domain-knowledge-kit 0.2.7 → 0.2.8

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 (58) hide show
  1. package/README.md +45 -27
  2. package/dist/cli.js +13 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/features/agent/commands/init.d.ts.map +1 -1
  5. package/dist/features/agent/commands/init.js +3 -2
  6. package/dist/features/agent/commands/init.js.map +1 -1
  7. package/dist/features/agent/commands/prime.d.ts +4 -1
  8. package/dist/features/agent/commands/prime.d.ts.map +1 -1
  9. package/dist/features/agent/commands/prime.js +213 -61
  10. package/dist/features/agent/commands/prime.js.map +1 -1
  11. package/dist/features/pipeline/renderer.js +1 -1
  12. package/dist/features/pipeline/renderer.js.map +1 -1
  13. package/dist/features/pipeline/tests/indexer.test.js +5 -5
  14. package/dist/features/pipeline/tests/indexer.test.js.map +1 -1
  15. package/dist/features/pipeline/tests/validator.test.js +25 -25
  16. package/dist/features/pipeline/tests/validator.test.js.map +1 -1
  17. package/dist/features/query/commands/search.d.ts +3 -0
  18. package/dist/features/query/commands/search.d.ts.map +1 -1
  19. package/dist/features/query/commands/search.js +29 -8
  20. package/dist/features/query/commands/search.js.map +1 -1
  21. package/dist/features/query/tests/searcher.test.js +5 -5
  22. package/dist/features/query/tests/searcher.test.js.map +1 -1
  23. package/dist/features/scaffold/commands/add-item.d.ts +15 -0
  24. package/dist/features/scaffold/commands/add-item.d.ts.map +1 -0
  25. package/dist/features/scaffold/commands/add-item.js +125 -0
  26. package/dist/features/scaffold/commands/add-item.js.map +1 -0
  27. package/dist/features/scaffold/commands/new-adr.d.ts +12 -0
  28. package/dist/features/scaffold/commands/new-adr.d.ts.map +1 -0
  29. package/dist/features/scaffold/commands/new-adr.js +95 -0
  30. package/dist/features/scaffold/commands/new-adr.js.map +1 -0
  31. package/dist/features/scaffold/commands/new-context.d.ts +17 -0
  32. package/dist/features/scaffold/commands/new-context.d.ts.map +1 -0
  33. package/dist/features/scaffold/commands/new-context.js +67 -0
  34. package/dist/features/scaffold/commands/new-context.js.map +1 -0
  35. package/dist/features/scaffold/commands/new-domain.d.ts +14 -0
  36. package/dist/features/scaffold/commands/new-domain.d.ts.map +1 -0
  37. package/dist/features/scaffold/commands/new-domain.js +86 -0
  38. package/dist/features/scaffold/commands/new-domain.js.map +1 -0
  39. package/dist/shared/errors.js +1 -1
  40. package/dist/shared/errors.js.map +1 -1
  41. package/dist/shared/index.d.ts +1 -1
  42. package/dist/shared/index.d.ts.map +1 -1
  43. package/dist/shared/index.js +1 -1
  44. package/dist/shared/index.js.map +1 -1
  45. package/dist/shared/loader.js +2 -2
  46. package/dist/shared/paths.d.ts +32 -11
  47. package/dist/shared/paths.d.ts.map +1 -1
  48. package/dist/shared/paths.js +49 -19
  49. package/dist/shared/paths.js.map +1 -1
  50. package/dist/shared/tests/graph.test.js +9 -9
  51. package/dist/shared/tests/graph.test.js.map +1 -1
  52. package/dist/shared/tests/loader.test.js +20 -20
  53. package/dist/shared/tests/loader.test.js.map +1 -1
  54. package/dist/shared/tests/verify-collision-fix.test.js +1 -1
  55. package/dist/shared/tests/verify-collision-fix.test.js.map +1 -1
  56. package/dist/shared/types/domain.d.ts +4 -4
  57. package/dist/shared/types/domain.d.ts.map +1 -1
  58. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `dkk new adr <title>` command — scaffold a new ADR file.
3
+ *
4
+ * Creates `.dkk/adr/adr-NNNN.md` with YAML frontmatter template.
5
+ * Automatically determines the next ADR number by scanning existing files.
6
+ *
7
+ * Flags:
8
+ * --status accepted|proposed|deprecated (default: proposed)
9
+ */
10
+ import type { Command as Cmd } from "commander";
11
+ export declare function registerNewAdr(program: Cmd): void;
12
+ //# sourceMappingURL=new-adr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-adr.d.ts","sourceRoot":"","sources":["../../../../src/features/scaffold/commands/new-adr.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AA2ChD,wBAAgB,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CA8DjD"}
@@ -0,0 +1,95 @@
1
+ import { existsSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { adrDir } from "../../../shared/paths.js";
4
+ /** Scan existing adr-NNNN.md files and return the next number. */
5
+ function nextAdrNumber(dir) {
6
+ if (!existsSync(dir))
7
+ return 1;
8
+ const files = readdirSync(dir);
9
+ let max = 0;
10
+ for (const f of files) {
11
+ const m = f.match(/^adr-(\d{4})\.md$/);
12
+ if (m) {
13
+ const n = parseInt(m[1], 10);
14
+ if (n > max)
15
+ max = n;
16
+ }
17
+ }
18
+ return max + 1;
19
+ }
20
+ /** Pad a number to 4 digits. */
21
+ function pad4(n) {
22
+ return String(n).padStart(4, "0");
23
+ }
24
+ /** Get today's date as YYYY-MM-DD. */
25
+ function today() {
26
+ const d = new Date();
27
+ const year = d.getFullYear();
28
+ const month = String(d.getMonth() + 1).padStart(2, "0");
29
+ const day = String(d.getDate()).padStart(2, "0");
30
+ return `${year}-${month}-${day}`;
31
+ }
32
+ /** Convert a title to a kebab-case slug for the filename hint. */
33
+ function slugify(title) {
34
+ return title
35
+ .toLowerCase()
36
+ .replace(/[^a-z0-9]+/g, "-")
37
+ .replace(/^-|-$/g, "");
38
+ }
39
+ export function registerNewAdr(program) {
40
+ program
41
+ .command("adr <title>")
42
+ .description("Scaffold a new ADR file with frontmatter template")
43
+ .option("-r, --root <path>", "Override repository root")
44
+ .option("-s, --status <status>", "ADR status (proposed, accepted, deprecated)", "proposed")
45
+ .action((title, opts) => {
46
+ const status = opts.status ?? "proposed";
47
+ const validStatuses = ["proposed", "accepted", "deprecated", "superseded"];
48
+ if (!validStatuses.includes(status)) {
49
+ console.error(`Error: Invalid status "${status}". Must be one of: ${validStatuses.join(", ")}`);
50
+ process.exit(1);
51
+ }
52
+ const dir = adrDir(opts.root);
53
+ mkdirSync(dir, { recursive: true });
54
+ const num = nextAdrNumber(dir);
55
+ const id = `adr-${pad4(num)}`;
56
+ const filename = `${id}.md`;
57
+ const filePath = join(dir, filename);
58
+ // Guard: should not happen with auto-numbering, but be safe
59
+ if (existsSync(filePath)) {
60
+ console.error(`Error: ${filePath} already exists.`);
61
+ process.exit(1);
62
+ }
63
+ const _slug = slugify(title);
64
+ const content = `---
65
+ id: ${id}
66
+ title: ${title}
67
+ status: ${status}
68
+ date: ${today()}
69
+ deciders: []
70
+ domain_refs: []
71
+ ---
72
+
73
+ # ${id.toUpperCase()} — ${title}
74
+
75
+ **Status:** ${status.charAt(0).toUpperCase() + status.slice(1)}
76
+ **Date:** ${today()}
77
+
78
+ ## Context
79
+
80
+ <!-- What is the issue that we're seeing that is motivating this decision? -->
81
+
82
+ ## Decision
83
+
84
+ <!-- What is the change that we're proposing and/or doing? -->
85
+
86
+ ## Consequences
87
+
88
+ <!-- What becomes easier or harder as a result of this decision? -->
89
+ `;
90
+ writeFileSync(filePath, content, "utf-8");
91
+ console.log(`Created ${filename}`);
92
+ console.log(` .dkk/adr/${filename}`);
93
+ });
94
+ }
95
+ //# sourceMappingURL=new-adr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-adr.js","sourceRoot":"","sources":["../../../../src/features/scaffold/commands/new-adr.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,kEAAkE;AAClE,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAE/B,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC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,GAAG;MAChB,EAAE;SACC,KAAK;UACJ,MAAM;QACR,KAAK,EAAE;;;;;IAKX,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK;;cAEjB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAClD,KAAK,EAAE;;;;;;;;;;;;;CAalB,CAAC;QAEI,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,WAAW,QAAQ,EAAE,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,cAAc,QAAQ,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `dkk new context <name>` command — scaffold a new bounded context.
3
+ *
4
+ * Creates:
5
+ * .dkk/domain/contexts/<name>/context.yml
6
+ * .dkk/domain/contexts/<name>/events/
7
+ * .dkk/domain/contexts/<name>/commands/
8
+ * .dkk/domain/contexts/<name>/aggregates/
9
+ * .dkk/domain/contexts/<name>/policies/
10
+ * .dkk/domain/contexts/<name>/read-models/
11
+ *
12
+ * Registers the context in `.dkk/domain/index.yml`.
13
+ * Errors if the context already exists.
14
+ */
15
+ import type { Command as Cmd } from "commander";
16
+ export declare function registerNewContext(program: Cmd): void;
17
+ //# sourceMappingURL=new-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-context.d.ts","sourceRoot":"","sources":["../../../../src/features/scaffold/commands/new-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAYhD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAoErD"}
@@ -0,0 +1,67 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { contextsDir, indexFile } from "../../../shared/paths.js";
4
+ import { parseYaml, stringifyYaml } from "../../../shared/yaml.js";
5
+ /** Validate context name is kebab-case per schema: ^[a-z][a-z0-9-]*$ */
6
+ function isValidContextName(name) {
7
+ return /^[a-z][a-z0-9-]*$/.test(name);
8
+ }
9
+ export function registerNewContext(program) {
10
+ program
11
+ .command("context <name>")
12
+ .description("Scaffold a new bounded context directory and register it in index.yml")
13
+ .option("-r, --root <path>", "Override repository root")
14
+ .option("-d, --description <text>", "Description of the bounded context")
15
+ .action((name, opts) => {
16
+ // Validate name
17
+ if (!isValidContextName(name)) {
18
+ console.error(`Error: Context name "${name}" is invalid. Use kebab-case (e.g. "order-management").`);
19
+ process.exit(1);
20
+ }
21
+ const ctxDir = join(contextsDir(opts.root), name);
22
+ // Guard: refuse if context directory already exists
23
+ if (existsSync(ctxDir)) {
24
+ console.error(`Error: Context "${name}" already exists at ${ctxDir}.`);
25
+ process.exit(1);
26
+ }
27
+ const description = opts.description ?? `The ${name} bounded context`;
28
+ // Create directory structure
29
+ const subDirs = ["events", "commands", "aggregates", "policies", "read-models"];
30
+ for (const sub of subDirs) {
31
+ mkdirSync(join(ctxDir, sub), { recursive: true });
32
+ }
33
+ // Write context.yml
34
+ const contextYaml = `# Bounded context metadata and glossary.
35
+ name: ${name}
36
+ description: ${description}
37
+ `;
38
+ writeFileSync(join(ctxDir, "context.yml"), contextYaml, "utf-8");
39
+ // Register in index.yml
40
+ const idxPath = indexFile(opts.root);
41
+ let index;
42
+ if (existsSync(idxPath)) {
43
+ const raw = readFileSync(idxPath, "utf-8");
44
+ index = parseYaml(raw);
45
+ }
46
+ else {
47
+ // Create index.yml if it doesn't exist
48
+ mkdirSync(join(idxPath, ".."), { recursive: true });
49
+ index = { contexts: [], flows: [] };
50
+ }
51
+ // Check if already registered
52
+ const alreadyRegistered = index.contexts.some((c) => c.name === name);
53
+ if (!alreadyRegistered) {
54
+ index.contexts.push({ name, description });
55
+ writeFileSync(idxPath, stringifyYaml(index), "utf-8");
56
+ }
57
+ console.log(`Created context "${name}":`);
58
+ console.log(` contexts/${name}/context.yml`);
59
+ for (const sub of subDirs) {
60
+ console.log(` contexts/${name}/${sub}/`);
61
+ }
62
+ if (!alreadyRegistered) {
63
+ console.log(`\nRegistered "${name}" in index.yml.`);
64
+ }
65
+ });
66
+ }
67
+ //# sourceMappingURL=new-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-context.js","sourceRoot":"","sources":["../../../../src/features/scaffold/commands/new-context.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGnE,wEAAwE;AACxE,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAY;IAC7C,OAAO;SACJ,OAAO,CAAC,gBAAgB,CAAC;SACzB,WAAW,CAAC,uEAAuE,CAAC;SACpF,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC;SACvD,MAAM,CAAC,0BAA0B,EAAE,oCAAoC,CAAC;SACxE,MAAM,CAAC,CAAC,IAAY,EAAE,IAA6C,EAAE,EAAE;QACtE,gBAAgB;QAChB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,KAAK,CACX,wBAAwB,IAAI,yDAAyD,CACtF,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,C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E,EAAE,EAAE,CAAC;QACtC,CAAC;QAED,8BAA8B;QAC9B,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;YAC3C,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,cAAc,CAAC,CAAC;QAC9C,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,iBAAiB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * `dkk new domain` command — scaffold a complete `.dkk/domain/` structure.
3
+ *
4
+ * Creates:
5
+ * .dkk/domain/index.yml — domain index with one sample context
6
+ * .dkk/domain/actors.yml — actors file with one sample actor
7
+ * .dkk/domain/contexts/sample/ — example bounded context with:
8
+ * context.yml, events/, commands/, aggregates/, policies/, read-models/
9
+ *
10
+ * Errors if `.dkk/domain/` already exists (use `--force` to overwrite).
11
+ */
12
+ import type { Command as Cmd } from "commander";
13
+ export declare function registerNewDomain(program: Cmd): void;
14
+ //# sourceMappingURL=new-domain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-domain.d.ts","sourceRoot":"","sources":["../../../../src/features/scaffold/commands/new-domain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AA0DhD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CA0CpD"}
@@ -0,0 +1,86 @@
1
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { domainDir } from "../../../shared/paths.js";
4
+ // ── Template content ──────────────────────────────────────────────────
5
+ const INDEX_YML = `# Domain index — registered bounded contexts and cross-context flows.
6
+ contexts:
7
+ - name: sample
8
+ description: Example bounded context (replace with your own)
9
+ flows: []
10
+ `;
11
+ const ACTORS_YML = `# Actors — people and systems that interact with the domain.
12
+ actors:
13
+ - name: User
14
+ type: human
15
+ description: A person who interacts with the system
16
+ `;
17
+ const CONTEXT_YML = `# Bounded context metadata and glossary.
18
+ name: sample
19
+ description: Example bounded context (replace with your own)
20
+ glossary:
21
+ - term: Example
22
+ definition: A sample glossary term to demonstrate the structure
23
+ `;
24
+ const SAMPLE_EVENT = `# Domain event — something that happened in the domain.
25
+ name: SampleCreated
26
+ description: Raised when a new sample entity is created
27
+ fields:
28
+ - name: sampleId
29
+ type: UUID
30
+ raised_by: Sample
31
+ `;
32
+ const SAMPLE_COMMAND = `# Command — an instruction to change domain state.
33
+ name: CreateSample
34
+ description: Create a new sample entity
35
+ actor: User
36
+ handled_by: Sample
37
+ `;
38
+ const SAMPLE_AGGREGATE = `# Aggregate — a consistency boundary that handles commands and emits events.
39
+ name: Sample
40
+ description: Sample aggregate root
41
+ handles:
42
+ commands:
43
+ - CreateSample
44
+ emits:
45
+ events:
46
+ - SampleCreated
47
+ `;
48
+ // ── Registration ──────────────────────────────────────────────────────
49
+ export function registerNewDomain(program) {
50
+ program
51
+ .command("domain")
52
+ .description("Scaffold a complete .dkk/domain/ structure with sample content")
53
+ .option("-r, --root <path>", "Override repository root")
54
+ .option("--force", "Overwrite existing .dkk/domain/ directory")
55
+ .action((opts) => {
56
+ const dir = domainDir(opts.root);
57
+ // Guard: refuse to overwrite unless --force
58
+ if (existsSync(dir) && !opts.force) {
59
+ console.error(`Error: ${dir} already exists. Use --force to overwrite.`);
60
+ process.exit(1);
61
+ }
62
+ // Create directory structure
63
+ const contextsBase = join(dir, "contexts", "sample");
64
+ const subDirs = ["events", "commands", "aggregates", "policies", "read-models"];
65
+ for (const sub of subDirs) {
66
+ mkdirSync(join(contextsBase, sub), { recursive: true });
67
+ }
68
+ // Write files
69
+ writeFileSync(join(dir, "index.yml"), INDEX_YML, "utf-8");
70
+ writeFileSync(join(dir, "actors.yml"), ACTORS_YML, "utf-8");
71
+ writeFileSync(join(contextsBase, "context.yml"), CONTEXT_YML, "utf-8");
72
+ writeFileSync(join(contextsBase, "events", "SampleCreated.yml"), SAMPLE_EVENT, "utf-8");
73
+ writeFileSync(join(contextsBase, "commands", "CreateSample.yml"), SAMPLE_COMMAND, "utf-8");
74
+ writeFileSync(join(contextsBase, "aggregates", "Sample.yml"), SAMPLE_AGGREGATE, "utf-8");
75
+ console.log("Created .dkk/domain/ with sample content:");
76
+ console.log(" index.yml");
77
+ console.log(" actors.yml");
78
+ console.log(" contexts/sample/");
79
+ console.log(" context.yml");
80
+ console.log(" events/SampleCreated.yml");
81
+ console.log(" commands/CreateSample.yml");
82
+ console.log(" aggregates/Sample.yml");
83
+ console.log("\nRun `dkk render` to validate and generate documentation.");
84
+ });
85
+ }
86
+ //# sourceMappingURL=new-domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-domain.js","sourceRoot":"","sources":["../../../../src/features/scaffold/commands/new-domain.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM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I,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAC1D,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC5D,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACvE,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,mBAAmB,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACxF,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,EAAE,kBAAkB,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;QAC3F,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAEzF,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -41,7 +41,7 @@ export function formatCliError(err) {
41
41
  const filePath = err.path ? ` "${err.path}"` : "";
42
42
  switch (err.code) {
43
43
  case "ENOENT":
44
- return `File not found:${filePath}. Check that the path exists and the domain/ directory is present.`;
44
+ return `File not found:${filePath}. Check that the path exists and the .dkk/domain/ directory is present.`;
45
45
  case "EACCES":
46
46
  case "EPERM":
47
47
  return `Permission denied:${filePath}. Check file permissions.`;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,OAAO,GAAG,YAAY,KAAK,IAAI,OAAQ,GAAuB,CAAC,IAAI,KAAK,QAAQ,CAAC;AACnF,CAAC;AAYD,MAAM,UAAU,eAAe,CAAC,GAAY;IAC1C,OAAO,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,CAAC;AAC9D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,uBAAuB;IACvB,IAAI,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,qBAAqB,CAAC;QACnD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,gDAAgD;YAChD,MAAM,QAAQ,GAAG,QAAQ,IAAI,CAAC,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3E,IAAI,GAAG,GAAG,0BAA0B,MAAM,KAAK,IAAI,GAAG,QAAQ,GAAG,CAAC;YAClE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,GAAG,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7B,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CA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AAE,CAAC;QACrE,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,CAAC;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC"}
@@ -9,7 +9,7 @@ export * from "./types/index.js";
9
9
  export { type ItemType, type AnyDomainItem, ITEM_TYPES, itemName, itemDescription, itemAdrRefs, forEachItem, mapItems, } from "./item-visitor.js";
10
10
  export { loadDomainModel, type LoaderOptions } from "./loader.js";
11
11
  export { DomainGraph, type NodeKind, type GraphNode, type GraphEdge } from "./graph.js";
12
- export { repoRoot, domainDir, contextsDir, actorsFile, indexFile, adrDir, docsDir, templatesDir, schemaDir, repoRelative, } from "./paths.js";
12
+ export { repoRoot, packageRoot, domainDir, contextsDir, actorsFile, indexFile, adrDir, docsDir, templatesDir, schemaDir, repoRelative, } from "./paths.js";
13
13
  export { parseYaml, stringifyYaml } from "./yaml.js";
14
14
  export { parseAdrFrontmatter, parseAdrFile } from "./adr-parser.js";
15
15
  export { formatCliError, isYAMLException, isNodeSystemError } from "./errors.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGxF,OAAO,EACL,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAGxF,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -14,7 +14,7 @@ export { loadDomainModel } from "./loader.js";
14
14
  // ── Graph ─────────────────────────────────────────────────────────────
15
15
  export { DomainGraph } from "./graph.js";
16
16
  // ── Path helpers ──────────────────────────────────────────────────────
17
- export { repoRoot, domainDir, contextsDir, actorsFile, indexFile, adrDir, docsDir, templatesDir, schemaDir, repoRelative, } from "./paths.js";
17
+ export { repoRoot, packageRoot, domainDir, contextsDir, actorsFile, indexFile, adrDir, docsDir, templatesDir, schemaDir, repoRelative, } from "./paths.js";
18
18
  // ── YAML helpers ──────────────────────────────────────────────────────
19
19
  export { parseYaml, stringifyYaml } from "./yaml.js";
20
20
  // ── ADR parser ────────────────────────────────────────────────────────
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yEAAyE;AACzE,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,yEAAyE;AACzE,OAAO,EAGL,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAE3B,yEAAyE;AACzE,OAAO,EAAE,eAAe,EAAsB,MAAM,aAAa,CAAC;AAElE,yEAAyE;AACzE,OAAO,EAAE,WAAW,EAAiD,MAAM,YAAY,CAAC;AAExF,yEAAyE;AACzE,OAAO,EACL,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAErD,yEAAyE;AACzE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,yEAAyE;AACzE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yEAAyE;AACzE,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,yEAAyE;AACzE,OAAO,EAGL,UAAU,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,WAAW,EACX,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAE3B,yEAAyE;AACzE,OAAO,EAAE,eAAe,EAAsB,MAAM,aAAa,CAAC;AAElE,yEAAyE;AACzE,OAAO,EAAE,WAAW,EAAiD,MAAM,YAAY,CAAC;AAExF,yEAAyE;AACzE,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAErD,yEAAyE;AACzE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,yEAAyE;AACzE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Domain model loader.
3
3
  *
4
- * Recursively walks `domain/` and `.dkk/adr/` to discover all YAML
4
+ * Recursively walks `.dkk/domain/` and `.dkk/adr/` to discover all YAML
5
5
  * definition files and ADR Markdown files, then assembles and returns
6
6
  * a fully-typed {@link DomainModel}.
7
7
  *
8
8
  * Context layout (per-item directory format):
9
9
  *
10
- * domain/contexts/<name>/
10
+ * .dkk/domain/contexts/<name>/
11
11
  * context.yml ← metadata: name, description, glossary
12
12
  * events/ ← one .yml file per DomainEvent
13
13
  * commands/ ← one .yml file per Command
@@ -1,29 +1,50 @@
1
1
  /**
2
- * Resolve the repository root.
2
+ * Resolve the DKK package installation root.
3
3
  *
4
4
  * When running from source (`tsx src/cli.ts`) `import.meta.dirname`
5
- * points at `src/shared/`, so we go up two levels. When running from
5
+ * points at `src/shared/`, so we go up two levels. When running from
6
6
  * the compiled output (`dist/shared/`) we also go up two levels.
7
7
  *
8
- * Callers can override by passing an explicit `repoRoot`.
8
+ * Used exclusively for locating package-bundled assets (schemas,
9
+ * templates).
10
+ */
11
+ export declare function packageRoot(): string;
12
+ /**
13
+ * Resolve the project root (where `.dkk/` lives).
14
+ *
15
+ * Defaults to `process.cwd()` so that DKK works correctly whether it
16
+ * is run from source, from a global install, or as a project dependency.
17
+ *
18
+ * Callers can override by passing an explicit root path (the `--root`
19
+ * CLI flag).
9
20
  */
10
21
  export declare function repoRoot(override?: string): string;
11
- /** Absolute path to the `domain/` directory. */
22
+ /** Absolute path to the `.dkk/domain/` directory. */
12
23
  export declare function domainDir(root?: string): string;
13
- /** Absolute path to `domain/contexts/`. */
24
+ /** Absolute path to `.dkk/domain/contexts/`. */
14
25
  export declare function contextsDir(root?: string): string;
15
- /** Absolute path to `domain/actors.yml`. */
26
+ /** Absolute path to `.dkk/domain/actors.yml`. */
16
27
  export declare function actorsFile(root?: string): string;
17
- /** Absolute path to `domain/index.yml`. */
28
+ /** Absolute path to `.dkk/domain/index.yml`. */
18
29
  export declare function indexFile(root?: string): string;
19
30
  /** Absolute path to `.dkk/adr/`. */
20
31
  export declare function adrDir(root?: string): string;
21
32
  /** Absolute path to `.dkk/docs/` (rendered output). */
22
33
  export declare function docsDir(root?: string): string;
23
- /** Absolute path to `tools/dkk/templates/`. */
24
- export declare function templatesDir(root?: string): string;
25
- /** Absolute path to `tools/dkk/schema/`. */
26
- export declare function schemaDir(root?: string): string;
34
+ /**
35
+ * Absolute path to `tools/dkk/templates/`.
36
+ *
37
+ * Always resolves relative to the DKK package installation so that
38
+ * templates are found regardless of the user's working directory.
39
+ */
40
+ export declare function templatesDir(): string;
41
+ /**
42
+ * Absolute path to `tools/dkk/schema/`.
43
+ *
44
+ * Always resolves relative to the DKK package installation so that
45
+ * schemas are found regardless of the user's working directory.
46
+ */
47
+ export declare function schemaDir(): string;
27
48
  /**
28
49
  * Turn an absolute path into a repo-relative POSIX path
29
50
  * (forward slashes, no leading `./`).
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/shared/paths.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAIlD;AAED,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,2CAA2C;AAC3C,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,2CAA2C;AAC3C,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,oCAAoC;AACpC,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,uDAAuD;AACvD,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,4CAA4C;AAC5C,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnE"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/shared/paths.ts"],"names":[],"mappings":"AAeA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAGpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,iDAAiD;AACjD,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,oCAAoC;AACpC,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,uDAAuD;AACvD,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEnE"}
@@ -1,38 +1,58 @@
1
1
  /**
2
- * Repo-relative path resolution utilities.
2
+ * Path resolution utilities.
3
3
  *
4
- * Every path helper resolves relative to the repository root
5
- * so callers never need to worry about the working directory.
4
+ * Two resolution strategies:
5
+ *
6
+ * 1. **Project paths** (`repoRoot`, `domainDir`, `docsDir`, …) resolve
7
+ * from `process.cwd()` (or an explicit `--root` override). This is
8
+ * the user's project directory — where `.dkk/domain/` lives.
9
+ *
10
+ * 2. **Package asset paths** (`packageRoot`, `schemaDir`, `templatesDir`)
11
+ * resolve from `import.meta.dirname` relative to the DKK package
12
+ * install. Schemas and Handlebars templates ship with the package.
6
13
  */
7
14
  import { resolve, join, relative } from "node:path";
8
15
  /**
9
- * Resolve the repository root.
16
+ * Resolve the DKK package installation root.
10
17
  *
11
18
  * When running from source (`tsx src/cli.ts`) `import.meta.dirname`
12
- * points at `src/shared/`, so we go up two levels. When running from
19
+ * points at `src/shared/`, so we go up two levels. When running from
13
20
  * the compiled output (`dist/shared/`) we also go up two levels.
14
21
  *
15
- * Callers can override by passing an explicit `repoRoot`.
22
+ * Used exclusively for locating package-bundled assets (schemas,
23
+ * templates).
24
+ */
25
+ export function packageRoot() {
26
+ // import.meta.dirname is src/shared or dist/shared
27
+ return resolve(import.meta.dirname, "../..");
28
+ }
29
+ /**
30
+ * Resolve the project root (where `.dkk/` lives).
31
+ *
32
+ * Defaults to `process.cwd()` so that DKK works correctly whether it
33
+ * is run from source, from a global install, or as a project dependency.
34
+ *
35
+ * Callers can override by passing an explicit root path (the `--root`
36
+ * CLI flag).
16
37
  */
17
38
  export function repoRoot(override) {
18
39
  if (override)
19
40
  return resolve(override);
20
- // import.meta.dirname is src/shared or dist/shared
21
- return resolve(import.meta.dirname, "../..");
41
+ return resolve(process.cwd());
22
42
  }
23
- /** Absolute path to the `domain/` directory. */
43
+ /** Absolute path to the `.dkk/domain/` directory. */
24
44
  export function domainDir(root) {
25
- return join(repoRoot(root), "domain");
45
+ return join(repoRoot(root), ".dkk", "domain");
26
46
  }
27
- /** Absolute path to `domain/contexts/`. */
47
+ /** Absolute path to `.dkk/domain/contexts/`. */
28
48
  export function contextsDir(root) {
29
49
  return join(domainDir(root), "contexts");
30
50
  }
31
- /** Absolute path to `domain/actors.yml`. */
51
+ /** Absolute path to `.dkk/domain/actors.yml`. */
32
52
  export function actorsFile(root) {
33
53
  return join(domainDir(root), "actors.yml");
34
54
  }
35
- /** Absolute path to `domain/index.yml`. */
55
+ /** Absolute path to `.dkk/domain/index.yml`. */
36
56
  export function indexFile(root) {
37
57
  return join(domainDir(root), "index.yml");
38
58
  }
@@ -44,13 +64,23 @@ export function adrDir(root) {
44
64
  export function docsDir(root) {
45
65
  return join(repoRoot(root), ".dkk", "docs");
46
66
  }
47
- /** Absolute path to `tools/dkk/templates/`. */
48
- export function templatesDir(root) {
49
- return join(repoRoot(root), "tools", "dkk", "templates");
67
+ /**
68
+ * Absolute path to `tools/dkk/templates/`.
69
+ *
70
+ * Always resolves relative to the DKK package installation so that
71
+ * templates are found regardless of the user's working directory.
72
+ */
73
+ export function templatesDir() {
74
+ return join(packageRoot(), "tools", "dkk", "templates");
50
75
  }
51
- /** Absolute path to `tools/dkk/schema/`. */
52
- export function schemaDir(root) {
53
- return join(repoRoot(root), "tools", "dkk", "schema");
76
+ /**
77
+ * Absolute path to `tools/dkk/schema/`.
78
+ *
79
+ * Always resolves relative to the DKK package installation so that
80
+ * schemas are found regardless of the user's working directory.
81
+ */
82
+ export function schemaDir() {
83
+ return join(packageRoot(), "tools", "dkk", "schema");
54
84
  }
55
85
  /**
56
86
  * Turn an absolute path into a repo-relative POSIX path
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/shared/paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAiB;IACxC,IAAI,QAAQ;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,oDAAoD;IACpD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;AAC3C,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,UAAU,CAAC,IAAa;IACt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