@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
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
import { renderPublicAkRoleCommand } from "./command-renderer.ts";
|
|
9
9
|
import type { NavigatorPhase } from "../navigator-attendance.ts";
|
|
10
10
|
import type { NoReceiptLifecycleFacts } from "../receipt-delivery-policy.ts";
|
|
11
|
+
import type { ControlledFailureCause } from "../host-contracts.ts";
|
|
12
|
+
|
|
13
|
+
export type { ControlledFailureCause } from "../host-contracts.ts";
|
|
11
14
|
|
|
12
15
|
/** Encode one free-text Terminal cell. JSON string form cannot embed raw tab/newline. */
|
|
13
16
|
export function encodeTerminalField(value: string): string {
|
|
@@ -20,15 +23,6 @@ export type TerminalArtifactRef = {
|
|
|
20
23
|
path: string;
|
|
21
24
|
};
|
|
22
25
|
|
|
23
|
-
/** Controlled post-admission failure classes (ADR 0052 / #107). */
|
|
24
|
-
export type ControlledFailureCause =
|
|
25
|
-
| "activation"
|
|
26
|
-
| "provider"
|
|
27
|
-
| "session"
|
|
28
|
-
| "output"
|
|
29
|
-
| "timeout"
|
|
30
|
-
| "unrecognized";
|
|
31
|
-
|
|
32
26
|
/** Public callable roles that currently produce Terminal outcomes. */
|
|
33
27
|
export type TerminalRoleName =
|
|
34
28
|
| "judge"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-owner host-neutral TurnRequest projection (#526 / standards-3).
|
|
3
|
+
* Collapses common principal, cwd, runDirectory, model, engine, continuation,
|
|
4
|
+
* and correlationId assembly across all public roles.
|
|
5
|
+
*/
|
|
6
|
+
import type {
|
|
7
|
+
DurablePrincipal,
|
|
8
|
+
MethodBinding,
|
|
9
|
+
RoleTurnActivation,
|
|
10
|
+
RoleTurnModelConfig,
|
|
11
|
+
RoleTurnRequest,
|
|
12
|
+
} from "../host-contracts.ts";
|
|
13
|
+
import type { SeatModelConfig } from "./config.ts";
|
|
14
|
+
import type { PublicThinkingLevel } from "./registry.ts";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Single authority for resume model precedence: an explicit CLI/env model wins;
|
|
18
|
+
* otherwise the admitted (originally recorded) model is restored, including its
|
|
19
|
+
* thinking level. `undefined` when neither source carries a model.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveResumeModel(
|
|
22
|
+
explicitModel: ResumeModelConfig | undefined,
|
|
23
|
+
admittedModel: ResumeModelConfig | undefined,
|
|
24
|
+
): ResumeModelConfig | undefined {
|
|
25
|
+
return explicitModel ?? admittedModel;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Structural model shape shared by the seam so both config sources fit. */
|
|
29
|
+
export type ResumeModelConfig = {
|
|
30
|
+
readonly provider: string;
|
|
31
|
+
readonly model: string;
|
|
32
|
+
readonly thinking?: PublicThinkingLevel;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type RoleTurnRequestProjectionOptions = {
|
|
36
|
+
packageRoot: string;
|
|
37
|
+
home: string;
|
|
38
|
+
agentDir: string;
|
|
39
|
+
model?: SeatModelConfig;
|
|
40
|
+
engine?: string;
|
|
41
|
+
timeoutMs?: number;
|
|
42
|
+
correlationId?: string;
|
|
43
|
+
continuation: RoleTurnRequest["continuation"];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type AdmittedTurnInvocation = {
|
|
47
|
+
principal?: DurablePrincipal;
|
|
48
|
+
projectRoot?: string;
|
|
49
|
+
repoRoot?: string;
|
|
50
|
+
cwd?: string;
|
|
51
|
+
runDirectory: string;
|
|
52
|
+
/** Effective model restored on resume; fallback when no CLI/env model is given. */
|
|
53
|
+
model?: ResumeModelConfig;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function projectRoleTurnRequest(
|
|
57
|
+
admitted: AdmittedTurnInvocation,
|
|
58
|
+
roleDetails: {
|
|
59
|
+
activation: RoleTurnActivation;
|
|
60
|
+
methods?: readonly MethodBinding[];
|
|
61
|
+
},
|
|
62
|
+
options: RoleTurnRequestProjectionOptions,
|
|
63
|
+
): RoleTurnRequest {
|
|
64
|
+
const cwd = admitted.projectRoot ?? admitted.repoRoot ?? admitted.cwd;
|
|
65
|
+
if (cwd === undefined) throw new Error("admitted invocation missing working directory");
|
|
66
|
+
if (admitted.principal === undefined) throw new Error("admitted invocation missing principal");
|
|
67
|
+
// Explicit CLI/env model wins on resume; admitted model is the fallback so a
|
|
68
|
+
// model-less resume restores the originally recorded effective model instead of
|
|
69
|
+
// silently dropping to the current env default.
|
|
70
|
+
const effectiveModel = resolveResumeModel(options.model, admitted.model);
|
|
71
|
+
return {
|
|
72
|
+
principal: admitted.principal,
|
|
73
|
+
activation: roleDetails.activation,
|
|
74
|
+
methods: roleDetails.methods ?? [],
|
|
75
|
+
continuation: options.continuation,
|
|
76
|
+
...(effectiveModel === undefined ? {} : { model: effectiveModel }),
|
|
77
|
+
...(options.engine === undefined ? {} : { engine: options.engine }),
|
|
78
|
+
cwd,
|
|
79
|
+
home: options.home,
|
|
80
|
+
agentDir: options.agentDir,
|
|
81
|
+
runDirectory: admitted.runDirectory,
|
|
82
|
+
...(options.correlationId === undefined || options.correlationId.trim() === ""
|
|
83
|
+
? {}
|
|
84
|
+
: { correlationId: options.correlationId }),
|
|
85
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -5,6 +5,9 @@ import type { AcceptedReviewerLeg } from "./reviewer-dispatch.ts";
|
|
|
5
5
|
export type ReviewerChildExecuteOptions = Readonly<{
|
|
6
6
|
signal?: AbortSignal;
|
|
7
7
|
credentialScratchParent?: string;
|
|
8
|
+
/** Run directory carrying the institutional resolution page (#518). Derives
|
|
9
|
+
* from context when absent. */
|
|
10
|
+
runDirectory?: string;
|
|
8
11
|
/** Package root for optional engine method-material on legs (#378). */
|
|
9
12
|
packageRoot?: string;
|
|
10
13
|
}>;
|
|
@@ -26,7 +29,12 @@ export function projectSharedChildFailure(error: unknown): unknown {
|
|
|
26
29
|
/** Reviewer policy adapter over the shared evidence-child lifecycle seam. */
|
|
27
30
|
export async function executeReviewerChild(workspace: string, leg: AcceptedReviewerLeg, context: ExtensionContext, options: ReviewerChildExecuteOptions = {}) {
|
|
28
31
|
try {
|
|
29
|
-
return await executeEvidenceChild(workspace, leg.prompt, context,
|
|
32
|
+
return await executeEvidenceChild(workspace, leg.prompt, context, {
|
|
33
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
34
|
+
...(options.credentialScratchParent === undefined ? {} : { credentialScratchParent: options.credentialScratchParent }),
|
|
35
|
+
...(options.runDirectory === undefined ? {} : { runDirectory: options.runDirectory }),
|
|
36
|
+
...(options.packageRoot === undefined ? {} : { packageRoot: options.packageRoot }),
|
|
37
|
+
});
|
|
30
38
|
} catch (error) {
|
|
31
39
|
throw projectSharedChildFailure(error);
|
|
32
40
|
}
|
package/src/reviewer-role.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RoleHost, HostContext, HostToolResult } from "./host-contracts.ts";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { openToolObjectFromUnion } from "./open-tool-schema.ts";
|
|
4
4
|
|
|
@@ -10,10 +10,6 @@ import { ReviewerDispatchExecutionError, type ReviewerDispatchRunResult } from "
|
|
|
10
10
|
import { createReviewerExecutionLedger, projectAcceptedDispatch, projectReviewerDispatchOutcome, type ReviewerExecutionRecord } from "./reviewer-execution-ledger.ts";
|
|
11
11
|
import { assembleRuntimeReviewerReceipt } from "./reviewer-settlement.ts";
|
|
12
12
|
import { REVIEWER_ACCEPTED_TEXT, REVIEWER_OUTPUT_TOOL_NAME, validateReviewerIntent, type ReviewerIntent } from "./package-contracts/reviewer-output.ts";
|
|
13
|
-
import {
|
|
14
|
-
failOnInfrastructureFailureDeclaration,
|
|
15
|
-
withInfrastructureFailureDeclaration,
|
|
16
|
-
} from "./package-contracts/terminating-infrastructure.ts";
|
|
17
13
|
|
|
18
14
|
export { REVIEWER_OUTPUT_TOOL_NAME };
|
|
19
15
|
export type { ReviewerIntent };
|
|
@@ -43,24 +39,22 @@ const reviewerOutputVariants = Type.Union([
|
|
|
43
39
|
amendments: Type.Optional(reviewerAmendmentsSchema),
|
|
44
40
|
}, { additionalProperties: false }),
|
|
45
41
|
]);
|
|
46
|
-
|
|
47
|
-
openToolObjectFromUnion(reviewerOutputVariants),
|
|
48
|
-
);
|
|
42
|
+
const reviewerOutputSchema = openToolObjectFromUnion(reviewerOutputVariants);
|
|
49
43
|
export type ReviewerRoleDependencies = {
|
|
50
44
|
loadSoul(): Promise<string>;
|
|
51
45
|
loadCanonicalSkillBinding(name: "code-review"): Promise<AnyCanonicalSkillBinding>;
|
|
52
46
|
createPinnedGitReader(): Promise<ReviewerPinnedGitReader>;
|
|
53
47
|
/** Injected issue-fetch capability; shared seam owns gh lifecycle. */
|
|
54
48
|
fetchIssue?: ReviewerIssueFetcher;
|
|
55
|
-
runDispatch(execution: AcceptedReviewerExecution, options: { context:
|
|
49
|
+
runDispatch(execution: AcceptedReviewerExecution, options: { context: HostContext; signal?: AbortSignal }): Promise<ReviewerDispatchRunResult>;
|
|
56
50
|
shutdownAgent?(): Promise<void>;
|
|
57
51
|
};
|
|
58
|
-
export type ReviewerRoleHostActions = { failInfrastructure(error: unknown, ctx:
|
|
52
|
+
export type ReviewerRoleHostActions = { failInfrastructure(error: unknown, ctx: HostContext, toolCallId?: string): never };
|
|
59
53
|
|
|
60
|
-
function requireSoleReviewerOutputCall(id: string, ctx:
|
|
54
|
+
function requireSoleReviewerOutputCall(id: string, ctx: HostContext): void {
|
|
61
55
|
const leaf = ctx.sessionManager.getLeafEntry();
|
|
62
|
-
if (leaf?.type !== "message" || leaf.message.role !== "assistant") throw new Error("御史台回执非唯一终局工具调用");
|
|
63
|
-
const calls = leaf.message.content.filter((part) => part.type === "toolCall");
|
|
56
|
+
if (leaf?.type !== "message" || leaf.message === undefined || leaf.message.role !== "assistant" || !Array.isArray(leaf.message.content)) throw new Error("御史台回执非唯一终局工具调用");
|
|
57
|
+
const calls = leaf.message.content.filter((part): part is Extract<typeof part, { type: "toolCall" }> => part.type === "toolCall");
|
|
64
58
|
if (calls.length !== 1 || calls[0]?.id !== id || calls[0]?.name !== REVIEWER_OUTPUT_TOOL_NAME) throw new Error("御史台回执非唯一终局工具调用");
|
|
65
59
|
}
|
|
66
60
|
|
|
@@ -80,11 +74,11 @@ export type ReviewerActivation = Readonly<{
|
|
|
80
74
|
* Reviewer-side 审刑院 gate retired (#495 S6 / 风闻奏事); accept on typed validate only.
|
|
81
75
|
*/
|
|
82
76
|
export function createReviewerRoleRuntime(
|
|
83
|
-
pi:
|
|
77
|
+
pi: RoleHost,
|
|
84
78
|
dependencies: ReviewerRoleDependencies,
|
|
85
79
|
hostActions: ReviewerRoleHostActions,
|
|
86
80
|
): {
|
|
87
|
-
activate(ctx:
|
|
81
|
+
activate(ctx: HostContext | undefined, admitted: ReviewerAdmittedInputs): Promise<ReviewerActivation>;
|
|
88
82
|
} {
|
|
89
83
|
let soul: string | undefined;
|
|
90
84
|
let binding: CanonicalSkillBinding<"code-review"> | undefined;
|
|
@@ -113,7 +107,7 @@ export function createReviewerRoleRuntime(
|
|
|
113
107
|
const executeAndProjectDispatch = async (execution: AcceptedReviewerExecution, invocation: unknown): Promise<ReviewerDispatchRunResult> => {
|
|
114
108
|
const dispatch = acceptedDispatch;
|
|
115
109
|
if (dispatch === undefined || dispatch.identity !== execution.identity) throw new Error("Reviewer execution lacks accepted construction evidence");
|
|
116
|
-
const { context, signal } = invocation as { context:
|
|
110
|
+
const { context, signal } = invocation as { context: HostContext; signal?: AbortSignal };
|
|
117
111
|
ledger.append({ source: "reviewer-agent", type: "dispatch-started", dispatchIdentity: execution.identity, cardinality: execution.legs.length as 1 | 2 });
|
|
118
112
|
try {
|
|
119
113
|
const result = await dependencies.runDispatch(execution, { context, ...(signal === undefined ? {} : { signal }) });
|
|
@@ -151,11 +145,8 @@ export function createReviewerRoleRuntime(
|
|
|
151
145
|
if (!registered) {
|
|
152
146
|
registered = true;
|
|
153
147
|
pi.registerTool({ name: REVIEWER_OUTPUT_TOOL_NAME, label: "御史台输出", description: "Standards/Spec 评审腿由 runtime 以取证子会话代跑,本席收腿报告后交薄回执。", promptSnippet: "提交御史台终局回执", parameters: reviewerOutputSchema,
|
|
154
|
-
async execute(id, parameters, _signal, _update, toolCtx): Promise<
|
|
148
|
+
async execute(id: string, parameters: unknown, _signal: AbortSignal | undefined, _update: unknown, toolCtx: HostContext): Promise<HostToolResult<unknown>> {
|
|
155
149
|
if (!soul || !binding) throw new Error("御史台输入未装载");
|
|
156
|
-
// #541: infra declaration fails via the shared host seam before the
|
|
157
|
-
// ledger audit record / receipt assembly / shutdown.
|
|
158
|
-
failOnInfrastructureFailureDeclaration(parameters, hostActions, toolCtx, id);
|
|
159
150
|
requireSoleReviewerOutputCall(id, toolCtx);
|
|
160
151
|
const output = validateReviewerIntent(parameters);
|
|
161
152
|
let record: ReviewerExecutionRecord;
|