domain-knowledge-kit 0.2.15 → 0.2.19

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 (210) hide show
  1. package/README.md +4 -0
  2. package/dist/cli.js +24 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/features/agent/commands/init.d.ts +90 -1
  5. package/dist/features/agent/commands/init.d.ts.map +1 -1
  6. package/dist/features/agent/commands/init.js +328 -32
  7. package/dist/features/agent/commands/init.js.map +1 -1
  8. package/dist/features/agent/commands/prime.d.ts +11 -0
  9. package/dist/features/agent/commands/prime.d.ts.map +1 -1
  10. package/dist/features/agent/commands/prime.js +105 -8
  11. package/dist/features/agent/commands/prime.js.map +1 -1
  12. package/dist/features/agent/commands/update.d.ts +27 -0
  13. package/dist/features/agent/commands/update.d.ts.map +1 -0
  14. package/dist/features/agent/commands/update.js +316 -0
  15. package/dist/features/agent/commands/update.js.map +1 -0
  16. package/dist/features/agent/dkk-artifacts.d.ts +76 -0
  17. package/dist/features/agent/dkk-artifacts.d.ts.map +1 -0
  18. package/dist/features/agent/dkk-artifacts.js +328 -0
  19. package/dist/features/agent/dkk-artifacts.js.map +1 -0
  20. package/dist/features/agent/install-mode.d.ts +34 -0
  21. package/dist/features/agent/install-mode.d.ts.map +1 -0
  22. package/dist/features/agent/install-mode.js +78 -0
  23. package/dist/features/agent/install-mode.js.map +1 -0
  24. package/dist/features/agent/mcp-register.d.ts +20 -0
  25. package/dist/features/agent/mcp-register.d.ts.map +1 -0
  26. package/dist/features/agent/mcp-register.js +116 -0
  27. package/dist/features/agent/mcp-register.js.map +1 -0
  28. package/dist/features/agent/settings-prune.d.ts +29 -0
  29. package/dist/features/agent/settings-prune.d.ts.map +1 -0
  30. package/dist/features/agent/settings-prune.js +70 -0
  31. package/dist/features/agent/settings-prune.js.map +1 -0
  32. package/dist/features/agent/tests/settings-prune.test.d.ts +2 -0
  33. package/dist/features/agent/tests/settings-prune.test.d.ts.map +1 -0
  34. package/dist/features/agent/tests/settings-prune.test.js +118 -0
  35. package/dist/features/agent/tests/settings-prune.test.js.map +1 -0
  36. package/dist/features/federation/commands/consumers.d.ts +40 -0
  37. package/dist/features/federation/commands/consumers.d.ts.map +1 -0
  38. package/dist/features/federation/commands/consumers.js +126 -0
  39. package/dist/features/federation/commands/consumers.js.map +1 -0
  40. package/dist/features/federation/commands/peers-add.d.ts +14 -0
  41. package/dist/features/federation/commands/peers-add.d.ts.map +1 -0
  42. package/dist/features/federation/commands/peers-add.js +79 -0
  43. package/dist/features/federation/commands/peers-add.js.map +1 -0
  44. package/dist/features/federation/commands/peers-list.d.ts +8 -0
  45. package/dist/features/federation/commands/peers-list.d.ts.map +1 -0
  46. package/dist/features/federation/commands/peers-list.js +51 -0
  47. package/dist/features/federation/commands/peers-list.js.map +1 -0
  48. package/dist/features/federation/commands/peers-status.d.ts +8 -0
  49. package/dist/features/federation/commands/peers-status.d.ts.map +1 -0
  50. package/dist/features/federation/commands/peers-status.js +78 -0
  51. package/dist/features/federation/commands/peers-status.js.map +1 -0
  52. package/dist/features/federation/commands/pull.d.ts +18 -0
  53. package/dist/features/federation/commands/pull.d.ts.map +1 -0
  54. package/dist/features/federation/commands/pull.js +153 -0
  55. package/dist/features/federation/commands/pull.js.map +1 -0
  56. package/dist/features/federation/git-fetcher.d.ts +45 -0
  57. package/dist/features/federation/git-fetcher.d.ts.map +1 -0
  58. package/dist/features/federation/git-fetcher.js +70 -0
  59. package/dist/features/federation/git-fetcher.js.map +1 -0
  60. package/dist/features/federation/loader.d.ts +60 -0
  61. package/dist/features/federation/loader.d.ts.map +1 -0
  62. package/dist/features/federation/loader.js +193 -0
  63. package/dist/features/federation/loader.js.map +1 -0
  64. package/dist/features/federation/lock.d.ts +12 -0
  65. package/dist/features/federation/lock.d.ts.map +1 -0
  66. package/dist/features/federation/lock.js +48 -0
  67. package/dist/features/federation/lock.js.map +1 -0
  68. package/dist/features/federation/tests/git-fetcher.test.d.ts +2 -0
  69. package/dist/features/federation/tests/git-fetcher.test.d.ts.map +1 -0
  70. package/dist/features/federation/tests/git-fetcher.test.js +167 -0
  71. package/dist/features/federation/tests/git-fetcher.test.js.map +1 -0
  72. package/dist/features/federation/tests/loader.test.d.ts +2 -0
  73. package/dist/features/federation/tests/loader.test.d.ts.map +1 -0
  74. package/dist/features/federation/tests/loader.test.js +144 -0
  75. package/dist/features/federation/tests/loader.test.js.map +1 -0
  76. package/dist/features/federation/tests/phase5.test.d.ts +2 -0
  77. package/dist/features/federation/tests/phase5.test.d.ts.map +1 -0
  78. package/dist/features/federation/tests/phase5.test.js +137 -0
  79. package/dist/features/federation/tests/phase5.test.js.map +1 -0
  80. package/dist/features/federation/tests/schema-load.test.d.ts +2 -0
  81. package/dist/features/federation/tests/schema-load.test.d.ts.map +1 -0
  82. package/dist/features/federation/tests/schema-load.test.js +97 -0
  83. package/dist/features/federation/tests/schema-load.test.js.map +1 -0
  84. package/dist/features/federation/tests/validator.test.d.ts +2 -0
  85. package/dist/features/federation/tests/validator.test.d.ts.map +1 -0
  86. package/dist/features/federation/tests/validator.test.js +319 -0
  87. package/dist/features/federation/tests/validator.test.js.map +1 -0
  88. package/dist/features/mcp/commands/serve.d.ts +10 -0
  89. package/dist/features/mcp/commands/serve.d.ts.map +1 -0
  90. package/dist/features/mcp/commands/serve.js +12 -0
  91. package/dist/features/mcp/commands/serve.js.map +1 -0
  92. package/dist/features/mcp/server.d.ts +15 -0
  93. package/dist/features/mcp/server.d.ts.map +1 -0
  94. package/dist/features/mcp/server.js +438 -0
  95. package/dist/features/mcp/server.js.map +1 -0
  96. package/dist/features/pipeline/commands/validate.d.ts.map +1 -1
  97. package/dist/features/pipeline/commands/validate.js +7 -0
  98. package/dist/features/pipeline/commands/validate.js.map +1 -1
  99. package/dist/features/pipeline/indexer.d.ts +28 -2
  100. package/dist/features/pipeline/indexer.d.ts.map +1 -1
  101. package/dist/features/pipeline/indexer.js +82 -27
  102. package/dist/features/pipeline/indexer.js.map +1 -1
  103. package/dist/features/pipeline/validator.d.ts +10 -0
  104. package/dist/features/pipeline/validator.d.ts.map +1 -1
  105. package/dist/features/pipeline/validator.js +274 -27
  106. package/dist/features/pipeline/validator.js.map +1 -1
  107. package/dist/features/query/commands/list.d.ts +10 -0
  108. package/dist/features/query/commands/list.d.ts.map +1 -1
  109. package/dist/features/query/commands/list.js +1 -1
  110. package/dist/features/query/commands/list.js.map +1 -1
  111. package/dist/features/query/commands/locate.d.ts +1 -0
  112. package/dist/features/query/commands/locate.d.ts.map +1 -1
  113. package/dist/features/query/commands/locate.js +1 -1
  114. package/dist/features/query/commands/locate.js.map +1 -1
  115. package/dist/features/query/commands/search.d.ts.map +1 -1
  116. package/dist/features/query/commands/search.js +2 -0
  117. package/dist/features/query/commands/search.js.map +1 -1
  118. package/dist/features/query/commands/show.d.ts +15 -0
  119. package/dist/features/query/commands/show.d.ts.map +1 -1
  120. package/dist/features/query/commands/show.js +116 -58
  121. package/dist/features/query/commands/show.js.map +1 -1
  122. package/dist/features/query/commands/story.d.ts +70 -0
  123. package/dist/features/query/commands/story.d.ts.map +1 -1
  124. package/dist/features/query/commands/story.js +2 -2
  125. package/dist/features/query/commands/story.js.map +1 -1
  126. package/dist/features/query/commands/summary.d.ts +3 -0
  127. package/dist/features/query/commands/summary.d.ts.map +1 -1
  128. package/dist/features/query/commands/summary.js +1 -1
  129. package/dist/features/query/commands/summary.js.map +1 -1
  130. package/dist/features/query/searcher.d.ts +18 -1
  131. package/dist/features/query/searcher.d.ts.map +1 -1
  132. package/dist/features/query/searcher.js +11 -2
  133. package/dist/features/query/searcher.js.map +1 -1
  134. package/dist/features/scaffold/commands/new-domain.d.ts +22 -0
  135. package/dist/features/scaffold/commands/new-domain.d.ts.map +1 -1
  136. package/dist/features/scaffold/commands/new-domain.js +44 -28
  137. package/dist/features/scaffold/commands/new-domain.js.map +1 -1
  138. package/dist/features/scaffold/commands/service-init.d.ts +12 -0
  139. package/dist/features/scaffold/commands/service-init.d.ts.map +1 -0
  140. package/dist/features/scaffold/commands/service-init.js +69 -0
  141. package/dist/features/scaffold/commands/service-init.js.map +1 -0
  142. package/dist/shared/graph.d.ts +8 -0
  143. package/dist/shared/graph.d.ts.map +1 -1
  144. package/dist/shared/graph.js +180 -112
  145. package/dist/shared/graph.js.map +1 -1
  146. package/dist/shared/index.d.ts +4 -1
  147. package/dist/shared/index.d.ts.map +1 -1
  148. package/dist/shared/index.js +6 -1
  149. package/dist/shared/index.js.map +1 -1
  150. package/dist/shared/loader.d.ts +22 -0
  151. package/dist/shared/loader.d.ts.map +1 -1
  152. package/dist/shared/loader.js +31 -1
  153. package/dist/shared/loader.js.map +1 -1
  154. package/dist/shared/paths.d.ts +59 -7
  155. package/dist/shared/paths.d.ts.map +1 -1
  156. package/dist/shared/paths.js +93 -11
  157. package/dist/shared/paths.js.map +1 -1
  158. package/dist/shared/refs.d.ts +96 -0
  159. package/dist/shared/refs.d.ts.map +1 -0
  160. package/dist/shared/refs.js +182 -0
  161. package/dist/shared/refs.js.map +1 -0
  162. package/dist/shared/service-id.d.ts +11 -0
  163. package/dist/shared/service-id.d.ts.map +1 -0
  164. package/dist/shared/service-id.js +64 -0
  165. package/dist/shared/service-id.js.map +1 -0
  166. package/dist/shared/tests/paths.test.d.ts +2 -0
  167. package/dist/shared/tests/paths.test.d.ts.map +1 -0
  168. package/dist/shared/tests/paths.test.js +111 -0
  169. package/dist/shared/tests/paths.test.js.map +1 -0
  170. package/dist/shared/tests/refs.test.d.ts +2 -0
  171. package/dist/shared/tests/refs.test.d.ts.map +1 -0
  172. package/dist/shared/tests/refs.test.js +104 -0
  173. package/dist/shared/tests/refs.test.js.map +1 -0
  174. package/dist/shared/types/domain.d.ts +14 -0
  175. package/dist/shared/types/domain.d.ts.map +1 -1
  176. package/dist/shared/types/federation.d.ts +60 -0
  177. package/dist/shared/types/federation.d.ts.map +1 -0
  178. package/dist/shared/types/federation.js +12 -0
  179. package/dist/shared/types/federation.js.map +1 -0
  180. package/dist/version.d.ts +4 -0
  181. package/dist/version.d.ts.map +1 -0
  182. package/dist/version.js +15 -0
  183. package/dist/version.js.map +1 -0
  184. package/package.json +8 -5
  185. package/tools/dkk/claude/agents/dkk-domain-reviewer.md +69 -0
  186. package/tools/dkk/claude/commands/dkk-adr.md +11 -0
  187. package/tools/dkk/claude/commands/dkk-impact.md +34 -0
  188. package/tools/dkk/claude/commands/dkk-implement.md +12 -0
  189. package/tools/dkk/claude/commands/dkk-prime.md +6 -0
  190. package/tools/dkk/claude/commands/dkk-review.md +12 -0
  191. package/tools/dkk/claude/commands/dkk-story.md +12 -0
  192. package/tools/dkk/claude/hooks/post-edit-validate.mjs +68 -0
  193. package/tools/dkk/claude/hooks/pre-edit-block-generated.mjs +39 -0
  194. package/tools/dkk/claude/hooks/session-start-prime.mjs +20 -0
  195. package/tools/dkk/claude/hooks/stop-validate.mjs +67 -0
  196. package/tools/dkk/claude/settings.json +62 -0
  197. package/tools/dkk/claude/skills/dkk-adr-author/SKILL.md +54 -0
  198. package/tools/dkk/claude/skills/dkk-flow-implementer/SKILL.md +51 -0
  199. package/tools/dkk/claude/skills/dkk-story-analyst/SKILL.md +108 -0
  200. package/tools/dkk/schema/actors.schema.json +1 -1
  201. package/tools/dkk/schema/adr-frontmatter.schema.json +4 -4
  202. package/tools/dkk/schema/aggregate.schema.json +1 -1
  203. package/tools/dkk/schema/command.schema.json +1 -1
  204. package/tools/dkk/schema/event.schema.json +1 -1
  205. package/tools/dkk/schema/federation.schema.json +71 -0
  206. package/tools/dkk/schema/glossary.schema.json +1 -1
  207. package/tools/dkk/schema/index.schema.json +2 -2
  208. package/tools/dkk/schema/policy.schema.json +1 -1
  209. package/tools/dkk/schema/read-model.schema.json +1 -1
  210. package/tools/dkk/schema/service.schema.json +30 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Repo-relative paths that previous DKK versions installed but the current
3
+ * release no longer ships. `dkk update` removes any of these still present
4
+ * in a target repo. Append new entries here when a template file is
5
+ * renamed or retired.
6
+ */
7
+ export declare const LEGACY_DKK_PATHS: readonly string[];
8
+ export interface ClaudeArtifactInventory {
9
+ /** `.claude/hooks/<basename>.mjs` filenames the bundled template installs. */
10
+ hooks: string[];
11
+ /** `.claude/skills/<skill>/` directories the bundled template installs (matches the `dkk-*` prefix). */
12
+ skills: string[];
13
+ /** `.claude/agents/<agent>.md` filenames the bundled template installs. */
14
+ agents: string[];
15
+ /** `.claude/commands/<command>.md` filenames the bundled template installs. */
16
+ commands: string[];
17
+ }
18
+ /**
19
+ * Walk `tools/dkk/claude/` in the running DKK package and return the set of
20
+ * artifact basenames the template currently ships. Derived at runtime so
21
+ * future template additions don't require code changes here.
22
+ */
23
+ export declare function dkkClaudeFiles(): ClaudeArtifactInventory;
24
+ /**
25
+ * Skill directories the bundled `.github/skills/` template installs (e.g.
26
+ * `dkk-flow-implementer`). Returned as bare directory names.
27
+ */
28
+ export declare function dkkGithubSkillDirs(): string[];
29
+ /**
30
+ * `permissions.allow` entries the bundled `settings.json` template ships.
31
+ * Empty array if the template is missing or unparseable — callers should
32
+ * treat that as "DKK doesn't own any permissions" rather than erroring.
33
+ */
34
+ export declare function dkkPermissionAllowEntries(): string[];
35
+ /**
36
+ * Hook script basenames referenced by the bundled `settings.json` template
37
+ * (e.g. `session-start-prime.mjs`). Used to identify DKK-owned hook entries
38
+ * in a consumer's settings.json so they can be pruned cleanly.
39
+ */
40
+ export declare function dkkHookBasenames(): string[];
41
+ /**
42
+ * Result of scanning a target repo for every DKK-managed artifact path.
43
+ * Paths are absolute. Use {@link computeArtifactDiff} for the add / replace /
44
+ * remove triage.
45
+ */
46
+ export interface InstalledArtifactScan {
47
+ dkkPrefixedClaude: string[];
48
+ dkkHooks: string[];
49
+ githubSkillDirs: string[];
50
+ legacy: string[];
51
+ }
52
+ /**
53
+ * Walk a target repo's `.claude/` and `.github/skills/` trees and return
54
+ * the set of paths the predicates flag as DKK-managed.
55
+ */
56
+ export declare function scanInstalledArtifacts(root: string): InstalledArtifactScan;
57
+ export interface ArtifactDiff {
58
+ /** Files in the new template that aren't present in the target repo. */
59
+ toAdd: string[];
60
+ /** Files present in both but with different content. */
61
+ toReplace: string[];
62
+ /** Files present locally that DKK no longer ships (renamed/removed templates + legacy paths). */
63
+ toRemove: string[];
64
+ }
65
+ /**
66
+ * Compute the add / replace / remove triage between the bundled template
67
+ * and a target repo. Paths are returned as repo-relative POSIX paths.
68
+ *
69
+ * `toAdd` and `toReplace` are derived by enumerating the bundled template's
70
+ * shipped files; `toRemove` is the set of installed DKK-managed paths that
71
+ * have no counterpart in the new template.
72
+ */
73
+ export declare function computeArtifactDiff(root: string): ArtifactDiff;
74
+ /** True if `name` (basename or first path segment) starts with `dkk-`. */
75
+ export declare function isDkkPrefixed(path: string): boolean;
76
+ //# sourceMappingURL=dkk-artifacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dkk-artifacts.d.ts","sourceRoot":"","sources":["../../../src/features/agent/dkk-artifacts.ts"],"names":[],"mappings":"AAyBA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAE7C,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,8EAA8E;IAC9E,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,wGAAwG;IACxG,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,2EAA2E;IAC3E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAUxD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAI7C;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,EAAE,CAIpD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAa3C;AA8BD;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IAEpC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAE5B,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB,eAAe,EAAE,MAAM,EAAE,CAAC;IAE1B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAkD1E;AAED,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,wDAAwD;IACxD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iGAAiG;IACjG,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAqG9D;AAcD,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD"}
@@ -0,0 +1,328 @@
1
+ /**
2
+ * Canonical identification of DKK-managed AI assistant artifacts in a
3
+ * consumer's repo. Used by `dkk update` to safely sweep stale files and
4
+ * prune stale settings.json entries without touching user-authored content.
5
+ *
6
+ * Naming convention (single source of truth — keep changes here):
7
+ *
8
+ * - **Files** in `.claude/skills/`, `.claude/agents/`, `.claude/commands/`
9
+ * are DKK-managed if their first path segment matches `dkk-*`.
10
+ * - **Hooks** in `.claude/hooks/` are identified by basename — only those
11
+ * whose `.mjs` filename appears in the bundled settings.json template's
12
+ * hook command strings are owned by DKK.
13
+ * - **Skill directories** in `.github/skills/` are DKK-managed if they
14
+ * match `dkk-*`.
15
+ * - **permissions.allow** entries are DKK-managed iff they appear verbatim
16
+ * in the bundled settings.json template's `permissions.allow`.
17
+ * - **LEGACY_DKK_PATHS** captures artifact paths that prior versions of
18
+ * DKK installed and that current versions no longer ship — `update`
19
+ * removes them so users on old releases don't carry stale files forever.
20
+ */
21
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
22
+ import { basename, join, relative } from "node:path";
23
+ import { packageClaudeDir, packageSkillsDir } from "../../shared/paths.js";
24
+ import { extractHookBasename } from "./commands/init.js";
25
+ /**
26
+ * Repo-relative paths that previous DKK versions installed but the current
27
+ * release no longer ships. `dkk update` removes any of these still present
28
+ * in a target repo. Append new entries here when a template file is
29
+ * renamed or retired.
30
+ */
31
+ export const LEGACY_DKK_PATHS = [
32
+ ".github/skills/dkk-domain-knowledge",
33
+ ];
34
+ /**
35
+ * Walk `tools/dkk/claude/` in the running DKK package and return the set of
36
+ * artifact basenames the template currently ships. Derived at runtime so
37
+ * future template additions don't require code changes here.
38
+ */
39
+ export function dkkClaudeFiles() {
40
+ const inv = { hooks: [], skills: [], agents: [], commands: [] };
41
+ const src = packageClaudeDir();
42
+ if (!existsSync(src))
43
+ return inv;
44
+ inv.hooks = listFilesIfDir(join(src, "hooks"));
45
+ inv.skills = listDirsIfDir(join(src, "skills"));
46
+ inv.agents = listFilesIfDir(join(src, "agents"));
47
+ inv.commands = listFilesIfDir(join(src, "commands"));
48
+ return inv;
49
+ }
50
+ /**
51
+ * Skill directories the bundled `.github/skills/` template installs (e.g.
52
+ * `dkk-flow-implementer`). Returned as bare directory names.
53
+ */
54
+ export function dkkGithubSkillDirs() {
55
+ const src = packageSkillsDir();
56
+ if (!existsSync(src))
57
+ return [];
58
+ return listDirsIfDir(src);
59
+ }
60
+ /**
61
+ * `permissions.allow` entries the bundled `settings.json` template ships.
62
+ * Empty array if the template is missing or unparseable — callers should
63
+ * treat that as "DKK doesn't own any permissions" rather than erroring.
64
+ */
65
+ export function dkkPermissionAllowEntries() {
66
+ const settings = readBundledSettings();
67
+ if (!settings)
68
+ return [];
69
+ return settings.permissions?.allow ?? [];
70
+ }
71
+ /**
72
+ * Hook script basenames referenced by the bundled `settings.json` template
73
+ * (e.g. `session-start-prime.mjs`). Used to identify DKK-owned hook entries
74
+ * in a consumer's settings.json so they can be pruned cleanly.
75
+ */
76
+ export function dkkHookBasenames() {
77
+ const settings = readBundledSettings();
78
+ if (!settings?.hooks)
79
+ return [];
80
+ const out = new Set();
81
+ for (const entries of Object.values(settings.hooks)) {
82
+ for (const entry of entries) {
83
+ for (const hook of entry.hooks ?? []) {
84
+ const b = extractHookBasename(hook.command);
85
+ if (b)
86
+ out.add(b);
87
+ }
88
+ }
89
+ }
90
+ return [...out];
91
+ }
92
+ /**
93
+ * Read and parse the bundled `settings.json` template. Returns `null` if
94
+ * the file is missing or unparseable (failures are silent — see callers).
95
+ */
96
+ function readBundledSettings() {
97
+ const path = join(packageClaudeDir(), "settings.json");
98
+ if (!existsSync(path))
99
+ return null;
100
+ try {
101
+ return JSON.parse(readFileSync(path, "utf-8"));
102
+ }
103
+ catch {
104
+ return null;
105
+ }
106
+ }
107
+ function listFilesIfDir(dir) {
108
+ if (!existsSync(dir))
109
+ return [];
110
+ return readdirSync(dir).filter((n) => {
111
+ try {
112
+ return statSync(join(dir, n)).isFile();
113
+ }
114
+ catch {
115
+ return false;
116
+ }
117
+ });
118
+ }
119
+ function listDirsIfDir(dir) {
120
+ if (!existsSync(dir))
121
+ return [];
122
+ return readdirSync(dir).filter((n) => {
123
+ try {
124
+ return statSync(join(dir, n)).isDirectory();
125
+ }
126
+ catch {
127
+ return false;
128
+ }
129
+ });
130
+ }
131
+ /**
132
+ * Walk a target repo's `.claude/` and `.github/skills/` trees and return
133
+ * the set of paths the predicates flag as DKK-managed.
134
+ */
135
+ export function scanInstalledArtifacts(root) {
136
+ const hookBasenames = new Set(dkkHookBasenames());
137
+ const scan = {
138
+ dkkPrefixedClaude: [],
139
+ dkkHooks: [],
140
+ githubSkillDirs: [],
141
+ legacy: [],
142
+ };
143
+ // .claude/skills, .claude/agents, .claude/commands — match dkk-* prefix.
144
+ for (const sub of ["skills", "agents", "commands"]) {
145
+ const dir = join(root, ".claude", sub);
146
+ if (!existsSync(dir))
147
+ continue;
148
+ for (const name of readdirSync(dir)) {
149
+ if (!name.startsWith("dkk-"))
150
+ continue;
151
+ const path = join(dir, name);
152
+ // skills/ is nested (one dir per skill); agents/ + commands/ are flat files.
153
+ if (sub === "skills") {
154
+ // Push the directory itself; sweep deletes recursively.
155
+ scan.dkkPrefixedClaude.push(path);
156
+ }
157
+ else {
158
+ scan.dkkPrefixedClaude.push(path);
159
+ }
160
+ }
161
+ }
162
+ // .claude/hooks — match basenames the bundled template defines.
163
+ const hooksDir = join(root, ".claude", "hooks");
164
+ if (existsSync(hooksDir)) {
165
+ for (const name of readdirSync(hooksDir)) {
166
+ if (hookBasenames.has(name))
167
+ scan.dkkHooks.push(join(hooksDir, name));
168
+ }
169
+ }
170
+ // .github/skills/dkk-*
171
+ const ghSkills = join(root, ".github", "skills");
172
+ if (existsSync(ghSkills)) {
173
+ for (const name of readdirSync(ghSkills)) {
174
+ if (!name.startsWith("dkk-"))
175
+ continue;
176
+ scan.githubSkillDirs.push(join(ghSkills, name));
177
+ }
178
+ }
179
+ // Legacy paths.
180
+ for (const legacyRel of LEGACY_DKK_PATHS) {
181
+ const abs = join(root, legacyRel);
182
+ if (existsSync(abs))
183
+ scan.legacy.push(abs);
184
+ }
185
+ return scan;
186
+ }
187
+ /**
188
+ * Compute the add / replace / remove triage between the bundled template
189
+ * and a target repo. Paths are returned as repo-relative POSIX paths.
190
+ *
191
+ * `toAdd` and `toReplace` are derived by enumerating the bundled template's
192
+ * shipped files; `toRemove` is the set of installed DKK-managed paths that
193
+ * have no counterpart in the new template.
194
+ */
195
+ export function computeArtifactDiff(root) {
196
+ const diff = { toAdd: [], toReplace: [], toRemove: [] };
197
+ const claudeSrc = packageClaudeDir();
198
+ const skillsSrc = packageSkillsDir();
199
+ const inv = dkkClaudeFiles();
200
+ const installed = scanInstalledArtifacts(root);
201
+ const expectedInstalled = new Set();
202
+ // Hooks: flat files.
203
+ for (const name of inv.hooks) {
204
+ const srcPath = join(claudeSrc, "hooks", name);
205
+ const destPath = join(root, ".claude", "hooks", name);
206
+ expectedInstalled.add(destPath);
207
+ if (!existsSync(destPath)) {
208
+ diff.toAdd.push(toRel(root, destPath));
209
+ }
210
+ else if (!filesEqual(srcPath, destPath)) {
211
+ diff.toReplace.push(toRel(root, destPath));
212
+ }
213
+ }
214
+ // settings.json is intentionally left out of the diff: the prune+merge
215
+ // phase handles it independently and its content always differs from a
216
+ // fresh template (user customisations + additive merge state). Including
217
+ // it here would either always show "replace" on every run (noisy) or
218
+ // misleadingly suggest the file will be force-overwritten.
219
+ // Skills: nested (skill/<file>).
220
+ for (const skillName of inv.skills) {
221
+ const skillSrc = join(claudeSrc, "skills", skillName);
222
+ const skillDest = join(root, ".claude", "skills", skillName);
223
+ expectedInstalled.add(skillDest);
224
+ if (!existsSync(skillDest)) {
225
+ diff.toAdd.push(toRel(root, skillDest));
226
+ continue;
227
+ }
228
+ // Compare each file inside the skill dir.
229
+ let anyDiff = false;
230
+ for (const fileName of readdirSync(skillSrc)) {
231
+ const f = join(skillSrc, fileName);
232
+ try {
233
+ if (!statSync(f).isFile())
234
+ continue;
235
+ }
236
+ catch {
237
+ continue;
238
+ }
239
+ const df = join(skillDest, fileName);
240
+ if (!existsSync(df) || !filesEqual(f, df)) {
241
+ anyDiff = true;
242
+ break;
243
+ }
244
+ }
245
+ if (anyDiff)
246
+ diff.toReplace.push(toRel(root, skillDest));
247
+ }
248
+ // Agents + commands: flat files.
249
+ for (const [sub, names] of [["agents", inv.agents], ["commands", inv.commands]]) {
250
+ for (const name of names) {
251
+ const srcPath = join(claudeSrc, sub, name);
252
+ const destPath = join(root, ".claude", sub, name);
253
+ expectedInstalled.add(destPath);
254
+ if (!existsSync(destPath)) {
255
+ diff.toAdd.push(toRel(root, destPath));
256
+ }
257
+ else if (!filesEqual(srcPath, destPath)) {
258
+ diff.toReplace.push(toRel(root, destPath));
259
+ }
260
+ }
261
+ }
262
+ // .github/skills/<dkk-*>
263
+ if (existsSync(skillsSrc)) {
264
+ for (const skillName of dkkGithubSkillDirs()) {
265
+ const skillSrcDir = join(skillsSrc, skillName);
266
+ const skillDestDir = join(root, ".github", "skills", skillName);
267
+ expectedInstalled.add(skillDestDir);
268
+ if (!existsSync(skillDestDir)) {
269
+ diff.toAdd.push(toRel(root, skillDestDir));
270
+ continue;
271
+ }
272
+ let anyDiff = false;
273
+ for (const fileName of readdirSync(skillSrcDir)) {
274
+ const f = join(skillSrcDir, fileName);
275
+ try {
276
+ if (!statSync(f).isFile())
277
+ continue;
278
+ }
279
+ catch {
280
+ continue;
281
+ }
282
+ const df = join(skillDestDir, fileName);
283
+ if (!existsSync(df) || !filesEqual(f, df)) {
284
+ anyDiff = true;
285
+ break;
286
+ }
287
+ }
288
+ if (anyDiff)
289
+ diff.toReplace.push(toRel(root, skillDestDir));
290
+ }
291
+ }
292
+ // toRemove: any installed dkk-managed path not present in `expectedInstalled`,
293
+ // plus everything in `legacy` (which by definition is no longer shipped).
294
+ // De-duplicate because a legacy path can match both the `dkk-*` prefix
295
+ // predicate AND the LEGACY_DKK_PATHS list.
296
+ const seenRemove = new Set();
297
+ const candidates = [
298
+ ...installed.dkkPrefixedClaude,
299
+ ...installed.dkkHooks,
300
+ ...installed.githubSkillDirs,
301
+ ...installed.legacy,
302
+ ];
303
+ for (const path of candidates) {
304
+ if (expectedInstalled.has(path))
305
+ continue;
306
+ if (seenRemove.has(path))
307
+ continue;
308
+ seenRemove.add(path);
309
+ diff.toRemove.push(toRel(root, path));
310
+ }
311
+ return diff;
312
+ }
313
+ function filesEqual(a, b) {
314
+ try {
315
+ return readFileSync(a, "utf-8") === readFileSync(b, "utf-8");
316
+ }
317
+ catch {
318
+ return false;
319
+ }
320
+ }
321
+ function toRel(root, abs) {
322
+ return relative(root, abs).replace(/\\/g, "/");
323
+ }
324
+ /** True if `name` (basename or first path segment) starts with `dkk-`. */
325
+ export function isDkkPrefixed(path) {
326
+ return basename(path).startsWith("dkk-");
327
+ }
328
+ //# sourceMappingURL=dkk-artifacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dkk-artifacts.js","sourceRoot":"","sources":["../../../src/features/agent/dkk-artifacts.ts"],"names":[],"mappings":"AAAA;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EAAE,CAAC;QAC9B,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAC1C,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QACnC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACtC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,IAAY,EAAE,GAAW;IACtC,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,34 @@
1
+ export type InstallMode = "global" | "local" | "npx" | "unknown";
2
+ export interface InstallInfo {
3
+ /** How the running dkk binary was installed. */
4
+ mode: InstallMode;
5
+ /** Absolute path to the package root of the running install. */
6
+ packageRoot: string;
7
+ /** Absolute path to the npm global prefix's `node_modules` if resolvable, else null. */
8
+ globalNodeModules: string | null;
9
+ }
10
+ /**
11
+ * Inspect the running dkk binary's location and return its install mode.
12
+ *
13
+ * Resolution order:
14
+ * 1. Path lives under `~/.npm/_npx/` → `npx`. npx installs are transient
15
+ * caches; upgrading them is meaningless.
16
+ * 2. Path lives under the npm global `node_modules/` (resolved by
17
+ * `npm root -g`) → `global`.
18
+ * 3. Otherwise treat as `local` — covers devDependency installs and
19
+ * direct `tsx src/cli.ts` (dev) invocations alike. Callers that care
20
+ * about the difference can re-check by looking for a host
21
+ * `package.json` that depends on the package.
22
+ * 4. If `npm root -g` fails (npm not on PATH, unlikely) → `unknown`.
23
+ */
24
+ export declare function detectInstallMode(): InstallInfo;
25
+ /**
26
+ * Query the npm registry for the latest published version of `pkgName`.
27
+ *
28
+ * Uses `npm view <pkg> version` because it respects the user's npm config
29
+ * (registry overrides, auth tokens, proxies) without us having to
30
+ * re-implement any of that. Returns `null` on failure — callers should
31
+ * treat that as "can't check" rather than failing the whole command.
32
+ */
33
+ export declare function fetchLatestVersion(): string | null;
34
+ //# sourceMappingURL=install-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-mode.d.ts","sourceRoot":"","sources":["../../../src/features/agent/install-mode.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;AAEjE,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,IAAI,EAAE,WAAW,CAAC;IAClB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAkB/C;AAgBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CAYlD"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Detect how the running `dkk` binary was installed.
3
+ *
4
+ * `dkk update` needs to know this to pick the right `npm install`
5
+ * incantation (global vs. local devDep) and to refuse upgrade attempts
6
+ * under `npx`, where there's no persistent install to upgrade.
7
+ */
8
+ import { execFileSync } from "node:child_process";
9
+ import { sep, normalize } from "node:path";
10
+ import { homedir } from "node:os";
11
+ import { packageRoot } from "../../shared/paths.js";
12
+ import { pkgName } from "../../version.js";
13
+ /**
14
+ * Inspect the running dkk binary's location and return its install mode.
15
+ *
16
+ * Resolution order:
17
+ * 1. Path lives under `~/.npm/_npx/` → `npx`. npx installs are transient
18
+ * caches; upgrading them is meaningless.
19
+ * 2. Path lives under the npm global `node_modules/` (resolved by
20
+ * `npm root -g`) → `global`.
21
+ * 3. Otherwise treat as `local` — covers devDependency installs and
22
+ * direct `tsx src/cli.ts` (dev) invocations alike. Callers that care
23
+ * about the difference can re-check by looking for a host
24
+ * `package.json` that depends on the package.
25
+ * 4. If `npm root -g` fails (npm not on PATH, unlikely) → `unknown`.
26
+ */
27
+ export function detectInstallMode() {
28
+ const pkgRoot = normalize(packageRoot());
29
+ const globalNm = resolveGlobalNodeModules();
30
+ const npxPrefix = normalize(`${homedir()}${sep}.npm${sep}_npx${sep}`);
31
+ if (pkgRoot.startsWith(npxPrefix)) {
32
+ return { mode: "npx", packageRoot: pkgRoot, globalNodeModules: globalNm };
33
+ }
34
+ if (globalNm && pkgRoot.startsWith(normalize(globalNm) + sep)) {
35
+ return { mode: "global", packageRoot: pkgRoot, globalNodeModules: globalNm };
36
+ }
37
+ if (!globalNm) {
38
+ return { mode: "unknown", packageRoot: pkgRoot, globalNodeModules: null };
39
+ }
40
+ return { mode: "local", packageRoot: pkgRoot, globalNodeModules: globalNm };
41
+ }
42
+ function resolveGlobalNodeModules() {
43
+ try {
44
+ const out = execFileSync("npm", ["root", "-g"], {
45
+ encoding: "utf-8",
46
+ timeout: 10_000,
47
+ stdio: ["ignore", "pipe", "ignore"],
48
+ });
49
+ const path = out.trim();
50
+ return path.length > 0 ? path : null;
51
+ }
52
+ catch {
53
+ return null;
54
+ }
55
+ }
56
+ /**
57
+ * Query the npm registry for the latest published version of `pkgName`.
58
+ *
59
+ * Uses `npm view <pkg> version` because it respects the user's npm config
60
+ * (registry overrides, auth tokens, proxies) without us having to
61
+ * re-implement any of that. Returns `null` on failure — callers should
62
+ * treat that as "can't check" rather than failing the whole command.
63
+ */
64
+ export function fetchLatestVersion() {
65
+ try {
66
+ const out = execFileSync("npm", ["view", pkgName, "version"], {
67
+ encoding: "utf-8",
68
+ timeout: 15_000,
69
+ stdio: ["ignore", "pipe", "pipe"],
70
+ });
71
+ const v = out.trim();
72
+ return /^\d+\.\d+\.\d+/.test(v) ? v : null;
73
+ }
74
+ catch {
75
+ return null;
76
+ }
77
+ }
78
+ //# sourceMappingURL=install-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-mode.js","sourceRoot":"","sources":["../../../src/features/agent/install-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAa3C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAE5C,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,OAAO,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC;IACtE,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC;IAC5E,CAAC;IAED,IAAI,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;QAC9D,OAA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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ export type McpRegisterOutcome = {
2
+ status: "already-registered";
3
+ via: "project" | "claude-cli";
4
+ } | {
5
+ status: "registered";
6
+ via: "claude-cli" | "mcp-json";
7
+ } | {
8
+ status: "skipped";
9
+ reason: string;
10
+ } | {
11
+ status: "failed";
12
+ reason: string;
13
+ };
14
+ /**
15
+ * Detect existing registration → register via `claude mcp add` → fall back
16
+ * to writing `.mcp.json`. Returns a structured outcome rather than logging
17
+ * so callers can format the result as part of a larger summary.
18
+ */
19
+ export declare function ensureMcpRegistered(root: string): McpRegisterOutcome;
20
+ //# sourceMappingURL=mcp-register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-register.d.ts","sourceRoot":"","sources":["../../../src/features/agent/mcp-register.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,kBAAkB,GAC1B;IAAE,MAAM,EAAE,oBAAoB,CAAC;IAAC,GAAG,EAAE,SAAS,GAAG,YAAY,CAAA;CAAE,GAC/D;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,YAAY,GAAG,UAAU,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AASzC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CA6BpE"}