Skip to content

feat: add /agent-demote command and make grade optional#3

Merged
fdematos merged 2 commits intomainfrom
feat/agent-demote-and-optional-grade
Jan 14, 2026
Merged

feat: add /agent-demote command and make grade optional#3
fdematos merged 2 commits intomainfrom
feat/agent-demote-and-optional-grade

Conversation

@fdematos
Copy link
Contributor

Summary

  • Add /agent-demote command as a shortcut to demote agents to subagent mode
  • Make grade parameter optional in /agent-promote (defaults to primary)
  • Fix bug where empty string grade was not handled correctly
  • Bump version to 0.5.1

Changes

File Change
command/agent-demote.md New command file
command/agent-promote.md Updated description for optional grade
src/tools/agent-promote.ts Grade now optional, defaults to "primary", handles empty strings
README.md Updated docs
package.json Version bump to 0.5.1

Usage

/agent-promote rubber-duck          # Promote to primary (default)
/agent-promote rubber-duck all      # Promote to all
/agent-demote rubber-duck           # Demote to subagent

fdematos and others added 2 commits January 14, 2026 10:42
…mote

- Grade defaults to 'primary' when not specified
- Fix empty string grade bug
- Add /agent-demote command to quickly demote agents to subagent
- Bump version to 0.5.1
Co-authored-by: fdematos <fdematos@users.noreply.github.com>
@opencode-agent
Copy link
Contributor

Now I have a complete picture of the changes. Here's my review:


Pull Request Review: feat: add /agent-demote command and make grade optional

Summary

The PR adds a convenient /agent-demote command and makes the grade parameter optional in /agent-promote (defaulting to primary). The changes are well-structured and minimal.


Code Quality: Good

Strengths:

  • Clean implementation with minimal code changes
  • Proper handling of empty/whitespace strings via .trim() at src/tools/agent-promote.ts:38
  • Documentation is updated consistently in README.md
  • Version bump is appropriate for a minor feature addition

Potential Issues

1. Missing test coverage for the new default behavior

The existing tests in src/tools/agent-promote.test.ts don't cover the new optional grade behavior. While the core validation tests exist, there's no test for:

  • The args.grade?.trim() || "primary" default logic
  • Empty string handling after trim

Recommendation: Add tests for the execute function's default grade behavior. Consider adding an integration-style test or at least a unit test for the trim/default logic.

2. Minor: Command file inconsistency

In command/agent-promote.md:5, the instruction says:

Use the agent-promote tool to change agent $1 to grade $2. If no grade is provided, use primary.

This is fine, but it relies on the LLM to interpret "if no grade is provided, use primary" - which should work but could be more explicit by saying "If $2 is empty or not provided, omit the grade parameter".


Suggestions for Improvement

1. Add validation for empty/whitespace-only name

Currently, if someone calls /agent-promote " ", the name would be " " and fail validation with a confusing message. Consider trimming the name as well:

const name = args.name?.trim()
const grade = args.grade?.trim() || "primary"

if (!name) {
  return `Agent name is required`
}

2. Consider adding a test for the default grade behavior

// In agent-promote.test.ts
describe("default grade behavior", () => {
  it("should treat empty string grade as primary after trim", () => {
    const grade = "   "
    const result = grade?.trim() || "primary"
    expect(result).toBe("primary")
  })
})

Build Status

  • Typecheck: Passes
  • Tests: All 127 tests pass

Verdict

Approve with minor suggestions. The code is functional, well-documented, and follows existing patterns. The suggestions above are minor improvements that could be addressed in a follow-up PR if desired.

New%20session%20-%202026-01-14T09%3A43%3A14.493Z
opencode session  |  github run

@opencode-agent
Copy link
Contributor

User opencode-agent[bot] does not have write permissions

github run

@fdematos fdematos merged commit 798ddc3 into main Jan 14, 2026
1 of 2 checks passed
@fdematos fdematos deleted the feat/agent-demote-and-optional-grade branch January 14, 2026 20:04
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

Comments