@akagilnc/pi-workflow-roles 0.1.2521 → 0.1.2653-next.71811ca
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 +129 -39
- package/README.zh-CN.md +128 -39
- package/dist/activation-ledger-topology.js +1 -1
- package/dist/archivist-record-entry.js +47 -26
- package/dist/auditor-dossier-tool.js +3 -1
- package/dist/compliance-transport.js +17 -26
- package/dist/doctor-contracts.js +1 -2
- package/dist/dossier-resolution.js +4 -8
- package/dist/engine-detour-tool.js +33 -8
- package/dist/engine-detour.js +1 -0
- package/dist/evidence-child-executor.js +277 -424
- package/dist/host-contracts.js +22 -0
- package/dist/institutional-resolution.js +88 -0
- package/dist/merger-contracts.js +1 -2
- package/dist/navigator-attendance.js +16 -0
- package/dist/notary-contracts.js +2 -3
- package/dist/package-contracts/fixer-output.js +1 -2
- package/dist/packaged-role-registry.js +102 -9
- package/dist/pi/in-process-session.js +671 -0
- package/dist/public-cli/config.js +7 -5
- package/dist/public-cli/main.js +3767 -4113
- package/dist/reviewer-child-executor.js +6 -1
- package/dist/session-opening-materials.js +10 -38
- package/dist/sitian-appender.js +146 -0
- package/dist/sitian-contracts.js +21 -0
- package/dist/sitian-facade.js +15 -0
- package/dist/sitian-reader.js +52 -0
- package/extensions/role-runtime.ts +9 -7
- package/package.json +5 -5
- package/resources/engines/cursor.md +12 -26
- package/resources/engines/hermes.md +2 -23
- package/resources/engines/opus.md +1 -16
- package/resources/navigator-route-playbook.md +2 -2
- package/scripts/build-package.mjs +0 -1
- package/souls/quality-law.md +1 -1
- package/src/activation-ledger-topology.ts +1 -1
- package/src/archivist-record-entry.ts +57 -45
- package/src/auditor-dossier-tool.ts +4 -2
- package/src/canonical-skill-binding.ts +37 -27
- package/src/collector-role.ts +11 -20
- package/src/collector-tool-schemas.ts +1 -4
- package/src/compliance-transport.ts +19 -44
- package/src/doctor-auditor.ts +1 -5
- package/src/doctor-contracts.ts +1 -4
- package/src/doctor-role.ts +31 -8
- package/src/dossier-resolution.ts +8 -8
- package/src/engine-detour-tool.ts +48 -19
- package/src/engine-detour.ts +3 -0
- package/src/evidence-child-executor.ts +277 -485
- package/src/factory-board.ts +3 -3
- package/src/gatekeeper-role.ts +21 -10
- package/src/host-contracts.ts +386 -0
- package/src/in-process-session.ts +1 -115
- package/src/institutional-resolution.ts +135 -0
- package/src/judge-auditor.ts +1 -5
- package/src/judge-role.ts +37 -51
- package/src/merger-contracts.ts +1 -4
- package/src/merger-role.ts +7 -11
- package/src/navigator-attendance.ts +20 -1
- package/src/notary-contracts.ts +8 -11
- package/src/notary-role.ts +7 -23
- package/src/notary-source-run.ts +4 -3
- package/src/package-contracts/fixer-output.ts +1 -4
- package/src/package-resources/method-skill-binding.ts +10 -34
- package/src/packaged-role-registry.ts +122 -12
- package/src/pi/adapter.ts +192 -0
- package/src/pi/durable-principal.ts +98 -0
- package/src/pi/in-process-session.ts +819 -0
- package/src/pi/known-failure.ts +77 -0
- package/src/pi/pi-normalization.ts +284 -0
- package/src/pi/role-turn-host.ts +459 -0
- package/src/public-cli/auto-resume.ts +42 -44
- package/src/public-cli/cli.ts +171 -257
- package/src/public-cli/coder-run.ts +115 -433
- package/src/public-cli/collector-run.ts +62 -314
- package/src/public-cli/config.ts +7 -5
- package/src/public-cli/doctor-run.ts +41 -52
- package/src/public-cli/fixer-run.ts +122 -427
- package/src/public-cli/invocation.ts +287 -96
- package/src/public-cli/judge-run.ts +92 -422
- package/src/public-cli/merger-run.ts +167 -429
- package/src/public-cli/notary-run.ts +41 -47
- package/src/public-cli/option-definitions.ts +136 -3
- package/src/public-cli/post-admission.ts +497 -0
- package/src/public-cli/public-run-credentials.ts +4 -4
- package/src/public-cli/reviewer-dispatch-rejection.ts +106 -0
- package/src/public-cli/reviewer-run.ts +132 -449
- package/src/public-cli/run-lifecycle.ts +339 -327
- package/src/public-cli/settlement.ts +251 -134
- package/src/public-cli/terminal.ts +3 -9
- package/src/public-cli/turn-request.ts +87 -0
- package/src/reviewer-child-executor.ts +9 -1
- package/src/reviewer-role.ts +11 -20
- package/src/role-runtime.ts +129 -78
- package/src/session-opening-materials.ts +25 -39
- package/src/sitian-appender.ts +171 -0
- package/src/sitian-contracts.ts +106 -0
- package/src/sitian-facade.ts +18 -0
- package/src/sitian-reader.ts +62 -0
- package/src/worker-role.ts +42 -40
- package/src/worker-submission-gates.ts +33 -0
- package/dist/archivist-role-run-coordinates.js +0 -28
- package/dist/package-contracts/terminating-infrastructure.js +0 -90
- package/resources/engines/sonnet.md +0 -27
- package/resources/engines/zcode.md +0 -63
- package/src/archivist-role-run-coordinates.ts +0 -45
- package/src/package-contracts/terminating-infrastructure.ts +0 -132
- package/src/public-cli/explicit-internal.ts +0 -427
- package/src/public-cli/one-shot-dispatch.ts +0 -300
|
@@ -1,68 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Public Notary Role run: admit source-run locator → shared
|
|
3
|
-
* → settle Terminal result (#448). Zero caller prompt/attachment. Lifecycle is
|
|
4
|
-
* the shared
|
|
2
|
+
* Public Notary Role run: admit source-run locator → shared post-admission coordinator
|
|
3
|
+
* → settle Terminal result (#448 / #517). Zero caller prompt/attachment. Lifecycle is
|
|
4
|
+
* the shared post-admission seam; this module keeps only Notary adapters.
|
|
5
5
|
*/
|
|
6
|
+
import type { DurablePrincipalAuthority, RoleTurnRequest } from "../host-contracts.ts";
|
|
6
7
|
import { engineSessionMaterialFromOptions } from "../package-resources/engine-material.ts";
|
|
7
8
|
import { CliUsageError } from "./cli-errors.ts";
|
|
8
9
|
import {
|
|
9
10
|
admitNotaryInvocation,
|
|
10
11
|
buildNotaryTransportPrompt,
|
|
11
12
|
type AdmittedNotaryInvocation,
|
|
12
|
-
type ParseNotaryArgvResult
|
|
13
|
+
type ParseNotaryArgvResult
|
|
13
14
|
} from "./invocation.ts";
|
|
14
15
|
import {
|
|
15
|
-
|
|
16
|
-
type
|
|
17
|
-
} from "./
|
|
18
|
-
import {
|
|
19
|
-
runAdmittedOneShotRole,
|
|
20
|
-
type OneShotRunEnv,
|
|
21
|
-
} from "./one-shot-dispatch.ts";
|
|
16
|
+
runPostAdmissionOneShot,
|
|
17
|
+
type PostAdmissionEnv,
|
|
18
|
+
} from "./post-admission.ts";
|
|
19
|
+
import { markRunAdmitted } from "./run-lifecycle.ts";
|
|
22
20
|
import {
|
|
23
21
|
presentStructuralRejection,
|
|
24
22
|
trySettleNotaryTerminalResult,
|
|
25
23
|
} from "./settlement.ts";
|
|
26
24
|
import type { CliIo } from "./cli-io.ts";
|
|
27
25
|
import type { TerminalResult } from "./terminal.ts";
|
|
26
|
+
import {
|
|
27
|
+
projectRoleTurnRequest,
|
|
28
|
+
type RoleTurnRequestProjectionOptions,
|
|
29
|
+
} from "./turn-request.ts";
|
|
28
30
|
|
|
29
|
-
export type NotaryRunEnv =
|
|
31
|
+
export type NotaryRunEnv = PostAdmissionEnv & {
|
|
32
|
+
principalAuthority: DurablePrincipalAuthority;
|
|
30
33
|
createRunId?: () => string;
|
|
31
|
-
extraPiArgs?: readonly string[];
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
/** Project admitted invocation onto the host-neutral turn request. */
|
|
37
|
+
export function buildNotaryTurnRequest(
|
|
35
38
|
admitted: AdmittedNotaryInvocation,
|
|
36
|
-
options:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
packageRoot?: string;
|
|
40
|
-
extraPiArgs?: readonly string[];
|
|
41
|
-
} = {},
|
|
42
|
-
): string[] {
|
|
43
|
-
const prompt = buildNotaryTransportPrompt(
|
|
39
|
+
options: RoleTurnRequestProjectionOptions,
|
|
40
|
+
): RoleTurnRequest {
|
|
41
|
+
return projectRoleTurnRequest(
|
|
44
42
|
admitted,
|
|
45
|
-
|
|
43
|
+
{
|
|
44
|
+
activation: { role: "notary" as const, sourceRun: admitted.sourceRunPath },
|
|
45
|
+
},
|
|
46
|
+
options,
|
|
46
47
|
);
|
|
47
|
-
return [
|
|
48
|
-
"--no-skills",
|
|
49
|
-
"--no-prompt-templates",
|
|
50
|
-
"--no-themes",
|
|
51
|
-
"--no-context-files",
|
|
52
|
-
"--session",
|
|
53
|
-
admitted.sessionFile,
|
|
54
|
-
"--session-dir",
|
|
55
|
-
admitted.sessionDirectory,
|
|
56
|
-
...(options.extraPiArgs ?? []),
|
|
57
|
-
"--ak-role",
|
|
58
|
-
"notary",
|
|
59
|
-
"--ak-notary-source-run",
|
|
60
|
-
admitted.sourceRunPath,
|
|
61
|
-
"--mode",
|
|
62
|
-
"json",
|
|
63
|
-
...buildSeatModelCliArgs(options.model),
|
|
64
|
-
prompt,
|
|
65
|
-
];
|
|
66
48
|
}
|
|
67
49
|
|
|
68
50
|
export async function runPublicNotary(
|
|
@@ -80,6 +62,7 @@ export async function runPublicNotary(
|
|
|
80
62
|
const parsed = parseNotaryArgv(argv);
|
|
81
63
|
admitted = await admitNotaryInvocation({
|
|
82
64
|
home: env.home,
|
|
65
|
+
principalAuthority: env.principalAuthority,
|
|
83
66
|
cwd: env.cwd,
|
|
84
67
|
sourceRun: parsed.sourceRun,
|
|
85
68
|
...(parsed.project === undefined ? {} : { project: parsed.project }),
|
|
@@ -95,20 +78,31 @@ export async function runPublicNotary(
|
|
|
95
78
|
throw error;
|
|
96
79
|
}
|
|
97
80
|
|
|
98
|
-
|
|
81
|
+
await markRunAdmitted(admitted, env.principalAuthority);
|
|
82
|
+
|
|
83
|
+
const turnRequest = buildNotaryTurnRequest(admitted, {
|
|
99
84
|
packageRoot: env.packageRoot,
|
|
85
|
+
home: env.home,
|
|
86
|
+
agentDir: env.agentDir,
|
|
100
87
|
...(env.model === undefined ? {} : { model: env.model }),
|
|
101
88
|
...(env.engine === undefined ? {} : { engine: env.engine }),
|
|
102
|
-
...(env.
|
|
89
|
+
...(env.timeoutMs === undefined ? {} : { timeoutMs: env.timeoutMs }),
|
|
90
|
+
...(env.correlationId === undefined || env.correlationId.trim() === ""
|
|
91
|
+
? {}
|
|
92
|
+
: { correlationId: env.correlationId }),
|
|
93
|
+
continuation: {
|
|
94
|
+
kind: "initial",
|
|
95
|
+
prompt: buildNotaryTransportPrompt(admitted, engineSessionMaterialFromOptions({ ...(env.engine === undefined ? {} : { engine: env.engine }), packageRoot: env.packageRoot })),
|
|
96
|
+
},
|
|
103
97
|
});
|
|
104
98
|
|
|
105
|
-
return await
|
|
99
|
+
return await runPostAdmissionOneShot({
|
|
106
100
|
admitted,
|
|
107
101
|
env,
|
|
108
102
|
io,
|
|
109
|
-
|
|
103
|
+
request: turnRequest,
|
|
110
104
|
adapters: {
|
|
111
|
-
trySettle: trySettleNotaryTerminalResult,
|
|
105
|
+
trySettle: (admitted, authority) => trySettleNotaryTerminalResult(admitted, authority),
|
|
112
106
|
// Accepted receipts and failure terminals both present via shared path.
|
|
113
107
|
shouldPresentSettled: () => true,
|
|
114
108
|
},
|
|
@@ -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
|
-
* in parsers, help, or docs.
|
|
5
|
+
* `help <command>` consume this table; README flag inventory is generated from
|
|
6
|
+
* it. Do not maintain a parallel spelling set 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 or README projections.
|
|
219
219
|
*/
|
|
220
220
|
export type RejectedSpelling = {
|
|
221
221
|
readonly owner: OptionOwner;
|
|
@@ -1219,3 +1219,136 @@ 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
|
+
}
|