opencastle 1.4.2 → 1.4.3

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 (51) hide show
  1. package/dist/cli/convoy/spec-types.d.ts +15 -0
  2. package/dist/cli/convoy/spec-types.d.ts.map +1 -1
  3. package/dist/cli/pipeline.d.ts.map +1 -1
  4. package/dist/cli/pipeline.flow.test.js +134 -27
  5. package/dist/cli/pipeline.flow.test.js.map +1 -1
  6. package/dist/cli/pipeline.js +113 -34
  7. package/dist/cli/pipeline.js.map +1 -1
  8. package/dist/cli/plan.d.ts +22 -0
  9. package/dist/cli/plan.d.ts.map +1 -1
  10. package/dist/cli/plan.js +43 -6
  11. package/dist/cli/plan.js.map +1 -1
  12. package/dist/cli/run/adapters/claude.d.ts +13 -0
  13. package/dist/cli/run/adapters/claude.d.ts.map +1 -1
  14. package/dist/cli/run/adapters/claude.js +30 -1
  15. package/dist/cli/run/adapters/claude.js.map +1 -1
  16. package/dist/cli/run/adapters/claude.test.js +34 -1
  17. package/dist/cli/run/adapters/claude.test.js.map +1 -1
  18. package/dist/cli/run/adapters/codex.d.ts.map +1 -1
  19. package/dist/cli/run/adapters/codex.js +4 -0
  20. package/dist/cli/run/adapters/codex.js.map +1 -1
  21. package/dist/cli/run/adapters/codex.test.js +8 -0
  22. package/dist/cli/run/adapters/codex.test.js.map +1 -1
  23. package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
  24. package/dist/cli/run/adapters/copilot.js +4 -1
  25. package/dist/cli/run/adapters/copilot.js.map +1 -1
  26. package/dist/cli/run/adapters/copilot.test.js +9 -0
  27. package/dist/cli/run/adapters/copilot.test.js.map +1 -1
  28. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +2 -0
  29. package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -1
  30. package/dist/cli/run/adapters/stub-cli.test-helper.js +16 -1
  31. package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -1
  32. package/dist/cli/run/platform.d.ts +12 -0
  33. package/dist/cli/run/platform.d.ts.map +1 -1
  34. package/dist/cli/run/platform.js +49 -0
  35. package/dist/cli/run/platform.js.map +1 -1
  36. package/dist/cli/run/platform.test.js +21 -1
  37. package/dist/cli/run/platform.test.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/cli/convoy/spec-types.ts +15 -0
  40. package/src/cli/pipeline.flow.test.ts +143 -28
  41. package/src/cli/pipeline.ts +141 -34
  42. package/src/cli/plan.ts +51 -6
  43. package/src/cli/run/adapters/claude.test.ts +39 -1
  44. package/src/cli/run/adapters/claude.ts +27 -1
  45. package/src/cli/run/adapters/codex.test.ts +9 -0
  46. package/src/cli/run/adapters/codex.ts +3 -0
  47. package/src/cli/run/adapters/copilot.test.ts +11 -0
  48. package/src/cli/run/adapters/copilot.ts +3 -1
  49. package/src/cli/run/adapters/stub-cli.test-helper.ts +16 -1
  50. package/src/cli/run/platform.test.ts +23 -1
  51. package/src/cli/run/platform.ts +50 -0
@@ -130,6 +130,56 @@ export function killTree(pid: number | undefined, graceMs = 5000): void {
130
130
  timer.unref()
131
131
  }
132
132
 
133
+ /** Help text by the resolved path of the command that printed it. */
134
+ const helpCache = new Map<string, Promise<string>>()
135
+
136
+ /**
137
+ * What `<command> --help` prints, read once per process.
138
+ *
139
+ * An agent CLI fails a whole session on a flag it does not know, and the flags
140
+ * that make a session faster arrive release by release. An adapter passes one
141
+ * only when the installed version lists it. Keyed by the path the command
142
+ * resolves to, so a different install on PATH is asked again. Empty when the
143
+ * command cannot be run or does not answer within `timeoutMs`.
144
+ */
145
+ export function helpText(command: string, timeoutMs = 10_000): Promise<string> {
146
+ const key = resolveCommand(command) ?? command
147
+ const known = helpCache.get(key)
148
+ if (known) return known
149
+ const asked = new Promise<string>((done) => {
150
+ let out = ''
151
+ let child: ChildProcess
152
+ try {
153
+ child = spawnCommand(command, ['--help'], { stdio: ['ignore', 'pipe', 'pipe'] })
154
+ } catch {
155
+ done('')
156
+ return
157
+ }
158
+ const timer = setTimeout(() => {
159
+ killTree(child.pid, 0)
160
+ done(out)
161
+ }, timeoutMs)
162
+ timer.unref()
163
+ child.stdout?.on('data', (d) => (out += String(d)))
164
+ child.stderr?.on('data', (d) => (out += String(d)))
165
+ child.on('error', () => {
166
+ clearTimeout(timer)
167
+ done('')
168
+ })
169
+ child.on('close', () => {
170
+ clearTimeout(timer)
171
+ done(out)
172
+ })
173
+ })
174
+ helpCache.set(key, asked)
175
+ return asked
176
+ }
177
+
178
+ /** Forget every help text read so far — for tests that swap a CLI. */
179
+ export function forgetHelpText(): void {
180
+ helpCache.clear()
181
+ }
182
+
133
183
  export interface ShellResult {
134
184
  code: number
135
185
  stdout: string