Skip to content

Commit d56ac64

Browse files
committed
refactor: restructure CI workflows and rename ui package to cli
- Split CI into separate workflows: lint, test, and build - Rename packages/ui to packages/cli for clarity - Update documentation and dependencies
1 parent e1da853 commit d56ac64

33 files changed

Lines changed: 193 additions & 21 deletions

‎.github/workflows/build.yml‎

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main, dev]
9+
workflow_dispatch:
10+
11+
jobs:
12+
# 多平台二进制构建
13+
build-binary:
14+
name: Build ${{ matrix.target }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
# Linux builds
21+
- os: ubuntu-latest
22+
target: linux-x64
23+
artifact: memo-linux-x64
24+
- os: ubuntu-latest
25+
target: linux-arm64
26+
artifact: memo-linux-arm64
27+
28+
# macOS builds
29+
- os: macos-latest
30+
target: darwin-x64
31+
artifact: memo-darwin-x64
32+
- os: macos-latest
33+
target: darwin-arm64
34+
artifact: memo-darwin-arm64
35+
36+
# Windows build
37+
- os: windows-latest
38+
target: windows-x64
39+
artifact: memo-windows-x64.exe
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Setup Bun
46+
uses: oven-sh/setup-bun@v1
47+
48+
- name: Install ripgrep (Linux)
49+
if: runner.os == 'Linux'
50+
run: sudo apt-get update && sudo apt-get install -y ripgrep
51+
52+
- name: Install ripgrep (macOS)
53+
if: runner.os == 'macOS'
54+
run: brew install ripgrep
55+
56+
- name: Install ripgrep (Windows)
57+
if: runner.os == 'Windows'
58+
run: choco install ripgrep -y
59+
60+
- name: Install dependencies
61+
run: bun install
62+
63+
- name: Build binary (Unix)
64+
if: runner.os != 'Windows'
65+
run: bun build packages/cli/src/index.tsx --target=bun --compile --outfile=${{ matrix.artifact }}
66+
67+
- name: Build binary (Windows)
68+
if: runner.os == 'Windows'
69+
run: bun build packages/cli/src/index.tsx --target=bun --compile --outfile=${{ matrix.artifact }}
70+
71+
- name: Test binary (Unix)
72+
if: runner.os != 'Windows'
73+
run: ./${{ matrix.artifact }} --help
74+
75+
- name: Test binary (Windows)
76+
if: runner.os == 'Windows'
77+
run: .\${{ matrix.artifact }} --help
78+
79+
- name: Upload artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: ${{ matrix.artifact }}
83+
path: ${{ matrix.artifact }}
84+
retention-days: 7
85+
86+
# 汇总构建结果
87+
build-summary:
88+
name: Build Summary
89+
runs-on: ubuntu-latest
90+
needs: build-binary
91+
if: always()
92+
steps:
93+
- name: Check build status
94+
run: |
95+
echo "All builds completed"
96+
if [ "${{ needs.build-binary.result }}" != "success" ]; then
97+
echo "Some builds failed"
98+
exit 1
99+
fi
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
name: CI
1+
name: Lint
22

33
on:
44
push:
55
branches: ['**']
66
pull_request:
77
branches: ['**']
8+
workflow_dispatch:
89

910
jobs:
10-
test:
11+
lint:
12+
name: Code Quality Check
1113
runs-on: ubuntu-latest
1214
steps:
1315
- name: Checkout
@@ -16,11 +18,8 @@ jobs:
1618
- name: Setup Bun
1719
uses: oven-sh/setup-bun@v1
1820

19-
- name: Install ripgrep (for grep tool)
20-
run: sudo apt-get update && sudo apt-get install -y ripgrep
21-
2221
- name: Install dependencies
2322
run: bun install
2423

25-
- name: Run tests
26-
run: bun test
24+
- name: Check code formatting
25+
run: bun run format:check

‎.github/workflows/test.yml‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
workflow_dispatch:
9+
10+
jobs:
11+
# 测试各个包 (Linux only, 快速反馈)
12+
test-packages:
13+
name: Test @memo/${{ matrix.package }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
package: [core, tools, cli]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Bun
24+
uses: oven-sh/setup-bun@v1
25+
26+
- name: Install ripgrep
27+
run: sudo apt-get update && sudo apt-get install -y ripgrep
28+
29+
- name: Install dependencies
30+
run: bun install
31+
32+
- name: Run tests
33+
run: bun run test:${{ matrix.package }}
34+
35+
# 多平台集成测试
36+
test-integration:
37+
name: Integration (${{ matrix.os }})
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
os: [ubuntu-latest, macos-latest, windows-latest]
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Bun
48+
uses: oven-sh/setup-bun@v1
49+
50+
- name: Install ripgrep (Linux)
51+
if: runner.os == 'Linux'
52+
run: sudo apt-get update && sudo apt-get install -y ripgrep
53+
54+
- name: Install ripgrep (macOS)
55+
if: runner.os == 'macOS'
56+
run: brew install ripgrep
57+
58+
- name: Install ripgrep (Windows)
59+
if: runner.os == 'Windows'
60+
run: choco install ripgrep -y
61+
62+
- name: Install dependencies
63+
run: bun install
64+
65+
- name: Run all tests
66+
run: bun run test:all
67+
68+
- name: Test build
69+
run: bun run build

‎CLAUDE.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ memo-cli 是基于 Bun + TypeScript 的终端 ReAct Agent(monorepo 结构,~2
2121
- 基于 MCP 协议,Zod 验证输入
2222
- 统一导出为 `TOOLKIT`
2323

24-
- **packages/ui** (~170 行):CLI 交互层(REPL + `--once` 模式)
24+
- **packages/cli** (~170 行):CLI 交互层(REPL + `--once` 模式)
2525

2626
- **docs/**:架构文档(core.md、config-storage.md、tools/\*.md)
2727

@@ -105,7 +105,7 @@ bun run format # 代码格式化
105105
bun run format:check # 检查格式
106106

107107
# 调试
108-
bun run packages/ui/src/index.tsx "问题"
108+
bun run packages/cli/src/index.tsx "问题"
109109
```
110110

111111
**环境变量**:
@@ -168,7 +168,7 @@ main() → parseArgs() → ensureProviderConfig()
168168

169169
## 关键文件
170170

171-
- `packages/ui/src/index.tsx` - 入口
171+
- `packages/cli/src/index.tsx` - 入口
172172
- `packages/core/src/runtime/session.ts` - ReAct 核心
173173
- `packages/core/src/utils/utils.ts` - JSON 解析
174174
- `packages/core/src/config/config.ts` - 配置管理

‎bun.lock‎

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/future-plan.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ memo-cli 是一个基于 Bun + TypeScript 的 ReAct Agent CLI 工具,具有以
1414

1515
- `packages/core`:配置、运行时(Session/Turn)、LLM 适配、工具集装配
1616
- `packages/tools`:内置工具实现与测试
17-
- `packages/ui`:CLI 入口,组装 Core + Tools
17+
- `packages/cli`:CLI 入口,组装 Core + Tools
1818
- `docs/`:架构与设计文档
1919

2020
## 2. 市场竞品对比

‎docs/multi-turn.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## 背景与痛点
66

7-
- 当前 `packages/ui/src/index.tsx` 只接受一次问题,调用 `runAgent` 后直接退出,无法继续追问或补充上下文。
7+
- 当前 `packages/cli/src/index.tsx` 只接受一次问题,调用 `runAgent` 后直接退出,无法继续追问或补充上下文。
88
- 日志仅有 `history.xml`(旧方案)时无法按消息维度索引/分析;现统一写 JSONL。
99
- 缺少 Session/Turn 概念,无法区分同一进程内的多轮、或复盘某一轮的工具轨迹。
1010

@@ -31,7 +31,7 @@
3131
## 运行模式与 CLI 行为
3232

3333
- **交互模式(默认)**:
34-
- `bun start` 或 `bun run packages/ui/src/index.tsx` 启动 Session,打印 `sessionId`。
34+
- `bun start` 或 `bun run packages/cli/src/index.tsx` 启动 Session,打印 `sessionId`。
3535
- 可选第一个问题来自 argv,其余问题从 stdin 读取;支持 `/exit`、`/help` 之类的指令退出或查看状态。
3636
- 每个 Turn 结束后继续等待输入,直到用户退出或遇到致命错误。
3737
- **一次性模式(`--once`)**:

‎package.json‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
"type": "module",
44
"private": true,
55
"scripts": {
6-
"start": "bun run packages/ui/src/index.tsx",
7-
"build": "bun build packages/ui/src/index.tsx --target bun --outdir dist --minify",
8-
"build:binary": "bun build packages/ui/src/index.tsx --target=bun --compile --outfile=memo",
6+
"start": "bun run packages/cli/src/index.tsx",
7+
"build": "bun build packages/cli/src/index.tsx --target bun --outdir dist --minify",
8+
"build:binary": "bun build packages/cli/src/index.tsx --target=bun --compile --outfile=memo",
99
"format": "bunx prettier --write .",
10-
"format:check": "bunx prettier --check ."
10+
"format:check": "bunx prettier --check .",
11+
"test": "bun test",
12+
"test:core": "cd packages/core && bun test",
13+
"test:tools": "cd packages/tools && bun test",
14+
"test:cli": "cd packages/cli && bun test",
15+
"test:all": "bun run test:core && bun run test:tools && bun run test:cli"
1116
},
1217
"workspaces": [
1318
"packages/*"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@memo/ui",
2+
"name": "@memo/cli",
33
"type": "module",
44
"module": "src/index.tsx",
55
"private": true,

0 commit comments

Comments
 (0)