Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Coding Code 是 AI 编程助手。
|---|---|---|
| `@codingcode/core` | `packages/codingcode` | 核心引擎:agent loop 与全部编排能力 |
| `@codingcode/infra` | `packages/infra` | 基础设施:配置加载、日志、禁用项存储 |
| `@codingcode/tui` | `packages/tui` | 终端界面(Ink + React) |
| `@codingcode/desktop` | `packages/desktop` | 桌面端(Electron + React) |

`packages/sdk`、`packages/web` 目前只有空 `src/`,尚无实现。
Expand All @@ -34,7 +33,6 @@ Coding Code 是 AI 编程助手。
- `rules`:全局 / 项目级规则装载
- `server`:HTTP / SSE 入口
- `client`:HTTP 客户端(`AgentClient` 的实现)
- `direct`:进程内直连端口,免 HTTP 的 runtime / sessions / settings / models 接口
- `core`:通用件(`error` / `result` / `path`),不指向任何功能模块
- `contracts`:跨领域共享契约
- `layer.ts`:组合根,全量装配
Expand Down Expand Up @@ -75,7 +73,7 @@ Coding Code 是 AI 编程助手。
- 禁止用户当前轮未明确要求就主动进行 reset、commit、push 等相关会影响 git 历史或者当前仓库代码的操作,仅用户显式要求进行某类操作才能进行;仅允许 `git diff`、`git log` 等无副作用的操作可以自主进行
- 禁止未在用户指示下补充测试,当开发任务完成后,给用户报告完成程度,由用户决定针对哪些部分写测试
- 禁止将工具执行细节泄漏到 agent 编排层及其他模块,agent 只依赖端口契约,不得 import 工具实现
- 禁止将传输协议细节(HTTP / SSE)泄漏到 agent 核心及其他模块,agent 不得依赖 `server/`、`client/`、`direct/`
- 禁止将传输协议细节(HTTP / SSE)泄漏到 agent 核心及其他模块,agent 不得依赖 `server/`、`client/`
- 不允许假设“这是未来需要扩展的”,所以现在就不做,应该贴合用户的实际要求
- 不允许总是有阶段性计划,分阶段完成很容易导致过程产生一堆没用的死代码
- 不许兼容、兜底旧代码
Expand Down
4 changes: 1 addition & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Coding Code 是 AI 编程助手。
|---|---|---|
| `@codingcode/core` | `packages/codingcode` | 核心引擎:agent loop 与全部编排能力 |
| `@codingcode/infra` | `packages/infra` | 基础设施:配置加载、日志、禁用项存储 |
| `@codingcode/tui` | `packages/tui` | 终端界面(Ink + React) |
| `@codingcode/desktop` | `packages/desktop` | 桌面端(Electron + React) |

`packages/sdk`、`packages/web` 目前只有空 `src/`,尚无实现。
Expand All @@ -34,7 +33,6 @@ Coding Code 是 AI 编程助手。
- `rules`:全局 / 项目级规则装载
- `server`:HTTP / SSE 入口
- `client`:HTTP 客户端(`AgentClient` 的实现)
- `direct`:进程内直连端口,免 HTTP 的 runtime / sessions / settings / models 接口
- `core`:通用件(`error` / `result` / `path`),不指向任何功能模块
- `contracts`:跨领域共享契约
- `layer.ts`:组合根,全量装配
Expand Down Expand Up @@ -75,7 +73,7 @@ Coding Code 是 AI 编程助手。
- 禁止用户当前轮未明确要求就主动进行 reset、commit、push 等相关会影响 git 历史或者当前仓库代码的操作,仅用户显式要求进行某类操作才能进行;仅允许 `git diff`、`git log` 等无副作用的操作可以自主进行
- 禁止未在用户指示下补充测试,当开发任务完成后,给用户报告完成程度,由用户决定针对哪些部分写测试
- 禁止将工具执行细节泄漏到 agent 编排层及其他模块,agent 只依赖端口契约,不得 import 工具实现
- 禁止将传输协议细节(HTTP / SSE)泄漏到 agent 核心及其他模块,agent 不得依赖 `server/`、`client/`、`direct/`
- 禁止将传输协议细节(HTTP / SSE)泄漏到 agent 核心及其他模块,agent 不得依赖 `server/`、`client/`
- 不允许假设“这是未来需要扩展的”,所以现在就不做,应该贴合用户的实际要求
- 不允许总是有阶段性计划,分阶段完成很容易导致过程产生一堆没用的死代码
- 不许兼容、兜底旧代码
Expand Down
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ coding-code/
│ │ ├── subagent/ # 子智能体加载和注册
│ │ ├── scheduler/ # 调度服务
│ │ ├── rules/ # 规则注入
│ │ ├── client/ # 客户端(HTTP / Direct / SSE)
│ │ ├── client/ # 客户端(HTTP / SSE)
│ │ ├── core/ # 核心工具类型和路径
│ │ ├── runtime/ # 项目运行时
│ │ ├── sandbox/ # 沙箱(stub,预留)
│ │ ├── server/ # Hono HTTP 服务 + SSE
│ │ ├── cli.ts # CLI 入口
│ │ └── layer.ts # Effect Layer 入口
│ ├── tui/src/ # @codingcode/tui — Ink 终端 UI
│ │ ├── components/ # App, InputBox, MessageItem 等
│ │ └── hooks/ # useAgentRunner, useTerminalSize
│ ├── desktop/ # @codingcode/desktop — Electron 桌面应用
│ │ ├── electron/ # 主进程(IPC、文件服务、Git 服务)
│ │ └── src/ # React 前端(Agent UI、设置面板)
Expand Down
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/)

终端原生的 AI 编程助手。核心引擎纯手写 ReAct 循环,通过 HTTP 服务化对外暴露,TUI / Desktop / SDK 等所有端共享同一份编排逻辑。没有黑盒,所有行为都可定制。
终端原生的 AI 编程助手。核心引擎纯手写 ReAct 循环,通过 HTTP 服务化对外暴露,Desktop / SDK 等所有端共享同一份编排逻辑。没有黑盒,所有行为都可定制。

</div>

Expand Down Expand Up @@ -43,29 +43,24 @@ pnpm install
# 2. 配置 API Key
export DEEPSEEK_API_KEY=sk-xxx

# 3. 启动(server + TUI)
# 3. 启动
pnpm start
```

启动成功后,终端会显示交互式 TUI 界面。

### 其他启动方式

```bash
pnpm start serve # 仅启动 HTTP server(供 Web / SDK 调用)
pnpm start tui # 仅启动 TUI(连接已有 server)
```
启动成功后,HTTP server 开始监听并打印 `CODINGCODE_SERVER_READY:<port>`,可用 Desktop 或 SDK 接入。

### SDK 调用示例

```typescript
import { createHttpClient } from '@codingcode/core/client/http';
import { createHttpClients } from '@codingcode/core/client';

const client = await createHttpClient('http://localhost:8080');
const clients = createHttpClients('http://localhost:8080');

for await (const chunk of client.sendMessage('帮我写一个快排')) {
if (chunk.type === 'text') {
process.stdout.write(chunk.text);
for await (const frame of clients.agent.sendMessage('帮我写一个快排', {
cwd: process.cwd(),
})) {
if (frame.family === 'event' && frame.event.type === 'text_delta') {
process.stdout.write(frame.event.text);
}
}
```
Expand All @@ -77,7 +72,7 @@ for await (const chunk of client.sendMessage('帮我写一个快排')) {
```
┌──────────────────────────────────────────────────────────┐
│ 客户端层 │
│ @codingcode/tui (Ink) · @codingcode/desktop (Electron) │
│ @codingcode/desktop (Electron) │
└──────────────────────────┬───────────────────────────────┘
│ HTTP / SSE(AgentClient 接口)
┌──────────────────────────┴───────────────────────────────┐
Expand Down Expand Up @@ -126,7 +121,7 @@ for await (const chunk of client.sendMessage('帮我写一个快排')) {
}
```

`driver` 支持 `"deepseek"`(原生 SDK)、`"openai"`(OpenAI 兼容 API)和 `"gemini"`(Google Gemini)。运行时可通过 `/model` 命令切换。
`driver` 支持 `"deepseek"`(原生 SDK)、`"openai"`(OpenAI 兼容 API)和 `"gemini"`(Google Gemini)。运行时可在客户端中切换模型。

---

Expand Down Expand Up @@ -168,7 +163,6 @@ for await (const chunk of client.sendMessage('帮我写一个快排')) {
| DI / 错误追踪 | Effect TS 3.x |
| LLM SDK | Vercel AI SDK v6 + @ai-sdk/deepseek + @ai-sdk/openai |
| HTTP 框架 | Hono 4.x |
| TUI | Ink 7.x + React 19 |
| Desktop | Electron 35 + React 19 + Zustand 5 |
| MCP | @modelcontextprotocol/sdk 1.29.x |
| 校验 | Zod 4.x |
Expand Down
1 change: 0 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ memory:

### 运行时切换

- TUI 中输入 `/model` 命令可切换模型
- 通过 API `POST /api/models` 切换

---
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"workspaces": [
"packages/infra",
"packages/codingcode",
"packages/tui",
"packages/desktop"
],
"scripts": {
Expand Down Expand Up @@ -34,9 +33,6 @@
"effect": "^3.21.2",
"globby": "^14.1.0",
"hono": "^4.12.19",
"ink": "^7.0.3",
"ink-spinner": "^5.0.0",
"ink-text-input": "^6.0.0",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
"react": "^19.2.6",
Expand Down
4 changes: 0 additions & 4 deletions packages/codingcode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
".": "./src/layer.ts",
"./client": "./src/client/http/index.ts",
"./server": "./src/server/index.ts",
"./direct/agent-runtime": "./src/direct/agent-runtime.ts",
"./direct/sessions": "./src/direct/sessions.ts",
"./direct/settings": "./src/direct/settings.ts",
"./direct/models": "./src/direct/models.ts",
"./approval/types": "./src/approval/types.ts",
"./agent/profile": "./src/agent/profile.ts",
"./contracts/frame": "./src/contracts/frame.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/codingcode/scripts/bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ await build({
outfile: resolve(root, 'dist/cli.bundle.js'),
// pino-pretty 仅在开发模式使用,生产模式不会加载
external: ['pino-pretty'],
// 动态 import 的 TUI 路径无法静态解析,保持原样
splitting: false,
sourcemap: true,
minify: false,
Expand Down
26 changes: 0 additions & 26 deletions packages/codingcode/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Effect } from 'effect';
import { serve } from '@hono/node-server';
import { LLMFactoryService } from './llm/port.js';
import { createServer } from './server/index.js';
import { createAppRuntime } from './layer.js';
import { loadConfig, ensureUserConfig } from '@codingcode/infra/config';
Expand All @@ -10,50 +9,25 @@ import { AgentError } from './core/error.js';
import { SchedulerService } from './scheduler/port.js';

async function main() {
const args = process.argv.slice(2);
ensureUserConfig();
ensureTempCwd();
const config = loadConfig();

const serveOnly = args.includes('serve');
const tuiOnly = args.includes('tui');
const basePort = config.server.port;

const rt = createAppRuntime();

const program = Effect.gen(function* () {
const port = yield* Effect.tryPromise(() => findAvailablePort(basePort));
const llmFactory = yield* LLMFactoryService;

// Initialize scheduler with the shared runtime
const scheduler = yield* SchedulerService;
scheduler.setRuntime(rt);
scheduler.initialize();

if (tuiOnly) {
const tuiPath = '../../tui/src/index.js';
const { runTui, createTuiClientFromFacades } = yield* Effect.tryPromise(
() => import(tuiPath)
);
const llm = yield* llmFactory.getLLMClient();
const client = createTuiClientFromFacades(llm, rt);
runTui({ client });
return;
}

const app = yield* Effect.tryPromise(() => createServer(rt));
serve({ fetch: app.fetch, port });
console.log(`CODINGCODE_SERVER_READY:${port}`);

if (!serveOnly) {
const tuiPath = '../../tui/src/index.js';
const { runTui, createTuiClientFromFacades } = yield* Effect.tryPromise(
() => import(tuiPath)
);
const llm = yield* llmFactory.getLLMClient();
const client = createTuiClientFromFacades(llm, rt);
runTui({ client });
}
});

const result = await rt.runPromise(
Expand Down
113 changes: 0 additions & 113 deletions packages/codingcode/src/direct/agent-runtime.ts

This file was deleted.

33 changes: 0 additions & 33 deletions packages/codingcode/src/direct/models.ts

This file was deleted.

Loading
Loading