xtrm-tools 0.5.36 → 0.5.38

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.
@@ -4,125 +4,265 @@ description: |
4
4
  Autonomous session close flow for xt worktree sessions. Use this skill whenever
5
5
  the user says "done", "finished", "wrap up", "close session", "ship it", "I'm done",
6
6
  "ready to merge", or similar. Also activate when all beads issues in the session
7
- are closed, or when the user explicitly runs /xt-end. This skill guides the agent
8
- through pre-flight checks, commit cleanup, PR creation via 'xt end', conflict
9
- resolution, and worktree cleanup handling every edge case so the agent doesn't
10
- need to figure it out from scratch.
7
+ are closed, or when the user explicitly runs /xt-end. This skill is designed for
8
+ headless/specialist use: it must make deterministic decisions, auto-remediate common
9
+ anomalies, and avoid clarification questions unless execution is truly blocked.
11
10
  ---
12
11
 
13
- # xt-end — Session Close Flow
12
+ # xt-end — Autonomous Session Close Flow
14
13
 
15
- You are closing an `xt` worktree session. The canonical CLI is `xt end`, but it has preconditions you need to satisfy first. Work through these stages in order.
14
+ You are closing an `xt` worktree session. The canonical CLI is `xt end`, but you must normalize the session first and automatically handle common anomalies.
16
15
 
17
- ## Stage 1 — Pre-flight: close all open work
16
+ ## Operating Mode
17
+
18
+ Default to **autonomous execution**:
19
+ - do not ask the user routine clarification questions
20
+ - prefer deterministic fallbacks over conversational review
21
+ - only stop when a real blocker prevents safe progress
22
+
23
+ ## Success States
24
+
25
+ Use these mental result classes while operating:
26
+ - `SUCCESS_PR_CREATED`
27
+ - `SUCCESS_PR_CREATED_WITH_WARNINGS`
28
+ - `BLOCKED_UNCLOSED_SESSION_WORK`
29
+ - `BLOCKED_NO_COMMITS`
30
+ - `BLOCKED_AUTH`
31
+ - `BLOCKED_CONFLICTS`
32
+ - `BLOCKED_DIRTY_UNCLASSIFIED_CHANGES`
33
+
34
+ ---
35
+
36
+ ## Stage 1 — Session Work Audit
18
37
 
19
38
  Run:
20
39
  ```bash
21
40
  bd list --status=in_progress
22
41
  bd list --status=open
42
+ git log --oneline @{upstream}..HEAD 2>/dev/null || git log --oneline origin/main..HEAD 2>/dev/null || git log --oneline
23
43
  ```
24
44
 
25
- If any issues are still open or in_progress, **do not proceed**. Guide the user to finish them first:
26
- - For in-progress work: complete it, then `bd close <id> --reason "what was done"`
27
- - For open issues that won't be done in this session: ask the user — close as deferred, or leave for next session?
45
+ Rules:
46
+ - **Block** on `in_progress` issues
47
+ - **Do not block** on unrelated open backlog issues
48
+ - infer **session-touched issues** from commit messages and recent session work
49
+ - if a touched issue is still not closed, close it if the work is complete; otherwise stop with `BLOCKED_UNCLOSED_SESSION_WORK`
28
50
 
29
- Only continue when `bd list --status=in_progress` returns empty (or the user explicitly says to skip unfinished issues).
51
+ This skill is stricter about unfinished session work than about unrelated backlog.
30
52
 
31
- ## Stage 2 — Uncommitted changes
53
+ ---
32
54
 
55
+ ## Stage 2 — Tree Normalization
56
+
57
+ Run:
33
58
  ```bash
34
- git status
59
+ git status --short
35
60
  ```
36
61
 
37
- If the working tree is dirty:
38
- - If the changes belong to a beads issue you just closed: `git add -A && git commit -m "<close_reason> (<id>)"` (or a descriptive summary)
39
- - If the changes are unrelated WIP: consider stashing with `git stash` and noting what was stashed
40
- - Never run `xt end` with a dirty working tree — it will abort with an error
62
+ If clean, continue.
41
63
 
42
- ## Stage 3 — Dry run (preview the PR)
64
+ If dirty:
65
+ - if the changes clearly belong to the just-finished session work, commit them automatically
66
+ - if they look like unrelated WIP, stash them with a labeled stash message
67
+ - never run `xt end` with a dirty tree
43
68
 
69
+ Preferred automatic actions:
70
+ ```bash
71
+ git add -A && git commit -m "<descriptive summary> (<issue-id>)"
72
+ # or
73
+
74
+ git stash push -m "xt-end:auto-stash before session close"
75
+ ```
76
+
77
+ If changes cannot be classified safely, stop with `BLOCKED_DIRTY_UNCLASSIFIED_CHANGES`.
78
+
79
+ ---
80
+
81
+ ## Stage 3 — Dry Run and Anomaly Detection
82
+
83
+ Run:
44
84
  ```bash
45
85
  xt end --dry-run
46
86
  ```
47
87
 
48
- This shows the PR title, body, files changed, and issues that will be linked. Review with the user:
49
- - Does the PR title accurately reflect the work?
50
- - Are all the right issues captured?
51
- - Is the scope correct?
88
+ Parse the preview and check for anomalies:
89
+
90
+ ### A. Generic PR title
91
+ Treat these as invalid:
92
+ - `session changes`
93
+ - `update`
94
+ - `updates`
95
+ - `misc`
96
+ - `wip`
97
+ - `work in progress`
98
+
99
+ Auto-remediation:
100
+ - prefer closed issue titles from this session
101
+ - otherwise infer from changed files / dominant area
102
+ - examples:
103
+ - `Add docs cross-check command and tests`
104
+ - `Integrate docs workflow with sync-docs`
105
+ - `Update docs workflow and CLI help`
106
+
107
+ ### B. Missing beads linkage
108
+ If dry-run says no beads issues were found, but commit messages contain issue-like IDs, treat that as a tooling mismatch.
109
+
110
+ Auto-remediation:
111
+ - extract issue IDs directly from commit messages
112
+ - continue with those IDs as manually inferred linkage
113
+ - report the mismatch in the final summary
114
+
115
+ ### C. Generated artifacts in scope
116
+ If files like `dist/` are included:
117
+ - keep them if the repo conventionally commits built artifacts
118
+ - otherwise revert them before continuing
119
+
120
+ Use repository history/common practice as the heuristic; do not ask.
121
+
122
+ ### D. Overscoped PR
123
+ Classify the PR scope into buckets:
124
+ - source
125
+ - tests
126
+ - docs
127
+ - skills
128
+ - generated artifacts
129
+
130
+ If all buckets support one coherent feature/change, continue.
131
+ If they look unrelated, continue but mark the PR as `WITH_WARNINGS` and mention overscope in the final report.
132
+
133
+ After auto-remediating anomalies, re-run:
134
+ ```bash
135
+ xt end --dry-run
136
+ ```
52
137
 
53
- If something looks wrong, adjust (e.g., add a missing commit message or close a forgotten issue) and re-run the dry run.
138
+ Repeat until the preview is acceptable or a hard blocker appears.
54
139
 
55
- ## Stage 4 — Run xt end
140
+ ---
141
+
142
+ ## Stage 4 — No-Commit / Session-Sanity Gate
56
143
 
144
+ Before actual execution, ensure the branch really has changes:
57
145
  ```bash
58
- xt end
146
+ git log --oneline @{upstream}..HEAD 2>/dev/null || git log --oneline origin/main..HEAD 2>/dev/null
59
147
  ```
60
148
 
61
- ### If it succeeds
62
- You'll see:
63
- - ✓ Rebased onto origin/<default-branch>
64
- - ✓ Pushed branch
65
- - ✓ PR created: <url>
66
- - ✓ Linked PR to N issue(s)
149
+ If there are no commits ahead of base, stop with `BLOCKED_NO_COMMITS`.
67
150
 
68
- Capture the PR URL for Stage 6.
151
+ ---
69
152
 
70
- ### If rebase conflicts occur
153
+ ## Stage 5 Run xt end
71
154
 
72
- `xt end` will abort cleanly with a list of conflicted files. Guide the agent through:
155
+ Run:
156
+ ```bash
157
+ xt end --yes
158
+ ```
159
+
160
+ Use non-interactive mode by default for autonomous execution.
73
161
 
162
+ ### If it succeeds
163
+ Capture:
164
+ - rebase success
165
+ - push success
166
+ - PR URL
167
+ - linked issue count
168
+
169
+ ### If rebase conflicts occur
170
+ Run:
171
+ ```bash
172
+ git status
173
+ ```
174
+
175
+ Resolve all conflict markers, then:
74
176
  ```bash
75
- git status # see conflicted files
76
- # Edit each conflicted file to resolve <<<< ==== >>>> markers
77
177
  git add <resolved-files>
78
178
  git rebase --continue
179
+ xt end --yes
79
180
  ```
80
181
 
81
- Then re-run `xt end`. If the conflicts are complex, explain what each file conflict is about before resolving.
82
-
83
- ### If the push fails
182
+ If conflicts are too complex to resolve safely, stop with `BLOCKED_CONFLICTS`.
84
183
 
85
- Usually a stale remote ref. Try:
184
+ ### If push fails
185
+ Try:
86
186
  ```bash
87
187
  git fetch origin
88
- xt end
188
+ xt end --yes
189
+ ```
190
+
191
+ ### If `gh` auth fails
192
+ Stop with `BLOCKED_AUTH` and report:
193
+ ```bash
194
+ gh auth login
89
195
  ```
90
196
 
91
- ## Stage 5 — Worktree cleanup
197
+ ---
92
198
 
93
- After a clean PR creation, ask the user:
199
+ ## Stage 6 Autonomous Cleanup
94
200
 
95
- > "PR is open at <url>. Should I remove this worktree? (Recommended: yes, since the branch is pushed and the PR is open. Keep only if you plan to do follow-up work here.)"
201
+ Default behavior: **remove the worktree automatically** after a successful PR creation.
96
202
 
97
- Default recommendation: **remove** (the branch is safe on remote, the worktree is just disk space).
203
+ Rationale:
204
+ - branch is pushed
205
+ - PR is open
206
+ - worktree is disposable local state
98
207
 
99
- If removing:
208
+ If cleanup is needed after `xt end --yes`:
100
209
  ```bash
101
- xt end --keep # was already run; use git worktree remove directly
102
210
  git worktree remove <path> --force
103
211
  ```
104
212
 
105
- Or if `xt end` was run interactively, it already prompted for this just confirm.
213
+ Keep the worktree only if an explicit keep policy exists (for example, known immediate follow-up work on the same branch).
214
+
215
+ ---
106
216
 
107
- ## Stage 6 — Report
217
+ ## Stage 7Final Report
108
218
 
109
- Tell the user:
219
+ Always report:
220
+ - final result class (`SUCCESS_PR_CREATED` or `SUCCESS_PR_CREATED_WITH_WARNINGS`)
110
221
  - PR URL
111
- - Which issues were linked
112
- - Reminder: "Monitor CI — merge when green. No auto-merge."
222
+ - linked or inferred issues
223
+ - whether anomalies were auto-remediated
224
+ - whether the worktree was removed
225
+ - reminder: monitor CI and merge when green; no auto-merge assumption
113
226
 
114
- If the worktree was removed: confirm that too.
227
+ If linkage had to be inferred from commits rather than detected by `xt end`, say so explicitly.
115
228
 
116
229
  ---
117
230
 
118
- ## Edge cases
231
+ ## Edge Cases
232
+
233
+ **Already on main/master/default branch**
234
+ - stop immediately; this is not an xt worktree session
235
+
236
+ **No commits yet on branch**
237
+ - stop with `BLOCKED_NO_COMMITS`
238
+
239
+ **Dirty tree with unclear ownership**
240
+ - stop with `BLOCKED_DIRTY_UNCLASSIFIED_CHANGES`
119
241
 
120
- **Already on main/master branch**: `xt end` will error — you're not in an xt session. Don't run it from the default branch.
242
+ **`gh` not authenticated**
243
+ - stop with `BLOCKED_AUTH`
121
244
 
122
- **No commits yet on branch**: The PR will have no changes. This usually means something went wrong earlier. Verify with `git log origin/<default-branch>..HEAD` (where default-branch is main or master).
245
+ **beads unavailable**
246
+ - continue PR creation if possible
247
+ - infer issues from commit messages when available
248
+ - report linkage as unavailable/manual
123
249
 
124
- **`gh` CLI not authenticated**: `gh pr create` will fail. Fix: `gh auth login`, then re-run `xt end`.
250
+ **Multiple anomalies at once**
251
+ - remediate in order:
252
+ 1. dirty tree
253
+ 2. missing commits
254
+ 3. generic title
255
+ 4. missing issue linkage
256
+ 5. generated artifacts
257
+ 6. overscope warning
125
258
 
126
- **Multiple conflicts**: Resolve all files before `git rebase --continue`. If `git status` shows unmerged paths, keep resolving.
259
+ ## Policy Summary
127
260
 
128
- **beads not available**: `xt end` gracefully skips beads linkage if `bd` isn't running. The PR still gets created. Let the user know.
261
+ The autonomous rule is simple:
262
+ - normalize the session
263
+ - dry-run
264
+ - auto-fix predictable anomalies
265
+ - rerun dry-run
266
+ - execute non-interactively
267
+ - clean up automatically
268
+ - stop only on genuine safety blockers
@@ -4,11 +4,12 @@ description: >-
4
4
  Doc audit and structural sync for xtrm projects. Use whenever the README
5
5
  feels too long, docs are out of sync after a sprint, the CHANGELOG is behind,
6
6
  or the user asks to "sync docs", "doc audit", "split readme", "check docs
7
- health", or "detect drift". Reads bd issues and git history, then runs
8
- docs-only drift detection on README.md, CHANGELOG.md, and docs/ — creating
9
- missing focused files instead of a monolithic README.
7
+ health", or "detect drift". Prefer the xtrm docs command suite (`xtrm docs
8
+ list`, `xtrm docs show`, `xtrm docs cross-check`) for operator-facing
9
+ inspection, then use docs-only drift detection on README.md, CHANGELOG.md,
10
+ and docs/ plus the Python analyzers as validation/backstop tools.
10
11
  gemini-command: sync-docs
11
- version: 1.2.0
12
+ version: 1.3.0
12
13
  ---
13
14
 
14
15
  # sync-docs
@@ -19,18 +20,37 @@ Keeps project documentation in sync with code reality.
19
20
 
20
21
  ```
21
22
  Phase 1: Gather context — what changed recently?
22
- Phase 2: Detect docs driftwhich docs/ files are stale?
23
- Phase 3: Analyze structurewhat belongs outside README?
24
- Phase 4: Plan + execute fix docs and changelog
25
- Phase 5: Validate schema-check all docs/
23
+ Phase 2: Inspect with xtrmwhat does the docs suite already report?
24
+ Phase 3: Detect docs driftwhich docs/ files are stale?
25
+ Phase 4: Analyze structure what belongs outside README?
26
+ Phase 5: Plan + execute fix docs and changelog
27
+ Phase 6: Validate — schema-check all docs/
26
28
  ```
27
29
 
28
- **Audit vs Execute mode:** If the user asked for an audit/report/check-only task, stop after Phase 3. Only run fixes when the user explicitly asks for changes.
30
+ **Preferred workflow:** use the `xtrm docs` command suite first for human/operator-facing inspection, then use the Python scripts for drift validation, structure analysis, metadata checks, and sync checkpoints.
31
+
32
+ **Audit vs Execute mode:** If the user asked for an audit/report/check-only task, stop after Phase 4. Only run fixes when the user explicitly asks for changes.
29
33
 
30
34
  ---
31
35
 
32
36
  ## Phase 1: Gather Context
33
37
 
38
+ Start with the user-facing docs suite so the agent sees the same command surfaces users do:
39
+
40
+ ```bash
41
+ xtrm docs list
42
+ xtrm docs list --json
43
+ xtrm docs show --json
44
+ xtrm docs cross-check --json --days 30
45
+ ```
46
+
47
+ Use these commands for:
48
+ - `xtrm docs list` — inventory docs files, paths, titles, types, and cache-backed scans
49
+ - `xtrm docs show --json` — inspect frontmatter for README, CHANGELOG, and `docs/*.md`
50
+ - `xtrm docs cross-check --json` — gather stale-doc, coverage-gap, and open-issue-ref signals
51
+
52
+ Then gather deeper repository context if needed:
53
+
34
54
  ```bash
35
55
  # Global install
36
56
  python3 "$HOME/.agents/skills/sync-docs/scripts/context_gatherer.py" [--since=30]
@@ -47,7 +67,30 @@ Outputs JSON with:
47
67
 
48
68
  ---
49
69
 
50
- ## Phase 2: Detect docs/ Drift
70
+ ## Phase 2: Inspect with `xtrm docs`
71
+
72
+ Treat the CLI docs suite as the primary operator workflow:
73
+
74
+ ```bash
75
+ xtrm docs --help
76
+ xtrm docs list --json
77
+ xtrm docs show --json
78
+ xtrm docs cross-check --json --days 30
79
+ ```
80
+
81
+ Use it to answer:
82
+ - what docs currently exist?
83
+ - which docs have missing or outdated metadata?
84
+ - are there coverage gaps between recent work and docs?
85
+ - do docs reference open issues?
86
+
87
+ If the xtrm docs suite already isolates the problem clearly, proceed directly to fixes. If you need machine-level drift validation for `docs/*.md`, continue to the Python drift detector.
88
+
89
+ ---
90
+
91
+ ## Phase 3: Detect docs/ Drift
92
+
93
+ Use the Python detector as the authoritative drift/backstop check for tracked `docs/*.md` pages:
51
94
 
52
95
  ```bash
53
96
  python3 "skills/sync-docs/scripts/drift_detector.py" scan --since 30
@@ -82,7 +125,7 @@ This sets `synced_at` to current HEAD, marking the doc as synced.
82
125
 
83
126
  ---
84
127
 
85
- ## Phase 3: Analyze Document Structure
128
+ ## Phase 4: Analyze Document Structure
86
129
 
87
130
  ```bash
88
131
  python3 "skills/sync-docs/scripts/doc_structure_analyzer.py"
@@ -96,11 +139,13 @@ Checks:
96
139
 
97
140
  Statuses: `BLOATED`, `EXTRACTABLE`, `MISSING`, `STALE`, `INVALID_SCHEMA`, `OK`.
98
141
 
99
- If this is audit-only, stop here and report.
142
+ If this is audit-only, stop here and report. In the report, include both:
143
+ - `xtrm docs` findings (operator-facing)
144
+ - Python analyzer findings (drift/structure enforcement)
100
145
 
101
146
  ---
102
147
 
103
- ## Phase 4: Execute Fixes
148
+ ## Phase 5: Execute Fixes
104
149
 
105
150
  | Situation | Action |
106
151
  |---|---|
@@ -131,6 +176,16 @@ python3 "skills/sync-docs/scripts/validate_doc.py" --generate docs/hooks.md \
131
176
  python3 "skills/sync-docs/scripts/validate_metadata.py" docs/
132
177
  ```
133
178
 
179
+ ### Re-run xtrm docs suite after fixes
180
+
181
+ ```bash
182
+ xtrm docs list --json
183
+ xtrm docs show --json
184
+ xtrm docs cross-check --json --days 30
185
+ ```
186
+
187
+ Use this pass to confirm the user-facing docs workflow now reflects the repaired state before final validation.
188
+
134
189
  ### Add changelog entry
135
190
 
136
191
  ```bash
@@ -140,13 +195,20 @@ python3 "skills/sync-docs/scripts/changelog/add_entry.py" \
140
195
 
141
196
  ---
142
197
 
143
- ## Phase 5: Final Validation
198
+ ## Phase 6: Final Validation
199
+
200
+ Run both layers:
144
201
 
145
202
  ```bash
203
+ xtrm docs list --json
204
+ xtrm docs show --json
205
+ xtrm docs cross-check --json --days 30
146
206
  python3 "skills/sync-docs/scripts/validate_doc.py" docs/
147
207
  python3 "skills/sync-docs/scripts/drift_detector.py" scan --since 30
148
208
  ```
149
209
 
210
+ The `xtrm docs` commands confirm the end-user/operator view; the Python tools confirm schema and tracked-doc drift guarantees.
211
+
150
212
  ---
151
213
 
152
214
  ## Frontmatter Schema
@@ -208,3 +270,17 @@ title: What's New in v2.0
208
270
  `docs/` is the only source of truth for project documentation in this workflow.
209
271
  Scripts validate `docs/*.md` only — subdirectories (`docs/plans/`, `docs/reference/`) are ignored.
210
272
  Use frontmatter (`source_of_truth_for`) to link docs pages to code areas and detect drift.
273
+
274
+ ## Command Selection Rules
275
+
276
+ Use `xtrm docs` commands first when the task is about understanding the current docs state:
277
+ - `xtrm docs list --json` → inventory and filtering
278
+ - `xtrm docs show --json` → frontmatter inspection
279
+ - `xtrm docs cross-check --json` → recent-work drift, coverage gaps, open issue refs
280
+
281
+ Use Python scripts when the task is about enforcement or synchronization internals:
282
+ - `drift_detector.py` → `synced_at` / `source_of_truth_for` drift checks for `docs/*.md`
283
+ - `doc_structure_analyzer.py` → README bloat, missing focused docs, changelog version gaps
284
+ - `validate_metadata.py` / `validate_doc.py` → schema/index validation
285
+
286
+ Do not replace the Python tools with `xtrm docs`; use the CLI for operator-facing inspection and the scripts for authoritative structural validation.
@@ -19,10 +19,12 @@ priority: high
19
19
  ```bash
20
20
  bd prime # load workflow context + active claims
21
21
  bd memories <today's topic> # retrieve relevant past context
22
- bd ready # find available work
22
+ bv --robot-triage # graph-ranked picks, quick wins, unblock targets
23
23
  bd update <id> --claim # claim before any edit
24
24
  ```
25
25
 
26
+ > Use `bv --robot-next` for the single top pick. Use `bv --robot-triage --format toon` to save context tokens. **Never run bare `bv` — it launches an interactive TUI.**
27
+
26
28
  ---
27
29
 
28
30
  ## Trigger Patterns
@@ -30,6 +32,7 @@ bd update <id> --claim # claim before any edit
30
32
  | Situation | Action |
31
33
  |-----------|--------|
32
34
  | User prompt contains `?` | `bd memories <keywords>` before answering — check stored context first |
35
+ | "What should I work on?" | `bv --robot-triage` — ranked picks with dependency context |
33
36
  | "What was I working on?" | `bd list --status=in_progress` |
34
37
  | Unfamiliar area of code | `gitnexus_query({query: "concept"})` before opening any file |
35
38
  | About to edit a symbol | `gitnexus_impact({target: "name", direction: "upstream"})` |