@skillsmith/core 0.9.0 → 0.11.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 (404) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/src/analysis/tree-sitter/pythonIncremental.d.ts +23 -0
  4. package/dist/src/analysis/tree-sitter/pythonIncremental.d.ts.map +1 -1
  5. package/dist/src/analysis/tree-sitter/pythonIncremental.hardening.test.js +137 -0
  6. package/dist/src/analysis/tree-sitter/pythonIncremental.hardening.test.js.map +1 -1
  7. package/dist/src/analysis/tree-sitter/pythonIncremental.js +83 -10
  8. package/dist/src/analysis/tree-sitter/pythonIncremental.js.map +1 -1
  9. package/dist/src/analysis/tree-sitter/queryExtractionMatchesOrExceedsRegex.test.js +6 -1
  10. package/dist/src/analysis/tree-sitter/queryExtractionMatchesOrExceedsRegex.test.js.map +1 -1
  11. package/dist/src/api/client.d.ts.map +1 -1
  12. package/dist/src/api/client.js +6 -0
  13. package/dist/src/api/client.js.map +1 -1
  14. package/dist/src/api/client.test.d.ts +9 -0
  15. package/dist/src/api/client.test.d.ts.map +1 -0
  16. package/dist/src/api/client.test.js +81 -0
  17. package/dist/src/api/client.test.js.map +1 -0
  18. package/dist/src/config/audit-notify-state.d.ts +46 -0
  19. package/dist/src/config/audit-notify-state.d.ts.map +1 -0
  20. package/dist/src/config/audit-notify-state.js +55 -0
  21. package/dist/src/config/audit-notify-state.js.map +1 -0
  22. package/dist/src/config/audit-notify-state.test.d.ts +9 -0
  23. package/dist/src/config/audit-notify-state.test.d.ts.map +1 -0
  24. package/dist/src/config/audit-notify-state.test.js +63 -0
  25. package/dist/src/config/audit-notify-state.test.js.map +1 -0
  26. package/dist/src/config/index.d.ts +10 -0
  27. package/dist/src/config/index.d.ts.map +1 -1
  28. package/dist/src/config/index.js.map +1 -1
  29. package/dist/src/exports/services.d.ts +3 -1
  30. package/dist/src/exports/services.d.ts.map +1 -1
  31. package/dist/src/exports/services.js +9 -1
  32. package/dist/src/exports/services.js.map +1 -1
  33. package/dist/src/index.d.ts +6 -3
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/index.js +11 -2
  36. package/dist/src/index.js.map +1 -1
  37. package/dist/src/install/agent-config-merge.json-array.d.ts +29 -0
  38. package/dist/src/install/agent-config-merge.json-array.d.ts.map +1 -0
  39. package/dist/src/install/agent-config-merge.json-array.js +100 -0
  40. package/dist/src/install/agent-config-merge.json-array.js.map +1 -0
  41. package/dist/src/install/agent-config-merge.json.d.ts +37 -0
  42. package/dist/src/install/agent-config-merge.json.d.ts.map +1 -0
  43. package/dist/src/install/agent-config-merge.json.js +134 -0
  44. package/dist/src/install/agent-config-merge.json.js.map +1 -0
  45. package/dist/src/install/agent-config-merge.toml-block.d.ts +48 -0
  46. package/dist/src/install/agent-config-merge.toml-block.d.ts.map +1 -0
  47. package/dist/src/install/agent-config-merge.toml-block.js +107 -0
  48. package/dist/src/install/agent-config-merge.toml-block.js.map +1 -0
  49. package/dist/src/install/agent-config-merge.types.d.ts +87 -0
  50. package/dist/src/install/agent-config-merge.types.d.ts.map +1 -0
  51. package/dist/src/install/agent-config-merge.types.js +83 -0
  52. package/dist/src/install/agent-config-merge.types.js.map +1 -0
  53. package/dist/src/install/agent-config-merge.yaml.d.ts +46 -0
  54. package/dist/src/install/agent-config-merge.yaml.d.ts.map +1 -0
  55. package/dist/src/install/agent-config-merge.yaml.js +133 -0
  56. package/dist/src/install/agent-config-merge.yaml.js.map +1 -0
  57. package/dist/src/install/agent-config-merge.yaml.test.d.ts +2 -0
  58. package/dist/src/install/agent-config-merge.yaml.test.d.ts.map +1 -0
  59. package/dist/src/install/agent-config-merge.yaml.test.js +210 -0
  60. package/dist/src/install/agent-config-merge.yaml.test.js.map +1 -0
  61. package/dist/src/install/agent-harness-targets.d.ts +98 -0
  62. package/dist/src/install/agent-harness-targets.d.ts.map +1 -0
  63. package/dist/src/install/agent-harness-targets.js +154 -0
  64. package/dist/src/install/agent-harness-targets.js.map +1 -0
  65. package/dist/src/install/agent-home-relocate.d.ts +29 -0
  66. package/dist/src/install/agent-home-relocate.d.ts.map +1 -0
  67. package/dist/src/install/agent-home-relocate.js +38 -0
  68. package/dist/src/install/agent-home-relocate.js.map +1 -0
  69. package/dist/src/install/agent-manifest-path-guard.d.ts +55 -0
  70. package/dist/src/install/agent-manifest-path-guard.d.ts.map +1 -0
  71. package/dist/src/install/agent-manifest-path-guard.js +109 -0
  72. package/dist/src/install/agent-manifest-path-guard.js.map +1 -0
  73. package/dist/src/install/agent-manifest-path-guard.test.d.ts +2 -0
  74. package/dist/src/install/agent-manifest-path-guard.test.d.ts.map +1 -0
  75. package/dist/src/install/agent-manifest-path-guard.test.js +72 -0
  76. package/dist/src/install/agent-manifest-path-guard.test.js.map +1 -0
  77. package/dist/src/install/agent-manifest.d.ts +58 -0
  78. package/dist/src/install/agent-manifest.d.ts.map +1 -0
  79. package/dist/src/install/agent-manifest.js +103 -0
  80. package/dist/src/install/agent-manifest.js.map +1 -0
  81. package/dist/src/install/agent-pack-installer.d.ts +39 -0
  82. package/dist/src/install/agent-pack-installer.d.ts.map +1 -0
  83. package/dist/src/install/agent-pack-installer.entry.d.ts +55 -0
  84. package/dist/src/install/agent-pack-installer.entry.d.ts.map +1 -0
  85. package/dist/src/install/agent-pack-installer.entry.js +90 -0
  86. package/dist/src/install/agent-pack-installer.entry.js.map +1 -0
  87. package/dist/src/install/agent-pack-installer.fs-helpers.d.ts +33 -0
  88. package/dist/src/install/agent-pack-installer.fs-helpers.d.ts.map +1 -0
  89. package/dist/src/install/agent-pack-installer.fs-helpers.js +59 -0
  90. package/dist/src/install/agent-pack-installer.fs-helpers.js.map +1 -0
  91. package/dist/src/install/agent-pack-installer.harness.d.ts +66 -0
  92. package/dist/src/install/agent-pack-installer.harness.d.ts.map +1 -0
  93. package/dist/src/install/agent-pack-installer.harness.js +310 -0
  94. package/dist/src/install/agent-pack-installer.harness.js.map +1 -0
  95. package/dist/src/install/agent-pack-installer.js +221 -0
  96. package/dist/src/install/agent-pack-installer.js.map +1 -0
  97. package/dist/src/install/agent-pack-installer.preserve.test.d.ts +11 -0
  98. package/dist/src/install/agent-pack-installer.preserve.test.d.ts.map +1 -0
  99. package/dist/src/install/agent-pack-installer.preserve.test.js +72 -0
  100. package/dist/src/install/agent-pack-installer.preserve.test.js.map +1 -0
  101. package/dist/src/install/agent-pack-installer.test.d.ts +2 -0
  102. package/dist/src/install/agent-pack-installer.test.d.ts.map +1 -0
  103. package/dist/src/install/agent-pack-installer.test.js +350 -0
  104. package/dist/src/install/agent-pack-installer.test.js.map +1 -0
  105. package/dist/src/install/agent-pack-installer.types.d.ts +51 -0
  106. package/dist/src/install/agent-pack-installer.types.d.ts.map +1 -0
  107. package/dist/src/install/agent-pack-installer.types.js +16 -0
  108. package/dist/src/install/agent-pack-installer.types.js.map +1 -0
  109. package/dist/src/install/agent-pack-uninstaller.d.ts +43 -0
  110. package/dist/src/install/agent-pack-uninstaller.d.ts.map +1 -0
  111. package/dist/src/install/agent-pack-uninstaller.js +113 -0
  112. package/dist/src/install/agent-pack-uninstaller.js.map +1 -0
  113. package/dist/src/install/agent-pack-uninstaller.test.d.ts +2 -0
  114. package/dist/src/install/agent-pack-uninstaller.test.d.ts.map +1 -0
  115. package/dist/src/install/agent-pack-uninstaller.test.js +212 -0
  116. package/dist/src/install/agent-pack-uninstaller.test.js.map +1 -0
  117. package/dist/src/install/index.d.ts +7 -0
  118. package/dist/src/install/index.d.ts.map +1 -1
  119. package/dist/src/install/index.js +7 -0
  120. package/dist/src/install/index.js.map +1 -1
  121. package/dist/src/install/paths.d.ts +1 -1
  122. package/dist/src/install/paths.d.ts.map +1 -1
  123. package/dist/src/install/paths.js +4 -0
  124. package/dist/src/install/paths.js.map +1 -1
  125. package/dist/src/install/paths.test.js +15 -0
  126. package/dist/src/install/paths.test.js.map +1 -1
  127. package/dist/src/journal/hash.d.ts +13 -0
  128. package/dist/src/journal/hash.d.ts.map +1 -0
  129. package/dist/src/journal/hash.js +16 -0
  130. package/dist/src/journal/hash.js.map +1 -0
  131. package/dist/src/journal/index.d.ts +15 -0
  132. package/dist/src/journal/index.d.ts.map +1 -0
  133. package/dist/src/journal/index.js +15 -0
  134. package/dist/src/journal/index.js.map +1 -0
  135. package/dist/src/journal/journal.test.d.ts +16 -0
  136. package/dist/src/journal/journal.test.d.ts.map +1 -0
  137. package/dist/src/journal/journal.test.js +171 -0
  138. package/dist/src/journal/journal.test.js.map +1 -0
  139. package/dist/src/journal/path.d.ts +44 -0
  140. package/dist/src/journal/path.d.ts.map +1 -0
  141. package/dist/src/journal/path.js +61 -0
  142. package/dist/src/journal/path.js.map +1 -0
  143. package/dist/src/journal/reader.d.ts +38 -0
  144. package/dist/src/journal/reader.d.ts.map +1 -0
  145. package/dist/src/journal/reader.js +93 -0
  146. package/dist/src/journal/reader.js.map +1 -0
  147. package/dist/src/journal/types.d.ts +87 -0
  148. package/dist/src/journal/types.d.ts.map +1 -0
  149. package/dist/src/journal/types.js +21 -0
  150. package/dist/src/journal/types.js.map +1 -0
  151. package/dist/src/journal/writer.d.ts +52 -0
  152. package/dist/src/journal/writer.d.ts.map +1 -0
  153. package/dist/src/journal/writer.js +125 -0
  154. package/dist/src/journal/writer.js.map +1 -0
  155. package/dist/src/logging/context.d.ts +58 -0
  156. package/dist/src/logging/context.d.ts.map +1 -0
  157. package/dist/src/logging/context.js +62 -0
  158. package/dist/src/logging/context.js.map +1 -0
  159. package/dist/src/logging/context.test.d.ts +14 -0
  160. package/dist/src/logging/context.test.d.ts.map +1 -0
  161. package/dist/src/logging/context.test.js +88 -0
  162. package/dist/src/logging/context.test.js.map +1 -0
  163. package/dist/src/logging/index.d.ts +13 -0
  164. package/dist/src/logging/index.d.ts.map +1 -0
  165. package/dist/src/logging/index.js +12 -0
  166. package/dist/src/logging/index.js.map +1 -0
  167. package/dist/src/logging/logger.d.ts +71 -0
  168. package/dist/src/logging/logger.d.ts.map +1 -0
  169. package/dist/src/logging/logger.js +264 -0
  170. package/dist/src/logging/logger.js.map +1 -0
  171. package/dist/src/logging/logger.test.d.ts +9 -0
  172. package/dist/src/logging/logger.test.d.ts.map +1 -0
  173. package/dist/src/logging/logger.test.js +320 -0
  174. package/dist/src/logging/logger.test.js.map +1 -0
  175. package/dist/src/logging/redact.d.ts +35 -0
  176. package/dist/src/logging/redact.d.ts.map +1 -0
  177. package/dist/src/logging/redact.js +152 -0
  178. package/dist/src/logging/redact.js.map +1 -0
  179. package/dist/src/logging/redact.test.d.ts +8 -0
  180. package/dist/src/logging/redact.test.d.ts.map +1 -0
  181. package/dist/src/logging/redact.test.js +330 -0
  182. package/dist/src/logging/redact.test.js.map +1 -0
  183. package/dist/src/logging/rotation.d.ts +75 -0
  184. package/dist/src/logging/rotation.d.ts.map +1 -0
  185. package/dist/src/logging/rotation.js +284 -0
  186. package/dist/src/logging/rotation.js.map +1 -0
  187. package/dist/src/logging/rotation.test.d.ts +11 -0
  188. package/dist/src/logging/rotation.test.d.ts.map +1 -0
  189. package/dist/src/logging/rotation.test.js +132 -0
  190. package/dist/src/logging/rotation.test.js.map +1 -0
  191. package/dist/src/logging/types.d.ts +69 -0
  192. package/dist/src/logging/types.d.ts.map +1 -0
  193. package/dist/src/logging/types.js +9 -0
  194. package/dist/src/logging/types.js.map +1 -0
  195. package/dist/src/paywall-triggers/index.d.ts +13 -0
  196. package/dist/src/paywall-triggers/index.d.ts.map +1 -0
  197. package/dist/src/paywall-triggers/index.js +13 -0
  198. package/dist/src/paywall-triggers/index.js.map +1 -0
  199. package/dist/src/paywall-triggers/path.d.ts +47 -0
  200. package/dist/src/paywall-triggers/path.d.ts.map +1 -0
  201. package/dist/src/paywall-triggers/path.js +73 -0
  202. package/dist/src/paywall-triggers/path.js.map +1 -0
  203. package/dist/src/paywall-triggers/store.d.ts +75 -0
  204. package/dist/src/paywall-triggers/store.d.ts.map +1 -0
  205. package/dist/src/paywall-triggers/store.js +122 -0
  206. package/dist/src/paywall-triggers/store.js.map +1 -0
  207. package/dist/src/paywall-triggers/store.test.d.ts +2 -0
  208. package/dist/src/paywall-triggers/store.test.d.ts.map +1 -0
  209. package/dist/src/paywall-triggers/store.test.js +121 -0
  210. package/dist/src/paywall-triggers/store.test.js.map +1 -0
  211. package/dist/src/paywall-triggers/types.d.ts +24 -0
  212. package/dist/src/paywall-triggers/types.d.ts.map +1 -0
  213. package/dist/src/paywall-triggers/types.js +13 -0
  214. package/dist/src/paywall-triggers/types.js.map +1 -0
  215. package/dist/src/security/index.d.ts +2 -0
  216. package/dist/src/security/index.d.ts.map +1 -1
  217. package/dist/src/security/index.js +4 -0
  218. package/dist/src/security/index.js.map +1 -1
  219. package/dist/src/security/scanner/SecurityScanner.compound.d.ts +13 -0
  220. package/dist/src/security/scanner/SecurityScanner.compound.d.ts.map +1 -0
  221. package/dist/src/security/scanner/SecurityScanner.compound.js +127 -0
  222. package/dist/src/security/scanner/SecurityScanner.compound.js.map +1 -0
  223. package/dist/src/security/scanner/SecurityScanner.d.ts.map +1 -1
  224. package/dist/src/security/scanner/SecurityScanner.hostile-update.d.ts +46 -0
  225. package/dist/src/security/scanner/SecurityScanner.hostile-update.d.ts.map +1 -0
  226. package/dist/src/security/scanner/SecurityScanner.hostile-update.js +209 -0
  227. package/dist/src/security/scanner/SecurityScanner.hostile-update.js.map +1 -0
  228. package/dist/src/security/scanner/SecurityScanner.js +10 -1
  229. package/dist/src/security/scanner/SecurityScanner.js.map +1 -1
  230. package/dist/src/security/scanner/SecurityScanner.pii.d.ts +23 -0
  231. package/dist/src/security/scanner/SecurityScanner.pii.d.ts.map +1 -0
  232. package/dist/src/security/scanner/SecurityScanner.pii.js +152 -0
  233. package/dist/src/security/scanner/SecurityScanner.pii.js.map +1 -0
  234. package/dist/src/security/scanner/SecurityScanner.scanners.d.ts +5 -12
  235. package/dist/src/security/scanner/SecurityScanner.scanners.d.ts.map +1 -1
  236. package/dist/src/security/scanner/SecurityScanner.scanners.js +63 -137
  237. package/dist/src/security/scanner/SecurityScanner.scanners.js.map +1 -1
  238. package/dist/src/security/scanner/index.d.ts +2 -1
  239. package/dist/src/security/scanner/index.d.ts.map +1 -1
  240. package/dist/src/security/scanner/index.js +2 -0
  241. package/dist/src/security/scanner/index.js.map +1 -1
  242. package/dist/src/security/scanner/patterns.d.ts +2 -0
  243. package/dist/src/security/scanner/patterns.d.ts.map +1 -1
  244. package/dist/src/security/scanner/patterns.js +79 -11
  245. package/dist/src/security/scanner/patterns.js.map +1 -1
  246. package/dist/src/security/scanner/types.d.ts +23 -0
  247. package/dist/src/security/scanner/types.d.ts.map +1 -1
  248. package/dist/src/services/agent-pack/agent-pack.test.d.ts +18 -0
  249. package/dist/src/services/agent-pack/agent-pack.test.d.ts.map +1 -0
  250. package/dist/src/services/agent-pack/agent-pack.test.js +344 -0
  251. package/dist/src/services/agent-pack/agent-pack.test.js.map +1 -0
  252. package/dist/src/services/agent-pack/hooks.d.ts +29 -0
  253. package/dist/src/services/agent-pack/hooks.d.ts.map +1 -0
  254. package/dist/src/services/agent-pack/hooks.js +139 -0
  255. package/dist/src/services/agent-pack/hooks.js.map +1 -0
  256. package/dist/src/services/agent-pack/index.d.ts +26 -0
  257. package/dist/src/services/agent-pack/index.d.ts.map +1 -0
  258. package/dist/src/services/agent-pack/index.js +109 -0
  259. package/dist/src/services/agent-pack/index.js.map +1 -0
  260. package/dist/src/services/agent-pack/prompt-source.d.ts +47 -0
  261. package/dist/src/services/agent-pack/prompt-source.d.ts.map +1 -0
  262. package/dist/src/services/agent-pack/prompt-source.js +182 -0
  263. package/dist/src/services/agent-pack/prompt-source.js.map +1 -0
  264. package/dist/src/services/agent-pack/shims.d.ts +40 -0
  265. package/dist/src/services/agent-pack/shims.d.ts.map +1 -0
  266. package/dist/src/services/agent-pack/shims.js +96 -0
  267. package/dist/src/services/agent-pack/shims.js.map +1 -0
  268. package/dist/src/services/agent-pack/skill-md.d.ts +35 -0
  269. package/dist/src/services/agent-pack/skill-md.d.ts.map +1 -0
  270. package/dist/src/services/agent-pack/skill-md.js +89 -0
  271. package/dist/src/services/agent-pack/skill-md.js.map +1 -0
  272. package/dist/src/services/agent-pack/types.d.ts +118 -0
  273. package/dist/src/services/agent-pack/types.d.ts.map +1 -0
  274. package/dist/src/services/agent-pack/types.js +61 -0
  275. package/dist/src/services/agent-pack/types.js.map +1 -0
  276. package/dist/src/services/agent-tool-profile.d.ts +59 -0
  277. package/dist/src/services/agent-tool-profile.d.ts.map +1 -0
  278. package/dist/src/services/agent-tool-profile.js +76 -0
  279. package/dist/src/services/agent-tool-profile.js.map +1 -0
  280. package/dist/src/services/agent-tool-profile.test.d.ts +2 -0
  281. package/dist/src/services/agent-tool-profile.test.d.ts.map +1 -0
  282. package/dist/src/services/agent-tool-profile.test.js +28 -0
  283. package/dist/src/services/agent-tool-profile.test.js.map +1 -0
  284. package/dist/src/services/bundled-sibling-scan.d.ts +111 -0
  285. package/dist/src/services/bundled-sibling-scan.d.ts.map +1 -0
  286. package/dist/src/services/bundled-sibling-scan.js +170 -0
  287. package/dist/src/services/bundled-sibling-scan.js.map +1 -0
  288. package/dist/src/services/skill-installation.io.d.ts +16 -5
  289. package/dist/src/services/skill-installation.io.d.ts.map +1 -1
  290. package/dist/src/services/skill-installation.io.js +63 -22
  291. package/dist/src/services/skill-installation.io.js.map +1 -1
  292. package/dist/src/services/skill-installation.policy.d.ts +96 -0
  293. package/dist/src/services/skill-installation.policy.d.ts.map +1 -0
  294. package/dist/src/services/skill-installation.policy.js +144 -0
  295. package/dist/src/services/skill-installation.policy.js.map +1 -0
  296. package/dist/src/services/skill-installation.service.d.ts.map +1 -1
  297. package/dist/src/services/skill-installation.service.js +9 -3
  298. package/dist/src/services/skill-installation.service.js.map +1 -1
  299. package/dist/src/sources/index.d.ts +1 -0
  300. package/dist/src/sources/index.d.ts.map +1 -1
  301. package/dist/src/sources/index.js +4 -0
  302. package/dist/src/sources/index.js.map +1 -1
  303. package/dist/src/sync/access-token.d.ts +27 -0
  304. package/dist/src/sync/access-token.d.ts.map +1 -0
  305. package/dist/src/sync/access-token.js +40 -0
  306. package/dist/src/sync/access-token.js.map +1 -0
  307. package/dist/src/sync/audit-notify-client.d.ts +83 -0
  308. package/dist/src/sync/audit-notify-client.d.ts.map +1 -0
  309. package/dist/src/sync/audit-notify-client.js +126 -0
  310. package/dist/src/sync/audit-notify-client.js.map +1 -0
  311. package/dist/src/sync/audit-notify-client.test.d.ts +14 -0
  312. package/dist/src/sync/audit-notify-client.test.d.ts.map +1 -0
  313. package/dist/src/sync/audit-notify-client.test.js +133 -0
  314. package/dist/src/sync/audit-notify-client.test.js.map +1 -0
  315. package/dist/src/sync/index.d.ts +2 -1
  316. package/dist/src/sync/index.d.ts.map +1 -1
  317. package/dist/src/sync/index.js +3 -1
  318. package/dist/src/sync/index.js.map +1 -1
  319. package/dist/src/sync/inventory-client.d.ts +16 -0
  320. package/dist/src/sync/inventory-client.d.ts.map +1 -1
  321. package/dist/src/sync/inventory-client.js +59 -16
  322. package/dist/src/sync/inventory-client.js.map +1 -1
  323. package/dist/src/sync/inventory-client.test.js +67 -1
  324. package/dist/src/sync/inventory-client.test.js.map +1 -1
  325. package/dist/src/sync/inventory-collector.d.ts.map +1 -1
  326. package/dist/src/sync/inventory-collector.js +32 -5
  327. package/dist/src/sync/inventory-collector.js.map +1 -1
  328. package/dist/src/sync/inventory-collector.test.js +50 -1
  329. package/dist/src/sync/inventory-collector.test.js.map +1 -1
  330. package/dist/src/sync/inventory-types.d.ts +9 -0
  331. package/dist/src/sync/inventory-types.d.ts.map +1 -1
  332. package/dist/src/sync/inventory-types.js +3 -0
  333. package/dist/src/sync/inventory-types.js.map +1 -1
  334. package/dist/src/telemetry/agent-marker.d.ts +137 -0
  335. package/dist/src/telemetry/agent-marker.d.ts.map +1 -0
  336. package/dist/src/telemetry/agent-marker.js +242 -0
  337. package/dist/src/telemetry/agent-marker.js.map +1 -0
  338. package/dist/src/telemetry/agent-marker.test.d.ts +13 -0
  339. package/dist/src/telemetry/agent-marker.test.d.ts.map +1 -0
  340. package/dist/src/telemetry/agent-marker.test.js +202 -0
  341. package/dist/src/telemetry/agent-marker.test.js.map +1 -0
  342. package/dist/src/telemetry/index.d.ts +2 -1
  343. package/dist/src/telemetry/index.d.ts.map +1 -1
  344. package/dist/src/telemetry/index.js +6 -1
  345. package/dist/src/telemetry/index.js.map +1 -1
  346. package/dist/src/telemetry/posthog.d.ts +25 -0
  347. package/dist/src/telemetry/posthog.d.ts.map +1 -1
  348. package/dist/src/telemetry/posthog.js +10 -1
  349. package/dist/src/telemetry/posthog.js.map +1 -1
  350. package/dist/src/telemetry/wrap.bench.js +5 -0
  351. package/dist/src/telemetry/wrap.bench.js.map +1 -1
  352. package/dist/src/telemetry/wrap.correlation.test.d.ts +20 -0
  353. package/dist/src/telemetry/wrap.correlation.test.d.ts.map +1 -0
  354. package/dist/src/telemetry/wrap.correlation.test.js +174 -0
  355. package/dist/src/telemetry/wrap.correlation.test.js.map +1 -0
  356. package/dist/src/telemetry/wrap.d.ts +28 -7
  357. package/dist/src/telemetry/wrap.d.ts.map +1 -1
  358. package/dist/src/telemetry/wrap.gate.test.d.ts +22 -0
  359. package/dist/src/telemetry/wrap.gate.test.d.ts.map +1 -0
  360. package/dist/src/telemetry/wrap.gate.test.js +202 -0
  361. package/dist/src/telemetry/wrap.gate.test.js.map +1 -0
  362. package/dist/src/telemetry/wrap.js +196 -52
  363. package/dist/src/telemetry/wrap.js.map +1 -1
  364. package/dist/src/telemetry/wrap.marker.test.d.ts +16 -0
  365. package/dist/src/telemetry/wrap.marker.test.d.ts.map +1 -0
  366. package/dist/src/telemetry/wrap.marker.test.js +190 -0
  367. package/dist/src/telemetry/wrap.marker.test.js.map +1 -0
  368. package/dist/src/telemetry/wrap.test.js +14 -0
  369. package/dist/src/telemetry/wrap.test.js.map +1 -1
  370. package/dist/src/types.d.ts +6 -0
  371. package/dist/src/types.d.ts.map +1 -1
  372. package/dist/tests/SecurityScanner.exec.test.js +60 -0
  373. package/dist/tests/SecurityScanner.exec.test.js.map +1 -1
  374. package/dist/tests/security/ContinuousSecurity.test.js +10 -4
  375. package/dist/tests/security/ContinuousSecurity.test.js.map +1 -1
  376. package/dist/tests/security/SecurityScanner.chmod-evasion.test.d.ts +2 -0
  377. package/dist/tests/security/SecurityScanner.chmod-evasion.test.d.ts.map +1 -0
  378. package/dist/tests/security/SecurityScanner.chmod-evasion.test.js +126 -0
  379. package/dist/tests/security/SecurityScanner.chmod-evasion.test.js.map +1 -0
  380. package/dist/tests/security/chmod-compound.test.d.ts +2 -0
  381. package/dist/tests/security/chmod-compound.test.d.ts.map +1 -0
  382. package/dist/tests/security/chmod-compound.test.js +188 -0
  383. package/dist/tests/security/chmod-compound.test.js.map +1 -0
  384. package/dist/tests/security/pii-detection.test.js +24 -0
  385. package/dist/tests/security/pii-detection.test.js.map +1 -1
  386. package/dist/tests/security/scanner-regression-guard.test.d.ts +23 -7
  387. package/dist/tests/security/scanner-regression-guard.test.d.ts.map +1 -1
  388. package/dist/tests/security/scanner-regression-guard.test.js +206 -12
  389. package/dist/tests/security/scanner-regression-guard.test.js.map +1 -1
  390. package/dist/tests/security/sensitive-path-fp.test.d.ts +2 -0
  391. package/dist/tests/security/sensitive-path-fp.test.d.ts.map +1 -0
  392. package/dist/tests/security/sensitive-path-fp.test.js +142 -0
  393. package/dist/tests/security/sensitive-path-fp.test.js.map +1 -0
  394. package/dist/tests/services/bundled-sibling-scan.test.d.ts +2 -0
  395. package/dist/tests/services/bundled-sibling-scan.test.d.ts.map +1 -0
  396. package/dist/tests/services/bundled-sibling-scan.test.js +139 -0
  397. package/dist/tests/services/bundled-sibling-scan.test.js.map +1 -0
  398. package/dist/tests/unit/services/skill-installation.io.test.js +166 -0
  399. package/dist/tests/unit/services/skill-installation.io.test.js.map +1 -1
  400. package/dist/tests/unit/services/skill-installation.policy.test.d.ts +8 -0
  401. package/dist/tests/unit/services/skill-installation.policy.test.d.ts.map +1 -0
  402. package/dist/tests/unit/services/skill-installation.policy.test.js +151 -0
  403. package/dist/tests/unit/services/skill-installation.policy.test.js.map +1 -0
  404. package/package.json +28 -3
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @fileoverview Change-journal writer — single-writer, fsync'd, hash-chained
3
+ * append (SMI-5456 Wave 1 Step 3 / SMI-5470).
4
+ * @module @skillsmith/core/journal/writer
5
+ *
6
+ * P-5 single-writer invariant (docs/internal/implementation/smi-5456-skillsmith-agent-wave1.md
7
+ * "Shared-State / Coordination Audit"): the journal file is written by the
8
+ * apply-family MCP tools ONLY, and every writer in this process funnels
9
+ * through `appendJournalRecord`, which serializes behind ONE module-scoped
10
+ * promise queue. That queue — not any per-caller locking — is what makes
11
+ * concurrent `apply_namespace_rename` / `apply_recommended_edit` / `undo_apply`
12
+ * calls in the same server process produce well-formed, correctly-chained
13
+ * lines instead of interleaved/torn writes.
14
+ *
15
+ * Durability: each append opens the file, writes the line, calls
16
+ * `FileHandle.sync()` (fsync), then closes — so a record that returns
17
+ * successfully is durable on disk before the caller's apply/undo response
18
+ * goes out, matching the "fsync'd appends" requirement in the plan's P-5
19
+ * table.
20
+ */
21
+ import { mkdir, open, readFile } from 'node:fs/promises';
22
+ import { dirname } from 'node:path';
23
+ import { JOURNAL_GENESIS_HASH, sha256Hex } from './hash.js';
24
+ import { getJournalFilePath } from './path.js';
25
+ /**
26
+ * Canonical (fixed-key-order) JSON of every hash-chain-relevant field,
27
+ * INCLUDING `prev_hash` but EXCLUDING `record_hash` itself. Plain
28
+ * `JSON.stringify` is sufficient canonicalization here because the object
29
+ * literal below is always constructed with the same key order — a full
30
+ * canonical-JSON library would be overkill for a single fixed shape.
31
+ */
32
+ function canonicalFields(record) {
33
+ const ordered = {
34
+ schema: record.schema,
35
+ ts: record.ts,
36
+ session_id: record.session_id,
37
+ tool: record.tool,
38
+ action: record.action,
39
+ suggestion_id: record.suggestion_id,
40
+ target_path: record.target_path,
41
+ before_hash: record.before_hash,
42
+ after_hash: record.after_hash,
43
+ approval: record.approval,
44
+ backup_ref: record.backup_ref,
45
+ detail: record.detail,
46
+ prev_hash: record.prev_hash,
47
+ };
48
+ return JSON.stringify(ordered);
49
+ }
50
+ /**
51
+ * Recompute a record's `record_hash` from its other fields. Exported so the
52
+ * reader can independently verify each line without duplicating the
53
+ * canonicalization logic (drift between writer and reader would silently
54
+ * break every chain-verification call).
55
+ */
56
+ export function computeRecordHash(record) {
57
+ return sha256Hex(canonicalFields(record));
58
+ }
59
+ export function isCorruptTailError(err) {
60
+ return (err instanceof Error &&
61
+ err.kind === 'journal.write.corrupt_tail');
62
+ }
63
+ async function getLastRecordHash(filePath) {
64
+ let raw;
65
+ try {
66
+ raw = await readFile(filePath, 'utf-8');
67
+ }
68
+ catch {
69
+ return JOURNAL_GENESIS_HASH;
70
+ }
71
+ const lines = raw.split('\n').filter((line) => line.trim().length > 0);
72
+ if (lines.length === 0)
73
+ return JOURNAL_GENESIS_HASH;
74
+ const lastLine = lines[lines.length - 1];
75
+ try {
76
+ const parsed = JSON.parse(lastLine);
77
+ if (typeof parsed.record_hash === 'string' && parsed.record_hash.length > 0) {
78
+ return parsed.record_hash;
79
+ }
80
+ }
81
+ catch {
82
+ // fall through to the corrupt-tail error below
83
+ }
84
+ const err = new Error('journal tail is corrupt or unparseable; refusing to append past an unverifiable chain head');
85
+ err.kind = 'journal.write.corrupt_tail';
86
+ throw err;
87
+ }
88
+ // P-5 single-writer invariant: every append in this process funnels through
89
+ // this one queue, regardless of which apply-family tool called it.
90
+ let writeQueue = Promise.resolve();
91
+ /**
92
+ * Append a record to the journal. Serialized behind the module-scoped
93
+ * write queue and fsync'd before the returned promise resolves.
94
+ *
95
+ * Callers (the apply-family tools) should treat a rejection as fail-soft —
96
+ * the journal is an evidence trail, not a gate on the user's mutation —
97
+ * and log rather than propagate. See `tools/apply-journal.helpers.ts` in
98
+ * `@skillsmith/mcp-server` for the call-site convention.
99
+ */
100
+ export function appendJournalRecord(input) {
101
+ const task = writeQueue.then(() => doAppend(input));
102
+ // A rejected append must not wedge the queue for subsequent callers.
103
+ writeQueue = task.then(() => undefined, () => undefined);
104
+ return task;
105
+ }
106
+ async function doAppend(input) {
107
+ const filePath = getJournalFilePath();
108
+ await mkdir(dirname(filePath), { recursive: true });
109
+ // Propagates as-is (including `JournalCorruptTailError`) — callers use
110
+ // `isCorruptTailError` to distinguish it from a generic I/O failure.
111
+ const prevHash = await getLastRecordHash(filePath);
112
+ const withoutHash = { ...input, prev_hash: prevHash };
113
+ const record = { ...withoutHash, record_hash: computeRecordHash(withoutHash) };
114
+ const line = JSON.stringify(record) + '\n';
115
+ const handle = await open(filePath, 'a');
116
+ try {
117
+ await handle.appendFile(line, 'utf-8');
118
+ await handle.sync();
119
+ }
120
+ finally {
121
+ await handle.close();
122
+ }
123
+ return record;
124
+ }
125
+ //# sourceMappingURL=writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.js","sourceRoot":"","sources":["../../../src/journal/writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAG9C;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,MAA0C;IACjE,MAAM,OAAO,GAAG;QACd,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,WAAW,EAAE,MAAM,CA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MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACtC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IACtB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * SMI-5615: Correlation-ID context for the shared logging + telemetry pipeline.
3
+ *
4
+ * Lives in `logging/` (not `telemetry/wrap.ts`) so both `telemetry/wrap.ts`
5
+ * and the future `logging/logger.ts` (Wave 2) can read/write it without a
6
+ * circular import between the `telemetry` and `logging` subtrees (F4). This
7
+ * module imports ONLY `node:async_hooks` — it must never import from
8
+ * `../telemetry/*`, or the one-directional `telemetry -> logging` boundary
9
+ * this split exists to guarantee breaks. An ESLint `no-restricted-imports`
10
+ * boundary guard (Wave 2, §1) enforces this mechanically; keep it true by
11
+ * construction here regardless.
12
+ *
13
+ * Mirrors the existing `markerStorage` / `runWithMarkerContext` pattern in
14
+ * `packages/core/src/telemetry/wrap.ts`: a module-scoped `AsyncLocalStorage`
15
+ * instance, installed per-call via a `runWith*` function, read live via
16
+ * `.getStore()` — never memoised. `AsyncLocalStorage` (not a module-scoped
17
+ * variable) because harnesses batch PARALLEL tool calls to one server
18
+ * process; a plain module slot would let call A's completion clear call B's
19
+ * still-in-flight correlation ID.
20
+ *
21
+ * Install-site correction (F1, see `docs/internal/implementation/production-error-logging.md`):
22
+ * the correlation ID is installed by `withTelemetry` around its *entire*
23
+ * `wrappedFn` body (try + finally), not just the inner `handler(...args)`
24
+ * call — otherwise the emit path's `getCorrelationId()` read happens after
25
+ * the scope has already unwound and always returns `undefined`.
26
+ */
27
+ import { AsyncLocalStorage } from 'node:async_hooks';
28
+ /**
29
+ * Per-call correlation ID, scoped via `runWithCorrelationId`. Read live via
30
+ * `getCorrelationId()` — never memoised — so every consumer (the
31
+ * `withTelemetry` emit path, and later `logging/logger.ts`) observes the ID
32
+ * for its OWN call's async continuation, never a sibling's.
33
+ */
34
+ export declare const correlationIdStorage: AsyncLocalStorage<string>;
35
+ /**
36
+ * Run `fn` with `id` installed as the correlation ID for every telemetry
37
+ * emit / log call inside its async continuation. Concurrency-safe: parallel
38
+ * invocations each see only their own ID; code outside any
39
+ * `runWithCorrelationId` scope sees no ID (`getCorrelationId()` returns
40
+ * `undefined`).
41
+ *
42
+ * Callers should mint-if-absent (`getCorrelationId() ?? randomUUID()`)
43
+ * before calling this, so a wrapped call nested inside another wrapped
44
+ * call's continuation inherits the outer ID instead of fragmenting one
45
+ * logical request's trace across multiple IDs.
46
+ */
47
+ export declare function runWithCorrelationId<T>(id: string, fn: () => Promise<T>): Promise<T>;
48
+ /**
49
+ * Read the correlation ID installed for the current async continuation, or
50
+ * `undefined` if called outside any `runWithCorrelationId` scope (e.g.
51
+ * fire-and-forget work started before any tool call establishes a scope).
52
+ *
53
+ * Must be read synchronously at the log/emit call site — never deferred to
54
+ * an async flush/rotation callback, which could fire outside the
55
+ * originating call's scope (F3).
56
+ */
57
+ export declare function getCorrelationId(): string | undefined;
58
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/logging/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,2BAAkC,CAAA;AAEnE;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAEpF;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * SMI-5615: Correlation-ID context for the shared logging + telemetry pipeline.
3
+ *
4
+ * Lives in `logging/` (not `telemetry/wrap.ts`) so both `telemetry/wrap.ts`
5
+ * and the future `logging/logger.ts` (Wave 2) can read/write it without a
6
+ * circular import between the `telemetry` and `logging` subtrees (F4). This
7
+ * module imports ONLY `node:async_hooks` — it must never import from
8
+ * `../telemetry/*`, or the one-directional `telemetry -> logging` boundary
9
+ * this split exists to guarantee breaks. An ESLint `no-restricted-imports`
10
+ * boundary guard (Wave 2, §1) enforces this mechanically; keep it true by
11
+ * construction here regardless.
12
+ *
13
+ * Mirrors the existing `markerStorage` / `runWithMarkerContext` pattern in
14
+ * `packages/core/src/telemetry/wrap.ts`: a module-scoped `AsyncLocalStorage`
15
+ * instance, installed per-call via a `runWith*` function, read live via
16
+ * `.getStore()` — never memoised. `AsyncLocalStorage` (not a module-scoped
17
+ * variable) because harnesses batch PARALLEL tool calls to one server
18
+ * process; a plain module slot would let call A's completion clear call B's
19
+ * still-in-flight correlation ID.
20
+ *
21
+ * Install-site correction (F1, see `docs/internal/implementation/production-error-logging.md`):
22
+ * the correlation ID is installed by `withTelemetry` around its *entire*
23
+ * `wrappedFn` body (try + finally), not just the inner `handler(...args)`
24
+ * call — otherwise the emit path's `getCorrelationId()` read happens after
25
+ * the scope has already unwound and always returns `undefined`.
26
+ */
27
+ import { AsyncLocalStorage } from 'node:async_hooks';
28
+ /**
29
+ * Per-call correlation ID, scoped via `runWithCorrelationId`. Read live via
30
+ * `getCorrelationId()` — never memoised — so every consumer (the
31
+ * `withTelemetry` emit path, and later `logging/logger.ts`) observes the ID
32
+ * for its OWN call's async continuation, never a sibling's.
33
+ */
34
+ export const correlationIdStorage = new AsyncLocalStorage();
35
+ /**
36
+ * Run `fn` with `id` installed as the correlation ID for every telemetry
37
+ * emit / log call inside its async continuation. Concurrency-safe: parallel
38
+ * invocations each see only their own ID; code outside any
39
+ * `runWithCorrelationId` scope sees no ID (`getCorrelationId()` returns
40
+ * `undefined`).
41
+ *
42
+ * Callers should mint-if-absent (`getCorrelationId() ?? randomUUID()`)
43
+ * before calling this, so a wrapped call nested inside another wrapped
44
+ * call's continuation inherits the outer ID instead of fragmenting one
45
+ * logical request's trace across multiple IDs.
46
+ */
47
+ export function runWithCorrelationId(id, fn) {
48
+ return correlationIdStorage.run(id, fn);
49
+ }
50
+ /**
51
+ * Read the correlation ID installed for the current async continuation, or
52
+ * `undefined` if called outside any `runWithCorrelationId` scope (e.g.
53
+ * fire-and-forget work started before any tool call establishes a scope).
54
+ *
55
+ * Must be read synchronously at the log/emit call site — never deferred to
56
+ * an async flush/rotation callback, which could fire outside the
57
+ * originating call's scope (F3).
58
+ */
59
+ export function getCorrelationId() {
60
+ return correlationIdStorage.getStore();
61
+ }
62
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/logging/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,iBAAiB,EAAU,CAAA;AAEnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAI,EAAU,EAAE,EAAoB;IACtE,OAAO,oBAAoB,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,oBAAoB,CAAC,QAAQ,EAAE,CAAA;AACxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * SMI-5615: Unit tests for `correlationIdStorage` / `runWithCorrelationId` /
3
+ * `getCorrelationId`. Mirrors the pattern of the `markerStorage` coverage in
4
+ * `packages/core/src/telemetry/wrap.marker.test.ts` — a module-scoped
5
+ * `AsyncLocalStorage` instance, installed per-call via a `runWith*` function,
6
+ * read live via `.getStore()`.
7
+ *
8
+ * These are direct, in-isolation tests of the primitive itself; the
9
+ * `withTelemetry` install-site contract (mint-if-absent, whole-`wrappedFn`-
10
+ * body scope) is covered separately in
11
+ * `packages/core/src/telemetry/wrap.correlation.test.ts`.
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=context.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.test.d.ts","sourceRoot":"","sources":["../../../src/logging/context.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * SMI-5615: Unit tests for `correlationIdStorage` / `runWithCorrelationId` /
3
+ * `getCorrelationId`. Mirrors the pattern of the `markerStorage` coverage in
4
+ * `packages/core/src/telemetry/wrap.marker.test.ts` — a module-scoped
5
+ * `AsyncLocalStorage` instance, installed per-call via a `runWith*` function,
6
+ * read live via `.getStore()`.
7
+ *
8
+ * These are direct, in-isolation tests of the primitive itself; the
9
+ * `withTelemetry` install-site contract (mint-if-absent, whole-`wrappedFn`-
10
+ * body scope) is covered separately in
11
+ * `packages/core/src/telemetry/wrap.correlation.test.ts`.
12
+ */
13
+ import { describe, it, expect } from 'vitest';
14
+ import { correlationIdStorage, runWithCorrelationId, getCorrelationId } from './context.js';
15
+ describe('getCorrelationId', () => {
16
+ it('returns undefined outside any runWithCorrelationId scope', () => {
17
+ expect(getCorrelationId()).toBeUndefined();
18
+ });
19
+ });
20
+ describe('runWithCorrelationId', () => {
21
+ it('installs the ID for the duration of the callback', async () => {
22
+ let observed;
23
+ await runWithCorrelationId('id-1', async () => {
24
+ observed = getCorrelationId();
25
+ });
26
+ expect(observed).toBe('id-1');
27
+ });
28
+ it('auto-unwinds after the callback resolves', async () => {
29
+ await runWithCorrelationId('id-2', async () => {
30
+ // no-op
31
+ });
32
+ expect(getCorrelationId()).toBeUndefined();
33
+ });
34
+ it('auto-unwinds after the callback rejects', async () => {
35
+ await expect(runWithCorrelationId('id-3', async () => {
36
+ throw new Error('boom');
37
+ })).rejects.toThrow('boom');
38
+ expect(getCorrelationId()).toBeUndefined();
39
+ });
40
+ it('returns the callback resolved value', async () => {
41
+ const result = await runWithCorrelationId('id-4', async () => 42);
42
+ expect(result).toBe(42);
43
+ });
44
+ it('nested scopes — inner ID shadows the outer ID inside its own callback', async () => {
45
+ const seen = [];
46
+ await runWithCorrelationId('outer', async () => {
47
+ seen.push(getCorrelationId());
48
+ await runWithCorrelationId('inner', async () => {
49
+ seen.push(getCorrelationId()); // 'inner' — shadows the outer ID
50
+ });
51
+ // Outer scope resumes after the inner one unwinds — back to 'outer'.
52
+ seen.push(getCorrelationId());
53
+ });
54
+ expect(seen).toEqual(['outer', 'inner', 'outer']);
55
+ });
56
+ it('concurrent, overlapping scopes each observe only their own ID (P-5 invariant)', async () => {
57
+ let releaseA;
58
+ let releaseB;
59
+ const blockA = new Promise((r) => (releaseA = r));
60
+ const blockB = new Promise((r) => (releaseB = r));
61
+ const observedA = [];
62
+ const observedB = [];
63
+ const callA = runWithCorrelationId('id-a', async () => {
64
+ observedA.push(getCorrelationId());
65
+ await blockA;
66
+ observedA.push(getCorrelationId());
67
+ });
68
+ const callB = runWithCorrelationId('id-b', async () => {
69
+ observedB.push(getCorrelationId());
70
+ await blockB;
71
+ observedB.push(getCorrelationId());
72
+ });
73
+ // A completes first while B is still awaiting; B must never observe A's ID.
74
+ releaseA();
75
+ await callA;
76
+ releaseB();
77
+ await callB;
78
+ expect(observedA).toEqual(['id-a', 'id-a']);
79
+ expect(observedB).toEqual(['id-b', 'id-b']);
80
+ });
81
+ it('the exported correlationIdStorage is the same instance read.write path', async () => {
82
+ // Sanity: getCorrelationId is a thin wrapper over correlationIdStorage.getStore().
83
+ await correlationIdStorage.run('direct-id', async () => {
84
+ expect(getCorrelationId()).toBe('direct-id');
85
+ });
86
+ });
87
+ });
88
+ //# sourceMappingURL=context.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.test.js","sourceRoot":"","sources":["../../../src/logging/context.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE3F,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,aAAa,EAAE,CAAA;IAC5C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,IAAI,QAA4B,CAAA;QAChC,MAAM,oBAAoB,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;YAC5C,QAAQ,GAAG,gBAAgB,EAAE,CAAA;QAC/B,CAAC,CAAC,CAAA;QACF,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,oBAAoB,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;YAC5C,QAAQ;QACV,CAAC,CAAC,CAAA;QACF,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,aAAa,EAAE,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,MAAM,CACV,oBAAoB,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,MAAM,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+1,13 @@
1
+ /**
2
+ * SMI-5615: Logging Module Exports
3
+ *
4
+ * Shared structured JSON-line error logging (`~/.skillsmith/logs/`) with
5
+ * SMI-883 redaction, per-surface write serialization, and correlation-ID
6
+ * threading with `@skillsmith/core/telemetry`'s `withTelemetry`. Consumed by
7
+ * the MCP server and CLI via the `"./logging"` package export.
8
+ */
9
+ export { createLogger, getLogger, type CreateLoggerOptions, type Logger } from './logger.js';
10
+ export { runWithCorrelationId, getCorrelationId } from './context.js';
11
+ export { redactSensitiveData, redactSensitiveObject } from './redact.js';
12
+ export type { LogLevel, Surface, LogRecord, LogRecordError, LogDetails } from './types.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,mBAAmB,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAA;AAE5F,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAErE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * SMI-5615: Logging Module Exports
3
+ *
4
+ * Shared structured JSON-line error logging (`~/.skillsmith/logs/`) with
5
+ * SMI-883 redaction, per-surface write serialization, and correlation-ID
6
+ * threading with `@skillsmith/core/telemetry`'s `withTelemetry`. Consumed by
7
+ * the MCP server and CLI via the `"./logging"` package export.
8
+ */
9
+ export { createLogger, getLogger } from './logger.js';
10
+ export { runWithCorrelationId, getCorrelationId } from './context.js';
11
+ export { redactSensitiveData, redactSensitiveObject } from './redact.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAyC,MAAM,aAAa,CAAA;AAE5F,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAErE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * SMI-5615: Shared structured JSON-line logger.
3
+ *
4
+ * Generalized from the dead `packages/mcp-server/src/logger.ts` (SMI-883
5
+ * redaction) into a surface-agnostic module usable by the MCP server, CLI,
6
+ * and VS Code extension independently — `createLogger(surface)` is a
7
+ * factory, not a singleton, so each host process can mint its own logger
8
+ * (optionally stamped with its own package version) while still writing to
9
+ * per-surface files that are safe to share across processes for the same
10
+ * surface (see `rotation.ts`).
11
+ *
12
+ * Call-site invariants (see
13
+ * docs/internal/implementation/production-error-logging.md §1 and the
14
+ * Shared-State / Coordination Audit table, F2/F3):
15
+ *
16
+ * - `getCorrelationId()` is read SYNCHRONOUSLY at the call site, inside
17
+ * `buildRecord`, never inside an async flush/rotation callback (F3) — a
18
+ * deferred read could observe a different call's (or no) correlation ID
19
+ * once the originating call's `AsyncLocalStorage` scope has unwound.
20
+ * - The full JSON-line record (including the synchronously-read
21
+ * correlation ID and synchronously-applied redaction) is built and
22
+ * `JSON.stringify`'d BEFORE handing the string off to `rotation.ts`'s
23
+ * serialized per-surface writer (F2) — only the actual disk write may
24
+ * complete asynchronously; by the time it starts, the record content is
25
+ * already frozen.
26
+ * - Logger calls never throw. Any failure while assembling or persisting a
27
+ * record falls back to `console.error`/`console.warn` (matching level,
28
+ * with `info`/`debug` also routed to `console.error`) rather than being
29
+ * fully silent — stderr remains the safety net of last resort. This
30
+ * differs from the old logger's "silently fail" comment intent, which is
31
+ * no longer acceptable once this is the only durable failure signal.
32
+ * - `warn`/`error` ALWAYS mirror to `console.warn`/`console.error`,
33
+ * synchronously, regardless of whether the disk write succeeds — this is
34
+ * NOT a failure-only fallback for those two levels (only `info`/`debug`
35
+ * use console purely as a write-failure fallback). This is what makes
36
+ * `logger.error`/`logger.warn` a safe drop-in replacement for existing
37
+ * `console.error`/`console.warn` call sites in the MCP server and CLI —
38
+ * the caller-visible terminal/stderr output stays identical to today,
39
+ * with redacted disk persistence added on top rather than instead of it.
40
+ */
41
+ import type { LogDetails, Surface } from './types.js';
42
+ export interface CreateLoggerOptions {
43
+ /**
44
+ * Package/CLI version stamped on every record from this logger instance.
45
+ * Defaults to `'unknown'` — pass each host package's own `version` (e.g.
46
+ * from its own `package.json`) at its entrypoint for an accurate value.
47
+ */
48
+ version?: string;
49
+ }
50
+ export interface Logger {
51
+ info(message: string, details?: LogDetails): void;
52
+ warn(message: string, details?: LogDetails): void;
53
+ error(message: string, details?: LogDetails): void;
54
+ debug(message: string, details?: LogDetails): void;
55
+ }
56
+ /**
57
+ * Creates a logger bound to `surface`. Independent instances for different
58
+ * surfaces (or the same surface with different `version` stamps) are safe to
59
+ * create concurrently — they only share state at the `rotation.ts` layer,
60
+ * which is itself safe for concurrent writers to the same surface (F2).
61
+ */
62
+ export declare function createLogger(surface: Surface, options?: CreateLoggerOptions): Logger;
63
+ /**
64
+ * Memoized per-surface logger created with default options
65
+ * (`version: 'unknown'`). Prefer calling `createLogger(surface, { version })`
66
+ * once at each package's entrypoint so records carry that package's real
67
+ * version; `getLogger` is a convenience for call sites that don't need a
68
+ * custom version stamp and want a single shared instance per surface.
69
+ */
70
+ export declare function getLogger(surface: Surface): Logger;
71
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logging/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAuB,OAAO,EAAE,MAAM,YAAY,CAAA;AA2L1E,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACjD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACjD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAClD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;CACnD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA0BxF;AAID;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAOlD"}