qwen-base 1.0.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 (71) hide show
  1. package/README.md +183 -0
  2. package/bin/install.js +227 -0
  3. package/package.json +42 -0
  4. package/src/commands/audit-claude-md.md +44 -0
  5. package/src/commands/audit-claude.md +45 -0
  6. package/src/commands/audit.md +33 -0
  7. package/src/commands/carl-hygiene.md +33 -0
  8. package/src/commands/groom.md +35 -0
  9. package/src/commands/history.md +27 -0
  10. package/src/commands/orientation/tasks/deep-why.md +132 -0
  11. package/src/commands/orientation/tasks/elevator-pitch.md +115 -0
  12. package/src/commands/orientation/tasks/initiatives.md +98 -0
  13. package/src/commands/orientation/tasks/key-values.md +130 -0
  14. package/src/commands/orientation/tasks/new-orientation.md +162 -0
  15. package/src/commands/orientation/tasks/north-star.md +97 -0
  16. package/src/commands/orientation/tasks/project-mapping.md +103 -0
  17. package/src/commands/orientation/tasks/reorientation.md +96 -0
  18. package/src/commands/orientation/tasks/surface-vision.md +113 -0
  19. package/src/commands/orientation/tasks/task-seeding.md +93 -0
  20. package/src/commands/orientation/templates/operator-json.md +88 -0
  21. package/src/commands/orientation.md +87 -0
  22. package/src/commands/pulse.md +33 -0
  23. package/src/commands/scaffold.md +33 -0
  24. package/src/commands/status.md +28 -0
  25. package/src/commands/surface-convert.md +35 -0
  26. package/src/commands/surface-create.md +34 -0
  27. package/src/commands/surface-list.md +27 -0
  28. package/src/commands/weekly-domain.md +34 -0
  29. package/src/commands/weekly.md +39 -0
  30. package/src/framework/context/base-principles.md +69 -0
  31. package/src/framework/frameworks/audit-strategies.md +53 -0
  32. package/src/framework/frameworks/claude-config-alignment.md +256 -0
  33. package/src/framework/frameworks/claudemd-strategy.md +158 -0
  34. package/src/framework/frameworks/satellite-registration.md +44 -0
  35. package/src/framework/tasks/audit-claude-md.md +171 -0
  36. package/src/framework/tasks/audit-claude.md +330 -0
  37. package/src/framework/tasks/audit.md +64 -0
  38. package/src/framework/tasks/carl-hygiene.md +142 -0
  39. package/src/framework/tasks/groom.md +157 -0
  40. package/src/framework/tasks/history.md +34 -0
  41. package/src/framework/tasks/pulse.md +83 -0
  42. package/src/framework/tasks/scaffold.md +389 -0
  43. package/src/framework/tasks/status.md +35 -0
  44. package/src/framework/tasks/surface-convert.md +143 -0
  45. package/src/framework/tasks/surface-create.md +184 -0
  46. package/src/framework/tasks/surface-list.md +42 -0
  47. package/src/framework/tasks/weekly-domain-create.md +173 -0
  48. package/src/framework/tasks/weekly.md +347 -0
  49. package/src/framework/templates/claudemd-template.md +102 -0
  50. package/src/framework/templates/workspace-json.md +96 -0
  51. package/src/framework/utils/scan-claude-dirs.py +549 -0
  52. package/src/hooks/_template.py +130 -0
  53. package/src/hooks/active-hook.py +178 -0
  54. package/src/hooks/apex-insights.py +169 -0
  55. package/src/hooks/backlog-hook.py +115 -0
  56. package/src/hooks/base-pulse-check.py +216 -0
  57. package/src/hooks/operator.py +53 -0
  58. package/src/hooks/psmm-injector.py +67 -0
  59. package/src/hooks/satellite-detection.py +320 -0
  60. package/src/packages/base-mcp/index.js +119 -0
  61. package/src/packages/base-mcp/package.json +10 -0
  62. package/src/packages/base-mcp/tools/entities.js +228 -0
  63. package/src/packages/base-mcp/tools/operator.js +106 -0
  64. package/src/packages/base-mcp/tools/projects.js +324 -0
  65. package/src/packages/base-mcp/tools/psmm.js +206 -0
  66. package/src/packages/base-mcp/tools/satellite.js +243 -0
  67. package/src/packages/base-mcp/tools/state.js +201 -0
  68. package/src/packages/base-mcp/tools/validate.js +121 -0
  69. package/src/skill/base.md +110 -0
  70. package/src/templates/operator.json +66 -0
  71. package/src/templates/workspace.json +76 -0
@@ -0,0 +1,330 @@
1
+ <purpose>
2
+ Audit all .qwen/ directories across a workspace. Discover sprawl, classify each item against the global/workspace/project hierarchy, plan remediation with operator approval at every step, and execute changes safely.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder with multiple projects in my workspace, I want all my .qwen/ directories audited for duplication, staleness, and misplacement, so that my Claude Code configuration is clean, consistent, and I know exactly what's project-specific vs what should be global.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - During BASE setup on an existing workspace with legacy projects
11
+ - Periodically as part of workspace optimization
12
+ - After installing global skills/hooks and wanting to clean up project copies
13
+ - When user says "audit my claude config", "clean up my .claude dirs", "check claude setup"
14
+ - Entry point routes here via /base:audit-claude
15
+ </when-to-use>
16
+
17
+ <framework>
18
+ @frameworks/claude-config-alignment.md
19
+ </framework>
20
+
21
+ <output-rules>
22
+ ALL audit findings MUST be written to a markdown report file at `.base/audits/claude-config-{YYYY-MM-DD}.md`.
23
+
24
+ Do NOT dump findings into the chat as inline text. The chat is for brief status updates, questions, and confirmations only. The report is where all detail lives.
25
+
26
+ The report must be:
27
+ - Written in clean markdown with tables, headers, and clear visual hierarchy
28
+ - Readable by a human who opens it in any markdown viewer
29
+ - Comprehensive: current state, classifications with evidence, remediation plan with risk levels, items kept and why
30
+
31
+ After writing the report, tell the operator: "Audit report written to `.base/audits/claude-config-{date}.md`. Review it, then tell me which remediation groups to execute."
32
+
33
+ During remediation execution, update the report with results (append a "Remediation Results" section).
34
+ </output-rules>
35
+
36
+ <steps>
37
+
38
+ <step name="scan" priority="first">
39
+ Run the scanner utility to produce a complete, verified dataset.
40
+
41
+ This step uses a deterministic Python script that scans the entire workspace and produces structured JSON. The script handles all data collection — baselines, directory discovery, file hashing, settings parsing. Claude does NOT gather this data manually.
42
+
43
+ **Run the scanner:**
44
+ ```
45
+ python3 ~/.qwen/base-framework/utils/scan-claude-dirs.py --workspace {workspace_root}
46
+ ```
47
+
48
+ The script outputs a JSON file to `.base/audits/data-sets/claude-scan-{date}.json` containing:
49
+ - **Baselines:** Complete inventory of global `~/.qwen/` and workspace root `.qwen/` (every file with MD5 hash)
50
+ - **MCP registry:** All server names from `.mcp.json`
51
+ - **Directories:** Every project-level `.qwen/` directory with full contents (hooks, commands, skills, rules, settings — all with MD5 hashes)
52
+ - **Summary:** Counts of hooks, commands, skills, settings files, nested dirs, empty dirs, templates
53
+
54
+ **Read the JSON output.** This is your single source of truth for all subsequent steps. Do not make ad-hoc bash calls to re-discover or re-hash files. If it's not in the scan data, re-run the scanner.
55
+
56
+ If the scanner fails, diagnose and fix before proceeding. Do not fall back to manual scanning.
57
+ </step>
58
+
59
+ <step name="classify">
60
+ Classify every item in every project-level .qwen/ directory.
61
+
62
+ **CRITICAL: Git boundary awareness.**
63
+
64
+ The scanner dataset includes `git_boundary` data for each directory. This tells you what each project actually sees when Claude Code boots there:
65
+
66
+ - `has_own_git: true` → This project has its own git root. It does NOT see the workspace root `.qwen/` or workspace `.mcp.json`. It only sees global `~/.qwen/` + its own `.qwen/`.
67
+ - `has_own_git: false` → This project inherits the workspace root. It sees global `~/.qwen/` + workspace root `.qwen/` + its own `.qwen/`.
68
+
69
+ **This changes what "duplicate" means.** If a project has its own git root and contains a hook that also exists in the workspace root `.qwen/`, that's not a duplicate running twice — the workspace root version is invisible to that project. Removing the local copy would leave the project with NO version of that hook.
70
+
71
+ For own-git projects, the right framing is:
72
+ - Does a current version exist in **global** `~/.qwen/`? If yes, the local copy is a true duplicate (global is always visible).
73
+ - Does a version only exist in **workspace root** `.qwen/`? Then the local copy is the project's ONLY access to that functionality. The right recommendation is to **promote to global** so all projects benefit, THEN clean up local copies.
74
+ - Is the local copy an outdated version of something in a baseline? It's DIVERGED — recommend updating to current or promoting current to global.
75
+
76
+ **Classification order:**
77
+
78
+ 1. **TEMPLATE** — In a template directory? Mark and skip.
79
+ 2. **ACCIDENTAL** — Nested .claude dirs, empty dirs.
80
+ 3. **DUPLICATE** — MD5 matches a baseline the project can ACTUALLY SEE:
81
+ - Global baseline: always checked (always visible)
82
+ - Workspace root baseline: only checked if `has_own_git: false`
83
+ - Match against visible baseline → DUPLICATE (safe to remove)
84
+ - Match against non-visible baseline → NOT a duplicate. See PROMOTE_TO_GLOBAL.
85
+ 4. **DIVERGED** — Same-named file exists in a visible baseline but MD5 differs.
86
+ 5. **PROMOTE_TO_GLOBAL** — Item exists in workspace root `.qwen/` (or same pattern across multiple projects) but NOT in global `~/.qwen/`. These are hooks/skills/commands the user wants everywhere but hasn't centralized. This is the most valuable finding — "put this in global and stop copying it into every project." When multiple projects have the same hook, that's strong evidence.
87
+ 6. **STALE** — References things that no longer exist:
88
+ - settings.json hooks pointing to missing files
89
+ - settings.local.json MCP servers not in registry (also check if MCP is even visible per git boundary)
90
+ - Files untouched for 60+ days in an inactive project
91
+ 7. **GLOBAL_CANDIDATE** — Exists only in one project, serves a user-level purpose, not in any baseline.
92
+ 8. **PROJECT_SPECIFIC** — Everything else that legitimately belongs in the project.
93
+
94
+ **Classification rules:**
95
+ - A file is DUPLICATE only if its MD5 matches a baseline the project can actually see
96
+ - A file matching a non-visible baseline is a signal that something should be promoted to global
97
+ - PROMOTE_TO_GLOBAL is the key recommendation for own-git projects with hooks/skills that mirror workspace root
98
+ - When multiple projects share the same hook, that's strong evidence it belongs in global
99
+ - When in doubt, check the hash (hashes don't lie) and the git_boundary data (assumptions lie)
100
+ </step>
101
+
102
+ <step name="settings_reconciliation">
103
+ Analyze settings.json and settings.local.json files specifically.
104
+
105
+ These are the most dangerous files because they control Claude Code behavior:
106
+
107
+ 1. For each project-level settings.json:
108
+ a. Parse hook definitions — list every hook command
109
+ b. For each hook, check: does this reference a local file? Does that file exist? Is it a duplicate?
110
+ c. Check if hook arrays are empty `[]` — this OVERRIDES global hooks with nothing
111
+ d. Compare hook list against global settings.json hooks — identify double-execution patterns
112
+ e. Check permissions — do they conflict with or duplicate global?
113
+
114
+ 2. For each project-level settings.local.json:
115
+ a. List every entry in enabledMcpjsonServers
116
+ b. Check each server name against MCP baseline — flag any that don't exist
117
+ c. Note enableAllProjectMcpServers boolean
118
+
119
+ 3. **Git-aware analysis** — For each project, use git_boundary data to determine:
120
+ - Which hooks are ACTUALLY running (global + project? or global + workspace root + project?)
121
+ - Is the project's `.mcp.json` visibility correct? (own-git projects can't see workspace .mcp.json)
122
+ - Would removing a local hook leave the project with NO version of that functionality?
123
+
124
+ 4. Build a "Settings Danger Report" section:
125
+ - Which projects have duplicate hooks running (only possible if project inherits workspace root)
126
+ - Which own-git projects rely on local hooks as their ONLY source of CARL/time/etc functionality
127
+ - Which settings.json files will have dangling references after hook files are removed
128
+ - Which settings.local.json files have stale MCP entries (or reference MCP servers they can't even see)
129
+ </step>
130
+
131
+ <step name="verify_classifications">
132
+ Self-audit: verify every classification is correct before writing the report.
133
+
134
+ This step exists because classification errors are the most damaging mistake this audit can make. A misclassified DUPLICATE that's actually PROJECT_SPECIFIC means deleting something the user needs.
135
+
136
+ **Verification checks:**
137
+
138
+ 1. **DUPLICATE verification** — For every item classified as DUPLICATE:
139
+ - Confirm the baseline file it supposedly duplicates actually exists
140
+ - Confirm the MD5 hashes actually match (re-check, don't trust prior step)
141
+ - Confirm the baseline version is the current/active version
142
+
143
+ 2. **GLOBAL_CANDIDATE verification** — For every item classified as GLOBAL_CANDIDATE:
144
+ - Search global baseline for any file with the same name (case-insensitive)
145
+ - Search workspace root baseline for any file with the same name
146
+ - Search for the same MD5 hash across all baselines (catches renamed copies)
147
+ - If found anywhere → reclassify as DUPLICATE
148
+
149
+ 3. **DIVERGED verification** — For every item classified as DIVERGED:
150
+ - Confirm both versions actually exist and differ
151
+ - Note which is newer (by file modification date)
152
+
153
+ 4. **STALE verification** — For every STALE settings entry:
154
+ - Confirm the referenced resource actually doesn't exist (not just renamed)
155
+ - Check both .mcp.json AND global settings for MCP servers
156
+
157
+ 5. **Completeness check** — Count total items classified vs total items discovered. If they don't match, something was missed. Find and classify the missing items.
158
+
159
+ 6. **Cross-reference check** — For items in the remediation plan that depend on each other (e.g., deleting a hook file + cleaning the settings.json that references it), verify both sides of the dependency are in the plan.
160
+
161
+ If any reclassifications happen in this step, update all downstream plan entries.
162
+ </step>
163
+
164
+ <step name="build_report">
165
+ Write the complete audit report to `.base/audits/claude-config-{YYYY-MM-DD}.md`.
166
+
167
+ Report structure:
168
+ 1. **MD5 disclaimer** — Always include this at the top, right after the metadata block, as a blockquote:
169
+ > *\* This audit uses MD5 fingerprinting to classify files. An MD5 hash is a unique fingerprint generated from a file's contents — if two files produce the same fingerprint, they are byte-for-byte identical. If the fingerprints differ, the files are different, even if they share the same name. This means every "DUPLICATE" classification in this report is provably exact, and every "DIVERGED" classification is provably different — not guessed, not assumed.*
170
+ 2. **Summary** — What's wrong, what's fine, item counts by classification
171
+ 2. **Baselines** — Brief description of what exists globally and at workspace root (so the reader understands what "duplicate of" means)
172
+ 3. **Findings by Directory** — Each project .qwen/ gets its own section with:
173
+ - Table of items: item path, classification, evidence (MD5 match, baseline reference)
174
+ - Last modified date
175
+ - Risk notes specific to that directory
176
+ 4. **Settings Reconciliation** — Dangerous patterns: duplicate hook execution, stale MCP refs, empty hook overrides
177
+ 5. **Remediation Plan** — Grouped by risk level (1-6), each item has:
178
+ - Item number
179
+ - Exact path
180
+ - Action (delete, clean, keep, promote)
181
+ - Why (with specific evidence)
182
+ - Dependencies (e.g., "after removing hook file, settings.json needs cleanup in Group 4")
183
+ 6. **Items Kept (No Action)** — What's staying and exactly why
184
+ 7. **Next Steps** — What the operator should do
185
+
186
+ Tell the operator: "Audit report written to `.base/audits/claude-config-{date}.md`. Review it, then we'll decide how to handle remediation."
187
+
188
+ **Wait for operator to review the report before proceeding to graduation routing.**
189
+ </step>
190
+
191
+ <step name="graduate_to_project">
192
+ Route remediation into a structured execution path. Present the operator with options.
193
+
194
+ **Display routing prompt:**
195
+ ```
196
+ ════════════════════════════════════════
197
+ AUDIT COMPLETE — REMEDIATION ROUTING
198
+ ════════════════════════════════════════
199
+
200
+ The audit report is ready at .base/audits/claude-config-{date}.md
201
+
202
+ How would you like to handle remediation?
203
+
204
+ [1] Create standalone PAUL project
205
+ → Initializes a new PAUL project seeded with audit findings
206
+ → Best for: large remediation, multiple phases, traceability needed
207
+
208
+ [2] Add milestone to existing PAUL project
209
+ → Adds a remediation milestone to a registered satellite
210
+ → Best for: audit is part of ongoing workspace optimization work
211
+
212
+ [3] Execute ad-hoc (legacy)
213
+ → Proceed with group-by-group remediation in this session
214
+ → Best for: small, straightforward cleanups
215
+
216
+ ════════════════════════════════════════
217
+ ```
218
+
219
+ **If option 1 (standalone PAUL project):**
220
+
221
+ 1. Ask: "Where should the project be created? (e.g., `projects/claude-audit-remediation`)"
222
+ 2. If user has no obvious location, suggest `projects/` as a convention
223
+ 3. Provide instructions:
224
+ ```
225
+ To proceed:
226
+ 1. mkdir -p {path}
227
+ 2. cd {path}
228
+ 3. Run /paul:init
229
+ 4. When defining scope, reference the audit report:
230
+ @.base/audits/claude-config-{date}.md
231
+
232
+ The audit report's Remediation Plan section maps directly
233
+ to PAUL phases — each remediation group can be a phase.
234
+ ```
235
+ 4. Do NOT auto-run /paul:init — the operator invokes it in the right context
236
+ 5. Exit this workflow (remediation happens through PAUL)
237
+
238
+ **If option 2 (add milestone to existing PAUL project):**
239
+
240
+ 1. Read `.base/workspace.json` for registered satellites:
241
+ ```
242
+ Read workspace.json → satellites array → list projects with paths and current status
243
+ ```
244
+ 2. Present registered projects:
245
+ ```
246
+ Registered PAUL projects:
247
+ [a] apps/base — v2.4 Config Governance (in progress)
248
+ [b] apps/casegate-v2 — v1.0 (if registered)
249
+ ...
250
+
251
+ Select a project, or provide a path:
252
+ ```
253
+ 3. After selection, provide instructions:
254
+ ```
255
+ To proceed:
256
+ 1. In the selected project, run /paul:milestone
257
+ 2. When defining scope, reference the audit report:
258
+ @.base/audits/claude-config-{date}.md
259
+
260
+ The audit report's Remediation Plan section provides
261
+ the scope — each remediation group maps to a phase.
262
+ ```
263
+ 4. Do NOT auto-run /paul:milestone
264
+ 5. Exit this workflow (remediation happens through PAUL)
265
+
266
+ **If option 3 (ad-hoc / legacy):**
267
+
268
+ Proceed directly to the execute_remediation step below. This preserves the original workflow behavior for operators who prefer immediate execution.
269
+
270
+ ```
271
+ Proceeding with ad-hoc remediation.
272
+ Tell me which groups to execute (or "approve all").
273
+ ```
274
+ </step>
275
+
276
+ <step name="execute_remediation">
277
+ Execute approved remediation items one group at a time.
278
+
279
+ For each approved group:
280
+ 1. Announce in chat: "Executing Group {N}: {description} ({count} items)"
281
+ 2. For each item:
282
+ a. Execute the change
283
+ b. If the change involves a settings.json modification, verify the JSON is still valid after edit
284
+ c. Brief confirmation in chat: "{path} — done"
285
+ 3. After each group completes:
286
+ a. Verify no broken references were created
287
+ b. Report in chat: "Group {N} complete. {count} items processed."
288
+ 4. If any item fails or produces an unexpected result, STOP and report to operator
289
+
290
+ **Between groups, pause and confirm: "Group {N} complete. Proceed to Group {N+1}?"**
291
+ </step>
292
+
293
+ <step name="post_remediation_verify">
294
+ Verify the workspace is healthy after all remediation and update the report.
295
+
296
+ 1. Re-scan every `.qwen/` directory that was modified
297
+ 2. For each modified directory verify:
298
+ - settings.json is valid JSON (if it was modified)
299
+ - No hook arrays reference files that don't exist
300
+ - No empty `.qwen/` directories left behind (unless intentional)
301
+ - No orphaned subdirectories (hooks/ dir with no hooks in it)
302
+ 3. Run a quick re-discovery scan to catch anything the remediation might have exposed
303
+ 4. Append a "Remediation Results" section to the audit report file:
304
+ - What was executed (by group)
305
+ - What was verified
306
+ - Any issues found during verification
307
+ - Projects the operator should test by opening Claude Code in them
308
+
309
+ Tell the operator: "Remediation complete. Report updated. Recommend testing Claude Code in: {list of modified projects}."
310
+ </step>
311
+
312
+ </steps>
313
+
314
+ <output>
315
+ Complete .qwen/ directory audit with inventory, classification, verified remediation, and post-remediation verification — all in a structured markdown report.
316
+ </output>
317
+
318
+ <acceptance-criteria>
319
+ - [ ] Three baselines built (global, workspace root, MCP registry) before any classification
320
+ - [ ] Every file hashed with MD5 — no classification without hash evidence
321
+ - [ ] Every item classified against ALL baselines, not just one
322
+ - [ ] Self-audit pass completed — all classifications verified, no GLOBAL_CANDIDATE that's actually a DUPLICATE
323
+ - [ ] Item count verified: classified items == discovered items (nothing missed)
324
+ - [ ] Settings files analyzed for dangerous patterns (empty hooks, stale MCP refs, double execution)
325
+ - [ ] Report written to .base/audits/ as structured markdown (not inline chat)
326
+ - [ ] Operator reviewed report and approved remediation before execution
327
+ - [ ] Changes executed one group at a time with verification between groups
328
+ - [ ] Post-remediation scan confirms no broken references or invalid JSON
329
+ - [ ] Report updated with remediation results
330
+ </acceptance-criteria>
@@ -0,0 +1,64 @@
1
+ <purpose>
2
+ Deep workspace optimization. Dynamically generate audit phases from the workspace manifest, run each area's configured audit strategy, and execute operator-approved changes.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder, I want a thorough workspace audit that adapts to my workspace structure, so that every area gets properly reviewed regardless of how complex my setup is.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - Quarterly or after major workspace shifts
11
+ - When user says "base audit", "deep clean", "optimize workspace"
12
+ - Entry point routes here via /base:audit
13
+ </when-to-use>
14
+
15
+ <steps>
16
+
17
+ <step name="generate_phases" priority="first">
18
+ Read workspace manifest and generate audit phases dynamically.
19
+
20
+ 1. Read `.base/workspace.json`
21
+ 2. For each area, create an audit phase using its configured strategy
22
+ 3. Present phase list: "Audit will cover {N} phases: {list with strategies}"
23
+ 4. Create task tracking for each phase
24
+
25
+ **Wait for operator confirmation. Allow them to skip or reorder phases.**
26
+ </step>
27
+
28
+ <step name="execute_phases">
29
+ Run each phase using its configured audit strategy.
30
+
31
+ For each phase:
32
+ 1. Announce: "Phase {N}: {area-name} ({strategy})"
33
+ 2. Execute the strategy (reference frameworks/audit-strategies.md)
34
+ 3. Present findings
35
+ 4. Collect operator decisions (keep/archive/delete/move)
36
+ 5. Execute approved changes
37
+ 6. Mark phase complete
38
+
39
+ Strategies are documented in `@frameworks/audit-strategies.md`.
40
+ </step>
41
+
42
+ <step name="record_audit">
43
+ Record the audit results.
44
+
45
+ 1. Update `.base/data/state.json`
46
+ 2. Write audit record to `.base/audits/{YYYY-MM-DD}.md`
47
+ 3. Log to `.base/ROADMAP.md`
48
+ 4. Report final summary: phases completed, items changed, new drift score
49
+ </step>
50
+
51
+ </steps>
52
+
53
+ <output>
54
+ Complete workspace audit with dynamic phases. All areas reviewed, changes executed, audit recorded.
55
+ </output>
56
+
57
+ <acceptance-criteria>
58
+ - [ ] Phases generated dynamically from manifest (not hardcoded)
59
+ - [ ] Each area audited using its configured strategy
60
+ - [ ] Operator approved all changes before execution
61
+ - [ ] Audit record written to audits/ directory
62
+ - [ ] state.json updated
63
+ - [ ] ROADMAP.md updated with audit entry
64
+ </acceptance-criteria>
@@ -0,0 +1,142 @@
1
+ <purpose>
2
+ Structured CARL domain maintenance. Review staged proposals, flag stale rules, audit domain health, and keep CARL lean and accurate. All operations target carl.json as the single source of truth.
3
+ </purpose>
4
+
5
+ <user-story>
6
+ As an AI builder, I want a guided CARL maintenance session, so that my domain rules stay relevant, staged proposals get decided on, and CARL doesn't become a dumping ground of stale rules.
7
+ </user-story>
8
+
9
+ <when-to-use>
10
+ - Monthly (on configured cadence)
11
+ - When pulse reports overdue CARL hygiene
12
+ - When user says "carl hygiene", "review carl rules", "clean up carl"
13
+ - Entry point routes here via /base:carl-hygiene
14
+ </when-to-use>
15
+
16
+ <steps>
17
+
18
+ <step name="assess" priority="first">
19
+ Gather CARL health data and present summary.
20
+
21
+ 1. Read `.base/workspace.json` for `carl_hygiene` config (threshold, max rules, last run)
22
+ 2. Use `carl_v2_list_domains` to get all domains with rule/decision counts and state
23
+ 3. Use `carl_v2_get_staged` to check for pending staging proposals
24
+ 4. For each active domain from `carl_v2_list_domains`:
25
+ - Note rule count and decision count
26
+ - Use `carl_v2_get_domain(domain)` to inspect rule `last_reviewed` fields
27
+ - Flag rules where `last_reviewed` is null or older than `staleness_threshold_days`
28
+ - Flag domains exceeding `max_rules_per_domain`
29
+ 5. Present summary:
30
+ ```
31
+ CARL Hygiene Assessment
32
+ ━━━━━━━━━━━━━━━━━━━━━━
33
+ Staged proposals: {N} pending
34
+ Domains: {N} total ({N} active, {N} inactive), {N} with stale rules, {N} over max
35
+ Total rules: {N} across all domains
36
+ Total decisions: {N} ({N} active, {N} archived)
37
+ Last hygiene: {date or "never"}
38
+ ```
39
+
40
+ **Wait for operator confirmation before proceeding.**
41
+ </step>
42
+
43
+ <step name="review_proposals">
44
+ Process each pending staged proposal.
45
+
46
+ Use `carl_v2_get_staged` to retrieve all proposals. For each with `status: "pending"`:
47
+ 1. Present:
48
+ ```
49
+ Proposal {id} — {proposed_domain}
50
+ Proposed: {created_at} | Source: {source_session or "manual"}
51
+ Rule: "{rule_text}"
52
+ Rationale: {rationale}
53
+ ```
54
+ 2. Ask: "**Approve**, **Kill**, or **Defer**?"
55
+ 3. Execute:
56
+ - Approve → `carl_v2_approve_proposal(id)` — promotes to domain rule with `source: "staging"`, removes from staging
57
+ - Kill → Read `.carl/carl.json`, remove the proposal entry from the `staging` array, write back
58
+ - Defer → skip (stays pending for next hygiene)
59
+
60
+ If no pending proposals: "No staged proposals to review." and move to next step.
61
+
62
+ Process one proposal at a time. Wait for response between each.
63
+ </step>
64
+
65
+ <step name="review_stale_rules">
66
+ Review rules flagged as stale (last_reviewed is null or older than threshold).
67
+
68
+ For each domain with stale rules (identified in assess step):
69
+ 1. Present domain name and total rule count
70
+ 2. For each stale rule:
71
+ ```
72
+ [{DOMAIN}] Rule {id} — last reviewed {date or "never"} ({days} days ago)
73
+ "{text}"
74
+ ```
75
+ 3. Ask: "**Keep** (update reviewed date), or **Kill**?"
76
+ 4. Execute:
77
+ - Keep → Use `carl_v2_replace_rules(domain, rules)` with updated `last_reviewed` set to today's date for kept rules
78
+ - Kill → Use `carl_v2_remove_rule(domain, rule_id)` (with "Are you sure?" confirmation)
79
+
80
+ If no stale rules: "All rules are current. No staleness issues." and move to next step.
81
+
82
+ Process one domain at a time.
83
+ </step>
84
+
85
+ <step name="review_domains">
86
+ Quick domain health check — guided Q&A.
87
+
88
+ 1. List all domains (active and inactive) with rule counts from `carl_v2_list_domains`
89
+ 2. For each active domain:
90
+ - "Do the recall phrases for **{domain}** still match how you talk about this work?"
91
+ - Show current recall keywords for reference
92
+ 3. Check for domains over `max_rules_per_domain`:
93
+ - "Domain **{X}** has {N} rules (max: {max}). Any candidates to kill or consolidate?"
94
+ 4. Check for inactive domains: "These domains are inactive: {list}. Reactivate or remove any?"
95
+ 5. Ask: "Any new domains to create? Any to deactivate?"
96
+
97
+ **Guided Q&A — don't force changes, just surface questions.**
98
+ </step>
99
+
100
+ <step name="review_decisions">
101
+ Quick check on per-domain decision health.
102
+
103
+ For each domain that has decisions (from `carl_v2_get_domain`):
104
+ 1. List decisions with date and status
105
+ 2. Flag decisions older than 90 days (might be outdated)
106
+ 3. Flag domains with 0 decisions that might benefit from decision logging
107
+ 4. Ask: "Any decisions to archive?" → use `carl_v2_archive_decision(id)` if yes
108
+
109
+ **Brief pass — decisions are mostly self-maintaining.**
110
+ </step>
111
+
112
+ <step name="log">
113
+ Record the hygiene session.
114
+
115
+ 1. Update `.base/workspace.json` → `carl_hygiene.last_run` to today's date
116
+ 2. Update `.base/data/state.json` → note CARL hygiene completed with timestamp
117
+ 3. Report:
118
+ ```
119
+ CARL Hygiene Complete
120
+ ━━━━━━━━━━━━━━━━━━━━━
121
+ Proposals: {N} processed ({N} approved, {N} killed, {N} deferred)
122
+ Rules reviewed: {N} ({N} kept, {N} killed)
123
+ Decisions reviewed: {N} ({N} archived)
124
+ Domains: {N} active, {N} inactive
125
+ Next hygiene due: {date based on cadence}
126
+ ```
127
+ </step>
128
+
129
+ </steps>
130
+
131
+ <output>
132
+ CARL domains reviewed and maintained. Staged proposals decided. Stale rules addressed. Domain health verified. Hygiene session logged to workspace.json.
133
+ </output>
134
+
135
+ <acceptance-criteria>
136
+ - [ ] All pending proposals presented and decided (approve/kill/defer)
137
+ - [ ] Stale rules flagged and reviewed with operator
138
+ - [ ] Domain health check completed (rule counts, recall phrases)
139
+ - [ ] workspace.json carl_hygiene.last_run updated
140
+ - [ ] state.json updated with hygiene completion
141
+ - [ ] Operator confirmed completion of each step
142
+ </acceptance-criteria>