@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,465 +0,0 @@
1
- import chalk from "chalk";
2
- import * as p from "@clack/prompts";
3
- import { resolve } from "node:path";
4
- import { listCompiledMethodChoices, getCompiledMethod, } from "../../packages/method-package/method-definitions.js";
5
- import { createLocalMethodPackageFromTemplate } from "../../packages/method-package/interf-method-package.js";
6
- import { rmSync } from "node:fs";
7
- import { isMethodId, loadMethodDefinitionFromDir, seedLocalDefaultMethod, } from "../../packages/method-package/local-methods.js";
8
- import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
9
- import { runMethodAuthoringDraft } from "../../packages/method-authoring/method-authoring.js";
10
- import { listSourcePreparationConfigs, loadSourceFolderConfig, resolveSourcePreparationPath, } from "../../packages/project-model/source-config.js";
11
- import { slugify } from "../../packages/shared/naming.js";
12
- import { submitMethodAuthoringRunToLocalService } from "../../packages/local-service/index.js";
13
- import { DEFAULT_SOURCE_FOLDER_PATH_PLACEHOLDER, listSourceFolderChoices, normalizeSourceFolderPathForConfig, } from "./source-config-wizard.js";
14
- export const clackMethodPrompts = {
15
- intro: p.intro,
16
- select: (options) => p.select(options),
17
- text: (options) => p.text(options),
18
- isCancel: p.isCancel,
19
- log: {
20
- info: p.log.info,
21
- error: p.log.error,
22
- },
23
- };
24
- function normalizeMethodCreationMode(mode) {
25
- if (mode === "draft")
26
- return "draft-from-scratch";
27
- if (mode === "manual")
28
- return "fork-existing";
29
- return mode;
30
- }
31
- function findMatchingPreparationConfig(sourcePath, sourceFolderPath) {
32
- const config = loadSourceFolderConfig(sourcePath);
33
- for (const preparation of listSourcePreparationConfigs(config)) {
34
- if (resolveSourcePreparationPath(sourcePath, preparation) === sourceFolderPath) {
35
- return preparation;
36
- }
37
- }
38
- return null;
39
- }
40
- function describeSavedPreparation(preparation) {
41
- return preparation.about
42
- ? `${preparation.path} · ${preparation.about}`
43
- : `${preparation.path} · ${preparation.checks.length} readiness check${preparation.checks.length === 1 ? "" : "s"}`;
44
- }
45
- async function promptMethodSourceFolder(sourcePath, prompts) {
46
- const savedPreparations = listSourcePreparationConfigs(loadSourceFolderConfig(sourcePath));
47
- const folderChoices = listSourceFolderChoices(sourcePath);
48
- if (folderChoices.length > 0) {
49
- const selected = await prompts.select({
50
- message: "Which Source Folder should shape this Method?",
51
- options: [
52
- ...savedPreparations.map((preparation) => ({
53
- value: preparation.name,
54
- label: preparation.name,
55
- hint: describeSavedPreparation(preparation),
56
- })),
57
- ...folderChoices,
58
- {
59
- value: "__manual__",
60
- label: "Enter a different path",
61
- hint: "Use a relative path if the Source Folder is not listed here",
62
- },
63
- ],
64
- });
65
- if (prompts.isCancel(selected))
66
- return selected;
67
- if (selected !== "__manual__") {
68
- const savedPreparation = savedPreparations.find((preparation) => preparation.name === selected);
69
- if (savedPreparation) {
70
- return resolveSourcePreparationPath(sourcePath, savedPreparation);
71
- }
72
- return resolve(sourcePath, normalizeSourceFolderPathForConfig(sourcePath, String(selected)));
73
- }
74
- }
75
- const sourceFolderPrompt = await prompts.text({
76
- message: "Which Source Folder should shape this Method?",
77
- placeholder: DEFAULT_SOURCE_FOLDER_PATH_PLACEHOLDER,
78
- initialValue: folderChoices.length === 1 ? folderChoices[0]?.value : undefined,
79
- validate: (value) => {
80
- const trimmed = value.trim();
81
- if (trimmed.length === 0)
82
- return "Source Folder is required";
83
- try {
84
- normalizeSourceFolderPathForConfig(sourcePath, trimmed);
85
- return undefined;
86
- }
87
- catch (error) {
88
- return error instanceof Error ? error.message : String(error);
89
- }
90
- },
91
- });
92
- if (prompts.isCancel(sourceFolderPrompt))
93
- return sourceFolderPrompt;
94
- return resolve(sourcePath, normalizeSourceFolderPathForConfig(sourcePath, String(sourceFolderPrompt)));
95
- }
96
- export function formatMethodLabel(method) {
97
- return {
98
- value: method.id,
99
- label: method.scope === "local" ? `${method.label} (Local)` : method.label,
100
- hint: method.hint,
101
- };
102
- }
103
- export function buildCompiledMethodOptions(sourcePath) {
104
- return listCompiledMethodChoices(sourcePath).map(formatMethodLabel);
105
- }
106
- function methodUseLabel(method) {
107
- if (method.value === "interf-default") {
108
- return "built-in Method";
109
- }
110
- return method.label.replace(/ \(Local\)$/, "");
111
- }
112
- function methodForkLabel(method) {
113
- return `Fork ${methodUseLabel(method)}`;
114
- }
115
- export async function chooseCompiledMethod(sourcePath, options = {}) {
116
- const currentMethodId = options.currentMethodId;
117
- const methodOptions = buildCompiledMethodOptions(sourcePath);
118
- const orderedOptions = methodOptions
119
- .map((option) => option.value === currentMethodId
120
- ? {
121
- ...option,
122
- label: `${option.label} (Current)`,
123
- hint: option.hint,
124
- }
125
- : option)
126
- .sort((left, right) => {
127
- if (left.value === currentMethodId)
128
- return -1;
129
- if (right.value === currentMethodId)
130
- return 1;
131
- return 0;
132
- });
133
- if (orderedOptions.length === 1) {
134
- return orderedOptions[0]?.value ?? "interf-default";
135
- }
136
- return p.select({
137
- message: options.message ?? "Preparation Method?",
138
- options: orderedOptions,
139
- });
140
- }
141
- export async function chooseOrCreateCompiledMethodForPreparation(sourcePath, preparationConfig, options = {}, prompts = clackMethodPrompts) {
142
- const currentMethodId = options.currentMethodId ?? preparationConfig.method ?? "interf-default";
143
- const methodOptions = buildCompiledMethodOptions(sourcePath);
144
- const currentMethod = methodOptions.find((method) => method.value === currentMethodId) ??
145
- methodOptions.find((method) => method.value === "interf-default") ??
146
- methodOptions[0];
147
- const selected = await prompts.select({
148
- message: "Which Method should Interf use for this Preparation?",
149
- options: [
150
- {
151
- value: "__draft_from_scratch__",
152
- label: "Draft a new Method from scratch (Recommended)",
153
- hint: "Start from a neutral scaffold; an agent designs stages, outputs, and proof for this Preparation",
154
- },
155
- ...(currentMethod
156
- ? [{
157
- value: "__current__",
158
- label: `Use ${methodUseLabel(currentMethod)}`,
159
- hint: currentMethod.value === "interf-default"
160
- ? "Use the built-in Method without drafting a custom package"
161
- : currentMethod.hint,
162
- }]
163
- : []),
164
- ...(currentMethod
165
- ? [{
166
- value: "__fork_existing__",
167
- label: methodForkLabel(currentMethod),
168
- hint: "Copy its existing stage topology, then write the per-stage guidance yourself",
169
- }]
170
- : []),
171
- ...methodOptions
172
- .filter((method) => method.value !== currentMethod?.value)
173
- .map((method) => ({
174
- ...method,
175
- label: `Use ${methodUseLabel(method)}`,
176
- })),
177
- ],
178
- });
179
- if (prompts.isCancel(selected))
180
- return selected;
181
- if (selected === "__current__") {
182
- if (currentMethod?.value === "interf-default") {
183
- seedLocalDefaultMethod({ sourcePath });
184
- }
185
- return currentMethod?.value ?? currentMethodId;
186
- }
187
- if (selected === "__draft_from_scratch__" || selected === "__fork_existing__") {
188
- if (selected === "__fork_existing__" && currentMethod?.value === "interf-default") {
189
- seedLocalDefaultMethod({ sourcePath });
190
- }
191
- const methodId = await createMethodWizard({
192
- intro: false,
193
- sourcePath,
194
- baseMethodId: selected === "__fork_existing__"
195
- ? currentMethod?.value ?? currentMethodId
196
- : undefined,
197
- creationMode: selected === "__draft_from_scratch__" ? "draft-from-scratch" : "fork-existing",
198
- executionProfile: options.executionProfile,
199
- resolveExecutor: options.resolveExecutor,
200
- runDraft: options.runDraft,
201
- preparationContext: {
202
- config: preparationConfig,
203
- sourceFolderPath: resolveSourcePreparationPath(sourcePath, preparationConfig),
204
- },
205
- }, prompts);
206
- return methodId;
207
- }
208
- return String(selected);
209
- }
210
- export async function createMethodWizard(options = {}, prompts = clackMethodPrompts) {
211
- if (options.intro !== false) {
212
- prompts.intro(chalk.bold("Create a Method"));
213
- }
214
- const sourcePath = options.sourcePath ?? process.cwd();
215
- return createCompiledMethodWizard(sourcePath, prompts, {
216
- executionProfile: options.executionProfile,
217
- baseMethodId: options.baseMethodId,
218
- creationMode: options.creationMode,
219
- preparationContext: options.preparationContext,
220
- resolveExecutor: options.resolveExecutor,
221
- runDraft: options.runDraft,
222
- });
223
- }
224
- export async function createCompiledMethodWizard(sourcePath, prompts = clackMethodPrompts, options = {}) {
225
- const creationMode = options.creationMode ?? await prompts.select({
226
- message: "How do you want to create it?",
227
- options: [
228
- {
229
- value: "draft-from-scratch",
230
- label: "Draft a new Method from scratch (Recommended)",
231
- hint: "Start from a neutral scaffold and let a local agent design a reusable Method for this kind of agent work",
232
- },
233
- {
234
- value: "fork-existing",
235
- label: "Fork an existing Method and edit stage guidance",
236
- hint: "Copy an existing topology; choose this when the stages are right but their emphasis should change",
237
- },
238
- ],
239
- });
240
- if (prompts.isCancel(creationMode))
241
- return creationMode;
242
- const creationModeValue = normalizeMethodCreationMode(creationMode);
243
- const baseMethod = creationModeValue === "fork-existing"
244
- ? options.baseMethodId ?? await prompts.select({
245
- message: "Which existing Method should Interf fork?",
246
- options: listCompiledMethodChoices(sourcePath).map(formatMethodLabel),
247
- })
248
- : null;
249
- if (prompts.isCancel(baseMethod))
250
- return baseMethod;
251
- const baseMethodId = typeof baseMethod === "string" ? baseMethod : null;
252
- const resolvedBaseMethod = baseMethodId
253
- ? getCompiledMethod(baseMethodId, { sourcePath })
254
- : null;
255
- const rawName = await prompts.text({
256
- message: "New Method name?",
257
- placeholder: "customer-research",
258
- validate: (value) => {
259
- if (value.trim().length === 0)
260
- return "Name is required";
261
- const methodId = slugify(value);
262
- if (!isMethodId(methodId))
263
- return "Use letters, numbers, and dashes only";
264
- if (listCompiledMethodChoices(sourcePath).some((method) => method.id === methodId)) {
265
- return "That Method name already exists";
266
- }
267
- return undefined;
268
- },
269
- });
270
- if (prompts.isCancel(rawName))
271
- return rawName;
272
- const methodId = slugify(rawName);
273
- const label = rawName.trim();
274
- const hint = await prompts.text({
275
- message: "One-line Method description?",
276
- placeholder: "Bias toward evidence-backed summaries and strong retrieval structure",
277
- validate: (value) => (value.trim().length === 0 ? "Description is required" : undefined),
278
- });
279
- if (prompts.isCancel(hint))
280
- return hint;
281
- if (creationModeValue === "draft-from-scratch") {
282
- let sourceFolderPath = options.preparationContext?.sourceFolderPath ?? null;
283
- let matchedPreparation = options.preparationContext?.config ?? null;
284
- if (!sourceFolderPath) {
285
- const savedPreparations = listSourcePreparationConfigs(loadSourceFolderConfig(sourcePath));
286
- if (savedPreparations.length > 0) {
287
- const preparationChoice = await prompts.select({
288
- message: "Which saved Preparation should shape this Method?",
289
- options: [
290
- ...savedPreparations.map((preparation) => ({
291
- value: preparation.name,
292
- label: preparation.name,
293
- hint: describeSavedPreparation(preparation),
294
- })),
295
- {
296
- value: "__manual__",
297
- label: "Enter folder path manually",
298
- hint: "Use a folder that is not saved as a Preparation yet",
299
- },
300
- ],
301
- });
302
- if (prompts.isCancel(preparationChoice))
303
- return preparationChoice;
304
- if (preparationChoice !== "__manual__") {
305
- matchedPreparation = savedPreparations.find((preparation) => preparation.name === preparationChoice) ?? null;
306
- sourceFolderPath = matchedPreparation
307
- ? resolveSourcePreparationPath(sourcePath, matchedPreparation)
308
- : null;
309
- }
310
- }
311
- }
312
- if (!sourceFolderPath) {
313
- const sourceFolderPrompt = await promptMethodSourceFolder(sourcePath, prompts);
314
- if (prompts.isCancel(sourceFolderPrompt))
315
- return sourceFolderPrompt;
316
- if (!sourceFolderPrompt)
317
- return null;
318
- sourceFolderPath = String(sourceFolderPrompt);
319
- matchedPreparation = matchedPreparation ?? findMatchingPreparationConfig(sourcePath, sourceFolderPath);
320
- }
321
- const taskPrompt = await prompts.text({
322
- message: "What should this Method prepare for agents, and what evidence should show the data is ready?",
323
- placeholder: "Data: research interviews. Output: per-file summaries, themes, entities, claims, and source links. Evidence: every file processed, evidence linked to sources, required outputs created.",
324
- validate: (value) => (value.trim().length === 0 ? "A description is required" : undefined),
325
- });
326
- if (prompts.isCancel(taskPrompt))
327
- return taskPrompt;
328
- if (matchedPreparation) {
329
- prompts.log.info(`Shaping this Method from Preparation "${matchedPreparation.name}".`);
330
- }
331
- if (matchedPreparation?.checks.length) {
332
- prompts.log.info(`Using ${matchedPreparation.checks.length} saved readiness check${matchedPreparation.checks.length === 1 ? "" : "s"} from Preparation "${matchedPreparation.name}" as authoring context.`);
333
- }
334
- prompts.log.info("Preparing a Method-authoring shell from the Source Folder, then drafting the package.");
335
- let lastServiceStatus = "";
336
- const serviceRun = await submitMethodAuthoringRunToLocalService({
337
- projectPath: sourcePath,
338
- request: {
339
- preparation: matchedPreparation?.name ?? null,
340
- source_folder_path: sourceFolderPath,
341
- method_id: methodId,
342
- label,
343
- hint: hint.trim(),
344
- task_prompt: taskPrompt.trim(),
345
- checks: matchedPreparation?.checks ?? [],
346
- },
347
- onSubmitted: (submission) => {
348
- prompts.log.info(`Visible in Interf: ${submission.serviceUrl}/`);
349
- },
350
- onUpdate: (job) => {
351
- const activeStep = job.steps.find((step) => step.status === "running")
352
- ?? [...job.steps].reverse().find((step) => step.status === "succeeded" || step.status === "failed")
353
- ?? null;
354
- const statusKey = `${job.status}:${activeStep?.id ?? ""}:${activeStep?.status ?? ""}`;
355
- if (statusKey === lastServiceStatus)
356
- return;
357
- lastServiceStatus = statusKey;
358
- prompts.log.info(activeStep
359
- ? `${activeStep.label}: ${activeStep.status}`
360
- : `Method draft run: ${job.status}`);
361
- },
362
- });
363
- const result = serviceRun
364
- ? serviceRun.result
365
- ? {
366
- status: serviceRun.result.status,
367
- changed: serviceRun.result.changed,
368
- summary: serviceRun.result.summary,
369
- validation: serviceRun.result.validation ?? null,
370
- methodPath: serviceRun.result.method_path,
371
- shellPath: serviceRun.result.shell_path,
372
- }
373
- : {
374
- status: "executor-failed",
375
- changed: false,
376
- summary: serviceRun.error ?? "Method authoring failed in the local Interf service.",
377
- validation: null,
378
- methodPath: resolve(sourcePath, "interf", "methods", methodId),
379
- shellPath: resolve(sourcePath, "interf", "methods", methodId),
380
- }
381
- : await (async () => {
382
- const resolveExecutor = options.resolveExecutor ?? resolveOrConfigureLocalExecutor;
383
- const runDraft = options.runDraft ?? runMethodAuthoringDraft;
384
- const { executor, error } = await resolveExecutor({
385
- executionProfile: options.executionProfile,
386
- purpose: "method",
387
- });
388
- if (!executor && !error) {
389
- return null;
390
- }
391
- if (!executor) {
392
- process.exitCode = 1;
393
- (prompts.log.error ?? prompts.log.info)(error ?? "No coding agent detected.");
394
- return null;
395
- }
396
- return runDraft({
397
- sourcePath,
398
- sourceFolderPath,
399
- methodId,
400
- label,
401
- hint: hint.trim(),
402
- taskPrompt: taskPrompt.trim(),
403
- checks: matchedPreparation?.checks ?? [],
404
- executor,
405
- onStatus: (line) => prompts.log.info(line),
406
- });
407
- })();
408
- if (!result)
409
- return null;
410
- if (result.status === "updated") {
411
- const draft = loadMethodDefinitionFromDir(result.methodPath);
412
- const stageList = draft?.stages?.map((stage) => stage.id).join(" -> ") ?? "-";
413
- prompts.log.info(`Draft ready at ${result.methodPath}`);
414
- prompts.log.info(` Name: ${draft?.label ?? label}`);
415
- prompts.log.info(` Description: ${draft?.hint ?? hint.trim()}`);
416
- if (draft?.purpose)
417
- prompts.log.info(` Purpose: ${draft.purpose}`);
418
- prompts.log.info(` Stages: ${stageList}`);
419
- const confirmChoice = await prompts.select({
420
- message: "Save this Method?",
421
- options: [
422
- { value: "save", label: "Save", hint: "Keep the draft as your new Method package" },
423
- { value: "cancel", label: "Discard", hint: "Remove the draft folder and exit without saving" },
424
- ],
425
- });
426
- if (prompts.isCancel(confirmChoice) || confirmChoice === "cancel") {
427
- rmSync(result.methodPath, { recursive: true, force: true });
428
- prompts.log.info(`Discarded draft at ${result.methodPath}`);
429
- return null;
430
- }
431
- prompts.log.info(`Saved local Method: ${result.methodPath}`);
432
- return methodId;
433
- }
434
- process.exitCode = 1;
435
- (prompts.log.error ?? prompts.log.info)(result.status === "no-change"
436
- ? `${result.summary} Draft mode only succeeds when it produces an agent-work-specific package change.`
437
- : result.summary);
438
- prompts.log.info(`Method shell kept at: ${result.shellPath}`);
439
- return null;
440
- }
441
- const stagePolicyNotes = {};
442
- if (!baseMethodId || !resolvedBaseMethod) {
443
- throw new Error("Fork-existing Method creation needs a base Method.");
444
- }
445
- for (const stage of resolvedBaseMethod.stages) {
446
- const stagePrompt = await prompts.text({
447
- message: `What should ${stage.id} (${stage.label}) emphasize?`,
448
- placeholder: stage.description,
449
- validate: (value) => (value.trim().length === 0 ? `${stage.label} guidance is required` : undefined),
450
- });
451
- if (prompts.isCancel(stagePrompt))
452
- return stagePrompt;
453
- stagePolicyNotes[stage.id] = [String(stagePrompt).trim()];
454
- }
455
- const methodPath = createLocalMethodPackageFromTemplate({
456
- sourcePath,
457
- baseMethodId,
458
- methodId,
459
- label,
460
- hint: hint.trim(),
461
- stagePolicyNotes,
462
- });
463
- prompts.log.info(`Saved local Method: ${methodPath}`);
464
- return methodId;
465
- }
@@ -1,8 +0,0 @@
1
- import type { CommandModule } from "yargs";
2
- import type { MethodExecutionProfile } from "../../packages/agents/lib/executors.js";
3
- export declare const createCommand: CommandModule;
4
- export declare function createCompiledWizard(options?: {
5
- intro?: boolean;
6
- executionProfile?: MethodExecutionProfile;
7
- }): Promise<void>;
8
- export { type MethodWizardPrompts, formatMethodLabel, createMethodWizard, createCompiledMethodWizard, } from "./create-method-wizard.js";
@@ -1,189 +0,0 @@
1
- import chalk from "chalk";
2
- import * as p from "@clack/prompts";
3
- import { detectInterf, ensurePortableContextScaffold, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
4
- import { addExecutionProfileOptions, executionProfileFromArgv, } from "../../packages/agents/lib/execution-profile.js";
5
- import { SOURCE_FOLDER_CONFIG_PATH, listSourcePreparationConfigs, loadSourceFolderConfig, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../../packages/project-model/source-config.js";
6
- import { chooseOrCreateCompiledMethodForPreparation, createMethodWizard, } from "./create-method-wizard.js";
7
- import { findBuiltCompiledPath, } from "./compiled-flow.js";
8
- import { DEFAULT_PREPARATION_NAME, promptSingleCompiledConfig, } from "./source-config-wizard.js";
9
- import { defaultPreparationNameForPath, } from "../../packages/project-model/source-folders.js";
10
- import { resolveCommandControlPath, resolveInterfInstanceContext, } from "./control-path.js";
11
- import { resolveMethodId } from "../../packages/methods/method-resolution.js";
12
- function normalizeCreateTarget(value) {
13
- if (!value)
14
- return null;
15
- switch (value) {
16
- case "preparation":
17
- return "preparation";
18
- case "method":
19
- return "method";
20
- default:
21
- return null;
22
- }
23
- }
24
- async function selectCreateTarget() {
25
- return p.select({
26
- message: "Create what?",
27
- options: [
28
- {
29
- value: "preparation",
30
- label: "Preparation (Recommended)",
31
- hint: "Add one Preparation for this Source Folder",
32
- },
33
- {
34
- value: "method",
35
- label: "Method",
36
- hint: "Create a reusable local Method",
37
- },
38
- ],
39
- });
40
- }
41
- async function maybeAssignMethodToPreparation(sourcePath, methodId) {
42
- const config = loadSourceFolderConfig(sourcePath);
43
- const preparations = listSourcePreparationConfigs(config);
44
- if (preparations.length === 0) {
45
- p.log.info(`Created Method "${methodId}".`);
46
- p.log.info(`Next: run \`interf\`, add a Preparation, then assign Method "${methodId}" from that menu.`);
47
- return;
48
- }
49
- const assignNow = await p.confirm({
50
- message: "Assign this Method to a Preparation now? (Recommended)",
51
- initialValue: true,
52
- });
53
- if (p.isCancel(assignNow) || !assignNow) {
54
- p.log.info(`Created Method "${methodId}".`);
55
- p.log.info(`Next: run \`interf\`, open a saved Preparation, and assign Method "${methodId}" from that menu.`);
56
- return;
57
- }
58
- let targetPreparation = preparations[0] ?? null;
59
- if (preparations.length > 1) {
60
- const selected = await p.select({
61
- message: "Which saved Preparation should use this Method?",
62
- options: preparations.map((preparation) => ({
63
- value: preparation.name,
64
- label: preparation.name,
65
- hint: `${preparation.path} · ${preparation.about ?? `${preparation.checks.length} readiness check${preparation.checks.length === 1 ? "" : "s"}`}`,
66
- })),
67
- });
68
- if (p.isCancel(selected))
69
- return;
70
- targetPreparation = preparations.find((preparation) => preparation.name === selected) ?? null;
71
- }
72
- if (!targetPreparation)
73
- return;
74
- const nextConfig = {
75
- ...targetPreparation,
76
- method: methodId,
77
- };
78
- upsertSourcePreparationConfig(sourcePath, nextConfig, {
79
- matchName: targetPreparation.name,
80
- });
81
- const builtCompiledPath = findBuiltCompiledPath(sourcePath, targetPreparation.name);
82
- if (builtCompiledPath) {
83
- syncCompiledInterfConfigFromSourcePreparationConfig(builtCompiledPath, nextConfig);
84
- }
85
- else {
86
- ensurePortableContextScaffold(sourcePath, nextConfig.name, resolveMethodId(nextConfig));
87
- }
88
- p.log.info(`Assigned Method "${methodId}" to Preparation "${targetPreparation.name}".`);
89
- if (builtCompiledPath) {
90
- p.log.info("The active local Method copy for that Portable Context lives under `.interf/method/`.");
91
- }
92
- p.log.info("Next: run `interf compile`, then `interf test`.");
93
- }
94
- export const createCommand = {
95
- command: "create [type]",
96
- describe: "Create a Preparation or reusable Method",
97
- builder: (yargs) => addExecutionProfileOptions(yargs.positional("type", {
98
- type: "string",
99
- describe: "Type to create (`preparation` or `method`)",
100
- default: undefined,
101
- })),
102
- handler: async (argv) => {
103
- const rawType = argv.type;
104
- let type = normalizeCreateTarget(rawType);
105
- const executionProfile = executionProfileFromArgv(argv);
106
- if (rawType && !type) {
107
- process.exitCode = 1;
108
- p.log.error(`Unknown create target: ${rawType}`);
109
- return;
110
- }
111
- if (!type) {
112
- const selected = await selectCreateTarget();
113
- if (p.isCancel(selected))
114
- return;
115
- type = selected;
116
- }
117
- if (type === "method") {
118
- const detected = detectInterf(process.cwd());
119
- const sourcePath = detected ? resolveSourceControlPath(detected.path) : resolveCommandControlPath();
120
- const methodId = await createMethodWizard({
121
- sourcePath,
122
- executionProfile,
123
- });
124
- if (typeof methodId === "string") {
125
- await maybeAssignMethodToPreparation(sourcePath, methodId);
126
- }
127
- return;
128
- }
129
- await createCompiledWizard({ executionProfile });
130
- },
131
- };
132
- export async function createCompiledWizard(options = {}) {
133
- if (options.intro !== false) {
134
- p.intro(chalk.bold("Add a Preparation"));
135
- }
136
- const cwd = process.cwd();
137
- const detected = detectInterf(cwd);
138
- if (detected) {
139
- process.exitCode = 1;
140
- p.log.error("You are already inside Portable Context.");
141
- return;
142
- }
143
- const initContext = resolveInterfInstanceContext(cwd);
144
- const sourcePath = initContext.controlPath;
145
- const savedPreparations = listSourcePreparationConfigs(loadSourceFolderConfig(sourcePath));
146
- if (savedPreparations.length > 0) {
147
- p.log.info(`This Source Folder already has ${savedPreparations.length} saved Preparation${savedPreparations.length === 1 ? "" : "s"} in ${SOURCE_FOLDER_CONFIG_PATH}. Add another only when you need a separate Source Folder, agent-work focus, or readiness-check set.`);
148
- }
149
- if (sourcePath !== cwd) {
150
- p.log.info(`Interf Workspace: ${sourcePath}`);
151
- }
152
- p.log.info("Interf works one Preparation at a time. Start with the agent work, the relevant files, and a few readiness checks, then build Portable Context when you need evidence that the data is ready for agents.");
153
- const existingConfig = loadSourceFolderConfig(sourcePath);
154
- const initialConfig = initContext.defaultSourceFolderPath && initContext.defaultPreparationPath
155
- ? {
156
- name: defaultPreparationNameForPath(initContext.defaultSourceFolderPath),
157
- path: initContext.defaultPreparationPath,
158
- }
159
- : { name: DEFAULT_PREPARATION_NAME };
160
- const draft = await promptSingleCompiledConfig({
161
- projectPath: sourcePath,
162
- initial: initialConfig,
163
- introStyle: existingConfig ? "additional" : "first",
164
- });
165
- if (!draft)
166
- return;
167
- const existingNames = new Set(listSourcePreparationConfigs(existingConfig).map((preparation) => preparation.name));
168
- if (existingNames.has(draft.name)) {
169
- process.exitCode = 1;
170
- p.log.error(`Preparation "${draft.name}" already exists. Use \`interf\` or \`interf init\` to edit it.`);
171
- return;
172
- }
173
- const methodChoice = await chooseOrCreateCompiledMethodForPreparation(sourcePath, draft, {
174
- currentMethodId: "interf-default",
175
- executionProfile: options.executionProfile,
176
- });
177
- if (!methodChoice || p.isCancel(methodChoice))
178
- return;
179
- const configToSave = {
180
- ...draft,
181
- method: String(methodChoice),
182
- };
183
- upsertSourcePreparationConfig(sourcePath, configToSave);
184
- ensurePortableContextScaffold(sourcePath, configToSave.name, configToSave.method);
185
- p.outro(configToSave.checks.length > 0
186
- ? "Saved Preparation.\nNext:\n interf compile\n interf test"
187
- : "Saved Preparation.\nNext:\n interf or interf init");
188
- }
189
- export { formatMethodLabel, createMethodWizard, createCompiledMethodWizard, } from "./create-method-wizard.js";
@@ -1,2 +0,0 @@
1
- import type { CommandModule } from "yargs";
2
- export declare const defaultCommand: CommandModule;