@haposoft/cafekit 0.16.0-rc.6 → 0.16.0-rc.8

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 (87) hide show
  1. package/README.md +21 -58
  2. package/bin/__tests__/change-firewall.semantic-firewall.test.js +4 -5
  3. package/bin/__tests__/codex-hooks.test.js +382 -0
  4. package/bin/__tests__/codex-native.test.js +579 -80
  5. package/bin/__tests__/develop-contract.test.js +155 -76
  6. package/bin/__tests__/installer-safety.test.js +19 -154
  7. package/bin/__tests__/package-inventory.test.js +494 -26
  8. package/bin/__tests__/release-preflight.semantic-firewall.test.js +2 -2
  9. package/bin/__tests__/validator-grounding.test.js +11 -11
  10. package/bin/install.js +2 -7
  11. package/bin/lib/context.js +0 -45
  12. package/bin/lib/copy-utils.js +1 -1
  13. package/bin/lib/i18n.js +0 -3
  14. package/bin/lib/manifest.js +1 -1
  15. package/bin/phases/claude-runtime.js +1 -3
  16. package/bin/phases/codex-runtime.js +4 -2
  17. package/bin/phases/copy-payload.js +3 -15
  18. package/bin/phases/post-install.js +5 -17
  19. package/bin/phases/root-config.js +2 -3
  20. package/bin/phases/select-platform.js +2 -5
  21. package/bin/phases/summary.js +0 -1
  22. package/package.json +2 -5
  23. package/src/claude/CLAUDE.md +19 -6
  24. package/src/claude/agents/project-manager.md +41 -9
  25. package/src/claude/agents/spec-maker.md +82 -155
  26. package/src/claude/gitignore +1 -1
  27. package/src/claude/hooks/__tests__/spec-gate.test.js +238 -0
  28. package/src/claude/hooks/__tests__/state.test.js +249 -3
  29. package/src/claude/hooks/lib/context.cjs +1 -1
  30. package/src/claude/hooks/lib/detect.cjs +1 -1
  31. package/src/claude/hooks/spec-gate.cjs +44 -9
  32. package/src/claude/hooks/spec-state.cjs +51 -13
  33. package/src/claude/hooks/task-scaffold-guard.cjs +1 -1
  34. package/src/claude/migration-manifest.json +17 -3
  35. package/src/claude/rules/manage-docs.md +43 -24
  36. package/src/claude/rules/state-sync.md +57 -62
  37. package/src/claude/rules/workflow.md +30 -13
  38. package/src/claude/scripts/change-firewall.cjs +2 -2
  39. package/src/claude/scripts/generate-skill-catalog.cjs +0 -1
  40. package/src/claude/scripts/spec-receipt.cjs +196 -1
  41. package/src/claude/scripts/spec-resolver.cjs +428 -0
  42. package/src/claude/skills/develop/SKILL.md +89 -125
  43. package/src/claude/skills/develop/references/parallel-waves.md +75 -162
  44. package/src/claude/skills/develop/references/quality-gate.md +61 -121
  45. package/src/claude/skills/develop/references/subagent-patterns.md +31 -38
  46. package/src/claude/skills/question/SKILL.md +1 -1
  47. package/src/claude/skills/specs/SKILL.md +152 -204
  48. package/src/claude/skills/specs/references/review.md +124 -243
  49. package/src/claude/skills/specs/references/templates.md +202 -0
  50. package/src/claude/skills/sync/SKILL.md +66 -90
  51. package/src/claude/skills/sync/references/sync-protocols.md +62 -83
  52. package/src/codex/AGENTS.md +20 -7
  53. package/src/codex/hooks/lib/spec-receipt.cjs +18 -0
  54. package/src/codex/hooks/lib/spec-utils.cjs +25 -0
  55. package/src/codex/hooks/spec-gate.cjs +46 -16
  56. package/src/codex/hooks/spec-state.cjs +54 -16
  57. package/src/codex/rules/state-sync.md +57 -61
  58. package/src/common/AGENTS.md +8 -1
  59. package/bin/__tests__/opencode-spec-gate.test.js +0 -799
  60. package/bin/lib/opencode-install.js +0 -899
  61. package/bin/phases/opencode-runtime.js +0 -38
  62. package/src/claude/skills/specs/references/archive-workflow.md +0 -74
  63. package/src/claude/skills/specs/references/ask-user-question-gates.md +0 -70
  64. package/src/claude/skills/specs/references/codebase-analysis.md +0 -102
  65. package/src/claude/skills/specs/references/cross-spec-dependency.md +0 -76
  66. package/src/claude/skills/specs/references/research-strategy.md +0 -107
  67. package/src/claude/skills/specs/references/scope-inquiry.md +0 -107
  68. package/src/claude/skills/specs/references/translation-mirror.md +0 -83
  69. package/src/claude/skills/specs/rules/design-discovery-full.md +0 -45
  70. package/src/claude/skills/specs/rules/design-discovery-light.md +0 -28
  71. package/src/claude/skills/specs/rules/design-principles.md +0 -138
  72. package/src/claude/skills/specs/rules/design-review.md +0 -55
  73. package/src/claude/skills/specs/rules/ears-format.md +0 -42
  74. package/src/claude/skills/specs/rules/phase-decision-matrix.md +0 -56
  75. package/src/claude/skills/specs/rules/task-scoring-rubric.md +0 -52
  76. package/src/claude/skills/specs/rules/tasks-generation.md +0 -189
  77. package/src/opencode/AGENTS.md +0 -41
  78. package/src/opencode/plugins/docs-sync.ts +0 -175
  79. package/src/opencode/plugins/inspect-block.ts +0 -164
  80. package/src/opencode/plugins/privacy-block.ts +0 -182
  81. package/src/opencode/plugins/rules.ts +0 -155
  82. package/src/opencode/plugins/session.ts +0 -179
  83. package/src/opencode/plugins/spec-gate.ts +0 -457
  84. package/src/opencode/plugins/spec-state.ts +0 -311
  85. package/src/opencode/plugins/state.ts +0 -253
  86. package/src/opencode/plugins/task-scaffold-guard.ts +0 -161
  87. package/src/opencode/plugins/usage.ts +0 -178
@@ -1,38 +0,0 @@
1
- /**
2
- * Phase: OpenCode runtime installation.
3
- *
4
- * Delegates to the existing opencode-install.js module (kept as-is) in the
5
- * exact original order. These writers manage their own files (plugins, command
6
- * templates, AGENTS.md, opencode.json) and honor the legacy `upgrade` option.
7
- * In dry-run we skip them and report intent, since they are not dry-run aware.
8
- */
9
-
10
- const {
11
- copyOpenCodeSharedRuntimeFiles,
12
- copyOpenCodePlugins,
13
- copyOpenCodeCommandTemplates,
14
- copyOpenCodeAgentsMdFile,
15
- mergeOpenCodeConfig
16
- } = require('../lib/opencode-install');
17
- const { copyRulesDirectory } = require('./claude-runtime');
18
-
19
- function installOpenCodeRuntime(ctx, platformKey) {
20
- if (platformKey !== 'opencode') return;
21
-
22
- if (ctx.dryRun) {
23
- ctx.ui.detail(' → [dry-run] OpenCode runtime (plugins, command templates, AGENTS.md, opencode.json) would be installed');
24
- // rules/ is dry-run aware; still preview it.
25
- copyRulesDirectory(ctx, platformKey);
26
- return;
27
- }
28
-
29
- const { results, options } = ctx;
30
- copyOpenCodeSharedRuntimeFiles(platformKey, results, options);
31
- copyOpenCodePlugins(platformKey, results, options);
32
- copyOpenCodeCommandTemplates(platformKey, results, options);
33
- copyOpenCodeAgentsMdFile(platformKey, results, options);
34
- copyRulesDirectory(ctx, platformKey);
35
- mergeOpenCodeConfig(platformKey, results);
36
- }
37
-
38
- module.exports = { installOpenCodeRuntime };
@@ -1,74 +0,0 @@
1
- # Archive Workflow
2
-
3
- ## Purpose
4
-
5
- Archive completed specs, write technical journals summarizing the work, and clean up the `specs/` directory.
6
-
7
- ## Spec Resolution
8
-
9
- 1. If `<feature>` argument provided → archive that specific spec
10
- 2. If not → scan all specs in `specs/`, filter those with fully completed `progress`
11
-
12
- ## 5-Step Workflow
13
-
14
- ### Step 1: Read Spec Files
15
- - `spec.json` — metadata and status
16
- - Read first 20 lines of each task file to understand progress
17
- - Determine which specs are complete vs still in-progress
18
-
19
- ### Step 2: Summarize & Write Journal
20
- Ask user via `AskUserQuestion`: "Would you like to write technical journal entries for these specs?"
21
-
22
- If user selects "Yes":
23
- - Analyze information from Step 1
24
- - Spawn journal-writer agent to document each spec
25
- - Journal entries should be concise, focusing on: key events, major changes, impact, decisions
26
- - Save to `./docs/journals/`
27
-
28
- If user selects "No": skip this step.
29
-
30
- ### Step 3: Confirm Action
31
- Ask user via `AskUserQuestion`:
32
- - "Archive all completed specs"
33
- - "Select specific specs to archive"
34
- - "Cancel, don't archive"
35
-
36
- Then ask:
37
- - "Move to `specs/archive/`"
38
- - "Delete permanently"
39
-
40
- ### Step 4: Execute Archive
41
- Based on user's choice:
42
- - **Move:** `mv specs/<feature> specs/archive/<feature>`
43
- - **Delete:** `rm -rf specs/<feature>` (⚠️ requires confirmation first)
44
-
45
- ### Step 5: Ask About Commit
46
- Ask user via `AskUserQuestion`:
47
- - "Stage and commit changes"
48
- - "Commit and push"
49
- - "I'll handle it later"
50
-
51
- ## Output
52
-
53
- After archiving, present summary:
54
-
55
- ```markdown
56
- ## Archive Results
57
-
58
- | Spec | Status | Created | Action |
59
- |---|---|---|---|
60
- | mobile-app | done | 2026-04-01 | Moved → archive |
61
- | auth-system | done | 2026-03-28 | Deleted permanently |
62
-
63
- **Journal entries written:**
64
- | Title | Path |
65
- |---|---|
66
- | Mobile App Release | docs/journals/2026-04-06-mobile-app.md |
67
- ```
68
-
69
- ## Notes
70
-
71
- - Only archive completed specs — never archive in-progress specs
72
- - Keep questions focused on genuine decision points
73
- - Be concise, prioritize efficiency
74
- - List unresolved questions at the end
@@ -1,70 +0,0 @@
1
- # AskUserQuestion Gate Matrix
2
-
3
- Use this matrix to classify authority before pausing for user input. A workflow
4
- event, uncertainty, or architecture choice does not by itself justify a question.
5
-
6
- ## Source Priority
7
-
8
- Resolve uncertainty in this order:
9
-
10
- 1. Existing `spec.json`, `requirements.md`, `research.md`, `design.md`, and task files.
11
- 2. Codebase evidence from targeted scout/inspect.
12
- 3. Official/current external docs when platform/provider behavior matters.
13
- 4. Reasonable default from CafeKit rules.
14
- 5. `AskUserQuestion` only when the remaining decision is user-owned.
15
-
16
- Classify first:
17
-
18
- - `repository_fact`: investigate and ground it from repository or required
19
- current evidence. Do not ask the user to supply a discoverable fact.
20
- - `reversible_assumption`: choose the simplest engineering option and record its
21
- bounded reversal boundary. Do not ask unless the user explicitly requested
22
- control of that choice.
23
- - `user_owned`: HOLD and ASK for a product, scope, security, data, or
24
- irreversible decision. Never infer or self-approve it.
25
-
26
- Store only actual items in optional `spec.json.decisions`; omit it when absent.
27
- Every unresolved `user_owned` entry blocks readiness; facts and reversible
28
- assumptions do not become user questions merely because they are unresolved.
29
-
30
- ## Gate Matrix
31
-
32
- | Class | Example trigger | Action | Record in |
33
- |---|---|---|---|
34
- | Repository fact | Existing behavior, path, dependency, API shape, or current constraint | Investigate and ground; if evidence remains unavailable, report the exact grounding blocker without asking the user to guess | design/research anchor |
35
- | Reversible assumption | Two technically valid internal approaches with bounded rollback | Select the simplest compatible option and record the reversal trigger/boundary | `spec.json.decisions` when material, otherwise design |
36
- | User-owned decision | Product behavior, scope expansion/reduction, security posture, data handling, or irreversible migration | HOLD and ASK; keep the exact decision unresolved until the user answers | `spec.json.decisions` and affected artifact |
37
- | Active-target ambiguity | Multiple plausible feature/spec targets | HOLD and ASK because target selection changes scope | `scope_lock` |
38
- | Validation finding | A factual defect or reversible repair | Ground and repair without approval; ASK only if resolution changes a user-owned decision | affected canonical artifact |
39
- | Task conflict | Shared files/contracts between parallel candidates | Serialize or merge using the simplest reversible topology | task boundaries |
40
-
41
- ## Question Format
42
-
43
- Every `AskUserQuestion` must:
44
-
45
- - Ask 1-3 questions max per pause.
46
- - Provide 2-3 concrete options.
47
- - Put recommended option first and suffix label with `(Recommended)`.
48
- - Explain the tradeoff in one sentence per option.
49
- - Include an implicit free-form "Other" option when the tool supports it.
50
-
51
- ## Do Not Ask
52
-
53
- Do not ask when:
54
-
55
- - The answer is discoverable via repo files, tests, docs, or official/current docs.
56
- - The choice is pure implementation detail with no scope/user impact.
57
- - The task can safely use an existing codebase convention.
58
- - The question exists only to avoid making a normal engineering judgment.
59
- - Evidence is missing for a `repository_fact`; report the grounding blocker
60
- instead of asking the user to guess.
61
-
62
- ## Recording Rules
63
-
64
- After a user answer:
65
-
66
- - Update the artifact that drives implementation, not only a report.
67
- - Keep exact selected option and custom free text when provided.
68
- - Add unresolved questions at the end of the affected document.
69
- - HOLD while any `user_owned` decision is unresolved. Do not mark
70
- `ready_for_implementation = true` until the user resolves it.
@@ -1,102 +0,0 @@
1
- # Codebase Analysis
2
-
3
- ## Purpose
4
-
5
- Understand the current codebase before designing solutions — ensure the new spec aligns with existing architecture, patterns, contracts, tests, and runtime boundaries.
6
-
7
- ## Skip Conditions
8
-
9
- - Already provided with inspector reports → skip, use directly
10
- - Greenfield artifact that does not integrate with existing code → record skip rationale in `research.md`
11
- - Internal docs/text-only spec with no runtime behavior → record skip rationale in `research.md`
12
-
13
- ## Targeted Codebase Scout Gate
14
-
15
- Run a targeted scout before requirements when any of these are true:
16
-
17
- - The feature modifies existing behavior, UI, API, CLI, data flow, runtime config, hooks, settings, generated artifacts, or package exports.
18
- - The feature touches database schemas, migrations, auth/session, permissions, external integrations, or shared contracts.
19
- - The task may break existing tests, snapshots, build scripts, type checks, e2e flows, or docs generation.
20
- - The spec crosses monorepo boundaries such as source package → installed `.claude/`, library package → docs app, package manifest → publish/install runtime.
21
- - `Related Files` cannot be named precisely yet.
22
- - A resumed or validated spec may be stale because files, tests, dependencies, or contracts changed since the spec was created.
23
-
24
- The scout must be narrow and question-driven. Do not scan the whole repo just because the repo is available.
25
-
26
- ## 4 Mandatory Files to Read First
27
-
28
- | # | File | Content | Importance |
29
- |---|---|---|---|
30
- | 1 | `./docs/development-rules.md` | Development rules, naming conventions, file size management, coding standards | **MANDATORY** |
31
- | 2 | `./docs/codebase-summary.md` | Architecture overview, project structure, component relationships | High |
32
- | 3 | `./docs/code-standards.md` | Coding conventions, language-specific patterns | High |
33
- | 4 | `./docs/design-guidelines.md` | Design system, branding, UI/UX conventions | If exists |
34
-
35
- ### Validation & Fallback Protocol (MANDATORY)
36
- 1. **Trust but Verify:** If `codebase-summary.md` or `code-standards.md` exists, you MUST verify their technical claims by cross-checking `package.json`, `go.mod`, etc. (e.g., if Docs say Redux but package.json only has Zustand → Flag documentation as STALE in your research).
37
- 2. **The "Blind Flight" Halt:** If ALL 4 mandatory docs are missing in a non-empty repository:
38
- - **DO NOT** blindly use `inspector` to scan the whole repo.
39
- - **HALT** the spec process immediately.
40
- - Ask the User: *"No codebase documentation found. Exploring blind will drain tokens and produce inaccurate specs. Shall I call the `docs-keeper` agent to generate a baseline `codebase-summary.md` first?"*
41
-
42
- ## Scout Output Contract
43
-
44
- Record the concise findings in `research.md`; if inspector agents are used, save detailed output to `reports/inspect-report.md`.
45
-
46
- Required output:
47
- - **Project surface:** project type, package/workspace boundaries, languages, frameworks, and relevant commands.
48
- - **Relevant files/modules:** exact paths likely to be created, modified, deleted, or read.
49
- - **Existing patterns:** naming, architecture, state/data flow, error handling, testing, and docs conventions that tasks must follow.
50
- - **Contracts:** API/CLI/schema/auth/config/runtime/package/export contracts affected by the spec.
51
- - **Tests and verification:** existing tests/checks likely to pass, fail, or require updates.
52
- - **Blast radius:** affected modules, consumers, generated artifacts, publish/install paths, and rollback considerations.
53
- - **Staleness check:** docs or prior specs that conflict with source code or manifests.
54
-
55
- ## Analysis Activities
56
-
57
- ### 1. Environment Analysis
58
- - Review development environment setup
59
- - Analyze dotenv files and configuration
60
- - Identify required dependencies
61
- - Understand build and deployment processes
62
-
63
- ### 2. Core Data Structures (MANDATORY for Enhancements)
64
- Before designing any logic, you must identify and read the existing schemas:
65
- - Tell `inspector` to grep for database schema files (`schema.ts`, `schema.prisma`, entities, migrations).
66
- - Identify Global State setups (Redux stores, Zustand, React Context).
67
- - Output the relational impact: How will the new feature alter existing tables or state structures?
68
-
69
- ### 3. Pattern Recognition
70
- - Study existing patterns in codebase
71
- - Identify conventions and architectural decisions
72
- - Note consistency in implementation approaches
73
- - Understand error handling patterns
74
-
75
- ### 4. Integration Planning
76
- - Identify how new features integrate with existing architecture
77
- - Map dependencies between components
78
- - Understand data flow and state management
79
- - Consider backward compatibility
80
-
81
- ### 5. Blast Radius & Regression Check
82
- Write a "Collateral Damage" section in your `research.md`:
83
- - List EXACTLY which existing files will need to be modified.
84
- - **Test Invalidation:** Identify which existing `.test.ts` or `.spec.ts` files will break because of these modifications.
85
- - Ensure the mitigation for these breaking changes is passed downstream to the Task generation phase.
86
-
87
- ### 6. Inspector Usage (when needed)
88
- - Use inspector agents for targeted file discovery in large codebases
89
- - Each inspector targets a specific aspect of the task
90
- - Wait for all inspectors to report before analysis
91
- - Save results to `reports/inspect-report.md`
92
- - If the scout cannot name exact paths/tests after inspection, stop and ask a grounded question instead of generating vague tasks
93
-
94
- ## Best Practices
95
-
96
- - Start with documentation before diving into code
97
- - Use inspectors for targeted file discovery
98
- - Document patterns found for consistency
99
- - Note any inconsistencies or technical debt
100
- - Consider impact on existing features
101
- - Use `rg`/targeted search terms or inspector agents before broad traversal
102
- - Pass exact file and test findings downstream into `design.md` and task `Related Files`
@@ -1,76 +0,0 @@
1
- # Cross-Spec Dependency Detection
2
-
3
- ## Purpose
4
-
5
- Before creating a new spec, the system must check whether any existing in-progress spec is related — to avoid file conflicts, duplicated work, or breaking something another spec depends on.
6
-
7
- ## Workflow
8
-
9
- ### Step 1: Scan
10
-
11
- Read `spec.json` in each subdirectory of `specs/`. Filter specs that have any phase in `progress` not yet `done` or `cancelled`.
12
-
13
- ### Step 2: Compare Scope
14
-
15
- For each incomplete spec, compare against the new spec being created:
16
-
17
- | Comparison Criteria | Example |
18
- |---|---|
19
- | Overlapping code files? | Both specs modify `src/auth/login.ts` |
20
- | Shared module/dependency? | Both depend on `@auth/core` |
21
- | Same feature area? | Both belong to "Authentication" module |
22
-
23
- ### Step 3: Classify Relationship
24
-
25
- - **New spec needs results from old spec** → New spec sets `blockedBy: ["<old-spec>"]`
26
- - **New spec changes something old spec uses** → Old spec sets `blockedBy: ["<new-spec>"]`, new spec sets `blocks: ["<old-spec>"]`
27
- - **Mutual dependency** → Both reference each other
28
-
29
- ### Step 4: Bidirectional Update
30
-
31
- When a relationship is detected, update `spec.json` of **BOTH** specs:
32
-
33
- ```json
34
- // specs/auth-system/spec.json
35
- {
36
- "dependencies": {
37
- "blockedBy": [],
38
- "blocks": ["user-dashboard"]
39
- }
40
- }
41
-
42
- // specs/user-dashboard/spec.json
43
- {
44
- "dependencies": {
45
- "blockedBy": ["auth-system"],
46
- "blocks": []
47
- }
48
- }
49
- ```
50
-
51
- ### Step 5: Handle Ambiguity
52
-
53
- Treat dependency direction as a `repository_fact`: inspect owned outputs,
54
- consumers, typed boundaries, and current lifecycle, then ground the edge. Do not
55
- ask the user to guess a factual graph relationship. If no direction can be
56
- grounded, leave the edge absent and report the exact grounding blocker.
57
-
58
- If choosing which deliverable proceeds first changes user-owned scope, release
59
- ordering, data handling, or an irreversible commitment, HOLD and ASK for that
60
- decision; unresolved `user_owned` ordering blocks readiness.
61
-
62
- ## Blocked State
63
-
64
- A spec with `blockedBy` containing a spec not yet `done`:
65
- - The `progress` field shows current phase as `blocked`
66
- - When all blocking specs complete → automatically unblock on next scan
67
-
68
- ## Output Format
69
-
70
- ```
71
- Dependency Scan:
72
- - Found: {N} incomplete specs
73
- - Related: {M} specs with overlapping scope
74
- - Updated: specs/{A}/spec.json ↔ specs/{B}/spec.json
75
- - Status: {A} blocks {B}
76
- ```
@@ -1,107 +0,0 @@
1
- # Research Strategy
2
-
3
- ## Purpose
4
-
5
- Provide tools and methods to gather necessary information before writing requirements and design. The goal is evidence-backed decision-making: use the current codebase and current external knowledge before locking requirements, architecture, and tasks.
6
-
7
- ## Skip Conditions
8
-
9
- - Simple one-file task with no integration point → record skip rationale in `research.md`
10
- - Internal text/docs-only change → record skip rationale in `research.md`
11
- - User already provided recent research reports → use directly, but record what was reused
12
-
13
- Skipping research does NOT mean skipping the evidence trail. Every non-trivial spec still needs an Evidence Summary in `research.md`.
14
-
15
- ## Evidence Gate Triggers
16
-
17
- ### Targeted Codebase Scout — Mandatory When
18
-
19
- - The spec changes existing behavior rather than creating an isolated new artifact.
20
- - The spec touches API routes, CLI commands, package exports, database schemas, migrations, auth/session, permissions, runtime config, hooks, generated artifacts, or settings.
21
- - Requirements or tasks cannot name exact affected files, modules, tests, or contracts.
22
- - The change may invalidate existing `.test.*`, `.spec.*`, e2e, build, or integration checks.
23
- - The spec is being resumed or validated after the codebase may have changed.
24
- - The work crosses monorepo, package source, installed runtime, docs site, or publish/install boundaries.
25
-
26
- ### External / Current Research — Mandatory When
27
-
28
- - The spec depends on third-party APIs, libraries, SDKs, browser/platform policies, package manager behavior, cloud services, or external protocols.
29
- - The spec touches security, auth, payment, privacy, delete-data, compliance, performance, accessibility, SEO, or current framework best practices.
30
- - The spec involves AI providers, model behavior, agent tooling, browser automation, or fast-moving platform constraints.
31
- - The user asks for "best", "optimal", "latest", "recommended", "current", "modern", or equivalent.
32
- - Existing internal docs are stale, incomplete, or contradict package manifests/source code.
33
-
34
- ## 7 Research Tools
35
-
36
- | # | Tool | Description | When to Use |
37
- |---|---|---|---|
38
- | 1 | **Researcher agents** (max 2) | Spawn in parallel, each investigates a different aspect | Complex tasks, need to explore multiple approaches |
39
- | 2 | **Sequential thinking** | Step-by-step reasoning, avoids context overload | Multi-step logic analysis, tangled problems |
40
- | 3 | **Docs seeker** | Look up framework/package docs from official sources | Need to understand external APIs/libraries, find best practices |
41
- | 4 | **GitHub analysis** (`gh`) | Read action logs, PRs, issues, discussions | Need context from project history, understand past decisions |
42
- | 5 | **Repomix remote** (`repomix --remote <url>`) | Generate codebase summary from remote repo | Reference how other repos solve similar problems. *(If not installed, use WebFetch as fallback)* |
43
- | 6 | **Inspector agents** | Search for files across large codebases | Find relevant files faster than grep in large projects |
44
- | 7 | **Debugger delegation** | Hand off to debugger agent for analysis | Investigate root cause of bugs |
45
-
46
- ## Workflow
47
-
48
- ### 1. Classify Evidence Needs
49
- Before detailing requirements, list unanswered questions:
50
- - Which technology is most suitable?
51
- - Is there an existing pattern/library that solves this?
52
- - How does the current codebase handle similar functionality?
53
- - Are there technical risks that need verification?
54
- - What evidence is needed from the repository?
55
- - What evidence requires current external sources?
56
-
57
- ### 2. Run Targeted Codebase Scout
58
- - Read project docs first, then verify claims against source files such as `package.json`, `go.mod`, schemas, routes, tests, and runtime config.
59
- - Use inspector agents for large codebases or when multiple focused searches are needed.
60
- - Save scout details to `reports/inspect-report.md` when inspector agents are used.
61
- - Record the useful summary in `research.md`; do not dump raw search output.
62
-
63
- ### 3. Run External / Current Research
64
- - Prefer official documentation, standards, release notes, package repositories, or maintained upstream examples.
65
- - Use broader web search only when primary sources do not answer the question.
66
- - Record links and explain why each source matters.
67
- - If sources conflict, state which source wins and why.
68
-
69
- ### 4. Pick the Right Tool
70
- - Framework/API questions → Docs seeker
71
- - Current codebase questions → Inspector agents
72
- - Architecture/approach questions → Researcher agents
73
- - Complex multi-step reasoning → Sequential thinking
74
- - Historical decision questions → GitHub analysis
75
-
76
- ### 5. Spawn Researchers (when needed)
77
- - Max 2 agents running in parallel
78
- - Each agent gets a specific aspect (e.g., agent 1 researches auth approach, agent 2 researches database schema)
79
- - Limit each agent to max 5 tool calls
80
- - Wait for all agents to complete before synthesizing
81
-
82
- ### 6. Synthesize Decisions
83
- - Convert raw findings into decisions before writing requirements:
84
- - selected approach
85
- - rejected alternatives
86
- - codebase fit
87
- - external/current constraints
88
- - downstream task and test implications
89
- - If evidence leaves multiple viable choices, classify authority: choose the
90
- simplest reversible engineering option and record its bounded reversal;
91
- HOLD/ASK only for a user-owned product, scope, security, data, or irreversible
92
- decision. Missing repository facts remain grounding blockers, not questions.
93
-
94
- ### 7. Record Findings
95
- - Write to `research.md` using template `templates/research.md`
96
- - Save researcher reports to `reports/researcher-{NN}.md`
97
- - Save inspector reports to `reports/inspect-report.md`
98
-
99
- ## Best Practices
100
-
101
- - Breadth before depth
102
- - Record findings before synthesizing
103
- - Identify multiple approaches for comparison
104
- - Consider edge cases during research
105
- - Flag security concerns early
106
- - Do not design from memory when repository or current external evidence can settle the decision
107
- - Keep external research concise: source, finding, implication, decision
@@ -1,107 +0,0 @@
1
- # Scope Inquiry
2
-
3
- ## Purpose
4
-
5
- Before investing time in planning, select the smallest scope consistent with the
6
- request and evidence. Scope inquiry is an analysis step, not a mandatory user
7
- question.
8
-
9
- ## Skip Conditions
10
-
11
- Skip Scope Inquiry when:
12
- - Task is clearly trivial (1 file, typo fix, config change)
13
- - Description is under 20 words and unambiguous
14
- - User signals urgency ("just do it", "quick", etc.)
15
-
16
- ## 5-Dimension Complexity Assessment
17
-
18
- Evaluate complexity across **5 dimensions** to avoid blind spots. A task may be architecturally small but extremely risky, or seemingly simple but with a huge blast radius.
19
-
20
- ### Dimension 1: Semantic Intent & Current State
21
- - What is the core business or technical meaning of the request?
22
- - How does the system currently behave in this area? What existing patterns, services, or infrastructure can be leveraged?
23
- - Would this spec rebuild something that already exists? If yes, warn before proceeding.
24
-
25
- ### Dimension 2: High-Level Implementation Hypothesis
26
- - Conceptually, how must the architecture adapt to fulfill the semantic intent?
27
- - Hypothesize the structural impact: Does this require new database models, API contracts, third-party integrations, or is it strictly localized logic/UI changes?
28
-
29
- ### Dimension 3: Gap Analysis & Sizing
30
- Evaluate the gap between Current State and Hypothesis:
31
- - **Small**: No architectural changes. Extending existing patterns, adding UI components, or patching localized logic.
32
- - **Medium**: Modifying data flows, adding new API endpoints, or bridging two previously unconnected modules.
33
- - **Large**: New persistence models, security/auth changes, cross-system migrations, or touching core system foundations.
34
- - **Scope check**: Separate aspirational goals (nice-to-haves) from what is strictly necessary to bridge the core gap.
35
-
36
- ### Dimension 4: Risk & Uncertainty (Cynefin-inspired)
37
- Classify the *knowability* of the solution path:
38
- - **Clear**: Well-understood problem with established patterns and documentation (e.g., CRUD endpoints, standard auth flows). Proceed with confidence.
39
- - **Complicated**: Solution exists but requires expert analysis or research (e.g., payment gateway integration, complex query optimization). Plan carefully, may need `researcher` subagent.
40
- - **Complex**: Outcome is uncertain; solution emerges through experimentation (e.g., AI/ML tuning, novel UX interactions, performance bottleneck with unknown root cause). Requires prototyping or spike tasks before committing to a full spec.
41
- - **Chaotic**: No clear path; urgent stabilization needed first (e.g., production outage, data corruption). Skip spec workflow entirely — use `hapo:hotfix` instead.
42
-
43
- > **Rule**: If Dimension 4 = Complex, record the uncertainty and add a bounded
44
- > spike only when it is a real dependency. Chaotic tasks exit to `hapo:hotfix`.
45
- > Ask only when the response requires a user-owned scope or irreversible choice.
46
-
47
- ### Dimension 5: Dependency & Blast Radius
48
- Assess how many other parts of the system are affected if this change breaks or behaves unexpectedly:
49
- - **Isolated**: Change is self-contained within a single module or feature. No shared interfaces touched.
50
- - **Moderate**: Change touches shared utilities, common components, or API contracts consumed by 2-3 other modules.
51
- - **Critical Path**: Change affects core infrastructure (auth, data layer, routing, state management) or shared libraries used system-wide. A bug here cascades everywhere.
52
-
53
- > **Rule**: If Blast Radius = Critical Path, the spec MUST include rollback strategy and explicit test coverage requirements in the task files.
54
-
55
- ### Complexity Smell Check (by numbers)
56
-
57
- After the qualitative 5-Dimension pass, run a quick quantitative gut-check. These are YAGNI tripwires, not hard limits — when one trips, pause and justify or simplify before locking scope:
58
-
59
- - **> 8 files touched** → challenge whether the same goal is reachable with fewer; flag accidental scope creep.
60
- - **> 2 new classes / services / modules** → smell; justify each new abstraction (could an existing module absorb it?).
61
- - **> 12 task files** → the spec is large; consider splitting by deliverable boundary into sibling specs (cross-spec `blockedBy`) rather than one mega-spec.
62
- - **> 15 task files** → strong signal to split. A single mega-spec is slow to generate, prone to mid-run failure, and hard to review. Prefer 2-3 focused specs unless the work is genuinely one indivisible slice.
63
-
64
- If a tripwire fires, first reduce or split using the simplest reversible boundary.
65
- HOLD and ASK only when that change would alter user-owned deliverables or scope.
66
- Do not silently build the mega-version.
67
-
68
- ## Level Selection
69
-
70
- After the assessment, classify the remaining choice:
71
-
72
- - Ground current size, dependencies, and blast radius as `repository_fact`.
73
- - Choose the smallest `reversible_assumption` and record its bounded reversal.
74
- - For a `user_owned` Expand/Hold/Reduce/Split decision, HOLD and present via
75
- `AskUserQuestion`; unresolved scope blocks readiness.
76
-
77
- When a user-owned choice exists, use:
78
-
79
- **Title:** "Scope Inquiry"
80
- **Question:** "Based on analysis, what scope level do you want?"
81
-
82
- | Option | Description | Impact |
83
- |---|---|---|
84
- | **Expand** | Deep research, explore multiple approaches, add stretch features | More research, stretch requirements, more tasks |
85
- | **Hold** | Keep scope as described, prioritize quality | Focus on edge cases, test coverage, failure modes |
86
- | **Reduce** | Core only, defer everything non-essential | Fewer tasks, simpler architecture, defer non-blocking parts |
87
-
88
- ## Immutable Rule
89
-
90
- **Once user picks a level, respect it throughout the entire workflow:**
91
- - Don't silently shrink when user chose Expand or Hold
92
- - Don't silently expand when user chose Reduce
93
- - Raise scope concerns ONCE at this step. Then commit and optimize within the chosen scope.
94
-
95
- ## Output Format
96
-
97
- ```
98
- Scope Inquiry:
99
- - Semantic Intent: [Core meaning of request]
100
- - Hypothesis: [High-level architectural adaptation needed]
101
- - Gap Size: [Small/Medium/Large] — [reason]
102
- - Risk Level: [Clear/Complicated/Complex/Chaotic] — [reason]
103
- - Blast Radius: [Isolated/Moderate/Critical Path] — [affected modules]
104
- - Complexity smells: [none | >8 files | >2 new services | >12 tasks → consider split | >15 tasks → split]
105
- - Minimum Change: [Essential gap vs Niceties]
106
- - Decision: [grounded fact | reversible default + reversal boundary | user choice]
107
- ```
@@ -1,83 +0,0 @@
1
- # Translation Mirror
2
-
3
- Optional, reference-only duplicate of a spec in the user's configured language. The English spec is always the canonical source of truth; the mirror exists only for human cross-reading.
4
-
5
- ## When To Offer
6
-
7
- 1. Read the configured language from `.claude/settings.json` → `language` (a freeform label written at install time, e.g. `Tiếng Việt`, `日本語`, `Korean`, `English`).
8
- 2. If the label resolves to English (`English` / `en`) → **do not** offer a mirror; there is nothing to duplicate.
9
- 3. If it is any other language AND the run is interactive (no `--auto`) → ask once via `AskUserQuestion`:
10
- - "Generate a `<language>` reference copy of this spec? (kept in sync, read-only)" → `Yes` / `No`.
11
- 4. `--auto` runs are non-interactive → **skip** the offer (an `--auto` create makes no mirror). If `translation.enabled` is already `true` from an earlier run, always-sync still applies during an `--auto` resume.
12
- 5. Persist the choice in `spec.json.translation` (see Fields).
13
-
14
- ## Language Code
15
-
16
- Map the freeform label to a short folder code:
17
-
18
- | Label | Code |
19
- |---|---|
20
- | Tiếng Việt | `vi` |
21
- | 日本語 / Japanese | `ja` |
22
- | 한국어 / Korean | `ko` |
23
- | 中文 / Chinese | `zh` |
24
- | Français / French | `fr` |
25
- | (anything else) | kebab-case slug of the label |
26
-
27
- ## Layout
28
-
29
- The mirror lives under the spec, never replacing canonical files:
30
-
31
- ```
32
- specs/<feature>/
33
- ├── spec.json # canonical state — NOT mirrored
34
- ├── requirements.md # English canonical
35
- ├── design.md
36
- ├── research.md
37
- ├── tasks/task-R*.md
38
- └── i18n/<code>/ # mirror (reference only)
39
- ├── requirements.md
40
- ├── design.md
41
- ├── research.md
42
- └── tasks/task-R*.md
43
- ```
44
-
45
- - Mirror **only** the human-readable docs: `requirements.md`, `design.md`, `research.md`, and every `tasks/task-*.md`.
46
- - Do **not** mirror `spec.json` (machine state is language-agnostic and lives only at the root).
47
- - Keep file names and the `tasks/` substructure identical to canonical so they line up 1:1.
48
-
49
- ## Mirror File Marker
50
-
51
- Every generated mirror file MUST begin with this HTML comment so no one mistakes it for a source:
52
-
53
- ```
54
- <!-- TRANSLATION MIRROR — generated from English canonical. Reference only. Do not edit; regenerated on sync. -->
55
- ```
56
-
57
- EARS trigger keywords and fixed phrases stay in English even inside the mirror (`When`, `If`, `While`, `Where`, `The system shall`); only the variable parts are translated — same rule as `rules/ears-format.md`.
58
-
59
- ## Always-Sync
60
-
61
- `spec.json.translation.sync` is `always`:
62
-
63
- - Whenever a canonical doc is written or updated (Step 5 requirements/research, Step 6 design, Step 7 tasks, or any later edit), regenerate the matching mirror file from the new canonical content.
64
- - After regenerating, set `spec.json.translation.last_synced_at` to the current time.
65
- - If a canonical task file is added/removed, add/remove the matching mirror file so the two trees stay 1:1.
66
-
67
- ## Not A Source Of Truth
68
-
69
- - The deterministic validator (`validate-spec-output.cjs`) runs on **canonical only**. The `i18n/` tree is never validated and never blocks `ready_for_implementation`.
70
- - `task_files` and `task_registry` reference canonical paths only.
71
- - `hapo:develop` implements from canonical English; it must ignore `i18n/`.
72
- - If the mirror and canonical ever disagree, canonical wins; re-sync the mirror.
73
-
74
- ## Fields (`spec.json.translation`)
75
-
76
- | Field | Meaning |
77
- |---|---|
78
- | `enabled` | `true` once the user opts in |
79
- | `language` | freeform label from settings (e.g. `Tiếng Việt`) |
80
- | `language_code` | folder code (e.g. `vi`) |
81
- | `dir` | relative mirror dir (e.g. `i18n/vi`) |
82
- | `sync` | `always` |
83
- | `last_synced_at` | ISO 8601 timestamp of the last regeneration |