clawvault 2.5.4 → 2.6.0

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 (82) hide show
  1. package/README.md +159 -159
  2. package/bin/clawvault.js +111 -111
  3. package/bin/command-registration.test.js +166 -166
  4. package/bin/command-runtime.js +93 -93
  5. package/bin/command-runtime.test.js +154 -154
  6. package/bin/help-contract.test.js +39 -39
  7. package/bin/register-config-commands.js +153 -153
  8. package/bin/register-config-route-commands.test.js +121 -121
  9. package/bin/register-core-commands.js +237 -237
  10. package/bin/register-kanban-commands.js +56 -56
  11. package/bin/register-kanban-commands.test.js +83 -83
  12. package/bin/register-maintenance-commands.js +282 -282
  13. package/bin/register-project-commands.js +209 -209
  14. package/bin/register-project-commands.test.js +206 -206
  15. package/bin/register-query-commands.js +317 -317
  16. package/bin/register-query-commands.test.js +65 -65
  17. package/bin/register-resilience-commands.js +182 -182
  18. package/bin/register-resilience-commands.test.js +81 -81
  19. package/bin/register-route-commands.js +114 -114
  20. package/bin/register-session-lifecycle-commands.js +206 -206
  21. package/bin/register-tailscale-commands.js +106 -106
  22. package/bin/register-task-commands.js +348 -348
  23. package/bin/register-task-commands.test.js +69 -69
  24. package/bin/register-template-commands.js +75 -72
  25. package/bin/register-template-commands.test.js +87 -0
  26. package/bin/register-vault-operations-commands.js +300 -300
  27. package/bin/test-helpers/cli-command-fixtures.js +119 -119
  28. package/dashboard/lib/graph-diff.js +104 -104
  29. package/dashboard/lib/graph-diff.test.js +75 -75
  30. package/dashboard/lib/vault-parser.js +556 -556
  31. package/dashboard/lib/vault-parser.test.js +254 -254
  32. package/dashboard/public/app.js +796 -796
  33. package/dashboard/public/index.html +52 -52
  34. package/dashboard/public/styles.css +221 -221
  35. package/dashboard/server.js +374 -374
  36. package/dist/{chunk-J5EMBUPK.js → chunk-4OXMU5S2.js} +1 -1
  37. package/dist/{chunk-4IV3R2F5.js → chunk-4TE4JMLA.js} +1 -1
  38. package/dist/{chunk-5GZFTAL7.js → chunk-AZYOKJYC.js} +128 -42
  39. package/dist/{chunk-JDLOL2PL.js → chunk-HA5M6KJB.js} +1 -1
  40. package/dist/{chunk-IZEY5S74.js → chunk-IEVLHNLU.js} +1 -1
  41. package/dist/{chunk-OSMS7QIG.js → chunk-ME37YNW3.js} +2 -2
  42. package/dist/chunk-MFAWT5O5.js +301 -0
  43. package/dist/{chunk-TPDH3JPP.js → chunk-PBEE567J.js} +1 -1
  44. package/dist/{chunk-S2IG7VNM.js → chunk-Q2J5YTUF.js} +2 -2
  45. package/dist/{chunk-IOALNTAN.js → chunk-QWQ3TIKS.js} +103 -29
  46. package/dist/{chunk-YCVDVI5B.js → chunk-R2MIW5G7.js} +1 -1
  47. package/dist/{chunk-W2HNZC22.js → chunk-UEOUADMO.js} +1 -1
  48. package/dist/cli/index.js +8 -6
  49. package/dist/commands/backlog.js +3 -1
  50. package/dist/commands/blocked.js +3 -1
  51. package/dist/commands/canvas.js +3 -1
  52. package/dist/commands/doctor.js +7 -5
  53. package/dist/commands/kanban.js +4 -2
  54. package/dist/commands/observe.js +7 -5
  55. package/dist/commands/project.js +5 -3
  56. package/dist/commands/rebuild.js +6 -4
  57. package/dist/commands/replay.js +6 -4
  58. package/dist/commands/setup.js +1 -1
  59. package/dist/commands/sleep.js +5 -3
  60. package/dist/commands/status.js +6 -4
  61. package/dist/commands/task.js +4 -2
  62. package/dist/commands/template.d.ts +10 -1
  63. package/dist/commands/template.js +47 -55
  64. package/dist/index.js +16 -15
  65. package/dist/lib/project-utils.js +4 -2
  66. package/dist/lib/task-utils.d.ts +14 -13
  67. package/dist/lib/task-utils.js +3 -1
  68. package/dist/lib/template-engine.d.ts +1 -0
  69. package/hooks/clawvault/HOOK.md +83 -83
  70. package/hooks/clawvault/handler.js +816 -816
  71. package/hooks/clawvault/handler.test.js +263 -263
  72. package/package.json +94 -94
  73. package/templates/checkpoint.md +34 -19
  74. package/templates/daily-note.md +34 -19
  75. package/templates/daily.md +34 -19
  76. package/templates/decision.md +39 -17
  77. package/templates/handoff.md +34 -19
  78. package/templates/lesson.md +31 -16
  79. package/templates/person.md +37 -19
  80. package/templates/project.md +84 -23
  81. package/templates/task.md +81 -0
  82. /package/dist/{chunk-AXKYDCNN.js → chunk-RVYA52PY.js} +0 -0
@@ -1,3 +1,8 @@
1
+ import {
2
+ loadSchemaTemplateDefinition,
3
+ renderDocumentFromTemplate
4
+ } from "./chunk-MFAWT5O5.js";
5
+
1
6
  // src/lib/task-utils.ts
2
7
  import * as fs2 from "fs";
3
8
  import * as path2 from "path";
@@ -192,6 +197,79 @@ function startOfToday() {
192
197
  const now = /* @__PURE__ */ new Date();
193
198
  return new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
194
199
  }
200
+ function buildTaskFrontmatterFallback(now, options) {
201
+ const frontmatter = {
202
+ status: "open",
203
+ created: now,
204
+ updated: now
205
+ };
206
+ if (options.source) frontmatter.source = options.source;
207
+ if (options.owner) frontmatter.owner = options.owner;
208
+ if (options.project) frontmatter.project = options.project;
209
+ if (options.priority) frontmatter.priority = options.priority;
210
+ if (options.due) frontmatter.due = options.due;
211
+ if (options.tags && options.tags.length > 0) frontmatter.tags = options.tags;
212
+ if (options.description) frontmatter.description = options.description;
213
+ if (options.estimate) frontmatter.estimate = options.estimate;
214
+ if (options.parent) frontmatter.parent = options.parent;
215
+ if (options.depends_on && options.depends_on.length > 0) frontmatter.depends_on = options.depends_on;
216
+ return frontmatter;
217
+ }
218
+ function buildTaskContentFallback(title, options) {
219
+ let content = `# ${title}
220
+ `;
221
+ const links = [];
222
+ if (options.owner) links.push(`[[${options.owner}]]`);
223
+ if (options.project) links.push(`[[${options.project}]]`);
224
+ if (links.length > 0) {
225
+ content += `
226
+ ${links.join(" | ")}
227
+ `;
228
+ }
229
+ if (options.content) {
230
+ content += `
231
+ ${options.content}
232
+ `;
233
+ }
234
+ return content;
235
+ }
236
+ function buildTaskTemplateOverrides(options) {
237
+ const overrides = {};
238
+ if (options.source) overrides.source = options.source;
239
+ if (options.owner) overrides.owner = options.owner;
240
+ if (options.project) overrides.project = options.project;
241
+ if (options.priority) overrides.priority = options.priority;
242
+ if (options.due) overrides.due = options.due;
243
+ if (options.tags && options.tags.length > 0) overrides.tags = options.tags;
244
+ if (options.description) overrides.description = options.description;
245
+ if (options.estimate) overrides.estimate = options.estimate;
246
+ if (options.parent) overrides.parent = options.parent;
247
+ if (options.depends_on && options.depends_on.length > 0) overrides.depends_on = options.depends_on;
248
+ return overrides;
249
+ }
250
+ function buildTaskTemplateVariables(title, slug, options) {
251
+ const ownerLink = options.owner ? `[[${options.owner}]]` : "";
252
+ const projectLink = options.project ? `[[${options.project}]]` : "";
253
+ const linksLine = [ownerLink, projectLink].filter(Boolean).join(" | ");
254
+ return {
255
+ title,
256
+ slug,
257
+ source: options.source ?? "",
258
+ owner: options.owner ?? "",
259
+ project: options.project ?? "",
260
+ priority: options.priority ?? "",
261
+ due: options.due ?? "",
262
+ tags_csv: (options.tags || []).join(", "),
263
+ description: options.description ?? "",
264
+ estimate: options.estimate ?? "",
265
+ parent: options.parent ?? "",
266
+ depends_on_csv: (options.depends_on || []).join(", "),
267
+ content: options.content ?? "",
268
+ owner_link: ownerLink,
269
+ project_link: projectLink,
270
+ links_line: linksLine
271
+ };
272
+ }
195
273
  var VALID_TASK_STATUSES = /* @__PURE__ */ new Set([
196
274
  "open",
197
275
  "in-progress",
@@ -387,35 +465,31 @@ function createTask(vaultPath, title, options = {}) {
387
465
  throw new Error(`Task already exists: ${slug}`);
388
466
  }
389
467
  const now = (/* @__PURE__ */ new Date()).toISOString();
390
- const frontmatter = {
391
- status: "open",
392
- created: now,
393
- updated: now
394
- };
395
- if (options.source) frontmatter.source = options.source;
396
- if (options.owner) frontmatter.owner = options.owner;
397
- if (options.project) frontmatter.project = options.project;
398
- if (options.priority) frontmatter.priority = options.priority;
399
- if (options.due) frontmatter.due = options.due;
400
- if (options.tags && options.tags.length > 0) frontmatter.tags = options.tags;
401
- if (options.description) frontmatter.description = options.description;
402
- if (options.estimate) frontmatter.estimate = options.estimate;
403
- if (options.parent) frontmatter.parent = options.parent;
404
- if (options.depends_on && options.depends_on.length > 0) frontmatter.depends_on = options.depends_on;
405
- let content = `# ${title}
406
- `;
407
- const links = [];
408
- if (options.owner) links.push(`[[${options.owner}]]`);
409
- if (options.project) links.push(`[[${options.project}]]`);
410
- if (links.length > 0) {
411
- content += `
412
- ${links.join(" | ")}
413
- `;
414
- }
415
- if (options.content) {
416
- content += `
417
- ${options.content}
418
- `;
468
+ const template = loadSchemaTemplateDefinition("task", {
469
+ vaultPath: path2.resolve(vaultPath)
470
+ });
471
+ let frontmatter;
472
+ let content;
473
+ if (template) {
474
+ const rendered = renderDocumentFromTemplate(template, {
475
+ title,
476
+ type: "task",
477
+ now: new Date(now),
478
+ variables: buildTaskTemplateVariables(title, slug, options),
479
+ overrides: buildTaskTemplateOverrides(options),
480
+ frontmatter: { pruneEmpty: true }
481
+ });
482
+ const templateFrontmatter = rendered.frontmatter;
483
+ frontmatter = {
484
+ ...templateFrontmatter,
485
+ status: isTaskStatus(templateFrontmatter.status) ? templateFrontmatter.status : "open",
486
+ created: typeof templateFrontmatter.created === "string" && templateFrontmatter.created ? templateFrontmatter.created : now,
487
+ updated: typeof templateFrontmatter.updated === "string" && templateFrontmatter.updated ? templateFrontmatter.updated : now
488
+ };
489
+ content = rendered.content;
490
+ } else {
491
+ frontmatter = buildTaskFrontmatterFallback(now, options);
492
+ content = buildTaskContentFallback(title, options);
419
493
  }
420
494
  const fileContent = matter.stringify(content, frontmatter);
421
495
  fs2.writeFileSync(taskPath, fileContent);
@@ -8,7 +8,7 @@ import {
8
8
  queryTransitions,
9
9
  readTask,
10
10
  updateTask
11
- } from "./chunk-IOALNTAN.js";
11
+ } from "./chunk-QWQ3TIKS.js";
12
12
 
13
13
  // src/commands/task.ts
14
14
  function taskAdd(vaultPath, title, options = {}) {
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-4VQTUVH7.js";
7
7
  import {
8
8
  getObserverStaleness
9
- } from "./chunk-IZEY5S74.js";
9
+ } from "./chunk-IEVLHNLU.js";
10
10
  import {
11
11
  ClawVault,
12
12
  findVault
package/dist/cli/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  registerCliCommands
3
- } from "../chunk-JDLOL2PL.js";
3
+ } from "../chunk-HA5M6KJB.js";
4
4
  import "../chunk-THRJVD4L.js";
5
5
  import "../chunk-TIGW564L.js";
6
6
  import "../chunk-IVRIKYFE.js";
7
- import "../chunk-OSMS7QIG.js";
7
+ import "../chunk-ME37YNW3.js";
8
8
  import "../chunk-P5EPF6MB.js";
9
9
  import "../chunk-2YDBJS7M.js";
10
10
  import "../chunk-YOSEUUNB.js";
11
11
  import "../chunk-XAVB4GB4.js";
12
- import "../chunk-IZEY5S74.js";
12
+ import "../chunk-IEVLHNLU.js";
13
13
  import "../chunk-HRLWZGMA.js";
14
- import "../chunk-S2IG7VNM.js";
15
- import "../chunk-5GZFTAL7.js";
14
+ import "../chunk-Q2J5YTUF.js";
15
+ import "../chunk-AZYOKJYC.js";
16
16
  import "../chunk-KL4NAOMO.js";
17
17
  import "../chunk-FHFUXL6G.js";
18
18
  import "../chunk-4QYGFWRM.js";
@@ -25,7 +25,9 @@ import "../chunk-MQUJNOHK.js";
25
25
  import "../chunk-MXSSG3QU.js";
26
26
  import "../chunk-ZZA73MFY.js";
27
27
  import "../chunk-Z2XBWN7A.js";
28
- import "../chunk-IOALNTAN.js";
28
+ import "../chunk-QWQ3TIKS.js";
29
+ import "../chunk-MFAWT5O5.js";
30
+ import "../chunk-7766SIJP.js";
29
31
  export {
30
32
  registerCliCommands
31
33
  };
@@ -2,7 +2,9 @@ import {
2
2
  createBacklogItem,
3
3
  listBacklogItems,
4
4
  promoteBacklogItem
5
- } from "../chunk-IOALNTAN.js";
5
+ } from "../chunk-QWQ3TIKS.js";
6
+ import "../chunk-MFAWT5O5.js";
7
+ import "../chunk-7766SIJP.js";
6
8
 
7
9
  // src/commands/backlog.ts
8
10
  function toDateStr(val) {
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  getBlockedTasks
3
- } from "../chunk-IOALNTAN.js";
3
+ } from "../chunk-QWQ3TIKS.js";
4
+ import "../chunk-MFAWT5O5.js";
5
+ import "../chunk-7766SIJP.js";
4
6
 
5
7
  // src/commands/blocked.ts
6
8
  function toDateStr(val) {
@@ -15,7 +15,9 @@ import {
15
15
  } from "../chunk-Z2XBWN7A.js";
16
16
  import {
17
17
  listTasks
18
- } from "../chunk-IOALNTAN.js";
18
+ } from "../chunk-QWQ3TIKS.js";
19
+ import "../chunk-MFAWT5O5.js";
20
+ import "../chunk-7766SIJP.js";
19
21
 
20
22
  // src/commands/canvas.ts
21
23
  import * as fs2 from "fs";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  doctor
3
- } from "../chunk-W2HNZC22.js";
3
+ } from "../chunk-UEOUADMO.js";
4
4
  import "../chunk-7ZRP733D.js";
5
5
  import "../chunk-4VQTUVH7.js";
6
6
  import "../chunk-J7ZWCI2C.js";
7
- import "../chunk-IZEY5S74.js";
7
+ import "../chunk-IEVLHNLU.js";
8
8
  import "../chunk-HRLWZGMA.js";
9
- import "../chunk-S2IG7VNM.js";
10
- import "../chunk-5GZFTAL7.js";
9
+ import "../chunk-Q2J5YTUF.js";
10
+ import "../chunk-AZYOKJYC.js";
11
11
  import "../chunk-KL4NAOMO.js";
12
12
  import "../chunk-FHFUXL6G.js";
13
13
  import "../chunk-MAKNAHAW.js";
@@ -15,7 +15,9 @@ import "../chunk-ITPEXLHA.js";
15
15
  import "../chunk-2CDEETQN.js";
16
16
  import "../chunk-ZZA73MFY.js";
17
17
  import "../chunk-Z2XBWN7A.js";
18
- import "../chunk-IOALNTAN.js";
18
+ import "../chunk-QWQ3TIKS.js";
19
+ import "../chunk-MFAWT5O5.js";
20
+ import "../chunk-7766SIJP.js";
19
21
  import "../chunk-QVMXF7FY.js";
20
22
  export {
21
23
  doctor
@@ -7,8 +7,10 @@ import {
7
7
  kanbanCommand,
8
8
  parseKanbanMarkdown,
9
9
  syncKanbanBoard
10
- } from "../chunk-J5EMBUPK.js";
11
- import "../chunk-IOALNTAN.js";
10
+ } from "../chunk-4OXMU5S2.js";
11
+ import "../chunk-QWQ3TIKS.js";
12
+ import "../chunk-MFAWT5O5.js";
13
+ import "../chunk-7766SIJP.js";
12
14
  export {
13
15
  buildKanbanLanes,
14
16
  extractCardSlug,
@@ -1,18 +1,20 @@
1
1
  import {
2
2
  observeCommand,
3
3
  registerObserveCommand
4
- } from "../chunk-OSMS7QIG.js";
4
+ } from "../chunk-ME37YNW3.js";
5
5
  import "../chunk-P5EPF6MB.js";
6
- import "../chunk-IZEY5S74.js";
6
+ import "../chunk-IEVLHNLU.js";
7
7
  import "../chunk-HRLWZGMA.js";
8
- import "../chunk-S2IG7VNM.js";
9
- import "../chunk-5GZFTAL7.js";
8
+ import "../chunk-Q2J5YTUF.js";
9
+ import "../chunk-AZYOKJYC.js";
10
10
  import "../chunk-FHFUXL6G.js";
11
11
  import "../chunk-ITPEXLHA.js";
12
12
  import "../chunk-2CDEETQN.js";
13
13
  import "../chunk-MXSSG3QU.js";
14
14
  import "../chunk-Z2XBWN7A.js";
15
- import "../chunk-IOALNTAN.js";
15
+ import "../chunk-QWQ3TIKS.js";
16
+ import "../chunk-MFAWT5O5.js";
17
+ import "../chunk-7766SIJP.js";
16
18
  export {
17
19
  observeCommand,
18
20
  registerObserveCommand
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  formatTaskList,
3
3
  taskList
4
- } from "../chunk-YCVDVI5B.js";
4
+ } from "../chunk-R2MIW5G7.js";
5
5
  import {
6
6
  archiveProject,
7
7
  createProject,
@@ -10,8 +10,10 @@ import {
10
10
  listProjects,
11
11
  readProject,
12
12
  updateProject
13
- } from "../chunk-5GZFTAL7.js";
14
- import "../chunk-IOALNTAN.js";
13
+ } from "../chunk-AZYOKJYC.js";
14
+ import "../chunk-QWQ3TIKS.js";
15
+ import "../chunk-MFAWT5O5.js";
16
+ import "../chunk-7766SIJP.js";
15
17
 
16
18
  // src/commands/project.ts
17
19
  import * as fs from "fs";
@@ -1,15 +1,17 @@
1
1
  import {
2
2
  rebuildCommand,
3
3
  registerRebuildCommand
4
- } from "../chunk-TPDH3JPP.js";
5
- import "../chunk-S2IG7VNM.js";
6
- import "../chunk-5GZFTAL7.js";
4
+ } from "../chunk-PBEE567J.js";
5
+ import "../chunk-Q2J5YTUF.js";
6
+ import "../chunk-AZYOKJYC.js";
7
7
  import "../chunk-FHFUXL6G.js";
8
8
  import "../chunk-ITPEXLHA.js";
9
9
  import "../chunk-2CDEETQN.js";
10
10
  import "../chunk-MXSSG3QU.js";
11
11
  import "../chunk-Z2XBWN7A.js";
12
- import "../chunk-IOALNTAN.js";
12
+ import "../chunk-QWQ3TIKS.js";
13
+ import "../chunk-MFAWT5O5.js";
14
+ import "../chunk-7766SIJP.js";
13
15
  export {
14
16
  rebuildCommand,
15
17
  registerRebuildCommand
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  registerReplayCommand,
3
3
  replayCommand
4
- } from "../chunk-4IV3R2F5.js";
4
+ } from "../chunk-4TE4JMLA.js";
5
5
  import "../chunk-YOSEUUNB.js";
6
- import "../chunk-S2IG7VNM.js";
7
- import "../chunk-5GZFTAL7.js";
6
+ import "../chunk-Q2J5YTUF.js";
7
+ import "../chunk-AZYOKJYC.js";
8
8
  import "../chunk-FHFUXL6G.js";
9
9
  import "../chunk-K3CDT7IH.js";
10
10
  import "../chunk-ITPEXLHA.js";
@@ -12,7 +12,9 @@ import "../chunk-2CDEETQN.js";
12
12
  import "../chunk-MQUJNOHK.js";
13
13
  import "../chunk-MXSSG3QU.js";
14
14
  import "../chunk-Z2XBWN7A.js";
15
- import "../chunk-IOALNTAN.js";
15
+ import "../chunk-QWQ3TIKS.js";
16
+ import "../chunk-MFAWT5O5.js";
17
+ import "../chunk-7766SIJP.js";
16
18
  export {
17
19
  registerReplayCommand,
18
20
  replayCommand
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  setupCommand
3
- } from "../chunk-AXKYDCNN.js";
3
+ } from "../chunk-RVYA52PY.js";
4
4
  import "../chunk-MAKNAHAW.js";
5
5
  import "../chunk-2CDEETQN.js";
6
6
  export {
@@ -6,8 +6,8 @@ import {
6
6
  } from "../chunk-YOSEUUNB.js";
7
7
  import {
8
8
  Observer
9
- } from "../chunk-S2IG7VNM.js";
10
- import "../chunk-5GZFTAL7.js";
9
+ } from "../chunk-Q2J5YTUF.js";
10
+ import "../chunk-AZYOKJYC.js";
11
11
  import {
12
12
  ClawVault
13
13
  } from "../chunk-KL4NAOMO.js";
@@ -21,7 +21,9 @@ import "../chunk-2CDEETQN.js";
21
21
  import "../chunk-MQUJNOHK.js";
22
22
  import "../chunk-ZZA73MFY.js";
23
23
  import "../chunk-Z2XBWN7A.js";
24
- import "../chunk-IOALNTAN.js";
24
+ import "../chunk-QWQ3TIKS.js";
25
+ import "../chunk-MFAWT5O5.js";
26
+ import "../chunk-7766SIJP.js";
25
27
  import {
26
28
  clearDirtyFlag
27
29
  } from "../chunk-F55HGNU4.js";
@@ -7,10 +7,10 @@ import {
7
7
  import "../chunk-J7ZWCI2C.js";
8
8
  import {
9
9
  getObserverStaleness
10
- } from "../chunk-IZEY5S74.js";
10
+ } from "../chunk-IEVLHNLU.js";
11
11
  import "../chunk-HRLWZGMA.js";
12
- import "../chunk-S2IG7VNM.js";
13
- import "../chunk-5GZFTAL7.js";
12
+ import "../chunk-Q2J5YTUF.js";
13
+ import "../chunk-AZYOKJYC.js";
14
14
  import {
15
15
  ClawVault
16
16
  } from "../chunk-KL4NAOMO.js";
@@ -26,7 +26,9 @@ import {
26
26
  loadMemoryGraphIndex
27
27
  } from "../chunk-ZZA73MFY.js";
28
28
  import "../chunk-Z2XBWN7A.js";
29
- import "../chunk-IOALNTAN.js";
29
+ import "../chunk-QWQ3TIKS.js";
30
+ import "../chunk-MFAWT5O5.js";
31
+ import "../chunk-7766SIJP.js";
30
32
 
31
33
  // src/commands/status.ts
32
34
  import * as fs from "fs";
@@ -8,8 +8,10 @@ import {
8
8
  taskShow,
9
9
  taskTransitions,
10
10
  taskUpdate
11
- } from "../chunk-YCVDVI5B.js";
12
- import "../chunk-IOALNTAN.js";
11
+ } from "../chunk-R2MIW5G7.js";
12
+ import "../chunk-QWQ3TIKS.js";
13
+ import "../chunk-MFAWT5O5.js";
14
+ import "../chunk-7766SIJP.js";
13
15
  export {
14
16
  formatTaskDetails,
15
17
  formatTaskList,
@@ -13,6 +13,15 @@ interface TemplateAddOptions extends TemplateCommandContext {
13
13
  name: string;
14
14
  overwrite?: boolean;
15
15
  }
16
+ interface TemplateDefinitionInfo {
17
+ name: string;
18
+ primitive: string;
19
+ description?: string;
20
+ fields: string[];
21
+ path: string;
22
+ format: 'schema' | 'legacy';
23
+ }
24
+ declare function listTemplateDefinitions(options?: TemplateCommandContext): TemplateDefinitionInfo[];
16
25
  declare function listTemplates(options?: TemplateCommandContext): string[];
17
26
  declare function createFromTemplate(name: string, options?: TemplateCreateOptions): {
18
27
  outputPath: string;
@@ -24,4 +33,4 @@ declare function addTemplate(file: string, options: TemplateAddOptions): {
24
33
  name: string;
25
34
  };
26
35
 
27
- export { type TemplateAddOptions, type TemplateCommandContext, type TemplateCreateOptions, addTemplate, createFromTemplate, listTemplates };
36
+ export { type TemplateAddOptions, type TemplateCommandContext, type TemplateCreateOptions, type TemplateDefinitionInfo, addTemplate, createFromTemplate, listTemplateDefinitions, listTemplates };
@@ -1,3 +1,11 @@
1
+ import {
2
+ TEMPLATE_EXTENSION,
3
+ buildTemplateIndex,
4
+ listTemplateDefinitions,
5
+ normalizeTemplateName,
6
+ parseTemplateDefinition,
7
+ renderDocumentFromTemplate
8
+ } from "../chunk-MFAWT5O5.js";
1
9
  import {
2
10
  buildTemplateVariables,
3
11
  renderTemplate
@@ -6,26 +14,8 @@ import {
6
14
  // src/commands/template.ts
7
15
  import * as fs from "fs";
8
16
  import * as path from "path";
9
- import { fileURLToPath } from "url";
10
17
  var VAULT_CONFIG_FILE = ".clawvault.json";
11
- var TEMPLATE_EXTENSION = ".md";
12
- function resolveBuiltinTemplatesDir(override) {
13
- if (override) {
14
- const resolved = path.resolve(override);
15
- return fs.existsSync(resolved) ? resolved : null;
16
- }
17
- const moduleDir = path.dirname(fileURLToPath(import.meta.url));
18
- const candidates = [
19
- path.resolve(moduleDir, "../templates"),
20
- path.resolve(moduleDir, "../../templates")
21
- ];
22
- for (const candidate of candidates) {
23
- if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) {
24
- return candidate;
25
- }
26
- }
27
- return null;
28
- }
18
+ var TEMPLATE_LIST_IGNORED_BUILTINS = /* @__PURE__ */ new Set(["daily"]);
29
19
  function findVaultRoot(start) {
30
20
  let current = path.resolve(start);
31
21
  while (true) {
@@ -48,53 +38,41 @@ function resolveVaultPath(options) {
48
38
  const cwd = options.cwd ?? process.cwd();
49
39
  return findVaultRoot(cwd);
50
40
  }
51
- function normalizeTemplateName(name) {
52
- const base = path.basename(name, path.extname(name));
53
- return base.trim();
54
- }
55
41
  function slugify(text) {
56
42
  return text.toLowerCase().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
57
43
  }
58
- function listTemplateFiles(dir, ignore) {
59
- const entries = /* @__PURE__ */ new Map();
60
- if (!fs.existsSync(dir)) return entries;
61
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
62
- if (!entry.isFile() || !entry.name.endsWith(TEMPLATE_EXTENSION)) continue;
63
- const name = normalizeTemplateName(entry.name);
64
- if (!name) continue;
65
- if (ignore?.has(name)) continue;
66
- entries.set(name, path.join(dir, entry.name));
67
- }
68
- return entries;
44
+ function buildTemplateIndexForContext(options) {
45
+ const vaultPath = resolveVaultPath(options) ?? void 0;
46
+ return buildTemplateIndex({
47
+ vaultPath,
48
+ builtinDir: options.builtinDir,
49
+ ignoreBuiltinNames: TEMPLATE_LIST_IGNORED_BUILTINS
50
+ });
69
51
  }
70
- function buildTemplateIndex(options) {
71
- const index = /* @__PURE__ */ new Map();
72
- const builtinDir = resolveBuiltinTemplatesDir(options.builtinDir);
73
- if (builtinDir) {
74
- const ignore = /* @__PURE__ */ new Set(["daily"]);
75
- for (const [name, filePath] of listTemplateFiles(builtinDir, ignore)) {
76
- index.set(name, filePath);
77
- }
78
- }
79
- const vaultPath = resolveVaultPath(options);
80
- if (vaultPath) {
81
- const vaultTemplatesDir = path.join(vaultPath, "templates");
82
- for (const [name, filePath] of listTemplateFiles(vaultTemplatesDir)) {
83
- index.set(name, filePath);
84
- }
85
- }
86
- return index;
52
+ function listTemplateDefinitions2(options = {}) {
53
+ const vaultPath = resolveVaultPath(options) ?? void 0;
54
+ return listTemplateDefinitions({
55
+ vaultPath,
56
+ builtinDir: options.builtinDir,
57
+ ignoreBuiltinNames: TEMPLATE_LIST_IGNORED_BUILTINS
58
+ }).map((definition) => ({
59
+ name: definition.name,
60
+ primitive: definition.primitive,
61
+ description: definition.description,
62
+ fields: Object.keys(definition.fields),
63
+ path: definition.path,
64
+ format: definition.format
65
+ }));
87
66
  }
88
67
  function listTemplates(options = {}) {
89
- const index = buildTemplateIndex(options);
90
- return [...index.keys()].sort();
68
+ return listTemplateDefinitions2(options).map((definition) => definition.name);
91
69
  }
92
70
  function createFromTemplate(name, options = {}) {
93
71
  const templateName = normalizeTemplateName(name);
94
72
  if (!templateName) {
95
73
  throw new Error("Template name is required.");
96
74
  }
97
- const index = buildTemplateIndex(options);
75
+ const index = buildTemplateIndexForContext(options);
98
76
  const templatePath = index.get(templateName);
99
77
  if (!templatePath) {
100
78
  const available = [...index.keys()].sort();
@@ -107,7 +85,20 @@ function createFromTemplate(name, options = {}) {
107
85
  const type = options.type ?? templateName;
108
86
  const title = options.title ?? `${type} ${date}`.trim();
109
87
  const variables = buildTemplateVariables({ title, type, date }, now);
110
- const rendered = renderTemplate(raw, variables);
88
+ const parsedTemplate = parseTemplateDefinition(raw, templateName, templatePath);
89
+ const rendered = parsedTemplate.format === "schema" ? renderDocumentFromTemplate(parsedTemplate, {
90
+ title,
91
+ type,
92
+ now,
93
+ variables: {
94
+ ...variables,
95
+ content: "",
96
+ links_line: "",
97
+ owner_link: "",
98
+ project_link: "",
99
+ team_links_line: ""
100
+ }
101
+ }).markdown : renderTemplate(raw, variables);
111
102
  const cwd = options.cwd ?? process.cwd();
112
103
  const slug = slugify(title) || slugify(templateName) || `template-${date}`;
113
104
  const outputPath = path.join(cwd, `${slug}${TEMPLATE_EXTENSION}`);
@@ -143,5 +134,6 @@ function addTemplate(file, options) {
143
134
  export {
144
135
  addTemplate,
145
136
  createFromTemplate,
137
+ listTemplateDefinitions2 as listTemplateDefinitions,
146
138
  listTemplates
147
139
  };