dotmd-cli 0.10.0 → 0.10.2

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.10.0",
3
+ "version": "0.10.2",
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/lint.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { readFileSync, writeFileSync } from 'node:fs';
2
+ import path from 'node:path';
2
3
  import { extractFrontmatter, parseSimpleFrontmatter, replaceFrontmatter } from './frontmatter.mjs';
3
4
  import { asString, toRepoPath, escapeRegex, warn } from './util.mjs';
4
5
  import { buildIndex, collectDocFiles } from './index.mjs';
@@ -29,9 +30,14 @@ export function runLint(argv, config, opts = {}) {
29
30
  const repoPath = toRepoPath(filePath, config.repoRoot);
30
31
  const fixes = [];
31
32
 
32
- // Missing type (fixable — default to 'doc')
33
+ // Missing type (fixable — infer from root: plans → 'plan', else 'doc')
33
34
  if (!asString(parsed.type)) {
34
- fixes.push({ field: 'type', oldValue: null, newValue: 'doc', type: 'add' });
35
+ const roots = config.docsRoots || [config.docsRoot];
36
+ const docRoot = roots.find(r => filePath.startsWith(r)) ?? config.docsRoot;
37
+ const rootLabel = path.relative(config.repoRoot, docRoot).split(path.sep).join('/');
38
+ // If the root label contains 'plan' (e.g. 'docs/plans'), default to plan type
39
+ const inferredType = rootLabel.includes('plan') ? 'plan' : 'doc';
40
+ fixes.push({ field: 'type', oldValue: null, newValue: inferredType, type: 'add' });
35
41
  }
36
42
 
37
43
  // Missing status (fixable via AI inference)
package/src/validate.mjs CHANGED
@@ -7,10 +7,10 @@ import { toRepoPath } from './util.mjs';
7
7
  const NOW = new Date();
8
8
 
9
9
  function isValidStatus(status, root, config, type) {
10
- // Type-specific statuses take priority
10
+ // Union type-specific + root-specific statuses (a doc can satisfy either)
11
11
  if (type) {
12
12
  const typeSet = config.typeStatuses?.get(type);
13
- if (typeSet) return typeSet.has(status);
13
+ if (typeSet && typeSet.has(status)) return true;
14
14
  }
15
15
  const rootSet = config.rootValidStatuses?.get(root);
16
16
  if (rootSet) return rootSet.has(status);
@@ -26,8 +26,10 @@ export function validateDoc(doc, frontmatter, headingTitle, config) {
26
26
  if (!doc.status) {
27
27
  doc.errors.push({ path: doc.path, level: 'error', message: 'Missing frontmatter `status`.' });
28
28
  } else if (!isValidStatus(doc.status, doc.root, config, doc.type)) {
29
- const validSet = doc.type && config.typeStatuses?.get(doc.type);
30
- const hint = validSet ? `valid for type \`${doc.type}\`: ${[...validSet].join(', ')}` : 'not in statuses.order';
29
+ const typeSet = doc.type && config.typeStatuses?.get(doc.type);
30
+ const rootSet = config.rootValidStatuses?.get(doc.root);
31
+ const combined = new Set([...(typeSet ?? []), ...(rootSet ?? config.validStatuses)]);
32
+ const hint = `valid: ${[...combined].join(', ')}`;
31
33
  doc.warnings.push({ path: doc.path, level: 'warning', message: `Unknown status \`${doc.status}\`; ${hint}.` });
32
34
  }
33
35