dreamteamer 0.49.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (977) hide show
  1. package/bin/dreamteamer.js +163 -87
  2. package/collections/modules.collection.yaml +4 -0
  3. package/dist/api.d.ts +89 -0
  4. package/dist/api.js +139 -0
  5. package/dist/changes/commitPending.d.ts +28 -0
  6. package/dist/changes/commitPending.js +658 -0
  7. package/dist/changes/composeSubject.d.ts +9 -0
  8. package/dist/changes/composeSubject.js +19 -0
  9. package/dist/changes/consts.d.ts +11 -0
  10. package/dist/changes/consts.js +19 -0
  11. package/dist/changes/deriveEvents.d.ts +19 -0
  12. package/dist/changes/deriveEvents.js +118 -0
  13. package/dist/changes/foldChanges.d.ts +13 -0
  14. package/dist/changes/foldChanges.js +47 -0
  15. package/dist/changes/groupChanges.d.ts +6 -0
  16. package/dist/changes/groupChanges.js +23 -0
  17. package/dist/changes/layerOf.d.ts +6 -0
  18. package/dist/changes/layerOf.js +12 -0
  19. package/dist/changes/lib/reportLine.d.ts +7 -0
  20. package/dist/changes/lib/reportLine.js +14 -0
  21. package/dist/changes/printChanges.d.ts +11 -0
  22. package/dist/changes/printChanges.js +20 -0
  23. package/dist/changes/recordChanges.d.ts +21 -0
  24. package/dist/changes/recordChanges.js +32 -0
  25. package/dist/changes/rowChanges.d.ts +7 -0
  26. package/dist/changes/rowChanges.js +27 -0
  27. package/dist/changes/types.d.ts +28 -0
  28. package/dist/changes/types.js +1 -0
  29. package/dist/check/check.d.ts +11 -0
  30. package/dist/check/check.js +555 -0
  31. package/dist/check/checkAlone.d.ts +9 -0
  32. package/dist/check/checkAlone.js +200 -0
  33. package/dist/check/consts.d.ts +1 -0
  34. package/dist/check/consts.js +3 -0
  35. package/dist/check/engineRun.d.ts +3 -0
  36. package/dist/check/engineRun.js +20 -0
  37. package/dist/check/freshWorkspace.d.ts +5 -0
  38. package/dist/check/freshWorkspace.js +24 -0
  39. package/dist/check/isStale.d.ts +3 -0
  40. package/dist/check/isStale.js +2 -0
  41. package/dist/check/symlinkedChildRoots.d.ts +3 -0
  42. package/dist/check/symlinkedChildRoots.js +13 -0
  43. package/dist/check/unreadData.d.ts +7 -0
  44. package/dist/check/unreadData.js +113 -0
  45. package/dist/cli.d.ts +21 -0
  46. package/dist/cli.js +151 -0
  47. package/dist/collections/addField.d.ts +23 -0
  48. package/dist/collections/addField.js +28 -0
  49. package/dist/collections/collectionsCommand.d.ts +7 -0
  50. package/dist/collections/collectionsCommand.js +357 -0
  51. package/dist/collections/createCollection.d.ts +21 -0
  52. package/dist/collections/createCollection.js +134 -0
  53. package/dist/collections/lib/applyRewrites.d.ts +4 -0
  54. package/dist/collections/lib/applyRewrites.js +26 -0
  55. package/dist/collections/lib/consts.d.ts +18 -0
  56. package/dist/collections/lib/consts.js +56 -0
  57. package/dist/collections/lib/declaringSource.d.ts +18 -0
  58. package/dist/collections/lib/declaringSource.js +44 -0
  59. package/dist/collections/lib/descriptorSources.d.ts +4 -0
  60. package/dist/collections/lib/descriptorSources.js +16 -0
  61. package/dist/collections/lib/fieldRenameWalk.d.ts +10 -0
  62. package/dist/collections/lib/fieldRenameWalk.js +50 -0
  63. package/dist/collections/lib/mixinDeclaring.d.ts +7 -0
  64. package/dist/collections/lib/mixinDeclaring.js +13 -0
  65. package/dist/collections/lib/mixinSources.d.ts +6 -0
  66. package/dist/collections/lib/mixinSources.js +18 -0
  67. package/dist/collections/lib/mixinsListedBy.d.ts +3 -0
  68. package/dist/collections/lib/mixinsListedBy.js +14 -0
  69. package/dist/collections/lib/placeField.d.ts +7 -0
  70. package/dist/collections/lib/placeField.js +19 -0
  71. package/dist/collections/lib/positionLines.d.ts +10 -0
  72. package/dist/collections/lib/positionLines.js +7 -0
  73. package/dist/collections/lib/qualify.d.ts +2 -0
  74. package/dist/collections/lib/qualify.js +5 -0
  75. package/dist/collections/lib/recordRewrites.d.ts +5 -0
  76. package/dist/collections/lib/recordRewrites.js +27 -0
  77. package/dist/collections/lib/removeFieldPlan.d.ts +26 -0
  78. package/dist/collections/lib/removeFieldPlan.js +57 -0
  79. package/dist/collections/lib/renameFieldPlan.d.ts +12 -0
  80. package/dist/collections/lib/renameFieldPlan.js +18 -0
  81. package/dist/collections/lib/renameInConstraint.d.ts +2 -0
  82. package/dist/collections/lib/renameInConstraint.js +45 -0
  83. package/dist/collections/lib/renameInDisplay.d.ts +2 -0
  84. package/dist/collections/lib/renameInDisplay.js +52 -0
  85. package/dist/collections/lib/renameInTemplate.d.ts +3 -0
  86. package/dist/collections/lib/renameInTemplate.js +12 -0
  87. package/dist/collections/lib/renameKeys.d.ts +13 -0
  88. package/dist/collections/lib/renameKeys.js +31 -0
  89. package/dist/collections/lib/renameMirrorOf.d.ts +3 -0
  90. package/dist/collections/lib/renameMirrorOf.js +10 -0
  91. package/dist/collections/lib/renameOwnField.d.ts +3 -0
  92. package/dist/collections/lib/renameOwnField.js +30 -0
  93. package/dist/collections/lib/renameValueInCondition.d.ts +4 -0
  94. package/dist/collections/lib/renameValueInCondition.js +42 -0
  95. package/dist/collections/lib/renameValueInConstraint.d.ts +3 -0
  96. package/dist/collections/lib/renameValueInConstraint.js +19 -0
  97. package/dist/collections/lib/renameValueInSubschema.d.ts +3 -0
  98. package/dist/collections/lib/renameValueInSubschema.js +24 -0
  99. package/dist/collections/lib/renameValuePlan.d.ts +13 -0
  100. package/dist/collections/lib/renameValuePlan.js +33 -0
  101. package/dist/collections/lib/reportMirror.d.ts +8 -0
  102. package/dist/collections/lib/reportMirror.js +19 -0
  103. package/dist/collections/lib/types.d.ts +36 -0
  104. package/dist/collections/lib/types.js +1 -0
  105. package/dist/collections/lib/upsertField.d.ts +22 -0
  106. package/dist/collections/lib/upsertField.js +39 -0
  107. package/dist/collections/lib/valueRenameWalk.d.ts +4 -0
  108. package/dist/collections/lib/valueRenameWalk.js +60 -0
  109. package/dist/collections/lib/viewSources.d.ts +6 -0
  110. package/dist/collections/lib/viewSources.js +20 -0
  111. package/dist/collections/lib/walkFilter.d.ts +3 -0
  112. package/dist/collections/lib/walkFilter.js +25 -0
  113. package/dist/collections/lib/walkSources.d.ts +17 -0
  114. package/dist/collections/lib/walkSources.js +80 -0
  115. package/dist/collections/moveCollection.d.ts +42 -0
  116. package/dist/collections/moveCollection.js +176 -0
  117. package/dist/collections/removeCollection.d.ts +8 -0
  118. package/dist/collections/removeCollection.js +40 -0
  119. package/dist/collections/removeField.d.ts +30 -0
  120. package/dist/collections/removeField.js +150 -0
  121. package/dist/collections/renameCollection.d.ts +55 -0
  122. package/dist/collections/renameCollection.js +492 -0
  123. package/dist/collections/renameField.d.ts +32 -0
  124. package/dist/collections/renameField.js +49 -0
  125. package/dist/collections/renameValue.d.ts +29 -0
  126. package/dist/collections/renameValue.js +35 -0
  127. package/dist/collections/setCollectionScalars.d.ts +32 -0
  128. package/dist/collections/setCollectionScalars.js +248 -0
  129. package/dist/collections/updateField.d.ts +27 -0
  130. package/dist/collections/updateField.js +20 -0
  131. package/dist/commands/addCommand.d.ts +1 -0
  132. package/dist/commands/addCommand.js +2 -0
  133. package/dist/commands/addFieldCommand.d.ts +1 -0
  134. package/dist/commands/addFieldCommand.js +2 -0
  135. package/dist/commands/changesCommand.d.ts +10 -0
  136. package/dist/commands/changesCommand.js +37 -0
  137. package/dist/commands/checkCommand.d.ts +1 -0
  138. package/dist/commands/checkCommand.js +22 -0
  139. package/dist/commands/commitCommand.d.ts +6 -0
  140. package/dist/commands/commitCommand.js +89 -0
  141. package/dist/commands/compileCommand.d.ts +2 -0
  142. package/dist/commands/compileCommand.js +35 -0
  143. package/dist/commands/diffCommand.d.ts +1 -0
  144. package/dist/commands/diffCommand.js +2 -0
  145. package/dist/commands/doctorCommand.d.ts +1 -0
  146. package/dist/commands/doctorCommand.js +14 -0
  147. package/dist/commands/exportsCommand.d.ts +1 -0
  148. package/dist/commands/exportsCommand.js +10 -0
  149. package/dist/commands/fmtCommand.d.ts +1 -0
  150. package/dist/commands/fmtCommand.js +27 -0
  151. package/dist/commands/getCommand.d.ts +1 -0
  152. package/dist/commands/getCommand.js +2 -0
  153. package/dist/commands/helpCommand.d.ts +5 -0
  154. package/dist/commands/helpCommand.js +27 -0
  155. package/dist/commands/historyCommand.d.ts +1 -0
  156. package/dist/commands/historyCommand.js +2 -0
  157. package/dist/commands/initCommand.d.ts +2 -0
  158. package/dist/commands/initCommand.js +17 -0
  159. package/dist/commands/installCommand.d.ts +1 -0
  160. package/dist/commands/installCommand.js +12 -0
  161. package/dist/commands/lib/fieldVerb.d.ts +12 -0
  162. package/dist/commands/lib/fieldVerb.js +26 -0
  163. package/dist/commands/lib/recordVerb.d.ts +2 -0
  164. package/dist/commands/lib/recordVerb.js +53 -0
  165. package/dist/commands/lib/unknownVerb.d.ts +14 -0
  166. package/dist/commands/lib/unknownVerb.js +74 -0
  167. package/dist/commands/lib/verify.d.ts +3 -0
  168. package/dist/commands/lib/verify.js +4 -0
  169. package/dist/commands/listCommand.d.ts +1 -0
  170. package/dist/commands/listCommand.js +2 -0
  171. package/dist/commands/nextCommand.d.ts +1 -0
  172. package/dist/commands/nextCommand.js +2 -0
  173. package/dist/commands/relationsCommand.d.ts +11 -0
  174. package/dist/commands/relationsCommand.js +186 -0
  175. package/dist/commands/relocateCommand.d.ts +1 -0
  176. package/dist/commands/relocateCommand.js +39 -0
  177. package/dist/commands/renameCommand.d.ts +1 -0
  178. package/dist/commands/renameCommand.js +2 -0
  179. package/dist/commands/renameFieldCommand.d.ts +1 -0
  180. package/dist/commands/renameFieldCommand.js +2 -0
  181. package/dist/commands/renameValueCommand.d.ts +1 -0
  182. package/dist/commands/renameValueCommand.js +2 -0
  183. package/dist/commands/reorderCommand.d.ts +1 -0
  184. package/dist/commands/reorderCommand.js +2 -0
  185. package/dist/commands/resolveCommand.d.ts +15 -0
  186. package/dist/commands/resolveCommand.js +69 -0
  187. package/dist/commands/revertCommand.d.ts +1 -0
  188. package/dist/commands/revertCommand.js +2 -0
  189. package/dist/commands/rmCommand.d.ts +1 -0
  190. package/dist/commands/rmCommand.js +2 -0
  191. package/dist/commands/rmFieldCommand.d.ts +1 -0
  192. package/dist/commands/rmFieldCommand.js +2 -0
  193. package/dist/commands/runCommand.d.ts +5 -0
  194. package/dist/commands/runCommand.js +9 -0
  195. package/dist/commands/setCommand.d.ts +1 -0
  196. package/dist/commands/setCommand.js +2 -0
  197. package/dist/commands/setFieldCommand.d.ts +1 -0
  198. package/dist/commands/setFieldCommand.js +2 -0
  199. package/dist/commands/setupCommand.d.ts +5 -0
  200. package/dist/commands/setupCommand.js +196 -0
  201. package/dist/commands/statusCommand.d.ts +1 -0
  202. package/dist/commands/statusCommand.js +16 -0
  203. package/dist/commands/updateCommand.d.ts +1 -0
  204. package/dist/commands/updateCommand.js +18 -0
  205. package/dist/commands/valuesCommand.d.ts +1 -0
  206. package/dist/commands/valuesCommand.js +2 -0
  207. package/dist/commands/versionCommand.d.ts +2 -0
  208. package/dist/commands/versionCommand.js +7 -0
  209. package/dist/compile/compile.d.ts +24 -0
  210. package/dist/compile/compile.js +1553 -0
  211. package/dist/compile/consts.d.ts +52 -0
  212. package/dist/compile/consts.js +120 -0
  213. package/dist/compile/ensureEditorRecommendation.d.ts +1 -0
  214. package/dist/compile/ensureEditorRecommendation.js +31 -0
  215. package/dist/compile/isV2.d.ts +2 -0
  216. package/dist/compile/isV2.js +1 -0
  217. package/dist/compile/kindDir.d.ts +11 -0
  218. package/dist/compile/kindDir.js +19 -0
  219. package/dist/compile/lib/bindingErrors.d.ts +11 -0
  220. package/dist/compile/lib/bindingErrors.js +47 -0
  221. package/dist/compile/lib/buildCollectionsIndex.d.ts +8 -0
  222. package/dist/compile/lib/buildCollectionsIndex.js +49 -0
  223. package/dist/compile/lib/buildModulesIndex.d.ts +9 -0
  224. package/dist/compile/lib/buildModulesIndex.js +54 -0
  225. package/dist/compile/lib/compileCollections.d.ts +74 -0
  226. package/dist/compile/lib/compileCollections.js +614 -0
  227. package/dist/compile/lib/consts.d.ts +5 -0
  228. package/dist/compile/lib/consts.js +10 -0
  229. package/dist/compile/lib/ensureEnvExample.d.ts +28 -0
  230. package/dist/compile/lib/ensureEnvExample.js +79 -0
  231. package/dist/compile/lib/ensureGitignored.d.ts +6 -0
  232. package/dist/compile/lib/ensureGitignored.js +16 -0
  233. package/dist/compile/lib/filterFields.d.ts +5 -0
  234. package/dist/compile/lib/filterFields.js +17 -0
  235. package/dist/compile/lib/harnessMarkers.d.ts +2 -0
  236. package/dist/compile/lib/harnessMarkers.js +4 -0
  237. package/dist/compile/lib/mergeMixins.d.ts +14 -0
  238. package/dist/compile/lib/mergeMixins.js +55 -0
  239. package/dist/compile/lib/mergeOverlays.d.ts +6 -0
  240. package/dist/compile/lib/mergeOverlays.js +37 -0
  241. package/dist/compile/lib/nameErrors.d.ts +6 -0
  242. package/dist/compile/lib/nameErrors.js +57 -0
  243. package/dist/compile/lib/namespaceProblems.d.ts +8 -0
  244. package/dist/compile/lib/namespaceProblems.js +34 -0
  245. package/dist/compile/lib/overlayView.d.ts +2 -0
  246. package/dist/compile/lib/overlayView.js +17 -0
  247. package/dist/compile/lib/renderContributions.d.ts +14 -0
  248. package/dist/compile/lib/renderContributions.js +50 -0
  249. package/dist/compile/lib/resolveFields.d.ts +21 -0
  250. package/dist/compile/lib/resolveFields.js +232 -0
  251. package/dist/compile/lib/runHarnessAdapters.d.ts +19 -0
  252. package/dist/compile/lib/runHarnessAdapters.js +590 -0
  253. package/dist/compile/lib/shapeErrors.d.ts +3 -0
  254. package/dist/compile/lib/shapeErrors.js +64 -0
  255. package/dist/compile/lib/storageOverlaps.d.ts +17 -0
  256. package/dist/compile/lib/storageOverlaps.js +26 -0
  257. package/dist/compile/lib/subpathProblem.d.ts +6 -0
  258. package/dist/compile/lib/subpathProblem.js +14 -0
  259. package/dist/compile/lib/toJsonSchema.d.ts +9 -0
  260. package/dist/compile/lib/toJsonSchema.js +100 -0
  261. package/dist/compile/lib/types.d.ts +46 -0
  262. package/dist/compile/lib/types.js +1 -0
  263. package/dist/compile/lib/unqualifiedProblems.d.ts +6 -0
  264. package/dist/compile/lib/unqualifiedProblems.js +18 -0
  265. package/dist/compile/lib/viewDisplay.d.ts +6 -0
  266. package/dist/compile/lib/viewDisplay.js +21 -0
  267. package/dist/compile/lib/viewErrors.d.ts +20 -0
  268. package/dist/compile/lib/viewErrors.js +143 -0
  269. package/dist/compile/lib/writeLine.d.ts +12 -0
  270. package/dist/compile/lib/writeLine.js +31 -0
  271. package/dist/compile/sha256.d.ts +1 -0
  272. package/dist/compile/sha256.js +2 -0
  273. package/dist/compile/stagedKindDir.d.ts +18 -0
  274. package/dist/compile/stagedKindDir.js +32 -0
  275. package/dist/compile/staleness.d.ts +11 -0
  276. package/dist/compile/staleness.js +118 -0
  277. package/dist/compile/toPosix.d.ts +2 -0
  278. package/dist/compile/toPosix.js +3 -0
  279. package/dist/compile/types.d.ts +39 -0
  280. package/dist/compile/types.js +1 -0
  281. package/dist/compile/v1ManifestRefusal.d.ts +8 -0
  282. package/dist/compile/v1ManifestRefusal.js +16 -0
  283. package/dist/compile/v1Refusal.d.ts +2 -0
  284. package/dist/compile/v1Refusal.js +5 -0
  285. package/dist/compile/views.d.ts +2 -0
  286. package/dist/compile/views.js +3 -0
  287. package/dist/compile/warnIfStale.d.ts +3 -0
  288. package/dist/compile/warnIfStale.js +10 -0
  289. package/dist/coreVerbs.d.ts +6 -0
  290. package/dist/coreVerbs.js +50 -0
  291. package/dist/doctor/consts.d.ts +10 -0
  292. package/dist/doctor/consts.js +10 -0
  293. package/dist/doctor/doctorBoard.d.ts +7 -0
  294. package/dist/doctor/doctorBoard.js +97 -0
  295. package/dist/doctor/renderBoard.d.ts +2 -0
  296. package/dist/doctor/renderBoard.js +9 -0
  297. package/dist/doctor/types.d.ts +7 -0
  298. package/dist/doctor/types.js +1 -0
  299. package/dist/entities/createSkill.d.ts +12 -0
  300. package/dist/entities/createSkill.js +56 -0
  301. package/dist/entities/entitiesCommand.d.ts +7 -0
  302. package/dist/entities/entitiesCommand.js +97 -0
  303. package/dist/entities/lib/consts.d.ts +2 -0
  304. package/dist/entities/lib/consts.js +2 -0
  305. package/dist/entities/lib/entitySource.d.ts +10 -0
  306. package/dist/entities/lib/entitySource.js +17 -0
  307. package/dist/entities/lib/refuseBuiltSkill.d.ts +9 -0
  308. package/dist/entities/lib/refuseBuiltSkill.js +23 -0
  309. package/dist/entities/lib/refuseHandAuthored.d.ts +7 -0
  310. package/dist/entities/lib/refuseHandAuthored.js +15 -0
  311. package/dist/entities/lib/setFrontmatterKey.d.ts +8 -0
  312. package/dist/entities/lib/setFrontmatterKey.js +21 -0
  313. package/dist/entities/removeEntity.d.ts +7 -0
  314. package/dist/entities/removeEntity.js +35 -0
  315. package/dist/entities/renameEntity.d.ts +11 -0
  316. package/dist/entities/renameEntity.js +51 -0
  317. package/dist/entities/setEntityFrontmatter.d.ts +9 -0
  318. package/dist/entities/setEntityFrontmatter.js +58 -0
  319. package/dist/exports/planExports.d.ts +10 -0
  320. package/dist/exports/planExports.js +72 -0
  321. package/dist/exports/runExports.d.ts +7 -0
  322. package/dist/exports/runExports.js +95 -0
  323. package/dist/exports/serializeExports.d.ts +6 -0
  324. package/dist/exports/serializeExports.js +17 -0
  325. package/dist/extensions/consts.d.ts +1 -0
  326. package/dist/extensions/consts.js +1 -0
  327. package/dist/extensions/declaredExtensions.d.ts +17 -0
  328. package/dist/extensions/declaredExtensions.js +85 -0
  329. package/dist/extensions/extensions.d.ts +21 -0
  330. package/dist/extensions/extensions.js +24 -0
  331. package/dist/extensions/lib/consts.d.ts +2 -0
  332. package/dist/extensions/lib/consts.js +2 -0
  333. package/dist/extensions/lib/validateSetup.d.ts +15 -0
  334. package/dist/extensions/lib/validateSetup.js +128 -0
  335. package/dist/extensions/loadExtensions.d.ts +14 -0
  336. package/dist/extensions/loadExtensions.js +146 -0
  337. package/dist/extensions/manifestViolations.d.ts +11 -0
  338. package/dist/extensions/manifestViolations.js +17 -0
  339. package/dist/fmt/formatDescriptors.d.ts +20 -0
  340. package/dist/fmt/formatDescriptors.js +67 -0
  341. package/dist/fmt/formatSource.d.ts +7 -0
  342. package/dist/fmt/formatSource.js +50 -0
  343. package/dist/init/consts.d.ts +1 -0
  344. package/dist/init/consts.js +1 -0
  345. package/dist/init/escapes.d.ts +2 -0
  346. package/dist/init/escapes.js +64 -0
  347. package/dist/init/init.d.ts +7 -0
  348. package/dist/init/init.js +152 -0
  349. package/dist/init/initCommand.d.ts +30 -0
  350. package/dist/init/initCommand.js +407 -0
  351. package/dist/init/initFootprint.d.ts +6 -0
  352. package/dist/init/initFootprint.js +19 -0
  353. package/dist/init/seedBlock.d.ts +7 -0
  354. package/dist/init/seedBlock.js +37 -0
  355. package/dist/install/applyInstall.d.ts +15 -0
  356. package/dist/install/applyInstall.js +190 -0
  357. package/dist/install/buildClone.d.ts +5 -0
  358. package/dist/install/buildClone.js +22 -0
  359. package/dist/install/commitOf.d.ts +1 -0
  360. package/dist/install/commitOf.js +2 -0
  361. package/dist/install/declaredDeps.d.ts +3 -0
  362. package/dist/install/declaredDeps.js +2 -0
  363. package/dist/install/indexFolder.d.ts +6 -0
  364. package/dist/install/indexFolder.js +32 -0
  365. package/dist/install/install.d.ts +8 -0
  366. package/dist/install/install.js +177 -0
  367. package/dist/install/installCheckout.d.ts +15 -0
  368. package/dist/install/installCheckout.js +142 -0
  369. package/dist/install/installClone.d.ts +6 -0
  370. package/dist/install/installClone.js +32 -0
  371. package/dist/install/installCommand.d.ts +15 -0
  372. package/dist/install/installCommand.js +61 -0
  373. package/dist/install/installModules.d.ts +17 -0
  374. package/dist/install/installModules.js +208 -0
  375. package/dist/install/installedModules.d.ts +12 -0
  376. package/dist/install/installedModules.js +27 -0
  377. package/dist/install/isLink.d.ts +1 -0
  378. package/dist/install/isLink.js +9 -0
  379. package/dist/install/lib/readTarballManifest.d.ts +6 -0
  380. package/dist/install/lib/readTarballManifest.js +27 -0
  381. package/dist/install/npmAndCompile.d.ts +35 -0
  382. package/dist/install/npmAndCompile.js +151 -0
  383. package/dist/install/observeState.d.ts +29 -0
  384. package/dist/install/observeState.js +98 -0
  385. package/dist/install/offRef.d.ts +7 -0
  386. package/dist/install/offRef.js +19 -0
  387. package/dist/install/planInstall.d.ts +9 -0
  388. package/dist/install/planInstall.js +73 -0
  389. package/dist/install/presetMembers.d.ts +17 -0
  390. package/dist/install/presetMembers.js +25 -0
  391. package/dist/install/readHookInput.d.ts +17 -0
  392. package/dist/install/readHookInput.js +29 -0
  393. package/dist/install/readSpecManifest.d.ts +12 -0
  394. package/dist/install/readSpecManifest.js +55 -0
  395. package/dist/install/readStdin.d.ts +12 -0
  396. package/dist/install/readStdin.js +25 -0
  397. package/dist/install/resolveClosure.d.ts +21 -0
  398. package/dist/install/resolveClosure.js +69 -0
  399. package/dist/install/resolves.d.ts +8 -0
  400. package/dist/install/resolves.js +9 -0
  401. package/dist/install/types.d.ts +26 -0
  402. package/dist/install/types.js +1 -0
  403. package/dist/install/versions.d.ts +12 -0
  404. package/dist/install/versions.js +25 -0
  405. package/dist/lib/alreadyThat.d.ts +5 -0
  406. package/dist/lib/alreadyThat.js +8 -0
  407. package/dist/lib/appendMissing.d.ts +1 -0
  408. package/dist/lib/appendMissing.js +7 -0
  409. package/dist/lib/atomicWrite.d.ts +1 -0
  410. package/dist/lib/atomicWrite.js +9 -0
  411. package/dist/lib/baseDescriptorSource.d.ts +18 -0
  412. package/dist/lib/baseDescriptorSource.js +52 -0
  413. package/dist/lib/childEnv.d.ts +12 -0
  414. package/dist/lib/childEnv.js +16 -0
  415. package/dist/lib/collectionSourceFile.d.ts +26 -0
  416. package/dist/lib/collectionSourceFile.js +56 -0
  417. package/dist/lib/consts.d.ts +93 -0
  418. package/dist/lib/consts.js +180 -0
  419. package/dist/lib/dryRunPlan.d.ts +21 -0
  420. package/dist/lib/dryRunPlan.js +23 -0
  421. package/dist/lib/editWorkspacePkg.d.ts +8 -0
  422. package/dist/lib/editWorkspacePkg.js +19 -0
  423. package/dist/lib/emit.d.ts +32 -0
  424. package/dist/lib/emit.js +46 -0
  425. package/dist/lib/emitDocument.d.ts +6 -0
  426. package/dist/lib/emitDocument.js +61 -0
  427. package/dist/lib/endOf.d.ts +11 -0
  428. package/dist/lib/endOf.js +25 -0
  429. package/dist/lib/escapeRe.d.ts +2 -0
  430. package/dist/lib/escapeRe.js +2 -0
  431. package/dist/lib/fieldFromFlags.d.ts +13 -0
  432. package/dist/lib/fieldFromFlags.js +195 -0
  433. package/dist/lib/gatedTreeOp.d.ts +30 -0
  434. package/dist/lib/gatedTreeOp.js +59 -0
  435. package/dist/lib/git/commitArg.d.ts +1 -0
  436. package/dist/lib/git/commitArg.js +13 -0
  437. package/dist/lib/git/defaultGit.d.ts +1 -0
  438. package/dist/lib/git/defaultGit.js +20 -0
  439. package/dist/lib/git/describeCheckout.d.ts +9 -0
  440. package/dist/lib/git/describeCheckout.js +45 -0
  441. package/dist/lib/git/gitOk.d.ts +2 -0
  442. package/dist/lib/git/gitOk.js +11 -0
  443. package/dist/lib/git/inProgress.d.ts +5 -0
  444. package/dist/lib/git/inProgress.js +28 -0
  445. package/dist/lib/git/repoRootOf.d.ts +6 -0
  446. package/dist/lib/git/repoRootOf.js +20 -0
  447. package/dist/lib/git/tryGit.d.ts +1 -0
  448. package/dist/lib/git/tryGit.js +10 -0
  449. package/dist/lib/isEntityKind.d.ts +2 -0
  450. package/dist/lib/isEntityKind.js +3 -0
  451. package/dist/lib/nearest.d.ts +5 -0
  452. package/dist/lib/nearest.js +21 -0
  453. package/dist/lib/need.d.ts +1 -0
  454. package/dist/lib/need.js +5 -0
  455. package/dist/lib/npm/exact.d.ts +5 -0
  456. package/dist/lib/npm/exact.js +5 -0
  457. package/dist/lib/npm/npmFloor.d.ts +2 -0
  458. package/dist/lib/npm/npmFloor.js +18 -0
  459. package/dist/lib/npm/resolveNpm.d.ts +10 -0
  460. package/dist/lib/npm/resolveNpm.js +35 -0
  461. package/dist/lib/npm/satisfies.d.ts +11 -0
  462. package/dist/lib/npm/satisfies.js +66 -0
  463. package/dist/lib/oneValue.d.ts +7 -0
  464. package/dist/lib/oneValue.js +12 -0
  465. package/dist/lib/pairs.d.ts +5 -0
  466. package/dist/lib/pairs.js +15 -0
  467. package/dist/lib/parseArgs.d.ts +17 -0
  468. package/dist/lib/parseArgs.js +36 -0
  469. package/dist/lib/refuseUnknownFlags.d.ts +3 -0
  470. package/dist/lib/refuseUnknownFlags.js +53 -0
  471. package/dist/lib/rel.d.ts +1 -0
  472. package/dist/lib/rel.js +3 -0
  473. package/dist/lib/schema-ops.d.ts +105 -0
  474. package/dist/lib/schema-ops.js +177 -0
  475. package/dist/lib/singular.d.ts +1 -0
  476. package/dist/lib/singular.js +23 -0
  477. package/dist/lib/stripMeta.d.ts +2 -0
  478. package/dist/lib/stripMeta.js +2 -0
  479. package/dist/lib/symlinkBelow.d.ts +13 -0
  480. package/dist/lib/symlinkBelow.js +33 -0
  481. package/dist/lib/types.d.ts +22 -0
  482. package/dist/lib/types.js +1 -0
  483. package/dist/lib/walk.d.ts +5 -0
  484. package/dist/lib/walk.js +21 -0
  485. package/dist/lib/writeSource.d.ts +7 -0
  486. package/dist/lib/writeSource.js +77 -0
  487. package/dist/lib/yaml.d.ts +18 -0
  488. package/dist/lib/yaml.js +26 -0
  489. package/dist/modules/createModule.d.ts +16 -0
  490. package/dist/modules/createModule.js +136 -0
  491. package/dist/modules/lib/consts.d.ts +10 -0
  492. package/dist/modules/lib/consts.js +17 -0
  493. package/dist/modules/lib/extensionText.d.ts +3 -0
  494. package/dist/modules/lib/extensionText.js +36 -0
  495. package/dist/modules/lib/readmeText.d.ts +6 -0
  496. package/dist/modules/lib/readmeText.js +25 -0
  497. package/dist/modules/lib/scaffoldKey.d.ts +2 -0
  498. package/dist/modules/lib/scaffoldKey.js +2 -0
  499. package/dist/modules/lib/testText.d.ts +7 -0
  500. package/dist/modules/lib/testText.js +19 -0
  501. package/dist/modules/modulesCommand.d.ts +4 -0
  502. package/dist/modules/modulesCommand.js +121 -0
  503. package/dist/modules/removeModule.d.ts +25 -0
  504. package/dist/modules/removeModule.js +94 -0
  505. package/dist/modules/renameModule.d.ts +15 -0
  506. package/dist/modules/renameModule.js +109 -0
  507. package/dist/modules/runModuleScript.d.ts +17 -0
  508. package/dist/modules/runModuleScript.js +100 -0
  509. package/dist/modules/setModule.d.ts +9 -0
  510. package/dist/modules/setModule.js +88 -0
  511. package/dist/openWorkspace.d.ts +12 -0
  512. package/dist/openWorkspace.js +22 -0
  513. package/dist/record/bodyField.d.ts +2 -0
  514. package/dist/record/bodyField.js +4 -0
  515. package/dist/record/collectRefFields.d.ts +3 -0
  516. package/dist/record/collectRefFields.js +16 -0
  517. package/dist/record/consts.d.ts +43 -0
  518. package/dist/record/consts.js +85 -0
  519. package/dist/record/descriptor.d.ts +44 -0
  520. package/dist/record/descriptor.js +56 -0
  521. package/dist/record/displayOf.d.ts +3 -0
  522. package/dist/record/displayOf.js +13 -0
  523. package/dist/record/expectedMirrors.d.ts +10 -0
  524. package/dist/record/expectedMirrors.js +27 -0
  525. package/dist/record/exportsContext.d.ts +17 -0
  526. package/dist/record/exportsContext.js +62 -0
  527. package/dist/record/fields.d.ts +9 -0
  528. package/dist/record/fields.js +30 -0
  529. package/dist/record/idFromRecordPath.d.ts +16 -0
  530. package/dist/record/idFromRecordPath.js +28 -0
  531. package/dist/record/lib/applyFilter.d.ts +5 -0
  532. package/dist/record/lib/applyFilter.js +32 -0
  533. package/dist/record/lib/consts.d.ts +7 -0
  534. package/dist/record/lib/consts.js +7 -0
  535. package/dist/record/lib/enumChoices.d.ts +2 -0
  536. package/dist/record/lib/enumChoices.js +16 -0
  537. package/dist/record/lib/fmtDate.d.ts +1 -0
  538. package/dist/record/lib/fmtDate.js +18 -0
  539. package/dist/record/lib/placedChildAt.d.ts +10 -0
  540. package/dist/record/lib/placedChildAt.js +25 -0
  541. package/dist/record/lib/rootRecords.d.ts +8 -0
  542. package/dist/record/lib/rootRecords.js +37 -0
  543. package/dist/record/lib/types.d.ts +6 -0
  544. package/dist/record/lib/types.js +1 -0
  545. package/dist/record/namespace.d.ts +22 -0
  546. package/dist/record/namespace.js +36 -0
  547. package/dist/record/nav.d.ts +41 -0
  548. package/dist/record/nav.js +237 -0
  549. package/dist/record/normalizeNamespaces.d.ts +8 -0
  550. package/dist/record/normalizeNamespaces.js +20 -0
  551. package/dist/record/outsideRefs.d.ts +19 -0
  552. package/dist/record/outsideRefs.js +34 -0
  553. package/dist/record/ownerIdOf.d.ts +11 -0
  554. package/dist/record/ownerIdOf.js +12 -0
  555. package/dist/record/ownersReadIn.d.ts +9 -0
  556. package/dist/record/ownersReadIn.js +11 -0
  557. package/dist/record/parentFolders.d.ts +6 -0
  558. package/dist/record/parentFolders.js +18 -0
  559. package/dist/record/parseRecordText.d.ts +2 -0
  560. package/dist/record/parseRecordText.js +19 -0
  561. package/dist/record/parseRef.d.ts +11 -0
  562. package/dist/record/parseRef.js +27 -0
  563. package/dist/record/parseTemplate.d.ts +3 -0
  564. package/dist/record/parseTemplate.js +24 -0
  565. package/dist/record/pathToRecord.d.ts +9 -0
  566. package/dist/record/pathToRecord.js +39 -0
  567. package/dist/record/placedRecords.d.ts +8 -0
  568. package/dist/record/placedRecords.js +22 -0
  569. package/dist/record/placement.d.ts +15 -0
  570. package/dist/record/placement.js +19 -0
  571. package/dist/record/presentation.d.ts +3 -0
  572. package/dist/record/presentation.js +236 -0
  573. package/dist/record/readExports.d.ts +2 -0
  574. package/dist/record/readExports.js +14 -0
  575. package/dist/record/records.d.ts +15 -0
  576. package/dist/record/records.js +53 -0
  577. package/dist/record/ref.d.ts +12 -0
  578. package/dist/record/ref.js +26 -0
  579. package/dist/record/regenerate.d.ts +18 -0
  580. package/dist/record/regenerate.js +56 -0
  581. package/dist/record/relationsOf.d.ts +3 -0
  582. package/dist/record/relationsOf.js +33 -0
  583. package/dist/record/renderDisplay.d.ts +13 -0
  584. package/dist/record/renderDisplay.js +33 -0
  585. package/dist/record/sees.d.ts +6 -0
  586. package/dist/record/sees.js +7 -0
  587. package/dist/record/serialize.d.ts +2 -0
  588. package/dist/record/serialize.js +35 -0
  589. package/dist/record/splitRef.d.ts +10 -0
  590. package/dist/record/splitRef.js +23 -0
  591. package/dist/record/storageOf.d.ts +3 -0
  592. package/dist/record/storageOf.js +40 -0
  593. package/dist/record/template.d.ts +12 -0
  594. package/dist/record/template.js +28 -0
  595. package/dist/record/temporal.d.ts +2 -0
  596. package/dist/record/temporal.js +8 -0
  597. package/dist/record/types.d.ts +76 -0
  598. package/dist/record/types.js +1 -0
  599. package/dist/record/unknownOperators.d.ts +5 -0
  600. package/dist/record/unknownOperators.js +25 -0
  601. package/dist/record/unknownTokens.d.ts +5 -0
  602. package/dist/record/unknownTokens.js +17 -0
  603. package/dist/record/validateTemplate.d.ts +14 -0
  604. package/dist/record/validateTemplate.js +36 -0
  605. package/dist/record/valuesAt.d.ts +2 -0
  606. package/dist/record/valuesAt.js +11 -0
  607. package/dist/records/commandsFor.d.ts +18 -0
  608. package/dist/records/commandsFor.js +65 -0
  609. package/dist/records/distinctValues.d.ts +16 -0
  610. package/dist/records/distinctValues.js +63 -0
  611. package/dist/records/history.d.ts +19 -0
  612. package/dist/records/history.js +35 -0
  613. package/dist/records/historyDiff.d.ts +7 -0
  614. package/dist/records/historyDiff.js +14 -0
  615. package/dist/records/lib/coerceArrays.d.ts +3 -0
  616. package/dist/records/lib/coerceArrays.js +26 -0
  617. package/dist/records/lib/compareValues.d.ts +8 -0
  618. package/dist/records/lib/compareValues.js +21 -0
  619. package/dist/records/lib/consts.d.ts +3 -0
  620. package/dist/records/lib/consts.js +3 -0
  621. package/dist/records/lib/contributedNotes.d.ts +14 -0
  622. package/dist/records/lib/contributedNotes.js +28 -0
  623. package/dist/records/lib/fmtCell.d.ts +1 -0
  624. package/dist/records/lib/fmtCell.js +1 -0
  625. package/dist/records/lib/keyBetween.d.ts +2 -0
  626. package/dist/records/lib/keyBetween.js +4 -0
  627. package/dist/records/lib/landedIn.d.ts +9 -0
  628. package/dist/records/lib/landedIn.js +13 -0
  629. package/dist/records/lib/listColumns.d.ts +3 -0
  630. package/dist/records/lib/listColumns.js +6 -0
  631. package/dist/records/lib/looseEq.d.ts +6 -0
  632. package/dist/records/lib/looseEq.js +6 -0
  633. package/dist/records/lib/matchesFilter.d.ts +2 -0
  634. package/dist/records/lib/matchesFilter.js +151 -0
  635. package/dist/records/lib/narrowRows.d.ts +16 -0
  636. package/dist/records/lib/narrowRows.js +79 -0
  637. package/dist/records/lib/parseTemporal.d.ts +9 -0
  638. package/dist/records/lib/parseTemporal.js +27 -0
  639. package/dist/records/lib/placementKey.d.ts +12 -0
  640. package/dist/records/lib/placementKey.js +31 -0
  641. package/dist/records/lib/recordResolver.d.ts +8 -0
  642. package/dist/records/lib/recordResolver.js +35 -0
  643. package/dist/records/lib/sortRows.d.ts +6 -0
  644. package/dist/records/lib/sortRows.js +20 -0
  645. package/dist/records/lib/sourceHintFor.d.ts +3 -0
  646. package/dist/records/lib/sourceHintFor.js +12 -0
  647. package/dist/records/lib/tokenValue.d.ts +3 -0
  648. package/dist/records/lib/tokenValue.js +17 -0
  649. package/dist/records/lib/trackedPaths.d.ts +14 -0
  650. package/dist/records/lib/trackedPaths.js +29 -0
  651. package/dist/records/lib/whereKeys.d.ts +8 -0
  652. package/dist/records/lib/whereKeys.js +2 -0
  653. package/dist/records/nextCommand.d.ts +4 -0
  654. package/dist/records/nextCommand.js +53 -0
  655. package/dist/records/recordsCommand.d.ts +7 -0
  656. package/dist/records/recordsCommand.js +291 -0
  657. package/dist/records-api.d.ts +42 -0
  658. package/dist/records-api.js +41 -0
  659. package/dist/repos/lib/relPath.d.ts +1 -0
  660. package/dist/repos/lib/relPath.js +6 -0
  661. package/dist/repos/lib/repoPath.d.ts +3 -0
  662. package/dist/repos/lib/repoPath.js +11 -0
  663. package/dist/repos/listRepos.d.ts +12 -0
  664. package/dist/repos/listRepos.js +28 -0
  665. package/dist/repos/materializeRepo.d.ts +9 -0
  666. package/dist/repos/materializeRepo.js +26 -0
  667. package/dist/repos/repos.d.ts +14 -0
  668. package/dist/repos/repos.js +17 -0
  669. package/dist/repos/reposCommand.d.ts +4 -0
  670. package/dist/repos/reposCommand.js +28 -0
  671. package/dist/repos/types.d.ts +29 -0
  672. package/dist/repos/types.js +1 -0
  673. package/dist/runtime/consts.d.ts +12 -0
  674. package/dist/runtime/consts.js +12 -0
  675. package/dist/runtime/exportsFacts.d.ts +17 -0
  676. package/dist/runtime/exportsFacts.js +10 -0
  677. package/dist/runtime/loadDescriptors.d.ts +8 -0
  678. package/dist/runtime/loadDescriptors.js +46 -0
  679. package/dist/runtime/runtime.d.ts +35 -0
  680. package/dist/runtime/runtime.js +66 -0
  681. package/dist/runtime/sourceRoots.d.ts +10 -0
  682. package/dist/runtime/sourceRoots.js +22 -0
  683. package/dist/scripts/migrate-descriptors-v2.js +1248 -0
  684. package/dist/scripts/migrate-stubs.js +170 -0
  685. package/dist/setup/consts.d.ts +2 -0
  686. package/dist/setup/consts.js +2 -0
  687. package/dist/setup/fillInputs.d.ts +28 -0
  688. package/dist/setup/fillInputs.js +142 -0
  689. package/dist/setup/fold.d.ts +6 -0
  690. package/dist/setup/fold.js +30 -0
  691. package/dist/setup/lib/consent.d.ts +9 -0
  692. package/dist/setup/lib/consent.js +14 -0
  693. package/dist/setup/lib/env-write.d.ts +6 -0
  694. package/dist/setup/lib/env-write.js +10 -0
  695. package/dist/setup/lib/envSpans.d.ts +17 -0
  696. package/dist/setup/lib/envSpans.js +27 -0
  697. package/dist/setup/lib/fingerprint.d.ts +2 -0
  698. package/dist/setup/lib/fingerprint.js +21 -0
  699. package/dist/setup/lib/gitExposure.d.ts +8 -0
  700. package/dist/setup/lib/gitExposure.js +50 -0
  701. package/dist/setup/lib/judgeEnvAction.d.ts +25 -0
  702. package/dist/setup/lib/judgeEnvAction.js +60 -0
  703. package/dist/setup/lib/leftoverTemps.d.ts +2 -0
  704. package/dist/setup/lib/leftoverTemps.js +15 -0
  705. package/dist/setup/lib/redact.d.ts +7 -0
  706. package/dist/setup/lib/redact.js +28 -0
  707. package/dist/setup/lib/secretPathProblem.d.ts +2 -0
  708. package/dist/setup/lib/secretPathProblem.js +16 -0
  709. package/dist/setup/lib/setEnvValues.d.ts +12 -0
  710. package/dist/setup/lib/setEnvValues.js +57 -0
  711. package/dist/setup/lib/setup-contract.d.ts +5 -0
  712. package/dist/setup/lib/setup-contract.js +2 -0
  713. package/dist/setup/lib/validateEnvAction.d.ts +16 -0
  714. package/dist/setup/lib/validateEnvAction.js +25 -0
  715. package/dist/setup/lib/writeEnvAtomic.d.ts +7 -0
  716. package/dist/setup/lib/writeEnvAtomic.js +60 -0
  717. package/dist/setup/parseAllow.d.ts +8 -0
  718. package/dist/setup/parseAllow.js +20 -0
  719. package/dist/setup/parseInputFlags.d.ts +3 -0
  720. package/dist/setup/parseInputFlags.js +17 -0
  721. package/dist/setup/printUnitResults.d.ts +3 -0
  722. package/dist/setup/printUnitResults.js +23 -0
  723. package/dist/setup/renderStatusLines.d.ts +2 -0
  724. package/dist/setup/renderStatusLines.js +14 -0
  725. package/dist/setup/runUnit.d.ts +21 -0
  726. package/dist/setup/runUnit.js +204 -0
  727. package/dist/setup/safeInspect.d.ts +7 -0
  728. package/dist/setup/safeInspect.js +28 -0
  729. package/dist/setup/setup.d.ts +14 -0
  730. package/dist/setup/setup.js +28 -0
  731. package/dist/setup/setupAndCommit.d.ts +28 -0
  732. package/dist/setup/setupAndCommit.js +103 -0
  733. package/dist/setup/statusLines.d.ts +6 -0
  734. package/dist/setup/statusLines.js +90 -0
  735. package/dist/setup/ttyIO.d.ts +5 -0
  736. package/dist/setup/ttyIO.js +25 -0
  737. package/dist/setup/types.d.ts +65 -0
  738. package/dist/setup/types.js +1 -0
  739. package/dist/setup/unitEnvFor.d.ts +11 -0
  740. package/dist/setup/unitEnvFor.js +29 -0
  741. package/dist/setup/units.d.ts +4 -0
  742. package/dist/setup/units.js +7 -0
  743. package/dist/statusCommand.d.ts +2 -0
  744. package/dist/statusCommand.js +249 -0
  745. package/dist/store/Store.d.ts +561 -0
  746. package/dist/store/Store.js +744 -0
  747. package/dist/store/add.d.ts +14 -0
  748. package/dist/store/add.js +92 -0
  749. package/dist/store/addFile.d.ts +7 -0
  750. package/dist/store/addFile.js +43 -0
  751. package/dist/store/addedDates.d.ts +2 -0
  752. package/dist/store/addedDates.js +44 -0
  753. package/dist/store/createdOf.d.ts +3 -0
  754. package/dist/store/createdOf.js +20 -0
  755. package/dist/store/external.d.ts +8 -0
  756. package/dist/store/external.js +18 -0
  757. package/dist/store/findInboundRefs.d.ts +2 -0
  758. package/dist/store/findInboundRefs.js +13 -0
  759. package/dist/store/gitHead.d.ts +2 -0
  760. package/dist/store/gitHead.js +13 -0
  761. package/dist/store/ids.d.ts +2 -0
  762. package/dist/store/ids.js +19 -0
  763. package/dist/store/lib/applyMirrorEdits.d.ts +7 -0
  764. package/dist/store/lib/applyMirrorEdits.js +125 -0
  765. package/dist/store/lib/assertUnambiguous.d.ts +2 -0
  766. package/dist/store/lib/assertUnambiguous.js +11 -0
  767. package/dist/store/lib/checkRefs.d.ts +7 -0
  768. package/dist/store/lib/checkRefs.js +65 -0
  769. package/dist/store/lib/commit.d.ts +3 -0
  770. package/dist/store/lib/commit.js +40 -0
  771. package/dist/store/lib/commitIn.d.ts +3 -0
  772. package/dist/store/lib/commitIn.js +37 -0
  773. package/dist/store/lib/dirTreeStamps.d.ts +7 -0
  774. package/dist/store/lib/dirTreeStamps.js +33 -0
  775. package/dist/store/lib/filePath.d.ts +3 -0
  776. package/dist/store/lib/filePath.js +32 -0
  777. package/dist/store/lib/generateId.d.ts +4 -0
  778. package/dist/store/lib/generateId.js +72 -0
  779. package/dist/store/lib/gitDateToStamp.d.ts +6 -0
  780. package/dist/store/lib/gitDateToStamp.js +8 -0
  781. package/dist/store/lib/idsKey.d.ts +3 -0
  782. package/dist/store/lib/idsKey.js +23 -0
  783. package/dist/store/lib/indexAdd.d.ts +5 -0
  784. package/dist/store/lib/indexAdd.js +41 -0
  785. package/dist/store/lib/mirrorRemedy.d.ts +19 -0
  786. package/dist/store/lib/mirrorRemedy.js +24 -0
  787. package/dist/store/lib/moveRecord.d.ts +4 -0
  788. package/dist/store/lib/moveRecord.js +29 -0
  789. package/dist/store/lib/normalizeRecord.d.ts +2 -0
  790. package/dist/store/lib/normalizeRecord.js +28 -0
  791. package/dist/store/lib/normalizeTemporal.d.ts +10 -0
  792. package/dist/store/lib/normalizeTemporal.js +38 -0
  793. package/dist/store/lib/pathAt.d.ts +3 -0
  794. package/dist/store/lib/pathAt.js +29 -0
  795. package/dist/store/lib/placedChildrenIn.d.ts +8 -0
  796. package/dist/store/lib/placedChildrenIn.js +18 -0
  797. package/dist/store/lib/placementOfFile.d.ts +11 -0
  798. package/dist/store/lib/placementOfFile.js +20 -0
  799. package/dist/store/lib/pruneEmptyDirs.d.ts +8 -0
  800. package/dist/store/lib/pruneEmptyDirs.js +20 -0
  801. package/dist/store/lib/qualifyBareRefs.d.ts +3 -0
  802. package/dist/store/lib/qualifyBareRefs.js +16 -0
  803. package/dist/store/lib/recordFileName.d.ts +3 -0
  804. package/dist/store/lib/recordFileName.js +6 -0
  805. package/dist/store/lib/refuseDuplicateValues.d.ts +3 -0
  806. package/dist/store/lib/refuseDuplicateValues.js +16 -0
  807. package/dist/store/lib/refuseEngineWrites.d.ts +3 -0
  808. package/dist/store/lib/refuseEngineWrites.js +12 -0
  809. package/dist/store/lib/refuseMirrorWrites.d.ts +2 -0
  810. package/dist/store/lib/refuseMirrorWrites.js +8 -0
  811. package/dist/store/lib/snapshot.d.ts +17 -0
  812. package/dist/store/lib/snapshot.js +60 -0
  813. package/dist/store/lib/validate.d.ts +6 -0
  814. package/dist/store/lib/validate.js +33 -0
  815. package/dist/store/lib/walkIds.d.ts +3 -0
  816. package/dist/store/lib/walkIds.js +54 -0
  817. package/dist/store/lib/walkRoot.d.ts +3 -0
  818. package/dist/store/lib/walkRoot.js +24 -0
  819. package/dist/store/lib/writableDescriptor.d.ts +3 -0
  820. package/dist/store/lib/writableDescriptor.js +15 -0
  821. package/dist/store/recordFiles.d.ts +2 -0
  822. package/dist/store/recordFiles.js +27 -0
  823. package/dist/store/recordRoot.d.ts +3 -0
  824. package/dist/store/recordRoot.js +26 -0
  825. package/dist/store/relocate.d.ts +9 -0
  826. package/dist/store/relocate.js +52 -0
  827. package/dist/store/relocatePlan.d.ts +5 -0
  828. package/dist/store/relocatePlan.js +79 -0
  829. package/dist/store/rename.d.ts +8 -0
  830. package/dist/store/rename.js +95 -0
  831. package/dist/store/revert.d.ts +7 -0
  832. package/dist/store/revert.js +86 -0
  833. package/dist/store/rewriteRefsBatch.d.ts +3 -0
  834. package/dist/store/rewriteRefsBatch.js +142 -0
  835. package/dist/store/rm.d.ts +7 -0
  836. package/dist/store/rm.js +187 -0
  837. package/dist/store/set.d.ts +6 -0
  838. package/dist/store/set.js +80 -0
  839. package/dist/store/types.d.ts +40 -0
  840. package/dist/store/types.js +1 -0
  841. package/dist/store/vouched.d.ts +13 -0
  842. package/dist/store/vouched.js +31 -0
  843. package/dist/store/withWriteLock.d.ts +2 -0
  844. package/dist/store/withWriteLock.js +40 -0
  845. package/dist/store/writeLockPath.d.ts +2 -0
  846. package/dist/store/writeLockPath.js +20 -0
  847. package/dist/targetCommand.d.ts +2 -0
  848. package/dist/targetCommand.js +45 -0
  849. package/dist/testing.d.ts +23 -0
  850. package/dist/testing.js +85 -0
  851. package/dist/types.d.ts +699 -0
  852. package/dist/types.js +1 -0
  853. package/dist/ui-views/lib/assignPath.d.ts +17 -0
  854. package/dist/ui-views/lib/assignPath.js +34 -0
  855. package/dist/ui-views/lib/assignViewValue.d.ts +5 -0
  856. package/dist/ui-views/lib/assignViewValue.js +9 -0
  857. package/dist/ui-views/lib/consts.d.ts +21 -0
  858. package/dist/ui-views/lib/consts.js +27 -0
  859. package/dist/ui-views/lib/parseViewValue.d.ts +6 -0
  860. package/dist/ui-views/lib/parseViewValue.js +50 -0
  861. package/dist/ui-views/lib/viewOverlayOf.d.ts +2 -0
  862. package/dist/ui-views/lib/viewOverlayOf.js +19 -0
  863. package/dist/ui-views/moveUiView.d.ts +31 -0
  864. package/dist/ui-views/moveUiView.js +56 -0
  865. package/dist/ui-views/removeUiView.d.ts +6 -0
  866. package/dist/ui-views/removeUiView.js +17 -0
  867. package/dist/ui-views/saveUiView.d.ts +25 -0
  868. package/dist/ui-views/saveUiView.js +80 -0
  869. package/dist/ui-views/uiViewsCommand.d.ts +4 -0
  870. package/dist/ui-views/uiViewsCommand.js +118 -0
  871. package/dist/update/parseUpdateArgs.d.ts +9 -0
  872. package/dist/update/parseUpdateArgs.js +32 -0
  873. package/dist/update/update.d.ts +7 -0
  874. package/dist/update/update.js +57 -0
  875. package/dist/update/updateModules.d.ts +19 -0
  876. package/dist/update/updateModules.js +221 -0
  877. package/dist/update-setup.d.ts +1 -0
  878. package/dist/update-setup.js +14 -0
  879. package/dist/usage.d.ts +1 -0
  880. package/dist/usage.js +281 -0
  881. package/dist/workspace/commitByRepo.d.ts +4 -0
  882. package/dist/workspace/commitByRepo.js +51 -0
  883. package/dist/workspace/declaredGitModules.d.ts +51 -0
  884. package/dist/workspace/declaredGitModules.js +89 -0
  885. package/dist/workspace/discoverModules.d.ts +23 -0
  886. package/dist/workspace/discoverModules.js +123 -0
  887. package/dist/workspace/envContext.d.ts +3 -0
  888. package/dist/workspace/envContext.js +11 -0
  889. package/dist/workspace/findWorkspace.d.ts +2 -0
  890. package/dist/workspace/findWorkspace.js +49 -0
  891. package/dist/workspace/layerEntries.d.ts +16 -0
  892. package/dist/workspace/layerEntries.js +36 -0
  893. package/dist/workspace/lib/aheadCount.d.ts +6 -0
  894. package/dist/workspace/lib/aheadCount.js +29 -0
  895. package/dist/workspace/lib/assertCommentsKept.d.ts +16 -0
  896. package/dist/workspace/lib/assertCommentsKept.js +27 -0
  897. package/dist/workspace/lib/isTracked.d.ts +2 -0
  898. package/dist/workspace/lib/isTracked.js +14 -0
  899. package/dist/workspace/lib/shortHead.d.ts +1 -0
  900. package/dist/workspace/lib/shortHead.js +10 -0
  901. package/dist/workspace/moduleRows.d.ts +7 -0
  902. package/dist/workspace/moduleRows.js +9 -0
  903. package/dist/workspace/navFragments.d.ts +54 -0
  904. package/dist/workspace/navFragments.js +223 -0
  905. package/dist/workspace/parseEnvValues.d.ts +1 -0
  906. package/dist/workspace/parseEnvValues.js +13 -0
  907. package/dist/workspace/renderTemplate.d.ts +2 -0
  908. package/dist/workspace/renderTemplate.js +26 -0
  909. package/dist/workspace/reportCommits.d.ts +10 -0
  910. package/dist/workspace/reportCommits.js +18 -0
  911. package/dist/workspace/types.d.ts +90 -0
  912. package/dist/workspace/types.js +1 -0
  913. package/dist/workspace/writeGated.d.ts +9 -0
  914. package/dist/workspace/writeGated.js +128 -0
  915. package/package.json +45 -22
  916. package/skills/using-dreamteamer/SKILL.md +1 -1
  917. package/skills/using-dreamteamer/references/collections.md +1 -1
  918. package/skills/using-dreamteamer/references/skills.md +7 -0
  919. package/skills/using-dreamteamer/references/ui-views.md +2 -2
  920. package/skills/using-dreamteamer/references/writing-a-module.md +14 -0
  921. package/scripts/migrate-descriptors-v2.mjs +0 -795
  922. package/scripts/migrate-stubs.mjs +0 -98
  923. package/src/api.d.ts +0 -154
  924. package/src/api.js +0 -109
  925. package/src/check-alone.js +0 -171
  926. package/src/check.js +0 -427
  927. package/src/checkout.js +0 -705
  928. package/src/cli.js +0 -1000
  929. package/src/collections-cli.js +0 -1352
  930. package/src/commit.js +0 -611
  931. package/src/compile-collections.js +0 -481
  932. package/src/compile.js +0 -1498
  933. package/src/descriptor-v2.js +0 -167
  934. package/src/descriptor.js +0 -99
  935. package/src/doctor.js +0 -69
  936. package/src/env-vars.js +0 -59
  937. package/src/env-write.js +0 -162
  938. package/src/events.js +0 -204
  939. package/src/exports-cli.js +0 -91
  940. package/src/exports.js +0 -162
  941. package/src/extensions.js +0 -228
  942. package/src/field-values.js +0 -70
  943. package/src/fields.js +0 -255
  944. package/src/filter.js +0 -154
  945. package/src/fractional-index.js +0 -44
  946. package/src/harnesses.js +0 -649
  947. package/src/history.js +0 -90
  948. package/src/init.js +0 -473
  949. package/src/install-modules.js +0 -430
  950. package/src/namespace.js +0 -215
  951. package/src/nav-fragments.js +0 -190
  952. package/src/nav.js +0 -185
  953. package/src/placement.js +0 -219
  954. package/src/presentation.js +0 -182
  955. package/src/record-commands.js +0 -94
  956. package/src/records-api.d.ts +0 -210
  957. package/src/records-api.js +0 -41
  958. package/src/records.js +0 -109
  959. package/src/ref.js +0 -39
  960. package/src/relations.js +0 -62
  961. package/src/runtime.js +0 -160
  962. package/src/scaffold-templates.js +0 -85
  963. package/src/schema-ops.js +0 -2959
  964. package/src/semver.js +0 -36
  965. package/src/setup-contract.js +0 -101
  966. package/src/setup.js +0 -518
  967. package/src/store.js +0 -1940
  968. package/src/template.js +0 -201
  969. package/src/temporal.js +0 -157
  970. package/src/testing.d.ts +0 -29
  971. package/src/testing.js +0 -86
  972. package/src/unread-data.js +0 -74
  973. package/src/update-setup.js +0 -22
  974. package/src/update.js +0 -138
  975. package/src/views.js +0 -206
  976. package/src/workspace.js +0 -214
  977. package/src/yaml.js +0 -251
@@ -0,0 +1,1248 @@
1
+ #!/usr/bin/env node
2
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
3
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
4
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
5
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
6
+ });
7
+ }
8
+ return path;
9
+ };
10
+ // migrate-descriptors-v2 — rewrite a workspace's v1 descriptor sources in descriptor format v2.
11
+ //
12
+ // node node_modules/dreamteamer/dist/scripts/migrate-descriptors-v2.js [--root <workspace>] [--dry-run]
13
+ //
14
+ // What it rewrites, under the workspace's own sources (`modules/*/` and a classic root layout):
15
+ // - every `*.collection.yaml`, and every `*.collection-template.yaml`, which becomes `mixins/<id>.mixin.yaml`;
16
+ // - every `*.ui-view.yaml`: `route`, `scope`, and the collection's own `display` block, layout option
17
+ // keys renamed. A `default: true` view is not a view in v2 — the collection's `display` is its
18
+ // default view — so it folds into that descriptor's `display.list` (a record-scope one into
19
+ // `display.record`), or into an overlay when the collection belongs to another module, and the
20
+ // view file is deleted;
21
+ // - every `*.command-binding.yaml`: `scope`, `available_when`, `done_when`;
22
+ // - the `dreamteamer` block of every package.json: snake_case keys, `peer_collections`, and
23
+ // `disable` entries as `modules/<module>` or `<kind>/<id>`;
24
+ // - the workspace's `dreamteamer.md`, which is named `DREAMTEAMER.md`, and its .gitignore, which
25
+ // gains the generated harness files (it prints the `git rm --cached` for any git still tracks).
26
+ // Skill, agent and command frontmatter keeps its keys, so it is not touched.
27
+ // What it never touches: anything under `data/`, `node_modules/` or `git_modules/` (somebody else's
28
+ // sources — convert those in their own repo), and the bytes of any record.
29
+ //
30
+ // It edits the YAML DOCUMENT, not a re-dump, so a comment stays on the key it was written above, and
31
+ // it is idempotent: a source already in v2 is left alone. A relation declared on its OWNER (v1
32
+ // spelling A, `x-inverse`) is folded into the one v2 spelling — a `mirror_of` field on the target's
33
+ // descriptor — when the target is in the same tree; otherwise it is reported.
34
+ //
35
+ // The pure half (`convertCollection`, `convertTemplate`, `convertView`, `foldDisplay`,
36
+ // `convertBinding`, `convertPackage`, `addMirrorField`, `recordTitle`) is exported for the tests.
37
+ import fs from "node:fs";
38
+ import path from "node:path";
39
+ import { fileURLToPath } from "node:url";
40
+ import { parseDocument, isMap, isSeq, isScalar, Scalar, visit } from "yaml";
41
+ import { execFileSync } from "node:child_process";
42
+ // Run from a checkout (scripts/x.ts beside src/) and from the npm package (built to dist/scripts/x.js,
43
+ // one level under the engine's dist/*.js). Run as scripts/x.ts it imports the source beside it — running
44
+ // the TypeScript is that explicit choice; built, it imports the dist/ it sits in.
45
+ const engine = (name) => import(__rewriteRelativeImportExtension(new URL(fs.existsSync(new URL("../src/api.ts", import.meta.url)) ? `../src/${name}.ts` : `../${name}.js`, import.meta.url).href));
46
+ const { singular } = await engine("lib/singular");
47
+ const { MANIFEST_KEYS } = await engine("compile/consts");
48
+ const { V2_KEYS: V2_ORDER } = await engine("compile/consts");
49
+ const STRINGIFY = { lineWidth: 0, flowCollectionPadding: false };
50
+ const FIELD_ORDER = [
51
+ "type",
52
+ "title",
53
+ "required",
54
+ "many",
55
+ "default",
56
+ "enum",
57
+ "unique",
58
+ "mirror_of",
59
+ "on_delete",
60
+ "soft",
61
+ "sensitive",
62
+ "body",
63
+ "derived",
64
+ "virtual",
65
+ "deprecated",
66
+ "passthrough",
67
+ "fields",
68
+ "values",
69
+ "item_title",
70
+ "examples",
71
+ "pattern",
72
+ "minimum",
73
+ "maximum",
74
+ "minItems",
75
+ "maxItems",
76
+ "minLength",
77
+ "maxLength",
78
+ "const",
79
+ "display",
80
+ "description",
81
+ ];
82
+ const PASS = [
83
+ "title",
84
+ "default",
85
+ "examples",
86
+ "pattern",
87
+ "minimum",
88
+ "maximum",
89
+ "minItems",
90
+ "maxItems",
91
+ "minLength",
92
+ "maxLength",
93
+ "const",
94
+ "description",
95
+ ];
96
+ /** Block style is canonical: a flow MAPPING is accepted on input and never written (a comma ends a
97
+ * flow value). Flow sequences of scalars stay as written. */
98
+ function toText(doc) {
99
+ visit(doc, {
100
+ Map(_, n) {
101
+ if (n.items.length)
102
+ n.flow = false;
103
+ },
104
+ });
105
+ return doc.toString(STRINGIFY);
106
+ }
107
+ const keyOf = (pair) => String(isScalar(pair.key) ? pair.key.value : pair.key);
108
+ const pairOf = (map, k) => map?.items?.find(p => keyOf(p) === k);
109
+ const toJS = (node) => node && typeof node.toJSON === "function" ? node.toJSON() : node;
110
+ /** The suffix a v1 engine derived for an unauthored `storage.suffix` — what every existing record's
111
+ * filename carries. The converter writes it explicitly wherever v2's inflector would derive another,
112
+ * so no record is renamed by an upgrade. */
113
+ function v1Suffix(name) {
114
+ return name.endsWith("ies") ? name.slice(0, -3) + "y" : name.endsWith("s") ? name.slice(0, -1) : name;
115
+ }
116
+ /**
117
+ * A record title whose first token is not a string field cannot be what `dt add <c> "<title>"`
118
+ * fills, and v2 refuses it. Move the first string token to the front, keeping what preceded it as
119
+ * the separator; with no string token at all, return null (the caller drops the key).
120
+ * @param {string} tpl
121
+ * @param {Record<string, string>} types field name → its v2 type
122
+ */
123
+ export function recordTitle(tpl, types) {
124
+ const isText = (f) => types[f] === "string" || types[f] === "markdown";
125
+ const parts = [...String(tpl).matchAll(/\{\{\s*([A-Za-z_][\w-]*)[^}]*\}\}/g)];
126
+ if (!parts.length)
127
+ return tpl;
128
+ const first = parts[0][1];
129
+ // a built-in or a field this converter cannot see the type of is left as written
130
+ if (isText(first) || !(first in types))
131
+ return tpl;
132
+ const at = parts.findIndex(m => isText(m[1]));
133
+ if (at === -1)
134
+ return null;
135
+ const token = parts[at];
136
+ const prev = parts[at - 1];
137
+ const sep = tpl.slice(prev.index + prev[0].length, token.index) || " ";
138
+ const rest = (tpl.slice(0, prev.index + prev[0].length) + tpl.slice(token.index + token[0].length)).trim();
139
+ return `${token[0]}${sep}${rest}`;
140
+ }
141
+ /**
142
+ * Rewrite a map node's pairs to match `value`, in `order`, REUSING the pair (and so the comments)
143
+ * of every key whose value is unchanged and the key's comments wherever a key was renamed. `renamed`
144
+ * maps a new key to the old key whose comments it inherits.
145
+ */
146
+ function rewriteMap(doc, map, value, order, renamed = {}) {
147
+ const keys = Object.keys(value).sort((a, b) => rank(order, a) - rank(order, b));
148
+ map.items = keys.map(k => {
149
+ const old = pairOf(map, k) ?? pairOf(map, renamed[k]);
150
+ const v = value[k];
151
+ if (old && JSON.stringify(toJS(old.value)) === JSON.stringify(v) && keyOf(old) === k)
152
+ return old;
153
+ const pair = doc.createPair(k, v);
154
+ if (old) {
155
+ const oldKey = old.key;
156
+ const newKey = pair.key;
157
+ for (const c of ["commentBefore", "spaceBefore"])
158
+ if (oldKey?.[c] !== undefined)
159
+ newKey[c] = oldKey[c];
160
+ if (old.value?.comment != null && isScalar(pair.value))
161
+ pair.value.comment = old.value.comment;
162
+ // a nested map that is merely re-keyed keeps its own node, comments and all
163
+ if (isMap(old.value) && isMap(pair.value) && v && typeof v === "object" && !Array.isArray(v)) {
164
+ pair.value = old.value;
165
+ // the new value is already in its canonical order (convertField sorts a field's keys)
166
+ rewriteMap(doc, old.value, v, Object.keys(v));
167
+ }
168
+ }
169
+ return pair;
170
+ });
171
+ return map;
172
+ }
173
+ const rank = (order, k) => {
174
+ const i = order.indexOf(k);
175
+ return i === -1 ? order.length : i;
176
+ };
177
+ /**
178
+ * One v1 field definition (plain JS) → its v2 form, plus what the conversion needs to report.
179
+ * @returns {{ field: object, fold?: { name, description?, unique } , warnings: string[] }}
180
+ */
181
+ export function convertField(p, { required = false } = {}) {
182
+ const warnings = [];
183
+ const many = p.type === "array";
184
+ const holder = many && p.items && typeof p.items === "object" ? p.items : p;
185
+ const out = {}; // every branch below sets `type`
186
+ // a SOFT reference must target a named collection while a missing record is tolerated — `soft: true`.
187
+ // One kind stays a plain string: a soft reference into `collections`, whose value names a
188
+ // collection (a peer that may not be installed), not a record of one
189
+ const soft = holder["x-reference-soft"] === true;
190
+ const ref = soft && holder["x-reference"] === "collections" ? undefined : holder["x-reference"];
191
+ if (ref !== undefined) {
192
+ out.type = ref === "*" ? "reference" : ref;
193
+ if (soft)
194
+ out.soft = true;
195
+ }
196
+ else if (holder.type === "object") {
197
+ if (holder.properties) {
198
+ out.type = "object";
199
+ const req = new Set(holder.required ?? []);
200
+ out.fields = Object.fromEntries(Object.entries(holder.properties).map(([k, v]) => [k, convertField(v, { required: req.has(k) }).field]));
201
+ }
202
+ else if (holder.additionalProperties && typeof holder.additionalProperties === "object") {
203
+ out.type = "map";
204
+ const inner = convertField(holder.additionalProperties).field;
205
+ out.values = Object.keys(inner).length === 1 ? inner.type : inner;
206
+ }
207
+ else
208
+ out.type = "map";
209
+ }
210
+ else if (many && (!p.items || typeof p.items !== "object" || p.items.type === undefined)) {
211
+ // an UNTYPED list: v2 has no "any value" element, and every measured one holds strings
212
+ out.type = "string";
213
+ warnings.push("a list with untyped items became `type: string, many: true` — `dt check` confirms the records agree");
214
+ }
215
+ else {
216
+ const f = holder.format;
217
+ out.type =
218
+ holder.type === "string" || holder.type === undefined
219
+ ? f === "markdown"
220
+ ? "markdown"
221
+ : f === "date"
222
+ ? "date"
223
+ : f === "date-time"
224
+ ? "datetime"
225
+ : f === "uri"
226
+ ? "url"
227
+ : f === "email"
228
+ ? "email"
229
+ : "string"
230
+ : holder.type;
231
+ if (!["string", "markdown", "date", "datetime", "url", "email", "integer", "number", "boolean"].includes(out.type)) {
232
+ warnings.push(`type "${holder.type}" has no v2 equivalent — kept as written; fix it by hand`);
233
+ }
234
+ }
235
+ if (required)
236
+ out.required = true;
237
+ if (many)
238
+ out.many = true;
239
+ for (const k of PASS) {
240
+ const v = k === "title" ||
241
+ k === "description" ||
242
+ k === "default" ||
243
+ k === "examples" ||
244
+ k === "minItems" ||
245
+ k === "maxItems"
246
+ ? p[k]
247
+ : (holder[k] ?? p[k]);
248
+ if (v !== undefined)
249
+ out[k] = v;
250
+ }
251
+ const enumv = holder.enum ?? p.enum;
252
+ if (enumv !== undefined) {
253
+ const choices = holder["x-choices"] ?? p["x-choices"];
254
+ out.enum =
255
+ choices && typeof choices === "object" ? Object.fromEntries(enumv.map(v => [v, choices[String(v)] ?? {}])) : enumv;
256
+ }
257
+ const pick = (k) => holder[k] ?? p[k];
258
+ if (pick("x-unique") === true)
259
+ out.unique = true;
260
+ if (pick("x-on-delete") !== undefined)
261
+ out.on_delete = pick("x-on-delete");
262
+ // the body is prose — a v1 body declared as a bare string is the same text after the frontmatter
263
+ if (pick("x-body") === true) {
264
+ out.body = true;
265
+ out.type = "markdown";
266
+ }
267
+ if (pick("x-sensitive") === true)
268
+ out.sensitive = true;
269
+ const inverseOf = pick("x-inverse-of");
270
+ if (inverseOf !== undefined)
271
+ out.mirror_of = String(inverseOf).slice(String(inverseOf).lastIndexOf(".") + 1);
272
+ const tt = holder["x-title-template"];
273
+ if (tt !== undefined) {
274
+ if (out.type === "object" && many)
275
+ out.item_title = tt;
276
+ else
277
+ warnings.push("x-title-template on a reference is dropped — a reference is labelled by its target's record_title");
278
+ }
279
+ if (pick("x-display") !== undefined)
280
+ warnings.push("x-display is dropped — a reference is labelled by its target's record_title");
281
+ let fold;
282
+ const inv = pick("x-inverse");
283
+ if (inv !== undefined) {
284
+ // the object form names the mirror `field` — compile's own reading (materializeRelations)
285
+ const name = typeof inv === "object" ? inv.field : inv;
286
+ const description = pick("x-inverse-description") ??
287
+ (typeof inv === "object" ? inv.description : undefined);
288
+ // v1 wrote both as text; the folded mirror carries them verbatim
289
+ fold = { name: name, description: description, unique: out.unique === true };
290
+ }
291
+ // the same field, its keys in canonical order
292
+ return {
293
+ field: Object.fromEntries(Object.keys(out)
294
+ .sort((a, b) => rank(FIELD_ORDER, a) - rank(FIELD_ORDER, b))
295
+ .map(k => [k, out[k]])),
296
+ fold,
297
+ warnings,
298
+ };
299
+ }
300
+ /**
301
+ * Convert one collection descriptor's TEXT. Returns the new text (null when it was already v2),
302
+ * the relations declared on the owner that need a mirror field on their target, and warnings.
303
+ * @param {string} text
304
+ * @param {{ bareName?: string }} [ctx] the name without its namespace, for the suffix default
305
+ */
306
+ export function convertCollection(text, ctx = {}) {
307
+ const doc = parseDocument(text, { keepSourceTokens: false });
308
+ const top = doc.contents;
309
+ if (!isMap(top))
310
+ return { text: null, folds: [], warnings: ["not a mapping — left alone"] };
311
+ const v1 = top.toJSON();
312
+ if ("fields" in v1)
313
+ return { text: null, folds: [], warnings: [] };
314
+ const warnings = [];
315
+ const folds = [];
316
+ const value = {};
317
+ const renamed = {};
318
+ for (const k of ["name", "title", "singular", "description", "use_when", "sensitive"])
319
+ if (v1[k] !== undefined)
320
+ value[k] = v1[k];
321
+ if (v1.title_template !== undefined) {
322
+ value.record_title = v1.title_template;
323
+ renamed.record_title = "title_template";
324
+ }
325
+ if (v1.group === "system") {
326
+ value.internal = true;
327
+ renamed.internal = "group";
328
+ }
329
+ // storage
330
+ {
331
+ const s = v1.storage ?? {};
332
+ const st = {};
333
+ if (s.path !== undefined)
334
+ st.path = s.path;
335
+ if (s.codec !== undefined)
336
+ st.format = s.codec === "file" ? "binary" : s.codec;
337
+ if (s.shape !== undefined && s.shape !== "file")
338
+ st.shape = s.shape;
339
+ if (s.entry !== undefined)
340
+ st.entry = s.entry;
341
+ const bare = ctx.bareName ??
342
+ String(v1.name ?? "")
343
+ .split("/")
344
+ .pop();
345
+ const onDisk = s.suffix ?? v1Suffix(bare);
346
+ if (onDisk !== singular(bare))
347
+ st.suffix = onDisk;
348
+ if (s.under)
349
+ st.under = { parent: s.under.field, subfolder: s.under.path };
350
+ if (s.max_bytes !== undefined)
351
+ st.max_bytes = s.max_bytes;
352
+ if (s.extensions !== undefined)
353
+ st.accept = s.extensions;
354
+ if (Object.keys(st).length)
355
+ value.storage = st;
356
+ }
357
+ if (v1.id) {
358
+ value.ids = {
359
+ ...(v1.id.generate !== undefined && { from: v1.id.generate }),
360
+ ...(v1.id.pattern !== undefined && { pattern: v1.id.pattern }),
361
+ };
362
+ renamed.ids = "id";
363
+ }
364
+ if (v1.templates) {
365
+ value.mixins = v1.templates.map((t) => String(t).replace(/^collection-templates\//, ""));
366
+ renamed.mixins = "templates";
367
+ }
368
+ if (v1.extends) {
369
+ value.overlay = true;
370
+ renamed.overlay = "extends";
371
+ }
372
+ // fields — the properties map node is RE-KEYED, so every comment above a property travels with it
373
+ const schemaPair = pairOf(top, "schema");
374
+ const propsNode = (schemaPair && isMap(schemaPair.value) ? pairOf(schemaPair.value, "properties")?.value : null);
375
+ const required = new Set(v1.schema?.required ?? []);
376
+ const fields = {};
377
+ const stats = { fields: 0, enums: 0 };
378
+ for (const [k, p] of Object.entries(v1.schema?.properties ?? {})) {
379
+ const { field, fold, warnings: w } = convertField(p, { required: required.has(k) });
380
+ for (const x of w)
381
+ warnings.push(`${k}: ${x}`);
382
+ if (fold)
383
+ folds.push({ field: k, target: field.type, many: field.many === true, ...fold });
384
+ if (field.enum && !Array.isArray(field.enum))
385
+ stats.enums++;
386
+ fields[k] = field;
387
+ stats.fields++;
388
+ }
389
+ // v1 let a descriptor redeclare a template's field; v2 has one source per field. The same shape
390
+ // is the mixin's field, so the redeclaration goes (its own description is printed, not lost); a
391
+ // different shape is the author's call
392
+ const shape = (f) => JSON.stringify(Object.fromEntries(Object.entries(f ?? {})
393
+ .filter(([k]) => k !== "description" && k !== "title")
394
+ .sort(([a], [b]) => a.localeCompare(b))));
395
+ for (const [k, { mixin, field: mf }] of Object.entries(ctx.mixinFieldDefs ?? {})) {
396
+ if (!fields[k])
397
+ continue;
398
+ if (shape(fields[k]) !== shape(mf)) {
399
+ warnings.push(`${k}: also declared by mixin ${mixin} with a different shape — compile refuses a field from two sources; rename this one, or drop it and adjust the mixin`);
400
+ continue;
401
+ }
402
+ if (fields[k].description !== undefined && fields[k].description !== mf.description)
403
+ warnings.push(`${k}: also declared by mixin ${mixin} — dropped here, so its description is the mixin's; this collection's was: "${fields[k].description}"`);
404
+ delete fields[k];
405
+ stats.fields--;
406
+ }
407
+ if (v1.sort_field !== undefined && fields[v1.sort_field]) {
408
+ if (["string"].includes(fields[v1.sort_field].type))
409
+ fields[v1.sort_field].type = "position";
410
+ else
411
+ (value.display ??= {}).list = { ...(value.display?.list ?? {}), sort: v1.sort_field };
412
+ }
413
+ value.fields = fields;
414
+ if (value.record_title !== undefined) {
415
+ const types = {
416
+ ...(ctx.mixinFields ?? {}),
417
+ ...Object.fromEntries(Object.entries(fields).map(([k, f]) => [k, f.type])),
418
+ };
419
+ const fixed = recordTitle(value.record_title, types);
420
+ if (fixed === null) {
421
+ warnings.push(`record_title "${value.record_title}" names no string field to open with — dropped, so the default (title · name · subject) applies`);
422
+ delete value.record_title;
423
+ }
424
+ else
425
+ value.record_title = fixed;
426
+ }
427
+ if (v1.schema?.allOf)
428
+ value.constraints = v1.schema.allOf;
429
+ // display
430
+ const nav = {};
431
+ if (v1.icon !== undefined)
432
+ nav.icon = v1.icon;
433
+ if (v1.order !== undefined)
434
+ nav.order = v1.order;
435
+ if (v1.group !== undefined && v1.group !== "system")
436
+ nav.section = v1.group;
437
+ const list = { ...(value.display?.list ?? {}) };
438
+ if (v1.list_fields !== undefined)
439
+ list.columns = v1.list_fields.map((c) => (c === "last-modified" ? "last_modified" : c));
440
+ if (Object.keys(nav).length || Object.keys(list).length)
441
+ value.display = { ...(Object.keys(nav).length && { nav }), ...(Object.keys(list).length && { list }) };
442
+ // rewrite in place: `fields` takes over the `schema` pair's position and comments
443
+ if (schemaPair) {
444
+ schemaPair.key = doc.createNode("fields");
445
+ if (propsNode) {
446
+ propsNode.items = propsNode.items.filter(pair => fields[keyOf(pair)] !== undefined);
447
+ schemaPair.value = propsNode;
448
+ for (const pair of propsNode.items) {
449
+ const k = keyOf(pair);
450
+ if (!fields[k])
451
+ continue;
452
+ if (isMap(pair.value))
453
+ rewriteMap(doc, pair.value, fields[k], FIELD_ORDER, {
454
+ mirror_of: "x-inverse-of",
455
+ body: "x-body",
456
+ unique: "x-unique",
457
+ on_delete: "x-on-delete",
458
+ sensitive: "x-sensitive",
459
+ fields: "properties",
460
+ });
461
+ else
462
+ pair.value = doc.createNode(fields[k]);
463
+ }
464
+ }
465
+ else
466
+ schemaPair.value = doc.createNode(fields);
467
+ }
468
+ // every other top-level key, in canonical order; anything v1-only is dropped
469
+ const keep = top.items.find(p => keyOf(p) === "fields");
470
+ const rest = { ...value };
471
+ delete rest.fields;
472
+ rewriteMap(doc, top, { ...rest, fields: "__KEEP__" }, V2_ORDER, renamed);
473
+ const at = top.items.findIndex(p => keyOf(p) === "fields");
474
+ if (keep)
475
+ top.items[at] = keep;
476
+ else
477
+ top.items[at] = doc.createPair("fields", fields);
478
+ return { text: toText(doc), folds, warnings, stats };
479
+ }
480
+ /** A v1 collection-template's TEXT → the text of the equivalent mixin. */
481
+ export function convertTemplate(text, id) {
482
+ const v1 = parseDocument(text).toJSON() ?? {};
483
+ const t = v1.template ?? {};
484
+ const req = new Set(t.schema?.required ?? []);
485
+ const mixin = {
486
+ name: id,
487
+ ...(v1.description !== undefined && { description: v1.description }),
488
+ };
489
+ if (t.storage) {
490
+ const s = t.storage;
491
+ const st = {};
492
+ if (s.path !== undefined)
493
+ st.path = s.path;
494
+ if (s.codec !== undefined)
495
+ st.format = s.codec === "file" ? "binary" : s.codec;
496
+ if (s.shape !== undefined && s.shape !== "file")
497
+ st.shape = s.shape;
498
+ if (Object.keys(st).length)
499
+ mixin.storage = st;
500
+ }
501
+ if (t.id)
502
+ mixin.ids = {
503
+ ...(t.id.generate !== undefined && { from: t.id.generate }),
504
+ ...(t.id.pattern !== undefined && { pattern: t.id.pattern }),
505
+ };
506
+ mixin.fields = Object.fromEntries(Object.entries(t.schema?.properties ?? {}).map(([k, p]) => [
507
+ k,
508
+ convertField(p, { required: req.has(k) }).field,
509
+ ]));
510
+ if (t.list_fields)
511
+ mixin.display = {
512
+ list: { columns: t.list_fields.map((c) => (c === "last-modified" ? "last_modified" : c)) },
513
+ };
514
+ const doc = parseDocument(text);
515
+ const out = parseDocument("{}");
516
+ out.contents = out.createNode(mixin);
517
+ out.commentBefore = doc.commentBefore;
518
+ return toText(out);
519
+ }
520
+ /** Insert a mirror field into a v2 descriptor's TEXT, before its body field. No-op when present. */
521
+ export function addMirrorField(text, name, def) {
522
+ const doc = parseDocument(text);
523
+ const fields = doc.contents && pairOf(doc.contents, "fields")?.value;
524
+ if (!isMap(fields))
525
+ return { text, added: false };
526
+ if (pairOf(fields, name))
527
+ return { text, added: false };
528
+ const pair = doc.createPair(name, def);
529
+ const bodyAt = fields.items.findIndex(p => isMap(p.value) && toJS(p.value)?.body === true);
530
+ if (bodyAt === -1)
531
+ fields.items.push(pair);
532
+ else
533
+ fields.items.splice(bodyAt, 0, pair);
534
+ return { text: toText(doc), added: true };
535
+ }
536
+ // ---- ui-views and command-bindings ----------------------------------------------------------------
537
+ const VIEW_ORDER = ["name", "title", "description", "route", "scope", "collection", "filter", "display"];
538
+ const SCOPES = { list: "collection", item: "record", page: "page" };
539
+ /** Layout option keys whose name changes: a field option is named for the role the field plays, a
540
+ * template option for what it labels. `template` labels a card, or a bar on a gantt. */
541
+ const OPTION_KEYS = {
542
+ color_by_field: "color_by",
543
+ group_rows_by_field: "group_by",
544
+ group_columns_by_field: "lanes_by",
545
+ start_field: "start",
546
+ end_field: "end",
547
+ lat_field: "lat",
548
+ lng_field: "lng",
549
+ group_template: "group_title",
550
+ group_summary_template: "group_summary",
551
+ };
552
+ const optionKey = (k, layout) => k === "template"
553
+ ? layout === "gantt"
554
+ ? "bar_title"
555
+ : "card_title"
556
+ : (OPTION_KEYS[k] ?? (/^[a-z][a-z0-9_]*_field$/.test(k) ? k.replace(/_field$/, "") : k));
557
+ const injected = (v) => typeof v === "string" ? v.replace(/^(-?)last-modified$/, "$1last_modified") : v;
558
+ const scalarKey = (pair, k) => {
559
+ if (isScalar(pair.key))
560
+ pair.key.value = k;
561
+ else
562
+ pair.key = new Scalar(k);
563
+ return pair;
564
+ };
565
+ /**
566
+ * One v1 ui-view's TEXT → v2. Returns null when it is already v2. A `default: true` view comes back
567
+ * as `fold` — the display block to merge into its collection's descriptor — and the caller deletes
568
+ * the file; a default view that also filters cannot be a collection's display, and is converted as a
569
+ * named view instead, with a warning.
570
+ * @returns {null | { text?: string, fold?: { collection, block, value, nav, comment }, warnings: string[], options: number }}
571
+ */
572
+ export function convertView(text) {
573
+ const doc = parseDocument(text);
574
+ const top = doc.contents;
575
+ if (!isMap(top))
576
+ return null;
577
+ const v1 = top.toJSON() ?? {};
578
+ if ("route" in v1 || "scope" in v1 || "display" in v1)
579
+ return null;
580
+ const warnings = [];
581
+ const scope = SCOPES[v1.target] ?? v1.target;
582
+ const block = scope === "record" ? "record" : "list";
583
+ const take = (k) => {
584
+ const p = pairOf(top, k);
585
+ if (p)
586
+ top.items.splice(top.items.indexOf(p), 1);
587
+ return p;
588
+ };
589
+ const defaultPair = take("default");
590
+ const fold = v1.default === true && v1.filter === undefined;
591
+ if (v1.default === true && !fold)
592
+ warnings.push("a default view with a filter cannot be its collection's display — converted as a named view");
593
+ // the display sub-block: layout, columns and sort, then the remaining options with their keys renamed
594
+ const sub = doc.createNode({});
595
+ const layoutPair = take("layout");
596
+ const layout = v1.layout;
597
+ if (layoutPair && !(fold && layout === (block === "list" ? "table" : "page")))
598
+ sub.items.push(layoutPair);
599
+ const optionsPair = take("options");
600
+ let renamedOptions = 0;
601
+ if (optionsPair && isMap(optionsPair.value)) {
602
+ const opts = optionsPair.value;
603
+ // a comment above the first option belongs to that option, which may be about to move
604
+ if (opts.commentBefore && opts.items[0]) {
605
+ opts.items[0].key.commentBefore = [opts.commentBefore, opts.items[0].key.commentBefore].filter(Boolean).join("\n");
606
+ opts.commentBefore = undefined;
607
+ }
608
+ for (const k of block === "list" ? ["columns", "sort"] : []) {
609
+ const p = pairOf(opts, k);
610
+ if (!p)
611
+ continue;
612
+ opts.items.splice(opts.items.indexOf(p), 1);
613
+ if (k === "sort" && isScalar(p.value))
614
+ p.value.value = injected(p.value.value);
615
+ if (k === "columns" && isSeq(p.value))
616
+ for (const c of p.value.items)
617
+ if (isScalar(c))
618
+ c.value = injected(c.value);
619
+ sub.items.push(p);
620
+ }
621
+ for (const p of opts.items) {
622
+ const k = keyOf(p);
623
+ const to = optionKey(k, layout);
624
+ if (to !== k) {
625
+ scalarKey(p, to);
626
+ renamedOptions++;
627
+ }
628
+ if (isScalar(p.value) && to !== k && /_field$/.test(k))
629
+ p.value.value = injected(p.value.value);
630
+ }
631
+ opts.flow = false;
632
+ if (opts.items.length)
633
+ sub.items.push(optionsPair);
634
+ }
635
+ const navPair = take("nav");
636
+ if (navPair && isMap(navPair.value)) {
637
+ const label = pairOf(navPair.value, "label");
638
+ if (label)
639
+ scalarKey(label, "title");
640
+ navPair.value.flow = false;
641
+ }
642
+ if (fold) {
643
+ const nav = (toJS(navPair?.value) ?? {});
644
+ if (nav.title !== undefined)
645
+ warnings.push(`nav.label "${nav.title}" is dropped — a collection's nav entry reads its \`title\``);
646
+ // the view's header, and any comment on a key that does not survive, reads above the folded block
647
+ const comment = [
648
+ doc.commentBefore,
649
+ ...top.items.map(p => p.key?.commentBefore),
650
+ defaultPair?.key?.commentBefore,
651
+ ]
652
+ .filter(Boolean)
653
+ .join("\n") || undefined;
654
+ return {
655
+ fold: {
656
+ collection: String(v1.collection ?? "").replace(/^collections\//, ""),
657
+ block,
658
+ node: sub,
659
+ nav: {
660
+ ...(nav.icon !== undefined && { icon: nav.icon }),
661
+ ...(nav.order !== undefined && { order: nav.order }),
662
+ },
663
+ comment,
664
+ },
665
+ warnings,
666
+ options: renamedOptions,
667
+ };
668
+ }
669
+ const pathPair = pairOf(top, "path");
670
+ if (pathPair)
671
+ scalarKey(pathPair, "route");
672
+ const targetPair = pairOf(top, "target");
673
+ if (targetPair) {
674
+ scalarKey(targetPair, "scope");
675
+ if (isScalar(targetPair.value))
676
+ targetPair.value.value = scope;
677
+ }
678
+ const display = doc.createNode({});
679
+ if (navPair)
680
+ display.items.push(navPair);
681
+ if (sub.items.length)
682
+ display.items.push(doc.createPair(block, sub));
683
+ if (display.items.length) {
684
+ const pair = doc.createPair("display", display);
685
+ // the moved pairs carry their own comments; one above a dropped `default: false` reads on the block
686
+ if (defaultPair?.key?.commentBefore)
687
+ pair.key.commentBefore = defaultPair.key.commentBefore;
688
+ top.items.push(pair);
689
+ }
690
+ top.items.sort((a, b) => rank(VIEW_ORDER, keyOf(a)) - rank(VIEW_ORDER, keyOf(b)));
691
+ return { text: toText(doc), warnings, options: renamedOptions };
692
+ }
693
+ /** Merge a folded default view into a v2 descriptor's TEXT: its sub-block keys win, and nav keys
694
+ * fill only where the descriptor has none. The view's pairs move whole, so a comment above a key
695
+ * stays above it, and the view's own header lands above the block. */
696
+ export function foldDisplay(text, { block, node, nav = {}, comment, }) {
697
+ const doc = parseDocument(text);
698
+ const top = doc.contents;
699
+ let display = pairOf(top, "display");
700
+ if (!display) {
701
+ display = doc.createPair("display", {});
702
+ top.items.push(display);
703
+ }
704
+ if (!isMap(display.value))
705
+ display.value = doc.createNode({});
706
+ const shown = display.value;
707
+ shown.flow = false;
708
+ const ensure = (k) => {
709
+ let p = pairOf(shown, k);
710
+ if (!p) {
711
+ p = doc.createPair(k, {});
712
+ shown.items.push(p);
713
+ }
714
+ if (!isMap(p.value))
715
+ p.value = doc.createNode({});
716
+ const map = p.value;
717
+ map.flow = false;
718
+ return p;
719
+ };
720
+ if (node?.items?.length) {
721
+ const sub = ensure(block);
722
+ for (const p of node.items) {
723
+ const old = pairOf(sub.value, keyOf(p));
724
+ if (old)
725
+ sub.value.items.splice(sub.value.items.indexOf(old), 1, p);
726
+ else
727
+ sub.value.items.push(p);
728
+ }
729
+ if (comment)
730
+ sub.key.commentBefore = [sub.key.commentBefore, comment].filter(Boolean).join("\n");
731
+ }
732
+ const navKeys = Object.entries(nav).filter(([k]) => !pairOf(pairOf(shown, "nav")?.value, k));
733
+ if (navKeys.length) {
734
+ const n = ensure("nav");
735
+ for (const [k, v] of navKeys)
736
+ n.value.items.push(doc.createPair(k, v));
737
+ }
738
+ shown.items.sort((a, b) => rank(["nav", "list", "record", "form"], keyOf(a)) - rank(["nav", "list", "record", "form"], keyOf(b)));
739
+ return toText(doc);
740
+ }
741
+ const BINDING_KEYS = { target: "scope", "can-enter": "available_when", "can-exit": "done_when" };
742
+ /** One v1 command-binding's TEXT → v2, keys renamed in place so every comment stays put. Null when v2. */
743
+ export function convertBinding(text) {
744
+ const doc = parseDocument(text);
745
+ if (!isMap(doc.contents))
746
+ return null;
747
+ const hits = doc.contents.items.filter(p => BINDING_KEYS[keyOf(p)]);
748
+ if (!hits.length)
749
+ return null;
750
+ for (const p of hits)
751
+ scalarKey(p, BINDING_KEYS[keyOf(p)]);
752
+ return toText(doc);
753
+ }
754
+ // ---- package.json `dreamteamer` blocks --------------------------------------------------------------
755
+ /**
756
+ * A package.json's TEXT with its `dreamteamer` block in v2: snake_case keys, `peer_collections`, and
757
+ * `disable` in the record grammar — a whole module (a bare name or `@scope/name`) as
758
+ * `modules/<it>`, a `<module>/<entity>` as `<kind>/<entity>`. `kindsOf(module, entity)` answers
759
+ * which kinds a module ships that entity in — [] when it does not, null when the module is unknown.
760
+ * A key the engine does not read is reported, since compile refuses it. Null text when nothing changes.
761
+ */
762
+ export function convertPackage(text, kindsOf) {
763
+ const pkg = JSON.parse(text);
764
+ const block = pkg.dreamteamer;
765
+ if (!block || typeof block !== "object")
766
+ return { text: null, warnings: [] };
767
+ const warnings = [];
768
+ const out = {};
769
+ for (const [k, v] of Object.entries(block)) {
770
+ const key = k === "peerDependencies" || k === "peer-dependencies" ? "peer_collections" : k.replace(/-/g, "_");
771
+ out[key] = key === "peer_collections" && Array.isArray(v) ? v.map(c => String(c).replace(/^collections\//, "")) : v;
772
+ }
773
+ for (const k of Object.keys(out))
774
+ if (!MANIFEST_KEYS.includes(k))
775
+ warnings.push(`dreamteamer.${k} is not a key the engine reads, and compile refuses it — the keys are ${MANIFEST_KEYS.join(" · ")}`);
776
+ if (Array.isArray(out.disable)) {
777
+ out.disable = out.disable.flatMap(d => {
778
+ if (typeof d !== "string")
779
+ return [d];
780
+ if (!d.includes("/") || /^@[^/]+\/[^/]+$/.test(d))
781
+ return [`modules/${d}`];
782
+ const segs = d.split("/");
783
+ const mod = d.startsWith("@") ? segs.slice(0, 2).join("/") : segs[0];
784
+ const id = segs.slice(d.startsWith("@") ? 2 : 1).join("/");
785
+ const kinds = kindsOf(mod, id);
786
+ if (kinds === null)
787
+ return [d]; // not a module: already `<kind>/<id>`, or a name this tree cannot see
788
+ if (!kinds.length) {
789
+ warnings.push(`disable "${d}": module ${mod} ships no "${id}" — left as written`);
790
+ return [d];
791
+ }
792
+ return kinds.map(k => `${k}/${id}`);
793
+ });
794
+ }
795
+ pkg.dreamteamer = out;
796
+ const indent = /^[ \t]+(?=")/m.exec(text)?.[0] ?? "\t";
797
+ const next = JSON.stringify(pkg, null, indent) + (text.endsWith("\n") ? "\n" : "");
798
+ return { text: next === text ? null : next, warnings };
799
+ }
800
+ /** The kinds a module root ships one entity id in — the folders compile reads, either layout. */
801
+ function entityKinds(moduleRoot, id) {
802
+ const kinds = [];
803
+ for (const kind of [
804
+ "collections",
805
+ "skills",
806
+ "agents",
807
+ "commands",
808
+ "command-bindings",
809
+ "ui-views",
810
+ "mixins",
811
+ "collection-templates",
812
+ ]) {
813
+ for (const dir of [path.join(moduleRoot, kind), path.join(moduleRoot, "system", kind)]) {
814
+ if (!fs.existsSync(dir))
815
+ continue;
816
+ const hit = kind === "skills"
817
+ ? fs.existsSync(path.join(dir, id))
818
+ : [...walk(dir)].some(f => path
819
+ .relative(dir, f)
820
+ .split(path.sep)
821
+ .join("/")
822
+ .replace(/\.[^.]+\.(yaml|md|json)$/, "") === id);
823
+ if (hit) {
824
+ kinds.push(kind === "collection-templates" ? "mixins" : kind);
825
+ break;
826
+ }
827
+ }
828
+ }
829
+ return [...new Set(kinds)];
830
+ }
831
+ /** Every module this workspace can see, by package name → the roots carrying that name (the
832
+ * workspace's own package may share its module's name). */
833
+ function moduleRootsByName(root) {
834
+ const out = new Map();
835
+ const add = (dir) => {
836
+ try {
837
+ const name = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")).name;
838
+ if (name)
839
+ out.set(name, [...(out.get(name) ?? []), dir]);
840
+ }
841
+ catch {
842
+ /* not a module */
843
+ }
844
+ };
845
+ for (const base of ["modules", "git_modules"]) {
846
+ const at = path.join(root, base);
847
+ if (!fs.existsSync(at))
848
+ continue;
849
+ for (const e of fs.readdirSync(at, { withFileTypes: true })) {
850
+ if (!e.isDirectory() && !e.isSymbolicLink())
851
+ continue;
852
+ if (e.name.startsWith("@"))
853
+ for (const s of fs.readdirSync(path.join(at, e.name)))
854
+ add(path.join(at, e.name, s));
855
+ else
856
+ add(path.join(at, e.name));
857
+ }
858
+ }
859
+ try {
860
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
861
+ for (const dep of Object.keys({ ...pkg.dependencies, ...pkg.devDependencies }))
862
+ add(path.join(root, "node_modules", dep));
863
+ }
864
+ catch {
865
+ /* no package.json is caught by the CLI */
866
+ }
867
+ add(root);
868
+ return out;
869
+ }
870
+ // ---- the CLI ------------------------------------------------------------------------------------
871
+ function* walk(dir) {
872
+ if (!fs.existsSync(dir))
873
+ return;
874
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
875
+ const p = path.join(dir, e.name);
876
+ if (e.isDirectory())
877
+ yield* walk(p);
878
+ else
879
+ yield p;
880
+ }
881
+ }
882
+ /** Every source root a workspace AUTHORS: its modules, and the root itself for the classic layout. */
883
+ function sourceRoots(root) {
884
+ const roots = [];
885
+ const mods = path.join(root, "modules");
886
+ if (fs.existsSync(mods))
887
+ for (const e of fs.readdirSync(mods, { withFileTypes: true }))
888
+ if (e.isDirectory())
889
+ roots.push(path.join(mods, e.name));
890
+ roots.push(root);
891
+ return roots;
892
+ }
893
+ export function migrate(root, { dryRun = false, log = console.log } = {}) {
894
+ const plan = {
895
+ descriptors: 0,
896
+ fields: 0,
897
+ folded: 0,
898
+ enums: 0,
899
+ mixins: 0,
900
+ viewsFolded: 0,
901
+ viewsConverted: 0,
902
+ bindings: 0,
903
+ packages: 0,
904
+ instructions: 0,
905
+ ignored: 0,
906
+ warnings: [],
907
+ unfolded: [],
908
+ };
909
+ const texts = new Map(); // file -> new text (null: removed)
910
+ const byName = new Map(); // collection name -> file of its BASE descriptor
911
+ const moduleOf = new Map(); // descriptor file -> the module root it sits in
912
+ const roots = sourceRoots(root);
913
+ const at = (file) => path.relative(root, file);
914
+ const current = (file) => (texts.has(file) ? texts.get(file) : fs.readFileSync(file, "utf8"));
915
+ // templates first: a mixin's field types are what a converted record_title may open with
916
+ const mixinTypes = new Map(); // mixin id -> { field: type }
917
+ const mixinDefs = new Map(); // mixin id -> { field: its v2 definition }
918
+ for (const r of roots) {
919
+ for (const file of walk(path.join(r, "collection-templates"))) {
920
+ if (!file.endsWith(".collection-template.yaml"))
921
+ continue;
922
+ const id = path.basename(file).replace(/\.collection-template\.yaml$/, "");
923
+ const dest = path.join(r, "mixins", `${id}.mixin.yaml`);
924
+ let text;
925
+ try {
926
+ text = convertTemplate(fs.readFileSync(file, "utf8"), id);
927
+ }
928
+ catch (e) {
929
+ throw new Error(`${at(file)}: ${e.message}`, { cause: e });
930
+ }
931
+ texts.set(dest, text);
932
+ texts.set(file, null);
933
+ mixinTypes.set(id, Object.fromEntries(Object.entries(parseDocument(text).toJSON()?.fields ?? {}).map(([k, f]) => [k, f?.type])));
934
+ mixinDefs.set(id, parseDocument(text).toJSON()?.fields ?? {});
935
+ plan.mixins++;
936
+ // a module published from npm ships only what its `files` names — the mixins must travel
937
+ const pkgFile = path.join(r, "package.json");
938
+ if (r !== root && fs.existsSync(pkgFile)) {
939
+ const pkg = JSON.parse(current(pkgFile));
940
+ if (Array.isArray(pkg.files) && !pkg.files.includes("mixins")) {
941
+ pkg.files.push("mixins");
942
+ texts.set(pkgFile, JSON.stringify(pkg, null, "\t") + "\n");
943
+ }
944
+ }
945
+ }
946
+ }
947
+ for (const r of roots) {
948
+ for (const file of walk(path.join(r, "collections"))) {
949
+ if (!file.endsWith(".collection.yaml"))
950
+ continue;
951
+ const text = fs.readFileSync(file, "utf8");
952
+ const parsed = parseDocument(text);
953
+ if (parsed.errors.length)
954
+ throw new Error(`${at(file)}: ${parsed.errors[0].message.split("\n")[0]}`);
955
+ const v1 = parsed.toJSON() ?? {};
956
+ const name = v1.name;
957
+ const ids = (Array.isArray(v1.templates) ? v1.templates : []).map((t) => String(t).replace(/^collection-templates\//, ""));
958
+ const mixinFields = Object.assign({}, ...ids.map(t => mixinTypes.get(t) ?? {}));
959
+ const mixinFieldDefs = Object.assign({}, ...ids.map(t => Object.fromEntries(Object.entries(mixinDefs.get(t) ?? {}).map(([k, f]) => [k, { mixin: t, field: f }]))));
960
+ let res;
961
+ try {
962
+ res = convertCollection(text, {
963
+ bareName: String(name ?? "")
964
+ .split("/")
965
+ .pop(),
966
+ mixinFields,
967
+ mixinFieldDefs,
968
+ });
969
+ }
970
+ catch (e) {
971
+ throw new Error(`${at(file)}: ${e.message}`, { cause: e });
972
+ }
973
+ for (const w of res.warnings)
974
+ plan.warnings.push(`${at(file)}: ${w}`);
975
+ moduleOf.set(file, r);
976
+ if (name && !("overlay" in v1) && !("extends" in v1))
977
+ byName.set(name, file);
978
+ if (res.text === null)
979
+ continue;
980
+ texts.set(file, res.text);
981
+ plan.descriptors++;
982
+ plan.fields += res.stats.fields;
983
+ plan.enums += res.stats.enums;
984
+ for (const f of res.folds) {
985
+ // the mirror's type is the OWNER collection, its cardinality the inverse of the owner's
986
+ f.owner = name;
987
+ f.ownerRoot = r;
988
+ (plan._folds ??= []).push(f);
989
+ }
990
+ }
991
+ }
992
+ for (const f of plan._folds ?? []) {
993
+ const targets = Array.isArray(f.target) ? f.target : [f.target];
994
+ for (const t of targets) {
995
+ const file = byName.get(t);
996
+ if (!file) {
997
+ plan.unfolded.push(`${f.owner}.${f.field} → ${t}.${f.name}: the target's descriptor is not in this tree — add \`${f.name}: { type: ${f.owner}, ${f.unique && !f.many ? "" : "many: true, "}mirror_of: ${f.field} }\` to it by hand`);
998
+ continue;
999
+ }
1000
+ const def = {
1001
+ type: f.owner,
1002
+ ...(!(f.unique && !f.many) && { many: true }),
1003
+ mirror_of: f.field,
1004
+ ...(f.description && { description: f.description }),
1005
+ };
1006
+ // A mirror on ANOTHER module's collection goes in an overlay in the OWNER's module — the
1007
+ // v1 stamp only happened while the owner was installed, and writing the field into the
1008
+ // target's own descriptor would make that module reference one it does not depend on.
1009
+ const dest = moduleOf.get(file) === f.ownerRoot ? file : overlayFile(f.ownerRoot, t, texts);
1010
+ let text, added;
1011
+ try {
1012
+ ;
1013
+ ({ text, added } = addMirrorField(current(dest), f.name, def));
1014
+ }
1015
+ catch (e) {
1016
+ throw new Error(`${at(dest)} (mirror ${f.name}): ${e.message}`, { cause: e });
1017
+ }
1018
+ if (added) {
1019
+ texts.set(dest, text);
1020
+ plan.folded++;
1021
+ }
1022
+ }
1023
+ }
1024
+ delete plan._folds;
1025
+ // ui-views: a default view folds into its collection's display; every other view is rewritten
1026
+ for (const r of roots) {
1027
+ for (const file of walk(path.join(r, "ui-views"))) {
1028
+ if (!file.endsWith(".ui-view.yaml"))
1029
+ continue;
1030
+ let res;
1031
+ try {
1032
+ res = convertView(fs.readFileSync(file, "utf8"));
1033
+ }
1034
+ catch (e) {
1035
+ throw new Error(`${at(file)}: ${e.message}`, { cause: e });
1036
+ }
1037
+ if (!res)
1038
+ continue;
1039
+ for (const w of res.warnings)
1040
+ plan.warnings.push(`${at(file)}: ${w}`);
1041
+ if (!res.fold) {
1042
+ texts.set(file, res.text);
1043
+ plan.viewsConverted++;
1044
+ continue;
1045
+ }
1046
+ const { collection } = res.fold;
1047
+ const base = byName.get(collection);
1048
+ // the view's own module edits the collection it owns; any other module's collection takes an overlay
1049
+ const dest = base && moduleOf.get(base) === r ? base : overlayFile(r, collection, texts);
1050
+ if (dest !== base) {
1051
+ const owner = base ? packageName(moduleOf.get(base)) : null;
1052
+ const deps = (() => {
1053
+ try {
1054
+ return JSON.parse(current(path.join(r, "package.json"))).dreamteamer?.dependencies ?? [];
1055
+ }
1056
+ catch {
1057
+ return [];
1058
+ }
1059
+ })();
1060
+ if (!(owner === null && ENGINE_COLLECTIONS.has(collection)) && (!owner || !deps.includes(owner)))
1061
+ plan.warnings.push(`${at(file)}: folded into an overlay of ${collection} (${at(dest)}) — an overlay needs ${owner ? `"${owner}"` : `the module that owns ${collection}`} in this module's \`dreamteamer.dependencies\``);
1062
+ }
1063
+ try {
1064
+ texts.set(dest, foldDisplay(current(dest), res.fold));
1065
+ }
1066
+ catch (e) {
1067
+ throw new Error(`${at(dest)} (view ${path.basename(file)}): ${e.message}`, { cause: e });
1068
+ }
1069
+ texts.set(file, null);
1070
+ plan.viewsFolded++;
1071
+ }
1072
+ for (const file of walk(path.join(r, "command-bindings"))) {
1073
+ if (!file.endsWith(".command-binding.yaml"))
1074
+ continue;
1075
+ const text = convertBinding(fs.readFileSync(file, "utf8"));
1076
+ if (text === null)
1077
+ continue;
1078
+ texts.set(file, text);
1079
+ plan.bindings++;
1080
+ }
1081
+ }
1082
+ // package.json blocks: the workspace's and each module's own
1083
+ const modules = moduleRootsByName(root);
1084
+ const kindsOf = (mod, id) => modules.has(mod) ? [...new Set(modules.get(mod).flatMap(dir => entityKinds(dir, id)))] : null;
1085
+ for (const r of roots) {
1086
+ const file = path.join(r, "package.json");
1087
+ if (!fs.existsSync(file))
1088
+ continue;
1089
+ let res;
1090
+ try {
1091
+ res = convertPackage(current(file), kindsOf);
1092
+ }
1093
+ catch (e) {
1094
+ throw new Error(`${at(file)}: ${e.message}`, { cause: e });
1095
+ }
1096
+ for (const w of res.warnings)
1097
+ plan.warnings.push(`${at(file)}: ${w}`);
1098
+ if (res.text === null)
1099
+ continue;
1100
+ texts.set(file, res.text);
1101
+ plan.packages++;
1102
+ }
1103
+ // the hand-written instructions file is DREAMTEAMER.md; the generated harness files are build output
1104
+ const names = fs.readdirSync(root);
1105
+ const renameInstructions = names.includes("dreamteamer.md");
1106
+ if (renameInstructions && names.includes("DREAMTEAMER.md"))
1107
+ plan.warnings.push("dreamteamer.md and DREAMTEAMER.md both exist — merge them into DREAMTEAMER.md by hand");
1108
+ plan.instructions = renameInstructions && !names.includes("DREAMTEAMER.md") ? 1 : 0;
1109
+ const ignoreFile = path.join(root, ".gitignore");
1110
+ const ignoreText = fs.existsSync(ignoreFile) ? fs.readFileSync(ignoreFile, "utf8") : "";
1111
+ const ignoreLines = new Set(ignoreText.split(/\r?\n/).map(l => l.trim()));
1112
+ // a root harness file is compile's only when everything in it is a generated block; one with text
1113
+ // of its own outside the blocks is hand-written, stays tracked, and is named — ignoring it would
1114
+ // drop that text from every fresh clone
1115
+ const ownText = (f) => fs
1116
+ .readFileSync(path.join(root, f), "utf8")
1117
+ .replace(/<!-- dreamteamer:(instructions:)?begin[^>]*-->[\s\S]*?<!-- dreamteamer:(instructions:)?end -->/g, "")
1118
+ .trim();
1119
+ const handWritten = HARNESS_FILES.filter(f => names.includes(f) && ownText(f) !== "");
1120
+ for (const f of handWritten)
1121
+ plan.warnings.push(`${f} carries text outside the generated block, so it stays tracked and is not ignored — move that text into DREAMTEAMER.md, then run this again to hand ${f} to compile`);
1122
+ const generated = HARNESS_FILES.filter(f => !handWritten.includes(f));
1123
+ const toIgnore = generated.map(f => `/${f}`).filter(l => !ignoreLines.has(l));
1124
+ plan.ignored = toIgnore.length;
1125
+ // a `collection-templates/` folder is a kind the engine no longer knows, and compile refuses it:
1126
+ // one holding nothing but folder litter goes, whichever run emptied it; one still holding files is named
1127
+ const litterOnly = [];
1128
+ for (const r of roots) {
1129
+ const dir = path.join(r, "collection-templates");
1130
+ if (!fs.existsSync(dir))
1131
+ continue;
1132
+ const left = [...walk(dir)].filter(f => !LITTER.has(path.basename(f)) && texts.get(f) !== null);
1133
+ if (!left.length)
1134
+ litterOnly.push(dir);
1135
+ else
1136
+ plan.warnings.push(`${at(dir)} still holds ${left.map(at).join(", ")} — compile refuses the folder; move or delete what is left`);
1137
+ }
1138
+ log(`${dryRun ? "plan" : "migrated"}: descriptors ${plan.descriptors} · fields ${plan.fields} · relations folded ${plan.folded} · enums merged ${plan.enums} · mixins ${plan.mixins} · views folded ${plan.viewsFolded} · views converted ${plan.viewsConverted} · bindings converted ${plan.bindings} · packages ${plan.packages} · instructions renamed ${plan.instructions} · harness files ignored ${plan.ignored}`);
1139
+ for (const w of plan.warnings)
1140
+ log(`⚠ ${w}`);
1141
+ for (const u of plan.unfolded)
1142
+ log(`⚠ ${u}`);
1143
+ const tracked = trackedFiles(root, generated);
1144
+ if (tracked.length)
1145
+ log(`then stop tracking the generated harness files: git rm --cached ${tracked.join(" ")}`);
1146
+ if (!dryRun) {
1147
+ if (plan.instructions) {
1148
+ // a tracked file moves through `git mv`, so the index follows a rename that only changes case —
1149
+ // on a case-insensitive filesystem git sees no change otherwise; an untracked one goes through a
1150
+ // temporary name, because there the two spellings are one path
1151
+ if (trackedFiles(root, ["dreamteamer.md"]).length)
1152
+ execFileSync("git", ["mv", "dreamteamer.md", "DREAMTEAMER.md"], { cwd: root, stdio: "ignore", timeout: 10_000 });
1153
+ else {
1154
+ const tmp = path.join(root, `.dreamteamer.md.${process.pid}`);
1155
+ fs.renameSync(path.join(root, "dreamteamer.md"), tmp);
1156
+ fs.renameSync(tmp, path.join(root, "DREAMTEAMER.md"));
1157
+ }
1158
+ }
1159
+ if (toIgnore.length)
1160
+ fs.writeFileSync(ignoreFile, `${ignoreText}${ignoreText && !ignoreText.endsWith("\n") ? "\n" : ""}# harness files compile generates\n${toIgnore.join("\n")}\n`);
1161
+ for (const [file, text] of texts) {
1162
+ if (text === null) {
1163
+ fs.rmSync(file, { force: true });
1164
+ continue;
1165
+ }
1166
+ if (fs.existsSync(file) && fs.readFileSync(file, "utf8") === text)
1167
+ continue;
1168
+ fs.mkdirSync(path.dirname(file), { recursive: true });
1169
+ fs.writeFileSync(file, text);
1170
+ }
1171
+ for (const dir of litterOnly)
1172
+ fs.rmSync(dir, { recursive: true, force: true });
1173
+ }
1174
+ return plan;
1175
+ }
1176
+ const packageName = (dir) => {
1177
+ try {
1178
+ return JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")).name;
1179
+ }
1180
+ catch {
1181
+ return null;
1182
+ }
1183
+ };
1184
+ /** Files an OS or an editor drops into a folder, never written by an author. */
1185
+ const LITTER = new Set([".DS_Store", "Thumbs.db", "desktop.ini"]);
1186
+ /** The harness files compile writes at the workspace root. */
1187
+ const HARNESS_FILES = ["CLAUDE.md", "AGENTS.md", "GEMINI.md", "NOTEBOOKLM.md"];
1188
+ /** The engine's own collections: any module may overlay one without declaring a dependency. */
1189
+ const ENGINE_COLLECTIONS = (() => {
1190
+ try {
1191
+ return new Set(fs
1192
+ .readdirSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "collections"))
1193
+ .filter(f => f.endsWith(".collection.yaml"))
1194
+ .map(f => f.replace(/\.collection\.yaml$/, "")));
1195
+ }
1196
+ catch {
1197
+ return new Set();
1198
+ }
1199
+ })();
1200
+ /** Which of `files` git tracks in `root` — [] when it is not a repository or git is not there. */
1201
+ function trackedFiles(root, files) {
1202
+ try {
1203
+ return execFileSync("git", ["ls-files", "--", ...files], {
1204
+ cwd: root,
1205
+ encoding: "utf8",
1206
+ stdio: ["ignore", "pipe", "ignore"],
1207
+ timeout: 10_000,
1208
+ })
1209
+ .split("\n")
1210
+ .filter(Boolean);
1211
+ }
1212
+ catch {
1213
+ return [];
1214
+ }
1215
+ }
1216
+ /** The overlay of `collection` in module root `r` — its existing source, or a fresh one. */
1217
+ function overlayFile(r, collection, texts) {
1218
+ const dest = path.join(r, "collections", `${collection}.collection.yaml`);
1219
+ if (!texts.has(dest))
1220
+ texts.set(dest, fs.existsSync(dest) ? fs.readFileSync(dest, "utf8") : `name: ${collection}\noverlay: true\nfields: {}\n`);
1221
+ return dest;
1222
+ }
1223
+ /** Is this file the program node was asked to run? Compared through realpaths, because the engine is
1224
+ * often reached through a link (`git_modules/dreamteamer`, an npm link) and a plain resolve differs. */
1225
+ function invokedDirectly() {
1226
+ try {
1227
+ return !!process.argv[1] && fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
1228
+ }
1229
+ catch {
1230
+ return false;
1231
+ }
1232
+ }
1233
+ if (invokedDirectly()) {
1234
+ const args = process.argv.slice(2);
1235
+ const at = args.indexOf("--root");
1236
+ const root = path.resolve(at >= 0 ? args[at + 1] : process.cwd());
1237
+ if (!fs.existsSync(path.join(root, "package.json"))) {
1238
+ console.error(`✖ ${root} is not a workspace (no package.json)`);
1239
+ process.exit(2);
1240
+ }
1241
+ try {
1242
+ migrate(root, { dryRun: args.includes("--dry-run") });
1243
+ }
1244
+ catch (e) {
1245
+ console.error(`✖ ${e.message}`);
1246
+ process.exit(1);
1247
+ }
1248
+ }