@myclaw163/clawclaw-cli 0.9.2 → 0.10.2
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/QUICKSTART.md +1 -1
- package/QUICKSTART_OTHER.md +13 -12
- package/README.md +7 -8
- package/bin/clawclaw-channel.mjs +2 -2
- package/bin/clawclaw-cli.mjs +2 -2
- package/docs/configuration.md +27 -101
- package/docs/custom-modules/README.md +23 -35
- package/docs/custom-modules/api-reference.md +95 -273
- package/docs/custom-modules/behavior.md +94 -78
- package/docs/custom-modules/examples/auto-escape.ts +5 -5
- package/docs/custom-modules/examples/go-to-point.ts +11 -11
- package/docs/custom-modules/examples/nearby-reflex.ts +2 -2
- package/docs/custom-modules/examples/task-reminder.ts +4 -5
- package/docs/custom-modules/perception.md +42 -603
- package/docs/custom-modules/skill.md +12 -10
- package/docs/desktop-event-push.md +3 -3
- package/docs/runtime/README.md +16 -17
- package/docs/runtime/agent-notifications.md +42 -12
- package/docs/runtime/behavior-runtime.md +47 -46
- package/docs/runtime/components-and-boundaries.md +70 -28
- package/docs/runtime/events-and-state.md +41 -18
- package/docs/runtime/framework-package.md +73 -0
- package/docs/runtime/official-perception-modules.md +5 -5
- package/docs/runtime/owner-lifecycle-and-observability.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +8 -9
- package/docs/user-guide/README.md +10 -7
- package/docs/user-guide/api-reference.md +81 -164
- package/docs/user-guide/behavior.md +84 -68
- package/docs/user-guide/installation.md +7 -7
- package/docs/user-guide/perception.md +42 -586
- package/docs/user-guide/skill.md +12 -10
- package/package.json +24 -9
- package/scripts/check-framework-boundaries.mjs +27 -0
- package/scripts/check-skill-command-surface.mjs +20 -23
- package/scripts/enable_ccl_permissions.cjs +4 -0
- package/scripts/install-local-runtime.mjs +35 -0
- package/scripts/postinstall.mjs +1 -1
- package/scripts/qa-install.mjs +105 -0
- package/scripts/sync-bundled-skill.mjs +35 -28
- package/skills/clawclaw/SKILL.md +53 -57
- package/skills/clawclaw/references/BEHAVIORS.md +43 -83
- package/skills/clawclaw/references/CHANNELS.md +2 -2
- package/skills/clawclaw/references/COMMANDS.md +62 -103
- package/skills/clawclaw/references/HUB.md +2 -2
- package/skills/clawclaw/references/STREAM.md +8 -8
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/skills/clawclaw-creator/SKILL.md +82 -0
- package/skills/{clawclaw → clawclaw-creator}/references/CUSTOM-BEHAVIOR-DEVELOPMENT.md +95 -79
- package/skills/{clawclaw → clawclaw-creator}/references/CUSTOM-MODULE-API.md +95 -180
- package/skills/{clawclaw → clawclaw-creator}/references/CUSTOM-MODULES.md +26 -24
- package/skills/clawclaw-creator/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +126 -0
- package/skills/clawclaw-creator/references/CUSTOM-PERSONA-DEVELOPMENT.md +29 -0
- package/skills/clawclaw-creator/references/CUSTOM-SKILL-DEVELOPMENT.md +69 -0
- package/skills/clawclaw-creator/references/SYNC-AND-REPORT.md +36 -0
- package/src/channel/claude-channel-ipc-server.ts +1 -0
- package/src/cli.ts +4 -2
- package/src/commands/behavior.ts +26 -10
- package/src/commands/capability.ts +17 -14
- package/src/commands/load.ts +5 -3
- package/src/commands/perception.ts +5 -0
- package/src/commands/skill.ts +34 -29
- package/src/commands/strategy.ts +2 -0
- package/src/commands/upgrade.ts +2 -2
- package/src/lib/agent-workspace-skills.ts +20 -13
- package/src/lib/capability-cloud-sync.ts +2 -1
- package/src/lib/capability-discovery.ts +2 -1
- package/src/lib/capability-load-diagnostics.ts +3 -3
- package/src/lib/capability-workspace.ts +2 -1
- package/src/lib/game-client.ts +7 -1
- package/src/lib/package-skills.ts +4 -0
- package/src/lib/perception-config.ts +18 -6
- package/src/lib/runtime-cadence-config.ts +16 -0
- package/src/lib/skill-host.ts +1 -1
- package/src/lib/workspace-runtime-lock.ts +3 -46
- package/src/pipeline/canonical-event-presentation.ts +23 -124
- package/src/pipeline/event-format.ts +12 -21
- package/src/pipeline/event-hints.ts +6 -6
- package/src/pipeline/game-sync-event-normalization.ts +57 -63
- package/src/runtime/clawclaw/behavior-decision.ts +7 -3
- package/src/runtime/clawclaw/behavior-input.ts +8 -4
- package/src/runtime/clawclaw/behavior-observation-memory.ts +3 -2
- package/src/runtime/clawclaw/notification-policy.ts +42 -0
- package/src/runtime/clawclaw/notification-turn.ts +19 -0
- package/src/runtime/clawclaw/observation-frame-projector.ts +3 -3
- package/src/runtime/clawclaw/owner.ts +47 -9
- package/src/runtime/clawclaw/perception-module-manifest.ts +8 -3
- package/src/runtime/clawclaw/perception-strategy-names.ts +17 -0
- package/src/runtime/clawclaw/persistence-compatibility.ts +36 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +3 -3
- package/src/runtime/clawclaw/plugins/assembly.ts +7 -9
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +1 -495
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +17 -190
- package/src/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.ts +1 -123
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +126 -1779
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +13 -276
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +2 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +3 -180
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.ts +13 -972
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +8 -109
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +2 -2
- package/src/runtime/clawclaw/plugins/derived-event/reminder-plugin.ts +27 -17
- package/src/runtime/clawclaw/plugins/derived-event/reminder-runner.ts +1 -0
- package/src/runtime/clawclaw/plugins/derived-event/state-change-rules.ts +3 -3
- package/src/runtime/clawclaw/plugins/derived-event/task-change-tracker.ts +1 -259
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +4 -4
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +9 -97
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +8 -343
- package/src/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.ts +15 -20
- package/src/runtime/clawclaw/plugins/mailbox/adapters/game-sync-runtime-report-adapter.ts +59 -0
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +60 -572
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +6 -434
- package/src/runtime/clawclaw/plugins/mailbox/index.ts +1 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +1 -266
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +6 -161
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +4 -23
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +49 -752
- package/src/runtime/clawclaw/plugins/perception/map-concurrent.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/notification-content.ts +60 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-plugin.ts +125 -297
- package/src/runtime/clawclaw/plugins/perception/perception-module-runner.ts +7 -56
- package/src/runtime/clawclaw/plugins/perception/perception-module-worker.ts +11 -33
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +25 -10
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +12 -6
- package/src/runtime/clawclaw/plugins/perception/report-content.ts +50 -0
- package/src/runtime/clawclaw/plugins/perception/task-baseline.ts +29 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +6 -0
- package/src/runtime/clawclaw/plugins/system-perception/rule-runner.ts +107 -0
- package/src/runtime/clawclaw/plugins/system-perception/system-perceptions.ts +107 -0
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +8 -3
- package/src/runtime/clawclaw/reaction-behavior-resolution.ts +1 -23
- package/src/runtime/clawclaw/reminder-manifest.ts +5 -2
- package/src/runtime/clawclaw/runtime-cadence.ts +24 -0
- package/src/runtime/clawclaw/runtime-state.ts +11 -0
- package/src/runtime/clawclaw/runtime.ts +8 -0
- package/src/runtime/clawclaw/strategy-memory-rpc.ts +1 -63
- package/src/runtime/clawclaw/strategy-memory.ts +1 -77
- package/src/runtime/clawclaw-event-catalog.ts +12 -12
- package/src/runtime/framework/action-diagnostics.ts +3 -83
- package/src/runtime/framework/capability-registry.ts +2 -395
- package/src/runtime/framework/contracts.ts +2 -144
- package/src/runtime/framework/control/control-scheduler.ts +2 -1268
- package/src/runtime/framework/control/domain-set.ts +2 -81
- package/src/runtime/framework/control/index.ts +1 -3
- package/src/runtime/framework/control/types.ts +2 -191
- package/src/runtime/framework/control-coordinator.ts +2 -11
- package/src/runtime/framework/events/event-catalog.ts +2 -74
- package/src/runtime/framework/events/event-delivery-service.ts +2 -200
- package/src/runtime/framework/events/event-ingress.ts +2 -99
- package/src/runtime/framework/events/event-repository.ts +2 -82
- package/src/runtime/framework/events/index.ts +2 -7
- package/src/runtime/framework/events/memory-event-repository.ts +2 -1100
- package/src/runtime/framework/events/runtime-resume.ts +2 -20
- package/src/runtime/framework/events/sqlite-event-repository.ts +5 -2280
- package/src/runtime/framework/events/test-helpers.ts +1 -1
- package/src/runtime/framework/events/types.ts +2 -312
- package/src/runtime/framework/index.ts +3 -7
- package/src/runtime/framework/load-node-sqlite.ts +2 -17
- package/src/runtime/framework/mailbox/coalescer.ts +2 -83
- package/src/runtime/framework/mailbox/host-notification-sink.ts +2 -44
- package/src/runtime/framework/mailbox/identity.ts +2 -38
- package/src/runtime/framework/mailbox/index.ts +1 -7
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +2 -282
- package/src/runtime/framework/mailbox/mailbox-repository.ts +2 -44
- package/src/runtime/framework/mailbox/notification-projector.ts +2 -65
- package/src/runtime/framework/mailbox/types.ts +2 -145
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -154
- package/src/runtime/framework/modules/runtime-module-loader.ts +7 -51
- package/src/runtime/framework/modules/runtime-module-output.ts +2 -24
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -23
- package/src/runtime/framework/participation-manager.ts +2 -253
- package/src/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -77
- package/src/runtime/framework/persistence/memory-first-persistence.ts +4 -489
- package/src/runtime/framework/plugins/contracts.ts +2 -396
- package/src/runtime/framework/plugins/index.ts +1 -4
- package/src/runtime/framework/plugins/runtime-event-identity.ts +2 -17
- package/src/runtime/framework/plugins/runtime-input-journal.ts +2 -866
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +2 -2071
- package/src/runtime/framework/runtime.ts +5 -1843
- package/src/runtime/framework/serial-task-queue.ts +2 -14
- package/src/runtime/framework/state/contracts.ts +2 -49
- package/src/runtime/framework/state/current-state-store.ts +2 -184
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +2 -209
- package/src/runtime/framework/state/freshness.ts +2 -72
- package/src/runtime/framework/state/history/contracts.ts +2 -158
- package/src/runtime/framework/state/history/history-writer.ts +2 -194
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +2 -230
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +2 -648
- package/src/runtime/framework/state/history/trajectory-projector.ts +2 -209
- package/src/runtime/framework/state/index.ts +1 -13
- package/src/runtime/framework/state/state-ingress.ts +2 -95
- package/src/runtime/framework/state/state-provider.ts +2 -62
- package/src/runtime/framework/state/types.ts +2 -155
- package/src/runtime/game-sync-ingress-protocol.ts +3 -2
- package/src/runtime/game-sync-ingress-worker.ts +7 -1
- package/src/runtime/game-sync-protocol.ts +64 -4
- package/src/runtime/host-monitor-rate-gate.ts +1 -123
- package/src/runtime/mailbox-host-relay.ts +1 -326
- package/src/runtime/observability/detail-capture.ts +4 -108
- package/src/runtime/observability/process-timing.ts +2 -59
- package/src/runtime/observability/recorder.ts +2 -238
- package/src/runtime/observability/redaction.ts +2 -181
- package/src/runtime/observability/reporter.ts +2 -154
- package/src/runtime/observability/sinks.ts +2 -135
- package/src/runtime/observability/types.ts +2 -92
- package/src/runtime/owner-control.ts +45 -320
- package/src/runtime/parent-process-watch.ts +1 -51
- package/src/runtime/process-identity.ts +1 -72
- package/src/runtime/threaded-ws-client.ts +11 -2
- package/src/runtime/ws-client.ts +6 -0
- package/src/sdk/behavior-plugin/index.ts +9 -3
- package/src/sdk/index.ts +40 -2
- package/src/sdk/module-input/index.ts +5 -0
- package/src/sdk/perception-plugin/index.ts +3 -1
- package/src/sdk/perception-plugin/module.ts +12 -2
- package/src/sdk/perception-plugin/reminder-rules.ts +8 -42
- package/src/sdk/perception-plugin/reminder.ts +2 -1
- package/src/sdk/perception-plugin/task-change-tracker.ts +258 -0
- package/src/sdk/strategy-memory.ts +1 -12
- package/src/sdk/strategy-plugin/index.ts +36 -0
- package/src/sdk/trigger-plugin/index.ts +1 -0
- package/docs/custom-modules/trigger.md +0 -295
- package/skills/clawclaw/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +0 -692
- package/skills/clawclaw/references/CUSTOM-SKILL-DEVELOPMENT.md +0 -67
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
# 自定义模块开发
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CCL 内置玩家、任务、能力、紧急任务、房间与流程、会议、策略消息七类感知,强制启用且不可配置;Hub/社区模块另外装配。自定义感知只读 Source/后端原始事实和状态,各感知互不依赖。策略事件由内置感知在后续轮次转发。
|
|
4
4
|
|
|
5
|
-
普通任务变化的可配置提醒已支持;固定倒计时和能力通知继续由 CCL 负责,见[自定义局内提醒感知](./CUSTOM-PERCEPTION-DEVELOPMENT.md#提醒型感知)。新脚本可通过 API v3 的统一输入调用提醒辅助算法,已有 API v2 脚本保留兼容。
|
|
6
5
|
|
|
6
|
+
感知使用统一 Perception API v3,持续观察、记忆和通知,并可通过固定绑定请求反射。感知和策略分别安装、分别装配,由 Strategy 插件仲裁并执行。
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
内置任务提醒始终启用;社区脚本可追加自己的提醒,不能关闭内置通知。固定倒计时和能力通知由相应内置感知负责,见[自定义局内提醒感知](./CUSTOM-PERCEPTION-DEVELOPMENT.md#内置感知与自定义感知)。感知使用统一 API v3,自定义模块提供职责不同的判断。
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
本文说明 Strategy 和 Perception 的接口边界。创建和编辑统一遵循 [创作流程](../SKILL.md),写完后由 Agent 完成装配、私有同步和用户汇报。现有模块满足需求时,直接选择和配置即可;需要新的玩法或新的视觉事实时,可以编写社区模块。
|
|
9
12
|
|
|
10
13
|
## 可以自定义什么
|
|
11
14
|
|
|
12
15
|
| 资源 | 用途 | 代码入口 |
|
|
13
16
|
|---|---|---|
|
|
14
|
-
| 策略 | 决定并请求具体动作,由独立感知请求自动反射 | 默认导出 `
|
|
17
|
+
| 策略 | 决定并请求具体动作,由独立感知请求自动反射 | 默认导出 `ClawclawStrategy` |
|
|
15
18
|
| 感知 | 组合观察、提醒和通知控制 | `ClawclawPerception.evaluate(input)`,API v3 |
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
统一感知共用同一输入输出,一个脚本可组合多种能力。策略的 long、short、reflex 仍是同一模块的三种运行方式。
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
策略与感知各自使用 API v3。版本独立演进,现有默认策略类不要求新增字段。
|
|
20
23
|
|
|
21
24
|
## 官方已经支持什么
|
|
22
25
|
|
|
23
|
-
###
|
|
26
|
+
### Strategy
|
|
24
27
|
|
|
25
|
-
官方
|
|
28
|
+
官方 Strategy 从当前账号 Hub loadout 获取;CLI 包不再把官方 Strategy 物化到本地目录。
|
|
26
29
|
|
|
27
30
|
查看当前账号的准确清单和参数:
|
|
28
31
|
|
|
29
32
|
```powershell
|
|
30
|
-
ccl
|
|
31
|
-
ccl
|
|
33
|
+
ccl strategy list
|
|
34
|
+
ccl strategy info <id>
|
|
32
35
|
```
|
|
33
36
|
|
|
34
37
|
### Perception
|
|
@@ -45,25 +48,24 @@ ccl perception --list
|
|
|
45
48
|
|
|
46
49
|
- 控制角色行动、理解反射与抢占:[策略教程](./CUSTOM-BEHAVIOR-DEVELOPMENT.md)
|
|
47
50
|
- 先确定需要哪类感知:[感知开发总览](./CUSTOM-PERCEPTION-DEVELOPMENT.md)
|
|
48
|
-
-
|
|
49
|
-
- 配置任务和附近发言提醒:[提醒型感知](./CUSTOM-PERCEPTION-DEVELOPMENT.md#提醒型感知)
|
|
51
|
+
- 配置任务和附近发言提醒:[提醒型感知](./CUSTOM-PERCEPTION-DEVELOPMENT.md#内置感知与自定义感知)
|
|
50
52
|
- 条件满足后自动行动:策略教程的“独立感知与局中控制”。
|
|
51
53
|
- 查询准确字段和签名:[API 参考](./CUSTOM-MODULE-API.md)
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
首次编写感知,先看开头的统一通知接口,再照首次目击示例理解写法;安装、通知控制、固定反射与记忆在同一文档中说明。策略教程解释动作、结束和控制权交还。
|
|
54
56
|
|
|
55
57
|
## 感知与策略怎样配合
|
|
56
58
|
|
|
57
59
|
```mermaid
|
|
58
60
|
flowchart LR
|
|
59
|
-
Input["当前 State / 可见观察 /
|
|
61
|
+
Input["当前 State / 可见观察 / 源与后端原始事实"] --> Perception["统一感知 API v3"]
|
|
60
62
|
Perception --> Events["提交自己的事件"]
|
|
61
63
|
Events --> Mailbox["Mailbox / Agent"]
|
|
62
|
-
Perception -->|"固定绑定 Reflex 请求,经本局开关"|
|
|
63
|
-
|
|
64
|
+
Perception -->|"固定绑定 Reflex 请求,经本局开关"| Strategy["独立策略执行类"]
|
|
65
|
+
Strategy --> Runtime["Runtime 检查并提交动作"]
|
|
64
66
|
```
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
新感知只读取源与后端原始事实,不依赖其他感知或策略输出。感知独立决定自己的通知,并可请求固定反射,后续权威状态确认动作结果。
|
|
67
69
|
|
|
68
70
|
## 策略的三种运行方式
|
|
69
71
|
|
|
@@ -73,7 +75,7 @@ flowchart LR
|
|
|
73
75
|
| `short` | 暂时完成一件有限工作 |
|
|
74
76
|
| `reflex` | 配套独立感知条件命中后请求优先执行即时反应 |
|
|
75
77
|
|
|
76
|
-
三层都使用 `
|
|
78
|
+
三层都使用 `ClawclawStrategy`,优先级为 `reflex > short > long`。手动启动支持 long/short,反射由配套感知请求,默认策略 fallback 是空栈时使用哪个 long 的配置。具体启动、暂停恢复与会议边界见[策略教程](./CUSTOM-BEHAVIOR-DEVELOPMENT.md#长期短期和反射)。
|
|
77
79
|
|
|
78
80
|
## 一个模块文件由什么组成
|
|
79
81
|
|
|
@@ -81,9 +83,7 @@ flowchart LR
|
|
|
81
83
|
|
|
82
84
|
| 用途 | 基类 | 回调 |
|
|
83
85
|
|---|---|---|
|
|
84
|
-
| 策略 | `
|
|
85
|
-
| 视觉感知 | `ClawclawPerception` | `update(frame, api)` |
|
|
86
|
-
| 提醒型感知 | `ClawclawReminder` | `update(input)` |
|
|
86
|
+
| 策略 | `ClawclawStrategy` | `decide(input, api)` |
|
|
87
87
|
| 统一感知 | `ClawclawPerception`(API v3) | `evaluate(input, api)` |
|
|
88
88
|
|
|
89
89
|
这些回调的输入和返回值不同,不能把一个示例的字段直接套进另一类。新手先使用对应教程中的完整文件,再查 API 字段。
|
|
@@ -91,15 +91,17 @@ flowchart LR
|
|
|
91
91
|
## 共同的数据边界
|
|
92
92
|
|
|
93
93
|
- `GameState` 是当前玩家视角的权威快照,不是全知世界;
|
|
94
|
-
-
|
|
94
|
+
- Strategy 使用只读输入和查询能力;
|
|
95
95
|
- Perception 不直接发 Action;
|
|
96
96
|
- Action 是请求,不是成功事实;
|
|
97
97
|
- Status 是公开说明,不会修改 `GameState`;
|
|
98
98
|
- Event 是公开结构化事实,不是模块私有 KV;
|
|
99
|
-
-
|
|
99
|
+
- 策略实例字段是运行期内存;策略可选 snapshot 也不提供跨进程持久恢复。感知返回的 state 由 Host 保存为检查点,在同一作用域恢复且检查点可用时使用。新对局和各类模块边界仍会清理相应记忆,详见[感知状态说明](./CUSTOM-PERCEPTION-DEVELOPMENT.md#编写规则)。
|
|
100
100
|
|
|
101
101
|
## 本地编辑、私有同步与公开分享
|
|
102
102
|
|
|
103
|
+
编辑已有策略或感知前,按 [创作流程](../SKILL.md) 先完整 `ccl load` 同步远端装配和工作副本;处理目标冲突后重新 list/info 定位、读取源码,再修改。编辑后再完整 load 同步核验,并向用户汇报。不能只查本地目录就基于旧版本修改,也不能把编辑前的 load 当作编辑后的保存步骤。
|
|
104
|
+
|
|
103
105
|
| 步骤 | 实际作用 |
|
|
104
106
|
|---|---|
|
|
105
107
|
| 本地编辑 | 修改当前账号的可编辑工作副本;保存文件本身不会替换正在运行的模块 |
|
|
@@ -119,7 +121,7 @@ flowchart LR
|
|
|
119
121
|
<workspace>/user-data/accounts/<account-hash>/capabilities/perceptions/*.ts
|
|
120
122
|
```
|
|
121
123
|
|
|
122
|
-
`ccl
|
|
124
|
+
`ccl strategy list/info`、`ccl perception --list` 和 `ccl load` 在判断第三方模块是否静态可识别时,只读取源码文本和字面量 Manifest,不执行第三方源码。
|
|
123
125
|
|
|
124
126
|
模块在实际启用或激活时才会 import。自定义模块与 CCL 进程拥有相同权限,不是安全沙箱;只运行自己编写或已经审查的代码。
|
|
125
127
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# 开发感知
|
|
2
|
+
|
|
3
|
+
感知使用统一 Perception API v3。一个脚本可以识别可见事实、组织提醒和决定自己的通知是否唤醒 Agent,无需声明视觉或提醒类型。新脚本继承 `ClawclawPerception`,实现 `evaluate(input, api)`;可选声明固定策略绑定,在观察和通知的同时请求反射。感知与策略分别装配。
|
|
4
|
+
|
|
5
|
+
## 内置感知与自定义感知
|
|
6
|
+
|
|
7
|
+
CCL 强制启用七类内置感知:玩家、任务、能力、紧急任务、房间与流程、会议、策略消息。内置代码随 CCL 发布,暂不允许用户修改、关闭或配置。Hub 上的官方资源和社区脚本属于可装配的自定义感知,不会替换这些内置模块。
|
|
8
|
+
|
|
9
|
+
所有感知独立读取本轮输入,互不消费对方输出;多个脚本可并行计算,各自按轮次保存检查点。自定义感知只能订阅 Source/后端原始事件,不能订阅 players_changed、tasks_changed、ability.*、meeting_state 等旧系统派生输出。用 gameState/frame 判断这些条件,任务差异可直接用每个模块独立的 taskChanges。
|
|
10
|
+
|
|
11
|
+
策略产生的公开事件先记录,由内置策略消息感知在后续轮次转发;内容、类型、发生时间保留。在感知模块中,只有该内置模块能读取策略事件。退出、断线等固定生命周期消息由系统通道交付。自定义感知的 wakeAgent 只影响自己的通知,不能覆盖内置或其他模块。
|
|
12
|
+
|
|
13
|
+
## 完整例子:首次目击玩家
|
|
14
|
+
|
|
15
|
+
保存下面的完整文件。它读取可见观察帧,用返回的私有 state 去重,产生自己的通知。
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
ClawclawPerception,
|
|
20
|
+
type PerceptionModuleInput,
|
|
21
|
+
type PerceptionModuleResult,
|
|
22
|
+
type PerceptionModuleEvent,
|
|
23
|
+
} from '@myclaw163/clawclaw-cli/perception-plugin';
|
|
24
|
+
|
|
25
|
+
export default class FirstSighting extends ClawclawPerception {
|
|
26
|
+
static readonly manifest = {
|
|
27
|
+
apiVersion: 3,
|
|
28
|
+
id: 'first_sighting',
|
|
29
|
+
description: '首次看见玩家时通知,可与同一脚本中的其他判断组合。',
|
|
30
|
+
consumes: [],
|
|
31
|
+
produces: ['perception.first_sighting'],
|
|
32
|
+
} as const;
|
|
33
|
+
|
|
34
|
+
evaluate(input: PerceptionModuleInput): PerceptionModuleResult {
|
|
35
|
+
const previous = input.state as { seen?: string[] } | undefined;
|
|
36
|
+
const seen = new Set(previous?.seen ?? []);
|
|
37
|
+
const events: PerceptionModuleEvent[] = [];
|
|
38
|
+
for (const player of input.frame?.observation.players ?? []) {
|
|
39
|
+
if (player.observer || seen.has(player.id)) continue;
|
|
40
|
+
seen.add(player.id);
|
|
41
|
+
events.push({ type: 'perception.first_sighting', key: `${input.nowMs}:${player.id}`,
|
|
42
|
+
wakeAgent: true, payload: { text: '第一次看见一名玩家。', player_id: player.id } });
|
|
43
|
+
}
|
|
44
|
+
return { state: { seen: [...seen] }, events };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
这个例子先从 `input.frame.observation.players` 读取可见玩家,跳过自己和已经记录的 ID,再返回事件与下一轮私有状态。`wakeAgent: true` 允许通知唤醒 Agent;改成 false 会保留事件等待后续批次。不需要通知时不加入这条事件,当前 State 和原始输入事实仍保留。
|
|
50
|
+
|
|
51
|
+
## 使用与验证
|
|
52
|
+
|
|
53
|
+
本地创作按 [统一流程](../SKILL.md) 完成:用 `ccl perception -h` 查看当前账号目录,直接写文件,检查后用 `ccl capability list` 获取目标 `selection_ref`,显式执行 `ccl capability equip <selection_ref>`,再完整 `ccl load` 同步。用 `ccl perception --list` 核对准确操作名和 `api_version: 3`、`loadable: true`,最后向用户汇报。装配后,下次正常启动 Runtime 才加载源码;静态可加载不代表已执行成功。网页导入是独立入口,在网页导入并装配后由同账号 load 同步。
|
|
54
|
+
|
|
55
|
+
本地编辑、私有同步和公开上传 Hub 是三个不同步骤。新脚本需要支持 API v3 的 CCL;旧 CCL 不能加载新版脚本,不能仅更新 Hub 文件而忽略客户端版本。
|
|
56
|
+
|
|
57
|
+
## 一个输入,一个结果
|
|
58
|
+
|
|
59
|
+
| 输入 | 内容 |
|
|
60
|
+
|---|---|
|
|
61
|
+
| gameState / frame | 当前玩家权威 State、可见观察帧;缺失时为 null,不代表事实不存在 |
|
|
62
|
+
| events | 声明订阅的 Source/后端原始事实,不包含其他感知或策略的输出 |
|
|
63
|
+
| taskChanges | 各模块独立比较连续权威任务快照得到的变化;对应同轮输入,不订阅内置或其他感知 |
|
|
64
|
+
| scope / nowMs / boundary | 当前作用域、观测时间,以及 initial/recovery 边界 |
|
|
65
|
+
| config / state | Manifest 参数与上一轮提交后的私有检查点 |
|
|
66
|
+
| availableStrategies | 当前可加载的策略操作名 |
|
|
67
|
+
|
|
68
|
+
结果可同时包含 `state`、`events` 和可选 `activations`,也可以只返回其中需要的部分。每次计算使用新实例,跨回调记忆用返回的 state,不能依赖实例字段。阶段、对局或有效状态边界会清理相应记忆;恢复使用检查点,不重放旧通知来触发动作。
|
|
69
|
+
|
|
70
|
+
Manifest 使用 `apiVersion: 3`、`id`、`description`,可声明 `consumes`、`produces`、`inputs`、`config` 、可选固定 `strategies` 绑定与本地化信息。不填写 kind。事件必须在 produces 中声明,并使用稳定的 key 和可序列化 payload;text 可用于直接表达通知。不能冒充击杀、能力就绪或策略生命周期等系统事实。
|
|
71
|
+
|
|
72
|
+
## 通知内容与过滤
|
|
73
|
+
|
|
74
|
+
感知生成通知时确定并保存正文、结构化信息和提示。自定义感知可在 payload 中提供字符串 hint;非字符串 hint 以及旧 next_step/notice 字段由感知执行器过滤。内置感知会先去掉后端或策略原始事件的这些提示字段,再根据自己的固定规则生成提示。原始事件保留用于核查,不因通知过滤而修改。
|
|
75
|
+
|
|
76
|
+
通知通过 notificationOf 关联原事实,另存 notificationContent。投递层只读取已准备的内容,可排版、分批、截断、重试,不从当前 State 补业务字段或重新生成提示。关闭重开、延迟交付和重复投递使用同一份已保存内容。系统生命周期例外由系统通知入口准备内容。
|
|
77
|
+
|
|
78
|
+
meeting_briefing 的 speech_order 完全由后端提供:无字段就不补;Source 可用同一事件的 all_seats 将名字字符串转换为 PlayerRef 数组,并保留原发言顺序。座位表缺失/无效、名字重名或含逗号、名字无法匹配等歧义时保留原字符串并记录诊断,不借用会议 State。显式 State 查询仍可读取当前 meeting 状态。
|
|
79
|
+
|
|
80
|
+
## 通知控制
|
|
81
|
+
|
|
82
|
+
当前 v3 evaluate 按 CCL 本地周期调用,默认 100ms。gameState/frame 可复用最新观察,nowMs 是本地周期时间,cycle 提供 hasNewState、stateVersion、stateReceivedAtMs、stateAgeMs 和 connectionState;frame.timeMs 保持真实观察时间。中间 State 不强制逐帧回放,但后端原始事件按订阅保留。不新增策略与感知共同的 State 历史输入。
|
|
83
|
+
|
|
84
|
+
通知只有三种行为:允许唤醒、静默等待下次唤醒一起交付、不提供给 Agent。前两者沿用 monitor_and_events + wakeAgent:true/false;第三种使用 internal_only,或由模块不生成通知。静默通知也可主动查询,没有独立的“仅查询”模式。运行配置未显式覆盖时,继续采用模块自己的 wakeAgent;配置不能关闭内置强制提醒。
|
|
85
|
+
|
|
86
|
+
通知的异步发送在本轮所有模块处理完成后触发,不等待下一次后端 tick;宿主确认不会阻塞下一轮计算。wakeAgent=false 仍只随后续唤醒一起交付,不因完成一轮而单独唤醒。
|
|
87
|
+
|
|
88
|
+
- 不返回事件:不产生这条通知,仍可保存私有 state。
|
|
89
|
+
- 返回事件且 `wakeAgent: false`:保存为静默事件,等待后续唤醒时一并送达。
|
|
90
|
+
- 返回事件且 `wakeAgent: true` 或省略:允许按投递规则唤醒 Agent。
|
|
91
|
+
|
|
92
|
+
上述选择只控制该模块自己的输出,不能取消原始输入事实或其他模块的通知。感知不能返回 Action 或权威 State 补丁;可通过声明的固定绑定请求反射,由 Strategy 仲裁后执行。
|
|
93
|
+
|
|
94
|
+
## 输入与职责边界
|
|
95
|
+
|
|
96
|
+
API v3 模块只订阅 Source/后端原始事实;读取可见观察不需要等待其他感知。感知不消费其他感知或策略的输出。Runtime 还会按事件生产者隔离输入,不能通过改事件名称绕过。感知返回自己的通知、私有状态及可选固定反射请求,不持有策略控制权。
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
感知与策略分别安装和装配。
|
|
100
|
+
|
|
101
|
+
## 请求固定反射与局中改参
|
|
102
|
+
|
|
103
|
+
感知和策略分别安装、分别装配。感知在 Manifest 声明 `strategies`,绑定键固定到一个已装配策略,结果返回 `activations: [{ strategy: '绑定键', input?, reason? }]`。只允许 Reflex,不能返回任意策略 ID 或直接 Action。绑定支持 `name`、可选 `resourceId`、静态 `input`、`reflexPriority`、`cooldownMs`、`rearm` 和 `maxRuntimeMs`。优先按资源 ID,再按实际操作名/已确认的同源别名解析;缺失只影响该绑定。
|
|
104
|
+
|
|
105
|
+
完整独立文件示例见策略教程的“独立感知与局中控制”。感知仍可在同一个结果里返回 state、events 与 activations:通知是否唤醒由事件决定,自动激活是否获准由运行时开关、作用域、阶段、生死、冷却和优先级决定,两者独立。
|
|
106
|
+
|
|
107
|
+
```powershell
|
|
108
|
+
ccl strategy update community.auto-escape --input '{"x":100,"y":200}'
|
|
109
|
+
ccl perception update community.nearby-reflex --input '{"triggerDistance":180}'
|
|
110
|
+
ccl strategy status community.auto-escape
|
|
111
|
+
ccl perception status community.nearby-reflex
|
|
112
|
+
ccl strategy unwatch community.auto-escape
|
|
113
|
+
ccl strategy watch community.auto-escape
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
`perception update` 更新判断参数,不清除 state 或 api.memory;`strategy update` 更新执行参数,不要求 watch。配套感知和策略装配完成且绑定可用时,自动反射默认开启。`watch/unwatch` 用于局中恢复/关闭所有明确绑定它的感知的自动激活;**unwatch 不停止感知观察和通知,也不禁止它读写记忆**,只撤销关联 Reflex 并拦截后续请求。参数与开关本局有效,换局重置。`availableBindings`/`availableStrategies` 表示可用依赖;`enabledBindings` 进一步表示允许自动激活的绑定,感知可据此避免把关闭期间的命中当成已经执行。
|
|
117
|
+
|
|
118
|
+
`evaluate(input, api)` 的第二个参数提供 `api.memory.get/set/delete`。感知所有绑定都解析到同一个可用策略时,与其共享持续记忆;否则使用模块私有记忆。关闭自动反射、改参和 Worker 重建保留;换局、game_over、Owner 退出清空。input.state 则是每次结果返回的检查点,可在阶段边界清理。不要依赖实例字段或模块全局变量。
|
|
119
|
+
|
|
120
|
+
## 编写规则
|
|
121
|
+
|
|
122
|
+
- 每个感知只负责自己的判断,基础任务与紧急提醒由内置感知负责,不再重复输出。
|
|
123
|
+
- 跨轮状态通过返回的 state 保存;感知与授权绑定策略共享的局内记录使用 api.memory。
|
|
124
|
+
- nowMs 是本地计算时间,frame.timeMs 是实际观察时间;不要把回调次数当作后端帧数。
|
|
125
|
+
- 没有新 State 时也可能被调用,使用 cycle 判断状态版本;原始事件只消费一次。
|
|
126
|
+
- 不直接提交 Action,不读取其他感知的输出。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 人设 Markdown
|
|
2
|
+
|
|
3
|
+
人设定义玩家的声音、性格、称呼和表达偏好。它不改变角色能力、可见信息或游戏命令权限,也不替代主玩法 Skill 的开局、会议和收尾流程。
|
|
4
|
+
|
|
5
|
+
## 写入内容
|
|
6
|
+
|
|
7
|
+
按创作 Skill 确认当前账号的 `capabilities` 目录后,直接写 `personas/<名称>.md`。建议使用简短唯一的文件名;不要覆盖已有同名文件来实现新建。正文是普通 UTF-8 Markdown,无需 Skill frontmatter,不写入当前局身份、座位嫌疑、凭据或临时事件。
|
|
8
|
+
|
|
9
|
+
例如 `calm-analyst.md`:
|
|
10
|
+
|
|
11
|
+
```markdown
|
|
12
|
+
# 冷静分析员
|
|
13
|
+
|
|
14
|
+
说话简洁、冷静,先给判断,再说明可见事实和不确定之处。
|
|
15
|
+
面对玩家用自然口语,面对观战用户解释关键决定,不重复播报每次移动。
|
|
16
|
+
被质疑时回应证据,不凭空捏造亲眼目击;可以按本局阵营目标进行游戏内博弈。
|
|
17
|
+
会议轮到发言时先按玩法流程及时提交,个性表达不拖延操作。
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
根据用户的设定写有区分度的内容,不必固定使用这些小节。编辑已有的人设前先完整 `ccl load` 同步远端选择和内容,处理目标冲突后,再从新的 `ccl persona list` 的 `path` 或当前 `ccl persona path` 定位并读取原文件,保持名称和资源身份。编辑完成后再完整 load 同步核验并向用户汇报;不要用旧的本地人设选择覆盖远端的新选择。
|
|
21
|
+
|
|
22
|
+
## 新建后切为当前人设
|
|
23
|
+
|
|
24
|
+
1. 文件写完后运行 `ccl persona list`,按绝对 `path` 找到该条记录。
|
|
25
|
+
2. 将它的 `selection_ref` 去掉 `persona/` 前缀,执行 `ccl persona use <剩余选择器>`。例如返回 `persona/@abc...`,命令参数就是 `@abc...`;不要猜测同名操作名。
|
|
26
|
+
3. 完整运行 `ccl load`,检查私有入库结果和 `context.persona`;再用 `ccl persona path` 确认当前选中的文件。
|
|
27
|
+
4. 给用户汇报已创建、已保存到库、已切换为当前人设;同步失败时分别说明本地切换和云端保存结果。
|
|
28
|
+
|
|
29
|
+
人设只能选一个,use 会切换当前选择,旧文件保留。新建即使用由 Agent 显式发命令完成;只写文件或执行 list 不会自动选中它。无需调用 `persona create`,也不要直接修改账号选择配置或 registry。
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# 自定义游戏技能
|
|
2
|
+
|
|
3
|
+
游戏技能(Skill)是供 Agent 阅读的操作说明与参考资料,例如会议记录方法、发言流程或阵营线索整理。它不是自动运行的策略或感知模块,也不会因为装配就获得新的游戏 API。持续动作决策使用策略,视觉事实识别使用感知;技能只能指导 Agent 使用当前可用的命令和信息。
|
|
4
|
+
|
|
5
|
+
## 本地创建与修改
|
|
6
|
+
|
|
7
|
+
新技能的实体目录放在当前账号的工作副本中:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
<workspace>/user-data/accounts/<account-hash>/capabilities/skills/my-game-helper/
|
|
11
|
+
SKILL.md
|
|
12
|
+
references/
|
|
13
|
+
examples.md
|
|
14
|
+
scripts/
|
|
15
|
+
helper.py
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
只有 `SKILL.md` 是必需的;附属目录按需创建。正文通过相对路径引用资料。脚本不是自动执行入口,必须说明用途、参数、依赖及何时运行。
|
|
19
|
+
|
|
20
|
+
先按 [创作流程](../SKILL.md) 用 `ccl perception -h` 确认当前账号的 `capabilities` 根目录;这不依赖已有资源。`ccl capability list` 的 `relativePath` 相对于此根目录。不要猜 account-hash;`ccl data path` 只返回总 user-data 目录。
|
|
21
|
+
|
|
22
|
+
不要直接在 `.agents/skills`、`.claude/skills`、`.codex/skills` 或 `.openclaw/skills` 下创建游戏技能实体。这些宿主入口由 CCL 建立目录链接,指向账号工作副本。不要修改 Hub revision cache,也不要覆盖随 CCL 安装的 `clawclaw` 和 `clawclaw-creator` 技能。修改现有技能应找到原工作副本,不另建同名副本。
|
|
23
|
+
|
|
24
|
+
最小示例:
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
---
|
|
28
|
+
name: my-game-helper
|
|
29
|
+
description: Organize visible meeting evidence before speaking.
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# 会议线索整理
|
|
33
|
+
|
|
34
|
+
当玩家要求整理会议线索时使用本技能。
|
|
35
|
+
只依据当前玩家已获得的状态、事件和发言,区分亲眼所见与他人陈述。
|
|
36
|
+
按“事实、来源、尚待确认的问题”整理要点;使用官方 ClawClaw 技能中当前支持的命令行动。
|
|
37
|
+
不要推断不可见身份,不要把动作请求当作执行成功。
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
目录名与 `name` 保持一致。使用唯一名称;名称以字母或数字开头,后续只使用字母、数字、点、下划线或连字符,总长度不超过 128 字符。不要占用官方技能名称 `clawclaw` 或 `clawclaw-creator`。描述说明适用场景,正文写清执行步骤、信息边界和完成条件;不要复制过时的游戏命令、写入凭据或要求绕过官方开局流程。
|
|
41
|
+
|
|
42
|
+
## 本地装配与汇报
|
|
43
|
+
|
|
44
|
+
写好后运行 `ccl capability list`,按文件路径识别本次新建的技能,并使用返回的完整选择器:
|
|
45
|
+
|
|
46
|
+
```powershell
|
|
47
|
+
ccl capability equip <selection_ref>
|
|
48
|
+
ccl load
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
新建技能默认装配,不重复询问。CCL 负责建立宿主链接和自动私有同步;不要把仅注册宿主技能的安装命令当作账号入库流程,也不要手工创建宿主目录链接。核对最终 `capabilities.skills`、同步和宿主链接结果后,通过宿主正常技能入口按名称实际加载一次,再向用户汇报创建/编辑、入库、装配和生效状态。仅用文件工具读取源码不证明宿主已发现它;宿主入口不可用或找不到目标时,说明当前会话尚未确认可用,需要刷新技能列表或开启新会话。不要猜当前项目 `.agents/skills` 就是 CCL 的链接位置。更新已有技能可能需要新会话,不能统一承诺“下次开局生效”。
|
|
52
|
+
|
|
53
|
+
编辑已有技能前先完整 `ccl load`,同步远端装配与内容,处理目标冲突后重新定位、读取工作副本。编辑后再 load 同步核验并汇报,保持同步后的资源身份和装配选择;用户要求改好使用时显式 equip。只保存草稿时放在账号 `drafts/`;未装配不等于不上传。发现其它不属于本次创作的纯本地技能仍由玩家选择,不顺带装配。
|
|
54
|
+
|
|
55
|
+
## 网页导入与公开分享
|
|
56
|
+
|
|
57
|
+
网页导入是另一条独立路径,无需先放进本地账号目录:在当前账号的技能管理入口导入技能文件包,完成装配,再由同一账号执行 `ccl load`。文件包包含 `SKILL.md` 和所需附属文件;ZIP 可直接以 `SKILL.md` 为根,也可包含一层技能文件夹。
|
|
58
|
+
|
|
59
|
+
导入自己的配置、装配使用、上传至 HUB 广场公开分享是不同操作。公开分享按网页对应入口操作;不要把本地创建或自动同步描述成已经公开发布。
|
|
60
|
+
|
|
61
|
+
## 同名真实目录
|
|
62
|
+
|
|
63
|
+
如果某个宿主同名位置已存在真实目录,CCL 保留原文件,只跳过该目录的链接装配;其他宿主照常建立或更新链接,不会因这个冲突移除既有链接。切换账号也按目录分别处理。CCL 不会迁移、覆盖或删除真实目录,也不会因此修改 Hub 装配选择。
|
|
64
|
+
|
|
65
|
+
命令以英文结构化提示返回 `reason: local_skill_directory_exists`、仅包含冲突目录的 `paths` 和 `blocking: false`。每次 `ccl load` 仍遇到此情况都会在 `changes.skills.skipped` 返回提示;Agent 每次应向玩家简短说明这些目录被跳过,其他目录独立处理,不能将它当作整个技能装配失败、开局阻塞或再次询问是否装配。equip 只在所有宿主目录都冲突时返回 `effective: skipped`,部分目录冲突时返回 `effective: immediate` 并附上 `skipped` 提示。
|
|
66
|
+
|
|
67
|
+
取消装配只移除 CCL 管理的链接,真实目录仍保留,仍返回提示。宿主可能继续读取这个本地技能,因此不能承诺技能已从 Agent 完全禁用。玩家以后自行移走真实目录,且该技能仍被选择装配时,下次 `ccl load` 会恢复链接。
|
|
68
|
+
|
|
69
|
+
真实目录跳过不影响开局;其他错误仍按其实际原因处理,不能把权限错误、源文件损坏等都归为同名目录跳过。
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# 同步异常与用户汇报
|
|
2
|
+
|
|
3
|
+
## 核对结果
|
|
4
|
+
|
|
5
|
+
只处理本次创建/编辑的目标,按 `selection_ref`、路径和资源 ID 关联结果。没有错误不等于已经执行:分别核对文件、私有库、装配、运行/宿主生效状态。
|
|
6
|
+
|
|
7
|
+
| 返回情况 | 下一步 |
|
|
8
|
+
|---|---|
|
|
9
|
+
| 编辑前 load 的同步不可用、回退旧快照,或目标更新失败 | 先处理同步问题,暂不基于旧内容修改;不能声称已经取得最新装配或版本 |
|
|
10
|
+
| 编辑前目标发生 fork/替换 | 使用 load 同步后的资源身份,重新 list/info 定位并读取文件,不沿用旧路径 |
|
|
11
|
+
| 本次目标仍在 `selection_required` | 已约定新建默认装配,直接执行对应 equip 或 persona use,再完整 load |
|
|
12
|
+
| `uploaded` 同时有 `failed: equipment` | 内容已入库;不要再次创建/fork。修复装配问题,重试该目标 equip/use,再 load |
|
|
13
|
+
| 内容冲突 `conflicts` | 保留内容,请用户选择 local/cloud/later;用返回的目标引用执行 `ccl capability resolve <引用> --use local\|cloud\|later`,local/cloud 后再 load |
|
|
14
|
+
| `WORKSPACE_INVENTORY_UNAVAILABLE`、网络或 Workspace 同步失败 | 说明本地已保存及尚未确认的云端状态;不要声称入库成功或反复创建 |
|
|
15
|
+
| `skipped: local_origin_unrecognized` | 本地副本仍保留,来源基线不明导致未上传;不要自行按同名资源关联 |
|
|
16
|
+
| `local_skill_directory_exists` | 保留原目录,按返回的 skipped/failed 结果说明宿主链接未生效的范围;不能把云端装配成功当作当前 Agent 已能使用 |
|
|
17
|
+
| `INVALID_SKILL_NAME` / `SKILL_NAME_IMMUTABLE` | 修正新 Skill 的 frontmatter,或恢复已有资源原 name;已有资源不能通过发版本改名 |
|
|
18
|
+
| 创建/fork 的 `SKILL_NAME_CONFLICT` | 核对用户要编辑已有项还是新建另一个名称,不能按同名自动覆盖或关联 |
|
|
19
|
+
| 装配的 `SKILL_NAME_CONFLICT` / `INVALID_LOADOUT` | 告知具体冲突,按服务端提示处理;不自行卸下其它 Skill |
|
|
20
|
+
| `WORKSPACE_REVISION_CONFLICT` | CCL 已进行有限重试,仍失败就说明并发修改,不循环覆盖用户后来在 Hub 的选择 |
|
|
21
|
+
|
|
22
|
+
配置禁用或取消装配不会阻止合法文件参与私有同步。只要草稿就放在账号 `drafts/`,不要为了暂存把文件留在四类发现目录中。
|
|
23
|
+
|
|
24
|
+
## 收尾话术
|
|
25
|
+
|
|
26
|
+
每次任务结束必须主动回复用户,不以工具输出代替。简短表达“【名称】做了什么、保存/装配到了哪一步、什么时候生效”。只有已核实成功才使用“已安装并开启”。
|
|
27
|
+
|
|
28
|
+
- 新建策略/感知:“【名称】已创建完成,已保存到你的库并装配开启,下次开局生效。”若当前没有运行中的 Runtime,可说“下次启动对局时加载”。不把静态检查描述为已通过实战。
|
|
29
|
+
- 编辑已装配策略/感知:“【名称】已编辑并同步到你的库,仍处于装配开启状态,新版本下次开局生效。”
|
|
30
|
+
- 新建人设:“【名称】已创建完成,已保存到你的库,并切换为当前人设。”当前 Agent 按 `load` 返回的内容使用;不要承诺其它已运行会话也已刷新。
|
|
31
|
+
- Skill:“【名称】已创建/编辑完成,已保存到你的库并装配。”只有宿主正常技能入口按名称实际加载成功,才说当前会话可用;没有成功回执就明确说当前会话尚未确认可用,需要刷新技能列表或开启新会话。普通文件读取成功、目录存在或 CCL 装配清单包含名称都不够。不要把所有 Skill 更新都写成“下次开局生效”。
|
|
32
|
+
- 编辑未装配项:“【名称】已编辑并保存到你的库,当前仍未装配。”用户要求改好使用时先执行装配,不用这句话提前结束。
|
|
33
|
+
- 草稿:“【名称】草稿已保存到〈路径〉,尚未入库和装配。”
|
|
34
|
+
- 部分失败:“【名称】内容已保存到库,但装配未完成:〈具体原因〉。〈下一步〉。”如果只保存了本地文件,就明确说“本地已保存,尚未同步到库”。
|
|
35
|
+
|
|
36
|
+
用户不需要查看 registry、账号 hash 或 JSON 才能理解结果。可提供实际文件路径供继续编辑;只有定位失败或冲突时才补必要的技术细节。
|
package/src/cli.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from './commands/communication.js';
|
|
16
16
|
import { createEventsCommand } from './commands/events.js';
|
|
17
17
|
import { createBehaviorCommand } from './commands/behavior.js';
|
|
18
|
+
import { createStrategyCommand } from './commands/strategy.js';
|
|
18
19
|
import { createTriggerCommand } from './commands/trigger.js';
|
|
19
20
|
import { createAccountCommand } from './commands/account.js';
|
|
20
21
|
import { createPeekCommand } from './commands/peek.js';
|
|
@@ -52,8 +53,9 @@ program.addCommand(createSpeakCommand());
|
|
|
52
53
|
program.addCommand(createVoteCommand());
|
|
53
54
|
program.addCommand(createAsideCommand());
|
|
54
55
|
program.addCommand(createEventsCommand());
|
|
55
|
-
program.addCommand(
|
|
56
|
-
program.addCommand(
|
|
56
|
+
program.addCommand(createStrategyCommand());
|
|
57
|
+
program.addCommand(createBehaviorCommand(), { hidden: true });
|
|
58
|
+
program.addCommand(createTriggerCommand(), { hidden: true });
|
|
57
59
|
program.addCommand(createStartCommand());
|
|
58
60
|
program.addCommand(createJoinCommand());
|
|
59
61
|
program.addCommand(createGameCommand());
|
package/src/commands/behavior.ts
CHANGED
|
@@ -242,8 +242,13 @@ function inventorySources(
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
export function createBehaviorCommand(dependencies: BehaviorCommandDependencies = {}): Command {
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
return createStrategyControlCommand('behavior', dependencies);
|
|
246
|
+
}
|
|
247
|
+
export function createStrategyCommand(dependencies: BehaviorCommandDependencies = {}): Command {
|
|
248
|
+
return createStrategyControlCommand('strategy', dependencies);
|
|
249
|
+
}
|
|
250
|
+
function createStrategyControlCommand(commandName: 'behavior' | 'strategy', dependencies: BehaviorCommandDependencies): Command {
|
|
251
|
+
const behavior = new Command(commandName)
|
|
247
252
|
.description('Discover, configure, and run long or short Behaviors')
|
|
248
253
|
.addHelpText('after', () => {
|
|
249
254
|
const workspaceDir = getWorkspaceDir();
|
|
@@ -251,7 +256,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
251
256
|
const directory = profile
|
|
252
257
|
? getUserDataAccountBehaviorsDir(workspaceDir, profile)
|
|
253
258
|
: '<active-account>/capabilities/behaviors';
|
|
254
|
-
return `\
|
|
259
|
+
return `\n${commandName === 'strategy' ? 'Strategy' : 'Behavior'} modules:\n Place .ts or .js files in ${directory}\n Discovery reads static manifests without executing module code.\n`;
|
|
255
260
|
});
|
|
256
261
|
behavior.addCommand(new Command('rename')
|
|
257
262
|
.description('Rename one equipped Behavior operation for the active account')
|
|
@@ -380,7 +385,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
380
385
|
if (!hub && gameplay.disabled_behaviors.includes(id)) {
|
|
381
386
|
throw new Error(`Behavior '${id}' is disabled in user-data/gameplay.json.`);
|
|
382
387
|
}
|
|
383
|
-
await runOwnerCommand(
|
|
388
|
+
await runOwnerCommand(`ccl ${commandName} start`, 'behavior_start', {
|
|
384
389
|
behavior: id,
|
|
385
390
|
layer: opts.layer,
|
|
386
391
|
input: opts.input,
|
|
@@ -393,7 +398,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
393
398
|
.argument('[id]', 'Optional Behavior operation name')
|
|
394
399
|
.allowExcessArguments(false)
|
|
395
400
|
.action(async (id?: string) => {
|
|
396
|
-
await runOwnerCommand(
|
|
401
|
+
await runOwnerCommand(`ccl ${commandName} status`, 'behavior_status', id ? { behavior: id } : {}, false, dependencies);
|
|
397
402
|
}));
|
|
398
403
|
|
|
399
404
|
behavior.addCommand(new Command('cancel')
|
|
@@ -401,7 +406,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
401
406
|
.argument('[activation-id]', 'Activation id')
|
|
402
407
|
.allowExcessArguments(false)
|
|
403
408
|
.action(async (activationId?: string) => {
|
|
404
|
-
await runOwnerCommand(
|
|
409
|
+
await runOwnerCommand(`ccl ${commandName} cancel`, 'behavior_cancel', {
|
|
405
410
|
...(activationId === undefined ? {} : { activation_id: activationId }),
|
|
406
411
|
}, true, dependencies);
|
|
407
412
|
}));
|
|
@@ -506,17 +511,17 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
506
511
|
behavior.addCommand(fallback);
|
|
507
512
|
|
|
508
513
|
behavior.addCommand(new Command('watch')
|
|
509
|
-
.description('
|
|
514
|
+
.description('Re-enable automatic activation by equipped paired Perceptions in the current game (enabled by default)')
|
|
510
515
|
.argument('<id>', 'Equipped Behavior operation name')
|
|
511
516
|
.option('--input <json>', 'Optional execution parameter patch; perception parameters use perception update', value => parseJsonObject(value), {})
|
|
512
517
|
.allowExcessArguments(false).action(async (id: string, opts: { input: Record<string, unknown> }) => {
|
|
513
|
-
await runOwnerCommand(
|
|
518
|
+
await runOwnerCommand(`ccl ${commandName} watch`, 'behavior_watch', { behavior: id, input: opts.input }, true, dependencies);
|
|
514
519
|
}));
|
|
515
520
|
behavior.addCommand(new Command('unwatch')
|
|
516
521
|
.description('Block automatic activation and cancel associated Reflex; perceptions keep observing and notifying')
|
|
517
522
|
.argument('<id>', 'Equipped Behavior operation name')
|
|
518
523
|
.allowExcessArguments(false).action(async (id: string) => {
|
|
519
|
-
await runOwnerCommand(
|
|
524
|
+
await runOwnerCommand(`ccl ${commandName} unwatch`, 'behavior_unwatch', { behavior: id }, true, dependencies);
|
|
520
525
|
}));
|
|
521
526
|
behavior.addCommand(new Command('update')
|
|
522
527
|
.description('Patch this Behavior\'s match-local parameters and current executions; keep its watch switch')
|
|
@@ -524,8 +529,19 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
524
529
|
.option('--activation', 'Update only the specified execution, without changing shared parameters')
|
|
525
530
|
.requiredOption('--input <json>', 'Parameter patch JSON object', value => parseJsonObject(value))
|
|
526
531
|
.allowExcessArguments(false).action(async (id: string, opts: { activation?: boolean; input: Record<string, unknown> }) => {
|
|
527
|
-
await runOwnerCommand(
|
|
532
|
+
await runOwnerCommand(`ccl ${commandName} update`, 'behavior_update',
|
|
528
533
|
opts.activation ? { activation_id: id, input: opts.input } : { behavior: id, input: opts.input }, true, dependencies);
|
|
529
534
|
}));
|
|
535
|
+
if (commandName === 'behavior') behavior.alias('beh');
|
|
536
|
+
if (commandName === 'strategy') {
|
|
537
|
+
const present = (value: string) => value.replace(/Behaviors/g, 'Strategies').replace(/Behavior/g, 'Strategy');
|
|
538
|
+
const visit = (command: Command): void => {
|
|
539
|
+
command.description(present(command.description()));
|
|
540
|
+
for (const argument of command.registeredArguments) argument.description = present(argument.description);
|
|
541
|
+
for (const option of command.options) option.description = present(option.description);
|
|
542
|
+
for (const child of command.commands) visit(child);
|
|
543
|
+
};
|
|
544
|
+
visit(behavior);
|
|
545
|
+
}
|
|
530
546
|
return behavior;
|
|
531
547
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isPackageManagedSkill } from '../lib/package-skills.js';
|
|
1
2
|
import { Command, InvalidArgumentError } from 'commander';
|
|
2
3
|
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
3
4
|
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
@@ -136,13 +137,13 @@ function activeProfile(): AuthProfile {
|
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
function parseRef(value: string): { type: CapabilityWorkspaceType; id: string } {
|
|
139
|
-
const match = /^(behavior|perception|persona|skill)\/(\S.{0,254})$/u.exec(value);
|
|
140
|
+
const match = /^(strategy|behavior|perception|persona|skill)\/(\S.{0,254})$/u.exec(value);
|
|
140
141
|
if (!match) {
|
|
141
|
-
throw new InvalidArgumentError('expected <
|
|
142
|
+
throw new InvalidArgumentError('expected <strategy|perception|persona|skill>/<id>');
|
|
142
143
|
}
|
|
143
|
-
const parsed = { type: match[1] as CapabilityWorkspaceType, id: match[2]! };
|
|
144
|
-
if (parsed.type === 'skill' && parsed.id
|
|
145
|
-
throw new InvalidArgumentError(
|
|
144
|
+
const parsed = { type: (match[1] === 'strategy' ? 'behavior' : match[1]) as CapabilityWorkspaceType, id: match[2]! };
|
|
145
|
+
if (parsed.type === 'skill' && isPackageManagedSkill(parsed.id)) {
|
|
146
|
+
throw new InvalidArgumentError(`The official ${parsed.id} Skill is managed by the installed CCL package`);
|
|
146
147
|
}
|
|
147
148
|
return parsed;
|
|
148
149
|
}
|
|
@@ -153,7 +154,7 @@ function applySkillSelection(
|
|
|
153
154
|
workspaceDir: string,
|
|
154
155
|
profile: AuthProfile,
|
|
155
156
|
dependencies: CapabilityCommandDependencies,
|
|
156
|
-
):
|
|
157
|
+
): { effective: 'immediate' | 'skipped'; skipped?: SkillHostSkip } {
|
|
157
158
|
const source = capabilityWorkspacePath(workspaceDir, profile, entry);
|
|
158
159
|
const targets = dependencies.skillTargets ?? agentSkillTargets;
|
|
159
160
|
const link = dependencies.linkSkillTarget ?? linkAgentSkillTarget;
|
|
@@ -161,13 +162,12 @@ function applySkillSelection(
|
|
|
161
162
|
const applied: string[] = [];
|
|
162
163
|
const hostTargets = targets(entry.runtimeId);
|
|
163
164
|
const realTargets = realSkillTargets(hostTargets);
|
|
164
|
-
const shouldLink = equipped && realTargets.length === 0;
|
|
165
165
|
for (const target of hostTargets) {
|
|
166
166
|
if (realTargets.includes(target)) continue;
|
|
167
|
-
const result =
|
|
167
|
+
const result = equipped ? link(source, target) : unlink(target);
|
|
168
168
|
if (!result.ok) {
|
|
169
169
|
for (const completed of applied.reverse()) {
|
|
170
|
-
if (
|
|
170
|
+
if (equipped) unlink(completed);
|
|
171
171
|
else link(source, completed);
|
|
172
172
|
}
|
|
173
173
|
throw new Error(`capability_skill_${equipped ? 'equip' : 'unequip'}_failed:${
|
|
@@ -176,7 +176,10 @@ function applySkillSelection(
|
|
|
176
176
|
}
|
|
177
177
|
applied.push(target);
|
|
178
178
|
}
|
|
179
|
-
return
|
|
179
|
+
return {
|
|
180
|
+
effective: equipped && realTargets.length > 0 && applied.length === 0 ? 'skipped' : 'immediate',
|
|
181
|
+
...(realTargets.length ? { skipped: skillHostSkip(entry.runtimeId, realTargets) } : {}),
|
|
182
|
+
};
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
async function updateSelection(
|
|
@@ -189,10 +192,10 @@ async function updateSelection(
|
|
|
189
192
|
discoverLocalCapabilities(workspaceDir, profile);
|
|
190
193
|
const { type, id } = parseRef(ref);
|
|
191
194
|
const entry = await selectCapability(workspaceDir, profile, type, id, equipped, dependencies.client);
|
|
192
|
-
let
|
|
195
|
+
let skillSelection: ReturnType<typeof applySkillSelection> | undefined;
|
|
193
196
|
if (type === 'skill') {
|
|
194
197
|
try {
|
|
195
|
-
|
|
198
|
+
skillSelection = applySkillSelection(entry, equipped, workspaceDir, profile, dependencies);
|
|
196
199
|
} catch (error) {
|
|
197
200
|
throw new Error(`capability_selection_saved_skill_links_failed:run_ccl_load:${error instanceof Error ? error.message : String(error)}`);
|
|
198
201
|
}
|
|
@@ -210,8 +213,8 @@ async function updateSelection(
|
|
|
210
213
|
return {
|
|
211
214
|
capability: `${type}/${entry.runtimeId}`, selection_ref: capabilitySelectionRef(entry),
|
|
212
215
|
equipped, selection: entry.selection,
|
|
213
|
-
effective:
|
|
214
|
-
...(skipped ? { skipped: [skipped] } : {}),
|
|
216
|
+
effective: skillSelection?.effective ?? 'immediate', reload_required_before_game: true,
|
|
217
|
+
...(skillSelection?.skipped ? { skipped: [skillSelection.skipped] } : {}),
|
|
215
218
|
};
|
|
216
219
|
}
|
|
217
220
|
export function createCapabilityCommand(dependencies: CapabilityCommandDependencies = {}): Command {
|