aiserver.v1 + cursor client — kod yapısı
Cursor reverse-engineering (eisbaw/cursor_api_demo, unite.proto) ile hizalı dizin yapısı.
Backend — aiserver.v1
src/aiserver/v1/
├── connect/
│ ├── envelope.ts Connect-RPC router (json + proto)
│ └── connect-proto.ts Binary envelope [flags:1][len:4BE][payload]
├── messages/
│ ├── common.ts StreamCpp, CppFate, CurrentFileInfo
│ ├── agent.ts StreamUnifiedChatWithTools
│ ├── client-side-tool-v2.ts ClientSideToolV2 enum
│ ├── git.ts GitService
│ ├── indexing.ts IndexService
│ └── shadow-workspace.ts ShadowWorkspaceService (GetLintsForChange)
├── services/
│ ├── ai-service.ts AiService
│ ├── chat-service.ts ChatService (StreamUnifiedChatWithTools)
│ ├── cpp-service.ts CppService
│ ├── file-sync-service.ts FileSyncService
│ ├── git-service.ts GitService
│ ├── index-service.ts IndexService
│ └── shadow-workspace-service.ts ShadowWorkspaceService
├── extension-host/
│ ├── agent/agent-harness.ts Agent Harness + Tool Orchestrator
│ ├── shadow/
│ │ ├── shadow-workspace-host.ts ApplyEdit / SyncWorkspace / GetDiagnostics
│ │ └── shadow-linter.ts GetLintsForChange
│ ├── tab/
│ │ ├── context-compiler.ts RefreshTabContext
│ │ ├── tab-policy.ts policy gradient gate
│ │ ├── tab-policy-gradient.ts ödül + gradient step
│ │ └── online-rl-trainer.ts RecordCppFate → TrainTabPolicy loop
│ ├── git/git-context-compiler.ts GetGitContext
│ └── index/index-builder.ts BuildIndex / Instant Grep
├── indexing/ trigram, semantic, merkle, chunker
├── inference/lenec-adapter.ts BYOK gateway
└── stores/ fate, index, tab-config, search-index
Client — cursor_*
src/cursor/
├── cursor-connect-client.ts Connect-RPC transport (connect+proto)
├── cursor-config-bootstrap.ts Server config auto-load (/api/config)
├── cursor-proper-protobuf.ts Envelope encode/decode
├── cursor-streaming-decoder.ts Stream frame parser
├── cursor-tab-client.ts StreamCpp, RecordCppFate, CppConfig
├── cursor-tab-rl-client.ts TrainTabPolicy, GetTabRlStatus
├── cursor-agent-client.ts StreamUnifiedChatWithTools
├── cursor-git-client.ts GetGitContext
├── cursor-index-client.ts BuildIndex, InstantGrep, SearchCodebase
├── cursor-inline-edit-client.ts StreamInlineEdit
├── cursor-shadow-workspace-client.ts ShadowWorkspaceService + shadow_workspace.v1
└── tool-executor.ts ClientSideToolV2 executor (EDIT_FILE → ApplyEdit)
shadow_workspace.v1
src/shadow_workspace/v1/
├── messages.ts ApplyEdit, SyncWorkspace, GetDiagnostics
└── edit-resolver.ts code_edit / new_contents resolver
RPC
| RPC | Servis | Path |
|---|---|---|
| StreamCpp | AiService | /api/aiserver/v1/AiService/StreamCpp |
| StreamUnifiedChatWithTools | ChatService | /api/aiserver/v1/ChatService/StreamUnifiedChatWithTools |
| InstantGrep | IndexService | /api/aiserver/v1/IndexService/InstantGrep |
| SearchCodebase | IndexService | /api/aiserver/v1/IndexService/SearchCodebase |
| GetLintsForChange | ShadowWorkspaceService | /api/aiserver/v1/ShadowWorkspaceService/GetLintsForChange |
| ApplyEdit | ShadowWorkspaceService | /api/aiserver/v1/ShadowWorkspaceService/ApplyEdit |
| TrainTabPolicy | CppService | /api/aiserver/v1/CppService/TrainTabPolicy |
| GetTabRlStatus | CppService | /api/aiserver/v1/CppService/GetTabRlStatus |
| SyncWorkspace | shadow_workspace.v1 | /api/aiserver/v1/shadow_workspace.v1.ShadowWorkspaceService/SyncWorkspace |
Endpoint format: aiserver.v1.{Service}/{Rpc} (Connect-RPC)