@akagilnc/pi-workflow-roles 0.1.1751
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/LICENSE +202 -0
- package/README.md +104 -0
- package/README.zh-CN.md +133 -0
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/dist/activation-ledger-git.js +68 -0
- package/dist/activation-ledger-session.js +120 -0
- package/dist/activation-ledger-topology.js +239 -0
- package/dist/activation-reconciliation.js +61 -0
- package/dist/audit-escalation.js +108 -0
- package/dist/auditor-dossier-tool.js +35 -0
- package/dist/canonical-json.js +78 -0
- package/dist/compliance-transport.js +77 -0
- package/dist/doctor-contracts.js +172 -0
- package/dist/dossier-resolution.js +103 -0
- package/dist/evidence-child-executor.js +661 -0
- package/dist/exact-utf8.js +12 -0
- package/dist/git-object-id.js +7 -0
- package/dist/in-process-session.js +50 -0
- package/dist/merger-contracts.js +76 -0
- package/dist/navigator-attendance.js +995 -0
- package/dist/navigator-invocation-identity.js +220 -0
- package/dist/open-tool-schema.js +39 -0
- package/dist/package-contracts/collector-output.js +50 -0
- package/dist/package-contracts/fixer-output.js +72 -0
- package/dist/package-contracts/fixer-packet.js +77 -0
- package/dist/package-contracts/judge-output.js +17 -0
- package/dist/package-contracts/reviewer-output.js +82 -0
- package/dist/package-contracts/terminating-tools.js +173 -0
- package/dist/package-contracts/worker-output.js +13 -0
- package/dist/package-owned-tool-idle.js +104 -0
- package/dist/packaged-role-registry.js +34 -0
- package/dist/public-cli/main.js +23867 -0
- package/dist/public-command-renderer.js +20 -0
- package/dist/reviewer-agent.js +93 -0
- package/dist/reviewer-child-executor.js +23 -0
- package/dist/reviewer-construction.js +95 -0
- package/dist/reviewer-dispatch.js +77 -0
- package/dist/reviewer-execution-ledger.js +160 -0
- package/dist/reviewer-failure-diagnostic.js +17 -0
- package/dist/reviewer-git-snapshot.js +38 -0
- package/dist/reviewer-pinned-git.js +146 -0
- package/dist/reviewer-preflight-error.js +15 -0
- package/dist/reviewer-prompt-identity.js +10 -0
- package/dist/reviewer-scope-prompt.js +21 -0
- package/dist/reviewer-workspace.js +151 -0
- package/dist/sha256.js +5 -0
- package/dist/sitian-record-entry.js +33 -0
- package/dist/stderr-jsonl.js +26 -0
- package/dist/stream-idle-guard.js +75 -0
- package/dist/tool-execution-observation.js +141 -0
- package/dist/uuidv7.js +21 -0
- package/dist/work-subject-identity.js +53 -0
- package/extensions/role-runtime.ts +303 -0
- package/package.json +69 -0
- package/packets/fixer-prerequisites.json +6 -0
- package/packets/fixer-repair.md +5 -0
- package/packets/judge-apply.md +77 -0
- package/packets/judge-authority.md +64 -0
- package/packets/judge-plan.md +55 -0
- package/packets/judge-review.md +49 -0
- package/packets/judge-submission.md +34 -0
- package/resources/methods/code-review/SKILL.md +92 -0
- package/resources/methods/code-review/agents/openai.yaml +3 -0
- package/resources/methods/code-review/provenance.json +26 -0
- package/resources/methods/diagnosing-bugs/SKILL.md +134 -0
- package/resources/methods/diagnosing-bugs/agents/openai.yaml +3 -0
- package/resources/methods/diagnosing-bugs/provenance.json +31 -0
- package/resources/methods/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
- package/resources/methods/resolving-merge-conflicts/SKILL.md +14 -0
- package/resources/methods/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/resources/methods/resolving-merge-conflicts/provenance.json +26 -0
- package/resources/methods/tdd/SKILL.md +38 -0
- package/resources/methods/tdd/agents/openai.yaml +3 -0
- package/resources/methods/tdd/mocking.md +59 -0
- package/resources/methods/tdd/provenance.json +36 -0
- package/resources/methods/tdd/tests.md +77 -0
- package/resources/navigator-route-playbook.md +32 -0
- package/schemas/tool-execution-observation.schema.json +107 -0
- package/scripts/build-package.mjs +65 -0
- package/scripts/generate-tool-execution-observation-schema.ts +7 -0
- package/souls/coder.md +10 -0
- package/souls/collector.md +11 -0
- package/souls/doctor-auditor.md +23 -0
- package/souls/doctor.md +8 -0
- package/souls/fixer-auditor.md +33 -0
- package/souls/fixer.md +13 -0
- package/souls/judge-auditor.md +33 -0
- package/souls/judge.md +74 -0
- package/souls/merger.md +5 -0
- package/souls/navigator.md +5 -0
- package/souls/reviewer-auditor.md +25 -0
- package/souls/reviewer.md +11 -0
- package/src/activation-ledger-git.ts +96 -0
- package/src/activation-ledger-session.ts +188 -0
- package/src/activation-ledger-topology.ts +301 -0
- package/src/activation-ledger.ts +240 -0
- package/src/activation-reconciliation.ts +163 -0
- package/src/activation-trace.ts +38 -0
- package/src/audit-escalation.ts +177 -0
- package/src/auditor-dossier-tool.ts +48 -0
- package/src/auditor-soul.ts +28 -0
- package/src/canonical-json.ts +74 -0
- package/src/canonical-skill-binding.ts +107 -0
- package/src/collector-config.ts +89 -0
- package/src/collector-evidence.ts +461 -0
- package/src/collector-github.ts +656 -0
- package/src/collector-identity.ts +161 -0
- package/src/collector-ledger.ts +827 -0
- package/src/collector-receipt.ts +87 -0
- package/src/collector-role.ts +592 -0
- package/src/collector-tool-schemas.ts +19 -0
- package/src/compliance-transport.ts +130 -0
- package/src/doctor-auditor.ts +53 -0
- package/src/doctor-contracts.ts +166 -0
- package/src/doctor-evidence.ts +47 -0
- package/src/doctor-role.ts +18 -0
- package/src/dossier-resolution.ts +137 -0
- package/src/evidence-child-executor.ts +775 -0
- package/src/exact-utf8.ts +9 -0
- package/src/factory-board.ts +1822 -0
- package/src/git-object-id.ts +11 -0
- package/src/human-format.ts +65 -0
- package/src/in-process-session.ts +78 -0
- package/src/judge-auditor.ts +55 -0
- package/src/judge-recording-anti-forge.ts +53 -0
- package/src/judge-role.ts +160 -0
- package/src/merger-contracts.ts +71 -0
- package/src/merger-git-state.ts +76 -0
- package/src/merger-role.ts +60 -0
- package/src/navigator-attendance.ts +1254 -0
- package/src/navigator-invocation-identity.ts +446 -0
- package/src/open-tool-schema.ts +46 -0
- package/src/package-contracts/collector-output.ts +109 -0
- package/src/package-contracts/fixer-output.ts +81 -0
- package/src/package-contracts/fixer-packet.ts +93 -0
- package/src/package-contracts/judge-output.ts +39 -0
- package/src/package-contracts/reviewer-output.ts +115 -0
- package/src/package-contracts/terminating-tools.ts +259 -0
- package/src/package-contracts/worker-output.ts +36 -0
- package/src/package-owned-tool-idle.ts +134 -0
- package/src/package-resources/method-skill-binding.ts +87 -0
- package/src/package-resources/method-skill.ts +358 -0
- package/src/packaged-role-registry.ts +36 -0
- package/src/public-cli/cli-errors.ts +11 -0
- package/src/public-cli/cli-io.ts +4 -0
- package/src/public-cli/cli.ts +912 -0
- package/src/public-cli/coder-run.ts +575 -0
- package/src/public-cli/collector-run.ts +375 -0
- package/src/public-cli/command-renderer.ts +8 -0
- package/src/public-cli/config.ts +346 -0
- package/src/public-cli/doctor-run.ts +355 -0
- package/src/public-cli/explicit-internal.ts +274 -0
- package/src/public-cli/fixer-run.ts +587 -0
- package/src/public-cli/host-pi-runtime.ts +112 -0
- package/src/public-cli/invocation.ts +1958 -0
- package/src/public-cli/judge-run.ts +507 -0
- package/src/public-cli/main.ts +15 -0
- package/src/public-cli/merger-run.ts +681 -0
- package/src/public-cli/public-run-credentials.ts +71 -0
- package/src/public-cli/registry.ts +153 -0
- package/src/public-cli/reviewer-run.ts +561 -0
- package/src/public-cli/run-lifecycle.ts +884 -0
- package/src/public-cli/settlement.ts +3765 -0
- package/src/public-cli/terminal.ts +325 -0
- package/src/public-command-renderer.ts +43 -0
- package/src/reviewer-agent.ts +94 -0
- package/src/reviewer-auditor.ts +53 -0
- package/src/reviewer-child-executor.ts +31 -0
- package/src/reviewer-construction.ts +137 -0
- package/src/reviewer-dispatch.ts +94 -0
- package/src/reviewer-execution-ledger.ts +206 -0
- package/src/reviewer-failure-diagnostic.ts +18 -0
- package/src/reviewer-git-snapshot.ts +53 -0
- package/src/reviewer-pinned-git.ts +144 -0
- package/src/reviewer-preflight-error.ts +14 -0
- package/src/reviewer-prompt-identity.ts +17 -0
- package/src/reviewer-role.ts +193 -0
- package/src/reviewer-scope-prompt.ts +24 -0
- package/src/reviewer-settlement.ts +63 -0
- package/src/reviewer-workspace.ts +111 -0
- package/src/role-runtime.ts +884 -0
- package/src/sha256.ts +6 -0
- package/src/sitian-record-entry.ts +57 -0
- package/src/stderr-jsonl.ts +28 -0
- package/src/stream-idle-guard.ts +98 -0
- package/src/ticket-snapshot.ts +662 -0
- package/src/ticket-trajectory.ts +1000 -0
- package/src/tool-execution-observation.ts +168 -0
- package/src/uuidv7.ts +1 -0
- package/src/work-subject-identity.ts +94 -0
- package/src/worker-role.ts +434 -0
- package/src/worker-submission-gates.ts +225 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin shared in-process AgentSession open (#233).
|
|
3
|
+
* Static Pi imports are safe for Navigator (same module instance as ModelRuntime).
|
|
4
|
+
* Auditor/evidence callers must dynamic-import this module so public-cli bundling
|
|
5
|
+
* does not statically reach @earendil-works/pi-coding-agent.
|
|
6
|
+
*/
|
|
7
|
+
import { createAgentSession, DefaultResourceLoader, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
/**
|
|
9
|
+
* Single createAgentSession + Settings construction for all in-process children.
|
|
10
|
+
*/
|
|
11
|
+
export async function openInProcessAgentSession(options) {
|
|
12
|
+
const settings = SettingsManager.inMemory({ compaction: { enabled: false }, retry: { enabled: false } });
|
|
13
|
+
const createArgs = {
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
model: options.model,
|
|
16
|
+
thinkingLevel: options.thinkingLevel ?? "off",
|
|
17
|
+
modelRuntime: options.modelRuntime,
|
|
18
|
+
sessionManager: options.sessionManager,
|
|
19
|
+
settingsManager: settings,
|
|
20
|
+
...(options.noTools === undefined ? {} : { noTools: options.noTools }),
|
|
21
|
+
...(options.tools === undefined ? {} : { tools: options.tools }),
|
|
22
|
+
...(options.customTools === undefined ? {} : { customTools: options.customTools }),
|
|
23
|
+
};
|
|
24
|
+
if (options.agentDir !== undefined) {
|
|
25
|
+
const loader = new DefaultResourceLoader({
|
|
26
|
+
cwd: options.cwd,
|
|
27
|
+
agentDir: options.agentDir,
|
|
28
|
+
settingsManager: settings,
|
|
29
|
+
noExtensions: true,
|
|
30
|
+
noSkills: true,
|
|
31
|
+
noPromptTemplates: true,
|
|
32
|
+
noThemes: true,
|
|
33
|
+
noContextFiles: true,
|
|
34
|
+
...(options.systemPrompt === undefined ? {} : { systemPrompt: options.systemPrompt }),
|
|
35
|
+
});
|
|
36
|
+
await loader.reload();
|
|
37
|
+
createArgs.agentDir = options.agentDir;
|
|
38
|
+
createArgs.resourceLoader = loader;
|
|
39
|
+
}
|
|
40
|
+
else if (options.systemPrompt !== undefined) {
|
|
41
|
+
throw new Error("openInProcessAgentSession requires agentDir when systemPrompt is set");
|
|
42
|
+
}
|
|
43
|
+
const { session } = await createAgentSession(createArgs);
|
|
44
|
+
return {
|
|
45
|
+
session,
|
|
46
|
+
dispose() {
|
|
47
|
+
session.dispose();
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { isFullGitObjectId } from "./git-object-id.js";
|
|
3
|
+
import { exactUtf8 } from "./exact-utf8.js";
|
|
4
|
+
import { sha256Hex } from "./sha256.js";
|
|
5
|
+
import { openToolObjectFromUnion } from "./open-tool-schema.js";
|
|
6
|
+
const oidPattern = "^(?:[0-9a-f]{40}|[0-9a-f]{64})$";
|
|
7
|
+
const materialSchema = Type.Object({ bytesBase64: Type.String(), sha256: Type.String() }, { additionalProperties: false });
|
|
8
|
+
const checkSchema = Type.Object({ name: Type.String({ minLength: 1 }), argv: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
|
|
9
|
+
export const mergerInputSchema = Type.Object({
|
|
10
|
+
version: Type.Literal(1), attemptId: Type.String({ minLength: 1 }),
|
|
11
|
+
targetObjectId: Type.String({ pattern: oidPattern }), sourceObjectId: Type.String({ pattern: oidPattern }),
|
|
12
|
+
materials: Type.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
|
|
13
|
+
expectedConflictPaths: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
14
|
+
resolutionScope: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
|
|
15
|
+
authorizedChecks: Type.Array(checkSchema),
|
|
16
|
+
}, { additionalProperties: false });
|
|
17
|
+
const mergerOutputVariants = Type.Union([
|
|
18
|
+
Type.Object({ status: Type.Literal("completed", { description: "Merge attempt completed." }), attemptId: Type.String({ minLength: 1, description: "Identity of the admitted merge attempt." }), report: Type.String({ minLength: 1, description: "Truthful merge outcome report." }), mergeCommitId: Type.String({ pattern: oidPattern, description: "Verified completed merge commit object ID." }) }, { additionalProperties: false }),
|
|
19
|
+
Type.Object({ status: Type.Literal("escalate", { description: "Merge attempt requires human authority." }), attemptId: Type.String({ minLength: 1, description: "Identity of the admitted merge attempt." }), diagnosis: Type.String({ minLength: 1, description: "Reason merge completion requires escalation." }), report: Type.String({ minLength: 1, description: "Truthful merge outcome report." }) }, { additionalProperties: false }),
|
|
20
|
+
]);
|
|
21
|
+
export const mergerOutputSchema = openToolObjectFromUnion(mergerOutputVariants);
|
|
22
|
+
export const MERGER_OUTPUT_TOOL_NAME = "ak_merger_output";
|
|
23
|
+
export const MERGER_ACCEPTED_TEXT = "Merger output accepted";
|
|
24
|
+
const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
25
|
+
const blank = (v) => typeof v !== "string" || v.trim().length === 0;
|
|
26
|
+
export class MergerInputContractError extends Error {
|
|
27
|
+
constructor(message = "Merger input violates its exact contract") { super(message); this.name = "MergerInputContractError"; }
|
|
28
|
+
}
|
|
29
|
+
function fail(message = "Merger input violates its exact contract") { throw new MergerInputContractError(message); }
|
|
30
|
+
function canonicalPath(path) { return typeof path === "string" && path.length > 0 && !path.startsWith("/") && !path.includes("\0") && path.split("/").every(part => part !== "" && part !== "." && part !== ".."); }
|
|
31
|
+
function validatePathSet(value, label) {
|
|
32
|
+
if (!Array.isArray(value) || value.length === 0 || !value.every(canonicalPath))
|
|
33
|
+
fail(`Merger ${label} must be a non-empty canonical path set`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function validateMaterial(value, label) {
|
|
37
|
+
if (!record(value) || typeof value.bytesBase64 !== "string" || typeof value.sha256 !== "string")
|
|
38
|
+
fail(`Merger ${label} material is malformed`);
|
|
39
|
+
const bytes = Buffer.from(value.bytesBase64, "base64");
|
|
40
|
+
exactUtf8(bytes, `Merger ${label} material`);
|
|
41
|
+
if (sha256Hex(bytes) !== value.sha256)
|
|
42
|
+
fail(`Merger ${label} material digest mismatch`);
|
|
43
|
+
}
|
|
44
|
+
function deepFreeze(value) { if (value && typeof value === "object") {
|
|
45
|
+
for (const child of Object.values(value))
|
|
46
|
+
deepFreeze(child);
|
|
47
|
+
Object.freeze(value);
|
|
48
|
+
} return value; }
|
|
49
|
+
export function validateMergerInput(value) {
|
|
50
|
+
if (!record(value) || blank(value.attemptId) || !isFullGitObjectId(value.targetObjectId) || !isFullGitObjectId(value.sourceObjectId) || value.targetObjectId.length !== value.sourceObjectId.length)
|
|
51
|
+
fail("Merger input has invalid identity or object ID");
|
|
52
|
+
if (!record(value.materials))
|
|
53
|
+
fail();
|
|
54
|
+
for (const key of ["task", "authority", "targetIntent", "sourceIntent"])
|
|
55
|
+
validateMaterial(value.materials[key], key);
|
|
56
|
+
const conflicts = validatePathSet(value.expectedConflictPaths, "expected conflict paths");
|
|
57
|
+
const scope = validatePathSet(value.resolutionScope, "resolution scope");
|
|
58
|
+
if (!conflicts.every(path => scope.includes(path)))
|
|
59
|
+
fail("Merger resolution scope must contain the complete conflict set");
|
|
60
|
+
if (!Array.isArray(value.authorizedChecks))
|
|
61
|
+
fail("Merger authorized checks are malformed");
|
|
62
|
+
for (const check of value.authorizedChecks) {
|
|
63
|
+
if (!record(check) || !Array.isArray(check.argv) || check.argv.length === 0 || check.argv.some(blank))
|
|
64
|
+
fail("Merger authorized check is malformed");
|
|
65
|
+
}
|
|
66
|
+
return deepFreeze(structuredClone(value));
|
|
67
|
+
}
|
|
68
|
+
export function validateMergerOutput(value, expectedAttemptId) {
|
|
69
|
+
if (!record(value) || (expectedAttemptId !== undefined && value.attemptId !== expectedAttemptId))
|
|
70
|
+
throw new Error("Merger output attempt mismatch");
|
|
71
|
+
if (value.status === "completed" && isFullGitObjectId(value.mergeCommitId))
|
|
72
|
+
return structuredClone(value);
|
|
73
|
+
if (value.status === "escalate")
|
|
74
|
+
return structuredClone(value);
|
|
75
|
+
throw new Error("Merger output has no recognized execution discriminator");
|
|
76
|
+
}
|