@punks/cli 4.0.3 → 5.0.0
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/dist/BASELINE_CHANGELOG.md +25 -1
- package/dist/CHANGELOG.md +41 -0
- package/dist/baseline/scaffold-baseline/baseline.json +563 -5
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.d.mts +23 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.mjs +84 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/authoring.test.ts +79 -0
- package/dist/baseline/scaffold-baseline/data/scripts/harness-projection/lint-feedback.test.ts +60 -28
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents-validator.test.ts +59 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.d.mts +1 -0
- package/dist/baseline/scaffold-baseline/data/scripts/sync-subagents.mjs +192 -16
- package/dist/baseline/scaffold-baseline/data/shared-agents.md +55 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/cli/hi-cli/references/post-command-flow.md +12 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/generic/handoff/SKILL.md +18 -5
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/SKILL.md +10 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/plan-schema.md +28 -8
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-plan/references/planner-task-graph.md +7 -3
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-verification-skill/SKILL.md +66 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/create-verification-skill/references/upstream.md +20 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/SKILL.md +16 -41
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +14 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/lifecycle.md +47 -7
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +102 -134
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +77 -67
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/parallel.md +19 -39
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/implement-spec/references/runtime-product-validation.md +27 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/swarm-planner/SKILL.md +27 -2
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/update-verification-skill/SKILL.md +81 -0
- package/dist/baseline/scaffold-baseline/skills/agnostic/planning/verify-behavior/SKILL.md +105 -65
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/SKILL.md +17 -4
- package/dist/baseline/scaffold-baseline/skills/agnostic/quality/autoreview/scripts/autoreview +102 -5
- package/dist/baseline/scaffold-baseline/skills/agnostic/requirements/brainstorm/SKILL.md +11 -5
- package/dist/baseline/scaffold-baseline/skills/agnostic/subagents/swarm-planner/SKILL.md +27 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/SKILL.md +12 -14
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/backlog.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/closeout.md +12 -4
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/debug.md +11 -5
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/docs-ingest.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/handback.md +6 -2
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/implement.md +12 -7
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/plan.md +7 -1
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/review.md +61 -22
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/router.md +45 -91
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/phases/spec.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/artifact-state.md +21 -9
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/context-continuity.md +109 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/failure-continuity.md +27 -0
- package/dist/baseline/scaffold-baseline/skills/phases/delivery-phase/references/phase-handoff.md +32 -20
- package/dist/baseline/scaffold-baseline/skills/phases/docs-ingest-phase/SKILL.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/docs-ingest-phase/references/wiki-ingest.md +4 -0
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/prepare-review.md +41 -8
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/retain-report.md +13 -4
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/phases/run-review.md +24 -18
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/durable-report.md +40 -6
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/review-packet.md +72 -0
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/runtime-handoff.md +3 -0
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/references/state-graph.md +51 -42
- package/dist/baseline/scaffold-baseline/skills/phases/review-phase/scripts/review-contract.mjs +239 -4
- package/dist/baseline/scaffold-baseline.json +5 -5
- package/dist/baseline/scaffold-baseline.tgz +0 -0
- package/dist/data/scripts/harness-projection/authoring.d.mts +23 -0
- package/dist/data/scripts/harness-projection/authoring.mjs +84 -0
- package/dist/data/scripts/sync-subagents.d.mts +1 -0
- package/dist/data/scripts/sync-subagents.mjs +158 -15
- package/dist/data/shared-agents.md +2 -60
- package/dist/index.js +1417 -1407
- package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +12 -0
- package/dist/skills/agnostic/generic/handoff/SKILL.md +18 -5
- package/dist/skills/agnostic/planning/create-plan/SKILL.md +10 -2
- package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +28 -8
- package/dist/skills/agnostic/planning/create-plan/references/planner-task-graph.md +7 -3
- package/dist/skills/agnostic/planning/create-verification-skill/SKILL.md +66 -0
- package/dist/skills/agnostic/planning/create-verification-skill/references/upstream.md +20 -0
- package/dist/skills/agnostic/planning/implement-spec/SKILL.md +16 -41
- package/dist/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +14 -0
- package/dist/skills/agnostic/planning/implement-spec/references/architecture-conformance.md +10 -6
- package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +47 -7
- package/dist/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +102 -134
- package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +77 -67
- package/dist/skills/agnostic/planning/implement-spec/references/parallel.md +19 -39
- package/dist/skills/agnostic/planning/implement-spec/references/runtime-product-validation.md +27 -0
- package/dist/skills/agnostic/planning/swarm-planner/SKILL.md +27 -2
- package/dist/skills/agnostic/planning/update-verification-skill/SKILL.md +81 -0
- package/dist/skills/agnostic/planning/verify-behavior/SKILL.md +105 -65
- package/dist/skills/agnostic/quality/autoreview/SKILL.md +17 -4
- package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +102 -5
- package/dist/skills/agnostic/requirements/brainstorm/SKILL.md +11 -5
- package/dist/skills/agnostic/subagents/swarm-planner/SKILL.md +27 -2
- package/dist/skills/phases/delivery-phase/SKILL.md +12 -14
- package/dist/skills/phases/delivery-phase/phases/backlog.md +4 -0
- package/dist/skills/phases/delivery-phase/phases/closeout.md +12 -4
- package/dist/skills/phases/delivery-phase/phases/debug.md +11 -5
- package/dist/skills/phases/delivery-phase/phases/docs-ingest.md +4 -0
- package/dist/skills/phases/delivery-phase/phases/handback.md +6 -2
- package/dist/skills/phases/delivery-phase/phases/implement.md +12 -7
- package/dist/skills/phases/delivery-phase/phases/plan.md +7 -1
- package/dist/skills/phases/delivery-phase/phases/review.md +61 -22
- package/dist/skills/phases/delivery-phase/phases/router.md +45 -91
- package/dist/skills/phases/delivery-phase/phases/spec.md +4 -0
- package/dist/skills/phases/delivery-phase/references/artifact-state.md +21 -9
- package/dist/skills/phases/delivery-phase/references/context-continuity.md +109 -0
- package/dist/skills/phases/delivery-phase/references/failure-continuity.md +27 -0
- package/dist/skills/phases/delivery-phase/references/phase-handoff.md +32 -20
- package/dist/skills/phases/docs-ingest-phase/SKILL.md +4 -0
- package/dist/skills/phases/docs-ingest-phase/references/wiki-ingest.md +4 -0
- package/dist/skills/phases/review-phase/phases/prepare-review.md +40 -8
- package/dist/skills/phases/review-phase/phases/retain-report.md +13 -4
- package/dist/skills/phases/review-phase/phases/router.md +1 -1
- package/dist/skills/phases/review-phase/phases/run-review.md +24 -18
- package/dist/skills/phases/review-phase/references/durable-report.md +40 -6
- package/dist/skills/phases/review-phase/references/review-packet.md +72 -0
- package/dist/skills/phases/review-phase/references/runtime-handoff.md +3 -0
- package/dist/skills/phases/review-phase/references/state-graph.md +21 -12
- package/dist/skills/phases/review-phase/scripts/review-contract.mjs +137 -4
- package/package.json +4 -1
|
@@ -12,6 +12,7 @@ import { cursorAdapter } from "./harness-projection/adapters/cursor.mjs";
|
|
|
12
12
|
import { openCodeAdapter } from "./harness-projection/adapters/opencode.mjs";
|
|
13
13
|
import { applyProjection } from "./harness-projection/apply.mjs";
|
|
14
14
|
import { project } from "./harness-projection/core.mjs";
|
|
15
|
+
import { assessScopedAuthoring, readScopedAuthoringProofs } from "./harness-projection/authoring.mjs";
|
|
15
16
|
|
|
16
17
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
17
18
|
const sharedAgentsPath = path.join(repoRoot, ".agents/AGENTS.md");
|
|
@@ -2878,6 +2879,7 @@ const contributionKinds = new Set([
|
|
|
2878
2879
|
"lifecycle-hook",
|
|
2879
2880
|
"tool-configuration",
|
|
2880
2881
|
"subagent-template",
|
|
2882
|
+
"commit-gate",
|
|
2881
2883
|
]);
|
|
2882
2884
|
|
|
2883
2885
|
const identityIssue = (identity) =>
|
|
@@ -2902,19 +2904,23 @@ const compatibilityIssue = (compatibility) =>
|
|
|
2902
2904
|
isNonEmptyString(entry.id) &&
|
|
2903
2905
|
isNonEmptyString(entry.versionRange),
|
|
2904
2906
|
)
|
|
2907
|
+
? undefined
|
|
2908
|
+
: "Context contribution compatibility is invalid";
|
|
2909
|
+
|
|
2910
|
+
const commitGateContractIssue = (contract) =>
|
|
2911
|
+
exactKeys(contract, ["lint", "formatCheck"]) &&
|
|
2912
|
+
isNonEmptyString(contract.lint) &&
|
|
2913
|
+
isNonEmptyString(contract.formatCheck)
|
|
2905
2914
|
? undefined
|
|
2906
|
-
: "
|
|
2915
|
+
: "Commit-gate contract must contain non-empty lint and formatCheck strings";
|
|
2907
2916
|
|
|
2908
2917
|
const contributionIssue = (contribution) => {
|
|
2918
|
+
const expectedKeys =
|
|
2919
|
+
contribution?.kind === "commit-gate"
|
|
2920
|
+
? ["kind", "identity", "provenance", "compatibility", "references", "order", "contract"]
|
|
2921
|
+
: ["kind", "identity", "provenance", "compatibility", "references", "order"];
|
|
2909
2922
|
if (
|
|
2910
|
-
!exactKeys(contribution,
|
|
2911
|
-
"kind",
|
|
2912
|
-
"identity",
|
|
2913
|
-
"provenance",
|
|
2914
|
-
"compatibility",
|
|
2915
|
-
"references",
|
|
2916
|
-
"order",
|
|
2917
|
-
])
|
|
2923
|
+
!exactKeys(contribution, expectedKeys)
|
|
2918
2924
|
) {
|
|
2919
2925
|
return "Context contribution fields are invalid";
|
|
2920
2926
|
}
|
|
@@ -2925,6 +2931,9 @@ const contributionIssue = (contribution) => {
|
|
|
2925
2931
|
identityIssue(contribution.identity) ??
|
|
2926
2932
|
provenanceIssue(contribution.provenance) ??
|
|
2927
2933
|
compatibilityIssue(contribution.compatibility) ??
|
|
2934
|
+
(contribution.kind === "commit-gate"
|
|
2935
|
+
? commitGateContractIssue(contribution.contract)
|
|
2936
|
+
: undefined) ??
|
|
2928
2937
|
(!Array.isArray(contribution.references) || !contribution.references.every(isNonEmptyString)
|
|
2929
2938
|
? "Context contribution references are invalid"
|
|
2930
2939
|
: undefined) ??
|
|
@@ -2933,9 +2942,31 @@ const contributionIssue = (contribution) => {
|
|
|
2933
2942
|
};
|
|
2934
2943
|
|
|
2935
2944
|
const scopeIssue = (scope) => {
|
|
2936
|
-
|
|
2945
|
+
const expectedKeys = scope?.authoring === undefined
|
|
2946
|
+
? ["id", "packs", "contributions"]
|
|
2947
|
+
: ["id", "packs", "contributions", "authoring"];
|
|
2948
|
+
if (!exactKeys(scope, expectedKeys) || !isNonEmptyString(scope.id)) {
|
|
2937
2949
|
return "Context scope fields are invalid";
|
|
2938
2950
|
}
|
|
2951
|
+
if (scope.authoring !== undefined) {
|
|
2952
|
+
const identity = scope.authoring;
|
|
2953
|
+
if (
|
|
2954
|
+
!exactKeys(identity, ["path", "kind", "contracts", "missingContracts"]) ||
|
|
2955
|
+
!isNonEmptyString(identity.path) ||
|
|
2956
|
+
!isNonEmptyString(identity.kind) ||
|
|
2957
|
+
!Array.isArray(identity.contracts) ||
|
|
2958
|
+
!identity.contracts.every((contract) =>
|
|
2959
|
+
exactKeys(contract, ["id", "authoringRevision", "activationRevision"]) &&
|
|
2960
|
+
isNonEmptyString(contract.id) &&
|
|
2961
|
+
isNonEmptyString(contract.authoringRevision) &&
|
|
2962
|
+
isNonEmptyString(contract.activationRevision)
|
|
2963
|
+
) ||
|
|
2964
|
+
!Array.isArray(identity.missingContracts) ||
|
|
2965
|
+
!identity.missingContracts.every(isNonEmptyString)
|
|
2966
|
+
) {
|
|
2967
|
+
return `Context scope ${scope.id} authoring identity is invalid`;
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2939
2970
|
if (
|
|
2940
2971
|
!Array.isArray(scope.packs) ||
|
|
2941
2972
|
!scope.packs.every(
|
|
@@ -3002,18 +3033,76 @@ function subagentManifestIssue(contextPlan) {
|
|
|
3002
3033
|
const canonicalContextIssue = (contextPlan) =>
|
|
3003
3034
|
contextPlanIssue(contextPlan) ?? subagentManifestIssue(contextPlan);
|
|
3004
3035
|
|
|
3036
|
+
export const validateCanonicalContextPlan = (contextPlan) =>
|
|
3037
|
+
canonicalContextIssue(contextPlan);
|
|
3038
|
+
|
|
3005
3039
|
const contextPlanVersion = (contextPlan) =>
|
|
3006
3040
|
isObject(contextPlan) && typeof contextPlan.version === "string"
|
|
3007
3041
|
? contextPlan.version
|
|
3008
3042
|
: "unknown";
|
|
3009
3043
|
|
|
3010
|
-
|
|
3044
|
+
const parseAuthoringCompletion = (args) => {
|
|
3045
|
+
if (args.length === 0) return undefined;
|
|
3046
|
+
if (args.length !== 3 || args[0] !== "--complete-authoring" || !/^[a-f0-9]{64}$/.test(args[2])) {
|
|
3047
|
+
throw new Error("Expected --complete-authoring <scope> <current input identity>.");
|
|
3048
|
+
}
|
|
3049
|
+
return { scopeId: args[1], inputIdentity: args[2] };
|
|
3050
|
+
};
|
|
3051
|
+
|
|
3052
|
+
async function readAuthoredScope(action) {
|
|
3053
|
+
const promptFile = action.allowedOutputs[0];
|
|
3054
|
+
const bytes = await readConfinedRegularFile(resolveActionPath(promptFile, "authored output"));
|
|
3055
|
+
if (bytes === null || bytes.toString("utf8").trim().length === 0) {
|
|
3056
|
+
throw new Error(`Authored output is missing or empty: ${promptFile}`);
|
|
3057
|
+
}
|
|
3058
|
+
return bytes;
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
async function verifyAuthoredProjection(action, projections, application) {
|
|
3062
|
+
await readAuthoredScope(action);
|
|
3063
|
+
for (const projection of projections) {
|
|
3064
|
+
const relevant = (entry) => entry.trace?.scopeId === action.scopeId &&
|
|
3065
|
+
["scoped-prompt", "subagent-template"].includes(entry.trace?.kind);
|
|
3066
|
+
if ([...projection.failures, ...projection.omissions].some(relevant)) {
|
|
3067
|
+
throw new Error(`Scoped authoring projection is incomplete: ${action.scopeId}`);
|
|
3068
|
+
}
|
|
3069
|
+
for (const mirror of projection.actions.filter((entry) => relevant(entry) && entry.operation === "mirror" && entry.source !== entry.target)) {
|
|
3070
|
+
const sourcePath = resolveActionPath(mirror.source, "source");
|
|
3071
|
+
const targetPath = resolveActionPath(mirror.target, "target");
|
|
3072
|
+
const stat = await lstat(targetPath);
|
|
3073
|
+
if (stat.isSymbolicLink()) {
|
|
3074
|
+
if ((await readlink(targetPath)) !== path.relative(path.dirname(targetPath), sourcePath)) {
|
|
3075
|
+
throw new Error(`Scoped authoring mirror diverges: ${mirror.target}`);
|
|
3076
|
+
}
|
|
3077
|
+
} else {
|
|
3078
|
+
const source = await readConfinedRegularFile(sourcePath);
|
|
3079
|
+
const target = await readConfinedRegularFile(targetPath);
|
|
3080
|
+
if (source === null || target === null || !source.equals(target)) {
|
|
3081
|
+
throw new Error(`Scoped authoring mirror diverges: ${mirror.target}`);
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
for (const agentId of action.allowedAgentIds) {
|
|
3087
|
+
for (const [adapterId, surface] of Object.entries(harnessAgentSurface)) {
|
|
3088
|
+
const expected = application.rendered[adapterId]?.[agentId];
|
|
3089
|
+
const actual = await readConfinedRegularFile(path.join(surface.directory, `${agentId}.${surface.extension}`));
|
|
3090
|
+
if (typeof expected !== "string" || actual?.toString("utf8") !== expected) {
|
|
3091
|
+
throw new Error(`Scoped authoring native agent diverges: ${adapterId}:${agentId}`);
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
async function main({ publicationLock, authoringCompletion } = {}) {
|
|
3011
3098
|
operationRepoRootIdentity = await captureRepoRootIdentity("synchronize scaffold output");
|
|
3012
3099
|
const manifestPreflight = await preflightScaffoldManifest();
|
|
3013
3100
|
await assertConfinedRegularFile(projectionReceiptPath);
|
|
3014
3101
|
const previousReceiptBytes = await readConfinedRegularFile(projectionReceiptPath);
|
|
3102
|
+
let previousAuthoringProofs = [];
|
|
3015
3103
|
try {
|
|
3016
3104
|
const previousReceipt = JSON.parse(previousReceiptBytes?.toString("utf8") ?? "null");
|
|
3105
|
+
previousAuthoringProofs = readScopedAuthoringProofs(previousReceipt);
|
|
3017
3106
|
previousCopyFallbacks = Array.isArray(previousReceipt.copyFallbacks)
|
|
3018
3107
|
? previousReceipt.copyFallbacks.filter(
|
|
3019
3108
|
(copy) =>
|
|
@@ -3028,6 +3117,8 @@ async function main({ publicationLock } = {}) {
|
|
|
3028
3117
|
}
|
|
3029
3118
|
const loadedContextPlan = await readContextPlan();
|
|
3030
3119
|
const loadedProjectionPlan = await readProjectionPlan();
|
|
3120
|
+
const authoringManifestPath = path.join(repoRoot, ".agents/subagents/manifest.mjs");
|
|
3121
|
+
const authoringManifestBytes = await readConfinedRegularFile(authoringManifestPath);
|
|
3031
3122
|
const application = await prepareHarnessApplication();
|
|
3032
3123
|
const renderedOutputSha256 = semanticJsonHash({
|
|
3033
3124
|
availableHooks: application.availableHooks,
|
|
@@ -3037,10 +3128,27 @@ async function main({ publicationLock } = {}) {
|
|
|
3037
3128
|
try {
|
|
3038
3129
|
await assertScaffoldManifestPreflight(manifestPreflight);
|
|
3039
3130
|
if (!loadedContextPlan.exists && !loadedProjectionPlan.exists) {
|
|
3131
|
+
if (authoringCompletion !== undefined) {
|
|
3132
|
+
throw new Error("Scoped authoring completion requires a canonical context plan.");
|
|
3133
|
+
}
|
|
3040
3134
|
await materializeLegacyHarnesses(application);
|
|
3041
3135
|
return;
|
|
3042
3136
|
}
|
|
3043
3137
|
const contextPlan = loadedContextPlan.value;
|
|
3138
|
+
const authoringActions = contextPlanIssue(contextPlan) === undefined
|
|
3139
|
+
? assessScopedAuthoring({ contextPlan, proofs: [] })
|
|
3140
|
+
: [];
|
|
3141
|
+
const completionAction = authoringCompletion === undefined ? undefined : authoringActions.find(
|
|
3142
|
+
(action) => action.scopeId === authoringCompletion.scopeId && action.inputIdentity === authoringCompletion.inputIdentity,
|
|
3143
|
+
);
|
|
3144
|
+
if (authoringCompletion !== undefined) {
|
|
3145
|
+
if (completionAction === undefined || completionAction.trigger === "compatibility-unknown") {
|
|
3146
|
+
throw new Error("Scoped authoring completion does not match a supported current input.");
|
|
3147
|
+
}
|
|
3148
|
+
const issue = canonicalContextIssue(contextPlan);
|
|
3149
|
+
if (issue !== undefined) throw new Error(issue);
|
|
3150
|
+
await readAuthoredScope(completionAction);
|
|
3151
|
+
}
|
|
3044
3152
|
const suppliedProjectionPlan = loadedProjectionPlan.exists
|
|
3045
3153
|
? validateProjectionPlan({ plan: loadedProjectionPlan.value, contextPlan })
|
|
3046
3154
|
: undefined;
|
|
@@ -3088,12 +3196,41 @@ async function main({ publicationLock } = {}) {
|
|
|
3088
3196
|
);
|
|
3089
3197
|
}
|
|
3090
3198
|
|
|
3199
|
+
const scopedAuthoring = previousAuthoringProofs.filter((proof) =>
|
|
3200
|
+
!authoringActions.some((action) => action.scopeId === proof.scopeId &&
|
|
3201
|
+
(action === completionAction || action.inputIdentity === proof.inputIdentity)),
|
|
3202
|
+
);
|
|
3203
|
+
for (const action of authoringActions) {
|
|
3204
|
+
if (action.trigger === "compatibility-unknown") continue;
|
|
3205
|
+
const prior = previousAuthoringProofs.find((proof) => proof.scopeId === action.scopeId && proof.inputIdentity === action.inputIdentity);
|
|
3206
|
+
if (action !== completionAction && prior === undefined) continue;
|
|
3207
|
+
try {
|
|
3208
|
+
await verifyAuthoredProjection(action, applied, application);
|
|
3209
|
+
scopedAuthoring.push({ scopeId: action.scopeId, inputIdentity: action.inputIdentity, status: "verified" });
|
|
3210
|
+
} catch (error) {
|
|
3211
|
+
if (action === completionAction) throw error;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
if (scopedAuthoring.length > 0) {
|
|
3215
|
+
const currentApplication = await prepareHarnessApplication();
|
|
3216
|
+
const currentManifest = await readConfinedRegularFile(authoringManifestPath);
|
|
3217
|
+
if (authoringManifestBytes === null || currentManifest === null ||
|
|
3218
|
+
!authoringManifestBytes.equals(currentManifest) ||
|
|
3219
|
+
semanticJsonHash({ availableHooks: currentApplication.availableHooks, rendered: currentApplication.rendered }) !== renderedOutputSha256) {
|
|
3220
|
+
throw new Error("Scoped authoring inputs changed during projection; retry completion.");
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
const currentContext = await readContextPlan();
|
|
3224
|
+
if (!currentContext.exists || semanticJsonHash(currentContext.value) !== semanticJsonHash(contextPlan)) {
|
|
3225
|
+
throw new Error("Scoped authoring inputs changed during projection; retry completion.");
|
|
3226
|
+
}
|
|
3091
3227
|
const receipt = {
|
|
3092
3228
|
version: "1",
|
|
3093
3229
|
contextPlanVersion: contextPlanVersion(contextPlan),
|
|
3094
3230
|
renderedOutputSha256,
|
|
3095
3231
|
status: receiptStatus(applied),
|
|
3096
3232
|
projections: applied,
|
|
3233
|
+
scopedAuthoring: scopedAuthoring.toSorted((left, right) => left.scopeId.localeCompare(right.scopeId)),
|
|
3097
3234
|
copyFallbacks: [...currentCopyFallbacks.values()].toSorted((left, right) =>
|
|
3098
3235
|
copyFallbackKey(left).localeCompare(copyFallbackKey(right)),
|
|
3099
3236
|
),
|
|
@@ -3109,8 +3246,14 @@ async function main({ publicationLock } = {}) {
|
|
|
3109
3246
|
}
|
|
3110
3247
|
}
|
|
3111
3248
|
|
|
3112
|
-
|
|
3113
|
-
await
|
|
3114
|
-
|
|
3115
|
-
|
|
3249
|
+
const entrypointPath =
|
|
3250
|
+
process.argv[1] === undefined ? null : await realpath(process.argv[1]);
|
|
3251
|
+
const modulePath = await realpath(fileURLToPath(import.meta.url));
|
|
3252
|
+
|
|
3253
|
+
if (entrypointPath === modulePath) {
|
|
3254
|
+
try {
|
|
3255
|
+
await main({ authoringCompletion: parseAuthoringCompletion(process.argv.slice(2)) });
|
|
3256
|
+
} finally {
|
|
3257
|
+
await closeMutationWorkers();
|
|
3258
|
+
}
|
|
3116
3259
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
# AGENTS.md
|
|
2
|
-
|
|
3
|
-
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
|
|
4
|
-
|
|
5
|
-
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
|
|
6
|
-
|
|
7
1
|
## Philosophy
|
|
8
2
|
|
|
9
3
|
This codebase will outlive you. Every shortcut becomes someone else's burden. Every hack compounds into technical debt that slows the team down.
|
|
10
4
|
|
|
11
|
-
You are
|
|
5
|
+
You are shaping the future of the project. The patterns established will be copied, the corners cut will be cut again.
|
|
12
6
|
|
|
13
7
|
Fight entropy, leave the codebase better than when you found it.
|
|
14
8
|
|
|
@@ -16,6 +10,7 @@ Fight entropy, leave the codebase better than when you found it.
|
|
|
16
10
|
|
|
17
11
|
- When generating tokens be extremely concise. Sacrifice grammar for the sake of concision.
|
|
18
12
|
- Be detailed about concepts, reasoning, assumptions, tradeoffs, and questions; keep wording terse.
|
|
13
|
+
- Stop using jargon and speak coherently. State it more simply and concisely, like one human talking to another.
|
|
19
14
|
|
|
20
15
|
## 1. Think Before Coding
|
|
21
16
|
|
|
@@ -58,56 +53,3 @@ When your changes create orphans:
|
|
|
58
53
|
- Don't remove pre-existing dead code unless asked.
|
|
59
54
|
|
|
60
55
|
The test: Every changed line should trace directly to the user's request or to necessary entropy-reducing support for that request.
|
|
61
|
-
|
|
62
|
-
## 4. Goal-Driven Execution
|
|
63
|
-
|
|
64
|
-
**Define success criteria. Loop until verified.**
|
|
65
|
-
|
|
66
|
-
Transform tasks into verifiable goals:
|
|
67
|
-
|
|
68
|
-
- "Add validation" -> "Write tests for invalid inputs, then make them pass"
|
|
69
|
-
- "Fix the bug" -> "Write a test that reproduces it, then make it pass"
|
|
70
|
-
- "Refactor X" -> "Ensure tests pass before and after"
|
|
71
|
-
|
|
72
|
-
For multi-step tasks, state a brief plan:
|
|
73
|
-
|
|
74
|
-
```text
|
|
75
|
-
1. [Step] -> verify: [check]
|
|
76
|
-
2. [Step] -> verify: [check]
|
|
77
|
-
3. [Step] -> verify: [check]
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
|
|
81
|
-
|
|
82
|
-
## Dependency source inspection
|
|
83
|
-
|
|
84
|
-
- Prefer web search and official docs first when inspecting external libraries or packages.
|
|
85
|
-
- If web results are unsuccessful, stale, or not detailed enough for implementation, fetch source locally.
|
|
86
|
-
- For npm packages, use `opensrc path <package>` to get the absolute path to cached source code, fetching on cache miss.
|
|
87
|
-
- For non-npm packages, clone the upstream `owner/repo` git source directly with `opensrc path <owner>/<repo>`.
|
|
88
|
-
|
|
89
|
-
## Subagents
|
|
90
|
-
|
|
91
|
-
Subagent-based working is mandatory. Before delegating, verify the active harness global/project settings actually enable subagent execution. Then verify `.agents/subagents/manifest.mjs` exists and the chosen specialist has matching owned paths, guidance files, and skills.
|
|
92
|
-
|
|
93
|
-
Use one active execution or implementation subagent at a time by default. Spawn multiple execution or implementation subagents in parallel only when the user explicitly asks for parallelism.
|
|
94
|
-
|
|
95
|
-
If a spawn is blocked by a full subagent/thread set, close existing completed or finished subagents, then retry.
|
|
96
|
-
|
|
97
|
-
Use readonly subagents for research, auditing, investigating hypotheses, or exploring separate paths. When readonly work can be split across independent questions, paths, or hypotheses, parallel readonly subagents are mandatory.
|
|
98
|
-
|
|
99
|
-
If the runtime guard fails, repair setup or report the blocker; do not claim inactive worker coverage and do not silently fall back to main-thread execution.
|
|
100
|
-
|
|
101
|
-
## Notes — Cross-session Memory
|
|
102
|
-
|
|
103
|
-
Notebook at `.agents/notes/`. Shared memory across sessions. Never ask permission.
|
|
104
|
-
|
|
105
|
-
**On session start:** Read `.agents/notes/index.md` (create if missing).
|
|
106
|
-
**Write notes for:**
|
|
107
|
-
|
|
108
|
-
- Non-obvious behaviors, gotchas, edge cases
|
|
109
|
-
- Hard-won insights that took investigation
|
|
110
|
-
- Project conventions and architectural decisions
|
|
111
|
-
- Setup and config quirks
|
|
112
|
-
**Don't note:** File locations, basic structure, session summaries, trivial facts.
|
|
113
|
-
**Guidelines:** Store in `.agents/notes/`, keep `index.md` lean with one line per note, update existing notes before creating new ones, include why not just what, prune aggressively.
|