Skip to content

feat: add templates command#63

Merged
felipefreitag merged 5 commits intomainfrom
worktree-add-templates-command
Mar 13, 2026
Merged

feat: add templates command#63
felipefreitag merged 5 commits intomainfrom
worktree-add-templates-command

Conversation

@felipefreitag
Copy link
Contributor

Add full templates CRUD support with list, get, create, update, delete, publish, and duplicate subcommands. Create requires --html or --html-file (prompts interactively if missing), matching the SDK's requirement.

@felipefreitag felipefreitag force-pushed the worktree-add-templates-command branch from 6a949cb to 85b1559 Compare March 12, 2026 21:07
@felipefreitag felipefreitag marked this pull request as ready for review March 12, 2026 21:07
@felipefreitag felipefreitag requested a review from vcapretz March 12, 2026 21:08
Copy link
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.

5 issues found across 10 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="src/commands/templates/utils.ts">

<violation number="1" location="src/commands/templates/utils.ts:33">
P2: Reject empty numeric fallbacks instead of coercing `count:number:` to `fallbackValue: 0`.</violation>
</file>

<file name="src/commands/templates/delete.ts">

<violation number="1" location="src/commands/templates/delete.ts:9">
P2: Deleting by alias produces incorrect `--json` output because the helper echoes the input string into the `id` field instead of the API response.</violation>
</file>

<file name="src/commands/templates/create.ts">

<violation number="1" location="src/commands/templates/create.ts:81">
P2: Reject `--html` with `--html-file` instead of silently preferring the file body.</violation>
</file>

<file name="src/commands/templates/update.ts">

<violation number="1" location="src/commands/templates/update.ts:25">
P2: The update command is missing `variables` support even though `templates.update` now accepts it, so the help text documents a limitation that is no longer true.</violation>

<violation number="2" location="src/commands/templates/update.ts:79">
P1: Truthy checks here prevent supported empty-string updates from ever reaching `templates.update`.</violation>
</file>

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

export const deleteTemplateCommand = new Command('delete')
.alias('rm')
.description('Delete a template')
.argument('<id>', 'Template ID or alias')
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 12, 2026

Choose a reason for hiding this comment

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

P2: Deleting by alias produces incorrect --json output because the helper echoes the input string into the id field instead of the API response.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/commands/templates/delete.ts, line 9:

<comment>Deleting by alias produces incorrect `--json` output because the helper echoes the input string into the `id` field instead of the API response.</comment>

<file context>
@@ -0,0 +1,48 @@
+export const deleteTemplateCommand = new Command('delete')
+  .alias('rm')
+  .description('Delete a template')
+  .argument('<id>', 'Template ID or alias')
+  .option(
+    '--yes',
</file context>
Fix with Cubic

@felipefreitag felipefreitag requested a review from zenorocha March 12, 2026 21:23
Copy link
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.

3 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="src/commands/templates/utils.ts">

<violation number="1" location="src/commands/templates/utils.ts:31">
P2: This now rejects valid empty-string fallbacks for `string` template variables. `--var NAME:string:` should still map to `fallbackValue: ''`; only empty numeric fallbacks need to be rejected.</violation>
</file>

<file name="src/commands/templates/update.ts">

<violation number="1" location="src/commands/templates/update.ts:71">
P2: Use the same null-check semantics in the `--html`/`--html-file` exclusivity guard; `--html ""` currently bypasses the conflict error.</violation>
</file>

<file name="src/commands/templates/create.ts">

<violation number="1" location="src/commands/templates/create.ts:79">
P2: Check option presence here rather than truthiness; `--html "" --html-file ...` currently bypasses the mutual-exclusion error.</violation>
</file>

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

Add full templates CRUD support with list, get, create, update, delete,
publish, and duplicate subcommands. Create requires --html or --html-file
(prompts interactively if missing), matching the SDK's requirement.
- Reject empty numeric fallbacks in --var parsing
- Use API response for delete JSON output instead of manually constructed object
- Reject --html + --html-file as mutually exclusive on create and update
- Add --var support to update command
- Use != null checks in update to allow clearing fields with empty strings
The runDelete action was outputting raw SDK responses which lack a
consistent shape. Now it synthesizes {object, id, deleted} so piped
and --json output matches the documented contract.
@felipefreitag felipefreitag force-pushed the worktree-add-templates-command branch from 01beb0b to a6d2b1e Compare March 13, 2026 12:46
@felipefreitag felipefreitag merged commit e47d6df into main Mar 13, 2026
5 checks passed
@felipefreitag felipefreitag deleted the worktree-add-templates-command branch March 13, 2026 12:48
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.

2 participants