@yhong91/cpac 0.1.34 → 0.1.35
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/README.md +6 -5
- package/dist/cpac.js +52 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,8 +91,9 @@ cpac status # 验证:各 target 显示 ready/injected
|
|
|
91
91
|
|
|
92
92
|
1. **统一启动与配置**:
|
|
93
93
|
- 启动:`cpac <codex|claude|kimi|grok|pi|opencode> [args...]`(所有原生参数如 `-c` 等原样透明传递)
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
- `setup` / `--setup`:配置 Codex/Claude,然后启动
|
|
95
|
+
- `clear`:还原原生配置
|
|
96
|
+
- 查看当前设置:`cpac setup`
|
|
96
97
|
|
|
97
98
|
2. **已安装后升级**:npm 发布新版本后,等 publish 成功再执行 `cpac upgrade`。它会按需 `npm install -g`,再对已接入的 Codex / Pi / Kimi / Grok 做 `sync`。不要拆成 `npm install -g @yhong91/cpac` 再手动 `cpac sync`。只刷新配置、不升 CLI 时才用 `cpac sync`。
|
|
98
99
|
|
|
@@ -109,9 +110,9 @@ CPA: http://124.223.178.52:8317
|
|
|
109
110
|
CPA_API_KEY: configured / not configured
|
|
110
111
|
|
|
111
112
|
Commands:
|
|
112
|
-
cpac
|
|
113
|
-
cpac setup
|
|
114
|
-
cpac status Show
|
|
113
|
+
cpac <agent> [args...] Launch an agent through CPA
|
|
114
|
+
cpac setup Show current Codex/Claude setup
|
|
115
|
+
cpac status Show agent support status
|
|
115
116
|
cpac restore <id> | --all Detach injected agents
|
|
116
117
|
cpac --help Show command usage
|
|
117
118
|
```
|
package/dist/cpac.js
CHANGED
|
@@ -82,7 +82,7 @@ export async function status(config) {
|
|
|
82
82
|
return 0;
|
|
83
83
|
}
|
|
84
84
|
async function guide(config) {
|
|
85
|
-
console.log(`CPA Companion\n\nCPA: ${config.cpa_url}\nCPA_API_KEY: ${process.env[config.api_key_env]?.trim() ? "configured" : "not configured"}\n\nCommands:\n cpac <agent> [args...] Launch an agent (codex, kimi, grok, pi, claude, opencode) through CPA\n cpac setup <codex|claude>
|
|
85
|
+
console.log(`CPA Companion\n\nCPA: ${config.cpa_url}\nCPA_API_KEY: ${process.env[config.api_key_env]?.trim() ? "configured" : "not configured"}\n\nCommands:\n cpac <agent> [args...] Launch an agent (codex, kimi, grok, pi, claude, opencode) through CPA\n cpac setup Show current Codex/Claude setup; cpac setup <codex|claude> to change\n cpac status Show agent support status (Codex, Claude, Pi, Kimi, Grok)\n cpac restore <id> | --all Detach injected agents
|
|
86
86
|
cpac detect Show supported targets and install status
|
|
87
87
|
cpac install [ids...] Install CPA into detected targets, or named agents
|
|
88
88
|
cpac sync Refresh installed Codex/Pi/Kimi/Grok injections from CPA
|
|
@@ -102,8 +102,11 @@ function usage() {
|
|
|
102
102
|
return [
|
|
103
103
|
"Usage: cpac",
|
|
104
104
|
" cpac <codex|kimi|grok|pi|claude|opencode> [args...]",
|
|
105
|
-
"
|
|
106
|
-
"
|
|
105
|
+
" setup|--setup configure Codex/Claude, then launch",
|
|
106
|
+
" clear restore native config",
|
|
107
|
+
" cpac setup [--config PATH] Show current Codex/Claude setup",
|
|
108
|
+
" claude [--opus [M]] [--sonnet [M]] [--haiku [M]] [--reset]",
|
|
109
|
+
" codex [--v2_off] [--v2_models] [--max_context]",
|
|
107
110
|
" cpac restore <id...> | --all [--dry-run] [--config PATH]",
|
|
108
111
|
" cpac status [--config PATH]",
|
|
109
112
|
" cpac detect [--json] [--home PATH]",
|
|
@@ -113,14 +116,15 @@ function usage() {
|
|
|
113
116
|
" cpac upgrade [--check]",
|
|
114
117
|
" cpac -v | --version",
|
|
115
118
|
"",
|
|
116
|
-
"launch an agent
|
|
117
|
-
"
|
|
119
|
+
"launch an agent with `cpac <agent> [args...]` (remaining args forwarded).",
|
|
120
|
+
"`setup`/`clear` hang off the agent; `cpac setup` with no agent prints current settings.",
|
|
118
121
|
].join("\n");
|
|
119
122
|
}
|
|
120
123
|
function setupUsage() {
|
|
121
124
|
return [
|
|
122
|
-
"Usage: cpac setup
|
|
123
|
-
"
|
|
125
|
+
"Usage: cpac setup [--config PATH] Show current Codex/Claude setup",
|
|
126
|
+
" claude [--opus [M]] [--sonnet [M]] [--haiku [M]] [--reset]",
|
|
127
|
+
" codex [--v2_off] [--v2_models] [--max_context]",
|
|
124
128
|
"",
|
|
125
129
|
"Claude slots (saved to config, applied on every `cpac claude`):",
|
|
126
130
|
" --opus heavy reasoning / planning fallback (ANTHROPIC_DEFAULT_OPUS_MODEL)",
|
|
@@ -131,6 +135,19 @@ function setupUsage() {
|
|
|
131
135
|
"No flags on a TTY opens the wizard, then launches.",
|
|
132
136
|
].join("\n");
|
|
133
137
|
}
|
|
138
|
+
function printSetup(config, configPath) {
|
|
139
|
+
const claude = config.claude_models ?? {};
|
|
140
|
+
const auto = (value) => typeof value === "string" && value.trim() ? value.trim() : "(auto)";
|
|
141
|
+
console.log(`config ${configPath}`);
|
|
142
|
+
console.log(`codex spawn_models ${(config.spawn_models ?? []).join(", ") || "(catalog order)"}`);
|
|
143
|
+
console.log(`codex max_context ${config.max_context ? "on" : "off"}`);
|
|
144
|
+
console.log(`codex v2 ${config.v2_off ? "off" : "on"}`);
|
|
145
|
+
console.log(`claude opus ${auto(claude.opus)}`);
|
|
146
|
+
console.log(`claude sonnet ${auto(claude.sonnet)}`);
|
|
147
|
+
console.log(`claude haiku ${auto(claude.haiku)}`);
|
|
148
|
+
console.log("");
|
|
149
|
+
console.log(setupUsage());
|
|
150
|
+
}
|
|
134
151
|
function parseArgs(args) {
|
|
135
152
|
if (args.length === 0) {
|
|
136
153
|
return { command: "guide", configPath: defaultConfigPath() };
|
|
@@ -346,11 +363,33 @@ function parseArgs(args) {
|
|
|
346
363
|
console.log(setupUsage());
|
|
347
364
|
return null;
|
|
348
365
|
}
|
|
349
|
-
|
|
366
|
+
let configPath = defaultConfigPath();
|
|
367
|
+
let agent;
|
|
368
|
+
const flags = [];
|
|
369
|
+
for (let index = 1; index < args.length; index++) {
|
|
370
|
+
const arg = args[index];
|
|
371
|
+
if (arg === "--config") {
|
|
372
|
+
const value = args[++index];
|
|
373
|
+
if (!value)
|
|
374
|
+
throw new CPACError("--config requires a path");
|
|
375
|
+
configPath = resolve(expandUserPath(value));
|
|
376
|
+
}
|
|
377
|
+
else if (!arg.startsWith("-") && agent === undefined) {
|
|
378
|
+
agent = arg;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
flags.push(arg);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (agent === undefined) {
|
|
385
|
+
if (flags.length > 0)
|
|
386
|
+
throw new CPACError(`unknown option: ${flags[0]}`);
|
|
387
|
+
return { command: "setup-show", configPath };
|
|
388
|
+
}
|
|
350
389
|
if (agent !== "claude" && agent !== "codex") {
|
|
351
390
|
throw new CPACError("setup requires claude or codex");
|
|
352
391
|
}
|
|
353
|
-
|
|
392
|
+
args = ["setup", agent, ...flags];
|
|
354
393
|
if (agent === "codex") {
|
|
355
394
|
let v2Off = false;
|
|
356
395
|
let v2Models = false;
|
|
@@ -539,6 +578,10 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
539
578
|
}
|
|
540
579
|
return await runUninstall(config, { dryRun: parsed.dryRun });
|
|
541
580
|
}
|
|
581
|
+
if (parsed.command === "setup-show") {
|
|
582
|
+
printSetup(config, parsed.configPath);
|
|
583
|
+
return 0;
|
|
584
|
+
}
|
|
542
585
|
if (parsed.command === "upgrade")
|
|
543
586
|
return await runUpgrade(config, parsed.check);
|
|
544
587
|
if (parsed.command === "claude")
|