Skip to content

FULL REFACTOR#126

Merged
bmdavis419 merged 3 commits intomainfrom
davis/remote-local-rebuild
Jan 27, 2026
Merged

FULL REFACTOR#126
bmdavis419 merged 3 commits intomainfrom
davis/remote-local-rebuild

Conversation

@bmdavis419
Copy link
Collaborator

@bmdavis419 bmdavis419 commented Jan 26, 2026

it's time

step 1 + 2 done

phase 3

step 4

it's all looking pretty good

Greptile Overview

Greptile Summary

This PR implements a comprehensive v2 refactor introducing local and remote operational modes with a unified agent core. The changes span 84 files with ~13,300 additions and ~1,700 deletions.

Key Changes

  • Agent Architecture: Replaced OpenCode spawning with custom AI SDK agent loop using 4 sandboxed tools (read, grep, glob, list)
  • Provider System: Added support for 40+ AI providers through OpenCode's auth system with new provider registry and model instantiation layer
  • Project Support: Introduced projects table and migrated existing data to "default" projects for backward compatibility
  • API Key Migration: Replaced custom API key system with Clerk-based validation (breaking change for existing API keys)
  • Remote Mode: Added CLI commands (remote link, remote add, remote sync, etc.) and web API endpoints for cloud-based operations
  • Schema Changes: Added projects, mcpQuestions, and apiKeyUsage tables; added optional projectId fields to existing tables
  • Security: Implemented path sandboxing to prevent directory traversal attacks
  • Ripgrep Integration: Auto-downloads ripgrep binary for multiple platforms when not available

Important Notes

  • The planning documents (IMPLEMENTATION_PLAN.md, PROJECT_REFERENCE.md) are left in the repository
  • Migrations must be run before deploying: npx convex run migrations:runAll
  • The DEFAULT_REMOTE_URL in apps/cli/src/client/remote.ts has a TODO comment to verify production URL
  • The old apiKeys table is removed - existing custom API keys will stop working
  • MCP commands maintain backward compatibility by defaulting to "default" project

Confidence Score: 3/5

  • Safe to merge with precautions - requires running migrations and verifying configuration
  • This is a well-planned comprehensive refactor with proper migrations and backward compatibility. Score reduced due to: (1) planning docs left in repo that should be cleaned up, (2) migrations that must be run before deployment, (3) TODO comment about verifying production URL, and (4) breaking change to API key system. The refactor is thorough and follows the implementation plan closely.
  • Check apps/cli/src/client/remote.ts for production URL configuration, verify planning documents are intentional, and ensure migrations are run before deploying

Important Files Changed

Filename Overview
IMPLEMENTATION_PLAN.md New planning document added - comprehensive refactor plan for v2
PROJECT_REFERENCE.md New reference documentation for architecture and commands
apps/server/src/agent/loop.ts New custom AI SDK agent loop replaces OpenCode spawning
apps/web/src/convex/schema.ts Added projects table, projectId fields, mcpQuestions, and apiKeyUsage tables
apps/web/src/convex/mcp.ts Updated to use Clerk API keys and project support with backward compatibility
apps/cli/src/commands/remote.ts New remote CLI commands for link, add, sync, wake, status, grab, ask
apps/cli/src/client/remote.ts New remote API client with hardcoded dev URL that needs fixing

Context used:

  • Context from dashboard - AGENTS.md (source)

Copy link
Collaborator Author

bmdavis419 commented Jan 26, 2026

@bmdavis419 bmdavis419 changed the title it's time FULL REFACTOR Jan 26, 2026
@bmdavis419 bmdavis419 marked this pull request as ready for review January 26, 2026 07:16
@bmdavis419 bmdavis419 changed the base branch from davis/better-onboarding to graphite-base/126 January 26, 2026 20:16
@bmdavis419 bmdavis419 changed the base branch from graphite-base/126 to main January 26, 2026 20:16
@bmdavis419 bmdavis419 changed the base branch from main to graphite-base/126 January 26, 2026 20:25
@bmdavis419 bmdavis419 force-pushed the davis/remote-local-rebuild branch from dce10d8 to f27daf9 Compare January 26, 2026 20:25
@bmdavis419 bmdavis419 changed the base branch from graphite-base/126 to davis/better-onboarding January 26, 2026 20:25
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

*/

// TODO: Change back to 'https://btca.dev' before deploying!
const DEFAULT_REMOTE_URL = 'http://localhost:5173';
Copy link
Contributor

Choose a reason for hiding this comment

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

hardcoded development URL will break remote functionality in production

Suggested change
const DEFAULT_REMOTE_URL = 'http://localhost:5173';
const DEFAULT_REMOTE_URL = 'https://btca.dev';
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/cli/src/client/remote.ts
Line: 7:7

Comment:
hardcoded development URL will break remote functionality in production

```suggestion
const DEFAULT_REMOTE_URL = 'https://btca.dev';
```

How can I resolve this? If you propose a fix, please make it concise.

@bmdavis419 bmdavis419 force-pushed the davis/remote-local-rebuild branch from de1a1d3 to abfc6de Compare January 27, 2026 21:46
Copy link
Collaborator Author

bmdavis419 commented Jan 27, 2026

Merge activity

  • Jan 27, 9:55 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 27, 9:56 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jan 27, 9:57 PM UTC: @bmdavis419 merged this pull request with Graphite.

@bmdavis419 bmdavis419 changed the base branch from davis/better-onboarding to graphite-base/126 January 27, 2026 21:55
@bmdavis419 bmdavis419 changed the base branch from graphite-base/126 to main January 27, 2026 21:55
@bmdavis419 bmdavis419 force-pushed the davis/remote-local-rebuild branch from 915b90b to 12968de Compare January 27, 2026 21:56
@bmdavis419 bmdavis419 merged commit 3a90843 into main Jan 27, 2026
3 checks passed
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