@dev-sergeev/datalab-kit 0.1.2 → 0.1.4

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 (355) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +23 -5
  3. package/THIRD_PARTY_NOTICES.md +6 -2
  4. package/docs/adr/0001-user-settings-priority.md +2 -0
  5. package/docs/adr/0002-package-delivery.md +8 -0
  6. package/node_modules/@pi-plugins/elapsed/LICENSE +21 -0
  7. package/node_modules/@pi-plugins/elapsed/README.md +45 -0
  8. package/node_modules/@pi-plugins/elapsed/dist/index.d.mts +8 -0
  9. package/node_modules/@pi-plugins/elapsed/dist/index.d.mts.map +1 -0
  10. package/node_modules/@pi-plugins/elapsed/dist/index.mjs +47 -0
  11. package/node_modules/@pi-plugins/elapsed/dist/index.mjs.map +1 -0
  12. package/node_modules/@pi-plugins/elapsed/package.json +65 -0
  13. package/node_modules/@tifan/pi-recap/README.md +61 -0
  14. package/node_modules/@tifan/pi-recap/package.json +43 -0
  15. package/node_modules/@tifan/pi-recap/src/index.ts +586 -0
  16. package/node_modules/@tifan/pi-recap/src/model-picker.ts +234 -0
  17. package/node_modules/@tifan/pi-recap/src/models.ts +180 -0
  18. package/node_modules/@tifan/pi-recap/src/sanitize.ts +119 -0
  19. package/node_modules/@tifan/pi-recap/src/tui.ts +155 -0
  20. package/node_modules/@zigai/pi-extension-internals/README.md +24 -0
  21. package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.d.ts +21 -0
  22. package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.js +233 -0
  23. package/node_modules/@zigai/pi-extension-internals/dist/index.d.ts +6 -0
  24. package/node_modules/@zigai/pi-extension-internals/dist/index.js +3 -0
  25. package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.d.ts +34 -0
  26. package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.js +272 -0
  27. package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.d.ts +11 -0
  28. package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.js +139 -0
  29. package/node_modules/@zigai/pi-extension-internals/package.json +41 -0
  30. package/node_modules/@zigai/pi-extension-settings/LICENSE +21 -0
  31. package/node_modules/@zigai/pi-extension-settings/README.md +36 -0
  32. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts +23 -0
  33. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts.map +1 -0
  34. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js +75 -0
  35. package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js.map +1 -0
  36. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts +3 -0
  37. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts.map +1 -0
  38. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js +5 -0
  39. package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js.map +1 -0
  40. package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts +6 -0
  41. package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts.map +1 -0
  42. package/node_modules/@zigai/pi-extension-settings/dist/cli.js +87 -0
  43. package/node_modules/@zigai/pi-extension-settings/dist/cli.js.map +1 -0
  44. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts +2 -0
  45. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts.map +1 -0
  46. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js +2 -0
  47. package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js.map +1 -0
  48. package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts +159 -0
  49. package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts.map +1 -0
  50. package/node_modules/@zigai/pi-extension-settings/dist/definition.js +248 -0
  51. package/node_modules/@zigai/pi-extension-settings/dist/definition.js.map +1 -0
  52. package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts +10 -0
  53. package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts.map +1 -0
  54. package/node_modules/@zigai/pi-extension-settings/dist/file-system.js +115 -0
  55. package/node_modules/@zigai/pi-extension-settings/dist/file-system.js.map +1 -0
  56. package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts +2 -0
  57. package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts.map +1 -0
  58. package/node_modules/@zigai/pi-extension-settings/dist/index.js +2 -0
  59. package/node_modules/@zigai/pi-extension-settings/dist/index.js.map +1 -0
  60. package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts +18 -0
  61. package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts.map +1 -0
  62. package/node_modules/@zigai/pi-extension-settings/dist/json-value.js +56 -0
  63. package/node_modules/@zigai/pi-extension-settings/dist/json-value.js.map +1 -0
  64. package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts +11 -0
  65. package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts.map +1 -0
  66. package/node_modules/@zigai/pi-extension-settings/dist/paths.js +23 -0
  67. package/node_modules/@zigai/pi-extension-settings/dist/paths.js.map +1 -0
  68. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts +5 -0
  69. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts.map +1 -0
  70. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js +21 -0
  71. package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js.map +1 -0
  72. package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts +106 -0
  73. package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts.map +1 -0
  74. package/node_modules/@zigai/pi-extension-settings/dist/pi.js +122 -0
  75. package/node_modules/@zigai/pi-extension-settings/dist/pi.js.map +1 -0
  76. package/node_modules/@zigai/pi-extension-settings/dist/pi.ts +2537 -0
  77. package/node_modules/@zigai/pi-extension-settings/dist/pi.ts.map +7 -0
  78. package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts +10 -0
  79. package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts.map +1 -0
  80. package/node_modules/@zigai/pi-extension-settings/dist/projects.js +177 -0
  81. package/node_modules/@zigai/pi-extension-settings/dist/projects.js.map +1 -0
  82. package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts +40 -0
  83. package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts.map +1 -0
  84. package/node_modules/@zigai/pi-extension-settings/dist/runtime.js +158 -0
  85. package/node_modules/@zigai/pi-extension-settings/dist/runtime.js.map +1 -0
  86. package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts +158 -0
  87. package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts.map +7 -0
  88. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts +19 -0
  89. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts.map +1 -0
  90. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js +168 -0
  91. package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js.map +1 -0
  92. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts +9 -0
  93. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts.map +1 -0
  94. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js +242 -0
  95. package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js.map +1 -0
  96. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts +59 -0
  97. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts.map +1 -0
  98. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js +98 -0
  99. package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js.map +1 -0
  100. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts +80 -0
  101. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts.map +1 -0
  102. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js +144 -0
  103. package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js.map +1 -0
  104. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts +5 -0
  105. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts.map +1 -0
  106. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js +30 -0
  107. package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js.map +1 -0
  108. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts +10 -0
  109. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts.map +1 -0
  110. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js +16 -0
  111. package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js.map +1 -0
  112. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts +54 -0
  113. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts.map +1 -0
  114. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js +202 -0
  115. package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js.map +1 -0
  116. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts +5 -0
  117. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts.map +1 -0
  118. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js +9 -0
  119. package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js.map +1 -0
  120. package/node_modules/@zigai/pi-extension-settings/docs/generation.md +71 -0
  121. package/node_modules/@zigai/pi-extension-settings/docs/manual-setup.md +98 -0
  122. package/node_modules/@zigai/pi-extension-settings/docs/runtime.md +100 -0
  123. package/node_modules/@zigai/pi-extension-settings/docs/ui-controls.md +31 -0
  124. package/node_modules/@zigai/pi-extension-settings/package.json +97 -0
  125. package/node_modules/@zigai/pi-mention-anything/README.md +113 -0
  126. package/node_modules/@zigai/pi-mention-anything/config.schema.json +313 -0
  127. package/node_modules/@zigai/pi-mention-anything/docs/command-protocol.md +106 -0
  128. package/node_modules/@zigai/pi-mention-anything/docs/providers.md +128 -0
  129. package/node_modules/@zigai/pi-mention-anything/examples/query-command.mjs +96 -0
  130. package/node_modules/@zigai/pi-mention-anything/examples/recursive-tree.ts +28 -0
  131. package/node_modules/@zigai/pi-mention-anything/examples/static.ts +28 -0
  132. package/node_modules/@zigai/pi-mention-anything/examples/tmux.ts +90 -0
  133. package/node_modules/@zigai/pi-mention-anything/examples/tree-settings.json +25 -0
  134. package/node_modules/@zigai/pi-mention-anything/package.json +58 -0
  135. package/node_modules/@zigai/pi-mention-anything/src/api.ts +75 -0
  136. package/node_modules/@zigai/pi-mention-anything/src/autocomplete.ts +231 -0
  137. package/node_modules/@zigai/pi-mention-anything/src/chain-autocomplete.ts +596 -0
  138. package/node_modules/@zigai/pi-mention-anything/src/chain-syntax.ts +345 -0
  139. package/node_modules/@zigai/pi-mention-anything/src/command-provider.ts +291 -0
  140. package/node_modules/@zigai/pi-mention-anything/src/configured-source.ts +66 -0
  141. package/node_modules/@zigai/pi-mention-anything/src/editor.ts +180 -0
  142. package/node_modules/@zigai/pi-mention-anything/src/expand-mentions.ts +162 -0
  143. package/node_modules/@zigai/pi-mention-anything/src/index.ts +54 -0
  144. package/node_modules/@zigai/pi-mention-anything/src/initial-suggestions.ts +190 -0
  145. package/node_modules/@zigai/pi-mention-anything/src/list-provider.ts +71 -0
  146. package/node_modules/@zigai/pi-mention-anything/src/mention-hub.ts +307 -0
  147. package/node_modules/@zigai/pi-mention-anything/src/mention-resolution.ts +374 -0
  148. package/node_modules/@zigai/pi-mention-anything/src/mention-syntax.ts +105 -0
  149. package/node_modules/@zigai/pi-mention-anything/src/register-mention.ts +89 -0
  150. package/node_modules/@zigai/pi-mention-anything/src/rendering.ts +53 -0
  151. package/node_modules/@zigai/pi-mention-anything/src/selected-items.ts +21 -0
  152. package/node_modules/@zigai/pi-mention-anything/src/selection-history.ts +135 -0
  153. package/node_modules/@zigai/pi-mention-anything/src/settings-input.ts +317 -0
  154. package/node_modules/@zigai/pi-mention-anything/src/settings.prevalidated.ts +57 -0
  155. package/node_modules/@zigai/pi-mention-anything/src/settings.ts +52 -0
  156. package/node_modules/@zigai/pi-mention-anything/src/source-contract.ts +174 -0
  157. package/node_modules/@zigai/pi-mention-anything/src/source-controller.ts +1070 -0
  158. package/node_modules/@zigai/pi-mention-anything/src/source-runtime.ts +99 -0
  159. package/node_modules/@zigai/pi-mention-skill/README.md +60 -0
  160. package/node_modules/@zigai/pi-mention-skill/config.schema.json +81 -0
  161. package/node_modules/@zigai/pi-mention-skill/package.json +56 -0
  162. package/node_modules/@zigai/pi-mention-skill/src/index.ts +60 -0
  163. package/node_modules/@zigai/pi-mention-skill/src/settings-input.ts +74 -0
  164. package/node_modules/@zigai/pi-mention-skill/src/settings.prevalidated.ts +18 -0
  165. package/node_modules/@zigai/pi-mention-skill/src/settings.ts +54 -0
  166. package/node_modules/@zigai/pi-mention-skill/src/skill-commands.ts +18 -0
  167. package/node_modules/@zigai/pi-mention-skill/src/skill-content.ts +60 -0
  168. package/node_modules/@zigai/pi-mention-skill/src/skill-provider.ts +105 -0
  169. package/node_modules/@zigai/pi-mention-skill/src/slash-skill-filter.ts +29 -0
  170. package/node_modules/argparse/LICENSE +21 -0
  171. package/node_modules/argparse/README.md +257 -0
  172. package/node_modules/argparse/index.js +3 -0
  173. package/node_modules/argparse/lib/action/append/constant.js +47 -0
  174. package/node_modules/argparse/lib/action/append.js +53 -0
  175. package/node_modules/argparse/lib/action/count.js +40 -0
  176. package/node_modules/argparse/lib/action/help.js +47 -0
  177. package/node_modules/argparse/lib/action/store/constant.js +43 -0
  178. package/node_modules/argparse/lib/action/store/false.js +27 -0
  179. package/node_modules/argparse/lib/action/store/true.js +26 -0
  180. package/node_modules/argparse/lib/action/store.js +50 -0
  181. package/node_modules/argparse/lib/action/subparsers.js +149 -0
  182. package/node_modules/argparse/lib/action/version.js +47 -0
  183. package/node_modules/argparse/lib/action.js +146 -0
  184. package/node_modules/argparse/lib/action_container.js +482 -0
  185. package/node_modules/argparse/lib/argparse.js +14 -0
  186. package/node_modules/argparse/lib/argument/error.js +50 -0
  187. package/node_modules/argparse/lib/argument/exclusive.js +54 -0
  188. package/node_modules/argparse/lib/argument/group.js +75 -0
  189. package/node_modules/argparse/lib/argument_parser.js +1161 -0
  190. package/node_modules/argparse/lib/const.js +21 -0
  191. package/node_modules/argparse/lib/help/added_formatters.js +87 -0
  192. package/node_modules/argparse/lib/help/formatter.js +795 -0
  193. package/node_modules/argparse/lib/namespace.js +76 -0
  194. package/node_modules/argparse/lib/utils.js +57 -0
  195. package/node_modules/argparse/package.json +34 -0
  196. package/node_modules/esprima/LICENSE.BSD +21 -0
  197. package/node_modules/esprima/README.md +46 -0
  198. package/node_modules/esprima/bin/esparse.js +139 -0
  199. package/node_modules/esprima/bin/esvalidate.js +236 -0
  200. package/node_modules/esprima/dist/esprima.js +6709 -0
  201. package/node_modules/esprima/package.json +112 -0
  202. package/node_modules/extend-shallow/LICENSE +21 -0
  203. package/node_modules/extend-shallow/README.md +61 -0
  204. package/node_modules/extend-shallow/index.js +33 -0
  205. package/node_modules/extend-shallow/package.json +56 -0
  206. package/node_modules/graceful-fs/LICENSE +15 -0
  207. package/node_modules/graceful-fs/README.md +143 -0
  208. package/node_modules/graceful-fs/clone.js +23 -0
  209. package/node_modules/graceful-fs/graceful-fs.js +448 -0
  210. package/node_modules/graceful-fs/legacy-streams.js +118 -0
  211. package/node_modules/graceful-fs/package.json +53 -0
  212. package/node_modules/graceful-fs/polyfills.js +355 -0
  213. package/node_modules/gray-matter/LICENSE +21 -0
  214. package/node_modules/gray-matter/README.md +565 -0
  215. package/node_modules/gray-matter/gray-matter.d.ts +114 -0
  216. package/node_modules/gray-matter/index.js +228 -0
  217. package/node_modules/gray-matter/lib/defaults.js +18 -0
  218. package/node_modules/gray-matter/lib/engine.js +30 -0
  219. package/node_modules/gray-matter/lib/engines.js +54 -0
  220. package/node_modules/gray-matter/lib/excerpt.js +32 -0
  221. package/node_modules/gray-matter/lib/parse.js +13 -0
  222. package/node_modules/gray-matter/lib/stringify.js +56 -0
  223. package/node_modules/gray-matter/lib/to-file.js +43 -0
  224. package/node_modules/gray-matter/lib/utils.js +66 -0
  225. package/node_modules/gray-matter/package.json +127 -0
  226. package/node_modules/is-extendable/LICENSE +21 -0
  227. package/node_modules/is-extendable/README.md +72 -0
  228. package/node_modules/is-extendable/index.js +13 -0
  229. package/node_modules/is-extendable/package.json +51 -0
  230. package/node_modules/js-yaml/LICENSE +21 -0
  231. package/node_modules/js-yaml/README.md +302 -0
  232. package/node_modules/js-yaml/bin/js-yaml.js +132 -0
  233. package/node_modules/js-yaml/dist/js-yaml.js +4024 -0
  234. package/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  235. package/node_modules/js-yaml/index.js +7 -0
  236. package/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  237. package/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  238. package/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  239. package/node_modules/js-yaml/lib/js-yaml/loader.js +1679 -0
  240. package/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  241. package/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  242. package/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  243. package/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  244. package/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  245. package/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  246. package/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  247. package/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  248. package/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  249. package/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  250. package/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  251. package/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  252. package/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  253. package/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  254. package/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  255. package/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  256. package/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  257. package/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  258. package/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  259. package/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  260. package/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  261. package/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  262. package/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  263. package/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  264. package/node_modules/js-yaml/lib/js-yaml.js +39 -0
  265. package/node_modules/js-yaml/package.json +52 -0
  266. package/node_modules/kind-of/LICENSE +21 -0
  267. package/node_modules/kind-of/README.md +367 -0
  268. package/node_modules/kind-of/index.js +129 -0
  269. package/node_modules/kind-of/package.json +88 -0
  270. package/node_modules/node-addon-api/common 2.gypi +21 -0
  271. package/node_modules/node-addon-api/except 2.gypi +25 -0
  272. package/node_modules/node-addon-api/napi 2.h +3463 -0
  273. package/node_modules/node-addon-api/napi-inl 2.h +7250 -0
  274. package/node_modules/node-addon-api/napi-inl.deprecated 2.h +186 -0
  275. package/node_modules/node-addon-api/node_addon_api 2.gyp +42 -0
  276. package/node_modules/node-addon-api/node_api 2.gyp +9 -0
  277. package/node_modules/node-addon-api/noexcept 2.gypi +26 -0
  278. package/node_modules/node-addon-api/nothing 2.c +0 -0
  279. package/node_modules/pi-toggle-skills/README.md +213 -0
  280. package/node_modules/pi-toggle-skills/package.json +60 -0
  281. package/node_modules/pi-toggle-skills/src/index.ts +112 -0
  282. package/node_modules/pi-toggle-skills/src/skill-discovery.ts +258 -0
  283. package/node_modules/pi-toggle-skills/src/skill-selector.ts +435 -0
  284. package/node_modules/pi-toggle-skills/toggle-skills 2.ts +316 -0
  285. package/node_modules/pi-toggle-skills/toggle-skills.ts +316 -0
  286. package/node_modules/pi-toggle-skills/vitest.config 2.ts +15 -0
  287. package/node_modules/pi-toggle-skills/vitest.config.ts +15 -0
  288. package/node_modules/proper-lockfile/LICENSE +21 -0
  289. package/node_modules/proper-lockfile/README.md +183 -0
  290. package/node_modules/proper-lockfile/index.js +40 -0
  291. package/node_modules/proper-lockfile/lib/adapter.js +85 -0
  292. package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
  293. package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
  294. package/node_modules/proper-lockfile/node_modules/retry/.npmignore +3 -0
  295. package/node_modules/proper-lockfile/node_modules/retry/.travis.yml +15 -0
  296. package/node_modules/proper-lockfile/node_modules/retry/License +21 -0
  297. package/node_modules/proper-lockfile/node_modules/retry/Makefile +18 -0
  298. package/node_modules/proper-lockfile/node_modules/retry/README.md +227 -0
  299. package/node_modules/proper-lockfile/node_modules/retry/equation.gif +0 -0
  300. package/node_modules/proper-lockfile/node_modules/retry/example/dns.js +31 -0
  301. package/node_modules/proper-lockfile/node_modules/retry/example/stop.js +40 -0
  302. package/node_modules/proper-lockfile/node_modules/retry/index.js +1 -0
  303. package/node_modules/proper-lockfile/node_modules/retry/lib/retry.js +100 -0
  304. package/node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js +158 -0
  305. package/node_modules/proper-lockfile/node_modules/retry/package.json +32 -0
  306. package/node_modules/proper-lockfile/node_modules/retry/test/common.js +10 -0
  307. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-forever.js +24 -0
  308. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-operation.js +258 -0
  309. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
  310. package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-timeouts.js +69 -0
  311. package/node_modules/proper-lockfile/package.json +71 -0
  312. package/node_modules/section-matter/LICENSE +21 -0
  313. package/node_modules/section-matter/README.md +236 -0
  314. package/node_modules/section-matter/index.js +136 -0
  315. package/node_modules/section-matter/package.json +55 -0
  316. package/node_modules/signal-exit/LICENSE.txt +16 -0
  317. package/node_modules/signal-exit/README.md +39 -0
  318. package/node_modules/signal-exit/index.js +202 -0
  319. package/node_modules/signal-exit/package.json +38 -0
  320. package/node_modules/signal-exit/signals.js +53 -0
  321. package/node_modules/sprintf-js/.npmignore +1 -0
  322. package/node_modules/sprintf-js/.npmignore 2 +1 -0
  323. package/node_modules/sprintf-js/LICENSE +24 -0
  324. package/node_modules/sprintf-js/LICENSE 2 +24 -0
  325. package/node_modules/sprintf-js/README 2.md +88 -0
  326. package/node_modules/sprintf-js/README.md +88 -0
  327. package/node_modules/sprintf-js/bower 2.json +14 -0
  328. package/node_modules/sprintf-js/bower.json +14 -0
  329. package/node_modules/sprintf-js/demo/angular.html +20 -0
  330. package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  331. package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  332. package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  333. package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  334. package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  335. package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  336. package/node_modules/sprintf-js/gruntfile 2.js +36 -0
  337. package/node_modules/sprintf-js/gruntfile.js +36 -0
  338. package/node_modules/sprintf-js/package 2.json +22 -0
  339. package/node_modules/sprintf-js/package.json +22 -0
  340. package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  341. package/node_modules/sprintf-js/src/sprintf.js +208 -0
  342. package/node_modules/sprintf-js/test/test.js +82 -0
  343. package/node_modules/strip-bom-string/LICENSE +21 -0
  344. package/node_modules/strip-bom-string/README.md +66 -0
  345. package/node_modules/strip-bom-string/index.js +15 -0
  346. package/node_modules/strip-bom-string/package.json +60 -0
  347. package/node_modules/tree-sitter-bash/tree-sitter-bash 2.wasm +0 -0
  348. package/node_modules/typebox/license 2 +23 -0
  349. package/node_modules/typebox/package 2.json +87 -0
  350. package/node_modules/typebox/readme 2.md +370 -0
  351. package/node_modules/zod/compile 2.cjs +96 -0
  352. package/node_modules/zod/compile 2.js +52 -0
  353. package/node_modules/zod/index 2.cjs +52 -0
  354. package/node_modules/zod/index 2.js +7 -0
  355. package/package.json +13 -4
@@ -0,0 +1,202 @@
1
+ import { mkdir } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import { isDeepStrictEqual } from "node:util";
4
+ import lockfile from "proper-lockfile";
5
+ import { readTextIfPresentAsync, writeTextAtomicallyAsync } from "./file-system.js";
6
+ import { cloneJson, formatJson, isJsonObject, JsonValueSchema, } from "./json-value.js";
7
+ import { Value } from "./typebox-runtime.js";
8
+ import { createSettingsDocument, createSettingsFileSchema } from "./schema-document.js";
9
+ import { applySettingsLayer, parseSettingsLayer, settingsValidationIssues, } from "./settings-layer.js";
10
+ import { mergeSettings } from "./settings-merge.js";
11
+ import { createSettingsRevision } from "./settings-revision.js";
12
+ class SettingsPersistenceError extends Error {
13
+ constructor(cause) {
14
+ super("The settings transaction could not access persistent storage.", { cause });
15
+ }
16
+ }
17
+ async function persistently(operation) {
18
+ try {
19
+ return await operation();
20
+ }
21
+ catch (cause) {
22
+ throw new SettingsPersistenceError(cause);
23
+ }
24
+ }
25
+ function typedSettingsLayer(schema, value) {
26
+ return isJsonObject(value) && !("$schema" in value) && Value.Check(schema, value);
27
+ }
28
+ function parseExistingLayer(path, scope, text, layerSchema) {
29
+ if (text === undefined) {
30
+ return {
31
+ status: "valid",
32
+ settings: {},
33
+ schemaReference: undefined,
34
+ };
35
+ }
36
+ const parsedLayer = parseSettingsLayer(path, scope, text, layerSchema);
37
+ if (parsedLayer.settings === undefined) {
38
+ return { status: "invalid", diagnostics: parsedLayer.diagnostics };
39
+ }
40
+ return {
41
+ status: "valid",
42
+ settings: parsedLayer.settings,
43
+ schemaReference: parsedLayer.schemaReference,
44
+ };
45
+ }
46
+ function invalidExisting(diagnostics) {
47
+ return {
48
+ status: "invalid-existing",
49
+ message: diagnostics[0]?.message ?? "The existing settings are invalid.",
50
+ diagnostics,
51
+ };
52
+ }
53
+ function invalidUpdate(message, issues) {
54
+ return { status: "invalid-update", message, issues };
55
+ }
56
+ async function withInterprocessLocks(paths, operation, index = 0) {
57
+ const path = paths[index];
58
+ if (path === undefined)
59
+ return operation();
60
+ await persistently(() => mkdir(dirname(path), { recursive: true }));
61
+ const release = await persistently(() => lockfile.lock(path, {
62
+ realpath: false,
63
+ retries: {
64
+ retries: 20,
65
+ factor: 1.25,
66
+ minTimeout: 10,
67
+ maxTimeout: 100,
68
+ randomize: true,
69
+ },
70
+ }));
71
+ try {
72
+ return await withInterprocessLocks(paths, operation, index + 1);
73
+ }
74
+ finally {
75
+ await persistently(release);
76
+ }
77
+ }
78
+ async function runSettingsTransaction(definition, options) {
79
+ const layerSchema = createSettingsFileSchema(definition);
80
+ const expectedSchema = formatJson(layerSchema);
81
+ const installedSchema = await persistently(() => readTextIfPresentAsync(options.paths.global.schemaPath));
82
+ if (installedSchema !== expectedSchema) {
83
+ return {
84
+ status: "conflict",
85
+ reason: "schema-changed",
86
+ message: "The installed settings schema changed; reload the extension before saving.",
87
+ };
88
+ }
89
+ const globalText = await persistently(() => readTextIfPresentAsync(options.paths.global.configPath));
90
+ const projectText = options.scope === "project"
91
+ ? await persistently(() => readTextIfPresentAsync(options.paths.project.configPath))
92
+ : undefined;
93
+ const revision = options.scope === "global"
94
+ ? createSettingsRevision(globalText)
95
+ : createSettingsRevision(globalText, projectText);
96
+ if (options.expectedRevision !== undefined && options.expectedRevision !== revision) {
97
+ return {
98
+ status: "conflict",
99
+ reason: "settings-changed",
100
+ message: "The settings changed after they were loaded; reload before saving.",
101
+ };
102
+ }
103
+ const globalResult = parseExistingLayer(options.paths.global.configPath, "global", globalText, layerSchema);
104
+ if (globalResult.status === "invalid")
105
+ return invalidExisting(globalResult.diagnostics);
106
+ const globalApplied = applySettingsLayer(definition.schema, definition.defaultSettings, globalResult, options.paths.global.configPath, "global");
107
+ if (globalApplied.diagnostic !== undefined) {
108
+ return invalidExisting([globalApplied.diagnostic]);
109
+ }
110
+ let currentLayer = globalResult;
111
+ let validationBase = definition.defaultSettings;
112
+ if (options.scope === "project") {
113
+ const projectResult = parseExistingLayer(options.paths.project.configPath, "project", projectText, layerSchema);
114
+ if (projectResult.status === "invalid")
115
+ return invalidExisting(projectResult.diagnostics);
116
+ const projectApplied = applySettingsLayer(definition.schema, globalApplied.settings, projectResult, options.paths.project.configPath, "project");
117
+ if (projectApplied.diagnostic !== undefined) {
118
+ return invalidExisting([projectApplied.diagnostic]);
119
+ }
120
+ currentLayer = projectResult;
121
+ validationBase = globalApplied.settings;
122
+ }
123
+ const currentForUpdate = cloneJson(currentLayer.settings);
124
+ if (!typedSettingsLayer(layerSchema, currentForUpdate)) {
125
+ throw new TypeError("A validated settings layer unexpectedly failed its encoded schema.");
126
+ }
127
+ const candidate = options.update(currentForUpdate);
128
+ let candidateJson;
129
+ try {
130
+ candidateJson = Value.Parse(JsonValueSchema, candidate);
131
+ }
132
+ catch {
133
+ return invalidUpdate("The settings updater must return a JSON object.", [
134
+ { path: "/", message: "Expected a JSON object" },
135
+ ]);
136
+ }
137
+ if (!isJsonObject(candidateJson)) {
138
+ return invalidUpdate("The settings updater must return a JSON object.", [
139
+ { path: "/", message: "Expected a JSON object" },
140
+ ]);
141
+ }
142
+ if ("$schema" in candidateJson) {
143
+ return invalidUpdate("The settings updater cannot modify $schema metadata.", [
144
+ { path: "/$schema", message: "$schema is reserved for editor metadata" },
145
+ ]);
146
+ }
147
+ if (!Value.Check(layerSchema, candidateJson)) {
148
+ return invalidUpdate("The settings update does not match the extension schema.", settingsValidationIssues(layerSchema, candidateJson));
149
+ }
150
+ const nextLayer = cloneJson(candidateJson);
151
+ const resolved = mergeSettings(validationBase, nextLayer);
152
+ if (!Value.Check(definition.schema, resolved)) {
153
+ return invalidUpdate("The settings update conflicts with the resolved configuration.", settingsValidationIssues(definition.schema, resolved));
154
+ }
155
+ try {
156
+ Value.Decode(Value.Clone(definition.schema), resolved);
157
+ }
158
+ catch {
159
+ return invalidUpdate("The settings update could not be decoded.", [
160
+ { path: "/", message: "The resolved settings codec rejected the update" },
161
+ ]);
162
+ }
163
+ if (isDeepStrictEqual(currentLayer.settings, nextLayer)) {
164
+ return { status: "unchanged", revision };
165
+ }
166
+ const targetPaths = options.scope === "global" ? options.paths.global : options.paths.project;
167
+ const schemaReference = currentLayer.schemaReference ??
168
+ (options.scope === "global" ? targetPaths.schemaReference : definition.schemaId);
169
+ const content = formatJson(createSettingsDocument(definition.id, nextLayer, schemaReference));
170
+ await persistently(() => writeTextAtomicallyAsync(targetPaths.configPath, content));
171
+ const nextRevision = options.scope === "global"
172
+ ? createSettingsRevision(content)
173
+ : createSettingsRevision(globalText, content);
174
+ return { status: "updated", revision: nextRevision };
175
+ }
176
+ export async function updateSettingsTransaction(definition, options) {
177
+ if (options.scope === "project" && !options.projectTrusted) {
178
+ return {
179
+ status: "blocked",
180
+ reason: "project-untrusted",
181
+ message: "Project settings can only be updated for a trusted project.",
182
+ };
183
+ }
184
+ const lockPaths = options.scope === "global"
185
+ ? [options.paths.global.configPath]
186
+ : [options.paths.global.configPath, options.paths.project.configPath].sort();
187
+ try {
188
+ return await withInterprocessLocks(lockPaths, () => runSettingsTransaction(definition, options));
189
+ }
190
+ catch (cause) {
191
+ if (cause instanceof SettingsPersistenceError) {
192
+ return {
193
+ status: "failed",
194
+ message: `The ${options.scope} settings transaction failed.`,
195
+ };
196
+ }
197
+ if (cause instanceof Error)
198
+ throw cause;
199
+ throw new Error("The settings transaction threw a non-Error value.", { cause });
200
+ }
201
+ }
202
+ //# sourceMappingURL=settings-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-transaction.js","sourceRoot":"","sources":["../src/settings-transaction.ts"],"names":[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AAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACtB,IAAI,KAAK,YAAY,wBAAwB,EAAE,CAAC;YAC5C,OAAO;gBACH,MAAM,EAAE,QAAQ;gBAChB,OAAO,EAAE,OAAO,OAAO,CAAC,KAAK,+BAA+B;aAC/D,CAAC;QACN,CAAC;QACD,IAAI,KAAK,YAAY,KAAK;YAAE,MAAM,KAAK,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mDAAmD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,CAAC;AACL,CAAC","sourcesContent":["import { mkdir } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport { isDeepStrictEqual } from \"node:util\";\n\nimport lockfile from \"proper-lockfile\";\nimport type { TObject, TSchema } from \"typebox\";\n\nimport type { ExtensionSettingsDefinition, ExtensionSettingsLayer } from \"./definition.ts\";\nimport { readTextIfPresentAsync, writeTextAtomicallyAsync } from \"./file-system.ts\";\nimport {\n cloneJson,\n formatJson,\n isJsonObject,\n JsonValueSchema,\n type JsonObject,\n} from \"./json-value.ts\";\nimport { Value } from \"./typebox-runtime.ts\";\nimport type { ExtensionSettingsPaths } from \"./paths.ts\";\nimport { createSettingsDocument, createSettingsFileSchema } from \"./schema-document.ts\";\nimport {\n applySettingsLayer,\n parseSettingsLayer,\n settingsValidationIssues,\n type SettingsDiagnostic,\n type SettingsScope,\n type SettingsValidationIssue,\n} from \"./settings-layer.ts\";\nimport { mergeSettings } from \"./settings-merge.ts\";\nimport { createSettingsRevision, type PiSettingsRevision } from \"./settings-revision.ts\";\n\nexport type PiSettingsUpdateScope = \"global\" | \"project\";\n\nexport type PiSettingsUpdateIssue = SettingsValidationIssue;\n\nexport type UpdatePiExtensionSettingsOptions<Schema extends TObject> = {\n /** Settings layer to update. Project updates require a trusted project. */\n readonly scope: PiSettingsUpdateScope;\n /** Reject the update if the relevant sources no longer match this loader revision. */\n readonly expectedRevision?: PiSettingsRevision;\n /**\n * Produce the next encoded settings layer from the latest valid layer.\n *\n * The callback is invoked once, synchronously, while the settings transaction is locked. It may\n * return a copy or mutate and return the supplied clone. Throwing an `Error` aborts the\n * transaction and rejects `updatePiExtensionSettings` with the same error.\n */\n readonly update: (current: ExtensionSettingsLayer<Schema>) => ExtensionSettingsLayer<Schema>;\n};\n\nexport type UpdatePiExtensionSettingsResult =\n | {\n readonly status: \"updated\" | \"unchanged\";\n readonly revision: PiSettingsRevision;\n }\n | {\n readonly status: \"conflict\";\n readonly reason: \"schema-changed\" | \"settings-changed\";\n readonly message: string;\n }\n | {\n readonly status: \"blocked\";\n readonly reason: \"project-untrusted\";\n readonly message: string;\n }\n | {\n readonly status: \"invalid-existing\";\n readonly message: string;\n readonly diagnostics: readonly SettingsDiagnostic[];\n }\n | {\n readonly status: \"invalid-update\";\n readonly message: string;\n readonly issues: readonly PiSettingsUpdateIssue[];\n }\n | {\n readonly status: \"failed\";\n readonly message: string;\n };\n\nexport type SettingsTransactionPaths = {\n readonly global: ExtensionSettingsPaths;\n readonly project: ExtensionSettingsPaths;\n};\n\nexport type SettingsTransactionOptions<Schema extends TObject> =\n UpdatePiExtensionSettingsOptions<Schema> & {\n readonly paths: SettingsTransactionPaths;\n readonly projectTrusted: boolean;\n };\n\ntype ExistingLayerResult =\n | {\n readonly status: \"valid\";\n readonly settings: JsonObject;\n readonly schemaReference: string | undefined;\n }\n | {\n readonly status: \"invalid\";\n readonly diagnostics: readonly SettingsDiagnostic[];\n };\n\nclass SettingsPersistenceError extends Error {\n constructor(cause: unknown) {\n super(\"The settings transaction could not access persistent storage.\", { cause });\n }\n}\n\nasync function persistently<Result>(operation: () => Promise<Result>): Promise<Result> {\n try {\n return await operation();\n } catch (cause: unknown) {\n throw new SettingsPersistenceError(cause);\n }\n}\n\nfunction typedSettingsLayer<Schema extends TObject>(\n schema: TSchema,\n value: JsonObject,\n): value is JsonObject & ExtensionSettingsLayer<Schema> {\n return isJsonObject(value) && !(\"$schema\" in value) && Value.Check(schema, value);\n}\n\nfunction parseExistingLayer(\n path: string,\n scope: SettingsScope,\n text: string | undefined,\n layerSchema: TSchema,\n): ExistingLayerResult {\n if (text === undefined) {\n return {\n status: \"valid\",\n settings: {},\n schemaReference: undefined,\n };\n }\n\n const parsedLayer = parseSettingsLayer(path, scope, text, layerSchema);\n if (parsedLayer.settings === undefined) {\n return { status: \"invalid\", diagnostics: parsedLayer.diagnostics };\n }\n return {\n status: \"valid\",\n settings: parsedLayer.settings,\n schemaReference: parsedLayer.schemaReference,\n };\n}\n\nfunction invalidExisting(\n diagnostics: readonly SettingsDiagnostic[],\n): UpdatePiExtensionSettingsResult {\n return {\n status: \"invalid-existing\",\n message: diagnostics[0]?.message ?? \"The existing settings are invalid.\",\n diagnostics,\n };\n}\n\nfunction invalidUpdate(\n message: string,\n issues: readonly PiSettingsUpdateIssue[],\n): UpdatePiExtensionSettingsResult {\n return { status: \"invalid-update\", message, issues };\n}\n\nasync function withInterprocessLocks<Result>(\n paths: readonly string[],\n operation: () => Promise<Result>,\n index = 0,\n): Promise<Result> {\n const path = paths[index];\n if (path === undefined) return operation();\n\n await persistently(() => mkdir(dirname(path), { recursive: true }));\n const release = await persistently(() =>\n lockfile.lock(path, {\n realpath: false,\n retries: {\n retries: 20,\n factor: 1.25,\n minTimeout: 10,\n maxTimeout: 100,\n randomize: true,\n },\n }),\n );\n try {\n return await withInterprocessLocks(paths, operation, index + 1);\n } finally {\n await persistently(release);\n }\n}\n\nasync function runSettingsTransaction<Schema extends TObject>(\n definition: ExtensionSettingsDefinition<Schema>,\n options: SettingsTransactionOptions<Schema>,\n): Promise<UpdatePiExtensionSettingsResult> {\n const layerSchema = createSettingsFileSchema(definition);\n const expectedSchema = formatJson(layerSchema);\n const installedSchema = await persistently(() =>\n readTextIfPresentAsync(options.paths.global.schemaPath),\n );\n if (installedSchema !== expectedSchema) {\n return {\n status: \"conflict\",\n reason: \"schema-changed\",\n message: \"The installed settings schema changed; reload the extension before saving.\",\n };\n }\n\n const globalText = await persistently(() =>\n readTextIfPresentAsync(options.paths.global.configPath),\n );\n const projectText =\n options.scope === \"project\"\n ? await persistently(() => readTextIfPresentAsync(options.paths.project.configPath))\n : undefined;\n const revision =\n options.scope === \"global\"\n ? createSettingsRevision(globalText)\n : createSettingsRevision(globalText, projectText);\n if (options.expectedRevision !== undefined && options.expectedRevision !== revision) {\n return {\n status: \"conflict\",\n reason: \"settings-changed\",\n message: \"The settings changed after they were loaded; reload before saving.\",\n };\n }\n\n const globalResult = parseExistingLayer(\n options.paths.global.configPath,\n \"global\",\n globalText,\n layerSchema,\n );\n if (globalResult.status === \"invalid\") return invalidExisting(globalResult.diagnostics);\n\n const globalApplied = applySettingsLayer(\n definition.schema,\n definition.defaultSettings,\n globalResult,\n options.paths.global.configPath,\n \"global\",\n );\n if (globalApplied.diagnostic !== undefined) {\n return invalidExisting([globalApplied.diagnostic]);\n }\n\n let currentLayer = globalResult;\n let validationBase = definition.defaultSettings;\n if (options.scope === \"project\") {\n const projectResult = parseExistingLayer(\n options.paths.project.configPath,\n \"project\",\n projectText,\n layerSchema,\n );\n if (projectResult.status === \"invalid\") return invalidExisting(projectResult.diagnostics);\n\n const projectApplied = applySettingsLayer(\n definition.schema,\n globalApplied.settings,\n projectResult,\n options.paths.project.configPath,\n \"project\",\n );\n if (projectApplied.diagnostic !== undefined) {\n return invalidExisting([projectApplied.diagnostic]);\n }\n currentLayer = projectResult;\n validationBase = globalApplied.settings;\n }\n\n const currentForUpdate = cloneJson(currentLayer.settings);\n if (!typedSettingsLayer<Schema>(layerSchema, currentForUpdate)) {\n throw new TypeError(\"A validated settings layer unexpectedly failed its encoded schema.\");\n }\n\n const candidate: unknown = options.update(currentForUpdate);\n let candidateJson;\n try {\n candidateJson = Value.Parse(JsonValueSchema, candidate);\n } catch {\n return invalidUpdate(\"The settings updater must return a JSON object.\", [\n { path: \"/\", message: \"Expected a JSON object\" },\n ]);\n }\n if (!isJsonObject(candidateJson)) {\n return invalidUpdate(\"The settings updater must return a JSON object.\", [\n { path: \"/\", message: \"Expected a JSON object\" },\n ]);\n }\n if (\"$schema\" in candidateJson) {\n return invalidUpdate(\"The settings updater cannot modify $schema metadata.\", [\n { path: \"/$schema\", message: \"$schema is reserved for editor metadata\" },\n ]);\n }\n if (!Value.Check(layerSchema, candidateJson)) {\n return invalidUpdate(\n \"The settings update does not match the extension schema.\",\n settingsValidationIssues(layerSchema, candidateJson),\n );\n }\n\n const nextLayer = cloneJson(candidateJson);\n const resolved = mergeSettings(validationBase, nextLayer);\n if (!Value.Check(definition.schema, resolved)) {\n return invalidUpdate(\n \"The settings update conflicts with the resolved configuration.\",\n settingsValidationIssues(definition.schema, resolved),\n );\n }\n try {\n Value.Decode(Value.Clone(definition.schema), resolved);\n } catch {\n return invalidUpdate(\"The settings update could not be decoded.\", [\n { path: \"/\", message: \"The resolved settings codec rejected the update\" },\n ]);\n }\n\n if (isDeepStrictEqual(currentLayer.settings, nextLayer)) {\n return { status: \"unchanged\", revision };\n }\n\n const targetPaths = options.scope === \"global\" ? options.paths.global : options.paths.project;\n const schemaReference =\n currentLayer.schemaReference ??\n (options.scope === \"global\" ? targetPaths.schemaReference : definition.schemaId);\n const content = formatJson(createSettingsDocument(definition.id, nextLayer, schemaReference));\n await persistently(() => writeTextAtomicallyAsync(targetPaths.configPath, content));\n const nextRevision =\n options.scope === \"global\"\n ? createSettingsRevision(content)\n : createSettingsRevision(globalText, content);\n return { status: \"updated\", revision: nextRevision };\n}\n\nexport async function updateSettingsTransaction<Schema extends TObject>(\n definition: ExtensionSettingsDefinition<Schema>,\n options: SettingsTransactionOptions<Schema>,\n): Promise<UpdatePiExtensionSettingsResult> {\n if (options.scope === \"project\" && !options.projectTrusted) {\n return {\n status: \"blocked\",\n reason: \"project-untrusted\",\n message: \"Project settings can only be updated for a trusted project.\",\n };\n }\n\n const lockPaths =\n options.scope === \"global\"\n ? [options.paths.global.configPath]\n : [options.paths.global.configPath, options.paths.project.configPath].sort();\n try {\n return await withInterprocessLocks(lockPaths, () =>\n runSettingsTransaction(definition, options),\n );\n } catch (cause: unknown) {\n if (cause instanceof SettingsPersistenceError) {\n return {\n status: \"failed\",\n message: `The ${options.scope} settings transaction failed.`,\n };\n }\n if (cause instanceof Error) throw cause;\n throw new Error(\"The settings transaction threw a non-Error value.\", { cause });\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const Typebox: typeof import("typebox");
2
+ export declare const IsSchema: typeof import("typebox").IsSchema;
3
+ export declare const Type: typeof import("typebox").Type;
4
+ export declare const Value: typeof import("typebox/value").Value;
5
+ //# sourceMappingURL=typebox-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typebox-runtime.d.ts","sourceRoot":"","sources":["../src/typebox-runtime.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,EAAE,cAAc,SAAS,CAAW,CAAC;AACzD,eAAO,MAAM,QAAQ,EAAE,cAAc,SAAS,EAAE,QAA2B,CAAC;AAC5E,eAAO,MAAM,IAAI,EAAE,cAAc,SAAS,EAAE,IAAmB,CAAC;AAChE,eAAO,MAAM,KAAK,EAAE,cAAc,eAAe,EAAE,KAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import * as typebox from "typebox";
2
+ import { Value as typeboxValue } from "typebox/value";
3
+ // Pi-facing runtime bundles retain these as externals in generated .ts entries, so Pi's loader
4
+ // supplies the host-owned TypeBox modules. Authoring/CLI code resolves the package peer normally.
5
+ export const Typebox = typebox;
6
+ export const IsSchema = typebox.IsSchema;
7
+ export const Type = typebox.Type;
8
+ export const Value = typeboxValue;
9
+ //# sourceMappingURL=typebox-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typebox-runtime.js","sourceRoot":"","sources":["../src/typebox-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtD,+FAA+F;AAC/F,kGAAkG;AAClG,MAAM,CAAC,MAAM,OAAO,GAA6B,OAAO,CAAC;AACzD,MAAM,CAAC,MAAM,QAAQ,GAAsC,OAAO,CAAC,QAAQ,CAAC;AAC5E,MAAM,CAAC,MAAM,IAAI,GAAkC,OAAO,CAAC,IAAI,CAAC;AAChE,MAAM,CAAC,MAAM,KAAK,GAAyC,YAAY,CAAC","sourcesContent":["import * as typebox from \"typebox\";\nimport { Value as typeboxValue } from \"typebox/value\";\n\n// Pi-facing runtime bundles retain these as externals in generated .ts entries, so Pi's loader\n// supplies the host-owned TypeBox modules. Authoring/CLI code resolves the package peer normally.\nexport const Typebox: typeof import(\"typebox\") = typebox;\nexport const IsSchema: typeof import(\"typebox\").IsSchema = typebox.IsSchema;\nexport const Type: typeof import(\"typebox\").Type = typebox.Type;\nexport const Value: typeof import(\"typebox/value\").Value = typeboxValue;\n"]}
@@ -0,0 +1,71 @@
1
+ # Generated artifacts and commands
2
+
3
+ The CLI turns each package's `piExtensionSettings` manifest into checked-in artifacts. It supports a standalone package and npm workspaces.
4
+
5
+ ## Manifest
6
+
7
+ ```json
8
+ {
9
+ "piExtensionSettings": {
10
+ "definition": "./src/settings-input.ts",
11
+ "prevalidation": "./src/settings.prevalidated.ts"
12
+ }
13
+ }
14
+ ```
15
+
16
+ | Field | Required | Default | Purpose |
17
+ | --------------- | -------- | ------------------------- | ----------------------------------------------------------------------------------- |
18
+ | `definition` | yes | — | TypeScript module whose default export is a settings definition or definition input |
19
+ | `prevalidation` | no | — | Generated runtime artifact path |
20
+ | `schema` | no | `config.schema.json` | Generated JSON Schema path |
21
+ | `readme` | no | `README.md` | README whose marked configuration section is generated |
22
+ | `globalPath` | no | Pi's standard global path | Display path used in generated README documentation |
23
+
24
+ Every configured path must be relative and remain inside its package. The README must already exist. If the package uses a `files` allowlist, its published artifact must include the definition and prevalidation modules named by the manifest.
25
+
26
+ Definitions may include `exampleSettings` when structured or interacting options benefit from a realistic non-default example. Generation validates the example and includes it in the generated README section.
27
+
28
+ ## Generate artifacts
29
+
30
+ ```sh
31
+ pi-extension-settings generate
32
+ ```
33
+
34
+ `generate` imports and validates each discovered definition, then updates the JSON Schema, optional prevalidation artifact, and marked README section. Invalid inputs fail before writes begin, and current files remain unchanged.
35
+
36
+ The command mutates checked-in files. Projects can run it explicitly or through their preferred authoring automation.
37
+
38
+ ## Verify artifacts
39
+
40
+ ```sh
41
+ pi-extension-settings check
42
+ ```
43
+
44
+ `check` performs the same discovery and validation without modifying files. It fails for invalid inputs and missing or stale artifacts, making it suitable for pre-commit, CI, verification, and release gates.
45
+
46
+ For prevalidated definitions, `check` also compares codec function text and non-enumerable schema metadata. Runtime hydration checks the JSON-visible contract only: Pi and bundlers can rewrite equivalent codec functions. Run `generate` and `check` against the authoring source before packaging.
47
+
48
+ ## Package scripts
49
+
50
+ Short package scripts keep automation independent of the installed CLI path:
51
+
52
+ ```json
53
+ {
54
+ "scripts": {
55
+ "config:generate": "pi-extension-settings generate",
56
+ "config:check": "pi-extension-settings check"
57
+ }
58
+ }
59
+ ```
60
+
61
+ These names are conventions, not requirements. Include `config:check` in the package's canonical verification command so stale generated files cannot be released.
62
+
63
+ ## Roots and workspaces
64
+
65
+ Commands use the current directory by default. Pass `--root` for another package or npm workspace root:
66
+
67
+ ```sh
68
+ pi-extension-settings check --root ./path/to/repository
69
+ ```
70
+
71
+ At a workspace root, the CLI reads the root package and packages matched by its npm `workspaces` patterns. Only packages with a `piExtensionSettings` manifest participate.
@@ -0,0 +1,98 @@
1
+ # Add settings to an existing Pi extension
2
+
3
+ This guide adds typed settings to an existing TypeScript Pi extension. For a new extension, [Pi Extension Template](https://github.com/zigai/pi-extension-template) generates this structure for you.
4
+
5
+ ## 1. Install the package
6
+
7
+ ```sh
8
+ npm install @zigai/pi-extension-settings
9
+ ```
10
+
11
+ ## 2. Define the settings
12
+
13
+ Keep authoring-only schema code in `src/settings-input.ts`. The generator imports this file, so it must not import Pi runtime code or the generated prevalidation artifact.
14
+
15
+ ```ts
16
+ import type { ExtensionSettingsDefinitionInput } from "@zigai/pi-extension-settings";
17
+ import { Type } from "typebox";
18
+
19
+ export const settingsSchema = Type.Object(
20
+ {
21
+ enabled: Type.Boolean({
22
+ default: true,
23
+ description: "Enable the extension's behavior.",
24
+ }),
25
+ excludedTools: Type.Array(Type.String(), {
26
+ default: [],
27
+ description: "Tool names the extension should ignore.",
28
+ }),
29
+ },
30
+ { additionalProperties: false },
31
+ );
32
+
33
+ const settingsInput = {
34
+ id: "pi-example",
35
+ title: "Pi Example",
36
+ description: "Settings for Pi Example.",
37
+ schemaId: "https://raw.githubusercontent.com/zigai/pi-example/main/config.schema.json",
38
+ schema: settingsSchema,
39
+ } as const satisfies ExtensionSettingsDefinitionInput<typeof settingsSchema>;
40
+
41
+ export default settingsInput;
42
+ ```
43
+
44
+ ## 3. Configure generation
45
+
46
+ Add the settings manifest and commands to `package.json`:
47
+
48
+ ```json
49
+ {
50
+ "piExtensionSettings": {
51
+ "definition": "./src/settings-input.ts",
52
+ "prevalidation": "./src/settings.prevalidated.ts"
53
+ },
54
+ "scripts": {
55
+ "config:generate": "pi-extension-settings generate",
56
+ "config:check": "pi-extension-settings check"
57
+ }
58
+ }
59
+ ```
60
+
61
+ The generated schema and README paths default to `config.schema.json` and `README.md`. Set `schema` or `readme` in the manifest only when those defaults do not fit the package.
62
+
63
+ If `package.json` uses a `files` allowlist, publish both manifest targets. Including `src` is sufficient; a bundled package can include `src/settings-input.ts` and `src/settings.prevalidated.ts` explicitly.
64
+
65
+ Generate the initial artifacts:
66
+
67
+ ```sh
68
+ npm run config:generate
69
+ ```
70
+
71
+ Commit the generated `config.schema.json`, `src/settings.prevalidated.ts`, and README settings section. See [Generated artifacts and commands](generation.md) for command behavior, workspace discovery, manifest options, and automation guidance.
72
+
73
+ ## 4. Create the runtime loader
74
+
75
+ Keep the runtime definition and loader in `src/settings.ts`:
76
+
77
+ ```ts
78
+ import { loadPiExtensionSettings, type PiSettingsContext } from "@zigai/pi-extension-settings/pi";
79
+ import { definePrevalidatedExtensionSettings } from "@zigai/pi-extension-settings/runtime";
80
+ import type { StaticDecode } from "typebox";
81
+
82
+ import artifact from "./settings.prevalidated.ts";
83
+ import settingsInput, { settingsSchema } from "./settings-input.ts";
84
+
85
+ export type ExtensionSettings = StaticDecode<typeof settingsSchema>;
86
+
87
+ export const settingsDefinition = definePrevalidatedExtensionSettings(settingsInput, artifact);
88
+
89
+ export function loadExampleSettings(ctx: PiSettingsContext) {
90
+ return loadPiExtensionSettings(settingsDefinition, ctx, {
91
+ bundledSchema: { kind: "url", url: new URL("../config.schema.json", import.meta.url) },
92
+ });
93
+ }
94
+ ```
95
+
96
+ Use `StaticDecode`, not `Static`, for values after TypeBox codecs run.
97
+
98
+ Do not load settings during module import or the extension factory. Resolve them once per session at the first lifecycle event that needs them. See [Runtime loading and updates](runtime.md) for lifecycle guidance, merge behavior, diagnostics, and transactional writes.
@@ -0,0 +1,100 @@
1
+ # Runtime loading and updates
2
+
3
+ Pi Extension Settings separates authoring-time schema work from the code loaded by Pi.
4
+
5
+ | Import | Use it for |
6
+ | -------------------------------------- | ----------------------------------------------------------------- |
7
+ | `@zigai/pi-extension-settings` | Defining and generating settings in Node.js authoring tools |
8
+ | `@zigai/pi-extension-settings/runtime` | Hydrating the checked-in prevalidation artifact in extension code |
9
+ | `@zigai/pi-extension-settings/pi` | Loading and updating settings through Pi paths and project trust |
10
+
11
+ ## Load settings
12
+
13
+ ```ts
14
+ import { loadPiExtensionSettings } from "@zigai/pi-extension-settings/pi";
15
+ import settingsDefinition from "./settings.ts";
16
+
17
+ const loaded = loadPiExtensionSettings(settingsDefinition, ctx, {
18
+ bundledSchema: {
19
+ kind: "url",
20
+ url: new URL("../config.schema.json", import.meta.url),
21
+ },
22
+ });
23
+ ```
24
+
25
+ Resolution applies layers in this order:
26
+
27
+ 1. Schema defaults.
28
+ 2. Global settings.
29
+ 3. Trusted-project settings.
30
+
31
+ Objects merge recursively. Arrays and scalar values replace earlier values. Invalid layers are ignored and reported through `loaded.diagnostics` without exposing their values.
32
+
33
+ Global settings are stored under Pi's agent directory at `extension-settings/<id>.json`. Trusted-project overrides use `<project>/<Pi config directory>/extension-settings/<id>.json`. `getPiGlobalSettingsPath()` and `getPiProjectSettingsPath()` return the resolved paths.
34
+
35
+ Loading installs or refreshes the generated editor schema and creates a missing global settings file. It never overwrites an existing settings file and never creates a project settings file.
36
+
37
+ ### Choose the activation boundary
38
+
39
+ Keep module import and the extension factory free of settings I/O. Treat `session_start` as the reset boundary and load settings once in the first callback that needs them. If the feature genuinely begins during `session_start`, that handler is the correct activation boundary.
40
+
41
+ Cache the load result inside the extension factory. A cached result means loading is complete even when `enabled` is false; no separate activation flag is needed. Call the same getter from each tool execution, command, shortcut, or event handler that needs settings. Keep additional extension-specific validation with that getter and cache rejected results too.
42
+
43
+ ```ts
44
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
45
+ import { loadExampleSettings, type ExtensionSettings } from "./settings.ts";
46
+
47
+ export default function extension(pi: ExtensionAPI): void {
48
+ let loaded: ReturnType<typeof loadExampleSettings> | undefined;
49
+
50
+ function getSettings(ctx: ExtensionContext): ExtensionSettings | undefined {
51
+ if (loaded === undefined) {
52
+ loaded = loadExampleSettings(ctx);
53
+ if (ctx.hasUI) {
54
+ for (const diagnostic of loaded.diagnostics) {
55
+ ctx.ui.notify(diagnostic.message, diagnostic.severity);
56
+ }
57
+ }
58
+ }
59
+ return loaded.settings.enabled ? loaded.settings : undefined;
60
+ }
61
+
62
+ const reset = () => {
63
+ loaded = undefined;
64
+ };
65
+ pi.on("session_start", reset);
66
+ pi.on("session_shutdown", reset);
67
+
68
+ pi.on("before_agent_start", (_event, ctx) => {
69
+ const settings = getSettings(ctx);
70
+ if (settings === undefined) return;
71
+
72
+ // Run enabled behavior that needs settings.
73
+ });
74
+ }
75
+ ```
76
+
77
+ Renderers receive `ToolRenderContext`, not `ExtensionContext`. Keep rendering free of settings I/O and notifications; use presentation data captured during execution or already-owned session state. Renderers must also handle history rendered before settings activation and still return a component.
78
+
79
+ This moves synchronous settings work from Pi startup to first feature use; it does not eliminate that cost. Pi-level package configuration is the zero-load switch when an extension should not be imported or registered at all. Add cancellation, stale-result rejection, and disposal when the extension acquires asynchronous work or resources that need them.
80
+
81
+ ## Update settings safely
82
+
83
+ Use `updatePiExtensionSettings()` instead of writing settings files directly. Load first so the generated editor schema is installed and verified.
84
+
85
+ ```ts
86
+ import { updatePiExtensionSettings } from "@zigai/pi-extension-settings/pi";
87
+
88
+ const result = await updatePiExtensionSettings(settingsDefinition, ctx, {
89
+ scope: "global",
90
+ update: (current) => ({ ...current, enabled: false }),
91
+ });
92
+
93
+ if (result.status !== "updated" && result.status !== "unchanged") {
94
+ ctx.ui.notify(result.message, "error");
95
+ }
96
+ ```
97
+
98
+ The synchronous callback receives the latest encoded layer and runs once while the settings file is locked. The package validates the returned layer by itself and after resolution, then publishes it atomically. Invalid existing files and invalid updates remain untouched. Project updates require a trusted project and may create its missing settings file.
99
+
100
+ For an editor based on a previously loaded snapshot, pass `globalRevision` or `projectRevision` as `expectedRevision`. A stale revision returns `conflict`. Omit it for semantic updates that should apply to the latest valid layer.
@@ -0,0 +1,31 @@
1
+ # Optional UI controls
2
+
3
+ The optional `x-control` TypeBox annotation tells compatible settings editors how to present a property. It does not change validation, defaults, or runtime loading.
4
+
5
+ [Pi Settings UI](https://github.com/zigai/pi-settings-ui) supports these values:
6
+
7
+ | `x-control` | Compatible schema | Presentation |
8
+ | ------------- | --------------------------- | ----------------------------------------------------------------------- |
9
+ | `text` | string | Single-line input |
10
+ | `textarea` | string | Multiline editor |
11
+ | `switch` | boolean | Toggle |
12
+ | `segmented` | primitive choices | Compact choice control |
13
+ | `select` | primitive choices | Searchable picker |
14
+ | `slider` | number or integer | Range control using schema bounds and `multipleOf` |
15
+ | `numeric` | number or integer | Numeric input |
16
+ | `color` | string | Text input with a hexadecimal color preview |
17
+ | `path` | string | Text input with Tab completion |
18
+ | `combobox` | string or string-only union | Suggestions from `examples` or union branches, plus custom valid values |
19
+ | `json-editor` | any property schema | Validated JSON editor |
20
+
21
+ Pass the annotation as a quoted schema option:
22
+
23
+ ```ts
24
+ const enabled = Type.Boolean({
25
+ default: true,
26
+ description: "Enable the extension's behavior.",
27
+ "x-control": "switch",
28
+ });
29
+ ```
30
+
31
+ Choose a control only when it communicates the setting more clearly than the editor's schema-derived default.