@ai-atomic-framework/cli 0.1.14 → 0.1.16

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.
@@ -0,0 +1,469 @@
1
+ # Advanced Governed Routes
2
+
3
+ Use this skill when a user asks in natural language to inspect, rank, clean up,
4
+ refactor, split, atomize, infect, migrate, or modernize existing source code.
5
+
6
+ The goal is to keep the user request natural while still routing the work
7
+ through ATM evidence before choosing a local implementation path.
8
+
9
+ ## Selective Learning Loop
10
+
11
+ When the router basically worked but the agent still felt friction, near-bypass,
12
+ or repeated uncertainty, do not read a monolithic lesson log by default.
13
+
14
+ Read order:
15
+
16
+ 1. Read `references/index.md`.
17
+ 2. Pick only the single shard that matches the current symptom.
18
+ 3. Stop after the first relevant shard unless the blocker still remains
19
+ unresolved.
20
+ 4. Prefer durable rules already promoted into this `SKILL.md` or `atm-next`;
21
+ use the shard files for examples, edge cases, and recovery patterns.
22
+
23
+ ## Captain/Dispatch Entry Gate
24
+
25
+ If the user asks for Captain, Coordinator, dispatch, task cards, sidecars,
26
+ subagents, delegation, condition review, or closeout work, first route the
27
+ request through `ai-role-router` when available, then through `atm-dispatch`
28
+ before drafting instructions, delegating work, or reviewing another agent.
29
+
30
+ State `Skill used: atm-dispatch` and the chosen `Delegation mode`. Internal
31
+ sidecar is the default for review, preflight, grep, checklist, planning-only
32
+ checks, and post-report verification. External dispatch is opt-in, and external
33
+ write is forbidden unless the user explicitly grants write authority and scope.
34
+
35
+ ## Highest Parallel Governance Principle
36
+
37
+ ATM parallel governance uses a Tier model:
38
+
39
+ - Reads never queue behind write lanes.
40
+ - Private writes to the actor's own ledger, evidence, notes, or planning
41
+ artifacts never queue behind unrelated lanes.
42
+ - Shared writes to the git index, release mirrors, build artifacts, protected
43
+ runtime state, or other shared mutation surfaces go through the broker, which
44
+ answers with a ticket: execute now, enqueue with a position, or batch into a
45
+ shared write window. A bare refusal at a shared-write gate is charter debt
46
+ (INV-ATM-008), not a design choice.
47
+
48
+ The only standing serialization exceptions are the four owner-ruled cases in
49
+ `docs/governance/parallel-governance-charter.md` (one lane session per task
50
+ card; dependency gates block code only, never documents; the single-branch
51
+ commit core with related-task batching only; document writes are ungoverned,
52
+ code writes are always governed). Any new serialization point must be surfaced
53
+ to the project owner for an explicit ruling before it ships.
54
+
55
+ Use this model before widening a blocker. A natural-language request for
56
+ inspection, planning, evidence, or private ledger work should remain parallel
57
+ unless ATM identifies a concrete Tier 2 shared surface intersection.
58
+
59
+ ## Cohesion-First Split Rule
60
+
61
+ TASK-SKL-0020 promoted this rule and TASK-SKL-0028 keeps it in the skill corpus
62
+ canary set: split work by cohesion before splitting by ticket count. A proposed
63
+ "to-tickets" breakdown is healthy only when each card owns one behavior,
64
+ interface, evidence contract, or rollback boundary. If a split would scatter
65
+ one behavior across several cards merely to reduce file count or make smaller
66
+ claims, keep it as one card or create a provider-neutral review receipt first.
67
+
68
+ For skill-template or integration projection work, source templates are the
69
+ authority. Installed copies and adapter projections must come from a sealed
70
+ corpus source snapshot and must report source digest, compiler version,
71
+ degradation diagnostics, and manifest digest.
72
+
73
+ ## Delivery Principle
74
+
75
+ The objective is to deliver the task content, not to close task cards. A task
76
+ card is a delivery contract. `done` is only the record after the requested
77
+ code, data, pipeline, document, or artifact exists and validators/evidence pass.
78
+
79
+ Do not optimize for making many cards become `done`. Optimize for producing the
80
+ requested non-.atm deliverables for the current task or current batch queue
81
+ head.
82
+
83
+ ## Governance Flow Backwrite
84
+
85
+ For Captain, dispatch, handoff, evidence, closeout, and first-layer governance
86
+ work, promote only stable rules into reusable skills. Historical task status,
87
+ dirty worktree residue, local commit shas, actor ids, queue ids, and
88
+ date-bound incident instructions belong in task evidence, backlog, handoff, or
89
+ learning references, not in this entry skill.
90
+
91
+ Before implementation on a governed card, record an opening data-driven
92
+ decision in the task evidence, close summary, or dispatch report:
93
+
94
+ - consumed sealed summaries;
95
+ - missing data;
96
+ - assumption changes;
97
+ - stop rule;
98
+ - whether the card adds, removes, or touches a shared-write gate.
99
+
100
+ For every shared-write gate touched by the route, apply the `INV-ATM-008`
101
+ check before accepting a blocker as normal: did the workflow turn a
102
+ coordinatable shared write into a bare refusal or terminal block, and is that
103
+ refusal one of the owner-ruled exceptions? If not, route through a broker
104
+ ticket, compose/steward path, queue ticket, or backlog item instead of
105
+ normalizing the refusal.
106
+
107
+ For repairs, follow `INV-ATM-009`: derive behavior from schemas, registries,
108
+ configuration, observed counters, canonical ErrorCodes, capability payloads,
109
+ or compact digest evidence. Do not hard-code task ids, actor ids, queue names,
110
+ local absolute paths, dates, or one incident's error string unless the task
111
+ records why the general rule is unsafe or infeasible.
112
+
113
+ Before closeout, check that evidence and telemetry include a window,
114
+ watermark, counters, duration/timing, source availability, compact digest, and
115
+ explicit unavailable receipts where data is missing. Raw runtime logs should
116
+ remain in runtime or gitignored storage; tracked history should carry compact
117
+ evidence.
118
+
119
+ If the route changes runner, release, broker shared-write behavior,
120
+ first-layer entry behavior, skill template projection, or generated
121
+ integration output, source tests alone are insufficient. Rebuild the frozen
122
+ runner when ATM says it is stale and run a frozen-entry smoke or probe before
123
+ claiming delivery.
124
+
125
+ If the natural-language request mentions a task id, task card, plan document, or
126
+ scoped task batch, invoke `atm-task-intent-resolver` first. It must write
127
+ `.atm/runtime/task-intent.json` from semantic reading of the user prompt and then
128
+ call:
129
+
130
+ ```bash
131
+ node atm.mjs next --intent .atm/runtime/task-intent.json --json
132
+ ```
133
+
134
+ Do not rely on keyword-only `next --prompt` extraction when the task intent
135
+ resolver skill is available.
136
+
137
+ Apply the Actor Identity Handoff Gate in the primary entry before taking authority.
138
+
139
+ ## Tool-First Orchestration
140
+
141
+ Every CLI example in this reference is conditional on the loaded runtime
142
+ capability and the current route. A sample is neither availability nor authority.
143
+
144
+ Prefer a structured ATM tool or editor connector before shelling out when the
145
+ environment exposes one. Treat a blocked tool result as route truth: surface its
146
+ status, reason, `allowedCommands`, `blockedCommands`, user notice, and
147
+ `evidence.nextAction.command` before choosing any fallback.
148
+
149
+ Use CLI fallback only for read-only inspection, legacy editors, explicit user
150
+ fallback, unavailable tools, or a fallback command named by the structured
151
+ result. Do not replace a blocked tool route with an ad hoc shell workaround.
152
+
153
+ Keep this router thin. After `next`, `next --claim`, or the task-intent
154
+ resolver returns, delegate sequencing to `evidence.nextAction.playbook` and
155
+ specialist skills such as `atm-next`, `atm-evidence`, `atm-lock`,
156
+ `atm-dispatch`, and Team role packs. Preserve shared Team Agents fields when
157
+ they appear: `teamLevel`, `runtimeTier`, `decisionClass`, `decisionReason`,
158
+ `requiresHumanSignoff`, `requiresAdr`, `violationStatus`,
159
+ `escalationTarget`, and `broker-conflict-blocked`.
160
+
161
+ For Team Agents work, do not rely on the older assumption that `team start`
162
+ always means "no execution." Plain `team start` is still state-only, but
163
+ `team start --execute` is a governed provider orchestration lane. Route crew
164
+ completeness with `--team-size L1..L5`, route per-role providers with
165
+ `--role-provider role=provider:model[:sdk][:mode]`, and keep
166
+ `broker-conflict-blocked` as a hard gate.
167
+
168
+ ## After First-Run Inspection
169
+
170
+ Use the primary entry first. The following examples are conditional on the
171
+ loaded runtime capability contract and the selected playbook; do not execute
172
+ an unsupported sample or substitute a sample for the returned command.
173
+
174
+ ```bash
175
+ node atm.mjs next --prompt "$ARGUMENTS" --json
176
+ ```
177
+
178
+ If the first command returns a user notice, surface it briefly, then continue the
179
+ original user request.
180
+
181
+ ## First-Layer Command Contract
182
+
183
+ For backlog, audit, optimization, and create prompts, inspect the canonical
184
+ first-layer matrix before falling back to CLI discovery:
185
+
186
+ ```bash
187
+ node atm.mjs guide first-layer --json
188
+ ```
189
+
190
+ The matrix is `intent -> route -> command -> authority -> negative case`.
191
+ Backlog, audit, and governance/product optimization prompts are docs-first or
192
+ read-only status work until a scoped task/backlog record exists; they must not
193
+ fall through to `create-atom`. Explicit atom birth keeps the
194
+ `node atm.mjs guide create-atom --json` path.
195
+
196
+ Normal release/checkpoint/backlog/audit syntax should be visible from this
197
+ first layer:
198
+
199
+ ```bash
200
+ node atm.mjs broker release --task <task-id> --actor <actor> --json
201
+ node atm.mjs batch checkpoint --actor <actor> --json
202
+ node atm.mjs guide first-layer --json
203
+ node atm.mjs tasks audit --json
204
+ ```
205
+
206
+ Default `next` output is compact: it keeps blocker/status, recommended action,
207
+ ticket state, queue/revalidation/reconcile hints, and validator summary. Use
208
+ `--verbose --json` only when you need the full duplicated playbook body, large
209
+ file lists, or complete diagnostic arrays.
210
+
211
+ Ticket states are route truth. Preserve distinct next actions for
212
+ `execute-now`, `batch/applyStrategy=compose`,
213
+ `queue(position/head/health/waitedMs/release condition)`,
214
+ `revalidation-required`, `reconcile-required`, and R1 `ATM_LOCK_CONFLICT`.
215
+ Queued, compose, revalidation, and reconcile states are ticket/status states,
216
+ not new ErrorCodes. A waiting shared write still permits reads, docs, private
217
+ evidence, and isolated proposals; only intersecting dependent code side effects
218
+ are restricted.
219
+
220
+ For Windows Markdown/JSON/text planning docs, use Node UTF-8 reads and `rg`
221
+ searches:
222
+
223
+ ```bash
224
+ node -e "const fs=require('node:fs'); console.log(fs.readFileSync(process.argv[1],'utf8').slice(0,4000))" -- <file.md>
225
+ rg "pattern" <path>
226
+ rg --files <path>
227
+ ```
228
+
229
+ Do not recommend PowerShell range indexing or document parsing for planning
230
+ documents.
231
+
232
+ If `evidence.nextAction.governanceReadiness` is present, prepare those items
233
+ before you reach commit or push. Treat framework claim, protected push
234
+ evidence, `doctor`, and branch queue retry codes as early blockers, not as
235
+ something to discover only after a hook or push failure.
236
+
237
+ Turn `evidence.nextAction.governanceReadiness` into an immediate preparation
238
+ checklist before implementation:
239
+
240
+ 1. Resolve actor identity now, not at commit time.
241
+ 2. If framework claim is required, inspect `node atm.mjs framework-mode status --json` and acquire the returned `framework-mode claim` before editing framework-critical files. If the same actor left behind a stale-completed temporary framework lock, retry `framework-mode claim` directly and let ATM auto-reconcile it; do not invent a skill-side lock override.
242
+ 3. If the route is on a protected or shared branch, run `node atm.mjs doctor --json` before the first governed write so readiness blockers surface early.
243
+ 4. Use `governanceReadiness.upstreamRef` when present and run `node atm.mjs hook pre-push --base <upstream-ref> --head HEAD --json` proactively before the final push, or earlier once the branch is ahead, so git-head evidence and branch-queue blockers show up before the real push.
244
+ 5. Treat `queueRetryCodes` as a shared-branch retry contract, not as an unexpected raw Git failure.
245
+
246
+ Only for a positively identified framework target, when the loaded runtime exposes `framework-mode`, inspect framework mode before editing implementation files:
247
+
248
+ ```bash
249
+ node atm.mjs framework-mode status --json
250
+ ```
251
+
252
+ If the result mode is `required` or `cross-repo-target-required`, do not hand-edit
253
+ task status to `done`, do not bulk-close task cards, and do not treat static
254
+ `atomic_workbench/evidence/*.json` files as completion evidence. Claim/lock the
255
+ task, run `guard framework-development`, `tasks audit`, `doctor`, and the
256
+ required validators before closing with `tasks close`.
257
+
258
+ Before you consider implementation "finished", do one local static-hygiene
259
+ pass on the code you actually touched:
260
+
261
+ 1. Fix syntax, import, and type errors that appear in the touched scope immediately instead of deferring them to CI or another agent.
262
+ 2. Treat adapter-native static warnings in touched or staged files as part of the same delivery when the repair is straightforward and low-risk.
263
+ 3. Do not use this rule to justify repo-wide cleanup drift; keep the cleanup narrow unless the route explicitly broadens scope.
264
+ 4. Prefer lifting this habit into the operator workflow first, then let hooks and validators harden it later.
265
+
266
+ For ordinary task-card delivery, the lifecycle remains:
267
+
268
+ ```text
269
+ claim -> implement -> validators -> evidence add -> tasks close -> commit
270
+ ```
271
+
272
+ Framework critical files only change the close/commit timing when the close gate
273
+ blocks a live critical diff. If `tasks close` reports
274
+ `ATM_TASK_CLOSE_FRAMEWORK_DIFF_ACTIVE`, do not bypass the gate. Make a governed
275
+ delivery commit for the scoped non-`.atm` deliverables, then run:
276
+
277
+ ```bash
278
+ node atm.mjs tasks close --task <task-id> --actor "$ATM_ACTOR_ID" --status done --historical-delivery <commit> --json
279
+ ```
280
+
281
+ After close succeeds, make a separate closure commit for the generated ATM
282
+ ledger updates. This historical-delivery path still requires validators and
283
+ command-backed evidence; it is not a relaxed closure rule.
284
+
285
+ ## ATM-Only Execution Route
286
+
287
+ Raw Git mutation, `node -e` / `node --eval`, PowerShell write commands such as
288
+ `Set-Content`, `cmd /c`, and `bash -c` are not approved worker routes for any
289
+ cleanup, refactor, or migration goal this router selects. The only normal
290
+ mutation path is the ATM command returned by the current playbook, diagnostic,
291
+ or recovery hint for the selected route.
292
+
293
+ Do not reconstruct that command from this text. Read it from the ATM output
294
+ (`evidence.nextAction.command`, `evidence.nextAction.playbook`, or the blocking
295
+ message's `requiredCommand`) and run exactly that.
296
+
297
+ This warning is not an authorization. Permission comes only from a
298
+ `RestrictedExecutionGateway` allow decision, projected as
299
+ `evidence.executionSurfacePolicy`. An override phrase in chat, a sentence in a
300
+ routing document, or an environment variable never unlocks a denied command.
301
+
302
+ This restriction covers ATM-managed worker and integration execution. It does
303
+ not try to sandbox an ordinary human local shell outside that runtime.
304
+
305
+ ## Route Command
306
+
307
+ ```bash
308
+ node atm.mjs guide --goal "$ARGUMENTS" --cwd . --json
309
+ ```
310
+
311
+ This route is also referred to as the `atm guide --goal` workflow in validator
312
+ evidence and release documentation.
313
+
314
+ Validator shorthand terms for this route are `atm guide --goal`, `atm candidates rank`, `atm start --legacy-flow`, `atm next`, `dry-run proposal`, and `human review`.
315
+
316
+ Follow the returned `nextCommand`. If the matched intent is
317
+ `legacy-candidate-ranking`, run the candidate ranking command before doing local
318
+ source analysis by hand. If the matched intent is `task-plan-import`, run the
319
+ task import dry run before creating or editing any task files.
320
+
321
+ Before mutating repository files for implementation work, claim the prompt-scoped task:
322
+
323
+ ```bash
324
+ node atm.mjs next --claim --actor "$ATM_ACTOR_ID" --prompt "$ARGUMENTS" --json
325
+ ```
326
+
327
+ If the claim result says `recommendedChannel: "batch"`, the governed route is:
328
+
329
+ 1. Read `evidence.nextAction.playbook` before editing. Treat it as the
330
+ step-by-step work order for this request.
331
+ 2. Run `node atm.mjs next --claim --actor "$ATM_ACTOR_ID" --prompt "$ARGUMENTS" --json`.
332
+ 3. Deliver the current queue head only.
333
+ 4. Run validators and add command-backed evidence for that queue-head deliverable.
334
+ 5. Run `node atm.mjs batch checkpoint --actor "$ATM_ACTOR_ID" --json`.
335
+ 6. Commit only after checkpoint succeeds, and commit the deliverables together
336
+ with `.atm/history/tasks/<task>.json`,
337
+ `.atm/history/evidence/<task>.json`, and
338
+ `.atm/history/task-events/<task>/`.
339
+ 7. Continue with the next queue head returned by the checkpoint response.
340
+
341
+ Do not manually loop through `tasks reserve`, `tasks promote`, `tasks claim`,
342
+ `tasks close`, or old close commits. That is governance bypass, not batch.
343
+ Do not commit before `batch checkpoint` succeeds.
344
+
345
+ If `recommendedChannel` is `fast` or `normal`, still read
346
+ `evidence.nextAction.playbook` first. It tells you the exact claim, evidence,
347
+ close, and commit order for that channel.
348
+
349
+ ATM's default task ledger is the active flow monitor when `taskLedger.enabled`
350
+ is true. Use the repo-local `.atm/history/tasks` store for adopter work; use the
351
+ ATM framework repo ledger only when `framework-mode status` reports
352
+ `framework-development`. If the user provides an external task (GitHub Issue,
353
+ Jira, Linear, or another provider) and no ATM mirror exists yet, create the
354
+ visible mirror before implementation:
355
+
356
+ ```bash
357
+ node atm.mjs tasks mirror --provider <provider> --origin-task <id> --origin-url <url> --actor "$ATM_ACTOR_ID" --json
358
+ ```
359
+
360
+ A write-intent claim mints the task admission ticket; do not invent a second
361
+ `write-ticket` command or copy a ticket between tasks. Pre-tool hooks may ask
362
+ ATM to project that ticket early, but unsupported editors still meet the same
363
+ Police, review, commit, close, push, and protected-branch gates. If a gate
364
+ reports missing, stale, wrong-scope, or recovery-required ticket coverage,
365
+ stop and follow its returned recovery command. The ticket is authority data in
366
+ the task ledger; this skill only explains the route.
367
+
368
+ ## Required Evidence
369
+
370
+ For legacy candidate ranking, final reasoning should cite or create:
371
+
372
+ - ATM guidance result
373
+ - candidate ranking artifact
374
+ - source inventory artifact
375
+ - police artifact
376
+ - recommended split, atomize, infect, or compose route
377
+
378
+ For task plan import, final reasoning should cite or create:
379
+
380
+ - ATM guidance result
381
+ - task import dry-run manifest
382
+ - written `.atm/history/tasks/*.json` paths, when `--write` is used
383
+ - task import evidence report path
384
+ - `tasks verify` report
385
+ - `next` result showing imported open work items, when available
386
+
387
+ ## Task Plan Import Route
388
+
389
+ If the matched intent is `task-plan-import`, run the dry-run import first:
390
+
391
+ ```bash
392
+ node atm.mjs tasks import --from <plan.md> --dry-run --cwd . --json
393
+ ```
394
+
395
+ Confirm the parsed manifest before persisting. When the manifest looks correct,
396
+ run the write phase and verify:
397
+
398
+ ```bash
399
+ node atm.mjs tasks import --from <plan.md> --write --cwd . --json
400
+ node atm.mjs tasks verify --cwd . --json
401
+ ```
402
+
403
+ Do not hand-write `.atm/history/tasks/*.json` and do not reuse `atm create` for
404
+ work-item import; `atm create` is for atom birth.
405
+
406
+ ## Guided Fallback
407
+
408
+ If preferred documents are missing, do not stop and do not silently improvise.
409
+ Preserve the fallback contract from ATM output:
410
+
411
+ - `missingDocs[]`
412
+ - `fallbackSources[]`
413
+ - `continuedOriginalRequest: true`
414
+
415
+ Then continue the user's original request with the fallback sources.
416
+
417
+ ## Guardrails
418
+
419
+ - Do not rank legacy scripts with ad-hoc shell-only heuristics when ATM can
420
+ produce candidate ranking evidence.
421
+ - Do not choose split, atomize, or infect before candidate ranking and police
422
+ evidence exist.
423
+ - Do not mutate host files during candidate ranking; ranking is advisory until
424
+ a later governed dry run is selected.
425
+ - Do not treat task closure as the work. Implement the task's requested
426
+ deliverables first, then close.
427
+ - Do not hand-roll batch task completion with low-level task lifecycle commands;
428
+ if `recommendedChannel` is `batch`, finish each queue head with
429
+ `node atm.mjs batch checkpoint --actor "$ATM_ACTOR_ID" --json`.
430
+ - Do not start implementation edits before a task is in `ready` and has an
431
+ active claim.
432
+ - Do not bypass the default task ledger when it is enabled; task status changes
433
+ must go through `tasks create/import/mirror/claim/block/close/abandon`.
434
+ - Do not mark task cards `done` by editing Markdown or JSON directly; use
435
+ `node atm.mjs tasks close --status done` so closure evidence is checked.
436
+ - Do not bulk-complete multiple tasks without a bulk closure manifest and one
437
+ closure packet per task.
438
+ - Do not use static JSON evidence files as proof of completion unless they carry
439
+ command runs with exit codes and output hashes.
440
+ - Do not move heavy checks (build/lint/network) into hooks; hooks should only
441
+ call thin ATM guard commands.
442
+ - Do not normalize a habit where agents leave fresh syntax, type, lint, or
443
+ adapter-native warnings behind in files they just touched. Narrow-scope
444
+ static cleanup is part of finishing the delivery, even before the lower
445
+ governance gates become stricter.
446
+ - Do not treat multi-adapter `stale` parity as six unrelated incidents by
447
+ default. When several installed adapters are only behind the same current
448
+ template snapshot, refresh them as one governed parity batch and re-run
449
+ `doctor` before continuing implementation.
450
+ - Do not link or junction a disposable worktree's `node_modules` back to the
451
+ main repo. In npm workspace repos, cleanup can follow reparse points and
452
+ remove tracked `packages/*` or `examples/*` files from the main worktree.
453
+ - Do not treat task-card import as atom birth; task-card import uses `tasks
454
+ import`, while atom birth uses `create` or a governed atomize flow.
455
+ - Do not acquire runtime locks during import-only task-plan operations.
456
+ - Keep `.atm/history/tasks` as the canonical imported work-item store; host
457
+ Markdown projections are optional secondary views.
458
+ - Keep host-local language and phrasing in evidence or host lexicons, not in
459
+ this canonical skill.
460
+
461
+ ## Handoff
462
+
463
+ ```bash
464
+ node atm.mjs handoff summarize --task "$ARGUMENTS" --json
465
+ ```
466
+
467
+ ## Charter Invariants
468
+
469
+ The primary installed entry carries the injected Charter Invariants; they remain authoritative.