@sweny-ai/core 0.1.64 → 0.1.65

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 (2) hide show
  1. package/dist/cli/main.js +28 -2
  2. package/package.json +1 -1
package/dist/cli/main.js CHANGED
@@ -800,6 +800,7 @@ workflowCmd
800
800
  .option("--title <title>", "Diagram title (defaults to workflow name)")
801
801
  .option("--block", "Wrap in ```mermaid fenced code block (default)", true)
802
802
  .option("--no-block", "Output raw Mermaid without code fence")
803
+ .option("-o, --output <path>", "Write the diagram to a file instead of stdout")
803
804
  .action((file, options) => {
804
805
  let workflow;
805
806
  // Support builtin workflow names
@@ -824,8 +825,33 @@ workflowCmd
824
825
  }
825
826
  const direction = (options.direction === "LR" ? "LR" : "TB");
826
827
  const title = options.title ?? workflow.name;
827
- const render = options.block !== false ? toMermaidBlock : toMermaid;
828
- process.stdout.write(render(workflow, { direction, title }) + "\n");
828
+ // Block default: when writing to a file, infer from extension.
829
+ // `.mmd` is raw Mermaid (what mmdc / Mermaid Live expect); `.md` is
830
+ // fenced markdown. Stdout and unknown extensions keep the prior default
831
+ // (fenced). An explicit --block / --no-block always wins.
832
+ const blockExplicit = process.argv.includes("--block") || process.argv.includes("--no-block");
833
+ let useBlock = options.block !== false;
834
+ if (!blockExplicit && options.output) {
835
+ const ext = path.extname(options.output).toLowerCase();
836
+ if (ext === ".mmd")
837
+ useBlock = false;
838
+ else if (ext === ".md")
839
+ useBlock = true;
840
+ }
841
+ const render = useBlock ? toMermaidBlock : toMermaid;
842
+ const output = render(workflow, { direction, title }) + "\n";
843
+ if (options.output) {
844
+ try {
845
+ fs.writeFileSync(options.output, output, "utf8");
846
+ console.error(chalk.green(` ✓ Wrote diagram to ${options.output}`));
847
+ }
848
+ catch (err) {
849
+ console.error(chalk.red(` Error: ${err instanceof Error ? err.message : String(err)}`));
850
+ process.exit(1);
851
+ }
852
+ return;
853
+ }
854
+ process.stdout.write(output);
829
855
  });
830
856
  workflowCmd
831
857
  .command("export <name>")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweny-ai/core",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sweny": "./dist/cli/main.js"