skyloom 1.14.6 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +2 -2
- package/.github/workflows/publish.yml +74 -0
- package/CONVERSION_PLAN.md +191 -191
- package/README.md +523 -220
- package/config/default.yaml +46 -43
- package/config/models.yaml +928 -155
- package/config/providers.yaml +109 -6
- package/dist/agents/snow.d.ts +2 -0
- package/dist/agents/snow.d.ts.map +1 -1
- package/dist/agents/snow.js +36 -5
- package/dist/agents/snow.js.map +1 -1
- package/dist/cli/loom_chat.d.ts.map +1 -1
- package/dist/cli/loom_chat.js +207 -1
- package/dist/cli/loom_chat.js.map +1 -1
- package/dist/cli/main.js +190 -40
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/tui.d.ts.map +1 -1
- package/dist/cli/tui.js +6 -31
- package/dist/cli/tui.js.map +1 -1
- package/dist/core/agent.d.ts +6 -4
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +61 -20
- package/dist/core/agent.js.map +1 -1
- package/dist/core/catalog.d.ts.map +1 -1
- package/dist/core/catalog.js +30 -9
- package/dist/core/catalog.js.map +1 -1
- package/dist/core/commands.d.ts +110 -0
- package/dist/core/commands.d.ts.map +1 -0
- package/dist/core/commands.js +633 -0
- package/dist/core/commands.js.map +1 -0
- package/dist/core/concurrency.d.ts +38 -0
- package/dist/core/concurrency.d.ts.map +1 -0
- package/dist/core/concurrency.js +65 -0
- package/dist/core/concurrency.js.map +1 -0
- package/dist/core/factory.js +16 -16
- package/dist/core/file_checkpoint.d.ts +9 -0
- package/dist/core/file_checkpoint.d.ts.map +1 -1
- package/dist/core/file_checkpoint.js +33 -1
- package/dist/core/file_checkpoint.js.map +1 -1
- package/dist/core/llm.d.ts.map +1 -1
- package/dist/core/llm.js +66 -13
- package/dist/core/llm.js.map +1 -1
- package/dist/core/memory.js +51 -51
- package/dist/core/schemas.d.ts +16 -0
- package/dist/core/schemas.d.ts.map +1 -1
- package/dist/core/schemas.js +32 -0
- package/dist/core/schemas.js.map +1 -1
- package/dist/core/security.d.ts.map +1 -1
- package/dist/core/security.js +27 -0
- package/dist/core/security.js.map +1 -1
- package/dist/core/skymd.js +14 -14
- package/dist/core/trace.d.ts +105 -0
- package/dist/core/trace.d.ts.map +1 -0
- package/dist/core/trace.js +213 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/tools/builtin.d.ts +2 -6
- package/dist/tools/builtin.d.ts.map +1 -1
- package/dist/tools/builtin.js +180 -125
- package/dist/tools/builtin.js.map +1 -1
- package/dist/tools/extra.d.ts +13 -0
- package/dist/tools/extra.d.ts.map +1 -0
- package/dist/tools/extra.js +827 -0
- package/dist/tools/extra.js.map +1 -0
- package/dist/tools/guards.d.ts +12 -0
- package/dist/tools/guards.d.ts.map +1 -0
- package/dist/tools/guards.js +143 -0
- package/dist/tools/guards.js.map +1 -0
- package/dist/tools/model_tool.d.ts.map +1 -1
- package/dist/tools/model_tool.js +24 -4
- package/dist/tools/model_tool.js.map +1 -1
- package/dist/web/markdown.d.ts +32 -0
- package/dist/web/markdown.d.ts.map +1 -0
- package/dist/web/markdown.js +202 -0
- package/dist/web/markdown.js.map +1 -0
- package/dist/web/server.d.ts +4 -0
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js +14 -582
- package/dist/web/server.js.map +1 -1
- package/dist/web/ui.d.ts +31 -0
- package/dist/web/ui.d.ts.map +1 -0
- package/dist/web/ui.js +1009 -0
- package/dist/web/ui.js.map +1 -0
- package/docs/AESTHETIC_DESIGN.md +152 -152
- package/docs/OPTIMIZATION_PLAN.md +178 -178
- package/package.json +68 -68
- package/src/agents/snow.ts +38 -5
- package/src/cli/commands_md.ts +112 -112
- package/src/cli/input_macros.ts +83 -83
- package/src/cli/loom.ts +1041 -1041
- package/src/cli/loom_chat.ts +772 -603
- package/src/cli/main.ts +853 -723
- package/src/cli/tui.ts +264 -289
- package/src/core/agent/guard.ts +133 -133
- package/src/core/agent/task.ts +100 -100
- package/src/core/agent.ts +1630 -1590
- package/src/core/agent_helpers.ts +500 -500
- package/src/core/bus.ts +221 -221
- package/src/core/cache.ts +153 -153
- package/src/core/catalog.ts +199 -178
- package/src/core/circuit_breaker.ts +119 -119
- package/src/core/commands.ts +704 -0
- package/src/core/concurrency.ts +73 -0
- package/src/core/config.ts +365 -365
- package/src/core/constants.ts +95 -95
- package/src/core/factory.ts +656 -656
- package/src/core/file_checkpoint.ts +163 -136
- package/src/core/hooks.ts +126 -126
- package/src/core/llm.ts +972 -915
- package/src/core/logger.ts +143 -143
- package/src/core/mcp.ts +1001 -1001
- package/src/core/memory.ts +1201 -1201
- package/src/core/middleware.ts +350 -350
- package/src/core/model_config.ts +159 -159
- package/src/core/pipelines.ts +424 -424
- package/src/core/schemas.ts +319 -282
- package/src/core/security.ts +27 -0
- package/src/core/semantic.ts +211 -211
- package/src/core/skill.ts +384 -384
- package/src/core/skymd.ts +143 -143
- package/src/core/theme.ts +65 -65
- package/src/core/tool.ts +457 -457
- package/src/core/trace.ts +236 -0
- package/src/core/verify.ts +71 -71
- package/src/plugins/loader.ts +91 -91
- package/src/skills/loader.ts +75 -75
- package/src/tools/builtin.ts +571 -493
- package/src/tools/computer.ts +279 -279
- package/src/tools/extra.ts +662 -0
- package/src/tools/guards.ts +82 -0
- package/src/tools/model_tool.ts +93 -74
- package/src/tools/todo.ts +76 -76
- package/src/web/markdown.ts +193 -0
- package/src/web/server.ts +117 -693
- package/src/web/ui.ts +949 -0
- package/tests/agent.test.ts +211 -159
- package/tests/agent_helpers.test.ts +48 -48
- package/tests/catalog.test.ts +86 -86
- package/tests/checkpoint_commands.test.ts +124 -124
- package/tests/claude_compat.test.ts +110 -110
- package/tests/commands.test.ts +103 -0
- package/tests/concurrency.test.ts +102 -0
- package/tests/config.test.ts +41 -41
- package/tests/extra_tools.test.ts +212 -0
- package/tests/fence_plugin.test.ts +52 -52
- package/tests/guard.test.ts +75 -75
- package/tests/loom.test.ts +337 -337
- package/tests/memory.test.ts +170 -170
- package/tests/model_config.test.ts +109 -109
- package/tests/skymd.test.ts +146 -146
- package/tests/ssrf.test.ts +38 -38
- package/tests/structured_retry.test.ts +87 -0
- package/tests/task.test.ts +60 -60
- package/tests/todo_toolstats.test.ts +94 -94
- package/tests/trace.test.ts +128 -0
- package/tests/tui.test.ts +67 -67
- package/tests/web.test.ts +169 -0
- package/tsconfig.json +38 -38
package/.github/workflows/ci.yml
CHANGED
|
@@ -15,10 +15,10 @@ jobs:
|
|
|
15
15
|
node-version: [18, 20, 22]
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
19
|
|
|
20
20
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
-
uses: actions/setup-node@
|
|
21
|
+
uses: actions/setup-node@v5
|
|
22
22
|
with:
|
|
23
23
|
node-version: ${{ matrix.node-version }}
|
|
24
24
|
cache: 'npm'
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
# Continuous delivery from master: every push runs the workflow, the
|
|
8
|
+
# version check below makes it a no-op unless package.json declares a
|
|
9
|
+
# version that is not yet on npm. Needed because some environments
|
|
10
|
+
# (remote agent sessions) can push branches but not tags, and the
|
|
11
|
+
# API token cannot dispatch workflows either.
|
|
12
|
+
branches:
|
|
13
|
+
- master
|
|
14
|
+
# Manual trigger: publishes whatever version master's package.json declares,
|
|
15
|
+
# then creates the matching v* tag. Needed because some environments (e.g.
|
|
16
|
+
# remote agent sessions) can push branches but not tags.
|
|
17
|
+
workflow_dispatch: {}
|
|
18
|
+
|
|
19
|
+
permissions:
|
|
20
|
+
id-token: write
|
|
21
|
+
contents: write
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
publish:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
permissions:
|
|
27
|
+
id-token: write
|
|
28
|
+
contents: write
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v5
|
|
31
|
+
|
|
32
|
+
- uses: actions/setup-node@v5
|
|
33
|
+
with:
|
|
34
|
+
node-version: '20'
|
|
35
|
+
registry-url: 'https://registry.npmjs.org'
|
|
36
|
+
|
|
37
|
+
# OIDC trusted publishing requires npm >= 11.5.1; Node 20 bundles npm 10,
|
|
38
|
+
# whose unauthenticated PUT is rejected by the registry with 404 — the
|
|
39
|
+
# reason every previous publish run (v1.14.8, v1.14.9) failed.
|
|
40
|
+
- run: npm install -g npm@^11.5.1
|
|
41
|
+
- run: npm --version
|
|
42
|
+
|
|
43
|
+
- run: npm ci
|
|
44
|
+
- run: npm run build
|
|
45
|
+
|
|
46
|
+
# Refuse to republish an existing version (idempotent dispatches).
|
|
47
|
+
- name: Skip if version already published
|
|
48
|
+
id: check
|
|
49
|
+
run: |
|
|
50
|
+
V=$(node -p "require('./package.json').version")
|
|
51
|
+
echo "version=$V" >> "$GITHUB_OUTPUT"
|
|
52
|
+
if npm view "skyloom@$V" version >/dev/null 2>&1; then
|
|
53
|
+
echo "already=true" >> "$GITHUB_OUTPUT"
|
|
54
|
+
echo "skyloom@$V already on npm — skipping publish"
|
|
55
|
+
else
|
|
56
|
+
echo "already=false" >> "$GITHUB_OUTPUT"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
- name: Publish
|
|
60
|
+
if: steps.check.outputs.already == 'false'
|
|
61
|
+
run: npm publish --access public
|
|
62
|
+
|
|
63
|
+
# When publishing from a branch (master push or manual dispatch), create
|
|
64
|
+
# the release tag the environment couldn't push. Tag pushes skip this.
|
|
65
|
+
- name: Tag release
|
|
66
|
+
if: github.ref_type == 'branch'
|
|
67
|
+
run: |
|
|
68
|
+
V="v${{ steps.check.outputs.version }}"
|
|
69
|
+
if git ls-remote --exit-code origin "refs/tags/$V" >/dev/null 2>&1; then
|
|
70
|
+
echo "$V already exists"
|
|
71
|
+
else
|
|
72
|
+
git tag "$V"
|
|
73
|
+
git push origin "$V"
|
|
74
|
+
fi
|
package/CONVERSION_PLAN.md
CHANGED
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
# Skyloom Python → TypeScript 完整转换计划
|
|
2
|
-
|
|
3
|
-
## 已完成的核心模块(✅)
|
|
4
|
-
|
|
5
|
-
### 基础配置层
|
|
6
|
-
- ✅ `constants.ts` - 所有常量定义(VALID_AGENTS, TASK_DONE_SENTINEL, etc)
|
|
7
|
-
- ✅ `schemas.ts` - LLM 响应验证和数据结构(TaskPlanSchema, FactSchema)
|
|
8
|
-
- ✅ `logger.ts` - 结构化日志系统(JSON lines format)
|
|
9
|
-
- ✅ `config.ts` - 配置管理(YAML加载、合并、提供者目录)
|
|
10
|
-
|
|
11
|
-
### 工具和中间件层
|
|
12
|
-
- ✅ `tool.ts` - 工具注册和执行框架(缓存、重试、参数验证)
|
|
13
|
-
- ✅ `circuit_breaker.ts` - 熔断器模式(故障容错)
|
|
14
|
-
|
|
15
|
-
## 待转换的模块
|
|
16
|
-
|
|
17
|
-
### Phase 1: 核心基础设施(Core Infrastructure)
|
|
18
|
-
- [ ] `memory.ts` - 三层内存系统(短期、工作、长期)+ SQLite 持久化
|
|
19
|
-
- [ ] `cache.ts` - LLM 响应缓存
|
|
20
|
-
- [ ] `middleware.ts` - 中间件链(前处理、后处理)
|
|
21
|
-
- [ ] `bus.ts` - 事件总线系统
|
|
22
|
-
- [ ] `pipelines.ts` - DAG 管道编排
|
|
23
|
-
|
|
24
|
-
### Phase 2: LLM 和 API 集成
|
|
25
|
-
- [ ] `llm.ts` - LiteLLM 抽象(流式、重试、成本追踪)
|
|
26
|
-
- [ ] `mcp.ts` - 模型上下文协议集成
|
|
27
|
-
- [ ] `semantic.ts` - 语义搜索和嵌入
|
|
28
|
-
|
|
29
|
-
### Phase 3: Agent 核心
|
|
30
|
-
- [ ] `agent.ts` - BaseAgent 类(message management, tool execution)
|
|
31
|
-
- [ ] `factory.ts` - Agent 工厂模式
|
|
32
|
-
- [ ] `router.ts` - 智能路由系统(direct/single/orchestrate 分类)
|
|
33
|
-
|
|
34
|
-
### Phase 4: 六个 Agent 实现
|
|
35
|
-
- [ ] `agents/fog.ts` - 研究 Agent
|
|
36
|
-
- [ ] `agents/rain.ts` - 代码生成 Agent
|
|
37
|
-
- [ ] `agents/frost.ts` - 代码审查 Agent
|
|
38
|
-
- [ ] `agents/snow.ts` - 编排 Agent
|
|
39
|
-
- [ ] `agents/dew.ts` - DevOps Agent
|
|
40
|
-
- [ ] `agents/fair.ts` - 情感陪伴 Agent
|
|
41
|
-
|
|
42
|
-
### Phase 5: 技能系统
|
|
43
|
-
- [ ] `skill.ts` - 技能基类和注册表
|
|
44
|
-
- [ ] `skills/loader.ts` - 技能动态加载
|
|
45
|
-
- [ ] 40+ 内置技能转换
|
|
46
|
-
|
|
47
|
-
### Phase 6: 工具系统
|
|
48
|
-
- [ ] `tools/builtin.ts` - 内置工具(文件、shell、HTTP、git)
|
|
49
|
-
- [ ] `tools/delegate.ts` - MCP 工具委派
|
|
50
|
-
|
|
51
|
-
### Phase 7: CLI 和 Web
|
|
52
|
-
- [ ] `cli/main.ts` - 命令行入口(Commander.js)
|
|
53
|
-
- [ ] `cli/mode.ts` - 交互模式管理
|
|
54
|
-
- [ ] CLI 子命令(chat, task, web, setup)
|
|
55
|
-
- [ ] `web/server.ts` - Express/Fastify 服务器
|
|
56
|
-
- [ ] `web/tts.ts` - 文字转语音集成
|
|
57
|
-
|
|
58
|
-
### Phase 8: 测试
|
|
59
|
-
- [ ] 所有 52 个测试文件转换为 Vitest
|
|
60
|
-
|
|
61
|
-
## 转换规范
|
|
62
|
-
|
|
63
|
-
### 文件映射
|
|
64
|
-
|
|
65
|
-
| Python | TypeScript | 备注 |
|
|
66
|
-
|--------|-----------|-----|
|
|
67
|
-
| `asyncio` | `Promise / async-await` | 原生支持 |
|
|
68
|
-
| `dataclasses` | `interfaces + types` | TypeScript types |
|
|
69
|
-
| `pathlib.Path` | `path` module | Node.js 标准 |
|
|
70
|
-
| `aiosqlite` | `sqlite / sqlite3` | Node.js SQLite |
|
|
71
|
-
| `typer` | `commander` | CLI 框架 |
|
|
72
|
-
| `rich` | `chalk` + `enquirer` | TUI 输出 |
|
|
73
|
-
| `pyyaml` | `yaml` npm package | YAML 处理 |
|
|
74
|
-
| `litellm` | `openai` + providers | LLM SDK |
|
|
75
|
-
| `httpx` | `axios` / `got` | HTTP 客户端 |
|
|
76
|
-
| `pytest` | `vitest` | 测试框架 |
|
|
77
|
-
|
|
78
|
-
### 关键转换模式
|
|
79
|
-
|
|
80
|
-
#### 1. Python Dataclass → TypeScript Interface + Class
|
|
81
|
-
```python
|
|
82
|
-
@dataclass
|
|
83
|
-
class Message:
|
|
84
|
-
role: str
|
|
85
|
-
content: str
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
```typescript
|
|
89
|
-
interface Message {
|
|
90
|
-
role: string;
|
|
91
|
-
content: string;
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
#### 2. Python Dict/List 操作 → TypeScript Map/Set/Array
|
|
96
|
-
```python
|
|
97
|
-
data: dict[str, list[str]] = {}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
```typescript
|
|
101
|
-
data: Map<string, string[]> = new Map();
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
#### 3. Python 异步 → TypeScript Async/Await
|
|
105
|
-
```python
|
|
106
|
-
async def fetch():
|
|
107
|
-
result = await client.get()
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
async function fetch() {
|
|
112
|
-
const result = await client.get();
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
#### 4. Python 类型提示 → TypeScript 类型注解
|
|
117
|
-
```python
|
|
118
|
-
def execute(tool: str, params: dict) -> str:
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
function execute(tool: string, params: Record<string, unknown>): string
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
## 命名规范(保持一致)
|
|
126
|
-
|
|
127
|
-
- Agent 名称:`fog`, `rain`, `frost`, `snow`, `dew`, `fair`(全部小写)
|
|
128
|
-
- 文件名:camelCase(`agentFactory.ts` 而非 `agent_factory.ts`)
|
|
129
|
-
- 变量名:camelCase(`maxRetries` 而非 `max_retries`)
|
|
130
|
-
- 常量:UPPER_SNAKE_CASE(`DEFAULT_TOOL_TIMEOUT`)
|
|
131
|
-
- 接口:PascalCase(`ToolRegistry`, `Message`, `AgentConfig`)
|
|
132
|
-
|
|
133
|
-
## 依赖管理
|
|
134
|
-
|
|
135
|
-
### 核心依赖映射
|
|
136
|
-
| 功能 | Python | TypeScript |
|
|
137
|
-
|------|--------|-----------|
|
|
138
|
-
| CLI | typer | commander |
|
|
139
|
-
| TUI | rich | chalk + enquirer + ora |
|
|
140
|
-
| LLM | litellm | openai + axios |
|
|
141
|
-
| Database | aiosqlite | sqlite / better-sqlite3 |
|
|
142
|
-
| YAML | pyyaml | yaml |
|
|
143
|
-
| HTTP | httpx | axios / got |
|
|
144
|
-
| 测试 | pytest | vitest |
|
|
145
|
-
| 类型检查 | mypy | typescript |
|
|
146
|
-
|
|
147
|
-
### 质量保证工具
|
|
148
|
-
- **Linter**: eslint + @typescript-eslint
|
|
149
|
-
- **格式化**: prettier
|
|
150
|
-
- **类型**: TypeScript strict mode
|
|
151
|
-
- **测试**: vitest + coverage
|
|
152
|
-
|
|
153
|
-
## 大小估计
|
|
154
|
-
|
|
155
|
-
| 层级 | 文件数 | LOC | 转换难度 |
|
|
156
|
-
|-----|--------|-----|---------|
|
|
157
|
-
| Core | 8 | 2500 | ⭐⭐ |
|
|
158
|
-
| Memory | 1 | 800 | ⭐⭐⭐ |
|
|
159
|
-
| Agents | 7 | 2000 | ⭐⭐ |
|
|
160
|
-
| Skills | 40+ | 8000 | ⭐ |
|
|
161
|
-
| Tools | 2 | 2000 | ⭐⭐ |
|
|
162
|
-
| CLI/Web | 10 | 3000 | ⭐⭐⭐ |
|
|
163
|
-
| Tests | 52 | 10000 | ⭐⭐ |
|
|
164
|
-
| **总计** | **120+** | **28000** | - |
|
|
165
|
-
|
|
166
|
-
## 质量检查清单
|
|
167
|
-
|
|
168
|
-
- [ ] 所有 TypeScript 文件通过 tsc --noEmit
|
|
169
|
-
- [ ] 所有文件通过 eslint
|
|
170
|
-
- [ ] 100% 类型覆盖率(no `any` 除非必要)
|
|
171
|
-
- [ ] 所有测试通过(npm test)
|
|
172
|
-
- [ ] CLI 命令可执行(npm start)
|
|
173
|
-
- [ ] Web 服务启动正常
|
|
174
|
-
- [ ] 配置加载和合并正确
|
|
175
|
-
- [ ] 内存系统持久化正确
|
|
176
|
-
- [ ] Agent 通信链正常
|
|
177
|
-
- [ ] 工具执行链正常
|
|
178
|
-
|
|
179
|
-
## 转换步骤
|
|
180
|
-
|
|
181
|
-
1. ✅ 基础配置(constants, schemas, logger, config)
|
|
182
|
-
2. ✅ 工具框架(tool, circuit_breaker)
|
|
183
|
-
3. ⏳ 转换其他核心模块(使用 agent 并行)
|
|
184
|
-
4. ⏳ 转换 Agent 系统
|
|
185
|
-
5. ⏳ 转换 CLI/Web 接口
|
|
186
|
-
6. ⏳ 转换所有测试
|
|
187
|
-
7. ⏳ 集成测试和优化
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
|
|
191
|
-
**目标**: 完整的功能对等、无任何功能丢失、所有业务逻辑保持一致的 TypeScript 版本。
|
|
1
|
+
# Skyloom Python → TypeScript 完整转换计划
|
|
2
|
+
|
|
3
|
+
## 已完成的核心模块(✅)
|
|
4
|
+
|
|
5
|
+
### 基础配置层
|
|
6
|
+
- ✅ `constants.ts` - 所有常量定义(VALID_AGENTS, TASK_DONE_SENTINEL, etc)
|
|
7
|
+
- ✅ `schemas.ts` - LLM 响应验证和数据结构(TaskPlanSchema, FactSchema)
|
|
8
|
+
- ✅ `logger.ts` - 结构化日志系统(JSON lines format)
|
|
9
|
+
- ✅ `config.ts` - 配置管理(YAML加载、合并、提供者目录)
|
|
10
|
+
|
|
11
|
+
### 工具和中间件层
|
|
12
|
+
- ✅ `tool.ts` - 工具注册和执行框架(缓存、重试、参数验证)
|
|
13
|
+
- ✅ `circuit_breaker.ts` - 熔断器模式(故障容错)
|
|
14
|
+
|
|
15
|
+
## 待转换的模块
|
|
16
|
+
|
|
17
|
+
### Phase 1: 核心基础设施(Core Infrastructure)
|
|
18
|
+
- [ ] `memory.ts` - 三层内存系统(短期、工作、长期)+ SQLite 持久化
|
|
19
|
+
- [ ] `cache.ts` - LLM 响应缓存
|
|
20
|
+
- [ ] `middleware.ts` - 中间件链(前处理、后处理)
|
|
21
|
+
- [ ] `bus.ts` - 事件总线系统
|
|
22
|
+
- [ ] `pipelines.ts` - DAG 管道编排
|
|
23
|
+
|
|
24
|
+
### Phase 2: LLM 和 API 集成
|
|
25
|
+
- [ ] `llm.ts` - LiteLLM 抽象(流式、重试、成本追踪)
|
|
26
|
+
- [ ] `mcp.ts` - 模型上下文协议集成
|
|
27
|
+
- [ ] `semantic.ts` - 语义搜索和嵌入
|
|
28
|
+
|
|
29
|
+
### Phase 3: Agent 核心
|
|
30
|
+
- [ ] `agent.ts` - BaseAgent 类(message management, tool execution)
|
|
31
|
+
- [ ] `factory.ts` - Agent 工厂模式
|
|
32
|
+
- [ ] `router.ts` - 智能路由系统(direct/single/orchestrate 分类)
|
|
33
|
+
|
|
34
|
+
### Phase 4: 六个 Agent 实现
|
|
35
|
+
- [ ] `agents/fog.ts` - 研究 Agent
|
|
36
|
+
- [ ] `agents/rain.ts` - 代码生成 Agent
|
|
37
|
+
- [ ] `agents/frost.ts` - 代码审查 Agent
|
|
38
|
+
- [ ] `agents/snow.ts` - 编排 Agent
|
|
39
|
+
- [ ] `agents/dew.ts` - DevOps Agent
|
|
40
|
+
- [ ] `agents/fair.ts` - 情感陪伴 Agent
|
|
41
|
+
|
|
42
|
+
### Phase 5: 技能系统
|
|
43
|
+
- [ ] `skill.ts` - 技能基类和注册表
|
|
44
|
+
- [ ] `skills/loader.ts` - 技能动态加载
|
|
45
|
+
- [ ] 40+ 内置技能转换
|
|
46
|
+
|
|
47
|
+
### Phase 6: 工具系统
|
|
48
|
+
- [ ] `tools/builtin.ts` - 内置工具(文件、shell、HTTP、git)
|
|
49
|
+
- [ ] `tools/delegate.ts` - MCP 工具委派
|
|
50
|
+
|
|
51
|
+
### Phase 7: CLI 和 Web
|
|
52
|
+
- [ ] `cli/main.ts` - 命令行入口(Commander.js)
|
|
53
|
+
- [ ] `cli/mode.ts` - 交互模式管理
|
|
54
|
+
- [ ] CLI 子命令(chat, task, web, setup)
|
|
55
|
+
- [ ] `web/server.ts` - Express/Fastify 服务器
|
|
56
|
+
- [ ] `web/tts.ts` - 文字转语音集成
|
|
57
|
+
|
|
58
|
+
### Phase 8: 测试
|
|
59
|
+
- [ ] 所有 52 个测试文件转换为 Vitest
|
|
60
|
+
|
|
61
|
+
## 转换规范
|
|
62
|
+
|
|
63
|
+
### 文件映射
|
|
64
|
+
|
|
65
|
+
| Python | TypeScript | 备注 |
|
|
66
|
+
|--------|-----------|-----|
|
|
67
|
+
| `asyncio` | `Promise / async-await` | 原生支持 |
|
|
68
|
+
| `dataclasses` | `interfaces + types` | TypeScript types |
|
|
69
|
+
| `pathlib.Path` | `path` module | Node.js 标准 |
|
|
70
|
+
| `aiosqlite` | `sqlite / sqlite3` | Node.js SQLite |
|
|
71
|
+
| `typer` | `commander` | CLI 框架 |
|
|
72
|
+
| `rich` | `chalk` + `enquirer` | TUI 输出 |
|
|
73
|
+
| `pyyaml` | `yaml` npm package | YAML 处理 |
|
|
74
|
+
| `litellm` | `openai` + providers | LLM SDK |
|
|
75
|
+
| `httpx` | `axios` / `got` | HTTP 客户端 |
|
|
76
|
+
| `pytest` | `vitest` | 测试框架 |
|
|
77
|
+
|
|
78
|
+
### 关键转换模式
|
|
79
|
+
|
|
80
|
+
#### 1. Python Dataclass → TypeScript Interface + Class
|
|
81
|
+
```python
|
|
82
|
+
@dataclass
|
|
83
|
+
class Message:
|
|
84
|
+
role: str
|
|
85
|
+
content: str
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
interface Message {
|
|
90
|
+
role: string;
|
|
91
|
+
content: string;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### 2. Python Dict/List 操作 → TypeScript Map/Set/Array
|
|
96
|
+
```python
|
|
97
|
+
data: dict[str, list[str]] = {}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
data: Map<string, string[]> = new Map();
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### 3. Python 异步 → TypeScript Async/Await
|
|
105
|
+
```python
|
|
106
|
+
async def fetch():
|
|
107
|
+
result = await client.get()
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
async function fetch() {
|
|
112
|
+
const result = await client.get();
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### 4. Python 类型提示 → TypeScript 类型注解
|
|
117
|
+
```python
|
|
118
|
+
def execute(tool: str, params: dict) -> str:
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
function execute(tool: string, params: Record<string, unknown>): string
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 命名规范(保持一致)
|
|
126
|
+
|
|
127
|
+
- Agent 名称:`fog`, `rain`, `frost`, `snow`, `dew`, `fair`(全部小写)
|
|
128
|
+
- 文件名:camelCase(`agentFactory.ts` 而非 `agent_factory.ts`)
|
|
129
|
+
- 变量名:camelCase(`maxRetries` 而非 `max_retries`)
|
|
130
|
+
- 常量:UPPER_SNAKE_CASE(`DEFAULT_TOOL_TIMEOUT`)
|
|
131
|
+
- 接口:PascalCase(`ToolRegistry`, `Message`, `AgentConfig`)
|
|
132
|
+
|
|
133
|
+
## 依赖管理
|
|
134
|
+
|
|
135
|
+
### 核心依赖映射
|
|
136
|
+
| 功能 | Python | TypeScript |
|
|
137
|
+
|------|--------|-----------|
|
|
138
|
+
| CLI | typer | commander |
|
|
139
|
+
| TUI | rich | chalk + enquirer + ora |
|
|
140
|
+
| LLM | litellm | openai + axios |
|
|
141
|
+
| Database | aiosqlite | sqlite / better-sqlite3 |
|
|
142
|
+
| YAML | pyyaml | yaml |
|
|
143
|
+
| HTTP | httpx | axios / got |
|
|
144
|
+
| 测试 | pytest | vitest |
|
|
145
|
+
| 类型检查 | mypy | typescript |
|
|
146
|
+
|
|
147
|
+
### 质量保证工具
|
|
148
|
+
- **Linter**: eslint + @typescript-eslint
|
|
149
|
+
- **格式化**: prettier
|
|
150
|
+
- **类型**: TypeScript strict mode
|
|
151
|
+
- **测试**: vitest + coverage
|
|
152
|
+
|
|
153
|
+
## 大小估计
|
|
154
|
+
|
|
155
|
+
| 层级 | 文件数 | LOC | 转换难度 |
|
|
156
|
+
|-----|--------|-----|---------|
|
|
157
|
+
| Core | 8 | 2500 | ⭐⭐ |
|
|
158
|
+
| Memory | 1 | 800 | ⭐⭐⭐ |
|
|
159
|
+
| Agents | 7 | 2000 | ⭐⭐ |
|
|
160
|
+
| Skills | 40+ | 8000 | ⭐ |
|
|
161
|
+
| Tools | 2 | 2000 | ⭐⭐ |
|
|
162
|
+
| CLI/Web | 10 | 3000 | ⭐⭐⭐ |
|
|
163
|
+
| Tests | 52 | 10000 | ⭐⭐ |
|
|
164
|
+
| **总计** | **120+** | **28000** | - |
|
|
165
|
+
|
|
166
|
+
## 质量检查清单
|
|
167
|
+
|
|
168
|
+
- [ ] 所有 TypeScript 文件通过 tsc --noEmit
|
|
169
|
+
- [ ] 所有文件通过 eslint
|
|
170
|
+
- [ ] 100% 类型覆盖率(no `any` 除非必要)
|
|
171
|
+
- [ ] 所有测试通过(npm test)
|
|
172
|
+
- [ ] CLI 命令可执行(npm start)
|
|
173
|
+
- [ ] Web 服务启动正常
|
|
174
|
+
- [ ] 配置加载和合并正确
|
|
175
|
+
- [ ] 内存系统持久化正确
|
|
176
|
+
- [ ] Agent 通信链正常
|
|
177
|
+
- [ ] 工具执行链正常
|
|
178
|
+
|
|
179
|
+
## 转换步骤
|
|
180
|
+
|
|
181
|
+
1. ✅ 基础配置(constants, schemas, logger, config)
|
|
182
|
+
2. ✅ 工具框架(tool, circuit_breaker)
|
|
183
|
+
3. ⏳ 转换其他核心模块(使用 agent 并行)
|
|
184
|
+
4. ⏳ 转换 Agent 系统
|
|
185
|
+
5. ⏳ 转换 CLI/Web 接口
|
|
186
|
+
6. ⏳ 转换所有测试
|
|
187
|
+
7. ⏳ 集成测试和优化
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
**目标**: 完整的功能对等、无任何功能丢失、所有业务逻辑保持一致的 TypeScript 版本。
|