feat: add /setproject command to bind conversation to registered codebase#1917
Conversation
Chat conversations had no explicit, deterministic way to bind to a registered codebase — the orchestrator had to infer the project from natural language. This adds `/setproject <name>` as a deterministic slash command that writes `codebase_id` + `cwd` to the conversation row, completing the chat half of the project-binding primitive (#1886). Changes: - Add resolveCodebaseName helper with 4-tier matching (exact → case-insensitive → prefix → substring, with ambiguity detection) in orchestrator-agent.ts - Add handleSetProject function that resolves a project name and calls updateConversation with codebase_id + cwd - Register 'setproject' in the deterministic commands list and dispatch block in handleMessage - Surface /setproject under the Projects section of /help - Add 8 dispatch tests covering all 4 resolution tiers, not-found (with and without registered projects), ambiguity, and no-args Closes #1044
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughIntroduces a new ChangesSet Project Command Feature
Sequence DiagramsequenceDiagram
participant User
participant Orchestrator
participant handleSetProject
participant resolveCodebaseName
participant Database
User->>Orchestrator: /setproject ProjectName
Orchestrator->>handleSetProject: dispatch command
handleSetProject->>resolveCodebaseName: resolve project name
resolveCodebaseName->>Database: query available codebases
Database-->>resolveCodebaseName: list of codebases
resolveCodebaseName-->>handleSetProject: matched codebase
handleSetProject->>Database: updateConversation(codebase_id, cwd)
Database-->>handleSetProject: confirmation
handleSetProject-->>Orchestrator: confirmation message
Orchestrator-->>User: "Project set to ProjectName"
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
✨ 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. Comment |
Comprehensive PR ReviewPR: #1917 — feat: add /setproject command SummaryClean, well-scoped implementation. The 4-tier fuzzy resolver is correct, the dispatch wiring is consistent with peer handlers, all 8 test paths are covered, and CLAUDE.md rules are satisfied. One docs gap (commands reference page not updated), two minor LOW log-naming issues, no blockers. Verdict:
🟡 Medium Issues (Decision Needed)Missing
|
- Rename log event project.setproject_completed → project.set_completed
to match the {domain}.{action}_{state} convention used by peer handlers
(project.register_completed, project.update_completed, project.remove_completed)
- Add per-tier debug logging to resolveCodebaseName checkTier, mirroring
the observability pattern in resolveWorkflowName (router.ts)
- Add /setproject row to commands reference doc in packages/docs-web
⚡ Self-Fix Report (Aggressive)Status: COMPLETE Fixes Applied (3 total)
View all fixes
Tests Added(none — existing 8-case suite already covers all behavioral paths) Skipped (0)(none — all findings addressed) Suggested Follow-up Issues(none) Validation✅ Type check | ✅ Lint | ✅ Tests (all pass) Self-fix by Archon · aggressive mode · fixes pushed to |
Summary
codebase_idandcwdfor workflows, tool filtering, and env-var injection to work. Without explicit binding, the orchestrator may operate without codebase context or against the wrong project./setproject <name>as a deterministic slash command — adds aresolveCodebaseName4-tier fuzzy resolver, ahandleSetProjecthandler, dispatch registration, and a/helpentry.isolation_env_idis not cleared on bind (users have existing worktree commands for that).UX Journey
Before
After
Architecture Diagram
Before
After
Connection inventory:
handleMessagedeterministicCommandslist'setproject'addedhandleMessagehandleSetProjecthandleSetProjectresolveCodebaseNamehandleSetProjectcodebaseDb.listCodebaseshandleSetProjectdb.updateConversationcodebase_id+cwdhandleCommand('help')/helptext stringLabel Snapshot
risk: lowsize: Scorecore:orchestrator,core:command-handlerChange Metadata
featurecoreLinked Issue
Validation Evidence (required)
bun run validateoutput, all 7 checks EXIT=0Security Impact (required)
codebase_id/cwdon the same conversation row the user already owns.Compatibility / Migration
/setprojectis a new command that didn't exist before.updateConversationwrites to existing columns (codebase_id,cwd) already present in the schema.Human Verification (required)
What was personally validated beyond CI:
/setproject my-app(exact match) →updateConversationcalled with correctcodebase_id+cwd/setproject MY-APP(case-insensitive) → resolves to canonical-cased codebase/setproject my-w(prefix) → resolves tomy-website/setproject api(substring) → resolves toarchon-my-api/setproject appwithapp-backend+app-frontendregistered → ambiguity message, no DB write/setproject nonexistent→ not-found message listing registered projects/setproject(no args) → usage message, no DB write/setprojectwith no registered codebases → not-found message with/register-projecthint/setproject "my app"), ambiguity at each resolution tiercurlagainst a running server (unit tests cover all paths; the dispatch path is identical toupdate-projectandremove-projectwhich are already live-tested in the codebase)Side Effects / Blast Radius (required)
@archon/coreonly — orchestrator dispatch and command-handler help text./setproject awith many projects starting with "a"). This is the same trade-off made byresolveWorkflowNameand is mitigated by the ambiguity check — multiple matches at any tier return an error instead of silently picking one.Rollback Plan (required)
git revert bd651c1d) — the change is contained to 3 files, all additive./setprojectreturns an error message to the user (never panics); worst case is a no-op ifupdateConversationfails (logged asproject.setproject_completedabsent from logs).Risks and Mitigations
/setproject e).Summary by CodeRabbit
New Features
/setproject <name>command to bind conversations to registered projects with flexible name matching.Documentation