Cangjie AI for Cursor
A Cursor editor extension that automatically adds a fixed prompt prefix for the Cangjie language (.cj files).
Features
- 🎯 Automatic
.cjFile Detection: Automatically activates when opening or switching to.cjfiles - 📝 Automatic
.cursorrulesManagement: Creates or updates the.cursorrulesfile in the workspace root directory - 🤖 Intelligent Prompt Prefixing: Automatically injects Cangjie-language–specific context and instructions into AI conversations
- ⚙️ Fully Configurable: Customize the prompt prefix via the settings UI or commands
- 🔄 Real-Time Updates: Configuration changes take effect immediately without restarting
- 🔌 Context7 MCP Integration: Automatically installs and configures the Context7 MCP server to provide up-to-date documentation and code examples
- 🛠️ Cangjie Toolchain Support: Built-in guidance for
cjpmcommands (init,build,run,test)
Installation
Install from the Marketplace
- Open the Cursor editor
- Press
Cmd+Shift+X(macOS) orCtrl+Shift+X(Windows/Linux) to open the Extensions Marketplace - Search for “Cangjie AI for Cursor”
- Click Install
Install from a VSIX File
- Download the
.vsixfile - In Cursor, press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type “Extensions: Install from VSIX…”
- Select the downloaded
.vsixfile
Usage
Basic Usage
- After installing the extension, open any
.cjfile - The extension automatically detects the file and updates the
.cursorrulesfile in the workspace root, adding the configured prompt prefix - When interacting with AI in Cursor, the prefix is automatically applied to all prompts
How It Works:
The extension creates or updates a .cursorrules file in the workspace root directory. This is an officially supported rule file format in Cursor. Cursor automatically reads this file and applies its contents to AI conversations, enabling the AI to better understand the Cangjie language syntax and best practices.
Configuring the Prompt Prefix
There are two ways to configure the prompt prefix:
Option 1: Via the Settings UI
- Open Cursor Settings (
Cmd+,orCtrl+,) - Search for “Cangjie AI for Cursor”
- Locate the “Prompt Prefix” setting
- Enter your desired prefix text
- Save the settings
Option 2: Via Command Palette
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type “Set Prompt Prefix”
- Enter the prefix text in the input box
- Confirm to save
Default Prompt Prefix
The default prompt prefix includes the following content:
- When handling Cangjie language–related questions, use the context7 MCP to retrieve Cangjie documentation and examples. Base responses and code generation on the retrieved documentation.
- Use the yolomao/cangjiecorpus-mirror repository to obtain Cangjie language documentation and examples.
- Use
cjpm initto create a project. - Use
cjpm buildto compile the project. - Use
cjpm runto run the project. - Use
cjpm testto test the project.
You can modify this content as needed.
Manually Updating .cursorrules
If you need to manually update the .cursorrules file:
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type “Update .cursorrules File”
- Execute the command to update the
.cursorrulesfile
Note:
The .cursorrules file is located in the workspace root directory. You can open and edit it directly to view or modify its contents.
Enable / Disable
In the settings, search for “Cangjie AI for Cursor” to find the “Enabled” option, which allows you to enable or disable this functionality.
Context7 MCP Integration
This extension automatically installs and configures the Context7 MCP server. Context7 MCP provides the Cursor AI assistant with the latest library documentation and code examples.
Automatic Configuration
When the extension is activated, it automatically:
- Installs the
@upstash/context7-mcpdependency - Configures the Context7 MCP server in
~/.cursor/mcp.json - Displays a notification indicating successful configuration
Manual Configuration
If you need to reconfigure Context7 MCP manually:
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type “Configure Context7 MCP”
- Execute the command and restart Cursor for the changes to take effect
Using Context7
After configuration, the extension automatically adds instructions to the .cursorrules file, guiding the AI on how to use Context7 MCP to locate Cangjie language documentation.
How It Works:
- The AI first uses the
resolve-library-idtool to locate the Cangjie language library (searching for “cangjie” or “仓颉”) - Then it uses the
get-library-docstool to retrieve relevant documentation and code examples - Responses and code are generated based on the retrieved documentation
Note:
If you encounter a “Library does not exist” error, it means you must first use resolve-library-id to identify the correct library ID, rather than directly using /cangjie/cangjie.
Verifying Context7 MCP Usage
-
Check Configuration Status:
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Type “Check Context7 MCP Status”
- Verify that the configuration has been correctly written
- Press
-
Inspect Console Logs:
- Open Developer Tools (Help > Toggle Developer Tools)
- Search for
[Context7 MCP]in the console to view detailed logs - You should see information such as configuration paths and content
-
Check the Configuration File:
- Configuration file location:
~/.cursor/mcp.json - Ensure that the file contains the
context7configuration
- Configuration file location:
-
Important Notes:
- MCP servers must be started by the Cursor main process
- Cursor must be restarted after writing the configuration for it to take effect
- In debug mode, MCP configurations may not be loaded (as the debug window runs in a separate process)
- To actually use MCP, the extension must be packaged and installed, rather than run in debug mode
Configuration File Location
The Context7 MCP configuration file is located at:
~/.cursor/mcp.json
Example configuration:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}