From 275debdd3850dce5c19751691b454fa3be581c11 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 16 Mar 2026 10:44:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20IoT=20=E5=8D=A1=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=A1=A5=E5=85=85=20virtual=5Fno=20=E5=AD=97=E6=AE=B5=E5=92=8C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=BF=87=E6=BB=A4=EF=BC=8C=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E8=AE=BE=E5=A4=87/=E5=8D=A1=E5=AF=BC=E5=85=A5=20API=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- .claude/commands/opsx/archive.md | 4 +- .claude/commands/opsx/bulk-archive.md | 242 -------- .claude/commands/opsx/continue.md | 114 ---- .claude/commands/opsx/explore.md | 7 +- .claude/commands/opsx/new.md | 69 --- .claude/commands/opsx/onboard.md | 525 ----------------- .claude/commands/opsx/{ff.md => propose.md} | 26 +- .claude/commands/opsx/sync.md | 134 ----- .claude/commands/opsx/verify.md | 164 ------ .claude/skills/openspec-apply-change/SKILL.md | 2 +- .../skills/openspec-archive-change/SKILL.md | 4 +- .../openspec-bulk-archive-change/SKILL.md | 246 -------- .../skills/openspec-continue-change/SKILL.md | 118 ---- .claude/skills/openspec-explore/SKILL.md | 12 +- .claude/skills/openspec-new-change/SKILL.md | 74 --- .claude/skills/openspec-onboard/SKILL.md | 529 ------------------ .../SKILL.md | 23 +- .claude/skills/openspec-sync-specs/SKILL.md | 138 ----- .../skills/openspec-verify-change/SKILL.md | 168 ------ .codex/skills/openspec-apply-change/SKILL.md | 2 +- .../skills/openspec-archive-change/SKILL.md | 4 +- .../openspec-bulk-archive-change/SKILL.md | 246 -------- .../skills/openspec-continue-change/SKILL.md | 118 ---- .codex/skills/openspec-explore/SKILL.md | 12 +- .codex/skills/openspec-new-change/SKILL.md | 74 --- .codex/skills/openspec-onboard/SKILL.md | 529 ------------------ .../SKILL.md | 23 +- .codex/skills/openspec-sync-specs/SKILL.md | 138 ----- .codex/skills/openspec-verify-change/SKILL.md | 168 ------ .opencode/command/opsx-archive.md | 4 +- .opencode/command/opsx-bulk-archive.md | 239 -------- .opencode/command/opsx-continue.md | 111 ---- .opencode/command/opsx-explore.md | 7 +- .opencode/command/opsx-new.md | 66 --- .opencode/command/opsx-onboard.md | 522 ----------------- .../command/{opsx-ff.md => opsx-propose.md} | 24 +- .opencode/command/opsx-sync.md | 131 ----- .opencode/command/opsx-verify.md | 161 ------ .../skills/openspec-apply-change/SKILL.md | 2 +- .../skills/openspec-archive-change/SKILL.md | 4 +- .../openspec-bulk-archive-change/SKILL.md | 246 -------- .../skills/openspec-continue-change/SKILL.md | 118 ---- .opencode/skills/openspec-explore/SKILL.md | 12 +- .opencode/skills/openspec-new-change/SKILL.md | 74 --- .opencode/skills/openspec-onboard/SKILL.md | 529 ------------------ .../SKILL.md | 23 +- .opencode/skills/openspec-sync-specs/SKILL.md | 138 ----- .../skills/openspec-verify-change/SKILL.md | 168 ------ docs/admin-openapi.yaml | 21 +- internal/model/dto/iot_card_dto.go | 2 + internal/routes/device.go | 2 +- internal/routes/iot_card.go | 11 +- internal/service/iot_card/service.go | 4 + internal/store/postgres/iot_card_store.go | 6 +- 54 files changed, 159 insertions(+), 6379 deletions(-) delete mode 100644 .claude/commands/opsx/bulk-archive.md delete mode 100644 .claude/commands/opsx/continue.md delete mode 100644 .claude/commands/opsx/new.md delete mode 100644 .claude/commands/opsx/onboard.md rename .claude/commands/opsx/{ff.md => propose.md} (80%) delete mode 100644 .claude/commands/opsx/sync.md delete mode 100644 .claude/commands/opsx/verify.md delete mode 100644 .claude/skills/openspec-bulk-archive-change/SKILL.md delete mode 100644 .claude/skills/openspec-continue-change/SKILL.md delete mode 100644 .claude/skills/openspec-new-change/SKILL.md delete mode 100644 .claude/skills/openspec-onboard/SKILL.md rename .claude/skills/{openspec-ff-change => openspec-propose}/SKILL.md (85%) delete mode 100644 .claude/skills/openspec-sync-specs/SKILL.md delete mode 100644 .claude/skills/openspec-verify-change/SKILL.md delete mode 100644 .codex/skills/openspec-bulk-archive-change/SKILL.md delete mode 100644 .codex/skills/openspec-continue-change/SKILL.md delete mode 100644 .codex/skills/openspec-new-change/SKILL.md delete mode 100644 .codex/skills/openspec-onboard/SKILL.md rename .codex/skills/{openspec-ff-change => openspec-propose}/SKILL.md (85%) delete mode 100644 .codex/skills/openspec-sync-specs/SKILL.md delete mode 100644 .codex/skills/openspec-verify-change/SKILL.md delete mode 100644 .opencode/command/opsx-bulk-archive.md delete mode 100644 .opencode/command/opsx-continue.md delete mode 100644 .opencode/command/opsx-new.md delete mode 100644 .opencode/command/opsx-onboard.md rename .opencode/command/{opsx-ff.md => opsx-propose.md} (80%) delete mode 100644 .opencode/command/opsx-sync.md delete mode 100644 .opencode/command/opsx-verify.md delete mode 100644 .opencode/skills/openspec-bulk-archive-change/SKILL.md delete mode 100644 .opencode/skills/openspec-continue-change/SKILL.md delete mode 100644 .opencode/skills/openspec-new-change/SKILL.md delete mode 100644 .opencode/skills/openspec-onboard/SKILL.md rename .opencode/skills/{openspec-ff-change => openspec-propose}/SKILL.md (85%) delete mode 100644 .opencode/skills/openspec-sync-specs/SKILL.md delete mode 100644 .opencode/skills/openspec-verify-change/SKILL.md diff --git a/.claude/commands/opsx/archive.md b/.claude/commands/opsx/archive.md index 7275c85..5e91608 100644 --- a/.claude/commands/opsx/archive.md +++ b/.claude/commands/opsx/archive.md @@ -59,7 +59,7 @@ Archive a completed change in the experimental workflow. - If changes needed: "Sync now (recommended)", "Archive without syncing" - If already synced: "Archive now", "Sync anyway", "Cancel" - If user chooses sync, execute `/opsx:sync` logic. Proceed to archive regardless of choice. + If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change ''. Delta spec analysis: "). Proceed to archive regardless of choice. 5. **Perform the archive** @@ -153,5 +153,5 @@ Target archive directory already exists. - Don't block archive on warnings - just inform and confirm - Preserve .openspec.yaml when moving to archive (it moves with the directory) - Show clear summary of what happened -- If sync is requested, use /opsx:sync approach (agent-driven) +- If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven) - If delta specs exist, always run the sync assessment and show the combined summary before prompting diff --git a/.claude/commands/opsx/bulk-archive.md b/.claude/commands/opsx/bulk-archive.md deleted file mode 100644 index b700261..0000000 --- a/.claude/commands/opsx/bulk-archive.md +++ /dev/null @@ -1,242 +0,0 @@ ---- -name: "OPSX: Bulk Archive" -description: Archive multiple completed changes at once -category: Workflow -tags: [workflow, archive, experimental, bulk] ---- - -Archive multiple completed changes in a single operation. - -This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented. - -**Input**: None required (prompts for selection) - -**Steps** - -1. **Get active changes** - - Run `openspec list --json` to get all active changes. - - If no active changes exist, inform user and stop. - -2. **Prompt for change selection** - - Use **AskUserQuestion tool** with multi-select to let user choose changes: - - Show each change with its schema - - Include an option for "All changes" - - Allow any number of selections (1+ works, 2+ is the typical use case) - - **IMPORTANT**: Do NOT auto-select. Always let the user choose. - -3. **Batch validation - gather status for all selected changes** - - For each selected change, collect: - - a. **Artifact status** - Run `openspec status --change "" --json` - - Parse `schemaName` and `artifacts` list - - Note which artifacts are `done` vs other states - - b. **Task completion** - Read `openspec/changes//tasks.md` - - Count `- [ ]` (incomplete) vs `- [x]` (complete) - - If no tasks file exists, note as "No tasks" - - c. **Delta specs** - Check `openspec/changes//specs/` directory - - List which capability specs exist - - For each, extract requirement names (lines matching `### Requirement: `) - -4. **Detect spec conflicts** - - Build a map of `capability -> [changes that touch it]`: - - ``` - auth -> [change-a, change-b] <- CONFLICT (2+ changes) - api -> [change-c] <- OK (only 1 change) - ``` - - A conflict exists when 2+ selected changes have delta specs for the same capability. - -5. **Resolve conflicts agentically** - - **For each conflict**, investigate the codebase: - - a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify - - b. **Search the codebase** for implementation evidence: - - Look for code implementing requirements from each delta spec - - Check for related files, functions, or tests - - c. **Determine resolution**: - - If only one change is actually implemented -> sync that one's specs - - If both implemented -> apply in chronological order (older first, newer overwrites) - - If neither implemented -> skip spec sync, warn user - - d. **Record resolution** for each conflict: - - Which change's specs to apply - - In what order (if both) - - Rationale (what was found in codebase) - -6. **Show consolidated status table** - - Display a table summarizing all changes: - - ``` - | Change | Artifacts | Tasks | Specs | Conflicts | Status | - |---------------------|-----------|-------|---------|-----------|--------| - | schema-management | Done | 5/5 | 2 delta | None | Ready | - | project-config | Done | 3/3 | 1 delta | None | Ready | - | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* | - | add-verify-skill | 1 left | 2/5 | None | None | Warn | - ``` - - For conflicts, show the resolution: - ``` - * Conflict resolution: - - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order) - ``` - - For incomplete changes, show warnings: - ``` - Warnings: - - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks - ``` - -7. **Confirm batch operation** - - Use **AskUserQuestion tool** with a single confirmation: - - - "Archive N changes?" with options based on status - - Options might include: - - "Archive all N changes" - - "Archive only N ready changes (skip incomplete)" - - "Cancel" - - If there are incomplete changes, make clear they'll be archived with warnings. - -8. **Execute archive for each confirmed change** - - Process changes in the determined order (respecting conflict resolution): - - a. **Sync specs** if delta specs exist: - - Use the openspec-sync-specs approach (agent-driven intelligent merge) - - For conflicts, apply in resolved order - - Track if sync was done - - b. **Perform the archive**: - ```bash - mkdir -p openspec/changes/archive - mv openspec/changes/ openspec/changes/archive/YYYY-MM-DD- - ``` - - c. **Track outcome** for each change: - - Success: archived successfully - - Failed: error during archive (record error) - - Skipped: user chose not to archive (if applicable) - -9. **Display summary** - - Show final results: - - ``` - ## Bulk Archive Complete - - Archived 3 changes: - - schema-management-cli -> archive/2026-01-19-schema-management-cli/ - - project-config -> archive/2026-01-19-project-config/ - - add-oauth -> archive/2026-01-19-add-oauth/ - - Skipped 1 change: - - add-verify-skill (user chose not to archive incomplete) - - Spec sync summary: - - 4 delta specs synced to main specs - - 1 conflict resolved (auth: applied both in chronological order) - ``` - - If any failures: - ``` - Failed 1 change: - - some-change: Archive directory already exists - ``` - -**Conflict Resolution Examples** - -Example 1: Only one implemented -``` -Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt] - -Checking add-oauth: -- Delta adds "OAuth Provider Integration" requirement -- Searching codebase... found src/auth/oauth.ts implementing OAuth flow - -Checking add-jwt: -- Delta adds "JWT Token Handling" requirement -- Searching codebase... no JWT implementation found - -Resolution: Only add-oauth is implemented. Will sync add-oauth specs only. -``` - -Example 2: Both implemented -``` -Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql] - -Checking add-rest-api (created 2026-01-10): -- Delta adds "REST Endpoints" requirement -- Searching codebase... found src/api/rest.ts - -Checking add-graphql (created 2026-01-15): -- Delta adds "GraphQL Schema" requirement -- Searching codebase... found src/api/graphql.ts - -Resolution: Both implemented. Will apply add-rest-api specs first, -then add-graphql specs (chronological order, newer takes precedence). -``` - -**Output On Success** - -``` -## Bulk Archive Complete - -Archived N changes: -- -> archive/YYYY-MM-DD-/ -- -> archive/YYYY-MM-DD-/ - -Spec sync summary: -- N delta specs synced to main specs -- No conflicts (or: M conflicts resolved) -``` - -**Output On Partial Success** - -``` -## Bulk Archive Complete (partial) - -Archived N changes: -- -> archive/YYYY-MM-DD-/ - -Skipped M changes: -- (user chose not to archive incomplete) - -Failed K changes: -- : Archive directory already exists -``` - -**Output When No Changes** - -``` -## No Changes to Archive - -No active changes found. Use `/opsx:new` to create a new change. -``` - -**Guardrails** -- Allow any number of changes (1+ is fine, 2+ is the typical use case) -- Always prompt for selection, never auto-select -- Detect spec conflicts early and resolve by checking codebase -- When both changes are implemented, apply specs in chronological order -- Skip spec sync only when implementation is missing (warn user) -- Show clear per-change status before confirming -- Use single confirmation for entire batch -- Track and report all outcomes (success/skip/fail) -- Preserve .openspec.yaml when moving to archive -- Archive directory target uses current date: YYYY-MM-DD- -- If archive target exists, fail that change but continue with others diff --git a/.claude/commands/opsx/continue.md b/.claude/commands/opsx/continue.md deleted file mode 100644 index af255c6..0000000 --- a/.claude/commands/opsx/continue.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -name: "OPSX: Continue" -description: Continue working on a change - create the next artifact (Experimental) -category: Workflow -tags: [workflow, artifacts, experimental] ---- - -Continue working on a change by creating the next artifact. - -**Input**: Optionally specify a change name after `/opsx:continue` (e.g., `/opsx:continue 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. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on. - - Present the top 3-4 most recently modified changes as options, showing: - - Change name - - Schema (from `schema` field if present, otherwise "spec-driven") - - Status (e.g., "0/5 tasks", "complete", "no tasks") - - How recently it was modified (from `lastModified` field) - - Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue. - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Check current status** - ```bash - openspec status --change "" --json - ``` - Parse the JSON to understand current state. The response includes: - - `schemaName`: The workflow schema being used (e.g., "spec-driven") - - `artifacts`: Array of artifacts with their status ("done", "ready", "blocked") - - `isComplete`: Boolean indicating if all artifacts are complete - -3. **Act based on status**: - - --- - - **If all artifacts are complete (`isComplete: true`)**: - - Congratulate the user - - Show final status including the schema used - - Suggest: "All artifacts created! You can now implement this change with `/opsx:apply` or archive it with `/opsx:archive`." - - STOP - - --- - - **If artifacts are ready to create** (status shows artifacts with `status: "ready"`): - - Pick the FIRST artifact with `status: "ready"` from the status output - - Get its instructions: - ```bash - openspec instructions --change "" --json - ``` - - Parse the JSON. The key fields are: - - `context`: Project background (constraints for you - do NOT include in output) - - `rules`: Artifact-specific rules (constraints for you - do NOT include in output) - - `template`: The structure to use for your output file - - `instruction`: Schema-specific guidance - - `outputPath`: Where to write the artifact - - `dependencies`: Completed artifacts to read for context - - **Create the artifact file**: - - Read any completed dependency files for context - - Use `template` as the structure - fill in its sections - - Apply `context` and `rules` as constraints when writing - but do NOT copy them into the file - - Write to the output path specified in instructions - - Show what was created and what's now unlocked - - STOP after creating ONE artifact - - --- - - **If no artifacts are ready (all blocked)**: - - This shouldn't happen with a valid schema - - Show status and suggest checking for issues - -4. **After creating an artifact, show progress** - ```bash - openspec status --change "" - ``` - -**Output** - -After each invocation, show: -- Which artifact was created -- Schema workflow being used -- Current progress (N/M complete) -- What artifacts are now unlocked -- Prompt: "Run `/opsx:continue` to create the next artifact" - -**Artifact Creation Guidelines** - -The artifact types and their purpose depend on the schema. Use the `instruction` field from the instructions output to understand what to create. - -Common artifact patterns: - -**spec-driven schema** (proposal → specs → design → tasks): -- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact. - - The Capabilities section is critical - each capability listed will need a spec file. -- **specs//spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name). -- **design.md**: Document technical decisions, architecture, and implementation approach. -- **tasks.md**: Break down implementation into checkboxed tasks. - -For other schemas, follow the `instruction` field from the CLI output. - -**Guardrails** -- Create ONE artifact per invocation -- Always read dependency artifacts before creating a new one -- Never skip artifacts or create out of order -- If context is unclear, ask the user before creating -- Verify the artifact file exists after writing before marking progress -- Use the schema's artifact sequence, don't assume specific artifact names -- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file - - Do NOT copy ``, ``, `` blocks into the artifact - - These guide what you write, but should never appear in the output diff --git a/.claude/commands/opsx/explore.md b/.claude/commands/opsx/explore.md index 202566b..30d9c57 100644 --- a/.claude/commands/opsx/explore.md +++ b/.claude/commands/opsx/explore.md @@ -7,7 +7,7 @@ tags: [workflow, explore, experimental, thinking] Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes. -**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with `/opsx:new` or `/opsx:ff`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. +**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore. @@ -100,8 +100,7 @@ If the user mentioned a specific change name, read its artifacts for context. Think freely. When insights crystallize, you might offer: -- "This feels solid enough to start a change. Want me to create one?" - → Can transition to `/opsx:new` or `/opsx:ff` +- "This feels solid enough to start a change. Want me to create a proposal?" - Or keep exploring - no pressure to formalize ### When a change exists @@ -153,7 +152,7 @@ If the user mentions a change or you detect one is relevant: There's no required ending. Discovery might: -- **Flow into action**: "Ready to start? `/opsx:new` or `/opsx:ff`" +- **Flow into a proposal**: "Ready to start? I can create a change proposal." - **Result in artifact updates**: "Updated design.md with these decisions" - **Just provide clarity**: User has what they need, moves on - **Continue later**: "We can pick this up anytime" diff --git a/.claude/commands/opsx/new.md b/.claude/commands/opsx/new.md deleted file mode 100644 index ef26cfa..0000000 --- a/.claude/commands/opsx/new.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -name: "OPSX: New" -description: Start a new change using the experimental artifact workflow (OPSX) -category: Workflow -tags: [workflow, artifacts, experimental] ---- - -Start a new change using the experimental artifact-driven approach. - -**Input**: The argument after `/opsx:new` is the change name (kebab-case), OR a description of what the user wants to build. - -**Steps** - -1. **If no input provided, ask what they want to build** - - Use the **AskUserQuestion tool** (open-ended, no preset options) to ask: - > "What change do you want to work on? Describe what you want to build or fix." - - From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`). - - **IMPORTANT**: Do NOT proceed without understanding what the user wants to build. - -2. **Determine the workflow schema** - - Use the default schema (omit `--schema`) unless the user explicitly requests a different workflow. - - **Use a different schema only if the user mentions:** - - A specific schema name → use `--schema ` - - "show workflows" or "what workflows" → run `openspec schemas --json` and let them choose - - **Otherwise**: Omit `--schema` to use the default. - -3. **Create the change directory** - ```bash - openspec new change "" - ``` - Add `--schema ` only if the user requested a specific workflow. - This creates a scaffolded change at `openspec/changes//` with the selected schema. - -4. **Show the artifact status** - ```bash - openspec status --change "" - ``` - This shows which artifacts need to be created and which are ready (dependencies satisfied). - -5. **Get instructions for the first artifact** - The first artifact depends on the schema. Check the status output to find the first artifact with status "ready". - ```bash - openspec instructions --change "" - ``` - This outputs the template and context for creating the first artifact. - -6. **STOP and wait for user direction** - -**Output** - -After completing the steps, summarize: -- Change name and location -- Schema/workflow being used and its artifact sequence -- Current status (0/N artifacts complete) -- The template for the first artifact -- Prompt: "Ready to create the first artifact? Run `/opsx:continue` or just describe what this change is about and I'll draft it." - -**Guardrails** -- Do NOT create any artifacts yet - just show the instructions -- Do NOT advance beyond showing the first artifact template -- If the name is invalid (not kebab-case), ask for a valid name -- If a change with that name already exists, suggest using `/opsx:continue` instead -- Pass --schema if using a non-default workflow diff --git a/.claude/commands/opsx/onboard.md b/.claude/commands/opsx/onboard.md deleted file mode 100644 index e15790e..0000000 --- a/.claude/commands/opsx/onboard.md +++ /dev/null @@ -1,525 +0,0 @@ ---- -name: "OPSX: Onboard" -description: Guided onboarding - walk through a complete OpenSpec workflow cycle with narration -category: Workflow -tags: [workflow, onboarding, tutorial, learning] ---- - -Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step. - ---- - -## Preflight - -Before starting, check if OpenSpec is initialized: - -```bash -openspec status --json 2>&1 || echo "NOT_INITIALIZED" -``` - -**If not initialized:** -> OpenSpec isn't set up in this project yet. Run `openspec init` first, then come back to `/opsx:onboard`. - -Stop here if not initialized. - ---- - -## Phase 1: Welcome - -Display: - -``` -## Welcome to OpenSpec! - -I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it. - -**What we'll do:** -1. Pick a small, real task in your codebase -2. Explore the problem briefly -3. Create a change (the container for our work) -4. Build the artifacts: proposal → specs → design → tasks -5. Implement the tasks -6. Archive the completed change - -**Time:** ~15-20 minutes - -Let's start by finding something to work on. -``` - ---- - -## Phase 2: Task Selection - -### Codebase Analysis - -Scan the codebase for small improvement opportunities. Look for: - -1. **TODO/FIXME comments** - Search for `TODO`, `FIXME`, `HACK`, `XXX` in code files -2. **Missing error handling** - `catch` blocks that swallow errors, risky operations without try-catch -3. **Functions without tests** - Cross-reference `src/` with test directories -4. **Type issues** - `any` types in TypeScript files (`: any`, `as any`) -5. **Debug artifacts** - `console.log`, `console.debug`, `debugger` statements in non-debug code -6. **Missing validation** - User input handlers without validation - -Also check recent git activity: -```bash -git log --oneline -10 2>/dev/null || echo "No git history" -``` - -### Present Suggestions - -From your analysis, present 3-4 specific suggestions: - -``` -## Task Suggestions - -Based on scanning your codebase, here are some good starter tasks: - -**1. [Most promising task]** - Location: `src/path/to/file.ts:42` - Scope: ~1-2 files, ~20-30 lines - Why it's good: [brief reason] - -**2. [Second task]** - Location: `src/another/file.ts` - Scope: ~1 file, ~15 lines - Why it's good: [brief reason] - -**3. [Third task]** - Location: [location] - Scope: [estimate] - Why it's good: [brief reason] - -**4. Something else?** - Tell me what you'd like to work on. - -Which task interests you? (Pick a number or describe your own) -``` - -**If nothing found:** Fall back to asking what the user wants to build: -> I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix? - -### Scope Guardrail - -If the user picks or describes something too large (major feature, multi-day work): - -``` -That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through. - -For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details. - -**Options:** -1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]? -2. **Pick something else** - One of the other suggestions, or a different small task? -3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer. - -What would you prefer? -``` - -Let the user override if they insist—this is a soft guardrail. - ---- - -## Phase 3: Explore Demo - -Once a task is selected, briefly demonstrate explore mode: - -``` -Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction. -``` - -Spend 1-2 minutes investigating the relevant code: -- Read the file(s) involved -- Draw a quick ASCII diagram if it helps -- Note any considerations - -``` -## Quick Exploration - -[Your brief analysis—what you found, any considerations] - -┌─────────────────────────────────────────┐ -│ [Optional: ASCII diagram if helpful] │ -└─────────────────────────────────────────┘ - -Explore mode (`/opsx:explore`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem. - -Now let's create a change to hold our work. -``` - -**PAUSE** - Wait for user acknowledgment before proceeding. - ---- - -## Phase 4: Create the Change - -**EXPLAIN:** -``` -## Creating a Change - -A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in `openspec/changes//` and holds your artifacts—proposal, specs, design, tasks. - -Let me create one for our task. -``` - -**DO:** Create the change with a derived kebab-case name: -```bash -openspec new change "" -``` - -**SHOW:** -``` -Created: `openspec/changes//` - -The folder structure: -``` -openspec/changes// -├── proposal.md ← Why we're doing this (empty, we'll fill it) -├── design.md ← How we'll build it (empty) -├── specs/ ← Detailed requirements (empty) -└── tasks.md ← Implementation checklist (empty) -``` - -Now let's fill in the first artifact—the proposal. -``` - ---- - -## Phase 5: Proposal - -**EXPLAIN:** -``` -## The Proposal - -The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work. - -I'll draft one based on our task. -``` - -**DO:** Draft the proposal content (don't save yet): - -``` -Here's a draft proposal: - ---- - -## Why - -[1-2 sentences explaining the problem/opportunity] - -## What Changes - -[Bullet points of what will be different] - -## Capabilities - -### New Capabilities -- ``: [brief description] - -### Modified Capabilities - - -## Impact - -- `src/path/to/file.ts`: [what changes] -- [other files if applicable] - ---- - -Does this capture the intent? I can adjust before we save it. -``` - -**PAUSE** - Wait for user approval/feedback. - -After approval, save the proposal: -```bash -openspec instructions proposal --change "" --json -``` -Then write the content to `openspec/changes//proposal.md`. - -``` -Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves. - -Next up: specs. -``` - ---- - -## Phase 6: Specs - -**EXPLAIN:** -``` -## Specs - -Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear. - -For a small task like this, we might only need one spec file. -``` - -**DO:** Create the spec file: -```bash -mkdir -p openspec/changes//specs/ -``` - -Draft the spec content: - -``` -Here's the spec: - ---- - -## ADDED Requirements - -### Requirement: - - - -#### Scenario: - -- **WHEN** -- **THEN** -- **AND** - ---- - -This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases. -``` - -Save to `openspec/changes//specs//spec.md`. - ---- - -## Phase 7: Design - -**EXPLAIN:** -``` -## Design - -The design captures **how** we'll build it—technical decisions, tradeoffs, approach. - -For small changes, this might be brief. That's fine—not every change needs deep design discussion. -``` - -**DO:** Draft design.md: - -``` -Here's the design: - ---- - -## Context - -[Brief context about the current state] - -## Goals / Non-Goals - -**Goals:** -- [What we're trying to achieve] - -**Non-Goals:** -- [What's explicitly out of scope] - -## Decisions - -### Decision 1: [Key decision] - -[Explanation of approach and rationale] - ---- - -For a small task, this captures the key decisions without over-engineering. -``` - -Save to `openspec/changes//design.md`. - ---- - -## Phase 8: Tasks - -**EXPLAIN:** -``` -## Tasks - -Finally, we break the work into implementation tasks—checkboxes that drive the apply phase. - -These should be small, clear, and in logical order. -``` - -**DO:** Generate tasks based on specs and design: - -``` -Here are the implementation tasks: - ---- - -## 1. [Category or file] - -- [ ] 1.1 [Specific task] -- [ ] 1.2 [Specific task] - -## 2. Verify - -- [ ] 2.1 [Verification step] - ---- - -Each checkbox becomes a unit of work in the apply phase. Ready to implement? -``` - -**PAUSE** - Wait for user to confirm they're ready to implement. - -Save to `openspec/changes//tasks.md`. - ---- - -## Phase 9: Apply (Implementation) - -**EXPLAIN:** -``` -## Implementation - -Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach. -``` - -**DO:** For each task: - -1. Announce: "Working on task N: [description]" -2. Implement the change in the codebase -3. Reference specs/design naturally: "The spec says X, so I'm doing Y" -4. Mark complete in tasks.md: `- [ ]` → `- [x]` -5. Brief status: "✓ Task N complete" - -Keep narration light—don't over-explain every line of code. - -After all tasks: - -``` -## Implementation Complete - -All tasks done: -- [x] Task 1 -- [x] Task 2 -- [x] ... - -The change is implemented! One more step—let's archive it. -``` - ---- - -## Phase 10: Archive - -**EXPLAIN:** -``` -## Archiving - -When a change is complete, we archive it. This moves it from `openspec/changes/` to `openspec/changes/archive/YYYY-MM-DD-/`. - -Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way. -``` - -**DO:** -```bash -openspec archive "" -``` - -**SHOW:** -``` -Archived to: `openspec/changes/archive/YYYY-MM-DD-/` - -The change is now part of your project's history. The code is in your codebase, the decision record is preserved. -``` - ---- - -## Phase 11: Recap & Next Steps - -``` -## Congratulations! - -You just completed a full OpenSpec cycle: - -1. **Explore** - Thought through the problem -2. **New** - Created a change container -3. **Proposal** - Captured WHY -4. **Specs** - Defined WHAT in detail -5. **Design** - Decided HOW -6. **Tasks** - Broke it into steps -7. **Apply** - Implemented the work -8. **Archive** - Preserved the record - -This same rhythm works for any size change—a small fix or a major feature. - ---- - -## Command Reference - -| Command | What it does | -|---------|--------------| -| `/opsx:explore` | Think through problems before/during work | -| `/opsx:new` | Start a new change, step through artifacts | -| `/opsx:ff` | Fast-forward: create all artifacts at once | -| `/opsx:continue` | Continue working on an existing change | -| `/opsx:apply` | Implement tasks from a change | -| `/opsx:verify` | Verify implementation matches artifacts | -| `/opsx:archive` | Archive a completed change | - ---- - -## What's Next? - -Try `/opsx:new` or `/opsx:ff` on something you actually want to build. You've got the rhythm now! -``` - ---- - -## Graceful Exit Handling - -### User wants to stop mid-way - -If the user says they need to stop, want to pause, or seem disengaged: - -``` -No problem! Your change is saved at `openspec/changes//`. - -To pick up where we left off later: -- `/opsx:continue ` - Resume artifact creation -- `/opsx:apply ` - Jump to implementation (if tasks exist) - -The work won't be lost. Come back whenever you're ready. -``` - -Exit gracefully without pressure. - -### User just wants command reference - -If the user says they just want to see the commands or skip the tutorial: - -``` -## OpenSpec Quick Reference - -| Command | What it does | -|---------|--------------| -| `/opsx:explore` | Think through problems (no code changes) | -| `/opsx:new ` | Start a new change, step by step | -| `/opsx:ff ` | Fast-forward: all artifacts at once | -| `/opsx:continue ` | Continue an existing change | -| `/opsx:apply ` | Implement tasks | -| `/opsx:verify ` | Verify implementation | -| `/opsx:archive ` | Archive when done | - -Try `/opsx:new` to start your first change, or `/opsx:ff` if you want to move fast. -``` - -Exit gracefully. - ---- - -## Guardrails - -- **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive) -- **Keep narration light** during implementation—teach without lecturing -- **Don't skip phases** even if the change is small—the goal is teaching the workflow -- **Pause for acknowledgment** at marked points, but don't over-pause -- **Handle exits gracefully**—never pressure the user to continue -- **Use real codebase tasks**—don't simulate or use fake examples -- **Adjust scope gently**—guide toward smaller tasks but respect user choice diff --git a/.claude/commands/opsx/ff.md b/.claude/commands/opsx/propose.md similarity index 80% rename from .claude/commands/opsx/ff.md rename to .claude/commands/opsx/propose.md index bea9d61..05276f4 100644 --- a/.claude/commands/opsx/ff.md +++ b/.claude/commands/opsx/propose.md @@ -1,13 +1,22 @@ --- -name: "OPSX: Fast Forward" -description: Create a change and generate all artifacts needed for implementation in one go +name: "OPSX: Propose" +description: Propose a new change - create it and generate all artifacts in one step category: Workflow tags: [workflow, artifacts, experimental] --- -Fast-forward through artifact creation - generate everything needed to start implementation. +Propose a new change - create the change and generate all artifacts in one step. -**Input**: The argument after `/opsx:ff` is the change name (kebab-case), OR a description of what the user wants to build. +I'll create a change with artifacts: +- proposal.md (what & why) +- design.md (how) +- tasks.md (implementation steps) + +When ready to implement, run /opsx:apply + +--- + +**Input**: The argument after `/opsx:propose` is the change name (kebab-case), OR a description of what the user wants to build. **Steps** @@ -24,7 +33,7 @@ Fast-forward through artifact creation - generate everything needed to start imp ```bash openspec new change "" ``` - This creates a scaffolded change at `openspec/changes//`. + This creates a scaffolded change at `openspec/changes//` with `.openspec.yaml`. 3. **Get the artifact build order** ```bash @@ -55,7 +64,7 @@ Fast-forward through artifact creation - generate everything needed to start imp - Read any completed dependency files for context - Create the artifact file using `template` as the structure - Apply `context` and `rules` as constraints - but do NOT copy them into the file - - Show brief progress: "✓ Created " + - Show brief progress: "Created " b. **Continue until all `applyRequires` artifacts are complete** - After creating each artifact, re-run `openspec status --change "" --json` @@ -84,7 +93,10 @@ After completing all artifacts, summarize: - Follow the `instruction` field from `openspec instructions` for each artifact type - The schema defines what each artifact should contain - follow it - Read dependency artifacts for context before creating new ones -- Use the `template` as a starting point, filling in based on context +- Use `template` as the structure for your output file - fill in its sections +- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file + - Do NOT copy ``, ``, `` blocks into the artifact + - These guide what you write, but should never appear in the output **Guardrails** - Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`) diff --git a/.claude/commands/opsx/sync.md b/.claude/commands/opsx/sync.md deleted file mode 100644 index 1571610..0000000 --- a/.claude/commands/opsx/sync.md +++ /dev/null @@ -1,134 +0,0 @@ ---- -name: "OPSX: Sync" -description: Sync delta specs from a change to main specs -category: Workflow -tags: [workflow, specs, experimental] ---- - -Sync delta specs from a change to main specs. - -This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement). - -**Input**: Optionally specify a change name after `/opsx:sync` (e.g., `/opsx:sync 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. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have delta specs (under `specs/` directory). - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Find delta specs** - - Look for delta spec files in `openspec/changes//specs/*/spec.md`. - - Each delta spec file contains sections like: - - `## ADDED Requirements` - New requirements to add - - `## MODIFIED Requirements` - Changes to existing requirements - - `## REMOVED Requirements` - Requirements to remove - - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format) - - If no delta specs found, inform user and stop. - -3. **For each delta spec, apply changes to main specs** - - For each capability with a delta spec at `openspec/changes//specs//spec.md`: - - a. **Read the delta spec** to understand the intended changes - - b. **Read the main spec** at `openspec/specs//spec.md` (may not exist yet) - - c. **Apply changes intelligently**: - - **ADDED Requirements:** - - If requirement doesn't exist in main spec → add it - - If requirement already exists → update it to match (treat as implicit MODIFIED) - - **MODIFIED Requirements:** - - Find the requirement in main spec - - Apply the changes - this can be: - - Adding new scenarios (don't need to copy existing ones) - - Modifying existing scenarios - - Changing the requirement description - - Preserve scenarios/content not mentioned in the delta - - **REMOVED Requirements:** - - Remove the entire requirement block from main spec - - **RENAMED Requirements:** - - Find the FROM requirement, rename to TO - - d. **Create new main spec** if capability doesn't exist yet: - - Create `openspec/specs//spec.md` - - Add Purpose section (can be brief, mark as TBD) - - Add Requirements section with the ADDED requirements - -4. **Show summary** - - After applying all changes, summarize: - - Which capabilities were updated - - What changes were made (requirements added/modified/removed/renamed) - -**Delta Spec Format Reference** - -```markdown -## ADDED Requirements - -### Requirement: New Feature -The system SHALL do something new. - -#### Scenario: Basic case -- **WHEN** user does X -- **THEN** system does Y - -## MODIFIED Requirements - -### Requirement: Existing Feature -#### Scenario: New scenario to add -- **WHEN** user does A -- **THEN** system does B - -## REMOVED Requirements - -### Requirement: Deprecated Feature - -## RENAMED Requirements - -- FROM: `### Requirement: Old Name` -- TO: `### Requirement: New Name` -``` - -**Key Principle: Intelligent Merging** - -Unlike programmatic merging, you can apply **partial updates**: -- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios -- The delta represents *intent*, not a wholesale replacement -- Use your judgment to merge changes sensibly - -**Output On Success** - -``` -## Specs Synced: - -Updated main specs: - -****: -- Added requirement: "New Feature" -- Modified requirement: "Existing Feature" (added 1 scenario) - -****: -- Created new spec file -- Added requirement: "Another Feature" - -Main specs are now updated. The change remains active - archive when implementation is complete. -``` - -**Guardrails** -- Read both delta and main specs before making changes -- Preserve existing content not mentioned in delta -- If something is unclear, ask for clarification -- Show what you're changing as you go -- The operation should be idempotent - running twice should give same result diff --git a/.claude/commands/opsx/verify.md b/.claude/commands/opsx/verify.md deleted file mode 100644 index 82ab63f..0000000 --- a/.claude/commands/opsx/verify.md +++ /dev/null @@ -1,164 +0,0 @@ ---- -name: "OPSX: Verify" -description: Verify implementation matches change artifacts before archiving -category: Workflow -tags: [workflow, verify, experimental] ---- - -Verify that an implementation matches the change artifacts (specs, tasks, design). - -**Input**: Optionally specify a change name after `/opsx:verify` (e.g., `/opsx:verify 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. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have implementation tasks (tasks artifact exists). - Include the schema used for each change if available. - Mark changes with incomplete tasks as "(In Progress)". - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -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 artifacts exist for this change - -3. **Get the change directory and load artifacts** - - ```bash - openspec instructions apply --change "" --json - ``` - - This returns the change directory and context files. Read all available artifacts from `contextFiles`. - -4. **Initialize verification report structure** - - Create a report structure with three dimensions: - - **Completeness**: Track tasks and spec coverage - - **Correctness**: Track requirement implementation and scenario coverage - - **Coherence**: Track design adherence and pattern consistency - - Each dimension can have CRITICAL, WARNING, or SUGGESTION issues. - -5. **Verify Completeness** - - **Task Completion**: - - If tasks.md exists in contextFiles, read it - - Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete) - - Count complete vs total tasks - - If incomplete tasks exist: - - Add CRITICAL issue for each incomplete task - - Recommendation: "Complete task: " or "Mark as done if already implemented" - - **Spec Coverage**: - - If delta specs exist in `openspec/changes//specs/`: - - Extract all requirements (marked with "### Requirement:") - - For each requirement: - - Search codebase for keywords related to the requirement - - Assess if implementation likely exists - - If requirements appear unimplemented: - - Add CRITICAL issue: "Requirement not found: " - - Recommendation: "Implement requirement X: " - -6. **Verify Correctness** - - **Requirement Implementation Mapping**: - - For each requirement from delta specs: - - Search codebase for implementation evidence - - If found, note file paths and line ranges - - Assess if implementation matches requirement intent - - If divergence detected: - - Add WARNING: "Implementation may diverge from spec:
" - - Recommendation: "Review : against requirement X" - - **Scenario Coverage**: - - For each scenario in delta specs (marked with "#### Scenario:"): - - Check if conditions are handled in code - - Check if tests exist covering the scenario - - If scenario appears uncovered: - - Add WARNING: "Scenario not covered: " - - Recommendation: "Add test or implementation for scenario: " - -7. **Verify Coherence** - - **Design Adherence**: - - If design.md exists in contextFiles: - - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:") - - Verify implementation follows those decisions - - If contradiction detected: - - Add WARNING: "Design decision not followed: " - - Recommendation: "Update implementation or revise design.md to match reality" - - If no design.md: Skip design adherence check, note "No design.md to verify against" - - **Code Pattern Consistency**: - - Review new code for consistency with project patterns - - Check file naming, directory structure, coding style - - If significant deviations found: - - Add SUGGESTION: "Code pattern deviation:
" - - Recommendation: "Consider following project pattern: " - -8. **Generate Verification Report** - - **Summary Scorecard**: - ``` - ## Verification Report: - - ### Summary - | Dimension | Status | - |--------------|------------------| - | Completeness | X/Y tasks, N reqs| - | Correctness | M/N reqs covered | - | Coherence | Followed/Issues | - ``` - - **Issues by Priority**: - - 1. **CRITICAL** (Must fix before archive): - - Incomplete tasks - - Missing requirement implementations - - Each with specific, actionable recommendation - - 2. **WARNING** (Should fix): - - Spec/design divergences - - Missing scenario coverage - - Each with specific recommendation - - 3. **SUGGESTION** (Nice to fix): - - Pattern inconsistencies - - Minor improvements - - Each with specific recommendation - - **Final Assessment**: - - If CRITICAL issues: "X critical issue(s) found. Fix before archiving." - - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)." - - If all clear: "All checks passed. Ready for archive." - -**Verification Heuristics** - -- **Completeness**: Focus on objective checklist items (checkboxes, requirements list) -- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty -- **Coherence**: Look for glaring inconsistencies, don't nitpick style -- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL -- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable - -**Graceful Degradation** - -- If only tasks.md exists: verify task completion only, skip spec/design checks -- If tasks + specs exist: verify completeness and correctness, skip design -- If full artifacts: verify all three dimensions -- Always note which checks were skipped and why - -**Output Format** - -Use clear markdown with: -- Table for summary scorecard -- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION) -- Code references in format: `file.ts:123` -- Specific, actionable recommendations -- No vague suggestions like "consider reviewing" diff --git a/.claude/skills/openspec-apply-change/SKILL.md b/.claude/skills/openspec-apply-change/SKILL.md index 47d4bc2..d474dc1 100644 --- a/.claude/skills/openspec-apply-change/SKILL.md +++ b/.claude/skills/openspec-apply-change/SKILL.md @@ -6,7 +6,7 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Implement tasks from an OpenSpec change. diff --git a/.claude/skills/openspec-archive-change/SKILL.md b/.claude/skills/openspec-archive-change/SKILL.md index 8fa4b23..9b1f851 100644 --- a/.claude/skills/openspec-archive-change/SKILL.md +++ b/.claude/skills/openspec-archive-change/SKILL.md @@ -6,7 +6,7 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Archive a completed change in the experimental workflow. @@ -63,7 +63,7 @@ Archive a completed change in the experimental workflow. - If changes needed: "Sync now (recommended)", "Archive without syncing" - If already synced: "Archive now", "Sync anyway", "Cancel" - If user chooses sync, execute /opsx:sync logic (use the openspec-sync-specs skill). Proceed to archive regardless of choice. + If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change ''. Delta spec analysis: "). Proceed to archive regardless of choice. 5. **Perform the archive** diff --git a/.claude/skills/openspec-bulk-archive-change/SKILL.md b/.claude/skills/openspec-bulk-archive-change/SKILL.md deleted file mode 100644 index 719b279..0000000 --- a/.claude/skills/openspec-bulk-archive-change/SKILL.md +++ /dev/null @@ -1,246 +0,0 @@ ---- -name: openspec-bulk-archive-change -description: Archive multiple completed changes at once. Use when archiving several parallel changes. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Archive multiple completed changes in a single operation. - -This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented. - -**Input**: None required (prompts for selection) - -**Steps** - -1. **Get active changes** - - Run `openspec list --json` to get all active changes. - - If no active changes exist, inform user and stop. - -2. **Prompt for change selection** - - Use **AskUserQuestion tool** with multi-select to let user choose changes: - - Show each change with its schema - - Include an option for "All changes" - - Allow any number of selections (1+ works, 2+ is the typical use case) - - **IMPORTANT**: Do NOT auto-select. Always let the user choose. - -3. **Batch validation - gather status for all selected changes** - - For each selected change, collect: - - a. **Artifact status** - Run `openspec status --change "" --json` - - Parse `schemaName` and `artifacts` list - - Note which artifacts are `done` vs other states - - b. **Task completion** - Read `openspec/changes//tasks.md` - - Count `- [ ]` (incomplete) vs `- [x]` (complete) - - If no tasks file exists, note as "No tasks" - - c. **Delta specs** - Check `openspec/changes//specs/` directory - - List which capability specs exist - - For each, extract requirement names (lines matching `### Requirement: `) - -4. **Detect spec conflicts** - - Build a map of `capability -> [changes that touch it]`: - - ``` - auth -> [change-a, change-b] <- CONFLICT (2+ changes) - api -> [change-c] <- OK (only 1 change) - ``` - - A conflict exists when 2+ selected changes have delta specs for the same capability. - -5. **Resolve conflicts agentically** - - **For each conflict**, investigate the codebase: - - a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify - - b. **Search the codebase** for implementation evidence: - - Look for code implementing requirements from each delta spec - - Check for related files, functions, or tests - - c. **Determine resolution**: - - If only one change is actually implemented -> sync that one's specs - - If both implemented -> apply in chronological order (older first, newer overwrites) - - If neither implemented -> skip spec sync, warn user - - d. **Record resolution** for each conflict: - - Which change's specs to apply - - In what order (if both) - - Rationale (what was found in codebase) - -6. **Show consolidated status table** - - Display a table summarizing all changes: - - ``` - | Change | Artifacts | Tasks | Specs | Conflicts | Status | - |---------------------|-----------|-------|---------|-----------|--------| - | schema-management | Done | 5/5 | 2 delta | None | Ready | - | project-config | Done | 3/3 | 1 delta | None | Ready | - | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* | - | add-verify-skill | 1 left | 2/5 | None | None | Warn | - ``` - - For conflicts, show the resolution: - ``` - * Conflict resolution: - - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order) - ``` - - For incomplete changes, show warnings: - ``` - Warnings: - - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks - ``` - -7. **Confirm batch operation** - - Use **AskUserQuestion tool** with a single confirmation: - - - "Archive N changes?" with options based on status - - Options might include: - - "Archive all N changes" - - "Archive only N ready changes (skip incomplete)" - - "Cancel" - - If there are incomplete changes, make clear they'll be archived with warnings. - -8. **Execute archive for each confirmed change** - - Process changes in the determined order (respecting conflict resolution): - - a. **Sync specs** if delta specs exist: - - Use the openspec-sync-specs approach (agent-driven intelligent merge) - - For conflicts, apply in resolved order - - Track if sync was done - - b. **Perform the archive**: - ```bash - mkdir -p openspec/changes/archive - mv openspec/changes/ openspec/changes/archive/YYYY-MM-DD- - ``` - - c. **Track outcome** for each change: - - Success: archived successfully - - Failed: error during archive (record error) - - Skipped: user chose not to archive (if applicable) - -9. **Display summary** - - Show final results: - - ``` - ## Bulk Archive Complete - - Archived 3 changes: - - schema-management-cli -> archive/2026-01-19-schema-management-cli/ - - project-config -> archive/2026-01-19-project-config/ - - add-oauth -> archive/2026-01-19-add-oauth/ - - Skipped 1 change: - - add-verify-skill (user chose not to archive incomplete) - - Spec sync summary: - - 4 delta specs synced to main specs - - 1 conflict resolved (auth: applied both in chronological order) - ``` - - If any failures: - ``` - Failed 1 change: - - some-change: Archive directory already exists - ``` - -**Conflict Resolution Examples** - -Example 1: Only one implemented -``` -Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt] - -Checking add-oauth: -- Delta adds "OAuth Provider Integration" requirement -- Searching codebase... found src/auth/oauth.ts implementing OAuth flow - -Checking add-jwt: -- Delta adds "JWT Token Handling" requirement -- Searching codebase... no JWT implementation found - -Resolution: Only add-oauth is implemented. Will sync add-oauth specs only. -``` - -Example 2: Both implemented -``` -Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql] - -Checking add-rest-api (created 2026-01-10): -- Delta adds "REST Endpoints" requirement -- Searching codebase... found src/api/rest.ts - -Checking add-graphql (created 2026-01-15): -- Delta adds "GraphQL Schema" requirement -- Searching codebase... found src/api/graphql.ts - -Resolution: Both implemented. Will apply add-rest-api specs first, -then add-graphql specs (chronological order, newer takes precedence). -``` - -**Output On Success** - -``` -## Bulk Archive Complete - -Archived N changes: -- -> archive/YYYY-MM-DD-/ -- -> archive/YYYY-MM-DD-/ - -Spec sync summary: -- N delta specs synced to main specs -- No conflicts (or: M conflicts resolved) -``` - -**Output On Partial Success** - -``` -## Bulk Archive Complete (partial) - -Archived N changes: -- -> archive/YYYY-MM-DD-/ - -Skipped M changes: -- (user chose not to archive incomplete) - -Failed K changes: -- : Archive directory already exists -``` - -**Output When No Changes** - -``` -## No Changes to Archive - -No active changes found. Use `/opsx:new` to create a new change. -``` - -**Guardrails** -- Allow any number of changes (1+ is fine, 2+ is the typical use case) -- Always prompt for selection, never auto-select -- Detect spec conflicts early and resolve by checking codebase -- When both changes are implemented, apply specs in chronological order -- Skip spec sync only when implementation is missing (warn user) -- Show clear per-change status before confirming -- Use single confirmation for entire batch -- Track and report all outcomes (success/skip/fail) -- Preserve .openspec.yaml when moving to archive -- Archive directory target uses current date: YYYY-MM-DD- -- If archive target exists, fail that change but continue with others diff --git a/.claude/skills/openspec-continue-change/SKILL.md b/.claude/skills/openspec-continue-change/SKILL.md deleted file mode 100644 index 5060b2f..0000000 --- a/.claude/skills/openspec-continue-change/SKILL.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -name: openspec-continue-change -description: Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Continue working on a change by creating the next artifact. - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on. - - Present the top 3-4 most recently modified changes as options, showing: - - Change name - - Schema (from `schema` field if present, otherwise "spec-driven") - - Status (e.g., "0/5 tasks", "complete", "no tasks") - - How recently it was modified (from `lastModified` field) - - Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue. - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Check current status** - ```bash - openspec status --change "" --json - ``` - Parse the JSON to understand current state. The response includes: - - `schemaName`: The workflow schema being used (e.g., "spec-driven") - - `artifacts`: Array of artifacts with their status ("done", "ready", "blocked") - - `isComplete`: Boolean indicating if all artifacts are complete - -3. **Act based on status**: - - --- - - **If all artifacts are complete (`isComplete: true`)**: - - Congratulate the user - - Show final status including the schema used - - Suggest: "All artifacts created! You can now implement this change or archive it." - - STOP - - --- - - **If artifacts are ready to create** (status shows artifacts with `status: "ready"`): - - Pick the FIRST artifact with `status: "ready"` from the status output - - Get its instructions: - ```bash - openspec instructions --change "" --json - ``` - - Parse the JSON. The key fields are: - - `context`: Project background (constraints for you - do NOT include in output) - - `rules`: Artifact-specific rules (constraints for you - do NOT include in output) - - `template`: The structure to use for your output file - - `instruction`: Schema-specific guidance - - `outputPath`: Where to write the artifact - - `dependencies`: Completed artifacts to read for context - - **Create the artifact file**: - - Read any completed dependency files for context - - Use `template` as the structure - fill in its sections - - Apply `context` and `rules` as constraints when writing - but do NOT copy them into the file - - Write to the output path specified in instructions - - Show what was created and what's now unlocked - - STOP after creating ONE artifact - - --- - - **If no artifacts are ready (all blocked)**: - - This shouldn't happen with a valid schema - - Show status and suggest checking for issues - -4. **After creating an artifact, show progress** - ```bash - openspec status --change "" - ``` - -**Output** - -After each invocation, show: -- Which artifact was created -- Schema workflow being used -- Current progress (N/M complete) -- What artifacts are now unlocked -- Prompt: "Want to continue? Just ask me to continue or tell me what to do next." - -**Artifact Creation Guidelines** - -The artifact types and their purpose depend on the schema. Use the `instruction` field from the instructions output to understand what to create. - -Common artifact patterns: - -**spec-driven schema** (proposal → specs → design → tasks): -- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact. - - The Capabilities section is critical - each capability listed will need a spec file. -- **specs//spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name). -- **design.md**: Document technical decisions, architecture, and implementation approach. -- **tasks.md**: Break down implementation into checkboxed tasks. - -For other schemas, follow the `instruction` field from the CLI output. - -**Guardrails** -- Create ONE artifact per invocation -- Always read dependency artifacts before creating a new one -- Never skip artifacts or create out of order -- If context is unclear, ask the user before creating -- Verify the artifact file exists after writing before marking progress -- Use the schema's artifact sequence, don't assume specific artifact names -- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file - - Do NOT copy ``, ``, `` blocks into the artifact - - These guide what you write, but should never appear in the output diff --git a/.claude/skills/openspec-explore/SKILL.md b/.claude/skills/openspec-explore/SKILL.md index 8ed4a76..ffa10ca 100644 --- a/.claude/skills/openspec-explore/SKILL.md +++ b/.claude/skills/openspec-explore/SKILL.md @@ -6,12 +6,12 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes. -**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with `/opsx:new` or `/opsx:ff`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. +**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore. @@ -95,8 +95,7 @@ This tells you: Think freely. When insights crystallize, you might offer: -- "This feels solid enough to start a change. Want me to create one?" - → Can transition to `/opsx:new` or `/opsx:ff` +- "This feels solid enough to start a change. Want me to create a proposal?" - Or keep exploring - no pressure to formalize ### When a change exists @@ -252,7 +251,7 @@ You: That changes everything. There's no required ending. Discovery might: -- **Flow into action**: "Ready to start? /opsx:new or /opsx:ff" +- **Flow into a proposal**: "Ready to start? I can create a change proposal." - **Result in artifact updates**: "Updated design.md with these decisions" - **Just provide clarity**: User has what they need, moves on - **Continue later**: "We can pick this up anytime" @@ -269,8 +268,7 @@ When it feels like things are crystallizing, you might summarize: **Open questions**: [if any remain] **Next steps** (if ready): -- Create a change: /opsx:new -- Fast-forward to tasks: /opsx:ff +- Create a change proposal - Keep exploring: just keep talking ``` diff --git a/.claude/skills/openspec-new-change/SKILL.md b/.claude/skills/openspec-new-change/SKILL.md deleted file mode 100644 index 37ac7ba..0000000 --- a/.claude/skills/openspec-new-change/SKILL.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -name: openspec-new-change -description: Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Start a new change using the experimental artifact-driven approach. - -**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build. - -**Steps** - -1. **If no clear input provided, ask what they want to build** - - Use the **AskUserQuestion tool** (open-ended, no preset options) to ask: - > "What change do you want to work on? Describe what you want to build or fix." - - From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`). - - **IMPORTANT**: Do NOT proceed without understanding what the user wants to build. - -2. **Determine the workflow schema** - - Use the default schema (omit `--schema`) unless the user explicitly requests a different workflow. - - **Use a different schema only if the user mentions:** - - A specific schema name → use `--schema ` - - "show workflows" or "what workflows" → run `openspec schemas --json` and let them choose - - **Otherwise**: Omit `--schema` to use the default. - -3. **Create the change directory** - ```bash - openspec new change "" - ``` - Add `--schema ` only if the user requested a specific workflow. - This creates a scaffolded change at `openspec/changes//` with the selected schema. - -4. **Show the artifact status** - ```bash - openspec status --change "" - ``` - This shows which artifacts need to be created and which are ready (dependencies satisfied). - -5. **Get instructions for the first artifact** - The first artifact depends on the schema (e.g., `proposal` for spec-driven). - Check the status output to find the first artifact with status "ready". - ```bash - openspec instructions --change "" - ``` - This outputs the template and context for creating the first artifact. - -6. **STOP and wait for user direction** - -**Output** - -After completing the steps, summarize: -- Change name and location -- Schema/workflow being used and its artifact sequence -- Current status (0/N artifacts complete) -- The template for the first artifact -- Prompt: "Ready to create the first artifact? Just describe what this change is about and I'll draft it, or ask me to continue." - -**Guardrails** -- Do NOT create any artifacts yet - just show the instructions -- Do NOT advance beyond showing the first artifact template -- If the name is invalid (not kebab-case), ask for a valid name -- If a change with that name already exists, suggest continuing that change instead -- Pass --schema if using a non-default workflow diff --git a/.claude/skills/openspec-onboard/SKILL.md b/.claude/skills/openspec-onboard/SKILL.md deleted file mode 100644 index 4a03038..0000000 --- a/.claude/skills/openspec-onboard/SKILL.md +++ /dev/null @@ -1,529 +0,0 @@ ---- -name: openspec-onboard -description: Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step. - ---- - -## Preflight - -Before starting, check if OpenSpec is initialized: - -```bash -openspec status --json 2>&1 || echo "NOT_INITIALIZED" -``` - -**If not initialized:** -> OpenSpec isn't set up in this project yet. Run `openspec init` first, then come back to `/opsx:onboard`. - -Stop here if not initialized. - ---- - -## Phase 1: Welcome - -Display: - -``` -## Welcome to OpenSpec! - -I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it. - -**What we'll do:** -1. Pick a small, real task in your codebase -2. Explore the problem briefly -3. Create a change (the container for our work) -4. Build the artifacts: proposal → specs → design → tasks -5. Implement the tasks -6. Archive the completed change - -**Time:** ~15-20 minutes - -Let's start by finding something to work on. -``` - ---- - -## Phase 2: Task Selection - -### Codebase Analysis - -Scan the codebase for small improvement opportunities. Look for: - -1. **TODO/FIXME comments** - Search for `TODO`, `FIXME`, `HACK`, `XXX` in code files -2. **Missing error handling** - `catch` blocks that swallow errors, risky operations without try-catch -3. **Functions without tests** - Cross-reference `src/` with test directories -4. **Type issues** - `any` types in TypeScript files (`: any`, `as any`) -5. **Debug artifacts** - `console.log`, `console.debug`, `debugger` statements in non-debug code -6. **Missing validation** - User input handlers without validation - -Also check recent git activity: -```bash -git log --oneline -10 2>/dev/null || echo "No git history" -``` - -### Present Suggestions - -From your analysis, present 3-4 specific suggestions: - -``` -## Task Suggestions - -Based on scanning your codebase, here are some good starter tasks: - -**1. [Most promising task]** - Location: `src/path/to/file.ts:42` - Scope: ~1-2 files, ~20-30 lines - Why it's good: [brief reason] - -**2. [Second task]** - Location: `src/another/file.ts` - Scope: ~1 file, ~15 lines - Why it's good: [brief reason] - -**3. [Third task]** - Location: [location] - Scope: [estimate] - Why it's good: [brief reason] - -**4. Something else?** - Tell me what you'd like to work on. - -Which task interests you? (Pick a number or describe your own) -``` - -**If nothing found:** Fall back to asking what the user wants to build: -> I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix? - -### Scope Guardrail - -If the user picks or describes something too large (major feature, multi-day work): - -``` -That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through. - -For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details. - -**Options:** -1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]? -2. **Pick something else** - One of the other suggestions, or a different small task? -3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer. - -What would you prefer? -``` - -Let the user override if they insist—this is a soft guardrail. - ---- - -## Phase 3: Explore Demo - -Once a task is selected, briefly demonstrate explore mode: - -``` -Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction. -``` - -Spend 1-2 minutes investigating the relevant code: -- Read the file(s) involved -- Draw a quick ASCII diagram if it helps -- Note any considerations - -``` -## Quick Exploration - -[Your brief analysis—what you found, any considerations] - -┌─────────────────────────────────────────┐ -│ [Optional: ASCII diagram if helpful] │ -└─────────────────────────────────────────┘ - -Explore mode (`/opsx:explore`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem. - -Now let's create a change to hold our work. -``` - -**PAUSE** - Wait for user acknowledgment before proceeding. - ---- - -## Phase 4: Create the Change - -**EXPLAIN:** -``` -## Creating a Change - -A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in `openspec/changes//` and holds your artifacts—proposal, specs, design, tasks. - -Let me create one for our task. -``` - -**DO:** Create the change with a derived kebab-case name: -```bash -openspec new change "" -``` - -**SHOW:** -``` -Created: `openspec/changes//` - -The folder structure: -``` -openspec/changes// -├── proposal.md ← Why we're doing this (empty, we'll fill it) -├── design.md ← How we'll build it (empty) -├── specs/ ← Detailed requirements (empty) -└── tasks.md ← Implementation checklist (empty) -``` - -Now let's fill in the first artifact—the proposal. -``` - ---- - -## Phase 5: Proposal - -**EXPLAIN:** -``` -## The Proposal - -The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work. - -I'll draft one based on our task. -``` - -**DO:** Draft the proposal content (don't save yet): - -``` -Here's a draft proposal: - ---- - -## Why - -[1-2 sentences explaining the problem/opportunity] - -## What Changes - -[Bullet points of what will be different] - -## Capabilities - -### New Capabilities -- ``: [brief description] - -### Modified Capabilities - - -## Impact - -- `src/path/to/file.ts`: [what changes] -- [other files if applicable] - ---- - -Does this capture the intent? I can adjust before we save it. -``` - -**PAUSE** - Wait for user approval/feedback. - -After approval, save the proposal: -```bash -openspec instructions proposal --change "" --json -``` -Then write the content to `openspec/changes//proposal.md`. - -``` -Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves. - -Next up: specs. -``` - ---- - -## Phase 6: Specs - -**EXPLAIN:** -``` -## Specs - -Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear. - -For a small task like this, we might only need one spec file. -``` - -**DO:** Create the spec file: -```bash -mkdir -p openspec/changes//specs/ -``` - -Draft the spec content: - -``` -Here's the spec: - ---- - -## ADDED Requirements - -### Requirement: - - - -#### Scenario: - -- **WHEN** -- **THEN** -- **AND** - ---- - -This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases. -``` - -Save to `openspec/changes//specs//spec.md`. - ---- - -## Phase 7: Design - -**EXPLAIN:** -``` -## Design - -The design captures **how** we'll build it—technical decisions, tradeoffs, approach. - -For small changes, this might be brief. That's fine—not every change needs deep design discussion. -``` - -**DO:** Draft design.md: - -``` -Here's the design: - ---- - -## Context - -[Brief context about the current state] - -## Goals / Non-Goals - -**Goals:** -- [What we're trying to achieve] - -**Non-Goals:** -- [What's explicitly out of scope] - -## Decisions - -### Decision 1: [Key decision] - -[Explanation of approach and rationale] - ---- - -For a small task, this captures the key decisions without over-engineering. -``` - -Save to `openspec/changes//design.md`. - ---- - -## Phase 8: Tasks - -**EXPLAIN:** -``` -## Tasks - -Finally, we break the work into implementation tasks—checkboxes that drive the apply phase. - -These should be small, clear, and in logical order. -``` - -**DO:** Generate tasks based on specs and design: - -``` -Here are the implementation tasks: - ---- - -## 1. [Category or file] - -- [ ] 1.1 [Specific task] -- [ ] 1.2 [Specific task] - -## 2. Verify - -- [ ] 2.1 [Verification step] - ---- - -Each checkbox becomes a unit of work in the apply phase. Ready to implement? -``` - -**PAUSE** - Wait for user to confirm they're ready to implement. - -Save to `openspec/changes//tasks.md`. - ---- - -## Phase 9: Apply (Implementation) - -**EXPLAIN:** -``` -## Implementation - -Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach. -``` - -**DO:** For each task: - -1. Announce: "Working on task N: [description]" -2. Implement the change in the codebase -3. Reference specs/design naturally: "The spec says X, so I'm doing Y" -4. Mark complete in tasks.md: `- [ ]` → `- [x]` -5. Brief status: "✓ Task N complete" - -Keep narration light—don't over-explain every line of code. - -After all tasks: - -``` -## Implementation Complete - -All tasks done: -- [x] Task 1 -- [x] Task 2 -- [x] ... - -The change is implemented! One more step—let's archive it. -``` - ---- - -## Phase 10: Archive - -**EXPLAIN:** -``` -## Archiving - -When a change is complete, we archive it. This moves it from `openspec/changes/` to `openspec/changes/archive/YYYY-MM-DD-/`. - -Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way. -``` - -**DO:** -```bash -openspec archive "" -``` - -**SHOW:** -``` -Archived to: `openspec/changes/archive/YYYY-MM-DD-/` - -The change is now part of your project's history. The code is in your codebase, the decision record is preserved. -``` - ---- - -## Phase 11: Recap & Next Steps - -``` -## Congratulations! - -You just completed a full OpenSpec cycle: - -1. **Explore** - Thought through the problem -2. **New** - Created a change container -3. **Proposal** - Captured WHY -4. **Specs** - Defined WHAT in detail -5. **Design** - Decided HOW -6. **Tasks** - Broke it into steps -7. **Apply** - Implemented the work -8. **Archive** - Preserved the record - -This same rhythm works for any size change—a small fix or a major feature. - ---- - -## Command Reference - -| Command | What it does | -|---------|--------------| -| `/opsx:explore` | Think through problems before/during work | -| `/opsx:new` | Start a new change, step through artifacts | -| `/opsx:ff` | Fast-forward: create all artifacts at once | -| `/opsx:continue` | Continue working on an existing change | -| `/opsx:apply` | Implement tasks from a change | -| `/opsx:verify` | Verify implementation matches artifacts | -| `/opsx:archive` | Archive a completed change | - ---- - -## What's Next? - -Try `/opsx:new` or `/opsx:ff` on something you actually want to build. You've got the rhythm now! -``` - ---- - -## Graceful Exit Handling - -### User wants to stop mid-way - -If the user says they need to stop, want to pause, or seem disengaged: - -``` -No problem! Your change is saved at `openspec/changes//`. - -To pick up where we left off later: -- `/opsx:continue ` - Resume artifact creation -- `/opsx:apply ` - Jump to implementation (if tasks exist) - -The work won't be lost. Come back whenever you're ready. -``` - -Exit gracefully without pressure. - -### User just wants command reference - -If the user says they just want to see the commands or skip the tutorial: - -``` -## OpenSpec Quick Reference - -| Command | What it does | -|---------|--------------| -| `/opsx:explore` | Think through problems (no code changes) | -| `/opsx:new ` | Start a new change, step by step | -| `/opsx:ff ` | Fast-forward: all artifacts at once | -| `/opsx:continue ` | Continue an existing change | -| `/opsx:apply ` | Implement tasks | -| `/opsx:verify ` | Verify implementation | -| `/opsx:archive ` | Archive when done | - -Try `/opsx:new` to start your first change, or `/opsx:ff` if you want to move fast. -``` - -Exit gracefully. - ---- - -## Guardrails - -- **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive) -- **Keep narration light** during implementation—teach without lecturing -- **Don't skip phases** even if the change is small—the goal is teaching the workflow -- **Pause for acknowledgment** at marked points, but don't over-pause -- **Handle exits gracefully**—never pressure the user to continue -- **Use real codebase tasks**—don't simulate or use fake examples -- **Adjust scope gently**—guide toward smaller tasks but respect user choice diff --git a/.claude/skills/openspec-ff-change/SKILL.md b/.claude/skills/openspec-propose/SKILL.md similarity index 85% rename from .claude/skills/openspec-ff-change/SKILL.md rename to .claude/skills/openspec-propose/SKILL.md index d586012..d27bc53 100644 --- a/.claude/skills/openspec-ff-change/SKILL.md +++ b/.claude/skills/openspec-propose/SKILL.md @@ -1,15 +1,24 @@ --- -name: openspec-ff-change -description: Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually. +name: openspec-propose +description: Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation. license: MIT compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- -Fast-forward through artifact creation - generate everything needed to start implementation in one go. +Propose a new change - create the change and generate all artifacts in one step. + +I'll create a change with artifacts: +- proposal.md (what & why) +- design.md (how) +- tasks.md (implementation steps) + +When ready to implement, run /opsx:apply + +--- **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build. @@ -28,7 +37,7 @@ Fast-forward through artifact creation - generate everything needed to start imp ```bash openspec new change "" ``` - This creates a scaffolded change at `openspec/changes//`. + This creates a scaffolded change at `openspec/changes//` with `.openspec.yaml`. 3. **Get the artifact build order** ```bash @@ -59,7 +68,7 @@ Fast-forward through artifact creation - generate everything needed to start imp - Read any completed dependency files for context - Create the artifact file using `template` as the structure - Apply `context` and `rules` as constraints - but do NOT copy them into the file - - Show brief progress: "✓ Created " + - Show brief progress: "Created " b. **Continue until all `applyRequires` artifacts are complete** - After creating each artifact, re-run `openspec status --change "" --json` @@ -97,5 +106,5 @@ After completing all artifacts, summarize: - Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`) - Always read dependency artifacts before creating a new one - If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum -- If a change with that name already exists, suggest continuing that change instead +- If a change with that name already exists, ask if user wants to continue it or create a new one - Verify each artifact file exists after writing before proceeding to next diff --git a/.claude/skills/openspec-sync-specs/SKILL.md b/.claude/skills/openspec-sync-specs/SKILL.md deleted file mode 100644 index 4c7e3aa..0000000 --- a/.claude/skills/openspec-sync-specs/SKILL.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -name: openspec-sync-specs -description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Sync delta specs from a change to main specs. - -This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement). - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have delta specs (under `specs/` directory). - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Find delta specs** - - Look for delta spec files in `openspec/changes//specs/*/spec.md`. - - Each delta spec file contains sections like: - - `## ADDED Requirements` - New requirements to add - - `## MODIFIED Requirements` - Changes to existing requirements - - `## REMOVED Requirements` - Requirements to remove - - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format) - - If no delta specs found, inform user and stop. - -3. **For each delta spec, apply changes to main specs** - - For each capability with a delta spec at `openspec/changes//specs//spec.md`: - - a. **Read the delta spec** to understand the intended changes - - b. **Read the main spec** at `openspec/specs//spec.md` (may not exist yet) - - c. **Apply changes intelligently**: - - **ADDED Requirements:** - - If requirement doesn't exist in main spec → add it - - If requirement already exists → update it to match (treat as implicit MODIFIED) - - **MODIFIED Requirements:** - - Find the requirement in main spec - - Apply the changes - this can be: - - Adding new scenarios (don't need to copy existing ones) - - Modifying existing scenarios - - Changing the requirement description - - Preserve scenarios/content not mentioned in the delta - - **REMOVED Requirements:** - - Remove the entire requirement block from main spec - - **RENAMED Requirements:** - - Find the FROM requirement, rename to TO - - d. **Create new main spec** if capability doesn't exist yet: - - Create `openspec/specs//spec.md` - - Add Purpose section (can be brief, mark as TBD) - - Add Requirements section with the ADDED requirements - -4. **Show summary** - - After applying all changes, summarize: - - Which capabilities were updated - - What changes were made (requirements added/modified/removed/renamed) - -**Delta Spec Format Reference** - -```markdown -## ADDED Requirements - -### Requirement: New Feature -The system SHALL do something new. - -#### Scenario: Basic case -- **WHEN** user does X -- **THEN** system does Y - -## MODIFIED Requirements - -### Requirement: Existing Feature -#### Scenario: New scenario to add -- **WHEN** user does A -- **THEN** system does B - -## REMOVED Requirements - -### Requirement: Deprecated Feature - -## RENAMED Requirements - -- FROM: `### Requirement: Old Name` -- TO: `### Requirement: New Name` -``` - -**Key Principle: Intelligent Merging** - -Unlike programmatic merging, you can apply **partial updates**: -- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios -- The delta represents *intent*, not a wholesale replacement -- Use your judgment to merge changes sensibly - -**Output On Success** - -``` -## Specs Synced: - -Updated main specs: - -****: -- Added requirement: "New Feature" -- Modified requirement: "Existing Feature" (added 1 scenario) - -****: -- Created new spec file -- Added requirement: "Another Feature" - -Main specs are now updated. The change remains active - archive when implementation is complete. -``` - -**Guardrails** -- Read both delta and main specs before making changes -- Preserve existing content not mentioned in delta -- If something is unclear, ask for clarification -- Show what you're changing as you go -- The operation should be idempotent - running twice should give same result diff --git a/.claude/skills/openspec-verify-change/SKILL.md b/.claude/skills/openspec-verify-change/SKILL.md deleted file mode 100644 index 443ac5f..0000000 --- a/.claude/skills/openspec-verify-change/SKILL.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -name: openspec-verify-change -description: Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Verify that an implementation matches the change artifacts (specs, tasks, design). - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have implementation tasks (tasks artifact exists). - Include the schema used for each change if available. - Mark changes with incomplete tasks as "(In Progress)". - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -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 artifacts exist for this change - -3. **Get the change directory and load artifacts** - - ```bash - openspec instructions apply --change "" --json - ``` - - This returns the change directory and context files. Read all available artifacts from `contextFiles`. - -4. **Initialize verification report structure** - - Create a report structure with three dimensions: - - **Completeness**: Track tasks and spec coverage - - **Correctness**: Track requirement implementation and scenario coverage - - **Coherence**: Track design adherence and pattern consistency - - Each dimension can have CRITICAL, WARNING, or SUGGESTION issues. - -5. **Verify Completeness** - - **Task Completion**: - - If tasks.md exists in contextFiles, read it - - Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete) - - Count complete vs total tasks - - If incomplete tasks exist: - - Add CRITICAL issue for each incomplete task - - Recommendation: "Complete task: " or "Mark as done if already implemented" - - **Spec Coverage**: - - If delta specs exist in `openspec/changes//specs/`: - - Extract all requirements (marked with "### Requirement:") - - For each requirement: - - Search codebase for keywords related to the requirement - - Assess if implementation likely exists - - If requirements appear unimplemented: - - Add CRITICAL issue: "Requirement not found: " - - Recommendation: "Implement requirement X: " - -6. **Verify Correctness** - - **Requirement Implementation Mapping**: - - For each requirement from delta specs: - - Search codebase for implementation evidence - - If found, note file paths and line ranges - - Assess if implementation matches requirement intent - - If divergence detected: - - Add WARNING: "Implementation may diverge from spec:
" - - Recommendation: "Review : against requirement X" - - **Scenario Coverage**: - - For each scenario in delta specs (marked with "#### Scenario:"): - - Check if conditions are handled in code - - Check if tests exist covering the scenario - - If scenario appears uncovered: - - Add WARNING: "Scenario not covered: " - - Recommendation: "Add test or implementation for scenario: " - -7. **Verify Coherence** - - **Design Adherence**: - - If design.md exists in contextFiles: - - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:") - - Verify implementation follows those decisions - - If contradiction detected: - - Add WARNING: "Design decision not followed: " - - Recommendation: "Update implementation or revise design.md to match reality" - - If no design.md: Skip design adherence check, note "No design.md to verify against" - - **Code Pattern Consistency**: - - Review new code for consistency with project patterns - - Check file naming, directory structure, coding style - - If significant deviations found: - - Add SUGGESTION: "Code pattern deviation:
" - - Recommendation: "Consider following project pattern: " - -8. **Generate Verification Report** - - **Summary Scorecard**: - ``` - ## Verification Report: - - ### Summary - | Dimension | Status | - |--------------|------------------| - | Completeness | X/Y tasks, N reqs| - | Correctness | M/N reqs covered | - | Coherence | Followed/Issues | - ``` - - **Issues by Priority**: - - 1. **CRITICAL** (Must fix before archive): - - Incomplete tasks - - Missing requirement implementations - - Each with specific, actionable recommendation - - 2. **WARNING** (Should fix): - - Spec/design divergences - - Missing scenario coverage - - Each with specific recommendation - - 3. **SUGGESTION** (Nice to fix): - - Pattern inconsistencies - - Minor improvements - - Each with specific recommendation - - **Final Assessment**: - - If CRITICAL issues: "X critical issue(s) found. Fix before archiving." - - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)." - - If all clear: "All checks passed. Ready for archive." - -**Verification Heuristics** - -- **Completeness**: Focus on objective checklist items (checkboxes, requirements list) -- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty -- **Coherence**: Look for glaring inconsistencies, don't nitpick style -- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL -- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable - -**Graceful Degradation** - -- If only tasks.md exists: verify task completion only, skip spec/design checks -- If tasks + specs exist: verify completeness and correctness, skip design -- If full artifacts: verify all three dimensions -- Always note which checks were skipped and why - -**Output Format** - -Use clear markdown with: -- Table for summary scorecard -- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION) -- Code references in format: `file.ts:123` -- Specific, actionable recommendations -- No vague suggestions like "consider reviewing" diff --git a/.codex/skills/openspec-apply-change/SKILL.md b/.codex/skills/openspec-apply-change/SKILL.md index 47d4bc2..d474dc1 100644 --- a/.codex/skills/openspec-apply-change/SKILL.md +++ b/.codex/skills/openspec-apply-change/SKILL.md @@ -6,7 +6,7 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Implement tasks from an OpenSpec change. diff --git a/.codex/skills/openspec-archive-change/SKILL.md b/.codex/skills/openspec-archive-change/SKILL.md index 8fa4b23..9b1f851 100644 --- a/.codex/skills/openspec-archive-change/SKILL.md +++ b/.codex/skills/openspec-archive-change/SKILL.md @@ -6,7 +6,7 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Archive a completed change in the experimental workflow. @@ -63,7 +63,7 @@ Archive a completed change in the experimental workflow. - If changes needed: "Sync now (recommended)", "Archive without syncing" - If already synced: "Archive now", "Sync anyway", "Cancel" - If user chooses sync, execute /opsx:sync logic (use the openspec-sync-specs skill). Proceed to archive regardless of choice. + If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change ''. Delta spec analysis: "). Proceed to archive regardless of choice. 5. **Perform the archive** diff --git a/.codex/skills/openspec-bulk-archive-change/SKILL.md b/.codex/skills/openspec-bulk-archive-change/SKILL.md deleted file mode 100644 index 719b279..0000000 --- a/.codex/skills/openspec-bulk-archive-change/SKILL.md +++ /dev/null @@ -1,246 +0,0 @@ ---- -name: openspec-bulk-archive-change -description: Archive multiple completed changes at once. Use when archiving several parallel changes. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Archive multiple completed changes in a single operation. - -This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented. - -**Input**: None required (prompts for selection) - -**Steps** - -1. **Get active changes** - - Run `openspec list --json` to get all active changes. - - If no active changes exist, inform user and stop. - -2. **Prompt for change selection** - - Use **AskUserQuestion tool** with multi-select to let user choose changes: - - Show each change with its schema - - Include an option for "All changes" - - Allow any number of selections (1+ works, 2+ is the typical use case) - - **IMPORTANT**: Do NOT auto-select. Always let the user choose. - -3. **Batch validation - gather status for all selected changes** - - For each selected change, collect: - - a. **Artifact status** - Run `openspec status --change "" --json` - - Parse `schemaName` and `artifacts` list - - Note which artifacts are `done` vs other states - - b. **Task completion** - Read `openspec/changes//tasks.md` - - Count `- [ ]` (incomplete) vs `- [x]` (complete) - - If no tasks file exists, note as "No tasks" - - c. **Delta specs** - Check `openspec/changes//specs/` directory - - List which capability specs exist - - For each, extract requirement names (lines matching `### Requirement: `) - -4. **Detect spec conflicts** - - Build a map of `capability -> [changes that touch it]`: - - ``` - auth -> [change-a, change-b] <- CONFLICT (2+ changes) - api -> [change-c] <- OK (only 1 change) - ``` - - A conflict exists when 2+ selected changes have delta specs for the same capability. - -5. **Resolve conflicts agentically** - - **For each conflict**, investigate the codebase: - - a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify - - b. **Search the codebase** for implementation evidence: - - Look for code implementing requirements from each delta spec - - Check for related files, functions, or tests - - c. **Determine resolution**: - - If only one change is actually implemented -> sync that one's specs - - If both implemented -> apply in chronological order (older first, newer overwrites) - - If neither implemented -> skip spec sync, warn user - - d. **Record resolution** for each conflict: - - Which change's specs to apply - - In what order (if both) - - Rationale (what was found in codebase) - -6. **Show consolidated status table** - - Display a table summarizing all changes: - - ``` - | Change | Artifacts | Tasks | Specs | Conflicts | Status | - |---------------------|-----------|-------|---------|-----------|--------| - | schema-management | Done | 5/5 | 2 delta | None | Ready | - | project-config | Done | 3/3 | 1 delta | None | Ready | - | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* | - | add-verify-skill | 1 left | 2/5 | None | None | Warn | - ``` - - For conflicts, show the resolution: - ``` - * Conflict resolution: - - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order) - ``` - - For incomplete changes, show warnings: - ``` - Warnings: - - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks - ``` - -7. **Confirm batch operation** - - Use **AskUserQuestion tool** with a single confirmation: - - - "Archive N changes?" with options based on status - - Options might include: - - "Archive all N changes" - - "Archive only N ready changes (skip incomplete)" - - "Cancel" - - If there are incomplete changes, make clear they'll be archived with warnings. - -8. **Execute archive for each confirmed change** - - Process changes in the determined order (respecting conflict resolution): - - a. **Sync specs** if delta specs exist: - - Use the openspec-sync-specs approach (agent-driven intelligent merge) - - For conflicts, apply in resolved order - - Track if sync was done - - b. **Perform the archive**: - ```bash - mkdir -p openspec/changes/archive - mv openspec/changes/ openspec/changes/archive/YYYY-MM-DD- - ``` - - c. **Track outcome** for each change: - - Success: archived successfully - - Failed: error during archive (record error) - - Skipped: user chose not to archive (if applicable) - -9. **Display summary** - - Show final results: - - ``` - ## Bulk Archive Complete - - Archived 3 changes: - - schema-management-cli -> archive/2026-01-19-schema-management-cli/ - - project-config -> archive/2026-01-19-project-config/ - - add-oauth -> archive/2026-01-19-add-oauth/ - - Skipped 1 change: - - add-verify-skill (user chose not to archive incomplete) - - Spec sync summary: - - 4 delta specs synced to main specs - - 1 conflict resolved (auth: applied both in chronological order) - ``` - - If any failures: - ``` - Failed 1 change: - - some-change: Archive directory already exists - ``` - -**Conflict Resolution Examples** - -Example 1: Only one implemented -``` -Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt] - -Checking add-oauth: -- Delta adds "OAuth Provider Integration" requirement -- Searching codebase... found src/auth/oauth.ts implementing OAuth flow - -Checking add-jwt: -- Delta adds "JWT Token Handling" requirement -- Searching codebase... no JWT implementation found - -Resolution: Only add-oauth is implemented. Will sync add-oauth specs only. -``` - -Example 2: Both implemented -``` -Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql] - -Checking add-rest-api (created 2026-01-10): -- Delta adds "REST Endpoints" requirement -- Searching codebase... found src/api/rest.ts - -Checking add-graphql (created 2026-01-15): -- Delta adds "GraphQL Schema" requirement -- Searching codebase... found src/api/graphql.ts - -Resolution: Both implemented. Will apply add-rest-api specs first, -then add-graphql specs (chronological order, newer takes precedence). -``` - -**Output On Success** - -``` -## Bulk Archive Complete - -Archived N changes: -- -> archive/YYYY-MM-DD-/ -- -> archive/YYYY-MM-DD-/ - -Spec sync summary: -- N delta specs synced to main specs -- No conflicts (or: M conflicts resolved) -``` - -**Output On Partial Success** - -``` -## Bulk Archive Complete (partial) - -Archived N changes: -- -> archive/YYYY-MM-DD-/ - -Skipped M changes: -- (user chose not to archive incomplete) - -Failed K changes: -- : Archive directory already exists -``` - -**Output When No Changes** - -``` -## No Changes to Archive - -No active changes found. Use `/opsx:new` to create a new change. -``` - -**Guardrails** -- Allow any number of changes (1+ is fine, 2+ is the typical use case) -- Always prompt for selection, never auto-select -- Detect spec conflicts early and resolve by checking codebase -- When both changes are implemented, apply specs in chronological order -- Skip spec sync only when implementation is missing (warn user) -- Show clear per-change status before confirming -- Use single confirmation for entire batch -- Track and report all outcomes (success/skip/fail) -- Preserve .openspec.yaml when moving to archive -- Archive directory target uses current date: YYYY-MM-DD- -- If archive target exists, fail that change but continue with others diff --git a/.codex/skills/openspec-continue-change/SKILL.md b/.codex/skills/openspec-continue-change/SKILL.md deleted file mode 100644 index 5060b2f..0000000 --- a/.codex/skills/openspec-continue-change/SKILL.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -name: openspec-continue-change -description: Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Continue working on a change by creating the next artifact. - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on. - - Present the top 3-4 most recently modified changes as options, showing: - - Change name - - Schema (from `schema` field if present, otherwise "spec-driven") - - Status (e.g., "0/5 tasks", "complete", "no tasks") - - How recently it was modified (from `lastModified` field) - - Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue. - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Check current status** - ```bash - openspec status --change "" --json - ``` - Parse the JSON to understand current state. The response includes: - - `schemaName`: The workflow schema being used (e.g., "spec-driven") - - `artifacts`: Array of artifacts with their status ("done", "ready", "blocked") - - `isComplete`: Boolean indicating if all artifacts are complete - -3. **Act based on status**: - - --- - - **If all artifacts are complete (`isComplete: true`)**: - - Congratulate the user - - Show final status including the schema used - - Suggest: "All artifacts created! You can now implement this change or archive it." - - STOP - - --- - - **If artifacts are ready to create** (status shows artifacts with `status: "ready"`): - - Pick the FIRST artifact with `status: "ready"` from the status output - - Get its instructions: - ```bash - openspec instructions --change "" --json - ``` - - Parse the JSON. The key fields are: - - `context`: Project background (constraints for you - do NOT include in output) - - `rules`: Artifact-specific rules (constraints for you - do NOT include in output) - - `template`: The structure to use for your output file - - `instruction`: Schema-specific guidance - - `outputPath`: Where to write the artifact - - `dependencies`: Completed artifacts to read for context - - **Create the artifact file**: - - Read any completed dependency files for context - - Use `template` as the structure - fill in its sections - - Apply `context` and `rules` as constraints when writing - but do NOT copy them into the file - - Write to the output path specified in instructions - - Show what was created and what's now unlocked - - STOP after creating ONE artifact - - --- - - **If no artifacts are ready (all blocked)**: - - This shouldn't happen with a valid schema - - Show status and suggest checking for issues - -4. **After creating an artifact, show progress** - ```bash - openspec status --change "" - ``` - -**Output** - -After each invocation, show: -- Which artifact was created -- Schema workflow being used -- Current progress (N/M complete) -- What artifacts are now unlocked -- Prompt: "Want to continue? Just ask me to continue or tell me what to do next." - -**Artifact Creation Guidelines** - -The artifact types and their purpose depend on the schema. Use the `instruction` field from the instructions output to understand what to create. - -Common artifact patterns: - -**spec-driven schema** (proposal → specs → design → tasks): -- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact. - - The Capabilities section is critical - each capability listed will need a spec file. -- **specs//spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name). -- **design.md**: Document technical decisions, architecture, and implementation approach. -- **tasks.md**: Break down implementation into checkboxed tasks. - -For other schemas, follow the `instruction` field from the CLI output. - -**Guardrails** -- Create ONE artifact per invocation -- Always read dependency artifacts before creating a new one -- Never skip artifacts or create out of order -- If context is unclear, ask the user before creating -- Verify the artifact file exists after writing before marking progress -- Use the schema's artifact sequence, don't assume specific artifact names -- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file - - Do NOT copy ``, ``, `` blocks into the artifact - - These guide what you write, but should never appear in the output diff --git a/.codex/skills/openspec-explore/SKILL.md b/.codex/skills/openspec-explore/SKILL.md index 8ed4a76..ffa10ca 100644 --- a/.codex/skills/openspec-explore/SKILL.md +++ b/.codex/skills/openspec-explore/SKILL.md @@ -6,12 +6,12 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes. -**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with `/opsx:new` or `/opsx:ff`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. +**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore. @@ -95,8 +95,7 @@ This tells you: Think freely. When insights crystallize, you might offer: -- "This feels solid enough to start a change. Want me to create one?" - → Can transition to `/opsx:new` or `/opsx:ff` +- "This feels solid enough to start a change. Want me to create a proposal?" - Or keep exploring - no pressure to formalize ### When a change exists @@ -252,7 +251,7 @@ You: That changes everything. There's no required ending. Discovery might: -- **Flow into action**: "Ready to start? /opsx:new or /opsx:ff" +- **Flow into a proposal**: "Ready to start? I can create a change proposal." - **Result in artifact updates**: "Updated design.md with these decisions" - **Just provide clarity**: User has what they need, moves on - **Continue later**: "We can pick this up anytime" @@ -269,8 +268,7 @@ When it feels like things are crystallizing, you might summarize: **Open questions**: [if any remain] **Next steps** (if ready): -- Create a change: /opsx:new -- Fast-forward to tasks: /opsx:ff +- Create a change proposal - Keep exploring: just keep talking ``` diff --git a/.codex/skills/openspec-new-change/SKILL.md b/.codex/skills/openspec-new-change/SKILL.md deleted file mode 100644 index 37ac7ba..0000000 --- a/.codex/skills/openspec-new-change/SKILL.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -name: openspec-new-change -description: Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Start a new change using the experimental artifact-driven approach. - -**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build. - -**Steps** - -1. **If no clear input provided, ask what they want to build** - - Use the **AskUserQuestion tool** (open-ended, no preset options) to ask: - > "What change do you want to work on? Describe what you want to build or fix." - - From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`). - - **IMPORTANT**: Do NOT proceed without understanding what the user wants to build. - -2. **Determine the workflow schema** - - Use the default schema (omit `--schema`) unless the user explicitly requests a different workflow. - - **Use a different schema only if the user mentions:** - - A specific schema name → use `--schema ` - - "show workflows" or "what workflows" → run `openspec schemas --json` and let them choose - - **Otherwise**: Omit `--schema` to use the default. - -3. **Create the change directory** - ```bash - openspec new change "" - ``` - Add `--schema ` only if the user requested a specific workflow. - This creates a scaffolded change at `openspec/changes//` with the selected schema. - -4. **Show the artifact status** - ```bash - openspec status --change "" - ``` - This shows which artifacts need to be created and which are ready (dependencies satisfied). - -5. **Get instructions for the first artifact** - The first artifact depends on the schema (e.g., `proposal` for spec-driven). - Check the status output to find the first artifact with status "ready". - ```bash - openspec instructions --change "" - ``` - This outputs the template and context for creating the first artifact. - -6. **STOP and wait for user direction** - -**Output** - -After completing the steps, summarize: -- Change name and location -- Schema/workflow being used and its artifact sequence -- Current status (0/N artifacts complete) -- The template for the first artifact -- Prompt: "Ready to create the first artifact? Just describe what this change is about and I'll draft it, or ask me to continue." - -**Guardrails** -- Do NOT create any artifacts yet - just show the instructions -- Do NOT advance beyond showing the first artifact template -- If the name is invalid (not kebab-case), ask for a valid name -- If a change with that name already exists, suggest continuing that change instead -- Pass --schema if using a non-default workflow diff --git a/.codex/skills/openspec-onboard/SKILL.md b/.codex/skills/openspec-onboard/SKILL.md deleted file mode 100644 index 4a03038..0000000 --- a/.codex/skills/openspec-onboard/SKILL.md +++ /dev/null @@ -1,529 +0,0 @@ ---- -name: openspec-onboard -description: Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step. - ---- - -## Preflight - -Before starting, check if OpenSpec is initialized: - -```bash -openspec status --json 2>&1 || echo "NOT_INITIALIZED" -``` - -**If not initialized:** -> OpenSpec isn't set up in this project yet. Run `openspec init` first, then come back to `/opsx:onboard`. - -Stop here if not initialized. - ---- - -## Phase 1: Welcome - -Display: - -``` -## Welcome to OpenSpec! - -I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it. - -**What we'll do:** -1. Pick a small, real task in your codebase -2. Explore the problem briefly -3. Create a change (the container for our work) -4. Build the artifacts: proposal → specs → design → tasks -5. Implement the tasks -6. Archive the completed change - -**Time:** ~15-20 minutes - -Let's start by finding something to work on. -``` - ---- - -## Phase 2: Task Selection - -### Codebase Analysis - -Scan the codebase for small improvement opportunities. Look for: - -1. **TODO/FIXME comments** - Search for `TODO`, `FIXME`, `HACK`, `XXX` in code files -2. **Missing error handling** - `catch` blocks that swallow errors, risky operations without try-catch -3. **Functions without tests** - Cross-reference `src/` with test directories -4. **Type issues** - `any` types in TypeScript files (`: any`, `as any`) -5. **Debug artifacts** - `console.log`, `console.debug`, `debugger` statements in non-debug code -6. **Missing validation** - User input handlers without validation - -Also check recent git activity: -```bash -git log --oneline -10 2>/dev/null || echo "No git history" -``` - -### Present Suggestions - -From your analysis, present 3-4 specific suggestions: - -``` -## Task Suggestions - -Based on scanning your codebase, here are some good starter tasks: - -**1. [Most promising task]** - Location: `src/path/to/file.ts:42` - Scope: ~1-2 files, ~20-30 lines - Why it's good: [brief reason] - -**2. [Second task]** - Location: `src/another/file.ts` - Scope: ~1 file, ~15 lines - Why it's good: [brief reason] - -**3. [Third task]** - Location: [location] - Scope: [estimate] - Why it's good: [brief reason] - -**4. Something else?** - Tell me what you'd like to work on. - -Which task interests you? (Pick a number or describe your own) -``` - -**If nothing found:** Fall back to asking what the user wants to build: -> I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix? - -### Scope Guardrail - -If the user picks or describes something too large (major feature, multi-day work): - -``` -That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through. - -For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details. - -**Options:** -1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]? -2. **Pick something else** - One of the other suggestions, or a different small task? -3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer. - -What would you prefer? -``` - -Let the user override if they insist—this is a soft guardrail. - ---- - -## Phase 3: Explore Demo - -Once a task is selected, briefly demonstrate explore mode: - -``` -Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction. -``` - -Spend 1-2 minutes investigating the relevant code: -- Read the file(s) involved -- Draw a quick ASCII diagram if it helps -- Note any considerations - -``` -## Quick Exploration - -[Your brief analysis—what you found, any considerations] - -┌─────────────────────────────────────────┐ -│ [Optional: ASCII diagram if helpful] │ -└─────────────────────────────────────────┘ - -Explore mode (`/opsx:explore`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem. - -Now let's create a change to hold our work. -``` - -**PAUSE** - Wait for user acknowledgment before proceeding. - ---- - -## Phase 4: Create the Change - -**EXPLAIN:** -``` -## Creating a Change - -A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in `openspec/changes//` and holds your artifacts—proposal, specs, design, tasks. - -Let me create one for our task. -``` - -**DO:** Create the change with a derived kebab-case name: -```bash -openspec new change "" -``` - -**SHOW:** -``` -Created: `openspec/changes//` - -The folder structure: -``` -openspec/changes// -├── proposal.md ← Why we're doing this (empty, we'll fill it) -├── design.md ← How we'll build it (empty) -├── specs/ ← Detailed requirements (empty) -└── tasks.md ← Implementation checklist (empty) -``` - -Now let's fill in the first artifact—the proposal. -``` - ---- - -## Phase 5: Proposal - -**EXPLAIN:** -``` -## The Proposal - -The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work. - -I'll draft one based on our task. -``` - -**DO:** Draft the proposal content (don't save yet): - -``` -Here's a draft proposal: - ---- - -## Why - -[1-2 sentences explaining the problem/opportunity] - -## What Changes - -[Bullet points of what will be different] - -## Capabilities - -### New Capabilities -- ``: [brief description] - -### Modified Capabilities - - -## Impact - -- `src/path/to/file.ts`: [what changes] -- [other files if applicable] - ---- - -Does this capture the intent? I can adjust before we save it. -``` - -**PAUSE** - Wait for user approval/feedback. - -After approval, save the proposal: -```bash -openspec instructions proposal --change "" --json -``` -Then write the content to `openspec/changes//proposal.md`. - -``` -Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves. - -Next up: specs. -``` - ---- - -## Phase 6: Specs - -**EXPLAIN:** -``` -## Specs - -Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear. - -For a small task like this, we might only need one spec file. -``` - -**DO:** Create the spec file: -```bash -mkdir -p openspec/changes//specs/ -``` - -Draft the spec content: - -``` -Here's the spec: - ---- - -## ADDED Requirements - -### Requirement: - - - -#### Scenario: - -- **WHEN** -- **THEN** -- **AND** - ---- - -This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases. -``` - -Save to `openspec/changes//specs//spec.md`. - ---- - -## Phase 7: Design - -**EXPLAIN:** -``` -## Design - -The design captures **how** we'll build it—technical decisions, tradeoffs, approach. - -For small changes, this might be brief. That's fine—not every change needs deep design discussion. -``` - -**DO:** Draft design.md: - -``` -Here's the design: - ---- - -## Context - -[Brief context about the current state] - -## Goals / Non-Goals - -**Goals:** -- [What we're trying to achieve] - -**Non-Goals:** -- [What's explicitly out of scope] - -## Decisions - -### Decision 1: [Key decision] - -[Explanation of approach and rationale] - ---- - -For a small task, this captures the key decisions without over-engineering. -``` - -Save to `openspec/changes//design.md`. - ---- - -## Phase 8: Tasks - -**EXPLAIN:** -``` -## Tasks - -Finally, we break the work into implementation tasks—checkboxes that drive the apply phase. - -These should be small, clear, and in logical order. -``` - -**DO:** Generate tasks based on specs and design: - -``` -Here are the implementation tasks: - ---- - -## 1. [Category or file] - -- [ ] 1.1 [Specific task] -- [ ] 1.2 [Specific task] - -## 2. Verify - -- [ ] 2.1 [Verification step] - ---- - -Each checkbox becomes a unit of work in the apply phase. Ready to implement? -``` - -**PAUSE** - Wait for user to confirm they're ready to implement. - -Save to `openspec/changes//tasks.md`. - ---- - -## Phase 9: Apply (Implementation) - -**EXPLAIN:** -``` -## Implementation - -Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach. -``` - -**DO:** For each task: - -1. Announce: "Working on task N: [description]" -2. Implement the change in the codebase -3. Reference specs/design naturally: "The spec says X, so I'm doing Y" -4. Mark complete in tasks.md: `- [ ]` → `- [x]` -5. Brief status: "✓ Task N complete" - -Keep narration light—don't over-explain every line of code. - -After all tasks: - -``` -## Implementation Complete - -All tasks done: -- [x] Task 1 -- [x] Task 2 -- [x] ... - -The change is implemented! One more step—let's archive it. -``` - ---- - -## Phase 10: Archive - -**EXPLAIN:** -``` -## Archiving - -When a change is complete, we archive it. This moves it from `openspec/changes/` to `openspec/changes/archive/YYYY-MM-DD-/`. - -Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way. -``` - -**DO:** -```bash -openspec archive "" -``` - -**SHOW:** -``` -Archived to: `openspec/changes/archive/YYYY-MM-DD-/` - -The change is now part of your project's history. The code is in your codebase, the decision record is preserved. -``` - ---- - -## Phase 11: Recap & Next Steps - -``` -## Congratulations! - -You just completed a full OpenSpec cycle: - -1. **Explore** - Thought through the problem -2. **New** - Created a change container -3. **Proposal** - Captured WHY -4. **Specs** - Defined WHAT in detail -5. **Design** - Decided HOW -6. **Tasks** - Broke it into steps -7. **Apply** - Implemented the work -8. **Archive** - Preserved the record - -This same rhythm works for any size change—a small fix or a major feature. - ---- - -## Command Reference - -| Command | What it does | -|---------|--------------| -| `/opsx:explore` | Think through problems before/during work | -| `/opsx:new` | Start a new change, step through artifacts | -| `/opsx:ff` | Fast-forward: create all artifacts at once | -| `/opsx:continue` | Continue working on an existing change | -| `/opsx:apply` | Implement tasks from a change | -| `/opsx:verify` | Verify implementation matches artifacts | -| `/opsx:archive` | Archive a completed change | - ---- - -## What's Next? - -Try `/opsx:new` or `/opsx:ff` on something you actually want to build. You've got the rhythm now! -``` - ---- - -## Graceful Exit Handling - -### User wants to stop mid-way - -If the user says they need to stop, want to pause, or seem disengaged: - -``` -No problem! Your change is saved at `openspec/changes//`. - -To pick up where we left off later: -- `/opsx:continue ` - Resume artifact creation -- `/opsx:apply ` - Jump to implementation (if tasks exist) - -The work won't be lost. Come back whenever you're ready. -``` - -Exit gracefully without pressure. - -### User just wants command reference - -If the user says they just want to see the commands or skip the tutorial: - -``` -## OpenSpec Quick Reference - -| Command | What it does | -|---------|--------------| -| `/opsx:explore` | Think through problems (no code changes) | -| `/opsx:new ` | Start a new change, step by step | -| `/opsx:ff ` | Fast-forward: all artifacts at once | -| `/opsx:continue ` | Continue an existing change | -| `/opsx:apply ` | Implement tasks | -| `/opsx:verify ` | Verify implementation | -| `/opsx:archive ` | Archive when done | - -Try `/opsx:new` to start your first change, or `/opsx:ff` if you want to move fast. -``` - -Exit gracefully. - ---- - -## Guardrails - -- **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive) -- **Keep narration light** during implementation—teach without lecturing -- **Don't skip phases** even if the change is small—the goal is teaching the workflow -- **Pause for acknowledgment** at marked points, but don't over-pause -- **Handle exits gracefully**—never pressure the user to continue -- **Use real codebase tasks**—don't simulate or use fake examples -- **Adjust scope gently**—guide toward smaller tasks but respect user choice diff --git a/.codex/skills/openspec-ff-change/SKILL.md b/.codex/skills/openspec-propose/SKILL.md similarity index 85% rename from .codex/skills/openspec-ff-change/SKILL.md rename to .codex/skills/openspec-propose/SKILL.md index d586012..d27bc53 100644 --- a/.codex/skills/openspec-ff-change/SKILL.md +++ b/.codex/skills/openspec-propose/SKILL.md @@ -1,15 +1,24 @@ --- -name: openspec-ff-change -description: Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually. +name: openspec-propose +description: Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation. license: MIT compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- -Fast-forward through artifact creation - generate everything needed to start implementation in one go. +Propose a new change - create the change and generate all artifacts in one step. + +I'll create a change with artifacts: +- proposal.md (what & why) +- design.md (how) +- tasks.md (implementation steps) + +When ready to implement, run /opsx:apply + +--- **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build. @@ -28,7 +37,7 @@ Fast-forward through artifact creation - generate everything needed to start imp ```bash openspec new change "" ``` - This creates a scaffolded change at `openspec/changes//`. + This creates a scaffolded change at `openspec/changes//` with `.openspec.yaml`. 3. **Get the artifact build order** ```bash @@ -59,7 +68,7 @@ Fast-forward through artifact creation - generate everything needed to start imp - Read any completed dependency files for context - Create the artifact file using `template` as the structure - Apply `context` and `rules` as constraints - but do NOT copy them into the file - - Show brief progress: "✓ Created " + - Show brief progress: "Created " b. **Continue until all `applyRequires` artifacts are complete** - After creating each artifact, re-run `openspec status --change "" --json` @@ -97,5 +106,5 @@ After completing all artifacts, summarize: - Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`) - Always read dependency artifacts before creating a new one - If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum -- If a change with that name already exists, suggest continuing that change instead +- If a change with that name already exists, ask if user wants to continue it or create a new one - Verify each artifact file exists after writing before proceeding to next diff --git a/.codex/skills/openspec-sync-specs/SKILL.md b/.codex/skills/openspec-sync-specs/SKILL.md deleted file mode 100644 index 4c7e3aa..0000000 --- a/.codex/skills/openspec-sync-specs/SKILL.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -name: openspec-sync-specs -description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Sync delta specs from a change to main specs. - -This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement). - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have delta specs (under `specs/` directory). - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Find delta specs** - - Look for delta spec files in `openspec/changes//specs/*/spec.md`. - - Each delta spec file contains sections like: - - `## ADDED Requirements` - New requirements to add - - `## MODIFIED Requirements` - Changes to existing requirements - - `## REMOVED Requirements` - Requirements to remove - - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format) - - If no delta specs found, inform user and stop. - -3. **For each delta spec, apply changes to main specs** - - For each capability with a delta spec at `openspec/changes//specs//spec.md`: - - a. **Read the delta spec** to understand the intended changes - - b. **Read the main spec** at `openspec/specs//spec.md` (may not exist yet) - - c. **Apply changes intelligently**: - - **ADDED Requirements:** - - If requirement doesn't exist in main spec → add it - - If requirement already exists → update it to match (treat as implicit MODIFIED) - - **MODIFIED Requirements:** - - Find the requirement in main spec - - Apply the changes - this can be: - - Adding new scenarios (don't need to copy existing ones) - - Modifying existing scenarios - - Changing the requirement description - - Preserve scenarios/content not mentioned in the delta - - **REMOVED Requirements:** - - Remove the entire requirement block from main spec - - **RENAMED Requirements:** - - Find the FROM requirement, rename to TO - - d. **Create new main spec** if capability doesn't exist yet: - - Create `openspec/specs//spec.md` - - Add Purpose section (can be brief, mark as TBD) - - Add Requirements section with the ADDED requirements - -4. **Show summary** - - After applying all changes, summarize: - - Which capabilities were updated - - What changes were made (requirements added/modified/removed/renamed) - -**Delta Spec Format Reference** - -```markdown -## ADDED Requirements - -### Requirement: New Feature -The system SHALL do something new. - -#### Scenario: Basic case -- **WHEN** user does X -- **THEN** system does Y - -## MODIFIED Requirements - -### Requirement: Existing Feature -#### Scenario: New scenario to add -- **WHEN** user does A -- **THEN** system does B - -## REMOVED Requirements - -### Requirement: Deprecated Feature - -## RENAMED Requirements - -- FROM: `### Requirement: Old Name` -- TO: `### Requirement: New Name` -``` - -**Key Principle: Intelligent Merging** - -Unlike programmatic merging, you can apply **partial updates**: -- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios -- The delta represents *intent*, not a wholesale replacement -- Use your judgment to merge changes sensibly - -**Output On Success** - -``` -## Specs Synced: - -Updated main specs: - -****: -- Added requirement: "New Feature" -- Modified requirement: "Existing Feature" (added 1 scenario) - -****: -- Created new spec file -- Added requirement: "Another Feature" - -Main specs are now updated. The change remains active - archive when implementation is complete. -``` - -**Guardrails** -- Read both delta and main specs before making changes -- Preserve existing content not mentioned in delta -- If something is unclear, ask for clarification -- Show what you're changing as you go -- The operation should be idempotent - running twice should give same result diff --git a/.codex/skills/openspec-verify-change/SKILL.md b/.codex/skills/openspec-verify-change/SKILL.md deleted file mode 100644 index 443ac5f..0000000 --- a/.codex/skills/openspec-verify-change/SKILL.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -name: openspec-verify-change -description: Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Verify that an implementation matches the change artifacts (specs, tasks, design). - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have implementation tasks (tasks artifact exists). - Include the schema used for each change if available. - Mark changes with incomplete tasks as "(In Progress)". - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -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 artifacts exist for this change - -3. **Get the change directory and load artifacts** - - ```bash - openspec instructions apply --change "" --json - ``` - - This returns the change directory and context files. Read all available artifacts from `contextFiles`. - -4. **Initialize verification report structure** - - Create a report structure with three dimensions: - - **Completeness**: Track tasks and spec coverage - - **Correctness**: Track requirement implementation and scenario coverage - - **Coherence**: Track design adherence and pattern consistency - - Each dimension can have CRITICAL, WARNING, or SUGGESTION issues. - -5. **Verify Completeness** - - **Task Completion**: - - If tasks.md exists in contextFiles, read it - - Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete) - - Count complete vs total tasks - - If incomplete tasks exist: - - Add CRITICAL issue for each incomplete task - - Recommendation: "Complete task: " or "Mark as done if already implemented" - - **Spec Coverage**: - - If delta specs exist in `openspec/changes//specs/`: - - Extract all requirements (marked with "### Requirement:") - - For each requirement: - - Search codebase for keywords related to the requirement - - Assess if implementation likely exists - - If requirements appear unimplemented: - - Add CRITICAL issue: "Requirement not found: " - - Recommendation: "Implement requirement X: " - -6. **Verify Correctness** - - **Requirement Implementation Mapping**: - - For each requirement from delta specs: - - Search codebase for implementation evidence - - If found, note file paths and line ranges - - Assess if implementation matches requirement intent - - If divergence detected: - - Add WARNING: "Implementation may diverge from spec:
" - - Recommendation: "Review : against requirement X" - - **Scenario Coverage**: - - For each scenario in delta specs (marked with "#### Scenario:"): - - Check if conditions are handled in code - - Check if tests exist covering the scenario - - If scenario appears uncovered: - - Add WARNING: "Scenario not covered: " - - Recommendation: "Add test or implementation for scenario: " - -7. **Verify Coherence** - - **Design Adherence**: - - If design.md exists in contextFiles: - - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:") - - Verify implementation follows those decisions - - If contradiction detected: - - Add WARNING: "Design decision not followed: " - - Recommendation: "Update implementation or revise design.md to match reality" - - If no design.md: Skip design adherence check, note "No design.md to verify against" - - **Code Pattern Consistency**: - - Review new code for consistency with project patterns - - Check file naming, directory structure, coding style - - If significant deviations found: - - Add SUGGESTION: "Code pattern deviation:
" - - Recommendation: "Consider following project pattern: " - -8. **Generate Verification Report** - - **Summary Scorecard**: - ``` - ## Verification Report: - - ### Summary - | Dimension | Status | - |--------------|------------------| - | Completeness | X/Y tasks, N reqs| - | Correctness | M/N reqs covered | - | Coherence | Followed/Issues | - ``` - - **Issues by Priority**: - - 1. **CRITICAL** (Must fix before archive): - - Incomplete tasks - - Missing requirement implementations - - Each with specific, actionable recommendation - - 2. **WARNING** (Should fix): - - Spec/design divergences - - Missing scenario coverage - - Each with specific recommendation - - 3. **SUGGESTION** (Nice to fix): - - Pattern inconsistencies - - Minor improvements - - Each with specific recommendation - - **Final Assessment**: - - If CRITICAL issues: "X critical issue(s) found. Fix before archiving." - - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)." - - If all clear: "All checks passed. Ready for archive." - -**Verification Heuristics** - -- **Completeness**: Focus on objective checklist items (checkboxes, requirements list) -- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty -- **Coherence**: Look for glaring inconsistencies, don't nitpick style -- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL -- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable - -**Graceful Degradation** - -- If only tasks.md exists: verify task completion only, skip spec/design checks -- If tasks + specs exist: verify completeness and correctness, skip design -- If full artifacts: verify all three dimensions -- Always note which checks were skipped and why - -**Output Format** - -Use clear markdown with: -- Table for summary scorecard -- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION) -- Code references in format: `file.ts:123` -- Specific, actionable recommendations -- No vague suggestions like "consider reviewing" diff --git a/.opencode/command/opsx-archive.md b/.opencode/command/opsx-archive.md index 20ad82b..2bd807a 100644 --- a/.opencode/command/opsx-archive.md +++ b/.opencode/command/opsx-archive.md @@ -56,7 +56,7 @@ Archive a completed change in the experimental workflow. - If changes needed: "Sync now (recommended)", "Archive without syncing" - If already synced: "Archive now", "Sync anyway", "Cancel" - If user chooses sync, execute `/opsx-sync` logic. Proceed to archive regardless of choice. + If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change ''. Delta spec analysis: "). Proceed to archive regardless of choice. 5. **Perform the archive** @@ -150,5 +150,5 @@ Target archive directory already exists. - Don't block archive on warnings - just inform and confirm - Preserve .openspec.yaml when moving to archive (it moves with the directory) - Show clear summary of what happened -- If sync is requested, use /opsx-sync approach (agent-driven) +- If sync is requested, use the Skill tool to invoke `openspec-sync-specs` (agent-driven) - If delta specs exist, always run the sync assessment and show the combined summary before prompting diff --git a/.opencode/command/opsx-bulk-archive.md b/.opencode/command/opsx-bulk-archive.md deleted file mode 100644 index 05fdf8d..0000000 --- a/.opencode/command/opsx-bulk-archive.md +++ /dev/null @@ -1,239 +0,0 @@ ---- -description: Archive multiple completed changes at once ---- - -Archive multiple completed changes in a single operation. - -This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented. - -**Input**: None required (prompts for selection) - -**Steps** - -1. **Get active changes** - - Run `openspec list --json` to get all active changes. - - If no active changes exist, inform user and stop. - -2. **Prompt for change selection** - - Use **AskUserQuestion tool** with multi-select to let user choose changes: - - Show each change with its schema - - Include an option for "All changes" - - Allow any number of selections (1+ works, 2+ is the typical use case) - - **IMPORTANT**: Do NOT auto-select. Always let the user choose. - -3. **Batch validation - gather status for all selected changes** - - For each selected change, collect: - - a. **Artifact status** - Run `openspec status --change "" --json` - - Parse `schemaName` and `artifacts` list - - Note which artifacts are `done` vs other states - - b. **Task completion** - Read `openspec/changes//tasks.md` - - Count `- [ ]` (incomplete) vs `- [x]` (complete) - - If no tasks file exists, note as "No tasks" - - c. **Delta specs** - Check `openspec/changes//specs/` directory - - List which capability specs exist - - For each, extract requirement names (lines matching `### Requirement: `) - -4. **Detect spec conflicts** - - Build a map of `capability -> [changes that touch it]`: - - ``` - auth -> [change-a, change-b] <- CONFLICT (2+ changes) - api -> [change-c] <- OK (only 1 change) - ``` - - A conflict exists when 2+ selected changes have delta specs for the same capability. - -5. **Resolve conflicts agentically** - - **For each conflict**, investigate the codebase: - - a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify - - b. **Search the codebase** for implementation evidence: - - Look for code implementing requirements from each delta spec - - Check for related files, functions, or tests - - c. **Determine resolution**: - - If only one change is actually implemented -> sync that one's specs - - If both implemented -> apply in chronological order (older first, newer overwrites) - - If neither implemented -> skip spec sync, warn user - - d. **Record resolution** for each conflict: - - Which change's specs to apply - - In what order (if both) - - Rationale (what was found in codebase) - -6. **Show consolidated status table** - - Display a table summarizing all changes: - - ``` - | Change | Artifacts | Tasks | Specs | Conflicts | Status | - |---------------------|-----------|-------|---------|-----------|--------| - | schema-management | Done | 5/5 | 2 delta | None | Ready | - | project-config | Done | 3/3 | 1 delta | None | Ready | - | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* | - | add-verify-skill | 1 left | 2/5 | None | None | Warn | - ``` - - For conflicts, show the resolution: - ``` - * Conflict resolution: - - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order) - ``` - - For incomplete changes, show warnings: - ``` - Warnings: - - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks - ``` - -7. **Confirm batch operation** - - Use **AskUserQuestion tool** with a single confirmation: - - - "Archive N changes?" with options based on status - - Options might include: - - "Archive all N changes" - - "Archive only N ready changes (skip incomplete)" - - "Cancel" - - If there are incomplete changes, make clear they'll be archived with warnings. - -8. **Execute archive for each confirmed change** - - Process changes in the determined order (respecting conflict resolution): - - a. **Sync specs** if delta specs exist: - - Use the openspec-sync-specs approach (agent-driven intelligent merge) - - For conflicts, apply in resolved order - - Track if sync was done - - b. **Perform the archive**: - ```bash - mkdir -p openspec/changes/archive - mv openspec/changes/ openspec/changes/archive/YYYY-MM-DD- - ``` - - c. **Track outcome** for each change: - - Success: archived successfully - - Failed: error during archive (record error) - - Skipped: user chose not to archive (if applicable) - -9. **Display summary** - - Show final results: - - ``` - ## Bulk Archive Complete - - Archived 3 changes: - - schema-management-cli -> archive/2026-01-19-schema-management-cli/ - - project-config -> archive/2026-01-19-project-config/ - - add-oauth -> archive/2026-01-19-add-oauth/ - - Skipped 1 change: - - add-verify-skill (user chose not to archive incomplete) - - Spec sync summary: - - 4 delta specs synced to main specs - - 1 conflict resolved (auth: applied both in chronological order) - ``` - - If any failures: - ``` - Failed 1 change: - - some-change: Archive directory already exists - ``` - -**Conflict Resolution Examples** - -Example 1: Only one implemented -``` -Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt] - -Checking add-oauth: -- Delta adds "OAuth Provider Integration" requirement -- Searching codebase... found src/auth/oauth.ts implementing OAuth flow - -Checking add-jwt: -- Delta adds "JWT Token Handling" requirement -- Searching codebase... no JWT implementation found - -Resolution: Only add-oauth is implemented. Will sync add-oauth specs only. -``` - -Example 2: Both implemented -``` -Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql] - -Checking add-rest-api (created 2026-01-10): -- Delta adds "REST Endpoints" requirement -- Searching codebase... found src/api/rest.ts - -Checking add-graphql (created 2026-01-15): -- Delta adds "GraphQL Schema" requirement -- Searching codebase... found src/api/graphql.ts - -Resolution: Both implemented. Will apply add-rest-api specs first, -then add-graphql specs (chronological order, newer takes precedence). -``` - -**Output On Success** - -``` -## Bulk Archive Complete - -Archived N changes: -- -> archive/YYYY-MM-DD-/ -- -> archive/YYYY-MM-DD-/ - -Spec sync summary: -- N delta specs synced to main specs -- No conflicts (or: M conflicts resolved) -``` - -**Output On Partial Success** - -``` -## Bulk Archive Complete (partial) - -Archived N changes: -- -> archive/YYYY-MM-DD-/ - -Skipped M changes: -- (user chose not to archive incomplete) - -Failed K changes: -- : Archive directory already exists -``` - -**Output When No Changes** - -``` -## No Changes to Archive - -No active changes found. Use `/opsx-new` to create a new change. -``` - -**Guardrails** -- Allow any number of changes (1+ is fine, 2+ is the typical use case) -- Always prompt for selection, never auto-select -- Detect spec conflicts early and resolve by checking codebase -- When both changes are implemented, apply specs in chronological order -- Skip spec sync only when implementation is missing (warn user) -- Show clear per-change status before confirming -- Use single confirmation for entire batch -- Track and report all outcomes (success/skip/fail) -- Preserve .openspec.yaml when moving to archive -- Archive directory target uses current date: YYYY-MM-DD- -- If archive target exists, fail that change but continue with others diff --git a/.opencode/command/opsx-continue.md b/.opencode/command/opsx-continue.md deleted file mode 100644 index 1a64810..0000000 --- a/.opencode/command/opsx-continue.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -description: Continue working on a change - create the next artifact (Experimental) ---- - -Continue working on a change by creating the next artifact. - -**Input**: Optionally specify a change name after `/opsx-continue` (e.g., `/opsx-continue 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. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on. - - Present the top 3-4 most recently modified changes as options, showing: - - Change name - - Schema (from `schema` field if present, otherwise "spec-driven") - - Status (e.g., "0/5 tasks", "complete", "no tasks") - - How recently it was modified (from `lastModified` field) - - Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue. - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Check current status** - ```bash - openspec status --change "" --json - ``` - Parse the JSON to understand current state. The response includes: - - `schemaName`: The workflow schema being used (e.g., "spec-driven") - - `artifacts`: Array of artifacts with their status ("done", "ready", "blocked") - - `isComplete`: Boolean indicating if all artifacts are complete - -3. **Act based on status**: - - --- - - **If all artifacts are complete (`isComplete: true`)**: - - Congratulate the user - - Show final status including the schema used - - Suggest: "All artifacts created! You can now implement this change with `/opsx-apply` or archive it with `/opsx-archive`." - - STOP - - --- - - **If artifacts are ready to create** (status shows artifacts with `status: "ready"`): - - Pick the FIRST artifact with `status: "ready"` from the status output - - Get its instructions: - ```bash - openspec instructions --change "" --json - ``` - - Parse the JSON. The key fields are: - - `context`: Project background (constraints for you - do NOT include in output) - - `rules`: Artifact-specific rules (constraints for you - do NOT include in output) - - `template`: The structure to use for your output file - - `instruction`: Schema-specific guidance - - `outputPath`: Where to write the artifact - - `dependencies`: Completed artifacts to read for context - - **Create the artifact file**: - - Read any completed dependency files for context - - Use `template` as the structure - fill in its sections - - Apply `context` and `rules` as constraints when writing - but do NOT copy them into the file - - Write to the output path specified in instructions - - Show what was created and what's now unlocked - - STOP after creating ONE artifact - - --- - - **If no artifacts are ready (all blocked)**: - - This shouldn't happen with a valid schema - - Show status and suggest checking for issues - -4. **After creating an artifact, show progress** - ```bash - openspec status --change "" - ``` - -**Output** - -After each invocation, show: -- Which artifact was created -- Schema workflow being used -- Current progress (N/M complete) -- What artifacts are now unlocked -- Prompt: "Run `/opsx-continue` to create the next artifact" - -**Artifact Creation Guidelines** - -The artifact types and their purpose depend on the schema. Use the `instruction` field from the instructions output to understand what to create. - -Common artifact patterns: - -**spec-driven schema** (proposal → specs → design → tasks): -- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact. - - The Capabilities section is critical - each capability listed will need a spec file. -- **specs//spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name). -- **design.md**: Document technical decisions, architecture, and implementation approach. -- **tasks.md**: Break down implementation into checkboxed tasks. - -For other schemas, follow the `instruction` field from the CLI output. - -**Guardrails** -- Create ONE artifact per invocation -- Always read dependency artifacts before creating a new one -- Never skip artifacts or create out of order -- If context is unclear, ask the user before creating -- Verify the artifact file exists after writing before marking progress -- Use the schema's artifact sequence, don't assume specific artifact names -- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file - - Do NOT copy ``, ``, `` blocks into the artifact - - These guide what you write, but should never appear in the output diff --git a/.opencode/command/opsx-explore.md b/.opencode/command/opsx-explore.md index 01ee33c..1d54215 100644 --- a/.opencode/command/opsx-explore.md +++ b/.opencode/command/opsx-explore.md @@ -4,7 +4,7 @@ description: Enter explore mode - think through ideas, investigate problems, cla Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes. -**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with `/opsx-new` or `/opsx-ff`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. +**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore. @@ -97,8 +97,7 @@ If the user mentioned a specific change name, read its artifacts for context. Think freely. When insights crystallize, you might offer: -- "This feels solid enough to start a change. Want me to create one?" - → Can transition to `/opsx-new` or `/opsx-ff` +- "This feels solid enough to start a change. Want me to create a proposal?" - Or keep exploring - no pressure to formalize ### When a change exists @@ -150,7 +149,7 @@ If the user mentions a change or you detect one is relevant: There's no required ending. Discovery might: -- **Flow into action**: "Ready to start? `/opsx-new` or `/opsx-ff`" +- **Flow into a proposal**: "Ready to start? I can create a change proposal." - **Result in artifact updates**: "Updated design.md with these decisions" - **Just provide clarity**: User has what they need, moves on - **Continue later**: "We can pick this up anytime" diff --git a/.opencode/command/opsx-new.md b/.opencode/command/opsx-new.md deleted file mode 100644 index 0f30abd..0000000 --- a/.opencode/command/opsx-new.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -description: Start a new change using the experimental artifact workflow (OPSX) ---- - -Start a new change using the experimental artifact-driven approach. - -**Input**: The argument after `/opsx-new` is the change name (kebab-case), OR a description of what the user wants to build. - -**Steps** - -1. **If no input provided, ask what they want to build** - - Use the **AskUserQuestion tool** (open-ended, no preset options) to ask: - > "What change do you want to work on? Describe what you want to build or fix." - - From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`). - - **IMPORTANT**: Do NOT proceed without understanding what the user wants to build. - -2. **Determine the workflow schema** - - Use the default schema (omit `--schema`) unless the user explicitly requests a different workflow. - - **Use a different schema only if the user mentions:** - - A specific schema name → use `--schema ` - - "show workflows" or "what workflows" → run `openspec schemas --json` and let them choose - - **Otherwise**: Omit `--schema` to use the default. - -3. **Create the change directory** - ```bash - openspec new change "" - ``` - Add `--schema ` only if the user requested a specific workflow. - This creates a scaffolded change at `openspec/changes//` with the selected schema. - -4. **Show the artifact status** - ```bash - openspec status --change "" - ``` - This shows which artifacts need to be created and which are ready (dependencies satisfied). - -5. **Get instructions for the first artifact** - The first artifact depends on the schema. Check the status output to find the first artifact with status "ready". - ```bash - openspec instructions --change "" - ``` - This outputs the template and context for creating the first artifact. - -6. **STOP and wait for user direction** - -**Output** - -After completing the steps, summarize: -- Change name and location -- Schema/workflow being used and its artifact sequence -- Current status (0/N artifacts complete) -- The template for the first artifact -- Prompt: "Ready to create the first artifact? Run `/opsx-continue` or just describe what this change is about and I'll draft it." - -**Guardrails** -- Do NOT create any artifacts yet - just show the instructions -- Do NOT advance beyond showing the first artifact template -- If the name is invalid (not kebab-case), ask for a valid name -- If a change with that name already exists, suggest using `/opsx-continue` instead -- Pass --schema if using a non-default workflow diff --git a/.opencode/command/opsx-onboard.md b/.opencode/command/opsx-onboard.md deleted file mode 100644 index 50b4b82..0000000 --- a/.opencode/command/opsx-onboard.md +++ /dev/null @@ -1,522 +0,0 @@ ---- -description: Guided onboarding - walk through a complete OpenSpec workflow cycle with narration ---- - -Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step. - ---- - -## Preflight - -Before starting, check if OpenSpec is initialized: - -```bash -openspec status --json 2>&1 || echo "NOT_INITIALIZED" -``` - -**If not initialized:** -> OpenSpec isn't set up in this project yet. Run `openspec init` first, then come back to `/opsx-onboard`. - -Stop here if not initialized. - ---- - -## Phase 1: Welcome - -Display: - -``` -## Welcome to OpenSpec! - -I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it. - -**What we'll do:** -1. Pick a small, real task in your codebase -2. Explore the problem briefly -3. Create a change (the container for our work) -4. Build the artifacts: proposal → specs → design → tasks -5. Implement the tasks -6. Archive the completed change - -**Time:** ~15-20 minutes - -Let's start by finding something to work on. -``` - ---- - -## Phase 2: Task Selection - -### Codebase Analysis - -Scan the codebase for small improvement opportunities. Look for: - -1. **TODO/FIXME comments** - Search for `TODO`, `FIXME`, `HACK`, `XXX` in code files -2. **Missing error handling** - `catch` blocks that swallow errors, risky operations without try-catch -3. **Functions without tests** - Cross-reference `src/` with test directories -4. **Type issues** - `any` types in TypeScript files (`: any`, `as any`) -5. **Debug artifacts** - `console.log`, `console.debug`, `debugger` statements in non-debug code -6. **Missing validation** - User input handlers without validation - -Also check recent git activity: -```bash -git log --oneline -10 2>/dev/null || echo "No git history" -``` - -### Present Suggestions - -From your analysis, present 3-4 specific suggestions: - -``` -## Task Suggestions - -Based on scanning your codebase, here are some good starter tasks: - -**1. [Most promising task]** - Location: `src/path/to/file.ts:42` - Scope: ~1-2 files, ~20-30 lines - Why it's good: [brief reason] - -**2. [Second task]** - Location: `src/another/file.ts` - Scope: ~1 file, ~15 lines - Why it's good: [brief reason] - -**3. [Third task]** - Location: [location] - Scope: [estimate] - Why it's good: [brief reason] - -**4. Something else?** - Tell me what you'd like to work on. - -Which task interests you? (Pick a number or describe your own) -``` - -**If nothing found:** Fall back to asking what the user wants to build: -> I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix? - -### Scope Guardrail - -If the user picks or describes something too large (major feature, multi-day work): - -``` -That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through. - -For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details. - -**Options:** -1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]? -2. **Pick something else** - One of the other suggestions, or a different small task? -3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer. - -What would you prefer? -``` - -Let the user override if they insist—this is a soft guardrail. - ---- - -## Phase 3: Explore Demo - -Once a task is selected, briefly demonstrate explore mode: - -``` -Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction. -``` - -Spend 1-2 minutes investigating the relevant code: -- Read the file(s) involved -- Draw a quick ASCII diagram if it helps -- Note any considerations - -``` -## Quick Exploration - -[Your brief analysis—what you found, any considerations] - -┌─────────────────────────────────────────┐ -│ [Optional: ASCII diagram if helpful] │ -└─────────────────────────────────────────┘ - -Explore mode (`/opsx-explore`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem. - -Now let's create a change to hold our work. -``` - -**PAUSE** - Wait for user acknowledgment before proceeding. - ---- - -## Phase 4: Create the Change - -**EXPLAIN:** -``` -## Creating a Change - -A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in `openspec/changes//` and holds your artifacts—proposal, specs, design, tasks. - -Let me create one for our task. -``` - -**DO:** Create the change with a derived kebab-case name: -```bash -openspec new change "" -``` - -**SHOW:** -``` -Created: `openspec/changes//` - -The folder structure: -``` -openspec/changes// -├── proposal.md ← Why we're doing this (empty, we'll fill it) -├── design.md ← How we'll build it (empty) -├── specs/ ← Detailed requirements (empty) -└── tasks.md ← Implementation checklist (empty) -``` - -Now let's fill in the first artifact—the proposal. -``` - ---- - -## Phase 5: Proposal - -**EXPLAIN:** -``` -## The Proposal - -The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work. - -I'll draft one based on our task. -``` - -**DO:** Draft the proposal content (don't save yet): - -``` -Here's a draft proposal: - ---- - -## Why - -[1-2 sentences explaining the problem/opportunity] - -## What Changes - -[Bullet points of what will be different] - -## Capabilities - -### New Capabilities -- ``: [brief description] - -### Modified Capabilities - - -## Impact - -- `src/path/to/file.ts`: [what changes] -- [other files if applicable] - ---- - -Does this capture the intent? I can adjust before we save it. -``` - -**PAUSE** - Wait for user approval/feedback. - -After approval, save the proposal: -```bash -openspec instructions proposal --change "" --json -``` -Then write the content to `openspec/changes//proposal.md`. - -``` -Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves. - -Next up: specs. -``` - ---- - -## Phase 6: Specs - -**EXPLAIN:** -``` -## Specs - -Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear. - -For a small task like this, we might only need one spec file. -``` - -**DO:** Create the spec file: -```bash -mkdir -p openspec/changes//specs/ -``` - -Draft the spec content: - -``` -Here's the spec: - ---- - -## ADDED Requirements - -### Requirement: - - - -#### Scenario: - -- **WHEN** -- **THEN** -- **AND** - ---- - -This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases. -``` - -Save to `openspec/changes//specs//spec.md`. - ---- - -## Phase 7: Design - -**EXPLAIN:** -``` -## Design - -The design captures **how** we'll build it—technical decisions, tradeoffs, approach. - -For small changes, this might be brief. That's fine—not every change needs deep design discussion. -``` - -**DO:** Draft design.md: - -``` -Here's the design: - ---- - -## Context - -[Brief context about the current state] - -## Goals / Non-Goals - -**Goals:** -- [What we're trying to achieve] - -**Non-Goals:** -- [What's explicitly out of scope] - -## Decisions - -### Decision 1: [Key decision] - -[Explanation of approach and rationale] - ---- - -For a small task, this captures the key decisions without over-engineering. -``` - -Save to `openspec/changes//design.md`. - ---- - -## Phase 8: Tasks - -**EXPLAIN:** -``` -## Tasks - -Finally, we break the work into implementation tasks—checkboxes that drive the apply phase. - -These should be small, clear, and in logical order. -``` - -**DO:** Generate tasks based on specs and design: - -``` -Here are the implementation tasks: - ---- - -## 1. [Category or file] - -- [ ] 1.1 [Specific task] -- [ ] 1.2 [Specific task] - -## 2. Verify - -- [ ] 2.1 [Verification step] - ---- - -Each checkbox becomes a unit of work in the apply phase. Ready to implement? -``` - -**PAUSE** - Wait for user to confirm they're ready to implement. - -Save to `openspec/changes//tasks.md`. - ---- - -## Phase 9: Apply (Implementation) - -**EXPLAIN:** -``` -## Implementation - -Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach. -``` - -**DO:** For each task: - -1. Announce: "Working on task N: [description]" -2. Implement the change in the codebase -3. Reference specs/design naturally: "The spec says X, so I'm doing Y" -4. Mark complete in tasks.md: `- [ ]` → `- [x]` -5. Brief status: "✓ Task N complete" - -Keep narration light—don't over-explain every line of code. - -After all tasks: - -``` -## Implementation Complete - -All tasks done: -- [x] Task 1 -- [x] Task 2 -- [x] ... - -The change is implemented! One more step—let's archive it. -``` - ---- - -## Phase 10: Archive - -**EXPLAIN:** -``` -## Archiving - -When a change is complete, we archive it. This moves it from `openspec/changes/` to `openspec/changes/archive/YYYY-MM-DD-/`. - -Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way. -``` - -**DO:** -```bash -openspec archive "" -``` - -**SHOW:** -``` -Archived to: `openspec/changes/archive/YYYY-MM-DD-/` - -The change is now part of your project's history. The code is in your codebase, the decision record is preserved. -``` - ---- - -## Phase 11: Recap & Next Steps - -``` -## Congratulations! - -You just completed a full OpenSpec cycle: - -1. **Explore** - Thought through the problem -2. **New** - Created a change container -3. **Proposal** - Captured WHY -4. **Specs** - Defined WHAT in detail -5. **Design** - Decided HOW -6. **Tasks** - Broke it into steps -7. **Apply** - Implemented the work -8. **Archive** - Preserved the record - -This same rhythm works for any size change—a small fix or a major feature. - ---- - -## Command Reference - -| Command | What it does | -|---------|--------------| -| `/opsx-explore` | Think through problems before/during work | -| `/opsx-new` | Start a new change, step through artifacts | -| `/opsx-ff` | Fast-forward: create all artifacts at once | -| `/opsx-continue` | Continue working on an existing change | -| `/opsx-apply` | Implement tasks from a change | -| `/opsx-verify` | Verify implementation matches artifacts | -| `/opsx-archive` | Archive a completed change | - ---- - -## What's Next? - -Try `/opsx-new` or `/opsx-ff` on something you actually want to build. You've got the rhythm now! -``` - ---- - -## Graceful Exit Handling - -### User wants to stop mid-way - -If the user says they need to stop, want to pause, or seem disengaged: - -``` -No problem! Your change is saved at `openspec/changes//`. - -To pick up where we left off later: -- `/opsx-continue ` - Resume artifact creation -- `/opsx-apply ` - Jump to implementation (if tasks exist) - -The work won't be lost. Come back whenever you're ready. -``` - -Exit gracefully without pressure. - -### User just wants command reference - -If the user says they just want to see the commands or skip the tutorial: - -``` -## OpenSpec Quick Reference - -| Command | What it does | -|---------|--------------| -| `/opsx-explore` | Think through problems (no code changes) | -| `/opsx-new ` | Start a new change, step by step | -| `/opsx-ff ` | Fast-forward: all artifacts at once | -| `/opsx-continue ` | Continue an existing change | -| `/opsx-apply ` | Implement tasks | -| `/opsx-verify ` | Verify implementation | -| `/opsx-archive ` | Archive when done | - -Try `/opsx-new` to start your first change, or `/opsx-ff` if you want to move fast. -``` - -Exit gracefully. - ---- - -## Guardrails - -- **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive) -- **Keep narration light** during implementation—teach without lecturing -- **Don't skip phases** even if the change is small—the goal is teaching the workflow -- **Pause for acknowledgment** at marked points, but don't over-pause -- **Handle exits gracefully**—never pressure the user to continue -- **Use real codebase tasks**—don't simulate or use fake examples -- **Adjust scope gently**—guide toward smaller tasks but respect user choice diff --git a/.opencode/command/opsx-ff.md b/.opencode/command/opsx-propose.md similarity index 80% rename from .opencode/command/opsx-ff.md rename to .opencode/command/opsx-propose.md index 33190e0..b063a7e 100644 --- a/.opencode/command/opsx-ff.md +++ b/.opencode/command/opsx-propose.md @@ -1,10 +1,19 @@ --- -description: Create a change and generate all artifacts needed for implementation in one go +description: Propose a new change - create it and generate all artifacts in one step --- -Fast-forward through artifact creation - generate everything needed to start implementation. +Propose a new change - create the change and generate all artifacts in one step. -**Input**: The argument after `/opsx-ff` is the change name (kebab-case), OR a description of what the user wants to build. +I'll create a change with artifacts: +- proposal.md (what & why) +- design.md (how) +- tasks.md (implementation steps) + +When ready to implement, run /opsx-apply + +--- + +**Input**: The argument after `/opsx-propose` is the change name (kebab-case), OR a description of what the user wants to build. **Steps** @@ -21,7 +30,7 @@ Fast-forward through artifact creation - generate everything needed to start imp ```bash openspec new change "" ``` - This creates a scaffolded change at `openspec/changes//`. + This creates a scaffolded change at `openspec/changes//` with `.openspec.yaml`. 3. **Get the artifact build order** ```bash @@ -52,7 +61,7 @@ Fast-forward through artifact creation - generate everything needed to start imp - Read any completed dependency files for context - Create the artifact file using `template` as the structure - Apply `context` and `rules` as constraints - but do NOT copy them into the file - - Show brief progress: "✓ Created " + - Show brief progress: "Created " b. **Continue until all `applyRequires` artifacts are complete** - After creating each artifact, re-run `openspec status --change "" --json` @@ -81,7 +90,10 @@ After completing all artifacts, summarize: - Follow the `instruction` field from `openspec instructions` for each artifact type - The schema defines what each artifact should contain - follow it - Read dependency artifacts for context before creating new ones -- Use the `template` as a starting point, filling in based on context +- Use `template` as the structure for your output file - fill in its sections +- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file + - Do NOT copy ``, ``, `` blocks into the artifact + - These guide what you write, but should never appear in the output **Guardrails** - Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`) diff --git a/.opencode/command/opsx-sync.md b/.opencode/command/opsx-sync.md deleted file mode 100644 index 1208c4b..0000000 --- a/.opencode/command/opsx-sync.md +++ /dev/null @@ -1,131 +0,0 @@ ---- -description: Sync delta specs from a change to main specs ---- - -Sync delta specs from a change to main specs. - -This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement). - -**Input**: Optionally specify a change name after `/opsx-sync` (e.g., `/opsx-sync 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. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have delta specs (under `specs/` directory). - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Find delta specs** - - Look for delta spec files in `openspec/changes//specs/*/spec.md`. - - Each delta spec file contains sections like: - - `## ADDED Requirements` - New requirements to add - - `## MODIFIED Requirements` - Changes to existing requirements - - `## REMOVED Requirements` - Requirements to remove - - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format) - - If no delta specs found, inform user and stop. - -3. **For each delta spec, apply changes to main specs** - - For each capability with a delta spec at `openspec/changes//specs//spec.md`: - - a. **Read the delta spec** to understand the intended changes - - b. **Read the main spec** at `openspec/specs//spec.md` (may not exist yet) - - c. **Apply changes intelligently**: - - **ADDED Requirements:** - - If requirement doesn't exist in main spec → add it - - If requirement already exists → update it to match (treat as implicit MODIFIED) - - **MODIFIED Requirements:** - - Find the requirement in main spec - - Apply the changes - this can be: - - Adding new scenarios (don't need to copy existing ones) - - Modifying existing scenarios - - Changing the requirement description - - Preserve scenarios/content not mentioned in the delta - - **REMOVED Requirements:** - - Remove the entire requirement block from main spec - - **RENAMED Requirements:** - - Find the FROM requirement, rename to TO - - d. **Create new main spec** if capability doesn't exist yet: - - Create `openspec/specs//spec.md` - - Add Purpose section (can be brief, mark as TBD) - - Add Requirements section with the ADDED requirements - -4. **Show summary** - - After applying all changes, summarize: - - Which capabilities were updated - - What changes were made (requirements added/modified/removed/renamed) - -**Delta Spec Format Reference** - -```markdown -## ADDED Requirements - -### Requirement: New Feature -The system SHALL do something new. - -#### Scenario: Basic case -- **WHEN** user does X -- **THEN** system does Y - -## MODIFIED Requirements - -### Requirement: Existing Feature -#### Scenario: New scenario to add -- **WHEN** user does A -- **THEN** system does B - -## REMOVED Requirements - -### Requirement: Deprecated Feature - -## RENAMED Requirements - -- FROM: `### Requirement: Old Name` -- TO: `### Requirement: New Name` -``` - -**Key Principle: Intelligent Merging** - -Unlike programmatic merging, you can apply **partial updates**: -- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios -- The delta represents *intent*, not a wholesale replacement -- Use your judgment to merge changes sensibly - -**Output On Success** - -``` -## Specs Synced: - -Updated main specs: - -****: -- Added requirement: "New Feature" -- Modified requirement: "Existing Feature" (added 1 scenario) - -****: -- Created new spec file -- Added requirement: "Another Feature" - -Main specs are now updated. The change remains active - archive when implementation is complete. -``` - -**Guardrails** -- Read both delta and main specs before making changes -- Preserve existing content not mentioned in delta -- If something is unclear, ask for clarification -- Show what you're changing as you go -- The operation should be idempotent - running twice should give same result diff --git a/.opencode/command/opsx-verify.md b/.opencode/command/opsx-verify.md deleted file mode 100644 index 7bd3aba..0000000 --- a/.opencode/command/opsx-verify.md +++ /dev/null @@ -1,161 +0,0 @@ ---- -description: Verify implementation matches change artifacts before archiving ---- - -Verify that an implementation matches the change artifacts (specs, tasks, design). - -**Input**: Optionally specify a change name after `/opsx-verify` (e.g., `/opsx-verify 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. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have implementation tasks (tasks artifact exists). - Include the schema used for each change if available. - Mark changes with incomplete tasks as "(In Progress)". - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -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 artifacts exist for this change - -3. **Get the change directory and load artifacts** - - ```bash - openspec instructions apply --change "" --json - ``` - - This returns the change directory and context files. Read all available artifacts from `contextFiles`. - -4. **Initialize verification report structure** - - Create a report structure with three dimensions: - - **Completeness**: Track tasks and spec coverage - - **Correctness**: Track requirement implementation and scenario coverage - - **Coherence**: Track design adherence and pattern consistency - - Each dimension can have CRITICAL, WARNING, or SUGGESTION issues. - -5. **Verify Completeness** - - **Task Completion**: - - If tasks.md exists in contextFiles, read it - - Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete) - - Count complete vs total tasks - - If incomplete tasks exist: - - Add CRITICAL issue for each incomplete task - - Recommendation: "Complete task: " or "Mark as done if already implemented" - - **Spec Coverage**: - - If delta specs exist in `openspec/changes//specs/`: - - Extract all requirements (marked with "### Requirement:") - - For each requirement: - - Search codebase for keywords related to the requirement - - Assess if implementation likely exists - - If requirements appear unimplemented: - - Add CRITICAL issue: "Requirement not found: " - - Recommendation: "Implement requirement X: " - -6. **Verify Correctness** - - **Requirement Implementation Mapping**: - - For each requirement from delta specs: - - Search codebase for implementation evidence - - If found, note file paths and line ranges - - Assess if implementation matches requirement intent - - If divergence detected: - - Add WARNING: "Implementation may diverge from spec:
" - - Recommendation: "Review : against requirement X" - - **Scenario Coverage**: - - For each scenario in delta specs (marked with "#### Scenario:"): - - Check if conditions are handled in code - - Check if tests exist covering the scenario - - If scenario appears uncovered: - - Add WARNING: "Scenario not covered: " - - Recommendation: "Add test or implementation for scenario: " - -7. **Verify Coherence** - - **Design Adherence**: - - If design.md exists in contextFiles: - - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:") - - Verify implementation follows those decisions - - If contradiction detected: - - Add WARNING: "Design decision not followed: " - - Recommendation: "Update implementation or revise design.md to match reality" - - If no design.md: Skip design adherence check, note "No design.md to verify against" - - **Code Pattern Consistency**: - - Review new code for consistency with project patterns - - Check file naming, directory structure, coding style - - If significant deviations found: - - Add SUGGESTION: "Code pattern deviation:
" - - Recommendation: "Consider following project pattern: " - -8. **Generate Verification Report** - - **Summary Scorecard**: - ``` - ## Verification Report: - - ### Summary - | Dimension | Status | - |--------------|------------------| - | Completeness | X/Y tasks, N reqs| - | Correctness | M/N reqs covered | - | Coherence | Followed/Issues | - ``` - - **Issues by Priority**: - - 1. **CRITICAL** (Must fix before archive): - - Incomplete tasks - - Missing requirement implementations - - Each with specific, actionable recommendation - - 2. **WARNING** (Should fix): - - Spec/design divergences - - Missing scenario coverage - - Each with specific recommendation - - 3. **SUGGESTION** (Nice to fix): - - Pattern inconsistencies - - Minor improvements - - Each with specific recommendation - - **Final Assessment**: - - If CRITICAL issues: "X critical issue(s) found. Fix before archiving." - - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)." - - If all clear: "All checks passed. Ready for archive." - -**Verification Heuristics** - -- **Completeness**: Focus on objective checklist items (checkboxes, requirements list) -- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty -- **Coherence**: Look for glaring inconsistencies, don't nitpick style -- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL -- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable - -**Graceful Degradation** - -- If only tasks.md exists: verify task completion only, skip spec/design checks -- If tasks + specs exist: verify completeness and correctness, skip design -- If full artifacts: verify all three dimensions -- Always note which checks were skipped and why - -**Output Format** - -Use clear markdown with: -- Table for summary scorecard -- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION) -- Code references in format: `file.ts:123` -- Specific, actionable recommendations -- No vague suggestions like "consider reviewing" diff --git a/.opencode/skills/openspec-apply-change/SKILL.md b/.opencode/skills/openspec-apply-change/SKILL.md index 628c56e..9f31f2c 100644 --- a/.opencode/skills/openspec-apply-change/SKILL.md +++ b/.opencode/skills/openspec-apply-change/SKILL.md @@ -6,7 +6,7 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Implement tasks from an OpenSpec change. diff --git a/.opencode/skills/openspec-archive-change/SKILL.md b/.opencode/skills/openspec-archive-change/SKILL.md index 07e9df4..9b1f851 100644 --- a/.opencode/skills/openspec-archive-change/SKILL.md +++ b/.opencode/skills/openspec-archive-change/SKILL.md @@ -6,7 +6,7 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Archive a completed change in the experimental workflow. @@ -63,7 +63,7 @@ Archive a completed change in the experimental workflow. - If changes needed: "Sync now (recommended)", "Archive without syncing" - If already synced: "Archive now", "Sync anyway", "Cancel" - If user chooses sync, execute /opsx-sync logic (use the openspec-sync-specs skill). Proceed to archive regardless of choice. + If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change ''. Delta spec analysis: "). Proceed to archive regardless of choice. 5. **Perform the archive** diff --git a/.opencode/skills/openspec-bulk-archive-change/SKILL.md b/.opencode/skills/openspec-bulk-archive-change/SKILL.md deleted file mode 100644 index bf4214f..0000000 --- a/.opencode/skills/openspec-bulk-archive-change/SKILL.md +++ /dev/null @@ -1,246 +0,0 @@ ---- -name: openspec-bulk-archive-change -description: Archive multiple completed changes at once. Use when archiving several parallel changes. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Archive multiple completed changes in a single operation. - -This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented. - -**Input**: None required (prompts for selection) - -**Steps** - -1. **Get active changes** - - Run `openspec list --json` to get all active changes. - - If no active changes exist, inform user and stop. - -2. **Prompt for change selection** - - Use **AskUserQuestion tool** with multi-select to let user choose changes: - - Show each change with its schema - - Include an option for "All changes" - - Allow any number of selections (1+ works, 2+ is the typical use case) - - **IMPORTANT**: Do NOT auto-select. Always let the user choose. - -3. **Batch validation - gather status for all selected changes** - - For each selected change, collect: - - a. **Artifact status** - Run `openspec status --change "" --json` - - Parse `schemaName` and `artifacts` list - - Note which artifacts are `done` vs other states - - b. **Task completion** - Read `openspec/changes//tasks.md` - - Count `- [ ]` (incomplete) vs `- [x]` (complete) - - If no tasks file exists, note as "No tasks" - - c. **Delta specs** - Check `openspec/changes//specs/` directory - - List which capability specs exist - - For each, extract requirement names (lines matching `### Requirement: `) - -4. **Detect spec conflicts** - - Build a map of `capability -> [changes that touch it]`: - - ``` - auth -> [change-a, change-b] <- CONFLICT (2+ changes) - api -> [change-c] <- OK (only 1 change) - ``` - - A conflict exists when 2+ selected changes have delta specs for the same capability. - -5. **Resolve conflicts agentically** - - **For each conflict**, investigate the codebase: - - a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify - - b. **Search the codebase** for implementation evidence: - - Look for code implementing requirements from each delta spec - - Check for related files, functions, or tests - - c. **Determine resolution**: - - If only one change is actually implemented -> sync that one's specs - - If both implemented -> apply in chronological order (older first, newer overwrites) - - If neither implemented -> skip spec sync, warn user - - d. **Record resolution** for each conflict: - - Which change's specs to apply - - In what order (if both) - - Rationale (what was found in codebase) - -6. **Show consolidated status table** - - Display a table summarizing all changes: - - ``` - | Change | Artifacts | Tasks | Specs | Conflicts | Status | - |---------------------|-----------|-------|---------|-----------|--------| - | schema-management | Done | 5/5 | 2 delta | None | Ready | - | project-config | Done | 3/3 | 1 delta | None | Ready | - | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* | - | add-verify-skill | 1 left | 2/5 | None | None | Warn | - ``` - - For conflicts, show the resolution: - ``` - * Conflict resolution: - - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order) - ``` - - For incomplete changes, show warnings: - ``` - Warnings: - - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks - ``` - -7. **Confirm batch operation** - - Use **AskUserQuestion tool** with a single confirmation: - - - "Archive N changes?" with options based on status - - Options might include: - - "Archive all N changes" - - "Archive only N ready changes (skip incomplete)" - - "Cancel" - - If there are incomplete changes, make clear they'll be archived with warnings. - -8. **Execute archive for each confirmed change** - - Process changes in the determined order (respecting conflict resolution): - - a. **Sync specs** if delta specs exist: - - Use the openspec-sync-specs approach (agent-driven intelligent merge) - - For conflicts, apply in resolved order - - Track if sync was done - - b. **Perform the archive**: - ```bash - mkdir -p openspec/changes/archive - mv openspec/changes/ openspec/changes/archive/YYYY-MM-DD- - ``` - - c. **Track outcome** for each change: - - Success: archived successfully - - Failed: error during archive (record error) - - Skipped: user chose not to archive (if applicable) - -9. **Display summary** - - Show final results: - - ``` - ## Bulk Archive Complete - - Archived 3 changes: - - schema-management-cli -> archive/2026-01-19-schema-management-cli/ - - project-config -> archive/2026-01-19-project-config/ - - add-oauth -> archive/2026-01-19-add-oauth/ - - Skipped 1 change: - - add-verify-skill (user chose not to archive incomplete) - - Spec sync summary: - - 4 delta specs synced to main specs - - 1 conflict resolved (auth: applied both in chronological order) - ``` - - If any failures: - ``` - Failed 1 change: - - some-change: Archive directory already exists - ``` - -**Conflict Resolution Examples** - -Example 1: Only one implemented -``` -Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt] - -Checking add-oauth: -- Delta adds "OAuth Provider Integration" requirement -- Searching codebase... found src/auth/oauth.ts implementing OAuth flow - -Checking add-jwt: -- Delta adds "JWT Token Handling" requirement -- Searching codebase... no JWT implementation found - -Resolution: Only add-oauth is implemented. Will sync add-oauth specs only. -``` - -Example 2: Both implemented -``` -Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql] - -Checking add-rest-api (created 2026-01-10): -- Delta adds "REST Endpoints" requirement -- Searching codebase... found src/api/rest.ts - -Checking add-graphql (created 2026-01-15): -- Delta adds "GraphQL Schema" requirement -- Searching codebase... found src/api/graphql.ts - -Resolution: Both implemented. Will apply add-rest-api specs first, -then add-graphql specs (chronological order, newer takes precedence). -``` - -**Output On Success** - -``` -## Bulk Archive Complete - -Archived N changes: -- -> archive/YYYY-MM-DD-/ -- -> archive/YYYY-MM-DD-/ - -Spec sync summary: -- N delta specs synced to main specs -- No conflicts (or: M conflicts resolved) -``` - -**Output On Partial Success** - -``` -## Bulk Archive Complete (partial) - -Archived N changes: -- -> archive/YYYY-MM-DD-/ - -Skipped M changes: -- (user chose not to archive incomplete) - -Failed K changes: -- : Archive directory already exists -``` - -**Output When No Changes** - -``` -## No Changes to Archive - -No active changes found. Use `/opsx-new` to create a new change. -``` - -**Guardrails** -- Allow any number of changes (1+ is fine, 2+ is the typical use case) -- Always prompt for selection, never auto-select -- Detect spec conflicts early and resolve by checking codebase -- When both changes are implemented, apply specs in chronological order -- Skip spec sync only when implementation is missing (warn user) -- Show clear per-change status before confirming -- Use single confirmation for entire batch -- Track and report all outcomes (success/skip/fail) -- Preserve .openspec.yaml when moving to archive -- Archive directory target uses current date: YYYY-MM-DD- -- If archive target exists, fail that change but continue with others diff --git a/.opencode/skills/openspec-continue-change/SKILL.md b/.opencode/skills/openspec-continue-change/SKILL.md deleted file mode 100644 index 5060b2f..0000000 --- a/.opencode/skills/openspec-continue-change/SKILL.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -name: openspec-continue-change -description: Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Continue working on a change by creating the next artifact. - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on. - - Present the top 3-4 most recently modified changes as options, showing: - - Change name - - Schema (from `schema` field if present, otherwise "spec-driven") - - Status (e.g., "0/5 tasks", "complete", "no tasks") - - How recently it was modified (from `lastModified` field) - - Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue. - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Check current status** - ```bash - openspec status --change "" --json - ``` - Parse the JSON to understand current state. The response includes: - - `schemaName`: The workflow schema being used (e.g., "spec-driven") - - `artifacts`: Array of artifacts with their status ("done", "ready", "blocked") - - `isComplete`: Boolean indicating if all artifacts are complete - -3. **Act based on status**: - - --- - - **If all artifacts are complete (`isComplete: true`)**: - - Congratulate the user - - Show final status including the schema used - - Suggest: "All artifacts created! You can now implement this change or archive it." - - STOP - - --- - - **If artifacts are ready to create** (status shows artifacts with `status: "ready"`): - - Pick the FIRST artifact with `status: "ready"` from the status output - - Get its instructions: - ```bash - openspec instructions --change "" --json - ``` - - Parse the JSON. The key fields are: - - `context`: Project background (constraints for you - do NOT include in output) - - `rules`: Artifact-specific rules (constraints for you - do NOT include in output) - - `template`: The structure to use for your output file - - `instruction`: Schema-specific guidance - - `outputPath`: Where to write the artifact - - `dependencies`: Completed artifacts to read for context - - **Create the artifact file**: - - Read any completed dependency files for context - - Use `template` as the structure - fill in its sections - - Apply `context` and `rules` as constraints when writing - but do NOT copy them into the file - - Write to the output path specified in instructions - - Show what was created and what's now unlocked - - STOP after creating ONE artifact - - --- - - **If no artifacts are ready (all blocked)**: - - This shouldn't happen with a valid schema - - Show status and suggest checking for issues - -4. **After creating an artifact, show progress** - ```bash - openspec status --change "" - ``` - -**Output** - -After each invocation, show: -- Which artifact was created -- Schema workflow being used -- Current progress (N/M complete) -- What artifacts are now unlocked -- Prompt: "Want to continue? Just ask me to continue or tell me what to do next." - -**Artifact Creation Guidelines** - -The artifact types and their purpose depend on the schema. Use the `instruction` field from the instructions output to understand what to create. - -Common artifact patterns: - -**spec-driven schema** (proposal → specs → design → tasks): -- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact. - - The Capabilities section is critical - each capability listed will need a spec file. -- **specs//spec.md**: Create one spec per capability listed in the proposal's Capabilities section (use the capability name, not the change name). -- **design.md**: Document technical decisions, architecture, and implementation approach. -- **tasks.md**: Break down implementation into checkboxed tasks. - -For other schemas, follow the `instruction` field from the CLI output. - -**Guardrails** -- Create ONE artifact per invocation -- Always read dependency artifacts before creating a new one -- Never skip artifacts or create out of order -- If context is unclear, ask the user before creating -- Verify the artifact file exists after writing before marking progress -- Use the schema's artifact sequence, don't assume specific artifact names -- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file - - Do NOT copy ``, ``, `` blocks into the artifact - - These guide what you write, but should never appear in the output diff --git a/.opencode/skills/openspec-explore/SKILL.md b/.opencode/skills/openspec-explore/SKILL.md index 147c7ef..2510ac4 100644 --- a/.opencode/skills/openspec-explore/SKILL.md +++ b/.opencode/skills/openspec-explore/SKILL.md @@ -6,12 +6,12 @@ compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes. -**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first (e.g., start a change with `/opsx-new` or `/opsx-ff`). You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. +**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore. @@ -95,8 +95,7 @@ This tells you: Think freely. When insights crystallize, you might offer: -- "This feels solid enough to start a change. Want me to create one?" - → Can transition to `/opsx-new` or `/opsx-ff` +- "This feels solid enough to start a change. Want me to create a proposal?" - Or keep exploring - no pressure to formalize ### When a change exists @@ -252,7 +251,7 @@ You: That changes everything. There's no required ending. Discovery might: -- **Flow into action**: "Ready to start? /opsx-new or /opsx-ff" +- **Flow into a proposal**: "Ready to start? I can create a change proposal." - **Result in artifact updates**: "Updated design.md with these decisions" - **Just provide clarity**: User has what they need, moves on - **Continue later**: "We can pick this up anytime" @@ -269,8 +268,7 @@ When it feels like things are crystallizing, you might summarize: **Open questions**: [if any remain] **Next steps** (if ready): -- Create a change: /opsx-new -- Fast-forward to tasks: /opsx-ff +- Create a change proposal - Keep exploring: just keep talking ``` diff --git a/.opencode/skills/openspec-new-change/SKILL.md b/.opencode/skills/openspec-new-change/SKILL.md deleted file mode 100644 index 37ac7ba..0000000 --- a/.opencode/skills/openspec-new-change/SKILL.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -name: openspec-new-change -description: Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Start a new change using the experimental artifact-driven approach. - -**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build. - -**Steps** - -1. **If no clear input provided, ask what they want to build** - - Use the **AskUserQuestion tool** (open-ended, no preset options) to ask: - > "What change do you want to work on? Describe what you want to build or fix." - - From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`). - - **IMPORTANT**: Do NOT proceed without understanding what the user wants to build. - -2. **Determine the workflow schema** - - Use the default schema (omit `--schema`) unless the user explicitly requests a different workflow. - - **Use a different schema only if the user mentions:** - - A specific schema name → use `--schema ` - - "show workflows" or "what workflows" → run `openspec schemas --json` and let them choose - - **Otherwise**: Omit `--schema` to use the default. - -3. **Create the change directory** - ```bash - openspec new change "" - ``` - Add `--schema ` only if the user requested a specific workflow. - This creates a scaffolded change at `openspec/changes//` with the selected schema. - -4. **Show the artifact status** - ```bash - openspec status --change "" - ``` - This shows which artifacts need to be created and which are ready (dependencies satisfied). - -5. **Get instructions for the first artifact** - The first artifact depends on the schema (e.g., `proposal` for spec-driven). - Check the status output to find the first artifact with status "ready". - ```bash - openspec instructions --change "" - ``` - This outputs the template and context for creating the first artifact. - -6. **STOP and wait for user direction** - -**Output** - -After completing the steps, summarize: -- Change name and location -- Schema/workflow being used and its artifact sequence -- Current status (0/N artifacts complete) -- The template for the first artifact -- Prompt: "Ready to create the first artifact? Just describe what this change is about and I'll draft it, or ask me to continue." - -**Guardrails** -- Do NOT create any artifacts yet - just show the instructions -- Do NOT advance beyond showing the first artifact template -- If the name is invalid (not kebab-case), ask for a valid name -- If a change with that name already exists, suggest continuing that change instead -- Pass --schema if using a non-default workflow diff --git a/.opencode/skills/openspec-onboard/SKILL.md b/.opencode/skills/openspec-onboard/SKILL.md deleted file mode 100644 index 8ee6cdc..0000000 --- a/.opencode/skills/openspec-onboard/SKILL.md +++ /dev/null @@ -1,529 +0,0 @@ ---- -name: openspec-onboard -description: Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step. - ---- - -## Preflight - -Before starting, check if OpenSpec is initialized: - -```bash -openspec status --json 2>&1 || echo "NOT_INITIALIZED" -``` - -**If not initialized:** -> OpenSpec isn't set up in this project yet. Run `openspec init` first, then come back to `/opsx-onboard`. - -Stop here if not initialized. - ---- - -## Phase 1: Welcome - -Display: - -``` -## Welcome to OpenSpec! - -I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it. - -**What we'll do:** -1. Pick a small, real task in your codebase -2. Explore the problem briefly -3. Create a change (the container for our work) -4. Build the artifacts: proposal → specs → design → tasks -5. Implement the tasks -6. Archive the completed change - -**Time:** ~15-20 minutes - -Let's start by finding something to work on. -``` - ---- - -## Phase 2: Task Selection - -### Codebase Analysis - -Scan the codebase for small improvement opportunities. Look for: - -1. **TODO/FIXME comments** - Search for `TODO`, `FIXME`, `HACK`, `XXX` in code files -2. **Missing error handling** - `catch` blocks that swallow errors, risky operations without try-catch -3. **Functions without tests** - Cross-reference `src/` with test directories -4. **Type issues** - `any` types in TypeScript files (`: any`, `as any`) -5. **Debug artifacts** - `console.log`, `console.debug`, `debugger` statements in non-debug code -6. **Missing validation** - User input handlers without validation - -Also check recent git activity: -```bash -git log --oneline -10 2>/dev/null || echo "No git history" -``` - -### Present Suggestions - -From your analysis, present 3-4 specific suggestions: - -``` -## Task Suggestions - -Based on scanning your codebase, here are some good starter tasks: - -**1. [Most promising task]** - Location: `src/path/to/file.ts:42` - Scope: ~1-2 files, ~20-30 lines - Why it's good: [brief reason] - -**2. [Second task]** - Location: `src/another/file.ts` - Scope: ~1 file, ~15 lines - Why it's good: [brief reason] - -**3. [Third task]** - Location: [location] - Scope: [estimate] - Why it's good: [brief reason] - -**4. Something else?** - Tell me what you'd like to work on. - -Which task interests you? (Pick a number or describe your own) -``` - -**If nothing found:** Fall back to asking what the user wants to build: -> I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix? - -### Scope Guardrail - -If the user picks or describes something too large (major feature, multi-day work): - -``` -That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through. - -For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details. - -**Options:** -1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]? -2. **Pick something else** - One of the other suggestions, or a different small task? -3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer. - -What would you prefer? -``` - -Let the user override if they insist—this is a soft guardrail. - ---- - -## Phase 3: Explore Demo - -Once a task is selected, briefly demonstrate explore mode: - -``` -Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction. -``` - -Spend 1-2 minutes investigating the relevant code: -- Read the file(s) involved -- Draw a quick ASCII diagram if it helps -- Note any considerations - -``` -## Quick Exploration - -[Your brief analysis—what you found, any considerations] - -┌─────────────────────────────────────────┐ -│ [Optional: ASCII diagram if helpful] │ -└─────────────────────────────────────────┘ - -Explore mode (`/opsx-explore`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem. - -Now let's create a change to hold our work. -``` - -**PAUSE** - Wait for user acknowledgment before proceeding. - ---- - -## Phase 4: Create the Change - -**EXPLAIN:** -``` -## Creating a Change - -A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in `openspec/changes//` and holds your artifacts—proposal, specs, design, tasks. - -Let me create one for our task. -``` - -**DO:** Create the change with a derived kebab-case name: -```bash -openspec new change "" -``` - -**SHOW:** -``` -Created: `openspec/changes//` - -The folder structure: -``` -openspec/changes// -├── proposal.md ← Why we're doing this (empty, we'll fill it) -├── design.md ← How we'll build it (empty) -├── specs/ ← Detailed requirements (empty) -└── tasks.md ← Implementation checklist (empty) -``` - -Now let's fill in the first artifact—the proposal. -``` - ---- - -## Phase 5: Proposal - -**EXPLAIN:** -``` -## The Proposal - -The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work. - -I'll draft one based on our task. -``` - -**DO:** Draft the proposal content (don't save yet): - -``` -Here's a draft proposal: - ---- - -## Why - -[1-2 sentences explaining the problem/opportunity] - -## What Changes - -[Bullet points of what will be different] - -## Capabilities - -### New Capabilities -- ``: [brief description] - -### Modified Capabilities - - -## Impact - -- `src/path/to/file.ts`: [what changes] -- [other files if applicable] - ---- - -Does this capture the intent? I can adjust before we save it. -``` - -**PAUSE** - Wait for user approval/feedback. - -After approval, save the proposal: -```bash -openspec instructions proposal --change "" --json -``` -Then write the content to `openspec/changes//proposal.md`. - -``` -Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves. - -Next up: specs. -``` - ---- - -## Phase 6: Specs - -**EXPLAIN:** -``` -## Specs - -Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear. - -For a small task like this, we might only need one spec file. -``` - -**DO:** Create the spec file: -```bash -mkdir -p openspec/changes//specs/ -``` - -Draft the spec content: - -``` -Here's the spec: - ---- - -## ADDED Requirements - -### Requirement: - - - -#### Scenario: - -- **WHEN** -- **THEN** -- **AND** - ---- - -This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases. -``` - -Save to `openspec/changes//specs//spec.md`. - ---- - -## Phase 7: Design - -**EXPLAIN:** -``` -## Design - -The design captures **how** we'll build it—technical decisions, tradeoffs, approach. - -For small changes, this might be brief. That's fine—not every change needs deep design discussion. -``` - -**DO:** Draft design.md: - -``` -Here's the design: - ---- - -## Context - -[Brief context about the current state] - -## Goals / Non-Goals - -**Goals:** -- [What we're trying to achieve] - -**Non-Goals:** -- [What's explicitly out of scope] - -## Decisions - -### Decision 1: [Key decision] - -[Explanation of approach and rationale] - ---- - -For a small task, this captures the key decisions without over-engineering. -``` - -Save to `openspec/changes//design.md`. - ---- - -## Phase 8: Tasks - -**EXPLAIN:** -``` -## Tasks - -Finally, we break the work into implementation tasks—checkboxes that drive the apply phase. - -These should be small, clear, and in logical order. -``` - -**DO:** Generate tasks based on specs and design: - -``` -Here are the implementation tasks: - ---- - -## 1. [Category or file] - -- [ ] 1.1 [Specific task] -- [ ] 1.2 [Specific task] - -## 2. Verify - -- [ ] 2.1 [Verification step] - ---- - -Each checkbox becomes a unit of work in the apply phase. Ready to implement? -``` - -**PAUSE** - Wait for user to confirm they're ready to implement. - -Save to `openspec/changes//tasks.md`. - ---- - -## Phase 9: Apply (Implementation) - -**EXPLAIN:** -``` -## Implementation - -Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach. -``` - -**DO:** For each task: - -1. Announce: "Working on task N: [description]" -2. Implement the change in the codebase -3. Reference specs/design naturally: "The spec says X, so I'm doing Y" -4. Mark complete in tasks.md: `- [ ]` → `- [x]` -5. Brief status: "✓ Task N complete" - -Keep narration light—don't over-explain every line of code. - -After all tasks: - -``` -## Implementation Complete - -All tasks done: -- [x] Task 1 -- [x] Task 2 -- [x] ... - -The change is implemented! One more step—let's archive it. -``` - ---- - -## Phase 10: Archive - -**EXPLAIN:** -``` -## Archiving - -When a change is complete, we archive it. This moves it from `openspec/changes/` to `openspec/changes/archive/YYYY-MM-DD-/`. - -Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way. -``` - -**DO:** -```bash -openspec archive "" -``` - -**SHOW:** -``` -Archived to: `openspec/changes/archive/YYYY-MM-DD-/` - -The change is now part of your project's history. The code is in your codebase, the decision record is preserved. -``` - ---- - -## Phase 11: Recap & Next Steps - -``` -## Congratulations! - -You just completed a full OpenSpec cycle: - -1. **Explore** - Thought through the problem -2. **New** - Created a change container -3. **Proposal** - Captured WHY -4. **Specs** - Defined WHAT in detail -5. **Design** - Decided HOW -6. **Tasks** - Broke it into steps -7. **Apply** - Implemented the work -8. **Archive** - Preserved the record - -This same rhythm works for any size change—a small fix or a major feature. - ---- - -## Command Reference - -| Command | What it does | -|---------|--------------| -| `/opsx-explore` | Think through problems before/during work | -| `/opsx-new` | Start a new change, step through artifacts | -| `/opsx-ff` | Fast-forward: create all artifacts at once | -| `/opsx-continue` | Continue working on an existing change | -| `/opsx-apply` | Implement tasks from a change | -| `/opsx-verify` | Verify implementation matches artifacts | -| `/opsx-archive` | Archive a completed change | - ---- - -## What's Next? - -Try `/opsx-new` or `/opsx-ff` on something you actually want to build. You've got the rhythm now! -``` - ---- - -## Graceful Exit Handling - -### User wants to stop mid-way - -If the user says they need to stop, want to pause, or seem disengaged: - -``` -No problem! Your change is saved at `openspec/changes//`. - -To pick up where we left off later: -- `/opsx-continue ` - Resume artifact creation -- `/opsx-apply ` - Jump to implementation (if tasks exist) - -The work won't be lost. Come back whenever you're ready. -``` - -Exit gracefully without pressure. - -### User just wants command reference - -If the user says they just want to see the commands or skip the tutorial: - -``` -## OpenSpec Quick Reference - -| Command | What it does | -|---------|--------------| -| `/opsx-explore` | Think through problems (no code changes) | -| `/opsx-new ` | Start a new change, step by step | -| `/opsx-ff ` | Fast-forward: all artifacts at once | -| `/opsx-continue ` | Continue an existing change | -| `/opsx-apply ` | Implement tasks | -| `/opsx-verify ` | Verify implementation | -| `/opsx-archive ` | Archive when done | - -Try `/opsx-new` to start your first change, or `/opsx-ff` if you want to move fast. -``` - -Exit gracefully. - ---- - -## Guardrails - -- **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive) -- **Keep narration light** during implementation—teach without lecturing -- **Don't skip phases** even if the change is small—the goal is teaching the workflow -- **Pause for acknowledgment** at marked points, but don't over-pause -- **Handle exits gracefully**—never pressure the user to continue -- **Use real codebase tasks**—don't simulate or use fake examples -- **Adjust scope gently**—guide toward smaller tasks but respect user choice diff --git a/.opencode/skills/openspec-ff-change/SKILL.md b/.opencode/skills/openspec-propose/SKILL.md similarity index 85% rename from .opencode/skills/openspec-ff-change/SKILL.md rename to .opencode/skills/openspec-propose/SKILL.md index 519f356..b92cb90 100644 --- a/.opencode/skills/openspec-ff-change/SKILL.md +++ b/.opencode/skills/openspec-propose/SKILL.md @@ -1,15 +1,24 @@ --- -name: openspec-ff-change -description: Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually. +name: openspec-propose +description: Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation. license: MIT compatibility: Requires openspec CLI. metadata: author: openspec version: "1.0" - generatedBy: "1.1.1" + generatedBy: "1.2.0" --- -Fast-forward through artifact creation - generate everything needed to start implementation in one go. +Propose a new change - create the change and generate all artifacts in one step. + +I'll create a change with artifacts: +- proposal.md (what & why) +- design.md (how) +- tasks.md (implementation steps) + +When ready to implement, run /opsx-apply + +--- **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build. @@ -28,7 +37,7 @@ Fast-forward through artifact creation - generate everything needed to start imp ```bash openspec new change "" ``` - This creates a scaffolded change at `openspec/changes//`. + This creates a scaffolded change at `openspec/changes//` with `.openspec.yaml`. 3. **Get the artifact build order** ```bash @@ -59,7 +68,7 @@ Fast-forward through artifact creation - generate everything needed to start imp - Read any completed dependency files for context - Create the artifact file using `template` as the structure - Apply `context` and `rules` as constraints - but do NOT copy them into the file - - Show brief progress: "✓ Created " + - Show brief progress: "Created " b. **Continue until all `applyRequires` artifacts are complete** - After creating each artifact, re-run `openspec status --change "" --json` @@ -97,5 +106,5 @@ After completing all artifacts, summarize: - Create ALL artifacts needed for implementation (as defined by schema's `apply.requires`) - Always read dependency artifacts before creating a new one - If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum -- If a change with that name already exists, suggest continuing that change instead +- If a change with that name already exists, ask if user wants to continue it or create a new one - Verify each artifact file exists after writing before proceeding to next diff --git a/.opencode/skills/openspec-sync-specs/SKILL.md b/.opencode/skills/openspec-sync-specs/SKILL.md deleted file mode 100644 index 4c7e3aa..0000000 --- a/.opencode/skills/openspec-sync-specs/SKILL.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -name: openspec-sync-specs -description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Sync delta specs from a change to main specs. - -This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement). - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have delta specs (under `specs/` directory). - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -2. **Find delta specs** - - Look for delta spec files in `openspec/changes//specs/*/spec.md`. - - Each delta spec file contains sections like: - - `## ADDED Requirements` - New requirements to add - - `## MODIFIED Requirements` - Changes to existing requirements - - `## REMOVED Requirements` - Requirements to remove - - `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format) - - If no delta specs found, inform user and stop. - -3. **For each delta spec, apply changes to main specs** - - For each capability with a delta spec at `openspec/changes//specs//spec.md`: - - a. **Read the delta spec** to understand the intended changes - - b. **Read the main spec** at `openspec/specs//spec.md` (may not exist yet) - - c. **Apply changes intelligently**: - - **ADDED Requirements:** - - If requirement doesn't exist in main spec → add it - - If requirement already exists → update it to match (treat as implicit MODIFIED) - - **MODIFIED Requirements:** - - Find the requirement in main spec - - Apply the changes - this can be: - - Adding new scenarios (don't need to copy existing ones) - - Modifying existing scenarios - - Changing the requirement description - - Preserve scenarios/content not mentioned in the delta - - **REMOVED Requirements:** - - Remove the entire requirement block from main spec - - **RENAMED Requirements:** - - Find the FROM requirement, rename to TO - - d. **Create new main spec** if capability doesn't exist yet: - - Create `openspec/specs//spec.md` - - Add Purpose section (can be brief, mark as TBD) - - Add Requirements section with the ADDED requirements - -4. **Show summary** - - After applying all changes, summarize: - - Which capabilities were updated - - What changes were made (requirements added/modified/removed/renamed) - -**Delta Spec Format Reference** - -```markdown -## ADDED Requirements - -### Requirement: New Feature -The system SHALL do something new. - -#### Scenario: Basic case -- **WHEN** user does X -- **THEN** system does Y - -## MODIFIED Requirements - -### Requirement: Existing Feature -#### Scenario: New scenario to add -- **WHEN** user does A -- **THEN** system does B - -## REMOVED Requirements - -### Requirement: Deprecated Feature - -## RENAMED Requirements - -- FROM: `### Requirement: Old Name` -- TO: `### Requirement: New Name` -``` - -**Key Principle: Intelligent Merging** - -Unlike programmatic merging, you can apply **partial updates**: -- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios -- The delta represents *intent*, not a wholesale replacement -- Use your judgment to merge changes sensibly - -**Output On Success** - -``` -## Specs Synced: - -Updated main specs: - -****: -- Added requirement: "New Feature" -- Modified requirement: "Existing Feature" (added 1 scenario) - -****: -- Created new spec file -- Added requirement: "Another Feature" - -Main specs are now updated. The change remains active - archive when implementation is complete. -``` - -**Guardrails** -- Read both delta and main specs before making changes -- Preserve existing content not mentioned in delta -- If something is unclear, ask for clarification -- Show what you're changing as you go -- The operation should be idempotent - running twice should give same result diff --git a/.opencode/skills/openspec-verify-change/SKILL.md b/.opencode/skills/openspec-verify-change/SKILL.md deleted file mode 100644 index 443ac5f..0000000 --- a/.opencode/skills/openspec-verify-change/SKILL.md +++ /dev/null @@ -1,168 +0,0 @@ ---- -name: openspec-verify-change -description: Verify implementation matches change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archiving. -license: MIT -compatibility: Requires openspec CLI. -metadata: - author: openspec - version: "1.0" - generatedBy: "1.1.1" ---- - -Verify that an implementation matches the change artifacts (specs, tasks, design). - -**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. - -**Steps** - -1. **If no change name provided, prompt for selection** - - Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. - - Show changes that have implementation tasks (tasks artifact exists). - Include the schema used for each change if available. - Mark changes with incomplete tasks as "(In Progress)". - - **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. - -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 artifacts exist for this change - -3. **Get the change directory and load artifacts** - - ```bash - openspec instructions apply --change "" --json - ``` - - This returns the change directory and context files. Read all available artifacts from `contextFiles`. - -4. **Initialize verification report structure** - - Create a report structure with three dimensions: - - **Completeness**: Track tasks and spec coverage - - **Correctness**: Track requirement implementation and scenario coverage - - **Coherence**: Track design adherence and pattern consistency - - Each dimension can have CRITICAL, WARNING, or SUGGESTION issues. - -5. **Verify Completeness** - - **Task Completion**: - - If tasks.md exists in contextFiles, read it - - Parse checkboxes: `- [ ]` (incomplete) vs `- [x]` (complete) - - Count complete vs total tasks - - If incomplete tasks exist: - - Add CRITICAL issue for each incomplete task - - Recommendation: "Complete task: " or "Mark as done if already implemented" - - **Spec Coverage**: - - If delta specs exist in `openspec/changes//specs/`: - - Extract all requirements (marked with "### Requirement:") - - For each requirement: - - Search codebase for keywords related to the requirement - - Assess if implementation likely exists - - If requirements appear unimplemented: - - Add CRITICAL issue: "Requirement not found: " - - Recommendation: "Implement requirement X: " - -6. **Verify Correctness** - - **Requirement Implementation Mapping**: - - For each requirement from delta specs: - - Search codebase for implementation evidence - - If found, note file paths and line ranges - - Assess if implementation matches requirement intent - - If divergence detected: - - Add WARNING: "Implementation may diverge from spec:
" - - Recommendation: "Review : against requirement X" - - **Scenario Coverage**: - - For each scenario in delta specs (marked with "#### Scenario:"): - - Check if conditions are handled in code - - Check if tests exist covering the scenario - - If scenario appears uncovered: - - Add WARNING: "Scenario not covered: " - - Recommendation: "Add test or implementation for scenario: " - -7. **Verify Coherence** - - **Design Adherence**: - - If design.md exists in contextFiles: - - Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:") - - Verify implementation follows those decisions - - If contradiction detected: - - Add WARNING: "Design decision not followed: " - - Recommendation: "Update implementation or revise design.md to match reality" - - If no design.md: Skip design adherence check, note "No design.md to verify against" - - **Code Pattern Consistency**: - - Review new code for consistency with project patterns - - Check file naming, directory structure, coding style - - If significant deviations found: - - Add SUGGESTION: "Code pattern deviation:
" - - Recommendation: "Consider following project pattern: " - -8. **Generate Verification Report** - - **Summary Scorecard**: - ``` - ## Verification Report: - - ### Summary - | Dimension | Status | - |--------------|------------------| - | Completeness | X/Y tasks, N reqs| - | Correctness | M/N reqs covered | - | Coherence | Followed/Issues | - ``` - - **Issues by Priority**: - - 1. **CRITICAL** (Must fix before archive): - - Incomplete tasks - - Missing requirement implementations - - Each with specific, actionable recommendation - - 2. **WARNING** (Should fix): - - Spec/design divergences - - Missing scenario coverage - - Each with specific recommendation - - 3. **SUGGESTION** (Nice to fix): - - Pattern inconsistencies - - Minor improvements - - Each with specific recommendation - - **Final Assessment**: - - If CRITICAL issues: "X critical issue(s) found. Fix before archiving." - - If only warnings: "No critical issues. Y warning(s) to consider. Ready for archive (with noted improvements)." - - If all clear: "All checks passed. Ready for archive." - -**Verification Heuristics** - -- **Completeness**: Focus on objective checklist items (checkboxes, requirements list) -- **Correctness**: Use keyword search, file path analysis, reasonable inference - don't require perfect certainty -- **Coherence**: Look for glaring inconsistencies, don't nitpick style -- **False Positives**: When uncertain, prefer SUGGESTION over WARNING, WARNING over CRITICAL -- **Actionability**: Every issue must have a specific recommendation with file/line references where applicable - -**Graceful Degradation** - -- If only tasks.md exists: verify task completion only, skip spec/design checks -- If tasks + specs exist: verify completeness and correctness, skip design -- If full artifacts: verify all three dimensions -- Always note which checks were skipped and why - -**Output Format** - -Use clear markdown with: -- Table for summary scorecard -- Grouped lists for issues (CRITICAL/WARNING/SUGGESTION) -- Code references in format: `file.ts:123` -- Specific, actionable recommendations -- No vague suggestions like "consider reviewing" diff --git a/docs/admin-openapi.yaml b/docs/admin-openapi.yaml index 9e53a61..24d07b7 100644 --- a/docs/admin-openapi.yaml +++ b/docs/admin-openapi.yaml @@ -5029,6 +5029,9 @@ components: description: 更新时间 format: date-time type: string + virtual_no: + description: 卡虚拟号(用于客服查找资产) + type: string type: object DtoSwitchCardRequest: properties: @@ -9884,7 +9887,7 @@ paths: - 文件格式:仅支持 .xlsx (Excel 2007+) - 必须包含列(首行为表头): - - `device_no`: 设备号(必填,唯一) + - `virtual_no`: 设备虚拟号(必填,全局唯一) - `device_name`: 设备名称 - `device_model`: 设备型号 - `device_type`: 设备类型 @@ -11166,9 +11169,16 @@ paths: ### Excel 文件格式 - 文件格式:仅支持 .xlsx (Excel 2007+) - - 必须包含两列:`ICCID`, `MSISDN` + - 必填列:`ICCID`, `MSISDN` + - 可选列:`virtual_no`(虚拟号,表头关键字:virtual_no / VirtualNo / 虚拟号 / 设备号) - 首行为表头(可选,但建议包含) - 列格式:设置为文本格式(避免长数字被转为科学记数法) + + #### virtual_no 列导入规则(只补空白) + + - 该行 virtual_no 非空 + 数据库当前值为 NULL:填入新值 + - 该行 virtual_no 非空 + 数据库已有值:跳过(不覆盖) + - 批次内有任意 virtual_no 与数据库现存值重复:**整批拒绝** requestBody: content: application/json: @@ -11542,6 +11552,13 @@ paths: description: 卡接入号(模糊查询) maxLength: 20 type: string + - description: 虚拟号(模糊查询) + in: query + name: virtual_no + schema: + description: 虚拟号(模糊查询) + maxLength: 50 + type: string - description: 批次号 in: query name: batch_no diff --git a/internal/model/dto/iot_card_dto.go b/internal/model/dto/iot_card_dto.go index 6c10caf..d8d0daa 100644 --- a/internal/model/dto/iot_card_dto.go +++ b/internal/model/dto/iot_card_dto.go @@ -11,6 +11,7 @@ type ListStandaloneIotCardRequest struct { SeriesID *uint `json:"series_id" query:"series_id" description:"套餐系列ID"` ICCID string `json:"iccid" query:"iccid" validate:"omitempty,max=20" maxLength:"20" description:"ICCID(模糊查询)"` MSISDN string `json:"msisdn" query:"msisdn" validate:"omitempty,max=20" maxLength:"20" description:"卡接入号(模糊查询)"` + VirtualNo string `json:"virtual_no" query:"virtual_no" validate:"omitempty,max=50" maxLength:"50" description:"虚拟号(模糊查询)"` BatchNo string `json:"batch_no" query:"batch_no" validate:"omitempty,max=100" maxLength:"100" description:"批次号"` PackageID *uint `json:"package_id" query:"package_id" description:"套餐ID"` IsDistributed *bool `json:"is_distributed" query:"is_distributed" description:"是否已分销 (true:已分销, false:未分销)"` @@ -22,6 +23,7 @@ type ListStandaloneIotCardRequest struct { type StandaloneIotCardResponse struct { ID uint `json:"id" description:"卡ID"` ICCID string `json:"iccid" description:"ICCID"` + VirtualNo string `json:"virtual_no,omitempty" description:"卡虚拟号(用于客服查找资产)"` CardCategory string `json:"card_category" description:"卡业务类型 (normal:普通卡, industry:行业卡)"` CarrierID uint `json:"carrier_id" description:"运营商ID"` CarrierType string `json:"carrier_type,omitempty" description:"运营商类型 (CMCC:中国移动, CUCC:中国联通, CTCC:中国电信, CBN:中国广电)"` diff --git a/internal/routes/device.go b/internal/routes/device.go index f1ad3e2..40fe44b 100644 --- a/internal/routes/device.go +++ b/internal/routes/device.go @@ -88,7 +88,7 @@ func registerDeviceRoutes(router fiber.Router, handler *admin.DeviceHandler, imp - 文件格式:仅支持 .xlsx (Excel 2007+) - 必须包含列(首行为表头): - - ` + "`device_no`" + `: 设备号(必填,唯一) + - ` + "`virtual_no`" + `: 设备虚拟号(必填,全局唯一) - ` + "`device_name`" + `: 设备名称 - ` + "`device_model`" + `: 设备型号 - ` + "`device_type`" + `: 设备类型 diff --git a/internal/routes/iot_card.go b/internal/routes/iot_card.go index 116c07c..dc97f57 100644 --- a/internal/routes/iot_card.go +++ b/internal/routes/iot_card.go @@ -49,9 +49,16 @@ func registerIotCardRoutes(router fiber.Router, handler *admin.IotCardHandler, i ### Excel 文件格式 - 文件格式:仅支持 .xlsx (Excel 2007+) -- 必须包含两列:` + "`ICCID`" + `, ` + "`MSISDN`" + ` +- 必填列:` + "`ICCID`" + `, ` + "`MSISDN`" + ` +- 可选列:` + "`virtual_no`" + `(虚拟号,表头关键字:virtual_no / VirtualNo / 虚拟号 / 设备号) - 首行为表头(可选,但建议包含) -- 列格式:设置为文本格式(避免长数字被转为科学记数法)`, +- 列格式:设置为文本格式(避免长数字被转为科学记数法) + +#### virtual_no 列导入规则(只补空白) + +- 该行 virtual_no 非空 + 数据库当前值为 NULL:填入新值 +- 该行 virtual_no 非空 + 数据库已有值:跳过(不覆盖) +- 批次内有任意 virtual_no 与数据库现存值重复:**整批拒绝**`, Tags: []string{"IoT卡管理"}, Input: new(dto.ImportIotCardRequest), Output: new(dto.ImportIotCardResponse), diff --git a/internal/service/iot_card/service.go b/internal/service/iot_card/service.go index c93c9fa..a7b82ce 100644 --- a/internal/service/iot_card/service.go +++ b/internal/service/iot_card/service.go @@ -105,6 +105,9 @@ func (s *Service) ListStandalone(ctx context.Context, req *dto.ListStandaloneIot if req.MSISDN != "" { filters["msisdn"] = req.MSISDN } + if req.VirtualNo != "" { + filters["virtual_no"] = req.VirtualNo + } if req.BatchNo != "" { filters["batch_no"] = req.BatchNo } @@ -238,6 +241,7 @@ func (s *Service) toStandaloneResponse(card *model.IotCard, shopMap map[uint]str resp := &dto.StandaloneIotCardResponse{ ID: card.ID, ICCID: card.ICCID, + VirtualNo: card.VirtualNo, CardCategory: card.CardCategory, CarrierID: card.CarrierID, CarrierType: card.CarrierType, diff --git a/internal/store/postgres/iot_card_store.go b/internal/store/postgres/iot_card_store.go index 22c72e0..afe0965 100644 --- a/internal/store/postgres/iot_card_store.go +++ b/internal/store/postgres/iot_card_store.go @@ -234,7 +234,8 @@ func (s *IotCardStore) ListStandalone(ctx context.Context, opts *store.QueryOpti _, hasICCID := filters["iccid"].(string) _, hasMSISDN := filters["msisdn"].(string) - useFuzzySearch := (hasICCID && filters["iccid"] != "") || (hasMSISDN && filters["msisdn"] != "") + _, hasVirtualNo := filters["virtual_no"].(string) + useFuzzySearch := (hasICCID && filters["iccid"] != "") || (hasMSISDN && filters["msisdn"] != "") || (hasVirtualNo && filters["virtual_no"] != "") if !useFuzzySearch { if shopIDs, ok := filters["subordinate_shop_ids"].([]uint); ok && len(shopIDs) > 1 { @@ -615,6 +616,9 @@ func (s *IotCardStore) applyStandaloneFilters(ctx context.Context, query *gorm.D if msisdn, ok := filters["msisdn"].(string); ok && msisdn != "" { query = query.Where("msisdn LIKE ?", "%"+msisdn+"%") } + if virtualNo, ok := filters["virtual_no"].(string); ok && virtualNo != "" { + query = query.Where("virtual_no LIKE ?", "%"+virtualNo+"%") + } if batchNo, ok := filters["batch_no"].(string); ok && batchNo != "" { query = query.Where("batch_no = ?", batchNo) }