@compass-aiden/neo 0.2.3 → 0.2.5
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 -4
- package/dist/index.js +297 -54
- package/dist/index.js.map +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,17 +17,19 @@ npm i -g @compass-aiden/neo # 满意再全局安装
|
|
|
17
17
|
|
|
18
18
|
```pwsh
|
|
19
19
|
neo init # 写 ~/.neo/config.yaml;发现存量技能会问是否导入
|
|
20
|
-
neo add anthropics/skills --skill pdf # 往全局底座角色 default 装技能(也接受 -s)
|
|
21
20
|
neo create writer # 建一个新角色
|
|
22
|
-
neo add anthropics/skills --skill docx --role writer
|
|
21
|
+
neo add anthropics/skills --skill docx --role writer # 目标角色必须显式(TTY 不给会弹选择器)
|
|
22
|
+
neo add anthropics/skills --skill pdf --role default # 装进所有角色继承的底座就要显式写 default
|
|
23
23
|
neo use writer # 把 writer 设为默认(不触任何 agent 全局目录)
|
|
24
24
|
neo run claude-code # 以隔离配置根启动:技能/提示词/MCP/登录态都在根内
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
- `neo add <source>` 不给 `--skill/-s` 时:TTY 下列出来源技能多选(单技能直接装);非 TTY 必须显式给 flag 或 `-l`。
|
|
28
|
+
- 写入型命令(`add`/`remove`/`migrate --apply`)的 `--role` **必须显式**:TTY 下不给会弹角色选择器(选到 `default` 再确认一次,因为它被所有角色继承);非 TTY 缺 `--role` = usage 错误。`--role` 指向不存在的角色不会被顺手创建,先 `neo create <name>`。
|
|
28
29
|
- 模型/网关:`neo model provider add litellm --base-url https://gw.example/v1 --api-key env:LITELLM_API_KEY` 读一次 `/v1/models` 建清单;`neo model edit/use/refresh` 调整;`neo run` 时按 Pi/DSH/Codex/Claude 各自格式渲染。
|
|
29
|
-
- `neo
|
|
30
|
-
-
|
|
30
|
+
- 不想记参数:TTY 下裸跑 `neo model provider` 进供应商菜单(新增/编辑/refresh/删除),`neo model edit|rm|use` 不给目标会先让你从清单里选;删除会列出影响面再确认。
|
|
31
|
+
- `neo init` 会扫描 `~/.agents/skills` 与各 agent 技能目录:有存量技能时询问导入到哪个角色(TTY 选择器,可就地新建;选 `default` 再确认);拒绝则原样不动。
|
|
32
|
+
- 想自己控制收编节奏:`neo migrate`(预览,无需 `--role`)→ `neo migrate --scan-agents --apply --role <name>`。
|
|
31
33
|
- 仍需要 0.1 的全局挂载:`neo use writer --global`;卸载:`neo off --global`。
|
|
32
34
|
|
|
33
35
|
全部命令与约定见 `neo --help`;完整文档见 [主仓库](https://github.com/Aiden-FE/neo)。
|
package/dist/index.js
CHANGED
|
@@ -1291,7 +1291,7 @@ function promptSkillSelection(options, context) {
|
|
|
1291
1291
|
}
|
|
1292
1292
|
|
|
1293
1293
|
// ../core/dist/version.js
|
|
1294
|
-
var NEO_VERSION = "0.2.
|
|
1294
|
+
var NEO_VERSION = "0.2.5";
|
|
1295
1295
|
|
|
1296
1296
|
// ../core/dist/error.js
|
|
1297
1297
|
var NeoError = class extends Error {
|
|
@@ -2419,7 +2419,7 @@ function buildUpstreamAddArgs(opts) {
|
|
|
2419
2419
|
return [...base, "-a", "universal", "-y", "--copy", "--json", ...selection];
|
|
2420
2420
|
}
|
|
2421
2421
|
function parseSourceSkillList(output) {
|
|
2422
|
-
const clean = output.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/\r/g, "");
|
|
2422
|
+
const clean = output.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "").replace(/\r/g, "").replace(/│/g, "|");
|
|
2423
2423
|
const lines = clean.split("\n");
|
|
2424
2424
|
const out = [];
|
|
2425
2425
|
let inList = false;
|
|
@@ -2433,7 +2433,7 @@ function parseSourceSkillList(output) {
|
|
|
2433
2433
|
continue;
|
|
2434
2434
|
if (/Use --skill|Installation failed|Found \d+ skills?/i.test(line))
|
|
2435
2435
|
break;
|
|
2436
|
-
const name = /^\|\s{4}([a-zA-Z0-9][a-zA-Z0-9._
|
|
2436
|
+
const name = /^\|\s{4}([a-zA-Z0-9][a-zA-Z0-9._+-]*)\s*$/.exec(line)?.[1];
|
|
2437
2437
|
if (name !== void 0) {
|
|
2438
2438
|
if (!out.some((item) => item.name === name)) {
|
|
2439
2439
|
current = { name };
|
|
@@ -7108,8 +7108,11 @@ async function cmdOverview(args, io, deps) {
|
|
|
7108
7108
|
async function cmdProvider(args, io, deps) {
|
|
7109
7109
|
const first = args[0];
|
|
7110
7110
|
const sub = first === void 0 || first.startsWith("-") ? void 0 : first;
|
|
7111
|
-
if (sub ===
|
|
7112
|
-
return cmdProviderList(
|
|
7111
|
+
if (sub === "list" || sub === "ls") {
|
|
7112
|
+
return cmdProviderList(args.slice(1), io, deps);
|
|
7113
|
+
}
|
|
7114
|
+
if (sub === void 0) {
|
|
7115
|
+
return cmdProviderHub(args, io, deps);
|
|
7113
7116
|
}
|
|
7114
7117
|
switch (sub) {
|
|
7115
7118
|
case "add":
|
|
@@ -7123,6 +7126,52 @@ async function cmdProvider(args, io, deps) {
|
|
|
7123
7126
|
throw new NeoError("usage", `model provider: unknown subcommand "${sub}" (expected list|add|rm|edit)`);
|
|
7124
7127
|
}
|
|
7125
7128
|
}
|
|
7129
|
+
var PROVIDER_MENU = [
|
|
7130
|
+
{ value: "add", label: "Add a provider", hint: "base URL + key, then read /v1/models" },
|
|
7131
|
+
{ value: "edit", label: "Edit a provider", hint: "base URL, api, key reference" },
|
|
7132
|
+
{ value: "refresh", label: "Refresh model lists", hint: "merge from /v1/models (additive)" },
|
|
7133
|
+
{ value: "remove", label: "Remove a provider", hint: "refuses while referenced" },
|
|
7134
|
+
{ value: "done", label: "Done" }
|
|
7135
|
+
];
|
|
7136
|
+
var PROVIDER_HUB_VALUED = /* @__PURE__ */ new Set(["base-url", "api", "api-key", "header", "rm-header"]);
|
|
7137
|
+
function rebuildFlags(parsed) {
|
|
7138
|
+
const out = [];
|
|
7139
|
+
for (const [name, values] of parsed.flags) {
|
|
7140
|
+
for (const value of values) out.push(`--${name}`, value);
|
|
7141
|
+
}
|
|
7142
|
+
for (const name of parsed.bools) out.push(`--${name}`);
|
|
7143
|
+
return out;
|
|
7144
|
+
}
|
|
7145
|
+
async function cmdProviderHub(args, io, deps) {
|
|
7146
|
+
const parsed = parseArgs(args, {
|
|
7147
|
+
valued: PROVIDER_HUB_VALUED,
|
|
7148
|
+
boolean: boolFlags("force", "no-fetch", "dry-run", "prune", "json")
|
|
7149
|
+
});
|
|
7150
|
+
if (parsed.positionals.length > 0) {
|
|
7151
|
+
throw new NeoError("usage", `model provider: unexpected argument "${parsed.positionals[0] ?? ""}"`);
|
|
7152
|
+
}
|
|
7153
|
+
if (parsed.bools.has("json")) return cmdProviderList(args, io, deps);
|
|
7154
|
+
if (!interactiveTty(deps)) {
|
|
7155
|
+
throw new NeoError("usage", "model provider: pass a subcommand (list|add|edit|rm) when not interactive");
|
|
7156
|
+
}
|
|
7157
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7158
|
+
const flags = rebuildFlags(parsed);
|
|
7159
|
+
await cmdOverview([], io, deps);
|
|
7160
|
+
for (; ; ) {
|
|
7161
|
+
const action = await prompts.select("Provider actions", PROVIDER_MENU);
|
|
7162
|
+
if (action === "done") return 0;
|
|
7163
|
+
const code = action === "add" ? await cmdProviderAdd([...flags], io, deps) : action === "edit" ? await cmdProviderEdit([...flags], io, deps) : action === "refresh" ? await cmdRefresh([...flags], io, deps) : await cmdProviderRemove([...flags], io, deps);
|
|
7164
|
+
if (code !== 0) return code;
|
|
7165
|
+
await printProviderSummary(io, deps);
|
|
7166
|
+
}
|
|
7167
|
+
}
|
|
7168
|
+
async function printProviderSummary(io, deps) {
|
|
7169
|
+
const { config } = await readConfig(resolveHome(deps));
|
|
7170
|
+
const entries = Object.entries(config.providers);
|
|
7171
|
+
io.stdout(`
|
|
7172
|
+
providers (${entries.length}): ${entries.map(([id]) => id).join(", ") || "(none)"}
|
|
7173
|
+
`);
|
|
7174
|
+
}
|
|
7126
7175
|
async function cmdProviderList(args, io, deps) {
|
|
7127
7176
|
const parsed = parseArgs(args, { valued: /* @__PURE__ */ new Set(), boolean: boolFlags("json") });
|
|
7128
7177
|
if (parsed.positionals.length > 0) throw new NeoError("usage", "model provider list: takes no arguments");
|
|
@@ -7153,6 +7202,79 @@ function requireProviderId(raw) {
|
|
|
7153
7202
|
}
|
|
7154
7203
|
return raw;
|
|
7155
7204
|
}
|
|
7205
|
+
function singlePositional(parsed, usage) {
|
|
7206
|
+
if (parsed.positionals.length > 1) throw new NeoError("usage", `${usage}: too many arguments`);
|
|
7207
|
+
return parsed.positionals[0];
|
|
7208
|
+
}
|
|
7209
|
+
function providerOptions(entries) {
|
|
7210
|
+
return entries.map(([id, provider]) => {
|
|
7211
|
+
const baseUrl = typeof provider.baseUrl === "string" ? provider.baseUrl : "-";
|
|
7212
|
+
return { value: id, label: id, hint: `${baseUrl} \xB7 ${providerModels(provider).length} model(s)` };
|
|
7213
|
+
});
|
|
7214
|
+
}
|
|
7215
|
+
function modelOptions(providers) {
|
|
7216
|
+
const options = [];
|
|
7217
|
+
for (const [id, provider] of Object.entries(providers)) {
|
|
7218
|
+
for (const entry of providerModels(provider)) {
|
|
7219
|
+
options.push({
|
|
7220
|
+
value: `${id}/${entry.id}`,
|
|
7221
|
+
label: `${id}/${entry.id}`,
|
|
7222
|
+
hint: describeModel(entry)
|
|
7223
|
+
});
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
return options;
|
|
7227
|
+
}
|
|
7228
|
+
async function resolveProviderId(parsed, deps, prompts, usage, entries, message) {
|
|
7229
|
+
const raw = singlePositional(parsed, usage);
|
|
7230
|
+
if (raw !== void 0) return requireProviderId(raw);
|
|
7231
|
+
if (!interactiveTty(deps)) throw new NeoError("usage", `usage: neo ${usage}`);
|
|
7232
|
+
if (entries.length === 0) {
|
|
7233
|
+
throw new NeoError(
|
|
7234
|
+
"failure",
|
|
7235
|
+
'no providers yet; add one with "neo model provider add <id> --base-url <url>"'
|
|
7236
|
+
);
|
|
7237
|
+
}
|
|
7238
|
+
return prompts.select(message, providerOptions(entries));
|
|
7239
|
+
}
|
|
7240
|
+
async function resolveModelRef(parsed, deps, prompts, providers, usage, message) {
|
|
7241
|
+
const raw = singlePositional(parsed, usage);
|
|
7242
|
+
if (raw !== void 0) return parseModelRef(raw);
|
|
7243
|
+
if (!interactiveTty(deps)) throw new NeoError("usage", `usage: neo ${usage}`);
|
|
7244
|
+
const options = modelOptions(providers);
|
|
7245
|
+
if (options.length === 0) {
|
|
7246
|
+
throw new NeoError(
|
|
7247
|
+
"failure",
|
|
7248
|
+
'no models configured yet; add one with "neo model add <provider>/<model>" or run "neo model refresh"'
|
|
7249
|
+
);
|
|
7250
|
+
}
|
|
7251
|
+
return parseModelRef(await prompts.select(message, options));
|
|
7252
|
+
}
|
|
7253
|
+
async function resolveModelTarget(parsed, deps, prompts, providers, usage) {
|
|
7254
|
+
const raw = singlePositional(parsed, usage);
|
|
7255
|
+
if (raw !== void 0) return parseModelRef(raw);
|
|
7256
|
+
if (!interactiveTty(deps)) throw new NeoError("usage", `usage: neo ${usage}`);
|
|
7257
|
+
const entries = Object.entries(providers);
|
|
7258
|
+
if (entries.length === 0) {
|
|
7259
|
+
throw new NeoError(
|
|
7260
|
+
"failure",
|
|
7261
|
+
'no providers yet; add one with "neo model provider add <id> --base-url <url>"'
|
|
7262
|
+
);
|
|
7263
|
+
}
|
|
7264
|
+
const provider = entries.length === 1 ? entries[0][0] : await prompts.select("Add a model to which provider?", providerOptions(entries));
|
|
7265
|
+
const model = (await prompts.text({
|
|
7266
|
+
message: "Model id (as the provider exposes it)",
|
|
7267
|
+
validate: (value) => value.trim().length > 0 ? void 0 : "model id is required"
|
|
7268
|
+
})).trim();
|
|
7269
|
+
return { provider, model };
|
|
7270
|
+
}
|
|
7271
|
+
async function confirmRemoval(io, deps, prompts, parsed, lines) {
|
|
7272
|
+
if (parsed.bools.has("yes") || parsed.bools.has("force")) return true;
|
|
7273
|
+
if (!interactiveTty(deps)) return true;
|
|
7274
|
+
for (const line of lines) io.stdout(`${line}
|
|
7275
|
+
`);
|
|
7276
|
+
return prompts.confirm("proceed with this removal?", false);
|
|
7277
|
+
}
|
|
7156
7278
|
function parseHeaders(values) {
|
|
7157
7279
|
const headers = {};
|
|
7158
7280
|
for (const raw of values) {
|
|
@@ -7210,9 +7332,17 @@ async function cmdProviderAdd(args, io, deps) {
|
|
|
7210
7332
|
if (parsed.bools.has("json")) {
|
|
7211
7333
|
throw new NeoError("usage", "model provider add: --json is not available on write commands");
|
|
7212
7334
|
}
|
|
7213
|
-
const id = requireProviderId(expectSinglePositional(parsed, "model provider add <id>"));
|
|
7214
7335
|
const isTty = interactiveTty(deps);
|
|
7215
7336
|
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7337
|
+
const rawId = singlePositional(parsed, "model provider add <id>");
|
|
7338
|
+
if (rawId === void 0 && !isTty) throw new NeoError("usage", "usage: neo model provider add <id>");
|
|
7339
|
+
const id = requireProviderId(
|
|
7340
|
+
rawId ?? (await prompts.text({
|
|
7341
|
+
message: "Provider id",
|
|
7342
|
+
placeholder: "litellm",
|
|
7343
|
+
validate: (value) => PROVIDER_ID.test(value.trim()) ? void 0 : `expected ${PROVIDER_ID.source}`
|
|
7344
|
+
})).trim()
|
|
7345
|
+
);
|
|
7216
7346
|
const headerValues = parsed.flags.get("header") ?? [];
|
|
7217
7347
|
const headers = parseHeaders(headerValues);
|
|
7218
7348
|
let baseUrl = lastFlag(parsed, "base-url");
|
|
@@ -7271,12 +7401,19 @@ async function cmdProviderEdit(args, io, deps) {
|
|
|
7271
7401
|
if (parsed.bools.has("json")) {
|
|
7272
7402
|
throw new NeoError("usage", "model provider edit: --json is not available on write commands");
|
|
7273
7403
|
}
|
|
7274
|
-
const id = requireProviderId(expectSinglePositional(parsed, "model provider edit <id>"));
|
|
7275
7404
|
const home = resolveHome(deps);
|
|
7276
7405
|
const before = await readConfig(home);
|
|
7406
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7407
|
+
const id = await resolveProviderId(
|
|
7408
|
+
parsed,
|
|
7409
|
+
deps,
|
|
7410
|
+
prompts,
|
|
7411
|
+
"model provider edit <id>",
|
|
7412
|
+
Object.entries(before.config.providers),
|
|
7413
|
+
"Edit which provider?"
|
|
7414
|
+
);
|
|
7277
7415
|
const current = before.config.providers[id];
|
|
7278
7416
|
if (current === void 0) throw new NeoError("failure", `unknown provider "${id}"`);
|
|
7279
|
-
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7280
7417
|
const setHeaders = parseHeaders(parsed.flags.get("header") ?? []);
|
|
7281
7418
|
const rmHeaders = parsed.flags.get("rm-header") ?? [];
|
|
7282
7419
|
let baseUrl = lastFlag(parsed, "base-url");
|
|
@@ -7339,10 +7476,18 @@ async function cmdProviderRemove(args, io, deps) {
|
|
|
7339
7476
|
if (parsed.bools.has("json")) {
|
|
7340
7477
|
throw new NeoError("usage", "model provider rm: --json is not available on write commands");
|
|
7341
7478
|
}
|
|
7342
|
-
const id = requireProviderId(expectSinglePositional(parsed, "model provider rm <id>"));
|
|
7343
|
-
const force = parsed.bools.has("force");
|
|
7344
7479
|
const home = resolveHome(deps);
|
|
7345
7480
|
const before = await readConfig(home);
|
|
7481
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7482
|
+
const id = await resolveProviderId(
|
|
7483
|
+
parsed,
|
|
7484
|
+
deps,
|
|
7485
|
+
prompts,
|
|
7486
|
+
"model provider rm <id>",
|
|
7487
|
+
Object.entries(before.config.providers),
|
|
7488
|
+
"Remove which provider?"
|
|
7489
|
+
);
|
|
7490
|
+
const force = parsed.bools.has("force");
|
|
7346
7491
|
if (!hasProvider(before, id)) throw new NeoError("failure", `unknown provider "${id}"`);
|
|
7347
7492
|
const configRef = providerReferencedByDefault(before, id);
|
|
7348
7493
|
const roles = await roleRefs(home, (ref) => ref.provider === id);
|
|
@@ -7356,6 +7501,14 @@ async function cmdProviderRemove(args, io, deps) {
|
|
|
7356
7501
|
`provider "${id}" is still referenced by ${refs.join(", ")}; pick another default or pass --force`
|
|
7357
7502
|
);
|
|
7358
7503
|
}
|
|
7504
|
+
const models = providerModels(before.config.providers[id]);
|
|
7505
|
+
if (!await confirmRemoval(io, deps, prompts, parsed, [
|
|
7506
|
+
`will remove provider "${id}" and ${models.length} model(s)`,
|
|
7507
|
+
...models.map((model) => ` ${model.id} ${describeModel(model)}`)
|
|
7508
|
+
])) {
|
|
7509
|
+
io.stderr("aborted, nothing removed\n");
|
|
7510
|
+
return 0;
|
|
7511
|
+
}
|
|
7359
7512
|
await withHomeLock(home, async () => {
|
|
7360
7513
|
const loaded = await readConfig(home);
|
|
7361
7514
|
if (!hasProvider(loaded, id)) throw new NeoError("failure", `unknown provider "${id}"`);
|
|
@@ -7560,10 +7713,18 @@ async function cmdModelAdd(args, io, deps) {
|
|
|
7560
7713
|
if (parsed.bools.has("json")) {
|
|
7561
7714
|
throw new NeoError("usage", "model add: --json is not available on write commands");
|
|
7562
7715
|
}
|
|
7563
|
-
const
|
|
7716
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7564
7717
|
const fields = collectModelFields(parsed) ?? {};
|
|
7565
|
-
const entry = withModelDefaults(applyFields({ id: ref.model }, fields));
|
|
7566
7718
|
const home = resolveHome(deps);
|
|
7719
|
+
const before = await readConfig(home);
|
|
7720
|
+
const ref = await resolveModelTarget(
|
|
7721
|
+
parsed,
|
|
7722
|
+
deps,
|
|
7723
|
+
prompts,
|
|
7724
|
+
before.config.providers,
|
|
7725
|
+
"model add <provider>/<model>"
|
|
7726
|
+
);
|
|
7727
|
+
const entry = withModelDefaults(applyFields({ id: ref.model }, fields));
|
|
7567
7728
|
await withHomeLock(home, async () => {
|
|
7568
7729
|
const loaded = await readConfig(home);
|
|
7569
7730
|
const provider = loaded.config.providers[ref.provider];
|
|
@@ -7586,10 +7747,18 @@ async function cmdModelRemove(args, io, deps) {
|
|
|
7586
7747
|
if (parsed.bools.has("json")) {
|
|
7587
7748
|
throw new NeoError("usage", "model rm: --json is not available on write commands");
|
|
7588
7749
|
}
|
|
7589
|
-
const ref = parseModelRef(expectSinglePositional(parsed, "model rm <provider>/<model>"));
|
|
7590
|
-
const force = parsed.bools.has("force");
|
|
7591
7750
|
const home = resolveHome(deps);
|
|
7751
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7592
7752
|
const before = await readConfig(home);
|
|
7753
|
+
const ref = await resolveModelRef(
|
|
7754
|
+
parsed,
|
|
7755
|
+
deps,
|
|
7756
|
+
prompts,
|
|
7757
|
+
before.config.providers,
|
|
7758
|
+
"model rm <provider>/<model>",
|
|
7759
|
+
"Remove which model?"
|
|
7760
|
+
);
|
|
7761
|
+
const force = parsed.bools.has("force");
|
|
7593
7762
|
const found = findProviderModel(before.config.providers, ref.provider, ref.model);
|
|
7594
7763
|
if (found === void 0) throw new NeoError("failure", `unknown model "${ref.provider}/${ref.model}"`);
|
|
7595
7764
|
const isDefault = modelReferencedByDefault(before, ref.provider, ref.model);
|
|
@@ -7603,6 +7772,12 @@ async function cmdModelRemove(args, io, deps) {
|
|
|
7603
7772
|
home,
|
|
7604
7773
|
(defaults) => defaults.provider === ref.provider && defaults.model === ref.model
|
|
7605
7774
|
);
|
|
7775
|
+
if (!await confirmRemoval(io, deps, prompts, parsed, [
|
|
7776
|
+
`will remove ${ref.provider}/${ref.model} ${describeModel(found.model)}`
|
|
7777
|
+
])) {
|
|
7778
|
+
io.stderr("aborted, nothing removed\n");
|
|
7779
|
+
return 0;
|
|
7780
|
+
}
|
|
7606
7781
|
await withHomeLock(home, async () => {
|
|
7607
7782
|
const loaded = await readConfig(home);
|
|
7608
7783
|
await writeConfig(home, removeModel(loaded, ref.provider, ref.model, { force }));
|
|
@@ -7684,12 +7859,19 @@ async function cmdModelEdit(args, io, deps) {
|
|
|
7684
7859
|
if (parsed.bools.has("json")) {
|
|
7685
7860
|
throw new NeoError("usage", "model edit: --json is not available on write commands");
|
|
7686
7861
|
}
|
|
7687
|
-
const ref = parseModelRef(expectSinglePositional(parsed, "model edit <provider>/<model>"));
|
|
7688
7862
|
const home = resolveHome(deps);
|
|
7689
7863
|
const before = await readConfig(home);
|
|
7864
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7865
|
+
const ref = await resolveModelRef(
|
|
7866
|
+
parsed,
|
|
7867
|
+
deps,
|
|
7868
|
+
prompts,
|
|
7869
|
+
before.config.providers,
|
|
7870
|
+
"model edit <provider>/<model>",
|
|
7871
|
+
"Edit which model?"
|
|
7872
|
+
);
|
|
7690
7873
|
const found = findProviderModel(before.config.providers, ref.provider, ref.model);
|
|
7691
7874
|
if (found === void 0) throw new NeoError("failure", `unknown model "${ref.provider}/${ref.model}"`);
|
|
7692
|
-
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7693
7875
|
const fields = collectModelFields(parsed);
|
|
7694
7876
|
let next;
|
|
7695
7877
|
if (fields === void 0) {
|
|
@@ -7728,8 +7910,17 @@ async function cmdModelUse(args, io, deps) {
|
|
|
7728
7910
|
if (parsed.bools.has("json")) {
|
|
7729
7911
|
throw new NeoError("usage", "model use: --json is not available on write commands");
|
|
7730
7912
|
}
|
|
7731
|
-
const ref = parseModelRef(expectSinglePositional(parsed, "model use <provider>/<model>"));
|
|
7732
7913
|
const home = resolveHome(deps);
|
|
7914
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
7915
|
+
const before = await readConfig(home);
|
|
7916
|
+
const ref = await resolveModelRef(
|
|
7917
|
+
parsed,
|
|
7918
|
+
deps,
|
|
7919
|
+
prompts,
|
|
7920
|
+
before.config.providers,
|
|
7921
|
+
"model use <provider>/<model>",
|
|
7922
|
+
"Set which model as default?"
|
|
7923
|
+
);
|
|
7733
7924
|
await withHomeLock(home, async () => {
|
|
7734
7925
|
const loaded = await readConfig(home);
|
|
7735
7926
|
await writeConfig(home, setDefaultModel(loaded, ref));
|
|
@@ -7740,15 +7931,16 @@ async function cmdModelUse(args, io, deps) {
|
|
|
7740
7931
|
}
|
|
7741
7932
|
var MODEL_USAGE = [
|
|
7742
7933
|
"neo model",
|
|
7743
|
-
"neo model provider
|
|
7934
|
+
"neo model provider (TTY: interactive provider menu; add/edit/refresh/remove in one session)",
|
|
7935
|
+
"neo model provider add [<id>] --base-url <url> [--api <api>] [--api-key env:VAR] [--header k=v]\u2026 [--no-fetch]",
|
|
7744
7936
|
"neo model provider list [--json]",
|
|
7745
|
-
"neo model provider edit <id> [--base-url \u2026] [--api \u2026] [--api-key env:VAR] [--header k=v]\u2026 [--rm-header k]\u2026",
|
|
7746
|
-
"neo model provider rm <id> [--force]",
|
|
7937
|
+
"neo model provider edit [<id>] [--base-url \u2026] [--api \u2026] [--api-key env:VAR] [--header k=v]\u2026 [--rm-header k]\u2026",
|
|
7938
|
+
"neo model provider rm [<id>] [--force|--yes]",
|
|
7747
7939
|
"neo model refresh [<provider>] [--dry-run] [--prune]",
|
|
7748
|
-
"neo model add <provider>/<model> [--name \u2026] [--context 1M] [--max-tokens 16K] [--input text,image] [--reasoning|--no-reasoning] [--thinking-levels low,high,max] [--thinking-level high]",
|
|
7749
|
-
"neo model edit <provider>/<model> [\u540C\u4E0A\u5B57\u6BB5 flags;\u65E0 flags \
|
|
7750
|
-
"neo model rm <provider>/<model> [--force]",
|
|
7751
|
-
"neo model use <provider>/<model>"
|
|
7940
|
+
"neo model add [<provider>/<model>] [--name \u2026] [--context 1M] [--max-tokens 16K] [--input text,image] [--reasoning|--no-reasoning] [--thinking-levels low,high,max] [--thinking-level high]",
|
|
7941
|
+
"neo model edit [<provider>/<model>] [\u540C\u4E0A\u5B57\u6BB5 flags;\u65E0 flags \u65F6\u8FDB\u5165\u4EA4\u4E92\u7F16\u8F91]",
|
|
7942
|
+
"neo model rm [<provider>/<model>] [--force|--yes]",
|
|
7943
|
+
"neo model use [<provider>/<model>]"
|
|
7752
7944
|
];
|
|
7753
7945
|
var MODEL_FLAGS_HELP = [
|
|
7754
7946
|
"--base-url <url> provider API base URL (include /v1)",
|
|
@@ -7762,7 +7954,8 @@ var MODEL_FLAGS_HELP = [
|
|
|
7762
7954
|
"--reasoning/--no-reasoning whether the model supports thinking (default: yes)",
|
|
7763
7955
|
"--thinking-levels a,b available levels (default: low,high,max)",
|
|
7764
7956
|
"--thinking-level <lvl> startup level (must be listed in --thinking-levels)",
|
|
7765
|
-
"--force override references when removing",
|
|
7957
|
+
"--force override references when removing (also skips the confirmation)",
|
|
7958
|
+
"--yes skip the interactive removal confirmation",
|
|
7766
7959
|
"--dry-run refresh: preview only",
|
|
7767
7960
|
"--prune refresh: drop models that disappeared upstream"
|
|
7768
7961
|
];
|
|
@@ -7807,7 +8000,7 @@ var COMMANDS = [
|
|
|
7807
8000
|
"--strategy <name> conflict winner: first | newest | skip (default: first)",
|
|
7808
8001
|
"--scan-agents scan agent skill dirs for unmanaged installs",
|
|
7809
8002
|
"--absorb-links absorb registry-scope links pointing into neo home",
|
|
7810
|
-
|
|
8003
|
+
'--role <name> target role (preview defaults to "default"; required with --apply)'
|
|
7811
8004
|
]
|
|
7812
8005
|
},
|
|
7813
8006
|
{
|
|
@@ -7826,10 +8019,10 @@ var COMMANDS = [
|
|
|
7826
8019
|
{
|
|
7827
8020
|
name: "add",
|
|
7828
8021
|
summary: "install skills from a single source into a role",
|
|
7829
|
-
usage: ["neo add <source> [--skill|-s <skill>\u2026|*] [
|
|
8022
|
+
usage: ["neo add <source> --role <name> [--skill|-s <skill>\u2026|*] [-l]"],
|
|
7830
8023
|
flags: [
|
|
7831
8024
|
"--skill, -s <skill> skill to install (repeatable; comma-separated; * = all)",
|
|
7832
|
-
"--role <name> target role (default
|
|
8025
|
+
"--role <name> target role (required; no implicit default \u2014 TTY shows a picker)",
|
|
7833
8026
|
"-l list source skills and exit (upstream text, passed through)",
|
|
7834
8027
|
" (without --skill/-s: TTY multi-select; non-TTY requires a flag)"
|
|
7835
8028
|
]
|
|
@@ -7847,9 +8040,9 @@ var COMMANDS = [
|
|
|
7847
8040
|
name: "remove",
|
|
7848
8041
|
aliases: ["rm"],
|
|
7849
8042
|
summary: "remove skills from a role and re-converge mounts (the only TTY confirmation)",
|
|
7850
|
-
usage: ["neo remove <skills\u2026>
|
|
8043
|
+
usage: ["neo remove <skills\u2026> --role <name> [--yes]"],
|
|
7851
8044
|
flags: [
|
|
7852
|
-
"--role <name> source role (default
|
|
8045
|
+
"--role <name> source role (required; no implicit default \u2014 TTY shows a picker)",
|
|
7853
8046
|
"--yes skip the TTY confirmation (required when not interactive)"
|
|
7854
8047
|
]
|
|
7855
8048
|
},
|
|
@@ -8156,19 +8349,13 @@ async function importExistingSkills(home, io, deps) {
|
|
|
8156
8349
|
const more = importable.length > 6 ? `, \u2026 (+${importable.length - 6})` : "";
|
|
8157
8350
|
io.stdout(`found ${importable.length} existing skill(s) outside neo: ${sample}${more}
|
|
8158
8351
|
`);
|
|
8159
|
-
const ask = deps.ask ?? promptAsk;
|
|
8160
8352
|
const confirm2 = deps.confirm ?? promptConfirm;
|
|
8161
|
-
const answer = await confirm2(
|
|
8162
|
-
"import existing skills into a neo role? (default is inherited by every role)",
|
|
8163
|
-
true
|
|
8164
|
-
);
|
|
8353
|
+
const answer = await confirm2("import existing skills into a neo role?", true);
|
|
8165
8354
|
if (!answer) {
|
|
8166
8355
|
io.stdout("left untouched; import later with: neo migrate --scan-agents\n");
|
|
8167
8356
|
return 0;
|
|
8168
8357
|
}
|
|
8169
|
-
const role = await
|
|
8170
|
-
const created = role !== "default" && !await pathExists(roleDir(home, role));
|
|
8171
|
-
if (created) await createRole(home, role);
|
|
8358
|
+
const role = await resolveRoleTarget(io, deps, void 0, "import", true);
|
|
8172
8359
|
const report = await runMigrate(ports, home, {
|
|
8173
8360
|
...common,
|
|
8174
8361
|
role,
|
|
@@ -8177,7 +8364,7 @@ async function importExistingSkills(home, io, deps) {
|
|
|
8177
8364
|
});
|
|
8178
8365
|
const imported = report.items.filter((item) => item.disposition === "absorb").length;
|
|
8179
8366
|
const failed = report.items.filter((item) => item.disposition === "error");
|
|
8180
|
-
io.stdout(`imported ${imported} skill(s) into role ${role}
|
|
8367
|
+
io.stdout(`imported ${imported} skill(s) into role ${role}
|
|
8181
8368
|
`);
|
|
8182
8369
|
if (report.quarantineDir !== null) {
|
|
8183
8370
|
io.stdout(`duplicate/conflicting copies preserved in ${report.quarantineDir}
|
|
@@ -8196,27 +8383,80 @@ async function importExistingSkills(home, io, deps) {
|
|
|
8196
8383
|
}
|
|
8197
8384
|
return 0;
|
|
8198
8385
|
}
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8386
|
+
var NEW_ROLE_CHOICE = "__new_role__";
|
|
8387
|
+
async function resolveRoleTarget(io, deps, roleFlag, action, allowCreate) {
|
|
8388
|
+
const home = resolveHome(deps);
|
|
8389
|
+
if (roleFlag !== void 0) {
|
|
8390
|
+
validateRoleName(roleFlag);
|
|
8391
|
+
if (roleFlag !== "default" && !await pathExists(roleDir(home, roleFlag))) {
|
|
8392
|
+
throw new NeoError(
|
|
8393
|
+
"state",
|
|
8394
|
+
`${action}: role "${roleFlag}" does not exist (create it first: neo create ${roleFlag})`
|
|
8395
|
+
);
|
|
8396
|
+
}
|
|
8397
|
+
return roleFlag;
|
|
8398
|
+
}
|
|
8399
|
+
if (!interactiveTty(deps)) {
|
|
8400
|
+
const names = (await listRoles(home, null)).map((role) => role.name);
|
|
8401
|
+
const known = names.includes("default") ? names : ["default", ...names];
|
|
8402
|
+
throw new NeoError(
|
|
8403
|
+
"usage",
|
|
8404
|
+
`${action}: --role is required (roles: ${known.join(", ")}); "default" is inherited by every role \u2014 pass --role default to opt in`
|
|
8405
|
+
);
|
|
8406
|
+
}
|
|
8407
|
+
const prompts = deps.prompts ?? defaultPromptPort;
|
|
8408
|
+
const { config } = await readConfig(home);
|
|
8409
|
+
const askTarget = action === "remove" ? `${action}: which role to remove from?` : `${action}: which role to install into?`;
|
|
8410
|
+
const warnDefault = action === "remove" ? "default is inherited by every role \u2014 removing there affects every role. Proceed?" : "default is inherited by every role \u2014 install there?";
|
|
8411
|
+
for (; ; ) {
|
|
8412
|
+
const roles = await listRoles(home, config.activeRole);
|
|
8413
|
+
const listed = roles.some((role) => role.name === "default") ? roles : [{ name: "default", skills: 0, active: config.activeRole === null }, ...roles];
|
|
8414
|
+
const options = listed.map((role) => ({
|
|
8415
|
+
value: role.name,
|
|
8416
|
+
label: role.name,
|
|
8417
|
+
hint: [
|
|
8418
|
+
`${role.skills} skill(s)`,
|
|
8419
|
+
role.active ? "active" : null,
|
|
8420
|
+
role.name === "default" ? "inherited by every role" : null
|
|
8421
|
+
].filter((part) => part !== null).join(", ")
|
|
8422
|
+
}));
|
|
8423
|
+
if (allowCreate) options.push({ value: NEW_ROLE_CHOICE, label: "Create a new role\u2026" });
|
|
8424
|
+
const chosen = await prompts.select(askTarget, options);
|
|
8425
|
+
if (chosen === NEW_ROLE_CHOICE) {
|
|
8426
|
+
const name = (await prompts.text({
|
|
8427
|
+
message: "New role name",
|
|
8428
|
+
validate: (value) => {
|
|
8429
|
+
const trimmed = value.trim();
|
|
8430
|
+
if (trimmed === "default") return "default always exists \u2014 pick it from the list";
|
|
8431
|
+
try {
|
|
8432
|
+
validateRoleName(trimmed);
|
|
8433
|
+
} catch (error) {
|
|
8434
|
+
return error.message;
|
|
8435
|
+
}
|
|
8436
|
+
return void 0;
|
|
8437
|
+
}
|
|
8438
|
+
})).trim();
|
|
8439
|
+
if (!await pathExists(roleDir(home, name))) {
|
|
8440
|
+
await createRole(home, name);
|
|
8441
|
+
io.stdout(`created role ${name}
|
|
8208
8442
|
`);
|
|
8443
|
+
}
|
|
8444
|
+
return name;
|
|
8209
8445
|
}
|
|
8446
|
+
if (chosen === "default") {
|
|
8447
|
+
const agreed = await prompts.confirm(warnDefault, false);
|
|
8448
|
+
if (agreed) return "default";
|
|
8449
|
+
continue;
|
|
8450
|
+
}
|
|
8451
|
+
return chosen;
|
|
8210
8452
|
}
|
|
8211
|
-
throw new NeoError("usage", "init: invalid role name (expected ^[a-z0-9][a-z0-9-]{0,63}$)");
|
|
8212
8453
|
}
|
|
8213
8454
|
async function cmdAdd(args, io, deps) {
|
|
8214
8455
|
const parsed = parseArgs(args, {
|
|
8215
8456
|
valued: /* @__PURE__ */ new Set(["s", "skill", "role"]),
|
|
8216
8457
|
boolean: boolFlags("l")
|
|
8217
8458
|
});
|
|
8218
|
-
const source = expectSinglePositional(parsed, "add <source>");
|
|
8219
|
-
const role = lastFlag(parsed, "role") ?? "default";
|
|
8459
|
+
const source = expectSinglePositional(parsed, "add <source> --role <name>");
|
|
8220
8460
|
const listRequested = parsed.bools.has("l");
|
|
8221
8461
|
let skills = [...parsed.flags.get("s") ?? [], ...parsed.flags.get("skill") ?? []].flatMap((value) => value.split(",")).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
8222
8462
|
if (skills.length > 0 && listRequested) {
|
|
@@ -8238,6 +8478,7 @@ async function cmdAdd(args, io, deps) {
|
|
|
8238
8478
|
if (result.stderr) io.stderr(result.stderr);
|
|
8239
8479
|
return result.code === 0 ? 0 : 1;
|
|
8240
8480
|
}
|
|
8481
|
+
const role = await resolveRoleTarget(io, deps, lastFlag(parsed, "role"), "add", true);
|
|
8241
8482
|
if (skills.length === 0) {
|
|
8242
8483
|
const isTty = interactiveTty(deps);
|
|
8243
8484
|
if (!isTty) {
|
|
@@ -8254,9 +8495,10 @@ async function cmdAdd(args, io, deps) {
|
|
|
8254
8495
|
}
|
|
8255
8496
|
const options = parseSourceSkillList(result.stdout);
|
|
8256
8497
|
if (options.length === 0) {
|
|
8498
|
+
io.stdout(result.stdout);
|
|
8257
8499
|
throw new NeoError(
|
|
8258
8500
|
"failure",
|
|
8259
|
-
"add: could not parse the source skill list
|
|
8501
|
+
"add: could not parse the source skill list (the raw upstream list is above); install with --skill <name>, or inspect again with -l"
|
|
8260
8502
|
);
|
|
8261
8503
|
}
|
|
8262
8504
|
const only = options[0]?.name;
|
|
@@ -8799,7 +9041,8 @@ async function cmdMigrate(args, io, deps) {
|
|
|
8799
9041
|
`migrate: unknown strategy "${strategy}" (expected ${MIGRATE_STRATEGIES.join("|")})`
|
|
8800
9042
|
);
|
|
8801
9043
|
}
|
|
8802
|
-
const
|
|
9044
|
+
const roleFlag = lastFlag(parsed, "role");
|
|
9045
|
+
const role = parsed.bools.has("apply") ? await resolveRoleTarget(io, deps, roleFlag, "migrate", true) : roleFlag;
|
|
8803
9046
|
const report = await runMigrate({ link: nodeLinkPort(), now: deps.now }, resolveHome(deps), {
|
|
8804
9047
|
homedir: deps.homedir,
|
|
8805
9048
|
...role !== void 0 ? { role } : {},
|
|
@@ -9074,7 +9317,7 @@ async function cmdUpdate(args, io, deps) {
|
|
|
9074
9317
|
async function cmdRemove(args, io, deps) {
|
|
9075
9318
|
const parsed = parseArgs(args, { valued: /* @__PURE__ */ new Set(["role"]), boolean: boolFlags() });
|
|
9076
9319
|
if (parsed.positionals.length === 0) throw new NeoError("usage", "remove: at least one skill name required");
|
|
9077
|
-
const role = lastFlag(parsed, "role")
|
|
9320
|
+
const role = await resolveRoleTarget(io, deps, lastFlag(parsed, "role"), "remove", false);
|
|
9078
9321
|
const home = resolveHome(deps);
|
|
9079
9322
|
const plan = await planRemove(home, { skills: parsed.positionals, role });
|
|
9080
9323
|
for (const name of plan.missing) io.stderr(`remove ${name}: not found in role "${role}"
|