@interf/compiler 0.9.4 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -91
- package/TRADEMARKS.md +2 -13
- package/agent-skills/interf-actions/SKILL.md +97 -32
- package/agent-skills/interf-actions/references/cli.md +124 -71
- package/builtin-methods/interf-default/README.md +3 -4
- package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
- package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
- package/builtin-methods/interf-default/improve/SKILL.md +1 -1
- package/builtin-methods/interf-default/method.json +10 -4
- package/builtin-methods/interf-default/method.schema.json +0 -9
- package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
- package/dist/cli/commands/compile.d.ts +9 -31
- package/dist/cli/commands/compile.js +75 -388
- package/dist/cli/commands/doctor.js +1 -1
- package/dist/cli/commands/login.d.ts +7 -0
- package/dist/cli/commands/login.js +39 -0
- package/dist/cli/commands/logout.d.ts +2 -0
- package/dist/cli/commands/logout.js +16 -0
- package/dist/cli/commands/method.d.ts +2 -0
- package/dist/cli/commands/method.js +113 -0
- package/dist/cli/commands/prep.d.ts +2 -0
- package/dist/cli/commands/prep.js +134 -0
- package/dist/cli/commands/reset.d.ts +8 -1
- package/dist/cli/commands/reset.js +47 -15
- package/dist/cli/commands/runs.d.ts +2 -0
- package/dist/cli/commands/runs.js +120 -0
- package/dist/cli/commands/status.d.ts +6 -1
- package/dist/cli/commands/status.js +61 -220
- package/dist/cli/commands/test.d.ts +6 -15
- package/dist/cli/commands/test.js +63 -342
- package/dist/cli/commands/web.d.ts +0 -9
- package/dist/cli/commands/web.js +140 -367
- package/dist/cli/commands/wizard.d.ts +9 -0
- package/dist/cli/commands/wizard.js +442 -0
- package/dist/cli/index.d.ts +7 -6
- package/dist/cli/index.js +13 -10
- package/dist/compiler-ui/404.html +1 -1
- package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
- package/dist/compiler-ui/__next._full.txt +3 -3
- package/dist/compiler-ui/__next._head.txt +1 -1
- package/dist/compiler-ui/__next._index.txt +2 -2
- package/dist/compiler-ui/__next._tree.txt +2 -2
- package/dist/compiler-ui/_next/static/chunks/045gole2ojo3g.css +3 -0
- package/dist/compiler-ui/_next/static/chunks/17t-lulmyawg5.js +89 -0
- package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
- package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
- package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
- package/dist/compiler-ui/_not-found.html +1 -1
- package/dist/compiler-ui/_not-found.txt +2 -2
- package/dist/compiler-ui/index.html +1 -1
- package/dist/compiler-ui/index.txt +3 -3
- package/dist/index.d.ts +0 -23
- package/dist/index.js +0 -16
- package/dist/packages/agents/lib/shells.d.ts +1 -1
- package/dist/packages/agents/lib/shells.js +113 -54
- package/dist/packages/agents/lib/user-config.d.ts +4 -2
- package/dist/packages/agents/lib/user-config.js +15 -7
- package/dist/packages/compiler/compiled-paths.d.ts +9 -2
- package/dist/packages/compiler/compiled-paths.js +30 -15
- package/dist/packages/compiler/compiled-pipeline.js +23 -3
- package/dist/packages/compiler/compiled-stage-plan.js +4 -0
- package/dist/packages/compiler/compiled-target.d.ts +1 -1
- package/dist/packages/compiler/compiled-target.js +1 -1
- package/dist/packages/compiler/index.d.ts +1 -0
- package/dist/packages/compiler/index.js +1 -0
- package/dist/packages/compiler/lib/schema.d.ts +27 -32
- package/dist/packages/compiler/lib/schema.js +2 -13
- package/dist/packages/compiler/method-runs.d.ts +2 -3
- package/dist/packages/compiler/method-runs.js +2 -3
- package/dist/packages/compiler/reset.js +3 -1
- package/dist/packages/compiler/runtime-contracts.js +0 -3
- package/dist/packages/compiler/runtime-prompt.js +1 -1
- package/dist/packages/compiler/source-files.d.ts +46 -0
- package/dist/packages/compiler/source-files.js +149 -0
- package/dist/packages/compiler/state-artifacts.d.ts +3 -2
- package/dist/packages/compiler/state-artifacts.js +4 -3
- package/dist/packages/compiler/state-io.d.ts +3 -2
- package/dist/packages/compiler/state-io.js +11 -5
- package/dist/packages/compiler/state-paths.d.ts +2 -1
- package/dist/packages/compiler/state-paths.js +6 -3
- package/dist/packages/compiler/state-view.d.ts +3 -2
- package/dist/packages/compiler/state-view.js +18 -28
- package/dist/packages/compiler/state.d.ts +4 -4
- package/dist/packages/compiler/state.js +3 -3
- package/dist/packages/contracts/index.d.ts +1 -1
- package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
- package/dist/packages/contracts/lib/preparation-paths.js +177 -0
- package/dist/packages/contracts/lib/schema.d.ts +85 -6
- package/dist/packages/contracts/lib/schema.js +46 -2
- package/dist/packages/execution/lib/schema.d.ts +50 -57
- package/dist/packages/execution/lib/schema.js +1 -2
- package/dist/packages/local-service/action-definitions.d.ts +246 -0
- package/dist/packages/local-service/action-definitions.js +1147 -0
- package/dist/packages/local-service/action-planner.d.ts +9 -0
- package/dist/packages/local-service/action-planner.js +135 -0
- package/dist/packages/local-service/action-values.d.ts +1 -23
- package/dist/packages/local-service/action-values.js +1 -31
- package/dist/packages/local-service/client.d.ts +76 -46
- package/dist/packages/local-service/client.js +184 -149
- package/dist/packages/local-service/connection-config.d.ts +38 -0
- package/dist/packages/local-service/connection-config.js +75 -0
- package/dist/packages/local-service/index.d.ts +14 -7
- package/dist/packages/local-service/index.js +8 -4
- package/dist/packages/local-service/instance-paths.d.ts +100 -0
- package/dist/packages/local-service/instance-paths.js +165 -0
- package/dist/packages/local-service/lib/schema.d.ts +689 -2575
- package/dist/packages/local-service/lib/schema.js +260 -101
- package/dist/packages/local-service/native-run-handlers.d.ts +23 -0
- package/dist/{cli/commands/compile-controller.js → packages/local-service/native-run-handlers.js} +204 -20
- package/dist/packages/local-service/preparation-store.d.ts +92 -0
- package/dist/packages/local-service/preparation-store.js +171 -0
- package/dist/{cli/commands/check-draft.d.ts → packages/local-service/readiness-check-draft.d.ts} +2 -2
- package/dist/packages/local-service/routes.d.ts +33 -11
- package/dist/packages/local-service/routes.js +44 -15
- package/dist/packages/local-service/run-observability.js +25 -27
- package/dist/packages/local-service/runtime-caches.d.ts +76 -0
- package/dist/packages/local-service/runtime-caches.js +191 -0
- package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
- package/dist/packages/local-service/runtime-event-applier.js +177 -0
- package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
- package/dist/packages/local-service/runtime-persistence.js +137 -0
- package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
- package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
- package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
- package/dist/packages/local-service/runtime-resource-builders.js +149 -0
- package/dist/packages/local-service/runtime.d.ts +201 -44
- package/dist/packages/local-service/runtime.js +1062 -1106
- package/dist/packages/local-service/server.d.ts +15 -0
- package/dist/packages/local-service/server.js +651 -233
- package/dist/packages/local-service/service-registry.d.ts +47 -0
- package/dist/packages/local-service/service-registry.js +137 -0
- package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
- package/dist/packages/method-authoring/method-authoring.js +2 -2
- package/dist/packages/method-authoring/method-improvement.js +1 -1
- package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
- package/dist/packages/method-package/builtin-compiled-method.js +8 -14
- package/dist/packages/method-package/context-interface.d.ts +4 -40
- package/dist/packages/method-package/context-interface.js +1 -23
- package/dist/packages/method-package/interf-method-package.d.ts +4 -4
- package/dist/packages/method-package/interf-method-package.js +21 -33
- package/dist/packages/method-package/local-methods.d.ts +10 -6
- package/dist/packages/method-package/local-methods.js +57 -39
- package/dist/packages/method-package/method-definitions.d.ts +8 -34
- package/dist/packages/method-package/method-definitions.js +49 -37
- package/dist/packages/method-package/method-helpers.d.ts +1 -13
- package/dist/packages/method-package/method-helpers.js +8 -42
- package/dist/packages/method-package/method-review-paths.d.ts +1 -1
- package/dist/packages/method-package/method-review-paths.js +5 -5
- package/dist/packages/method-package/method-stage-runner.js +2 -2
- package/dist/packages/method-package/user-methods.d.ts +17 -0
- package/dist/packages/method-package/user-methods.js +77 -0
- package/dist/packages/project-model/index.d.ts +1 -1
- package/dist/packages/project-model/index.js +1 -1
- package/dist/packages/project-model/interf-detect.d.ts +8 -3
- package/dist/packages/project-model/interf-detect.js +34 -34
- package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
- package/dist/packages/project-model/interf-scaffold.js +23 -32
- package/dist/packages/project-model/lib/schema.js +38 -1
- package/dist/packages/project-model/preparation-entries.d.ts +11 -0
- package/dist/packages/project-model/preparation-entries.js +49 -0
- package/dist/packages/project-model/source-config.d.ts +11 -10
- package/dist/packages/project-model/source-config.js +83 -44
- package/dist/packages/project-model/source-folders.d.ts +5 -5
- package/dist/packages/project-model/source-folders.js +14 -14
- package/dist/packages/shared/filesystem.d.ts +7 -0
- package/dist/packages/shared/filesystem.js +97 -10
- package/dist/packages/testing/lib/schema.d.ts +12 -13
- package/dist/packages/testing/lib/schema.js +4 -5
- package/dist/packages/testing/readiness-check-run.d.ts +7 -7
- package/dist/packages/testing/readiness-check-run.js +46 -51
- package/dist/packages/testing/test-execution.js +6 -6
- package/dist/packages/testing/test-paths.js +4 -3
- package/dist/packages/testing/test-sandbox.d.ts +0 -1
- package/dist/packages/testing/test-sandbox.js +14 -30
- package/dist/packages/testing/test-targets.d.ts +1 -1
- package/dist/packages/testing/test-targets.js +6 -6
- package/dist/packages/testing/test.d.ts +1 -1
- package/dist/packages/testing/test.js +1 -1
- package/package.json +6 -26
- package/LICENSE +0 -183
- package/dist/cli/commands/compile-controller.d.ts +0 -17
- package/dist/cli/commands/compiled-flow.d.ts +0 -25
- package/dist/cli/commands/compiled-flow.js +0 -112
- package/dist/cli/commands/control-path.d.ts +0 -11
- package/dist/cli/commands/control-path.js +0 -72
- package/dist/cli/commands/create-method-wizard.d.ts +0 -76
- package/dist/cli/commands/create-method-wizard.js +0 -465
- package/dist/cli/commands/create.d.ts +0 -8
- package/dist/cli/commands/create.js +0 -189
- package/dist/cli/commands/default.d.ts +0 -2
- package/dist/cli/commands/default.js +0 -39
- package/dist/cli/commands/executor-flow.d.ts +0 -29
- package/dist/cli/commands/executor-flow.js +0 -163
- package/dist/cli/commands/init.d.ts +0 -11
- package/dist/cli/commands/init.js +0 -784
- package/dist/cli/commands/list.d.ts +0 -2
- package/dist/cli/commands/list.js +0 -30
- package/dist/cli/commands/preparation-selection.d.ts +0 -6
- package/dist/cli/commands/preparation-selection.js +0 -11
- package/dist/cli/commands/source-config-wizard.d.ts +0 -52
- package/dist/cli/commands/source-config-wizard.js +0 -680
- package/dist/cli/commands/test-flow.d.ts +0 -58
- package/dist/cli/commands/test-flow.js +0 -231
- package/dist/cli/commands/verify.d.ts +0 -2
- package/dist/cli/commands/verify.js +0 -94
- package/dist/compiler-ui/_next/static/chunks/0d~8t0zm6545p.js +0 -118
- package/dist/compiler-ui/_next/static/chunks/0xnel.ax9a.2c.css +0 -3
- package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
- package/dist/packages/compiler/raw-snapshot.js +0 -101
- package/dist/packages/method-package/index.d.ts +0 -11
- package/dist/packages/method-package/index.js +0 -11
- package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
- package/dist/packages/method-package/method-stage-policy.js +0 -31
- package/dist/packages/project-model/project-paths.d.ts +0 -12
- package/dist/packages/project-model/project-paths.js +0 -33
- /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
- /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
- /package/dist/{cli/commands/check-draft.js → packages/local-service/readiness-check-draft.js} +0 -0
|
@@ -1,784 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import * as p from "@clack/prompts";
|
|
3
|
-
import { existsSync, statSync } from "node:fs";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import { basename, isAbsolute, relative, resolve } from "node:path";
|
|
6
|
-
import { assertCompiledContainer, detectInterf, ensurePortableContextScaffold, readInterfConfig, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
|
|
7
|
-
import { SOURCE_FOLDER_CONFIG_PATH, configuredSourceFolderPath, loadSourceFolderConfig, resolveConfiguredSourceFolderPath, saveSourceFolderConfig, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../../packages/project-model/source-config.js";
|
|
8
|
-
import { defaultPreparationNameForPath, } from "../../packages/project-model/source-folders.js";
|
|
9
|
-
import { DEFAULT_PREPARATION_NAME, describeCompileLoopSelection, listSourceFolderChoices, promptSingleCompiledConfig, } from "./source-config-wizard.js";
|
|
10
|
-
import { chooseOrCreateCompiledMethodForPreparation, createMethodWizard, } from "./create-method-wizard.js";
|
|
11
|
-
import { seedLocalDefaultMethod } from "../../packages/method-package/local-methods.js";
|
|
12
|
-
import { findBuiltCompiledPath, findSavedCompiledConfig, listSavedPreparationEntries, } from "./compiled-flow.js";
|
|
13
|
-
import { readCurrentSavedTestComparison, } from "./test-flow.js";
|
|
14
|
-
import { runCompileCommand } from "./compile.js";
|
|
15
|
-
import { runTestCommand } from "./test.js";
|
|
16
|
-
import { defaultInterfInstanceRoot, relativeSourceFolderPath, resolveInterfInstanceContext, } from "./control-path.js";
|
|
17
|
-
import { runWebCommand } from "./web.js";
|
|
18
|
-
function displayPath(path) {
|
|
19
|
-
const resolvedPath = resolve(path);
|
|
20
|
-
const cwd = process.cwd();
|
|
21
|
-
if (resolvedPath === cwd)
|
|
22
|
-
return ".";
|
|
23
|
-
if (isPathInside(cwd, resolvedPath))
|
|
24
|
-
return `./${relative(cwd, resolvedPath)}`;
|
|
25
|
-
const home = homedir();
|
|
26
|
-
if (resolvedPath === home)
|
|
27
|
-
return "~";
|
|
28
|
-
if (isPathInside(home, resolvedPath))
|
|
29
|
-
return `~/${relative(home, resolvedPath)}`;
|
|
30
|
-
return resolvedPath;
|
|
31
|
-
}
|
|
32
|
-
function isPathInside(parentPath, childPath) {
|
|
33
|
-
const relativePath = relative(parentPath, childPath);
|
|
34
|
-
return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
|
|
35
|
-
}
|
|
36
|
-
function normalizeSourceFolderInput(cwd, input) {
|
|
37
|
-
const trimmed = input.trim();
|
|
38
|
-
if (trimmed.length === 0) {
|
|
39
|
-
throw new Error("Source Folder is required.");
|
|
40
|
-
}
|
|
41
|
-
const sourceFolderPath = resolve(cwd, trimmed);
|
|
42
|
-
if (!existsSync(sourceFolderPath)) {
|
|
43
|
-
throw new Error("Pick an existing Source Folder.");
|
|
44
|
-
}
|
|
45
|
-
if (!statSync(sourceFolderPath).isDirectory()) {
|
|
46
|
-
throw new Error("Source Folder must be a directory.");
|
|
47
|
-
}
|
|
48
|
-
return sourceFolderPath;
|
|
49
|
-
}
|
|
50
|
-
function normalizeInterfInstanceFolderInput(cwd, sourceFolderPath, input) {
|
|
51
|
-
const trimmed = input.trim();
|
|
52
|
-
if (trimmed.length === 0) {
|
|
53
|
-
throw new Error("Interf Workspace folder is required.");
|
|
54
|
-
}
|
|
55
|
-
const controlPath = resolve(cwd, trimmed);
|
|
56
|
-
if (isPathInside(sourceFolderPath, controlPath)) {
|
|
57
|
-
throw new Error("Choose an Interf Workspace folder outside the Source Folder so Interf does not write generated state into your source files.");
|
|
58
|
-
}
|
|
59
|
-
assertCompiledContainer(controlPath);
|
|
60
|
-
return controlPath;
|
|
61
|
-
}
|
|
62
|
-
async function promptSourceFolderForInstance(cwd) {
|
|
63
|
-
const folderChoices = listSourceFolderChoices(cwd);
|
|
64
|
-
const selected = await p.select({
|
|
65
|
-
message: "Which Source Folder should Interf prepare?",
|
|
66
|
-
options: [
|
|
67
|
-
...folderChoices,
|
|
68
|
-
{
|
|
69
|
-
value: "__current__",
|
|
70
|
-
label: `Use current folder (${basename(cwd)})`,
|
|
71
|
-
hint: cwd,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
value: "__manual__",
|
|
75
|
-
label: "Enter a different path",
|
|
76
|
-
hint: "Use an absolute path or a path relative to this folder",
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
initialValue: folderChoices.length === 1 ? folderChoices[0]?.value : "__current__",
|
|
80
|
-
});
|
|
81
|
-
if (p.isCancel(selected))
|
|
82
|
-
return null;
|
|
83
|
-
if (selected === "__manual__") {
|
|
84
|
-
const sourceInput = await p.text({
|
|
85
|
-
message: "Source Folder path?",
|
|
86
|
-
placeholder: cwd,
|
|
87
|
-
initialValue: cwd,
|
|
88
|
-
validate: (value) => {
|
|
89
|
-
try {
|
|
90
|
-
normalizeSourceFolderInput(cwd, value);
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
return error instanceof Error ? error.message : String(error);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
if (p.isCancel(sourceInput))
|
|
99
|
-
return null;
|
|
100
|
-
return normalizeSourceFolderInput(cwd, String(sourceInput));
|
|
101
|
-
}
|
|
102
|
-
return normalizeSourceFolderInput(cwd, selected === "__current__" ? "." : String(selected));
|
|
103
|
-
}
|
|
104
|
-
async function promptInterfInstanceFolder(cwd, sourceFolderPath) {
|
|
105
|
-
const defaultControlPath = defaultInterfInstanceRoot(sourceFolderPath);
|
|
106
|
-
p.log.info("Interf stores config, Methods, runs, and portable context outside the Source Folder.");
|
|
107
|
-
const controlInput = await p.text({
|
|
108
|
-
message: "Where should Interf store this Interf Workspace?",
|
|
109
|
-
placeholder: defaultControlPath,
|
|
110
|
-
initialValue: defaultControlPath,
|
|
111
|
-
validate: (value) => {
|
|
112
|
-
try {
|
|
113
|
-
normalizeInterfInstanceFolderInput(cwd, sourceFolderPath, value);
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
return error instanceof Error ? error.message : String(error);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
if (p.isCancel(controlInput))
|
|
122
|
-
return null;
|
|
123
|
-
return normalizeInterfInstanceFolderInput(cwd, sourceFolderPath, String(controlInput));
|
|
124
|
-
}
|
|
125
|
-
async function setupInterfInstance(cwd) {
|
|
126
|
-
const sourceFolderPath = await promptSourceFolderForInstance(cwd);
|
|
127
|
-
if (!sourceFolderPath)
|
|
128
|
-
return null;
|
|
129
|
-
const controlPath = await promptInterfInstanceFolder(cwd, sourceFolderPath);
|
|
130
|
-
if (!controlPath)
|
|
131
|
-
return null;
|
|
132
|
-
const sourceFolderConfigPath = relativeSourceFolderPath(controlPath, sourceFolderPath);
|
|
133
|
-
saveSourceFolderConfig(controlPath, {
|
|
134
|
-
source_folder: { path: sourceFolderConfigPath },
|
|
135
|
-
preparations: [],
|
|
136
|
-
});
|
|
137
|
-
const seeded = seedLocalDefaultMethod({ sourcePath: controlPath });
|
|
138
|
-
p.log.info(`Source Folder: ${displayPath(sourceFolderPath)}`);
|
|
139
|
-
p.log.info(`Interf Workspace: ${displayPath(controlPath)}`);
|
|
140
|
-
if (!seeded.alreadyExisted)
|
|
141
|
-
p.log.info(`Method: ${seeded.methodId}`);
|
|
142
|
-
return {
|
|
143
|
-
sourceFolderPath,
|
|
144
|
-
controlPath,
|
|
145
|
-
sourceFolderConfigPath,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
async function promptEmptyInstanceAction() {
|
|
149
|
-
const selected = await p.select({
|
|
150
|
-
message: "What next?",
|
|
151
|
-
options: [
|
|
152
|
-
{
|
|
153
|
-
value: "web",
|
|
154
|
-
label: "Open Interf UI (Recommended)",
|
|
155
|
-
hint: "Start the local UI and API for this Source Folder",
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
value: "preparation",
|
|
159
|
-
label: "Create Preparation",
|
|
160
|
-
hint: "Describe the agent work, choose a Method, and save readiness checks",
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
value: "method",
|
|
164
|
-
label: "Create Method",
|
|
165
|
-
hint: "Create or draft a reusable way to process files",
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
value: "done",
|
|
169
|
-
label: "Done",
|
|
170
|
-
hint: `Leave the empty Interf Workspace at ${SOURCE_FOLDER_CONFIG_PATH}`,
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
});
|
|
174
|
-
if (p.isCancel(selected))
|
|
175
|
-
return null;
|
|
176
|
-
return selected;
|
|
177
|
-
}
|
|
178
|
-
export function currentRunTargetStatus(rows, target) {
|
|
179
|
-
const outcomes = rows
|
|
180
|
-
.map((row) => (target === "raw" ? row.rawOutcome : row.compiledOutcome))
|
|
181
|
-
.filter((outcome) => Boolean(outcome));
|
|
182
|
-
if (outcomes.length === 0)
|
|
183
|
-
return "missing";
|
|
184
|
-
const passFlags = outcomes.map((outcome) => outcome.result.totalCases > 0 && outcome.result.passedCases === outcome.result.totalCases);
|
|
185
|
-
if (passFlags.every(Boolean))
|
|
186
|
-
return "pass";
|
|
187
|
-
if (passFlags.some(Boolean))
|
|
188
|
-
return "mixed";
|
|
189
|
-
return "fail";
|
|
190
|
-
}
|
|
191
|
-
function describeSavedReadinessChecks(preparation) {
|
|
192
|
-
const count = preparation.checks.length;
|
|
193
|
-
if (count === 0)
|
|
194
|
-
return "no checks";
|
|
195
|
-
return `${count} readiness check${count === 1 ? "" : "s"}`;
|
|
196
|
-
}
|
|
197
|
-
function printPreparationSummary(options) {
|
|
198
|
-
const compiledConfig = options.builtCompiledPath
|
|
199
|
-
? readInterfConfig(options.builtCompiledPath)
|
|
200
|
-
: null;
|
|
201
|
-
const methodLabel = `${options.preparation.method ?? "interf-default"}${compiledConfig?.method_origin?.local_draft === true ? " (local draft)" : ""}`;
|
|
202
|
-
const sourceFolderPath = resolve(options.sourcePath, options.preparation.path);
|
|
203
|
-
p.log.info(`Preparation: ${options.preparation.name} · Method: ${methodLabel}`);
|
|
204
|
-
if (options.preparation.about) {
|
|
205
|
-
p.log.info(`Agent work: ${options.preparation.about}`);
|
|
206
|
-
}
|
|
207
|
-
p.log.info(`Source Folder: ${displayPath(sourceFolderPath)}`);
|
|
208
|
-
p.log.info(`Portable Context: ${options.built ? "built" : "not built"} · Readiness: ${describeSavedReadinessChecks(options.preparation)}`);
|
|
209
|
-
const prepareMode = describeCompileLoopSelection({
|
|
210
|
-
maxAttempts: options.preparation.max_attempts,
|
|
211
|
-
maxLoops: options.preparation.max_loops,
|
|
212
|
-
});
|
|
213
|
-
if (prepareMode !== "Prepare once.")
|
|
214
|
-
p.log.info(`Prepare mode: ${prepareMode}`);
|
|
215
|
-
if (options.latestComparison?.raw && options.latestComparison?.compiled) {
|
|
216
|
-
p.log.info(`Latest saved comparison: source files ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}, Portable Context ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
|
|
217
|
-
}
|
|
218
|
-
else if (options.latestComparison?.raw) {
|
|
219
|
-
p.log.info(`Latest saved source-files run: ${options.latestComparison.raw.passed_cases}/${options.latestComparison.raw.total_cases}.`);
|
|
220
|
-
}
|
|
221
|
-
else if (options.latestComparison?.compiled) {
|
|
222
|
-
p.log.info(`Latest Portable Context run: ${options.latestComparison.compiled.passed_cases}/${options.latestComparison.compiled.total_cases}.`);
|
|
223
|
-
}
|
|
224
|
-
else if (options.latestComparisonStale) {
|
|
225
|
-
p.log.info("Saved readiness results are stale for the current checks.");
|
|
226
|
-
}
|
|
227
|
-
if (options.sourcePath !== process.cwd()) {
|
|
228
|
-
p.log.info(`Interf Workspace: ${displayPath(options.sourcePath)}`);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
async function promptPreparationAction(preparation, built, latestComparison) {
|
|
232
|
-
const options = [];
|
|
233
|
-
const hasSavedRawBaseline = Boolean(latestComparison?.raw);
|
|
234
|
-
const latestRawPasses = latestComparison?.raw &&
|
|
235
|
-
latestComparison.raw.passed_cases === latestComparison.raw.total_cases;
|
|
236
|
-
const compileOption = {
|
|
237
|
-
value: "compile",
|
|
238
|
-
label: built ? "Prepare again" : "Prepare files",
|
|
239
|
-
hint: built
|
|
240
|
-
? "Refresh Portable Context"
|
|
241
|
-
: preparation.checks.length > 0
|
|
242
|
-
? latestRawPasses
|
|
243
|
-
? "Use the latest source-files baseline"
|
|
244
|
-
: hasSavedRawBaseline
|
|
245
|
-
? "Run the same readiness checks after prepare"
|
|
246
|
-
: "Write Portable Context"
|
|
247
|
-
: "Write Portable Context",
|
|
248
|
-
};
|
|
249
|
-
const webOption = {
|
|
250
|
-
value: "web",
|
|
251
|
-
label: "Open Interf UI",
|
|
252
|
-
hint: "Start the local UI and API for this Interf Workspace",
|
|
253
|
-
};
|
|
254
|
-
if (built) {
|
|
255
|
-
options.push(webOption);
|
|
256
|
-
}
|
|
257
|
-
if (preparation.checks.length > 0) {
|
|
258
|
-
const testOption = {
|
|
259
|
-
value: "test",
|
|
260
|
-
label: built
|
|
261
|
-
? "Run readiness checks"
|
|
262
|
-
: hasSavedRawBaseline
|
|
263
|
-
? "Rerun the source-files baseline"
|
|
264
|
-
: "Measure the source-files baseline",
|
|
265
|
-
hint: built
|
|
266
|
-
? "Check source files and Portable Context"
|
|
267
|
-
: hasSavedRawBaseline
|
|
268
|
-
? "Refresh the saved source-files baseline on the current readiness checks"
|
|
269
|
-
: "Optional source-files readiness baseline before Interf builds Portable Context",
|
|
270
|
-
};
|
|
271
|
-
if (built) {
|
|
272
|
-
options.push(testOption, compileOption);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
options.push(compileOption, testOption);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
options.push(compileOption);
|
|
280
|
-
}
|
|
281
|
-
options.push({
|
|
282
|
-
value: "preparation",
|
|
283
|
-
label: "Add another Preparation",
|
|
284
|
-
hint: "Separate source, focus, or checks",
|
|
285
|
-
}, {
|
|
286
|
-
value: "edit",
|
|
287
|
-
label: preparation.checks.length === 0 ? "Add readiness checks" : "Edit checks and settings",
|
|
288
|
-
hint: "Checks, focus, Method, or mode",
|
|
289
|
-
}, {
|
|
290
|
-
value: "method",
|
|
291
|
-
label: "Create Method",
|
|
292
|
-
hint: "Custom file processing",
|
|
293
|
-
}, {
|
|
294
|
-
value: "done",
|
|
295
|
-
label: "Done",
|
|
296
|
-
hint: "Exit the wizard",
|
|
297
|
-
});
|
|
298
|
-
const selected = await p.select({
|
|
299
|
-
message: "What next?",
|
|
300
|
-
options,
|
|
301
|
-
});
|
|
302
|
-
if (p.isCancel(selected))
|
|
303
|
-
return null;
|
|
304
|
-
return selected;
|
|
305
|
-
}
|
|
306
|
-
function printPreparationRecommendation(preparation, built, latestComparison) {
|
|
307
|
-
if (preparation.checks.length === 0) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
if (!built) {
|
|
311
|
-
if (latestComparison?.raw) {
|
|
312
|
-
p.log.info(latestComparison.raw.passed_cases === latestComparison.raw.total_cases
|
|
313
|
-
? `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Prepare files if you want a side-by-side comparison.`
|
|
314
|
-
: `Latest source-files run: ${latestComparison.raw.passed_cases}/${latestComparison.raw.total_cases}. Some readiness checks still fail on the source files. Prepare files if you want Interf to process this data and run the same checks.`);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
p.log.info("Recommended first step: choose a Method and prepare files.");
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
p.log.info("Recommended first step: compare the source-files baseline and Portable Context.");
|
|
321
|
-
}
|
|
322
|
-
async function promptPostBaselineAction(rows) {
|
|
323
|
-
const status = currentRunTargetStatus(rows, "raw");
|
|
324
|
-
const subject = rows.length === 1 ? "selected agent" : "selected agents";
|
|
325
|
-
if (status === "pass") {
|
|
326
|
-
p.log.info(`Source files passed on all ${subject} in this run.`);
|
|
327
|
-
}
|
|
328
|
-
else if (status === "mixed") {
|
|
329
|
-
p.log.info(`Source files were mixed across the ${subject} in this run.`);
|
|
330
|
-
}
|
|
331
|
-
else if (status === "fail") {
|
|
332
|
-
p.log.info(`Source files did not pass on the ${subject} in this run.`);
|
|
333
|
-
}
|
|
334
|
-
const compileRecommended = status !== "pass";
|
|
335
|
-
const selected = await p.select({
|
|
336
|
-
message: "What next?",
|
|
337
|
-
options: [
|
|
338
|
-
{
|
|
339
|
-
value: "compile",
|
|
340
|
-
label: compileRecommended
|
|
341
|
-
? "Prepare files and write Portable Context (Recommended)"
|
|
342
|
-
: "Prepare files and write Portable Context",
|
|
343
|
-
hint: compileRecommended
|
|
344
|
-
? status === "mixed"
|
|
345
|
-
? "Some selected agents still failed on the source files. Prepare files and run the same readiness checks"
|
|
346
|
-
: "Prepare files and run the same readiness checks"
|
|
347
|
-
: "Prepare files and run the same readiness checks",
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
value: "edit",
|
|
351
|
-
label: "Change readiness checks and settings",
|
|
352
|
-
hint: "Revise the readiness checks or Preparation settings before the next run",
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
value: "rerun",
|
|
356
|
-
label: "Rerun the source-files baseline",
|
|
357
|
-
hint: "Run the same readiness checks again, including different local agents if you want",
|
|
358
|
-
},
|
|
359
|
-
{
|
|
360
|
-
value: "done",
|
|
361
|
-
label: "Stop here",
|
|
362
|
-
hint: "Leave the Preparation as-is for now",
|
|
363
|
-
},
|
|
364
|
-
],
|
|
365
|
-
});
|
|
366
|
-
if (p.isCancel(selected))
|
|
367
|
-
return null;
|
|
368
|
-
return selected;
|
|
369
|
-
}
|
|
370
|
-
async function chooseCompiledForWizard(options) {
|
|
371
|
-
if (options.fixedCompiledName) {
|
|
372
|
-
return findSavedCompiledConfig(options.sourcePath, options.fixedCompiledName);
|
|
373
|
-
}
|
|
374
|
-
const savedEntries = listSavedPreparationEntries(options.sourcePath);
|
|
375
|
-
if (savedEntries.length === 0)
|
|
376
|
-
return null;
|
|
377
|
-
if (savedEntries.length === 1)
|
|
378
|
-
return savedEntries[0]?.config ?? null;
|
|
379
|
-
const selected = await p.select({
|
|
380
|
-
message: "Which saved Preparation do you want to work with?",
|
|
381
|
-
options: [
|
|
382
|
-
...savedEntries.map((entry) => ({
|
|
383
|
-
value: entry.config.name,
|
|
384
|
-
label: entry.config.name,
|
|
385
|
-
hint: [
|
|
386
|
-
`path ${entry.config.path}`,
|
|
387
|
-
entry.config.about ?? describeSavedReadinessChecks(entry.config),
|
|
388
|
-
`Method ${entry.config.method ?? "interf-default"}${entry.localDraft ? " (local draft)" : ""}`,
|
|
389
|
-
entry.path ? "Portable Context available" : "Portable Context not built yet",
|
|
390
|
-
].join(" · "),
|
|
391
|
-
})),
|
|
392
|
-
{
|
|
393
|
-
value: "__new__",
|
|
394
|
-
label: "Add another Preparation",
|
|
395
|
-
hint: "Add a separate folder, focus, or readiness-check set",
|
|
396
|
-
},
|
|
397
|
-
],
|
|
398
|
-
});
|
|
399
|
-
if (p.isCancel(selected))
|
|
400
|
-
return null;
|
|
401
|
-
if (selected === "__new__")
|
|
402
|
-
return "__new__";
|
|
403
|
-
return findSavedCompiledConfig(options.sourcePath, String(selected));
|
|
404
|
-
}
|
|
405
|
-
async function promptCompiledSetup(options) {
|
|
406
|
-
const savedConfig = loadSourceFolderConfig(options.sourcePath);
|
|
407
|
-
const fixedPath = options.fixedPath
|
|
408
|
-
?? (options.fixedName ? options.initial?.path : configuredSourceFolderPath(savedConfig) ?? undefined);
|
|
409
|
-
const compiledConfig = await promptSingleCompiledConfig({
|
|
410
|
-
projectPath: options.sourcePath,
|
|
411
|
-
initial: options.initial,
|
|
412
|
-
...(options.fixedName ? { fixedName: options.fixedName } : {}),
|
|
413
|
-
...(fixedPath ? { fixedPath } : {}),
|
|
414
|
-
introStyle: options.introStyle,
|
|
415
|
-
});
|
|
416
|
-
if (!compiledConfig)
|
|
417
|
-
return null;
|
|
418
|
-
const methodChoice = await chooseOrCreateCompiledMethodForPreparation(options.sourcePath, compiledConfig, {
|
|
419
|
-
currentMethodId: options.initial?.method ?? "interf-default",
|
|
420
|
-
executionProfile: options.executionProfile,
|
|
421
|
-
});
|
|
422
|
-
if (!methodChoice || p.isCancel(methodChoice))
|
|
423
|
-
return null;
|
|
424
|
-
const methodId = String(methodChoice);
|
|
425
|
-
const compiledConfigWithMethod = {
|
|
426
|
-
...compiledConfig,
|
|
427
|
-
method: methodId,
|
|
428
|
-
};
|
|
429
|
-
upsertSourcePreparationConfig(options.sourcePath, compiledConfigWithMethod, {
|
|
430
|
-
...(options.fixedName ? { matchName: options.fixedName } : {}),
|
|
431
|
-
});
|
|
432
|
-
const builtCompiledPath = findBuiltCompiledPath(options.sourcePath, compiledConfigWithMethod.name);
|
|
433
|
-
if (builtCompiledPath) {
|
|
434
|
-
syncCompiledInterfConfigFromSourcePreparationConfig(builtCompiledPath, compiledConfigWithMethod);
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
ensurePortableContextScaffold(options.sourcePath, compiledConfigWithMethod.name, compiledConfigWithMethod.method ?? "interf-default");
|
|
438
|
-
}
|
|
439
|
-
console.log();
|
|
440
|
-
console.log(chalk.green(` ✓ Saved Preparation in ${SOURCE_FOLDER_CONFIG_PATH}`));
|
|
441
|
-
console.log(chalk.dim(` Interf Workspace: ${options.sourcePath}`));
|
|
442
|
-
console.log(chalk.dim(` Preparation: ${compiledConfigWithMethod.name}`));
|
|
443
|
-
console.log(chalk.dim(` Source folder: ${compiledConfigWithMethod.path}`));
|
|
444
|
-
console.log(chalk.dim(` Method: ${methodId} · interf/methods/${methodId}/`));
|
|
445
|
-
console.log(chalk.dim(` Prepare mode: ${describeCompileLoopSelection({
|
|
446
|
-
maxAttempts: compiledConfigWithMethod.max_attempts,
|
|
447
|
-
maxLoops: compiledConfigWithMethod.max_loops,
|
|
448
|
-
})}`));
|
|
449
|
-
return compiledConfigWithMethod;
|
|
450
|
-
}
|
|
451
|
-
export async function compileSelectedCompiled(sourcePath, compiledConfig, deps = {}) {
|
|
452
|
-
return (deps.runCompileCommand ?? runCompileCommand)({
|
|
453
|
-
sourcePath,
|
|
454
|
-
preparation: compiledConfig.name,
|
|
455
|
-
preparationConfig: compiledConfig,
|
|
456
|
-
skipConfirm: true,
|
|
457
|
-
skipPreparationBanner: true,
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
async function runCompiledActionMenu(sourcePath, compiledConfig, options = {}) {
|
|
461
|
-
const builtCompiledPath = findBuiltCompiledPath(sourcePath, compiledConfig.name);
|
|
462
|
-
const { comparison: latestComparison, stale: latestComparisonStale, } = readCurrentSavedTestComparison({
|
|
463
|
-
projectPath: sourcePath,
|
|
464
|
-
preparationName: compiledConfig.name,
|
|
465
|
-
checks: compiledConfig.checks,
|
|
466
|
-
});
|
|
467
|
-
printPreparationSummary({
|
|
468
|
-
sourcePath,
|
|
469
|
-
preparation: compiledConfig,
|
|
470
|
-
built: Boolean(builtCompiledPath),
|
|
471
|
-
builtCompiledPath,
|
|
472
|
-
latestComparison,
|
|
473
|
-
latestComparisonStale,
|
|
474
|
-
});
|
|
475
|
-
printPreparationRecommendation(compiledConfig, Boolean(builtCompiledPath), latestComparison);
|
|
476
|
-
const action = await promptPreparationAction(compiledConfig, Boolean(builtCompiledPath), latestComparison);
|
|
477
|
-
if (!action)
|
|
478
|
-
return;
|
|
479
|
-
if (action === "done") {
|
|
480
|
-
p.outro(options.justConfigured ? "Saved Preparation." : "Nothing changed.");
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
if (action === "method") {
|
|
484
|
-
const methodId = await createMethodWizard({
|
|
485
|
-
sourcePath,
|
|
486
|
-
preparationContext: {
|
|
487
|
-
config: compiledConfig,
|
|
488
|
-
sourceFolderPath: resolve(sourcePath, compiledConfig.path),
|
|
489
|
-
},
|
|
490
|
-
});
|
|
491
|
-
if (typeof methodId === "string") {
|
|
492
|
-
const nextConfig = {
|
|
493
|
-
...compiledConfig,
|
|
494
|
-
method: methodId,
|
|
495
|
-
};
|
|
496
|
-
upsertSourcePreparationConfig(sourcePath, nextConfig, {
|
|
497
|
-
matchName: compiledConfig.name,
|
|
498
|
-
});
|
|
499
|
-
const builtCompiledPath = findBuiltCompiledPath(sourcePath, compiledConfig.name);
|
|
500
|
-
if (builtCompiledPath) {
|
|
501
|
-
syncCompiledInterfConfigFromSourcePreparationConfig(builtCompiledPath, nextConfig);
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
504
|
-
ensurePortableContextScaffold(sourcePath, nextConfig.name, nextConfig.method ?? "interf-default");
|
|
505
|
-
}
|
|
506
|
-
p.log.info(`Assigned Method "${methodId}" to Preparation "${compiledConfig.name}".`);
|
|
507
|
-
p.log.info("Next: run `interf compile`, then `interf test`.");
|
|
508
|
-
}
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
if (action === "web") {
|
|
512
|
-
await runWebCommand({ "control-path": sourcePath });
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
if (action === "preparation") {
|
|
516
|
-
const nextCompiled = await promptCompiledSetup({
|
|
517
|
-
sourcePath,
|
|
518
|
-
initial: { name: DEFAULT_PREPARATION_NAME },
|
|
519
|
-
introStyle: "additional",
|
|
520
|
-
});
|
|
521
|
-
if (!nextCompiled)
|
|
522
|
-
return;
|
|
523
|
-
await runCompiledActionMenu(sourcePath, nextCompiled, { justConfigured: true });
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
if (action === "edit") {
|
|
527
|
-
const nextCompiled = await promptCompiledSetup({
|
|
528
|
-
sourcePath,
|
|
529
|
-
initial: compiledConfig,
|
|
530
|
-
fixedName: compiledConfig.name,
|
|
531
|
-
introStyle: "edit",
|
|
532
|
-
});
|
|
533
|
-
if (!nextCompiled)
|
|
534
|
-
return;
|
|
535
|
-
await runCompiledActionMenu(sourcePath, nextCompiled, { justConfigured: true });
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
if (action === "test") {
|
|
539
|
-
if (compiledConfig.checks.length === 0) {
|
|
540
|
-
process.exitCode = 1;
|
|
541
|
-
console.log(chalk.red(` Preparation "${compiledConfig.name}" does not have any readiness checks yet.`));
|
|
542
|
-
console.log(chalk.dim(" Run `interf`, edit this Preparation, and add a few readiness checks first."));
|
|
543
|
-
console.log(chalk.dim(" Then rerun `interf test`."));
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
if (builtCompiledPath) {
|
|
547
|
-
const baselineRan = await runTestCommand({
|
|
548
|
-
sourcePath,
|
|
549
|
-
preparation: compiledConfig.name,
|
|
550
|
-
preparationConfig: compiledConfig,
|
|
551
|
-
target: "both",
|
|
552
|
-
});
|
|
553
|
-
if (!baselineRan) {
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
while (true) {
|
|
559
|
-
const baselineCapture = { result: null };
|
|
560
|
-
const baselineRan = await runTestCommand({
|
|
561
|
-
sourcePath,
|
|
562
|
-
preparation: compiledConfig.name,
|
|
563
|
-
preparationConfig: compiledConfig,
|
|
564
|
-
target: "source-files",
|
|
565
|
-
onComplete(result) {
|
|
566
|
-
baselineCapture.result = result;
|
|
567
|
-
},
|
|
568
|
-
});
|
|
569
|
-
const baselineResult = baselineCapture.result;
|
|
570
|
-
if (!baselineRan || !baselineResult) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
const nextAction = await promptPostBaselineAction(baselineResult.rows);
|
|
574
|
-
if (!nextAction || nextAction === "done") {
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
if (nextAction === "rerun") {
|
|
578
|
-
continue;
|
|
579
|
-
}
|
|
580
|
-
if (nextAction === "edit") {
|
|
581
|
-
const nextCompiled = await promptCompiledSetup({
|
|
582
|
-
sourcePath,
|
|
583
|
-
initial: compiledConfig,
|
|
584
|
-
fixedName: compiledConfig.name,
|
|
585
|
-
introStyle: "edit",
|
|
586
|
-
});
|
|
587
|
-
if (!nextCompiled) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
await runCompiledActionMenu(sourcePath, nextCompiled, { justConfigured: true });
|
|
591
|
-
return;
|
|
592
|
-
}
|
|
593
|
-
break;
|
|
594
|
-
}
|
|
595
|
-
const compileResult = await compileSelectedCompiled(sourcePath, compiledConfig);
|
|
596
|
-
if (!compileResult) {
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
if (compileResult.testedDuringCompile) {
|
|
600
|
-
p.log.info("This prepare run already checked the Portable Context on the saved readiness checks.");
|
|
601
|
-
p.log.info("Run `interf test` later if you want a fresh side-by-side comparison summary.");
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
await runTestCommand({
|
|
605
|
-
sourcePath,
|
|
606
|
-
preparation: compiledConfig.name,
|
|
607
|
-
preparationConfig: compiledConfig,
|
|
608
|
-
target: "both",
|
|
609
|
-
});
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
if (action === "compile") {
|
|
613
|
-
const compileResult = await compileSelectedCompiled(sourcePath, compiledConfig);
|
|
614
|
-
if (!compileResult)
|
|
615
|
-
return;
|
|
616
|
-
if (compiledConfig.checks.length === 0)
|
|
617
|
-
return;
|
|
618
|
-
if (compileResult.testedDuringCompile) {
|
|
619
|
-
p.log.info("This prepare run already checked the Portable Context on the compile agent.");
|
|
620
|
-
}
|
|
621
|
-
const runCompiledTest = await p.confirm({
|
|
622
|
-
message: compileResult.testedDuringCompile
|
|
623
|
-
? "Run a fresh source-files versus Portable Context comparison now?"
|
|
624
|
-
: builtCompiledPath
|
|
625
|
-
? "Run readiness checks on source files and Portable Context now?"
|
|
626
|
-
: "Run readiness checks on source files and Portable Context now?",
|
|
627
|
-
initialValue: true,
|
|
628
|
-
});
|
|
629
|
-
if (p.isCancel(runCompiledTest) || !runCompiledTest)
|
|
630
|
-
return;
|
|
631
|
-
await runTestCommand({
|
|
632
|
-
sourcePath,
|
|
633
|
-
preparation: compiledConfig.name,
|
|
634
|
-
preparationConfig: compiledConfig,
|
|
635
|
-
target: "both",
|
|
636
|
-
});
|
|
637
|
-
return;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
export const initCommand = {
|
|
641
|
-
command: "init",
|
|
642
|
-
describe: "Set up Interf or open the Preparation wizard",
|
|
643
|
-
handler: async () => {
|
|
644
|
-
await runInitCommand();
|
|
645
|
-
},
|
|
646
|
-
};
|
|
647
|
-
export async function runInitCommand() {
|
|
648
|
-
p.intro(chalk.bold("Interf"));
|
|
649
|
-
const cwd = process.cwd();
|
|
650
|
-
const detected = detectInterf(cwd);
|
|
651
|
-
let initContext = detected
|
|
652
|
-
? {
|
|
653
|
-
controlPath: resolveSourceControlPath(detected.path),
|
|
654
|
-
defaultSourceFolderPath: null,
|
|
655
|
-
defaultPreparationPath: null,
|
|
656
|
-
}
|
|
657
|
-
: resolveInterfInstanceContext(cwd);
|
|
658
|
-
let sourcePath = initContext.controlPath;
|
|
659
|
-
if (detected) {
|
|
660
|
-
p.log.info(`Interf Workspace: ${displayPath(sourcePath)}`);
|
|
661
|
-
}
|
|
662
|
-
const hasConfig = Boolean(loadSourceFolderConfig(sourcePath));
|
|
663
|
-
let initialSourceFolderPath = initContext.defaultSourceFolderPath;
|
|
664
|
-
let initialSourceFolderConfigPath = initContext.defaultPreparationPath;
|
|
665
|
-
if (!detected && !hasConfig) {
|
|
666
|
-
const setup = await setupInterfInstance(cwd);
|
|
667
|
-
if (!setup)
|
|
668
|
-
return;
|
|
669
|
-
sourcePath = setup.controlPath;
|
|
670
|
-
initialSourceFolderPath = setup.sourceFolderPath;
|
|
671
|
-
initialSourceFolderConfigPath = setup.sourceFolderConfigPath;
|
|
672
|
-
initContext = {
|
|
673
|
-
controlPath: sourcePath,
|
|
674
|
-
defaultSourceFolderPath: initialSourceFolderPath,
|
|
675
|
-
defaultPreparationPath: initialSourceFolderConfigPath,
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
else {
|
|
679
|
-
const seeded = seedLocalDefaultMethod({ sourcePath });
|
|
680
|
-
if (!seeded.alreadyExisted) {
|
|
681
|
-
p.log.info(`Method: ${seeded.methodId}`);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
let currentConfig = loadSourceFolderConfig(sourcePath);
|
|
685
|
-
if (!currentConfig?.source_folder && !detected) {
|
|
686
|
-
const currentEntries = currentConfig?.preparations ?? [];
|
|
687
|
-
if (initialSourceFolderPath && initialSourceFolderConfigPath) {
|
|
688
|
-
saveSourceFolderConfig(sourcePath, {
|
|
689
|
-
source_folder: { path: initialSourceFolderConfigPath },
|
|
690
|
-
preparations: currentEntries,
|
|
691
|
-
});
|
|
692
|
-
currentConfig = loadSourceFolderConfig(sourcePath);
|
|
693
|
-
}
|
|
694
|
-
else if (currentConfig && currentEntries.length === 0) {
|
|
695
|
-
const sourceFolderPath = await promptSourceFolderForInstance(cwd);
|
|
696
|
-
if (!sourceFolderPath)
|
|
697
|
-
return;
|
|
698
|
-
const sourceFolderConfigPath = relativeSourceFolderPath(sourcePath, sourceFolderPath);
|
|
699
|
-
saveSourceFolderConfig(sourcePath, {
|
|
700
|
-
source_folder: { path: sourceFolderConfigPath },
|
|
701
|
-
preparations: [],
|
|
702
|
-
});
|
|
703
|
-
initialSourceFolderPath = sourceFolderPath;
|
|
704
|
-
initialSourceFolderConfigPath = sourceFolderConfigPath;
|
|
705
|
-
currentConfig = loadSourceFolderConfig(sourcePath);
|
|
706
|
-
p.log.info(`Source Folder: ${sourceFolderPath}`);
|
|
707
|
-
p.log.info(`Source Folder path in Interf config: ${sourceFolderConfigPath}`);
|
|
708
|
-
}
|
|
709
|
-
else if (!currentConfig) {
|
|
710
|
-
const setup = await setupInterfInstance(cwd);
|
|
711
|
-
if (!setup)
|
|
712
|
-
return;
|
|
713
|
-
sourcePath = setup.controlPath;
|
|
714
|
-
initialSourceFolderPath = setup.sourceFolderPath;
|
|
715
|
-
initialSourceFolderConfigPath = setup.sourceFolderConfigPath;
|
|
716
|
-
currentConfig = loadSourceFolderConfig(sourcePath);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
const configuredSourcePath = resolveConfiguredSourceFolderPath(sourcePath, currentConfig);
|
|
720
|
-
const configuredSourceConfigPath = configuredSourceFolderPath(currentConfig);
|
|
721
|
-
if (configuredSourcePath && configuredSourceConfigPath) {
|
|
722
|
-
initialSourceFolderPath = configuredSourcePath;
|
|
723
|
-
initialSourceFolderConfigPath = configuredSourceConfigPath;
|
|
724
|
-
}
|
|
725
|
-
const savedEntries = listSavedPreparationEntries(sourcePath);
|
|
726
|
-
if (savedEntries.length === 0) {
|
|
727
|
-
p.log.info("No Preparations yet. Create one when you are ready to describe the agent work.");
|
|
728
|
-
const action = await promptEmptyInstanceAction();
|
|
729
|
-
if (!action || action === "done") {
|
|
730
|
-
p.outro("Interf Workspace is ready. Next: run `interf web` or `interf create preparation`.");
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
if (action === "web") {
|
|
734
|
-
await runWebCommand({ "control-path": sourcePath });
|
|
735
|
-
return;
|
|
736
|
-
}
|
|
737
|
-
if (action === "method") {
|
|
738
|
-
const methodId = await createMethodWizard({ sourcePath });
|
|
739
|
-
if (typeof methodId === "string") {
|
|
740
|
-
p.outro(`Saved Method "${methodId}". Next: create a Preparation and assign this Method.`);
|
|
741
|
-
}
|
|
742
|
-
return;
|
|
743
|
-
}
|
|
744
|
-
const compiledConfig = await promptCompiledSetup({
|
|
745
|
-
sourcePath,
|
|
746
|
-
initial: initialSourceFolderPath && initialSourceFolderConfigPath
|
|
747
|
-
? {
|
|
748
|
-
name: defaultPreparationNameForPath(initialSourceFolderPath),
|
|
749
|
-
path: initialSourceFolderConfigPath,
|
|
750
|
-
}
|
|
751
|
-
: { name: DEFAULT_PREPARATION_NAME },
|
|
752
|
-
...(initialSourceFolderConfigPath ? { fixedPath: initialSourceFolderConfigPath } : {}),
|
|
753
|
-
introStyle: "first",
|
|
754
|
-
});
|
|
755
|
-
if (!compiledConfig)
|
|
756
|
-
return;
|
|
757
|
-
await runCompiledActionMenu(sourcePath, compiledConfig, { justConfigured: true });
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
const selectedCompiled = await chooseCompiledForWizard({
|
|
761
|
-
sourcePath,
|
|
762
|
-
fixedCompiledName: detected?.config.name ?? null,
|
|
763
|
-
});
|
|
764
|
-
if (!selectedCompiled)
|
|
765
|
-
return;
|
|
766
|
-
if (selectedCompiled === "__new__") {
|
|
767
|
-
const compiledConfig = await promptCompiledSetup({
|
|
768
|
-
sourcePath,
|
|
769
|
-
initial: initialSourceFolderPath && initialSourceFolderConfigPath
|
|
770
|
-
? {
|
|
771
|
-
name: defaultPreparationNameForPath(initialSourceFolderPath),
|
|
772
|
-
path: initialSourceFolderConfigPath,
|
|
773
|
-
}
|
|
774
|
-
: { name: DEFAULT_PREPARATION_NAME },
|
|
775
|
-
...(initialSourceFolderConfigPath ? { fixedPath: initialSourceFolderConfigPath } : {}),
|
|
776
|
-
introStyle: "additional",
|
|
777
|
-
});
|
|
778
|
-
if (!compiledConfig)
|
|
779
|
-
return;
|
|
780
|
-
await runCompiledActionMenu(sourcePath, compiledConfig, { justConfigured: true });
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
await runCompiledActionMenu(sourcePath, selectedCompiled);
|
|
784
|
-
}
|