@opensumi/ide-ai-native 3.9.1-next-1749175927.0 → 3.9.1-next-1749196667.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ai-core.contribution.d.ts.map +1 -1
- package/lib/browser/ai-core.contribution.js +4 -9
- package/lib/browser/ai-core.contribution.js.map +1 -1
- package/lib/browser/chat/apply.service.d.ts +0 -3
- package/lib/browser/chat/apply.service.d.ts.map +1 -1
- package/lib/browser/chat/apply.service.js +0 -47
- package/lib/browser/chat/apply.service.js.map +1 -1
- package/lib/browser/chat/chat-manager.service.d.ts +0 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +3 -9
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +1 -8
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +76 -113
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +2 -0
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +57 -50
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.feature.registry.d.ts +1 -4
- package/lib/browser/chat/chat.feature.registry.d.ts.map +1 -1
- package/lib/browser/chat/chat.feature.registry.js +0 -6
- package/lib/browser/chat/chat.feature.registry.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +10 -51
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatEditor.js +2 -2
- package/lib/browser/components/ChatEditor.js.map +1 -1
- package/lib/browser/components/ChatHistory.d.ts.map +1 -1
- package/lib/browser/components/ChatHistory.js +1 -2
- package/lib/browser/components/ChatHistory.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +28 -124
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
- package/lib/browser/components/ChatToolRender.js +2 -7
- package/lib/browser/components/ChatToolRender.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +0 -25
- package/lib/browser/components/components.module.less +0 -7
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +13 -155
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +0 -165
- package/lib/browser/components/mention-input/types.d.ts +1 -15
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js +0 -1
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.service.d.ts +2 -21
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +20 -162
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -1
- package/lib/browser/contrib/terminal/terminal.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +0 -7
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout/ai-layout.d.ts.map +1 -1
- package/lib/browser/layout/ai-layout.js +4 -6
- package/lib/browser/layout/ai-layout.js.map +1 -1
- package/lib/browser/layout/tabbar.view.d.ts +1 -1
- package/lib/browser/layout/tabbar.view.d.ts.map +1 -1
- package/lib/browser/layout/tabbar.view.js +12 -5
- package/lib/browser/layout/tabbar.view.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +4 -5
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js +5 -23
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts +1 -3
- package/lib/browser/mcp/mcp-server-proxy.service.d.ts.map +1 -1
- package/lib/browser/mcp/mcp-server-proxy.service.js +0 -4
- package/lib/browser/mcp/mcp-server-proxy.service.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +1 -47
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +2 -127
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +0 -5
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/types.d.ts +1 -12
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/common/index.d.ts +1 -5
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +0 -2
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +0 -19
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +2 -0
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +29 -35
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/types.d.ts +0 -21
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js.map +1 -1
- package/lib/common/utils.d.ts +0 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +2 -5
- package/lib/common/utils.js.map +1 -1
- package/lib/node/base-language-model.d.ts +1 -2
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +1 -10
- package/lib/node/base-language-model.js.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.d.ts +1 -3
- package/lib/node/mcp/sumi-mcp-server.d.ts.map +1 -1
- package/lib/node/mcp/sumi-mcp-server.js +1 -7
- package/lib/node/mcp/sumi-mcp-server.js.map +1 -1
- package/lib/node/mcp-server-manager-impl.d.ts +1 -3
- package/lib/node/mcp-server-manager-impl.d.ts.map +1 -1
- package/lib/node/mcp-server-manager-impl.js +2 -14
- package/lib/node/mcp-server-manager-impl.js.map +1 -1
- package/package.json +24 -25
- package/src/browser/ai-core.contribution.ts +4 -14
- package/src/browser/chat/apply.service.ts +1 -62
- package/src/browser/chat/chat-manager.service.ts +7 -16
- package/src/browser/chat/chat-model.ts +73 -130
- package/src/browser/chat/chat-proxy.service.ts +81 -68
- package/src/browser/chat/chat.feature.registry.ts +1 -17
- package/src/browser/chat/chat.view.tsx +12 -74
- package/src/browser/components/ChatEditor.tsx +1 -1
- package/src/browser/components/ChatHistory.tsx +1 -2
- package/src/browser/components/ChatMentionInput.tsx +32 -144
- package/src/browser/components/ChatToolRender.module.less +0 -25
- package/src/browser/components/ChatToolRender.tsx +2 -10
- package/src/browser/components/components.module.less +0 -7
- package/src/browser/components/mention-input/mention-input.module.less +0 -165
- package/src/browser/components/mention-input/mention-input.tsx +29 -244
- package/src/browser/components/mention-input/types.ts +0 -15
- package/src/browser/context/llm-context.service.ts +21 -182
- package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts +1 -1
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +1 -1
- package/src/browser/contrib/terminal/terminal.feature.registry.ts +1 -1
- package/src/browser/index.ts +0 -8
- package/src/browser/layout/ai-layout.tsx +8 -12
- package/src/browser/layout/tabbar.view.tsx +23 -10
- package/src/browser/mcp/base-apply.service.ts +10 -30
- package/src/browser/mcp/mcp-server-proxy.service.ts +1 -6
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -1
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +1 -1
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -1
- package/src/browser/model/msg-history-manager.ts +2 -181
- package/src/browser/preferences/schema.ts +0 -5
- package/src/browser/types.ts +0 -18
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +1 -0
- package/src/common/index.ts +1 -6
- package/src/common/llm-context.ts +0 -23
- package/src/common/prompts/context-prompt-provider.ts +40 -55
- package/src/common/types.ts +0 -18
- package/src/common/utils.ts +1 -4
- package/src/node/base-language-model.ts +13 -10
- package/src/node/mcp/sumi-mcp-server.ts +2 -10
- package/src/node/mcp-server-manager-impl.ts +2 -17
- package/lib/browser/rules/rules.contribution.d.ts +0 -29
- package/lib/browser/rules/rules.contribution.d.ts.map +0 -1
- package/lib/browser/rules/rules.contribution.js +0 -94
- package/lib/browser/rules/rules.contribution.js.map +0 -1
- package/lib/browser/rules/rules.module.less +0 -174
- package/lib/browser/rules/rules.service.d.ts +0 -25
- package/lib/browser/rules/rules.service.d.ts.map +0 -1
- package/lib/browser/rules/rules.service.js +0 -180
- package/lib/browser/rules/rules.service.js.map +0 -1
- package/lib/browser/rules/rules.view.d.ts +0 -3
- package/lib/browser/rules/rules.view.d.ts.map +0 -1
- package/lib/browser/rules/rules.view.js +0 -76
- package/lib/browser/rules/rules.view.js.map +0 -1
- package/lib/common/MDC_PARSER_README.md +0 -171
- package/lib/common/image-compression.d.ts +0 -25
- package/lib/common/image-compression.d.ts.map +0 -1
- package/lib/common/image-compression.js +0 -153
- package/lib/common/image-compression.js.map +0 -1
- package/lib/common/mdc-parser.d.ts +0 -60
- package/lib/common/mdc-parser.d.ts.map +0 -1
- package/lib/common/mdc-parser.js +0 -246
- package/lib/common/mdc-parser.js.map +0 -1
- package/lib/common/prompts/system-prompt.d.ts +0 -2
- package/lib/common/prompts/system-prompt.d.ts.map +0 -1
- package/lib/common/prompts/system-prompt.js +0 -5
- package/lib/common/prompts/system-prompt.js.map +0 -1
- package/src/browser/rules/rules.contribution.ts +0 -105
- package/src/browser/rules/rules.module.less +0 -174
- package/src/browser/rules/rules.service.ts +0 -189
- package/src/browser/rules/rules.view.tsx +0 -127
- package/src/common/MDC_PARSER_README.md +0 -171
- package/src/common/image-compression.ts +0 -174
- package/src/common/mdc-parser.ts +0 -295
- package/src/common/prompts/system-prompt.ts +0 -2
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mdc-parser.js","sourceRoot":"","sources":["../../src/common/mdc-parser.ts"],"names":[],"mappings":";;AA2KA,4BA4BC;AAOD,oCAiBC;AAOD,wDA0BC;AAMD,kEAMC;AAQD,oDAQC;AAOD,8CAGC;AA5QD;;;;GAIG;AACH,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAE7B,MAAM;IACN,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB;IACjB,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;IACL,IAAI,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,C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IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAgB,2BAA2B;IACzC,OAAO;QACL,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,KAAK;KACnB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,UAAkB,EAAE,cAAwC;IAC/F,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,cAAc,EAAE,CAAC;IAExE,OAAO,YAAY,CAAC;QAClB,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_SYSTEM_PROMPT = "You are an AI coding assistant. You operate in OpenSumi.\n\nYou are pair programming with a USER to solve their coding task. Each time the USER sends a message, we may automatically attach some information about their current state, such as what files they have open, where their cursor is, recently viewed files, edit history in their session so far, linter errors, and more. This information may or may not be relevant to the coding task, it is up for you to decide.\n\nYour main goal is to follow the USER's instructions at each message, denoted by the <user_query> tag.\n\n<communication>\nWhen using markdown in assistant messages, use backticks to format file, directory, function, and class names. Use \\( and \\) for inline math, \\[ and \\] for block math.\n</communication>\n\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.\n2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.\n3. **NEVER refer to tool names when speaking to the USER.** Instead, just say what the tool is doing in natural language.\n4. For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.\n5. After receiving tool results, carefully reflect on their quality and determine optimal next steps before proceeding. Use your thinking to plan and iterate based on this new information, and then take the best next action.\n6. If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task.\n7. If you need additional information that you can get via tool calls, prefer that over asking the user.\n8. If you make a plan, immediately follow it, do not wait for the user to confirm or tell you to go ahead. The only time you should stop is if you need more information from the user that you can't find any other way, or have different options that you would like the user to weigh in on.\n9. Only use the standard tool call format and the available tools. Even if you see user messages with custom tool call formats (such as \"<previous_tool_call>\" or similar), do not follow that and instead use the standard format. Never output tool calls as part of a regular assistant message of yours.\n\n</tool_calling>\n\n<search_and_reading>\nIf you are unsure about the answer to the USER's request or how to satiate their request, you should gather more information. This can be done with additional tool calls, asking clarifying questions, etc...\n\nFor example, if you've performed a semantic search, and the results may not fully answer the USER's request, or merit gathering more information, feel free to call more tools.\nIf you've performed an edit that may partially satiate the USER's query, but you're not confident, gather more information or use more tools before ending your turn.\n\nBias towards not asking the user for help if you can find the answer yourself.\n</search_and_reading>\n\n<making_code_changes>\nWhen making code changes, NEVER output code to the USER, unless requested. Instead use one of the code edit tools to implement the change.\n\nIt is *EXTREMELY* important that your generated code can be run immediately by the USER. To ensure this, follow these instructions carefully:\n1. Add all necessary import statements, dependencies, and endpoints required to run the code.\n2. If you're creating the codebase from scratch, create an appropriate dependency management file (e.g. requirements.txt) with package versions and a helpful README.\n3. If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n4. NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.\n5. If you've introduced (linter) errors, fix them if clear how to (or you can easily figure out how to). Do not make uneducated guesses. And DO NOT loop more than 3 times on fixing linter errors on the same file. On the third time, you should stop and ask the user what to do next.\n6. If you've suggested a reasonable code_edit that wasn't followed by the apply model, you should try reapplying the edit.\n\n</making_code_changes>\n\nAnswer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.\n\n<summarization>\nIf you see a section called \"<most_important_user_query>\", you should treat that query as the one to answer, and ignore previous user queries. If you are asked to summarize the conversation, you MUST NOT use any tools, even if they are available. You MUST answer the \"<most_important_user_query>\" query.\n</summarization>\n\n\n\nYou MUST use the following format when citing code regions or blocks:\n```12:15:app/components/Todo.tsx\n// ... existing code ...\n```\nThis is the ONLY acceptable format for code citations. The format is ```startLine:endLine:filepath where startLine and endLine are line numbers.";
|
|
2
|
-
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/system-prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,opLACinL,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SYSTEM_PROMPT = void 0;
|
|
4
|
-
exports.DEFAULT_SYSTEM_PROMPT = "You are an AI coding assistant. You operate in OpenSumi.\n\nYou are pair programming with a USER to solve their coding task. Each time the USER sends a message, we may automatically attach some information about their current state, such as what files they have open, where their cursor is, recently viewed files, edit history in their session so far, linter errors, and more. This information may or may not be relevant to the coding task, it is up for you to decide.\n\nYour main goal is to follow the USER's instructions at each message, denoted by the <user_query> tag.\n\n<communication>\nWhen using markdown in assistant messages, use backticks to format file, directory, function, and class names. Use \\( and \\) for inline math, \\[ and \\] for block math.\n</communication>\n\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.\n2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.\n3. **NEVER refer to tool names when speaking to the USER.** Instead, just say what the tool is doing in natural language.\n4. For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.\n5. After receiving tool results, carefully reflect on their quality and determine optimal next steps before proceeding. Use your thinking to plan and iterate based on this new information, and then take the best next action.\n6. If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task.\n7. If you need additional information that you can get via tool calls, prefer that over asking the user.\n8. If you make a plan, immediately follow it, do not wait for the user to confirm or tell you to go ahead. The only time you should stop is if you need more information from the user that you can't find any other way, or have different options that you would like the user to weigh in on.\n9. Only use the standard tool call format and the available tools. Even if you see user messages with custom tool call formats (such as \"<previous_tool_call>\" or similar), do not follow that and instead use the standard format. Never output tool calls as part of a regular assistant message of yours.\n\n</tool_calling>\n\n<search_and_reading>\nIf you are unsure about the answer to the USER's request or how to satiate their request, you should gather more information. This can be done with additional tool calls, asking clarifying questions, etc...\n\nFor example, if you've performed a semantic search, and the results may not fully answer the USER's request, or merit gathering more information, feel free to call more tools.\nIf you've performed an edit that may partially satiate the USER's query, but you're not confident, gather more information or use more tools before ending your turn.\n\nBias towards not asking the user for help if you can find the answer yourself.\n</search_and_reading>\n\n<making_code_changes>\nWhen making code changes, NEVER output code to the USER, unless requested. Instead use one of the code edit tools to implement the change.\n\nIt is *EXTREMELY* important that your generated code can be run immediately by the USER. To ensure this, follow these instructions carefully:\n1. Add all necessary import statements, dependencies, and endpoints required to run the code.\n2. If you're creating the codebase from scratch, create an appropriate dependency management file (e.g. requirements.txt) with package versions and a helpful README.\n3. If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n4. NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.\n5. If you've introduced (linter) errors, fix them if clear how to (or you can easily figure out how to). Do not make uneducated guesses. And DO NOT loop more than 3 times on fixing linter errors on the same file. On the third time, you should stop and ask the user what to do next.\n6. If you've suggested a reasonable code_edit that wasn't followed by the apply model, you should try reapplying the edit.\n\n</making_code_changes>\n\nAnswer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.\n\n<summarization>\nIf you see a section called \"<most_important_user_query>\", you should treat that query as the one to answer, and ignore previous user queries. If you are asked to summarize the conversation, you MUST NOT use any tools, even if they are available. You MUST answer the \"<most_important_user_query>\" query.\n</summarization>\n\n\n\nYou MUST use the following format when citing code regions or blocks:\n```12:15:app/components/Todo.tsx\n// ... existing code ...\n```\nThis is the ONLY acceptable format for code citations. The format is ```startLine:endLine:filepath where startLine and endLine are line numbers.";
|
|
5
|
-
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/common/prompts/system-prompt.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAChC,ipLAAipL,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Autowired } from '@opensumi/di';
|
|
2
|
-
import { getIcon } from '@opensumi/ide-components';
|
|
3
|
-
import { ClientAppContribution } from '@opensumi/ide-core-browser';
|
|
4
|
-
import { LabelService } from '@opensumi/ide-core-browser/lib/services';
|
|
5
|
-
import {
|
|
6
|
-
CommandContribution,
|
|
7
|
-
CommandRegistry,
|
|
8
|
-
Domain,
|
|
9
|
-
RulesServiceToken,
|
|
10
|
-
URI,
|
|
11
|
-
localize,
|
|
12
|
-
} from '@opensumi/ide-core-common';
|
|
13
|
-
import {
|
|
14
|
-
BrowserEditorContribution,
|
|
15
|
-
EditorComponentRegistry,
|
|
16
|
-
EditorComponentRenderMode,
|
|
17
|
-
IResource,
|
|
18
|
-
ResourceService,
|
|
19
|
-
WorkbenchEditorService,
|
|
20
|
-
} from '@opensumi/ide-editor/lib/browser/types';
|
|
21
|
-
import { IconService } from '@opensumi/ide-theme/lib/browser';
|
|
22
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace/lib/common';
|
|
23
|
-
|
|
24
|
-
import { RulesService } from './rules.service';
|
|
25
|
-
import { RulesView } from './rules.view';
|
|
26
|
-
|
|
27
|
-
export namespace RulesCommands {
|
|
28
|
-
export const OPEN_RULES_FILE = {
|
|
29
|
-
id: 'rules.openRulesConfig',
|
|
30
|
-
label: 'Open Rules Configuration',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const COMPONENTS_ID = 'opensumi-rules-viewer';
|
|
35
|
-
export const RULES_COMPONENTS_SCHEME_ID = 'rules';
|
|
36
|
-
|
|
37
|
-
export type IRulesResource = IResource<{ configType: string }>;
|
|
38
|
-
|
|
39
|
-
@Domain(BrowserEditorContribution, CommandContribution, ClientAppContribution)
|
|
40
|
-
export class RulesContribution implements BrowserEditorContribution, CommandContribution, ClientAppContribution {
|
|
41
|
-
@Autowired(IWorkspaceService)
|
|
42
|
-
protected readonly workspaceService: IWorkspaceService;
|
|
43
|
-
|
|
44
|
-
@Autowired(IconService)
|
|
45
|
-
protected readonly iconService: IconService;
|
|
46
|
-
|
|
47
|
-
@Autowired(WorkbenchEditorService)
|
|
48
|
-
protected readonly editorService: WorkbenchEditorService;
|
|
49
|
-
|
|
50
|
-
@Autowired()
|
|
51
|
-
labelService: LabelService;
|
|
52
|
-
|
|
53
|
-
@Autowired(RulesServiceToken)
|
|
54
|
-
protected readonly rulesService: RulesService;
|
|
55
|
-
|
|
56
|
-
onStart() {
|
|
57
|
-
this.rulesService.initProjectRules();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
registerEditorComponent(registry: EditorComponentRegistry) {
|
|
61
|
-
registry.registerEditorComponent({
|
|
62
|
-
uid: COMPONENTS_ID,
|
|
63
|
-
scheme: RULES_COMPONENTS_SCHEME_ID,
|
|
64
|
-
component: RulesView,
|
|
65
|
-
renderMode: EditorComponentRenderMode.ONE_PER_WORKBENCH,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
registry.registerEditorComponentResolver(RULES_COMPONENTS_SCHEME_ID, (resource, results) => {
|
|
69
|
-
results.push({
|
|
70
|
-
type: 'component',
|
|
71
|
-
componentId: COMPONENTS_ID,
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
registerResource(service: ResourceService) {
|
|
77
|
-
service.registerResourceProvider({
|
|
78
|
-
scheme: RULES_COMPONENTS_SCHEME_ID,
|
|
79
|
-
provideResource: async (uri: URI): Promise<IRulesResource> => {
|
|
80
|
-
const { configType } = uri.getParsedQuery();
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
uri,
|
|
84
|
-
name: localize('ai.native.rules.title'),
|
|
85
|
-
icon: getIcon('rules'),
|
|
86
|
-
metadata: {
|
|
87
|
-
configType,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
registerCommands(registry: CommandRegistry) {
|
|
95
|
-
registry.registerCommand(RulesCommands.OPEN_RULES_FILE, {
|
|
96
|
-
execute: () => {
|
|
97
|
-
const uri = new URI().withScheme(RULES_COMPONENTS_SCHEME_ID);
|
|
98
|
-
this.editorService.open(uri, {
|
|
99
|
-
preview: false,
|
|
100
|
-
focus: true,
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
padding: 20px;
|
|
3
|
-
color: var(--foreground);
|
|
4
|
-
textarea {
|
|
5
|
-
resize: vertical;
|
|
6
|
-
min-height: 60px;
|
|
7
|
-
}
|
|
8
|
-
input,
|
|
9
|
-
textarea {
|
|
10
|
-
width: 100%;
|
|
11
|
-
padding: 8px;
|
|
12
|
-
border: 1px solid var(--input-border);
|
|
13
|
-
border-radius: 4px;
|
|
14
|
-
background-color: var(--input-background);
|
|
15
|
-
color: var(--input-foreground);
|
|
16
|
-
font-size: 13px;
|
|
17
|
-
font-family: var(--monaco-monospace-font);
|
|
18
|
-
|
|
19
|
-
&:focus {
|
|
20
|
-
border-color: var(--focusBorder);
|
|
21
|
-
outline: none;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&::placeholder {
|
|
25
|
-
color: var(--descriptionForeground);
|
|
26
|
-
opacity: 0.6;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.header {
|
|
32
|
-
display: flex;
|
|
33
|
-
justify-content: space-between;
|
|
34
|
-
align-items: flex-start;
|
|
35
|
-
margin-bottom: 24px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.title {
|
|
39
|
-
margin: 0 0 8px 0;
|
|
40
|
-
font-size: 24px;
|
|
41
|
-
font-weight: 600;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.description {
|
|
45
|
-
margin: 0;
|
|
46
|
-
color: var(--descriptionForeground);
|
|
47
|
-
font-size: 14px;
|
|
48
|
-
line-height: 1.5;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.user_rules {
|
|
52
|
-
display: flex;
|
|
53
|
-
flex-direction: column;
|
|
54
|
-
gap: 16px;
|
|
55
|
-
.user_rules_header {
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.project_rules {
|
|
62
|
-
margin-top: 20px;
|
|
63
|
-
display: flex;
|
|
64
|
-
flex-direction: column;
|
|
65
|
-
gap: 16px;
|
|
66
|
-
h3 {
|
|
67
|
-
position: relative;
|
|
68
|
-
}
|
|
69
|
-
.actionButton {
|
|
70
|
-
position: absolute;
|
|
71
|
-
right: 0;
|
|
72
|
-
top: 0;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.project_rules_header {
|
|
77
|
-
display: flex;
|
|
78
|
-
justify-content: space-between;
|
|
79
|
-
align-items: flex-start;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.project_rules_header_left {
|
|
83
|
-
display: flex;
|
|
84
|
-
flex-direction: column;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.actionButton {
|
|
88
|
-
padding: 8px 16px;
|
|
89
|
-
border-radius: 4px;
|
|
90
|
-
background-color: var(--button-primary-background);
|
|
91
|
-
color: var(--button-primary-foreground);
|
|
92
|
-
border: none;
|
|
93
|
-
cursor: pointer;
|
|
94
|
-
font-size: 13px;
|
|
95
|
-
.actionButtonIcon {
|
|
96
|
-
margin-right: 5px;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&:hover {
|
|
100
|
-
background-color: var(--button-primary-hover-background);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.project_rules_list {
|
|
105
|
-
display: flex;
|
|
106
|
-
flex-direction: column;
|
|
107
|
-
gap: 8px;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.rule_item {
|
|
111
|
-
display: flex;
|
|
112
|
-
justify-content: space-between;
|
|
113
|
-
align-items: center;
|
|
114
|
-
padding: 12px;
|
|
115
|
-
border: 1px solid var(--input-border);
|
|
116
|
-
border-radius: 4px;
|
|
117
|
-
background-color: var(--input-background);
|
|
118
|
-
opacity: 0.6;
|
|
119
|
-
|
|
120
|
-
&:hover {
|
|
121
|
-
opacity: 1;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.rule_item_left {
|
|
126
|
-
display: flex;
|
|
127
|
-
flex-direction: column;
|
|
128
|
-
gap: 4px;
|
|
129
|
-
flex: 1;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.rule_item_right {
|
|
133
|
-
display: flex;
|
|
134
|
-
align-items: center;
|
|
135
|
-
flex-shrink: 0;
|
|
136
|
-
margin-left: 16px;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.rule_filename {
|
|
140
|
-
font-size: 13px;
|
|
141
|
-
font-weight: 500;
|
|
142
|
-
color: var(--foreground);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.rule_description {
|
|
146
|
-
font-size: 12px;
|
|
147
|
-
color: var(--descriptionForeground);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.rule_warning {
|
|
151
|
-
font-size: 12px;
|
|
152
|
-
color: var(--editorWarning-foreground);
|
|
153
|
-
display: flex;
|
|
154
|
-
align-items: center;
|
|
155
|
-
gap: 4px;
|
|
156
|
-
|
|
157
|
-
&::before {
|
|
158
|
-
content: '⚠';
|
|
159
|
-
color: var(--editorWarning-foreground);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.rule_applies_to {
|
|
164
|
-
font-size: 12px;
|
|
165
|
-
color: var(--descriptionForeground);
|
|
166
|
-
font-family: var(--monaco-monospace-font);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.empty_state {
|
|
170
|
-
text-align: center;
|
|
171
|
-
padding: 32px;
|
|
172
|
-
color: var(--descriptionForeground);
|
|
173
|
-
font-style: italic;
|
|
174
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
-
import { VALIDATE_TYPE } from '@opensumi/ide-components';
|
|
3
|
-
import { AppConfig, PreferenceService } from '@opensumi/ide-core-browser';
|
|
4
|
-
import {
|
|
5
|
-
AINativeSettingSectionsId,
|
|
6
|
-
Disposable,
|
|
7
|
-
Emitter,
|
|
8
|
-
URI,
|
|
9
|
-
formatLocalize,
|
|
10
|
-
localize,
|
|
11
|
-
} from '@opensumi/ide-core-common';
|
|
12
|
-
import { WorkbenchEditorService } from '@opensumi/ide-editor';
|
|
13
|
-
import { IFileServiceClient } from '@opensumi/ide-file-service';
|
|
14
|
-
import { QuickInputService } from '@opensumi/ide-quick-open/lib/browser/quick-input-service';
|
|
15
|
-
import { WorkspaceService } from '@opensumi/ide-workspace/lib/browser/workspace-service';
|
|
16
|
-
import { IWorkspaceService } from '@opensumi/ide-workspace/lib/common';
|
|
17
|
-
|
|
18
|
-
import { IMDCContent, IMDCParseResult, parseMDC, serializeMDC } from '../../common';
|
|
19
|
-
import { ProjectRule } from '../../common/types';
|
|
20
|
-
|
|
21
|
-
@Injectable()
|
|
22
|
-
export class RulesService extends Disposable {
|
|
23
|
-
@Autowired(PreferenceService)
|
|
24
|
-
private readonly preferenceService: PreferenceService;
|
|
25
|
-
|
|
26
|
-
@Autowired(AppConfig)
|
|
27
|
-
private readonly appConfig: AppConfig;
|
|
28
|
-
|
|
29
|
-
@Autowired(IWorkspaceService)
|
|
30
|
-
private readonly workspaceService: WorkspaceService;
|
|
31
|
-
|
|
32
|
-
@Autowired(IFileServiceClient)
|
|
33
|
-
private readonly fileServiceClient: IFileServiceClient;
|
|
34
|
-
|
|
35
|
-
@Autowired(QuickInputService)
|
|
36
|
-
private readonly quickInputService: QuickInputService;
|
|
37
|
-
|
|
38
|
-
@Autowired(WorkbenchEditorService)
|
|
39
|
-
private readonly workbenchEditorService: WorkbenchEditorService;
|
|
40
|
-
|
|
41
|
-
private readonly rulesChangeEventEmitter = new Emitter<void>();
|
|
42
|
-
|
|
43
|
-
private _globalRules: string;
|
|
44
|
-
private _projectRules: ProjectRule[];
|
|
45
|
-
|
|
46
|
-
private _projectRulesPath: string;
|
|
47
|
-
|
|
48
|
-
get onRulesChange() {
|
|
49
|
-
return this.rulesChangeEventEmitter.event;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
get globalRules() {
|
|
53
|
-
if (!this._globalRules) {
|
|
54
|
-
this._globalRules = this.preferenceService.get<string>(AINativeSettingSectionsId.GlobalRules) || '';
|
|
55
|
-
}
|
|
56
|
-
return this._globalRules;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
get projectRules() {
|
|
60
|
-
return this._projectRules || [];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public async initProjectRules() {
|
|
64
|
-
this.dispose();
|
|
65
|
-
await this.workspaceService.whenReady;
|
|
66
|
-
const workspace = this.workspaceService.workspace;
|
|
67
|
-
// 如果存在 .sumi, 默认从 .sumi 中获取
|
|
68
|
-
const sumiConfigPath = new URI(workspace?.uri)
|
|
69
|
-
.resolve(this.appConfig.preferenceDirName || '.sumi')
|
|
70
|
-
.resolve('rules');
|
|
71
|
-
const cursorConfigPath = new URI(workspace?.uri).resolve('.cursor').resolve('rules');
|
|
72
|
-
if (await this.fileServiceClient.access(sumiConfigPath.codeUri.fsPath)) {
|
|
73
|
-
this._projectRulesPath = sumiConfigPath.codeUri.fsPath;
|
|
74
|
-
} else if (await this.fileServiceClient.access(cursorConfigPath.codeUri.fsPath)) {
|
|
75
|
-
this._projectRulesPath = cursorConfigPath.codeUri.fsPath;
|
|
76
|
-
} else {
|
|
77
|
-
this._projectRulesPath = sumiConfigPath.codeUri.fsPath;
|
|
78
|
-
}
|
|
79
|
-
const watcher = await this.fileServiceClient.watchFileChanges(new URI(this._projectRulesPath));
|
|
80
|
-
this.addDispose(
|
|
81
|
-
watcher.onFilesChanged((changes) => {
|
|
82
|
-
if (
|
|
83
|
-
changes.length > 0 &&
|
|
84
|
-
changes.some((change) => change.uri.endsWith('.mdc') && change.uri.includes('rules'))
|
|
85
|
-
) {
|
|
86
|
-
this.initProjectRules();
|
|
87
|
-
}
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
const dir = await this.fileServiceClient.getFileStat(this._projectRulesPath);
|
|
91
|
-
if (dir && dir.isDirectory) {
|
|
92
|
-
const files = dir.children?.filter((file) => !file.isDirectory && file.uri.endsWith('.mdc'));
|
|
93
|
-
if (files) {
|
|
94
|
-
const rules = await Promise.all(
|
|
95
|
-
files.map(async (file) => {
|
|
96
|
-
const item = await this.fileServiceClient.readFile(file.uri);
|
|
97
|
-
const data = this.parseMDCContent(item.content.toString());
|
|
98
|
-
return {
|
|
99
|
-
path: file.uri,
|
|
100
|
-
...data.frontmatter,
|
|
101
|
-
content: data.content,
|
|
102
|
-
};
|
|
103
|
-
}),
|
|
104
|
-
);
|
|
105
|
-
if (rules.length > 0) {
|
|
106
|
-
this._projectRules = rules;
|
|
107
|
-
this.rulesChangeEventEmitter.fire();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
this._projectRules = [];
|
|
113
|
-
this.rulesChangeEventEmitter.fire();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async openRule(rule: ProjectRule) {
|
|
117
|
-
this.workbenchEditorService.open(new URI(rule.path));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async createNewRule() {
|
|
121
|
-
let value = await this.quickInputService.open({
|
|
122
|
-
title: localize('ai.native.rules.projectRules.newRule'),
|
|
123
|
-
value: '',
|
|
124
|
-
placeHolder: localize('ai.native.rules.projectRules.newRule.placeholder'),
|
|
125
|
-
validateInput: async (value) => {
|
|
126
|
-
const invalidCharsRegex = /[<>:"/\\|?*\x00-\x1F]/;
|
|
127
|
-
value = value.trim();
|
|
128
|
-
if (value === '') {
|
|
129
|
-
return {
|
|
130
|
-
message: localize('ai.native.rules.projectRules.newRule.error.notEmpty'),
|
|
131
|
-
type: VALIDATE_TYPE.ERROR,
|
|
132
|
-
};
|
|
133
|
-
} else if (invalidCharsRegex.test(value)) {
|
|
134
|
-
return {
|
|
135
|
-
message: localize('ai.native.rules.error.invalidFileName'),
|
|
136
|
-
type: VALIDATE_TYPE.ERROR,
|
|
137
|
-
};
|
|
138
|
-
} else {
|
|
139
|
-
const newRulePath = new URI(this._projectRulesPath).resolve(value + '.mdc');
|
|
140
|
-
const fileExists = this.projectRules.find(
|
|
141
|
-
(rule) => new URI(rule.path).codeUri.fsPath === newRulePath.codeUri.fsPath,
|
|
142
|
-
);
|
|
143
|
-
if (fileExists) {
|
|
144
|
-
return {
|
|
145
|
-
message: formatLocalize('ai.native.rules.error.fileExists', value + '.mdc'),
|
|
146
|
-
type: VALIDATE_TYPE.ERROR,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
value = value?.trim();
|
|
153
|
-
if (value) {
|
|
154
|
-
const newRulePath = new URI(this._projectRulesPath).resolve(value + '.mdc');
|
|
155
|
-
await this.fileServiceClient.createFile(newRulePath.toString(), {
|
|
156
|
-
content: this.serializeMDCContent({
|
|
157
|
-
frontmatter: {
|
|
158
|
-
description: '',
|
|
159
|
-
globs: '',
|
|
160
|
-
alwaysApply: false,
|
|
161
|
-
},
|
|
162
|
-
content: '',
|
|
163
|
-
}),
|
|
164
|
-
});
|
|
165
|
-
this.workbenchEditorService.open(new URI(newRulePath.toString()));
|
|
166
|
-
this.initProjectRules();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
updateGlobalRules(rules: string) {
|
|
171
|
-
this._globalRules = rules;
|
|
172
|
-
this.preferenceService.set(AINativeSettingSectionsId.GlobalRules, rules);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
parseMDCContent(content: string): IMDCParseResult {
|
|
176
|
-
try {
|
|
177
|
-
return parseMDC(content);
|
|
178
|
-
} catch (error) {
|
|
179
|
-
return {
|
|
180
|
-
frontmatter: {},
|
|
181
|
-
content,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
serializeMDCContent(mdcContent: IMDCContent): string {
|
|
187
|
-
return serializeMDC(mdcContent);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Icon } from '@opensumi/ide-components';
|
|
4
|
-
import { useInjectable } from '@opensumi/ide-core-browser';
|
|
5
|
-
import { RulesServiceToken, localize } from '@opensumi/ide-core-common';
|
|
6
|
-
|
|
7
|
-
import { ProjectRule } from '../../common/types';
|
|
8
|
-
|
|
9
|
-
import styles from './rules.module.less';
|
|
10
|
-
import { RulesService } from './rules.service';
|
|
11
|
-
|
|
12
|
-
export const RulesView: React.FC = () => {
|
|
13
|
-
const rulesService = useInjectable<RulesService>(RulesServiceToken);
|
|
14
|
-
const [globalRules, setGlobalRules] = useState<string>(rulesService.globalRules as string);
|
|
15
|
-
const [projectRules, setProjectRules] = useState<ProjectRule[]>([]);
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
setProjectRules(rulesService.projectRules);
|
|
19
|
-
}, [rulesService]);
|
|
20
|
-
|
|
21
|
-
const handleGlobalRulesChange = useCallback(
|
|
22
|
-
(e) => {
|
|
23
|
-
setGlobalRules(e.target.value);
|
|
24
|
-
rulesService.updateGlobalRules(e.target.value);
|
|
25
|
-
},
|
|
26
|
-
[rulesService, globalRules],
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const handleCreateNewRule = useCallback(() => {
|
|
30
|
-
rulesService.createNewRule();
|
|
31
|
-
}, [rulesService]);
|
|
32
|
-
|
|
33
|
-
const handleOpenRule = useCallback(
|
|
34
|
-
(rule: ProjectRule) => {
|
|
35
|
-
rulesService.openRule(rule);
|
|
36
|
-
},
|
|
37
|
-
[rulesService],
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const getFileNameFromPath = (path: string) => path.split('/').pop() || path;
|
|
41
|
-
|
|
42
|
-
const hasWarning = (rule: ProjectRule) => !rule.description && !rule.alwaysApply && !rule.globs;
|
|
43
|
-
|
|
44
|
-
const getAppliesToText = (rule: ProjectRule) => {
|
|
45
|
-
if (rule.globs) {
|
|
46
|
-
if (Array.isArray(rule.globs)) {
|
|
47
|
-
return `Applies to: ${rule.globs.join(', ')}`;
|
|
48
|
-
} else {
|
|
49
|
-
return `Applies to: ${rule.globs}`;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return '';
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
const disposable = rulesService.onRulesChange(() => {
|
|
57
|
-
setProjectRules(rulesService.projectRules);
|
|
58
|
-
});
|
|
59
|
-
return () => {
|
|
60
|
-
disposable.dispose();
|
|
61
|
-
};
|
|
62
|
-
}, []);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<div className={styles.container}>
|
|
66
|
-
<div className={styles.header}>
|
|
67
|
-
<div>
|
|
68
|
-
<h2 className={styles.title}>{localize('ai.native.rules.title')}</h2>
|
|
69
|
-
<p className={styles.description}>{localize('ai.native.rules.description')}</p>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
<div className={styles.user_rules}>
|
|
73
|
-
<div className={styles.user_rules_header}>
|
|
74
|
-
<h3 className={styles.title}>{localize('ai.native.rules.userRules.title')}</h3>
|
|
75
|
-
<p className={styles.description}>{localize('ai.native.rules.userRules.description')}</p>
|
|
76
|
-
</div>
|
|
77
|
-
<div className={styles.user_rules_content}>
|
|
78
|
-
<textarea
|
|
79
|
-
rows={6}
|
|
80
|
-
placeholder={localize('ai.native.rules.userRules.placeholder')}
|
|
81
|
-
value={globalRules}
|
|
82
|
-
onChange={handleGlobalRulesChange}
|
|
83
|
-
style={{ resize: 'none' }}
|
|
84
|
-
/>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
<div className={styles.project_rules}>
|
|
88
|
-
<div className={styles.project_rules_header}>
|
|
89
|
-
<div className={styles.project_rules_header_left}>
|
|
90
|
-
<h3 className={styles.title}>
|
|
91
|
-
{localize('ai.native.rules.projectRules.title')}
|
|
92
|
-
<button className={styles.actionButton} onClick={handleCreateNewRule}>
|
|
93
|
-
<Icon icon='plus' className={styles.actionButtonIcon} />
|
|
94
|
-
{localize('ai.native.rules.projectRules.newRule')}
|
|
95
|
-
</button>
|
|
96
|
-
</h3>
|
|
97
|
-
<p className={styles.description}>{localize('ai.native.rules.projectRules.description')}</p>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
<div className={styles.project_rules_content}>
|
|
101
|
-
{projectRules.length > 0 ? (
|
|
102
|
-
<div className={styles.project_rules_list}>
|
|
103
|
-
{projectRules.map((rule, index) => (
|
|
104
|
-
<div key={index} className={styles.rule_item} onClick={() => handleOpenRule(rule)}>
|
|
105
|
-
<div className={styles.rule_item_left}>
|
|
106
|
-
<div className={styles.rule_filename}>{getFileNameFromPath(rule.path)}</div>
|
|
107
|
-
{rule.description && <div className={styles.rule_description}>{rule.description}</div>}
|
|
108
|
-
{hasWarning(rule) && (
|
|
109
|
-
<div className={styles.rule_warning}>
|
|
110
|
-
This rule may never be used since it has no description or auto attachments
|
|
111
|
-
</div>
|
|
112
|
-
)}
|
|
113
|
-
</div>
|
|
114
|
-
<div className={styles.rule_item_right}>
|
|
115
|
-
{getAppliesToText(rule) && <div className={styles.rule_applies_to}>{getAppliesToText(rule)}</div>}
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
))}
|
|
119
|
-
</div>
|
|
120
|
-
) : (
|
|
121
|
-
<div className={styles.empty_state}>{localize('ai.native.rules.projectRules.empty')}</div>
|
|
122
|
-
)}
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
};
|