@memberjunction/cli 6.1.2 → 6.2.0-edge.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +18 -7
  2. package/dist/commands/agent/init.d.ts +23 -0
  3. package/dist/commands/agent/init.d.ts.map +1 -0
  4. package/dist/commands/agent/init.js +222 -0
  5. package/dist/commands/agent/init.js.map +1 -0
  6. package/dist/commands/doctor/index.d.ts +6 -4
  7. package/dist/commands/doctor/index.d.ts.map +1 -1
  8. package/dist/commands/doctor/index.js +43 -18
  9. package/dist/commands/doctor/index.js.map +1 -1
  10. package/dist/commands/test/scripts.d.ts +13 -0
  11. package/dist/commands/test/scripts.d.ts.map +1 -0
  12. package/dist/commands/test/scripts.js +50 -0
  13. package/dist/commands/test/scripts.js.map +1 -0
  14. package/dist/init-templates/citizen-builder/.agents/skills/new-agent/SKILL.md +66 -0
  15. package/dist/init-templates/citizen-builder/.agents/skills/package-agent/SKILL.md +69 -0
  16. package/dist/init-templates/citizen-builder/.agents/skills/test-agent/SKILL.md +61 -0
  17. package/dist/init-templates/citizen-builder/.claude/skills/new-agent/SKILL.md +66 -0
  18. package/dist/init-templates/citizen-builder/.claude/skills/package-agent/SKILL.md +69 -0
  19. package/dist/init-templates/citizen-builder/.claude/skills/test-agent/SKILL.md +61 -0
  20. package/dist/init-templates/citizen-builder/.env.example +30 -0
  21. package/dist/init-templates/citizen-builder/AGENTS.md +331 -0
  22. package/dist/init-templates/citizen-builder/README.md +259 -0
  23. package/dist/init-templates/citizen-builder/docker/Dockerfile +16 -0
  24. package/dist/init-templates/citizen-builder/docker-compose.yml +59 -0
  25. package/dist/init-templates/citizen-builder/docs/ENTERPRISE_ORG_SETUP.md +73 -0
  26. package/dist/init-templates/citizen-builder/docs/PROMOTION_GUIDE.md +70 -0
  27. package/dist/init-templates/citizen-builder/metadata/.mj-sync.json +7 -0
  28. package/dist/init-templates/citizen-builder/metadata/agents/.customer-insight-agent.json +55 -0
  29. package/dist/init-templates/citizen-builder/metadata/agents/.mj-sync.json +45 -0
  30. package/dist/init-templates/citizen-builder/metadata/prompts/.customer-insight-prompt.json +15 -0
  31. package/dist/init-templates/citizen-builder/metadata/prompts/.mj-sync.json +45 -0
  32. package/dist/init-templates/citizen-builder/metadata/prompts/templates/customer-insight.template.md +18 -0
  33. package/dist/init-templates/citizen-builder/scripts/bootstrap.sh +47 -0
  34. package/dist/init-templates/citizen-builder/scripts/docker-entrypoint.sh +184 -0
  35. package/dist/init-templates/citizen-builder/scripts/generate-capabilities.sh +74 -0
  36. package/dist/init-templates/citizen-builder/scripts/query-run-history.sh +34 -0
  37. package/dist/init-templates/citizen-builder/scripts/sync-metadata.sh +14 -0
  38. package/dist/init-templates/remote-mj/README.md +4 -4
  39. package/oclif.manifest.json +271 -98
  40. package/package.json +22 -22
@@ -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,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