dsh-artcraft-plugin-vectorcraft 0.2.12 → 0.2.14

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/package.json +3 -2
  2. package/src/kit/tools.js +26 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-artcraft-plugin-vectorcraft",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "DSH plugin: drive VectorCraft (vector art) headlessly through its own CLI and MCP server.",
@@ -44,7 +44,8 @@
44
44
  "access": "public"
45
45
  },
46
46
  "engines": {
47
- "dsh": "^0.2.1-rc.3"
47
+ "dsh": "^0.2.1-rc.3",
48
+ "node": "^22.19.0 || >=24.0.0"
48
49
  },
49
50
  "repository": {
50
51
  "type": "git",
package/src/kit/tools.js CHANGED
@@ -105,6 +105,31 @@ function extractParams(stdout ) {
105
105
  return match?.[1]?.trim()
106
106
  }
107
107
 
108
+ /**
109
+ * Create the folder an output file lives in.
110
+ *
111
+ * A crafting app refuses to write into a directory that does not exist and
112
+ * reports it as a bare OS error; creating the parent here turns "save to
113
+ * ~/Documents/2026 Q3/report.docx" into one call instead of two, and the same
114
+ * behaviour on macOS, Windows and Linux.
115
+ * @param args - the tool arguments, which may name `save`, `export`, `out` or `output`.
116
+ */
117
+ function ensureOutputDir(args ) {
118
+ for (const key of ['save', 'export', 'out', 'output']) {
119
+ const value = args[key]
120
+ if (typeof value !== 'string' || value.length === 0) continue
121
+ const folder = dirname(value)
122
+ // A bare filename has no folder part; `dirname('x.xlsx')` is '.', and a
123
+ // Windows-looking absolute path on POSIX is not ours to create.
124
+ if (folder === '.' || folder === '' || folder === '/') continue
125
+ try {
126
+ mkdirSync(folder, { recursive: true })
127
+ } catch {
128
+ // Leave it to the craft to report; a read-only volume should fail there.
129
+ }
130
+ }
131
+ }
132
+
108
133
  /** Scratch directory for files the kernel generates per craft (script modes). */
109
134
  function craftWorkDir(profile ) {
110
135
  return join(tmpdir(), 'dsh-artcraft', profile.id)
@@ -663,6 +688,7 @@ export function createToolSet(runtime ) {
663
688
  ]
664
689
  return await runOrStart(binary, [...globalFlagsFor(profile, args), profile.run.verb, ...extra], args.background, documentOf(args), labelOf(args))
665
690
  }
691
+ ensureOutputDir(args)
666
692
  // PdfCraft's `run` accepts exactly one tool per invocation; sending a
667
693
  // list would produce "expected key=value" from the CLI, so the extra
668
694
  // commands are reported instead of silently mis-executed.