Skip to content

feat(cli): split 'automations prompt' into 'prompt get' and 'prompt set'#3959

Merged
saddlepaddle merged 5 commits into
mainfrom
alkaline-efraasia
May 1, 2026
Merged

feat(cli): split 'automations prompt' into 'prompt get' and 'prompt set'#3959
saddlepaddle merged 5 commits into
mainfrom
alkaline-efraasia

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 1, 2026

Summary

The mixed read/write automations prompt <id> command was a footgun. Without --from-file it tried to read a new prompt from stdin and bailed on EOF, so superset automations prompt <id> > /tmp/x.md produced a 0-byte file with Refusing to write an empty prompt from stdin.. There was no non-interactive read path — the only way to inspect a live prompt was automations list + grep — so verifying that a push landed (get | diff -) was impossible.

Split into explicit subcommands:

  • superset automations prompt get <id> — writes the prompt to stdout. Uses process.stdout.write with no trailing newline so get > file.md and get | diff - file.md round-trip byte-exactly. Falls back to structured { id, prompt } output under --json/--quiet/agent mode.
  • superset automations prompt set <id> --from-file <path> — replaces the prompt. --from-file is required; --from-file - reads from stdin.

automations get continues to omit the prompt field (it can be large markdown); prompt get is the canonical read path. Comment on automations get updated to point at the new path.

No legacy alias — automations prompt <id> now errors with "Unknown command" and suggests get/set. No wire-format / API changes.

Test plan

  • superset automations prompt get <uuid> → exit 0, prompt body on stdout, nothing on stderr
  • superset automations prompt get <uuid> > /tmp/x.md → file contains exactly the live prompt
  • superset automations prompt set <uuid> --from-file /tmp/x.md → succeeds, returns updated metadata
  • superset automations prompt set <uuid> --from-file - (heredoc/pipe) → reads from stdin, succeeds
  • Round-trip: superset automations prompt get <uuid> | diff - /tmp/x.md → empty diff after a set
  • superset automations prompt --help lists get and set

Follow-ups (out of scope)

  • Same get/set split for any other CLI surface that mixes read+write under one verb.
  • superset automations prompt diff <id> <file> for cheap pre-push verification.
  • Inheriting the slug / name resolver from the sibling accept-name-not-just-uuid task once it lands, so prompt get "Sales — Update Notion" works.

Summary by cubic

Split the footgun superset automations prompt <id> into explicit prompt get and prompt set for safe, scriptable reads/writes. Moved prompt omission to the server with SQL projection so automation.list/automation.get return lean metadata; getPrompt is the single read path.

  • Migration

    • Read: superset automations prompt get <id> (prints raw prompt to stdout, no trailing newline).
    • Write: superset automations prompt set <id> --from-file <path> (use --from-file - to read from stdin).
    • Round-trip: superset automations prompt get <id> > file.md then superset automations prompt set <id> --from-file file.md and verify with superset automations prompt get <id> | diff - file.md.
  • Refactors

    • tRPC: SQL-level projection (omit prompt) in automation.list/automation.get is now inlined; getPrompt is the canonical read path.
    • SDK: split types into AutomationSummary (for list/retrieve, no prompt) and Automation (full row for mutations). Updated CLI automations get and MCP tools to the server’s lean shape; outputs stay the same.
    • CLI: prompt get emits structured { id, prompt } only under --json and ignores --quiet to avoid dropping the prompt body.

Written for commit 72be5df. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor

    • Replaced the old single automations prompt CLI command with distinct prompt get and prompt set subcommands.
  • New Features

    • prompt get: prints raw prompt or structured JSON.
    • prompt set: accepts file or stdin, rejects empty input, returns update info.
    • SDK: added an AutomationSummary type (metadata without prompt).
  • Behavior

    • SDK/API automations list / retrieve omit prompt; use prompt get.
    • CLI automations get now returns the full automation object (includes prompt).
  • Documentation

    • Updated CLI and SDK docs for the new prompt workflow.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08f54581-dec8-4b83-8c83-11249f14736d

📥 Commits

Reviewing files that changed from the base of the PR and between ff89de3 and 72be5df.

📒 Files selected for processing (1)
  • packages/trpc/src/router/automation/automation.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/trpc/src/router/automation/automation.ts

📝 Walkthrough

Walkthrough

Prompt handling split into dedicated automations prompt get and automations prompt set CLI subcommands; the previous combined prompt command was removed. Server router list/get now omit prompt (use summary projection); tools/CLI and SDK were updated to expose summary vs full automation shapes and prompt-specific endpoints.

Changes

Cohort / File(s) Summary
CLI: automations get
packages/cli/src/commands/automations/get/command.ts
Now returns the API result verbatim (no longer strips prompt).
CLI: removed monolith
packages/cli/src/commands/automations/prompt/command.ts
Removed the previous combined read/write automations prompt command and its default export.
CLI: prompt subcommands
packages/cli/src/commands/automations/prompt/get/command.ts, packages/cli/src/commands/automations/prompt/set/command.ts
Added prompt get (fetches prompt via API; supports structured JSON or raw stdout) and prompt set (writes prompt from file or stdin, trims/validates, calls setPrompt).
CLI: metadata
packages/cli/src/commands/automations/prompt/meta.ts
Added metadata for automations/prompt (description).
Tools (mcp-v2)
packages/mcp-v2/src/tools/automations/get.ts, packages/mcp-v2/src/tools/automations/list.ts
Tool handlers now return caller API results verbatim (no longer strip prompt); list description updated to reference prompt-specific retrieval.
Server router: omit prompt
packages/trpc/src/router/automation/automation.ts
automationRouter.list and automationRouter.get now project summary columns that exclude prompt; JSDoc updated to point callers to getPrompt.
SDK: models & exports
packages/sdk/src/resources/automations.ts, packages/sdk/src/resources/index.ts, packages/sdk/src/index.ts, packages/sdk/src/client.ts
Introduce AutomationSummary (omits prompt); Automation extends it with prompt. list/retrieve now return summary types and summary is re-exported.
Docs: CLI & SDK references
apps/docs/content/docs/cli/cli-reference.mdx, apps/docs/content/docs/sdk/reference.mdx
CLI docs split automations prompt into prompt get/prompt set and updated examples; SDK docs state list/retrieve return AutomationSummary without prompt and reference getPrompt.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant Tools as MCPv2_Tools
    participant API as Server_API
    participant DB
    CLI->>API: automations prompt get <id>
    API->>DB: SELECT automation summary (or full for prompt endpoint)
    DB-->>API: row (prompt only for getPrompt)
    API-->>CLI: structured { id, prompt } or raw prompt output
    CLI->>API: automations prompt set <id> (file or stdin)
    API->>DB: UPDATE automation.prompt
    DB-->>API: updated full automation row
    API-->>CLI: { id, name, length, message }
    CLI->>Tools: automations/get or automations/list
    Tools->>API: caller.automation.get/list()
    API-->>Tools: returns summary (list/get) or full (getPrompt/setPrompt) depending on endpoint
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I nudged the prompt into its lane,
split get and set to keep things plain.
Get reads bytes, Set writes tight,
Routers whisper summaries light.
A tiny hop, a tidy byte.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: splitting the 'automations prompt' command into separate 'get' and 'set' subcommands.
Description check ✅ Passed The description provides clear motivation, migration paths, implementation details, and a comprehensive test plan covering all major scenarios.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch alkaline-efraasia

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 6/8 reviews remaining, refill in 8 minutes and 17 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 1, 2026

Greptile Summary

This PR replaces the single mixed automations prompt <id> command with explicit prompt get <id> and prompt set <id> --from-file <path> subcommands, fixing the footgun where the old command silently produced a 0-byte file when stdout was redirected. The framework's file-system-based command discovery picks up the new structure automatically via meta.ts (group) + get/command.ts / set/command.ts (leaves).

  • prompt get <id> in --quiet mode returns { id, prompt } to the framework but extractIds then strips the prompt, so only the UUID is printed — the prompt content is silently discarded (see inline comment).
  • The globals.json !== undefined / globals.quiet !== undefined checks work today (boolean flags are true or undefined), but === true would be more robust against future framework changes that initialise flags with a default false.

Confidence Score: 5/5

Safe to merge — all remaining findings are P2 style/robustness suggestions with no impact on the primary use cases.

The refactoring is clean and correct. The --from-file required constraint is properly enforced by the framework parser, the byte-exact round-trip guarantee is sound, and the new group/leaf command structure is auto-discovered correctly. The two P2 comments (quiet-mode drops prompt content; !== undefined vs === true) are minor and do not affect the main get/set paths described in the test plan.

packages/cli/src/commands/automations/prompt/get/command.ts — the wantsStructured detection and --quiet interaction.

Important Files Changed

Filename Overview
packages/cli/src/commands/automations/prompt/get/command.ts New prompt get subcommand — writes raw prompt to stdout by default; falls back to structured { id, prompt } under --json/agent mode; --quiet silently discards the prompt content and returns only the ID.
packages/cli/src/commands/automations/prompt/set/command.ts New prompt set subcommand — --from-file is required (enforced by framework); handles - for stdin; guards against empty prompts; clean separation from the read path.
packages/cli/src/commands/automations/prompt/command.ts Old mixed read/write command deleted; prompt is now a group node backed by the new meta.ts, get/command.ts, and set/command.ts.
packages/cli/src/commands/automations/prompt/meta.ts New group descriptor for automations prompt — provides the description shown in --help for the intermediate node.
packages/cli/src/commands/automations/get/command.ts Comment updated to reference prompt get instead of the old prompt <id> command path; no functional changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["superset automations prompt …"] --> B{subcommand}
    B -->|get &lt;id&gt;| C[fetch getPrompt API]
    B -->|set &lt;id&gt; --from-file &lt;path&gt;| D{source}
    B -->|"(anything else)"| E["CLIError: Unknown command\n(suggests get / set)"]

    C --> F{output mode?}
    F -->|"--json / agent mode"| G["return { data: { id, prompt } }\n→ framework renders JSON"]
    F -->|"--quiet"| H["return { data: { id, prompt } }\n→ extractIds → prints ID only\n⚠ prompt silently dropped"]
    F -->|default| I["process.stdout.write(prompt)\nno trailing newline"]

    D -->|"path"| J["readFileSync(path, utf-8)"]
    D -->|"-"| K["readStdin()"]
    J --> L{empty after trim?}
    K --> L
    L -->|yes| M["throw: Refusing to write an empty prompt"]
    L -->|no| N["setPrompt API → return metadata"]
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/cli/src/commands/automations/prompt/get/command.ts:11-16
**`--quiet` silently drops the prompt**

When `--quiet` is passed, `wantsStructured` becomes `true` and the command returns `{ data: { id, prompt } }`. The framework's `extractIds` then strips everything except the `id` field, so `prompt get <id> --quiet` outputs only the UUID — the prompt content is silently discarded. A user expecting `--quiet` to give them a script-friendly version of the prompt will get nothing useful.

Consider either: (a) not entering the `wantsStructured` branch for `--quiet` so the raw bytes still go to stdout, or (b) adding a `display` function that returns `prompt` directly so the quiet path at least provides the content.

### Issue 2 of 2
packages/cli/src/commands/automations/prompt/get/command.ts:10-13
**`!== undefined` is fragile for boolean flags**

Boolean global flags are `true` when supplied and `undefined` when absent — never `false`. So `globals.json !== undefined` works today, but `globals.json === true` (and the same for `quiet`) more clearly expresses the intent and is immune to any future framework change that initialises globals with a default `false`.

```suggestion
		const wantsStructured =
			globals.json === true ||
			globals.quiet === true ||
			isAgentMode();
```

Reviews (1): Last reviewed commit: "feat(cli): split 'automations prompt' in..." | Re-trigger Greptile

Comment on lines +11 to +16
const wantsStructured =
globals.json !== undefined ||
globals.quiet !== undefined ||
isAgentMode();
if (wantsStructured) {
return { data: { id, prompt } };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 --quiet silently drops the prompt

When --quiet is passed, wantsStructured becomes true and the command returns { data: { id, prompt } }. The framework's extractIds then strips everything except the id field, so prompt get <id> --quiet outputs only the UUID — the prompt content is silently discarded. A user expecting --quiet to give them a script-friendly version of the prompt will get nothing useful.

Consider either: (a) not entering the wantsStructured branch for --quiet so the raw bytes still go to stdout, or (b) adding a display function that returns prompt directly so the quiet path at least provides the content.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/automations/prompt/get/command.ts
Line: 11-16

Comment:
**`--quiet` silently drops the prompt**

When `--quiet` is passed, `wantsStructured` becomes `true` and the command returns `{ data: { id, prompt } }`. The framework's `extractIds` then strips everything except the `id` field, so `prompt get <id> --quiet` outputs only the UUID — the prompt content is silently discarded. A user expecting `--quiet` to give them a script-friendly version of the prompt will get nothing useful.

Consider either: (a) not entering the `wantsStructured` branch for `--quiet` so the raw bytes still go to stdout, or (b) adding a `display` function that returns `prompt` directly so the quiet path at least provides the content.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +10 to +13
const globals = options as Record<string, unknown>;
const wantsStructured =
globals.json !== undefined ||
globals.quiet !== undefined ||
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 !== undefined is fragile for boolean flags

Boolean global flags are true when supplied and undefined when absent — never false. So globals.json !== undefined works today, but globals.json === true (and the same for quiet) more clearly expresses the intent and is immune to any future framework change that initialises globals with a default false.

Suggested change
const globals = options as Record<string, unknown>;
const wantsStructured =
globals.json !== undefined ||
globals.quiet !== undefined ||
const wantsStructured =
globals.json === true ||
globals.quiet === true ||
isAgentMode();
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/automations/prompt/get/command.ts
Line: 10-13

Comment:
**`!== undefined` is fragile for boolean flags**

Boolean global flags are `true` when supplied and `undefined` when absent — never `false`. So `globals.json !== undefined` works today, but `globals.json === true` (and the same for `quiet`) more clearly expresses the intent and is immune to any future framework change that initialises globals with a default `false`.

```suggestion
		const wantsStructured =
			globals.json === true ||
			globals.quiet === true ||
			isAgentMode();
```

How can I resolve this? If you propose a fix, please make it concise.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/commands/automations/prompt/get/command.ts">

<violation number="1" location="packages/cli/src/commands/automations/prompt/get/command.ts:11">
P2: `wantsStructured` treats `--json false`/`--quiet false` as enabled because it checks for option presence, not truthy value. This can force structured/JSON output when raw prompt output was explicitly requested by passing false.</violation>

<violation number="2" location="packages/cli/src/commands/automations/prompt/get/command.ts:13">
P2: Including `--quiet` in the structured-output branch causes the prompt body to be discarded in quiet mode. `prompt get` should still emit prompt content for scripting; otherwise `--quiet` returns only the ID and breaks prompt retrieval.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/cli/src/commands/automations/prompt/get/command.ts Outdated
Comment thread packages/cli/src/commands/automations/prompt/get/command.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/trpc/src/router/automation/automation.ts (1)

166-175: ⚠️ Potential issue | 🟠 Major

db.select() fetches the full prompt column on every list call, then immediately discards it.

Because prompt can be an arbitrarily large Markdown body, this silently transfers that data from the DB → application on every list request only to drop it at the JS layer. Now that the tRPC layer is the authoritative owner of the "no prompt in list/get" contract, push the exclusion down to the query itself.

Drizzle 0.45.2 supports column exclusion via getTableColumns: const { content, ...rest } = getTableColumns(posts); await db.select({ ...rest }).from(posts); — use the same pattern here:

⚡ Proposed fix for `list`
-import { and, desc, eq } from "drizzle-orm";
+import { and, desc, eq, getTableColumns } from "drizzle-orm";
+    const { prompt: _omit, ...automationCols } = getTableColumns(automations);
     const rows = await db
-      .select()
+      .select(automationCols)
       .from(automations)
       .where(eq(automations.organizationId, organizationId))
       .orderBy(desc(automations.createdAt));

-    return rows.map(({ prompt: _prompt, ...row }) => ({
-      ...row,
+    return rows.map((row) => ({
+      ...row,
       scheduleText: safeDescribeRrule(row),
     }));

The get endpoint has the same issue via getAutomationForUser (line 137), but since that helper is also called by runNow (which needs prompt for dispatch), fixing get cleanly requires a separate helper or an overload — treat that as a follow-up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/trpc/src/router/automation/automation.ts` around lines 166 - 175,
The query in list currently selects all columns (including the large prompt) and
then discards prompt in JS; change the DB query to exclude prompt using
Drizzle's getTableColumns pattern so we never fetch it: import/getTableColumns
for the automations table, destructure to remove prompt (e.g., const { prompt,
...rest } = getTableColumns(automations)) and use await db.select({ ...rest
}).from(automations).where(eq(automations.organizationId,
organizationId)).orderBy(desc(automations.createdAt)); keep the downstream
mapping that sets scheduleText via safeDescribeRrule; note
getAutomationForUser/runNow need separate handling later and should not be
changed in this PR.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/trpc/src/router/automation/automation.ts`:
- Around line 166-175: The query in list currently selects all columns
(including the large prompt) and then discards prompt in JS; change the DB query
to exclude prompt using Drizzle's getTableColumns pattern so we never fetch it:
import/getTableColumns for the automations table, destructure to remove prompt
(e.g., const { prompt, ...rest } = getTableColumns(automations)) and use await
db.select({ ...rest }).from(automations).where(eq(automations.organizationId,
organizationId)).orderBy(desc(automations.createdAt)); keep the downstream
mapping that sets scheduleText via safeDescribeRrule; note
getAutomationForUser/runNow need separate handling later and should not be
changed in this PR.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f83ba006-487a-4213-958b-c26f25c81b38

📥 Commits

Reviewing files that changed from the base of the PR and between 60ee5d9 and cd5c657.

📒 Files selected for processing (4)
  • packages/cli/src/commands/automations/get/command.ts
  • packages/mcp-v2/src/tools/automations/get.ts
  • packages/mcp-v2/src/tools/automations/list.ts
  • packages/trpc/src/router/automation/automation.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/commands/automations/get/command.ts

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/trpc/src/router/automation/automation.ts">

<violation number="1" location="packages/trpc/src/router/automation/automation.ts:172">
P2: `list` strips `prompt` after fetching it, so large prompt bodies are still read from the database for every automation.</violation>

<violation number="2" location="packages/trpc/src/router/automation/automation.ts:192">
P2: `get` removes `prompt` only after loading the full row, so metadata reads still fetch the large prompt field.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/trpc/src/router/automation/automation.ts Outdated
Comment thread packages/trpc/src/router/automation/automation.ts Outdated
The mixed read/write `automations prompt <id>` command was a footgun — without
`--from-file` it tried to read from stdin and bailed on EOF, so stdout
redirects produced empty files and there was no scriptable read path. Split
into explicit subcommands:

- `automations prompt get <id>` writes the prompt to stdout (no trailing
  newline added) so `get | diff -` and `get > file.md` round-trip cleanly.
- `automations prompt set <id> --from-file <path>` replaces the prompt;
  `--from-file -` reads from stdin.
Both the CLI and the MCP `automations_get`/`automations_list` tools were
stripping the `prompt` field client-side after fetching the full row. Move
that to the tRPC procedures themselves so every caller gets the lean
metadata shape by default and `getPrompt` is the single canonical read path
for the (potentially large) prompt body.
`automation.list` and `automation.get` now omit the prompt body server-side
(see preceding commit). Mirror that in the SDK so the static types match the
wire shape: `list()` and `retrieve()` return `AutomationSummary` (no
prompt), while mutations that return the full row keep returning
`Automation`. Also point `getPrompt`/`setPrompt` JSDoc at the new CLI
commands (`automations prompt get` / `automations prompt set`).
…ling + docs

- tRPC: project columns at the SQL level for `list` and `get` so the
  prompt body isn't shipped from the database for metadata reads
  (previously SELECT * + JS strip).
- CLI: drop `--quiet` from the `prompt get` structured branch — quiet
  would have routed through `extractIds` and dropped the prompt body,
  leaving the caller with only the UUID they passed in. Also tighten
  `globals.json !== undefined` to `=== true` so `--no-json` doesn't
  accidentally trigger structured output.
- Docs: split the CLI reference into `automations prompt get` /
  `automations prompt set` blocks; note `AutomationSummary` (no prompt)
  in the SDK reference.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/automations/prompt/get/command.ts`:
- Around line 11-14: The wantsStructured boolean is incorrectly computed with
`globals.json !== undefined` and `globals.quiet !== undefined` which are always
true because the framework supplies booleans; update the check in the
wantsStructured calculation to test truthiness of those flags (e.g., use
`globals.json || globals.quiet || isAgentMode()` or explicit equality to true)
so the raw stdout branch in the prompt get command (where the file is written to
stdout) remains reachable; change the expression that sets wantsStructured
(referencing wantsStructured, globals.json, globals.quiet, and isAgentMode())
accordingly.

In `@packages/sdk/src/resources/automations.ts`:
- Around line 26-35: The SDK's retrieve and list methods
(AutomationResource.retrieve and AutomationResource.list) now return responses
that omit the prompt field because the underlying tRPC handlers
("automation.get" / "automation.list") no longer include it; update the release
artifacts: add a changelog entry and semver-major bump (or explicit migration
note) explaining the breaking change and point consumers to
automations.getPrompt(id) for prompt data, and also update the TypeScript
docs/comments for retrieve and list to reflect that prompt is no longer returned
so callers know to call getPrompt instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3e1b9a7-a36a-4d05-a002-f9f51a97d51e

📥 Commits

Reviewing files that changed from the base of the PR and between cd5c657 and 5a95661.

📒 Files selected for processing (12)
  • packages/cli/src/commands/automations/get/command.ts
  • packages/cli/src/commands/automations/prompt/command.ts
  • packages/cli/src/commands/automations/prompt/get/command.ts
  • packages/cli/src/commands/automations/prompt/meta.ts
  • packages/cli/src/commands/automations/prompt/set/command.ts
  • packages/mcp-v2/src/tools/automations/get.ts
  • packages/mcp-v2/src/tools/automations/list.ts
  • packages/sdk/src/client.ts
  • packages/sdk/src/index.ts
  • packages/sdk/src/resources/automations.ts
  • packages/sdk/src/resources/index.ts
  • packages/trpc/src/router/automation/automation.ts
💤 Files with no reviewable changes (1)
  • packages/cli/src/commands/automations/prompt/command.ts
✅ Files skipped from review due to trivial changes (4)
  • packages/sdk/src/resources/index.ts
  • packages/cli/src/commands/automations/prompt/meta.ts
  • packages/sdk/src/index.ts
  • packages/sdk/src/client.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/mcp-v2/src/tools/automations/get.ts
  • packages/cli/src/commands/automations/get/command.ts
  • packages/mcp-v2/src/tools/automations/list.ts

Comment thread packages/cli/src/commands/automations/prompt/get/command.ts Outdated
Comment on lines +26 to 35
retrieve(
id: string,
options?: RequestOptions,
): APIPromise<AutomationSummary> {
return this._client.query<AutomationSummary>(
"automation.get",
{ id },
options,
);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Breaking SDK change: retrieve and list no longer return prompt — needs version bump or migration note

Both the TypeScript API type and the underlying automation.get / automation.list tRPC wire responses now omit prompt. Any existing SDK consumer reading .prompt from automations.retrieve(id) or automations.list() will silently receive undefined at runtime (even without TypeScript errors if they're on an older version of the package).

The PR description states "No wire-format/API changes," but the tRPC response shape for get and list has genuinely changed. This should be accompanied by a semver major bump, a changelog entry, or at minimum a migration note pointing consumers to automations.getPrompt(id).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/sdk/src/resources/automations.ts` around lines 26 - 35, The SDK's
retrieve and list methods (AutomationResource.retrieve and
AutomationResource.list) now return responses that omit the prompt field because
the underlying tRPC handlers ("automation.get" / "automation.list") no longer
include it; update the release artifacts: add a changelog entry and semver-major
bump (or explicit migration note) explaining the breaking change and point
consumers to automations.getPrompt(id) for prompt data, and also update the
TypeScript docs/comments for retrieve and list to reflect that prompt is no
longer returned so callers know to call getPrompt instead.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/docs/content/docs/cli/cli-reference.mdx`:
- Around line 668-685: The documentation for the Command "superset automations
prompt get <id>" only shows the raw Markdown output and omits the structured
JSON fallback; update the Command block to document both outputs so machine
users see the JSON shape used for --json/--quiet/agent modes (add an inline type
block showing { id: string; prompt: string }) and adjust the output
prop/description to reflect both the raw Markdown path and the structured JSON
fallback so the rendered docs show the machine-readable return shape as well as
the raw prompt behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c7ae6139-aa1f-4334-87db-2a08ee10907e

📥 Commits

Reviewing files that changed from the base of the PR and between 5a95661 and ff89de3.

📒 Files selected for processing (4)
  • apps/docs/content/docs/cli/cli-reference.mdx
  • apps/docs/content/docs/sdk/reference.mdx
  • packages/cli/src/commands/automations/prompt/get/command.ts
  • packages/trpc/src/router/automation/automation.ts
✅ Files skipped from review due to trivial changes (1)
  • apps/docs/content/docs/sdk/reference.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cli/src/commands/automations/prompt/get/command.ts

Comment on lines +668 to +685
name="superset automations prompt get <id>"
args={[
{ name: "id", required: true, description: "Automation ID." },
]}
output="Markdown"
>
Print an automation's prompt body to stdout. The output is the raw prompt
with no trailing newline added, so `prompt get` and `prompt set` round-trip
byte-exactly.

```bash
# Read to a file
superset automations prompt get aut_… > prompt.md

# Verify a push landed
superset automations prompt get aut_… | diff - ./prompt.md
```
</Command>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

prompt get is missing its structured output shape for --json / --quiet / agent modes.

The PR description explicitly states that prompt get "falls back to structured { id, prompt } output" when --json, --quiet, or an agent-mode env var is active. The current block only documents the raw-text path via output="Markdown", so users scripting against prompt get --json (the typical machine-readable invocation) have no documented return shape.

Also, "Markdown" is not a TypeScript type name — every other output prop in this file is either a named type ("Automation", "Array<AutomationRun>") or an inline literal. Depending on how the Command component renders the output prop, this may appear oddly in the rendered docs.

Suggested fix — add the JSON fallback shape inline the same way other commands document multiple output modes:

📝 Proposed documentation update
 <Command
 	name="superset automations prompt get <id>"
 	args={[
 		{ name: "id", required: true, description: "Automation ID." },
 	]}
-	output="Markdown"
 >
 Print an automation's prompt body to stdout. The output is the raw prompt
 with no trailing newline added, so `prompt get` and `prompt set` round-trip
 byte-exactly.

+In `--json`, `--quiet`, or agent modes the command falls back to structured output:
+
+```ts
+{ id: string; prompt: string }
+```
+
 ```bash
 # Read to a file
 superset automations prompt get aut_… > prompt.md
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name="superset automations prompt get <id>"
args={[
{ name: "id", required: true, description: "Automation ID." },
]}
output="Markdown"
>
Print an automation's prompt body to stdout. The output is the raw prompt
with no trailing newline added, so `prompt get` and `prompt set` round-trip
byte-exactly.
```bash
# Read to a file
superset automations prompt get aut_… > prompt.md
# Verify a push landed
superset automations prompt get aut_… | diff - ./prompt.md
```
</Command>
name="superset automations prompt get <id>"
args={[
{ name: "id", required: true, description: "Automation ID." },
]}
>
Print an automation's prompt body to stdout. The output is the raw prompt
with no trailing newline added, so `prompt get` and `prompt set` round-trip
byte-exactly.
In `--json`, `--quiet`, or agent modes the command falls back to structured output:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/docs/content/docs/cli/cli-reference.mdx` around lines 668 - 685, The
documentation for the Command "superset automations prompt get <id>" only shows
the raw Markdown output and omits the structured JSON fallback; update the
Command block to document both outputs so machine users see the JSON shape used
for --json/--quiet/agent modes (add an inline type block showing { id: string;
prompt: string }) and adjust the output prop/description to reflect both the raw
Markdown path and the structured JSON fallback so the rendered docs show the
machine-readable return shape as well as the raw prompt behavior.

Drop the helper indirection — getAutomationSummaryForUser was only used twice and the inline destructure makes each procedure self-contained.
@saddlepaddle saddlepaddle merged commit b7a2558 into main May 1, 2026
14 checks passed
saddlepaddle added a commit that referenced this pull request May 2, 2026
Bundles the 5 feat(cli) commits since v0.2.2:
- automations + tasks alignment with SDK and MCP-v2 (#3966)
- cross-device login via OAuth code + PKCE (#3965)
- 'automations prompt' split into 'prompt get' / 'prompt set' (#3959)
- --name filter on automations list (#3952)
- --assignee filter on tasks list (#3972)

Push cli-v0.2.3 after this lands to fire the release pipeline.
@Kitenite Kitenite deleted the alkaline-efraasia branch May 6, 2026 04:51
@saddlepaddle saddlepaddle mentioned this pull request May 7, 2026
3 tasks
saddlepaddle added a commit that referenced this pull request May 7, 2026
npm has alpha.6 as the most recent published; alpha.7 was bumped in
71bf008 but never `npm publish`-ed. Skip alpha.7 on the registry
and ship the current repo state as alpha.8.

Changes since alpha.6:

- workspaces.create adopts the canonical host-service shape (#3893)
- automations.list accepts --name filter (#3952)
- automations.prompt split into automations.prompt.get / .set (#3959)
- agents.list (presets demoted to UI-only configuration) (#4097)
- agents.run / workspaces.create gain `superset-chat` agent + `kind`
  discriminator on launch results (terminal vs chat) (#4116)
- type adjustments for v2 workspace render path (#4141)
- redact x-api-key in debug-log header dumps (#3956, was alpha.7)

After merge: `cd packages/sdk && bun run build && cd dist && npm publish --access public`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant