qualia-framework 6.2.7 → 6.2.10

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 (76) hide show
  1. package/README.md +18 -11
  2. package/agents/builder.md +7 -7
  3. package/agents/planner.md +39 -3
  4. package/agents/research-synthesizer.md +1 -1
  5. package/agents/researcher.md +3 -3
  6. package/agents/roadmapper.md +7 -7
  7. package/agents/verifier.md +18 -6
  8. package/agents/visual-evaluator.md +8 -7
  9. package/bin/cli.js +111 -14
  10. package/bin/codex-goal.js +92 -0
  11. package/bin/contract-runner.js +219 -0
  12. package/bin/host-adapters.js +66 -0
  13. package/bin/install.js +171 -124
  14. package/bin/plan-contract.js +99 -2
  15. package/bin/planning-hygiene.js +262 -0
  16. package/bin/runtime-manifest.js +32 -0
  17. package/bin/state-ledger.js +184 -0
  18. package/bin/state.js +299 -20
  19. package/bin/trust-score.js +276 -0
  20. package/docs/onboarding.html +5 -4
  21. package/guide.md +3 -2
  22. package/hooks/pre-deploy-gate.js +27 -0
  23. package/hooks/pre-push.js +19 -0
  24. package/package.json +1 -1
  25. package/qualia-design/design-rubric.md +17 -5
  26. package/qualia-design/frontend.md +5 -1
  27. package/qualia-design/graphics.md +47 -0
  28. package/rules/codex-goal.md +46 -0
  29. package/rules/command-output.md +35 -0
  30. package/skills/qualia/SKILL.md +10 -10
  31. package/skills/qualia-build/SKILL.md +24 -14
  32. package/skills/qualia-debug/SKILL.md +16 -8
  33. package/skills/qualia-discuss/SKILL.md +10 -10
  34. package/skills/qualia-doctor/SKILL.md +140 -0
  35. package/skills/qualia-feature/SKILL.md +27 -21
  36. package/skills/qualia-fix/SKILL.md +216 -0
  37. package/skills/qualia-flush/SKILL.md +9 -9
  38. package/skills/qualia-handoff/SKILL.md +9 -9
  39. package/skills/qualia-help/SKILL.md +3 -3
  40. package/skills/qualia-hook-gen/SKILL.md +1 -1
  41. package/skills/qualia-idk/SKILL.md +4 -4
  42. package/skills/qualia-issues/SKILL.md +2 -2
  43. package/skills/qualia-learn/SKILL.md +10 -10
  44. package/skills/qualia-map/SKILL.md +2 -2
  45. package/skills/qualia-milestone/SKILL.md +15 -15
  46. package/skills/qualia-new/REFERENCE.md +9 -9
  47. package/skills/qualia-new/SKILL.md +14 -14
  48. package/skills/qualia-optimize/REFERENCE.md +1 -1
  49. package/skills/qualia-optimize/SKILL.md +23 -16
  50. package/skills/qualia-pause/SKILL.md +2 -2
  51. package/skills/qualia-plan/SKILL.md +27 -13
  52. package/skills/qualia-polish/REFERENCE.md +14 -14
  53. package/skills/qualia-polish/SKILL.md +64 -19
  54. package/skills/qualia-polish/scripts/loop.mjs +3 -3
  55. package/skills/qualia-polish/scripts/score.mjs +9 -3
  56. package/skills/qualia-postmortem/SKILL.md +9 -9
  57. package/skills/qualia-report/SKILL.md +23 -23
  58. package/skills/qualia-research/SKILL.md +5 -5
  59. package/skills/qualia-resume/SKILL.md +4 -4
  60. package/skills/qualia-review/SKILL.md +28 -12
  61. package/skills/qualia-road/SKILL.md +18 -5
  62. package/skills/qualia-ship/SKILL.md +22 -22
  63. package/skills/qualia-skill-new/SKILL.md +13 -13
  64. package/skills/qualia-test/SKILL.md +5 -5
  65. package/skills/qualia-triage/SKILL.md +1 -1
  66. package/skills/qualia-verify/SKILL.md +37 -23
  67. package/skills/qualia-vibe/SKILL.md +13 -10
  68. package/skills/qualia-vibe/scripts/extract.mjs +1 -1
  69. package/skills/zoho-workflow/SKILL.md +1 -1
  70. package/templates/help.html +12 -10
  71. package/tests/bin.test.sh +35 -5
  72. package/tests/install-smoke.test.sh +23 -3
  73. package/tests/lib.test.sh +290 -0
  74. package/tests/runner.js +3 -0
  75. package/tests/skills.test.sh +4 -4
  76. package/tests/state.test.sh +65 -3
@@ -24,13 +24,19 @@ Execute phase plan. Each task = fresh subagent. Independent tasks run parallel.
24
24
 
25
25
  ## Process
26
26
 
27
+ ### 0. Codex goal (Codex runtime only)
28
+
29
+ Per `rules/codex-goal.md` — set the thread goal at phase start with scope `phase`.
30
+
27
31
  ### 1. Load Plan
28
32
 
29
33
  ```bash
30
34
  cat .planning/phase-{N}-plan.md
35
+ cat .planning/phase-{N}-contract.json
36
+ node ${QUALIA_BIN}/plan-contract.js validate .planning/phase-{N}-contract.json
31
37
  ```
32
38
 
33
- Parse tasks, waves, file refs.
39
+ Parse tasks, waves, file refs. Prefer the JSON contract for task ids, dependencies, file lists, and verification checks; use the Markdown plan as the human-readable context.
34
40
 
35
41
  ### 1b. Recovery Reference
36
42
 
@@ -41,7 +47,7 @@ git tag -f "pre-build-phase-{N}" HEAD 2>/dev/null
41
47
  ```
42
48
 
43
49
  ```bash
44
- node ~/.claude/bin/qualia-ui.js info "Recovery point: pre-build-phase-{N}"
50
+ node ${QUALIA_BIN}/qualia-ui.js info "Recovery point: pre-build-phase-{N}"
45
51
  ```
46
52
 
47
53
  Wave fail → stop, inspect status + output. Preserve work; fix forward or ask before reverting.
@@ -53,19 +59,19 @@ git diff --stat
53
59
  ### 2. Execute Waves
54
60
 
55
61
  ```bash
56
- node ~/.claude/bin/qualia-ui.js banner build {N} "{phase name}"
62
+ node ${QUALIA_BIN}/qualia-ui.js banner build {N} "{phase name}"
57
63
  ```
58
64
 
59
65
  **For each wave (sequential):**
60
66
 
61
67
  ```bash
62
- node ~/.claude/bin/qualia-ui.js wave {W} {total_waves} {tasks_in_wave}
68
+ node ${QUALIA_BIN}/qualia-ui.js wave {W} {total_waves} {tasks_in_wave}
63
69
  ```
64
70
 
65
71
  **Per task in wave: spawn ALL as separate `Agent()` calls in SAME turn (concurrent). Do NOT await one before spawning next.**
66
72
 
67
73
  ```bash
68
- node ~/.claude/bin/qualia-ui.js task {task_num} "{task title}"
74
+ node ${QUALIA_BIN}/qualia-ui.js task {task_num} "{task title}"
69
75
  ```
70
76
 
71
77
  **Pre-inline context** (saves 3-5 Read calls per builder):
@@ -80,7 +86,7 @@ Spawn builder:
80
86
 
81
87
  ```
82
88
  Agent(prompt="
83
- Role: @~/.claude/agents/builder.md
89
+ Role: @${QUALIA_AGENTS}/builder.md
84
90
 
85
91
  <phase_context>
86
92
  # PROJECT.md
@@ -106,6 +112,10 @@ Parallel tasks Wave {W} (do NOT touch their files):
106
112
  {task block from plan: title, wave, persona, files, depends-on, why, AC, action, validation, context}
107
113
  </task>
108
114
 
115
+ <task_contract>
116
+ {matching task object from .planning/phase-{N}-contract.json}
117
+ </task_contract>
118
+
109
119
  Context tags already loaded. Only Read project code you modify.
110
120
  Execute. Commit. Return DONE/BLOCKED/PARTIAL.
111
121
  ", subagent_type="qualia-builder", description="Task {N}: {title}")
@@ -117,7 +127,7 @@ Execute. Commit. Return DONE/BLOCKED/PARTIAL.
117
127
  - Verify commit: `git log --oneline -1`
118
128
  - Show:
119
129
  ```bash
120
- node ~/.claude/bin/qualia-ui.js done {task_num} "{title}" {commit_hash}
130
+ node ${QUALIA_BIN}/qualia-ui.js done {task_num} "{title}" {commit_hash}
121
131
  ```
122
132
 
123
133
  **After each wave:** move to next, show summary.
@@ -127,10 +137,10 @@ node ~/.claude/bin/qualia-ui.js done {task_num} "{title}" {commit_hash}
127
137
  All waves done:
128
138
 
129
139
  ```bash
130
- node ~/.claude/bin/qualia-ui.js divider
131
- node ~/.claude/bin/qualia-ui.js ok "Tasks: {done}/{total}"
132
- node ~/.claude/bin/qualia-ui.js ok "Commits: {count}"
133
- node ~/.claude/bin/qualia-ui.js ok "Waves: {count}"
140
+ node ${QUALIA_BIN}/qualia-ui.js divider
141
+ node ${QUALIA_BIN}/qualia-ui.js ok "Tasks: {done}/{total}"
142
+ node ${QUALIA_BIN}/qualia-ui.js ok "Commits: {count}"
143
+ node ${QUALIA_BIN}/qualia-ui.js ok "Waves: {count}"
134
144
  ```
135
145
 
136
146
  ### 4. Handle Failures
@@ -143,7 +153,7 @@ Builder returns deviation/blocker:
143
153
  ### 5. Update State
144
154
 
145
155
  ```bash
146
- node ~/.claude/bin/state.js transition --to built --phase {N} --tasks-done {done} --tasks-total {total} --wave {wave}
156
+ node ${QUALIA_BIN}/state.js transition --to built --phase {N} --tasks-done {done} --tasks-total {total} --wave {wave}
147
157
  ```
148
158
  Error → show, stop.
149
159
  Do NOT edit STATE.md or tracking.json manually; state.js handles both.
@@ -153,7 +163,7 @@ Do NOT edit STATE.md or tracking.json manually; state.js handles both.
153
163
  **`--auto`:** invoke `/qualia-verify {N} --auto` inline. No pause.
154
164
 
155
165
  ```bash
156
- node ~/.claude/bin/qualia-ui.js info "Auto mode — chaining into /qualia-verify {N}"
166
+ node ${QUALIA_BIN}/qualia-ui.js info "Auto mode — chaining into /qualia-verify {N}"
157
167
  ```
158
168
 
159
169
  Then invoke `qualia-verify` inline with `--auto`.
@@ -161,5 +171,5 @@ Then invoke `qualia-verify` inline with `--auto`.
161
171
  **Guided mode:** stop, show next step:
162
172
 
163
173
  ```bash
164
- node ~/.claude/bin/qualia-ui.js end "PHASE {N} BUILT" "/qualia-verify {N}"
174
+ node ${QUALIA_BIN}/qualia-ui.js end "PHASE {N} BUILT" "/qualia-verify {N}"
165
175
  ```
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-debug
3
- description: "Investigative debugging parses symptom from arguments, runs diagnostic scans, identifies root cause, applies minimal fix, writes DEBUG report. Trigger on 'debug', 'find bug', 'fix error', 'something is broken', 'not working', 'weird behavior', 'layout broken', 'CSS issue', 'slow page', 'performance'."
3
+ description: "Investigation lane for unclear bugs and weird behavior. Parses symptoms, runs diagnostic scans, identifies root cause, and either reports insufficient evidence or routes actionable repair work to /qualia-fix. Trigger on 'debug', 'find bug', 'why is this broken', 'something is weird', 'investigate', 'root cause', 'not sure what's failing', 'CSS issue', 'slow page', 'performance'."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -13,7 +13,7 @@ allowed-tools:
13
13
 
14
14
  # /qualia-debug — Investigative Debugging (one-shot)
15
15
 
16
- Parse the symptom. Run diagnostics. Find root cause. Apply minimal fix. Write report. **One-shot — no mandatory user questions.**
16
+ Parse the symptom. Run diagnostics. Find root cause. Write report, or route to `/qualia-fix` when the repair is actionable. **One-shot — no mandatory user questions.**
17
17
 
18
18
  ## Usage
19
19
 
@@ -22,6 +22,8 @@ Parse the symptom. Run diagnostics. Find root cause. Apply minimal fix. Write re
22
22
  - `/qualia-debug --frontend {symptom}` — layout/z-index/overflow bias
23
23
  - `/qualia-debug --perf {symptom}` — performance bias
24
24
 
25
+ If the user says "fix it" and the expected behavior is known, prefer `/qualia-fix`. Debug is for uncertainty; fix is for repair.
26
+
25
27
  ## Tool Budget
26
28
 
27
29
  Max 10 Read/Grep/Bash calls for investigation. If you haven't narrowed to root cause in 10, return `INSUFFICIENT EVIDENCE after 10 steps. Narrowed to: {files}. Recommend: {next diagnostic}.` Do not keep guessing.
@@ -29,7 +31,7 @@ Max 10 Read/Grep/Bash calls for investigation. If you haven't narrowed to root c
29
31
  ## Process
30
32
 
31
33
  ```bash
32
- node ~/.claude/bin/qualia-ui.js banner debug
34
+ node ${QUALIA_BIN}/qualia-ui.js banner debug
33
35
  ```
34
36
 
35
37
  ### 1. Parse Symptom from $ARGUMENTS
@@ -40,7 +42,7 @@ node ~/.claude/bin/qualia-ui.js banner debug
40
42
  ### 2. Check Known Fixes First (cheap)
41
43
 
42
44
  ```bash
43
- node ~/.claude/bin/knowledge.js search "{symptom_keywords}"
45
+ node ${QUALIA_BIN}/knowledge.js search "{symptom_keywords}"
44
46
  ```
45
47
 
46
48
  If a known fix matches, apply it and jump to step 5 (verify). Known fixes are pre-verified patterns — no need to re-investigate.
@@ -97,10 +99,12 @@ grep -rn "import(\|next/dynamic" --include="*.tsx" --include="*.ts" app/ src/ 2>
97
99
  grep -rln "'use client'" --include="*.tsx" app/ components/ src/ 2>/dev/null | wc -l
98
100
  ```
99
101
 
100
- ### 4. Form Hypothesis + Apply Minimal Fix
102
+ ### 4. Form Hypothesis + Route or Apply Minimal Fix
101
103
 
102
104
  From the diagnostic output, state the root cause in one sentence with `file:line` citation. No hedging — either you have evidence or you write `INSUFFICIENT EVIDENCE` and return (step 6).
103
105
 
106
+ If the user explicitly asked for repair and the fix is <= 3 files, route to `/qualia-fix {symptom}` with the root cause summary. If this debug invocation is already mid-repair, apply the minimal fix here for backward compatibility.
107
+
104
108
  Apply the minimal fix:
105
109
  - Only edit files whose contents caused the symptom
106
110
  - One concept per commit — don't fold in cleanup
@@ -122,7 +126,11 @@ If the verification fails, revert and return to step 3 with narrower hypothesis.
122
126
 
123
127
  ### 6. Write DEBUG Report
124
128
 
125
- Write to `.planning/DEBUG-{YYYY-MM-DD-HHMM}.md`:
129
+ Create the report directory and write to `.planning/reports/debug/DEBUG-{YYYY-MM-DD-HHMM}.md`:
130
+
131
+ ```bash
132
+ mkdir -p .planning/reports/debug
133
+ ```
126
134
 
127
135
  ```markdown
128
136
  # Debug Report — {YYYY-MM-DD HH:MM}
@@ -180,6 +188,6 @@ Do NOT apply a speculative fix. Return the report and stop.
180
188
 
181
189
  - **No mandatory questions.** This is one-shot. If symptom args are missing, investigate recent changes.
182
190
  - **Root cause or INSUFFICIENT EVIDENCE** — no "probably" fixes.
183
- - **Minimal fix only.** One concept, one commit. No refactors dressed as debug.
191
+ - **Minimal fix only.** One concept, one commit. No refactors dressed as debug. Prefer `/qualia-fix` for explicit repair requests.
184
192
  - **Tool budget is hard.** 10 calls, then stop.
185
- - **Every fix gets a DEBUG report in .planning/** — creates a searchable record.
193
+ - **Every investigation gets a DEBUG report in `.planning/reports/debug/`** — creates a searchable record without cluttering the root.
@@ -64,7 +64,7 @@ This is the only fork. Demo runs §1-§8 of the discovery template. Full project
64
64
  ### P2. Banner and open
65
65
 
66
66
  ```bash
67
- node ~/.claude/bin/qualia-ui.js banner discuss-project
67
+ node ${QUALIA_BIN}/qualia-ui.js banner discuss-project
68
68
  ```
69
69
 
70
70
  Say: **"Eight quick questions for the demo path"** or **"Fourteen questions to shape the full project — we'll move fast"** depending on type.
@@ -85,20 +85,20 @@ Allowed `[Enter]` defaults exist on §2, §3, §5 only (inferred from project ty
85
85
 
86
86
  ### P4. Write `.planning/project-discovery.md`
87
87
 
88
- Fill the template at `~/.claude/qualia-templates/project-discovery.md` with the user's verbatim answers. Set frontmatter `project_type` and `discovered_at`.
88
+ Fill the template at `${QUALIA_TEMPLATES}/project-discovery.md` with the user's verbatim answers. Set frontmatter `project_type` and `discovered_at`.
89
89
 
90
90
  ### P5. Hand back to `/qualia-new`
91
91
 
92
92
  ```bash
93
93
  git add .planning/project-discovery.md
94
94
  git commit -m "docs: project discovery interview ($PROJECT_TYPE)"
95
- node ~/.claude/bin/qualia-ui.js ok "Discovery captured — back to /qualia-new"
95
+ node ${QUALIA_BIN}/qualia-ui.js ok "Discovery captured — back to /qualia-new"
96
96
  ```
97
97
 
98
98
  If invoked standalone (not from `/qualia-new`), end with:
99
99
 
100
100
  ```bash
101
- node ~/.claude/bin/qualia-ui.js end "DISCOVERY CAPTURED" "/qualia-new"
101
+ node ${QUALIA_BIN}/qualia-ui.js end "DISCOVERY CAPTURED" "/qualia-new"
102
102
  ```
103
103
 
104
104
  If invoked inline by `/qualia-new`, return control silently — `/qualia-new` continues from Step 2.
@@ -135,19 +135,19 @@ Surface and lock the decisions, trade-offs, and constraints that must inform a p
135
135
  ### 1. Load substrate
136
136
 
137
137
  ```bash
138
- node ~/.claude/bin/state.js check 2>/dev/null
138
+ node ${QUALIA_BIN}/state.js check 2>/dev/null
139
139
  cat .planning/PROJECT.md .planning/ROADMAP.md .planning/CONTEXT.md 2>/dev/null
140
140
  ls .planning/decisions/ 2>/dev/null
141
141
  cat .planning/research/SUMMARY.md 2>/dev/null
142
142
  ```
143
143
 
144
- If `.planning/CONTEXT.md` is missing, copy `~/.claude/qualia-templates/CONTEXT.md` to `.planning/CONTEXT.md` first.
145
- If `.planning/decisions/` is missing, create it. Copy `~/.claude/qualia-templates/decisions/ADR-template.md` next to it for reference.
144
+ If `.planning/CONTEXT.md` is missing, copy `${QUALIA_TEMPLATES}/CONTEXT.md` to `.planning/CONTEXT.md` first.
145
+ If `.planning/decisions/` is missing, create it. Copy `${QUALIA_TEMPLATES}/decisions/ADR-template.md` next to it for reference.
146
146
 
147
147
  ### 2. Open the conversation
148
148
 
149
149
  ```bash
150
- node ~/.claude/bin/qualia-ui.js banner discuss {N} "{phase name from ROADMAP.md}"
150
+ node ${QUALIA_BIN}/qualia-ui.js banner discuss {N} "{phase name from ROADMAP.md}"
151
151
  ```
152
152
 
153
153
  Then state the goal in one sentence and the open questions you found in priority order (highest-stakes / hardest-to-reverse first).
@@ -200,14 +200,14 @@ Loop until "Lock it in".
200
200
 
201
201
  ### 6. Write phase-{N}-context.md
202
202
 
203
- Fill `~/.claude/qualia-templates/phase-context.md` with concrete content. Reference any ADRs written, any CONTEXT.md terms added.
203
+ Fill `${QUALIA_TEMPLATES}/phase-context.md` with concrete content. Reference any ADRs written, any CONTEXT.md terms added.
204
204
 
205
205
  ### 7. Commit and route
206
206
 
207
207
  ```bash
208
208
  git add .planning/phase-{N}-context.md .planning/CONTEXT.md .planning/decisions/
209
209
  git commit -m "docs(phase-{N}): lock context, glossary terms, ADRs"
210
- node ~/.claude/bin/qualia-ui.js end "PHASE {N} CONTEXT LOCKED" "/qualia-plan {N}"
210
+ node ${QUALIA_BIN}/qualia-ui.js end "PHASE {N} CONTEXT LOCKED" "/qualia-plan {N}"
211
211
  ```
212
212
 
213
213
  ## Rules — PHASE MODE
@@ -0,0 +1,140 @@
1
+ ---
2
+ name: qualia-doctor
3
+ description: "Employee-facing framework health check. Wraps `qualia-framework doctor`, checks install targets, project state, contract coverage, planning-folder hygiene, hooks, memory, ERP queue health, and gives safe repair commands. Trigger on 'doctor', 'health check', 'framework broken', 'is Qualia installed correctly', 'Codex not picking up Qualia', 'hooks not running', 'memory broken', 'ERP queue stuck', '.planning messy'."
4
+ allowed-tools:
5
+ - Bash
6
+ - Read
7
+ - Grep
8
+ ---
9
+
10
+ # /qualia-doctor
11
+
12
+ Diagnose whether the framework harness itself is healthy before blaming the project or the model.
13
+
14
+ ## 1. Install Health
15
+
16
+ Run:
17
+
18
+ ```bash
19
+ qualia-framework doctor
20
+ qualia-framework trust
21
+ ```
22
+
23
+ If it fails, report the failed checks first. Use safe repair commands only:
24
+
25
+ ```bash
26
+ npx qualia-framework@latest install
27
+ ```
28
+
29
+ Do not delete user files, configs, knowledge, or hooks manually.
30
+
31
+ ## 2. Project State Health
32
+
33
+ Run from the project root:
34
+
35
+ ```bash
36
+ node ${QUALIA_BIN}/state.js check
37
+ ```
38
+
39
+ If installed under Codex only, use:
40
+
41
+ ```bash
42
+ node ~/.codex/bin/state.js check
43
+ ```
44
+
45
+ Classify:
46
+ - `NO_PROJECT` -> project has not been initialized; next command is `/qualia-new` or `/qualia-map` for brownfield.
47
+ - `schema_errors` -> recommend `node ${QUALIA_BIN}/state.js fix` or Codex equivalent.
48
+ - `gap_cycles` at limit -> recommend replanning or escalation.
49
+
50
+ ## 3. Contract Health
51
+
52
+ For the current phase, check whether a machine-readable contract exists:
53
+
54
+ ```bash
55
+ node ${QUALIA_BIN}/state.js validate-plan --phase {N}
56
+ ```
57
+
58
+ If `contract_status` is `missing`, `invalid`, or `drifted`, the harness is not at full-trust mode yet.
59
+
60
+ When a contract exists, run:
61
+
62
+ ```bash
63
+ node ${QUALIA_BIN}/contract-runner.js .planning/phase-{N}-contract.json
64
+ ```
65
+
66
+ Use the Codex path on Codex-only installs.
67
+
68
+ ## 4. Planning Folder Hygiene
69
+
70
+ Run:
71
+
72
+ ```bash
73
+ qualia-framework planning-hygiene scan
74
+ ```
75
+
76
+ If it reports loose files, show the dry-run result first. Only organize when the user approves:
77
+
78
+ ```bash
79
+ qualia-framework planning-hygiene organize --write
80
+ ```
81
+
82
+ Do not move files by hand; the script keeps phase-critical root files in place and moves loose reports/assets into `.planning/reports/`, `.planning/assets/`, `.planning/design/`, or `.planning/archive/loose/`.
83
+
84
+ ## 5. Memory Health
85
+
86
+ Run:
87
+
88
+ ```bash
89
+ node ${QUALIA_BIN}/knowledge.js
90
+ node ${QUALIA_BIN}/knowledge.js list
91
+ ```
92
+
93
+ Healthy memory has at least `index.md`, `agents.md`, and a writable `daily-log/` directory. Missing curated memory is not fatal, but missing installed memory files means reinstall.
94
+
95
+ ## 6. ERP Queue Health
96
+
97
+ Run:
98
+
99
+ ```bash
100
+ qualia-framework erp-flush show
101
+ ```
102
+
103
+ If the queue has entries, run:
104
+
105
+ ```bash
106
+ qualia-framework erp-flush drain
107
+ ```
108
+
109
+ If the queue fails with `401`, the ERP API key is invalid. Use:
110
+
111
+ ```bash
112
+ printf '%s' "$QUALIA_ERP_KEY" | qualia-framework set-erp-key
113
+ ```
114
+
115
+ ## Output
116
+
117
+ End with:
118
+
119
+ ```text
120
+ Harness health: PASS | DEGRADED | FAIL
121
+ Trust score: {N}/100
122
+ Install: ...
123
+ State: ...
124
+ State ledger: ...
125
+ Contracts: ...
126
+ Planning hygiene: ...
127
+ Memory: ...
128
+ Design/UI: ...
129
+ Employee experience: ...
130
+ ERP: ...
131
+ Next: ...
132
+ ```
133
+
134
+ ## Rules
135
+
136
+ 1. Read diagnostics before repair.
137
+ 2. Never remove user-owned files.
138
+ 3. Treat missing contracts as degraded trust, not a project failure.
139
+ 4. Prefer reinstall for missing framework files.
140
+ 5. Prefer `state.js fix` only for malformed generated state.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-feature
3
- description: "Auto-scoped single feature build. Picks inline (≤1 trivial file, no spawn) or fresh builder spawn (1-5 logic files, atomic commit) automatically from the task description. Refuses and routes to /qualia-plan for 5+ files or full phases. Flags: --force-spawn forces a builder, --force-inline forces inline. Trigger phrases: 'build this one thing', 'add a component', 'implement this feature', 'quick fix', 'small change', 'tweak', 'hot fix', 'one-line fix', 'typo', 'config tweak', 'qualia-feature'."
3
+ description: "Auto-scoped single feature build for adding net-new capability. Picks inline (≤1 trivial file, no spawn) or fresh builder spawn (1-5 logic files, atomic commit). Refuses and routes to /qualia-plan for phase-sized work, and routes broken existing behavior to /qualia-fix. Trigger phrases: 'build this one thing', 'add a component', 'implement this feature', 'small change', 'tweak', 'one-line copy change', 'config tweak', 'qualia-feature'."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -14,7 +14,7 @@ allowed-tools:
14
14
 
15
15
  # /qualia-feature — Auto-scoped Single Feature
16
16
 
17
- One command for everything between a typo and a phase. Auto-detects scope from the task description and picks the right execution path.
17
+ One command for adding a small new capability outside the planned Road. Auto-detects scope from the task description and picks the right execution path.
18
18
 
19
19
  ## Usage
20
20
 
@@ -26,7 +26,7 @@ One command for everything between a typo and a phase. Auto-detects scope from t
26
26
  ## When to use
27
27
 
28
28
  - One feature outside a planned phase
29
- - A bug fix, typo, config tweak, or one-line change
29
+ - A copy tweak, config tweak, or one-line non-repair change
30
30
  - A 1-5 file feature, component, API route, or integration
31
31
  - A refactor of a single module
32
32
 
@@ -34,11 +34,16 @@ One command for everything between a typo and a phase. Auto-detects scope from t
34
34
 
35
35
  - 5+ files or multiple subsystems touched → `/qualia-plan`
36
36
  - Part of a planned phase → `/qualia-build`
37
+ - Broken existing behavior, regression, failing test, or hotfix → `/qualia-fix`
37
38
  - Investigating a symptom you can't name yet → `/qualia-debug`
38
39
  - Optimization or polish pass → `/qualia-optimize` or `/qualia-polish`
39
40
 
40
41
  ## Process
41
42
 
43
+ ### 0. Codex goal (Codex runtime only)
44
+
45
+ Per `rules/codex-goal.md` — set the thread goal with scope matching the auto-detected bucket (`quick` for inline, `feature` for spawn). Do this AFTER Step 2 (auto-detect scope) so the budget matches the actual work shape.
46
+
42
47
  ### 1. Capture description
43
48
 
44
49
  If invoked without args, ask: **"What do you want to build?"**
@@ -64,6 +69,7 @@ Classify the description into one of three buckets:
64
69
  - "add a", "implement", "build", "create" + a single noun (component, route, page, table, form, modal, hook, util, migration)
65
70
  - Description names a single feature with multiple touch points (e.g. "add a feedback form" → migration + API + UI = 3-4 files, but still one cohesive thing)
66
71
  - The work needs a fresh context to avoid contaminating the current conversation
72
+ - The work repairs a non-trivial bug only if invoked explicitly with `/qualia-feature --force-spawn`; otherwise use `/qualia-fix`
67
73
 
68
74
  **Refuse signals** (any one is sufficient):
69
75
  - "build the X system", "implement the entire Y", "add complete Z support"
@@ -75,9 +81,9 @@ Classify the description into one of three buckets:
75
81
  Show the user what was detected. Always offer the escape hatch:
76
82
 
77
83
  ```bash
78
- node ~/.claude/bin/qualia-ui.js banner feature
79
- node ~/.claude/bin/qualia-ui.js info "Detected scope: {inline|spawn|refuse}"
80
- node ~/.claude/bin/qualia-ui.js info "Reason: {one-line rationale}"
84
+ node ${QUALIA_BIN}/qualia-ui.js banner feature
85
+ node ${QUALIA_BIN}/qualia-ui.js info "Detected scope: {inline|spawn|refuse}"
86
+ node ${QUALIA_BIN}/qualia-ui.js info "Reason: {one-line rationale}"
81
87
  ```
82
88
 
83
89
  Then:
@@ -110,13 +116,13 @@ git commit -m "fix: {description}"
110
116
  5. Record in state:
111
117
 
112
118
  ```bash
113
- node ~/.claude/bin/state.js transition --to note --notes "{brief description}" --tasks-done 1
119
+ node ${QUALIA_BIN}/state.js transition --to note --notes "{brief description}" --tasks-done 1
114
120
  ```
115
121
 
116
122
  6. End with:
117
123
 
118
124
  ```bash
119
- node ~/.claude/bin/qualia-ui.js end "FEATURE SHIPPED (inline)"
125
+ node ${QUALIA_BIN}/qualia-ui.js end "FEATURE SHIPPED (inline)"
120
126
  ```
121
127
 
122
128
  ### 5. Execute the spawn path
@@ -126,9 +132,9 @@ For spawn scope:
126
132
  1. Build a quick task spec (don't write to a file, just confirm with user):
127
133
 
128
134
  ```bash
129
- node ~/.claude/bin/qualia-ui.js info "What: {what to build}"
130
- node ~/.claude/bin/qualia-ui.js info "Files: {files to create/modify, comma list}"
131
- node ~/.claude/bin/qualia-ui.js info "Done: {observable acceptance criteria, 1-3 bullets}"
135
+ node ${QUALIA_BIN}/qualia-ui.js info "What: {what to build}"
136
+ node ${QUALIA_BIN}/qualia-ui.js info "Files: {files to create/modify, comma list}"
137
+ node ${QUALIA_BIN}/qualia-ui.js info "Done: {observable acceptance criteria, 1-3 bullets}"
132
138
  ```
133
139
 
134
140
  Ask: **"Good to build?"** Wait for confirmation.
@@ -138,7 +144,7 @@ Ask: **"Good to build?"** Wait for confirmation.
138
144
  ```
139
145
  Agent(subagent_type="qualia-builder", description="Feature: {short title}")
140
146
  prompt: |
141
- Read your role: @~/.claude/agents/builder.md
147
+ Read your role: @${QUALIA_AGENTS}/builder.md
142
148
 
143
149
  <task>
144
150
  {task description verbatim from user}
@@ -168,17 +174,17 @@ Agent(subagent_type="qualia-builder", description="Feature: {short title}")
168
174
  4. Report:
169
175
 
170
176
  ```bash
171
- node ~/.claude/bin/qualia-ui.js divider
172
- node ~/.claude/bin/qualia-ui.js ok "Feature: {description}"
173
- node ~/.claude/bin/qualia-ui.js ok "Files: {files changed}"
174
- node ~/.claude/bin/qualia-ui.js ok "Commit: {commit hash}"
175
- node ~/.claude/bin/qualia-ui.js end "FEATURE SHIPPED (spawn)"
177
+ node ${QUALIA_BIN}/qualia-ui.js divider
178
+ node ${QUALIA_BIN}/qualia-ui.js ok "Feature: {description}"
179
+ node ${QUALIA_BIN}/qualia-ui.js ok "Files: {files changed}"
180
+ node ${QUALIA_BIN}/qualia-ui.js ok "Commit: {commit hash}"
181
+ node ${QUALIA_BIN}/qualia-ui.js end "FEATURE SHIPPED (spawn)"
176
182
  ```
177
183
 
178
184
  5. Record in state:
179
185
 
180
186
  ```bash
181
- node ~/.claude/bin/state.js transition --to note --notes "{description}" --tasks-done 1
187
+ node ${QUALIA_BIN}/state.js transition --to note --notes "{description}" --tasks-done 1
182
188
  ```
183
189
 
184
190
  ### 6. Execute the refuse path
@@ -186,9 +192,9 @@ node ~/.claude/bin/state.js transition --to note --notes "{description}" --tasks
186
192
  For refuse scope, do NOT build. Explain why and route:
187
193
 
188
194
  ```bash
189
- node ~/.claude/bin/qualia-ui.js warn "This is too big for /qualia-feature (5+ files or multi-step workflow)."
190
- node ~/.claude/bin/qualia-ui.js info "Reason: {one-line — e.g. 'description names the entire auth system, not a slice'}"
191
- node ~/.claude/bin/qualia-ui.js end "ROUTED" "/qualia-plan"
195
+ node ${QUALIA_BIN}/qualia-ui.js warn "This is too big for /qualia-feature (5+ files or multi-step workflow)."
196
+ node ${QUALIA_BIN}/qualia-ui.js info "Reason: {one-line — e.g. 'description names the entire auth system, not a slice'}"
197
+ node ${QUALIA_BIN}/qualia-ui.js end "ROUTED" "/qualia-plan"
192
198
  ```
193
199
 
194
200
  If the user is sure it's small and the classifier got it wrong, they can re-invoke with `--force-spawn`.