@compass-aiden/neo 0.2.4 → 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 CHANGED
@@ -17,18 +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
30
  - 不想记参数:TTY 下裸跑 `neo model provider` 进供应商菜单(新增/编辑/refresh/删除),`neo model edit|rm|use` 不给目标会先让你从清单里选;删除会列出影响面再确认。
30
- - `neo init` 会扫描 `~/.agents/skills` 与各 agent 技能目录:有存量技能时询问导入 `default`(所有角色继承)或一个新角色;拒绝则原样不动。
31
- - 想自己控制收编节奏:`neo migrate`(预览)→ `neo migrate --scan-agents --apply`。
31
+ - `neo init` 会扫描 `~/.agents/skills` 与各 agent 技能目录:有存量技能时询问导入到哪个角色(TTY 选择器,可就地新建;选 `default` 再确认);拒绝则原样不动。
32
+ - 想自己控制收编节奏:`neo migrate`(预览,无需 `--role`)→ `neo migrate --scan-agents --apply --role <name>`。
32
33
  - 仍需要 0.1 的全局挂载:`neo use writer --global`;卸载:`neo off --global`。
33
34
 
34
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.4";
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._-]*)\s*$/.exec(line)?.[1];
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 };
@@ -8000,7 +8000,7 @@ var COMMANDS = [
8000
8000
  "--strategy <name> conflict winner: first | newest | skip (default: first)",
8001
8001
  "--scan-agents scan agent skill dirs for unmanaged installs",
8002
8002
  "--absorb-links absorb registry-scope links pointing into neo home",
8003
- "--role <name> target role (default: default)"
8003
+ '--role <name> target role (preview defaults to "default"; required with --apply)'
8004
8004
  ]
8005
8005
  },
8006
8006
  {
@@ -8019,10 +8019,10 @@ var COMMANDS = [
8019
8019
  {
8020
8020
  name: "add",
8021
8021
  summary: "install skills from a single source into a role",
8022
- usage: ["neo add <source> [--skill|-s <skill>\u2026|*] [--role <name>] [-l]"],
8022
+ usage: ["neo add <source> --role <name> [--skill|-s <skill>\u2026|*] [-l]"],
8023
8023
  flags: [
8024
8024
  "--skill, -s <skill> skill to install (repeatable; comma-separated; * = all)",
8025
- "--role <name> target role (default: default)",
8025
+ "--role <name> target role (required; no implicit default \u2014 TTY shows a picker)",
8026
8026
  "-l list source skills and exit (upstream text, passed through)",
8027
8027
  " (without --skill/-s: TTY multi-select; non-TTY requires a flag)"
8028
8028
  ]
@@ -8040,9 +8040,9 @@ var COMMANDS = [
8040
8040
  name: "remove",
8041
8041
  aliases: ["rm"],
8042
8042
  summary: "remove skills from a role and re-converge mounts (the only TTY confirmation)",
8043
- usage: ["neo remove <skills\u2026> [--role <name>] [--yes]"],
8043
+ usage: ["neo remove <skills\u2026> --role <name> [--yes]"],
8044
8044
  flags: [
8045
- "--role <name> source role (default: default)",
8045
+ "--role <name> source role (required; no implicit default \u2014 TTY shows a picker)",
8046
8046
  "--yes skip the TTY confirmation (required when not interactive)"
8047
8047
  ]
8048
8048
  },
@@ -8349,19 +8349,13 @@ async function importExistingSkills(home, io, deps) {
8349
8349
  const more = importable.length > 6 ? `, \u2026 (+${importable.length - 6})` : "";
8350
8350
  io.stdout(`found ${importable.length} existing skill(s) outside neo: ${sample}${more}
8351
8351
  `);
8352
- const ask = deps.ask ?? promptAsk;
8353
8352
  const confirm2 = deps.confirm ?? promptConfirm;
8354
- const answer = await confirm2(
8355
- "import existing skills into a neo role? (default is inherited by every role)",
8356
- true
8357
- );
8353
+ const answer = await confirm2("import existing skills into a neo role?", true);
8358
8354
  if (!answer) {
8359
8355
  io.stdout("left untouched; import later with: neo migrate --scan-agents\n");
8360
8356
  return 0;
8361
8357
  }
8362
- const role = await askImportRole(io, ask);
8363
- const created = role !== "default" && !await pathExists(roleDir(home, role));
8364
- if (created) await createRole(home, role);
8358
+ const role = await resolveRoleTarget(io, deps, void 0, "import", true);
8365
8359
  const report = await runMigrate(ports, home, {
8366
8360
  ...common,
8367
8361
  role,
@@ -8370,7 +8364,7 @@ async function importExistingSkills(home, io, deps) {
8370
8364
  });
8371
8365
  const imported = report.items.filter((item) => item.disposition === "absorb").length;
8372
8366
  const failed = report.items.filter((item) => item.disposition === "error");
8373
- io.stdout(`imported ${imported} skill(s) into role ${role}${created ? " (role created)" : ""}
8367
+ io.stdout(`imported ${imported} skill(s) into role ${role}
8374
8368
  `);
8375
8369
  if (report.quarantineDir !== null) {
8376
8370
  io.stdout(`duplicate/conflicting copies preserved in ${report.quarantineDir}
@@ -8389,27 +8383,80 @@ async function importExistingSkills(home, io, deps) {
8389
8383
  }
8390
8384
  return 0;
8391
8385
  }
8392
- async function askImportRole(io, ask) {
8393
- for (let attempt = 0; attempt < 3; attempt++) {
8394
- const name = (await ask("role to import into [default]:", "default")).trim();
8395
- if (name.length === 0 || name === "default") return "default";
8396
- try {
8397
- validateRoleName(name);
8398
- return name;
8399
- } catch (error) {
8400
- io.stderr(`${error.message}
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}
8401
8442
  `);
8443
+ }
8444
+ return name;
8402
8445
  }
8446
+ if (chosen === "default") {
8447
+ const agreed = await prompts.confirm(warnDefault, false);
8448
+ if (agreed) return "default";
8449
+ continue;
8450
+ }
8451
+ return chosen;
8403
8452
  }
8404
- throw new NeoError("usage", "init: invalid role name (expected ^[a-z0-9][a-z0-9-]{0,63}$)");
8405
8453
  }
8406
8454
  async function cmdAdd(args, io, deps) {
8407
8455
  const parsed = parseArgs(args, {
8408
8456
  valued: /* @__PURE__ */ new Set(["s", "skill", "role"]),
8409
8457
  boolean: boolFlags("l")
8410
8458
  });
8411
- const source = expectSinglePositional(parsed, "add <source>");
8412
- const role = lastFlag(parsed, "role") ?? "default";
8459
+ const source = expectSinglePositional(parsed, "add <source> --role <name>");
8413
8460
  const listRequested = parsed.bools.has("l");
8414
8461
  let skills = [...parsed.flags.get("s") ?? [], ...parsed.flags.get("skill") ?? []].flatMap((value) => value.split(",")).map((s) => s.trim()).filter((s) => s.length > 0);
8415
8462
  if (skills.length > 0 && listRequested) {
@@ -8431,6 +8478,7 @@ async function cmdAdd(args, io, deps) {
8431
8478
  if (result.stderr) io.stderr(result.stderr);
8432
8479
  return result.code === 0 ? 0 : 1;
8433
8480
  }
8481
+ const role = await resolveRoleTarget(io, deps, lastFlag(parsed, "role"), "add", true);
8434
8482
  if (skills.length === 0) {
8435
8483
  const isTty = interactiveTty(deps);
8436
8484
  if (!isTty) {
@@ -8447,9 +8495,10 @@ async function cmdAdd(args, io, deps) {
8447
8495
  }
8448
8496
  const options = parseSourceSkillList(result.stdout);
8449
8497
  if (options.length === 0) {
8498
+ io.stdout(result.stdout);
8450
8499
  throw new NeoError(
8451
8500
  "failure",
8452
- "add: could not parse the source skill list; run with -l to inspect it, or pass --skill <name>"
8501
+ "add: could not parse the source skill list (the raw upstream list is above); install with --skill <name>, or inspect again with -l"
8453
8502
  );
8454
8503
  }
8455
8504
  const only = options[0]?.name;
@@ -8992,7 +9041,8 @@ async function cmdMigrate(args, io, deps) {
8992
9041
  `migrate: unknown strategy "${strategy}" (expected ${MIGRATE_STRATEGIES.join("|")})`
8993
9042
  );
8994
9043
  }
8995
- const role = lastFlag(parsed, "role");
9044
+ const roleFlag = lastFlag(parsed, "role");
9045
+ const role = parsed.bools.has("apply") ? await resolveRoleTarget(io, deps, roleFlag, "migrate", true) : roleFlag;
8996
9046
  const report = await runMigrate({ link: nodeLinkPort(), now: deps.now }, resolveHome(deps), {
8997
9047
  homedir: deps.homedir,
8998
9048
  ...role !== void 0 ? { role } : {},
@@ -9267,7 +9317,7 @@ async function cmdUpdate(args, io, deps) {
9267
9317
  async function cmdRemove(args, io, deps) {
9268
9318
  const parsed = parseArgs(args, { valued: /* @__PURE__ */ new Set(["role"]), boolean: boolFlags() });
9269
9319
  if (parsed.positionals.length === 0) throw new NeoError("usage", "remove: at least one skill name required");
9270
- const role = lastFlag(parsed, "role") ?? "default";
9320
+ const role = await resolveRoleTarget(io, deps, lastFlag(parsed, "role"), "remove", false);
9271
9321
  const home = resolveHome(deps);
9272
9322
  const plan = await planRemove(home, { skills: parsed.positionals, role });
9273
9323
  for (const name of plan.missing) io.stderr(`remove ${name}: not found in role "${role}"