@interf/compiler 0.2.5 → 0.3.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 +192 -187
- package/dist/bin.js +3 -3
- package/dist/bin.js.map +1 -1
- package/dist/commands/compile.d.ts +1 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +45 -138
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/create-workflow-wizard.d.ts +4 -25
- package/dist/commands/create-workflow-wizard.d.ts.map +1 -1
- package/dist/commands/create-workflow-wizard.js +46 -222
- package/dist/commands/create-workflow-wizard.js.map +1 -1
- package/dist/commands/create.d.ts +2 -11
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +78 -477
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/default.d.ts.map +1 -1
- package/dist/commands/default.js +27 -43
- package/dist/commands/default.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/executor-flow.d.ts +9 -0
- package/dist/commands/executor-flow.d.ts.map +1 -0
- package/dist/commands/executor-flow.js +55 -0
- package/dist/commands/executor-flow.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +320 -321
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +12 -22
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +27 -124
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/source-config-wizard.d.ts +10 -11
- package/dist/commands/source-config-wizard.d.ts.map +1 -1
- package/dist/commands/source-config-wizard.js +100 -97
- package/dist/commands/source-config-wizard.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +60 -56
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test-flow.d.ts +21 -0
- package/dist/commands/test-flow.d.ts.map +1 -0
- package/dist/commands/test-flow.js +106 -0
- package/dist/commands/test-flow.js.map +1 -0
- package/dist/commands/test.d.ts +4 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +131 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +63 -98
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/workspace-flow.d.ts +21 -0
- package/dist/commands/workspace-flow.d.ts.map +1 -0
- package/dist/commands/workspace-flow.js +90 -0
- package/dist/commands/workspace-flow.js.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-constants.js +1 -1
- package/dist/lib/agent-constants.js.map +1 -1
- package/dist/lib/agent-detection.js +4 -4
- package/dist/lib/agent-detection.js.map +1 -1
- package/dist/lib/agent-skills.js +6 -6
- package/dist/lib/agent-skills.js.map +1 -1
- package/dist/lib/benchmark-execution.d.ts.map +1 -1
- package/dist/lib/benchmark-execution.js +32 -19
- package/dist/lib/benchmark-execution.js.map +1 -1
- package/dist/lib/benchmark-sandbox.d.ts +10 -0
- package/dist/lib/benchmark-sandbox.d.ts.map +1 -0
- package/dist/lib/benchmark-sandbox.js +75 -0
- package/dist/lib/benchmark-sandbox.js.map +1 -0
- package/dist/lib/benchmark-targets.d.ts +4 -4
- package/dist/lib/benchmark-targets.d.ts.map +1 -1
- package/dist/lib/benchmark-targets.js +20 -54
- package/dist/lib/benchmark-targets.js.map +1 -1
- package/dist/lib/benchmark-types.d.ts +2 -3
- package/dist/lib/benchmark-types.d.ts.map +1 -1
- package/dist/lib/benchmark.d.ts +1 -1
- package/dist/lib/benchmark.d.ts.map +1 -1
- package/dist/lib/benchmark.js +1 -1
- package/dist/lib/benchmark.js.map +1 -1
- package/dist/lib/config.d.ts +1 -2
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +2 -4
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.d.ts.map +1 -1
- package/dist/lib/discovery.js +7 -2
- package/dist/lib/discovery.js.map +1 -1
- package/dist/lib/eval-packs.d.ts +6 -52
- package/dist/lib/eval-packs.d.ts.map +1 -1
- package/dist/lib/eval-packs.js +11 -39
- package/dist/lib/eval-packs.js.map +1 -1
- package/dist/lib/interf-bootstrap.d.ts +3 -5
- package/dist/lib/interf-bootstrap.d.ts.map +1 -1
- package/dist/lib/interf-bootstrap.js +10 -57
- package/dist/lib/interf-bootstrap.js.map +1 -1
- package/dist/lib/interf-detect.d.ts +13 -11
- package/dist/lib/interf-detect.d.ts.map +1 -1
- package/dist/lib/interf-detect.js +59 -45
- package/dist/lib/interf-detect.js.map +1 -1
- package/dist/lib/interf-scaffold.d.ts +2 -5
- package/dist/lib/interf-scaffold.d.ts.map +1 -1
- package/dist/lib/interf-scaffold.js +99 -235
- package/dist/lib/interf-scaffold.js.map +1 -1
- package/dist/lib/interf-workflow-package.d.ts +1 -2
- package/dist/lib/interf-workflow-package.d.ts.map +1 -1
- package/dist/lib/interf-workflow-package.js +99 -90
- package/dist/lib/interf-workflow-package.js.map +1 -1
- package/dist/lib/interf.d.ts +4 -5
- package/dist/lib/interf.d.ts.map +1 -1
- package/dist/lib/interf.js +3 -6
- package/dist/lib/interf.js.map +1 -1
- package/dist/lib/local-workflows.d.ts +9 -8
- package/dist/lib/local-workflows.d.ts.map +1 -1
- package/dist/lib/local-workflows.js +56 -92
- package/dist/lib/local-workflows.js.map +1 -1
- package/dist/lib/obsidian.d.ts +1 -3
- package/dist/lib/obsidian.d.ts.map +1 -1
- package/dist/lib/obsidian.js +10 -81
- package/dist/lib/obsidian.js.map +1 -1
- package/dist/lib/registry.d.ts +6 -17
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/registry.js +36 -50
- package/dist/lib/registry.js.map +1 -1
- package/dist/lib/runtime-contracts.d.ts +4 -3
- package/dist/lib/runtime-contracts.d.ts.map +1 -1
- package/dist/lib/runtime-contracts.js +125 -9
- package/dist/lib/runtime-contracts.js.map +1 -1
- package/dist/lib/runtime-reconcile.d.ts +3 -5
- package/dist/lib/runtime-reconcile.d.ts.map +1 -1
- package/dist/lib/runtime-reconcile.js +70 -167
- package/dist/lib/runtime-reconcile.js.map +1 -1
- package/dist/lib/runtime-runs.d.ts.map +1 -1
- package/dist/lib/runtime-runs.js +61 -57
- package/dist/lib/runtime-runs.js.map +1 -1
- package/dist/lib/runtime-types.d.ts +16 -6
- package/dist/lib/runtime-types.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts +2 -2
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/runtime.js.map +1 -1
- package/dist/lib/schema.d.ts +69 -311
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/schema.js +49 -210
- package/dist/lib/schema.js.map +1 -1
- package/dist/lib/source-config.d.ts +8 -7
- package/dist/lib/source-config.d.ts.map +1 -1
- package/dist/lib/source-config.js +59 -63
- package/dist/lib/source-config.js.map +1 -1
- package/dist/lib/state-artifacts.d.ts +5 -11
- package/dist/lib/state-artifacts.d.ts.map +1 -1
- package/dist/lib/state-artifacts.js +8 -18
- package/dist/lib/state-artifacts.js.map +1 -1
- package/dist/lib/state-health.d.ts +4 -8
- package/dist/lib/state-health.d.ts.map +1 -1
- package/dist/lib/state-health.js +52 -233
- package/dist/lib/state-health.js.map +1 -1
- package/dist/lib/state-io.d.ts +7 -12
- package/dist/lib/state-io.d.ts.map +1 -1
- package/dist/lib/state-io.js +32 -93
- package/dist/lib/state-io.js.map +1 -1
- package/dist/lib/state-view.d.ts +4 -6
- package/dist/lib/state-view.d.ts.map +1 -1
- package/dist/lib/state-view.js +62 -101
- package/dist/lib/state-view.js.map +1 -1
- package/dist/lib/state.d.ts +5 -5
- package/dist/lib/state.d.ts.map +1 -1
- package/dist/lib/state.js +4 -4
- package/dist/lib/state.js.map +1 -1
- package/dist/lib/summarize-plan.d.ts +2 -2
- package/dist/lib/summarize-plan.d.ts.map +1 -1
- package/dist/lib/summarize-plan.js +13 -13
- package/dist/lib/summarize-plan.js.map +1 -1
- package/dist/lib/{validate-kb.d.ts → validate-workspace.d.ts} +49 -8
- package/dist/lib/validate-workspace.d.ts.map +1 -0
- package/dist/lib/validate-workspace.js +398 -0
- package/dist/lib/validate-workspace.js.map +1 -0
- package/dist/lib/validate.d.ts +5 -7
- package/dist/lib/validate.d.ts.map +1 -1
- package/dist/lib/validate.js +22 -20
- package/dist/lib/validate.js.map +1 -1
- package/dist/lib/workflow-definitions.d.ts +14 -50
- package/dist/lib/workflow-definitions.d.ts.map +1 -1
- package/dist/lib/workflow-definitions.js +100 -353
- package/dist/lib/workflow-definitions.js.map +1 -1
- package/dist/lib/workflow-helpers.d.ts +3 -4
- package/dist/lib/workflow-helpers.d.ts.map +1 -1
- package/dist/lib/workflow-helpers.js +17 -49
- package/dist/lib/workflow-helpers.js.map +1 -1
- package/dist/lib/workflow-stage-runner.d.ts +1 -2
- package/dist/lib/workflow-stage-runner.d.ts.map +1 -1
- package/dist/lib/workflow-stage-runner.js +4 -6
- package/dist/lib/workflow-stage-runner.js.map +1 -1
- package/dist/lib/workflow-starter-docs.d.ts +3 -5
- package/dist/lib/workflow-starter-docs.d.ts.map +1 -1
- package/dist/lib/workflow-starter-docs.js +2 -17
- package/dist/lib/workflow-starter-docs.js.map +1 -1
- package/dist/lib/workflows.d.ts +9 -14
- package/dist/lib/workflows.d.ts.map +1 -1
- package/dist/lib/workflows.js +15 -30
- package/dist/lib/workflows.js.map +1 -1
- package/dist/lib/workspace-compile.d.ts +51 -0
- package/dist/lib/workspace-compile.d.ts.map +1 -0
- package/dist/lib/workspace-compile.js +397 -0
- package/dist/lib/workspace-compile.js.map +1 -0
- package/package.json +9 -9
- package/skills/benchmark/SKILL.md +20 -27
- package/skills/workflow/create/SKILL.md +10 -14
- package/skills/workspace/shape/SKILL.md +15 -0
- package/skills/workspace/structure/SKILL.md +15 -0
- package/skills/workspace/summarize/SKILL.md +15 -0
- package/templates/workspace/README.md +23 -0
- package/templates/workspace/interfignore +2 -0
- package/dist/commands/benchmark.d.ts +0 -3
- package/dist/commands/benchmark.d.ts.map +0 -1
- package/dist/commands/benchmark.js +0 -374
- package/dist/commands/benchmark.js.map +0 -1
- package/dist/lib/bundled-templates.d.ts +0 -5
- package/dist/lib/bundled-templates.d.ts.map +0 -1
- package/dist/lib/bundled-templates.js +0 -23
- package/dist/lib/bundled-templates.js.map +0 -1
- package/dist/lib/interf-compile-plan.d.ts +0 -12
- package/dist/lib/interf-compile-plan.d.ts.map +0 -1
- package/dist/lib/interf-compile-plan.js +0 -143
- package/dist/lib/interf-compile-plan.js.map +0 -1
- package/dist/lib/validate-interface.d.ts +0 -79
- package/dist/lib/validate-interface.d.ts.map +0 -1
- package/dist/lib/validate-interface.js +0 -535
- package/dist/lib/validate-interface.js.map +0 -1
- package/dist/lib/validate-kb.d.ts.map +0 -1
- package/dist/lib/validate-kb.js +0 -252
- package/dist/lib/validate-kb.js.map +0 -1
- package/dist/lib/workflows-interface-contracts.d.ts +0 -24
- package/dist/lib/workflows-interface-contracts.d.ts.map +0 -1
- package/dist/lib/workflows-interface-contracts.js +0 -304
- package/dist/lib/workflows-interface-contracts.js.map +0 -1
- package/dist/lib/workflows-interface.d.ts +0 -72
- package/dist/lib/workflows-interface.d.ts.map +0 -1
- package/dist/lib/workflows-interface.js +0 -377
- package/dist/lib/workflows-interface.js.map +0 -1
- package/dist/lib/workflows-kb.d.ts +0 -50
- package/dist/lib/workflows-kb.d.ts.map +0 -1
- package/dist/lib/workflows-kb.js +0 -306
- package/dist/lib/workflows-kb.js.map +0 -1
- package/skills/interface/analyze/SKILL.md +0 -191
- package/skills/interface/compile/SKILL.md +0 -152
- package/skills/interface/compile/references/output-format.md +0 -48
- package/skills/interface/create/SKILL.md +0 -87
- package/skills/interface/create/references/compile-plan-format.md +0 -109
- package/skills/interface/create/references/workflows.md +0 -35
- package/skills/interface/query/SKILL.md +0 -48
- package/skills/interface/retrieve/SKILL.md +0 -133
- package/skills/knowledge-base/compile/SKILL.md +0 -196
- package/skills/knowledge-base/compile/references/output-format.md +0 -48
- package/skills/knowledge-base/compile/references/stage-claims.md +0 -60
- package/skills/knowledge-base/compile/references/stage-entities.md +0 -46
- package/skills/knowledge-base/query/SKILL.md +0 -45
- package/skills/knowledge-base/summarize/SKILL.md +0 -152
- package/templates/interface/README.md +0 -159
- package/templates/interface/interfaces.md +0 -102
- package/templates/knowledge-base/README.md +0 -137
- package/templates/knowledge-base/interfignore +0 -19
- package/templates/knowledge-base/registry.md +0 -118
- package/templates/workflow-package/README.md +0 -16
- package/templates/workflow-package/create/SKILL.md +0 -8
- package/templates/workflow-package/interface-query/SKILL.md +0 -29
- package/templates/workflow-package/interface-stage/SKILL.md +0 -13
- package/templates/workflow-package/knowledge-base-query/SKILL.md +0 -36
- package/templates/workflow-package/knowledge-base-stage/SKILL.md +0 -13
- package/templates/workflow-starters/interface/interf/README.md +0 -13
- package/templates/workflow-starters/interface/interf/create/SKILL.md +0 -15
- package/templates/workflow-starters/knowledge-base/interf/README.md +0 -13
- package/templates/workflow-starters/knowledge-base/karpathy/README.md +0 -13
package/dist/commands/init.js
CHANGED
|
@@ -1,356 +1,355 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
import { basename } from "node:path";
|
|
4
2
|
import * as p from "@clack/prompts";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
3
|
+
import { detectInterf, resolveSourceFolderPath, } from "../lib/interf.js";
|
|
4
|
+
import { SOURCE_FOLDER_CONFIG_FILE, listSourceWorkspaceConfigs, loadSourceFolderConfig, upsertSourceWorkspaceConfig, } from "../lib/source-config.js";
|
|
5
|
+
import { promptSingleWorkspaceConfig } from "./source-config-wizard.js";
|
|
6
|
+
import { createWorkflowWizard } from "./create-workflow-wizard.js";
|
|
7
|
+
import { findBuiltWorkspacePath, findSavedWorkspaceConfig, listSavedWorkspaceEntries, ensureWorkspaceFromConfig, compileWorkspaceWithReporter, } from "./workspace-flow.js";
|
|
8
|
+
import { printSavedTestComparison, runSavedRawTest, runSavedWorkspaceTest, } from "./test-flow.js";
|
|
9
|
+
import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
|
|
10
|
+
function describeSavedQuestions(workspace) {
|
|
11
|
+
const count = workspace.checks.length;
|
|
12
|
+
if (count === 0)
|
|
13
|
+
return "No saved questions yet";
|
|
14
|
+
return `${count} saved question${count === 1 ? "" : "s"}`;
|
|
15
|
+
}
|
|
16
|
+
function printWorkspaceSummary(options) {
|
|
17
|
+
p.log.info(`Workspace: ${options.workspace.name}`);
|
|
18
|
+
if (options.workspace.about) {
|
|
19
|
+
p.log.info(`Focus: ${options.workspace.about}`);
|
|
20
|
+
}
|
|
21
|
+
p.log.info(describeSavedQuestions(options.workspace));
|
|
22
|
+
p.log.info(options.built ? "Compiled workspace is available." : "Compiled workspace has not been built yet.");
|
|
23
|
+
if (options.sourcePath !== process.cwd()) {
|
|
24
|
+
p.log.info(`Source folder: ${options.sourcePath}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function promptWorkspaceAction(workspace, built) {
|
|
28
|
+
const options = [
|
|
29
|
+
{
|
|
30
|
+
value: "edit",
|
|
31
|
+
label: "Edit questions and focus",
|
|
32
|
+
hint: "Update this workspace setup",
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
if (workspace.checks.length > 0) {
|
|
36
|
+
options.push({
|
|
37
|
+
value: "raw",
|
|
38
|
+
label: "Run a baseline test on the raw files",
|
|
39
|
+
hint: "Measure current performance before compilation",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
options.push({
|
|
43
|
+
value: "compile",
|
|
44
|
+
label: built ? "Refresh the compiled workspace" : "Compile the workspace",
|
|
45
|
+
hint: built ? "Rebuild it from the current files" : "Build it for the first time",
|
|
46
|
+
});
|
|
47
|
+
if (workspace.checks.length > 0 && built) {
|
|
48
|
+
options.push({
|
|
49
|
+
value: "test",
|
|
50
|
+
label: "Run the saved test on the compiled workspace",
|
|
51
|
+
hint: "Score this workspace on its saved questions",
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
options.push({
|
|
55
|
+
value: "workspace",
|
|
56
|
+
label: "Create another workspace",
|
|
57
|
+
hint: "Add a separate focus or question set",
|
|
58
|
+
}, {
|
|
59
|
+
value: "workflow",
|
|
60
|
+
label: "Create workflow",
|
|
61
|
+
hint: "Advanced: customize the compile method",
|
|
62
|
+
}, {
|
|
63
|
+
value: "done",
|
|
64
|
+
label: "Done",
|
|
65
|
+
hint: "Exit the wizard",
|
|
66
|
+
});
|
|
67
|
+
const selected = await p.select({
|
|
68
|
+
message: "What do you want to do next?",
|
|
69
|
+
options,
|
|
70
|
+
});
|
|
71
|
+
if (p.isCancel(selected))
|
|
72
|
+
return null;
|
|
73
|
+
return selected;
|
|
74
|
+
}
|
|
75
|
+
async function chooseWorkspaceForWizard(options) {
|
|
76
|
+
if (options.fixedWorkspaceName) {
|
|
77
|
+
return findSavedWorkspaceConfig(options.sourcePath, options.fixedWorkspaceName);
|
|
78
|
+
}
|
|
79
|
+
const savedEntries = listSavedWorkspaceEntries(options.sourcePath);
|
|
80
|
+
if (savedEntries.length === 0)
|
|
81
|
+
return null;
|
|
82
|
+
if (savedEntries.length === 1)
|
|
83
|
+
return savedEntries[0]?.config ?? null;
|
|
84
|
+
const selected = await p.select({
|
|
85
|
+
message: "Which workspace do you want to work with?",
|
|
86
|
+
options: [
|
|
87
|
+
...savedEntries.map((entry) => ({
|
|
88
|
+
value: entry.config.name,
|
|
89
|
+
label: entry.config.name,
|
|
90
|
+
hint: [
|
|
91
|
+
entry.config.about ?? describeSavedQuestions(entry.config),
|
|
92
|
+
entry.path ? "built" : "not built yet",
|
|
93
|
+
].join(" · "),
|
|
94
|
+
})),
|
|
95
|
+
{
|
|
96
|
+
value: "__new__",
|
|
97
|
+
label: "Create another workspace",
|
|
98
|
+
hint: "Add a separate focus or question set",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
if (p.isCancel(selected))
|
|
103
|
+
return null;
|
|
104
|
+
if (selected === "__new__")
|
|
105
|
+
return "__new__";
|
|
106
|
+
return findSavedWorkspaceConfig(options.sourcePath, String(selected));
|
|
107
|
+
}
|
|
108
|
+
async function promptWorkspaceSetup(options) {
|
|
109
|
+
const workspaceConfig = await promptSingleWorkspaceConfig({
|
|
110
|
+
initial: options.initial,
|
|
111
|
+
...(options.fixedName ? { fixedName: options.fixedName } : {}),
|
|
112
|
+
skipNamePrompt: !options.fixedName && options.introStyle === "first",
|
|
113
|
+
introStyle: options.introStyle,
|
|
114
|
+
});
|
|
115
|
+
if (!workspaceConfig)
|
|
116
|
+
return null;
|
|
117
|
+
upsertSourceWorkspaceConfig(options.sourcePath, workspaceConfig, {
|
|
118
|
+
...(options.fixedName ? { matchName: options.fixedName } : {}),
|
|
119
|
+
});
|
|
120
|
+
console.log();
|
|
121
|
+
console.log(chalk.green(` ✓ Saved workspace setup in ${SOURCE_FOLDER_CONFIG_FILE}`));
|
|
122
|
+
console.log(chalk.dim(` Source folder: ${options.sourcePath}`));
|
|
123
|
+
console.log(chalk.dim(` Workspace: ${workspaceConfig.name}`));
|
|
124
|
+
return workspaceConfig;
|
|
125
|
+
}
|
|
126
|
+
async function compileSelectedWorkspace(sourcePath, workspaceConfig) {
|
|
127
|
+
const { executor, error } = await resolveOrConfigureLocalExecutor();
|
|
128
|
+
if (!executor) {
|
|
129
|
+
process.exitCode = 1;
|
|
130
|
+
console.log(chalk.red(error ?? "No coding agent detected."));
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const workspacePath = ensureWorkspaceFromConfig(sourcePath, workspaceConfig);
|
|
134
|
+
const result = await compileWorkspaceWithReporter(executor, workspacePath);
|
|
135
|
+
if (!result.ok) {
|
|
136
|
+
process.exitCode = 1;
|
|
137
|
+
console.log(chalk.red(" Workspace compile failed."));
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return workspacePath;
|
|
141
|
+
}
|
|
142
|
+
async function runFirstWorkspaceFlow(sourcePath, workspaceConfig) {
|
|
143
|
+
let rawOutcome = null;
|
|
144
|
+
let workspaceOutcome = null;
|
|
145
|
+
if (workspaceConfig.checks.length > 0) {
|
|
146
|
+
const runRawFirst = await p.confirm({
|
|
147
|
+
message: "Run a baseline test on the raw files now? (Recommended)",
|
|
148
|
+
initialValue: true,
|
|
149
|
+
});
|
|
150
|
+
if (p.isCancel(runRawFirst))
|
|
52
151
|
return;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
agent = supportedAgents[0];
|
|
58
|
-
p.log.info(`Using ${agent.displayName}`);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
const choice = await p.select({
|
|
62
|
-
message: "Which agent for compile commands?",
|
|
63
|
-
options: supportedAgents.map((a) => ({
|
|
64
|
-
value: a.name,
|
|
65
|
-
label: a.displayName,
|
|
66
|
-
})),
|
|
152
|
+
if (runRawFirst) {
|
|
153
|
+
rawOutcome = await runSavedRawTest({
|
|
154
|
+
sourcePath,
|
|
155
|
+
workspaceConfig,
|
|
67
156
|
});
|
|
68
|
-
if (p.isCancel(choice))
|
|
69
|
-
return;
|
|
70
|
-
agent = supportedAgents.find((a) => a.name === choice);
|
|
71
|
-
}
|
|
72
|
-
// Step 3: Verify agent connection
|
|
73
|
-
s.start(`Checking ${agent.displayName} connection...`);
|
|
74
|
-
try {
|
|
75
|
-
execSync(`which ${agent.command}`, { stdio: "ignore" });
|
|
76
|
-
s.stop(`${agent.displayName} CLI available`);
|
|
77
157
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
p.log.info("You can compile this workspace now and add questions later when you want to test it.");
|
|
161
|
+
}
|
|
162
|
+
const compileAndTest = workspaceConfig.checks.length > 0 && rawOutcome
|
|
163
|
+
? await p.confirm({
|
|
164
|
+
message: "Compile the workspace and run the same test now? (Recommended)",
|
|
165
|
+
initialValue: true,
|
|
166
|
+
})
|
|
167
|
+
: await p.confirm({
|
|
168
|
+
message: "Compile the workspace now? (Recommended)",
|
|
169
|
+
initialValue: true,
|
|
170
|
+
});
|
|
171
|
+
if (p.isCancel(compileAndTest) || !compileAndTest) {
|
|
172
|
+
console.log();
|
|
173
|
+
console.log(chalk.dim(" Next:"));
|
|
174
|
+
console.log(chalk.dim(" interf compile"));
|
|
175
|
+
if (workspaceConfig.checks.length > 0) {
|
|
176
|
+
console.log(chalk.dim(" interf test"));
|
|
81
177
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const workspacePath = await compileSelectedWorkspace(sourcePath, workspaceConfig);
|
|
181
|
+
if (!workspacePath) {
|
|
182
|
+
printSavedTestComparison(rawOutcome, null);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (workspaceConfig.checks.length === 0) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!rawOutcome) {
|
|
189
|
+
const runWorkspaceTest = await p.confirm({
|
|
190
|
+
message: "Run the saved test on the compiled workspace now? (Recommended)",
|
|
191
|
+
initialValue: true,
|
|
88
192
|
});
|
|
89
|
-
|
|
90
|
-
? await p.confirm({
|
|
91
|
-
message: "Create the main Interf workspace for this folder now?",
|
|
92
|
-
initialValue: true,
|
|
93
|
-
})
|
|
94
|
-
: false;
|
|
95
|
-
if (p.isCancel(attachNow))
|
|
96
|
-
return;
|
|
97
|
-
if (attachNow) {
|
|
98
|
-
const configured = await ensureSourceFolderConfig(cwd);
|
|
99
|
-
if (!configured)
|
|
100
|
-
return;
|
|
101
|
-
p.log.info("Global setup complete. Continuing with knowledge-base creation in this folder.");
|
|
102
|
-
await createKnowledgeBaseWizard({ intro: false, skipSkillInstall: true });
|
|
193
|
+
if (p.isCancel(runWorkspaceTest) || !runWorkspaceTest)
|
|
103
194
|
return;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
195
|
+
}
|
|
196
|
+
workspaceOutcome = await runSavedWorkspaceTest({
|
|
197
|
+
sourcePath,
|
|
198
|
+
workspaceConfig,
|
|
199
|
+
workspacePath,
|
|
200
|
+
});
|
|
201
|
+
printSavedTestComparison(rawOutcome, workspaceOutcome);
|
|
202
|
+
}
|
|
203
|
+
export const initCommand = {
|
|
204
|
+
command: "init",
|
|
205
|
+
describe: "Open the root-folder wizard for this folder",
|
|
206
|
+
handler: async () => {
|
|
207
|
+
await runInitCommand();
|
|
114
208
|
},
|
|
115
209
|
};
|
|
116
|
-
async function
|
|
210
|
+
export async function runInitCommand() {
|
|
211
|
+
p.intro(chalk.bold("Interf"));
|
|
212
|
+
p.log.info("Measure and improve how accurately your local agent answers questions from this folder.");
|
|
213
|
+
const cwd = process.cwd();
|
|
117
214
|
const detected = detectInterf(cwd);
|
|
118
|
-
const
|
|
215
|
+
const sourcePath = detected ? resolveSourceFolderPath(detected.path, detected.config) : cwd;
|
|
119
216
|
if (detected) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
: null;
|
|
131
|
-
if (!sourcePath) {
|
|
132
|
-
p.outro([
|
|
133
|
-
"Global setup unchanged.",
|
|
134
|
-
"",
|
|
135
|
-
`This folder is already attached to Interf at:`,
|
|
136
|
-
` ${detected.path}`,
|
|
137
|
-
"",
|
|
138
|
-
`Next:`,
|
|
139
|
-
` interf compile`,
|
|
140
|
-
` interf create interface`,
|
|
141
|
-
].join("\n"));
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const managed = await maybeManageSourceFolderConfig(sourcePath, currentContext);
|
|
145
|
-
if (!managed)
|
|
217
|
+
p.log.info(`Working from the source folder: ${sourcePath}`);
|
|
218
|
+
}
|
|
219
|
+
const currentConfig = loadSourceFolderConfig(sourcePath);
|
|
220
|
+
if (!currentConfig || listSourceWorkspaceConfigs(currentConfig).length === 0) {
|
|
221
|
+
const workspaceConfig = await promptWorkspaceSetup({
|
|
222
|
+
sourcePath,
|
|
223
|
+
initial: { name: "default" },
|
|
224
|
+
introStyle: "first",
|
|
225
|
+
});
|
|
226
|
+
if (!workspaceConfig)
|
|
146
227
|
return;
|
|
147
|
-
|
|
148
|
-
summaryLabel,
|
|
149
|
-
"",
|
|
150
|
-
`This folder is already attached to Interf at:`,
|
|
151
|
-
` ${detected.path}`,
|
|
152
|
-
`Source config:`,
|
|
153
|
-
` ${sourcePath}/${SOURCE_FOLDER_CONFIG_FILE}`,
|
|
154
|
-
"",
|
|
155
|
-
`Next:`,
|
|
156
|
-
` interf compile`,
|
|
157
|
-
` interf create interface`,
|
|
158
|
-
].join("\n"));
|
|
228
|
+
await runFirstWorkspaceFlow(sourcePath, workspaceConfig);
|
|
159
229
|
return;
|
|
160
230
|
}
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
231
|
+
const selectedWorkspace = await chooseWorkspaceForWizard({
|
|
232
|
+
sourcePath,
|
|
233
|
+
fixedWorkspaceName: detected?.config.name ?? null,
|
|
234
|
+
});
|
|
235
|
+
if (!selectedWorkspace)
|
|
236
|
+
return;
|
|
237
|
+
if (selectedWorkspace === "__new__") {
|
|
238
|
+
const workspaceConfig = await promptWorkspaceSetup({
|
|
239
|
+
sourcePath,
|
|
240
|
+
initial: { name: "default" },
|
|
241
|
+
introStyle: "additional",
|
|
242
|
+
});
|
|
243
|
+
if (!workspaceConfig)
|
|
165
244
|
return;
|
|
166
|
-
|
|
167
|
-
p.outro([
|
|
168
|
-
summaryLabel,
|
|
169
|
-
"",
|
|
170
|
-
`Source config:`,
|
|
171
|
-
` ${cwd}/${SOURCE_FOLDER_CONFIG_FILE}`,
|
|
172
|
-
"",
|
|
173
|
-
`Next:`,
|
|
174
|
-
...(localKnowledgeBases.length > 0
|
|
175
|
-
? [
|
|
176
|
-
` interf compile`,
|
|
177
|
-
` interf benchmark`,
|
|
178
|
-
` interf create interface`,
|
|
179
|
-
]
|
|
180
|
-
: [
|
|
181
|
-
` interf create knowledge-base`,
|
|
182
|
-
` interf compile`,
|
|
183
|
-
` interf benchmark`,
|
|
184
|
-
]),
|
|
185
|
-
].join("\n"));
|
|
245
|
+
await runFirstWorkspaceFlow(sourcePath, workspaceConfig);
|
|
186
246
|
return;
|
|
187
247
|
}
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
248
|
+
const builtWorkspacePath = findBuiltWorkspacePath(sourcePath, selectedWorkspace.name);
|
|
249
|
+
printWorkspaceSummary({
|
|
250
|
+
sourcePath,
|
|
251
|
+
workspace: selectedWorkspace,
|
|
252
|
+
built: Boolean(builtWorkspacePath),
|
|
191
253
|
});
|
|
192
|
-
|
|
254
|
+
const action = await promptWorkspaceAction(selectedWorkspace, Boolean(builtWorkspacePath));
|
|
255
|
+
if (!action)
|
|
193
256
|
return;
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
if (!configured)
|
|
197
|
-
return;
|
|
198
|
-
await createKnowledgeBaseWizard({ intro: false, skipSkillInstall: true });
|
|
257
|
+
if (action === "done") {
|
|
258
|
+
p.outro("Nothing changed.");
|
|
199
259
|
return;
|
|
200
260
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
"This command did not create a knowledge base in the current folder.",
|
|
205
|
-
"",
|
|
206
|
-
"To attach and compile this folder later, run:",
|
|
207
|
-
" interf init",
|
|
208
|
-
" interf compile",
|
|
209
|
-
" interf benchmark",
|
|
210
|
-
].join("\n"));
|
|
211
|
-
}
|
|
212
|
-
async function ensureSourceFolderConfig(sourcePath) {
|
|
213
|
-
const existing = loadSourceFolderConfig(sourcePath);
|
|
214
|
-
if (existing) {
|
|
215
|
-
p.log.info(`Using existing ${SOURCE_FOLDER_CONFIG_FILE} in this folder. You can edit it any time.`);
|
|
216
|
-
p.log.info("Top-level evals are shared baseline checks for the workspace and every interface. `interfaces[].evals` add task-specific checks in the same file.");
|
|
217
|
-
p.log.info("These evals become the pass/fail checks used by `interf benchmark`.");
|
|
218
|
-
return true;
|
|
261
|
+
if (action === "workflow") {
|
|
262
|
+
await createWorkflowWizard({ sourcePath });
|
|
263
|
+
return;
|
|
219
264
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
answerPlaceholder: DEFAULT_SHARED_EVAL_ANSWER_PLACEHOLDER,
|
|
231
|
-
addAnotherMessage: "Add another shared eval?",
|
|
232
|
-
});
|
|
233
|
-
if (evals === null)
|
|
234
|
-
return false;
|
|
235
|
-
const interfaces = await promptInterfaceConfigs();
|
|
236
|
-
if (interfaces === null)
|
|
237
|
-
return false;
|
|
238
|
-
saveSourceFolderConfig(sourcePath, {
|
|
239
|
-
evals,
|
|
240
|
-
...(interfaces.length > 0 ? { interfaces } : {}),
|
|
241
|
-
});
|
|
242
|
-
p.log.info(`Saved ${SOURCE_FOLDER_CONFIG_FILE}. You can edit it any time.`);
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
async function maybeManageSourceFolderConfig(sourcePath, options = {}) {
|
|
246
|
-
const existing = loadSourceFolderConfig(sourcePath);
|
|
247
|
-
if (!existing) {
|
|
248
|
-
return ensureSourceFolderConfig(sourcePath);
|
|
265
|
+
if (action === "workspace") {
|
|
266
|
+
const workspaceConfig = await promptWorkspaceSetup({
|
|
267
|
+
sourcePath,
|
|
268
|
+
initial: { name: "default" },
|
|
269
|
+
introStyle: "additional",
|
|
270
|
+
});
|
|
271
|
+
if (!workspaceConfig)
|
|
272
|
+
return;
|
|
273
|
+
await runFirstWorkspaceFlow(sourcePath, workspaceConfig);
|
|
274
|
+
return;
|
|
249
275
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
{
|
|
257
|
-
value: "keep",
|
|
258
|
-
label: "Keep current config",
|
|
259
|
-
hint: "Use the existing evals and interfaces as-is",
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
value: "add-shared-evals",
|
|
263
|
-
label: "Add shared evals",
|
|
264
|
-
hint: "For the main workspace and every interface benchmark",
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
value: "add-interface",
|
|
268
|
-
label: "Add or update one interface",
|
|
269
|
-
hint: "Create or edit one task-specific compiled workspace on top of the main one",
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
});
|
|
273
|
-
if (p.isCancel(choice))
|
|
274
|
-
return false;
|
|
275
|
-
if (choice === "keep")
|
|
276
|
-
return true;
|
|
277
|
-
if (choice === "add-shared-evals") {
|
|
278
|
-
const currentSharedEvals = existing.evals ?? existing.knowledge_base?.evals ?? [];
|
|
279
|
-
const evals = await promptEvalCases({
|
|
280
|
-
heading: "Add shared evals",
|
|
281
|
-
questionMessage: `Shared eval ${currentSharedEvals.length + 1} question?`,
|
|
282
|
-
questionPlaceholder: DEFAULT_SHARED_EVAL_QUESTION_PLACEHOLDER,
|
|
283
|
-
answerMessage: `Shared eval ${currentSharedEvals.length + 1} expected answer?`,
|
|
284
|
-
answerPlaceholder: DEFAULT_SHARED_EVAL_ANSWER_PLACEHOLDER,
|
|
285
|
-
addAnotherMessage: "Add another shared eval?",
|
|
286
|
-
startIndex: currentSharedEvals.length + 1,
|
|
276
|
+
if (action === "edit") {
|
|
277
|
+
const workspaceConfig = await promptWorkspaceSetup({
|
|
278
|
+
sourcePath,
|
|
279
|
+
initial: selectedWorkspace,
|
|
280
|
+
fixedName: selectedWorkspace.name,
|
|
281
|
+
introStyle: "edit",
|
|
287
282
|
});
|
|
288
|
-
if (
|
|
289
|
-
return
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
return true;
|
|
283
|
+
if (!workspaceConfig)
|
|
284
|
+
return;
|
|
285
|
+
await runFirstWorkspaceFlow(sourcePath, workspaceConfig);
|
|
286
|
+
return;
|
|
293
287
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (options.currentTargetType === "interface" && options.currentInterfaceName) {
|
|
301
|
-
fixedName = options.currentInterfaceName;
|
|
302
|
-
initial = existingInterfaces.find((entry) => entry.name === fixedName);
|
|
303
|
-
if (initial) {
|
|
304
|
-
p.log.info(`Updating interface evals for "${fixedName}" from the current interface folder.`);
|
|
305
|
-
p.log.info(`Current interface purpose: ${initial.about}`);
|
|
288
|
+
if (action === "raw") {
|
|
289
|
+
if (selectedWorkspace.checks.length === 0) {
|
|
290
|
+
process.exitCode = 1;
|
|
291
|
+
console.log(chalk.red(` Workspace "${selectedWorkspace.name}" does not have any saved questions yet.`));
|
|
292
|
+
console.log(chalk.dim(" Run `interf` or `interf init` to add a few first."));
|
|
293
|
+
return;
|
|
306
294
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
295
|
+
const rawOutcome = await runSavedRawTest({
|
|
296
|
+
sourcePath,
|
|
297
|
+
workspaceConfig: selectedWorkspace,
|
|
298
|
+
});
|
|
299
|
+
if (!rawOutcome)
|
|
300
|
+
return;
|
|
301
|
+
const compileAndCompare = await p.confirm({
|
|
302
|
+
message: "Compile the workspace and run the same test now? (Recommended)",
|
|
303
|
+
initialValue: true,
|
|
304
|
+
});
|
|
305
|
+
if (p.isCancel(compileAndCompare) || !compileAndCompare) {
|
|
306
|
+
printSavedTestComparison(rawOutcome, null);
|
|
307
|
+
return;
|
|
316
308
|
}
|
|
317
|
-
|
|
318
|
-
|
|
309
|
+
const workspacePath = await compileSelectedWorkspace(sourcePath, selectedWorkspace);
|
|
310
|
+
if (!workspacePath) {
|
|
311
|
+
printSavedTestComparison(rawOutcome, null);
|
|
312
|
+
return;
|
|
319
313
|
}
|
|
314
|
+
const workspaceOutcome = await runSavedWorkspaceTest({
|
|
315
|
+
sourcePath,
|
|
316
|
+
workspaceConfig: selectedWorkspace,
|
|
317
|
+
workspacePath,
|
|
318
|
+
});
|
|
319
|
+
printSavedTestComparison(rawOutcome, workspaceOutcome);
|
|
320
|
+
return;
|
|
320
321
|
}
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
{
|
|
331
|
-
value: "__create_new__",
|
|
332
|
-
label: "Create new interface",
|
|
333
|
-
hint: "Add a new interface block to this file",
|
|
334
|
-
},
|
|
335
|
-
],
|
|
322
|
+
if (action === "compile") {
|
|
323
|
+
const workspacePath = await compileSelectedWorkspace(sourcePath, selectedWorkspace);
|
|
324
|
+
if (!workspacePath)
|
|
325
|
+
return;
|
|
326
|
+
if (selectedWorkspace.checks.length === 0)
|
|
327
|
+
return;
|
|
328
|
+
const runWorkspaceTest = await p.confirm({
|
|
329
|
+
message: "Run the saved test on the compiled workspace now?",
|
|
330
|
+
initialValue: true,
|
|
336
331
|
});
|
|
337
|
-
if (p.isCancel(
|
|
338
|
-
return
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
332
|
+
if (p.isCancel(runWorkspaceTest) || !runWorkspaceTest)
|
|
333
|
+
return;
|
|
334
|
+
const workspaceOutcome = await runSavedWorkspaceTest({
|
|
335
|
+
sourcePath,
|
|
336
|
+
workspaceConfig: selectedWorkspace,
|
|
337
|
+
workspacePath,
|
|
338
|
+
});
|
|
339
|
+
printSavedTestComparison(null, workspaceOutcome);
|
|
340
|
+
return;
|
|
342
341
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
342
|
+
if (!builtWorkspacePath) {
|
|
343
|
+
process.exitCode = 1;
|
|
344
|
+
console.log(chalk.red(` Workspace "${selectedWorkspace.name}" is not compiled yet.`));
|
|
345
|
+
console.log(chalk.dim(" Run `interf compile` first."));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const workspaceOutcome = await runSavedWorkspaceTest({
|
|
349
|
+
sourcePath,
|
|
350
|
+
workspaceConfig: selectedWorkspace,
|
|
351
|
+
workspacePath: builtWorkspacePath,
|
|
352
352
|
});
|
|
353
|
-
|
|
354
|
-
return true;
|
|
353
|
+
printSavedTestComparison(null, workspaceOutcome);
|
|
355
354
|
}
|
|
356
355
|
//# sourceMappingURL=init.js.map
|