@akagilnc/pi-workflow-roles 0.1.2514 → 0.1.2521
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.
- package/README.md +23 -129
- package/README.zh-CN.md +21 -127
- package/package.json +5 -5
- package/src/public-cli/option-definitions.ts +3 -136
package/README.md
CHANGED
|
@@ -4,14 +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
|
|
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>`;
|
|
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
15
|
|
|
16
16
|
### Test channel (`next`)
|
|
17
17
|
|
|
@@ -39,13 +39,11 @@ ak-role judge --attach ./plan.md "Review this plan." > result.txt
|
|
|
39
39
|
|
|
40
40
|
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
41
|
|
|
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
|
|
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).
|
|
43
43
|
|
|
44
44
|
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
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Every run also prepares Navigator advice in the same Terminal. Configure seats like this:
|
|
46
|
+
Seat and Gate-officer configuration:
|
|
49
47
|
|
|
50
48
|
```bash
|
|
51
49
|
ak-role config set judge <provider/model[:thinking]>
|
|
@@ -61,63 +59,46 @@ ak-role config unset-engine judge
|
|
|
61
59
|
ak-role config set-auto-resume-limit 3
|
|
62
60
|
```
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Receipts are typed, so callers compose roles without parsing prose; ordering and stopping stay caller-owned. Province-grade (省部级) seats may dispatch proper role calls within their own single invocation, but the public CLI semantics are unchanged — an external caller still launches one chosen role per invocation and retains ordering, repetition, and stopping across CLI calls (ADR 0010 two-grade amendment). Programmatic consumers derive contracts from the exported schemas in `src/package-contracts/`, not from this guide.
|
|
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`.
|
|
67
63
|
|
|
68
|
-
|
|
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.
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
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).
|
|
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)).
|
|
73
67
|
|
|
74
68
|
## Call the roles
|
|
75
69
|
|
|
76
|
-
|
|
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.
|
|
77
71
|
|
|
78
72
|
```bash
|
|
79
|
-
# judge — adjudicate the supplied materials
|
|
73
|
+
# judge — adjudicate the supplied materials
|
|
80
74
|
ak-role judge --attach ./findings.md --attach ./adr.md "Adjudicate every finding."
|
|
81
75
|
|
|
82
|
-
# coder — first implementation
|
|
76
|
+
# coder — first implementation
|
|
83
77
|
ak-role coder plan "Propose the first implementation plan."
|
|
84
78
|
ak-role coder apply --attach ./plan.md "Implement the approved slice."
|
|
85
|
-
# apply binds the package-owned TDD method; do not bind a home Skill as a substitute
|
|
86
79
|
|
|
87
|
-
# reviewer — fixed-target two-axis review
|
|
88
|
-
ak-role reviewer --base main "Review the branch
|
|
89
|
-
# --base is required and pins the fixed point; Reviewer does not accept --attach
|
|
90
|
-
# completed ≠ approved — read the findings in the Terminal
|
|
80
|
+
# reviewer — fixed-target two-axis review; completed ≠ approved, read the findings
|
|
81
|
+
ak-role reviewer --base main "Review the branch."
|
|
91
82
|
|
|
92
|
-
# collector — GitHub PR review evidence;
|
|
83
|
+
# collector — GitHub PR review evidence; one-shot
|
|
93
84
|
ak-role collector --pr 42 --repo owner/repository
|
|
94
|
-
# repo defaults from origin; --repo owner/repo overrides
|
|
95
85
|
|
|
96
|
-
# fixer — repair the assigned findings
|
|
86
|
+
# fixer — repair the assigned findings
|
|
97
87
|
ak-role fixer --attach ./findings.md --prerequisites ./prereqs.json "Repair the findings."
|
|
98
|
-
# --prerequisites is a JSON array of {id, requirement}; malformed grammar exits 2
|
|
99
|
-
# apply/resume mount the package-owned diagnosis and TDD methods from the install; neither is forced into the prompt
|
|
100
88
|
|
|
101
89
|
# doctor — diagnose one retained case; one-shot
|
|
102
90
|
ak-role doctor --issue 115 "Diagnose this retained case."
|
|
103
|
-
# --runs must stay project-relative: .ak-roles/books/<book>/issues/<n>/runs matching --issue
|
|
104
91
|
|
|
105
|
-
# merger — resolve one merge already in conflict (start it
|
|
92
|
+
# merger — resolve one merge already in conflict (start it with Git's ort first)
|
|
106
93
|
ak-role merger --project /path/to/worktree "Reconcile the active merge."
|
|
107
|
-
# hands new intent/authority questions back instead of inventing authority
|
|
108
94
|
|
|
109
|
-
# notary — document-fidelity check on one retained source run;
|
|
95
|
+
# notary — document-fidelity check on one retained source run; one-shot
|
|
110
96
|
ak-role notary --source-run <runId@role|path>
|
|
111
97
|
|
|
112
|
-
# analyst — deterministic metrics
|
|
98
|
+
# analyst — deterministic metrics; bare call = whole book
|
|
113
99
|
ak-role analyst
|
|
114
|
-
ak-role analyst --ticket <N>
|
|
115
|
-
ak-role analyst sweep --attach ./payload.md
|
|
116
|
-
ak-role analyst --cohort \
|
|
117
|
-
--group-a-label A --group-a-issues 1,2 \
|
|
118
|
-
--group-b-label B --group-b-issues 3,4
|
|
119
100
|
|
|
120
|
-
# after escalate: feed the owner ruling into the same session (standard chain
|
|
101
|
+
# after escalate: feed the owner ruling into the same session (standard chain)
|
|
121
102
|
ak-role resume <runId> "<ruling>"
|
|
122
103
|
```
|
|
123
104
|
|
|
@@ -129,95 +110,8 @@ Roles are named after Tang/Song offices; the full roster and naming rule live in
|
|
|
129
110
|
|
|
130
111
|
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.
|
|
131
112
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
### `global`
|
|
138
|
-
|
|
139
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
140
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
141
|
-
| `--model` | — | `provider/model` | no | no | option | — | Override the effective seat model for this invocation (before or after the command). |
|
|
142
|
-
| `--thinking` | — | `level` | no | no | option | — | Override thinking level: off\|minimal\|low\|medium\|high\|xhigh\|max. |
|
|
143
|
-
| `--engine` | — | `name` | no | no | option | — | Optional labor engine for this invocation (owner pool-directive name; packaged notes attached when present; any role). |
|
|
144
|
-
| `--help` | `-h` | — | no | no | option | — | Show public CLI help and exit. |
|
|
145
|
-
|
|
146
|
-
### `judge`
|
|
147
|
-
|
|
148
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
149
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
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
|
-
|
|
153
|
-
### `coder`
|
|
154
|
-
|
|
155
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
156
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
157
|
-
| `plan\|apply` | `plan`, `apply` | — | no | no | positional | phases=plan\|apply; default=apply | Optional phase token before the instruction; defaults to apply. |
|
|
158
|
-
| `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
|
|
159
|
-
| `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
|
|
160
|
-
|
|
161
|
-
### `fixer`
|
|
162
|
-
|
|
163
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
164
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
165
|
-
| `plan\|apply` | `plan`, `apply` | — | no | no | positional | phases=plan\|apply; default=apply | Optional phase token before the instruction; defaults to apply. |
|
|
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
|
-
| `--prerequisites` | — | `path` | no | no | option | — | JSON array of {id, requirement} prerequisite objects. |
|
|
169
|
-
|
|
170
|
-
### `reviewer`
|
|
171
|
-
|
|
172
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
173
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
174
|
-
| `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
|
|
175
|
-
| `--base` | — | `revision` | yes | no | option | — | Required fixed-point revision for the pinned review target. |
|
|
176
|
-
| `--authority-ref` | — | `ref` | no | yes | option | — | Durable authority reference/URL (repeatable; refs only, not inline prose). |
|
|
177
|
-
|
|
178
|
-
### `collector`
|
|
179
|
-
|
|
180
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
181
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
182
|
-
| `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
|
|
183
|
-
| `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
|
|
184
|
-
| `--pr` | — | `number` | yes | no | option | — | Required positive GitHub pull request number. |
|
|
185
|
-
| `--repo` | — | `owner/repo` | no | no | option | — | GitHub owner/repo override (defaults from origin when github.com). |
|
|
186
|
-
| `--request-manifest` | — | `path` | no | no | option | — | Optional request manifest JSON path ({requests:[{id,body}]}). |
|
|
187
|
-
|
|
188
|
-
### `doctor`
|
|
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
|
-
| `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
|
|
194
|
-
| `--issue` | — | `number` | yes | no | option | — | Required positive issue number for the retained case. |
|
|
195
|
-
| `--runs` | — | `path` | no | no | option | — | Optional project-relative .ak-roles/books/<book>/issues/<n>/runs override matching --issue. |
|
|
196
|
-
|
|
197
|
-
### `merger`
|
|
198
|
-
|
|
199
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
200
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
201
|
-
| `--project` | — | `path` | no | no | option | — | Project root with one ordinary in-progress merge (defaults to cwd). |
|
|
202
|
-
| `--attach` | — | `path` | no | yes | option | — | Attach a regular file; frozen at admission (repeatable). |
|
|
203
|
-
|
|
204
|
-
### `notary`
|
|
205
|
-
|
|
206
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
207
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
208
|
-
| `--project` | — | `path` | no | no | option | — | Project root for ledger identity (defaults to process cwd). |
|
|
209
|
-
| `--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. |
|
|
210
|
-
|
|
211
|
-
### `analyst`
|
|
212
|
-
|
|
213
|
-
| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |
|
|
214
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
215
|
-
| `sweep` | — | — | no | no | positional | modes=sweep | Optional sweep mode token (at most once; no other positionals). |
|
|
216
|
-
| `--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. |
|
|
217
|
-
| `--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. |
|
|
218
|
-
| `--cohort` | — | — | no | no | option | modes=cohort | Select cohort mode. |
|
|
219
|
-
| `--group-a-label` | — | `label` | when:cohort | no | option | modes=cohort | Cohort group A label (required in cohort mode). |
|
|
220
|
-
| `--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). |
|
|
221
|
-
| `--group-b-label` | — | `label` | when:cohort | no | option | modes=cohort | Cohort group B label (required in cohort mode). |
|
|
222
|
-
| `--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). |
|
|
223
|
-
<!-- END GENERATED: public-cli-options -->
|
|
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.
|
package/README.zh-CN.md
CHANGED
|
@@ -11,7 +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
|
|
14
|
+
更新用 `pi update npm:@akagilnc/pi-workflow-roles`——勿另起全局 `npm install -g`。查看能力:`ak-role roles`、`ak-role help <role>`;席位与官席配置见下方「读结果」。
|
|
15
15
|
|
|
16
16
|
### 测试通道(`next`)
|
|
17
17
|
|
|
@@ -39,13 +39,11 @@ ak-role judge --attach ./plan.md "Review this plan." > result.txt
|
|
|
39
39
|
|
|
40
40
|
退出码报的是生命周期诚实,不是业务成败:一切合法 typed 终态(含 `audit_escalation`)退出零;无合法终态的失败退出非零,其 Terminal 携带 Error Artifact 引用与原始原因,不伪造回执。
|
|
41
41
|
|
|
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
|
|
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 裁定口径)。
|
|
43
43
|
|
|
44
44
|
大理寺、将作监、修内司、御史台、校书郎在单次调用内对非 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
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
每次运行游奕使自动出席,建议随同一 Terminal 给出。配置:
|
|
46
|
+
席位与官席配置:
|
|
49
47
|
|
|
50
48
|
```bash
|
|
51
49
|
ak-role config set judge <provider/model[:thinking]>
|
|
@@ -61,63 +59,46 @@ ak-role config unset-engine judge
|
|
|
61
59
|
ak-role config set-auto-resume-limit 3
|
|
62
60
|
```
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
回执是 typed 的,调用者不必解析散文即可组合角色;顺序与停止归调用者。省部级(province-grade)角色可在自己单次调用的内政之内派发正经角色调用,但公开 CLI 语义零变化——外部调用者仍一次启动其选中的一个角色,跨 CLI 调用的顺序、重复与停止仍全归外部调用者(ADR 0010 两品级窄修)。编程消费者从 `src/package-contracts/` 导出推导契约,不从本文。
|
|
62
|
+
门下省官席解析顺序:官自钉 → 省钉(`gatekeeper`)→ 继承父 session;显式指定失败响亮、不回退。配置用法与拒绝文案以 `ak-role config`/`ak-role help config` 为准。
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
回执是 typed 的,调用者不必解析散文即可组合角色;顺序与停止归调用者([ADR 0010](docs/adr/0010-callers-own-role-composition-and-repetition.md))。编程消费者从 `src/package-contracts/` 导出推导契约,不从本文。
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
劳务引擎绕行进程无法启动、非零退出或未产生可用输出时,角色运行沿既有基础设施失败路径立即停止并保留可见真因;座席不继续顶班,也不产出 typed 回执。调用方 cancel 仍原样传播。见 [ADR 0071](docs/adr/0071-engine-detour-failure-seat-fallback-declaration.md)。
|
|
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))。
|
|
73
67
|
|
|
74
68
|
## 调用百官
|
|
75
69
|
|
|
76
|
-
|
|
70
|
+
下例只是用法速写;option 身份、别名、必填性与 mode 面以 `ak-role help <command>` 为准,不另立第二份旗标合同。
|
|
77
71
|
|
|
78
72
|
```bash
|
|
79
|
-
#
|
|
73
|
+
# 大理寺——审断所供材料
|
|
80
74
|
ak-role judge --attach ./findings.md --attach ./adr.md "Adjudicate every finding."
|
|
81
75
|
|
|
82
|
-
#
|
|
76
|
+
# 将作监——营造新作
|
|
83
77
|
ak-role coder plan "Propose the first implementation plan."
|
|
84
78
|
ak-role coder apply --attach ./plan.md "Implement the approved slice."
|
|
85
|
-
# apply 强制包内 TDD 方法;勿绑 home Skill 顶替
|
|
86
79
|
|
|
87
|
-
#
|
|
80
|
+
# 御史台——固定目标双轴察举;completed ≠ 准行,findings 在 Terminal 里
|
|
88
81
|
ak-role reviewer --base main "Review the branch."
|
|
89
|
-
# --base 为必填并钉住 fixed point;御史台不接受 --attach
|
|
90
|
-
# completed ≠ 准行——findings 在 Terminal 里
|
|
91
82
|
|
|
92
|
-
# 通进司——GitHub PR
|
|
83
|
+
# 通进司——GitHub PR 收证;一次性
|
|
93
84
|
ak-role collector --pr 42 --repo owner/repository
|
|
94
|
-
ak-role collector --pr 42 --request-manifest ./requests.json
|
|
95
|
-
# 无配置时仅观察;可选 request manifest 为 {requests:[{id,body}]};repo 默认取 origin
|
|
96
85
|
|
|
97
|
-
# 修内司——缮修所指 findings
|
|
86
|
+
# 修内司——缮修所指 findings
|
|
98
87
|
ak-role fixer --attach ./findings.md --prerequisites ./prereqs.json "Repair the findings."
|
|
99
|
-
# --prerequisites 为 {id, requirement} JSON 数组;语法畸形退出 2
|
|
100
88
|
|
|
101
89
|
# 太医署——单案诊断;一次性
|
|
102
90
|
ak-role doctor --issue 115 "Diagnose this retained case."
|
|
103
|
-
# --runs 须为项目相对的 .ak-roles/books/<book>/issues/<n>/runs 且匹配 --issue
|
|
104
91
|
|
|
105
|
-
#
|
|
92
|
+
# 校书郎——调和已在冲突的 merge(先用 Git ort 起动)
|
|
106
93
|
ak-role merger --project /path/to/worktree "Reconcile the active merge."
|
|
107
|
-
# 遇新意图/权限问题交回调用者,不捏造 authority
|
|
108
94
|
|
|
109
|
-
#
|
|
95
|
+
# 符宝郎——文书核验一份留存 source run;一次性
|
|
110
96
|
ak-role notary --source-run <runId@role|path>
|
|
111
97
|
|
|
112
|
-
#
|
|
98
|
+
# 太史——确定性指标;裸调=整簿
|
|
113
99
|
ak-role analyst
|
|
114
|
-
ak-role analyst --ticket <N>
|
|
115
|
-
ak-role analyst sweep --attach ./payload.md
|
|
116
|
-
ak-role analyst --cohort \
|
|
117
|
-
--group-a-label A --group-a-issues 1,2 \
|
|
118
|
-
--group-b-label B --group-b-issues 3,4
|
|
119
100
|
|
|
120
|
-
# escalate 后:把 owner 裁定喂回同一 session
|
|
101
|
+
# escalate 后:把 owner 裁定喂回同一 session(标准链)
|
|
121
102
|
ak-role resume <runId> "<裁定>"
|
|
122
103
|
```
|
|
123
104
|
|
|
@@ -164,95 +145,8 @@ ak-role resume <runId> "<裁定>"
|
|
|
164
145
|
|
|
165
146
|
开启:`echo "fast_mode = on" > ~/.pi-codex-fast`;关闭:`echo "fast_mode = off" > ~/.pi-codex-fast`(或删文件)。修改后无需重启,下一个请求即生效。Fast 档价格高于默认档。
|
|
166
147
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
### `global`
|
|
173
|
-
|
|
174
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
175
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
176
|
-
| `--model` | — | `provider/model` | 否 | 否 | option | — | 覆盖本调用有效席位模型(可置于子命令前或后)。 |
|
|
177
|
-
| `--thinking` | — | `level` | 否 | 否 | option | — | 覆盖 thinking 档位:off\|minimal\|low\|medium\|high\|xhigh\|max。 |
|
|
178
|
-
| `--engine` | — | `name` | 否 | 否 | option | — | 本调用可选劳动引擎(池令名字;有包内调法笔记则附卷;全部角色可用)。 |
|
|
179
|
-
| `--help` | `-h` | — | 否 | 否 | option | — | 显示公开 CLI 帮助并退出。 |
|
|
180
|
-
|
|
181
|
-
### `judge`
|
|
182
|
-
|
|
183
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
184
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
185
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
186
|
-
| `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
|
|
187
|
-
|
|
188
|
-
### `coder`
|
|
189
|
-
|
|
190
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
191
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
192
|
-
| `plan\|apply` | `plan`, `apply` | — | 否 | 否 | positional | phases=plan\|apply; default=apply | 指令前可选 phase 词元;默认 apply。 |
|
|
193
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
194
|
-
| `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
|
|
195
|
-
|
|
196
|
-
### `fixer`
|
|
197
|
-
|
|
198
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
199
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
200
|
-
| `plan\|apply` | `plan`, `apply` | — | 否 | 否 | positional | phases=plan\|apply; default=apply | 指令前可选 phase 词元;默认 apply。 |
|
|
201
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
202
|
-
| `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
|
|
203
|
-
| `--prerequisites` | — | `path` | 否 | 否 | option | — | {id, requirement} 前置条件 JSON 数组路径。 |
|
|
204
|
-
|
|
205
|
-
### `reviewer`
|
|
206
|
-
|
|
207
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
208
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
209
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
210
|
-
| `--base` | — | `revision` | 是 | 否 | option | — | 必填;钉住审查目标的 fixed-point revision。 |
|
|
211
|
-
| `--authority-ref` | — | `ref` | 否 | 是 | option | — | 持久 authority 引用/URL(可重复;仅 ref,非内联散文)。 |
|
|
212
|
-
|
|
213
|
-
### `collector`
|
|
214
|
-
|
|
215
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
216
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
217
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
218
|
-
| `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
|
|
219
|
-
| `--pr` | — | `number` | 是 | 否 | option | — | 必填;正整数 GitHub PR 号。 |
|
|
220
|
-
| `--repo` | — | `owner/repo` | 否 | 否 | option | — | GitHub owner/repo 覆盖(默认取 github.com origin)。 |
|
|
221
|
-
| `--request-manifest` | — | `path` | 否 | 否 | option | — | 可选 request manifest JSON 路径({requests:[{id,body}]})。 |
|
|
222
|
-
|
|
223
|
-
### `doctor`
|
|
224
|
-
|
|
225
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
226
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
227
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
228
|
-
| `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
|
|
229
|
-
| `--issue` | — | `number` | 是 | 否 | option | — | 必填;留存病例的正整数 issue 号。 |
|
|
230
|
-
| `--runs` | — | `path` | 否 | 否 | option | — | 可选项目相对 .ak-roles/books/<book>/issues/<n>/runs 覆盖,且须匹配 --issue。 |
|
|
231
|
-
|
|
232
|
-
### `merger`
|
|
233
|
-
|
|
234
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
235
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
236
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 已有进行中 ordinary merge 的项目根(默认 cwd)。 |
|
|
237
|
-
| `--attach` | — | `path` | 否 | 是 | option | — | 附加普通文件;受理即冻结(可重复)。 |
|
|
238
|
-
|
|
239
|
-
### `notary`
|
|
240
|
-
|
|
241
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
242
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
243
|
-
| `--project` | — | `path` | 否 | 否 | option | — | 卷宗身份用的项目根(默认进程 cwd)。 |
|
|
244
|
-
| `--source-run` | — | `runId@role\|path` | 是 | 否 | option | — | 必填源 run 定位符(簿内 runId@role,或该 run 目录路径)。零 prompt/附件投影。 |
|
|
245
|
-
|
|
246
|
-
### `analyst`
|
|
247
|
-
|
|
248
|
-
| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |
|
|
249
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
250
|
-
| `sweep` | — | — | 否 | 否 | positional | modes=sweep | 可选 sweep 模式词元(至多一次;不得夹带其他 positional)。 |
|
|
251
|
-
| `--ticket` | — | `number` | 否 | 否 | option | modes=issue | 票号;在 cwd 候簿(git common-dir)内按 invocation.ticketNumber 现取现算。裸调用=整簿。不依赖 library-index 自举。 |
|
|
252
|
-
| `--attach` | — | `path` | 条件:sweep | 是 | option | modes=sweep; max=sweep:1 | sweep 模式附件路径;sweep 必填且恰一次;载荷为附件正文。 |
|
|
253
|
-
| `--cohort` | — | — | 否 | 否 | option | modes=cohort | 选择 cohort 模式。 |
|
|
254
|
-
| `--group-a-label` | — | `label` | 条件:cohort | 否 | option | modes=cohort | cohort A 组标签(cohort 模式必填)。 |
|
|
255
|
-
| `--group-a-issues` | — | `N\|book:N[,...]` | 条件:cohort | 否 | option | modes=cohort | cohort A 组 issue:裸 N 归属 cwd 簿;book:N 显式跨簿;簿键中的逗号/反斜杠用 \, / \\ 转义(cohort 模式必填)。 |
|
|
256
|
-
| `--group-b-label` | — | `label` | 条件:cohort | 否 | option | modes=cohort | cohort B 组标签(cohort 模式必填)。 |
|
|
257
|
-
| `--group-b-issues` | — | `N\|book:N[,...]` | 条件:cohort | 否 | option | modes=cohort | cohort B 组 issue:裸 N 归属 cwd 簿;book:N 显式跨簿;簿键中的逗号/反斜杠用 \, / \\ 转义(cohort 模式必填)。 |
|
|
258
|
-
<!-- END GENERATED: public-cli-options -->
|
|
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/` 导出。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akagilnc/pi-workflow-roles",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2521",
|
|
4
4
|
"description": "Soul-bound workflow roles for Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "tsx scripts/generate-tool-execution-observation-schema.ts && tsc -p tsconfig.build.json && node scripts/build-package.mjs",
|
|
44
44
|
"prepack": "npm run build",
|
|
45
|
-
"test": "node --import tsx --test test/unit/**/*.test.ts test/contract/**/*.test.ts",
|
|
46
|
-
"test:fast": "node --import tsx --test test/unit/**/*.test.ts test/contract/**/*.test.ts",
|
|
47
|
-
"test:integration": "node --import tsx --test test/unit/**/*.test.ts test/contract/**/*.test.ts test/integration/**/*.test.ts",
|
|
45
|
+
"test": "node --import tsx --import ./scripts/test-process-env-preload.mjs --test test/unit/**/*.test.ts test/contract/**/*.test.ts",
|
|
46
|
+
"test:fast": "node --import tsx --import ./scripts/test-process-env-preload.mjs --test test/unit/**/*.test.ts test/contract/**/*.test.ts",
|
|
47
|
+
"test:integration": "node --import tsx --import ./scripts/test-process-env-preload.mjs --test test/unit/**/*.test.ts test/contract/**/*.test.ts test/integration/**/*.test.ts",
|
|
48
48
|
"test:all": "node scripts/run-test-all.mjs",
|
|
49
|
-
"test:adjudication": "node --import tsx --test test/adjudication/**/*.test.ts",
|
|
49
|
+
"test:adjudication": "node --import tsx --import ./scripts/test-process-env-preload.mjs --test test/adjudication/**/*.test.ts",
|
|
50
50
|
"typecheck": "tsc --noEmit"
|
|
51
51
|
},
|
|
52
52
|
"pi": {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* #342 — sole typed public CLI option-definition source.
|
|
3
3
|
*
|
|
4
4
|
* PUBLIC_ROLE_ARGV rows reference these definitions. Production parsers and
|
|
5
|
-
* `help <command>` consume this table
|
|
6
|
-
*
|
|
5
|
+
* `help <command>` consume this table. Do not maintain a parallel spelling set
|
|
6
|
+
* in parsers, help, or docs.
|
|
7
7
|
*
|
|
8
8
|
* Dashed-option take, positional selector match, role-phase resolution,
|
|
9
9
|
* `repeatable` enforcement, and unconditional `required` checks share one
|
|
@@ -215,7 +215,7 @@ export function evaluateAnalystModeOptionContract(
|
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
217
|
* Rejected / internal spellings retained by parsers for explicit refusal.
|
|
218
|
-
* Must never appear in public help
|
|
218
|
+
* Must never appear in public help.
|
|
219
219
|
*/
|
|
220
220
|
export type RejectedSpelling = {
|
|
221
221
|
readonly owner: OptionOwner;
|
|
@@ -1219,136 +1219,3 @@ export function renderHumanOwnerOptionLines(
|
|
|
1219
1219
|
}
|
|
1220
1220
|
return lines;
|
|
1221
1221
|
}
|
|
1222
|
-
|
|
1223
|
-
const README_BEGIN = "<!-- BEGIN GENERATED: public-cli-options -->";
|
|
1224
|
-
const README_END = "<!-- END GENERATED: public-cli-options -->";
|
|
1225
|
-
|
|
1226
|
-
export const PUBLIC_CLI_OPTIONS_README_MARKERS = {
|
|
1227
|
-
begin: README_BEGIN,
|
|
1228
|
-
end: README_END,
|
|
1229
|
-
} as const;
|
|
1230
|
-
|
|
1231
|
-
/** Escape `|` so GFM table cells keep their column count (including inside code spans). */
|
|
1232
|
-
function escapeMarkdownTableCell(value: string): string {
|
|
1233
|
-
return value.replaceAll("|", "\\|");
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
/** Markdown flag inventory for README generation (EN or ZH). */
|
|
1237
|
-
export function renderReadmeOptionsMarkdown(locale: "en" | "zh"): string {
|
|
1238
|
-
const lines: string[] = [];
|
|
1239
|
-
if (locale === "zh") {
|
|
1240
|
-
lines.push("## 公开 CLI 选项(生成)");
|
|
1241
|
-
lines.push("");
|
|
1242
|
-
lines.push(
|
|
1243
|
-
"本表由 `src/public-cli/option-definitions.ts` 生成;以 `ak-role help <command>` 为准。勿手改本区。",
|
|
1244
|
-
);
|
|
1245
|
-
} else {
|
|
1246
|
-
lines.push("## Public CLI options (generated)");
|
|
1247
|
-
lines.push("");
|
|
1248
|
-
lines.push(
|
|
1249
|
-
"Generated from `src/public-cli/option-definitions.ts`. Prefer `ak-role help <command>`. Do not hand-edit this section.",
|
|
1250
|
-
);
|
|
1251
|
-
}
|
|
1252
|
-
lines.push("");
|
|
1253
|
-
|
|
1254
|
-
const owners: OptionOwner[] = ["global", ...PUBLIC_ROLE_OPTION_OWNERS];
|
|
1255
|
-
for (const owner of owners) {
|
|
1256
|
-
lines.push(locale === "zh" ? `### \`${owner}\`` : `### \`${owner}\``);
|
|
1257
|
-
lines.push("");
|
|
1258
|
-
lines.push(
|
|
1259
|
-
locale === "zh"
|
|
1260
|
-
? "| 拼写 | 别名 | 值 | 必填 | 可重复 | 形式 | 模式/阶段 | 说明 |"
|
|
1261
|
-
: "| Spelling | Aliases | Value | Required | Repeatable | Form | Modes/Phases | Description |",
|
|
1262
|
-
);
|
|
1263
|
-
lines.push("| --- | --- | --- | --- | --- | --- | --- | --- |");
|
|
1264
|
-
for (const opt of projectOwnerOptions(owner)) {
|
|
1265
|
-
const aliasesRaw =
|
|
1266
|
-
opt.aliases.length === 0 ? "—" : opt.aliases.join(", ");
|
|
1267
|
-
const aliases =
|
|
1268
|
-
aliasesRaw === "—"
|
|
1269
|
-
? aliasesRaw
|
|
1270
|
-
: aliasesRaw
|
|
1271
|
-
.split(", ")
|
|
1272
|
-
.map((a) => `\`${escapeMarkdownTableCell(a)}\``)
|
|
1273
|
-
.join(", ");
|
|
1274
|
-
const valueRaw = opt.valueMetavar ?? "—";
|
|
1275
|
-
const value =
|
|
1276
|
-
valueRaw === "—"
|
|
1277
|
-
? valueRaw
|
|
1278
|
-
: `\`${escapeMarkdownTableCell(valueRaw)}\``;
|
|
1279
|
-
const requiredRaw = opt.required
|
|
1280
|
-
? locale === "zh"
|
|
1281
|
-
? "是"
|
|
1282
|
-
: "yes"
|
|
1283
|
-
: opt.requiredInModes !== undefined
|
|
1284
|
-
? locale === "zh"
|
|
1285
|
-
? `条件:${opt.requiredInModes.join("|")}`
|
|
1286
|
-
: `when:${opt.requiredInModes.join("|")}`
|
|
1287
|
-
: locale === "zh"
|
|
1288
|
-
? "否"
|
|
1289
|
-
: "no";
|
|
1290
|
-
const required = escapeMarkdownTableCell(requiredRaw);
|
|
1291
|
-
const repeatable = escapeMarkdownTableCell(
|
|
1292
|
-
opt.repeatable
|
|
1293
|
-
? locale === "zh"
|
|
1294
|
-
? "是"
|
|
1295
|
-
: "yes"
|
|
1296
|
-
: locale === "zh"
|
|
1297
|
-
? "否"
|
|
1298
|
-
: "no",
|
|
1299
|
-
);
|
|
1300
|
-
const modePhase = escapeMarkdownTableCell(
|
|
1301
|
-
[
|
|
1302
|
-
opt.modes === undefined ? "" : `modes=${opt.modes.join("|")}`,
|
|
1303
|
-
opt.phases === undefined ? "" : `phases=${opt.phases.join("|")}`,
|
|
1304
|
-
opt.exclusiveWith === undefined
|
|
1305
|
-
? ""
|
|
1306
|
-
: `xor=${opt.exclusiveWith.join("|")}`,
|
|
1307
|
-
opt.maxCountByMode === undefined
|
|
1308
|
-
? ""
|
|
1309
|
-
: `max=${Object.entries(opt.maxCountByMode)
|
|
1310
|
-
.map(([m, n]) => `${m}:${n}`)
|
|
1311
|
-
.join(",")}`,
|
|
1312
|
-
opt.defaultValue === undefined ? "" : `default=${opt.defaultValue}`,
|
|
1313
|
-
]
|
|
1314
|
-
.filter((part) => part !== "")
|
|
1315
|
-
.join("; ") || "—",
|
|
1316
|
-
);
|
|
1317
|
-
const desc = escapeMarkdownTableCell(
|
|
1318
|
-
locale === "zh" ? opt.description.zh : opt.description.en,
|
|
1319
|
-
);
|
|
1320
|
-
const spelling = `\`${escapeMarkdownTableCell(opt.canonical)}\``;
|
|
1321
|
-
const form = escapeMarkdownTableCell(opt.form);
|
|
1322
|
-
lines.push(
|
|
1323
|
-
`| ${spelling} | ${aliases} | ${value} | ${required} | ${repeatable} | ${form} | ${modePhase} | ${desc} |`,
|
|
1324
|
-
);
|
|
1325
|
-
}
|
|
1326
|
-
lines.push("");
|
|
1327
|
-
}
|
|
1328
|
-
return `${lines.join("\n").trimEnd()}\n`;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
/**
|
|
1332
|
-
* Replace the generated region inside a README body, or append one.
|
|
1333
|
-
* Returns the full file text.
|
|
1334
|
-
*/
|
|
1335
|
-
export function applyReadmeOptionsSection(
|
|
1336
|
-
readmeText: string,
|
|
1337
|
-
locale: "en" | "zh",
|
|
1338
|
-
): string {
|
|
1339
|
-
const section = `${README_BEGIN}\n${renderReadmeOptionsMarkdown(locale)}${README_END}\n`;
|
|
1340
|
-
const beginIdx = readmeText.indexOf(README_BEGIN);
|
|
1341
|
-
const endIdx = readmeText.indexOf(README_END);
|
|
1342
|
-
if (beginIdx !== -1 && endIdx !== -1 && endIdx > beginIdx) {
|
|
1343
|
-
const afterEnd = endIdx + README_END.length;
|
|
1344
|
-
// Consume a single trailing newline after the end marker when present.
|
|
1345
|
-
const tailStart =
|
|
1346
|
-
readmeText[afterEnd] === "\n" ? afterEnd + 1 : afterEnd;
|
|
1347
|
-
return (
|
|
1348
|
-
readmeText.slice(0, beginIdx) + section + readmeText.slice(tailStart)
|
|
1349
|
-
);
|
|
1350
|
-
}
|
|
1351
|
-
// No markers yet — append before EOF.
|
|
1352
|
-
const base = readmeText.endsWith("\n") ? readmeText : `${readmeText}\n`;
|
|
1353
|
-
return `${base}\n${section}`;
|
|
1354
|
-
}
|