@jaggerxtrm/specialists 3.12.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 (32) hide show
  1. package/config/hooks/specialists-session-start.mjs +1 -1
  2. package/config/mandatory-rules/bead-id-verbatim.md +14 -0
  3. package/config/mandatory-rules/per-turn-handoff-schema.md +16 -0
  4. package/config/skills/specialists-creator/SKILL.md +16 -0
  5. package/config/skills/update-specialists/SKILL.md +183 -350
  6. package/config/skills/using-kpi/SKILL.md +86 -0
  7. package/config/skills/using-specialists-v2/SKILL.md +1 -1
  8. package/config/skills/using-specialists-v3/SKILL.md +390 -112
  9. package/config/specialists/changelog-keeper.specialist.json +2 -1
  10. package/config/specialists/code-sanity.specialist.json +3 -1
  11. package/config/specialists/debugger.specialist.json +3 -1
  12. package/config/specialists/executor.specialist.json +3 -1
  13. package/config/specialists/explorer.specialist.json +2 -1
  14. package/config/specialists/overthinker.specialist.json +2 -1
  15. package/config/specialists/planner.specialist.json +3 -1
  16. package/config/specialists/researcher.specialist.json +2 -1
  17. package/config/specialists/reviewer.specialist.json +3 -1
  18. package/config/specialists/security-auditor.specialist.json +53 -10
  19. package/config/specialists/specialists-creator.specialist.json +2 -2
  20. package/config/specialists/sync-docs.specialist.json +3 -1
  21. package/config/specialists/test-runner.specialist.json +2 -1
  22. package/dist/index.js +247 -355
  23. package/dist/lib.js +38 -19
  24. package/dist/types/cli/help.d.ts.map +1 -1
  25. package/dist/types/cli/run.d.ts.map +1 -1
  26. package/dist/types/cli/version-check.d.ts +3 -0
  27. package/dist/types/cli/version-check.d.ts.map +1 -1
  28. package/dist/types/index.d.ts +1 -1
  29. package/dist/types/specialist/mandatory-rules.d.ts +5 -0
  30. package/dist/types/specialist/mandatory-rules.d.ts.map +1 -1
  31. package/package.json +4 -4
  32. package/config/specialists/.serena/project.yml +0 -151
@@ -1,448 +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.4
10
- synced_at: 2026-04-29
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; auto-migrates on next runtime startup) |
95
- | `specialist_job_metrics` table | Present at v11+ — holds aggregated per-job metrics |
96
- | `specialist_job_metrics` columns | Includes `active_runtime_ms` + `waiting_ms` (drs41.1 — auto-added by idempotent `migrateToV11` ALTER TABLE on first start of upgraded runtime; pre-existing rows get NULL until next aggregate) |
97
- | Auto-aggregation hook | Supervisor + `sp stop` invoke `aggregateJobMetricsBestEffort` after terminal-status persistence (drs41.1) — table populates without manual `sp db extract` under normal operation |
98
- | Merge target lookup | DB-first (post-ofjvj): `readAllJobStatuses()` reads `specialist_jobs` via `listStatuses()`. `sp merge` no longer reads `.specialists/jobs/<id>/status.json`. Older versions silently failed after `sp stop` cleaned status.json. |
99
- | WAL / busy timeout settings | Present when runtime uses SQLite |
100
- | Corruption / lock errors | None in `sp doctor` |
101
- | Pre-prune extract | `sp db prune --apply` extracts metrics to `specialist_job_metrics` before deleting events |
102
- | Extract backfill | `sp db extract --all-missing` populates metrics for jobs whose events still exist (still useful for backfilling historical jobs that ran before the auto-aggregate hook landed) |
103
- | Historical stats query | `sp db stats [--spec <name>] [--model <glob>] [--since <dur>]` reads the aggregated table; output includes `active_s`, `waiting_s`, `total_s` (drs41.1) |
104
-
105
- **Safety: `sp init` and `sp init --sync-defaults` do NOT touch `.specialists/db/observability.db`.** Init checks file existence and skips with "observability database already exists (not touched)" when present. Schema migrations run on next runtime startup (any `sp` invocation that opens the DB), additively via `ALTER TABLE ADD COLUMN`. No data loss path during a normal package upgrade.
106
-
107
- ### Skills + extensions parity
108
-
109
- | Check | Expected value |
110
- |-------|----------------|
111
- | `.xtrm/skills/default/` | Matches canonical package skill set for installed version |
112
- | Active skill links / copies | Resolve to expected default or active targets |
113
- | Skill frontmatter `version` / `synced_at` | Present and reasonable for shipped skills |
114
- | `quality-gates` | Registered if project uses quality gates |
115
- | `pi-gitnexus` | Registered when GitNexus integration is expected |
116
- | `pi-serena-tools` | Registered when Serena integration is expected |
117
- | Extension paths | Resolve from installed project, not stale workspace copies |
118
-
119
- ### Mandatory-rules template parity (three-tier)
120
-
121
- Loader unions indexes from three paths and probes set files in reverse precedence
122
- (overlay wins on set-id conflict). Full authoring guide:
123
- `config/mandatory-rules/README.md`.
124
-
125
- | Check | Expected value |
126
- |-------|----------------|
127
- | `.specialists/default/mandatory-rules/*` | Mirrors canonical package templates after `sp init --sync-defaults` (managed mirror, no hand edits) |
128
- | `.specialists/mandatory-rules/*` | Repo-specific overlay (user-maintained). Present when repo ships its own rules. NOT drift. |
129
- | Template frontmatter | YAML frontmatter present and parseable |
130
- | `specialist.mandatory_rules.template_sets` references | Resolve in order: `.specialists/mandatory-rules/` → `.specialists/default/mandatory-rules/` → `config/mandatory-rules/` |
131
- | Index files (`index.json`) | Any of the three tiers may define `required_template_sets` / `default_template_sets`; loader unions + dedups |
132
- | Prompt injection behavior | Runner appends resolved `MANDATORY_RULES` block at end of prompt; supervisor emits `mandatory_rules_injection` meta event |
133
-
134
- ## Discover Latest Release
135
-
136
- Before reconciling, determine whether a newer release is published. Compare local `package.json` version to the most recent `vX.Y.Z` tag on `origin`:
14
+ Interactive operator workflow for the two distribution tracks:
137
15
 
138
- ```bash
139
- LOCAL=$(node -p "require('./package.json').version")
140
- LATEST=$(git ls-remote --tags --refs origin | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 | sed 's/^v//')
141
- echo "local: $LOCAL latest: $LATEST"
142
- ```
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`
143
27
 
144
- If `LATEST > LOCAL`, read the corresponding `CHANGELOG.md` section to summarize what shipped:
28
+ Do not collapse these flows. Category A is specialists-owned and uses `sp` commands. Category B is xtrm-owned and uses `xt` commands.
145
29
 
146
- ```bash
147
- awk -v ver="$LATEST" '/^## \[v?'"$LATEST"'\]/,/^## \[/{print}' CHANGELOG.md | head -60
148
- ```
30
+ No automatic destructive execution. Always summarize first and ask before applying refresh/prune actions.
149
31
 
150
- Surface a one-line summary to the user (Added/Changed/Fixed counts plus the headline) and **ask before pulling**. The reconcile flow below applies regardless of whether the user pulls a new release first or stays on the current version — drift detection is independent of release version.
32
+ ## Quick Decision Tree
151
33
 
152
- Skip this discovery step entirely when `SPECIALISTS_OFFLINE=1` is set, when offline, or when the user already specified the version. The `using-specialists-v2` skill performs the same lightweight check on session-load and may have already surfaced the notice; do not repeat it.
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.
153
40
 
154
- After the user confirms a pull (e.g. `git fetch && git pull origin master`), proceed with detection below to catch any drift introduced by the new release.
41
+ ## Category A Specialists Runtime / npm-live Flow
155
42
 
156
- ## Detection
43
+ ### A1) Verify package and command surface
157
44
 
158
- Run these in order. Report which checks pass and which drift.
45
+ Run in the target repo:
159
46
 
160
47
  ```bash
161
- # 1. Primary health check
48
+ sp --version
162
49
  sp doctor
50
+ sp doctor --check-drift
51
+ ```
163
52
 
164
- # 2. Runtime status
165
- sp status
166
-
167
- # 3. Installed package + CLI version parity
168
- npm ls @jaggerxtrm/specialists --depth=0 2>/dev/null || true
169
- 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'); }"
170
- sp --version 2>/dev/null || true
171
- specialists --version 2>/dev/null || true
172
-
173
- # 4. Resolve canonical package root for direct drift diff
174
- 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'); }"
175
-
176
- # 5. Config shape
177
- find .specialists/default -maxdepth 1 -name '*.specialist.json' -print
53
+ Use `specialists` instead of `sp` if the alias is unavailable.
178
54
 
179
- # 6. Validate specialist JSON files
180
- 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); }"
55
+ Category A canonical source is the installed `@jaggerxtrm/specialists` npm package. To update it, upgrade/pin the package version:
181
56
 
182
- # 7. Validate referenced skill paths
183
- 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); } }"
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
+ ```
184
62
 
185
- # 8. Compare repo defaults against installed package defaults (if package root resolvable)
186
- PKG_ROOT="$(node -e "try { const path=require('path'); process.stdout.write(path.dirname(require.resolve('@jaggerxtrm/specialists/package.json'))); } catch (err) {}")"
187
- if [ -n "$PKG_ROOT" ]; then
188
- diff -rq .specialists/default "$PKG_ROOT/config/specialists" || true
189
- diff -rq .xtrm/skills/default "$PKG_ROOT/config/skills" || true
190
- diff -rq .claude/hooks "$PKG_ROOT/config/hooks" || true
191
- else
192
- echo PACKAGE_COMPARE_UNAVAILABLE
193
- fi
63
+ Report the installed version and whether the repo is intentionally pinned.
194
64
 
195
- # 9. Hooks wiring
196
- 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'); }"
65
+ ### A2) Interpret `sp doctor --check-drift`
197
66
 
198
- # 10. Command availability
199
- command -v sp
200
- command -v specialists
201
- specialists init --help | sed -n '1,120p'
202
- specialists edit --help | sed -n '1,120p' | grep -E -- '--fork-from|fork-from' || true
203
- sp doctor --json 2>/dev/null || true
67
+ This checks stale `.specialists/default/` snapshots against package-canonical assets.
204
68
 
205
- # 11. Jobs and worktrees
206
- ls -1 .specialists/jobs 2>/dev/null || true
207
- find .worktrees -maxdepth 2 -mindepth 1 -type d 2>/dev/null || true
69
+ Typical statuses:
208
70
 
209
- # 12. Extension registration
210
- 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')"
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 |
211
77
 
212
- # 13a. Observability schema + metrics coverage + drs41.1 column presence
213
- 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; const cols=has ? new Set(db.query('PRAGMA table_info(specialist_job_metrics)').all().map(r=>r.name)) : new Set(); const drs41Cols={active_runtime_ms: cols.has('active_runtime_ms'), waiting_ms: cols.has('waiting_ms')}; console.log(JSON.stringify({schema_version: v?.value, has_metrics_table: !!has, drs41_columns_present: drs41Cols, 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"
78
+ ### A3) Prune redundant Category A snapshots
214
79
 
215
- # 13. Mandatory-rules template tiers + reference checks (three-tier resolution)
216
- find .specialists/default/mandatory-rules -maxdepth 1 -type f 2>/dev/null || true
217
- find .specialists/mandatory-rules -maxdepth 1 -type f 2>/dev/null || true
218
- 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'));"
80
+ Dry-run first:
219
81
 
220
- # 14. Shipped skill frontmatter parity
221
- 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')); }"
82
+ ```bash
83
+ sp prune-stale-defaults --dry-run
84
+ sp prune-stale-defaults --root <repo>
222
85
  ```
223
86
 
224
- ## Drift -> Fix Mapping
225
-
226
- Use targeted fixes first. Escalate to full sync only if needed.
227
-
228
- | Drift | Fix |
229
- |-------|-----|
230
- | Installed package version mismatch | reinstall / upgrade `@jaggerxtrm/specialists`, then re-run checks |
231
- | CLI version mismatch vs package | reinstall runtime so `sp` / `specialists` align with installed package |
232
- | Specialist JSON missing required fields | `sp edit <name> ...` or regenerate via `specialists init --sync-defaults` |
233
- | Need user-layer override from default/package specialist | `sp edit <name> --fork-from <base>` to materialize editable copy in `.specialists/user/` |
234
- | Specialist JSON schema mismatch | `specialists init --sync-defaults` (refreshes specialists + mandatory-rules + nodes) |
235
- | Installed specialist default differs from canonical package copy | `specialists init --sync-defaults` unless local customization is intentional |
236
- | Hooks missing or stale | `specialists init` |
237
- | Installed hook file differs from canonical package copy | `specialists init` unless local customization is intentional |
238
- | `sp` / `specialists` missing from PATH | Reinstall / re-bootstrap specialists runtime |
239
- | Job dir missing | `specialists init` |
240
- | Orphaned `.worktrees/` entries | `specialists clean` |
241
- | SQLite schema/version mismatch | `sp doctor` first, then `specialists init --sync-defaults` or runtime migration command |
242
- | Schema below v11 (no `specialist_job_metrics`) | Reinstall / upgrade runtime; table is created by initSchema / migrateToV11. No data loss — raw events untouched. |
243
- | `specialist_job_metrics` missing `active_runtime_ms` / `waiting_ms` columns (post-drs41.1) | Open any `sp` command — `migrateToV11` is idempotent and ALTERs the table to add the columns. No reinstall needed. Pre-existing rows show NULL until next aggregate or `sp db extract --all-missing`. |
244
- | Auto-aggregate hook absent (older runtime) — empty `specialist_job_metrics` despite job activity | Upgrade `@jaggerxtrm/specialists` package. Post-drs41.1, supervisor + `sp stop` invoke `aggregateJobMetricsBestEffort` on every terminal status, so the table fills under normal operation. Backfill historical with `sp db extract --all-missing`. |
245
- | `sp merge` fails after `sp stop` (older runtime) — "No chain-root job with worktree metadata found" | Upgrade `@jaggerxtrm/specialists` past ofjvj fix. Merge lookup is now DB-first via `readAllJobStatuses()` / `listStatuses()`. Pre-fix workaround was manual `git merge --no-ff feature/<branch>` (skips tsc + conflict gates). |
246
- | 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). |
247
- | 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. |
248
- | Historical per-job stats needed | `sp db stats` reads `specialist_job_metrics`. Replaces ad-hoc `status.json` scans. Supports `--format json\|table`. |
249
- | Pi extensions missing | `specialists init --sync-skills` or reinstall extension registration |
250
- | Hook config format stale | `specialists init` |
251
- | Skill symlink / active-skill drift | `specialists init --sync-skills` |
252
- | Installed default skill differs from canonical package copy | `specialists init --sync-skills` unless local customization is intentional |
253
- | Skill frontmatter version / synced_at drift | `specialists init --sync-skills` or refresh packaged skills |
254
- | Mandatory-rules mirror drift (`.specialists/default/mandatory-rules`) | `specialists init --sync-defaults` |
255
- | `.specialists/mandatory-rules/` overlay present | Leave alone — this is repo overlay, NOT drift |
256
- | 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 |
257
- | Unknown manual drift | Stop, inspect, then apply user-approved fix |
258
-
259
- ## Remediation
260
-
261
- ### Fix: Package/runtime version drift
262
-
263
- If installed npm package version, CLI version, or package root parity checks disagree:
87
+ Only after operator confirmation, prune redundant defaults:
264
88
 
265
89
  ```bash
266
- npm ls @jaggerxtrm/specialists --depth=0
267
- specialists --version
268
- sp --version
90
+ sp prune-stale-defaults --root <repo>
269
91
  ```
270
92
 
271
- If versions do not align, reinstall or upgrade the package first. After runtime
272
- 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.
273
98
 
274
- ### Fix: Specialist configs drifted
99
+ ### A4) Validate runtime resolution
275
100
 
276
- If `sp doctor`, JSON validation, or direct diff against package canonical defaults
277
- shows missing fields, wrong names, or schema mismatch:
101
+ For specialist definitions and tool policy:
278
102
 
279
103
  ```bash
280
- specialists init --sync-defaults
104
+ sp list --full
105
+ sp config show <specialist> --resolved
281
106
  ```
282
107
 
283
- `--sync-defaults` refreshes specialists + mandatory-rules + nodes mirrors.
284
-
285
- If one specialist needs a small repair and `sp edit` supports it, prefer that over
286
- 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:
287
109
 
288
110
  ```bash
289
- sp edit <name> --fork-from <base>
111
+ sp config show <specialist> --resolved --from-source
290
112
  ```
291
113
 
292
- ### Fix: Hooks not firing
114
+ Use `--from-source` only in a specialists source/worktree context where installed dist may lag local source.
293
115
 
294
- If hooks are missing, wrong events, stale script paths, or hook files differ from
295
- installed package canonical copies:
116
+ ## Category B xtrm-managed Filesystem Asset Flow
296
117
 
297
- ```bash
298
- specialists init
299
- ```
118
+ ### B1) Discover projects root
119
+
120
+ Ask for root if user did not name one.
300
121
 
301
- If runtime exposes a narrower hook sync command, prefer it. Use full init only
302
- 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.
303
127
 
304
- ### Fix: CLI not reachable
128
+ If multiple candidate roots exist, ask which one to use.
305
129
 
306
- If `sp` or `specialists` is missing or incompatible:
130
+ ### B2) Run xtrm doctor
131
+
132
+ Use:
307
133
 
308
134
  ```bash
309
- sp doctor
135
+ xt doctor --cwd <root> --json
310
136
  ```
311
137
 
312
- If doctor confirms install drift, reinstall or re-bootstrap specialists runtime.
313
- 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.
314
139
 
315
- ### Fix: Job dirs or worktree GC drift
140
+ ### B3) Summarize Category B drift
316
141
 
317
- If jobs exist without owners, worktrees are orphaned, or cleanup state is stale:
142
+ Render a clean table grouped by repo:
318
143
 
319
- ```bash
320
- specialists clean
321
- ```
144
+ | repo | status | drift | missing | mismatched | suggested action |
145
+ |---|---|---:|---:|---:|---|
322
146
 
323
- Then re-run `sp doctor`.
147
+ Keep focus on operator action, not internal diagnostics.
324
148
 
325
- ### Fix: SQLite schema drift
149
+ ### B4) Ask for confirmation
326
150
 
327
- 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.
328
155
 
329
- 1. Run `sp doctor` and capture exact schema error.
330
- 2. Apply runtime migration command if available.
331
- 3. If no automated migration exists, flag manual intervention.
156
+ If user names one repo, keep flow narrow and confirm only that repo.
332
157
 
333
- For additive schema bumps (e.g. drs41.1 added `active_runtime_ms` / `waiting_ms` columns within v11): just open any `sp` command in the repo. `initSchema()` runs every migrate-up function on every startup; `migrateToV11` is idempotent — it detects existing v11 schema and `ALTER TABLE ADD COLUMN`s the missing fields. Existing rows are preserved (new fields = NULL until next aggregate). No data loss, no manual SQL.
158
+ ### B5) Apply xtrm refresh
334
159
 
335
- `sp init` and `sp init --sync-defaults` skip the DB entirely when it exists — the only way to wipe `.specialists/db/observability.db` is to delete the file manually.
160
+ Dry-run:
336
161
 
337
- ### Fix: metrics aggregation missing or stale
162
+ ```bash
163
+ xt update --root <root>
164
+ xt update --repo <repo>
165
+ ```
338
166
 
339
- 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`:
167
+ Apply:
340
168
 
341
169
  ```bash
342
- # Backfill metrics for any job whose events still exist but lack a metrics row.
343
- sp db extract --all-missing
170
+ xt update --apply --root <root>
171
+ xt update --apply --repo <repo>
172
+ ```
344
173
 
345
- # Inspect specific job metrics.
346
- sp db extract --job <job-id>
174
+ ### B6) Re-run doctor
347
175
 
348
- # Query aggregates.
349
- sp db stats
350
- sp db stats --spec executor --since 7d --format json
351
- sp db stats --model 'openai-codex/*' --since 30d
176
+ Run the same doctor command again after update:
177
+
178
+ ```bash
179
+ xt doctor --cwd <root> --json
352
180
  ```
353
181
 
354
- `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.
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:
187
+
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:
355
194
 
356
- Safe order before a retention cleanup:
357
- 1. `sp db extract --all-missing` — verify no extract errors.
358
- 2. `sp db prune --before 30d --dry-run` — confirm scope.
359
- 3. `sp db prune --before 30d --apply` — prune with pre-extract built in.
360
- 4. `sp db vacuum` — compact file size.
195
+ | repo | specialists pkg | Category A status | Category B status | recommended action |
196
+ |---|---|---|---|---|
361
197
 
362
- ### Fix: Skills/defaults differ from shipped package copy
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.
363
204
 
364
- If diff against the installed package shows `.specialists/default/`,
365
- `.xtrm/skills/default/`, or `.claude/hooks/` drift from shipped canonical files:
205
+ ## Fallbacks
366
206
 
367
- - If drift is intentional project customization, report it and do not overwrite silently.
368
- - If drift is unintentional, use the narrowest sync that fixes the affected area:
207
+ ### `sp` missing
208
+
209
+ Say Category A cannot be verified until specialists is installed:
369
210
 
370
211
  ```bash
371
- specialists init --sync-defaults
372
- specialists init --sync-skills
373
- specialists init
212
+ npm install -g @jaggerxtrm/specialists@latest
374
213
  ```
375
214
 
376
- ### 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
377
218
 
378
- 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:
379
220
 
380
221
  ```bash
381
- specialists init --sync-skills
222
+ npm install -g xtrm-tools@latest
223
+ xt install
224
+ xt doctor --cwd <repo> --json
382
225
  ```
383
226
 
384
- If project uses different extension packaging, re-run install step that writes
385
- `.pi/settings.json`.
227
+ Do not claim skills/hooks are synced without `xt` or a valid `.xtrm/registry.json`.
386
228
 
387
- ## Verification
229
+ ### `.xtrm/registry.json` missing
388
230
 
389
- 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:
390
232
 
391
233
  ```bash
392
- sp doctor
393
- sp status
394
- npm ls @jaggerxtrm/specialists --depth=0 2>/dev/null || true
395
- specialists --version 2>/dev/null || true
396
- sp --version 2>/dev/null || true
397
-
398
- 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
399
235
  ```
400
236
 
401
- Expected outcome:
402
- - `sp doctor` clean
403
- - `sp status` no drift / no repair hints
404
- - `sp` and `specialists` reachable (`sp` is shorthand; `specialists` is canonical)
405
- - installed package / CLI versions aligned
406
- - specialist JSON files valid
407
- - repo defaults match installed package defaults (or intentional custom drift acknowledged)
408
- - hooks present on required events and canonical hook files match installed package copy
409
- - no orphaned worktrees
410
- - SQLite state healthy
411
-
412
- ## Manual Intervention
237
+ or pull a repo revision that tracks `.xtrm/registry.json`.
413
238
 
414
- Flag these when automatic fix is unsafe or impossible:
239
+ ## Safety Rules
415
240
 
416
- - `sp doctor` reports corrupt DB / unreadable SQLite file
417
- - command surface missing because install itself is broken
418
- - hook scripts absent from repo and cannot be regenerated
419
- - schema mismatch with no available migration path
420
- - worktree cleanup would remove user changes
421
- - extensions required by project are not installed at package level
422
- - package root is unavailable, so package-vs-installed diff cannot be computed
423
- - repo intentionally diverges from canonical package copies and user must preserve customizations
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.
424
246
 
425
- When manual intervention needed, report:
426
- 1. exact drift
427
- 2. exact command tried
428
- 3. why auto-fix stopped
429
- 4. next safe operator action
247
+ ## Output Shape
430
248
 
431
- ## User Summary Format
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.
432
259
 
433
- After detection + remediation, answer with compact status:
260
+ ## Example Operator Loop
434
261
 
435
262
  ```text
436
- ## specialists update complete
437
-
438
- sp doctor clean
439
- package / CLI versions aligned
440
- specialist configs valid
441
- hooks wired
442
- ✓ canonical package parity checked
443
- jobs/worktrees clean
444
- ✓ SQLite healthy
445
- ✓ extensions registered
446
-
447
- [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
448
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.