@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.
Files changed (160) hide show
  1. package/README.md +71 -69
  2. package/builtin-workflows/interf/README.md +6 -6
  3. package/builtin-workflows/interf/compile/stages/shape/SKILL.md +7 -7
  4. package/builtin-workflows/interf/compile/stages/structure/SKILL.md +2 -2
  5. package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +1 -1
  6. package/builtin-workflows/interf/{workspace.schema.json → compiled.schema.json} +5 -5
  7. package/builtin-workflows/interf/improve/SKILL.md +3 -3
  8. package/builtin-workflows/interf/use/query/SKILL.md +2 -2
  9. package/builtin-workflows/interf/workflow.json +42 -31
  10. package/dist/commands/check-draft.d.ts +19 -0
  11. package/dist/commands/check-draft.js +110 -0
  12. package/dist/commands/compile-controller.d.ts +4 -4
  13. package/dist/commands/compile-controller.js +117 -81
  14. package/dist/commands/compile.d.ts +5 -5
  15. package/dist/commands/compile.js +61 -62
  16. package/dist/commands/compiled-flow.d.ts +23 -0
  17. package/dist/commands/compiled-flow.js +112 -0
  18. package/dist/commands/create-workflow-wizard.d.ts +3 -3
  19. package/dist/commands/create-workflow-wizard.js +11 -11
  20. package/dist/commands/create.d.ts +2 -2
  21. package/dist/commands/create.js +50 -57
  22. package/dist/commands/default.js +2 -2
  23. package/dist/commands/executor-flow.d.ts +20 -1
  24. package/dist/commands/executor-flow.js +67 -7
  25. package/dist/commands/init.js +242 -289
  26. package/dist/commands/list.js +14 -10
  27. package/dist/commands/reset.js +6 -6
  28. package/dist/commands/source-config-wizard.d.ts +12 -8
  29. package/dist/commands/source-config-wizard.js +356 -119
  30. package/dist/commands/status.js +49 -26
  31. package/dist/commands/test-flow.d.ts +23 -10
  32. package/dist/commands/test-flow.js +278 -58
  33. package/dist/commands/test.d.ts +7 -1
  34. package/dist/commands/test.js +264 -65
  35. package/dist/commands/verify.js +23 -14
  36. package/dist/index.d.ts +7 -7
  37. package/dist/index.js +4 -4
  38. package/dist/lib/agent-args.js +2 -1
  39. package/dist/lib/agent-constants.js +1 -1
  40. package/dist/lib/agent-render.js +4 -4
  41. package/dist/lib/agent-shells.d.ts +8 -8
  42. package/dist/lib/agent-shells.js +231 -142
  43. package/dist/lib/compiled-compile.d.ts +52 -0
  44. package/dist/lib/compiled-compile.js +274 -0
  45. package/dist/lib/compiled-home.d.ts +5 -0
  46. package/dist/lib/compiled-home.js +32 -0
  47. package/dist/lib/compiled-layout.d.ts +2 -0
  48. package/dist/lib/compiled-layout.js +60 -0
  49. package/dist/lib/compiled-paths.d.ts +41 -0
  50. package/dist/lib/compiled-paths.js +111 -0
  51. package/dist/lib/{workspace-raw.d.ts → compiled-raw.d.ts} +8 -7
  52. package/dist/lib/{workspace-raw.js → compiled-raw.js} +16 -14
  53. package/dist/lib/compiled-reset.d.ts +1 -0
  54. package/dist/lib/compiled-reset.js +44 -0
  55. package/dist/lib/compiled-schema.d.ts +27 -0
  56. package/dist/lib/compiled-schema.js +110 -0
  57. package/dist/lib/config.d.ts +0 -1
  58. package/dist/lib/config.js +0 -1
  59. package/dist/lib/discovery.d.ts +1 -1
  60. package/dist/lib/discovery.js +3 -3
  61. package/dist/lib/interf-bootstrap.d.ts +1 -1
  62. package/dist/lib/interf-bootstrap.js +4 -4
  63. package/dist/lib/interf-detect.d.ts +10 -10
  64. package/dist/lib/interf-detect.js +78 -56
  65. package/dist/lib/interf-scaffold.d.ts +2 -2
  66. package/dist/lib/interf-scaffold.js +90 -57
  67. package/dist/lib/interf-workflow-package.d.ts +3 -3
  68. package/dist/lib/interf-workflow-package.js +30 -30
  69. package/dist/lib/interf.d.ts +5 -5
  70. package/dist/lib/interf.js +4 -4
  71. package/dist/lib/local-workflows.d.ts +4 -4
  72. package/dist/lib/local-workflows.js +35 -70
  73. package/dist/lib/obsidian.d.ts +1 -1
  74. package/dist/lib/parse.js +92 -1
  75. package/dist/lib/project-paths.d.ts +13 -0
  76. package/dist/lib/project-paths.js +29 -0
  77. package/dist/lib/runtime-acceptance.d.ts +7 -1
  78. package/dist/lib/runtime-acceptance.js +194 -59
  79. package/dist/lib/runtime-contracts.d.ts +2 -4
  80. package/dist/lib/runtime-contracts.js +17 -161
  81. package/dist/lib/runtime-inventory.d.ts +7 -0
  82. package/dist/lib/runtime-inventory.js +29 -0
  83. package/dist/lib/runtime-paths.js +5 -5
  84. package/dist/lib/runtime-prompt.js +9 -6
  85. package/dist/lib/runtime-reconcile.d.ts +2 -3
  86. package/dist/lib/runtime-reconcile.js +92 -171
  87. package/dist/lib/runtime-runs.js +30 -39
  88. package/dist/lib/runtime-types.d.ts +10 -19
  89. package/dist/lib/runtime.d.ts +2 -2
  90. package/dist/lib/runtime.js +1 -1
  91. package/dist/lib/schema.d.ts +163 -140
  92. package/dist/lib/schema.js +163 -124
  93. package/dist/lib/source-config.d.ts +24 -20
  94. package/dist/lib/source-config.js +154 -116
  95. package/dist/lib/state-artifacts.d.ts +5 -5
  96. package/dist/lib/state-artifacts.js +8 -8
  97. package/dist/lib/state-health.d.ts +4 -4
  98. package/dist/lib/state-health.js +108 -126
  99. package/dist/lib/state-io.d.ts +8 -8
  100. package/dist/lib/state-io.js +77 -50
  101. package/dist/lib/state-paths.js +5 -5
  102. package/dist/lib/state-view.d.ts +4 -4
  103. package/dist/lib/state-view.js +52 -55
  104. package/dist/lib/state.d.ts +5 -5
  105. package/dist/lib/state.js +4 -4
  106. package/dist/lib/summarize-plan.d.ts +3 -2
  107. package/dist/lib/summarize-plan.js +18 -16
  108. package/dist/lib/test-execution.js +9 -9
  109. package/dist/lib/test-matrices.d.ts +3 -3
  110. package/dist/lib/test-matrices.js +6 -6
  111. package/dist/lib/test-paths.d.ts +4 -4
  112. package/dist/lib/test-paths.js +16 -10
  113. package/dist/lib/test-sandbox.d.ts +1 -1
  114. package/dist/lib/test-sandbox.js +38 -31
  115. package/dist/lib/test-targets.d.ts +2 -2
  116. package/dist/lib/test-targets.js +11 -11
  117. package/dist/lib/test-types.d.ts +1 -1
  118. package/dist/lib/test.d.ts +1 -1
  119. package/dist/lib/test.js +1 -1
  120. package/dist/lib/util.d.ts +2 -0
  121. package/dist/lib/util.js +14 -1
  122. package/dist/lib/validate-compiled.d.ts +27 -0
  123. package/dist/lib/validate-compiled.js +236 -0
  124. package/dist/lib/validate-helpers.d.ts +0 -8
  125. package/dist/lib/validate-helpers.js +0 -30
  126. package/dist/lib/validate.d.ts +4 -4
  127. package/dist/lib/validate.js +49 -15
  128. package/dist/lib/workflow-abi.d.ts +37 -46
  129. package/dist/lib/workflow-abi.js +51 -76
  130. package/dist/lib/workflow-definitions.d.ts +11 -11
  131. package/dist/lib/workflow-definitions.js +36 -53
  132. package/dist/lib/workflow-helpers.d.ts +2 -3
  133. package/dist/lib/workflow-helpers.js +9 -13
  134. package/dist/lib/workflow-improvement.d.ts +3 -3
  135. package/dist/lib/workflow-improvement.js +48 -48
  136. package/dist/lib/workflow-review-paths.d.ts +3 -3
  137. package/dist/lib/workflow-review-paths.js +11 -11
  138. package/dist/lib/workflow-stage-runner.d.ts +1 -1
  139. package/dist/lib/workflow-stage-runner.js +8 -8
  140. package/dist/lib/workflows.d.ts +9 -9
  141. package/dist/lib/workflows.js +15 -17
  142. package/package.json +10 -9
  143. package/dist/commands/workspace-flow.d.ts +0 -23
  144. package/dist/commands/workspace-flow.js +0 -109
  145. package/dist/lib/registry.d.ts +0 -16
  146. package/dist/lib/registry.js +0 -65
  147. package/dist/lib/validate-workspace.d.ts +0 -121
  148. package/dist/lib/validate-workspace.js +0 -407
  149. package/dist/lib/workspace-compile.d.ts +0 -54
  150. package/dist/lib/workspace-compile.js +0 -476
  151. package/dist/lib/workspace-home.d.ts +0 -5
  152. package/dist/lib/workspace-home.js +0 -32
  153. package/dist/lib/workspace-layout.d.ts +0 -2
  154. package/dist/lib/workspace-layout.js +0 -60
  155. package/dist/lib/workspace-paths.d.ts +0 -41
  156. package/dist/lib/workspace-paths.js +0 -107
  157. package/dist/lib/workspace-reset.d.ts +0 -1
  158. package/dist/lib/workspace-reset.js +0 -43
  159. package/dist/lib/workspace-schema.d.ts +0 -17
  160. package/dist/lib/workspace-schema.js +0 -74
@@ -1,107 +0,0 @@
1
- import { basename, dirname, join, relative, resolve, sep } from "node:path";
2
- export const WORKSPACE_INTERF_DIR = ".interf";
3
- export const WORKSPACE_CONFIG_FILE = "interf.json";
4
- export const WORKSPACE_WORKFLOW_DIR = "workflow";
5
- export const WORKSPACE_TEST_DIR = "tests";
6
- export const WORKSPACE_TEST_TARGETS_DIR = "targets";
7
- export const WORKSPACE_RUNTIME_DIR = "runtime";
8
- export const WORKSPACE_RUNTIME_STATE_FILE = "state.json";
9
- export const WORKSPACE_RUNTIME_HEALTH_FILE = "health.json";
10
- export const WORKSPACE_RUNTIME_VIEW_SPEC_FILE = "view-spec.json";
11
- export const WORKSPACE_RUNTIME_RAW_SNAPSHOT_FILE = "raw-snapshot.json";
12
- export const WORKSPACE_RUNTIME_INVENTORY_FILE = "inventory.json";
13
- export const WORKSPACE_RUNTIME_RUN_FILE = "run.json";
14
- export const WORKSPACE_RUNTIME_RUN_HISTORY_FILE = "run-history.jsonl";
15
- export const WORKSPACE_RUNTIME_STAGE_CONTRACT_FILE = "stage-contract.json";
16
- export function workspaceRuntimeRoot(workspacePath) {
17
- return join(workspacePath, WORKSPACE_INTERF_DIR, WORKSPACE_RUNTIME_DIR);
18
- }
19
- export function workspaceRuntimeFilePath(workspacePath, fileName) {
20
- return join(workspaceRuntimeRoot(workspacePath), fileName);
21
- }
22
- export function workspaceInterfRoot(workspacePath) {
23
- return join(workspacePath, WORKSPACE_INTERF_DIR);
24
- }
25
- export function workspaceInterfConfigPath(workspacePath) {
26
- return join(workspaceInterfRoot(workspacePath), WORKSPACE_CONFIG_FILE);
27
- }
28
- export function workflowPackagePathForWorkspace(workspacePath) {
29
- return join(workspaceInterfRoot(workspacePath), WORKSPACE_WORKFLOW_DIR);
30
- }
31
- export function testRootForWorkspace(workspacePath) {
32
- return join(workspaceInterfRoot(workspacePath), WORKSPACE_TEST_DIR);
33
- }
34
- export function testRunsRootForWorkspace(workspacePath) {
35
- return join(testRootForWorkspace(workspacePath), "runs");
36
- }
37
- export function testTargetsRootForWorkspace(workspacePath) {
38
- return join(testRootForWorkspace(workspacePath), WORKSPACE_TEST_TARGETS_DIR);
39
- }
40
- export function latestTestComparisonPathForWorkspace(workspacePath) {
41
- return join(testRootForWorkspace(workspacePath), "latest.json");
42
- }
43
- export function stageExecutionShellsRoot(workspacePath) {
44
- return join(workspaceRuntimeRoot(workspacePath), "execution-shells");
45
- }
46
- export function workflowImprovementLoopsRoot(workspacePath) {
47
- return join(workspaceRuntimeRoot(workspacePath), "improvement-loops");
48
- }
49
- export function workflowImprovementRunRoot(workspacePath, runId) {
50
- return join(workflowImprovementLoopsRoot(workspacePath), runId);
51
- }
52
- export function workflowImprovementLoopRoot(workspacePath, runId, loopIndex) {
53
- return join(workflowImprovementRunRoot(workspacePath, runId), `loop-${String(loopIndex).padStart(2, "0")}`);
54
- }
55
- export function targetTestRunsRootForWorkspace(workspacePath) {
56
- return join(testTargetsRootForWorkspace(workspacePath), "runs");
57
- }
58
- export function targetTestSandboxesRootForWorkspace(workspacePath) {
59
- return join(testTargetsRootForWorkspace(workspacePath), "sandboxes");
60
- }
61
- export function workspaceRuntimeLogsRoot(workspacePath) {
62
- return join(workspaceRuntimeRoot(workspacePath), "logs");
63
- }
64
- export function workspaceQueryAcceptanceRoot(workspacePath) {
65
- return join(workspaceRuntimeRoot(workspacePath), "query-acceptance");
66
- }
67
- export function workspaceRuntimeStatePath(workspacePath) {
68
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_STATE_FILE);
69
- }
70
- export function workspaceRuntimeHealthPath(workspacePath) {
71
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_HEALTH_FILE);
72
- }
73
- export function workspaceRuntimeViewSpecPath(workspacePath) {
74
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_VIEW_SPEC_FILE);
75
- }
76
- export function workspaceRawSnapshotMetadataPath(workspacePath) {
77
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_RAW_SNAPSHOT_FILE);
78
- }
79
- export function workspaceRuntimeInventoryPath(workspacePath) {
80
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_INVENTORY_FILE);
81
- }
82
- export function workspaceRuntimeRunPath(workspacePath) {
83
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_RUN_FILE);
84
- }
85
- export function workspaceRuntimeRunHistoryPath(workspacePath) {
86
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_RUN_HISTORY_FILE);
87
- }
88
- export function workspaceRuntimeStageContractPath(workspacePath) {
89
- return workspaceRuntimeFilePath(workspacePath, WORKSPACE_RUNTIME_STAGE_CONTRACT_FILE);
90
- }
91
- export function resolveSourceControlPathForWorkspace(workspacePath) {
92
- let cursor = resolve(workspacePath);
93
- while (true) {
94
- const parent = dirname(cursor);
95
- if (parent === cursor)
96
- break;
97
- if (basename(parent) === "workspaces" && basename(dirname(parent)) === "interf") {
98
- return dirname(dirname(parent));
99
- }
100
- cursor = parent;
101
- }
102
- return resolve(workspacePath, "..", "..", "..");
103
- }
104
- export function defaultControlPathForWorkspace(workspacePath) {
105
- const relativePath = relative(workspacePath, resolveSourceControlPathForWorkspace(workspacePath));
106
- return relativePath.length > 0 ? relativePath.split(sep).join("/") : ".";
107
- }
@@ -1 +0,0 @@
1
- export declare function resetWorkspaceGeneratedState(workspacePath: string, scope?: "compile" | "all"): void;
@@ -1,43 +0,0 @@
1
- import { existsSync, rmSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { initWorkspaceState, refreshWorkspaceArtifacts, saveState, } from "./state.js";
4
- import { saveEmptyWorkspaceInventory } from "./state-io.js";
5
- import { stageExecutionShellsRoot, testRootForWorkspace, testTargetsRootForWorkspace, workflowImprovementLoopsRoot, workspaceQueryAcceptanceRoot, workspaceRuntimeRoot, workspaceRuntimeLogsRoot, } from "./workspace-paths.js";
6
- function removeIfExists(path) {
7
- if (existsSync(path)) {
8
- rmSync(path, { recursive: true, force: true });
9
- }
10
- }
11
- const COMPILE_RUNTIME_RESET_ENTRIES = [
12
- "state.json",
13
- "health.json",
14
- "view-spec.json",
15
- "inventory.json",
16
- "run.json",
17
- "stage-contract.json",
18
- "summarize-targets.json",
19
- ];
20
- function resetWorkspaceRuntimeFiles(workspacePath) {
21
- const runtimeRoot = workspaceRuntimeRoot(workspacePath);
22
- for (const entry of COMPILE_RUNTIME_RESET_ENTRIES) {
23
- removeIfExists(join(runtimeRoot, entry));
24
- }
25
- removeIfExists(workspaceQueryAcceptanceRoot(workspacePath));
26
- }
27
- export function resetWorkspaceGeneratedState(workspacePath, scope = "compile") {
28
- removeIfExists(join(workspacePath, "summaries"));
29
- removeIfExists(join(workspacePath, "knowledge"));
30
- removeIfExists(join(workspacePath, ".obsidian"));
31
- resetWorkspaceRuntimeFiles(workspacePath);
32
- saveState(workspacePath, initWorkspaceState());
33
- saveEmptyWorkspaceInventory(workspacePath);
34
- refreshWorkspaceArtifacts(workspacePath, { ensureViewSpec: true });
35
- if (scope === "all") {
36
- removeIfExists(stageExecutionShellsRoot(workspacePath));
37
- removeIfExists(workflowImprovementLoopsRoot(workspacePath));
38
- removeIfExists(workspaceRuntimeLogsRoot(workspacePath));
39
- removeIfExists(join(workspaceRuntimeRoot(workspacePath), "run-history.jsonl"));
40
- removeIfExists(testRootForWorkspace(workspacePath));
41
- removeIfExists(testTargetsRootForWorkspace(workspacePath));
42
- }
43
- }
@@ -1,17 +0,0 @@
1
- import { type RuntimeContractType, type WorkflowWorkspaceSchema, type WorkflowWorkspaceZone, type WorkflowZoneId } from "./schema.js";
2
- export interface WorkflowSchemaStageLike {
3
- id: string;
4
- contractType?: RuntimeContractType;
5
- contract_type?: RuntimeContractType;
6
- }
7
- export { BUILTIN_WORKSPACE_ZONE_IDS } from "./workflow-abi.js";
8
- export declare const WORKSPACE_SCHEMA_FILE = "workspace.schema.json";
9
- export declare function workspaceSchemaFilePath(rootPath: string): string;
10
- export declare function workspaceSchemaRelativePath(): string;
11
- export declare function listWorkspaceSchemaZones(schema: WorkflowWorkspaceSchema): WorkflowWorkspaceZone[];
12
- export declare function findWorkspaceSchemaZone(schema: WorkflowWorkspaceSchema, zoneId: WorkflowZoneId): WorkflowWorkspaceZone | null;
13
- export declare function workspaceZoneAbsolutePath(workspacePath: string, zone: Pick<WorkflowWorkspaceZone, "path">): string;
14
- export declare function ensureWorkspaceZoneTargets(workspacePath: string, schema: WorkflowWorkspaceSchema): void;
15
- export declare function buildWorkspaceSchema(stages: WorkflowSchemaStageLike[], label?: string): WorkflowWorkspaceSchema;
16
- export declare function writeWorkspaceSchemaFile(rootPath: string, stages: WorkflowSchemaStageLike[], label?: string): WorkflowWorkspaceSchema;
17
- export declare function readWorkspaceSchemaFile(rootPath: string): WorkflowWorkspaceSchema | null;
@@ -1,74 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
- import { dirname, join } from "node:path";
3
- import { readJsonFileWithSchema } from "./parse.js";
4
- import { listBuiltinWorkspaceZoneSpecs, requiredWorkspaceZoneOwners, } from "./workflow-abi.js";
5
- import { WorkflowWorkspaceSchemaSchema, } from "./schema.js";
6
- export { BUILTIN_WORKSPACE_ZONE_IDS } from "./workflow-abi.js";
7
- export const WORKSPACE_SCHEMA_FILE = "workspace.schema.json";
8
- export function workspaceSchemaFilePath(rootPath) {
9
- return join(rootPath, WORKSPACE_SCHEMA_FILE);
10
- }
11
- export function workspaceSchemaRelativePath() {
12
- return `workflow/${WORKSPACE_SCHEMA_FILE}`;
13
- }
14
- export function listWorkspaceSchemaZones(schema) {
15
- return [...schema.zones];
16
- }
17
- export function findWorkspaceSchemaZone(schema, zoneId) {
18
- return schema.zones.find((zone) => zone.id === zoneId) ?? null;
19
- }
20
- export function workspaceZoneAbsolutePath(workspacePath, zone) {
21
- return join(workspacePath, zone.path);
22
- }
23
- export function ensureWorkspaceZoneTargets(workspacePath, schema) {
24
- for (const zone of schema.zones) {
25
- if (zone.kind === "directory" || zone.kind === "runtime") {
26
- mkdirSync(workspaceZoneAbsolutePath(workspacePath, zone), { recursive: true });
27
- continue;
28
- }
29
- mkdirSync(dirname(workspaceZoneAbsolutePath(workspacePath, zone)), { recursive: true });
30
- }
31
- }
32
- function stageContractType(stage) {
33
- return (stage.contractType ?? stage.contract_type);
34
- }
35
- function pushZone(zones, zone) {
36
- if (zones.some((existing) => existing.path === zone.path))
37
- return;
38
- zones.push(zone);
39
- }
40
- export function buildWorkspaceSchema(stages, label = "Compiled workspace schema") {
41
- const zones = [];
42
- const normalizedStages = stages.map((stage) => ({
43
- id: stage.id,
44
- contractType: stageContractType(stage),
45
- }));
46
- for (const zone of listBuiltinWorkspaceZoneSpecs()) {
47
- pushZone(zones, {
48
- id: zone.id,
49
- path: zone.path,
50
- kind: zone.kind,
51
- required: zone.required,
52
- owned_by: requiredWorkspaceZoneOwners(normalizedStages, zone.id),
53
- description: zone.description,
54
- });
55
- }
56
- return {
57
- kind: "workspace-schema",
58
- version: 1,
59
- target_type: "workspace",
60
- label,
61
- zones,
62
- };
63
- }
64
- export function writeWorkspaceSchemaFile(rootPath, stages, label) {
65
- const schema = buildWorkspaceSchema(stages, label);
66
- writeFileSync(workspaceSchemaFilePath(rootPath), `${JSON.stringify(schema, null, 2)}\n`);
67
- return schema;
68
- }
69
- export function readWorkspaceSchemaFile(rootPath) {
70
- const path = workspaceSchemaFilePath(rootPath);
71
- if (!existsSync(path))
72
- return null;
73
- return readJsonFileWithSchema(path, "workspace schema", WorkflowWorkspaceSchemaSchema);
74
- }