@kejiaqi/cannwork 0.0.0-stage → 0.0.1
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.md +89 -3
- package/bin/cannwork.js +68 -0
- package/package.json +59 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kejiaqi
|
|
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.md
CHANGED
|
@@ -1,3 +1,89 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# cannwork-core
|
|
2
|
+
|
|
3
|
+
**cannwork = 会话任务的多 harness 执行调度器。**
|
|
4
|
+
|
|
5
|
+
用户在任一端(GUI / CLI / WebUI)发起任务,core 把任务派给用户选定的外部 harness(opencode CLI、claude-code、codex、gemini…)去执行,并治理全程:统一身份、统一流量、统一审计。core 是编排者不是引擎——无推理循环、无内置引擎、不做模型路由。
|
|
6
|
+
|
|
7
|
+
本仓为**全自建路线**(无 opencode fork 底座):TypeScript + Bun monorepo,五层 21 包,`bun build --compile` 产出单二进制 `cannwork`(常驻 `:9700` 客户端 API + `:9100` LLM proxy,均仅本机)。
|
|
8
|
+
|
|
9
|
+
## 快速开始
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun install # 安装依赖(workspace 联动)
|
|
13
|
+
bun run typecheck # tsc --noEmit
|
|
14
|
+
bun run lint # eslint + 包边界(boundaries)强制
|
|
15
|
+
bun test # 全量测试
|
|
16
|
+
bun run build # 编译单二进制 → dist/cannwork(.exe)
|
|
17
|
+
./dist/cannwork --version
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 目录结构(五层 21 包)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
cannwork-core/
|
|
24
|
+
├── packages/ # 架构 21 包(private,编译进单二进制,永不单独发布)
|
|
25
|
+
│ ├── cmd/ # L0 组装:main · DI 装配 · 双监听启动 · 优雅退出
|
|
26
|
+
│ ├── common/ apitypes/ # L1 基础:类型/错误码/常量 · 客户端线类型(契约先行)
|
|
27
|
+
│ │ store/ assets/ # SQLite repo · 内置资产(注册表 seed/模板)
|
|
28
|
+
│ ├── server/ events/ proc/ # L2 运行时:HTTP+SSE · 事件总线 · 子进程 · 配置
|
|
29
|
+
│ │ config/ fs/ mcp/ # 数据目录 · 文件工具 · MCP 基座
|
|
30
|
+
│ ├── auth/ harness/ acp/ # L3 业务:身份 · 接入情报 · ACP 运行时 · 配置生成
|
|
31
|
+
│ │ configgen/ skills/ # 技能库/快照/物化 · 运行通道 · 会话编排
|
|
32
|
+
│ │ skillrt/ session/ proxy/ # LLM 流量出口 + system/settings 面(并入 session)
|
|
33
|
+
│ │ code/ # Code 模式:容器内 dsh web 进程管理 + token 捕获
|
|
34
|
+
│ └── cli/ # L4 客户端:cannwork chat
|
|
35
|
+
├── npm/cannwork/ # npm 分发薄壳:bin 启动器 + 平台包 optionalDependencies
|
|
36
|
+
├── docs/ # 设计文档(见下)
|
|
37
|
+
└── scripts/ # version.mjs 版本同步 · release.mjs 多平台编译+发布
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 依赖规则
|
|
41
|
+
|
|
42
|
+
依赖图单向无环,`eslint.config.js` 的 `DEPENDS_ON` 白名单强制(违反即 lint 报错)。要点:
|
|
43
|
+
|
|
44
|
+
- `common` 零依赖;基础层只依赖 `common`
|
|
45
|
+
- 跨层只许向下;横向许可仅两条:`harness→acp·configgen`(ACP 探测)、`proxy→auth`(取令牌)
|
|
46
|
+
- `session` 是业务顶层(无人反向依赖,不依赖 proxy);`cmd` 依赖全部、无人依赖它
|
|
47
|
+
|
|
48
|
+
完整依赖表与包职责见 [docs/repo-design.md](docs/repo-design.md)。
|
|
49
|
+
|
|
50
|
+
## 设计不变量
|
|
51
|
+
|
|
52
|
+
- harness env 永远只有占位符(`http://127.0.0.1:9100` + `cannwork-local`),真实 JWT 只在 proxy 进程内附加,令牌绝不打日志
|
|
53
|
+
- 技能快照 `(auto_inject − exclude) ∪ preset_enabled` 创建即冻结;物化视图只写 `~/.cannwork/cache/`,零 workspace 侵入
|
|
54
|
+
- core 是唯一 config writer;`:9100` 仅监听 127.0.0.1
|
|
55
|
+
|
|
56
|
+
## 安装与发版(npm 分发,整包 lockstep)
|
|
57
|
+
|
|
58
|
+
发布后用户安装(esbuild/biome 同款 optionalDependencies 模式,npm 自动按平台只装一个二进制包,无 postinstall):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install -g cannwork
|
|
62
|
+
npx cannwork --version
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
发版流程(内部 21 包永不单独发布;每次发版 = 5 平台二进制 + 薄壳**同版本原子更新**):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bun scripts/version.mjs 0.1.0 # 统一 bump:根 + 20 内部包 + 薄壳 + 平台包版本锁定
|
|
69
|
+
bun scripts/release.mjs # 交叉编译 5 平台 → dist/npm/<platform>/(附 sha256)
|
|
70
|
+
bun scripts/release.mjs --publish # 按「平台包先、薄壳后」顺序 npm publish(需登录态)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
注意:unix 平台包需从 Linux/macOS(或 CI)执行 publish 以保留可执行位;Windows 本地 assemble 仅用于验证(平台包 bin 字段 `cannwork-bin` 已做安装时置执行位兜底)。单二进制约 90–115MB/平台(含 Bun 运行时)。
|
|
74
|
+
|
|
75
|
+
## 文档地图
|
|
76
|
+
|
|
77
|
+
| 文档 | 回答什么 |
|
|
78
|
+
|---|---|
|
|
79
|
+
| [docs/overview.md](docs/overview.md) | 是什么/不是什么、概念地基、总架构 |
|
|
80
|
+
| [docs/architecture.md](docs/architecture.md) | 凭证链/流量链路/Harness 规范/技能系统全量细节 |
|
|
81
|
+
| [docs/repo-design.md](docs/repo-design.md) | **本仓**结构与模块设计、依赖规则、里程碑 |
|
|
82
|
+
| [docs/code-mode.md](docs/code-mode.md) | Code 模式:dsh web 托管、token 捕获、四个接口与状态机 |
|
|
83
|
+
| [docs/acp.md](docs/acp.md) | ACP 协议六步报文流 |
|
|
84
|
+
| [docs/skill.md](docs/skill.md) | 技能与文件的会话同步机制 |
|
|
85
|
+
| [docs/reference-core-structure-7pkg-fork.md](docs/reference-core-structure-7pkg-fork.md) | 参考对照:fork 路线 7 包方案 |
|
|
86
|
+
|
|
87
|
+
## 里程碑
|
|
88
|
+
|
|
89
|
+
**M0**(当前阶段):一条消息端到端——SSE 登录 → keychain → proxy 透传 JWT → 外部 opencode CLI(ACP)→ APISIX 审计可见。随后 M1 harness 管理 → M2 多 harness/会话完整 → M3 技能闭环 → M4 三端同构。
|
package/bin/cannwork.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cannwork CLI dispatcher(npm-distribution-bun-free Phase 2)。
|
|
4
|
+
*
|
|
5
|
+
* 检测当前平台 → require 对应的 @cannwork/<platform> 包 → spawn 编译二进制 → 透传退出码。
|
|
6
|
+
* 平台包通过 optionalDependencies + os/cpu 过滤——npm install 只装当前平台的产物。
|
|
7
|
+
*
|
|
8
|
+
* 用户安装:npm install -g cannwork
|
|
9
|
+
* 使用:cannwork serve / cannwork probe / …(参数原样透传给编译二进制)
|
|
10
|
+
*/
|
|
11
|
+
const { spawn } = require("node:child_process");
|
|
12
|
+
const { resolve } = require("node:path");
|
|
13
|
+
|
|
14
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
15
|
+
|
|
16
|
+
// 支持的平台列表(与 CI 矩阵一致)
|
|
17
|
+
const SUPPORTED = new Set([
|
|
18
|
+
"linux-x64",
|
|
19
|
+
"linux-arm64",
|
|
20
|
+
"darwin-x64",
|
|
21
|
+
"darwin-arm64",
|
|
22
|
+
"win32-x64",
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
if (!SUPPORTED.has(platform)) {
|
|
26
|
+
console.error(`cannwork: unsupported platform ${platform}`);
|
|
27
|
+
console.error(`Supported: ${[...SUPPORTED].join(", ")}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 平台包的二进制名(Windows 用 .exe)
|
|
32
|
+
const binName = process.platform === "win32" ? "cannwork.exe" : "cannwork";
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
// require 解析——平台包的 package.json 里 bin 字段指向编译产物
|
|
36
|
+
const platformPkg = require(`@kejiaqi/cannwork-${platform}/package.json`);
|
|
37
|
+
const binPath = resolve(
|
|
38
|
+
__dirname,
|
|
39
|
+
"..",
|
|
40
|
+
"node_modules",
|
|
41
|
+
"@kejiaqi",
|
|
42
|
+
`cannwork-${platform}`,
|
|
43
|
+
platformPkg.bin?.cannwork || binName,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
47
|
+
stdio: "inherit",
|
|
48
|
+
env: process.env,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
child.on("error", (err) => {
|
|
52
|
+
console.error(`cannwork: failed to start binary: ${err.message}`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
child.on("exit", (code, signal) => {
|
|
57
|
+
if (signal !== null && signal !== undefined) {
|
|
58
|
+
process.kill(process.pid, signal);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
process.exit(code ?? 0);
|
|
62
|
+
});
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error(`cannwork: platform package @kejiaqi/cannwork-${platform} not found`);
|
|
65
|
+
console.error(`Install it with: npm install @kejiaqi/cannwork-${platform}`);
|
|
66
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@kejiaqi/cannwork",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@kejiaqi/cannwork",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "cannwork — multi-agent orchestration platform (unified ACP management for 7 agents)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"agent",
|
|
10
|
+
"acp",
|
|
11
|
+
"multi-agent",
|
|
12
|
+
"orchestration",
|
|
13
|
+
"coding-assistant"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/cann-dev/cannwork-core.git"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"cannwork": "./bin/cannwork.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"bin/",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"optionalDependencies": {
|
|
28
|
+
"@kejiaqi/cannwork-linux-x64": "0.0.1",
|
|
29
|
+
"@kejiaqi/cannwork-linux-arm64": "0.0.1",
|
|
30
|
+
"@kejiaqi/cannwork-darwin-x64": "0.0.1",
|
|
31
|
+
"@kejiaqi/cannwork-darwin-arm64": "0.0.1",
|
|
32
|
+
"@kejiaqi/cannwork-win32-x64": "0.0.1"
|
|
33
|
+
},
|
|
34
|
+
"workspaces": [
|
|
35
|
+
"packages/*"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"gen:migrations": "bun scripts/gen-migrations.mjs",
|
|
39
|
+
"dev": "bun --watch run packages/cmd/src/main.ts serve",
|
|
40
|
+
"lint": "eslint .",
|
|
41
|
+
"test": "bun test",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"build": "bun build --compile packages/cmd/src/main.ts --outfile dist/cannwork",
|
|
44
|
+
"release": "bun scripts/release.mjs"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@eslint/js": "^9.39.0",
|
|
48
|
+
"@types/bun": "^1.2.25",
|
|
49
|
+
"eslint": "^9.39.0",
|
|
50
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
51
|
+
"eslint-plugin-boundaries": "^5.0.0",
|
|
52
|
+
"globals": "^16.5.0",
|
|
53
|
+
"typescript": "^5.9.3",
|
|
54
|
+
"typescript-eslint": "^8.46.0"
|
|
55
|
+
},
|
|
56
|
+
"trustedDependencies": [
|
|
57
|
+
"unrs-resolver"
|
|
58
|
+
]
|
|
59
|
+
}
|