@jaggerxtrm/specialists 3.10.0 → 3.13.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 (104) hide show
  1. package/README.md +3 -0
  2. package/config/hooks/specialists-session-start.mjs +33 -1
  3. package/config/mandatory-rules/bead-id-verbatim.md +14 -0
  4. package/config/mandatory-rules/changelog-conventions.md +21 -0
  5. package/config/mandatory-rules/changelog-keeper-scope.md +50 -0
  6. package/config/mandatory-rules/gitnexus-required.md +6 -1
  7. package/config/mandatory-rules/per-turn-handoff-schema.md +16 -0
  8. package/config/mandatory-rules/sync-docs-scope-discipline.md +40 -0
  9. package/config/skills/releasing/SKILL.md +82 -0
  10. package/config/skills/specialists-creator/SKILL.md +100 -10
  11. package/config/skills/specialists-creator/scripts/validate-specialist.ts +1 -1
  12. package/config/skills/update-specialists/SKILL.md +192 -325
  13. package/config/skills/using-kpi/SKILL.md +236 -0
  14. package/config/skills/using-script-specialists/SKILL.md +208 -0
  15. package/config/skills/using-specialists-v2/SKILL.md +162 -28
  16. package/config/skills/using-specialists-v3/SKILL.md +562 -0
  17. package/config/skills/using-specialists-v3/evals/evals.json +89 -0
  18. package/config/specialists/changelog-drafter.specialist.json +62 -0
  19. package/config/specialists/changelog-keeper.specialist.json +80 -0
  20. package/config/specialists/code-sanity.specialist.json +108 -0
  21. package/config/specialists/debugger.specialist.json +7 -5
  22. package/config/specialists/executor.specialist.json +7 -5
  23. package/config/specialists/explorer.specialist.json +16 -5
  24. package/config/specialists/memory-processor.specialist.json +4 -4
  25. package/config/specialists/node-coordinator.specialist.json +3 -3
  26. package/config/specialists/overthinker.specialist.json +5 -4
  27. package/config/specialists/planner.specialist.json +7 -5
  28. package/config/specialists/researcher.specialist.json +5 -4
  29. package/config/specialists/reviewer.specialist.json +7 -5
  30. package/config/specialists/security-auditor.specialist.json +111 -0
  31. package/config/specialists/specialists-creator.specialist.json +6 -5
  32. package/config/specialists/sync-docs.specialist.json +18 -19
  33. package/config/specialists/test-runner.specialist.json +5 -4
  34. package/config/specialists/xt-merge.specialist.json +4 -4
  35. package/dist/index.js +3379 -1168
  36. package/dist/lib.js +518 -154
  37. package/dist/types/cli/clean.d.ts.map +1 -1
  38. package/dist/types/cli/config.d.ts.map +1 -1
  39. package/dist/types/cli/db.d.ts.map +1 -1
  40. package/dist/types/cli/doctor.d.ts.map +1 -1
  41. package/dist/types/cli/feed.d.ts.map +1 -1
  42. package/dist/types/cli/help.d.ts.map +1 -1
  43. package/dist/types/cli/init.d.ts.map +1 -1
  44. package/dist/types/cli/list.d.ts +4 -0
  45. package/dist/types/cli/list.d.ts.map +1 -1
  46. package/dist/types/cli/merge.d.ts +4 -2
  47. package/dist/types/cli/merge.d.ts.map +1 -1
  48. package/dist/types/cli/node.d.ts.map +1 -1
  49. package/dist/types/cli/prune-stale-defaults.d.ts +2 -0
  50. package/dist/types/cli/prune-stale-defaults.d.ts.map +1 -0
  51. package/dist/types/cli/ps.d.ts.map +1 -1
  52. package/dist/types/cli/result.d.ts.map +1 -1
  53. package/dist/types/cli/run.d.ts.map +1 -1
  54. package/dist/types/cli/script.d.ts.map +1 -1
  55. package/dist/types/cli/serve-hot-reload.d.ts +13 -0
  56. package/dist/types/cli/serve-hot-reload.d.ts.map +1 -0
  57. package/dist/types/cli/serve.d.ts +28 -0
  58. package/dist/types/cli/serve.d.ts.map +1 -1
  59. package/dist/types/cli/status.d.ts.map +1 -1
  60. package/dist/types/cli/stop.d.ts.map +1 -1
  61. package/dist/types/cli/version-check.d.ts +20 -0
  62. package/dist/types/cli/version-check.d.ts.map +1 -0
  63. package/dist/types/index.d.ts +1 -1
  64. package/dist/types/pi/session.d.ts +10 -0
  65. package/dist/types/pi/session.d.ts.map +1 -1
  66. package/dist/types/specialist/canonical-asset-resolver.d.ts +6 -0
  67. package/dist/types/specialist/canonical-asset-resolver.d.ts.map +1 -0
  68. package/dist/types/specialist/drift-detector.d.ts +39 -0
  69. package/dist/types/specialist/drift-detector.d.ts.map +1 -0
  70. package/dist/types/specialist/epic-lifecycle.d.ts.map +1 -1
  71. package/dist/types/specialist/epic-readiness.d.ts.map +1 -1
  72. package/dist/types/specialist/epic-reconciler.d.ts.map +1 -1
  73. package/dist/types/specialist/loader.d.ts +2 -1
  74. package/dist/types/specialist/loader.d.ts.map +1 -1
  75. package/dist/types/specialist/mandatory-rules.d.ts +5 -0
  76. package/dist/types/specialist/mandatory-rules.d.ts.map +1 -1
  77. package/dist/types/specialist/manifest-resolver.d.ts +55 -0
  78. package/dist/types/specialist/manifest-resolver.d.ts.map +1 -0
  79. package/dist/types/specialist/node-contract.d.ts +2 -2
  80. package/dist/types/specialist/observability-sqlite.d.ts +43 -0
  81. package/dist/types/specialist/observability-sqlite.d.ts.map +1 -1
  82. package/dist/types/specialist/payload-measure.d.ts +19 -0
  83. package/dist/types/specialist/payload-measure.d.ts.map +1 -0
  84. package/dist/types/specialist/porcelain-parser.d.ts +2 -0
  85. package/dist/types/specialist/porcelain-parser.d.ts.map +1 -0
  86. package/dist/types/specialist/resolution-diagnostics.d.ts +36 -0
  87. package/dist/types/specialist/resolution-diagnostics.d.ts.map +1 -0
  88. package/dist/types/specialist/runner.d.ts +8 -0
  89. package/dist/types/specialist/runner.d.ts.map +1 -1
  90. package/dist/types/specialist/schema.d.ts +27 -0
  91. package/dist/types/specialist/schema.d.ts.map +1 -1
  92. package/dist/types/specialist/script-runner.d.ts +44 -1
  93. package/dist/types/specialist/script-runner.d.ts.map +1 -1
  94. package/dist/types/specialist/supervisor.d.ts +4 -0
  95. package/dist/types/specialist/supervisor.d.ts.map +1 -1
  96. package/dist/types/specialist/timeline-events.d.ts +29 -1
  97. package/dist/types/specialist/timeline-events.d.ts.map +1 -1
  98. package/dist/types/specialist/timeline-query.d.ts.map +1 -1
  99. package/dist/types/specialist/tool-catalog.d.ts +126 -0
  100. package/dist/types/specialist/tool-catalog.d.ts.map +1 -0
  101. package/dist/types/tools/specialist/feed_specialist.tool.d.ts +2 -2
  102. package/dist/types/tools/specialist/use_specialist.tool.d.ts.map +1 -1
  103. package/package.json +4 -4
  104. package/config/specialists/.serena/project.yml +0 -151
@@ -1,414 +1,281 @@
1
1
  ---
2
2
  name: update-specialists
3
3
  description: >
4
- Reconcile a project with current canonical specialists install state.
5
- Use this skill when a user says "update specialists", "specialists is broken",
6
- "sp is out of date", "hooks not firing", "skills not loading after update",
7
- or when drift is detected in installed specialists config, hooks, jobs, DB,
8
- extensions, or worktree cleanup.
9
- version: 1.3
10
- synced_at: 2026-04-25
4
+ Reconcile specialists runtime drift and xtrm-managed asset drift across one repo or many.
5
+ Use this skill when user says "update specialists", "specialists is out of date",
6
+ "xtrm drift", "skills not updating", "assets out of date", or when operator needs
7
+ guided refresh of specialists/xtrm state.
8
+ version: 2.1
9
+ synced_at: 2026-05-05
11
10
  ---
12
11
 
13
12
  # update-specialists
14
13
 
15
- Bring specialists install back to canonical state. Detect drift, apply targeted
16
- fixes, then verify with `sp doctor`. Treat canonical state as both:
17
- 1. healthy repo wiring and runtime behavior, and
18
- 2. parity with currently installed `@jaggerxtrm/specialists` package version
19
- when package-level comparison is available.
20
-
21
- Ownership contract during repair:
22
- - upstream source: package `config/*` (read-only for repo operators)
23
- - managed mirror: `.specialists/default/*` (refresh via `sp init --sync-defaults`; sync scope = specialists + mandatory-rules + nodes; no hand edits)
24
- - repo custom layer: `.specialists/user/*` + `config/nodes/*` + `.specialists/mandatory-rules/*` (rule overlay, wins on set-id conflict; NOT drift — do not overwrite or flag)
25
- - runtime/generated: `.specialists/{jobs,ready,db}`
26
-
27
- Isolation rule: backlog-clean surfaces out of scope for this skill.
28
-
29
- ## Canonical State
30
-
31
- Check each item explicitly. This is what a healthy specialists-initialized project
32
- looks like.
33
-
34
- ### Package + runtime parity
35
-
36
- | Check | Expected value |
37
- |-------|----------------|
38
- | Installed `@jaggerxtrm/specialists` package version | Matches intended runtime version for repo install |
39
- | `sp --version` / `specialists --version` | Matches installed package version or same release line |
40
- | Installed package root | Resolvable from Node / npm environment |
41
- | Canonical package defaults | Available from installed package for direct diffing |
42
- | Repo install vs package install | No unexpected drift in canonical files unless intentionally customized |
43
-
44
- ### Specialists configs
45
-
46
- | Check | Expected value |
47
- |-------|----------------|
48
- | `.specialists/default/*.specialist.json` | JSON-first specialist configs present |
49
- | `metadata.name` | Matches filename stem |
50
- | `metadata.version` | Valid semver string and consistent with canonical shipped copy when comparing like-for-like |
51
- | `metadata.description` | Present |
52
- | `metadata.category` | Present |
53
- | `execution.model` | Present and pingable |
54
- | `execution.fallback_model` | Present, different provider from primary |
55
- | `execution.permission_required` | Valid enum |
56
- | `skills.paths` | Referenced skill paths resolve correctly |
57
- | `execution.interactive` | Matches intended keep-alive behavior |
58
- | Installed default specialist copy | Matches canonical package copy unless intentionally customized |
59
-
60
- ### Hooks wiring
61
-
62
- | Check | Expected value |
63
- |-------|----------------|
64
- | `.claude/settings.json` | Has hook entries for active events |
65
- | Hook events | At minimum: `SessionStart`, `PreToolUse`, `PostToolUse`, `Stop` |
66
- | Hook paths | Point at specialists runtime hook scripts, not stale xtrm-only paths |
67
- | Hook format | Matches project's installed settings format and loads cleanly |
68
- | Installed hook scripts | Match canonical package hook files unless intentionally customized |
69
-
70
- ### CLI reachability
71
-
72
- | Check | Expected value |
73
- |-------|----------------|
74
- | `sp` command | On PATH and runs |
75
- | `specialists` command | On PATH and runs |
76
- | Version compatibility | `sp doctor` reports matching runtime / install state |
77
- | Command surface | `sp doctor`, `sp init`, `sp clean`, `sp status` available |
78
-
79
- ### Jobs and runtime dirs
80
-
81
- | Check | Expected value |
82
- |-------|----------------|
83
- | `.specialists/jobs/` | Exists |
84
- | `.specialists/ready/` | Exists if used by runtime |
85
- | `.specialists/default/` | Canonical install copy present |
86
- | Orphaned worktrees | None under `.worktrees/` |
87
- | Worktree ownership | No stale entries for deleted jobs |
88
-
89
- ### SQLite / observability
90
-
91
- | Check | Expected value |
92
- |-------|----------------|
93
- | specialists DB | Opens cleanly (`.specialists/db/observability.db`) |
94
- | Schema version | Matches runtime expectation (current: v11) |
95
- | `specialist_job_metrics` table | Present at v11+ — holds aggregated per-job metrics |
96
- | WAL / busy timeout settings | Present when runtime uses SQLite |
97
- | Corruption / lock errors | None in `sp doctor` |
98
- | Pre-prune extract | `sp db prune --apply` extracts metrics to `specialist_job_metrics` before deleting events |
99
- | Extract backfill | `sp db extract --all-missing` populates metrics for jobs whose events still exist |
100
- | Historical stats query | `sp db stats [--spec <name>] [--model <glob>] [--since <dur>]` reads the aggregated table |
101
-
102
- ### Skills + extensions parity
103
-
104
- | Check | Expected value |
105
- |-------|----------------|
106
- | `.xtrm/skills/default/` | Matches canonical package skill set for installed version |
107
- | Active skill links / copies | Resolve to expected default or active targets |
108
- | Skill frontmatter `version` / `synced_at` | Present and reasonable for shipped skills |
109
- | `quality-gates` | Registered if project uses quality gates |
110
- | `pi-gitnexus` | Registered when GitNexus integration is expected |
111
- | `pi-serena-tools` | Registered when Serena integration is expected |
112
- | Extension paths | Resolve from installed project, not stale workspace copies |
113
-
114
- ### Mandatory-rules template parity (three-tier)
115
-
116
- Loader unions indexes from three paths and probes set files in reverse precedence
117
- (overlay wins on set-id conflict). Full authoring guide:
118
- `config/mandatory-rules/README.md`.
119
-
120
- | Check | Expected value |
121
- |-------|----------------|
122
- | `.specialists/default/mandatory-rules/*` | Mirrors canonical package templates after `sp init --sync-defaults` (managed mirror, no hand edits) |
123
- | `.specialists/mandatory-rules/*` | Repo-specific overlay (user-maintained). Present when repo ships its own rules. NOT drift. |
124
- | Template frontmatter | YAML frontmatter present and parseable |
125
- | `specialist.mandatory_rules.template_sets` references | Resolve in order: `.specialists/mandatory-rules/` → `.specialists/default/mandatory-rules/` → `config/mandatory-rules/` |
126
- | Index files (`index.json`) | Any of the three tiers may define `required_template_sets` / `default_template_sets`; loader unions + dedups |
127
- | Prompt injection behavior | Runner appends resolved `MANDATORY_RULES` block at end of prompt; supervisor emits `mandatory_rules_injection` meta event |
128
-
129
- ## Detection
130
-
131
- Run these in order. Report which checks pass and which drift.
14
+ Interactive operator workflow for the two distribution tracks:
132
15
 
133
- ```bash
134
- # 1. Primary health check
135
- sp doctor
16
+ - **Category A — specialists runtime / npm-live assets**
17
+ - specialist definitions
18
+ - mandatory rules
19
+ - tool catalogs
20
+ - node configs
21
+ - resolved by `sp` from the installed `@jaggerxtrm/specialists` package unless a repo intentionally overrides them
22
+ - **Category B — xtrm-managed filesystem assets**
23
+ - skills under `.xtrm/skills/default/`
24
+ - hooks under `.xtrm/hooks/default/`
25
+ - active `.claude/skills`, `.pi/skills`, hook settings, and related registry-managed files
26
+ - refreshed by `xt update`
136
27
 
137
- # 2. Runtime status
138
- sp status
28
+ Do not collapse these flows. Category A is specialists-owned and uses `sp` commands. Category B is xtrm-owned and uses `xt` commands.
139
29
 
140
- # 3. Installed package + CLI version parity
141
- npm ls @jaggerxtrm/specialists --depth=0 2>/dev/null || true
142
- node -e "try { const pkg=require(require.resolve('@jaggerxtrm/specialists/package.json')); console.log(JSON.stringify({installed_package_version: pkg.version}, null, 2)); } catch (err) { console.log('PACKAGE_NOT_RESOLVABLE'); }"
143
- sp --version 2>/dev/null || true
144
- specialists --version 2>/dev/null || true
30
+ No automatic destructive execution. Always summarize first and ask before applying refresh/prune actions.
145
31
 
146
- # 4. Resolve canonical package root for direct drift diff
147
- node -e "try { const path=require('path'); const pkgPath=require.resolve('@jaggerxtrm/specialists/package.json'); console.log(path.dirname(pkgPath)); } catch (err) { console.log('PACKAGE_ROOT_UNAVAILABLE'); }"
32
+ ## Quick Decision Tree
148
33
 
149
- # 5. Config shape
150
- find .specialists/default -maxdepth 1 -name '*.specialist.json' -print
34
+ 1. User says **specialist configs/rules/catalog/node behavior is stale** → run Category A flow.
35
+ 2. User says **skills/hooks/Claude/Pi active files are stale** → run Category B flow.
36
+ 3. User says **update specialists** with no detail → run both diagnostics, then present a combined plan.
37
+ 4. User is in many repos → use root discovery and group results by repo.
38
+ 5. `xt` missing → Category A can still run; Category B falls back to install/update guidance.
39
+ 6. `sp` missing → tell user to install/upgrade `@jaggerxtrm/specialists`; do not claim runtime drift is fixed.
151
40
 
152
- # 6. Validate specialist JSON files
153
- node -e "const fs=require('fs'); const path=require('path'); const dir='.specialists/default'; for (const file of fs.readdirSync(dir)) { if (!file.endsWith('.specialist.json')) continue; const s=JSON.parse(fs.readFileSync(path.join(dir,file),'utf8')); const m=s.metadata||{}; const e=s.execution||{}; const missing=[]; for (const key of ['name','version','description','category']) if (!m[key]) missing.push('metadata.'+key); for (const key of ['model','fallback_model','permission_required']) if (!e[key]) missing.push('execution.'+key); if (missing.length) console.log(file+': MISSING '+missing.join(', ')); if (m.name && m.name !== file.replace(/\.specialist\.json$/, '')) console.log(file+': NAME MISMATCH '+m.name); }"
41
+ ## Category A Specialists Runtime / npm-live Flow
154
42
 
155
- # 7. Validate referenced skill paths
156
- node -e "const fs=require('fs'); const path=require('path'); const dir='.specialists/default'; for (const file of fs.readdirSync(dir)) { if (!file.endsWith('.specialist.json')) continue; const s=JSON.parse(fs.readFileSync(path.join(dir,file),'utf8')); for (const p of (s.skills?.paths ?? [])) { if (!fs.existsSync(p)) console.log(file+': MISSING SKILL PATH '+p); } }"
43
+ ### A1) Verify package and command surface
157
44
 
158
- # 8. Compare repo defaults against installed package defaults (if package root resolvable)
159
- PKG_ROOT="$(node -e "try { const path=require('path'); process.stdout.write(path.dirname(require.resolve('@jaggerxtrm/specialists/package.json'))); } catch (err) {}")"
160
- if [ -n "$PKG_ROOT" ]; then
161
- diff -rq .specialists/default "$PKG_ROOT/config/specialists" || true
162
- diff -rq .xtrm/skills/default "$PKG_ROOT/config/skills" || true
163
- diff -rq .claude/hooks "$PKG_ROOT/config/hooks" || true
164
- else
165
- echo PACKAGE_COMPARE_UNAVAILABLE
166
- fi
45
+ Run in the target repo:
167
46
 
168
- # 9. Hooks wiring
169
- node -e "const fs=require('fs'); const p='.claude/settings.json'; if (fs.existsSync(p)) { const s=JSON.parse(fs.readFileSync(p,'utf8')); console.log(JSON.stringify(s.hooks ?? s, null, 2)); } else { console.log('MISSING .claude/settings.json'); }"
47
+ ```bash
48
+ sp --version
49
+ sp doctor
50
+ sp doctor --check-drift
51
+ ```
52
+
53
+ Use `specialists` instead of `sp` if the alias is unavailable.
54
+
55
+ Category A canonical source is the installed `@jaggerxtrm/specialists` npm package. To update it, upgrade/pin the package version:
56
+
57
+ ```bash
58
+ npm install -g @jaggerxtrm/specialists@latest
59
+ # or project-local/package-managed pin, depending on repo policy
60
+ npm install -D @jaggerxtrm/specialists@<version>
61
+ ```
170
62
 
171
- # 10. Command availability
172
- command -v sp
173
- command -v specialists
174
- specialists init --help | sed -n '1,120p'
175
- specialists edit --help | sed -n '1,120p' | grep -E -- '--fork-from|fork-from' || true
176
- sp doctor --json 2>/dev/null || true
63
+ Report the installed version and whether the repo is intentionally pinned.
177
64
 
178
- # 11. Jobs and worktrees
179
- ls -1 .specialists/jobs 2>/dev/null || true
180
- find .worktrees -maxdepth 2 -mindepth 1 -type d 2>/dev/null || true
65
+ ### A2) Interpret `sp doctor --check-drift`
181
66
 
182
- # 12. Extension registration
183
- node -e "const fs=require('fs'); const p='.pi/settings.json'; if (fs.existsSync(p)) console.log(JSON.stringify(JSON.parse(fs.readFileSync(p,'utf8')).skills ?? JSON.parse(fs.readFileSync(p,'utf8')).extensions ?? {}, null, 2)); else console.log('MISSING .pi/settings.json')"
67
+ This checks stale `.specialists/default/` snapshots against package-canonical assets.
184
68
 
185
- # 13a. Observability schema + metrics coverage
186
- node -e "const {Database} = require('bun:sqlite'); const p='.specialists/db/observability.db'; const fs=require('fs'); if (!fs.existsSync(p)) { console.log('NO_DB'); process.exit(0); } const db=new Database(p,{readonly:true}); const v=db.query(\"SELECT value FROM schema_meta WHERE key='version'\").get(); const has=db.query(\"SELECT name FROM sqlite_master WHERE type='table' AND name='specialist_job_metrics'\").get(); const jobs=db.query('SELECT COUNT(*) c FROM specialist_jobs').get(); const metrics=has ? db.query('SELECT COUNT(*) c FROM specialist_job_metrics').get() : null; console.log(JSON.stringify({schema_version: v?.value, has_metrics_table: !!has, jobs: jobs.c, metrics_rows: metrics?.c ?? 0, metrics_coverage: metrics ? (metrics.c/jobs.c).toFixed(2) : null}, null, 2));" 2>/dev/null || echo "REQUIRES_BUN_RUNTIME"
69
+ Typical statuses:
187
70
 
188
- # 13. Mandatory-rules template tiers + reference checks (three-tier resolution)
189
- find .specialists/default/mandatory-rules -maxdepth 1 -type f 2>/dev/null || true
190
- find .specialists/mandatory-rules -maxdepth 1 -type f 2>/dev/null || true
191
- node -e "const fs=require('fs'); const path=require('path'); const roots=['.specialists/default/specialists','.specialists/user/specialists']; const missing=[]; for (const root of roots) { if (!fs.existsSync(root)) continue; for (const file of fs.readdirSync(root)) { if (!file.endsWith('.specialist.json')) continue; const spec=JSON.parse(fs.readFileSync(path.join(root,file),'utf8')); const sets=spec.specialist?.mandatory_rules?.template_sets ?? []; for (const set of sets) { const candidates=[path.join('.specialists/mandatory-rules',set+'.md'), path.join('.specialists/default/mandatory-rules',set+'.md'), path.join('config/mandatory-rules',set+'.md')]; if (!candidates.some((p)=>fs.existsSync(p))) missing.push(file+': missing template set '+set); } } } if (missing.length) console.log(missing.join('\n'));"
71
+ | Finding | Meaning | Action |
72
+ |---|---|---|
73
+ | redundant / byte-identical default | Local default snapshot duplicates package canonical | Safe to prune after review |
74
+ | diverged default | Local default differs from package canonical | Treat as intentional until operator confirms migration |
75
+ | missing package canonical | Installed package or registry is incomplete/stale | Upgrade/reinstall specialists package |
76
+ | user overlay | `.specialists/user/` custom asset | Preserve; never overwrite automatically |
192
77
 
193
- # 14. Shipped skill frontmatter parity
194
- node -e "const fs=require('fs'); const path=require('path'); const dir='.xtrm/skills/default'; if (!fs.existsSync(dir)) process.exit(0); for (const name of fs.readdirSync(dir)) { const p=path.join(dir,name,'SKILL.md'); if (!fs.existsSync(p)) continue; const head=fs.readFileSync(p,'utf8').split('---')[1] || ''; const version=(head.match(/version:\s*([^\n]+)/)||[])[1]; const synced=(head.match(/synced_at:\s*([^\n]+)/)||[])[1]; console.log(name+': version='+(version||'missing')+' synced_at='+(synced||'missing')); }"
78
+ ### A3) Prune redundant Category A snapshots
79
+
80
+ Dry-run first:
81
+
82
+ ```bash
83
+ sp prune-stale-defaults --dry-run
84
+ sp prune-stale-defaults --root <repo>
195
85
  ```
196
86
 
197
- ## Drift -> Fix Mapping
198
-
199
- Use targeted fixes first. Escalate to full sync only if needed.
200
-
201
- | Drift | Fix |
202
- |-------|-----|
203
- | Installed package version mismatch | reinstall / upgrade `@jaggerxtrm/specialists`, then re-run checks |
204
- | CLI version mismatch vs package | reinstall runtime so `sp` / `specialists` align with installed package |
205
- | Specialist JSON missing required fields | `sp edit <name> ...` or regenerate via `specialists init --sync-defaults` |
206
- | Need user-layer override from default/package specialist | `sp edit <name> --fork-from <base>` to materialize editable copy in `.specialists/user/` |
207
- | Specialist JSON schema mismatch | `specialists init --sync-defaults` (refreshes specialists + mandatory-rules + nodes) |
208
- | Installed specialist default differs from canonical package copy | `specialists init --sync-defaults` unless local customization is intentional |
209
- | Hooks missing or stale | `specialists init` |
210
- | Installed hook file differs from canonical package copy | `specialists init` unless local customization is intentional |
211
- | `sp` / `specialists` missing from PATH | Reinstall / re-bootstrap specialists runtime |
212
- | Job dir missing | `specialists init` |
213
- | Orphaned `.worktrees/` entries | `specialists clean` |
214
- | SQLite schema/version mismatch | `sp doctor` first, then `specialists init --sync-defaults` or runtime migration command |
215
- | Schema below v11 (no `specialist_job_metrics`) | Reinstall / upgrade runtime; table is created by initSchema / migrateToV11. No data loss — raw events untouched. |
216
- | Events about to be pruned but never aggregated | `sp db extract --all-missing` BEFORE `sp db prune --apply`. Prune refuses when extract fails (safe by design). |
217
- | Emergency: need to prune but extract is wedged | `sp db prune --apply --skip-extract` — raw events deleted without aggregation. Use only when data loss is acceptable. |
218
- | Historical per-job stats needed | `sp db stats` reads `specialist_job_metrics`. Replaces ad-hoc `status.json` scans. Supports `--format json\|table`. |
219
- | Pi extensions missing | `specialists init --sync-skills` or reinstall extension registration |
220
- | Hook config format stale | `specialists init` |
221
- | Skill symlink / active-skill drift | `specialists init --sync-skills` |
222
- | Installed default skill differs from canonical package copy | `specialists init --sync-skills` unless local customization is intentional |
223
- | Skill frontmatter version / synced_at drift | `specialists init --sync-skills` or refresh packaged skills |
224
- | Mandatory-rules mirror drift (`.specialists/default/mandatory-rules`) | `specialists init --sync-defaults` |
225
- | `.specialists/mandatory-rules/` overlay present | Leave alone — this is repo overlay, NOT drift |
226
- | Missing/invalid `template_sets` references | Check all three tiers first; `sp edit <name> --fork-from <base>` then fix references, or sync defaults if mirror missing, or add set to overlay if intended |
227
- | Unknown manual drift | Stop, inspect, then apply user-approved fix |
228
-
229
- ## Remediation
230
-
231
- ### Fix: Package/runtime version drift
232
-
233
- If installed npm package version, CLI version, or package root parity checks disagree:
87
+ Only after operator confirmation, prune redundant defaults:
234
88
 
235
89
  ```bash
236
- npm ls @jaggerxtrm/specialists --depth=0
237
- specialists --version
238
- sp --version
90
+ sp prune-stale-defaults --root <repo>
239
91
  ```
240
92
 
241
- If versions do not align, reinstall or upgrade the package first. After runtime
242
- version is correct, re-run `specialists init` / sync commands to repair repo drift.
93
+ Rules:
94
+ - Never prune `.specialists/user/`.
95
+ - Never overwrite or delete diverged defaults without explicit operator approval.
96
+ - If a diverged default should become a customization, move/keep it as user-owned policy and document why.
97
+ - If the repo deliberately pins old behavior, leave `.specialists/default/` in place and record the pinned specialists version.
243
98
 
244
- ### Fix: Specialist configs drifted
99
+ ### A4) Validate runtime resolution
245
100
 
246
- If `sp doctor`, JSON validation, or direct diff against package canonical defaults
247
- shows missing fields, wrong names, or schema mismatch:
101
+ For specialist definitions and tool policy:
248
102
 
249
103
  ```bash
250
- specialists init --sync-defaults
104
+ sp list --full
105
+ sp config show <specialist> --resolved
251
106
  ```
252
107
 
253
- `--sync-defaults` refreshes specialists + mandatory-rules + nodes mirrors.
254
-
255
- If one specialist needs a small repair and `sp edit` supports it, prefer that over
256
- full sync. If target specialist lives in default/package layer, fork first:
108
+ For mandatory rules/skills references in custom specialists, verify resolution from package canonical or project override:
257
109
 
258
110
  ```bash
259
- sp edit <name> --fork-from <base>
111
+ sp config show <specialist> --resolved --from-source
260
112
  ```
261
113
 
262
- ### Fix: Hooks not firing
114
+ Use `--from-source` only in a specialists source/worktree context where installed dist may lag local source.
263
115
 
264
- If hooks are missing, wrong events, stale script paths, or hook files differ from
265
- installed package canonical copies:
116
+ ## Category B xtrm-managed Filesystem Asset Flow
266
117
 
267
- ```bash
268
- specialists init
269
- ```
118
+ ### B1) Discover projects root
119
+
120
+ Ask for root if user did not name one.
270
121
 
271
- If runtime exposes a narrower hook sync command, prefer it. Use full init only
272
- when hook-only sync is not enough.
122
+ Default order:
123
+ 1. explicit user root,
124
+ 2. `~/dev`,
125
+ 3. git-discovered repo root / workspace root,
126
+ 4. current directory as last fallback.
273
127
 
274
- ### Fix: CLI not reachable
128
+ If multiple candidate roots exist, ask which one to use.
275
129
 
276
- If `sp` or `specialists` is missing or incompatible:
130
+ ### B2) Run xtrm doctor
131
+
132
+ Use:
277
133
 
278
134
  ```bash
279
- sp doctor
135
+ xt doctor --cwd <root> --json
280
136
  ```
281
137
 
282
- If doctor confirms install drift, reinstall or re-bootstrap specialists runtime.
283
- Do not guess at file edits when command surface itself is broken.
138
+ If `xt` is unavailable, stop Category B and use fallback guidance below. Do not invent xtrm bulk commands.
284
139
 
285
- ### Fix: Job dirs or worktree GC drift
140
+ ### B3) Summarize Category B drift
286
141
 
287
- If jobs exist without owners, worktrees are orphaned, or cleanup state is stale:
142
+ Render a clean table grouped by repo:
288
143
 
289
- ```bash
290
- specialists clean
291
- ```
144
+ | repo | status | drift | missing | mismatched | suggested action |
145
+ |---|---|---:|---:|---:|---|
292
146
 
293
- Then re-run `sp doctor`.
147
+ Keep focus on operator action, not internal diagnostics.
294
148
 
295
- ### Fix: SQLite schema drift
149
+ ### B4) Ask for confirmation
296
150
 
297
- If doctor reports DB version mismatch or recovery issue:
151
+ Offer three paths:
152
+ - dry-run only,
153
+ - refresh specific repos,
154
+ - refresh all repos.
298
155
 
299
- 1. Run `sp doctor` and capture exact schema error.
300
- 2. Apply runtime migration command if available.
301
- 3. If no automated migration exists, flag manual intervention.
156
+ If user names one repo, keep flow narrow and confirm only that repo.
302
157
 
303
- ### Fix: metrics aggregation missing or stale
158
+ ### B5) Apply xtrm refresh
304
159
 
305
- Schema v11 introduced `specialist_job_metrics` (aggregated per-job stats). If you see low `metrics_coverage` in the detection output, or want historical stats before running `sp db prune`:
160
+ Dry-run:
306
161
 
307
162
  ```bash
308
- # Backfill metrics for any job whose events still exist but lack a metrics row.
309
- sp db extract --all-missing
163
+ xt update --root <root>
164
+ xt update --repo <repo>
165
+ ```
310
166
 
311
- # Inspect specific job metrics.
312
- sp db extract --job <job-id>
167
+ Apply:
313
168
 
314
- # Query aggregates.
315
- sp db stats
316
- sp db stats --spec executor --since 7d --format json
317
- sp db stats --model 'openai-codex/*' --since 30d
169
+ ```bash
170
+ xt update --apply --root <root>
171
+ xt update --apply --repo <repo>
318
172
  ```
319
173
 
320
- `sp db prune --apply` automatically extracts for every job whose events will be deleted (unless `--skip-extract`). If extract throws, prune aborts — investigate the failing job instead of bypassing.
174
+ ### B6) Re-run doctor
175
+
176
+ Run the same doctor command again after update:
177
+
178
+ ```bash
179
+ xt doctor --cwd <root> --json
180
+ ```
181
+
182
+ Confirm clean state or reduced-to-intentional drift.
183
+
184
+ ## Combined Multi-repo Flow
185
+
186
+ When the operator asks broadly to "update specialists" across repos:
321
187
 
322
- Safe order before a retention cleanup:
323
- 1. `sp db extract --all-missing` verify no extract errors.
324
- 2. `sp db prune --before 30d --dry-run` confirm scope.
325
- 3. `sp db prune --before 30d --apply` — prune with pre-extract built in.
326
- 4. `sp db vacuum` compact file size.
188
+ 1. Choose projects root.
189
+ 2. For each repo with specialists state:
190
+ - run/record Category A status: `sp --version`, `sp doctor --check-drift` if available.
191
+ 3. For each repo with `.xtrm/registry.json`:
192
+ - run/record Category B status: `xt doctor --cwd <repo> --json`.
193
+ 4. Present one combined table:
327
194
 
328
- ### Fix: Skills/defaults differ from shipped package copy
195
+ | repo | specialists pkg | Category A status | Category B status | recommended action |
196
+ |---|---|---|---|---|
329
197
 
330
- If diff against the installed package shows `.specialists/default/`,
331
- `.xtrm/skills/default/`, or `.claude/hooks/` drift from shipped canonical files:
198
+ Recommended action examples:
199
+ - upgrade `@jaggerxtrm/specialists`, then re-run `sp doctor --check-drift`,
200
+ - prune redundant `.specialists/default/` snapshots,
201
+ - preserve `.specialists/user/` customization,
202
+ - run `xt update --repo <repo> --apply`,
203
+ - no action.
332
204
 
333
- - If drift is intentional project customization, report it and do not overwrite silently.
334
- - If drift is unintentional, use the narrowest sync that fixes the affected area:
205
+ ## Fallbacks
206
+
207
+ ### `sp` missing
208
+
209
+ Say Category A cannot be verified until specialists is installed:
335
210
 
336
211
  ```bash
337
- specialists init --sync-defaults
338
- specialists init --sync-skills
339
- specialists init
212
+ npm install -g @jaggerxtrm/specialists@latest
340
213
  ```
341
214
 
342
- ### Fix: Pi extensions not registered
215
+ If project policy uses local dev dependency, recommend the project-local package manager command instead.
216
+
217
+ ### `xt` missing
343
218
 
344
- If `quality-gates`, `pi-gitnexus`, or `pi-serena-tools` are missing:
219
+ Category A can still be checked with `sp`. For Category B, tell user:
345
220
 
346
221
  ```bash
347
- specialists init --sync-skills
222
+ npm install -g xtrm-tools@latest
223
+ xt install
224
+ xt doctor --cwd <repo> --json
348
225
  ```
349
226
 
350
- If project uses different extension packaging, re-run install step that writes
351
- `.pi/settings.json`.
227
+ Do not claim skills/hooks are synced without `xt` or a valid `.xtrm/registry.json`.
352
228
 
353
- ## Verification
229
+ ### `.xtrm/registry.json` missing
354
230
 
355
- After fixes, confirm canonical state restored.
231
+ Report that xtrm-managed assets cannot be drift-checked in that repo until registry scaffold exists. Suggested action:
356
232
 
357
233
  ```bash
358
- sp doctor
359
- sp status
360
- npm ls @jaggerxtrm/specialists --depth=0 2>/dev/null || true
361
- specialists --version 2>/dev/null || true
362
- sp --version 2>/dev/null || true
363
-
364
- node -e "const fs=require('fs'); const p='.claude/settings.json'; const s=JSON.parse(fs.readFileSync(p,'utf8')); console.log(Boolean(s.hooks || Object.keys(s).length))"
234
+ xt install
365
235
  ```
366
236
 
367
- Expected outcome:
368
- - `sp doctor` clean
369
- - `sp status` no drift / no repair hints
370
- - `sp` and `specialists` reachable (`sp` is shorthand; `specialists` is canonical)
371
- - installed package / CLI versions aligned
372
- - specialist JSON files valid
373
- - repo defaults match installed package defaults (or intentional custom drift acknowledged)
374
- - hooks present on required events and canonical hook files match installed package copy
375
- - no orphaned worktrees
376
- - SQLite state healthy
237
+ or pull a repo revision that tracks `.xtrm/registry.json`.
377
238
 
378
- ## Manual Intervention
239
+ ## Safety Rules
379
240
 
380
- Flag these when automatic fix is unsafe or impossible:
241
+ - Preserve `.specialists/user/` and any user-authored skill/hook layer.
242
+ - Treat `.specialists/default/` as compatibility/pinning surface, not normal fresh-repo state.
243
+ - Treat `.xtrm/skills/default/` and `.xtrm/hooks/default/` as managed output; do not hand-edit as the repair path.
244
+ - Prefer dry-run first when more than one repo will change.
245
+ - Keep Category A and Category B results separate in the final report.
381
246
 
382
- - `sp doctor` reports corrupt DB / unreadable SQLite file
383
- - command surface missing because install itself is broken
384
- - hook scripts absent from repo and cannot be regenerated
385
- - schema mismatch with no available migration path
386
- - worktree cleanup would remove user changes
387
- - extensions required by project are not installed at package level
388
- - package root is unavailable, so package-vs-installed diff cannot be computed
389
- - repo intentionally diverges from canonical package copies and user must preserve customizations
247
+ ## Output Shape
390
248
 
391
- When manual intervention needed, report:
392
- 1. exact drift
393
- 2. exact command tried
394
- 3. why auto-fix stopped
395
- 4. next safe operator action
249
+ Use this order:
250
+ 1. root/repo chosen,
251
+ 2. specialists package version and Category A summary,
252
+ 3. xtrm Category B summary,
253
+ 4. combined drift table,
254
+ 5. proposed actions,
255
+ 6. explicit confirmation request,
256
+ 7. commands run,
257
+ 8. post-action verification,
258
+ 9. residual manual work.
396
259
 
397
- ## User Summary Format
398
-
399
- After detection + remediation, answer with compact status:
260
+ ## Example Operator Loop
400
261
 
401
262
  ```text
402
- ## specialists update complete
403
-
404
- sp doctor clean
405
- package / CLI versions aligned
406
- specialist configs valid
407
- hooks wired
408
- ✓ canonical package parity checked
409
- jobs/worktrees clean
410
- ✓ SQLite healthy
411
- ✓ extensions registered
412
-
413
- [manual items, if any]
263
+ Root: ~/dev
264
+
265
+ repo sp version Category A Category B action
266
+ repo-a 3.13.0 redundant defaults: 4 skills drift: 2 prune A + xt update
267
+ repo-b 3.12.0 package behind latest in-sync upgrade sp only
268
+ repo-c 3.13.0 user overlay only hooks drift: 1 preserve user + xt update
269
+
270
+ Apply which actions? dry-run / selected repos / all
414
271
  ```
272
+
273
+ ## Verification Checklist
274
+
275
+ After work:
276
+ - `sp doctor --check-drift` clean or reduced to intentional pins/overrides,
277
+ - `sp prune-stale-defaults --dry-run` shows no redundant defaults unless intentionally retained,
278
+ - `sp list --full` and selected `sp config show <name> --resolved` reflect package-live runtime,
279
+ - `xt doctor --cwd <root> --json` clean or reduced to intentional custom drift,
280
+ - single-repo case stays single-repo,
281
+ - missing-tool paths fall back cleanly.