@interf/compiler 0.16.0 → 0.18.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/LICENSE.md +1 -0
- package/README.md +10 -7
- package/TRADEMARKS.md +4 -4
- package/builtin-methods/interf-default/README.md +6 -7
- package/builtin-methods/interf-default/method.json +7 -68
- package/builtin-methods/interf-default/method.schema.json +52 -50
- package/dist/cli/commands/prep.js +58 -2
- package/dist/cli/commands/verify.d.ts +2 -0
- package/dist/cli/commands/verify.js +17 -8
- package/dist/cli/commands/wizard.js +122 -14
- package/dist/compiler-ui/404.html +1 -1
- package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
- package/dist/compiler-ui/__next._full.txt +3 -3
- package/dist/compiler-ui/__next._head.txt +1 -1
- package/dist/compiler-ui/__next._index.txt +2 -2
- package/dist/compiler-ui/__next._tree.txt +2 -2
- package/dist/compiler-ui/_next/static/chunks/{13awzu4tooflw.css → 0_c_tvh-cukjz.css} +1 -1
- package/dist/compiler-ui/_next/static/chunks/{0jipmpez3_ehh.js → 0f_geuwdesg_c.js} +42 -17
- package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
- package/dist/compiler-ui/_not-found.html +1 -1
- package/dist/compiler-ui/_not-found.txt +2 -2
- package/dist/compiler-ui/index.html +1 -1
- package/dist/compiler-ui/index.txt +3 -3
- package/dist/packages/contracts/index.d.ts +2 -2
- package/dist/packages/contracts/index.js +1 -1
- package/dist/packages/contracts/lib/schema.d.ts +271 -72
- package/dist/packages/contracts/lib/schema.js +243 -83
- package/dist/packages/engine/action-definitions.js +1 -1
- package/dist/packages/engine/agents/lib/shells.d.ts +12 -4
- package/dist/packages/engine/agents/lib/shells.js +127 -120
- package/dist/packages/engine/cloud-seams.d.ts +115 -0
- package/dist/packages/engine/cloud-seams.js +84 -0
- package/dist/packages/engine/compile/artifact-counts.d.ts +1 -1
- package/dist/packages/engine/compile/artifact-counts.js +3 -3
- package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
- package/dist/packages/engine/compile/artifact-status.js +166 -0
- package/dist/packages/engine/compile/billing-events.d.ts +89 -0
- package/dist/packages/engine/compile/billing-events.js +74 -0
- package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
- package/dist/packages/engine/compile/check-evaluator.js +298 -0
- package/dist/packages/engine/compile/compiled-schema.d.ts +7 -17
- package/dist/packages/engine/compile/compiled-schema.js +55 -70
- package/dist/packages/engine/compile/compiled-stage-plan.d.ts +1 -0
- package/dist/packages/engine/compile/compiled-stage-plan.js +32 -15
- package/dist/packages/engine/compile/compiled-stage-runner.js +1 -1
- package/dist/packages/engine/compile/index.d.ts +0 -1
- package/dist/packages/engine/compile/index.js +0 -1
- package/dist/packages/engine/compile/lib/schema.d.ts +111 -92
- package/dist/packages/engine/compile/lib/schema.js +35 -39
- package/dist/packages/engine/compile/method-primitives.d.ts +2 -2
- package/dist/packages/engine/compile/method-primitives.js +1 -1
- package/dist/packages/engine/compile/reset.js +4 -4
- package/dist/packages/engine/compile/runtime-contracts.js +2 -1
- package/dist/packages/engine/compile/runtime-prompt.js +3 -2
- package/dist/packages/engine/compile/runtime-reconcile.js +35 -35
- package/dist/packages/engine/compile/runtime-runs.js +0 -1
- package/dist/packages/engine/compile/runtime-types.d.ts +7 -8
- package/dist/packages/engine/compile/runtime.d.ts +1 -2
- package/dist/packages/engine/compile/runtime.js +0 -1
- package/dist/packages/engine/compile/state-health.js +6 -6
- package/dist/packages/engine/compile/state-view.js +7 -6
- package/dist/packages/engine/compile/validate-compiled.js +61 -30
- package/dist/packages/engine/compile/validate.js +26 -24
- package/dist/packages/engine/execution/lib/schema.d.ts +79 -33
- package/dist/packages/engine/execution/lib/schema.js +13 -5
- package/dist/packages/engine/index.d.ts +2 -2
- package/dist/packages/engine/index.js +1 -1
- package/dist/packages/engine/lib/schema.d.ts +551 -242
- package/dist/packages/engine/lib/schema.js +53 -17
- package/dist/packages/engine/native-run-handlers.js +15 -7
- package/dist/packages/engine/preparation-store.d.ts +6 -0
- package/dist/packages/engine/preparation-store.js +8 -0
- package/dist/packages/engine/routes.d.ts +6 -0
- package/dist/packages/engine/routes.js +6 -0
- package/dist/packages/engine/run-observability.js +1 -2
- package/dist/packages/engine/runtime-event-applier.js +7 -0
- package/dist/packages/engine/runtime-proposal-helpers.js +1 -1
- package/dist/packages/engine/runtime-resource-builders.d.ts +6 -6
- package/dist/packages/engine/runtime-resource-builders.js +5 -4
- package/dist/packages/engine/runtime.d.ts +67 -7
- package/dist/packages/engine/runtime.js +159 -29
- package/dist/packages/engine/server.d.ts +25 -0
- package/dist/packages/engine/server.js +62 -3
- package/dist/packages/engine/verify/index.d.ts +10 -10
- package/dist/packages/engine/verify/index.js +8 -8
- package/dist/packages/engine/verify/readiness-check-run.d.ts +27 -4
- package/dist/packages/engine/verify/readiness-check-run.js +92 -24
- package/dist/packages/engine/verify/{test-execution.d.ts → verify-execution.d.ts} +2 -2
- package/dist/packages/engine/verify/{test-execution.js → verify-execution.js} +2 -2
- package/dist/packages/engine/verify/{test-paths.d.ts → verify-paths.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-sandbox.d.ts → verify-sandbox.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-specs.d.ts → verify-specs.d.ts} +1 -1
- package/dist/packages/engine/verify/{test-specs.js → verify-specs.js} +1 -1
- package/dist/packages/engine/verify/{test-targets.d.ts → verify-targets.d.ts} +1 -1
- package/dist/packages/engine/verify/{test.d.ts → verify.d.ts} +4 -4
- package/dist/packages/engine/verify/{test.js → verify.js} +3 -3
- package/dist/packages/engine/wire-schemas.d.ts +545 -0
- package/dist/packages/engine/wire-schemas.js +59 -0
- package/dist/packages/methods/authoring/method-authoring.d.ts +2 -0
- package/dist/packages/methods/authoring/method-authoring.js +99 -18
- package/dist/packages/methods/authoring/method-edit-session.js +5 -5
- package/dist/packages/methods/authoring/method-improvement.js +1 -1
- package/dist/packages/methods/package/builtin-compiled-method.d.ts +12 -12
- package/dist/packages/methods/package/builtin-compiled-method.js +25 -22
- package/dist/packages/methods/package/context-interface.d.ts +39 -26
- package/dist/packages/methods/package/context-interface.js +48 -39
- package/dist/packages/methods/package/interf-method-package.js +28 -47
- package/dist/packages/methods/package/local-methods.d.ts +3 -4
- package/dist/packages/methods/package/local-methods.js +34 -62
- package/dist/packages/methods/package/method-definitions.d.ts +4 -6
- package/dist/packages/methods/package/method-definitions.js +0 -4
- package/dist/packages/methods/package/method-helpers.d.ts +0 -2
- package/dist/packages/methods/package/method-helpers.js +0 -4
- package/dist/packages/project/interf-scaffold.js +12 -12
- package/dist/packages/project/source-config.js +2 -1
- package/package.json +6 -16
- package/dist/packages/engine/compile/runtime-acceptance.d.ts +0 -9
- package/dist/packages/engine/compile/runtime-acceptance.js +0 -265
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_ssgManifest.js +0 -0
- /package/dist/packages/engine/verify/{test-paths.js → verify-paths.js} +0 -0
- /package/dist/packages/engine/verify/{test-profile-presets.d.ts → verify-profile-presets.d.ts} +0 -0
- /package/dist/packages/engine/verify/{test-profile-presets.js → verify-profile-presets.js} +0 -0
- /package/dist/packages/engine/verify/{test-sandbox.js → verify-sandbox.js} +0 -0
- /package/dist/packages/engine/verify/{test-targets.js → verify-targets.js} +0 -0
- /package/dist/packages/engine/verify/{test-types.d.ts → verify-types.d.ts} +0 -0
- /package/dist/packages/engine/verify/{test-types.js → verify-types.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { createMethodAuthoringShell } from "../../engine/agents/lib/shells.js";
|
|
3
|
+
import { createMethodAuthoringShell, } from "../../engine/agents/lib/shells.js";
|
|
4
4
|
import { createScratchLocalMethodPackage } from "../package/interf-method-package.js";
|
|
5
|
-
import { CONTEXT_INTERFACE_FILE } from "../package/context-interface.js";
|
|
5
|
+
import { CONTEXT_INTERFACE_FILE, listContextInterfaceArtifacts } from "../package/context-interface.js";
|
|
6
6
|
import { loadMethodDefinitionFromDir, validateMethodPackage, methodDefinitionPath, } from "../package/local-methods.js";
|
|
7
7
|
import { runMethodEditSession } from "./method-edit-session.js";
|
|
8
8
|
/**
|
|
@@ -66,29 +66,27 @@ function buildMethodAuthoringPrompt() {
|
|
|
66
66
|
"Treat `task_prompt` as the user's preparation-and-evidence brief: source data, output shape, and evidence that should show the data is ready.",
|
|
67
67
|
`Then read \`method/README.md\`, \`method/method.json\`, and \`method/${CONTEXT_INTERFACE_FILE}\`.`,
|
|
68
68
|
"The `method/` directory starts as a neutral Method package scaffold, not as a suggested Method.",
|
|
69
|
-
"Replace the scaffold purpose, inputs,
|
|
69
|
+
"Replace the scaffold purpose, inputs, Artifacts, stages, stage docs, checks, and query guidance with the Method this agent work actually needs.",
|
|
70
70
|
"Read `runtime/source-files.json` and inspect the listed source locators before editing the package.",
|
|
71
71
|
"Prefer direct file-reading and search tools over shell commands for routine file inspection.",
|
|
72
72
|
"Do not use shell helpers like `cat`, `sed`, `ls`, or `find` when a native read/search tool can inspect the same files.",
|
|
73
73
|
"Edit only files under `method/`.",
|
|
74
74
|
"Keep the Method package valid for the current compiler API and `method.schema.json`.",
|
|
75
|
-
"Choose stage ids, stage order, reads, writes,
|
|
76
|
-
"Use kebab-case ids everywhere: stage ids, skill_dir values,
|
|
75
|
+
"Choose stage ids, stage order, artifact reads, artifact writes, artifact checks, and stage docs from the source data and preparation-and-evidence brief.",
|
|
76
|
+
"Use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids. Never use underscores.",
|
|
77
77
|
"Each stage MAY declare a `role`: one of `extractor`, `summarizer`, `structurer`, `verifier`, or `general`. Pick the role that best matches what the stage's prompt asks the agent to do. Omit `role` (or use `general`) when the stage doesn't fit any specialized role. Custom role names are allowed; the engine treats unknown roles as `general`.",
|
|
78
78
|
"Do not preserve the placeholder `prepare` stage unless the final Method genuinely needs a stage with that exact role.",
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"Before stopping, verify every zone-count acceptance key is declared in `method.schema.json`.",
|
|
79
|
+
"Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
|
|
80
|
+
"Use only the CheckKind values listed in `runtime/authoring-context.json`; do not invent aliases.",
|
|
81
|
+
"Keep Artifact checks and the producing stage docs aligned: every checked output requirement must be described in the stage doc that writes that Artifact.",
|
|
83
82
|
"For every stage in `method.json`, create `method/compile/stages/<skill_dir>/SKILL.md` and make the folder name exactly match that stage's kebab-case `skill_dir`.",
|
|
84
|
-
"Every
|
|
83
|
+
"Every Artifact path in `method.schema.json` must be unique and non-overlapping.",
|
|
85
84
|
"Make the package materially specific to this Preparation task, output shape, and proof requirement. A no-op scaffold is not acceptable.",
|
|
86
85
|
"Treat the Method package as four aligned layers: purpose, inputs, context interface, and stages.",
|
|
87
|
-
"
|
|
88
|
-
"Do not move the main entrypoint to `knowledge/home.md` or any other nested path.",
|
|
86
|
+
"If the Method writes an agent entrypoint, declare it as an Artifact and make the final shaping stage own it.",
|
|
89
87
|
"Prefer explicit stage-doc, stage-policy, purpose, input-contract, and context-interface edits over vague rewrites.",
|
|
90
88
|
"Do not introduce wikilinks unless the Method also creates the target note by exact basename or explicit relative path.",
|
|
91
|
-
"Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read
|
|
89
|
+
"Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read Artifacts.",
|
|
92
90
|
"Do not make one stage point at files or notes that are only created later by another stage.",
|
|
93
91
|
"Prefer conservative retrieval routing over speculative note sprawl.",
|
|
94
92
|
"Do not narrate plans or ask follow-up questions.",
|
|
@@ -96,7 +94,87 @@ function buildMethodAuthoringPrompt() {
|
|
|
96
94
|
"As soon as the Method edits are complete, stop.",
|
|
97
95
|
].join("\n");
|
|
98
96
|
}
|
|
99
|
-
function
|
|
97
|
+
function stableJson(value) {
|
|
98
|
+
if (value === null || typeof value !== "object") {
|
|
99
|
+
return JSON.stringify(value ?? {});
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
return `[${value.map((entry) => stableJson(entry)).join(",")}]`;
|
|
103
|
+
}
|
|
104
|
+
const record = value;
|
|
105
|
+
return `{${Object.keys(record)
|
|
106
|
+
.sort()
|
|
107
|
+
.map((key) => `${JSON.stringify(key)}:${stableJson(record[key])}`)
|
|
108
|
+
.join(",")}}`;
|
|
109
|
+
}
|
|
110
|
+
function checkMatchesRequirement(actual, required) {
|
|
111
|
+
return actual.id === required.id &&
|
|
112
|
+
actual.kind === required.kind &&
|
|
113
|
+
(actual.required ?? true) === (required.required ?? true) &&
|
|
114
|
+
stableJson(actual.params) === stableJson(required.params);
|
|
115
|
+
}
|
|
116
|
+
function producingStagesForArtifact(definition, artifactId) {
|
|
117
|
+
return (definition.stages ?? []).filter((stage) => Array.isArray(stage.writes) && stage.writes.includes(artifactId));
|
|
118
|
+
}
|
|
119
|
+
function readProducingStageDocs(methodPath, stages) {
|
|
120
|
+
return stages
|
|
121
|
+
.map((stage) => join(methodPath, "compile", "stages", stage.skill_dir ?? stage.id, "SKILL.md"))
|
|
122
|
+
.filter((filePath) => existsSync(filePath))
|
|
123
|
+
.map((filePath) => readFileSync(filePath, "utf8"))
|
|
124
|
+
.join("\n");
|
|
125
|
+
}
|
|
126
|
+
function validateMustContainStageDocs(methodPath, definition) {
|
|
127
|
+
const artifacts = definition.method_schema.artifacts ?? [];
|
|
128
|
+
const errors = [];
|
|
129
|
+
for (const artifact of artifacts) {
|
|
130
|
+
const producingStages = producingStagesForArtifact(definition, artifact.id);
|
|
131
|
+
if (producingStages.length === 0)
|
|
132
|
+
continue;
|
|
133
|
+
const producingStageDocs = readProducingStageDocs(methodPath, producingStages);
|
|
134
|
+
for (const check of artifact.checks ?? []) {
|
|
135
|
+
if (check.kind !== "must_contain")
|
|
136
|
+
continue;
|
|
137
|
+
const phrases = check.params?.phrases;
|
|
138
|
+
if (!Array.isArray(phrases))
|
|
139
|
+
continue;
|
|
140
|
+
for (const phrase of phrases) {
|
|
141
|
+
if (typeof phrase !== "string")
|
|
142
|
+
continue;
|
|
143
|
+
if (!producingStageDocs.includes(phrase)) {
|
|
144
|
+
errors.push(`Artifact \`${artifact.id}\` check \`${check.id}\` requires phrase not present in producing stage docs.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return errors;
|
|
150
|
+
}
|
|
151
|
+
function validateArtifactRequirements(methodPath, definition, requirements) {
|
|
152
|
+
const artifacts = definition.method_schema.artifacts ?? [];
|
|
153
|
+
const errors = [];
|
|
154
|
+
for (const requirement of requirements) {
|
|
155
|
+
const artifact = artifacts.find((candidate) => candidate.id === requirement.id);
|
|
156
|
+
if (!artifact) {
|
|
157
|
+
errors.push(`Missing required Artifact \`${requirement.id}\`.`);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (artifact.shape.kind !== requirement.shape.kind ||
|
|
161
|
+
artifact.shape.path !== requirement.shape.path ||
|
|
162
|
+
artifact.shape.artifact_kind !== requirement.shape.artifact_kind) {
|
|
163
|
+
errors.push(`Artifact \`${requirement.id}\` does not match required shape.`);
|
|
164
|
+
}
|
|
165
|
+
for (const check of requirement.checks) {
|
|
166
|
+
if (!artifact.checks.some((candidate) => checkMatchesRequirement(candidate, check))) {
|
|
167
|
+
errors.push(`Artifact \`${requirement.id}\` is missing required check \`${check.id}\`.`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const producingStages = producingStagesForArtifact(definition, requirement.id);
|
|
171
|
+
if (producingStages.length === 0) {
|
|
172
|
+
errors.push(`Artifact \`${requirement.id}\` is not written by any stage.`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return errors;
|
|
176
|
+
}
|
|
177
|
+
function validateAuthoredMethodPackage(methodPath, artifactRequirements = []) {
|
|
100
178
|
const validation = validateMethodPackage(methodPath);
|
|
101
179
|
if (!validation.ok)
|
|
102
180
|
return validation;
|
|
@@ -107,18 +185,20 @@ function validateAuthoredMethodPackage(methodPath) {
|
|
|
107
185
|
const placeholderStage = definition.stages?.find((stage) => stage.id === "prepare" &&
|
|
108
186
|
stage.contract_type === "method-draft-stage" &&
|
|
109
187
|
stage.writes.includes("draft-context"));
|
|
110
|
-
const
|
|
188
|
+
const placeholderArtifact = listContextInterfaceArtifacts(definition.method_schema).find((artifact) => artifact.id === "draft-context");
|
|
111
189
|
const placeholderPurpose = definition.purpose?.label === "From-scratch Method draft" ||
|
|
112
190
|
definition.purpose?.task_hint?.includes("Replace this neutral scaffold");
|
|
113
191
|
if (placeholderStage) {
|
|
114
192
|
errors.push("Authored Method still contains the neutral scaffold stage `prepare`.");
|
|
115
193
|
}
|
|
116
|
-
if (
|
|
117
|
-
errors.push("Authored Method still contains the neutral scaffold
|
|
194
|
+
if (placeholderArtifact) {
|
|
195
|
+
errors.push("Authored Method still contains the neutral scaffold artifact `draft-context`.");
|
|
118
196
|
}
|
|
119
197
|
if (placeholderPurpose) {
|
|
120
198
|
errors.push("Authored Method still contains the neutral scaffold purpose.");
|
|
121
199
|
}
|
|
200
|
+
errors.push(...validateArtifactRequirements(methodPath, definition, artifactRequirements));
|
|
201
|
+
errors.push(...validateMustContainStageDocs(methodPath, definition));
|
|
122
202
|
return {
|
|
123
203
|
ok: validation.ok && errors.length === 0,
|
|
124
204
|
summary: errors.length === 0
|
|
@@ -143,13 +223,14 @@ export async function runMethodAuthoringDraft(options) {
|
|
|
143
223
|
sourceFolderPath: options.sourceFolderPath,
|
|
144
224
|
taskPrompt: options.taskPrompt,
|
|
145
225
|
checks: options.checks ?? [],
|
|
226
|
+
artifactRequirements: options.artifactRequirements ?? [],
|
|
146
227
|
});
|
|
147
228
|
const session = await runMethodEditSession({
|
|
148
229
|
executor: options.executor,
|
|
149
230
|
methodPath,
|
|
150
231
|
shell,
|
|
151
232
|
prompt: buildMethodAuthoringPrompt(),
|
|
152
|
-
validate: validateAuthoredMethodPackage,
|
|
233
|
+
validate: (methodPath) => validateAuthoredMethodPackage(methodPath, options.artifactRequirements ?? []),
|
|
153
234
|
maxValidationRepairAttempts: 1,
|
|
154
235
|
onStatus: options.onStatus,
|
|
155
236
|
});
|
|
@@ -94,12 +94,12 @@ export async function runMethodEditSession(options) {
|
|
|
94
94
|
"",
|
|
95
95
|
"Rules:",
|
|
96
96
|
"- Edit only files under `method/`.",
|
|
97
|
-
"- Use kebab-case ids everywhere: stage ids, skill_dir values,
|
|
97
|
+
"- Use kebab-case ids everywhere: stage ids, skill_dir values, Artifact ids, reads/writes values, and package ids. Never use underscores.",
|
|
98
98
|
"- Keep every stage `skill_dir` matched by `method/compile/stages/<skill_dir>/SKILL.md`.",
|
|
99
|
-
"- Keep `method.schema.json`
|
|
100
|
-
"-
|
|
101
|
-
"-
|
|
102
|
-
"-
|
|
99
|
+
"- Keep `method.schema.json` Artifact paths unique and non-overlapping.",
|
|
100
|
+
"- Put deterministic validation on Artifact `checks[]`; do not add stage `acceptance` blocks.",
|
|
101
|
+
"- Use only CheckKind values listed in `runtime/authoring-context.json`; replace invented aliases with valid kinds.",
|
|
102
|
+
"- If the Method writes an agent entrypoint, keep it declared as an Artifact owned by the producing stage.",
|
|
103
103
|
"- Stop as soon as the package should validate.",
|
|
104
104
|
].join("\n");
|
|
105
105
|
appendFileSync(options.shell.promptLogPath, `\n\n---\n\n${prompt}\n`);
|
|
@@ -67,7 +67,7 @@ function buildMethodImprovementPrompt() {
|
|
|
67
67
|
"Edit only files under `method/`.",
|
|
68
68
|
"Do not edit checks, test specs, source files, or generated portable-context outputs.",
|
|
69
69
|
"Keep the Method package valid for the current compiler API and `method.schema.json`.",
|
|
70
|
-
"Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read
|
|
70
|
+
"Respect stage boundaries: a stage may only introduce links that resolve within that stage's declared writes or already-existing read Artifacts.",
|
|
71
71
|
"Do not make one stage point at files or notes that are only created later by another stage.",
|
|
72
72
|
"Prefer small, defensible changes to Method docs, stage docs, stage policies, or schema ownership over random churn.",
|
|
73
73
|
"Do not narrate plans or ask follow-up questions.",
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CompiledArtifactKind } from "../../engine/compile/method-primitives.js";
|
|
2
2
|
declare const BUILTIN_COMPILED_STAGE_IDS: {
|
|
3
3
|
readonly SUMMARIZE: "summarize";
|
|
4
4
|
readonly STRUCTURE: "structure";
|
|
5
5
|
readonly SHAPE: "shape";
|
|
6
6
|
};
|
|
7
7
|
type BuiltinCompiledStageId = typeof BUILTIN_COMPILED_STAGE_IDS[keyof typeof BUILTIN_COMPILED_STAGE_IDS];
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const BUILTIN_COMPILED_ARTIFACT_IDS: {
|
|
9
9
|
readonly SUMMARIES: "summaries";
|
|
10
10
|
readonly KNOWLEDGE_ENTITIES: "knowledge-entities";
|
|
11
11
|
readonly KNOWLEDGE_CLAIMS: "knowledge-claims";
|
|
12
12
|
readonly KNOWLEDGE_INDEXES: "knowledge-indexes";
|
|
13
|
-
readonly HOME: "
|
|
13
|
+
readonly HOME: "atlas";
|
|
14
14
|
readonly RUNTIME: "runtime";
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
17
|
-
export interface
|
|
18
|
-
id:
|
|
16
|
+
export type BuiltinCompiledArtifactId = typeof BUILTIN_COMPILED_ARTIFACT_IDS[keyof typeof BUILTIN_COMPILED_ARTIFACT_IDS];
|
|
17
|
+
export interface BuiltinCompiledArtifactSpec {
|
|
18
|
+
id: BuiltinCompiledArtifactId;
|
|
19
19
|
role: "input" | "working" | "output" | "runtime";
|
|
20
20
|
path: string;
|
|
21
|
-
kind:
|
|
21
|
+
kind: CompiledArtifactKind;
|
|
22
22
|
required: boolean;
|
|
23
23
|
description: string;
|
|
24
24
|
}
|
|
25
25
|
export interface BuiltinCompiledStageAccessPattern {
|
|
26
26
|
id: BuiltinCompiledStageId;
|
|
27
27
|
contract_type: string;
|
|
28
|
-
reads:
|
|
29
|
-
writes:
|
|
28
|
+
reads: BuiltinCompiledArtifactId[];
|
|
29
|
+
writes: BuiltinCompiledArtifactId[];
|
|
30
30
|
}
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function listBuiltinCompiledArtifactSpecs(): BuiltinCompiledArtifactSpec[];
|
|
32
32
|
export declare function listBuiltinCompiledFallbackStages(): BuiltinCompiledStageAccessPattern[];
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function requiredCompiledArtifactOwners<TStage extends {
|
|
34
34
|
id: string;
|
|
35
35
|
writes: readonly string[];
|
|
36
|
-
}>(stages: readonly TStage[],
|
|
36
|
+
}>(stages: readonly TStage[], artifactId: BuiltinCompiledArtifactId): string[];
|
|
37
37
|
export {};
|
|
@@ -8,20 +8,20 @@ const BUILTIN_COMPILED_STAGE_IDS = {
|
|
|
8
8
|
STRUCTURE: "structure",
|
|
9
9
|
SHAPE: "shape",
|
|
10
10
|
};
|
|
11
|
-
export const
|
|
11
|
+
export const BUILTIN_COMPILED_ARTIFACT_IDS = {
|
|
12
12
|
SUMMARIES: "summaries",
|
|
13
13
|
KNOWLEDGE_ENTITIES: "knowledge-entities",
|
|
14
14
|
KNOWLEDGE_CLAIMS: "knowledge-claims",
|
|
15
15
|
KNOWLEDGE_INDEXES: "knowledge-indexes",
|
|
16
|
-
HOME: "
|
|
16
|
+
HOME: "atlas",
|
|
17
17
|
RUNTIME: "runtime",
|
|
18
18
|
};
|
|
19
|
-
const
|
|
19
|
+
const BUILTIN_ARTIFACT_ID_SET = new Set(Object.values(BUILTIN_COMPILED_ARTIFACT_IDS));
|
|
20
20
|
const BUILTIN_STAGE_ID_SET = new Set(Object.values(BUILTIN_COMPILED_STAGE_IDS));
|
|
21
21
|
const BuiltinMethodStageSchema = z.object({
|
|
22
22
|
id: z.string(),
|
|
23
23
|
contract_type: z.string(),
|
|
24
|
-
reads: z.array(z.string())
|
|
24
|
+
reads: z.array(z.string()),
|
|
25
25
|
writes: z.array(z.string()).min(1),
|
|
26
26
|
});
|
|
27
27
|
const BuiltinMethodPackageSchema = z.object({
|
|
@@ -29,9 +29,9 @@ const BuiltinMethodPackageSchema = z.object({
|
|
|
29
29
|
});
|
|
30
30
|
let builtinCompiledContractCache = null;
|
|
31
31
|
const BUILTIN_DEFAULT_METHOD_ROOT = join(PACKAGE_ROOT, "builtin-methods", "interf-default");
|
|
32
|
-
function
|
|
33
|
-
if (!
|
|
34
|
-
throw new Error(`Built-in Interf Method schema declares unsupported
|
|
32
|
+
function assertBuiltinArtifactId(value) {
|
|
33
|
+
if (!BUILTIN_ARTIFACT_ID_SET.has(value)) {
|
|
34
|
+
throw new Error(`Built-in Interf Method schema declares unsupported Artifact id "${value}".`);
|
|
35
35
|
}
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
@@ -54,25 +54,28 @@ function loadBuiltinCompiledContract() {
|
|
|
54
54
|
if (!method) {
|
|
55
55
|
throw new Error(`Missing or invalid built-in Method package at ${methodPath}.`);
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
const artifacts = schema.artifacts.map((artifact) => {
|
|
58
|
+
const path = artifact.shape.path;
|
|
59
|
+
return {
|
|
60
|
+
id: assertBuiltinArtifactId(artifact.id),
|
|
61
|
+
role: "output",
|
|
62
|
+
path,
|
|
63
|
+
kind: artifact.shape.artifact_kind,
|
|
64
|
+
required: true,
|
|
65
|
+
description: artifact.description,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
65
68
|
const stages = method.stages.map((stage) => ({
|
|
66
69
|
id: assertBuiltinStageId(stage.id),
|
|
67
70
|
contract_type: stage.contract_type,
|
|
68
|
-
reads: stage.reads.map(
|
|
69
|
-
writes: stage.writes.map(
|
|
71
|
+
reads: stage.reads.map(assertBuiltinArtifactId),
|
|
72
|
+
writes: stage.writes.map(assertBuiltinArtifactId),
|
|
70
73
|
}));
|
|
71
|
-
builtinCompiledContractCache = {
|
|
74
|
+
builtinCompiledContractCache = { artifacts, stages };
|
|
72
75
|
return builtinCompiledContractCache;
|
|
73
76
|
}
|
|
74
|
-
export function
|
|
75
|
-
return loadBuiltinCompiledContract().
|
|
77
|
+
export function listBuiltinCompiledArtifactSpecs() {
|
|
78
|
+
return loadBuiltinCompiledContract().artifacts.map((artifact) => ({ ...artifact }));
|
|
76
79
|
}
|
|
77
80
|
export function listBuiltinCompiledFallbackStages() {
|
|
78
81
|
return loadBuiltinCompiledContract().stages.map((stage) => ({
|
|
@@ -81,8 +84,8 @@ export function listBuiltinCompiledFallbackStages() {
|
|
|
81
84
|
writes: [...stage.writes],
|
|
82
85
|
}));
|
|
83
86
|
}
|
|
84
|
-
export function
|
|
87
|
+
export function requiredCompiledArtifactOwners(stages, artifactId) {
|
|
85
88
|
return Array.from(new Set(stages
|
|
86
|
-
.filter((stage) => stage.writes.includes(
|
|
89
|
+
.filter((stage) => stage.writes.includes(artifactId))
|
|
87
90
|
.map((stage) => stage.id)));
|
|
88
91
|
}
|
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { type MethodCompiledSchema, type
|
|
2
|
+
import { type MethodCompiledSchema, type MethodCompiledArtifact, type MethodArtifactId } from "../../engine/compile/lib/schema.js";
|
|
3
3
|
export declare const CONTEXT_INTERFACE_FILE = "method.schema.json";
|
|
4
4
|
export declare const ContextInterfaceSchema: z.ZodObject<{
|
|
5
5
|
kind: z.ZodLiteral<"method-schema">;
|
|
6
6
|
version: z.ZodLiteral<1>;
|
|
7
7
|
target_type: z.ZodLiteral<"compiled">;
|
|
8
8
|
label: z.ZodString;
|
|
9
|
-
|
|
9
|
+
artifacts: z.ZodArray<z.ZodObject<{
|
|
10
10
|
id: z.ZodString;
|
|
11
|
-
role: z.ZodEnum<{
|
|
12
|
-
runtime: "runtime";
|
|
13
|
-
output: "output";
|
|
14
|
-
input: "input";
|
|
15
|
-
working: "working";
|
|
16
|
-
}>;
|
|
17
|
-
path: z.ZodString;
|
|
18
|
-
kind: z.ZodEnum<{
|
|
19
|
-
runtime: "runtime";
|
|
20
|
-
file: "file";
|
|
21
|
-
directory: "directory";
|
|
22
|
-
}>;
|
|
23
|
-
required: z.ZodBoolean;
|
|
24
|
-
owned_by: z.ZodArray<z.ZodString>;
|
|
25
11
|
description: z.ZodString;
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
shape: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
|
+
kind: z.ZodLiteral<"path">;
|
|
14
|
+
path: z.ZodString;
|
|
15
|
+
artifact_kind: z.ZodEnum<{
|
|
16
|
+
file: "file";
|
|
17
|
+
directory: "directory";
|
|
18
|
+
}>;
|
|
19
|
+
}, z.core.$strict>], "kind">;
|
|
20
|
+
checks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
kind: z.ZodEnum<{
|
|
23
|
+
file_exists: "file_exists";
|
|
24
|
+
min_file_count: "min_file_count";
|
|
25
|
+
min_file_count_matches_source: "min_file_count_matches_source";
|
|
26
|
+
frontmatter_valid: "frontmatter_valid";
|
|
27
|
+
frontmatter_required_keys: "frontmatter_required_keys";
|
|
28
|
+
wikilinks_valid: "wikilinks_valid";
|
|
29
|
+
must_not_contain: "must_not_contain";
|
|
30
|
+
must_contain: "must_contain";
|
|
31
|
+
qa_match: "qa_match";
|
|
32
|
+
}>;
|
|
33
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
|
+
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
35
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
+
}, z.core.$strict>>>;
|
|
37
|
+
built_by_stages: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
}, z.core.$strict>;
|
|
28
40
|
export declare const MethodInputSpecSchema: z.ZodObject<{
|
|
29
41
|
id: z.ZodString;
|
|
30
42
|
label: z.ZodString;
|
|
@@ -33,24 +45,25 @@ export declare const MethodInputSpecSchema: z.ZodObject<{
|
|
|
33
45
|
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
46
|
}, z.core.$strict>;
|
|
35
47
|
export type ContextInterface = MethodCompiledSchema;
|
|
36
|
-
export type
|
|
37
|
-
export type
|
|
48
|
+
export type ContextInterfaceArtifact = MethodCompiledArtifact;
|
|
49
|
+
export type ContextInterfaceArtifactId = MethodArtifactId;
|
|
38
50
|
export type MethodInputSpec = z.infer<typeof MethodInputSpecSchema>;
|
|
39
51
|
interface ContextInterfaceStageLike {
|
|
40
52
|
id: string;
|
|
41
53
|
writes: readonly string[];
|
|
42
54
|
}
|
|
43
55
|
interface ContextInterfaceSummary {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
inputArtifacts: ContextInterfaceArtifact[];
|
|
57
|
+
workingArtifacts: ContextInterfaceArtifact[];
|
|
58
|
+
outputArtifacts: ContextInterfaceArtifact[];
|
|
59
|
+
runtimeArtifacts: ContextInterfaceArtifact[];
|
|
48
60
|
}
|
|
61
|
+
export declare function listContextInterfaceArtifacts(contextInterface: ContextInterface): ContextInterfaceArtifact[];
|
|
49
62
|
export declare function contextInterfaceFilePath(rootPath: string): string;
|
|
50
63
|
export declare function resolveContextInterfacePath(rootPath: string): string | null;
|
|
51
64
|
export declare function contextInterfaceExists(rootPath: string): boolean;
|
|
52
|
-
export declare function
|
|
53
|
-
export declare function contextInterfaceArtifactPath(
|
|
65
|
+
export declare function contextInterfaceArtifactAbsolutePath(compiledPath: string, artifact: Pick<ContextInterfaceArtifact, "path">): string;
|
|
66
|
+
export declare function contextInterfaceArtifactPath(artifact: Pick<ContextInterfaceArtifact, "path" | "kind">): string;
|
|
54
67
|
export declare function summarizeContextInterface(contextInterface: ContextInterface): ContextInterfaceSummary;
|
|
55
68
|
export declare function deriveMethodInputsFromContextInterface(contextInterface: ContextInterface | null | undefined): MethodInputSpec[];
|
|
56
69
|
export declare function buildContextInterface(stages: ContextInterfaceStageLike[], label?: string): ContextInterface;
|
|
@@ -3,8 +3,8 @@ import { join } from "node:path";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { warnInterf } from "../../contracts/utils/logger.js";
|
|
5
5
|
import { readJsonFileUnchecked } from "../../contracts/utils/parse.js";
|
|
6
|
-
import { MethodCompiledSchemaSchema,
|
|
7
|
-
import {
|
|
6
|
+
import { MethodCompiledSchemaSchema, MethodArtifactIdSchema, } from "../../engine/compile/lib/schema.js";
|
|
7
|
+
import { listBuiltinCompiledArtifactSpecs, requiredCompiledArtifactOwners, } from "./builtin-compiled-method.js";
|
|
8
8
|
// Method packages define the context interface. The compiler persists the
|
|
9
9
|
// same schema on disk, but higher layers should prefer this boundary when they
|
|
10
10
|
// mean "the Method-declared shape a portable context must implement."
|
|
@@ -15,7 +15,7 @@ export const ContextInterfaceSchema = MethodCompiledSchemaSchema;
|
|
|
15
15
|
// Method expects to organize before the compiler materializes the context
|
|
16
16
|
// interface on disk.
|
|
17
17
|
export const MethodInputSpecSchema = z.object({
|
|
18
|
-
id:
|
|
18
|
+
id: MethodArtifactIdSchema,
|
|
19
19
|
label: z.string().min(1),
|
|
20
20
|
description: z.string().min(1),
|
|
21
21
|
required: z.boolean().default(false),
|
|
@@ -27,13 +27,23 @@ function normalizeContextInterface(contextInterface) {
|
|
|
27
27
|
kind: "method-schema",
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
function artifactToMethodArtifact(artifact) {
|
|
31
|
+
const path = artifact.shape.kind === "path" ? artifact.shape.path : artifact.id;
|
|
32
|
+
return {
|
|
33
|
+
id: artifact.id,
|
|
34
|
+
role: "output",
|
|
35
|
+
path,
|
|
36
|
+
kind: artifact.shape.kind === "path" ? artifact.shape.artifact_kind : "directory",
|
|
37
|
+
required: true,
|
|
38
|
+
owned_by: [...artifact.built_by_stages],
|
|
39
|
+
description: artifact.description,
|
|
40
|
+
};
|
|
34
41
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
42
|
+
export function listContextInterfaceArtifacts(contextInterface) {
|
|
43
|
+
return contextInterface.artifacts.map(artifactToMethodArtifact);
|
|
44
|
+
}
|
|
45
|
+
function titleCaseArtifactId(artifactId) {
|
|
46
|
+
return artifactId
|
|
37
47
|
.split("-")
|
|
38
48
|
.filter(Boolean)
|
|
39
49
|
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
@@ -49,53 +59,52 @@ export function resolveContextInterfacePath(rootPath) {
|
|
|
49
59
|
export function contextInterfaceExists(rootPath) {
|
|
50
60
|
return existsSync(contextInterfaceFilePath(rootPath));
|
|
51
61
|
}
|
|
52
|
-
export function
|
|
53
|
-
return join(compiledPath,
|
|
62
|
+
export function contextInterfaceArtifactAbsolutePath(compiledPath, artifact) {
|
|
63
|
+
return join(compiledPath, artifact.path);
|
|
54
64
|
}
|
|
55
|
-
export function contextInterfaceArtifactPath(
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
58
|
-
return
|
|
65
|
+
export function contextInterfaceArtifactPath(artifact) {
|
|
66
|
+
if (artifact.kind === "file")
|
|
67
|
+
return artifact.path;
|
|
68
|
+
return artifact.path.endsWith("/") ? artifact.path : `${artifact.path}/`;
|
|
59
69
|
}
|
|
60
70
|
export function summarizeContextInterface(contextInterface) {
|
|
71
|
+
const artifacts = listContextInterfaceArtifacts(contextInterface);
|
|
61
72
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
inputArtifacts: artifacts.filter((artifact) => artifact.role === "input"),
|
|
74
|
+
workingArtifacts: artifacts.filter((artifact) => artifact.role === "working"),
|
|
75
|
+
outputArtifacts: artifacts.filter((artifact) => artifact.role === "output"),
|
|
76
|
+
runtimeArtifacts: artifacts.filter((artifact) => artifact.role === "runtime"),
|
|
66
77
|
};
|
|
67
78
|
}
|
|
68
79
|
export function deriveMethodInputsFromContextInterface(contextInterface) {
|
|
69
80
|
if (!contextInterface)
|
|
70
81
|
return [];
|
|
71
|
-
return contextInterface
|
|
72
|
-
.filter((
|
|
73
|
-
.map((
|
|
74
|
-
id:
|
|
75
|
-
label:
|
|
76
|
-
description:
|
|
77
|
-
required:
|
|
82
|
+
return listContextInterfaceArtifacts(contextInterface)
|
|
83
|
+
.filter((artifact) => artifact.role === "input")
|
|
84
|
+
.map((artifact) => ({
|
|
85
|
+
id: artifact.id,
|
|
86
|
+
label: titleCaseArtifactId(artifact.id),
|
|
87
|
+
description: artifact.description,
|
|
88
|
+
required: artifact.required,
|
|
78
89
|
}));
|
|
79
90
|
}
|
|
80
91
|
export function buildContextInterface(stages, label = "Method context interface") {
|
|
81
|
-
const zones = [];
|
|
82
|
-
for (const zone of listBuiltinCompiledZoneSpecs()) {
|
|
83
|
-
pushContextInterfaceZone(zones, {
|
|
84
|
-
id: zone.id,
|
|
85
|
-
role: zone.role,
|
|
86
|
-
path: zone.path,
|
|
87
|
-
kind: zone.kind,
|
|
88
|
-
required: zone.required,
|
|
89
|
-
owned_by: requiredCompiledZoneOwners(stages, zone.id),
|
|
90
|
-
description: zone.description,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
92
|
return {
|
|
94
93
|
kind: "method-schema",
|
|
95
94
|
version: 1,
|
|
96
95
|
target_type: "compiled",
|
|
97
96
|
label,
|
|
98
|
-
|
|
97
|
+
artifacts: listBuiltinCompiledArtifactSpecs().map((artifact) => ({
|
|
98
|
+
id: artifact.id,
|
|
99
|
+
description: artifact.description,
|
|
100
|
+
shape: {
|
|
101
|
+
kind: "path",
|
|
102
|
+
path: artifact.path,
|
|
103
|
+
artifact_kind: artifact.kind === "file" ? "file" : "directory",
|
|
104
|
+
},
|
|
105
|
+
checks: [],
|
|
106
|
+
built_by_stages: requiredCompiledArtifactOwners(stages, artifact.id),
|
|
107
|
+
})),
|
|
99
108
|
};
|
|
100
109
|
}
|
|
101
110
|
export function writeContextInterfaceFile(rootPath, stages, label) {
|