gsd-pi 2.20.0 → 2.22.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 (279) hide show
  1. package/README.md +12 -0
  2. package/dist/cli.js +21 -18
  3. package/dist/help-text.d.ts +2 -0
  4. package/dist/help-text.js +47 -0
  5. package/dist/loader.js +2 -16
  6. package/dist/mcp-server.d.ts +18 -0
  7. package/dist/mcp-server.js +53 -0
  8. package/dist/onboarding.d.ts +0 -6
  9. package/dist/onboarding.js +0 -28
  10. package/dist/resources/agents/javascript-pro.md +280 -0
  11. package/dist/resources/agents/typescript-pro.md +255 -0
  12. package/dist/resources/extensions/bg-shell/index.ts +14 -2
  13. package/dist/resources/extensions/bg-shell/utilities.ts +14 -0
  14. package/dist/resources/extensions/browser-tools/{core.js → core.ts} +329 -190
  15. package/dist/resources/extensions/gsd/auto-dashboard.ts +2 -1
  16. package/dist/resources/extensions/gsd/auto-prompts.ts +42 -1
  17. package/dist/resources/extensions/gsd/auto-worktree.ts +35 -2
  18. package/dist/resources/extensions/gsd/auto.ts +116 -10
  19. package/dist/resources/extensions/gsd/claude-import.ts +656 -0
  20. package/dist/resources/extensions/gsd/collision-diagnostics.ts +332 -0
  21. package/dist/resources/extensions/gsd/commands.ts +60 -7
  22. package/dist/resources/extensions/gsd/diff-context.ts +220 -0
  23. package/dist/resources/extensions/gsd/docs/claude-marketplace-import.md +214 -0
  24. package/dist/resources/extensions/gsd/docs/preferences-reference.md +2 -1
  25. package/dist/resources/extensions/gsd/doctor.ts +12 -4
  26. package/dist/resources/extensions/gsd/file-watcher.ts +97 -0
  27. package/dist/resources/extensions/gsd/files.ts +1 -1
  28. package/dist/resources/extensions/gsd/forensics.ts +596 -0
  29. package/dist/resources/extensions/gsd/git-service.ts +2 -1
  30. package/dist/resources/extensions/gsd/github-client.ts +235 -0
  31. package/dist/resources/extensions/gsd/gitignore.ts +1 -0
  32. package/dist/resources/extensions/gsd/marketplace-discovery.ts +507 -0
  33. package/dist/resources/extensions/gsd/mcp-server.ts +87 -0
  34. package/dist/resources/extensions/gsd/namespaced-registry.ts +467 -0
  35. package/dist/resources/extensions/gsd/namespaced-resolver.ts +307 -0
  36. package/dist/resources/extensions/gsd/plugin-importer.ts +410 -0
  37. package/dist/resources/extensions/gsd/preferences.ts +14 -3
  38. package/dist/resources/extensions/gsd/prompts/execute-task.md +1 -1
  39. package/dist/resources/extensions/gsd/prompts/forensics.md +71 -0
  40. package/dist/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  41. package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -1
  42. package/dist/resources/extensions/gsd/prompts/system.md +12 -3
  43. package/dist/resources/extensions/gsd/roadmap-slices.ts +1 -1
  44. package/dist/resources/extensions/gsd/session-forensics.ts +5 -5
  45. package/dist/resources/extensions/gsd/tests/claude-import-tui.test.ts +351 -0
  46. package/dist/resources/extensions/gsd/tests/collision-diagnostics.test.ts +705 -0
  47. package/dist/resources/extensions/gsd/tests/context-compression.test.ts +13 -0
  48. package/dist/resources/extensions/gsd/tests/diff-context.test.ts +136 -0
  49. package/dist/resources/extensions/gsd/tests/doctor-git.test.ts +118 -0
  50. package/dist/resources/extensions/gsd/tests/marketplace-discovery.test.ts +202 -0
  51. package/dist/resources/extensions/gsd/tests/marketplace-test-fixtures.ts +91 -0
  52. package/dist/resources/extensions/gsd/tests/namespaced-registry.test.ts +1027 -0
  53. package/dist/resources/extensions/gsd/tests/namespaced-resolver.test.ts +671 -0
  54. package/dist/resources/extensions/gsd/tests/none-mode-gates.test.ts +105 -0
  55. package/dist/resources/extensions/gsd/tests/plugin-importer-live.test.ts +481 -0
  56. package/dist/resources/extensions/gsd/tests/plugin-importer.test.ts +1383 -0
  57. package/dist/resources/extensions/gsd/tests/preferences-git.test.ts +21 -2
  58. package/dist/resources/extensions/gsd/tests/preferences-schema-validation.test.ts +8 -1
  59. package/dist/resources/extensions/gsd/tests/visualizer-data.test.ts +11 -0
  60. package/dist/resources/extensions/gsd/tests/worktree-bugfix.test.ts +120 -0
  61. package/dist/resources/extensions/gsd/token-counter.ts +45 -0
  62. package/dist/resources/extensions/gsd/visualizer-data.ts +2 -2
  63. package/dist/resources/extensions/gsd/worktree-manager.ts +29 -1
  64. package/dist/resources/extensions/gsd/worktree.ts +3 -0
  65. package/dist/resources/extensions/mcporter/index.ts +90 -7
  66. package/dist/resources/extensions/search-the-web/native-search.ts +2 -0
  67. package/dist/resources/extensions/search-the-web/tool-fetch-page.ts +9 -1
  68. package/dist/resources/extensions/search-the-web/url-utils.ts +35 -1
  69. package/dist/resources/extensions/shared/terminal.ts +1 -1
  70. package/dist/resources/extensions/universal-config/discovery.ts +4 -0
  71. package/dist/resources/extensions/universal-config/format.ts +35 -4
  72. package/dist/resources/extensions/universal-config/index.ts +5 -3
  73. package/dist/resources/extensions/universal-config/scanners.ts +65 -2
  74. package/dist/resources/extensions/universal-config/tests/discovery.test.ts +9 -1
  75. package/dist/resources/extensions/universal-config/tests/format.test.ts +22 -6
  76. package/dist/resources/extensions/universal-config/tests/scanners.test.ts +18 -0
  77. package/dist/resources/extensions/universal-config/types.ts +20 -1
  78. package/dist/resources/skills/lint/SKILL.md +141 -0
  79. package/dist/resources/skills/review/SKILL.md +214 -0
  80. package/dist/resources/skills/test/SKILL.md +201 -0
  81. package/dist/tool-bootstrap.js +2 -1
  82. package/dist/wizard.js +2 -0
  83. package/package.json +12 -7
  84. package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  85. package/packages/pi-ai/dist/providers/azure-openai-responses.js +12 -1
  86. package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  87. package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  88. package/packages/pi-ai/dist/providers/openai-responses.js +12 -1
  89. package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
  90. package/packages/pi-ai/node_modules/@smithy/node-http-handler/LICENSE +201 -0
  91. package/packages/pi-ai/node_modules/@smithy/node-http-handler/README.md +9 -0
  92. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-cjs/index.js +762 -0
  93. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js +19 -0
  94. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/constants.js +1 -0
  95. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/get-transformed-headers.js +9 -0
  96. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -0
  97. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +230 -0
  98. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +87 -0
  99. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-pool.js +32 -0
  100. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +169 -0
  101. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/readable.mock.js +21 -0
  102. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/server.mock.js +88 -0
  103. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +36 -0
  104. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
  105. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-socket-keep-alive.js +22 -0
  106. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +23 -0
  107. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +8 -0
  108. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +41 -0
  109. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/stream-collector/readable.mock.js +21 -0
  110. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/timing.js +4 -0
  111. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +63 -0
  112. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/build-abort-error.d.ts +10 -0
  113. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/constants.d.ts +5 -0
  114. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/get-transformed-headers.d.ts +4 -0
  115. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -0
  116. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/node-http-handler.d.ts +46 -0
  117. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-manager.d.ts +24 -0
  118. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-pool.d.ts +12 -0
  119. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/node-http2-handler.d.ts +63 -0
  120. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/readable.mock.d.ts +13 -0
  121. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/server.mock.d.ts +12 -0
  122. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/set-connection-timeout.d.ts +2 -0
  123. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/set-request-timeout.d.ts +6 -0
  124. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/set-socket-keep-alive.d.ts +6 -0
  125. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/set-socket-timeout.d.ts +2 -0
  126. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +5 -0
  127. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +6 -0
  128. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/stream-collector/readable.mock.d.ts +13 -0
  129. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/timing.d.ts +8 -0
  130. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/build-abort-error.d.ts +10 -0
  131. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/constants.d.ts +5 -0
  132. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/get-transformed-headers.d.ts +4 -0
  133. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/index.d.ts +3 -0
  134. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +46 -0
  135. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-connection-manager.d.ts +24 -0
  136. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-connection-pool.d.ts +12 -0
  137. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-handler.d.ts +63 -0
  138. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/readable.mock.d.ts +13 -0
  139. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/server.mock.d.ts +12 -0
  140. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-connection-timeout.d.ts +2 -0
  141. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-request-timeout.d.ts +6 -0
  142. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-keep-alive.d.ts +6 -0
  143. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-timeout.d.ts +2 -0
  144. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/collector.d.ts +5 -0
  145. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/index.d.ts +6 -0
  146. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/readable.mock.d.ts +13 -0
  147. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/timing.d.ts +8 -0
  148. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/ts3.4/write-request-body.d.ts +12 -0
  149. package/packages/pi-ai/node_modules/@smithy/node-http-handler/dist-types/write-request-body.d.ts +12 -0
  150. package/packages/pi-ai/node_modules/@smithy/node-http-handler/package.json +68 -0
  151. package/packages/pi-ai/package.json +3 -0
  152. package/packages/pi-ai/pnpm-lock.yaml +2022 -0
  153. package/packages/pi-ai/src/providers/azure-openai-responses.ts +12 -1
  154. package/packages/pi-ai/src/providers/openai-responses.ts +12 -1
  155. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts +1 -1
  156. package/packages/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  157. package/packages/pi-coding-agent/dist/core/extensions/index.js +1 -1
  158. package/packages/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  159. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts +1 -0
  160. package/packages/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
  161. package/packages/pi-coding-agent/dist/core/extensions/loader.js +12 -1
  162. package/packages/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
  163. package/packages/pi-coding-agent/dist/core/extensions/loader.test.d.ts +2 -0
  164. package/packages/pi-coding-agent/dist/core/extensions/loader.test.d.ts.map +1 -0
  165. package/packages/pi-coding-agent/dist/core/extensions/loader.test.js +113 -0
  166. package/packages/pi-coding-agent/dist/core/extensions/loader.test.js.map +1 -0
  167. package/packages/pi-coding-agent/dist/core/extensions/project-trust.d.ts +4 -0
  168. package/packages/pi-coding-agent/dist/core/extensions/project-trust.d.ts.map +1 -0
  169. package/packages/pi-coding-agent/dist/core/extensions/project-trust.js +42 -0
  170. package/packages/pi-coding-agent/dist/core/extensions/project-trust.js.map +1 -0
  171. package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts +1 -0
  172. package/packages/pi-coding-agent/dist/core/resolve-config-value.d.ts.map +1 -1
  173. package/packages/pi-coding-agent/dist/core/resolve-config-value.js +18 -0
  174. package/packages/pi-coding-agent/dist/core/resolve-config-value.js.map +1 -1
  175. package/packages/pi-coding-agent/dist/core/resolve-config-value.test.d.ts +2 -0
  176. package/packages/pi-coding-agent/dist/core/resolve-config-value.test.d.ts.map +1 -0
  177. package/packages/pi-coding-agent/dist/core/resolve-config-value.test.js +114 -0
  178. package/packages/pi-coding-agent/dist/core/resolve-config-value.test.js.map +1 -0
  179. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  180. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +8 -2
  181. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
  182. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts +2 -0
  183. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.d.ts.map +1 -1
  184. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js +23 -9
  185. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.js.map +1 -1
  186. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.test.d.ts +2 -0
  187. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.test.d.ts.map +1 -0
  188. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.test.js +67 -0
  189. package/packages/pi-coding-agent/dist/resources/extensions/memory/storage.test.js.map +1 -0
  190. package/packages/pi-coding-agent/package.json +1 -1
  191. package/packages/pi-coding-agent/pnpm-lock.yaml +454 -0
  192. package/packages/pi-coding-agent/scripts/copy-assets.cjs +24 -0
  193. package/packages/pi-coding-agent/src/core/extensions/index.ts +3 -0
  194. package/packages/pi-coding-agent/src/core/extensions/loader.test.ts +141 -0
  195. package/packages/pi-coding-agent/src/core/extensions/loader.ts +14 -1
  196. package/packages/pi-coding-agent/src/core/extensions/project-trust.ts +51 -0
  197. package/packages/pi-coding-agent/src/core/resolve-config-value.test.ts +132 -0
  198. package/packages/pi-coding-agent/src/core/resolve-config-value.ts +20 -0
  199. package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +7 -2
  200. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.test.ts +98 -0
  201. package/packages/pi-coding-agent/src/resources/extensions/memory/storage.ts +24 -9
  202. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  203. package/packages/pi-tui/dist/tui.js +2 -2
  204. package/packages/pi-tui/dist/tui.js.map +1 -1
  205. package/packages/pi-tui/package.json +3 -1
  206. package/packages/pi-tui/src/tui.ts +2 -2
  207. package/src/resources/agents/javascript-pro.md +280 -0
  208. package/src/resources/agents/typescript-pro.md +255 -0
  209. package/src/resources/extensions/bg-shell/index.ts +14 -2
  210. package/src/resources/extensions/bg-shell/utilities.ts +14 -0
  211. package/src/resources/extensions/browser-tools/{core.js → core.ts} +329 -190
  212. package/src/resources/extensions/gsd/auto-dashboard.ts +2 -1
  213. package/src/resources/extensions/gsd/auto-prompts.ts +42 -1
  214. package/src/resources/extensions/gsd/auto-worktree.ts +35 -2
  215. package/src/resources/extensions/gsd/auto.ts +116 -10
  216. package/src/resources/extensions/gsd/claude-import.ts +656 -0
  217. package/src/resources/extensions/gsd/collision-diagnostics.ts +332 -0
  218. package/src/resources/extensions/gsd/commands.ts +60 -7
  219. package/src/resources/extensions/gsd/diff-context.ts +220 -0
  220. package/src/resources/extensions/gsd/docs/claude-marketplace-import.md +214 -0
  221. package/src/resources/extensions/gsd/docs/preferences-reference.md +2 -1
  222. package/src/resources/extensions/gsd/doctor.ts +12 -4
  223. package/src/resources/extensions/gsd/file-watcher.ts +97 -0
  224. package/src/resources/extensions/gsd/files.ts +1 -1
  225. package/src/resources/extensions/gsd/forensics.ts +596 -0
  226. package/src/resources/extensions/gsd/git-service.ts +2 -1
  227. package/src/resources/extensions/gsd/github-client.ts +235 -0
  228. package/src/resources/extensions/gsd/gitignore.ts +1 -0
  229. package/src/resources/extensions/gsd/marketplace-discovery.ts +507 -0
  230. package/src/resources/extensions/gsd/mcp-server.ts +87 -0
  231. package/src/resources/extensions/gsd/namespaced-registry.ts +467 -0
  232. package/src/resources/extensions/gsd/namespaced-resolver.ts +307 -0
  233. package/src/resources/extensions/gsd/plugin-importer.ts +410 -0
  234. package/src/resources/extensions/gsd/preferences.ts +14 -3
  235. package/src/resources/extensions/gsd/prompts/execute-task.md +1 -1
  236. package/src/resources/extensions/gsd/prompts/forensics.md +71 -0
  237. package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -1
  238. package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
  239. package/src/resources/extensions/gsd/prompts/system.md +12 -3
  240. package/src/resources/extensions/gsd/roadmap-slices.ts +1 -1
  241. package/src/resources/extensions/gsd/session-forensics.ts +5 -5
  242. package/src/resources/extensions/gsd/tests/claude-import-tui.test.ts +351 -0
  243. package/src/resources/extensions/gsd/tests/collision-diagnostics.test.ts +705 -0
  244. package/src/resources/extensions/gsd/tests/context-compression.test.ts +13 -0
  245. package/src/resources/extensions/gsd/tests/diff-context.test.ts +136 -0
  246. package/src/resources/extensions/gsd/tests/doctor-git.test.ts +118 -0
  247. package/src/resources/extensions/gsd/tests/marketplace-discovery.test.ts +202 -0
  248. package/src/resources/extensions/gsd/tests/marketplace-test-fixtures.ts +91 -0
  249. package/src/resources/extensions/gsd/tests/namespaced-registry.test.ts +1027 -0
  250. package/src/resources/extensions/gsd/tests/namespaced-resolver.test.ts +671 -0
  251. package/src/resources/extensions/gsd/tests/none-mode-gates.test.ts +105 -0
  252. package/src/resources/extensions/gsd/tests/plugin-importer-live.test.ts +481 -0
  253. package/src/resources/extensions/gsd/tests/plugin-importer.test.ts +1383 -0
  254. package/src/resources/extensions/gsd/tests/preferences-git.test.ts +21 -2
  255. package/src/resources/extensions/gsd/tests/preferences-schema-validation.test.ts +8 -1
  256. package/src/resources/extensions/gsd/tests/visualizer-data.test.ts +11 -0
  257. package/src/resources/extensions/gsd/tests/worktree-bugfix.test.ts +120 -0
  258. package/src/resources/extensions/gsd/token-counter.ts +45 -0
  259. package/src/resources/extensions/gsd/visualizer-data.ts +2 -2
  260. package/src/resources/extensions/gsd/worktree-manager.ts +29 -1
  261. package/src/resources/extensions/gsd/worktree.ts +3 -0
  262. package/src/resources/extensions/mcporter/index.ts +90 -7
  263. package/src/resources/extensions/search-the-web/native-search.ts +2 -0
  264. package/src/resources/extensions/search-the-web/tool-fetch-page.ts +9 -1
  265. package/src/resources/extensions/search-the-web/url-utils.ts +35 -1
  266. package/src/resources/extensions/shared/terminal.ts +1 -1
  267. package/src/resources/extensions/universal-config/discovery.ts +4 -0
  268. package/src/resources/extensions/universal-config/format.ts +35 -4
  269. package/src/resources/extensions/universal-config/index.ts +5 -3
  270. package/src/resources/extensions/universal-config/scanners.ts +65 -2
  271. package/src/resources/extensions/universal-config/tests/discovery.test.ts +9 -1
  272. package/src/resources/extensions/universal-config/tests/format.test.ts +22 -6
  273. package/src/resources/extensions/universal-config/tests/scanners.test.ts +18 -0
  274. package/src/resources/extensions/universal-config/types.ts +20 -1
  275. package/src/resources/skills/lint/SKILL.md +141 -0
  276. package/src/resources/skills/review/SKILL.md +214 -0
  277. package/src/resources/skills/test/SKILL.md +201 -0
  278. package/dist/resources/extensions/browser-tools/core.d.ts +0 -205
  279. package/src/resources/extensions/browser-tools/core.d.ts +0 -205
@@ -0,0 +1,1383 @@
1
+ /**
2
+ * PluginImporter Contract Tests
3
+ *
4
+ * Tests that prove R012 (discover/select/import flow) and R013 (canonical name preservation).
5
+ *
6
+ * Coverage:
7
+ * - Discovery pipeline: marketplace discovery → registry population
8
+ * - Selective filtering: filter function correctly selects components
9
+ * - Diagnostic gating: errors block, warnings pass
10
+ * - Config manifest format: canonical identity preserved
11
+ */
12
+
13
+ import { describe, it, beforeEach, mock } from 'node:test';
14
+ import assert from 'node:assert';
15
+ import {
16
+ PluginImporter,
17
+ type DiscoveryResult,
18
+ type ValidationResult,
19
+ type ImportManifest,
20
+ } from '../plugin-importer.js';
21
+ import type { NamespacedComponent } from '../namespaced-registry.js';
22
+ import type {
23
+ MarketplaceDiscoveryResult,
24
+ DiscoveredPlugin,
25
+ } from '../marketplace-discovery.js';
26
+
27
+ // ============================================================================
28
+ // Test Fixtures
29
+ // ============================================================================
30
+
31
+ /**
32
+ * Create a mock discovered plugin for testing.
33
+ */
34
+ function createMockPlugin(overrides: Partial<DiscoveredPlugin> = {}): DiscoveredPlugin {
35
+ return {
36
+ name: 'test-plugin',
37
+ canonicalName: 'test-plugin',
38
+ source: './plugins/test-plugin',
39
+ resolvedPath: '/plugins/test-plugin',
40
+ status: 'ok',
41
+ manifestSource: 'plugin.json',
42
+ description: 'A test plugin',
43
+ version: '1.0.0',
44
+ author: { name: 'Test Author' },
45
+ inventory: {
46
+ skills: ['skill-a', 'skill-b'],
47
+ agents: ['agent-x'],
48
+ commands: [],
49
+ mcpServers: {},
50
+ lspServers: {},
51
+ hooks: [],
52
+ },
53
+ ...overrides,
54
+ };
55
+ }
56
+
57
+ /**
58
+ * Create a mock marketplace discovery result.
59
+ */
60
+ function createMockDiscoveryResult(
61
+ plugins: DiscoveredPlugin[] = [],
62
+ overrides: Partial<MarketplaceDiscoveryResult> = {}
63
+ ): MarketplaceDiscoveryResult {
64
+ return {
65
+ status: 'ok',
66
+ marketplacePath: '/test/marketplace.json',
67
+ marketplaceName: 'Test Marketplace',
68
+ pluginFormat: 'jamie-style',
69
+ plugins,
70
+ summary: {
71
+ total: plugins.length,
72
+ ok: plugins.filter((p) => p.status === 'ok').length,
73
+ error: plugins.filter((p) => p.status === 'error').length,
74
+ },
75
+ ...overrides,
76
+ };
77
+ }
78
+
79
+ // ============================================================================
80
+ // Tests
81
+ // ============================================================================
82
+
83
+ describe('PluginImporter', () => {
84
+ let importer: PluginImporter;
85
+
86
+ beforeEach(() => {
87
+ importer = new PluginImporter();
88
+ });
89
+
90
+ describe('Stage 1: discover()', () => {
91
+ it('should throw error if paths array is empty but return valid result', () => {
92
+ const result = importer.discover([]);
93
+
94
+ assert.strictEqual(result.summary.marketplacesProcessed, 0);
95
+ assert.strictEqual(result.summary.totalPlugins, 0);
96
+ assert.strictEqual(result.summary.totalComponents, 0);
97
+ });
98
+
99
+ it('should call discoverMarketplace for each path and aggregate results', () => {
100
+ // Test with non-existent paths - should still return structure
101
+ const result = importer.discover([
102
+ '/nonexistent/marketplace-1',
103
+ '/nonexistent/marketplace-2',
104
+ ]);
105
+
106
+ assert.strictEqual(result.summary.marketplacesProcessed, 2);
107
+ assert.strictEqual(Array.isArray(result.marketplaceResults), true);
108
+ assert.strictEqual(result.marketplaceResults.length, 2);
109
+ });
110
+
111
+ it('should populate registry via componentsFromDiscovery', () => {
112
+ // Test against a real path if it exists, otherwise test structure
113
+ const result = importer.discover([]);
114
+
115
+ // Registry should be populated (even if empty)
116
+ const registry = importer.getRegistry();
117
+ assert.ok(registry !== null);
118
+ assert.strictEqual(registry!.size, result.summary.totalComponents);
119
+ });
120
+
121
+ it('should track plugins with errors in summary', () => {
122
+ const result = importer.discover(['/nonexistent/path']);
123
+
124
+ // Non-existent path should result in error status
125
+ assert.ok(result.summary.marketplacesWithErrors >= 0);
126
+ });
127
+
128
+ it('should be re-entrant (calling discover again resets state)', () => {
129
+ // First discovery
130
+ importer.discover(['/nonexistent/path-1']);
131
+ const firstPlugins = importer.getDiscoveredPlugins();
132
+
133
+ // Second discovery should reset
134
+ importer.discover(['/nonexistent/path-2']);
135
+ const secondPlugins = importer.getDiscoveredPlugins();
136
+
137
+ // Should have fresh state (not accumulated)
138
+ // Both should have 0 plugins since paths don't exist
139
+ assert.strictEqual(firstPlugins.length, 0);
140
+ assert.strictEqual(secondPlugins.length, 0);
141
+ });
142
+ });
143
+
144
+ describe('Stage 2: selectComponents()', () => {
145
+ it('should throw error if called before discover()', () => {
146
+ assert.throws(
147
+ () => importer.selectComponents(() => true),
148
+ /Must call discover\(\) before selectComponents\(\)/
149
+ );
150
+ });
151
+
152
+ it('should return empty array if no components match filter', () => {
153
+ importer.discover([]);
154
+ const selected = importer.selectComponents(() => false);
155
+ assert.deepStrictEqual(selected, []);
156
+ });
157
+
158
+ it('should return all components if filter returns true', () => {
159
+ importer.discover([]);
160
+ const selected = importer.selectComponents(() => true);
161
+ // Empty discovery means no components
162
+ assert.deepStrictEqual(selected, []);
163
+ });
164
+
165
+ it('should filter by namespace correctly', () => {
166
+ importer.discover([]);
167
+ const selected = importer.selectComponents(
168
+ (c) => c.namespace === 'target-plugin'
169
+ );
170
+ assert.deepStrictEqual(selected, []);
171
+ });
172
+
173
+ it('should filter by type correctly', () => {
174
+ importer.discover([]);
175
+ const skills = importer.selectComponents((c) => c.type === 'skill');
176
+ const agents = importer.selectComponents((c) => c.type === 'agent');
177
+ assert.deepStrictEqual(skills, []);
178
+ assert.deepStrictEqual(agents, []);
179
+ });
180
+
181
+ it('should filter by name pattern correctly', () => {
182
+ importer.discover([]);
183
+ const selected = importer.selectComponents((c) =>
184
+ c.name.includes('review')
185
+ );
186
+ assert.deepStrictEqual(selected, []);
187
+ });
188
+ });
189
+
190
+ describe('Stage 3: validateImport()', () => {
191
+ it('should throw error if called before discover()', () => {
192
+ const components: NamespacedComponent[] = [];
193
+ assert.throws(
194
+ () => importer.validateImport(components),
195
+ /Must call discover\(\) before validateImport\(\)/
196
+ );
197
+ });
198
+
199
+ it('should return canProceed: true for empty selection', () => {
200
+ importer.discover([]);
201
+ const result = importer.validateImport([]);
202
+
203
+ assert.strictEqual(result.canProceed, true);
204
+ assert.strictEqual(result.diagnostics.length, 0);
205
+ assert.strictEqual(result.summary.total, 0);
206
+ assert.strictEqual(result.summary.errors, 0);
207
+ assert.strictEqual(result.summary.warnings, 0);
208
+ });
209
+
210
+ it('should return canProceed: true when no collisions', () => {
211
+ importer.discover([]);
212
+
213
+ // Create mock components without collisions
214
+ const components: NamespacedComponent[] = [
215
+ {
216
+ name: 'skill-a',
217
+ namespace: 'plugin-x',
218
+ canonicalName: 'plugin-x:skill-a',
219
+ type: 'skill',
220
+ filePath: '/x/skill-a.md',
221
+ source: 'plugin:plugin-x',
222
+ description: undefined,
223
+ metadata: {},
224
+ },
225
+ {
226
+ name: 'skill-b',
227
+ namespace: 'plugin-y',
228
+ canonicalName: 'plugin-y:skill-b',
229
+ type: 'skill',
230
+ filePath: '/y/skill-b.md',
231
+ source: 'plugin:plugin-y',
232
+ description: undefined,
233
+ metadata: {},
234
+ },
235
+ ];
236
+
237
+ const result = importer.validateImport(components);
238
+
239
+ assert.strictEqual(result.canProceed, true);
240
+ });
241
+
242
+ it('should detect canonical collision and return canProceed: false (error blocks)', () => {
243
+ importer.discover([]);
244
+
245
+ // Create components with same canonical name (collision)
246
+ const components: NamespacedComponent[] = [
247
+ {
248
+ name: 'skill-a',
249
+ namespace: 'plugin-x',
250
+ canonicalName: 'plugin-x:skill-a',
251
+ type: 'skill',
252
+ filePath: '/first/skill-a.md',
253
+ source: 'plugin:plugin-x',
254
+ description: undefined,
255
+ metadata: {},
256
+ },
257
+ {
258
+ name: 'skill-a',
259
+ namespace: 'plugin-x',
260
+ canonicalName: 'plugin-x:skill-a', // Same canonical name!
261
+ type: 'skill',
262
+ filePath: '/second/skill-a.md',
263
+ source: 'plugin:plugin-x',
264
+ description: undefined,
265
+ metadata: {},
266
+ },
267
+ ];
268
+
269
+ const result = importer.validateImport(components);
270
+
271
+ // Error severity should block
272
+ assert.strictEqual(result.canProceed, false);
273
+ assert.strictEqual(result.summary.errors, 1);
274
+ assert.ok(result.diagnostics.some((d) => d.severity === 'error'));
275
+ });
276
+
277
+ it('should detect shorthand overlap but return canProceed: true (warning passes)', () => {
278
+ importer.discover([]);
279
+
280
+ // Create components with same bare name but different namespaces
281
+ const components: NamespacedComponent[] = [
282
+ {
283
+ name: 'review', // Same bare name
284
+ namespace: 'plugin-a',
285
+ canonicalName: 'plugin-a:review',
286
+ type: 'skill',
287
+ filePath: '/a/review.md',
288
+ source: 'plugin:plugin-a',
289
+ description: undefined,
290
+ metadata: {},
291
+ },
292
+ {
293
+ name: 'review', // Same bare name
294
+ namespace: 'plugin-b',
295
+ canonicalName: 'plugin-b:review',
296
+ type: 'skill',
297
+ filePath: '/b/review.md',
298
+ source: 'plugin:plugin-b',
299
+ description: undefined,
300
+ metadata: {},
301
+ },
302
+ ];
303
+
304
+ const result = importer.validateImport(components);
305
+
306
+ // Warning severity should NOT block
307
+ assert.strictEqual(result.canProceed, true);
308
+ assert.strictEqual(result.summary.errors, 0);
309
+ assert.strictEqual(result.summary.warnings, 1);
310
+ assert.ok(result.diagnostics.some((d) => d.severity === 'warning'));
311
+ });
312
+
313
+ it('should correctly classify severity: error for canonical conflict', () => {
314
+ importer.discover([]);
315
+
316
+ const components: NamespacedComponent[] = [
317
+ {
318
+ name: 'dup',
319
+ namespace: 'ns',
320
+ canonicalName: 'ns:dup',
321
+ type: 'skill',
322
+ filePath: '/1/dup.md',
323
+ source: 'first',
324
+ description: undefined,
325
+ metadata: {},
326
+ },
327
+ {
328
+ name: 'dup',
329
+ namespace: 'ns',
330
+ canonicalName: 'ns:dup',
331
+ type: 'skill',
332
+ filePath: '/2/dup.md',
333
+ source: 'second',
334
+ description: undefined,
335
+ metadata: {},
336
+ },
337
+ ];
338
+
339
+ const result = importer.validateImport(components);
340
+
341
+ const error = result.diagnostics.find((d) => d.severity === 'error');
342
+ assert.ok(error !== undefined);
343
+ assert.strictEqual(error!.class, 'canonical-conflict');
344
+ assert.ok(error!.involvedCanonicalNames.includes('ns:dup'));
345
+ });
346
+
347
+ it('should correctly classify severity: warning for shorthand overlap', () => {
348
+ importer.discover([]);
349
+
350
+ const components: NamespacedComponent[] = [
351
+ {
352
+ name: 'common-skill',
353
+ namespace: 'plugin-a',
354
+ canonicalName: 'plugin-a:common-skill',
355
+ type: 'skill',
356
+ filePath: '/a/common.md',
357
+ source: 'plugin:plugin-a',
358
+ description: undefined,
359
+ metadata: {},
360
+ },
361
+ {
362
+ name: 'common-skill',
363
+ namespace: 'plugin-b',
364
+ canonicalName: 'plugin-b:common-skill',
365
+ type: 'skill',
366
+ filePath: '/b/common.md',
367
+ source: 'plugin:plugin-b',
368
+ description: undefined,
369
+ metadata: {},
370
+ },
371
+ ];
372
+
373
+ const result = importer.validateImport(components);
374
+
375
+ const warning = result.diagnostics.find((d) => d.severity === 'warning');
376
+ assert.ok(warning !== undefined);
377
+ assert.strictEqual(warning!.class, 'shorthand-overlap');
378
+ assert.strictEqual(warning!.ambiguousBareName, 'common-skill');
379
+ });
380
+ });
381
+
382
+ describe('Stage 4: getImportManifest()', () => {
383
+ it('should produce valid manifest for empty selection', () => {
384
+ const manifest = importer.getImportManifest([]);
385
+
386
+ assert.strictEqual(manifest.schemaVersion, '1.0');
387
+ assert.strictEqual(typeof manifest.generatedAt, 'string');
388
+ assert.deepStrictEqual(manifest.entries, []);
389
+ assert.strictEqual(manifest.summary.total, 0);
390
+ assert.strictEqual(manifest.summary.skills, 0);
391
+ assert.strictEqual(manifest.summary.agents, 0);
392
+ assert.deepStrictEqual(manifest.summary.namespaces, []);
393
+ });
394
+
395
+ it('should preserve canonical names in manifest (R013)', () => {
396
+ const components: NamespacedComponent[] = [
397
+ {
398
+ name: 'code-review',
399
+ namespace: 'my-plugin',
400
+ canonicalName: 'my-plugin:code-review',
401
+ type: 'skill',
402
+ filePath: '/plugins/my-plugin/skills/code-review/SKILL.md',
403
+ source: 'plugin:my-plugin',
404
+ description: 'Reviews code',
405
+ metadata: {
406
+ pluginVersion: '1.0.0',
407
+ pluginAuthor: 'Test Author',
408
+ },
409
+ },
410
+ ];
411
+
412
+ const manifest = importer.getImportManifest(components);
413
+
414
+ assert.strictEqual(manifest.entries.length, 1);
415
+
416
+ // Verify canonical name preserved
417
+ const entry = manifest.entries[0];
418
+ assert.strictEqual(entry!.canonicalName, 'my-plugin:code-review');
419
+ assert.strictEqual(entry!.name, 'code-review');
420
+ assert.strictEqual(entry!.namespace, 'my-plugin');
421
+ });
422
+
423
+ it('should include all component metadata in manifest', () => {
424
+ const components: NamespacedComponent[] = [
425
+ {
426
+ name: 'test-skill',
427
+ namespace: 'test-plugin',
428
+ canonicalName: 'test-plugin:test-skill',
429
+ type: 'skill',
430
+ filePath: '/test/skill.md',
431
+ source: 'plugin:test-plugin',
432
+ description: 'A test skill',
433
+ metadata: {
434
+ pluginVersion: '2.0.0',
435
+ pluginAuthor: 'Author Name',
436
+ pluginHomepage: 'https://example.com',
437
+ pluginCategory: 'testing',
438
+ },
439
+ },
440
+ ];
441
+
442
+ const manifest = importer.getImportManifest(components);
443
+
444
+ const entry = manifest.entries[0];
445
+ assert.ok(entry !== undefined);
446
+ assert.strictEqual(entry!.description, 'A test skill');
447
+ assert.strictEqual(entry!.metadata.pluginVersion, '2.0.0');
448
+ assert.strictEqual(entry!.metadata.pluginAuthor, 'Author Name');
449
+ assert.strictEqual(entry!.metadata.pluginHomepage, 'https://example.com');
450
+ assert.strictEqual(entry!.metadata.pluginCategory, 'testing');
451
+ });
452
+
453
+ it('should count skills and agents separately in summary', () => {
454
+ const components: NamespacedComponent[] = [
455
+ {
456
+ name: 'skill-a',
457
+ namespace: 'ns',
458
+ canonicalName: 'ns:skill-a',
459
+ type: 'skill',
460
+ filePath: '/a.md',
461
+ source: 'plugin:ns',
462
+ description: undefined,
463
+ metadata: {},
464
+ },
465
+ {
466
+ name: 'skill-b',
467
+ namespace: 'ns',
468
+ canonicalName: 'ns:skill-b',
469
+ type: 'skill',
470
+ filePath: '/b.md',
471
+ source: 'plugin:ns',
472
+ description: undefined,
473
+ metadata: {},
474
+ },
475
+ {
476
+ name: 'agent-x',
477
+ namespace: 'ns',
478
+ canonicalName: 'ns:agent-x',
479
+ type: 'agent',
480
+ filePath: '/x.md',
481
+ source: 'plugin:ns',
482
+ description: undefined,
483
+ metadata: {},
484
+ },
485
+ ];
486
+
487
+ const manifest = importer.getImportManifest(components);
488
+
489
+ assert.strictEqual(manifest.summary.total, 3);
490
+ assert.strictEqual(manifest.summary.skills, 2);
491
+ assert.strictEqual(manifest.summary.agents, 1);
492
+ });
493
+
494
+ it('should list unique namespaces in summary', () => {
495
+ const components: NamespacedComponent[] = [
496
+ {
497
+ name: 'skill',
498
+ namespace: 'plugin-a',
499
+ canonicalName: 'plugin-a:skill',
500
+ type: 'skill',
501
+ filePath: '/a.md',
502
+ source: 'plugin:plugin-a',
503
+ description: undefined,
504
+ metadata: {},
505
+ },
506
+ {
507
+ name: 'skill',
508
+ namespace: 'plugin-b',
509
+ canonicalName: 'plugin-b:skill',
510
+ type: 'skill',
511
+ filePath: '/b.md',
512
+ source: 'plugin:plugin-b',
513
+ description: undefined,
514
+ metadata: {},
515
+ },
516
+ {
517
+ name: 'skill',
518
+ namespace: 'plugin-a', // Duplicate namespace
519
+ canonicalName: 'plugin-a:skill-2',
520
+ type: 'skill',
521
+ filePath: '/a2.md',
522
+ source: 'plugin:plugin-a',
523
+ description: undefined,
524
+ metadata: {},
525
+ },
526
+ ];
527
+
528
+ const manifest = importer.getImportManifest(components);
529
+
530
+ // Should have unique, sorted namespaces
531
+ assert.deepStrictEqual(manifest.summary.namespaces, ['plugin-a', 'plugin-b']);
532
+ });
533
+
534
+ it('should handle flat (non-namespaced) components', () => {
535
+ const components: NamespacedComponent[] = [
536
+ {
537
+ name: 'flat-skill',
538
+ namespace: undefined,
539
+ canonicalName: 'flat-skill',
540
+ type: 'skill',
541
+ filePath: '/flat.md',
542
+ source: 'user',
543
+ description: undefined,
544
+ metadata: {},
545
+ },
546
+ ];
547
+
548
+ const manifest = importer.getImportManifest(components);
549
+
550
+ assert.strictEqual(manifest.entries.length, 1);
551
+ assert.strictEqual(manifest.entries[0]!.namespace, undefined);
552
+ assert.strictEqual(manifest.entries[0]!.canonicalName, 'flat-skill');
553
+ assert.deepStrictEqual(manifest.summary.namespaces, []);
554
+ });
555
+
556
+ it('should be serializable to JSON', () => {
557
+ const components: NamespacedComponent[] = [
558
+ {
559
+ name: 'skill',
560
+ namespace: 'plugin',
561
+ canonicalName: 'plugin:skill',
562
+ type: 'skill',
563
+ filePath: '/skill.md',
564
+ source: 'plugin:plugin',
565
+ description: 'A skill',
566
+ metadata: { pluginVersion: '1.0.0' },
567
+ },
568
+ ];
569
+
570
+ const manifest = importer.getImportManifest(components);
571
+
572
+ // Should be JSON serializable without errors
573
+ const json = JSON.stringify(manifest);
574
+ const parsed = JSON.parse(json);
575
+
576
+ assert.strictEqual(parsed.schemaVersion, '1.0');
577
+ assert.strictEqual(parsed.entries[0].canonicalName, 'plugin:skill');
578
+ });
579
+ });
580
+
581
+ describe('Full Pipeline: discover → select → validate → manifest', () => {
582
+ it('should execute full pipeline with mock components', () => {
583
+ // Stage 1: Discover (empty in this case)
584
+ const discovery = importer.discover([]);
585
+ assert.strictEqual(discovery.summary.totalComponents, 0);
586
+
587
+ // Stage 2: Select all (empty)
588
+ const selected = importer.selectComponents(() => true);
589
+ assert.strictEqual(selected.length, 0);
590
+
591
+ // Stage 3: Validate
592
+ const validation = importer.validateImport(selected);
593
+ assert.strictEqual(validation.canProceed, true);
594
+
595
+ // Stage 4: Manifest
596
+ const manifest = importer.getImportManifest(selected);
597
+ assert.strictEqual(manifest.summary.total, 0);
598
+ });
599
+
600
+ it('should preserve canonical names through full pipeline (R013)', () => {
601
+ // Start with discovery
602
+ importer.discover([]);
603
+
604
+ // Create mock components as if they were discovered
605
+ const components: NamespacedComponent[] = [
606
+ {
607
+ name: 'code-review',
608
+ namespace: 'my-plugin',
609
+ canonicalName: 'my-plugin:code-review',
610
+ type: 'skill',
611
+ filePath: '/plugins/my-plugin/skills/code-review/SKILL.md',
612
+ source: 'plugin:my-plugin',
613
+ description: 'Reviews code',
614
+ metadata: { pluginVersion: '1.0.0' },
615
+ },
616
+ {
617
+ name: 'architect',
618
+ namespace: 'my-plugin',
619
+ canonicalName: 'my-plugin:architect',
620
+ type: 'agent',
621
+ filePath: '/plugins/my-plugin/agents/architect/AGENT.md',
622
+ source: 'plugin:my-plugin',
623
+ description: 'Designs architecture',
624
+ metadata: { pluginVersion: '1.0.0' },
625
+ },
626
+ ];
627
+
628
+ // Stage 3: Validate (no collisions)
629
+ const validation = importer.validateImport(components);
630
+ assert.strictEqual(validation.canProceed, true);
631
+
632
+ // Stage 4: Manifest
633
+ const manifest = importer.getImportManifest(components);
634
+
635
+ // Verify canonical names preserved
636
+ assert.strictEqual(manifest.entries.length, 2);
637
+ assert.strictEqual(manifest.entries[0]!.canonicalName, 'my-plugin:code-review');
638
+ assert.strictEqual(manifest.entries[1]!.canonicalName, 'my-plugin:architect');
639
+
640
+ // Verify round-trip identity
641
+ const skill = manifest.entries.find((e) => e.type === 'skill');
642
+ assert.ok(skill !== undefined);
643
+ assert.strictEqual(skill!.canonicalName, 'my-plugin:code-review');
644
+ assert.strictEqual(skill!.name, 'code-review');
645
+ assert.strictEqual(skill!.namespace, 'my-plugin');
646
+ });
647
+
648
+ it('should block import on canonical collision', () => {
649
+ importer.discover([]);
650
+
651
+ const components: NamespacedComponent[] = [
652
+ {
653
+ name: 'skill',
654
+ namespace: 'ns',
655
+ canonicalName: 'ns:skill',
656
+ type: 'skill',
657
+ filePath: '/first.md',
658
+ source: 'first',
659
+ description: undefined,
660
+ metadata: {},
661
+ },
662
+ {
663
+ name: 'skill',
664
+ namespace: 'ns',
665
+ canonicalName: 'ns:skill', // Collision!
666
+ type: 'skill',
667
+ filePath: '/second.md',
668
+ source: 'second',
669
+ description: undefined,
670
+ metadata: {},
671
+ },
672
+ ];
673
+
674
+ const validation = importer.validateImport(components);
675
+
676
+ // Should block
677
+ assert.strictEqual(validation.canProceed, false);
678
+
679
+ // Diagnostic should explain why
680
+ assert.strictEqual(validation.summary.errors, 1);
681
+ assert.ok(validation.diagnostics[0]!.remediation.length > 0);
682
+ });
683
+
684
+ it('should allow import with warnings (shorthand overlap)', () => {
685
+ importer.discover([]);
686
+
687
+ const components: NamespacedComponent[] = [
688
+ {
689
+ name: 'review',
690
+ namespace: 'plugin-a',
691
+ canonicalName: 'plugin-a:review',
692
+ type: 'skill',
693
+ filePath: '/a.md',
694
+ source: 'plugin:plugin-a',
695
+ description: undefined,
696
+ metadata: {},
697
+ },
698
+ {
699
+ name: 'review',
700
+ namespace: 'plugin-b',
701
+ canonicalName: 'plugin-b:review',
702
+ type: 'skill',
703
+ filePath: '/b.md',
704
+ source: 'plugin:plugin-b',
705
+ description: undefined,
706
+ metadata: {},
707
+ },
708
+ ];
709
+
710
+ const validation = importer.validateImport(components);
711
+
712
+ // Should NOT block (warning only)
713
+ assert.strictEqual(validation.canProceed, true);
714
+ assert.strictEqual(validation.summary.warnings, 1);
715
+
716
+ // Manifest should still work
717
+ const manifest = importer.getImportManifest(components);
718
+ assert.strictEqual(manifest.entries.length, 2);
719
+ });
720
+ });
721
+
722
+ describe('Inspection methods', () => {
723
+ it('should return null for getRegistry() before discover()', () => {
724
+ assert.strictEqual(importer.getRegistry(), null);
725
+ });
726
+
727
+ it('should return registry after discover()', () => {
728
+ importer.discover([]);
729
+ assert.ok(importer.getRegistry() !== null);
730
+ });
731
+
732
+ it('should return empty array for getDiscoveredPlugins() before discover()', () => {
733
+ const plugins = importer.getDiscoveredPlugins();
734
+ assert.deepStrictEqual(plugins, []);
735
+ });
736
+
737
+ it('should return null for getLastValidation() before validateImport()', () => {
738
+ assert.strictEqual(importer.getLastValidation(), null);
739
+ });
740
+
741
+ it('should return last validation after validateImport()', () => {
742
+ importer.discover([]);
743
+ importer.validateImport([]);
744
+ assert.ok(importer.getLastValidation() !== null);
745
+ });
746
+
747
+ it('should return null for getLastDiscovery() before discover()', () => {
748
+ assert.strictEqual(importer.getLastDiscovery(), null);
749
+ });
750
+
751
+ it('should return last discovery after discover()', () => {
752
+ importer.discover([]);
753
+ assert.ok(importer.getLastDiscovery() !== null);
754
+ });
755
+ });
756
+
757
+ describe('Diagnostic structure verification', () => {
758
+ it('should provide actionable remediation in diagnostics', () => {
759
+ importer.discover([]);
760
+
761
+ const components: NamespacedComponent[] = [
762
+ {
763
+ name: 'dup',
764
+ namespace: 'ns',
765
+ canonicalName: 'ns:dup',
766
+ type: 'skill',
767
+ filePath: '/first.md',
768
+ source: 'first',
769
+ description: undefined,
770
+ metadata: {},
771
+ },
772
+ {
773
+ name: 'dup',
774
+ namespace: 'ns',
775
+ canonicalName: 'ns:dup',
776
+ type: 'skill',
777
+ filePath: '/second.md',
778
+ source: 'second',
779
+ description: undefined,
780
+ metadata: {},
781
+ },
782
+ ];
783
+
784
+ const validation = importer.validateImport(components);
785
+ const diag = validation.diagnostics[0];
786
+
787
+ assert.ok(diag !== undefined);
788
+ assert.ok(diag!.remediation.length > 0);
789
+ assert.ok(diag!.remediation.includes('ns:dup'));
790
+ });
791
+
792
+ it('should include file paths in collision diagnostic', () => {
793
+ importer.discover([]);
794
+
795
+ const components: NamespacedComponent[] = [
796
+ {
797
+ name: 'dup',
798
+ namespace: 'ns',
799
+ canonicalName: 'ns:dup',
800
+ type: 'skill',
801
+ filePath: '/first/dup.md',
802
+ source: 'first',
803
+ description: undefined,
804
+ metadata: {},
805
+ },
806
+ {
807
+ name: 'dup',
808
+ namespace: 'ns',
809
+ canonicalName: 'ns:dup',
810
+ type: 'skill',
811
+ filePath: '/second/dup.md',
812
+ source: 'second',
813
+ description: undefined,
814
+ metadata: {},
815
+ },
816
+ ];
817
+
818
+ const validation = importer.validateImport(components);
819
+ const diag = validation.diagnostics[0];
820
+
821
+ assert.ok(diag!.filePaths.includes('/first/dup.md'));
822
+ assert.ok(diag!.filePaths.includes('/second/dup.md'));
823
+ });
824
+ });
825
+ });
826
+
827
+ describe('R012: Discover / select / import flow', () => {
828
+ it('should support staged discovery → selection → validation → manifest', () => {
829
+ const importer = new PluginImporter();
830
+
831
+ // Stage 1: Discover
832
+ const discovery = importer.discover([]);
833
+ assert.ok(discovery.registry !== undefined);
834
+
835
+ // Stage 2: Select
836
+ const selected = importer.selectComponents(() => true);
837
+ assert.ok(Array.isArray(selected));
838
+
839
+ // Stage 3: Validate
840
+ const validation = importer.validateImport(selected);
841
+ assert.ok(typeof validation.canProceed === 'boolean');
842
+ assert.ok(Array.isArray(validation.diagnostics));
843
+
844
+ // Stage 4: Manifest
845
+ const manifest = importer.getImportManifest(selected);
846
+ assert.ok(manifest.schemaVersion === '1.0');
847
+ assert.ok(Array.isArray(manifest.entries));
848
+ });
849
+
850
+ it('should allow independent testing of each stage', () => {
851
+ const importer = new PluginImporter();
852
+
853
+ // Each stage can be tested independently
854
+ importer.discover([]);
855
+
856
+ // Selection can be called multiple times with different filters
857
+ const all = importer.selectComponents(() => true);
858
+ const skills = importer.selectComponents((c) => c.type === 'skill');
859
+ const agents = importer.selectComponents((c) => c.type === 'agent');
860
+
861
+ // All should work without error
862
+ assert.ok(true);
863
+
864
+ // Validation can be called with any component set
865
+ const validation1 = importer.validateImport(all);
866
+ const validation2 = importer.validateImport(skills);
867
+ const validation3 = importer.validateImport(agents);
868
+
869
+ assert.ok(validation1.canProceed === true);
870
+ assert.ok(validation2.canProceed === true);
871
+ assert.ok(validation3.canProceed === true);
872
+
873
+ // Manifest can be generated for any component set
874
+ const manifest1 = importer.getImportManifest(all);
875
+ const manifest2 = importer.getImportManifest(skills);
876
+ const manifest3 = importer.getImportManifest(agents);
877
+
878
+ assert.ok(manifest1.schemaVersion === '1.0');
879
+ assert.ok(manifest2.schemaVersion === '1.0');
880
+ assert.ok(manifest3.schemaVersion === '1.0');
881
+ });
882
+ });
883
+
884
+ describe('R013: Canonical name preservation', () => {
885
+ it('should preserve plugin:component format in manifest entries', () => {
886
+ const importer = new PluginImporter();
887
+
888
+ const components: NamespacedComponent[] = [
889
+ {
890
+ name: 'my-skill',
891
+ namespace: 'my-plugin',
892
+ canonicalName: 'my-plugin:my-skill',
893
+ type: 'skill',
894
+ filePath: '/skill.md',
895
+ source: 'plugin:my-plugin',
896
+ description: undefined,
897
+ metadata: {},
898
+ },
899
+ ];
900
+
901
+ const manifest = importer.getImportManifest(components);
902
+
903
+ assert.strictEqual(manifest.entries[0]!.canonicalName, 'my-plugin:my-skill');
904
+ });
905
+
906
+ it('should preserve flat names for non-namespaced components', () => {
907
+ const importer = new PluginImporter();
908
+
909
+ const components: NamespacedComponent[] = [
910
+ {
911
+ name: 'flat-skill',
912
+ namespace: undefined,
913
+ canonicalName: 'flat-skill',
914
+ type: 'skill',
915
+ filePath: '/skill.md',
916
+ source: 'user',
917
+ description: undefined,
918
+ metadata: {},
919
+ },
920
+ ];
921
+
922
+ const manifest = importer.getImportManifest(components);
923
+
924
+ assert.strictEqual(manifest.entries[0]!.canonicalName, 'flat-skill');
925
+ assert.strictEqual(manifest.entries[0]!.namespace, undefined);
926
+ });
927
+
928
+ it('should support round-trip identity (name + namespace → canonical)', () => {
929
+ const importer = new PluginImporter();
930
+
931
+ const components: NamespacedComponent[] = [
932
+ {
933
+ name: 'component',
934
+ namespace: 'namespace',
935
+ canonicalName: 'namespace:component',
936
+ type: 'skill',
937
+ filePath: '/path',
938
+ source: 'source',
939
+ description: undefined,
940
+ metadata: {},
941
+ },
942
+ ];
943
+
944
+ const manifest = importer.getImportManifest(components);
945
+ const entry = manifest.entries[0]!;
946
+
947
+ // Round-trip: namespace:name should equal canonicalName
948
+ const reconstructed = entry.namespace
949
+ ? `${entry.namespace}:${entry.name}`
950
+ : entry.name;
951
+
952
+ assert.strictEqual(reconstructed, entry.canonicalName);
953
+ assert.strictEqual(reconstructed, 'namespace:component');
954
+ });
955
+ });
956
+
957
+ // ============================================================================
958
+ // T02: Command Flow Integration Tests
959
+ // ============================================================================
960
+
961
+ describe('T02: Command flow integration', () => {
962
+ describe('Marketplace detection', () => {
963
+ it('should categorize plugin roots into marketplaces vs flat paths', () => {
964
+ // Import the helper function (we'll need to export it for testing)
965
+ // For now, test the logic indirectly
966
+ const importer = new PluginImporter();
967
+
968
+ // Non-existent paths should still work
969
+ const result = importer.discover(['/nonexistent/marketplace']);
970
+
971
+ // Should not crash and return valid structure
972
+ assert.ok(result.summary.marketplacesProcessed === 1);
973
+ });
974
+
975
+ it('should handle empty marketplace paths gracefully', () => {
976
+ const importer = new PluginImporter();
977
+
978
+ const result = importer.discover([]);
979
+
980
+ assert.strictEqual(result.summary.marketplacesProcessed, 0);
981
+ assert.strictEqual(result.summary.totalPlugins, 0);
982
+ assert.strictEqual(result.summary.totalComponents, 0);
983
+ });
984
+ });
985
+
986
+ describe('Component selection flow', () => {
987
+ it('should support filtering by plugin namespace', () => {
988
+ const importer = new PluginImporter();
989
+ importer.discover([]);
990
+
991
+ // Create mock components as if discovered
992
+ const components: NamespacedComponent[] = [
993
+ {
994
+ name: 'skill-a',
995
+ namespace: 'plugin-x',
996
+ canonicalName: 'plugin-x:skill-a',
997
+ type: 'skill',
998
+ filePath: '/x/skill-a.md',
999
+ source: 'plugin:plugin-x',
1000
+ description: undefined,
1001
+ metadata: {},
1002
+ },
1003
+ {
1004
+ name: 'skill-b',
1005
+ namespace: 'plugin-y',
1006
+ canonicalName: 'plugin-y:skill-b',
1007
+ type: 'skill',
1008
+ filePath: '/y/skill-b.md',
1009
+ source: 'plugin:plugin-y',
1010
+ description: undefined,
1011
+ metadata: {},
1012
+ },
1013
+ ];
1014
+
1015
+ // Validate should work with any component set
1016
+ const validation = importer.validateImport(components);
1017
+ assert.strictEqual(validation.canProceed, true);
1018
+
1019
+ // Manifest should preserve namespace info
1020
+ const manifest = importer.getImportManifest(components);
1021
+ assert.strictEqual(manifest.entries.length, 2);
1022
+ assert.strictEqual(manifest.summary.namespaces.length, 2);
1023
+ assert.ok(manifest.summary.namespaces.includes('plugin-x'));
1024
+ assert.ok(manifest.summary.namespaces.includes('plugin-y'));
1025
+ });
1026
+
1027
+ it('should support filtering by component type', () => {
1028
+ const importer = new PluginImporter();
1029
+ importer.discover([]);
1030
+
1031
+ const components: NamespacedComponent[] = [
1032
+ {
1033
+ name: 'skill-a',
1034
+ namespace: 'plugin',
1035
+ canonicalName: 'plugin:skill-a',
1036
+ type: 'skill',
1037
+ filePath: '/skill-a.md',
1038
+ source: 'plugin:plugin',
1039
+ description: undefined,
1040
+ metadata: {},
1041
+ },
1042
+ {
1043
+ name: 'agent-x',
1044
+ namespace: 'plugin',
1045
+ canonicalName: 'plugin:agent-x',
1046
+ type: 'agent',
1047
+ filePath: '/agent-x.md',
1048
+ source: 'plugin:plugin',
1049
+ description: undefined,
1050
+ metadata: {},
1051
+ },
1052
+ ];
1053
+
1054
+ const manifest = importer.getImportManifest(components);
1055
+
1056
+ assert.strictEqual(manifest.summary.skills, 1);
1057
+ assert.strictEqual(manifest.summary.agents, 1);
1058
+ });
1059
+ });
1060
+
1061
+ describe('Pre-import diagnostics gating', () => {
1062
+ it('should block import on canonical collision (error)', () => {
1063
+ const importer = new PluginImporter();
1064
+ importer.discover([]);
1065
+
1066
+ const components: NamespacedComponent[] = [
1067
+ {
1068
+ name: 'skill',
1069
+ namespace: 'ns',
1070
+ canonicalName: 'ns:skill',
1071
+ type: 'skill',
1072
+ filePath: '/first.md',
1073
+ source: 'first',
1074
+ description: undefined,
1075
+ metadata: {},
1076
+ },
1077
+ {
1078
+ name: 'skill',
1079
+ namespace: 'ns',
1080
+ canonicalName: 'ns:skill', // Collision
1081
+ type: 'skill',
1082
+ filePath: '/second.md',
1083
+ source: 'second',
1084
+ description: undefined,
1085
+ metadata: {},
1086
+ },
1087
+ ];
1088
+
1089
+ const validation = importer.validateImport(components);
1090
+
1091
+ // Should block - error severity
1092
+ assert.strictEqual(validation.canProceed, false);
1093
+ assert.strictEqual(validation.summary.errors, 1);
1094
+ });
1095
+
1096
+ it('should allow import with shorthand overlap (warning)', () => {
1097
+ const importer = new PluginImporter();
1098
+ importer.discover([]);
1099
+
1100
+ const components: NamespacedComponent[] = [
1101
+ {
1102
+ name: 'review',
1103
+ namespace: 'plugin-a',
1104
+ canonicalName: 'plugin-a:review',
1105
+ type: 'skill',
1106
+ filePath: '/a/review.md',
1107
+ source: 'plugin:plugin-a',
1108
+ description: undefined,
1109
+ metadata: {},
1110
+ },
1111
+ {
1112
+ name: 'review',
1113
+ namespace: 'plugin-b',
1114
+ canonicalName: 'plugin-b:review',
1115
+ type: 'skill',
1116
+ filePath: '/b/review.md',
1117
+ source: 'plugin:plugin-b',
1118
+ description: undefined,
1119
+ metadata: {},
1120
+ },
1121
+ ];
1122
+
1123
+ const validation = importer.validateImport(components);
1124
+
1125
+ // Should NOT block - warning only
1126
+ assert.strictEqual(validation.canProceed, true);
1127
+ assert.strictEqual(validation.summary.warnings, 1);
1128
+ assert.strictEqual(validation.summary.errors, 0);
1129
+ });
1130
+
1131
+ it('should provide actionable diagnostics for blocking errors', () => {
1132
+ const importer = new PluginImporter();
1133
+ importer.discover([]);
1134
+
1135
+ const components: NamespacedComponent[] = [
1136
+ {
1137
+ name: 'dup',
1138
+ namespace: 'ns',
1139
+ canonicalName: 'ns:dup',
1140
+ type: 'skill',
1141
+ filePath: '/first.md',
1142
+ source: 'first',
1143
+ description: undefined,
1144
+ metadata: {},
1145
+ },
1146
+ {
1147
+ name: 'dup',
1148
+ namespace: 'ns',
1149
+ canonicalName: 'ns:dup',
1150
+ type: 'skill',
1151
+ filePath: '/second.md',
1152
+ source: 'second',
1153
+ description: undefined,
1154
+ metadata: {},
1155
+ },
1156
+ ];
1157
+
1158
+ const validation = importer.validateImport(components);
1159
+
1160
+ // Should have diagnostic with remediation
1161
+ assert.strictEqual(validation.diagnostics.length, 1);
1162
+ assert.ok(validation.diagnostics[0]!.remediation.length > 0);
1163
+ assert.ok(validation.diagnostics[0]!.remediation.includes('ns:dup'));
1164
+ });
1165
+ });
1166
+
1167
+ describe('Config persistence with canonical names', () => {
1168
+ it('should preserve canonical names in manifest for persistence', () => {
1169
+ const importer = new PluginImporter();
1170
+
1171
+ const components: NamespacedComponent[] = [
1172
+ {
1173
+ name: 'code-review',
1174
+ namespace: 'my-plugin',
1175
+ canonicalName: 'my-plugin:code-review',
1176
+ type: 'skill',
1177
+ filePath: '/plugins/my-plugin/skills/code-review/SKILL.md',
1178
+ source: 'plugin:my-plugin',
1179
+ description: 'Reviews code',
1180
+ metadata: { pluginVersion: '1.0.0' },
1181
+ },
1182
+ {
1183
+ name: 'architect',
1184
+ namespace: 'my-plugin',
1185
+ canonicalName: 'my-plugin:architect',
1186
+ type: 'agent',
1187
+ filePath: '/plugins/my-plugin/agents/architect/AGENT.md',
1188
+ source: 'plugin:my-plugin',
1189
+ description: 'Designs architecture',
1190
+ metadata: { pluginVersion: '1.0.0' },
1191
+ },
1192
+ ];
1193
+
1194
+ const manifest = importer.getImportManifest(components);
1195
+
1196
+ // Verify canonical names preserved
1197
+ assert.strictEqual(manifest.entries.length, 2);
1198
+ assert.strictEqual(manifest.entries[0]!.canonicalName, 'my-plugin:code-review');
1199
+ assert.strictEqual(manifest.entries[1]!.canonicalName, 'my-plugin:architect');
1200
+
1201
+ // Verify manifest is JSON-serializable for config persistence
1202
+ const json = JSON.stringify(manifest);
1203
+ const parsed = JSON.parse(json);
1204
+ assert.strictEqual(parsed.entries[0].canonicalName, 'my-plugin:code-review');
1205
+ });
1206
+
1207
+ it('should include file paths for settings persistence', () => {
1208
+ const importer = new PluginImporter();
1209
+
1210
+ const components: NamespacedComponent[] = [
1211
+ {
1212
+ name: 'skill',
1213
+ namespace: 'plugin',
1214
+ canonicalName: 'plugin:skill',
1215
+ type: 'skill',
1216
+ filePath: '/absolute/path/to/skill.md',
1217
+ source: 'plugin:plugin',
1218
+ description: undefined,
1219
+ metadata: {},
1220
+ },
1221
+ ];
1222
+
1223
+ const manifest = importer.getImportManifest(components);
1224
+
1225
+ assert.strictEqual(manifest.entries[0]!.filePath, '/absolute/path/to/skill.md');
1226
+ });
1227
+
1228
+ it('should separate skills and agents for settings routing', () => {
1229
+ const importer = new PluginImporter();
1230
+
1231
+ const components: NamespacedComponent[] = [
1232
+ {
1233
+ name: 'skill-1',
1234
+ namespace: 'p',
1235
+ canonicalName: 'p:skill-1',
1236
+ type: 'skill',
1237
+ filePath: '/s1.md',
1238
+ source: 'plugin:p',
1239
+ description: undefined,
1240
+ metadata: {},
1241
+ },
1242
+ {
1243
+ name: 'skill-2',
1244
+ namespace: 'p',
1245
+ canonicalName: 'p:skill-2',
1246
+ type: 'skill',
1247
+ filePath: '/s2.md',
1248
+ source: 'plugin:p',
1249
+ description: undefined,
1250
+ metadata: {},
1251
+ },
1252
+ {
1253
+ name: 'agent-1',
1254
+ namespace: 'p',
1255
+ canonicalName: 'p:agent-1',
1256
+ type: 'agent',
1257
+ filePath: '/a1.md',
1258
+ source: 'plugin:p',
1259
+ description: undefined,
1260
+ metadata: {},
1261
+ },
1262
+ ];
1263
+
1264
+ const manifest = importer.getImportManifest(components);
1265
+
1266
+ const skills = manifest.entries.filter(e => e.type === 'skill');
1267
+ const agents = manifest.entries.filter(e => e.type === 'agent');
1268
+
1269
+ assert.strictEqual(skills.length, 2);
1270
+ assert.strictEqual(agents.length, 1);
1271
+ });
1272
+ });
1273
+
1274
+ describe('End-to-end command flow simulation', () => {
1275
+ it('should execute full pipeline: discover → select → validate → manifest', () => {
1276
+ const importer = new PluginImporter();
1277
+
1278
+ // Stage 1: Discover (empty in this test)
1279
+ const discovery = importer.discover([]);
1280
+ assert.strictEqual(discovery.summary.totalComponents, 0);
1281
+
1282
+ // Stage 2: Simulate user selection (mock components)
1283
+ const selected: NamespacedComponent[] = [
1284
+ {
1285
+ name: 'code-review',
1286
+ namespace: 'my-plugin',
1287
+ canonicalName: 'my-plugin:code-review',
1288
+ type: 'skill',
1289
+ filePath: '/plugins/my-plugin/skills/code-review/SKILL.md',
1290
+ source: 'plugin:my-plugin',
1291
+ description: 'Reviews code',
1292
+ metadata: { pluginVersion: '1.0.0' },
1293
+ },
1294
+ ];
1295
+
1296
+ // Stage 3: Validate
1297
+ const validation = importer.validateImport(selected);
1298
+ assert.strictEqual(validation.canProceed, true);
1299
+
1300
+ // Stage 4: Generate manifest
1301
+ const manifest = importer.getImportManifest(selected);
1302
+ assert.strictEqual(manifest.entries.length, 1);
1303
+ assert.strictEqual(manifest.entries[0]!.canonicalName, 'my-plugin:code-review');
1304
+ });
1305
+
1306
+ it('should block on validation failure before persistence', () => {
1307
+ const importer = new PluginImporter();
1308
+ importer.discover([]);
1309
+
1310
+ const selected: NamespacedComponent[] = [
1311
+ {
1312
+ name: 'dup',
1313
+ namespace: 'ns',
1314
+ canonicalName: 'ns:dup',
1315
+ type: 'skill',
1316
+ filePath: '/first.md',
1317
+ source: 'first',
1318
+ description: undefined,
1319
+ metadata: {},
1320
+ },
1321
+ {
1322
+ name: 'dup',
1323
+ namespace: 'ns',
1324
+ canonicalName: 'ns:dup',
1325
+ type: 'skill',
1326
+ filePath: '/second.md',
1327
+ source: 'second',
1328
+ description: undefined,
1329
+ metadata: {},
1330
+ },
1331
+ ];
1332
+
1333
+ const validation = importer.validateImport(selected);
1334
+
1335
+ // Simulate command flow logic: should NOT proceed to persistence
1336
+ if (validation.canProceed) {
1337
+ // This should NOT be reached
1338
+ assert.fail('Should not proceed to persistence with errors');
1339
+ } else {
1340
+ // Correct: blocked before persistence
1341
+ assert.strictEqual(validation.summary.errors, 1);
1342
+ }
1343
+ });
1344
+
1345
+ it('should allow proceeding after user confirms warnings', () => {
1346
+ const importer = new PluginImporter();
1347
+ importer.discover([]);
1348
+
1349
+ const selected: NamespacedComponent[] = [
1350
+ {
1351
+ name: 'review',
1352
+ namespace: 'plugin-a',
1353
+ canonicalName: 'plugin-a:review',
1354
+ type: 'skill',
1355
+ filePath: '/a/review.md',
1356
+ source: 'plugin:plugin-a',
1357
+ description: undefined,
1358
+ metadata: {},
1359
+ },
1360
+ {
1361
+ name: 'review',
1362
+ namespace: 'plugin-b',
1363
+ canonicalName: 'plugin-b:review',
1364
+ type: 'skill',
1365
+ filePath: '/b/review.md',
1366
+ source: 'plugin:plugin-b',
1367
+ description: undefined,
1368
+ metadata: {},
1369
+ },
1370
+ ];
1371
+
1372
+ const validation = importer.validateImport(selected);
1373
+
1374
+ // Warnings should NOT block
1375
+ assert.strictEqual(validation.canProceed, true);
1376
+ assert.strictEqual(validation.summary.warnings, 1);
1377
+
1378
+ // Simulate user confirmation and proceed to manifest
1379
+ const manifest = importer.getImportManifest(selected);
1380
+ assert.strictEqual(manifest.entries.length, 2);
1381
+ });
1382
+ });
1383
+ });