@interf/compiler 0.9.5 → 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 (214) hide show
  1. package/README.md +96 -92
  2. package/TRADEMARKS.md +2 -13
  3. package/agent-skills/interf-actions/SKILL.md +95 -36
  4. package/agent-skills/interf-actions/references/cli.md +118 -51
  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 +8 -25
  13. package/dist/cli/commands/compile.js +75 -360
  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 -26
  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 +68 -111
  29. package/dist/cli/commands/test.d.ts +6 -14
  30. package/dist/cli/commands/test.js +65 -181
  31. package/dist/cli/commands/web.d.ts +0 -9
  32. package/dist/cli/commands/web.js +147 -120
  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/{18a8f2jkv3z.c.css → 045gole2ojo3g.css} +1 -1
  44. package/dist/compiler-ui/_next/static/chunks/{177mvn4rse235.js → 17t-lulmyawg5.js} +9 -9
  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/packages/agents/lib/shells.d.ts +1 -1
  56. package/dist/packages/agents/lib/shells.js +111 -52
  57. package/dist/packages/agents/lib/user-config.d.ts +4 -2
  58. package/dist/packages/agents/lib/user-config.js +15 -7
  59. package/dist/packages/compiler/compiled-paths.d.ts +9 -2
  60. package/dist/packages/compiler/compiled-paths.js +30 -15
  61. package/dist/packages/compiler/compiled-pipeline.js +23 -3
  62. package/dist/packages/compiler/compiled-stage-plan.js +4 -0
  63. package/dist/packages/compiler/compiled-target.d.ts +1 -1
  64. package/dist/packages/compiler/compiled-target.js +1 -1
  65. package/dist/packages/compiler/index.d.ts +1 -0
  66. package/dist/packages/compiler/index.js +1 -0
  67. package/dist/packages/compiler/lib/schema.d.ts +26 -31
  68. package/dist/packages/compiler/lib/schema.js +1 -12
  69. package/dist/packages/compiler/method-runs.d.ts +2 -3
  70. package/dist/packages/compiler/method-runs.js +2 -3
  71. package/dist/packages/compiler/reset.js +3 -1
  72. package/dist/packages/compiler/runtime-contracts.js +0 -3
  73. package/dist/packages/compiler/runtime-prompt.js +1 -1
  74. package/dist/packages/compiler/source-files.d.ts +46 -0
  75. package/dist/packages/compiler/source-files.js +149 -0
  76. package/dist/packages/compiler/state-artifacts.d.ts +3 -2
  77. package/dist/packages/compiler/state-artifacts.js +4 -3
  78. package/dist/packages/compiler/state-io.d.ts +3 -2
  79. package/dist/packages/compiler/state-io.js +11 -5
  80. package/dist/packages/compiler/state-paths.d.ts +2 -1
  81. package/dist/packages/compiler/state-paths.js +6 -3
  82. package/dist/packages/compiler/state-view.d.ts +3 -2
  83. package/dist/packages/compiler/state-view.js +18 -28
  84. package/dist/packages/compiler/state.d.ts +4 -4
  85. package/dist/packages/compiler/state.js +3 -3
  86. package/dist/packages/contracts/index.d.ts +1 -1
  87. package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
  88. package/dist/packages/contracts/lib/preparation-paths.js +177 -0
  89. package/dist/packages/contracts/lib/schema.d.ts +85 -5
  90. package/dist/packages/contracts/lib/schema.js +46 -1
  91. package/dist/packages/execution/lib/schema.d.ts +50 -50
  92. package/dist/packages/execution/lib/schema.js +1 -1
  93. package/dist/packages/local-service/action-definitions.d.ts +14 -14
  94. package/dist/packages/local-service/action-definitions.js +27 -28
  95. package/dist/packages/local-service/action-planner.js +2 -1
  96. package/dist/packages/local-service/client.d.ts +51 -52
  97. package/dist/packages/local-service/client.js +132 -140
  98. package/dist/packages/local-service/connection-config.d.ts +38 -0
  99. package/dist/packages/local-service/connection-config.js +75 -0
  100. package/dist/packages/local-service/index.d.ts +11 -7
  101. package/dist/packages/local-service/index.js +6 -4
  102. package/dist/packages/local-service/instance-paths.d.ts +100 -0
  103. package/dist/packages/local-service/instance-paths.js +165 -0
  104. package/dist/packages/local-service/lib/schema.d.ts +405 -2297
  105. package/dist/packages/local-service/lib/schema.js +146 -62
  106. package/dist/packages/local-service/native-run-handlers.js +3 -3
  107. package/dist/packages/local-service/preparation-store.d.ts +92 -0
  108. package/dist/packages/local-service/preparation-store.js +171 -0
  109. package/dist/packages/local-service/routes.d.ts +33 -16
  110. package/dist/packages/local-service/routes.js +44 -20
  111. package/dist/packages/local-service/run-observability.js +11 -11
  112. package/dist/packages/local-service/runtime-caches.d.ts +76 -0
  113. package/dist/packages/local-service/runtime-caches.js +191 -0
  114. package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
  115. package/dist/packages/local-service/runtime-event-applier.js +177 -0
  116. package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
  117. package/dist/packages/local-service/runtime-persistence.js +137 -0
  118. package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
  119. package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
  120. package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
  121. package/dist/packages/local-service/runtime-resource-builders.js +149 -0
  122. package/dist/packages/local-service/runtime.d.ts +197 -43
  123. package/dist/packages/local-service/runtime.js +800 -974
  124. package/dist/packages/local-service/server.d.ts +15 -0
  125. package/dist/packages/local-service/server.js +641 -273
  126. package/dist/packages/local-service/service-registry.d.ts +47 -0
  127. package/dist/packages/local-service/service-registry.js +137 -0
  128. package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
  129. package/dist/packages/method-authoring/method-authoring.js +2 -2
  130. package/dist/packages/method-authoring/method-improvement.js +1 -1
  131. package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
  132. package/dist/packages/method-package/builtin-compiled-method.js +8 -14
  133. package/dist/packages/method-package/context-interface.d.ts +4 -40
  134. package/dist/packages/method-package/context-interface.js +1 -23
  135. package/dist/packages/method-package/interf-method-package.d.ts +4 -4
  136. package/dist/packages/method-package/interf-method-package.js +21 -33
  137. package/dist/packages/method-package/local-methods.d.ts +10 -6
  138. package/dist/packages/method-package/local-methods.js +57 -39
  139. package/dist/packages/method-package/method-definitions.d.ts +8 -34
  140. package/dist/packages/method-package/method-definitions.js +49 -37
  141. package/dist/packages/method-package/method-helpers.d.ts +1 -13
  142. package/dist/packages/method-package/method-helpers.js +8 -42
  143. package/dist/packages/method-package/method-stage-runner.js +2 -2
  144. package/dist/packages/method-package/user-methods.d.ts +17 -0
  145. package/dist/packages/method-package/user-methods.js +77 -0
  146. package/dist/packages/project-model/index.d.ts +0 -1
  147. package/dist/packages/project-model/index.js +0 -1
  148. package/dist/packages/project-model/interf-detect.d.ts +8 -3
  149. package/dist/packages/project-model/interf-detect.js +34 -34
  150. package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
  151. package/dist/packages/project-model/interf-scaffold.js +23 -32
  152. package/dist/packages/project-model/lib/schema.js +38 -1
  153. package/dist/packages/project-model/preparation-entries.d.ts +5 -5
  154. package/dist/packages/project-model/preparation-entries.js +14 -14
  155. package/dist/packages/project-model/source-config.d.ts +11 -11
  156. package/dist/packages/project-model/source-config.js +74 -46
  157. package/dist/packages/project-model/source-folders.d.ts +5 -5
  158. package/dist/packages/project-model/source-folders.js +14 -14
  159. package/dist/packages/shared/filesystem.d.ts +7 -0
  160. package/dist/packages/shared/filesystem.js +97 -10
  161. package/dist/packages/testing/lib/schema.d.ts +10 -10
  162. package/dist/packages/testing/lib/schema.js +2 -2
  163. package/dist/packages/testing/readiness-check-run.d.ts +4 -4
  164. package/dist/packages/testing/readiness-check-run.js +36 -36
  165. package/dist/packages/testing/test-execution.js +6 -6
  166. package/dist/packages/testing/test-paths.js +4 -3
  167. package/dist/packages/testing/test-sandbox.d.ts +0 -1
  168. package/dist/packages/testing/test-sandbox.js +14 -30
  169. package/dist/packages/testing/test-targets.d.ts +1 -1
  170. package/dist/packages/testing/test-targets.js +6 -6
  171. package/dist/packages/testing/test.d.ts +1 -1
  172. package/dist/packages/testing/test.js +1 -1
  173. package/package.json +3 -4
  174. package/CHANGELOG.md +0 -93
  175. package/LICENSE +0 -183
  176. package/dist/cli/commands/action-input-cli.d.ts +0 -25
  177. package/dist/cli/commands/action-input-cli.js +0 -73
  178. package/dist/cli/commands/control-path.d.ts +0 -11
  179. package/dist/cli/commands/control-path.js +0 -72
  180. package/dist/cli/commands/create-method-wizard.d.ts +0 -64
  181. package/dist/cli/commands/create-method-wizard.js +0 -434
  182. package/dist/cli/commands/create.d.ts +0 -6
  183. package/dist/cli/commands/create.js +0 -183
  184. package/dist/cli/commands/default.d.ts +0 -2
  185. package/dist/cli/commands/default.js +0 -39
  186. package/dist/cli/commands/executor-flow.d.ts +0 -29
  187. package/dist/cli/commands/executor-flow.js +0 -163
  188. package/dist/cli/commands/init.d.ts +0 -26
  189. package/dist/cli/commands/init.js +0 -771
  190. package/dist/cli/commands/list.d.ts +0 -2
  191. package/dist/cli/commands/list.js +0 -30
  192. package/dist/cli/commands/preparation-action.d.ts +0 -8
  193. package/dist/cli/commands/preparation-action.js +0 -29
  194. package/dist/cli/commands/preparation-picker.d.ts +0 -5
  195. package/dist/cli/commands/preparation-picker.js +0 -36
  196. package/dist/cli/commands/preparation-selection.d.ts +0 -6
  197. package/dist/cli/commands/preparation-selection.js +0 -11
  198. package/dist/cli/commands/service-action-flow.d.ts +0 -9
  199. package/dist/cli/commands/service-action-flow.js +0 -19
  200. package/dist/cli/commands/source-config-wizard.d.ts +0 -51
  201. package/dist/cli/commands/source-config-wizard.js +0 -670
  202. package/dist/cli/commands/verify.d.ts +0 -2
  203. package/dist/cli/commands/verify.js +0 -94
  204. package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
  205. package/dist/packages/compiler/raw-snapshot.js +0 -101
  206. package/dist/packages/method-package/index.d.ts +0 -11
  207. package/dist/packages/method-package/index.js +0 -11
  208. package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
  209. package/dist/packages/method-package/method-stage-policy.js +0 -31
  210. package/dist/packages/project-model/project-paths.d.ts +0 -12
  211. package/dist/packages/project-model/project-paths.js +0 -33
  212. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
  213. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
  214. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
@@ -1,670 +0,0 @@
1
- import * as p from "@clack/prompts";
2
- import { sourceConfig as projectSourceConfig, sourceFolders as projectSourceFolders, } from "../../packages/project-model/index.js";
3
- import { slugify } from "../../packages/shared/naming.js";
4
- import { submitReadinessCheckDraftToLocalService, } from "../../packages/local-service/index.js";
5
- import { buildCreatePreparationActionDefinition, } from "../../packages/local-service/action-definitions.js";
6
- export const DEFAULT_PREPARATION_NAME = "default";
7
- export const DEFAULT_COMPILED_CHECK_QUESTION_PLACEHOLDER = "An agent-work-critical check you can already verify from this Source Folder";
8
- export const DEFAULT_COMPILED_CHECK_ANSWER_PLACEHOLDER = "The expected answer in plain English";
9
- export const DEFAULT_SOURCE_FOLDER_PATH_PLACEHOLDER = "./source-files";
10
- export const DEFAULT_COMPILE_RETRY_ATTEMPTS = 3;
11
- export const DEFAULT_SELF_IMPROVING_LOOPS = 3;
12
- const DEFAULT_SELF_IMPROVING_ATTEMPTS = 1;
13
- function normalizeOptionalPromptText(value) {
14
- if (typeof value !== "string")
15
- return undefined;
16
- const normalized = value.trim();
17
- return normalized.length > 0 ? normalized : undefined;
18
- }
19
- export function normalizeSourceFolderPathForConfig(projectPath, value) {
20
- return projectSourceFolders.normalizeSourcePreparationPathForConfig(projectPath, value);
21
- }
22
- function defaultPreparationNameForPath(sourceFolderPath) {
23
- return projectSourceFolders.defaultPreparationNameForPath(sourceFolderPath);
24
- }
25
- export function listSourceFolderChoices(cwd = process.cwd()) {
26
- return projectSourceFolders.listSourceFolderChoices(cwd);
27
- }
28
- export function defaultSourceFolderPathForPrompt(name, introStyle, cwd = process.cwd()) {
29
- return projectSourceFolders.defaultSourcePreparationPathForPrompt(name, introStyle, cwd);
30
- }
31
- async function promptSourceFolderPath(options) {
32
- const folderChoices = listSourceFolderChoices(options.projectPath);
33
- if (folderChoices.length > 0) {
34
- const selected = await p.select({
35
- message: "Which Source Folder should Interf use?",
36
- options: [
37
- ...folderChoices,
38
- {
39
- value: "__manual__",
40
- label: "Enter a different path",
41
- hint: "Use a relative path if the Source Folder is not listed here",
42
- },
43
- ],
44
- initialValue: folderChoices.some((choice) => choice.value === options.initialPath)
45
- ? options.initialPath
46
- : undefined,
47
- });
48
- if (p.isCancel(selected))
49
- return null;
50
- if (selected !== "__manual__") {
51
- try {
52
- return normalizeSourceFolderPathForConfig(options.projectPath, String(selected));
53
- }
54
- catch (error) {
55
- p.log.error(error instanceof Error ? error.message : String(error));
56
- return null;
57
- }
58
- }
59
- }
60
- const sourceFolderPath = await p.text({
61
- message: "Which Source Folder should Interf use?",
62
- placeholder: DEFAULT_SOURCE_FOLDER_PATH_PLACEHOLDER,
63
- initialValue: options.initialPath,
64
- validate: (value) => {
65
- const normalized = value.trim();
66
- if (normalized.length === 0)
67
- return "Source Folder is required";
68
- try {
69
- normalizeSourceFolderPathForConfig(options.projectPath, normalized);
70
- return undefined;
71
- }
72
- catch (error) {
73
- return error instanceof Error ? error.message : String(error);
74
- }
75
- },
76
- });
77
- if (p.isCancel(sourceFolderPath))
78
- return null;
79
- return normalizeSourceFolderPathForConfig(options.projectPath, String(sourceFolderPath));
80
- }
81
- export function preparationAboutPromptMessage(introStyle) {
82
- void introStyle;
83
- return createPreparationActionField("about").label;
84
- }
85
- function createPreparationActionField(name) {
86
- const definition = buildCreatePreparationActionDefinition({
87
- existingNames: [],
88
- methods: [],
89
- sourcePath: DEFAULT_SOURCE_FOLDER_PATH_PLACEHOLDER,
90
- suggestedName: DEFAULT_PREPARATION_NAME,
91
- });
92
- const field = definition.fields.find((candidate) => candidate.name === name);
93
- if (!field)
94
- throw new Error(`Create Preparation action field missing: ${name}`);
95
- return field;
96
- }
97
- function formatAttemptLabel(count, noun) {
98
- return `${count} ${noun}${count === 1 ? "" : "s"}`;
99
- }
100
- export function resolveCompileLoopMode(maxAttempts, maxLoops) {
101
- if ((maxLoops ?? 0) > 0)
102
- return "self-improving";
103
- if ((maxAttempts ?? 0) > 1)
104
- return "retry";
105
- return "once";
106
- }
107
- export function describeCompileLoopSelection(options) {
108
- const mode = resolveCompileLoopMode(options.maxAttempts, options.maxLoops);
109
- if (mode === "once") {
110
- return "Prepare once.";
111
- }
112
- if (mode === "retry") {
113
- const attempts = options.maxAttempts ?? DEFAULT_COMPILE_RETRY_ATTEMPTS;
114
- return `Prepare retries are enabled here (${formatAttemptLabel(attempts, "total attempt")}).`;
115
- }
116
- const loops = options.maxLoops ?? DEFAULT_SELF_IMPROVING_LOOPS;
117
- const attempts = options.maxAttempts ?? DEFAULT_SELF_IMPROVING_ATTEMPTS;
118
- return `Self-improving loops are enabled here (${formatAttemptLabel(attempts, "attempt")} per variation, ${formatAttemptLabel(loops, "Method revision")}).`;
119
- }
120
- async function promptCompileRetryAttempts(options) {
121
- const maxAttempts = await p.text({
122
- message: options.message,
123
- placeholder: String(DEFAULT_COMPILE_RETRY_ATTEMPTS),
124
- initialValue: String(options.initialMaxAttempts ?? DEFAULT_COMPILE_RETRY_ATTEMPTS),
125
- validate: (value) => {
126
- const parsed = Number.parseInt(value.trim(), 10);
127
- if (!Number.isInteger(parsed) || parsed < 2 || parsed > 5) {
128
- return "Enter a whole number from 2 to 5";
129
- }
130
- return undefined;
131
- },
132
- });
133
- if (p.isCancel(maxAttempts))
134
- return null;
135
- return projectSourceConfig.compiledMaxAttempts(Number.parseInt(String(maxAttempts).trim(), 10))
136
- ?? DEFAULT_COMPILE_RETRY_ATTEMPTS;
137
- }
138
- export async function promptCheckCases(options) {
139
- p.log.info(options.heading);
140
- const cases = [];
141
- const startIndex = options.startIndex ?? 1;
142
- while (true) {
143
- const question = await p.text({
144
- message: cases.length === 0
145
- ? options.questionMessage
146
- : `Check ${startIndex + cases.length}?`,
147
- placeholder: options.questionPlaceholder,
148
- validate: (value) => (value.trim().length === 0 ? "Check is required" : undefined),
149
- });
150
- if (p.isCancel(question))
151
- return null;
152
- const answer = await p.text({
153
- message: cases.length === 0
154
- ? options.answerMessage
155
- : `Expected answer ${startIndex + cases.length}?`,
156
- placeholder: options.answerPlaceholder,
157
- validate: (value) => (value.trim().length === 0 ? "Answer is required" : undefined),
158
- });
159
- if (p.isCancel(answer))
160
- return null;
161
- cases.push({
162
- question: String(question).trim(),
163
- answer: String(answer).trim(),
164
- });
165
- const addAnother = await p.confirm({
166
- message: options.addAnotherMessage,
167
- initialValue: false,
168
- });
169
- if (p.isCancel(addAnother))
170
- return null;
171
- if (!addAnother)
172
- return cases;
173
- }
174
- }
175
- function printDraftReadinessChecks(checks) {
176
- console.log();
177
- p.log.info(`Draft readiness checks: ${checks.length}`);
178
- for (const [index, check] of checks.entries()) {
179
- console.log(` ${index + 1}. ${check.question}`);
180
- console.log(` Expected: ${check.answer ?? ""}`);
181
- }
182
- }
183
- async function promptDraftReadinessChecks(options) {
184
- let resolvedSourceFolderPath;
185
- try {
186
- const preparationPathConfig = {
187
- path: options.sourceFolderPath,
188
- };
189
- resolvedSourceFolderPath = projectSourceConfig.resolveSourcePreparationPath(options.projectPath, preparationPathConfig);
190
- }
191
- catch (error) {
192
- p.log.error(error instanceof Error ? error.message : String(error));
193
- return "manual";
194
- }
195
- while (true) {
196
- p.log.info("Drafting readiness checks from the source files.");
197
- let lastServiceStatus = "";
198
- const serviceRun = await submitReadinessCheckDraftToLocalService({
199
- projectPath: options.projectPath,
200
- request: {
201
- preparation: options.preparationName,
202
- source_folder_path: resolvedSourceFolderPath,
203
- about: options.about,
204
- target_count: 4,
205
- },
206
- onSubmitted: (submission) => {
207
- p.log.info(`Visible in Interf: ${submission.serviceUrl}/`);
208
- },
209
- onUpdate: (job) => {
210
- const activeStep = job.steps.find((step) => step.status === "running")
211
- ?? [...job.steps].reverse().find((step) => step.status === "succeeded" || step.status === "failed")
212
- ?? null;
213
- const statusKey = `${job.status}:${activeStep?.id ?? ""}:${activeStep?.status ?? ""}`;
214
- if (statusKey === lastServiceStatus)
215
- return;
216
- lastServiceStatus = statusKey;
217
- p.log.info(activeStep
218
- ? `${activeStep.label}: ${activeStep.status}`
219
- : `Draft readiness checks run: ${job.status}`);
220
- },
221
- });
222
- const drafted = serviceRun
223
- ? {
224
- checks: serviceRun.result?.checks ?? null,
225
- error: serviceRun.error,
226
- }
227
- : "service-missing";
228
- if (drafted === null)
229
- return null;
230
- if (drafted === "service-missing") {
231
- p.log.error("Interf local service is not running. Start `interf web` to create visible runs for drafting readiness checks.");
232
- const manualChoice = await p.select({
233
- message: "How do you want to continue?",
234
- options: [
235
- {
236
- value: "manual",
237
- label: "Add readiness checks manually",
238
- hint: "Write the checks and expected answers yourself",
239
- },
240
- {
241
- value: "skip",
242
- label: "Skip for now",
243
- hint: "Save this Preparation without readiness checks",
244
- },
245
- ],
246
- });
247
- if (p.isCancel(manualChoice))
248
- return null;
249
- return manualChoice === "manual" ? "manual" : [];
250
- }
251
- if (!drafted.checks) {
252
- p.log.error(drafted.error ?? "Could not draft readiness checks from this Source Folder.");
253
- const retryMode = await p.select({
254
- message: "How do you want to continue?",
255
- options: [
256
- {
257
- value: "retry",
258
- label: "Try auto-create again",
259
- hint: "Run the same local agent again on the Source Folder",
260
- },
261
- {
262
- value: "manual",
263
- label: "Add readiness checks manually",
264
- hint: "Write the checks yourself instead",
265
- },
266
- {
267
- value: "skip",
268
- label: "Skip for now",
269
- hint: "Save this Preparation without readiness checks",
270
- },
271
- ],
272
- });
273
- if (p.isCancel(retryMode))
274
- return null;
275
- if (retryMode === "retry")
276
- continue;
277
- return retryMode === "manual" ? "manual" : [];
278
- }
279
- printDraftReadinessChecks(drafted.checks);
280
- const nextStep = await p.select({
281
- message: "Use these readiness checks?",
282
- options: [
283
- {
284
- value: "use",
285
- label: "Use this draft (Recommended)",
286
- hint: "Save these checks and edit them later if needed",
287
- },
288
- {
289
- value: "retry",
290
- label: "Draft again",
291
- hint: "Run the same local agent again on the Source Folder",
292
- },
293
- {
294
- value: "manual",
295
- label: "Add readiness checks manually instead",
296
- hint: "Discard this draft and write the checks yourself",
297
- },
298
- {
299
- value: "skip",
300
- label: "Skip for now",
301
- hint: "Save this Preparation without readiness checks",
302
- },
303
- ],
304
- });
305
- if (p.isCancel(nextStep))
306
- return null;
307
- if (nextStep === "retry")
308
- continue;
309
- if (nextStep === "manual")
310
- return "manual";
311
- if (nextStep === "skip")
312
- return [];
313
- return drafted.checks;
314
- }
315
- }
316
- async function promptCompiledChecks(options) {
317
- if (!options.initialChecks?.length) {
318
- if (options.initialAbout) {
319
- p.log.info(`About: ${options.initialAbout}`);
320
- }
321
- p.log.info("Readiness checks are small agent-work-critical checks from your files that define when this data is ready for agent work.");
322
- const mode = await p.select({
323
- message: "How should Interf create them?",
324
- options: [
325
- {
326
- value: "draft",
327
- label: "Auto-create readiness checks (Recommended)",
328
- hint: "Let your chosen local agent recommend a few clear, verifiable checks from this Source Folder",
329
- },
330
- {
331
- value: "manual",
332
- label: "Add readiness checks manually",
333
- hint: "Write the checks and expected answers yourself",
334
- },
335
- {
336
- value: "skip",
337
- label: "Skip for now",
338
- hint: "You can save the Preparation first and add readiness checks later",
339
- },
340
- ],
341
- });
342
- if (p.isCancel(mode))
343
- return null;
344
- if (mode === "skip")
345
- return [];
346
- if (mode === "draft") {
347
- const drafted = await promptDraftReadinessChecks({
348
- projectPath: options.projectPath,
349
- preparationName: options.preparationName,
350
- sourceFolderPath: options.sourceFolderPath,
351
- about: options.initialAbout,
352
- });
353
- if (drafted === null)
354
- return null;
355
- if (drafted === "manual") {
356
- return promptCheckCases({
357
- heading: "Readiness checks",
358
- questionMessage: "Check 1?",
359
- questionPlaceholder: DEFAULT_COMPILED_CHECK_QUESTION_PLACEHOLDER,
360
- answerMessage: "Expected answer 1?",
361
- answerPlaceholder: DEFAULT_COMPILED_CHECK_ANSWER_PLACEHOLDER,
362
- addAnotherMessage: "Add another readiness check?",
363
- });
364
- }
365
- return drafted;
366
- }
367
- return promptCheckCases({
368
- heading: "Readiness checks",
369
- questionMessage: "Check 1?",
370
- questionPlaceholder: DEFAULT_COMPILED_CHECK_QUESTION_PLACEHOLDER,
371
- answerMessage: "Expected answer 1?",
372
- answerPlaceholder: DEFAULT_COMPILED_CHECK_ANSWER_PLACEHOLDER,
373
- addAnotherMessage: "Add another readiness check?",
374
- });
375
- }
376
- if (options.initialAbout) {
377
- p.log.info(`About: ${options.initialAbout}`);
378
- }
379
- p.log.info(`Current readiness checks: ${options.initialChecks.length}`);
380
- const mode = await p.select({
381
- message: "What do you want to do with them?",
382
- options: [
383
- {
384
- value: "keep",
385
- label: "Keep them",
386
- hint: "Leave the current readiness checks as-is",
387
- },
388
- {
389
- value: "add",
390
- label: "Add more",
391
- hint: "Append more readiness checks",
392
- },
393
- {
394
- value: "replace",
395
- label: "Replace all",
396
- hint: "Rewrite the readiness checks from scratch",
397
- },
398
- {
399
- value: "redraft",
400
- label: "Replace with auto-created draft",
401
- hint: "Let a local agent rewrite the readiness checks from the Preparation files",
402
- },
403
- {
404
- value: "clear",
405
- label: "Clear them for now",
406
- hint: "Keep this Preparation without readiness checks",
407
- },
408
- ],
409
- });
410
- if (p.isCancel(mode))
411
- return null;
412
- if (mode === "keep") {
413
- return options.initialChecks;
414
- }
415
- if (mode === "clear") {
416
- return [];
417
- }
418
- if (mode === "redraft") {
419
- const drafted = await promptDraftReadinessChecks({
420
- projectPath: options.projectPath,
421
- preparationName: options.preparationName,
422
- sourceFolderPath: options.sourceFolderPath,
423
- about: options.initialAbout,
424
- });
425
- if (drafted === null)
426
- return null;
427
- if (drafted === "manual") {
428
- return promptCheckCases({
429
- heading: "Replace readiness checks",
430
- questionMessage: "Check 1?",
431
- questionPlaceholder: DEFAULT_COMPILED_CHECK_QUESTION_PLACEHOLDER,
432
- answerMessage: "Expected answer 1?",
433
- answerPlaceholder: DEFAULT_COMPILED_CHECK_ANSWER_PLACEHOLDER,
434
- addAnotherMessage: "Add another readiness check?",
435
- });
436
- }
437
- return drafted;
438
- }
439
- const nextChecks = await promptCheckCases({
440
- heading: mode === "add" ? "Add more readiness checks" : "Replace readiness checks",
441
- questionMessage: mode === "add"
442
- ? `Check ${options.initialChecks.length + 1}?`
443
- : "Check 1?",
444
- questionPlaceholder: DEFAULT_COMPILED_CHECK_QUESTION_PLACEHOLDER,
445
- answerMessage: mode === "add"
446
- ? `Expected answer ${options.initialChecks.length + 1}?`
447
- : "Expected answer 1?",
448
- answerPlaceholder: DEFAULT_COMPILED_CHECK_ANSWER_PLACEHOLDER,
449
- addAnotherMessage: "Add another readiness check?",
450
- startIndex: mode === "add" ? options.initialChecks.length + 1 : 1,
451
- });
452
- if (nextChecks === null)
453
- return null;
454
- return mode === "add" ? [...options.initialChecks, ...nextChecks] : nextChecks;
455
- }
456
- async function promptSelfImprovingLoops(options) {
457
- const maxLoops = await p.text({
458
- message: options.message,
459
- placeholder: String(DEFAULT_SELF_IMPROVING_LOOPS),
460
- initialValue: String(options.initialMaxLoops ?? DEFAULT_SELF_IMPROVING_LOOPS),
461
- validate: (value) => {
462
- const parsed = Number.parseInt(value.trim(), 10);
463
- if (!Number.isInteger(parsed) || parsed < 1 || parsed > 3) {
464
- return "Enter a whole number from 1 to 3";
465
- }
466
- return undefined;
467
- },
468
- });
469
- if (p.isCancel(maxLoops))
470
- return null;
471
- return projectSourceConfig.compiledMaxLoops(Number.parseInt(String(maxLoops).trim(), 10))
472
- ?? DEFAULT_SELF_IMPROVING_LOOPS;
473
- }
474
- export async function promptCompileLoopSelection(options) {
475
- if (!options.hasChecks) {
476
- return {};
477
- }
478
- const currentMode = resolveCompileLoopMode(options.initialMaxAttempts, options.initialMaxLoops);
479
- const currentPromptMode = currentMode;
480
- const recommendedMode = options.recommendedMode ?? "once";
481
- const includeCompileOnce = options.includeCompileOnce !== false;
482
- const hasSavedPolicy = typeof options.initialMaxAttempts === "number" ||
483
- typeof options.initialMaxLoops === "number";
484
- for (const line of options.intro ?? []) {
485
- p.log.info(line);
486
- }
487
- p.log.info(`Current mode: ${describeCompileLoopSelection({
488
- maxAttempts: options.initialMaxAttempts,
489
- maxLoops: options.initialMaxLoops,
490
- })}`);
491
- const optionsByMode = {
492
- once: {
493
- value: "once",
494
- label: "Prepare once",
495
- hint: "Run the selected Method once and write Portable Context",
496
- },
497
- "self-improving": {
498
- value: "self-improving",
499
- label: recommendedMode === "self-improving"
500
- ? "Self-improving loops (Recommended)"
501
- : "Self-improving loops",
502
- hint: `Let Interf revise the Method and retry up to ${options.initialMaxLoops ?? DEFAULT_SELF_IMPROVING_LOOPS} time${(options.initialMaxLoops ?? DEFAULT_SELF_IMPROVING_LOOPS) === 1 ? "" : "s"}`,
503
- },
504
- retry: {
505
- value: "retry",
506
- label: "Retry same Method",
507
- hint: `Retry the same Method and readiness checks up to ${options.initialMaxAttempts ?? DEFAULT_COMPILE_RETRY_ATTEMPTS} total time${(options.initialMaxAttempts ?? DEFAULT_COMPILE_RETRY_ATTEMPTS) === 1 ? "" : "s"} without editing the Method`,
508
- },
509
- };
510
- const orderedModes = (hasSavedPolicy
511
- ? [
512
- currentPromptMode,
513
- ...(recommendedMode !== currentPromptMode ? [recommendedMode] : []),
514
- "retry",
515
- "once",
516
- ]
517
- : [
518
- recommendedMode,
519
- "retry",
520
- "once",
521
- ]).filter((mode, index, list) => list.indexOf(mode) === index)
522
- .filter((mode) => includeCompileOnce || mode !== "once");
523
- const selectedMode = await p.select({
524
- message: options.message ?? "How should this prepare run work?",
525
- options: orderedModes.map((mode) => optionsByMode[mode]),
526
- });
527
- if (p.isCancel(selectedMode))
528
- return null;
529
- if (selectedMode === "once") {
530
- return {};
531
- }
532
- if (selectedMode === "retry") {
533
- const maxAttempts = await promptCompileRetryAttempts({
534
- initialMaxAttempts: options.initialMaxAttempts ?? DEFAULT_COMPILE_RETRY_ATTEMPTS,
535
- message: "How many total attempts should Interf try before stopping?",
536
- });
537
- if (maxAttempts === null)
538
- return null;
539
- return {
540
- max_attempts: maxAttempts,
541
- };
542
- }
543
- const maxLoops = await promptSelfImprovingLoops({
544
- initialMaxLoops: options.initialMaxLoops ?? DEFAULT_SELF_IMPROVING_LOOPS,
545
- message: "How many Method revisions should Interf try?",
546
- });
547
- if (maxLoops === null)
548
- return null;
549
- return {
550
- max_attempts: DEFAULT_SELF_IMPROVING_ATTEMPTS,
551
- max_loops: maxLoops,
552
- };
553
- }
554
- export async function promptSingleCompiledConfig(options = {}) {
555
- const initial = options.initial;
556
- const introStyle = options.introStyle ?? "first";
557
- if (introStyle === "first") {
558
- if (options.fixedPath) {
559
- p.log.info("Describe the agent work this Preparation should help with and review the recommended readiness checks.");
560
- }
561
- else {
562
- p.log.info("Pick the Source Folder for this Preparation.");
563
- p.log.info("Then say what agent work this Preparation should help with and review the recommended readiness checks.");
564
- }
565
- }
566
- else if (introStyle === "additional") {
567
- p.log.info("Add another Preparation only if this Source Folder needs a separate folder, agent-work focus, or readiness-check set.");
568
- }
569
- const fixedName = options.fixedName ? slugify(String(options.fixedName)) : undefined;
570
- if (options.fixedName && !fixedName) {
571
- p.log.error("Current Preparation name needs letters, numbers, or dashes.");
572
- return null;
573
- }
574
- let name = fixedName;
575
- if (name && options.fixedName) {
576
- p.log.info(`Editing readiness checks for Preparation "${name}".`);
577
- }
578
- let about = normalizeOptionalPromptText(initial?.about);
579
- const projectPath = options.projectPath ?? process.cwd();
580
- const defaultNameSeed = slugify(String(initial?.name ?? DEFAULT_PREPARATION_NAME)) || DEFAULT_PREPARATION_NAME;
581
- const defaultSourceFolderPath = initial?.path ?? defaultSourceFolderPathForPrompt(defaultNameSeed, introStyle, projectPath);
582
- const normalizedSourceFolderPath = options.fixedPath
583
- ? (() => {
584
- try {
585
- return normalizeSourceFolderPathForConfig(projectPath, options.fixedPath);
586
- }
587
- catch (error) {
588
- p.log.error(error instanceof Error ? error.message : String(error));
589
- return null;
590
- }
591
- })()
592
- : await promptSourceFolderPath({
593
- projectPath,
594
- initialPath: defaultSourceFolderPath,
595
- });
596
- if (!normalizedSourceFolderPath)
597
- return null;
598
- if (options.fixedPath) {
599
- p.log.info(`Source Folder: ${normalizedSourceFolderPath}`);
600
- }
601
- if (!name) {
602
- const suggestedName = defaultPreparationNameForPath(normalizedSourceFolderPath);
603
- const nameField = createPreparationActionField("name");
604
- const rawName = await p.text({
605
- message: nameField.label,
606
- placeholder: nameField.placeholder ?? suggestedName,
607
- initialValue: suggestedName,
608
- validate: (value) => (value.trim().length === 0 ? "Preparation name is required" : undefined),
609
- });
610
- if (p.isCancel(rawName))
611
- return null;
612
- name = slugify(String(rawName));
613
- if (!name) {
614
- p.log.error("Preparation name needs letters, numbers, or dashes.");
615
- return null;
616
- }
617
- if (name !== rawName) {
618
- p.log.info(`Preparation name: ${name}`);
619
- }
620
- }
621
- let compileLoopSelection = {
622
- ...(typeof initial?.max_attempts === "number" ? { max_attempts: initial.max_attempts } : {}),
623
- ...(typeof initial?.max_loops === "number" ? { max_loops: initial.max_loops } : {}),
624
- };
625
- if (!(options.skipAboutPrompt && initial?.about)) {
626
- const aboutField = createPreparationActionField("about");
627
- const aboutInput = await p.text({
628
- message: preparationAboutPromptMessage(introStyle),
629
- placeholder: aboutField.placeholder,
630
- initialValue: about ?? "",
631
- });
632
- if (p.isCancel(aboutInput))
633
- return null;
634
- about = normalizeOptionalPromptText(aboutInput);
635
- }
636
- const checks = await promptCompiledChecks({
637
- projectPath: options.projectPath ?? process.cwd(),
638
- preparationName: name,
639
- sourceFolderPath: normalizedSourceFolderPath,
640
- initialAbout: about,
641
- initialChecks: initial?.checks,
642
- });
643
- if (checks === null)
644
- return null;
645
- if (introStyle === "edit") {
646
- compileLoopSelection = await promptCompileLoopSelection({
647
- initialMaxAttempts: initial?.max_attempts,
648
- initialMaxLoops: initial?.max_loops,
649
- hasChecks: checks.length > 0,
650
- intro: [
651
- "Prepare mode",
652
- "Choose whether Interf should prepare once, retry the same Method, or try self-improving Method variations against the same readiness checks.",
653
- ],
654
- });
655
- if (compileLoopSelection === null)
656
- return null;
657
- }
658
- return {
659
- name,
660
- path: normalizedSourceFolderPath,
661
- ...(about ? { about } : {}),
662
- ...(typeof compileLoopSelection.max_attempts === "number"
663
- ? { max_attempts: compileLoopSelection.max_attempts }
664
- : {}),
665
- ...(typeof compileLoopSelection.max_loops === "number"
666
- ? { max_loops: compileLoopSelection.max_loops }
667
- : {}),
668
- checks,
669
- };
670
- }
@@ -1,2 +0,0 @@
1
- import type { CommandModule } from "yargs";
2
- export declare const verifyCommand: CommandModule;