feat(cli): align automations + tasks commands with SDK and MCP-v2#3966
Conversation
- Add 'superset automations logs <id>' (already in SDK as logs() and MCP-v2 as automations_logs). - Drop the runtime-only "--project required" guard on 'automations create'; accept --project or --workspace, matching the API schema and the other surfaces. - Expose --project, --workspace, --mcp-scope on 'automations update'. - Expose --status-id, --pr-url, --estimate, --due-date, --labels on 'tasks update'; create already had them. - Whitelist packages/cli/src/commands/automations/logs in .gitignore so the new directory isn't swallowed by the generic 'logs' rule.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new "automation logs" CLI command, expands automation create/update commands to accept v2 scoping options, extends task update options with date/label parsing, and updates .gitignore to unignore the new logs command directory. Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI
participant Context as ctx (runtime)
participant API as Automation API
participant Formatter as Table Formatter
CLI->>Context: invoke `automations logs` (id, limit)
Context->>API: listRuns.query({automationId, limit})
API-->>Context: runs[]
Context->>Formatter: map runs -> table rows (format dates, host fallback)
Formatter-->>CLI: render table with headers RUN ID / STATUS / SCHEDULED / DISPATCHED / HOST
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~32 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 4/8 reviews remaining, refill in 24 minutes and 25 seconds.Comment |
Greptile SummaryThis PR closes four CLI gaps identified by auditing the CLI against the SDK and MCP-v2 surfaces: adds the missing Confidence Score: 4/5Safe to merge; only P2 concerns around null/undefined asymmetry and a silent empty-scope edge case. No P0 or P1 issues found. Two P2 findings: an asymmetric null vs undefined fallback in packages/cli/src/commands/automations/create/command.ts (null/undefined asymmetry) and packages/cli/src/commands/automations/update/command.ts (empty mcp-scope handling)
|
| Filename | Overview |
|---|---|
| .gitignore | Adds a negation rule to allow the new packages/cli/src/commands/automations/logs directory, which would otherwise be swallowed by the top-level logs ignore rule. |
| packages/cli/src/commands/automations/create/command.ts | Relaxes --project from required to optional and accepts --workspace as an alternative; minor asymmetry between null and undefined fallbacks for the two ID fields. |
| packages/cli/src/commands/automations/logs/command.ts | New command wiring automation.listRuns into the CLI; follows existing list command patterns correctly including the display casting style. |
| packages/cli/src/commands/automations/update/command.ts | Adds --project, --workspace, and --mcp-scope flags; --mcp-scope "" can silently produce an empty array and clear all scopes without warning. |
| packages/cli/src/commands/tasks/update/command.ts | Adds --status-id, --pr-url, --estimate, --due-date, and --labels flags, bringing update parity with create; date validation and label splitting follow the same logic as tasks create. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[superset automations] --> B[create]
A --> C[update]
A --> D[logs NEW]
A --> E[list / get / delete / pause / resume / run / prompt]
B --> B1{--project OR --workspace?}
B1 -- neither --> B2[Error: Provide --project or --workspace]
B1 -- one or both --> B3[automation.create.mutate]
C --> C1[--enabled? setEnabled.mutate]
C1 --> C2[automation.update.mutate]
C2 --> C3[+--project +--workspace +--mcp-scope NEW]
D --> D1[automation.listRuns.query]
D1 --> D2[table: id / status / scheduledFor / dispatchedAt / host]
F[superset tasks update] --> G[task.byIdOrSlug.query]
G --> H[task.update.mutate]
H --> I[+statusId +prUrl +estimate +dueDate +labels NEW]
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/create/command.ts:91-92
**Asymmetric null vs undefined fallbacks for project/workspace**
`v2ProjectId` falls back to `undefined` (field omitted from payload) while `v2WorkspaceId` falls back to `null` (field explicitly sent as `null`). When the user passes only `--project`, `v2WorkspaceId: null` is always included in the mutation payload. Whether this intentionally clears any pre-existing workspace association on the server depends on how the API schema handles a `null` vs absent field — if `null` is treated as "clear this field", the behaviour is asymmetric and potentially surprising.
```suggestion
v2ProjectId: options.project ?? undefined,
v2WorkspaceId: options.workspace ?? undefined,
```
### Issue 2 of 2
packages/cli/src/commands/automations/update/command.ts:75-81
**Empty `--mcp-scope` silently clears all scopes**
If a user passes `--mcp-scope ""` or `--mcp-scope " "`, the split-trim-filter chain produces `[]`, and `mcpScope: []` is then spread into the mutation — clearing every scope on the automation. A guard that rejects an all-whitespace value would make the intent explicit and prevent accidental scope-clearing.
Reviews (1): Last reviewed commit: "feat(cli): align automations + tasks com..." | Re-trigger Greptile
| v2ProjectId: options.project ?? undefined, | ||
| v2WorkspaceId: options.workspace ?? null, |
There was a problem hiding this comment.
Asymmetric null vs undefined fallbacks for project/workspace
v2ProjectId falls back to undefined (field omitted from payload) while v2WorkspaceId falls back to null (field explicitly sent as null). When the user passes only --project, v2WorkspaceId: null is always included in the mutation payload. Whether this intentionally clears any pre-existing workspace association on the server depends on how the API schema handles a null vs absent field — if null is treated as "clear this field", the behaviour is asymmetric and potentially surprising.
| v2ProjectId: options.project ?? undefined, | |
| v2WorkspaceId: options.workspace ?? null, | |
| v2ProjectId: options.project ?? undefined, | |
| v2WorkspaceId: options.workspace ?? undefined, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/automations/create/command.ts
Line: 91-92
Comment:
**Asymmetric null vs undefined fallbacks for project/workspace**
`v2ProjectId` falls back to `undefined` (field omitted from payload) while `v2WorkspaceId` falls back to `null` (field explicitly sent as `null`). When the user passes only `--project`, `v2WorkspaceId: null` is always included in the mutation payload. Whether this intentionally clears any pre-existing workspace association on the server depends on how the API schema handles a `null` vs absent field — if `null` is treated as "clear this field", the behaviour is asymmetric and potentially surprising.
```suggestion
v2ProjectId: options.project ?? undefined,
v2WorkspaceId: options.workspace ?? undefined,
```
How can I resolve this? If you propose a fix, please make it concise.| const mcpScope = | ||
| options.mcpScope !== undefined | ||
| ? options.mcpScope | ||
| .split(",") | ||
| .map((s) => s.trim()) | ||
| .filter(Boolean) | ||
| : undefined; |
There was a problem hiding this comment.
Empty
--mcp-scope silently clears all scopes
If a user passes --mcp-scope "" or --mcp-scope " ", the split-trim-filter chain produces [], and mcpScope: [] is then spread into the mutation — clearing every scope on the automation. A guard that rejects an all-whitespace value would make the intent explicit and prevent accidental scope-clearing.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/automations/update/command.ts
Line: 75-81
Comment:
**Empty `--mcp-scope` silently clears all scopes**
If a user passes `--mcp-scope ""` or `--mcp-scope " "`, the split-trim-filter chain produces `[]`, and `mcpScope: []` is then spread into the mutation — clearing every scope on the automation. A guard that rejects an all-whitespace value would make the intent explicit and prevent accidental scope-clearing.
How can I resolve this? If you propose a fix, please make it concise.
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
Previously v2WorkspaceId fell back to null while v2ProjectId fell back to undefined; with the schema treating both as nullish/optional this just sent an unnecessary explicit null. Use undefined for both.
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.
Summary
Audited the CLI, SDK, and MCP-v2 surfaces for automations / tasks / workspaces / hosts / projects and brought the CLI back into sync with what the SDK and MCP-v2 already expose. Four real misalignments — all in CLI:
superset automations logs <id>was missing. SDK already hadautomations.logs()and MCP-v2 already hadautomations_logs, both wrappingautomation.listRuns. New command added atpackages/cli/src/commands/automations/logs/command.ts. Required a.gitignoreexception so the newlogs/directory isn't swallowed by the genericlogsrule at the top of the file.automations createrequired--projectat runtime even though the API schema (and SDK / MCP-v2) acceptsv2ProjectIdORv2WorkspaceId. Now accepts either; errors only when both are missing.automations updatedidn't expose--project,--workspace, or--mcp-scopeeven though the underlyingautomation.updateschema accepts all three (and SDK / MCP-v2 already pass them through). Added the flags; partial-update semantics preserved (omitting a flag leaves the field unchanged).tasks updatewas missing--status-id,--pr-url,--estimate,--due-date,--labels.tasks createalready had most of these, so the create/update flag surface was asymmetric. SDK and MCP-v2 expose the full set; CLI now does too.Surfaces I checked and found already aligned:
tasks list/get/create/delete,automations list/get/delete/pause/resume/run/getPrompt/setPrompt,hosts list,projects list,workspaces list/create/delete. The legacypackages/mcp(mounted at/api/agent/[transport]) is a separate older domain (devices/organizations/tasks) and out of scope;packages/desktop-mcpis a different domain entirely (DOM/browser control).Test plan
bun run typecheck --filter=@superset/clicleanbun run typecheck --filter=@superset/sdk --filter=@superset/mcp-v2clean (no transitive breakage)bun run lint:fixcleansuperset automations logs <id>against a real automation and confirm table outputsuperset automations create --workspace <ws>(no --project) and confirm it succeedssuperset tasks update <slug> --status-id <id> --labels foo,bar --estimate 3and confirm the patch appliesSummary by cubic
Aligns the
supersetCLI with@superset/sdkand@superset/mcp-v2for automations and tasks. Adds automation run logs, completes update flags, and fixes create to accept workspace IDs.New Features
superset automations logs <id>to list recent runs (supports--limit).tasks updatenow supports--status-id,--pr-url,--estimate,--due-date(ISO), and--labels.Bug Fixes
automations createnow accepts--projector--workspace(either).automations updateexposes--project,--workspace, and--mcp-scope.undefined(notnull) for optionalv2ProjectId/v2WorkspaceIdon create to match schema expectations.Written for commit 924c445. Summary will update on new commits.
Summary by CodeRabbit
New Features
Enhancements