@opensip-cli/core 0.1.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 (604) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +31 -0
  4. package/dist/__tests__/config-resolution.test.d.ts +2 -0
  5. package/dist/__tests__/config-resolution.test.d.ts.map +1 -0
  6. package/dist/__tests__/config-resolution.test.js +94 -0
  7. package/dist/__tests__/config-resolution.test.js.map +1 -0
  8. package/dist/__tests__/public-api.test.d.ts +16 -0
  9. package/dist/__tests__/public-api.test.d.ts.map +1 -0
  10. package/dist/__tests__/public-api.test.js +209 -0
  11. package/dist/__tests__/public-api.test.js.map +1 -0
  12. package/dist/__tests__/signal-batch.test.d.ts +2 -0
  13. package/dist/__tests__/signal-batch.test.d.ts.map +1 -0
  14. package/dist/__tests__/signal-batch.test.js +39 -0
  15. package/dist/__tests__/signal-batch.test.js.map +1 -0
  16. package/dist/__tests__/signal-sink.test.d.ts +2 -0
  17. package/dist/__tests__/signal-sink.test.d.ts.map +1 -0
  18. package/dist/__tests__/signal-sink.test.js +25 -0
  19. package/dist/__tests__/signal-sink.test.js.map +1 -0
  20. package/dist/__tests__/strip-utils.test.d.ts +2 -0
  21. package/dist/__tests__/strip-utils.test.d.ts.map +1 -0
  22. package/dist/__tests__/strip-utils.test.js +397 -0
  23. package/dist/__tests__/strip-utils.test.js.map +1 -0
  24. package/dist/__tests__/text-tree.test.d.ts +2 -0
  25. package/dist/__tests__/text-tree.test.d.ts.map +1 -0
  26. package/dist/__tests__/text-tree.test.js +31 -0
  27. package/dist/__tests__/text-tree.test.js.map +1 -0
  28. package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts +2 -0
  29. package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts.map +1 -0
  30. package/dist/baseline/__tests__/fingerprint-strategy.test.js +69 -0
  31. package/dist/baseline/__tests__/fingerprint-strategy.test.js.map +1 -0
  32. package/dist/baseline/fingerprint-strategy.d.ts +70 -0
  33. package/dist/baseline/fingerprint-strategy.d.ts.map +1 -0
  34. package/dist/baseline/fingerprint-strategy.js +90 -0
  35. package/dist/baseline/fingerprint-strategy.js.map +1 -0
  36. package/dist/config-resolution.d.ts +27 -0
  37. package/dist/config-resolution.d.ts.map +1 -0
  38. package/dist/config-resolution.js +92 -0
  39. package/dist/config-resolution.js.map +1 -0
  40. package/dist/index.d.ts +81 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +165 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/languages/__tests__/content-filter-dispatch.test.d.ts +2 -0
  45. package/dist/languages/__tests__/content-filter-dispatch.test.d.ts.map +1 -0
  46. package/dist/languages/__tests__/content-filter-dispatch.test.js +87 -0
  47. package/dist/languages/__tests__/content-filter-dispatch.test.js.map +1 -0
  48. package/dist/languages/__tests__/non-code-formats.test.d.ts +2 -0
  49. package/dist/languages/__tests__/non-code-formats.test.d.ts.map +1 -0
  50. package/dist/languages/__tests__/non-code-formats.test.js +31 -0
  51. package/dist/languages/__tests__/non-code-formats.test.js.map +1 -0
  52. package/dist/languages/__tests__/parse-cache.test.d.ts +2 -0
  53. package/dist/languages/__tests__/parse-cache.test.d.ts.map +1 -0
  54. package/dist/languages/__tests__/parse-cache.test.js +228 -0
  55. package/dist/languages/__tests__/parse-cache.test.js.map +1 -0
  56. package/dist/languages/__tests__/registry.test.d.ts +2 -0
  57. package/dist/languages/__tests__/registry.test.d.ts.map +1 -0
  58. package/dist/languages/__tests__/registry.test.js +193 -0
  59. package/dist/languages/__tests__/registry.test.js.map +1 -0
  60. package/dist/languages/__tests__/workspace-unit-contract.test.d.ts +2 -0
  61. package/dist/languages/__tests__/workspace-unit-contract.test.d.ts.map +1 -0
  62. package/dist/languages/__tests__/workspace-unit-contract.test.js +66 -0
  63. package/dist/languages/__tests__/workspace-unit-contract.test.js.map +1 -0
  64. package/dist/languages/adapter.d.ts +66 -0
  65. package/dist/languages/adapter.d.ts.map +1 -0
  66. package/dist/languages/adapter.js +2 -0
  67. package/dist/languages/adapter.js.map +1 -0
  68. package/dist/languages/content-filter-dispatch.d.ts +36 -0
  69. package/dist/languages/content-filter-dispatch.d.ts.map +1 -0
  70. package/dist/languages/content-filter-dispatch.js +75 -0
  71. package/dist/languages/content-filter-dispatch.js.map +1 -0
  72. package/dist/languages/generic-types.d.ts +22 -0
  73. package/dist/languages/generic-types.d.ts.map +1 -0
  74. package/dist/languages/generic-types.js +3 -0
  75. package/dist/languages/generic-types.js.map +1 -0
  76. package/dist/languages/index.d.ts +12 -0
  77. package/dist/languages/index.d.ts.map +1 -0
  78. package/dist/languages/index.js +7 -0
  79. package/dist/languages/index.js.map +1 -0
  80. package/dist/languages/non-code-formats.d.ts +37 -0
  81. package/dist/languages/non-code-formats.d.ts.map +1 -0
  82. package/dist/languages/non-code-formats.js +45 -0
  83. package/dist/languages/non-code-formats.js.map +1 -0
  84. package/dist/languages/parse-cache-class.d.ts +69 -0
  85. package/dist/languages/parse-cache-class.d.ts.map +1 -0
  86. package/dist/languages/parse-cache-class.js +135 -0
  87. package/dist/languages/parse-cache-class.js.map +1 -0
  88. package/dist/languages/parse-cache.d.ts +54 -0
  89. package/dist/languages/parse-cache.d.ts.map +1 -0
  90. package/dist/languages/parse-cache.js +88 -0
  91. package/dist/languages/parse-cache.js.map +1 -0
  92. package/dist/languages/registry.d.ts +35 -0
  93. package/dist/languages/registry.d.ts.map +1 -0
  94. package/dist/languages/registry.js +123 -0
  95. package/dist/languages/registry.js.map +1 -0
  96. package/dist/languages/strip-scanners.d.ts +170 -0
  97. package/dist/languages/strip-scanners.d.ts.map +1 -0
  98. package/dist/languages/strip-scanners.js +233 -0
  99. package/dist/languages/strip-scanners.js.map +1 -0
  100. package/dist/languages/strip-utils.d.ts +66 -0
  101. package/dist/languages/strip-utils.d.ts.map +1 -0
  102. package/dist/languages/strip-utils.js +88 -0
  103. package/dist/languages/strip-utils.js.map +1 -0
  104. package/dist/languages/text-tree.d.ts +44 -0
  105. package/dist/languages/text-tree.d.ts.map +1 -0
  106. package/dist/languages/text-tree.js +34 -0
  107. package/dist/languages/text-tree.js.map +1 -0
  108. package/dist/languages/workspace-unit.d.ts +18 -0
  109. package/dist/languages/workspace-unit.d.ts.map +1 -0
  110. package/dist/languages/workspace-unit.js +2 -0
  111. package/dist/languages/workspace-unit.js.map +1 -0
  112. package/dist/lib/__tests__/config-version.test.d.ts +12 -0
  113. package/dist/lib/__tests__/config-version.test.d.ts.map +1 -0
  114. package/dist/lib/__tests__/config-version.test.js +92 -0
  115. package/dist/lib/__tests__/config-version.test.js.map +1 -0
  116. package/dist/lib/__tests__/diagnostics-bus.test.d.ts +7 -0
  117. package/dist/lib/__tests__/diagnostics-bus.test.d.ts.map +1 -0
  118. package/dist/lib/__tests__/diagnostics-bus.test.js +44 -0
  119. package/dist/lib/__tests__/diagnostics-bus.test.js.map +1 -0
  120. package/dist/lib/__tests__/env-registry.test.d.ts +7 -0
  121. package/dist/lib/__tests__/env-registry.test.d.ts.map +1 -0
  122. package/dist/lib/__tests__/env-registry.test.js +82 -0
  123. package/dist/lib/__tests__/env-registry.test.js.map +1 -0
  124. package/dist/lib/__tests__/errors.test.d.ts +2 -0
  125. package/dist/lib/__tests__/errors.test.d.ts.map +1 -0
  126. package/dist/lib/__tests__/errors.test.js +218 -0
  127. package/dist/lib/__tests__/errors.test.js.map +1 -0
  128. package/dist/lib/__tests__/format.test.d.ts +2 -0
  129. package/dist/lib/__tests__/format.test.d.ts.map +1 -0
  130. package/dist/lib/__tests__/format.test.js +23 -0
  131. package/dist/lib/__tests__/format.test.js.map +1 -0
  132. package/dist/lib/__tests__/ids.test.d.ts +2 -0
  133. package/dist/lib/__tests__/ids.test.d.ts.map +1 -0
  134. package/dist/lib/__tests__/ids.test.js +80 -0
  135. package/dist/lib/__tests__/ids.test.js.map +1 -0
  136. package/dist/lib/__tests__/logger.test.d.ts +2 -0
  137. package/dist/lib/__tests__/logger.test.d.ts.map +1 -0
  138. package/dist/lib/__tests__/logger.test.js +284 -0
  139. package/dist/lib/__tests__/logger.test.js.map +1 -0
  140. package/dist/lib/__tests__/package-version.test.d.ts +2 -0
  141. package/dist/lib/__tests__/package-version.test.d.ts.map +1 -0
  142. package/dist/lib/__tests__/package-version.test.js +47 -0
  143. package/dist/lib/__tests__/package-version.test.js.map +1 -0
  144. package/dist/lib/__tests__/paths.test.d.ts +5 -0
  145. package/dist/lib/__tests__/paths.test.d.ts.map +1 -0
  146. package/dist/lib/__tests__/paths.test.js +59 -0
  147. package/dist/lib/__tests__/paths.test.js.map +1 -0
  148. package/dist/lib/__tests__/payload-version.test.d.ts +2 -0
  149. package/dist/lib/__tests__/payload-version.test.d.ts.map +1 -0
  150. package/dist/lib/__tests__/payload-version.test.js +35 -0
  151. package/dist/lib/__tests__/payload-version.test.js.map +1 -0
  152. package/dist/lib/__tests__/phantom-detect.test.d.ts +10 -0
  153. package/dist/lib/__tests__/phantom-detect.test.d.ts.map +1 -0
  154. package/dist/lib/__tests__/phantom-detect.test.js +84 -0
  155. package/dist/lib/__tests__/phantom-detect.test.js.map +1 -0
  156. package/dist/lib/__tests__/project-context.test.d.ts +10 -0
  157. package/dist/lib/__tests__/project-context.test.d.ts.map +1 -0
  158. package/dist/lib/__tests__/project-context.test.js +240 -0
  159. package/dist/lib/__tests__/project-context.test.js.map +1 -0
  160. package/dist/lib/__tests__/registry.test.d.ts +2 -0
  161. package/dist/lib/__tests__/registry.test.d.ts.map +1 -0
  162. package/dist/lib/__tests__/registry.test.js +333 -0
  163. package/dist/lib/__tests__/registry.test.js.map +1 -0
  164. package/dist/lib/__tests__/retry.test.d.ts +2 -0
  165. package/dist/lib/__tests__/retry.test.d.ts.map +1 -0
  166. package/dist/lib/__tests__/retry.test.js +71 -0
  167. package/dist/lib/__tests__/retry.test.js.map +1 -0
  168. package/dist/lib/__tests__/run-diagnostics.test.d.ts +9 -0
  169. package/dist/lib/__tests__/run-diagnostics.test.d.ts.map +1 -0
  170. package/dist/lib/__tests__/run-diagnostics.test.js +61 -0
  171. package/dist/lib/__tests__/run-diagnostics.test.js.map +1 -0
  172. package/dist/lib/__tests__/run-scope.test.d.ts +2 -0
  173. package/dist/lib/__tests__/run-scope.test.d.ts.map +1 -0
  174. package/dist/lib/__tests__/run-scope.test.js +202 -0
  175. package/dist/lib/__tests__/run-scope.test.js.map +1 -0
  176. package/dist/lib/__tests__/run-timer.test.d.ts +2 -0
  177. package/dist/lib/__tests__/run-timer.test.d.ts.map +1 -0
  178. package/dist/lib/__tests__/run-timer.test.js +152 -0
  179. package/dist/lib/__tests__/run-timer.test.js.map +1 -0
  180. package/dist/lib/__tests__/severity-policy.test.d.ts +6 -0
  181. package/dist/lib/__tests__/severity-policy.test.d.ts.map +1 -0
  182. package/dist/lib/__tests__/severity-policy.test.js +47 -0
  183. package/dist/lib/__tests__/severity-policy.test.js.map +1 -0
  184. package/dist/lib/__tests__/telemetry.test.d.ts +2 -0
  185. package/dist/lib/__tests__/telemetry.test.d.ts.map +1 -0
  186. package/dist/lib/__tests__/telemetry.test.js +212 -0
  187. package/dist/lib/__tests__/telemetry.test.js.map +1 -0
  188. package/dist/lib/__tests__/verdict-policy.test.d.ts +7 -0
  189. package/dist/lib/__tests__/verdict-policy.test.d.ts.map +1 -0
  190. package/dist/lib/__tests__/verdict-policy.test.js +91 -0
  191. package/dist/lib/__tests__/verdict-policy.test.js.map +1 -0
  192. package/dist/lib/__tests__/yaml.test.d.ts +6 -0
  193. package/dist/lib/__tests__/yaml.test.d.ts.map +1 -0
  194. package/dist/lib/__tests__/yaml.test.js +79 -0
  195. package/dist/lib/__tests__/yaml.test.js.map +1 -0
  196. package/dist/lib/config-version.d.ts +49 -0
  197. package/dist/lib/config-version.d.ts.map +1 -0
  198. package/dist/lib/config-version.js +56 -0
  199. package/dist/lib/config-version.js.map +1 -0
  200. package/dist/lib/diagnostics-bus.d.ts +48 -0
  201. package/dist/lib/diagnostics-bus.d.ts.map +1 -0
  202. package/dist/lib/diagnostics-bus.js +74 -0
  203. package/dist/lib/diagnostics-bus.js.map +1 -0
  204. package/dist/lib/env-registry.d.ts +108 -0
  205. package/dist/lib/env-registry.d.ts.map +1 -0
  206. package/dist/lib/env-registry.js +92 -0
  207. package/dist/lib/env-registry.js.map +1 -0
  208. package/dist/lib/errors.d.ts +132 -0
  209. package/dist/lib/errors.d.ts.map +1 -0
  210. package/dist/lib/errors.js +160 -0
  211. package/dist/lib/errors.js.map +1 -0
  212. package/dist/lib/execution/__tests__/execution.test.d.ts +7 -0
  213. package/dist/lib/execution/__tests__/execution.test.d.ts.map +1 -0
  214. package/dist/lib/execution/__tests__/execution.test.js +254 -0
  215. package/dist/lib/execution/__tests__/execution.test.js.map +1 -0
  216. package/dist/lib/execution/index.d.ts +15 -0
  217. package/dist/lib/execution/index.d.ts.map +1 -0
  218. package/dist/lib/execution/index.js +10 -0
  219. package/dist/lib/execution/index.js.map +1 -0
  220. package/dist/lib/execution/options.d.ts +32 -0
  221. package/dist/lib/execution/options.d.ts.map +1 -0
  222. package/dist/lib/execution/options.js +15 -0
  223. package/dist/lib/execution/options.js.map +1 -0
  224. package/dist/lib/execution/pipeline.d.ts +36 -0
  225. package/dist/lib/execution/pipeline.d.ts.map +1 -0
  226. package/dist/lib/execution/pipeline.js +38 -0
  227. package/dist/lib/execution/pipeline.js.map +1 -0
  228. package/dist/lib/execution/retry.d.ts +38 -0
  229. package/dist/lib/execution/retry.d.ts.map +1 -0
  230. package/dist/lib/execution/retry.js +56 -0
  231. package/dist/lib/execution/retry.js.map +1 -0
  232. package/dist/lib/execution/run-with-timeout.d.ts +46 -0
  233. package/dist/lib/execution/run-with-timeout.d.ts.map +1 -0
  234. package/dist/lib/execution/run-with-timeout.js +86 -0
  235. package/dist/lib/execution/run-with-timeout.js.map +1 -0
  236. package/dist/lib/execution/schedule.d.ts +62 -0
  237. package/dist/lib/execution/schedule.d.ts.map +1 -0
  238. package/dist/lib/execution/schedule.js +130 -0
  239. package/dist/lib/execution/schedule.js.map +1 -0
  240. package/dist/lib/format.d.ts +17 -0
  241. package/dist/lib/format.d.ts.map +1 -0
  242. package/dist/lib/format.js +26 -0
  243. package/dist/lib/format.js.map +1 -0
  244. package/dist/lib/ids.d.ts +13 -0
  245. package/dist/lib/ids.d.ts.map +1 -0
  246. package/dist/lib/ids.js +48 -0
  247. package/dist/lib/ids.js.map +1 -0
  248. package/dist/lib/logger.d.ts +166 -0
  249. package/dist/lib/logger.d.ts.map +1 -0
  250. package/dist/lib/logger.js +283 -0
  251. package/dist/lib/logger.js.map +1 -0
  252. package/dist/lib/package-version.d.ts +17 -0
  253. package/dist/lib/package-version.d.ts.map +1 -0
  254. package/dist/lib/package-version.js +52 -0
  255. package/dist/lib/package-version.js.map +1 -0
  256. package/dist/lib/paths.d.ts +139 -0
  257. package/dist/lib/paths.d.ts.map +1 -0
  258. package/dist/lib/paths.js +105 -0
  259. package/dist/lib/paths.js.map +1 -0
  260. package/dist/lib/payload-version.d.ts +15 -0
  261. package/dist/lib/payload-version.d.ts.map +1 -0
  262. package/dist/lib/payload-version.js +24 -0
  263. package/dist/lib/payload-version.js.map +1 -0
  264. package/dist/lib/phantom-detect.d.ts +21 -0
  265. package/dist/lib/phantom-detect.d.ts.map +1 -0
  266. package/dist/lib/phantom-detect.js +76 -0
  267. package/dist/lib/phantom-detect.js.map +1 -0
  268. package/dist/lib/project-context.d.ts +66 -0
  269. package/dist/lib/project-context.d.ts.map +1 -0
  270. package/dist/lib/project-context.js +112 -0
  271. package/dist/lib/project-context.js.map +1 -0
  272. package/dist/lib/recipe-id.d.ts +13 -0
  273. package/dist/lib/recipe-id.d.ts.map +1 -0
  274. package/dist/lib/recipe-id.js +15 -0
  275. package/dist/lib/recipe-id.js.map +1 -0
  276. package/dist/lib/registry.d.ts +98 -0
  277. package/dist/lib/registry.d.ts.map +1 -0
  278. package/dist/lib/registry.js +152 -0
  279. package/dist/lib/registry.js.map +1 -0
  280. package/dist/lib/retry.d.ts +26 -0
  281. package/dist/lib/retry.d.ts.map +1 -0
  282. package/dist/lib/retry.js +48 -0
  283. package/dist/lib/retry.js.map +1 -0
  284. package/dist/lib/run-diagnostics.d.ts +64 -0
  285. package/dist/lib/run-diagnostics.d.ts.map +1 -0
  286. package/dist/lib/run-diagnostics.js +25 -0
  287. package/dist/lib/run-diagnostics.js.map +1 -0
  288. package/dist/lib/run-scope.d.ts +167 -0
  289. package/dist/lib/run-scope.d.ts.map +1 -0
  290. package/dist/lib/run-scope.js +176 -0
  291. package/dist/lib/run-scope.js.map +1 -0
  292. package/dist/lib/run-timer.d.ts +82 -0
  293. package/dist/lib/run-timer.d.ts.map +1 -0
  294. package/dist/lib/run-timer.js +79 -0
  295. package/dist/lib/run-timer.js.map +1 -0
  296. package/dist/lib/scope-types.d.ts +172 -0
  297. package/dist/lib/scope-types.d.ts.map +1 -0
  298. package/dist/lib/scope-types.js +27 -0
  299. package/dist/lib/scope-types.js.map +1 -0
  300. package/dist/lib/severity-policy.d.ts +38 -0
  301. package/dist/lib/severity-policy.d.ts.map +1 -0
  302. package/dist/lib/severity-policy.js +44 -0
  303. package/dist/lib/severity-policy.js.map +1 -0
  304. package/dist/lib/telemetry.d.ts +93 -0
  305. package/dist/lib/telemetry.d.ts.map +1 -0
  306. package/dist/lib/telemetry.js +144 -0
  307. package/dist/lib/telemetry.js.map +1 -0
  308. package/dist/lib/ui-context.d.ts +34 -0
  309. package/dist/lib/ui-context.d.ts.map +1 -0
  310. package/dist/lib/ui-context.js +16 -0
  311. package/dist/lib/ui-context.js.map +1 -0
  312. package/dist/lib/verdict-policy.d.ts +71 -0
  313. package/dist/lib/verdict-policy.d.ts.map +1 -0
  314. package/dist/lib/verdict-policy.js +82 -0
  315. package/dist/lib/verdict-policy.js.map +1 -0
  316. package/dist/lib/yaml.d.ts +74 -0
  317. package/dist/lib/yaml.d.ts.map +1 -0
  318. package/dist/lib/yaml.js +118 -0
  319. package/dist/lib/yaml.js.map +1 -0
  320. package/dist/plugins/__tests__/as-if-external.test.d.ts +18 -0
  321. package/dist/plugins/__tests__/as-if-external.test.d.ts.map +1 -0
  322. package/dist/plugins/__tests__/as-if-external.test.js +159 -0
  323. package/dist/plugins/__tests__/as-if-external.test.js.map +1 -0
  324. package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts +8 -0
  325. package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts.map +1 -0
  326. package/dist/plugins/__tests__/authored-tool-discovery.test.js +97 -0
  327. package/dist/plugins/__tests__/authored-tool-discovery.test.js.map +1 -0
  328. package/dist/plugins/__tests__/capability-discovery.test.d.ts +2 -0
  329. package/dist/plugins/__tests__/capability-discovery.test.d.ts.map +1 -0
  330. package/dist/plugins/__tests__/capability-discovery.test.js +349 -0
  331. package/dist/plugins/__tests__/capability-discovery.test.js.map +1 -0
  332. package/dist/plugins/__tests__/capability-from-manifest.test.d.ts +2 -0
  333. package/dist/plugins/__tests__/capability-from-manifest.test.d.ts.map +1 -0
  334. package/dist/plugins/__tests__/capability-from-manifest.test.js +172 -0
  335. package/dist/plugins/__tests__/capability-from-manifest.test.js.map +1 -0
  336. package/dist/plugins/__tests__/capability-loader.test.d.ts +2 -0
  337. package/dist/plugins/__tests__/capability-loader.test.d.ts.map +1 -0
  338. package/dist/plugins/__tests__/capability-loader.test.js +122 -0
  339. package/dist/plugins/__tests__/capability-loader.test.js.map +1 -0
  340. package/dist/plugins/__tests__/capability-registry.test.d.ts +2 -0
  341. package/dist/plugins/__tests__/capability-registry.test.d.ts.map +1 -0
  342. package/dist/plugins/__tests__/capability-registry.test.js +185 -0
  343. package/dist/plugins/__tests__/capability-registry.test.js.map +1 -0
  344. package/dist/plugins/__tests__/discover.test.d.ts +2 -0
  345. package/dist/plugins/__tests__/discover.test.d.ts.map +1 -0
  346. package/dist/plugins/__tests__/discover.test.js +311 -0
  347. package/dist/plugins/__tests__/discover.test.js.map +1 -0
  348. package/dist/plugins/__tests__/loader.test.d.ts +2 -0
  349. package/dist/plugins/__tests__/loader.test.d.ts.map +1 -0
  350. package/dist/plugins/__tests__/loader.test.js +191 -0
  351. package/dist/plugins/__tests__/loader.test.js.map +1 -0
  352. package/dist/plugins/__tests__/manifest-discovery.test.d.ts +2 -0
  353. package/dist/plugins/__tests__/manifest-discovery.test.d.ts.map +1 -0
  354. package/dist/plugins/__tests__/manifest-discovery.test.js +132 -0
  355. package/dist/plugins/__tests__/manifest-discovery.test.js.map +1 -0
  356. package/dist/plugins/__tests__/manifest-loader.test.d.ts +2 -0
  357. package/dist/plugins/__tests__/manifest-loader.test.d.ts.map +1 -0
  358. package/dist/plugins/__tests__/manifest-loader.test.js +434 -0
  359. package/dist/plugins/__tests__/manifest-loader.test.js.map +1 -0
  360. package/dist/plugins/__tests__/marker-discovery.test.d.ts +2 -0
  361. package/dist/plugins/__tests__/marker-discovery.test.d.ts.map +1 -0
  362. package/dist/plugins/__tests__/marker-discovery.test.js +164 -0
  363. package/dist/plugins/__tests__/marker-discovery.test.js.map +1 -0
  364. package/dist/plugins/__tests__/node-modules-walk.test.d.ts +2 -0
  365. package/dist/plugins/__tests__/node-modules-walk.test.d.ts.map +1 -0
  366. package/dist/plugins/__tests__/node-modules-walk.test.js +76 -0
  367. package/dist/plugins/__tests__/node-modules-walk.test.js.map +1 -0
  368. package/dist/plugins/__tests__/package-entry.test.d.ts +9 -0
  369. package/dist/plugins/__tests__/package-entry.test.d.ts.map +1 -0
  370. package/dist/plugins/__tests__/package-entry.test.js +117 -0
  371. package/dist/plugins/__tests__/package-entry.test.js.map +1 -0
  372. package/dist/plugins/__tests__/recipe-loader.test.d.ts +2 -0
  373. package/dist/plugins/__tests__/recipe-loader.test.d.ts.map +1 -0
  374. package/dist/plugins/__tests__/recipe-loader.test.js +130 -0
  375. package/dist/plugins/__tests__/recipe-loader.test.js.map +1 -0
  376. package/dist/plugins/__tests__/scope-validation.test.d.ts +2 -0
  377. package/dist/plugins/__tests__/scope-validation.test.d.ts.map +1 -0
  378. package/dist/plugins/__tests__/scope-validation.test.js +68 -0
  379. package/dist/plugins/__tests__/scope-validation.test.js.map +1 -0
  380. package/dist/plugins/__tests__/single-core-guard.test.d.ts +10 -0
  381. package/dist/plugins/__tests__/single-core-guard.test.d.ts.map +1 -0
  382. package/dist/plugins/__tests__/single-core-guard.test.js +89 -0
  383. package/dist/plugins/__tests__/single-core-guard.test.js.map +1 -0
  384. package/dist/plugins/__tests__/tool-package-discovery.test.d.ts +2 -0
  385. package/dist/plugins/__tests__/tool-package-discovery.test.d.ts.map +1 -0
  386. package/dist/plugins/__tests__/tool-package-discovery.test.js +215 -0
  387. package/dist/plugins/__tests__/tool-package-discovery.test.js.map +1 -0
  388. package/dist/plugins/authored-tool-discovery.d.ts +45 -0
  389. package/dist/plugins/authored-tool-discovery.d.ts.map +1 -0
  390. package/dist/plugins/authored-tool-discovery.js +61 -0
  391. package/dist/plugins/authored-tool-discovery.js.map +1 -0
  392. package/dist/plugins/capability-discovery.d.ts +80 -0
  393. package/dist/plugins/capability-discovery.d.ts.map +1 -0
  394. package/dist/plugins/capability-discovery.js +278 -0
  395. package/dist/plugins/capability-discovery.js.map +1 -0
  396. package/dist/plugins/capability-loader.d.ts +50 -0
  397. package/dist/plugins/capability-loader.d.ts.map +1 -0
  398. package/dist/plugins/capability-loader.js +85 -0
  399. package/dist/plugins/capability-loader.js.map +1 -0
  400. package/dist/plugins/capability-registry.d.ts +169 -0
  401. package/dist/plugins/capability-registry.d.ts.map +1 -0
  402. package/dist/plugins/capability-registry.js +319 -0
  403. package/dist/plugins/capability-registry.js.map +1 -0
  404. package/dist/plugins/discover.d.ts +64 -0
  405. package/dist/plugins/discover.d.ts.map +1 -0
  406. package/dist/plugins/discover.js +303 -0
  407. package/dist/plugins/discover.js.map +1 -0
  408. package/dist/plugins/index.d.ts +37 -0
  409. package/dist/plugins/index.d.ts.map +1 -0
  410. package/dist/plugins/index.js +40 -0
  411. package/dist/plugins/index.js.map +1 -0
  412. package/dist/plugins/json-guards.d.ts +11 -0
  413. package/dist/plugins/json-guards.d.ts.map +1 -0
  414. package/dist/plugins/json-guards.js +15 -0
  415. package/dist/plugins/json-guards.js.map +1 -0
  416. package/dist/plugins/loader.d.ts +67 -0
  417. package/dist/plugins/loader.d.ts.map +1 -0
  418. package/dist/plugins/loader.js +137 -0
  419. package/dist/plugins/loader.js.map +1 -0
  420. package/dist/plugins/manifest-discovery.d.ts +28 -0
  421. package/dist/plugins/manifest-discovery.d.ts.map +1 -0
  422. package/dist/plugins/manifest-discovery.js +103 -0
  423. package/dist/plugins/manifest-discovery.js.map +1 -0
  424. package/dist/plugins/manifest-loader.d.ts +120 -0
  425. package/dist/plugins/manifest-loader.d.ts.map +1 -0
  426. package/dist/plugins/manifest-loader.js +410 -0
  427. package/dist/plugins/manifest-loader.js.map +1 -0
  428. package/dist/plugins/marker-discovery.d.ts +115 -0
  429. package/dist/plugins/marker-discovery.d.ts.map +1 -0
  430. package/dist/plugins/marker-discovery.js +172 -0
  431. package/dist/plugins/marker-discovery.js.map +1 -0
  432. package/dist/plugins/node-modules-walk.d.ts +61 -0
  433. package/dist/plugins/node-modules-walk.d.ts.map +1 -0
  434. package/dist/plugins/node-modules-walk.js +99 -0
  435. package/dist/plugins/node-modules-walk.js.map +1 -0
  436. package/dist/plugins/package-entry.d.ts +38 -0
  437. package/dist/plugins/package-entry.d.ts.map +1 -0
  438. package/dist/plugins/package-entry.js +86 -0
  439. package/dist/plugins/package-entry.js.map +1 -0
  440. package/dist/plugins/recipe-loader.d.ts +63 -0
  441. package/dist/plugins/recipe-loader.d.ts.map +1 -0
  442. package/dist/plugins/recipe-loader.js +67 -0
  443. package/dist/plugins/recipe-loader.js.map +1 -0
  444. package/dist/plugins/scope-validation.d.ts +35 -0
  445. package/dist/plugins/scope-validation.d.ts.map +1 -0
  446. package/dist/plugins/scope-validation.js +55 -0
  447. package/dist/plugins/scope-validation.js.map +1 -0
  448. package/dist/plugins/single-core-guard.d.ts +28 -0
  449. package/dist/plugins/single-core-guard.d.ts.map +1 -0
  450. package/dist/plugins/single-core-guard.js +69 -0
  451. package/dist/plugins/single-core-guard.js.map +1 -0
  452. package/dist/plugins/tool-package-discovery.d.ts +93 -0
  453. package/dist/plugins/tool-package-discovery.d.ts.map +1 -0
  454. package/dist/plugins/tool-package-discovery.js +118 -0
  455. package/dist/plugins/tool-package-discovery.js.map +1 -0
  456. package/dist/plugins/types.d.ts +78 -0
  457. package/dist/plugins/types.d.ts.map +1 -0
  458. package/dist/plugins/types.js +15 -0
  459. package/dist/plugins/types.js.map +1 -0
  460. package/dist/recipes/__tests__/registry.test.d.ts +2 -0
  461. package/dist/recipes/__tests__/registry.test.d.ts.map +1 -0
  462. package/dist/recipes/__tests__/registry.test.js +170 -0
  463. package/dist/recipes/__tests__/registry.test.js.map +1 -0
  464. package/dist/recipes/__tests__/selector.test.d.ts +20 -0
  465. package/dist/recipes/__tests__/selector.test.d.ts.map +1 -0
  466. package/dist/recipes/__tests__/selector.test.js +173 -0
  467. package/dist/recipes/__tests__/selector.test.js.map +1 -0
  468. package/dist/recipes/__tests__/unit-config.test.d.ts +7 -0
  469. package/dist/recipes/__tests__/unit-config.test.d.ts.map +1 -0
  470. package/dist/recipes/__tests__/unit-config.test.js +52 -0
  471. package/dist/recipes/__tests__/unit-config.test.js.map +1 -0
  472. package/dist/recipes/registry.d.ts +105 -0
  473. package/dist/recipes/registry.d.ts.map +1 -0
  474. package/dist/recipes/registry.js +141 -0
  475. package/dist/recipes/registry.js.map +1 -0
  476. package/dist/recipes/selector.d.ts +112 -0
  477. package/dist/recipes/selector.d.ts.map +1 -0
  478. package/dist/recipes/selector.js +134 -0
  479. package/dist/recipes/selector.js.map +1 -0
  480. package/dist/recipes/unit-config.d.ts +63 -0
  481. package/dist/recipes/unit-config.d.ts.map +1 -0
  482. package/dist/recipes/unit-config.js +68 -0
  483. package/dist/recipes/unit-config.js.map +1 -0
  484. package/dist/runtime/__tests__/in-process-transport.test.d.ts +6 -0
  485. package/dist/runtime/__tests__/in-process-transport.test.d.ts.map +1 -0
  486. package/dist/runtime/__tests__/in-process-transport.test.js +73 -0
  487. package/dist/runtime/__tests__/in-process-transport.test.js.map +1 -0
  488. package/dist/runtime/__tests__/subprocess-transport.test.d.ts +11 -0
  489. package/dist/runtime/__tests__/subprocess-transport.test.d.ts.map +1 -0
  490. package/dist/runtime/__tests__/subprocess-transport.test.js +118 -0
  491. package/dist/runtime/__tests__/subprocess-transport.test.js.map +1 -0
  492. package/dist/runtime/in-process-transport.d.ts +20 -0
  493. package/dist/runtime/in-process-transport.d.ts.map +1 -0
  494. package/dist/runtime/in-process-transport.js +49 -0
  495. package/dist/runtime/in-process-transport.js.map +1 -0
  496. package/dist/runtime/progress-transport.d.ts +73 -0
  497. package/dist/runtime/progress-transport.d.ts.map +1 -0
  498. package/dist/runtime/progress-transport.js +17 -0
  499. package/dist/runtime/progress-transport.js.map +1 -0
  500. package/dist/runtime/subprocess-transport.d.ts +43 -0
  501. package/dist/runtime/subprocess-transport.d.ts.map +1 -0
  502. package/dist/runtime/subprocess-transport.js +134 -0
  503. package/dist/runtime/subprocess-transport.js.map +1 -0
  504. package/dist/signals/comment-openers.d.ts +29 -0
  505. package/dist/signals/comment-openers.d.ts.map +1 -0
  506. package/dist/signals/comment-openers.js +41 -0
  507. package/dist/signals/comment-openers.js.map +1 -0
  508. package/dist/signals/comment-openers.test.d.ts +7 -0
  509. package/dist/signals/comment-openers.test.d.ts.map +1 -0
  510. package/dist/signals/comment-openers.test.js +41 -0
  511. package/dist/signals/comment-openers.test.js.map +1 -0
  512. package/dist/signals/create-signal-from-violation.d.ts +29 -0
  513. package/dist/signals/create-signal-from-violation.d.ts.map +1 -0
  514. package/dist/signals/create-signal-from-violation.js +29 -0
  515. package/dist/signals/create-signal-from-violation.js.map +1 -0
  516. package/dist/signals/signal-sink.d.ts +49 -0
  517. package/dist/signals/signal-sink.d.ts.map +1 -0
  518. package/dist/signals/signal-sink.js +6 -0
  519. package/dist/signals/signal-sink.js.map +1 -0
  520. package/dist/signals/suppress.d.ts +102 -0
  521. package/dist/signals/suppress.d.ts.map +1 -0
  522. package/dist/signals/suppress.js +325 -0
  523. package/dist/signals/suppress.js.map +1 -0
  524. package/dist/signals/suppress.test.d.ts +2 -0
  525. package/dist/signals/suppress.test.d.ts.map +1 -0
  526. package/dist/signals/suppress.test.js +213 -0
  527. package/dist/signals/suppress.test.js.map +1 -0
  528. package/dist/tools/__tests__/command-spec.test.d.ts +2 -0
  529. package/dist/tools/__tests__/command-spec.test.d.ts.map +1 -0
  530. package/dist/tools/__tests__/command-spec.test.js +191 -0
  531. package/dist/tools/__tests__/command-spec.test.js.map +1 -0
  532. package/dist/tools/__tests__/compatibility.test.d.ts +5 -0
  533. package/dist/tools/__tests__/compatibility.test.d.ts.map +1 -0
  534. package/dist/tools/__tests__/compatibility.test.js +41 -0
  535. package/dist/tools/__tests__/compatibility.test.js.map +1 -0
  536. package/dist/tools/__tests__/ids.test.d.ts +5 -0
  537. package/dist/tools/__tests__/ids.test.d.ts.map +1 -0
  538. package/dist/tools/__tests__/ids.test.js +56 -0
  539. package/dist/tools/__tests__/ids.test.js.map +1 -0
  540. package/dist/tools/__tests__/manifest-assert.test.d.ts +5 -0
  541. package/dist/tools/__tests__/manifest-assert.test.d.ts.map +1 -0
  542. package/dist/tools/__tests__/manifest-assert.test.js +66 -0
  543. package/dist/tools/__tests__/manifest-assert.test.js.map +1 -0
  544. package/dist/tools/__tests__/registry.test.d.ts +2 -0
  545. package/dist/tools/__tests__/registry.test.d.ts.map +1 -0
  546. package/dist/tools/__tests__/registry.test.js +93 -0
  547. package/dist/tools/__tests__/registry.test.js.map +1 -0
  548. package/dist/tools/__tests__/types.test.d.ts +2 -0
  549. package/dist/tools/__tests__/types.test.d.ts.map +1 -0
  550. package/dist/tools/__tests__/types.test.js +51 -0
  551. package/dist/tools/__tests__/types.test.js.map +1 -0
  552. package/dist/tools/capability.d.ts +257 -0
  553. package/dist/tools/capability.d.ts.map +1 -0
  554. package/dist/tools/capability.js +46 -0
  555. package/dist/tools/capability.js.map +1 -0
  556. package/dist/tools/command-spec.d.ts +211 -0
  557. package/dist/tools/command-spec.d.ts.map +1 -0
  558. package/dist/tools/command-spec.js +110 -0
  559. package/dist/tools/command-spec.js.map +1 -0
  560. package/dist/tools/compatibility.d.ts +45 -0
  561. package/dist/tools/compatibility.d.ts.map +1 -0
  562. package/dist/tools/compatibility.js +49 -0
  563. package/dist/tools/compatibility.js.map +1 -0
  564. package/dist/tools/ids.d.ts +61 -0
  565. package/dist/tools/ids.d.ts.map +1 -0
  566. package/dist/tools/ids.js +61 -0
  567. package/dist/tools/ids.js.map +1 -0
  568. package/dist/tools/index.d.ts +22 -0
  569. package/dist/tools/index.d.ts.map +1 -0
  570. package/dist/tools/index.js +28 -0
  571. package/dist/tools/index.js.map +1 -0
  572. package/dist/tools/manifest-assert.d.ts +35 -0
  573. package/dist/tools/manifest-assert.d.ts.map +1 -0
  574. package/dist/tools/manifest-assert.js +67 -0
  575. package/dist/tools/manifest-assert.js.map +1 -0
  576. package/dist/tools/manifest.d.ts +178 -0
  577. package/dist/tools/manifest.d.ts.map +1 -0
  578. package/dist/tools/manifest.js +35 -0
  579. package/dist/tools/manifest.js.map +1 -0
  580. package/dist/tools/registry.d.ts +37 -0
  581. package/dist/tools/registry.d.ts.map +1 -0
  582. package/dist/tools/registry.js +49 -0
  583. package/dist/tools/registry.js.map +1 -0
  584. package/dist/tools/types.d.ts +1021 -0
  585. package/dist/tools/types.d.ts.map +1 -0
  586. package/dist/tools/types.js +77 -0
  587. package/dist/tools/types.js.map +1 -0
  588. package/dist/types/__tests__/signal.test.d.ts +2 -0
  589. package/dist/types/__tests__/signal.test.d.ts.map +1 -0
  590. package/dist/types/__tests__/signal.test.js +111 -0
  591. package/dist/types/__tests__/signal.test.js.map +1 -0
  592. package/dist/types/index.d.ts +5 -0
  593. package/dist/types/index.d.ts.map +1 -0
  594. package/dist/types/index.js +3 -0
  595. package/dist/types/index.js.map +1 -0
  596. package/dist/types/signal-batch.d.ts +56 -0
  597. package/dist/types/signal-batch.d.ts.map +1 -0
  598. package/dist/types/signal-batch.js +54 -0
  599. package/dist/types/signal-batch.js.map +1 -0
  600. package/dist/types/signal.d.ts +77 -0
  601. package/dist/types/signal.d.ts.map +1 -0
  602. package/dist/types/signal.js +42 -0
  603. package/dist/types/signal.js.map +1 -0
  604. package/package.json +57 -0
@@ -0,0 +1,283 @@
1
+ // @fitness-ignore-file error-handling-quality -- this module IS the logger; its own write/prune failures cannot be reported via itself without infinite recursion. Best-effort swallow is the documented contract on lines 273/281/297/302.
2
+ // @fitness-ignore-file interface-implementation-consistency -- LoggerImpl deliberately exposes configuration methods (applyOptions/setSilent/setDebugMode/setRunId/getRunId/setRunIdProvider/initLogFile) that are not on the public `Logger` interface. The interface is the narrow log-emission seam used by call sites; the impl's wider surface is the bootstrap/test configuration surface (see JSDoc on LoggerImpl).
3
+ /**
4
+ * Structured logger for opensip-cli.
5
+ *
6
+ * Outputs JSON log lines with:
7
+ * - ts: ISO timestamp
8
+ * - level: debug | info | warn | error
9
+ * - evt: event name (e.g., 'cli.start', 'cli.check.complete')
10
+ * - runId: correlation ID for the current CLI invocation
11
+ * - msg: human-readable message
12
+ * - ...data: additional structured fields
13
+ *
14
+ * Destinations:
15
+ * - File: <project>/opensip-cli/.runtime/logs/{YYYY-MM-DD}.jsonl
16
+ * The CLI bootstrap supplies this path via configureLogger({ logDir }).
17
+ * Without that, file output is disabled — user-global state
18
+ * (`~/.opensip-cli/`) is reserved for config.yml only.
19
+ * - stderr: when debug mode is enabled (Ink renders to stdout, logs to stderr)
20
+ *
21
+ * The `silent: true` option only suppresses stderr output, NOT file output.
22
+ *
23
+ * Two access patterns:
24
+ *
25
+ * 1. The exported `logger` singleton + `configureLogger(opts)`. Used
26
+ * by the CLI bootstrap and any production caller that wants the
27
+ * process-wide configuration. The four prior free mutators
28
+ * (`setSilent`, `setDebugMode`, `setRunId`, `initLogFile`) were
29
+ * collapsed into `configureLogger` in T1 deferred Item C.
30
+ *
31
+ * 2. The exported `LoggerImpl` class. Used by tests (or tools that
32
+ * need an isolated logger) to construct a fresh instance whose
33
+ * state is independent of the singleton.
34
+ */
35
+ import { appendFileSync, mkdirSync, readdirSync, unlinkSync } from 'node:fs';
36
+ import { join } from 'node:path';
37
+ const LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
38
+ const MAX_LOG_AGE_DAYS = 7;
39
+ /** Concrete logger writing JSONL to stderr and an optional daily file. */
40
+ export class LoggerImpl {
41
+ currentLevel;
42
+ silent = false;
43
+ debugMode = false;
44
+ runId;
45
+ logFilePath;
46
+ runIdProvider;
47
+ constructor(opts = {}) {
48
+ this.currentLevel = opts.level ?? 'warn';
49
+ this.applyOptions(opts);
50
+ }
51
+ /**
52
+ * Apply a `LoggerOptions` bag to this instance. Used by the singleton
53
+ * via `configureLogger(opts)` — the bootstrap-time configuration seam
54
+ * that collapsed the four prior free mutators into one shot. Each
55
+ * field is independent: an `applyOptions({ silent: true })` leaves
56
+ * `debugMode` and `runId` alone.
57
+ */
58
+ applyOptions(opts) {
59
+ if (opts.level !== undefined)
60
+ this.currentLevel = opts.level;
61
+ if (opts.silent !== undefined)
62
+ this.silent = opts.silent;
63
+ if (opts.debugMode !== undefined) {
64
+ this.debugMode = opts.debugMode;
65
+ if (opts.debugMode)
66
+ this.currentLevel = 'debug';
67
+ }
68
+ if (opts.runId !== undefined)
69
+ this.runId = opts.runId;
70
+ if (opts.logDir !== undefined)
71
+ this.initLogFile(opts.logDir);
72
+ }
73
+ debug(msgOrObj, data) {
74
+ this.log('debug', msgOrObj, data);
75
+ }
76
+ info(msgOrObj, data) {
77
+ this.log('info', msgOrObj, data);
78
+ }
79
+ warn(msgOrObj, data) {
80
+ this.log('warn', msgOrObj, data);
81
+ }
82
+ error(msgOrObj, data) {
83
+ this.log('error', msgOrObj, data);
84
+ }
85
+ /**
86
+ * Suppress stderr output. File output still occurs. Used by the CLI
87
+ * to silence the logger during Ink renders (Ink owns stdout; stderr
88
+ * is reserved for `--debug` traces). Tests use this on fresh
89
+ * `new LoggerImpl()` instances to verify the silent-mode contract.
90
+ */
91
+ setSilent(value) {
92
+ this.silent = value;
93
+ }
94
+ /**
95
+ * Enable debug-level output to stderr. Sets the current level to
96
+ * `'debug'` when enabled. Disabling does NOT restore a prior level.
97
+ */
98
+ setDebugMode(value) {
99
+ this.debugMode = value;
100
+ if (value)
101
+ this.currentLevel = 'debug';
102
+ }
103
+ /** Set the correlation id stamped on each log entry. */
104
+ setRunId(id) {
105
+ this.runId = id;
106
+ }
107
+ getRunId() {
108
+ return this.runId;
109
+ }
110
+ /**
111
+ * Inject a runId source consulted on every `log()`. Lets the kernel
112
+ * route the singleton through the RunScope-bound runId without the
113
+ * logger module having to import run-scope.ts (which would create a
114
+ * cycle, since run-scope already imports the logger).
115
+ */
116
+ setRunIdProvider(provider) {
117
+ this.runIdProvider = provider;
118
+ }
119
+ /**
120
+ * Initialize the log file for this instance.
121
+ *
122
+ * Writes to `<dir>/<YYYY-MM-DD>.jsonl`; the CLI bootstrap supplies
123
+ * the path from `resolveProjectPaths(cwd).logsDir`. Without a call
124
+ * to this function, file output is disabled (logs still hit stderr
125
+ * in debug mode).
126
+ *
127
+ * Prunes log files older than 7 days inside the chosen directory.
128
+ *
129
+ * @internal — production callers route through `configureLogger`'s
130
+ * `logDir` option. The method is `private` from a domain-design
131
+ * standpoint but TypeScript can't mark it `private` because the
132
+ * constructor calls it via `applyOptions`.
133
+ */
134
+ initLogFile(dir) {
135
+ try {
136
+ mkdirSync(dir, { recursive: true });
137
+ // Partition by the UTC calendar date (toISOString is always UTC).
138
+ // This makes log file names stable and sortable across timezones.
139
+ // pruneOldLogs respects the same UTC-bucket convention for retention.
140
+ const today = new Date().toISOString().slice(0, 10);
141
+ this.logFilePath = join(dir, `${today}.jsonl`);
142
+ pruneOldLogs(dir);
143
+ }
144
+ catch {
145
+ // Best effort — don't crash if we can't create the log directory
146
+ this.logFilePath = undefined;
147
+ }
148
+ }
149
+ shouldLog(level) {
150
+ return LEVELS[level] >= LEVELS[this.currentLevel];
151
+ }
152
+ shouldWriteToFile(level) {
153
+ // Always write info+ to the log file regardless of silent mode.
154
+ // Silent mode suppresses stderr output (for Ink rendering), not file output.
155
+ // In debug mode, write everything (including debug) to file.
156
+ if (this.debugMode)
157
+ return true;
158
+ return LEVELS[level] >= LEVELS.info;
159
+ }
160
+ log(level, msgOrObj, data) {
161
+ if (!this.shouldLog(level) && !this.logFilePath)
162
+ return;
163
+ // RunScope-bound runId wins over the instance-level field.
164
+ // Production callers always go through the singleton inside a
165
+ // `runWithScope`/`enterScope` block; the kernel binds a
166
+ // `runIdProvider` at module init that reads `currentScope()?.runId`
167
+ // (Item 2 — runId moved off the singleton onto RunScope as a flat
168
+ // kernel field). Tests that construct an isolated `new LoggerImpl()`
169
+ // outside any scope still get instance-level runId via the fallback.
170
+ const scopedRunId = this.runIdProvider?.();
171
+ const effectiveRunId = scopedRunId !== undefined && scopedRunId !== '' ? scopedRunId : this.runId;
172
+ const entry = formatEntry(level, msgOrObj, data, effectiveRunId);
173
+ if (this.shouldWriteToFile(level)) {
174
+ writeToFile(this.logFilePath, entry);
175
+ }
176
+ // Write to stderr only when debugMode is on. setSilent(true) is called
177
+ // during preAction so Ink owns stdout; stderr is reserved for --debug.
178
+ if (this.shouldLog(level) && this.debugMode && !this.silent) {
179
+ writeToStderr(entry);
180
+ }
181
+ }
182
+ }
183
+ function formatEntry(level, msgOrObj, data, runId) {
184
+ const entry = {
185
+ ts: new Date().toISOString(),
186
+ level,
187
+ };
188
+ if (runId)
189
+ entry.runId = runId;
190
+ if (typeof msgOrObj === 'string') {
191
+ entry.msg = msgOrObj;
192
+ }
193
+ else {
194
+ Object.assign(entry, msgOrObj);
195
+ }
196
+ if (data)
197
+ Object.assign(entry, data);
198
+ return entry;
199
+ }
200
+ function writeToFile(logFilePath, entry) {
201
+ if (!logFilePath)
202
+ return;
203
+ try {
204
+ appendFileSync(logFilePath, JSON.stringify(entry) + '\n');
205
+ }
206
+ catch {
207
+ // Best effort — don't crash the CLI if logging fails
208
+ }
209
+ }
210
+ function writeToStderr(entry) {
211
+ try {
212
+ process.stderr.write(JSON.stringify(entry) + '\n');
213
+ }
214
+ catch {
215
+ // Best effort
216
+ }
217
+ }
218
+ function pruneOldLogs(dir) {
219
+ try {
220
+ // Retention is based on the UTC calendar date embedded in the filename
221
+ // (which is produced by toISOString().slice(0,10) at creation time).
222
+ // Compute a cutoff as "N full UTC days before now" to avoid engine-
223
+ // dependent interpretation of bare "YYYY-MM-DD" strings and TZ skew.
224
+ const cutoff = Date.now() - MAX_LOG_AGE_DAYS * 24 * 60 * 60 * 1000;
225
+ const files = readdirSync(dir);
226
+ for (const file of files) {
227
+ if (!file.endsWith('.jsonl'))
228
+ continue;
229
+ const dateStr = file.replace('.jsonl', '');
230
+ // Parse the bucket date as UTC midnight so comparisons are independent
231
+ // of local TZ and of how the JS engine treats new Date('YYYY-MM-DD').
232
+ const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateStr);
233
+ if (!m)
234
+ continue;
235
+ const [, y, mo, d] = m;
236
+ const fileUtcMs = Date.UTC(Number(y), Number(mo) - 1, Number(d));
237
+ if (fileUtcMs < cutoff) {
238
+ try {
239
+ unlinkSync(join(dir, file));
240
+ }
241
+ catch {
242
+ // Skip files we can't delete
243
+ }
244
+ }
245
+ }
246
+ }
247
+ catch {
248
+ // Best effort
249
+ }
250
+ }
251
+ // =============================================================================
252
+ // SINGLETON + COMPATIBILITY HELPERS
253
+ // =============================================================================
254
+ /**
255
+ * Process-wide logger singleton. CLI bootstrap configures it via
256
+ * `configureLogger(opts)` once at startup; production callers import
257
+ * this constant directly. Tests should construct a fresh
258
+ * `new LoggerImpl({...})` instead of mutating the singleton's state.
259
+ *
260
+ * Typed as the `Logger` interface (not the concrete class) so generic
261
+ * call sites see only the four log-level methods. Configuration
262
+ * reaches the underlying instance through `configureLogger`, which is
263
+ * the only seam — the four free mutators (`setSilent`, `setDebugMode`,
264
+ * `setRunId`, `initLogFile`) that previously existed are gone
265
+ * (T1 deferred Item C).
266
+ */
267
+ const _logger = new LoggerImpl();
268
+ export const logger = _logger;
269
+ /**
270
+ * One-shot configuration for the process-wide `logger` singleton.
271
+ * Replaces the four free mutators that previously each mutated one
272
+ * field. The CLI's pre-action-hook calls this once with all relevant
273
+ * options after flags are parsed and the project context is resolved.
274
+ *
275
+ * SaaS hosts that run multiple invocations concurrently should NOT use
276
+ * this — they construct per-invocation `new LoggerImpl({...})` and
277
+ * wire it into the `RunScope.logger` field so each run has its own
278
+ * file path and runId.
279
+ */
280
+ export function configureLogger(opts) {
281
+ _logger.applyOptions(opts);
282
+ }
283
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/lib/logger.ts"],"names":[],"mappings":"AAAA,4OAA4O;AAC5O,2ZAA2Z;AAC3Z;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAajC,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAW,CAAC;AACjE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAoD3B,0EAA0E;AAC1E,MAAM,OAAO,UAAU;IACb,YAAY,CAAW;IACvB,MAAM,GAAG,KAAK,CAAC;IACf,SAAS,GAAG,KAAK,CAAC;IAClB,KAAK,CAAqB;IAC1B,WAAW,CAAqB;IAChC,aAAa,CAA4B;IAEjD,YAAY,OAAsB,EAAE;QAClC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QACzC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;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,IAAI,CAAC,CAAC;gBAAE,SAAS;YACjB,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YACvB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,IAAI,SAAS,GAAG,MAAM,EAAE,CAAC;gBACvB,IAAI,CAAC;oBACH,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC9B,CAAC;gBAAC,MAAM,CAAC;oBACP,6BAA6B;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,oCAAoC;AACpC,gFAAgF;AAEhF;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,GAAG,IAAI,UAAU,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,MAAM,GAAW,OAAO,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Read the nearest enclosing package.json's `version` field.
3
+ *
4
+ * Pass `import.meta.url` from the calling module. The function walks
5
+ * up from that module's directory until it finds a package.json, then
6
+ * returns its `version`. This is the standard way for a Tool to set
7
+ * its `metadata.version` without duplicating the literal in source.
8
+ *
9
+ * Result is cached per `metaUrl` so subsequent calls from the same
10
+ * module are O(1).
11
+ *
12
+ * Returns `'0.0.0'` if no package.json is found or if it lacks a
13
+ * version field — Tools should treat that as "version unknown" rather
14
+ * than crash. In practice this only happens in malformed installs.
15
+ */
16
+ export declare function readPackageVersion(metaUrl: string): string;
17
+ //# sourceMappingURL=package-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../../src/lib/package-version.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA0B1D"}
@@ -0,0 +1,52 @@
1
+ // @fitness-ignore-file error-handling-quality -- upward package.json walk: a missing/unreadable package.json at any non-root level is the expected non-terminal signal to keep walking; logging would be noisy and load-bearing-incorrect.
2
+ import { readFileSync } from 'node:fs';
3
+ import { dirname, join, parse } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ /**
6
+ * Per-`metaUrl` cache. Each call site (typically a Tool's metadata
7
+ * factory) hands in a stable `import.meta.url`, so the resolved
8
+ * version is constant for the process lifetime. Memoizing avoids the
9
+ * O(depth) `package.json` walk on every call as the helper sees more
10
+ * adoption from third-party tools.
11
+ */
12
+ const versionCache = new Map();
13
+ /**
14
+ * Read the nearest enclosing package.json's `version` field.
15
+ *
16
+ * Pass `import.meta.url` from the calling module. The function walks
17
+ * up from that module's directory until it finds a package.json, then
18
+ * returns its `version`. This is the standard way for a Tool to set
19
+ * its `metadata.version` without duplicating the literal in source.
20
+ *
21
+ * Result is cached per `metaUrl` so subsequent calls from the same
22
+ * module are O(1).
23
+ *
24
+ * Returns `'0.0.0'` if no package.json is found or if it lacks a
25
+ * version field — Tools should treat that as "version unknown" rather
26
+ * than crash. In practice this only happens in malformed installs.
27
+ */
28
+ export function readPackageVersion(metaUrl) {
29
+ const cached = versionCache.get(metaUrl);
30
+ if (cached !== undefined)
31
+ return cached;
32
+ let dir = dirname(fileURLToPath(metaUrl));
33
+ const { root } = parse(dir);
34
+ while (true) {
35
+ try {
36
+ const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
37
+ if (typeof pkg.version === 'string' && pkg.version.length > 0) {
38
+ versionCache.set(metaUrl, pkg.version);
39
+ return pkg.version;
40
+ }
41
+ }
42
+ catch {
43
+ // No package.json at this level — keep walking up.
44
+ }
45
+ if (dir === root) {
46
+ versionCache.set(metaUrl, '0.0.0');
47
+ return '0.0.0';
48
+ }
49
+ dir = dirname(dir);
50
+ }
51
+ }
52
+ //# sourceMappingURL=package-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-version.js","sourceRoot":"","sources":["../../src/lib/package-version.ts"],"names":[],"mappings":"AAAA,2OAA2O;AAC3O,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IAExC,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1C,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IAE5B,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAErE,CAAC;YACF,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9D,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;gBACvC,OAAO,GAAG,CAAC,OAAO,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,mDAAmD;QACrD,CAAC;QAED,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACnC,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @fileoverview Path resolution for opensip-cli project + user state.
3
+ *
4
+ * Per-project state lives at:
5
+ *
6
+ * <project>/opensip-cli.config.yml ← TRACKED — project config
7
+ * <project>/opensip-cli/ ← TRACKED — user-authored
8
+ * fit/checks/<*.mjs> ← custom fitness checks
9
+ * fit/recipes/<*.mjs> ← custom fitness recipes
10
+ * sim/scenarios/<*.mjs> ← custom sim scenarios
11
+ * sim/recipes/<*.mjs> ← custom sim recipes
12
+ * tools/<name>/opensip-tool.manifest.json ← TRACKED authored Tool
13
+ * (whole subcommand; the
14
+ * project-local analogue of
15
+ * fit/checks + sim/scenarios —
16
+ * lives BESIDE fit/sim, NOT
17
+ * under .runtime/;
18
+ * deny-by-default)
19
+ * .runtime/ ← GITIGNORED — runtime state
20
+ * sessions/ ← run history
21
+ * reports/ ← dashboard HTML
22
+ * logs/ ← structured JSONL logs
23
+ * datastore.sqlite ← sessions, baselines, catalog
24
+ * cache/ ← AST + prewarm caches
25
+ * plugins/<fit|sim>/node_modules/ ← npm-installed plugins
26
+ *
27
+ * ~/.opensip-cli/ ← USER-LEVEL (cross-project)
28
+ * config.yml ← cloud API key, defaults
29
+ * plugins/tool/node_modules/ ← user-global Tool plugins
30
+ * (whole subcommands;
31
+ * available in every project)
32
+ * tools/<name>/opensip-tool.manifest.json ← user-global authored Tool
33
+ * (trusted-by-default authored
34
+ * sidecar; the `npm i -g`
35
+ * analogue for authored code)
36
+ *
37
+ * Every consumer (logger, persistence/store, gate, plugin loader,
38
+ * configure command, uninstall command) constructs paths through this
39
+ * resolver instead of using inline string concatenation, so a future
40
+ * change to the layout is a single-file edit.
41
+ */
42
+ import type { ToolShortId } from '../tools/ids.js';
43
+ /** Per-project paths produced by `resolveProjectPaths(projectDir)`. */
44
+ export interface ProjectPaths {
45
+ /** Absolute path to the project root (== input). */
46
+ readonly projectDir: string;
47
+ /** <project>/opensip-cli.config.yml */
48
+ readonly configFile: string;
49
+ /** <project>/opensip-cli — user-authored content root. */
50
+ readonly userSourceDir: string;
51
+ /**
52
+ * `<project>/opensip-cli/tools` — TRACKED authored Tool sidecars (the
53
+ * whole-subcommand analogue of fit/checks + sim/scenarios). Each child is
54
+ * a `<name>/opensip-tool.manifest.json` sidecar. Lives BESIDE `fit/` and
55
+ * `sim/`, NOT under `.runtime/`; deny-by-default at admission.
56
+ */
57
+ readonly authoredToolsDir: string;
58
+ /**
59
+ * `<project>/opensip-cli/<domain>/<kind>` — a tool's user-authored
60
+ * plugin source dir (e.g. `userPluginDir('fit', 'checks')`). Generic
61
+ * over (domain, kind) so the kernel carries no fit/sim vocabulary
62
+ * (ADR-0009 corollary 1); the layout's `userSubdirs` supply the kinds.
63
+ */
64
+ readonly userPluginDir: (domain: string, kind: string) => string;
65
+ /** <project>/opensip-cli/.runtime — gitignored runtime state. */
66
+ readonly runtimeDir: string;
67
+ /** <project>/opensip-cli/.runtime/sessions */
68
+ readonly sessionsDir: string;
69
+ /** <project>/opensip-cli/.runtime/reports */
70
+ readonly reportsDir: string;
71
+ /** <project>/opensip-cli/.runtime/logs */
72
+ readonly logsDir: string;
73
+ /** <project>/opensip-cli/.runtime/cache */
74
+ readonly cacheDir: string;
75
+ /** <project>/opensip-cli/.runtime/cache/graph — graph-tool catalog cache root. */
76
+ readonly graphCacheDir: string;
77
+ /** <project>/opensip-cli/.runtime/plugins/<domain> — npm-installed plugins. */
78
+ readonly pluginsDir: (domain: string) => string;
79
+ }
80
+ /**
81
+ * Path-resolver domain set for FIRST-PARTY tools — the storage/path
82
+ * discriminator (`'fit' | 'sim' | 'graph'`). Aliased to `ToolShortId`
83
+ * from the central registry (audit-round-3 Finding H) so first-party
84
+ * path/storage sites stay in sync.
85
+ *
86
+ * Note this is tool *identity*, a separate concern from plugin
87
+ * *discovery*: `pluginsDir` / `userPluginDir` take a plain `string` so
88
+ * third-party tools can host project-local plugins without being listed
89
+ * here (ADR-0009 corollary 1).
90
+ */
91
+ export type PathDomain = ToolShortId;
92
+ /** Resolve the project path layout for a given project directory. */
93
+ export declare function resolveProjectPaths(projectDir: string): ProjectPaths;
94
+ /** User-level paths in `~/.opensip-cli/`. */
95
+ export interface UserPaths {
96
+ /** ~/.opensip-cli — root for all user-level state. */
97
+ readonly userHomeDir: string;
98
+ /** ~/.opensip-cli/config.yml — cloud API key + per-user defaults. */
99
+ readonly configFile: string;
100
+ /**
101
+ * `~/.opensip-cli/plugins/<domain>` — user-global (cross-project)
102
+ * npm-installed plugins. Used today by the `tool` domain: a Tool plugin
103
+ * is a whole subcommand, so a user-global install makes it available in
104
+ * every project (like `npm i -g`), unlike fit/sim packs which are
105
+ * project-committed. Generic over domain for symmetry with
106
+ * `ProjectPaths.pluginsDir`.
107
+ */
108
+ readonly pluginsDir: (domain: string) => string;
109
+ /**
110
+ * `~/.opensip-cli/tools` — global authored Tool sidecars
111
+ * (trusted-by-default). Each child is a
112
+ * `<name>/opensip-tool.manifest.json` sidecar. The user placed it in
113
+ * their own home dir → admitted without an allowlist (the `npm i -g`
114
+ * analogue for authored code).
115
+ */
116
+ readonly authoredToolsDir: string;
117
+ /**
118
+ * ~/.opensip-cli/update-state.json — tool-generated cache of the
119
+ * last-known newer published version, so the "update available" notice can
120
+ * persist across runs instead of showing once. NOT user-authored: written
121
+ * by the update notifier, cleared automatically once the running version
122
+ * catches up. Distinct from `configFile`, which holds user-authored config.
123
+ */
124
+ readonly updateStateFile: string;
125
+ }
126
+ /** Resolve the user-level path layout. */
127
+ export declare function resolveUserPaths(): UserPaths;
128
+ /**
129
+ * Returns true iff `child`, after resolving symlinks via realpath, is the same
130
+ * path as `parent` or located inside it (native-separator prefix match after
131
+ * realpath). Returns false on any error (missing, unresolvable, permission, etc).
132
+ *
133
+ * Canonical helper for preventing path escape / symlink traversal in glob
134
+ * results, plugin discovery, targeting, etc. See also the cli-realpath-validation
135
+ * fitness check that enforces use of realpath-based containment over naive
136
+ * `.startsWith`.
137
+ */
138
+ export declare function isPathInside(child: string, parent: string): boolean;
139
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAMnD,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0DAA0D;IAC1D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACjE,iEAAiE;IACjE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CACjD;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAmBpE;AAMD,6CAA6C;AAC7C,MAAM,WAAW,SAAS;IACxB,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,0CAA0C;AAC1C,wBAAgB,gBAAgB,IAAI,SAAS,CAS5C;AAMD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAYnE"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @fileoverview Path resolution for opensip-cli project + user state.
3
+ *
4
+ * Per-project state lives at:
5
+ *
6
+ * <project>/opensip-cli.config.yml ← TRACKED — project config
7
+ * <project>/opensip-cli/ ← TRACKED — user-authored
8
+ * fit/checks/<*.mjs> ← custom fitness checks
9
+ * fit/recipes/<*.mjs> ← custom fitness recipes
10
+ * sim/scenarios/<*.mjs> ← custom sim scenarios
11
+ * sim/recipes/<*.mjs> ← custom sim recipes
12
+ * tools/<name>/opensip-tool.manifest.json ← TRACKED authored Tool
13
+ * (whole subcommand; the
14
+ * project-local analogue of
15
+ * fit/checks + sim/scenarios —
16
+ * lives BESIDE fit/sim, NOT
17
+ * under .runtime/;
18
+ * deny-by-default)
19
+ * .runtime/ ← GITIGNORED — runtime state
20
+ * sessions/ ← run history
21
+ * reports/ ← dashboard HTML
22
+ * logs/ ← structured JSONL logs
23
+ * datastore.sqlite ← sessions, baselines, catalog
24
+ * cache/ ← AST + prewarm caches
25
+ * plugins/<fit|sim>/node_modules/ ← npm-installed plugins
26
+ *
27
+ * ~/.opensip-cli/ ← USER-LEVEL (cross-project)
28
+ * config.yml ← cloud API key, defaults
29
+ * plugins/tool/node_modules/ ← user-global Tool plugins
30
+ * (whole subcommands;
31
+ * available in every project)
32
+ * tools/<name>/opensip-tool.manifest.json ← user-global authored Tool
33
+ * (trusted-by-default authored
34
+ * sidecar; the `npm i -g`
35
+ * analogue for authored code)
36
+ *
37
+ * Every consumer (logger, persistence/store, gate, plugin loader,
38
+ * configure command, uninstall command) constructs paths through this
39
+ * resolver instead of using inline string concatenation, so a future
40
+ * change to the layout is a single-file edit.
41
+ */
42
+ import { realpathSync } from 'node:fs';
43
+ import { homedir } from 'node:os';
44
+ import { join, sep } from 'node:path';
45
+ /** Resolve the project path layout for a given project directory. */
46
+ export function resolveProjectPaths(projectDir) {
47
+ const userSourceDir = join(projectDir, 'opensip-cli');
48
+ const runtimeDir = join(userSourceDir, '.runtime');
49
+ const cacheDir = join(runtimeDir, 'cache');
50
+ const graphCacheDir = join(cacheDir, 'graph');
51
+ return {
52
+ projectDir,
53
+ configFile: join(projectDir, 'opensip-cli.config.yml'),
54
+ userSourceDir,
55
+ authoredToolsDir: join(userSourceDir, 'tools'),
56
+ userPluginDir: (domain, kind) => join(userSourceDir, domain, kind),
57
+ runtimeDir,
58
+ sessionsDir: join(runtimeDir, 'sessions'),
59
+ reportsDir: join(runtimeDir, 'reports'),
60
+ logsDir: join(runtimeDir, 'logs'),
61
+ cacheDir,
62
+ graphCacheDir,
63
+ pluginsDir: (domain) => join(runtimeDir, 'plugins', domain),
64
+ };
65
+ }
66
+ /** Resolve the user-level path layout. */
67
+ export function resolveUserPaths() {
68
+ const userHomeDir = join(homedir(), '.opensip-cli');
69
+ return {
70
+ userHomeDir,
71
+ configFile: join(userHomeDir, 'config.yml'),
72
+ updateStateFile: join(userHomeDir, 'update-state.json'),
73
+ authoredToolsDir: join(userHomeDir, 'tools'),
74
+ pluginsDir: (domain) => join(userHomeDir, 'plugins', domain),
75
+ };
76
+ }
77
+ // =============================================================================
78
+ // SAFE PATH CONTAINMENT
79
+ // =============================================================================
80
+ /**
81
+ * Returns true iff `child`, after resolving symlinks via realpath, is the same
82
+ * path as `parent` or located inside it (native-separator prefix match after
83
+ * realpath). Returns false on any error (missing, unresolvable, permission, etc).
84
+ *
85
+ * Canonical helper for preventing path escape / symlink traversal in glob
86
+ * results, plugin discovery, targeting, etc. See also the cli-realpath-validation
87
+ * fitness check that enforces use of realpath-based containment over naive
88
+ * `.startsWith`.
89
+ */
90
+ export function isPathInside(child, parent) {
91
+ let realChild;
92
+ let realParent;
93
+ try {
94
+ realChild = realpathSync(child);
95
+ realParent = realpathSync(parent);
96
+ }
97
+ catch {
98
+ // @swallow-ok realpathSync throws when a path does not exist; fail closed (treat as "not inside")
99
+ return false;
100
+ }
101
+ if (realChild === realParent)
102
+ return true;
103
+ return realChild.startsWith(realParent + sep);
104
+ }
105
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AA2DtC,qEAAqE;AACrE,MAAM,UAAU,mBAAmB,CAAC,UAAkB;IACpD,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAA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FAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,MAAc;IACxD,IAAI,SAAiB,CAAC;IACtB,IAAI,UAAkB,CAAC;IACvB,IAAI,CAAC;QACH,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QAChC,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,kGAAkG;QAClG,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,SAAS,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,SAAS,CAAC,UAAU,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Extract the inner `__version` (if present and valid) from an opaque tool-owned payload.
3
+ *
4
+ * This is the single canonical helper for the payload schema evolution convention.
5
+ * It is intentionally pure, tiny, and has zero knowledge of any tool's payload shape
6
+ * (FitnessSessionPayload, GraphSessionPayload, etc.). Callers in session-store and
7
+ * the individual tools use it to decide legacy projection vs. current shape.
8
+ *
9
+ * Rules (defensive, per plan hardening):
10
+ * - Only plain objects are inspected.
11
+ * - `__version` must be a positive finite number.
12
+ * - Missing, non-numeric, <=0, Infinity, NaN → undefined (treated as legacy v1 by callers).
13
+ */
14
+ export declare function extractPayloadVersion(payload: unknown): number | undefined;
15
+ //# sourceMappingURL=payload-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload-version.d.ts","sourceRoot":"","sources":["../../src/lib/payload-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS1E"}