@curdx/flow 2.3.11 → 3.1.0

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 (210) hide show
  1. package/CHANGELOG.md +21 -34
  2. package/LICENSE +1 -1
  3. package/README.md +28 -79
  4. package/dist/index.mjs +995 -0
  5. package/package.json +33 -42
  6. package/.claude-plugin/marketplace.json +0 -48
  7. package/.claude-plugin/plugin.json +0 -70
  8. package/agent-preamble/preamble.md +0 -314
  9. package/agents/flow-adversary.md +0 -202
  10. package/agents/flow-architect.md +0 -197
  11. package/agents/flow-brownfield-analyst.md +0 -142
  12. package/agents/flow-debugger.md +0 -321
  13. package/agents/flow-edge-hunter.md +0 -288
  14. package/agents/flow-executor.md +0 -269
  15. package/agents/flow-orchestrator.md +0 -145
  16. package/agents/flow-planner.md +0 -246
  17. package/agents/flow-product-designer.md +0 -159
  18. package/agents/flow-qa-engineer.md +0 -282
  19. package/agents/flow-researcher.md +0 -165
  20. package/agents/flow-reviewer.md +0 -303
  21. package/agents/flow-security-auditor.md +0 -401
  22. package/agents/flow-triage-analyst.md +0 -272
  23. package/agents/flow-ui-researcher.md +0 -229
  24. package/agents/flow-ux-designer.md +0 -221
  25. package/agents/flow-verifier.md +0 -349
  26. package/bin/curdx-flow +0 -5
  27. package/bin/curdx-flow.js +0 -54
  28. package/cli/README.md +0 -104
  29. package/cli/doctor-workflow.js +0 -483
  30. package/cli/doctor.js +0 -73
  31. package/cli/help.js +0 -59
  32. package/cli/install-bundled-mcps.js +0 -37
  33. package/cli/install-companions.js +0 -19
  34. package/cli/install-context7-config.js +0 -80
  35. package/cli/install-curdx-plugin.js +0 -96
  36. package/cli/install-language.js +0 -35
  37. package/cli/install-next-steps.js +0 -29
  38. package/cli/install-options.js +0 -9
  39. package/cli/install-paths.js +0 -52
  40. package/cli/install-recommended-plugins.js +0 -104
  41. package/cli/install-required-plugins.js +0 -57
  42. package/cli/install-self-update.js +0 -62
  43. package/cli/install-workflow.js +0 -209
  44. package/cli/install.js +0 -101
  45. package/cli/lib/claude-commands.js +0 -41
  46. package/cli/lib/claude-ops.js +0 -47
  47. package/cli/lib/claude.js +0 -183
  48. package/cli/lib/config.js +0 -24
  49. package/cli/lib/doctor-claude-settings.js +0 -1186
  50. package/cli/lib/doctor-report.js +0 -978
  51. package/cli/lib/doctor-runtime-environment.js +0 -196
  52. package/cli/lib/frontmatter.js +0 -44
  53. package/cli/lib/json-schema.js +0 -57
  54. package/cli/lib/logging.js +0 -25
  55. package/cli/lib/process.js +0 -60
  56. package/cli/lib/prompts.js +0 -135
  57. package/cli/lib/runtime.js +0 -107
  58. package/cli/lib/semver.js +0 -109
  59. package/cli/lib/version.js +0 -12
  60. package/cli/protocols-body.md +0 -22
  61. package/cli/protocols.js +0 -162
  62. package/cli/registry.js +0 -123
  63. package/cli/router.js +0 -49
  64. package/cli/uninstall-actions.js +0 -360
  65. package/cli/uninstall-workflow.js +0 -146
  66. package/cli/uninstall.js +0 -42
  67. package/cli/upgrade-workflow.js +0 -80
  68. package/cli/upgrade.js +0 -91
  69. package/cli/utils.js +0 -40
  70. package/gates/adversarial-review-gate.md +0 -219
  71. package/gates/coverage-audit-gate.md +0 -182
  72. package/gates/devex-gate.md +0 -254
  73. package/gates/edge-case-gate.md +0 -194
  74. package/gates/karpathy-gate.md +0 -130
  75. package/gates/security-gate.md +0 -218
  76. package/gates/tdd-gate.md +0 -182
  77. package/gates/test-quality-gate.md +0 -59
  78. package/gates/verification-gate.md +0 -179
  79. package/hooks/hooks.json +0 -58
  80. package/hooks/scripts/common.sh +0 -46
  81. package/hooks/scripts/inject-karpathy.sh +0 -53
  82. package/hooks/scripts/quick-mode-guard.sh +0 -68
  83. package/hooks/scripts/session-start.sh +0 -90
  84. package/hooks/scripts/stop-watcher.sh +0 -230
  85. package/hooks/scripts/subagent-artifact-guard.sh +0 -159
  86. package/hooks/scripts/subagent-statusline.sh +0 -105
  87. package/knowledge/artifact-output-discipline.md +0 -24
  88. package/knowledge/artifact-summary-contracts.md +0 -50
  89. package/knowledge/atomic-commits.md +0 -262
  90. package/knowledge/claude-code-runtime-contracts.md +0 -219
  91. package/knowledge/epic-decomposition.md +0 -307
  92. package/knowledge/execution-strategies.md +0 -303
  93. package/knowledge/karpathy-guidelines.md +0 -219
  94. package/knowledge/planning-reviews.md +0 -211
  95. package/knowledge/poc-first-workflow.md +0 -223
  96. package/knowledge/review-feedback-intake.md +0 -57
  97. package/knowledge/spec-driven-development.md +0 -180
  98. package/knowledge/systematic-debugging.md +0 -378
  99. package/knowledge/two-stage-review.md +0 -249
  100. package/knowledge/wave-execution.md +0 -403
  101. package/monitors/monitors.json +0 -8
  102. package/monitors/scripts/flow-state-monitor.sh +0 -99
  103. package/output-styles/curdx-evidence-first.md +0 -34
  104. package/schemas/agent-frontmatter.schema.json +0 -63
  105. package/schemas/config.schema.json +0 -134
  106. package/schemas/gate-frontmatter.schema.json +0 -30
  107. package/schemas/hooks.schema.json +0 -115
  108. package/schemas/output-style-frontmatter.schema.json +0 -22
  109. package/schemas/plugin-manifest.schema.json +0 -436
  110. package/schemas/plugin-settings.schema.json +0 -29
  111. package/schemas/skill-frontmatter.schema.json +0 -177
  112. package/schemas/spec-frontmatter.schema.json +0 -42
  113. package/schemas/spec-state.schema.json +0 -147
  114. package/settings.json +0 -7
  115. package/skills/brownfield-index/SKILL.md +0 -53
  116. package/skills/brownfield-index/references/applicability.md +0 -12
  117. package/skills/brownfield-index/references/handoff.md +0 -8
  118. package/skills/brownfield-index/references/index-contract.md +0 -10
  119. package/skills/browser-qa/SKILL.md +0 -39
  120. package/skills/browser-qa/references/handoff.md +0 -6
  121. package/skills/browser-qa/references/prerequisites.md +0 -10
  122. package/skills/browser-qa/references/qa-contract.md +0 -20
  123. package/skills/cancel/SKILL.md +0 -41
  124. package/skills/cancel/references/destructive-mode.md +0 -17
  125. package/skills/cancel/references/reporting.md +0 -18
  126. package/skills/cancel/references/state-recovery.md +0 -30
  127. package/skills/cancel/references/target-resolution.md +0 -7
  128. package/skills/debug/SKILL.md +0 -45
  129. package/skills/debug/references/context-gathering.md +0 -11
  130. package/skills/debug/references/failure-guard.md +0 -25
  131. package/skills/debug/references/intake.md +0 -12
  132. package/skills/debug/references/phase-workflow.md +0 -34
  133. package/skills/debug/references/reporting.md +0 -20
  134. package/skills/epic/SKILL.md +0 -39
  135. package/skills/epic/references/epic-artifacts.md +0 -20
  136. package/skills/epic/references/epic-intake.md +0 -9
  137. package/skills/epic/references/slice-handoff.md +0 -16
  138. package/skills/fast/SKILL.md +0 -62
  139. package/skills/fast/references/applicability.md +0 -25
  140. package/skills/fast/references/clarification.md +0 -20
  141. package/skills/fast/references/execution-contract.md +0 -56
  142. package/skills/help/SKILL.md +0 -55
  143. package/skills/help/references/dispatch.md +0 -20
  144. package/skills/help/references/overview.md +0 -39
  145. package/skills/help/references/troubleshoot.md +0 -47
  146. package/skills/help/references/workflow.md +0 -37
  147. package/skills/implement/SKILL.md +0 -96
  148. package/skills/implement/references/error-recovery.md +0 -36
  149. package/skills/implement/references/linear-execution.md +0 -32
  150. package/skills/implement/references/preflight.md +0 -43
  151. package/skills/implement/references/progress-contract.md +0 -32
  152. package/skills/implement/references/state-init.md +0 -33
  153. package/skills/implement/references/stop-hook-execution.md +0 -36
  154. package/skills/implement/references/strategy-router.md +0 -38
  155. package/skills/implement/references/subagent-execution.md +0 -43
  156. package/skills/implement/references/wave-execution.md +0 -162
  157. package/skills/init/SKILL.md +0 -49
  158. package/skills/init/references/gitignore-and-health.md +0 -26
  159. package/skills/init/references/next-steps.md +0 -22
  160. package/skills/init/references/preflight.md +0 -15
  161. package/skills/init/references/scaffold-contract.md +0 -27
  162. package/skills/review/SKILL.md +0 -82
  163. package/skills/review/references/optional-passes.md +0 -48
  164. package/skills/review/references/preflight.md +0 -38
  165. package/skills/review/references/report-contract.md +0 -49
  166. package/skills/review/references/reporting.md +0 -20
  167. package/skills/review/references/stage-execution.md +0 -32
  168. package/skills/security-audit/SKILL.md +0 -47
  169. package/skills/security-audit/references/audit-contract.md +0 -21
  170. package/skills/security-audit/references/gate-handoff.md +0 -8
  171. package/skills/security-audit/references/scope-and-depth.md +0 -9
  172. package/skills/spec/SKILL.md +0 -100
  173. package/skills/spec/references/artifact-landing.md +0 -31
  174. package/skills/spec/references/phase-execution.md +0 -50
  175. package/skills/spec/references/planning-review.md +0 -31
  176. package/skills/spec/references/preflight-and-routing.md +0 -46
  177. package/skills/spec/references/reporting.md +0 -21
  178. package/skills/start/SKILL.md +0 -84
  179. package/skills/start/references/branch-routing.md +0 -51
  180. package/skills/start/references/mode-semantics.md +0 -12
  181. package/skills/start/references/preflight.md +0 -13
  182. package/skills/start/references/reporting.md +0 -20
  183. package/skills/start/references/state-seeding.md +0 -44
  184. package/skills/start/references/workflow-handoff.md +0 -26
  185. package/skills/status/SKILL.md +0 -41
  186. package/skills/status/references/gather-contract.md +0 -27
  187. package/skills/status/references/health-rules.md +0 -27
  188. package/skills/status/references/output-contract.md +0 -24
  189. package/skills/status/references/preflight.md +0 -10
  190. package/skills/status/references/recovery-hints.md +0 -18
  191. package/skills/ui-sketch/SKILL.md +0 -39
  192. package/skills/ui-sketch/references/brief-intake.md +0 -10
  193. package/skills/ui-sketch/references/iteration-handoff.md +0 -5
  194. package/skills/ui-sketch/references/variant-contract.md +0 -15
  195. package/skills/verify/SKILL.md +0 -56
  196. package/skills/verify/references/evidence-workflow.md +0 -39
  197. package/skills/verify/references/output-contract.md +0 -23
  198. package/skills/verify/references/preflight.md +0 -11
  199. package/skills/verify/references/report-handoff.md +0 -35
  200. package/skills/verify/references/strict-mode.md +0 -12
  201. package/templates/CONTEXT.md.tmpl +0 -53
  202. package/templates/PROJECT.md.tmpl +0 -59
  203. package/templates/ROADMAP.md.tmpl +0 -50
  204. package/templates/STATE.md.tmpl +0 -49
  205. package/templates/config.json.tmpl +0 -51
  206. package/templates/design.md.tmpl +0 -83
  207. package/templates/progress.md.tmpl +0 -77
  208. package/templates/requirements.md.tmpl +0 -76
  209. package/templates/research.md.tmpl +0 -83
  210. package/templates/tasks.md.tmpl +0 -107
@@ -1,59 +0,0 @@
1
- ---
2
- gate: test-quality-gate
3
- category: standard-mode
4
- severity: blocking
5
- depends_on: []
6
- ---
7
-
8
- # Test Quality Gate
9
-
10
- A green test suite is not enough. Tests must exercise real behavior and fail for the right reason.
11
-
12
- ## Blocking Findings
13
-
14
- Flag as blocking when a test is the only evidence for an FR/AC and any of these hold:
15
-
16
- 1. **Mock-only behavior**
17
- - Assertions only check mock calls (`toHaveBeenCalled`, `calledWith`, spy counts).
18
- - The real module/function under test is never invoked.
19
- - The test would still pass if the production implementation were empty.
20
-
21
- 2. **Mock setup dominates evidence**
22
- - Mock/stub/spy setup lines are more than 3x real behavioral assertions.
23
- - The test mostly restates fixture wiring instead of asserting output, state, persistence, or user-visible behavior.
24
-
25
- 3. **Skipped or inert tests**
26
- - `it.skip`, `describe.skip`, `test.skip`, `xit`, `pending`, or equivalent on covered behavior.
27
- - Test has no assertions and no meaningful side-effect check.
28
-
29
- 4. **Implementation-biased regression**
30
- - Test was added after implementation without evidence of RED failure when the task claims TDD.
31
- - Test asserts internal private structure instead of externally observable behavior.
32
-
33
- 5. **Missing cleanup for stateful mocks**
34
- - Stateful mocks/spies are used across tests without `afterEach` cleanup (`restoreAllMocks`, `clearAllMocks`, sandbox restore, etc.).
35
- - Shared mock state can leak between tests.
36
-
37
- ## Acceptable Mock Usage
38
-
39
- Mocks are acceptable when they isolate a boundary and the assertion still verifies real behavior:
40
-
41
- - Network/payment/email provider mocked, but service logic and error handling are real.
42
- - Clock/randomness mocked to make deterministic assertions.
43
- - Database mocked only when a separate integration test covers persistence behavior.
44
-
45
- ## Evidence Checklist
46
-
47
- For each FR/AC test evidence, record:
48
-
49
- - Test file and test name.
50
- - What real code path is invoked.
51
- - What behavioral assertion proves the requirement.
52
- - Whether the test was observed RED before GREEN when TDD is claimed.
53
- - Whether mocks are boundary-only or behavior-replacing.
54
-
55
- ## Verdicts
56
-
57
- - `PASS`: Tests exercise real behavior with meaningful assertions.
58
- - `WARN`: Mock-heavy but supported by separate integration/e2e coverage.
59
- - `FAIL`: Mock-only/skipped/no-assertion test is used as primary evidence.
@@ -1,179 +0,0 @@
1
- ---
2
- gate: verification-gate
3
- category: always-on
4
- severity: blocking
5
- depends_on: []
6
- ---
7
-
8
- # Verification Gate — Verification Required Before Completion
9
-
10
- > **Always enabled**. No evidence = no completion. Verification must be based on observed proof, not claimed completion.
11
-
12
- ---
13
-
14
- ## Core Rule
15
-
16
- **Do not declare `done`, `fixed`, `passed`, `working`, `okay` unless there is fresh execution evidence.**
17
-
18
- ---
19
-
20
- ## Trigger Timing
21
-
22
- - Before any agent outputs a "done/fixed/passed" conclusion
23
- - Before commit messages contain forbidden words
24
- - Before Phase transitions (research → requirements, requirements → design, etc.)
25
-
26
- ---
27
-
28
- ## Forbidden Word List (English + Chinese)
29
-
30
- Fresh evidence required to use:
31
-
32
- **English**:
33
- - `done`, `fixed`, `working`, `passed`, `resolved`, `completed`
34
- - `should work`, `probably`, `likely`, `might work`
35
- - `seems to`, `appears to`, `looks good`, `looks right`
36
- - `great!`, `perfect!`, `all set`
37
-
38
- **Chinese**:
39
- - `完成`, `搞定`, `好了`, `可以了`, `修好了`
40
- - `应该`, `可能`, `大概`, `似乎`, `好像`
41
- - `看起来没问题`, `应该能工作`
42
-
43
- ---
44
-
45
- ## Allowed Conclusions Must Carry Evidence
46
-
47
- ✗ **Violation**:
48
- > I fixed the login bug
49
-
50
- ✓ **Compliant**:
51
- > I fixed the login bug. Re-running `npm test -- auth/login` produced:
52
- > ```
53
- > ✓ login endpoint rejects empty email
54
- > ✓ login endpoint accepts valid credentials
55
- > Test Suites: 1 passed, Tests: 2 passed
56
- > ```
57
-
58
- ✗ **Violation**:
59
- > The code looks fine
60
-
61
- ✓ **Compliant**:
62
- > Ran `npx tsc --noEmit` → 0 errors
63
- > Ran `npx eslint src/auth/` → 0 errors, 0 warnings
64
-
65
- ---
66
-
67
- ## Evidence Types
68
-
69
- | Claim | Required Evidence |
70
- |------|---------|
71
- | "Fixed X" | command reproducing X + execution output |
72
- | "Tests pass" | full `npm test` output including pass count |
73
- | "Code is valid" | `tsc --noEmit` exit code + output |
74
- | "API works" | `curl` response + status code |
75
- | "Deployment succeeded" | deployment log + health check response |
76
- | "User can log in" | browser / chrome-devtools test screenshot or log |
77
- | "Performance meets target" | benchmark command + numbers |
78
-
79
- ---
80
-
81
- ## Checking Methods
82
-
83
- ### Agent Built-in (self-check)
84
-
85
- Each agent runs an internal check before outputting:
86
-
87
- ```
88
- For each conclusion sentence, ask yourself:
89
- 1. Does this sentence contain a forbidden word?
90
- 2. If so, do I have fresh evidence supporting it?
91
- 3. Is the evidence from a just-executed command, or older / assumed?
92
- 4. If the evidence is not fresh or does not exist, re-run or delete this sentence.
93
- ```
94
-
95
- ### flow-reviewer Agent (external check)
96
-
97
- Scan:
98
- - `commit messages` for forbidden words
99
- - declarative sentences in `.progress.md`
100
- - the conclusion section of agent output
101
-
102
- ---
103
-
104
- ## Violation Handling
105
-
106
- ### Severe (block)
107
-
108
- - commit message contains forbidden word without evidence
109
- - `.progress.md` says "done" but has no verify output
110
-
111
- **Actions**:
112
- - Block the commit (pre-commit hook, Phase 4+)
113
- - Or dispatch flow-executor to re-run Verify and update the record
114
- - Rewrite the commit message
115
-
116
- ### Medium (warning)
117
-
118
- - Verbally saying "looks good" (not in commit or file)
119
- - Using "should" as a hypothetical statement (acceptable)
120
-
121
- **Action**: mark, non-blocking
122
-
123
- ---
124
-
125
- ## Special Cases
126
-
127
- ### "I already checked"
128
-
129
- Not enough. "Checked" is a subjective claim. You need **execution output**.
130
-
131
- ```
132
- ✗ "I checked that all tests pass"
133
- ✓ "Ran npm test: Test Suites: 5 passed, Tests: 47 passed, Snapshots: 0 total"
134
- ```
135
-
136
- ### Partial Completion
137
-
138
- Do not describe partial completion as complete. Clearly categorize:
139
-
140
- ```
141
- ✓ Completed:
142
- - FR-01 login endpoint: passed (test output)
143
- - FR-02 password encryption: passed (test output)
144
-
145
- ⚠ Partially completed:
146
- - FR-03 Token refresh: code written but tests not yet run
147
-
148
- ✗ Not started:
149
- - FR-04 Logout
150
- ```
151
-
152
- ---
153
-
154
- ## Output Format
155
-
156
- ```markdown
157
- ## Verification Gate Check Result
158
-
159
- Scan range: commit abc123..def456
160
- Statements containing forbidden words: 3
161
-
162
- [V1] "Login bug fixed" (commit abc123)
163
- Evidence: ✗ none (no corresponding test output or verify record found)
164
- Verdict: block
165
-
166
- [V2] "All tests pass" (.progress.md line 12)
167
- Evidence: ✓ "npm test: 47/47 passed" (same file, line 11)
168
- Verdict: compliant
169
-
170
- [V3] "Should handle concurrency" (design.md AD-05)
171
- Evidence: ⚠ "should" is hypothetical tone, acceptable
172
- Verdict: warning (recommend adding a spike to verify)
173
-
174
- Blockers: 1
175
- Warnings: 1
176
-
177
- Fix recommendations:
178
- V1: dispatch flow-executor to run tests, add evidence to the commit message body
179
- ```
package/hooks/hooks.json DELETED
@@ -1,58 +0,0 @@
1
- {
2
- "hooks": {
3
- "SessionStart": [
4
- {
5
- "hooks": [
6
- {
7
- "type": "command",
8
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-start.sh",
9
- "statusMessage": "Loading CurDX-Flow project context"
10
- }
11
- ]
12
- },
13
- {
14
- "matcher": "startup|clear|compact",
15
- "hooks": [
16
- {
17
- "type": "command",
18
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/inject-karpathy.sh",
19
- "statusMessage": "Injecting CurDX-Flow engineering baseline"
20
- }
21
- ]
22
- }
23
- ],
24
- "Stop": [
25
- {
26
- "hooks": [
27
- {
28
- "type": "command",
29
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/stop-watcher.sh"
30
- }
31
- ]
32
- }
33
- ],
34
- "SubagentStop": [
35
- {
36
- "matcher": "flow-(architect|brownfield-analyst|debugger|edge-hunter|executor|product-designer|planner|qa-engineer|researcher|reviewer|security-auditor|triage-analyst|ui-researcher|ux-designer|verifier|adversary)",
37
- "hooks": [
38
- {
39
- "type": "command",
40
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/subagent-artifact-guard.sh",
41
- "statusMessage": "Checking curdx-flow artifact landing"
42
- }
43
- ]
44
- }
45
- ],
46
- "PreToolUse": [
47
- {
48
- "matcher": "AskUserQuestion",
49
- "hooks": [
50
- {
51
- "type": "command",
52
- "command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/quick-mode-guard.sh"
53
- }
54
- ]
55
- }
56
- ]
57
- }
58
- }
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- has_python3() {
4
- command -v python3 >/dev/null 2>&1
5
- }
6
-
7
- env_flag_enabled() {
8
- case "$(printf '%s' "${1:-}" | tr '[:upper:]' '[:lower:]')" in
9
- 1|true|yes|on) return 0 ;;
10
- *) return 1 ;;
11
- esac
12
- }
13
-
14
- json_escape() {
15
- local value="${1:-}"
16
-
17
- if has_python3; then
18
- printf '%s' "$value" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
19
- return
20
- fi
21
-
22
- printf '%s' "$value" \
23
- | sed 's/\\/\\\\/g; s/"/\\"/g' \
24
- | awk 'BEGIN{printf "\""} {printf "%s\\n", $0} END{printf "\""}'
25
- }
26
-
27
- emit_session_start_context() {
28
- local context="${1:-}"
29
- printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":%s}}\n' \
30
- "$(json_escape "$context")"
31
- }
32
-
33
- emit_pretooluse_deny() {
34
- local reason="${1:-}"
35
- printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":%s}}\n' \
36
- "$(json_escape "$reason")"
37
- }
38
-
39
- emit_stop_block() {
40
- local reason="${1:-}"
41
- printf '{"decision":"block","reason":%s}\n' "$(json_escape "$reason")"
42
- }
43
-
44
- emit_subagentstop_block() {
45
- emit_stop_block "${1:-}"
46
- }
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env bash
2
- # CurDX-Flow SessionStart baseline injection
3
- # Injects the L1 baseline (Karpathy 4 principles + mandatory tool rules + 3 red lines)
4
- # as additionalContext at every session boot (startup, /clear, post-compact).
5
- #
6
- # Wired under SessionStart with matcher "startup|clear|compact" so the
7
- # baseline survives startup, /clear, and post-compact resume.
8
-
9
- set -u
10
-
11
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
- . "$SCRIPT_DIR/common.sh"
13
-
14
- CONTEXT='## CurDX-Flow Mind Baseline (L1 — always on)
15
-
16
- ### 1. Think Before Coding
17
- - State assumptions before any non-trivial task
18
- - When uncertain, use AskUserQuestion — do not silently assume
19
- - When confused, stop — do not push forward
20
-
21
- ### 2. Simplicity First
22
- - YAGNI: do not write features beyond what was requested
23
- - No single-use abstractions
24
- - If 200 lines suffice, do not write 1000
25
-
26
- ### 3. Surgical Changes
27
- - Modify only the lines that must change
28
- - Match existing style
29
- - Do not delete pre-existing dead code
30
-
31
- ### 4. Goal-Driven
32
- - Define a verifiable success criterion first
33
- - Forbidden to say done/fixed/working without evidence
34
-
35
- ## Mandatory Tools (L2 — enforced)
36
-
37
- - library/framework questions → **context7 first** (`mcp__context7__*`); forbidden to rely on training memory
38
- - planning / design / architecture / review → **sequential-thinking first** (≥5 thoughts)
39
- - before any task → **claude-mem search** (if installed)
40
- - UI code → **frontend-design skill** (if installed)
41
- - browser QA → **chrome-devtools MCP**
42
-
43
- ## Three Red Lines (L3 — inherited from pua, universal)
44
-
45
- 1. **Closed loop**: claiming "done"? Provide evidence (build output / passing tests / curl result)
46
- 2. **Fact-driven**: verify before saying "probably". An unverified attribution is blame-shifting
47
- 3. **Exhaust everything**: before saying "I cannot", complete the systematic 4-stage debugging'
48
-
49
- if has_python3; then
50
- emit_session_start_context "$CONTEXT"
51
- fi
52
-
53
- exit 0
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env bash
2
- # CurDX-Flow PreToolUse Hook for AskUserQuestion
3
- # Blocks AskUserQuestion when the active spec has quickMode=true.
4
- # This prevents quick execution loops from stalling waiting for user input.
5
- #
6
- # The hook reads Claude's PreToolUse input JSON from stdin. We only act when
7
- # the tool being invoked is AskUserQuestion.
8
-
9
- set -u
10
-
11
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
- . "$SCRIPT_DIR/common.sh"
13
-
14
- # Read input (Claude sends JSON on stdin for PreToolUse)
15
- INPUT=$(cat 2>/dev/null || echo "{}")
16
-
17
- if ! command -v python3 >/dev/null 2>&1; then
18
- # Without JSON parsing, allow everything (fail open)
19
- exit 0
20
- fi
21
-
22
- # Parse the tool name being invoked
23
- TOOL_NAME=$(echo "$INPUT" | python3 -c '
24
- import json, sys
25
- try:
26
- d = json.load(sys.stdin)
27
- print(d.get("tool_name", ""))
28
- except Exception:
29
- print("")
30
- ' 2>/dev/null)
31
-
32
- # We only guard AskUserQuestion
33
- if [ "$TOOL_NAME" != "AskUserQuestion" ]; then
34
- exit 0
35
- fi
36
-
37
- # Check if we're in a flow project with quick mode enabled.
38
- [ ! -d ".flow" ] && exit 0
39
-
40
- ACTIVE=$(cat .flow/.active-spec 2>/dev/null)
41
- [ -z "$ACTIVE" ] && exit 0
42
-
43
- STATE_FILE=".flow/specs/$ACTIVE/.state.json"
44
- [ ! -f "$STATE_FILE" ] && exit 0
45
-
46
- # Read quickMode. Pass STATE_FILE via env (NOT shell interpolation
47
- # into the python source) so an active-spec name containing quotes/$ cannot
48
- # inject python code.
49
- export STATE_FILE
50
- QUICK_MODE=$(python3 -c '
51
- import json, os
52
- try:
53
- s = json.load(open(os.environ["STATE_FILE"]))
54
- qm = s.get("quickMode", False)
55
- print("true" if qm else "false")
56
- except Exception:
57
- print("false")
58
- ' 2>/dev/null)
59
-
60
- if [ "$QUICK_MODE" = "true" ]; then
61
- # Block and inject guidance
62
- MSG="[CurDX-Flow quick-mode-guard] Active spec '$ACTIVE' is in quick mode — AskUserQuestion is forbidden. Decide based on user preferences in .flow/CONTEXT.md plus the most reasonable assumption, and record your assumption in .progress.md."
63
- emit_pretooluse_deny "$MSG"
64
- exit 0
65
- fi
66
-
67
- # Allow
68
- exit 0
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env bash
2
- # CurDX-Flow SessionStart Hook
3
- # Duties:
4
- # 1. Daily dependency check — nudge user to `npx @curdx/flow install --all` if recommended plugins missing
5
- # 2. Load active spec progress into session context
6
- # 3. Persist stable CurDX-Flow environment hints for this session
7
- #
8
- # Design notes:
9
- # - Idempotent: marker file tracks last check date
10
- # - Silent when everything is healthy (no noise)
11
- # - Graceful degradation: missing `claude` CLI doesn't break hook
12
-
13
- set -u
14
-
15
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
16
- . "$SCRIPT_DIR/common.sh"
17
-
18
- DATA_DIR="${CLAUDE_PLUGIN_DATA:-$HOME/.claude/plugins/data/curdx-flow}"
19
- MARKER="$DATA_DIR/.deps-checked"
20
- TODAY="$(date +%Y-%m-%d)"
21
- ADDITIONAL_CONTEXT=""
22
-
23
- mkdir -p "$DATA_DIR" 2>/dev/null || true
24
-
25
- # ---------- 1. Dependency check (once per day) ----------
26
- LAST_CHECK=""
27
- [ -f "$MARKER" ] && LAST_CHECK="$(cat "$MARKER" 2>/dev/null)"
28
-
29
- if env_flag_enabled "${CLAUDE_PLUGIN_OPTION_DAILY_DEPENDENCY_CHECK:-1}" && [ "$LAST_CHECK" != "$TODAY" ]; then
30
- MISSING=()
31
-
32
- # Skip if `claude` CLI is not on PATH
33
- if command -v claude >/dev/null 2>&1; then
34
- INSTALLED="$(claude plugin list 2>/dev/null || true)"
35
-
36
- # Names must stay in lockstep with cli/registry.js RECOMMENDED_PLUGINS.
37
- # Drift is guarded by test/registry-session-start-parity.test.js.
38
- echo "$INSTALLED" | grep -q 'pua' || MISSING+=("pua")
39
- echo "$INSTALLED" | grep -q 'claude-mem' || MISSING+=("claude-mem")
40
- echo "$INSTALLED" | grep -q 'frontend-design' || MISSING+=("frontend-design")
41
- echo "$INSTALLED" | grep -q 'chrome-devtools-mcp' || MISSING+=("chrome-devtools-mcp")
42
- fi
43
-
44
- if [ "${#MISSING[@]}" -gt 0 ]; then
45
- JOINED="$(IFS=,; echo "${MISSING[*]}")"
46
- ADDITIONAL_CONTEXT+="## CurDX-Flow Recommended Plugins Check\n\nThe following recommended plugins were not detected: **${JOINED}**\n\nRun \`npx @curdx/flow install --all\` for interactive one-shot install. Run \`npx @curdx/flow doctor\` for the full health report.\n\n"
47
- fi
48
-
49
- { echo "$TODAY" > "$MARKER"; } 2>/dev/null || true
50
- fi
51
-
52
- # ---------- 2. Load .flow/ state (if project is a flow project) ----------
53
- if [ -d ".flow" ]; then
54
- ADDITIONAL_CONTEXT+="## CurDX-Flow Project Active\n\n"
55
- ADDITIONAL_CONTEXT+="- Plugin root: \`${CLAUDE_PLUGIN_ROOT:-unknown}\`\n"
56
- ADDITIONAL_CONTEXT+="- Plugin data: \`${CLAUDE_PLUGIN_DATA:-$DATA_DIR}\`\n"
57
- ADDITIONAL_CONTEXT+="- Best practice: write long agent artifacts to disk first; keep final assistant summaries short.\n\n"
58
-
59
- if [ -f ".flow/PROJECT.md" ]; then
60
- ADDITIONAL_CONTEXT+="### Project Vision\n$(head -80 .flow/PROJECT.md)\n\n"
61
- fi
62
-
63
- if [ -f ".flow/.active-spec" ]; then
64
- ACTIVE="$(cat .flow/.active-spec 2>/dev/null)"
65
- if [ -n "$ACTIVE" ] && [ -d ".flow/specs/$ACTIVE" ]; then
66
- ADDITIONAL_CONTEXT+="### Active Spec: \`$ACTIVE\`\n\n"
67
- if [ -f ".flow/specs/$ACTIVE/.progress.md" ]; then
68
- ADDITIONAL_CONTEXT+="$(head -40 ".flow/specs/$ACTIVE/.progress.md")\n\n"
69
- fi
70
- fi
71
- fi
72
- fi
73
-
74
- # ---------- 3. Persist session environment hints ----------
75
- if [ -n "${CLAUDE_ENV_FILE:-}" ]; then
76
- {
77
- printf 'export CURDX_FLOW_PLUGIN_ROOT=%s\n' "$(json_escape "${CLAUDE_PLUGIN_ROOT:-}")"
78
- printf 'export CURDX_FLOW_PLUGIN_DATA=%s\n' "$(json_escape "${CLAUDE_PLUGIN_DATA:-$DATA_DIR}")"
79
- if [ -f ".flow/.active-spec" ]; then
80
- printf 'export CURDX_FLOW_ACTIVE_SPEC=%s\n' "$(json_escape "$(cat .flow/.active-spec 2>/dev/null)")"
81
- fi
82
- } >> "$CLAUDE_ENV_FILE" 2>/dev/null || true
83
- fi
84
-
85
- # ---------- 4. Emit hook output ----------
86
- if [ -n "$ADDITIONAL_CONTEXT" ]; then
87
- emit_session_start_context "$ADDITIONAL_CONTEXT"
88
- fi
89
-
90
- exit 0