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