@nathan33/nao-skill 0.2.0 → 0.3.0

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.
Files changed (2) hide show
  1. package/bin/nao-skill.js +82 -0
  2. package/package.json +1 -1
package/bin/nao-skill.js CHANGED
@@ -17,6 +17,7 @@
17
17
  * bash .agents/scripts/nao-fleet.sh check / ensure arch rd-fe ...
18
18
  * 角色卡经 fleet 拉起时 --append-system-prompt 注入;checklists 按需读取
19
19
  */
20
+ import { execFileSync } from 'node:child_process';
20
21
  import {
21
22
  cpSync,
22
23
  existsSync,
@@ -64,6 +65,67 @@ function copyDir(src, dst, force) {
64
65
  return { copied, skipped, overwritten };
65
66
  }
66
67
 
68
+ // 已知 pi 插件(nao 舰队生态),name → npm 包
69
+ const PI_PLUGINS = {
70
+ intercom: { pkg: 'pi-intercom', desc: '多会话协作(舰队机制核心依赖)' },
71
+ 'ask-me': { pkg: 'pi-ask-me', desc: '提问/访谈工具' },
72
+ subagents: { pkg: 'pi-subagents', desc: '子代理委派' },
73
+ 'web-access': { pkg: 'pi-web-access', desc: '网页访问' },
74
+ codegraph: { pkg: '@sean_pedersen/pi-codegraph', desc: 'CodeGraph 代码定位(pi 集成)' },
75
+ };
76
+
77
+ function piSettingsPath() {
78
+ return join(process.env.HOME || process.env.USERPROFILE || '', '.pi', 'agent', 'settings.json');
79
+ }
80
+
81
+ function readPackages() {
82
+ try {
83
+ const d = JSON.parse(readFileSync(piSettingsPath(), 'utf8'));
84
+ return Array.isArray(d.packages) ? d.packages : [];
85
+ } catch {
86
+ return [];
87
+ }
88
+ }
89
+
90
+ function installedPlugins() {
91
+ const pkgs = readPackages();
92
+ const out = {};
93
+ for (const [name, { pkg }] of Object.entries(PI_PLUGINS)) {
94
+ out[name] = pkgs.includes(`npm:${pkg}`) || pkgs.includes(pkg);
95
+ }
96
+ return out;
97
+ }
98
+
99
+ function pluginsList() {
100
+ const installed = installedPlugins();
101
+ log(`pi 插件状态(settings: ${piSettingsPath()})`);
102
+ for (const [name, { pkg, desc }] of Object.entries(PI_PLUGINS)) {
103
+ console.log(` ${installed[name] ? '✓' : '·'} ${name.padEnd(11)} ${pkg.padEnd(26)} ${desc}${installed[name] ? '' : '(缺失)'}`);
104
+ }
105
+ console.log('\n安装: nao-skill plugins install <name...> | plugins install-all');
106
+ }
107
+
108
+ function pluginsInstall(names, all = false) {
109
+ const targets = all ? Object.keys(PI_PLUGINS) : names;
110
+ const todo = [];
111
+ for (const n of targets) {
112
+ const p = PI_PLUGINS[n];
113
+ if (!p) { warn(`未知插件: ${n}(可用: ${Object.keys(PI_PLUGINS).join(', ')})`); continue; }
114
+ if (installedPlugins()[n]) { log(`已安装: ${n}`); continue; }
115
+ todo.push([n, p]);
116
+ }
117
+ if (!todo.length) { log('全部插件已就绪。'); return; }
118
+ for (const [n, p] of todo) {
119
+ log(`安装 ${n} → pi install npm:${p.pkg} ...`);
120
+ try {
121
+ execFileSync('pi', ['install', `npm:${p.pkg}`], { stdio: 'inherit' });
122
+ log(`✓ ${n} 安装完成(重启 pi 会话后生效)`);
123
+ } catch (e) {
124
+ warn(`✗ ${n} 安装失败: ${e.message}(确认 pi 已安装且在 PATH)`);
125
+ }
126
+ }
127
+ }
128
+
67
129
  function install(target, force) {
68
130
  if (!existsSync(SRC)) {
69
131
  warn(`包内 .agents 缺失:${SRC}(发布物损坏?)`);
@@ -154,7 +216,11 @@ function help() {
154
216
 
155
217
  用法:
156
218
  nao-skill install [dir] [--force] 安装/合并 .agents/ 到目标项目(默认当前目录)
219
+ nao-skill install --plugins 项目接入时顺带安装 pi 舰队插件
157
220
  nao-skill update [dir] 升级已有安装:源优先覆盖 + 清理废弃路径 + 保留项目自定义
221
+ nao-skill plugins list 列出已知 pi 插件与安装状态
222
+ nao-skill plugins install <名...> 安装指定插件(intercom/ask-me/subagents/web-access/codegraph)
223
+ nao-skill plugins install-all 安装全部舰队插件
158
224
  nao-skill --version 显示版本
159
225
  nao-skill --help 显示本帮助
160
226
 
@@ -179,9 +245,11 @@ if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
179
245
  } else if (cmd === 'install' || cmd === 'i') {
180
246
  let target = process.cwd();
181
247
  let force = false;
248
+ let withPlugins = false;
182
249
  const rest = args.slice(1);
183
250
  for (let i = 0; i < rest.length; i++) {
184
251
  if (rest[i] === '--force' || rest[i] === '-f') force = true;
252
+ else if (rest[i] === '--plugins') withPlugins = true;
185
253
  else if (rest[i] === '--target') target = resolve(rest[++i]);
186
254
  else if (!rest[i].startsWith('-')) target = resolve(rest[i]);
187
255
  else { warn(`未知参数: ${rest[i]}`); process.exit(2); }
@@ -191,6 +259,20 @@ if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
191
259
  process.exit(2);
192
260
  }
193
261
  install(target, force);
262
+ if (withPlugins) pluginsInstall([], true);
263
+ } else if (cmd === 'plugins' || cmd === 'plugin') {
264
+ const sub = args[1];
265
+ const rest = args.slice(2);
266
+ if (sub === 'list' || sub === 'ls' || !sub) {
267
+ pluginsList();
268
+ } else if (sub === 'install' || sub === 'add') {
269
+ pluginsInstall(rest);
270
+ } else if (sub === 'install-all' || sub === 'installAll') {
271
+ pluginsInstall([], true);
272
+ } else {
273
+ warn(`未知插件命令: ${sub}(可用: list / install / install-all)`);
274
+ process.exit(2);
275
+ }
194
276
  } else if (cmd === 'update' || cmd === 'u') {
195
277
  let target = process.cwd();
196
278
  const rest = args.slice(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathan33/nao-skill",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "nao 多角色 AI 开发舰队:角色卡 / 技能 / 协作协议 / 工具链,一键接入项目(pi / Claude / 任意 Agent)",
5
5
  "type": "module",
6
6
  "bin": {