-
Notifications
You must be signed in to change notification settings - Fork 863
feat: add Trae IDE support to configuration #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4b0c7b9
b7b78f1
d7b7e4a
22073e8
d791c37
2017f0b
589f601
9ed2bf2
8be4148
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # 增加对 Trae IDE 的支持 | ||
|
|
||
| ## Why | ||
|
|
||
| Trae IDE 是一个新兴的 AI 驱动开发环境,需要与 OpenSpec 集成以支持规范驱动的开发工作流。目前 OpenSpec 支持多种 AI 工具(Claude、Cline、CodeBuddy 等),但缺少对 Trae IDE 的支持。 | ||
|
|
||
| ## What Changes | ||
|
|
||
| - 添加 `TraeConfigurator` 类,实现 `ToolConfigurator` 接口 | ||
| - 在 `ToolRegistry` 中注册 Trae 配置器 | ||
| - 支持在项目根目录的 `.trae/rules/project_rules.md` 文件中注入 OpenSpec 指令 | ||
| - 遵循现有的配置器模式,使用 OPENSPEC 标记管理内容 | ||
|
|
||
| ## Impact | ||
|
|
||
| - affected specs: `cli-init` (初始化命令需要支持 Trae 选项) | ||
| - affected code: | ||
| - `src/core/configurators/trae.ts` (新文件) | ||
| - `src/core/configurators/registry.ts` (注册新配置器) | ||
| - 相关测试文件 | ||
| - 向后兼容:不影响现有功能 | ||
| - 用户体验:Trae IDE 用户可以通过 `openspec init` 自动配置项目规则 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # CLI Init 规范增量变更 | ||
|
|
||
| ## ADDED Requirements | ||
|
|
||
| ### Requirement: Trae IDE 配置支持 | ||
| 系统 SHALL 支持为 Trae IDE 生成项目配置文件。 | ||
|
|
||
| #### Scenario: 用户选择 Trae IDE 工具 | ||
| - **WHEN** 用户在初始化过程中选择 Trae IDE 作为 AI 工具 | ||
| - **THEN** 系统应在 `.trae/rules/project_rules.md` 文件中注入 OpenSpec 指令 | ||
| - **AND** 使用 OPENSPEC 标记管理内容块 | ||
| - **AND** 内容应包含项目特定的 OpenSpec 使用说明 | ||
|
|
||
| #### Scenario: Trae 配置文件已存在 | ||
| - **WHEN** 项目中已存在 `.trae/rules/project_rules.md` 文件 | ||
| - **THEN** 系统应使用 OPENSPEC 标记更新现有文件 | ||
| - **AND** 保留文件中的其他内容不变 | ||
| - **AND** 仅更新 OPENSPEC 标记之间的内容 | ||
|
|
||
| #### Scenario: Trae 目录不存在 | ||
| - **WHEN** 项目中不存在 `.trae/rules/` 目录 | ||
| - **THEN** 系统应自动创建必要的目录结构 | ||
| - **AND** 创建 `project_rules.md` 文件 | ||
| - **AND** 注入完整的 OpenSpec 配置内容 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # 实现任务 | ||
|
|
||
| ## 1. 核心实现 | ||
| - [ ] 1.1 创建 `src/core/configurators/trae.ts` 文件 | ||
| - [ ] 1.2 实现 `TraeConfigurator` 类,继承 `ToolConfigurator` 接口 | ||
| - [ ] 1.3 配置目标文件路径为 `.trae/rules/project_rules.md` | ||
| - [ ] 1.4 使用 `TemplateManager.getAgentsStandardTemplate()` 获取模板内容 | ||
|
|
||
| ## 2. 注册集成 | ||
| - [ ] 2.1 在 `src/core/configurators/registry.ts` 中导入 `TraeConfigurator` | ||
| - [ ] 2.2 在 `ToolRegistry` 静态块中注册 Trae 配置器 | ||
| - [ ] 2.3 使用 'trae' 作为工具 ID | ||
|
|
||
| ## 3. 测试验证 | ||
| - [ ] 3.1 创建单元测试文件 `test/core/configurators/trae.test.ts` | ||
| - [ ] 3.2 测试配置器的基本功能 | ||
| - [ ] 3.3 验证文件路径和内容生成 | ||
| - [ ] 3.4 运行现有测试确保无回归 | ||
|
|
||
| ## 4. 文档更新 | ||
| - [ ] 4.1 确认 CLI 初始化命令自动包含新的配置器 | ||
| - [ ] 4.2 验证 `openspec init` 命令中 Trae 选项可用 | ||
|
Comment on lines
+1
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mark completed tasks as done. All tasks listed in this file have been implemented:
As per coding guidelines, mark each completed item with Apply this diff to mark all tasks as complete: # 实现任务
## 1. 核心实现
-- [ ] 1.1 创建 `src/core/configurators/trae.ts` 文件
-- [ ] 1.2 实现 `TraeConfigurator` 类,继承 `ToolConfigurator` 接口
-- [ ] 1.3 配置目标文件路径为 `.trae/rules/project_rules.md`
-- [ ] 1.4 使用 `TemplateManager.getAgentsStandardTemplate()` 获取模板内容
+- [x] 1.1 创建 `src/core/configurators/trae.ts` 文件
+- [x] 1.2 实现 `TraeConfigurator` 类,继承 `ToolConfigurator` 接口
+- [x] 1.3 配置目标文件路径为 `.trae/rules/project_rules.md`
+- [x] 1.4 使用 `TemplateManager.getAgentsStandardTemplate()` 获取模板内容
## 2. 注册集成
-- [ ] 2.1 在 `src/core/configurators/registry.ts` 中导入 `TraeConfigurator`
-- [ ] 2.2 在 `ToolRegistry` 静态块中注册 Trae 配置器
-- [ ] 2.3 使用 'trae' 作为工具 ID
+- [x] 2.1 在 `src/core/configurators/registry.ts` 中导入 `TraeConfigurator`
+- [x] 2.2 在 `ToolRegistry` 静态块中注册 Trae 配置器
+- [x] 2.3 使用 'trae' 作为工具 ID
## 3. 测试验证
-- [ ] 3.1 创建单元测试文件 `test/core/configurators/trae.test.ts`
-- [ ] 3.2 测试配置器的基本功能
-- [ ] 3.3 验证文件路径和内容生成
-- [ ] 3.4 运行现有测试确保无回归
+- [x] 3.1 创建单元测试文件 `test/core/configurators/trae.test.ts`
+- [x] 3.2 测试配置器的基本功能
+- [x] 3.3 验证文件路径和内容生成
+- [x] 3.4 运行现有测试确保无回归
## 4. 文档更新
-- [ ] 4.1 确认 CLI 初始化命令自动包含新的配置器
-- [ ] 4.2 验证 `openspec init` 命令中 Trae 选项可用
+- [x] 4.1 确认 CLI 初始化命令自动包含新的配置器
+- [x] 4.2 验证 `openspec init` 命令中 Trae 选项可用🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ## Why | ||
| Current validation output is designed for human consumption but lacks structured data that tools and scripts can easily parse. Adding JSON output support will enable better integration with CI/CD pipelines, IDE extensions, and automated tooling. | ||
|
|
||
| ## What Changes | ||
| - Add a `--json` flag to the `openspec validate` command that outputs validation results in structured JSON format | ||
| - Update validation logic to include detailed error information, file paths, and line numbers in JSON output | ||
| - Document the JSON output format in the CLI documentation | ||
|
|
||
| ## Impact | ||
| - Affected specs: `specs/cli-validate` | ||
| - Affected code: `src/commands/validate.ts`, `src/cli/index.ts`, documentation |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| ## ADDED Requirements | ||
| ### Requirement: JSON Output Flag | ||
| The validate command SHALL support a `--json` flag that outputs validation results in structured JSON format instead of human-readable text. | ||
|
|
||
| #### Scenario: Using JSON output flag | ||
| - **WHEN** a user runs `openspec validate --json` | ||
| - **THEN** the command SHALL output validation results in JSON format | ||
| - **AND** include detailed error information with file paths and line numbers | ||
| - **AND** exit with appropriate status codes (0 for success, 1 for validation errors) | ||
|
|
||
| ### Requirement: JSON Output Format | ||
| The JSON output SHALL include structured information about validation results including change identifiers, validation status, error details, and file locations. | ||
|
|
||
| #### Scenario: JSON output structure | ||
| - **WHEN** validation is run with the `--json` flag | ||
| - **THEN** the output SHALL be a valid JSON object | ||
| - **AND** include fields for `valid`, `errors`, and `changeId` | ||
| - **AND** each error SHALL include `message`, `file`, and `line` information when applicable | ||
|
Comment on lines
+11
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainJSON schema mismatch between spec and implementation. The spec requires JSON output with fields Reconcile the spec to match the actual implementation, or update the implementation to match the spec. Please verify which schema is canonical by checking:
If the implementation is correct, update the spec to reflect the actual 🏁 Script executed: #!/bin/bash
# Find and read the spec file
find . -name "spec.md" -path "*/add-validation-json-output/specs/cli-validate/*" 2>/dev/null | head -5Length of output: 72 🏁 Script executed: #!/bin/bash
# Find validate.ts and validator.ts files
find . -name "validate.ts" -o -name "validator.ts" 2>/dev/null | grep -v node_modules | head -10Length of output: 61 🏁 Script executed: #!/bin/bash
# Find test file for validate command
find . -path "*/test/commands/validate.test.ts" 2>/dev/nullLength of output: 32 🏁 Script executed: #!/bin/bash
# Show directory structure to understand repository layout
ls -laLength of output: 1877 🏁 Script executed: #!/bin/bash
# Check for spec.md files anywhere under openspec/changes
find openspec/changes -name "spec.md" 2>/dev/nullLength of output: 5239 🏁 Script executed: #!/bin/bash
# Look for src or lib directories with validate-related files
find . -type d -name "src" -o -type d -name "lib" 2>/dev/null | head -5Length of output: 5 🏁 Script executed: #!/bin/bash
# List all TypeScript files that contain "validate" in their name
find . -name "*validate*.ts" -type f 2>/dev/null | grep -v node_modules | head -20Length of output: 268 🏁 Script executed: #!/bin/bash
# List test files
find . -path "*/test/*" -name "*.test.ts" 2>/dev/null | head -10Length of output: 392 🏁 Script executed: #!/bin/bash
# Show the current directory contents
pwd
find . -maxdepth 2 -type d | head -20Length of output: 251 🏁 Script executed: #!/bin/bash
# Look for spec files more broadly
find . -name "*.md" -type f 2>/dev/null | grep -i spec | head -20Length of output: 1267 🏁 Script executed: #!/bin/bash
# Search for "JSON Output Format" in codebase
rg -l "JSON Output Format" --type mdLength of output: 70 🏁 Script executed: #!/bin/bash
# Search for printReport function mentioned in review
rg -n "printReport" --type tsLength of output: 356 🏁 Script executed: #!/bin/bash
# Search for JSON output structure with items and summary
rg -n "items.*summary" --type ts | head -10Length of output: 426 🏁 Script executed: #!/bin/bash
# Look for test files related to validate command
rg -l "validate.*test\|test.*validate" --type ts | head -10Length of output: 0 🏁 Script executed: #!/bin/bash
# Find all markdown files in openspec
find openspec -name "*.md" 2>/dev/null | head -20Length of output: 1270 🏁 Script executed: #!/bin/bash
# Show structure of openspec directory
find openspec -type f | head -30Length of output: 2033 🏁 Script executed: #!/bin/bash
# Get the spec file at the exact location mentioned
cat "openspec/changes/add-validation-json-output/specs/cli-validate/spec.md" 2>/dev/null || echo "File not found at specified path"Length of output: 1435 🏁 Script executed: #!/bin/bash
# Search for any files with "add-validation" in path
find . -path "*add-validation*" 2>/dev/nullLength of output: 348 🏁 Script executed: #!/bin/bash
# Read validate.ts to see implementation of printReport
cat src/commands/validate.ts | head -300 | tail -200Length of output: 8594 🏁 Script executed: #!/bin/bash
# Get specific lines from validate.ts around printReport
sed -n '140,170p' src/commands/validate.tsLength of output: 1524 🏁 Script executed: #!/bin/bash
# Get lines 250-270 to see the multi-report output
sed -n '250,270p' src/commands/validate.tsLength of output: 770 🏁 Script executed: #!/bin/bash
# Read validator.ts to check issue structure
cat src/core/validation/validator.ts | head -200Length of output: 8180 🏁 Script executed: #!/bin/bash
# Look for the issue/ValidationIssue type definition
rg -n "interface.*Issue\|type.*Issue" --type ts -A 5Length of output: 0 🏁 Script executed: #!/bin/bash
# Get the full printReport method
sed -n '149,165p' src/commands/validate.tsLength of output: 1079 🏁 Script executed: #!/bin/bash
# Check test file expectations around lines 82-89
sed -n '75,95p' test/commands/validate.test.tsLength of output: 922 🏁 Script executed: #!/bin/bash
# Look for JSON output tests
rg -n "\.json\|JSON" test/commands/validate.test.ts | head -20Length of output: 0 🏁 Script executed: #!/bin/bash
# Check what tests expect from validate command
cat test/commands/validate.test.ts | head -150Length of output: 5873 🏁 Script executed: #!/bin/bash
# Search for test assertions about JSON structure
rg -n "items\|summary\|version" test/commands/validate.test.tsLength of output: 0 Update spec to match the actual JSON output structure. The implementation produces a different schema than the spec requires. Tests validate against the implementation, confirming it as canonical. Spec requires: Implementation outputs: Update lines 11–18 to document the actual structure: top-level 🤖 Prompt for AI Agents |
||
|
|
||
| ### Requirement: Backward Compatibility | ||
| The validate command SHALL maintain backward compatibility, with JSON output only enabled when the `--json` flag is explicitly provided. | ||
|
|
||
| #### Scenario: Backward compatibility | ||
| - **WHEN** a user runs `openspec validate` without flags | ||
| - **THEN** the command SHALL output results in the existing human-readable format | ||
| - **AND** behavior SHALL be identical to current implementation | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ## 1. CLI Implementation | ||
| - [ ] 1.1 Add `--json` flag to the validate command in `src/cli/index.ts` | ||
| - [ ] 1.2 Modify validation logic in `src/commands/validate.ts` to support JSON output format | ||
| - [ ] 1.3 Implement JSON output structure with detailed error information | ||
|
|
||
| ## 2. Documentation | ||
| - [ ] 2.1 Update CLI documentation to include `--json` flag usage | ||
| - [ ] 2.2 Document the JSON output format schema | ||
|
|
||
| ## 3. Testing | ||
| - [ ] 3.1 Add unit tests for JSON output functionality | ||
| - [ ] 3.2 Add integration tests to ensure JSON output is valid and parseable | ||
| - [ ] 3.3 Test backward compatibility with existing validation output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant ignore entry.
Line 160 (
.trae/rules/project_rules.md) is already covered by line 154 (.trae/), which ignores all files under the.trae/directory. The specific file entry is unnecessary.-.trae/rules/project_rules.md📝 Committable suggestion
🤖 Prompt for AI Agents