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

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 (224) hide show
  1. package/README.md +1047 -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/usage.d.ts +7 -0
  6. package/dist/commands/agent/usage.d.ts.map +1 -0
  7. package/dist/commands/agent/usage.js +10 -0
  8. package/dist/commands/agent/usage.js.map +1 -0
  9. package/dist/commands/codegen/manifest.d.ts +40 -0
  10. package/dist/commands/codegen/manifest.d.ts.map +1 -1
  11. package/dist/commands/codegen/manifest.js +124 -3
  12. package/dist/commands/codegen/manifest.js.map +1 -1
  13. package/dist/commands/diag/usage.d.ts +7 -0
  14. package/dist/commands/diag/usage.d.ts.map +1 -0
  15. package/dist/commands/diag/usage.js +10 -0
  16. package/dist/commands/diag/usage.js.map +1 -0
  17. package/dist/commands/doctor/index.d.ts +6 -0
  18. package/dist/commands/doctor/index.d.ts.map +1 -1
  19. package/dist/commands/doctor/index.js +42 -0
  20. package/dist/commands/doctor/index.js.map +1 -1
  21. package/dist/commands/explorer/postbuild.d.ts +14 -0
  22. package/dist/commands/explorer/postbuild.d.ts.map +1 -0
  23. package/dist/commands/explorer/postbuild.js +49 -0
  24. package/dist/commands/explorer/postbuild.js.map +1 -0
  25. package/dist/commands/explorer/usage.d.ts +7 -0
  26. package/dist/commands/explorer/usage.d.ts.map +1 -0
  27. package/dist/commands/explorer/usage.js +10 -0
  28. package/dist/commands/explorer/usage.js.map +1 -0
  29. package/dist/commands/harness/account/add.d.ts +22 -0
  30. package/dist/commands/harness/account/add.d.ts.map +1 -0
  31. package/dist/commands/harness/account/add.js +100 -0
  32. package/dist/commands/harness/account/add.js.map +1 -0
  33. package/dist/commands/harness/account/clear-cooldown.d.ts +13 -0
  34. package/dist/commands/harness/account/clear-cooldown.d.ts.map +1 -0
  35. package/dist/commands/harness/account/clear-cooldown.js +32 -0
  36. package/dist/commands/harness/account/clear-cooldown.js.map +1 -0
  37. package/dist/commands/harness/account/disable.d.ts +13 -0
  38. package/dist/commands/harness/account/disable.d.ts.map +1 -0
  39. package/dist/commands/harness/account/disable.js +34 -0
  40. package/dist/commands/harness/account/disable.js.map +1 -0
  41. package/dist/commands/harness/account/enable.d.ts +13 -0
  42. package/dist/commands/harness/account/enable.d.ts.map +1 -0
  43. package/dist/commands/harness/account/enable.js +34 -0
  44. package/dist/commands/harness/account/enable.js.map +1 -0
  45. package/dist/commands/harness/account/index.d.ts +7 -0
  46. package/dist/commands/harness/account/index.d.ts.map +1 -0
  47. package/dist/commands/harness/account/index.js +23 -0
  48. package/dist/commands/harness/account/index.js.map +1 -0
  49. package/dist/commands/harness/account/list.d.ts +15 -0
  50. package/dist/commands/harness/account/list.d.ts.map +1 -0
  51. package/dist/commands/harness/account/list.js +58 -0
  52. package/dist/commands/harness/account/list.js.map +1 -0
  53. package/dist/commands/harness/account/login.d.ts +16 -0
  54. package/dist/commands/harness/account/login.d.ts.map +1 -0
  55. package/dist/commands/harness/account/login.js +50 -0
  56. package/dist/commands/harness/account/login.js.map +1 -0
  57. package/dist/commands/harness/account/remove.d.ts +14 -0
  58. package/dist/commands/harness/account/remove.d.ts.map +1 -0
  59. package/dist/commands/harness/account/remove.js +43 -0
  60. package/dist/commands/harness/account/remove.js.map +1 -0
  61. package/dist/commands/harness/account/set-strategy.d.ts +13 -0
  62. package/dist/commands/harness/account/set-strategy.d.ts.map +1 -0
  63. package/dist/commands/harness/account/set-strategy.js +38 -0
  64. package/dist/commands/harness/account/set-strategy.js.map +1 -0
  65. package/dist/commands/harness/index.d.ts +7 -0
  66. package/dist/commands/harness/index.d.ts.map +1 -0
  67. package/dist/commands/harness/index.js +22 -0
  68. package/dist/commands/harness/index.js.map +1 -0
  69. package/dist/commands/harness/usage.d.ts +7 -0
  70. package/dist/commands/harness/usage.d.ts.map +1 -0
  71. package/dist/commands/harness/usage.js +10 -0
  72. package/dist/commands/harness/usage.js.map +1 -0
  73. package/dist/commands/migrate/convert.d.ts +25 -1
  74. package/dist/commands/migrate/convert.d.ts.map +1 -1
  75. package/dist/commands/migrate/convert.js +156 -38
  76. package/dist/commands/migrate/convert.js.map +1 -1
  77. package/dist/commands/migrate/index.d.ts +8 -0
  78. package/dist/commands/migrate/index.d.ts.map +1 -1
  79. package/dist/commands/migrate/index.js +41 -2
  80. package/dist/commands/migrate/index.js.map +1 -1
  81. package/dist/commands/migrate/rebake.d.ts +13 -0
  82. package/dist/commands/migrate/rebake.d.ts.map +1 -1
  83. package/dist/commands/migrate/rebake.js +45 -6
  84. package/dist/commands/migrate/rebake.js.map +1 -1
  85. package/dist/commands/queue/export-topology.d.ts +2 -0
  86. package/dist/commands/queue/export-topology.d.ts.map +1 -1
  87. package/dist/commands/queue/export-topology.js +3 -1
  88. package/dist/commands/queue/export-topology.js.map +1 -1
  89. package/dist/commands/queue/import-bindings.d.ts +2 -0
  90. package/dist/commands/queue/import-bindings.d.ts.map +1 -1
  91. package/dist/commands/queue/import-bindings.js +3 -1
  92. package/dist/commands/queue/import-bindings.js.map +1 -1
  93. package/dist/commands/queue/index.js +1 -1
  94. package/dist/commands/queue/index.js.map +1 -1
  95. package/dist/commands/queue/sweep.d.ts +4 -6
  96. package/dist/commands/queue/sweep.d.ts.map +1 -1
  97. package/dist/commands/queue/sweep.js +15 -23
  98. package/dist/commands/queue/sweep.js.map +1 -1
  99. package/dist/commands/queue/validate-bindings.d.ts +2 -0
  100. package/dist/commands/queue/validate-bindings.d.ts.map +1 -1
  101. package/dist/commands/queue/validate-bindings.js +3 -1
  102. package/dist/commands/queue/validate-bindings.js.map +1 -1
  103. package/dist/commands/queue/work.d.ts +2 -19
  104. package/dist/commands/queue/work.d.ts.map +1 -1
  105. package/dist/commands/queue/work.js +9 -29
  106. package/dist/commands/queue/work.js.map +1 -1
  107. package/dist/commands/rubric/usage.d.ts +7 -0
  108. package/dist/commands/rubric/usage.d.ts.map +1 -0
  109. package/dist/commands/rubric/usage.js +10 -0
  110. package/dist/commands/rubric/usage.js.map +1 -0
  111. package/dist/commands/test/regression/index.d.ts.map +1 -1
  112. package/dist/commands/test/regression/index.js +2 -0
  113. package/dist/commands/test/regression/index.js.map +1 -1
  114. package/dist/commands/test/regression/new.d.ts +21 -0
  115. package/dist/commands/test/regression/new.d.ts.map +1 -0
  116. package/dist/commands/test/regression/new.js +82 -0
  117. package/dist/commands/test/regression/new.js.map +1 -0
  118. package/dist/commands/test/regression/up.d.ts +1 -0
  119. package/dist/commands/test/regression/up.d.ts.map +1 -1
  120. package/dist/commands/test/regression/up.js +17 -0
  121. package/dist/commands/test/regression/up.js.map +1 -1
  122. package/dist/commands/test/scripts.d.ts +6 -4
  123. package/dist/commands/test/scripts.d.ts.map +1 -1
  124. package/dist/commands/test/scripts.js +14 -0
  125. package/dist/commands/test/scripts.js.map +1 -1
  126. package/dist/commands/test/suite.d.ts +1 -0
  127. package/dist/commands/test/suite.d.ts.map +1 -1
  128. package/dist/commands/test/suite.js +6 -0
  129. package/dist/commands/test/suite.js.map +1 -1
  130. package/dist/commands/usage.js +2 -1
  131. package/dist/commands/usage.js.map +1 -1
  132. package/dist/commands/user/usage.d.ts +7 -0
  133. package/dist/commands/user/usage.d.ts.map +1 -0
  134. package/dist/commands/user/usage.js +10 -0
  135. package/dist/commands/user/usage.js.map +1 -0
  136. package/dist/config.d.ts +119 -0
  137. package/dist/config.d.ts.map +1 -1
  138. package/dist/config.js +43 -1
  139. package/dist/config.js.map +1 -1
  140. package/dist/init-templates/citizen-builder/.env.example +1 -0
  141. package/dist/init-templates/citizen-builder/docker-compose.yml +2 -0
  142. package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +2 -1
  143. package/dist/lib/db-preflight.d.ts.map +1 -1
  144. package/dist/lib/db-preflight.js +22 -0
  145. package/dist/lib/db-preflight.js.map +1 -1
  146. package/dist/lib/derived-usage.d.ts +8 -0
  147. package/dist/lib/derived-usage.d.ts.map +1 -1
  148. package/dist/lib/derived-usage.js +30 -20
  149. package/dist/lib/derived-usage.js.map +1 -1
  150. package/dist/lib/domain-profiles.d.ts.map +1 -1
  151. package/dist/lib/domain-profiles.js +24 -0
  152. package/dist/lib/domain-profiles.js.map +1 -1
  153. package/dist/lib/domain-usage-command.js +2 -1
  154. package/dist/lib/domain-usage-command.js.map +1 -1
  155. package/dist/lib/explorer-postbuild/public-page-html.d.ts +48 -0
  156. package/dist/lib/explorer-postbuild/public-page-html.d.ts.map +1 -0
  157. package/dist/lib/explorer-postbuild/public-page-html.js +284 -0
  158. package/dist/lib/explorer-postbuild/public-page-html.js.map +1 -0
  159. package/dist/lib/explorer-postbuild/service-worker-check.d.ts +13 -0
  160. package/dist/lib/explorer-postbuild/service-worker-check.d.ts.map +1 -0
  161. package/dist/lib/explorer-postbuild/service-worker-check.js +41 -0
  162. package/dist/lib/explorer-postbuild/service-worker-check.js.map +1 -0
  163. package/dist/lib/harness-account.d.ts +34 -0
  164. package/dist/lib/harness-account.d.ts.map +1 -0
  165. package/dist/lib/harness-account.js +105 -0
  166. package/dist/lib/harness-account.js.map +1 -0
  167. package/dist/lib/pg-preflight/checks.d.ts +28 -0
  168. package/dist/lib/pg-preflight/checks.d.ts.map +1 -0
  169. package/dist/lib/pg-preflight/checks.js +94 -0
  170. package/dist/lib/pg-preflight/checks.js.map +1 -0
  171. package/dist/lib/pg-preflight/extension-check.d.ts +28 -0
  172. package/dist/lib/pg-preflight/extension-check.d.ts.map +1 -0
  173. package/dist/lib/pg-preflight/extension-check.js +86 -0
  174. package/dist/lib/pg-preflight/extension-check.js.map +1 -0
  175. package/dist/lib/pg-preflight/extension-scan.d.ts +24 -0
  176. package/dist/lib/pg-preflight/extension-scan.d.ts.map +1 -0
  177. package/dist/lib/pg-preflight/extension-scan.js +58 -0
  178. package/dist/lib/pg-preflight/extension-scan.js.map +1 -0
  179. package/dist/lib/pg-preflight/pending-migrations.d.ts +28 -0
  180. package/dist/lib/pg-preflight/pending-migrations.d.ts.map +1 -0
  181. package/dist/lib/pg-preflight/pending-migrations.js +48 -0
  182. package/dist/lib/pg-preflight/pending-migrations.js.map +1 -0
  183. package/dist/lib/pg-preflight/preflight.d.ts +18 -0
  184. package/dist/lib/pg-preflight/preflight.d.ts.map +1 -0
  185. package/dist/lib/pg-preflight/preflight.js +43 -0
  186. package/dist/lib/pg-preflight/preflight.js.map +1 -0
  187. package/dist/lib/pg-preflight/remediation.d.ts +27 -0
  188. package/dist/lib/pg-preflight/remediation.d.ts.map +1 -0
  189. package/dist/lib/pg-preflight/remediation.js +82 -0
  190. package/dist/lib/pg-preflight/remediation.js.map +1 -0
  191. package/dist/lib/pg-preflight/render.d.ts +15 -0
  192. package/dist/lib/pg-preflight/render.d.ts.map +1 -0
  193. package/dist/lib/pg-preflight/render.js +48 -0
  194. package/dist/lib/pg-preflight/render.js.map +1 -0
  195. package/dist/lib/pg-preflight/run-for-config.d.ts +23 -0
  196. package/dist/lib/pg-preflight/run-for-config.d.ts.map +1 -0
  197. package/dist/lib/pg-preflight/run-for-config.js +45 -0
  198. package/dist/lib/pg-preflight/run-for-config.js.map +1 -0
  199. package/dist/lib/pg-preflight/types.d.ts +67 -0
  200. package/dist/lib/pg-preflight/types.d.ts.map +1 -0
  201. package/dist/lib/pg-preflight/types.js +8 -0
  202. package/dist/lib/pg-preflight/types.js.map +1 -0
  203. package/dist/lib/regression/test-scaffold.d.ts +52 -0
  204. package/dist/lib/regression/test-scaffold.d.ts.map +1 -0
  205. package/dist/lib/regression/test-scaffold.js +237 -0
  206. package/dist/lib/regression/test-scaffold.js.map +1 -0
  207. package/dist/lib/work-queue/queue-format.d.ts +4 -0
  208. package/dist/lib/work-queue/queue-format.d.ts.map +1 -1
  209. package/dist/lib/work-queue/queue-format.js +15 -0
  210. package/dist/lib/work-queue/queue-format.js.map +1 -1
  211. package/dist/lib/work-queue/queue-worker.d.ts +16 -1
  212. package/dist/lib/work-queue/queue-worker.d.ts.map +1 -1
  213. package/dist/lib/work-queue/queue-worker.js +18 -0
  214. package/dist/lib/work-queue/queue-worker.js.map +1 -1
  215. package/dist/light-commands.d.ts.map +1 -1
  216. package/dist/light-commands.js +34 -0
  217. package/dist/light-commands.js.map +1 -1
  218. package/dist/tsconfig.tsbuildinfo +1 -1
  219. package/dist/utils/open-app-context.d.ts +1 -0
  220. package/dist/utils/open-app-context.d.ts.map +1 -1
  221. package/dist/utils/open-app-context.js +7 -2
  222. package/dist/utils/open-app-context.js.map +1 -1
  223. package/oclif.manifest.json +2261 -1382
  224. package/package.json +31 -28
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,1253 @@ 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, 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/Integrations/CRM/HubSpot
375
+ mj app install ./openapps/analytics
376
+
377
+ # Upgrade to a newer version (or --reapply a local folder app without bumping version)
378
+ mj app upgrade acme-crm
379
+ mj app upgrade acme-crm --version 1.3.0 --non-interactive
380
+ mj app upgrade analytics --reapply
381
+
382
+ # Enable / disable without removing
383
+ mj app enable acme-crm
384
+ mj app disable acme-crm
385
+
386
+ # Remove (add --keep-data to preserve schema/data, --force to ignore dependents, -y to skip prompt)
387
+ mj app remove acme-crm
388
+ mj app remove acme-crm --keep-data --yes
389
+
390
+ # Check which installed apps have newer versions available
391
+ mj app check-updates
392
+ ```
393
+
394
+ #### Private repositories
395
+
396
+ 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):
397
+
398
+ ```bash
399
+ # 1. mj.config.cjs — per-repository tokens, keyed by repo URL
400
+ # openApps: { github: { tokens: { 'https://github.com/acme/private-app': process.env.APP_TOKEN } } }
401
+
402
+ # 2. mj.config.cjs — one token for every Open App repo
403
+ # openApps: { github: { token: process.env.GITHUB_TOKEN } }
404
+
405
+ # 3. Environment variable
406
+ GITHUB_TOKEN=$(gh auth token) mj app install https://github.com/acme/private-app
407
+ ```
408
+
409
+ #### Internal / dangerous flags
410
+
411
+ Intentionally omitted from `--help` because standard MJ Open Apps use the `__mj_<AppName>` schema namespace without any flag:
412
+
413
+ - `--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.
414
+
415
+ ---
416
+
417
+ ### mj artifacts
418
+
419
+ Maintenance utilities for stored conversation artifacts.
420
+
421
+ #### mj artifacts reclassify
422
+
423
+ 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.
424
+
425
+ ```bash
426
+ # Dry-run preview (inspects up to 100 rows by default)
427
+ mj artifacts reclassify
428
+
429
+ # Apply reclassification for artifacts created after a date
430
+ mj artifacts reclassify --since 2026-01-01 --limit 50 --apply --verbose
431
+ ```
432
+
433
+ | Flag | Short | Description |
434
+ |------|-------|-------------|
435
+ | `--conversation-id <id>` | | Scope to artifacts attached to one conversation |
436
+ | `--since <iso-date>` | | Scope to artifacts created on or after this ISO date |
437
+ | `--limit <n>` | | Maximum rows to inspect (default `100`) |
438
+ | `--apply` | | Write changes (dry-run when omitted) |
439
+ | `--verbose` | `-v` | Print every candidate row, not just the summary |
440
+
441
+ ---
442
+
443
+ ### mj baseline
444
+
445
+ 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.
446
+
447
+ > Niche maintainer command — use `mj migrate` for routine schema changes.
448
+
449
+ #### Operating modes
450
+
451
+ | Mode | Trigger | Version source | Timestamp | Output folder |
452
+ |------|---------|----------------|-----------|---------------|
453
+ | **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}/` |
454
+ | **EXPLICIT — major-boundary baseline** | `--baseline-version M.N` provided | Flag value | `Date.now()` UTC | `migrations/v{N+1}/` |
455
+
456
+ Filename format: `B{YYYYMMDDHHMM}__v{Major}.{Minor}.x__Baseline.sql`.
457
+
458
+ #### mj baseline build
459
+
460
+ ```bash
461
+ # AUTO within-major rebaseline
462
+ mj baseline build --out ./migrations/v5/
463
+
464
+ # EXPLICIT major-boundary baseline
465
+ mj baseline build --baseline-version 6.0 --out ./migrations/v6/
245
466
 
246
- # Migrate to a specific version tag
247
- mj migrate --tag v2.10.0
467
+ # Schema-only, no INSERT statements
468
+ mj baseline build --no-data --out ./baselines/
469
+ ```
470
+
471
+ Key flags: `--baseline-version`, `--source-dir`, `--description`, `--database`, `--out`, `--exclude-data <csv>`, `--batch-size <n>` (default `1000`), `--no-data`, `--dry-run`, `--verbose`.
472
+
473
+ #### mj baseline compare
474
+
475
+ ```bash
476
+ # Full object-by-object and row-by-row diff
477
+ mj baseline compare --left MJ_BL_Stack --right MJ_BL_New
478
+
479
+ # Counts-only (fastest) or CI gate with report files
480
+ mj baseline compare --left A --right B --row-compare counts
481
+ mj baseline compare --left A --right B --fail-on-diff --out ./diffs/
482
+ ```
483
+
484
+ 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`.
485
+
486
+ #### mj baseline roundtrip
487
+
488
+ ```bash
489
+ # Build from gold-standard V-stack DB, apply to empty target DB, and verify byte-equivalence
490
+ mj baseline roundtrip --source MJ_BL_Stack --target MJ_BL_New
491
+ mj baseline roundtrip --baseline-version 6.0 --source MJ_BL_Stack --target MJ_BL_New --keep-target
492
+ ```
493
+
494
+ 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`.
495
+
496
+ Related docs: [`packages/MJCLI/src/commands/baseline/PLAN.md`](src/commands/baseline/PLAN.md).
497
+
498
+ ---
499
+
500
+ ### mj bump
501
+
502
+ Bump `@memberjunction/*` dependency versions in `package.json` files.
503
+
504
+ ```bash
505
+ # Bump current directory's package.json to the current CLI version
506
+ mj bump
507
+
508
+ # Dry-run recursively across subdirectories with verbose logging
509
+ mj bump -rdv
510
+
511
+ # Recursively bump to a specific tag and output only modified package paths
512
+ mj bump -rqt v6.0.0 | xargs -n1 -I{} npm install --prefix {}
513
+ ```
514
+
515
+ | Flag | Short | Description |
516
+ |------|-------|-------------|
517
+ | `--recursive` | `-r` | Bump versions in current directory and all subdirectories |
518
+ | `--tag <ver>` | `-t` | Target version tag (defaults to the CLI's version) |
519
+ | `--dry` | `-d` | Dry run without writing `package.json` changes |
520
+ | `--quiet` | `-q` | Print only paths of updated packages |
521
+ | `--verbose` | `-v` | Enable additional logging |
522
+
523
+ ---
524
+
525
+ ### mj bundle
526
+
527
+ Create a self-contained MemberJunction distribution zip for offline/air-gapped installations.
528
+
529
+ ```bash
530
+ # Bundle latest branch tip into a distribution zip
531
+ mj bundle --out ./mj-install.zip
532
+
533
+ # Bundle a specific release tag with SQL Server + PostgreSQL migrations
534
+ mj bundle --tag v5.38.0 --with-migrations --out ./mj-install.zip
535
+
536
+ # Bundle from local working tree for PostgreSQL only, excluding the Claude Code pack
537
+ mj bundle --source . --with-migrations --db-platform postgresql --no-claude-pack --out ./mj-pg.zip
538
+ ```
539
+
540
+ | Flag | Short | Description |
541
+ |------|-------|-------------|
542
+ | `--out <path>` | `-o` | Output zip path (required) |
543
+ | `--tag <ver>` | `-t` | Release tag to bundle (defaults to latest branch tip) |
544
+ | `--source <dir>` | | Bundle from a local working-tree directory instead of GitHub |
545
+ | `--with-migrations` | | Include migration trees for offline `mj migrate` |
546
+ | `--db-platform <val>` | | With `--with-migrations`, ship only `sqlserver` or `postgresql` |
547
+ | `--no-claude-pack` | | Exclude the Claude Code pack (`CLAUDE.md` + `.claude/`) |
548
+ | `--verbose` | `-v` | Show detailed output |
549
+
550
+ ---
551
+
552
+ ### mj cache
553
+
554
+ Inspect and clear the shared Redis cache (`REDIS_URL`) so every running MJAPI server reloads fresh data from the database.
555
+
556
+ #### mj cache clear
557
+
558
+ ```bash
559
+ # Clear RunView, dataset, and metadata caches
560
+ mj cache clear
561
+
562
+ # Preview target Redis URL and per-category key counts without deleting
563
+ mj cache clear --dry-run
564
+
565
+ # Clear a single category (repeatable) or target a custom Redis URL/prefix
566
+ mj cache clear --category RunViewCache --prefix mj
567
+ mj cache clear --url redis://localhost:6379
568
+ ```
569
+
570
+ | Flag | Description |
571
+ |------|-------------|
572
+ | `--dry-run` | Report target and key counts per category without deleting |
573
+ | `--category <name>` | Specific cache category to clear (repeatable; case-insensitive) |
574
+ | `--url <redis-url>` | Redis URL override (default: `REDIS_URL`) |
575
+ | `--prefix <str>` | Key prefix override (default: `REDIS_KEY_PREFIX`, else `mj`) |
576
+
577
+ > `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`.
578
+
579
+ ---
580
+
581
+ ### mj clean
248
582
 
249
- # Migrate a custom schema with custom migrations directory
250
- mj migrate --schema __BCSaaS --dir ./migrations/v1
583
+ Reset a MemberJunction database to a pre-installation state.
251
584
 
252
- # Verbose output for debugging
253
- mj migrate --verbose
585
+ ```bash
586
+ mj clean
587
+ mj clean --verbose
254
588
  ```
255
589
 
590
+ Flags: `-v, --verbose`.
591
+
592
+ ---
593
+
256
594
  ### mj codegen
257
595
 
258
- Run MemberJunction code generation.
596
+ Run the full MemberJunction code generation pipeline (metadata sync, SQL objects, TypeScript entity subclasses, Angular forms, GraphQL resolvers, and DB schema JSON).
259
597
 
260
598
  ```bash
261
599
  # Run full code generation
262
600
  mj codegen
263
601
 
264
- # Generate class registration manifests only
602
+ # Regenerate code files only (skip database metadata/SQL pass) or database-only
603
+ mj codegen --skipdb
604
+ mj codegen --skipfiles
605
+
606
+ # Disable AI-driven advanced generation or skip configured shell hooks
607
+ mj codegen --no-ai --skip-commands
608
+
609
+ # Re-emit files for every schema and customize SQL output directory
610
+ mj codegen --all-schemas --sql-output-dir ./migrations/codegen
611
+ ```
612
+
613
+ 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`.
614
+
615
+ #### mj codegen manifest
616
+
617
+ Generate a static class registration manifest so modern bundlers (ESBuild, Vite) do not tree-shake `@RegisterClass`-decorated classes.
618
+
619
+ ```bash
620
+ # Default manifest generation
265
621
  mj codegen manifest
266
- mj codegen manifest --exclude-packages @memberjunction --output ./src/generated/manifest.ts
622
+
623
+ # Generate a supplemental manifest excluding @memberjunction/* packages
624
+ mj codegen manifest --exclude-packages @memberjunction --no-sync-deps --output ./src/generated/manifest.ts
625
+
626
+ # Generate manifest + lazy-loading config + Open App client bootstrap for MJExplorer
627
+ 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
628
  ```
268
629
 
630
+ | Flag | Short | Description |
631
+ |------|-------|-------------|
632
+ | `--output <path>` | `-o` | Output manifest path (default `./src/generated/class-registrations-manifest.ts`) |
633
+ | `--appDir <dir>` | `-a` | Root directory whose `package.json` dependency tree is scanned |
634
+ | `--filter <base>` | `-f` | Only include classes extending this base class (repeatable) |
635
+ | `--exclude-packages <prefix>` | `-e` | Skip packages starting with prefix (repeatable) |
636
+ | `--no-sync-deps` | | Skip automatic `package.json` dependency reconciliation |
637
+ | `--scan-dist` | | Also scan compiled JS in `dist/` for npm-published packages without `src/` |
638
+ | `--lazy-config <path>` | | Emit a lazy-loading feature config file (requires `--exclude-packages`) |
639
+ | `--strict` | | Fail with non-zero exit if excluded packages have unreachable `@RegisterClass` gaps |
640
+ | `--open-app-client-bootstrap` | | Append Open App client side-effect imports and emit `public-pages.generated.ts` |
641
+ | `--quiet` / `--verbose` | `-q` / `-v` | Control output verbosity |
642
+
269
643
  #### v5.0 Entity Name Migration Commands
270
644
 
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.
645
+ 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
646
 
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.
647
+ - **`mj codegen 5-0-fix-entity-names`** — AST + regex scanner for TypeScript (`.ts`) entity names and class/subclass renames.
648
+ - **`mj codegen 5-0-fix-html-entity-names`** — Targeted scanner for Angular HTML templates (`.html`).
649
+ - **`mj codegen 5-0-fix-metadata-names`** — Scanner for `metadata/` JSON files (including `.mj-sync.json`, `@lookup:`, and `relatedEntities`).
277
650
 
278
- > These commands will be kept for 1-2 years to support the v5.0 upgrade window, then removed.
651
+ ```bash
652
+ # 1. Dry-run scan across code, templates, and metadata
653
+ mj codegen 5-0-fix-entity-names --path packages/
654
+ mj codegen 5-0-fix-html-entity-names --path packages/Angular/
655
+ mj codegen 5-0-fix-metadata-names --path metadata/
279
656
 
280
- ##### mj codegen 5-0-fix-entity-names
657
+ # 2. Apply fixes in place
658
+ mj codegen 5-0-fix-entity-names --path packages/ --fix
659
+ mj codegen 5-0-fix-html-entity-names --path packages/Angular/ --fix
660
+ mj codegen 5-0-fix-metadata-names --path metadata/ --fix
661
+ ```
281
662
 
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.
663
+ Common flags across all three commands: `-p, --path <dir|file>`, `--fix`, `--entity-subclasses <path>`, `-q, --quiet`, `-v, --verbose`.
283
664
 
284
- **Detected patterns:**
665
+ ---
285
666
 
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')` |
667
+ ### mj dbdoc
297
668
 
298
- **Default exclusions:** `node_modules`, `dist`, `build`, `.git`, `__tests__`, `*.d.ts`, `*.spec.ts`, `*.test.ts`, `generated/`, `Demos/`
669
+ AI-powered database documentation and sample-query generator (delegates to `@memberjunction/db-auto-doc`; `mj dbdoc` prints topic help).
299
670
 
300
671
  ```bash
301
- # Dry-run: scan entire packages/ directory
302
- mj codegen 5-0-fix-entity-names --path packages/
672
+ # Initialize a DBAutoDoc project
673
+ mj dbdoc init
303
674
 
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
675
+ # Analyze database schema (supports --resume, --config, --skip-sampling)
676
+ mj dbdoc analyze --config ./config.json
677
+ mj dbdoc analyze --resume ./output/run-6/state.json --skip-sampling
306
678
 
307
- # Apply fixes
308
- mj codegen 5-0-fix-entity-names --path packages/ --fix
679
+ # Check analysis status or reset state
680
+ mj dbdoc status --state-file ./db-doc-state.json
681
+ mj dbdoc reset --force
309
682
 
310
- # Custom entity_subclasses.ts location
311
- mj codegen 5-0-fix-entity-names --path packages/ --entity-subclasses ./path/to/entity_subclasses.ts
683
+ # Export documentation (SQL extended properties, Markdown, HTML, CSV, Mermaid ERDs, report)
684
+ mj dbdoc export --state-file ./db-doc-state.json --markdown --html --mermaid --erd-mode clusters --erd-columns keys
685
+ mj dbdoc export --sql --apply --approved-only --confidence-threshold 0.8
312
686
 
313
- # Quiet mode (summary only)
314
- mj codegen 5-0-fix-entity-names --path packages/ -q
687
+ # Generate sample SQL queries from analysis state and export to MJ metadata JSON
688
+ mj dbdoc generate-queries --from-state ./output/run-1/state.json --queries-per-table 10
689
+ 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
690
  ```
316
691
 
317
- ##### mj codegen 5-0-fix-html-entity-names
692
+ ---
318
693
 
319
- Scans **Angular HTML template files** (`.html`) using targeted regex patterns for entity name references in template expressions and attribute values.
694
+ ### mj dev
320
695
 
321
- **Detected patterns:**
696
+ 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
697
 
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"` |
698
+ #### mj dev workspace
699
+
700
+ ```bash
701
+ # Auto-detect sibling MJ / Open App clones and generate the joined pnpm workspace
702
+ mj dev workspace --dir ~/code/mj-workspace
703
+
704
+ # Customize included/excluded repos or admit app shells
705
+ mj dev workspace --dir ~/code/mj-workspace --include bizapps-common --exclude bizapps-sonar
706
+ mj dev workspace --dir ~/code/mj-workspace --apps my-app=apps/API,apps/Explorer --clean-members
707
+
708
+ # Regenerate workspace files without running pnpm install
709
+ MJ_DEV_WORKSPACE_DIR=~/code/mj-workspace mj dev workspace --no-install --force
710
+ ```
711
+
712
+ | Flag | Description |
713
+ |------|-------------|
714
+ | `--dir <path>` | Parent directory holding sibling clones (must not be a git repo; env: `MJ_DEV_WORKSPACE_DIR`, default `.`) |
715
+ | `--include <dir>` | Repo directory name to include (repeatable) |
716
+ | `--exclude <dir>` | Repo directory name to exclude (repeatable) |
717
+ | `--apps <member=globs>` | Admit app-shell packages (`<member>=<glob>[,<glob>]`, repeatable) |
718
+ | `--[no-]install` | Run `pnpm install` at the parent after generating (default `true`) |
719
+ | `--force` | Overwrite existing workspace files (keeps `.bak` copies) |
720
+ | `--[no-]clean-members` | Remove member repos' standalone `node_modules` trees before parent install |
721
+ | `-v, --verbose` | Show detailed output |
330
722
 
331
- **Default exclusions:** `node_modules`, `dist`, `build`, `.git`, `generated/`, `Demos/`
723
+ #### mj dev workspace status / doctor / clean
332
724
 
333
725
  ```bash
334
- # Dry-run: scan Angular templates
335
- mj codegen 5-0-fix-html-entity-names --path packages/Angular/
726
+ # Read-only status summary of generated files, lockfile, sentinel, and members
727
+ mj dev workspace status --dir ~/code/mj-workspace
336
728
 
337
- # Apply fixes
338
- mj codegen 5-0-fix-html-entity-names --path packages/Angular/ --fix
729
+ # Read-only health check (duplicate singletons, standalone installs, stale builds)
730
+ mj dev workspace doctor --dir ~/code/mj-workspace
339
731
 
340
- # Verbose output showing individual file progress
341
- mj codegen 5-0-fix-html-entity-names --path packages/ -v
732
+ # Preview teardown, then remove generated workspace residue (repos untouched)
733
+ mj dev workspace clean --dir ~/code/mj-workspace --dry-run
734
+ mj dev workspace clean --dir ~/code/mj-workspace
342
735
  ```
343
736
 
344
- ##### mj codegen 5-0-fix-metadata-names
737
+ Flags: `--dir <path>` on all three; `--dry-run` and `--force` on `mj dev workspace clean`.
345
738
 
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`.
739
+ ---
347
740
 
348
- **Detected patterns:**
741
+ ### mj diag
349
742
 
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 |
743
+ 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).
744
+
745
+ All commands that read bundles accept encrypted `MJDB` envelopes via `--private-key-file <path>`, `MJ_DIAG_PRIVATE_KEY` (preferred), or `--private-key <base64>`.
357
746
 
358
747
  ```bash
359
- # Dry-run: scan metadata directory
360
- mj codegen 5-0-fix-metadata-names --path metadata/
748
+ # Verify archive integrity and inspect bundle manifest/summary
749
+ mj diag inspect ./capture.mjdiag
750
+ mj diag inspect ./encrypted.mjdiag --private-key-file ./intake.key --json
361
751
 
362
- # Apply fixes
363
- mj codegen 5-0-fix-metadata-names --path metadata/ --fix
752
+ # Print a merged chronological timeline (client spans, server spans, SQL, breadcrumbs)
753
+ mj diag timeline ./capture.mjdiag --limit 100
754
+
755
+ # List slow client/server spans and SQL queries above a millisecond threshold
756
+ mj diag slow ./capture.mjdiag --threshold 250
757
+
758
+ # Export traces to Chrome Trace Event (ui.perfetto.dev) or OpenTelemetry OTLP JSON
759
+ mj diag export ./capture.mjdiag --perfetto -o ./trace-perfetto.json
760
+ mj diag export ./capture.mjdiag --otlp -o ./trace-otlp.json
364
761
 
365
- # Scan a specific subdirectory
366
- mj codegen 5-0-fix-metadata-names --path metadata/resource-types
762
+ # Re-scrub a bundle archive at Standard or FullRaw profile
763
+ mj diag scrub ./capture.mjdiag -o ./scrubbed.mjdiag --profile Standard
367
764
 
368
- # Scan and fix a single file
369
- mj codegen 5-0-fix-metadata-names --path metadata/entities/.audit-related-entities.json --fix
765
+ # Generate an X25519 collector keypair (and optional Ed25519 signing keypair) for an intake server
766
+ mj diag keygen --key-id intake-2026-01 --signing --json
370
767
  ```
371
768
 
372
- ##### Common flags (all three commands)
769
+ | Subcommand | Args & Key Flags |
770
+ |------------|------------------|
771
+ | `mj diag inspect <file>` | `--json`, `--private-key-file`, `--private-key` |
772
+ | `mj diag timeline <file>` | `-n, --limit <n>` (default `50`), `--private-key-file`, `--private-key` |
773
+ | `mj diag slow <file>` | `-t, --threshold <ms>` (default `500`), `--private-key-file`, `--private-key` |
774
+ | `mj diag export <file>` | `-o, --output <path>` (required), `--perfetto`, `--otlp`, `--private-key-file`, `--private-key` |
775
+ | `mj diag scrub <file>` | `-o, --output <path>` (required), `--profile <Standard\|FullRaw>`, `--private-key-file`, `--private-key` |
776
+ | `mj diag keygen` | `--key-id <kid>`, `--signing`, `--json` |
777
+
778
+ ---
779
+
780
+ ### mj doctor
781
+
782
+ Diagnose a MemberJunction installation and check for metadata/data drift.
783
+
784
+ #### mj doctor
785
+
786
+ ```bash
787
+ # Run full installation diagnostics in current directory
788
+ mj doctor
789
+
790
+ # Filter to a specific diagnostic scope or emit machine-readable JSON
791
+ mj doctor --dir ./my-mj-project --scope ai --verbose
792
+ mj doctor --format json
793
+
794
+ # Generate a shareable support report (or extended report with service startup logs)
795
+ mj doctor --report
796
+ mj doctor --report_extended
797
+ ```
373
798
 
374
799
  | Flag | Short | Description |
375
800
  |------|-------|-------------|
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. |
801
+ | `--dir <path>` | | Target directory to diagnose (default `.`) |
802
+ | `--scope <name>` | | Filter diagnostics: `install \| runtime \| ai \| metadata \| agent` |
803
+ | `--format` | | Output format (`text \| json \| md`) |
804
+ | `--verbose` | `-v` | Show detailed output with inline suggested fixes |
805
+ | `--report` | `-r` | Write `mj-diagnostic-report.md` |
806
+ | `--report_extended` | | Extended report with config snapshots and startup log capture |
807
+
808
+ #### mj doctor value-lists
381
809
 
382
- ##### Recommended migration workflow
810
+ 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
811
 
384
812
  ```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/
813
+ # Scan all entities (read-only)
814
+ mj doctor value-lists
389
815
 
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
816
+ # Scan specific entities and fail CI if findings exist
817
+ mj doctor value-lists --entity "MJ: AI Agents" --format json --fail-on-findings
394
818
 
395
- # 3. Build and test
396
- npm run build
819
+ # Relax named fields to ListOrUserEntry through the entity layer
820
+ mj doctor value-lists --fix "Projects.Phase,Projects.Status"
397
821
  ```
398
822
 
399
- ### mj sync
823
+ Flags: `--entity <name>` (repeatable), `--format`, `--fail-on-findings`, `--fix <Entity.Field,...>` (repeatable).
824
+
825
+ ---
826
+
827
+ ### mj explorer
828
+
829
+ Post-build tasks for MJ Explorer hosts.
830
+
831
+ #### mj explorer postbuild
400
832
 
401
- Metadata synchronization between JSON files and the database.
833
+ 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
834
 
403
835
  ```bash
404
- # Initialize metadata directory
405
- mj sync init
836
+ mj explorer postbuild --dir dist/MJExplorer/browser
837
+ mj explorer postbuild --dir dist/MJExplorer/browser --quiet
838
+ ```
839
+
840
+ Flags: `--dir <path>` (required), `-q, --quiet`.
406
841
 
407
- # Check sync status
408
- mj sync status
842
+ ---
409
843
 
410
- # Pull metadata from database to files
411
- mj sync pull
844
+ ### mj harness
412
845
 
413
- # Push metadata from files to database
414
- mj sync push
846
+ 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).
415
847
 
416
- # Validate metadata files
417
- mj sync validate
848
+ 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).
418
849
 
419
- # Watch for file changes
420
- mj sync watch
850
+ #### Practical multi-account setup & balancing workflow
421
851
 
422
- # Reset file state
423
- mj sync file-reset
852
+ ```bash
853
+ # 1. Inspect existing OS-default and enrolled slots (also probes live `<binary> --version` health)
854
+ mj harness account list
855
+ mj harness account list --vendor claude --json
856
+
857
+ # 2. Enroll extra isolated accounts across vendors (launches each vendor's interactive OAuth login)
858
+ mj harness account add claude --label "Pro #2" --weight 2 --priority 50
859
+ mj harness account add agy --label "Team Seat"
860
+ mj harness account add codex --label "Codex #2" --no-login
861
+ mj harness account add gemini --label "Gemini Alt"
862
+
863
+ # 3. Choose the default pool balancing strategy:
864
+ # least-in-flight (default) | weighted | round-robin | priority-failover
865
+ mj harness account set-strategy least-in-flight
866
+ mj harness account set-strategy weighted
867
+ mj harness account set-strategy round-robin
868
+ mj harness account set-strategy priority-failover
869
+
870
+ # 4. Re-authenticate a slot (clears active cooldown) or manage cooldown / enabled state
871
+ mj harness account login claude-pro-2
872
+ mj harness account clear-cooldown claude-pro-2
873
+ mj harness account disable os-default-claude
874
+ mj harness account enable os-default-claude
875
+
876
+ # 5. Remove an enrolled slot (add --purge-files to delete its isolated directory too)
877
+ mj harness account remove codex-codex-2 --purge-files
878
+
879
+ # 6. Target an isolated pool directory (e.g. per-team or CI runner)
880
+ MJ_HARNESS_ACCOUNT_POOL_DIR=/srv/mj-harness-pool mj harness account list
424
881
  ```
425
882
 
426
- ### mj ai
883
+ #### Auth status & live binary health probing
427
884
 
428
- AI-powered operations.
885
+ `mj harness account list` verifies both credential presence and CLI executability (`<binary> --version`) for every listed vendor:
886
+
887
+ | `AUTH` Status | Meaning |
888
+ |---------------|---------|
889
+ | `Ready` | Credentials exist for the slot and `<binary> --version` succeeded. |
890
+ | `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. |
891
+ | `Needs Login` | CLI binary is runnable, but the slot has no active login session yet (`mj harness account login <slotId>`). |
892
+
893
+ #### Subcommands & flags
894
+
895
+ | Subcommand | Args & Key Flags |
896
+ |------------|------------------|
897
+ | `mj harness account list` | `-v, --vendor <claude\|agy\|codex\|gemini>`, `--json`, `--pool-dir <dir>` |
898
+ | `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>` |
899
+ | `mj harness account login <slotId>` | `--pool-dir <dir>` |
900
+ | `mj harness account remove <slotId>` | `--purge-files`, `--pool-dir <dir>` |
901
+ | `mj harness account set-strategy <strategy>` | `strategy`: `least-in-flight \| round-robin \| weighted \| priority-failover`; `--pool-dir <dir>` |
902
+ | `mj harness account enable <slotId>` | `--pool-dir <dir>` |
903
+ | `mj harness account disable <slotId>` | `--pool-dir <dir>` |
904
+ | `mj harness account clear-cooldown <slotId>` | `--pool-dir <dir>` |
905
+
906
+ ---
907
+
908
+ ### mj install
909
+
910
+ Install MemberJunction from a GitHub release, or seed the MemberJunction Claude Code pack into an existing project.
911
+
912
+ #### mj install
429
913
 
430
914
  ```bash
431
- mj ai
915
+ # Interactive installer (shows version picker)
916
+ mj install
917
+
918
+ # Non-interactive install of a specific release tag (or preview with --dry-run)
919
+ mj install -t v6.0.0 --dir ./my-mj-app --yes
920
+ mj install --dry-run
921
+
922
+ # Config-driven install, skipping DB provisioning or startup smoke tests
923
+ mj install -c ./install-config.json --skip-db --skip-start --fast
432
924
  ```
433
925
 
434
- ### mj test
926
+ 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`.
927
+
928
+ #### mj install claude
435
929
 
436
- Testing framework operations (delegates to `@memberjunction/testing-cli`).
930
+ Install or refresh the MemberJunction Claude Code pack (`CLAUDE.md` managed block, `.claude/commands/`, `.claude/skills/`, and `.claude/settings.json`) in a directory.
437
931
 
438
932
  ```bash
439
- # Run a test
440
- mj test run --name "My Test"
933
+ mj install claude
934
+ mj install claude --dry-run
935
+ mj install claude --from ./local-pack --offline --json
936
+ ```
441
937
 
442
- # Run a suite
443
- mj test suite --name "My Suite"
938
+ 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`.
444
939
 
445
- # List tests
446
- mj test list
940
+ ---
941
+
942
+ ### mj migrate
447
943
 
448
- # View history
449
- mj test history --name "My Test"
944
+ 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).
450
945
 
451
- # Compare runs
452
- mj test compare --run1 id1 --run2 id2
946
+ #### mj migrate
453
947
 
454
- # Validate test config
455
- mj test validate --name "My Test"
948
+ ```bash
949
+ # Apply pending migrations using mj.config.cjs
950
+ mj migrate
951
+
952
+ # Verify database connectivity and TLS without migrating
953
+ mj migrate --check-connection
954
+
955
+ # Migrate a specific schema and directory (or remote version tag)
956
+ mj migrate --schema __my_app --dir ./migrations/v1 --verbose
957
+ mj migrate --schema __my_app --tag v1.0.0 --skip-cache-clear
456
958
  ```
457
959
 
458
- ### mj dbdoc
960
+ | Flag | Short | Description |
961
+ |------|-------|-------------|
962
+ | `--verbose` | `-v` | Enable detailed logging |
963
+ | `--tag <version>` | `-t` | Version tag for remote migrations |
964
+ | `--schema <name>` | `-s` | Target schema (overrides `coreSchema` / `mj-app.json` auto-detection; auto-created if missing) |
965
+ | `--dir <path>` | | Migration source directory override |
966
+ | `--check-connection` | | Verify DB connection and TLS, then exit without migrating |
967
+ | `--skip-cache-clear` | | Skip automatic Redis cache clear after applying migrations (`MJ_SKIP_SHARED_CACHE_CLEAR=1`) |
968
+
969
+ Request timeout defaults to 30 minutes per batch; override with `MJ_MIGRATION_REQUEST_TIMEOUT` (ms) or `dbRequestTimeout` in `mj.config.cjs`.
459
970
 
460
- Database documentation generation.
971
+ #### mj migrate create
972
+
973
+ Scaffold a timestamped migration file for SQL Server or PostgreSQL.
461
974
 
462
975
  ```bash
463
- # Initialize documentation
464
- mj dbdoc init
976
+ mj migrate create "Add Priority To Tasks"
977
+ mj migrate create "Add Priority To Tasks" --version 6.2 --platform postgresql --dir ./migrations-pg/v6
978
+ ```
979
+
980
+ Args & flags: `<description>` (required), `-v, --version <M.N>`, `-p, --platform <sqlserver|postgresql>`, `--dir <path>`, `--x-x`.
981
+
982
+ #### mj migrate convert
983
+
984
+ 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.
985
+
986
+ ```bash
987
+ # Standard split-and-regenerate conversion
988
+ mj migrate convert --split --dry-run
989
+ mj migrate convert --split --file V202604060452__v5.24.x__KnowledgeHub.sql
465
990
 
466
- # Analyze database schema
467
- mj dbdoc analyze
991
+ # Bake native PostgreSQL CodeGen inline against a seeded PG database
992
+ mj migrate convert --split --bake-codegen --source-dir ./migrations/v6 --output-dir ./migrations-pg/v6
468
993
 
469
- # Export documentation
470
- mj dbdoc export
994
+ # Open App conversion with distinct app schema and core schema
995
+ mj migrate convert --split --schema __mj_MyApp --core-schema __mj --source-dir ./migrations/v1 --output-dir ./migrations-pg/v1
996
+ ```
997
+
998
+ 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`.
999
+
1000
+ #### mj migrate rebake
471
1001
 
472
- # Check status
473
- mj dbdoc status
1002
+ Re-bake post-baseline PostgreSQL migrations with fresh inline native CodeGen while keeping committed hand-written DDL regions byte-for-byte intact.
474
1003
 
475
- # Reset documentation
476
- mj dbdoc reset
1004
+ ```bash
1005
+ # Dry-run preview of post-baseline migrations that would be rebaked
1006
+ mj migrate rebake --dry-run
1007
+
1008
+ # Re-bake all post-baseline migrations and write output
1009
+ mj migrate rebake --baseline-floor V202605291452 --write
477
1010
 
478
- # Generate sample queries
479
- mj dbdoc generate-queries
480
- mj dbdoc export-sample-queries
1011
+ # Capture CodeGen for a single already-applied PG migration
1012
+ mj migrate rebake --file V202611031700__v6.2.x__Example.sql --capture-only
481
1013
  ```
482
1014
 
1015
+ Key flags: `--source-dir`, `--output-dir`, `--schema`, `--core-schema`, `--baseline-floor <ver>`, `--file <name>`, `--capture-only`, `--write`, `--dry-run`.
1016
+
1017
+ ---
1018
+
1019
+ ### mj plugin
1020
+
1021
+ Register third-party CLI plugins so `mj` loads them automatically at startup.
1022
+
1023
+ #### mj plugin add
1024
+
1025
+ ```bash
1026
+ mj plugin add @my-org/mj-plugin/plugins
1027
+ mj plugin add ./local-plugins/my-tool --format json
1028
+ ```
1029
+
1030
+ Args & flags: `<package>` (required — npm package name, subpath, or relative path), `--format <text|json>`.
1031
+
1032
+ ---
1033
+
483
1034
  ### mj query
484
1035
 
485
- Saved query maintenance.
1036
+ Saved query metadata maintenance.
486
1037
 
487
1038
  #### mj query refresh
488
1039
 
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.
1040
+ 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
1041
 
491
1042
  ```bash
492
- # Recommended after upgrading: review first, then apply
1043
+ # Recommended after upgrading: preview first, then apply
493
1044
  mj query refresh --all --dry-run
494
1045
  mj query refresh --all
495
1046
 
496
- # One query by full path, or every query with a bare name
1047
+ # Target specific queries by path, category, entity, or ID
497
1048
  mj query refresh --name "MJ/Reports/Top Customers"
498
-
499
- # A category and everything below it, filling empty descriptions with the LLM
500
1049
  mj query refresh --category MJ --with-ai
501
-
502
- # Every query that reads an entity
503
- mj query refresh --entity "MJ: AI Agents"
1050
+ mj query refresh --entity "MJ: AI Agents" --verbose
504
1051
  ```
505
1052
 
506
1053
  | Flag | Description |
507
1054
  |------|-------------|
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. |
1055
+ | `--id <id>` | Refresh the query with this ID (repeatable) |
1056
+ | `--name <name>` | Query name or full path `Category/Sub/Name` (repeatable) |
1057
+ | `--category <path>` | Category path and all descendant categories |
1058
+ | `--entity <name>` | Queries that read this entity (repeatable) |
1059
+ | `--all` | Refresh every query |
1060
+ | `--dry-run` | Report changes without writing |
1061
+ | `--with-ai` | Fill empty descriptions via LLM (off by default) |
1062
+ | `-v, --verbose` | Also list unchanged queries |
1063
+ | `--format <text\|json>` | Output format (default `text`) |
1064
+
1065
+ Exit codes: `0` (all refreshed/unchanged/skipped), `1` (a query failed or `--id`/`--name` matched nothing), `2` (no selector flag given).
1066
+
1067
+ ---
1068
+
1069
+ ### mj querygen
1070
+
1071
+ AI-assisted stored query template generation, validation, and export (delegates to `@memberjunction/query-gen`).
517
1072
 
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.
1073
+ ```bash
1074
+ # Generate SQL query templates for specific entities
1075
+ mj querygen generate --entities "Customers,Orders" --max-entities 5 --mode metadata --verbose
519
1076
 
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:
1077
+ # Validate query templates in metadata files
1078
+ mj querygen validate --path ./metadata/queries --verbose
521
1079
 
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).
1080
+ # Export queries from database to metadata files
1081
+ mj querygen export --output ./metadata/queries --verbose
529
1082
  ```
530
1083
 
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.
1084
+ 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`.
1085
+
1086
+ ---
1087
+
1088
+ ### mj queue
532
1089
 
533
- **Exit codes.**
1090
+ 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).
1091
+
1092
+ ```bash
1093
+ # Publish one or more messages to a topic (supports partition & dedup keys)
1094
+ mj queue publish --topic samples.hello --payload '{"name":"Alex"}'
1095
+ mj queue publish --topic samples.hello --count 5 --partition-key customer-42 --dedup-key batch-1 --attribute source=cli
1096
+
1097
+ # Inspect subscription counts, autoscaler backlog, and blocked partitions
1098
+ mj queue stats
1099
+ mj queue stats --subscription email.unsubscribe --json
1100
+ mj queue backlog --subscription venue-import --json
1101
+ mj queue partitions --subscription integration.apply --condition Blocked
1102
+
1103
+ # Inspect, replay, or discard dead-lettered / in-flight deliveries
1104
+ mj queue dead-letters --subscription integration.apply --page-size 20
1105
+ mj queue replay --subscription integration.apply --delivery <delivery-id> --note "mapping fixed"
1106
+ mj queue discard --subscription integration.apply --delivery <delivery-id> --reason "bad batch, republished"
1107
+
1108
+ # Run container-job or long-running workers and manual sweeper passes
1109
+ mj queue work --subscription venue-import --once --max 5 --concurrency 2 --max-duration-ms 3300000
1110
+ mj queue work --subscription "*" --concurrency 4
1111
+ mj queue sweep --json
1112
+
1113
+ # Cloud transport topology & Terraform binding lifecycle
1114
+ mj queue export-topology --transport AWS-prod --output infrastructure/work-queue/manifest.json
1115
+ mj queue import-bindings bindings.json
1116
+ mj queue validate-bindings --transport AWS-prod
1117
+ ```
534
1118
 
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. |
1119
+ | Subcommand | Key Flags / Args |
1120
+ |------------|------------------|
1121
+ | `mj queue publish` | `-t, --topic` (req), `-p, --payload`, `-k, --partition-key`, `--dedup-key`, `-a, --attribute <k=v>` (repeatable), `-n, --count`, `--json` |
1122
+ | `mj queue stats` | `-s, --subscription`, `--json` |
1123
+ | `mj queue backlog` | `-s, --subscription` (req), `--json` |
1124
+ | `mj queue partitions` | `-s, --subscription` (req), `--condition <Idle\|InFlight\|Blocked>`, `--cursor`, `--page-size`, `--json` |
1125
+ | `mj queue dead-letters` | `-s, --subscription` (req), `--cursor`, `--page-size`, `--json` |
1126
+ | `mj queue replay` | `-s, --subscription` (req), `-d, --delivery` (req), `--note` |
1127
+ | `mj queue discard` | `-s, --subscription` (req), `-d, --delivery` (req), `-r, --reason` (req) |
1128
+ | `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` |
1129
+ | `mj queue sweep` | `--json` |
1130
+ | `mj queue export-topology` | `-t, --transport` (req), `-o, --output` |
1131
+ | `mj queue import-bindings <file>` | `--json` |
1132
+ | `mj queue validate-bindings` | `-t, --transport`, `--json` |
540
1133
 
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.
1134
+ ---
542
1135
 
543
- #### mj query usage
1136
+ ### mj rubric
544
1137
 
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.
1138
+ List, inspect, diff, validate, and evaluate versioned scoring rubrics (`mj rubric` displays topic help). See [`guides/RUBRICS_GUIDE.md`](../../guides/RUBRICS_GUIDE.md).
546
1139
 
547
1140
  ```bash
548
- mj query usage
549
- mj query usage --format=json
1141
+ # List all rubrics
1142
+ mj rubric list
1143
+
1144
+ # Show a rubric (optionally pinned to @version) and its criteria
1145
+ mj rubric show "Agent Quality"
1146
+ mj rubric show "Agent Quality@1.2.0"
1147
+
1148
+ # Diff two versions of a rubric
1149
+ mj rubric diff "Agent Quality" 1.1.0 1.2.0
1150
+
1151
+ # Validate a rubric JSON snapshot file locally (duplicate keys, gates, weights, scales)
1152
+ mj rubric validate ./rubric-publications/agent-quality.json
1153
+
1154
+ # Evaluate a single entity record against a rubric (does not publish)
1155
+ mj rubric evaluate --rubric "Agent Quality@1.2.0" --entity "MJ: AI Agent Runs" --record <record-id> --evaluator LLM --mode SinglePass
550
1156
  ```
551
1157
 
552
- ### mj querygen
1158
+ 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>`.
553
1159
 
554
- Query generation tools.
1160
+ ---
1161
+
1162
+ ### mj sql-audit
1163
+
1164
+ Compare source and target databases (e.g. SQL Server vs PostgreSQL) for migration verification.
555
1165
 
556
1166
  ```bash
557
- mj querygen generate
558
- mj querygen export
559
- mj querygen validate
1167
+ mj sql-audit --source "mssql://sa:pass@host/db" --target "postgres://user:pass@host:5432/db"
1168
+ mj sql-audit --source "mssql://..." --target "postgres://..." --source-schema __mj --target-schema __mj --output report.txt
560
1169
  ```
561
1170
 
562
- ### mj bump
1171
+ Flags: `--source <conn>` (required), `--target <conn>` (required), `--source-schema <name>` (default `__mj`), `--target-schema <name>` (default `__mj`), `-o, --output <file>`.
563
1172
 
564
- Version management for packages.
1173
+ ---
1174
+
1175
+ ### mj sql-convert
1176
+
1177
+ Convert standalone SQL files between database dialects using the rule-based `BatchConverter` engine.
565
1178
 
566
1179
  ```bash
567
- mj bump
1180
+ mj sql-convert ./migration.sql --from tsql --to postgres
1181
+ mj sql-convert ./migration.sql --from tsql --to postgres --output converted.sql --schema my_schema --no-header --verbose
568
1182
  ```
569
1183
 
570
- ### mj clean
1184
+ Args & flags: `<source>` (required), `--from <dialect>` (required), `--to <dialect>` (required), `-o, --output <path>`, `--schema <name>` (default `__mj`), `--no-header`, `--no-post-process`, `-v, --verbose`.
1185
+
1186
+ ---
1187
+
1188
+ ### mj standards
571
1189
 
572
- Clean build artifacts.
1190
+ 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
1191
 
574
1192
  ```bash
575
- mj clean
1193
+ # List all available standards and this repository's adoption stance
1194
+ mj standards list --verbose
1195
+
1196
+ # Run all adopted standards (or target one check; add --strict to fail on warnings)
1197
+ mj standards check
1198
+ mj standards check --check naming-conventions --strict
1199
+ mj standards check --quiet
1200
+
1201
+ # Adopt standards into a repository (config + optional GitHub Actions workflow + npm script)
1202
+ mj standards adopt --ci github --declare-compliant
1203
+ mj standards adopt --upgrade --dry-run
576
1204
  ```
577
1205
 
578
- ### mj app
1206
+ | Subcommand | Key Flags |
1207
+ |------------|-----------|
1208
+ | `mj standards list` | `--cwd <dir>`, `-v, --verbose` |
1209
+ | `mj standards check` | `--cwd <dir>`, `--check <id>` (repeatable), `--strict`, `--quiet` |
1210
+ | `mj standards adopt` | `--cwd <dir>`, `--check <id>` (repeatable), `--ci <github\|none>`, `--[no-]npm-script`, `--declare-compliant`, `--upgrade`, `--dry-run` |
1211
+
1212
+ ---
579
1213
 
580
- Install, upgrade, and manage MJ Open Apps (packaged via `@memberjunction/open-app-engine`).
1214
+ ### mj sync
1215
+
1216
+ Synchronize metadata between local JSON files and the database (delegates to `@memberjunction/metadata-sync`).
581
1217
 
582
1218
  ```bash
583
- # List installed apps
584
- mj app list
1219
+ # Initialize a metadata directory (prompts at a terminal; scriptable with --setup-entity)
1220
+ mj sync init
1221
+ mj sync init --setup-entity=ai-prompts
1222
+ mj sync init --setup-entity=other --entity="MJ: AI Models" --dir=ai-models --no-interactive
585
1223
 
586
- # Show detailed info for one app
587
- mj app info <name>
1224
+ # Check status of local files vs database
1225
+ mj sync status --dir="ai-prompts" --verbose
588
1226
 
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
1227
+ # Pull metadata from database to local files
1228
+ mj sync pull --entity="MJ: AI Prompts" --dry-run
1229
+ mj sync pull --entity="MJ: AI Prompts" --incremental --merge-strategy=merge --backup-before-update
592
1230
 
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
1231
+ # Push local metadata files to database (atomic single transaction by default)
1232
+ mj sync push --dir="metadata" --dry-run
1233
+ mj sync push --dir="metadata" --ci --incremental
1234
+ mj sync push --isolated-transactions --parallel-batch-size=10 --change-detail
596
1235
 
597
- # Enable / disable without removing
598
- mj app enable <name>
599
- mj app disable <name>
1236
+ # Validate metadata files and optionally write a markdown report
1237
+ mj sync validate --dir="metadata" --save-report --output=validation-report.md
600
1238
 
601
- # Remove (add --keep-data to preserve the schema)
602
- mj app remove <name>
603
- mj app remove <name> --keep-data
1239
+ # Watch for file changes and sync automatically
1240
+ mj sync watch --dir="ai-prompts" --debounce=1000
604
1241
 
605
- # See which installed apps have newer versions available
606
- mj app check-updates
1242
+ # Reset stored metadata sections on local files
1243
+ mj sync file-reset --dir="ai-prompts" --sections="dependencies,references" --dry-run
607
1244
  ```
608
1245
 
609
- #### Private repositories
1246
+ ---
1247
+
1248
+ ### mj test
1249
+
1250
+ 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
1251
 
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:
1252
+ #### Core test execution & reporting
614
1253
 
615
1254
  ```bash
616
- # 1. Environment variable
617
- GITHUB_TOKEN=$(gh auth token) mj app install https://github.com/MemberJunction/bizapps-ats
1255
+ # Run a single test by ID or name (supports --rubric, --checks-module, --oracles-module, --dry-run)
1256
+ mj test run <test-id>
1257
+ mj test run --name="Active Members Count" --environment=staging --format=json --output=results.json
618
1258
 
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 } } }
1259
+ # Run a test suite (supports parallel execution, sharding, flaky-check, transport & test filters)
1260
+ mj test suite <suite-id> --parallel --max-parallel=4 --shard=1/3
1261
+ mj test suite --name="Agent Quality Suite" --flaky-check=3 --transport=server
1262
+ mj test suite --name="MJ Explorer Regression Suite" --test="T001 - Login Smoke"
621
1263
 
622
- # 3. mj.config.cjs — one token for every Open App repo
623
- # openApps: { github: { token: process.env.GITHUB_TOKEN } }
624
- ```
1264
+ # List tests, suites, or test types
1265
+ mj test list
1266
+ mj test list --suites --tag=smoke --status=active
1267
+ mj test list --types
625
1268
 
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`.
1269
+ # View test execution history
1270
+ mj test history --test=<test-id> --recent=20 --from=2026-01-01
628
1271
 
629
- The token needs `repo` scope for the repositories you install from.
1272
+ # Compare test runs (DB mode by ID/version/commit/--latest, or offline --from-json)
1273
+ mj test compare --latest --format=markdown --output=report.md
1274
+ mj test compare <run-id-1> <run-id-2> --diff-only
1275
+ mj test compare --from-json baseline.json --from-json latest.json
630
1276
 
631
- #### Internal / dangerous flags
1277
+ # Print per-criterion rubric breakdown for a test run
1278
+ mj test report <run-id>
1279
+
1280
+ # Validate test definitions without executing
1281
+ mj test validate --all --save-report --output=validation-report.md
1282
+
1283
+ # Promote a test's inline judge criteria into a Draft rubric and bind Test.RubricID
1284
+ mj test promote-criteria <test-id>
1285
+ mj test promote-criteria "Reply check"
632
1286
 
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.
1287
+ # Review, promote, or discard pending recorded replay scripts
1288
+ mj test scripts
1289
+ mj test scripts --test "T042 - Filter Grid" --promote
1290
+ mj test scripts --test "T042 - Filter Grid" --discard
1291
+ mj test scripts --promote --yes --format=md --output=drift.md
1292
+ ```
636
1293
 
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.
1294
+ #### mj test regression
645
1295
 
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.
1296
+ Docker-based LLM-driven browser regression testing for MJ Explorer and external web apps (`mj test regression` prints subcommand overview).
651
1297
 
652
1298
  ```bash
653
- mj app install https://github.com/BlueCypress/SaaS \
654
- --dangerously-ignore-dbl-underscore-schema-rule
1299
+ # Scaffold a bundled regression-suite mode template
1300
+ mj test regression init --list
1301
+ mj test regression init generic-web
1302
+
1303
+ # Author a new regression test entry
1304
+ mj test regression new --name "Form builder clones a form" --priority P1 --tags form-builder \
1305
+ --start-path /app/form-builder --goal "Clone Contact Form and verify the copy opens in the editor." \
1306
+ --criteria "A form named Copy of Contact Form is listed"
1307
+
1308
+ # Build images (runs gen-forms automatically when .docker-generated/ is empty) or regenerate forms directly
1309
+ mj test regression build
1310
+ mj test regression build mjexplorer --skip-gen-forms
1311
+ mj test regression gen-forms
1312
+
1313
+ # Run self-contained local stack (Mode A) or against a .bacpac database
1314
+ mj test regression up
1315
+ mj test regression up --test="T001 - Login Smoke" --detach
1316
+ mj test regression up --bacpac=./db.bacpac --suite="My Suite" --metadata=./my-suite-metadata
1317
+
1318
+ # Run against a remote URL or compose overlay (Mode B/C/D)
1319
+ mj test regression remote --target=staging-mj
1320
+ mj test regression remote --target=./app/target.json --overlay=./app/docker-compose.app.yml --env-file=./.env
1321
+
1322
+ # Compare recent runs, export a self-contained HTML report, and tear down
1323
+ mj test regression compare --diff-only
1324
+ mj test regression export --run=run-20260526T220118Z
1325
+ mj test regression down --keep-volumes
655
1326
  ```
656
1327
 
657
- ### mj baseline
1328
+ ---
658
1329
 
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.
1330
+ ### mj translate-sql
660
1331
 
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.
1332
+ Translate SQL fragments and stored MJ metadata SQL (`queries`, `views`, `filters`, or `all`) between SQL Server and PostgreSQL.
662
1333
 
663
- Three subcommands:
1334
+ ```bash
1335
+ # Preview translations across all stored SQL metadata
1336
+ mj translate-sql --from sqlserver --to postgresql --dry-run
664
1337
 
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.
1338
+ # Translate stored queries only or generate a review report without DB writes
1339
+ mj translate-sql --from sqlserver --to postgresql --scope queries
1340
+ mj translate-sql --from sqlserver --to postgresql --scope all --review --output ./reports
668
1341
 
669
- #### Two operating modes
1342
+ # Translate a single inline SQL fragment
1343
+ mj translate-sql --from sqlserver --to postgresql --sql "SELECT TOP 10 [Name] FROM [Users]"
1344
+ ```
670
1345
 
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) |
1346
+ 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
1347
 
676
- AUTO mode is the right choice 99% of the time. EXPLICIT is for starting a new major version (e.g. `v6.0`).
1348
+ ---
677
1349
 
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).
1350
+ ### mj update
679
1351
 
680
- #### mj baseline build
1352
+ Update installed MemberJunction developer tooling.
681
1353
 
682
- ```bash
683
- # AUTO — within-major rebaseline (writes back into ./migrations/v5/)
684
- mj baseline build --out ./migrations/v5/
1354
+ #### mj update claude
685
1355
 
686
- # EXPLICIT — start a new major version (writes into ./migrations/v6/)
687
- mj baseline build --baseline-version 6.0 --out ./migrations/v6/
1356
+ Check for or apply updates to the MemberJunction Claude Code pack in a repository.
688
1357
 
689
- # Schema-only, no data inserts
690
- mj baseline build --no-data --out ./baselines/
1358
+ ```bash
1359
+ mj update claude --check
1360
+ mj update claude
1361
+ mj update claude --refresh-commands --refresh-skills --allow-major --json
691
1362
  ```
692
1363
 
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.
1364
+ 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
1365
 
695
- Database host/user/password come from the MJ config (`mj.config.cjs` / `.env`); `--database` overrides only the database name.
1366
+ ---
696
1367
 
697
- #### mj baseline compare
1368
+ ### mj usage
1369
+
1370
+ 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
1371
 
699
1372
  ```bash
700
- # Full row-by-row diff (default)
701
- mj baseline compare --left MJ_BL_Stack --right MJ_BL_New
1373
+ mj usage
1374
+ mj usage --format=json
1375
+ mj usage --format=md
1376
+ ```
702
1377
 
703
- # Counts-only (fastest)
704
- mj baseline compare --left A --right B --row-compare counts
1378
+ Flags: `--format <text|json|md>` (defaults to `text` on a terminal and `json` when stdout is piped).
705
1379
 
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
- ```
1380
+ ---
709
1381
 
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).
1382
+ ### mj user
711
1383
 
712
- #### mj baseline roundtrip
1384
+ User administration utilities.
1385
+
1386
+ #### mj user clone
1387
+
1388
+ Create a new MemberJunction user as a copy of an existing user (defaults to the `template` preset for template users).
713
1389
 
714
1390
  ```bash
715
- # AUTO — verify the current v5.x V-stack collapses cleanly
716
- mj baseline roundtrip --source MJ_BL_Stack --target MJ_BL_New
1391
+ # Dry-run preview of cloning a template user
1392
+ mj user clone --from demo.user@example.org --email jane@example.com --first Jane --last Doe --dry-run
717
1393
 
718
- # EXPLICIT — verify a v6.0 baseline
719
- mj baseline roundtrip --baseline-version 6.0 --source MJ_BL_Stack --target MJ_BL_New
1394
+ # Clone a user with views or settings preset, optionally leaving inactive for review
1395
+ mj user clone --from alice@example.com --email bob@example.com --first Bob --last Lee --preset with-settings --inactive
720
1396
  ```
721
1397
 
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
1398
+ | Flag | Description |
1399
+ |------|-------------|
1400
+ | `--from <email>` | Email of the source user to copy (required) |
1401
+ | `--email <email>` | Sign-in email of the new user (required) |
1402
+ | `--first <name>` | First name of the new user (required) |
1403
+ | `--last <name>` | Last name of the new user (required) |
1404
+ | `--preset <name>` | Clone preset: `template` (default), `with-views`, `with-settings`, or `none` |
1405
+ | `--inactive` | Leave the newly created user inactive for review |
1406
+ | `--dry-run` | Preview what would be copied without creating records |
725
1407
 
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.
1408
+ ---
730
1409
 
731
1410
  ## Hooks
732
1411
 
733
1412
  | Hook | Timing | Purpose |
734
1413
  |------|--------|---------|
735
1414
  | `init` | Before any command | Loads configuration, initializes environment |
736
- | `prerun` | Before command execution | Validates configuration, connects to database |
1415
+ | `prerun` | Before command execution | Validates configuration, loads bootstrap & dynamic packages for non-light commands |
1416
+ | `postrun` | After command execution | Releases wake locks and performs post-command cleanup |
737
1417
 
738
1418
  ## Plugin System
739
1419
 
740
1420
  The CLI includes these oclif plugins:
741
1421
 
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)
1422
+ - `@oclif/plugin-help` — Auto-generated help text
1423
+ - `@oclif/plugin-version` — Version display
1424
+ - `@oclif/plugin-warn-if-update-available` — Update notifications (checks daily)
1425
+
1426
+ Third-party CLI plugins can be registered via `mj plugin add <package>` in `mj-cli-plugins.json`.
745
1427
 
746
1428
  ## Dependencies
747
1429
 
748
1430
  | Package | Purpose |
749
1431
  |---------|---------|
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 |
1432
+ | `@memberjunction/ai-agent-harness` | Multi-account CLI harness pool and runtime integration |
1433
+ | `@memberjunction/ai-cli` | AI agent, prompt, action, and audit operations |
1434
+ | `@memberjunction/cli-core` | Shared CLI plugin contract, envelopes, and usage registry |
1435
+ | `@memberjunction/codegen-lib` | Code generation engine and manifest scanner |
756
1436
  | `@memberjunction/config` | Configuration management |
1437
+ | `@memberjunction/db-auto-doc` | AI-powered database documentation |
1438
+ | `@memberjunction/diagnostics` | `.mjdiag` archive verification, scrubbing, timeline, and export |
1439
+ | `@memberjunction/installer` | Release installation, offline bundling, and environment doctor |
1440
+ | `@memberjunction/metadata-sync` | Metadata synchronization |
1441
+ | `@memberjunction/open-app-engine` | Open App lifecycle management |
1442
+ | `@memberjunction/query-gen` | AI query template generation |
1443
+ | `@memberjunction/record-cloning` | Entity/user cloning engine |
1444
+ | `@memberjunction/redis-provider` | Shared Redis cache inspection and invalidation |
757
1445
  | `@memberjunction/server-bootstrap-lite` | Lightweight server initialization |
758
- | `@memberjunction/sqlserver-dataprovider` | Database connectivity |
759
- | `@oclif/core` | CLI framework |
760
- | `cosmiconfig` | Configuration file loading |
761
1446
  | `@memberjunction/skyway-core` | Database migration execution |
762
- | `simple-git` | Git operations |
763
- | `figlet` | ASCII art for banners |
1447
+ | `@memberjunction/sql-converter` | Rule-based SQL dialect conversion and auditing |
1448
+ | `@memberjunction/standards` | Repository engineering standards engine |
1449
+ | `@memberjunction/testing-cli` | Testing framework CLI |
1450
+ | `@memberjunction/work-queue-engine` | Durable work queue operations |
1451
+ | `@oclif/core` | CLI framework |
764
1452
 
765
1453
  ## License
766
1454