@skillsmith/core 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/README.md +2 -2
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/src/api/client.d.ts +5 -3
  5. package/dist/src/api/client.d.ts.map +1 -1
  6. package/dist/src/api/client.js +23 -33
  7. package/dist/src/api/client.js.map +1 -1
  8. package/dist/src/api/client.registry-sync.d.ts +28 -0
  9. package/dist/src/api/client.registry-sync.d.ts.map +1 -0
  10. package/dist/src/api/client.registry-sync.js +36 -0
  11. package/dist/src/api/client.registry-sync.js.map +1 -0
  12. package/dist/src/api/client.test.js +185 -0
  13. package/dist/src/api/client.test.js.map +1 -1
  14. package/dist/src/api/client.toSkill.d.ts +16 -0
  15. package/dist/src/api/client.toSkill.d.ts.map +1 -0
  16. package/dist/src/api/client.toSkill.js +46 -0
  17. package/dist/src/api/client.toSkill.js.map +1 -0
  18. package/dist/src/api/client.types.d.ts +22 -0
  19. package/dist/src/api/client.types.d.ts.map +1 -1
  20. package/dist/src/api/index.d.ts +1 -1
  21. package/dist/src/api/index.d.ts.map +1 -1
  22. package/dist/src/api/index.js.map +1 -1
  23. package/dist/src/api/schemas.d.ts +28 -0
  24. package/dist/src/api/schemas.d.ts.map +1 -1
  25. package/dist/src/api/schemas.js +13 -0
  26. package/dist/src/api/schemas.js.map +1 -1
  27. package/dist/src/audit/remote-audit.d.ts +85 -0
  28. package/dist/src/audit/remote-audit.d.ts.map +1 -1
  29. package/dist/src/audit/remote-audit.js +126 -3
  30. package/dist/src/audit/remote-audit.js.map +1 -1
  31. package/dist/src/audit/remote-audit.test.js +217 -1
  32. package/dist/src/audit/remote-audit.test.js.map +1 -1
  33. package/dist/src/config/index.d.ts +1 -0
  34. package/dist/src/config/index.d.ts.map +1 -1
  35. package/dist/src/config/index.js.map +1 -1
  36. package/dist/src/db/migration-runner.d.ts.map +1 -1
  37. package/dist/src/db/migration-runner.js +6 -0
  38. package/dist/src/db/migration-runner.js.map +1 -1
  39. package/dist/src/db/migrations/v18-skill-versions-real-content-hash.d.ts +36 -0
  40. package/dist/src/db/migrations/v18-skill-versions-real-content-hash.d.ts.map +1 -0
  41. package/dist/src/db/migrations/v18-skill-versions-real-content-hash.js +38 -0
  42. package/dist/src/db/migrations/v18-skill-versions-real-content-hash.js.map +1 -0
  43. package/dist/src/db/schema.d.ts +1 -1
  44. package/dist/src/db/schema.d.ts.map +1 -1
  45. package/dist/src/db/schema.js +3 -1
  46. package/dist/src/db/schema.js.map +1 -1
  47. package/dist/src/exports/services.d.ts +3 -7
  48. package/dist/src/exports/services.d.ts.map +1 -1
  49. package/dist/src/exports/services.install.d.ts +18 -0
  50. package/dist/src/exports/services.install.d.ts.map +1 -0
  51. package/dist/src/exports/services.install.js +62 -0
  52. package/dist/src/exports/services.install.js.map +1 -0
  53. package/dist/src/exports/services.js +12 -32
  54. package/dist/src/exports/services.js.map +1 -1
  55. package/dist/src/exports/types.d.ts +1 -1
  56. package/dist/src/exports/types.d.ts.map +1 -1
  57. package/dist/src/index.d.ts +5 -5
  58. package/dist/src/index.d.ts.map +1 -1
  59. package/dist/src/index.js +7 -4
  60. package/dist/src/index.js.map +1 -1
  61. package/dist/src/install/agent-config-merge.json.d.ts +5 -4
  62. package/dist/src/install/agent-config-merge.json.d.ts.map +1 -1
  63. package/dist/src/install/agent-config-merge.json.js +10 -9
  64. package/dist/src/install/agent-config-merge.json.js.map +1 -1
  65. package/dist/src/install/agent-config-merge.types.d.ts +11 -1
  66. package/dist/src/install/agent-config-merge.types.d.ts.map +1 -1
  67. package/dist/src/install/agent-config-merge.types.js.map +1 -1
  68. package/dist/src/install/agent-harness-targets.d.ts +30 -2
  69. package/dist/src/install/agent-harness-targets.d.ts.map +1 -1
  70. package/dist/src/install/agent-harness-targets.js +17 -0
  71. package/dist/src/install/agent-harness-targets.js.map +1 -1
  72. package/dist/src/install/agent-manifest-path-guard.d.ts +28 -3
  73. package/dist/src/install/agent-manifest-path-guard.d.ts.map +1 -1
  74. package/dist/src/install/agent-manifest-path-guard.js +59 -3
  75. package/dist/src/install/agent-manifest-path-guard.js.map +1 -1
  76. package/dist/src/install/agent-manifest-path-guard.test.js +27 -1
  77. package/dist/src/install/agent-manifest-path-guard.test.js.map +1 -1
  78. package/dist/src/install/agent-pack-installer.antigravity-mcp.d.ts +74 -0
  79. package/dist/src/install/agent-pack-installer.antigravity-mcp.d.ts.map +1 -0
  80. package/dist/src/install/agent-pack-installer.antigravity-mcp.js +106 -0
  81. package/dist/src/install/agent-pack-installer.antigravity-mcp.js.map +1 -0
  82. package/dist/src/install/agent-pack-installer.antigravity-mcp.test.d.ts +2 -0
  83. package/dist/src/install/agent-pack-installer.antigravity-mcp.test.d.ts.map +1 -0
  84. package/dist/src/install/agent-pack-installer.antigravity-mcp.test.js +157 -0
  85. package/dist/src/install/agent-pack-installer.antigravity-mcp.test.js.map +1 -0
  86. package/dist/src/install/agent-pack-installer.cursor-mcp.d.ts +53 -0
  87. package/dist/src/install/agent-pack-installer.cursor-mcp.d.ts.map +1 -0
  88. package/dist/src/install/agent-pack-installer.cursor-mcp.js +207 -0
  89. package/dist/src/install/agent-pack-installer.cursor-mcp.js.map +1 -0
  90. package/dist/src/install/agent-pack-installer.cursor-mcp.test.d.ts +2 -0
  91. package/dist/src/install/agent-pack-installer.cursor-mcp.test.d.ts.map +1 -0
  92. package/dist/src/install/agent-pack-installer.cursor-mcp.test.js +285 -0
  93. package/dist/src/install/agent-pack-installer.cursor-mcp.test.js.map +1 -0
  94. package/dist/src/install/agent-pack-installer.d.ts +8 -0
  95. package/dist/src/install/agent-pack-installer.d.ts.map +1 -1
  96. package/dist/src/install/agent-pack-installer.entry.d.ts +120 -3
  97. package/dist/src/install/agent-pack-installer.entry.d.ts.map +1 -1
  98. package/dist/src/install/agent-pack-installer.entry.js +166 -3
  99. package/dist/src/install/agent-pack-installer.entry.js.map +1 -1
  100. package/dist/src/install/agent-pack-installer.js +97 -3
  101. package/dist/src/install/agent-pack-installer.js.map +1 -1
  102. package/dist/src/install/agent-pack-installer.types.d.ts +27 -0
  103. package/dist/src/install/agent-pack-installer.types.d.ts.map +1 -1
  104. package/dist/src/install/agent-pack-installer.types.js +6 -0
  105. package/dist/src/install/agent-pack-installer.types.js.map +1 -1
  106. package/dist/src/install/agent-pack-installer.workspace-scope.test.d.ts +2 -0
  107. package/dist/src/install/agent-pack-installer.workspace-scope.test.d.ts.map +1 -0
  108. package/dist/src/install/agent-pack-installer.workspace-scope.test.js +148 -0
  109. package/dist/src/install/agent-pack-installer.workspace-scope.test.js.map +1 -0
  110. package/dist/src/install/agent-pack-uninstaller.d.ts +18 -7
  111. package/dist/src/install/agent-pack-uninstaller.d.ts.map +1 -1
  112. package/dist/src/install/agent-pack-uninstaller.js +59 -9
  113. package/dist/src/install/agent-pack-uninstaller.js.map +1 -1
  114. package/dist/src/install/agent-pack-uninstaller.test.js +74 -1
  115. package/dist/src/install/agent-pack-uninstaller.test.js.map +1 -1
  116. package/dist/src/install/fan-out.d.ts.map +1 -1
  117. package/dist/src/install/fan-out.js +6 -0
  118. package/dist/src/install/fan-out.js.map +1 -1
  119. package/dist/src/install/index.d.ts +2 -0
  120. package/dist/src/install/index.d.ts.map +1 -1
  121. package/dist/src/install/index.js +2 -0
  122. package/dist/src/install/index.js.map +1 -1
  123. package/dist/src/install/workspace-scope.d.ts +207 -0
  124. package/dist/src/install/workspace-scope.d.ts.map +1 -0
  125. package/dist/src/install/workspace-scope.js +275 -0
  126. package/dist/src/install/workspace-scope.js.map +1 -0
  127. package/dist/src/install/workspace-scope.test.d.ts +2 -0
  128. package/dist/src/install/workspace-scope.test.d.ts.map +1 -0
  129. package/dist/src/install/workspace-scope.test.js +378 -0
  130. package/dist/src/install/workspace-scope.test.js.map +1 -0
  131. package/dist/src/security/__tests__/pathValidation.test.js +30 -1
  132. package/dist/src/security/__tests__/pathValidation.test.js.map +1 -1
  133. package/dist/src/services/SubagentGenerator.client-profiles.d.ts +258 -0
  134. package/dist/src/services/SubagentGenerator.client-profiles.d.ts.map +1 -0
  135. package/dist/src/services/SubagentGenerator.client-profiles.js +260 -0
  136. package/dist/src/services/SubagentGenerator.client-profiles.js.map +1 -0
  137. package/dist/src/services/SubagentGenerator.d.ts +19 -41
  138. package/dist/src/services/SubagentGenerator.d.ts.map +1 -1
  139. package/dist/src/services/SubagentGenerator.helpers.d.ts +64 -0
  140. package/dist/src/services/SubagentGenerator.helpers.d.ts.map +1 -0
  141. package/dist/src/services/SubagentGenerator.helpers.js +228 -0
  142. package/dist/src/services/SubagentGenerator.helpers.js.map +1 -0
  143. package/dist/src/services/SubagentGenerator.js +66 -208
  144. package/dist/src/services/SubagentGenerator.js.map +1 -1
  145. package/dist/src/services/SubagentGenerator.types.d.ts +45 -0
  146. package/dist/src/services/SubagentGenerator.types.d.ts.map +1 -0
  147. package/dist/src/services/SubagentGenerator.types.js +14 -0
  148. package/dist/src/services/SubagentGenerator.types.js.map +1 -0
  149. package/dist/src/services/TransformationService.d.ts +18 -61
  150. package/dist/src/services/TransformationService.d.ts.map +1 -1
  151. package/dist/src/services/TransformationService.js +29 -17
  152. package/dist/src/services/TransformationService.js.map +1 -1
  153. package/dist/src/services/TransformationService.types.d.ts +74 -0
  154. package/dist/src/services/TransformationService.types.d.ts.map +1 -0
  155. package/dist/src/services/TransformationService.types.js +8 -0
  156. package/dist/src/services/TransformationService.types.js.map +1 -0
  157. package/dist/src/services/__tests__/SubagentGenerator.client-profiles.test.d.ts +5 -0
  158. package/dist/src/services/__tests__/SubagentGenerator.client-profiles.test.d.ts.map +1 -0
  159. package/dist/src/services/__tests__/SubagentGenerator.client-profiles.test.js +72 -0
  160. package/dist/src/services/__tests__/SubagentGenerator.client-profiles.test.js.map +1 -0
  161. package/dist/src/services/__tests__/SubagentGenerator.helpers.test.d.ts +2 -0
  162. package/dist/src/services/__tests__/SubagentGenerator.helpers.test.d.ts.map +1 -0
  163. package/dist/src/services/__tests__/SubagentGenerator.helpers.test.js +61 -0
  164. package/dist/src/services/__tests__/SubagentGenerator.helpers.test.js.map +1 -0
  165. package/dist/src/services/__tests__/SubagentGenerator.test.js +155 -0
  166. package/dist/src/services/__tests__/SubagentGenerator.test.js.map +1 -1
  167. package/dist/src/services/__tests__/TransformationService.test.js +48 -0
  168. package/dist/src/services/__tests__/TransformationService.test.js.map +1 -1
  169. package/dist/src/services/agent-pack/agent-pack.test.js +1 -0
  170. package/dist/src/services/agent-pack/agent-pack.test.js.map +1 -1
  171. package/dist/src/services/agent-pack/prompt-source.d.ts +1 -1
  172. package/dist/src/services/agent-pack/prompt-source.d.ts.map +1 -1
  173. package/dist/src/services/agent-pack/prompt-source.js +10 -3
  174. package/dist/src/services/agent-pack/prompt-source.js.map +1 -1
  175. package/dist/src/services/agent-pack/types.d.ts +26 -2
  176. package/dist/src/services/agent-pack/types.d.ts.map +1 -1
  177. package/dist/src/services/agent-pack/types.js +13 -0
  178. package/dist/src/services/agent-pack/types.js.map +1 -1
  179. package/dist/src/services/agent-tool-profile.d.ts.map +1 -1
  180. package/dist/src/services/agent-tool-profile.js +7 -0
  181. package/dist/src/services/agent-tool-profile.js.map +1 -1
  182. package/dist/src/services/agent-tool-profile.test.js +2 -2
  183. package/dist/src/services/skill-content-comparison.d.ts +71 -0
  184. package/dist/src/services/skill-content-comparison.d.ts.map +1 -0
  185. package/dist/src/services/skill-content-comparison.js +90 -0
  186. package/dist/src/services/skill-content-comparison.js.map +1 -0
  187. package/dist/src/services/skill-content-comparison.test.d.ts +6 -0
  188. package/dist/src/services/skill-content-comparison.test.d.ts.map +1 -0
  189. package/dist/src/services/skill-content-comparison.test.js +83 -0
  190. package/dist/src/services/skill-content-comparison.test.js.map +1 -0
  191. package/dist/src/services/skill-identity-classification.d.ts +202 -0
  192. package/dist/src/services/skill-identity-classification.d.ts.map +1 -0
  193. package/dist/src/services/skill-identity-classification.js +295 -0
  194. package/dist/src/services/skill-identity-classification.js.map +1 -0
  195. package/dist/src/services/skill-identity-classification.test.d.ts +6 -0
  196. package/dist/src/services/skill-identity-classification.test.d.ts.map +1 -0
  197. package/dist/src/services/skill-identity-classification.test.js +314 -0
  198. package/dist/src/services/skill-identity-classification.test.js.map +1 -0
  199. package/dist/src/services/skill-installation.content.d.ts.map +1 -1
  200. package/dist/src/services/skill-installation.content.js +6 -1
  201. package/dist/src/services/skill-installation.content.js.map +1 -1
  202. package/dist/src/services/skill-installation.helpers.d.ts +8 -15
  203. package/dist/src/services/skill-installation.helpers.d.ts.map +1 -1
  204. package/dist/src/services/skill-installation.helpers.js +11 -105
  205. package/dist/src/services/skill-installation.helpers.js.map +1 -1
  206. package/dist/src/services/skill-installation.helpers.test.js +106 -1
  207. package/dist/src/services/skill-installation.helpers.test.js.map +1 -1
  208. package/dist/src/services/skill-installation.service.js +1 -1
  209. package/dist/src/services/skill-installation.service.js.map +1 -1
  210. package/dist/src/services/skill-installation.types.d.ts +33 -0
  211. package/dist/src/services/skill-installation.types.d.ts.map +1 -1
  212. package/dist/src/services/skill-installation.types.js.map +1 -1
  213. package/dist/src/services/skill-installation.uninstall.d.ts +84 -0
  214. package/dist/src/services/skill-installation.uninstall.d.ts.map +1 -0
  215. package/dist/src/services/skill-installation.uninstall.js +252 -0
  216. package/dist/src/services/skill-installation.uninstall.js.map +1 -0
  217. package/dist/src/services/skill-manifest.d.ts +41 -0
  218. package/dist/src/services/skill-manifest.d.ts.map +1 -1
  219. package/dist/src/services/skill-manifest.js +93 -0
  220. package/dist/src/services/skill-manifest.js.map +1 -1
  221. package/dist/src/services/skill-manifest.test.js +27 -0
  222. package/dist/src/services/skill-manifest.test.js.map +1 -1
  223. package/dist/src/sync/SyncEngine.d.ts.map +1 -1
  224. package/dist/src/sync/SyncEngine.js +69 -77
  225. package/dist/src/sync/SyncEngine.js.map +1 -1
  226. package/dist/src/telemetry/agent-marker.d.ts +8 -0
  227. package/dist/src/telemetry/agent-marker.d.ts.map +1 -1
  228. package/dist/src/telemetry/agent-marker.js +7 -0
  229. package/dist/src/telemetry/agent-marker.js.map +1 -1
  230. package/dist/src/telemetry/agent-marker.test.js +7 -1
  231. package/dist/src/telemetry/agent-marker.test.js.map +1 -1
  232. package/dist/src/telemetry/index.d.ts +1 -1
  233. package/dist/src/telemetry/index.d.ts.map +1 -1
  234. package/dist/src/telemetry/index.js +1 -1
  235. package/dist/src/telemetry/index.js.map +1 -1
  236. package/dist/src/telemetry/wrap.d.ts +6 -0
  237. package/dist/src/telemetry/wrap.d.ts.map +1 -1
  238. package/dist/src/telemetry/wrap.js +65 -10
  239. package/dist/src/telemetry/wrap.js.map +1 -1
  240. package/dist/src/telemetry/wrap.test.js +81 -1
  241. package/dist/src/telemetry/wrap.test.js.map +1 -1
  242. package/dist/src/telemetry/wrap.tool-call-sink.test.d.ts +26 -0
  243. package/dist/src/telemetry/wrap.tool-call-sink.test.d.ts.map +1 -0
  244. package/dist/src/telemetry/wrap.tool-call-sink.test.js +162 -0
  245. package/dist/src/telemetry/wrap.tool-call-sink.test.js.map +1 -0
  246. package/dist/src/types/skill.d.ts +9 -1
  247. package/dist/src/types/skill.d.ts.map +1 -1
  248. package/dist/src/utils/index.d.ts +1 -1
  249. package/dist/src/utils/index.d.ts.map +1 -1
  250. package/dist/src/utils/index.js +1 -1
  251. package/dist/src/utils/index.js.map +1 -1
  252. package/dist/src/utils/version-check.d.ts +61 -0
  253. package/dist/src/utils/version-check.d.ts.map +1 -1
  254. package/dist/src/utils/version-check.js +78 -1
  255. package/dist/src/utils/version-check.js.map +1 -1
  256. package/dist/src/utils/version-check.test.js +130 -1
  257. package/dist/src/utils/version-check.test.js.map +1 -1
  258. package/dist/tests/db/migration-runner-race.test.js +19 -9
  259. package/dist/tests/db/migration-runner-race.test.js.map +1 -1
  260. package/dist/tests/install/fan-out.test.js +27 -0
  261. package/dist/tests/install/fan-out.test.js.map +1 -1
  262. package/dist/tests/sync/SyncEngine.abort.test.js +15 -11
  263. package/dist/tests/sync/SyncEngine.abort.test.js.map +1 -1
  264. package/dist/tests/sync/SyncEngine.status.test.js +1 -1
  265. package/dist/tests/sync/SyncEngine.status.test.js.map +1 -1
  266. package/dist/tests/sync/SyncEngine.test.d.ts +11 -2
  267. package/dist/tests/sync/SyncEngine.test.d.ts.map +1 -1
  268. package/dist/tests/sync/SyncEngine.test.js +164 -13
  269. package/dist/tests/sync/SyncEngine.test.js.map +1 -1
  270. package/dist/tests/unit/migrations/migration-v18.test.d.ts +16 -0
  271. package/dist/tests/unit/migrations/migration-v18.test.d.ts.map +1 -0
  272. package/dist/tests/unit/migrations/migration-v18.test.js +192 -0
  273. package/dist/tests/unit/migrations/migration-v18.test.js.map +1 -0
  274. package/dist/tests/unit/services/skill-installation.content.test.js +65 -1
  275. package/dist/tests/unit/services/skill-installation.content.test.js.map +1 -1
  276. package/dist/tests/unit/services/skill-installation.service.test.js +9 -8
  277. package/dist/tests/unit/services/skill-installation.service.test.js.map +1 -1
  278. package/dist/tests/unit/sync-engine.source-aware.test.js +5 -5
  279. package/dist/tests/unit/sync-engine.source-aware.test.js.map +1 -1
  280. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tool-profile.js","sourceRoot":"","sources":["../../../src/services/agent-tool-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,sFAAsF;AACtF,MAAM,CAAC,MAAM,0BAA0B,GAAG,yBAAyB,CAAA;AAEnE,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACzD,QAAQ;IACR,WAAW;IACX,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,YAAY;IACZ,kBAAkB;IAClB,uBAAuB;IACvB,wBAAwB;IACxB,wBAAwB;IACxB,aAAa;IACb,YAAY;CACb,CAAA"}
1
+ {"version":3,"file":"agent-tool-profile.js","sourceRoot":"","sources":["../../../src/services/agent-tool-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,sFAAsF;AACtF,MAAM,CAAC,MAAM,0BAA0B,GAAG,yBAAyB,CAAA;AAEnE,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAA;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACzD,QAAQ;IACR,WAAW;IACX,eAAe;IACf,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,YAAY;IACZ,kBAAkB;IAClB,uBAAuB;IACvB,wBAAwB;IACxB,wBAAwB;IACxB,aAAa;IACb,YAAY;IACZ,8DAA8D;IAC9D,uEAAuE;IACvE,wEAAwE;IACxE,uEAAuE;IACvE,0EAA0E;IAC1E,2BAA2B;IAC3B,0BAA0B;CAC3B,CAAA"}
@@ -6,8 +6,8 @@
6
6
  import { describe, expect, it } from 'vitest';
7
7
  import { AGENT_TOOL_PROFILE_ENV_VAR, AGENT_TOOL_PROFILE_NAMES, AGENT_TOOL_PROFILE_VALUE, } from './agent-tool-profile.js';
8
8
  describe('AGENT_TOOL_PROFILE_NAMES (core, QD-1 relocation)', () => {
9
- it('has 16 entries', () => {
10
- expect(AGENT_TOOL_PROFILE_NAMES).toHaveLength(16);
9
+ it('has 17 entries', () => {
10
+ expect(AGENT_TOOL_PROFILE_NAMES).toHaveLength(17);
11
11
  });
12
12
  it('contains undo_apply', () => {
13
13
  expect(AGENT_TOOL_PROFILE_NAMES).toContain('undo_apply');
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @fileoverview Shared skill content-hash comparator
3
+ * @module @skillsmith/core/services/skill-content-comparison
4
+ * @see SMI-6343 Wave 2 — repair the content-hash comparison
5
+ *
6
+ * A single comparison function, consumed by every "is this skill outdated"
7
+ * reader in the codebase (`packages/mcp-server/src/tools/outdated.ts`,
8
+ * `packages/mcp-server/src/tools/skill-updates.ts`,
9
+ * `packages/cli/src/utils/skills-directory.ts`) so they cannot drift apart
10
+ * on what "current" / "outdated" / "unknown" means again — exactly the class
11
+ * of bug an adversarial review caught in SMI-6343 Wave 1, where one
12
+ * implementation was fixed and its siblings were left broken.
13
+ *
14
+ * Deliberately narrow: this function only adjudicates "do these two hashes
15
+ * agree," given whatever installed-side and registry-side hash the caller
16
+ * already resolved (manifest-recorded hash, on-disk SHA-256, live registry
17
+ * lookup, cached `skill_versions` row — the callers differ on where the
18
+ * hash comes from, not on how two hashes are compared). Richer per-caller
19
+ * diagnosis (offline, quota-exhausted, network-error, identity-mismatch,
20
+ * etc.) is caller-specific context this function has no visibility into —
21
+ * callers layer their own explanation on top of the `reason` this returns.
22
+ */
23
+ /** The three possible outcomes of comparing an installed hash to a registry hash. */
24
+ export type ContentComparisonOutcome = 'current' | 'outdated' | 'unknown';
25
+ /**
26
+ * Result of {@link compareSkillContentHashes}.
27
+ */
28
+ export interface ContentComparisonResult {
29
+ /** current: hashes match. outdated: hashes differ. unknown: no comparison could be made. */
30
+ outcome: ContentComparisonOutcome;
31
+ /**
32
+ * Populated only when `outcome === 'unknown'` — explains why no
33
+ * comparison could be made (missing installed hash, missing registry
34
+ * hash, or both). Always `undefined` for `current`/`outdated`.
35
+ */
36
+ reason?: string;
37
+ }
38
+ /**
39
+ * Normalize a hash value: `null`/`undefined`/non-string/blank all collapse
40
+ * to `null` so every caller's "I don't have this" shape (a missing manifest
41
+ * field, an absent DB row, an `undefined` API response field) is handled
42
+ * uniformly regardless of how the caller spells "nothing here."
43
+ */
44
+ export declare function normalizeHash(hash: string | null | undefined): string | null;
45
+ /**
46
+ * SMI-6343 (adversarial-review fix): return the first candidate that
47
+ * normalizes to a non-blank value, else `null`.
48
+ *
49
+ * Exists because a bare `a ?? b` precedence chain (the original shape at
50
+ * both call sites) only falls through on `null`/`undefined` — a blank
51
+ * string (`''`, whitespace-only) is neither, so `a ?? b` incorrectly
52
+ * "wins" with a value `normalizeHash()` would itself treat as absent,
53
+ * silently discarding a legitimate `b`. Every caller selecting between a
54
+ * manifest's `contentHash`/`originalContentHash` (or an on-disk fallback)
55
+ * should route through this instead of raw `??` chaining.
56
+ */
57
+ export declare function firstNonBlankHash(...candidates: Array<string | null | undefined>): string | null;
58
+ /**
59
+ * Compare an installed-side content hash against a registry-side content
60
+ * hash and return a comparison outcome plus (when `unknown`) the reason no
61
+ * comparison could be made.
62
+ *
63
+ * @param installedHash SHA-256 hex digest of what is actually installed —
64
+ * e.g. a manifest's recorded `contentHash`/`originalContentHash`, or a
65
+ * freshly-computed hash of the on-disk SKILL.md.
66
+ * @param registryHash SHA-256 hex digest of the registry's current SKILL.md
67
+ * content — e.g. a live `lookupSkillFromRegistry()` result's
68
+ * `contentHash`, or the most-recently-synced `skill_versions.content_hash`.
69
+ */
70
+ export declare function compareSkillContentHashes(installedHash: string | null | undefined, registryHash: string | null | undefined): ContentComparisonResult;
71
+ //# sourceMappingURL=skill-content-comparison.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content-comparison.d.ts","sourceRoot":"","sources":["../../../src/services/skill-content-comparison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,qFAAqF;AACrF,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAEzE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,4FAA4F;IAC5F,OAAO,EAAE,wBAAwB,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAI5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,CAMhG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACxC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,uBAAuB,CAwBzB"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @fileoverview Shared skill content-hash comparator
3
+ * @module @skillsmith/core/services/skill-content-comparison
4
+ * @see SMI-6343 Wave 2 — repair the content-hash comparison
5
+ *
6
+ * A single comparison function, consumed by every "is this skill outdated"
7
+ * reader in the codebase (`packages/mcp-server/src/tools/outdated.ts`,
8
+ * `packages/mcp-server/src/tools/skill-updates.ts`,
9
+ * `packages/cli/src/utils/skills-directory.ts`) so they cannot drift apart
10
+ * on what "current" / "outdated" / "unknown" means again — exactly the class
11
+ * of bug an adversarial review caught in SMI-6343 Wave 1, where one
12
+ * implementation was fixed and its siblings were left broken.
13
+ *
14
+ * Deliberately narrow: this function only adjudicates "do these two hashes
15
+ * agree," given whatever installed-side and registry-side hash the caller
16
+ * already resolved (manifest-recorded hash, on-disk SHA-256, live registry
17
+ * lookup, cached `skill_versions` row — the callers differ on where the
18
+ * hash comes from, not on how two hashes are compared). Richer per-caller
19
+ * diagnosis (offline, quota-exhausted, network-error, identity-mismatch,
20
+ * etc.) is caller-specific context this function has no visibility into —
21
+ * callers layer their own explanation on top of the `reason` this returns.
22
+ */
23
+ /**
24
+ * Normalize a hash value: `null`/`undefined`/non-string/blank all collapse
25
+ * to `null` so every caller's "I don't have this" shape (a missing manifest
26
+ * field, an absent DB row, an `undefined` API response field) is handled
27
+ * uniformly regardless of how the caller spells "nothing here."
28
+ */
29
+ export function normalizeHash(hash) {
30
+ if (typeof hash !== 'string')
31
+ return null;
32
+ const trimmed = hash.trim();
33
+ return trimmed.length > 0 ? trimmed : null;
34
+ }
35
+ /**
36
+ * SMI-6343 (adversarial-review fix): return the first candidate that
37
+ * normalizes to a non-blank value, else `null`.
38
+ *
39
+ * Exists because a bare `a ?? b` precedence chain (the original shape at
40
+ * both call sites) only falls through on `null`/`undefined` — a blank
41
+ * string (`''`, whitespace-only) is neither, so `a ?? b` incorrectly
42
+ * "wins" with a value `normalizeHash()` would itself treat as absent,
43
+ * silently discarding a legitimate `b`. Every caller selecting between a
44
+ * manifest's `contentHash`/`originalContentHash` (or an on-disk fallback)
45
+ * should route through this instead of raw `??` chaining.
46
+ */
47
+ export function firstNonBlankHash(...candidates) {
48
+ for (const candidate of candidates) {
49
+ const normalized = normalizeHash(candidate);
50
+ if (normalized !== null)
51
+ return normalized;
52
+ }
53
+ return null;
54
+ }
55
+ /**
56
+ * Compare an installed-side content hash against a registry-side content
57
+ * hash and return a comparison outcome plus (when `unknown`) the reason no
58
+ * comparison could be made.
59
+ *
60
+ * @param installedHash SHA-256 hex digest of what is actually installed —
61
+ * e.g. a manifest's recorded `contentHash`/`originalContentHash`, or a
62
+ * freshly-computed hash of the on-disk SKILL.md.
63
+ * @param registryHash SHA-256 hex digest of the registry's current SKILL.md
64
+ * content — e.g. a live `lookupSkillFromRegistry()` result's
65
+ * `contentHash`, or the most-recently-synced `skill_versions.content_hash`.
66
+ */
67
+ export function compareSkillContentHashes(installedHash, registryHash) {
68
+ const installed = normalizeHash(installedHash);
69
+ const registry = normalizeHash(registryHash);
70
+ if (installed === null && registry === null) {
71
+ return {
72
+ outcome: 'unknown',
73
+ reason: 'No installed content hash and no registry content hash available for comparison.',
74
+ };
75
+ }
76
+ if (installed === null) {
77
+ return {
78
+ outcome: 'unknown',
79
+ reason: 'No installed content hash recorded — cannot compare against the registry.',
80
+ };
81
+ }
82
+ if (registry === null) {
83
+ return {
84
+ outcome: 'unknown',
85
+ reason: 'No registry content hash available — cannot compare against the installed skill.',
86
+ };
87
+ }
88
+ return installed === registry ? { outcome: 'current' } : { outcome: 'outdated' };
89
+ }
90
+ //# sourceMappingURL=skill-content-comparison.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content-comparison.js","sourceRoot":"","sources":["../../../src/services/skill-content-comparison.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAmBH;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAA+B;IAC3D,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAC3B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;AAC5C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAG,UAA4C;IAC/E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAA;QAC3C,IAAI,UAAU,KAAK,IAAI;YAAE,OAAO,UAAU,CAAA;IAC5C,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,yBAAyB,CACvC,aAAwC,EACxC,YAAuC;IAEvC,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,CAAC,CAAA;IAC9C,MAAM,QAAQ,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA;IAE5C,IAAI,SAAS,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,kFAAkF;SAC3F,CAAA;IACH,CAAC;IACD,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,2EAA2E;SACpF,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,kFAAkF;SAC3F,CAAA;IACH,CAAC;IAED,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA;AAClF,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @fileoverview Unit tests for the shared skill content-hash comparator
3
+ * @see SMI-6343 Wave 2 — repair the content-hash comparison
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=skill-content-comparison.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content-comparison.test.d.ts","sourceRoot":"","sources":["../../../src/services/skill-content-comparison.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @fileoverview Unit tests for the shared skill content-hash comparator
3
+ * @see SMI-6343 Wave 2 — repair the content-hash comparison
4
+ */
5
+ import { describe, it, expect } from 'vitest';
6
+ import { compareSkillContentHashes, firstNonBlankHash } from './skill-content-comparison.js';
7
+ describe('compareSkillContentHashes', () => {
8
+ it('returns current when both hashes match exactly', () => {
9
+ const result = compareSkillContentHashes('abc123', 'abc123');
10
+ expect(result.outcome).toBe('current');
11
+ expect(result.reason).toBeUndefined();
12
+ });
13
+ it('returns outdated when the hashes differ', () => {
14
+ const result = compareSkillContentHashes('abc123', 'def456');
15
+ expect(result.outcome).toBe('outdated');
16
+ expect(result.reason).toBeUndefined();
17
+ });
18
+ it('returns unknown with a reason when the installed hash is missing', () => {
19
+ const result = compareSkillContentHashes(null, 'def456');
20
+ expect(result.outcome).toBe('unknown');
21
+ expect(result.reason).toMatch(/no installed content hash/i);
22
+ });
23
+ it('returns unknown with a reason when the installed hash is undefined', () => {
24
+ const result = compareSkillContentHashes(undefined, 'def456');
25
+ expect(result.outcome).toBe('unknown');
26
+ expect(result.reason).toMatch(/no installed content hash/i);
27
+ });
28
+ it('returns unknown with a reason when the registry hash is missing', () => {
29
+ const result = compareSkillContentHashes('abc123', null);
30
+ expect(result.outcome).toBe('unknown');
31
+ expect(result.reason).toMatch(/no registry content hash/i);
32
+ });
33
+ it('returns unknown with a reason when the registry hash is undefined', () => {
34
+ const result = compareSkillContentHashes('abc123', undefined);
35
+ expect(result.outcome).toBe('unknown');
36
+ expect(result.reason).toMatch(/no registry content hash/i);
37
+ });
38
+ it('returns unknown when both hashes are missing', () => {
39
+ const result = compareSkillContentHashes(null, null);
40
+ expect(result.outcome).toBe('unknown');
41
+ expect(result.reason).toMatch(/no installed content hash and no registry content hash/i);
42
+ });
43
+ it('treats a blank/whitespace-only hash the same as missing', () => {
44
+ expect(compareSkillContentHashes(' ', 'abc123').outcome).toBe('unknown');
45
+ expect(compareSkillContentHashes('abc123', ' ').outcome).toBe('unknown');
46
+ expect(compareSkillContentHashes('', '').outcome).toBe('unknown');
47
+ });
48
+ it('is case-sensitive — differently-cased hex digests are treated as different hashes', () => {
49
+ const result = compareSkillContentHashes('ABC123', 'abc123');
50
+ expect(result.outcome).toBe('outdated');
51
+ });
52
+ it('trims surrounding whitespace before comparing', () => {
53
+ const result = compareSkillContentHashes(' abc123 ', 'abc123');
54
+ expect(result.outcome).toBe('current');
55
+ });
56
+ });
57
+ describe('firstNonBlankHash (adversarial-review addition, SMI-6343)', () => {
58
+ it('returns the first candidate when it is non-blank', () => {
59
+ expect(firstNonBlankHash('abc123', 'def456')).toBe('abc123');
60
+ });
61
+ it('falls through past null/undefined to the next candidate', () => {
62
+ expect(firstNonBlankHash(null, 'def456')).toBe('def456');
63
+ expect(firstNonBlankHash(undefined, 'def456')).toBe('def456');
64
+ });
65
+ it('falls through past a BLANK (whitespace-only) first candidate — the exact case a raw `??` chain gets wrong', () => {
66
+ // `' ' ?? 'def456'` would incorrectly return ' ' (?? only falls
67
+ // through on null/undefined) — this is the whole reason this helper
68
+ // exists instead of a raw `??` chain at each call site.
69
+ expect(firstNonBlankHash(' ', 'def456')).toBe('def456');
70
+ expect(firstNonBlankHash('', 'def456')).toBe('def456');
71
+ });
72
+ it('trims a winning candidate', () => {
73
+ expect(firstNonBlankHash(' abc123 ')).toBe('abc123');
74
+ });
75
+ it('returns null when every candidate is blank/null/undefined', () => {
76
+ expect(firstNonBlankHash(null, undefined, ' ', '')).toBeNull();
77
+ expect(firstNonBlankHash()).toBeNull();
78
+ });
79
+ it('supports three or more candidates (on-disk-hash fallback chains)', () => {
80
+ expect(firstNonBlankHash(' ', undefined, 'on-disk-hash')).toBe('on-disk-hash');
81
+ });
82
+ });
83
+ //# sourceMappingURL=skill-content-comparison.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-content-comparison.test.js","sourceRoot":"","sources":["../../../src/services/skill-content-comparison.test.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAE5F,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,MAAM,GAAG,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC5D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACtC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,MAAM,GAAG,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC5D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,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,EAAE,GAAG,EAAE;QAC1E,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAClF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * @fileoverview Shared skill-identity contradiction-signal classification
3
+ * @module @skillsmith/core/services/skill-identity-classification
4
+ * @see SMI-6343 Wave 3 — tamper-check classification (AC#3)
5
+ *
6
+ * Three deterministic-or-best-effort "does this manifest entry's recorded
7
+ * identity contradict what's actually installed" signals, plus a
8
+ * "has this on-disk content been locally edited since install" check —
9
+ * consumed by BOTH `packages/mcp-server/src/tools/outdated.ts` (via
10
+ * `outdated.identity.ts`) and `packages/cli/src/commands/manage.update.ts`,
11
+ * so the two packages cannot drift into two independently-maintained
12
+ * implementations of the same contradiction logic (exactly the "sibling
13
+ * implementation" bug class both Wave 1 and Wave 2 of SMI-6343 already hit).
14
+ *
15
+ * Deliberately decoupled from either caller's own `RegistrySkillInfo` shape
16
+ * (mcp-server's `install.types.ts` and core's own `skill-installation.types.ts`
17
+ * both have independently-evolved versions) — callers adapt their own
18
+ * registry-lookup result into the minimal {@link RegistryLookupOutcome} shape
19
+ * this module needs.
20
+ *
21
+ * Every function here is synchronous and filesystem-free by design: signal 3
22
+ * (path containment) is a pure string check against an already-resolved
23
+ * expected root directory, not a `fs.realpath` call — the callers of this
24
+ * module (`outdated.ts`, `manage.update.ts`) only ever reach the "outdated"
25
+ * classification branch after already having successfully read the
26
+ * installed skill's SKILL.md this same iteration, so "does installPath
27
+ * exist" is already established by the time these signals run.
28
+ */
29
+ import type { ContentComparisonOutcome } from './skill-content-comparison.js';
30
+ import type { ClientId } from '../install/paths.js';
31
+ /** Which of the three contradiction signals fired. */
32
+ export type IdentitySignal = 'owner-mismatch' | 'frontmatter-contradiction' | 'path-unresolved';
33
+ /** Why a classification could not be conclusively determined. */
34
+ export type IdentityInconclusiveReason = 'offline' | 'quota-exhausted' | 'network-error' | 'no-registry-record' | 'no-history';
35
+ /** The five-state classification `outdated.ts`/`manage.update.ts` report against a divergent entry. */
36
+ export type OutdatedClassificationState = 'current' | 'outdated' | 'local-drift' | 'identity-mismatch' | 'unknown';
37
+ /** Minimal registry-record shape signal 2 needs. */
38
+ export interface IdentityRegistryRecord {
39
+ author?: string | null;
40
+ name?: string | null;
41
+ }
42
+ /**
43
+ * The outcome of a caller's OWN registry lookup for the entry's claimed
44
+ * `id`, adapted into this module's minimal shape.
45
+ *
46
+ * `attempted: false` means the caller never even tried this run (offline,
47
+ * or an earlier skill in the same batch already exhausted quota) —
48
+ * `failureReason` in that case names WHY it wasn't attempted. `attempted:
49
+ * true` with `record: null` means the lookup completed but found nothing
50
+ * for this id (a distinct case from a failed lookup — see
51
+ * `no-registry-record` below).
52
+ */
53
+ export interface RegistryLookupOutcome {
54
+ attempted: boolean;
55
+ record: IdentityRegistryRecord | null;
56
+ /** Populated when the lookup either wasn't attempted or didn't complete. */
57
+ failureReason?: 'offline' | 'quota-exhausted' | 'network-error' | null;
58
+ }
59
+ /** The subset of a manifest entry every signal needs. */
60
+ export interface ManifestEntryForIdentity {
61
+ id: string;
62
+ source: string;
63
+ installPath: string;
64
+ client?: ClientId;
65
+ contentHash?: string;
66
+ originalContentHash?: string;
67
+ }
68
+ /** Result of {@link classifyManifestEntryIdentity}. */
69
+ export interface IdentityClassificationResult {
70
+ /** Which signal fired. Null when no signal fired (regardless of `inconclusive`). */
71
+ signal: IdentitySignal | null;
72
+ /** True when signal 2 (frontmatter) could not be checked at all. */
73
+ inconclusive: boolean;
74
+ /** Populated only when `inconclusive` is true. */
75
+ inconclusiveReason: IdentityInconclusiveReason | null;
76
+ }
77
+ /** Result of {@link classifyDivergentEntry}. */
78
+ export interface DivergentEntryClassification {
79
+ state: Exclude<OutdatedClassificationState, 'current'>;
80
+ signal: IdentitySignal | null;
81
+ inconclusiveReason: IdentityInconclusiveReason | null;
82
+ }
83
+ /**
84
+ * Parse the owner segment out of a manifest `source` string. Real installs
85
+ * write `source` as `'github:' + owner + '/' + repo` (`skill-installation.
86
+ * service.ts`) — the `'github:'` prefix is optional here so a bare
87
+ * `owner/repo` (or a future non-GitHub source shape) still parses. Returns
88
+ * `null` for the `'unknown'` distrust sentinel, a raw URL, or anything else
89
+ * with no parseable `owner/name` shape.
90
+ */
91
+ export declare function parseOwnerFromSource(source: string | undefined | null): string | null;
92
+ /**
93
+ * Parse the owner segment out of a manifest entry's `id`. Returns `null`
94
+ * for anything that isn't a clean `owner/name` pair — most importantly a
95
+ * raw GitHub URL, which a direct-URL install records as `id` verbatim (see
96
+ * {@link parseOwnerFromOwnerNamePair}).
97
+ */
98
+ export declare function parseOwnerFromId(id: string | undefined | null): string | null;
99
+ /**
100
+ * Signal 1: `id` parses as `owner/name` and `source` names a DIFFERENT
101
+ * owner. Deterministic, offline, zero network dependency. Catches the real
102
+ * `linear` skill corruption (`source: "github:lobehub/lobehub"` vs
103
+ * `id: "wrsmith108/linear"`).
104
+ */
105
+ export declare function detectOwnerMismatch(entry: Pick<ManifestEntryForIdentity, 'id' | 'source'>): boolean;
106
+ /**
107
+ * Signal 3: `installPath` is absent, or resolves OUTSIDE `expectedRootDir`
108
+ * (the claimed client's native install root, or a workspace-scoped
109
+ * equivalent the caller resolves — see each caller's own scope handling).
110
+ *
111
+ * Deliberately a pure string containment check (`path.relative`), not a
112
+ * filesystem call: both callers of this module only reach this signal after
113
+ * already having successfully read the entry's SKILL.md this same
114
+ * iteration, so filesystem existence is already established. This also
115
+ * catches the exact shape of the SMI-6343 Wave 1 test-fixture leak (an
116
+ * OS-temp-dir `installPath` written into the real manifest) via simple
117
+ * string comparison, with no need to resolve symlinks.
118
+ *
119
+ * NOT a symlink-escape check (Wave 3 adversarial review, considered and
120
+ * scoped out): a real `installPath` inside `expectedRootDir` that is
121
+ * ITSELF a symlink pointing elsewhere is a local-filesystem-tampering
122
+ * threat distinct from this signal's actual purpose (catching a manifest
123
+ * entry whose *recorded* path doesn't match a legitimate install
124
+ * location — a software-bug/registry-tamper shape, not local attacker
125
+ * capability); an attacker with write access to plant such a symlink
126
+ * inside the client root already has equivalent-or-greater capability to
127
+ * edit SKILL.md content directly, making a `fs.realpath` upgrade here
128
+ * (which would also force this whole synchronous, filesystem-free module
129
+ * to become async) address a threat this signal was never meant to cover.
130
+ *
131
+ * The parent-segment check below (`rel === '..' || rel.startsWith('..' +
132
+ * sep)`) is deliberately NOT a bare `rel.startsWith('..')`: a literal
133
+ * directory name that happens to start with two dots (e.g. `..cache`) is a
134
+ * legitimate contained child — `path.relative('/r', '/r/..cache')` returns
135
+ * `'..cache'`, which a bare `startsWith('..')` would misclassify as an
136
+ * escape (Wave 3 adversarial review finding).
137
+ */
138
+ export declare function detectPathUnresolved(installPath: string | undefined | null, expectedRootDir: string): boolean;
139
+ /**
140
+ * Run all three contradiction signals against a manifest entry. Any one
141
+ * conclusively firing means `signal` is non-null — order (1, 3, 2) checks
142
+ * the two deterministic/offline signals first, only falling to the
143
+ * network-dependent signal 2 when neither of those already answered the
144
+ * question.
145
+ */
146
+ export declare function classifyManifestEntryIdentity(params: {
147
+ entry: ManifestEntryForIdentity;
148
+ localContent: string | null;
149
+ expectedRootDir: string;
150
+ registryLookup: RegistryLookupOutcome;
151
+ }): IdentityClassificationResult;
152
+ /**
153
+ * Has the on-disk content changed since the manifest's own recorded
154
+ * install/update-time hash? This is what distinguishes a benign local edit
155
+ * (`local-drift`) from a genuine registry version bump (`outdated`) once
156
+ * no identity signal has fired.
157
+ *
158
+ * When the manifest never recorded a comparable hash at all (a legacy or
159
+ * adopted entry, `contentHash`/`originalContentHash` both absent), this
160
+ * deliberately defaults to `false` (no edit evidence) rather than `true`
161
+ * (conservative) — absence of a recorded hash is a data-quality gap, not
162
+ * positive evidence of tampering, and defaulting to `true` here would
163
+ * misclassify the large population of legacy/adopted entries that never had
164
+ * a hash recorded as `local-drift` even when they are genuinely just
165
+ * outdated (SMI-6343 Wave 3 review finding).
166
+ */
167
+ export declare function hasRecordedLocalEdit(entry: Pick<ManifestEntryForIdentity, 'contentHash' | 'originalContentHash'>, localHash: string | null): boolean;
168
+ /**
169
+ * Classify an entry the caller has ALREADY determined is divergent from the
170
+ * registry (mcp-server: `compareSkillContentHashes(...).outcome ===
171
+ * 'outdated'`; CLI: `getSkillDiff()` found a version/content difference).
172
+ * Never returns `'current'` — callers own that trivial case themselves,
173
+ * since it never needs signal evaluation at all.
174
+ */
175
+ export declare function classifyDivergentEntry(params: {
176
+ entry: ManifestEntryForIdentity;
177
+ localHash: string | null;
178
+ localContent: string | null;
179
+ expectedRootDir: string;
180
+ registryLookup: RegistryLookupOutcome;
181
+ }): DivergentEntryClassification;
182
+ /**
183
+ * Full 5-state classification given an already-computed content-comparison
184
+ * outcome (from `compareSkillContentHashes`) plus the caller-derived reason
185
+ * a plain `'unknown'` comparison outcome couldn't be resolved (offline,
186
+ * quota-exhausted, network-error, or no-history — the caller already tracks
187
+ * which applies; see `outdated.ts`'s `deriveUnknownReason`).
188
+ */
189
+ export declare function classifyOutdatedState(params: {
190
+ comparisonOutcome: ContentComparisonOutcome;
191
+ unknownReasonWhenComparisonUnknown: IdentityInconclusiveReason;
192
+ entry: ManifestEntryForIdentity;
193
+ localHash: string | null;
194
+ localContent: string | null;
195
+ expectedRootDir: string;
196
+ registryLookup: RegistryLookupOutcome;
197
+ }): {
198
+ state: OutdatedClassificationState;
199
+ signal: IdentitySignal | null;
200
+ inconclusiveReason: IdentityInconclusiveReason | null;
201
+ };
202
+ //# sourceMappingURL=skill-identity-classification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-identity-classification.d.ts","sourceRoot":"","sources":["../../../src/services/skill-identity-classification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAKH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAC7E,OAAO,KAAK,EAAE,QAA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