@haposoft/cafekit 0.15.3 → 0.16.0-rc.1
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.
- package/README.md +4 -2
- package/bin/__tests__/codex-hooks.test.js +140 -0
- package/bin/__tests__/codex-native.test.js +2 -2
- package/bin/__tests__/develop-contract.test.js +1120 -0
- package/bin/__tests__/installer-safety.test.js +510 -2
- package/bin/__tests__/package-inventory.test.js +258 -0
- package/bin/__tests__/secret-scanner.test.js +157 -0
- package/bin/__tests__/validator-grounding.test.js +713 -0
- package/bin/install.js +5 -1
- package/bin/lib/codex-install.js +21 -6
- package/bin/lib/context.js +17 -6
- package/bin/lib/copy-utils.js +31 -0
- package/bin/lib/instruction-blocks.js +85 -0
- package/bin/lib/managed-writer.js +4 -1
- package/bin/lib/opencode-install.js +75 -30
- package/bin/phases/claude-runtime.js +103 -4
- package/bin/phases/codex-runtime.js +9 -5
- package/bin/phases/post-install.js +29 -22
- package/bin/phases/root-config.js +89 -10
- package/package.json +14 -4
- package/src/claude/CLAUDE.md +6 -122
- package/src/claude/agents/code-auditor.md +21 -22
- package/src/claude/agents/debugger.md +3 -3
- package/src/claude/agents/deployer.md +1 -1
- package/src/claude/agents/{god-developer.md → implementer.md} +2 -2
- package/src/claude/agents/project-manager.md +1 -1
- package/src/claude/agents/spec-maker.md +2 -2
- package/src/claude/hooks/__tests__/spec-gate.test.js +356 -5
- package/src/claude/hooks/agent.cjs +7 -14
- package/src/claude/hooks/rules.cjs +33 -53
- package/src/claude/hooks/spec-gate.cjs +66 -21
- package/src/claude/hooks/spec-state.cjs +5 -0
- package/src/claude/migration-manifest.json +9 -2
- package/src/claude/runtime.json +0 -3
- package/src/claude/scripts/generate-skill-catalog.cjs +1 -1
- package/src/claude/scripts/scan-staged-secrets.cjs +170 -0
- package/src/claude/scripts/spec-ground.cjs +189 -83
- package/src/claude/scripts/validate-spec-output.cjs +294 -30
- package/src/claude/scripts/workflow-policy.cjs +609 -0
- package/src/claude/skills/ai-multimodal/SKILL.md +2 -2
- package/src/claude/skills/ai-multimodal/references/audio-processing.md +6 -6
- package/src/claude/skills/ai-multimodal/references/video-analysis.md +1 -1
- package/src/claude/skills/backend-development/SKILL.md +4 -4
- package/src/claude/skills/backend-development/references/backend-architecture.md +1 -1
- package/src/claude/skills/backend-development/references/backend-devops.md +2 -2
- package/src/claude/skills/backend-development/references/backend-mindset.md +3 -3
- package/src/claude/skills/backend-development/references/backend-performance.md +5 -5
- package/src/claude/skills/backend-development/references/backend-security.md +3 -3
- package/src/claude/skills/backend-development/references/backend-technologies.md +5 -5
- package/src/claude/skills/backend-development/references/backend-testing.md +2 -2
- package/src/claude/skills/brainstorm/SKILL.md +2 -3
- package/src/claude/skills/code-review/SKILL.md +12 -8
- package/src/claude/skills/code-review/references/verification-gate.md +4 -4
- package/src/claude/skills/debug/SKILL.md +2 -0
- package/src/claude/skills/develop/SKILL.md +100 -52
- package/src/claude/skills/develop/references/parallel-waves.md +105 -26
- package/src/claude/skills/develop/references/quality-gate.md +58 -38
- package/src/claude/skills/develop/references/subagent-patterns.md +2 -2
- package/src/claude/skills/git/SKILL.md +44 -50
- package/src/claude/skills/hotfix/SKILL.md +10 -8
- package/src/claude/skills/hotfix/references/parallel-patterns.md +2 -2
- package/src/claude/skills/hotfix/references/review-cycle.md +26 -21
- package/src/claude/skills/inspect/SKILL.md +12 -30
- package/src/claude/skills/mobile-development/SKILL.md +12 -12
- package/src/claude/skills/mobile-development/references/mobile-android.md +7 -7
- package/src/claude/skills/mobile-development/references/mobile-best-practices.md +22 -23
- package/src/claude/skills/mobile-development/references/mobile-frameworks.md +13 -13
- package/src/claude/skills/mobile-development/references/mobile-ios.md +1 -1
- package/src/claude/skills/mobile-development/references/mobile-mindset.md +17 -19
- package/src/claude/skills/question/SKILL.md +13 -13
- package/src/claude/skills/research/SKILL.md +2 -2
- package/src/claude/skills/specs/SKILL.md +32 -15
- package/src/claude/skills/specs/references/review.md +3 -3
- package/src/claude/skills/specs/rules/tasks-generation.md +1 -1
- package/src/claude/skills/specs/templates/spec-state.json +7 -3
- package/src/claude/skills/sync/SKILL.md +26 -1
- package/src/claude/skills/sync/references/sync-protocols.md +3 -3
- package/src/claude/skills/test/SKILL.md +12 -4
- package/src/claude/skills/test/references/failure-triage.md +17 -17
- package/src/claude/skills/test/references/test-memory.md +2 -2
- package/src/codex/AGENTS.md +16 -24
- package/src/codex/hooks/lib/spec-receipt.cjs +57 -4
- package/src/codex/hooks/rules.cjs +27 -26
- package/src/codex/hooks/spec-gate.cjs +19 -8
- package/src/codex/hooks/spec-state.cjs +10 -1
- package/src/common/AGENTS.md +43 -0
- package/src/opencode/AGENTS.md +21 -121
- package/src/opencode/plugins/rules.ts +26 -34
- package/src/opencode/plugins/spec-gate.ts +283 -0
- package/src/claude/skills/inspect/references/external-gemini-inspection.md +0 -169
|
@@ -59,13 +59,13 @@ See: `references/backend-technologies.md` for detailed comparisons
|
|
|
59
59
|
|
|
60
60
|
## Key Best Practices (2025)
|
|
61
61
|
|
|
62
|
-
**Security:** Argon2id passwords, parameterized queries
|
|
62
|
+
**Security:** Argon2id passwords, parameterized queries prevent SQL injection, OAuth 2.1 + PKCE, rate limiting, security headers
|
|
63
63
|
|
|
64
|
-
**Performance:** Redis caching
|
|
64
|
+
**Performance:** Redis caching reduces DB load, database indexing reduces I/O, CDN cuts latency, connection pooling
|
|
65
65
|
|
|
66
|
-
**Testing:** 70-20-10 pyramid (unit-integration-E2E), Vitest
|
|
66
|
+
**Testing:** 70-20-10 pyramid (unit-integration-E2E), Vitest or Jest, contract testing for microservices, migration tests
|
|
67
67
|
|
|
68
|
-
**DevOps:** Blue-green/canary deployments, feature flags
|
|
68
|
+
**DevOps:** Blue-green/canary deployments, feature flags can reduce failures, Kubernetes, Prometheus/Grafana monitoring, OpenTelemetry tracing
|
|
69
69
|
|
|
70
70
|
## Quick Decision Matrix
|
|
71
71
|
|
|
@@ -50,7 +50,7 @@ kubectl rollout resume deployment/api
|
|
|
50
50
|
|
|
51
51
|
### Feature Flags (Progressive Delivery)
|
|
52
52
|
|
|
53
|
-
**Impact:**
|
|
53
|
+
**Impact:** Fewer deployment failures when combined with canary
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
56
|
import { LaunchDarkly } from 'launchdarkly-node-server-sdk';
|
|
@@ -105,7 +105,7 @@ CMD ["node", "dist/main.js"]
|
|
|
105
105
|
```
|
|
106
106
|
|
|
107
107
|
**Benefits:**
|
|
108
|
-
- Smaller image size
|
|
108
|
+
- Smaller image size
|
|
109
109
|
- Faster deployments
|
|
110
110
|
- Reduced attack surface
|
|
111
111
|
|
|
@@ -105,7 +105,7 @@ const users = await db.query(`
|
|
|
105
105
|
|
|
106
106
|
### Technical Debt Management
|
|
107
107
|
|
|
108
|
-
**
|
|
108
|
+
**Productivity increase** from addressing technical debt properly
|
|
109
109
|
|
|
110
110
|
**Debt Quadrants:**
|
|
111
111
|
1. **Reckless + Deliberate:** "We don't have time for design"
|
|
@@ -264,7 +264,7 @@ async function getUsers(limit?: number) {
|
|
|
264
264
|
|
|
265
265
|
### Testing Mindset (TDD/BDD)
|
|
266
266
|
|
|
267
|
-
**
|
|
267
|
+
**AI drafts happy-path tests, humans focus on edge cases**
|
|
268
268
|
|
|
269
269
|
**Test-Driven Development (TDD):**
|
|
270
270
|
```
|
|
@@ -287,7 +287,7 @@ Feature: User Registration
|
|
|
287
287
|
|
|
288
288
|
### Observability and Debugging Approach
|
|
289
289
|
|
|
290
|
-
**
|
|
290
|
+
**Positive ROI** from observability investments
|
|
291
291
|
|
|
292
292
|
**Three Questions:**
|
|
293
293
|
1. **Is it slow?** → Check metrics (response time, DB queries)
|
|
@@ -8,7 +8,7 @@ Performance optimization strategies, caching patterns, and scalability best prac
|
|
|
8
8
|
|
|
9
9
|
#### Indexing Strategies
|
|
10
10
|
|
|
11
|
-
**Impact:**
|
|
11
|
+
**Impact:** Reduced disk I/O and faster queries
|
|
12
12
|
|
|
13
13
|
```sql
|
|
14
14
|
-- Create index on frequently queried columns
|
|
@@ -88,7 +88,7 @@ const posts = await Post.findAll({
|
|
|
88
88
|
|
|
89
89
|
### Redis Caching
|
|
90
90
|
|
|
91
|
-
**Impact:**
|
|
91
|
+
**Impact:** Reduced DB load and faster responses
|
|
92
92
|
|
|
93
93
|
#### Cache-Aside Pattern (Lazy Loading)
|
|
94
94
|
|
|
@@ -140,7 +140,7 @@ await redis.keys('user:*').then(keys => redis.del(...keys));
|
|
|
140
140
|
|
|
141
141
|
```
|
|
142
142
|
Client
|
|
143
|
-
→ CDN Cache (static assets,
|
|
143
|
+
→ CDN Cache (static assets, reduced latency)
|
|
144
144
|
→ API Gateway Cache (public endpoints)
|
|
145
145
|
→ Application Cache (Redis)
|
|
146
146
|
→ Database Query Cache
|
|
@@ -236,7 +236,7 @@ emailQueue.process('send-welcome', async (job) => {
|
|
|
236
236
|
|
|
237
237
|
## CDN (Content Delivery Network)
|
|
238
238
|
|
|
239
|
-
**Impact:**
|
|
239
|
+
**Impact:** Reduced latency for global users
|
|
240
240
|
|
|
241
241
|
### Configuration
|
|
242
242
|
|
|
@@ -302,7 +302,7 @@ const users = await replicaDb.users.findAll();
|
|
|
302
302
|
```
|
|
303
303
|
|
|
304
304
|
**Use Cases:**
|
|
305
|
-
- Read-heavy workloads
|
|
305
|
+
- Read-heavy workloads
|
|
306
306
|
- Analytics queries
|
|
307
307
|
- Reporting dashboards
|
|
308
308
|
|
|
@@ -11,7 +11,7 @@ Security best practices, OWASP Top 10 mitigation, and modern security standards
|
|
|
11
11
|
### Top Vulnerabilities & Mitigation
|
|
12
12
|
|
|
13
13
|
#### 1. Broken Access Control
|
|
14
|
-
**Risk:** Users access unauthorized resources
|
|
14
|
+
**Risk:** Users access unauthorized resources
|
|
15
15
|
|
|
16
16
|
**Mitigation:**
|
|
17
17
|
- Implement RBAC (Role-Based Access Control)
|
|
@@ -52,7 +52,7 @@ ph.verify(hash, "password123") # Verify password
|
|
|
52
52
|
#### 3. Injection Attacks
|
|
53
53
|
**Risk:** SQL injection, NoSQL injection, command injection (6x increase 2020-2024)
|
|
54
54
|
|
|
55
|
-
**Mitigation
|
|
55
|
+
**Mitigation:** Parameterized queries prevent SQL injection.
|
|
56
56
|
- Use parameterized queries ALWAYS
|
|
57
57
|
- Input validation with allow-lists
|
|
58
58
|
- Escape special characters
|
|
@@ -156,7 +156,7 @@ pip-audit --fix
|
|
|
156
156
|
- Network segmentation
|
|
157
157
|
- Disable unnecessary protocols (file://, gopher://)
|
|
158
158
|
|
|
159
|
-
## Input Validation (Prevents
|
|
159
|
+
## Input Validation (Prevents Vulnerabilities)
|
|
160
160
|
|
|
161
161
|
### Validation Strategies
|
|
162
162
|
|
|
@@ -22,7 +22,7 @@ Core technologies, frameworks, databases, and message queues for modern backend
|
|
|
22
22
|
**When to Choose:** Team already using JavaScript/TypeScript, real-time features needed, rapid development priority
|
|
23
23
|
|
|
24
24
|
### Python
|
|
25
|
-
**Market Position:** FastAPI adoption
|
|
25
|
+
**Market Position:** FastAPI adoption is increasing among Flask users
|
|
26
26
|
|
|
27
27
|
**Best For:**
|
|
28
28
|
- Data-heavy applications
|
|
@@ -54,7 +54,7 @@ Core technologies, frameworks, databases, and message queues for modern backend
|
|
|
54
54
|
**When to Choose:** Microservices, high concurrency needs, DevOps tooling, simple deployment (single binary)
|
|
55
55
|
|
|
56
56
|
### Rust
|
|
57
|
-
**Market Position:**
|
|
57
|
+
**Market Position:** Highly admired language, faster than Go
|
|
58
58
|
|
|
59
59
|
**Best For:**
|
|
60
60
|
- Performance-critical systems
|
|
@@ -129,7 +129,7 @@ Core technologies, frameworks, databases, and message queues for modern backend
|
|
|
129
129
|
- Rate limiting
|
|
130
130
|
- Real-time leaderboards
|
|
131
131
|
- Job queues (Bull, BullMQ)
|
|
132
|
-
- Caching layer (
|
|
132
|
+
- Caching layer (reduces DB load)
|
|
133
133
|
|
|
134
134
|
**When to Choose:** Need sub-millisecond latency, caching layer, session management
|
|
135
135
|
|
|
@@ -242,9 +242,9 @@ Millions msg/sec? → Yes → Kafka
|
|
|
242
242
|
|
|
243
243
|
1. **Choosing NoSQL for relational data** - Use PostgreSQL if data has clear relationships
|
|
244
244
|
2. **Not using connection pooling** - Implement pooling for 5-10x performance boost
|
|
245
|
-
3. **Ignoring indexes** - Add indexes to frequently queried columns (
|
|
245
|
+
3. **Ignoring indexes** - Add indexes to frequently queried columns (reduces I/O)
|
|
246
246
|
4. **Over-engineering with microservices** - Start monolith, split when needed
|
|
247
|
-
5. **Not caching** - Redis caching
|
|
247
|
+
5. **Not caching** - Redis caching reduces DB load
|
|
248
248
|
|
|
249
249
|
## Resources
|
|
250
250
|
|
|
@@ -24,7 +24,7 @@ Comprehensive testing approaches, frameworks, and quality assurance practices (2
|
|
|
24
24
|
### Frameworks by Language
|
|
25
25
|
|
|
26
26
|
**TypeScript/JavaScript:**
|
|
27
|
-
- **Vitest** -
|
|
27
|
+
- **Vitest** - Faster than Jest in CI/CD, ESM native
|
|
28
28
|
- **Jest** - Mature, large ecosystem, snapshot testing
|
|
29
29
|
|
|
30
30
|
**Python:**
|
|
@@ -269,7 +269,7 @@ test('user can register and login', async ({ page }) => {
|
|
|
269
269
|
|
|
270
270
|
## Database Migration Testing
|
|
271
271
|
|
|
272
|
-
**
|
|
272
|
+
**Migrations fail without proper testing**
|
|
273
273
|
|
|
274
274
|
```typescript
|
|
275
275
|
describe('Database Migrations', () => {
|
|
@@ -59,7 +59,7 @@ If any item is vague, ask one more grounded question. Do not proceed with phrase
|
|
|
59
59
|
| "This is too simple to need a design" | Simple projects = most wasted work from unexamined assumptions. |
|
|
60
60
|
| "I already know the solution" | Then writing it down takes 30 seconds. Do it. |
|
|
61
61
|
| "The user wants action, not talk" | Bad action wastes more time than good planning. |
|
|
62
|
-
| "
|
|
62
|
+
| "I'll skip the scout summary and go straight to questions" | Gate order is scout → summarize findings → ask. Questions come from evidence. |
|
|
63
63
|
| "I'll just prototype quickly" | Prototypes become production code. Design first. |
|
|
64
64
|
|
|
65
65
|
## Collaboration Tools
|
|
@@ -70,8 +70,7 @@ Leverage these specific tools or sub-agents to execute the workflow effectively:
|
|
|
70
70
|
- `hapo:ai-multimodal`: Use this when analyzing visual materials and mockups.
|
|
71
71
|
- `repomix --remote`: Use this bash command to summarize external Github repositories if a URL is provided.
|
|
72
72
|
- `psql`: Query database schemas to understand existing data structures.
|
|
73
|
-
|
|
74
|
-
- **Ecosystem Swarm (`SendMessage`):** Call `researcher` (validation), `docs-keeper` (architecture boundaries), or `project-manager` (scope warnings) for deeply complex specs.
|
|
73
|
+
Call brainstormer only when 2+ architectures have material trade-offs after discovery; call researcher only for external/current facts the repo cannot answer.
|
|
75
74
|
|
|
76
75
|
## Discovery Question Framework
|
|
77
76
|
|
|
@@ -24,6 +24,9 @@ Before executing any review, firmly grasp these two pillars:
|
|
|
24
24
|
- `references/adversarial-review.md` (Stage 3 rules)
|
|
25
25
|
|
|
26
26
|
## Core Principles
|
|
27
|
+
|
|
28
|
+
Executable policy source: `.claude/scripts/workflow-policy.cjs` (source: `src/claude/scripts/workflow-policy.cjs`). Review outputs and consumers must use its exact `PASS | FAIL | BLOCKED` verdict enum.
|
|
29
|
+
|
|
27
30
|
1. **YAGNI**, **KISS**, **DRY** always prevail.
|
|
28
31
|
2. Technical correctness over social comfort. Be honest and straight to the point.
|
|
29
32
|
3. If Specs are provided as PDF or Design Images, do not guess — use `hapo:ai-multimodal` to verify.
|
|
@@ -41,7 +44,7 @@ If invoked without explicit arguments, default to reviewing recent changes (pend
|
|
|
41
44
|
|
|
42
45
|
## 3-Stage Adversarial Protocol
|
|
43
46
|
|
|
44
|
-
Ensure verification walks through these three stages before delivering a final
|
|
47
|
+
Ensure verification walks through these three stages before delivering a final verdict.
|
|
45
48
|
|
|
46
49
|
### Stage 1 — Spec Compliance (with `ai-multimodal` injection)
|
|
47
50
|
Does the code match what was requested?
|
|
@@ -61,18 +64,18 @@ Actively try to break the code.
|
|
|
61
64
|
- Find false assumptions, resource exhaustion loops, and race conditions.
|
|
62
65
|
- Find unhandled edge cases (e.g. empty strings, null pointers, negative integers).
|
|
63
66
|
|
|
64
|
-
## Output
|
|
67
|
+
## Output
|
|
65
68
|
|
|
66
|
-
Your report MUST return
|
|
67
|
-
- **PASS:**
|
|
68
|
-
- **FAIL:**
|
|
69
|
+
Your report MUST classify every finding by severity and return exactly one verdict from `PASS | FAIL | BLOCKED`. Every review verdict/output consumer MUST accept only `PASS | FAIL | BLOCKED` and reject any other value.
|
|
70
|
+
- **PASS:** no Critical findings, no High findings, at most one Medium.
|
|
71
|
+
- **FAIL:** one or more Critical or High findings, or two or more Medium findings.
|
|
72
|
+
- **BLOCKED:** missing execution proof, permission, environment, or user-owned decision prevents review completion. Stop without blind retry; report blocker and required input.
|
|
69
73
|
|
|
70
74
|
Format:
|
|
71
75
|
```markdown
|
|
72
76
|
# Code Review Results [hapo:code-review]
|
|
73
77
|
|
|
74
|
-
**
|
|
75
|
-
**Status:** PASS | FAIL
|
|
78
|
+
**Verdict:** PASS | FAIL | BLOCKED
|
|
76
79
|
**Target:** [PR | Commit | Path]
|
|
77
80
|
|
|
78
81
|
## Stage 1: Spec Compliance
|
|
@@ -83,7 +86,8 @@ Format:
|
|
|
83
86
|
|
|
84
87
|
## Stage 3: Adversarial Findings
|
|
85
88
|
- [🔴 Critical] ...
|
|
86
|
-
- [
|
|
89
|
+
- [🟠 High] ...
|
|
90
|
+
- [🟡 Medium] ...
|
|
87
91
|
- [🔵 Suggestion] ...
|
|
88
92
|
|
|
89
93
|
## Fix Commands (Terminal ready)
|
|
@@ -8,7 +8,7 @@ description: The Iron Law of Proof. Prohibits reporting a 'PASS' status without
|
|
|
8
8
|
In the Hapo ecosystem, words are cheap. Code that "looks right" to an AI can easily break in production. This reference defines the strictest, most uncompromising rule for Code Review.
|
|
9
9
|
|
|
10
10
|
## 1. The Iron Law
|
|
11
|
-
**You MUST NOT issue a final
|
|
11
|
+
**You MUST NOT issue a final verdict of PASS unless you hold concrete, verifiable execution proof.**
|
|
12
12
|
|
|
13
13
|
## 2. Hallucination Block
|
|
14
14
|
Never use the following phrases or implications to assess code functionality:
|
|
@@ -28,6 +28,6 @@ To clear the Verification Gate, you must cite one of the following concrete proo
|
|
|
28
28
|
- **Multimodal Visual Evidence:** `hapo:ai-multimodal` confirming that the visual rendering perfectly matches the design layout.
|
|
29
29
|
|
|
30
30
|
## 4. How to Handle Missing Proof
|
|
31
|
-
If you are asked to review a PR or commit and no execution proof is available
|
|
32
|
-
1. **
|
|
33
|
-
2.
|
|
31
|
+
If you are asked to review a PR or commit and no execution proof is available:
|
|
32
|
+
1. **Return `BLOCKED`** and name missing commands, artifacts, permissions, or environment access.
|
|
33
|
+
2. Do not issue `PASS`, do not downgrade to a tentative pass, and do not blind-retry. Resume only after proof arrives.
|
|
@@ -49,6 +49,8 @@ Do NOT recommend a fix until the root-cause contract is complete.
|
|
|
49
49
|
Do NOT stop at the first plausible explanation. Test hypotheses against evidence.
|
|
50
50
|
If 2+ hypotheses are refuted, change strategy before continuing.
|
|
51
51
|
If evidence is insufficient, report `Root cause: unknown`, `Missing Evidence`, and `Next Diagnostic Action`; do not hand off to `hapo:hotfix` as ready.
|
|
52
|
+
Answer each item in one concrete sentence.
|
|
53
|
+
If any answer contains 'probably', 'I think', 'something with', or 'maybe' — it is not an answer; gather evidence instead.
|
|
52
54
|
</ROOT-CAUSE-GATE>
|
|
53
55
|
|
|
54
56
|
If the user asks to fix while still inside `hapo:debug`, finish the debug report first. Then hand off only the completed root-cause contract to `hapo:hotfix`.
|
|
@@ -16,6 +16,8 @@ Reads the project specification (`hapo:specs`) and implements code through a dis
|
|
|
16
16
|
|
|
17
17
|
**Principles:** YAGNI, KISS, DRY | Continuous execution | Smart self-healing
|
|
18
18
|
|
|
19
|
+
**Executable policy source:** `src/claude/scripts/workflow-policy.cjs` defines Direct/Standard/Critical lane classification, lane delegation, approval-state semantics, mode conflict fail-fast, legacy Light/Standard/Deep delegation, review verdict handling, and flash promotion. Installed Claude runtime uses `.claude/scripts/workflow-policy.cjs`; contracts below must match it.
|
|
20
|
+
|
|
19
21
|
## Usage
|
|
20
22
|
|
|
21
23
|
```bash
|
|
@@ -27,7 +29,52 @@ Reads the project specification (`hapo:specs`) and implements code through a dis
|
|
|
27
29
|
/hapo:develop <feature name> --no-notes
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
##
|
|
32
|
+
## Mode Matrix
|
|
33
|
+
|
|
34
|
+
| Mode | Scout | Quality gate | Receipt | Notes |
|
|
35
|
+
|---|---|---|---|---|
|
|
36
|
+
| default (specific-task / full-spec) | per tier | full (Step 4) | verified | |
|
|
37
|
+
| `--flash` | per tier | Flash Gate (4F) | `FLASH_UNVERIFIED` | |
|
|
38
|
+
| `--parallel` | inspector per task (Critical) | full, inside each worktree | verified | implies Critical lane (legacy Deep) |
|
|
39
|
+
| `--flash --parallel` | **flash+parallel fail-fast — no execution** | | | reject before state/worktree changes |
|
|
40
|
+
| `--no-notes` | — | — | — | composable with all modes |
|
|
41
|
+
|
|
42
|
+
## Argument validation
|
|
43
|
+
|
|
44
|
+
Run policy pre-state guard before loading spec files or mutating state. For the incompatible flag pair, the command must exit nonzero and write no state, receipt, worktree, subagent, or commit:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
node .claude/scripts/workflow-policy.cjs --flash --parallel --json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Expected JSON contract: `{"ok":false,"contract":"execution-policy","failFast":true,...}` with exit code `2`. If both `--flash` and `--parallel` are present, print:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
Unsupported flags: --flash and --parallel are incompatible.
|
|
54
|
+
Remediation: run `/hapo:develop <feature> --flash` or `/hapo:develop <feature> --parallel [N]`.
|
|
55
|
+
No spec state, task receipt, worktree, subagent, or commit was created.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Then STOP with no execution. Never silently drop `--flash`, prefer `--parallel`, or start a more expensive workflow.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Lane selection before spec gate
|
|
62
|
+
|
|
63
|
+
Run lane classification at the runtime boundary before loading spec files or mutating state. Decisions are executable, not advisory prose:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '<task JSON>' --json
|
|
67
|
+
# Downgrade requires explicit user authorization - model-supplied downgrade is blocked
|
|
68
|
+
node .claude/scripts/workflow-policy.cjs --classify-lane --task-json '{"riskSignals":{"auth":true},"override":"Direct","userAuthorized":true}' --json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- **Direct** — clear, isolated, reversible, low-risk work. May skip spec/state/subagents and full task/spec/registry ceremony; execute targeted test, diff self-check, and proportional evidence only.
|
|
72
|
+
- **Standard** — default. Use one bounded spec artifact (`requirements.md` + `design.md` in current layout), one canonical receipt, and exactly one combined `code-auditor` review at feature ship point (not per-task).
|
|
73
|
+
- **Critical** — destructive/irreversible, auth/payment/privacy/data, schema/migration, public contract, cross-runtime coupling, outcome-changing ambiguity, or difficult rollback. Use strict durable state and evidence with risk-driven delegation (inspector/test-runner/code-auditor enabled per risk lens), not a fixed four-agent chain.
|
|
74
|
+
|
|
75
|
+
Explicit overrides are enforced at the runtime boundary. A model-supplied lane or downgrade must not bypass risk signals. Downgrading from Critical requires explicit user-originated authorization (`userAuthorized:true` or `origin:user`) and must surface the trade-off (reduced review/evidence coverage). Keep `generated`, `agent_validated`, and `user_approved` independent; agent validation or --auto never fabricates `user_approved`.
|
|
76
|
+
|
|
77
|
+
Direct may bypass the approved-spec hard gate only for low-risk reversible work. Standard and Critical still require their lane-appropriate spec/state gate.
|
|
31
78
|
|
|
32
79
|
### 1. Specific-Task Mode
|
|
33
80
|
Triggered by `/hapo:develop <feature> <task-file>`.
|
|
@@ -46,7 +93,7 @@ Triggered by `/hapo:develop <feature>` or `/hapo:develop specs/<feature>`.
|
|
|
46
93
|
- Sync state.
|
|
47
94
|
- Recompute the queue and continue.
|
|
48
95
|
- STOP the overall run on the first blocked task, unresolved gate failure, or missing proof.
|
|
49
|
-
- In `--flash` mode, missing full test proof
|
|
96
|
+
- In `--flash` mode, missing full test proof stores the task as `status: "in_progress"` with receipt `FLASH_UNVERIFIED` and blocker `awaiting /hapo:test <feature>`. It does not unblock dependencies or mark the task done.
|
|
50
97
|
|
|
51
98
|
### 2b. Parallel Wave Mode (opt-in)
|
|
52
99
|
Triggered by adding `--parallel [N]` to Full-Spec mode. Load `references/parallel-waves.md` and follow it exactly — it is the operating procedure (wave planning, dispatch, merge, cleanup).
|
|
@@ -64,7 +111,7 @@ Contracts: WAVE_CONFIG
|
|
|
64
111
|
|
|
65
112
|
- Preconditions first: if `runtime.json` sets `develop.parallel: false`, refuse `--parallel`, name the key, and run the sequential loop. If the work context is not a git repository or worktree isolation is unavailable, state the reason and fall back sequential (see parallel-waves.md §1).
|
|
66
113
|
- Waves are computed from `task_registry.dependencies` with the single-writer-per-file rule; wave cap = N (1..5, default 3).
|
|
67
|
-
- Dispatch one `
|
|
114
|
+
- Dispatch one `implementer` per wave task — worktree isolation, background, self-contained prompt per `rules/orchestrator.md`, plus the mandatory lines in parallel-waves.md §3 (commit mandate; never edit `spec.json`/`tasks/*.md`; never touch files outside the task's `Related Files`).
|
|
68
115
|
- Quality gate (Stage A+B, unchanged) runs inside each task's worktree BEFORE merge; merge = sequential `git cherry-pick` of agent commits with explicit worktree/branch cleanup (spike-verified — see parallel-waves.md §5); post-merge integration check gates the next wave.
|
|
69
116
|
- The orchestrator is the single writer of spec state: registry/task-md/receipts update after each cherry-pick, exactly as in sequential mode.
|
|
70
117
|
- Without `--parallel`, nothing in this section applies — the sequential Full-Spec loop below is unchanged.
|
|
@@ -77,23 +124,39 @@ Triggered by adding `--flash` to either specific-task or full-spec mode.
|
|
|
77
124
|
- Skip dedicated test suites, E2E/browser/manual QA loops, full task evidence execution, and code-review retry loops.
|
|
78
125
|
- Run only cheap preflight checks when available and fast: syntax, typecheck, or build commands that do not require installing dependencies or starting external services.
|
|
79
126
|
- Never weaken, delete, or rewrite tests to avoid running them.
|
|
80
|
-
- Sync
|
|
127
|
+
- Sync the implementation as `status: "in_progress"` with receipt `FLASH_UNVERIFIED`, blocker `awaiting /hapo:test <feature>`, and no dependency unblocking. Do not claim task or feature completion.
|
|
81
128
|
- Final output MUST recommend `/hapo:test <feature>` before merge, release, or publish.
|
|
82
129
|
|
|
83
130
|
### 4. Implementation Notes
|
|
84
|
-
|
|
131
|
+
Implementation notes apply to Standard/Critical modes by default; Direct stays artifact-free unless user explicitly requests a receipt. Disable notes with `--no-notes`.
|
|
85
132
|
|
|
86
|
-
-
|
|
87
|
-
-
|
|
133
|
+
- **Standard/Critical**: maintain `specs/<feature-name>/implementation-notes.html`.
|
|
134
|
+
- **Standard/Critical**: use `references/implementation-notes-template.html` when the file does not exist.
|
|
88
135
|
- Keep the file self-contained: inline CSS, no JS, no external fonts, no network assets.
|
|
89
136
|
- Style notes as readable Claude Code-like blocks: compact cards, left accent bars, category badges, monospace file paths, and a task timeline.
|
|
90
137
|
- Record decisions and caveats while implementing, not only at the end.
|
|
91
138
|
- Do not use notes to justify scope changes that alter the approved contract. If the contract changes, stop and route back to `/hapo:specs update`.
|
|
92
139
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
140
|
+
## Delegation policy (single source for this skill)
|
|
141
|
+
|
|
142
|
+
Implement in the main session by default. Do not spawn a subagent because a step
|
|
143
|
+
mentions an agent name — spawn only per this table:
|
|
144
|
+
|
|
145
|
+
| Lane | Delegation (risk-driven) | Quality gate |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| Direct | None | Main-session targeted verification and diff self-check |
|
|
148
|
+
| Standard | Exactly one combined `code-auditor` at feature ship point (not per-task) | Feature-level ship point |
|
|
149
|
+
| Critical | Risk-driven: `inspector` when discovery needed, `test-runner` when code changes, `code-auditor` at feature closeout (not fixed four-agent per task) | Strict evidence gate |
|
|
150
|
+
|
|
151
|
+
Legacy `execution_tier` (`Light | Standard | Deep`) is retained only as backward-compatible metadata (tier = Light → Direct, Standard → Standard, Deep → Critical). When both exist, lane policy controls ceremony/delegation and tier is metadata only. Do not treat tier as authoritative.
|
|
152
|
+
|
|
153
|
+
<LANE-GATE>
|
|
154
|
+
Do not write implementation code until lane classification runs at the runtime boundary.
|
|
155
|
+
- **Direct** may bypass spec/state/registry and full task ceremony only when classifier confirms clear, isolated, reversible, low-risk work; targeted verification and evidence remain mandatory.
|
|
156
|
+
- **Standard** requires one bounded approved spec artifact (`requirements.md` + `design.md` in current layout) and canonical receipt before implementation; exactly one feature-level closeout review.
|
|
157
|
+
- **Critical** requires approved lane-appropriate spec/state plus strict evidence before implementation; delegation is risk-driven, not a fixed chain.
|
|
158
|
+
Never treat a Direct override as automatic low risk; preserve its warning, risk signals, and user authorization requirement. Model-supplied downgrades without user authorization are blocked.
|
|
159
|
+
</LANE-GATE>
|
|
97
160
|
|
|
98
161
|
<DEFINITION-OF-DONE>
|
|
99
162
|
A task is NOT done because code compiles or a placeholder renders.
|
|
@@ -111,21 +174,16 @@ The approved `scope_lock`, requirements, design contracts, and active task packe
|
|
|
111
174
|
You MUST implement all scoped behavior for the active task, MUST NOT add out-of-scope behavior, and MUST NOT mark work done while required surfaces exist only as orphaned files, unmounted UI, unregistered routes, uncalled loaders, or placeholder wiring.
|
|
112
175
|
</SCOPE-FIDELITY>
|
|
113
176
|
|
|
114
|
-
## Anti-Rationalization Protocol
|
|
115
|
-
|
|
116
|
-
| Thought (Excuse) | Reality (Rule) |
|
|
117
|
-
|-------------------|----------------|
|
|
118
|
-
| "No need to scout first" | Coding without knowing the architecture is blind. ALWAYS call the `inspector` agent to scan files. |
|
|
119
|
-
| "Review process is too tedious, let me just finish it myself" | The system needs an audit trail through agents. ALWAYS delegate via the `Agent` tool. |
|
|
120
|
-
|
|
121
177
|
## Absolute Workflow
|
|
122
178
|
|
|
123
179
|
```mermaid
|
|
124
180
|
flowchart TD
|
|
125
|
-
A["/hapo:develop \u003cfeature\u003e"] -->
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
181
|
+
A["/hapo:develop \u003cfeature\u003e"] --> L[Classify lane]
|
|
182
|
+
L -->|Direct| D[Step 3: Implement (targeted or lane-scoped)]
|
|
183
|
+
L -->|Standard/Critical| B[Step 1: Load lane spec/state]
|
|
184
|
+
B -->|Missing or not approved| Z[Stop: Run lane-appropriate /hapo:specs]
|
|
185
|
+
B -->|Ready| C[Step 2: Task-Aware Scout (per lane policy)]
|
|
186
|
+
C --> D
|
|
129
187
|
D --> E{Flash Mode?}
|
|
130
188
|
E -->|No| Q[Step 4: Quality Gate: Test + Spec Review + Code Review + Evidence]
|
|
131
189
|
E -->|Yes| R[Step 4F: Flash Gate: Minimal Preflight + Scope Sanity]
|
|
@@ -139,37 +197,29 @@ flowchart TD
|
|
|
139
197
|
```
|
|
140
198
|
|
|
141
199
|
### Step 1: Initialize & Load Spec
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
200
|
+
- **Direct**: after classifier confirms low-risk reversible work, skip spec/state/registry initialization and continue with targeted implementation/evidence.
|
|
201
|
+
- **Standard/Critical**: identify input and open the lane-appropriate `spec.json` plus bounded spec artifacts; require approved state before implementation.
|
|
202
|
+
- Check `ready_for_implementation` only for Standard/Critical specs. If not ready, notify user.
|
|
203
|
+
- **Standard/Critical only**: load `task_registry` and verify it matches the requested task file(s). If registry is missing or stale, route to `/hapo:sync audit <feature>` before coding.
|
|
204
|
+
- **Standard/Critical only**: unless `--no-notes` is present, initialize or update `specs/<feature-name>/implementation-notes.html`:
|
|
146
205
|
- If missing, create it from `references/implementation-notes-template.html`.
|
|
147
206
|
- Replace template placeholders for feature name, spec path, creation timestamp, and current mode.
|
|
148
207
|
- If present, preserve existing note cards and update the summary/timeline/status fields.
|
|
149
|
-
- **
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
-
|
|
153
|
-
|
|
154
|
-
- Related Files
|
|
155
|
-
- Completion Criteria
|
|
156
|
-
- `## Evidence` (legacy heading aliases still parse)
|
|
157
|
-
- Exact executable verification commands named in the task
|
|
158
|
-
- Requirement IDs referenced by the task
|
|
159
|
-
- Named technologies, frameworks, protocols, and data stores that the task/spec explicitly requires
|
|
160
|
-
- Relevant `Canonical Contracts & Invariants` from `design.md`
|
|
161
|
-
- If the task file is missing actionable completion or verification detail, STOP and route back to spec correction. Do not guess.
|
|
162
|
-
- Before coding, set the active task(s) to `in_progress` in both markdown and `spec.json.task_registry`, or route through `/hapo:sync` if the runtime expects the sync protocol.
|
|
208
|
+
- **Direct** does not create or update spec implementation notes unless user explicitly asks for a receipt.
|
|
209
|
+
- **Standard/Critical only**: load exactly one task packet for specific-task mode, or resolve one unblocked task from `task_registry` for full-spec mode.
|
|
210
|
+
- **Standard/Critical only**: extract Objective + Constraints, Related Files, Completion Criteria, Evidence commands, requirement IDs, named technologies, and canonical contracts before coding.
|
|
211
|
+
- If a Standard/Critical task file lacks actionable completion or verification detail, stop and route back to spec correction. Direct does not use this packet gate.
|
|
212
|
+
- **Standard/Critical only**: set the active task to `in_progress` in markdown and `spec.json.task_registry` before coding. Direct has no registry mutation.
|
|
163
213
|
|
|
164
214
|
### Step 2: Scout (Codebase Inspection)
|
|
165
|
-
- **
|
|
166
|
-
- The
|
|
215
|
+
- **Scout per Delegation policy** — Critical may delegate to `inspector` when risk lens requires discovery; Direct/Standard scout in the main session with the same required outputs (legacy Light/Standard/Deep tier is metadata only):
|
|
216
|
+
- The scout prompt MUST include:
|
|
167
217
|
- Active task file path and extracted task packet
|
|
168
218
|
- Requirement IDs and `scope_lock`
|
|
169
219
|
- Relevant `design.md` contracts/invariants
|
|
170
220
|
- Prior completed task outputs from `spec.json.task_registry`
|
|
171
221
|
- Related Files from the active task
|
|
172
|
-
-
|
|
222
|
+
- The scout MUST report:
|
|
173
223
|
- Real runtime entrypoints/callers affected by the task (`App.tsx`, routes, CLI command, worker registration, manifest, API consumer, etc.)
|
|
174
224
|
- Existing integration points and adjacent code patterns to follow
|
|
175
225
|
- Prior task outputs this task must consume or preserve
|
|
@@ -179,10 +229,10 @@ flowchart TD
|
|
|
179
229
|
- If the inspector cannot identify the entrypoint/caller for a runtime-facing task, STOP and route back to spec correction or ask the user. Do not guess.
|
|
180
230
|
|
|
181
231
|
### Step 3: Implement Code
|
|
182
|
-
- Act as `
|
|
232
|
+
- Act as the `implementer` per the Delegation policy (default: the main session), executing tasks specified in the loaded Markdown file(s) sequentially.
|
|
183
233
|
- **Important:** You may create and modify files directly, but must faithfully follow the design from the Spec.
|
|
184
234
|
- You MUST use the Step 2 scout report as implementation context. If code reality contradicts the task packet, stop and reconcile the spec before coding.
|
|
185
|
-
-
|
|
235
|
+
- **Standard/Critical only**: unless `--no-notes` is present, append a note card to `implementation-notes.html` whenever any of these occurs:
|
|
186
236
|
- `decision`: a necessary implementation choice not specified by the spec
|
|
187
237
|
- `spec-gap`: missing or ambiguous spec detail discovered during implementation
|
|
188
238
|
- `codebase-reality`: existing code requires a different integration path than the task implied
|
|
@@ -208,7 +258,7 @@ flowchart TD
|
|
|
208
258
|
|
|
209
259
|
### Step 4: Self-Healing (Quality Gate Auto-Fix)
|
|
210
260
|
The moment you finish coding, DO NOT proceed further. Switch to `references/quality-gate.md` and run the automatic review loop.
|
|
211
|
-
**Mantra:** Scope/spec compliance first, code quality second. All feedback from code-auditor must be addressed thoroughly:
|
|
261
|
+
**Mantra:** Scope/spec compliance first, code quality second. All feedback from code-auditor must be addressed thoroughly: PASS requires no Critical findings, no High findings, and at most one Medium.
|
|
212
262
|
|
|
213
263
|
If `--flash` is active, use **Step 4F: Flash Gate** instead of the full automatic review loop.
|
|
214
264
|
|
|
@@ -217,11 +267,9 @@ If `--flash` is active, use **Step 4F: Flash Gate** instead of the full automati
|
|
|
217
267
|
2. Spec compliance review passes: every scoped requirement and active task criterion is implemented, with no extras and no omissions
|
|
218
268
|
3. Code quality review passes
|
|
219
269
|
4. Task evidence passes (artifacts/runtime surfaces/reachability/negative-path checks from the task file are proven)
|
|
270
|
+
- Violating any Step 3 rule = FAIL.
|
|
220
271
|
- `PRECHECK_FAIL` outranks `NO_TESTS`. If compile/typecheck/build fails, the task is FAIL even when no test suite exists yet.
|
|
221
|
-
- `NO_TESTS` is NOT equivalent to PASS. If the task explicitly requires a test command or automated test proof, `NO_TESTS` is a FAIL or BLOCKED outcome until the requirement is satisfied or the spec is corrected.
|
|
222
272
|
- If build/test passes but task evidence is missing, the task is still FAIL.
|
|
223
|
-
- If runtime-facing work is orphaned, unmounted, unregistered, uncalled, or unreachable from the declared entrypoint/caller, the task is still FAIL.
|
|
224
|
-
- If the implementation silently replaced a named contract choice or relies on cross-service process-local stand-ins, the task is still FAIL.
|
|
225
273
|
- Only escalate to the user after 3 consecutive failed review rounds.
|
|
226
274
|
|
|
227
275
|
### Step 4F: Flash Gate (`--flash` only)
|
|
@@ -245,7 +293,7 @@ Flash mode is an explicit speed trade-off requested by the user.
|
|
|
245
293
|
|
|
246
294
|
### Step 5: State Sync + Task-Level Docs Sync
|
|
247
295
|
- Only after Step 4 passes may you mark task checkboxes completed and sync `spec.json` progress/timestamps/task_registry.
|
|
248
|
-
- In `--flash
|
|
296
|
+
- In `--flash`, Step 4F may record implementation closeout only as `status: "in_progress"` with `FLASH_UNVERIFIED` and blocker `awaiting /hapo:test <feature>`; it never syncs `done` or unblocks dependencies.
|
|
249
297
|
- If verification is partial or blocked by environment, keep the task in `pending` or `in_progress` and record the blocker instead of pretending completion.
|
|
250
298
|
- A completed task MUST leave behind:
|
|
251
299
|
- markdown `**Status:** done`
|
|
@@ -253,7 +301,7 @@ Flash mode is an explicit speed trade-off requested by the user.
|
|
|
253
301
|
- `completed_at` + `last_updated_at`
|
|
254
302
|
- synchronized top-level `updated_at`
|
|
255
303
|
- a human-readable verification receipt inside the task's `Evidence` section showing which commands ran, their outcomes, and what proof was observed
|
|
256
|
-
- In `--flash
|
|
304
|
+
- In `--flash`, the receipt MUST include `Mode: --flash`, `Tests: skipped by user request`, `Evidence: FLASH_UNVERIFIED`, `Status: in_progress`, `Blocker: awaiting /hapo:test <feature>`, and `Next verification: /hapo:test <feature>`.
|
|
257
305
|
- Verification receipts with `PRECHECK_FAIL`, `FAIL`, `UNVERIFIED`, or an explicit note that the implementation intentionally simplified a named contract MUST NOT be synchronized as `done`.
|
|
258
306
|
- Exception: `FLASH_UNVERIFIED` is allowed only when `--flash` is explicitly present. It records fast implementation completion, not full verification completion.
|
|
259
307
|
- Unless `--no-notes` is present, update `implementation-notes.html` before reporting the task:
|
|
@@ -267,7 +315,7 @@ Flash mode is an explicit speed trade-off requested by the user.
|
|
|
267
315
|
- If `none`: record that explicitly in the completion report and stop
|
|
268
316
|
- If `minor` or `major`: trigger `docs-keeper` to surgically update affected existing docs under `./docs`
|
|
269
317
|
- Default to **lightweight docs sync**: update only the docs touched by this task and its verified behavior; do NOT run `repomix` unless `docs-keeper` truly cannot verify the required architecture/context from the code, spec, and current docs
|
|
270
|
-
- **CWD Protocol (CRITICAL):** When spawning `docs-keeper`,
|
|
318
|
+
- **CWD Protocol (CRITICAL):** When spawning `docs-keeper`, set its Current Working Directory (CWD context) to the **Workspace Root**, not the inner package directory.
|
|
271
319
|
- Task-level docs sync happens after every verified completed task, but actual edits still depend on `Docs impact`.
|
|
272
320
|
- In **Specific-Task Mode**, STOP after sync and report the result.
|
|
273
321
|
- In **Full-Spec Mode**, only after sync may you re-read `task_registry`, pick the next unblocked pending task, and repeat from Step 1 for that task.
|