@haposoft/cafekit 0.14.1 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +7 -3
  2. package/bin/__tests__/installer-safety.test.js +145 -0
  3. package/bin/install.js +9 -1
  4. package/bin/lib/backup.js +60 -16
  5. package/bin/lib/context.js +1 -1
  6. package/bin/phases/claude-runtime.js +57 -4
  7. package/bin/phases/post-install.js +39 -26
  8. package/bin/phases/select-platform.js +14 -9
  9. package/package.json +1 -1
  10. package/src/claude/CLAUDE.md +1 -1
  11. package/src/claude/agents/code-auditor.md +1 -1
  12. package/src/claude/agents/debugger.md +1 -0
  13. package/src/claude/agents/god-developer.md +10 -1
  14. package/src/claude/agents/inspector.md +1 -0
  15. package/src/claude/agents/spec-maker.md +1 -1
  16. package/src/claude/agents/test-runner.md +2 -2
  17. package/src/claude/hooks/__tests__/privacy-block.test.js +50 -10
  18. package/src/claude/hooks/__tests__/spec-gate.test.js +75 -1
  19. package/src/claude/hooks/__tests__/state.test.js +65 -0
  20. package/src/claude/hooks/docs-sync.cjs +15 -21
  21. package/src/claude/hooks/inspect-block.cjs +1 -1
  22. package/src/claude/hooks/lib/config.cjs +0 -5
  23. package/src/claude/hooks/privacy-block.cjs +39 -62
  24. package/src/claude/hooks/spec-gate.cjs +18 -7
  25. package/src/claude/hooks/spec-state.cjs +4 -0
  26. package/src/claude/hooks/state.cjs +13 -3
  27. package/src/claude/hooks/usage.cjs +6 -0
  28. package/src/claude/rules/orchestrator.md +2 -2
  29. package/src/claude/rules/skill-domain-routing.md +27 -86
  30. package/src/claude/rules/skill-workflow-routing.md +11 -82
  31. package/src/claude/rules/state-sync.md +1 -1
  32. package/src/claude/runtime.json +7 -7
  33. package/src/claude/scripts/validate-spec-output.cjs +6 -0
  34. package/src/claude/skills/code-review/references/spec-compliance-review.md +1 -1
  35. package/src/claude/skills/develop/SKILL.md +26 -5
  36. package/src/claude/skills/develop/references/parallel-waves.md +112 -0
  37. package/src/claude/skills/develop/references/quality-gate.md +10 -2
  38. package/src/claude/skills/hotfix/references/parallel-patterns.md +1 -1
  39. package/src/claude/skills/inspect/SKILL.md +42 -113
  40. package/src/claude/skills/inspect/references/internal-inspection.md +16 -135
  41. package/src/claude/skills/specs/SKILL.md +134 -386
  42. package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
  43. package/src/claude/skills/specs/templates/task.md +3 -1
  44. package/src/claude/skills/sync/SKILL.md +2 -2
  45. package/src/claude/skills/sync/references/sync-protocols.md +4 -4
  46. package/src/claude/skills/test/SKILL.md +1 -1
  47. package/src/claude/status.cjs +9 -6
  48. package/src/opencode/plugins/docs-sync.ts +10 -16
  49. package/src/claude/archive-command/code/SKILL.md +0 -55
  50. package/src/claude/archive-command/code/references/execution-loop.md +0 -21
  51. package/src/claude/archive-command/code.md +0 -17
  52. package/src/claude/archive-command/docs.md +0 -609
  53. package/src/claude/archive-command/review/codebase/parallel.md +0 -76
  54. package/src/claude/archive-command/spec-design.md +0 -247
  55. package/src/claude/archive-command/spec-init.md +0 -120
  56. package/src/claude/archive-command/spec-requirements.md +0 -138
  57. package/src/claude/archive-command/spec-status.md +0 -98
  58. package/src/claude/archive-command/spec-tasks.md +0 -173
  59. package/src/claude/archive-command/spec-validate.md +0 -118
  60. package/src/claude/archive-command/test.md +0 -8
@@ -1,173 +0,0 @@
1
- ---
2
- name: spec-tasks
3
- description: Generate implementation tasks for a specification
4
- allowed-tools: Glob, Grep, Read, Write, Edit, WebSearch, WebFetch
5
- argument-hint: <feature-name> [-y] [--sequential]
6
- ---
7
-
8
- # Implementation Tasks Generator
9
-
10
- <background_information>
11
- - **Mission**: Generate detailed, actionable implementation tasks that translate technical design into executable work items
12
- - **Success Criteria**:
13
- - All requirements mapped to specific tasks
14
- - Tasks properly sized (1-3 hours each)
15
- - Clear task progression with proper hierarchy
16
- - Natural language descriptions focused on capabilities
17
- </background_information>
18
-
19
- <instructions>
20
- ## Core Task
21
- Generate implementation tasks for feature **$ARGUMENTS** based on approved requirements and design.
22
-
23
- ## Execution Steps
24
-
25
- ### Step 0: Validate Phase State (Plan-Style Gate)
26
-
27
- - Read `.specs/$ARGUMENTS/spec.json` first
28
- - If feature directory or `spec.json` is missing: stop and instruct user to run `/spec-init <project-description>`, `/spec-requirements <feature-name>`, and `/spec-design <feature-name>` first
29
- - If design has not been generated yet (phase before design): stop and instruct user to run `/spec-design $ARGUMENTS`
30
- - If `phase` is already `tasks-generated`: explain tasks phase already exists and only continue for explicit regeneration/merge intent
31
-
32
- ### Step 1: Load Context
33
-
34
- **Read all necessary context**:
35
- - `.specs/$ARGUMENTS/spec.json`, `requirements.md`, `design.md`
36
- - `.specs/$ARGUMENTS/tasks.md` (if exists, for merge mode)
37
- - `.specs/$ARGUMENTS/research.md` (if exists, includes validation log)
38
- - Resolve scope baseline from `spec.json.scope_lock` (fallback to derived baseline when missing)
39
- - **Entire `.specs/steering/` directory** for complete project memory (if exists)
40
- - **Load project docs context (Plan-style quality gate)** when available:
41
- - `docs/codebase-summary.md`
42
- - `docs/code-standards.md`
43
- - `docs/system-architecture.md`
44
- - `docs/project-overview-pdr.md`
45
- - If any docs file is missing, continue and mention missing context in execution output (do not block generation)
46
-
47
- **Validate approvals**:
48
- - If `-y` flag provided: Auto-approve requirements and design in spec.json
49
- - Otherwise: Verify both approved (stop if not, see Safety & Fallback)
50
- - **Backward compatibility fallback (older specs):**
51
- - If `validation` object is missing, treat validation status as `not-run`
52
- - If `design_context` object is missing, treat `validation_recommended` as `false`
53
- - If `spec.json.validation.status == "completed"`, treat validation as satisfied
54
- - If validation is missing and `design_context.validation_recommended == true`, warn user to run `/spec-validate $ARGUMENTS` before continuing (do not hard-block)
55
- - Determine sequential mode based on presence of `--sequential`
56
-
57
- ### Step 2: Generate Implementation Tasks
58
-
59
- **Load generation rules and template**:
60
- - Read `{{SKILLS_DIR}}/specs/rules/tasks-generation.md` for principles
61
- - If `sequential` is **false**: Read `{{SKILLS_DIR}}/specs/rules/tasks-parallel-analysis.md` for parallel judgement criteria
62
- - Read `{{SKILLS_DIR}}/specs/templates/tasks.md` for format (supports `(P)` markers)
63
-
64
- **Generate task list following all rules**:
65
- - Use language specified in spec.json
66
- - Map all requirements to tasks
67
- - Only use valid in-scope requirement IDs from requirements.md
68
- - Every task MUST reference at least one valid in-scope requirement ID
69
- - Reject or defer task candidates that map only to out-of-scope capabilities
70
- - When documenting requirement coverage, list numeric requirement IDs only (comma-separated) without descriptive suffixes, parentheses, translations, or free-form labels
71
- - Ensure all in-scope design components included
72
- - Verify task progression is logical and incremental
73
- - Collapse single-subtask structures by promoting them to major tasks and avoid duplicating details on container-only major tasks (use template patterns accordingly)
74
- - Apply `(P)` markers to tasks that satisfy parallel criteria (omit markers in sequential mode)
75
- - Mark optional test coverage subtasks with `- [ ]*` only when they strictly cover acceptance criteria already satisfied by core implementation and can be deferred post-MVP
76
- - If existing tasks.md found, merge with new content
77
-
78
- ### Step 3: Finalize
79
-
80
- **Write and update**:
81
- - Create/update `.specs/$ARGUMENTS/tasks.md`
82
- - Update spec.json metadata:
83
- - Set `phase: "tasks-generated"`
84
- - Set `approvals.tasks.generated: true, approved: false`
85
- - Set `approvals.requirements.approved: true`
86
- - Set `approvals.design.approved: true`
87
- - Update `updated_at` timestamp
88
-
89
- ## Critical Constraints
90
- - **Follow rules strictly**: All principles in tasks-generation.md are mandatory
91
- - **Natural Language**: Describe what to do, not code structure details
92
- - **Complete Coverage**: ALL in-scope requirements must map to tasks
93
- - **Scope Lock**: Do not generate out-of-scope tasks; classify them as deferred when needed
94
- - **Requirement Mapping Integrity**: Each task must map to valid numeric in-scope requirement IDs
95
- - **Maximum 2 Levels**: Major tasks and sub-tasks only (no deeper nesting)
96
- - **Sequential Numbering**: Major tasks increment (1, 2, 3...), never repeat
97
- - **Task Integration**: Every task must connect to the system (no orphaned work)
98
- </instructions>
99
-
100
- ## Tool Guidance
101
- - **Read first**: Load all context, rules, and templates before generation
102
- - **Write last**: Generate tasks.md only after complete analysis and verification
103
-
104
- ## Output Description
105
-
106
- Provide brief summary in the language specified in spec.json:
107
-
108
- 1. **Status**: Confirm tasks generated at `.specs/$ARGUMENTS/tasks.md`
109
- 2. **Task Summary**:
110
- - Total: X major tasks, Y sub-tasks
111
- - All Z requirements covered
112
- - Average task size: 1-3 hours per sub-task
113
- 3. **Quality Validation**:
114
- - ✅ All in-scope requirements mapped to tasks
115
- - ✅ Task dependencies verified
116
- - ✅ Testing tasks included
117
- 4. **Scope Guard**:
118
- - ✅ Every task maps to valid in-scope requirement IDs
119
- - ✅ Out-of-scope tasks deferred/blocked
120
- 5. **Next Action**: Review tasks and proceed when ready
121
-
122
- **Format**: Concise (under 200 words)
123
-
124
- ## Safety & Fallback
125
-
126
- ### Error Scenarios
127
-
128
- **Requirements or Design Not Approved**:
129
- - **Stop Execution**: Cannot proceed without approved requirements and design
130
- - **User Message**: "Requirements and design must be approved before task generation"
131
- - **Suggested Action**: "Run `/spec-tasks $ARGUMENTS -y` to auto-approve both and proceed"
132
-
133
- **Missing Requirements or Design**:
134
- - **Stop Execution**: Both documents must exist
135
- - **User Message**: "Missing requirements.md or design.md at `.specs/$ARGUMENTS/`"
136
- - **Suggested Action**: "Complete requirements and design phases first"
137
-
138
- **Incomplete Requirements Coverage**:
139
- - **Warning**: "Not all in-scope requirements mapped to tasks. Review coverage."
140
- - **User Action Required**: Confirm intentional gaps or regenerate tasks
141
-
142
- **Out-of-Scope Tasks Detected**:
143
- - **Block/Defer**: Do not include out-of-scope tasks in primary task plan
144
- - **User Guidance**: Request explicit scope expansion approval if user wants those tasks promoted
145
-
146
- **Template/Rules Missing**:
147
- - **User Message**: "Template or rules files missing in `{{SKILLS_DIR}}/specs/`"
148
- - **Fallback**: Use inline basic structure with warning
149
- - **Suggested Action**: "Check repository setup or restore template files"
150
-
151
- **Missing Numeric Requirement IDs**:
152
- - **Stop Execution**: All requirements in requirements.md MUST have numeric IDs. If any requirement lacks a numeric ID, stop and request that requirements.md be fixed before generating tasks.
153
-
154
- **Invalid Requirement Mapping in Tasks**:
155
- - **Stop Execution**: If a generated task cannot map to valid in-scope numeric requirement IDs, remove/defer it and regenerate task mapping
156
-
157
- ### Next Phase: Implementation
158
-
159
- **Before Starting Implementation**:
160
- - **IMPORTANT**: Clear conversation history and free up context before running `/code`
161
- - This applies when starting first task OR switching between tasks
162
- - Fresh context ensures clean state and proper task focus
163
-
164
- **If Tasks Approved**:
165
- - Execute coding pass from approved spec tasks: `/code $ARGUMENTS`
166
- - After coding, run `/test` then `/review`
167
- - Repeat in small passes and clear context between iterations when needed
168
-
169
- **If Modifications Needed**:
170
- - Provide feedback and re-run `/spec-tasks $ARGUMENTS`
171
- - Existing tasks used as reference (merge mode)
172
-
173
- **Note**: Continue with `/test` then `/review` after `/code` to complete the workflow.
@@ -1,118 +0,0 @@
1
- ---
2
- name: spec-validate
3
- description: Validate design decisions with interview questions before task generation
4
- allowed-tools: Read, Write, Edit, Glob, AskUserQuestion
5
- argument-hint: <feature-name>
6
- ---
7
-
8
- # Specification Validation Interview
9
-
10
- <background_information>
11
- - **Mission**: Validate critical design decisions, assumptions, and trade-offs before generating implementation tasks.
12
- - **Success Criteria**:
13
- - Ask targeted, concrete questions about high-impact decisions
14
- - Record answers in spec artifacts for future traceability
15
- - Update spec metadata to reflect validation status
16
- </background_information>
17
-
18
- <instructions>
19
- ## Core Task
20
- Run a structured interview for feature **$ARGUMENTS** and persist decisions.
21
-
22
- ## Execution Steps
23
-
24
- ### Step 0: Resolve & Validate State
25
- - Require `$ARGUMENTS` as feature name
26
- - Read `.specs/$ARGUMENTS/spec.json`
27
- - Stop with guidance if spec does not exist
28
- - Ensure `requirements.md` and `design.md` exist before validation
29
-
30
- ### Step 1: Load Validation Context
31
- Read:
32
- - `.specs/$ARGUMENTS/spec.json`
33
- - `.specs/$ARGUMENTS/requirements.md`
34
- - `.specs/$ARGUMENTS/design.md`
35
- - `.specs/$ARGUMENTS/research.md` (if exists)
36
-
37
- Resolve scope lock first:
38
- - `scope_lock.source`
39
- - `scope_lock.in_scope[]`
40
- - `scope_lock.out_of_scope[]`
41
- - `scope_lock.expansion_policy`
42
-
43
- Extract decision points around in-scope trade-offs only:
44
- - architecture and boundaries
45
- - assumptions and defaults
46
- - integration risks
47
- - scope and sequencing
48
- - testing/security/performance trade-offs
49
-
50
- ### Step 2: Determine Question Budget
51
- Use injected session validation settings when available (`Validation: mode=X, questions=MIN-MAX`).
52
- - If unavailable, use 3-6 questions
53
- - Ask only meaningful questions that can change in-scope implementation
54
- - Each question must have 2-4 concrete options
55
- - Prefer in-scope confirmation questions first; scope-expansion questions are optional and only if needed
56
-
57
- ### Step 3: Interview User
58
- Use `AskUserQuestion` in batches (max 4 questions per call).
59
- Rules:
60
- - Include one recommended option when a safe default exists
61
- - Keep options mutually exclusive
62
- - Do not ask redundant questions
63
- - Keep questions inside current scope by default
64
- - Open-scope expansion questions are allowed only when scope pressure is detected and must require explicit user approval
65
-
66
- ### Step 4: Persist Validation Log
67
- Append to `.specs/$ARGUMENTS/research.md` under `## Validation Log`.
68
- If section missing, create it.
69
-
70
- Session format:
71
- ```markdown
72
- ## Validation Log
73
-
74
- ### Session N — YYYY-MM-DD
75
- - Questions asked: X
76
-
77
- 1. [Category] Question text
78
- - Options: A | B | C
79
- - Answer: ...
80
- - Rationale: why this decision matters
81
-
82
- #### Confirmed Decisions
83
- - ...
84
-
85
- #### Follow-up Actions
86
- - [ ] ...
87
- ```
88
-
89
- ### Step 5: Update Metadata
90
- Update `.specs/$ARGUMENTS/spec.json`:
91
- - `approvals.requirements.approved: true`
92
- - `approvals.design.approved: true`
93
- - `validation.last_validated_at: <ISO timestamp>`
94
- - `validation.questions_asked: <number>`
95
- - `validation.status: "completed"`
96
- - increment `validation.session_count` (initialize to 1 if absent)
97
- - if explicit expansion approved by user, update `scope_lock.in_scope` / `scope_lock.out_of_scope` accordingly
98
- - update `updated_at`
99
-
100
- ## Constraints
101
- - Keep input/output contract of existing `spec-*` commands unchanged
102
- - Validation must be traceable and append-only (never overwrite old sessions)
103
- - Ask fewer questions when artifact is simple; quality over quantity
104
- - Do not introduce new capability domains during validation unless user explicitly approves scope expansion
105
- </instructions>
106
-
107
- ## Output Description
108
- Provide concise summary:
109
- 1. Validation status and files updated
110
- 2. Number of questions asked
111
- 3. Top confirmed decisions
112
- 4. Recommended next command:
113
- - `/spec-tasks $ARGUMENTS` when ready
114
-
115
- ## Safety & Fallback
116
- - Missing spec/design artifacts: stop and instruct the exact preceding command
117
- - Empty decision surface: ask only 1-2 high-value confirmation questions
118
- - Write failure: report exact path and retry guidance
@@ -1,8 +0,0 @@
1
- ---
2
- description: ⚡ Run tests locally and analyze the summary report.
3
- ---
4
-
5
- Use the `test-runner` subagent to run tests locally and analyze the summary report.
6
-
7
- **IMPORTANT**: **Do not** start implementing.
8
- **IMPORTANT:** Analyze the skills catalog and activate the skills that are needed for the task during the process.