@miphamai/cli 0.16.0 → 0.16.1

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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Template literal tag that strips leading indentation from multi-line strings.
3
+ * Used by slash command handlers to format help text and status messages.
4
+ */
5
+ export function stripIndent(strings: TemplateStringsArray, ...values: unknown[]): string {
6
+ let result = strings.reduce((acc, s, i) => acc + s + (values[i] ?? ''), '')
7
+ // Remove leading newline
8
+ result = result.replace(/^\n/, '')
9
+ // Find minimum indent
10
+ const match = result.match(/^( +)/m)
11
+ if (match?.[1]) {
12
+ const indent = match[1].length
13
+ result = result
14
+ .split('\n')
15
+ .map((line) => line.slice(indent))
16
+ .join('\n')
17
+ }
18
+ return result.trim()
19
+ }
@@ -157,7 +157,17 @@ export async function runWorkflow(
157
157
  sandboxCtx.phase = wrappedPhase
158
158
  sandboxCtx.log = log
159
159
 
160
- const result = await vmScript.runInContext(sandboxCtx, { timeout: 120_000 })
160
+ let result: unknown
161
+ try {
162
+ result = await vmScript.runInContext(sandboxCtx, { timeout: 120_000 })
163
+ } catch (err) {
164
+ const message = err instanceof Error ? err.message : String(err)
165
+ throw new Error(
166
+ `Workflow script execution failed: ${message}\n\n` +
167
+ `This is likely a bug in the workflow script, not in Mipham Code itself. ` +
168
+ `Check the script for syntax errors, undefined references, or unhandled promise rejections.`,
169
+ )
170
+ }
161
171
 
162
172
  // Count journal entries from state
163
173
  const priorEntries = loadJournal(runId)