@interf/compiler 0.4.1 → 0.5.1
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 +70 -66
- 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 +274 -65
- 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/{workflow-abi.d.ts → builtin-compiled-workflow.d.ts} +37 -46
- package/dist/lib/builtin-compiled-workflow.js +153 -0
- 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-paths.d.ts +39 -0
- package/dist/lib/compiled-paths.js +103 -0
- package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +9 -8
- 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 +9 -10
- package/dist/lib/interf-detect.js +70 -59
- 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 +11 -0
- package/dist/lib/project-paths.js +32 -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 +7 -6
- package/dist/lib/runtime-reconcile.d.ts +2 -3
- package/dist/lib/runtime-reconcile.js +94 -184
- package/dist/lib/runtime-runs.js +25 -119
- 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 +169 -153
- package/dist/lib/schema.js +116 -164
- package/dist/lib/source-config.d.ts +24 -20
- package/dist/lib/source-config.js +159 -122
- 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 +110 -126
- package/dist/lib/state-io.d.ts +8 -8
- package/dist/lib/state-io.js +21 -102
- 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 +19 -21
- 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 +26 -11
- package/dist/lib/test-sandbox.d.ts +1 -1
- package/dist/lib/test-sandbox.js +32 -38
- package/dist/lib/test-specs.js +1 -1
- 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 +238 -0
- package/dist/lib/validate-helpers.d.ts +0 -8
- package/dist/lib/validate-helpers.js +0 -30
- package/dist/lib/validate.d.ts +6 -4
- package/dist/lib/validate.js +76 -27
- package/dist/lib/workflow-definitions.d.ts +12 -11
- package/dist/lib/workflow-definitions.js +45 -55
- 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-primitives.d.ts +2 -0
- package/dist/lib/workflow-primitives.js +5 -0
- 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 +13 -12
- 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/workflow-abi.js +0 -181
- 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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const COMPILED_INTERF_DIR = ".interf";
|
|
2
|
+
export declare const COMPILED_CONFIG_FILE = "interf.json";
|
|
3
|
+
export declare const COMPILED_WORKFLOW_DIR = "workflow";
|
|
4
|
+
export declare const COMPILED_TEST_DIR = "tests";
|
|
5
|
+
export declare const COMPILED_TEST_TARGETS_DIR = "targets";
|
|
6
|
+
export declare const COMPILED_RUNTIME_DIR = "runtime";
|
|
7
|
+
export declare const COMPILED_RUNTIME_STATE_FILE = "state.json";
|
|
8
|
+
export declare const COMPILED_RUNTIME_HEALTH_FILE = "health.json";
|
|
9
|
+
export declare const COMPILED_RUNTIME_VIEW_SPEC_FILE = "view-spec.json";
|
|
10
|
+
export declare const COMPILED_RUNTIME_RAW_SNAPSHOT_FILE = "raw-snapshot.json";
|
|
11
|
+
export declare const COMPILED_RUNTIME_INVENTORY_FILE = "inventory.json";
|
|
12
|
+
export declare const COMPILED_RUNTIME_RUN_FILE = "run.json";
|
|
13
|
+
export declare const COMPILED_RUNTIME_RUN_HISTORY_FILE = "run-history.jsonl";
|
|
14
|
+
export declare const COMPILED_RUNTIME_STAGE_CONTRACT_FILE = "stage-contract.json";
|
|
15
|
+
export declare function compiledRuntimeRoot(compiledPath: string): string;
|
|
16
|
+
export declare function compiledRuntimeFilePath(compiledPath: string, fileName: string): string;
|
|
17
|
+
export declare function compiledInterfRoot(compiledPath: string): string;
|
|
18
|
+
export declare function compiledInterfConfigPath(compiledPath: string): string;
|
|
19
|
+
export declare function workflowPackagePathForCompiled(compiledPath: string): string;
|
|
20
|
+
export declare function testRootForCompiled(compiledPath: string): string;
|
|
21
|
+
export declare function testTargetsRootForCompiled(compiledPath: string): string;
|
|
22
|
+
export declare function stageExecutionShellsRoot(compiledPath: string): string;
|
|
23
|
+
export declare function workflowImprovementLoopsRoot(compiledPath: string): string;
|
|
24
|
+
export declare function workflowImprovementRunRoot(compiledPath: string, runId: string): string;
|
|
25
|
+
export declare function workflowImprovementLoopRoot(compiledPath: string, runId: string, loopIndex: number): string;
|
|
26
|
+
export declare function targetTestRunsRootForCompiled(compiledPath: string): string;
|
|
27
|
+
export declare function targetTestSandboxesRootForCompiled(compiledPath: string): string;
|
|
28
|
+
export declare function compiledRuntimeLogsRoot(compiledPath: string): string;
|
|
29
|
+
export declare function compiledQueryAcceptanceRoot(compiledPath: string): string;
|
|
30
|
+
export declare function compiledRuntimeStatePath(compiledPath: string): string;
|
|
31
|
+
export declare function compiledRuntimeHealthPath(compiledPath: string): string;
|
|
32
|
+
export declare function compiledRuntimeViewSpecPath(compiledPath: string): string;
|
|
33
|
+
export declare function compiledRawSnapshotMetadataPath(compiledPath: string): string;
|
|
34
|
+
export declare function compiledRuntimeInventoryPath(compiledPath: string): string;
|
|
35
|
+
export declare function compiledRuntimeRunPath(compiledPath: string): string;
|
|
36
|
+
export declare function compiledRuntimeRunHistoryPath(compiledPath: string): string;
|
|
37
|
+
export declare function compiledRuntimeStageContractPath(compiledPath: string): string;
|
|
38
|
+
export declare function resolveSourceControlPathForCompiled(compiledPath: string): string;
|
|
39
|
+
export declare function defaultControlPathForCompiled(compiledPath: string): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
2
|
+
export const COMPILED_INTERF_DIR = ".interf";
|
|
3
|
+
export const COMPILED_CONFIG_FILE = "interf.json";
|
|
4
|
+
export const COMPILED_WORKFLOW_DIR = "workflow";
|
|
5
|
+
export const COMPILED_TEST_DIR = "tests";
|
|
6
|
+
export const COMPILED_TEST_TARGETS_DIR = "targets";
|
|
7
|
+
export const COMPILED_RUNTIME_DIR = "runtime";
|
|
8
|
+
export const COMPILED_RUNTIME_STATE_FILE = "state.json";
|
|
9
|
+
export const COMPILED_RUNTIME_HEALTH_FILE = "health.json";
|
|
10
|
+
export const COMPILED_RUNTIME_VIEW_SPEC_FILE = "view-spec.json";
|
|
11
|
+
export const COMPILED_RUNTIME_RAW_SNAPSHOT_FILE = "raw-snapshot.json";
|
|
12
|
+
export const COMPILED_RUNTIME_INVENTORY_FILE = "inventory.json";
|
|
13
|
+
export const COMPILED_RUNTIME_RUN_FILE = "run.json";
|
|
14
|
+
export const COMPILED_RUNTIME_RUN_HISTORY_FILE = "run-history.jsonl";
|
|
15
|
+
export const COMPILED_RUNTIME_STAGE_CONTRACT_FILE = "stage-contract.json";
|
|
16
|
+
export function compiledRuntimeRoot(compiledPath) {
|
|
17
|
+
return join(compiledPath, COMPILED_INTERF_DIR, COMPILED_RUNTIME_DIR);
|
|
18
|
+
}
|
|
19
|
+
export function compiledRuntimeFilePath(compiledPath, fileName) {
|
|
20
|
+
return join(compiledRuntimeRoot(compiledPath), fileName);
|
|
21
|
+
}
|
|
22
|
+
export function compiledInterfRoot(compiledPath) {
|
|
23
|
+
return join(compiledPath, COMPILED_INTERF_DIR);
|
|
24
|
+
}
|
|
25
|
+
export function compiledInterfConfigPath(compiledPath) {
|
|
26
|
+
return join(compiledInterfRoot(compiledPath), COMPILED_CONFIG_FILE);
|
|
27
|
+
}
|
|
28
|
+
export function workflowPackagePathForCompiled(compiledPath) {
|
|
29
|
+
return join(compiledInterfRoot(compiledPath), COMPILED_WORKFLOW_DIR);
|
|
30
|
+
}
|
|
31
|
+
export function testRootForCompiled(compiledPath) {
|
|
32
|
+
return join(compiledInterfRoot(compiledPath), COMPILED_TEST_DIR);
|
|
33
|
+
}
|
|
34
|
+
export function testTargetsRootForCompiled(compiledPath) {
|
|
35
|
+
return join(testRootForCompiled(compiledPath), COMPILED_TEST_TARGETS_DIR);
|
|
36
|
+
}
|
|
37
|
+
export function stageExecutionShellsRoot(compiledPath) {
|
|
38
|
+
return join(compiledRuntimeRoot(compiledPath), "execution-shells");
|
|
39
|
+
}
|
|
40
|
+
export function workflowImprovementLoopsRoot(compiledPath) {
|
|
41
|
+
return join(compiledRuntimeRoot(compiledPath), "improvement-loops");
|
|
42
|
+
}
|
|
43
|
+
export function workflowImprovementRunRoot(compiledPath, runId) {
|
|
44
|
+
return join(workflowImprovementLoopsRoot(compiledPath), runId);
|
|
45
|
+
}
|
|
46
|
+
export function workflowImprovementLoopRoot(compiledPath, runId, loopIndex) {
|
|
47
|
+
return join(workflowImprovementRunRoot(compiledPath, runId), `loop-${String(loopIndex).padStart(2, "0")}`);
|
|
48
|
+
}
|
|
49
|
+
export function targetTestRunsRootForCompiled(compiledPath) {
|
|
50
|
+
return join(testTargetsRootForCompiled(compiledPath), "runs");
|
|
51
|
+
}
|
|
52
|
+
export function targetTestSandboxesRootForCompiled(compiledPath) {
|
|
53
|
+
return join(testTargetsRootForCompiled(compiledPath), "sandboxes");
|
|
54
|
+
}
|
|
55
|
+
export function compiledRuntimeLogsRoot(compiledPath) {
|
|
56
|
+
return join(compiledRuntimeRoot(compiledPath), "logs");
|
|
57
|
+
}
|
|
58
|
+
export function compiledQueryAcceptanceRoot(compiledPath) {
|
|
59
|
+
return join(compiledRuntimeRoot(compiledPath), "query-acceptance");
|
|
60
|
+
}
|
|
61
|
+
export function compiledRuntimeStatePath(compiledPath) {
|
|
62
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_STATE_FILE);
|
|
63
|
+
}
|
|
64
|
+
export function compiledRuntimeHealthPath(compiledPath) {
|
|
65
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_HEALTH_FILE);
|
|
66
|
+
}
|
|
67
|
+
export function compiledRuntimeViewSpecPath(compiledPath) {
|
|
68
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_VIEW_SPEC_FILE);
|
|
69
|
+
}
|
|
70
|
+
export function compiledRawSnapshotMetadataPath(compiledPath) {
|
|
71
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_RAW_SNAPSHOT_FILE);
|
|
72
|
+
}
|
|
73
|
+
export function compiledRuntimeInventoryPath(compiledPath) {
|
|
74
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_INVENTORY_FILE);
|
|
75
|
+
}
|
|
76
|
+
export function compiledRuntimeRunPath(compiledPath) {
|
|
77
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_RUN_FILE);
|
|
78
|
+
}
|
|
79
|
+
export function compiledRuntimeRunHistoryPath(compiledPath) {
|
|
80
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_RUN_HISTORY_FILE);
|
|
81
|
+
}
|
|
82
|
+
export function compiledRuntimeStageContractPath(compiledPath) {
|
|
83
|
+
return compiledRuntimeFilePath(compiledPath, COMPILED_RUNTIME_STAGE_CONTRACT_FILE);
|
|
84
|
+
}
|
|
85
|
+
export function resolveSourceControlPathForCompiled(compiledPath) {
|
|
86
|
+
let cursor = resolve(compiledPath);
|
|
87
|
+
while (true) {
|
|
88
|
+
const parent = dirname(cursor);
|
|
89
|
+
if (basename(parent) === "interf" &&
|
|
90
|
+
basename(cursor) !== "tests" &&
|
|
91
|
+
basename(cursor) !== "workflows") {
|
|
92
|
+
return dirname(parent);
|
|
93
|
+
}
|
|
94
|
+
if (parent === cursor)
|
|
95
|
+
break;
|
|
96
|
+
cursor = parent;
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Compiled dataset is not under the canonical project layout: ${compiledPath}`);
|
|
99
|
+
}
|
|
100
|
+
export function defaultControlPathForCompiled(compiledPath) {
|
|
101
|
+
const relativePath = relative(compiledPath, resolveSourceControlPathForCompiled(compiledPath));
|
|
102
|
+
return relativePath.length > 0 ? relativePath.split(sep).join("/") : ".";
|
|
103
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { InterfConfig } from "./schema.js";
|
|
2
|
-
export interface
|
|
2
|
+
export interface CompiledRawSyncResult {
|
|
3
3
|
sourceTotal: number;
|
|
4
4
|
copied: number;
|
|
5
5
|
removed: number;
|
|
6
6
|
}
|
|
7
7
|
type RawSnapshotMaterializeMode = "copy" | "link-or-copy";
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function resolveCompiledRawPath(compiledPath: string, config?: {
|
|
9
9
|
[x: string]: unknown;
|
|
10
|
-
type: "
|
|
10
|
+
type: "compiled";
|
|
11
11
|
name: string;
|
|
12
|
+
workflow: string;
|
|
12
13
|
checks: {
|
|
13
14
|
question: string;
|
|
14
15
|
id?: string | undefined;
|
|
@@ -24,10 +25,10 @@ export declare function resolveWorkspaceRawPath(workspacePath: string, config?:
|
|
|
24
25
|
}[];
|
|
25
26
|
source: {
|
|
26
27
|
path: string;
|
|
28
|
+
dataset_path: string;
|
|
27
29
|
control_path?: string | undefined;
|
|
28
30
|
};
|
|
29
31
|
about?: string | undefined;
|
|
30
|
-
workflow?: string | undefined;
|
|
31
32
|
max_attempts?: number | undefined;
|
|
32
33
|
max_loops?: number | undefined;
|
|
33
34
|
workflow_origin?: {
|
|
@@ -35,14 +36,14 @@ export declare function resolveWorkspaceRawPath(workspacePath: string, config?:
|
|
|
35
36
|
local_draft?: boolean | undefined;
|
|
36
37
|
} | undefined;
|
|
37
38
|
} | null): string;
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function
|
|
39
|
+
export declare function syncCompiledRawSnapshot(compiledPath: string, sourcePath?: string): CompiledRawSyncResult;
|
|
40
|
+
export declare function ensureCompiledRawBinding(compiledPath: string): InterfConfig | null;
|
|
40
41
|
export declare function projectRawSnapshot(options: {
|
|
41
42
|
sourcePath: string;
|
|
42
43
|
destinationPath: string;
|
|
43
|
-
|
|
44
|
+
compiledPath: string;
|
|
44
45
|
mode?: RawSnapshotMaterializeMode;
|
|
45
46
|
prune?: boolean;
|
|
46
47
|
preserveTimestamps?: boolean;
|
|
47
|
-
}):
|
|
48
|
+
}): CompiledRawSyncResult;
|
|
48
49
|
export {};
|
|
@@ -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 "./builtin-compiled-workflow.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 "./builtin-compiled-workflow.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 "./builtin-compiled-workflow.js";
|
|
5
|
+
import { WorkflowCompiledSchemaSchema, } from "./schema.js";
|
|
6
|
+
export { BUILTIN_COMPILED_ZONE_IDS } from "./builtin-compiled-workflow.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,15 @@
|
|
|
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 prepareWorkspaceLayout(dirPath: string): boolean;
|
|
15
13
|
export declare function readInterfConfig(dirPath: string): InterfConfig | null;
|
|
16
14
|
export declare function hasSourceFolderInput(config: InterfConfig | null | undefined): config is InterfConfig & {
|
|
17
15
|
source: {
|
|
@@ -22,13 +20,14 @@ export declare function detectInterf(cwd: string): {
|
|
|
22
20
|
path: string;
|
|
23
21
|
config: InterfConfig;
|
|
24
22
|
} | null;
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function resolveSourceFolderPath(
|
|
27
|
-
export declare function resolveSourceControlPath(
|
|
28
|
-
export declare function
|
|
23
|
+
export declare function resolveCompiled(cwd: string): ResolvedCompiled | null;
|
|
24
|
+
export declare function resolveSourceFolderPath(compiledPath: string, config?: InterfConfig | null): string;
|
|
25
|
+
export declare function resolveSourceControlPath(compiledPath: string): string;
|
|
26
|
+
export declare function resolveSourceInputPath(compiledPath: string): string;
|
|
27
|
+
export declare function listCompiledDatasetsForSourceFolder(sourcePath: string): Array<{
|
|
29
28
|
path: string;
|
|
30
29
|
config: InterfConfig;
|
|
31
30
|
}>;
|
|
32
|
-
export declare function
|
|
31
|
+
export declare function assertCompiledContainer(sourcePath: string): string;
|
|
33
32
|
export declare function assertWritableTargetDir(dirPath: string, label: string): void;
|
|
34
|
-
export declare function
|
|
33
|
+
export declare function assertCompiledName(name: string, label: string): void;
|