@akagilnc/pi-workflow-roles 0.1.2521 → 0.1.2652-next.adb6682

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 (109) hide show
  1. package/README.md +129 -39
  2. package/README.zh-CN.md +128 -39
  3. package/dist/activation-ledger-topology.js +1 -1
  4. package/dist/archivist-record-entry.js +47 -26
  5. package/dist/auditor-dossier-tool.js +3 -1
  6. package/dist/compliance-transport.js +17 -26
  7. package/dist/doctor-contracts.js +1 -2
  8. package/dist/dossier-resolution.js +4 -8
  9. package/dist/engine-detour-tool.js +33 -8
  10. package/dist/engine-detour.js +1 -0
  11. package/dist/evidence-child-executor.js +277 -424
  12. package/dist/host-contracts.js +22 -0
  13. package/dist/institutional-resolution.js +88 -0
  14. package/dist/merger-contracts.js +1 -2
  15. package/dist/navigator-attendance.js +16 -0
  16. package/dist/notary-contracts.js +2 -3
  17. package/dist/package-contracts/fixer-output.js +1 -2
  18. package/dist/packaged-role-registry.js +102 -9
  19. package/dist/pi/in-process-session.js +671 -0
  20. package/dist/public-cli/config.js +7 -5
  21. package/dist/public-cli/main.js +3767 -4113
  22. package/dist/reviewer-child-executor.js +6 -1
  23. package/dist/session-opening-materials.js +10 -38
  24. package/dist/sitian-appender.js +146 -0
  25. package/dist/sitian-contracts.js +21 -0
  26. package/dist/sitian-facade.js +15 -0
  27. package/dist/sitian-reader.js +52 -0
  28. package/extensions/role-runtime.ts +9 -7
  29. package/package.json +5 -5
  30. package/resources/engines/cursor.md +12 -26
  31. package/resources/engines/hermes.md +2 -23
  32. package/resources/engines/opus.md +1 -16
  33. package/resources/navigator-route-playbook.md +2 -2
  34. package/scripts/build-package.mjs +0 -1
  35. package/souls/quality-law.md +1 -1
  36. package/src/activation-ledger-topology.ts +1 -1
  37. package/src/archivist-record-entry.ts +57 -45
  38. package/src/auditor-dossier-tool.ts +4 -2
  39. package/src/canonical-skill-binding.ts +37 -27
  40. package/src/collector-role.ts +11 -20
  41. package/src/collector-tool-schemas.ts +1 -4
  42. package/src/compliance-transport.ts +19 -44
  43. package/src/doctor-auditor.ts +1 -5
  44. package/src/doctor-contracts.ts +1 -4
  45. package/src/doctor-role.ts +31 -8
  46. package/src/dossier-resolution.ts +8 -8
  47. package/src/engine-detour-tool.ts +48 -19
  48. package/src/engine-detour.ts +3 -0
  49. package/src/evidence-child-executor.ts +277 -485
  50. package/src/factory-board.ts +3 -3
  51. package/src/gatekeeper-role.ts +21 -10
  52. package/src/host-contracts.ts +386 -0
  53. package/src/in-process-session.ts +1 -115
  54. package/src/institutional-resolution.ts +135 -0
  55. package/src/judge-auditor.ts +1 -5
  56. package/src/judge-role.ts +37 -51
  57. package/src/merger-contracts.ts +1 -4
  58. package/src/merger-role.ts +7 -11
  59. package/src/navigator-attendance.ts +20 -1
  60. package/src/notary-contracts.ts +8 -11
  61. package/src/notary-role.ts +7 -23
  62. package/src/notary-source-run.ts +4 -3
  63. package/src/package-contracts/fixer-output.ts +1 -4
  64. package/src/package-resources/method-skill-binding.ts +10 -34
  65. package/src/packaged-role-registry.ts +122 -12
  66. package/src/pi/adapter.ts +192 -0
  67. package/src/pi/durable-principal.ts +98 -0
  68. package/src/pi/in-process-session.ts +819 -0
  69. package/src/pi/known-failure.ts +77 -0
  70. package/src/pi/pi-normalization.ts +284 -0
  71. package/src/pi/role-turn-host.ts +459 -0
  72. package/src/public-cli/auto-resume.ts +42 -44
  73. package/src/public-cli/cli.ts +171 -257
  74. package/src/public-cli/coder-run.ts +115 -433
  75. package/src/public-cli/collector-run.ts +62 -314
  76. package/src/public-cli/config.ts +7 -5
  77. package/src/public-cli/doctor-run.ts +41 -52
  78. package/src/public-cli/fixer-run.ts +122 -427
  79. package/src/public-cli/invocation.ts +287 -96
  80. package/src/public-cli/judge-run.ts +92 -422
  81. package/src/public-cli/merger-run.ts +167 -429
  82. package/src/public-cli/notary-run.ts +41 -47
  83. package/src/public-cli/option-definitions.ts +136 -3
  84. package/src/public-cli/post-admission.ts +497 -0
  85. package/src/public-cli/public-run-credentials.ts +4 -4
  86. package/src/public-cli/reviewer-dispatch-rejection.ts +106 -0
  87. package/src/public-cli/reviewer-run.ts +132 -449
  88. package/src/public-cli/run-lifecycle.ts +339 -327
  89. package/src/public-cli/settlement.ts +251 -134
  90. package/src/public-cli/terminal.ts +3 -9
  91. package/src/public-cli/turn-request.ts +87 -0
  92. package/src/reviewer-child-executor.ts +9 -1
  93. package/src/reviewer-role.ts +11 -20
  94. package/src/role-runtime.ts +129 -78
  95. package/src/session-opening-materials.ts +25 -39
  96. package/src/sitian-appender.ts +171 -0
  97. package/src/sitian-contracts.ts +106 -0
  98. package/src/sitian-facade.ts +18 -0
  99. package/src/sitian-reader.ts +62 -0
  100. package/src/worker-role.ts +42 -40
  101. package/src/worker-submission-gates.ts +33 -0
  102. package/dist/archivist-role-run-coordinates.js +0 -28
  103. package/dist/package-contracts/terminating-infrastructure.js +0 -90
  104. package/resources/engines/sonnet.md +0 -27
  105. package/resources/engines/zcode.md +0 -63
  106. package/src/archivist-role-run-coordinates.ts +0 -45
  107. package/src/package-contracts/terminating-infrastructure.ts +0 -132
  108. package/src/public-cli/explicit-internal.ts +0 -427
  109. package/src/public-cli/one-shot-dispatch.ts +0 -300
package/README.md CHANGED
@@ -4,30 +4,14 @@ Packaged workflow roles for [Pi](https://pi.dev): `judge`, `fixer`, `coder`, `re
4
4
 
5
5
  ## Install
6
6
 
7
- Install through Pi so the CLI and runtime come from the same package copy, and add Pi's private npm bin to `PATH` once:
7
+ Install through Pi so the CLI and runtime come from the same package copy, and add Pi’s private npm bin to `PATH` once:
8
8
 
9
9
  ```bash
10
10
  pi install npm:@akagilnc/pi-workflow-roles
11
11
  export PATH="$HOME/.pi/agent/npm/node_modules/.bin:$PATH"
12
12
  ```
13
13
 
14
- Update with `pi update npm:@akagilnc/pi-workflow-roles`—never a second global `npm install -g`. Inspect with `ak-role roles` and `ak-role help <role>`; seat and Gate-officer configuration lives under Reading results below.
15
-
16
- ### Test channel (`next`)
17
-
18
- Family / dogfood installs use the same package under dist-tag `next`, on a dedicated `HOME` so the test surface never shares AK config, ledger, book, or `PI_CODING_AGENT_DIR` with the host install. Do not mount or copy host credentials into the test home; do not use a book/worktree as a stand-in for install isolation. No second global npm.
19
-
20
- ```bash
21
- export HOME=/path/to/test-home # dedicated test HOME
22
- export PI_CODING_AGENT_DIR="$HOME/.pi/agent"
23
- export PATH="$PI_CODING_AGENT_DIR/npm/node_modules/.bin:$PATH"
24
- ```
25
-
26
- - **First install of next**: `pi install npm:@akagilnc/pi-workflow-roles@next` → `ak-role roles` runs; installed version looks like `0.1.<count>-next.<shortsha>`.
27
- - **Advance to a newer next**: `pi update npm:@akagilnc/pi-workflow-roles@next` → `<shortsha>` becomes the new CI `head_sha` prefix (7 chars).
28
- - **Same-version reinstall / restore**: rerun the first-install command → idempotent; version unchanged (stamp path that only moves the dist-tag when the version is already on the registry).
29
-
30
- Publish routing (Actions, not local stamp): successful `ci` push on `main` → `latest`; successful `ci` push on an allowlisted non-main branch (see `.github/workflows/ci.yml` `push.branches`) → `next`. PR completions and failed CI never publish.
14
+ Update with `pi update npm:@akagilnc/pi-workflow-roles`—never a second global `npm install -g`. Inspect with `ak-role roles` and `ak-role help <role>`; set per-seat model defaults with `ak-role config set <seat> <provider/model[:thinking]>` (callable seats plus automatic `gatekeeper` / `inspector` / `navigator`); clear a Gate officer override with `ak-role config unset <gatekeeper|inspector|notary>`; set or clear a persistent labor engine (callable roles) with `ak-role config set-engine <seat> <name>` / `ak-role config unset-engine <seat>`.
31
15
 
32
16
  ## Reading results
33
17
 
@@ -39,11 +23,13 @@ ak-role judge --attach ./plan.md "Review this plan." > result.txt
39
23
 
40
24
  Exit status reports lifecycle honesty, not business success: every lawful typed result (including `audit_escalation`) exits zero; a failure without a lawful result exits nonzero, and its Terminal carries the Error Artifact ref and original cause instead of a fabricated receipt.
41
25
 
42
- `ak-role resume <runId> [message]` reopens that run's exact Pi session. Standard chain after a role `escalate`s: take the owner ruling and feed it back with `ak-role resume <runId> "<ruling>"` so the same session continues to a terminal. The optional `message` after `runId` is passed through unchanged as the continuation prompt (opaque: not parsed as flags); omit it to use the package resume envelope. Whether to resume is the caller's decision: the command does not require a typed HTTP 429 or a `resumable` state. Unknown run IDs and missing session principals are rejected. Collector, Doctor, and Notary remain one-shot. The model resolves from the **current seat configuration**; pass `--model` explicitly when identity matters (#552 ruling).
26
+ `ak-role resume <runId> [message]` reopens that run's exact Pi session. Standard chain after a role `escalate`s: take the owner ruling and feed it back with `ak-role resume <runId> "<ruling>"` so the same session continues to a terminal. The optional `message` after `runId` is passed through unchanged as the continuation prompt (opaque: not parsed as flags); omit it to use the package resume envelope. Whether to resume is the caller's decision: the command does not require a typed HTTP 429 or a `resumable` state. Unknown run IDs and missing session principals are rejected. Collector, Doctor, and Notary remain one-shot. The package never auto-switches providers; override the model for one run with the global flags.
43
27
 
44
28
  Judge, coder, fixer, reviewer, and merger also retry a non-lawful LLM call in place (same `runId` and session) up to `autoResumeLimit` times. Unset defaults to 2; `ak-role config set-auto-resume-limit <N>` writes the ceiling (`0` disables). Lawful typed terminals (`accepted`, `audit_escalation`, `no_receipt`) stop immediately. Manual `ak-role resume` stays available.
45
29
 
46
- Seat and Gate-officer configuration:
30
+ Global overrides work before the opaque message segment: `ak-role --model <provider/model[:thinking]> resume <runId>` or `ak-role resume --model <provider/model[:thinking]> <runId>`.
31
+
32
+ Every run also prepares Navigator advice in the same Terminal. Configure seats like this:
47
33
 
48
34
  ```bash
49
35
  ak-role config set judge <provider/model[:thinking]>
@@ -59,46 +45,63 @@ ak-role config unset-engine judge
59
45
  ak-role config set-auto-resume-limit 3
60
46
  ```
61
47
 
62
- For Gate officers (`gatekeeper` / `inspector` / `notary`) resolution is officer pin → province (`gatekeeper`) pin → inherit parent session; an explicit selection that fails is loud and does not fall back. Configuration usage and refusal text are owned by `ak-role config` / `ak-role help config`.
48
+ `config set` stores the seat model default. For Gate officers (`gatekeeper` / `inspector` / `notary`) resolution is officer pin → province (`gatekeeper`) pin → inherit parent session; an explicit selection that fails is loud and does not fall back. `config unset` clears only those officer overrides. `config set-engine` / `unset-engine` store or clear the persistent labor-engine name on callable roles (same seats as `--engine`; navigator refused — no independent activation). `config set-auto-resume-limit` stores the single-call auto-resume ceiling. Usage and refusal text are owned by `ak-role config` / `ak-role help config`.
49
+
50
+ Receipts are typed, so callers compose roles without parsing prose; ordering and stopping stay caller-owned. Programmatic consumers derive contracts from the exported schemas in `src/package-contracts/`, not from this guide.
63
51
 
64
- Receipts are typed, so callers compose roles without parsing prose; ordering and stopping stay caller-owned ([ADR 0010](docs/adr/0010-callers-own-role-composition-and-repetition.md)). Programmatic consumers derive contracts from the exported schemas in `src/package-contracts/`, not from this guide.
52
+ ### Gate submission gate
65
53
 
66
- Gate submission gate: on completing-side submissions the package may spawn the Gate province before the run settles (`gatekeeper` dispatching `inspector` or `notary`); bounce means rewrite-and-resubmit in that same session, not role failure; `planned` / `refused` / `unfinished` skip the province; read gate history from the typed gate section of the receipt, never from session prose. Pointers: [ADR 0067](docs/adr/0067-menxia-province-founding-jishizhong-fubaolang.md), [ADR 0072](docs/adr/0072-menxia-pre-pr-submission-hooks.md). A labor-engine detour that fails to spawn, exits nonzero, or produces no usable output stops the run through the existing infrastructure-failure path with the original cause visible ([ADR 0071](docs/adr/0071-engine-detour-failure-seat-fallback-declaration.md)).
54
+ On completing-side submissions the package may spawn the Gate province before the run settles: `gatekeeper` reads the subject and dispatches an officer (`inspector` or `notary`); existing auditor hooks stay where already wired. The gate runs inside the submission session; bounce means rewrite-and-resubmit in that same session — not role failure; the final receipt is the post-gate product. `planned` / `refused` / `unfinished` skip the province. Pointers only: [ADR 0067](docs/adr/0067-menxia-province-founding-jishizhong-fubaolang.md), [ADR 0072](docs/adr/0072-menxia-pre-pr-submission-hooks.md). Gate history is projected into the typed TerminalResult: an optional gate section lists the seats that actually sat, each dispatch round (officer, optional reason verbatim), and each officer report (seat, status, findings). Absent when no gate ran. Do not scrape session prose for gate status — read the typed section.
55
+
56
+ When a labor-engine detour process fails to spawn, exits nonzero, or produces no usable output, the role run stops through the existing infrastructure-failure path with the original cause visible. The seat does not continue the labor or produce a typed Receipt. Caller cancellation continues to propagate unchanged. See [ADR 0071](docs/adr/0071-engine-detour-failure-seat-fallback-declaration.md).
67
57
 
68
58
  ## Call the roles
69
59
 
70
- The examples below are usage sketches; option identity, aliases, requiredness, and mode faces are owned by `ak-role help <command>`, not by a second flag contract here.
60
+ Public option identity, aliases, requiredness, and mode faces live in the generated [Public CLI options](#public-cli-options-generated) table and in `ak-role help <command>` — both project the same typed source. The examples below are usage sketches, not a second flag contract. An instruction is optional for judge, collector, and doctor; notary admits no caller prompt or attachment; analyst is deterministic (see help). Required nonblank for coder, fixer, reviewer, and merger.
71
61
 
72
62
  ```bash
73
- # judge — adjudicate the supplied materials
63
+ # judge — adjudicate the supplied materials; infers its burden, no burden flag
74
64
  ak-role judge --attach ./findings.md --attach ./adr.md "Adjudicate every finding."
75
65
 
76
- # coder — first implementation
66
+ # coder — first implementation; phase defaults to apply, or pass plan
77
67
  ak-role coder plan "Propose the first implementation plan."
78
68
  ak-role coder apply --attach ./plan.md "Implement the approved slice."
69
+ # apply binds the package-owned TDD method; do not bind a home Skill as a substitute
79
70
 
80
- # reviewer — fixed-target two-axis review; completed ≠ approved, read the findings
81
- ak-role reviewer --base main "Review the branch."
71
+ # reviewer — fixed-target two-axis review (Standards + Spec)
72
+ ak-role reviewer --base main "Review the branch against the governing issue and repository authority."
73
+ # --base is required and pins the fixed point; Reviewer does not accept --attach
74
+ # completed ≠ approved — read the findings in the Terminal
82
75
 
83
- # collector — GitHub PR review evidence; one-shot
76
+ # collector — GitHub PR review evidence; github.com only, needs gh auth; one-shot
84
77
  ak-role collector --pr 42 --repo owner/repository
78
+ # repo defaults from origin; --repo owner/repo overrides
85
79
 
86
- # fixer — repair the assigned findings
80
+ # fixer — repair the assigned findings; phase defaults to apply, or pass plan
87
81
  ak-role fixer --attach ./findings.md --prerequisites ./prereqs.json "Repair the findings."
82
+ # --prerequisites is a JSON array of {id, requirement}; malformed grammar exits 2
83
+ # apply/resume mount the package-owned diagnosis and TDD methods from the install; neither is forced into the prompt
88
84
 
89
85
  # doctor — diagnose one retained case; one-shot
90
86
  ak-role doctor --issue 115 "Diagnose this retained case."
87
+ # --runs must stay project-relative: .ak-roles/books/<book>/issues/<n>/runs matching --issue
91
88
 
92
- # merger — resolve one merge already in conflict (start it with Git's ort first)
89
+ # merger — resolve one merge already in conflict (start it first with Git’s ort)
93
90
  ak-role merger --project /path/to/worktree "Reconcile the active merge."
91
+ # hands new intent/authority questions back instead of inventing authority
94
92
 
95
- # notary — document-fidelity check on one retained source run; one-shot
93
+ # notary — document-fidelity check on one retained source run; zero prompt/attachment; one-shot
96
94
  ak-role notary --source-run <runId@role|path>
97
95
 
98
- # analyst — deterministic metrics; bare call = whole book
96
+ # analyst — deterministic metrics over the book (cwd git common-dir); bare = whole book
99
97
  ak-role analyst
98
+ ak-role analyst --ticket <N>
99
+ ak-role analyst sweep --attach ./payload.md
100
+ ak-role analyst --cohort \
101
+ --group-a-label A --group-a-issues 1,2 \
102
+ --group-b-label B --group-b-issues 3,4
100
103
 
101
- # after escalate: feed the owner ruling into the same session (standard chain)
104
+ # after escalate: feed the owner ruling into the same session (standard chain; see resume under Reading results)
102
105
  ak-role resume <runId> "<ruling>"
103
106
  ```
104
107
 
@@ -110,8 +113,95 @@ Roles are named after Tang/Song offices; the full roster and naming rule live in
110
113
 
111
114
  Enable fast tier with `echo "fast_mode = on" > ~/.pi-codex-fast`; disable it with `echo "fast_mode = off" > ~/.pi-codex-fast` (or delete the file). The change takes effect on the next request without a restart. Fast tier costs more than the default tier.
112
115
 
113
- ## Normative pointers
114
-
115
- - Command usage and refusal text: `ak-role help <command>`, `ak-role help config` (sole authority).
116
- - Decisions and rationale: `docs/adr/` (composition ADR 0010, public CLI face ADR 0052, submission gates ADR 0066/0067/0070/0072, labor engines ADR 0069/0071, among others; not exhaustive).
117
- - Glossary: [CONTEXT.md](CONTEXT.md). Programmatic contracts: `src/package-contracts/` exports.
116
+ <!-- BEGIN GENERATED: public-cli-options -->
117
+ ## Public CLI options (generated)
118
+
119
+ Generated from `src/public-cli/option-definitions.ts`. Prefer `ak-role help <command>`. Do not hand-edit this section.
120
+
121
+ ### `global`
122
+
123
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
124
+ | --- | --- | --- | --- | --- | --- | --- | --- |
125
+ | `--model` | — | `provider/model` | no | no | option | — | Override the effective seat model for this invocation (before or after the command). |
126
+ | `--thinking` | — | `level` | no | no | option | — | Override thinking level: off\|minimal\|low\|medium\|high\|xhigh\|max. |
127
+ | `--engine` | — | `name` | no | no | option | — | Optional labor engine for this invocation (owner pool-directive name; packaged notes attached when present; any role). |
128
+ | `--help` | `-h` | — | no | no | option | — | Show public CLI help and exit. |
129
+
130
+ ### `judge`
131
+
132
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
133
+ | --- | --- | --- | --- | --- | --- | --- | --- |
134
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
135
+ | `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
136
+
137
+ ### `coder`
138
+
139
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
140
+ | --- | --- | --- | --- | --- | --- | --- | --- |
141
+ | `plan\|apply` | `plan`, `apply` | — | no | no | positional | phases=plan\|apply; default=apply | Optional phase token before the instruction; defaults to apply. |
142
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
143
+ | `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
144
+
145
+ ### `fixer`
146
+
147
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
148
+ | --- | --- | --- | --- | --- | --- | --- | --- |
149
+ | `plan\|apply` | `plan`, `apply` | — | no | no | positional | phases=plan\|apply; default=apply | Optional phase token before the instruction; defaults to apply. |
150
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
151
+ | `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
152
+ | `--prerequisites` | — | `path` | no | no | option | — | JSON array of {id, requirement} prerequisite objects. |
153
+
154
+ ### `reviewer`
155
+
156
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
157
+ | --- | --- | --- | --- | --- | --- | --- | --- |
158
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
159
+ | `--base` | — | `revision` | yes | no | option | — | Required fixed-point revision for the pinned review target. |
160
+ | `--authority-ref` | — | `ref` | no | yes | option | — | Durable authority reference/URL (repeatable; refs only, not inline prose). |
161
+
162
+ ### `collector`
163
+
164
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
165
+ | --- | --- | --- | --- | --- | --- | --- | --- |
166
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
167
+ | `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
168
+ | `--pr` | — | `number` | yes | no | option | — | Required positive GitHub pull request number. |
169
+ | `--repo` | — | `owner/repo` | no | no | option | — | GitHub owner/repo override (defaults from origin when github.com). |
170
+ | `--request-manifest` | — | `path` | no | no | option | — | Optional request manifest JSON path ({requests:[{id,body}]}). |
171
+
172
+ ### `doctor`
173
+
174
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
175
+ | --- | --- | --- | --- | --- | --- | --- | --- |
176
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
177
+ | `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
178
+ | `--issue` | — | `number` | yes | no | option | — | Required positive issue number for the retained case. |
179
+ | `--runs` | — | `path` | no | no | option | — | Optional project-relative .ak-roles/books/<book>/issues/<n>/runs override matching --issue. |
180
+
181
+ ### `merger`
182
+
183
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
184
+ | --- | --- | --- | --- | --- | --- | --- | --- |
185
+ | `--project` | — | `path` | no | no | option | — | Project root with one ordinary in-progress merge (defaults to cwd). |
186
+ | `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
187
+
188
+ ### `notary`
189
+
190
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
191
+ | --- | --- | --- | --- | --- | --- | --- | --- |
192
+ | `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
193
+ | `--source-run` | — | `runId@role\|path` | yes | no | option | — | Required source run locator (runId@role under the book home, or path to that run directory). Zero prompt/attachment projection. |
194
+
195
+ ### `analyst`
196
+
197
+ | Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
198
+ | --- | --- | --- | --- | --- | --- | --- | --- |
199
+ | `sweep` | — | — | no | no | positional | modes=sweep | Optional sweep mode token (at most once; no other positionals). |
200
+ | `--ticket` | — | `number` | no | no | option | modes=issue | Ticket/issue number; live filter by invocation.ticketNumber inside the cwd book (git common-dir). Bare call = whole book. No library-index bootstrap. |
201
+ | `--attach` | — | `path` | when:sweep | yes | option | modes=sweep; max=sweep:1 | Sweep-mode attachment path; required exactly once in sweep; payload is the attachment body. |
202
+ | `--cohort` | — | — | no | no | option | modes=cohort | Select cohort mode. |
203
+ | `--group-a-label` | — | `label` | when:cohort | no | option | modes=cohort | Cohort group A label (required in cohort mode). |
204
+ | `--group-a-issues` | — | `N\|book:N[,...]` | when:cohort | no | option | modes=cohort | Cohort group A issues: bare N joins cwd book; book:N selects another book; escape a literal comma/backslash in a book key as \, / \\ (required in cohort mode). |
205
+ | `--group-b-label` | — | `label` | when:cohort | no | option | modes=cohort | Cohort group B label (required in cohort mode). |
206
+ | `--group-b-issues` | — | `N\|book:N[,...]` | when:cohort | no | option | modes=cohort | Cohort group B issues: bare N joins cwd book; book:N selects another book; escape a literal comma/backslash in a book key as \, / \\ (required in cohort mode). |
207
+ <!-- END GENERATED: public-cli-options -->
package/README.zh-CN.md CHANGED
@@ -11,23 +11,7 @@ pi install npm:@akagilnc/pi-workflow-roles
11
11
  export PATH="$HOME/.pi/agent/npm/node_modules/.bin:$PATH"
12
12
  ```
13
13
 
14
- 更新用 `pi update npm:@akagilnc/pi-workflow-roles`——勿另起全局 `npm install -g`。查看能力:`ak-role roles`、`ak-role help <role>`;席位与官席配置见下方「读结果」。
15
-
16
- ### 测试通道(`next`)
17
-
18
- 家族/dogfood 安装面复用同一包,经 dist-tag `next` 取得;测试面自有 `HOME`,其下的 AK config/ledger/book 与 `PI_CODING_AGENT_DIR` 一并独立,不与宿主已装包共享。测试面不挂载、不复制宿主凭据;不以 book/worktree 冒充安装隔离。不装第二份全局 npm。
19
-
20
- ```bash
21
- export HOME=/path/to/test-home # 测试面自有 HOME
22
- export PI_CODING_AGENT_DIR="$HOME/.pi/agent"
23
- export PATH="$PI_CODING_AGENT_DIR/npm/node_modules/.bin:$PATH"
24
- ```
25
-
26
- - **首次装 next**:`pi install npm:@akagilnc/pi-workflow-roles@next` → `ak-role roles` 可跑;装到的版本形如 `0.1.<count>-next.<shortsha>`。
27
- - **推进到新 next**:`pi update npm:@akagilnc/pi-workflow-roles@next` → 版本号里的 `<shortsha>` 变为新 CI `head_sha` 的前 7 位。
28
- - **同版本重装/恢复**:重跑首次安装命令 → 幂等,版本不变(对应 stamp「版本已在 registry 则只移 dist-tag」路径)。
29
-
30
- 发布路由(Actions 真入口,非本地 stamp):`ci` 在 `main` 上成功 push → `latest`;`ci` 在 allowlist 非 main 分支上成功 push(见 `.github/workflows/ci.yml` 的 `push.branches`)→ `next`。PR completion 与失败 CI 不发布。
14
+ 更新用 `pi update npm:@akagilnc/pi-workflow-roles`——勿另起全局 `npm install -g`。查看能力:`ak-role roles`、`ak-role help <role>`;设席位模型默认:`ak-role config set <seat> <provider/model[:thinking]>`(可调用席位,以及自动出席的 `gatekeeper`/`inspector`/`navigator`);清除门下省官钉:`ak-role config unset <gatekeeper|inspector|notary>`;设或清持久劳务引擎(可调用角色):`ak-role config set-engine <seat> <name>` / `ak-role config unset-engine <seat>`。
31
15
 
32
16
  ## 读结果
33
17
 
@@ -39,11 +23,13 @@ ak-role judge --attach ./plan.md "Review this plan." > result.txt
39
23
 
40
24
  退出码报的是生命周期诚实,不是业务成败:一切合法 typed 终态(含 `audit_escalation`)退出零;无合法终态的失败退出非零,其 Terminal 携带 Error Artifact 引用与原始原因,不伪造回执。
41
25
 
42
- `ak-role resume <runId> [message]` 重开该次运行的同一 Pi session。角色 `escalate`(直通御前)后拿到 owner 裁定,标准续跑是 `ak-role resume <runId> "<裁定>"`——把裁定喂回同一 session,角色继续走到终局。`runId` 后可选的 `message` 原样作为续跑 prompt(opaque:不进全局旗标语法);省略则用包自带 resume envelope。要不要续跑由调用者决定:不再要求 typed HTTP 429,也不要求 `resumable` 状态。未知 run ID、session 主体不在则拒绝。通进司、太医署、符宝郎仍为一次性,无 resume。模型解析自**现行席位配置**;在乎身份的续跑显式带 `--model` 钉住(#552 裁定口径)。
26
+ `ak-role resume <runId> [message]` 重开该次运行的同一 Pi session。角色 `escalate`(直通御前)后拿到 owner 裁定,标准续跑是 `ak-role resume <runId> "<裁定>"`——把裁定喂回同一 session,角色继续走到终局。`runId` 后可选的 `message` 原样作为续跑 prompt(opaque:不进全局旗标语法);省略则用包自带 resume envelope。要不要续跑由调用者决定:不再要求 typed HTTP 429,也不要求 `resumable` 状态。未知 run ID、session 主体不在则拒绝。通进司、太医署、符宝郎仍为一次性,无 resume。包绝不自动换 provider;临时换模型用全局旗标。
43
27
 
44
28
  大理寺、将作监、修内司、御史台、校书郎在单次调用内对非 lawful LLM 终态原地续跑(同一 `runId` 与 session),次数上限为 `autoResumeLimit`。缺键默认 2;`ak-role config set-auto-resume-limit <N>` 写入(`0` 关闭自动续)。lawful typed 终态(`accepted` / `audit_escalation` / `no_receipt`)立即停止。手动 `ak-role resume` 仍可用。
45
29
 
46
- 席位与官席配置:
30
+ 全局覆盖须在 opaque message 段之前:`ak-role --model <provider/model[:thinking]> resume <runId>` 或 `ak-role resume --model <provider/model[:thinking]> <runId>`。
31
+
32
+ 每次运行游奕使自动出席,建议随同一 Terminal 给出。配置:
47
33
 
48
34
  ```bash
49
35
  ak-role config set judge <provider/model[:thinking]>
@@ -59,46 +45,63 @@ ak-role config unset-engine judge
59
45
  ak-role config set-auto-resume-limit 3
60
46
  ```
61
47
 
62
- 门下省官席解析顺序:官自钉 → 省钉(`gatekeeper`)→ 继承父 session;显式指定失败响亮、不回退。配置用法与拒绝文案以 `ak-role config`/`ak-role help config` 为准。
48
+ `config set` 存席位模型默认。门下省官席(`gatekeeper`/`inspector`/`notary`)解析顺序:官自钉 → 省钉(`gatekeeper`)→ 继承父 session;显式指定失败响亮、不回退。`config unset` 只清这三官的覆盖。`config set-engine`/`unset-engine` 在可调用角色上写入或清除持久劳务引擎名(与 `--engine` 同轴;拒收 navigator——无独立 activation)。`config set-auto-resume-limit` 写入单次调用自动续跑上限。用法与拒绝文案以 `ak-role config`/`ak-role help config` 为准。
49
+
50
+ 回执是 typed 的,调用者不必解析散文即可组合角色;顺序与停止归调用者。编程消费者从 `src/package-contracts/` 导出推导契约,不从本文。
63
51
 
64
- 回执是 typed 的,调用者不必解析散文即可组合角色;顺序与停止归调用者([ADR 0010](docs/adr/0010-callers-own-role-composition-and-repetition.md))。编程消费者从 `src/package-contracts/` 导出推导契约,不从本文。
52
+ ### 门下省交卷闸
65
53
 
66
- 门下省交卷闸:完成侧交卷时包可在本局结算前起省(`gatekeeper` 派 `inspector`/`notary`),封驳=当场重写重交,不是角色失败;`planned`/`refused`/`unfinished` 不调省;闸史读回执 typed gate 段,勿刮 session 散文。指针:[ADR 0067](docs/adr/0067-menxia-province-founding-jishizhong-fubaolang.md)、[ADR 0072](docs/adr/0072-menxia-pre-pr-submission-hooks.md)。劳务引擎绕行失败沿既有基础设施故障路径停止、真因可见([ADR 0071](docs/adr/0071-engine-detour-failure-seat-fallback-declaration.md))。
54
+ 完成侧交卷时,包可能在本局结算前起门下省:`gatekeeper` 读受审物并派官(`inspector` 给事中或 `notary` 符宝郎);既有审刑院挂钩仍在原位。闸在交卷 session 内运行;封驳=当场重写重交,不是角色失败;最终回执即过闸产物。`planned`/`refused`/`unfinished` 不调省。指针:[ADR 0067](docs/adr/0067-menxia-province-founding-jishizhong-fubaolang.md)、[ADR 0072](docs/adr/0072-menxia-pre-pr-submission-hooks.md)。闸史已投影进 typed 回执:可选 gate 段列出实际在场席位、每轮派官(officer 与逐字 reason)与各官报告(席位/判决/findings);无闸调用时该段缺席。勿刮 session 散文当闸状态——读 typed 段。
55
+
56
+ 劳务引擎绕行进程无法启动、非零退出或未产生可用输出时,角色运行沿既有基础设施失败路径立即停止并保留可见真因;座席不继续顶班,也不产出 typed 回执。调用方 cancel 仍原样传播。见 [ADR 0071](docs/adr/0071-engine-detour-failure-seat-fallback-declaration.md)。
67
57
 
68
58
  ## 调用百官
69
59
 
70
- 下例只是用法速写;option 身份、别名、必填性与 mode 面以 `ak-role help <command>` 为准,不另立第二份旗标合同。
60
+ 公开 option 身份、别名、必填性与 mode 面以生成区 [公开 CLI 选项(生成)](#公开-cli-选项生成) 与 `ak-role help <command>` 为准——二者同源。下例只是用法速写,不是第二份旗标合同。指令对大理寺、通进司、太医署可省略;符宝郎零 prompt/附件;太史为确定性命令(见 help)。对将作监、修内司、御史台、校书郎必须非空。
71
61
 
72
62
  ```bash
73
- # 大理寺——审断所供材料
63
+ # 大理寺——审断所供材料;自行推断举证责任,无 burden 旗标
74
64
  ak-role judge --attach ./findings.md --attach ./adr.md "Adjudicate every finding."
75
65
 
76
- # 将作监——营造新作
66
+ # 将作监——营造新作;phase 默认 apply,或显式 plan
77
67
  ak-role coder plan "Propose the first implementation plan."
78
68
  ak-role coder apply --attach ./plan.md "Implement the approved slice."
69
+ # apply 强制包内 TDD 方法;勿绑 home Skill 顶替
79
70
 
80
- # 御史台——固定目标双轴察举;completed ≠ 准行,findings 在 Terminal 里
71
+ # 御史台——固定目标双轴察举(Standards + Spec)
81
72
  ak-role reviewer --base main "Review the branch."
73
+ # --base 为必填并钉住 fixed point;御史台不接受 --attach
74
+ # completed ≠ 准行——findings 在 Terminal 里
82
75
 
83
- # 通进司——GitHub PR 收证;一次性
76
+ # 通进司——GitHub PR 收证;仅 github.com,需 gh 已认证;一次性
84
77
  ak-role collector --pr 42 --repo owner/repository
78
+ ak-role collector --pr 42 --request-manifest ./requests.json
79
+ # 无配置时仅观察;可选 request manifest 为 {requests:[{id,body}]};repo 默认取 origin
85
80
 
86
- # 修内司——缮修所指 findings
81
+ # 修内司——缮修所指 findings;phase 默认 apply,或显式 plan
87
82
  ak-role fixer --attach ./findings.md --prerequisites ./prereqs.json "Repair the findings."
83
+ # --prerequisites 为 {id, requirement} JSON 数组;语法畸形退出 2
88
84
 
89
85
  # 太医署——单案诊断;一次性
90
86
  ak-role doctor --issue 115 "Diagnose this retained case."
87
+ # --runs 须为项目相对的 .ak-roles/books/<book>/issues/<n>/runs 且匹配 --issue
91
88
 
92
- # 校书郎——调和已在冲突的 merge(先用 Git ort 起动)
89
+ # 校书郎——雠校一个已在冲突的 merge(先用 Git ort 起动)
93
90
  ak-role merger --project /path/to/worktree "Reconcile the active merge."
91
+ # 遇新意图/权限问题交回调用者,不捏造 authority
94
92
 
95
- # 符宝郎——文书核验一份留存 source run;一次性
93
+ # 符宝郎——对一份留存 source run 做文书核验;零 prompt/附件;一次性
96
94
  ak-role notary --source-run <runId@role|path>
97
95
 
98
- # 太史——确定性指标;裸调=整簿
96
+ # 太史——确定性指标(cwd 候簿=git common-dir);裸调=整簿
99
97
  ak-role analyst
98
+ ak-role analyst --ticket <N>
99
+ ak-role analyst sweep --attach ./payload.md
100
+ ak-role analyst --cohort \
101
+ --group-a-label A --group-a-issues 1,2 \
102
+ --group-b-label B --group-b-issues 3,4
100
103
 
101
- # escalate 后:把 owner 裁定喂回同一 session(标准链)
104
+ # escalate 后:把 owner 裁定喂回同一 session(标准链;细则见上方「读结果」resume 段)
102
105
  ak-role resume <runId> "<裁定>"
103
106
  ```
104
107
 
@@ -130,14 +133,13 @@ ak-role resume <runId> "<裁定>"
130
133
  | analyst | **太史** | 司天台分析席:只读司天记录、出高阶指标;确定性机制,非 LLM,可单独调用 | 已建([ADR 0068](docs/adr/0068-taishi-analysis-seat-reads-records-writes-sibling-home.md);机器面键 `analyst`,[#445](https://github.com/Akagilnc/ak-pi-workflow-roles/issues/445) 拼音清零) |
131
134
  | — | **司天台** | 记候簿——只打点、只指针,不分析不执法 | **一期不是角色**([ADR 0047](docs/adr/0047-sitian-phase-one-mechanism-not-role.md):零 LLM 双面对账);分析席已由太史承担;机器面键 `archivist`([#445](https://github.com/Akagilnc/ak-pi-workflow-roles/issues/445)) |
132
135
  | gleaner-left | **左拾遗** | 合并前以无锚定冷眼审全幅合并候选,只上弹章、不封驳不裁决(风闻) | soul 已落+[ADR 0067](docs/adr/0067-menxia-province-founding-jishizhong-fubaolang.md) 修正案;机器席位待建 |
133
- | marshal | **尚书省** | 审→判→修 质量收敛环的省部级驱动角色:调用方递票号与 baseline,尚书省驱动御史台/大理寺/修内司滚到收敛(converged 唯庭可判)或 escalate 上呈,交回 typed 报告;不弹、不判、不修,只让链条转到收敛 | 已定名(#145);席位待落地(#146) |
134
136
  | — | **兰台** | 读档议制——耗时/缺口/冗余三条,上奏不执法 | 未建 |
135
137
  | — | **考功司** | 考具体效率——角色与档位的升档率、一次通过率、每票成本 | 留档,需要时另立票 |
136
138
  | — | **主簿** | 合并后勾稽销案:核实确已合上、清理残留、报到达 | 未建 |
137
139
 
138
140
  **merge 按钮归调用者**,没有任何角色握不可逆权限:通进司把收证这件苦活做完并报收集终态,人(或 AI)自己判断、自己点,点完想调主簿就调、不调也可以。
139
141
 
140
- 上表**不规定调用顺序**——组合、顺序、重复次数归调用者([ADR 0010](docs/adr/0010-callers-own-role-composition-and-repetition.md))。御史台/大理寺/审刑院是**职责分立的类比,不是必经链**;审刑院也并非只跟在大理寺之后,大理寺、御史台、太医署各自都有一次。门下省交卷闸是完成侧挂钩,不是调用者必经编排链。省部级角色的内部组合属于其单次调用的内政,公开 CLI 语义零变化——外部调用者仍一次启动其选中的一个角色,跨 CLI 调用的顺序、重复与停止仍全归外部调用者。
142
+ 上表**不规定调用顺序**——组合、顺序、重复次数归调用者([ADR 0010](docs/adr/0010-callers-own-role-composition-and-repetition.md))。御史台/大理寺/审刑院是**职责分立的类比,不是必经链**;审刑院也并非只跟在大理寺之后,大理寺、御史台、太医署各自都有一次。门下省交卷闸是完成侧挂钩,不是调用者必经编排链。
141
143
 
142
144
  `拾遗补阙` 成对留档,待将来出现第二个进言席再启用。
143
145
 
@@ -145,8 +147,95 @@ ak-role resume <runId> "<裁定>"
145
147
 
146
148
  开启:`echo "fast_mode = on" > ~/.pi-codex-fast`;关闭:`echo "fast_mode = off" > ~/.pi-codex-fast`(或删文件)。修改后无需重启,下一个请求即生效。Fast 档价格高于默认档。
147
149
 
148
- ## 规范指针
149
-
150
- - 命令用法与拒绝文案:`ak-role help <command>`、`ak-role help config`(唯一权威)。
151
- - 决策与法理:`docs/adr/`(组合与顺序 ADR 0010、公开 CLI 面 ADR 0052、交卷闸 ADR 0066/0067/0070/0072、劳务引擎 ADR 0069/0071 等,未尽举)。
152
- - 术语表:[CONTEXT.md](CONTEXT.md)。编程契约:`src/package-contracts/` 导出。
150
+ <!-- BEGIN GENERATED: public-cli-options -->
151
+ ## 公开 CLI 选项(生成)
152
+
153
+ 本表由 `src/public-cli/option-definitions.ts` 生成;以 `ak-role help <command>` 为准。勿手改本区。
154
+
155
+ ### `global`
156
+
157
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
158
+ | --- | --- | --- | --- | --- | --- | --- | --- |
159
+ | `--model` | — | `provider/model` | 否 | 否 | option | — | 覆盖本调用有效席位模型(可置于子命令前或后)。 |
160
+ | `--thinking` | — | `level` | 否 | 否 | option | — | 覆盖 thinking 档位:off\|minimal\|low\|medium\|high\|xhigh\|max。 |
161
+ | `--engine` | — | `name` | 否 | 否 | option | — | 本调用可选劳动引擎(池令名字;有包内调法笔记则附卷;全部角色可用)。 |
162
+ | `--help` | `-h` | — | 否 | 否 | option | — | 显示公开 CLI 帮助并退出。 |
163
+
164
+ ### `judge`
165
+
166
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
167
+ | --- | --- | --- | --- | --- | --- | --- | --- |
168
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
169
+ | `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
170
+
171
+ ### `coder`
172
+
173
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
174
+ | --- | --- | --- | --- | --- | --- | --- | --- |
175
+ | `plan\|apply` | `plan`, `apply` | — | 否 | 否 | positional | phases=plan\|apply; default=apply | 指令前可选 phase 词元;默认 apply。 |
176
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
177
+ | `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
178
+
179
+ ### `fixer`
180
+
181
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
182
+ | --- | --- | --- | --- | --- | --- | --- | --- |
183
+ | `plan\|apply` | `plan`, `apply` | — | 否 | 否 | positional | phases=plan\|apply; default=apply | 指令前可选 phase 词元;默认 apply。 |
184
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
185
+ | `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
186
+ | `--prerequisites` | — | `path` | 否 | 否 | option | — | {id, requirement} 前置条件 JSON 数组路径。 |
187
+
188
+ ### `reviewer`
189
+
190
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
191
+ | --- | --- | --- | --- | --- | --- | --- | --- |
192
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
193
+ | `--base` | — | `revision` | 是 | 否 | option | — | 必填;钉住审查目标的 fixed-point revision。 |
194
+ | `--authority-ref` | — | `ref` | 否 | 是 | option | — | 持久 authority 引用/URL(可重复;仅 ref,非内联散文)。 |
195
+
196
+ ### `collector`
197
+
198
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
199
+ | --- | --- | --- | --- | --- | --- | --- | --- |
200
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
201
+ | `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
202
+ | `--pr` | — | `number` | 是 | 否 | option | — | 必填;正整数 GitHub PR 号。 |
203
+ | `--repo` | — | `owner/repo` | 否 | 否 | option | — | GitHub owner/repo 覆盖(默认取 github.com origin)。 |
204
+ | `--request-manifest` | — | `path` | 否 | 否 | option | — | 可选 request manifest JSON 路径({requests:[{id,body}]})。 |
205
+
206
+ ### `doctor`
207
+
208
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
209
+ | --- | --- | --- | --- | --- | --- | --- | --- |
210
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
211
+ | `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
212
+ | `--issue` | — | `number` | 是 | 否 | option | — | 必填;留存病例的正整数 issue 号。 |
213
+ | `--runs` | — | `path` | 否 | 否 | option | — | 可选项目相对 .ak-roles/books/<book>/issues/<n>/runs 覆盖,且须匹配 --issue。 |
214
+
215
+ ### `merger`
216
+
217
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
218
+ | --- | --- | --- | --- | --- | --- | --- | --- |
219
+ | `--project` | — | `path` | 否 | 否 | option | — | 已有进行中 ordinary merge 的项目根(默认 cwd)。 |
220
+ | `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
221
+
222
+ ### `notary`
223
+
224
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
225
+ | --- | --- | --- | --- | --- | --- | --- | --- |
226
+ | `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
227
+ | `--source-run` | — | `runId@role\|path` | 是 | 否 | option | — | 必填源 run 定位符(簿内 runId@role,或该 run 目录路径)。零 prompt/附件投影。 |
228
+
229
+ ### `analyst`
230
+
231
+ | 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
232
+ | --- | --- | --- | --- | --- | --- | --- | --- |
233
+ | `sweep` | — | — | 否 | 否 | positional | modes=sweep | 可选 sweep 模式词元(至多一次;不得夹带其他 positional)。 |
234
+ | `--ticket` | — | `number` | 否 | 否 | option | modes=issue | 票号;在 cwd 候簿(git common-dir)内按 invocation.ticketNumber 现取现算。裸调用=整簿。不依赖 library-index 自举。 |
235
+ | `--attach` | — | `path` | 条件:sweep | 是 | option | modes=sweep; max=sweep:1 | sweep 模式附件路径;sweep 必填且恰一次;载荷为附件正文。 |
236
+ | `--cohort` | — | — | 否 | 否 | option | modes=cohort | 选择 cohort 模式。 |
237
+ | `--group-a-label` | — | `label` | 条件:cohort | 否 | option | modes=cohort | cohort A 组标签(cohort 模式必填)。 |
238
+ | `--group-a-issues` | — | `N\|book:N[,...]` | 条件:cohort | 否 | option | modes=cohort | cohort A 组 issue:裸 N 归属 cwd 簿;book:N 显式跨簿;簿键中的逗号/反斜杠用 \, / \\ 转义(cohort 模式必填)。 |
239
+ | `--group-b-label` | — | `label` | 条件:cohort | 否 | option | modes=cohort | cohort B 组标签(cohort 模式必填)。 |
240
+ | `--group-b-issues` | — | `N\|book:N[,...]` | 条件:cohort | 否 | option | modes=cohort | cohort B 组 issue:裸 N 归属 cwd 簿;book:N 显式跨簿;簿键中的逗号/反斜杠用 \, / \\ 转义(cohort 模式必填)。 |
241
+ <!-- END GENERATED: public-cli-options -->
@@ -16,7 +16,7 @@ class ActivationLedgerError extends Error {
16
16
  this.name = "ActivationLedgerError";
17
17
  }
18
18
  }
19
- function resolveActivationLedgerHome(home = homedir) {
19
+ function resolveActivationLedgerHome(home = () => process.env.HOME ?? homedir()) {
20
20
  const processHome = home();
21
21
  if (typeof processHome !== "string" || processHome.length === 0 || !isAbsolute(processHome)) {
22
22
  throw new ActivationLedgerError(
@@ -1,11 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
- import { existsSync, realpathSync, writeFileSync } from "node:fs";
3
- import { dirname, isAbsolute, resolve, join, relative, sep } from "node:path";
2
+ import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
3
+ import { dirname, resolve, join } from "node:path";
4
4
  import { SessionManager } from "@earendil-works/pi-coding-agent";
5
5
  import { resolveBookKeyFromGit } from "./activation-ledger-git.js";
6
- import {
7
- roleRunSessionCoordinates
8
- } from "./archivist-role-run-coordinates.js";
9
6
  import {
10
7
  ActivationLedgerError,
11
8
  activationBookDirectory,
@@ -15,26 +12,49 @@ import {
15
12
  physicallyContainedIn,
16
13
  resolveActivationLedgerHome
17
14
  } from "./activation-ledger-topology.js";
18
- const { findMostRecentSession } = await import(new URL("./core/session-manager.js", import.meta.resolve("@earendil-works/pi-coding-agent")).href);
15
+ const CURRENT_SESSION_LEDGER = "current-session.json";
16
+ function readCurrentSession(sessionDir) {
17
+ const ledger = join(sessionDir, CURRENT_SESSION_LEDGER);
18
+ try {
19
+ const value = JSON.parse(readFileSync(ledger, "utf8"));
20
+ if (typeof value !== "object" || value === null || typeof value.sessionFile !== "string" || value.sessionFile.length === 0) {
21
+ throw new Error("sessionFile is missing");
22
+ }
23
+ return value.sessionFile;
24
+ } catch (error) {
25
+ throw new ActivationLedgerError(
26
+ `archivist current-session ledger is unavailable or invalid (${ledger}): ${errorText(error)}`,
27
+ { cause: error }
28
+ );
29
+ }
30
+ }
31
+ function writeCurrentSession(sessionDir, sessionFile) {
32
+ const ledger = join(sessionDir, CURRENT_SESSION_LEDGER);
33
+ try {
34
+ writeFileSync(ledger, `${JSON.stringify({ sessionFile })}
35
+ `, { flag: "wx" });
36
+ } catch (error) {
37
+ throw new ActivationLedgerError(
38
+ `archivist current-session ledger cannot be created (${ledger}): ${errorText(error)}`,
39
+ { cause: error }
40
+ );
41
+ }
42
+ }
19
43
  const WORKER_SUBMISSION_GATE_KIND = "worker-submission-gate";
20
- function assertRecentFinalFileUnderLedgerHome(ledgerHome, sessionDir, recentFile) {
21
- const absoluteHome = resolve(ledgerHome);
44
+ function assertRecentFinalFileUnderSessionDir(sessionDir, recentFile) {
22
45
  const absoluteSessionDir = resolve(sessionDir);
23
46
  const absoluteFile = resolve(recentFile);
24
- const relToHome = relative(absoluteHome, absoluteSessionDir);
25
- const segments = relToHome.split(sep);
26
- if (relToHome === "" || isAbsolute(relToHome) || relToHome === ".." || relToHome.startsWith(`..${sep}`) || segments[0] !== "books" || segments[1] === void 0 || segments[1] === "" || segments[1] === "." || segments[1] === "..") {
47
+ if (absoluteFile !== absoluteSessionDir && !pathContainedIn(absoluteSessionDir, absoluteFile)) {
27
48
  throw new ActivationLedgerError(
28
- `archivist record sessionDir must be under a ledger book (${ledgerHome}): ${sessionDir}`
49
+ `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
29
50
  );
30
51
  }
31
- const bookRoot = join(absoluteHome, "books", segments[1]);
32
- let realBookRoot;
52
+ let realSessionDir;
33
53
  try {
34
- realBookRoot = realpathSync(bookRoot);
54
+ realSessionDir = realpathSync(absoluteSessionDir);
35
55
  } catch (error) {
36
56
  throw new ActivationLedgerError(
37
- `activation ledger book is not resolvable (${bookRoot}): ${errorText(error)}`,
57
+ `archivist record sessionDir is not resolvable (${absoluteSessionDir}): ${errorText(error)}`,
38
58
  { cause: error }
39
59
  );
40
60
  }
@@ -47,9 +67,9 @@ function assertRecentFinalFileUnderLedgerHome(ledgerHome, sessionDir, recentFile
47
67
  { cause: error }
48
68
  );
49
69
  }
50
- if (realFile !== realBookRoot && !pathContainedIn(realBookRoot, realFile)) {
70
+ if (realFile !== realSessionDir && !pathContainedIn(realSessionDir, realFile)) {
51
71
  throw new ActivationLedgerError(
52
- `archivist record session must be under the ledger book (${bookRoot}): ${recentFile}`
72
+ `archivist record session must be under the authorized nest (${sessionDir}): ${recentFile}`
53
73
  );
54
74
  }
55
75
  }
@@ -74,14 +94,13 @@ function createRecordSession(options) {
74
94
  sessionDir = physicallyContainedIn(ledgerHome, parentResolved) ? join(dirname(parentResolved), options.kind) : join(activationBookDirectory(ledgerHome, resolveBookKeyFromGit(cwd)), options.kind);
75
95
  parentSession = parentFile;
76
96
  }
97
+ const nestAlreadyExists = existsSync(sessionDir);
77
98
  ensureRealDirectoryTree(ledgerHome, sessionDir);
78
99
  const mayResumeSameNest = options.subject !== void 0 || options.kind === WORKER_SUBMISSION_GATE_KIND;
79
- if (mayResumeSameNest) {
80
- const recentFile = findMostRecentSession(sessionDir, cwd);
81
- if (recentFile !== null) {
82
- assertRecentFinalFileUnderLedgerHome(ledgerHome, sessionDir, recentFile);
83
- return SessionManager.open(recentFile, sessionDir, cwd);
84
- }
100
+ if (mayResumeSameNest && nestAlreadyExists) {
101
+ const recentFile = readCurrentSession(sessionDir);
102
+ assertRecentFinalFileUnderSessionDir(sessionDir, recentFile);
103
+ return SessionManager.open(recentFile, sessionDir, cwd);
85
104
  }
86
105
  const session = SessionManager.create(
87
106
  cwd,
@@ -98,11 +117,13 @@ function createRecordSession(options) {
98
117
  session.setSessionFile(file);
99
118
  }
100
119
  }
120
+ if (mayResumeSameNest && file !== void 0) {
121
+ writeCurrentSession(sessionDir, file);
122
+ }
101
123
  }
102
124
  return session;
103
125
  }
104
126
  export {
105
127
  WORKER_SUBMISSION_GATE_KIND,
106
- createRecordSession,
107
- roleRunSessionCoordinates
128
+ createRecordSession
108
129
  };
@@ -4,7 +4,9 @@ export const AUDITOR_DOSSIER_TOOL_NAME = "ak_get_run_dossier";
4
4
  /** Resolve the exact run binding already carried by the parent record session. */
5
5
  export function auditorRunDirectory(context) {
6
6
  const sessionFile = context.sessionManager?.getSessionFile?.();
7
- return sessionFile === undefined ? undefined : resolve(dirname(dirname(sessionFile)));
7
+ if (sessionFile !== undefined)
8
+ return resolve(dirname(dirname(sessionFile)));
9
+ return undefined;
8
10
  }
9
11
  /** The one shared, run-bound dossier locator exposed to every auditor seat. */
10
12
  export function createAuditorDossierTool(runDirectory) {