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
15 changes: 2 additions & 13 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to gh-pages
name: Deploy docs to gh-pages

on:
push:
Expand All @@ -14,21 +14,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.11

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build client
run: bun run build:client

- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: packages/client/dist
publish_dir: docs
publish_branch: gh-pages
force_orphan: true
15 changes: 2 additions & 13 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy Client to GitHub Pages
name: Deploy Docs to GitHub Pages

on:
push:
Expand All @@ -19,21 +19,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.11

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Build client
run: bun run build:client

- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: packages/client/dist
publish_dir: docs
publish_branch: gh-pages
force_orphan: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ bundle.*
docs/*
!docs/call-code-architecture.html
!docs/call-code-architecture.png
.DS_Store # macOS
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ call-code 是一个本地运行的终端编程 Agent(CLI coding agent),基
- 本地记忆:短期记忆按任务保存,长期记忆按主题沉淀,仅在进程内使用,不写入本地 JSON。
- 上下文预算:运行时基于 token 估算对历史消息做裁剪,减少超出模型上下文的风险。
- 会话持久化:基于 Node 内置 `node:sqlite` 保存会话、条目、泳道、分支、记录、统计、事实和租约,默认写入 `.agent-sessions/sessions.db`。
- 会话展示端:`packages/client` 提供 React + Vite 静态页面,可把会话数据导出为 JSON 后部署到 GitHub Pages
- 会话客户端:`packages/client` 提供 React + Vite 会话界面,静态展示已停止,后续用于实时对话展示

## 架构

Expand Down Expand Up @@ -55,7 +55,7 @@ OpenAI-compatible LLM 模型层
<img src="docs/call-code-architecture.png" alt="call-code 架构图" width="100%" />
</p>

交互式版本见 [docs/call-code-architecture.html](docs/call-code-architecture.html),可明暗主题切换、搜索、关系高亮与节点聚焦,直接在浏览器打开。
交互式版本见 [docs/call-code-architecture.html](docs/call-code-architecture.html),可明暗主题切换、搜索、关系高亮与节点聚焦,直接在浏览器打开。`docs/` 目录会由 GitHub Actions 发布到 `gh-pages` 分支。

运行时核心流程:

Expand Down Expand Up @@ -86,8 +86,8 @@ packages/
utils/ # shell 与文本截断等工具
types/ # 领域类型
utils/ # JSON、日志工具
web/ # GitHub Pages 客户端数据导出
client/ # TypeScript + React 会话历史界面,可部署到 GitHub Pages
web/ # 会话数据导出
client/ # TypeScript + React 会话界面客户端
session-sqlite/ # 基于 node:sqlite 的会话历史与运行状态存储
tests/ # 项目统一单元测试
vitest.config.ts # Vitest 测试配置
Expand Down Expand Up @@ -136,7 +136,7 @@ bun dev
/pages 打开相关页面选择
/memory 查看 memory 概览
/status 查看当前 CLI 状态
/export 导出会话数据到 GitHub Pages 客户端
/export 导出会话数据到 JSON 文件
/mode 查看当前模式和阶段
/plan 切换到 PLAN 模式
/build 切换到 BUILD 模式
Expand Down Expand Up @@ -170,10 +170,10 @@ bun run test
# 构建 agent-core
bun run build:agent-core

# 导出会话历史到 packages/client/public/data.json
# 导出会话数据到 packages/client/public/data.json
bun run export:web

# 构建 GitHub Pages 客户端
# 构建会话客户端(本地预览用)
bun run build:client
```

Expand Down
26 changes: 2 additions & 24 deletions docs/call-code-architecture.html
Original file line number Diff line number Diff line change
Expand Up @@ -4841,7 +4841,7 @@ <h1>call-code 架构</h1>
</div>

<script id="archify-guided-views-data" type="application/json">[]</script>
<script id="archify-source-evidence-data" type="application/json">{"schemaVersion":1,"verified":true,"repository":{"url":"https://github.com/AlkaidSTART/call-code","revision":"baee5b2614b50e7d4b66eb8831db26b3914b2087","shortRevision":"baee5b2"},"referenceCount":9,"nodes":{"cli":[{"path":"source/app.tsx","label":"入口与交互界面","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/source/app.tsx"}],"core":[{"path":"packages/agent-core/src/harness/core/agent.ts","label":"规划→执行→观察","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/core/agent.ts"}],"context":[{"path":"packages/agent-core/src/harness/context/builder.ts","label":"构建上下文","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/context/builder.ts"}],"protocol":[{"path":"packages/agent-core/src/harness/protocol/parser.ts","label":"解析 action","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/protocol/parser.ts"}],"policy":[{"path":"packages/agent-core/src/harness/tools/policy/modes.ts","label":"模式权限","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/tools/policy/modes.ts"}],"tools":[{"path":"packages/agent-core/src/harness/tools/index.ts","label":"工具注册","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/tools/index.ts"}],"memory":[{"path":"packages/agent-core/src/harness/memory/memory-store.ts","label":"内存存储","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/memory/memory-store.ts"}],"sessdb":[{"path":"packages/session-sqlite/src/store.ts","label":"sessions.db","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/session-sqlite/src/store.ts"}],"client":[{"path":"packages/client/src/App.tsx","label":"会话界面","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/client/src/App.tsx"}]}}</script>
<script id="archify-source-evidence-data" type="application/json">{"schemaVersion":1,"verified":true,"repository":{"url":"https://github.com/AlkaidSTART/call-code","revision":"baee5b2614b50e7d4b66eb8831db26b3914b2087","shortRevision":"baee5b2"},"referenceCount":8,"nodes":{"cli":[{"path":"source/app.tsx","label":"入口与交互界面","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/source/app.tsx"}],"core":[{"path":"packages/agent-core/src/harness/core/agent.ts","label":"规划→执行→观察","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/core/agent.ts"}],"context":[{"path":"packages/agent-core/src/harness/context/builder.ts","label":"构建上下文","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/context/builder.ts"}],"protocol":[{"path":"packages/agent-core/src/harness/protocol/parser.ts","label":"解析 action","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/protocol/parser.ts"}],"policy":[{"path":"packages/agent-core/src/harness/tools/policy/modes.ts","label":"模式权限","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/tools/policy/modes.ts"}],"tools":[{"path":"packages/agent-core/src/harness/tools/index.ts","label":"工具注册","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/tools/index.ts"}],"memory":[{"path":"packages/agent-core/src/harness/memory/memory-store.ts","label":"内存存储","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/agent-core/src/harness/memory/memory-store.ts"}],"sessdb":[{"path":"packages/session-sqlite/src/store.ts","label":"sessions.db","href":"https://github.com/AlkaidSTART/call-code/blob/baee5b2614b50e7d4b66eb8831db26b3914b2087/packages/session-sqlite/src/store.ts"}]}}</script>
<div class="guided-views no-print" id="guided-views" hidden aria-label="Guided diagram views">
<button id="guided-view-prev" type="button" aria-label="Previous guided view" title="Previous guided view ([)">&#8592;</button>
<div class="guided-view-copy">
Expand Down Expand Up @@ -4920,7 +4920,6 @@ <h1>call-code 架构</h1>
<path data-edge-from="core" data-edge-to="protocol" data-edge-key="4" data-edge-id="core-protocol" data-composition-points="404,100;404,180" d="M 404 100 L 404 180" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path data-edge-from="core" data-edge-to="memory" data-edge-label="记忆读写" data-edge-key="5" data-edge-id="core-memory" data-composition-points="344,70;252,70;252,350;160,350" d="M 344 70 L 260 70 Q 252 70 252 78 L 252 342 Q 252 350 244 350 L 160 350" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path data-edge-from="core" data-edge-to="sessdb" data-edge-label="会话持久化" data-edge-key="6" data-edge-id="core-sessdb" data-composition-points="464,70;556,70;556,350;648,350" d="M 464 70 L 548 70 Q 556 70 556 78 L 556 342 Q 556 350 564 350 L 648 350" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path data-edge-from="sessdb" data-edge-to="client" data-edge-label="导出 data.json" data-edge-key="7" data-edge-id="sessdb-client" data-composition-points="768,350;952,350" d="M 768 350 L 952 350" class="a-dashed" stroke-width="1.5" marker-end="url(#arrowhead-dashed)"/>
<path data-edge-from="core" data-edge-to="policy" data-edge-key="8" data-edge-id="core-policy" data-composition-points="464,63;556,63;556,210;648,210" d="M 464 63 L 548 63 Q 556 63 556 71 L 556 202 Q 556 210 564 210 L 648 210" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path data-edge-from="core" data-edge-to="tools" data-edge-key="9" data-edge-id="core-tools" data-composition-points="464,77;928,77;928,210;952,210" d="M 464 77 L 920 77 Q 928 77 928 85 L 928 202 Q 928 210 936 210 L 952 210" class="a-default" stroke-width="1.5" marker-end="url(#arrowhead)"/>

Expand Down Expand Up @@ -5029,20 +5028,6 @@ <h1>call-code 架构</h1>
<text data-detail="context" x="708" y="364" class="t-muted" font-size="9" text-anchor="middle">node:sqlite</text>
</g>

<g id="node-client" data-node-id="client" data-node-label="会话展示端" tabindex="0" role="button" aria-label="Focus 会话展示端, React + Vite · GitHub Pages, Architecture component" aria-pressed="false" data-node-kind="frontend" data-node-sublabel="React + Vite · GitHub Pages" data-node-context="Architecture component">
<title>会话展示端 · React + Vite · GitHub Pages · Architecture component</title>
<rect x="952" y="320" width="120" height="60" rx="6" class="c-mask"/>
<rect x="952" y="320" width="120" height="60" rx="6" class="c-frontend" stroke-width="1.5"/>
<g aria-hidden="true" data-semantic-sigil="frontend" class="semantic-sigil s-frontend" transform="translate(958 326) scale(0.6875)">
<rect x="2" y="3" width="12" height="10" rx="2"/>
<path d="M2 6.5h12"/>
<circle cx="4.1" cy="4.8" r=".7" class="sigil-fill"/>
<circle cx="6.3" cy="4.8" r=".7" class="sigil-fill"/>
</g>
<text data-detail-anchor x="1012" y="348" class="t-primary" font-size="11" font-weight="600" text-anchor="middle">会话展示端</text>
<text data-detail="context" x="1012" y="364" class="t-muted" font-size="6.9" text-anchor="middle">React + Vite · GitHub Pages</text>
</g>

<!-- Connection labels -->
<g data-detail="context" data-edge-from="cli" data-edge-to="core" data-edge-label="任务输入" data-edge-key="0" data-edge-id="cli-core">
<rect x="227.8" y="43" width="48.4" height="14" rx="3" class="c-mask"/>
Expand All @@ -5066,13 +5051,6 @@ <h1>call-code 架构</h1>
<rect x="671" y="150" width="58" height="14" rx="3" class="c-mask"/>
<text x="700" y="160" class="t-muted" font-size="8" text-anchor="middle">会话持久化</text>
</g>
<g data-detail="context" data-edge-from="sessdb" data-edge-to="client" data-edge-label="导出 data.json" data-edge-key="7" data-edge-id="sessdb-client">
<rect x="821.4" y="330" width="77.2" height="14" rx="3" class="c-mask"/>
<text x="860" y="340" class="t-messagebus" font-size="8" text-anchor="middle">导出 data.json</text>
</g>



<!-- Legend -->
<g data-legend data-legend-bridge>
<text x="40" y="684" class="t-primary" font-size="12" font-weight="650">Legend</text>
Expand Down Expand Up @@ -5285,7 +5263,7 @@ <h3>功能特性</h3>
<li>&bull; Ink 终端界面 · 双模式 PLAN/BUILD</li>
<li>&bull; 本地工具集 · 结构化 action 协议</li>
<li>&bull; 短期 / 长期记忆 · token 预算裁剪</li>
<li>&bull; node:sqlite 会话持久化 + GitHub Pages 展示</li>
<li>&bull; node:sqlite 会话持久化</li>
</ul>
</div>

Expand Down
6 changes: 3 additions & 3 deletions packages/agent-core/src/web/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
SessionStatsLike,
} from '../harness/session/store-types';

/** GitHub Pages 客户端读取的会话快照格式。 */
/** Web 客户端读取的会话快照格式。 */
export interface WebEntry {
seq: number;
id: string;
Expand Down Expand Up @@ -120,7 +120,7 @@ const toWebEntry = (entry: EntryLike): WebEntry => {
};

/**
* 把会话存储导出为静态客户端可用的 JSON 结构。
* 把会话存储导出为 Web 客户端可用的 JSON 结构。
* records 和 facts 是可选能力,存储未实现时自动省略。
*/
export const buildWebExport = (
Expand Down Expand Up @@ -164,7 +164,7 @@ export const buildWebExport = (
};
};

/** 把会话快照写入 packages/client 可读取的静态 JSON 文件。 */
/** 把会话快照写入 packages/client 可读取的 JSON 文件。 */
export const writeWebExport = (
store: WebStore,
outputPath: string,
Expand Down
14 changes: 7 additions & 7 deletions packages/client/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# Call Code History Client

这是 CLI 会话历史的静态展示端,基于 TypeScript、React 和 Tailwind CSS 构建,可直接部署到 GitHub Pages。页面默认读取 `data.json`,如果不存在则回退到 `data.example.json` 预览数据;也可以用 `?data=<url>` 指定数据文件,用 `?session=<id>` 直达某个会话。
这是 CLI 会话历史的静态展示端,基于 TypeScript、React 和 Tailwind CSS 构建,当前仅用于本地预览,不再部署到 GitHub Pages。页面默认读取 `data.json`,如果不存在则回退到 `data.example.json` 预览数据;也可以用 `?data=<url>` 指定数据文件,用 `?session=<id>` 直达某个会话。

## 构建

```bash
pnpm build:client
bun run build:client
```

产物输出到 `packages/client/dist`,GitHub Actions 会构建后上传该目录
产物输出到 `packages/client/dist`,用于本地预览

## 本地开发

```bash
pnpm dev:client
bun run dev:client
```

## 导出数据

在仓库根目录运行:

```bash
pnpm export:web
bun run export:web
```

脚本会把当前 `SESSION_DB_PATH` 指向的会话数据库导出为 `packages/client/public/data.json`。也可以在 CLI 中执行 `/export` 完成同样操作。

导出文件包含会话、消息、工具调用、统计和事实数据。发布到公开 GitHub Pages 前请先检查内容是否包含不该公开的路径、命令输出或密钥。
导出文件包含会话、消息、工具调用、统计和事实数据。若后续公开发布,请先检查内容是否包含不该公开的路径、命令输出或密钥。

## 本地预览

预览构建产物:

```bash
pnpm preview:client
bun run preview:client
```

## 主题
Expand Down
2 changes: 1 addition & 1 deletion source/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const commandHelp = [
'/pages - 打开相关页面选择',
'/memory - 查看 memory 概览',
'/status - 查看当前 CLI 状态',
'/export - 导出会话数据到 GitHub Pages 客户端',
'/export - 导出会话数据到 JSON 文件',
'/mode - 查看当前模式和阶段',
'/plan - 切换到 PLAN 模式',
'/build - 切换到 BUILD 模式',
Expand Down
2 changes: 1 addition & 1 deletion tests/web-export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('WebExport', () => {
}
});

it('构建 GitHub Pages 客户端可读的会话快照', () => {
it('构建 Web 客户端可读的会话快照', () => {
const store = createStore();
store.createSession({ cwd: '/tmp/project', id: 's-web' });
store.appendEntry('s-web', {
Expand Down
Loading