Skip to content

feat: think-cli + think-server — remote coding agent#1135

Draft
mattzcarey wants to merge 2 commits intomainfrom
feat/think-cli
Draft

feat: think-cli + think-server — remote coding agent#1135
mattzcarey wants to merge 2 commits intomainfrom
feat/think-cli

Conversation

@mattzcarey
Copy link
Copy Markdown
Contributor

Summary

  • think-server: Cloudflare Worker (Durable Object) extending Think with model provider config, workspace tools, code execution in dynamic V8 isolates, git operations via isomorphic-git, and context memory
  • think-cli: Terminal client using pi-tui that connects via WebSocket — pure rendering client, all execution happens server-side
  • Modular tool rendering shared between live streaming and session history restore
  • Session naming (/name) with fuzzy matching on /resume
  • Gated fetch for sandbox outbound requests with per-host secret bindings (GitHub token auto-injected, never exposed to LLM)

Test plan

  • think CLI connects to local server, sends messages, streams responses
  • Tool calls render correctly during streaming and on session resume
  • /name, /resume, /new, /clear, /session commands work
  • Git clone/commit/push operations work in production Workers environment
  • Context memory blocks persist and show staleness warnings

A terminal coding agent where all execution happens in Cloudflare Workers.

## think-server (apps/think-server/)
- ThinkServer extends Think with workspace tools, code execution, git, memory
- Model providers: Anthropic (direct + OpenCode gateway), OpenAI, Workers AI
- Code tool: sandboxed V8 isolates with state.* (filesystem) + git.* (isomorphic-git)
- Gated fetch: per-host secret bindings, auto-injected auth headers
- Context memory: persistent blocks with staleness warnings (project + scratchpad)
- Session persistence via Think's SessionManager

## think-cli (apps/think-cli/)
- pi-tui terminal UI with pi dark theme
- WebSocket native cf_agent_chat protocol
- Slash commands with autocomplete (/resume, /clear, /new, /session, /model)
- Session index at ~/.think/sessions.json for /resume
- Print mode (-p) and JSON mode (--mode json)
- Config at ~/.think/config.json (provider, model, apiKey, githubToken)
- Auto-resolves API keys from env, OpenCode auth, gh CLI

## @cloudflare/shell/git (packages/shell/src/git/)
- isomorphic-git wrapped as ToolProvider for codemode sandbox
- CLI-matching commands: clone, status, add, commit, push, pull, checkout, log, etc.
- fs-adapter bridges shell FileSystem to isomorphic-git's fs.promises
- Auto-injected auth tokens (LLM never sees secrets)
- 8 Workers pool tests (init, add, commit, log, status, branch, checkout, diff)

## Context API updates (packages/agents/src/experimental/memory/context/)
- Add source field (system/user/project/local) to BlockDefinition
- Add updatedAt timestamp to StoredBlock
- Staleness warnings in toString() for memories >1 day old
- AgentContextProvider stores source + updated_at in SQLite
… naming

Extract shared tool rendering into ui/render.ts so live streaming and
history restore use the same code paths. Fix history restore to show
tool calls (was only rendering text parts). Add /name command for
session aliases with fuzzy matching on /resume.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 19, 2026

⚠️ No Changeset found

Latest commit: 9374106

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

const config = this.getConfig();
const workspaceTools = createWorkspaceTools(this.workspace);
const stateProvider = stateToolsFromBackend(createWorkspaceStateBackend(this.workspace));
const gitProvider = gitTools(this.workspace, { token: config?.githubToken });
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here

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