@interf/compiler 0.9.4 → 0.13.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/README.md +96 -91
- package/TRADEMARKS.md +2 -13
- package/agent-skills/interf-actions/SKILL.md +97 -32
- package/agent-skills/interf-actions/references/cli.md +124 -71
- package/builtin-methods/interf-default/README.md +3 -4
- package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
- package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
- package/builtin-methods/interf-default/improve/SKILL.md +1 -1
- package/builtin-methods/interf-default/method.json +10 -4
- package/builtin-methods/interf-default/method.schema.json +0 -9
- package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
- package/dist/cli/commands/compile.d.ts +9 -31
- package/dist/cli/commands/compile.js +75 -388
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/login.d.ts +7 -0
- package/dist/cli/commands/login.js +39 -0
- package/dist/cli/commands/logout.d.ts +2 -0
- package/dist/cli/commands/logout.js +16 -0
- package/dist/cli/commands/method.d.ts +2 -0
- package/dist/cli/commands/method.js +113 -0
- package/dist/cli/commands/prep.d.ts +2 -0
- package/dist/cli/commands/prep.js +134 -0
- package/dist/cli/commands/reset.d.ts +8 -1
- package/dist/cli/commands/reset.js +47 -15
- package/dist/cli/commands/runs.d.ts +2 -0
- package/dist/cli/commands/runs.js +120 -0
- package/dist/cli/commands/status.d.ts +6 -1
- package/dist/cli/commands/status.js +61 -220
- package/dist/cli/commands/test.d.ts +6 -15
- package/dist/cli/commands/test.js +63 -342
- package/dist/cli/commands/web.d.ts +0 -9
- package/dist/cli/commands/web.js +140 -367
- package/dist/cli/commands/wizard.d.ts +9 -0
- package/dist/cli/commands/wizard.js +442 -0
- package/dist/cli/index.d.ts +7 -6
- package/dist/cli/index.js +13 -10
- 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/045gole2ojo3g.css +3 -0
- package/dist/compiler-ui/_next/static/chunks/17t-lulmyawg5.js +89 -0
- 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/index.d.ts +0 -23
- package/dist/index.js +0 -16
- package/dist/packages/agents/lib/shells.d.ts +1 -1
- package/dist/packages/agents/lib/shells.js +113 -54
- package/dist/packages/agents/lib/user-config.d.ts +4 -2
- package/dist/packages/agents/lib/user-config.js +15 -7
- package/dist/packages/compiler/compiled-paths.d.ts +9 -2
- package/dist/packages/compiler/compiled-paths.js +30 -15
- package/dist/packages/compiler/compiled-pipeline.js +23 -3
- package/dist/packages/compiler/compiled-stage-plan.js +4 -0
- package/dist/packages/compiler/compiled-target.d.ts +1 -1
- package/dist/packages/compiler/compiled-target.js +1 -1
- package/dist/packages/compiler/index.d.ts +1 -0
- package/dist/packages/compiler/index.js +1 -0
- package/dist/packages/compiler/lib/schema.d.ts +27 -32
- package/dist/packages/compiler/lib/schema.js +2 -13
- package/dist/packages/compiler/method-runs.d.ts +2 -3
- package/dist/packages/compiler/method-runs.js +2 -3
- package/dist/packages/compiler/reset.js +3 -1
- package/dist/packages/compiler/runtime-contracts.js +0 -3
- package/dist/packages/compiler/runtime-prompt.js +1 -1
- package/dist/packages/compiler/source-files.d.ts +46 -0
- package/dist/packages/compiler/source-files.js +149 -0
- package/dist/packages/compiler/state-artifacts.d.ts +3 -2
- package/dist/packages/compiler/state-artifacts.js +4 -3
- package/dist/packages/compiler/state-io.d.ts +3 -2
- package/dist/packages/compiler/state-io.js +11 -5
- package/dist/packages/compiler/state-paths.d.ts +2 -1
- package/dist/packages/compiler/state-paths.js +6 -3
- package/dist/packages/compiler/state-view.d.ts +3 -2
- package/dist/packages/compiler/state-view.js +18 -28
- package/dist/packages/compiler/state.d.ts +4 -4
- package/dist/packages/compiler/state.js +3 -3
- package/dist/packages/contracts/index.d.ts +1 -1
- package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
- package/dist/packages/contracts/lib/preparation-paths.js +177 -0
- package/dist/packages/contracts/lib/schema.d.ts +85 -6
- package/dist/packages/contracts/lib/schema.js +46 -2
- package/dist/packages/execution/lib/schema.d.ts +50 -57
- package/dist/packages/execution/lib/schema.js +1 -2
- package/dist/packages/local-service/action-definitions.d.ts +246 -0
- package/dist/packages/local-service/action-definitions.js +1147 -0
- package/dist/packages/local-service/action-planner.d.ts +9 -0
- package/dist/packages/local-service/action-planner.js +135 -0
- package/dist/packages/local-service/action-values.d.ts +1 -23
- package/dist/packages/local-service/action-values.js +1 -31
- package/dist/packages/local-service/client.d.ts +76 -46
- package/dist/packages/local-service/client.js +184 -149
- package/dist/packages/local-service/connection-config.d.ts +38 -0
- package/dist/packages/local-service/connection-config.js +75 -0
- package/dist/packages/local-service/index.d.ts +14 -7
- package/dist/packages/local-service/index.js +8 -4
- package/dist/packages/local-service/instance-paths.d.ts +100 -0
- package/dist/packages/local-service/instance-paths.js +165 -0
- package/dist/packages/local-service/lib/schema.d.ts +689 -2575
- package/dist/packages/local-service/lib/schema.js +260 -101
- package/dist/packages/local-service/native-run-handlers.d.ts +23 -0
- package/dist/{cli/commands/compile-controller.js → packages/local-service/native-run-handlers.js} +204 -20
- package/dist/packages/local-service/preparation-store.d.ts +92 -0
- package/dist/packages/local-service/preparation-store.js +171 -0
- package/dist/{cli/commands/check-draft.d.ts → packages/local-service/readiness-check-draft.d.ts} +2 -2
- package/dist/packages/local-service/routes.d.ts +33 -11
- package/dist/packages/local-service/routes.js +44 -15
- package/dist/packages/local-service/run-observability.js +25 -27
- package/dist/packages/local-service/runtime-caches.d.ts +76 -0
- package/dist/packages/local-service/runtime-caches.js +191 -0
- package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
- package/dist/packages/local-service/runtime-event-applier.js +177 -0
- package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
- package/dist/packages/local-service/runtime-persistence.js +137 -0
- package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
- package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
- package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
- package/dist/packages/local-service/runtime-resource-builders.js +149 -0
- package/dist/packages/local-service/runtime.d.ts +201 -44
- package/dist/packages/local-service/runtime.js +1062 -1106
- package/dist/packages/local-service/server.d.ts +15 -0
- package/dist/packages/local-service/server.js +651 -233
- package/dist/packages/local-service/service-registry.d.ts +47 -0
- package/dist/packages/local-service/service-registry.js +137 -0
- package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
- package/dist/packages/method-authoring/method-authoring.js +2 -2
- package/dist/packages/method-authoring/method-improvement.js +1 -1
- package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
- package/dist/packages/method-package/builtin-compiled-method.js +8 -14
- package/dist/packages/method-package/context-interface.d.ts +4 -40
- package/dist/packages/method-package/context-interface.js +1 -23
- package/dist/packages/method-package/interf-method-package.d.ts +4 -4
- package/dist/packages/method-package/interf-method-package.js +21 -33
- package/dist/packages/method-package/local-methods.d.ts +10 -6
- package/dist/packages/method-package/local-methods.js +57 -39
- package/dist/packages/method-package/method-definitions.d.ts +8 -34
- package/dist/packages/method-package/method-definitions.js +49 -37
- package/dist/packages/method-package/method-helpers.d.ts +1 -13
- package/dist/packages/method-package/method-helpers.js +8 -42
- package/dist/packages/method-package/method-review-paths.d.ts +1 -1
- package/dist/packages/method-package/method-review-paths.js +5 -5
- package/dist/packages/method-package/method-stage-runner.js +2 -2
- package/dist/packages/method-package/user-methods.d.ts +17 -0
- package/dist/packages/method-package/user-methods.js +77 -0
- package/dist/packages/project-model/index.d.ts +1 -1
- package/dist/packages/project-model/index.js +1 -1
- package/dist/packages/project-model/interf-detect.d.ts +8 -3
- package/dist/packages/project-model/interf-detect.js +34 -34
- package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
- package/dist/packages/project-model/interf-scaffold.js +23 -32
- package/dist/packages/project-model/lib/schema.js +38 -1
- package/dist/packages/project-model/preparation-entries.d.ts +11 -0
- package/dist/packages/project-model/preparation-entries.js +49 -0
- package/dist/packages/project-model/source-config.d.ts +11 -10
- package/dist/packages/project-model/source-config.js +83 -44
- package/dist/packages/project-model/source-folders.d.ts +5 -5
- package/dist/packages/project-model/source-folders.js +14 -14
- package/dist/packages/shared/filesystem.d.ts +7 -0
- package/dist/packages/shared/filesystem.js +97 -10
- package/dist/packages/testing/lib/schema.d.ts +12 -13
- package/dist/packages/testing/lib/schema.js +4 -5
- package/dist/packages/testing/readiness-check-run.d.ts +7 -7
- package/dist/packages/testing/readiness-check-run.js +46 -51
- package/dist/packages/testing/test-execution.js +6 -6
- package/dist/packages/testing/test-paths.js +4 -3
- package/dist/packages/testing/test-sandbox.d.ts +0 -1
- package/dist/packages/testing/test-sandbox.js +14 -30
- package/dist/packages/testing/test-targets.d.ts +1 -1
- package/dist/packages/testing/test-targets.js +6 -6
- package/dist/packages/testing/test.d.ts +1 -1
- package/dist/packages/testing/test.js +1 -1
- package/package.json +6 -26
- package/LICENSE +0 -183
- package/dist/cli/commands/compile-controller.d.ts +0 -17
- package/dist/cli/commands/compiled-flow.d.ts +0 -25
- package/dist/cli/commands/compiled-flow.js +0 -112
- package/dist/cli/commands/control-path.d.ts +0 -11
- package/dist/cli/commands/control-path.js +0 -72
- package/dist/cli/commands/create-method-wizard.d.ts +0 -76
- package/dist/cli/commands/create-method-wizard.js +0 -465
- package/dist/cli/commands/create.d.ts +0 -8
- package/dist/cli/commands/create.js +0 -189
- package/dist/cli/commands/default.d.ts +0 -2
- package/dist/cli/commands/default.js +0 -39
- package/dist/cli/commands/executor-flow.d.ts +0 -29
- package/dist/cli/commands/executor-flow.js +0 -163
- package/dist/cli/commands/init.d.ts +0 -11
- package/dist/cli/commands/init.js +0 -784
- package/dist/cli/commands/list.d.ts +0 -2
- package/dist/cli/commands/list.js +0 -30
- package/dist/cli/commands/preparation-selection.d.ts +0 -6
- package/dist/cli/commands/preparation-selection.js +0 -11
- package/dist/cli/commands/source-config-wizard.d.ts +0 -52
- package/dist/cli/commands/source-config-wizard.js +0 -680
- package/dist/cli/commands/test-flow.d.ts +0 -58
- package/dist/cli/commands/test-flow.js +0 -231
- package/dist/cli/commands/verify.d.ts +0 -2
- package/dist/cli/commands/verify.js +0 -94
- package/dist/compiler-ui/_next/static/chunks/0d~8t0zm6545p.js +0 -118
- package/dist/compiler-ui/_next/static/chunks/0xnel.ax9a.2c.css +0 -3
- package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
- package/dist/packages/compiler/raw-snapshot.js +0 -101
- package/dist/packages/method-package/index.d.ts +0 -11
- package/dist/packages/method-package/index.js +0 -11
- package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
- package/dist/packages/method-package/method-stage-policy.js +0 -31
- package/dist/packages/project-model/project-paths.d.ts +0 -12
- package/dist/packages/project-model/project-paths.js +0 -33
- /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
- /package/dist/{cli/commands/check-draft.js → packages/local-service/readiness-check-draft.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
2
|
-
import { dirname, join, relative } from "node:path";
|
|
2
|
+
import { basename, dirname, join, relative } from "node:path";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { listFilesRecursive } from "../shared/filesystem.js";
|
|
5
5
|
import { warnInterf } from "../shared/logger.js";
|
|
@@ -7,10 +7,10 @@ import { readJsonFileUnchecked, readJsonFileWithSchema } from "../shared/parse.j
|
|
|
7
7
|
import { isMarkdownFile } from "../shared/file-types.js";
|
|
8
8
|
import { MethodCompilerApiSchema, RuntimeStageAcceptanceSchema, MethodPurposeSchema, MethodStageZoneAccessSchema, } from "../compiler/lib/schema.js";
|
|
9
9
|
import { RuntimeContractTypeSchema, InterfIdPattern, } from "../contracts/lib/schema.js";
|
|
10
|
+
import { asPreparationDataDir, preparationMethodsRoot, } from "../contracts/lib/preparation-paths.js";
|
|
10
11
|
import { listBuiltinCompiledZoneSpecs, } from "./builtin-compiled-method.js";
|
|
11
12
|
import { CONTEXT_INTERFACE_FILE, ContextInterfaceSchema, contextInterfaceExists, contextInterfaceFilePath, readContextInterface, MethodInputSpecSchema, writeContextInterface, } from "./context-interface.js";
|
|
12
13
|
import { PACKAGE_ROOT } from "./lib/package-root.js";
|
|
13
|
-
import { mergeStagePolicyNotesForStages } from "./method-stage-policy.js";
|
|
14
14
|
const LocalMethodStageDefinitionSchema = z.object({
|
|
15
15
|
id: z.string().regex(InterfIdPattern),
|
|
16
16
|
label: z.string().min(1),
|
|
@@ -32,14 +32,45 @@ const LocalMethodDefinitionSchema = z.object({
|
|
|
32
32
|
stages: z.array(LocalMethodStageDefinitionSchema).min(1).optional(),
|
|
33
33
|
stage_policy_notes: z.record(z.string(), z.array(z.string())).optional(),
|
|
34
34
|
});
|
|
35
|
-
function
|
|
36
|
-
|
|
35
|
+
function normalizeStagePolicyNotes(value) {
|
|
36
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
37
|
+
return undefined;
|
|
38
|
+
const normalized = {};
|
|
39
|
+
for (const [stageId, notes] of Object.entries(value)) {
|
|
40
|
+
if (!Array.isArray(notes))
|
|
41
|
+
continue;
|
|
42
|
+
const cleaned = Array.from(new Set(notes
|
|
43
|
+
.filter((note) => typeof note === "string")
|
|
44
|
+
.map((note) => note.trim())
|
|
45
|
+
.filter((note) => note.length > 0)));
|
|
46
|
+
if (cleaned.length > 0) {
|
|
47
|
+
normalized[stageId] = cleaned;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
37
51
|
}
|
|
38
|
-
function
|
|
52
|
+
export function mergeStagePolicyNotesForStages(stages, baseNotes, overrideNotes) {
|
|
53
|
+
const normalizedBase = normalizeStagePolicyNotes(baseNotes);
|
|
54
|
+
const merged = {};
|
|
55
|
+
for (const stage of stages) {
|
|
56
|
+
const combined = Array.from(new Set([
|
|
57
|
+
...(normalizedBase?.[stage.id] ?? []),
|
|
58
|
+
...((overrideNotes?.[stage.id] ?? []).map((note) => note.trim()).filter((note) => note.length > 0)),
|
|
59
|
+
]));
|
|
60
|
+
if (combined.length > 0) {
|
|
61
|
+
merged[stage.id] = combined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
65
|
+
}
|
|
66
|
+
function methodRootPath(prepDataDir) {
|
|
67
|
+
return preparationMethodsRoot(asPreparationDataDir(prepDataDir));
|
|
68
|
+
}
|
|
69
|
+
export function builtinMethodPackagePath(methodId) {
|
|
39
70
|
return join(PACKAGE_ROOT, "builtin-methods", methodId);
|
|
40
71
|
}
|
|
41
|
-
export function methodDefinitionPath(
|
|
42
|
-
return join(methodRootPath(
|
|
72
|
+
export function methodDefinitionPath(prepDataDir, id) {
|
|
73
|
+
return join(methodRootPath(prepDataDir), id);
|
|
43
74
|
}
|
|
44
75
|
function isSupportedMethodStarterDocPath(relativePath) {
|
|
45
76
|
if (relativePath === "README.md")
|
|
@@ -109,9 +140,9 @@ export function loadMethodDefinitionFromDir(dirPath) {
|
|
|
109
140
|
methodSchemaPath: contextInterfaceFilePath(dirPath),
|
|
110
141
|
};
|
|
111
142
|
}
|
|
112
|
-
export function listLocalMethodDefinitions(
|
|
143
|
+
export function listLocalMethodDefinitions(prepDataDir) {
|
|
113
144
|
const definitions = new Map();
|
|
114
|
-
const root = methodRootPath(
|
|
145
|
+
const root = methodRootPath(prepDataDir);
|
|
115
146
|
if (existsSync(root)) {
|
|
116
147
|
for (const entryPath of readdirSync(root).map((entry) => join(root, entry))) {
|
|
117
148
|
try {
|
|
@@ -128,25 +159,25 @@ export function listLocalMethodDefinitions(sourcePath) {
|
|
|
128
159
|
}
|
|
129
160
|
return [...definitions.values()].sort((a, b) => a.label.localeCompare(b.label));
|
|
130
161
|
}
|
|
131
|
-
export function loadLocalMethodDefinition(
|
|
132
|
-
return loadMethodDefinitionFromDir(methodDefinitionPath(
|
|
162
|
+
export function loadLocalMethodDefinition(prepDataDir, id) {
|
|
163
|
+
return loadMethodDefinitionFromDir(methodDefinitionPath(prepDataDir, id));
|
|
133
164
|
}
|
|
134
|
-
export function resolveMethodPackageSourcePath(
|
|
135
|
-
const localPath = methodDefinitionPath(
|
|
165
|
+
export function resolveMethodPackageSourcePath(prepDataDir, methodId) {
|
|
166
|
+
const localPath = methodDefinitionPath(prepDataDir, methodId);
|
|
136
167
|
if (loadMethodDefinitionFromDir(localPath))
|
|
137
168
|
return localPath;
|
|
138
|
-
const builtinPath =
|
|
169
|
+
const builtinPath = builtinMethodPackagePath(methodId);
|
|
139
170
|
if (loadMethodDefinitionFromDir(builtinPath))
|
|
140
171
|
return builtinPath;
|
|
141
172
|
return null;
|
|
142
173
|
}
|
|
143
174
|
export function seedLocalDefaultMethod(options) {
|
|
144
175
|
const methodId = "interf-default";
|
|
145
|
-
const targetPath = methodDefinitionPath(options.
|
|
176
|
+
const targetPath = methodDefinitionPath(options.prepDataDir, methodId);
|
|
146
177
|
if (existsSync(join(targetPath, "method.json"))) {
|
|
147
178
|
return { methodId, targetPath, alreadyExisted: true };
|
|
148
179
|
}
|
|
149
|
-
const builtinInterfPath =
|
|
180
|
+
const builtinInterfPath = builtinMethodPackagePath(methodId);
|
|
150
181
|
if (!existsSync(join(builtinInterfPath, "method.json"))) {
|
|
151
182
|
throw new Error(`Built-in "${methodId}" Method package not found at ${builtinInterfPath}.`);
|
|
152
183
|
}
|
|
@@ -169,7 +200,7 @@ function readMethodJsonObject(dirPath) {
|
|
|
169
200
|
}
|
|
170
201
|
return { ...raw };
|
|
171
202
|
}
|
|
172
|
-
export function patchMethodPackageMetadata(dirPath, options
|
|
203
|
+
export function patchMethodPackageMetadata(dirPath, options) {
|
|
173
204
|
const methodPath = join(dirPath, "method.json");
|
|
174
205
|
const methodJson = readMethodJsonObject(dirPath);
|
|
175
206
|
const normalizedStages = Array.isArray(methodJson.stages) && methodJson.stages.length > 0
|
|
@@ -209,6 +240,11 @@ export function patchMethodPackageMetadata(dirPath, options = {}) {
|
|
|
209
240
|
label: schemaLabel,
|
|
210
241
|
});
|
|
211
242
|
}
|
|
243
|
+
function resolveStageSkillDir(stage) {
|
|
244
|
+
return typeof stage.skill_dir === "string" && stage.skill_dir.trim().length > 0
|
|
245
|
+
? stage.skill_dir
|
|
246
|
+
: stage.id;
|
|
247
|
+
}
|
|
212
248
|
function collectMethodPackageStructureIssues(dirPath, stages) {
|
|
213
249
|
const issues = [];
|
|
214
250
|
const methodPath = join(dirPath, "method.json");
|
|
@@ -225,23 +261,7 @@ function collectMethodPackageStructureIssues(dirPath, stages) {
|
|
|
225
261
|
if (!stages)
|
|
226
262
|
return issues;
|
|
227
263
|
for (const stage of stages) {
|
|
228
|
-
const skillDir =
|
|
229
|
-
? stage.skill_dir
|
|
230
|
-
: stage.id;
|
|
231
|
-
if (!existsSync(join(dirPath, "compile", "stages", skillDir, "SKILL.md"))) {
|
|
232
|
-
issues.push(`missing compile/stages/${skillDir}/SKILL.md`);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return issues;
|
|
236
|
-
}
|
|
237
|
-
function collectMethodStageSkillIssues(dirPath, stages) {
|
|
238
|
-
if (!stages)
|
|
239
|
-
return [];
|
|
240
|
-
const issues = [];
|
|
241
|
-
for (const stage of stages) {
|
|
242
|
-
const skillDir = typeof stage.skill_dir === "string" && stage.skill_dir.trim().length > 0
|
|
243
|
-
? stage.skill_dir
|
|
244
|
-
: stage.id;
|
|
264
|
+
const skillDir = resolveStageSkillDir(stage);
|
|
245
265
|
if (!existsSync(join(dirPath, "compile", "stages", skillDir, "SKILL.md"))) {
|
|
246
266
|
issues.push(`missing compile/stages/${skillDir}/SKILL.md`);
|
|
247
267
|
}
|
|
@@ -271,9 +291,10 @@ export function describeMethodPackagePortability(dirPath) {
|
|
|
271
291
|
issues.push("method.json must declare explicit stages for a portable Method package");
|
|
272
292
|
return issues;
|
|
273
293
|
}
|
|
294
|
+
// Structural issues already returned earlier; only stage-skill files can be missing now.
|
|
274
295
|
return [
|
|
275
296
|
...issues,
|
|
276
|
-
...
|
|
297
|
+
...collectMethodPackageStructureIssues(dirPath, parsed.data.stages ?? null),
|
|
277
298
|
];
|
|
278
299
|
}
|
|
279
300
|
export function isPortableMethodPackage(dirPath) {
|
|
@@ -413,7 +434,7 @@ export function validateMethodPackage(dirPath) {
|
|
|
413
434
|
}
|
|
414
435
|
}
|
|
415
436
|
}
|
|
416
|
-
for (const requiredZone of listBuiltinCompiledZoneSpecs().filter((zone) => zone.id === "
|
|
437
|
+
for (const requiredZone of listBuiltinCompiledZoneSpecs().filter((zone) => zone.id === "runtime")) {
|
|
417
438
|
const match = zoneById.get(requiredZone.id);
|
|
418
439
|
if (!match) {
|
|
419
440
|
errors.push(`method.schema.json is missing required zone "${requiredZone.id}".`);
|
|
@@ -461,6 +482,3 @@ function describeContextInterfaceValidationIssues(dirPath) {
|
|
|
461
482
|
return `method.schema.json ${path}: ${issue.message}`;
|
|
462
483
|
});
|
|
463
484
|
}
|
|
464
|
-
function basename(filePath) {
|
|
465
|
-
return filePath.split(/[\\/]/).pop() ?? filePath;
|
|
466
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LocalMethodDefinition } from "./local-methods.js";
|
|
1
2
|
import type { RuntimeStageAcceptance, MethodCompilerApi } from "../compiler/lib/schema.js";
|
|
2
3
|
import type { MethodId, RuntimeContractType } from "../contracts/lib/schema.js";
|
|
3
4
|
import { type ContextInterface, type ContextInterfaceZoneId, type MethodInputSpec } from "./context-interface.js";
|
|
@@ -31,53 +32,26 @@ export interface MethodDefinition<TId extends string> {
|
|
|
31
32
|
stages: MethodStageDefinition[];
|
|
32
33
|
stagePolicyNotes?: Record<string, string[]>;
|
|
33
34
|
starterDocs?: MethodStarterDoc[];
|
|
34
|
-
scope?: "builtin" | "local";
|
|
35
|
+
scope?: "builtin" | "user" | "local";
|
|
35
36
|
}
|
|
36
37
|
export type CompiledMethodId = string;
|
|
37
|
-
export declare function standaloneMethodDefinitionFromLocalPackage(local:
|
|
38
|
-
|
|
39
|
-
compiler_api?: MethodCompilerApi;
|
|
40
|
-
purpose?: {
|
|
41
|
-
label: string;
|
|
42
|
-
task_hint: string;
|
|
43
|
-
};
|
|
44
|
-
inputs?: MethodInputSpec[];
|
|
45
|
-
label: string;
|
|
46
|
-
hint: string;
|
|
47
|
-
stages?: Array<{
|
|
48
|
-
id: string;
|
|
49
|
-
label: string;
|
|
50
|
-
description?: string;
|
|
51
|
-
contract_type: RuntimeContractType;
|
|
52
|
-
skill_dir?: string;
|
|
53
|
-
reads: ContextInterfaceZoneId[];
|
|
54
|
-
writes: ContextInterfaceZoneId[];
|
|
55
|
-
acceptance?: RuntimeStageAcceptance;
|
|
56
|
-
}>;
|
|
57
|
-
stage_policy_notes?: Record<string, string[]>;
|
|
58
|
-
method_schema?: ContextInterface;
|
|
59
|
-
starter_docs: MethodStarterDoc[];
|
|
60
|
-
}): MethodDefinition<string>;
|
|
61
|
-
export declare function listCompiledMethodChoices(sourcePath?: string): MethodDefinition<string>[];
|
|
38
|
+
export declare function standaloneMethodDefinitionFromLocalPackage(local: LocalMethodDefinition): MethodDefinition<string>;
|
|
39
|
+
export declare function listCompiledMethodChoices(prepDataDir?: string): MethodDefinition<string>[];
|
|
62
40
|
export declare function getCompiledMethod(methodId: CompiledMethodId, options?: {
|
|
63
|
-
|
|
41
|
+
prepDataDir?: string;
|
|
64
42
|
}): MethodDefinition<string>;
|
|
65
43
|
export declare function getActiveCompiledMethod(compiledPath: string): MethodDefinition<string>;
|
|
66
44
|
export declare function resolveCompiledMethodId(value: unknown): CompiledMethodId | null;
|
|
67
45
|
export declare function resolveCompiledMethodFromConfig(config: unknown): CompiledMethodId | null;
|
|
68
46
|
export declare function resolveRequiredCompiledMethodFromConfig(config: unknown, label?: string): CompiledMethodId;
|
|
69
|
-
export declare function
|
|
70
|
-
|
|
71
|
-
}): string;
|
|
72
|
-
export declare function getMethodStageDefinition(methodId: MethodId, stage: string, sourcePath?: string): MethodStageDefinition | null;
|
|
73
|
-
export declare function getMethodStagePosition(methodId: MethodId, stage: string, sourcePath?: string): {
|
|
47
|
+
export declare function getMethodStageDefinition(methodId: MethodId, stage: string, prepDataDir?: string): MethodStageDefinition | null;
|
|
48
|
+
export declare function getMethodStagePosition(methodId: MethodId, stage: string, prepDataDir?: string): {
|
|
74
49
|
stageIndex: number;
|
|
75
50
|
stageTotal: number;
|
|
76
51
|
stages: string[];
|
|
77
52
|
} | null;
|
|
78
|
-
export declare function getMethodStages(methodId: MethodId,
|
|
53
|
+
export declare function getMethodStages(methodId: MethodId, prepDataDir?: string): string[];
|
|
79
54
|
export declare function getActiveCompiledStages(compiledPath: string): string[];
|
|
80
|
-
export declare function getMethodStagePolicyNotes(methodId: MethodId, stage: string, sourcePath?: string): string[];
|
|
81
55
|
export declare function getActiveCompiledStagePolicyNotes(compiledPath: string, stage: string): string[];
|
|
82
56
|
export declare function resolveActiveCompiledStageAcceptance(compiledPath: string, stage: string): MethodStageDefinition["acceptance"] | undefined;
|
|
83
57
|
export declare function formatActiveCompiledMethodStageStep(compiledPath: string, stage: string): string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { isMethodId, listLocalMethodDefinitions, loadLocalMethodDefinition, loadMethodDefinitionFromDir, } from "./local-methods.js";
|
|
3
|
+
import { builtinMethodPackagePath, isMethodId, listLocalMethodDefinitions, loadLocalMethodDefinition, loadMethodDefinitionFromDir, mergeStagePolicyNotesForStages, } from "./local-methods.js";
|
|
4
|
+
import { listUserMethodDefinitions, loadUserMethodDefinition, } from "./user-methods.js";
|
|
4
5
|
import { warnInterf } from "../shared/logger.js";
|
|
5
6
|
import { methodPackagePathForCompiled } from "../compiler/compiled-paths.js";
|
|
7
|
+
import { asPreparationDataDir, preparationMethodPackagePath } from "../contracts/lib/preparation-paths.js";
|
|
6
8
|
import { resolveSourceControlPath } from "../project-model/interf.js";
|
|
7
|
-
import { PACKAGE_ROOT } from "./lib/package-root.js";
|
|
8
9
|
import { deriveMethodInputsFromContextInterface, } from "./context-interface.js";
|
|
9
|
-
import { mergeStagePolicyNotesForStages } from "./method-stage-policy.js";
|
|
10
10
|
const DEFAULT_METHOD_ID = "interf-default";
|
|
11
11
|
let builtinDefaultMethodCache = null;
|
|
12
12
|
function toMethodStages(stages) {
|
|
@@ -56,9 +56,6 @@ export function standaloneMethodDefinitionFromLocalPackage(local) {
|
|
|
56
56
|
scope: "local",
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function builtinMethodPackagePath(methodId) {
|
|
60
|
-
return join(PACKAGE_ROOT, "builtin-methods", methodId);
|
|
61
|
-
}
|
|
62
59
|
function getBuiltinDefaultMethod() {
|
|
63
60
|
if (builtinDefaultMethodCache)
|
|
64
61
|
return builtinDefaultMethodCache;
|
|
@@ -78,24 +75,41 @@ function getBuiltinDefaultMethod() {
|
|
|
78
75
|
function listBuiltinCompiledMethods() {
|
|
79
76
|
return [getBuiltinDefaultMethod()];
|
|
80
77
|
}
|
|
81
|
-
function resolveCompiledMethodFromLocal(methodId,
|
|
82
|
-
const local = loadLocalMethodDefinition(
|
|
78
|
+
function resolveCompiledMethodFromLocal(methodId, prepDataDir) {
|
|
79
|
+
const local = loadLocalMethodDefinition(prepDataDir, methodId);
|
|
83
80
|
if (!local)
|
|
84
81
|
return null;
|
|
85
82
|
const resolved = standaloneMethodDefinitionFromLocalPackage(local);
|
|
86
83
|
return resolved;
|
|
87
84
|
}
|
|
88
|
-
|
|
85
|
+
function resolveCompiledMethodFromUserLibrary(methodId) {
|
|
86
|
+
const user = loadUserMethodDefinition(methodId);
|
|
87
|
+
if (!user)
|
|
88
|
+
return null;
|
|
89
|
+
const resolved = standaloneMethodDefinitionFromLocalPackage(user);
|
|
90
|
+
return { ...resolved, scope: "user" };
|
|
91
|
+
}
|
|
92
|
+
export function listCompiledMethodChoices(prepDataDir) {
|
|
89
93
|
const builtins = listBuiltinCompiledMethods();
|
|
90
|
-
if (!sourcePath)
|
|
91
|
-
return builtins;
|
|
92
94
|
const methodsById = new Map();
|
|
93
95
|
for (const method of builtins) {
|
|
94
96
|
methodsById.set(method.id, method);
|
|
95
97
|
}
|
|
96
|
-
for (const definition of
|
|
98
|
+
for (const definition of listUserMethodDefinitions()) {
|
|
99
|
+
try {
|
|
100
|
+
const method = resolveCompiledMethodFromUserLibrary(definition.id);
|
|
101
|
+
if (method)
|
|
102
|
+
methodsById.set(method.id, method);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
warnInterf(`Warning: skipping user Method "${definition.id}" because it could not be resolved cleanly: ${error instanceof Error ? error.message : String(error)}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!prepDataDir)
|
|
109
|
+
return [...methodsById.values()];
|
|
110
|
+
for (const definition of listLocalMethodDefinitions(prepDataDir)) {
|
|
97
111
|
try {
|
|
98
|
-
const method = resolveCompiledMethodFromLocal(definition.id,
|
|
112
|
+
const method = resolveCompiledMethodFromLocal(definition.id, prepDataDir);
|
|
99
113
|
if (method)
|
|
100
114
|
methodsById.set(method.id, method);
|
|
101
115
|
}
|
|
@@ -106,16 +120,21 @@ export function listCompiledMethodChoices(sourcePath) {
|
|
|
106
120
|
return [...methodsById.values()];
|
|
107
121
|
}
|
|
108
122
|
export function getCompiledMethod(methodId, options = {}) {
|
|
123
|
+
if (options.prepDataDir) {
|
|
124
|
+
const local = resolveCompiledMethodFromLocal(methodId, options.prepDataDir);
|
|
125
|
+
if (local)
|
|
126
|
+
return local;
|
|
127
|
+
}
|
|
128
|
+
const user = resolveCompiledMethodFromUserLibrary(methodId);
|
|
129
|
+
if (user)
|
|
130
|
+
return user;
|
|
109
131
|
const builtin = listBuiltinCompiledMethods().find((candidate) => candidate.id === methodId);
|
|
110
132
|
if (builtin)
|
|
111
133
|
return builtin;
|
|
112
|
-
if (options.
|
|
113
|
-
|
|
114
|
-
if (local)
|
|
115
|
-
return local;
|
|
116
|
-
throw new Error(`No local Method package found for "${methodId}" under ${join(options.sourcePath, "interf", "methods", methodId)}.`);
|
|
134
|
+
if (options.prepDataDir) {
|
|
135
|
+
throw new Error(`No Method "${methodId}" found in this workspace, in your user library, or among bundled Methods. Looked under ${preparationMethodPackagePath(asPreparationDataDir(options.prepDataDir), methodId)} and ~/.interf/methods/${methodId}.`);
|
|
117
136
|
}
|
|
118
|
-
throw new Error(`Method "${methodId}" is not built-in
|
|
137
|
+
throw new Error(`Method "${methodId}" is not built-in and no workspace root was provided to look for a local override.`);
|
|
119
138
|
}
|
|
120
139
|
export function getActiveCompiledMethod(compiledPath) {
|
|
121
140
|
const methodPath = methodPackagePathForCompiled(compiledPath);
|
|
@@ -147,15 +166,12 @@ export function resolveRequiredCompiledMethodFromConfig(config, label = "compile
|
|
|
147
166
|
}
|
|
148
167
|
return methodId;
|
|
149
168
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (sourcePath &&
|
|
155
|
-
existsSync(join(methodPackagePathForCompiled(sourcePath), "method.json"))) {
|
|
156
|
-
return getActiveCompiledMethod(sourcePath);
|
|
169
|
+
function resolveMethodDefinitionForStageMetadata(methodId, prepDataDir) {
|
|
170
|
+
if (prepDataDir &&
|
|
171
|
+
existsSync(join(methodPackagePathForCompiled(prepDataDir), "method.json"))) {
|
|
172
|
+
return getActiveCompiledMethod(prepDataDir);
|
|
157
173
|
}
|
|
158
|
-
return getCompiledMethod(methodId, {
|
|
174
|
+
return getCompiledMethod(methodId, { prepDataDir });
|
|
159
175
|
}
|
|
160
176
|
function formatMethodStageStep(method, stage) {
|
|
161
177
|
const stageIndex = method.stages.findIndex((candidate) => candidate.id === stage);
|
|
@@ -168,12 +184,12 @@ function formatMethodStageStep(method, stage) {
|
|
|
168
184
|
}
|
|
169
185
|
return `Stage ${stageIndex + 1}/${method.stages.length} - ${stageDefinition.label}`;
|
|
170
186
|
}
|
|
171
|
-
export function getMethodStageDefinition(methodId, stage,
|
|
172
|
-
const method = resolveMethodDefinitionForStageMetadata(methodId,
|
|
187
|
+
export function getMethodStageDefinition(methodId, stage, prepDataDir) {
|
|
188
|
+
const method = resolveMethodDefinitionForStageMetadata(methodId, prepDataDir);
|
|
173
189
|
return method.stages.find((candidate) => candidate.id === stage) ?? null;
|
|
174
190
|
}
|
|
175
|
-
export function getMethodStagePosition(methodId, stage,
|
|
176
|
-
const stages = getMethodStages(methodId,
|
|
191
|
+
export function getMethodStagePosition(methodId, stage, prepDataDir) {
|
|
192
|
+
const stages = getMethodStages(methodId, prepDataDir);
|
|
177
193
|
const stageIndex = stages.findIndex((candidate) => candidate === stage);
|
|
178
194
|
if (stageIndex === -1)
|
|
179
195
|
return null;
|
|
@@ -183,16 +199,12 @@ export function getMethodStagePosition(methodId, stage, sourcePath) {
|
|
|
183
199
|
stages: [...stages],
|
|
184
200
|
};
|
|
185
201
|
}
|
|
186
|
-
export function getMethodStages(methodId,
|
|
187
|
-
return resolveMethodDefinitionForStageMetadata(methodId,
|
|
202
|
+
export function getMethodStages(methodId, prepDataDir) {
|
|
203
|
+
return resolveMethodDefinitionForStageMetadata(methodId, prepDataDir).stages.map((definition) => definition.id);
|
|
188
204
|
}
|
|
189
205
|
export function getActiveCompiledStages(compiledPath) {
|
|
190
206
|
return getActiveCompiledMethod(compiledPath).stages.map((definition) => definition.id);
|
|
191
207
|
}
|
|
192
|
-
export function getMethodStagePolicyNotes(methodId, stage, sourcePath) {
|
|
193
|
-
const method = resolveMethodDefinitionForStageMetadata(methodId, sourcePath);
|
|
194
|
-
return [...(method.stagePolicyNotes?.[stage] ?? [])];
|
|
195
|
-
}
|
|
196
208
|
export function getActiveCompiledStagePolicyNotes(compiledPath, stage) {
|
|
197
209
|
const method = getActiveCompiledMethod(compiledPath);
|
|
198
210
|
return [...(method.stagePolicyNotes?.[stage] ?? [])];
|
|
@@ -9,8 +9,6 @@ export interface MethodStageResult {
|
|
|
9
9
|
code: number;
|
|
10
10
|
summary?: string | null;
|
|
11
11
|
}
|
|
12
|
-
export declare function methodQueryDirectory(): string;
|
|
13
|
-
export declare function methodImproveDirectory(): string;
|
|
14
12
|
export declare function methodCompileStageDirectory(stageDir: string): string;
|
|
15
13
|
export interface LocalSkillContractExtension {
|
|
16
14
|
reads: string[];
|
|
@@ -20,19 +18,9 @@ export interface LocalSkillContractExtension {
|
|
|
20
18
|
effectiveMode: RuntimeInstructionMode;
|
|
21
19
|
modeSources: string[];
|
|
22
20
|
}
|
|
23
|
-
export declare function emptyLocalSkillContractExtension(): LocalSkillContractExtension;
|
|
24
21
|
export declare function buildLocalSkillContractExtension(rootPath: string, directories: string[], purpose: string): LocalSkillContractExtension;
|
|
25
|
-
export declare function buildLocalSkillContractExtensionRelativeTo(rootPath: string, relativeToPath: string, directories: string[], purpose: string): LocalSkillContractExtension;
|
|
26
|
-
export declare function mergeLocalSkillContractExtensions(extensions: LocalSkillContractExtension[]): LocalSkillContractExtension;
|
|
27
22
|
export declare function buildStageInstructions(stageSkillDir: string, localSkills: LocalSkillContractExtension): RuntimeStageInstructions;
|
|
28
23
|
export declare function reportLine(reporter: MethodReporter | undefined, message: string): void;
|
|
29
24
|
export declare function reportBlankLine(reporter: MethodReporter | undefined): void;
|
|
30
25
|
export declare function reportValidationFailure(reporter: MethodReporter | undefined, summary: string, errors?: string[]): void;
|
|
31
|
-
export declare function resolveStageAcceptance(methodId: string, stageId: string,
|
|
32
|
-
export declare function validateStageOutcome(_dirPath: string, validation: {
|
|
33
|
-
ok: boolean;
|
|
34
|
-
summary: string;
|
|
35
|
-
}): {
|
|
36
|
-
ok: boolean;
|
|
37
|
-
summary: string;
|
|
38
|
-
};
|
|
26
|
+
export declare function resolveStageAcceptance(methodId: string, stageId: string, prepDataDir?: string): MethodStageDefinition["acceptance"] | undefined;
|
|
@@ -6,16 +6,10 @@ import { isMarkdownFile } from "../shared/file-types.js";
|
|
|
6
6
|
import { getCompiledMethod, } from "./method-definitions.js";
|
|
7
7
|
import { COMPILED_METHOD_DIR, methodPackagePathForCompiled } from "../compiler/compiled-paths.js";
|
|
8
8
|
const LOCAL_SKILL_READ_LIMIT = 50;
|
|
9
|
-
export function methodQueryDirectory() {
|
|
10
|
-
return `${COMPILED_METHOD_DIR}/use/query`;
|
|
11
|
-
}
|
|
12
|
-
export function methodImproveDirectory() {
|
|
13
|
-
return `${COMPILED_METHOD_DIR}/improve`;
|
|
14
|
-
}
|
|
15
9
|
export function methodCompileStageDirectory(stageDir) {
|
|
16
10
|
return `${COMPILED_METHOD_DIR}/compile/stages/${stageDir}`;
|
|
17
11
|
}
|
|
18
|
-
|
|
12
|
+
function emptyLocalSkillContractExtension() {
|
|
19
13
|
return {
|
|
20
14
|
reads: [],
|
|
21
15
|
count: 0,
|
|
@@ -36,14 +30,11 @@ function readLocalInstructionMode(filePath) {
|
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
32
|
function collectLocalSkillDocs(rootPath, directories) {
|
|
39
|
-
return collectLocalSkillDocsRelativeTo(rootPath, rootPath, directories);
|
|
40
|
-
}
|
|
41
|
-
function collectLocalSkillDocsRelativeTo(rootPath, relativeToPath, directories) {
|
|
42
33
|
const docs = new Map();
|
|
43
34
|
const methodRoot = methodPackagePathForCompiled(rootPath);
|
|
44
35
|
const rootReadme = join(methodRoot, "README.md");
|
|
45
36
|
if (existsSync(rootReadme)) {
|
|
46
|
-
const read = projectMethodReadPath(rootPath,
|
|
37
|
+
const read = projectMethodReadPath(rootPath, rootReadme);
|
|
47
38
|
docs.set(read, {
|
|
48
39
|
read,
|
|
49
40
|
absolutePath: rootReadme,
|
|
@@ -53,7 +44,7 @@ function collectLocalSkillDocsRelativeTo(rootPath, relativeToPath, directories)
|
|
|
53
44
|
for (const directory of directories) {
|
|
54
45
|
const absoluteDirectory = resolveAuthoringDirectory(rootPath, directory);
|
|
55
46
|
for (const filePath of listFilesRecursive(absoluteDirectory, isMarkdownFile)) {
|
|
56
|
-
const read = projectMethodReadPath(rootPath,
|
|
47
|
+
const read = projectMethodReadPath(rootPath, filePath);
|
|
57
48
|
docs.set(read, {
|
|
58
49
|
read,
|
|
59
50
|
absolutePath: filePath,
|
|
@@ -75,23 +66,19 @@ function resolveAuthoringDirectory(rootPath, directory) {
|
|
|
75
66
|
}
|
|
76
67
|
return join(rootPath, directory);
|
|
77
68
|
}
|
|
78
|
-
function projectMethodReadPath(rootPath,
|
|
69
|
+
function projectMethodReadPath(rootPath, absolutePath) {
|
|
79
70
|
const methodRoot = methodPackagePathForCompiled(rootPath);
|
|
80
71
|
const normalizedMethodRoot = `${methodRoot}${sep}`;
|
|
81
72
|
if (absolutePath === methodRoot || absolutePath.startsWith(normalizedMethodRoot)) {
|
|
82
73
|
const relativeMethodPath = relative(methodRoot, absolutePath);
|
|
83
|
-
return relative(
|
|
74
|
+
return relative(rootPath, join(rootPath, COMPILED_METHOD_DIR, relativeMethodPath));
|
|
84
75
|
}
|
|
85
|
-
return relative(
|
|
76
|
+
return relative(rootPath, absolutePath);
|
|
86
77
|
}
|
|
87
78
|
export function buildLocalSkillContractExtension(rootPath, directories, purpose) {
|
|
88
79
|
const docs = collectLocalSkillDocs(rootPath, directories);
|
|
89
80
|
return buildContractExtensionFromDocs(docs, directories, purpose);
|
|
90
81
|
}
|
|
91
|
-
export function buildLocalSkillContractExtensionRelativeTo(rootPath, relativeToPath, directories, purpose) {
|
|
92
|
-
const docs = collectLocalSkillDocsRelativeTo(rootPath, relativeToPath, directories);
|
|
93
|
-
return buildContractExtensionFromDocs(docs, directories, purpose);
|
|
94
|
-
}
|
|
95
82
|
function buildContractExtensionFromDocs(docs, directories, purpose) {
|
|
96
83
|
const reads = docs.map((doc) => doc.read);
|
|
97
84
|
const modeSources = docs.filter((doc) => doc.mode !== null).map((doc) => doc.read);
|
|
@@ -120,24 +107,6 @@ function buildContractExtensionFromDocs(docs, directories, purpose) {
|
|
|
120
107
|
modeSources,
|
|
121
108
|
};
|
|
122
109
|
}
|
|
123
|
-
export function mergeLocalSkillContractExtensions(extensions) {
|
|
124
|
-
const reads = Array.from(new Set(extensions.flatMap((extension) => extension.reads)));
|
|
125
|
-
const notes = Array.from(new Set(extensions.flatMap((extension) => extension.notes)));
|
|
126
|
-
const modeSources = Array.from(new Set(extensions.flatMap((extension) => extension.modeSources)));
|
|
127
|
-
const localMode = extensions.some((extension) => extension.localMode === "override")
|
|
128
|
-
? "override"
|
|
129
|
-
: extensions.some((extension) => extension.localMode === "extend")
|
|
130
|
-
? "extend"
|
|
131
|
-
: null;
|
|
132
|
-
return {
|
|
133
|
-
reads,
|
|
134
|
-
count: reads.length,
|
|
135
|
-
notes,
|
|
136
|
-
localMode,
|
|
137
|
-
effectiveMode: localMode ?? "builtin",
|
|
138
|
-
modeSources,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
110
|
export function buildStageInstructions(stageSkillDir, localSkills) {
|
|
142
111
|
return {
|
|
143
112
|
stage_skill_dir: stageSkillDir,
|
|
@@ -159,9 +128,6 @@ export function reportValidationFailure(reporter, summary, errors = []) {
|
|
|
159
128
|
reportLine(reporter, `- ${error}`);
|
|
160
129
|
}
|
|
161
130
|
}
|
|
162
|
-
export function resolveStageAcceptance(methodId, stageId,
|
|
163
|
-
return getCompiledMethod(methodId, {
|
|
164
|
-
}
|
|
165
|
-
export function validateStageOutcome(_dirPath, validation) {
|
|
166
|
-
return validation;
|
|
131
|
+
export function resolveStageAcceptance(methodId, stageId, prepDataDir) {
|
|
132
|
+
return getCompiledMethod(methodId, { prepDataDir }).stages.find((stage) => stage.id === stageId)?.acceptance;
|
|
167
133
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MethodImprovementContext } from "../compiler/lib/schema.js";
|
|
2
2
|
export interface MethodImprovementReviewSourcePaths {
|
|
3
3
|
compiledRuntime: string | null;
|
|
4
|
-
|
|
4
|
+
readinessRuns: string | null;
|
|
5
5
|
executionShells: string | null;
|
|
6
6
|
targetTestRuns: string | null;
|
|
7
7
|
targetTestSandboxes: string | null;
|
|
@@ -3,15 +3,15 @@ import { join } from "node:path";
|
|
|
3
3
|
import { testRootForCompiled, targetTestRunsRootForCompiled, targetTestSandboxesRootForCompiled, stageExecutionShellsRoot, compiledRuntimeRoot, } from "../compiler/compiled-paths.js";
|
|
4
4
|
export function resolveMethodImprovementReviewSourcePaths(compiledPath) {
|
|
5
5
|
const compiledRuntime = compiledRuntimeRoot(compiledPath);
|
|
6
|
-
const
|
|
6
|
+
const readinessRuns = testRootForCompiled(compiledPath);
|
|
7
7
|
const executionShells = stageExecutionShellsRoot(compiledPath);
|
|
8
8
|
const targetTestRuns = targetTestRunsRootForCompiled(compiledPath);
|
|
9
9
|
const targetTestSandboxes = targetTestSandboxesRootForCompiled(compiledPath);
|
|
10
10
|
return {
|
|
11
11
|
compiledRuntime: existsSync(compiledRuntime) ? compiledRuntime : null,
|
|
12
|
-
|
|
13
|
-
existsSync(join(
|
|
14
|
-
?
|
|
12
|
+
readinessRuns: existsSync(join(readinessRuns, "latest.json")) ||
|
|
13
|
+
existsSync(join(readinessRuns, "latest.md"))
|
|
14
|
+
? readinessRuns
|
|
15
15
|
: null,
|
|
16
16
|
executionShells: existsSync(executionShells) ? executionShells : null,
|
|
17
17
|
targetTestRuns: existsSync(targetTestRuns) ? targetTestRuns : null,
|
|
@@ -23,7 +23,7 @@ export function resolveMethodImprovementReviewPaths(compiledPath) {
|
|
|
23
23
|
return {
|
|
24
24
|
method_root: "method",
|
|
25
25
|
compiled_runtime: sources.compiledRuntime ? "artifacts/compiled-runtime" : null,
|
|
26
|
-
|
|
26
|
+
readiness_runs: sources.readinessRuns ? "artifacts/readiness-runs" : null,
|
|
27
27
|
execution_shells: sources.executionShells ? "artifacts/execution-shells" : null,
|
|
28
28
|
test_runs: sources.targetTestRuns ? "artifacts/test-runs" : null,
|
|
29
29
|
test_sandboxes: sources.targetTestSandboxes ? "artifacts/test-sandboxes" : null,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { markRuntimeRunSucceededAfterValidation, buildStagePrompt, markRuntimeRunFailedAfterValidation, runExecutorStage, runExecutorSummarizeStage, } from "../compiler/runtime.js";
|
|
2
|
-
import { reportValidationFailure,
|
|
2
|
+
import { reportValidationFailure, } from "./method-helpers.js";
|
|
3
3
|
export function findStageByContractType(stages, contractType) {
|
|
4
4
|
const stage = stages.find((candidate) => candidate.contractType === contractType);
|
|
5
5
|
if (!stage) {
|
|
@@ -66,7 +66,7 @@ function finalizeValidatedStage(options, code) {
|
|
|
66
66
|
options.syncWrites?.();
|
|
67
67
|
options.reconcile?.();
|
|
68
68
|
options.refreshArtifacts?.();
|
|
69
|
-
return
|
|
69
|
+
return options.validate();
|
|
70
70
|
};
|
|
71
71
|
if (code !== 0) {
|
|
72
72
|
let completionSatisfied = false;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type LocalMethodDefinition } from "./local-methods.js";
|
|
2
|
+
export declare function userMethodPath(id: string): string;
|
|
3
|
+
export declare function userMethodExists(id: string): boolean;
|
|
4
|
+
export declare function listUserMethodDefinitions(): LocalMethodDefinition[];
|
|
5
|
+
export declare function loadUserMethodDefinition(id: string): LocalMethodDefinition | null;
|
|
6
|
+
export interface InstallUserMethodOptions {
|
|
7
|
+
sourceDir: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
overwrite?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface InstallUserMethodResult {
|
|
12
|
+
id: string;
|
|
13
|
+
path: string;
|
|
14
|
+
overwritten: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function installUserMethod(options: InstallUserMethodOptions): InstallUserMethodResult;
|
|
17
|
+
export declare function removeUserMethod(id: string): boolean;
|