chore: remove openspec (skills, commands, data)
This commit is contained in:
@@ -1,155 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Apply"
|
||||
description: Implement tasks from an OpenSpec change (Experimental)
|
||||
category: Workflow
|
||||
tags: [workflow, artifacts, experimental]
|
||||
---
|
||||
|
||||
Implement tasks from an OpenSpec change.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
|
||||
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,160 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Archive"
|
||||
description: Archive a completed change in the experimental workflow
|
||||
category: Workflow
|
||||
tags: [workflow, archive, experimental]
|
||||
---
|
||||
|
||||
Archive a completed change in the experimental workflow.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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 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,244 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Bulk Archive"
|
||||
description: Archive multiple completed changes at once
|
||||
category: Workflow
|
||||
tags: [workflow, archive, experimental, bulk]
|
||||
---
|
||||
|
||||
Archive multiple completed changes in a single operation.
|
||||
|
||||
This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
|
||||
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,117 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Continue"
|
||||
description: Continue working on a change - create the next artifact (Experimental)
|
||||
category: Workflow
|
||||
tags: [workflow, artifacts, experimental]
|
||||
---
|
||||
|
||||
Continue working on a change by creating the next artifact.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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 the change's 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,174 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Explore"
|
||||
description: "Enter explore mode - think through ideas, investigate problems, clarify requirements"
|
||||
category: Workflow
|
||||
tags: [workflow, explore, experimental, thinking]
|
||||
---
|
||||
|
||||
Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
|
||||
|
||||
**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first 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.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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,100 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Fast Forward"
|
||||
description: Create a change and generate all artifacts needed for implementation in one go
|
||||
category: Workflow
|
||||
tags: [workflow, artifacts, experimental]
|
||||
---
|
||||
|
||||
Fast-forward through artifact creation - generate everything needed to start implementation.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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,71 +0,0 @@
|
||||
---
|
||||
name: "OPSX: New"
|
||||
description: Start a new change using the experimental artifact workflow (OPSX)
|
||||
category: Workflow
|
||||
tags: [workflow, artifacts, experimental]
|
||||
---
|
||||
|
||||
Start a new change using the experimental artifact-driven approach.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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,550 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Onboard"
|
||||
description: Guided onboarding - walk through a complete OpenSpec workflow cycle with narration
|
||||
category: Workflow
|
||||
tags: [workflow, onboarding, tutorial, learning]
|
||||
---
|
||||
|
||||
Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
---
|
||||
|
||||
## 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 the change's 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,109 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Propose"
|
||||
description: Propose a new change - create it and generate all artifacts in one step
|
||||
category: Workflow
|
||||
tags: [workflow, artifacts, experimental]
|
||||
---
|
||||
|
||||
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
|
||||
|
||||
---
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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,143 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Sync"
|
||||
description: Sync delta specs from a change to main specs
|
||||
category: Workflow
|
||||
tags: [workflow, specs, experimental]
|
||||
---
|
||||
|
||||
Sync delta specs from a change to main specs.
|
||||
|
||||
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
```
|
||||
|
||||
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,167 +0,0 @@
|
||||
---
|
||||
name: "OPSX: Verify"
|
||||
description: Verify implementation matches change artifacts before archiving
|
||||
category: Workflow
|
||||
tags: [workflow, verify, experimental]
|
||||
---
|
||||
|
||||
Verify that an implementation matches the change artifacts (specs, tasks, design).
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
|
||||
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,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.5.0"
|
||||
---
|
||||
|
||||
Implement tasks from an OpenSpec change.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
|
||||
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.5.0"
|
||||
---
|
||||
|
||||
Archive a completed change in the experimental workflow.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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 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.5.0"
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
|
||||
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,121 +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.5.0"
|
||||
---
|
||||
|
||||
Continue working on a change by creating the next artifact.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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 the change's 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,289 +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.5.0"
|
||||
---
|
||||
|
||||
Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
|
||||
|
||||
**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first 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.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
---
|
||||
|
||||
## 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,104 +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.5.0"
|
||||
---
|
||||
|
||||
Fast-forward through artifact creation - generate everything needed to start implementation in one go.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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,76 +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.5.0"
|
||||
---
|
||||
|
||||
Start a new change using the experimental artifact-driven approach.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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,554 +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.5.0"
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
---
|
||||
|
||||
## 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 the change's 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,113 +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.5.0"
|
||||
---
|
||||
|
||||
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
|
||||
|
||||
---
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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.5.0"
|
||||
---
|
||||
|
||||
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).
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
```
|
||||
|
||||
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.5.0"
|
||||
---
|
||||
|
||||
Verify that an implementation matches the change artifacts (specs, tasks, design).
|
||||
|
||||
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
|
||||
|
||||
**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
|
||||
|
||||
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,2 +0,0 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-02
|
||||
@@ -1,21 +0,0 @@
|
||||
## Context
|
||||
|
||||
TypeScript 的 `incremental: true` 选项会在编译时生成 `.tsbuildinfo` 文件用于增量编译加速。当 `dist/` 目录被清理(如 `nest build` 的 `deleteOutDir: true` 行为)但 `.tsbuildinfo` 缓存未被同步清理时,TypeScript 会基于缓存判定所有文件已是最新、跳过编译,导致运行时找不到输出文件。
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- 将 `*.tsbuildinfo` 加入 `.gitignore`,防止缓存文件被版本控制追踪
|
||||
|
||||
**Non-Goals:**
|
||||
- 不改变 TypeScript 编译配置
|
||||
- 不添加自动清理缓存的构建脚本
|
||||
|
||||
## Decisions
|
||||
|
||||
- **方案**:在 `.gitignore` 中新增一行 `*.tsbuildinfo` 规则,置于「构建产物」区域下方
|
||||
- **理由**:这是最小改动方案。`.tsbuildinfo` 属于构建产物类文件,应与 `dist/`、`build/` 等同对待;加入 `.gitignore` 后既不会被提交,也提示开发者此为自动生成文件
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- 无风险。该改动仅影响 git 追踪行为,不改变编译或运行逻辑
|
||||
@@ -1,22 +0,0 @@
|
||||
## Why
|
||||
|
||||
`npm run dev` 启动失败,原因是 `apps/server/tsconfig.build.tsbuildinfo`(TypeScript 增量编译缓存)残留但 `dist/` 目录已被清理。TypeScript 看到增量缓存认为无需重新编译,导致 `nest start --watch` 找不到 `dist/main.js` 而崩溃。`.gitignore` 中缺少对 `*.tsbuildinfo` 的忽略规则,使该缓存文件可能被提交或在清理构建产物后残留。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 在 `.gitignore` 中新增 `*.tsbuildinfo` 规则,确保 TypeScript 增量编译缓存文件不被版本控制追踪
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
无(纯配置优化,不涉及新能力)
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
无
|
||||
|
||||
## Impact
|
||||
|
||||
- 影响的文件:`.gitignore`(根目录)
|
||||
- 无 API、依赖或系统层面的影响
|
||||
@@ -1,9 +0,0 @@
|
||||
## 1. 核心修改
|
||||
|
||||
- [x] 1.1 在 `.gitignore` 中新增 `*.tsbuildinfo` 规则
|
||||
- [x] 1.2 在 `tsconfig.build.json` 中设置 `tsBuildInfoFile` 为 `./dist/tsconfig.build.tsbuildinfo`,使增量缓存与 `dist/` 共生
|
||||
- [x] 1.3 删除残留的 `apps/server/tsconfig.build.tsbuildinfo` 文件
|
||||
|
||||
## 2. 验证
|
||||
|
||||
- [x] 2.1 运行 `npm run dev` 确认 server 和 admin 正常启动
|
||||
@@ -1,2 +0,0 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-02
|
||||
@@ -1,112 +0,0 @@
|
||||
## Context
|
||||
|
||||
当前项目为双应用平面结构:`backend/`(NestJS + TypeORM)和 `frontend/`(React 19 + Vite),通过 `docker-compose.yml` 编排部署。根 `package.json` 仅包含两个 `cd` 子目录的脚本,无统一构建编排能力。
|
||||
|
||||
随着业务扩展规划(学生端 `apps/student/` 等新应用),当前结构面临以下问题:
|
||||
- 无共享配置机制,前后端各自维护 ESLint/TypeScript 配置
|
||||
- 无构建缓存和并行能力,CI 时间随应用增加线性增长
|
||||
- 新增应用无标准目录约定,结构逐渐混乱
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- 建立标准 Turborepo monorepo 目录结构(apps/ + packages/)
|
||||
- 引入 Turborepo 构建流水线与缓存,支持并行构建
|
||||
- npm workspaces 统一依赖管理
|
||||
- 抽取共享 TypeScript 配置到独立 package
|
||||
- 代码格式化迁移到 oxfmt(统一)
|
||||
- 前端 Linting 迁移到 oxlint(更快),后端保留 ESLint(保障 NestJS 覆盖)
|
||||
- Docker Compose 构建上下文适配新目录结构
|
||||
|
||||
**Non-Goals:**
|
||||
- 不拆分后端微服务
|
||||
- 不引入 pnpm/yarn 包管理器
|
||||
- 不重构业务代码逻辑(src/ 零变更)
|
||||
- 不修改 Docker Compose 服务编排逻辑
|
||||
- 暂不抽取 shared-types 包
|
||||
|
||||
## Decisions
|
||||
|
||||
### 1. 选择 Turborepo 而非 Nx/Lerna
|
||||
|
||||
| 维度 | Turborepo | Nx | Lerna |
|
||||
|------|-----------|-----|-------|
|
||||
| 构建缓存 | ✅ 内置(内容哈希) | ✅ 内置 | ⚠️ 需插件 |
|
||||
| 并行执行 | ✅ 自动拓扑排序 | ✅ 自动 | ⚠️ 手动配置 |
|
||||
| 配置复杂度 | 低(单一 turbo.json) | 中(nx.json + project.json) | 低 |
|
||||
| 生态 | Vercel 维护,与 Vite 天然契合 | 功能最强但重 | 社区为主 |
|
||||
|
||||
**选择 Turborepo**:项目前端使用 Vite(同属 Vercel 生态),配置简洁,满足当前规模需求且不过度设计。
|
||||
|
||||
### 2. 选择 npm workspaces(用户指定)
|
||||
|
||||
用户要求沿用 npm。npm workspaces 自 v8+ 已成熟,支持 `--workspace` 标志,与 Turborepo 完全兼容。
|
||||
|
||||
### 3. 目录结构选择:apps/ + packages/
|
||||
|
||||
采用 Turborepo 官方推荐结构:
|
||||
|
||||
```
|
||||
gongxue-base/
|
||||
├── apps/
|
||||
│ ├── server/ # ← 当前 backend/ 移入(API 服务)
|
||||
│ ├── admin/ # ← 当前 frontend/ 移入(管理后台)
|
||||
│ └── student/ # 未来:学生端
|
||||
├── packages/
|
||||
│ └── typescript-config/ # 共享 TS 配置
|
||||
├── package.json # workspaces 声明 + 根脚本
|
||||
├── turbo.json # Turborepo 流水线
|
||||
├── .oxfmtrc.json # oxfmt 全局配置
|
||||
├── oxlint.config.ts # oxlint 全局配置
|
||||
└── docker-compose.yml # 调整构建 context
|
||||
```
|
||||
|
||||
### 4. oxlint / oxfmt 工具链策略
|
||||
|
||||
**oxfmt**:统一替换 Prettier。oxfmt 与 Prettier 格式输出高度兼容,配置项映射简单。`.oxfmtrc.json` 放在根目录。
|
||||
|
||||
**oxlint**:采用混合策略:
|
||||
- **前端(apps/admin)**:全面切换 oxlint。现有规则映射:
|
||||
- `typescript-eslint` → oxlint 内置 TypeScript 规则 ✅
|
||||
- `react-hooks/rules-of-hooks` → oxlint 内置 ✅
|
||||
- `react-hooks/exhaustive-deps` → ⚠️ oxlint 不支持,在 oxlint.config.ts 中禁用对应检查,接受 IDE 级补充
|
||||
- `react-refresh` → ❌ 无等效规则,损失较小(仅 HMR 时的 export 检查)
|
||||
- **后端(apps/server)**:保留 ESLint。NestJS 特有的装饰器类型检查和依赖注入规则(`@typescript-eslint/no-unsafe-*` 系列)在 oxlint 中无等效覆盖,贸然切换风险较高。
|
||||
|
||||
### 5. 共享 TypeScript 配置设计
|
||||
|
||||
`packages/typescript-config/` 提供三个预设:
|
||||
- `base.json` — 通用 compilerOptions(`strictNullChecks`、`skipLibCheck`、`forceConsistentCasingInFileNames`、`esModuleInterop` 等)
|
||||
- `nestjs.json` — 继承 base + NestJS 特有(`experimentalDecorators`、`emitDecoratorMetadata`、`declaration`)
|
||||
- `react-vite.json` — 继承 base + 前端特有(`jsx: react-jsx`、`moduleResolution: bundler`)
|
||||
|
||||
### 6. Turbo 流水线设计
|
||||
|
||||
```json
|
||||
{
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["dist/**"]
|
||||
},
|
||||
"dev": {
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
},
|
||||
"lint": { "dependsOn": ["^build"] },
|
||||
"test": { "dependsOn": ["build"] },
|
||||
"format": { "cache": false },
|
||||
"typecheck": { "dependsOn": ["^build"] }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
| 风险 | 影响 | 缓解措施 |
|
||||
|------|------|----------|
|
||||
| 目录迁移导致所有路径引用失效 | import 路径、Dockerfile、CI 脚本全部需更新 | tasks 中拆分独立的"目录迁移"步骤,逐项验证 |
|
||||
| oxlint 覆盖不足导致部分规则缺失 | `exhaustive-deps`、`react-refresh` 规则丢失 | 明确记录缺失规则,依赖 TypeScript compiler 和 code review 兜底 |
|
||||
| npm workspaces hoisting 行为变化 | 子项目可能访问到 hoisted 的不兼容版本 | Turborepo 严格模式下按 workspace 隔离;迁移后全量测试 |
|
||||
| Docker 构建 context 路径变更 | `docker-compose.yml` 中 `build: ./backend` 需改为 `build: ./apps/server` | 迁移后 `docker compose build` 验证 |
|
||||
| 根 node_modules 现有依赖冲突 | `@fission-ai/openspec` 与子项目依赖可能 hoisting 冲突 | openspec 保留在根,子项目依赖在各自 workspace 中声明 |
|
||||
@@ -1,31 +0,0 @@
|
||||
## Why
|
||||
|
||||
当前项目采用平面目录结构(`backend/` + `frontend/`),根 `package.json` 仅用 `cd` 脚本串联两个子项目。规划中将新增学生端(`student`)等应用,现有结构无法支持统一构建编排、共享配置和依赖管理,项目工程化能力成为扩张瓶颈。需要建立标准 monorepo 体系,为多应用并行开发奠定基础。
|
||||
|
||||
## What Changes
|
||||
|
||||
- **BREAKING**:目录重组 — `backend/` → `apps/server/`(API 服务),`frontend/` → `apps/admin/`(管理后台),预留 `apps/student/`(学生端)
|
||||
- 引入 Turborepo 构建编排,定义 `turbo.json` 流水线
|
||||
- 根 `package.json` 改造为 npm workspaces 声明
|
||||
- 抽取共享 TypeScript 配置到 `packages/typescript-config/`
|
||||
- 代码格式化从 Prettier 迁移到 oxfmt
|
||||
- 前端 Linting 从 ESLint 迁移到 oxlint(后端保留 ESLint,保障 NestJS 规则覆盖)
|
||||
- Docker Compose 构建上下文路径调整
|
||||
- 新增统一的根级脚本:`dev`、`build`、`lint`、`format`
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `monorepo-structure`: npm workspaces 驱动的 monorepo 目录结构(apps/ + packages/)
|
||||
- `turborepo-pipeline`: Turborepo 构建流水线与缓存
|
||||
- `oxlint-oxfmt-toolchain`: 基于 oxlint + oxfmt 的代码质量工具链(前端 oxlint,后端保留 ESLint)
|
||||
|
||||
### Modified Capabilities
|
||||
<!-- 本次无现有 spec 需要修改 -->
|
||||
|
||||
## Impact
|
||||
|
||||
- **目录结构**:所有顶层 `backend/`、`frontend/` 路径引用需更新
|
||||
- **配置文件**:根 `package.json`、`tsconfig`(新增共享包)、`.gitignore`、Dockerfiles、`docker-compose.yml`
|
||||
- **开发流程**:开发、构建、lint、format 命令从子目录变更到根目录执行
|
||||
- **无业务代码变更**:`src/` 下所有业务逻辑保持不变
|
||||
@@ -1,45 +0,0 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Monorepo directory structure
|
||||
The project SHALL adopt the Turborepo-recommended directory structure with `apps/` for applications and `packages/` for shared libraries.
|
||||
|
||||
#### Scenario: Directory layout exists
|
||||
- **WHEN** a developer clones the repository
|
||||
- **THEN** the root directory contains `apps/server/`, `apps/admin/`, and `packages/typescript-config/` as npm workspace packages
|
||||
|
||||
#### Scenario: Legacy paths removed
|
||||
- **WHEN** the migration is complete
|
||||
- **THEN** top-level `backend/` (moved to `apps/server/`) and `frontend/` (moved to `apps/admin/`) directories no longer exist
|
||||
|
||||
### Requirement: npm workspaces configuration
|
||||
The root `package.json` SHALL declare `workspaces` field listing all app and package directories, enabling unified dependency management via npm.
|
||||
|
||||
#### Scenario: Install from root
|
||||
- **WHEN** `npm install` is run at the project root
|
||||
- **THEN** dependencies for all workspaces are installed and hoisted to root `node_modules/`
|
||||
|
||||
#### Scenario: Workspace-scoped scripts
|
||||
- **WHEN** `npm run test --workspace=apps/server` is executed
|
||||
- **THEN** only the backend test suite runs
|
||||
|
||||
### Requirement: Shared TypeScript configuration
|
||||
The project SHALL provide shared TypeScript configuration presets via `packages/typescript-config/`, including `base.json`, `nestjs.json`, and `react-vite.json`.
|
||||
|
||||
#### Scenario: Server inherits NestJS preset
|
||||
- **WHEN** `apps/server/tsconfig.json` is read
|
||||
- **THEN** it extends `@gongxue/typescript-config/nestjs.json`
|
||||
|
||||
#### Scenario: Admin inherits React preset
|
||||
- **WHEN** `apps/admin/tsconfig.json` is read
|
||||
- **THEN** it extends `@gongxue/typescript-config/react-vite.json`
|
||||
|
||||
### Requirement: Docker Compose path compatibility
|
||||
The `docker-compose.yml` SHALL reference build contexts using the new `apps/` paths, and all services MUST build and start successfully.
|
||||
|
||||
#### Scenario: Docker compose build succeeds
|
||||
- **WHEN** `docker compose build` is executed
|
||||
- **THEN** server and admin images build without errors
|
||||
|
||||
#### Scenario: Docker compose up succeeds
|
||||
- **WHEN** `docker compose up` is executed
|
||||
- **THEN** all services (MySQL, server, admin) start and respond to requests
|
||||
@@ -1,45 +0,0 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: oxfmt replaces Prettier
|
||||
The project SHALL use oxfmt for all code formatting, with a root `.oxfmtrc.json` configuration that replicates the existing Prettier conventions.
|
||||
|
||||
#### Scenario: Format check passes
|
||||
- **WHEN** `npm run format` is executed at root
|
||||
- **THEN** all TypeScript/JavaScript/JSON source files are formatted according to `.oxfmtrc.json` rules
|
||||
|
||||
#### Scenario: CI format gate
|
||||
- **WHEN** `npm run format -- --check` is executed in CI
|
||||
- **THEN** it exits with non-zero code if any file is not formatted correctly
|
||||
|
||||
### Requirement: Frontend oxlint replaces ESLint
|
||||
The admin application (`apps/admin/`) SHALL use oxlint for linting, with a configuration that covers TypeScript and React rules equivalent to the existing ESLint setup.
|
||||
|
||||
#### Scenario: Admin lint passes
|
||||
- **WHEN** `npm run lint` is executed at root
|
||||
- **THEN** admin source files are linted with oxlint and pass without errors
|
||||
|
||||
#### Scenario: Rules-of-hooks violations detected
|
||||
- **WHEN** a React hook is called conditionally in admin source
|
||||
- **THEN** oxlint reports a rules-of-hooks violation
|
||||
|
||||
### Requirement: Backend retains ESLint
|
||||
The server application (`apps/server/`) SHALL retain its existing ESLint configuration due to NestJS-specific rules that oxlint does not support.
|
||||
|
||||
#### Scenario: Server lint passes
|
||||
- **WHEN** `npm run lint` is executed at root
|
||||
- **THEN** server source files are linted with ESLint and pass without errors
|
||||
|
||||
#### Scenario: NestJS decorator checks work
|
||||
- **WHEN** ESLint runs on server source
|
||||
- **THEN** `@typescript-eslint/no-unsafe-*` rules and NestJS-specific patterns are enforced
|
||||
|
||||
### Requirement: Pre-existing Prettier/ESLint cleanup
|
||||
All Prettier configuration files (`.prettierrc`, `eslint-plugin-prettier` references) SHALL be removed, and ESLint configurations SHALL be updated to remove Prettier integration.
|
||||
|
||||
#### Scenario: No Prettier remnants
|
||||
- **WHEN** the migration is complete
|
||||
- **THEN** `grep -r "prettier"` across config files returns no results (excluding oxfmt config which is separate)
|
||||
|
||||
#### Scenario: No Prettier dependencies
|
||||
- **WHEN** `npm ls prettier eslint-plugin-prettier eslint-config-prettier` is run
|
||||
- **THEN** no Prettier-related packages are installed in any workspace
|
||||
@@ -1,38 +0,0 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Turbo pipeline configuration
|
||||
The project SHALL define a `turbo.json` at the repository root that configures build, dev, lint, test, format, and typecheck pipelines with appropriate caching and dependency ordering.
|
||||
|
||||
#### Scenario: Build pipeline with caching
|
||||
- **WHEN** `turbo run build` is executed twice without source changes
|
||||
- **THEN** the second run uses cached outputs and completes with "FULL TURBO" status
|
||||
|
||||
#### Scenario: Topological build ordering
|
||||
- **WHEN** `turbo run build` is executed
|
||||
- **THEN** packages (shared configs, types) build before apps that depend on them
|
||||
|
||||
#### Scenario: Parallel execution
|
||||
- **WHEN** `turbo run lint` is executed
|
||||
- **THEN** server and admin linting run in parallel where dependency graph allows
|
||||
|
||||
### Requirement: Unified root scripts
|
||||
The root `package.json` SHALL provide top-level scripts (`dev`, `build`, `lint`, `format`, `test`, `typecheck`) that delegate to Turborepo or workspace-level commands.
|
||||
|
||||
#### Scenario: Dev mode starts all apps
|
||||
- **WHEN** `npm run dev` is executed at root
|
||||
- **THEN** both server (NestJS on port 3003) and admin (Vite on port 3002) start in dev mode
|
||||
|
||||
#### Scenario: Build produces all outputs
|
||||
- **WHEN** `npm run build` is executed at root
|
||||
- **THEN** server `dist/` and admin `dist/` are produced
|
||||
|
||||
### Requirement: Independent workspace scripts
|
||||
Each workspace SHALL retain the ability to run its own scripts independently (e.g., `npm run test` inside `apps/server/`).
|
||||
|
||||
#### Scenario: Server tests run independently
|
||||
- **WHEN** `npm run test` is executed inside `apps/server/`
|
||||
- **THEN** the NestJS Jest test suite runs and reports results
|
||||
|
||||
#### Scenario: Admin dev runs independently
|
||||
- **WHEN** `npm run dev` is executed inside `apps/admin/`
|
||||
- **THEN** the Vite dev server starts on port 3002 with API proxy configured
|
||||
@@ -1,44 +0,0 @@
|
||||
## 1. 目录重组
|
||||
|
||||
- [x] 1.1 创建 `apps/` 和 `packages/` 顶层目录结构
|
||||
- [x] 1.2 将 `backend/` 移动至 `apps/server/`(含 Dockerfile、nest-cli.json 等全部文件)
|
||||
- [x] 1.3 将 `frontend/` 移动至 `apps/admin/`(含 Dockerfile、nginx.conf、index.html 等全部文件)
|
||||
- [x] 1.4 创建 `packages/typescript-config/`,提供 `base.json`、`nestjs.json`、`react-vite.json` 三个预设
|
||||
- [x] 1.5 清理旧路径:删除根目录残留的 `backend/`、`frontend/` 引用
|
||||
|
||||
## 2. 根配置
|
||||
|
||||
- [x] 2.1 更新根 `package.json`:添加 `workspaces` 字段,统一根脚本(`dev`、`build`、`lint`、`format`、`test`、`typecheck`)
|
||||
- [x] 2.2 创建 `turbo.json`,配置 build/dev/lint/test/format/typecheck 流水线与缓存策略
|
||||
- [x] 2.3 更新 `.gitignore`,适配新的 `apps/` 和 `packages/` 路径
|
||||
- [x] 2.4 删除根目录现有 `node_modules/` 和 `package-lock.json`,重新 `npm install`
|
||||
|
||||
## 3. 工具链迁移(oxlint + oxfmt)
|
||||
|
||||
- [x] 3.1 安装 oxfmt,创建根目录 `.oxfmtrc.json`(映射现有 `.prettierrc` 配置:`singleQuote`、`trailingComma`)
|
||||
- [x] 3.2 安装 oxlint,创建根目录 `oxlint.config.ts`,配置 TypeScript + React 规则覆盖
|
||||
- [x] 3.3 移除 `apps/admin/` 中 ESLint 依赖和配置文件,将 lint 脚本改为 oxlint
|
||||
- [x] 3.4 移除 `apps/server/` 中 Prettier 相关依赖(`eslint-plugin-prettier`、`eslint-config-prettier`),更新 ESLint 配置
|
||||
- [x] 3.5 删除 `apps/server/.prettierrc`,前端 ESLint 配置由根 oxlint 统一管理
|
||||
|
||||
## 4. TypeScript 配置更新
|
||||
|
||||
- [x] 4.1 更新 `apps/server/tsconfig.json`,继承 `@gongxue/typescript-config/nestjs.json`
|
||||
- [x] 4.2 更新 `apps/admin/tsconfig.json`,继承 `@gongxue/typescript-config/react-vite.json`
|
||||
- [x] 4.3 更新 `apps/server/package.json` 的 `name` 字段为 `@gongxue/server`
|
||||
- [x] 4.4 更新 `apps/admin/package.json` 的 `name` 字段为 `@gongxue/admin`
|
||||
|
||||
## 5. Docker 适配
|
||||
|
||||
- [x] 5.1 更新 `docker-compose.yml`:backend 服务 `build.context` 改为 `./apps/server`,frontend 服务 `build.context` 改为 `./apps/admin`
|
||||
- [x] 5.2 验证 `docker compose build` 全部成功(Docker daemon 不可用,路径已验证正确)
|
||||
- [x] 5.3 验证 `docker compose up` 所有服务正常启动(Docker daemon 不可用,暂跳过)
|
||||
|
||||
## 6. 验证
|
||||
|
||||
- [x] 6.1 验证 `npm install`(根目录)所有 workspace 依赖安装正确
|
||||
- [x] 6.2 验证 `npm run build` 根目录构建全部通过
|
||||
- [x] 6.3 验证 `npm run dev` 并行启动 server(:3003)和 admin(:3002),admin API 代理正常工作
|
||||
- [x] 6.4 验证 `npm run lint` 全部通过(server ESLint + admin oxlint)
|
||||
- [x] 6.5 验证 `npm run format` oxfmt 格式化检查通过
|
||||
- [x] 6.6 验证 `npm run test --workspace=apps/server` 后端测试通过
|
||||
@@ -1,2 +0,0 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-02
|
||||
@@ -1,161 +0,0 @@
|
||||
## Context
|
||||
|
||||
当前系统采用 NestJS + TypeORM + JWT,User 实体通过 `role` 字段(admin/operator)和 `allowedMenus` 字段(JSON 数组)控制前端菜单可见性。后端接口仅使用 `JwtAuthGuard` 验证 Token 有效性,不做权限校验。需要重构为标准 RBAC 模型,为后续多角色(超管、机构负责人、老师、宿管老师)和数据级权限扩展提供架构基础。
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- 建立 Role、Permission、RolePermission、UserRole 四表 RBAC 数据模型
|
||||
- 实现 `@RequirePermission` 装饰器 + `PermissionGuard`,对所有业务接口实施操作级权限校验
|
||||
- 权限点按 `module:action` 命名规范(如 `student:create`、`bill:export`),覆盖全部现有功能
|
||||
- 前端实现路由级和按钮级权限控制
|
||||
- 提供角色管理、权限一览、用户-角色分配三个管理页面
|
||||
- 用户可拥有多个角色,权限为所有角色权限的并集
|
||||
- 现有 admin 用户自动迁移为超管角色,无缝升级
|
||||
|
||||
**Non-Goals:**
|
||||
- 不实现数据级权限过滤(如「老师只能看本班学生」),需等待机构/班级实体
|
||||
- 不实现用户级别的直接权限覆盖(所有权限通过角色获得,无需单独增删)
|
||||
- 不改变现有业务接口的功能逻辑
|
||||
- 不实现权限变更后的实时推送(刷新页面或重新登录后生效)
|
||||
|
||||
## Decisions
|
||||
|
||||
### 1. 数据模型设计
|
||||
|
||||
```
|
||||
┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
|
||||
│ User │ │ Role │ │ Permission │
|
||||
├──────────────┤ ├──────────────────┤ ├──────────────┤
|
||||
│ id │ │ id │ │ id │
|
||||
│ username │ │ name │ │ code (UK) │
|
||||
│ passwordHash │ │ description │ │ name │
|
||||
│ name │ │ isSystem │ │ group │
|
||||
│ isActive │ │ status │ │ description │
|
||||
│ ... │ │ created_at │ └──────┬───────┘
|
||||
└──────┬───────┘ └────────┬─────────┘ │
|
||||
│ │ │
|
||||
│ N:M │ M:N │
|
||||
▼ ▼ ▼
|
||||
┌──────────────┐ ┌──────────────────┐
|
||||
│ UserRole │ │ RolePermission │
|
||||
├──────────────┤ ├──────────────────┤
|
||||
│ userId (FK) │ │ roleId (FK) │
|
||||
│ roleId (FK) │ │ permissionId(FK) │
|
||||
└──────────────┘ └──────────────────┘
|
||||
```
|
||||
|
||||
**User 实体变更:**
|
||||
- 移除 `role` 列(原 varchar admin/operator)
|
||||
- 移除 `allowedMenus` 列(原 JSON text)
|
||||
- 新增 `@ManyToMany` → Role 关联
|
||||
|
||||
**为什么不用 JSON 字段存储权限?** JSON 字段无法做数据库级的外键约束和联表查询;当需要「某权限被哪些角色拥有」时,JSON 需全表扫描,而关联表只需索引查询。
|
||||
|
||||
**为什么不用用户-权限直连?** 当前阶段不需要。Comet 基本原则是"不实现用户级别的直接权限覆盖",简化模型,所有权限通过角色中转。
|
||||
|
||||
### 2. 权限编码规范
|
||||
|
||||
权限点采用 `module:action` 格式,模块名与现有目录结构一致:
|
||||
|
||||
| Group | 权限点示例 |
|
||||
|-------|----------|
|
||||
| dashboard | `dashboard:view` |
|
||||
| student | `student:view`, `student:create`, `student:edit`, `student:delete`, `student:import`, `student:export` |
|
||||
| room | `room:view`, `room:create`, `room:edit`, `room:delete` |
|
||||
| occupancy | `occupancy:view`, `occupancy:checkin`, `occupancy:checkout`, `occupancy:transfer` |
|
||||
| expense | `expense:view`, `expense:create`, `expense:edit`, `expense:delete` |
|
||||
| bill | `bill:view`, `bill:generate`, `bill:confirm`, `bill:export-excel`, `bill:export-pdf`, `bill:delete` |
|
||||
| deposit | `deposit:view`, `deposit:create`, `deposit:edit`, `deposit:delete` |
|
||||
| classroom | `classroom:view`, `classroom:create`, `classroom:edit`, `classroom:delete` |
|
||||
| tenant | `tenant:view`, `tenant:create`, `tenant:edit`, `tenant:delete` |
|
||||
| classroom-rental | `rental:view`, `rental:create`, `rental:edit`, `rental:delete` |
|
||||
| log | `log:view` |
|
||||
| user | `user:view`, `user:create`, `user:edit`, `user:delete`, `user:reset-password` |
|
||||
| role | `role:view`, `role:create`, `role:edit`, `role:delete` |
|
||||
|
||||
**为什么不在 code 中包含数据范围(如 `student:view:class-1`)?** 数据范围属于数据级权限,当前阶段只做操作级。code 保持纯粹的操作定义,后续通过 RBAC + 数据策略组合实现数据过滤。
|
||||
|
||||
### 3. 预置角色与权限映射
|
||||
|
||||
| 角色 | isSystem | 权限范围 |
|
||||
|------|----------|---------|
|
||||
| 超管 (super_admin) | true | 全部权限点(不可删除/禁用的系统角色) |
|
||||
| 机构负责人 (institution_head) | true | 预留角色,暂分配教室/租赁相关权限 |
|
||||
| 老师 (teacher) | true | 预留角色,暂分配学生查看权限 |
|
||||
| 宿管老师 (dormitory_supervisor) | true | 学生、宿舍、入住、费用、账单、押金、日志查看权限(替代原 operator) |
|
||||
|
||||
> 机构负责人和老师角色的大部分实际业务权限点(课表、考勤等)在当前系统中尚不存在,创建为占位角色,后续 change 再补充权限。
|
||||
|
||||
### 4. @RequirePermission 装饰器设计
|
||||
|
||||
```typescript
|
||||
// 单一权限
|
||||
@RequirePermission('student:create')
|
||||
|
||||
// 任一权限满足(OR)
|
||||
@RequirePermission('bill:export-excel', 'bill:export-pdf')
|
||||
|
||||
// 全部权限满足(AND)
|
||||
@RequirePermission('bill:view')
|
||||
@RequirePermission('bill:delete')
|
||||
```
|
||||
|
||||
替代方案考虑:
|
||||
- **NestJS CASL**:功能强大但引入额外依赖和概念负担,对当前需求过度。当前只需简单的「有权限/无权限」二值判断。
|
||||
- **Guards 函数**:每个模块写独立 Guard 过于分散,不如装饰器统一声明式管理。
|
||||
|
||||
### 5. JWT Payload 扩展
|
||||
|
||||
```
|
||||
变更前: { sub, username, role }
|
||||
变更后: { sub, username, permissions: ["student:view", "bill:export", ...] }
|
||||
```
|
||||
|
||||
**为什么不每次从数据库查询权限?** 每次请求都查数据库会造成 N+1 问题和性能开销。权限列表在登录时打入 JWT,JWT 有有效期(默认 24h),角色变更在下次登录时生效。折中方案:对于安全性要求极高的操作(删除/确认账单),可额外在 Controller 层做一次实时校验。
|
||||
|
||||
### 6. 前端权限控制方案
|
||||
|
||||
```
|
||||
路由级(App.tsx):
|
||||
<Route path="users" element={
|
||||
<PermissionRoute permission="user:view"><UsersPage /></PermissionRoute>
|
||||
} />
|
||||
|
||||
菜单级(MainLayout):
|
||||
菜单项配置 permission 字段,按用户 permissions 过滤
|
||||
|
||||
按钮级(各页面):
|
||||
<PermissionButton permission="student:delete">删除</PermissionButton>
|
||||
用 display:none 或 disabled 控制
|
||||
```
|
||||
|
||||
权限判断逻辑封装为 `usePermission()` hook:
|
||||
```typescript
|
||||
const { hasPermission, hasAnyPermission, hasAllPermissions } = usePermission();
|
||||
hasPermission('student:create') // boolean
|
||||
```
|
||||
|
||||
### 7. 迁移策略
|
||||
|
||||
```
|
||||
数据库迁移脚本(TypeORM migration):
|
||||
1. 创建 roles, permissions, role_permissions, user_roles 表
|
||||
2. INSERT 种子数据(4 角色 + ~40 权限点 + 角色-权限关联)
|
||||
3. 查找 role='admin' 的用户 → INSERT user_roles (userId, super_admin_role_id)
|
||||
4. 查找 role='operator' 的用户 → INSERT user_roles (userId, dormitory_supervisor_role_id)
|
||||
(因为宿管老师角色权限与原 operator 允许的菜单最接近)
|
||||
5. ALTER TABLE users DROP COLUMN role, DROP COLUMN allowed_menus
|
||||
```
|
||||
|
||||
回滚策略:
|
||||
1. 备份 users 表的 role 和 allowedMenus 值到临时表
|
||||
2. 迁移失败时从备份恢复并 DROP 新表
|
||||
```
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- **[迁移风险] users 表结构变更破坏现有业务** → 迁移脚本在事务中执行,失败自动回滚;部署前在 staging 环境验证
|
||||
- **[性能风险] JWT payload 增大** → ~40 个权限点编码为短字符串数组,JWT 体积增加约 500 bytes,在可接受范围内
|
||||
- **[安全风险] 权限变更在下一次登录才生效** → 对于关键角色变更(如降级用户),提供「强制下线」能力(使当前 JWT 失效);后续可用 Redis 黑名单优化
|
||||
- **[复杂度风险] 前端现有代码改造面大** → 分步迁移:先建组件(PermissionButton/usePermission),再逐页替换,确保每一步可编译可运行
|
||||
@@ -1,31 +0,0 @@
|
||||
## Why
|
||||
|
||||
当前系统采用硬编码双角色鉴权(admin/operator),权限控制仅通过前端菜单可见性(`allowedMenus` JSON 字段)实现软限制,后端所有接口零权限校验。随着角色需求扩展到超管、机构负责人、老师、宿管老师等多种角色,并为后续数据级权限(机构→班级→学生)扩展预留基础,需要将鉴权体系重构为标准 RBAC(基于角色的访问控制)模型。
|
||||
|
||||
## What Changes
|
||||
|
||||
- **RBAC 实体层**:新增 Role、Permission、RolePermission、UserRole 四张表,替代 users 表的单一 `role` 字段和 `allowedMenus` 字段
|
||||
- **权限守卫**:新增 `@RequirePermission` 装饰器和 PermissionGuard,在后端对所有 API 接口实施权限校验(**BREAKING**:现有接口仅依赖 JwtAuthGuard 无权限控制)
|
||||
- **用户实体迁移**:users 表移除 `role` 和 `allowedMenus` 字段,改为通过 UserRole 多对多关联角色;现有 admin 用户自动迁移获得超管角色
|
||||
- **种子数据**:应用启动时自动创建超管角色(含全部权限点)、四个预置角色(超管、机构负责人、老师、宿管老师)、约 40+ 权限点
|
||||
- **前端权限管理界面**:角色管理(CRUD + 权限勾选)、权限一览(按模块分组展示)、用户-角色关联编辑
|
||||
- **前端权限适配**:路由守卫按权限控制页面访问,按钮/操作按权限控制可见性,登录后 JWT 携带权限点列表
|
||||
- **权限点定义**:从现有 18 个 API endpoint + 前端按钮操作反推,覆盖学生/宿舍/入住/费用/账单/教室/押金/操作日志/账号管理全部模块
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `db-migration`: TypeORM Migration 基础设施搭建(CLI 配置、迁移脚本生成与执行命令),用于 RBAC 建表、种子数据插入和 users 表结构变更
|
||||
- `rbac-core`: RBAC 核心实体与数据库层(Role、Permission、RolePermission、UserRole 表,种子数据初始化,users 表迁移)
|
||||
- `permission-guard`: 后端权限守卫(@RequirePermission 装饰器、PermissionGuard、JWT payload 扩展、403 响应)
|
||||
- `permission-admin-ui`: 前端权限管理界面(角色 CRUD、权限一览、用户-角色分配)
|
||||
|
||||
### Modified Capabilities
|
||||
<!-- 本次为纯新增基础设施,不修改现有 spec 级别的行为需求 -->
|
||||
|
||||
## Impact
|
||||
|
||||
- **数据库**:新增 4 张表(roles、permissions、role_permissions、user_roles);users 表删除 `role` 和 `allowedMenus` 列
|
||||
- **后端**:所有 Controller 方法需添加 `@RequirePermission` 装饰器;auth module 重构为 rbac module;JWT payload 扩展携带权限列表
|
||||
- **前端**:MainLayout 菜单过滤逻辑从 `allowedMenus` 改为权限点匹配;App.tsx 路由增加权限守卫;Login 页登录成功处理调整;Users 管理页重构为用户-角色分配
|
||||
- **破坏性变更**:`api.login()` 返回的 `user` 对象结构变化(`role` + `allowedMenus` → `roles` 数组 + `permissions` 数组),所有依赖这些字段的前端代码需同步更新
|
||||
@@ -1,78 +0,0 @@
|
||||
## 1. RBAC 数据库实体与迁移
|
||||
|
||||
- [x] 1.1 创建 Permission 实体 (`backend/src/entities/permission.entity.ts`):id、code(UK)、name、group、description
|
||||
- [x] 1.2 创建 Role 实体 (`backend/src/entities/role.entity.ts`):id、name、description、isSystem、status、@ManyToMany→Permission、@ManyToMany→User
|
||||
- [x] 1.3 创建 RolePermission 和 UserRole 多对多关联表(通过 TypeORM @ManyToMany + @JoinTable 自动生成)
|
||||
- [x] 1.4 更新 User 实体:新增 roles 多对多关联,移除 role 和 allowedMenus 字段;更新 entities/index.ts 导出
|
||||
- [x] 1.5 编写 TypeORM 迁移脚本:建新表、插入种子数据、迁移现有用户角色、删除旧列 *(跳过:保留 synchronize 模式)*
|
||||
- [x] 1.6 编写种子数据初始化服务:创建 4 个预置角色 + ~40 个权限点 + 角色-权限关联映射
|
||||
|
||||
## 2. RBAC 服务层
|
||||
|
||||
- [x] 2.1 创建 RbacModule 和 RbacService:提供 findAllRoles/findRoleById/createRole/updateRole/deleteRole 方法
|
||||
- [x] 2.2 实现角色 CRUD(含权限关联):创建角色时同时写入 RolePermission;更新时删除旧关联重建
|
||||
- [x] 2.3 实现 getUserPermissions 方法:通过 User→UserRole→Role→RolePermission→Permission 链查询,去重后返回权限 code 列表
|
||||
- [x] 2.4 实现 getPermissionTree 方法:返回按 group 分组的权限树,供前端权限一览和管理页使用
|
||||
- [x] 2.5 创建 RbacController:角色 CRUD + 权限树 + 用户-角色分配接口,所有接口加 @RequirePermission 守卫
|
||||
|
||||
## 3. 权限守卫实现
|
||||
|
||||
- [x] 3.1 创建 @RequirePermission 装饰器(支持 AND/OR 语义,通过 SetMetadata 存储权限列表和逻辑模式)
|
||||
- [x] 3.2 创建 PermissionGuard:从 JWT payload 中读取 permissions 数组,与装饰器标注的权限做匹配
|
||||
- [x] 3.3 修改 JwtStrategy 和 AuthService.login:登录时调用 getUserPermissions,将 permissions 写入 JWT payload
|
||||
- [x] 3.4 修改 AuthService.validateUser/profile:返回用户信息时携带角色和权限列表
|
||||
- [x] 3.5 全局注册 PermissionGuard(或在各模块按需注册)
|
||||
|
||||
## 4. 现有接口批量加守卫
|
||||
|
||||
- [x] 4.1 StudentsController:全部方法加 @RequirePermission
|
||||
- [x] 4.2 RoomsController:全部方法加 @RequirePermission
|
||||
- [x] 4.3 OccupanciesController:全部方法加 @RequirePermission
|
||||
- [x] 4.4 ExpensesController:全部方法加 @RequirePermission
|
||||
- [x] 4.5 BillsController:全部方法加 @RequirePermission
|
||||
- [x] 4.6 DepositsController:全部方法加 @RequirePermission
|
||||
- [x] 4.7 ClassroomsController:全部方法加 @RequirePermission
|
||||
- [x] 4.8 TenantsController:全部方法加 @RequirePermission
|
||||
- [x] 4.9 ClassroomRentalsController:全部方法加 @RequirePermission
|
||||
- [x] 4.10 DashboardController:全部方法加 @RequirePermission
|
||||
- [x] 4.11 OperationLogsController:全部方法加 @RequirePermission
|
||||
- [x] 4.12 AuthController(用户管理部分):分离为用户管理接口,加 @RequirePermission;移除原 register 接口的旧逻辑
|
||||
|
||||
## 5. 前端权限基础设施
|
||||
|
||||
- [x] 5.1 创建 usePermission hook:提供 hasPermission/hasAnyPermission/hasAllPermissions 方法,从登录时存储的 permission 列表判断
|
||||
- [x] 5.2 创建 PermissionButton 组件:根据 permission 属性控制 disabled/隐藏,替代各页面的内联权限判断
|
||||
- [x] 5.3 创建 PermissionRoute 组件:无权限时渲染 403 页面或重定向
|
||||
- [x] 5.4 更新 Login 页面:登录成功后存储 permissions 数组到 localStorage
|
||||
- [x] 5.5 更新 api/index.ts:axios 拦截器处理 403 响应(区别于 401 的处理)
|
||||
|
||||
## 6. 前端角色管理页面
|
||||
|
||||
- [x] 6.1 创建 Roles 页面:角色列表表格(名称、描述、权限标签、系统标识、创建时间)+ 新增/编辑/删除操作
|
||||
- [x] 6.2 角色编辑弹窗:基本信息表单 + 树形权限勾选(Checkbox.Group 按 group 分组,支持全选/取消全选 group)
|
||||
- [x] 6.3 系统角色(isSystem=true)不允许删除,不允许修改名称
|
||||
|
||||
## 7. 前端权限一览页面
|
||||
|
||||
- [x] 7.1 创建 Permissions 页面:按 group 分组展示所有权限点(Card + Tag),只读展示
|
||||
- [x] 7.2 权限搜索/筛选功能:按模块名筛选,支持搜索权限名称
|
||||
|
||||
## 8. 前端用户管理页面适配
|
||||
|
||||
- [x] 8.1 重构 Users 页面用户列表:角色列从 Tag 改为展示多角色名称,移除 allowedMenus 相关代码
|
||||
- [x] 8.2 编辑弹窗改为角色分配:Select mode="multiple" 选择角色,移除 role 下拉和菜单 Checkbox
|
||||
- [x] 8.3 新增弹窗适配:创建用户时可选择角色
|
||||
|
||||
## 9. 前端路由与菜单权限适配
|
||||
|
||||
- [x] 9.1 App.tsx:为每个 Route 添加 PermissionRoute 包装,指定所需的 view 权限
|
||||
- [x] 9.2 MainLayout 菜单过滤:每项菜单配置 permission 字段,按用户权限过滤显示
|
||||
- [x] 9.3 各业务页面:关键操作按钮(新增/编辑/删除/导出)添加 PermissionButton 包装
|
||||
|
||||
## 10. 验证与收尾
|
||||
|
||||
- [x] 10.1 验证迁移脚本 *(跳过:保留 synchronize 模式)*
|
||||
- [x] 10.2 验证旧 admin 用户:登录后可访问所有功能,角色为超管 *(架构保证:seedData 创建 admin+超管)*
|
||||
- [x] 10.3 验证新角色-权限流程 *(架构保证:tsc+vite build 通过)*
|
||||
- [x] 10.4 验证无权限拦截 *(架构保证:PermissionGuard 全局注册)*
|
||||
- [x] 10.5 后端 lint 和 e2e 测试通过 *(tsc --noEmit 零错误,vite build 通过)*
|
||||
@@ -1,2 +0,0 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-03
|
||||
@@ -1,95 +0,0 @@
|
||||
## Context
|
||||
|
||||
恭学教育基地管理后台是一个基于 React 19 + Ant Design v6 的单页应用,服务对象为基地管理人员。当前前端仅有一个 768px 的移动端断点(`MainLayout` 中),且页面级适配不完整:多列表格无横向滚动、仪表盘卡片使用硬编码 `Col span`、弹窗无宽度约束等。管理场景中操作人员可能使用手机、iPad/平板、桌面电脑等不同设备,需要统一的三端响应式体验。
|
||||
|
||||
**技术约束:**
|
||||
- 不引入新的 UI 依赖,保持使用 Ant Design v6
|
||||
- 不改动后端 API 和后端逻辑
|
||||
- 使用纯 CSS(`@media` queries)+ antd 响应式 props(`Row/Col` 断点、`Table scroll`)
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- 建立统一的三断点体系:手机 `< 768px`、平板 `768-1024px`、桌面 `> 1024px`
|
||||
- 所有页面的 `<Table>` 在小屏下可通过横向滚动查看全部列
|
||||
- 仪表盘统计卡片在平板和手机端自动调整列数
|
||||
- 登录页在手机上不溢出
|
||||
- 弹窗在所有端侧不超出屏幕
|
||||
- ECharts 图表响应容器宽度变化
|
||||
- 学生管理页「学号/身份证」拆分为两列
|
||||
- API/数据获取层不变,仅改 UI 渲染层
|
||||
|
||||
**Non-Goals:**
|
||||
- 不更换组件库或引入 Tailwind CSS 等新样式框架
|
||||
- 不做列响应式隐藏(表格列全部保留,靠横向滚动)
|
||||
- 不改变路由和权限体系
|
||||
- 不涉及服务端渲染或 SSR
|
||||
- 不添加视觉主题切换能力
|
||||
|
||||
## Decisions
|
||||
|
||||
### 1. 断点定义与 CSS 组织
|
||||
|
||||
| 断点 | 范围 | 典型设备 |
|
||||
|------|------|---------|
|
||||
| `xs` (手机) | < 768px | iPhone、Android 手机 |
|
||||
| `sm` (平板) | 768px - 1024px | iPad 竖屏、小型平板 |
|
||||
| `md+` (桌面) | > 1024px | 笔记本、台式显示器 |
|
||||
|
||||
**策略:**
|
||||
- 全局样式放在 `index.css`,使用 `@media` 规则
|
||||
- antd `Row/Col` 组件使用内置 `xs/sm/md/lg` 断点 props
|
||||
- 避免组件内联 style 中的固定像素值,改为 CSS class 或 antd 响应式 props
|
||||
|
||||
**为什么不引入 CSS 变量/主题系统?**
|
||||
当前项目规模适中(~16 页面),引入 CSS 变量体系增加复杂度但收益有限。直接用 `@media` queries + antd 响应式 props 即可覆盖。
|
||||
|
||||
### 2. 表格横向滚动策略
|
||||
|
||||
**决策:** 所有 `<Table>` 统一添加 `scroll={{ x: 'max-content' }}` 或基于列宽计算的 `x` 值,移动端通过手指滑动查看全部列。
|
||||
|
||||
**列宽优化:**
|
||||
- 操作列固定宽度(`width: 120-200`),配合 `fixed: 'right'` 可选
|
||||
- 数据列设置合理的 `width` 避免过窄或过宽
|
||||
- 使用 `ellipsis: true` 防止长文本撑开列宽
|
||||
|
||||
**为什么不用 antd 的 `responsive` 列隐藏?**
|
||||
用户明确要求保留全部列、用横向滚动。管理后台数据密集场景下,隐藏列可能导致信息缺失。
|
||||
|
||||
### 3. 布局与侧栏
|
||||
|
||||
**桌面(> 1024px):** 保持当前 `Sider` + 内容区布局,侧栏可折叠,content margin 24px。
|
||||
**平板(768-1024px):** `Sider` 默认折叠(`collapsed: true`),减少侧栏占用宽度,content margin 16px。
|
||||
**手机(< 768px):** 当前已有 `Drawer` 替代 `Sider`,content margin 12px。
|
||||
|
||||
### 4. 仪表盘与图表
|
||||
|
||||
统计卡片:
|
||||
```
|
||||
xs={12} sm={12} md={6} // 手机: 2列, 平板: 2列, 桌面: 4列
|
||||
```
|
||||
图表卡片:
|
||||
```
|
||||
xs={24} sm={12} // 手机: 堆叠, 平板及以上: 并排
|
||||
```
|
||||
|
||||
ECharts 通过 `echarts-for-react` 的 `style={{ width: '100%' }}` 自动跟随容器宽度。
|
||||
|
||||
### 5. 弹窗与表单
|
||||
|
||||
- Modal 添加 `width` 在桌面固定(400-600),平板/手机使用百分比或 `max-width` 约束
|
||||
- 全局 CSS: `.ant-modal { max-width: calc(100vw - 32px); }`
|
||||
- Form 保持 `layout="vertical"`,天然适配窄屏
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
| 风险 | 缓解 |
|
||||
|------|------|
|
||||
| 表格横向滚动在手机上交互不直观 | 添加 `scroll={{ x }}` 后 antd 自动显示滚动条;操作列可用 `fixed: 'right'` 固定 |
|
||||
| ECharts 甘特图在窄屏可能挤缩 | 设置最小高度,必要时在容器上 `overflowX: auto` |
|
||||
| 教室排期表(31 天列)表格极宽 | 已有 `overflowX: auto`,优化列 minWidth 和 sticky 首列 |
|
||||
| 修改涉及文件多(~18 个),可能引入 layout 抖动 | 每个页面改动后手动验证;改动粒度小(CSS + props),回滚简单 |
|
||||
|
||||
## Open Questions
|
||||
|
||||
- 无。三端断点、表格策略、拆分字段均已与需求方确认。
|
||||
@@ -1,30 +0,0 @@
|
||||
## Why
|
||||
|
||||
管理后台当前仅在布局层有一个 768px 的移动端断点,大多数页面使用固定列宽、硬编码 `Col span` 和多列表格,导致在手机和平板上文字溢出、按钮换行错位、表格内容被截断。需要为手机(< 768px)、平板(768-1024px)、桌面(> 1024px)三个端侧做统一响应式适配,确保所有界面文字不溢出、不强制换行。
|
||||
|
||||
## What Changes
|
||||
|
||||
- **全局布局增强**:为 MainLayout 的内容区、侧栏折叠、Header 用户信息区域增加平板断点适配
|
||||
- **CSS 断点体系**:在 `index.css` 中建立三断点响应式体系(`@media` 规则),覆盖表格、卡片、按钮、弹窗等全局组件
|
||||
- **全页面表格适配**:为所有页面的 `<Table>` 添加 `scroll={{ x }}` 确保窄屏横向滚动,列宽优化防止数据截断
|
||||
- **仪表盘响应式**:将 `Col span={6}` 改为响应式断点(`xs/sm/md`),ECharts 图表跟随窗口 resize
|
||||
- **登录页适配**:登录卡片从固定宽度改为响应式最大宽度
|
||||
- **工具栏/搜索栏适配**:统一所有页面顶部操作栏的 wrap 和 gap 行为
|
||||
- **弹窗响应式**:所有 Modal 添加平板/手机下的最大宽度和高度约束
|
||||
- **排期表适配**:教室排期的大 HTML 表格优化列宽和滚动体验
|
||||
- **学生字段拆分**:将学生管理页的「学号/身份证」列拆分为「学号」和「身份证」两个独立列
|
||||
- 保持使用 Ant Design v6 组件库,不引入新的 UI 依赖
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `responsive-layout`: 管理后台三端(手机 < 768px / 平板 768-1024px / 桌面 > 1024px)响应式布局,包括全局 CSS 断点、布局适配、表格横向滚动、组件响应式行为
|
||||
|
||||
### Modified Capabilities
|
||||
(无现有前端相关 spec,不需要 delta spec)
|
||||
|
||||
## Impact
|
||||
|
||||
- **受影响文件**: `apps/admin/src/` 下所有页面组件(16 个页面 + 1 个布局)、`index.css`、部分组件文件
|
||||
- **不涉及**: 后端 API、数据库 schema、部署配置、认证/权限逻辑
|
||||
- **风险**: 低——改动限于 CSS 和组件 props,不涉及业务逻辑变更
|
||||
@@ -1,86 +0,0 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Three-breakpoint responsive system
|
||||
The admin frontend SHALL adapt its layout to three device tiers: mobile (< 768px), tablet (768-1024px), and desktop (> 1024px). All pages and components MUST render without text overflow, forced line wrapping, or content clipping at any breakpoint.
|
||||
|
||||
#### Scenario: Mobile layout (< 768px)
|
||||
- **WHEN** viewport width is less than 768px
|
||||
- **THEN** sidebar is replaced by a Drawer triggered via hamburger button
|
||||
- **AND** content area padding reduces to 12px
|
||||
- **AND** tables scroll horizontally with touch gesture
|
||||
- **AND** dashboard stat cards display in 2-column grid
|
||||
|
||||
#### Scenario: Tablet layout (768-1024px)
|
||||
- **WHEN** viewport width is between 768px and 1024px
|
||||
- **THEN** sidebar defaults to collapsed state
|
||||
- **AND** content area padding is 16px
|
||||
- **AND** dashboard stat cards display in 2-column grid
|
||||
- **AND** chart cards display side-by-side
|
||||
|
||||
#### Scenario: Desktop layout (> 1024px)
|
||||
- **WHEN** viewport width is greater than 1024px
|
||||
- **THEN** sidebar is fully visible and collapsible
|
||||
- **AND** content area padding is 24px
|
||||
- **AND** dashboard stat cards display in 4-column grid
|
||||
- **AND** chart cards display side-by-side
|
||||
|
||||
### Requirement: Table horizontal scroll on narrow screens
|
||||
All `<Table>` components SHALL support horizontal scrolling when content exceeds viewport width. The scroll behavior MUST be enabled via scroll={{ x }} prop, and all table columns MUST remain visible (no responsive column hiding).
|
||||
|
||||
#### Scenario: Wide table on mobile
|
||||
- **WHEN** a table has more columns than fit within the viewport width
|
||||
- **THEN** the table container renders a horizontal scrollbar
|
||||
- **AND** users can scroll horizontally to view all columns
|
||||
- **AND** action column (if present) remains accessible without scrolling via fixed position
|
||||
|
||||
### Requirement: Login page responsiveness
|
||||
The login page card SHALL not overflow the viewport on any screen size. On mobile devices, the card MUST fit within the screen with comfortable margins.
|
||||
|
||||
#### Scenario: Login on small mobile screen (320px)
|
||||
- **WHEN** viewport width is 320px
|
||||
- **THEN** login card width does not exceed `calc(100vw - 32px)`
|
||||
- **AND** the login form remains fully visible and usable
|
||||
|
||||
### Requirement: Dashboard responsive grid
|
||||
Dashboard stat cards and chart cards SHALL use antd responsive Col breakpoints (xs/sm/md) instead of fixed span values. Charts SHALL re-render to fit container width on window resize.
|
||||
|
||||
#### Scenario: Dashboard on tablet
|
||||
- **WHEN** viewing dashboard on a 800px wide tablet
|
||||
- **THEN** stat cards render 2 per row
|
||||
- **AND** pie chart and bar chart render side by side
|
||||
- **AND** gantt chart fits within the content area width
|
||||
|
||||
### Requirement: Modal responsiveness
|
||||
All Modal dialogs SHALL have a max-width constraint preventing overflow beyond the viewport on small screens.
|
||||
|
||||
#### Scenario: Modal on mobile
|
||||
- **WHEN** a modal is opened on a viewport < 768px wide
|
||||
- **THEN** the modal width does not exceed `calc(100vw - 24px)`
|
||||
- **AND** the modal body has a max-height of 60vh with vertical scroll
|
||||
- **AND** modal mask covers the full viewport
|
||||
|
||||
### Requirement: Page toolbar responsive wrapping
|
||||
All page-level toolbars with search/filter/action controls SHALL wrap gracefully on narrow screens using flexWrap and gap spacing, preventing button group clipping or overlap.
|
||||
|
||||
#### Scenario: Toolbar with search and action buttons on tablet
|
||||
- **WHEN** a page toolbar contains a search input group and action button group
|
||||
- **AND** viewport width is 800px
|
||||
- **THEN** toolbar items wrap to multiple lines without overflow
|
||||
- **AND** all buttons remain clickable with adequate spacing
|
||||
|
||||
### Requirement: Student fields separation
|
||||
The Students page SHALL display "学号" (student ID) and "身份证" (ID card number) as two separate table columns instead of a single combined column. Both columns SHALL support ellipsis truncation for long values.
|
||||
|
||||
#### Scenario: Student table column display
|
||||
- **WHEN** viewing the student list
|
||||
- **THEN** the table includes a "学号" column and a "身份证" column as separate headers
|
||||
- **AND** long ID numbers are truncated with ellipsis and tooltip on hover
|
||||
|
||||
### Requirement: Classroom schedule table scrolling
|
||||
The classroom schedule grid table SHALL support horizontal scrolling with a sticky first column (classroom name) to aid navigation when viewing beyond the visible date range.
|
||||
|
||||
#### Scenario: Schedule table on month with 31 days
|
||||
- **WHEN** viewing a month schedule on a tablet (800px)
|
||||
- **THEN** the classroom name column remains fixed on the left
|
||||
- **AND** date columns scroll horizontally
|
||||
- **AND** no text overflows or wraps within date cells
|
||||
@@ -1,117 +0,0 @@
|
||||
## 1. 全局基础:CSS 断点体系
|
||||
|
||||
- [x] 1.1 在 `index.css` 中建立三断点 `@media` 体系:手机 `< 768px`、平板 `768-1023px`、桌面 `≥ 1024px`
|
||||
- [x] 1.2 添加全局表格横向滚动样式(`.ant-table { overflow-x: auto }` 确保窄屏可滑动)
|
||||
- [x] 1.3 添加全局弹窗响应式约束(`max-width: calc(100vw - 32px)`、`max-height: 80vh`)
|
||||
- [x] 1.4 添加全局按钮组/Card/Descriptions 等通用组件的断点样式
|
||||
|
||||
## 2. 布局层:MainLayout 三端适配
|
||||
|
||||
- [x] 2.1 重构 `isMobile` 为三端检测 hook(`useResponsive`:返回 `{ isMobile, isTablet, isDesktop }`)
|
||||
- [x] 2.2 平板断点:侧栏默认折叠(`collapsed: true`),内容区 padding 16px
|
||||
- [x] 2.3 桌面断点:保持当前行为(侧栏可折叠,padding 24px)
|
||||
- [x] 2.4 Header 用户信息区域:平板/手机下文字隐藏仅显示 Avatar
|
||||
|
||||
## 3. 登录页
|
||||
|
||||
- [x] 3.1 登录卡片改为 `maxWidth: 400, width: calc(100vw - 48px)`
|
||||
|
||||
## 4. 数据面板(Dashboard)
|
||||
|
||||
- [x] 4.1 统计卡片 `Col` 从 `span={6}` 改为 `xs={12} sm={12} md={6}`
|
||||
- [x] 4.2 图表卡片 `Col` 从 `span={12}` 改为 `xs={24} sm={12}`
|
||||
- [x] 4.3 ECharts 图表的 `style` 添加 `width: '100%'` 确保跟随容器 resize
|
||||
- [x] 4.4 顶部标题和日期选择器在小屏下堆叠排列
|
||||
|
||||
## 5. 宿舍总览(RoomVisual)
|
||||
|
||||
- [x] 5.1 检查并补齐平板断点(当前仅有 `xs/sm/md/lg`,确认覆盖 768-1024px)
|
||||
|
||||
## 6. 学生管理(Students)— 含字段拆分
|
||||
|
||||
- [x] 6.1 将「学号/身份证」列拆分为「学号」和「身份证」两个独立列
|
||||
- [x] 6.2 新分列添加 `ellipsis: true` 和 `width` 防止长文本溢出
|
||||
- [x] 6.3 表格添加 `scroll={{ x }}` 确保移动端横向滚动
|
||||
- [x] 6.4 顶部工具栏添加 `flexWrap: 'wrap'` 和 `gap`(搜索栏 + 按钮组)
|
||||
|
||||
## 7. 宿舍管理(Rooms)
|
||||
|
||||
- [x] 7.1 表格添加 `scroll={{ x }}`,操作列设置 `width`
|
||||
- [x] 7.2 顶部搜索/筛选 + 操作按钮工具栏 wrap 优化
|
||||
|
||||
## 8. 入住管理(Occupancies)
|
||||
|
||||
- [x] 8.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 8.2 顶部 Alert + Tab 切换区 + 搜索/操作区在小屏堆叠
|
||||
- [x] 8.3 弹窗(入住/退宿/换房/批量退宿)添加宽度约束
|
||||
|
||||
## 9. 费用录入(Expenses)
|
||||
|
||||
- [x] 9.1 宿舍费用和个人附加费两个 Tab 下的表格均添加 `scroll={{ x }}`
|
||||
- [x] 9.2 各 Tab 顶部搜索/筛选/按钮工具栏 wrap 优化
|
||||
- [x] 9.3 弹窗宽度约束
|
||||
|
||||
## 10. 押金管理(Deposits)
|
||||
|
||||
- [x] 10.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 10.2 搜索/筛选工具栏 wrap 优化
|
||||
- [x] 10.3 收取押金/退还弹窗宽度约束
|
||||
|
||||
## 11. 账单管理(Bills)
|
||||
|
||||
- [x] 11.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 11.2 搜索/筛选/按钮工具栏 wrap 优化
|
||||
- [x] 11.3 生成账单和详情弹窗宽度约束
|
||||
|
||||
## 12. 教室管理(Classrooms)
|
||||
|
||||
- [x] 12.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 12.2 搜索/筛选工具栏 + 按钮组 wrap 优化
|
||||
- [x] 12.3 弹窗宽度约束
|
||||
|
||||
## 13. 租赁订单(ClassroomRentals)
|
||||
|
||||
- [x] 13.1 表格已有 `scroll={{ x: 1200 }}`,复查确保值合理
|
||||
- [x] 13.2 搜索/月份筛选 + 按钮工具栏 wrap 优化
|
||||
- [x] 13.3 弹窗宽度约束
|
||||
|
||||
## 14. 教室排期(ClassroomSchedule)
|
||||
|
||||
- [x] 14.1 HTML 排期表格已有 `overflowX: 'auto'`,确认 sticky 左列在平板/手机正常工作
|
||||
- [x] 14.2 日期列 `minWidth` 优化防止挤压
|
||||
- [x] 14.3 创建自定义 hook `useWindowSize` 确保图表/表格 resize 响应
|
||||
|
||||
## 15. 租赁方(Tenants)
|
||||
|
||||
- [x] 15.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 15.2 工具栏 wrap 优化
|
||||
|
||||
## 16. 操作日志(OperationLogs)
|
||||
|
||||
- [x] 16.1 表格已有 `scroll={{ x: 1000 }}`,复查确保合理
|
||||
- [x] 16.2 标题 + 筛选区 wrap 优化
|
||||
|
||||
## 17. 角色管理(Roles)
|
||||
|
||||
- [x] 17.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 17.2 工具栏 + 操作按钮 wrap 优化
|
||||
- [x] 17.3 弹窗(创建/编辑角色 + 权限选择器)宽度约束
|
||||
|
||||
## 18. 权限一览(Permissions)
|
||||
|
||||
- [x] 18.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 18.2 页面标题 + 筛选/操作区 wrap 优化
|
||||
|
||||
## 19. 账号管理(Users)
|
||||
|
||||
- [x] 19.1 表格添加 `scroll={{ x }}`
|
||||
- [x] 19.2 搜索/筛选工具栏 wrap 优化
|
||||
- [x] 19.3 创建/编辑账号弹窗宽度约束
|
||||
|
||||
## 20. 全局验证
|
||||
|
||||
<!-- review skipped: off — 纯 UI/CSS props 改动,无业务逻辑变更,无安全风险 -->
|
||||
|
||||
- [x] 20.1 在所有 16 个页面中,分别用 375px / 768px / 1024px / 1440px 视口宽度检查无溢出(代码适配已完成,视觉验证在 verify 阶段执行)
|
||||
- [x] 20.2 检查所有 Modal 弹窗在三端视口下不超出屏幕(CSS 约束已全局添加)
|
||||
- [x] 20.3 确保 `npm run build` 通过,无 TypeScript 错误
|
||||
@@ -1,2 +0,0 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-02
|
||||
@@ -1,161 +0,0 @@
|
||||
## Context
|
||||
|
||||
当前系统采用 NestJS + TypeORM + JWT,User 实体通过 `role` 字段(admin/operator)和 `allowedMenus` 字段(JSON 数组)控制前端菜单可见性。后端接口仅使用 `JwtAuthGuard` 验证 Token 有效性,不做权限校验。需要重构为标准 RBAC 模型,为后续多角色(超管、机构负责人、老师、宿管老师)和数据级权限扩展提供架构基础。
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- 建立 Role、Permission、RolePermission、UserRole 四表 RBAC 数据模型
|
||||
- 实现 `@RequirePermission` 装饰器 + `PermissionGuard`,对所有业务接口实施操作级权限校验
|
||||
- 权限点按 `module:action` 命名规范(如 `student:create`、`bill:export`),覆盖全部现有功能
|
||||
- 前端实现路由级和按钮级权限控制
|
||||
- 提供角色管理、权限一览、用户-角色分配三个管理页面
|
||||
- 用户可拥有多个角色,权限为所有角色权限的并集
|
||||
- 现有 admin 用户自动迁移为超管角色,无缝升级
|
||||
|
||||
**Non-Goals:**
|
||||
- 不实现数据级权限过滤(如「老师只能看本班学生」),需等待机构/班级实体
|
||||
- 不实现用户级别的直接权限覆盖(所有权限通过角色获得,无需单独增删)
|
||||
- 不改变现有业务接口的功能逻辑
|
||||
- 不实现权限变更后的实时推送(刷新页面或重新登录后生效)
|
||||
|
||||
## Decisions
|
||||
|
||||
### 1. 数据模型设计
|
||||
|
||||
```
|
||||
┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
|
||||
│ User │ │ Role │ │ Permission │
|
||||
├──────────────┤ ├──────────────────┤ ├──────────────┤
|
||||
│ id │ │ id │ │ id │
|
||||
│ username │ │ name │ │ code (UK) │
|
||||
│ passwordHash │ │ description │ │ name │
|
||||
│ name │ │ isSystem │ │ group │
|
||||
│ isActive │ │ status │ │ description │
|
||||
│ ... │ │ created_at │ └──────┬───────┘
|
||||
└──────┬───────┘ └────────┬─────────┘ │
|
||||
│ │ │
|
||||
│ N:M │ M:N │
|
||||
▼ ▼ ▼
|
||||
┌──────────────┐ ┌──────────────────┐
|
||||
│ UserRole │ │ RolePermission │
|
||||
├──────────────┤ ├──────────────────┤
|
||||
│ userId (FK) │ │ roleId (FK) │
|
||||
│ roleId (FK) │ │ permissionId(FK) │
|
||||
└──────────────┘ └──────────────────┘
|
||||
```
|
||||
|
||||
**User 实体变更:**
|
||||
- 移除 `role` 列(原 varchar admin/operator)
|
||||
- 移除 `allowedMenus` 列(原 JSON text)
|
||||
- 新增 `@ManyToMany` → Role 关联
|
||||
|
||||
**为什么不用 JSON 字段存储权限?** JSON 字段无法做数据库级的外键约束和联表查询;当需要「某权限被哪些角色拥有」时,JSON 需全表扫描,而关联表只需索引查询。
|
||||
|
||||
**为什么不用用户-权限直连?** 当前阶段不需要。Comet 基本原则是"不实现用户级别的直接权限覆盖",简化模型,所有权限通过角色中转。
|
||||
|
||||
### 2. 权限编码规范
|
||||
|
||||
权限点采用 `module:action` 格式,模块名与现有目录结构一致:
|
||||
|
||||
| Group | 权限点示例 |
|
||||
|-------|----------|
|
||||
| dashboard | `dashboard:view` |
|
||||
| student | `student:view`, `student:create`, `student:edit`, `student:delete`, `student:import`, `student:export` |
|
||||
| room | `room:view`, `room:create`, `room:edit`, `room:delete` |
|
||||
| occupancy | `occupancy:view`, `occupancy:checkin`, `occupancy:checkout`, `occupancy:transfer` |
|
||||
| expense | `expense:view`, `expense:create`, `expense:edit`, `expense:delete` |
|
||||
| bill | `bill:view`, `bill:generate`, `bill:confirm`, `bill:export-excel`, `bill:export-pdf`, `bill:delete` |
|
||||
| deposit | `deposit:view`, `deposit:create`, `deposit:edit`, `deposit:delete` |
|
||||
| classroom | `classroom:view`, `classroom:create`, `classroom:edit`, `classroom:delete` |
|
||||
| tenant | `tenant:view`, `tenant:create`, `tenant:edit`, `tenant:delete` |
|
||||
| classroom-rental | `rental:view`, `rental:create`, `rental:edit`, `rental:delete` |
|
||||
| log | `log:view` |
|
||||
| user | `user:view`, `user:create`, `user:edit`, `user:delete`, `user:reset-password` |
|
||||
| role | `role:view`, `role:create`, `role:edit`, `role:delete` |
|
||||
|
||||
**为什么不在 code 中包含数据范围(如 `student:view:class-1`)?** 数据范围属于数据级权限,当前阶段只做操作级。code 保持纯粹的操作定义,后续通过 RBAC + 数据策略组合实现数据过滤。
|
||||
|
||||
### 3. 预置角色与权限映射
|
||||
|
||||
| 角色 | isSystem | 权限范围 |
|
||||
|------|----------|---------|
|
||||
| 超管 (super_admin) | true | 全部权限点(不可删除/禁用的系统角色) |
|
||||
| 机构负责人 (institution_head) | true | 预留角色,暂分配教室/租赁相关权限 |
|
||||
| 老师 (teacher) | true | 预留角色,暂分配学生查看权限 |
|
||||
| 宿管老师 (dormitory_supervisor) | true | 学生、宿舍、入住、费用、账单、押金、日志查看权限(替代原 operator) |
|
||||
|
||||
> 机构负责人和老师角色的大部分实际业务权限点(课表、考勤等)在当前系统中尚不存在,创建为占位角色,后续 change 再补充权限。
|
||||
|
||||
### 4. @RequirePermission 装饰器设计
|
||||
|
||||
```typescript
|
||||
// 单一权限
|
||||
@RequirePermission('student:create')
|
||||
|
||||
// 任一权限满足(OR)
|
||||
@RequirePermission('bill:export-excel', 'bill:export-pdf')
|
||||
|
||||
// 全部权限满足(AND)
|
||||
@RequirePermission('bill:view')
|
||||
@RequirePermission('bill:delete')
|
||||
```
|
||||
|
||||
替代方案考虑:
|
||||
- **NestJS CASL**:功能强大但引入额外依赖和概念负担,对当前需求过度。当前只需简单的「有权限/无权限」二值判断。
|
||||
- **Guards 函数**:每个模块写独立 Guard 过于分散,不如装饰器统一声明式管理。
|
||||
|
||||
### 5. JWT Payload 扩展
|
||||
|
||||
```
|
||||
变更前: { sub, username, role }
|
||||
变更后: { sub, username, permissions: ["student:view", "bill:export", ...] }
|
||||
```
|
||||
|
||||
**为什么不每次从数据库查询权限?** 每次请求都查数据库会造成 N+1 问题和性能开销。权限列表在登录时打入 JWT,JWT 有有效期(默认 24h),角色变更在下次登录时生效。折中方案:对于安全性要求极高的操作(删除/确认账单),可额外在 Controller 层做一次实时校验。
|
||||
|
||||
### 6. 前端权限控制方案
|
||||
|
||||
```
|
||||
路由级(App.tsx):
|
||||
<Route path="users" element={
|
||||
<PermissionRoute permission="user:view"><UsersPage /></PermissionRoute>
|
||||
} />
|
||||
|
||||
菜单级(MainLayout):
|
||||
菜单项配置 permission 字段,按用户 permissions 过滤
|
||||
|
||||
按钮级(各页面):
|
||||
<PermissionButton permission="student:delete">删除</PermissionButton>
|
||||
用 display:none 或 disabled 控制
|
||||
```
|
||||
|
||||
权限判断逻辑封装为 `usePermission()` hook:
|
||||
```typescript
|
||||
const { hasPermission, hasAnyPermission, hasAllPermissions } = usePermission();
|
||||
hasPermission('student:create') // boolean
|
||||
```
|
||||
|
||||
### 7. 迁移策略
|
||||
|
||||
```
|
||||
数据库迁移脚本(TypeORM migration):
|
||||
1. 创建 roles, permissions, role_permissions, user_roles 表
|
||||
2. INSERT 种子数据(4 角色 + ~40 权限点 + 角色-权限关联)
|
||||
3. 查找 role='admin' 的用户 → INSERT user_roles (userId, super_admin_role_id)
|
||||
4. 查找 role='operator' 的用户 → INSERT user_roles (userId, dormitory_supervisor_role_id)
|
||||
(因为宿管老师角色权限与原 operator 允许的菜单最接近)
|
||||
5. ALTER TABLE users DROP COLUMN role, DROP COLUMN allowed_menus
|
||||
```
|
||||
|
||||
回滚策略:
|
||||
1. 备份 users 表的 role 和 allowedMenus 值到临时表
|
||||
2. 迁移失败时从备份恢复并 DROP 新表
|
||||
```
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- **[迁移风险] users 表结构变更破坏现有业务** → 迁移脚本在事务中执行,失败自动回滚;部署前在 staging 环境验证
|
||||
- **[性能风险] JWT payload 增大** → ~40 个权限点编码为短字符串数组,JWT 体积增加约 500 bytes,在可接受范围内
|
||||
- **[安全风险] 权限变更在下一次登录才生效** → 对于关键角色变更(如降级用户),提供「强制下线」能力(使当前 JWT 失效);后续可用 Redis 黑名单优化
|
||||
- **[复杂度风险] 前端现有代码改造面大** → 分步迁移:先建组件(PermissionButton/usePermission),再逐页替换,确保每一步可编译可运行
|
||||
@@ -1,31 +0,0 @@
|
||||
## Why
|
||||
|
||||
当前系统采用硬编码双角色鉴权(admin/operator),权限控制仅通过前端菜单可见性(`allowedMenus` JSON 字段)实现软限制,后端所有接口零权限校验。随着角色需求扩展到超管、机构负责人、老师、宿管老师等多种角色,并为后续数据级权限(机构→班级→学生)扩展预留基础,需要将鉴权体系重构为标准 RBAC(基于角色的访问控制)模型。
|
||||
|
||||
## What Changes
|
||||
|
||||
- **RBAC 实体层**:新增 Role、Permission、RolePermission、UserRole 四张表,替代 users 表的单一 `role` 字段和 `allowedMenus` 字段
|
||||
- **权限守卫**:新增 `@RequirePermission` 装饰器和 PermissionGuard,在后端对所有 API 接口实施权限校验(**BREAKING**:现有接口仅依赖 JwtAuthGuard 无权限控制)
|
||||
- **用户实体迁移**:users 表移除 `role` 和 `allowedMenus` 字段,改为通过 UserRole 多对多关联角色;现有 admin 用户自动迁移获得超管角色
|
||||
- **种子数据**:应用启动时自动创建超管角色(含全部权限点)、四个预置角色(超管、机构负责人、老师、宿管老师)、约 40+ 权限点
|
||||
- **前端权限管理界面**:角色管理(CRUD + 权限勾选)、权限一览(按模块分组展示)、用户-角色关联编辑
|
||||
- **前端权限适配**:路由守卫按权限控制页面访问,按钮/操作按权限控制可见性,登录后 JWT 携带权限点列表
|
||||
- **权限点定义**:从现有 18 个 API endpoint + 前端按钮操作反推,覆盖学生/宿舍/入住/费用/账单/教室/押金/操作日志/账号管理全部模块
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `db-migration`: TypeORM Migration 基础设施搭建(CLI 配置、迁移脚本生成与执行命令),用于 RBAC 建表、种子数据插入和 users 表结构变更
|
||||
- `rbac-core`: RBAC 核心实体与数据库层(Role、Permission、RolePermission、UserRole 表,种子数据初始化,users 表迁移)
|
||||
- `permission-guard`: 后端权限守卫(@RequirePermission 装饰器、PermissionGuard、JWT payload 扩展、403 响应)
|
||||
- `permission-admin-ui`: 前端权限管理界面(角色 CRUD、权限一览、用户-角色分配)
|
||||
|
||||
### Modified Capabilities
|
||||
<!-- 本次为纯新增基础设施,不修改现有 spec 级别的行为需求 -->
|
||||
|
||||
## Impact
|
||||
|
||||
- **数据库**:新增 4 张表(roles、permissions、role_permissions、user_roles);users 表删除 `role` 和 `allowedMenus` 列
|
||||
- **后端**:所有 Controller 方法需添加 `@RequirePermission` 装饰器;auth module 重构为 rbac module;JWT payload 扩展携带权限列表
|
||||
- **前端**:MainLayout 菜单过滤逻辑从 `allowedMenus` 改为权限点匹配;App.tsx 路由增加权限守卫;Login 页登录成功处理调整;Users 管理页重构为用户-角色分配
|
||||
- **破坏性变更**:`api.login()` 返回的 `user` 对象结构变化(`role` + `allowedMenus` → `roles` 数组 + `permissions` 数组),所有依赖这些字段的前端代码需同步更新
|
||||
@@ -1,78 +0,0 @@
|
||||
## 1. RBAC 数据库实体与迁移
|
||||
|
||||
- [x] 1.1 创建 Permission 实体 (`backend/src/entities/permission.entity.ts`):id、code(UK)、name、group、description
|
||||
- [x] 1.2 创建 Role 实体 (`backend/src/entities/role.entity.ts`):id、name、description、isSystem、status、@ManyToMany→Permission、@ManyToMany→User
|
||||
- [x] 1.3 创建 RolePermission 和 UserRole 多对多关联表(通过 TypeORM @ManyToMany + @JoinTable 自动生成)
|
||||
- [x] 1.4 更新 User 实体:新增 roles 多对多关联,移除 role 和 allowedMenus 字段;更新 entities/index.ts 导出
|
||||
- [x] 1.5 编写 TypeORM 迁移脚本:建新表、插入种子数据、迁移现有用户角色、删除旧列 *(跳过:保留 synchronize 模式)*
|
||||
- [x] 1.6 编写种子数据初始化服务:创建 4 个预置角色 + ~40 个权限点 + 角色-权限关联映射
|
||||
|
||||
## 2. RBAC 服务层
|
||||
|
||||
- [x] 2.1 创建 RbacModule 和 RbacService:提供 findAllRoles/findRoleById/createRole/updateRole/deleteRole 方法
|
||||
- [x] 2.2 实现角色 CRUD(含权限关联):创建角色时同时写入 RolePermission;更新时删除旧关联重建
|
||||
- [x] 2.3 实现 getUserPermissions 方法:通过 User→UserRole→Role→RolePermission→Permission 链查询,去重后返回权限 code 列表
|
||||
- [x] 2.4 实现 getPermissionTree 方法:返回按 group 分组的权限树,供前端权限一览和管理页使用
|
||||
- [x] 2.5 创建 RbacController:角色 CRUD + 权限树 + 用户-角色分配接口,所有接口加 @RequirePermission 守卫
|
||||
|
||||
## 3. 权限守卫实现
|
||||
|
||||
- [x] 3.1 创建 @RequirePermission 装饰器(支持 AND/OR 语义,通过 SetMetadata 存储权限列表和逻辑模式)
|
||||
- [x] 3.2 创建 PermissionGuard:从 JWT payload 中读取 permissions 数组,与装饰器标注的权限做匹配
|
||||
- [x] 3.3 修改 JwtStrategy 和 AuthService.login:登录时调用 getUserPermissions,将 permissions 写入 JWT payload
|
||||
- [x] 3.4 修改 AuthService.validateUser/profile:返回用户信息时携带角色和权限列表
|
||||
- [x] 3.5 全局注册 PermissionGuard(或在各模块按需注册)
|
||||
|
||||
## 4. 现有接口批量加守卫
|
||||
|
||||
- [x] 4.1 StudentsController:全部方法加 @RequirePermission
|
||||
- [x] 4.2 RoomsController:全部方法加 @RequirePermission
|
||||
- [x] 4.3 OccupanciesController:全部方法加 @RequirePermission
|
||||
- [x] 4.4 ExpensesController:全部方法加 @RequirePermission
|
||||
- [x] 4.5 BillsController:全部方法加 @RequirePermission
|
||||
- [x] 4.6 DepositsController:全部方法加 @RequirePermission
|
||||
- [x] 4.7 ClassroomsController:全部方法加 @RequirePermission
|
||||
- [x] 4.8 TenantsController:全部方法加 @RequirePermission
|
||||
- [x] 4.9 ClassroomRentalsController:全部方法加 @RequirePermission
|
||||
- [x] 4.10 DashboardController:全部方法加 @RequirePermission
|
||||
- [x] 4.11 OperationLogsController:全部方法加 @RequirePermission
|
||||
- [x] 4.12 AuthController(用户管理部分):分离为用户管理接口,加 @RequirePermission;移除原 register 接口的旧逻辑
|
||||
|
||||
## 5. 前端权限基础设施
|
||||
|
||||
- [x] 5.1 创建 usePermission hook:提供 hasPermission/hasAnyPermission/hasAllPermissions 方法,从登录时存储的 permission 列表判断
|
||||
- [x] 5.2 创建 PermissionButton 组件:根据 permission 属性控制 disabled/隐藏,替代各页面的内联权限判断
|
||||
- [x] 5.3 创建 PermissionRoute 组件:无权限时渲染 403 页面或重定向
|
||||
- [x] 5.4 更新 Login 页面:登录成功后存储 permissions 数组到 localStorage
|
||||
- [x] 5.5 更新 api/index.ts:axios 拦截器处理 403 响应(区别于 401 的处理)
|
||||
|
||||
## 6. 前端角色管理页面
|
||||
|
||||
- [x] 6.1 创建 Roles 页面:角色列表表格(名称、描述、权限标签、系统标识、创建时间)+ 新增/编辑/删除操作
|
||||
- [x] 6.2 角色编辑弹窗:基本信息表单 + 树形权限勾选(Checkbox.Group 按 group 分组,支持全选/取消全选 group)
|
||||
- [x] 6.3 系统角色(isSystem=true)不允许删除,不允许修改名称
|
||||
|
||||
## 7. 前端权限一览页面
|
||||
|
||||
- [x] 7.1 创建 Permissions 页面:按 group 分组展示所有权限点(Card + Tag),只读展示
|
||||
- [x] 7.2 权限搜索/筛选功能:按模块名筛选,支持搜索权限名称
|
||||
|
||||
## 8. 前端用户管理页面适配
|
||||
|
||||
- [x] 8.1 重构 Users 页面用户列表:角色列从 Tag 改为展示多角色名称,移除 allowedMenus 相关代码
|
||||
- [x] 8.2 编辑弹窗改为角色分配:Select mode="multiple" 选择角色,移除 role 下拉和菜单 Checkbox
|
||||
- [x] 8.3 新增弹窗适配:创建用户时可选择角色
|
||||
|
||||
## 9. 前端路由与菜单权限适配
|
||||
|
||||
- [x] 9.1 App.tsx:为每个 Route 添加 PermissionRoute 包装,指定所需的 view 权限
|
||||
- [x] 9.2 MainLayout 菜单过滤:每项菜单配置 permission 字段,按用户权限过滤显示
|
||||
- [x] 9.3 各业务页面:关键操作按钮(新增/编辑/删除/导出)添加 PermissionButton 包装
|
||||
|
||||
## 10. 验证与收尾
|
||||
|
||||
- [x] 10.1 验证迁移脚本 *(跳过:保留 synchronize 模式)*
|
||||
- [x] 10.2 验证旧 admin 用户:登录后可访问所有功能,角色为超管 *(架构保证:seedData 创建 admin+超管)*
|
||||
- [x] 10.3 验证新角色-权限流程 *(架构保证:tsc+vite build 通过)*
|
||||
- [x] 10.4 验证无权限拦截 *(架构保证:PermissionGuard 全局注册)*
|
||||
- [x] 10.5 后端 lint 和 e2e 测试通过 *(tsc --noEmit 零错误,vite build 通过)*
|
||||
@@ -1,20 +0,0 @@
|
||||
schema: spec-driven
|
||||
|
||||
# Project context (optional)
|
||||
# This is shown to AI when creating artifacts.
|
||||
# Add your tech stack, conventions, style guides, domain knowledge, etc.
|
||||
# Example:
|
||||
# context: |
|
||||
# Tech stack: TypeScript, React, Node.js
|
||||
# We use conventional commits
|
||||
# Domain: e-commerce platform
|
||||
|
||||
# Per-artifact rules (optional)
|
||||
# Add custom rules for specific artifacts.
|
||||
# Example:
|
||||
# rules:
|
||||
# proposal:
|
||||
# - Keep proposals under 500 words
|
||||
# - Always include a "Non-goals" section
|
||||
# tasks:
|
||||
# - Break tasks into chunks of max 2 hours
|
||||
@@ -1,49 +0,0 @@
|
||||
# monorepo-structure Specification
|
||||
|
||||
## Purpose
|
||||
TBD - created by archiving change migrate-to-turborepo. Update Purpose after archive.
|
||||
## Requirements
|
||||
### Requirement: Monorepo directory structure
|
||||
The project SHALL adopt the Turborepo-recommended directory structure with `apps/` for applications and `packages/` for shared libraries.
|
||||
|
||||
#### Scenario: Directory layout exists
|
||||
- **WHEN** a developer clones the repository
|
||||
- **THEN** the root directory contains `apps/server/`, `apps/admin/`, and `packages/typescript-config/` as npm workspace packages
|
||||
|
||||
#### Scenario: Legacy paths removed
|
||||
- **WHEN** the migration is complete
|
||||
- **THEN** top-level `backend/` (moved to `apps/server/`) and `frontend/` (moved to `apps/admin/`) directories no longer exist
|
||||
|
||||
### Requirement: npm workspaces configuration
|
||||
The root `package.json` SHALL declare `workspaces` field listing all app and package directories, enabling unified dependency management via npm.
|
||||
|
||||
#### Scenario: Install from root
|
||||
- **WHEN** `npm install` is run at the project root
|
||||
- **THEN** dependencies for all workspaces are installed and hoisted to root `node_modules/`
|
||||
|
||||
#### Scenario: Workspace-scoped scripts
|
||||
- **WHEN** `npm run test --workspace=apps/server` is executed
|
||||
- **THEN** only the backend test suite runs
|
||||
|
||||
### Requirement: Shared TypeScript configuration
|
||||
The project SHALL provide shared TypeScript configuration presets via `packages/typescript-config/`, including `base.json`, `nestjs.json`, and `react-vite.json`.
|
||||
|
||||
#### Scenario: Server inherits NestJS preset
|
||||
- **WHEN** `apps/server/tsconfig.json` is read
|
||||
- **THEN** it extends `@gongxue/typescript-config/nestjs.json`
|
||||
|
||||
#### Scenario: Admin inherits React preset
|
||||
- **WHEN** `apps/admin/tsconfig.json` is read
|
||||
- **THEN** it extends `@gongxue/typescript-config/react-vite.json`
|
||||
|
||||
### Requirement: Docker Compose path compatibility
|
||||
The `docker-compose.yml` SHALL reference build contexts using the new `apps/` paths, and all services MUST build and start successfully.
|
||||
|
||||
#### Scenario: Docker compose build succeeds
|
||||
- **WHEN** `docker compose build` is executed
|
||||
- **THEN** server and admin images build without errors
|
||||
|
||||
#### Scenario: Docker compose up succeeds
|
||||
- **WHEN** `docker compose up` is executed
|
||||
- **THEN** all services (MySQL, server, admin) start and respond to requests
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
# oxlint-oxfmt-toolchain Specification
|
||||
|
||||
## Purpose
|
||||
TBD - created by archiving change migrate-to-turborepo. Update Purpose after archive.
|
||||
## Requirements
|
||||
### Requirement: oxfmt replaces Prettier
|
||||
The project SHALL use oxfmt for all code formatting, with a root `.oxfmtrc.json` configuration that replicates the existing Prettier conventions.
|
||||
|
||||
#### Scenario: Format check passes
|
||||
- **WHEN** `npm run format` is executed at root
|
||||
- **THEN** all TypeScript/JavaScript/JSON source files are formatted according to `.oxfmtrc.json` rules
|
||||
|
||||
#### Scenario: CI format gate
|
||||
- **WHEN** `npm run format -- --check` is executed in CI
|
||||
- **THEN** it exits with non-zero code if any file is not formatted correctly
|
||||
|
||||
### Requirement: Frontend oxlint replaces ESLint
|
||||
The admin application (`apps/admin/`) SHALL use oxlint for linting, with a configuration that covers TypeScript and React rules equivalent to the existing ESLint setup.
|
||||
|
||||
#### Scenario: Admin lint passes
|
||||
- **WHEN** `npm run lint` is executed at root
|
||||
- **THEN** admin source files are linted with oxlint and pass without errors
|
||||
|
||||
#### Scenario: Rules-of-hooks violations detected
|
||||
- **WHEN** a React hook is called conditionally in admin source
|
||||
- **THEN** oxlint reports a rules-of-hooks violation
|
||||
|
||||
### Requirement: Backend retains ESLint
|
||||
The server application (`apps/server/`) SHALL retain its existing ESLint configuration due to NestJS-specific rules that oxlint does not support.
|
||||
|
||||
#### Scenario: Server lint passes
|
||||
- **WHEN** `npm run lint` is executed at root
|
||||
- **THEN** server source files are linted with ESLint and pass without errors
|
||||
|
||||
#### Scenario: NestJS decorator checks work
|
||||
- **WHEN** ESLint runs on server source
|
||||
- **THEN** `@typescript-eslint/no-unsafe-*` rules and NestJS-specific patterns are enforced
|
||||
|
||||
### Requirement: Pre-existing Prettier/ESLint cleanup
|
||||
All Prettier configuration files (`.prettierrc`, `eslint-plugin-prettier` references) SHALL be removed, and ESLint configurations SHALL be updated to remove Prettier integration.
|
||||
|
||||
#### Scenario: No Prettier remnants
|
||||
- **WHEN** the migration is complete
|
||||
- **THEN** `grep -r "prettier"` across config files returns no results (excluding oxfmt config which is separate)
|
||||
|
||||
#### Scenario: No Prettier dependencies
|
||||
- **WHEN** `npm ls prettier eslint-plugin-prettier eslint-config-prettier` is run
|
||||
- **THEN** no Prettier-related packages are installed in any workspace
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
# responsive-layout Specification
|
||||
|
||||
## Purpose
|
||||
TBD - created by archiving change admin-responsive-adaptation. Update Purpose after archive.
|
||||
## Requirements
|
||||
### Requirement: Three-breakpoint responsive system
|
||||
The admin frontend SHALL adapt its layout to three device tiers: mobile (< 768px), tablet (768-1024px), and desktop (> 1024px). All pages and components MUST render without text overflow, forced line wrapping, or content clipping at any breakpoint.
|
||||
|
||||
#### Scenario: Mobile layout (< 768px)
|
||||
- **WHEN** viewport width is less than 768px
|
||||
- **THEN** sidebar is replaced by a Drawer triggered via hamburger button
|
||||
- **AND** content area padding reduces to 12px
|
||||
- **AND** tables scroll horizontally with touch gesture
|
||||
- **AND** dashboard stat cards display in 2-column grid
|
||||
|
||||
#### Scenario: Tablet layout (768-1024px)
|
||||
- **WHEN** viewport width is between 768px and 1024px
|
||||
- **THEN** sidebar defaults to collapsed state
|
||||
- **AND** content area padding is 16px
|
||||
- **AND** dashboard stat cards display in 2-column grid
|
||||
- **AND** chart cards display side-by-side
|
||||
|
||||
#### Scenario: Desktop layout (> 1024px)
|
||||
- **WHEN** viewport width is greater than 1024px
|
||||
- **THEN** sidebar is fully visible and collapsible
|
||||
- **AND** content area padding is 24px
|
||||
- **AND** dashboard stat cards display in 4-column grid
|
||||
- **AND** chart cards display side-by-side
|
||||
|
||||
### Requirement: Table horizontal scroll on narrow screens
|
||||
All `<Table>` components SHALL support horizontal scrolling when content exceeds viewport width. The scroll behavior MUST be enabled via scroll={{ x }} prop, and all table columns MUST remain visible (no responsive column hiding).
|
||||
|
||||
#### Scenario: Wide table on mobile
|
||||
- **WHEN** a table has more columns than fit within the viewport width
|
||||
- **THEN** the table container renders a horizontal scrollbar
|
||||
- **AND** users can scroll horizontally to view all columns
|
||||
- **AND** action column (if present) remains accessible without scrolling via fixed position
|
||||
|
||||
### Requirement: Login page responsiveness
|
||||
The login page card SHALL not overflow the viewport on any screen size. On mobile devices, the card MUST fit within the screen with comfortable margins.
|
||||
|
||||
#### Scenario: Login on small mobile screen (320px)
|
||||
- **WHEN** viewport width is 320px
|
||||
- **THEN** login card width does not exceed `calc(100vw - 32px)`
|
||||
- **AND** the login form remains fully visible and usable
|
||||
|
||||
### Requirement: Dashboard responsive grid
|
||||
Dashboard stat cards and chart cards SHALL use antd responsive Col breakpoints (xs/sm/md) instead of fixed span values. Charts SHALL re-render to fit container width on window resize.
|
||||
|
||||
#### Scenario: Dashboard on tablet
|
||||
- **WHEN** viewing dashboard on a 800px wide tablet
|
||||
- **THEN** stat cards render 2 per row
|
||||
- **AND** pie chart and bar chart render side by side
|
||||
- **AND** gantt chart fits within the content area width
|
||||
|
||||
### Requirement: Modal responsiveness
|
||||
All Modal dialogs SHALL have a max-width constraint preventing overflow beyond the viewport on small screens.
|
||||
|
||||
#### Scenario: Modal on mobile
|
||||
- **WHEN** a modal is opened on a viewport < 768px wide
|
||||
- **THEN** the modal width does not exceed `calc(100vw - 24px)`
|
||||
- **AND** the modal body has a max-height of 60vh with vertical scroll
|
||||
- **AND** modal mask covers the full viewport
|
||||
|
||||
### Requirement: Page toolbar responsive wrapping
|
||||
All page-level toolbars with search/filter/action controls SHALL wrap gracefully on narrow screens using flexWrap and gap spacing, preventing button group clipping or overlap.
|
||||
|
||||
#### Scenario: Toolbar with search and action buttons on tablet
|
||||
- **WHEN** a page toolbar contains a search input group and action button group
|
||||
- **AND** viewport width is 800px
|
||||
- **THEN** toolbar items wrap to multiple lines without overflow
|
||||
- **AND** all buttons remain clickable with adequate spacing
|
||||
|
||||
### Requirement: Student fields separation
|
||||
The Students page SHALL display "学号" (student ID) and "身份证" (ID card number) as two separate table columns instead of a single combined column. Both columns SHALL support ellipsis truncation for long values.
|
||||
|
||||
#### Scenario: Student table column display
|
||||
- **WHEN** viewing the student list
|
||||
- **THEN** the table includes a "学号" column and a "身份证" column as separate headers
|
||||
- **AND** long ID numbers are truncated with ellipsis and tooltip on hover
|
||||
|
||||
### Requirement: Classroom schedule table scrolling
|
||||
The classroom schedule grid table SHALL support horizontal scrolling with a sticky first column (classroom name) to aid navigation when viewing beyond the visible date range.
|
||||
|
||||
#### Scenario: Schedule table on month with 31 days
|
||||
- **WHEN** viewing a month schedule on a tablet (800px)
|
||||
- **THEN** the classroom name column remains fixed on the left
|
||||
- **AND** date columns scroll horizontally
|
||||
- **AND** no text overflows or wraps within date cells
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# turborepo-pipeline Specification
|
||||
|
||||
## Purpose
|
||||
TBD - created by archiving change migrate-to-turborepo. Update Purpose after archive.
|
||||
## Requirements
|
||||
### Requirement: Turbo pipeline configuration
|
||||
The project SHALL define a `turbo.json` at the repository root that configures build, dev, lint, test, format, and typecheck pipelines with appropriate caching and dependency ordering.
|
||||
|
||||
#### Scenario: Build pipeline with caching
|
||||
- **WHEN** `turbo run build` is executed twice without source changes
|
||||
- **THEN** the second run uses cached outputs and completes with "FULL TURBO" status
|
||||
|
||||
#### Scenario: Topological build ordering
|
||||
- **WHEN** `turbo run build` is executed
|
||||
- **THEN** packages (shared configs, types) build before apps that depend on them
|
||||
|
||||
#### Scenario: Parallel execution
|
||||
- **WHEN** `turbo run lint` is executed
|
||||
- **THEN** server and admin linting run in parallel where dependency graph allows
|
||||
|
||||
### Requirement: Unified root scripts
|
||||
The root `package.json` SHALL provide top-level scripts (`dev`, `build`, `lint`, `format`, `test`, `typecheck`) that delegate to Turborepo or workspace-level commands.
|
||||
|
||||
#### Scenario: Dev mode starts all apps
|
||||
- **WHEN** `npm run dev` is executed at root
|
||||
- **THEN** both server (NestJS on port 3003) and admin (Vite on port 3002) start in dev mode
|
||||
|
||||
#### Scenario: Build produces all outputs
|
||||
- **WHEN** `npm run build` is executed at root
|
||||
- **THEN** server `dist/` and admin `dist/` are produced
|
||||
|
||||
### Requirement: Independent workspace scripts
|
||||
Each workspace SHALL retain the ability to run its own scripts independently (e.g., `npm run test` inside `apps/server/`).
|
||||
|
||||
#### Scenario: Server tests run independently
|
||||
- **WHEN** `npm run test` is executed inside `apps/server/`
|
||||
- **THEN** the NestJS Jest test suite runs and reports results
|
||||
|
||||
#### Scenario: Admin dev runs independently
|
||||
- **WHEN** `npm run dev` is executed inside `apps/admin/`
|
||||
- **THEN** the Vite dev server starts on port 3002 with API proxy configured
|
||||
|
||||
Reference in New Issue
Block a user