@sweny-ai/core 0.1.138 → 0.1.139
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.
- package/dist/cli/main.js +11 -14
- package/dist/cli/output.js +1 -1
- package/dist/cli/workflow-input.d.ts +13 -0
- package/dist/cli/workflow-input.js +18 -0
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -17,7 +17,7 @@ import { buildAutoMcpServers, buildSkillMcpServers, buildProviderContext } from
|
|
|
17
17
|
import { loadAdditionalContext } from "../templates.js";
|
|
18
18
|
import { loadAndValidateWorkflow } from "../loader.js";
|
|
19
19
|
import { validateRuntimeInput } from "../inputs.js";
|
|
20
|
-
import { mergeDryRunIntoInput, parseRunBudgetFlags } from "./workflow-input.js";
|
|
20
|
+
import { mergeDryRunIntoInput, parseInputFlag, parseRunBudgetFlags } from "./workflow-input.js";
|
|
21
21
|
import { stringify as stringifyYaml } from "yaml";
|
|
22
22
|
import { buildWorkflow, refineWorkflow } from "../workflow-builder.js";
|
|
23
23
|
import { toMermaidBlock } from "../mermaid.js";
|
|
@@ -74,7 +74,7 @@ loadDotenv();
|
|
|
74
74
|
applyAgentFileConfig(loadConfigFile());
|
|
75
75
|
const program = new Command()
|
|
76
76
|
.name("sweny")
|
|
77
|
-
.description("
|
|
77
|
+
.description("Workflows for coding agents. One set of rules, a receipt for every run.")
|
|
78
78
|
.version(version);
|
|
79
79
|
// ── sweny new ─────────────────────────────────────────────────────────
|
|
80
80
|
program
|
|
@@ -626,8 +626,7 @@ implementCmd.action(async (issueId, options) => {
|
|
|
626
626
|
process.exit(0);
|
|
627
627
|
}
|
|
628
628
|
catch (err) {
|
|
629
|
-
|
|
630
|
-
console.error(chalk.red(`\n Error: ${crashMsg}\n`));
|
|
629
|
+
console.error(formatCrashError(err));
|
|
631
630
|
// Finalize the cloud run as failed (covers thrown errors, incl.
|
|
632
631
|
// RouteEvaluationError). Without this a crashed implement run stays
|
|
633
632
|
// "running" in cloud forever.
|
|
@@ -804,15 +803,14 @@ export async function workflowRunAction(file, options) {
|
|
|
804
803
|
// Build workflow input — prefer --input JSON if provided, else fall back to config-derived input
|
|
805
804
|
let workflowInput;
|
|
806
805
|
if (options.input && typeof options.input === "string") {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
catch {
|
|
812
|
-
console.error(chalk.red(" --input must be valid JSON"));
|
|
806
|
+
const parsedInput = parseInputFlag(options.input);
|
|
807
|
+
if (!parsedInput.ok) {
|
|
808
|
+
for (const line of parsedInput.lines)
|
|
809
|
+
console.error(chalk.red(` ${line}`));
|
|
813
810
|
process.exit(1);
|
|
814
811
|
return;
|
|
815
812
|
}
|
|
813
|
+
const parsed = parsedInput.value;
|
|
816
814
|
// Validate against the workflow's declared `inputs` contract (when present).
|
|
817
815
|
// Workflows without an `inputs` block pass through unchanged.
|
|
818
816
|
const validated = validateRuntimeInput(workflow.inputs, parsed);
|
|
@@ -990,8 +988,7 @@ export async function workflowRunAction(file, options) {
|
|
|
990
988
|
process.exit(0);
|
|
991
989
|
}
|
|
992
990
|
catch (err) {
|
|
993
|
-
|
|
994
|
-
console.error(chalk.red(`\n Error: ${crashMsg}\n`));
|
|
991
|
+
console.error(formatCrashError(err));
|
|
995
992
|
runLogger.flush();
|
|
996
993
|
recordHistory(nodeTimer.lastResults, undefined, true);
|
|
997
994
|
console.error(` ${renderReceiptLine(summarizeRun(new Map(), Date.now() - runStart, true), isTTY)}\n`);
|
|
@@ -1149,7 +1146,7 @@ workflowCmd
|
|
|
1149
1146
|
}
|
|
1150
1147
|
}
|
|
1151
1148
|
catch (err) {
|
|
1152
|
-
console.error(
|
|
1149
|
+
console.error(formatCrashError(err));
|
|
1153
1150
|
process.exit(1);
|
|
1154
1151
|
}
|
|
1155
1152
|
});
|
|
@@ -1220,7 +1217,7 @@ workflowCmd
|
|
|
1220
1217
|
}
|
|
1221
1218
|
}
|
|
1222
1219
|
catch (err) {
|
|
1223
|
-
console.error(
|
|
1220
|
+
console.error(formatCrashError(err));
|
|
1224
1221
|
process.exit(1);
|
|
1225
1222
|
}
|
|
1226
1223
|
});
|
package/dist/cli/output.js
CHANGED
|
@@ -360,7 +360,7 @@ export function extractCredentialHint(err) {
|
|
|
360
360
|
}
|
|
361
361
|
// ── Crash error ─────────────────────────────────────────────────
|
|
362
362
|
export function formatCrashError(error) {
|
|
363
|
-
const msg = error instanceof Error ? error.message : "Unknown error";
|
|
363
|
+
const msg = error instanceof Error ? error.message : error == null ? "Unknown error" : String(error);
|
|
364
364
|
const title = `${c.fail("\u2717")} ${chalk.bold("Unexpected Error")}`;
|
|
365
365
|
const header = [title];
|
|
366
366
|
const hint = extractCredentialHint(error);
|
|
@@ -39,3 +39,16 @@ export declare function parseRunBudgetFlags(timeout: string | undefined, maxStep
|
|
|
39
39
|
timeoutMs: number;
|
|
40
40
|
maxSteps: number | undefined;
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Parse the `--input` flag (#339). The old catch printed only "--input must be
|
|
44
|
+
* valid JSON" and dropped the parser's reason, so a stray quote from shell
|
|
45
|
+
* escaping left the user guessing. Returns the parsed value, or the lines to
|
|
46
|
+
* print: the real parse error plus a valid-shape example.
|
|
47
|
+
*/
|
|
48
|
+
export declare function parseInputFlag(raw: string): {
|
|
49
|
+
ok: true;
|
|
50
|
+
value: unknown;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
lines: string[];
|
|
54
|
+
};
|
|
@@ -54,3 +54,21 @@ export function parseRunBudgetFlags(timeout, maxSteps, defaultTimeoutMs) {
|
|
|
54
54
|
maxSteps: maxSteps === undefined ? undefined : parse(maxSteps, "--max-steps", 1),
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Parse the `--input` flag (#339). The old catch printed only "--input must be
|
|
59
|
+
* valid JSON" and dropped the parser's reason, so a stray quote from shell
|
|
60
|
+
* escaping left the user guessing. Returns the parsed value, or the lines to
|
|
61
|
+
* print: the real parse error plus a valid-shape example.
|
|
62
|
+
*/
|
|
63
|
+
export function parseInputFlag(raw) {
|
|
64
|
+
try {
|
|
65
|
+
return { ok: true, value: JSON.parse(raw) };
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
lines: [`--input must be valid JSON: ${reason}`, `Example: --input '{"repository": "owner/repo", "limit": 5}'`],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|