@interf/compiler 0.4.0 → 0.5.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 +71 -69
- package/builtin-workflows/interf/README.md +6 -6
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
- package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
- package/builtin-workflows/interf/improve/SKILL.md +3 -3
- package/builtin-workflows/interf/use/query/SKILL.md +2 -2
- package/builtin-workflows/interf/workflow.json +42 -31
- package/dist/commands/check-draft.d.ts +19 -0
- package/dist/commands/check-draft.js +110 -0
- package/dist/commands/compile-controller.d.ts +4 -4
- package/dist/commands/compile-controller.js +117 -81
- package/dist/commands/compile.d.ts +5 -5
- package/dist/commands/compile.js +61 -62
- package/dist/commands/compiled-flow.d.ts +23 -0
- package/dist/commands/compiled-flow.js +112 -0
- package/dist/commands/create-workflow-wizard.d.ts +3 -3
- package/dist/commands/create-workflow-wizard.js +11 -11
- package/dist/commands/create.d.ts +2 -2
- package/dist/commands/create.js +50 -57
- package/dist/commands/default.js +2 -2
- package/dist/commands/executor-flow.d.ts +20 -1
- package/dist/commands/executor-flow.js +67 -7
- package/dist/commands/init.js +242 -289
- package/dist/commands/list.js +14 -10
- package/dist/commands/reset.js +6 -6
- package/dist/commands/source-config-wizard.d.ts +12 -8
- package/dist/commands/source-config-wizard.js +356 -119
- package/dist/commands/status.js +49 -26
- package/dist/commands/test-flow.d.ts +23 -10
- package/dist/commands/test-flow.js +278 -58
- package/dist/commands/test.d.ts +7 -1
- package/dist/commands/test.js +264 -65
- package/dist/commands/verify.js +23 -14
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -4
- package/dist/lib/agent-args.js +2 -1
- package/dist/lib/agent-constants.js +1 -1
- package/dist/lib/agent-render.js +4 -4
- package/dist/lib/agent-shells.d.ts +8 -8
- package/dist/lib/agent-shells.js +231 -142
- package/dist/lib/compiled-compile.d.ts +52 -0
- package/dist/lib/compiled-compile.js +274 -0
- package/dist/lib/compiled-home.d.ts +5 -0
- package/dist/lib/compiled-home.js +32 -0
- package/dist/lib/compiled-layout.d.ts +2 -0
- package/dist/lib/compiled-layout.js +60 -0
- package/dist/lib/compiled-paths.d.ts +41 -0
- package/dist/lib/compiled-paths.js +111 -0
- package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
- package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
- package/dist/lib/compiled-reset.d.ts +1 -0
- package/dist/lib/compiled-reset.js +44 -0
- package/dist/lib/compiled-schema.d.ts +27 -0
- package/dist/lib/compiled-schema.js +110 -0
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +0 -1
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.js +3 -3
- package/dist/lib/interf-bootstrap.d.ts +1 -1
- package/dist/lib/interf-bootstrap.js +4 -4
- package/dist/lib/interf-detect.d.ts +10 -10
- package/dist/lib/interf-detect.js +78 -56
- package/dist/lib/interf-scaffold.d.ts +2 -2
- package/dist/lib/interf-scaffold.js +90 -57
- package/dist/lib/interf-workflow-package.d.ts +3 -3
- package/dist/lib/interf-workflow-package.js +30 -30
- package/dist/lib/interf.d.ts +5 -5
- package/dist/lib/interf.js +4 -4
- package/dist/lib/local-workflows.d.ts +4 -4
- package/dist/lib/local-workflows.js +35 -70
- package/dist/lib/obsidian.d.ts +1 -1
- package/dist/lib/parse.js +92 -1
- package/dist/lib/project-paths.d.ts +13 -0
- package/dist/lib/project-paths.js +29 -0
- package/dist/lib/runtime-acceptance.d.ts +7 -1
- package/dist/lib/runtime-acceptance.js +194 -59
- package/dist/lib/runtime-contracts.d.ts +2 -4
- package/dist/lib/runtime-contracts.js +17 -161
- package/dist/lib/runtime-inventory.d.ts +7 -0
- package/dist/lib/runtime-inventory.js +29 -0
- package/dist/lib/runtime-paths.js +5 -5
- package/dist/lib/runtime-prompt.js +9 -6
- package/dist/lib/runtime-reconcile.d.ts +2 -3
- package/dist/lib/runtime-reconcile.js +92 -171
- package/dist/lib/runtime-runs.js +30 -39
- package/dist/lib/runtime-types.d.ts +10 -19
- package/dist/lib/runtime.d.ts +2 -2
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/schema.d.ts +163 -140
- package/dist/lib/schema.js +163 -124
- package/dist/lib/source-config.d.ts +24 -20
- package/dist/lib/source-config.js +154 -116
- package/dist/lib/state-artifacts.d.ts +5 -5
- package/dist/lib/state-artifacts.js +8 -8
- package/dist/lib/state-health.d.ts +4 -4
- package/dist/lib/state-health.js +108 -126
- package/dist/lib/state-io.d.ts +8 -8
- package/dist/lib/state-io.js +77 -50
- package/dist/lib/state-paths.js +5 -5
- package/dist/lib/state-view.d.ts +4 -4
- package/dist/lib/state-view.js +52 -55
- package/dist/lib/state.d.ts +5 -5
- package/dist/lib/state.js +4 -4
- package/dist/lib/summarize-plan.d.ts +3 -2
- package/dist/lib/summarize-plan.js +18 -16
- package/dist/lib/test-execution.js +9 -9
- package/dist/lib/test-matrices.d.ts +3 -3
- package/dist/lib/test-matrices.js +6 -6
- package/dist/lib/test-paths.d.ts +4 -4
- package/dist/lib/test-paths.js +16 -10
- package/dist/lib/test-sandbox.d.ts +1 -1
- package/dist/lib/test-sandbox.js +38 -31
- package/dist/lib/test-targets.d.ts +2 -2
- package/dist/lib/test-targets.js +11 -11
- package/dist/lib/test-types.d.ts +1 -1
- package/dist/lib/test.d.ts +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/util.d.ts +2 -0
- package/dist/lib/util.js +14 -1
- package/dist/lib/validate-compiled.d.ts +27 -0
- package/dist/lib/validate-compiled.js +236 -0
- package/dist/lib/validate-helpers.d.ts +0 -8
- package/dist/lib/validate-helpers.js +0 -30
- package/dist/lib/validate.d.ts +4 -4
- package/dist/lib/validate.js +49 -15
- package/dist/lib/workflow-abi.d.ts +37 -46
- package/dist/lib/workflow-abi.js +51 -76
- package/dist/lib/workflow-definitions.d.ts +11 -11
- package/dist/lib/workflow-definitions.js +36 -53
- package/dist/lib/workflow-helpers.d.ts +2 -3
- package/dist/lib/workflow-helpers.js +9 -13
- package/dist/lib/workflow-improvement.d.ts +3 -3
- package/dist/lib/workflow-improvement.js +48 -48
- package/dist/lib/workflow-review-paths.d.ts +3 -3
- package/dist/lib/workflow-review-paths.js +11 -11
- package/dist/lib/workflow-stage-runner.d.ts +1 -1
- package/dist/lib/workflow-stage-runner.js +8 -8
- package/dist/lib/workflows.d.ts +9 -9
- package/dist/lib/workflows.js +15 -17
- package/package.json +10 -9
- package/dist/commands/workspace-flow.d.ts +0 -23
- package/dist/commands/workspace-flow.js +0 -109
- package/dist/lib/registry.d.ts +0 -16
- package/dist/lib/registry.js +0 -65
- package/dist/lib/validate-workspace.d.ts +0 -121
- package/dist/lib/validate-workspace.js +0 -407
- package/dist/lib/workspace-compile.d.ts +0 -54
- package/dist/lib/workspace-compile.js +0 -476
- package/dist/lib/workspace-home.d.ts +0 -5
- package/dist/lib/workspace-home.js +0 -32
- package/dist/lib/workspace-layout.d.ts +0 -2
- package/dist/lib/workspace-layout.js +0 -60
- package/dist/lib/workspace-paths.d.ts +0 -41
- package/dist/lib/workspace-paths.js +0 -107
- package/dist/lib/workspace-reset.d.ts +0 -1
- package/dist/lib/workspace-reset.js +0 -43
- package/dist/lib/workspace-schema.d.ts +0 -17
- package/dist/lib/workspace-schema.js +0 -74
package/dist/lib/state.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type { RuntimeStatus,
|
|
1
|
+
export type { RuntimeStatus, CompiledStage, CompiledState, CompiledHealth, ViewSection, ViewCard, CompiledViewSpec, CompiledRawSnapshot, } from "./schema.js";
|
|
2
2
|
export { statePath, healthPath, viewSpecPath, rawSnapshotPath, } from "./state-paths.js";
|
|
3
|
-
export { loadState, saveState,
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
3
|
+
export { loadState, saveState, loadCompiledHealth, saveCompiledHealth, loadCompiledViewSpec, loadCompiledRawSnapshot, saveCompiledViewSpec, initCompiledState, } from "./state-io.js";
|
|
4
|
+
export { refreshCompiledArtifacts, } from "./state-artifacts.js";
|
|
5
|
+
export { computeCompiledHealth, resolveCompiledStatus, resolveCompiledStage, } from "./state-health.js";
|
|
6
|
+
export { ensureCompiledViewSpec, ensureCompiledRawSnapshot, normalizeCompiledViewSpec, } from "./state-view.js";
|
package/dist/lib/state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { statePath, healthPath, viewSpecPath, rawSnapshotPath, } from "./state-paths.js";
|
|
2
|
-
export { loadState, saveState,
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
2
|
+
export { loadState, saveState, loadCompiledHealth, saveCompiledHealth, loadCompiledViewSpec, loadCompiledRawSnapshot, saveCompiledViewSpec, initCompiledState, } from "./state-io.js";
|
|
3
|
+
export { refreshCompiledArtifacts, } from "./state-artifacts.js";
|
|
4
|
+
export { computeCompiledHealth, resolveCompiledStatus, resolveCompiledStage, } from "./state-health.js";
|
|
5
|
+
export { ensureCompiledViewSpec, ensureCompiledRawSnapshot, normalizeCompiledViewSpec, } from "./state-view.js";
|
|
@@ -12,5 +12,6 @@ export interface SummarizePlan {
|
|
|
12
12
|
targetCount: number;
|
|
13
13
|
targets: SummarizeTarget[];
|
|
14
14
|
}
|
|
15
|
-
export declare
|
|
16
|
-
export declare function
|
|
15
|
+
export declare const SUMMARIZE_PLAN_RELATIVE_PATH: string;
|
|
16
|
+
export declare function buildSummarizePlan(sourcePath: string, compiledPath: string, mode?: "pending" | "all"): SummarizePlan;
|
|
17
|
+
export declare function writeSummarizePlan(compiledPath: string, plan: SummarizePlan): string;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { listFilesRecursive } from "./filesystem.js";
|
|
4
|
+
import { builtinCompiledZoneRelativePath, compiledSummariesPath, BUILTIN_COMPILED_ZONE_IDS, } from "./compiled-schema.js";
|
|
4
5
|
import { discoverSourceFiles } from "./discovery.js";
|
|
5
6
|
import { loadState } from "./state.js";
|
|
6
7
|
import { parseJsonFrontmatter } from "./parse.js";
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
9
|
-
export function buildSummarizePlan(sourcePath,
|
|
10
|
-
const discovery = discoverSourceFiles(sourcePath,
|
|
8
|
+
import { compiledRuntimeRoot } from "./compiled-paths.js";
|
|
9
|
+
export const SUMMARIZE_PLAN_RELATIVE_PATH = join(".interf", "runtime", "summarize-targets.json");
|
|
10
|
+
export function buildSummarizePlan(sourcePath, compiledPath, mode = "pending") {
|
|
11
|
+
const discovery = discoverSourceFiles(sourcePath, compiledPath);
|
|
11
12
|
const sourceFiles = discovery.sourceFiles;
|
|
12
|
-
const summariesDir =
|
|
13
|
-
const summaryFiles = listSummaryFiles(summariesDir,
|
|
14
|
-
const state = loadState(
|
|
13
|
+
const summariesDir = compiledSummariesPath(compiledPath);
|
|
14
|
+
const summaryFiles = listSummaryFiles(summariesDir, compiledPath);
|
|
15
|
+
const state = loadState(compiledPath);
|
|
15
16
|
const pending = new Set((state?.pending ?? []).filter((value) => typeof value === "string" && sourceFiles.includes(value)));
|
|
16
17
|
const summaryIndex = new Map();
|
|
17
18
|
for (const summary of summaryFiles) {
|
|
18
|
-
const source = readSourceReference(join(
|
|
19
|
+
const source = readSourceReference(join(compiledPath, summary));
|
|
19
20
|
if (source)
|
|
20
21
|
summaryIndex.set(source, summary);
|
|
21
22
|
}
|
|
@@ -63,7 +64,7 @@ export function buildSummarizePlan(sourcePath, workspacePath, mode = "pending")
|
|
|
63
64
|
if (targets.has(src))
|
|
64
65
|
continue;
|
|
65
66
|
const sourceFile = join(sourcePath, src);
|
|
66
|
-
const synthFile = join(
|
|
67
|
+
const synthFile = join(compiledPath, summary);
|
|
67
68
|
if (!existsSync(sourceFile) || !existsSync(synthFile))
|
|
68
69
|
continue;
|
|
69
70
|
try {
|
|
@@ -91,14 +92,14 @@ export function buildSummarizePlan(sourcePath, workspacePath, mode = "pending")
|
|
|
91
92
|
targets: Array.from(targets.values()).sort((a, b) => a.source.localeCompare(b.source)),
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
|
-
export function writeSummarizePlan(
|
|
95
|
-
const planPath = join(
|
|
96
|
-
mkdirSync(
|
|
95
|
+
export function writeSummarizePlan(compiledPath, plan) {
|
|
96
|
+
const planPath = join(compiledPath, SUMMARIZE_PLAN_RELATIVE_PATH);
|
|
97
|
+
mkdirSync(compiledRuntimeRoot(compiledPath), { recursive: true });
|
|
97
98
|
writeFileSync(planPath, JSON.stringify(plan, null, 2) + "\n");
|
|
98
99
|
return planPath;
|
|
99
100
|
}
|
|
100
|
-
function listSummaryFiles(summariesDir,
|
|
101
|
-
return listFilesRecursive(summariesDir, (filePath) => filePath.endsWith(".md")).map((filePath) => relative(
|
|
101
|
+
function listSummaryFiles(summariesDir, compiledPath) {
|
|
102
|
+
return listFilesRecursive(summariesDir, (filePath) => filePath.endsWith(".md")).map((filePath) => relative(compiledPath, filePath));
|
|
102
103
|
}
|
|
103
104
|
function readSourceReference(synthPath) {
|
|
104
105
|
if (!existsSync(synthPath))
|
|
@@ -115,8 +116,9 @@ function readSourceReference(synthPath) {
|
|
|
115
116
|
return source?.trim() ?? null;
|
|
116
117
|
}
|
|
117
118
|
function defaultSummaryPath(sourcePath) {
|
|
119
|
+
const summariesRoot = builtinCompiledZoneRelativePath(BUILTIN_COMPILED_ZONE_IDS.SUMMARIES);
|
|
118
120
|
if (sourcePath.endsWith(".md"))
|
|
119
|
-
return
|
|
121
|
+
return `${summariesRoot}/${sourcePath}`;
|
|
120
122
|
const replaced = sourcePath.replace(/\.[^.]+$/, ".md");
|
|
121
|
-
return
|
|
123
|
+
return `${summariesRoot}/${replaced === sourcePath ? `${sourcePath}.md` : replaced}`;
|
|
122
124
|
}
|
|
@@ -195,23 +195,23 @@ async function runTargetTestsJudge(testCase, executor, candidateLabel, candidate
|
|
|
195
195
|
return { verdict, error: executionError };
|
|
196
196
|
}
|
|
197
197
|
function buildTestQueryPrompt(target, testCase, answerPath, tracePath) {
|
|
198
|
-
const header = target.type === "
|
|
198
|
+
const header = target.type === "compiled"
|
|
199
199
|
? [
|
|
200
|
-
"You are running an Interf test inside an isolated sandboxed compiled
|
|
200
|
+
"You are running an Interf test inside an isolated sandboxed compiled dataset.",
|
|
201
201
|
"Read `AGENTS.md` first.",
|
|
202
|
-
"Use the local native `interf-query` skill available in this
|
|
203
|
-
"Answer the truth-check question the same way you would answer a real user inside this compiled
|
|
204
|
-
"Prefer
|
|
205
|
-
"This sandbox is self-contained: the copied
|
|
206
|
-
"The
|
|
202
|
+
"Use the local native `interf-query` skill available in this compiled dataset.",
|
|
203
|
+
"Answer the truth-check question the same way you would answer a real user inside this compiled dataset.",
|
|
204
|
+
"Prefer the workflow-declared compiled outputs before raw fallback.",
|
|
205
|
+
"This sandbox is self-contained: the copied compiled dataset has its own sanitized `raw/` fallback via `.interf/interf.json` `source.path`.",
|
|
206
|
+
"The project control plane is intentionally absent from this sandbox. Work only from this sandboxed compiled dataset and its embedded raw files.",
|
|
207
207
|
]
|
|
208
208
|
: [
|
|
209
209
|
"You are running an Interf baseline test inside an isolated raw test shell.",
|
|
210
210
|
"Read `AGENTS.md` first.",
|
|
211
211
|
"Use the local native `interf-query` skill available in this shell.",
|
|
212
|
-
"There is no compiled
|
|
212
|
+
"There is no compiled dataset in this sandbox.",
|
|
213
213
|
"Answer only from `raw/` inside this shell.",
|
|
214
|
-
"The
|
|
214
|
+
"The project control plane is intentionally absent from this sandbox.",
|
|
215
215
|
];
|
|
216
216
|
return [
|
|
217
217
|
...header,
|
|
@@ -40,7 +40,7 @@ export declare const TestMatrixProfileSchema: z.ZodPipe<z.ZodObject<{
|
|
|
40
40
|
export declare const TestMatrixRetryPolicySchema: z.ZodObject<{
|
|
41
41
|
max_attempts_per_profile: z.ZodOptional<z.ZodNumber>;
|
|
42
42
|
}, z.core.$strip>;
|
|
43
|
-
export declare const
|
|
43
|
+
export declare const TestMatrixDatasetSchema: z.ZodString;
|
|
44
44
|
export declare const TestMatrixSchema: z.ZodObject<{
|
|
45
45
|
id: z.ZodString;
|
|
46
46
|
name: z.ZodString;
|
|
@@ -81,10 +81,10 @@ export declare const TestMatrixSchema: z.ZodObject<{
|
|
|
81
81
|
retry_policy: z.ZodOptional<z.ZodObject<{
|
|
82
82
|
max_attempts_per_profile: z.ZodOptional<z.ZodNumber>;
|
|
83
83
|
}, z.core.$strip>>;
|
|
84
|
-
|
|
84
|
+
datasets: z.ZodArray<z.ZodString>;
|
|
85
85
|
}, z.core.$strip>;
|
|
86
86
|
export type TestMatrixProfile = z.infer<typeof TestMatrixProfileSchema>;
|
|
87
87
|
export type TestMatrixRetryPolicy = z.infer<typeof TestMatrixRetryPolicySchema>;
|
|
88
|
-
export type
|
|
88
|
+
export type TestMatrixDataset = z.infer<typeof TestMatrixDatasetSchema>;
|
|
89
89
|
export type TestMatrix = z.infer<typeof TestMatrixSchema>;
|
|
90
90
|
export declare function testMatrixProfileToExecutionProfile(profile: TestMatrixProfile): WorkflowExecutionProfile;
|
|
@@ -50,14 +50,14 @@ export const TestMatrixProfileSchema = TestMatrixProfileInputSchema.transform((v
|
|
|
50
50
|
export const TestMatrixRetryPolicySchema = z.object({
|
|
51
51
|
max_attempts_per_profile: z.number().int().min(1).max(5).optional(),
|
|
52
52
|
});
|
|
53
|
-
export const
|
|
53
|
+
export const TestMatrixDatasetSchema = z.string().regex(WorkflowIdPattern);
|
|
54
54
|
export const TestMatrixSchema = z.object({
|
|
55
55
|
id: z.string().regex(WorkflowIdPattern),
|
|
56
56
|
name: z.string().min(1),
|
|
57
57
|
source_path: z.string().min(1),
|
|
58
58
|
compile_profiles: z.array(TestMatrixProfileSchema).min(1),
|
|
59
59
|
retry_policy: TestMatrixRetryPolicySchema.optional(),
|
|
60
|
-
|
|
60
|
+
datasets: z.array(TestMatrixDatasetSchema).min(1),
|
|
61
61
|
}).superRefine((value, ctx) => {
|
|
62
62
|
const duplicateProfileIds = findDuplicates(value.compile_profiles.map((profile) => profile.id));
|
|
63
63
|
for (const id of duplicateProfileIds) {
|
|
@@ -67,12 +67,12 @@ export const TestMatrixSchema = z.object({
|
|
|
67
67
|
message: `Duplicate compile profile id in test matrix: ${id}`,
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
for (const id of
|
|
70
|
+
const duplicateCompiledIds = findDuplicates(value.datasets);
|
|
71
|
+
for (const id of duplicateCompiledIds) {
|
|
72
72
|
ctx.addIssue({
|
|
73
73
|
code: z.ZodIssueCode.custom,
|
|
74
|
-
path: ["
|
|
75
|
-
message: `Duplicate
|
|
74
|
+
path: ["datasets"],
|
|
75
|
+
message: `Duplicate dataset id in test matrix: ${id}`,
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
});
|
package/dist/lib/test-paths.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { TestTargetType } from "./test-types.js";
|
|
|
2
2
|
export declare const TEST_SPEC_EXTENSIONS: Set<string>;
|
|
3
3
|
export declare function testSpecRootPath(sourcePath: string): string;
|
|
4
4
|
export declare function testSpecTypePath(sourcePath: string, type: TestTargetType): string;
|
|
5
|
-
export declare function targetTestRunsPath(
|
|
6
|
-
export declare function targetTestRunGitignorePath(
|
|
7
|
-
export declare function targetTestSandboxesPath(
|
|
8
|
-
export declare function targetTestSandboxGitignorePath(
|
|
5
|
+
export declare function targetTestRunsPath(compiledPath: string, type: TestTargetType): string;
|
|
6
|
+
export declare function targetTestRunGitignorePath(compiledPath: string, type: TestTargetType): string;
|
|
7
|
+
export declare function targetTestSandboxesPath(compiledPath: string, type: TestTargetType): string;
|
|
8
|
+
export declare function targetTestSandboxGitignorePath(compiledPath: string, type: TestTargetType): string;
|
|
9
9
|
export declare function testSpecFilePath(sourcePath: string, type: TestTargetType, id: string): string;
|
|
10
10
|
export declare function normalizeTestId(input: string): string;
|
|
11
11
|
export declare function assertTestId(id: string): void;
|
package/dist/lib/test-paths.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { targetTestRunsRootForCompiled, targetTestSandboxesRootForCompiled, compiledInterfConfigPath, } from "./compiled-paths.js";
|
|
4
4
|
const TEST_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,79}$/;
|
|
5
5
|
export const TEST_SPEC_EXTENSIONS = new Set([".json"]);
|
|
6
6
|
export function testSpecRootPath(sourcePath) {
|
|
7
|
-
return join(sourcePath, "interf", "tests");
|
|
7
|
+
return join(sourcePath, "interf", "tests", "internal", "specs");
|
|
8
8
|
}
|
|
9
9
|
export function testSpecTypePath(sourcePath, type) {
|
|
10
10
|
return join(testSpecRootPath(sourcePath), type);
|
|
11
11
|
}
|
|
12
|
-
export function targetTestRunsPath(
|
|
13
|
-
|
|
12
|
+
export function targetTestRunsPath(compiledPath, type) {
|
|
13
|
+
if (existsSync(compiledInterfConfigPath(compiledPath))) {
|
|
14
|
+
return join(targetTestRunsRootForCompiled(compiledPath), type);
|
|
15
|
+
}
|
|
16
|
+
return join(compiledPath, "tests", type === "raw" ? "file-as-is" : "compiled", "runs");
|
|
14
17
|
}
|
|
15
|
-
export function targetTestRunGitignorePath(
|
|
16
|
-
return join(targetTestRunsPath(
|
|
18
|
+
export function targetTestRunGitignorePath(compiledPath, type) {
|
|
19
|
+
return join(targetTestRunsPath(compiledPath, type), ".gitignore");
|
|
17
20
|
}
|
|
18
|
-
export function targetTestSandboxesPath(
|
|
19
|
-
|
|
21
|
+
export function targetTestSandboxesPath(compiledPath, type) {
|
|
22
|
+
if (existsSync(compiledInterfConfigPath(compiledPath))) {
|
|
23
|
+
return join(targetTestSandboxesRootForCompiled(compiledPath), type);
|
|
24
|
+
}
|
|
25
|
+
return join(compiledPath, "tests", type === "raw" ? "file-as-is" : "compiled", "sandboxes");
|
|
20
26
|
}
|
|
21
|
-
export function targetTestSandboxGitignorePath(
|
|
22
|
-
return join(targetTestSandboxesPath(
|
|
27
|
+
export function targetTestSandboxGitignorePath(compiledPath, type) {
|
|
28
|
+
return join(targetTestSandboxesPath(compiledPath, type), ".gitignore");
|
|
23
29
|
}
|
|
24
30
|
export function testSpecFilePath(sourcePath, type, id) {
|
|
25
31
|
return join(testSpecTypePath(sourcePath, type), `${id}.json`);
|
package/dist/lib/test-sandbox.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, renameSync, rmSync, } from "node:fs";
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { dirname, join, relative, sep } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import { readInterfConfig, resolveSourceControlPath,
|
|
4
|
+
import { refreshCompiledBootstrapGuidance } from "./interf-bootstrap.js";
|
|
5
|
+
import { readInterfConfig, resolveSourceControlPath, resolveCompiledRawPath } from "./interf.js";
|
|
6
6
|
import { projectRawTestQueryShell } from "./agent-shells.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { compiledCompiledPathForDataset } from "./project-paths.js";
|
|
8
|
+
import { findSourceDatasetConfig, loadSourceFolderConfig, resolveSourceDatasetPath, saveCompiledInterfConfig, } from "./source-config.js";
|
|
9
|
+
import { refreshCompiledArtifacts } from "./state.js";
|
|
10
|
+
import { projectRawSnapshot } from "./compiled-raw.js";
|
|
11
|
+
import { testRootForCompiled, stageExecutionShellsRoot, targetTestSandboxesRootForCompiled, workflowImprovementLoopsRoot, compiledQueryAcceptanceRoot, compiledRuntimeLogsRoot, } from "./compiled-paths.js";
|
|
11
12
|
function toPortableRelativePath(fromPath, toPath) {
|
|
12
13
|
return relative(fromPath, toPath).split(sep).join("/");
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function sanitizeCompiledArtifacts(compiledPath) {
|
|
15
16
|
for (const absolutePath of [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
stageExecutionShellsRoot(
|
|
19
|
-
workflowImprovementLoopsRoot(
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
testRootForCompiled(compiledPath),
|
|
18
|
+
targetTestSandboxesRootForCompiled(compiledPath),
|
|
19
|
+
stageExecutionShellsRoot(compiledPath),
|
|
20
|
+
workflowImprovementLoopsRoot(compiledPath),
|
|
21
|
+
compiledRuntimeLogsRoot(compiledPath),
|
|
22
|
+
compiledQueryAcceptanceRoot(compiledPath),
|
|
22
23
|
]) {
|
|
23
24
|
rmSync(absolutePath, { recursive: true, force: true });
|
|
24
25
|
}
|
|
@@ -26,50 +27,56 @@ function sanitizeWorkspaceArtifacts(workspacePath) {
|
|
|
26
27
|
export function createTestSandbox(target) {
|
|
27
28
|
let sandboxRoot = mkdtempSync(join(tmpdir(), "interf-test-sandbox-"));
|
|
28
29
|
let preserved = false;
|
|
29
|
-
const
|
|
30
|
-
?
|
|
30
|
+
const sandboxCompiledPath = () => (target.type === "compiled"
|
|
31
|
+
? compiledCompiledPathForDataset(sandboxRoot, target.name)
|
|
31
32
|
: null);
|
|
32
|
-
const sandboxRawPath = () => (target.type === "
|
|
33
|
-
? join(sandboxRoot,
|
|
33
|
+
const sandboxRawPath = () => (target.type === "compiled"
|
|
34
|
+
? join(compiledCompiledPathForDataset(sandboxRoot, target.name), "raw")
|
|
34
35
|
: join(sandboxRoot, "raw"));
|
|
35
|
-
const sandboxTargetPath = () => (target.type === "
|
|
36
|
-
?
|
|
36
|
+
const sandboxTargetPath = () => (target.type === "compiled"
|
|
37
|
+
? compiledCompiledPathForDataset(sandboxRoot, target.name)
|
|
37
38
|
: sandboxRoot);
|
|
38
39
|
try {
|
|
39
|
-
if (target.type === "
|
|
40
|
+
if (target.type === "compiled") {
|
|
40
41
|
mkdirSync(dirname(sandboxTargetPath()), { recursive: true });
|
|
41
42
|
cpSync(target.path, sandboxTargetPath(), { recursive: true });
|
|
42
|
-
|
|
43
|
+
sanitizeCompiledArtifacts(sandboxTargetPath());
|
|
43
44
|
const sandboxConfig = readInterfConfig(sandboxTargetPath());
|
|
44
45
|
if (!sandboxConfig) {
|
|
45
|
-
throw new Error(`Sandbox
|
|
46
|
+
throw new Error(`Sandbox compiled is missing interf.json: ${sandboxTargetPath()}`);
|
|
46
47
|
}
|
|
47
|
-
if (!existsSync(
|
|
48
|
-
const
|
|
48
|
+
if (!existsSync(resolveCompiledRawPath(sandboxTargetPath(), sandboxConfig))) {
|
|
49
|
+
const projectPath = resolveSourceControlPath(target.path);
|
|
50
|
+
const projectConfig = loadSourceFolderConfig(projectPath);
|
|
51
|
+
const datasetConfig = findSourceDatasetConfig(projectConfig, sandboxConfig.name);
|
|
52
|
+
if (!datasetConfig) {
|
|
53
|
+
throw new Error(`Sandbox compiled is missing a trusted dataset binding for "${sandboxConfig.name}": ${target.path}`);
|
|
54
|
+
}
|
|
55
|
+
const controlSourcePath = resolveSourceDatasetPath(projectPath, datasetConfig);
|
|
49
56
|
projectRawSnapshot({
|
|
50
57
|
sourcePath: controlSourcePath,
|
|
51
58
|
destinationPath: sandboxRawPath(),
|
|
52
|
-
|
|
59
|
+
compiledPath: target.path,
|
|
53
60
|
mode: "link-or-copy",
|
|
54
61
|
prune: false,
|
|
55
62
|
preserveTimestamps: false,
|
|
56
63
|
});
|
|
57
64
|
}
|
|
58
|
-
|
|
65
|
+
saveCompiledInterfConfig(sandboxTargetPath(), {
|
|
59
66
|
...sandboxConfig,
|
|
60
67
|
checks: [],
|
|
61
68
|
source: {
|
|
62
69
|
path: toPortableRelativePath(sandboxTargetPath(), sandboxRawPath()),
|
|
63
70
|
},
|
|
64
71
|
});
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
refreshCompiledBootstrapGuidance(sandboxTargetPath());
|
|
73
|
+
refreshCompiledArtifacts(sandboxTargetPath(), { ensureViewSpec: true });
|
|
67
74
|
}
|
|
68
75
|
else {
|
|
69
76
|
projectRawSnapshot({
|
|
70
77
|
sourcePath: target.path,
|
|
71
78
|
destinationPath: sandboxRawPath(),
|
|
72
|
-
|
|
79
|
+
compiledPath: target.path,
|
|
73
80
|
mode: "link-or-copy",
|
|
74
81
|
prune: false,
|
|
75
82
|
preserveTimestamps: false,
|
|
@@ -91,8 +98,8 @@ export function createTestSandbox(target) {
|
|
|
91
98
|
get targetPath() {
|
|
92
99
|
return sandboxTargetPath();
|
|
93
100
|
},
|
|
94
|
-
get
|
|
95
|
-
return
|
|
101
|
+
get compiledPath() {
|
|
102
|
+
return sandboxCompiledPath();
|
|
96
103
|
},
|
|
97
104
|
preserve(destinationPath) {
|
|
98
105
|
mkdirSync(dirname(destinationPath), { recursive: true });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TestTargetCandidate } from "./test-types.js";
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function listCompiledTestTargets(sourcePath: string): TestTargetCandidate[];
|
|
3
|
+
export declare function createCompiledTestTarget(compiledPath: string, compiledName: string, workflowId?: string): TestTargetCandidate;
|
|
4
4
|
export declare function createRawTestTarget(sourcePath: string): TestTargetCandidate;
|
|
5
5
|
export declare function listTestTargets(sourcePath: string): TestTargetCandidate[];
|
package/dist/lib/test-targets.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { listCompiledDatasetsForSourceFolder } from "./interf.js";
|
|
2
|
+
import { computeCompiledHealth } from "./state.js";
|
|
3
3
|
function summarizeTargetSortKey(target) {
|
|
4
4
|
return `${target.name}\u0000${target.workflow}`;
|
|
5
5
|
}
|
|
6
|
-
export function
|
|
7
|
-
return
|
|
8
|
-
.map(({ path, config }) =>
|
|
6
|
+
export function listCompiledTestTargets(sourcePath) {
|
|
7
|
+
return listCompiledDatasetsForSourceFolder(sourcePath)
|
|
8
|
+
.map(({ path, config }) => createCompiledTestTarget(path, config.name, config.workflow ?? "interf"))
|
|
9
9
|
.sort((left, right) => summarizeTargetSortKey(left).localeCompare(summarizeTargetSortKey(right)));
|
|
10
10
|
}
|
|
11
|
-
export function
|
|
12
|
-
const health =
|
|
11
|
+
export function createCompiledTestTarget(compiledPath, compiledName, workflowId = "interf") {
|
|
12
|
+
const health = computeCompiledHealth(compiledPath);
|
|
13
13
|
return {
|
|
14
|
-
type: "
|
|
15
|
-
name:
|
|
16
|
-
path:
|
|
14
|
+
type: "compiled",
|
|
15
|
+
name: compiledName,
|
|
16
|
+
path: compiledPath,
|
|
17
17
|
workflow: workflowId,
|
|
18
18
|
status: health.status,
|
|
19
19
|
stage: health.stage,
|
|
@@ -34,5 +34,5 @@ export function createRawTestTarget(sourcePath) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
export function listTestTargets(sourcePath) {
|
|
37
|
-
return
|
|
37
|
+
return listCompiledTestTargets(sourcePath);
|
|
38
38
|
}
|
package/dist/lib/test-types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TestSpec } from "./schema.js";
|
|
2
2
|
export type { TestCaseExpect, TestCase, TestSpec, TestCheckResult, TestCaseResult, TestTargetResult, TestTargetRun, } from "./schema.js";
|
|
3
|
-
export type TestTargetType = "
|
|
3
|
+
export type TestTargetType = "compiled" | "raw";
|
|
4
4
|
export interface LoadedTestSpec extends TestSpec {
|
|
5
5
|
id: string;
|
|
6
6
|
filePath: string;
|
package/dist/lib/test.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export type { TestCaseExpect, TestCase, TestSpec, TestCheckResult, TestCaseResult, TestTargetResult, TestTargetRun, TestTargetType, LoadedTestSpec, TestTargetCandidate, } from "./test-types.js";
|
|
2
2
|
export { listTestSpecs, loadTestSpec, loadTestSpecFromFile, writeTestSpec, } from "./test-specs.js";
|
|
3
|
-
export { createRawTestTarget,
|
|
3
|
+
export { createRawTestTarget, createCompiledTestTarget, listCompiledTestTargets, listTestTargets, } from "./test-targets.js";
|
|
4
4
|
export { runTargetTests, runTargetTestsWithJudge, runTargetTestsAuto, saveTargetTestRun, } from "./test-execution.js";
|
package/dist/lib/test.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { listTestSpecs, loadTestSpec, loadTestSpecFromFile, writeTestSpec, } from "./test-specs.js";
|
|
2
|
-
export { createRawTestTarget,
|
|
2
|
+
export { createRawTestTarget, createCompiledTestTarget, listCompiledTestTargets, listTestTargets, } from "./test-targets.js";
|
|
3
3
|
export { runTargetTests, runTargetTestsWithJudge, runTargetTestsAuto, saveTargetTestRun, } from "./test-execution.js";
|
package/dist/lib/util.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare function slugify(input: string): string;
|
|
2
2
|
export declare function isMarkdownFile(filePath: string): boolean;
|
|
3
|
+
export declare function isPathWithinRoot(rootPath: string, candidatePath: string): boolean;
|
|
4
|
+
export declare function assertPathWithinRoot(rootPath: string, candidatePath: string, label: string): string;
|
package/dist/lib/util.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extname } from "node:path";
|
|
1
|
+
import { extname, isAbsolute, relative, resolve, sep } from "node:path";
|
|
2
2
|
export function slugify(input) {
|
|
3
3
|
return input
|
|
4
4
|
.toLowerCase()
|
|
@@ -10,3 +10,16 @@ export function slugify(input) {
|
|
|
10
10
|
export function isMarkdownFile(filePath) {
|
|
11
11
|
return extname(filePath).toLowerCase() === ".md";
|
|
12
12
|
}
|
|
13
|
+
export function isPathWithinRoot(rootPath, candidatePath) {
|
|
14
|
+
const root = resolve(rootPath);
|
|
15
|
+
const candidate = resolve(candidatePath);
|
|
16
|
+
const relativePath = relative(root, candidate);
|
|
17
|
+
return relativePath === "" || (!isAbsolute(relativePath) && relativePath !== ".." && !relativePath.startsWith(`..${sep}`));
|
|
18
|
+
}
|
|
19
|
+
export function assertPathWithinRoot(rootPath, candidatePath, label) {
|
|
20
|
+
const resolvedPath = resolve(candidatePath);
|
|
21
|
+
if (!isPathWithinRoot(rootPath, resolvedPath)) {
|
|
22
|
+
throw new Error(`${label} must stay inside ${resolve(rootPath)}: ${resolvedPath}`);
|
|
23
|
+
}
|
|
24
|
+
return resolvedPath;
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface CompiledValidationSummary {
|
|
2
|
+
config_present: boolean;
|
|
3
|
+
config_valid: boolean;
|
|
4
|
+
config_type_match: boolean;
|
|
5
|
+
workflow_present: boolean;
|
|
6
|
+
workflow_valid: boolean;
|
|
7
|
+
schema_present: boolean;
|
|
8
|
+
schema_valid: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CompiledStageValidation {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
required: boolean;
|
|
13
|
+
stage: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
counts: Record<string, number>;
|
|
16
|
+
checks: Record<string, boolean>;
|
|
17
|
+
errors: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface CompiledWorkflowValidation extends CompiledStageValidation {
|
|
20
|
+
stage_results: Record<string, boolean>;
|
|
21
|
+
}
|
|
22
|
+
export declare function validateCompiled(dirPath: string): CompiledValidationSummary;
|
|
23
|
+
export declare function validateCompiledStage(dirPath: string, stageId: string): CompiledStageValidation;
|
|
24
|
+
export declare function validateCompiledWorkflow(dirPath: string): CompiledWorkflowValidation;
|
|
25
|
+
export declare function validateCompiledSummarize(dirPath: string): CompiledStageValidation;
|
|
26
|
+
export declare function validateCompiledStructure(dirPath: string): CompiledStageValidation;
|
|
27
|
+
export declare function validateCompiledCompile(dirPath: string): CompiledWorkflowValidation;
|