Skip to content

feat(cli): remove default agent and resolve from saved config or init - #271

Merged
lavaman131 merged 1 commit into
mainfrom
flora131/feature/remove-default-agent
Feb 24, 2026
Merged

feat(cli): remove default agent and resolve from saved config or init#271
lavaman131 merged 1 commit into
mainfrom
flora131/feature/remove-default-agent

Conversation

@flora131

@flora131 flora131 commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Removes the hardcoded default agent (Claude) from the chat command. Instead, the CLI now resolves the agent from saved configuration or prompts the user via init, ensuring an explicit agent choice every time.

Key Changes

  • Removed default value from --agent flag in src/cli.ts:98-99
  • Agent resolution logic now follows this priority:
    1. CLI flag (--agent <name>)
    2. Saved config (.atomic/settings.json - local or global)
    3. Auto-run init to prompt user selection
  • Updated help text to reflect new behavior: "Start chat (uses saved agent or runs init)"
  • Added validation in chatCommand to require explicit agentType parameter

Behavior Changes

Before

$ atomic chat              # Silently defaulted to Claude
$ atomic chat -a opencode  # Used OpenCode

After

$ atomic chat              # Uses saved agent OR runs init to prompt
$ atomic chat -a opencode  # Uses OpenCode (flag takes precedence)

Impact

  • First-time users: Will be prompted to select an agent during their first atomic chat command
  • Existing users: Will use their previously selected agent from .atomic/settings.json
  • Breaking change: None - existing workflows with explicit --agent flags continue to work

Instead of defaulting to Claude when no --agent flag is provided,
the chat command now checks the saved atomic config for a previously
selected agent. If none is found, it runs init to prompt the user,
ensuring an explicit agent choice.

Assistant-model: Claude Code
@flora131
flora131 marked this pull request as ready for review February 24, 2026 02:17
Copilot AI review requested due to automatic review settings February 24, 2026 02:17
@claude

claude Bot commented Feb 24, 2026

Copy link
Copy Markdown

PR Review: feat(cli): remove default agent and resolve from saved config or init

Summary

This PR removes the hardcoded default agent (Claude) from the chat command and instead resolves the agent from saved config or prompts the user via init on first run. This is a good UX improvement that ensures users explicitly choose their preferred agent.


✅ What Looks Good

  1. Clean separation of concerns - Agent resolution logic is properly placed in cli.ts before calling chatCommand, while chatCommand now requires agentType explicitly.

  2. Defensive validation - The new throw new Error() in chat.ts:206 ensures chatCommand fails fast if called without an agent, making the contract clear.

  3. Good config fallback chain - The resolution order (CLI flag → saved config → init prompt) follows expected precedence.

  4. Updated help text - The example in the CLI help was correctly updated to reflect the new behavior.


🔧 Suggestions & Issues

1. Outdated Comment in chat.ts

The file header comment at line 8 still says:

 *   atomic chat                      Start chat with default agent (claude)

This should be updated to match the new behavior, e.g.:

 *   atomic chat                      Start chat (uses saved agent or runs init)

2. Consider Logging Which Agent Was Selected

When the agent is resolved from saved config (not explicitly passed via flag), it might help users to know which agent was selected. Consider adding a log message:

console.log(`Using ${agentType} from saved configuration...`);

3. Lockfile Change

The bun.lock change adding "configVersion": 0 appears to be an incidental lockfile format update. This is harmless but worth noting - it's not related to the feature.

4. Test Coverage Gap

The existing tests in chat.test.ts cover hasProjectScmSkills and shouldAutoInitChat, but there are no tests for the new agent resolution logic in cli.ts. Consider adding integration tests that verify:

  • Agent flag takes precedence over saved config
  • Saved config is used when no flag is provided
  • Init is triggered when neither flag nor saved config exists

🔒 Security

No security concerns identified. The changes involve reading local config files with proper error handling.

⚡ Performance

Minor note: readAtomicConfig() is called twice in the "no saved agent" path (once to check, once after init). This is acceptable but could be optimized by capturing the agent from initCommand directly.


✅ Verdict

Approve with minor suggestions. The core logic is sound and improves the UX. The suggestions above are non-blocking improvements.

@lavaman131
lavaman131 merged commit d6b0ff7 into main Feb 24, 2026
5 checks passed
@lavaman131
lavaman131 deleted the flora131/feature/remove-default-agent branch February 24, 2026 02:19

Copilot AI left a comment

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.

Pull request overview

This PR removes the implicit default agent selection for atomic chat and instead resolves the agent from persisted .atomic/settings.json (local override + global fallback) or triggers atomic init to prompt the user on first run.

Changes:

  • Removed the --agent default from the CLI and added resolution via readAtomicConfig(...), with a fallback to running init.
  • Updated chatCommand to require agentType at runtime (no longer defaulting to "claude").
  • Updated bun.lock metadata (configVersion).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/commands/chat.ts Removes default agent behavior and enforces presence of agentType before proceeding.
src/cli.ts Resolves agent from CLI flag → saved config → init prompt; updates help text accordingly.
bun.lock Lockfile metadata updated (configVersion).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli.ts

// If still no agent (first run), run init which prompts for selection
if (!agentType) {
await initCommand({ showBanner: true });

Copilot AI Feb 24, 2026

Copy link

Choose a reason for hiding this comment

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

The fallback-to-init path ignores global CLI flags. Here initCommand({ showBanner: true }) does not respect --no-banner, and it also drops --force/--yes, which can change behavior for users expecting non-interactive / overwrite semantics. Consider reading const globalOpts = program.opts() and passing showBanner: globalOpts.banner !== false, force: globalOpts.force, and yes: globalOpts.yes (matching the init command behavior).

Suggested change
await initCommand({ showBanner: true });
const globalOpts = program.opts();
await initCommand({
showBanner: globalOpts.banner !== false,
force: globalOpts.force,
yes: globalOpts.yes,
});

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
Comment on lines +148 to 152
// Validate agent choice
if (!validAgents.includes(agentType)) {
console.error(`${COLORS.red}Error: Unknown agent '${agentType}'${COLORS.reset}`);
console.error(`Valid agents: ${agentChoices}`);
process.exit(1);

Copilot AI Feb 24, 2026

Copy link

Choose a reason for hiding this comment

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

Agent validation currently uses Object.keys(AGENT_CONFIG) + includes, which doesn’t type-narrow agentType and duplicates the agent list logic. Since config.ts already exposes isValidAgent(key: string): key is AgentKey, using that guard here would both validate and narrow the type in one step (and keep this code resilient if agents are added/removed).

Copilot uses AI. Check for mistakes.
Comment thread src/cli.ts
Comment on lines 163 to 165
const exitCode = await chatCommand({
agentType: localOpts.agent as "claude" | "opencode" | "copilot",
agentType: agentType as "claude" | "opencode" | "copilot",
workflow: localOpts.workflow,

Copilot AI Feb 24, 2026

Copy link

Choose a reason for hiding this comment

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

After validation, agentType is cast to a hard-coded union ("claude" | "opencode" | "copilot"). This will become incorrect the next time AGENT_CONFIG gains an agent and also hides type errors if the validation logic changes. Prefer passing a properly narrowed AgentKey/AgentType (e.g., via isValidAgent narrowing) instead of a literal union cast.

Copilot uses AI. Check for mistakes.
Comment thread src/commands/chat.ts
Comment on lines +205 to +207
if (!agentType) {
throw new Error("agentType is required — resolve via saved config or init before calling chatCommand");
}

Copilot AI Feb 24, 2026

Copy link

Choose a reason for hiding this comment

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

chatCommand now throws if agentType is missing, but the type signature still allows callers to omit it (ChatCommandOptions.agentType? and chatCommand(options: ChatCommandOptions = {})). To prevent accidental runtime failures and make the contract explicit, make agentType required in ChatCommandOptions (or change the function signature to require it and drop the default {}), so TypeScript catches misuses at compile time.

Copilot uses AI. Check for mistakes.
@claude claude Bot mentioned this pull request Feb 25, 2026
lavaman131 pushed a commit that referenced this pull request Mar 26, 2026
…#271)

Instead of defaulting to Claude when no --agent flag is provided,
the chat command now checks the saved atomic config for a previously
selected agent. If none is found, it runs init to prompt the user,
ensuring an explicit agent choice.

Assistant-model: Claude Code
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.

3 participants