From 852883603397c4ef9ae46d566e3269ccb55346a7 Mon Sep 17 00:00:00 2001 From: shijiashuai Date: Thu, 23 Apr 2026 02:36:41 +0800 Subject: [PATCH 01/10] feat: integrate OpenSpec for spec-driven development - Add OpenSpec configuration and directory structure - Migrate existing specs to domain-based organization: - sorting/webgpu-sorting.md (core sorting requirements) - quality/project-enhancement.md (CI/CD, code quality) - _archived/core-architecture-v1.md (historical RFC) - Add custom templates for proposals, specs, and tasks - Configure Claude Code integration with /opsx: commands - Update AGENTS.md with OpenSpec workflow documentation - Remove legacy specs/ directory Breaking change: specs/ directory moved to openspec/specs/ --- .claude/commands/opsx/apply.md | 155 +++++++++ .claude/commands/opsx/archive.md | 159 ++++++++++ .claude/commands/opsx/explore.md | 181 +++++++++++ .claude/commands/opsx/propose.md | 114 +++++++ .claude/skills/openspec-apply-change/SKILL.md | 159 ++++++++++ .../skills/openspec-archive-change/SKILL.md | 116 +++++++ .claude/skills/openspec-explore/SKILL.md | 299 ++++++++++++++++++ .claude/skills/openspec-propose/SKILL.md | 118 +++++++ AGENTS.md | 147 +++++++-- openspec/.templates/design.md | 45 +++ openspec/.templates/proposal.md | 61 ++++ openspec/.templates/spec.md | 61 ++++ openspec/.templates/tasks.md | 73 +++++ openspec/archive/.gitkeep | 0 openspec/changes/.gitkeep | 0 openspec/config.yaml | 85 +++++ openspec/specs/_archived/README.md | 31 ++ .../specs/_archived/core-architecture-v1.md | 0 openspec/specs/infrastructure/README.md | 22 ++ openspec/specs/quality/README.md | 23 ++ .../specs/quality/project-enhancement.md | 0 openspec/specs/sorting/README.md | 23 ++ .../specs/sorting/webgpu-sorting.md | 0 specs/README.md | 112 ------- 24 files changed, 1838 insertions(+), 146 deletions(-) create mode 100644 .claude/commands/opsx/apply.md create mode 100644 .claude/commands/opsx/archive.md create mode 100644 .claude/commands/opsx/explore.md create mode 100644 .claude/commands/opsx/propose.md create mode 100644 .claude/skills/openspec-apply-change/SKILL.md create mode 100644 .claude/skills/openspec-archive-change/SKILL.md create mode 100644 .claude/skills/openspec-explore/SKILL.md create mode 100644 .claude/skills/openspec-propose/SKILL.md create mode 100644 openspec/.templates/design.md create mode 100644 openspec/.templates/proposal.md create mode 100644 openspec/.templates/spec.md create mode 100644 openspec/.templates/tasks.md create mode 100644 openspec/archive/.gitkeep create mode 100644 openspec/changes/.gitkeep create mode 100644 openspec/config.yaml create mode 100644 openspec/specs/_archived/README.md rename specs/rfc/0001-core-architecture.md => openspec/specs/_archived/core-architecture-v1.md (100%) create mode 100644 openspec/specs/infrastructure/README.md create mode 100644 openspec/specs/quality/README.md rename specs/product/0002-project-quality-enhancement.md => openspec/specs/quality/project-enhancement.md (100%) create mode 100644 openspec/specs/sorting/README.md rename specs/product/0001-webgpu-sorting.md => openspec/specs/sorting/webgpu-sorting.md (100%) delete mode 100644 specs/README.md diff --git a/.claude/commands/opsx/apply.md b/.claude/commands/opsx/apply.md new file mode 100644 index 0000000..9bd5b10 --- /dev/null +++ b/.claude/commands/opsx/apply.md @@ -0,0 +1,155 @@ +--- +name: 'OPSX: Apply' +description: Implement tasks from an OpenSpec change (Experimental) +category: Workflow +tags: [workflow, artifacts, experimental] +--- + +Implement tasks from an OpenSpec change. + +**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. + +**Steps** + +1. **Select the change** + + If a name is provided, use it. Otherwise: + - Infer from conversation context if the user mentioned a change + - Auto-select if only one active change exists + - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select + + Always announce: "Using change: " and how to override (e.g., `/opsx:apply `). + +2. **Check status to understand the schema** + + ```bash + openspec status --change "" --json + ``` + + Parse the JSON to understand: + - `schemaName`: The workflow being used (e.g., "spec-driven") + - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others) + +3. **Get apply instructions** + + ```bash + openspec instructions apply --change "" --json + ``` + + This returns: + - `contextFiles`: artifact ID -> array of concrete file paths (varies by schema) + - Progress (total, complete, remaining) + - Task list with status + - Dynamic instruction based on current state + + **Handle states:** + - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` + - If `state: "all_done"`: congratulate, suggest archive + - Otherwise: proceed to implementation + +4. **Read context files** + + Read every file path listed under `contextFiles` from the apply instructions output. + The files depend on the schema being used: + - **spec-driven**: proposal, specs, design, tasks + - Other schemas: follow the contextFiles from CLI output + +5. **Show current progress** + + Display: + - Schema being used + - Progress: "N/M tasks complete" + - Remaining tasks overview + - Dynamic instruction from CLI + +6. **Implement tasks (loop until done or blocked)** + + For each pending task: + - Show which task is being worked on + - Make the code changes required + - Keep changes minimal and focused + - Mark task complete in the tasks file: `- [ ]` → `- [x]` + - Continue to next task + + **Pause if:** + - Task is unclear → ask for clarification + - Implementation reveals a design issue → suggest updating artifacts + - Error or blocker encountered → report and wait for guidance + - User interrupts + +7. **On completion or pause, show status** + + Display: + - Tasks completed this session + - Overall progress: "N/M tasks complete" + - If all done: suggest archive + - If paused: explain why and wait for guidance + +**Output During Implementation** + +``` +## Implementing: (schema: ) + +Working on task 3/7: +[...implementation happening...] +✓ Task complete + +Working on task 4/7: +[...implementation happening...] +✓ Task complete +``` + +**Output On Completion** + +``` +## Implementation Complete + +**Change:** +**Schema:** +**Progress:** 7/7 tasks complete ✓ + +### Completed This Session +- [x] Task 1 +- [x] Task 2 +... + +All tasks complete! You can archive this change with `/opsx:archive`. +``` + +**Output On Pause (Issue Encountered)** + +``` +## Implementation Paused + +**Change:** +**Schema:** +**Progress:** 4/7 tasks complete + +### Issue Encountered + + +**Options:** +1.