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
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Coding Code 是 AI 编程助手。
| 包 | 目录 | 职责 |
|---|---|---|
| `@codingcode/core` | `packages/codingcode` | 核心引擎:agent loop 与全部编排能力 |
| `@codingcode/infra` | `packages/infra` | 基础设施:配置加载、日志、禁用项存储 |
| `@codingcode/desktop` | `packages/desktop` | 桌面端(Electron + React) |

`packages/sdk`、`packages/web` 目前只有空 `src/`,尚无实现。
Expand All @@ -19,6 +18,7 @@ Coding Code 是 AI 编程助手。
- `agent`:本项目核心,手写 ReAct loop 与编排;不持有 Session、不感知传输协议
- `tools`:工具系统,`domains/` 下分 fs / bash / web / self / subagent 五个域
- `llm`:模型调用与 provider 适配
- `infra`:应用配置(`config.yaml`)、模型清单(`models.json`)、YAML 存取、日志
- `mcp`:Model Context Protocol 集成
- `context`:上下文预算与压缩
- `memory`:跨会话长期记忆
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Coding Code 是 AI 编程助手。
| 包 | 目录 | 职责 |
|---|---|---|
| `@codingcode/core` | `packages/codingcode` | 核心引擎:agent loop 与全部编排能力 |
| `@codingcode/infra` | `packages/infra` | 基础设施:配置加载、日志、禁用项存储 |
| `@codingcode/desktop` | `packages/desktop` | 桌面端(Electron + React) |

`packages/sdk`、`packages/web` 目前只有空 `src/`,尚无实现。
Expand All @@ -19,6 +18,7 @@ Coding Code 是 AI 编程助手。
- `agent`:本项目核心,手写 ReAct loop 与编排;不持有 Session、不感知传输协议
- `tools`:工具系统,`domains/` 下分 fs / bash / web / self / subagent 五个域
- `llm`:模型调用与 provider 适配
- `infra`:应用配置(`config.yaml`)、模型清单(`models.json`)、YAML 存取、日志
- `mcp`:Model Context Protocol 集成
- `context`:上下文预算与压缩
- `memory`:跨会话长期记忆
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ coding-code/
├── packages/
│ ├── codingcode/src/ # @codingcode/core — 核心引擎
│ │ ├── agent/ # ReAct Loop(纯引擎,无副作用)
│ │ ├── llm/ # LLM 客户端工厂(多厂商)
│ │ ├── llm/ # LLM 调用通道(多厂商)
│ │ ├── infra/ # 应用配置、模型清单、YAML 存取、日志
│ │ ├── mcp/ # MCP 服务集成
│ │ ├── context/ # 上下文管理 + 自动压缩
│ │ ├── session/ # JSONL 会话持久化
Expand All @@ -46,10 +47,9 @@ coding-code/
│ │ ├── server/ # Hono HTTP 服务 + SSE
│ │ ├── cli.ts # CLI 入口
│ │ └── layer.ts # Effect Layer 入口
│ ├── desktop/ # @codingcode/desktop — Electron 桌面应用
│ │ ├── electron/ # 主进程(IPC、文件服务、Git 服务)
│ │ └── src/ # React 前端(Agent UI、设置面板)
│ └── infra/src/ # @codingcode/infra — 基础设施
│ └── desktop/ # @codingcode/desktop — Electron 桌面应用
│ ├── electron/ # 主进程(IPC、文件服务、Git 服务)
│ └── src/ # React 前端(Agent UI、设置面板)
├── config/ # 模型配置
│ └── models.json # 模型/厂商目录
├── docs/ # 项目文档
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pnpm start
### SDK 调用示例

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

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

Expand All @@ -73,19 +73,15 @@ for await (const frame of clients.agent.sendMessage('帮我写一个快排', {
┌──────────────────────────────────────────────────────────┐
│ 客户端层 │
│ @codingcode/desktop (Electron) │
│ @codingcode/sdk(AgentClient 契约 + HTTP/SSE 实现) │
└──────────────────────────┬───────────────────────────────┘
│ HTTP / SSE(AgentClient 接口)
┌──────────────────────────┴───────────────────────────────┐
│ 核心引擎层 │
│ @codingcode/core │
│ ReAct Loop · 工具 · MCP · 上下文 · 记忆 · Checkpoint │
│ 钩子 · 子智能体 · 技能 · 审批 · 会话 · 调度 │
└──────────────────────────┬───────────────────────────────┘
│
┌──────────────────────────┴───────────────────────────────┐
│ 基础设施层 │
│ @codingcode/infra │
│ 配置加载 · 日志 · 共享类型 │
│ 模型清单 · 应用配置 · YAML 存取 · 日志 · 共享类型 │
└──────────────────────────────────────────────────────────┘
```

Expand Down
34 changes: 14 additions & 20 deletions docs/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,46 @@ Coding Code 采用两层压缩策略,在不同阈值下自动触发:
|--------|-----|------|
| 触发阈值 | `promptEstimate > modelMaxTokens * 0.9` | prompt 估算超过模型最大 token 90% 时触发 |
| 保留最近 turn | 1 | 保留最近 1 个 turn 不压缩 |
| 压缩方式 | 调用 LLM 生成摘要 | 输出 `<summary>...</summary>` 块 |
| 压缩方式 | 调用 LLM 生成摘要 | 整段输出即摘要(全量替换,不做标签抽取) |
| 增量压缩 | 是 | 找到已有 SummaryEvent,只压缩 `endTurnId` 之后的事件 |
| 失败追踪 | 连续 3 次失败后停止 | 24 小时 TTL 后重置 |

---

## 压缩输出格式

LLM 压缩的摘要包含 10 个固定小节:
LLM 压缩要求模型按 10 个固定小节输出;**模型的整段输出即摘要文本**,不做标签抽取:

```
<analysis>
自由推理区域,分析对话内容和关键信息
</analysis>

<summary>
### Primary Request
## 1. Primary Request and Intent
用户的核心请求

### Key Technical Concepts
## 2. Key Technical Concepts
涉及的关键技术概念

### Files and Code Sections
## 3. Files and Code Sections
相关文件和代码段

### Errors and Fixes
## 4. Errors and Fixes
遇到的错误和修复

### Problem Solving
## 5. Problem Solving
问题解决过程

### Decision Rationale
决策理由
## 6. Decision Rationale and Rejected Approaches
决策理由与被否决的方案

### All User Messages
所有用户消息摘要
## 7. All User Messages
所有用户消息

### Pending Tasks
## 8. Pending Tasks
待处理任务

### Current Work
## 9. Current Work
当前工作内容

### Optional Next Step
## 10. Optional Next Step
可选的下一步
</summary>
```

---
Expand Down
4 changes: 2 additions & 2 deletions docs/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Coding Code 支持跨会话的长期记忆:自动从对话中提取关键信

1. 读取记忆文件全文作为"已有记忆"
2. 将会话记录(按 `[user]` / `[assistant]` / `[tool:名称]` 标注)与已有记忆一起发送给 LLM
3. LLM 输出整份**最新版记忆**,放在 `<memory>...</memory>` 块中
3. LLM 输出整份**最新版记忆**(整段输出即内容,不做标签或片段抽取)
4. 直接用输出内容整体替换记忆文件(受字节上限约束)

模型自行决定更新哪些内容:可以新增条目、修改过时信息、删除不再相关的内容,代码不做"模型只改动哪部分"的任何假设。若模型没有输出有效内容、或输出与当前文件一致,则不写入。
模型自行决定更新哪些内容:可以新增条目、修改过时信息、删除不再相关的内容,代码不做"模型只改动哪部分"的任何假设。若模型输出为空、或输出与当前文件一致,则不写入。

### 提取提示词

Expand Down
10 changes: 3 additions & 7 deletions docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ interface ToolVisibilityPolicy {
| 层级 | 名称 | 逻辑 |
|------|------|------|
| 1 | **RuleEngine** | 规则引擎匹配,支持 glob 模式匹配工具名和参数,按优先级排序 |
| 2 | **PermissionMode** | 权限模式驱动的自动放行:`bypass`(全部放行)、`acceptEdits`(非破坏性工具放行,涵盖只读与编辑工具)、`default`(不自动放行,继续下一层)。只读工具不再有无条件的独立白名单层;`plan` Profile 由 `agent/profile.ts` 中的 `planProfileGateHook` 在下一层强制,不在此层处理 |
| 2 | **PermissionMode** | 权限模式驱动的自动放行:`bypass`(全部放行)、`acceptEdits`(非破坏性工具放行,涵盖只读与编辑工具)、`ask`(不自动放行,继续下一层)。只读工具不再有无条件的独立白名单层;`plan` Profile 由 `agent/profile.ts` 中的 `planProfileGateHook` 在下一层强制,不在此层处理 |
| 3 | **HookPreToolUse** | 钩子决策,可返回 allow/deny/ask/continue,支持 `modifiedInput` 修改参数 |
| 4 | **UserConfirmation** | 异步用户确认,支持 allow/deny/always/never 四种响应,always/never 会持久化为规则 |
| 5 | **AuditLog** | 每一层决策后记录审计日志,通过 `tool.approval.post` 钩子发出 |
Expand All @@ -126,17 +126,13 @@ interface ToolVisibilityPolicy {
### 权限模式

```typescript
type PermissionMode = 'default' | 'acceptEdits' | 'bypass';
type PermissionMode = 'ask' | 'acceptEdits' | 'bypass';
```

- `default`:不自动放行任何工具(含只读工具),全部逐层审批
- `ask`:不自动放行任何工具(含只读工具),全部逐层审批
- `acceptEdits`:非破坏性工具自动放行(涵盖只读工具与编辑类工具),破坏性工具仍需确认
- `bypass`:全部放行,跳过所有审批(慎用)

> 原独立的 `ReadonlyWhitelist` 层(在 `default` 下也无条件放行只读工具)已废弃,其语义并入 `PermissionMode` 的自动放行判定:`acceptEdits` 视只读工具为非破坏性工具自动放行,`default` 不再自动放行。

> `plan` 不再是 `PermissionMode` 的成员。plan Profile 通过 `AgentProfile.name === 'plan'` 结构化识别,由 `agent/profile.ts` 的 `planProfileGateHook` 和 `PLAN_PROFILE_ALLOWED_TOOLS` 共同限制工具。因只读白名单层已删除,`dispatch_agent` 等在 plan 下不再被流水线上层提前放行,统一由 plan gate 拦截。

### OS 级沙箱(预留)

`packages/codingcode/src/sandbox/` 目前是 stub 实现(`SandboxService` 为空类),尚未集成实际的沙箱运行时。审批流水线已提供基本安全保障,OS 级沙箱将在未来版本中实现。
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"packageManager": "pnpm@11.3.0",
"type": "module",
"workspaces": [
"packages/infra",
"packages/codingcode",
"packages/sdk",
"packages/desktop"
],
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions packages/codingcode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
},
"exports": {
".": "./src/layer.ts",
"./client": "./src/client/http/index.ts",
"./server": "./src/server/index.ts",
"./approval/types": "./src/approval/types.ts",
"./agent/profile": "./src/agent/profile.ts",
"./contracts/frame": "./src/contracts/frame.ts",
"./contracts/frame-io": "./src/contracts/frame-io.ts",
"./core/error": "./src/core/error.ts",
"./contracts/error": "./src/contracts/error.ts",
"./contracts/types": "./src/contracts/types.ts",
"./contracts/permission": "./src/contracts/permission.ts",
"./contracts/profile": "./src/contracts/profile.ts",
"./contracts/hooks": "./src/contracts/hooks.ts",
"./contracts/session": "./src/contracts/session.ts",
"./contracts/provider": "./src/contracts/provider.ts",
"./contracts/mcp": "./src/contracts/mcp.ts",
"./contracts/automation": "./src/contracts/automation.ts",
"./contracts/skill": "./src/contracts/skill.ts",
"./contracts/tool": "./src/contracts/tool.ts",
"./checkpoint/types": "./src/checkpoint/types.ts",
Expand All @@ -36,7 +38,9 @@
"cron": "^3.5.0",
"effect": "^3.21.2",
"hono": "^4.12.19",
"zod": "^4.4.3",
"@codingcode/infra": "workspace:*"
"pino": "^9.6.0",
"pino-pretty": "^13.0.0",
"yaml": "^2.9.0",
"zod": "^4.4.3"
}
}
Loading
Loading