@memberjunction/cli 6.1.4 → 6.2.0-edge.1

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 (235) hide show
  1. package/README.md +18 -7
  2. package/dist/baseline/cli-helpers.d.ts +4 -0
  3. package/dist/baseline/cli-helpers.d.ts.map +1 -1
  4. package/dist/baseline/cli-helpers.js +18 -10
  5. package/dist/baseline/cli-helpers.js.map +1 -1
  6. package/dist/baseline/comparator.d.ts +5 -3
  7. package/dist/baseline/comparator.d.ts.map +1 -1
  8. package/dist/baseline/comparator.js +142 -138
  9. package/dist/baseline/comparator.js.map +1 -1
  10. package/dist/baseline/connection.d.ts +8 -6
  11. package/dist/baseline/connection.d.ts.map +1 -1
  12. package/dist/baseline/connection.js +16 -12
  13. package/dist/baseline/connection.js.map +1 -1
  14. package/dist/baseline/data-dumper.d.ts +7 -3
  15. package/dist/baseline/data-dumper.d.ts.map +1 -1
  16. package/dist/baseline/data-dumper.js +33 -25
  17. package/dist/baseline/data-dumper.js.map +1 -1
  18. package/dist/baseline/emitter.d.ts +5 -3
  19. package/dist/baseline/emitter.d.ts.map +1 -1
  20. package/dist/baseline/emitter.js +114 -110
  21. package/dist/baseline/emitter.js.map +1 -1
  22. package/dist/baseline/index.d.ts +7 -7
  23. package/dist/baseline/index.d.ts.map +1 -1
  24. package/dist/baseline/index.js +7 -7
  25. package/dist/baseline/index.js.map +1 -1
  26. package/dist/baseline/introspector-mssql.d.ts +2 -0
  27. package/dist/baseline/introspector-mssql.d.ts.map +1 -1
  28. package/dist/baseline/introspector-mssql.js +68 -64
  29. package/dist/baseline/introspector-mssql.js.map +1 -1
  30. package/dist/baseline/introspector-postgres.d.ts +2 -0
  31. package/dist/baseline/introspector-postgres.d.ts.map +1 -1
  32. package/dist/baseline/introspector-postgres.js +34 -30
  33. package/dist/baseline/introspector-postgres.js.map +1 -1
  34. package/dist/baseline/report.d.ts +4 -0
  35. package/dist/baseline/report.d.ts.map +1 -1
  36. package/dist/baseline/report.js +25 -17
  37. package/dist/baseline/report.js.map +1 -1
  38. package/dist/baseline/types.d.ts +71 -71
  39. package/dist/baseline/util.d.ts +54 -6
  40. package/dist/baseline/util.d.ts.map +1 -1
  41. package/dist/baseline/util.js +112 -36
  42. package/dist/baseline/util.js.map +1 -1
  43. package/dist/commands/agent/init.d.ts +23 -0
  44. package/dist/commands/agent/init.d.ts.map +1 -0
  45. package/dist/commands/agent/init.js +222 -0
  46. package/dist/commands/agent/init.js.map +1 -0
  47. package/dist/commands/ai/actions/list.js +7 -7
  48. package/dist/commands/ai/actions/run.js +7 -7
  49. package/dist/commands/ai/agents/list.js +7 -7
  50. package/dist/commands/ai/agents/run.js +9 -9
  51. package/dist/commands/ai/audit/agent-run.js +7 -7
  52. package/dist/commands/ai/prompts/run.js +7 -7
  53. package/dist/commands/app/check-updates.js +5 -5
  54. package/dist/commands/app/disable.js +2 -2
  55. package/dist/commands/app/enable.js +2 -2
  56. package/dist/commands/app/info.js +2 -2
  57. package/dist/commands/app/install.js +2 -2
  58. package/dist/commands/app/list.js +2 -2
  59. package/dist/commands/app/remove.js +4 -4
  60. package/dist/commands/app/upgrade.js +2 -2
  61. package/dist/commands/artifacts/reclassify.js +2 -2
  62. package/dist/commands/baseline/build.js +31 -31
  63. package/dist/commands/baseline/build.js.map +1 -1
  64. package/dist/commands/baseline/compare.js +36 -36
  65. package/dist/commands/baseline/roundtrip.js +56 -54
  66. package/dist/commands/baseline/roundtrip.js.map +1 -1
  67. package/dist/commands/bundle/index.js +4 -4
  68. package/dist/commands/clean/index.js +3 -3
  69. package/dist/commands/codegen/manifest.d.ts +2 -0
  70. package/dist/commands/codegen/manifest.d.ts.map +1 -1
  71. package/dist/commands/codegen/manifest.js +8 -4
  72. package/dist/commands/codegen/manifest.js.map +1 -1
  73. package/dist/commands/dev/workspace/index.d.ts +2 -0
  74. package/dist/commands/dev/workspace/index.d.ts.map +1 -1
  75. package/dist/commands/dev/workspace/index.js +8 -4
  76. package/dist/commands/dev/workspace/index.js.map +1 -1
  77. package/dist/commands/doctor/index.d.ts +6 -4
  78. package/dist/commands/doctor/index.d.ts.map +1 -1
  79. package/dist/commands/doctor/index.js +43 -18
  80. package/dist/commands/doctor/index.js.map +1 -1
  81. package/dist/commands/install/claude.d.ts +2 -0
  82. package/dist/commands/install/claude.d.ts.map +1 -1
  83. package/dist/commands/install/claude.js +11 -7
  84. package/dist/commands/install/claude.js.map +1 -1
  85. package/dist/commands/install/index.js +3 -3
  86. package/dist/commands/migrate/convert.d.ts +21 -0
  87. package/dist/commands/migrate/convert.d.ts.map +1 -1
  88. package/dist/commands/migrate/convert.js +22 -6
  89. package/dist/commands/migrate/convert.js.map +1 -1
  90. package/dist/commands/migrate/create.js +2 -2
  91. package/dist/commands/migrate/index.js +16 -16
  92. package/dist/commands/sync/file-reset.js +2 -2
  93. package/dist/commands/sync/init.js +3 -3
  94. package/dist/commands/test/compare.js +6 -6
  95. package/dist/commands/test/history.js +6 -6
  96. package/dist/commands/test/list.js +6 -6
  97. package/dist/commands/test/regression/build.js +5 -5
  98. package/dist/commands/test/regression/compare.js +3 -3
  99. package/dist/commands/test/regression/down.js +4 -4
  100. package/dist/commands/test/regression/export.js +4 -4
  101. package/dist/commands/test/regression/gen-forms.js +3 -3
  102. package/dist/commands/test/regression/remote.js +10 -10
  103. package/dist/commands/test/regression/up.js +6 -6
  104. package/dist/commands/test/run.js +6 -6
  105. package/dist/commands/test/scripts.d.ts +13 -0
  106. package/dist/commands/test/scripts.d.ts.map +1 -0
  107. package/dist/commands/test/scripts.js +50 -0
  108. package/dist/commands/test/scripts.js.map +1 -0
  109. package/dist/commands/test/suite.js +6 -6
  110. package/dist/commands/test/validate.js +6 -6
  111. package/dist/commands/translate-sql/index.js +25 -25
  112. package/dist/commands/update/claude.js +7 -7
  113. package/dist/commands/usage.js +4 -4
  114. package/dist/config.d.ts +175 -1
  115. package/dist/config.d.ts.map +1 -1
  116. package/dist/config.js +23 -9
  117. package/dist/config.js.map +1 -1
  118. package/dist/hooks/postrun.js +2 -2
  119. package/dist/hooks/prerun.js +2 -2
  120. package/dist/hooks/prerun.js.map +1 -1
  121. package/dist/init-templates/citizen-builder/.agents/skills/new-agent/SKILL.md +66 -0
  122. package/dist/init-templates/citizen-builder/.agents/skills/package-agent/SKILL.md +69 -0
  123. package/dist/init-templates/citizen-builder/.agents/skills/test-agent/SKILL.md +61 -0
  124. package/dist/init-templates/citizen-builder/.claude/skills/new-agent/SKILL.md +66 -0
  125. package/dist/init-templates/citizen-builder/.claude/skills/package-agent/SKILL.md +69 -0
  126. package/dist/init-templates/citizen-builder/.claude/skills/test-agent/SKILL.md +61 -0
  127. package/dist/init-templates/citizen-builder/.env.example +30 -0
  128. package/dist/init-templates/citizen-builder/AGENTS.md +331 -0
  129. package/dist/init-templates/citizen-builder/README.md +259 -0
  130. package/dist/init-templates/citizen-builder/docker/Dockerfile +16 -0
  131. package/dist/init-templates/citizen-builder/docker-compose.yml +59 -0
  132. package/dist/init-templates/citizen-builder/docs/ENTERPRISE_ORG_SETUP.md +73 -0
  133. package/dist/init-templates/citizen-builder/docs/PROMOTION_GUIDE.md +70 -0
  134. package/dist/init-templates/citizen-builder/metadata/.mj-sync.json +7 -0
  135. package/dist/init-templates/citizen-builder/metadata/agents/.customer-insight-agent.json +55 -0
  136. package/dist/init-templates/citizen-builder/metadata/agents/.mj-sync.json +45 -0
  137. package/dist/init-templates/citizen-builder/metadata/prompts/.customer-insight-prompt.json +15 -0
  138. package/dist/init-templates/citizen-builder/metadata/prompts/.mj-sync.json +45 -0
  139. package/dist/init-templates/citizen-builder/metadata/prompts/templates/customer-insight.template.md +18 -0
  140. package/dist/init-templates/citizen-builder/scripts/bootstrap.sh +47 -0
  141. package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +184 -0
  142. package/dist/init-templates/citizen-builder/scripts/generate-capabilities.sh +74 -0
  143. package/dist/init-templates/citizen-builder/scripts/query-run-history.sh +34 -0
  144. package/dist/init-templates/citizen-builder/scripts/sync-metadata.sh +14 -0
  145. package/dist/init-templates/remote-mj/README.md +4 -4
  146. package/dist/lib/claude-pack/ManagedBlockEditor.d.ts +6 -0
  147. package/dist/lib/claude-pack/ManagedBlockEditor.d.ts.map +1 -1
  148. package/dist/lib/claude-pack/ManagedBlockEditor.js +18 -6
  149. package/dist/lib/claude-pack/ManagedBlockEditor.js.map +1 -1
  150. package/dist/lib/claude-pack/PackFetcher.d.ts +8 -3
  151. package/dist/lib/claude-pack/PackFetcher.d.ts.map +1 -1
  152. package/dist/lib/claude-pack/PackFetcher.js +26 -18
  153. package/dist/lib/claude-pack/PackFetcher.js.map +1 -1
  154. package/dist/lib/claude-pack/PackInstaller.d.ts +6 -2
  155. package/dist/lib/claude-pack/PackInstaller.d.ts.map +1 -1
  156. package/dist/lib/claude-pack/PackInstaller.js +19 -13
  157. package/dist/lib/claude-pack/PackInstaller.js.map +1 -1
  158. package/dist/lib/claude-pack/PackMerger.d.ts +8 -0
  159. package/dist/lib/claude-pack/PackMerger.d.ts.map +1 -1
  160. package/dist/lib/claude-pack/PackMerger.js +63 -57
  161. package/dist/lib/claude-pack/PackMerger.js.map +1 -1
  162. package/dist/lib/claude-pack/PackOutputFormatter.d.ts +4 -0
  163. package/dist/lib/claude-pack/PackOutputFormatter.d.ts.map +1 -1
  164. package/dist/lib/claude-pack/PackOutputFormatter.js +10 -2
  165. package/dist/lib/claude-pack/PackOutputFormatter.js.map +1 -1
  166. package/dist/lib/claude-pack/PackPaths.d.ts +12 -0
  167. package/dist/lib/claude-pack/PackPaths.d.ts.map +1 -1
  168. package/dist/lib/claude-pack/PackPaths.js +31 -7
  169. package/dist/lib/claude-pack/PackPaths.js.map +1 -1
  170. package/dist/lib/claude-pack/PackTypes.d.ts +18 -14
  171. package/dist/lib/claude-pack/PackTypes.d.ts.map +1 -1
  172. package/dist/lib/claude-pack/PackTypes.js +11 -3
  173. package/dist/lib/claude-pack/PackTypes.js.map +1 -1
  174. package/dist/lib/claude-pack/SettingsMerger.d.ts +10 -0
  175. package/dist/lib/claude-pack/SettingsMerger.d.ts.map +1 -1
  176. package/dist/lib/claude-pack/SettingsMerger.js +36 -16
  177. package/dist/lib/claude-pack/SettingsMerger.js.map +1 -1
  178. package/dist/lib/cli-plugins.d.ts +2 -0
  179. package/dist/lib/cli-plugins.d.ts.map +1 -1
  180. package/dist/lib/cli-plugins.js +8 -4
  181. package/dist/lib/cli-plugins.js.map +1 -1
  182. package/dist/lib/db-preflight.d.ts +2 -0
  183. package/dist/lib/db-preflight.d.ts.map +1 -1
  184. package/dist/lib/db-preflight.js +12 -8
  185. package/dist/lib/db-preflight.js.map +1 -1
  186. package/dist/lib/db-version.d.ts +2 -0
  187. package/dist/lib/db-version.d.ts.map +1 -1
  188. package/dist/lib/db-version.js +5 -1
  189. package/dist/lib/db-version.js.map +1 -1
  190. package/dist/lib/derived-usage.d.ts +14 -8
  191. package/dist/lib/derived-usage.d.ts.map +1 -1
  192. package/dist/lib/derived-usage.js +30 -18
  193. package/dist/lib/derived-usage.js.map +1 -1
  194. package/dist/lib/domain-profiles.d.ts +4 -2
  195. package/dist/lib/domain-profiles.d.ts.map +1 -1
  196. package/dist/lib/domain-profiles.js +53 -49
  197. package/dist/lib/domain-profiles.js.map +1 -1
  198. package/dist/lib/domain-usage-command.js +4 -4
  199. package/dist/lib/dynamic-packages.d.ts +4 -2
  200. package/dist/lib/dynamic-packages.d.ts.map +1 -1
  201. package/dist/lib/dynamic-packages.js +9 -5
  202. package/dist/lib/dynamic-packages.js.map +1 -1
  203. package/dist/lib/format-compat.d.ts +9 -7
  204. package/dist/lib/format-compat.d.ts.map +1 -1
  205. package/dist/lib/format-compat.js +12 -8
  206. package/dist/lib/format-compat.js.map +1 -1
  207. package/dist/lib/interactive-guard.d.ts +16 -0
  208. package/dist/lib/interactive-guard.d.ts.map +1 -1
  209. package/dist/lib/interactive-guard.js +18 -6
  210. package/dist/lib/interactive-guard.js.map +1 -1
  211. package/dist/lib/migration-fetch.d.ts +16 -4
  212. package/dist/lib/migration-fetch.d.ts.map +1 -1
  213. package/dist/lib/migration-fetch.js +30 -18
  214. package/dist/lib/migration-fetch.js.map +1 -1
  215. package/dist/lib/regression/docker-helpers.d.ts +24 -0
  216. package/dist/lib/regression/docker-helpers.d.ts.map +1 -1
  217. package/dist/lib/regression/docker-helpers.js +46 -10
  218. package/dist/lib/regression/docker-helpers.js.map +1 -1
  219. package/dist/lib/usage-render.d.ts +6 -0
  220. package/dist/lib/usage-render.d.ts.map +1 -1
  221. package/dist/lib/usage-render.js +15 -3
  222. package/dist/lib/usage-render.js.map +1 -1
  223. package/dist/translate-sql/groundTruth.d.ts +3 -3
  224. package/dist/translate-sql/groundTruth.js +40 -40
  225. package/dist/translate-sql/reportGenerator.d.ts +7 -7
  226. package/dist/translate-sql/reportGenerator.js +18 -18
  227. package/dist/translate-sql/ruleTranslator.d.ts +3 -3
  228. package/dist/translate-sql/ruleTranslator.js +8 -8
  229. package/dist/translate-sql/ruleTranslator.js.map +1 -1
  230. package/dist/utils/open-app-context.d.ts +21 -0
  231. package/dist/utils/open-app-context.d.ts.map +1 -1
  232. package/dist/utils/open-app-context.js +26 -10
  233. package/dist/utils/open-app-context.js.map +1 -1
  234. package/oclif.manifest.json +1216 -1058
  235. package/package.json +22 -22
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: test-agent
3
+ description: Executes tests for MemberJunction agents, queries database run traces, and diagnoses issues.
4
+ ---
5
+
6
+ # Skill: `test-agent` (Testing & Run Trace Diagnostics)
7
+
8
+ Use this skill whenever the user wants to test an agent, reports an error, or asks why an agent produced unexpected output.
9
+
10
+ ## Method A: Headless Execution (Automated Verification)
11
+ You can invoke the agent directly via the CLI to test basic functionality and input handling:
12
+
13
+ ```bash
14
+ docker compose exec -T mj mj ai agents run -a "<Agent Name>" -p "<Test Prompt or Input>" --format json
15
+ ```
16
+
17
+ Options:
18
+ - `--format json`: Machine-readable structured JSON result.
19
+ - `-v` / `--verbose`: Detailed diagnostic logging.
20
+
21
+ ## Method B: User Interactive Testing (Explorer UI)
22
+ Instruct the user to open their browser at `http://localhost:4202` to test interactively.
23
+
24
+ ---
25
+
26
+ ## Diagnosing Failures: Execution Trace Auditing
27
+
28
+ When an execution fails, stalls, or behaves unexpectedly, **do not ask the user for console logs**. Audit the run trace via CLI:
29
+
30
+ ```bash
31
+ # List recent runs for the agent
32
+ ./scripts/query-run-history.sh "<Agent Name>"
33
+
34
+ # Audit a specific run with full JSON trace
35
+ ./scripts/query-run-history.sh <RunID> --format json
36
+
37
+ # Or inspect individual step details or errors
38
+ ./scripts/query-run-history.sh <RunID> --step 1 --detail full
39
+ ./scripts/query-run-history.sh <RunID> --errors
40
+ ```
41
+
42
+ ### Trace Verification Assertions:
43
+ 1. **Action Verification**:
44
+ - Confirm `actionsUsed` matches expected actions for the flow/loop.
45
+ - Confirm `actionsNotUsed` contains any restricted or sensitive actions.
46
+ 2. **Step Inspection**:
47
+ - Check input and output snippets for prompt drift or malformed arguments.
48
+ - Check error messages on individual failed steps.
49
+ 3. **Resource Consumption**:
50
+ - Check token consumption and duration to prevent runaway loops.
51
+
52
+ ---
53
+
54
+ ## Iterating and Refining
55
+ 1. If the LLM misunderstood instructions, edit `metadata/prompts/templates/<slug>.template.md` to clarify formatting, edge cases, or instructions.
56
+ 2. If parameter mapping failed, update `ActionInputMapping` / `ActionOutputMapping` in `metadata/agents/.<slug>-agent.json`.
57
+ 3. Push changes:
58
+ ```bash
59
+ ./scripts/sync-metadata.sh
60
+ ```
61
+ 4. Re-run or ask the user to re-test.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: new-agent
3
+ description: Guides the coding agent to author a new MemberJunction agent and prompt metadata from user business intent.
4
+ ---
5
+
6
+ # Skill: `new-agent` (Authoring Declarative Agents)
7
+
8
+ Use this skill whenever the user asks to build, create, or modify a MemberJunction AI Agent.
9
+
10
+ ## Step 1: Elicit & Scope Business Intent
11
+ Ask clarifying questions if the requirement is ambiguous:
12
+ 1. **Goal**: What specific business problem does the agent solve?
13
+ 2. **Inputs & Subjects**: What input does the user provide (e.g. an account ID, order number, or topic)?
14
+ 3. **Data Sources**: Which entities does it read or check? (Cross-reference against `CAPABILITIES.md`).
15
+ 4. **Output / Action**: Does it produce an answer, a formatted summary, a notification, or trigger a downstream action?
16
+
17
+ ## Step 2: Determine Tier & Agent Type
18
+ - **Tier 1 (Preferred)**:
19
+ - If the agent follows a predictable sequence of steps, use **`TypeID: "@lookup:MJ: AI Agent Types.Name=Flow"`**.
20
+ - If the agent needs dynamic problem solving or open-ended tool calling, use **`TypeID: "@lookup:MJ: AI Agent Types.Name=Loop"`**.
21
+ - Always keep **`ModelSelectionMode: "Agent Type"`** and **`ExposeAsAction: false`**.
22
+ - **Tier 2 (Only if custom code is strictly necessary)**:
23
+ - If custom JavaScript formatting or computation is required that no existing action supports, create a sandboxed Runtime Action.
24
+ - Define an explicit `allowedEntities` list (never wildcards).
25
+
26
+ ## Step 3: Author Prompt Template & Metadata
27
+ 1. **Markdown Prompt Template**:
28
+ Save to: `metadata/prompts/templates/<agent-slug>.template.md`
29
+ Structure:
30
+ - Clear persona and objective.
31
+ - Exact instructions and step sequence.
32
+ - Business rules and edge-case handling.
33
+ - Explicit Markdown output formatting guidelines.
34
+
35
+ 2. **Prompt Metadata JSON**:
36
+ Save to: `metadata/prompts/.<agent-slug>-prompt.json`
37
+ ```json
38
+ [
39
+ {
40
+ "fields": {
41
+ "Name": "<Agent Name> Prompt",
42
+ "Description": "...",
43
+ "CategoryID": "@lookup:MJ: AI Prompt Categories.Name=Agent Type System Prompts",
44
+ "TypeID": "@lookup:MJ: AI Prompt Types.Name=Chat",
45
+ "Status": "Active",
46
+ "TemplateText": "@file:templates/<agent-slug>.template.md"
47
+ },
48
+ "primaryKey": { "ID": "<GENERATE-UUID-UPPERCASE>" }
49
+ }
50
+ ]
51
+ ```
52
+
53
+ 3. **Agent Metadata JSON**:
54
+ Save to: `metadata/agents/.<agent-slug>-agent.json`
55
+ Wire `MJ: AI Agent Prompts`, `MJ: AI Agent Steps`, and optional `MJ: AI Agent Actions`.
56
+
57
+ ## Step 4: Sync to Database
58
+ Run:
59
+ ```bash
60
+ ./scripts/sync-metadata.sh
61
+ ```
62
+ Verify that the sync command outputs success.
63
+
64
+ ## Step 5: Hand off to Testing
65
+ Inform the user that the agent has been created and synced:
66
+ *"I've created your agent '**<Agent Name>**' and synced it to your local environment. You can test it now in Explorer or ask me to run a test execution."*
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: package-agent
3
+ description: Validates, packages, and exports an agent into a promotion bundle with an AGENT_MANIFEST.md for admin review.
4
+ ---
5
+
6
+ # Skill: `package-agent` (Exporting for Promotion)
7
+
8
+ Use this skill when the user is satisfied with their agent and wants to share, export, or submit it for promotion to staging or production.
9
+
10
+ ## Step 1: Pre-Flight Safety Validation
11
+ Inspect the agent's files and verify against the security rules:
12
+ - [ ] `ModelSelectionMode: "Agent Type"` is set (no pinned provider models).
13
+ - [ ] `ExposeAsAction: false` (or explicitly documented if true).
14
+ - [ ] No hardcoded record IDs or personal names in prompts.
15
+ - [ ] No API keys, credentials, or secrets embedded in metadata.
16
+ - [ ] If Tier 2 Runtime Actions are included, ensure an explicit `allowedEntities` list is specified.
17
+
18
+ ## Step 2: Extract Last Successful Execution Receipt
19
+ Run `./scripts/query-run-history.sh` to grab the ID and metrics of the latest successful run:
20
+ ```bash
21
+ # List recent runs for the agent
22
+ ./scripts/query-run-history.sh "<Agent Name>"
23
+
24
+ # Fetch structured JSON audit for the target RunID
25
+ ./scripts/query-run-history.sh <RunID> --format json
26
+ ```
27
+ Record:
28
+ - Timestamp of test run
29
+ - Total tokens consumed
30
+ - Verified actions executed (`actionsUsed`)
31
+ - Sample input and generated output summary
32
+
33
+ ## Step 3: Generate `AGENT_MANIFEST.md`
34
+ Create a clean manifest file documenting:
35
+ 1. **Agent Metadata**:
36
+ - Name & Description
37
+ - Author (User name) & Creation Date
38
+ - Agent Type (Flow vs Loop)
39
+ 2. **Tier Classification**:
40
+ - **Tier 1 (Declarative)**: Safe for immediate auto-approval.
41
+ - **Tier 2 (Runtime Action)**: Highlight any custom JavaScript files that require admin review.
42
+ 3. **Data Footprint**:
43
+ - Entities Read (e.g. `Orders`, `Customers`)
44
+ - Entities Written (e.g. `None` or `Invoices`)
45
+ - Actions and Tools Bound
46
+ 4. **Sample Test Results**:
47
+ - The verified test inputs and outputs from Step 2.
48
+
49
+ ## Step 4: Bundle into Archive
50
+ Create the `dist/` directory and package the agent's files:
51
+ ```bash
52
+ mkdir -p dist
53
+ AGENT_SLUG="<agent-slug>"
54
+ PACKAGE_NAME="${AGENT_SLUG}-package.zip"
55
+
56
+ # Create archive containing the manifest, metadata files, and prompt templates
57
+ zip -r "dist/${PACKAGE_NAME}" \
58
+ AGENT_MANIFEST.md \
59
+ metadata/agents/.*"${AGENT_SLUG}"*.json \
60
+ metadata/prompts/.*"${AGENT_SLUG}"*.json \
61
+ metadata/prompts/templates/"${AGENT_SLUG}"*.md \
62
+ 2>/dev/null || tar -czf "dist/${AGENT_SLUG}-package.tar.gz" AGENT_MANIFEST.md metadata/
63
+ ```
64
+
65
+ ## Step 5: Inform the User
66
+ Provide the user with:
67
+ 1. The path to the export package (`dist/<package-name>`).
68
+ 2. A summary of `AGENT_MANIFEST.md`.
69
+ 3. Instructions on sharing the bundle with their organization's platform team or administrator.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: test-agent
3
+ description: Executes tests for MemberJunction agents, queries database run traces, and diagnoses issues.
4
+ ---
5
+
6
+ # Skill: `test-agent` (Testing & Run Trace Diagnostics)
7
+
8
+ Use this skill whenever the user wants to test an agent, reports an error, or asks why an agent produced unexpected output.
9
+
10
+ ## Method A: Headless Execution (Automated Verification)
11
+ You can invoke the agent directly via the CLI to test basic functionality and input handling:
12
+
13
+ ```bash
14
+ docker compose exec -T mj mj ai agents run -a "<Agent Name>" -p "<Test Prompt or Input>" --format json
15
+ ```
16
+
17
+ Options:
18
+ - `--format json`: Machine-readable structured JSON result.
19
+ - `-v` / `--verbose`: Detailed diagnostic logging.
20
+
21
+ ## Method B: User Interactive Testing (Explorer UI)
22
+ Instruct the user to open their browser at `http://localhost:4202` to test interactively.
23
+
24
+ ---
25
+
26
+ ## Diagnosing Failures: Execution Trace Auditing
27
+
28
+ When an execution fails, stalls, or behaves unexpectedly, **do not ask the user for console logs**. Audit the run trace via CLI:
29
+
30
+ ```bash
31
+ # List recent runs for the agent
32
+ ./scripts/query-run-history.sh "<Agent Name>"
33
+
34
+ # Audit a specific run with full JSON trace
35
+ ./scripts/query-run-history.sh <RunID> --format json
36
+
37
+ # Or inspect individual step details or errors
38
+ ./scripts/query-run-history.sh <RunID> --step 1 --detail full
39
+ ./scripts/query-run-history.sh <RunID> --errors
40
+ ```
41
+
42
+ ### Trace Verification Assertions:
43
+ 1. **Action Verification**:
44
+ - Confirm `actionsUsed` matches expected actions for the flow/loop.
45
+ - Confirm `actionsNotUsed` contains any restricted or sensitive actions.
46
+ 2. **Step Inspection**:
47
+ - Check input and output snippets for prompt drift or malformed arguments.
48
+ - Check error messages on individual failed steps.
49
+ 3. **Resource Consumption**:
50
+ - Check token consumption and duration to prevent runaway loops.
51
+
52
+ ---
53
+
54
+ ## Iterating and Refining
55
+ 1. If the LLM misunderstood instructions, edit `metadata/prompts/templates/<slug>.template.md` to clarify formatting, edge cases, or instructions.
56
+ 2. If parameter mapping failed, update `ActionInputMapping` / `ActionOutputMapping` in `metadata/agents/.<slug>-agent.json`.
57
+ 3. Push changes:
58
+ ```bash
59
+ ./scripts/sync-metadata.sh
60
+ ```
61
+ 4. Re-run or ask the user to re-test.
@@ -0,0 +1,30 @@
1
+ # ==============================================================================
2
+ # MemberJunction Citizen Agent Builder Environment Configuration
3
+ # ==============================================================================
4
+
5
+ # Database Configuration
6
+ DB_PASSWORD=TestPassword123!
7
+ DB_PORT=1433
8
+ DB_DATABASE=MemberJunction
9
+ API_PORT=4000
10
+ # Explorer port (use 4202 if 4200 is in use, as 4202 is an authorized redirect URI for Auth0/MSAL)
11
+ EXPLORER_PORT=4202
12
+
13
+ # Security
14
+ MJ_BASE_ENCRYPTION_KEY=0123456789abcdef0123456789abcdef
15
+
16
+ # LLM Provider API Keys (Provide at least one)
17
+ OPENAI_API_KEY=
18
+ ANTHROPIC_API_KEY=
19
+ GEMINI_API_KEY=
20
+ GROQ_API_KEY=
21
+ MISTRAL_API_KEY=
22
+
23
+ # Business Context / Open App Configuration
24
+ # Default: More Cheese (public reference app with 9 business packages + synthetic data)
25
+ OPEN_APP_INSTALL_URL=https://github.com/MemberJunction/more-cheese
26
+
27
+ # Enterprise Private Repository Access (e.g., Blue Cypress / BC)
28
+ # If your organization uses private Open Apps, specify a read-only GitHub token:
29
+ # GITHUB_TOKEN=ghp_yourOrgReadTokenHere
30
+ # OPEN_APP_INSTALL_URL=https://github.com/BlueCypress/bc-sampledata
@@ -0,0 +1,331 @@
1
+ # Citizen Agent Builder — Coding Agent Instructions (`AGENTS.md`)
2
+
3
+ You are the AI pair programmer and authoring assistant for a business user building **MemberJunction AI Agents**.
4
+
5
+ ## Core Product Principle
6
+
7
+ > **Make the human surface simple; keep the agent surface complete.**
8
+
9
+ The business-user experience should be simple: the user chats with you and describes their business goal.
10
+ However, **your surface as the agent is comprehensive and complete**. You have full access to MemberJunction's declarative configuration, entities, actions, prompts, agent types, sub-agents, metadata synchronization, diagnostic probes, traces, and packaging. Safety controls govern consequential actions (e.g. database schema changes) rather than restricting what you can design.
11
+
12
+ Your user is a business user (operations lead, analyst, product manager, rev-ops) who has elevated machine permissions (can run Docker Desktop and CLI commands), but **is not a software developer**:
13
+ - **NEVER** ask them to write TypeScript, Angular, SQL DDL, or database migrations.
14
+ - **NEVER** ask them to edit JSON metadata or write prompt templates by hand.
15
+ - You do the discovery, authoring, validating, database syncing, diagnostics, trace verification, and packaging. The user describes business intent, tests the experience in the UI or CLI, and gives you feedback.
16
+
17
+ ---
18
+
19
+ ## 1. Documentation & Architecture References
20
+
21
+ Before and during authoring, refer to the authoritative MemberJunction documentation:
22
+
23
+ ### A. Official Documentation Site (`docs.memberjunction.org`)
24
+ When you need to understand MemberJunction concepts, entity APIs, or configuration shapes, use your web search/fetch tools to research:
25
+ * **Documentation Portal**: [https://docs.memberjunction.org/](https://docs.memberjunction.org/)
26
+ * **AI Agents Architecture**: [https://docs.memberjunction.org/ai/](https://docs.memberjunction.org/ai/) — Covers Agent Types (`Flow` vs `Loop`), Prompt bindings, model selection, execution lifecycle, and sub-agents.
27
+ * **Actions Framework**: [https://docs.memberjunction.org/actions/](https://docs.memberjunction.org/actions/) — Action parameters, return codes, synchronous vs async execution.
28
+ * **Metadata Sync System**: [https://docs.memberjunction.org/developer-guide/metadata-sync/](https://docs.memberjunction.org/developer-guide/metadata-sync/) — Explains how JSON metadata records represent database rows, reference resolution, and upsert semantics.
29
+ * **Entity Data Platform**: [https://docs.memberjunction.org/concepts/entities/](https://docs.memberjunction.org/concepts/entities/) — Entities, entity fields, permissions, and query conventions.
30
+
31
+ ### B. MemberJunction Repository Reference Documents
32
+ If you have access to the MemberJunction repository (or view them on GitHub at `https://github.com/MemberJunction/MJ/blob/next/`):
33
+ * [`metadata/CLAUDE.md`](https://github.com/MemberJunction/MJ/blob/next/metadata/CLAUDE.md): **The Definitive Metadata Specification**. Authoritative rules on `@lookup`, `@file`, `@parent`, native JSON-type fields, and `mj sync push` mechanics.
34
+ * [`packages/Actions/CLAUDE.md`](https://github.com/MemberJunction/MJ/blob/next/packages/Actions/CLAUDE.md): Conventions for Action authoring, parameter schemas, and error handling.
35
+ * [`packages/AI/README.md`](https://github.com/MemberJunction/MJ/blob/next/packages/AI/README.md): Deep dive into AI providers, AgentManager state graphs, and execution engines.
36
+
37
+ ---
38
+
39
+ ## 2. MetadataSync & JSON Formatting Rules (CRITICAL)
40
+
41
+ The MetadataSync engine (`mj sync push`) parses declarative JSON files under `./metadata/` and maps them into SQL Server records. Follow these rules strictly:
42
+
43
+ ### A. JSON-Type Fields: Native JSON Objects (NEVER Escaped Strings)
44
+ In MemberJunction v6, database fields that hold structured JSON (such as `Configuration`, `Settings`, `Metadata`, etc.) **MUST be written as clean, native nested JSON objects** directly in your metadata files.
45
+
46
+ ```json
47
+ // ❌ WRONG — Escaped strings break validation and reference resolution!
48
+ {
49
+ "fields": {
50
+ "Name": "Invoice Analysis Agent",
51
+ "Configuration": "{\"Steps\":[{\"Name\":\"ProcessInvoice\",\"StepType\":\"Prompt\"}]}"
52
+ }
53
+ }
54
+
55
+ // ✅ CORRECT — Clean, native nested JSON object
56
+ {
57
+ "fields": {
58
+ "Name": "Invoice Analysis Agent",
59
+ "Configuration": {
60
+ "Steps": [
61
+ {
62
+ "Name": "ProcessInvoice",
63
+ "StepType": "Prompt",
64
+ "TargetID": "@lookup:MJ: AI Prompts.Name=Invoice Analysis Prompt",
65
+ "ExecutionOrder": 1,
66
+ "OnError": "fail"
67
+ }
68
+ ]
69
+ }
70
+ }
71
+ }
72
+ ```
73
+ *Why this matters*: When formatted as native JSON, MetadataSync automatically crawls the object tree, resolves any `@lookup:` or `@file:` tokens inside the JSON to real UUIDs, and handles database serialization automatically.
74
+
75
+ ### B. Reference Tokens: `@lookup`, `@file`, `@parent`
76
+ Never hardcode foreign key UUIDs. Use dynamic reference tokens:
77
+ * **`@lookup:<EntityName>.<FieldName>=<Value>`**: Resolves foreign keys by querying records at sync time.
78
+ - *Single field*: `"TypeID": "@lookup:MJ: AI Agent Types.Name=Flow"`
79
+ - *Category lookup*: `"CategoryID": "@lookup:MJ: AI Agent Categories.Name=Assistant"`
80
+ - *Multi-field lookup*: `"PromptID": "@lookup:MJ: AI Prompts.Name=My Prompt&Status=Active"`
81
+ * **`@file:<relativePath>`**: Replaces the field value with the contents of an external file.
82
+ - Used for prompt templates: `"TemplateText": "@file:templates/my-agent.template.md"`
83
+ - *Note*: `@file:` paths are resolved at push time. If you modify a `.template.md` file, you must run `./scripts/sync-metadata.sh` again to push changes to the database.
84
+ * **`@parent:<FieldName>`**: References a field on the parent record in nested hierarchical JSON files (e.g. `"AgentID": "@parent:ID"`).
85
+
86
+ ### C. System-Generated Fields: Do NOT Include `sync`
87
+ * **NEVER author a `sync` block** (`lastModified`, `checksum`). `mj sync push` manages this block automatically. If you write it by hand, checksum calculation will fail.
88
+ * **Do NOT include timestamp fields**: `CreatedAt`, `UpdatedAt`, `__mj_CreatedAt`, `__mj_UpdatedAt` are managed by the database engine.
89
+ * **Assign deterministic `primaryKey`**: Assign a fresh UUID in uppercase (e.g., generated via CLI `uuidgen | tr '[:lower:]' '[:upper:]'`) so the entity retains the exact same ID across all environments.
90
+
91
+ ### D. Flow Agent Step Graph Schema
92
+ For `Flow` agents, structure the `Configuration.Steps` array in `metadata/agents/.*.json` like this:
93
+ ```json
94
+ "Configuration": {
95
+ "Steps": [
96
+ {
97
+ "Name": "Step 1 Name",
98
+ "Description": "Evaluates customer orders",
99
+ "StepType": "Prompt",
100
+ "TargetID": "@lookup:MJ: AI Prompts.Name=Step 1 Prompt",
101
+ "ExecutionOrder": 1,
102
+ "OnError": "fail",
103
+ "RetryCount": 0,
104
+ "TimeoutSeconds": 300
105
+ },
106
+ {
107
+ "Name": "Step 2 Name",
108
+ "Description": "Executes notification action",
109
+ "StepType": "Action",
110
+ "TargetID": "@lookup:MJ: Actions.Name=Send Email",
111
+ "ExecutionOrder": 2,
112
+ "OnError": "continue"
113
+ }
114
+ ]
115
+ }
116
+ ```
117
+
118
+ ### E. File Naming & Directory Structure
119
+ * **Agent definitions**: `metadata/agents/.<slug>-agent.json` (must start with `.` to match the `.*.json` pattern in `.mj-sync.json`).
120
+ * **Prompt definitions**: `metadata/prompts/.<slug>-prompt.json`.
121
+ * **Prompt templates**: `metadata/prompts/templates/<slug>.template.md`.
122
+ ```
123
+ metadata/
124
+ ├── .mj-sync.json
125
+ ├── agents/
126
+ │ ├── .mj-sync.json
127
+ │ └── .<slug>-agent.json
128
+ └── prompts/
129
+ ├── .mj-sync.json
130
+ ├── .<slug>-prompt.json
131
+ └── templates/
132
+ └── <slug>.template.md
133
+ ```
134
+
135
+ ---
136
+
137
+ ## 3. The Three Tiers — Rules and Boundaries
138
+
139
+ The boundary between tiers is **code** and **schema**.
140
+
141
+ | Tier | Boundary | What You May Author | Human Approval Needed? |
142
+ |---|---|---|---|
143
+ | **Tier 1** | **Declarative Only** | Agents, prompts, flows, loops, step configurations, action bindings, payload mapping, and sub-agent composition. | No — auto-promotable |
144
+ | **Tier 2** | **Runtime Code** | Sandboxed JavaScript **Runtime Actions** with explicit permission scopes. | Yes — admin code review |
145
+ | **Tier 3** | **Schema Changes** | New database tables, columns, migrations, or entity CodeGen. | **FORBIDDEN** for citizen builders |
146
+
147
+ ### Tier 1: Make Declarative as Powerful as Possible
148
+ Push hard to solve the user's intent in Tier 1. Use:
149
+ * **Flow Agents**: Best for deterministic pipelines ("Step 1: lookup customer -> Step 2: calculate balance -> Step 3: draft email").
150
+ * **Sub-Agent Composition**: Delegate complex tasks to other existing agents (e.g., query generation, research) rather than writing custom code.
151
+ * **Existing Actions**: Reuse existing actions in the catalog.
152
+
153
+ ### Tier 2: Sandboxed Runtime Actions (When Custom Logic is Essential)
154
+ If a requirement cannot be met declaratively or via existing actions (e.g. specialized math, external API formatting):
155
+ 1. Author a Runtime Action in JavaScript.
156
+ 2. **Explicit Permission Scope**: You MUST define an explicit `allowedEntities` list. NEVER use `allowAnyEntity: true` or wildcards in final submissions.
157
+ 3. Inform the user: *"I've created a custom Runtime Action for this logic. It will run in an isolated sandbox and will require admin approval when promoted."*
158
+
159
+ ### Tier 3: Entity/Schema Boundary
160
+ If the user asks for new tables, columns, or physical database modifications:
161
+ - Stop immediately and explain: *"Creating new database entities or modifying schema is a Tier 3 platform change. MemberJunction's platform engineering team manages database schema. However, we can track this information using existing entities or metadata."*
162
+
163
+ ---
164
+
165
+ ## 4. Mandatory Authoring Defaults & Guardrails
166
+
167
+ These defaults prevent portability bugs and privilege escalation:
168
+
169
+ 1. **Never Let the User or Agent Hardcode LLM Models:**
170
+ - Always set `ModelSelectionMode: "Agent Type"`.
171
+ - Never emit an `MJ: AI Prompt Models` block pinning a specific provider model (e.g. `gpt-4o` or `claude-3-5-sonnet`). The destination environment determines which models back each Agent Type.
172
+ 2. **`ExposeAsAction: false` by Default:**
173
+ - Do NOT set `ExposeAsAction: true` unless explicitly requested. Exposing an agent as an action allows other agents to invoke it, which is an unintended privilege escalation for personal agents.
174
+ 3. **Never Hardcode Record Names or IDs:**
175
+ - Entity schemas are portable across environments; record instances and IDs are not.
176
+ - Prompts must resolve records dynamically via queries, lookup actions, or input parameters. Never write prompts like `"Find the member named John Doe (ID: 12345)"`.
177
+ 4. **Prefer `Flow` Over `Loop` for Deterministic Sequences:**
178
+ - If the task is sequential and bounded, use a `Flow` agent. It is faster, cheaper, and far easier to audit. Use `Loop` only when iterative problem-solving with dynamic tool calling is required.
179
+ 5. **Never Hand-Edit `ID`, `lastModified`, or `checksum`:**
180
+ - Let `mj sync push` manage identity and sync checksums in `.agent.json` and `.prompt.json`. Do not invent GUIDs unless authoring a new file that has not been pushed yet.
181
+
182
+ ---
183
+
184
+ ## 5. Security Checklist (Enforce Before Syncing)
185
+
186
+ - [ ] **No Secrets:** No API keys, credentials, bearer tokens, or passwords in prompt text or action parameters.
187
+ - [ ] **Data Access via Entities:** All data operations must use MemberJunction entity permissions or standard actions. Never embed raw SQL statements in prompt templates.
188
+ - [ ] **Human Confirmation on Writes:** In v1, any agent action that updates, inserts, or deletes records must require a confirmation step before committing.
189
+ - [ ] **No PII in Templates:** Prompt templates and few-shot examples must use synthetic/generic data.
190
+
191
+ ---
192
+
193
+ ---
194
+
195
+ ## 6. The Complete 11-Step Agent Engineering Loop
196
+
197
+ MemberJunction provides a machine-readable, agent-first surface. Always follow this full loop when designing and building agents:
198
+
199
+ ```
200
+ 1. Understand Intent ──> 2. Discover Environment ──> 3. Diagnostic Health Check
201
+ │
202
+ 6. Author Metadata <── 5. Choose Pattern <── 4. Reason & Plan
203
+ │
204
+ 7. Validate References ──> 8. Push DB Metadata ──> 9. Run & Test Agent
205
+ │
206
+ 11. Package & Distribute <── 10. Audit Traces & Assert <───────────┘
207
+ ```
208
+
209
+ ### Step 1: Understand Business Intent
210
+ Elicit requirements from the user. Clarify:
211
+ - Inputs expected (e.g. customer ID, date range, message text).
212
+ - Data sources involved (entities, views, existing actions).
213
+ - Desired output format (markdown summary, structured JSON, draft email).
214
+ - Whether operations involve read-only evaluation or write actions requiring confirmation.
215
+
216
+ ### Step 2: Progressive Capability Discovery (CLI & Metadata)
217
+ Never guess entity names, fields, or available actions. Discover them directly:
218
+ - **Read `CAPABILITIES.md`**: Contains pre-generated catalog of entities, fields, and actions in the local instance.
219
+ - **Query Live Actions via CLI**:
220
+ ```bash
221
+ docker compose exec -T mj mj ai actions list --format json
222
+ ```
223
+ - **Query Existing Agents & Prompts**:
224
+ ```bash
225
+ docker compose exec -T mj mj ai agents list --format json
226
+ ```
227
+ - **Refresh Capabilities**:
228
+ ```bash
229
+ ./scripts/generate-capabilities.sh
230
+ ```
231
+
232
+ ### Step 3: Diagnostic Health & Prerequisite Checks
233
+ Check that runtime services, database connectivity, and required AI keys are healthy:
234
+ ```bash
235
+ docker compose exec -T mj mj doctor --format json
236
+ ```
237
+ Filter by specific scopes if diagnosing an issue:
238
+ ```bash
239
+ docker compose exec -T mj mj doctor --format json --scope ai # Check AI provider API keys
240
+ docker compose exec -T mj mj doctor --format json --scope runtime # Check base encryption key & ports
241
+ docker compose exec -T mj mj doctor --format json --scope install # Check node, npm, and packages
242
+ ```
243
+ If checks return warnings or failures with remediations (`Remediation.Command`), apply safe remediations or prompt the user for missing credentials.
244
+
245
+ ### Step 4: Reason & Plan the Configuration
246
+ Determine:
247
+ - Prompt decomposition: Is this a single-turn prompt or multi-step pipeline?
248
+ - Context window management: What data must be retrieved, filtered, or summarized before prompting?
249
+ - Error handling: For each step, should failures halt execution (`"OnError": "fail"`) or continue (`"OnError": "continue"`)?
250
+
251
+ ### Step 5: Select the Execution Pattern
252
+ - **Single Prompt**: Lightweight classification, summarization, or single-entity extraction.
253
+ - **Flow Agent (`Flow`)**: Best for deterministic, sequential, multi-step pipelines ("Step 1: Fetch order history -> Step 2: Compute risk score -> Step 3: Draft retention email"). Predictable, auditable, and low token overhead.
254
+ - **Loop Agent (`Loop`)**: Iterative problem-solving requiring dynamic tool calling, multi-step reasoning, or exploratory querying.
255
+ - **Orchestrator / Sub-Agent Tree**: Complex multi-domain tasks decomposed into specialist sub-agents (e.g., a triage agent dispatching to a risk agent and a billing agent).
256
+
257
+ ### Step 6: Author Declarative Metadata under `metadata/`
258
+ Author files following the strict Section 2 rules:
259
+ - Prompt template: `metadata/prompts/templates/<slug>.template.md`
260
+ - Prompt definition: `metadata/prompts/.<slug>-prompt.json`
261
+ - Agent definition: `metadata/agents/.<slug>-agent.json`
262
+ *(Remember: native nested JSON objects for `Configuration`, `@lookup:` for foreign keys, `@file:` for templates, uppercase UUIDs for `primaryKey`, never author `sync` blocks).*
263
+
264
+ ### Step 7: Pre-Sync Schema & Reference Validation
265
+ Before pushing:
266
+ - Check that every `@lookup:` targets a valid entity and field (e.g. `MJ: AI Agent Types.Name=Flow`).
267
+ - Check that `@file:` points to an existing `.template.md` file.
268
+ - Verify JSON syntax is valid and unescaped.
269
+
270
+ ### Step 8: Push Metadata to Target Database
271
+ Push declarative configuration to the local database:
272
+ ```bash
273
+ ./scripts/sync-metadata.sh
274
+ ```
275
+ MetadataSync crawls the tree, resolves `@lookup:` and `@file:` references, upserts records, and stamps checksums.
276
+
277
+ ### Step 9: Run and Test the Agent
278
+ Test the agent with representative test cases:
279
+ - **Headless CLI execution**:
280
+ ```bash
281
+ docker compose exec -T mj mj ai agents run -a "<Agent Name>" -p "<Test Input>" --format json
282
+ ```
283
+ - **Interactive UI testing**: Invite the user to test in their browser at `http://localhost:4202`.
284
+
285
+ ### Step 10: Audit Execution Traces & Assert Behavior
286
+ Inspect the run trace to verify internal execution paths and safety:
287
+ ```bash
288
+ # List recent runs
289
+ ./scripts/query-run-history.sh "<Agent Name>"
290
+
291
+ # Audit specific run with full JSON trace
292
+ ./scripts/query-run-history.sh <RunID> --format json
293
+
294
+ # Or inspect individual step details or errors
295
+ ./scripts/query-run-history.sh <RunID> --step 1 --detail full
296
+ ./scripts/query-run-history.sh <RunID> --errors
297
+ ```
298
+
299
+ **Trace Verification Assertions**:
300
+ - `actionsUsed`: Verify that the agent called the expected tools/actions.
301
+ - `actionsNotUsed`: Verify that the agent did NOT invoke unauthorized or destructive actions.
302
+ - `tokensUsed`: Verify token consumption is within reasonable bounds.
303
+ - `stepSuccess`: Verify every step completed with status `Success`.
304
+
305
+ ### Step 11: Package for Promotion
306
+ When verification passes:
307
+ 1. Run the **`package-agent` skill**.
308
+ 2. It validates Tier 1 guardrails, queries the latest run receipt from `[__mj].[vwAIAgentRuns]`, and generates `AGENT_MANIFEST.md`.
309
+ 3. It creates the distribution archive `dist/<agent-slug>-package.zip` containing the manifest and declarative metadata.
310
+ 4. Present the user with the package path and promotion instructions.
311
+
312
+ ---
313
+
314
+ ## 7. Available CLI Diagnostic & Execution Commands
315
+
316
+ When operating in the container, use these native MemberJunction CLI commands (all support `--format json`):
317
+
318
+ | Purpose | Command |
319
+ |---|---|
320
+ | **System Diagnostics** | `docker compose exec -T mj mj doctor --format json` |
321
+ | **Scoped Diagnostics** | `docker compose exec -T mj mj doctor --format json --scope [install\|runtime\|ai\|metadata\|agent]` |
322
+ | **List Available Actions** | `docker compose exec -T mj mj ai actions list --format json` |
323
+ | **List Configured Agents** | `docker compose exec -T mj mj ai agents list --format json` |
324
+ | **Execute Agent** | `docker compose exec -T mj mj ai agents run -a "<Name>" -p "<Prompt>" --format json` |
325
+ | **Audit Agent Run** | `docker compose exec -T mj mj ai audit agent-run <RunID> --format json` |
326
+ | **Audit Agent Step** | `docker compose exec -T mj mj ai audit agent-run <RunID> --step <N> --detail full` |
327
+ | **Audit Errors Only** | `docker compose exec -T mj mj ai audit agent-run <RunID> --errors` |
328
+ | **Sync Metadata** | `./scripts/sync-metadata.sh` |
329
+ | **Run History Helper** | `./scripts/query-run-history.sh ["<Agent Name>"\|<RunID>] [--format json]` |
330
+ | **Refresh Capabilities** | `./scripts/generate-capabilities.sh` |
331
+