@myclaw163/clawclaw-cli 0.8.11 → 0.8.13
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/docs/configuration.md +11 -12
- package/docs/custom-modules/README.md +3 -3
- package/docs/custom-modules/behavior.md +1 -1
- package/docs/custom-modules/perception.md +1 -1
- package/docs/custom-modules/trigger.md +1 -1
- package/docs/runtime/official-perception-modules.md +1 -1
- package/package.json +1 -1
- package/scripts/check-skill-command-surface.mjs +1 -0
- package/scripts/sync-bundled-skill.mjs +89 -52
- package/skills/clawclaw/SKILL.md +7 -3
- package/skills/clawclaw/references/BEHAVIORS.md +2 -0
- package/skills/clawclaw/references/COMMANDS.md +9 -2
- package/skills/clawclaw/references/HUB.md +4 -2
- package/src/cli.ts +2 -0
- package/src/commands/behavior.ts +49 -8
- package/src/commands/capability.ts +345 -0
- package/src/commands/load.ts +195 -8
- package/src/commands/perception.ts +21 -7
- package/src/commands/persona.ts +6 -0
- package/src/commands/trigger.ts +8 -5
- package/src/lib/agent-workspace-skills.ts +167 -68
- package/src/lib/agent-workspace-sync.ts +20 -31
- package/src/lib/capability-cloud-refresh.ts +313 -0
- package/src/lib/capability-cloud-sync.ts +315 -0
- package/src/lib/capability-discovery.ts +94 -0
- package/src/lib/capability-workspace.ts +291 -0
- package/src/lib/hub-client.ts +131 -4
- package/src/lib/persona.ts +1 -24
- package/src/lib/skill-host.ts +63 -0
- package/src/lib/user-data.ts +47 -59
- package/src/lib/zip-store.ts +92 -0
- package/src/runtime/clawclaw/owner.ts +12 -12
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +3 -1
package/docs/configuration.md
CHANGED
|
@@ -35,21 +35,20 @@ $env:CLAWCLAW_WORKSPACE_DIR = 'D:\clawclaw-workspace'
|
|
|
35
35
|
|
|
36
36
|
### 账号 Hub 装配快照
|
|
37
37
|
|
|
38
|
-
`ccl load` 使用当前账号的 Lobby API key 读取 `/api/v1/agents/workspace/config`。CCL 为每项保留上次 Hub `base version/digest
|
|
38
|
+
`ccl load` 使用当前账号的 Lobby API key 读取 `/api/v1/agents/workspace/config`。CCL 为每项保留上次 Hub `base version/digest`,并比较当前工作副本与远端:本地仍等于基线时采用新的 Hub 版本;本地偏离基线时优先使用本地。没有并发差异时,CCL 自动创建私有资源、新版本或 fork;上传失败不影响本次本地使用。需要远端内容时先下载到 staging,逐个校验大小、SHA-256 和 `content_digest`,全部成功后才原子切换 `current.json`。
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
本地和远端同时变化且内容不同时不自动上传;`ccl load` 输出冲突,由玩家通过 `ccl capability resolve <type/id> --use local|cloud|later` 选择。选择云端时命令立即把本地修改保存到 `drafts` 并切换工作副本;选择本地时命令立即只上传该目标资源。`ccl capability equip` 和 `ccl capability unequip` 也立即保存装配状态,Skill 同时更新宿主链接。执行这些实际修改后,开局前仍须重新运行完整 `ccl load`,用最终输出刷新上下文、能力清单、同步结果和 participation。
|
|
41
41
|
|
|
42
42
|
玩家可编辑源文件按资源类型放在稳定目录中:
|
|
43
43
|
|
|
44
44
|
```text
|
|
45
45
|
user-data/accounts/<account-hash>/
|
|
46
|
-
behaviors/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
triggers/local/
|
|
46
|
+
capabilities/behaviors/
|
|
47
|
+
capabilities/perceptions/
|
|
48
|
+
capabilities/personas/
|
|
49
|
+
capabilities/skills/
|
|
50
|
+
capabilities/triggers/
|
|
51
|
+
drafts/
|
|
53
52
|
hub-loadout/revisions/
|
|
54
53
|
```
|
|
55
54
|
|
|
@@ -57,7 +56,7 @@ user-data/accounts/<account-hash>/
|
|
|
57
56
|
|
|
58
57
|
除宿主全局 Skill 外,Strategy、Persona、Perception、本地 Behavior/Trigger、blacklist、默认 long Behavior 和 Hub 快照都按账号保存。Strategy 资源在 0.8.x 中映射为 Behavior API v3:一个 Hub Strategy 是一个顶层 `.ts` 或 `.js` Behavior 入口文件,默认导出一个 `ClawclawBehavior` 子类并声明字面量 `static manifest`。多选表示多个 Behavior 可供 Agent、Trigger 或默认 long 配置启动,不表示同层并行执行。
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
Skill 在账号 `capabilities/skills/<name>/` 中只有一个可编辑实体;`.agents/.claude/.codex/.openclaw` 都是当前 active 账号的目录链接。任意宿主修改都会落到同一实体。切换账号时链接切换;取消装配只移除链接,不删除账号工作副本。旧实体目录不迁移也不删除。
|
|
61
60
|
|
|
62
61
|
## Claude 通知输出
|
|
63
62
|
|
|
@@ -204,7 +203,7 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
|
|
|
204
203
|
|
|
205
204
|
`ccl load`、资源管理命令或 Owner 启动只要首次读到这些旧字段,就会把迁移结果写回原文件。迁移完成后的当前 schema 是严格的:未知顶层字段、未知角色、缺失角色绑定、非法资源 ID、错误类型或越界数值都会直接报错,不会静默忽略。经常切换不同 CCL 版本时,应先备份 `user-data/gameplay.json`;旧版本若不认识 Behavior/Trigger 当前字段,不应与新版本轮流写同一个 workspace。
|
|
206
205
|
|
|
207
|
-
|
|
206
|
+
官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip` 保存一次装配选择。Behavior 仍以 manifest `id` 作为 `list`、`start`、fallback 和 Trigger 绑定的稳定身份。
|
|
208
207
|
|
|
209
208
|
分角色 `fallback_behaviors` 现在表示“角色确定后立即启动的默认 long Behavior”。配置为 `null` 时保持 idle;配置引用未加载、禁用或不兼容时,`ccl load` 逐角色输出 `FALLBACK_BEHAVIOR_NOT_LOADED` warning,只说明当前配置项不可用且不自动改配置;Runtime 保持 idle,不让 `ccl load` 或 Runtime 失败。
|
|
210
209
|
|
|
@@ -267,4 +266,4 @@ Owner 启动时从 `gameplay.json` 计算启用的感知模块,并从根 `conf
|
|
|
267
266
|
|
|
268
267
|
配置解析器会拒绝非正整数补读上限、未知 Event type 或 delivery 值。配置在 Owner 启动时冻结,本局运行期间不会因文件变化而改变。
|
|
269
268
|
|
|
270
|
-
|
|
269
|
+
本地感知入口放在 `<workspace>/user-data/accounts/<account-hash>/capabilities/perceptions/`,默认导出一个 `ClawclawPerception` 子类;其静态 manifest 声明模块 ID、主体范围和可生成 Event type。安装模块、选择模块和选择 Event 投递方式是三个独立动作。完整输入、输出、切片生命周期与安全限制见 [开发 Perception](./custom-modules/perception.md)。
|
|
@@ -135,9 +135,9 @@ long 不等于 fallback。用户和 Agent 都可以立即启动 long;fallback
|
|
|
135
135
|
## 文件放在哪里
|
|
136
136
|
|
|
137
137
|
```text
|
|
138
|
-
<workspace>/user-data/accounts/<account-hash>/behaviors
|
|
139
|
-
<workspace>/user-data/accounts/<account-hash>/perceptions
|
|
140
|
-
<workspace>/user-data/accounts/<account-hash>/triggers
|
|
138
|
+
<workspace>/user-data/accounts/<account-hash>/capabilities/behaviors/*.ts
|
|
139
|
+
<workspace>/user-data/accounts/<account-hash>/capabilities/perceptions/*.ts
|
|
140
|
+
<workspace>/user-data/accounts/<account-hash>/capabilities/triggers/*.ts
|
|
141
141
|
```
|
|
142
142
|
|
|
143
143
|
`ccl behavior list/info`、`ccl perception --list`、`ccl trigger list/info` 和 `ccl load` 在判断第三方模块是否静态可识别时,只读取源码文本和字面量 Manifest,不执行第三方源码。
|
|
@@ -274,7 +274,7 @@ Hub 的 `strategy` 资源在 CCL 0.8.x 中就是这一合同的 Behavior。当
|
|
|
274
274
|
把 `.ts` 或 `.js` 文件放在:
|
|
275
275
|
|
|
276
276
|
```text
|
|
277
|
-
<workspace>/user-data/accounts/<account-hash>/behaviors/
|
|
277
|
+
<workspace>/user-data/accounts/<account-hash>/capabilities/behaviors/
|
|
278
278
|
```
|
|
279
279
|
|
|
280
280
|
静态发现与检查:
|
|
@@ -234,7 +234,7 @@ Trigger 的 Manifest 会被静态扫描器从源码字面量中读取。不要
|
|
|
234
234
|
把 `.ts` 或 `.js` 文件放在:
|
|
235
235
|
|
|
236
236
|
```text
|
|
237
|
-
<workspace>/user-data/accounts/<account-hash>/triggers/
|
|
237
|
+
<workspace>/user-data/accounts/<account-hash>/capabilities/triggers/
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
先静态查看 Manifest,再按需配置;模块默认可用,也可以显式禁用或恢复:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
本页记录官方感知的语义契约。官方感知制品由 Hub loadout 提供,CLI 包不再把这些模块写入用户目录。它们由同一个 `ClawclawPerceptionPlugin` 调度,把当前玩家可见的坐标 State 转成彼此独立的 `visual.*` Canonical Event。
|
|
4
4
|
|
|
5
|
-
实际加载集合以当前账号 `ccl load`
|
|
5
|
+
实际加载集合以当前账号 `ccl load` 为准;感知工作副本统一放在账号 `capabilities/perceptions/`,Hub immutable 版本保存在 revision cache。首次发现的本地感知只需保存一次装配选择。
|
|
6
6
|
|
|
7
7
|
## 模块清单
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -68,6 +68,7 @@ function commandPath(raw) {
|
|
|
68
68
|
if (first === 'competition') return second ? `competition ${second}` : 'competition';
|
|
69
69
|
if (first === 'data') return second ? `data ${second}` : 'data';
|
|
70
70
|
if (first === 'hub') return second ? `hub ${second}` : 'hub';
|
|
71
|
+
if (first === 'capability' || first === 'cap') return second ? `capability ${second}` : 'capability';
|
|
71
72
|
if (first === 'skill') return second ? `skill ${second}` : 'skill';
|
|
72
73
|
if (first === 'start') return second ? `start ${second}` : 'start';
|
|
73
74
|
if (first === 'join') return 'join';
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { spawnSync } from 'child_process';
|
|
2
1
|
import {
|
|
3
2
|
cpSync,
|
|
4
3
|
existsSync,
|
|
4
|
+
lstatSync,
|
|
5
5
|
mkdirSync,
|
|
6
6
|
readFileSync,
|
|
7
|
+
realpathSync,
|
|
8
|
+
renameSync,
|
|
7
9
|
rmSync,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
10
|
+
symlinkSync,
|
|
11
|
+
unlinkSync,
|
|
12
|
+
} from 'node:fs';
|
|
13
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
14
|
+
import { homedir } from 'node:os';
|
|
15
|
+
import { basename, dirname, join, resolve, win32 } from 'node:path';
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
12
17
|
|
|
13
18
|
const SKILL_NAME = 'clawclaw';
|
|
14
|
-
const SKILLS_ADD_TIMEOUT_MS = 60_000;
|
|
15
19
|
|
|
16
20
|
function getOpenClawSkillsDir(homeDir = homedir()) {
|
|
17
21
|
for (const dir of ['.openclaw', '.clawdbot', '.moltbot']) {
|
|
@@ -33,75 +37,108 @@ function defaultCandidateSkillDirs() {
|
|
|
33
37
|
];
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return
|
|
40
|
+
function defaultWorkspaceDir() {
|
|
41
|
+
const configured = process.env.CLAWCLAW_WORKSPACE_DIR?.trim();
|
|
42
|
+
if (configured) return resolve(configured);
|
|
43
|
+
if (process.platform === 'win32') {
|
|
44
|
+
return win32.join(process.env.APPDATA ?? win32.join(homedir(), 'AppData', 'Roaming'), 'clawclaw');
|
|
45
|
+
}
|
|
46
|
+
return join(homedir(), '.clawclaw');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function activeProfile(workspaceDir) {
|
|
50
|
+
const authPath = join(workspaceDir, 'user-data', 'auth.json');
|
|
51
|
+
if (!existsSync(authPath)) return undefined;
|
|
52
|
+
try {
|
|
53
|
+
const auth = JSON.parse(readFileSync(authPath, 'utf8'));
|
|
54
|
+
const key = auth.activeProfile;
|
|
55
|
+
const profile = key && auth.profiles?.[key];
|
|
56
|
+
return profile?.apiKey ? profile : undefined;
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function accountHash(apiKey) {
|
|
63
|
+
return createHash('sha256').update(apiKey).digest('hex').slice(0, 16);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function replaceCanonical(source, target) {
|
|
67
|
+
const stage = `${target}.ccl-stage-${randomUUID()}`;
|
|
68
|
+
const displaced = `${target}.ccl-old-${randomUUID()}`;
|
|
69
|
+
let moved = false;
|
|
70
|
+
try {
|
|
71
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
72
|
+
cpSync(source, stage, { recursive: true, dereference: true, errorOnExist: true });
|
|
73
|
+
if (existsSync(target)) {
|
|
74
|
+
renameSync(target, displaced);
|
|
75
|
+
moved = true;
|
|
76
|
+
}
|
|
77
|
+
renameSync(stage, target);
|
|
78
|
+
if (moved) rmSync(displaced, { recursive: true, force: true });
|
|
79
|
+
} catch (error) {
|
|
80
|
+
rmSync(stage, { recursive: true, force: true });
|
|
81
|
+
if (moved && !existsSync(target) && existsSync(displaced)) {
|
|
82
|
+
try { renameSync(displaced, target); } catch {}
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function linkTarget(source, target) {
|
|
89
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
90
|
+
if (existsSync(target)) {
|
|
91
|
+
if (!lstatSync(target).isSymbolicLink()) {
|
|
92
|
+
throw new Error(`legacy real skill directory is unsupported and was preserved: ${target}`);
|
|
93
|
+
}
|
|
94
|
+
if (resolve(realpathSync(target)) === resolve(source)) return;
|
|
95
|
+
unlinkSync(target);
|
|
96
|
+
}
|
|
97
|
+
symlinkSync(source, target, process.platform === 'win32' ? 'junction' : 'dir');
|
|
43
98
|
}
|
|
44
99
|
|
|
45
100
|
export function syncBundledSkill(options = {}) {
|
|
46
|
-
// Opt-out: hosts that own the clawclaw skill themselves (e.g. the claude-clawclaw
|
|
47
|
-
// channel plugin) set CLAWCLAW_NO_SKILL_SYNC=1 so the CLI never overwrites their skill.
|
|
48
101
|
if (process.env.CLAWCLAW_NO_SKILL_SYNC === '1') {
|
|
49
|
-
return { skipped: true, updatedTargets: 0 };
|
|
102
|
+
return { skipped: true, reason: 'disabled', updatedTargets: 0 };
|
|
50
103
|
}
|
|
51
104
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
52
105
|
const installDir = resolve(options.installDir ?? join(scriptDir, '..'));
|
|
53
106
|
const sourceDir = resolve(installDir, 'skills', SKILL_NAME);
|
|
54
107
|
if (!existsSync(sourceDir)) throw new Error(`bundled skill dir not found: ${sourceDir}`);
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
108
|
+
const workspaceDir = resolve(options.workspaceDir ?? defaultWorkspaceDir());
|
|
109
|
+
const profile = options.profile ?? activeProfile(workspaceDir);
|
|
110
|
+
if (!profile?.apiKey) return { skipped: true, reason: 'no_active_account', updatedTargets: 0 };
|
|
111
|
+
const canonical = join(
|
|
112
|
+
workspaceDir,
|
|
113
|
+
'user-data',
|
|
114
|
+
'accounts',
|
|
115
|
+
accountHash(profile.apiKey),
|
|
116
|
+
'capabilities',
|
|
117
|
+
'skills',
|
|
118
|
+
SKILL_NAME,
|
|
67
119
|
);
|
|
68
|
-
|
|
69
|
-
if (result.error) throw result.error;
|
|
70
|
-
if (typeof result.status === 'number' && result.status !== 0) {
|
|
71
|
-
throw new Error(`skills add exited with code ${result.status}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
120
|
+
replaceCanonical(sourceDir, canonical);
|
|
74
121
|
const targets = options.candidateDirs ?? defaultCandidateSkillDirs();
|
|
75
|
-
for (const target of targets)
|
|
76
|
-
|
|
77
|
-
if (existsSync(resolvedTarget)) rmSync(resolvedTarget, { recursive: true, force: true });
|
|
78
|
-
mkdirSync(dirname(resolvedTarget), { recursive: true });
|
|
79
|
-
cpSync(sourceDir, resolvedTarget, { recursive: true, dereference: true, errorOnExist: true });
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return { skipped: false, updatedTargets: targets.length };
|
|
122
|
+
for (const target of targets) linkTarget(canonical, resolve(target));
|
|
123
|
+
return { skipped: false, canonical, updatedTargets: targets.length };
|
|
83
124
|
}
|
|
84
125
|
|
|
85
|
-
function formatFailure(
|
|
86
|
-
return
|
|
126
|
+
function formatFailure(error) {
|
|
127
|
+
return error?.message ?? String(error);
|
|
87
128
|
}
|
|
88
129
|
|
|
89
130
|
function main() {
|
|
90
131
|
try {
|
|
91
132
|
const result = syncBundledSkill();
|
|
92
133
|
if (result.skipped) {
|
|
93
|
-
console.error(
|
|
94
|
-
return;
|
|
134
|
+
console.error(`[clawclaw-cli] skill sync skipped (${result.reason})`);
|
|
95
135
|
}
|
|
96
|
-
} catch (
|
|
136
|
+
} catch (error) {
|
|
97
137
|
console.error('[clawclaw-cli] Bundled agent skill was not updated.');
|
|
98
|
-
console.error(
|
|
99
|
-
console.error(`[clawclaw-cli] Error: ${formatFailure(err)}`);
|
|
138
|
+
console.error(`[clawclaw-cli] Error: ${formatFailure(error)}`);
|
|
100
139
|
process.exit(1);
|
|
101
140
|
}
|
|
102
141
|
}
|
|
103
142
|
|
|
104
143
|
const entry = process.argv[1] ? pathToFileURL(resolve(process.argv[1])).href : '';
|
|
105
|
-
if (import.meta.url === entry || basename(process.argv[1] ?? '') === 'sync-bundled-skill.mjs')
|
|
106
|
-
main();
|
|
107
|
-
}
|
|
144
|
+
if (import.meta.url === entry || basename(process.argv[1] ?? '') === 'sync-bundled-skill.mjs') main();
|
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clawclaw
|
|
3
3
|
description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始或继续普通匹配、创建或加入好友房,以及进入模拟训练或木桩训练。Use when the user asks to play/start/join/continue a ClawClaw match, friend room, or training room, including “玩一局”“开一局”“再来一局”“玩龙虾杀”“玩 ClawClaw”“玩 myclaw”“创建房间”“加入房间”“好友房”“房间码”“训练一下”“模拟训练”“木桩测试”. If another Hub/local/custom ClawClaw gameplay skill is available, prefer that skill and do not load this official fallback.
|
|
4
|
-
version: 4.8.
|
|
4
|
+
version: 4.8.93
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 龙虾杀(ClawClaw)
|
|
@@ -106,7 +106,7 @@ Claude/Claude Code 的局内行动不要改走 Channel MCP 工具。
|
|
|
106
106
|
|
|
107
107
|
**人设:** 注册流程不追问人设;新账号默认使用“无人设”预设。用户主动要求更换人设时,再按 `references/COMMANDS.md` 的人设选择流程处理。
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
**多终端:** 能力工作副本按账号隔离在 `accounts/<account-hash>/capabilities/`。各终端独立执行 `ccl load`,不要求自动合并;未修改旧版跟随云端,本地修改不会被远端覆盖。旧 `local/hub` 目录不迁移。Skill 只有账号 canonical 副本,`.agents/.claude/.codex/.openclaw` 都是当前 active 账号的软链接。
|
|
110
110
|
|
|
111
111
|
### 3.2 赛前介绍
|
|
112
112
|
|
|
@@ -121,7 +121,9 @@ Claude/Claude Code 的局内行动不要改走 Channel MCP 工具。
|
|
|
121
121
|
ccl load
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`{ schema, context, sync, changes?, capabilities, configuration_warnings, participation }`。`context` 包含有效 Persona 和 Memory 内容;Memory 最多发送前 200 行,收到 `MEMORY_LENGTH_EXCEEDED` 时只使用已发送内容,并在赛后整理完整 memory。`sync` 表示 Hub Workspace 新鲜度;`changes`
|
|
124
|
+
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`{ schema, context, sync, changes?, capabilities, configuration_warnings, participation }`。`context` 包含有效 Persona 和 Memory 内容;Memory 最多发送前 200 行,收到 `MEMORY_LENGTH_EXCEEDED` 时只使用已发送内容,并在赛后整理完整 memory。`sync` 表示 Hub Workspace 新鲜度;`changes.cloud_sync` 报告 CCL 自动创建私有资源、新版本或 fork 的成功、失败与冲突;Agent 不执行上传,也不在上传前询问。`capabilities.selection_required` 是首次发现的纯本地资源:只询问玩家一次是否装配,并执行返回 guidance 中明确给出的 `ccl capability equip` 或 `ccl capability unequip`,保存后不重复询问。资源展示优先使用英文 metadata,只有中文 metadata 时保留中文原文。本地修改优先使用;无并发差异时 CCL 自动上传,并发差异时使用本地并让玩家选择 `ccl capability resolve ... --use local|cloud|later`。静态检查绝不 import 或执行源码;可用清单只表示静态契约通过,动态 import/启动仍可能失败并由 Runtime 诊断隔离。`participation` 是执行当刻的后端快照;字段缺失时不要猜。
|
|
125
|
+
|
|
126
|
+
`ccl capability equip` 和 `ccl capability unequip` 立即保存装配状态;Skill 同时立即切换四个宿主链接。`ccl capability resolve ... --use local` 在命令内只上传所选资源,`--use cloud` 在命令内保存草稿并切换工作副本。执行上述任一实际修改后,不得直接运行 `start`、`join` 或好友房开局命令:开局前必须重新执行一次完整 `ccl load`,以最终输出刷新 Persona、能力清单、同步结果和 `participation`;若新的 load 又产生待选择或冲突,处理后再次 load。`--use later` 不修改有效内容,不要求为此重复 load。不要用 `behavior list` 代替这次赛前 load。
|
|
125
127
|
|
|
126
128
|
如果 `participation` 显示后端已有匹配、房间或对局,但当前会话没有健康 Monitor,第一步统一在新的 persistent Monitor 中运行裸 `ccl join`,等待第一条非 error 通知。即使玩家原话是“创建房间”“创建训练房”“加入其他房间”或“开始匹配”,也先跟上现有参与,再判断是否需要切换;这次 `join` 是断线恢复,不是切换,不需要先征求退出确认。
|
|
127
129
|
|
|
@@ -244,6 +246,8 @@ Runtime 使用固定优先级 `reflex > short > long`。服务端角色确定后
|
|
|
244
246
|
|
|
245
247
|
**Behavior 可用性只有一个权威来源:当前账号实时执行的 `ccl behavior list`。** 用户问“有哪些策略/Behavior 可切换”、Agent 要推荐或启动 Behavior、修改 fallback、配置 Trigger 绑定时,都必须先执行该命令;只使用返回中 `loadable: true` 且未禁用的条目。Skill/reference 中的能力说明、命令占位符、旧对局记忆、npm 包文件、源码目录、Runtime loader、Hub 搜索结果和模型知识都不是已安装清单。命令失败时明确说无法确定;成功返回空列表时明确说当前没有可用 Behavior,角色不能执行 Behavior 驱动的移动、任务、等待、跟随或战斗,会 idle/站着不动,但发言、投票和旁白等独立直连命令仍可使用。绝不补出固定/历史列表。`ccl load`、Hub loadout 或本地文件变化后重新查询。
|
|
246
248
|
|
|
249
|
+
纯本地能力文件统一放在当前账号 `capabilities/behaviors|perceptions|personas|skills` 主目录;`drafts` 不扫描、不装配、不上传。Behavior 的 `strategy_type` 由是否存在自主 `finish` 逻辑自动判定为 `long` 或 `short`,玩家不选标签。
|
|
250
|
+
|
|
247
251
|
`ccl load` 的 `capabilities.warnings[]` 表示本地应该进入 CCL、且未被相应 `disabled_*` 禁用,但最终未能装载的 Behavior、Perception、Trigger 或 Persona。必须向用户说明具体资源、文件和 `reason`,不能只复述可用列表或把它说成正常未选择;后端没有下发进账号 snapshot 的资源不在 CCL 可诊断范围内。`configuration_warnings[]` 中的 `FALLBACK_BEHAVIOR_NOT_LOADED` 只表示该角色当前配置的 fallback Behavior 没有加载,不要自动改配置。
|
|
248
252
|
|
|
249
253
|
对列表中的候选运行 `ccl behavior info <id>` 查看完整静态 manifest、输入、runtime 和 `fallback_for_roles`。`list/info` 不执行源码,也不从 CLI 包物化官方资源;`loadable` 不等于已经运行。本地 blacklist 只影响纯本地资源,Hub 资源是否启用由 Hub loadout 决定。输入只按 manifest 组装,不猜字段:
|
|
@@ -20,6 +20,8 @@ reflex > short > long
|
|
|
20
20
|
|
|
21
21
|
Behavior 类本身不分“长类/短类/反射类”;同一个模块由 Runtime 放进哪个 Activation 层,才决定它在控制栈中的位置。模块可以主动返回 completed/failed;`long` 只是持续控制层,不强迫模块永不结束。
|
|
22
22
|
|
|
23
|
+
产品展示另有 `strategy_type`:源码存在自主 `finish` 逻辑时显示为 `short`,否则显示为 `long`。该字段帮助 Agent/玩家选型,不替代实际 Activation 的 `--layer`;真实结束行为仍由模块 Decision 决定。
|
|
24
|
+
|
|
23
25
|
## 2. 发现与输入
|
|
24
26
|
|
|
25
27
|
```bash
|
|
@@ -21,6 +21,11 @@ ccl persona use-hub
|
|
|
21
21
|
ccl persona clear
|
|
22
22
|
ccl persona path
|
|
23
23
|
ccl load # 加载人设、记忆、启用的 Behavior/感知/Trigger + 后端 participation
|
|
24
|
+
ccl capability pending # 首次发现、尚未决定是否装配的纯本地能力
|
|
25
|
+
ccl capability list # 当前账号已保存的本地能力装配选择与云端身份
|
|
26
|
+
ccl capability equip <type/id> # 立即保存“装配”;Skill 同时立即创建四宿主链接
|
|
27
|
+
ccl capability unequip <type/id> # 立即取消装配;Skill 同时移除链接,本地实体保留
|
|
28
|
+
ccl capability resolve <type/id> --use <local|cloud|later> # local 立即上传目标;cloud 立即切换;later 不修改
|
|
24
29
|
ccl data path # 打印可手动打包迁移的 user-data 目录
|
|
25
30
|
ccl behavior list # 查看全部静态发现的 Behavior 及禁用状态
|
|
26
31
|
ccl behavior info <id> # 查看 manifest、输入、runtime、fallback 角色
|
|
@@ -39,7 +44,9 @@ ccl trigger enable <id> # 启用并尝试热应用到当前
|
|
|
39
44
|
ccl trigger disable <id> # 禁用并尝试热应用到当前 Runtime
|
|
40
45
|
```
|
|
41
46
|
|
|
42
|
-
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`context`、`sync`、可选 `changes`、`capabilities`、`configuration_warnings` 和 `participation`。`
|
|
47
|
+
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`context`、`sync`、可选 `changes`、`capabilities`、`configuration_warnings` 和 `participation`。`changes.cloud_sync` 是自动上传结果,`capabilities.selection_required` 是只需选择一次的本地装配项。`capabilities.warnings` 必须逐项说明本地应装载但失败的 Behavior、Perception、Trigger 或 Persona 及原因。并发差异不会自动上传,先用本地并让玩家选择;选择本地的命令立即上传目标资源,选择云端会立即把本地保存到 `drafts` 并切换工作副本。`FALLBACK_BEHAVIOR_NOT_LOADED` 只表示该角色配置的 fallback Behavior 没有加载,不自动改配置。这些命令只静态读取 Manifest,绝不 import 或执行源码;可用清单不代表模块已经运行。
|
|
48
|
+
|
|
49
|
+
执行 `ccl capability equip`、`unequip`、`resolve --use local` 或 `resolve --use cloud` 后,修改本身已经生效,但 Agent 在任何 `start`、`join` 或好友房开局操作前必须再运行一次完整 `ccl load`,以最终输出刷新上下文、同步结果、能力清单和 participation。`resolve --use later` 不修改有效内容,不触发这条复核要求。
|
|
43
50
|
|
|
44
51
|
### 注册流程详情
|
|
45
52
|
|
|
@@ -85,7 +92,7 @@ N+1. 自定义人设
|
|
|
85
92
|
- 用户要恢复 Hub 当前装配的人设:运行 `ccl persona use-hub`。
|
|
86
93
|
- 用户明确不要人设:运行 `ccl persona clear`。
|
|
87
94
|
|
|
88
|
-
|
|
95
|
+
人设文件按账号隔离,唯一工作副本位于 `capabilities/personas/`;云端不可编辑版本只保存在 revision cache。`ccl load` 直接读取选中的源文件,不再生成或读取活动 `persona.md`。`ccl persona path` 返回当前实际选中源文件;后续编辑只影响该账号。
|
|
89
96
|
|
|
90
97
|
### 多终端迁移
|
|
91
98
|
|
|
@@ -20,8 +20,10 @@ ccl hub sync <type>/<resource-id> --json
|
|
|
20
20
|
|
|
21
21
|
- `hub install`:加入云端 Workspace,不自动装配。
|
|
22
22
|
- Hub 页面选择:写入当前 Loadout。
|
|
23
|
-
- `ccl load`:读取当前 Loadout,并在本地/base/remote 三方比较后决定实际内容。未修改的线上旧版跟随 Hub
|
|
24
|
-
-
|
|
23
|
+
- `ccl load`:读取当前 Loadout,并在本地/base/remote 三方比较后决定实际内容。未修改的线上旧版跟随 Hub 更新;玩家本地修改优先使用,并由 CCL 自动创建私有版本或 fork。
|
|
24
|
+
- 纯本地主目录中的合法能力自动创建私有 v1,不自动公开或装配云端副本。`drafts` 永不自动上传。
|
|
25
|
+
- 并发差异不自动上传;Agent 让玩家选择本地、云端或暂不处理。选择本地的命令立即只上传目标资源,选择云端的命令立即把本地修改保存为草稿并切换工作副本。
|
|
26
|
+
- `ccl capability equip` 和 `ccl capability unequip` 立即保存本地装配状态;Skill 同时立即更新四个宿主链接。执行 equip、unequip、选择本地或选择云端后,Agent 开局前必须重新运行完整 `ccl load` 复核最终上下文与 participation。选择 later 不修改内容,不要求因此重复 load。
|
|
25
27
|
- `hub sync`:把一个已安装 Workspace 项切到市场当前公开版本;之后仍由 `ccl load` 应用。
|
|
26
28
|
|
|
27
29
|
## 0.8.x Strategy
|
package/src/cli.ts
CHANGED
|
@@ -30,6 +30,7 @@ import { createSetupCommand } from './commands/setup/index.js';
|
|
|
30
30
|
import { createConfigCommand } from './commands/config.js';
|
|
31
31
|
import { createSchemaCommand } from './commands/_schema.js';
|
|
32
32
|
import { createCompetitionCommand } from './commands/competition.js';
|
|
33
|
+
import { createCapabilityCommand } from './commands/capability.js';
|
|
33
34
|
import { initHttpKeepAlive } from './lib/http-keepalive.js';
|
|
34
35
|
import { applyWorkspaceArgv } from './lib/workspace-argv.js';
|
|
35
36
|
import { invalidAccountMessage, malformedApiKeyMessage } from './lib/account-guidance.js';
|
|
@@ -59,6 +60,7 @@ program.addCommand(createJoinCommand());
|
|
|
59
60
|
program.addCommand(createGameCommand());
|
|
60
61
|
program.addCommand(createAccountCommand());
|
|
61
62
|
program.addCommand(createCompetitionCommand());
|
|
63
|
+
program.addCommand(createCapabilityCommand());
|
|
62
64
|
program.addCommand(createLoadCommand());
|
|
63
65
|
program.addCommand(createMemoryCommand());
|
|
64
66
|
program.addCommand(createPersonaCommand());
|
package/src/commands/behavior.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import { BEHAVIOR_PLUGIN_API_VERSION, type BehaviorActivationLayer } from '../sdk/behavior-plugin/index.js';
|
|
17
17
|
import {
|
|
18
18
|
behaviorSourceCompatibilityError,
|
|
19
|
-
listClawclawBehaviorSources,
|
|
20
19
|
} from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
21
20
|
import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
|
|
22
21
|
import {
|
|
@@ -34,6 +33,13 @@ import {
|
|
|
34
33
|
type CommandIo,
|
|
35
34
|
type ShortCommandOperationResult,
|
|
36
35
|
} from '../short-command/runner.js';
|
|
36
|
+
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
37
|
+
import {
|
|
38
|
+
capabilityEntryForPath,
|
|
39
|
+
classifyStrategyLifecycle,
|
|
40
|
+
setCapabilitySelection,
|
|
41
|
+
} from '../lib/capability-workspace.js';
|
|
42
|
+
import { readFileSync } from 'node:fs';
|
|
37
43
|
|
|
38
44
|
const OWNER_CONTROL_TIMEOUT_MS = 30_000;
|
|
39
45
|
const MAX_BEHAVIOR_RUNTIME_MS = 120_000;
|
|
@@ -115,6 +121,7 @@ function sourceEntry(
|
|
|
115
121
|
inputs: source.inputs,
|
|
116
122
|
produces: source.produces ?? [],
|
|
117
123
|
...(source.runtime === undefined ? {} : { runtime: source.runtime }),
|
|
124
|
+
strategy_type: classifyStrategyLifecycle(readFileSync(source.sourcePath, 'utf8')),
|
|
118
125
|
source: source.management.source,
|
|
119
126
|
managed_by: source.management.managedBy,
|
|
120
127
|
...(source.management.publisher ? { publisher: source.management.publisher } : {}),
|
|
@@ -265,19 +272,23 @@ function activeProfile(dependencies: BehaviorCommandDependencies): AuthProfile {
|
|
|
265
272
|
function discoveredSources(profile: Pick<AuthProfile, 'apiKey'>) {
|
|
266
273
|
const workspaceDir = getWorkspaceDir();
|
|
267
274
|
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
268
|
-
const
|
|
275
|
+
const localCapabilities = discoverLocalCapabilities(workspaceDir, profile).behaviors;
|
|
276
|
+
const local = localCapabilities.map(({ source }) => source);
|
|
277
|
+
const selectedLocal = localCapabilities
|
|
278
|
+
.filter(({ entry }) => entry.selection === 'equipped')
|
|
279
|
+
.map(({ source }) => source);
|
|
269
280
|
const snapshot = readLocalAgentWorkspaceSnapshot(workspaceDir, profile);
|
|
270
281
|
const hub = snapshot
|
|
271
282
|
? listAgentWorkspaceBehaviorSources(workspaceDir, profile, snapshot)
|
|
272
283
|
: [];
|
|
273
|
-
return { local, hub };
|
|
284
|
+
return { local, selectedLocal, hub };
|
|
274
285
|
}
|
|
275
286
|
|
|
276
287
|
function sources(
|
|
277
288
|
profile: Pick<AuthProfile, 'apiKey'>,
|
|
278
289
|
disabledLocalIds: ReadonlySet<string> = new Set(),
|
|
279
290
|
): readonly ManagedClawclawBehaviorSource[] {
|
|
280
|
-
const { local, hub } = discoveredSources(profile);
|
|
291
|
+
const { selectedLocal: local, hub } = discoveredSources(profile);
|
|
281
292
|
return mergeAgentWorkspaceBehaviorSources(
|
|
282
293
|
local.filter(({ id }) => !disabledLocalIds.has(id)),
|
|
283
294
|
hub,
|
|
@@ -288,14 +299,25 @@ function inventorySources(
|
|
|
288
299
|
profile: Pick<AuthProfile, 'apiKey'>,
|
|
289
300
|
disabledLocalIds: ReadonlySet<string>,
|
|
290
301
|
): readonly ManagedClawclawBehaviorSource[] {
|
|
291
|
-
const { local, hub } = discoveredSources(profile);
|
|
302
|
+
const { local, selectedLocal, hub } = discoveredSources(profile);
|
|
292
303
|
const effective = mergeAgentWorkspaceBehaviorSources(
|
|
293
|
-
|
|
304
|
+
selectedLocal.filter(({ id }) => !disabledLocalIds.has(id)),
|
|
294
305
|
hub,
|
|
295
306
|
);
|
|
296
307
|
const effectiveIds = new Set(effective.map(({ id }) => id));
|
|
297
308
|
const disabledOnly = mergeAgentWorkspaceBehaviorSources(
|
|
298
|
-
local.filter((
|
|
309
|
+
local.filter((source) => (
|
|
310
|
+
!effectiveIds.has(source.id)
|
|
311
|
+
&& (
|
|
312
|
+
disabledLocalIds.has(source.id)
|
|
313
|
+
|| capabilityEntryForPath(
|
|
314
|
+
getWorkspaceDir(),
|
|
315
|
+
profile,
|
|
316
|
+
'behavior',
|
|
317
|
+
source.sourcePath,
|
|
318
|
+
)?.selection !== 'equipped'
|
|
319
|
+
)
|
|
320
|
+
)),
|
|
299
321
|
[],
|
|
300
322
|
);
|
|
301
323
|
return [...effective, ...disabledOnly];
|
|
@@ -310,7 +332,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
310
332
|
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
311
333
|
const directory = profile
|
|
312
334
|
? getUserDataAccountBehaviorsDir(workspaceDir, profile)
|
|
313
|
-
: '<active-account>/behaviors
|
|
335
|
+
: '<active-account>/capabilities/behaviors';
|
|
314
336
|
return `\nBehavior modules:\n Place .ts or .js files in ${directory}\n Discovery reads static manifests without executing module code.\n`;
|
|
315
337
|
});
|
|
316
338
|
|
|
@@ -321,6 +343,14 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
321
343
|
const profile = activeProfile(dependencies);
|
|
322
344
|
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
323
345
|
const disabled = new Set(gameplay.disabled_behaviors);
|
|
346
|
+
for (const source of discoveredSources(profile).local) {
|
|
347
|
+
if (capabilityEntryForPath(
|
|
348
|
+
workspaceDir,
|
|
349
|
+
profile,
|
|
350
|
+
'behavior',
|
|
351
|
+
source.sourcePath,
|
|
352
|
+
)?.selection !== 'equipped') disabled.add(source.id);
|
|
353
|
+
}
|
|
324
354
|
const discovered = inventorySources(profile, disabled);
|
|
325
355
|
const entries = discovered.map((source) => sourceEntry(source, disabled));
|
|
326
356
|
console.log(JSON.stringify({
|
|
@@ -339,6 +369,14 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
339
369
|
const profile = activeProfile(dependencies);
|
|
340
370
|
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
341
371
|
const disabled = new Set(gameplay.disabled_behaviors);
|
|
372
|
+
for (const source of discoveredSources(profile).local) {
|
|
373
|
+
if (capabilityEntryForPath(
|
|
374
|
+
workspaceDir,
|
|
375
|
+
profile,
|
|
376
|
+
'behavior',
|
|
377
|
+
source.sourcePath,
|
|
378
|
+
)?.selection !== 'equipped') disabled.add(source.id);
|
|
379
|
+
}
|
|
342
380
|
const source = inventorySources(profile, disabled).find((candidate) => candidate.id === id);
|
|
343
381
|
if (!source) throw new Error(`Unknown behavior module '${id}'.`);
|
|
344
382
|
console.log(JSON.stringify({
|
|
@@ -377,6 +415,9 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
377
415
|
);
|
|
378
416
|
}
|
|
379
417
|
}
|
|
418
|
+
if (local) {
|
|
419
|
+
setCapabilitySelection(workspaceDir, profile, 'behavior', id, !disabled);
|
|
420
|
+
}
|
|
380
421
|
const updated = updateGameplayConfig((current) => {
|
|
381
422
|
current.disabled_behaviors = disabled
|
|
382
423
|
? [...current.disabled_behaviors, id]
|