dotmd-cli 0.49.1 → 0.49.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotmd-cli",
3
- "version": "0.49.1",
3
+ "version": "0.49.3",
4
4
  "description": "CLI for managing markdown documents with YAML frontmatter — index, query, validate, graph, export, Notion sync, AI summaries.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/new.mjs CHANGED
@@ -271,6 +271,16 @@ function readBodyInput(source) {
271
271
  export async function runNew(argv, config, opts = {}) {
272
272
  const { dryRun } = opts;
273
273
 
274
+ const knownTypes = new Set(Object.keys(BUILTIN_TEMPLATES));
275
+ // Also include any custom templates from config
276
+ for (const k of Object.keys(config.raw?.templates ?? {})) knownTypes.add(k);
277
+
278
+ const hasNameForBody = args => {
279
+ if (args.length >= 2 && knownTypes.has(args[0])) return true;
280
+ if (args.length >= 1 && !knownTypes.has(args[0])) return true;
281
+ return false;
282
+ };
283
+
274
284
  // Parse args. Pull out flags first.
275
285
  const positional = [];
276
286
  let status = null;
@@ -296,17 +306,16 @@ export async function runNew(argv, config, opts = {}) {
296
306
  return;
297
307
  }
298
308
  // Treat `-` alone (stdin marker) as a positional, not a flag.
299
- if (!argv[i].startsWith('-') || argv[i] === '-') positional.push(argv[i]);
309
+ // Once the type/name have been collected, a positional body may itself
310
+ // start with `---` frontmatter. Preserve it instead of dropping it as an
311
+ // unknown flag; the leading frontmatter merge below will handle it.
312
+ if (!argv[i].startsWith('-') || argv[i] === '-' || hasNameForBody(positional)) positional.push(argv[i]);
300
313
  }
301
314
 
302
315
  // Resolve type vs name:
303
316
  // `dotmd new plan auth-revamp` → type=plan, name=auth-revamp
304
317
  // `dotmd new auth-revamp` → type=doc (default), name=auth-revamp
305
318
  // `dotmd new prompt foo "body"` → type=prompt, name=foo, bodyArg="body"
306
- const knownTypes = new Set(Object.keys(BUILTIN_TEMPLATES));
307
- // Also include any custom templates from config
308
- for (const k of Object.keys(config.raw?.templates ?? {})) knownTypes.add(k);
309
-
310
319
  let typeName, name, bodyArg = null;
311
320
  if (positional.length >= 1 && knownTypes.has(positional[0])) {
312
321
  typeName = positional[0];
@@ -357,14 +366,16 @@ export async function runNew(argv, config, opts = {}) {
357
366
  else if (bodyArg !== null) {
358
367
  bodyInput = readBodyInput(bodyArg);
359
368
  bodyInputSource = bodyArg === '-' ? 'stdin (`-`)' : (bodyArg.startsWith('@') ? `file (\`${bodyArg}\`)` : 'inline body argument');
360
- } else if (template.acceptsBody || template.requiresBody) {
369
+ } else {
361
370
  // Auto-consume piped or redirected stdin so agents don't need the `-`
362
371
  // placeholder for the most common pattern (`cat draft.md | dotmd new …`,
363
372
  // `dotmd new … < draft.md`, or a `<<'EOF'` heredoc). We probe stdin via
364
373
  // fstatSync rather than `!isTTY` so a closed/inherited fd doesn't trigger
365
374
  // a blocking read of an empty stream. We accept FIFO (shell pipes), regular
366
375
  // file (shell redirection / heredoc), and socket (Node spawnSync `input:`
367
- // delivers stdin as an AF_UNIX socket).
376
+ // delivers stdin as an AF_UNIX socket). Probe this even for templates that
377
+ // don't accept bodies so the fail-fast guard below can reject accidental
378
+ // heredoc/input instead of silently scaffolding without it.
368
379
  try {
369
380
  const stat = fstatSync(0);
370
381
  if (stat.isFIFO() || stat.isFile() || stat.isSocket()) {
package/src/ship.mjs CHANGED
@@ -20,6 +20,7 @@ const ALLOWLIST_PATTERNS = [
20
20
  /^package(?:-lock)?\.json$/,
21
21
  /^README\.md$/,
22
22
  /^CLAUDE\.md$/,
23
+ /^CHANGELOG\.md$/,
23
24
  /^\.gitignore$/,
24
25
  ];
25
26