xtrm-tools 0.7.12 → 0.7.13

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 (26) hide show
  1. package/.xtrm/hooks/specialists/specialists-memory-cache-sync.mjs +57 -0
  2. package/.xtrm/registry.json +477 -389
  3. package/.xtrm/skills/default/premortem/SKILL.md +218 -0
  4. package/.xtrm/skills/default/releasing/SKILL.md +90 -0
  5. package/.xtrm/skills/default/sync-docs/SKILL.md +88 -208
  6. package/.xtrm/skills/default/sync-docs/scripts/pre-context.sh +17 -0
  7. package/.xtrm/skills/default/update-specialists/SKILL.md +228 -36
  8. package/.xtrm/skills/default/update-xt/SKILL.md +34 -0
  9. package/.xtrm/skills/default/using-kpi/SKILL.md +150 -0
  10. package/.xtrm/skills/default/using-specialists-v2/SKILL.md +683 -0
  11. package/cli/dist/index.cjs +839 -429
  12. package/cli/dist/index.cjs.map +1 -1
  13. package/cli/package.json +1 -1
  14. package/package.json +2 -2
  15. package/packages/pi-extensions/.serena/project.yml +119 -0
  16. package/packages/pi-extensions/extensions/pi-serena-compact/index.ts +4 -12
  17. package/packages/pi-extensions/extensions/xtrm-loader/index.ts +0 -1
  18. package/packages/pi-extensions/extensions/xtrm-ui/index.ts +201 -36
  19. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-dark-flattools.json +79 -0
  20. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-dark.json +85 -0
  21. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-light-flattools.json +79 -0
  22. package/packages/pi-extensions/extensions/xtrm-ui/themes/pidex-light.json +85 -0
  23. package/packages/pi-extensions/package.json +1 -1
  24. package/packages/pi-extensions/themes/xtrm-ui/pidex-dark-flattools.json +79 -0
  25. package/packages/pi-extensions/themes/xtrm-ui/pidex-dark.json +3 -3
  26. package/packages/pi-extensions/themes/xtrm-ui/pidex-light-flattools.json +79 -0
@@ -1,262 +1,142 @@
1
1
  ---
2
2
  name: sync-docs
3
3
  description: >-
4
- Mode-routed documentation sync for xtrm projects. Three modes: targeted
5
- (named docs only), area (time-windowed + source scope), full audit.
6
- Commit-based context gathering, not PR-based. Use whenever docs need
7
- syncing after code changes, the user asks to "sync docs", "update docs",
8
- "doc audit", "check docs health", or "detect drift".
4
+ Single-doc documentation sync specialist for xtrm projects. Each invocation
5
+ operates on exactly one doc named in the bead's SCOPE. Source files are
6
+ off-limits to every tool — context comes from a pre-script (xt report
7
+ excerpt + commits) and per-commit `git show <hash> -- <paths>` for at most
8
+ 3 unclear commits. Hard runtime cap. Use when one specific doc needs
9
+ syncing after code changes — never for whole-tree audits.
9
10
  gemini-command: sync-docs
10
- version: 2.0.0
11
+ version: 3.1.0
11
12
  ---
12
13
 
13
14
  # sync-docs
14
15
 
15
- Keeps project documentation in sync with code reality.
16
+ Single-doc sync specialist. One invocation = one doc.
16
17
 
17
- ## Overview
18
+ ## The single-doc invariant
18
19
 
19
- ```
20
- Phase 0: Route mode/scope — targeted, area, or full audit?
21
- Phase 1: Gather context — commits, issues, changed files in window
22
- Phase 2: Inspect with xtrm — what does the docs suite report?
23
- Phase 3: Detect drift — which docs are stale?
24
- Phase 4: Plan delta — what to edit vs report
25
- Phase 5: Execute fixes — update docs within scope
26
- Phase 6: Validate — confirm no remaining drift
27
- ```
28
-
29
- **Audit vs Execute:** Bead-linked runs execute all phases. Non-bead runs with
30
- "audit/check/report" stop after Phase 4. Non-bead runs with "update/fix/sync"
31
- execute.
32
-
33
- ---
34
-
35
- ## Phase 0: Route Mode and Scope
36
-
37
- Determine your mode BEFORE gathering context. This controls everything downstream.
38
-
39
- ### Mode precedence
20
+ The bead's `SCOPE` field MUST name exactly one doc path. If SCOPE names zero docs, multiple docs, or a non-doc path, emit `BLOCKED: scope-violation` in Phase 1 and stop. There is no other mode. There is no "audit" or "area" path. Multi-doc updates are N parallel sync-docs runs orchestrated externally.
40
21
 
41
- | Priority | Condition | Mode |
42
- |----------|-----------|------|
43
- | 1 | Prompt contains explicit doc file paths | **Targeted** |
44
- | 2 | Prompt contains time window + directory/source scope | **Area** |
45
- | 3 | Everything else | **Full audit** |
22
+ The mandatory rule (`sync-docs-scope-discipline`) appended after this skill is enforced. Read it. It encodes the hard tool bans, the budget, the steer-obey rule, and the compaction-STOP rule.
46
23
 
47
- ### Mode behaviors
24
+ ## How you read code
48
25
 
49
- **Targeted** edit ONLY the named docs. Gather recent context for understanding.
50
- Report collateral docs that likely also need updates but do NOT edit them.
26
+ You don't, broadly. Source files under `src/`, `tests/`, `pi/`, `packages/`, `config/specialists/`, `.specialists/default/` are off-limits to **every tool**: `Read`, `Grep`, `Glob`, `find`, `cat`, `head`, `tail`, `sed`, `awk`, `rg`, `git grep`, `python -c open(...)`, and any `Bash` redirection that pipes a source file.
51
27
 
52
- **Area** derive candidate docs from changed source paths within the time window.
53
- Use drift detector to confirm staleness. Edit candidate docs within derived scope.
28
+ The legal channels for understanding what changed:
54
29
 
55
- **Full audit** run complete docs audit. Contextualize with recent commits/issues.
56
- Use drift detector + structure analyzer for comprehensive coverage.
30
+ 1. **Pre-script context** (already injected above): latest xt report excerpt + `git log master --oneline -20`.
31
+ 2. **Your one doc's content** (`Read`).
32
+ 3. **Filtered drift**: `python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py scan --json`, filtered through `jq` or `python -c` to YOUR ONE DOC. Discard everything else.
33
+ 4. **Filtered context_gatherer** (only if pre-script context is insufficient): `python3 .xtrm/skills/default/sync-docs/scripts/context_gatherer.py --doc <YOUR_DOC>` — that flag only.
34
+ 5. **Per-commit diff** for unclear claims: `git show <hash> -- <path1> [<path2>...]`. Maximum 3 such calls per run. NEVER `git diff <a>..<b>`. NEVER `git show <hash>` without `--`.
57
35
 
58
- ### Execution policy
36
+ ## Phases
59
37
 
60
- | Condition | Action |
61
- |-----------|--------|
62
- | `$bead_id` present | Execute (all phases) |
63
- | No bead + "audit"/"check"/"report"/"what's stale" | Report only (stop Phase 4) |
64
- | No bead + "update"/"fix"/"sync" | Execute |
65
-
66
- ---
67
-
68
- ## Phase 1: Gather Scoped Context
69
-
70
- ### Context gatherer
71
-
72
- The context gatherer supports time-window and scope-aware gathering:
73
-
74
- ```bash
75
- # Targeted: specific docs + time window
76
- python3 .xtrm/skills/default/sync-docs/scripts/context_gatherer.py \
77
- --doc docs/features.md --doc docs/cli-reference.md --since-hours 24
38
+ | Phase | Action | Budget |
39
+ |---|---|---|
40
+ | 1 | Verify SCOPE names exactly one doc. STOP if not. | 0 tools |
41
+ | 2 | Filtered drift scan for that one doc. | 1 call |
42
+ | 3 | Per-commit `git show <hash> -- <paths>` for unclear commits. | ≤3 calls |
43
+ | 4 | Edit the one doc. Bump `version` + `updated`. Stamp via `drift_detector.py update-sync <path>`. | edits to one doc only |
44
+ | 5 | Re-run filtered drift; confirm cleared. Emit final report. | 1 call |
78
45
 
79
- # Area: source scope + time window
80
- python3 .xtrm/skills/default/sync-docs/scripts/context_gatherer.py \
81
- --scope-path src/specialist/ --since-hours 24
46
+ After Phase 5, stop. Do not look at other docs. Do not propose new beads.
82
47
 
83
- # Area: broader window
84
- python3 .xtrm/skills/default/sync-docs/scripts/context_gatherer.py \
85
- --scope-path src/cli/ --since-days 7
48
+ ## Phase 1: SCOPE check
86
49
 
87
- # Full audit: broad window
88
- python3 .xtrm/skills/default/sync-docs/scripts/context_gatherer.py \
89
- --since-days 7
50
+ Read the bead's SCOPE field. It must name exactly one doc path. Examples of valid SCOPE:
90
51
 
91
- # Legacy compat (commit count)
92
- python3 .xtrm/skills/default/sync-docs/scripts/context_gatherer.py \
93
- --since-commits 30
94
52
  ```
95
-
96
- **Default:** `--since-hours 24` when no window specified.
97
-
98
- Outputs JSON with:
99
- - `mode_hint`: targeted / area / full
100
- - `window`: type + value + git_since
101
- - `scope`: doc targets + source paths
102
- - `git.recent_commits`: commits with changed files
103
- - `git.changed_files`: unique files ranked by change frequency
104
- - `git.changed_dirs`: directory-level summary
105
- - `bd.closed_issues`: recently closed issues
106
- - `docs`: drift detector results
107
-
108
- ### xtrm docs suite
109
-
110
- Use for operator-facing inspection:
111
-
112
- ```bash
113
- xtrm docs list --json
114
- xtrm docs show --json
115
- xtrm docs cross-check --json --days 30
53
+ SCOPE: docs/cli-reference.md
54
+ SCOPE: CHANGELOG.md
116
55
  ```
117
56
 
118
- ---
119
-
120
- ## Phase 2: Inspect Docs State
121
-
122
- Use `xtrm docs` to answer:
123
- - What docs exist and their metadata?
124
- - Which have missing or outdated frontmatter?
125
- - Coverage gaps between recent work and docs?
126
-
127
- If the CLI already isolates the problem clearly, skip to Phase 4.
128
-
129
- ---
130
-
131
- ## Phase 3: Detect Drift
132
-
133
- Use the drift detector filtered to your scope:
57
+ Examples that are `BLOCKED: scope-violation`:
134
58
 
135
- ```bash
136
- # All docs
137
- python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py scan --json
138
-
139
- # With commit window
140
- python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py scan --since 30 --json
59
+ ```
60
+ SCOPE: # empty
61
+ SCOPE: docs/cli-reference.md docs/features.md # multiple
62
+ SCOPE: docs/ # directory
63
+ SCOPE: src/cli/run.ts # non-doc
141
64
  ```
142
65
 
143
- A doc is stale when:
144
- 1. It declares `source_of_truth_for` globs in frontmatter
145
- 2. AND commits affecting matching files exist AFTER the `synced_at` hash
146
-
147
- ### Staleness model
148
-
149
- - **Time windows** decide what recent work to consider now (relevance)
150
- - **`synced_at` / hash-based drift** decides whether a doc is actually stale (truth)
151
- - **Fallback**: when metadata is missing, time-window heuristics prioritize review
152
-
153
- ---
154
-
155
- ## Phase 4: Plan Delta
156
-
157
- Before editing, identify:
158
- - Docs to update (within scope)
159
- - Docs to leave untouched
160
- - Collateral docs to report only (targeted mode)
161
-
162
- **If audit-only, stop here and output the report.**
163
-
164
- Include both:
165
- - `xtrm docs` findings (operator-facing)
166
- - Python analyzer findings (drift/structure enforcement)
167
-
168
- ---
169
-
170
- ## Phase 5: Execute Fixes
171
-
172
- | Situation | Action |
173
- |-----------|--------|
174
- | Stale docs file | Update content + bump `version` + `updated` |
175
- | README bloated | Extract large sections to focused docs files |
176
- | Missing docs file | Generate scaffold via `validate_doc.py --generate` |
177
- | Stale CHANGELOG | Add entry with changelog script |
178
- | Invalid schema | Fix frontmatter |
179
-
180
- ### After each doc update
66
+ If blocked, emit:
181
67
 
182
- Stamp the sync checkpoint:
183
- ```bash
184
- python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py update-sync <doc-path>
68
+ ```
69
+ DOC: <whatever was in SCOPE, or empty>
70
+ VERDICT: BLOCKED
71
+ EDITS: none
72
+ NOTES: scope-violation — <reason>
185
73
  ```
186
74
 
187
- ### Targeted mode boundary
188
-
189
- In targeted mode, ONLY edit the named docs. If you discover other docs need
190
- updating, list them in your output as "Suggested follow-ups" — do not edit them.
75
+ and stop.
191
76
 
192
- ### Structure analysis (full audit only)
77
+ ## Phase 2: Filtered drift
193
78
 
194
79
  ```bash
195
- python3 .xtrm/skills/default/sync-docs/scripts/doc_structure_analyzer.py
196
- python3 .xtrm/skills/default/sync-docs/scripts/doc_structure_analyzer.py --fix
80
+ python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py scan --json \
81
+ | jq '[.[] | select(.path == "<YOUR_DOC>")]'
197
82
  ```
198
83
 
199
- ### Add changelog entry
200
-
201
- ```bash
202
- python3 .xtrm/skills/default/sync-docs/scripts/changelog/add_entry.py \
203
- CHANGELOG.md Added "Describe the documentation update"
204
- ```
84
+ If your doc reports stale, capture the list of commits since `synced_at` — those are your candidate commits for Phase 3.
205
85
 
206
- ---
86
+ If your doc is not in the drift output (no `source_of_truth_for` declared, or no commits since `synced_at`), use the pre-script's recent commits + your reading of the doc's content to form a candidate list.
207
87
 
208
- ## Phase 6: Validate
88
+ ## Phase 3: Per-commit diff (unclear cases only)
209
89
 
210
- Re-run both layers:
90
+ For commits whose subjects don't make the impact on your doc obvious, run:
211
91
 
212
92
  ```bash
213
- xtrm docs list --json
214
- xtrm docs cross-check --json --days 30
215
- python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py scan --json
93
+ git show <hash> -- <path1> <path2>
216
94
  ```
217
95
 
218
- Confirm updated docs no longer show as stale.
219
-
220
- ---
96
+ The `<paths>` should be paths your doc actually claims about (e.g. if the doc is `docs/cli-reference.md`, paths under `src/cli/` and `src/index.ts` are reasonable; paths under `pi/` are not unless the doc covers pi).
221
97
 
222
- ## Frontmatter Schema
98
+ Maximum 3 such calls per run. If 3 calls aren't enough, the commit set is too broad — emit `BLOCKED: too-many-unclear-commits` and ask for a narrower bead.
223
99
 
224
- All `docs/*.md` files require valid YAML frontmatter.
100
+ ## Phase 4: Edit
225
101
 
226
- ### Required Fields
102
+ For your one doc:
103
+ - Update content based on the gathered context.
104
+ - Bump frontmatter `version` (patch/minor/major per change) and `updated` (today).
105
+ - Stamp:
106
+ ```bash
107
+ python3 .xtrm/skills/default/sync-docs/scripts/drift_detector.py update-sync <YOUR_DOC>
108
+ ```
227
109
 
228
- | Field | Format | Example |
229
- |-------|--------|---------|
230
- | `title` | string | `"Hooks Reference"` |
231
- | `scope` | string | `hooks` |
232
- | `category` | enum | `reference` |
233
- | `version` | semver | `1.0.0` |
234
- | `updated` | date | `2026-03-22` |
110
+ Edit nothing else. CHANGELOG, README, other docs, source files — all off-limits.
235
111
 
236
- ### Valid Categories
112
+ ## Phase 5: Validate
237
113
 
238
- `api` | `architecture` | `guide` | `overview` | `plan` | `reference`
114
+ Re-run the filtered drift scan from Phase 2. Confirm your doc is no longer stale.
239
115
 
240
- ### Optional Fields
116
+ ## Final report
241
117
 
242
- | Field | Format | Use |
243
- |-------|--------|-----|
244
- | `description` | string | Brief summary |
245
- | `source_of_truth_for` | list of globs | Link to code areas |
246
- | `synced_at` | git hash | Drift checkpoint |
247
- | `domain` | list of tags | Categorization |
118
+ ```
119
+ DOC: <path>
120
+ VERDICT: <UPDATED | NO_CHANGE_NEEDED | BLOCKED>
121
+ COMMITS_REVIEWED: <hash1>, <hash2>, ...
122
+ EDITS: <one-line summary, or "none">
123
+ DRIFT_BEFORE: <stale | clean | unknown>
124
+ DRIFT_AFTER: <clean | n/a>
125
+ SUGGESTED_FOLLOWUPS: <other doc names that may need separate sync-docs runs — names only, never edited>
126
+ ```
248
127
 
249
- ---
128
+ ## References
250
129
 
251
- ## Command Selection Rules
130
+ - [Frontmatter schema](references/schema.md) — required/optional fields, categories, version-bump rules
131
+ - [Doc structure](references/doc-structure.md) — INDEX block regen, structure analyzer
252
132
 
253
- **`xtrm docs` first** for understanding current docs state:
254
- - `xtrm docs list --json` — inventory
255
- - `xtrm docs show --json` — frontmatter inspection
256
- - `xtrm docs cross-check --json` — drift, coverage gaps
133
+ ## Anti-patterns (forbidden by the mandatory rule)
257
134
 
258
- **Python scripts** for enforcement and sync internals:
259
- - `drift_detector.py` `synced_at` / `source_of_truth_for` checks
260
- - `doc_structure_analyzer.py` README bloat, missing docs, changelog gaps
261
- - `validate_metadata.py` / `validate_doc.py` — schema/index validation
262
- - `context_gatherer.py` scoped commit/issue context for sync decisions
135
+ - Reading source files by **any** tool, not just `Read`
136
+ - `git diff <a>..<b>` (range diffs) or `git show <hash>` without `--`
137
+ - Editing CHANGELOG / README / other docs / source files (unless that file IS the SCOPE doc)
138
+ - Auditing the docs/ tree
139
+ - Running `context_gatherer.py` with `--scope-path` or `--since-days` (broad)
140
+ - Re-fetching after compaction
141
+ - Continuing after a steer/stop
142
+ - "Let me also check X" loops
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+ # sync-docs pre-script: byte-capped context dump.
3
+ # Output is injected into the specialist prompt at run-time.
4
+
5
+ echo '=== Latest xt report (excerpt, 5KB cap) ==='
6
+ R=$(ls -1 .xtrm/reports/*.md 2>/dev/null | sort -r | head -1)
7
+ if [ -n "$R" ]; then
8
+ echo "FILE: $R"
9
+ head -c 5000 "$R"
10
+ echo
11
+ else
12
+ echo '(no reports found)'
13
+ fi
14
+ echo
15
+ echo '=== Recent master commits (20, 2KB cap) ==='
16
+ git log master --oneline -20 2>/dev/null | head -c 2000 || echo '(git unavailable)'
17
+ echo