@memberjunction/cli 6.3.0-edge.1 → 6.3.0-edge.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/README.md +1052 -359
  2. package/dist/baseline/connection.d.ts.map +1 -1
  3. package/dist/baseline/connection.js +12 -1
  4. package/dist/baseline/connection.js.map +1 -1
  5. package/dist/commands/agent/init.d.ts +3 -0
  6. package/dist/commands/agent/init.d.ts.map +1 -1
  7. package/dist/commands/agent/init.js +102 -46
  8. package/dist/commands/agent/init.js.map +1 -1
  9. package/dist/commands/agent/usage.d.ts +7 -0
  10. package/dist/commands/agent/usage.d.ts.map +1 -0
  11. package/dist/commands/agent/usage.js +10 -0
  12. package/dist/commands/agent/usage.js.map +1 -0
  13. package/dist/commands/ai/actions/list.d.ts.map +1 -1
  14. package/dist/commands/ai/actions/list.js +18 -14
  15. package/dist/commands/ai/actions/list.js.map +1 -1
  16. package/dist/commands/ai/actions/run.d.ts.map +1 -1
  17. package/dist/commands/ai/actions/run.js +15 -8
  18. package/dist/commands/ai/actions/run.js.map +1 -1
  19. package/dist/commands/ai/agents/list.d.ts.map +1 -1
  20. package/dist/commands/ai/agents/list.js +18 -14
  21. package/dist/commands/ai/agents/list.js.map +1 -1
  22. package/dist/commands/ai/agents/run.d.ts.map +1 -1
  23. package/dist/commands/ai/agents/run.js +19 -8
  24. package/dist/commands/ai/agents/run.js.map +1 -1
  25. package/dist/commands/ai/audit/agent-run.d.ts.map +1 -1
  26. package/dist/commands/ai/audit/agent-run.js +62 -56
  27. package/dist/commands/ai/audit/agent-run.js.map +1 -1
  28. package/dist/commands/ai/prompts/list.d.ts.map +1 -1
  29. package/dist/commands/ai/prompts/list.js +6 -3
  30. package/dist/commands/ai/prompts/list.js.map +1 -1
  31. package/dist/commands/ai/prompts/run.d.ts.map +1 -1
  32. package/dist/commands/ai/prompts/run.js +17 -10
  33. package/dist/commands/ai/prompts/run.js.map +1 -1
  34. package/dist/commands/app/install.d.ts +4 -0
  35. package/dist/commands/app/install.d.ts.map +1 -1
  36. package/dist/commands/app/install.js +36 -1
  37. package/dist/commands/app/install.js.map +1 -1
  38. package/dist/commands/app/upgrade.d.ts +1 -0
  39. package/dist/commands/app/upgrade.d.ts.map +1 -1
  40. package/dist/commands/app/upgrade.js +9 -0
  41. package/dist/commands/app/upgrade.js.map +1 -1
  42. package/dist/commands/codegen/manifest.d.ts +40 -0
  43. package/dist/commands/codegen/manifest.d.ts.map +1 -1
  44. package/dist/commands/codegen/manifest.js +124 -3
  45. package/dist/commands/codegen/manifest.js.map +1 -1
  46. package/dist/commands/diag/usage.d.ts +7 -0
  47. package/dist/commands/diag/usage.d.ts.map +1 -0
  48. package/dist/commands/diag/usage.js +10 -0
  49. package/dist/commands/diag/usage.js.map +1 -0
  50. package/dist/commands/doctor/index.d.ts +6 -0
  51. package/dist/commands/doctor/index.d.ts.map +1 -1
  52. package/dist/commands/doctor/index.js +42 -0
  53. package/dist/commands/doctor/index.js.map +1 -1
  54. package/dist/commands/explorer/postbuild.d.ts +14 -0
  55. package/dist/commands/explorer/postbuild.d.ts.map +1 -0
  56. package/dist/commands/explorer/postbuild.js +49 -0
  57. package/dist/commands/explorer/postbuild.js.map +1 -0
  58. package/dist/commands/explorer/usage.d.ts +7 -0
  59. package/dist/commands/explorer/usage.d.ts.map +1 -0
  60. package/dist/commands/explorer/usage.js +10 -0
  61. package/dist/commands/explorer/usage.js.map +1 -0
  62. package/dist/commands/harness/account/add.d.ts +22 -0
  63. package/dist/commands/harness/account/add.d.ts.map +1 -0
  64. package/dist/commands/harness/account/add.js +100 -0
  65. package/dist/commands/harness/account/add.js.map +1 -0
  66. package/dist/commands/harness/account/clear-cooldown.d.ts +13 -0
  67. package/dist/commands/harness/account/clear-cooldown.d.ts.map +1 -0
  68. package/dist/commands/harness/account/clear-cooldown.js +32 -0
  69. package/dist/commands/harness/account/clear-cooldown.js.map +1 -0
  70. package/dist/commands/harness/account/disable.d.ts +13 -0
  71. package/dist/commands/harness/account/disable.d.ts.map +1 -0
  72. package/dist/commands/harness/account/disable.js +34 -0
  73. package/dist/commands/harness/account/disable.js.map +1 -0
  74. package/dist/commands/harness/account/enable.d.ts +13 -0
  75. package/dist/commands/harness/account/enable.d.ts.map +1 -0
  76. package/dist/commands/harness/account/enable.js +34 -0
  77. package/dist/commands/harness/account/enable.js.map +1 -0
  78. package/dist/commands/harness/account/index.d.ts +7 -0
  79. package/dist/commands/harness/account/index.d.ts.map +1 -0
  80. package/dist/commands/harness/account/index.js +23 -0
  81. package/dist/commands/harness/account/index.js.map +1 -0
  82. package/dist/commands/harness/account/list.d.ts +15 -0
  83. package/dist/commands/harness/account/list.d.ts.map +1 -0
  84. package/dist/commands/harness/account/list.js +58 -0
  85. package/dist/commands/harness/account/list.js.map +1 -0
  86. package/dist/commands/harness/account/login.d.ts +16 -0
  87. package/dist/commands/harness/account/login.d.ts.map +1 -0
  88. package/dist/commands/harness/account/login.js +50 -0
  89. package/dist/commands/harness/account/login.js.map +1 -0
  90. package/dist/commands/harness/account/remove.d.ts +14 -0
  91. package/dist/commands/harness/account/remove.d.ts.map +1 -0
  92. package/dist/commands/harness/account/remove.js +43 -0
  93. package/dist/commands/harness/account/remove.js.map +1 -0
  94. package/dist/commands/harness/account/set-strategy.d.ts +13 -0
  95. package/dist/commands/harness/account/set-strategy.d.ts.map +1 -0
  96. package/dist/commands/harness/account/set-strategy.js +38 -0
  97. package/dist/commands/harness/account/set-strategy.js.map +1 -0
  98. package/dist/commands/harness/index.d.ts +7 -0
  99. package/dist/commands/harness/index.d.ts.map +1 -0
  100. package/dist/commands/harness/index.js +22 -0
  101. package/dist/commands/harness/index.js.map +1 -0
  102. package/dist/commands/harness/usage.d.ts +7 -0
  103. package/dist/commands/harness/usage.d.ts.map +1 -0
  104. package/dist/commands/harness/usage.js +10 -0
  105. package/dist/commands/harness/usage.js.map +1 -0
  106. package/dist/commands/migrate/convert.d.ts +25 -1
  107. package/dist/commands/migrate/convert.d.ts.map +1 -1
  108. package/dist/commands/migrate/convert.js +156 -38
  109. package/dist/commands/migrate/convert.js.map +1 -1
  110. package/dist/commands/migrate/index.d.ts +8 -0
  111. package/dist/commands/migrate/index.d.ts.map +1 -1
  112. package/dist/commands/migrate/index.js +40 -1
  113. package/dist/commands/migrate/index.js.map +1 -1
  114. package/dist/commands/migrate/rebake.d.ts +13 -0
  115. package/dist/commands/migrate/rebake.d.ts.map +1 -1
  116. package/dist/commands/migrate/rebake.js +45 -6
  117. package/dist/commands/migrate/rebake.js.map +1 -1
  118. package/dist/commands/queue/export-topology.d.ts +2 -0
  119. package/dist/commands/queue/export-topology.d.ts.map +1 -1
  120. package/dist/commands/queue/export-topology.js +3 -1
  121. package/dist/commands/queue/export-topology.js.map +1 -1
  122. package/dist/commands/queue/import-bindings.d.ts +2 -0
  123. package/dist/commands/queue/import-bindings.d.ts.map +1 -1
  124. package/dist/commands/queue/import-bindings.js +3 -1
  125. package/dist/commands/queue/import-bindings.js.map +1 -1
  126. package/dist/commands/queue/index.js +1 -1
  127. package/dist/commands/queue/index.js.map +1 -1
  128. package/dist/commands/queue/sweep.d.ts +4 -6
  129. package/dist/commands/queue/sweep.d.ts.map +1 -1
  130. package/dist/commands/queue/sweep.js +15 -23
  131. package/dist/commands/queue/sweep.js.map +1 -1
  132. package/dist/commands/queue/validate-bindings.d.ts +2 -0
  133. package/dist/commands/queue/validate-bindings.d.ts.map +1 -1
  134. package/dist/commands/queue/validate-bindings.js +3 -1
  135. package/dist/commands/queue/validate-bindings.js.map +1 -1
  136. package/dist/commands/queue/work.d.ts +2 -19
  137. package/dist/commands/queue/work.d.ts.map +1 -1
  138. package/dist/commands/queue/work.js +9 -29
  139. package/dist/commands/queue/work.js.map +1 -1
  140. package/dist/commands/rubric/usage.d.ts +7 -0
  141. package/dist/commands/rubric/usage.d.ts.map +1 -0
  142. package/dist/commands/rubric/usage.js +10 -0
  143. package/dist/commands/rubric/usage.js.map +1 -0
  144. package/dist/commands/test/regression/index.d.ts.map +1 -1
  145. package/dist/commands/test/regression/index.js +2 -0
  146. package/dist/commands/test/regression/index.js.map +1 -1
  147. package/dist/commands/test/regression/new.d.ts +21 -0
  148. package/dist/commands/test/regression/new.d.ts.map +1 -0
  149. package/dist/commands/test/regression/new.js +82 -0
  150. package/dist/commands/test/regression/new.js.map +1 -0
  151. package/dist/commands/test/regression/up.d.ts +1 -0
  152. package/dist/commands/test/regression/up.d.ts.map +1 -1
  153. package/dist/commands/test/regression/up.js +17 -0
  154. package/dist/commands/test/regression/up.js.map +1 -1
  155. package/dist/commands/test/scripts.d.ts +6 -4
  156. package/dist/commands/test/scripts.d.ts.map +1 -1
  157. package/dist/commands/test/scripts.js +14 -0
  158. package/dist/commands/test/scripts.js.map +1 -1
  159. package/dist/commands/test/suite.d.ts +1 -0
  160. package/dist/commands/test/suite.d.ts.map +1 -1
  161. package/dist/commands/test/suite.js +6 -0
  162. package/dist/commands/test/suite.js.map +1 -1
  163. package/dist/commands/usage.js +2 -1
  164. package/dist/commands/usage.js.map +1 -1
  165. package/dist/commands/user/usage.d.ts +7 -0
  166. package/dist/commands/user/usage.d.ts.map +1 -0
  167. package/dist/commands/user/usage.js +10 -0
  168. package/dist/commands/user/usage.js.map +1 -0
  169. package/dist/config.d.ts +117 -0
  170. package/dist/config.d.ts.map +1 -1
  171. package/dist/config.js +44 -0
  172. package/dist/config.js.map +1 -1
  173. package/dist/init-templates/citizen-builder/.agents/skills/package-agent/SKILL.md +12 -2
  174. package/dist/init-templates/citizen-builder/.agents/skills/test-agent/SKILL.md +1 -1
  175. package/dist/init-templates/citizen-builder/.claude/skills/package-agent/SKILL.md +12 -2
  176. package/dist/init-templates/citizen-builder/.claude/skills/test-agent/SKILL.md +1 -1
  177. package/dist/init-templates/citizen-builder/.env.example +14 -2
  178. package/dist/init-templates/citizen-builder/AGENTS.md +5 -2
  179. package/dist/init-templates/citizen-builder/CAPABILITIES.md +9 -0
  180. package/dist/init-templates/citizen-builder/README.md +29 -15
  181. package/dist/init-templates/citizen-builder/docker-compose.yml +13 -0
  182. package/dist/init-templates/citizen-builder/docs/PROMOTION_GUIDE.md +5 -2
  183. package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +290 -33
  184. package/dist/init-templates/citizen-builder/scripts/generate-capabilities.sh +148 -41
  185. package/dist/lib/db-preflight.d.ts.map +1 -1
  186. package/dist/lib/db-preflight.js +22 -0
  187. package/dist/lib/db-preflight.js.map +1 -1
  188. package/dist/lib/derived-usage.d.ts +8 -0
  189. package/dist/lib/derived-usage.d.ts.map +1 -1
  190. package/dist/lib/derived-usage.js +30 -20
  191. package/dist/lib/derived-usage.js.map +1 -1
  192. package/dist/lib/domain-profiles.d.ts.map +1 -1
  193. package/dist/lib/domain-profiles.js +24 -0
  194. package/dist/lib/domain-profiles.js.map +1 -1
  195. package/dist/lib/domain-usage-command.js +2 -1
  196. package/dist/lib/domain-usage-command.js.map +1 -1
  197. package/dist/lib/explorer-postbuild/public-page-html.d.ts +48 -0
  198. package/dist/lib/explorer-postbuild/public-page-html.d.ts.map +1 -0
  199. package/dist/lib/explorer-postbuild/public-page-html.js +284 -0
  200. package/dist/lib/explorer-postbuild/public-page-html.js.map +1 -0
  201. package/dist/lib/explorer-postbuild/service-worker-check.d.ts +13 -0
  202. package/dist/lib/explorer-postbuild/service-worker-check.d.ts.map +1 -0
  203. package/dist/lib/explorer-postbuild/service-worker-check.js +41 -0
  204. package/dist/lib/explorer-postbuild/service-worker-check.js.map +1 -0
  205. package/dist/lib/harness-account.d.ts +34 -0
  206. package/dist/lib/harness-account.d.ts.map +1 -0
  207. package/dist/lib/harness-account.js +105 -0
  208. package/dist/lib/harness-account.js.map +1 -0
  209. package/dist/lib/pg-preflight/checks.d.ts +28 -0
  210. package/dist/lib/pg-preflight/checks.d.ts.map +1 -0
  211. package/dist/lib/pg-preflight/checks.js +94 -0
  212. package/dist/lib/pg-preflight/checks.js.map +1 -0
  213. package/dist/lib/pg-preflight/extension-check.d.ts +28 -0
  214. package/dist/lib/pg-preflight/extension-check.d.ts.map +1 -0
  215. package/dist/lib/pg-preflight/extension-check.js +86 -0
  216. package/dist/lib/pg-preflight/extension-check.js.map +1 -0
  217. package/dist/lib/pg-preflight/extension-scan.d.ts +24 -0
  218. package/dist/lib/pg-preflight/extension-scan.d.ts.map +1 -0
  219. package/dist/lib/pg-preflight/extension-scan.js +58 -0
  220. package/dist/lib/pg-preflight/extension-scan.js.map +1 -0
  221. package/dist/lib/pg-preflight/pending-migrations.d.ts +28 -0
  222. package/dist/lib/pg-preflight/pending-migrations.d.ts.map +1 -0
  223. package/dist/lib/pg-preflight/pending-migrations.js +48 -0
  224. package/dist/lib/pg-preflight/pending-migrations.js.map +1 -0
  225. package/dist/lib/pg-preflight/preflight.d.ts +18 -0
  226. package/dist/lib/pg-preflight/preflight.d.ts.map +1 -0
  227. package/dist/lib/pg-preflight/preflight.js +43 -0
  228. package/dist/lib/pg-preflight/preflight.js.map +1 -0
  229. package/dist/lib/pg-preflight/remediation.d.ts +27 -0
  230. package/dist/lib/pg-preflight/remediation.d.ts.map +1 -0
  231. package/dist/lib/pg-preflight/remediation.js +82 -0
  232. package/dist/lib/pg-preflight/remediation.js.map +1 -0
  233. package/dist/lib/pg-preflight/render.d.ts +15 -0
  234. package/dist/lib/pg-preflight/render.d.ts.map +1 -0
  235. package/dist/lib/pg-preflight/render.js +48 -0
  236. package/dist/lib/pg-preflight/render.js.map +1 -0
  237. package/dist/lib/pg-preflight/run-for-config.d.ts +23 -0
  238. package/dist/lib/pg-preflight/run-for-config.d.ts.map +1 -0
  239. package/dist/lib/pg-preflight/run-for-config.js +45 -0
  240. package/dist/lib/pg-preflight/run-for-config.js.map +1 -0
  241. package/dist/lib/pg-preflight/types.d.ts +67 -0
  242. package/dist/lib/pg-preflight/types.d.ts.map +1 -0
  243. package/dist/lib/pg-preflight/types.js +8 -0
  244. package/dist/lib/pg-preflight/types.js.map +1 -0
  245. package/dist/lib/regression/test-scaffold.d.ts +52 -0
  246. package/dist/lib/regression/test-scaffold.d.ts.map +1 -0
  247. package/dist/lib/regression/test-scaffold.js +237 -0
  248. package/dist/lib/regression/test-scaffold.js.map +1 -0
  249. package/dist/lib/work-queue/queue-format.d.ts +4 -0
  250. package/dist/lib/work-queue/queue-format.d.ts.map +1 -1
  251. package/dist/lib/work-queue/queue-format.js +15 -0
  252. package/dist/lib/work-queue/queue-format.js.map +1 -1
  253. package/dist/lib/work-queue/queue-worker.d.ts +16 -1
  254. package/dist/lib/work-queue/queue-worker.d.ts.map +1 -1
  255. package/dist/lib/work-queue/queue-worker.js +18 -0
  256. package/dist/lib/work-queue/queue-worker.js.map +1 -1
  257. package/dist/light-commands.d.ts.map +1 -1
  258. package/dist/light-commands.js +34 -0
  259. package/dist/light-commands.js.map +1 -1
  260. package/dist/tsconfig.tsbuildinfo +1 -1
  261. package/dist/utils/dependencies-from-head.d.ts +4 -0
  262. package/dist/utils/dependencies-from-head.d.ts.map +1 -0
  263. package/dist/utils/dependencies-from-head.js +5 -0
  264. package/dist/utils/dependencies-from-head.js.map +1 -0
  265. package/dist/utils/open-app-context.d.ts +1 -0
  266. package/dist/utils/open-app-context.d.ts.map +1 -1
  267. package/dist/utils/open-app-context.js +6 -1
  268. package/dist/utils/open-app-context.js.map +1 -1
  269. package/oclif.manifest.json +2026 -1091
  270. package/package.json +34 -31
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @memberjunction/cli
2
2
 
3
- The official command-line interface for MemberJunction. Provides tools for installation, database migrations, code generation, metadata sync, AI operations, testing, database documentation, and query generation.
3
+ The official command-line interface for MemberJunction (`mj`). Provides a unified entry point for installation, database migrations, code generation, metadata synchronization, Open App lifecycle management, AI & agent harness operations, rubrics, testing, durable work queues, diagnostic bundles, SQL dialect conversion, repo standards enforcement, and multi-repo local development workspaces.
4
4
 
5
5
  ## Architecture
6
6
 
@@ -8,21 +8,16 @@ The official command-line interface for MemberJunction. Provides tools for insta
8
8
  graph TD
9
9
  subgraph "@memberjunction/cli (mj)"
10
10
  A[CLI Entry Point] --> B[Commands]
11
- B --> C[install]
12
- B --> D[migrate]
13
- B --> E[codegen]
14
- B --> F[sync]
15
- B --> G[ai]
16
- B --> H[test]
17
- B --> I[dbdoc]
18
- B --> J[querygen]
19
- B --> Q2[query]
20
- B --> K[bump]
21
- B --> L[clean]
11
+ B --> C["Lifecycle: install, update, bundle, bump, clean, dev"]
12
+ B --> D["Database & Code: migrate, codegen, baseline, sql-convert, translate-sql, sql-audit"]
13
+ B --> E["Metadata & Queries: sync, query, querygen, dbdoc, cache, artifacts, user"]
14
+ B --> F["Apps & Quality: app, standards, doctor, diag, explorer, plugin"]
15
+ B --> G["AI, Testing & Ops: ai, agent, harness, rubric, test, queue, usage"]
22
16
 
23
17
  A --> M[Hooks]
24
18
  M --> N[init]
25
19
  M --> O[prerun]
20
+ M --> P2[postrun]
26
21
  end
27
22
 
28
23
  subgraph "Underlying Engines"
@@ -31,17 +26,19 @@ graph TD
31
26
  R["@memberjunction/testing-cli"]
32
27
  S["@memberjunction/db-auto-doc"]
33
28
  T["@memberjunction/query-gen"]
34
- U["@memberjunction/ai-cli"]
35
- V["@memberjunction/core-entities-server"]
29
+ U["@memberjunction/ai-cli & ai-agent-harness"]
30
+ V["@memberjunction/open-app-engine & installer"]
31
+ W["@memberjunction/work-queue-engine & diagnostics & standards"]
36
32
  end
37
33
 
38
- E --> P
39
- F --> Q
40
- H --> R
41
- I --> S
42
- J --> T
34
+ D --> P
35
+ E --> Q
36
+ G --> R
37
+ E --> S
38
+ E --> T
43
39
  G --> U
44
- Q2 --> V
40
+ F --> V
41
+ F --> W
45
42
 
46
43
  style A fill:#2d6a9f,stroke:#1a4971,color:#fff
47
44
  style C fill:#2d8659,stroke:#1a5c3a,color:#fff
@@ -49,15 +46,11 @@ graph TD
49
46
  style E fill:#7c5295,stroke:#563a6b,color:#fff
50
47
  style F fill:#7c5295,stroke:#563a6b,color:#fff
51
48
  style G fill:#b8762f,stroke:#8a5722,color:#fff
52
- style H fill:#b8762f,stroke:#8a5722,color:#fff
53
- style I fill:#b8762f,stroke:#8a5722,color:#fff
54
- style J fill:#b8762f,stroke:#8a5722,color:#fff
55
- style Q2 fill:#b8762f,stroke:#8a5722,color:#fff
56
49
  ```
57
50
 
58
51
  ## Overview
59
52
 
60
- The `mj` CLI is built on the oclif framework and acts as a unified entry point for all MemberJunction development tools. Each command group delegates to a specialized package.
53
+ The `mj` CLI is built on the [oclif](https://oclif.io/) framework and delegates each command domain to specialized MemberJunction packages. Lightweight commands (such as `usage`, `harness`, `dev workspace`, `diag`, `standards`, `migrate`, `cache`, `doctor`, and `install`) bypass the full server bootstrap so they start in milliseconds.
61
54
 
62
55
  ## Installation
63
56
 
@@ -118,19 +111,20 @@ export MJ_CLI_FORMAT=json # pin the format for a whole session
118
111
  still win over auto-detection when passed explicitly.
119
112
 
120
113
  > **Note on `-o`:** `-o` means *output format* in the `mj ai` family and *output file path*
121
- > in `mj test`, `querygen export`, and `sql-audit`. Prefer `--format` — it means the same
122
- > thing in every command.
114
+ > in `mj test`, `mj diag`, `mj queue export-topology`, `mj querygen export`, `mj sql-convert`,
115
+ > `mj sql-audit`, `mj translate-sql`, and `mj bundle`. Prefer `--format` for output format —
116
+ > it means the same thing across commands.
123
117
 
124
118
  ### Discovering commands without burning context
125
119
 
126
- `mj usage` is a two-tier progressive-disclosure surface. Tier 1 is a ~200-token domain map;
120
+ `mj usage` is a two-tier progressive-disclosure surface. Tier 1 is a compact domain map;
127
121
  tier 2 is one domain's commands, flags, examples, and expected runtime. Reading the full
128
122
  oclif help tree instead costs roughly 13–15k tokens.
129
123
 
130
124
  ```bash
131
- mj usage # every domain + a one-line summary + a runtime class
132
- mj sync usage # every mj sync command, its flags and examples
133
- mj sync usage --format=json # the same, machine-readable
125
+ mj usage # every domain + a one-line summary + a runtime class
126
+ mj sync usage # every mj sync command, its flags and examples
127
+ mj harness usage --format=json # the same, machine-readable
134
128
  ```
135
129
 
136
130
  Each entry carries a **runtime hint** (`fast` | `moderate` | `slow` | `variable`, often with
@@ -177,11 +171,11 @@ These can also be set in `mj.config.cjs` as `dbHost`, `dbPort`, `dbDatabase`, `c
177
171
  ### Open App packages and `--no-app-packages`
178
172
 
179
173
  Every heavy command (anything that is not `version`, `help`, `migrate`, `clean`, `bump`, `install`,
180
- `dbdoc *` or `* usage`) imports, before it opens a database, the host's generated packages and the
181
- installed Open Apps' server packages named in `mj.config.cjs` — so `mj sync push`, `mj app …`,
182
- `mj test` and `mj ai` construct an app's real entity subclasses rather than a generic `BaseEntity`.
183
- The command's process ID is `cli:<command>` (`cli:sync:push`), which entries can be scoped to with
184
- `Processes` / `ExcludeProcesses` and `dynamicPackages.policy`:
174
+ `dbdoc *`, `harness *`, `diag *`, `dev *`, or `* usage`) imports, before it opens a database,
175
+ the host's generated packages and the installed Open Apps' server packages named in `mj.config.cjs`
176
+ — so `mj sync push`, `mj app …`, `mj test` and `mj ai` construct an app's real entity subclasses
177
+ rather than a generic `BaseEntity`. The command's process ID is `cli:<command>` (`cli:sync:push`),
178
+ which entries can be scoped to with `Processes` / `ExcludeProcesses` and `dynamicPackages.policy`:
185
179
 
186
180
  ```javascript
187
181
  // mj.config.cjs
@@ -208,559 +202,1258 @@ not to let the machine sleep (or, on a Mac, close the lid) until they finish.
208
202
 
209
203
  ## Commands
210
204
 
211
- ### mj install
205
+ ### Quick Domain Index
206
+
207
+ Every domain also provides `mj <domain> usage` for progressive-disclosure discovery.
208
+
209
+ | Domain | Summary | Runtime |
210
+ |--------|---------|---------|
211
+ | [`mj agent`](#mj-agent) | Initialize a Citizen Agent Builder environment with Docker setup | `slow` |
212
+ | [`mj ai`](#mj-ai) | Run and audit AI agents, prompts, and actions from the terminal | `variable` |
213
+ | [`mj app`](#mj-app) | Install, upgrade, enable, disable, and remove MJ Open Apps | `slow` |
214
+ | [`mj artifacts`](#mj-artifacts) | Maintenance operations over stored conversation artifacts | `moderate` |
215
+ | [`mj baseline`](#mj-baseline) | Build, compare, and round-trip deterministic database baseline SQL scripts | `slow` |
216
+ | [`mj bump`](#mj-bump) | Bump `@memberjunction/*` dependency versions across `package.json` files | `fast` |
217
+ | [`mj bundle`](#mj-bundle) | Create self-contained distribution zips for offline/air-gapped installs | `moderate` |
218
+ | [`mj cache`](#mj-cache) | Inspect and clear the shared Redis server cache (`REDIS_URL`) | `fast` |
219
+ | [`mj clean`](#mj-clean) | Reset a MemberJunction database to a pre-installation state | `fast` |
220
+ | [`mj codegen`](#mj-codegen) | Run CodeGen, emit class registration manifests, and run v5.0 rename helpers | `slow` |
221
+ | [`mj dbdoc`](#mj-dbdoc) | Generate and export AI-authored database documentation and sample queries | `slow` |
222
+ | [`mj dev`](#mj-dev) | Generate, inspect, health-check, and clean cross-repo pnpm dev workspaces | `variable` |
223
+ | [`mj diag`](#mj-diag) | Inspect, scrub, analyze, export, and keygen `.mjdiag` diagnostic bundles | `fast` |
224
+ | [`mj doctor`](#mj-doctor) | Diagnose a local MJ environment and scan/fix value-list drift | `moderate` |
225
+ | [`mj explorer`](#mj-explorer) | Run MJ Explorer post-build tasks (service worker check, public page HTML) | `fast` |
226
+ | [`mj harness`](#mj-harness) | Manage multi-account CLI subscription pools, balancing strategies, and cooldowns | `fast` |
227
+ | [`mj install`](#mj-install) | Install MemberJunction from a release or seed the Claude Code pack | `slow` |
228
+ | [`mj migrate`](#mj-migrate) | Run, create, convert (T-SQL → PostgreSQL), and rebake migrations | `slow` |
229
+ | [`mj plugin`](#mj-plugin) | Register third-party CLI plugin packages in `mj-cli-plugins.json` | `fast` |
230
+ | [`mj query`](#mj-query) | Refresh saved queries' extracted parameters, fields, entities, and dependencies | `moderate` |
231
+ | [`mj querygen`](#mj-querygen) | Generate, validate, and export AI-authored stored query templates | `slow` |
232
+ | [`mj queue`](#mj-queue) | Operate the durable work queue (stats, backlog, dead letters, workers, bindings) | `moderate` |
233
+ | [`mj rubric`](#mj-rubric) | List, show, diff, validate, and evaluate versioned scoring rubrics | `moderate` |
234
+ | [`mj sql-audit`](#mj-sql-audit) | Compare source and target databases for SQL migration verification | `moderate` |
235
+ | [`mj sql-convert`](#mj-sql-convert) | Convert SQL files between dialects via the rule-based BatchConverter engine | `moderate` |
236
+ | [`mj standards`](#mj-standards) | List, adopt, and enforce MemberJunction repository engineering standards | `moderate` |
237
+ | [`mj sync`](#mj-sync) | Synchronize metadata between local JSON files and the database | `variable` |
238
+ | [`mj test`](#mj-test) | Run, compare, validate, and manage MJ tests, suites, scripts, and regression stacks | `variable` |
239
+ | [`mj translate-sql`](#mj-translate-sql) | Translate SQL fragments and stored metadata SQL between SQL Server and PostgreSQL | `moderate` |
240
+ | [`mj update`](#mj-update) | Update installed MJ tooling, including the Claude Code pack | `moderate` |
241
+ | [`mj usage`](#mj-usage) | Progressive-disclosure tier-1 domain map for humans and AI agents | `fast` |
242
+ | [`mj user`](#mj-user) | Clone an existing or template MJ user with roles, views, or settings | `fast` |
243
+
244
+ ---
245
+
246
+ ### mj agent
247
+
248
+ Scaffold a local Citizen Agent Builder environment with Docker Compose and optional Open App business context.
249
+
250
+ #### mj agent init
251
+
252
+ Alias: `mj ai agents init`
253
+
254
+ ```bash
255
+ # Initialize in the current directory and boot the Docker stack
256
+ mj agent init
257
+
258
+ # Initialize into a specific directory without starting containers yet
259
+ mj agent init ./my-agent-workspace --no-start
260
+
261
+ # Specify a custom Open App repository for business context
262
+ mj agent init --app https://github.com/acme/sample-data --force
263
+ ```
264
+
265
+ | Arg / Flag | Short | Description |
266
+ |------------|-------|-------------|
267
+ | `[dir]` | | Target directory for the agent builder environment (default: `.`) |
268
+ | `--force` | `-f` | Overwrite existing files in target directory |
269
+ | `--[no-]start` | `-s` | Start Docker containers and run bootstrap after init (default: `true`) |
270
+ | `--app <url>` | | Open App Git URL to install for business context (default: More Cheese) |
271
+ | `--skip-docker-check` | | Skip the Docker availability check and assume Docker is running |
272
+
273
+ ---
274
+
275
+ ### mj ai
276
+
277
+ Run, list, and audit AI agents, prompts, and actions from the terminal (`mj ai` prints topic help). All `mj ai` list/run/audit commands accept `--format <text|json|md>` (preferred) or legacy `-o, --output <compact|json|table>` (`markdown` also supported on `audit agent-run`).
212
278
 
213
- Interactive installer for new MemberJunction environments.
279
+ #### mj ai agents list / mj ai agents run
214
280
 
215
281
  ```bash
216
- mj install
282
+ # List available AI agents
283
+ mj ai agents list --format=json
284
+
285
+ # Execute an agent with an inline prompt or file
286
+ mj ai agents run -a "Requirements Expert" -p "Create a dashboard for sales metrics"
287
+ mj ai agents run -a "Customer Insight Agent" -f ./prompt.txt --verbose --timeout=600000
288
+
289
+ # Start an interactive chat session with an agent
290
+ mj ai agents run -a "Customer Insight Agent" --chat
217
291
  ```
218
292
 
219
- Sets up the database schema, applies migrations, and generates initial code.
293
+ Key flags on `mj ai agents run`: `-a, --agent <name>` (required), `-p, --prompt <text>`, `-f, --prompt-file <path>`, `-c, --chat` (mutually exclusive), `--format`, `-o, --output`, `-v, --verbose`, `--timeout <ms>` (default `300000`).
220
294
 
221
- ### mj migrate
295
+ #### mj ai prompts list / mj ai prompts run
222
296
 
223
- Run database migrations (powered by [Skyway](https://github.com/MemberJunction/skyway)).
297
+ ```bash
298
+ # List available AI models (add -v for detailed model info)
299
+ mj ai prompts list -v
300
+
301
+ # Execute a direct prompt with a specific model and system prompt
302
+ mj ai prompts run -p "Summarize this architecture" --model "gpt-4" --temperature 0.3
303
+ mj ai prompts run -p "Generate a haiku" --system "You are a poet" --max-tokens 100
304
+ ```
305
+
306
+ Key flags on `mj ai prompts run`: `-p, --prompt <text>` (required), `-m, --model <name>`, `-s, --system <text>`, `-t, --temperature <val>`, `--max-tokens <n>`, `-c, --configuration <id>`, `--format`, `-o, --output`, `-v, --verbose`, `--timeout <ms>`.
307
+
308
+ #### mj ai actions list / mj ai actions run
224
309
 
225
310
  ```bash
226
- mj migrate
227
- mj migrate [--verbose] [--tag <version>] [--schema <name>] [--dir <path>]
311
+ # List available AI actions
312
+ mj ai actions list --format=text
313
+
314
+ # Execute an action with repeatable key=value parameters (or --dry-run to validate)
315
+ mj ai actions run -n "Calculate Expression" --param "Expression=2+2*3" --dry-run
316
+ mj ai actions run -n "Get Weather" -p "Location=Boston" --verbose
228
317
  ```
229
318
 
230
- Options:
231
- - `-v, --verbose`: Enable detailed logging
232
- - `-t, --tag <version>`: Specify a version tag for migrations (e.g., 'v2.10.0')
233
- - `-s, --schema <name>`: Target schema (overrides `coreSchema` from config)
234
- - `--dir <path>`: Migration source directory (overrides `migrationsLocation` from config)
319
+ Key flags on `mj ai actions run`: `-n, --name <name>` (required), `-p, --param <key=value>` (repeatable), `--dry-run`, `--format`, `-o, --output`, `-v, --verbose`, `--timeout <ms>`.
235
320
 
236
- **Schema Handling:**
237
- - When using `--schema`, the specified schema will be automatically created if it doesn't exist
238
- - This enables migrating to new schemas without manual DDL setup
239
- - The schema creation uses Flyway's `createSchemas` feature
321
+ #### mj ai audit / mj ai audit agent-run
322
+
323
+ Audit and analyze AI agent execution runs for debugging and performance analysis (`mj ai audit` shows audit subcommands).
240
324
 
241
- Examples:
242
325
  ```bash
243
- # Basic migration
244
- mj migrate
326
+ # Inspect a run summary or export markdown
327
+ mj ai audit agent-run <run-id>
328
+ mj ai audit agent-run <run-id> --output=markdown
329
+
330
+ # Drill into a specific 1-based step or show errors only
331
+ mj ai audit agent-run <run-id> --step 3 --detail full
332
+ mj ai audit agent-run <run-id> --errors
333
+
334
+ # List recent runs with filters
335
+ mj ai audit agent-run --list --agent "Requirements Expert" --status failed --days 7 --limit 25
336
+
337
+ # Export full audit trace to a JSON file
338
+ mj ai audit agent-run <run-id> --export full --file report.json
339
+ ```
340
+
341
+ | Arg / Flag | Short | Description |
342
+ |------------|-------|-------------|
343
+ | `[runId]` | | AI Agent Run ID (UUID); omitted when using `--list` |
344
+ | `--step <n>` | `-s` | Show details for a specific 1-based step number |
345
+ | `--detail <level>` | `-d` | Step detail level: `minimal \| standard \| detailed \| full` (requires `--step`) |
346
+ | `--errors` | `-e` | Show only error details and context |
347
+ | `--list` | `-l` | List recent agent runs |
348
+ | `--agent <name>` | `-a` | Filter listed runs by agent name (requires `--list`) |
349
+ | `--status <val>` | | Filter by status: `success \| failed \| running \| all` (default `all`) |
350
+ | `--days <n>` | | Days to look back (default `7`, requires `--list`) |
351
+ | `--limit <n>` | | Maximum runs to return (default `50`, requires `--list`) |
352
+ | `--export <mode>` | | Export mode: `full \| summary \| steps` (requires `--file`) |
353
+ | `--file <path>` | `-f` | Output file path for `--export` |
354
+ | `--max-tokens <n>` | | Max tokens per field before truncation (`0` = no limit, default `5000`) |
355
+ | `--format` / `-o, --output` | | Output format (`compact \| json \| table \| markdown`) |
356
+ | `--verbose` | `-v` | Show detailed diagnostic information |
357
+
358
+ ---
359
+
360
+ ### mj app
361
+
362
+ Install, upgrade, enable, disable, and remove MJ Open Apps (powered by `@memberjunction/open-app-engine`).
363
+
364
+ ```bash
365
+ # List installed apps (add -v for details)
366
+ mj app list
367
+
368
+ # Show detailed info for one app
369
+ mj app info acme-crm
370
+
371
+ # Install from a GitHub repository, a multi-app repo subpath, an unpublished Git branch/ref, or a local workspace folder
372
+ mj app install https://github.com/acme/mj-crm
373
+ mj app install https://github.com/acme/mj-crm --version 1.2.0 --non-interactive
374
+ mj app install https://github.com/MemberJunction/more-cheese --ref next
375
+ mj app install https://github.com/MemberJunction/more-cheese --ref feat/new-ui --dep-ref next --local-workspace
376
+ mj app install https://github.com/MemberJunction/Integrations/CRM/HubSpot
377
+ mj app install ./openapps/analytics
378
+
379
+ # Upgrade to a newer version (or --reapply a local folder app without bumping version)
380
+ mj app upgrade acme-crm
381
+ mj app upgrade acme-crm --version 1.3.0 --non-interactive
382
+ mj app upgrade analytics --reapply
383
+
384
+ # Development only: check an installed app against its default branch (repeatable, or 'all')
385
+ mj app upgrade acme-crm --dependencies-from-head mj-common
386
+
387
+ # Enable / disable without removing
388
+ mj app enable acme-crm
389
+ mj app disable acme-crm
390
+
391
+ # Remove (add --keep-data to preserve schema/data, --force to ignore dependents, -y to skip prompt)
392
+ mj app remove acme-crm
393
+ mj app remove acme-crm --keep-data --yes
394
+
395
+ # Check which installed apps have newer versions available
396
+ mj app check-updates
397
+ ```
398
+
399
+ #### Private repositories
400
+
401
+ Private GitHub repositories return **404, not 403**, when no token is supplied. Provide a token with `repo` scope in one of three ways (in precedence order):
402
+
403
+ ```bash
404
+ # 1. mj.config.cjs — per-repository tokens, keyed by repo URL
405
+ # openApps: { github: { tokens: { 'https://github.com/acme/private-app': process.env.APP_TOKEN } } }
406
+
407
+ # 2. mj.config.cjs — one token for every Open App repo
408
+ # openApps: { github: { token: process.env.GITHUB_TOKEN } }
409
+
410
+ # 3. Environment variable
411
+ GITHUB_TOKEN=$(gh auth token) mj app install https://github.com/acme/private-app
412
+ ```
413
+
414
+ #### Internal / dangerous flags
415
+
416
+ Intentionally omitted from `--help` because standard MJ Open Apps use the `__mj_<AppName>` schema namespace without any flag:
417
+
418
+ - `--dangerously-ignore-dbl-underscore-schema-rule` — available on `mj app install`, `mj app upgrade`, and `mj app remove`. Permits a `__`-prefixed schema name outside the `__mj_` app namespace. Platform-reserved and MJ-owned schemas (`dbo`, `sys`, `guest`, `db_*`, `public`, `pg_*`, `information_schema`, `__mj`, `__mj_UDT`) remain hard-blocked regardless.
419
+
420
+ ---
421
+
422
+ ### mj artifacts
423
+
424
+ Maintenance utilities for stored conversation artifacts.
425
+
426
+ #### mj artifacts reclassify
427
+
428
+ Upgrade-recovery utility for v5.35 artifact unification. Re-evaluates rows whose `TypeID` still points to the deleted JSON fallback when their content is not JSON. Dry-run by default; pass `--apply` to persist changes through Record Changes.
429
+
430
+ ```bash
431
+ # Dry-run preview (inspects up to 100 rows by default)
432
+ mj artifacts reclassify
433
+
434
+ # Apply reclassification for artifacts created after a date
435
+ mj artifacts reclassify --since 2026-01-01 --limit 50 --apply --verbose
436
+ ```
437
+
438
+ | Flag | Short | Description |
439
+ |------|-------|-------------|
440
+ | `--conversation-id <id>` | | Scope to artifacts attached to one conversation |
441
+ | `--since <iso-date>` | | Scope to artifacts created on or after this ISO date |
442
+ | `--limit <n>` | | Maximum rows to inspect (default `100`) |
443
+ | `--apply` | | Write changes (dry-run when omitted) |
444
+ | `--verbose` | `-v` | Print every candidate row, not just the summary |
445
+
446
+ ---
447
+
448
+ ### mj baseline
449
+
450
+ Build, compare, and round-trip **baseline migrations** — a single deterministic `B`-prefixed SQL script capturing the end-state (schema + row data) of an entire V-stack so Skyway/Flyway can bootstrap a fresh database without replaying hundreds of historical migrations.
451
+
452
+ > Niche maintainer command — use `mj migrate` for routine schema changes.
453
+
454
+ #### Operating modes
455
+
456
+ | Mode | Trigger | Version source | Timestamp | Output folder |
457
+ |------|---------|----------------|-----------|---------------|
458
+ | **AUTO — within-major rebaseline** (default) | `--baseline-version` omitted | `Major.Minor` from latest V-file in `--source-dir` | Latest V-file timestamp **+ 1 minute** | Same `migrations/v{N}/` |
459
+ | **EXPLICIT — major-boundary baseline** | `--baseline-version M.N` provided | Flag value | `Date.now()` UTC | `migrations/v{N+1}/` |
460
+
461
+ Filename format: `B{YYYYMMDDHHMM}__v{Major}.{Minor}.x__Baseline.sql`.
462
+
463
+ #### mj baseline build
464
+
465
+ ```bash
466
+ # AUTO within-major rebaseline
467
+ mj baseline build --out ./migrations/v5/
468
+
469
+ # EXPLICIT major-boundary baseline
470
+ mj baseline build --baseline-version 6.0 --out ./migrations/v6/
471
+
472
+ # Schema-only, no INSERT statements
473
+ mj baseline build --no-data --out ./baselines/
474
+ ```
475
+
476
+ Key flags: `--baseline-version`, `--source-dir`, `--description`, `--database`, `--out`, `--exclude-data <csv>`, `--batch-size <n>` (default `1000`), `--no-data`, `--dry-run`, `--verbose`.
477
+
478
+ #### mj baseline compare
479
+
480
+ ```bash
481
+ # Full object-by-object and row-by-row diff
482
+ mj baseline compare --left MJ_BL_Stack --right MJ_BL_New
483
+
484
+ # Counts-only (fastest) or CI gate with report files
485
+ mj baseline compare --left A --right B --row-compare counts
486
+ mj baseline compare --left A --right B --fail-on-diff --out ./diffs/
487
+ ```
488
+
489
+ Key flags: `--left` (required), `--right` (required), `--dialect <mssql|postgres>`, `--row-compare <full|hash|counts|none>`, `--row-hash-algo <sha256|md5|checksum_agg>`, `--ignore <regex>`, `--sample-limit <n>`, `--out <dir>`, `--fail-on-diff`, `--verbose`.
490
+
491
+ #### mj baseline roundtrip
492
+
493
+ ```bash
494
+ # Build from gold-standard V-stack DB, apply to empty target DB, and verify byte-equivalence
495
+ mj baseline roundtrip --source MJ_BL_Stack --target MJ_BL_New
496
+ mj baseline roundtrip --baseline-version 6.0 --source MJ_BL_Stack --target MJ_BL_New --keep-target
497
+ ```
498
+
499
+ Key flags: `--source` (required), `--target` (required), `--baseline-version`, `--source-dir`, `--description`, `--dialect <mssql|postgres>`, `--out`, `--apply-cmd <template>` (tokens `{file}`, `{database}`), `--row-compare`, `--fail-on-diff` (default `true`), `--keep-target`, `--verbose`.
500
+
501
+ Related docs: [`packages/MJCLI/src/commands/baseline/PLAN.md`](src/commands/baseline/PLAN.md).
502
+
503
+ ---
504
+
505
+ ### mj bump
506
+
507
+ Bump `@memberjunction/*` dependency versions in `package.json` files.
508
+
509
+ ```bash
510
+ # Bump current directory's package.json to the current CLI version
511
+ mj bump
512
+
513
+ # Dry-run recursively across subdirectories with verbose logging
514
+ mj bump -rdv
515
+
516
+ # Recursively bump to a specific tag and output only modified package paths
517
+ mj bump -rqt v6.0.0 | xargs -n1 -I{} npm install --prefix {}
518
+ ```
519
+
520
+ | Flag | Short | Description |
521
+ |------|-------|-------------|
522
+ | `--recursive` | `-r` | Bump versions in current directory and all subdirectories |
523
+ | `--tag <ver>` | `-t` | Target version tag (defaults to the CLI's version) |
524
+ | `--dry` | `-d` | Dry run without writing `package.json` changes |
525
+ | `--quiet` | `-q` | Print only paths of updated packages |
526
+ | `--verbose` | `-v` | Enable additional logging |
527
+
528
+ ---
529
+
530
+ ### mj bundle
531
+
532
+ Create a self-contained MemberJunction distribution zip for offline/air-gapped installations.
533
+
534
+ ```bash
535
+ # Bundle latest branch tip into a distribution zip
536
+ mj bundle --out ./mj-install.zip
537
+
538
+ # Bundle a specific release tag with SQL Server + PostgreSQL migrations
539
+ mj bundle --tag v5.38.0 --with-migrations --out ./mj-install.zip
540
+
541
+ # Bundle from local working tree for PostgreSQL only, excluding the Claude Code pack
542
+ mj bundle --source . --with-migrations --db-platform postgresql --no-claude-pack --out ./mj-pg.zip
543
+ ```
245
544
 
246
- # Migrate to a specific version tag
247
- mj migrate --tag v2.10.0
545
+ | Flag | Short | Description |
546
+ |------|-------|-------------|
547
+ | `--out <path>` | `-o` | Output zip path (required) |
548
+ | `--tag <ver>` | `-t` | Release tag to bundle (defaults to latest branch tip) |
549
+ | `--source <dir>` | | Bundle from a local working-tree directory instead of GitHub |
550
+ | `--with-migrations` | | Include migration trees for offline `mj migrate` |
551
+ | `--db-platform <val>` | | With `--with-migrations`, ship only `sqlserver` or `postgresql` |
552
+ | `--no-claude-pack` | | Exclude the Claude Code pack (`CLAUDE.md` + `.claude/`) |
553
+ | `--verbose` | `-v` | Show detailed output |
554
+
555
+ ---
556
+
557
+ ### mj cache
558
+
559
+ Inspect and clear the shared Redis cache (`REDIS_URL`) so every running MJAPI server reloads fresh data from the database.
560
+
561
+ #### mj cache clear
562
+
563
+ ```bash
564
+ # Clear RunView, dataset, and metadata caches
565
+ mj cache clear
566
+
567
+ # Preview target Redis URL and per-category key counts without deleting
568
+ mj cache clear --dry-run
569
+
570
+ # Clear a single category (repeatable) or target a custom Redis URL/prefix
571
+ mj cache clear --category RunViewCache --prefix mj
572
+ mj cache clear --url redis://localhost:6379
573
+ ```
248
574
 
249
- # Migrate a custom schema with custom migrations directory
250
- mj migrate --schema __BCSaaS --dir ./migrations/v1
575
+ | Flag | Description |
576
+ |------|-------------|
577
+ | `--dry-run` | Report target and key counts per category without deleting |
578
+ | `--category <name>` | Specific cache category to clear (repeatable; case-insensitive) |
579
+ | `--url <redis-url>` | Redis URL override (default: `REDIS_URL`) |
580
+ | `--prefix <str>` | Key prefix override (default: `REDIS_KEY_PREFIX`, else `mj`) |
581
+
582
+ > `mj migrate`, `mj codegen`, and `mj sync push` clear the shared cache automatically when they modify the database and `REDIS_URL` is configured. Opt out with `--skip-cache-clear` or `MJ_SKIP_SHARED_CACHE_CLEAR=1`.
583
+
584
+ ---
585
+
586
+ ### mj clean
251
587
 
252
- # Verbose output for debugging
253
- mj migrate --verbose
588
+ Reset a MemberJunction database to a pre-installation state.
589
+
590
+ ```bash
591
+ mj clean
592
+ mj clean --verbose
254
593
  ```
255
594
 
595
+ Flags: `-v, --verbose`.
596
+
597
+ ---
598
+
256
599
  ### mj codegen
257
600
 
258
- Run MemberJunction code generation.
601
+ Run the full MemberJunction code generation pipeline (metadata sync, SQL objects, TypeScript entity subclasses, Angular forms, GraphQL resolvers, and DB schema JSON).
259
602
 
260
603
  ```bash
261
604
  # Run full code generation
262
605
  mj codegen
263
606
 
264
- # Generate class registration manifests only
607
+ # Regenerate code files only (skip database metadata/SQL pass) or database-only
608
+ mj codegen --skipdb
609
+ mj codegen --skipfiles
610
+
611
+ # Disable AI-driven advanced generation or skip configured shell hooks
612
+ mj codegen --no-ai --skip-commands
613
+
614
+ # Re-emit files for every schema and customize SQL output directory
615
+ mj codegen --all-schemas --sql-output-dir ./migrations/codegen
616
+ ```
617
+
618
+ Key flags on `mj codegen`: `--skipdb`, `--skipfiles`, `--force-advanced-gen`, `--no-ai` (`MJ_CODEGEN_NO_AI=1`), `--sql-output-dir <dir>`, `--all-schemas`, `--skip-commands` (`MJ_CODEGEN_SKIP_COMMANDS=1`), `--skip-cache-clear`, `--format`, `--no-banner`, `--no-app-packages`, `--[no-]interactive`, `-v, --verbose`.
619
+
620
+ #### mj codegen manifest
621
+
622
+ Generate a static class registration manifest so modern bundlers (ESBuild, Vite) do not tree-shake `@RegisterClass`-decorated classes.
623
+
624
+ ```bash
625
+ # Default manifest generation
265
626
  mj codegen manifest
266
- mj codegen manifest --exclude-packages @memberjunction --output ./src/generated/manifest.ts
627
+
628
+ # Generate a supplemental manifest excluding @memberjunction/* packages
629
+ mj codegen manifest --exclude-packages @memberjunction --no-sync-deps --output ./src/generated/manifest.ts
630
+
631
+ # Generate manifest + lazy-loading config + Open App client bootstrap for MJExplorer
632
+ mj codegen manifest --appDir ./packages/MJExplorer --output ./packages/MJExplorer/src/app/generated/class-registrations-manifest.ts --exclude-packages @memberjunction --lazy-config ./packages/MJExplorer/src/app/generated/lazy-feature-config.ts --open-app-client-bootstrap --strict
267
633
  ```
268
634
 
635
+ | Flag | Short | Description |
636
+ |------|-------|-------------|
637
+ | `--output <path>` | `-o` | Output manifest path (default `./src/generated/class-registrations-manifest.ts`) |
638
+ | `--appDir <dir>` | `-a` | Root directory whose `package.json` dependency tree is scanned |
639
+ | `--filter <base>` | `-f` | Only include classes extending this base class (repeatable) |
640
+ | `--exclude-packages <prefix>` | `-e` | Skip packages starting with prefix (repeatable) |
641
+ | `--no-sync-deps` | | Skip automatic `package.json` dependency reconciliation |
642
+ | `--scan-dist` | | Also scan compiled JS in `dist/` for npm-published packages without `src/` |
643
+ | `--lazy-config <path>` | | Emit a lazy-loading feature config file (requires `--exclude-packages`) |
644
+ | `--strict` | | Fail with non-zero exit if excluded packages have unreachable `@RegisterClass` gaps |
645
+ | `--open-app-client-bootstrap` | | Append Open App client side-effect imports and emit `public-pages.generated.ts` |
646
+ | `--quiet` / `--verbose` | `-q` / `-v` | Control output verbosity |
647
+
269
648
  #### v5.0 Entity Name Migration Commands
270
649
 
271
- Starting in MemberJunction v5.0, all 272 core entity names are being normalized with the `"MJ: "` prefix to prevent naming collisions on client systems (e.g., `"Actions"` becomes `"MJ: Actions"`). The database migration handles the rename automatically, but hardcoded entity name strings in your TypeScript source, Angular HTML templates, and metadata JSON files also need updating. These three commands automate that process.
650
+ Starting in MemberJunction v5.0, core entity names were normalized with the `"MJ: "` prefix (`"Actions"` → `"MJ: Actions"`) and generated entity classes gained the `MJ` prefix (`ActionEntity` → `MJActionEntity`). These three commands scan in dry-run mode by default and apply changes with `--fix`, building their rename map dynamically from `entity_subclasses.ts`:
272
651
 
273
- All three commands share the same workflow:
274
- 1. **Dry-run first** (default) -- scans and reports what would change, without modifying any files.
275
- 2. **Fix mode** (`--fix`) -- applies the changes in place.
276
- 3. **Rename map** -- built dynamically by parsing `@RegisterClass(BaseEntity, 'MJ: XYZ')` decorators from `entity_subclasses.ts`. No hardcoded list to maintain.
652
+ - **`mj codegen 5-0-fix-entity-names`** — AST + regex scanner for TypeScript (`.ts`) entity names and class/subclass renames.
653
+ - **`mj codegen 5-0-fix-html-entity-names`** — Targeted scanner for Angular HTML templates (`.html`).
654
+ - **`mj codegen 5-0-fix-metadata-names`** — Scanner for `metadata/` JSON files (including `.mj-sync.json`, `@lookup:`, and `relatedEntities`).
277
655
 
278
- > These commands will be kept for 1-2 years to support the v5.0 upgrade window, then removed.
656
+ ```bash
657
+ # 1. Dry-run scan across code, templates, and metadata
658
+ mj codegen 5-0-fix-entity-names --path packages/
659
+ mj codegen 5-0-fix-html-entity-names --path packages/Angular/
660
+ mj codegen 5-0-fix-metadata-names --path metadata/
279
661
 
280
- ##### mj codegen 5-0-fix-entity-names
662
+ # 2. Apply fixes in place
663
+ mj codegen 5-0-fix-entity-names --path packages/ --fix
664
+ mj codegen 5-0-fix-html-entity-names --path packages/Angular/ --fix
665
+ mj codegen 5-0-fix-metadata-names --path metadata/ --fix
666
+ ```
281
667
 
282
- Scans **TypeScript source files** (`.ts`) using the TypeScript compiler AST to find hardcoded entity names that need the `"MJ: "` prefix. This is the most comprehensive scanner -- it understands code context, not just string matching.
668
+ Common flags across all three commands: `-p, --path <dir|file>`, `--fix`, `--entity-subclasses <path>`, `-q, --quiet`, `-v, --verbose`.
283
669
 
284
- **Detected patterns:**
670
+ ---
285
671
 
286
- | Pattern | Example |
287
- |---------|---------|
288
- | `GetEntityObject` calls | `md.GetEntityObject<T>('Actions')` |
289
- | `OpenEntityRecord` calls | `this.OpenEntityRecord('Entities', id)` |
290
- | `navigateToEntity` calls | `navigateToEntity('Templates')` |
291
- | `BuildRelationshipViewParamsByEntityName` calls | `BuildRelationshipViewParamsByEntityName('Roles')` |
292
- | `NewRecordValues` calls | `NewRecordValues('Users')` |
293
- | `IsCurrentTab` calls | `IsCurrentTab('Queries')` |
294
- | `EntityName:` property assignments | `EntityName: 'AI Agent Examples'` |
295
- | `.Name ===` / `.Entity ===` comparisons | `entity.Name === 'Actions'` |
296
- | `@RegisterClass` decorator (BaseEntity) | `@RegisterClass(BaseEntity, 'Actions')` |
672
+ ### mj dbdoc
297
673
 
298
- **Default exclusions:** `node_modules`, `dist`, `build`, `.git`, `__tests__`, `*.d.ts`, `*.spec.ts`, `*.test.ts`, `generated/`, `Demos/`
674
+ AI-powered database documentation and sample-query generator (delegates to `@memberjunction/db-auto-doc`; `mj dbdoc` prints topic help).
299
675
 
300
676
  ```bash
301
- # Dry-run: scan entire packages/ directory
302
- mj codegen 5-0-fix-entity-names --path packages/
677
+ # Initialize a DBAutoDoc project
678
+ mj dbdoc init
303
679
 
304
- # Dry-run: scan a single file
305
- mj codegen 5-0-fix-entity-names --path packages/Angular/Explorer/dashboards/src/Actions/components/actions-overview.component.ts
680
+ # Analyze database schema (supports --resume, --config, --skip-sampling)
681
+ mj dbdoc analyze --config ./config.json
682
+ mj dbdoc analyze --resume ./output/run-6/state.json --skip-sampling
306
683
 
307
- # Apply fixes
308
- mj codegen 5-0-fix-entity-names --path packages/ --fix
684
+ # Check analysis status or reset state
685
+ mj dbdoc status --state-file ./db-doc-state.json
686
+ mj dbdoc reset --force
309
687
 
310
- # Custom entity_subclasses.ts location
311
- mj codegen 5-0-fix-entity-names --path packages/ --entity-subclasses ./path/to/entity_subclasses.ts
688
+ # Export documentation (SQL extended properties, Markdown, HTML, CSV, Mermaid ERDs, report)
689
+ mj dbdoc export --state-file ./db-doc-state.json --markdown --html --mermaid --erd-mode clusters --erd-columns keys
690
+ mj dbdoc export --sql --apply --approved-only --confidence-threshold 0.8
312
691
 
313
- # Quiet mode (summary only)
314
- mj codegen 5-0-fix-entity-names --path packages/ -q
692
+ # Generate sample SQL queries from analysis state and export to MJ metadata JSON
693
+ mj dbdoc generate-queries --from-state ./output/run-1/state.json --queries-per-table 10
694
+ mj dbdoc export-sample-queries --input ./output/sample-queries.json --output ./metadata/queries/.queries.json --separate-sql-files --category "Database Documentation" --status Pending --min-confidence 0.8 --validated-only
315
695
  ```
316
696
 
317
- ##### mj codegen 5-0-fix-html-entity-names
697
+ ---
318
698
 
319
- Scans **Angular HTML template files** (`.html`) using targeted regex patterns for entity name references in template expressions and attribute values.
699
+ ### mj dev
320
700
 
321
- **Detected patterns:**
701
+ Local multi-repo development tooling (`mj dev` displays domain help). Joins sibling clones (such as MJ and Open App repositories) into a single ephemeral pnpm workspace at their common parent directory so edits are live everywhere in ~1s with zero files committed to any repo. See [`guides/DEV_WORKSPACE_QUICKSTART.md`](../../guides/DEV_WORKSPACE_QUICKSTART.md).
322
702
 
323
- | Pattern | Example |
324
- |---------|---------|
325
- | Method calls in event/property bindings | `(click)="navigateToEntity('Actions')"` |
326
- | `OpenEntityRecord` / `openEntityRecord` | `(click)="OpenEntityRecord('Entities', id)"` |
327
- | `BuildRelationshipViewParamsByEntityName` | `[Params]="BuildRelationshipViewParamsByEntityName('Roles')"` |
328
- | `RowsEntityName` attribute | `RowsEntityName="Users"` |
329
- | `JoinEntityName` attribute | `JoinEntityName="Roles"` |
703
+ #### mj dev workspace
704
+
705
+ ```bash
706
+ # Auto-detect sibling MJ / Open App clones and generate the joined pnpm workspace
707
+ mj dev workspace --dir ~/code/mj-workspace
708
+
709
+ # Customize included/excluded repos or admit app shells
710
+ mj dev workspace --dir ~/code/mj-workspace --include bizapps-common --exclude bizapps-sonar
711
+ mj dev workspace --dir ~/code/mj-workspace --apps my-app=apps/API,apps/Explorer --clean-members
712
+
713
+ # Regenerate workspace files without running pnpm install
714
+ MJ_DEV_WORKSPACE_DIR=~/code/mj-workspace mj dev workspace --no-install --force
715
+ ```
716
+
717
+ | Flag | Description |
718
+ |------|-------------|
719
+ | `--dir <path>` | Parent directory holding sibling clones (must not be a git repo; env: `MJ_DEV_WORKSPACE_DIR`, default `.`) |
720
+ | `--include <dir>` | Repo directory name to include (repeatable) |
721
+ | `--exclude <dir>` | Repo directory name to exclude (repeatable) |
722
+ | `--apps <member=globs>` | Admit app-shell packages (`<member>=<glob>[,<glob>]`, repeatable) |
723
+ | `--[no-]install` | Run `pnpm install` at the parent after generating (default `true`) |
724
+ | `--force` | Overwrite existing workspace files (keeps `.bak` copies) |
725
+ | `--[no-]clean-members` | Remove member repos' standalone `node_modules` trees before parent install |
726
+ | `-v, --verbose` | Show detailed output |
330
727
 
331
- **Default exclusions:** `node_modules`, `dist`, `build`, `.git`, `generated/`, `Demos/`
728
+ #### mj dev workspace status / doctor / clean
332
729
 
333
730
  ```bash
334
- # Dry-run: scan Angular templates
335
- mj codegen 5-0-fix-html-entity-names --path packages/Angular/
731
+ # Read-only status summary of generated files, lockfile, sentinel, and members
732
+ mj dev workspace status --dir ~/code/mj-workspace
336
733
 
337
- # Apply fixes
338
- mj codegen 5-0-fix-html-entity-names --path packages/Angular/ --fix
734
+ # Read-only health check (duplicate singletons, standalone installs, stale builds)
735
+ mj dev workspace doctor --dir ~/code/mj-workspace
339
736
 
340
- # Verbose output showing individual file progress
341
- mj codegen 5-0-fix-html-entity-names --path packages/ -v
737
+ # Preview teardown, then remove generated workspace residue (repos untouched)
738
+ mj dev workspace clean --dir ~/code/mj-workspace --dry-run
739
+ mj dev workspace clean --dir ~/code/mj-workspace
342
740
  ```
343
741
 
344
- ##### mj codegen 5-0-fix-metadata-names
742
+ Flags: `--dir <path>` on all three; `--dry-run` and `--force` on `mj dev workspace clean`.
345
743
 
346
- Scans **metadata JSON files** (including dotfiles like `.mj-sync.json`) for entity name references that need the `"MJ: "` prefix. Targets the `metadata/` directory used by `mj sync`.
744
+ ---
347
745
 
348
- **Detected patterns:**
746
+ ### mj diag
349
747
 
350
- | Pattern | Example |
351
- |---------|---------|
352
- | `@lookup:` entity name | `@lookup:Entities.Name=Dashboards` |
353
- | `@lookup:` value (in Entities lookups) | `@lookup:MJ: Entities.Name=Actions` |
354
- | Folder config `entity`/`entityName` | `.mj-sync.json` with `"entity": "Dashboards"` |
355
- | `relatedEntities` object keys | `"relatedEntities": { "Actions": [...] }` |
356
- | `fields.Name` in Entities folders | Entity record data files where Name is the entity name |
748
+ Offline inspection, scrubbing, performance analysis, trace export, and key generation for MemberJunction `.mjdiag` diagnostic bundles (zero server bootstrap). See [`guides/DIAGNOSTIC_BUNDLES_GUIDE.md`](../../guides/DIAGNOSTIC_BUNDLES_GUIDE.md).
749
+
750
+ All commands that read bundles accept encrypted `MJDB` envelopes via `--private-key-file <path>`, `MJ_DIAG_PRIVATE_KEY` (preferred), or `--private-key <base64>`.
357
751
 
358
752
  ```bash
359
- # Dry-run: scan metadata directory
360
- mj codegen 5-0-fix-metadata-names --path metadata/
753
+ # Verify archive integrity and inspect bundle manifest/summary
754
+ mj diag inspect ./capture.mjdiag
755
+ mj diag inspect ./encrypted.mjdiag --private-key-file ./intake.key --json
361
756
 
362
- # Apply fixes
363
- mj codegen 5-0-fix-metadata-names --path metadata/ --fix
757
+ # Print a merged chronological timeline (client spans, server spans, SQL, breadcrumbs)
758
+ mj diag timeline ./capture.mjdiag --limit 100
759
+
760
+ # List slow client/server spans and SQL queries above a millisecond threshold
761
+ mj diag slow ./capture.mjdiag --threshold 250
364
762
 
365
- # Scan a specific subdirectory
366
- mj codegen 5-0-fix-metadata-names --path metadata/resource-types
763
+ # Export traces to Chrome Trace Event (ui.perfetto.dev) or OpenTelemetry OTLP JSON
764
+ mj diag export ./capture.mjdiag --perfetto -o ./trace-perfetto.json
765
+ mj diag export ./capture.mjdiag --otlp -o ./trace-otlp.json
367
766
 
368
- # Scan and fix a single file
369
- mj codegen 5-0-fix-metadata-names --path metadata/entities/.audit-related-entities.json --fix
767
+ # Re-scrub a bundle archive at Standard or FullRaw profile
768
+ mj diag scrub ./capture.mjdiag -o ./scrubbed.mjdiag --profile Standard
769
+
770
+ # Generate an X25519 collector keypair (and optional Ed25519 signing keypair) for an intake server
771
+ mj diag keygen --key-id intake-2026-01 --signing --json
370
772
  ```
371
773
 
372
- ##### Common flags (all three commands)
774
+ | Subcommand | Args & Key Flags |
775
+ |------------|------------------|
776
+ | `mj diag inspect <file>` | `--json`, `--private-key-file`, `--private-key` |
777
+ | `mj diag timeline <file>` | `-n, --limit <n>` (default `50`), `--private-key-file`, `--private-key` |
778
+ | `mj diag slow <file>` | `-t, --threshold <ms>` (default `500`), `--private-key-file`, `--private-key` |
779
+ | `mj diag export <file>` | `-o, --output <path>` (required), `--perfetto`, `--otlp`, `--private-key-file`, `--private-key` |
780
+ | `mj diag scrub <file>` | `-o, --output <path>` (required), `--profile <Standard\|FullRaw>`, `--private-key-file`, `--private-key` |
781
+ | `mj diag keygen` | `--key-id <kid>`, `--signing`, `--json` |
782
+
783
+ ---
784
+
785
+ ### mj doctor
786
+
787
+ Diagnose a MemberJunction installation and check for metadata/data drift.
788
+
789
+ #### mj doctor
790
+
791
+ ```bash
792
+ # Run full installation diagnostics in current directory
793
+ mj doctor
794
+
795
+ # Filter to a specific diagnostic scope or emit machine-readable JSON
796
+ mj doctor --dir ./my-mj-project --scope ai --verbose
797
+ mj doctor --format json
798
+
799
+ # Generate a shareable support report (or extended report with service startup logs)
800
+ mj doctor --report
801
+ mj doctor --report_extended
802
+ ```
373
803
 
374
804
  | Flag | Short | Description |
375
805
  |------|-------|-------------|
376
- | `--path <dir\|file>` | `-p` | File or directory to scan. Defaults to current directory. |
377
- | `--fix` | | Apply fixes in place. Without this flag, runs in dry-run mode. |
378
- | `--entity-subclasses <path>` | | Path to `entity_subclasses.ts`. Auto-detected if omitted. |
379
- | `--quiet` | `-q` | Suppress detailed output, show summary only. |
380
- | `--verbose` | `-v` | Show detailed progress for each file scanned. |
806
+ | `--dir <path>` | | Target directory to diagnose (default `.`) |
807
+ | `--scope <name>` | | Filter diagnostics: `install \| runtime \| ai \| metadata \| agent` |
808
+ | `--format` | | Output format (`text \| json \| md`) |
809
+ | `--verbose` | `-v` | Show detailed output with inline suggested fixes |
810
+ | `--report` | `-r` | Write `mj-diagnostic-report.md` |
811
+ | `--report_extended` | | Extended report with config snapshots and startup log capture |
812
+
813
+ #### mj doctor value-lists
381
814
 
382
- ##### Recommended migration workflow
815
+ Find database rows whose closed value-list (`ValueListType = List`) fields contain values outside their configured list (which fail validation on next save). Read-only unless `--fix` names specific `Entity.Field` targets.
383
816
 
384
817
  ```bash
385
- # 1. Scan everything first (dry-run)
386
- mj codegen 5-0-fix-entity-names --path packages/
387
- mj codegen 5-0-fix-html-entity-names --path packages/
388
- mj codegen 5-0-fix-metadata-names --path metadata/
818
+ # Scan all entities (read-only)
819
+ mj doctor value-lists
389
820
 
390
- # 2. Review the output, then apply
391
- mj codegen 5-0-fix-entity-names --path packages/ --fix
392
- mj codegen 5-0-fix-html-entity-names --path packages/ --fix
393
- mj codegen 5-0-fix-metadata-names --path metadata/ --fix
821
+ # Scan specific entities and fail CI if findings exist
822
+ mj doctor value-lists --entity "MJ: AI Agents" --format json --fail-on-findings
394
823
 
395
- # 3. Build and test
396
- npm run build
824
+ # Relax named fields to ListOrUserEntry through the entity layer
825
+ mj doctor value-lists --fix "Projects.Phase,Projects.Status"
397
826
  ```
398
827
 
399
- ### mj sync
828
+ Flags: `--entity <name>` (repeatable), `--format`, `--fail-on-findings`, `--fix <Entity.Field,...>` (repeatable).
829
+
830
+ ---
831
+
832
+ ### mj explorer
833
+
834
+ Post-build tasks for MJ Explorer hosts.
400
835
 
401
- Metadata synchronization between JSON files and the database.
836
+ #### mj explorer postbuild
837
+
838
+ Run as MJ Explorer's `postbuild` script after `ng build`: verifies the service worker cache list, emits one HTML file per public page (`public-pages/<slug>.html` plus `_fallback.html`) from `mj.config` `publicPages` with title/preview/CSP headers, and updates `staticwebapp.config.json` rewrites when present.
402
839
 
403
840
  ```bash
404
- # Initialize metadata directory
405
- mj sync init
841
+ mj explorer postbuild --dir dist/MJExplorer/browser
842
+ mj explorer postbuild --dir dist/MJExplorer/browser --quiet
843
+ ```
844
+
845
+ Flags: `--dir <path>` (required), `-q, --quiet`.
846
+
847
+ ---
406
848
 
407
- # Check sync status
408
- mj sync status
849
+ ### mj harness
409
850
 
410
- # Pull metadata from database to files
411
- mj sync pull
851
+ Manage external agent harness CLI subscription account pools, `1 + N` multi-account auto-balancing, interactive logins, and quota cooldown controls (`mj harness` and `mj harness account` print domain/topic help). Works across **Claude Code** (`claude`), **Antigravity** (`agy`), **OpenAI Codex** (`codex`), and **Gemini CLI** (`gemini`) with zero server bootstrap. See [`guides/AGENT_HARNESS_GUIDE.md`](../../guides/AGENT_HARNESS_GUIDE.md).
412
852
 
413
- # Push metadata from files to database
414
- mj sync push
853
+ Pool data is stored under `~/.mj/harness-accounts` by default and can be overridden globally with `MJ_HARNESS_ACCOUNT_POOL_DIR` or per command with `--pool-dir <path>`. Your existing OS `$HOME` login is automatically included as a synthetic `os-default-<vendor>` slot alongside any additional isolated accounts you enroll (`1 + N` hybrid pooling).
415
854
 
416
- # Validate metadata files
417
- mj sync validate
855
+ #### Practical multi-account setup & balancing workflow
418
856
 
419
- # Watch for file changes
420
- mj sync watch
857
+ ```bash
858
+ # 1. Inspect existing OS-default and enrolled slots (also probes live `<binary> --version` health)
859
+ mj harness account list
860
+ mj harness account list --vendor claude --json
861
+
862
+ # 2. Enroll extra isolated accounts across vendors (launches each vendor's interactive OAuth login)
863
+ mj harness account add claude --label "Pro #2" --weight 2 --priority 50
864
+ mj harness account add agy --label "Team Seat"
865
+ mj harness account add codex --label "Codex #2" --no-login
866
+ mj harness account add gemini --label "Gemini Alt"
867
+
868
+ # 3. Choose the default pool balancing strategy:
869
+ # least-in-flight (default) | weighted | round-robin | priority-failover
870
+ mj harness account set-strategy least-in-flight
871
+ mj harness account set-strategy weighted
872
+ mj harness account set-strategy round-robin
873
+ mj harness account set-strategy priority-failover
874
+
875
+ # 4. Re-authenticate a slot (clears active cooldown) or manage cooldown / enabled state
876
+ mj harness account login claude-pro-2
877
+ mj harness account clear-cooldown claude-pro-2
878
+ mj harness account disable os-default-claude
879
+ mj harness account enable os-default-claude
880
+
881
+ # 5. Remove an enrolled slot (add --purge-files to delete its isolated directory too)
882
+ mj harness account remove codex-codex-2 --purge-files
883
+
884
+ # 6. Target an isolated pool directory (e.g. per-team or CI runner)
885
+ MJ_HARNESS_ACCOUNT_POOL_DIR=/srv/mj-harness-pool mj harness account list
886
+ ```
887
+
888
+ #### Auth status & live binary health probing
889
+
890
+ `mj harness account list` verifies both credential presence and CLI executability (`<binary> --version`) for every listed vendor:
891
+
892
+ | `AUTH` Status | Meaning |
893
+ |---------------|---------|
894
+ | `Ready` | Credentials exist for the slot and `<binary> --version` succeeded. |
895
+ | `Binary Missing` | Credentials may exist on disk, but the vendor CLI binary is missing or broken (`<binary> --version` failed). Install or repair the CLI before leasing turns. |
896
+ | `Needs Login` | CLI binary is runnable, but the slot has no active login session yet (`mj harness account login <slotId>`). |
897
+
898
+ #### Subcommands & flags
899
+
900
+ | Subcommand | Args & Key Flags |
901
+ |------------|------------------|
902
+ | `mj harness account list` | `-v, --vendor <claude\|agy\|codex\|gemini>`, `--json`, `--pool-dir <dir>` |
903
+ | `mj harness account add <vendor>` | `-l, --label <name>`, `--slot-id <id>`, `-w, --weight <n>` (default `1`), `-p, --priority <n>` (default `100`), `--no-login`, `--oauth-token <tok>`, `--pool-dir <dir>` |
904
+ | `mj harness account login <slotId>` | `--pool-dir <dir>` |
905
+ | `mj harness account remove <slotId>` | `--purge-files`, `--pool-dir <dir>` |
906
+ | `mj harness account set-strategy <strategy>` | `strategy`: `least-in-flight \| round-robin \| weighted \| priority-failover`; `--pool-dir <dir>` |
907
+ | `mj harness account enable <slotId>` | `--pool-dir <dir>` |
908
+ | `mj harness account disable <slotId>` | `--pool-dir <dir>` |
909
+ | `mj harness account clear-cooldown <slotId>` | `--pool-dir <dir>` |
910
+
911
+ ---
912
+
913
+ ### mj install
914
+
915
+ Install MemberJunction from a GitHub release, or seed the MemberJunction Claude Code pack into an existing project.
421
916
 
422
- # Reset file state
423
- mj sync file-reset
917
+ #### mj install
918
+
919
+ ```bash
920
+ # Interactive installer (shows version picker)
921
+ mj install
922
+
923
+ # Non-interactive install of a specific release tag (or preview with --dry-run)
924
+ mj install -t v6.0.0 --dir ./my-mj-app --yes
925
+ mj install --dry-run
926
+
927
+ # Config-driven install, skipping DB provisioning or startup smoke tests
928
+ mj install -c ./install-config.json --skip-db --skip-start --fast
424
929
  ```
425
930
 
426
- ### mj ai
931
+ Key flags: `-t, --tag <ver>`, `--dir <path>`, `-c, --config <file>`, `--dry-run`, `-y, --yes`, `-v, --verbose`, `--skip-db`, `--skip-start`, `--no-resume`, `--fast`, `--overwrite-config`, `--monorepo`, `--no-claude-pack`.
427
932
 
428
- AI-powered operations.
933
+ #### mj install claude
934
+
935
+ Install or refresh the MemberJunction Claude Code pack (`CLAUDE.md` managed block, `.claude/commands/`, `.claude/skills/`, and `.claude/settings.json`) in a directory.
429
936
 
430
937
  ```bash
431
- mj ai
938
+ mj install claude
939
+ mj install claude --dry-run
940
+ mj install claude --from ./local-pack --offline --json
432
941
  ```
433
942
 
434
- ### mj test
943
+ Key flags: `--dir <path>`, `--major <n>`, `--ref <git-ref>`, `--from <path>`, `--offline`, `--dry-run`, `-y, --yes`, `--force`, `--skip-commands`, `--skip-skills`, `--skip-settings`, `--json`, `-v, --verbose`.
944
+
945
+ ---
946
+
947
+ ### mj migrate
435
948
 
436
- Testing framework operations (delegates to `@memberjunction/testing-cli`).
949
+ Create, execute, convert, and rebake database migrations (powered by [Skyway](https://github.com/MemberJunction/skyway)). See [`guides/MIGRATION_CODEGEN_WORKFLOW_GUIDE.md`](../../guides/MIGRATION_CODEGEN_WORKFLOW_GUIDE.md).
950
+
951
+ #### mj migrate
437
952
 
438
953
  ```bash
439
- # Run a test
440
- mj test run --name "My Test"
954
+ # Apply pending migrations using mj.config.cjs
955
+ mj migrate
441
956
 
442
- # Run a suite
443
- mj test suite --name "My Suite"
957
+ # Verify database connectivity and TLS without migrating
958
+ mj migrate --check-connection
444
959
 
445
- # List tests
446
- mj test list
960
+ # Migrate a specific schema and directory (or remote version tag)
961
+ mj migrate --schema __my_app --dir ./migrations/v1 --verbose
962
+ mj migrate --schema __my_app --tag v1.0.0 --skip-cache-clear
963
+ ```
447
964
 
448
- # View history
449
- mj test history --name "My Test"
965
+ | Flag | Short | Description |
966
+ |------|-------|-------------|
967
+ | `--verbose` | `-v` | Enable detailed logging |
968
+ | `--tag <version>` | `-t` | Version tag for remote migrations |
969
+ | `--schema <name>` | `-s` | Target schema (overrides `coreSchema` / `mj-app.json` auto-detection; auto-created if missing) |
970
+ | `--dir <path>` | | Migration source directory override |
971
+ | `--check-connection` | | Verify DB connection and TLS, then exit without migrating |
972
+ | `--skip-cache-clear` | | Skip automatic Redis cache clear after applying migrations (`MJ_SKIP_SHARED_CACHE_CLEAR=1`) |
450
973
 
451
- # Compare runs
452
- mj test compare --run1 id1 --run2 id2
974
+ Request timeout defaults to 30 minutes per batch; override with `MJ_MIGRATION_REQUEST_TIMEOUT` (ms) or `dbRequestTimeout` in `mj.config.cjs`.
453
975
 
454
- # Validate test config
455
- mj test validate --name "My Test"
976
+ #### mj migrate create
977
+
978
+ Scaffold a timestamped migration file for SQL Server or PostgreSQL.
979
+
980
+ ```bash
981
+ mj migrate create "Add Priority To Tasks"
982
+ mj migrate create "Add Priority To Tasks" --version 6.2 --platform postgresql --dir ./migrations-pg/v6
456
983
  ```
457
984
 
458
- ### mj dbdoc
985
+ Args & flags: `<description>` (required), `-v, --version <M.N>`, `-p, --platform <sqlserver|postgresql>`, `--dir <path>`, `--x-x`.
986
+
987
+ #### mj migrate convert
459
988
 
460
- Database documentation generation.
989
+ Convert T-SQL migrations to PostgreSQL. The standard path uses `--split` (AST-transpiles hand DDL and converts `mj-sync` logs inline), optionally with `--bake-codegen` to bake native PostgreSQL CodeGen objects inline against a live PG database so deployments run with `mj migrate` alone.
461
990
 
462
991
  ```bash
463
- # Initialize documentation
464
- mj dbdoc init
992
+ # Standard split-and-regenerate conversion
993
+ mj migrate convert --split --dry-run
994
+ mj migrate convert --split --file V202604060452__v5.24.x__KnowledgeHub.sql
995
+
996
+ # Bake native PostgreSQL CodeGen inline against a seeded PG database
997
+ mj migrate convert --split --bake-codegen --source-dir ./migrations/v6 --output-dir ./migrations-pg/v6
998
+
999
+ # Open App conversion with distinct app schema and core schema
1000
+ mj migrate convert --split --schema __mj_MyApp --core-schema __mj --source-dir ./migrations/v1 --output-dir ./migrations-pg/v1
1001
+ ```
1002
+
1003
+ Key flags: `--source-dir`, `--output-dir`, `--file <name>`, `--schema <name>` (default `__mj`), `--core-schema <name>` (default `__mj`), `--split`, `--bake-codegen`, `--allow-gaps`, `--dry-run`, `--no-header`, `-v, --verbose`.
1004
+
1005
+ #### mj migrate rebake
1006
+
1007
+ Re-bake post-baseline PostgreSQL migrations with fresh inline native CodeGen while keeping committed hand-written DDL regions byte-for-byte intact.
1008
+
1009
+ ```bash
1010
+ # Dry-run preview of post-baseline migrations that would be rebaked
1011
+ mj migrate rebake --dry-run
1012
+
1013
+ # Re-bake all post-baseline migrations and write output
1014
+ mj migrate rebake --baseline-floor V202605291452 --write
1015
+
1016
+ # Capture CodeGen for a single already-applied PG migration
1017
+ mj migrate rebake --file V202611031700__v6.2.x__Example.sql --capture-only
1018
+ ```
1019
+
1020
+ Key flags: `--source-dir`, `--output-dir`, `--schema`, `--core-schema`, `--baseline-floor <ver>`, `--file <name>`, `--capture-only`, `--write`, `--dry-run`.
465
1021
 
466
- # Analyze database schema
467
- mj dbdoc analyze
1022
+ ---
468
1023
 
469
- # Export documentation
470
- mj dbdoc export
1024
+ ### mj plugin
471
1025
 
472
- # Check status
473
- mj dbdoc status
1026
+ Register third-party CLI plugins so `mj` loads them automatically at startup.
474
1027
 
475
- # Reset documentation
476
- mj dbdoc reset
1028
+ #### mj plugin add
477
1029
 
478
- # Generate sample queries
479
- mj dbdoc generate-queries
480
- mj dbdoc export-sample-queries
1030
+ ```bash
1031
+ mj plugin add @my-org/mj-plugin/plugins
1032
+ mj plugin add ./local-plugins/my-tool --format json
481
1033
  ```
482
1034
 
1035
+ Args & flags: `<package>` (required — npm package name, subpath, or relative path), `--format <text|json>`.
1036
+
1037
+ ---
1038
+
483
1039
  ### mj query
484
1040
 
485
- Saved query maintenance.
1041
+ Saved query metadata maintenance.
486
1042
 
487
1043
  #### mj query refresh
488
1044
 
489
- Re-establishes saved queries' parameters, fields, entities and dependencies from their SQL and the database server. The SQL itself is never changed. It runs the same extraction that saving an edited query runs: each query is described on the database server and parsed, the child rows are corrected, and the query's `ExtractedSQLHash`, `ExtractionStatus` and `ExtractionMessage` are updated. Authored annotations (descriptions, and a `Manual` parameter's type, default, sample value and filters) are kept.
1045
+ Re-establishes saved queries' extracted parameters, fields, entities, and dependencies from their SQL and the database server without modifying the SQL itself. Authored annotations (descriptions and manual parameter metadata) are preserved.
490
1046
 
491
1047
  ```bash
492
- # Recommended after upgrading: review first, then apply
1048
+ # Recommended after upgrading: preview first, then apply
493
1049
  mj query refresh --all --dry-run
494
1050
  mj query refresh --all
495
1051
 
496
- # One query by full path, or every query with a bare name
1052
+ # Target specific queries by path, category, entity, or ID
497
1053
  mj query refresh --name "MJ/Reports/Top Customers"
498
-
499
- # A category and everything below it, filling empty descriptions with the LLM
500
1054
  mj query refresh --category MJ --with-ai
501
-
502
- # Every query that reads an entity
503
- mj query refresh --entity "MJ: AI Agents"
1055
+ mj query refresh --entity "MJ: AI Agents" --verbose
504
1056
  ```
505
1057
 
506
1058
  | Flag | Description |
507
1059
  |------|-------------|
508
- | `--id <id>` | Refresh the query with this ID. Repeatable. |
509
- | `--name <name>` | A query name or a full path `Category/Sub/Name`. A bare name selects every query with that name. Repeatable. |
510
- | `--category <path>` | A category path: the queries in it and in every category below it. Given once. |
511
- | `--entity <name>` | The queries that read this entity. Repeatable. |
512
- | `--all` | Refresh every query. |
513
- | `--dry-run` | Report the changes without writing anything. |
514
- | `--with-ai` | Fill empty descriptions with the LLM description pass (off by default). |
515
- | `-v`, `--verbose` | Also list queries that are unchanged. |
516
- | `--format <text\|json>` | Output format (default `text`). `json` prints the full run report. |
1060
+ | `--id <id>` | Refresh the query with this ID (repeatable) |
1061
+ | `--name <name>` | Query name or full path `Category/Sub/Name` (repeatable) |
1062
+ | `--category <path>` | Category path and all descendant categories |
1063
+ | `--entity <name>` | Queries that read this entity (repeatable) |
1064
+ | `--all` | Refresh every query |
1065
+ | `--dry-run` | Report changes without writing |
1066
+ | `--with-ai` | Fill empty descriptions via LLM (off by default) |
1067
+ | `-v, --verbose` | Also list unchanged queries |
1068
+ | `--format <text\|json>` | Output format (default `text`) |
1069
+
1070
+ Exit codes: `0` (all refreshed/unchanged/skipped), `1` (a query failed or `--id`/`--name` matched nothing), `2` (no selector flag given).
1071
+
1072
+ ---
1073
+
1074
+ ### mj querygen
517
1075
 
518
- At least one of `--id`, `--name`, `--category`, `--entity` or `--all` is required. The selectors are not mutually exclusive: when several are given, the queries any of them select are refreshed. Each query is refreshed in its own transaction, and the queries a composition depends on are refreshed before the queries that compose them.
1076
+ AI-assisted stored query template generation, validation, and export (delegates to `@memberjunction/query-gen`).
519
1077
 
520
- **Output.** Progress goes to stderr, one line per query (`[3/31] Refreshed AIUsageHourly`). The report goes to stdout: one heading per query with its outcome and extraction status, then its changes, then a summary line:
1078
+ ```bash
1079
+ # Generate SQL query templates for specific entities
1080
+ mj querygen generate --entities "Customers,Orders" --max-entities 5 --mode metadata --verbose
1081
+
1082
+ # Validate query templates in metadata files
1083
+ mj querygen validate --path ./metadata/queries --verbose
521
1084
 
522
- ```text
523
- WOULD REFRESH "AIUsageHourly" (<query ID>) [OK]
524
- + field CacheReadTokens
525
- ~ parameter start (Type)
526
- - entity MJ: AI Models
527
- ! parameter scope: authored, no longer used by the SQL (kept)
528
- 31 queries: 1 would be refreshed, 30 unchanged, 0 failed (dry run: nothing was written).
1085
+ # Export queries from database to metadata files
1086
+ mj querygen export --output ./metadata/queries --verbose
529
1087
  ```
530
1088
 
531
- `+`, `~` and `-` mark child rows added, updated (with the changed columns) and removed; `~ query (...)` lists changed columns on the query row itself. The outcomes are `REFRESHED` (`WOULD REFRESH` in a dry run), `UNCHANGED`, `NOTPERMITTED`, `UNAVAILABLE` and `FAILED`. Without `--verbose`, unchanged queries with no diagnostics are left out. A failed query reports the reason, and nothing is written for it.
1089
+ Key flags on `mj querygen generate`: `-e, --entities <csv>`, `-x, --exclude-entities <csv>`, `-s, --exclude-schemas <csv>`, `-m, --max-entities <n>` (default `3`), `-t, --target-groups <n>` (default `75`), `-r, --max-refinements <n>` (default `3`), `-f, --max-fixes <n>` (default `5`), `--model`, `--vendor`, `-o, --output <dir>`, `--mode <metadata|database|both>`, `-v, --verbose`.
1090
+
1091
+ ---
532
1092
 
533
- **Exit codes.**
1093
+ ### mj queue
534
1094
 
535
- | Code | Meaning |
536
- |------|---------|
537
- | `0` | Every selected query was refreshed, was unchanged, or was skipped as not permitted. |
538
- | `1` | A query failed, or an `--id` or `--name` you gave matched no query you can read. |
539
- | `2` | No selector flag was given. |
1095
+ Operate MemberJunction's durable work queue (`mj queue` prints domain help and examples). See [`guides/WORK_QUEUE_CONSUMER_GUIDE.md`](../../guides/WORK_QUEUE_CONSUMER_GUIDE.md).
1096
+
1097
+ ```bash
1098
+ # Publish one or more messages to a topic (supports partition & dedup keys)
1099
+ mj queue publish --topic samples.hello --payload '{"name":"Alex"}'
1100
+ mj queue publish --topic samples.hello --count 5 --partition-key customer-42 --dedup-key batch-1 --attribute source=cli
1101
+
1102
+ # Inspect subscription counts, autoscaler backlog, and blocked partitions
1103
+ mj queue stats
1104
+ mj queue stats --subscription email.unsubscribe --json
1105
+ mj queue backlog --subscription venue-import --json
1106
+ mj queue partitions --subscription integration.apply --condition Blocked
1107
+
1108
+ # Inspect, replay, or discard dead-lettered / in-flight deliveries
1109
+ mj queue dead-letters --subscription integration.apply --page-size 20
1110
+ mj queue replay --subscription integration.apply --delivery <delivery-id> --note "mapping fixed"
1111
+ mj queue discard --subscription integration.apply --delivery <delivery-id> --reason "bad batch, republished"
1112
+
1113
+ # Run container-job or long-running workers and manual sweeper passes
1114
+ mj queue work --subscription venue-import --once --max 5 --concurrency 2 --max-duration-ms 3300000
1115
+ mj queue work --subscription "*" --concurrency 4
1116
+ mj queue sweep --json
1117
+
1118
+ # Cloud transport topology & Terraform binding lifecycle
1119
+ mj queue export-topology --transport AWS-prod --output infrastructure/work-queue/manifest.json
1120
+ mj queue import-bindings bindings.json
1121
+ mj queue validate-bindings --transport AWS-prod
1122
+ ```
540
1123
 
541
- **Permissions.** A refresh, including a dry run, needs Update on `MJ: Queries` and Create, Update and Delete on `MJ: Query Fields`, `MJ: Query Parameters`, `MJ: Query Entities` and `MJ: Query Dependencies`. For each query it also needs read access to every entity the query reads, with no field denied on any of them. A query that fails these checks is reported as `NOTPERMITTED` in a bulk run, with no reason given. `mj query refresh` runs in process as the System user, using the database connection in `mj.config.cjs`; the same checks apply when a refresh is started from MJAPI or Explorer as a signed-in user.
1124
+ | Subcommand | Key Flags / Args |
1125
+ |------------|------------------|
1126
+ | `mj queue publish` | `-t, --topic` (req), `-p, --payload`, `-k, --partition-key`, `--dedup-key`, `-a, --attribute <k=v>` (repeatable), `-n, --count`, `--json` |
1127
+ | `mj queue stats` | `-s, --subscription`, `--json` |
1128
+ | `mj queue backlog` | `-s, --subscription` (req), `--json` |
1129
+ | `mj queue partitions` | `-s, --subscription` (req), `--condition <Idle\|InFlight\|Blocked>`, `--cursor`, `--page-size`, `--json` |
1130
+ | `mj queue dead-letters` | `-s, --subscription` (req), `--cursor`, `--page-size`, `--json` |
1131
+ | `mj queue replay` | `-s, --subscription` (req), `-d, --delivery` (req), `--note` |
1132
+ | `mj queue discard` | `-s, --subscription` (req), `-d, --delivery` (req), `-r, --reason` (req) |
1133
+ | `mj queue work` | `-s, --subscription` (req, or `*`), `--once`, `--max`, `--idle-exit-ms`, `--max-duration-ms`, `--concurrency`, `--shutdown-drain-ms`, `--sweeper-interval-ms`, `--reconcile-interval-ms` |
1134
+ | `mj queue sweep` | `--json` |
1135
+ | `mj queue export-topology` | `-t, --transport` (req), `-o, --output` |
1136
+ | `mj queue import-bindings <file>` | `--json` |
1137
+ | `mj queue validate-bindings` | `-t, --transport`, `--json` |
542
1138
 
543
- #### mj query usage
1139
+ ---
544
1140
 
545
- Prints every `mj query` command with its flags, examples and runtime hints. `--format` takes `text`, `json` or `md`; it defaults to `text` on a terminal and `json` when stdout is piped.
1141
+ ### mj rubric
1142
+
1143
+ List, inspect, diff, validate, and evaluate versioned scoring rubrics (`mj rubric` displays topic help). See [`guides/RUBRICS_GUIDE.md`](../../guides/RUBRICS_GUIDE.md).
546
1144
 
547
1145
  ```bash
548
- mj query usage
549
- mj query usage --format=json
1146
+ # List all rubrics
1147
+ mj rubric list
1148
+
1149
+ # Show a rubric (optionally pinned to @version) and its criteria
1150
+ mj rubric show "Agent Quality"
1151
+ mj rubric show "Agent Quality@1.2.0"
1152
+
1153
+ # Diff two versions of a rubric
1154
+ mj rubric diff "Agent Quality" 1.1.0 1.2.0
1155
+
1156
+ # Validate a rubric JSON snapshot file locally (duplicate keys, gates, weights, scales)
1157
+ mj rubric validate ./rubric-publications/agent-quality.json
1158
+
1159
+ # Evaluate a single entity record against a rubric (does not publish)
1160
+ mj rubric evaluate --rubric "Agent Quality@1.2.0" --entity "MJ: AI Agent Runs" --record <record-id> --evaluator LLM --mode SinglePass
550
1161
  ```
551
1162
 
552
- ### mj querygen
1163
+ Flags on `mj rubric evaluate`: `--rubric <name|id[@ver]>` (required), `--entity <name>` (required), `--record <id>` (required), `--evaluator <LLM|Decision|Agent|Deterministic|custom>` (default `LLM`), `--prompt <name>`, `--model <id>`, `--mode <SinglePass|PerCriterion>`.
1164
+
1165
+ ---
1166
+
1167
+ ### mj sql-audit
553
1168
 
554
- Query generation tools.
1169
+ Compare source and target databases (e.g. SQL Server vs PostgreSQL) for migration verification.
555
1170
 
556
1171
  ```bash
557
- mj querygen generate
558
- mj querygen export
559
- mj querygen validate
1172
+ mj sql-audit --source "mssql://sa:pass@host/db" --target "postgres://user:pass@host:5432/db"
1173
+ mj sql-audit --source "mssql://..." --target "postgres://..." --source-schema __mj --target-schema __mj --output report.txt
560
1174
  ```
561
1175
 
562
- ### mj bump
1176
+ Flags: `--source <conn>` (required), `--target <conn>` (required), `--source-schema <name>` (default `__mj`), `--target-schema <name>` (default `__mj`), `-o, --output <file>`.
1177
+
1178
+ ---
1179
+
1180
+ ### mj sql-convert
563
1181
 
564
- Version management for packages.
1182
+ Convert standalone SQL files between database dialects using the rule-based `BatchConverter` engine.
565
1183
 
566
1184
  ```bash
567
- mj bump
1185
+ mj sql-convert ./migration.sql --from tsql --to postgres
1186
+ mj sql-convert ./migration.sql --from tsql --to postgres --output converted.sql --schema my_schema --no-header --verbose
568
1187
  ```
569
1188
 
570
- ### mj clean
1189
+ Args & flags: `<source>` (required), `--from <dialect>` (required), `--to <dialect>` (required), `-o, --output <path>`, `--schema <name>` (default `__mj`), `--no-header`, `--no-post-process`, `-v, --verbose`.
1190
+
1191
+ ---
571
1192
 
572
- Clean build artifacts.
1193
+ ### mj standards
1194
+
1195
+ List, adopt, and check MemberJunction repository engineering standards (such as `ui-layers`, `naming-conventions`, `polymorphic-fk`, `migration-existence-guards`, `readable-status-values`, `migration-string-collation`, `agent-skill-governance`, and `limits-literals`).
573
1196
 
574
1197
  ```bash
575
- mj clean
1198
+ # List all available standards and this repository's adoption stance
1199
+ mj standards list --verbose
1200
+
1201
+ # Run all adopted standards (or target one check; add --strict to fail on warnings)
1202
+ mj standards check
1203
+ mj standards check --check naming-conventions --strict
1204
+ mj standards check --quiet
1205
+
1206
+ # Adopt standards into a repository (config + optional GitHub Actions workflow + npm script)
1207
+ mj standards adopt --ci github --declare-compliant
1208
+ mj standards adopt --upgrade --dry-run
576
1209
  ```
577
1210
 
578
- ### mj app
1211
+ | Subcommand | Key Flags |
1212
+ |------------|-----------|
1213
+ | `mj standards list` | `--cwd <dir>`, `-v, --verbose` |
1214
+ | `mj standards check` | `--cwd <dir>`, `--check <id>` (repeatable), `--strict`, `--quiet` |
1215
+ | `mj standards adopt` | `--cwd <dir>`, `--check <id>` (repeatable), `--ci <github\|none>`, `--[no-]npm-script`, `--declare-compliant`, `--upgrade`, `--dry-run` |
1216
+
1217
+ ---
1218
+
1219
+ ### mj sync
579
1220
 
580
- Install, upgrade, and manage MJ Open Apps (packaged via `@memberjunction/open-app-engine`).
1221
+ Synchronize metadata between local JSON files and the database (delegates to `@memberjunction/metadata-sync`).
581
1222
 
582
1223
  ```bash
583
- # List installed apps
584
- mj app list
1224
+ # Initialize a metadata directory (prompts at a terminal; scriptable with --setup-entity)
1225
+ mj sync init
1226
+ mj sync init --setup-entity=ai-prompts
1227
+ mj sync init --setup-entity=other --entity="MJ: AI Models" --dir=ai-models --no-interactive
585
1228
 
586
- # Show detailed info for one app
587
- mj app info <name>
1229
+ # Check status of local files vs database
1230
+ mj sync status --dir="ai-prompts" --verbose
588
1231
 
589
- # Install from a GitHub repository
590
- mj app install https://github.com/acme/mj-crm
591
- mj app install https://github.com/acme/mj-crm --version 1.2.0
1232
+ # Pull metadata from database to local files
1233
+ mj sync pull --entity="MJ: AI Prompts" --dry-run
1234
+ mj sync pull --entity="MJ: AI Prompts" --incremental --merge-strategy=merge --backup-before-update
592
1235
 
593
- # Upgrade to a newer version (latest if --version omitted)
594
- mj app upgrade acme-crm
595
- mj app upgrade acme-crm --version 1.3.0
1236
+ # Push local metadata files to database (atomic single transaction by default)
1237
+ mj sync push --dir="metadata" --dry-run
1238
+ mj sync push --dir="metadata" --ci --incremental
1239
+ mj sync push --isolated-transactions --parallel-batch-size=10 --change-detail
596
1240
 
597
- # Enable / disable without removing
598
- mj app enable <name>
599
- mj app disable <name>
1241
+ # Validate metadata files and optionally write a markdown report
1242
+ mj sync validate --dir="metadata" --save-report --output=validation-report.md
600
1243
 
601
- # Remove (add --keep-data to preserve the schema)
602
- mj app remove <name>
603
- mj app remove <name> --keep-data
1244
+ # Watch for file changes and sync automatically
1245
+ mj sync watch --dir="ai-prompts" --debounce=1000
604
1246
 
605
- # See which installed apps have newer versions available
606
- mj app check-updates
1247
+ # Reset stored metadata sections on local files
1248
+ mj sync file-reset --dir="ai-prompts" --sections="dependencies,references" --dry-run
607
1249
  ```
608
1250
 
609
- #### Private repositories
1251
+ ---
1252
+
1253
+ ### mj test
1254
+
1255
+ Execute, compare, validate, and manage MemberJunction tests, suites, replay scripts, rubric criteria, and Docker-based Explorer regression runs (`mj test` prints domain help; delegates to `@memberjunction/testing-cli`).
610
1256
 
611
- Some BizApp repositories are private or internal (`bizapps-ats` is one). GitHub answers **404, not 403**, for a repository
612
- it will not show you, so an install without a credential fails as though the app or the version
613
- did not exist. Supply a token one of three ways:
1257
+ #### Core test execution & reporting
614
1258
 
615
1259
  ```bash
616
- # 1. Environment variable
617
- GITHUB_TOKEN=$(gh auth token) mj app install https://github.com/MemberJunction/bizapps-ats
1260
+ # Run a single test by ID or name (supports --rubric, --checks-module, --oracles-module, --dry-run)
1261
+ mj test run <test-id>
1262
+ mj test run --name="Active Members Count" --environment=staging --format=json --output=results.json
618
1263
 
619
- # 2. mj.config.cjs — per-repository tokens, keyed by repo URL
620
- # openApps: { github: { tokens: { 'https://github.com/MemberJunction/bizapps-ats': process.env.ATS_TOKEN } } }
1264
+ # Run a test suite (supports parallel execution, sharding, flaky-check, transport & test filters)
1265
+ mj test suite <suite-id> --parallel --max-parallel=4 --shard=1/3
1266
+ mj test suite --name="Agent Quality Suite" --flaky-check=3 --transport=server
1267
+ mj test suite --name="MJ Explorer Regression Suite" --test="T001 - Login Smoke"
621
1268
 
622
- # 3. mj.config.cjs — one token for every Open App repo
623
- # openApps: { github: { token: process.env.GITHUB_TOKEN } }
624
- ```
1269
+ # List tests, suites, or test types
1270
+ mj test list
1271
+ mj test list --suites --tag=smoke --status=active
1272
+ mj test list --types
625
1273
 
626
- If more than one is set, the per-repo `tokens` entry wins, then `token`, then `GITHUB_TOKEN` — so a
627
- stale `token` left in `mj.config.cjs` silently shadows a freshly exported `GITHUB_TOKEN`.
1274
+ # View test execution history
1275
+ mj test history --test=<test-id> --recent=20 --from=2026-01-01
628
1276
 
629
- The token needs `repo` scope for the repositories you install from.
1277
+ # Compare test runs (DB mode by ID/version/commit/--latest, or offline --from-json)
1278
+ mj test compare --latest --format=markdown --output=report.md
1279
+ mj test compare <run-id-1> <run-id-2> --diff-only
1280
+ mj test compare --from-json baseline.json --from-json latest.json
630
1281
 
631
- #### Internal / dangerous flags
1282
+ # Print per-criterion rubric breakdown for a test run
1283
+ mj test report <run-id>
1284
+
1285
+ # Validate test definitions without executing
1286
+ mj test validate --all --save-report --output=validation-report.md
632
1287
 
633
- Intentionally omitted from `--help`. Almost never needed: MJ's own Open Apps use the
634
- `__mj_<AppName>` schema namespace (`__mj_BizAppsCommon`, `__mj_BizAppsForms`, …), which
635
- installs on the default path with no flag at all.
1288
+ # Promote a test's inline judge criteria into a Draft rubric and bind Test.RubricID
1289
+ mj test promote-criteria <test-id>
1290
+ mj test promote-criteria "Reply check"
636
1291
 
637
- - `--dangerously-ignore-dbl-underscore-schema-rule` — available on `mj app install`,
638
- `mj app upgrade` and `mj app remove`. Allows a `__`-prefixed schema name *outside* the
639
- `__mj_` app namespace (e.g. `__bcsaas`). Reserved schemas remain hard-blocked regardless,
640
- on both supported platforms: every schema the **database** owns — `dbo`, `sys`, `guest`,
641
- SQL Server's nine `db_*` fixed database-role schemas, `public`, anything starting `pg_`,
642
- and `information_schema` — plus every schema **MJ** owns: `__mj` and `__mj_UDT`. Each of
643
- these already exists in a stock database, so naming one would not create it, it would
644
- *adopt* it — and `mj app remove` would then drop it.
1292
+ # Review, promote, or discard pending recorded replay scripts
1293
+ mj test scripts
1294
+ mj test scripts --test "T042 - Filter Grid" --promote
1295
+ mj test scripts --test "T042 - Filter Grid" --discard
1296
+ mj test scripts --promote --yes --format=md --output=drift.md
1297
+ ```
1298
+
1299
+ #### mj test regression
645
1300
 
646
- Removing an app installed under one of those `__`-outside-namespace names (e.g. `__bcsaas`)
647
- needs the same flag again: `mj app remove <app> --dangerously-ignore-dbl-underscore-schema-rule`
648
- drops the schema. `--keep-data` is the exit for the platform- and MJ-reserved names above, which MJ
649
- must never drop: `mj app remove <app> --keep-data` unregisters the app and leaves the
650
- schema in place.
1301
+ Docker-based LLM-driven browser regression testing for MJ Explorer and external web apps (`mj test regression` prints subcommand overview).
651
1302
 
652
1303
  ```bash
653
- mj app install https://github.com/BlueCypress/SaaS \
654
- --dangerously-ignore-dbl-underscore-schema-rule
1304
+ # Scaffold a bundled regression-suite mode template
1305
+ mj test regression init --list
1306
+ mj test regression init generic-web
1307
+
1308
+ # Author a new regression test entry
1309
+ mj test regression new --name "Form builder clones a form" --priority P1 --tags form-builder \
1310
+ --start-path /app/form-builder --goal "Clone Contact Form and verify the copy opens in the editor." \
1311
+ --criteria "A form named Copy of Contact Form is listed"
1312
+
1313
+ # Build images (runs gen-forms automatically when .docker-generated/ is empty) or regenerate forms directly
1314
+ mj test regression build
1315
+ mj test regression build mjexplorer --skip-gen-forms
1316
+ mj test regression gen-forms
1317
+
1318
+ # Run self-contained local stack (Mode A) or against a .bacpac database
1319
+ mj test regression up
1320
+ mj test regression up --test="T001 - Login Smoke" --detach
1321
+ mj test regression up --bacpac=./db.bacpac --suite="My Suite" --metadata=./my-suite-metadata
1322
+
1323
+ # Run against a remote URL or compose overlay (Mode B/C/D)
1324
+ mj test regression remote --target=staging-mj
1325
+ mj test regression remote --target=./app/target.json --overlay=./app/docker-compose.app.yml --env-file=./.env
1326
+
1327
+ # Compare recent runs, export a self-contained HTML report, and tear down
1328
+ mj test regression compare --diff-only
1329
+ mj test regression export --run=run-20260526T220118Z
1330
+ mj test regression down --keep-volumes
655
1331
  ```
656
1332
 
657
- ### mj baseline
1333
+ ---
658
1334
 
659
- Build, compare, and round-trip **baseline migrations** — a single SQL script that captures the end-state of an entire V-stack (schema + every row of every table) into one deterministic `B`-prefixed file that Flyway/Skyway can apply to a fresh database in place of the long migration chain.
1335
+ ### mj translate-sql
660
1336
 
661
- > Niche command — only needed when **collapsing a V-stack into a new baseline** (within-major rebaseline) or **cutting a new major version** (e.g. v5 → v6). Day-to-day MJ development never touches this; use `mj migrate` for routine schema changes.
1337
+ Translate SQL fragments and stored MJ metadata SQL (`queries`, `views`, `filters`, or `all`) between SQL Server and PostgreSQL.
662
1338
 
663
- Three subcommands:
1339
+ ```bash
1340
+ # Preview translations across all stored SQL metadata
1341
+ mj translate-sql --from sqlserver --to postgresql --dry-run
664
1342
 
665
- - `mj baseline build` — connect to a live MSSQL database, introspect everything, dump every row of every table, and emit a canonical T-SQL script.
666
- - `mj baseline compare` — diff two live databases object-by-object **and** row-by-row.
667
- - `mj baseline roundtrip` — `build` + apply to a fresh DB + `compare` in one shot. Proves the new baseline is byte-equivalent to the V-stack it replaces.
1343
+ # Translate stored queries only or generate a review report without DB writes
1344
+ mj translate-sql --from sqlserver --to postgresql --scope queries
1345
+ mj translate-sql --from sqlserver --to postgresql --scope all --review --output ./reports
668
1346
 
669
- #### Two operating modes
1347
+ # Translate a single inline SQL fragment
1348
+ mj translate-sql --from sqlserver --to postgresql --sql "SELECT TOP 10 [Name] FROM [Users]"
1349
+ ```
670
1350
 
671
- | Mode | Trigger | Version source | Timestamp | Output folder |
672
- | --- | --- | --- | --- | --- |
673
- | **AUTO — within-major rebaseline** (default) | `--baseline-version` omitted | `Major.Minor` parsed from the latest V-file in `--source-dir` | latest V-file's timestamp **+ 1 minute** | the **same** `migrations/v{N}/` it scanned |
674
- | **EXPLICIT — major-boundary baseline** | `--baseline-version M.N` provided | the flag value | `Date.now()` UTC | `migrations/v{N+1}/` (new) |
1351
+ Flags: `--from <sqlserver|postgresql>` (required), `--to <sqlserver|postgresql>` (required), `--scope <queries|views|filters|all>` (default `all`), `--sql <fragment>`, `--dry-run`, `--review`, `-o, --output <dir>`, `--force`.
675
1352
 
676
- AUTO mode is the right choice 99% of the time. EXPLICIT is for starting a new major version (e.g. `v6.0`).
1353
+ ---
677
1354
 
678
- Filename format: `B{YYYYMMDDHHMM}__v{Major}.{Minor}.x__Baseline.sql` (literal lowercase `x` matches the V-file patch convention — patches don't carry migrations).
1355
+ ### mj update
679
1356
 
680
- #### mj baseline build
1357
+ Update installed MemberJunction developer tooling.
681
1358
 
682
- ```bash
683
- # AUTO — within-major rebaseline (writes back into ./migrations/v5/)
684
- mj baseline build --out ./migrations/v5/
1359
+ #### mj update claude
685
1360
 
686
- # EXPLICIT — start a new major version (writes into ./migrations/v6/)
687
- mj baseline build --baseline-version 6.0 --out ./migrations/v6/
1361
+ Check for or apply updates to the MemberJunction Claude Code pack in a repository.
688
1362
 
689
- # Schema-only, no data inserts
690
- mj baseline build --no-data --out ./baselines/
1363
+ ```bash
1364
+ mj update claude --check
1365
+ mj update claude
1366
+ mj update claude --refresh-commands --refresh-skills --allow-major --json
691
1367
  ```
692
1368
 
693
- Key flags: `--baseline-version`, `--source-dir`, `--database`, `--out`, `--exclude-data <csv>`, `--batch-size`, `--no-data`, `--dry-run`, `--verbose`. Run `mj baseline build --help` for the full list with defaults.
1369
+ Key flags: `--dir <path>`, `--major <n>`, `--ref <git-ref>`, `--from <path>`, `--offline`, `--check`, `--dry-run`, `-y, --yes`, `--force`, `--skip-commands`, `--skip-skills`, `--skip-settings`, `--refresh-commands`, `--refresh-skills`, `--allow-major`, `--json`, `-v, --verbose`.
694
1370
 
695
- Database host/user/password come from the MJ config (`mj.config.cjs` / `.env`); `--database` overrides only the database name.
1371
+ ---
696
1372
 
697
- #### mj baseline compare
1373
+ ### mj usage
1374
+
1375
+ Tier-1 progressive-disclosure command map for AI agents and developers. Lists every command domain with its one-line summary and runtime class, then directs callers to `mj <domain> usage`.
698
1376
 
699
1377
  ```bash
700
- # Full row-by-row diff (default)
701
- mj baseline compare --left MJ_BL_Stack --right MJ_BL_New
1378
+ mj usage
1379
+ mj usage --format=json
1380
+ mj usage --format=md
1381
+ ```
702
1382
 
703
- # Counts-only (fastest)
704
- mj baseline compare --left A --right B --row-compare counts
1383
+ Flags: `--format <text|json|md>` (defaults to `text` on a terminal and `json` when stdout is piped).
705
1384
 
706
- # CI use — fail the build on any diff, write reports
707
- mj baseline compare --left A --right B --fail-on-diff --out ./diffs/
708
- ```
1385
+ ---
709
1386
 
710
- Row-compare modes: `full` | `hash` | `counts` | `none`. Hash mode supports `--row-hash-algo sha256|md5|checksum_agg`. `--dialect mssql|postgres` (both sides must match).
1387
+ ### mj user
711
1388
 
712
- #### mj baseline roundtrip
1389
+ User administration utilities.
1390
+
1391
+ #### mj user clone
1392
+
1393
+ Create a new MemberJunction user as a copy of an existing user (defaults to the `template` preset for template users).
713
1394
 
714
1395
  ```bash
715
- # AUTO — verify the current v5.x V-stack collapses cleanly
716
- mj baseline roundtrip --source MJ_BL_Stack --target MJ_BL_New
1396
+ # Dry-run preview of cloning a template user
1397
+ mj user clone --from demo.user@example.org --email jane@example.com --first Jane --last Doe --dry-run
717
1398
 
718
- # EXPLICIT — verify a v6.0 baseline
719
- mj baseline roundtrip --baseline-version 6.0 --source MJ_BL_Stack --target MJ_BL_New
1399
+ # Clone a user with views or settings preset, optionally leaving inactive for review
1400
+ mj user clone --from alice@example.com --email bob@example.com --first Bob --last Lee --preset with-settings --inactive
720
1401
  ```
721
1402
 
722
- `--source` is the gold-standard DB with the V-stack already applied; `--target` is an empty DB the new baseline will be applied to and compared against. Add `--keep-target` to inspect the post-apply DB after a failed diff. `--apply-cmd` lets you override the default `sqlcmd` apply step (tokens: `{file}`, `{database}`).
723
-
724
- #### Related tooling
1403
+ | Flag | Description |
1404
+ |------|-------------|
1405
+ | `--from <email>` | Email of the source user to copy (required) |
1406
+ | `--email <email>` | Sign-in email of the new user (required) |
1407
+ | `--first <name>` | First name of the new user (required) |
1408
+ | `--last <name>` | Last name of the new user (required) |
1409
+ | `--preset <name>` | Clone preset: `template` (default), `with-views`, `with-settings`, or `none` |
1410
+ | `--inactive` | Leave the newly created user inactive for review |
1411
+ | `--dry-run` | Preview what would be copied without creating records |
725
1412
 
726
- - **Slash command** — [`/create-new-baseline-migration`](../../.claude/commands/create-new-baseline-migration.md) drives the workbench end-to-end from a local Claude Code session (spins up the workbench, runs the roundtrip, stages the file in `migrations/` only if byte-equivalent).
727
- - **Workbench script** — [`docker/workbench/baseline-roundtrip.sh`](../../docker/workbench/baseline-roundtrip.sh) (aliases `mjbaseline`, `mjbaseline-mssql`, `mjbaseline-pg` inside the workbench container) is the 7-phase end-to-end runner the slash command invokes.
728
- - **Design record** — [`packages/MJCLI/src/commands/baseline/PLAN.md`](src/commands/baseline/PLAN.md) documents the architecture, decisions, and component layout.
729
- - **PostgreSQL** — the T-SQL baseline is converted via `mj migrate convert` (see `/pg-migrate` skill) before being applied to a PG target.
1413
+ ---
730
1414
 
731
1415
  ## Hooks
732
1416
 
733
1417
  | Hook | Timing | Purpose |
734
1418
  |------|--------|---------|
735
1419
  | `init` | Before any command | Loads configuration, initializes environment |
736
- | `prerun` | Before command execution | Validates configuration, connects to database |
1420
+ | `prerun` | Before command execution | Validates configuration, loads bootstrap & dynamic packages for non-light commands |
1421
+ | `postrun` | After command execution | Releases wake locks and performs post-command cleanup |
737
1422
 
738
1423
  ## Plugin System
739
1424
 
740
1425
  The CLI includes these oclif plugins:
741
1426
 
742
- - `@oclif/plugin-help` -- Auto-generated help text
743
- - `@oclif/plugin-version` -- Version display
744
- - `@oclif/plugin-warn-if-update-available` -- Update notifications (checks daily)
1427
+ - `@oclif/plugin-help` — Auto-generated help text
1428
+ - `@oclif/plugin-version` — Version display
1429
+ - `@oclif/plugin-warn-if-update-available` — Update notifications (checks daily)
1430
+
1431
+ Third-party CLI plugins can be registered via `mj plugin add <package>` in `mj-cli-plugins.json`.
745
1432
 
746
1433
  ## Dependencies
747
1434
 
748
1435
  | Package | Purpose |
749
1436
  |---------|---------|
750
- | `@memberjunction/codegen-lib` | Code generation engine |
751
- | `@memberjunction/metadata-sync` | Metadata synchronization |
752
- | `@memberjunction/testing-cli` | Testing framework CLI |
753
- | `@memberjunction/db-auto-doc` | Database documentation |
754
- | `@memberjunction/query-gen` | Query generation |
755
- | `@memberjunction/ai-cli` | AI operations |
1437
+ | `@memberjunction/ai-agent-harness` | Multi-account CLI harness pool and runtime integration |
1438
+ | `@memberjunction/ai-cli` | AI agent, prompt, action, and audit operations |
1439
+ | `@memberjunction/cli-core` | Shared CLI plugin contract, envelopes, and usage registry |
1440
+ | `@memberjunction/codegen-lib` | Code generation engine and manifest scanner |
756
1441
  | `@memberjunction/config` | Configuration management |
1442
+ | `@memberjunction/db-auto-doc` | AI-powered database documentation |
1443
+ | `@memberjunction/diagnostics` | `.mjdiag` archive verification, scrubbing, timeline, and export |
1444
+ | `@memberjunction/installer` | Release installation, offline bundling, and environment doctor |
1445
+ | `@memberjunction/metadata-sync` | Metadata synchronization |
1446
+ | `@memberjunction/open-app-engine` | Open App lifecycle management |
1447
+ | `@memberjunction/query-gen` | AI query template generation |
1448
+ | `@memberjunction/record-cloning` | Entity/user cloning engine |
1449
+ | `@memberjunction/redis-provider` | Shared Redis cache inspection and invalidation |
757
1450
  | `@memberjunction/server-bootstrap-lite` | Lightweight server initialization |
758
- | `@memberjunction/sqlserver-dataprovider` | Database connectivity |
759
- | `@oclif/core` | CLI framework |
760
- | `cosmiconfig` | Configuration file loading |
761
1451
  | `@memberjunction/skyway-core` | Database migration execution |
762
- | `simple-git` | Git operations |
763
- | `figlet` | ASCII art for banners |
1452
+ | `@memberjunction/sql-converter` | Rule-based SQL dialect conversion and auditing |
1453
+ | `@memberjunction/standards` | Repository engineering standards engine |
1454
+ | `@memberjunction/testing-cli` | Testing framework CLI |
1455
+ | `@memberjunction/work-queue-engine` | Durable work queue operations |
1456
+ | `@oclif/core` | CLI framework |
764
1457
 
765
1458
  ## License
766
1459