@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
package/dist/lib/schema.js
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { COMPILED_ZONE_KINDS, } from "./workflow-primitives.js";
|
|
3
3
|
const JsonRecordSchema = z.record(z.string(), z.unknown());
|
|
4
|
-
const
|
|
5
|
-
function
|
|
4
|
+
const COMPILED_RELATIVE_PATH_SEGMENT = /^(?!\.{1,2}$)[^/\\]+$/;
|
|
5
|
+
function isCompiledRelativePath(value) {
|
|
6
6
|
if (value.length === 0)
|
|
7
7
|
return false;
|
|
8
8
|
if (value.startsWith("/") || value.startsWith("\\"))
|
|
9
9
|
return false;
|
|
10
10
|
return value
|
|
11
11
|
.split(/[\\/]+/)
|
|
12
|
-
.every((segment) =>
|
|
12
|
+
.every((segment) => COMPILED_RELATIVE_PATH_SEGMENT.test(segment));
|
|
13
13
|
}
|
|
14
|
-
export const RuntimeTargetTypeSchema = z.enum(["
|
|
15
|
-
export const TestTargetTypeSchema = z.enum(["
|
|
14
|
+
export const RuntimeTargetTypeSchema = z.enum(["compiled"]);
|
|
15
|
+
export const TestTargetTypeSchema = z.enum(["compiled", "raw"]);
|
|
16
16
|
export const WorkflowIdPattern = /^[a-z0-9][a-z0-9-]{0,79}$/;
|
|
17
17
|
export const RuntimeStageSchema = z.string().regex(WorkflowIdPattern);
|
|
18
|
-
export const RuntimeContractTypeSchema = z.
|
|
18
|
+
export const RuntimeContractTypeSchema = z.string().regex(WorkflowIdPattern);
|
|
19
19
|
export const WorkflowIdSchema = z.string().regex(WorkflowIdPattern);
|
|
20
20
|
export const WorkflowZoneIdSchema = z.string().regex(WorkflowIdPattern);
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
|
|
21
|
+
export const WorkflowCompiledZoneKindSchema = z.enum(COMPILED_ZONE_KINDS);
|
|
22
|
+
export const CompiledStageStatusSchema = z.enum(["idle", "running", "succeeded", "failed"]);
|
|
23
|
+
export const CompiledStageStateSchema = z.object({
|
|
24
|
+
contract_type: RuntimeContractTypeSchema.optional(),
|
|
25
|
+
status: CompiledStageStatusSchema.optional(),
|
|
26
|
+
started_at: z.string().nullable().optional(),
|
|
27
|
+
finished_at: z.string().nullable().optional(),
|
|
28
|
+
counts: z.record(z.string(), z.number()).optional(),
|
|
29
|
+
zone_counts: z.record(z.string(), z.number()).optional(),
|
|
30
|
+
artifacts: z.array(z.string()).optional(),
|
|
31
|
+
summary: z.string().nullable().optional(),
|
|
32
|
+
run_id: z.string().nullable().optional(),
|
|
33
|
+
});
|
|
34
|
+
export const CompiledStateSchema = z.object({
|
|
35
|
+
version: z.number().int().min(1),
|
|
24
36
|
pending: z.array(z.string()),
|
|
25
|
-
|
|
26
|
-
structured: z.number().optional(),
|
|
27
|
-
shaped: z.number().optional(),
|
|
28
|
-
compiled: z.number(),
|
|
37
|
+
stages: z.record(z.string().regex(WorkflowIdPattern), CompiledStageStateSchema).optional(),
|
|
29
38
|
last_add: z.string().nullable().optional(),
|
|
30
|
-
last_summarize: z.string().nullable().optional(),
|
|
31
|
-
last_structure: z.string().nullable().optional(),
|
|
32
|
-
last_shape: z.string().nullable().optional(),
|
|
33
39
|
last_compile: z.string().nullable().optional(),
|
|
34
40
|
inventory_complete: z.boolean().optional(),
|
|
35
41
|
abstracts_read: z.number().optional(),
|
|
@@ -38,7 +44,7 @@ export const WorkspaceStateSchema = z.object({
|
|
|
38
44
|
claim_count: z.number().optional(),
|
|
39
45
|
warning_count: z.number().optional(),
|
|
40
46
|
error_count: z.number().optional(),
|
|
41
|
-
});
|
|
47
|
+
}).strict();
|
|
42
48
|
export const ViewSectionSchema = z.object({
|
|
43
49
|
id: z.string(),
|
|
44
50
|
type: z.enum(["status", "cards", "graph", "documents", "table"]),
|
|
@@ -53,57 +59,34 @@ export const ViewCardSchema = z.object({
|
|
|
53
59
|
denominator_metric: z.string().optional(),
|
|
54
60
|
format: z.enum(["number", "fraction", "timestamp"]),
|
|
55
61
|
});
|
|
56
|
-
export const
|
|
57
|
-
kind: z.literal("
|
|
58
|
-
version: z.
|
|
62
|
+
export const CompiledHealthSchema = z.object({
|
|
63
|
+
kind: z.literal("compiled-health"),
|
|
64
|
+
version: z.number().int().min(1),
|
|
59
65
|
generated_at: z.string(),
|
|
60
66
|
target_name: z.string(),
|
|
61
67
|
status: z.enum(["idle", "running", "compiled", "stale", "failed"]),
|
|
62
|
-
stage: z.
|
|
68
|
+
stage: z.union([
|
|
69
|
+
z.enum(["idle", "compiled", "failed"]),
|
|
70
|
+
RuntimeStageSchema,
|
|
71
|
+
]),
|
|
63
72
|
summary: z.string(),
|
|
64
|
-
metrics: z.
|
|
65
|
-
|
|
66
|
-
source_covered: z.number(),
|
|
67
|
-
summarized: z.number(),
|
|
68
|
-
to_summarize: z.number(),
|
|
69
|
-
compiled: z.number(),
|
|
70
|
-
to_compile: z.number(),
|
|
71
|
-
entities: z.number(),
|
|
72
|
-
claims: z.number(),
|
|
73
|
-
outputs: z.number(),
|
|
74
|
-
invalid_frontmatter: z.number(),
|
|
75
|
-
short_abstracts: z.number(),
|
|
76
|
-
broken_links: z.number(),
|
|
77
|
-
warnings: z.number(),
|
|
78
|
-
errors: z.number(),
|
|
79
|
-
}),
|
|
80
|
-
checks: z.object({
|
|
81
|
-
config_present: z.boolean(),
|
|
82
|
-
config_valid: z.boolean(),
|
|
83
|
-
config_type_match: z.boolean(),
|
|
84
|
-
summaries_present: z.boolean(),
|
|
85
|
-
inventory_present: z.boolean(),
|
|
86
|
-
outputs_present: z.boolean(),
|
|
87
|
-
home_present: z.boolean(),
|
|
88
|
-
summary_frontmatter_valid: z.boolean(),
|
|
89
|
-
abstracts_valid: z.boolean(),
|
|
90
|
-
links_valid: z.boolean(),
|
|
91
|
-
}),
|
|
73
|
+
metrics: z.record(z.string(), z.number()),
|
|
74
|
+
checks: z.record(z.string(), z.boolean()),
|
|
92
75
|
});
|
|
93
|
-
export const
|
|
94
|
-
kind: z.literal("
|
|
95
|
-
version: z.
|
|
76
|
+
export const CompiledViewSpecSchema = z.object({
|
|
77
|
+
kind: z.literal("compiled-view-spec"),
|
|
78
|
+
version: z.number().int().min(1),
|
|
96
79
|
generated_at: z.string(),
|
|
97
80
|
target_name: z.string(),
|
|
98
81
|
health_source: z.string(),
|
|
99
82
|
state_source: z.string(),
|
|
100
|
-
default_note: z.string(),
|
|
83
|
+
default_note: z.string().nullable(),
|
|
101
84
|
graph_scope: z.array(z.string()),
|
|
102
85
|
cards: z.array(ViewCardSchema),
|
|
103
86
|
sections: z.array(ViewSectionSchema),
|
|
104
87
|
});
|
|
105
|
-
export const
|
|
106
|
-
kind: z.literal("
|
|
88
|
+
export const CompiledRawSnapshotSchema = z.object({
|
|
89
|
+
kind: z.literal("compiled-raw-snapshot"),
|
|
107
90
|
version: z.literal(1),
|
|
108
91
|
generated_at: z.string(),
|
|
109
92
|
target_name: z.string(),
|
|
@@ -112,31 +95,31 @@ export const WorkspaceRawSnapshotSchema = z.object({
|
|
|
112
95
|
source_total: z.number(),
|
|
113
96
|
sample_files: z.array(z.string()),
|
|
114
97
|
});
|
|
115
|
-
export const
|
|
98
|
+
export const WorkflowCompiledZoneSchema = z.object({
|
|
116
99
|
id: WorkflowZoneIdSchema,
|
|
117
|
-
path: z.string().min(1).refine(
|
|
118
|
-
message: "Zone paths must stay inside the
|
|
100
|
+
path: z.string().min(1).refine(isCompiledRelativePath, {
|
|
101
|
+
message: "Zone paths must stay inside the compiled root",
|
|
119
102
|
}),
|
|
120
|
-
kind:
|
|
103
|
+
kind: WorkflowCompiledZoneKindSchema,
|
|
121
104
|
required: z.boolean(),
|
|
122
105
|
owned_by: z.array(z.string().regex(WorkflowIdPattern)),
|
|
123
106
|
description: z.string().min(1),
|
|
124
107
|
});
|
|
125
|
-
export const
|
|
126
|
-
kind: z.literal("
|
|
108
|
+
export const WorkflowCompiledSchemaSchema = z.object({
|
|
109
|
+
kind: z.literal("compiled-schema"),
|
|
127
110
|
version: z.literal(1),
|
|
128
|
-
target_type: z.literal("
|
|
111
|
+
target_type: z.literal("compiled"),
|
|
129
112
|
label: z.string().min(1),
|
|
130
|
-
zones: z.array(
|
|
113
|
+
zones: z.array(WorkflowCompiledZoneSchema).min(1),
|
|
131
114
|
});
|
|
132
115
|
export const WorkflowCompilerApiSchema = z.object({
|
|
133
|
-
kind: z.literal("
|
|
116
|
+
kind: z.literal("compiled"),
|
|
134
117
|
version: z.literal(1),
|
|
135
118
|
});
|
|
136
119
|
export const WorkflowStageZoneAccessSchema = z.array(WorkflowZoneIdSchema).min(1);
|
|
137
120
|
export const ExecutionShellZoneMountSchema = z.object({
|
|
138
121
|
zone_id: WorkflowZoneIdSchema,
|
|
139
|
-
|
|
122
|
+
compiled_path: z.string(),
|
|
140
123
|
shell_root_path: z.string(),
|
|
141
124
|
input_mount_path: z.string().nullable(),
|
|
142
125
|
output_mount_path: z.string().nullable(),
|
|
@@ -160,19 +143,25 @@ export const RuntimeExecutorInfoSchema = z.object({
|
|
|
160
143
|
timeout_ms: z.number().nullable().optional(),
|
|
161
144
|
});
|
|
162
145
|
export const RuntimeStageInstructionsSchema = z.object({
|
|
163
|
-
|
|
146
|
+
stage_skill_dir: z.string().regex(WorkflowIdPattern),
|
|
164
147
|
effective_mode: z.enum(["builtin", "extend", "override"]),
|
|
165
148
|
local_mode: z.enum(["extend", "override"]).nullable(),
|
|
166
149
|
local_docs: z.array(z.string()),
|
|
167
150
|
mode_sources: z.array(z.string()),
|
|
168
|
-
});
|
|
151
|
+
}).strict();
|
|
169
152
|
export const RuntimeStageAcceptanceSchema = z.object({
|
|
170
153
|
artifacts_exist: z.array(z.string()).optional(),
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
154
|
+
stage_truthy: z.array(z.string()).optional(),
|
|
155
|
+
stage_equals_counts: z.record(z.string(), z.string()).optional(),
|
|
156
|
+
stage_at_least: z.record(z.string(), z.number()).optional(),
|
|
157
|
+
stage_at_least_counts: z.record(z.string(), z.string()).optional(),
|
|
158
|
+
zone_counts_at_least: z.record(z.string().regex(WorkflowIdPattern), z.number()).optional(),
|
|
159
|
+
zone_counts_at_least_counts: z.record(z.string().regex(WorkflowIdPattern), z.string()).optional(),
|
|
160
|
+
markdown_frontmatter_valid_zones: z.array(WorkflowZoneIdSchema).optional(),
|
|
161
|
+
markdown_abstract_valid_zones: z.array(WorkflowZoneIdSchema).optional(),
|
|
162
|
+
wikilinks_valid_in_zones: z.array(WorkflowZoneIdSchema).optional(),
|
|
163
|
+
artifacts_must_not_contain: z.record(z.string(), z.array(z.string().min(1))).optional(),
|
|
164
|
+
}).strict();
|
|
176
165
|
export const RuntimeStageContractSchema = z.object({
|
|
177
166
|
kind: z.literal("interf-stage-contract"),
|
|
178
167
|
version: z.literal(1),
|
|
@@ -240,27 +229,21 @@ export const RuntimeRunSchema = z.object({
|
|
|
240
229
|
exit_code: z.number().nullable(),
|
|
241
230
|
error: z.string().nullable(),
|
|
242
231
|
});
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
z.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
z.
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
z.object({
|
|
259
|
-
items: z.array(InventoryRecordSchema),
|
|
260
|
-
total: z.number().optional(),
|
|
261
|
-
summary_total: z.number().optional(),
|
|
262
|
-
}),
|
|
263
|
-
]);
|
|
232
|
+
export const CompiledInventoryEntrySchema = z.object({
|
|
233
|
+
input_zone: WorkflowZoneIdSchema,
|
|
234
|
+
input_path: z.string().min(1),
|
|
235
|
+
output_zone: WorkflowZoneIdSchema,
|
|
236
|
+
output_path: z.string().min(1),
|
|
237
|
+
state: z.string().min(1).optional(),
|
|
238
|
+
metadata: JsonRecordSchema.optional(),
|
|
239
|
+
}).strict();
|
|
240
|
+
export const CompiledInventorySchema = z.object({
|
|
241
|
+
kind: z.literal("compiled-runtime-ledger").optional(),
|
|
242
|
+
version: z.number().int().min(1).optional(),
|
|
243
|
+
stage: RuntimeStageSchema.optional(),
|
|
244
|
+
entries: z.array(CompiledInventoryEntrySchema),
|
|
245
|
+
total: z.number().int().nonnegative(),
|
|
246
|
+
});
|
|
264
247
|
export const TestCaseExpectSchema = z.object({
|
|
265
248
|
must_include: z.array(z.string().min(1)).optional(),
|
|
266
249
|
must_include_one_of: z.array(z.array(z.string().min(1)).min(1)).optional(),
|
|
@@ -293,32 +276,14 @@ const TestCaseCoreSchema = z.object({
|
|
|
293
276
|
});
|
|
294
277
|
}
|
|
295
278
|
});
|
|
296
|
-
export const TestCaseSchema =
|
|
297
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
298
|
-
return value;
|
|
299
|
-
const raw = value;
|
|
300
|
-
return {
|
|
301
|
-
...raw,
|
|
302
|
-
question: raw.question ?? raw.check ?? raw.ask,
|
|
303
|
-
answer: raw.answer ?? raw.expected ?? raw.pass_when,
|
|
304
|
-
};
|
|
305
|
-
}, TestCaseCoreSchema);
|
|
279
|
+
export const TestCaseSchema = TestCaseCoreSchema;
|
|
306
280
|
const TestSpecCoreSchema = z.object({
|
|
307
281
|
type: TestTargetTypeSchema,
|
|
308
282
|
name: z.string().min(1),
|
|
309
283
|
description: z.string().min(1).optional(),
|
|
310
284
|
cases: z.array(TestCaseSchema).min(1),
|
|
311
285
|
});
|
|
312
|
-
export const TestSpecSchema =
|
|
313
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
314
|
-
return value;
|
|
315
|
-
const raw = value;
|
|
316
|
-
return {
|
|
317
|
-
...raw,
|
|
318
|
-
type: raw.type ?? "workspace",
|
|
319
|
-
cases: raw.cases ?? raw.checks,
|
|
320
|
-
};
|
|
321
|
-
}, TestSpecCoreSchema);
|
|
286
|
+
export const TestSpecSchema = TestSpecCoreSchema;
|
|
322
287
|
export const SourceTruthCheckSchema = z.object({
|
|
323
288
|
id: z.string().regex(WorkflowIdPattern).optional(),
|
|
324
289
|
question: z.string().min(1),
|
|
@@ -334,46 +299,31 @@ export const SourceTruthCheckSchema = z.object({
|
|
|
334
299
|
});
|
|
335
300
|
}
|
|
336
301
|
});
|
|
337
|
-
export const
|
|
338
|
-
export const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return {
|
|
347
|
-
...raw,
|
|
348
|
-
max_attempts: raw.max_attempts ?? legacyRetryPolicy?.max_attempts,
|
|
349
|
-
max_loops: raw.max_loops,
|
|
350
|
-
};
|
|
351
|
-
}, z.object({
|
|
302
|
+
export const SourceCompiledMaxAttemptsSchema = z.number().int().min(1).max(5);
|
|
303
|
+
export const SourceCompiledMaxLoopsSchema = z.number().int().min(1).max(3);
|
|
304
|
+
const DatasetNamePattern = /^[a-z0-9][a-z0-9-]*$/;
|
|
305
|
+
const RESERVED_DATASET_NAMES = new Set(["tests", "workflows"]);
|
|
306
|
+
export const DatasetNameSchema = z
|
|
307
|
+
.string()
|
|
308
|
+
.regex(DatasetNamePattern, "Dataset names must use lowercase letters, numbers, and dashes only.")
|
|
309
|
+
.refine((value) => !RESERVED_DATASET_NAMES.has(value), "Dataset name is reserved.");
|
|
310
|
+
export const SourceDatasetConfigSchema = z.object({
|
|
352
311
|
id: z.string().regex(WorkflowIdPattern).optional(),
|
|
353
|
-
name:
|
|
312
|
+
name: DatasetNameSchema,
|
|
313
|
+
path: z.string().min(1).default("."),
|
|
354
314
|
about: z.string().min(1).optional(),
|
|
355
315
|
workflow: WorkflowIdSchema.optional(),
|
|
356
|
-
max_attempts:
|
|
357
|
-
max_loops:
|
|
316
|
+
max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
|
|
317
|
+
max_loops: SourceCompiledMaxLoopsSchema.optional(),
|
|
358
318
|
checks: z.array(SourceTruthCheckSchema).default([]),
|
|
359
|
-
}).strict()
|
|
360
|
-
export const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const raw = value;
|
|
364
|
-
return {
|
|
365
|
-
...raw,
|
|
366
|
-
type: "workspace",
|
|
367
|
-
source: raw.source ?? { path: "./raw" },
|
|
368
|
-
checks: raw.checks ?? [],
|
|
369
|
-
};
|
|
370
|
-
}, z.object({
|
|
371
|
-
type: z.literal("workspace"),
|
|
372
|
-
name: z.string(),
|
|
319
|
+
}).strict();
|
|
320
|
+
export const CompiledInterfConfigSchema = z.object({
|
|
321
|
+
type: z.literal("compiled"),
|
|
322
|
+
name: DatasetNameSchema,
|
|
373
323
|
about: z.string().optional(),
|
|
374
|
-
workflow: WorkflowIdSchema
|
|
375
|
-
max_attempts:
|
|
376
|
-
max_loops:
|
|
324
|
+
workflow: WorkflowIdSchema,
|
|
325
|
+
max_attempts: SourceCompiledMaxAttemptsSchema.optional(),
|
|
326
|
+
max_loops: SourceCompiledMaxLoopsSchema.optional(),
|
|
377
327
|
checks: z.array(SourceTruthCheckSchema).default([]),
|
|
378
328
|
workflow_origin: z.object({
|
|
379
329
|
selected: WorkflowIdSchema,
|
|
@@ -382,9 +332,10 @@ export const WorkspaceInterfConfigSchema = z.preprocess((value) => {
|
|
|
382
332
|
source: z.object({
|
|
383
333
|
path: z.string(),
|
|
384
334
|
control_path: z.string().optional(),
|
|
335
|
+
dataset_path: z.string(),
|
|
385
336
|
}),
|
|
386
|
-
}).passthrough()
|
|
387
|
-
export const InterfConfigSchema =
|
|
337
|
+
}).passthrough();
|
|
338
|
+
export const InterfConfigSchema = CompiledInterfConfigSchema;
|
|
388
339
|
export const WorkflowImprovementLoopSummarySchema = z.object({
|
|
389
340
|
variation: z.number().int().min(1),
|
|
390
341
|
kind: z.enum(["baseline", "edited"]),
|
|
@@ -404,11 +355,11 @@ export const WorkflowImprovementContextSchema = z.object({
|
|
|
404
355
|
target_name: z.string(),
|
|
405
356
|
workflow_id: WorkflowIdSchema,
|
|
406
357
|
loop_index: z.number().int().min(1),
|
|
407
|
-
max_loops:
|
|
408
|
-
max_attempts:
|
|
358
|
+
max_loops: SourceCompiledMaxLoopsSchema,
|
|
359
|
+
max_attempts: SourceCompiledMaxAttemptsSchema,
|
|
409
360
|
review_paths: z.object({
|
|
410
361
|
workflow_root: z.string(),
|
|
411
|
-
|
|
362
|
+
compiled_runtime: z.string().nullable(),
|
|
412
363
|
test_comparisons: z.string().nullable(),
|
|
413
364
|
execution_shells: z.string().nullable(),
|
|
414
365
|
test_runs: z.string().nullable(),
|
|
@@ -473,17 +424,17 @@ export const WorkflowImprovementRunLedgerSchema = z.object({
|
|
|
473
424
|
run_id: z.string(),
|
|
474
425
|
target_name: z.string(),
|
|
475
426
|
workflow_id: WorkflowIdSchema,
|
|
476
|
-
max_loops:
|
|
477
|
-
max_attempts:
|
|
427
|
+
max_loops: SourceCompiledMaxLoopsSchema,
|
|
428
|
+
max_attempts: SourceCompiledMaxAttemptsSchema,
|
|
478
429
|
loops: z.array(WorkflowImprovementLoopRecordSchema),
|
|
479
430
|
});
|
|
480
431
|
export const SourceFolderConfigSchema = z.object({
|
|
481
|
-
|
|
432
|
+
datasets: z.array(SourceDatasetConfigSchema).optional(),
|
|
482
433
|
}).strict().superRefine((value, ctx) => {
|
|
483
|
-
if ((value.
|
|
434
|
+
if ((value.datasets?.length ?? 0) === 0) {
|
|
484
435
|
ctx.addIssue({
|
|
485
436
|
code: z.ZodIssueCode.custom,
|
|
486
|
-
message: "
|
|
437
|
+
message: "Interf project config needs at least one dataset.",
|
|
487
438
|
});
|
|
488
439
|
}
|
|
489
440
|
});
|
|
@@ -544,7 +495,7 @@ export const TestTargetRunSchema = z.object({
|
|
|
544
495
|
target_count: z.number(),
|
|
545
496
|
results: z.array(TestTargetResultSchema),
|
|
546
497
|
});
|
|
547
|
-
export const TestRunModeSchema = z.enum(["raw", "
|
|
498
|
+
export const TestRunModeSchema = z.enum(["raw", "compiled", "both"]);
|
|
548
499
|
export const TestRunTargetSummarySchema = z.object({
|
|
549
500
|
label: z.string(),
|
|
550
501
|
run_path: z.string(),
|
|
@@ -566,12 +517,13 @@ export const TestRunComparisonSchema = z.object({
|
|
|
566
517
|
generated_at: z.string(),
|
|
567
518
|
mode: TestRunModeSchema,
|
|
568
519
|
source_path: z.string(),
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
520
|
+
checks_fingerprint: z.string().min(1).optional(),
|
|
521
|
+
dataset: z.object({
|
|
522
|
+
name: DatasetNameSchema,
|
|
523
|
+
compiled_path: z.string().nullable(),
|
|
572
524
|
}),
|
|
573
525
|
raw: TestRunTargetSummarySchema.nullable(),
|
|
574
|
-
|
|
526
|
+
compiled: TestRunTargetSummarySchema.nullable(),
|
|
575
527
|
summary: z.object({
|
|
576
528
|
raw_pass_rate: z.number().nullable(),
|
|
577
529
|
compiled_pass_rate: z.number().nullable(),
|
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import { type InterfConfig, type TestSpec, type TestTargetType, type SourceTruthCheck, type
|
|
2
|
-
export declare const SOURCE_FOLDER_CONFIG_FILE = "interf.
|
|
1
|
+
import { type InterfConfig, type TestSpec, type TestTargetType, type SourceTruthCheck, type SourceDatasetConfig, type SourceFolderConfig } from "./schema.js";
|
|
2
|
+
export declare const SOURCE_FOLDER_CONFIG_FILE = "interf.json";
|
|
3
3
|
export interface LoadedSourceTestSpec extends TestSpec {
|
|
4
4
|
id: string;
|
|
5
5
|
filePath: string;
|
|
6
6
|
}
|
|
7
|
+
export declare function fingerprintTruthChecks(checks: SourceTruthCheck[]): string;
|
|
7
8
|
export declare function loadSourceFolderConfig(sourcePath: string): SourceFolderConfig | null;
|
|
8
|
-
export interface
|
|
9
|
-
|
|
9
|
+
export interface WritableSourceProjectConfig {
|
|
10
|
+
datasets?: Array<Omit<SourceDatasetConfig, "path"> & {
|
|
11
|
+
path?: string;
|
|
12
|
+
}>;
|
|
10
13
|
}
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function saveSourceFolderConfig(sourcePath: string, config:
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
14
|
+
export declare function listSourceDatasetConfigs(config: SourceFolderConfig | null): SourceDatasetConfig[];
|
|
15
|
+
export declare function resolveDatasetCompileMaxAttempts(datasetConfig: Pick<SourceDatasetConfig, "max_attempts">, override?: number | null): number | null;
|
|
16
|
+
export declare function resolveDatasetCompileMaxLoops(datasetConfig: Pick<SourceDatasetConfig, "max_loops">, override?: number | null): number | null;
|
|
17
|
+
export declare function getDefaultSourceDatasetConfig(config: SourceFolderConfig | null): SourceDatasetConfig | null;
|
|
18
|
+
export declare function findSourceDatasetConfig(config: SourceFolderConfig | null, datasetName: string): SourceDatasetConfig | null;
|
|
19
|
+
export declare function saveSourceFolderConfig(sourcePath: string, config: WritableSourceProjectConfig): void;
|
|
20
|
+
export declare function appendSourceDatasetChecks(sourcePath: string, datasetName: string, checks: SourceTruthCheck[]): void;
|
|
21
|
+
export declare function upsertSourceDatasetConfig(sourcePath: string, datasetConfig: SourceDatasetConfig, options?: {
|
|
19
22
|
matchName?: string;
|
|
20
23
|
}): void;
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
24
|
+
export declare function compiledMaxAttempts(maxAttempts: number | null | undefined): number | undefined;
|
|
25
|
+
export declare function compiledMaxLoops(maxLoops: number | null | undefined): number | undefined;
|
|
26
|
+
export declare function sourceDatasetConfigFromInterfConfig(config: InterfConfig, datasetPath?: string): SourceDatasetConfig;
|
|
27
|
+
export declare function loadCompiledDatasetConfig(compiledPath: string): SourceDatasetConfig | null;
|
|
28
|
+
export declare function saveCompiledInterfConfig(compiledPath: string, config: InterfConfig): InterfConfig;
|
|
29
|
+
export declare function syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath: string, datasetConfig: SourceDatasetConfig): InterfConfig;
|
|
27
30
|
export declare function buildTestSpecFromSourceFolderConfig(options: {
|
|
28
31
|
sourcePath: string;
|
|
29
32
|
targetName?: string | null;
|
|
30
33
|
targetType?: TestTargetType;
|
|
31
34
|
}): LoadedSourceTestSpec | null;
|
|
32
|
-
export declare function
|
|
33
|
-
|
|
35
|
+
export declare function buildTestSpecFromCompiledDatasetConfig(options: {
|
|
36
|
+
compiledPath: string;
|
|
34
37
|
targetType?: TestTargetType;
|
|
35
38
|
}): LoadedSourceTestSpec | null;
|
|
39
|
+
export declare function resolveSourceDatasetPath(projectPath: string, datasetConfig: Pick<SourceDatasetConfig, "path">): string;
|