@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
|
@@ -2,29 +2,30 @@ import { cpSync, existsSync, linkSync, mkdirSync, rmSync, statSync, } from "node
|
|
|
2
2
|
import { dirname, join, relative, resolve } from "node:path";
|
|
3
3
|
import { listFilesRecursive } from "./filesystem.js";
|
|
4
4
|
import { discoverSourceFiles } from "./discovery.js";
|
|
5
|
-
import { readInterfConfig,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import { readInterfConfig, resolveSourceInputPath, } from "./interf-detect.js";
|
|
6
|
+
import { saveCompiledInterfConfig } from "./source-config.js";
|
|
7
|
+
import { defaultControlPathForCompiled, } from "./compiled-paths.js";
|
|
8
|
+
import { assertPathWithinRoot } from "./util.js";
|
|
9
|
+
export function resolveCompiledRawPath(compiledPath, config = readInterfConfig(compiledPath)) {
|
|
9
10
|
const configuredPath = typeof config?.source?.path === "string" && config.source.path.length > 0
|
|
10
11
|
? config.source.path
|
|
11
12
|
: "raw";
|
|
12
|
-
return resolve(
|
|
13
|
+
return assertPathWithinRoot(compiledPath, resolve(compiledPath, configuredPath), "Compiled raw path");
|
|
13
14
|
}
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
const rawPath =
|
|
15
|
+
export function syncCompiledRawSnapshot(compiledPath, sourcePath = resolveSourceInputPath(compiledPath)) {
|
|
16
|
+
ensureCompiledRawBinding(compiledPath);
|
|
17
|
+
const rawPath = resolveCompiledRawPath(compiledPath);
|
|
17
18
|
return projectRawSnapshot({
|
|
18
19
|
sourcePath,
|
|
19
20
|
destinationPath: rawPath,
|
|
20
|
-
|
|
21
|
+
compiledPath,
|
|
21
22
|
mode: "copy",
|
|
22
23
|
prune: true,
|
|
23
24
|
preserveTimestamps: true,
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
export function
|
|
27
|
-
const config = readInterfConfig(
|
|
27
|
+
export function ensureCompiledRawBinding(compiledPath) {
|
|
28
|
+
const config = readInterfConfig(compiledPath);
|
|
28
29
|
if (!config)
|
|
29
30
|
return null;
|
|
30
31
|
if (config.source?.path === "./raw")
|
|
@@ -34,10 +35,11 @@ export function ensureWorkspaceRawBinding(workspacePath) {
|
|
|
34
35
|
source: {
|
|
35
36
|
...(config.source ?? {}),
|
|
36
37
|
path: "./raw",
|
|
37
|
-
control_path: config.source?.control_path ??
|
|
38
|
+
control_path: config.source?.control_path ?? defaultControlPathForCompiled(compiledPath),
|
|
39
|
+
...(config.source?.dataset_path ? { dataset_path: config.source.dataset_path } : {}),
|
|
38
40
|
},
|
|
39
41
|
};
|
|
40
|
-
return
|
|
42
|
+
return saveCompiledInterfConfig(compiledPath, nextConfig);
|
|
41
43
|
}
|
|
42
44
|
function filesMatch(sourcePath, targetPath) {
|
|
43
45
|
if (!existsSync(targetPath))
|
|
@@ -66,7 +68,7 @@ function materializeRawSnapshotFile(sourcePath, targetPath, options) {
|
|
|
66
68
|
cpSync(sourcePath, targetPath, { preserveTimestamps: options.preserveTimestamps });
|
|
67
69
|
}
|
|
68
70
|
export function projectRawSnapshot(options) {
|
|
69
|
-
const discovery = discoverSourceFiles(options.sourcePath, options.
|
|
71
|
+
const discovery = discoverSourceFiles(options.sourcePath, options.compiledPath);
|
|
70
72
|
const expectedFiles = new Set(discovery.sourceFiles);
|
|
71
73
|
mkdirSync(options.destinationPath, { recursive: true });
|
|
72
74
|
let removed = 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resetCompiledGeneratedState(compiledPath: string, scope?: "compile" | "all"): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { existsSync, rmSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { compiledKnowledgeRootPath, compiledSummariesPath, } from "./compiled-schema.js";
|
|
4
|
+
import { initCompiledState, refreshCompiledArtifacts, saveState, } from "./state.js";
|
|
5
|
+
import { saveEmptyCompiledInventory } from "./state-io.js";
|
|
6
|
+
import { stageExecutionShellsRoot, testRootForCompiled, testTargetsRootForCompiled, workflowImprovementLoopsRoot, compiledQueryAcceptanceRoot, compiledRuntimeRoot, compiledRuntimeLogsRoot, } from "./compiled-paths.js";
|
|
7
|
+
function removeIfExists(path) {
|
|
8
|
+
if (existsSync(path)) {
|
|
9
|
+
rmSync(path, { recursive: true, force: true });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const COMPILE_RUNTIME_RESET_ENTRIES = [
|
|
13
|
+
"state.json",
|
|
14
|
+
"health.json",
|
|
15
|
+
"view-spec.json",
|
|
16
|
+
"inventory.json",
|
|
17
|
+
"run.json",
|
|
18
|
+
"stage-contract.json",
|
|
19
|
+
"summarize-targets.json",
|
|
20
|
+
];
|
|
21
|
+
function resetCompiledRuntimeFiles(compiledPath) {
|
|
22
|
+
const runtimeRoot = compiledRuntimeRoot(compiledPath);
|
|
23
|
+
for (const entry of COMPILE_RUNTIME_RESET_ENTRIES) {
|
|
24
|
+
removeIfExists(join(runtimeRoot, entry));
|
|
25
|
+
}
|
|
26
|
+
removeIfExists(compiledQueryAcceptanceRoot(compiledPath));
|
|
27
|
+
}
|
|
28
|
+
export function resetCompiledGeneratedState(compiledPath, scope = "compile") {
|
|
29
|
+
removeIfExists(compiledSummariesPath(compiledPath));
|
|
30
|
+
removeIfExists(compiledKnowledgeRootPath(compiledPath));
|
|
31
|
+
removeIfExists(join(compiledPath, ".obsidian"));
|
|
32
|
+
resetCompiledRuntimeFiles(compiledPath);
|
|
33
|
+
saveState(compiledPath, initCompiledState());
|
|
34
|
+
saveEmptyCompiledInventory(compiledPath);
|
|
35
|
+
refreshCompiledArtifacts(compiledPath, { ensureViewSpec: true });
|
|
36
|
+
if (scope === "all") {
|
|
37
|
+
removeIfExists(stageExecutionShellsRoot(compiledPath));
|
|
38
|
+
removeIfExists(workflowImprovementLoopsRoot(compiledPath));
|
|
39
|
+
removeIfExists(compiledRuntimeLogsRoot(compiledPath));
|
|
40
|
+
removeIfExists(join(compiledRuntimeRoot(compiledPath), "run-history.jsonl"));
|
|
41
|
+
removeIfExists(testRootForCompiled(compiledPath));
|
|
42
|
+
removeIfExists(testTargetsRootForCompiled(compiledPath));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type BuiltinCompiledZoneId } from "./workflow-abi.js";
|
|
2
|
+
import { type WorkflowCompiledSchema, type WorkflowCompiledZone, type WorkflowZoneId } from "./schema.js";
|
|
3
|
+
export interface WorkflowSchemaStageLike {
|
|
4
|
+
id: string;
|
|
5
|
+
writes: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "./workflow-abi.js";
|
|
8
|
+
export declare const COMPILED_SCHEMA_FILE = "compiled.schema.json";
|
|
9
|
+
export declare function compiledSchemaFilePath(rootPath: string): string;
|
|
10
|
+
export declare function compiledSchemaRelativePath(): string;
|
|
11
|
+
export declare function listCompiledSchemaZones(schema: WorkflowCompiledSchema): WorkflowCompiledZone[];
|
|
12
|
+
export declare function findCompiledSchemaZone(schema: WorkflowCompiledSchema, zoneId: WorkflowZoneId): WorkflowCompiledZone | null;
|
|
13
|
+
export declare function compiledZoneAbsolutePath(compiledPath: string, zone: Pick<WorkflowCompiledZone, "path">): string;
|
|
14
|
+
export declare function compiledContractArtifactPath(zone: Pick<WorkflowCompiledZone, "path" | "kind">): string;
|
|
15
|
+
export declare function compiledContractArtifactPathsForZoneIds(schema: WorkflowCompiledSchema, zoneIds: readonly WorkflowZoneId[]): string[];
|
|
16
|
+
export declare function builtinCompiledZoneRelativePath(zoneId: BuiltinCompiledZoneId): string;
|
|
17
|
+
export declare function builtinCompiledZoneAbsolutePath(compiledPath: string, zoneId: BuiltinCompiledZoneId): string;
|
|
18
|
+
export declare function compiledSummariesPath(compiledPath: string): string;
|
|
19
|
+
export declare function compiledKnowledgeEntitiesPath(compiledPath: string): string;
|
|
20
|
+
export declare function compiledKnowledgeClaimsPath(compiledPath: string): string;
|
|
21
|
+
export declare function compiledKnowledgeIndexesPath(compiledPath: string): string;
|
|
22
|
+
export declare function compiledKnowledgeRootPath(compiledPath: string): string;
|
|
23
|
+
export declare function compiledHomePath(compiledPath: string): string;
|
|
24
|
+
export declare function ensureCompiledZoneTargets(compiledPath: string, schema: WorkflowCompiledSchema): void;
|
|
25
|
+
export declare function buildCompiledSchema(stages: WorkflowSchemaStageLike[], label?: string): WorkflowCompiledSchema;
|
|
26
|
+
export declare function writeCompiledSchemaFile(rootPath: string, stages: WorkflowSchemaStageLike[], label?: string): WorkflowCompiledSchema;
|
|
27
|
+
export declare function readCompiledSchemaFile(rootPath: string): WorkflowCompiledSchema | null;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { readJsonFileWithSchema } from "./parse.js";
|
|
4
|
+
import { BUILTIN_COMPILED_ZONE_IDS, listBuiltinCompiledZoneSpecs, requiredCompiledZoneOwners, } from "./workflow-abi.js";
|
|
5
|
+
import { WorkflowCompiledSchemaSchema, } from "./schema.js";
|
|
6
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "./workflow-abi.js";
|
|
7
|
+
export const COMPILED_SCHEMA_FILE = "compiled.schema.json";
|
|
8
|
+
const BUILTIN_COMPILED_ZONE_SPEC_BY_ID = new Map(listBuiltinCompiledZoneSpecs().map((zone) => [zone.id, zone]));
|
|
9
|
+
export function compiledSchemaFilePath(rootPath) {
|
|
10
|
+
return join(rootPath, COMPILED_SCHEMA_FILE);
|
|
11
|
+
}
|
|
12
|
+
export function compiledSchemaRelativePath() {
|
|
13
|
+
return `workflow/${COMPILED_SCHEMA_FILE}`;
|
|
14
|
+
}
|
|
15
|
+
export function listCompiledSchemaZones(schema) {
|
|
16
|
+
return [...schema.zones];
|
|
17
|
+
}
|
|
18
|
+
export function findCompiledSchemaZone(schema, zoneId) {
|
|
19
|
+
return schema.zones.find((zone) => zone.id === zoneId) ?? null;
|
|
20
|
+
}
|
|
21
|
+
export function compiledZoneAbsolutePath(compiledPath, zone) {
|
|
22
|
+
return join(compiledPath, zone.path);
|
|
23
|
+
}
|
|
24
|
+
export function compiledContractArtifactPath(zone) {
|
|
25
|
+
if (zone.kind === "file")
|
|
26
|
+
return zone.path;
|
|
27
|
+
return zone.path.endsWith("/") ? zone.path : `${zone.path}/`;
|
|
28
|
+
}
|
|
29
|
+
export function compiledContractArtifactPathsForZoneIds(schema, zoneIds) {
|
|
30
|
+
return zoneIds.map((zoneId) => {
|
|
31
|
+
const zone = findCompiledSchemaZone(schema, zoneId);
|
|
32
|
+
if (!zone) {
|
|
33
|
+
throw new Error(`Compiled schema is missing declared zone "${zoneId}".`);
|
|
34
|
+
}
|
|
35
|
+
return compiledContractArtifactPath(zone);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export function builtinCompiledZoneRelativePath(zoneId) {
|
|
39
|
+
const zone = BUILTIN_COMPILED_ZONE_SPEC_BY_ID.get(zoneId);
|
|
40
|
+
if (!zone) {
|
|
41
|
+
throw new Error(`Missing built-in compiled zone "${zoneId}".`);
|
|
42
|
+
}
|
|
43
|
+
return zone.path;
|
|
44
|
+
}
|
|
45
|
+
export function builtinCompiledZoneAbsolutePath(compiledPath, zoneId) {
|
|
46
|
+
return join(compiledPath, builtinCompiledZoneRelativePath(zoneId));
|
|
47
|
+
}
|
|
48
|
+
export function compiledSummariesPath(compiledPath) {
|
|
49
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.SUMMARIES);
|
|
50
|
+
}
|
|
51
|
+
export function compiledKnowledgeEntitiesPath(compiledPath) {
|
|
52
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_ENTITIES);
|
|
53
|
+
}
|
|
54
|
+
export function compiledKnowledgeClaimsPath(compiledPath) {
|
|
55
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_CLAIMS);
|
|
56
|
+
}
|
|
57
|
+
export function compiledKnowledgeIndexesPath(compiledPath) {
|
|
58
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.KNOWLEDGE_INDEXES);
|
|
59
|
+
}
|
|
60
|
+
export function compiledKnowledgeRootPath(compiledPath) {
|
|
61
|
+
return dirname(compiledKnowledgeEntitiesPath(compiledPath));
|
|
62
|
+
}
|
|
63
|
+
export function compiledHomePath(compiledPath) {
|
|
64
|
+
return builtinCompiledZoneAbsolutePath(compiledPath, BUILTIN_COMPILED_ZONE_IDS.HOME);
|
|
65
|
+
}
|
|
66
|
+
export function ensureCompiledZoneTargets(compiledPath, schema) {
|
|
67
|
+
for (const zone of schema.zones) {
|
|
68
|
+
if (zone.kind === "directory" || zone.kind === "runtime") {
|
|
69
|
+
mkdirSync(compiledZoneAbsolutePath(compiledPath, zone), { recursive: true });
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
mkdirSync(dirname(compiledZoneAbsolutePath(compiledPath, zone)), { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function pushZone(zones, zone) {
|
|
76
|
+
if (zones.some((existing) => existing.path === zone.path))
|
|
77
|
+
return;
|
|
78
|
+
zones.push(zone);
|
|
79
|
+
}
|
|
80
|
+
export function buildCompiledSchema(stages, label = "Compiled dataset schema") {
|
|
81
|
+
const zones = [];
|
|
82
|
+
for (const zone of listBuiltinCompiledZoneSpecs()) {
|
|
83
|
+
pushZone(zones, {
|
|
84
|
+
id: zone.id,
|
|
85
|
+
path: zone.path,
|
|
86
|
+
kind: zone.kind,
|
|
87
|
+
required: zone.required,
|
|
88
|
+
owned_by: requiredCompiledZoneOwners(stages, zone.id),
|
|
89
|
+
description: zone.description,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
kind: "compiled-schema",
|
|
94
|
+
version: 1,
|
|
95
|
+
target_type: "compiled",
|
|
96
|
+
label,
|
|
97
|
+
zones,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function writeCompiledSchemaFile(rootPath, stages, label) {
|
|
101
|
+
const schema = buildCompiledSchema(stages, label);
|
|
102
|
+
writeFileSync(compiledSchemaFilePath(rootPath), `${JSON.stringify(schema, null, 2)}\n`);
|
|
103
|
+
return schema;
|
|
104
|
+
}
|
|
105
|
+
export function readCompiledSchemaFile(rootPath) {
|
|
106
|
+
const path = compiledSchemaFilePath(rootPath);
|
|
107
|
+
if (!existsSync(path))
|
|
108
|
+
return null;
|
|
109
|
+
return readJsonFileWithSchema(path, "compiled schema", WorkflowCompiledSchemaSchema);
|
|
110
|
+
}
|
package/dist/lib/config.d.ts
CHANGED
package/dist/lib/config.js
CHANGED
package/dist/lib/discovery.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export interface DiscoveryResult {
|
|
|
3
3
|
totalCount: number;
|
|
4
4
|
ignoredCount: number;
|
|
5
5
|
}
|
|
6
|
-
export declare function discoverSourceFiles(sourcePath: string,
|
|
6
|
+
export declare function discoverSourceFiles(sourcePath: string, compiledPath: string): DiscoveryResult;
|
|
7
7
|
export declare function loadIgnorePatterns(knowledgeBasePath: string): string[];
|
package/dist/lib/discovery.js
CHANGED
|
@@ -10,10 +10,10 @@ const DEFAULT_IGNORE_DIRS = new Set([
|
|
|
10
10
|
"node_modules",
|
|
11
11
|
]);
|
|
12
12
|
const DEFAULT_IGNORE_FILES = new Set([
|
|
13
|
-
"interf.
|
|
13
|
+
"interf.json",
|
|
14
14
|
]);
|
|
15
|
-
export function discoverSourceFiles(sourcePath,
|
|
16
|
-
const userPatterns = loadIgnorePatterns(
|
|
15
|
+
export function discoverSourceFiles(sourcePath, compiledPath) {
|
|
16
|
+
const userPatterns = loadIgnorePatterns(compiledPath);
|
|
17
17
|
let ignoredCount = 0;
|
|
18
18
|
const allFiles = listFilesRecursive(sourcePath, (filePath) => {
|
|
19
19
|
const rel = relative(sourcePath, filePath);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { basename } from "node:path";
|
|
2
2
|
import { readInterfConfig } from "./interf-detect.js";
|
|
3
|
-
import {
|
|
3
|
+
import { projectCompiledQueryShell, renderClaudeBootstrap } from "./agent-shells.js";
|
|
4
4
|
export { renderClaudeBootstrap };
|
|
5
|
-
export function
|
|
5
|
+
export function refreshCompiledBootstrapGuidance(dirPath) {
|
|
6
6
|
const config = readInterfConfig(dirPath);
|
|
7
7
|
if (!config)
|
|
8
8
|
return false;
|
|
9
|
-
const
|
|
9
|
+
const compiledName = config.name ?? basename(dirPath);
|
|
10
10
|
const workflowId = config.workflow ?? "interf";
|
|
11
11
|
const workflowOriginSelected = config.workflow_origin?.selected ?? workflowId;
|
|
12
12
|
const workflowLocalDraft = config.workflow_origin?.local_draft === true;
|
|
13
13
|
const about = typeof config.about === "string" && config.about.length > 0 ? config.about : undefined;
|
|
14
|
-
return
|
|
14
|
+
return projectCompiledQueryShell(dirPath, compiledName, workflowId, about, {
|
|
15
15
|
workflowOriginSelected,
|
|
16
16
|
workflowLocalDraft,
|
|
17
17
|
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { type InterfConfig } from "./schema.js";
|
|
2
2
|
export type { InterfConfig } from "./schema.js";
|
|
3
|
-
export interface
|
|
3
|
+
export interface ResolvedCompiled {
|
|
4
4
|
sourcePath: string;
|
|
5
|
-
|
|
5
|
+
compiledPath: string;
|
|
6
6
|
config: InterfConfig;
|
|
7
7
|
}
|
|
8
8
|
export declare const INTERF_CONTAINER_NAME = "interf";
|
|
9
|
-
export declare const WORKSPACE_CONTAINER_NAME = "workspaces";
|
|
10
9
|
export declare const WORKFLOW_CONTAINER_NAME = "workflows";
|
|
11
10
|
export declare const TEST_CONTAINER_NAME = "tests";
|
|
12
11
|
export declare const INTERF_CONFIG_FILE = "interf.json";
|
|
13
12
|
export declare const WORKFLOW_PACKAGE_DIR = "workflow";
|
|
14
|
-
export declare function
|
|
13
|
+
export declare function prepareCompiledLayout(dirPath: string): boolean;
|
|
15
14
|
export declare function readInterfConfig(dirPath: string): InterfConfig | null;
|
|
16
15
|
export declare function hasSourceFolderInput(config: InterfConfig | null | undefined): config is InterfConfig & {
|
|
17
16
|
source: {
|
|
@@ -22,13 +21,14 @@ export declare function detectInterf(cwd: string): {
|
|
|
22
21
|
path: string;
|
|
23
22
|
config: InterfConfig;
|
|
24
23
|
} | null;
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function resolveSourceFolderPath(
|
|
27
|
-
export declare function resolveSourceControlPath(
|
|
28
|
-
export declare function
|
|
24
|
+
export declare function resolveCompiled(cwd: string): ResolvedCompiled | null;
|
|
25
|
+
export declare function resolveSourceFolderPath(compiledPath: string, config?: InterfConfig | null): string;
|
|
26
|
+
export declare function resolveSourceControlPath(compiledPath: string): string;
|
|
27
|
+
export declare function resolveSourceInputPath(compiledPath: string): string;
|
|
28
|
+
export declare function listCompiledDatasetsForSourceFolder(sourcePath: string): Array<{
|
|
29
29
|
path: string;
|
|
30
30
|
config: InterfConfig;
|
|
31
31
|
}>;
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function assertCompiledContainer(sourcePath: string): string;
|
|
33
33
|
export declare function assertWritableTargetDir(dirPath: string, label: string): void;
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function assertCompiledName(name: string, label: string): void;
|
|
@@ -1,98 +1,108 @@
|
|
|
1
1
|
import { existsSync, readdirSync, statSync, } from "node:fs";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { warnInterf } from "./logger.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { readJsonFileUnchecked } from "./parse.js";
|
|
5
|
+
import { compiledCompiledPathForDataset, projectInterfRoot, } from "./project-paths.js";
|
|
6
|
+
import { resolveSourceControlPathForCompiled, compiledInterfConfigPath, } from "./compiled-paths.js";
|
|
7
|
+
import { normalizeLegacyCompiledLayout, compiledNeedsLegacyLayoutNormalization, } from "./compiled-layout.js";
|
|
7
8
|
import { InterfConfigSchema, } from "./schema.js";
|
|
9
|
+
import { assertPathWithinRoot } from "./util.js";
|
|
8
10
|
export const INTERF_CONTAINER_NAME = "interf";
|
|
9
|
-
export const WORKSPACE_CONTAINER_NAME = "workspaces";
|
|
10
11
|
export const WORKFLOW_CONTAINER_NAME = "workflows";
|
|
11
12
|
export const TEST_CONTAINER_NAME = "tests";
|
|
12
13
|
export const INTERF_CONFIG_FILE = "interf.json";
|
|
13
14
|
export const WORKFLOW_PACKAGE_DIR = "workflow";
|
|
14
|
-
export function
|
|
15
|
-
if (!
|
|
15
|
+
export function prepareCompiledLayout(dirPath) {
|
|
16
|
+
if (!compiledNeedsLegacyLayoutNormalization(dirPath)) {
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
|
-
return
|
|
19
|
+
return normalizeLegacyCompiledLayout(dirPath);
|
|
19
20
|
}
|
|
20
21
|
export function readInterfConfig(dirPath) {
|
|
21
|
-
const configPath =
|
|
22
|
+
const configPath = compiledInterfConfigPath(dirPath);
|
|
22
23
|
if (!existsSync(configPath))
|
|
23
24
|
return null;
|
|
24
|
-
|
|
25
|
+
const raw = readJsonFileUnchecked(configPath, "Interf config");
|
|
26
|
+
if (raw === null)
|
|
27
|
+
return null;
|
|
28
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
29
|
+
return null;
|
|
30
|
+
if (raw.type !== "compiled") {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const parsed = InterfConfigSchema.safeParse(raw);
|
|
34
|
+
if (!parsed.success) {
|
|
35
|
+
warnInterf(`Warning: failed to validate Interf config at ${configPath}: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return parsed.data;
|
|
25
39
|
}
|
|
26
40
|
export function hasSourceFolderInput(config) {
|
|
27
41
|
return typeof config?.source?.path === "string" && config.source.path.length > 0;
|
|
28
42
|
}
|
|
29
43
|
export function detectInterf(cwd) {
|
|
30
|
-
|
|
44
|
+
prepareCompiledLayout(cwd);
|
|
31
45
|
const config = readInterfConfig(cwd);
|
|
32
46
|
if (config)
|
|
33
47
|
return { path: cwd, config };
|
|
34
48
|
return null;
|
|
35
49
|
}
|
|
36
|
-
export function
|
|
50
|
+
export function resolveCompiled(cwd) {
|
|
37
51
|
const detected = detectInterf(cwd);
|
|
38
52
|
if (!detected)
|
|
39
53
|
return null;
|
|
40
54
|
return {
|
|
41
55
|
sourcePath: resolveSourceControlPath(detected.path),
|
|
42
|
-
|
|
56
|
+
compiledPath: detected.path,
|
|
43
57
|
config: detected.config,
|
|
44
58
|
};
|
|
45
59
|
}
|
|
46
|
-
export function resolveSourceFolderPath(
|
|
47
|
-
|
|
48
|
-
const resolvedConfig = config ?? readInterfConfig(
|
|
60
|
+
export function resolveSourceFolderPath(compiledPath, config = null) {
|
|
61
|
+
prepareCompiledLayout(compiledPath);
|
|
62
|
+
const resolvedConfig = config ?? readInterfConfig(compiledPath);
|
|
49
63
|
if (hasSourceFolderInput(resolvedConfig)) {
|
|
50
|
-
return resolve(
|
|
64
|
+
return assertPathWithinRoot(compiledPath, resolve(compiledPath, resolvedConfig.source.path), "Compiled raw source path");
|
|
51
65
|
}
|
|
52
|
-
return resolve(
|
|
66
|
+
return resolve(compiledPath, "raw");
|
|
53
67
|
}
|
|
54
|
-
export function resolveSourceControlPath(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
export function resolveSourceControlPath(compiledPath) {
|
|
69
|
+
prepareCompiledLayout(compiledPath);
|
|
70
|
+
return resolveSourceControlPathForCompiled(compiledPath);
|
|
71
|
+
}
|
|
72
|
+
export function resolveSourceInputPath(compiledPath) {
|
|
73
|
+
prepareCompiledLayout(compiledPath);
|
|
74
|
+
const projectPath = resolveSourceControlPathForCompiled(compiledPath);
|
|
75
|
+
const config = readInterfConfig(compiledPath);
|
|
76
|
+
if (typeof config?.source?.dataset_path === "string" && config.source.dataset_path.length > 0) {
|
|
77
|
+
return assertPathWithinRoot(projectPath, resolve(compiledPath, config.source.dataset_path), "Dataset source path");
|
|
59
78
|
}
|
|
60
|
-
return
|
|
79
|
+
return projectPath;
|
|
61
80
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
81
|
+
export function listCompiledDatasetsForSourceFolder(sourcePath) {
|
|
82
|
+
const interfRoot = projectInterfRoot(sourcePath);
|
|
83
|
+
if (!existsSync(interfRoot))
|
|
64
84
|
return [];
|
|
65
85
|
try {
|
|
66
|
-
if (!statSync(
|
|
86
|
+
if (!statSync(interfRoot).isDirectory())
|
|
67
87
|
return [];
|
|
68
88
|
}
|
|
69
89
|
catch (error) {
|
|
70
|
-
warnInterf(`Warning: failed to inspect Interf container at ${
|
|
90
|
+
warnInterf(`Warning: failed to inspect Interf container at ${interfRoot}: ${error instanceof Error ? error.message : String(error)}`);
|
|
71
91
|
return [];
|
|
72
92
|
}
|
|
73
|
-
return readdirSync(
|
|
74
|
-
.
|
|
75
|
-
.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
.map((entryPath) => {
|
|
85
|
-
prepareWorkspaceLayout(entryPath);
|
|
86
|
-
const config = readInterfConfig(entryPath);
|
|
87
|
-
return config ? { path: entryPath, config } : null;
|
|
93
|
+
return readdirSync(interfRoot)
|
|
94
|
+
.filter((entry) => !entry.startsWith(".") && entry !== WORKFLOW_CONTAINER_NAME)
|
|
95
|
+
.map((entry) => compiledCompiledPathForDataset(sourcePath, entry))
|
|
96
|
+
.filter((compiledPath) => existsSync(compiledPath))
|
|
97
|
+
.map((compiledPath) => {
|
|
98
|
+
prepareCompiledLayout(compiledPath);
|
|
99
|
+
const config = readInterfConfig(compiledPath);
|
|
100
|
+
return config ? { path: compiledPath, config } : null;
|
|
88
101
|
})
|
|
89
102
|
.filter((value) => value !== null);
|
|
90
103
|
}
|
|
91
|
-
export function
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
export function assertWorkspaceContainer(sourcePath) {
|
|
95
|
-
const interfRoot = join(sourcePath, INTERF_CONTAINER_NAME);
|
|
104
|
+
export function assertCompiledContainer(sourcePath) {
|
|
105
|
+
const interfRoot = projectInterfRoot(sourcePath);
|
|
96
106
|
if (existsSync(interfRoot)) {
|
|
97
107
|
const stat = statSync(interfRoot);
|
|
98
108
|
if (!stat.isDirectory()) {
|
|
@@ -102,9 +112,7 @@ export function assertWorkspaceContainer(sourcePath) {
|
|
|
102
112
|
if (entry.startsWith("."))
|
|
103
113
|
return false;
|
|
104
114
|
const entryPath = join(interfRoot, entry);
|
|
105
|
-
if (entry ===
|
|
106
|
-
entry === WORKFLOW_CONTAINER_NAME ||
|
|
107
|
-
entry === TEST_CONTAINER_NAME) {
|
|
115
|
+
if (entry === WORKFLOW_CONTAINER_NAME) {
|
|
108
116
|
try {
|
|
109
117
|
return !statSync(entryPath).isDirectory();
|
|
110
118
|
}
|
|
@@ -113,13 +121,21 @@ export function assertWorkspaceContainer(sourcePath) {
|
|
|
113
121
|
return true;
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
|
-
|
|
124
|
+
try {
|
|
125
|
+
if (!statSync(entryPath).isDirectory())
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
warnInterf(`Warning: failed to inspect Interf entry at ${entryPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
return false;
|
|
117
133
|
});
|
|
118
134
|
if (unexpectedRootEntries.length > 0) {
|
|
119
135
|
throw new Error(`Interf container contains unexpected entries: ${interfRoot}`);
|
|
120
136
|
}
|
|
121
137
|
}
|
|
122
|
-
const containerPath =
|
|
138
|
+
const containerPath = interfRoot;
|
|
123
139
|
if (!existsSync(containerPath)) {
|
|
124
140
|
return containerPath;
|
|
125
141
|
}
|
|
@@ -130,6 +146,8 @@ export function assertWorkspaceContainer(sourcePath) {
|
|
|
130
146
|
const unexpectedEntries = readdirSync(containerPath).filter((entry) => {
|
|
131
147
|
if (entry.startsWith("."))
|
|
132
148
|
return false;
|
|
149
|
+
if (entry === WORKFLOW_CONTAINER_NAME)
|
|
150
|
+
return false;
|
|
133
151
|
const entryPath = join(containerPath, entry);
|
|
134
152
|
try {
|
|
135
153
|
if (!statSync(entryPath).isDirectory())
|
|
@@ -139,11 +157,15 @@ export function assertWorkspaceContainer(sourcePath) {
|
|
|
139
157
|
warnInterf(`Warning: failed to inspect Interf entry at ${entryPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
140
158
|
return true;
|
|
141
159
|
}
|
|
142
|
-
|
|
143
|
-
|
|
160
|
+
const compiledPath = compiledCompiledPathForDataset(sourcePath, entry);
|
|
161
|
+
if (!existsSync(compiledPath)) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
prepareCompiledLayout(compiledPath);
|
|
165
|
+
return !readInterfConfig(compiledPath);
|
|
144
166
|
});
|
|
145
167
|
if (unexpectedEntries.length > 0) {
|
|
146
|
-
throw new Error(`Interf container contains invalid
|
|
168
|
+
throw new Error(`Interf container contains invalid dataset entries: ${containerPath}`);
|
|
147
169
|
}
|
|
148
170
|
return containerPath;
|
|
149
171
|
}
|
|
@@ -158,7 +180,7 @@ export function assertWritableTargetDir(dirPath, label) {
|
|
|
158
180
|
throw new Error(`${label} target already exists and is not empty: ${dirPath}`);
|
|
159
181
|
}
|
|
160
182
|
}
|
|
161
|
-
export function
|
|
183
|
+
export function assertCompiledName(name, label) {
|
|
162
184
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(name)) {
|
|
163
185
|
throw new Error(`${label} name must be a safe slug with lowercase letters, numbers, and dashes only: ${name}`);
|
|
164
186
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
export declare function
|
|
1
|
+
export declare function createCompiled(name: string, sourcePath: string, workflowId?: string, about?: string, datasetPath?: string): string;
|
|
2
|
+
export declare function defaultCompiledNameForSource(sourcePath: string): string;
|