parent
fd07fc1298
commit
0ee6a3dab7
@ -1,153 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Apply
|
|
||||||
description: "Implement tasks from an OpenSpec change (Experimental)"
|
|
||||||
---
|
|
||||||
|
|
||||||
Implement tasks from an OpenSpec change.
|
|
||||||
|
|
||||||
**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
|
|
||||||
|
|
||||||
**Steps**
|
|
||||||
|
|
||||||
1. **Select the change**
|
|
||||||
|
|
||||||
If a name is provided, use it. Otherwise:
|
|
||||||
- Infer from conversation context if the user mentioned a change
|
|
||||||
- Auto-select if only one active change exists
|
|
||||||
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
|
|
||||||
|
|
||||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
|
|
||||||
|
|
||||||
2. **Check status to understand the schema**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to understand:
|
|
||||||
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
||||||
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
|
|
||||||
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
||||||
|
|
||||||
3. **Get apply instructions**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openspec instructions apply --change "<name>" --json
|
|
||||||
```
|
|
||||||
|
|
||||||
This returns:
|
|
||||||
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema)
|
|
||||||
- Progress (total, complete, remaining)
|
|
||||||
- Task list with status
|
|
||||||
- Dynamic instruction based on current state
|
|
||||||
|
|
||||||
**Handle states:**
|
|
||||||
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue`
|
|
||||||
- If `state: "all_done"`: congratulate, suggest archive
|
|
||||||
- Otherwise: proceed to implementation
|
|
||||||
|
|
||||||
**Workspace guard:** If status JSON reports `actionContext.mode: "workspace-planning"` and `allowedEditRoots` is empty, explain that full workspace apply is not supported in this slice. Treat linked repos and folders as read-only context, ask the user to select an affected area through an explicit implementation workflow, and STOP before editing files.
|
|
||||||
|
|
||||||
4. **Read context files**
|
|
||||||
|
|
||||||
Read every file path listed under `contextFiles` from the apply instructions output.
|
|
||||||
The files depend on the schema being used:
|
|
||||||
- **spec-driven**: proposal, specs, design, tasks
|
|
||||||
- Other schemas: follow the contextFiles from CLI output
|
|
||||||
|
|
||||||
5. **Show current progress**
|
|
||||||
|
|
||||||
Display:
|
|
||||||
- Schema being used
|
|
||||||
- Progress: "N/M tasks complete"
|
|
||||||
- Remaining tasks overview
|
|
||||||
- Dynamic instruction from CLI
|
|
||||||
|
|
||||||
6. **Implement tasks (loop until done or blocked)**
|
|
||||||
|
|
||||||
For each pending task:
|
|
||||||
- Show which task is being worked on
|
|
||||||
- Make the code changes required
|
|
||||||
- Keep changes minimal and focused
|
|
||||||
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
|
|
||||||
- Continue to next task
|
|
||||||
|
|
||||||
**Pause if:**
|
|
||||||
- Task is unclear → ask for clarification
|
|
||||||
- Implementation reveals a design issue → suggest updating artifacts
|
|
||||||
- Error or blocker encountered → report and wait for guidance
|
|
||||||
- User interrupts
|
|
||||||
|
|
||||||
7. **On completion or pause, show status**
|
|
||||||
|
|
||||||
Display:
|
|
||||||
- Tasks completed this session
|
|
||||||
- Overall progress: "N/M tasks complete"
|
|
||||||
- If all done: suggest archive
|
|
||||||
- If paused: explain why and wait for guidance
|
|
||||||
|
|
||||||
**Output During Implementation**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Implementing: <change-name> (schema: <schema-name>)
|
|
||||||
|
|
||||||
Working on task 3/7: <task description>
|
|
||||||
[...implementation happening...]
|
|
||||||
✓ Task complete
|
|
||||||
|
|
||||||
Working on task 4/7: <task description>
|
|
||||||
[...implementation happening...]
|
|
||||||
✓ Task complete
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Completion**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Implementation Complete
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Progress:** 7/7 tasks complete ✓
|
|
||||||
|
|
||||||
### Completed This Session
|
|
||||||
- [x] Task 1
|
|
||||||
- [x] Task 2
|
|
||||||
...
|
|
||||||
|
|
||||||
All tasks complete! You can archive this change with `/opsx:archive`.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Pause (Issue Encountered)**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Implementation Paused
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Progress:** 4/7 tasks complete
|
|
||||||
|
|
||||||
### Issue Encountered
|
|
||||||
<description of the issue>
|
|
||||||
|
|
||||||
**Options:**
|
|
||||||
1. <option 1>
|
|
||||||
2. <option 2>
|
|
||||||
3. Other approach
|
|
||||||
|
|
||||||
What would you like to do?
|
|
||||||
```
|
|
||||||
|
|
||||||
**Guardrails**
|
|
||||||
- Keep going through tasks until done or blocked
|
|
||||||
- Always read context files before starting (from the apply instructions output)
|
|
||||||
- If task is ambiguous, pause and ask before implementing
|
|
||||||
- If implementation reveals issues, pause and suggest artifact updates
|
|
||||||
- Keep code changes minimal and scoped to each task
|
|
||||||
- Update task checkbox immediately after completing each task
|
|
||||||
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
||||||
- Use contextFiles from CLI output, don't assume specific file names
|
|
||||||
|
|
||||||
**Fluid Workflow Integration**
|
|
||||||
|
|
||||||
This skill supports the "actions on a change" model:
|
|
||||||
|
|
||||||
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
||||||
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
|
|
||||||
@ -1,158 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Archive
|
|
||||||
description: "Archive a completed change in the experimental workflow"
|
|
||||||
---
|
|
||||||
|
|
||||||
Archive a completed change in the experimental workflow.
|
|
||||||
|
|
||||||
**Input**: Optionally specify a change name after `/opsx:archive` (e.g., `/opsx:archive 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 only active changes (not already archived).
|
|
||||||
Include the schema used for each change if available.
|
|
||||||
|
|
||||||
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
||||||
|
|
||||||
2. **Check artifact completion status**
|
|
||||||
|
|
||||||
Run `openspec status --change "<name>" --json` to check artifact completion.
|
|
||||||
|
|
||||||
Parse the JSON to understand:
|
|
||||||
- `schemaName`: The workflow being used
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
|
||||||
- `artifacts`: List of artifacts with their status (`done` or other)
|
|
||||||
|
|
||||||
If status reports `actionContext.mode: "workspace-planning"`, explain that workspace archive is not supported in this slice and STOP. Do not move workspace changes into repo-local archives or edit linked repos.
|
|
||||||
|
|
||||||
**If any artifacts are not `done`:**
|
|
||||||
- Display warning listing incomplete artifacts
|
|
||||||
- Prompt user for confirmation to continue
|
|
||||||
- Proceed if user confirms
|
|
||||||
|
|
||||||
3. **Check task completion status**
|
|
||||||
|
|
||||||
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
|
|
||||||
|
|
||||||
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
|
|
||||||
|
|
||||||
**If incomplete tasks found:**
|
|
||||||
- Display warning showing count of incomplete tasks
|
|
||||||
- Prompt user for confirmation to continue
|
|
||||||
- Proceed if user confirms
|
|
||||||
|
|
||||||
**If no tasks file exists:** Proceed without task-related warning.
|
|
||||||
|
|
||||||
4. **Assess delta spec sync state**
|
|
||||||
|
|
||||||
Use `artifactPaths.specs.existingOutputPaths` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
|
|
||||||
|
|
||||||
**If delta specs exist:**
|
|
||||||
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
|
|
||||||
- Determine what changes would be applied (adds, modifications, removals, renames)
|
|
||||||
- Show a combined summary before prompting
|
|
||||||
|
|
||||||
**Prompt options:**
|
|
||||||
- If changes needed: "Sync now (recommended)", "Archive without syncing"
|
|
||||||
- If already synced: "Archive now", "Sync anyway", "Cancel"
|
|
||||||
|
|
||||||
If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
|
|
||||||
|
|
||||||
5. **Perform the archive**
|
|
||||||
|
|
||||||
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
|
|
||||||
```bash
|
|
||||||
mkdir -p "<planningHome.changesDir>/archive"
|
|
||||||
```
|
|
||||||
|
|
||||||
Generate target name using current date: `YYYY-MM-DD-<change-name>`
|
|
||||||
|
|
||||||
**Check if target already exists:**
|
|
||||||
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
||||||
- If no: Move `changeRoot` to the archive directory
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
6. **Display summary**
|
|
||||||
|
|
||||||
Show archive completion summary including:
|
|
||||||
- Change name
|
|
||||||
- Schema that was used
|
|
||||||
- Archive location
|
|
||||||
- Spec sync status (synced / sync skipped / no delta specs)
|
|
||||||
- Note about any warnings (incomplete artifacts/tasks)
|
|
||||||
|
|
||||||
**Output On Success**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Archive Complete
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
||||||
**Specs:** ✓ Synced to main specs
|
|
||||||
|
|
||||||
All artifacts complete. All tasks complete.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Success (No Delta Specs)**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Archive Complete
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
||||||
**Specs:** No delta specs
|
|
||||||
|
|
||||||
All artifacts complete. All tasks complete.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Success With Warnings**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Archive Complete (with warnings)
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
||||||
**Specs:** Sync skipped (user chose to skip)
|
|
||||||
|
|
||||||
**Warnings:**
|
|
||||||
- Archived with 2 incomplete artifacts
|
|
||||||
- Archived with 3 incomplete tasks
|
|
||||||
- Delta spec sync was skipped (user chose to skip)
|
|
||||||
|
|
||||||
Review the archive if this was not intentional.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Error (Archive Exists)**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Archive Failed
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Target:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
||||||
|
|
||||||
Target archive directory already exists.
|
|
||||||
|
|
||||||
**Options:**
|
|
||||||
1. Rename the existing archive
|
|
||||||
2. Delete the existing archive if it's a duplicate
|
|
||||||
3. Wait until a different date to archive
|
|
||||||
```
|
|
||||||
|
|
||||||
**Guardrails**
|
|
||||||
- Always prompt for change selection if not provided
|
|
||||||
- Use artifact graph (openspec status --json) for completion checking
|
|
||||||
- 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 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
|
|
||||||
@ -1,242 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Bulk Archive
|
|
||||||
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 "<name>" --json`
|
|
||||||
- Parse `schemaName`, `artifacts`, `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`
|
|
||||||
- Note which artifacts are `done` vs other states
|
|
||||||
|
|
||||||
If any selected change reports `actionContext.mode: "workspace-planning"`, explain that workspace bulk archive is not supported in this slice and STOP before syncing specs or moving changes. Do not fall back to repo-local paths or edit linked repos.
|
|
||||||
|
|
||||||
b. **Task completion** - Read `artifactPaths.tasks.existingOutputPaths` from status JSON
|
|
||||||
- Count `- [ ]` (incomplete) vs `- [x]` (complete)
|
|
||||||
- If no tasks file exists, note as "No tasks"
|
|
||||||
|
|
||||||
c. **Delta specs** - Check `artifactPaths.specs.existingOutputPaths` from status JSON
|
|
||||||
- List which capability specs exist
|
|
||||||
- For each, extract requirement names (lines matching `### Requirement: <name>`)
|
|
||||||
|
|
||||||
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 "<planningHome.changesDir>/archive"
|
|
||||||
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
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:
|
|
||||||
- <change-1> -> archive/YYYY-MM-DD-<change-1>/
|
|
||||||
- <change-2> -> archive/YYYY-MM-DD-<change-2>/
|
|
||||||
|
|
||||||
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:
|
|
||||||
- <change-1> -> archive/YYYY-MM-DD-<change-1>/
|
|
||||||
|
|
||||||
Skipped M changes:
|
|
||||||
- <change-2> (user chose not to archive incomplete)
|
|
||||||
|
|
||||||
Failed K changes:
|
|
||||||
- <change-3>: Archive directory already exists
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output When No Changes**
|
|
||||||
|
|
||||||
```
|
|
||||||
## No Changes to Archive
|
|
||||||
|
|
||||||
No active changes found. Create a new change to get started.
|
|
||||||
```
|
|
||||||
|
|
||||||
**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-<name>
|
|
||||||
- If archive target exists, fail that change but continue with others
|
|
||||||
@ -1,113 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Continue
|
|
||||||
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 "<name>" --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
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
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 <artifact-id> --change "<name>" --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
|
|
||||||
- `resolvedOutputPath`: Resolved path or pattern 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 `resolvedOutputPath` specified in instructions. If it is a glob pattern, choose the concrete file path using the schema instruction and workspace planning context
|
|
||||||
- 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 "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**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/<capability>/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 `<context>`, `<rules>`, `<project_context>` blocks into the artifact
|
|
||||||
- These guide what you write, but should never appear in the output
|
|
||||||
@ -1,170 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Explore
|
|
||||||
description: "Enter explore mode - think through ideas, investigate problems, clarify requirements"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 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.
|
|
||||||
|
|
||||||
**Input**: The argument after `/opsx:explore` is whatever the user wants to think about. Could be:
|
|
||||||
- A vague idea: "real-time collaboration"
|
|
||||||
- A specific problem: "the auth system is getting unwieldy"
|
|
||||||
- A change name: "add-dark-mode" (to explore in context of that change)
|
|
||||||
- A comparison: "postgres vs sqlite for this"
|
|
||||||
- Nothing (just enter explore mode)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## The Stance
|
|
||||||
|
|
||||||
- **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
|
|
||||||
- **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
|
|
||||||
- **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
|
|
||||||
- **Adaptive** - Follow interesting threads, pivot when new information emerges
|
|
||||||
- **Patient** - Don't rush to conclusions, let the shape of the problem emerge
|
|
||||||
- **Grounded** - Explore the actual codebase when relevant, don't just theorize
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What You Might Do
|
|
||||||
|
|
||||||
Depending on what the user brings, you might:
|
|
||||||
|
|
||||||
**Explore the problem space**
|
|
||||||
- Ask clarifying questions that emerge from what they said
|
|
||||||
- Challenge assumptions
|
|
||||||
- Reframe the problem
|
|
||||||
- Find analogies
|
|
||||||
|
|
||||||
**Investigate the codebase**
|
|
||||||
- Map existing architecture relevant to the discussion
|
|
||||||
- Find integration points
|
|
||||||
- Identify patterns already in use
|
|
||||||
- Surface hidden complexity
|
|
||||||
|
|
||||||
**Compare options**
|
|
||||||
- Brainstorm multiple approaches
|
|
||||||
- Build comparison tables
|
|
||||||
- Sketch tradeoffs
|
|
||||||
- Recommend a path (if asked)
|
|
||||||
|
|
||||||
**Visualize**
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────┐
|
|
||||||
│ Use ASCII diagrams liberally │
|
|
||||||
├─────────────────────────────────────────┤
|
|
||||||
│ │
|
|
||||||
│ ┌────────┐ ┌────────┐ │
|
|
||||||
│ │ State │────────▶│ State │ │
|
|
||||||
│ │ A │ │ B │ │
|
|
||||||
│ └────────┘ └────────┘ │
|
|
||||||
│ │
|
|
||||||
│ System diagrams, state machines, │
|
|
||||||
│ data flows, architecture sketches, │
|
|
||||||
│ dependency graphs, comparison tables │
|
|
||||||
│ │
|
|
||||||
└─────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
**Surface risks and unknowns**
|
|
||||||
- Identify what could go wrong
|
|
||||||
- Find gaps in understanding
|
|
||||||
- Suggest spikes or investigations
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## OpenSpec Awareness
|
|
||||||
|
|
||||||
You have full context of the OpenSpec system. Use it naturally, don't force it.
|
|
||||||
|
|
||||||
### Check for context
|
|
||||||
|
|
||||||
At the start, quickly check what exists:
|
|
||||||
```bash
|
|
||||||
openspec list --json
|
|
||||||
```
|
|
||||||
|
|
||||||
This tells you:
|
|
||||||
- If there are active changes
|
|
||||||
- Their names, schemas, and status
|
|
||||||
- What the user might be working on
|
|
||||||
|
|
||||||
If the user mentioned a specific change name, read its artifacts for context.
|
|
||||||
|
|
||||||
### When no change exists
|
|
||||||
|
|
||||||
Think freely. When insights crystallize, you might offer:
|
|
||||||
|
|
||||||
- "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
|
|
||||||
|
|
||||||
If the user mentions a change or you detect one is relevant:
|
|
||||||
|
|
||||||
1. **Resolve and read existing artifacts for context**
|
|
||||||
- Run `openspec status --change "<name>" --json`.
|
|
||||||
- Use `changeRoot`, `artifactPaths`, and `actionContext` from the status JSON.
|
|
||||||
- Read existing files from `artifactPaths.<artifact>.existingOutputPaths`.
|
|
||||||
|
|
||||||
2. **Reference them naturally in conversation**
|
|
||||||
- "Your design mentions using Redis, but we just realized SQLite fits better..."
|
|
||||||
- "The proposal scopes this to premium users, but we're now thinking everyone..."
|
|
||||||
|
|
||||||
3. **Offer to capture when decisions are made**
|
|
||||||
|
|
||||||
| Insight Type | Where to Capture |
|
|
||||||
|----------------------------|--------------------------------|
|
|
||||||
| New requirement discovered | `specs/<capability>/spec.md` |
|
|
||||||
| Requirement changed | `specs/<capability>/spec.md` |
|
|
||||||
| Design decision made | `design.md` |
|
|
||||||
| Scope changed | `proposal.md` |
|
|
||||||
| New work identified | `tasks.md` |
|
|
||||||
| Assumption invalidated | Relevant artifact |
|
|
||||||
|
|
||||||
Example offers:
|
|
||||||
- "That's a design decision. Capture it in design.md?"
|
|
||||||
- "This is a new requirement. Add it to specs?"
|
|
||||||
- "This changes scope. Update the proposal?"
|
|
||||||
|
|
||||||
4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What You Don't Have To Do
|
|
||||||
|
|
||||||
- Follow a script
|
|
||||||
- Ask the same questions every time
|
|
||||||
- Produce a specific artifact
|
|
||||||
- Reach a conclusion
|
|
||||||
- Stay on topic if a tangent is valuable
|
|
||||||
- Be brief (this is thinking time)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Ending Discovery
|
|
||||||
|
|
||||||
There's no required ending. Discovery might:
|
|
||||||
|
|
||||||
- **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"
|
|
||||||
|
|
||||||
When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Guardrails
|
|
||||||
|
|
||||||
- **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
|
|
||||||
- **Don't fake understanding** - If something is unclear, dig deeper
|
|
||||||
- **Don't rush** - Discovery is thinking time, not task time
|
|
||||||
- **Don't force structure** - Let patterns emerge naturally
|
|
||||||
- **Don't auto-capture** - Offer to save insights, don't just do it
|
|
||||||
- **Do visualize** - A good diagram is worth many paragraphs
|
|
||||||
- **Do explore the codebase** - Ground discussions in reality
|
|
||||||
- **Do question assumptions** - Including the user's and your own
|
|
||||||
@ -1,96 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Fast Forward
|
|
||||||
description: "Create a change and generate all artifacts needed for implementation in one go"
|
|
||||||
---
|
|
||||||
|
|
||||||
Fast-forward through artifact creation - generate everything needed to start implementation.
|
|
||||||
|
|
||||||
**Input**: The argument after `/opsx:ff` 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. **Create the change directory**
|
|
||||||
```bash
|
|
||||||
openspec new change "<name>"
|
|
||||||
```
|
|
||||||
This creates a scaffolded change in the planning home resolved by the CLI.
|
|
||||||
|
|
||||||
3. **Get the artifact build order**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to get:
|
|
||||||
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
||||||
- `artifacts`: list of all artifacts with their status and dependencies
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
4. **Create artifacts in sequence until apply-ready**
|
|
||||||
|
|
||||||
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
||||||
|
|
||||||
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
||||||
|
|
||||||
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
||||||
- Get instructions:
|
|
||||||
```bash
|
|
||||||
openspec instructions <artifact-id> --change "<name>" --json
|
|
||||||
```
|
|
||||||
- The instructions JSON includes:
|
|
||||||
- `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 for this artifact type
|
|
||||||
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
|
|
||||||
- `dependencies`: Completed artifacts to read for context
|
|
||||||
- Read any completed dependency files for context
|
|
||||||
- Create the artifact file using `template` as the structure and write it to `resolvedOutputPath`
|
|
||||||
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
||||||
- Show brief progress: "✓ Created <artifact-id>"
|
|
||||||
|
|
||||||
b. **Continue until all `applyRequires` artifacts are complete**
|
|
||||||
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
||||||
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
||||||
- Stop when all `applyRequires` artifacts are done
|
|
||||||
|
|
||||||
c. **If an artifact requires user input** (unclear context):
|
|
||||||
- Use **AskUserQuestion tool** to clarify
|
|
||||||
- Then continue with creation
|
|
||||||
|
|
||||||
5. **Show final status**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output**
|
|
||||||
|
|
||||||
After completing all artifacts, summarize:
|
|
||||||
- Change name and location
|
|
||||||
- List of artifacts created with brief descriptions
|
|
||||||
- What's ready: "All artifacts created! Ready for implementation."
|
|
||||||
- Prompt: "Run `/opsx:apply` to start implementing."
|
|
||||||
|
|
||||||
**Artifact Creation Guidelines**
|
|
||||||
|
|
||||||
- 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 `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 `<context>`, `<rules>`, `<project_context>` 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`)
|
|
||||||
- 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, ask if user wants to continue it or create a new one
|
|
||||||
- Verify each artifact file exists after writing before proceeding to next
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: New
|
|
||||||
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 <name>`
|
|
||||||
- "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 "<name>"
|
|
||||||
```
|
|
||||||
Add `--schema <name>` only if the user requested a specific workflow.
|
|
||||||
This creates a scaffolded change in the planning home resolved by the CLI.
|
|
||||||
|
|
||||||
4. **Show the artifact status**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Use the returned `planningHome`, `changeRoot`, `artifactPaths`, and `nextSteps` instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
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 <first-artifact-id> --change "<name>"
|
|
||||||
```
|
|
||||||
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
|
|
||||||
@ -1,546 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Onboard
|
|
||||||
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 the OpenSpec CLI is installed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Unix/macOS
|
|
||||||
openspec --version 2>&1 || echo "CLI_NOT_INSTALLED"
|
|
||||||
# Windows (PowerShell)
|
|
||||||
# if (Get-Command openspec -ErrorAction SilentlyContinue) { openspec --version } else { echo "CLI_NOT_INSTALLED" }
|
|
||||||
```
|
|
||||||
|
|
||||||
**If CLI not installed:**
|
|
||||||
> OpenSpec CLI is not installed. Install it first, then come back to `/opsx:onboard`.
|
|
||||||
|
|
||||||
Stop here if not installed.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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
|
|
||||||
# Unix/macOS
|
|
||||||
git log --oneline -10 2>/dev/null || echo "No git history"
|
|
||||||
# Windows (PowerShell)
|
|
||||||
# git log --oneline -10 2>$null; if ($LASTEXITCODE -ne 0) { 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 at the `changeRoot` reported by `openspec status --change "<name>" --json` 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 "<derived-name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**SHOW:**
|
|
||||||
```
|
|
||||||
Created: <changeRoot from status JSON>
|
|
||||||
|
|
||||||
The folder structure:
|
|
||||||
```
|
|
||||||
<changeRoot>/
|
|
||||||
├── 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
|
|
||||||
- `<capability-name>`: [brief description]
|
|
||||||
|
|
||||||
### Modified Capabilities
|
|
||||||
<!-- If modifying existing behavior -->
|
|
||||||
|
|
||||||
## 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 "<name>" --json
|
|
||||||
```
|
|
||||||
Then write the content to the `resolvedOutputPath` from `openspec instructions proposal --change "<name>" --json`.
|
|
||||||
|
|
||||||
```
|
|
||||||
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:** Resolve where the spec file should be created:
|
|
||||||
```bash
|
|
||||||
openspec instructions specs --change "<name>" --json
|
|
||||||
# Use resolvedOutputPath from the JSON. If it is a glob, choose the concrete file path using the schema instruction and workspace planning context.
|
|
||||||
```
|
|
||||||
|
|
||||||
Draft the spec content:
|
|
||||||
|
|
||||||
```
|
|
||||||
Here's the spec:
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ADDED Requirements
|
|
||||||
|
|
||||||
### Requirement: <Name>
|
|
||||||
|
|
||||||
<Description of what the system should do>
|
|
||||||
|
|
||||||
#### Scenario: <Scenario name>
|
|
||||||
|
|
||||||
- **WHEN** <trigger condition>
|
|
||||||
- **THEN** <expected outcome>
|
|
||||||
- **AND** <additional outcome if needed>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases.
|
|
||||||
```
|
|
||||||
|
|
||||||
Save to the concrete file path chosen from `resolvedOutputPath`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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 the `resolvedOutputPath` from `openspec instructions design --change "<name>" --json`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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 the `resolvedOutputPath` from `openspec instructions tasks --change "<name>" --json`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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. The archive path is derived from `planningHome.changesDir` and the date.
|
|
||||||
|
|
||||||
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 "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**SHOW:**
|
|
||||||
```
|
|
||||||
Archived to: `<planningHome.changesDir>/archive/YYYY-MM-DD-<name>/`
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
**Core workflow:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|-------------------|--------------------------------------------|
|
|
||||||
| `/opsx:propose` | Create a change and generate all artifacts |
|
|
||||||
| `/opsx:explore` | Think through problems before/during work |
|
|
||||||
| `/opsx:apply` | Implement tasks from a change |
|
|
||||||
| `/opsx:archive` | Archive a completed change |
|
|
||||||
|
|
||||||
**Additional commands:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|--------------------|----------------------------------------------------------|
|
|
||||||
| `/opsx:new` | Start a new change, step through artifacts one at a time |
|
|
||||||
| `/opsx:continue` | Continue working on an existing change |
|
|
||||||
| `/opsx:ff` | Fast-forward: create all artifacts at once |
|
|
||||||
| `/opsx:verify` | Verify implementation matches artifacts |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What's Next?
|
|
||||||
|
|
||||||
Try `/opsx:propose` 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 the `changeRoot` reported by `openspec status --change "<name>" --json`.
|
|
||||||
|
|
||||||
To pick up where we left off later:
|
|
||||||
- `/opsx:continue <name>` - Resume artifact creation
|
|
||||||
- `/opsx:apply <name>` - 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
|
|
||||||
|
|
||||||
**Core workflow:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|--------------------------|--------------------------------------------|
|
|
||||||
| `/opsx:propose <name>` | Create a change and generate all artifacts |
|
|
||||||
| `/opsx:explore` | Think through problems (no code changes) |
|
|
||||||
| `/opsx:apply <name>` | Implement tasks |
|
|
||||||
| `/opsx:archive <name>` | Archive when done |
|
|
||||||
|
|
||||||
**Additional commands:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|---------------------------|-------------------------------------|
|
|
||||||
| `/opsx:new <name>` | Start a new change, step by step |
|
|
||||||
| `/opsx:continue <name>` | Continue an existing change |
|
|
||||||
| `/opsx:ff <name>` | Fast-forward: all artifacts at once |
|
|
||||||
| `/opsx:verify <name>` | Verify implementation |
|
|
||||||
|
|
||||||
Try `/opsx:propose` to start your first change.
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
|
||||||
@ -1,105 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Propose
|
|
||||||
description: "Propose a new change - create it and generate all artifacts in one step"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 argument after `/opsx:propose` 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. **Create the change directory**
|
|
||||||
```bash
|
|
||||||
openspec new change "<name>"
|
|
||||||
```
|
|
||||||
This creates a scaffolded change in the planning home resolved by the CLI with `.openspec.yaml`.
|
|
||||||
|
|
||||||
3. **Get the artifact build order**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to get:
|
|
||||||
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
||||||
- `artifacts`: list of all artifacts with their status and dependencies
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
4. **Create artifacts in sequence until apply-ready**
|
|
||||||
|
|
||||||
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
||||||
|
|
||||||
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
||||||
|
|
||||||
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
||||||
- Get instructions:
|
|
||||||
```bash
|
|
||||||
openspec instructions <artifact-id> --change "<name>" --json
|
|
||||||
```
|
|
||||||
- The instructions JSON includes:
|
|
||||||
- `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 for this artifact type
|
|
||||||
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
|
|
||||||
- `dependencies`: Completed artifacts to read for context
|
|
||||||
- Read any completed dependency files for context
|
|
||||||
- Create the artifact file using `template` as the structure and write it to `resolvedOutputPath`
|
|
||||||
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
||||||
- Show brief progress: "Created <artifact-id>"
|
|
||||||
|
|
||||||
b. **Continue until all `applyRequires` artifacts are complete**
|
|
||||||
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
||||||
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
||||||
- Stop when all `applyRequires` artifacts are done
|
|
||||||
|
|
||||||
c. **If an artifact requires user input** (unclear context):
|
|
||||||
- Use **AskUserQuestion tool** to clarify
|
|
||||||
- Then continue with creation
|
|
||||||
|
|
||||||
5. **Show final status**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output**
|
|
||||||
|
|
||||||
After completing all artifacts, summarize:
|
|
||||||
- Change name and location
|
|
||||||
- List of artifacts created with brief descriptions
|
|
||||||
- What's ready: "All artifacts created! Ready for implementation."
|
|
||||||
- Prompt: "Run `/opsx:apply` to start implementing."
|
|
||||||
|
|
||||||
**Artifact Creation Guidelines**
|
|
||||||
|
|
||||||
- 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 `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 `<context>`, `<rules>`, `<project_context>` 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`)
|
|
||||||
- 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, ask if user wants to continue it or create a new one
|
|
||||||
- Verify each artifact file exists after writing before proceeding to next
|
|
||||||
@ -1,141 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Sync
|
|
||||||
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. **Resolve change context**
|
|
||||||
|
|
||||||
Run:
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
|
|
||||||
If status reports `actionContext.mode: "workspace-planning"`, explain that workspace spec sync is not supported in this slice and STOP. Do not fall back to repo-local paths or edit linked repos.
|
|
||||||
|
|
||||||
3. **Find delta specs**
|
|
||||||
|
|
||||||
Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the list of delta spec files.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
4. **For each delta spec, apply changes to main specs**
|
|
||||||
|
|
||||||
For each repo-local capability delta spec path returned by the CLI:
|
|
||||||
|
|
||||||
a. **Read the delta spec** to understand the intended changes
|
|
||||||
|
|
||||||
b. **Read the main spec** at `openspec/specs/<capability>/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/<capability>/spec.md`
|
|
||||||
- Add Purpose section (can be brief, mark as TBD)
|
|
||||||
- Add Requirements section with the ADDED requirements
|
|
||||||
|
|
||||||
5. **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: <change-name>
|
|
||||||
|
|
||||||
Updated main specs:
|
|
||||||
|
|
||||||
**<capability-1>**:
|
|
||||||
- Added requirement: "New Feature"
|
|
||||||
- Modified requirement: "Existing Feature" (added 1 scenario)
|
|
||||||
|
|
||||||
**<capability-2>**:
|
|
||||||
- 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
|
|
||||||
@ -1,165 +0,0 @@
|
|||||||
---
|
|
||||||
name: OPSX: Verify
|
|
||||||
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 "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to understand:
|
|
||||||
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
|
||||||
- Which artifacts exist for this change
|
|
||||||
|
|
||||||
If status reports `actionContext.mode: "workspace-planning"`, explain that full workspace implementation verification is not supported in this slice and STOP. Do not infer repo-local implementation ownership or edit linked repos.
|
|
||||||
|
|
||||||
3. **Get planning context and load artifacts**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openspec instructions apply --change "<name>" --json
|
|
||||||
```
|
|
||||||
|
|
||||||
This returns the change directory and `contextFiles` (artifact ID -> array of concrete file paths). 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 `contextFiles.tasks` exists, read every file path in 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: <description>" or "Mark as done if already implemented"
|
|
||||||
|
|
||||||
**Spec Coverage**:
|
|
||||||
- If delta specs exist in `contextFiles.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: <requirement name>"
|
|
||||||
- Recommendation: "Implement requirement X: <description>"
|
|
||||||
|
|
||||||
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: <details>"
|
|
||||||
- Recommendation: "Review <file>:<lines> 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: <scenario name>"
|
|
||||||
- Recommendation: "Add test or implementation for scenario: <description>"
|
|
||||||
|
|
||||||
7. **Verify Coherence**
|
|
||||||
|
|
||||||
**Design Adherence**:
|
|
||||||
- If `contextFiles.design` exists:
|
|
||||||
- Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
|
|
||||||
- Verify implementation follows those decisions
|
|
||||||
- If contradiction detected:
|
|
||||||
- Add WARNING: "Design decision not followed: <decision>"
|
|
||||||
- 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: <details>"
|
|
||||||
- Recommendation: "Consider following project pattern: <example>"
|
|
||||||
|
|
||||||
8. **Generate Verification Report**
|
|
||||||
|
|
||||||
**Summary Scorecard**:
|
|
||||||
```
|
|
||||||
## Verification Report: <change-name>
|
|
||||||
|
|
||||||
### 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"
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
# 用户决策点协议
|
|
||||||
|
|
||||||
规范路径:`comet/reference/decision-point.md`
|
|
||||||
|
|
||||||
本协议由所有包含用户决策点的 comet 子 skill 共享。凡标注为“阻塞点”或“用户决策点”的步骤,都必须按本协议处理。
|
|
||||||
|
|
||||||
## 核心规则
|
|
||||||
|
|
||||||
- 决策点是阻塞点。到达决策点时必须暂停,等待用户明确选择后才能继续
|
|
||||||
- 必须使用当前平台可用的用户输入/确认机制获取选择
|
|
||||||
- 若当前平台没有结构化提问工具,则必须在对话中提出明确选项并停止流程,等待用户回复
|
|
||||||
- 不得用推荐规则、默认值、历史偏好或“用户应该会同意”的推断代替当前确认
|
|
||||||
- 用户明确选择前,不得写入对应状态字段、执行对应分支操作或自动继续下一阶段
|
|
||||||
|
|
||||||
## 最低呈现要求
|
|
||||||
|
|
||||||
- 说明当前决策点正在决定什么
|
|
||||||
- 给出清晰可选项;需要用户单选时,选项必须互斥且可执行
|
|
||||||
- 如有推荐,只能作为说明,不能替代用户确认
|
|
||||||
- 用户选择后,再执行对应命令或状态更新
|
|
||||||
@ -1,311 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Comet Archive — automates the archive phase in one command
|
|
||||||
# Usage: comet-archive.sh <change-name> [--dry-run]
|
|
||||||
# Exit 0 = archive complete, exit 1 = fatal error
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
COMET_BASH="${COMET_BASH:-${BASH:-bash}}"
|
|
||||||
COMET_OPENSPEC="${COMET_OPENSPEC:-openspec}"
|
|
||||||
|
|
||||||
red() { echo -e "\033[31m$1\033[0m" >&2; }
|
|
||||||
green() { echo -e "\033[32m$1\033[0m" >&2; }
|
|
||||||
yellow() { echo -e "\033[33m$1\033[0m" >&2; }
|
|
||||||
|
|
||||||
DRY_RUN=0
|
|
||||||
if [[ "${2:-}" == "--dry-run" ]]; then
|
|
||||||
DRY_RUN=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Input validation
|
|
||||||
validate_change_name() {
|
|
||||||
local name="$1"
|
|
||||||
if [ -z "$name" ]; then
|
|
||||||
red "FATAL: Change name cannot be empty"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ ! "$name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
|
||||||
red "FATAL: Invalid change name: '$name'"
|
|
||||||
red "Valid characters: a-z, A-Z, 0-9, -, _"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ "$name" =~ \.\. ]]; then
|
|
||||||
red "FATAL: Change name cannot contain '..'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
CHANGE="$1"
|
|
||||||
validate_change_name "$CHANGE"
|
|
||||||
|
|
||||||
CHANGE_DIR="openspec/changes/$CHANGE"
|
|
||||||
YAML="$CHANGE_DIR/.comet.yaml"
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
||||||
STATE_SH="$SCRIPT_DIR/comet-state.sh"
|
|
||||||
TODAY=$(date -u +%Y-%m-%d)
|
|
||||||
ARCHIVE_NAME="${TODAY}-${CHANGE}"
|
|
||||||
ARCHIVE_DIR="openspec/changes/archive/${ARCHIVE_NAME}"
|
|
||||||
|
|
||||||
STEPS_OK=0
|
|
||||||
STEPS_TOTAL=0
|
|
||||||
|
|
||||||
step_ok() {
|
|
||||||
green " [OK] $1"
|
|
||||||
STEPS_OK=$((STEPS_OK + 1))
|
|
||||||
STEPS_TOTAL=$((STEPS_TOTAL + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
step_fail() {
|
|
||||||
red " [FAIL] $1"
|
|
||||||
STEPS_TOTAL=$((STEPS_TOTAL + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
step_dry_run() {
|
|
||||||
yellow " [DRY-RUN] $1"
|
|
||||||
STEPS_OK=$((STEPS_OK + 1))
|
|
||||||
STEPS_TOTAL=$((STEPS_TOTAL + 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "=== Comet Archive: $CHANGE ===" >&2
|
|
||||||
|
|
||||||
# --- Step 1: Read .comet.yaml, extract paths ---
|
|
||||||
|
|
||||||
yaml_field() {
|
|
||||||
local field="$1"
|
|
||||||
if [ -f "$STATE_SH" ]; then
|
|
||||||
"$COMET_BASH" "$STATE_SH" get "$CHANGE" "$field" 2>/dev/null
|
|
||||||
else
|
|
||||||
if [ -f "$YAML" ]; then
|
|
||||||
local value
|
|
||||||
value=$(grep "^${field}:" "$YAML" 2>/dev/null | sed "s/^${field}: *//" || true)
|
|
||||||
value=$(strip_inline_comment "$value")
|
|
||||||
strip_wrapping_quotes "$value"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_inline_comment() {
|
|
||||||
local value="$1"
|
|
||||||
printf '%s\n' "$value" | awk -v squote="'" '
|
|
||||||
{
|
|
||||||
out = ""
|
|
||||||
quote = ""
|
|
||||||
for (i = 1; i <= length($0); i++) {
|
|
||||||
c = substr($0, i, 1)
|
|
||||||
if (quote == "") {
|
|
||||||
if (c == "\"" || c == squote) {
|
|
||||||
quote = c
|
|
||||||
} else if (c == "#" && (i == 1 || substr($0, i - 1, 1) ~ /[[:space:]]/)) {
|
|
||||||
sub(/[[:space:]]+$/, "", out)
|
|
||||||
print out
|
|
||||||
next
|
|
||||||
}
|
|
||||||
} else if (c == quote) {
|
|
||||||
quote = ""
|
|
||||||
}
|
|
||||||
out = out c
|
|
||||||
}
|
|
||||||
print out
|
|
||||||
}
|
|
||||||
'
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_wrapping_quotes() {
|
|
||||||
local value="$1"
|
|
||||||
case "$value" in
|
|
||||||
\"*\") printf '%s\n' "${value:1:${#value}-2}" ;;
|
|
||||||
\'*\') printf '%s\n' "${value:1:${#value}-2}" ;;
|
|
||||||
*) printf '%s\n' "$value" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -f "$YAML" ]; then
|
|
||||||
red "FATAL: .comet.yaml not found in $CHANGE_DIR/"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
DESIGN_DOC=$(yaml_field "design_doc")
|
|
||||||
PLAN_PATH=$(yaml_field "plan")
|
|
||||||
|
|
||||||
# --- Step 2: Validate entry state ---
|
|
||||||
|
|
||||||
PHASE_VAL=$(yaml_field "phase")
|
|
||||||
VERIFY_VAL=$(yaml_field "verify_result")
|
|
||||||
ARCHIVED_VAL=$(yaml_field "archived")
|
|
||||||
|
|
||||||
if [ "$PHASE_VAL" != "archive" ]; then
|
|
||||||
red "FATAL: phase is '$PHASE_VAL', expected 'archive'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$VERIFY_VAL" != "pass" ]; then
|
|
||||||
red "FATAL: verify_result is '$VERIFY_VAL', expected 'pass'. Run comet-verify first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ARCHIVED_VAL" = "true" ]; then
|
|
||||||
red "FATAL: change already archived"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
step_ok "Entry state verified"
|
|
||||||
|
|
||||||
# --- Step 3: Check archive target ---
|
|
||||||
|
|
||||||
if [ -d "$ARCHIVE_DIR" ]; then
|
|
||||||
red "FATAL: archive target already exists: $ARCHIVE_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
step_ok "Archive target available"
|
|
||||||
|
|
||||||
# --- Step 4: Prepare document frontmatter annotation ---
|
|
||||||
|
|
||||||
annotate_frontmatter() {
|
|
||||||
local file="$1"
|
|
||||||
local extra_fields="$2"
|
|
||||||
|
|
||||||
if [ ! -f "$file" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$DRY_RUN" -eq 1 ]; then
|
|
||||||
step_dry_run "Would annotate: $file"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if head -1 "$file" | grep -q '^---'; then
|
|
||||||
local tmp_file
|
|
||||||
tmp_file=$(mktemp)
|
|
||||||
chmod 600 "$tmp_file"
|
|
||||||
awk -v archive="$ARCHIVE_NAME" -v extra="$extra_fields" '
|
|
||||||
/^archived-with:/ { next }
|
|
||||||
NR==1 && /^---/ { print; next }
|
|
||||||
/^---/ && NR>1 {
|
|
||||||
print "archived-with: " archive
|
|
||||||
if (extra != "") print extra
|
|
||||||
print; next
|
|
||||||
}
|
|
||||||
{ print }
|
|
||||||
' "$file" > "$tmp_file"
|
|
||||||
mv "$tmp_file" "$file"
|
|
||||||
else
|
|
||||||
local tmp_file
|
|
||||||
tmp_file=$(mktemp)
|
|
||||||
chmod 600 "$tmp_file"
|
|
||||||
{
|
|
||||||
echo "---"
|
|
||||||
echo "archived-with: $ARCHIVE_NAME"
|
|
||||||
if [ -n "$extra_fields" ]; then
|
|
||||||
echo "$extra_fields"
|
|
||||||
fi
|
|
||||||
echo "status: final"
|
|
||||||
echo "---"
|
|
||||||
cat "$file"
|
|
||||||
} > "$tmp_file"
|
|
||||||
mv "$tmp_file" "$file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
step_ok "Annotated: $file"
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Step 5: Run OpenSpec archive for delta merge and move ---
|
|
||||||
|
|
||||||
verify_main_specs_clean() {
|
|
||||||
if [ ! -d "openspec/specs" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
local found=0
|
|
||||||
local matches
|
|
||||||
for spec_file in openspec/specs/*/spec.md; do
|
|
||||||
[ -f "$spec_file" ] || continue
|
|
||||||
matches=$(grep -nE '^## (ADDED|MODIFIED|REMOVED|RENAMED) Requirements$' "$spec_file" 2>/dev/null || true)
|
|
||||||
if [ -n "$matches" ]; then
|
|
||||||
red "FATAL: delta-only section heading leaked into main spec: $spec_file"
|
|
||||||
printf '%s\n' "$matches" >&2
|
|
||||||
found=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$found" -ne 0 ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve_archive_dir() {
|
|
||||||
if [ -d "$ARCHIVE_DIR" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
# Fallback: search for any directory matching *-$CHANGE in archive
|
|
||||||
local found
|
|
||||||
found=$(find "openspec/changes/archive" -maxdepth 1 -mindepth 1 -type d -name "*-$CHANGE" 2>/dev/null | head -1 || true)
|
|
||||||
if [ -n "$found" ]; then
|
|
||||||
ARCHIVE_DIR="$found"
|
|
||||||
ARCHIVE_NAME=$(basename "$found")
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$DRY_RUN" -eq 1 ]; then
|
|
||||||
step_dry_run "Would run OpenSpec archive: $CHANGE"
|
|
||||||
else
|
|
||||||
if ! command -v "$COMET_OPENSPEC" >/dev/null 2>&1; then
|
|
||||||
red "FATAL: OpenSpec CLI not found: $COMET_OPENSPEC"
|
|
||||||
red "Install OpenSpec or set COMET_OPENSPEC to the openspec executable."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
"$COMET_OPENSPEC" archive "$CHANGE" --yes >&2
|
|
||||||
if ! resolve_archive_dir; then
|
|
||||||
step_fail "OpenSpec archive output not found"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
step_ok "OpenSpec archive completed: $ARCHIVE_DIR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
verify_main_specs_clean
|
|
||||||
step_ok "Main specs verified clean"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Step 6: Annotate design doc and plan frontmatter ---
|
|
||||||
|
|
||||||
if [ -n "$DESIGN_DOC" ] && [ "$DESIGN_DOC" != "null" ]; then
|
|
||||||
annotate_frontmatter "$DESIGN_DOC" "status: final"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$PLAN_PATH" ] && [ "$PLAN_PATH" != "null" ]; then
|
|
||||||
annotate_frontmatter "$PLAN_PATH" ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Step 7: Mark archived via comet-state transition ---
|
|
||||||
|
|
||||||
ARCHIVE_YAML="$ARCHIVE_DIR/.comet.yaml"
|
|
||||||
|
|
||||||
if [ "$DRY_RUN" -eq 1 ]; then
|
|
||||||
step_dry_run "Would set archived: true in $ARCHIVE_YAML"
|
|
||||||
else
|
|
||||||
if [ -f "$ARCHIVE_YAML" ]; then
|
|
||||||
"$COMET_BASH" "$STATE_SH" transition "$ARCHIVE_NAME" archived >/dev/null
|
|
||||||
step_ok "archived: true"
|
|
||||||
else
|
|
||||||
step_fail "archived: true (.comet.yaml not found after move)"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Step 8: Print summary ---
|
|
||||||
|
|
||||||
echo "" >&2
|
|
||||||
if [ "$DRY_RUN" -eq 1 ]; then
|
|
||||||
yellow "Dry run complete. $STEPS_OK/$STEPS_TOTAL steps would succeed."
|
|
||||||
else
|
|
||||||
green "Archive complete. $STEPS_OK/$STEPS_TOTAL steps succeeded."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$STEPS_OK" -lt "$STEPS_TOTAL" ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
@ -1,110 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Comet script locator — source this file to export paths to bundled scripts.
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# . /path/to/comet/scripts/comet-env.sh
|
|
||||||
#
|
|
||||||
# This file is sourced by workflow snippets. Do not set global shell options here.
|
|
||||||
|
|
||||||
_comet_env_source="${BASH_SOURCE[0]:-$0}"
|
|
||||||
_comet_script_dir="$(cd "$(dirname "$_comet_env_source")" && pwd -P)"
|
|
||||||
_comet_env_sourced=0
|
|
||||||
(return 0 2>/dev/null) && _comet_env_sourced=1
|
|
||||||
|
|
||||||
export COMET_GUARD="${COMET_GUARD:-${_comet_script_dir}/comet-guard.sh}"
|
|
||||||
export COMET_STATE="${COMET_STATE:-${_comet_script_dir}/comet-state.sh}"
|
|
||||||
export COMET_HANDOFF="${COMET_HANDOFF:-${_comet_script_dir}/comet-handoff.sh}"
|
|
||||||
export COMET_ARCHIVE="${COMET_ARCHIVE:-${_comet_script_dir}/comet-archive.sh}"
|
|
||||||
export COMET_YAML_VALIDATE="${COMET_YAML_VALIDATE:-${_comet_script_dir}/comet-yaml-validate.sh}"
|
|
||||||
|
|
||||||
_comet_bash_is_usable() {
|
|
||||||
local _comet_bash_candidate="$1"
|
|
||||||
if [ -z "$_comet_bash_candidate" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
case "$_comet_bash_candidate" in
|
|
||||||
*/Windows/System32/bash.exe|*/windows/system32/bash.exe|*\\Windows\\System32\\bash.exe|*\\windows\\system32\\bash.exe)
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
"$_comet_bash_candidate" -lc 'printf comet-bash-ok' >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
_comet_resolve_bash() {
|
|
||||||
local _comet_bash_candidate
|
|
||||||
|
|
||||||
if _comet_bash_is_usable "${COMET_BASH:-}"; then
|
|
||||||
printf '%s\n' "$COMET_BASH"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if _comet_bash_is_usable "${BASH:-}"; then
|
|
||||||
printf '%s\n' "$BASH"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
_comet_bash_candidate="$(command -v sh 2>/dev/null | awk '{ sub(/\/sh(\.exe)?$/, "/bash.exe"); print }')"
|
|
||||||
if _comet_bash_is_usable "$_comet_bash_candidate"; then
|
|
||||||
printf '%s\n' "$_comet_bash_candidate"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
_comet_bash_candidate="$(command -v bash 2>/dev/null || true)"
|
|
||||||
if _comet_bash_is_usable "$_comet_bash_candidate"; then
|
|
||||||
printf '%s\n' "$_comet_bash_candidate"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
COMET_BASH="$(_comet_resolve_bash || true)"
|
|
||||||
export COMET_BASH
|
|
||||||
|
|
||||||
_comet_env_fail() {
|
|
||||||
echo "ERROR: Comet scripts not found. Ensure the comet skill is installed completely." >&2
|
|
||||||
echo "Expected path pattern: */comet/scripts/comet-*.sh under project or platform skill directories" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
_comet_bash_fail() {
|
|
||||||
echo "ERROR: usable bash not found. Install Git Bash or set COMET_BASH to a working bash executable." >&2
|
|
||||||
echo "Windows WSL launcher bash.exe is not supported for Comet scripts." >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
_comet_env_abort() {
|
|
||||||
local _comet_env_was_sourced="$_comet_env_sourced"
|
|
||||||
unset _comet_env_source _comet_script_dir _comet_script _comet_env_missing _comet_env_sourced
|
|
||||||
unset _comet_bash_candidate
|
|
||||||
unset -f _comet_env_fail _comet_bash_fail _comet_bash_is_usable _comet_resolve_bash
|
|
||||||
if [ "$_comet_env_was_sourced" -eq 1 ]; then
|
|
||||||
unset -f _comet_env_abort
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
_comet_env_missing=0
|
|
||||||
if [ -z "$COMET_BASH" ]; then
|
|
||||||
_comet_bash_fail
|
|
||||||
_comet_env_missing=1
|
|
||||||
fi
|
|
||||||
for _comet_script in \
|
|
||||||
"$COMET_GUARD" \
|
|
||||||
"$COMET_STATE" \
|
|
||||||
"$COMET_HANDOFF" \
|
|
||||||
"$COMET_ARCHIVE" \
|
|
||||||
"$COMET_YAML_VALIDATE"; do
|
|
||||||
if [ ! -f "$_comet_script" ]; then
|
|
||||||
_comet_env_fail
|
|
||||||
_comet_env_missing=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$_comet_env_missing" -ne 0 ]; then
|
|
||||||
_comet_env_abort
|
|
||||||
else
|
|
||||||
unset _comet_env_source _comet_script_dir _comet_script _comet_env_missing _comet_env_sourced
|
|
||||||
unset _comet_bash_candidate
|
|
||||||
unset -f _comet_env_fail _comet_bash_fail _comet_bash_is_usable _comet_resolve_bash _comet_env_abort
|
|
||||||
fi
|
|
||||||
@ -1,778 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Comet Phase Guard — validates exit conditions before phase transitions
|
|
||||||
# Usage: comet-guard.sh <change-name> <current-phase> [--apply]
|
|
||||||
# Phases: open, design, build, verify, archive
|
|
||||||
# Exit 0 = all checks pass, exit 1 = blocked (reasons printed to stderr)
|
|
||||||
# shellcheck disable=SC2329 # Functions called indirectly via check() dispatch
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
COMET_BASH="${COMET_BASH:-${BASH:-bash}}"
|
|
||||||
|
|
||||||
red() { echo -e "\033[31m$1\033[0m" >&2; }
|
|
||||||
green() { echo -e "\033[32m$1\033[0m" >&2; }
|
|
||||||
warn() { echo -e "\033[33m$1\033[0m" >&2; }
|
|
||||||
|
|
||||||
# Input validation - prevent path traversal
|
|
||||||
validate_change_name() {
|
|
||||||
local name="$1"
|
|
||||||
# Reject empty names
|
|
||||||
if [ -z "$name" ]; then
|
|
||||||
red "ERROR: Change name cannot be empty" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Only allow alphanumeric, hyphens, and underscores
|
|
||||||
if [[ ! "$name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
|
||||||
red "ERROR: Invalid change name: '$name'" >&2
|
|
||||||
red "Valid characters: a-z, A-Z, 0-9, -, _" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Reject path traversal attempts
|
|
||||||
if [[ "$name" =~ \.\. ]]; then
|
|
||||||
red "ERROR: Change name cannot contain '..' (path traversal not allowed)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "${COMET_GUARD_SOURCE_ONLY:-0}" = "1" ]; then
|
|
||||||
CHANGE="${CHANGE:-}"
|
|
||||||
PHASE="${PHASE:-}"
|
|
||||||
APPLY="${APPLY:-0}"
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd -P)"
|
|
||||||
CHANGE_DIR="${CHANGE_DIR:-}"
|
|
||||||
else
|
|
||||||
validate_change_name "$1"
|
|
||||||
|
|
||||||
CHANGE="$1"
|
|
||||||
PHASE="$2"
|
|
||||||
APPLY=0
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
|
|
||||||
if [[ "${3:-}" == "--apply" ]]; then
|
|
||||||
APPLY=1
|
|
||||||
fi
|
|
||||||
CHANGE_DIR="openspec/changes/$CHANGE"
|
|
||||||
if [ "$PHASE" = "archive" ] && [ ! -d "$CHANGE_DIR" ] && [ -d "openspec/changes/archive/$CHANGE" ]; then
|
|
||||||
CHANGE_DIR="openspec/changes/archive/$CHANGE"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
BLOCK=0
|
|
||||||
check() {
|
|
||||||
local desc="$1"
|
|
||||||
shift
|
|
||||||
local output
|
|
||||||
if output=$("$@" 2>&1); then
|
|
||||||
green " [PASS] $desc"
|
|
||||||
else
|
|
||||||
red " [FAIL] $desc"
|
|
||||||
if [ -n "$output" ]; then
|
|
||||||
while IFS= read -r line; do
|
|
||||||
red " $line"
|
|
||||||
done <<< "$output"
|
|
||||||
fi
|
|
||||||
BLOCK=1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Helper functions ---
|
|
||||||
|
|
||||||
tasks_all_done() {
|
|
||||||
local tasks="$CHANGE_DIR/tasks.md"
|
|
||||||
if [ ! -f "$tasks" ]; then
|
|
||||||
echo "tasks.md is missing at $tasks" >&2
|
|
||||||
echo "Next: restore or create tasks.md for this change before leaving build." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if ! grep -q '\- \[x\]' "$tasks"; then
|
|
||||||
echo "tasks.md has no completed tasks." >&2
|
|
||||||
echo "Next: complete implementation tasks and mark them with '- [x]'." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if grep -q '\- \[ \]' "$tasks"; then
|
|
||||||
echo "Unfinished tasks:" >&2
|
|
||||||
grep -n '\- \[ \]' "$tasks" >&2 || true
|
|
||||||
echo "Next: complete or explicitly remove unfinished tasks, then mark tasks.md with '- [x]'." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks_has_any() {
|
|
||||||
local tasks="$CHANGE_DIR/tasks.md"
|
|
||||||
[ -f "$tasks" ] && grep -q '\- \[' "$tasks"
|
|
||||||
}
|
|
||||||
|
|
||||||
plan_tasks_all_done() {
|
|
||||||
local plan
|
|
||||||
plan=$(yaml_field_value "plan" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ -z "$plan" ] || [ "$plan" = "null" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [ ! -f "$plan" ]; then
|
|
||||||
echo "plan file is missing at $plan" >&2
|
|
||||||
echo "Next: restore the Superpowers plan file or update .comet.yaml plan before leaving build." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if grep -q '^[[:space:]]*- \[ \]' "$plan"; then
|
|
||||||
echo "Unfinished Superpowers plan tasks:" >&2
|
|
||||||
grep -n '^[[:space:]]*- \[ \]' "$plan" >&2 || true
|
|
||||||
echo "Next: check off corresponding completed plan tasks, then commit the plan update." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
yaml_field_value() {
|
|
||||||
local field="$1"
|
|
||||||
local yaml="$CHANGE_DIR/.comet.yaml"
|
|
||||||
if [ -f "$yaml" ]; then
|
|
||||||
local value
|
|
||||||
value=$(grep "^${field}:" "$yaml" 2>/dev/null | sed "s/^${field}: *//" || true)
|
|
||||||
value=$(strip_inline_comment "$value")
|
|
||||||
strip_wrapping_quotes "$value"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_inline_comment() {
|
|
||||||
local value="$1"
|
|
||||||
printf '%s\n' "$value" | awk -v squote="'" '
|
|
||||||
{
|
|
||||||
out = ""
|
|
||||||
quote = ""
|
|
||||||
for (i = 1; i <= length($0); i++) {
|
|
||||||
c = substr($0, i, 1)
|
|
||||||
if (quote == "") {
|
|
||||||
if (c == "\"" || c == squote) {
|
|
||||||
quote = c
|
|
||||||
} else if (c == "#" && (i == 1 || substr($0, i - 1, 1) ~ /[[:space:]]/)) {
|
|
||||||
sub(/[[:space:]]+$/, "", out)
|
|
||||||
print out
|
|
||||||
next
|
|
||||||
}
|
|
||||||
} else if (c == quote) {
|
|
||||||
quote = ""
|
|
||||||
}
|
|
||||||
out = out c
|
|
||||||
}
|
|
||||||
print out
|
|
||||||
}
|
|
||||||
'
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_wrapping_quotes() {
|
|
||||||
local value="$1"
|
|
||||||
case "$value" in
|
|
||||||
\"*\")
|
|
||||||
printf '%s\n' "${value:1:${#value}-2}"
|
|
||||||
;;
|
|
||||||
\'*\')
|
|
||||||
printf '%s\n' "${value:1:${#value}-2}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf '%s\n' "$value"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
project_config_value() {
|
|
||||||
local field="$1"
|
|
||||||
local value
|
|
||||||
|
|
||||||
value=$(yaml_field_value "$field" 2>/dev/null || true)
|
|
||||||
if [ -n "$value" ] && [ "$value" != "null" ]; then
|
|
||||||
echo "$value"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for config in ".comet.yaml" "comet.yaml" ".comet.yml" "comet.yml"; do
|
|
||||||
if [ -f "$config" ]; then
|
|
||||||
value=$(grep "^${field}:" "$config" 2>/dev/null | sed "s/^${field}: *//" || true)
|
|
||||||
value=$(strip_inline_comment "$value")
|
|
||||||
value=$(strip_wrapping_quotes "$value")
|
|
||||||
if [ -n "$value" ] && [ "$value" != "null" ]; then
|
|
||||||
echo "$value"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
file_nonempty() {
|
|
||||||
[ -f "$1" ] && [ -s "$1" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
is_windows_bash() {
|
|
||||||
case "$(uname -s 2>/dev/null || true)" in
|
|
||||||
MINGW*|MSYS*|CYGWIN*) return 0 ;;
|
|
||||||
*) return 1 ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
run_command_string() {
|
|
||||||
local command="$1"
|
|
||||||
if [ -z "$command" ]; then
|
|
||||||
red "ERROR: build/verify command is empty" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# Basic command injection guard: reject dangerous shell metacharacters
|
|
||||||
# Quotes are allowed to support paths with spaces (e.g. Windows)
|
|
||||||
if [[ "$command" =~ [\;\|\&\$\`] ]]; then
|
|
||||||
red "ERROR: build/verify command contains shell metacharacters: $command" >&2
|
|
||||||
red "Allowed: alphanumeric, spaces, hyphens, underscores, dots, colons, forward slashes, quotes" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
echo "+ $command" >&2
|
|
||||||
"$COMET_BASH" -lc "$command"
|
|
||||||
}
|
|
||||||
|
|
||||||
hash_stream() {
|
|
||||||
if command -v sha256sum >/dev/null 2>&1; then
|
|
||||||
sha256sum | awk '{print $1}'
|
|
||||||
elif command -v shasum >/dev/null 2>&1; then
|
|
||||||
shasum -a 256 | awk '{print $1}'
|
|
||||||
else
|
|
||||||
echo "sha256sum or shasum is required" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
hash_file() {
|
|
||||||
local file="$1"
|
|
||||||
if command -v sha256sum >/dev/null 2>&1; then
|
|
||||||
sha256sum "$file" | awk '{print $1}'
|
|
||||||
elif command -v shasum >/dev/null 2>&1; then
|
|
||||||
shasum -a 256 "$file" | awk '{print $1}'
|
|
||||||
else
|
|
||||||
echo "sha256sum or shasum is required" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
handoff_source_files() {
|
|
||||||
printf '%s\n' "$CHANGE_DIR/proposal.md"
|
|
||||||
printf '%s\n' "$CHANGE_DIR/design.md"
|
|
||||||
printf '%s\n' "$CHANGE_DIR/tasks.md"
|
|
||||||
if [ -d "$CHANGE_DIR/specs" ]; then
|
|
||||||
find "$CHANGE_DIR/specs" -path '*/spec.md' -type f 2>/dev/null | sort
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
compute_handoff_hash() {
|
|
||||||
local hash_input
|
|
||||||
hash_input=$(handoff_source_files | while IFS= read -r file; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
printf 'path:%s\n' "$file"
|
|
||||||
printf 'sha256:%s\n' "$(hash_file "$file")"
|
|
||||||
fi
|
|
||||||
done)
|
|
||||||
printf '%s' "$hash_input" | hash_stream
|
|
||||||
}
|
|
||||||
|
|
||||||
preflight() {
|
|
||||||
|
|
||||||
if [ ! -d "$CHANGE_DIR" ]; then
|
|
||||||
red "FATAL: change directory not found: $CHANGE_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -f "$CHANGE_DIR/.comet.yaml" ]; then
|
|
||||||
red "FATAL: .comet.yaml not found in $CHANGE_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Schema validation
|
|
||||||
local validate_script
|
|
||||||
validate_script="$SCRIPT_DIR/comet-yaml-validate.sh"
|
|
||||||
if [ -f "$validate_script" ]; then
|
|
||||||
if ! "$COMET_BASH" "$validate_script" "$CHANGE" 2>/dev/null; then
|
|
||||||
"$COMET_BASH" "$validate_script" "$CHANGE" || true
|
|
||||||
red "FATAL: .comet.yaml schema validation failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
build_passes() {
|
|
||||||
if [ "${COMET_SKIP_BUILD:-0}" = "1" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
local configured_build
|
|
||||||
configured_build=$(project_config_value "build_command" 2>/dev/null || true)
|
|
||||||
if [ -n "$configured_build" ]; then
|
|
||||||
run_command_string "$configured_build"
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
if [ -f "package.json" ] && grep -q '"build"' "package.json"; then
|
|
||||||
npm run build
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
if [ -f "pom.xml" ]; then
|
|
||||||
if [ -x "./mvnw" ]; then
|
|
||||||
./mvnw compile -q
|
|
||||||
elif is_windows_bash && command -v mvn.cmd >/dev/null 2>&1; then
|
|
||||||
mvn.cmd compile -q
|
|
||||||
else
|
|
||||||
mvn compile -q
|
|
||||||
fi
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
if [ -f "Cargo.toml" ]; then
|
|
||||||
cargo build
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
verification_command_passes() {
|
|
||||||
if [ "${COMET_SKIP_BUILD:-0}" = "1" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
local configured_verify
|
|
||||||
configured_verify=$(project_config_value "verify_command" 2>/dev/null || true)
|
|
||||||
if [ -n "$configured_verify" ]; then
|
|
||||||
run_command_string "$configured_verify"
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
build_passes
|
|
||||||
}
|
|
||||||
|
|
||||||
isolation_selected() {
|
|
||||||
local isolation
|
|
||||||
isolation=$(yaml_field_value "isolation" 2>/dev/null || true)
|
|
||||||
case "$isolation" in
|
|
||||||
branch|worktree) return 0 ;;
|
|
||||||
*)
|
|
||||||
echo "isolation must be branch or worktree, got '${isolation:-null}'" >&2
|
|
||||||
echo "Next: ask the user to choose branch or worktree, create the chosen isolation, then run:" >&2
|
|
||||||
echo " \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE isolation <branch|worktree>" >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
build_mode_selected() {
|
|
||||||
local build_mode
|
|
||||||
build_mode=$(yaml_field_value "build_mode" 2>/dev/null || true)
|
|
||||||
case "$build_mode" in
|
|
||||||
subagent-driven-development|executing-plans|direct) return 0 ;;
|
|
||||||
*)
|
|
||||||
echo "build_mode must be selected before leaving build, got '${build_mode:-null}'" >&2
|
|
||||||
echo "Next: ask the user to choose an execution mode, then run:" >&2
|
|
||||||
echo " \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE build_mode <subagent-driven-development|executing-plans>" >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
build_mode_allowed_for_workflow() {
|
|
||||||
local workflow build_mode direct_override
|
|
||||||
workflow=$(yaml_field_value "workflow" 2>/dev/null || true)
|
|
||||||
build_mode=$(yaml_field_value "build_mode" 2>/dev/null || true)
|
|
||||||
direct_override=$(yaml_field_value "direct_override" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ "$build_mode" != "direct" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
case "$workflow" in
|
|
||||||
hotfix|tweak) return 0 ;;
|
|
||||||
*)
|
|
||||||
if [ "$direct_override" = "true" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
echo "build_mode=direct is only allowed for hotfix/tweak unless direct_override: true is recorded" >&2
|
|
||||||
echo "Next: choose executing-plans or subagent-driven-development, or stop and ask the user for an explicit direct override." >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
subagent_dispatch_confirmed() {
|
|
||||||
local build_mode subagent_dispatch
|
|
||||||
build_mode=$(yaml_field_value "build_mode" 2>/dev/null || true)
|
|
||||||
subagent_dispatch=$(yaml_field_value "subagent_dispatch" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ "$build_mode" != "subagent-driven-development" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$subagent_dispatch" = "confirmed" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "subagent_dispatch must be confirmed before using build_mode=subagent-driven-development" >&2
|
|
||||||
echo "Next: confirm the current platform has a real background subagent/Task/multi-agent dispatcher, then run:" >&2
|
|
||||||
echo " \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE subagent_dispatch confirmed" >&2
|
|
||||||
echo "Or ask the user to switch to executing-plans and run:" >&2
|
|
||||||
echo " \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE build_mode executing-plans" >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
tdd_mode_selected() {
|
|
||||||
local workflow tdd_mode
|
|
||||||
workflow=$(yaml_field_value "workflow" 2>/dev/null || true)
|
|
||||||
tdd_mode=$(yaml_field_value "tdd_mode" 2>/dev/null || true)
|
|
||||||
|
|
||||||
case "$workflow" in
|
|
||||||
hotfix|tweak) return 0 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$tdd_mode" in
|
|
||||||
tdd|direct) return 0 ;;
|
|
||||||
*)
|
|
||||||
echo "tdd_mode must be tdd or direct for full workflow, got '${tdd_mode:-null}'" >&2
|
|
||||||
echo "Next: ask the user to choose TDD enforcement level, then run:" >&2
|
|
||||||
echo " \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE tdd_mode <tdd|direct>" >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
review_mode_selected() {
|
|
||||||
local workflow review_mode
|
|
||||||
workflow=$(yaml_field_value "workflow" 2>/dev/null || true)
|
|
||||||
review_mode=$(yaml_field_value "review_mode" 2>/dev/null || true)
|
|
||||||
|
|
||||||
case "$workflow" in
|
|
||||||
hotfix|tweak) return 0 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$review_mode" in
|
|
||||||
off|standard|thorough) return 0 ;;
|
|
||||||
*)
|
|
||||||
echo "review_mode must be off, standard, or thorough before leaving build, got '${review_mode:-null}'" >&2
|
|
||||||
echo "Next: ask the user to choose code review mode, then run:" >&2
|
|
||||||
echo " \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE review_mode <off|standard|thorough>" >&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
verify_result_is_pass() {
|
|
||||||
local result
|
|
||||||
result=$(yaml_field_value "verify_result" 2>/dev/null || true)
|
|
||||||
[ "$result" = "pass" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
verification_report_exists() {
|
|
||||||
local report
|
|
||||||
report=$(yaml_field_value "verification_report" 2>/dev/null || true)
|
|
||||||
[ -n "$report" ] && [ "$report" != "null" ] && [ -f "$report" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
branch_status_handled() {
|
|
||||||
local status
|
|
||||||
status=$(yaml_field_value "branch_status" 2>/dev/null || true)
|
|
||||||
[ "$status" = "handled" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
design_handoff_context_valid() {
|
|
||||||
local context recorded_hash actual_hash markdown
|
|
||||||
context=$(yaml_field_value "handoff_context" 2>/dev/null || true)
|
|
||||||
recorded_hash=$(yaml_field_value "handoff_hash" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ -z "$context" ] || [ "$context" = "null" ]; then
|
|
||||||
echo "handoff_context is missing from .comet.yaml" >&2
|
|
||||||
echo "Next: run \"\$COMET_BASH\" \"\$COMET_HANDOFF\" $CHANGE design --write before invoking Superpowers." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ! -s "$context" ]; then
|
|
||||||
echo "handoff_context does not point to a non-empty file: $context" >&2
|
|
||||||
echo "Next: regenerate the design handoff with comet-handoff.sh." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ ! "$recorded_hash" =~ ^[a-f0-9]{64}$ ]]; then
|
|
||||||
echo "handoff_hash is missing or invalid: ${recorded_hash:-null}" >&2
|
|
||||||
echo "Next: regenerate the design handoff with comet-handoff.sh." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
actual_hash=$(compute_handoff_hash)
|
|
||||||
if [ "$actual_hash" != "$recorded_hash" ]; then
|
|
||||||
echo "OpenSpec artifacts changed after handoff was generated." >&2
|
|
||||||
echo "Expected handoff_hash: $recorded_hash" >&2
|
|
||||||
echo "Actual handoff_hash: $actual_hash" >&2
|
|
||||||
echo "Next: rerun comet-handoff.sh so Superpowers receives the current OpenSpec context." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
markdown="${context%.json}.md"
|
|
||||||
if [ ! -s "$markdown" ]; then
|
|
||||||
echo "design handoff markdown is missing or empty: $markdown" >&2
|
|
||||||
echo "Next: regenerate the design handoff with comet-handoff.sh." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
design_handoff_markdown_traceable() {
|
|
||||||
local context markdown missing=0
|
|
||||||
context=$(yaml_field_value "handoff_context" 2>/dev/null || true)
|
|
||||||
if [ -z "$context" ] || [ "$context" = "null" ]; then
|
|
||||||
echo "handoff_context is missing from .comet.yaml" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
markdown="${context%.json}.md"
|
|
||||||
if [ ! -s "$markdown" ]; then
|
|
||||||
echo "design handoff markdown is missing or empty: $markdown" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
grep -q '^Generated-by: comet-handoff\.sh$' "$markdown" || {
|
|
||||||
echo "handoff markdown is missing Generated-by marker" >&2
|
|
||||||
missing=1
|
|
||||||
}
|
|
||||||
grep -Eq '^- Mode: (compact|full|beta)$' "$markdown" || {
|
|
||||||
echo "handoff markdown is missing Mode marker" >&2
|
|
||||||
missing=1
|
|
||||||
}
|
|
||||||
handoff_source_files | while IFS= read -r file; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
if ! grep -q "^- Source: $file$" "$markdown"; then
|
|
||||||
echo "handoff markdown is missing source reference: $file" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
if ! grep -q "^- SHA256: $(hash_file "$file")$" "$markdown"; then
|
|
||||||
echo "handoff markdown is missing current sha256 for: $file" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
done || missing=1
|
|
||||||
|
|
||||||
[ "$missing" -eq 0 ]
|
|
||||||
}
|
|
||||||
|
|
||||||
context_compression_mode() {
|
|
||||||
local mode
|
|
||||||
mode=$(yaml_field_value "context_compression" 2>/dev/null || true)
|
|
||||||
printf '%s\n' "${mode:-off}"
|
|
||||||
}
|
|
||||||
|
|
||||||
beta_spec_json_structurally_valid() {
|
|
||||||
local context missing=0
|
|
||||||
if [ "$(context_compression_mode)" != "beta" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
context=$(yaml_field_value "handoff_context" 2>/dev/null || true)
|
|
||||||
if [ -z "$context" ] || [ "$context" = "null" ]; then
|
|
||||||
echo "handoff_context is missing from .comet.yaml" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ! -s "$context" ]; then
|
|
||||||
echo "spec-context.json is missing or empty: $context" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Validate required JSON fields
|
|
||||||
grep -q '"change"' "$context" || { echo "spec-context.json missing 'change' field" >&2; return 1; }
|
|
||||||
grep -q '"phase"' "$context" || { echo "spec-context.json missing 'phase' field" >&2; return 1; }
|
|
||||||
grep -q '"mode": "beta"' "$context" || { echo "spec-context.json mode is not beta" >&2; return 1; }
|
|
||||||
grep -q '"files"' "$context" || { echo "spec-context.json missing 'files' field" >&2; return 1; }
|
|
||||||
grep -q '"context_hash"' "$context" || { echo "spec-context.json missing 'context_hash' field" >&2; return 1; }
|
|
||||||
|
|
||||||
# Verify all source files are referenced in the JSON
|
|
||||||
handoff_source_files | while IFS= read -r file; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
if ! grep -qF "$file" "$context"; then
|
|
||||||
echo "spec-context.json missing source file reference: $file" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
done || missing=1
|
|
||||||
|
|
||||||
[ "$missing" -eq 0 ]
|
|
||||||
}
|
|
||||||
|
|
||||||
design_doc_frontmatter_has() {
|
|
||||||
local design_doc="$1"
|
|
||||||
local field="$2"
|
|
||||||
local expected="$3"
|
|
||||||
awk '
|
|
||||||
{
|
|
||||||
line = $0
|
|
||||||
sub(/^\357\273\277/, "", line)
|
|
||||||
}
|
|
||||||
!in_fm && line == "---" { in_fm = 1; next }
|
|
||||||
in_fm && line == "---" { exit }
|
|
||||||
in_fm { print line }
|
|
||||||
' "$design_doc" | grep -Eq "^${field}: ['\"]?${expected}['\"]?[[:space:]]*$"
|
|
||||||
}
|
|
||||||
|
|
||||||
design_doc_links_current_change() {
|
|
||||||
local design_doc
|
|
||||||
design_doc=$(yaml_field_value "design_doc" 2>/dev/null || true)
|
|
||||||
if [ -z "$design_doc" ] || [ "$design_doc" = "null" ] || [ ! -s "$design_doc" ]; then
|
|
||||||
echo "design_doc must point to an existing Superpowers Design Doc before leaving design." >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
design_doc_frontmatter_has "$design_doc" "comet_change" "$CHANGE"
|
|
||||||
}
|
|
||||||
|
|
||||||
design_doc_declares_technical_role() {
|
|
||||||
local design_doc
|
|
||||||
design_doc=$(yaml_field_value "design_doc" 2>/dev/null || true)
|
|
||||||
[ -n "$design_doc" ] && [ "$design_doc" != "null" ] && [ -s "$design_doc" ] &&
|
|
||||||
design_doc_frontmatter_has "$design_doc" "role" "technical-design"
|
|
||||||
}
|
|
||||||
|
|
||||||
design_doc_declares_canonical_spec() {
|
|
||||||
local design_doc
|
|
||||||
design_doc=$(yaml_field_value "design_doc" 2>/dev/null || true)
|
|
||||||
[ -n "$design_doc" ] && [ "$design_doc" != "null" ] && [ -s "$design_doc" ] &&
|
|
||||||
design_doc_frontmatter_has "$design_doc" "canonical_spec" "openspec"
|
|
||||||
}
|
|
||||||
|
|
||||||
archived_is_true() {
|
|
||||||
local val
|
|
||||||
val=$(yaml_field_value "archived" 2>/dev/null || true)
|
|
||||||
[ "$val" = "true" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Phase-specific checks ---
|
|
||||||
|
|
||||||
guard_open() {
|
|
||||||
echo "=== Guard: open → next ===" >&2
|
|
||||||
|
|
||||||
local workflow
|
|
||||||
workflow=$(yaml_field_value "workflow" 2>/dev/null || true)
|
|
||||||
|
|
||||||
check "proposal.md exists and non-empty" file_nonempty "$CHANGE_DIR/proposal.md"
|
|
||||||
if [ "$workflow" = "full" ]; then
|
|
||||||
check "design.md exists and non-empty" file_nonempty "$CHANGE_DIR/design.md"
|
|
||||||
fi
|
|
||||||
check "tasks.md exists and non-empty" file_nonempty "$CHANGE_DIR/tasks.md"
|
|
||||||
check "tasks.md has at least one task" tasks_has_any
|
|
||||||
}
|
|
||||||
|
|
||||||
guard_design() {
|
|
||||||
echo "=== Guard: design → build ===" >&2
|
|
||||||
|
|
||||||
local design_doc workflow
|
|
||||||
design_doc=$(yaml_field_value "design_doc" 2>/dev/null || true)
|
|
||||||
workflow=$(yaml_field_value "workflow" 2>/dev/null || true)
|
|
||||||
|
|
||||||
check "proposal.md exists" file_nonempty "$CHANGE_DIR/proposal.md"
|
|
||||||
check "design.md exists" file_nonempty "$CHANGE_DIR/design.md"
|
|
||||||
check "tasks.md exists" file_nonempty "$CHANGE_DIR/tasks.md"
|
|
||||||
check "design handoff context exists" design_handoff_context_valid
|
|
||||||
check "design handoff markdown is traceable" design_handoff_markdown_traceable
|
|
||||||
if [ "$(context_compression_mode)" = "beta" ]; then
|
|
||||||
check "beta spec-context.json is structurally valid" beta_spec_json_structurally_valid
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$workflow" = "full" ]; then
|
|
||||||
# Full workflow: design_doc is REQUIRED
|
|
||||||
check "design_doc is recorded for full workflow" design_doc_recorded
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$design_doc" ] && [ "$design_doc" != "null" ]; then
|
|
||||||
check "Design Doc ($design_doc) exists" file_nonempty "$design_doc"
|
|
||||||
check "Design Doc frontmatter links current change" design_doc_links_current_change
|
|
||||||
check "Design Doc declares technical design role" design_doc_declares_technical_role
|
|
||||||
check "Design Doc declares OpenSpec as canonical spec" design_doc_declares_canonical_spec
|
|
||||||
elif [ "$workflow" != "full" ]; then
|
|
||||||
warn " [WARN] No design_doc recorded in .comet.yaml (optional for hotfix/tweak)"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
design_doc_recorded() {
|
|
||||||
local design_doc
|
|
||||||
design_doc=$(yaml_field_value "design_doc" 2>/dev/null || true)
|
|
||||||
if [ -n "$design_doc" ] && [ "$design_doc" != "null" ] && [ -f "$design_doc" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
echo "design_doc must point to an existing Superpowers Design Doc for full workflow before leaving design." >&2
|
|
||||||
echo "Next: create the Design Doc and run: \"\$COMET_BASH\" \"\$COMET_STATE\" set $CHANGE design_doc <path>" >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
guard_build() {
|
|
||||||
echo "=== Guard: build → verify ===" >&2
|
|
||||||
|
|
||||||
check "isolation selected" isolation_selected
|
|
||||||
check "build_mode selected" build_mode_selected
|
|
||||||
check "build_mode allowed for workflow" build_mode_allowed_for_workflow
|
|
||||||
check "subagent dispatch confirmed" subagent_dispatch_confirmed
|
|
||||||
check "tdd_mode selected" tdd_mode_selected
|
|
||||||
check "review_mode selected" review_mode_selected
|
|
||||||
check "tasks.md all tasks checked" tasks_all_done
|
|
||||||
check "Superpowers plan all tasks checked" plan_tasks_all_done
|
|
||||||
check "proposal.md exists" file_nonempty "$CHANGE_DIR/proposal.md"
|
|
||||||
check "Build passes" build_passes
|
|
||||||
}
|
|
||||||
|
|
||||||
guard_verify() {
|
|
||||||
echo "=== Guard: verify → archive ===" >&2
|
|
||||||
|
|
||||||
check "tasks.md all tasks checked" tasks_all_done
|
|
||||||
check "Build passes" verification_command_passes
|
|
||||||
check "verification_report exists" verification_report_exists
|
|
||||||
check "branch_status=handled" branch_status_handled
|
|
||||||
}
|
|
||||||
|
|
||||||
guard_archive() {
|
|
||||||
echo "=== Guard: archive completeness ===" >&2
|
|
||||||
|
|
||||||
check "archived is true" archived_is_true
|
|
||||||
check "proposal.md exists" file_nonempty "$CHANGE_DIR/proposal.md"
|
|
||||||
check "design.md exists" file_nonempty "$CHANGE_DIR/design.md"
|
|
||||||
check "tasks.md all tasks checked" tasks_all_done
|
|
||||||
}
|
|
||||||
|
|
||||||
apply_state_update() {
|
|
||||||
local state_sh="$SCRIPT_DIR/comet-state.sh"
|
|
||||||
local p="$1"
|
|
||||||
|
|
||||||
if [ -f "$state_sh" ]; then
|
|
||||||
case "$p" in
|
|
||||||
open) "$COMET_BASH" "$state_sh" transition "$CHANGE" open-complete ;;
|
|
||||||
design) "$COMET_BASH" "$state_sh" transition "$CHANGE" design-complete ;;
|
|
||||||
build) "$COMET_BASH" "$state_sh" transition "$CHANGE" build-complete ;;
|
|
||||||
verify) "$COMET_BASH" "$state_sh" transition "$CHANGE" verify-pass ;;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
red "FATAL: comet-state.sh not found; cannot apply state transition"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Main ---
|
|
||||||
|
|
||||||
if [ "${COMET_GUARD_SOURCE_ONLY:-0}" = "1" ]; then
|
|
||||||
return 0 2>/dev/null
|
|
||||||
# shellcheck disable=SC2317 # unreachable if sourced; fallback for direct execution
|
|
||||||
red "ERROR: COMET_GUARD_SOURCE_ONLY=1 is only for sourcing, not direct execution" >&2
|
|
||||||
# shellcheck disable=SC2317
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$PHASE" in
|
|
||||||
open) preflight ; guard_open ;;
|
|
||||||
design) preflight ; guard_design ;;
|
|
||||||
build) preflight ; guard_build ;;
|
|
||||||
verify) preflight ; guard_verify ;;
|
|
||||||
archive) preflight ; guard_archive ;;
|
|
||||||
*)
|
|
||||||
red "Unknown phase: $PHASE"
|
|
||||||
echo "Valid phases: open, design, build, verify, archive" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ "$BLOCK" -eq 1 ]; then
|
|
||||||
echo "" >&2
|
|
||||||
red "BLOCKED — fix failing checks before proceeding to next phase"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "" >&2
|
|
||||||
green "ALL CHECKS PASSED — ready for next phase"
|
|
||||||
if [ "$APPLY" -eq 1 ]; then
|
|
||||||
apply_state_update "$PHASE"
|
|
||||||
case "$PHASE" in
|
|
||||||
open)
|
|
||||||
new_phase=$(yaml_field_value "phase")
|
|
||||||
green " [APPLY] .comet.yaml updated: phase=$new_phase"
|
|
||||||
;;
|
|
||||||
design) green " [APPLY] .comet.yaml updated: phase=build" ;;
|
|
||||||
build) green " [APPLY] .comet.yaml updated: phase=verify, verify_result=pending" ;;
|
|
||||||
verify) green " [APPLY] .comet.yaml updated: phase=archive, verify_result=pass" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
@ -1,390 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Comet Handoff — creates machine-owned context packages between phases
|
|
||||||
# Usage: comet-handoff.sh <change-name> design --write [--full]
|
|
||||||
# comet-handoff.sh <change-name> --hash-only
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
COMET_BASH="${COMET_BASH:-${BASH:-bash}}"
|
|
||||||
|
|
||||||
red() { echo -e "\033[31m$1\033[0m" >&2; }
|
|
||||||
green() { echo -e "\033[32m$1\033[0m" >&2; }
|
|
||||||
warn() { echo -e "\033[33m$1\033[0m" >&2; }
|
|
||||||
|
|
||||||
validate_change_name() {
|
|
||||||
local name="$1"
|
|
||||||
if [ -z "$name" ]; then
|
|
||||||
red "ERROR: Change name cannot be empty"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ ! "$name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
|
||||||
red "ERROR: Invalid change name: '$name'"
|
|
||||||
red "Valid characters: a-z, A-Z, 0-9, -, _"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ "$name" =~ \.\. ]]; then
|
|
||||||
red "ERROR: Change name cannot contain '..' (path traversal not allowed)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_wrapping_quotes() {
|
|
||||||
local value="$1"
|
|
||||||
case "$value" in
|
|
||||||
\"*\") printf '%s\n' "${value:1:${#value}-2}" ;;
|
|
||||||
\'*\') printf '%s\n' "${value:1:${#value}-2}" ;;
|
|
||||||
*) printf '%s\n' "$value" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_inline_comment() {
|
|
||||||
local value="$1"
|
|
||||||
printf '%s\n' "$value" | awk -v squote="'" '
|
|
||||||
{
|
|
||||||
out = ""
|
|
||||||
quote = ""
|
|
||||||
for (i = 1; i <= length($0); i++) {
|
|
||||||
c = substr($0, i, 1)
|
|
||||||
if (quote == "") {
|
|
||||||
if (c == "\"" || c == squote) {
|
|
||||||
quote = c
|
|
||||||
} else if (c == "#" && (i == 1 || substr($0, i - 1, 1) ~ /[[:space:]]/)) {
|
|
||||||
sub(/[[:space:]]+$/, "", out)
|
|
||||||
print out
|
|
||||||
next
|
|
||||||
}
|
|
||||||
} else if (c == quote) {
|
|
||||||
quote = ""
|
|
||||||
}
|
|
||||||
out = out c
|
|
||||||
}
|
|
||||||
print out
|
|
||||||
}
|
|
||||||
'
|
|
||||||
}
|
|
||||||
|
|
||||||
yaml_field_value() {
|
|
||||||
local field="$1"
|
|
||||||
local yaml="$CHANGE_DIR/.comet.yaml"
|
|
||||||
local value
|
|
||||||
value=$(grep "^${field}:" "$yaml" 2>/dev/null | sed "s/^${field}: *//" || true)
|
|
||||||
value=$(strip_inline_comment "$value")
|
|
||||||
strip_wrapping_quotes "$value"
|
|
||||||
}
|
|
||||||
|
|
||||||
hash_stream() {
|
|
||||||
if command -v sha256sum >/dev/null 2>&1; then
|
|
||||||
sha256sum | awk '{print $1}'
|
|
||||||
elif command -v shasum >/dev/null 2>&1; then
|
|
||||||
shasum -a 256 | awk '{print $1}'
|
|
||||||
else
|
|
||||||
red "ERROR: sha256sum or shasum is required"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
hash_file() {
|
|
||||||
local file="$1"
|
|
||||||
if command -v sha256sum >/dev/null 2>&1; then
|
|
||||||
sha256sum "$file" | awk '{print $1}'
|
|
||||||
elif command -v shasum >/dev/null 2>&1; then
|
|
||||||
shasum -a 256 "$file" | awk '{print $1}'
|
|
||||||
else
|
|
||||||
red "ERROR: sha256sum or shasum is required"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
source_files() {
|
|
||||||
printf '%s\n' "$CHANGE_DIR/proposal.md"
|
|
||||||
printf '%s\n' "$CHANGE_DIR/design.md"
|
|
||||||
printf '%s\n' "$CHANGE_DIR/tasks.md"
|
|
||||||
if [ -d "$CHANGE_DIR/specs" ]; then
|
|
||||||
find "$CHANGE_DIR/specs" -path '*/spec.md' -type f 2>/dev/null | sort
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
compute_context_hash() {
|
|
||||||
local hash_input
|
|
||||||
hash_input=$(source_files | while IFS= read -r file; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
printf 'path:%s\n' "$file"
|
|
||||||
printf 'sha256:%s\n' "$(hash_file "$file")"
|
|
||||||
fi
|
|
||||||
done)
|
|
||||||
printf '%s' "$hash_input" | hash_stream
|
|
||||||
}
|
|
||||||
|
|
||||||
json_escape() {
|
|
||||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
file_line_count() {
|
|
||||||
local file="$1"
|
|
||||||
wc -l < "$file" | tr -d ' '
|
|
||||||
}
|
|
||||||
|
|
||||||
write_file_excerpt() {
|
|
||||||
local file="$1"
|
|
||||||
local max_lines="$2"
|
|
||||||
local total_lines
|
|
||||||
total_lines=$(file_line_count "$file")
|
|
||||||
|
|
||||||
echo "## $file"
|
|
||||||
echo ""
|
|
||||||
echo "- Source: $file"
|
|
||||||
echo "- Lines: 1-$total_lines"
|
|
||||||
echo "- SHA256: $(hash_file "$file")"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
if [ "$HANDOFF_MODE" = "full" ] || [ "$total_lines" -le "$max_lines" ]; then
|
|
||||||
echo '```md'
|
|
||||||
cat "$file"
|
|
||||||
echo '```'
|
|
||||||
else
|
|
||||||
echo "[TRUNCATED]"
|
|
||||||
echo ""
|
|
||||||
echo '```md'
|
|
||||||
sed -n "1,${max_lines}p" "$file"
|
|
||||||
echo '```'
|
|
||||||
echo ""
|
|
||||||
echo "Full source: $file"
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
write_markdown_context() {
|
|
||||||
local output="$1"
|
|
||||||
{
|
|
||||||
echo "# Comet Design Handoff"
|
|
||||||
echo ""
|
|
||||||
echo "- Change: $CHANGE"
|
|
||||||
echo "- Phase: design"
|
|
||||||
echo "- Mode: $HANDOFF_MODE"
|
|
||||||
echo "- Context hash: $CONTEXT_HASH"
|
|
||||||
echo ""
|
|
||||||
echo "Generated-by: comet-handoff.sh"
|
|
||||||
echo ""
|
|
||||||
echo "OpenSpec remains the canonical capability spec. This handoff is a deterministic, source-traceable context pack, not an agent-authored summary."
|
|
||||||
echo ""
|
|
||||||
source_files | while IFS= read -r file; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
write_file_excerpt "$file" 80
|
|
||||||
done
|
|
||||||
} > "$output"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_json_context() {
|
|
||||||
local output="$1"
|
|
||||||
{
|
|
||||||
echo "{"
|
|
||||||
echo " \"change\": \"$(json_escape "$CHANGE")\","
|
|
||||||
echo " \"phase\": \"design\","
|
|
||||||
echo " \"mode\": \"$HANDOFF_MODE\","
|
|
||||||
echo " \"canonical_spec\": \"openspec\","
|
|
||||||
echo " \"generated_by\": \"comet-handoff.sh\","
|
|
||||||
echo " \"context_hash\": \"$CONTEXT_HASH\","
|
|
||||||
echo " \"files\": ["
|
|
||||||
local first=1
|
|
||||||
while IFS= read -r file; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
if [ "$first" -eq 0 ]; then
|
|
||||||
echo ","
|
|
||||||
fi
|
|
||||||
first=0
|
|
||||||
printf ' { "path": "%s", "sha256": "%s" }' "$(json_escape "$file")" "$(hash_file "$file")"
|
|
||||||
done < <(source_files)
|
|
||||||
echo ""
|
|
||||||
echo " ]"
|
|
||||||
echo "}"
|
|
||||||
} > "$output"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_spec_projection_for_file() {
|
|
||||||
local file="$1"
|
|
||||||
echo "## $file"
|
|
||||||
echo ""
|
|
||||||
echo "- Source: $file"
|
|
||||||
echo "- Lines: 1-$(file_line_count "$file")"
|
|
||||||
echo "- SHA256: $(hash_file "$file")"
|
|
||||||
echo ""
|
|
||||||
echo '```md'
|
|
||||||
cat "$file"
|
|
||||||
echo '```'
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
write_spec_markdown_context() {
|
|
||||||
local output="$1"
|
|
||||||
{
|
|
||||||
echo "# Comet Spec Context"
|
|
||||||
echo ""
|
|
||||||
echo "- Change: $CHANGE"
|
|
||||||
echo "- Phase: design"
|
|
||||||
echo "- Mode: beta"
|
|
||||||
echo "- Context hash: $CONTEXT_HASH"
|
|
||||||
echo ""
|
|
||||||
echo "Generated-by: comet-handoff.sh"
|
|
||||||
echo ""
|
|
||||||
echo "OpenSpec remains the canonical capability spec. This beta context pack verbatim-projects spec files and references supporting artifacts by hash, not an agent-authored summary."
|
|
||||||
echo ""
|
|
||||||
echo "## Source References"
|
|
||||||
echo ""
|
|
||||||
source_files | while IFS= read -r file; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
echo "- Source: $file"
|
|
||||||
echo "- SHA256: $(hash_file "$file")"
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
echo "## Acceptance Projection"
|
|
||||||
echo ""
|
|
||||||
if [ -d "$CHANGE_DIR/specs" ]; then
|
|
||||||
find "$CHANGE_DIR/specs" -path '*/spec.md' -type f 2>/dev/null | sort | while IFS= read -r file; do
|
|
||||||
write_spec_projection_for_file "$file"
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "No delta spec files found."
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
echo "Full source files remain canonical. If a required heading or scenario is missing here, regenerate the handoff or read the source spec directly. Supporting files (proposal, design, tasks) are referenced by hash only."
|
|
||||||
} > "$output"
|
|
||||||
}
|
|
||||||
|
|
||||||
write_spec_json_context() {
|
|
||||||
local output="$1"
|
|
||||||
{
|
|
||||||
echo "{"
|
|
||||||
echo " \"change\": \"$(json_escape "$CHANGE")\","
|
|
||||||
echo " \"phase\": \"design\","
|
|
||||||
echo " \"mode\": \"beta\","
|
|
||||||
echo " \"canonical_spec\": \"openspec\","
|
|
||||||
echo " \"generated_by\": \"comet-handoff.sh\","
|
|
||||||
echo " \"context_hash\": \"$CONTEXT_HASH\","
|
|
||||||
echo " \"files\": ["
|
|
||||||
local first_file=1
|
|
||||||
while IFS= read -r file; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
local role="supporting"
|
|
||||||
case "$file" in
|
|
||||||
*/specs/*/spec.md) role="spec" ;;
|
|
||||||
esac
|
|
||||||
if [ "$first_file" -eq 0 ]; then
|
|
||||||
echo ","
|
|
||||||
fi
|
|
||||||
first_file=0
|
|
||||||
printf ' { "path": "%s", "sha256": "%s", "role": "%s" }' "$(json_escape "$file")" "$(hash_file "$file")" "$role"
|
|
||||||
done < <(source_files)
|
|
||||||
echo ""
|
|
||||||
echo " ]"
|
|
||||||
echo "}"
|
|
||||||
} > "$output"
|
|
||||||
}
|
|
||||||
|
|
||||||
CHANGE="${1:-}"
|
|
||||||
PHASE="${2:-}"
|
|
||||||
MODE="${3:-}"
|
|
||||||
FULL_FLAG="${4:-}"
|
|
||||||
|
|
||||||
validate_change_name "$CHANGE"
|
|
||||||
|
|
||||||
# --hash-only: compute and output context hash without generating handoff files
|
|
||||||
if [ "${PHASE:-}" = "--hash-only" ]; then
|
|
||||||
CHANGE_DIR="openspec/changes/$CHANGE"
|
|
||||||
if [ ! -d "$CHANGE_DIR" ]; then
|
|
||||||
red "ERROR: change directory not found: $CHANGE_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
for required in proposal.md design.md tasks.md; do
|
|
||||||
if [ ! -s "$CHANGE_DIR/$required" ]; then
|
|
||||||
red "ERROR: required file missing or empty: $CHANGE_DIR/$required"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
CONTEXT_HASH="$(compute_context_hash)"
|
|
||||||
printf '%s
|
|
||||||
' "$CONTEXT_HASH"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PHASE" != "design" ] || [ "$MODE" != "--write" ]; then
|
|
||||||
red "Usage: comet-handoff.sh <change-name> design --write [--full]"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
case "$FULL_FLAG" in
|
|
||||||
"") HANDOFF_MODE="compact" ;;
|
|
||||||
--full) HANDOFF_MODE="full" ;;
|
|
||||||
*)
|
|
||||||
red "Usage: comet-handoff.sh <change-name> design --write [--full]"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CHANGE_DIR="openspec/changes/$CHANGE"
|
|
||||||
YAML="$CHANGE_DIR/.comet.yaml"
|
|
||||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0" 2>/dev/null || echo "$0")" 2>/dev/null || dirname "$0")"
|
|
||||||
STATE_SH="$SCRIPT_DIR/comet-state.sh"
|
|
||||||
|
|
||||||
if [ ! -d "$CHANGE_DIR" ]; then
|
|
||||||
red "ERROR: change directory not found: $CHANGE_DIR"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -f "$YAML" ]; then
|
|
||||||
red "ERROR: .comet.yaml not found at $YAML"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "$(yaml_field_value phase)" != "design" ]; then
|
|
||||||
red "ERROR: design handoff requires phase: design"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for required in proposal.md design.md tasks.md; do
|
|
||||||
if [ ! -s "$CHANGE_DIR/$required" ]; then
|
|
||||||
red "ERROR: required OpenSpec artifact missing or empty: $CHANGE_DIR/$required"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
HANDOFF_DIR="$CHANGE_DIR/.comet/handoff"
|
|
||||||
CONTEXT_COMPRESSION="$(yaml_field_value context_compression 2>/dev/null || true)"
|
|
||||||
CONTEXT_COMPRESSION="${CONTEXT_COMPRESSION:-off}"
|
|
||||||
case "$CONTEXT_COMPRESSION" in
|
|
||||||
off)
|
|
||||||
CONTEXT_JSON="$HANDOFF_DIR/design-context.json"
|
|
||||||
CONTEXT_MD="$HANDOFF_DIR/design-context.md"
|
|
||||||
;;
|
|
||||||
beta)
|
|
||||||
if [ "$HANDOFF_MODE" = "full" ]; then
|
|
||||||
warn "[HANDOFF] --full is ignored in beta mode; spec files are projected verbatim"
|
|
||||||
fi
|
|
||||||
HANDOFF_MODE="beta"
|
|
||||||
CONTEXT_JSON="$HANDOFF_DIR/spec-context.json"
|
|
||||||
CONTEXT_MD="$HANDOFF_DIR/spec-context.md"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
red "ERROR: invalid context_compression: $CONTEXT_COMPRESSION"
|
|
||||||
red "Valid values: off, beta"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
mkdir -p "$HANDOFF_DIR"
|
|
||||||
|
|
||||||
CONTEXT_HASH="$(compute_context_hash)"
|
|
||||||
if [ "$CONTEXT_COMPRESSION" = "beta" ]; then
|
|
||||||
write_spec_markdown_context "$CONTEXT_MD"
|
|
||||||
write_spec_json_context "$CONTEXT_JSON"
|
|
||||||
else
|
|
||||||
write_markdown_context "$CONTEXT_MD"
|
|
||||||
write_json_context "$CONTEXT_JSON"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -x "$STATE_SH" ] || [ -f "$STATE_SH" ]; then
|
|
||||||
"$COMET_BASH" "$STATE_SH" set "$CHANGE" handoff_context "$CONTEXT_JSON" >/dev/null
|
|
||||||
"$COMET_BASH" "$STATE_SH" set "$CHANGE" handoff_hash "$CONTEXT_HASH" >/dev/null
|
|
||||||
else
|
|
||||||
red "ERROR: comet-state.sh not found; cannot record handoff fields"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
green "[HANDOFF] wrote $CONTEXT_JSON"
|
|
||||||
green "[HANDOFF] wrote $CONTEXT_MD"
|
|
||||||
green "[HANDOFF] handoff_hash=$CONTEXT_HASH"
|
|
||||||
@ -1,336 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# comet-hook-guard.sh — PreToolUse hook for Comet phase enforcement
|
|
||||||
#
|
|
||||||
# Blocks file writes (Write/Edit) when the active Comet change is in
|
|
||||||
# a phase that does not allow source code modifications (open/design/archive).
|
|
||||||
#
|
|
||||||
# Usage (called by harness, not directly):
|
|
||||||
# PreToolUse matcher "Write|Edit" → this script
|
|
||||||
# Stdin: JSON {"tool_name":"Write|Edit","tool_input":{"file_path":"..."}}
|
|
||||||
# Exit 0 = allow
|
|
||||||
# Exit 2 = blocked (stderr message shown to user)
|
|
||||||
#
|
|
||||||
# Cross-platform: macOS / Linux / Windows Git Bash
|
|
||||||
# shellcheck disable=SC2329
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# ── Extract target file path ──────────────────────────────────────
|
|
||||||
|
|
||||||
TARGET=""
|
|
||||||
|
|
||||||
# Method 1: FILE_PATH environment variable (set by some harnesses)
|
|
||||||
if [ -n "${FILE_PATH:-}" ]; then
|
|
||||||
TARGET="$FILE_PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Method 2: Parse stdin JSON
|
|
||||||
if [ -z "$TARGET" ]; then
|
|
||||||
INPUT=""
|
|
||||||
if [ ! -t 0 ]; then
|
|
||||||
INPUT=$(cat 2>/dev/null || true)
|
|
||||||
fi
|
|
||||||
if [ -n "$INPUT" ]; then
|
|
||||||
# Extract file_path value — works for both Write and Edit tool inputs
|
|
||||||
TARGET=$(printf '%s' "$INPUT" \
|
|
||||||
| grep -oE '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' 2>/dev/null \
|
|
||||||
| head -1 \
|
|
||||||
| sed 's/^"file_path"[[:space:]]*:[[:space:]]*"//' \
|
|
||||||
| sed 's/"$//' \
|
|
||||||
|| true)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# No target found — allow (not a file-path-bearing operation)
|
|
||||||
if [ -z "$TARGET" ]; then
|
|
||||||
echo "[COMET-HOOK] allowed: no file path in tool input" >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Normalize to forward slashes, collapse doubles from JSON escaping (\\ → //)
|
|
||||||
TARGET=$(printf '%s' "$TARGET" | sed 's|\\|/|g' | sed 's|///*|/|g')
|
|
||||||
|
|
||||||
# ── Resolve to project-relative path ─────────────────────────────
|
|
||||||
|
|
||||||
# Normalize helper: forward slashes only
|
|
||||||
norm() { printf '%s' "$1" | sed 's|\\|/|g'; }
|
|
||||||
|
|
||||||
RELPATH=$(norm "$TARGET")
|
|
||||||
|
|
||||||
# If already relative, use as-is
|
|
||||||
case "$RELPATH" in
|
|
||||||
/*|[A-Za-z]:/*)
|
|
||||||
# Absolute — try stripping CWD prefixes
|
|
||||||
CWD_UNIX=$(norm "$(pwd)")
|
|
||||||
CWD_PHYS=$(norm "$(pwd -P 2>/dev/null || pwd)")
|
|
||||||
|
|
||||||
# Try: TARGET as-is vs CWD logical
|
|
||||||
if [ "${RELPATH#"$CWD_UNIX"/}" != "$RELPATH" ]; then
|
|
||||||
RELPATH="${RELPATH#"$CWD_UNIX"/}"
|
|
||||||
# Try: TARGET as-is vs CWD physical (macOS /var → /private/var)
|
|
||||||
elif [ "${RELPATH#"$CWD_PHYS"/}" != "$RELPATH" ]; then
|
|
||||||
RELPATH="${RELPATH#"$CWD_PHYS"/}"
|
|
||||||
else
|
|
||||||
# Resolve TARGET's parent through filesystem (handles symlinked TARGET path)
|
|
||||||
_PDIR=$(cd "$(dirname "$TARGET")" 2>/dev/null && pwd -P 2>/dev/null || true)
|
|
||||||
if [ -n "$_PDIR" ]; then
|
|
||||||
_TRESOLVED=$(norm "${_PDIR}/$(basename "$TARGET")")
|
|
||||||
if [ "${_TRESOLVED#"$CWD_UNIX"/}" != "$_TRESOLVED" ]; then
|
|
||||||
RELPATH="${_TRESOLVED#"$CWD_UNIX"/}"
|
|
||||||
elif [ "${_TRESOLVED#"$CWD_PHYS"/}" != "$_TRESOLVED" ]; then
|
|
||||||
RELPATH="${_TRESOLVED#"$CWD_PHYS"/}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ── Helpers to read .comet.yaml fields ───────────────────────────
|
|
||||||
|
|
||||||
is_archived() {
|
|
||||||
grep "^archived:" "$1" 2>/dev/null \
|
|
||||||
| awk '{print $2}' | tr -d '[:space:][:cntrl:]' || true
|
|
||||||
}
|
|
||||||
|
|
||||||
read_phase() {
|
|
||||||
grep "^phase:" "$1" 2>/dev/null \
|
|
||||||
| awk '{print $2}' | tr -d '[:space:][:cntrl:]' || true
|
|
||||||
}
|
|
||||||
|
|
||||||
read_field() {
|
|
||||||
grep "^$1:" "$2" 2>/dev/null \
|
|
||||||
| head -1 | awk '{print $2}' | tr -d '[:space:][:cntrl:]' || true
|
|
||||||
}
|
|
||||||
|
|
||||||
# ── Determine the governing Comet change + phase ─────────────────
|
|
||||||
#
|
|
||||||
# A write targeting a specific change directory (openspec/changes/<name>/...)
|
|
||||||
# must be governed by THAT change's own phase — never by an unrelated
|
|
||||||
# active change. Otherwise a change left in the `archive` phase would
|
|
||||||
# wrongly block artifact writes for a brand-new change created alongside it.
|
|
||||||
|
|
||||||
PHASE=""
|
|
||||||
# Path to the .comet.yaml that governs this write (used for deeper invariant checks)
|
|
||||||
GOV_YAML=""
|
|
||||||
|
|
||||||
case "$RELPATH" in
|
|
||||||
openspec/changes/*/*)
|
|
||||||
_rest="${RELPATH#openspec/changes/}"
|
|
||||||
_own_change="${_rest%%/*}"
|
|
||||||
if [ -n "$_own_change" ] && [ "$_own_change" != "archive" ]; then
|
|
||||||
_own_yaml="openspec/changes/${_own_change}/.comet.yaml"
|
|
||||||
if [ -f "$_own_yaml" ]; then
|
|
||||||
if [ "$(is_archived "$_own_yaml")" = "true" ]; then
|
|
||||||
# This change is already archived — its own writes are unrestricted
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (own change archived)" >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
PHASE=$(read_phase "$_own_yaml")
|
|
||||||
GOV_YAML="$_own_yaml"
|
|
||||||
else
|
|
||||||
# Change directory exists but state file not yet written
|
|
||||||
# (artifacts are created before .comet.yaml during /comet-open).
|
|
||||||
# Treat as `open` so proposal/design/tasks/specs are allowed.
|
|
||||||
PHASE="open"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Fallback: writes outside a specific change directory are governed by
|
|
||||||
# the first active (non-archived) change.
|
|
||||||
if [ -z "$PHASE" ]; then
|
|
||||||
YAML_FILE=""
|
|
||||||
if [ -d "openspec/changes" ]; then
|
|
||||||
for dir in openspec/changes/*/; do
|
|
||||||
[ -d "$dir" ] || continue
|
|
||||||
# Skip archived changes directory
|
|
||||||
case "$dir" in
|
|
||||||
*/archive/*) continue ;;
|
|
||||||
esac
|
|
||||||
if [ -f "${dir}.comet.yaml" ]; then
|
|
||||||
# Skip changes already marked as archived
|
|
||||||
if [ "$(is_archived "${dir}.comet.yaml")" = "true" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
YAML_FILE="${dir}.comet.yaml"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# No active change — allow all writes
|
|
||||||
if [ -z "$YAML_FILE" ]; then
|
|
||||||
echo "[COMET-HOOK] allowed: no active comet change" >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
PHASE=$(read_phase "$YAML_FILE")
|
|
||||||
GOV_YAML="$YAML_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$PHASE" ]; then
|
|
||||||
echo "[COMET-HOOK] allowed: no phase in .comet.yaml" >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Whitelist: phase-aware allowed paths ─────────────────────────
|
|
||||||
|
|
||||||
case "$RELPATH" in
|
|
||||||
openspec/*)
|
|
||||||
# OpenSpec artifacts — phase-aware sub-check
|
|
||||||
case "$PHASE" in
|
|
||||||
open)
|
|
||||||
# open: allow proposal, design, tasks, yaml, handoff, specs
|
|
||||||
case "$RELPATH" in
|
|
||||||
*/proposal.md|*/design.md|*/tasks.md|*/.openspec.yaml|*/.comet.yaml|*/.comet/*|*/specs/*)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: open, openspec artifacts)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
design)
|
|
||||||
# design: allow handoff, delta spec (Spec Patch), proposal/design/tasks (minor refinements), .comet.yaml
|
|
||||||
case "$RELPATH" in
|
|
||||||
*/proposal.md|*/design.md|*/tasks.md|*/.comet/*|*/specs/*|*/.comet.yaml|*/.openspec.yaml)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: design, handoff/spec)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
build)
|
|
||||||
# build: allow delta spec (incremental update), tasks, .comet.yaml
|
|
||||||
case "$RELPATH" in
|
|
||||||
*/specs/*|*/tasks.md|*/.comet.yaml|*/.openspec.yaml)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: build, spec/tasks)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
verify)
|
|
||||||
# verify: allow tasks (post-check), .comet.yaml
|
|
||||||
case "$RELPATH" in
|
|
||||||
*/tasks.md|*/.comet.yaml|*/.openspec.yaml)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: verify, tasks/state)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
archive)
|
|
||||||
# archive: allow .comet.yaml state updates only
|
|
||||||
case "$RELPATH" in
|
|
||||||
*/.comet.yaml|*/.openspec.yaml)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: archive, state)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
docs/superpowers/*)
|
|
||||||
# Superpowers artifacts — phase-aware sub-check
|
|
||||||
case "$PHASE" in
|
|
||||||
design)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: design, superpowers)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
build)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: build, superpowers)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
verify)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: verify, superpowers)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# open/archive: block docs/superpowers writes
|
|
||||||
;;
|
|
||||||
.comet/*|*/.comet/*)
|
|
||||||
# Comet config
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (whitelist: comet config)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
.claude/*)
|
|
||||||
# Claude settings/rules
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (whitelist: claude config)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
CLAUDE.md|CHANGELOG.md|README.md|*.md)
|
|
||||||
# Root-level markdown files
|
|
||||||
case "$RELPATH" in
|
|
||||||
*/*) ;; # subdirectory .md — NOT whitelisted, fall through
|
|
||||||
*)
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (whitelist: root markdown)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
.comet.yaml|comet.yaml|.comet.yml|comet.yml)
|
|
||||||
# Project-level comet config
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (whitelist: comet config)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ── Phase-based enforcement ──────────────────────────────────────
|
|
||||||
|
|
||||||
case "$PHASE" in
|
|
||||||
build|verify)
|
|
||||||
# Full workflow must have a Design Doc before any source write in build/verify.
|
|
||||||
# Catches illegal open→build / design→build jumps that skipped the design phase
|
|
||||||
# (e.g. misclassified preset, direct `set phase`, or bare transition).
|
|
||||||
if [ -n "$GOV_YAML" ]; then
|
|
||||||
_wf=$(read_field "workflow" "$GOV_YAML")
|
|
||||||
_dd=$(read_field "design_doc" "$GOV_YAML")
|
|
||||||
if [ "$_wf" = "full" ] && { [ -z "$_dd" ] || [ "$_dd" = "null" ]; }; then
|
|
||||||
echo "" >&2
|
|
||||||
echo "╔══════════════════════════════════════════╗" >&2
|
|
||||||
echo "║ COMET PHASE GUARD — WRITE BLOCKED ║" >&2
|
|
||||||
echo "╚══════════════════════════════════════════╝" >&2
|
|
||||||
echo "" >&2
|
|
||||||
echo " Current phase: $PHASE (workflow: full), but design_doc is empty" >&2
|
|
||||||
echo " Target file: $RELPATH" >&2
|
|
||||||
echo "" >&2
|
|
||||||
echo " ❌ Illegal phase jump detected: full workflow entered $PHASE without a Design Doc" >&2
|
|
||||||
echo " ✅ Correct flow: create the Design Doc in design phase, then run comet-guard design --apply" >&2
|
|
||||||
echo " 💡 Run /comet-design to fill the missing design; for repair, set design_doc with comet-state" >&2
|
|
||||||
echo "" >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Code writes allowed in build and verify
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: $PHASE)" >&2
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
open|design|archive)
|
|
||||||
echo "" >&2
|
|
||||||
echo "╔══════════════════════════════════════════╗" >&2
|
|
||||||
echo "║ COMET PHASE GUARD — WRITE BLOCKED ║" >&2
|
|
||||||
echo "╚══════════════════════════════════════════╝" >&2
|
|
||||||
echo "" >&2
|
|
||||||
echo " Current phase: $PHASE" >&2
|
|
||||||
echo " Target file: $RELPATH" >&2
|
|
||||||
echo "" >&2
|
|
||||||
case "$PHASE" in
|
|
||||||
open)
|
|
||||||
echo " ❌ open phase does not allow source code writes" >&2
|
|
||||||
echo " ✅ Allowed: create proposal/design/tasks and run guard" >&2
|
|
||||||
echo " 💡 After clarification and artifact creation, run guard --apply" >&2
|
|
||||||
;;
|
|
||||||
design)
|
|
||||||
echo " ❌ design phase does not allow source code writes" >&2
|
|
||||||
echo " ✅ Allowed: brainstorming, create the Design Doc, and run guard" >&2
|
|
||||||
echo " 💡 After the Design Doc is ready, run comet-guard design --apply to enter build" >&2
|
|
||||||
;;
|
|
||||||
archive)
|
|
||||||
echo " ❌ archive phase does not allow source code writes" >&2
|
|
||||||
echo " ✅ Allowed: confirm archive intent and run the archive script" >&2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo "" >&2
|
|
||||||
exit 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "[COMET-HOOK] allowed: $RELPATH (phase: $PHASE)" >&2
|
|
||||||
exit 0
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,225 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Comet YAML Schema Validator — validates .comet.yaml structure
|
|
||||||
# Usage: comet-yaml-validate.sh <change-name>
|
|
||||||
# Exit 0 = valid, exit 1 = errors found (printed to stderr)
|
|
||||||
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
red() { echo -e "\033[31m$1\033[0m" >&2; }
|
|
||||||
green() { echo -e "\033[32m$1\033[0m" >&2; }
|
|
||||||
warn() { echo -e "\033[33m$1\033[0m" >&2; }
|
|
||||||
|
|
||||||
# Input validation - prevent path traversal
|
|
||||||
validate_change_name() {
|
|
||||||
local name="$1"
|
|
||||||
# Reject empty names
|
|
||||||
if [ -z "$name" ]; then
|
|
||||||
red "ERROR: Change name cannot be empty" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Only allow alphanumeric, hyphens, and underscores
|
|
||||||
if [[ ! "$name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
|
|
||||||
red "ERROR: Invalid change name: '$name'" >&2
|
|
||||||
red "Valid characters: a-z, A-Z, 0-9, -, _" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Reject path traversal attempts
|
|
||||||
if [[ "$name" =~ \.\. ]]; then
|
|
||||||
red "ERROR: Change name cannot contain '..' (path traversal not allowed)" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_change_name "$1"
|
|
||||||
|
|
||||||
CHANGE="$1"
|
|
||||||
CHANGE_DIR="openspec/changes/$CHANGE"
|
|
||||||
if [ ! -d "$CHANGE_DIR" ] && [ -d "openspec/changes/archive/$CHANGE" ]; then
|
|
||||||
CHANGE_DIR="openspec/changes/archive/$CHANGE"
|
|
||||||
fi
|
|
||||||
YAML="$CHANGE_DIR/.comet.yaml"
|
|
||||||
|
|
||||||
ERRORS=0
|
|
||||||
WARNINGS=0
|
|
||||||
|
|
||||||
# Helper: get value of a top-level field (handles null, empty, quoted)
|
|
||||||
field_value() {
|
|
||||||
local value
|
|
||||||
value=$(grep "^${1}:" "$YAML" 2>/dev/null | sed "s/^${1}: *//" || true)
|
|
||||||
value=$(strip_inline_comment "$value")
|
|
||||||
strip_wrapping_quotes "$value"
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_inline_comment() {
|
|
||||||
local value="$1"
|
|
||||||
printf '%s\n' "$value" | awk -v squote="'" '
|
|
||||||
{
|
|
||||||
out = ""
|
|
||||||
quote = ""
|
|
||||||
for (i = 1; i <= length($0); i++) {
|
|
||||||
c = substr($0, i, 1)
|
|
||||||
if (quote == "") {
|
|
||||||
if (c == "\"" || c == squote) {
|
|
||||||
quote = c
|
|
||||||
} else if (c == "#" && (i == 1 || substr($0, i - 1, 1) ~ /[[:space:]]/)) {
|
|
||||||
sub(/[[:space:]]+$/, "", out)
|
|
||||||
print out
|
|
||||||
next
|
|
||||||
}
|
|
||||||
} else if (c == quote) {
|
|
||||||
quote = ""
|
|
||||||
}
|
|
||||||
out = out c
|
|
||||||
}
|
|
||||||
print out
|
|
||||||
}
|
|
||||||
'
|
|
||||||
}
|
|
||||||
|
|
||||||
strip_wrapping_quotes() {
|
|
||||||
local value="$1"
|
|
||||||
case "$value" in
|
|
||||||
\"*\")
|
|
||||||
printf '%s\n' "${value:1:${#value}-2}"
|
|
||||||
;;
|
|
||||||
\'*\')
|
|
||||||
printf '%s\n' "${value:1:${#value}-2}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
printf '%s\n' "$value"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
fail() { red " FAIL: $1"; ERRORS=$((ERRORS + 1)); }
|
|
||||||
warn_msg() { warn " WARN: $1"; WARNINGS=$((WARNINGS + 1)); }
|
|
||||||
|
|
||||||
echo "[VALIDATE] $YAML" >&2
|
|
||||||
|
|
||||||
# --- Required fields ---
|
|
||||||
REQUIRED_FIELDS="workflow phase design_doc plan build_mode isolation verify_mode verify_result verified_at archived"
|
|
||||||
for field in $REQUIRED_FIELDS; do
|
|
||||||
if ! grep -q "^${field}:" "$YAML" 2>/dev/null; then
|
|
||||||
fail "missing required field '$field'"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# --- Enum validation ---
|
|
||||||
validate_enum() {
|
|
||||||
local field="$1" value="$2"
|
|
||||||
shift 2
|
|
||||||
local valid_values="$*"
|
|
||||||
|
|
||||||
# null or empty is always acceptable
|
|
||||||
if [ -z "$value" ] || [ "$value" = "null" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
for v in $valid_values; do
|
|
||||||
if [ "$value" = "$v" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fail "$field='$value' is not valid. Expected: $valid_values"
|
|
||||||
}
|
|
||||||
|
|
||||||
validate_required_enum() {
|
|
||||||
local field="$1" value="$2"
|
|
||||||
shift 2
|
|
||||||
local valid_values="$*"
|
|
||||||
|
|
||||||
if [ -z "$value" ] || [ "$value" = "null" ]; then
|
|
||||||
fail "$field='${value:-}' is not valid. Expected: $valid_values"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
validate_enum "$field" "$value" "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
workflow=$(field_value "workflow")
|
|
||||||
phase=$(field_value "phase")
|
|
||||||
context_compression=$(field_value "context_compression")
|
|
||||||
build_mode=$(field_value "build_mode")
|
|
||||||
build_pause=$(field_value "build_pause")
|
|
||||||
subagent_dispatch=$(field_value "subagent_dispatch")
|
|
||||||
tdd_mode=$(field_value "tdd_mode")
|
|
||||||
review_mode=$(field_value "review_mode")
|
|
||||||
isolation=$(field_value "isolation")
|
|
||||||
verify_mode=$(field_value "verify_mode")
|
|
||||||
auto_transition=$(field_value "auto_transition")
|
|
||||||
verify_result=$(field_value "verify_result")
|
|
||||||
branch_status=$(field_value "branch_status")
|
|
||||||
archived=$(field_value "archived")
|
|
||||||
direct_override=$(field_value "direct_override")
|
|
||||||
design_doc=$(field_value "design_doc")
|
|
||||||
plan=$(field_value "plan")
|
|
||||||
handoff_context=$(field_value "handoff_context")
|
|
||||||
handoff_hash=$(field_value "handoff_hash")
|
|
||||||
|
|
||||||
validate_enum "workflow" "$workflow" "full hotfix tweak"
|
|
||||||
validate_enum "phase" "$phase" "open design build verify archive"
|
|
||||||
validate_enum "context_compression" "$context_compression" "off beta"
|
|
||||||
validate_enum "build_mode" "$build_mode" "subagent-driven-development executing-plans direct"
|
|
||||||
validate_enum "build_pause" "$build_pause" "null plan-ready"
|
|
||||||
validate_enum "subagent_dispatch" "$subagent_dispatch" "null confirmed"
|
|
||||||
validate_enum "tdd_mode" "$tdd_mode" "tdd direct null"
|
|
||||||
validate_enum "review_mode" "$review_mode" "off standard thorough"
|
|
||||||
validate_enum "isolation" "$isolation" "branch worktree"
|
|
||||||
validate_enum "verify_mode" "$verify_mode" "light full"
|
|
||||||
if grep -q "^auto_transition:" "$YAML" 2>/dev/null; then
|
|
||||||
validate_required_enum "auto_transition" "$auto_transition" "true false"
|
|
||||||
fi
|
|
||||||
validate_enum "verify_result" "$verify_result" "pending pass fail"
|
|
||||||
validate_enum "branch_status" "$branch_status" "pending handled"
|
|
||||||
validate_enum "archived" "$archived" "true false"
|
|
||||||
validate_enum "direct_override" "$direct_override" "true false"
|
|
||||||
|
|
||||||
# --- Path validation ---
|
|
||||||
|
|
||||||
if [ -n "$design_doc" ] && [ "$design_doc" != "null" ]; then
|
|
||||||
if [ ! -f "$design_doc" ]; then
|
|
||||||
fail "design_doc='$design_doc' does not exist on disk"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$plan" ] && [ "$plan" != "null" ]; then
|
|
||||||
if [ ! -f "$plan" ]; then
|
|
||||||
fail "plan='$plan' does not exist on disk"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$handoff_context" ] && [ "$handoff_context" != "null" ]; then
|
|
||||||
if [ ! -f "$handoff_context" ]; then
|
|
||||||
fail "handoff_context='$handoff_context' does not exist on disk"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$handoff_hash" ] && [ "$handoff_hash" != "null" ]; then
|
|
||||||
if [[ ! "$handoff_hash" =~ ^[a-f0-9]{64}$ ]]; then
|
|
||||||
fail "handoff_hash='$handoff_hash' is not a sha256 hex digest"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Unknown keys check ---
|
|
||||||
KNOWN_KEYS="workflow phase context_compression design_doc plan build_mode build_pause subagent_dispatch tdd_mode review_mode isolation verify_mode auto_transition verify_result verification_report branch_status verified_at created_at archived direct_override build_command verify_command handoff_context handoff_hash base_ref"
|
|
||||||
while IFS=: read -r key _; do
|
|
||||||
key="${key// /}"
|
|
||||||
[ -z "$key" ] && continue
|
|
||||||
found=0
|
|
||||||
for known in $KNOWN_KEYS; do
|
|
||||||
[ "$key" = "$known" ] && found=1 && break
|
|
||||||
done
|
|
||||||
if [ "$found" -eq 0 ]; then
|
|
||||||
warn_msg "unknown field '$key' found"
|
|
||||||
fi
|
|
||||||
done < "$YAML"
|
|
||||||
|
|
||||||
# --- Summary ---
|
|
||||||
echo "" >&2
|
|
||||||
if [ "$ERRORS" -gt 0 ]; then
|
|
||||||
red "$ERRORS error(s), $WARNINGS warning(s) — validation FAILED"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
green "0 errors, $WARNINGS warning(s) — validation PASSED"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
@ -1,159 +0,0 @@
|
|||||||
---
|
|
||||||
name: openspec-apply-change
|
|
||||||
description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
|
|
||||||
license: MIT
|
|
||||||
compatibility: Requires openspec CLI.
|
|
||||||
metadata:
|
|
||||||
author: openspec
|
|
||||||
version: "1.0"
|
|
||||||
generatedBy: "1.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
Implement tasks from an OpenSpec change.
|
|
||||||
|
|
||||||
**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. **Select the change**
|
|
||||||
|
|
||||||
If a name is provided, use it. Otherwise:
|
|
||||||
- Infer from conversation context if the user mentioned a change
|
|
||||||
- Auto-select if only one active change exists
|
|
||||||
- If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
|
|
||||||
|
|
||||||
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
|
|
||||||
|
|
||||||
2. **Check status to understand the schema**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to understand:
|
|
||||||
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
||||||
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
|
|
||||||
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
||||||
|
|
||||||
3. **Get apply instructions**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openspec instructions apply --change "<name>" --json
|
|
||||||
```
|
|
||||||
|
|
||||||
This returns:
|
|
||||||
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
|
|
||||||
- Progress (total, complete, remaining)
|
|
||||||
- Task list with status
|
|
||||||
- Dynamic instruction based on current state
|
|
||||||
|
|
||||||
**Handle states:**
|
|
||||||
- If `state: "blocked"` (missing artifacts): show message, suggest using openspec-continue-change
|
|
||||||
- If `state: "all_done"`: congratulate, suggest archive
|
|
||||||
- Otherwise: proceed to implementation
|
|
||||||
|
|
||||||
**Workspace guard:** If status JSON reports `actionContext.mode: "workspace-planning"` and `allowedEditRoots` is empty, explain that full workspace apply is not supported in this slice. Treat linked repos and folders as read-only context, ask the user to select an affected area through an explicit implementation workflow, and STOP before editing files.
|
|
||||||
|
|
||||||
4. **Read context files**
|
|
||||||
|
|
||||||
Read every file path listed under `contextFiles` from the apply instructions output.
|
|
||||||
The files depend on the schema being used:
|
|
||||||
- **spec-driven**: proposal, specs, design, tasks
|
|
||||||
- Other schemas: follow the contextFiles from CLI output
|
|
||||||
|
|
||||||
5. **Show current progress**
|
|
||||||
|
|
||||||
Display:
|
|
||||||
- Schema being used
|
|
||||||
- Progress: "N/M tasks complete"
|
|
||||||
- Remaining tasks overview
|
|
||||||
- Dynamic instruction from CLI
|
|
||||||
|
|
||||||
6. **Implement tasks (loop until done or blocked)**
|
|
||||||
|
|
||||||
For each pending task:
|
|
||||||
- Show which task is being worked on
|
|
||||||
- Make the code changes required
|
|
||||||
- Keep changes minimal and focused
|
|
||||||
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
|
|
||||||
- Continue to next task
|
|
||||||
|
|
||||||
**Pause if:**
|
|
||||||
- Task is unclear → ask for clarification
|
|
||||||
- Implementation reveals a design issue → suggest updating artifacts
|
|
||||||
- Error or blocker encountered → report and wait for guidance
|
|
||||||
- User interrupts
|
|
||||||
|
|
||||||
7. **On completion or pause, show status**
|
|
||||||
|
|
||||||
Display:
|
|
||||||
- Tasks completed this session
|
|
||||||
- Overall progress: "N/M tasks complete"
|
|
||||||
- If all done: suggest archive
|
|
||||||
- If paused: explain why and wait for guidance
|
|
||||||
|
|
||||||
**Output During Implementation**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Implementing: <change-name> (schema: <schema-name>)
|
|
||||||
|
|
||||||
Working on task 3/7: <task description>
|
|
||||||
[...implementation happening...]
|
|
||||||
✓ Task complete
|
|
||||||
|
|
||||||
Working on task 4/7: <task description>
|
|
||||||
[...implementation happening...]
|
|
||||||
✓ Task complete
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Completion**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Implementation Complete
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Progress:** 7/7 tasks complete ✓
|
|
||||||
|
|
||||||
### Completed This Session
|
|
||||||
- [x] Task 1
|
|
||||||
- [x] Task 2
|
|
||||||
...
|
|
||||||
|
|
||||||
All tasks complete! Ready to archive this change.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output On Pause (Issue Encountered)**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Implementation Paused
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Progress:** 4/7 tasks complete
|
|
||||||
|
|
||||||
### Issue Encountered
|
|
||||||
<description of the issue>
|
|
||||||
|
|
||||||
**Options:**
|
|
||||||
1. <option 1>
|
|
||||||
2. <option 2>
|
|
||||||
3. Other approach
|
|
||||||
|
|
||||||
What would you like to do?
|
|
||||||
```
|
|
||||||
|
|
||||||
**Guardrails**
|
|
||||||
- Keep going through tasks until done or blocked
|
|
||||||
- Always read context files before starting (from the apply instructions output)
|
|
||||||
- If task is ambiguous, pause and ask before implementing
|
|
||||||
- If implementation reveals issues, pause and suggest artifact updates
|
|
||||||
- Keep code changes minimal and scoped to each task
|
|
||||||
- Update task checkbox immediately after completing each task
|
|
||||||
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
||||||
- Use contextFiles from CLI output, don't assume specific file names
|
|
||||||
|
|
||||||
**Fluid Workflow Integration**
|
|
||||||
|
|
||||||
This skill supports the "actions on a change" model:
|
|
||||||
|
|
||||||
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
||||||
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
|
|
||||||
@ -1,117 +0,0 @@
|
|||||||
---
|
|
||||||
name: openspec-archive-change
|
|
||||||
description: Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
|
|
||||||
license: MIT
|
|
||||||
compatibility: Requires openspec CLI.
|
|
||||||
metadata:
|
|
||||||
author: openspec
|
|
||||||
version: "1.0"
|
|
||||||
generatedBy: "1.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
Archive a completed change in the experimental workflow.
|
|
||||||
|
|
||||||
**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 only active changes (not already archived).
|
|
||||||
Include the schema used for each change if available.
|
|
||||||
|
|
||||||
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
||||||
|
|
||||||
2. **Check artifact completion status**
|
|
||||||
|
|
||||||
Run `openspec status --change "<name>" --json` to check artifact completion.
|
|
||||||
|
|
||||||
Parse the JSON to understand:
|
|
||||||
- `schemaName`: The workflow being used
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
|
||||||
- `artifacts`: List of artifacts with their status (`done` or other)
|
|
||||||
|
|
||||||
If status reports `actionContext.mode: "workspace-planning"`, explain that workspace archive is not supported in this slice and STOP. Do not move workspace changes into repo-local archives or edit linked repos.
|
|
||||||
|
|
||||||
**If any artifacts are not `done`:**
|
|
||||||
- Display warning listing incomplete artifacts
|
|
||||||
- Use **AskUserQuestion tool** to confirm user wants to proceed
|
|
||||||
- Proceed if user confirms
|
|
||||||
|
|
||||||
3. **Check task completion status**
|
|
||||||
|
|
||||||
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
|
|
||||||
|
|
||||||
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
|
|
||||||
|
|
||||||
**If incomplete tasks found:**
|
|
||||||
- Display warning showing count of incomplete tasks
|
|
||||||
- Use **AskUserQuestion tool** to confirm user wants to proceed
|
|
||||||
- Proceed if user confirms
|
|
||||||
|
|
||||||
**If no tasks file exists:** Proceed without task-related warning.
|
|
||||||
|
|
||||||
4. **Assess delta spec sync state**
|
|
||||||
|
|
||||||
Use `artifactPaths.specs.existingOutputPaths` from status JSON to check for delta specs. If none exist, proceed without sync prompt.
|
|
||||||
|
|
||||||
**If delta specs exist:**
|
|
||||||
- Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
|
|
||||||
- Determine what changes would be applied (adds, modifications, removals, renames)
|
|
||||||
- Show a combined summary before prompting
|
|
||||||
|
|
||||||
**Prompt options:**
|
|
||||||
- If changes needed: "Sync now (recommended)", "Archive without syncing"
|
|
||||||
- If already synced: "Archive now", "Sync anyway", "Cancel"
|
|
||||||
|
|
||||||
If user chooses sync, use Task tool (subagent_type: "general-purpose", prompt: "Use Skill tool to invoke openspec-sync-specs for change '<name>'. Delta spec analysis: <include the analyzed delta spec summary>"). Proceed to archive regardless of choice.
|
|
||||||
|
|
||||||
5. **Perform the archive**
|
|
||||||
|
|
||||||
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
|
|
||||||
```bash
|
|
||||||
mkdir -p "<planningHome.changesDir>/archive"
|
|
||||||
```
|
|
||||||
|
|
||||||
Generate target name using current date: `YYYY-MM-DD-<change-name>`
|
|
||||||
|
|
||||||
**Check if target already exists:**
|
|
||||||
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
||||||
- If no: Move `changeRoot` to the archive directory
|
|
||||||
|
|
||||||
```bash
|
|
||||||
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
6. **Display summary**
|
|
||||||
|
|
||||||
Show archive completion summary including:
|
|
||||||
- Change name
|
|
||||||
- Schema that was used
|
|
||||||
- Archive location
|
|
||||||
- Whether specs were synced (if applicable)
|
|
||||||
- Note about any warnings (incomplete artifacts/tasks)
|
|
||||||
|
|
||||||
**Output On Success**
|
|
||||||
|
|
||||||
```
|
|
||||||
## Archive Complete
|
|
||||||
|
|
||||||
**Change:** <change-name>
|
|
||||||
**Schema:** <schema-name>
|
|
||||||
**Archived to:** the archive path derived from `planningHome.changesDir`/YYYY-MM-DD-<name>/
|
|
||||||
**Specs:** ✓ Synced to main specs (or "No delta specs" or "Sync skipped")
|
|
||||||
|
|
||||||
All artifacts complete. All tasks complete.
|
|
||||||
```
|
|
||||||
|
|
||||||
**Guardrails**
|
|
||||||
- Always prompt for change selection if not provided
|
|
||||||
- Use artifact graph (openspec status --json) for completion checking
|
|
||||||
- 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 openspec-sync-specs approach (agent-driven)
|
|
||||||
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
|
|
||||||
@ -1,248 +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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 "<name>" --json`
|
|
||||||
- Parse `schemaName`, `artifacts`, `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`
|
|
||||||
- Note which artifacts are `done` vs other states
|
|
||||||
|
|
||||||
If any selected change reports `actionContext.mode: "workspace-planning"`, explain that workspace bulk archive is not supported in this slice and STOP before syncing specs or moving changes. Do not fall back to repo-local paths or edit linked repos.
|
|
||||||
|
|
||||||
b. **Task completion** - Read `artifactPaths.tasks.existingOutputPaths` from status JSON
|
|
||||||
- Count `- [ ]` (incomplete) vs `- [x]` (complete)
|
|
||||||
- If no tasks file exists, note as "No tasks"
|
|
||||||
|
|
||||||
c. **Delta specs** - Check `artifactPaths.specs.existingOutputPaths` from status JSON
|
|
||||||
- List which capability specs exist
|
|
||||||
- For each, extract requirement names (lines matching `### Requirement: <name>`)
|
|
||||||
|
|
||||||
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 "<planningHome.changesDir>/archive"
|
|
||||||
mv "<changeRoot>" "<planningHome.changesDir>/archive/YYYY-MM-DD-<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
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:
|
|
||||||
- <change-1> -> archive/YYYY-MM-DD-<change-1>/
|
|
||||||
- <change-2> -> archive/YYYY-MM-DD-<change-2>/
|
|
||||||
|
|
||||||
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:
|
|
||||||
- <change-1> -> archive/YYYY-MM-DD-<change-1>/
|
|
||||||
|
|
||||||
Skipped M changes:
|
|
||||||
- <change-2> (user chose not to archive incomplete)
|
|
||||||
|
|
||||||
Failed K changes:
|
|
||||||
- <change-3>: Archive directory already exists
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output When No Changes**
|
|
||||||
|
|
||||||
```
|
|
||||||
## No Changes to Archive
|
|
||||||
|
|
||||||
No active changes found. Create a new change to get started.
|
|
||||||
```
|
|
||||||
|
|
||||||
**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-<name>
|
|
||||||
- If archive target exists, fail that change but continue with others
|
|
||||||
@ -1,119 +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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 "<name>" --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
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
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 <artifact-id> --change "<name>" --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
|
|
||||||
- `resolvedOutputPath`: Resolved path or pattern 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 `resolvedOutputPath` specified in instructions. If it is a glob pattern, choose the concrete file path using the schema instruction and workspace planning context
|
|
||||||
- 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 "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**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/<capability>/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 `<context>`, `<rules>`, `<project_context>` blocks into the artifact
|
|
||||||
- These guide what you write, but should never appear in the output
|
|
||||||
@ -1,287 +0,0 @@
|
|||||||
---
|
|
||||||
name: openspec-explore
|
|
||||||
description: Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
|
|
||||||
license: MIT
|
|
||||||
compatibility: Requires openspec CLI.
|
|
||||||
metadata:
|
|
||||||
author: openspec
|
|
||||||
version: "1.0"
|
|
||||||
generatedBy: "1.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 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.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## The Stance
|
|
||||||
|
|
||||||
- **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
|
|
||||||
- **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
|
|
||||||
- **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
|
|
||||||
- **Adaptive** - Follow interesting threads, pivot when new information emerges
|
|
||||||
- **Patient** - Don't rush to conclusions, let the shape of the problem emerge
|
|
||||||
- **Grounded** - Explore the actual codebase when relevant, don't just theorize
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What You Might Do
|
|
||||||
|
|
||||||
Depending on what the user brings, you might:
|
|
||||||
|
|
||||||
**Explore the problem space**
|
|
||||||
- Ask clarifying questions that emerge from what they said
|
|
||||||
- Challenge assumptions
|
|
||||||
- Reframe the problem
|
|
||||||
- Find analogies
|
|
||||||
|
|
||||||
**Investigate the codebase**
|
|
||||||
- Map existing architecture relevant to the discussion
|
|
||||||
- Find integration points
|
|
||||||
- Identify patterns already in use
|
|
||||||
- Surface hidden complexity
|
|
||||||
|
|
||||||
**Compare options**
|
|
||||||
- Brainstorm multiple approaches
|
|
||||||
- Build comparison tables
|
|
||||||
- Sketch tradeoffs
|
|
||||||
- Recommend a path (if asked)
|
|
||||||
|
|
||||||
**Visualize**
|
|
||||||
```
|
|
||||||
┌─────────────────────────────────────────┐
|
|
||||||
│ Use ASCII diagrams liberally │
|
|
||||||
├─────────────────────────────────────────┤
|
|
||||||
│ │
|
|
||||||
│ ┌────────┐ ┌────────┐ │
|
|
||||||
│ │ State │────────▶│ State │ │
|
|
||||||
│ │ A │ │ B │ │
|
|
||||||
│ └────────┘ └────────┘ │
|
|
||||||
│ │
|
|
||||||
│ System diagrams, state machines, │
|
|
||||||
│ data flows, architecture sketches, │
|
|
||||||
│ dependency graphs, comparison tables │
|
|
||||||
│ │
|
|
||||||
└─────────────────────────────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
**Surface risks and unknowns**
|
|
||||||
- Identify what could go wrong
|
|
||||||
- Find gaps in understanding
|
|
||||||
- Suggest spikes or investigations
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## OpenSpec Awareness
|
|
||||||
|
|
||||||
You have full context of the OpenSpec system. Use it naturally, don't force it.
|
|
||||||
|
|
||||||
### Check for context
|
|
||||||
|
|
||||||
At the start, quickly check what exists:
|
|
||||||
```bash
|
|
||||||
openspec list --json
|
|
||||||
```
|
|
||||||
|
|
||||||
This tells you:
|
|
||||||
- If there are active changes
|
|
||||||
- Their names, schemas, and status
|
|
||||||
- What the user might be working on
|
|
||||||
|
|
||||||
### When no change exists
|
|
||||||
|
|
||||||
Think freely. When insights crystallize, you might offer:
|
|
||||||
|
|
||||||
- "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
|
|
||||||
|
|
||||||
If the user mentions a change or you detect one is relevant:
|
|
||||||
|
|
||||||
1. **Resolve and read existing artifacts for context**
|
|
||||||
- Run `openspec status --change "<name>" --json`.
|
|
||||||
- Use `changeRoot`, `artifactPaths`, and `actionContext` from the status JSON.
|
|
||||||
- Read existing files from `artifactPaths.<artifact>.existingOutputPaths`.
|
|
||||||
|
|
||||||
2. **Reference them naturally in conversation**
|
|
||||||
- "Your design mentions using Redis, but we just realized SQLite fits better..."
|
|
||||||
- "The proposal scopes this to premium users, but we're now thinking everyone..."
|
|
||||||
|
|
||||||
3. **Offer to capture when decisions are made**
|
|
||||||
|
|
||||||
| Insight Type | Where to Capture |
|
|
||||||
|----------------------------|--------------------------------|
|
|
||||||
| New requirement discovered | `specs/<capability>/spec.md` |
|
|
||||||
| Requirement changed | `specs/<capability>/spec.md` |
|
|
||||||
| Design decision made | `design.md` |
|
|
||||||
| Scope changed | `proposal.md` |
|
|
||||||
| New work identified | `tasks.md` |
|
|
||||||
| Assumption invalidated | Relevant artifact |
|
|
||||||
|
|
||||||
Example offers:
|
|
||||||
- "That's a design decision. Capture it in design.md?"
|
|
||||||
- "This is a new requirement. Add it to specs?"
|
|
||||||
- "This changes scope. Update the proposal?"
|
|
||||||
|
|
||||||
4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What You Don't Have To Do
|
|
||||||
|
|
||||||
- Follow a script
|
|
||||||
- Ask the same questions every time
|
|
||||||
- Produce a specific artifact
|
|
||||||
- Reach a conclusion
|
|
||||||
- Stay on topic if a tangent is valuable
|
|
||||||
- Be brief (this is thinking time)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Handling Different Entry Points
|
|
||||||
|
|
||||||
**User brings a vague idea:**
|
|
||||||
```
|
|
||||||
User: I'm thinking about adding real-time collaboration
|
|
||||||
|
|
||||||
You: Real-time collab is a big space. Let me think about this...
|
|
||||||
|
|
||||||
COLLABORATION SPECTRUM
|
|
||||||
════════════════════════════════════════════
|
|
||||||
|
|
||||||
Awareness Coordination Sync
|
|
||||||
│ │ │
|
|
||||||
▼ ▼ ▼
|
|
||||||
┌────────┐ ┌────────┐ ┌────────┐
|
|
||||||
│Presence│ │Cursors │ │ CRDT │
|
|
||||||
│ "3 │ │ Multi │ │Conflict│
|
|
||||||
│online" │ │ select │ │ free │
|
|
||||||
└────────┘ └────────┘ └────────┘
|
|
||||||
│ │ │
|
|
||||||
trivial moderate complex
|
|
||||||
|
|
||||||
Where's your head at?
|
|
||||||
```
|
|
||||||
|
|
||||||
**User brings a specific problem:**
|
|
||||||
```
|
|
||||||
User: The auth system is a mess
|
|
||||||
|
|
||||||
You: [reads codebase]
|
|
||||||
|
|
||||||
┌─────────────────────────────────────────────┐
|
|
||||||
│ CURRENT AUTH FLOW │
|
|
||||||
└─────────────────────────────────────────────┘
|
|
||||||
│
|
|
||||||
┌─────────────┼─────────────┐
|
|
||||||
▼ ▼ ▼
|
|
||||||
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
||||||
│ Google │ │ GitHub │ │ Email │
|
|
||||||
│ OAuth │ │ OAuth │ │ Magic │
|
|
||||||
└────┬────┘ └────┬────┘ └────┬────┘
|
|
||||||
│ │ │
|
|
||||||
└─────────────┼─────────────┘
|
|
||||||
▼
|
|
||||||
┌───────────┐
|
|
||||||
│ Session │
|
|
||||||
└─────┬─────┘
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
┌───────────┐
|
|
||||||
│ Perms │
|
|
||||||
└───────────┘
|
|
||||||
|
|
||||||
I see three tangles. Which one's burning?
|
|
||||||
```
|
|
||||||
|
|
||||||
**User is stuck mid-implementation:**
|
|
||||||
```
|
|
||||||
User: /opsx:explore add-auth-system
|
|
||||||
The OAuth integration is more complex than expected
|
|
||||||
|
|
||||||
You: [reads change artifacts]
|
|
||||||
|
|
||||||
You're on task 4: "Implement OAuth flow"
|
|
||||||
|
|
||||||
Let me trace what's involved...
|
|
||||||
|
|
||||||
[draws diagram, explores options, suggests paths]
|
|
||||||
|
|
||||||
Want to update the design to reflect this?
|
|
||||||
Or add a spike task to investigate?
|
|
||||||
```
|
|
||||||
|
|
||||||
**User wants to compare options:**
|
|
||||||
```
|
|
||||||
User: Should we use Postgres or SQLite?
|
|
||||||
|
|
||||||
You: Generic answer is boring. What's the context?
|
|
||||||
|
|
||||||
User: A CLI tool that tracks local dev environments
|
|
||||||
|
|
||||||
You: That changes everything.
|
|
||||||
|
|
||||||
┌─────────────────────────────────────────────────┐
|
|
||||||
│ CLI TOOL DATA STORAGE │
|
|
||||||
└─────────────────────────────────────────────────┘
|
|
||||||
|
|
||||||
Key constraints:
|
|
||||||
• No daemon running
|
|
||||||
• Must work offline
|
|
||||||
• Single user
|
|
||||||
|
|
||||||
SQLite Postgres
|
|
||||||
Deployment embedded ✓ needs server ✗
|
|
||||||
Offline yes ✓ no ✗
|
|
||||||
Single file yes ✓ no ✗
|
|
||||||
|
|
||||||
SQLite. Not even close.
|
|
||||||
|
|
||||||
Unless... is there a sync component?
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Ending Discovery
|
|
||||||
|
|
||||||
There's no required ending. Discovery might:
|
|
||||||
|
|
||||||
- **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"
|
|
||||||
|
|
||||||
When it feels like things are crystallizing, you might summarize:
|
|
||||||
|
|
||||||
```
|
|
||||||
## What We Figured Out
|
|
||||||
|
|
||||||
**The problem**: [crystallized understanding]
|
|
||||||
|
|
||||||
**The approach**: [if one emerged]
|
|
||||||
|
|
||||||
**Open questions**: [if any remain]
|
|
||||||
|
|
||||||
**Next steps** (if ready):
|
|
||||||
- Create a change proposal
|
|
||||||
- Keep exploring: just keep talking
|
|
||||||
```
|
|
||||||
|
|
||||||
But this summary is optional. Sometimes the thinking IS the value.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Guardrails
|
|
||||||
|
|
||||||
- **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
|
|
||||||
- **Don't fake understanding** - If something is unclear, dig deeper
|
|
||||||
- **Don't rush** - Discovery is thinking time, not task time
|
|
||||||
- **Don't force structure** - Let patterns emerge naturally
|
|
||||||
- **Don't auto-capture** - Offer to save insights, don't just do it
|
|
||||||
- **Do visualize** - A good diagram is worth many paragraphs
|
|
||||||
- **Do explore the codebase** - Ground discussions in reality
|
|
||||||
- **Do question assumptions** - Including the user's and your own
|
|
||||||
@ -1,102 +0,0 @@
|
|||||||
---
|
|
||||||
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.
|
|
||||||
license: MIT
|
|
||||||
compatibility: Requires openspec CLI.
|
|
||||||
metadata:
|
|
||||||
author: openspec
|
|
||||||
version: "1.0"
|
|
||||||
generatedBy: "1.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
Fast-forward through artifact creation - generate everything needed to start implementation in one go.
|
|
||||||
|
|
||||||
**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. **Create the change directory**
|
|
||||||
```bash
|
|
||||||
openspec new change "<name>"
|
|
||||||
```
|
|
||||||
This creates a scaffolded change in the planning home resolved by the CLI.
|
|
||||||
|
|
||||||
3. **Get the artifact build order**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to get:
|
|
||||||
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
||||||
- `artifacts`: list of all artifacts with their status and dependencies
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
4. **Create artifacts in sequence until apply-ready**
|
|
||||||
|
|
||||||
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
||||||
|
|
||||||
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
||||||
|
|
||||||
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
||||||
- Get instructions:
|
|
||||||
```bash
|
|
||||||
openspec instructions <artifact-id> --change "<name>" --json
|
|
||||||
```
|
|
||||||
- The instructions JSON includes:
|
|
||||||
- `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 for this artifact type
|
|
||||||
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
|
|
||||||
- `dependencies`: Completed artifacts to read for context
|
|
||||||
- Read any completed dependency files for context
|
|
||||||
- Create the artifact file using `template` as the structure and write it to `resolvedOutputPath`
|
|
||||||
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
||||||
- Show brief progress: "✓ Created <artifact-id>"
|
|
||||||
|
|
||||||
b. **Continue until all `applyRequires` artifacts are complete**
|
|
||||||
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
||||||
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
||||||
- Stop when all `applyRequires` artifacts are done
|
|
||||||
|
|
||||||
c. **If an artifact requires user input** (unclear context):
|
|
||||||
- Use **AskUserQuestion tool** to clarify
|
|
||||||
- Then continue with creation
|
|
||||||
|
|
||||||
5. **Show final status**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output**
|
|
||||||
|
|
||||||
After completing all artifacts, summarize:
|
|
||||||
- Change name and location
|
|
||||||
- List of artifacts created with brief descriptions
|
|
||||||
- What's ready: "All artifacts created! Ready for implementation."
|
|
||||||
- Prompt: "Run `/opsx:apply` or ask me to implement to start working on the tasks."
|
|
||||||
|
|
||||||
**Artifact Creation Guidelines**
|
|
||||||
|
|
||||||
- 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 `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 `<context>`, `<rules>`, `<project_context>` 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`)
|
|
||||||
- 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
|
|
||||||
- Verify each artifact file exists after writing before proceeding to next
|
|
||||||
@ -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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 <name>`
|
|
||||||
- "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 "<name>"
|
|
||||||
```
|
|
||||||
Add `--schema <name>` only if the user requested a specific workflow.
|
|
||||||
This creates a scaffolded change in the planning home resolved by the CLI.
|
|
||||||
|
|
||||||
4. **Show the artifact status**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Use the returned `planningHome`, `changeRoot`, `artifactPaths`, and `nextSteps` instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
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 <first-artifact-id> --change "<name>"
|
|
||||||
```
|
|
||||||
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
|
|
||||||
@ -1,552 +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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 the OpenSpec CLI is installed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Unix/macOS
|
|
||||||
openspec --version 2>&1 || echo "CLI_NOT_INSTALLED"
|
|
||||||
# Windows (PowerShell)
|
|
||||||
# if (Get-Command openspec -ErrorAction SilentlyContinue) { openspec --version } else { echo "CLI_NOT_INSTALLED" }
|
|
||||||
```
|
|
||||||
|
|
||||||
**If CLI not installed:**
|
|
||||||
> OpenSpec CLI is not installed. Install it first, then come back to `/opsx:onboard`.
|
|
||||||
|
|
||||||
Stop here if not installed.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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
|
|
||||||
# Unix/macOS
|
|
||||||
git log --oneline -10 2>/dev/null || echo "No git history"
|
|
||||||
# Windows (PowerShell)
|
|
||||||
# git log --oneline -10 2>$null; if ($LASTEXITCODE -ne 0) { 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 at the `changeRoot` reported by `openspec status --change "<name>" --json` 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 "<derived-name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**SHOW:**
|
|
||||||
```
|
|
||||||
Created: <changeRoot from status JSON>
|
|
||||||
|
|
||||||
The folder structure:
|
|
||||||
```
|
|
||||||
<changeRoot>/
|
|
||||||
├── 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
|
|
||||||
- `<capability-name>`: [brief description]
|
|
||||||
|
|
||||||
### Modified Capabilities
|
|
||||||
<!-- If modifying existing behavior -->
|
|
||||||
|
|
||||||
## 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 "<name>" --json
|
|
||||||
```
|
|
||||||
Then write the content to the `resolvedOutputPath` from `openspec instructions proposal --change "<name>" --json`.
|
|
||||||
|
|
||||||
```
|
|
||||||
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:** Resolve where the spec file should be created:
|
|
||||||
```bash
|
|
||||||
openspec instructions specs --change "<name>" --json
|
|
||||||
# Use resolvedOutputPath from the JSON. If it is a glob, choose the concrete file path using the schema instruction and workspace planning context.
|
|
||||||
```
|
|
||||||
|
|
||||||
Draft the spec content:
|
|
||||||
|
|
||||||
```
|
|
||||||
Here's the spec:
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## ADDED Requirements
|
|
||||||
|
|
||||||
### Requirement: <Name>
|
|
||||||
|
|
||||||
<Description of what the system should do>
|
|
||||||
|
|
||||||
#### Scenario: <Scenario name>
|
|
||||||
|
|
||||||
- **WHEN** <trigger condition>
|
|
||||||
- **THEN** <expected outcome>
|
|
||||||
- **AND** <additional outcome if needed>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases.
|
|
||||||
```
|
|
||||||
|
|
||||||
Save to the concrete file path chosen from `resolvedOutputPath`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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 the `resolvedOutputPath` from `openspec instructions design --change "<name>" --json`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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 the `resolvedOutputPath` from `openspec instructions tasks --change "<name>" --json`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 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. The archive path is derived from `planningHome.changesDir` and the date.
|
|
||||||
|
|
||||||
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 "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**SHOW:**
|
|
||||||
```
|
|
||||||
Archived to: `<planningHome.changesDir>/archive/YYYY-MM-DD-<name>/`
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
**Core workflow:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|-------------------|--------------------------------------------|
|
|
||||||
| `/opsx:propose` | Create a change and generate all artifacts |
|
|
||||||
| `/opsx:explore` | Think through problems before/during work |
|
|
||||||
| `/opsx:apply` | Implement tasks from a change |
|
|
||||||
| `/opsx:archive` | Archive a completed change |
|
|
||||||
|
|
||||||
**Additional commands:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|--------------------|----------------------------------------------------------|
|
|
||||||
| `/opsx:new` | Start a new change, step through artifacts one at a time |
|
|
||||||
| `/opsx:continue` | Continue working on an existing change |
|
|
||||||
| `/opsx:ff` | Fast-forward: create all artifacts at once |
|
|
||||||
| `/opsx:verify` | Verify implementation matches artifacts |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## What's Next?
|
|
||||||
|
|
||||||
Try `/opsx:propose` 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 the `changeRoot` reported by `openspec status --change "<name>" --json`.
|
|
||||||
|
|
||||||
To pick up where we left off later:
|
|
||||||
- `/opsx:continue <name>` - Resume artifact creation
|
|
||||||
- `/opsx:apply <name>` - 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
|
|
||||||
|
|
||||||
**Core workflow:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|--------------------------|--------------------------------------------|
|
|
||||||
| `/opsx:propose <name>` | Create a change and generate all artifacts |
|
|
||||||
| `/opsx:explore` | Think through problems (no code changes) |
|
|
||||||
| `/opsx:apply <name>` | Implement tasks |
|
|
||||||
| `/opsx:archive <name>` | Archive when done |
|
|
||||||
|
|
||||||
**Additional commands:**
|
|
||||||
|
|
||||||
| Command | What it does |
|
|
||||||
|---------------------------|-------------------------------------|
|
|
||||||
| `/opsx:new <name>` | Start a new change, step by step |
|
|
||||||
| `/opsx:continue <name>` | Continue an existing change |
|
|
||||||
| `/opsx:ff <name>` | Fast-forward: all artifacts at once |
|
|
||||||
| `/opsx:verify <name>` | Verify implementation |
|
|
||||||
|
|
||||||
Try `/opsx:propose` to start your first change.
|
|
||||||
```
|
|
||||||
|
|
||||||
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
|
|
||||||
@ -1,111 +0,0 @@
|
|||||||
---
|
|
||||||
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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
**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. **Create the change directory**
|
|
||||||
```bash
|
|
||||||
openspec new change "<name>"
|
|
||||||
```
|
|
||||||
This creates a scaffolded change in the planning home resolved by the CLI with `.openspec.yaml`.
|
|
||||||
|
|
||||||
3. **Get the artifact build order**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to get:
|
|
||||||
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
|
|
||||||
- `artifacts`: list of all artifacts with their status and dependencies
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
|
|
||||||
|
|
||||||
4. **Create artifacts in sequence until apply-ready**
|
|
||||||
|
|
||||||
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
||||||
|
|
||||||
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
||||||
|
|
||||||
a. **For each artifact that is `ready` (dependencies satisfied)**:
|
|
||||||
- Get instructions:
|
|
||||||
```bash
|
|
||||||
openspec instructions <artifact-id> --change "<name>" --json
|
|
||||||
```
|
|
||||||
- The instructions JSON includes:
|
|
||||||
- `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 for this artifact type
|
|
||||||
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
|
|
||||||
- `dependencies`: Completed artifacts to read for context
|
|
||||||
- Read any completed dependency files for context
|
|
||||||
- Create the artifact file using `template` as the structure and write it to `resolvedOutputPath`
|
|
||||||
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
|
|
||||||
- Show brief progress: "Created <artifact-id>"
|
|
||||||
|
|
||||||
b. **Continue until all `applyRequires` artifacts are complete**
|
|
||||||
- After creating each artifact, re-run `openspec status --change "<name>" --json`
|
|
||||||
- Check if every artifact ID in `applyRequires` has `status: "done"` in the artifacts array
|
|
||||||
- Stop when all `applyRequires` artifacts are done
|
|
||||||
|
|
||||||
c. **If an artifact requires user input** (unclear context):
|
|
||||||
- Use **AskUserQuestion tool** to clarify
|
|
||||||
- Then continue with creation
|
|
||||||
|
|
||||||
5. **Show final status**
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Output**
|
|
||||||
|
|
||||||
After completing all artifacts, summarize:
|
|
||||||
- Change name and location
|
|
||||||
- List of artifacts created with brief descriptions
|
|
||||||
- What's ready: "All artifacts created! Ready for implementation."
|
|
||||||
- Prompt: "Run `/opsx:apply` or ask me to implement to start working on the tasks."
|
|
||||||
|
|
||||||
**Artifact Creation Guidelines**
|
|
||||||
|
|
||||||
- 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 `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 `<context>`, `<rules>`, `<project_context>` 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`)
|
|
||||||
- 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, ask if user wants to continue it or create a new one
|
|
||||||
- Verify each artifact file exists after writing before proceeding to next
|
|
||||||
@ -1,147 +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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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. **Resolve change context**
|
|
||||||
|
|
||||||
Run:
|
|
||||||
```bash
|
|
||||||
openspec status --change "<name>" --json
|
|
||||||
```
|
|
||||||
|
|
||||||
If status reports `actionContext.mode: "workspace-planning"`, explain that workspace spec sync is not supported in this slice and STOP. Do not fall back to repo-local paths or edit linked repos.
|
|
||||||
|
|
||||||
3. **Find delta specs**
|
|
||||||
|
|
||||||
Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the list of delta spec files.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
4. **For each delta spec, apply changes to main specs**
|
|
||||||
|
|
||||||
For each repo-local capability delta spec path returned by the CLI:
|
|
||||||
|
|
||||||
a. **Read the delta spec** to understand the intended changes
|
|
||||||
|
|
||||||
b. **Read the main spec** at `openspec/specs/<capability>/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/<capability>/spec.md`
|
|
||||||
- Add Purpose section (can be brief, mark as TBD)
|
|
||||||
- Add Requirements section with the ADDED requirements
|
|
||||||
|
|
||||||
5. **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: <change-name>
|
|
||||||
|
|
||||||
Updated main specs:
|
|
||||||
|
|
||||||
**<capability-1>**:
|
|
||||||
- Added requirement: "New Feature"
|
|
||||||
- Modified requirement: "Existing Feature" (added 1 scenario)
|
|
||||||
|
|
||||||
**<capability-2>**:
|
|
||||||
- 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
|
|
||||||
@ -1,171 +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.4.2"
|
|
||||||
---
|
|
||||||
|
|
||||||
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 "<name>" --json
|
|
||||||
```
|
|
||||||
Parse the JSON to understand:
|
|
||||||
- `schemaName`: The workflow being used (e.g., "spec-driven")
|
|
||||||
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
|
|
||||||
- Which artifacts exist for this change
|
|
||||||
|
|
||||||
If status reports `actionContext.mode: "workspace-planning"`, explain that full workspace implementation verification is not supported in this slice and STOP. Do not infer repo-local implementation ownership or edit linked repos.
|
|
||||||
|
|
||||||
3. **Get planning context and load artifacts**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openspec instructions apply --change "<name>" --json
|
|
||||||
```
|
|
||||||
|
|
||||||
This returns the change directory and `contextFiles` (artifact ID -> array of concrete file paths). 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 `contextFiles.tasks` exists, read every file path in 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: <description>" or "Mark as done if already implemented"
|
|
||||||
|
|
||||||
**Spec Coverage**:
|
|
||||||
- If delta specs exist in `contextFiles.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: <requirement name>"
|
|
||||||
- Recommendation: "Implement requirement X: <description>"
|
|
||||||
|
|
||||||
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: <details>"
|
|
||||||
- Recommendation: "Review <file>:<lines> 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: <scenario name>"
|
|
||||||
- Recommendation: "Add test or implementation for scenario: <description>"
|
|
||||||
|
|
||||||
7. **Verify Coherence**
|
|
||||||
|
|
||||||
**Design Adherence**:
|
|
||||||
- If `contextFiles.design` exists:
|
|
||||||
- Extract key decisions (look for sections like "Decision:", "Approach:", "Architecture:")
|
|
||||||
- Verify implementation follows those decisions
|
|
||||||
- If contradiction detected:
|
|
||||||
- Add WARNING: "Design decision not followed: <decision>"
|
|
||||||
- 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: <details>"
|
|
||||||
- Recommendation: "Consider following project pattern: <example>"
|
|
||||||
|
|
||||||
8. **Generate Verification Report**
|
|
||||||
|
|
||||||
**Summary Scorecard**:
|
|
||||||
```
|
|
||||||
## Verification Report: <change-name>
|
|
||||||
|
|
||||||
### 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"
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*)
|
|
||||||
if command -v cygpath > /dev/null 2>&1; then
|
|
||||||
basedir=`cygpath -w "$basedir"`
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../which/bin/node-which" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../which/bin/node-which" "$@"
|
|
||||||
fi
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\which\bin\node-which" %*
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../which/bin/node-which" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../which/bin/node-which" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../which/bin/node-which" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*)
|
|
||||||
if command -v cygpath > /dev/null 2>&1; then
|
|
||||||
basedir=`cygpath -w "$basedir"`
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../@fission-ai/openspec/bin/openspec.js" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../@fission-ai/openspec/bin/openspec.js" "$@"
|
|
||||||
fi
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\@fission-ai\openspec\bin\openspec.js" %*
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../@fission-ai/openspec/bin/openspec.js" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../@fission-ai/openspec/bin/openspec.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../@fission-ai/openspec/bin/openspec.js" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../@fission-ai/openspec/bin/openspec.js" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*|*MINGW*|*MSYS*)
|
|
||||||
if command -v cygpath > /dev/null 2>&1; then
|
|
||||||
basedir=`cygpath -w "$basedir"`
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
exec "$basedir/node" "$basedir/../yaml/bin.mjs" "$@"
|
|
||||||
else
|
|
||||||
exec node "$basedir/../yaml/bin.mjs" "$@"
|
|
||||||
fi
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
@ECHO off
|
|
||||||
GOTO start
|
|
||||||
:find_dp0
|
|
||||||
SET dp0=%~dp0
|
|
||||||
EXIT /b
|
|
||||||
:start
|
|
||||||
SETLOCAL
|
|
||||||
CALL :find_dp0
|
|
||||||
|
|
||||||
IF EXIST "%dp0%\node.exe" (
|
|
||||||
SET "_prog=%dp0%\node.exe"
|
|
||||||
) ELSE (
|
|
||||||
SET "_prog=node"
|
|
||||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
)
|
|
||||||
|
|
||||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\yaml\bin.mjs" %*
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env pwsh
|
|
||||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
|
||||||
|
|
||||||
$exe=""
|
|
||||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|
||||||
# Fix case when both the Windows and Linux builds of Node
|
|
||||||
# are installed in the same directory
|
|
||||||
$exe=".exe"
|
|
||||||
}
|
|
||||||
$ret=0
|
|
||||||
if (Test-Path "$basedir/node$exe") {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "$basedir/node$exe" "$basedir/../yaml/bin.mjs" $args
|
|
||||||
} else {
|
|
||||||
& "$basedir/node$exe" "$basedir/../yaml/bin.mjs" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
} else {
|
|
||||||
# Support pipeline input
|
|
||||||
if ($MyInvocation.ExpectingInput) {
|
|
||||||
$input | & "node$exe" "$basedir/../yaml/bin.mjs" $args
|
|
||||||
} else {
|
|
||||||
& "node$exe" "$basedir/../yaml/bin.mjs" $args
|
|
||||||
}
|
|
||||||
$ret=$LASTEXITCODE
|
|
||||||
}
|
|
||||||
exit $ret
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,22 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2024 OpenSpec Contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
import { runCli } from '../dist/cli/index.js';
|
|
||||||
|
|
||||||
runCli();
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@fission-ai/openspec",
|
|
||||||
"version": "1.5.0",
|
|
||||||
"description": "AI-native system for spec-driven development",
|
|
||||||
"keywords": [
|
|
||||||
"openspec",
|
|
||||||
"specs",
|
|
||||||
"cli",
|
|
||||||
"ai",
|
|
||||||
"development"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/Fission-AI/OpenSpec",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/Fission-AI/OpenSpec"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"author": "OpenSpec Contributors",
|
|
||||||
"type": "module",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"default": "./dist/index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"openspec": "./bin/openspec.js"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist",
|
|
||||||
"bin",
|
|
||||||
"schemas",
|
|
||||||
"scripts/postinstall.js",
|
|
||||||
"!dist/**/*.test.js",
|
|
||||||
"!dist/**/__tests__",
|
|
||||||
"!dist/**/*.map"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=20.19.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@changesets/changelog-github": "^0.5.2",
|
|
||||||
"@changesets/cli": "^2.27.7",
|
|
||||||
"@types/node": "^24.2.0",
|
|
||||||
"@vitest/ui": "^3.2.6",
|
|
||||||
"eslint": "^9.39.2",
|
|
||||||
"typescript": "^5.9.3",
|
|
||||||
"typescript-eslint": "^8.62.0",
|
|
||||||
"vitest": "^3.2.6"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@inquirer/core": "^10.3.2",
|
|
||||||
"@inquirer/prompts": "^7.10.1",
|
|
||||||
"chalk": "^5.5.0",
|
|
||||||
"commander": "^14.0.0",
|
|
||||||
"cross-spawn": "7.0.6",
|
|
||||||
"fast-glob": "^3.3.3",
|
|
||||||
"ora": "^8.2.0",
|
|
||||||
"posthog-node": "^5.20.0",
|
|
||||||
"yaml": "^2.8.2",
|
|
||||||
"zod": "^4.0.17"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"lint": "eslint src/",
|
|
||||||
"build": "node build.js",
|
|
||||||
"dev": "tsc --watch",
|
|
||||||
"dev:cli": "pnpm build && node bin/openspec.js",
|
|
||||||
"test": "vitest run",
|
|
||||||
"test:watch": "vitest",
|
|
||||||
"test:ui": "vitest --ui",
|
|
||||||
"test:coverage": "vitest --coverage",
|
|
||||||
"test:postinstall": "node scripts/postinstall.js",
|
|
||||||
"postinstall": "node scripts/postinstall.js",
|
|
||||||
"check:pack-version": "node scripts/pack-version-check.mjs",
|
|
||||||
"release": "pnpm run release:ci",
|
|
||||||
"release:ci": "pnpm run check:pack-version && pnpm exec changeset publish",
|
|
||||||
"changeset": "changeset"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,153 +0,0 @@
|
|||||||
name: spec-driven
|
|
||||||
version: 1
|
|
||||||
description: Default OpenSpec workflow - proposal → specs → design → tasks
|
|
||||||
artifacts:
|
|
||||||
- id: proposal
|
|
||||||
generates: proposal.md
|
|
||||||
description: Initial proposal document outlining the change
|
|
||||||
template: proposal.md
|
|
||||||
instruction: |
|
|
||||||
Create the proposal document that establishes WHY this change is needed.
|
|
||||||
|
|
||||||
Sections:
|
|
||||||
- **Why**: 1-2 sentences on the problem or opportunity. What problem does this solve? Why now?
|
|
||||||
- **What Changes**: Bullet list of changes. Be specific about new capabilities, modifications, or removals. Mark breaking changes with **BREAKING**.
|
|
||||||
- **Capabilities**: Identify which specs will be created or modified:
|
|
||||||
- **New Capabilities**: List capabilities being introduced. Each becomes a new `specs/<name>/spec.md`. Use kebab-case names (e.g., `user-auth`, `data-export`).
|
|
||||||
- **Modified Capabilities**: List existing capabilities whose REQUIREMENTS are changing. Only include if spec-level behavior changes (not just implementation details). Each needs a delta spec file. Check `openspec/specs/` for existing spec names. Leave empty if no requirement changes.
|
|
||||||
- **Impact**: Affected code, APIs, dependencies, or systems.
|
|
||||||
|
|
||||||
IMPORTANT: The Capabilities section is critical. It creates the contract between
|
|
||||||
proposal and specs phases. Research existing specs before filling this in.
|
|
||||||
Each capability listed here will need a corresponding spec file.
|
|
||||||
|
|
||||||
Keep it concise (1-2 pages). Focus on the "why" not the "how" -
|
|
||||||
implementation details belong in design.md.
|
|
||||||
|
|
||||||
This is the foundation - specs, design, and tasks all build on this.
|
|
||||||
requires: []
|
|
||||||
|
|
||||||
- id: specs
|
|
||||||
generates: "specs/**/*.md"
|
|
||||||
description: Detailed specifications for the change
|
|
||||||
template: spec.md
|
|
||||||
instruction: |
|
|
||||||
Create specification files that define WHAT the system should do.
|
|
||||||
|
|
||||||
Create one spec file per capability listed in the proposal's Capabilities section.
|
|
||||||
- New capabilities: use the exact kebab-case name from the proposal (specs/<capability>/spec.md).
|
|
||||||
- Modified capabilities: use the existing spec folder name from openspec/specs/<capability>/ when creating the delta spec at specs/<capability>/spec.md.
|
|
||||||
|
|
||||||
Delta operations (use ## headers):
|
|
||||||
- **ADDED Requirements**: New capabilities
|
|
||||||
- **MODIFIED Requirements**: Changed behavior - MUST include full updated content
|
|
||||||
- **REMOVED Requirements**: Deprecated features - MUST include **Reason** and **Migration**
|
|
||||||
- **RENAMED Requirements**: Name changes only - use FROM:/TO: format
|
|
||||||
|
|
||||||
Format requirements:
|
|
||||||
- Each requirement: `### Requirement: <name>` followed by description
|
|
||||||
- Use SHALL/MUST for normative requirements (avoid should/may)
|
|
||||||
- Each scenario: `#### Scenario: <name>` with WHEN/THEN format
|
|
||||||
- **CRITICAL**: Scenarios MUST use exactly 4 hashtags (`####`). Using 3 hashtags or bullets will fail silently.
|
|
||||||
- Every requirement MUST have at least one scenario.
|
|
||||||
|
|
||||||
MODIFIED requirements workflow:
|
|
||||||
1. Locate the existing requirement in openspec/specs/<capability>/spec.md
|
|
||||||
2. Copy the ENTIRE requirement block (from `### Requirement:` through all scenarios)
|
|
||||||
3. Paste under `## MODIFIED Requirements` and edit to reflect new behavior
|
|
||||||
4. Ensure header text matches exactly (whitespace-insensitive)
|
|
||||||
|
|
||||||
Common pitfall: Using MODIFIED with partial content loses detail at archive time.
|
|
||||||
If adding new concerns without changing existing behavior, use ADDED instead.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```
|
|
||||||
## ADDED Requirements
|
|
||||||
|
|
||||||
### Requirement: User can export data
|
|
||||||
The system SHALL allow users to export their data in CSV format.
|
|
||||||
|
|
||||||
#### Scenario: Successful export
|
|
||||||
- **WHEN** user clicks "Export" button
|
|
||||||
- **THEN** system downloads a CSV file with all user data
|
|
||||||
|
|
||||||
## REMOVED Requirements
|
|
||||||
|
|
||||||
### Requirement: Legacy export
|
|
||||||
**Reason**: Replaced by new export system
|
|
||||||
**Migration**: Use new export endpoint at /api/v2/export
|
|
||||||
```
|
|
||||||
|
|
||||||
Specs should be testable - each scenario is a potential test case.
|
|
||||||
requires:
|
|
||||||
- proposal
|
|
||||||
|
|
||||||
- id: design
|
|
||||||
generates: design.md
|
|
||||||
description: Technical design document with implementation details
|
|
||||||
template: design.md
|
|
||||||
instruction: |
|
|
||||||
Create the design document that explains HOW to implement the change.
|
|
||||||
|
|
||||||
When to include design.md (create only if any apply):
|
|
||||||
- Cross-cutting change (multiple services/modules) or new architectural pattern
|
|
||||||
- New external dependency or significant data model changes
|
|
||||||
- Security, performance, or migration complexity
|
|
||||||
- Ambiguity that benefits from technical decisions before coding
|
|
||||||
|
|
||||||
Sections:
|
|
||||||
- **Context**: Background, current state, constraints, stakeholders
|
|
||||||
- **Goals / Non-Goals**: What this design achieves and explicitly excludes
|
|
||||||
- **Decisions**: Key technical choices with rationale (why X over Y?). Include alternatives considered for each decision.
|
|
||||||
- **Risks / Trade-offs**: Known limitations, things that could go wrong. Format: [Risk] → Mitigation
|
|
||||||
- **Migration Plan**: Steps to deploy, rollback strategy (if applicable)
|
|
||||||
- **Open Questions**: Outstanding decisions or unknowns to resolve
|
|
||||||
|
|
||||||
Focus on architecture and approach, not line-by-line implementation.
|
|
||||||
Reference the proposal for motivation and specs for requirements.
|
|
||||||
|
|
||||||
Good design docs explain the "why" behind technical decisions.
|
|
||||||
requires:
|
|
||||||
- proposal
|
|
||||||
|
|
||||||
- id: tasks
|
|
||||||
generates: tasks.md
|
|
||||||
description: Implementation checklist with trackable tasks
|
|
||||||
template: tasks.md
|
|
||||||
instruction: |
|
|
||||||
Create the task list that breaks down the implementation work.
|
|
||||||
|
|
||||||
**IMPORTANT: Follow the template below exactly.** The apply phase parses
|
|
||||||
checkbox format to track progress. Tasks not using `- [ ]` won't be tracked.
|
|
||||||
|
|
||||||
Guidelines:
|
|
||||||
- Group related tasks under ## numbered headings
|
|
||||||
- Each task MUST be a checkbox: `- [ ] X.Y Task description`
|
|
||||||
- Tasks should be small enough to complete in one session
|
|
||||||
- Order tasks by dependency (what must be done first?)
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```
|
|
||||||
## 1. Setup
|
|
||||||
|
|
||||||
- [ ] 1.1 Create new module structure
|
|
||||||
- [ ] 1.2 Add dependencies to package.json
|
|
||||||
|
|
||||||
## 2. Core Implementation
|
|
||||||
|
|
||||||
- [ ] 2.1 Implement data export function
|
|
||||||
- [ ] 2.2 Add CSV formatting utilities
|
|
||||||
```
|
|
||||||
|
|
||||||
Reference specs for what needs to be built, design for how to build it.
|
|
||||||
Each task should be verifiable - you know when it's done.
|
|
||||||
requires:
|
|
||||||
- specs
|
|
||||||
- design
|
|
||||||
|
|
||||||
apply:
|
|
||||||
requires: [tasks]
|
|
||||||
tracks: tasks.md
|
|
||||||
instruction: |
|
|
||||||
Read context files, work through pending tasks, mark complete as you go.
|
|
||||||
Pause if you hit blockers or need clarification.
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
## Context
|
|
||||||
|
|
||||||
<!-- Background and current state -->
|
|
||||||
|
|
||||||
## Goals / Non-Goals
|
|
||||||
|
|
||||||
**Goals:**
|
|
||||||
<!-- What this design aims to achieve -->
|
|
||||||
|
|
||||||
**Non-Goals:**
|
|
||||||
<!-- What is explicitly out of scope -->
|
|
||||||
|
|
||||||
## Decisions
|
|
||||||
|
|
||||||
<!-- Key design decisions and rationale -->
|
|
||||||
|
|
||||||
## Risks / Trade-offs
|
|
||||||
|
|
||||||
<!-- Known risks and trade-offs -->
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
## Why
|
|
||||||
|
|
||||||
<!-- Explain the motivation for this change. What problem does this solve? Why now? -->
|
|
||||||
|
|
||||||
## What Changes
|
|
||||||
|
|
||||||
<!-- Describe what will change. Be specific about new capabilities, modifications, or removals. -->
|
|
||||||
|
|
||||||
## Capabilities
|
|
||||||
|
|
||||||
### New Capabilities
|
|
||||||
<!-- Capabilities being introduced. Replace <name> with kebab-case identifier (e.g., user-auth, data-export, api-rate-limiting). Each creates specs/<name>/spec.md -->
|
|
||||||
- `<name>`: <brief description of what this capability covers>
|
|
||||||
|
|
||||||
### Modified Capabilities
|
|
||||||
<!-- Existing capabilities whose REQUIREMENTS are changing (not just implementation).
|
|
||||||
Only list here if spec-level behavior changes. Each needs a delta spec file.
|
|
||||||
Use existing spec names from openspec/specs/. Leave empty if no requirement changes. -->
|
|
||||||
- `<existing-name>`: <what requirement is changing>
|
|
||||||
|
|
||||||
## Impact
|
|
||||||
|
|
||||||
<!-- Affected code, APIs, dependencies, systems -->
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
## ADDED Requirements
|
|
||||||
|
|
||||||
### Requirement: <!-- requirement name -->
|
|
||||||
<!-- requirement text -->
|
|
||||||
|
|
||||||
#### Scenario: <!-- scenario name -->
|
|
||||||
- **WHEN** <!-- condition -->
|
|
||||||
- **THEN** <!-- expected outcome -->
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
## 1. <!-- Task Group Name -->
|
|
||||||
|
|
||||||
- [ ] 1.1 <!-- Task description -->
|
|
||||||
- [ ] 1.2 <!-- Task description -->
|
|
||||||
|
|
||||||
## 2. <!-- Task Group Name -->
|
|
||||||
|
|
||||||
- [ ] 2.1 <!-- Task description -->
|
|
||||||
- [ ] 2.2 <!-- Task description -->
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Postinstall script that hints about shell completions
|
|
||||||
*
|
|
||||||
* Completion installation is opt-in: the user must run
|
|
||||||
* `openspec completion install` explicitly. This script only
|
|
||||||
* prints a one-line tip after npm install.
|
|
||||||
*
|
|
||||||
* The tip is suppressed when:
|
|
||||||
* - CI=true environment variable is set
|
|
||||||
* - OPENSPEC_NO_COMPLETIONS=1 environment variable is set
|
|
||||||
* - dist/ directory doesn't exist (dev setup scenario)
|
|
||||||
*
|
|
||||||
* The script never fails npm install - all errors are caught and handled gracefully.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { promises as fs } from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
|
||||||
const __dirname = path.dirname(__filename);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we should skip installation
|
|
||||||
*/
|
|
||||||
function shouldSkipInstallation() {
|
|
||||||
// Skip in CI environments
|
|
||||||
if (process.env.CI === 'true' || process.env.CI === '1') {
|
|
||||||
return { skip: true, reason: 'CI environment detected' };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip if user opted out
|
|
||||||
if (process.env.OPENSPEC_NO_COMPLETIONS === '1') {
|
|
||||||
return { skip: true, reason: 'OPENSPEC_NO_COMPLETIONS=1 set' };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { skip: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if dist/ directory exists
|
|
||||||
*/
|
|
||||||
async function distExists() {
|
|
||||||
const distPath = path.join(__dirname, '..', 'dist');
|
|
||||||
try {
|
|
||||||
const stat = await fs.stat(distPath);
|
|
||||||
return stat.isDirectory();
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main function
|
|
||||||
*/
|
|
||||||
async function main() {
|
|
||||||
try {
|
|
||||||
// Check if we should skip
|
|
||||||
const skipCheck = shouldSkipInstallation();
|
|
||||||
if (skipCheck.skip) {
|
|
||||||
// Silent skip - no output
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if dist/ exists (skip silently if not - expected during dev setup)
|
|
||||||
if (!(await distExists())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Completions are opt-in — just print a hint
|
|
||||||
console.log(`\nTip: Run 'openspec completion install' for shell completions`);
|
|
||||||
} catch (error) {
|
|
||||||
// Fail gracefully - never break npm install
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run main and handle any unhandled errors
|
|
||||||
main().catch(() => {
|
|
||||||
// Silent failure - never break npm install
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
Copyright (c) 2025 Simon Boudrias
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation
|
|
||||||
files (the "Software"), to deal in the Software without
|
|
||||||
restriction, including without limitation the rights to use,
|
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
# @inquirer/ansi
|
|
||||||
|
|
||||||
A lightweight package providing ANSI escape sequences for terminal cursor manipulation and screen clearing.
|
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>npm</th>
|
|
||||||
<th>yarn</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install @inquirer/ansi
|
|
||||||
```
|
|
||||||
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
```sh
|
|
||||||
yarn add @inquirer/ansi
|
|
||||||
```
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```js
|
|
||||||
import {
|
|
||||||
cursorUp,
|
|
||||||
cursorDown,
|
|
||||||
cursorTo,
|
|
||||||
cursorLeft,
|
|
||||||
cursorHide,
|
|
||||||
cursorShow,
|
|
||||||
eraseLines,
|
|
||||||
} from '@inquirer/ansi';
|
|
||||||
|
|
||||||
// Move cursor up 3 lines
|
|
||||||
process.stdout.write(cursorUp(3));
|
|
||||||
|
|
||||||
// Move cursor to specific position (x: 10, y: 5)
|
|
||||||
process.stdout.write(cursorTo(10, 5));
|
|
||||||
|
|
||||||
// Hide/show cursor
|
|
||||||
process.stdout.write(cursorHide);
|
|
||||||
process.stdout.write(cursorShow);
|
|
||||||
|
|
||||||
// Clear 5 lines
|
|
||||||
process.stdout.write(eraseLines(5));
|
|
||||||
```
|
|
||||||
|
|
||||||
Or when used inside an inquirer prompt:
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { cursorHide } from '@inquirer/ansi';
|
|
||||||
import { createPrompt } from '@inquirer/core';
|
|
||||||
|
|
||||||
export default createPrompt((config, done: (value: void) => void) => {
|
|
||||||
return `Choose an option${cursorHide}`;
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### Cursor Movement
|
|
||||||
|
|
||||||
- **`cursorUp(count?: number)`** - Move cursor up by `count` lines (default: 1)
|
|
||||||
- **`cursorDown(count?: number)`** - Move cursor down by `count` lines (default: 1)
|
|
||||||
- **`cursorTo(x: number, y?: number)`** - Move cursor to position (x, y). If y is omitted, only moves horizontally
|
|
||||||
- **`cursorLeft`** - Move cursor to beginning of line
|
|
||||||
|
|
||||||
### Cursor Visibility
|
|
||||||
|
|
||||||
- **`cursorHide`** - Hide the cursor
|
|
||||||
- **`cursorShow`** - Show the cursor
|
|
||||||
|
|
||||||
### Screen Manipulation
|
|
||||||
|
|
||||||
- **`eraseLines(count: number)`** - Clear `count` lines and position cursor at the beginning of the first cleared line
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
Copyright (c) 2025 Simon Boudrias (twitter: [@vaxilart](https://twitter.com/Vaxilart))<br/>
|
|
||||||
Licensed under the MIT license.
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@inquirer/ansi",
|
|
||||||
"version": "1.0.2",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18"
|
|
||||||
},
|
|
||||||
"author": "Simon Boudrias <admin@simonboudrias.com>",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/SBoudrias/Inquirer.js.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"answer",
|
|
||||||
"answers",
|
|
||||||
"ask",
|
|
||||||
"base",
|
|
||||||
"cli",
|
|
||||||
"command",
|
|
||||||
"command-line",
|
|
||||||
"confirm",
|
|
||||||
"enquirer",
|
|
||||||
"generate",
|
|
||||||
"generator",
|
|
||||||
"hyper",
|
|
||||||
"input",
|
|
||||||
"inquire",
|
|
||||||
"inquirer",
|
|
||||||
"interface",
|
|
||||||
"iterm",
|
|
||||||
"javascript",
|
|
||||||
"menu",
|
|
||||||
"node",
|
|
||||||
"nodejs",
|
|
||||||
"prompt",
|
|
||||||
"promptly",
|
|
||||||
"prompts",
|
|
||||||
"question",
|
|
||||||
"readline",
|
|
||||||
"scaffold",
|
|
||||||
"scaffolder",
|
|
||||||
"scaffolding",
|
|
||||||
"stdin",
|
|
||||||
"stdout",
|
|
||||||
"terminal",
|
|
||||||
"tty",
|
|
||||||
"ui",
|
|
||||||
"yeoman",
|
|
||||||
"yo",
|
|
||||||
"zsh",
|
|
||||||
"ansi"
|
|
||||||
],
|
|
||||||
"sideEffects": false,
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
|
||||||
"@arethetypeswrong/cli": "^0.18.2",
|
|
||||||
"@repo/tsconfig": "0.0.0",
|
|
||||||
"tshy": "^3.0.3"
|
|
||||||
},
|
|
||||||
"tshy": {
|
|
||||||
"exclude": [
|
|
||||||
"src/**/*.test.ts"
|
|
||||||
],
|
|
||||||
"exports": {
|
|
||||||
"./package.json": "./package.json",
|
|
||||||
".": "./src/index.ts"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"tsc": "tshy",
|
|
||||||
"attw": "attw --pack"
|
|
||||||
},
|
|
||||||
"type": "module",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"exports": {
|
|
||||||
"./package.json": "./package.json",
|
|
||||||
".": {
|
|
||||||
"import": {
|
|
||||||
"types": "./dist/esm/index.d.ts",
|
|
||||||
"default": "./dist/esm/index.js"
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"types": "./dist/commonjs/index.d.ts",
|
|
||||||
"default": "./dist/commonjs/index.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"main": "./dist/commonjs/index.js",
|
|
||||||
"types": "./dist/commonjs/index.d.ts",
|
|
||||||
"module": "./dist/esm/index.js",
|
|
||||||
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/main/packages/ansi/README.md",
|
|
||||||
"gitHead": "6881993e517e76fa891b72e1f5086fd11f7676ac"
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
Copyright (c) 2025 Simon Boudrias
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation
|
|
||||||
files (the "Software"), to deal in the Software without
|
|
||||||
restriction, including without limitation the rights to use,
|
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue