@illumiarq/lumis 1.2.8 → 1.2.10

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 (296) hide show
  1. package/README.md +38 -0
  2. package/dist/adapter-loader.d.ts +67 -0
  3. package/dist/adapter-loader.d.ts.map +1 -0
  4. package/dist/adapter-loader.js +273 -0
  5. package/dist/adapter-loader.js.map +1 -0
  6. package/dist/cli.d.ts +16 -1
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +173 -402
  9. package/dist/cli.js.map +1 -1
  10. package/dist/commands/commands.command.d.ts +38 -0
  11. package/dist/commands/commands.command.d.ts.map +1 -0
  12. package/dist/commands/commands.command.js +176 -0
  13. package/dist/commands/commands.command.js.map +1 -0
  14. package/dist/commands/doctor.command.d.ts +9 -0
  15. package/dist/commands/doctor.command.d.ts.map +1 -0
  16. package/dist/commands/doctor.command.js +922 -0
  17. package/dist/commands/doctor.command.js.map +1 -0
  18. package/dist/commands/init.command.d.ts +9 -0
  19. package/dist/commands/init.command.d.ts.map +1 -0
  20. package/dist/commands/init.command.js +135 -0
  21. package/dist/commands/init.command.js.map +1 -0
  22. package/dist/commands/intent.command.d.ts +26 -0
  23. package/dist/commands/intent.command.d.ts.map +1 -0
  24. package/dist/commands/intent.command.js +211 -0
  25. package/dist/commands/intent.command.js.map +1 -0
  26. package/dist/commands/ir-rebuild.command.d.ts +9 -0
  27. package/dist/commands/ir-rebuild.command.d.ts.map +1 -0
  28. package/dist/commands/ir-rebuild.command.js +36 -0
  29. package/dist/commands/ir-rebuild.command.js.map +1 -0
  30. package/dist/commands/ir-show.command.d.ts +9 -0
  31. package/dist/commands/ir-show.command.d.ts.map +1 -0
  32. package/dist/commands/ir-show.command.js +32 -0
  33. package/dist/commands/ir-show.command.js.map +1 -0
  34. package/dist/commands/make.command.d.ts +9 -0
  35. package/dist/commands/make.command.d.ts.map +1 -0
  36. package/dist/commands/make.command.js +93 -0
  37. package/dist/commands/make.command.js.map +1 -0
  38. package/dist/commands/pack.command.d.ts +16 -0
  39. package/dist/commands/pack.command.d.ts.map +1 -0
  40. package/dist/commands/pack.command.js +44 -0
  41. package/dist/commands/pack.command.js.map +1 -0
  42. package/dist/commands/runtime.command.d.ts +6 -0
  43. package/dist/commands/runtime.command.d.ts.map +1 -0
  44. package/dist/commands/runtime.command.js +379 -0
  45. package/dist/commands/runtime.command.js.map +1 -0
  46. package/dist/commands/runtime.d.ts +45 -0
  47. package/dist/commands/runtime.d.ts.map +1 -0
  48. package/dist/commands/runtime.js +66 -0
  49. package/dist/commands/runtime.js.map +1 -0
  50. package/dist/commands/tinker-agent-plan.d.ts +26 -0
  51. package/dist/commands/tinker-agent-plan.d.ts.map +1 -0
  52. package/dist/commands/tinker-agent-plan.js +115 -0
  53. package/dist/commands/tinker-agent-plan.js.map +1 -0
  54. package/dist/commands/tinker-chat-commands.d.ts +19 -0
  55. package/dist/commands/tinker-chat-commands.d.ts.map +1 -0
  56. package/dist/commands/tinker-chat-commands.js +263 -0
  57. package/dist/commands/tinker-chat-commands.js.map +1 -0
  58. package/dist/commands/tinker-chat-runtime.d.ts +30 -0
  59. package/dist/commands/tinker-chat-runtime.d.ts.map +1 -0
  60. package/dist/commands/tinker-chat-runtime.js +227 -0
  61. package/dist/commands/tinker-chat-runtime.js.map +1 -0
  62. package/dist/commands/tinker-classic-mode.d.ts +15 -0
  63. package/dist/commands/tinker-classic-mode.d.ts.map +1 -0
  64. package/dist/commands/tinker-classic-mode.js +160 -0
  65. package/dist/commands/tinker-classic-mode.js.map +1 -0
  66. package/dist/commands/tinker-eval.command.d.ts +3 -0
  67. package/dist/commands/tinker-eval.command.d.ts.map +1 -0
  68. package/dist/commands/tinker-eval.command.js +151 -0
  69. package/dist/commands/tinker-eval.command.js.map +1 -0
  70. package/dist/commands/tinker-repl-display.d.ts +15 -0
  71. package/dist/commands/tinker-repl-display.d.ts.map +1 -0
  72. package/dist/commands/tinker-repl-display.js +147 -0
  73. package/dist/commands/tinker-repl-display.js.map +1 -0
  74. package/dist/commands/tinker-session-runtime.d.ts +27 -0
  75. package/dist/commands/tinker-session-runtime.d.ts.map +1 -0
  76. package/dist/commands/tinker-session-runtime.js +196 -0
  77. package/dist/commands/tinker-session-runtime.js.map +1 -0
  78. package/dist/commands/tinker.command.d.ts +9 -0
  79. package/dist/commands/tinker.command.d.ts.map +1 -0
  80. package/dist/commands/tinker.command.js +142 -0
  81. package/dist/commands/tinker.command.js.map +1 -0
  82. package/dist/commands/use.command.d.ts +10 -0
  83. package/dist/commands/use.command.d.ts.map +1 -0
  84. package/dist/commands/use.command.js +69 -0
  85. package/dist/commands/use.command.js.map +1 -0
  86. package/dist/config-loader.d.ts +110 -0
  87. package/dist/config-loader.d.ts.map +1 -0
  88. package/dist/config-loader.js +119 -0
  89. package/dist/config-loader.js.map +1 -0
  90. package/dist/index.d.ts +19 -15
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +12 -12
  93. package/dist/index.js.map +1 -1
  94. package/dist/launcher.d.ts +16 -0
  95. package/dist/launcher.d.ts.map +1 -0
  96. package/dist/launcher.js +301 -0
  97. package/dist/launcher.js.map +1 -0
  98. package/dist/lib/file-scanner.d.ts +8 -0
  99. package/dist/lib/file-scanner.d.ts.map +1 -0
  100. package/dist/lib/file-scanner.js +70 -0
  101. package/dist/lib/file-scanner.js.map +1 -0
  102. package/dist/lib/tinker-memory.d.ts +19 -0
  103. package/dist/lib/tinker-memory.d.ts.map +1 -0
  104. package/dist/lib/tinker-memory.js +107 -0
  105. package/dist/lib/tinker-memory.js.map +1 -0
  106. package/dist/lib/tinker-observer.d.ts +47 -0
  107. package/dist/lib/tinker-observer.d.ts.map +1 -0
  108. package/dist/lib/tinker-observer.js +77 -0
  109. package/dist/lib/tinker-observer.js.map +1 -0
  110. package/dist/lib/tinker-policy.d.ts +21 -0
  111. package/dist/lib/tinker-policy.d.ts.map +1 -0
  112. package/dist/lib/tinker-policy.js +102 -0
  113. package/dist/lib/tinker-policy.js.map +1 -0
  114. package/dist/lib/tinker-replay.d.ts +51 -0
  115. package/dist/lib/tinker-replay.d.ts.map +1 -0
  116. package/dist/lib/tinker-replay.js +123 -0
  117. package/dist/lib/tinker-replay.js.map +1 -0
  118. package/dist/{console.d.ts → output/ansi.d.ts} +4 -8
  119. package/dist/output/ansi.d.ts.map +1 -0
  120. package/dist/{console.js → output/ansi.js} +4 -12
  121. package/dist/output/ansi.js.map +1 -0
  122. package/dist/output/plan-display.d.ts +4 -0
  123. package/dist/output/plan-display.d.ts.map +1 -0
  124. package/dist/output/plan-display.js +49 -0
  125. package/dist/output/plan-display.js.map +1 -0
  126. package/dist/output/result-display.d.ts +5 -0
  127. package/dist/output/result-display.d.ts.map +1 -0
  128. package/dist/output/result-display.js +17 -0
  129. package/dist/output/result-display.js.map +1 -0
  130. package/dist/plugins/tinker-plugin.d.ts +86 -0
  131. package/dist/plugins/tinker-plugin.d.ts.map +1 -0
  132. package/dist/plugins/tinker-plugin.js +42 -0
  133. package/dist/plugins/tinker-plugin.js.map +1 -0
  134. package/dist/router-preferences.d.ts +5 -0
  135. package/dist/router-preferences.d.ts.map +1 -0
  136. package/dist/router-preferences.js +22 -0
  137. package/dist/router-preferences.js.map +1 -0
  138. package/dist/runtime/executor.d.ts +33 -0
  139. package/dist/runtime/executor.d.ts.map +1 -0
  140. package/dist/runtime/executor.js +180 -0
  141. package/dist/runtime/executor.js.map +1 -0
  142. package/dist/runtime/orchestration.d.ts +43 -0
  143. package/dist/runtime/orchestration.d.ts.map +1 -0
  144. package/dist/runtime/orchestration.js +209 -0
  145. package/dist/runtime/orchestration.js.map +1 -0
  146. package/dist/runtime/policy.d.ts +49 -0
  147. package/dist/runtime/policy.d.ts.map +1 -0
  148. package/dist/runtime/policy.js +78 -0
  149. package/dist/runtime/policy.js.map +1 -0
  150. package/dist/runtime/profiles.d.ts +15 -0
  151. package/dist/runtime/profiles.d.ts.map +1 -0
  152. package/dist/runtime/profiles.js +131 -0
  153. package/dist/runtime/profiles.js.map +1 -0
  154. package/dist/runtime/transcripts.d.ts +59 -0
  155. package/dist/runtime/transcripts.d.ts.map +1 -0
  156. package/dist/runtime/transcripts.js +172 -0
  157. package/dist/runtime/transcripts.js.map +1 -0
  158. package/dist/tools/git-diff.d.ts +3 -0
  159. package/dist/tools/git-diff.d.ts.map +1 -0
  160. package/dist/tools/git-diff.js +16 -0
  161. package/dist/tools/git-diff.js.map +1 -0
  162. package/dist/tools/index.d.ts +24 -0
  163. package/dist/tools/index.d.ts.map +1 -0
  164. package/dist/tools/index.js +88 -0
  165. package/dist/tools/index.js.map +1 -0
  166. package/dist/tools/lint.d.ts +3 -0
  167. package/dist/tools/lint.d.ts.map +1 -0
  168. package/dist/tools/lint.js +35 -0
  169. package/dist/tools/lint.js.map +1 -0
  170. package/dist/tools/read-file.d.ts +3 -0
  171. package/dist/tools/read-file.d.ts.map +1 -0
  172. package/dist/tools/read-file.js +47 -0
  173. package/dist/tools/read-file.js.map +1 -0
  174. package/dist/tools/run-command.d.ts +3 -0
  175. package/dist/tools/run-command.d.ts.map +1 -0
  176. package/dist/tools/run-command.js +71 -0
  177. package/dist/tools/run-command.js.map +1 -0
  178. package/dist/tools/run-tests.d.ts +3 -0
  179. package/dist/tools/run-tests.d.ts.map +1 -0
  180. package/dist/tools/run-tests.js +49 -0
  181. package/dist/tools/run-tests.js.map +1 -0
  182. package/dist/tools/tool-dispatch.d.ts +32 -0
  183. package/dist/tools/tool-dispatch.d.ts.map +1 -0
  184. package/dist/tools/tool-dispatch.js +120 -0
  185. package/dist/tools/tool-dispatch.js.map +1 -0
  186. package/dist/tools/typecheck.d.ts +3 -0
  187. package/dist/tools/typecheck.d.ts.map +1 -0
  188. package/dist/tools/typecheck.js +48 -0
  189. package/dist/tools/typecheck.js.map +1 -0
  190. package/dist/tools/types.d.ts +62 -0
  191. package/dist/tools/types.d.ts.map +1 -0
  192. package/dist/tools/types.js +7 -0
  193. package/dist/tools/types.js.map +1 -0
  194. package/dist/tools/write-file.d.ts +15 -0
  195. package/dist/tools/write-file.d.ts.map +1 -0
  196. package/dist/tools/write-file.js +52 -0
  197. package/dist/tools/write-file.js.map +1 -0
  198. package/dist/tracing/types.d.ts +10 -0
  199. package/dist/tracing/types.d.ts.map +1 -0
  200. package/dist/tracing/types.js +2 -0
  201. package/dist/tracing/types.js.map +1 -0
  202. package/package.json +37 -19
  203. package/dist/bridges/project-bridge.d.ts +0 -2
  204. package/dist/bridges/project-bridge.d.ts.map +0 -1
  205. package/dist/bridges/project-bridge.js +0 -171
  206. package/dist/bridges/project-bridge.js.map +0 -1
  207. package/dist/commands/app/cache-workflows.d.ts +0 -7
  208. package/dist/commands/app/cache-workflows.d.ts.map +0 -1
  209. package/dist/commands/app/cache-workflows.js +0 -139
  210. package/dist/commands/app/cache-workflows.js.map +0 -1
  211. package/dist/commands/app/command-runtime.d.ts +0 -11
  212. package/dist/commands/app/command-runtime.d.ts.map +0 -1
  213. package/dist/commands/app/command-runtime.js +0 -41
  214. package/dist/commands/app/command-runtime.js.map +0 -1
  215. package/dist/commands/app/config-cache.d.ts +0 -3
  216. package/dist/commands/app/config-cache.d.ts.map +0 -1
  217. package/dist/commands/app/config-cache.js +0 -75
  218. package/dist/commands/app/config-cache.js.map +0 -1
  219. package/dist/commands/app/config-publish.d.ts +0 -2
  220. package/dist/commands/app/config-publish.d.ts.map +0 -1
  221. package/dist/commands/app/config-publish.js +0 -68
  222. package/dist/commands/app/config-publish.js.map +0 -1
  223. package/dist/commands/app/config-stubs.d.ts +0 -3
  224. package/dist/commands/app/config-stubs.d.ts.map +0 -1
  225. package/dist/commands/app/config-stubs.js +0 -154
  226. package/dist/commands/app/config-stubs.js.map +0 -1
  227. package/dist/commands/app/database.d.ts +0 -3
  228. package/dist/commands/app/database.d.ts.map +0 -1
  229. package/dist/commands/app/database.js +0 -221
  230. package/dist/commands/app/database.js.map +0 -1
  231. package/dist/commands/app/docs.d.ts +0 -7
  232. package/dist/commands/app/docs.d.ts.map +0 -1
  233. package/dist/commands/app/docs.js +0 -61
  234. package/dist/commands/app/docs.js.map +0 -1
  235. package/dist/commands/app/routes.d.ts +0 -5
  236. package/dist/commands/app/routes.d.ts.map +0 -1
  237. package/dist/commands/app/routes.js +0 -95
  238. package/dist/commands/app/routes.js.map +0 -1
  239. package/dist/commands/app/security.d.ts +0 -3
  240. package/dist/commands/app/security.d.ts.map +0 -1
  241. package/dist/commands/app/security.js +0 -15
  242. package/dist/commands/app/security.js.map +0 -1
  243. package/dist/commands/app/worker-schedule.d.ts +0 -5
  244. package/dist/commands/app/worker-schedule.d.ts.map +0 -1
  245. package/dist/commands/app/worker-schedule.js +0 -94
  246. package/dist/commands/app/worker-schedule.js.map +0 -1
  247. package/dist/commands/app-commands.d.ts +0 -19
  248. package/dist/commands/app-commands.d.ts.map +0 -1
  249. package/dist/commands/app-commands.js +0 -77
  250. package/dist/commands/app-commands.js.map +0 -1
  251. package/dist/commands/build-vercel-fn.d.ts +0 -9
  252. package/dist/commands/build-vercel-fn.d.ts.map +0 -1
  253. package/dist/commands/build-vercel-fn.js +0 -32
  254. package/dist/commands/build-vercel-fn.js.map +0 -1
  255. package/dist/commands/build.d.ts +0 -14
  256. package/dist/commands/build.d.ts.map +0 -1
  257. package/dist/commands/build.js +0 -24
  258. package/dist/commands/build.js.map +0 -1
  259. package/dist/commands/info.d.ts +0 -2
  260. package/dist/commands/info.d.ts.map +0 -1
  261. package/dist/commands/info.js +0 -25
  262. package/dist/commands/info.js.map +0 -1
  263. package/dist/commands/keys.d.ts +0 -3
  264. package/dist/commands/keys.d.ts.map +0 -1
  265. package/dist/commands/keys.js +0 -60
  266. package/dist/commands/keys.js.map +0 -1
  267. package/dist/commands/maintenance.d.ts +0 -9
  268. package/dist/commands/maintenance.d.ts.map +0 -1
  269. package/dist/commands/maintenance.js +0 -38
  270. package/dist/commands/maintenance.js.map +0 -1
  271. package/dist/commands/module-list.d.ts +0 -2
  272. package/dist/commands/module-list.d.ts.map +0 -1
  273. package/dist/commands/module-list.js +0 -27
  274. package/dist/commands/module-list.js.map +0 -1
  275. package/dist/commands/preview.d.ts +0 -14
  276. package/dist/commands/preview.d.ts.map +0 -1
  277. package/dist/commands/preview.js +0 -49
  278. package/dist/commands/preview.js.map +0 -1
  279. package/dist/commands/serve.d.ts +0 -16
  280. package/dist/commands/serve.d.ts.map +0 -1
  281. package/dist/commands/serve.js +0 -61
  282. package/dist/commands/serve.js.map +0 -1
  283. package/dist/console.d.ts.map +0 -1
  284. package/dist/console.js.map +0 -1
  285. package/dist/paths.d.ts +0 -21
  286. package/dist/paths.d.ts.map +0 -1
  287. package/dist/paths.js +0 -47
  288. package/dist/paths.js.map +0 -1
  289. package/dist/server-wrapper.d.ts +0 -12
  290. package/dist/server-wrapper.d.ts.map +0 -1
  291. package/dist/server-wrapper.js +0 -63
  292. package/dist/server-wrapper.js.map +0 -1
  293. package/dist/vercel-wrapper.d.ts +0 -6
  294. package/dist/vercel-wrapper.d.ts.map +0 -1
  295. package/dist/vercel-wrapper.js +0 -50
  296. package/dist/vercel-wrapper.js.map +0 -1
@@ -0,0 +1,78 @@
1
+ function isTruthy(value) {
2
+ if (!value) {
3
+ return false;
4
+ }
5
+ const normalized = value.trim().toLowerCase();
6
+ return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'y';
7
+ }
8
+ export function resolveRuntimePolicy(config) {
9
+ const mode = config.runtime?.policy?.mode ?? 'strict';
10
+ const requireApprovalForRemote = config.runtime?.policy?.requireApprovalForRemote !== false;
11
+ const approvalEnvVar = config.runtime?.policy?.approvalEnvVar ?? 'LUMIS_RUNTIME_APPROVED';
12
+ const commandAllowlist = config.runtime?.policy?.commandAllowlist ?? [];
13
+ return {
14
+ mode,
15
+ requireApprovalForRemote,
16
+ approvalEnvVar,
17
+ commandAllowlist,
18
+ };
19
+ }
20
+ /**
21
+ * Check whether `command` (the program name or full command string) is permitted
22
+ * by the allowlist in the resolved policy.
23
+ *
24
+ * Matching rules:
25
+ * - Empty allowlist → all commands allowed.
26
+ * - Exact entry (e.g. "pnpm") → matches when command starts with that token.
27
+ * - Glob prefix entry ending in " *" (e.g. "pnpm *") → matches when the full
28
+ * command string starts with the prefix before " *".
29
+ *
30
+ * In strict mode a mismatch returns `allowed: false`.
31
+ * In advisory mode a mismatch returns `allowed: true` with a warning.
32
+ */
33
+ export function enforceCommandBoundary(command, policy) {
34
+ if (policy.commandAllowlist.length === 0) {
35
+ return { allowed: true };
36
+ }
37
+ const matched = policy.commandAllowlist.some((entry) => {
38
+ if (entry.endsWith(' *')) {
39
+ const prefix = entry.slice(0, -2);
40
+ return command === prefix || command.startsWith(prefix + ' ');
41
+ }
42
+ return command === entry || command.startsWith(entry + ' ');
43
+ });
44
+ if (matched) {
45
+ return { allowed: true };
46
+ }
47
+ const reason = `Command "${command}" is not in the runtime policy allowlist. Permitted: ${policy.commandAllowlist.join(', ')}.`;
48
+ if (policy.mode === 'advisory') {
49
+ return { allowed: true, advisory: true, warningReason: reason };
50
+ }
51
+ return { allowed: false, advisory: false, blockingReason: reason };
52
+ }
53
+ export function evaluateRuntimePolicy(input) {
54
+ const policy = resolveRuntimePolicy(input.config);
55
+ const isRemoteProfile = input.profile.kind !== 'local';
56
+ const requiresApproval = isRemoteProfile && policy.requireApprovalForRemote;
57
+ const env = input.processEnv ?? process.env;
58
+ const approvedByEnv = isTruthy(env[policy.approvalEnvVar]);
59
+ const approvedByFlag = input.approveRemote === true;
60
+ const approved = !requiresApproval || approvedByEnv || approvedByFlag;
61
+ if (!approved) {
62
+ return {
63
+ mode: policy.mode,
64
+ requiresApproval,
65
+ approved,
66
+ allowExecution: false,
67
+ blockingReason: `Runtime profile ${input.profile.id} (${input.profile.kind}) requires explicit approval. ` +
68
+ `Set ${policy.approvalEnvVar}=true or pass --approve-remote.`,
69
+ };
70
+ }
71
+ return {
72
+ mode: policy.mode,
73
+ requiresApproval,
74
+ approved,
75
+ allowExecution: true,
76
+ };
77
+ }
78
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +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AAC,gBAAgB,IAAI,aAAa,IAAI,cAAc,CAAA;IAErE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,OAAO;YACN,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,gBAAgB;YAChB,QAAQ;YACR,cAAc,EAAE,KAAK;YACrB,cAAc,EACb,mBAAmB,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,CAAC,IAAI,gCAAgC;gBAC1F,OAAO,MAAM,CAAC,cAAc,iCAAiC;SAC9D,CAAA;IACF,CAAC;IAED,OAAO;QACN,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,gBAAgB;QAChB,QAAQ;QACR,cAAc,EAAE,IAAI;KACpB,CAAA;AACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { RuntimeProfile, RuntimeProfileStore } from '@lumiarq/context';
2
+ export type RuntimeProfileValidationResult = {
3
+ ok: true;
4
+ value: RuntimeProfileStore;
5
+ } | {
6
+ ok: false;
7
+ errors: string[];
8
+ };
9
+ export declare function validateRuntimeProfileStore(input: unknown): RuntimeProfileValidationResult;
10
+ export declare function createDefaultRuntimeProfileStore(projectRoot: string): RuntimeProfileStore;
11
+ export declare function loadRuntimeProfileStore(projectRoot: string): RuntimeProfileStore;
12
+ export declare function saveRuntimeProfileStore(projectRoot: string, store: RuntimeProfileStore): void;
13
+ export declare function getRuntimeProfile(store: RuntimeProfileStore, profileId?: string): RuntimeProfile | null;
14
+ export declare function redactRuntimeProfileForLogs(profile: RuntimeProfile): RuntimeProfile;
15
+ //# sourceMappingURL=profiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../../src/runtime/profiles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EAEpB,MAAM,kBAAkB,CAAA;AAIzB,MAAM,MAAM,8BAA8B,GACtC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,GACxC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAiDnC,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,8BAA8B,CAkC1F;AAED,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,GAAG,mBAAmB,CAazF;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,mBAAmB,CAoBhF;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAI7F;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAMvG;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAWnF"}
@@ -0,0 +1,131 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ const PROFILE_STORE_RELATIVE_PATH = path.join('.lumis', 'runtime-profiles.json');
4
+ function isObject(value) {
5
+ return typeof value === 'object' && value !== null;
6
+ }
7
+ function asString(value) {
8
+ return typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;
9
+ }
10
+ function validateProfile(profile, index) {
11
+ if (!isObject(profile)) {
12
+ return [`profiles[${index}] must be an object`];
13
+ }
14
+ const id = asString(profile.id);
15
+ const name = asString(profile.name);
16
+ const kind = asString(profile.kind);
17
+ const errors = [];
18
+ if (!id)
19
+ errors.push(`profiles[${index}].id must be a non-empty string`);
20
+ if (!name)
21
+ errors.push(`profiles[${index}].name must be a non-empty string`);
22
+ if (!kind)
23
+ errors.push(`profiles[${index}].kind must be a non-empty string`);
24
+ if (kind === 'ssh') {
25
+ if (!asString(profile.host)) {
26
+ errors.push(`profiles[${index}].host is required for ssh profile`);
27
+ }
28
+ if (!asString(profile.user)) {
29
+ errors.push(`profiles[${index}].user is required for ssh profile`);
30
+ }
31
+ }
32
+ if (kind === 'container') {
33
+ if (!asString(profile.image)) {
34
+ errors.push(`profiles[${index}].image is required for container profile`);
35
+ }
36
+ if (!asString(profile.workspacePath)) {
37
+ errors.push(`profiles[${index}].workspacePath is required for container profile`);
38
+ }
39
+ }
40
+ if (kind === 'ci' && !asString(profile.provider)) {
41
+ errors.push(`profiles[${index}].provider is required for ci profile`);
42
+ }
43
+ return errors;
44
+ }
45
+ export function validateRuntimeProfileStore(input) {
46
+ if (!isObject(input)) {
47
+ return { ok: false, errors: ['profile store must be an object'] };
48
+ }
49
+ const version = asString(input.version);
50
+ const profiles = input.profiles;
51
+ const defaultProfileId = input.defaultProfileId;
52
+ const errors = [];
53
+ if (version !== '1.0') {
54
+ errors.push('profile store version must be "1.0"');
55
+ }
56
+ if (!Array.isArray(profiles)) {
57
+ errors.push('profiles must be an array');
58
+ }
59
+ else {
60
+ for (let index = 0; index < profiles.length; index += 1) {
61
+ errors.push(...validateProfile(profiles[index], index));
62
+ }
63
+ }
64
+ if (defaultProfileId !== undefined && asString(defaultProfileId) === null) {
65
+ errors.push('defaultProfileId must be a non-empty string when provided');
66
+ }
67
+ if (errors.length > 0) {
68
+ return { ok: false, errors };
69
+ }
70
+ return {
71
+ ok: true,
72
+ value: input,
73
+ };
74
+ }
75
+ export function createDefaultRuntimeProfileStore(projectRoot) {
76
+ return {
77
+ version: '1.0',
78
+ defaultProfileId: 'local',
79
+ profiles: [
80
+ {
81
+ id: 'local',
82
+ name: 'Local shell',
83
+ kind: 'local',
84
+ workingDirectory: projectRoot,
85
+ },
86
+ ],
87
+ };
88
+ }
89
+ export function loadRuntimeProfileStore(projectRoot) {
90
+ const storePath = path.join(projectRoot, PROFILE_STORE_RELATIVE_PATH);
91
+ if (!fs.existsSync(storePath)) {
92
+ return createDefaultRuntimeProfileStore(projectRoot);
93
+ }
94
+ const raw = fs.readFileSync(storePath, 'utf8');
95
+ let parsed;
96
+ try {
97
+ parsed = JSON.parse(raw);
98
+ }
99
+ catch {
100
+ return createDefaultRuntimeProfileStore(projectRoot);
101
+ }
102
+ const validated = validateRuntimeProfileStore(parsed);
103
+ if (!validated.ok) {
104
+ return createDefaultRuntimeProfileStore(projectRoot);
105
+ }
106
+ return validated.value;
107
+ }
108
+ export function saveRuntimeProfileStore(projectRoot, store) {
109
+ const storePath = path.join(projectRoot, PROFILE_STORE_RELATIVE_PATH);
110
+ fs.mkdirSync(path.dirname(storePath), { recursive: true });
111
+ fs.writeFileSync(storePath, JSON.stringify(store, null, 2), 'utf8');
112
+ }
113
+ export function getRuntimeProfile(store, profileId) {
114
+ const id = profileId ?? store.defaultProfileId;
115
+ if (!id) {
116
+ return null;
117
+ }
118
+ return store.profiles.find((profile) => profile.id === id) ?? null;
119
+ }
120
+ export function redactRuntimeProfileForLogs(profile) {
121
+ if (profile.kind !== 'ssh') {
122
+ return profile;
123
+ }
124
+ const sshProfile = profile;
125
+ return {
126
+ ...sshProfile,
127
+ ...(sshProfile.privateKeyEnvVar ? { privateKeyEnvVar: '[REDACTED_ENV_VAR]' } : {}),
128
+ ...(sshProfile.passwordEnvVar ? { passwordEnvVar: '[REDACTED_ENV_VAR]' } : {}),
129
+ };
130
+ }
131
+ //# sourceMappingURL=profiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/runtime/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAQ5B,MAAM,2BAA2B,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAA;AAMhF,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAA;AACpD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,E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,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC/E,CAAA;AACH,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { RuntimeExecutionResult } from './executor.js';
2
+ export type PersistedRuntimeTranscript = {
3
+ version: '1.0';
4
+ createdAt: string;
5
+ command: string;
6
+ args: string[];
7
+ profileId: string;
8
+ profileKind: RuntimeExecutionResult['profileKind'];
9
+ success: boolean;
10
+ exitCode: number | null;
11
+ durationMs: number;
12
+ diagnostics: string[];
13
+ stdout: string;
14
+ stderr: string;
15
+ transcript: RuntimeExecutionResult['transcript'];
16
+ redactedProfile: RuntimeExecutionResult['redactedProfile'];
17
+ };
18
+ export type RuntimeTranscriptIndexEntry = {
19
+ id: string;
20
+ createdAt: string;
21
+ label: string;
22
+ profileId: string;
23
+ profileKind: RuntimeExecutionResult['profileKind'];
24
+ transcriptFile: string;
25
+ success: boolean;
26
+ exitCode: number | null;
27
+ durationMs: number;
28
+ };
29
+ export type RuntimeTranscriptIndex = {
30
+ version: '1.0';
31
+ updatedAt: string;
32
+ entries: RuntimeTranscriptIndexEntry[];
33
+ };
34
+ export type RuntimeTranscriptSummary = {
35
+ total: number;
36
+ successful: number;
37
+ failed: number;
38
+ latestEntry: RuntimeTranscriptIndexEntry | null;
39
+ };
40
+ export type PruneRuntimeTranscriptsOptions = {
41
+ keep?: number;
42
+ maxAgeDays?: number;
43
+ profileId?: string;
44
+ label?: string;
45
+ dryRun?: boolean;
46
+ };
47
+ export type PruneRuntimeTranscriptsResult = {
48
+ removedEntries: RuntimeTranscriptIndexEntry[];
49
+ keptEntries: RuntimeTranscriptIndexEntry[];
50
+ missingFilesRemoved: number;
51
+ indexPath: string;
52
+ };
53
+ export declare function persistRuntimeTranscript(projectRoot: string, label: string, result: RuntimeExecutionResult): string;
54
+ export declare function loadRuntimeTranscriptIndex(projectRoot: string): RuntimeTranscriptIndex;
55
+ export declare function saveRuntimeTranscriptIndex(projectRoot: string, index: RuntimeTranscriptIndex): void;
56
+ export declare function appendRuntimeTranscriptIndex(projectRoot: string, entry: RuntimeTranscriptIndexEntry): void;
57
+ export declare function summarizeRuntimeTranscripts(index: RuntimeTranscriptIndex): RuntimeTranscriptSummary;
58
+ export declare function pruneRuntimeTranscripts(projectRoot: string, options?: PruneRuntimeTranscriptsOptions): PruneRuntimeTranscriptsResult;
59
+ //# sourceMappingURL=transcripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcripts.d.ts","sourceRoot":"","sources":["../../src/runtime/transcripts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAE3D,MAAM,MAAM,0BAA0B,GAAG;IACxC,OAAO,EAAE,KAAK,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAA;IAClD,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAA;IAChD,eAAe,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,CAAA;CAC1D,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACzC,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,sBAAsB,CAAC,aAAa,CAAC,CAAA;IAClD,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,E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,EAAE,sBAAsB,GAAG,wBAAwB,CAUnG;AAsBD,wBAAgB,uBAAuB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,8BAAmC,GAC1C,6BAA6B,CAyD/B"}
@@ -0,0 +1,172 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ const TRANSCRIPTS_RELATIVE_DIR = path.join('.lumis', 'transcripts');
4
+ const TRANSCRIPT_INDEX_FILE = 'index.json';
5
+ function getTranscriptPaths(projectRoot) {
6
+ const dir = path.join(projectRoot, TRANSCRIPTS_RELATIVE_DIR);
7
+ return {
8
+ dir,
9
+ indexPath: path.join(dir, TRANSCRIPT_INDEX_FILE),
10
+ };
11
+ }
12
+ function sanitizeFileToken(token) {
13
+ return token.replace(/[^a-zA-Z0-9_-]/g, '-').slice(0, 40);
14
+ }
15
+ export function persistRuntimeTranscript(projectRoot, label, result) {
16
+ const transcriptsDir = path.join(projectRoot, TRANSCRIPTS_RELATIVE_DIR);
17
+ fs.mkdirSync(transcriptsDir, { recursive: true });
18
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
19
+ const fileName = `${timestamp}-${sanitizeFileToken(label)}-${sanitizeFileToken(result.profileId)}.json`;
20
+ const filePath = path.join(transcriptsDir, fileName);
21
+ const payload = {
22
+ version: '1.0',
23
+ createdAt: new Date().toISOString(),
24
+ command: result.command,
25
+ args: result.args,
26
+ profileId: result.profileId,
27
+ profileKind: result.profileKind,
28
+ success: result.success,
29
+ exitCode: result.exitCode,
30
+ durationMs: result.durationMs,
31
+ diagnostics: result.diagnostics,
32
+ stdout: result.stdout,
33
+ stderr: result.stderr,
34
+ transcript: result.transcript,
35
+ redactedProfile: result.redactedProfile,
36
+ };
37
+ fs.writeFileSync(filePath, JSON.stringify(payload, null, 2), 'utf8');
38
+ appendRuntimeTranscriptIndex(projectRoot, {
39
+ id: `${Date.now()}-${Math.random().toString(16).slice(2, 10)}`,
40
+ createdAt: payload.createdAt,
41
+ label,
42
+ profileId: payload.profileId,
43
+ profileKind: payload.profileKind,
44
+ transcriptFile: path.relative(projectRoot, filePath).replaceAll('\\', '/'),
45
+ success: payload.success,
46
+ exitCode: payload.exitCode,
47
+ durationMs: payload.durationMs,
48
+ });
49
+ return filePath;
50
+ }
51
+ export function loadRuntimeTranscriptIndex(projectRoot) {
52
+ const { indexPath } = getTranscriptPaths(projectRoot);
53
+ if (!fs.existsSync(indexPath)) {
54
+ return {
55
+ version: '1.0',
56
+ updatedAt: new Date().toISOString(),
57
+ entries: [],
58
+ };
59
+ }
60
+ try {
61
+ const raw = fs.readFileSync(indexPath, 'utf8');
62
+ const parsed = JSON.parse(raw);
63
+ if (parsed.version !== '1.0' || !Array.isArray(parsed.entries)) {
64
+ return {
65
+ version: '1.0',
66
+ updatedAt: new Date().toISOString(),
67
+ entries: [],
68
+ };
69
+ }
70
+ return parsed;
71
+ }
72
+ catch {
73
+ return {
74
+ version: '1.0',
75
+ updatedAt: new Date().toISOString(),
76
+ entries: [],
77
+ };
78
+ }
79
+ }
80
+ export function saveRuntimeTranscriptIndex(projectRoot, index) {
81
+ const { dir: transcriptsDir, indexPath } = getTranscriptPaths(projectRoot);
82
+ fs.mkdirSync(transcriptsDir, { recursive: true });
83
+ fs.writeFileSync(indexPath, JSON.stringify(index, null, 2), 'utf8');
84
+ }
85
+ export function appendRuntimeTranscriptIndex(projectRoot, entry) {
86
+ const index = loadRuntimeTranscriptIndex(projectRoot);
87
+ index.entries.unshift(entry);
88
+ index.updatedAt = new Date().toISOString();
89
+ if (index.entries.length > 200) {
90
+ index.entries = index.entries.slice(0, 200);
91
+ }
92
+ saveRuntimeTranscriptIndex(projectRoot, index);
93
+ }
94
+ export function summarizeRuntimeTranscripts(index) {
95
+ const successful = index.entries.filter((entry) => entry.success).length;
96
+ const failed = index.entries.length - successful;
97
+ return {
98
+ total: index.entries.length,
99
+ successful,
100
+ failed,
101
+ latestEntry: index.entries[0] ?? null,
102
+ };
103
+ }
104
+ function shouldKeepEntry(entry, options, nowMs) {
105
+ if (options.profileId && entry.profileId !== options.profileId) {
106
+ return true;
107
+ }
108
+ if (options.label && !entry.label.startsWith(options.label)) {
109
+ return true;
110
+ }
111
+ if (options.maxAgeDays !== undefined) {
112
+ const createdAtMs = Date.parse(entry.createdAt);
113
+ const maxAgeMs = options.maxAgeDays * 24 * 60 * 60 * 1000;
114
+ if (!Number.isNaN(createdAtMs) && nowMs - createdAtMs <= maxAgeMs) {
115
+ return true;
116
+ }
117
+ }
118
+ return false;
119
+ }
120
+ export function pruneRuntimeTranscripts(projectRoot, options = {}) {
121
+ const index = loadRuntimeTranscriptIndex(projectRoot);
122
+ const { indexPath } = getTranscriptPaths(projectRoot);
123
+ const nowMs = Date.now();
124
+ const keepCount = options.keep ?? 20;
125
+ const filtered = index.entries.filter((entry) => {
126
+ if (options.profileId && entry.profileId !== options.profileId) {
127
+ return false;
128
+ }
129
+ if (options.label && !entry.label.startsWith(options.label)) {
130
+ return false;
131
+ }
132
+ return true;
133
+ });
134
+ const guaranteedKeepIds = new Set(filtered.slice(0, keepCount).map((entry) => entry.id));
135
+ const removedEntries = [];
136
+ const keptEntries = [];
137
+ let missingFilesRemoved = 0;
138
+ for (const entry of index.entries) {
139
+ const transcriptPath = path.join(projectRoot, entry.transcriptFile);
140
+ const fileExists = fs.existsSync(transcriptPath);
141
+ const matchesFilter = filtered.some((candidate) => candidate.id === entry.id);
142
+ const keepBecauseRecent = guaranteedKeepIds.has(entry.id);
143
+ const keepBecausePolicy = matchesFilter ? shouldKeepEntry(entry, options, nowMs) : true;
144
+ if (keepBecauseRecent || keepBecausePolicy) {
145
+ keptEntries.push(entry);
146
+ continue;
147
+ }
148
+ removedEntries.push(entry);
149
+ if (!options.dryRun) {
150
+ if (fileExists) {
151
+ fs.rmSync(transcriptPath, { force: true });
152
+ }
153
+ else {
154
+ missingFilesRemoved += 1;
155
+ }
156
+ }
157
+ }
158
+ if (!options.dryRun) {
159
+ saveRuntimeTranscriptIndex(projectRoot, {
160
+ version: '1.0',
161
+ updatedAt: new Date().toISOString(),
162
+ entries: keptEntries,
163
+ });
164
+ }
165
+ return {
166
+ removedEntries,
167
+ keptEntries,
168
+ missingFilesRemoved,
169
+ indexPath,
170
+ };
171
+ }
172
+ //# sourceMappingURL=transcripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transcripts.js","sourceRoot":"","sources":["../../src/runtime/transcripts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AA6D5B,MAAM,wBAAwB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;AACnE,MAAM,qBAAqB,GAAG,YAAY,CAAA;AAE1C,SAAS,kBAAkB,CAAC,WAAmB;IAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAA;IAC5D,OAAO;QACN,GAAG;QACH,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,qBAAqB,CAAC;KAChD,CAAA;AACF,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC1D,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,WAAmB,EAAE,KAAa,EAAE,MAA8B;IAC1G,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAA;IACvE,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAEjD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAChE,MAAM,QAAQ,GAAG,GAAG,SAAS,IAAI,iBAAiB,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,EAAE,CAAC;gBAChB,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;YAC3C,CAAC;iBAAM,CAAC;gBACP,mBAAmB,IAAI,CAAC,CAAA;YACzB,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACrB,0BAA0B,CAAC,WAAW,EAAE;YACvC,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,OAAO,EAAE,WAAW;SACpB,CAAC,CAAA;IACH,CAAC;IAED,OAAO;QACN,cAAc;QACd,WAAW;QACX,mBAAmB;QACnB,SAAS;KACT,CAAA;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ToolResult } from './types.js';
2
+ export declare function gitDiffTool(projectRoot: string, base?: string, filePath?: string): Promise<ToolResult>;
3
+ //# sourceMappingURL=git-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-diff.d.ts","sourceRoot":"","sources":["../../src/tools/git-diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAa5G"}
@@ -0,0 +1,16 @@
1
+ import { runCommandTool } from './run-command.js';
2
+ export async function gitDiffTool(projectRoot, base, filePath) {
3
+ const cmd = ['git', 'diff'];
4
+ if (base)
5
+ cmd.push(base);
6
+ if (filePath)
7
+ cmd.push('--', filePath);
8
+ const result = await runCommandTool(cmd, projectRoot, 15_000);
9
+ const trimmed = result.output.trim();
10
+ return {
11
+ ...result,
12
+ tool: 'git-diff',
13
+ output: trimmed.length === 0 ? '(no changes)' : trimmed,
14
+ };
15
+ }
16
+ //# sourceMappingURL=git-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-diff.js","sourceRoot":"","sources":["../../src/tools/git-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB,EAAE,IAAa,EAAE,QAAiB;IACtF,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC3B,IAAI,IAAI;QAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,QAAQ;QAAE,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAEtC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;IAE7D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;IACpC,OAAO;QACN,GAAG,MAAM;QACT,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO;KACvD,CAAA;AACF,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { ToolResult } from './types.js';
2
+ import { type WriteRecord } from './write-file.js';
3
+ import type { ToolCall } from './types.js';
4
+ export type { ToolCall, ToolResult, Diagnostic, DiagnosticSeverity, ToolOutcome, ToolCallType } from './types.js';
5
+ export { rollbackLastWrite, type WriteRecord } from './write-file.js';
6
+ export type VerificationGateLevel = 'strict' | 'standard' | 'off';
7
+ export type VerificationReport = {
8
+ passed: boolean;
9
+ typecheckOutcome?: 'pass' | 'fail' | 'skipped';
10
+ testOutcome?: 'pass' | 'fail' | 'skipped';
11
+ errorCount: number;
12
+ warningCount: number;
13
+ summary: string;
14
+ results: ToolResult[];
15
+ };
16
+ /**
17
+ * Run all verification gates (typecheck + tests) and return a structured report.
18
+ */
19
+ export declare function runVerificationGates(projectRoot: string, gateLevel?: VerificationGateLevel, testPattern?: string): Promise<VerificationReport>;
20
+ /**
21
+ * Execute a single ToolCall and return its ToolResult.
22
+ */
23
+ export declare function executeToolCall(call: ToolCall, projectRoot: string, writeLog: WriteRecord[]): Promise<ToolResult>;
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACjH,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAA;AAEjE,MAAM,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE,OAAO,CAAA;IACf,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IAC9C,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;IACzC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,UAAU,EAAE,CAAA;CACrB,CAAA;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACzC,WAAW,EAAE,MAAM,EACnB,SAAS,GAAE,qBAAkC,EAC7C,WAAW,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACpC,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,WAAW,EAAE,GACrB,OAAO,CAAC,UAAU,CAAC,CA+BrB"}
@@ -0,0 +1,88 @@
1
+ import { readFileTool } from './read-file.js';
2
+ import { writeFileTool } from './write-file.js';
3
+ import { runCommandTool } from './run-command.js';
4
+ import { typecheckTool } from './typecheck.js';
5
+ import { runTestsTool } from './run-tests.js';
6
+ import { lintTool } from './lint.js';
7
+ import { gitDiffTool } from './git-diff.js';
8
+ export { rollbackLastWrite } from './write-file.js';
9
+ /**
10
+ * Run all verification gates (typecheck + tests) and return a structured report.
11
+ */
12
+ export async function runVerificationGates(projectRoot, gateLevel = 'standard', testPattern) {
13
+ if (gateLevel === 'off') {
14
+ return {
15
+ passed: true,
16
+ typecheckOutcome: 'skipped',
17
+ testOutcome: 'skipped',
18
+ errorCount: 0,
19
+ warningCount: 0,
20
+ summary: 'Verification gates disabled.',
21
+ results: [],
22
+ };
23
+ }
24
+ const results = [];
25
+ const tcResult = await typecheckTool(projectRoot);
26
+ results.push(tcResult);
27
+ const testResult = await runTestsTool(projectRoot, testPattern);
28
+ results.push(testResult);
29
+ const allDiagnostics = results.flatMap((r) => r.diagnostics ?? []);
30
+ const errorCount = allDiagnostics.filter((d) => d.severity === 'error').length;
31
+ const warningCount = allDiagnostics.filter((d) => d.severity === 'warning').length;
32
+ const typecheckOutcome = tcResult.outcome === 'success' ? 'pass' : 'fail';
33
+ const testOutcome = testResult.outcome === 'success' ? 'pass' : 'fail';
34
+ const failedGates = [];
35
+ if (typecheckOutcome === 'fail')
36
+ failedGates.push('typecheck');
37
+ if (testOutcome === 'fail')
38
+ failedGates.push('tests');
39
+ const shouldFailOnWarnings = gateLevel === 'strict' && warningCount > 0;
40
+ const passed = failedGates.length === 0 && !shouldFailOnWarnings;
41
+ const summaryParts = [];
42
+ summaryParts.push(`Typecheck: ${typecheckOutcome}`);
43
+ summaryParts.push(`Tests: ${testOutcome}`);
44
+ if (errorCount > 0)
45
+ summaryParts.push(`${errorCount} error(s)`);
46
+ if (warningCount > 0)
47
+ summaryParts.push(`${warningCount} warning(s)`);
48
+ if (!passed)
49
+ summaryParts.push(`FAILED: ${failedGates.join(', ')}${shouldFailOnWarnings ? ', warnings (strict mode)' : ''}`);
50
+ return {
51
+ passed,
52
+ typecheckOutcome,
53
+ testOutcome,
54
+ errorCount,
55
+ warningCount,
56
+ summary: summaryParts.join(' | '),
57
+ results,
58
+ };
59
+ }
60
+ /**
61
+ * Execute a single ToolCall and return its ToolResult.
62
+ */
63
+ export async function executeToolCall(call, projectRoot, writeLog) {
64
+ switch (call.tool) {
65
+ case 'read-file':
66
+ return readFileTool(call.path, projectRoot);
67
+ case 'write-file':
68
+ return writeFileTool(call.path, call.content, projectRoot, writeLog);
69
+ case 'run-command':
70
+ return runCommandTool(call.cmd, call.cwd ?? projectRoot, call.timeoutMs);
71
+ case 'typecheck':
72
+ return typecheckTool(call.cwd ?? projectRoot);
73
+ case 'run-tests':
74
+ return runTestsTool(call.cwd ?? projectRoot, call.pattern);
75
+ case 'lint':
76
+ return lintTool(call.cwd ?? projectRoot, call.paths, call.fix);
77
+ case 'git-diff':
78
+ return gitDiffTool(projectRoot, call.base, call.path);
79
+ case 'search-repo': {
80
+ // Lightweight text grep — wraps ripgrep/grep; full RAG search is handled at chat layer
81
+ const cmd = call.fileGlob
82
+ ? ['grep', '-rn', '--include', call.fileGlob, '-m', String(call.maxResults ?? 20), call.query, '.']
83
+ : ['grep', '-rn', '-m', String(call.maxResults ?? 20), call.query, '.'];
84
+ return runCommandTool(cmd, projectRoot, 15_000);
85
+ }
86
+ }
87
+ }
88
+ //# sourceMappingURL=index.js.map