dreamteamer 0.49.1 → 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 (976) 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/writing-a-module.md +14 -0
  920. package/scripts/migrate-descriptors-v2.mjs +0 -795
  921. package/scripts/migrate-stubs.mjs +0 -98
  922. package/src/api.d.ts +0 -154
  923. package/src/api.js +0 -109
  924. package/src/check-alone.js +0 -171
  925. package/src/check.js +0 -427
  926. package/src/checkout.js +0 -705
  927. package/src/cli.js +0 -1000
  928. package/src/collections-cli.js +0 -1352
  929. package/src/commit.js +0 -611
  930. package/src/compile-collections.js +0 -481
  931. package/src/compile.js +0 -1511
  932. package/src/descriptor-v2.js +0 -167
  933. package/src/descriptor.js +0 -99
  934. package/src/doctor.js +0 -69
  935. package/src/env-vars.js +0 -59
  936. package/src/env-write.js +0 -162
  937. package/src/events.js +0 -204
  938. package/src/exports-cli.js +0 -91
  939. package/src/exports.js +0 -162
  940. package/src/extensions.js +0 -228
  941. package/src/field-values.js +0 -70
  942. package/src/fields.js +0 -255
  943. package/src/filter.js +0 -154
  944. package/src/fractional-index.js +0 -44
  945. package/src/harnesses.js +0 -649
  946. package/src/history.js +0 -90
  947. package/src/init.js +0 -473
  948. package/src/install-modules.js +0 -450
  949. package/src/namespace.js +0 -215
  950. package/src/nav-fragments.js +0 -190
  951. package/src/nav.js +0 -185
  952. package/src/placement.js +0 -219
  953. package/src/presentation.js +0 -182
  954. package/src/record-commands.js +0 -94
  955. package/src/records-api.d.ts +0 -210
  956. package/src/records-api.js +0 -41
  957. package/src/records.js +0 -109
  958. package/src/ref.js +0 -39
  959. package/src/relations.js +0 -62
  960. package/src/runtime.js +0 -160
  961. package/src/scaffold-templates.js +0 -85
  962. package/src/schema-ops.js +0 -2959
  963. package/src/semver.js +0 -36
  964. package/src/setup-contract.js +0 -101
  965. package/src/setup.js +0 -518
  966. package/src/store.js +0 -1964
  967. package/src/template.js +0 -201
  968. package/src/temporal.js +0 -157
  969. package/src/testing.d.ts +0 -29
  970. package/src/testing.js +0 -86
  971. package/src/unread-data.js +0 -74
  972. package/src/update-setup.js +0 -22
  973. package/src/update.js +0 -139
  974. package/src/views.js +0 -206
  975. package/src/workspace.js +0 -253
  976. package/src/yaml.js +0 -251
@@ -1,1352 +0,0 @@
1
- // The IMPLEMENTATION layer behind the verb-first CLI: `collectionCommand(ws, collection, verb, args)`
2
- // is (collection, verb) shaped and stays that way — `cli.js` translates `dt <verb> <target>` onto it.
3
- // So a spelling here (`collections add`, `<collection> add-field`, `commands for`, `repos ensure`) is
4
- // an INTERNAL pair, not what the operator types; `dt add collections` is what they type.
5
- import { execFileSync } from 'node:child_process';
6
- import fs from 'node:fs';
7
- import path from 'node:path';
8
- import { Store, bodyField, serialize, atomicWrite } from './store.js';
9
- import { load, dump } from './yaml.js';
10
- import { slug } from './template.js';
11
- import {
12
- createCollection, removeCollection, renameCollection, addField, updateField, removeField, fieldFromFlags, saveUiView, removeUiView, moveUiView,
13
- // was copy-pasted here, and the copy went stale the moment the source layout gained a second
14
- // spelling — one implementation, two callers
15
- workspaceSystemDir,
16
- createModule, removeModule, renameModule, setModule, moveCollection, setCollectionScalars, collectionSourceFileFor, renameField, renameFieldPlan,
17
- renameValue, renameValuePlan,
18
- createSkill, refuseHandAuthored, removeEntity, renameEntity, setEntityFrontmatter,
19
- } from './schema-ops.js';
20
- import { KINDS } from './compile.js';
21
- import { history, historyDiff } from './history.js';
22
- import { commandsFor, recordResolver } from './record-commands.js';
23
- import { contributedNotes } from './extensions.js';
24
- import { distinctValues } from './field-values.js';
25
- import { matchesFilter, unknownTokens, VALUE_TOKENS } from './filter.js';
26
- import { baseNameOf, defaultStoragePath } from './namespace.js';
27
- import { sortRows } from './temporal.js';
28
- import { keyBetween, placementKey } from './fractional-index.js';
29
- import { ensureRepo, ensureAllRepos } from './init.js';
30
- import { expectedMirrors, ownersReadIn } from './relations.js';
31
- import { parseRecord } from './records.js';
32
-
33
- import { storageOf, jsonSchemaOf, recordTitleOf, positionFieldOf, fieldsOf, displayOf, storedFieldsOf, targetsOf } from './descriptor.js';
34
- /**
35
- * Emit MACHINE-READABLE output synchronously. Use this for every `--json` payload.
36
- *
37
- * `console.log` to a pipe is asynchronous, and every CLI path ends in `process.exit()`, which
38
- * discards whatever is still buffered. A shell pipeline hides the bug completely — the reader
39
- * drains concurrently, so `dreamteamer list contacts --json | wc -c` reports all 32381 bytes — but
40
- * the way a script or a coding agent actually calls this is execFileSync/spawnSync, and there the
41
- * child exits with the pipe still full. Measured before this fix: the same command captured with
42
- * execFileSync returned exactly **8190 bytes** (one pipe buffer) of that 32381-byte document, i.e.
43
- * silently invalid JSON, with a zero exit status.
44
- *
45
- * Found while writing a setup script for a second operator — the first consumer to read `--json`
46
- * from a real program rather than a terminal.
47
- *
48
- * ⚠ 2026-07-30: a SINGLE `fs.writeSync` was NOT enough, and the previous version of this comment
49
- * claimed it was. Writing to a pipe performs one `write(2)`, which returns a SHORT COUNT once the
50
- * 64KB pipe buffer is full — it does not throw, it reports fewer bytes written and the caller
51
- * ignores the number. So the same truncation reappeared at a larger size: measured at exactly
52
- * **65126 bytes** of a ~100KB payload, again invalid JSON with a zero exit status. `meetings list
53
- * --json` (141767 bytes) was affected. Found in a sibling script that reproduced it twice, once
54
- * per fix.
55
- *
56
- * So: write in a LOOP until every byte lands, and retry EAGAIN — stdout can be a non-blocking pipe.
57
- *
58
- * ⚠ 2026-09-03: `USAGE` became the SECOND victim, and it is the one every agent reads. `dt help`
59
- * ended `console.log(USAGE); process.exit(0)`, which was fine while the text fit one pipe buffer —
60
- * and the system-verbs rewrite took it to 12,189 bytes. Measured with spawnSync: **8,113 bytes**
61
- * captured, i.e. help silently ends mid-sentence for every script, agent and test that reads it,
62
- * at exit 0. Hence the `fd` argument: `help` writes through here now, and so does the USAGE echoed
63
- * on an unknown verb (fd 2, same failure mode).
64
- */
65
- export const emit = (s, fd = 1) => {
66
- const buf = Buffer.from(s + '\n');
67
- let off = 0;
68
- while (off < buf.length) {
69
- try {
70
- off += fs.writeSync(fd, buf, off, buf.length - off);
71
- } catch (e) {
72
- if (e.code === 'EAGAIN') continue;
73
- throw e;
74
- }
75
- }
76
- };
77
-
78
- /** `list` flags that are options, not `field=value` shorthand filters. */
79
- const LIST_META_FLAGS = new Set(['json', 'filter', 'where', 'sort']);
80
-
81
- export function collectionCommand(ws, collection, verb, args) {
82
- const store = new Store(ws);
83
- const { flags, pos } = parseArgs(args);
84
- refuseUnknownFlags(store, collection, verb, flags);
85
-
86
- // ---- system verbs: source writes, never the runtime ----------
87
- // These MUST come before the generic switch: their collections are system-stored, so the
88
- // ordinary record path refuses them ("… are system sources") and always would.
89
- if (collection === 'collections' && verb === 'add') return metaCollectionsAdd(ws, store, flags);
90
- if (collection === 'collections' && verb === 'rm') return metaCollectionsRm(ws, store, flags, pos);
91
- if (collection === 'collections' && verb === 'rename') return metaCollectionsRename(ws, store, flags, pos);
92
- if (collection === 'collections' && verb === 'set') return metaCollectionsSet(ws, store, flags, pos);
93
- if (collection === 'collections' && verb === 'get' && flags.module !== undefined) return metaCollectionsGet(ws, store, flags, pos);
94
- if (collection === 'collections' && verb === 'reorder') return metaCollectionsMove(ws, store, flags, pos);
95
- if (collection === 'commands' && verb === 'for') return metaCommandsFor(ws, store, flags, pos);
96
- if (collection === 'ui-views' && ['add', 'set', 'rm'].includes(verb)) return metaUiView(ws, store, verb, flags, pos);
97
- if (collection === 'modules' && verb === 'add') return metaModulesAdd(ws, store, flags);
98
- if (collection === 'modules' && verb === 'rm') return metaModulesRm(ws, store, flags, pos);
99
- if (collection === 'modules' && verb === 'rename') return metaModulesRename(ws, store, flags, pos);
100
- if (collection === 'modules' && verb === 'set') return metaModulesSet(ws, store, flags, pos);
101
- if (collection === 'repos' && verb === 'ensure') return metaReposEnsure(ws, flags, pos);
102
- if (verb === 'add-field') return metaAddField(ws, store, collection, flags);
103
- if (verb === 'set-field') return metaUpdateField(ws, store, collection, flags);
104
- if (verb === 'rm-field') return metaRemoveField(ws, store, collection, flags);
105
- if (verb === 'rename-field') return metaRenameField(ws, store, collection, flags);
106
- if (verb === 'rename-value') return metaRenameValue(ws, store, collection, flags, pos);
107
-
108
- // ---- the identity entities. §3.1's last row: `add` scaffolds a skill and is refused WITH THE
109
- // PATH for the five hand-authored kinds; `set` edits frontmatter; `rm` and `rename` work on all
110
- // six. Keyed on the collection NAME rather than on `storage.base` because these six are the
111
- // ones with a source-file shape — `modules` is projected and `collections` has its own verbs.
112
- if (isEntityKind(store, collection) && ['add', 'set', 'rm', 'rename'].includes(verb)) {
113
- return metaEntityVerb(ws, store, collection, verb, flags, pos);
114
- }
115
- // `revert` on ANY system entity: its history is git's, and `store.revert` writes a RECORD.
116
- if (verb === 'revert' && storageOf(store.descriptors.get(collection)).runtime) {
117
- const src = sourceHintFor(store, collection);
118
- throw new Error(`${collection}/${pos[0] ?? '<id>'} is a compiled source, so there is no record to revert — its source is in git.\n git log -- ${src}\n git checkout <sha> -- ${src}\n dreamteamer compile`);
119
- }
120
-
121
- const d = store.descriptor(collection);
122
-
123
- // Every record write says WHICH workspace it landed in. `--vault` is OPTIONAL and a bare command
124
- // resolves from the working directory, so the one thing the flag cannot do is tell you when you
125
- // forgot it \u2014 this can, for the price of one word, with no state and nothing refused. A write
126
- // aimed at one workspace and landed in another becomes visible on the very next line of output
127
- // instead of never: on a machine holding several workspaces most collection NAMES are shared while
128
- // their fields are not, so the misplaced write succeeds and reports success.
129
- const at = ws.pkg?.name ? `${ws.pkg.name} \u00b7 ` : '';
130
-
131
- switch (verb) {
132
- case 'list': {
133
- const { rows, narrowed, files } = narrowRows(store, d, collection, flags);
134
- // each row says where it is read from and which repo commits it — `$`-keys, because a
135
- // collection may author a field called `file` or `repo` (an issue tracker's `repo` is one)
136
- if (flags.json) { emit(JSON.stringify(rows.map((r) => ({ ...r, ...whereKeys(store.locationOf(d, files.get(r.id))) })), null, 2)); return 0; }
137
- const cols = listColumns(d);
138
- // a module preset's row says so right after its id (CR-dt-008); every other row is unchanged
139
- const rowCols = (r) => (collection === 'modules' && r.preset_summary ? ['id', 'preset_summary', ...cols.slice(1)] : cols);
140
- for (const r of rows) console.log(rowCols(r).map((c) => fmtCell(r[c])).join(' '));
141
- if (!rows.length) console.log(`(no ${collection}${narrowed ? ' matching' : ''})`);
142
- return 0;
143
- }
144
- case 'get': {
145
- const id = need(pos, 0, 'id');
146
- // an id no root holds that an exports manifest vouches for (cr-dt-004): named, and still exit 1
147
- const ext = store.external(collection, id, { referrer: flags.referrer });
148
- if (ext) {
149
- if (flags.json) emit(JSON.stringify({ $external: { collection, id, ...ext } }, null, 2));
150
- console.error(`${collection}/${id} is not held here — external: "${ext.label}", held by ${ext.from ?? 'a workspace the manifest does not name'} (${ext.manifest})`);
151
- return 1;
152
- }
153
- const { fields, file } = store.read(collection, id);
154
- // descriptor v2: a record older than the `created` stamp still answers it — read, never written
155
- const created = store.createdOf(collection, id, fields, file);
156
- if (created !== undefined && fields.created === undefined) fields.created = created;
157
- if (flags.json) { emit(JSON.stringify({ ...fields, id, ...whereKeys(store.locationOf(d, file)) }, null, 2)); return 0; }
158
- console.log(dump(fields).trimEnd());
159
- return 0;
160
- }
161
- case 'add': {
162
- // An opaque collection is written by IMPORTING a file: the id is positional (nothing can
163
- // generate it from fields that do not exist) and the bytes come from --from.
164
- if (storageOf(d).format === 'binary') {
165
- const id = need(pos, 0, 'id');
166
- if (!flags.from) throw new Error(`"${collection}" is a \`format: binary\` collection — pass --from <path> with the file to import`);
167
- const { id: written, file } = store.addFile(collection, id, flags.from, { force: !!flags.force });
168
- flags.json ? emit(JSON.stringify({ id: written, path: rel(ws.root, file) })) : console.log(`✔ ${at}${rel(ws.root, file)}`);
169
- return 0;
170
- }
171
- if (flags.from) throw new Error(`--from imports a file as a record, and "${collection}" is not a \`format: binary\` collection`);
172
- // ONE bare positional is the record's title — the field `record_title` opens with — so
173
- // `dt add task "call the bank"` reads as a sentence. Two positionals is a mistake (a flag
174
- // value that lost its flag), and so is giving the title twice; both are refused by name.
175
- if (pos.length > 1) throw new Error(`dt add ${collection} takes ONE positional (the title) and flags for the rest — got ${pos.length}: ${pos.map((p) => `"${p}"`).join(' ')}`);
176
- if (pos.length === 1) {
177
- const titleField = /\{\{\s*([A-Za-z_][\w]*)/.exec(recordTitleOf(d))?.[1];
178
- if (!titleField || titleField === 'id') throw new Error(`"${collection}" labels its records by id, so there is no title field for "${pos[0]}" to fill — pass fields as --<field> <value>`);
179
- if (titleField in flags) throw new Error(`the title was given twice — "${pos[0]}" and --${titleField} ${JSON.stringify(flags[titleField])}`);
180
- flags[titleField] = pos[0];
181
- }
182
- const fields = coerceArrays(d, stripMeta(flags));
183
- const { id, file, idFallback, deprecated } = store.add(collection, fields, { id: flags.id });
184
- for (const k of deprecated ?? []) console.warn(`⚠ ${k} is deprecated on ${collection} — it still validates, and nothing draws it. Check the collection's description for what replaced it.`);
185
- flags.json
186
- ? emit(JSON.stringify({ id, path: rel(ws.root, file), ...(idFallback ? { idFallback } : {}) }))
187
- : console.log(`✔ ${at}${rel(ws.root, file)}`);
188
- // ⚠ SAY IT, EVERY TIME. The id was derived from a hash because the value it is generated
189
- // from carries no a-z0-9 — the write succeeded and the record is fine, but the id is
190
- // unreadable and unguessable, and nobody finds that out until they try to type it. By
191
- // then other records reference it and renaming is a migration.
192
- if (idFallback && !flags.json) {
193
- console.warn(`⚠ id "${idFallback.id}" is a hash, not a name — "${idFallback.field}" (${idFallback.value}) has no latin characters to slug.`);
194
- console.warn(' give this collection a latin handle: id.generate accepts an ORDERED LIST and takes the first that renders —');
195
- console.warn(" id: { generate: ['{{ code }}', '{{ name | slug }}'] }");
196
- console.warn(' or pass --id on this write. Renaming later rewrites every reference.');
197
- }
198
- return 0;
199
- }
200
- case 'set': {
201
- const id = need(pos, 0, 'id');
202
- const changes = coerceArrays(d, pairs(pos.slice(1)));
203
- Object.assign(changes, coerceArrays(d, stripMeta(flags)));
204
- if (!Object.keys(changes).length) throw new Error('nothing to set — pass key=value pairs or --key value flags');
205
- const where = store.ids(collection).has(id) ? store.locate(collection, id) : null; // a missing id is store.set's to refuse
206
- store.set(collection, id, changes);
207
- flags.json ? emit(JSON.stringify({ id, ...(where ? whereKeys(where) : {}) })) : console.log(`✔ ${at}updated${landedIn(where)}`);
208
- return 0;
209
- }
210
- // Manual ordering. ONE record is written per move — that is the entire feature; a dense
211
- // integer would renumber everything below the insertion point and bury the change. The field is
212
- // the descriptor's `type: position` field, never named here, so a workspace may call it anything.
213
- case 'reorder': {
214
- const field = positionFieldOf(d);
215
- if (!field) throw new Error(`collection "${collection}" has no \`type: position\` field — add one to its descriptor before ordering it by hand.`);
216
-
217
- // Blanks sort FIRST (compareValues, via `?? ''`), so unplaced records surface at the top
218
- // rather than hiding at the bottom, and ties fall back to id order: `walk` reads name-sorted
219
- // and Array.sort is stable. That is the tiebreak two agents landing on the same key rely on.
220
- const rows = [];
221
- for (const { id: rid, fields } of store.readAll(collection)) rows.push({ id: rid, key: fields[field] ?? '' });
222
- sortRows(rows, 'key');
223
-
224
- if (flags.init) {
225
- // Idempotent: a record that already carries a key keeps it, so --init can be re-run after
226
- // adding records without disturbing an order the operator set by hand.
227
- let prev = rows.filter((r) => r.key).pop()?.key ?? null;
228
- let written = 0;
229
- for (const r of rows) {
230
- if (r.key) continue;
231
- prev = keyBetween(prev, null);
232
- store.set(collection, r.id, { [field]: prev });
233
- written++;
234
- }
235
- flags.json ? emit(JSON.stringify({ placed: written })) : console.log(written ? `✔ placed ${written} record(s) in ${field}` : '✔ nothing to place');
236
- return 0;
237
- }
238
-
239
- const id = need(pos, 0, 'id');
240
- store.set(collection, id, { [field]: placementKey(rows, id, flags, collection) });
241
- flags.json ? emit(JSON.stringify({ id })) : console.log(`✔ ${at}moved`);
242
- return 0;
243
- }
244
- case 'rm': {
245
- const id = need(pos, 0, 'id');
246
- if (flags['dry-run']) return dryRunPlan(`rm ${collection}/${id}`, { records: store.ids(collection).has(id) ? 1 : 0, refs: store.findInboundRefs(`${collection}/${id}`).length });
247
- const where = store.ids(collection).has(id) ? store.locate(collection, id) : null; // a missing id is store.rm's to refuse
248
- const { inboundIgnored } = store.rm(collection, id, { force: !!flags.force });
249
- flags.json ? emit(JSON.stringify({ id, removed: true, inboundIgnored })) : console.log(`✔ ${at}removed${landedIn(where)}${inboundIgnored ? ` (${inboundIgnored} inbound reference(s) left dangling — run \`dreamteamer check\`)` : ''}`);
250
- return 0;
251
- }
252
- case 'rename': {
253
- const out = store.rename(collection, need(pos, 0, 'old id'), need(pos, 1, 'new id'));
254
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
255
- console.log(`✔ ${at}renamed ${collection}/${need(pos, 0, 'old id')} → ${collection}/${out.id}`);
256
- if (out.touched) console.log(`✔ rewrote ${out.rewrites} inbound reference(s) across ${out.touched} file(s)`);
257
- return 0;
258
- }
259
- // `dreamteamer values meetings status` — the vocabulary a field ACTUALLY uses, so a filter
260
- // or a command-binding validator can offer a dropdown for a plain `type: string` field that
261
- // no enum describes (operator: "still no dropdown for many things, visibility, status").
262
- case 'values': {
263
- const field = need(pos, 0, 'field');
264
- // ⚠ A BARE `--limit` parses as the boolean `true`, and `Number(true)` is 1 — so it
265
- // truncated the vocabulary to one value while the footer claimed "showing 1", which reads
266
- // as a fact about the collection. Refused, in `--drop`'s words.
267
- if ('limit' in flags && !Number.isFinite(Number(oneValue(flags, 'limit')))) throw new Error(`--limit needs a number: dreamteamer values ${collection} ${field} --limit 20`);
268
- const out = distinctValues(store, collection, field, { limit: flags.limit === undefined ? undefined : Number(flags.limit) });
269
- if (flags.json) { emit(JSON.stringify(out, null, 2)); return 0; }
270
- if (out.skipped) { console.log(`(${collection}.${field} is a ${out.skipped} field — no value vocabulary)`); return 0; }
271
- if (!out.values.length) { console.log(`(no values set on ${collection}.${field})`); return 0; }
272
- for (const { value, count } of out.values) console.log(count == null ? String(value) : `${String(count).padStart(5)} ${value}`);
273
- console.log(`— ${out.total} distinct${out.truncated ? ` (showing ${out.values.length})` : ''}, from ${out.source}`);
274
- return 0;
275
- }
276
- case 'history': {
277
- const id = need(pos, 0, 'id');
278
- const log = history(store, collection, id);
279
- if (flags.json) { emit(JSON.stringify(log, null, 2)); return 0; }
280
- if (!log.length) { console.log(`(no history for ${collection}/${id} — not committed yet)`); return 0; }
281
- for (const c of log) console.log(`${c.hash.slice(0, 7)} ${c.date.slice(0, 10)} ${c.author} ${c.subject}`);
282
- return 0;
283
- }
284
- case 'diff': {
285
- const id = need(pos, 0, 'id');
286
- const out = historyDiff(store, collection, id, oneValue(flags, 'hash') ?? 'HEAD');
287
- if (flags.json) { emit(JSON.stringify(out, null, 2)); return 0; }
288
- console.log(out.diff.trimEnd() || `(no change to ${out.path} in ${out.hash})`);
289
- return 0;
290
- }
291
- case 'revert': {
292
- const id = need(pos, 0, 'id');
293
- // the hash is REQUIRED and has no default: "revert" with an implied target is how you
294
- // destroy the wrong record. `<c> history <id>` is where you get one.
295
- const hash = oneValue(flags, 'hash') ?? pos[1];
296
- if (!hash) throw new Error(`missing --hash <commit> — run \`dreamteamer history ${collection}/${id}\` to pick one`);
297
- const out = store.revert(collection, id, hash);
298
- flags.json ? emit(JSON.stringify(out)) : console.log(out.reverted ? `✔ reverted ${collection}/${id} to ${String(hash).slice(0, 7)}` : `= already identical to ${String(hash).slice(0, 7)} — nothing changed`);
299
- return 0;
300
- }
301
- default:
302
- throw new Error(`unknown verb "${verb}" — use list | get | add | set | rm | rename | values | history | diff | revert`);
303
- }
304
- }
305
-
306
-
307
-
308
- // Which bound commands apply, in which state (available / done / not-applicable). THE engine
309
- // surface behind the studio's Commands tab (engine/UI parity: the verb lands first, the button
310
- // second).
311
- //
312
- // ⚠ The COLLECTION arrives already resolved, and the ids only ever through `--ids`. This used to
313
- // split its own target at the first slash — which cannot name a namespaced collection, so
314
- // `commands finance/transactions` asked for a collection called "finance" and every namespaced
315
- // target failed. `cli.js` owns reference resolution now (splitRef, longest declared prefix) and is
316
- // the only caller, so a second, weaker splitter here could only ever disagree with it.
317
- function metaCommandsFor(ws, store, flags, pos) {
318
- const collection = need(pos, 0, 'collection');
319
- const ids = (oneValue(flags, 'ids') ?? '').split(',').map((s) => s.trim()).filter(Boolean);
320
- const out = commandsFor(store, collection, ids);
321
- // what an installed extension says about these records (a session holding one, say) — after the
322
- // commands, because the commands are the answer and a note is context for it
323
- const notes = contributedNotes(ws, collection, ids);
324
- if (flags.json) { emit(JSON.stringify({ ...out, notes }, null, 2)); return 0; }
325
- if (!out.commands.length) console.log(`(no commands bound to ${collection})`);
326
- for (const c of out.commands) {
327
- if (c.scope === 'collection') { console.log(`${c.name} [collection] ${c.invocation}`); continue; }
328
- const counts = ids.length ? ` ${c.eligible.length}/${ids.length} eligible${c.done.length ? `, ${c.done.length} done` : ''}` : ' (no ids given)';
329
- console.log(`${c.name} [record]${counts}${c.invocation ? `\n ${c.invocation}` : ''}`);
330
- }
331
- for (const n of notes) console.log(n.error ? `✖ ${n.by}: ${n.text}` : `● ${collection}/${n.id} — ${n.text} (${n.by})`);
332
- return 0;
333
- }
334
-
335
- /**
336
- * `repos ensure <id>` / `repos ensure --all` — materialize declared repos on demand.
337
- * Lazy by design: `install` deliberately does NOT do this, so a fresh workspace clone is
338
- * immediately workable without pulling every attached repo (and one unreachable remote can only
339
- * fail the action you asked for, not the whole install).
340
- */
341
- function metaReposEnsure(ws, flags, pos) {
342
- const results = flags.all ? ensureAllRepos(ws) : [ensureRepo(ws, need(pos, 0, 'id'))];
343
- if (flags.json) { emit(JSON.stringify(results, null, 2)); return 0; }
344
- for (const r of results) console.log(r.cloned ? `✔ cloned ${r.path}` : `✔ ${r.path} (present)`);
345
- if (!results.length) console.log('(no repos declared)');
346
- return 0;
347
- }
348
-
349
- // ---- modules ----------------------------------------------------------------------------------
350
- // A module is the one system entity that had no verbs at all, which is what left system-entity CRUD
351
- // incomplete: there was no `add-module`, no `rm-module`, no `rename-field`, and no way to NAME a
352
- // target module. §6.2.
353
-
354
- // `dreamteamer add modules --name core [--description "…"]`
355
- function metaModulesAdd(ws, store, flags) {
356
- // ⚠ BEFORE the write, as `add collections` does it and for the same reason: naming the mistake
357
- // after the call lands a committed module and then exits 1.
358
- if (flags.namespace === true) throw new Error("--namespace takes a value: dreamteamer add modules --name <id> --namespace <ns>");
359
- const out = createModule(ws, store, {
360
- name: oneValue(flags, 'name'),
361
- description: oneValue(flags, 'description'),
362
- namespace: oneValue(flags, 'namespace'),
363
- extension: flags.extension === true || flags.extension === 'true',
364
- pkg: flags.package === undefined ? null : flags.package === true ? true : oneValue(flags, 'package'),
365
- });
366
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
367
- console.log(`✔ ${out.root}/ — ${out.files.join(' · ')} + ${KIND_COUNT} kind folder(s)`);
368
- // §6.2 promises the namespace is DECLARED IN THE MODULE, and §8 makes every later
369
- // `add collections --module <id>` infer it — so the declaration is echoed, because an inferred
370
- // identity the operator did not type is one they must be able to read back.
371
- if (out.namespace) console.log(`✔ declared namespace "${out.namespace}" in modules/${out.id}`);
372
- console.log('✔ compiled — the module is live (add a collection with `dreamteamer add collections --name <c> --module ' + out.id + '`)');
373
- reportCommits(out.commits);
374
- return 0;
375
- }
376
-
377
- // `dreamteamer rm modules/core [--force] [--dry-run]`
378
- function metaModulesRm(ws, store, flags, pos) {
379
- const id = need(pos, 0, 'module id');
380
- const out = removeModule(ws, store, id, { force: !!flags.force, dryRun: !!flags['dry-run'] });
381
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
382
- if (out.dryRun) return dryRunPlan(`rm modules/${id} --force`, out, [
383
- out.collections.length ? `sources removed for: ${out.collections.join(', ')}` : null,
384
- out.withRecords.length ? `records left in place and UNINDEXED: ${out.withRecords.join(', ')}` : null,
385
- out.dependents.length ? `dependencies entry dropped from: ${out.dependents.join(', ')}` : null,
386
- ]);
387
- console.log(`✔ removed module ${out.removed}`);
388
- if (out.withRecords.length) console.log(` ⚠ records remain and are now unindexed: ${out.withRecords.join(', ')}`);
389
- if (out.dependents.length) console.log(` dropped it from ${out.dependents.join(', ')}'s dependencies`);
390
- console.log('✔ compiled — the module is gone');
391
- reportCommits(out.commits);
392
- return 0;
393
- }
394
-
395
- // `dreamteamer rename modules/core shared`
396
- function metaModulesRename(ws, store, flags, pos) {
397
- const oldId = need(pos, 0, 'module id');
398
- const out = renameModule(ws, store, oldId, need(pos, 1, 'new module id'));
399
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
400
- if (!out.renamed) { console.log(`✔ ${oldId} — already named that, nothing to do`); return 0; }
401
- console.log(`✔ ${oldId} → ${out.id}`);
402
- console.log(` rewrote ${out.rewrites} reference(s): extends, dependencies, disable and modules/${oldId} refs`);
403
- console.log('✔ compiled — the rename is live, in ONE commit');
404
- reportCommits(out.commits);
405
- return 0;
406
- }
407
-
408
- // `dreamteamer set modules/hr description="…" dependencies=modules/core`
409
- function metaModulesSet(ws, store, flags, pos) {
410
- const id = need(pos, 0, 'module id');
411
- const changes = { ...pairs(pos.slice(1)), ...stripMeta(flags) };
412
- if (!Object.keys(changes).length) throw new Error('nothing to set — pass key=value pairs (description, namespaces, dependencies, peer_collections)');
413
- const out = setModule(ws, store, id, changes);
414
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
415
- if (out.unchanged) return alreadyThat(`modules/${id} ${out.changed.join(', ')}`);
416
- console.log(`✔ ${rel(ws.root, out.file)} — ${out.changed.join(', ')}`);
417
- console.log('✔ compiled — the module record is up to date');
418
- reportCommits(out.commits);
419
- return 0;
420
- }
421
-
422
- /** How many kind folders `add modules` scaffolds, for its own report. Read off the engine's own
423
- * KINDS so the sentence cannot go stale against the list it describes. */
424
- const KIND_COUNT = KINDS.length;
425
-
426
- /**
427
- * THE ONE PLAN PRINTER, for every verb that moves records or clears values — one shape, `records N ·
428
- * refs M · descriptors K · values cleared V`, because a reader comparing two dry runs must not have
429
- * to work out whether a missing term means zero or means "this verb does not count that".
430
- *
431
- * ⚠ FOUR OF THE SIX SPELLINGS DOCUMENTED `--dry-run` AND EXECUTED ANYWAY, and the self-commit made
432
- * it durable: `dt rm collections/widgets --dry-run --force` printed "✔ removed collection widgets",
433
- * deleted the source and committed it, at exit 0, against a `dt help` that spells `rm <system>/<id>
434
- * [--force] [--dry-run]` verbatim. `rm modules/<id>` was the ONE that honoured it. A flag a verb
435
- * advertises and ignores is worse than one it does not have — the operator's whole reason for typing
436
- * it is that they are not sure yet.
437
- *
438
- * It counts only what it can count WITHOUT doing the op; an unmeasured term is stated as such in
439
- * `extra` rather than guessed at, per `rename collections`' dry run.
440
- */
441
- function dryRunPlan(what, plan, extra) {
442
- console.log(`dry run — dreamteamer ${what} would:`);
443
- console.log(` records ${plan.records ?? 0} · refs ${plan.refs ?? 0} · descriptors ${plan.descriptors ?? 0} · values cleared ${plan.cleared ?? 0}`);
444
- for (const line of extra ?? []) if (line) console.log(` ${line}`);
445
- return 0;
446
- }
447
-
448
- /**
449
- * WHERE the schema change landed. ONE printer, because §9's whole point is that the answer is not
450
- * always "here": a write into a git-shape module commits in that clone, and the operator has to be
451
- * told — otherwise the change is in a repo they have not pushed and nothing said so.
452
- *
453
- * The workspace gets no "ahead" count on purpose: pushing the workspace is a thing the operator
454
- * already thinks about, and a number beside it would read as a new obligation.
455
- */
456
- export function reportCommits(commits) {
457
- for (const c of commits ?? []) {
458
- if (c.repo === '.') {
459
- console.log(`✔ committed in the workspace${c.sha ? ` (${c.sha})` : ''}`);
460
- continue;
461
- }
462
- const parts = [c.sha, c.ahead ? `ahead ${c.ahead} — push when ready` : null].filter(Boolean);
463
- console.log(`✔ committed in ${c.repo}${parts.length ? ` (${parts.join(', ')})` : ''}`);
464
- }
465
- }
466
-
467
- // `dreamteamer add collections --name research-docs --mixins docs --id-from '{{ created | date }}--{{ title | slug }}'`
468
- function metaCollectionsAdd(ws, store, flags) {
469
- // ⚠ BEFORE the write, not after. `--namespace=` is the empty STRING (clear it); a bare
470
- // `--namespace` parses as `true`, which is a mistake worth naming — and naming it AFTER the call
471
- // lands a committed collection and then exits 1, which is the one report shape that lies twice.
472
- if (flags.namespace === true) throw new Error("--namespace takes a value; --namespace '' means no namespace");
473
- const moduleId = oneValue(flags, 'module');
474
- const out = createCollection(ws, store, {
475
- name: oneValue(flags, 'name'),
476
- mixins: oneValue(flags, 'mixins'),
477
- idFrom: oneValue(flags, 'id-from'),
478
- namespace: flags.namespace,
479
- moduleId,
480
- description: oneValue(flags, 'description'),
481
- suffix: oneValue(flags, 'suffix'),
482
- });
483
- console.log(`✔ ${out.name}${out.inferred ? ` (namespace inferred from module ${moduleId})` : ''}`);
484
- console.log(`✔ ${rel(ws.root, out.file)}`);
485
- if (out.declaredNamespace) console.log(`✔ declared namespace "${out.declaredNamespace}" in ${moduleId ? `modules/${moduleId}` : 'the workspace'}`);
486
- // ⚠ ECHO THE SUFFIX, because it is DERIVED and the derivation is crude on purpose: every record
487
- // filename carries it (`<id>.<suffix>.md`), and the operator otherwise finds out what it decided
488
- // by looking at a file. Naming it here, with the override, is the whole papercut.
489
- if (out.suffixDerived) console.log(` suffix: ${out.suffix} — override with --suffix <singular>`);
490
- console.log('✔ compiled — the collection is live (schema ops prove sources with a real compile)');
491
- reportCommits(out.commits);
492
- return 0;
493
- }
494
-
495
- /**
496
- * `dt set collections/<c> module=<m>` — the MOVE — or the collection-level scalars.
497
- *
498
- * ⚠ Never both in one call. `module=` relocates a descriptor and validates the whole reference
499
- * contract; a scalar rewrites one key in it. Bundling them would make one command that either
500
- * half-applies or has to be explained, and the operator gets no signal about which happened.
501
- */
502
- function metaCollectionsSet(ws, store, flags, pos) {
503
- const name = need(pos, 0, 'collection name');
504
- const positional = pairs(pos.slice(1));
505
- const changes = { ...positional, ...stripMeta(flags) };
506
- delete changes.module;
507
- delete changes['dry-run'];
508
- const moveTo = positional.module ?? oneValue(flags, 'module');
509
- if (moveTo !== undefined && Object.keys(changes).length) {
510
- throw new Error(`module= moves the collection to another module and validates the whole reference contract; a scalar rewrites one key in its descriptor. Run them as two commands: dreamteamer set collections/${name} module=${moveTo}, then dreamteamer set collections/${name} ${Object.entries(changes).map(([k, v]) => `${k}=${v}`).join(' ')}`);
511
- }
512
- if (moveTo !== undefined) {
513
- const out = moveCollection(ws, store, name, String(moveTo), { dryRun: !!flags['dry-run'] });
514
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
515
- if (out.dryRun) return dryRunPlan(`set collections/${name} module=${moveTo}`, out, [`descriptor ${out.from} → ${out.to} (records stay where they are)`]);
516
- if (!out.moved) { console.log(`✔ ${name} — already owned by ${out.from}, nothing to do`); return 0; }
517
- console.log(`✔ ${name}: ${out.from} → ${out.to}`);
518
- console.log(` records ${out.records} left in place — a move never changes an id`);
519
- console.log(` descriptors ${out.descriptors} rewritten`);
520
- console.log('✔ compiled — the move is live, in ONE commit');
521
- reportCommits(out.commits);
522
- return 0;
523
- }
524
- if (!Object.keys(changes).length) throw new Error('nothing to set — pass key=value pairs, or module=<id> to move it');
525
- const out = setCollectionScalars(ws, store, name, changes, { moduleId: undefined });
526
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
527
- if (out.unchanged) return alreadyThat(`collections/${name} ${out.changed.join(', ')}`);
528
- console.log(`✔ ${rel(ws.root, out.file)} — ${out.changed.join(', ')}${out.peer ? `, and declared ${out.peer.collection} as a peer collection of ${out.peer.module}` : ''}`);
529
- console.log('✔ compiled — the descriptor is up to date');
530
- reportCommits(out.commits);
531
- return 0;
532
- }
533
-
534
- /**
535
- * `dt reorder collections/<c> …` — REFUSED since 0.49 (cr-dt-008). The nav is `nav.yaml` at the
536
- * workspace root, the one placement every surface draws from; a collection's `display.nav.order`
537
- * still compiles and moves no row. The verb used to write that key, compile, commit and print "the
538
- * nav order is live" while nothing on screen moved, so it now says where the order lives and writes
539
- * nothing. `module=` stays the move between modules (`dt set collections/<c> module=<m>`).
540
- */
541
- function metaCollectionsMove(ws, store, flags, pos) {
542
- const name = need(pos, 0, 'collection name');
543
- store.descriptor(name);
544
- throw new Error(`dt reorder collections/${name} is refused: since 0.49 the nav's order is nav.yaml at the workspace root, and a collection's display.nav.order compiles but moves no row. Move the row in the sidebar (Move up · Move down · Move to top/bottom, or drag it), or edit nav.yaml by hand — nothing was written.`);
545
- }
546
-
547
- /** `dt get collections/<c> --module <m>` — ONE module's source contribution, not the merged
548
- * descriptor. The merged one is what `dt get collections/<c>` prints and what every reader uses;
549
- * this is the only way to see what a given module actually wrote, which is the question an overlay
550
- * makes unanswerable from the runtime alone. */
551
- function metaCollectionsGet(ws, store, flags, pos) {
552
- const name = need(pos, 0, 'collection name');
553
- const moduleId = oneValue(flags, 'module');
554
- const { file } = collectionSourceFileFor(ws, store, name, moduleId);
555
- const doc = load(fs.readFileSync(file, 'utf8'));
556
- flags.json ? emit(JSON.stringify({ ...doc, id: name, source: rel(ws.root, file) }, null, 2)) : console.log(dump(doc).trimEnd());
557
- return 0;
558
- }
559
-
560
- // `dreamteamer collections rename doctors health/doctors`, or `… doctors --namespace health`.
561
- // The whole point is that namespacing EXISTING data is one command instead of a six-step hand
562
- // migration whose last step (rewriting references) dangles everything when forgotten.
563
- function metaCollectionsRename(ws, store, flags, pos) {
564
- const [oldName, explicitNew] = pos;
565
- if (!oldName) throw new Error('usage: dreamteamer rename collections/<old> <new> | collections/<old> --namespace <ns>');
566
- // `--namespace health` on its own moves the collection INTO that namespace keeping its bare name,
567
- // which is the common case and saves retyping it.
568
- const newName = explicitNew
569
- ?? (flags.namespace ? `${String(flags.namespace).replace(/^\/+|\/+$/g, '')}/${baseNameOf(oldName, store.namespaces)}` : null);
570
- if (!newName) throw new Error('missing new name — give it positionally or with --namespace <ns>');
571
-
572
- if (flags['dry-run']) {
573
- const d = store.descriptor(oldName);
574
- const records = store.ids(oldName).size;
575
- // ⚠ `refs` is honestly 0 here and the line says so. Counting them would mean running the batch
576
- // rewrite to find out, which IS the op — and a number the plan cannot know is worse than a
577
- // stated gap: the plan line has a fixed shape precisely so a reader never has to guess whether
578
- // a term is zero or unmeasured.
579
- return dryRunPlan(`rename collections/${oldName} ${newName}`, { records, descriptors: 1 }, [
580
- `records ${storageOf(d).path} → ${defaultStoragePath(newName, store.namespaces, ws.pkg.dreamteamer?.data_path ?? 'data')}`,
581
- 'refs are counted only by the real run — the rewrite is what discovers them',
582
- ]);
583
- }
584
- const out = renameCollection(ws, store, oldName, newName);
585
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
586
- if (!out.renamed) { console.log(`✔ ${oldName} — already named that, nothing to do`); return 0; }
587
- console.log(`✔ ${oldName} → ${out.name}`);
588
- if (out.from !== out.to) console.log(` records ${out.from} → ${out.to} (${out.records})`);
589
- if (out.suffix) console.log(` suffix .${out.suffix.from}.md → .${out.suffix.to}.md`);
590
- if (out.pathKept) console.log(` ⚠ storage.path kept as "${out.pathKept}" — it was authored, so the rename did not overrule it`);
591
- console.log(` refs ${out.rewrites} rewritten`);
592
- console.log('✔ compiled — the rename is live, in ONE commit');
593
- reportCommits(out.commits);
594
- return 0;
595
- }
596
-
597
- // `dreamteamer collections rm widgets [--force]` — --force is required to drop a collection
598
- // that still has records (removeCollection refuses otherwise, and says so).
599
- function metaCollectionsRm(ws, store, flags, pos) {
600
- const name = need(pos, 0, 'collection name');
601
- if (flags['dry-run']) return dryRunPlan(`rm collections/${name}`, { records: store.ids(name).size, descriptors: 1 }, [`descriptor removed; records under ${storageOf(store.descriptor(name)).path} stay in place and become unindexed`]);
602
- const out = removeCollection(ws, store, name, { force: !!flags.force });
603
- flags.json ? emit(JSON.stringify(out)) : console.log(`✔ removed collection ${out.removed}`);
604
- console.log('✔ compiled — the collection is gone');
605
- reportCommits(out.commits);
606
- return 0;
607
- }
608
-
609
- // `dreamteamer add-field health/visits --name kind --enum intake,follow-up --default-value follow-up`
610
- function metaAddField(ws, store, collection, flags) {
611
- const field = fieldFromFlags(store, flags);
612
- const out = addField(ws, store, collection, { name: oneValue(flags, 'name'), field, moduleId: oneValue(flags, 'module') });
613
- if (out.unchanged) return alreadyThat(`${collection}.${out.field}`);
614
- console.log(`✔ ${rel(ws.root, out.file)}${out.overlay ? ' (overlay)' : ''}`);
615
- console.log('✔ compiled — the field is live');
616
- reportCommits(out.commits);
617
- reportMirror(store, collection, out.field, out.value);
618
- return 0;
619
- }
620
-
621
- /** The idempotent answer, in `rename-collection`'s words — a command that asks for what is already
622
- * there succeeded, and the operator needs to know which field it was talking about. */
623
- function alreadyThat(subject) {
624
- console.log(`✔ ${subject} — already exactly that, nothing to do`);
625
- return 0;
626
- }
627
-
628
- /** A mirror is only correct for records written AFTER it existed: the far side's records already
629
- * carrying a value are counted here, with the repair, because `check` flags every one of them the
630
- * moment the field lands. */
631
- function reportMirror(store, collection, fieldName, field) {
632
- if (!field?.mirror_of) return;
633
- const t = targetsOf(field);
634
- const target = Array.isArray(t) ? t[0] : null;
635
- if (!target || !store.descriptors.has(target)) return;
636
- console.log(` mirror of ${target}.${field.mirror_of} (generated, read-only)`);
637
- const n = [...store.readAll(target)].filter((r) => r.fields[field.mirror_of] != null).length;
638
- if (n) console.log(` ${n} ${target} ${n === 1 ? 'record carries' : 'records carry'} values — run: dreamteamer relations rebuild ${collection}`);
639
- }
640
-
641
- // `dreamteamer set-field tasks --name urgent --required false`
642
- // Same flag vocabulary as add-field (one `fieldFromFlags`), applied over the field as its source
643
- // declares it: a flag that is not passed leaves its key alone.
644
- function metaUpdateField(ws, store, collection, flags) {
645
- const name = oneValue(flags, 'name');
646
- if (!name) throw new Error('missing --name <field>');
647
- const out = updateField(ws, store, collection, name, { flags, moduleId: oneValue(flags, 'module') });
648
- if (out.unchanged) return alreadyThat(`${collection}.${name}`);
649
- console.log(`✔ ${rel(ws.root, out.file)}${out.overlay ? ' (overlay)' : ''}`);
650
- console.log('✔ compiled — the field is updated');
651
- reportCommits(out.commits);
652
- reportMirror(store, collection, name, out.value);
653
- return 0;
654
- }
655
-
656
- /** The positions a positional verb rewrites (or refuses on), one line each — what `--dry-run` is
657
- * for: the operator reads WHERE before deciding. */
658
- function positionLines(positions) {
659
- return positions.map((p) => `${p.fixed ? ' ' : '✖ '}${p.rel} ${p.at}${p.fixed ? '' : ` — ${p.why}`}`);
660
- }
661
-
662
- // `dreamteamer rm-field tasks --name urgent`
663
- function metaRemoveField(ws, store, collection, flags) {
664
- const name = oneValue(flags, 'name');
665
- if (!name) throw new Error('missing --name <field>');
666
- const moduleId = oneValue(flags, 'module');
667
- if (flags['dry-run']) {
668
- const plan = removeField(ws, store, collection, name, { moduleId, dryRun: true });
669
- return dryRunPlan(`rm-field ${collection} --name ${name}`, plan, [...positionLines(plan.positions), ...positionLines(plan.blocking)]);
670
- }
671
- const out = removeField(ws, store, collection, name, { moduleId });
672
- flags.json ? emit(JSON.stringify(out)) : console.log(`✔ removed field ${collection}.${out.removed}`);
673
- console.log('✔ compiled — the field is gone');
674
- reportCommits(out.commits);
675
- // The field's own VALUES went with it, and that has to be said out loud: it is the destructive
676
- // half of a destructive verb, and a silent deletion is a different act from a reported one.
677
- if (!flags.json && out.cleared) console.log(` cleared its values from ${out.cleared} ${collection} record${out.cleared === 1 ? '' : 's'} (git holds them: git show HEAD~1)`);
678
- return 0;
679
- }
680
-
681
- /** An IDENTITY entity kind — a compiled source file per id (skills, agents, commands, bindings,
682
- * mixins, and any kind an extension contributes). Derived from the runtime rather than
683
- * listed, so a contributed kind gets `set · rm · rename` without core knowing its name; `collections`,
684
- * `ui-views` and `modules` have verbs of their own. */
685
- const OWN_VERBS = new Set(['collections', 'ui-views', 'modules']);
686
- const isEntityKind = (store, collection) => storageOf(store?.descriptors.get(collection)).runtime && !OWN_VERBS.has(collection);
687
- const SCAFFOLDABLE = new Set(['skills']);
688
-
689
- function metaEntityVerb(ws, store, kind, verb, flags, pos) {
690
- const one = kind.replace(/s$/, '');
691
- if (verb === 'add') {
692
- const name = oneValue(flags, 'name');
693
- if (!SCAFFOLDABLE.has(kind)) refuseHandAuthored(ws, store, kind, name, oneValue(flags, 'module'));
694
- const out = createSkill(ws, store, {
695
- name,
696
- description: oneValue(flags, 'description'),
697
- moduleId: oneValue(flags, 'module'),
698
- });
699
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
700
- console.log(`✔ ${rel(ws.root, out.file)}`);
701
- console.log('✔ compiled — the skill is live (write its body next; the frontmatter is the trigger)');
702
- reportCommits(out.commits);
703
- return 0;
704
- }
705
- if (verb === 'rm') {
706
- const id0 = need(pos, 0, `${one} id`);
707
- if (flags['dry-run']) return dryRunPlan(`rm ${kind}/${id0}`, { descriptors: 1 }, [`the ${one} source is removed; nothing else moves`]);
708
- const out = removeEntity(ws, store, kind, id0);
709
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
710
- console.log(`✔ removed ${one} ${out.removed}`);
711
- console.log('✔ compiled — it is gone');
712
- reportCommits(out.commits);
713
- return 0;
714
- }
715
- if (verb === 'rename') {
716
- const oldId = need(pos, 0, `${one} id`);
717
- const out = renameEntity(ws, store, kind, oldId, need(pos, 1, 'new id'));
718
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
719
- if (!out.renamed) { console.log(`✔ ${oldId} — already named that, nothing to do`); return 0; }
720
- console.log(`✔ ${kind}/${oldId} → ${kind}/${out.id}`);
721
- console.log('✔ compiled — the rename is live');
722
- reportCommits(out.commits);
723
- return 0;
724
- }
725
- const id = need(pos, 0, `${one} id`);
726
- const changes = { ...pairs(pos.slice(1)), ...stripMeta(flags) };
727
- if (!Object.keys(changes).length) throw new Error(`nothing to set — pass key=value pairs (a ${one}'s frontmatter keys)`);
728
- const out = setEntityFrontmatter(ws, store, kind, id, changes);
729
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
730
- if (out.unchanged) return alreadyThat(`${kind}/${id} ${out.changed.join(', ')}`);
731
- console.log(`✔ ${rel(ws.root, out.file)} — ${out.changed.join(', ')}`);
732
- console.log('✔ compiled — the change is live');
733
- reportCommits(out.commits);
734
- return 0;
735
- }
736
-
737
- /** The path `revert`'s refusal names — where a human edits this compiled entity. */
738
- function sourceHintFor(store, collection) {
739
- // ⚠ `modules` is the one system collection that is PROJECTED rather than stored as a kind folder:
740
- // its source is each module's package.json. Deriving the hint from `storage.path` gave
741
- // `modules/*/modules/`, which `git ls-files` matches nothing at all — a correct refusal handing
742
- // over an unusable remedy.
743
- if (collection === 'modules') return 'modules/*/package.json';
744
- return `modules/*/${storageOf(store.descriptors.get(collection)).path ?? collection}/`;
745
- }
746
-
747
- // `dreamteamer rename-field people --name employer --to company`
748
- function metaRenameField(ws, store, collection, flags) {
749
- const from = oneValue(flags, 'name');
750
- if (!from) throw new Error(`missing --name <field>: dreamteamer rename-field ${collection} --name <field> --to <new-name>`);
751
- const to = oneValue(flags, 'to');
752
- const out = renameField(ws, store, collection, from, to, { dryRun: !!flags['dry-run'] });
753
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
754
- if (out.dryRun) return dryRunPlan(`rename-field ${collection} --name ${from} --to ${to ?? '<new-name>'}`, out, positionLines(out.positions));
755
- if (!out.renamed) { console.log(`✔ ${collection}.${from} — already named that, nothing to do`); return 0; }
756
- console.log(`✔ ${collection}.${out.from} → ${collection}.${out.to}`);
757
- console.log(` records ${out.records} rewritten`);
758
- for (const line of positionLines(out.positions)) console.log(line);
759
- console.log('✔ compiled — the rename is live, in ONE commit');
760
- reportCommits(out.commits);
761
- return 0;
762
- }
763
-
764
- // `dreamteamer rename-value health/visits status seen done`
765
- function metaRenameValue(ws, store, collection, flags, pos) {
766
- const [field, from, to] = pos;
767
- if (!field || from === undefined || to === undefined || pos.length > 3) throw new Error(`usage: dreamteamer rename-value ${collection} <field> <old> <new> [--dry-run]`);
768
- const out = renameValue(ws, store, collection, field, from, to, { dryRun: !!flags['dry-run'] });
769
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
770
- if (out.dryRun) return dryRunPlan(`rename-value ${collection} ${field} ${from} ${to}`, out, positionLines(out.positions));
771
- console.log(`✔ ${collection}.${field}: ${from} → ${to}`);
772
- console.log(` records ${out.records} rewritten`);
773
- for (const line of positionLines(out.positions)) console.log(line);
774
- console.log('✔ compiled — the rename is live, in ONE commit');
775
- reportCommits(out.commits);
776
- return 0;
777
- }
778
-
779
- // ---- ui-views ---------------------------------------------------------------------------------
780
- // A view is an ordinary record conceptually (decision 49) but a SYSTEM-stored one, so it goes
781
- // through saveUiView's compile gate rather than the record store. Without these verbs everything
782
- // the Layout options panel does — columns, order, sort, layout, filter, nav — was click-only.
783
-
784
- /**
785
- * View keys whose value is a LIST, so `display.list.columns=title,status` means what it says.
786
- *
787
- * ⚠ NAMED, not inferred, and that is the whole design: `options` is an open bag with no schema —
788
- * each layout declares its own keys and unknown ones ride through untouched — so nothing in the
789
- * runtime can tell a list key from a scalar one. Without this set the comma spelling every other
790
- * verb accepts for an array (`--tags a,b`) stored the literal string `"title,status"`, which the
791
- * surface reads with `Array.isArray` and therefore ignores: a view that looked configured, drew
792
- * the descriptor's `display.list.columns` instead, and reported nothing anywhere.
793
- *
794
- * `columns` is honoured by every list layout; `ref_fields` and `value_fields` are the diagram's
795
- * link-by pickers. `arrangement` is deliberately ABSENT — its elements are objects, so the JSON
796
- * form is its only honest spelling, and a comma split would quietly produce garbage.
797
- */
798
- const VIEW_LIST_OPTIONS = new Set(['display.list.columns', ...['list', 'record'].flatMap((b) => [`display.${b}.options.ref_fields`, `display.${b}.options.value_fields`])]);
799
-
800
- /** `--filter '{"status":{"_eq":"seen"}}'` style flags, plus dotted `display.list.sort=-date` positionals. The
801
- * KEY is passed because the value's shape depends on it: only the key says whether a comma is a
802
- * separator or a character. */
803
- function parseViewValue(raw, key) {
804
- if (typeof raw !== 'string') return raw;
805
- const t = raw.trim();
806
- if (t === 'true') return true;
807
- if (t === 'false') return false;
808
- if (t !== '' && !Number.isNaN(Number(t))) return Number(t);
809
- if (t.startsWith('{') || t.startsWith('[')) {
810
- try { return JSON.parse(t); } catch { throw new Error(`not valid JSON: ${t}`); }
811
- }
812
- // ⚠ A QUOTED value is a LITERAL string, and `display.list.sort='""'` is the whole reason the branch
813
- // exists: `sort: ''` is what the surface requires to round-trip "unsorted" (omit it and the
814
- // ordering silently reverts to a fallback on the next load), and the dotted grammar could not
815
- // express it — an empty value UNSETS, by the same convention `dt set` has for a record field.
816
- // So the quoting is the operator saying "the empty string IS the value"; `assignViewValue`
817
- // carries that through to `assignPath`.
818
- if (t.startsWith('"')) {
819
- try {
820
- const s = JSON.parse(t);
821
- if (typeof s === 'string') return s;
822
- } catch { /* one message for every malformed quoting, below */ }
823
- throw new Error(`not a quoted string: ${t} — a literal is written like '"-date"' (and '""' for the empty one)`);
824
- }
825
- // An empty value falls through to assignPath, which UNSETS the key — a `columns=` that wrote
826
- // `columns: []` would be a configured-to-show-nothing view, not a removed setting.
827
- if (t !== '' && VIEW_LIST_OPTIONS.has(key)) return t.split(',').map((s) => s.trim()).filter(Boolean);
828
- return raw;
829
- }
830
-
831
- /**
832
- * Assign `a.b.c` into a nested object, creating plain objects on the way down.
833
- *
834
- * An empty or null value REMOVES the key rather than writing `''` — the same convention
835
- * `store.set` has always used for top-level fields (`if (v === null || v === '') delete next[k]`),
836
- * extended to the nested paths the meta verbs address. Without it there was no way to take a key
837
- * back out of a `ui-view`'s `options`, so a superseded option lingered as `provider: ''` and the
838
- * only cure was `rm` + `add`.
839
- *
840
- * Intermediate objects are not created on the way to a delete: unsetting `a.b` on a record with no
841
- * `a` should leave the record alone, not grow an empty `a: {}`.
842
- *
843
- * `explicit` is the escape hatch, and it has exactly one caller: a value the operator QUOTED
844
- * (`display.list.sort='""'`) is a value, empty or not. Without it the convention above has no exception
845
- * and `sort: ''` — which the surface needs to mean "unsorted" — is unwritable from the CLI.
846
- */
847
- function assignPath(target, dotted, value, explicit = false) {
848
- const keys = dotted.split('.');
849
- const leaf = keys[keys.length - 1];
850
- const unset = !explicit && (value === null || value === '');
851
- let node = target;
852
- for (const k of keys.slice(0, -1)) {
853
- if (node[k] == null || typeof node[k] !== 'object' || Array.isArray(node[k])) {
854
- if (unset) return;
855
- node[k] = {};
856
- }
857
- node = node[k];
858
- }
859
- if (unset) delete node[leaf];
860
- else node[leaf] = value;
861
- }
862
-
863
- /** One dotted `key=value` write into a view: the value grammar, plus the one signal `assignPath`
864
- * cannot recover from the parsed value — whether the operator quoted it. */
865
- function assignViewValue(view, key, raw) {
866
- assignPath(view, key, parseViewValue(raw, key), typeof raw === 'string' && raw.trim().startsWith('"'));
867
- }
868
-
869
- // ⚠ `module` is a VERB OPTION, exactly as it is on every other verb that takes one (see META_FLAGS)
870
- // — it says WHERE the source lands and is never a key of the view. Omitting it here is what wrote
871
- // `module: core` into the yaml as a field.
872
- const VIEW_META_FLAGS = new Set(['id', 'json', 'force', 'module']);
873
-
874
- function metaUiView(ws, store, verb, flags, pos) {
875
- if (verb === 'rm') {
876
- const viewId = need(pos, 0, 'ui-view id');
877
- if (flags['dry-run']) return dryRunPlan(`rm ui-views/${viewId}`, { descriptors: 1 }, ['the view source is removed; its route stops resolving']);
878
- const out = removeUiView(ws, store, viewId);
879
- flags.json ? emit(JSON.stringify(out)) : console.log(`✔ removed ui-view ${out.removed}`);
880
- console.log('✔ compiled — the route is gone');
881
- reportCommits(out.commits);
882
- return 0;
883
- }
884
-
885
- // `set` edits what the record already says; `add` starts from nothing. Reading through the
886
- // store means `set` works on a MODULE-shipped view too — the edit lands as a workspace source
887
- // that shadows it, which is the same thing saving one in the UI does.
888
- let view = {};
889
- let id = oneValue(flags, 'id');
890
- // `module=` on a set is the MOVE, spelled as it is for a collection (`dt set collections/<c>
891
- // module=<m>`): a value being written, not the `--module` selector `add` takes.
892
- const moveArg = verb === 'set' ? pos.slice(1).find((p) => p.startsWith('module=')) : undefined;
893
- if (moveArg) {
894
- const viewId = id ?? need(pos, 0, 'ui-view id');
895
- const moveTo = moveArg.slice('module='.length);
896
- const others = [...pos.slice(1).filter((p) => p !== moveArg && p.includes('=')), ...Object.keys(flags).filter((k) => !VIEW_META_FLAGS.has(k) && k !== 'dry-run')];
897
- if (others.length) throw new Error(`module= moves the view to another module; the other keys rewrite it. Run them as two commands: dreamteamer set ui-views/${viewId} module=${moveTo}, then dreamteamer set ui-views/${viewId} ${others.join(' ')}`);
898
- const out = moveUiView(ws, store, viewId, moveTo, { dryRun: !!flags['dry-run'] });
899
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
900
- if (out.dryRun) return dryRunPlan(`set ui-views/${viewId} module=${moveTo}`, { descriptors: 1 }, [`view source ${out.from} → ${out.to} (${out.file})`]);
901
- if (!out.moved) { console.log(`✔ ui-views/${viewId} — already in ${out.to}, nothing to do`); return 0; }
902
- console.log(`✔ ui-views/${viewId}: ${out.from} → ${out.to} (${out.file})`);
903
- console.log('✔ compiled — the move is live');
904
- reportCommits(out.commits);
905
- return 0;
906
- }
907
- if (flags['dry-run']) throw new Error('--dry-run plans a move (module=<m>); a key write has no plan to show — run it without the flag');
908
- if (verb === 'set') {
909
- id ??= need(pos, 0, 'ui-view id');
910
- const { fields } = store.read('ui-views', id);
911
- view = JSON.parse(JSON.stringify(fields));
912
- delete view.id; // the id is the filename, never a body key
913
- delete view.compiled; // compile's, rewritten on every compile
914
- }
915
-
916
- for (const p of pos.slice(verb === 'set' ? 1 : 0)) {
917
- if (!p.includes('=')) continue;
918
- assignViewValue(view, p.slice(0, p.indexOf('=')), p.slice(p.indexOf('=') + 1));
919
- }
920
- for (const [k, v] of Object.entries(flags)) {
921
- if (VIEW_META_FLAGS.has(k)) continue;
922
- // A view key holds ONE value, and a list IS one value — so a repeated flag is a mistake with
923
- // two spellings to correct it, rather than an array nobody asked for.
924
- if (Array.isArray(v)) {
925
- throw new Error(`--${k} was given ${v.length} times — a view key takes one value, and a list is written as one: --${k} ${v.join(',')} (or the JSON form '${JSON.stringify(v)}')`);
926
- }
927
- assignViewValue(view, k, v);
928
- }
929
-
930
- if (!view.route) throw new Error('missing --route </route> — a view is addressed by its route');
931
- // same id rule the descriptor declares (`{{ route | slug }}`) and the UI derives, so a view
932
- // saved from the CLI and one saved from the panel land on the SAME record.
933
- id ??= slug(view.route);
934
-
935
- const out = saveUiView(ws, store, { id, view, moduleId: oneValue(flags, 'module') });
936
- if (flags.json) { emit(JSON.stringify(out)); return 0; }
937
- if (out.unchanged) return alreadyThat(`ui-views/${id}`);
938
- console.log(`✔ ${rel(ws.root, out.file)}`);
939
- console.log(`✔ compiled — ${view.route} is live`);
940
- reportCommits(out.commits);
941
- return 0;
942
- }
943
-
944
- /**
945
- * `dt relations [<collection>] [--json]` — every two-way pair the compiled runtime declares — and
946
- * `dt relations rebuild <collection> [--drop <field>]`.
947
- *
948
- * Rebuild is not a convenience verb: `check` prints "<mirror>: stale — run: dreamteamer relations
949
- * rebuild <target>", so this IS the other half of that sentence and has to repair exactly the state
950
- * check flags. That is why the staleness comparison below is character-for-character the one in
951
- * check.js — two spellings of "stale" would send the operator round a loop that never converges.
952
- */
953
- export function relationsCommand(ws, args) {
954
- const store = new Store(ws);
955
- const { flags, pos } = parseArgs(args);
956
- const rebuilding = pos[0] === 'rebuild';
957
- refuseUnknownFlags(store, (rebuilding ? pos[1] : pos[0]) ?? '', rebuilding ? 'rebuild' : 'relations', flags);
958
- if (rebuilding) return relationsRebuild(store, flags, pos);
959
-
960
- // `store.relations()` is `relationsOf(this.descriptors)` memoized per Store — going through it
961
- // rather than calling relationsOf here keeps one decoder for the whole process.
962
- // The name is VALIDATED, exactly as `rebuild` validates it: without this a typo answered "no
963
- // two-way relations touch nosuch" at exit 0 — the same sentence a correctly-spelled collection
964
- // with no relations gets, so a misspelling reads as a fact about the workspace.
965
- if (pos[0]) store.descriptor(pos[0]);
966
- const rows = store.relations().filter((r) => !pos[0] || r.owner === pos[0] || r.target === pos[0]);
967
- if (flags.json) { emit(JSON.stringify(rows, null, 2)); return 0; }
968
- if (!rows.length) {
969
- console.log(pos[0] ? `no two-way relations touch ${pos[0]}` : 'no two-way relations declared');
970
- return 0;
971
- }
972
- // `[]` on the mirror is cardinality, not decoration: it is the difference between a field the
973
- // operator can read as one reference and one they have to iterate.
974
- const cells = rows.map((r) => [`${r.owner}.${r.field}`, `${r.target}.${r.mirror}${r.unique ? '' : '[]'}`, r.kind, r.onDelete]);
975
- const width = (i) => Math.max(...cells.map((c) => c[i].length));
976
- const [w0, w1, w2] = [width(0), width(1), width(2)];
977
- for (const c of cells) console.log(`${c[0].padEnd(w0)} → ${c[1].padEnd(w1)} ${c[2].padEnd(w2)} ${c[3]}`);
978
- return 0;
979
- }
980
-
981
- function relationsRebuild(store, flags, pos) {
982
- const collection = pos[1];
983
- if (!collection) throw new Error('usage: dreamteamer relations rebuild <collection> [--drop <field>]');
984
- const d = store.descriptor(collection);
985
- // The two shapes compile refuses to stamp a mirror onto, refused again here — because --drop
986
- // writes even when NO relation targets this collection, and `serialize` has no branch for
987
- // `format: binary`: it would replace the record's own bytes (an SVG, a PDF) with frontmatter.
988
- if (!store.canRewrite(collection)) {
989
- const why = storageOf(d).runtime ? 'a compiled source' : 'stored as `format: binary`';
990
- throw new Error(`"${collection}" is ${why} — it carries no generated mirrors and this verb will not rewrite it.`);
991
- }
992
- // `--drop` LAST on the line parses as the boolean `true`. Quietly treating that as "no --drop"
993
- // printed a green "rebuilt 0 records", which the operator reads as "the residue key is gone" —
994
- // the one sentence that must never be said falsely by a repair verb.
995
- if ('drop' in flags && (typeof flags.drop !== 'string' || !flags.drop.trim())) {
996
- throw new Error('--drop needs a field name: dreamteamer relations rebuild <collection> --drop <field>');
997
- }
998
- const drop = typeof flags.drop === 'string' ? flags.drop : null;
999
- if (drop && fieldsOf(d)[drop]) throw new Error(`"${drop}" is a live field of ${collection} — --drop only removes keys the schema no longer declares.`);
1000
-
1001
- // Expectations computed ONCE per relation, over a single pass of each owning collection. The
1002
- // store's own `applyMirrorEdits` re-walks the owners per write, which is right for one edit and
1003
- // quadratic for a whole collection — so rebuild does not build on it.
1004
- const unreadableOwners = [];
1005
- // PER REPO, like check.js and the store: an owner in another repo (a record layer, or this
1006
- // workspace against a module-owned target) implies no mirror on a target it cannot be committed with
1007
- const perRepo = (r) => {
1008
- const groups = new Map();
1009
- for (const o of parseEach(store, r.owner, (f) => unreadableOwners.push(rel(store.root, f)))) {
1010
- const repo = store.repoOfFile(store.descriptor(r.owner), o.file);
1011
- if (!groups.has(repo)) groups.set(repo, []);
1012
- groups.get(repo).push(o);
1013
- }
1014
- return new Map([...groups].map(([repo, os]) => [repo, expectedMirrors(r, os)]));
1015
- };
1016
- const expected = store.relations()
1017
- .filter((r) => r.target === collection)
1018
- .map((r) => ({ r, exp: perRepo(r) }));
1019
- // An owner that will not parse takes its edges with it — and rebuild would then DELETE the mirror
1020
- // values those edges justify. Refuse while nothing has been written yet; a skip here is data loss,
1021
- // unlike a skip on the target side below, which only leaves a record unrepaired.
1022
- if (unreadableOwners.length) {
1023
- throw new Error(`cannot rebuild ${collection}: ${unreadableOwners.join(', ')} will not parse — fix the owning record first (\`dreamteamer check\` names the syntax error).`);
1024
- }
1025
-
1026
- let rebuilt = 0;
1027
- // The write lock, like every other write verb: several agents work in one tree, and a concurrent
1028
- // `dt set` landing mid-sweep would be clobbered back to the pre-set mirror value.
1029
- store.withWriteLock(() => {
1030
- for (const { id, file, fields } of parseEach(store, collection, (f) => console.warn(`⚠ ${rel(store.root, f)}: parse error, skipped — \`dreamteamer check\` reports it`))) {
1031
- let changed = false;
1032
- const repo = store.repoOfFile(d, file);
1033
- for (const { r, exp } of expected) {
1034
- // a layer's mirror justified by owners this workspace does not read from that layer is
1035
- // left exactly as the layer wrote it — rebuilding it from here deleted it (ownersReadIn)
1036
- if (store.layerOfFile(d, file) && !ownersReadIn(store.descriptor(r.owner), repo)) continue;
1037
- const want = exp.get(repo)?.get(id);
1038
- const have = fields[r.mirror];
1039
- // ⚠ COERCE THE WAY AJV DOES. `check` validates with `coerceTypes: 'array'`, which mutates
1040
- // the record in place BEFORE its relation pass — so it compares a coerced value while this
1041
- // reads the raw parse. Unmatched, the two disagree in both directions: `recordings: 5`
1042
- // crashed the spread here ("(have ?? []) is not iterable") on the very record check had
1043
- // just named, mid-loop and after earlier writes; and `recordings: recordings/cap` read as
1044
- // stale here while check called it fine.
1045
- const list = Array.isArray(have) ? have : have == null ? [] : [have];
1046
- // the comparison check.js makes: a unique relation mirrors to a scalar, everything else
1047
- // to a sorted array, and absent reads the same as empty
1048
- const same = r.unique
1049
- ? (have ?? null) === (want ?? null)
1050
- : JSON.stringify([...list].sort()) === JSON.stringify(want ?? []);
1051
- if (same) continue;
1052
- if (want == null) delete fields[r.mirror];
1053
- else fields[r.mirror] = want;
1054
- changed = true;
1055
- }
1056
- if (drop && drop in fields) { delete fields[drop]; changed = true; }
1057
- // each record is written AT MOST ONCE, whatever number of relations point at it
1058
- if (changed && atomicWrite(file, serialize(d, fields))) rebuilt++;
1059
- }
1060
- });
1061
- if (flags.json) { emit(JSON.stringify({ collection, rebuilt })); return 0; }
1062
- // auto-commit is off by default, so these writes are sitting dirty — but only say so when
1063
- // something actually landed; a commit hint after "rebuilt 0" is an instruction to do nothing.
1064
- const hint = rebuilt ? ` — run: dreamteamer commit ${collection}` : '';
1065
- console.log(`✔ rebuilt ${rebuilt} record${rebuilt === 1 ? '' : 's'}${hint}`);
1066
- return 0;
1067
- }
1068
-
1069
- /** `store.readAll` for a reader that must SURVIVE a bad record. It is a generator, so a parse error
1070
- * mid-walk cannot be resumed past — and rebuild is the one reader that has already written by the
1071
- * time a later record blows up, so an abort leaves a partial sweep behind an error naming no file
1072
- * at all. Here the bad record is handed to `onError` and skipped, and the walk finishes. */
1073
- function* parseEach(store, collection, onError) {
1074
- const d = store.descriptor(collection);
1075
- const bf = bodyField(d);
1076
- const rows = [...store.ids(collection)].map(([id, file]) => ({ id, file }));
1077
- for (const { id, file } of rows) {
1078
- let fields;
1079
- try {
1080
- fields = parseRecord(file, d, bf);
1081
- } catch (e) {
1082
- onError(file, e);
1083
- continue;
1084
- }
1085
- yield { id, file, fields };
1086
- }
1087
- }
1088
-
1089
- /**
1090
- * `--flag value`, `--flag=value`, a bare `--flag` (true), and positionals.
1091
- *
1092
- * ⚠ A REPEATED flag PROMOTES TO AN ARRAY; it does not overwrite. `dt add c --tags a --tags b`
1093
- * assigned twice and kept `b`, so the first value never reached disk and nothing said so — the
1094
- * shape of every silent-wrong-answer bug this CLI has had. The promotion is the only honest parse,
1095
- * because "the operator typed it twice" is a fact the parser cannot interpret on its own.
1096
- *
1097
- * Every consumer of a flag therefore owes an answer to "what does a repeat MEAN here", and there
1098
- * are exactly three: it is one ELEMENT of an array field (`coerceArrays`), it is one more
1099
- * conjunctive CONDITION (`--filter`, in list), or the flag holds one value and a repeat is a
1100
- * MISTAKE (`oneValue`, and the view writer). Silence is not one of them.
1101
- */
1102
- export function parseArgs(args) {
1103
- const flags = {};
1104
- const pos = [];
1105
- const put = (k, v) => { flags[k] = k in flags ? [].concat(flags[k], v) : v; };
1106
- for (let i = 0; i < args.length; i++) {
1107
- const a = args[i];
1108
- if (a.startsWith('--')) {
1109
- const eq = a.indexOf('=');
1110
- if (eq > -1) put(a.slice(2, eq), a.slice(eq + 1));
1111
- else if (i + 1 < args.length && !args[i + 1].startsWith('--')) put(a.slice(2), args[++i]);
1112
- else put(a.slice(2), true);
1113
- } else pos.push(a);
1114
- }
1115
- return { flags, pos };
1116
- }
1117
-
1118
- /** Read a flag that takes exactly ONE value. A repeat arrives as an array, and dropping it on the
1119
- * floor (`typeof v === 'string'` reads an array as absent) would answer the wrong question at exit
1120
- * 0 — so it is named instead, with the line that was typed. */
1121
- function oneValue(flags, key) {
1122
- const v = flags[key];
1123
- if (Array.isArray(v)) {
1124
- throw new Error(`--${key} was given ${v.length} times and takes ONE value: ${v.map((x) => `--${key} ${x}`).join(' ')}`);
1125
- }
1126
- return typeof v === 'string' ? v : undefined;
1127
- }
1128
-
1129
- /** `field=value` positionals, with the same promote-on-repeat rule the flags have. It was
1130
- * `Object.fromEntries`, which keeps the LAST pair — `dt set c/id tags=a tags=b` wrote `[b]`. */
1131
- function pairs(list) {
1132
- const out = {};
1133
- for (const p of list) {
1134
- if (!p.includes('=')) continue;
1135
- const k = p.slice(0, p.indexOf('='));
1136
- const v = p.slice(p.indexOf('=') + 1);
1137
- out[k] = k in out ? [].concat(out[k], v) : v;
1138
- }
1139
- return out;
1140
- }
1141
-
1142
- // ⚠ `module` and `dry-run` are VERB OPTIONS on every verb that takes them, so they may never be
1143
- // read as record field names. A collection wanting a field literally called `module` writes it as
1144
- // `module=<v>` positionally, which `pairs()` reads and `stripMeta` never sees.
1145
- const META_FLAGS = new Set(['id', 'json', 'force', 'filter', 'module', 'dry-run']);
1146
- const stripMeta = (flags) => Object.fromEntries(Object.entries(flags).filter(([k]) => !META_FLAGS.has(k)));
1147
-
1148
- // CLI values are strings; split comma-lists for array-typed fields (ajv coerces the rest)
1149
- function coerceArrays(d, fields) {
1150
- const out = {};
1151
- for (const [k, v] of Object.entries(fields)) {
1152
- const isList = fieldsOf(d)[k]?.many === true;
1153
- // An array here means the operator SPELLED the key twice (`--tags a --tags b`, or
1154
- // `tags=a tags=b`). On a list field each sighting is one element — deliberately NOT
1155
- // comma-split again, so a value that contains a comma can be written by repeating the flag.
1156
- if (Array.isArray(v)) {
1157
- if (!isList) {
1158
- throw new Error(`${k} was given ${v.length} times (--${k} <value> / ${k}=<value>) and ${k} is not an array field — pass it once`);
1159
- }
1160
- out[k] = v;
1161
- continue;
1162
- }
1163
- out[k] = isList && typeof v === 'string' ? v.split(',').map((s) => s.trim()).filter(Boolean) : v;
1164
- }
1165
- return out;
1166
- }
1167
-
1168
- function need(pos, i, what) {
1169
- if (pos[i] === undefined) throw new Error(`missing <${what}>`);
1170
- return pos[i];
1171
- }
1172
-
1173
- const fmtCell = (v) => (v === undefined ? '-' : Array.isArray(v) ? v.join(',') : String(v));
1174
-
1175
- /**
1176
- * The rows one `list` invocation actually wants — narrowed, ordered, bodies dropped.
1177
- *
1178
- * ⚠ ONE implementation: the generic `list` case is its only caller today, and an interceptor that
1179
- * adds columns calls it rather than copying it — a second copy is how `--sort` ends up working on
1180
- * one collection and not on another.
1181
- */
1182
- function narrowRows(store, d, collection, flags) {
1183
- // EVERY condition, ANDed — a repeated flag composes rather than replacing. `--filter a=1
1184
- // --filter b=2` used to keep only `b=2` and return rows the caller had excluded, which is
1185
- // the one failure a narrowing verb must not have: a listing that answers a question nobody
1186
- // asked, at exit 0. Bare-field flags (`--status todo`) already composed this way; the
1187
- // meta flag now reads the same, and `[].concat` treats one and many alike.
1188
- const filters = Object.entries(flags)
1189
- .filter(([k]) => !LIST_META_FLAGS.has(k))
1190
- .flatMap(([k, v]) => [].concat(v).map((one) => [k, one]));
1191
- for (const cond of [].concat(flags.filter ?? [])) {
1192
- const eq = String(cond).indexOf('=');
1193
- // `--filter status` is not a condition. It used to slice into `statu = status`, which
1194
- // matches nothing and reads as a fact about the collection.
1195
- if (eq < 1) throw new Error(`--filter takes <field>=<value> — got "${cond}"`);
1196
- filters.push([String(cond).slice(0, eq), String(cond).slice(eq + 1)]);
1197
- }
1198
- // `--where` is the SAME operator set the studio's filter panel emits and saved views
1199
- // store — one `matchesFilter`, so `--where '{"starts":{"_gte":"2026-07-01"}}'` and the
1200
- // panel that produced that JSON cannot disagree about which records match.
1201
- const whereJson = oneValue(flags, 'where');
1202
- const where = whereJson ? load(whereJson) : null;
1203
- // ⚠ A FLAG NAME IS NOT THE ONLY THING THAT CAN BE MISSPELLED. `--filter nmae=Ada` and
1204
- // `--sort nmae` are correctly spelled FLAGS whose VALUE names a field that does not exist,
1205
- // and both answer at exit 0 — an empty listing and an unsorted one. Same silent-empty class,
1206
- // worse than a bad write because there is nothing to notice. `--where` gets the type check
1207
- // for the same reason: `--where 'name _eq Ada'` yaml-parses to a STRING, and matchesFilter
1208
- // then matched every row.
1209
- if (whereJson && (typeof where !== 'object' || where === null)) throw new Error(`--where takes ONE filter OBJECT and got a ${where === null ? 'null' : typeof where}: ${whereJson}\n a condition is {"<field>":{"_eq":"<value>"}} — the shorthand for one equality is --filter <field>=<value>`);
1210
- const badTokens = where ? [...unknownTokens(where)] : [];
1211
- if (badTokens.length) throw new Error(`--where holds unknown value token(s) ${badTokens.join(', ')} — the tokens are ${VALUE_TOKENS.join(' and ')}; any other value is a literal without a leading $`);
1212
- const sort = oneValue(flags, 'sort');
1213
- const vocab = ['id', ...Object.keys(fieldsOf(d))];
1214
- const stray = [...filters.map(([k]) => k), ...(sort ? [String(sort).replace(/^-/, '')] : [])].find((f) => !vocab.includes(f));
1215
- if (stray) throw new Error(`${collection} has no field "${stray}"${nearest(stray, vocab) ? ` — did you mean "${nearest(stray, vocab)}"?` : ''} (dt get collections/${collection} lists them)`);
1216
- const resolve = where ? recordResolver(store) : null;
1217
- const bf = bodyField(d);
1218
- const rows = [];
1219
- const files = new Map();
1220
- for (const { id, fields, file } of store.readAll(collection)) { // ONE walk, not one per record
1221
- if (!filters.every(([k, v]) => String(fields[k] ?? '') === String(v))) continue;
1222
- if (where && !matchesFilter({ ...fields, id }, where, resolve)) continue;
1223
- if (bf) delete fields[bf]; // bodies don't belong in listings
1224
- rows.push({ ...fields, id }); // record id WINS over any schema field named "id"
1225
- files.set(id, file);
1226
- }
1227
- // sorting was studio-only until now: the browse table ordered records and no CLI
1228
- // invocation could. Same `sortRows` the server and api.ts call, so `--sort -starts`
1229
- // orders date-times by INSTANT across mixed offsets rather than by string.
1230
- if (sort) sortRows(rows, sort, jsonSchemaOf(d));
1231
- return { rows, narrowed: !!(filters.length || where), files };
1232
- }
1233
-
1234
- /** A record's location as `--json` carries it: `$file` and `$repo` (null = outside every repo here). */
1235
- const whereKeys = ({ file, repo }) => ({ $file: file, $repo: repo });
1236
-
1237
- /** What a write on an EXISTING record adds to its `✔` line: nothing in the workspace's own repo; the
1238
- * repo when it is another clone (a layer, a module's list); and that it is never committed when the
1239
- * root is outside every repo here. The workspace name alone used to be printed wherever it landed. */
1240
- function landedIn(where) {
1241
- if (!where) return '';
1242
- const { repo } = where;
1243
- if (repo === null) return ' — outside every git repo here, never committed';
1244
- return repo === '.' ? '' : ` in ${repo}`;
1245
- }
1246
-
1247
- /** `id` first, then the descriptor's own columns — the shape every text listing prints. */
1248
- const listColumns = (d) => ['id', ...(displayOf(d).list?.columns ?? []).map((c) => (c === 'last_modified' ? 'last-modified' : c)).filter((c) => c !== 'id')];
1249
-
1250
- function rel(root, p) {
1251
- return p.startsWith(root) ? p.slice(root.length + 1) : p;
1252
- }
1253
-
1254
- /**
1255
- * THE ONE PLACE A FLAG NAME IS VALIDATED — every record, system and field verb goes through
1256
- * `collectionCommand`, so the check lives beside the parser they share rather than being
1257
- * re-invented per verb.
1258
- *
1259
- * ⚠ IT EXISTS BECAUSE THE PARSER USED TO SWALLOW EVERYTHING. `dt add modules --name hr --bogusflag x`
1260
- * succeeded silently, so a misspelled flag and a supported one were indistinguishable — and that is
1261
- * what let `add modules --namespace hr` be accepted-and-ignored for a whole release with nobody
1262
- * noticing. The worst instance was `--dryrun`, where the swallowed flag is the one standing between
1263
- * a plan and a self-committed delete.
1264
- *
1265
- * TWO VOCABULARIES, and the split is what keeps the refusal honest. A verb's OPTIONS are closed and
1266
- * enumerated here; an entity's own KEYS are open and cannot be — `dt list people --status todo` is a
1267
- * shorthand filter on a declared field, `dt add people --name Ada` writes one, and a ui-view's
1268
- * `display.list.options.*` is an open bag by design. So the allowlist is the table PLUS the target's declared
1269
- * properties, and nothing is refused that either half can name.
1270
- *
1271
- * ⚠ A REFUSAL THAT REJECTS A VALID FLAG IS WORSE THAN THE SILENCE IT REPLACES, which is why a verb
1272
- * with no table entry is left exactly as it was rather than being guessed at — and why the field
1273
- * verbs' row is the whole `fieldFromFlags` vocabulary, read off nothing, so a flag added there has to be
1274
- * added here too or its own test fails.
1275
- *
1276
- * A key is `<collection>:<verb>` where the system entity has its own interceptor, `<verb>` otherwise.
1277
- */
1278
- export const FIELD_FLAGS = ['json', 'module', 'name', 'type', 'enum', 'default-value', 'default', 'required', 'description', 'many', 'unique', 'soft', 'body', 'sensitive', 'on-delete', 'mirror-of'];
1279
- const JSON_ONLY = ['json'];
1280
- const FORCE_RM = ['json', 'force', 'dry-run'];
1281
- const NAV_MOVE = ['json', 'after', 'before', 'top', 'bottom'];
1282
-
1283
- export const VERB_FLAGS = {
1284
- list: ['json', 'filter', 'where', 'sort'], get: ['json', 'referrer'], add: ['json', 'id', 'from', 'force'], set: JSON_ONLY,
1285
- rm: FORCE_RM, rename: JSON_ONLY, reorder: [...NAV_MOVE, 'init'], values: ['json', 'limit'],
1286
- history: JSON_ONLY, diff: ['json', 'hash'], revert: ['json', 'hash'],
1287
- ensure: ['json', 'all'], for: ['json', 'ids'], relations: JSON_ONLY, rebuild: ['json', 'drop'],
1288
- 'add-field': FIELD_FLAGS, 'set-field': FIELD_FLAGS,
1289
- 'rm-field': ['json', 'module', 'name', 'dry-run'],
1290
- 'rename-field': ['json', 'name', 'to', 'dry-run'],
1291
- 'rename-value': ['json', 'dry-run'],
1292
- 'collections:add': ['json', 'module', 'name', 'namespace', 'mixins', 'id-from', 'description', 'suffix'],
1293
- 'collections:get': ['json', 'module'], 'collections:set': ['json', 'module', 'dry-run'],
1294
- 'collections:rm': FORCE_RM, 'collections:rename': ['json', 'namespace', 'dry-run'], 'collections:reorder': NAV_MOVE,
1295
- 'modules:add': ['json', 'name', 'description', 'namespace', 'extension', 'package'], 'modules:rename': JSON_ONLY, 'modules:rm': FORCE_RM,
1296
- 'modules:set': ['json', 'description', 'namespaces', 'dependencies', 'peer_collections'],
1297
- // the identity kinds: `add` scaffolds, `rm`/`rename` fall through to the generic rows, and `set`
1298
- // is deliberately UNCHECKED — a skill's frontmatter is an open document (`allowed-tools`, `model`,
1299
- // whatever a harness reads), so there is no closed set to check it against.
1300
- 'skills:add': ['json', 'module', 'name', 'description'],
1301
- 'ui-views:add': ['json', 'module', 'id', 'force'], 'ui-views:set': ['json', 'module', 'id', 'force', 'dry-run'], 'ui-views:rm': FORCE_RM,
1302
- };
1303
-
1304
- /** Edit distance, capped — enough to turn `--fliter` into "did you mean --filter?", and to refuse to
1305
- * guess at anything further away than a typo. */
1306
- function nearest(word, candidates) {
1307
- const distance = (c) => {
1308
- let prev = [...Array(word.length + 1).keys()];
1309
- for (let i = 1; i <= c.length; i++) {
1310
- const row = [i];
1311
- for (let j = 1; j <= word.length; j++) row[j] = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (c[i - 1] === word[j - 1] ? 0 : 1));
1312
- prev = row;
1313
- }
1314
- return prev[word.length];
1315
- };
1316
- const cap = Math.min(3, Math.ceil(word.length / 2));
1317
- return candidates.map((c) => [c, distance(c)]).filter(([, n]) => n <= cap).sort((a, b) => a[1] - b[1])[0]?.[0] ?? null;
1318
- }
1319
-
1320
- export function refuseUnknownFlags(store, collection, verb, flags) {
1321
- // `store` may be null for an entity the store does not know — the refusal is still owed.
1322
- const d = store?.descriptors.get(collection);
1323
- const known = VERB_FLAGS[`${collection}:${verb}`]
1324
- ?? (isEntityKind(store, collection) && verb === 'add' ? VERB_FLAGS['skills:add'] : VERB_FLAGS[verb]);
1325
- if (!known) return; // no declared vocabulary — left exactly as it was rather than guessed at
1326
- // The OPEN half: a data collection's own fields (shorthand filters and field writes), and the
1327
- // declared keys of an entity `set` writes (`--route` on a view, and dotted `display.list.sort`).
1328
- const system = storageOf(d).runtime;
1329
- // ⚠ NO DESCRIPTOR MEANS NO OPEN HALF — offering "plus any field of X" for a thing with no fields
1330
- // would read as though the refused flag were merely misspelled.
1331
- const openOf = !d ? null
1332
- : !system ? (['list', 'add', 'set'].includes(verb) ? `field of ${collection}` : null)
1333
- : (collection === 'ui-views' && verb !== 'rm') || (isEntityKind(store, collection) && verb === 'set') ? `declared key of ${collection}` : null;
1334
- const open = openOf ? Object.keys(storedFieldsOf(d)) : [];
1335
- const allowed = new Set([...known, ...open]);
1336
- for (const f of Object.keys(flags)) {
1337
- if (allowed.has(f) || (openOf && allowed.has(f.split('.')[0]))) continue;
1338
- const near = nearest(f, [...allowed]);
1339
- throw new Error(`unknown flag "--${f}" on \`dt ${verb} ${collection}\`${near ? ` — did you mean --${near}?` : ''}\n known: ${[...known].sort().map((k) => `--${k}`).join(', ')}${openOf ? `, plus any ${openOf}` : ''}`);
1340
- }
1341
- // ⚠ AND THE REPEAT REFUSAL, which used to be 15 hand-written `refuseRepeats(flags)` lines — one
1342
- // per meta verb, and a new verb had to remember it. A SCHEMA verb takes one value per flag (none
1343
- // of them means a list by repetition), so the same table that says which flags exist says which
1344
- // verbs the rule applies to: everything with a closed vocabulary EXCEPT the open halves, where a
1345
- // repeat legitimately composes (`--filter a=1 --filter b=2`, `--tags a --tags b`). `ui-views`
1346
- // keeps its own message, which names both spellings of the fix. ⚠ THE FIELD VERBS COUNT AS SCHEMA
1347
- // VERBS EVEN THOUGH THEIR TARGET IS A DATA COLLECTION — `add-field notes --name x --name y` is the
1348
- // case the old helper was written for, and keying the rule on the target alone excused it.
1349
- if (collection === 'ui-views' || (!system && !verb.endsWith('-field') && verb !== 'rename-value')) return;
1350
- const dup = Object.entries(flags).find(([, v]) => Array.isArray(v));
1351
- if (dup) throw new Error(`--${dup[0]} was given ${dup[1].length} times, and a schema verb takes ONE value per flag: ${dup[1].map((x) => `--${dup[0]} ${x}`).join(' ')}`);
1352
- }