total-recall-brain 3.44.0 → 3.46.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 (502) hide show
  1. package/bin/total-recall.mjs +10 -6
  2. package/docs/ARCHITECTURE.md +10 -7
  3. package/docs/reference/cli-reference.md +13 -8
  4. package/frontend/dist/assets/index-BRYE1jmv.css +1 -0
  5. package/frontend/dist/assets/index-D1goIPjC.js +5598 -0
  6. package/frontend/dist/index.html +2 -2
  7. package/frontend/dist/sw.js +5 -4
  8. package/frontend/src/App.tsx +185 -238
  9. package/frontend/src/api/auth-inventory.ts +62 -0
  10. package/frontend/src/api/memory.ts +13 -8
  11. package/frontend/src/api/plugin-credentials.ts +23 -0
  12. package/frontend/src/api/plugins.ts +37 -53
  13. package/frontend/src/api/workspace-drawers.ts +97 -0
  14. package/frontend/src/components/BrainSelector.tsx +9 -3
  15. package/frontend/src/components/plugins/PluginPanel.tsx +83 -42
  16. package/frontend/src/components/plugins/PluginSettings.tsx +10 -20
  17. package/frontend/src/components/plugins/PluginWorkspace.tsx +367 -0
  18. package/frontend/src/components/plugins/ScopedPluginCommands.tsx +142 -0
  19. package/frontend/src/components/plugins/plugin-frame.ts +44 -33
  20. package/frontend/src/components/plugins/scoped-plugin-operations.ts +28 -0
  21. package/frontend/src/components/workspace/DrawerChat.tsx +110 -0
  22. package/frontend/src/components/workspace/DrawerLayout.tsx +196 -0
  23. package/frontend/src/components/workspace/DrawerMarkup.tsx +49 -0
  24. package/frontend/src/components/workspace/PluginChunkLibrary.tsx +92 -0
  25. package/frontend/src/components/workspace/PluginHome.tsx +76 -0
  26. package/frontend/src/components/workspace/WorkspaceDrawers.tsx +96 -0
  27. package/frontend/src/components/workspace/WorkspacePage.tsx +95 -0
  28. package/frontend/src/components/workspace/usePluginDesign.ts +38 -0
  29. package/frontend/src/index.css +409 -136
  30. package/frontend/src/pages/HelpPage.tsx +15 -46
  31. package/frontend/src/pages/MemoryPage.tsx +19 -36
  32. package/frontend/src/pages/SettingsPage.tsx +1 -1
  33. package/metadata.plugin.schema.json +53 -227
  34. package/package.json +1 -1
  35. package/scaffold/.agent/skills/plugin/SKILL.md +13 -11
  36. package/scaffold/.agent/skills/plugin/evals/README.md +14 -21
  37. package/scaffold/.agent/skills/plugin/evals/cases/01-fabricated-seed.mjs +15 -18
  38. package/scaffold/.agent/skills/plugin/evals/cases/02-reassuring-default.mjs +19 -24
  39. package/scaffold/.agent/skills/plugin/evals/cases/03-declared-template.mjs +12 -20
  40. package/scaffold/.agent/skills/plugin/evals/cases/04-home-collects-credential.mjs +35 -0
  41. package/scaffold/.agent/skills/plugin/evals/cases/05-host-leak-in-scaffold.mjs +8 -28
  42. package/scaffold/.agent/skills/plugin/evals/cases/06-correct-plugin.mjs +85 -47
  43. package/scaffold/.agent/skills/plugin/evals/run.mjs +17 -18
  44. package/scaffold/.agent/skills/plugin/prompts/05-credentials.md +4 -4
  45. package/scaffold/.agent/skills/plugin/prompts/07-scaffold.md +2 -2
  46. package/scaffold/.agent/skills/plugin/prompts/08-verify.md +4 -4
  47. package/scaffold/.agent/skills/plugin/references/anti-patterns.md +2 -2
  48. package/scaffold/.agent/skills/plugin/references/generative-home.md +38 -0
  49. package/scaffold/.agent/skills/plugin/references/scaffold.md +5 -5
  50. package/scaffold/.agent/skills/plugin/references/surfaces.md +13 -4
  51. package/scaffold/.agent/skills/plugin/scripts/record.mjs +75 -153
  52. package/scaffold/.agent/skills/plugin/subagents/plugin-reviewer.md +4 -4
  53. package/scaffold/.agent/skills/total-recall/plugins/auth/DESIGN.md +76 -0
  54. package/scaffold/.agent/skills/total-recall/plugins/auth/README.md +3 -1
  55. package/scaffold/.agent/skills/total-recall/plugins/auth/cli.mjs +20 -15
  56. package/scaffold/.agent/skills/total-recall/plugins/auth/package-lock.json +7 -7
  57. package/scaffold/.agent/skills/total-recall/plugins/auth/package.json +2 -1
  58. package/scaffold/.agent/skills/total-recall/plugins/auth/plugin.json +13 -51
  59. package/scaffold/.agent/skills/total-recall/plugins/auth/src/cli-secret.mjs +20 -1
  60. package/scaffold/.agent/skills/total-recall/plugins/auth/src/secrets-store.mjs +12 -1
  61. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/access-overview.md +17 -0
  62. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/agent-login.md +20 -0
  63. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/baseline-audit.md +22 -0
  64. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/credential-repository-binding.md +17 -0
  65. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/credential-store-maintenance.md +17 -0
  66. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/dashboard-password.md +18 -0
  67. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/dashboard-sessions.md +18 -0
  68. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/endpoint-probe.md +23 -0
  69. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/google-sign-in.md +21 -0
  70. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/mesh-machines.md +16 -0
  71. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/passkey-enrollment.md +21 -0
  72. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/registered-brains.md +16 -0
  73. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/scoped-access-keys.md +17 -0
  74. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/secret-inventory.md +25 -0
  75. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/chunks/signing-key-rotation.md +22 -0
  76. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/home.js +375 -0
  77. package/scaffold/.agent/skills/total-recall/plugins/automations/BRICK.md +7 -0
  78. package/scaffold/.agent/skills/total-recall/plugins/automations/DESIGN.md +53 -0
  79. package/scaffold/.agent/skills/total-recall/plugins/automations/LICENSE +21 -0
  80. package/scaffold/.agent/skills/total-recall/plugins/automations/README.md +66 -0
  81. package/scaffold/.agent/skills/total-recall/plugins/automations/adapters.mjs +247 -0
  82. package/scaffold/.agent/skills/total-recall/plugins/automations/capability/index.mjs +16 -0
  83. package/scaffold/.agent/skills/total-recall/plugins/automations/cli.mjs +130 -0
  84. package/{src/core/plugin-cron.mjs → scaffold/.agent/skills/total-recall/plugins/automations/cron.mjs} +1 -3
  85. package/scaffold/.agent/skills/total-recall/plugins/automations/inventory.mjs +88 -0
  86. package/scaffold/.agent/skills/total-recall/plugins/automations/package-lock.json +7661 -0
  87. package/scaffold/.agent/skills/total-recall/plugins/automations/package.json +36 -0
  88. package/scaffold/.agent/skills/total-recall/plugins/automations/plugin.json +151 -0
  89. package/scaffold/.agent/skills/total-recall/plugins/automations/scheduler.mjs +246 -0
  90. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/automations.js +2 -0
  91. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/control-ledger.md +42 -0
  92. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/local-inventory-triage.md +17 -0
  93. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/pending-control.md +39 -0
  94. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/run-evidence.md +41 -0
  95. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/schedule-vs-run-evidence.md +17 -0
  96. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/chunks/source-coverage.md +41 -0
  97. package/scaffold/.agent/skills/total-recall/plugins/automations/ui/home.js +278 -0
  98. package/scaffold/.agent/skills/total-recall/plugins/code-quality/DESIGN.md +53 -0
  99. package/scaffold/.agent/skills/total-recall/plugins/code-quality/cli.mjs +23 -0
  100. package/scaffold/.agent/skills/total-recall/plugins/code-quality/commands/run-core.mjs +5 -3
  101. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/check.mjs +61 -7
  102. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report-data.mjs +40 -14
  103. package/scaffold/.agent/skills/total-recall/plugins/code-quality/core/report.mjs +15 -40
  104. package/scaffold/.agent/skills/total-recall/plugins/code-quality/package-lock.json +7 -7
  105. package/scaffold/.agent/skills/total-recall/plugins/code-quality/package.json +2 -1
  106. package/scaffold/.agent/skills/total-recall/plugins/code-quality/plugin.json +40 -40
  107. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/config.md +15 -0
  108. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/detect.md +15 -0
  109. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/gate.md +15 -0
  110. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/init.md +15 -0
  111. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/report.md +17 -0
  112. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/run.md +17 -0
  113. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/chunks/snapshot.md +15 -0
  114. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/code-quality-report.mjs +55 -23
  115. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/home.mjs +214 -0
  116. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/DESIGN.md +146 -0
  117. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package-lock.json +7 -7
  118. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/package.json +2 -1
  119. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/plugin.json +51 -34
  120. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/src/command.mjs +1 -1
  121. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/create.md +35 -0
  122. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/history.md +35 -0
  123. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/library.md +49 -0
  124. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/list.md +42 -0
  125. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/promote.md +40 -0
  126. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/read.md +25 -0
  127. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/remove.md +26 -0
  128. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/rollback.md +26 -0
  129. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/show.md +53 -0
  130. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/status.md +40 -0
  131. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/test-path.md +38 -0
  132. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/test.md +46 -0
  133. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/chunks/update.md +32 -0
  134. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/home.js +533 -0
  135. package/scaffold/.agent/skills/total-recall/plugins/embeddings/DESIGN.md +110 -0
  136. package/scaffold/.agent/skills/total-recall/plugins/embeddings/package-lock.json +7 -7
  137. package/scaffold/.agent/skills/total-recall/plugins/embeddings/package.json +2 -1
  138. package/scaffold/.agent/skills/total-recall/plugins/embeddings/plugin.json +13 -10
  139. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/benchmark.md +49 -0
  140. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/coverage.md +53 -0
  141. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/models.md +43 -0
  142. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/pull.md +41 -0
  143. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/chunks/status.md +59 -0
  144. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/home.js +353 -0
  145. package/scaffold/.agent/skills/total-recall/plugins/git/DESIGN.md +31 -0
  146. package/scaffold/.agent/skills/total-recall/plugins/git/README.md +136 -0
  147. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/cli.mjs +140 -24
  148. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/package-lock.json +9 -9
  149. package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/package.json +4 -2
  150. package/scaffold/.agent/skills/total-recall/plugins/git/plugin.json +151 -0
  151. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/context.mjs +94 -0
  152. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/phase3-spec-support.mjs +50 -0
  153. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/runtime.mjs +40 -0
  154. package/scaffold/.agent/skills/total-recall/plugins/git/src/lib/spec-support.mjs +51 -0
  155. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/_support.mjs +195 -0
  156. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/auth.mjs +201 -0
  157. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/bisect.mjs +40 -0
  158. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/cli-meta.mjs +159 -0
  159. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/commit-memory.mjs +54 -0
  160. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/commit.mjs +46 -0
  161. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/fleet.mjs +174 -0
  162. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/force-push.mjs +58 -0
  163. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/group.mjs +119 -0
  164. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/handoff.mjs +59 -0
  165. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/message.mjs +22 -0
  166. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/resolve.mjs +60 -0
  167. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/rules.mjs +81 -0
  168. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/secret-firewall.mjs +92 -0
  169. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/undo.mjs +156 -0
  170. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/unmerged.mjs +182 -0
  171. package/scaffold/.agent/skills/total-recall/plugins/git/src/ops/why.mjs +16 -0
  172. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/change-comparison.md +27 -0
  173. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/commit-identity.md +22 -0
  174. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/create-worktree.md +25 -0
  175. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/registered-worktrees.md +22 -0
  176. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/remove-worktree.md +23 -0
  177. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/repository-ledger.md +25 -0
  178. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/unmerged-work.md +22 -0
  179. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/upstream-divergence.md +17 -0
  180. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/worktree-conflict-triage.md +17 -0
  181. package/scaffold/.agent/skills/total-recall/plugins/git/ui/chunks/worktree-terminal.md +22 -0
  182. package/scaffold/.agent/skills/total-recall/plugins/git/ui/home.js +273 -0
  183. package/scaffold/.agent/skills/total-recall/plugins/mesh/DESIGN.md +35 -0
  184. package/scaffold/.agent/skills/total-recall/plugins/mesh/README.md +4 -5
  185. package/scaffold/.agent/skills/total-recall/plugins/mesh/cli.mjs +9 -3
  186. package/scaffold/.agent/skills/total-recall/plugins/mesh/package-lock.json +7 -7
  187. package/scaffold/.agent/skills/total-recall/plugins/mesh/package.json +2 -1
  188. package/scaffold/.agent/skills/total-recall/plugins/mesh/plugin.json +37 -39
  189. package/scaffold/.agent/skills/total-recall/plugins/mesh/src/cli/mesh.mjs +5 -3
  190. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/active-device-dispatch.md +22 -0
  191. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/control-probe.md +25 -0
  192. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/control-server.md +22 -0
  193. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/credential-readiness.md +23 -0
  194. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/elected-leader.md +22 -0
  195. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/enrollment-key.md +22 -0
  196. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/file-receipt.md +25 -0
  197. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/fleet-execution.md +23 -0
  198. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/fleet-presence.md +23 -0
  199. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/interactive-ssh.md +22 -0
  200. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/local-enrollment.md +23 -0
  201. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/mesh-policy.md +23 -0
  202. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/network-atlas.md +25 -0
  203. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/node-roster.md +26 -0
  204. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/node-selection-proof.md +17 -0
  205. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/owner-observations.md +23 -0
  206. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/peer-path.md +23 -0
  207. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/pinned-leader.md +24 -0
  208. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/reachability-evidence-ladder.md +17 -0
  209. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/recorded-login.md +23 -0
  210. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/remote-execution.md +22 -0
  211. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/chunks/secret-grants.md +26 -0
  212. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/{card.js → home.js} +93 -22
  213. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/DESIGN.md +86 -0
  214. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/README.md +44 -9
  215. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/capability/BRICK.md +1 -1
  216. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/capability/index.mjs +18 -6
  217. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/cli.mjs +128 -24
  218. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package-lock.json +7 -7
  219. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/package.json +3 -2
  220. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/plugin.json +188 -34
  221. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/skills/meta-harness/SKILL.md +17 -3
  222. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/adoption.mjs +2 -2
  223. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/alerts.mjs +3 -3
  224. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/cascade.mjs +92 -18
  225. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/chat.mjs +80 -0
  226. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/control.mjs +145 -0
  227. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/coordinator.mjs +42 -21
  228. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch-request.mjs +4 -2
  229. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/dispatch.mjs +33 -9
  230. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/documentation.mjs +55 -11
  231. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/executor.mjs +26 -4
  232. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/gate-adapters/hermes.mjs +29 -1
  233. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/gate-adapters/index.mjs +1 -1
  234. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/included-usage.mjs +1 -1
  235. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/jobs.mjs +84 -0
  236. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/learner.mjs +3 -12
  237. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/maintenance.mjs +17 -0
  238. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/mcp-server.mjs +228 -0
  239. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/process-manager.mjs +25 -2
  240. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/reasoning.mjs +1 -1
  241. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/remote-operation.mjs +5 -1
  242. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/review.mjs +34 -3
  243. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/reviews.mjs +25 -0
  244. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/router.mjs +1 -1
  245. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/claude.mjs +319 -0
  246. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/codex.mjs +387 -0
  247. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/result.mjs +67 -0
  248. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/resume.mjs +373 -0
  249. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session/run.mjs +223 -0
  250. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/session-jobs.mjs +72 -0
  251. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/setup.mjs +6 -3
  252. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/termination.mjs +16 -12
  253. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/threads.mjs +32 -1
  254. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/usage-queue.mjs +1 -1
  255. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/verify-ssss.mjs +3 -3
  256. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worker.mjs +285 -40
  257. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/src/worktree.mjs +76 -9
  258. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/adapter-docs-freshness.md +16 -0
  259. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/chat-handoff.md +26 -0
  260. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/fleet-maintenance.md +21 -0
  261. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/harness-inventory.md +21 -0
  262. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/included-access.md +18 -0
  263. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/included-usage-verification.md +15 -0
  264. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/independent-review.md +17 -0
  265. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/managed-execution.md +20 -0
  266. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/official-documentation.md +18 -0
  267. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/quota-recovery.md +21 -0
  268. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/review-routing-decision.md +16 -0
  269. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/route-work.md +18 -0
  270. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/routing-evidence.md +18 -0
  271. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/chunks/run-ledger.md +18 -0
  272. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/home.js +198 -0
  273. package/scaffold/.agent/skills/total-recall/plugins/openwiki/DESIGN.md +75 -0
  274. package/scaffold/.agent/skills/total-recall/plugins/openwiki/README.md +2 -0
  275. package/scaffold/.agent/skills/total-recall/plugins/openwiki/cli.mjs +64 -32
  276. package/scaffold/.agent/skills/total-recall/plugins/openwiki/package-lock.json +7 -7
  277. package/scaffold/.agent/skills/total-recall/plugins/openwiki/package.json +2 -1
  278. package/scaffold/.agent/skills/total-recall/plugins/openwiki/plugin.json +10 -44
  279. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/generate.mjs +5 -4
  280. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/graph.mjs +3 -4
  281. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/ingest.mjs +23 -18
  282. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/mesh-vaults.mjs +8 -3
  283. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh-diagnostics.mjs +44 -0
  284. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/refresh.mjs +123 -113
  285. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/search.mjs +3 -5
  286. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/token.mjs +21 -47
  287. package/scaffold/.agent/skills/total-recall/plugins/openwiki/src/upstream-watcher.mjs +17 -6
  288. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/auto-refresh.md +18 -0
  289. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/bootstrap-pages.md +18 -0
  290. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/generate-wiki.md +21 -0
  291. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/generator-settings.md +18 -0
  292. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/host-probe.md +18 -0
  293. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/ingest-preview.md +18 -0
  294. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/link-hygiene.md +21 -0
  295. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/link-topology.md +19 -0
  296. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/passage-search.md +19 -0
  297. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/propagation-plan.md +18 -0
  298. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/provider-credentials.md +18 -0
  299. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/refresh-report.md +18 -0
  300. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/task-evidence.md +22 -0
  301. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/upstream-record.md +18 -0
  302. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/watch-upstream.md +18 -0
  303. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/chunks/wiki-atlas.md +19 -0
  304. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/panel.js +261 -513
  305. package/scaffold/.agent/skills/total-recall/plugins/security/DESIGN.md +84 -0
  306. package/scaffold/.agent/skills/total-recall/plugins/security/README.md +4 -2
  307. package/scaffold/.agent/skills/total-recall/plugins/security/cli.mjs +7 -19
  308. package/scaffold/.agent/skills/total-recall/plugins/security/package-lock.json +7 -7
  309. package/scaffold/.agent/skills/total-recall/plugins/security/package.json +2 -3
  310. package/scaffold/.agent/skills/total-recall/plugins/security/plugin.json +19 -52
  311. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/device-evidence.md +21 -0
  312. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/evidence-desk.md +18 -0
  313. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/guided-device-review.md +17 -0
  314. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/host-and-network.md +21 -0
  315. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/https-headers.md +17 -0
  316. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/mesh-coverage.md +18 -0
  317. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/private-security-tools.md +16 -0
  318. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/single-origin-header-check.md +17 -0
  319. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/source-review.md +21 -0
  320. package/scaffold/.agent/skills/total-recall/plugins/security/ui/chunks/ssh-permission-plan.md +17 -0
  321. package/scaffold/.agent/skills/total-recall/plugins/security/ui/home.js +283 -0
  322. package/scaffold/.agent/skills/total-recall/plugins/ssss/DESIGN.md +93 -0
  323. package/scaffold/.agent/skills/total-recall/plugins/ssss/package-lock.json +2 -2
  324. package/scaffold/.agent/skills/total-recall/plugins/ssss/package.json +2 -1
  325. package/scaffold/.agent/skills/total-recall/plugins/ssss/plugin.json +5 -3
  326. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/conformance.md +26 -0
  327. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/registry.md +37 -0
  328. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/repair.md +42 -0
  329. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/scaffold.md +33 -0
  330. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/status.md +43 -0
  331. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/validate.md +34 -0
  332. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/validation-diagnostics.md +17 -0
  333. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/chunks/workspace-registry-preflight.md +17 -0
  334. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/home.js +348 -0
  335. package/scaffold/.agent/skills/total-recall/references/operations.md +3 -1
  336. package/src/cli/agent.mjs +1 -1
  337. package/src/cli/api.mjs +3 -3
  338. package/src/cli/brief.mjs +3 -0
  339. package/src/cli/command.mjs +41 -2
  340. package/src/cli/config.mjs +16 -0
  341. package/src/cli/connect.mjs +2 -7
  342. package/src/cli/dream.mjs +93 -69
  343. package/src/cli/harness.mjs +4 -4
  344. package/src/cli/help.mjs +1 -1
  345. package/src/cli/init.mjs +0 -25
  346. package/src/cli/lessons.mjs +51 -0
  347. package/src/cli/memory-plugin.mjs +1 -1
  348. package/src/cli/plugin/chunks.mjs +145 -0
  349. package/src/cli/plugin/copies.mjs +64 -14
  350. package/src/cli/plugin/create.mjs +30 -59
  351. package/src/cli/plugin/index.mjs +31 -16
  352. package/src/cli/plugin/install.mjs +10 -15
  353. package/src/cli/plugin/remove.mjs +1 -1
  354. package/src/cli/plugin/search.mjs +2 -2
  355. package/src/cli/preflight.mjs +19 -6
  356. package/src/cli/proposals.mjs +1 -1
  357. package/src/cli/recall.mjs +66 -23
  358. package/src/cli/remember.mjs +3 -14
  359. package/src/cli/server.mjs +18 -0
  360. package/src/cli/setup.mjs +2 -9
  361. package/src/cli/start.mjs +1 -0
  362. package/src/cli/startup.mjs +19 -0
  363. package/src/cli/task.mjs +9 -2
  364. package/src/cli/update.mjs +6 -2
  365. package/src/core/access-ledger.mjs +78 -0
  366. package/src/core/agent-manager.mjs +2 -2
  367. package/src/core/app-deploy/design-tokens.mjs +14 -9
  368. package/src/core/app-deploy/ui-elements.mjs +1 -1
  369. package/src/core/brain-locate.mjs +15 -0
  370. package/src/core/brain-registry.mjs +5 -0
  371. package/src/core/brain-updates.mjs +35 -11
  372. package/src/core/claude-hooks.mjs +3 -1
  373. package/src/core/cleanup-task.mjs +15 -0
  374. package/src/core/cli-commands.mjs +2 -0
  375. package/src/core/cli-maintenance.mjs +4 -1
  376. package/src/core/cli-semantic-index.mjs +23 -3
  377. package/src/core/context-compiler.mjs +20 -0
  378. package/src/core/daemon-control.mjs +5 -1
  379. package/src/core/daemon-loop.mjs +39 -62
  380. package/src/core/dashboard-bundle.mjs +261 -0
  381. package/src/core/default-plugins.mjs +1 -1
  382. package/src/core/dream.mjs +33 -105
  383. package/src/core/ensure-dependencies.mjs +152 -0
  384. package/src/core/fast-recall.mjs +2 -2
  385. package/src/core/field-evaluation.mjs +23 -0
  386. package/src/core/gate-mode.mjs +1 -1
  387. package/src/core/harness-hooks.mjs +14 -2
  388. package/src/core/lesson-hooks.mjs +74 -0
  389. package/src/core/lesson-memory.mjs +24 -0
  390. package/src/core/lesson-sessions.mjs +52 -0
  391. package/src/core/lessons.mjs +96 -0
  392. package/src/core/memory-brain.mjs +30 -8
  393. package/src/core/meta-harness.mjs +2 -2
  394. package/src/core/optimizer.mjs +66 -165
  395. package/src/core/plugin-activation.mjs +63 -20
  396. package/src/core/plugin-contracts/{card.mjs → manifest.mjs} +26 -57
  397. package/src/core/plugin-contracts/startup-check.mjs +49 -0
  398. package/src/core/plugin-contracts/ui.mjs +9 -3
  399. package/src/core/plugin-distribution.mjs +6 -6
  400. package/src/core/plugin-lifecycle.mjs +58 -0
  401. package/src/core/plugin-loader.mjs +21 -8
  402. package/src/core/plugin-runner.mjs +21 -10
  403. package/src/core/plugin-runtime.mjs +40 -1
  404. package/src/core/plugin-startup-checks.mjs +44 -0
  405. package/src/core/plugin-state.mjs +19 -5
  406. package/src/core/plugin-store.mjs +64 -33
  407. package/src/core/post-mortem.mjs +52 -36
  408. package/src/core/preflight-gate.mjs +23 -2
  409. package/src/core/project-id.mjs +15 -5
  410. package/src/core/proposal-applier.mjs +31 -2
  411. package/src/core/repo-sync.mjs +4 -6
  412. package/src/core/required-plugins.mjs +57 -10
  413. package/src/core/rule-length.mjs +23 -0
  414. package/src/core/runtime.mjs +1 -1
  415. package/src/core/scheduler.mjs +35 -43
  416. package/src/core/schema.mjs +3 -2
  417. package/src/core/search.mjs +4 -3
  418. package/src/core/server-service.mjs +148 -0
  419. package/src/core/session-watcher.mjs +19 -1
  420. package/src/core/skill-gap.mjs +16 -0
  421. package/src/core/ssss-kernel-bridge.mjs +32 -4
  422. package/src/core/ssss-operation-service.mjs +1 -0
  423. package/src/core/startup-health.mjs +34 -4
  424. package/src/core/surface.mjs +65 -54
  425. package/src/core/task-executors.mjs +54 -106
  426. package/src/core/testing/plugin-fixture.mjs +22 -21
  427. package/src/core/throttled-fetch.mjs +25 -18
  428. package/src/core/ui-chunk-choice.mjs +77 -0
  429. package/src/core/ui-chunk.registry.json +23 -0
  430. package/src/core/ui-chunks.mjs +434 -0
  431. package/src/core/validated-write.mjs +1 -0
  432. package/src/core/vault-cache.mjs +58 -59
  433. package/src/core/vector-field.mjs +134 -192
  434. package/src/core/workspace-compositions.mjs +151 -0
  435. package/src/core/workspace-drawers.mjs +79 -0
  436. package/src/server/api.mjs +4 -27
  437. package/src/server/index.mjs +28 -21
  438. package/src/server/invoke-core-child.mjs +24 -0
  439. package/src/server/invoke-core-operations.mjs +102 -0
  440. package/src/server/memory-events.mjs +31 -0
  441. package/src/server/plugin-brain-targets.mjs +89 -0
  442. package/src/server/rest.mjs +2 -0
  443. package/src/server/route-inventory.mjs +3 -2
  444. package/src/server/route-manifest.json +47 -55
  445. package/src/server/routes/_shared.mjs +7 -14
  446. package/src/server/routes/brains.mjs +29 -62
  447. package/src/server/routes/context.mjs +0 -41
  448. package/src/server/routes/dashboard.mjs +26 -0
  449. package/src/server/routes/invoke.mjs +26 -1
  450. package/src/server/routes/plugins.mjs +154 -45
  451. package/src/server/routes/ssss.mjs +0 -169
  452. package/src/server/routes/system.mjs +0 -15
  453. package/src/server/routes/tasks.mjs +0 -26
  454. package/src/server/routes/ui-chunks.mjs +192 -0
  455. package/src/server/routes/vault.mjs +2 -23
  456. package/frontend/dist/assets/index-DD4qONvH.js +0 -5607
  457. package/frontend/dist/assets/index-DtwsDyFM.css +0 -1
  458. package/frontend/src/components/plugins/card/CardEngine.tsx +0 -108
  459. package/frontend/src/components/plugins/card/CardScenes.tsx +0 -103
  460. package/frontend/src/components/plugins/card/ExecutionPicker.tsx +0 -64
  461. package/frontend/src/components/plugins/card/args.ts +0 -28
  462. package/frontend/src/components/plugins/card/card.css +0 -32
  463. package/frontend/src/components/plugins/card/cli-line.ts +0 -13
  464. package/frontend/src/components/plugins/card/contract.ts +0 -91
  465. package/frontend/src/components/plugins/card/format.ts +0 -49
  466. package/frontend/src/components/plugins/card/runner-context.ts +0 -11
  467. package/frontend/src/components/plugins/card/runner.tsx +0 -43
  468. package/frontend/src/components/plugins/card/theme.ts +0 -35
  469. package/frontend/src/components/plugins/card/use-source.ts +0 -22
  470. package/frontend/src/components/plugins/card/widgets.tsx +0 -94
  471. package/frontend/src/components/plugins/workspace/WorkspaceHost.tsx +0 -23
  472. package/frontend/src/pages/PluginsPage.tsx +0 -1719
  473. package/scaffold/.agent/skills/plugin/evals/cases/04-card-collects-credential.mjs +0 -47
  474. package/scaffold/.agent/skills/plugin/prompts/06-card.md +0 -46
  475. package/scaffold/.agent/skills/plugin/references/card.md +0 -90
  476. package/scaffold/.agent/skills/plugin/subagents/card-designer.md +0 -60
  477. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/DESIGN.md +0 -67
  478. package/scaffold/.agent/skills/total-recall/plugins/auth/ui/card.js +0 -1179
  479. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/DESIGN.md +0 -32
  480. package/scaffold/.agent/skills/total-recall/plugins/code-quality/ui/card.js +0 -588
  481. package/scaffold/.agent/skills/total-recall/plugins/composable-cli/ui/card.js +0 -575
  482. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/DESIGN.md +0 -32
  483. package/scaffold/.agent/skills/total-recall/plugins/embeddings/ui/card.js +0 -482
  484. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/README.md +0 -53
  485. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/plugin.json +0 -129
  486. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/ui/DESIGN.md +0 -100
  487. package/scaffold/.agent/skills/total-recall/plugins/git-sentinel/ui/card.js +0 -637
  488. package/scaffold/.agent/skills/total-recall/plugins/mesh/ui/DESIGN.md +0 -217
  489. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/DESIGN.md +0 -32
  490. package/scaffold/.agent/skills/total-recall/plugins/meta-harness/ui/card.js +0 -1276
  491. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/DESIGN.md +0 -45
  492. package/scaffold/.agent/skills/total-recall/plugins/openwiki/ui/card.js +0 -1401
  493. package/scaffold/.agent/skills/total-recall/plugins/security/scripts/build-ui.mjs +0 -4
  494. package/scaffold/.agent/skills/total-recall/plugins/security/ui/DESIGN.md +0 -41
  495. package/scaffold/.agent/skills/total-recall/plugins/security/ui/card.js +0 -396
  496. package/scaffold/.agent/skills/total-recall/plugins/security/ui/panel.js +0 -98
  497. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/DESIGN.md +0 -15
  498. package/scaffold/.agent/skills/total-recall/plugins/ssss/ui/card.js +0 -182
  499. package/src/core/append-log.mjs +0 -131
  500. package/src/core/plugin-tasks.mjs +0 -173
  501. package/templates/onboarding-interview.md +0 -82
  502. /package/scaffold/.agent/skills/total-recall/plugins/{git-sentinel → git}/LICENSE +0 -0
package/src/cli/dream.mjs CHANGED
@@ -1,84 +1,108 @@
1
- /**
2
- * total-recall dream
3
- *
4
- * Manually trigger a single dream cycle (Light → REM → Deep Sleep).
5
- *
6
- * Usage:
7
- * npx total-recall dream [options]
8
- *
9
- * Options:
10
- * --vault <path> Override vault directory (default: ~/.agent/memory-vault)
11
- * --help Show this help
12
- */
13
-
1
+ /** Run one dream cycle per selected brain. Scheduling belongs to automations. */
2
+ import fs from 'node:fs';
14
3
  import path from 'node:path';
15
- import { fileURLToPath } from 'node:url';
16
- import { resolveAgentDir, resolveBrainDir, parseLayerFlag, resolveSurfaceDir } from './agent-dir.mjs';
17
-
18
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
4
+ import { resolveAgentDir, resolveBrainDir, resolveSurfaceDir, getGlobalBrainDir, getGlobalAgentDir } from './agent-dir.mjs';
5
+ import { listUpdateRoots } from '../core/package-auto-update.mjs';
19
6
 
20
- function parseArgs(args) {
21
- const opts = { vault: null, help: false };
7
+ export function parseDreamArgs(args) {
8
+ const opts = { layer: 'global', allBrains: false, dryRun: false, json: false };
9
+ let explicitLayer;
22
10
  for (let i = 0; i < args.length; i++) {
23
- switch (args[i]) {
24
- case '--vault': opts.vault = args[++i]; break;
25
- case '--help': case '-h': opts.help = true; break;
26
- }
11
+ const arg = args[i];
12
+ if (arg === '--all-brains') opts.allBrains = true;
13
+ else if (arg === '--dry-run') opts.dryRun = true;
14
+ else if (arg === '--json') opts.json = true;
15
+ else if (arg === '--help' || arg === '-h') opts.help = true;
16
+ else if (arg === '--global' || arg === '--project') {
17
+ if (explicitLayer && explicitLayer !== arg) throw new Error('Choose --global or --project.');
18
+ explicitLayer = arg;
19
+ opts.layer = arg.slice(2);
20
+ } else if (arg === '--vault') {
21
+ if (!args[i + 1] || args[i + 1].startsWith('-')) throw new Error('--vault requires a path.');
22
+ opts.vault = path.resolve(args[++i]);
23
+ } else throw new Error(`Unknown dream option: ${arg}`);
27
24
  }
25
+ if (opts.allBrains && (opts.vault || explicitLayer)) throw new Error('--all-brains cannot be combined with --vault, --global or --project.');
28
26
  return opts;
29
27
  }
30
28
 
31
- function printHelp() {
32
- console.log(`
33
- total-recall dream — Manually trigger a dream cycle
29
+ function target(brainDir, agentDir, surfaceDir, root) {
30
+ return { root, brainDir, vaultDir: path.join(brainDir, 'memory-vault'),
31
+ derivedDir: path.join(brainDir, 'memory-derived'), skillsDir: path.join(agentDir, 'skills'),
32
+ conflictsDir: path.join(brainDir, 'memory-inbox', 'conflicts'),
33
+ instructionsFile: path.join(surfaceDir, 'INSTRUCTIONS.md') };
34
+ }
34
35
 
35
- The dream cycle runs three phases:
36
- 1. Light Sleep — Scan vault for recent modifications
37
- 2. REM — Score, conflict-check, and promote/decay candidates
38
- 3. Deep Sleep — Recompile the surface (indexes + INSTRUCTIONS.md)
36
+ export function discoverDreamBrains({ brainDir = getGlobalBrainDir(), agentDir = getGlobalAgentDir(), roots } = {}) {
37
+ const brains = [target(brainDir, agentDir, agentDir, agentDir)];
38
+ const seen = new Set([fs.existsSync(brainDir) ? fs.realpathSync(brainDir) : path.resolve(brainDir)]);
39
+ for (const { root } of listUpdateRoots({ brainDir, roots })) {
40
+ // Fleet selection is explicit. AGENT_DIR must not redirect project brains.
41
+ const projectAgent = ['.agent', '.agents'].map(name => path.join(root, name))
42
+ .find(dir => fs.existsSync(path.join(dir, 'skills/total-recall/memory-vault'))
43
+ || fs.existsSync(path.join(dir, 'skills/total-recall/SKILL.md')));
44
+ if (!projectAgent) continue;
45
+ const projectBrain = path.join(projectAgent, 'skills/total-recall');
46
+ const real = fs.realpathSync(projectBrain);
47
+ if (seen.has(real)) continue;
48
+ seen.add(real);
49
+ brains.push(target(projectBrain, projectAgent, root, root));
50
+ }
51
+ return brains;
52
+ }
39
53
 
40
- Usage: total-recall dream [options]
54
+ async function previewDecay({ vaultDir, derivedDir }) {
55
+ const [{ loadNodes }, { readAccess }, { decayCandidates }] = await Promise.all([
56
+ import('../core/vault.mjs'), import('../core/access-ledger.mjs'), import('../core/optimizer.mjs'),
57
+ ]);
58
+ return decayCandidates(loadNodes(vaultDir), readAccess(derivedDir)).map(node => node.slug);
59
+ }
41
60
 
42
- Options:
43
- --vault <path> Override vault directory
44
- --global Dream the global brain (default)
45
- --project Dream the project brain for the current repo
46
- --help, -h Show this help
47
- `);
61
+ function printHelp() {
62
+ console.log(`Usage: total-recall dream [--global | --project | --all-brains] [--vault <path>] [--dry-run] [--json]
63
+ Dream consolidates memory and runs phase 4 decay.
64
+ --all-brains Run the global brain and registered project brains on this node, one at a time.
65
+ --dry-run List brains and decay candidates without changes or runtime calls.
66
+ --json Print an array of per-brain results.
67
+ --help, -h Show this help.`);
48
68
  }
49
69
 
50
- export default async function dream(args) {
51
- const { layer, remainingArgs } = parseLayerFlag(args);
52
- const effectiveLayer = layer === 'auto' ? 'global' : layer;
53
- const opts = parseArgs(remainingArgs);
70
+ export default async function dream(args = [], dependencies = {}) {
71
+ let opts;
72
+ try { opts = parseDreamArgs(args); }
73
+ catch (error) { console.error(error.message); process.exitCode = 2; return; }
54
74
  if (opts.help) { printHelp(); return; }
55
-
56
- const agentDir = resolveAgentDir(effectiveLayer);
57
- const brainDir = resolveBrainDir(effectiveLayer);
58
- const vaultDir = opts.vault || path.join(brainDir, 'memory-vault');
59
- const skillsDir = path.join(agentDir, 'skills');
60
- const derivedDir = path.join(brainDir, 'memory-derived');
61
- const conflictsDir = path.join(brainDir, 'memory-inbox', 'conflicts');
62
- const instructionsFile = path.join(resolveSurfaceDir(effectiveLayer), 'INSTRUCTIONS.md');
63
-
64
- console.error('\n šŸŒ™ Starting dream cycle...\n');
65
- const startTime = Date.now();
66
-
75
+ const results = [];
67
76
  try {
68
- const { runDreamCycle } = await import('../core/dream.mjs');
69
- const result = await runDreamCycle({
70
- vaultDir,
71
- skillsDir,
72
- derivedDir,
73
- conflictsDir,
74
- instructionsFile,
75
- });
76
-
77
- const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
78
- console.error(`\n āœ… Dream cycle complete (${elapsed}s) — status: ${result.status}`);
79
- } catch (err) {
80
- console.error(`\n āŒ Dream cycle failed: ${err.message}`);
81
- console.error(err.stack);
82
- process.exit(1);
83
- }
77
+ const brains = opts.allBrains ? (dependencies.discover || discoverDreamBrains)() : [
78
+ target(resolveBrainDir(opts.layer), resolveAgentDir(opts.layer), resolveSurfaceDir(opts.layer), resolveSurfaceDir(opts.layer)),
79
+ ];
80
+ if (opts.vault) {
81
+ brains[0].vaultDir = opts.vault;
82
+ brains[0].brainDir = path.dirname(opts.vault);
83
+ brains[0].derivedDir = path.join(brains[0].brainDir, 'memory-derived');
84
+ brains[0].conflictsDir = path.join(brains[0].brainDir, 'memory-inbox', 'conflicts');
85
+ }
86
+ const run = opts.dryRun ? null : (dependencies.run || (await import('../core/dream.mjs')).runDreamCycle);
87
+ for (const brain of brains) {
88
+ let row;
89
+ try {
90
+ if (!fs.existsSync(brain.vaultDir)) throw new Error(`Vault not found: ${brain.vaultDir}`);
91
+ const result = opts.dryRun
92
+ ? { status: 'dry_run', decay_candidates: await (dependencies.preview || previewDecay)(brain) }
93
+ : await run(brain);
94
+ row = { ...brain, ...result };
95
+ } catch (error) { row = { ...brain, status: 'failed', error: error.message }; }
96
+ results.push(row);
97
+ if (!opts.json) {
98
+ console.log(`${row.brainDir}: ${row.status}${row.error ? ` — ${row.error}` : ''}`);
99
+ if (row.decay_candidates) console.log(` Decay candidates: ${row.decay_candidates.join(', ') || 'none'}`);
100
+ for (const error of row.errors || []) console.error(` ${error}`);
101
+ }
102
+ }
103
+ } catch (error) { results.push({ status: 'failed', error: error.message }); }
104
+ if (opts.json) console.log(JSON.stringify(results, null, 2));
105
+ else if (results.length === 1 && results[0].error && !results[0].brainDir) console.error(results[0].error);
106
+ if (results.some(row => !['success', 'dry_run'].includes(row.status))) process.exitCode = 1;
107
+ return results;
84
108
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /** Legacy command door. Native harness behavior is owned by the Meta Harness plugin. */
2
+ /** Legacy command door. Native harness behavior is owned by the Metaharness plugin. */
3
3
  import { checkAnyReceipt, findRoot, ACK_COMMAND } from '../core/preflight-receipt.mjs';
4
4
  import path from 'node:path';
5
5
 
@@ -11,9 +11,9 @@ async function callPlugin(subcommand, args, options = {}) {
11
11
  const result = await runPluginCommand(plugin, { subcommand, args: [...args, '--json'], timeoutMs: 600000, ...options });
12
12
  let data;
13
13
  try { data = JSON.parse(result.output); }
14
- catch { throw new Error(`Meta Harness returned invalid JSON for ${subcommand}`); }
14
+ catch { throw new Error(`Metaharness returned invalid JSON for ${subcommand}`); }
15
15
  if (!result.ok || data?.ok === false) {
16
- const error = new Error(data?.error || `Meta Harness ${subcommand} failed`);
16
+ const error = new Error(data?.error || `Metaharness ${subcommand} failed`);
17
17
  error.result = data;
18
18
  throw error;
19
19
  }
@@ -32,7 +32,7 @@ export async function run(argv = []) {
32
32
  const asJson = args.includes('--json');
33
33
  try {
34
34
  if (args.includes('--help') || args.includes('-h') || args[0] === 'help') {
35
- console.log('Usage: total-recall harness list|usage [--node ID] [--json] | dispatch <id> <task> [--node ID --cwd /remote/workspace] [--write] [--allow-unknown-auth] [--json] | council <task> [--allow-unknown-auth] [--json]. Harness operations delegate to the Meta Harness plugin.');
35
+ console.log('Usage: total-recall harness list|usage [--node ID] [--json] | dispatch <id> <task> [--node ID --cwd /remote/workspace] [--write] [--allow-unknown-auth] [--json] | council <task> [--allow-unknown-auth] [--json]. Harness operations delegate to the Metaharness plugin.');
36
36
  return;
37
37
  }
38
38
  const command = args[0] || 'list', positional = [];
package/src/cli/help.mjs CHANGED
@@ -19,7 +19,7 @@ const ROOT = path.join(__dirname, '..', '..');
19
19
  export default async function run(argv) {
20
20
  const args = argv || [];
21
21
  const requestedTopic = args.find(arg => !arg.startsWith('-'))?.toLowerCase() || null;
22
- const topic = ({ server: 'start', 'startup-check': 'startup' })[requestedTopic] || requestedTopic;
22
+ const topic = ({ 'startup-check': 'startup' })[requestedTopic] || requestedTopic;
23
23
  const isJson = args.includes('--json') || args.includes('-j');
24
24
 
25
25
  const cliRefPath = path.join(ROOT, 'docs', 'reference', 'cli-reference.md');
package/src/cli/init.mjs CHANGED
@@ -407,31 +407,6 @@ export default async function init(args) {
407
407
  logOk('Default memory vault seeded');
408
408
  }
409
409
 
410
- // ── Step 3.5: Seed the onboarding interview task ──
411
- logStep('3.5/4', 'Seeding onboarding interview into scheduler queue');
412
-
413
- const queueDir = path.join(brainDir, 'scheduler', 'queue');
414
- const interviewDest = path.join(queueDir, 'onboarding-interview.md');
415
- const interviewSrc = path.join(ROOT, 'templates', 'onboarding-interview.md');
416
-
417
- if (!fs.existsSync(interviewDest)) {
418
- if (!opts.dryRun) {
419
- fs.mkdirSync(queueDir, { recursive: true });
420
- if (fs.existsSync(interviewSrc)) {
421
- const now = new Date().toISOString();
422
- const content = fs.readFileSync(interviewSrc, 'utf8').replace(/\{\{CREATED_AT\}\}/g, now);
423
- fs.writeFileSync(interviewDest, content);
424
- logOk('Onboarding interview task queued — agent will conduct it on first chat');
425
- } else {
426
- logWarn('Interview template not found — skipping');
427
- }
428
- } else {
429
- log(` Would write ${path.relative(cwd, interviewDest)}`);
430
- }
431
- } else {
432
- logSkip('onboarding-interview.md already in queue');
433
- }
434
-
435
410
  // Seed non-credential settings. Auth owns password and signing state.
436
411
  if (!opts.dryRun) {
437
412
  const configDir = path.join(brainDir, 'config');
@@ -0,0 +1,51 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import crypto from 'node:crypto';
4
+ import { atomicWrite } from '../core/vault.mjs';
5
+ import { parseLayerFlag, resolveBrainDir } from './agent-dir.mjs';
6
+ import { tickLessons, enqueueSessionReviews } from '../core/lessons.mjs';
7
+
8
+ export default async function lessons(args) {
9
+ const { layer, remainingArgs } = parseLayerFlag(args);
10
+ const [command, ...flags] = remainingArgs;
11
+ if (!command || flags.includes('--help') || ['--help', '-h'].includes(command)) {
12
+ console.log('Usage: total-recall lessons tick|session-end|scan [--session ID] [--transcript PATH] [--harness ID] [--interval N] [--hold]\nHooks pass JSON on stdin. Stop queues completed turn ranges; session-end queues the remaining turns. scan reviews locally ingested sessions.');
13
+ return;
14
+ }
15
+ if (!['tick', 'session-end', 'scan'].includes(command)) throw new Error(`Unknown lessons command: ${command}`);
16
+ const opts = {};
17
+ for (let i = 0; i < flags.length; i++) {
18
+ const flag = flags[i];
19
+ if (flag === '--hold') { opts.hold = true; continue; }
20
+ if (!['--session', '--transcript', '--harness', '--interval', '--event'].includes(flag) || !flags[i + 1]) throw new Error(`Invalid lessons option: ${flag}`);
21
+ opts[flag.slice(2)] = flags[++i];
22
+ }
23
+ const brainDir = resolveBrainDir(layer);
24
+ if (command === 'scan') {
25
+ console.log(JSON.stringify(enqueueSessionReviews({ brainDir, interval: opts.interval ? Number(opts.interval) : undefined, hold: opts.hold })));
26
+ return;
27
+ }
28
+ let input = {};
29
+ if (!process.stdin.isTTY && !opts.session) {
30
+ const raw = fs.readFileSync(0, 'utf8');
31
+ if (raw.trim()) input = JSON.parse(raw);
32
+ }
33
+ const history = input.entries || input.conversation_history || input.extra?.conversation_history;
34
+ if (!opts.transcript && !input.transcript_path && Array.isArray(history)) {
35
+ const id = input.session_id || input.sessionId;
36
+ if (!id) throw new Error('Lesson hook history requires a session id');
37
+ const key = crypto.createHash('sha256').update(`${opts.harness || 'unknown'}:${id}`).digest('hex').slice(0, 12);
38
+ const dir = path.join(brainDir, 'sessions');
39
+ fs.mkdirSync(dir, { recursive: true });
40
+ opts.transcript = path.join(dir, `${key}.jsonl`);
41
+ atomicWrite(opts.transcript, history.map(entry => JSON.stringify(entry)).join('\n') + '\n');
42
+ }
43
+ const result = tickLessons({ brainDir, sessionId: opts.session || input.session_id || input.sessionId || input.conversation_id,
44
+ transcriptPath: opts.transcript || input.transcript_path || input.transcriptPath,
45
+ harness: opts.harness || 'unknown', turnId: input.turn_id || input.prompt_id,
46
+ event: command === 'session-end' ? 'SessionEnd' : (opts.event || input.hook_event_name || input.event || 'Stop'),
47
+ interval: opts.interval ? Number(opts.interval) : undefined, hold: opts.hold });
48
+ // Hook JSON must not ask the harness to continue, stop, or approve a tool.
49
+ if (opts.session) console.log(JSON.stringify(result));
50
+ else console.log('{}');
51
+ }
@@ -26,6 +26,6 @@ export default async function plugin(args = []) {
26
26
  const result = await uninstallPlugin(value, { projectRoot: process.cwd(), global: global ? true : undefined });
27
27
  console.log(JSON.stringify(result, null, 2));
28
28
  } else if (['help', '--help', '-h'].includes(action)) {
29
- console.log('Usage: total-recall plugin list|info <id>|install <directory-or-git-url>|remove <id> [--global] [--link]');
29
+ console.log('Usage: total-recall plugin list|info <id>|install <directory-or-git-url>|remove <id> [--link]');
30
30
  } else throw new Error(`Unsupported plugin action '${action}'`);
31
31
  }
@@ -0,0 +1,145 @@
1
+ import { parseArgs } from 'node:util';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { auditUiChunkCoverage, getUiChunk, searchUiChunks, uiChunkRegistryPath, validateUiChunkFile } from '../../core/ui-chunks.mjs';
5
+ import { chooseUiChunk } from '../../core/ui-chunk-choice.mjs';
6
+ import { callApi } from '../api.mjs';
7
+
8
+ const help = [
9
+ 'Usage: total-recall plugin chunks [query] [--plugin ID] [--surface page|left|right|bottom] [--limit N] [--decision|--workspace] [--brain ID] [--json]',
10
+ ' total-recall plugin chunks get <plugin:id> [--surface SURFACE] [--workspace] [--brain ID] [--json]',
11
+ ' total-recall plugin chunks validate <file> [--plugin-dir DIR] [--json]',
12
+ ' total-recall plugin chunks registry',
13
+ ' total-recall plugin chunks coverage [--plugin ID] [--json]',
14
+ ' total-recall plugin chunks add <id.md> --plugin ID [--brain ID] [--json]',
15
+ ' total-recall plugin chunks page <id> --brain ID [--json]',
16
+ ' total-recall plugin chunks page <id> <plugin:block>... --brain ID (--title TITLE | --revision VERSION) [--json]',
17
+ '',
18
+ 'Use --decision with a concise, non-sensitive query to request a ranked choice through the configured Decision plugin.',
19
+ 'Search and validation run locally by default. Decision requests send only the query and up to 20 eligible metadata records.',
20
+ 'Agents use total-recall decision compose to publish a Jev-selected page.',
21
+ ].join('\n');
22
+
23
+ export async function runPluginChunks(args) {
24
+ const asJson = args.includes('--json');
25
+ try {
26
+ const { values, positionals } = parseArgs({
27
+ args,
28
+ allowPositionals: true,
29
+ options: {
30
+ json: { type: 'boolean' },
31
+ help: { type: 'boolean', short: 'h' },
32
+ decision: { type: 'boolean' },
33
+ workspace: { type: 'boolean' },
34
+ brain: { type: 'string' },
35
+ surface: { type: 'string' },
36
+ plugin: { type: 'string' },
37
+ limit: { type: 'string' },
38
+ 'plugin-dir': { type: 'string' },
39
+ title: { type: 'string' },
40
+ revision: { type: 'string' },
41
+ },
42
+ });
43
+ if (values.help) return console.log(help);
44
+
45
+ const [verb, target, ...extra] = positionals;
46
+ if (verb === 'page') {
47
+ const { brain, title, revision } = values;
48
+ if (!target || !brain?.trim() || values.plugin || values.workspace || values.decision || values.surface || values.limit || values['plugin-dir']) throw new Error(help);
49
+ const writing = extra.length > 0;
50
+ const create = typeof title === 'string' && title.trim() && revision === undefined;
51
+ const edit = typeof revision === 'string' && revision.trim() && title === undefined;
52
+ if (writing ? !create && !edit : title !== undefined || revision !== undefined) throw new Error(help);
53
+ const collection = '/api/workspace/pages';
54
+ const detail = collection + '/' + encodeURIComponent(target);
55
+ const response = !writing
56
+ ? await callApi('GET', detail, { query: { brain } })
57
+ : await callApi(edit ? 'PUT' : 'POST', edit ? detail : collection, {
58
+ data: JSON.stringify({ id: target, brainId: brain, title, revision, keys: extra }),
59
+ });
60
+ if (!response.ok) throw new Error(response.body?.error || 'Could not access the saved page.');
61
+ const page = response.body;
62
+ if (asJson) return console.log(JSON.stringify({ ok: true, ...page }));
63
+ console.log(page.path || `${page.title} (${page.version})`);
64
+ for (const chunk of page.chunks) console.log(chunk.key);
65
+ return;
66
+ }
67
+ if (values.title !== undefined || values.revision !== undefined) throw new Error(help);
68
+ if (values.brain !== undefined && ((!values.workspace && verb !== 'add') || !values.brain.trim())) {
69
+ throw new Error('--brain requires a registered brain ID and --workspace, or an add operation.');
70
+ }
71
+ if (values.workspace && (values.decision || ['add', 'coverage', 'registry', 'validate'].includes(verb))) throw new Error(help);
72
+ if (verb === 'add') {
73
+ if (!target || !values.plugin || extra.length || values.decision || values.surface || values.limit || values['plugin-dir'] || path.extname(target) !== '.md') throw new Error(help);
74
+ const stat = fs.statSync(target);
75
+ if (!stat.isFile() || stat.size > 64 * 1024) throw new Error('Choose a Markdown block no larger than 64 KiB.');
76
+ const markdown = fs.readFileSync(target, 'utf8');
77
+ const { ok, body } = await callApi('POST', '/api/ui-chunks/pool', {
78
+ data: JSON.stringify({ plugin: values.plugin, id: path.basename(target, '.md'), markdown, brainId: values.brain }),
79
+ });
80
+ if (!ok) throw new Error(body?.error || 'The dashboard could not add the block.');
81
+ return console.log(asJson ? JSON.stringify({ ok, ...body }) : 'Added ' + body.chunk.key);
82
+ }
83
+ if (verb === 'coverage') {
84
+ if (target || values.decision || values.surface || values.limit || values['plugin-dir']) throw new Error(help);
85
+ const plugins = auditUiChunkCoverage({ plugin: values.plugin });
86
+ if (values.plugin && !plugins.length) throw new Error('Plugin is not installed.');
87
+ if (asJson) return console.log(JSON.stringify({ ok: true, plugins }));
88
+ for (const item of plugins) {
89
+ const bound = item.operations.total - item.operations.missing.length;
90
+ console.log(`${item.plugin}: ${item.pageBlocks} page blocks, ${bound}/${item.operations.total} operations, ${item.dataBindings.length} data bindings, design ${item.design || 'missing'}${item.partial ? ' (partial audit)' : ''}`);
91
+ }
92
+ return;
93
+ }
94
+ if (verb === 'registry') {
95
+ if (target || values.decision || values.surface || values.plugin || values.limit || values['plugin-dir']) throw new Error(help);
96
+ return console.log(asJson ? JSON.stringify({ ok: true, file: uiChunkRegistryPath }) : uiChunkRegistryPath);
97
+ }
98
+ if (verb === 'validate') {
99
+ if (!target || extra.length || values.decision || values.surface || values.plugin || values.limit) throw new Error(help);
100
+ const chunk = validateUiChunkFile(target, { pluginDir: values['plugin-dir'] });
101
+ return console.log(asJson ? JSON.stringify({ ok: true, chunk }) : 'Validated ' + chunk.key);
102
+ }
103
+ if (values['plugin-dir']) throw new Error('--plugin-dir is only available with validate.');
104
+ if (verb === 'get') {
105
+ if (!target || extra.length || values.decision || values.plugin || values.limit) throw new Error(help);
106
+ const [plugin, id, ...rest] = target.split(':');
107
+ if (!plugin || !id || rest.length) throw new Error('Specify a chunk as plugin:id.');
108
+ const query = values.surface ? { surface: values.surface } : {};
109
+ if (values.brain) query.brain = values.brain;
110
+ const chunk = values.workspace
111
+ ? (await callApi('GET', `/api/ui-chunks/${encodeURIComponent(plugin)}/${encodeURIComponent(id)}`, { query })).body?.chunk
112
+ : getUiChunk(plugin, id, { surface: values.surface });
113
+ if (!chunk) throw new Error('UI chunk unavailable.');
114
+ return console.log(asJson ? JSON.stringify({ ok: true, chunk }) : chunk.html);
115
+ }
116
+
117
+ const query = positionals.join(' ').trim();
118
+ const limit = values.limit === undefined ? undefined : Number(values.limit);
119
+ if (values.decision && !query) throw new Error('--decision requires an explicit query.');
120
+ let result;
121
+ if (values.workspace) {
122
+ const filters = Object.fromEntries(Object.entries({ plugin: values.plugin, surface: values.surface, q: query, limit, brain: values.brain }).filter(([, value]) => value !== undefined));
123
+ const response = await callApi('GET', '/api/ui-chunks', { query: filters });
124
+ if (!response.ok) throw new Error(response.body?.error || 'The dashboard could not read the workspace pool.');
125
+ result = response.body;
126
+ } else {
127
+ result = searchUiChunks({ plugin: values.plugin, surface: values.surface, query, limit });
128
+ }
129
+ if (values.decision) result.selection = await chooseUiChunk(result.chunks, query, values.surface);
130
+ if (asJson) return console.log(JSON.stringify({ ok: true, ...result }));
131
+ for (const chunk of result.chunks) console.log(chunk.key + ' ' + chunk.title + ' [' + chunk.surfaces.join(', ') + ']');
132
+ if (!result.chunks.length) console.log('No eligible UI chunks.');
133
+ for (const issue of result.diagnostics) {
134
+ console.error(issue.plugin + (issue.id ? ':' + issue.id : '') + ' ' + issue.message);
135
+ }
136
+ if (result.selection) {
137
+ const { key, source, reason } = result.selection;
138
+ console.log('Selection (' + source + '): ' + (key ?? 'none') + (reason ? ' (' + reason + ')' : ''));
139
+ }
140
+ } catch (error) {
141
+ process.exitCode = 1;
142
+ if (asJson) console.log(JSON.stringify({ ok: false, error: error.message }));
143
+ else console.error(error.message);
144
+ }
145
+ }
@@ -1,17 +1,21 @@
1
1
  /**
2
- * Audit and remove per-repository copies of the shared default plugins.
2
+ * Audit and remove plugin installs inside a repository.
3
3
  *
4
- * One shared plugin folder per machine is the design; copies inside repositories
5
- * are leftovers from an earlier release that put the nine defaults in every
6
- * brain. Only copies matching the bundled source can be deleted. The operator
7
- * can explicitly archive older differing copies to use the shared versions.
4
+ * Nothing is installed per repository: every plugin lives in the one shared
5
+ * folder and a repository only switches it on or off. Entries found in a
6
+ * repository are leftovers. Copies matching the bundled source are deleted;
7
+ * older differing copies can be archived on request; shadow links (to a plugin
8
+ * the shared folder installs, or any linked default) are removed as links only.
9
+ * A repository-only plugin is reported until it is installed in the shared folder.
8
10
  */
9
11
  import { randomUUID } from 'node:crypto';
10
12
  import fs from 'node:fs';
11
13
  import path from 'node:path';
12
14
  import { auditProjectPluginCopies } from '../../core/required-plugins.mjs';
13
- import { globalPluginsDir } from '../../core/plugin-loader.mjs';
14
- import { recompileAfterPluginMutation, replacementArchiveDir } from '../../core/plugin-store.mjs';
15
+ import { globalPluginsDir, projectPluginsDir, vaultForPluginsDir } from '../../core/plugin-loader.mjs';
16
+ import { recompileAfterPluginMutation, replacementArchiveDir, recordPath } from '../../core/plugin-store.mjs';
17
+ import { findVfsDocumentByPath } from '../../core/vfs-documents.mjs';
18
+ import { deleteVfsDocument } from '../../core/ssss-operation-service.mjs';
15
19
 
16
20
  export function pluginCopyRows(projectRoot = process.cwd(), { sharedDir = globalPluginsDir() } = {}) {
17
21
  const audit = auditProjectPluginCopies(projectRoot, { sharedDir });
@@ -19,7 +23,9 @@ export function pluginCopyRows(projectRoot = process.cwd(), { sharedDir = global
19
23
  root: projectRoot,
20
24
  sharedDir,
21
25
  count: audit.count,
22
- removable: audit.copies.filter(copy => copy.edited === false && copy.sharedDir && !copy.linked).map(copy => copy.id),
26
+ removable: audit.copies.filter(copy => (copy.edited === false && copy.sharedDir && !copy.linked) || copy.shadow).map(copy => copy.id),
27
+ shadows: audit.copies.filter(copy => copy.shadow).map(copy => copy.id),
28
+ repoOnly: audit.copies.filter(copy => copy.repoOnly).map(copy => copy.id),
23
29
  archivable: audit.copies.filter(copy => copy.stale && copy.edited !== false && !copy.linked).map(copy => copy.id),
24
30
  edited: audit.copies.filter(copy => copy.edited === true && copy.stale !== true).map(copy => copy.id),
25
31
  stale: audit.copies.filter(copy => copy.stale === true).map(copy => copy.id),
@@ -28,13 +34,49 @@ export function pluginCopyRows(projectRoot = process.cwd(), { sharedDir = global
28
34
  };
29
35
  }
30
36
 
37
+ /**
38
+ * Install records in this repository's brain for plugins that exist neither in
39
+ * the repository nor in the shared folder. They describe a repository install
40
+ * that is gone, so no on/off overlay is lost by removing them.
41
+ */
42
+ export function orphanRecordIds(projectRoot, { sharedDir = globalPluginsDir() } = {}) {
43
+ const vaultRoot = vaultForPluginsDir(projectPluginsDir(projectRoot));
44
+ const dir = path.join(vaultRoot, 'system', 'plugins');
45
+ let files = [];
46
+ try { files = fs.readdirSync(dir).filter(name => name.endsWith('.md')); } catch { return []; }
47
+ return files.map(name => name.slice(0, -3)).filter(id => {
48
+ if (fs.existsSync(path.join(projectPluginsDir(projectRoot), id))) return false;
49
+ if (fs.existsSync(path.join(sharedDir, id))) return false;
50
+ const record = findVfsDocumentByPath(recordPath(id), vaultRoot);
51
+ return record?.frontmatter?.type === 'plugin_record' && record.frontmatter.source?.kind !== 'shared';
52
+ });
53
+ }
54
+
55
+ async function removeOrphanRecords(projectRoot, ids) {
56
+ const vaultRoot = vaultForPluginsDir(projectPluginsDir(projectRoot));
57
+ const removed = [];
58
+ const failed = [];
59
+ for (const id of ids) {
60
+ try {
61
+ await deleteVfsDocument(recordPath(id), { actorRole: 'system', intent: `Remove repository install record ${id}`, vaultRoot });
62
+ removed.push(id);
63
+ } catch (error) {
64
+ failed.push({ id, error: error.message });
65
+ }
66
+ }
67
+ return { removed, failed };
68
+ }
69
+
31
70
  export function removePluginCopies(projectRoot, ids) {
32
71
  const removed = [];
33
72
  const failed = [];
34
73
  for (const id of ids) {
35
74
  const dir = path.join(projectRoot, '.agent', 'skills', 'total-recall', 'plugins', id);
36
75
  try {
37
- fs.rmSync(dir, { recursive: true, force: true });
76
+ // A link is removed by itself: its target checkout and this repository's
77
+ // plugin records (including on/off overlays) are left untouched.
78
+ if (fs.lstatSync(dir).isSymbolicLink()) fs.unlinkSync(dir);
79
+ else fs.rmSync(dir, { recursive: true, force: true });
38
80
  removed.push(id);
39
81
  } catch (error) {
40
82
  failed.push({ id, error: error.message });
@@ -65,28 +107,36 @@ export async function manageProjectPluginCopies(args = []) {
65
107
  const json = args.includes('--json');
66
108
  const apply = args.includes('--apply');
67
109
  const archiveStale = args.includes('--archive-stale');
110
+ const dropRepoOnly = args.includes('--drop-repo-only');
68
111
  const roots = args.filter(argument => !argument.startsWith('-'));
69
112
  const root = roots[0] || process.cwd();
70
113
  const report = pluginCopyRows(root);
71
114
  if (apply) {
72
- report.removal = removePluginCopies(root, report.removable);
115
+ report.removal = removePluginCopies(root, dropRepoOnly ? [...new Set([...report.removable, ...report.repoOnly])] : report.removable);
116
+ report.records = await removeOrphanRecords(root, orphanRecordIds(root, { sharedDir: report.sharedDir }));
73
117
  if (archiveStale) report.archival = archivePluginCopies(report.copies.filter(copy => report.archivable.includes(copy.id)));
74
- if (report.removal.removed.length || report.archival?.archived.length) {
118
+ if (report.removal.removed.length || report.records.removed.length || report.archival?.archived.length) {
75
119
  report.compilation = await recompileAfterPluginMutation(root);
76
120
  }
77
- if (report.removal.failed.length || report.archival?.failed.length || report.compilation?.ok === false) process.exitCode = 1;
121
+ if (report.removal.failed.length || report.records.failed.length || report.archival?.failed.length || report.compilation?.ok === false) process.exitCode = 1;
78
122
  }
123
+ if (!apply) report.orphanRecords = orphanRecordIds(root, { sharedDir: report.sharedDir });
79
124
  if (json) {
80
125
  console.log(JSON.stringify(report, null, 2));
81
126
  return;
82
127
  }
83
- console.log(`\nšŸ“¦ Per-repository copies of shared plugins in ${report.root}\n`);
128
+ console.log(`\nšŸ“¦ Plugin installs inside ${report.root} (all plugins belong in the shared folder)\n`);
129
+ const records = report.records?.removed || report.orphanRecords || [];
130
+ if (records.length) console.log(` ${report.records ? 'Removed' : 'Leftover'} install records for plugins installed nowhere: ${records.join(', ')}${report.records ? '' : ' (re-run with --apply)'}`);
131
+ if (report.records?.failed.length) console.error(` Could not remove records: ${report.records.failed.map(row => row.id).join(', ')}`);
84
132
  if (report.count === 0) {
85
133
  console.log(' None — this repository resolves the shared folder directly.\n');
86
134
  return;
87
135
  }
88
136
  for (const copy of report.copies) {
89
- const verdict = copy.linked ? 'linked checkout'
137
+ const verdict = copy.repoOnly ? `REPOSITORY-ONLY install${copy.target ? ` (link to ${copy.target})` : ''} — install it in the shared folder (plugin install <source>), or delete it with --apply --drop-repo-only`
138
+ : copy.shadow ? `SHADOW link to ${copy.target} — shadows the shared install`
139
+ : copy.linked ? 'linked checkout'
90
140
  : copy.stale === true ? 'STALE — older than the shared install and shadows it'
91
141
  : copy.edited === false ? 'identical to the bundled source'
92
142
  : copy.edited === true ? 'DIFFERS from the shared install' : 'no shared install to compare';