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
@@ -43,7 +43,7 @@ Initialize a project with the **entire arc mapped from kickoff to handoff**. All
43
43
  ### Step 0. Banner
44
44
 
45
45
  ```bash
46
- node ~/.claude/bin/qualia-ui.js banner new
46
+ node ${QUALIA_BIN}/qualia-ui.js banner new
47
47
  ```
48
48
 
49
49
  Banner only. Do NOT ask anything yet. The next thing the user sees is the project-shape gate — not a free-text "tell me what to build". Shape gate first, content second, because the shape drives the question set.
@@ -122,7 +122,7 @@ If "More questions": re-invoke `/qualia-discuss` for additional rounds. Otherwis
122
122
 
123
123
  ### Step 5. Detect Project Type
124
124
 
125
- From questioning answers, infer type → `website` | `ai-agent` | `voice-agent` | `mobile-app` | `null`. If matched, `cat ~/.claude/qualia-templates/projects/{type}.md` gives suggested milestone arc. Store `template_type` for Step 13.
125
+ From questioning answers, infer type → `website` | `ai-agent` | `voice-agent` | `mobile-app` | `null`. If matched, `cat ${QUALIA_TEMPLATES}/projects/{type}.md` gives suggested milestone arc. Store `template_type` for Step 13.
126
126
 
127
127
  ### Step 6. Design Direction (frontend only)
128
128
 
@@ -140,7 +140,7 @@ Plus free-text: "Any brand colors or reference sites I should look at?"
140
140
 
141
141
  If client, ask name. Check saved prefs:
142
142
  ```bash
143
- node ~/.claude/bin/knowledge.js search "{client name}"
143
+ node ${QUALIA_BIN}/knowledge.js search "{client name}"
144
144
  ```
145
145
 
146
146
  ### Step 8. Write PROJECT.md
@@ -159,11 +159,11 @@ The domain glossary is the single highest-leverage piece of substrate — every
159
159
 
160
160
  ```bash
161
161
  # Copy template
162
- cp ~/.claude/qualia-templates/CONTEXT.md .planning/CONTEXT.md
162
+ cp ${QUALIA_TEMPLATES}/CONTEXT.md .planning/CONTEXT.md
163
163
 
164
164
  # Initialize ADR folder with the template available for reference
165
165
  mkdir -p .planning/decisions
166
- cp ~/.claude/qualia-templates/decisions/ADR-template.md .planning/decisions/_template.md
166
+ cp ${QUALIA_TEMPLATES}/decisions/ADR-template.md .planning/decisions/_template.md
167
167
  ```
168
168
 
169
169
  Then **seed the glossary from the questioning answers**. For each domain term that came up during the Step 4 `/qualia-discuss` interview — entities, actions, statuses, key nouns the user repeatedly said — add an entry to `.planning/CONTEXT.md` under `## Language` with:
@@ -252,7 +252,7 @@ git commit -m "docs: DESIGN.md — direction commit + OKLCH palette + tokens"
252
252
  Only `/qualia-new --quick` skips this step.
253
253
 
254
254
  ```bash
255
- node ~/.claude/bin/qualia-ui.js banner research
255
+ node ${QUALIA_BIN}/qualia-ui.js banner research
256
256
  mkdir -p .planning/research
257
257
  ```
258
258
 
@@ -275,7 +275,7 @@ git commit -m "docs: research synthesis (4 dimensions, multi-milestone scope)"
275
275
 
276
276
  Show key findings:
277
277
  ```bash
278
- node ~/.claude/bin/qualia-ui.js ok "Research complete"
278
+ node ${QUALIA_BIN}/qualia-ui.js ok "Research complete"
279
279
  ```
280
280
  Display top 3 from SUMMARY.md (stack recommendation, table stakes, top pitfall).
281
281
 
@@ -300,7 +300,7 @@ Gather any additional requirements the user wants that research missed.
300
300
  ### Step 13. Run Roadmapper
301
301
 
302
302
  ```bash
303
- node ~/.claude/bin/qualia-ui.js banner roadmap
303
+ node ${QUALIA_BIN}/qualia-ui.js banner roadmap
304
304
  ```
305
305
 
306
306
  **Roadmapper output branches on `PROJECT_TYPE`:**
@@ -315,7 +315,7 @@ Spawn the roadmapper with `<project_type>$PROJECT_TYPE</project_type>` in the pr
315
315
  Render the branded journey ladder:
316
316
 
317
317
  ```bash
318
- node ~/.claude/bin/qualia-ui.js journey-tree .planning/JOURNEY.md
318
+ node ${QUALIA_BIN}/qualia-ui.js journey-tree .planning/JOURNEY.md
319
319
  ```
320
320
 
321
321
  This shows M1..M{N} as a vertical ladder: shipped milestones get a green dot, current gets a teal diamond with `[CURRENT]` tag, future get dim open circles. Handoff gets `[FINAL]` tag. Why-now + phase sketch render under current and final.
@@ -345,9 +345,9 @@ git commit -m "docs: journey + requirements + milestone 1 roadmap ({N} milestone
345
345
  **After approval, show the progressive-detail reminder explicitly:**
346
346
 
347
347
  ```bash
348
- node ~/.claude/bin/qualia-ui.js info "Milestone 1 is fully planned now."
349
- node ~/.claude/bin/qualia-ui.js info "Milestones 2..{N-1} are sketched (names + one-line goals)."
350
- node ~/.claude/bin/qualia-ui.js info "Full phase detail for each later milestone gets written when /qualia-milestone opens it."
348
+ node ${QUALIA_BIN}/qualia-ui.js info "Milestone 1 is fully planned now."
349
+ node ${QUALIA_BIN}/qualia-ui.js info "Milestones 2..{N-1} are sketched (names + one-line goals)."
350
+ node ${QUALIA_BIN}/qualia-ui.js info "Full phase detail for each later milestone gets written when /qualia-milestone opens it."
351
351
  ```
352
352
 
353
353
  (Skip this block when `--full-detail` was used — all milestones are already fully planned in that case.)
@@ -368,7 +368,7 @@ git commit -m "chore: environment setup" 2>/dev/null
368
368
  If invoked with `--auto`, skip straight into building Milestone 1:
369
369
 
370
370
  ```bash
371
- node ~/.claude/bin/qualia-ui.js info "Auto mode — chaining into /qualia-plan 1"
371
+ node ${QUALIA_BIN}/qualia-ui.js info "Auto mode — chaining into /qualia-plan 1"
372
372
  ```
373
373
 
374
374
  Then inline-invoke `/qualia-plan 1`. That skill will chain into `/qualia-build 1 → /qualia-verify 1 → /qualia-plan 2 → ...` until Milestone 1's last phase verifies, at which point the chain pauses at the milestone boundary and asks:
@@ -380,7 +380,7 @@ Then inline-invoke `/qualia-plan 1`. That skill will chain into `/qualia-build 1
380
380
  **Without `--auto`**, end with a clear pointer:
381
381
 
382
382
  ```bash
383
- node ~/.claude/bin/qualia-ui.js end "JOURNEY READY" "/qualia-plan 1"
383
+ node ${QUALIA_BIN}/qualia-ui.js end "JOURNEY READY" "/qualia-plan 1"
384
384
  ```
385
385
 
386
386
  Show summary:
@@ -258,7 +258,7 @@ Constraints:
258
258
  )
259
259
  ```
260
260
 
261
- After all 3 return, present a comparison table to the user (see SKILL.md Step 5b). User picks 1, 2, 3, or hybrid. Then a single synthesizer agent writes the Refactor RFC to `.planning/REFACTOR-{slug}.md` honoring the user's pick.
261
+ After all 3 return, present a comparison table to the user (see SKILL.md Step 5b). User picks 1, 2, 3, or hybrid. Then a single synthesizer agent writes the Refactor RFC to `.planning/reports/refactor/REFACTOR-{slug}.md` honoring the user's pick.
262
262
 
263
263
  **Token cost**: ~6K per variant × 3 variants = ~18K for the fan-out. Cached prefix (CONTEXT.md + ADRs + candidate block) is shared across the 3 spawns, so effective cost is closer to ~12K. The output rfc-pick stage adds ~3K. Total per-deepening-candidate: ~15K — well within Qualia's per-skill budget.
264
264
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-optimize
3
- description: "Deep optimization pass — reads .planning/ AND codebase to find performance, design, UI, backend, frontend, AND architecture-deepening opportunities. Spawns parallel specialist agents. Use whenever the user says 'optimize', 'optimization pass', 'find issues', 'qualia-optimize', 'deep optimize', 'performance audit', 'design alignment check', 'speed up', 'slow', 'bundle size', 'refactor architecture', 'shallow modules', 'simplify', or wants a comprehensive quality sweep. Supports --perf, --ui, --backend, --alignment, --deepen, --fix flags."
3
+ description: "Deep improvement discovery pass — reads .planning/ AND codebase to find performance, design, UI, backend, frontend, alignment, and architecture-deepening opportunities. Spawns parallel specialist agents and writes OPTIMIZE.md/RFCs; practical repair work routes to /qualia-fix or /qualia-polish. Use when the user says 'optimize', 'optimization pass', 'find issues', 'deep improve', 'performance audit', 'design alignment check', 'speed up', 'bundle size', 'refactor architecture', 'shallow modules', 'simplify', or wants a comprehensive quality sweep. Supports --perf, --ui, --backend, --alignment, --deepen, --fix flags."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -21,6 +21,8 @@ Detailed agent-prompt templates live in `REFERENCE.md` (in this same skill folde
21
21
 
22
22
  Reads `.planning/` docs AND codebase. Never analyze one without the other.
23
23
 
24
+ Optimize is discovery-first, not a hotfix lane. If the user has one broken behavior, route to `/qualia-fix`. If the user has visual quality problems, route to `/qualia-polish`. Use optimize when the question is "where can this system get better?"
25
+
24
26
  ## Usage
25
27
 
26
28
  - `/qualia-optimize` — Full (all 7 dimensions + architecture deepening)
@@ -29,7 +31,7 @@ Reads `.planning/` docs AND codebase. Never analyze one without the other.
29
31
  - `/qualia-optimize --backend` — Backend only (RLS, auth, queries, edge fns)
30
32
  - `/qualia-optimize --alignment` — Planning-code alignment only
31
33
  - `/qualia-optimize --deepen` — Architecture deepening only (Ousterhout: shallow modules, deeper interfaces)
32
- - `/qualia-optimize --fix` — Auto-fix LOW/MEDIUM from existing OPTIMIZE.md
34
+ - `/qualia-optimize --fix` — Compatibility mode: convert LOW/MEDIUM `.planning/reports/optimize/OPTIMIZE.md` findings into safe repairs, using `/qualia-fix` rules for any code mutation
33
35
 
34
36
  ## Process
35
37
 
@@ -37,7 +39,7 @@ Reads `.planning/` docs AND codebase. Never analyze one without the other.
37
39
 
38
40
  Mode from $ARGUMENTS. Default: `full`.
39
41
  Modes: `full`, `perf`, `ui`, `backend`, `alignment`, `deepen`, `fix`.
40
- `--fix` skips to Step 9 (requires `.planning/OPTIMIZE.md`).
42
+ `--fix` skips to Step 9 (requires `.planning/reports/optimize/OPTIMIZE.md`, with fallback to legacy `.planning/OPTIMIZE.md`) and follows `/qualia-fix` mutation rules.
41
43
 
42
44
  ### Step 2: Load Planning Context (MANDATORY)
43
45
 
@@ -73,8 +75,8 @@ ls .planning/decisions/ 2>/dev/null && cat .planning/decisions/*.md 2>/dev/null
73
75
 
74
76
  Also read rules:
75
77
  ```bash
76
- cat ~/.claude/qualia-design/frontend.md 2>/dev/null
77
- cat ~/.claude/rules/security.md 2>/dev/null
78
+ cat ${QUALIA_DESIGN}/frontend.md 2>/dev/null
79
+ cat ${QUALIA_RULES}/security.md 2>/dev/null
78
80
  ```
79
81
 
80
82
  Store all; inline into agent prompts.
@@ -146,7 +148,7 @@ Collect all 3 proposals. Present to the user as a side-by-side table:
146
148
  | 2 | ... | ... | ... | ... |
147
149
  | 3 | ... | ... | ... | ... |
148
150
 
149
- User picks `1`, `2`, `3`, or `hybrid` (with notes on which elements from which proposals to combine). The synthesizer then writes a "Refactor RFC" to `.planning/REFACTOR-{slug}.md` and optionally opens a GH issue.
151
+ User picks `1`, `2`, `3`, or `hybrid` (with notes on which elements from which proposals to combine). The synthesizer then writes a "Refactor RFC" to `.planning/reports/refactor/REFACTOR-{slug}.md` and optionally opens a GH issue.
150
152
 
151
153
  **Why parallel + radically different**: a single deepening proposal anchors on the first idea the LLM has. Three parallel proposals with diverse design constraints surface trade-offs the user can see at a glance — and the human's "taste" dominates the choice rather than the agent's first instinct. Empirically (Matt Pocock + Qualia internal testing) this produces dramatically better refactor RFCs than a single-pass proposal.
152
154
 
@@ -187,7 +189,11 @@ All agents done:
187
189
 
188
190
  ### Step 8: Write OPTIMIZE.md and Present Results
189
191
 
190
- Write to `.planning/OPTIMIZE.md`:
192
+ Create the report directory and write to `.planning/reports/optimize/OPTIMIZE.md`:
193
+
194
+ ```bash
195
+ mkdir -p .planning/reports/optimize
196
+ ```
191
197
 
192
198
  ```markdown
193
199
  ---
@@ -237,7 +243,7 @@ status: {clean|needs_attention|critical_issues}
237
243
 
238
244
  Commit:
239
245
  ```bash
240
- git add .planning/OPTIMIZE.md && git commit -m "docs: optimization report ({mode} mode, {critical} critical)"
246
+ git add .planning/reports/optimize/OPTIMIZE.md && git commit -m "docs: optimization report ({mode} mode, {critical} critical)"
241
247
  ```
242
248
 
243
249
  **Present results:**
@@ -247,25 +253,26 @@ If CRITICAL findings exist:
247
253
  {critical} critical issues found. Options:
248
254
 
249
255
  1. Create a fix phase in ROADMAP.md for critical + high findings
250
- 2. Auto-fix LOW/MEDIUM findings: /qualia-optimize --fix
251
- 3. Review full report: cat .planning/OPTIMIZE.md
256
+ 2. Repair a specific blocker: /qualia-fix {finding}
257
+ 3. Convert LOW/MEDIUM findings into safe repairs: /qualia-optimize --fix
258
+ 4. Review full report: cat .planning/reports/optimize/OPTIMIZE.md
252
259
  ```
253
260
 
254
261
  If no CRITICAL:
255
262
  ```
256
263
  Optimization complete. {total} findings ({high} high, {medium} medium, {low} low).
257
- Report: .planning/OPTIMIZE.md
264
+ Report: .planning/reports/optimize/OPTIMIZE.md
258
265
 
259
- Run /qualia-optimize --fix to auto-fix LOW/MEDIUM findings.
266
+ Run /qualia-fix for a specific defect, or /qualia-optimize --fix only for safe LOW/MEDIUM cleanup from this report.
260
267
  ```
261
268
 
262
269
  ### Step 9: --fix Mode
263
270
 
264
- `--fix` mode:
271
+ `--fix` mode is a compatibility cleanup lane, not a replacement for `/qualia-fix`.
265
272
 
266
- 1. Read `.planning/OPTIMIZE.md`; missing: "Run /qualia-optimize first"
273
+ 1. Read `.planning/reports/optimize/OPTIMIZE.md` (fallback: `.planning/OPTIMIZE.md` for older projects); missing: "Run /qualia-optimize first"
267
274
  2. Filter to LOW + MEDIUM only
268
- 3. Per finding with clear, safe fix:
275
+ 3. Per finding with clear, safe fix, apply `/qualia-fix` mutation rules:
269
276
  - Read target file
270
277
  - Apply fix
271
278
  - Verify (npx tsc --noEmit if TS)
@@ -273,7 +280,7 @@ Run /qualia-optimize --fix to auto-fix LOW/MEDIUM findings.
273
280
  5. Commit
274
281
  6. Report fixed vs remaining
275
282
 
276
- **Never auto-fix CRITICAL/HIGH.** Require human judgment.
283
+ **Never auto-fix CRITICAL/HIGH.** Require human judgment. If a finding is an actual broken behavior, use `/qualia-fix {finding}` instead of burying it in optimize.
277
284
 
278
285
  ### Step 10: Gap Phase Creation (user picks option 1)
279
286
 
@@ -15,7 +15,7 @@ Save context so the next session picks up where you left off.
15
15
  ## Process
16
16
 
17
17
  ```bash
18
- node ~/.claude/bin/qualia-ui.js banner pause
18
+ node ${QUALIA_BIN}/qualia-ui.js banner pause
19
19
  ```
20
20
 
21
21
  ### 1. Read State
@@ -63,6 +63,6 @@ git commit -m "WIP: {phase name} — session handoff"
63
63
  ```
64
64
 
65
65
  ```bash
66
- node ~/.claude/bin/state.js transition --to note --notes "Session paused — see .continue-here.md"
66
+ node ${QUALIA_BIN}/state.js transition --to note --notes "Session paused — see .continue-here.md"
67
67
  ```
68
68
  Do NOT manually edit STATE.md or tracking.json — state.js handles both.
@@ -27,15 +27,19 @@ Spawn planner to break phase into tasks, validate with checker (max 2 revision c
27
27
 
28
28
  ## Process
29
29
 
30
+ ### 0. Codex goal (Codex runtime only)
31
+
32
+ Per `rules/codex-goal.md` — set the thread goal at plan start with scope `phase`. The objective covers both planning and the subsequent build, so a single goal-set at this stage is enough.
33
+
30
34
  ### 1. Determine Phase & Load Context
31
35
 
32
36
  ```bash
33
37
  cat .planning/STATE.md 2>/dev/null
34
38
  cat .planning/ROADMAP.md 2>/dev/null
35
39
  cat .planning/PROJECT.md 2>/dev/null
36
- node ~/.claude/bin/knowledge.js
37
- node ~/.claude/bin/knowledge.js load patterns
38
- node ~/.claude/bin/knowledge.js load client
40
+ node ${QUALIA_BIN}/knowledge.js
41
+ node ${QUALIA_BIN}/knowledge.js load patterns
42
+ node ${QUALIA_BIN}/knowledge.js load client
39
43
  ```
40
44
 
41
45
  No phase number → current phase from STATE.md.
@@ -63,13 +67,13 @@ Suggest: *"Run /qualia-discuss {N} first to lock decisions? Optional."*
63
67
  ### 3. Spawn Planner (Fresh Context)
64
68
 
65
69
  ```bash
66
- node ~/.claude/bin/qualia-ui.js banner plan {N} "{phase name from ROADMAP.md}"
67
- node ~/.claude/bin/qualia-ui.js spawn planner "Breaking phase into tasks..."
70
+ node ${QUALIA_BIN}/qualia-ui.js banner plan {N} "{phase name from ROADMAP.md}"
71
+ node ${QUALIA_BIN}/qualia-ui.js spawn planner "Breaking phase into tasks..."
68
72
  ```
69
73
 
70
74
  ```
71
75
  Agent(prompt="
72
- Role: @~/.claude/agents/planner.md
76
+ Role: @${QUALIA_AGENTS}/planner.md
73
77
 
74
78
  <project_context>
75
79
  @.planning/PROJECT.md
@@ -112,7 +116,7 @@ Read generated plan. Spawn checker:
112
116
 
113
117
  ```
114
118
  Agent(prompt="
115
- Role: @~/.claude/agents/plan-checker.md
119
+ Role: @${QUALIA_AGENTS}/plan-checker.md
116
120
 
117
121
  <plan_path>.planning/phase-{N}-plan.md</plan_path>
118
122
  <phase_goal>{goal from ROADMAP.md}</phase_goal>
@@ -134,7 +138,7 @@ Per revision:
134
138
 
135
139
  ```
136
140
  Agent(prompt="
137
- Role: @~/.claude/agents/planner.md
141
+ Role: @${QUALIA_AGENTS}/planner.md
138
142
 
139
143
  <revision_mode>true</revision_mode>
140
144
  <current_plan>@.planning/phase-{N}-plan.md</current_plan>
@@ -151,7 +155,7 @@ After revision, re-spawn checker. Max 2 total cycles.
151
155
  **BLOCKED after 2 cycles:**
152
156
 
153
157
  ```bash
154
- node ~/.claude/bin/qualia-ui.js fail "Plan failed validation after 2 revisions"
158
+ node ${QUALIA_BIN}/qualia-ui.js fail "Plan failed validation after 2 revisions"
155
159
  ```
156
160
 
157
161
  Show remaining issues. Options:
@@ -161,10 +165,19 @@ Show remaining issues. Options:
161
165
 
162
166
  ### 5. Present Final Plan
163
167
 
168
+ Before presenting, write the machine-readable contract:
169
+
170
+ ```bash
171
+ node ${QUALIA_BIN}/plan-contract.js validate .planning/phase-{N}-contract.json
172
+ node ${QUALIA_BIN}/state.js validate-plan --phase {N} --require-contract
173
+ ```
174
+
175
+ The planner must create `.planning/phase-{N}-contract.json` from the final plan. This JSON contract is the authority for build and verification; Markdown contracts are explanatory only. If validation fails, revise the plan/contract pair before asking for approval.
176
+
164
177
  Render story-file dashboard:
165
178
 
166
179
  ```bash
167
- node ~/.claude/bin/qualia-ui.js plan-summary .planning/phase-{N}-plan.md
180
+ node ${QUALIA_BIN}/qualia-ui.js plan-summary .planning/phase-{N}-plan.md
168
181
  ```
169
182
 
170
183
  End with plain text: *"Approve? (yes / adjust)"*
@@ -174,7 +187,8 @@ If "adjust" — get feedback, re-spawn planner with revision context, re-validat
174
187
  ### 6. Update State
175
188
 
176
189
  ```bash
177
- node ~/.claude/bin/state.js transition --to planned --phase {N}
190
+ node ${QUALIA_BIN}/state.js validate-plan --phase {N} --require-contract
191
+ node ${QUALIA_BIN}/state.js transition --to planned --phase {N}
178
192
  ```
179
193
 
180
194
  Error → show, stop. Do NOT edit STATE.md or tracking.json manually.
@@ -184,7 +198,7 @@ Error → show, stop. Do NOT edit STATE.md or tracking.json manually.
184
198
  **`--auto`:** invoke `/qualia-build {N} --auto` inline. User approved at `/qualia-new`; no per-phase gate.
185
199
 
186
200
  ```bash
187
- node ~/.claude/bin/qualia-ui.js info "Auto mode — chaining into /qualia-build {N}"
201
+ node ${QUALIA_BIN}/qualia-ui.js info "Auto mode — chaining into /qualia-build {N}"
188
202
  ```
189
203
 
190
204
  Then invoke `qualia-build` inline with `--auto`.
@@ -192,7 +206,7 @@ Then invoke `qualia-build` inline with `--auto`.
192
206
  **Guided mode:** stop, show next step:
193
207
 
194
208
  ```bash
195
- node ~/.claude/bin/qualia-ui.js end "PHASE {N} PLANNED" "/qualia-build {N}"
209
+ node ${QUALIA_BIN}/qualia-ui.js end "PHASE {N} PLANNED" "/qualia-build {N}"
196
210
  ```
197
211
 
198
212
  ## Gap Closure Mode (`--gaps`)
@@ -55,10 +55,10 @@ Agent({
55
55
  subagent_type: "qualia-visual-evaluator",
56
56
  description: "Score iteration {N} screenshots against rubric",
57
57
  prompt: `
58
- Role: @~/.claude/agents/visual-evaluator.md
58
+ Role: @${QUALIA_AGENTS}/visual-evaluator.md
59
59
 
60
60
  <rubric>
61
- {INLINE qualia-design/design-rubric.md §"The 8 dimensions" through §"Aggregate score"}
61
+ {INLINE qualia-design/design-rubric.md §"The 9 dimensions" through §"Aggregate score"}
62
62
  </rubric>
63
63
 
64
64
  <brief>
@@ -101,7 +101,7 @@ Agent({
101
101
  subagent_type: "qualia-builder",
102
102
  description: "Fix {dim} issue: {short description}",
103
103
  prompt: `
104
- Role: @~/.claude/agents/builder.md
104
+ Role: @${QUALIA_AGENTS}/builder.md
105
105
 
106
106
  <phase_context>
107
107
  You are inside /qualia-polish --loop iteration {N}. The vision evaluator scored
@@ -133,7 +133,7 @@ the {dim} dimension at {score}. Your single task: fix that one dimension.
133
133
  2. Make the MINIMUM edit to fix this one dimension. Do not refactor. Do not change logic. Do not touch state management. Do not change copy unless this is a microcopy issue.
134
134
  3. Use design tokens from DESIGN.md. Do not invent new color values, font names, or spacing.
135
135
  4. After the edit, commit via the orchestrator (slop-detect-gated):
136
- node ~/.claude/skills/qualia-polish/scripts/loop.mjs commit-fix --state {STATE} --file {file} --slug {dim}-{short-keyword}
136
+ node ${QUALIA_SKILLS}/qualia-polish/scripts/loop.mjs commit-fix --state {STATE} --file {file} --slug {dim}-{short-keyword}
137
137
  If slop-detect blocks (exit 2), READ the slop output and re-edit. If you cannot fix without violating slop-detect, return BLOCKED with the conflict.
138
138
  5. Return DONE with: file modified, lines changed, slop-detect: pass, commit: {sha}.
139
139
  </task>
@@ -153,10 +153,10 @@ the {dim} dimension at {score}. Your single task: fix that one dimension.
153
153
  ```json
154
154
  {
155
155
  "iteration": 1,
156
- "scores": { "typography": 1, "color": 1, "spatial": 3, "layout": 1, "shadow": 3, "motion": 3, "microcopy": 1, "container": 1 },
157
- "aggregate": 14,
156
+ "scores": { "typography": 1, "color": 1, "spatial": 3, "layout": 1, "shadow": 3, "motion": 3, "microcopy": 1, "container": 1, "graphics": 1 },
157
+ "aggregate": 15,
158
158
  "pass": false,
159
- "failing_dims": ["typography", "color", "layout", "microcopy", "container"],
159
+ "failing_dims": ["typography", "color", "layout", "microcopy", "container", "graphics"],
160
160
  "top_issues": [
161
161
  { "dim": "color", "severity": "critical", "description": "blue→purple gradient on hero", "likely_file": "src/styles/globals.css", "fix": "replace linear-gradient with single accent var(--accent)" },
162
162
  { "dim": "typography", "severity": "critical", "description": "Inter as primary font-family", "likely_file": "src/styles/globals.css", "fix": "swap to Fraunces + JetBrains Mono per DESIGN.md §3" },
@@ -222,23 +222,23 @@ The pilot-results doc at `docs/playwright-loop-pilot-results.md` records the act
222
222
  ## Iteration log
223
223
 
224
224
  ### Iteration 1
225
- - Scores: typo=1 colo=1 spat=3 layo=1 shad=3 moti=3 micr=1 cont=1
226
- - Aggregate: 14/40 (avg 1.75)
227
- - Pass: NO (failing: typography, color, layout, microcopy, container)
225
+ - Scores: typo=1 colo=1 spat=3 layo=1 shad=3 moti=3 micr=1 cont=1 grap=1
226
+ - Aggregate: 15/45 (avg 1.67)
227
+ - Pass: NO (failing: typography, color, layout, microcopy, container, graphics)
228
228
  - Top issues:
229
229
  - **color** [critical] blue→purple gradient on hero → src/styles/globals.css
230
230
  - **typography** [critical] Inter as primary → src/styles/globals.css
231
231
  - **layout** [high] three identical cards → src/pages/index.tsx
232
232
 
233
233
  ### Iteration 2
234
- - Scores: typo=3 colo=3 spat=3 layo=2 shad=3 moti=3 micr=2 cont=2
235
- - Aggregate: 21/40 (avg 2.62)
234
+ - Scores: typo=3 colo=3 spat=3 layo=2 shad=3 moti=3 micr=2 cont=2 grap=2
235
+ - Aggregate: 23/45 (avg 2.56)
236
236
  - Pass: NO (failing: layout, microcopy, container)
237
237
  - ...
238
238
 
239
239
  ### Iteration 3
240
- - Scores: typo=4 colo=3 spat=3 layo=3 shad=3 moti=3 micr=3 cont=3
241
- - Aggregate: 25/40 (avg 3.13)
240
+ - Scores: typo=4 colo=3 spat=3 layo=3 shad=3 moti=3 micr=3 cont=3 grap=4
241
+ - Aggregate: 29/45 (avg 3.22)
242
242
  - Pass: YES
243
243
 
244
244
  ## Fix commits (revertable)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-polish
3
- description: "Scope-adaptive design pass. Works on a single component, a route, the whole app, a ground-up redesign, or an autonomous visual loop. Trigger on 'polish', 'design pass', 'fix the design', 'redesign', 'critique', 'audit design', 'looks ugly', 'make it look better', 'polish loop', 'visual loop', 'fix what I see', 'iterate on the design until it's correct'. Replaces /qualia-polish-loop (now /qualia-polish --loop) and /qualia-design from earlier versions."
3
+ description: "Scope-adaptive visual quality pass. Works on a single component, a route, the whole app, a ground-up redesign, or an autonomous visual loop, but does not repair business logic or broken data flow. Trigger on 'polish', 'design pass', 'fix the design', 'redesign', 'critique', 'audit design', 'looks ugly', 'make it look better', 'polish loop', 'visual loop', 'fix what I see', 'iterate on the design until it's correct'. Route functional bugs to /qualia-fix and aesthetic token pivots to /qualia-vibe."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -9,12 +9,16 @@ allowed-tools:
9
9
  - Grep
10
10
  - Glob
11
11
  - Agent
12
+ - WebSearch
13
+ - WebFetch
12
14
  argument-hint: "[file|route|--redesign|--critique|--quick|--loop] [--register=brand|product] [--brief PATH] [--max 8] [--viewports 375,768,1440]"
13
15
  ---
14
16
 
15
17
  # /qualia-polish — Scope-Adaptive Design Pass
16
18
 
17
- One command. Seven scopes. Use it whenever you need design work, from a 30-second component touch-up to a 30-minute ground-up redesign to a fully autonomous see-fix-verify loop.
19
+ One command. Seven scopes. Use it whenever you need design work, from a 30-second component touch-up to a ground-up redesign with current design research, complex visuals, and a fully transparent see-fix-verify loop.
20
+
21
+ Polish fixes visual quality only. Broken behavior, failing tests, API bugs, state bugs, and config errors go to `/qualia-fix`. Whole-site aesthetic token pivots go to `/qualia-vibe`.
18
22
 
19
23
  ## Scopes
20
24
 
@@ -32,9 +36,23 @@ The first argument selects the scope. Stage selection follows from scope.
32
36
 
33
37
  Other flags: `--register=brand|product` overrides register inference. Loop-specific flags: `--brief PATH`, `--max N`, `--viewports 375,768,1440`, `--ref PATH`, `--budget 100000`.
34
38
 
39
+ ## Transparent Command Output
40
+
41
+ Follow `rules/command-output.md`. At minimum, show:
42
+
43
+ ```text
44
+ Command: /qualia-polish {scope}
45
+ Scope: {target files/routes}
46
+ Intent: visual quality | redesign | critique | loop
47
+ Mutation: none | planned | active | blocked
48
+ Evidence: DESIGN.md, PRODUCT.md, qualia-design files, screenshots, online sources when used
49
+ Output: changed files, screenshots, report, commit
50
+ Next: {next command or done}
51
+ ```
52
+
35
53
  ## --loop mode (autonomous visual loop)
36
54
 
37
- When `--loop` is the first flag, the polish run is fully autonomous: screenshot a live URL at three viewports, score 8 design dimensions of `qualia-design/design-rubric.md` against the brief using vision, fix top issues in the codebase, re-screenshot, repeat until every dimension scores 3 or the kill-switch fires (regression, budget cap, max iterations).
55
+ When `--loop` is the first flag, the polish run is fully autonomous: screenshot a live URL at three viewports, score 9 design dimensions of `qualia-design/design-rubric.md` against the brief using vision, fix top issues in the codebase, re-screenshot, repeat until every dimension scores >= 3 or the kill-switch fires (regression, budget cap, max iterations).
38
56
 
39
57
  Scripts ship at `skills/qualia-polish/scripts/{loop,playwright-capture,score}.mjs`; the vision evaluator is `agents/visual-evaluator.md`; the full loop spec lives in this skill's `REFERENCE.md`.
40
58
 
@@ -46,7 +64,7 @@ Before any work — design or otherwise — pass these gates. Skipping them prod
46
64
 
47
65
  | Gate | Required check | If fail |
48
66
  |---|---|---|
49
- | Substrate | `qualia-design/design-laws.md`, `design-brand.md`, `design-product.md`, `design-rubric.md` exist and have been read | Read them. |
67
+ | Substrate | `qualia-design/design-laws.md`, `design-brand.md`, `design-product.md`, `design-rubric.md`, `design-reference.md`, `frontend.md`, `graphics.md` exist and have been read when scope requires them | Read them. |
50
68
  | PRODUCT | `PRODUCT.md` exists at project root, has `register:` field, and is not placeholder (`[TODO]` markers, &lt; 200 chars) | Run setup: ask 5 questions and generate it. Never synthesize from prompt alone. |
51
69
  | DESIGN | `DESIGN.md` exists. If missing on App / Redesign scope, BLOCK and run setup. If missing on Component / Section / Critique / Quick scope, NUDGE and proceed. | Generate from PRODUCT.md + 3 questions. |
52
70
  | Slop-detect | `bin/slop-detect.mjs` is callable | Install or pull from framework. |
@@ -55,13 +73,13 @@ Before any work — design or otherwise — pass these gates. Skipping them prod
55
73
  State this preflight explicitly before editing:
56
74
 
57
75
  ```
58
- POLISH_PREFLIGHT: substrate=pass product=pass design=pass|nudged slop_detect=pass mutation=open
76
+ POLISH_PREFLIGHT: substrate=pass product=pass design=pass|nudged graphics=loaded|skipped slop_detect=pass mutation=open
59
77
  ```
60
78
 
61
79
  ## Process
62
80
 
63
81
  ```bash
64
- node ~/.claude/bin/qualia-ui.js banner polish
82
+ node ${QUALIA_BIN}/qualia-ui.js banner polish
65
83
  ```
66
84
 
67
85
  ### Stage 0 — Direction commit (mandatory; light on small scopes)
@@ -79,8 +97,18 @@ Aesthetic direction: {ONE concrete direction — e.g. "editorial broadsheet, iv
79
97
  Color strategy: {ONE choice — Restrained / Committed / Full palette / Drenched — with one-line justification}
80
98
  Scene sentence: {who uses this, where, ambient light, mood — concrete}
81
99
  Differentiation: {what someone remembers 24 hours later}
100
+ Complex visual: {hero/product/data/diagram/3D/canvas concept, or "none because..."}
101
+ Research anchors: {2-4 sources checked, or "local only" for component/quick}
82
102
  ```
83
103
 
104
+ For Redesign scope, run a short online best-practices check before the brief unless the user explicitly says offline. Prefer primary sources:
105
+ - W3C WCAG 2.2 / WAI for accessibility, focus, target size, contrast: https://www.w3.org/TR/WCAG22/
106
+ - Apple Human Interface Guidelines for motion/accessibility restraint: https://developer.apple.com/design/human-interface-guidelines/motion
107
+ - Material Design motion guidance for spatial continuity and state transitions: https://m3.material.io/styles/motion/overview
108
+ - Nielsen Norman Group for visual hierarchy, scannability, and usability evidence: https://www.nngroup.com/articles/visual-hierarchy-ux-definition/
109
+
110
+ Use the sources as constraints, not as a style to copy. Cite links in the report/summary when they shaped the redesign.
111
+
84
112
  If the user pushes back on the proposed direction, that is a `/qualia-vibe` trigger — switch surfaces, do not start enumerating alternatives in the brief.
85
113
 
86
114
  For Component / Section / Quick scope, the brief is implicit (loaded from DESIGN.md). Skip the ultrathink step but cite the relevant DESIGN.md tokens you'll touch.
@@ -112,7 +140,9 @@ For App / Redesign / Section scope on multi-file work:
112
140
 
113
141
  Each agent receives:
114
142
  - `qualia-design/design-laws.md` + the matching register file
143
+ - `qualia-design/frontend.md`, `design-reference.md`, and `graphics.md` for App / Redesign / Loop scopes
115
144
  - `PRODUCT.md` + `DESIGN.md` (inlined)
145
+ - Online research anchors for Redesign scope, summarized in 3-6 bullets with links
116
146
  - Its 5 files (paths + contents)
117
147
  - Instruction: apply the Design Quality Rubric per file. Fix every dimension scoring &lt; 3. Make literal edits. Do NOT change logic — only styling.
118
148
 
@@ -130,6 +160,21 @@ For Component scope: do the work in main context. Read, fix, verify.
130
160
  | Motion intent | DESIGN.md §7 — easing, stagger, signature motion |
131
161
  | Microcopy | rename "Get Started" / "Learn More" to action-named CTAs |
132
162
  | Container depth | flatten card-on-card; remove side-stripe borders |
163
+ | Complex graphics | graphics.md — add meaningful product/data/process visuals, not decoration |
164
+
165
+ ### Stage 2b — Complex Visual Layer (App / Redesign / Loop)
166
+
167
+ For whole-app, redesign, and loop scopes, decide whether the page needs a stronger visual system.
168
+
169
+ 1. Read `qualia-design/graphics.md`.
170
+ 2. Inspect the product/domain from PRODUCT.md and CONTEXT.md.
171
+ 3. Choose one:
172
+ - **No complex visual**: explain why typography/layout alone is stronger.
173
+ - **Bitmap/media**: real/generative/search asset that reveals product/place/person/state.
174
+ - **Diagram/data**: custom SVG/canvas/chart that explains relationships.
175
+ - **3D/canvas**: Three.js or canvas scene for spatial/product/system experience.
176
+ 4. If adding a visual, implement it as a first-viewport or primary-section signal, not a tiny decoration.
177
+ 5. Verify mobile framing, reduced-motion fallback, contrast, and nonblank rendering.
133
178
 
134
179
  ### Stage 3 — Runtime gates (App / Section / Redesign only — needs dev server)
135
180
 
@@ -170,7 +215,7 @@ For each iteration:
170
215
 
171
216
  1. Capture all 3 viewports
172
217
  2. Pass to a vision-model agent with `qualia-design/design-rubric.md` as the prompt anchor + DESIGN.md as the spec
173
- 3. The agent scores 8 dimensions, anchored 1-5, with evidence per dimension
218
+ 3. The agent scores 9 dimensions, anchored 1-5, with evidence per dimension
174
219
  4. Apply fixes ONLY to dimensions scored 1 or 2 (don't nitpick 3s; prevents oscillation)
175
220
  5. STOP if: all dimensions ≥ 3 (success), OR any dimension regressed from previous iteration (regression-stop), OR 2 iterations reached (hard cap)
176
221
 
@@ -208,7 +253,7 @@ npx tsc --noEmit 2>&1 | tail -10
208
253
 
209
254
  ### Stage 7 — Commit & state
210
255
 
211
- For Critique scope: write the report to `.planning/polish-critique-{timestamp}.md` and STOP. Do not edit, do not commit.
256
+ For Critique scope: create `.planning/reports/polish/`, write the report to `.planning/reports/polish/polish-critique-{timestamp}.md`, and STOP. Do not edit, do not commit.
212
257
 
213
258
  For all other scopes:
214
259
 
@@ -219,7 +264,7 @@ polish({scope}): {brief summary}
219
264
 
220
265
  - {key change 1}
221
266
  - {key change 2}
222
- - rubric scores: typography {N}, color {N}, ..., aggregate {N}/40
267
+ - rubric scores: typography {N}, color {N}, graphics {N}, ..., aggregate {N}/45
223
268
 
224
269
  Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
225
270
  EOF
@@ -229,7 +274,7 @@ EOF
229
274
  If this is the FINAL polish before deploy (Handoff milestone, last phase):
230
275
 
231
276
  ```bash
232
- node ~/.claude/bin/state.js transition --to polished
277
+ node ${QUALIA_BIN}/state.js transition --to polished
233
278
  ```
234
279
 
235
280
  Otherwise, no state transition (polish is now a normal verb, not a phase boundary).
@@ -237,21 +282,21 @@ Otherwise, no state transition (polish is now a normal verb, not a phase boundar
237
282
  ### Output
238
283
 
239
284
  ```bash
240
- node ~/.claude/bin/qualia-ui.js divider
241
- node ~/.claude/bin/qualia-ui.js ok "Scope: {component|section|app|redesign|critique|quick}"
242
- node ~/.claude/bin/qualia-ui.js ok "Files: {N}"
243
- node ~/.claude/bin/qualia-ui.js ok "Slop-detect: {N critical, M high, K medium}"
244
- node ~/.claude/bin/qualia-ui.js ok "Rubric aggregate: {N}/40 (avg {N})"
245
- node ~/.claude/bin/qualia-ui.js ok "Vision iterations: {0|1|2}"
246
- node ~/.claude/bin/qualia-ui.js ok "Drift findings: {N}"
247
- node ~/.claude/bin/qualia-ui.js end "POLISHED" "{next command — depends on context}"
285
+ node ${QUALIA_BIN}/qualia-ui.js divider
286
+ node ${QUALIA_BIN}/qualia-ui.js ok "Scope: {component|section|app|redesign|critique|quick}"
287
+ node ${QUALIA_BIN}/qualia-ui.js ok "Files: {N}"
288
+ node ${QUALIA_BIN}/qualia-ui.js ok "Slop-detect: {N critical, M high, K medium}"
289
+ node ${QUALIA_BIN}/qualia-ui.js ok "Rubric aggregate: {N}/45 (avg {N})"
290
+ node ${QUALIA_BIN}/qualia-ui.js ok "Vision iterations: {0|1|2}"
291
+ node ${QUALIA_BIN}/qualia-ui.js ok "Drift findings: {N}"
292
+ node ${QUALIA_BIN}/qualia-ui.js end "POLISHED" "{next command — depends on context}"
248
293
  ```
249
294
 
250
295
  ## Rules
251
296
 
252
297
  1. **Read before write.** Understand every file before changing it.
253
298
  2. **DESIGN.md is law.** If a project decision exists, follow it. Don't override.
254
- 3. **Don't break functionality.** Only change styling, never logic.
299
+ 3. **Don't repair functionality here.** Only change styling, layout, copy polish, accessibility attributes, and design tokens already authorized by DESIGN.md. Route logic/data/config bugs to `/qualia-fix`.
255
300
  4. **Slop is a bug.** Critical-severity findings block commit. No overriding the script.
256
301
  5. **TypeScript must pass** after every change.
257
302
  6. **One commit per polish run** — not per category, not per file.