@az-zephyr/slate 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.en.md +107 -0
- package/README.md +106 -2
- package/bin/slate.mjs +226 -0
- package/dist/agent/chunk-BVWXAL54.js +3654 -0
- package/dist/agent/cli.js +6 -0
- package/dist/agent/multi.js +59 -0
- package/dist/api/001_initial.sql +127 -0
- package/dist/api/002_project_assistant.sql +24 -0
- package/dist/api/003_card_decisions.sql +20 -0
- package/dist/api/004_card_default_agent.sql +3 -0
- package/dist/api/005_card_attachments.sql +24 -0
- package/dist/api/006_comment_attachments.sql +7 -0
- package/dist/api/007_participant_last_outcome.sql +6 -0
- package/dist/api/008_output_attachments.sql +7 -0
- package/dist/api/009_card_agent_runs.sql +23 -0
- package/dist/api/server.js +4567 -0
- package/dist/api/server.js.map +1 -0
- package/dist/web/assets/abnfDiagram-XWFEHMT6-DmNFXSdi.js +1 -0
- package/dist/web/assets/architectureDiagram-CSQXQB3N-BTCN41JR.js +36 -0
- package/dist/web/assets/blockDiagram-BEDRHYPZ-BUJZDqr0.js +140 -0
- package/dist/web/assets/bpmnIcons-APHXDYXF-ByGoYv9M.js +1 -0
- package/dist/web/assets/c4Diagram-M2UUVUY5-CoTmMGy5.js +38 -0
- package/dist/web/assets/chunk-2Q5K7J3B-DN1oTl6j.js +1 -0
- package/dist/web/assets/chunk-3BJB4PZV-f0-m4Ag2.js +1 -0
- package/dist/web/assets/chunk-3GCGMST5-79GFiiwz.js +1 -0
- package/dist/web/assets/chunk-5VM5RSS4-D8XyNr_K.js +15 -0
- package/dist/web/assets/chunk-7U7NFRK5-CwjNfj8w.js +88 -0
- package/dist/web/assets/chunk-CNRTWJTD-CrX82YZ2.js +1 -0
- package/dist/web/assets/chunk-D5HYT7QG-DLlJaHjh.js +1 -0
- package/dist/web/assets/chunk-EBZ3SEQC-DYMBSe-a.js +2 -0
- package/dist/web/assets/chunk-JWPE2WC7-D7hN7LFG.js +1 -0
- package/dist/web/assets/chunk-KTR4FSNJ-DNqOwqFL.js +1 -0
- package/dist/web/assets/chunk-XXDRQBXY-ZgzK0pt4.js +1 -0
- package/dist/web/assets/classDiagram-v2-IZLYA2OM-CA7bnKxc.js +217 -0
- package/dist/web/assets/cose-bilkent-JH36ORCC-DOKkzmxA.js +1 -0
- package/dist/web/assets/cynefin-EF2NZ3EQ-C-bSVtsc.js +141 -0
- package/dist/web/assets/cynefinDiagram-NJNITYFG-C37MEEtf.js +62 -0
- package/dist/web/assets/cytoscape.esm-Bw5aGq32.js +332 -0
- package/dist/web/assets/d3-scale-4DPf7zan.js +1 -0
- package/dist/web/assets/dagre-KIHZ2IZ3-9ncwFAl9.js +4 -0
- package/dist/web/assets/diagram-7YQZDPLS-B5nOmdUq.js +41 -0
- package/dist/web/assets/diagram-QBROCOUO-C2R6lDiO.js +200 -0
- package/dist/web/assets/diagram-RJJCUUZO-C6CCweHA.js +30 -0
- package/dist/web/assets/diagram-WERXNKYE-BMvmqzmc.js +24 -0
- package/dist/web/assets/diagram-YHHI257C-mq9rFYCr.js +3 -0
- package/dist/web/assets/diagram-YR4HJLHV-GnLZxfuk.js +24 -0
- package/dist/web/assets/ebnfDiagram-N527522P-BD49AZHw.js +1 -0
- package/dist/web/assets/elk-O5DQBFGD-BPi3gK_q.js +27 -0
- package/dist/web/assets/erDiagram-GT5GOJPG-v00zB8rw.js +99 -0
- package/dist/web/assets/flowDiagram-JAYNFW54-DIf4aoDB.js +213 -0
- package/dist/web/assets/ganttDiagram-3PRQTZWP-DRl_shHP.js +292 -0
- package/dist/web/assets/gitGraphDiagram-VXDFKS5L-2RrHppJt.js +106 -0
- package/dist/web/assets/graph-Bn3Yngep.js +1 -0
- package/dist/web/assets/grid-E2QIVN74-BuI-3sqA.js +1 -0
- package/dist/web/assets/index-5BTf4y0R.css +1 -0
- package/dist/web/assets/index-CtfDl2Kw.js +358 -0
- package/dist/web/assets/infoDiagram-ATMJ4U3S-afgUHtXU.js +2 -0
- package/dist/web/assets/ishikawaDiagram-S3EKX5GW-BsIUfApm.js +70 -0
- package/dist/web/assets/journeyDiagram-POQNLL5X-BM1Liuxy.js +139 -0
- package/dist/web/assets/kanban-definition-BH5XI6FM-Bz439vDv.js +89 -0
- package/dist/web/assets/katex-Be3d8Y4U.js +257 -0
- package/dist/web/assets/mermaid.core-CDkqDmQh.js +314 -0
- package/dist/web/assets/mindmap-definition-WVAN44T4-DcgvDd37.js +98 -0
- package/dist/web/assets/pegDiagram-D4NLKWP3-Bs1FcfRL.js +1 -0
- package/dist/web/assets/pieDiagram-36ENHN4W-CX3-kIFy.js +39 -0
- package/dist/web/assets/quadrantDiagram-ZQUDMS73-CrSg-66H.js +7 -0
- package/dist/web/assets/railroadDiagram-JIZHGYPL-DBm7mKc_.js +1 -0
- package/dist/web/assets/render-VIF2ZAQL-CjnzRbOQ.js +2 -0
- package/dist/web/assets/requirementDiagram-AXW2TVFA--vkT5OaJ.js +84 -0
- package/dist/web/assets/sankeyDiagram-FBCJTAIF-CXyuNpgP.js +40 -0
- package/dist/web/assets/sequenceDiagram-3LA2ROMG-Cfn5c7T5.js +169 -0
- package/dist/web/assets/sizeCapture-2Q2CQKSF-CQJexuw3.js +1 -0
- package/dist/web/assets/stateDiagram-v2-XZFR63ZJ-W23Y_4Yd.js +291 -0
- package/dist/web/assets/swimlanes-YQL5WMAO-B8ymV9uv.js +1 -0
- package/dist/web/assets/swimlanesDiagram-BA3ZWDFA-ClHf-9J2.js +8 -0
- package/dist/web/assets/timeline-definition-7Z437IG3-BElgSf_v.js +120 -0
- package/dist/web/assets/usecaseDiagram-RDK6N6HP-BfopeYcl.js +370 -0
- package/dist/web/assets/vennDiagram-SHRQU5PJ-034PLwGh.js +34 -0
- package/dist/web/assets/wardleyDiagram-F3OXNVQS-Cmiyei3a.js +78 -0
- package/dist/web/assets/xychartDiagram-GDYJKCDI-DxF4glgl.js +7 -0
- package/dist/web/index.html +13 -0
- package/package.json +42 -4
- package/scripts/git-worktree.mjs +63 -0
- package/scripts/slate-cli.mjs +851 -0
- package/skills/slate-card/SKILL.md +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 az-zephyr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Slate · Human-Agent Collaborative Kanban
|
|
2
|
+
|
|
3
|
+
[中文](README.md) | English
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](package.json)
|
|
7
|
+
[](package.json)
|
|
8
|
+
|
|
9
|
+
A local-first human-agent collaborative kanban board for solo developers and everyday tasks (React 19 + Vite / Fastify + `node:sqlite` / local multi-CLI agent integration). Slate solves the problem of tasks getting scattered across separate AI agent chat windows, making them easy to track, run in parallel, and review in one place.
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
|
|
13
|
+
- **Local-First, Zero External Services, Out-of-the-Box**: Both the API and web UI bind strictly to `127.0.0.1` with data stored in local SQLite—no external database, no login walls. All agents run via unmodified official local CLIs without reading or forwarding local OAuth credentials.
|
|
14
|
+
- **Co-Editable Living Docs + Issue-Style Comments**: Each card supports Markdown & Mermaid rendering, incremental checklists, tags, sub-cards, image/file attachments, inline output previews, and native Finder/file reveal. Every edit records a read-only audit snapshot with before/after diffing. Agents can read, edit, split sub-cards, and move cards to `review`; humans always have final sign-off to mark `done`.
|
|
15
|
+
- **Multi-Agent Parallelism + On-Demand Worktree Isolation**: Built-in support for **Codex**, **Claude Code**, and **Antigravity** local CLIs. Supports two-tier default routing (`Project Default Agent → Card Default Agent`) and multi-select `@mentions` in comments. Tasks start in lightweight per-actor directories (no redundant branches for research/review/docs), and agents call `slate worktree` on demand only when modifying code in a bound Git repo. Runs execute serially per card and concurrently across cards (default concurrency: 5) with collapsible live execution step streams.
|
|
16
|
+
- **Structured Human Decisions (`slate ask`)**: When an agent hits an architectural trade-off or blocker, it raises a structured decision with options. Pending decisions highlight in real time on cards and the status bar; clicking an option or replying in the drawer logs the comment and wakes the asking agent to continue.
|
|
17
|
+
- **Read-Only Sandboxed Project Assistant & AI Card Drafting**: Includes a docked Project Assistant panel and an AI Card Drafting modal powered by your local CLI, with streaming previews, context-aware task breakdown, and board cleanup proposals. The assistant runs strictly in a read-only sandbox—every create/update/archive proposal requires human confirmation before applying.
|
|
18
|
+
- **Conflict Awareness & Self-Healing CLI**: When parallel agents race on status transitions (e.g. moving to `review`) or concurrent edits (`409`), the API returns current state, last actor, and latest snapshots so agents can self-heal via `slate comment`, `slate output`, or retry.
|
|
19
|
+
|
|
20
|
+
## Typical Workflow
|
|
21
|
+
|
|
22
|
+
1. **Create & Break Down**: Create cards manually or use AI Card Drafting to turn rough ideas into structured cards with body, checklist, and attachments.
|
|
23
|
+
2. **Drag to Run / `@` Wake**: Click **Run**, drag a card into `doing`, or `@mention` one or more agents in comments. Local CLIs pick up the card in isolated workspaces and stream structured execution steps in real time.
|
|
24
|
+
3. **Decide & Co-Edit**: Answer structured `slate ask` prompts in one click to unblock agents, co-edit living docs, or drop screenshots/files in comments.
|
|
25
|
+
4. **Review Outputs & Accept**: Agents deliver reports/artifacts via `slate output` or attach Git branches and move the card to `review`. Preview outputs directly in the drawer and mark `done` once satisfied.
|
|
26
|
+
|
|
27
|
+
## Prerequisites
|
|
28
|
+
|
|
29
|
+
- **Node.js**: `>=22.18 <23` (uses built-in `node:sqlite`)
|
|
30
|
+
- **Package Manager**: `pnpm@9.x`
|
|
31
|
+
- **Local CLI (at least one installed and signed in)**: Codex / Claude Code / Antigravity (or pass `--no-agents` to explore the board UI without starting agents)
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
### Option 1: One-Command Global Install via npm (Recommended)
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm i -g @az-zephyr/slate
|
|
39
|
+
slate
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Running `slate` starts the board at `http://127.0.0.1:3100` (serving both the UI and API on a single port), opens your browser, and auto-detects installed Codex / Claude Code / Antigravity CLIs. Local data is stored under `~/.slate`.
|
|
43
|
+
|
|
44
|
+
Common flags:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
slate --port 3200 # Listen on a custom port
|
|
48
|
+
slate --home ~/my-slate # Use a custom local data directory
|
|
49
|
+
slate --no-agents # Start only the board without launching CLI agents
|
|
50
|
+
slate --no-open # Do not auto-open the browser
|
|
51
|
+
slate agents --drivers codex # Manage / reconnect specific CLI drivers separately
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Option 2: Run from Source (Development)
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm install --frozen-lockfile # First-time setup
|
|
58
|
+
pnpm start:local # Start API (3100) + Web (5173) and auto-detect installed local CLIs
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Open [http://localhost:5173](http://localhost:5173) in your browser.
|
|
62
|
+
|
|
63
|
+
> To start only the API and Web UI without launching local agents, run `pnpm start:local --no-agents` (or `pnpm dev`).
|
|
64
|
+
|
|
65
|
+
### Manage / Restart CLI Agents from Source (Optional)
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pnpm start:agents # Auto-detect and start all installed CLIs
|
|
69
|
+
pnpm start:agents --drivers codex,antigravity,claude-code # Start specific drivers explicitly
|
|
70
|
+
pnpm start:agent --driver codex --name "Codex" # Start a single driver
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
On first launch, each agent registers with the local board and saves credentials under `.local/agent-<driver>-<id>.json` (`0600` permissions), with per-`agentId` locking so multiple CLIs can run side by side.
|
|
74
|
+
|
|
75
|
+
## Repository Layout
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
packages/contracts # Shared Zod schemas and TypeScript contracts
|
|
79
|
+
apps/api # Fastify + node:sqlite API, server-side @ routing, and SSE stream
|
|
80
|
+
apps/agent # Local CLI drivers, concurrent event loop, workspace/worktree isolation, and assistant runner
|
|
81
|
+
apps/web # React 19 + Vite kanban frontend, card drawer, project assistant, and live step timeline
|
|
82
|
+
scripts/slate-cli.mjs # Unified `slate` CLI injected into local agent environments
|
|
83
|
+
skills/slate-card # Runtime card collaboration guidelines (SKILL.md)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Verification & Quality Gates
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
pnpm check # Run Biome lint + typecheck + all unit tests (contracts / api / agent / web / slate CLI)
|
|
90
|
+
pnpm format # Format and auto-fix with Biome
|
|
91
|
+
pnpm build # Full monorepo build check
|
|
92
|
+
pnpm test:e2e # End-to-end Playwright verification
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Further Reading
|
|
96
|
+
|
|
97
|
+
- Architecture, data model & collaboration rules: [docs/architecture.md](docs/architecture.md)
|
|
98
|
+
- Runtime card collaboration & `slate` CLI guide: [skills/slate-card/SKILL.md](skills/slate-card/SKILL.md)
|
|
99
|
+
- Repository engineering guidelines: [AGENTS.md](AGENTS.md)
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
[MIT](LICENSE)
|
|
104
|
+
|
|
105
|
+
## Acknowledgments
|
|
106
|
+
|
|
107
|
+
Thanks to **Antigravity**, **Code**, and **GrokBots** for helping power this project—especially **Antigravity**, whose addition accelerated Slate's development and brought the project to life.
|
package/README.md
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Slate · 人机协同看板
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
中文 | [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](package.json)
|
|
7
|
+
[](package.json)
|
|
8
|
+
|
|
9
|
+
面向本机单人日常研发与通用任务协作的本地优先(Local-First)人机协同看板(React 19 + Vite / Fastify + `node:sqlite` / 本地多 CLI Agent 接入),解决“任务散落在不同 Agent 对话框里难以跟踪、并行协作和沉淀产出”的问题。
|
|
10
|
+
|
|
11
|
+
## 核心特性
|
|
12
|
+
|
|
13
|
+
- **本机单人、零外部依赖、开箱即用**:API 与前端默认仅绑定 `127.0.0.1`,数据保存在本地 SQLite,无需数据库服务、无需登录切换;所有 Agent 均通过官方未修改 CLI 本地拉起,不读取也不转发本地 OAuth 凭据。
|
|
14
|
+
- **人机共编活文档 + Issue 式评论区**:任务卡片支持 Markdown 与 Mermaid 渲染、Checklist(增量并发更新)、标签、子任务卡片、图片/文件附件、托管产出页内预览与本机访达定位;每次编辑自动留痕只读审计快照(支持查看前后 diff 与复制旧版)。Agent 可自由读写、拆卡并推至 `review`,最终由人验收标为 `done`。
|
|
15
|
+
- **单卡多 Agent 真并行 + 按需 Worktree 隔离**:首批支持 **Codex / Claude Code / Antigravity** 本地 CLI 驱动。支持「项目默认 Agent → 卡片默认 Agent」两层路由与评论区 `@` 多选精准唤醒;默认分配轻量独立目录防写冲突,非改代码任务零冗余分支,确实需要改 Git 仓库代码时再通过 `slate worktree` 按需创建独立分支与工作树;支持同卡串行、跨卡并发(默认并发 5)与可折叠实时执行步骤流回放。
|
|
16
|
+
- **结构化人机拍板(`slate ask`)**:Agent 遇到方案取舍或阻塞时可发起带选项的待确认决策,看板卡片与状态栏实时高亮聚合计数;人在卡片抽屉一键点选或回复后,自动写入评论并定向唤醒提问 Agent 续跑。
|
|
17
|
+
- **硬只读沙箱项目助手 & AI 建卡**:内置停靠式项目助手面板与 AI 建卡弹窗,复用本机 CLI 能力提供流式预览、上下文感知拆卡/起草以及看板整理提案;助手全程运行在只读沙箱中,所有新建、更新或归档提案均须人工确认后才会应用。
|
|
18
|
+
- **状态冲突自感知与 CLI 自愈闭环**:多 Agent 并行推进到同一状态(如 `review`)或出现并发编辑冲突(`409`)时,API 返回当前状态、最近变更者与最新快照摘要,由 Agent 自主通过 `slate comment` / `slate output` 补充说明或合并重试。
|
|
19
|
+
|
|
20
|
+
## 典型协作流
|
|
21
|
+
|
|
22
|
+
1. **建卡与拆解**:手动创建或通过 AI 建卡将模糊想法整理为带正文、Checklist 与附件的任务卡片。
|
|
23
|
+
2. **拖入执行 / `@` 唤醒**:点击「执行」、将卡片拖入 `doing` 或在评论区 `@Agent`(支持多选并行),本地 CLI 自动在隔离目录接手推进,并实时推送执行步骤流。
|
|
24
|
+
3. **中途拍板与共编**:Agent 遇阻时通过 `slate ask` 抛出选项,人一键拍板续跑;双方可随时共编活文档、互看产出或在评论区补充附图说明。
|
|
25
|
+
4. **产出审阅与验收**:Agent 通过 `slate output` 托管报告/制品或挂载代码分支并推进至 `review`,人在抽屉中直接预览产出,确认无误后标记 `done`。
|
|
26
|
+
|
|
27
|
+
## 环境要求
|
|
28
|
+
|
|
29
|
+
- **Node.js**:`>=22.18 <23`(使用内置 `node:sqlite`)
|
|
30
|
+
- **包管理器**:`pnpm@9.x`
|
|
31
|
+
- **本地 CLI(至少安装并登录其一)**:Codex / Claude Code / Antigravity(若暂不启动 Agent,可加 `--no-agents` 仅体验看板)
|
|
32
|
+
|
|
33
|
+
## 快速启动
|
|
34
|
+
|
|
35
|
+
### 方式一:npm 一键全局安装(推荐)
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm i -g @az-zephyr/slate
|
|
39
|
+
slate
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
执行 `slate` 会在 `http://127.0.0.1:3100` 启动看板(同端口托管前端与 API)、自动打开浏览器,并探测接入本机已安装的 Codex / Claude Code / Antigravity;数据默认保存在 `~/.slate`。
|
|
43
|
+
|
|
44
|
+
常用参数:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
slate --port 3200 # 指定监听端口
|
|
48
|
+
slate --home ~/my-slate # 指定本地数据目录
|
|
49
|
+
slate --no-agents # 仅启动看板,不自动拉起本地 CLI Agent
|
|
50
|
+
slate --no-open # 启动后不自动打开浏览器
|
|
51
|
+
slate agents --drivers codex # 单独管理 / 重连指定 CLI 驱动
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 方式二:从源码运行(本地开发)
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
pnpm install --frozen-lockfile # 首次安装依赖
|
|
58
|
+
pnpm start:local # 启动 API (3100) + Web (5173),并自动探测接入本机已安装的 CLI
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
启动后在浏览器打开 [http://localhost:5173](http://localhost:5173) 即可使用。
|
|
62
|
+
|
|
63
|
+
> 如只想启动看板服务、不自动拉起本地 Agent,可运行 `pnpm start:local --no-agents`(或 `pnpm dev`)。
|
|
64
|
+
|
|
65
|
+
### 源码模式下单独管理 / 重启 CLI 接入(可选)
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pnpm start:agents # 自动探测并启动全部已安装 CLI
|
|
69
|
+
pnpm start:agents --drivers codex,antigravity,claude-code # 显式指定要启动的驱动
|
|
70
|
+
pnpm start:agent --driver codex --name "Codex" # 单独启动某一个驱动
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
首次启动会自动向本机看板注册并将凭据保存至 `.local/agent-<driver>-<id>.json`(权限 `0600`),按 `agentId` 独立加锁,支持同机同时运行多个 CLI。
|
|
74
|
+
|
|
75
|
+
## 仓库结构
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
packages/contracts # 前后端与 Agent 共享的 Zod Schema 与 TypeScript 契约
|
|
79
|
+
apps/api # Fastify + node:sqlite 单体 API、服务端 @ 路由与 SSE 事件流
|
|
80
|
+
apps/agent # 本地 CLI 驱动、并发事件循环、工作区/Worktree 隔离与助手执行
|
|
81
|
+
apps/web # React 19 + Vite 看板前端、卡片抽屉、项目助手与实时步骤流
|
|
82
|
+
scripts/slate-cli.mjs # 注入给本地 CLI Agent 调用的统一 `slate` 命令行工具
|
|
83
|
+
skills/slate-card # 运行时卡片协作规范(SKILL.md)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## 验证与质量门禁
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
pnpm check # 一键执行 Biome lint + typecheck + 全部单元测试(contracts / api / agent / web / slate CLI)
|
|
90
|
+
pnpm format # 使用 Biome 自动格式化并修复代码风格
|
|
91
|
+
pnpm build # 全量构建校验
|
|
92
|
+
pnpm test:e2e # 端到端 Playwright 验证
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 延伸文档
|
|
96
|
+
|
|
97
|
+
- 架构、数据模型与协同规则:[docs/architecture.md](docs/architecture.md)
|
|
98
|
+
- Agent 卡片协作与 `slate` CLI 指南:[skills/slate-card/SKILL.md](skills/slate-card/SKILL.md)
|
|
99
|
+
- 仓库开发与工程规范:[AGENTS.md](AGENTS.md)
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
[MIT](LICENSE)
|
|
104
|
+
|
|
105
|
+
## 致谢
|
|
106
|
+
|
|
107
|
+
感谢 **Antigravity**、**Code** 和 **GrokBots** 对本项目的助力——尤其是 **Antigravity**,在它加入之后,Slate 才得以快速推进并落地成形。
|
package/bin/slate.mjs
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
4
|
+
import net from 'node:net';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
import { parseArgs } from 'node:util';
|
|
10
|
+
|
|
11
|
+
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
12
|
+
|
|
13
|
+
// When invoked inside an Agent subprocess with SLATE_RUNTIME_FILE set,
|
|
14
|
+
// delegate transparently to the card collaboration CLI to avoid name collisions.
|
|
15
|
+
if (process.env.SLATE_RUNTIME_FILE) {
|
|
16
|
+
const cliModule = await import(pathToFileURL(path.join(packageRoot, 'scripts/slate-cli.mjs')).href);
|
|
17
|
+
process.exitCode = await cliModule.main(process.env.SLATE_RUNTIME_FILE);
|
|
18
|
+
process.exit(process.exitCode ?? 0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const pkg = JSON.parse(readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
22
|
+
const rawArgs = process.argv.slice(2);
|
|
23
|
+
const firstArg = rawArgs[0];
|
|
24
|
+
|
|
25
|
+
if (firstArg === '-v' || firstArg === '--version' || firstArg === 'version') {
|
|
26
|
+
console.log(pkg.version);
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (firstArg === '-h' || firstArg === '--help' || firstArg === 'help') {
|
|
31
|
+
printHelp();
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
36
|
+
if (major !== 22 || minor < 18) {
|
|
37
|
+
console.error(`Slate 需要 Node.js >=22.18 <23(当前版本:v${process.versions.node})。`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const subcommand = firstArg && !firstArg.startsWith('-') ? firstArg : 'start';
|
|
42
|
+
const commandArgs = firstArg && !firstArg.startsWith('-') ? rawArgs.slice(1) : rawArgs;
|
|
43
|
+
|
|
44
|
+
if (subcommand !== 'start' && subcommand !== 'agents') {
|
|
45
|
+
console.error(`未知命令:${subcommand}\n`);
|
|
46
|
+
printHelp();
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function printHelp() {
|
|
51
|
+
console.log(`Slate v${pkg.version} — Local-first human-agent collaborative kanban board
|
|
52
|
+
|
|
53
|
+
Usage:
|
|
54
|
+
slate [start] [options] 启动 Slate 看板(默认仅绑定 127.0.0.1:3100)并自动探测本地 CLI
|
|
55
|
+
slate agents [options] 单独启动/重连本地 CLI Agent 接入进程
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
--port <port> 监听端口(默认 3100,或使用 API_PORT)
|
|
59
|
+
--home <dir> 本地数据目录(默认 ~/.slate,或使用 SLATE_HOME)
|
|
60
|
+
--no-agents 仅启动看板服务,不自动探测拉起本地 CLI Agent
|
|
61
|
+
--no-open 启动后不自动打开浏览器
|
|
62
|
+
--drivers <list> 指定要启动的驱动(如 codex,claude-code,antigravity)
|
|
63
|
+
--concurrency <n> 单 Agent 最大跨卡并发数(默认 5)
|
|
64
|
+
-v, --version 查看版本号
|
|
65
|
+
-h, --help 查看帮助
|
|
66
|
+
`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resolveHomeDir(homeFlag) {
|
|
70
|
+
const raw = homeFlag || process.env.SLATE_HOME || path.join(homedir(), '.slate');
|
|
71
|
+
if (raw === '~') return homedir();
|
|
72
|
+
if (raw.startsWith('~/')) return path.join(homedir(), raw.slice(2));
|
|
73
|
+
return path.resolve(raw);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function portOpen(port) {
|
|
77
|
+
return new Promise(resolve => {
|
|
78
|
+
const socket = net.connect({ host: '127.0.0.1', port }, () => {
|
|
79
|
+
socket.end();
|
|
80
|
+
resolve(true);
|
|
81
|
+
});
|
|
82
|
+
socket.on('error', () => resolve(false));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function fetchOk(url) {
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetch(url, { redirect: 'manual' });
|
|
89
|
+
return response.ok;
|
|
90
|
+
} catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function waitForHealth(url, timeoutMs = 30_000) {
|
|
96
|
+
const deadline = Date.now() + timeoutMs;
|
|
97
|
+
while (Date.now() < deadline) {
|
|
98
|
+
if (await fetchOk(url)) return;
|
|
99
|
+
await sleep(250);
|
|
100
|
+
}
|
|
101
|
+
console.error(`Slate 服务在 ${Math.round(timeoutMs / 1000)} 秒内未就绪。`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function openBrowser(url) {
|
|
106
|
+
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
107
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
108
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
109
|
+
child.on('error', () => {});
|
|
110
|
+
child.unref();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const { values } = parseArgs({
|
|
114
|
+
args: commandArgs,
|
|
115
|
+
options: {
|
|
116
|
+
port: { type: 'string' },
|
|
117
|
+
home: { type: 'string' },
|
|
118
|
+
'no-agents': { type: 'boolean', default: false },
|
|
119
|
+
'no-open': { type: 'boolean', default: false },
|
|
120
|
+
drivers: { type: 'string' },
|
|
121
|
+
concurrency: { type: 'string' },
|
|
122
|
+
},
|
|
123
|
+
strict: true,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const port = Number(values.port ?? process.env.API_PORT ?? 3100);
|
|
127
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
128
|
+
console.error(`无效端口:${values.port}`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const slateHome = resolveHomeDir(values.home);
|
|
133
|
+
mkdirSync(slateHome, { recursive: true });
|
|
134
|
+
|
|
135
|
+
const apiEntry = path.join(packageRoot, 'dist/api/server.js');
|
|
136
|
+
const agentMultiEntry = path.join(packageRoot, 'dist/agent/multi.js');
|
|
137
|
+
const webDistDir = path.join(packageRoot, 'dist/web');
|
|
138
|
+
|
|
139
|
+
if (!existsSync(apiEntry) || !existsSync(agentMultiEntry) || !existsSync(webDistDir)) {
|
|
140
|
+
console.error('未找到 Slate 构建产物。如在源码仓库中运行,请先执行 pnpm build:cli。');
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const baseUrl = `http://127.0.0.1:${port}`;
|
|
145
|
+
const sharedEnv = {
|
|
146
|
+
...process.env,
|
|
147
|
+
API_PORT: String(port),
|
|
148
|
+
WEB_ORIGIN: baseUrl,
|
|
149
|
+
SLATE_HOME: slateHome,
|
|
150
|
+
SLATE_PACKAGE_ROOT: packageRoot,
|
|
151
|
+
SLATE_WEB_DIST: webDistDir,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const agentArgs = [agentMultiEntry, '--api', `${baseUrl}/v1`];
|
|
155
|
+
if (values.drivers) agentArgs.push('--drivers', values.drivers);
|
|
156
|
+
if (values.concurrency) agentArgs.push('--concurrency', values.concurrency);
|
|
157
|
+
|
|
158
|
+
if (subcommand === 'agents') {
|
|
159
|
+
const child = spawn(process.execPath, agentArgs, { stdio: 'inherit', env: sharedEnv });
|
|
160
|
+
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
161
|
+
process.on(sig, () => {
|
|
162
|
+
if (!child.killed) child.kill(sig);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
child.on('exit', code => process.exit(code ?? 0));
|
|
166
|
+
} else {
|
|
167
|
+
const children = [];
|
|
168
|
+
const startChild = (label, args, { critical = true } = {}) => {
|
|
169
|
+
const child = spawn(process.execPath, args, { stdio: 'inherit', env: sharedEnv });
|
|
170
|
+
children.push(child);
|
|
171
|
+
child.on('exit', (code, signal) => {
|
|
172
|
+
if (!critical) return;
|
|
173
|
+
if (signal) process.exit(0);
|
|
174
|
+
if ((code ?? 1) !== 0) {
|
|
175
|
+
console.error(`${label} 已退出,状态码 ${code}`);
|
|
176
|
+
process.exit(code ?? 1);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return child;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const shutdown = signal => {
|
|
183
|
+
for (const child of children) {
|
|
184
|
+
if (!child.killed) child.kill(signal);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
for (const sig of ['SIGINT', 'SIGTERM']) {
|
|
188
|
+
process.on(sig, () => {
|
|
189
|
+
shutdown(sig);
|
|
190
|
+
process.exit(0);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const alreadyUp = await fetchOk(`${baseUrl}/health`);
|
|
195
|
+
if (!alreadyUp) {
|
|
196
|
+
if (await portOpen(port)) {
|
|
197
|
+
console.error(`127.0.0.1:${port} 已被其他进程占用,请使用 --port 指定其他端口。`);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
startChild('Slate 服务', [apiEntry]);
|
|
201
|
+
await waitForHealth(`${baseUrl}/health`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
console.log('');
|
|
205
|
+
console.log(`Slate v${pkg.version} 已就绪(仅绑定 127.0.0.1)`);
|
|
206
|
+
console.log(` 看板地址 ${baseUrl}`);
|
|
207
|
+
console.log(` 数据目录 ${slateHome}`);
|
|
208
|
+
console.log(
|
|
209
|
+
values['no-agents']
|
|
210
|
+
? ' CLI Agent 已通过 --no-agents 跳过自动探测'
|
|
211
|
+
: ' CLI Agent 正在自动探测并接入本机已安装的 Codex / Claude Code / Antigravity',
|
|
212
|
+
);
|
|
213
|
+
console.log('');
|
|
214
|
+
|
|
215
|
+
if (!values['no-open']) {
|
|
216
|
+
openBrowser(baseUrl);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!values['no-agents']) {
|
|
220
|
+
startChild('CLI Agent', [...agentArgs, '--optional'], { critical: false });
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (alreadyUp && values['no-agents']) {
|
|
224
|
+
process.exit(0);
|
|
225
|
+
}
|
|
226
|
+
}
|