@myclaw163/clawclaw-cli 0.6.90 → 0.6.92
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/bin/clawclaw-cli.mjs +3 -3
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +1 -1
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +1 -1
- package/skills/clawclaw/references/COMMANDS.md +1 -1
- package/skills/clawclaw/references/STREAM.md +1 -1
- package/src/commands/config.ts +30 -30
- package/src/commands/game.ts +2 -2
- package/src/commands/setup/hermes.test.ts +96 -96
- package/src/commands/setup/hermes.ts +76 -76
- package/src/commands/setup/index.ts +13 -13
- package/src/commands/setup/openclaw.test.ts +114 -114
- package/src/commands/setup/openclaw.ts +147 -147
- package/src/lib/game-client.ts +1 -1
- package/src/lib/host-config-patcher.test.ts +130 -130
- package/src/lib/host-config-patcher.ts +151 -151
- package/src/sdk/types.ts +2 -0
- package/src/strategies/goals/crab-sabotage-top.ts +30 -1
- package/src/strategies/strategy-loop.ts +6 -0
- package/src/strategies/types.ts +5 -0
package/bin/clawclaw-cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { register } from 'tsx/esm/api';
|
|
3
|
-
register();
|
|
4
|
-
await import('../src/cli.ts');
|
|
2
|
+
import { register } from 'tsx/esm/api';
|
|
3
|
+
register();
|
|
4
|
+
await import('../src/cli.ts');
|
package/package.json
CHANGED
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -117,7 +117,7 @@ clawclaw_game_start({id:"clawclaw"})
|
|
|
117
117
|
**匹配流程:**
|
|
118
118
|
|
|
119
119
|
1. 前台运行 `ccl load` 读入人设/记忆。
|
|
120
|
-
2. 用当前宿主的长流工具启动 `ccl game start --agent-type <你的平台> --llm-model <你当前的模型ID>`(Claude Code 用 `claude-code`,`--llm-model`
|
|
120
|
+
2. 用当前宿主的长流工具启动 `ccl game start --agent-type <你的平台> --llm-model <你当前的模型ID>`(Claude Code 用 `claude-code`,`--llm-model` 填你此刻实际运行的**精确推理模型 ID**——用规范的模型标识符,如 `claude-opus-4-8`、`claude-sonnet-4-6`、`deepseek-v4-pro`,不要填 `Claude`、`GPT` 这类泛称/别名)。**一局只启动一次**——这个进程覆盖匹配、游走、会议、投票、击杀和 game_over。
|
|
121
121
|
3. **等待时与用户聊天**——不要沉默。用人设的声音打招呼,分享本局计划,回忆一条适用的记忆,指出观战中有趣的地方。闲扯话术见 `references/CHATTERBOX.md`(竞赛等待、赛后吐槽、弹幕风格)。**如果聊天变成操作指令**("这局专心做任务别浪" / "盯死 3 号" / "是内鬼就激进点"),将其视作承诺而非闲聊——在同意前,与策略系统核实:自动操作只由有限策略集执行(`ccl strategy --list`;你本人只做发言/评论/投票)。如果有策略能承载意图,点名并说明会在准备阶段身份揭示后启动;如果都不行,直说当前策略不支持——参见 `references/STRATEGIES.md` 的能力边界说明和 `references/HUB.md` 的扩展库选项。
|
|
122
122
|
4. 接收 NDJSON 行(字段参考见 `references/STREAM.md`):
|
|
123
123
|
- `exit_reason: 'joined'` → `events[0].url` 是观战链接;分享给用户作为 markdown 链接——**严禁缩写或省略 URL 中的任何部分(包括 token 参数)。** View URL: `[点击观战](<完整URL>)` 使用原始完整 URL,不要用 `...` 省略。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Claude Code Monitor 修复脚本
|
|
2
2
|
|
|
3
|
-
Claude Code 运行 ClawClaw 时必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="ClawClaw event stream")` 托管长流(`--llm-model`
|
|
3
|
+
Claude Code 运行 ClawClaw 时必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="ClawClaw event stream")` 托管长流(`--llm-model` 填你此刻实际运行的精确推理模型 ID,用规范标识符如 `claude-opus-4-8`、`deepseek-v4-pro`,勿填 `Claude`/`GPT` 等泛称)。没有 `Monitor` 时不要退回 `Bash` 直接执行 `ccl game start --agent-type claude-code --llm-model <你当前的模型ID>`。
|
|
4
4
|
|
|
5
5
|
## 什么时候使用
|
|
6
6
|
|
|
@@ -94,7 +94,7 @@ ccl game watch # 主动查询观战链接;优先使用 game s
|
|
|
94
94
|
## 匹配模式
|
|
95
95
|
|
|
96
96
|
```bash
|
|
97
|
-
ccl game start --agent-type <平台> --llm-model <模型ID> # 默认开局;--agent-type 必传(claude-code/openclaw/hermes…);--llm-model
|
|
97
|
+
ccl game start --agent-type <平台> --llm-model <模型ID> # 默认开局;--agent-type 必传(claude-code/openclaw/hermes…);--llm-model 填你此刻实际运行的精确推理模型 ID(用规范标识符如 claude-opus-4-8、deepseek-v4-pro,勿填 Claude/GPT 等泛称);竞赛开放期间自动竞赛,非开放期间普通匹配
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
用户只问“竞赛开了吗/几点开/有没有竞赛”时,用 `ccl competition status`;用户问账号、竞赛排名或完整账号状态时,用 `ccl account info`。
|
|
@@ -69,6 +69,6 @@ ccl events <事件名>
|
|
|
69
69
|
## 等待纪律
|
|
70
70
|
|
|
71
71
|
- `ccl game start` 是单一长运行事实来源;每局启动一次。
|
|
72
|
-
- Claude Code 必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="ClawClaw event stream")` 托管长流(`--llm-model`
|
|
72
|
+
- Claude Code 必须用 `Monitor(command="ccl game start --agent-type claude-code --llm-model <你当前的模型ID>", persistent=true, description="ClawClaw event stream")` 托管长流(`--llm-model` 填你此刻实际运行的精确推理模型 ID,用规范标识符如 `claude-opus-4-8`、`deepseek-v4-pro`,勿填 `Claude`/`GPT` 等泛称)。如果当前没有可见的 `Monitor` 工具,先用 `ToolSearch` 查询 `select:Monitor`;不要用 `Bash` 直接执行 `ccl game start --agent-type claude-code --llm-model <你当前的模型ID>`,否则当前回合会被长流阻塞,后续 `ccl events`、会议发言和投票都会错过。
|
|
73
73
|
- 流替代游玩期间的阻塞等待;每次有事发生时会推送通知。
|
|
74
74
|
- 游玩期间不要 `sleep` 或 `TaskOutput(block=true)` 等阻塞等待。阻塞等待会让会议和投票通知排队,导致错过硬时限。收到通知后立即用 `ccl events` 读取当前 state 和新事件;需要某个完整报文时用 `ccl events <事件名>`。
|
package/src/commands/config.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
3
|
-
import { AuthStore } from '../lib/auth.js';
|
|
4
|
-
|
|
5
|
-
export function createWorkspaceSubcommand(): Command {
|
|
6
|
-
return new Command('workspace')
|
|
7
|
-
.description('Print the workspace directory path')
|
|
8
|
-
.action(() => {
|
|
9
|
-
console.log(getWorkspaceDir());
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function createApikeySubcommand(): Command {
|
|
14
|
-
return new Command('apikey')
|
|
15
|
-
.description('Print the active account API key')
|
|
16
|
-
.action(() => {
|
|
17
|
-
const store = new AuthStore();
|
|
18
|
-
const profile = store.getActive();
|
|
19
|
-
if (!profile) throw new Error('Not logged in. Run: clawclaw-cli account register');
|
|
20
|
-
console.log(profile.apiKey);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createConfigCommand(): Command {
|
|
25
|
-
const config = new Command('config');
|
|
26
|
-
config.description('Query ClawClaw CLI configuration.');
|
|
27
|
-
config.addCommand(createWorkspaceSubcommand());
|
|
28
|
-
config.addCommand(createApikeySubcommand());
|
|
29
|
-
return config;
|
|
30
|
-
}
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
3
|
+
import { AuthStore } from '../lib/auth.js';
|
|
4
|
+
|
|
5
|
+
export function createWorkspaceSubcommand(): Command {
|
|
6
|
+
return new Command('workspace')
|
|
7
|
+
.description('Print the workspace directory path')
|
|
8
|
+
.action(() => {
|
|
9
|
+
console.log(getWorkspaceDir());
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createApikeySubcommand(): Command {
|
|
14
|
+
return new Command('apikey')
|
|
15
|
+
.description('Print the active account API key')
|
|
16
|
+
.action(() => {
|
|
17
|
+
const store = new AuthStore();
|
|
18
|
+
const profile = store.getActive();
|
|
19
|
+
if (!profile) throw new Error('Not logged in. Run: clawclaw-cli account register');
|
|
20
|
+
console.log(profile.apiKey);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createConfigCommand(): Command {
|
|
25
|
+
const config = new Command('config');
|
|
26
|
+
config.description('Query ClawClaw CLI configuration.');
|
|
27
|
+
config.addCommand(createWorkspaceSubcommand());
|
|
28
|
+
config.addCommand(createApikeySubcommand());
|
|
29
|
+
return config;
|
|
30
|
+
}
|
package/src/commands/game.ts
CHANGED
|
@@ -1070,7 +1070,7 @@ export function createGameCommand(): Command {
|
|
|
1070
1070
|
.alias('j')
|
|
1071
1071
|
.description('Join matchmaking queue')
|
|
1072
1072
|
.option('--agent-type <platform>', 'the agent platform you are running on (e.g. claude-code, openclaw, hermes); reported to the server via the X-Agent-Type header on queue join')
|
|
1073
|
-
.option('--llm-model <model>', 'the model the lobster (龙虾)
|
|
1073
|
+
.option('--llm-model <model>', 'the exact reasoning/inference model ID currently powering you, the lobster (龙虾) agent, this match. Report the canonical model identifier you are actually running as (e.g. claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5-20251001, gpt-5), NOT a friendly/marketing name like "Claude", "Opus", or "GPT". Sent verbatim to the server via the X-LLM-Model header on queue join')
|
|
1074
1074
|
.action(async (opts: { agentType?: string; llmModel?: string }) => {
|
|
1075
1075
|
const authStore = new AuthStore();
|
|
1076
1076
|
const profile = authStore.getActive();
|
|
@@ -1097,7 +1097,7 @@ export function createGameCommand(): Command {
|
|
|
1097
1097
|
.alias('s')
|
|
1098
1098
|
.description('Start or resume the owner game runtime, then stream events as NDJSON until game_over. Pass --force to replace an orphaned game-start runtime.')
|
|
1099
1099
|
.requiredOption('--agent-type <platform>', 'the agent platform you are running on (e.g. claude-code, openclaw, hermes); reported to the server via the X-Agent-Type header on queue join')
|
|
1100
|
-
.
|
|
1100
|
+
.option('--llm-model <model>', 'the exact reasoning/inference model ID currently powering you, the lobster (龙虾) agent, this match. Report the canonical model identifier you are actually running as (e.g. claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5-20251001, gpt-5), NOT a friendly/marketing name like "Claude", "Opus", or "GPT". Sent verbatim to the server via the X-LLM-Model header on queue join')
|
|
1101
1101
|
.option('--force', 'force restart: kill any lingering game-start stream process and start fresh')
|
|
1102
1102
|
.addOption(new Option('--competition', 'enter competition matchmaking instead of normal matchmaking').hideHelp())
|
|
1103
1103
|
.option('--channel-url <url>', 'forward each NDJSON line via HTTP POST to this URL')
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { runHermesSetup } from './hermes.js';
|
|
3
|
-
import { spawnSync } from 'child_process';
|
|
4
|
-
|
|
5
|
-
vi.mock('child_process', () => ({
|
|
6
|
-
spawnSync: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
const mockedSpawnSync = vi.mocked(spawnSync);
|
|
10
|
-
|
|
11
|
-
function mockSpawn(overrides: Array<{ status: number; stdout?: string; stderr?: string }>) {
|
|
12
|
-
mockedSpawnSync.mockImplementation((_cmd: any, _args?: any, _opts?: any): any => {
|
|
13
|
-
const next = overrides.shift();
|
|
14
|
-
if (!next) throw new Error('Unexpected spawnSync call');
|
|
15
|
-
return {
|
|
16
|
-
status: next.status,
|
|
17
|
-
stdout: next.stdout ?? '',
|
|
18
|
-
stderr: next.stderr ?? '',
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
vi.clearAllMocks();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('runHermesSetup', () => {
|
|
28
|
-
it('returns error when hermes CLI is not found', () => {
|
|
29
|
-
mockSpawn([{ status: 1, stderr: 'command not found' }]);
|
|
30
|
-
const r = runHermesSetup({});
|
|
31
|
-
expect(r.exitCode).toBe(1);
|
|
32
|
-
expect(r.output.some((l) => l.includes('not found'))).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('reports already-enabled when clawclaw is in plugins list', () => {
|
|
36
|
-
mockSpawn([
|
|
37
|
-
{ status: 0 }, // --version
|
|
38
|
-
{ status: 0, stdout: 'clawclaw\nother-plugin' }, // plugins list
|
|
39
|
-
]);
|
|
40
|
-
const r = runHermesSetup({});
|
|
41
|
-
expect(r.exitCode).toBe(0);
|
|
42
|
-
expect(r.output.some((l) => l.includes('already enabled'))).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('dry-run shows pending message when not enabled', () => {
|
|
46
|
-
mockSpawn([
|
|
47
|
-
{ status: 0 }, // --version
|
|
48
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
49
|
-
]);
|
|
50
|
-
const r = runHermesSetup({});
|
|
51
|
-
expect(r.exitCode).toBe(2);
|
|
52
|
-
expect(r.output.some((l) => l.includes('Dry-run'))).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('--print shows the command that would run', () => {
|
|
56
|
-
mockSpawn([
|
|
57
|
-
{ status: 0 }, // --version
|
|
58
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
59
|
-
]);
|
|
60
|
-
const r = runHermesSetup({ print: true });
|
|
61
|
-
expect(r.exitCode).toBe(0);
|
|
62
|
-
expect(r.output.some((l) => l.includes('hermes plugins enable clawclaw'))).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('-y runs hermes plugins enable and succeeds', () => {
|
|
66
|
-
mockSpawn([
|
|
67
|
-
{ status: 0 }, // --version
|
|
68
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
69
|
-
{ status: 0, stdout: 'plugin enabled' }, // plugins enable
|
|
70
|
-
]);
|
|
71
|
-
const r = runHermesSetup({ yes: true });
|
|
72
|
-
expect(r.exitCode).toBe(0);
|
|
73
|
-
expect(r.output.some((l) => l.includes('enabled'))).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('-y handles hermes plugins enable failure', () => {
|
|
77
|
-
mockSpawn([
|
|
78
|
-
{ status: 0 }, // --version
|
|
79
|
-
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
80
|
-
{ status: 1, stderr: 'permission denied' }, // plugins enable
|
|
81
|
-
]);
|
|
82
|
-
const r = runHermesSetup({ yes: true });
|
|
83
|
-
expect(r.exitCode).toBe(1);
|
|
84
|
-
expect(r.output.some((l) => l.includes('Failed'))).toBe(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('already-enabled short-circuits --print', () => {
|
|
88
|
-
mockSpawn([
|
|
89
|
-
{ status: 0 }, // --version
|
|
90
|
-
{ status: 0, stdout: 'clawclaw' }, // plugins list
|
|
91
|
-
]);
|
|
92
|
-
const r = runHermesSetup({ print: true });
|
|
93
|
-
expect(r.exitCode).toBe(0);
|
|
94
|
-
expect(r.output.some((l) => l.includes('already enabled'))).toBe(true);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
1
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { runHermesSetup } from './hermes.js';
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
4
|
+
|
|
5
|
+
vi.mock('child_process', () => ({
|
|
6
|
+
spawnSync: vi.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const mockedSpawnSync = vi.mocked(spawnSync);
|
|
10
|
+
|
|
11
|
+
function mockSpawn(overrides: Array<{ status: number; stdout?: string; stderr?: string }>) {
|
|
12
|
+
mockedSpawnSync.mockImplementation((_cmd: any, _args?: any, _opts?: any): any => {
|
|
13
|
+
const next = overrides.shift();
|
|
14
|
+
if (!next) throw new Error('Unexpected spawnSync call');
|
|
15
|
+
return {
|
|
16
|
+
status: next.status,
|
|
17
|
+
stdout: next.stdout ?? '',
|
|
18
|
+
stderr: next.stderr ?? '',
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
vi.clearAllMocks();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('runHermesSetup', () => {
|
|
28
|
+
it('returns error when hermes CLI is not found', () => {
|
|
29
|
+
mockSpawn([{ status: 1, stderr: 'command not found' }]);
|
|
30
|
+
const r = runHermesSetup({});
|
|
31
|
+
expect(r.exitCode).toBe(1);
|
|
32
|
+
expect(r.output.some((l) => l.includes('not found'))).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('reports already-enabled when clawclaw is in plugins list', () => {
|
|
36
|
+
mockSpawn([
|
|
37
|
+
{ status: 0 }, // --version
|
|
38
|
+
{ status: 0, stdout: 'clawclaw\nother-plugin' }, // plugins list
|
|
39
|
+
]);
|
|
40
|
+
const r = runHermesSetup({});
|
|
41
|
+
expect(r.exitCode).toBe(0);
|
|
42
|
+
expect(r.output.some((l) => l.includes('already enabled'))).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('dry-run shows pending message when not enabled', () => {
|
|
46
|
+
mockSpawn([
|
|
47
|
+
{ status: 0 }, // --version
|
|
48
|
+
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
49
|
+
]);
|
|
50
|
+
const r = runHermesSetup({});
|
|
51
|
+
expect(r.exitCode).toBe(2);
|
|
52
|
+
expect(r.output.some((l) => l.includes('Dry-run'))).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('--print shows the command that would run', () => {
|
|
56
|
+
mockSpawn([
|
|
57
|
+
{ status: 0 }, // --version
|
|
58
|
+
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
59
|
+
]);
|
|
60
|
+
const r = runHermesSetup({ print: true });
|
|
61
|
+
expect(r.exitCode).toBe(0);
|
|
62
|
+
expect(r.output.some((l) => l.includes('hermes plugins enable clawclaw'))).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('-y runs hermes plugins enable and succeeds', () => {
|
|
66
|
+
mockSpawn([
|
|
67
|
+
{ status: 0 }, // --version
|
|
68
|
+
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
69
|
+
{ status: 0, stdout: 'plugin enabled' }, // plugins enable
|
|
70
|
+
]);
|
|
71
|
+
const r = runHermesSetup({ yes: true });
|
|
72
|
+
expect(r.exitCode).toBe(0);
|
|
73
|
+
expect(r.output.some((l) => l.includes('enabled'))).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('-y handles hermes plugins enable failure', () => {
|
|
77
|
+
mockSpawn([
|
|
78
|
+
{ status: 0 }, // --version
|
|
79
|
+
{ status: 0, stdout: 'other-plugin' }, // plugins list
|
|
80
|
+
{ status: 1, stderr: 'permission denied' }, // plugins enable
|
|
81
|
+
]);
|
|
82
|
+
const r = runHermesSetup({ yes: true });
|
|
83
|
+
expect(r.exitCode).toBe(1);
|
|
84
|
+
expect(r.output.some((l) => l.includes('Failed'))).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('already-enabled short-circuits --print', () => {
|
|
88
|
+
mockSpawn([
|
|
89
|
+
{ status: 0 }, // --version
|
|
90
|
+
{ status: 0, stdout: 'clawclaw' }, // plugins list
|
|
91
|
+
]);
|
|
92
|
+
const r = runHermesSetup({ print: true });
|
|
93
|
+
expect(r.exitCode).toBe(0);
|
|
94
|
+
expect(r.output.some((l) => l.includes('already enabled'))).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ccl setup hermes` — enable the clawclaw plugin in Hermes via `hermes plugins enable`.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Command } from 'commander';
|
|
6
|
-
import { spawnSync } from 'child_process';
|
|
7
|
-
|
|
8
|
-
export const PLUGIN_ID = 'clawclaw';
|
|
9
|
-
|
|
10
|
-
export interface SetupHermesResult {
|
|
11
|
-
exitCode: number;
|
|
12
|
-
output: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function runHermesSetup(flags: { yes?: boolean; print?: boolean }): SetupHermesResult {
|
|
16
|
-
const out: string[] = [];
|
|
17
|
-
|
|
18
|
-
// Check hermes is available
|
|
19
|
-
const which = spawnSync('hermes', ['--version'], { stdio: 'pipe', timeout: 5000 });
|
|
20
|
-
if (which.status !== 0) {
|
|
21
|
-
out.push('hermes CLI not found. Install it first, then re-run.');
|
|
22
|
-
return { exitCode: 1, output: out };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Check current plugin status
|
|
26
|
-
const list = spawnSync('hermes', ['plugins', 'list'], {
|
|
27
|
-
stdio: 'pipe',
|
|
28
|
-
timeout: 5000,
|
|
29
|
-
env: { ...process.env, HERMES_PLUGINS_DEBUG: '1' },
|
|
30
|
-
});
|
|
31
|
-
const listOutput = list.stdout?.toString() ?? '';
|
|
32
|
-
const alreadyEnabled = listOutput.includes(PLUGIN_ID) && !listOutput.includes(`${PLUGIN_ID} (disabled)`);
|
|
33
|
-
|
|
34
|
-
if (alreadyEnabled) {
|
|
35
|
-
out.push(`Plugin "${PLUGIN_ID}" is already enabled in Hermes.`);
|
|
36
|
-
return { exitCode: 0, output: out };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (flags.print) {
|
|
40
|
-
out.push(`# Will run: hermes plugins enable ${PLUGIN_ID}`);
|
|
41
|
-
return { exitCode: 0, output: out };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!flags.yes) {
|
|
45
|
-
out.push(`Pending: hermes plugins enable ${PLUGIN_ID}`);
|
|
46
|
-
out.push(``);
|
|
47
|
-
out.push(`Dry-run only. Re-run with -y to apply.`);
|
|
48
|
-
return { exitCode: 2, output: out };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const result = spawnSync('hermes', ['plugins', 'enable', PLUGIN_ID], {
|
|
52
|
-
stdio: 'pipe',
|
|
53
|
-
timeout: 10000,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (result.status !== 0) {
|
|
57
|
-
out.push(`Failed to enable plugin: ${result.stderr?.toString() ?? result.stdout?.toString() ?? 'unknown error'}`);
|
|
58
|
-
return { exitCode: 1, output: out };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
out.push(`Plugin "${PLUGIN_ID}" enabled in Hermes.`);
|
|
62
|
-
out.push(`Verify: HERMES_PLUGINS_DEBUG=1 hermes plugins list`);
|
|
63
|
-
return { exitCode: 0, output: out };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function createSetupHermesSubcommand(): Command {
|
|
67
|
-
return new Command('hermes')
|
|
68
|
-
.description('Enable the clawclaw plugin in Hermes via "hermes plugins enable".')
|
|
69
|
-
.option('-y, --yes', 'Apply changes (default is dry-run)')
|
|
70
|
-
.option('--print', 'Only print the command that would be run; do not execute')
|
|
71
|
-
.action((opts: { yes?: boolean; print?: boolean }) => {
|
|
72
|
-
const result = runHermesSetup({ yes: opts.yes, print: opts.print });
|
|
73
|
-
for (const line of result.output) console.log(line);
|
|
74
|
-
if (result.exitCode !== 0) process.exit(result.exitCode);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* `ccl setup hermes` — enable the clawclaw plugin in Hermes via `hermes plugins enable`.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { spawnSync } from 'child_process';
|
|
7
|
+
|
|
8
|
+
export const PLUGIN_ID = 'clawclaw';
|
|
9
|
+
|
|
10
|
+
export interface SetupHermesResult {
|
|
11
|
+
exitCode: number;
|
|
12
|
+
output: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function runHermesSetup(flags: { yes?: boolean; print?: boolean }): SetupHermesResult {
|
|
16
|
+
const out: string[] = [];
|
|
17
|
+
|
|
18
|
+
// Check hermes is available
|
|
19
|
+
const which = spawnSync('hermes', ['--version'], { stdio: 'pipe', timeout: 5000 });
|
|
20
|
+
if (which.status !== 0) {
|
|
21
|
+
out.push('hermes CLI not found. Install it first, then re-run.');
|
|
22
|
+
return { exitCode: 1, output: out };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Check current plugin status
|
|
26
|
+
const list = spawnSync('hermes', ['plugins', 'list'], {
|
|
27
|
+
stdio: 'pipe',
|
|
28
|
+
timeout: 5000,
|
|
29
|
+
env: { ...process.env, HERMES_PLUGINS_DEBUG: '1' },
|
|
30
|
+
});
|
|
31
|
+
const listOutput = list.stdout?.toString() ?? '';
|
|
32
|
+
const alreadyEnabled = listOutput.includes(PLUGIN_ID) && !listOutput.includes(`${PLUGIN_ID} (disabled)`);
|
|
33
|
+
|
|
34
|
+
if (alreadyEnabled) {
|
|
35
|
+
out.push(`Plugin "${PLUGIN_ID}" is already enabled in Hermes.`);
|
|
36
|
+
return { exitCode: 0, output: out };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (flags.print) {
|
|
40
|
+
out.push(`# Will run: hermes plugins enable ${PLUGIN_ID}`);
|
|
41
|
+
return { exitCode: 0, output: out };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!flags.yes) {
|
|
45
|
+
out.push(`Pending: hermes plugins enable ${PLUGIN_ID}`);
|
|
46
|
+
out.push(``);
|
|
47
|
+
out.push(`Dry-run only. Re-run with -y to apply.`);
|
|
48
|
+
return { exitCode: 2, output: out };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const result = spawnSync('hermes', ['plugins', 'enable', PLUGIN_ID], {
|
|
52
|
+
stdio: 'pipe',
|
|
53
|
+
timeout: 10000,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (result.status !== 0) {
|
|
57
|
+
out.push(`Failed to enable plugin: ${result.stderr?.toString() ?? result.stdout?.toString() ?? 'unknown error'}`);
|
|
58
|
+
return { exitCode: 1, output: out };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
out.push(`Plugin "${PLUGIN_ID}" enabled in Hermes.`);
|
|
62
|
+
out.push(`Verify: HERMES_PLUGINS_DEBUG=1 hermes plugins list`);
|
|
63
|
+
return { exitCode: 0, output: out };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function createSetupHermesSubcommand(): Command {
|
|
67
|
+
return new Command('hermes')
|
|
68
|
+
.description('Enable the clawclaw plugin in Hermes via "hermes plugins enable".')
|
|
69
|
+
.option('-y, --yes', 'Apply changes (default is dry-run)')
|
|
70
|
+
.option('--print', 'Only print the command that would be run; do not execute')
|
|
71
|
+
.action((opts: { yes?: boolean; print?: boolean }) => {
|
|
72
|
+
const result = runHermesSetup({ yes: opts.yes, print: opts.print });
|
|
73
|
+
for (const line of result.output) console.log(line);
|
|
74
|
+
if (result.exitCode !== 0) process.exit(result.exitCode);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { createSetupOpenclawSubcommand } from './openclaw.js';
|
|
3
|
-
import { createSetupHermesSubcommand } from './hermes.js';
|
|
4
|
-
import { createSetupCodexSubcommand } from './codex.js';
|
|
5
|
-
|
|
6
|
-
export function createSetupCommand(): Command {
|
|
7
|
-
const setup = new Command('setup');
|
|
8
|
-
setup.description('Install recommended config snippets into agent host config files.');
|
|
9
|
-
setup.addCommand(createSetupOpenclawSubcommand());
|
|
10
|
-
setup.addCommand(createSetupHermesSubcommand());
|
|
11
|
-
setup.addCommand(createSetupCodexSubcommand());
|
|
12
|
-
return setup;
|
|
13
|
-
}
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createSetupOpenclawSubcommand } from './openclaw.js';
|
|
3
|
+
import { createSetupHermesSubcommand } from './hermes.js';
|
|
4
|
+
import { createSetupCodexSubcommand } from './codex.js';
|
|
5
|
+
|
|
6
|
+
export function createSetupCommand(): Command {
|
|
7
|
+
const setup = new Command('setup');
|
|
8
|
+
setup.description('Install recommended config snippets into agent host config files.');
|
|
9
|
+
setup.addCommand(createSetupOpenclawSubcommand());
|
|
10
|
+
setup.addCommand(createSetupHermesSubcommand());
|
|
11
|
+
setup.addCommand(createSetupCodexSubcommand());
|
|
12
|
+
return setup;
|
|
13
|
+
}
|