@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.
Files changed (222) hide show
  1. package/README.md +96 -91
  2. package/TRADEMARKS.md +2 -13
  3. package/agent-skills/interf-actions/SKILL.md +97 -32
  4. package/agent-skills/interf-actions/references/cli.md +124 -71
  5. package/builtin-methods/interf-default/README.md +3 -4
  6. package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
  7. package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
  8. package/builtin-methods/interf-default/improve/SKILL.md +1 -1
  9. package/builtin-methods/interf-default/method.json +10 -4
  10. package/builtin-methods/interf-default/method.schema.json +0 -9
  11. package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
  12. package/dist/cli/commands/compile.d.ts +9 -31
  13. package/dist/cli/commands/compile.js +75 -388
  14. package/dist/cli/commands/doctor.js +1 -1
  15. package/dist/cli/commands/login.d.ts +7 -0
  16. package/dist/cli/commands/login.js +39 -0
  17. package/dist/cli/commands/logout.d.ts +2 -0
  18. package/dist/cli/commands/logout.js +16 -0
  19. package/dist/cli/commands/method.d.ts +2 -0
  20. package/dist/cli/commands/method.js +113 -0
  21. package/dist/cli/commands/prep.d.ts +2 -0
  22. package/dist/cli/commands/prep.js +134 -0
  23. package/dist/cli/commands/reset.d.ts +8 -1
  24. package/dist/cli/commands/reset.js +47 -15
  25. package/dist/cli/commands/runs.d.ts +2 -0
  26. package/dist/cli/commands/runs.js +120 -0
  27. package/dist/cli/commands/status.d.ts +6 -1
  28. package/dist/cli/commands/status.js +61 -220
  29. package/dist/cli/commands/test.d.ts +6 -15
  30. package/dist/cli/commands/test.js +63 -342
  31. package/dist/cli/commands/web.d.ts +0 -9
  32. package/dist/cli/commands/web.js +140 -367
  33. package/dist/cli/commands/wizard.d.ts +9 -0
  34. package/dist/cli/commands/wizard.js +442 -0
  35. package/dist/cli/index.d.ts +7 -6
  36. package/dist/cli/index.js +13 -10
  37. package/dist/compiler-ui/404.html +1 -1
  38. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  39. package/dist/compiler-ui/__next._full.txt +3 -3
  40. package/dist/compiler-ui/__next._head.txt +1 -1
  41. package/dist/compiler-ui/__next._index.txt +2 -2
  42. package/dist/compiler-ui/__next._tree.txt +2 -2
  43. package/dist/compiler-ui/_next/static/chunks/045gole2ojo3g.css +3 -0
  44. package/dist/compiler-ui/_next/static/chunks/17t-lulmyawg5.js +89 -0
  45. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  46. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  47. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  48. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  49. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  50. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  51. package/dist/compiler-ui/_not-found.html +1 -1
  52. package/dist/compiler-ui/_not-found.txt +2 -2
  53. package/dist/compiler-ui/index.html +1 -1
  54. package/dist/compiler-ui/index.txt +3 -3
  55. package/dist/index.d.ts +0 -23
  56. package/dist/index.js +0 -16
  57. package/dist/packages/agents/lib/shells.d.ts +1 -1
  58. package/dist/packages/agents/lib/shells.js +113 -54
  59. package/dist/packages/agents/lib/user-config.d.ts +4 -2
  60. package/dist/packages/agents/lib/user-config.js +15 -7
  61. package/dist/packages/compiler/compiled-paths.d.ts +9 -2
  62. package/dist/packages/compiler/compiled-paths.js +30 -15
  63. package/dist/packages/compiler/compiled-pipeline.js +23 -3
  64. package/dist/packages/compiler/compiled-stage-plan.js +4 -0
  65. package/dist/packages/compiler/compiled-target.d.ts +1 -1
  66. package/dist/packages/compiler/compiled-target.js +1 -1
  67. package/dist/packages/compiler/index.d.ts +1 -0
  68. package/dist/packages/compiler/index.js +1 -0
  69. package/dist/packages/compiler/lib/schema.d.ts +27 -32
  70. package/dist/packages/compiler/lib/schema.js +2 -13
  71. package/dist/packages/compiler/method-runs.d.ts +2 -3
  72. package/dist/packages/compiler/method-runs.js +2 -3
  73. package/dist/packages/compiler/reset.js +3 -1
  74. package/dist/packages/compiler/runtime-contracts.js +0 -3
  75. package/dist/packages/compiler/runtime-prompt.js +1 -1
  76. package/dist/packages/compiler/source-files.d.ts +46 -0
  77. package/dist/packages/compiler/source-files.js +149 -0
  78. package/dist/packages/compiler/state-artifacts.d.ts +3 -2
  79. package/dist/packages/compiler/state-artifacts.js +4 -3
  80. package/dist/packages/compiler/state-io.d.ts +3 -2
  81. package/dist/packages/compiler/state-io.js +11 -5
  82. package/dist/packages/compiler/state-paths.d.ts +2 -1
  83. package/dist/packages/compiler/state-paths.js +6 -3
  84. package/dist/packages/compiler/state-view.d.ts +3 -2
  85. package/dist/packages/compiler/state-view.js +18 -28
  86. package/dist/packages/compiler/state.d.ts +4 -4
  87. package/dist/packages/compiler/state.js +3 -3
  88. package/dist/packages/contracts/index.d.ts +1 -1
  89. package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
  90. package/dist/packages/contracts/lib/preparation-paths.js +177 -0
  91. package/dist/packages/contracts/lib/schema.d.ts +85 -6
  92. package/dist/packages/contracts/lib/schema.js +46 -2
  93. package/dist/packages/execution/lib/schema.d.ts +50 -57
  94. package/dist/packages/execution/lib/schema.js +1 -2
  95. package/dist/packages/local-service/action-definitions.d.ts +246 -0
  96. package/dist/packages/local-service/action-definitions.js +1147 -0
  97. package/dist/packages/local-service/action-planner.d.ts +9 -0
  98. package/dist/packages/local-service/action-planner.js +135 -0
  99. package/dist/packages/local-service/action-values.d.ts +1 -23
  100. package/dist/packages/local-service/action-values.js +1 -31
  101. package/dist/packages/local-service/client.d.ts +76 -46
  102. package/dist/packages/local-service/client.js +184 -149
  103. package/dist/packages/local-service/connection-config.d.ts +38 -0
  104. package/dist/packages/local-service/connection-config.js +75 -0
  105. package/dist/packages/local-service/index.d.ts +14 -7
  106. package/dist/packages/local-service/index.js +8 -4
  107. package/dist/packages/local-service/instance-paths.d.ts +100 -0
  108. package/dist/packages/local-service/instance-paths.js +165 -0
  109. package/dist/packages/local-service/lib/schema.d.ts +689 -2575
  110. package/dist/packages/local-service/lib/schema.js +260 -101
  111. package/dist/packages/local-service/native-run-handlers.d.ts +23 -0
  112. package/dist/{cli/commands/compile-controller.js → packages/local-service/native-run-handlers.js} +204 -20
  113. package/dist/packages/local-service/preparation-store.d.ts +92 -0
  114. package/dist/packages/local-service/preparation-store.js +171 -0
  115. package/dist/{cli/commands/check-draft.d.ts → packages/local-service/readiness-check-draft.d.ts} +2 -2
  116. package/dist/packages/local-service/routes.d.ts +33 -11
  117. package/dist/packages/local-service/routes.js +44 -15
  118. package/dist/packages/local-service/run-observability.js +25 -27
  119. package/dist/packages/local-service/runtime-caches.d.ts +76 -0
  120. package/dist/packages/local-service/runtime-caches.js +191 -0
  121. package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
  122. package/dist/packages/local-service/runtime-event-applier.js +177 -0
  123. package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
  124. package/dist/packages/local-service/runtime-persistence.js +137 -0
  125. package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
  126. package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
  127. package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
  128. package/dist/packages/local-service/runtime-resource-builders.js +149 -0
  129. package/dist/packages/local-service/runtime.d.ts +201 -44
  130. package/dist/packages/local-service/runtime.js +1062 -1106
  131. package/dist/packages/local-service/server.d.ts +15 -0
  132. package/dist/packages/local-service/server.js +651 -233
  133. package/dist/packages/local-service/service-registry.d.ts +47 -0
  134. package/dist/packages/local-service/service-registry.js +137 -0
  135. package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
  136. package/dist/packages/method-authoring/method-authoring.js +2 -2
  137. package/dist/packages/method-authoring/method-improvement.js +1 -1
  138. package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
  139. package/dist/packages/method-package/builtin-compiled-method.js +8 -14
  140. package/dist/packages/method-package/context-interface.d.ts +4 -40
  141. package/dist/packages/method-package/context-interface.js +1 -23
  142. package/dist/packages/method-package/interf-method-package.d.ts +4 -4
  143. package/dist/packages/method-package/interf-method-package.js +21 -33
  144. package/dist/packages/method-package/local-methods.d.ts +10 -6
  145. package/dist/packages/method-package/local-methods.js +57 -39
  146. package/dist/packages/method-package/method-definitions.d.ts +8 -34
  147. package/dist/packages/method-package/method-definitions.js +49 -37
  148. package/dist/packages/method-package/method-helpers.d.ts +1 -13
  149. package/dist/packages/method-package/method-helpers.js +8 -42
  150. package/dist/packages/method-package/method-review-paths.d.ts +1 -1
  151. package/dist/packages/method-package/method-review-paths.js +5 -5
  152. package/dist/packages/method-package/method-stage-runner.js +2 -2
  153. package/dist/packages/method-package/user-methods.d.ts +17 -0
  154. package/dist/packages/method-package/user-methods.js +77 -0
  155. package/dist/packages/project-model/index.d.ts +1 -1
  156. package/dist/packages/project-model/index.js +1 -1
  157. package/dist/packages/project-model/interf-detect.d.ts +8 -3
  158. package/dist/packages/project-model/interf-detect.js +34 -34
  159. package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
  160. package/dist/packages/project-model/interf-scaffold.js +23 -32
  161. package/dist/packages/project-model/lib/schema.js +38 -1
  162. package/dist/packages/project-model/preparation-entries.d.ts +11 -0
  163. package/dist/packages/project-model/preparation-entries.js +49 -0
  164. package/dist/packages/project-model/source-config.d.ts +11 -10
  165. package/dist/packages/project-model/source-config.js +83 -44
  166. package/dist/packages/project-model/source-folders.d.ts +5 -5
  167. package/dist/packages/project-model/source-folders.js +14 -14
  168. package/dist/packages/shared/filesystem.d.ts +7 -0
  169. package/dist/packages/shared/filesystem.js +97 -10
  170. package/dist/packages/testing/lib/schema.d.ts +12 -13
  171. package/dist/packages/testing/lib/schema.js +4 -5
  172. package/dist/packages/testing/readiness-check-run.d.ts +7 -7
  173. package/dist/packages/testing/readiness-check-run.js +46 -51
  174. package/dist/packages/testing/test-execution.js +6 -6
  175. package/dist/packages/testing/test-paths.js +4 -3
  176. package/dist/packages/testing/test-sandbox.d.ts +0 -1
  177. package/dist/packages/testing/test-sandbox.js +14 -30
  178. package/dist/packages/testing/test-targets.d.ts +1 -1
  179. package/dist/packages/testing/test-targets.js +6 -6
  180. package/dist/packages/testing/test.d.ts +1 -1
  181. package/dist/packages/testing/test.js +1 -1
  182. package/package.json +6 -26
  183. package/LICENSE +0 -183
  184. package/dist/cli/commands/compile-controller.d.ts +0 -17
  185. package/dist/cli/commands/compiled-flow.d.ts +0 -25
  186. package/dist/cli/commands/compiled-flow.js +0 -112
  187. package/dist/cli/commands/control-path.d.ts +0 -11
  188. package/dist/cli/commands/control-path.js +0 -72
  189. package/dist/cli/commands/create-method-wizard.d.ts +0 -76
  190. package/dist/cli/commands/create-method-wizard.js +0 -465
  191. package/dist/cli/commands/create.d.ts +0 -8
  192. package/dist/cli/commands/create.js +0 -189
  193. package/dist/cli/commands/default.d.ts +0 -2
  194. package/dist/cli/commands/default.js +0 -39
  195. package/dist/cli/commands/executor-flow.d.ts +0 -29
  196. package/dist/cli/commands/executor-flow.js +0 -163
  197. package/dist/cli/commands/init.d.ts +0 -11
  198. package/dist/cli/commands/init.js +0 -784
  199. package/dist/cli/commands/list.d.ts +0 -2
  200. package/dist/cli/commands/list.js +0 -30
  201. package/dist/cli/commands/preparation-selection.d.ts +0 -6
  202. package/dist/cli/commands/preparation-selection.js +0 -11
  203. package/dist/cli/commands/source-config-wizard.d.ts +0 -52
  204. package/dist/cli/commands/source-config-wizard.js +0 -680
  205. package/dist/cli/commands/test-flow.d.ts +0 -58
  206. package/dist/cli/commands/test-flow.js +0 -231
  207. package/dist/cli/commands/verify.d.ts +0 -2
  208. package/dist/cli/commands/verify.js +0 -94
  209. package/dist/compiler-ui/_next/static/chunks/0d~8t0zm6545p.js +0 -118
  210. package/dist/compiler-ui/_next/static/chunks/0xnel.ax9a.2c.css +0 -3
  211. package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
  212. package/dist/packages/compiler/raw-snapshot.js +0 -101
  213. package/dist/packages/method-package/index.d.ts +0 -11
  214. package/dist/packages/method-package/index.js +0 -11
  215. package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
  216. package/dist/packages/method-package/method-stage-policy.js +0 -31
  217. package/dist/packages/project-model/project-paths.d.ts +0 -12
  218. package/dist/packages/project-model/project-paths.js +0 -33
  219. /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
  220. /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
  221. /package/dist/compiler-ui/_next/static/{j7pdoqWrl4YJrJUVnksbl → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
  222. /package/dist/{cli/commands/check-draft.js → packages/local-service/readiness-check-draft.js} +0 -0
@@ -1,395 +1,82 @@
1
+ /**
2
+ * `interf compile <prep-id>` — start a compile run for a preparation.
3
+ *
4
+ * interf compile bristol
5
+ * interf compile bristol --quiet # only the locator on stdout (scripting)
6
+ * interf compile bristol --watch # stream events
7
+ *
8
+ * Requires an active connection. Hits POST /v1/preparations/<id>/compile-runs.
9
+ */
1
10
  import chalk from "chalk";
2
- import * as p from "@clack/prompts";
3
- import { detectInterf, readInterfConfig, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
4
- import { loadCompiledPreparationConfig, sourcePreparationConfigFromInterfConfig, resolvePreparationCompileMaxAttempts, resolvePreparationCompileMaxLoops, } from "../../packages/project-model/source-config.js";
5
- import { addExecutionProfileOptions, executionProfileFromArgv, } from "../../packages/agents/lib/execution-profile.js";
6
- import { chooseCompiledConfigToBuild, ensureCompiledFromConfig, } from "./compiled-flow.js";
7
- import { resolveConfiguredPreparationSelection } from "./preparation-selection.js";
8
- import { promptCompileLoopSelection, } from "./source-config-wizard.js";
9
- import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
10
- import { runConfiguredCompiledCompile } from "./compile-controller.js";
11
- import { submitCompileRunToLocalService, waitForLocalCompileRun, } from "../../packages/local-service/index.js";
12
- import { resolveCommandControlPath } from "./control-path.js";
13
- import { resolveMethodId } from "../../packages/methods/method-resolution.js";
14
- export { runConfiguredCompiledCompile } from "./compile-controller.js";
15
- export const compileCommand = {
16
- command: "compile",
17
- describe: "Prepare files and write Portable Context agents can use",
18
- builder: (yargs) => addExecutionProfileOptions(yargs).option("preparation", {
19
- type: "string",
20
- describe: "Preparation id to compile when this Source Folder has more than one Preparation",
21
- }).option("max-attempts", {
22
- type: "number",
23
- describe: "Retry the prepare run and run saved readiness checks with the same Method until the Preparation is ready or reaches this total attempt limit",
24
- }).option("max-loops", {
25
- type: "number",
26
- describe: "After retries fail, let Interf edit the Method and run saved readiness checks on new Method variations for this Preparation up to this loop limit",
27
- }).option("keep-stage-shells", {
28
- type: "boolean",
29
- default: false,
30
- describe: "Keep every executed stage shell under .interf/runtime/execution-shells for review instead of pruning successful shells",
31
- }),
32
- handler: async (argv) => {
33
- await runCompileCommand(argv);
34
- },
35
- };
36
- const defaultCompileCommandDeps = {
37
- chooseCompiledConfigToBuild,
38
- confirm: p.confirm,
39
- detectInterf,
40
- ensureCompiledFromConfig,
41
- resolveInteractiveCompileLoopOverrides,
42
- resolveOrConfigureLocalExecutor,
43
- runConfiguredCompiledCompile,
44
- };
45
- function readHintedSourcePath(argv) {
46
- return typeof argv.sourcePath === "string" && argv.sourcePath.trim().length > 0
47
- ? argv.sourcePath.trim()
48
- : null;
49
- }
50
- function readRequestedPreparationName(argv) {
51
- const raw = argv.preparation;
52
- return typeof raw === "string" && raw.trim().length > 0
53
- ? raw.trim()
54
- : null;
55
- }
56
- function shouldSkipCompileConfirm(argv) {
57
- return argv.skipConfirm === true;
58
- }
59
- function shouldSkipPreparationBanner(argv) {
60
- return argv.skipPreparationBanner === true;
61
- }
62
- function compileRunTests(options) {
63
- const checks = options.compiledConfig?.checks ?? [];
64
- if (checks.length === 0)
65
- return false;
66
- const configuredMaxAttempts = resolvePreparationCompileMaxAttempts(options.compiledConfig ?? { max_attempts: undefined }, options.maxAttemptsOverride);
67
- const maxLoops = resolvePreparationCompileMaxLoops(options.compiledConfig ?? { max_loops: undefined }, options.maxLoopsOverride);
68
- const maxAttempts = configuredMaxAttempts ?? (maxLoops != null ? 1 : null);
69
- return maxAttempts != null;
11
+ import { CONNECT_OR_ERROR_HINT, readActiveConnection } from "../../packages/local-service/connection-config.js";
12
+ function resolveConnection(args) {
13
+ const conn = readActiveConnection({
14
+ urlOverride: args.url,
15
+ authTokenOverride: args.token,
16
+ });
17
+ if (!conn) {
18
+ console.error(CONNECT_OR_ERROR_HINT);
19
+ process.exit(1);
20
+ }
21
+ return { url: conn.url.replace(/\/+$/, ""), token: conn.auth_token };
70
22
  }
71
- export async function runCompileCommand(argv = {}, deps = {}) {
72
- const helpers = {
73
- ...defaultCompileCommandDeps,
74
- ...deps,
75
- };
76
- let compiledPath = null;
77
- const hintedSourcePath = readHintedSourcePath(argv);
78
- const detected = hintedSourcePath ? null : helpers.detectInterf(process.cwd());
79
- let sourcePath = hintedSourcePath ?? resolveCommandControlPath();
80
- let compiledConfig = null;
81
- const requestedPreparationName = readRequestedPreparationName(argv);
82
- const hintedPreparationConfig = (argv.preparationConfig ?? null);
83
- const skipConfirm = shouldSkipCompileConfirm(argv);
84
- const skipPreparationBanner = shouldSkipPreparationBanner(argv);
85
- if (detected) {
86
- compiledPath = detected.path;
87
- sourcePath = resolveSourceControlPath(detected.path);
88
- compiledConfig = loadCompiledPreparationConfig(detected.path)
89
- ?? sourcePreparationConfigFromInterfConfig(detected.config);
90
- if (!skipConfirm && process.stdin.isTTY && process.stdout.isTTY) {
91
- const confirmed = await helpers.confirm({
92
- message: `Prepare files for Preparation "${detected.config.name}" now?`,
93
- initialValue: true,
94
- });
95
- if (p.isCancel(confirmed) || !confirmed)
96
- return null;
23
+ async function callJson(url, token, init = {}) {
24
+ const headers = new Headers(init.headers ?? {});
25
+ if (token)
26
+ headers.set("authorization", `Bearer ${token}`);
27
+ if (init.body && !headers.has("content-type"))
28
+ headers.set("content-type", "application/json");
29
+ const response = await fetch(url, { ...init, headers });
30
+ const raw = await response.text();
31
+ let body = null;
32
+ if (raw.length > 0) {
33
+ try {
34
+ body = JSON.parse(raw);
97
35
  }
98
- }
99
- else {
100
- const selectedCompiled = requestedPreparationName || hintedPreparationConfig
101
- ? resolveConfiguredPreparationSelection({
102
- sourcePath,
103
- requestedPreparationName,
104
- hintedPreparationConfig,
105
- })
106
- : await helpers.chooseCompiledConfigToBuild({
107
- sourcePath,
108
- selectMessage: "Which saved Preparation do you want to compile?",
109
- });
110
- if (selectedCompiled === undefined)
111
- return null;
112
- if (!selectedCompiled) {
113
- process.exitCode = 1;
114
- if (requestedPreparationName) {
115
- console.log(chalk.red(` Preparation "${requestedPreparationName}" is not saved in this Source Folder.`));
116
- console.log(chalk.dim(" Run `interf list` to see the saved Preparations."));
117
- }
118
- else {
119
- console.log(chalk.red(" No saved Preparations are configured for this Source Folder yet."));
120
- console.log(chalk.dim(" Start with `interf` or `interf init` to set up this folder."));
121
- }
122
- return null;
36
+ catch {
37
+ body = null;
123
38
  }
124
- if (!skipConfirm && process.stdin.isTTY && process.stdout.isTTY) {
125
- const confirmed = await helpers.confirm({
126
- message: `Prepare files for Preparation "${selectedCompiled.name}" now?`,
127
- initialValue: true,
128
- });
129
- if (p.isCancel(confirmed) || !confirmed)
130
- return null;
39
+ }
40
+ return { status: response.status, body, raw };
41
+ }
42
+ export const compileCommand = {
43
+ command: "compile <prep-id>",
44
+ describe: "Start a compile run for a preparation",
45
+ builder: (yargs) => yargs
46
+ .positional("prep-id", { type: "string", demandOption: true, describe: "Preparation id" })
47
+ .option("watch", { type: "boolean", default: false, describe: "Stream run events" })
48
+ .option("quiet", { type: "boolean", default: false, describe: "Print only the portable-context locator on success" })
49
+ .option("idempotency-key", { type: "string", describe: "Client-supplied dedupe key" })
50
+ .option("url", { type: "string", describe: "Override the active connection URL" })
51
+ .option("token", { type: "string", describe: "Override the active bearer token" }),
52
+ handler: async (args) => {
53
+ const { url, token } = resolveConnection(args);
54
+ const headers = {};
55
+ if (args.idempotencyKey)
56
+ headers["x-interf-idempotency-key"] = args.idempotencyKey;
57
+ const { status, body, raw } = await callJson(`${url}/v1/preparations/${encodeURIComponent(args.prepId)}/compile-runs`, token, { method: "POST", headers, body: JSON.stringify({}) });
58
+ if (status !== 201 && status !== 200 && status !== 202) {
59
+ console.error(chalk.red(`Failed to start compile run for ${args.prepId} (HTTP ${status}).`));
60
+ if (raw)
61
+ console.error(raw);
62
+ process.exit(1);
131
63
  }
132
- compiledConfig = selectedCompiled;
133
- compiledPath = helpers.ensureCompiledFromConfig(sourcePath, selectedCompiled);
134
- if (!skipPreparationBanner) {
135
- console.log(chalk.dim(` Preparation: ${selectedCompiled.name}`));
64
+ const run = body?.run;
65
+ const runId = run?.run_id ?? "(unknown run)";
66
+ const locator = run?.portable_context_path ?? "(no locator)";
67
+ if (args.quiet) {
68
+ console.log(locator);
69
+ return;
136
70
  }
137
- }
138
- let maxAttemptsOverride = null;
139
- let maxLoopsOverride = null;
140
- try {
141
- maxAttemptsOverride = readCompileMaxAttemptsOverride(argv);
142
- maxLoopsOverride = readCompileMaxLoopsOverride(argv);
143
- }
144
- catch (error) {
145
- process.exitCode = 1;
146
- console.log(chalk.red(error instanceof Error ? error.message : String(error)));
147
- return null;
148
- }
149
- const interactiveOverrides = await helpers.resolveInteractiveCompileLoopOverrides({
150
- compiledPath,
151
- compiledConfig,
152
- maxAttemptsOverride,
153
- maxLoopsOverride,
154
- });
155
- if (!interactiveOverrides)
156
- return null;
157
- compiledConfig = interactiveOverrides.compiledConfig;
158
- maxAttemptsOverride = interactiveOverrides.maxAttemptsOverride;
159
- maxLoopsOverride = interactiveOverrides.maxLoopsOverride;
160
- const testedDuringCompile = compileRunTests({
161
- compiledConfig,
162
- maxAttemptsOverride,
163
- maxLoopsOverride,
164
- });
165
- if (argv.skipService !== true && compiledConfig) {
166
- const submitted = await submitCompileRunToLocalService({
167
- projectPath: sourcePath,
168
- request: {
169
- preparation: compiledConfig.name,
170
- ...(compiledConfig.method ? { method: compiledConfig.method } : {}),
171
- ...(maxAttemptsOverride != null ? { max_attempts: maxAttemptsOverride } : {}),
172
- ...(maxLoopsOverride != null ? { max_loops: maxLoopsOverride } : {}),
173
- preserve_stage_shells: readStageShellRetentionMode(argv),
174
- },
175
- });
176
- if (submitted) {
177
- console.log(chalk.dim(` Visible in Interf: ${submitted.serviceUrl}/`));
178
- let lastStatus = "";
179
- let lastStage = "";
180
- const completed = await waitForLocalCompileRun({
181
- serviceUrl: submitted.serviceUrl,
182
- runId: submitted.resource.run.run_id,
183
- onUpdate(resource) {
184
- const activeStage = resource.run.stages.find((stage) => stage.status === "running")
185
- ?? [...resource.run.stages].reverse().find((stage) => stage.status === "succeeded" || stage.status === "failed")
186
- ?? null;
187
- const statusKey = `${resource.run.status}:${activeStage?.stage_id ?? ""}:${activeStage?.status ?? ""}`;
188
- if (statusKey === `${lastStatus}:${lastStage}`)
189
- return;
190
- lastStatus = resource.run.status;
191
- lastStage = `${activeStage?.stage_id ?? ""}:${activeStage?.status ?? ""}`;
192
- if (activeStage) {
193
- console.log(chalk.dim(` ${activeStage.stage_label ?? activeStage.stage_id}: ${activeStage.status}`));
194
- }
195
- else {
196
- console.log(chalk.dim(` Prepare run: ${resource.run.status}`));
197
- }
198
- },
199
- });
200
- if (completed.run.status !== "succeeded") {
201
- process.exitCode = 1;
202
- const failure = completed.run.stages.find((stage) => stage.status === "failed");
203
- console.log(chalk.red(` Prepare run ${completed.run.status}.`));
204
- if (failure?.failure)
205
- console.log(chalk.red(` ${failure.failure}`));
206
- return null;
207
- }
208
- console.log(chalk.green(" Portable Context ready."));
209
- return {
210
- compiledPath: completed.run.portable_context_path,
211
- testedDuringCompile,
212
- };
71
+ console.log();
72
+ console.log(` Run ${chalk.bold(runId)} ${chalk.dim(`(${run?.status ?? "started"})`)}`);
73
+ console.log(` Portable context: ${locator}`);
74
+ if (run?.status === "succeeded" || run?.finished_at) {
75
+ const prepResp = await callJson(`${url}/v1/preparations/${encodeURIComponent(args.prepId)}`, token);
76
+ const readiness = prepResp.body?.readiness?.status;
77
+ if (readiness)
78
+ console.log(` Readiness: ${readiness}`);
213
79
  }
214
- }
215
- const executionProfile = executionProfileFromArgv(argv);
216
- const { executor, error } = await helpers.resolveOrConfigureLocalExecutor({
217
- executionProfile,
218
- purpose: "compile",
219
- });
220
- if (!executor && !error)
221
- return null;
222
- if (!executor) {
223
- process.exitCode = 1;
224
- console.log(chalk.red(error ?? "No coding agent detected."));
225
- return null;
226
- }
227
- const compiled = await helpers.runConfiguredCompiledCompile({
228
- executor,
229
- testExecutor: executor,
230
- compiledPath,
231
- sourcePath,
232
- compiledConfig,
233
- executionProfile,
234
- maxAttemptsOverride,
235
- maxLoopsOverride,
236
- preserveStageShells: readStageShellRetentionMode(argv),
237
- });
238
- if (!compiled) {
239
- return null;
240
- }
241
- return {
242
- compiledPath,
243
- testedDuringCompile,
244
- };
245
- }
246
- export async function resolveInteractiveCompileLoopOverrides(options) {
247
- if (!process.stdin.isTTY || !process.stdout.isTTY) {
248
- return {
249
- compiledConfig: options.compiledConfig,
250
- maxAttemptsOverride: options.maxAttemptsOverride,
251
- maxLoopsOverride: options.maxLoopsOverride,
252
- };
253
- }
254
- if (options.maxAttemptsOverride != null || options.maxLoopsOverride != null) {
255
- return {
256
- compiledConfig: options.compiledConfig,
257
- maxAttemptsOverride: options.maxAttemptsOverride,
258
- maxLoopsOverride: options.maxLoopsOverride,
259
- };
260
- }
261
- const currentConfig = readInterfConfig(options.compiledPath);
262
- const checks = options.compiledConfig?.checks.length
263
- ? options.compiledConfig.checks
264
- : (currentConfig?.checks ?? []);
265
- if (checks.length === 0) {
266
- return {
267
- compiledConfig: options.compiledConfig,
268
- maxAttemptsOverride: options.maxAttemptsOverride,
269
- maxLoopsOverride: options.maxLoopsOverride,
270
- };
271
- }
272
- const savedCompiledConfig = options.compiledConfig
273
- ?? (currentConfig
274
- ? (loadCompiledPreparationConfig(options.compiledPath)
275
- ?? sourcePreparationConfigFromInterfConfig(currentConfig))
276
- : null);
277
- if (!savedCompiledConfig) {
278
- return {
279
- compiledConfig: options.compiledConfig,
280
- maxAttemptsOverride: options.maxAttemptsOverride,
281
- maxLoopsOverride: options.maxLoopsOverride,
282
- };
283
- }
284
- const hasSavedPolicy = typeof savedCompiledConfig.max_attempts === "number" ||
285
- typeof savedCompiledConfig.max_loops === "number";
286
- if (!hasSavedPolicy) {
287
- const overrideSelection = await promptCompileLoopSelection({
288
- hasChecks: true,
289
- initialMaxAttempts: savedCompiledConfig.max_attempts,
290
- initialMaxLoops: savedCompiledConfig.max_loops,
291
- intro: [
292
- `Method: ${resolveMethodId(savedCompiledConfig, resolveMethodId(currentConfig))}`,
293
- "This selection applies to this prepare run only. It does not change the saved Preparation.",
294
- ],
295
- message: "How should this prepare run work?",
296
- });
297
- if (overrideSelection === null)
298
- return null;
299
- return {
300
- compiledConfig: {
301
- ...savedCompiledConfig,
302
- max_attempts: undefined,
303
- max_loops: undefined,
304
- },
305
- maxAttemptsOverride: overrideSelection.max_attempts ?? null,
306
- maxLoopsOverride: overrideSelection.max_loops ?? null,
307
- };
308
- }
309
- const savedMode = await p.select({
310
- message: "Which prepare mode should this run use?",
311
- options: [
312
- {
313
- value: "saved",
314
- label: "Use saved prepare mode (Recommended)",
315
- hint: `${savedCompiledConfig.max_loops ? "Self-improving" : savedCompiledConfig.max_attempts && savedCompiledConfig.max_attempts > 1 ? "Retry" : "Single attempt"} · ${formatCompileModeHint(savedCompiledConfig)}`,
316
- },
317
- {
318
- value: "override",
319
- label: "Change it for this run only",
320
- hint: "Keep the saved Preparation unchanged",
321
- },
322
- ],
323
- });
324
- if (p.isCancel(savedMode))
325
- return null;
326
- if (savedMode === "saved") {
327
- return {
328
- compiledConfig: savedCompiledConfig,
329
- maxAttemptsOverride: null,
330
- maxLoopsOverride: null,
331
- };
332
- }
333
- const selection = await promptCompileLoopSelection({
334
- hasChecks: true,
335
- initialMaxAttempts: savedCompiledConfig.max_attempts,
336
- initialMaxLoops: savedCompiledConfig.max_loops,
337
- intro: [
338
- `Method: ${resolveMethodId(savedCompiledConfig, resolveMethodId(currentConfig))}`,
339
- "This applies to this prepare run only. It does not change the saved Preparation.",
340
- ],
341
- message: "Override the prepare mode for this run",
342
- });
343
- if (selection === null)
344
- return null;
345
- return {
346
- ...savedCompiledConfig,
347
- compiledConfig: {
348
- ...savedCompiledConfig,
349
- max_attempts: undefined,
350
- max_loops: undefined,
351
- },
352
- maxAttemptsOverride: selection.max_attempts ?? null,
353
- maxLoopsOverride: selection.max_loops ?? null,
354
- };
355
- }
356
- function formatCompileModeHint(compiledConfig) {
357
- if (typeof compiledConfig.max_loops === "number" && compiledConfig.max_loops > 0) {
358
- const attempts = compiledConfig.max_attempts ?? 1;
359
- return `${attempts} attempt${attempts === 1 ? "" : "s"} per variation, ${compiledConfig.max_loops} loop${compiledConfig.max_loops === 1 ? "" : "s"}`;
360
- }
361
- if (typeof compiledConfig.max_attempts === "number" && compiledConfig.max_attempts > 1) {
362
- return `${compiledConfig.max_attempts} attempts`;
363
- }
364
- return "1 attempt";
365
- }
366
- function readCompileMaxAttemptsOverride(argv) {
367
- const raw = argv["max-attempts"] ??
368
- argv.maxAttempts ??
369
- argv["max-retries"] ??
370
- argv.maxRetries;
371
- if (raw == null)
372
- return null;
373
- const parsed = Number.parseInt(String(raw), 10);
374
- if (!Number.isInteger(parsed) || parsed < 1 || parsed > 5) {
375
- throw new Error("`--max-attempts` must be a whole number from 1 to 5.");
376
- }
377
- return parsed;
378
- }
379
- function readStageShellRetentionMode(argv) {
380
- const enabled = argv["keep-stage-shells"] ??
381
- argv.keepStageShells ??
382
- false;
383
- return enabled ? "always" : "on-failure";
384
- }
385
- function readCompileMaxLoopsOverride(argv) {
386
- const raw = argv["max-loops"] ??
387
- argv.maxLoops;
388
- if (raw == null)
389
- return null;
390
- const parsed = Number.parseInt(String(raw), 10);
391
- if (!Number.isInteger(parsed) || parsed < 1 || parsed > 3) {
392
- throw new Error("`--max-loops` must be a whole number from 1 to 3.");
393
- }
394
- return parsed;
395
- }
80
+ console.log();
81
+ },
82
+ };
@@ -97,7 +97,7 @@ export const doctorCommand = {
97
97
  id: "live",
98
98
  label: "Live executor preflight",
99
99
  status: "skipped",
100
- message: "Skipped. Run `interf doctor --live` to exercise the real local agent before a check draft, Method authoring run, readiness check, or Compilation.",
100
+ message: "Skipped. Run `interf doctor --live` to exercise the real local agent before drafting readiness checks, Method authoring, a readiness check, or a compile run.",
101
101
  });
102
102
  }
103
103
  const ok = checks.every((check) => check.status !== "fail");
@@ -0,0 +1,7 @@
1
+ import type { CommandModule } from "yargs";
2
+ interface LoginArgs {
3
+ url: string;
4
+ token?: string;
5
+ }
6
+ export declare const loginCommand: CommandModule<unknown, LoginArgs>;
7
+ export {};
@@ -0,0 +1,39 @@
1
+ /**
2
+ * `interf login` — set the active connection record.
3
+ *
4
+ * interf login --url <url> [--token <token>]
5
+ *
6
+ * Writes `~/.interf/connection.json` so subsequent CLI commands target the
7
+ * remote (or alternate local) URL. There is no remote backend in 0.13 — this
8
+ * is the on-disk config layer that the cloud product will consume. Equivalent
9
+ * to running `interf web` (which writes a local connection record on
10
+ * startup).
11
+ */
12
+ import chalk from "chalk";
13
+ import { ConnectionRecordSchema, writeConnection, } from "../../packages/local-service/connection-config.js";
14
+ export const loginCommand = {
15
+ command: "login",
16
+ describe: "Set the active Interf instance connection (URL + optional bearer token)",
17
+ builder: (yargs) => yargs
18
+ .option("url", {
19
+ type: "string",
20
+ demandOption: true,
21
+ describe: "Engine URL, e.g. https://api.interf.cloud or http://127.0.0.1:4873",
22
+ })
23
+ .option("token", {
24
+ type: "string",
25
+ describe: "Bearer token for non-loopback connections",
26
+ }),
27
+ handler: (args) => {
28
+ const url = args.url.trim();
29
+ const token = args.token?.trim();
30
+ const record = ConnectionRecordSchema.parse({
31
+ url,
32
+ auth_token: token && token.length > 0 ? token : null,
33
+ });
34
+ writeConnection(record);
35
+ console.log(chalk.green(`Connection saved.`));
36
+ console.log(chalk.dim(` url: ${record.url}`));
37
+ console.log(chalk.dim(` auth: ${record.auth_token ? "(token set)" : "(loopback / no token)"}`));
38
+ },
39
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandModule } from "yargs";
2
+ export declare const logoutCommand: CommandModule;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `interf logout` — clear the active connection record.
3
+ *
4
+ * Removes `~/.interf/connection.json`. Subsequent CLI commands will exit
5
+ * non-zero with the connect-or-error hint until a new connection is set.
6
+ */
7
+ import chalk from "chalk";
8
+ import { clearConnection } from "../../packages/local-service/connection-config.js";
9
+ export const logoutCommand = {
10
+ command: "logout",
11
+ describe: "Clear the active Interf instance connection",
12
+ handler: () => {
13
+ clearConnection();
14
+ console.log(chalk.green("Connection cleared."));
15
+ },
16
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandModule } from "yargs";
2
+ export declare const methodCommand: CommandModule;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * `interf method` — manage methods on the connected instance.
3
+ *
4
+ * interf method ls # list methods (instance-wide)
5
+ * interf method install <path> # install a method package
6
+ * interf method draft <prep-id> # start a method-authoring run
7
+ * interf method improve <prep-id> # start a method-improvement run
8
+ */
9
+ import chalk from "chalk";
10
+ import { resolve } from "node:path";
11
+ import { CONNECT_OR_ERROR_HINT, readActiveConnection } from "../../packages/local-service/connection-config.js";
12
+ function resolveConnection(args) {
13
+ const conn = readActiveConnection({
14
+ urlOverride: args.url,
15
+ authTokenOverride: args.token,
16
+ });
17
+ if (!conn) {
18
+ console.error(CONNECT_OR_ERROR_HINT);
19
+ process.exit(1);
20
+ }
21
+ return { url: conn.url.replace(/\/+$/, ""), token: conn.auth_token };
22
+ }
23
+ async function callJson(url, token, init = {}) {
24
+ const headers = new Headers(init.headers ?? {});
25
+ if (token)
26
+ headers.set("authorization", `Bearer ${token}`);
27
+ if (init.body && !headers.has("content-type"))
28
+ headers.set("content-type", "application/json");
29
+ const response = await fetch(url, { ...init, headers });
30
+ const raw = await response.text();
31
+ let body = null;
32
+ if (raw) {
33
+ try {
34
+ body = JSON.parse(raw);
35
+ }
36
+ catch {
37
+ body = null;
38
+ }
39
+ }
40
+ return { status: response.status, body, raw };
41
+ }
42
+ export const methodCommand = {
43
+ command: "method <subcommand>",
44
+ describe: "Manage methods on the connected instance",
45
+ builder: (yargs) => yargs
46
+ .option("url", { type: "string", describe: "Override the active connection URL" })
47
+ .option("token", { type: "string", describe: "Override the active bearer token" })
48
+ .command("ls", "List methods on the instance", (y) => y, async (args) => {
49
+ const { url, token } = resolveConnection(args);
50
+ const { status, body, raw } = await callJson(`${url}/v1/methods`, token);
51
+ if (status !== 200) {
52
+ console.error(chalk.red(`Failed to list methods (HTTP ${status}).`));
53
+ if (raw)
54
+ console.error(raw);
55
+ process.exit(1);
56
+ }
57
+ const methods = body?.methods ?? [];
58
+ if (methods.length === 0) {
59
+ console.log(chalk.dim(" No methods on this instance."));
60
+ return;
61
+ }
62
+ console.log();
63
+ for (const m of methods) {
64
+ const id = m.method_id ?? m.id ?? "(?)";
65
+ const label = m.label ? ` ${chalk.dim(m.label)}` : "";
66
+ const kind = m.source_kind ? chalk.dim(`[${m.source_kind}]`) : "";
67
+ console.log(` ${chalk.bold(id)} ${kind}${label}`);
68
+ if (m.active_for_preparations?.length) {
69
+ console.log(chalk.dim(` used by: ${m.active_for_preparations.join(", ")}`));
70
+ }
71
+ }
72
+ console.log();
73
+ })
74
+ .command("install <path>", "Install a method package from a local folder", (y) => y.positional("path", { type: "string", demandOption: true, describe: "Path to the method package" }), async (args) => {
75
+ const { url, token } = resolveConnection(args);
76
+ const absolute = resolve(process.cwd(), args.path);
77
+ const { status, raw } = await callJson(`${url}/v1/methods`, token, { method: "POST", body: JSON.stringify({ source_path: absolute }) });
78
+ if (status !== 201 && status !== 200) {
79
+ console.error(chalk.red(`Failed to install method (HTTP ${status}).`));
80
+ if (raw)
81
+ console.error(raw);
82
+ process.exit(1);
83
+ }
84
+ console.log(chalk.green(`Installed method from ${absolute}.`));
85
+ })
86
+ .command("draft <prep-id>", "Start a method-authoring run for a preparation", (y) => y.positional("prep-id", { type: "string", demandOption: true, describe: "Preparation id" }), async (args) => {
87
+ const { url, token } = resolveConnection(args);
88
+ const { status, body, raw } = await callJson(`${url}/v1/preparations/${encodeURIComponent(args.prepId)}/method-authoring-runs`, token, { method: "POST", body: JSON.stringify({}) });
89
+ if (status !== 201 && status !== 200) {
90
+ console.error(chalk.red(`Failed to start method-authoring run (HTTP ${status}).`));
91
+ if (raw)
92
+ console.error(raw);
93
+ process.exit(1);
94
+ }
95
+ console.log(chalk.green(`Method-authoring run ${chalk.bold(body?.run_id ?? "(?)")} started.`));
96
+ })
97
+ .command("improve <prep-id>", "Start a method-improvement run for a preparation", (y) => y.positional("prep-id", { type: "string", demandOption: true, describe: "Preparation id" }), async (args) => {
98
+ const { url, token } = resolveConnection(args);
99
+ const { status, body, raw } = await callJson(`${url}/v1/preparations/${encodeURIComponent(args.prepId)}/method-improvement-runs`, token, { method: "POST", body: JSON.stringify({}) });
100
+ if (status !== 201 && status !== 200) {
101
+ console.error(chalk.red(`Failed to start method-improvement run (HTTP ${status}).`));
102
+ if (raw)
103
+ console.error(raw);
104
+ process.exit(1);
105
+ }
106
+ console.log(chalk.green(`Method-improvement run ${chalk.bold(body?.run_id ?? "(?)")} started.`));
107
+ })
108
+ .demandCommand(1)
109
+ .strict(),
110
+ handler: () => {
111
+ /* yargs subcommand handlers do the work */
112
+ },
113
+ };