@dev-sergeev/datalab-kit 0.1.2 → 0.1.3

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 (332) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +23 -5
  3. package/THIRD_PARTY_NOTICES.md +6 -2
  4. package/dist/extension.js +8 -1
  5. package/dist/recap.d.ts +2 -0
  6. package/dist/recap.js +31 -0
  7. package/docs/adr/0002-package-delivery.md +2 -0
  8. package/node_modules/@pi-plugins/elapsed/LICENSE +21 -0
  9. package/node_modules/@pi-plugins/elapsed/README.md +45 -0
  10. package/node_modules/@pi-plugins/elapsed/dist/index.d.mts +8 -0
  11. package/node_modules/@pi-plugins/elapsed/dist/index.d.mts.map +1 -0
  12. package/node_modules/@pi-plugins/elapsed/dist/index.mjs +47 -0
  13. package/node_modules/@pi-plugins/elapsed/dist/index.mjs.map +1 -0
  14. package/node_modules/@pi-plugins/elapsed/package.json +65 -0
  15. package/node_modules/@tifan/pi-recap/README.md +61 -0
  16. package/node_modules/@tifan/pi-recap/package.json +43 -0
  17. package/node_modules/@tifan/pi-recap/src/index.ts +584 -0
  18. package/node_modules/@tifan/pi-recap/src/model-picker.ts +233 -0
  19. package/node_modules/@tifan/pi-recap/src/models.ts +183 -0
  20. package/node_modules/@tifan/pi-recap/src/sanitize.ts +119 -0
  21. package/node_modules/@tifan/pi-recap/src/tui.ts +155 -0
  22. package/node_modules/@zigai/pi-extension-internals/README.md +24 -0
  23. package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.d.ts +21 -0
  24. package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.js +233 -0
  25. package/node_modules/@zigai/pi-extension-internals/dist/index.d.ts +6 -0
  26. package/node_modules/@zigai/pi-extension-internals/dist/index.js +3 -0
  27. package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.d.ts +34 -0
  28. package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.js +272 -0
  29. package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.d.ts +11 -0
  30. package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.js +139 -0
  31. package/node_modules/@zigai/pi-extension-internals/package.json +41 -0
  32. package/node_modules/@zigai/pi-extension-settings/LICENSE +21 -0
  33. package/node_modules/@zigai/pi-extension-settings/README.md +36 -0
  34. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts +23 -0
  35. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts.map +1 -0
  36. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js +75 -0
  37. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js.map +1 -0
  38. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts +3 -0
  39. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts.map +1 -0
  40. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js +5 -0
  41. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js.map +1 -0
  42. package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts +6 -0
  43. package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts.map +1 -0
  44. package/node_modules/@zigai/pi-extension-settings/dist/cli.js +87 -0
  45. package/node_modules/@zigai/pi-extension-settings/dist/cli.js.map +1 -0
  46. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts +2 -0
  47. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts.map +1 -0
  48. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js +2 -0
  49. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js.map +1 -0
  50. package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts +159 -0
  51. package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts.map +1 -0
  52. package/node_modules/@zigai/pi-extension-settings/dist/definition.js +248 -0
  53. package/node_modules/@zigai/pi-extension-settings/dist/definition.js.map +1 -0
  54. package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts +10 -0
  55. package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts.map +1 -0
  56. package/node_modules/@zigai/pi-extension-settings/dist/file-system.js +115 -0
  57. package/node_modules/@zigai/pi-extension-settings/dist/file-system.js.map +1 -0
  58. package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts +2 -0
  59. package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts.map +1 -0
  60. package/node_modules/@zigai/pi-extension-settings/dist/index.js +2 -0
  61. package/node_modules/@zigai/pi-extension-settings/dist/index.js.map +1 -0
  62. package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts +18 -0
  63. package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts.map +1 -0
  64. package/node_modules/@zigai/pi-extension-settings/dist/json-value.js +56 -0
  65. package/node_modules/@zigai/pi-extension-settings/dist/json-value.js.map +1 -0
  66. package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts +11 -0
  67. package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts.map +1 -0
  68. package/node_modules/@zigai/pi-extension-settings/dist/paths.js +23 -0
  69. package/node_modules/@zigai/pi-extension-settings/dist/paths.js.map +1 -0
  70. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts +5 -0
  71. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts.map +1 -0
  72. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js +21 -0
  73. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js.map +1 -0
  74. package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts +106 -0
  75. package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts.map +1 -0
  76. package/node_modules/@zigai/pi-extension-settings/dist/pi.js +122 -0
  77. package/node_modules/@zigai/pi-extension-settings/dist/pi.js.map +1 -0
  78. package/node_modules/@zigai/pi-extension-settings/dist/pi.ts +2537 -0
  79. package/node_modules/@zigai/pi-extension-settings/dist/pi.ts.map +7 -0
  80. package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts +10 -0
  81. package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts.map +1 -0
  82. package/node_modules/@zigai/pi-extension-settings/dist/projects.js +177 -0
  83. package/node_modules/@zigai/pi-extension-settings/dist/projects.js.map +1 -0
  84. package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts +40 -0
  85. package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts.map +1 -0
  86. package/node_modules/@zigai/pi-extension-settings/dist/runtime.js +158 -0
  87. package/node_modules/@zigai/pi-extension-settings/dist/runtime.js.map +1 -0
  88. package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts +158 -0
  89. package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts.map +7 -0
  90. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts +19 -0
  91. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts.map +1 -0
  92. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js +168 -0
  93. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js.map +1 -0
  94. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts +9 -0
  95. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts.map +1 -0
  96. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js +242 -0
  97. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js.map +1 -0
  98. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts +59 -0
  99. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts.map +1 -0
  100. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js +98 -0
  101. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js.map +1 -0
  102. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts +80 -0
  103. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts.map +1 -0
  104. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js +144 -0
  105. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js.map +1 -0
  106. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts +5 -0
  107. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts.map +1 -0
  108. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js +30 -0
  109. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js.map +1 -0
  110. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts +10 -0
  111. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts.map +1 -0
  112. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js +16 -0
  113. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js.map +1 -0
  114. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts +54 -0
  115. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts.map +1 -0
  116. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js +202 -0
  117. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js.map +1 -0
  118. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts +5 -0
  119. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts.map +1 -0
  120. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js +9 -0
  121. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js.map +1 -0
  122. package/node_modules/@zigai/pi-extension-settings/docs/generation.md +71 -0
  123. package/node_modules/@zigai/pi-extension-settings/docs/manual-setup.md +98 -0
  124. package/node_modules/@zigai/pi-extension-settings/docs/runtime.md +100 -0
  125. package/node_modules/@zigai/pi-extension-settings/docs/ui-controls.md +31 -0
  126. package/node_modules/@zigai/pi-extension-settings/package.json +97 -0
  127. package/node_modules/@zigai/pi-mention-anything/README.md +113 -0
  128. package/node_modules/@zigai/pi-mention-anything/config.schema.json +313 -0
  129. package/node_modules/@zigai/pi-mention-anything/docs/command-protocol.md +106 -0
  130. package/node_modules/@zigai/pi-mention-anything/docs/providers.md +128 -0
  131. package/node_modules/@zigai/pi-mention-anything/examples/query-command.mjs +96 -0
  132. package/node_modules/@zigai/pi-mention-anything/examples/recursive-tree.ts +28 -0
  133. package/node_modules/@zigai/pi-mention-anything/examples/static.ts +28 -0
  134. package/node_modules/@zigai/pi-mention-anything/examples/tmux.ts +90 -0
  135. package/node_modules/@zigai/pi-mention-anything/examples/tree-settings.json +25 -0
  136. package/node_modules/@zigai/pi-mention-anything/package.json +58 -0
  137. package/node_modules/@zigai/pi-mention-anything/src/api.ts +75 -0
  138. package/node_modules/@zigai/pi-mention-anything/src/autocomplete.ts +231 -0
  139. package/node_modules/@zigai/pi-mention-anything/src/chain-autocomplete.ts +596 -0
  140. package/node_modules/@zigai/pi-mention-anything/src/chain-syntax.ts +345 -0
  141. package/node_modules/@zigai/pi-mention-anything/src/command-provider.ts +291 -0
  142. package/node_modules/@zigai/pi-mention-anything/src/configured-source.ts +66 -0
  143. package/node_modules/@zigai/pi-mention-anything/src/editor.ts +180 -0
  144. package/node_modules/@zigai/pi-mention-anything/src/expand-mentions.ts +162 -0
  145. package/node_modules/@zigai/pi-mention-anything/src/index.ts +54 -0
  146. package/node_modules/@zigai/pi-mention-anything/src/initial-suggestions.ts +190 -0
  147. package/node_modules/@zigai/pi-mention-anything/src/list-provider.ts +71 -0
  148. package/node_modules/@zigai/pi-mention-anything/src/mention-hub.ts +307 -0
  149. package/node_modules/@zigai/pi-mention-anything/src/mention-resolution.ts +374 -0
  150. package/node_modules/@zigai/pi-mention-anything/src/mention-syntax.ts +105 -0
  151. package/node_modules/@zigai/pi-mention-anything/src/register-mention.ts +89 -0
  152. package/node_modules/@zigai/pi-mention-anything/src/rendering.ts +53 -0
  153. package/node_modules/@zigai/pi-mention-anything/src/selected-items.ts +21 -0
  154. package/node_modules/@zigai/pi-mention-anything/src/selection-history.ts +135 -0
  155. package/node_modules/@zigai/pi-mention-anything/src/settings-input.ts +317 -0
  156. package/node_modules/@zigai/pi-mention-anything/src/settings.prevalidated.ts +57 -0
  157. package/node_modules/@zigai/pi-mention-anything/src/settings.ts +52 -0
  158. package/node_modules/@zigai/pi-mention-anything/src/source-contract.ts +174 -0
  159. package/node_modules/@zigai/pi-mention-anything/src/source-controller.ts +1070 -0
  160. package/node_modules/@zigai/pi-mention-anything/src/source-runtime.ts +99 -0
  161. package/node_modules/@zigai/pi-mention-skill/README.md +60 -0
  162. package/node_modules/@zigai/pi-mention-skill/config.schema.json +81 -0
  163. package/node_modules/@zigai/pi-mention-skill/package.json +56 -0
  164. package/node_modules/@zigai/pi-mention-skill/src/index.ts +60 -0
  165. package/node_modules/@zigai/pi-mention-skill/src/settings-input.ts +74 -0
  166. package/node_modules/@zigai/pi-mention-skill/src/settings.prevalidated.ts +18 -0
  167. package/node_modules/@zigai/pi-mention-skill/src/settings.ts +54 -0
  168. package/node_modules/@zigai/pi-mention-skill/src/skill-commands.ts +18 -0
  169. package/node_modules/@zigai/pi-mention-skill/src/skill-content.ts +60 -0
  170. package/node_modules/@zigai/pi-mention-skill/src/skill-provider.ts +105 -0
  171. package/node_modules/@zigai/pi-mention-skill/src/slash-skill-filter.ts +29 -0
  172. package/node_modules/argparse/LICENSE +21 -0
  173. package/node_modules/argparse/README.md +257 -0
  174. package/node_modules/argparse/index.js +3 -0
  175. package/node_modules/argparse/lib/action/append/constant.js +47 -0
  176. package/node_modules/argparse/lib/action/append.js +53 -0
  177. package/node_modules/argparse/lib/action/count.js +40 -0
  178. package/node_modules/argparse/lib/action/help.js +47 -0
  179. package/node_modules/argparse/lib/action/store/constant.js +43 -0
  180. package/node_modules/argparse/lib/action/store/false.js +27 -0
  181. package/node_modules/argparse/lib/action/store/true.js +26 -0
  182. package/node_modules/argparse/lib/action/store.js +50 -0
  183. package/node_modules/argparse/lib/action/subparsers.js +149 -0
  184. package/node_modules/argparse/lib/action/version.js +47 -0
  185. package/node_modules/argparse/lib/action.js +146 -0
  186. package/node_modules/argparse/lib/action_container.js +482 -0
  187. package/node_modules/argparse/lib/argparse.js +14 -0
  188. package/node_modules/argparse/lib/argument/error.js +50 -0
  189. package/node_modules/argparse/lib/argument/exclusive.js +54 -0
  190. package/node_modules/argparse/lib/argument/group.js +75 -0
  191. package/node_modules/argparse/lib/argument_parser.js +1161 -0
  192. package/node_modules/argparse/lib/const.js +21 -0
  193. package/node_modules/argparse/lib/help/added_formatters.js +87 -0
  194. package/node_modules/argparse/lib/help/formatter.js +795 -0
  195. package/node_modules/argparse/lib/namespace.js +76 -0
  196. package/node_modules/argparse/lib/utils.js +57 -0
  197. package/node_modules/argparse/package.json +34 -0
  198. package/node_modules/esprima/LICENSE.BSD +21 -0
  199. package/node_modules/esprima/README.md +46 -0
  200. package/node_modules/esprima/bin/esparse.js +139 -0
  201. package/node_modules/esprima/bin/esvalidate.js +236 -0
  202. package/node_modules/esprima/dist/esprima.js +6709 -0
  203. package/node_modules/esprima/package.json +112 -0
  204. package/node_modules/extend-shallow/LICENSE +21 -0
  205. package/node_modules/extend-shallow/README.md +61 -0
  206. package/node_modules/extend-shallow/index.js +33 -0
  207. package/node_modules/extend-shallow/package.json +56 -0
  208. package/node_modules/graceful-fs/LICENSE +15 -0
  209. package/node_modules/graceful-fs/README.md +143 -0
  210. package/node_modules/graceful-fs/clone.js +23 -0
  211. package/node_modules/graceful-fs/graceful-fs.js +448 -0
  212. package/node_modules/graceful-fs/legacy-streams.js +118 -0
  213. package/node_modules/graceful-fs/package.json +53 -0
  214. package/node_modules/graceful-fs/polyfills.js +355 -0
  215. package/node_modules/gray-matter/LICENSE +21 -0
  216. package/node_modules/gray-matter/README.md +565 -0
  217. package/node_modules/gray-matter/gray-matter.d.ts +114 -0
  218. package/node_modules/gray-matter/index.js +228 -0
  219. package/node_modules/gray-matter/lib/defaults.js +18 -0
  220. package/node_modules/gray-matter/lib/engine.js +30 -0
  221. package/node_modules/gray-matter/lib/engines.js +54 -0
  222. package/node_modules/gray-matter/lib/excerpt.js +32 -0
  223. package/node_modules/gray-matter/lib/parse.js +13 -0
  224. package/node_modules/gray-matter/lib/stringify.js +56 -0
  225. package/node_modules/gray-matter/lib/to-file.js +43 -0
  226. package/node_modules/gray-matter/lib/utils.js +66 -0
  227. package/node_modules/gray-matter/package.json +127 -0
  228. package/node_modules/is-extendable/LICENSE +21 -0
  229. package/node_modules/is-extendable/README.md +72 -0
  230. package/node_modules/is-extendable/index.js +13 -0
  231. package/node_modules/is-extendable/package.json +51 -0
  232. package/node_modules/js-yaml/LICENSE +21 -0
  233. package/node_modules/js-yaml/README.md +302 -0
  234. package/node_modules/js-yaml/bin/js-yaml.js +132 -0
  235. package/node_modules/js-yaml/dist/js-yaml.js +4024 -0
  236. package/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  237. package/node_modules/js-yaml/index.js +7 -0
  238. package/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  239. package/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  240. package/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  241. package/node_modules/js-yaml/lib/js-yaml/loader.js +1679 -0
  242. package/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  243. package/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  244. package/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  245. package/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  246. package/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  247. package/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  248. package/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  249. package/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  250. package/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  251. package/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  252. package/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  253. package/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  254. package/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  255. package/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  256. package/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  257. package/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  258. package/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  259. package/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  260. package/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  261. package/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  262. package/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  263. package/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  264. package/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  265. package/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  266. package/node_modules/js-yaml/lib/js-yaml.js +39 -0
  267. package/node_modules/js-yaml/package.json +52 -0
  268. package/node_modules/kind-of/LICENSE +21 -0
  269. package/node_modules/kind-of/README.md +367 -0
  270. package/node_modules/kind-of/index.js +129 -0
  271. package/node_modules/kind-of/package.json +88 -0
  272. package/node_modules/pi-toggle-skills/README.md +213 -0
  273. package/node_modules/pi-toggle-skills/package.json +60 -0
  274. package/node_modules/pi-toggle-skills/src/index.ts +112 -0
  275. package/node_modules/pi-toggle-skills/src/skill-discovery.ts +258 -0
  276. package/node_modules/pi-toggle-skills/src/skill-selector.ts +435 -0
  277. package/node_modules/pi-toggle-skills/toggle-skills.ts +316 -0
  278. package/node_modules/pi-toggle-skills/vitest.config.ts +15 -0
  279. package/node_modules/proper-lockfile/LICENSE +21 -0
  280. package/node_modules/proper-lockfile/README.md +183 -0
  281. package/node_modules/proper-lockfile/index.js +40 -0
  282. package/node_modules/proper-lockfile/lib/adapter.js +85 -0
  283. package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
  284. package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
  285. package/node_modules/proper-lockfile/node_modules/retry/.npmignore +3 -0
  286. package/node_modules/proper-lockfile/node_modules/retry/.travis.yml +15 -0
  287. package/node_modules/proper-lockfile/node_modules/retry/License +21 -0
  288. package/node_modules/proper-lockfile/node_modules/retry/Makefile +18 -0
  289. package/node_modules/proper-lockfile/node_modules/retry/README.md +227 -0
  290. package/node_modules/proper-lockfile/node_modules/retry/equation.gif +0 -0
  291. package/node_modules/proper-lockfile/node_modules/retry/example/dns.js +31 -0
  292. package/node_modules/proper-lockfile/node_modules/retry/example/stop.js +40 -0
  293. package/node_modules/proper-lockfile/node_modules/retry/index.js +1 -0
  294. package/node_modules/proper-lockfile/node_modules/retry/lib/retry.js +100 -0
  295. package/node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js +158 -0
  296. package/node_modules/proper-lockfile/node_modules/retry/package.json +32 -0
  297. package/node_modules/proper-lockfile/node_modules/retry/test/common.js +10 -0
  298. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-forever.js +24 -0
  299. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-operation.js +258 -0
  300. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
  301. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-timeouts.js +69 -0
  302. package/node_modules/proper-lockfile/package.json +71 -0
  303. package/node_modules/section-matter/LICENSE +21 -0
  304. package/node_modules/section-matter/README.md +236 -0
  305. package/node_modules/section-matter/index.js +136 -0
  306. package/node_modules/section-matter/package.json +55 -0
  307. package/node_modules/signal-exit/LICENSE.txt +16 -0
  308. package/node_modules/signal-exit/README.md +39 -0
  309. package/node_modules/signal-exit/index.js +202 -0
  310. package/node_modules/signal-exit/package.json +38 -0
  311. package/node_modules/signal-exit/signals.js +53 -0
  312. package/node_modules/sprintf-js/.npmignore +1 -0
  313. package/node_modules/sprintf-js/LICENSE +24 -0
  314. package/node_modules/sprintf-js/README.md +88 -0
  315. package/node_modules/sprintf-js/bower.json +14 -0
  316. package/node_modules/sprintf-js/demo/angular.html +20 -0
  317. package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  318. package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  319. package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  320. package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  321. package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  322. package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  323. package/node_modules/sprintf-js/gruntfile.js +36 -0
  324. package/node_modules/sprintf-js/package.json +22 -0
  325. package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  326. package/node_modules/sprintf-js/src/sprintf.js +208 -0
  327. package/node_modules/sprintf-js/test/test.js +82 -0
  328. package/node_modules/strip-bom-string/LICENSE +21 -0
  329. package/node_modules/strip-bom-string/README.md +66 -0
  330. package/node_modules/strip-bom-string/index.js +15 -0
  331. package/node_modules/strip-bom-string/package.json +60 -0
  332. package/package.json +13 -4
@@ -0,0 +1,159 @@
1
+ import type { Static, StaticDecode, StaticEncode, TObject } from "typebox";
2
+ import { type JsonObject } from "./json-value.ts";
3
+ import { extensionSettingsDefinitionMarker as definitionMarker } from "./definition-marker.ts";
4
+ export declare const ExtensionSettingsDefinitionCandidateSchema: TObject<{
5
+ id: import("typebox").TOptional<import("typebox").TUnknown>;
6
+ title: import("typebox").TOptional<import("typebox").TUnknown>;
7
+ description: import("typebox").TOptional<import("typebox").TUnknown>;
8
+ schemaId: import("typebox").TOptional<import("typebox").TUnknown>;
9
+ schema: import("typebox").TOptional<import("typebox").TUnknown>;
10
+ defaultSettings: import("typebox").TOptional<import("typebox").TUnknown>;
11
+ exampleSettings: import("typebox").TOptional<import("typebox").TUnknown>;
12
+ }>;
13
+ export type ExtensionSettingsDefinitionCandidate = Static<typeof ExtensionSettingsDefinitionCandidateSchema> & {
14
+ readonly [definitionMarker]?: unknown;
15
+ };
16
+ export declare class InvalidSettingsDefinition extends Error {
17
+ readonly name = "InvalidSettingsDefinition";
18
+ readonly reason: string;
19
+ constructor(reason: string);
20
+ }
21
+ /**
22
+ * An immutable settings contract created by {@link defineExtensionSettings}.
23
+ *
24
+ * The schema and derived defaults are cloned and recursively frozen. Resolved runtime values retain
25
+ * the schema's decoded TypeBox type, while `defaultSettings` remains JSON data suitable for writing
26
+ * to disk.
27
+ *
28
+ * @template Schema The TypeBox object schema that defines persisted and resolved settings.
29
+ */
30
+ export type ExtensionSettingsDefinition<Schema extends TObject = TObject> = {
31
+ readonly [definitionMarker]: true;
32
+ /** The stable identifier used in settings and schema filenames. */
33
+ readonly id: string;
34
+ /** The display name used in generated schema and README content. */
35
+ readonly title: string;
36
+ /** The summary used in generated schema and README content. */
37
+ readonly description: string;
38
+ /** The absolute URI written to the generated JSON Schema `$id` field. */
39
+ readonly schemaId: string;
40
+ /** A validated, recursively frozen clone of the supplied TypeBox schema. */
41
+ readonly schema: Schema;
42
+ /** The schema defaults as recursively frozen JSON data, before TypeBox decoding. */
43
+ readonly defaultSettings: JsonObject;
44
+ /** An optional validated example settings layer rendered in generated documentation. */
45
+ readonly exampleSettings: JsonObject | undefined;
46
+ };
47
+ /** Deeply optional object properties with replacement arrays, matching settings-layer merging. */
48
+ type SettingsLayerValue<Value> = Value extends readonly unknown[] ? Value : Value extends object ? string extends keyof Value ? Value : {
49
+ [Key in keyof Value]?: SettingsLayerValue<Value[Key]>;
50
+ } : Value;
51
+ /**
52
+ * Encoded JSON layer persisted for an extension's global or project settings.
53
+ *
54
+ * Object properties are recursively optional because layers merge over schema defaults. Arrays and
55
+ * scalar values remain complete replacements. Values use the schema's encoded representation, not
56
+ * the decoded runtime representation returned by `loadPiExtensionSettings`.
57
+ *
58
+ * @template Schema The TypeBox object schema from an extension settings definition.
59
+ */
60
+ export type ExtensionSettingsLayer<Schema extends TObject> = SettingsLayerValue<StaticEncode<Schema>>;
61
+ /**
62
+ * Input accepted by {@link defineExtensionSettings}.
63
+ *
64
+ * @template Schema The TypeBox object schema that determines the returned settings type.
65
+ */
66
+ export type ExtensionSettingsDefinitionInput<Schema extends TObject> = {
67
+ /**
68
+ * Stable identity used in settings filenames.
69
+ *
70
+ * Must contain 1–128 lowercase letters, digits, dots, underscores, or hyphens; the first and
71
+ * last characters must be alphanumeric. Changing this value moves the extension to different
72
+ * settings files.
73
+ */
74
+ readonly id: string;
75
+ /** Non-blank display name for generated documentation and JSON Schema metadata. */
76
+ readonly title: string;
77
+ /** Non-blank summary for generated documentation and JSON Schema metadata. */
78
+ readonly description: string;
79
+ /**
80
+ * Absolute URI for the generated JSON Schema `$id`.
81
+ *
82
+ * Defaults to `urn:pi-extension-settings:<id>`.
83
+ */
84
+ readonly schemaId?: string;
85
+ /**
86
+ * TypeBox object schema for resolved settings.
87
+ *
88
+ * Every object must set `additionalProperties: false`, every user-facing leaf must have a
89
+ * non-blank description, and every required property must resolve to a valid JSON default.
90
+ * `$schema` is reserved for editor metadata and cannot be declared as a setting.
91
+ */
92
+ readonly schema: Schema;
93
+ /**
94
+ * A realistic, non-default settings layer rendered after the default configuration.
95
+ *
96
+ * Use this only when complex settings—such as structured arrays, nested objects, maps, or
97
+ * unions—benefit from a realistic advanced setup. The value must be valid JSON, must match the
98
+ * generated settings-file schema, and must resolve to valid settings when merged over the
99
+ * defaults. Nested object properties may be partial; arrays remain complete replacement values.
100
+ * Omit it for simple or self-explanatory settings.
101
+ */
102
+ readonly exampleSettings?: ExtensionSettingsLayer<Schema>;
103
+ };
104
+ /**
105
+ * Defines and validates an extension's settings contract.
106
+ *
107
+ * Validation is eager so invalid schemas fail while the extension is loading, before any settings
108
+ * files are read or written. The input schema is cloned; this function does not mutate caller-owned
109
+ * data.
110
+ *
111
+ * @template Schema The TypeBox object schema used to infer resolved settings.
112
+ * @param input Identity, documentation metadata, and the TypeBox settings schema.
113
+ * @returns An immutable definition with validated JSON defaults.
114
+ * @throws {InvalidSettingsDefinition} If metadata, schema structure, descriptions, or defaults do
115
+ * not satisfy the settings contract.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * import { defineExtensionSettings } from "@zigai/pi-extension-settings";
120
+ * import { Type } from "typebox";
121
+ *
122
+ * export default defineExtensionSettings({
123
+ * id: "pi-example",
124
+ * title: "Pi Example",
125
+ * description: "Settings for Pi Example.",
126
+ * schema: Type.Object(
127
+ * {
128
+ * enabled: Type.Boolean({
129
+ * default: true,
130
+ * description: "Enable the extension.",
131
+ * }),
132
+ * },
133
+ * { additionalProperties: false },
134
+ * ),
135
+ * });
136
+ * ```
137
+ */
138
+ export declare function defineExtensionSettings<const Schema extends TObject>(input: ExtensionSettingsDefinitionInput<Schema>): ExtensionSettingsDefinition<Schema>;
139
+ export declare function defineExtensionSettings(input: ExtensionSettingsDefinitionCandidate): ExtensionSettingsDefinition;
140
+ export declare function isExtensionSettingsDefinition(value: ExtensionSettingsDefinitionCandidate): value is ExtensionSettingsDefinition;
141
+ /**
142
+ * The decoded runtime settings type produced by an extension definition.
143
+ *
144
+ * This preserves TypeBox transforms: it represents values after decoding, not the JSON shape stored
145
+ * in settings files.
146
+ *
147
+ * @template Definition A definition returned by {@link defineExtensionSettings}.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import type { ResolvedSettings } from "@zigai/pi-extension-settings";
152
+ * import settingsDefinition from "./settings.ts";
153
+ *
154
+ * export type Settings = ResolvedSettings<typeof settingsDefinition>;
155
+ * ```
156
+ */
157
+ export type ResolvedSettings<Definition extends ExtensionSettingsDefinition> = StaticDecode<Definition["schema"]>;
158
+ export {};
159
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAW,MAAM,SAAS,CAAC;AAIpF,OAAO,EAKH,KAAK,UAAU,EAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iCAAiC,IA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AAC;AAEd;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,CAAC,MAAM,SAAS,OAAO,IAAI,kBAAkB,CAC3E,YAAY,CAAC,MAAM,CAAC,CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gCAAgC,CAAC,MAAM,SAAS,OAAO,IAAI;IACnE;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,MAAM,SAAS,OAAO,EAChE,KAAK,EAAE,gCAAgC,CAAC,MAAM,CAAC,GAChD,2BAA2B,CAAC,MAAM,CAAC,CAAC;AACvC,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,oCAAoC,GAC5C,2BAA2B,CAAC;AAyK/B,wBAAgB,6BAA6B,CACzC,KAAK,EAAE,oCAAoC,GAC5C,KAAK,IAAI,2BAA2B,CA6CtC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gBAAgB,CAAC,UAAU,SAAS,2BAA2B,IAAI,YAAY,CACvF,UAAU,CAAC,QAAQ,CAAC,CACvB,CAAC"}
@@ -0,0 +1,248 @@
1
+ import { isDeepStrictEqual } from "node:util";
2
+ import { IsSchema, Type, Value } from "./typebox-runtime.js";
3
+ import { cloneJson, isJsonObject, JsonValueSchema, parseJson, } from "./json-value.js";
4
+ import { extensionSettingsDefinitionMarker as definitionMarker } from "./definition-marker.js";
5
+ import { createSettingsFileSchema, findNonStrictObjectSchemas, findUndocumentedSettings, hasReservedSchemaProperty, } from "./schema-document.js";
6
+ import { mergeSettings } from "./settings-merge.js";
7
+ const SETTINGS_ID_PATTERN = /^[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$/;
8
+ const StringValueSchema = Type.String();
9
+ export const ExtensionSettingsDefinitionCandidateSchema = Type.Object({
10
+ id: Type.Optional(Type.Unknown()),
11
+ title: Type.Optional(Type.Unknown()),
12
+ description: Type.Optional(Type.Unknown()),
13
+ schemaId: Type.Optional(Type.Unknown()),
14
+ schema: Type.Optional(Type.Unknown()),
15
+ defaultSettings: Type.Optional(Type.Unknown()),
16
+ exampleSettings: Type.Optional(Type.Unknown()),
17
+ }, { additionalProperties: true });
18
+ function isSettingsSchema(value) {
19
+ if (!IsSchema(value))
20
+ return false;
21
+ let serialized;
22
+ try {
23
+ serialized = JSON.stringify(value);
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ if (serialized === undefined)
29
+ return false;
30
+ const parsed = parseJson(serialized);
31
+ return isJsonObject(parsed) && parsed.type === "object" && isJsonObject(parsed.properties);
32
+ }
33
+ function freezeRecursively(value) {
34
+ if (Object.isFrozen(value))
35
+ return;
36
+ for (const child of Object.values(value)) {
37
+ if (Value.Check(JsonValueSchema, child)) {
38
+ if (Array.isArray(child) || isJsonObject(child))
39
+ freezeRecursively(child);
40
+ }
41
+ else if (IsSchema(child)) {
42
+ freezeRecursively(child);
43
+ }
44
+ }
45
+ Object.freeze(value);
46
+ }
47
+ export class InvalidSettingsDefinition extends Error {
48
+ name = "InvalidSettingsDefinition";
49
+ reason;
50
+ constructor(reason) {
51
+ super(reason);
52
+ this.reason = reason;
53
+ }
54
+ }
55
+ export function defineExtensionSettings(input) {
56
+ let id;
57
+ try {
58
+ id = Value.Parse(StringValueSchema, input.id);
59
+ }
60
+ catch {
61
+ throw new InvalidSettingsDefinition("id must be 1-128 lowercase filename-safe characters and cannot end with punctuation");
62
+ }
63
+ if (!SETTINGS_ID_PATTERN.test(id)) {
64
+ throw new InvalidSettingsDefinition("id must be 1-128 lowercase filename-safe characters and cannot end with punctuation");
65
+ }
66
+ let title;
67
+ try {
68
+ title = Value.Parse(StringValueSchema, input.title);
69
+ }
70
+ catch {
71
+ throw new InvalidSettingsDefinition("title must not be blank");
72
+ }
73
+ if (title.trim() === "")
74
+ throw new InvalidSettingsDefinition("title must not be blank");
75
+ let description;
76
+ try {
77
+ description = Value.Parse(StringValueSchema, input.description);
78
+ }
79
+ catch {
80
+ throw new InvalidSettingsDefinition("description must not be blank");
81
+ }
82
+ if (description.trim() === "") {
83
+ throw new InvalidSettingsDefinition("description must not be blank");
84
+ }
85
+ let schemaId = `urn:pi-extension-settings:${id}`;
86
+ if (input.schemaId !== undefined) {
87
+ try {
88
+ schemaId = Value.Parse(StringValueSchema, input.schemaId);
89
+ }
90
+ catch {
91
+ throw new InvalidSettingsDefinition("schemaId must be an absolute URI");
92
+ }
93
+ }
94
+ try {
95
+ new URL(schemaId);
96
+ }
97
+ catch {
98
+ throw new InvalidSettingsDefinition("schemaId must be an absolute URI");
99
+ }
100
+ if (!IsSchema(input.schema) || !isSettingsSchema(input.schema)) {
101
+ throw new InvalidSettingsDefinition("schema must be a TypeBox object schema");
102
+ }
103
+ const schema = Value.Clone(input.schema);
104
+ if (hasReservedSchemaProperty(schema)) {
105
+ throw new InvalidSettingsDefinition("$schema is reserved for editor metadata");
106
+ }
107
+ const nonStrictObjects = findNonStrictObjectSchemas(schema);
108
+ if (nonStrictObjects.length > 0) {
109
+ throw new InvalidSettingsDefinition(`object schemas must set additionalProperties to false: ${nonStrictObjects.join(", ")}`);
110
+ }
111
+ const undocumentedSettings = findUndocumentedSettings(schema);
112
+ if (undocumentedSettings.length > 0) {
113
+ throw new InvalidSettingsDefinition(`user-facing settings must have descriptions: ${undocumentedSettings.join(", ")}`);
114
+ }
115
+ const rawDefaults = Value.Default(schema, {});
116
+ if (!Value.Check(schema, rawDefaults)) {
117
+ const issues = [...Value.Errors(schema, rawDefaults)]
118
+ .map((issue) => `${issue.instancePath || "/"}: ${issue.message}`)
119
+ .join("; ");
120
+ throw new InvalidSettingsDefinition(`required settings must have valid defaults${issues === "" ? "" : `: ${issues}`}`);
121
+ }
122
+ let serializedDefaults;
123
+ try {
124
+ serializedDefaults = JSON.stringify(rawDefaults);
125
+ }
126
+ catch {
127
+ throw new InvalidSettingsDefinition("schema defaults must produce a JSON object");
128
+ }
129
+ const parsedDefaults = parseJson(serializedDefaults);
130
+ if (!isJsonObject(parsedDefaults) || !isDeepStrictEqual(rawDefaults, parsedDefaults)) {
131
+ throw new InvalidSettingsDefinition("schema defaults must produce a JSON object");
132
+ }
133
+ try {
134
+ Value.Decode(schema, rawDefaults);
135
+ }
136
+ catch {
137
+ throw new InvalidSettingsDefinition("schema defaults could not be decoded");
138
+ }
139
+ const defaultSettings = cloneJson(parsedDefaults);
140
+ let exampleSettings;
141
+ if (input.exampleSettings !== undefined) {
142
+ let serializedExample;
143
+ try {
144
+ serializedExample = JSON.stringify(input.exampleSettings);
145
+ }
146
+ catch {
147
+ throw new InvalidSettingsDefinition("exampleSettings must be a JSON object");
148
+ }
149
+ const parsedExample = parseJson(serializedExample);
150
+ if (!isJsonObject(parsedExample) ||
151
+ !isDeepStrictEqual(input.exampleSettings, parsedExample)) {
152
+ throw new InvalidSettingsDefinition("exampleSettings must be a JSON object");
153
+ }
154
+ const fileSchema = createSettingsFileSchema({
155
+ id,
156
+ title,
157
+ description,
158
+ schemaId,
159
+ schema,
160
+ });
161
+ if (!Value.Check(fileSchema, parsedExample)) {
162
+ const issues = [...Value.Errors(fileSchema, parsedExample)]
163
+ .map((issue) => `${issue.instancePath || "/"}: ${issue.message}`)
164
+ .join("; ");
165
+ throw new InvalidSettingsDefinition(`exampleSettings must match the settings-file schema${issues === "" ? "" : `: ${issues}`}`);
166
+ }
167
+ const mergedExample = mergeSettings(defaultSettings, parsedExample);
168
+ if (!Value.Check(schema, mergedExample)) {
169
+ throw new InvalidSettingsDefinition("exampleSettings must resolve to valid settings when merged with defaults");
170
+ }
171
+ try {
172
+ Value.Decode(schema, mergedExample);
173
+ }
174
+ catch {
175
+ throw new InvalidSettingsDefinition("exampleSettings could not be decoded");
176
+ }
177
+ if (isDeepStrictEqual(mergedExample, defaultSettings)) {
178
+ throw new InvalidSettingsDefinition("exampleSettings must demonstrate configuration that differs from the defaults");
179
+ }
180
+ exampleSettings = cloneJson(parsedExample);
181
+ }
182
+ freezeRecursively(schema);
183
+ freezeRecursively(defaultSettings);
184
+ if (exampleSettings !== undefined)
185
+ freezeRecursively(exampleSettings);
186
+ const definition = Object.freeze({
187
+ [definitionMarker]: true,
188
+ id,
189
+ title,
190
+ description,
191
+ schemaId,
192
+ schema,
193
+ defaultSettings,
194
+ exampleSettings,
195
+ });
196
+ // Build once during definition so malformed schema structures fail at startup.
197
+ createSettingsFileSchema(definition);
198
+ return definition;
199
+ }
200
+ export function isExtensionSettingsDefinition(value) {
201
+ if (!(definitionMarker in value) || value[definitionMarker] !== true)
202
+ return false;
203
+ if (!("id" in value) ||
204
+ !Value.Check(StringValueSchema, value.id) ||
205
+ !SETTINGS_ID_PATTERN.test(value.id)) {
206
+ return false;
207
+ }
208
+ if (!("title" in value) || !Value.Check(StringValueSchema, value.title))
209
+ return false;
210
+ if (!("description" in value) || !Value.Check(StringValueSchema, value.description)) {
211
+ return false;
212
+ }
213
+ if (!("schemaId" in value) || !Value.Check(StringValueSchema, value.schemaId))
214
+ return false;
215
+ if (!("schema" in value) || !IsSchema(value.schema) || !isSettingsSchema(value.schema)) {
216
+ return false;
217
+ }
218
+ if (!("defaultSettings" in value))
219
+ return false;
220
+ const exampleSettings = "exampleSettings" in value ? value.exampleSettings : undefined;
221
+ let serializedDefaults;
222
+ try {
223
+ serializedDefaults = JSON.stringify(value.defaultSettings);
224
+ }
225
+ catch {
226
+ return false;
227
+ }
228
+ const parsedDefaults = parseJson(serializedDefaults);
229
+ if (!isJsonObject(parsedDefaults) ||
230
+ !isDeepStrictEqual(value.defaultSettings, parsedDefaults)) {
231
+ return false;
232
+ }
233
+ if (exampleSettings !== undefined) {
234
+ let serializedExample;
235
+ try {
236
+ serializedExample = JSON.stringify(exampleSettings);
237
+ }
238
+ catch {
239
+ return false;
240
+ }
241
+ const parsedExample = parseJson(serializedExample);
242
+ if (!isJsonObject(parsedExample) || !isDeepStrictEqual(exampleSettings, parsedExample)) {
243
+ return false;
244
+ }
245
+ }
246
+ return true;
247
+ }
248
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAI9C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7D,OAAO,EACH,SAAS,EACT,YAAY,EACZ,eAAe,EAGf,SAAS,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iCAAiC,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EACH,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,mBAAmB,GAAG,2CAA2C,CAAC;AACxE,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;AAExC,MAAM,CAAC,MAAM,0CAA0C,GAAG,IAAI,CAAC,MAAM,CACjE;IACI,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACpC,WAAW,EAAE,IAAI,C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B,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,cAAc,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACrD,IACI,CAAC,YAAY,CAAC,cAAc,CAAC;QAC7B,CAAC,iBAAiB,CAAC,KAAK,CAAC,eAAe,EAAE,cAAc,CAAC,EAC3D,CAAC;QACC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,iBAAyB,CAAC;QAC9B,IAAI,CAAC;YACD,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,MAAM,aAAa,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;QACnD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,eAAe,EAAE,aAAa,CAAC,EAAE,CAAC;YACrF,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { isDeepStrictEqual } from \"node:util\";\n\nimport type { Static, StaticDecode, StaticEncode, TObject, TSchema } from \"typebox\";\n\nimport { IsSchema, Type, Value } from \"./typebox-runtime.ts\";\n\nimport {\n cloneJson,\n isJsonObject,\n JsonValueSchema,\n type JsonArray,\n type JsonObject,\n parseJson,\n} from \"./json-value.ts\";\nimport { extensionSettingsDefinitionMarker as definitionMarker } from \"./definition-marker.ts\";\nimport {\n createSettingsFileSchema,\n findNonStrictObjectSchemas,\n findUndocumentedSettings,\n hasReservedSchemaProperty,\n} from \"./schema-document.ts\";\nimport { mergeSettings } from \"./settings-merge.ts\";\n\nconst SETTINGS_ID_PATTERN = /^[a-z0-9](?:[a-z0-9._-]{0,126}[a-z0-9])?$/;\nconst StringValueSchema = Type.String();\n\nexport const ExtensionSettingsDefinitionCandidateSchema = Type.Object(\n {\n id: Type.Optional(Type.Unknown()),\n title: Type.Optional(Type.Unknown()),\n description: Type.Optional(Type.Unknown()),\n schemaId: Type.Optional(Type.Unknown()),\n schema: Type.Optional(Type.Unknown()),\n defaultSettings: Type.Optional(Type.Unknown()),\n exampleSettings: Type.Optional(Type.Unknown()),\n },\n { additionalProperties: true },\n);\n\nexport type ExtensionSettingsDefinitionCandidate = Static<\n typeof ExtensionSettingsDefinitionCandidateSchema\n> & {\n readonly [definitionMarker]?: unknown;\n};\n\nfunction isSettingsSchema(value: TSchema): value is TObject {\n if (!IsSchema(value)) return false;\n let serialized: string | undefined;\n try {\n serialized = JSON.stringify(value);\n } catch {\n return false;\n }\n if (serialized === undefined) return false;\n const parsed = parseJson(serialized);\n return isJsonObject(parsed) && parsed.type === \"object\" && isJsonObject(parsed.properties);\n}\n\nfunction freezeRecursively(value: JsonArray | JsonObject | TSchema): void {\n if (Object.isFrozen(value)) return;\n for (const child of Object.values(value)) {\n if (Value.Check(JsonValueSchema, child)) {\n if (Array.isArray(child) || isJsonObject(child)) freezeRecursively(child);\n } else if (IsSchema(child)) {\n freezeRecursively(child);\n }\n }\n Object.freeze(value);\n}\n\nexport class InvalidSettingsDefinition extends Error {\n override readonly name = \"InvalidSettingsDefinition\";\n readonly reason: string;\n\n constructor(reason: string) {\n super(reason);\n this.reason = reason;\n }\n}\n\n/**\n * An immutable settings contract created by {@link defineExtensionSettings}.\n *\n * The schema and derived defaults are cloned and recursively frozen. Resolved runtime values retain\n * the schema's decoded TypeBox type, while `defaultSettings` remains JSON data suitable for writing\n * to disk.\n *\n * @template Schema The TypeBox object schema that defines persisted and resolved settings.\n */\nexport type ExtensionSettingsDefinition<Schema extends TObject = TObject> = {\n readonly [definitionMarker]: true;\n /** The stable identifier used in settings and schema filenames. */\n readonly id: string;\n /** The display name used in generated schema and README content. */\n readonly title: string;\n /** The summary used in generated schema and README content. */\n readonly description: string;\n /** The absolute URI written to the generated JSON Schema `$id` field. */\n readonly schemaId: string;\n /** A validated, recursively frozen clone of the supplied TypeBox schema. */\n readonly schema: Schema;\n /** The schema defaults as recursively frozen JSON data, before TypeBox decoding. */\n readonly defaultSettings: JsonObject;\n /** An optional validated example settings layer rendered in generated documentation. */\n readonly exampleSettings: JsonObject | undefined;\n};\n\n/** Deeply optional object properties with replacement arrays, matching settings-layer merging. */\ntype SettingsLayerValue<Value> = Value extends readonly unknown[]\n ? Value\n : Value extends object\n ? string extends keyof Value\n ? Value\n : { [Key in keyof Value]?: SettingsLayerValue<Value[Key]> }\n : Value;\n\n/**\n * Encoded JSON layer persisted for an extension's global or project settings.\n *\n * Object properties are recursively optional because layers merge over schema defaults. Arrays and\n * scalar values remain complete replacements. Values use the schema's encoded representation, not\n * the decoded runtime representation returned by `loadPiExtensionSettings`.\n *\n * @template Schema The TypeBox object schema from an extension settings definition.\n */\nexport type ExtensionSettingsLayer<Schema extends TObject> = SettingsLayerValue<\n StaticEncode<Schema>\n>;\n\n/**\n * Input accepted by {@link defineExtensionSettings}.\n *\n * @template Schema The TypeBox object schema that determines the returned settings type.\n */\nexport type ExtensionSettingsDefinitionInput<Schema extends TObject> = {\n /**\n * Stable identity used in settings filenames.\n *\n * Must contain 1–128 lowercase letters, digits, dots, underscores, or hyphens; the first and\n * last characters must be alphanumeric. Changing this value moves the extension to different\n * settings files.\n */\n readonly id: string;\n /** Non-blank display name for generated documentation and JSON Schema metadata. */\n readonly title: string;\n /** Non-blank summary for generated documentation and JSON Schema metadata. */\n readonly description: string;\n /**\n * Absolute URI for the generated JSON Schema `$id`.\n *\n * Defaults to `urn:pi-extension-settings:<id>`.\n */\n readonly schemaId?: string;\n /**\n * TypeBox object schema for resolved settings.\n *\n * Every object must set `additionalProperties: false`, every user-facing leaf must have a\n * non-blank description, and every required property must resolve to a valid JSON default.\n * `$schema` is reserved for editor metadata and cannot be declared as a setting.\n */\n readonly schema: Schema;\n /**\n * A realistic, non-default settings layer rendered after the default configuration.\n *\n * Use this only when complex settings—such as structured arrays, nested objects, maps, or\n * unions—benefit from a realistic advanced setup. The value must be valid JSON, must match the\n * generated settings-file schema, and must resolve to valid settings when merged over the\n * defaults. Nested object properties may be partial; arrays remain complete replacement values.\n * Omit it for simple or self-explanatory settings.\n */\n readonly exampleSettings?: ExtensionSettingsLayer<Schema>;\n};\n\n/**\n * Defines and validates an extension's settings contract.\n *\n * Validation is eager so invalid schemas fail while the extension is loading, before any settings\n * files are read or written. The input schema is cloned; this function does not mutate caller-owned\n * data.\n *\n * @template Schema The TypeBox object schema used to infer resolved settings.\n * @param input Identity, documentation metadata, and the TypeBox settings schema.\n * @returns An immutable definition with validated JSON defaults.\n * @throws {InvalidSettingsDefinition} If metadata, schema structure, descriptions, or defaults do\n * not satisfy the settings contract.\n *\n * @example\n * ```ts\n * import { defineExtensionSettings } from \"@zigai/pi-extension-settings\";\n * import { Type } from \"typebox\";\n *\n * export default defineExtensionSettings({\n * id: \"pi-example\",\n * title: \"Pi Example\",\n * description: \"Settings for Pi Example.\",\n * schema: Type.Object(\n * {\n * enabled: Type.Boolean({\n * default: true,\n * description: \"Enable the extension.\",\n * }),\n * },\n * { additionalProperties: false },\n * ),\n * });\n * ```\n */\nexport function defineExtensionSettings<const Schema extends TObject>(\n input: ExtensionSettingsDefinitionInput<Schema>,\n): ExtensionSettingsDefinition<Schema>;\nexport function defineExtensionSettings(\n input: ExtensionSettingsDefinitionCandidate,\n): ExtensionSettingsDefinition;\nexport function defineExtensionSettings(\n input: ExtensionSettingsDefinitionCandidate,\n): ExtensionSettingsDefinition {\n let id: string;\n try {\n id = Value.Parse(StringValueSchema, input.id);\n } catch {\n throw new InvalidSettingsDefinition(\n \"id must be 1-128 lowercase filename-safe characters and cannot end with punctuation\",\n );\n }\n if (!SETTINGS_ID_PATTERN.test(id)) {\n throw new InvalidSettingsDefinition(\n \"id must be 1-128 lowercase filename-safe characters and cannot end with punctuation\",\n );\n }\n\n let title: string;\n try {\n title = Value.Parse(StringValueSchema, input.title);\n } catch {\n throw new InvalidSettingsDefinition(\"title must not be blank\");\n }\n if (title.trim() === \"\") throw new InvalidSettingsDefinition(\"title must not be blank\");\n\n let description: string;\n try {\n description = Value.Parse(StringValueSchema, input.description);\n } catch {\n throw new InvalidSettingsDefinition(\"description must not be blank\");\n }\n if (description.trim() === \"\") {\n throw new InvalidSettingsDefinition(\"description must not be blank\");\n }\n\n let schemaId = `urn:pi-extension-settings:${id}`;\n if (input.schemaId !== undefined) {\n try {\n schemaId = Value.Parse(StringValueSchema, input.schemaId);\n } catch {\n throw new InvalidSettingsDefinition(\"schemaId must be an absolute URI\");\n }\n }\n try {\n new URL(schemaId);\n } catch {\n throw new InvalidSettingsDefinition(\"schemaId must be an absolute URI\");\n }\n\n if (!IsSchema(input.schema) || !isSettingsSchema(input.schema)) {\n throw new InvalidSettingsDefinition(\"schema must be a TypeBox object schema\");\n }\n const schema = Value.Clone(input.schema);\n if (hasReservedSchemaProperty(schema)) {\n throw new InvalidSettingsDefinition(\"$schema is reserved for editor metadata\");\n }\n\n const nonStrictObjects = findNonStrictObjectSchemas(schema);\n if (nonStrictObjects.length > 0) {\n throw new InvalidSettingsDefinition(\n `object schemas must set additionalProperties to false: ${nonStrictObjects.join(\", \")}`,\n );\n }\n const undocumentedSettings = findUndocumentedSettings(schema);\n if (undocumentedSettings.length > 0) {\n throw new InvalidSettingsDefinition(\n `user-facing settings must have descriptions: ${undocumentedSettings.join(\", \")}`,\n );\n }\n\n const rawDefaults: unknown = Value.Default(schema, {});\n if (!Value.Check(schema, rawDefaults)) {\n const issues = [...Value.Errors(schema, rawDefaults)]\n .map((issue) => `${issue.instancePath || \"/\"}: ${issue.message}`)\n .join(\"; \");\n throw new InvalidSettingsDefinition(\n `required settings must have valid defaults${issues === \"\" ? \"\" : `: ${issues}`}`,\n );\n }\n let serializedDefaults: string;\n try {\n serializedDefaults = JSON.stringify(rawDefaults);\n } catch {\n throw new InvalidSettingsDefinition(\"schema defaults must produce a JSON object\");\n }\n const parsedDefaults = parseJson(serializedDefaults);\n if (!isJsonObject(parsedDefaults) || !isDeepStrictEqual(rawDefaults, parsedDefaults)) {\n throw new InvalidSettingsDefinition(\"schema defaults must produce a JSON object\");\n }\n\n try {\n Value.Decode(schema, rawDefaults);\n } catch {\n throw new InvalidSettingsDefinition(\"schema defaults could not be decoded\");\n }\n\n const defaultSettings = cloneJson(parsedDefaults);\n let exampleSettings: JsonObject | undefined;\n if (input.exampleSettings !== undefined) {\n let serializedExample: string;\n try {\n serializedExample = JSON.stringify(input.exampleSettings);\n } catch {\n throw new InvalidSettingsDefinition(\"exampleSettings must be a JSON object\");\n }\n const parsedExample = parseJson(serializedExample);\n if (\n !isJsonObject(parsedExample) ||\n !isDeepStrictEqual(input.exampleSettings, parsedExample)\n ) {\n throw new InvalidSettingsDefinition(\"exampleSettings must be a JSON object\");\n }\n\n const fileSchema = createSettingsFileSchema({\n id,\n title,\n description,\n schemaId,\n schema,\n });\n if (!Value.Check(fileSchema, parsedExample)) {\n const issues = [...Value.Errors(fileSchema, parsedExample)]\n .map((issue) => `${issue.instancePath || \"/\"}: ${issue.message}`)\n .join(\"; \");\n throw new InvalidSettingsDefinition(\n `exampleSettings must match the settings-file schema${issues === \"\" ? \"\" : `: ${issues}`}`,\n );\n }\n\n const mergedExample = mergeSettings(defaultSettings, parsedExample);\n if (!Value.Check(schema, mergedExample)) {\n throw new InvalidSettingsDefinition(\n \"exampleSettings must resolve to valid settings when merged with defaults\",\n );\n }\n try {\n Value.Decode(schema, mergedExample);\n } catch {\n throw new InvalidSettingsDefinition(\"exampleSettings could not be decoded\");\n }\n if (isDeepStrictEqual(mergedExample, defaultSettings)) {\n throw new InvalidSettingsDefinition(\n \"exampleSettings must demonstrate configuration that differs from the defaults\",\n );\n }\n exampleSettings = cloneJson(parsedExample);\n }\n\n freezeRecursively(schema);\n freezeRecursively(defaultSettings);\n if (exampleSettings !== undefined) freezeRecursively(exampleSettings);\n\n const definition: ExtensionSettingsDefinition = Object.freeze({\n [definitionMarker]: true as const,\n id,\n title,\n description,\n schemaId,\n schema,\n defaultSettings,\n exampleSettings,\n });\n\n // Build once during definition so malformed schema structures fail at startup.\n createSettingsFileSchema(definition);\n return definition;\n}\n\nexport function isExtensionSettingsDefinition(\n value: ExtensionSettingsDefinitionCandidate,\n): value is ExtensionSettingsDefinition {\n if (!(definitionMarker in value) || value[definitionMarker] !== true) return false;\n if (\n !(\"id\" in value) ||\n !Value.Check(StringValueSchema, value.id) ||\n !SETTINGS_ID_PATTERN.test(value.id)\n ) {\n return false;\n }\n if (!(\"title\" in value) || !Value.Check(StringValueSchema, value.title)) return false;\n if (!(\"description\" in value) || !Value.Check(StringValueSchema, value.description)) {\n return false;\n }\n if (!(\"schemaId\" in value) || !Value.Check(StringValueSchema, value.schemaId)) return false;\n if (!(\"schema\" in value) || !IsSchema(value.schema) || !isSettingsSchema(value.schema)) {\n return false;\n }\n if (!(\"defaultSettings\" in value)) return false;\n const exampleSettings = \"exampleSettings\" in value ? value.exampleSettings : undefined;\n let serializedDefaults: string;\n try {\n serializedDefaults = JSON.stringify(value.defaultSettings);\n } catch {\n return false;\n }\n const parsedDefaults = parseJson(serializedDefaults);\n if (\n !isJsonObject(parsedDefaults) ||\n !isDeepStrictEqual(value.defaultSettings, parsedDefaults)\n ) {\n return false;\n }\n if (exampleSettings !== undefined) {\n let serializedExample: string;\n try {\n serializedExample = JSON.stringify(exampleSettings);\n } catch {\n return false;\n }\n const parsedExample = parseJson(serializedExample);\n if (!isJsonObject(parsedExample) || !isDeepStrictEqual(exampleSettings, parsedExample)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The decoded runtime settings type produced by an extension definition.\n *\n * This preserves TypeBox transforms: it represents values after decoding, not the JSON shape stored\n * in settings files.\n *\n * @template Definition A definition returned by {@link defineExtensionSettings}.\n *\n * @example\n * ```ts\n * import type { ResolvedSettings } from \"@zigai/pi-extension-settings\";\n * import settingsDefinition from \"./settings.ts\";\n *\n * export type Settings = ResolvedSettings<typeof settingsDefinition>;\n * ```\n */\nexport type ResolvedSettings<Definition extends ExtensionSettingsDefinition> = StaticDecode<\n Definition[\"schema\"]\n>;\n"]}
@@ -0,0 +1,10 @@
1
+ type WriteStatus = "created" | "unchanged" | "updated";
2
+ export declare function readTextIfPresent(path: string): string | undefined;
3
+ export declare function readTextIfPresentAsync(path: string): Promise<string | undefined>;
4
+ /** Produce content only for a missing destination, then atomically publish without clobbering. */
5
+ export declare function writeTextIfMissing(path: string, produceContent: () => string, mode?: number): WriteStatus;
6
+ export declare function writeTextAtomically(path: string, content: string, mode?: number): WriteStatus;
7
+ /** Atomically replace complete content while preserving an existing file's permission mode. */
8
+ export declare function writeTextAtomicallyAsync(path: string, content: string, defaultMode?: number): Promise<void>;
9
+ export {};
10
+ //# sourceMappingURL=file-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../src/file-system.ts"],"names":[],"mappings":"AAeA,KAAK,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC;AAQvD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOlE;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAOtF;AAED,kGAAkG;AAClG,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,MAAM,EAC5B,IAAI,SAAQ,GACb,WAAW,CAyBb;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,WAAW,CAkB5F;AAED,+FAA+F;AAC/F,wBAAsB,wBAAwB,CAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,SAAQ,GACpB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
@@ -0,0 +1,115 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { linkSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync, } from "node:fs";
3
+ import { chmod, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
4
+ import { basename, dirname, join } from "node:path";
5
+ import { Type, Value } from "./typebox-runtime.js";
6
+ const CodedErrorSchema = Type.Object({ code: Type.String() });
7
+ function errorCode(cause) {
8
+ return Value.Check(CodedErrorSchema, cause) ? cause.code : undefined;
9
+ }
10
+ export function readTextIfPresent(path) {
11
+ try {
12
+ return readFileSync(path, "utf8");
13
+ }
14
+ catch (cause) {
15
+ if (cause instanceof Error && errorCode(cause) === "ENOENT")
16
+ return undefined;
17
+ throw cause;
18
+ }
19
+ }
20
+ export async function readTextIfPresentAsync(path) {
21
+ try {
22
+ return await readFile(path, "utf8");
23
+ }
24
+ catch (cause) {
25
+ if (cause instanceof Error && errorCode(cause) === "ENOENT")
26
+ return undefined;
27
+ throw cause;
28
+ }
29
+ }
30
+ /** Produce content only for a missing destination, then atomically publish without clobbering. */
31
+ export function writeTextIfMissing(path, produceContent, mode = 0o600) {
32
+ // Avoid directory writes for existing entries, including dangling symlinks. The hard link
33
+ // below still provides no-clobber publication if another writer wins after this check.
34
+ if (lstatSync(path, { throwIfNoEntry: false }) !== undefined)
35
+ return "unchanged";
36
+ const directory = dirname(path);
37
+ const temporaryPath = join(directory, `.${basename(path)}.${randomUUID()}.tmp`);
38
+ try {
39
+ mkdirSync(directory, { recursive: true });
40
+ writeFileSync(temporaryPath, produceContent(), { encoding: "utf8", flag: "wx", mode });
41
+ try {
42
+ linkSync(temporaryPath, path);
43
+ return "created";
44
+ }
45
+ catch (cause) {
46
+ if (cause instanceof Error && errorCode(cause) === "EEXIST")
47
+ return "unchanged";
48
+ throw cause;
49
+ }
50
+ }
51
+ finally {
52
+ try {
53
+ rmSync(temporaryPath, { force: true });
54
+ }
55
+ catch {
56
+ // Cleanup must not mask the write result.
57
+ }
58
+ }
59
+ }
60
+ export function writeTextAtomically(path, content, mode = 0o644) {
61
+ const current = readTextIfPresent(path);
62
+ if (current === content)
63
+ return "unchanged";
64
+ const directory = dirname(path);
65
+ const temporaryPath = join(directory, `.${basename(path)}.${randomUUID()}.tmp`);
66
+ try {
67
+ mkdirSync(directory, { recursive: true });
68
+ writeFileSync(temporaryPath, content, { encoding: "utf8", flag: "wx", mode });
69
+ renameSync(temporaryPath, path);
70
+ return current === undefined ? "created" : "updated";
71
+ }
72
+ finally {
73
+ try {
74
+ rmSync(temporaryPath, { force: true });
75
+ }
76
+ catch {
77
+ // Cleanup must not mask the write result.
78
+ }
79
+ }
80
+ }
81
+ /** Atomically replace complete content while preserving an existing file's permission mode. */
82
+ export async function writeTextAtomicallyAsync(path, content, defaultMode = 0o600) {
83
+ let mode = defaultMode;
84
+ try {
85
+ mode = (await stat(path)).mode & 0o777;
86
+ }
87
+ catch (cause) {
88
+ if (!(cause instanceof Error) || errorCode(cause) !== "ENOENT")
89
+ throw cause;
90
+ }
91
+ const directory = dirname(path);
92
+ const temporaryPath = join(directory, `.${basename(path)}.${randomUUID()}.tmp`);
93
+ await mkdir(directory, { recursive: true });
94
+ try {
95
+ const handle = await open(temporaryPath, "wx", mode);
96
+ try {
97
+ await handle.writeFile(content, { encoding: "utf8" });
98
+ await handle.sync();
99
+ }
100
+ finally {
101
+ await handle.close();
102
+ }
103
+ await chmod(temporaryPath, mode);
104
+ await rename(temporaryPath, path);
105
+ }
106
+ finally {
107
+ try {
108
+ await rm(temporaryPath, { force: true });
109
+ }
110
+ catch {
111
+ // Cleanup must not mask the write result.
112
+ }
113
+ }
114
+ }
115
+ //# sourceMappingURL=file-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-system.js","sourceRoot":"","sources":["../src/file-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACH,Q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AChC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,MAAM,CAAC,CAAC;IAChF,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC;YACD,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YACtD,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC;gBAAS,CAAC;YACP,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;QACD,MAAM,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QACjC,MAAM,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;YAAS,CAAC;QACP,IAAI,CAAC;YACD,MAAM,EAAE,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;QAAC,MAAM,CAAC;YACL,0CAA0C;QAC9C,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport {\n linkSync,\n lstatSync,\n mkdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport { chmod, mkdir, open, readFile, rename, rm, stat } from \"node:fs/promises\";\nimport { basename, dirname, join } from \"node:path\";\n\nimport { Type, Value } from \"./typebox-runtime.ts\";\n\ntype WriteStatus = \"created\" | \"unchanged\" | \"updated\";\n\nconst CodedErrorSchema = Type.Object({ code: Type.String() });\n\nfunction errorCode(cause: Error): string | undefined {\n return Value.Check(CodedErrorSchema, cause) ? cause.code : undefined;\n}\n\nexport function readTextIfPresent(path: string): string | undefined {\n try {\n return readFileSync(path, \"utf8\");\n } catch (cause: unknown) {\n if (cause instanceof Error && errorCode(cause) === \"ENOENT\") return undefined;\n throw cause;\n }\n}\n\nexport async function readTextIfPresentAsync(path: string): Promise<string | undefined> {\n try {\n return await readFile(path, \"utf8\");\n } catch (cause: unknown) {\n if (cause instanceof Error && errorCode(cause) === \"ENOENT\") return undefined;\n throw cause;\n }\n}\n\n/** Produce content only for a missing destination, then atomically publish without clobbering. */\nexport function writeTextIfMissing(\n path: string,\n produceContent: () => string,\n mode = 0o600,\n): WriteStatus {\n // Avoid directory writes for existing entries, including dangling symlinks. The hard link\n // below still provides no-clobber publication if another writer wins after this check.\n if (lstatSync(path, { throwIfNoEntry: false }) !== undefined) return \"unchanged\";\n\n const directory = dirname(path);\n const temporaryPath = join(directory, `.${basename(path)}.${randomUUID()}.tmp`);\n\n try {\n mkdirSync(directory, { recursive: true });\n writeFileSync(temporaryPath, produceContent(), { encoding: \"utf8\", flag: \"wx\", mode });\n try {\n linkSync(temporaryPath, path);\n return \"created\";\n } catch (cause: unknown) {\n if (cause instanceof Error && errorCode(cause) === \"EEXIST\") return \"unchanged\";\n throw cause;\n }\n } finally {\n try {\n rmSync(temporaryPath, { force: true });\n } catch {\n // Cleanup must not mask the write result.\n }\n }\n}\n\nexport function writeTextAtomically(path: string, content: string, mode = 0o644): WriteStatus {\n const current = readTextIfPresent(path);\n if (current === content) return \"unchanged\";\n\n const directory = dirname(path);\n const temporaryPath = join(directory, `.${basename(path)}.${randomUUID()}.tmp`);\n try {\n mkdirSync(directory, { recursive: true });\n writeFileSync(temporaryPath, content, { encoding: \"utf8\", flag: \"wx\", mode });\n renameSync(temporaryPath, path);\n return current === undefined ? \"created\" : \"updated\";\n } finally {\n try {\n rmSync(temporaryPath, { force: true });\n } catch {\n // Cleanup must not mask the write result.\n }\n }\n}\n\n/** Atomically replace complete content while preserving an existing file's permission mode. */\nexport async function writeTextAtomicallyAsync(\n path: string,\n content: string,\n defaultMode = 0o600,\n): Promise<void> {\n let mode = defaultMode;\n try {\n mode = (await stat(path)).mode & 0o777;\n } catch (cause: unknown) {\n if (!(cause instanceof Error) || errorCode(cause) !== \"ENOENT\") throw cause;\n }\n\n const directory = dirname(path);\n const temporaryPath = join(directory, `.${basename(path)}.${randomUUID()}.tmp`);\n await mkdir(directory, { recursive: true });\n try {\n const handle = await open(temporaryPath, \"wx\", mode);\n try {\n await handle.writeFile(content, { encoding: \"utf8\" });\n await handle.sync();\n } finally {\n await handle.close();\n }\n await chmod(temporaryPath, mode);\n await rename(temporaryPath, path);\n } finally {\n try {\n await rm(temporaryPath, { force: true });\n } catch {\n // Cleanup must not mask the write result.\n }\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export { defineExtensionSettings, type ExtensionSettingsLayer, type ExtensionSettingsDefinition, type ExtensionSettingsDefinitionInput, type ResolvedSettings, } from "./definition.ts";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,KAAK,gBAAgB,GACxB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { defineExtensionSettings, } from "./definition.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,GAK1B,MAAM,iBAAiB,CAAC","sourcesContent":["export {\n defineExtensionSettings,\n type ExtensionSettingsLayer,\n type ExtensionSettingsDefinition,\n type ExtensionSettingsDefinitionInput,\n type ResolvedSettings,\n} from \"./definition.ts\";\n"]}