@phyzess/kitto 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Kitto
2
2
 
3
+ ## 0.2.1
4
+
5
+ - Select hosts with arrow keys and Space in the setup wizard, then choose a configuration source and preview or apply the plan. Scripted input remains supported.
6
+ - Use the pinned i-have-adhd skill in the default Codex and DSH configuration alongside the existing Pi extension.
7
+
3
8
  ## 0.2.0
4
9
 
5
10
  - Guide users through host selection, configuration sources, dependencies, preview and installation in one interactive setup.
package/README.md CHANGED
@@ -10,7 +10,7 @@ Kitto 把一套工作规则和 skills 带到 Pi、Codex 和 DeepSeek Harness(D
10
10
  npx --yes @phyzess/kitto@latest setup
11
11
  ```
12
12
 
13
- 向导会让你选择宿主和配置仓库。选「使用默认 Kitto 配置」即可部署仓库里的规则、skills 和各宿主的 Kitto 集成。选择 Pi 时还会同步 Pi 包、扩展和 MCP 设置。已有自己的配置仓库时,可以填 Git URL 或本地路径。向导会询问是否补装缺少的 CLI 和辅助依赖,也可以在同一次运行里先预览,再确认安装。已有 Kitto 源码的机器可直接运行 `./setup.sh`。
13
+ 用 ↑↓ 移动、空格勾选宿主、Enter 确认。随后从菜单选择配置来源,指定本地路径或 Git URL 时直接输入。选「使用默认 Kitto 配置」即可部署仓库里的规则、skills 和各宿主的 Kitto 集成。选择 Pi 时还会同步 Pi 包、扩展和 MCP 设置。已有自己的配置仓库时,可以填 Git URL 或本地路径。向导会询问是否补装缺少的 CLI 和辅助依赖,也可以在同一次运行里先预览,再确认安装。已有 Kitto 源码的机器可直接运行 `./setup.sh`。
14
14
 
15
15
  ## 以后才建工作区怎么办?
16
16
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "kitto",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "Maintain personal agent configuration on request"
6
6
  }
@@ -0,0 +1,68 @@
1
+ import { createInterface } from 'node:readline';
2
+
3
+ export async function setupPrompts(input, output) {
4
+ const print = message => output.write(message + '\n');
5
+ if (input.isTTY && output.isTTY && typeof input.setRawMode === 'function') {
6
+ const ui = await import('@clack/prompts');
7
+ const settings = { input, output };
8
+ const answer = async prompt => {
9
+ const result = await prompt;
10
+ return ui.isCancel(result) ? undefined : result;
11
+ };
12
+ return {
13
+ print,
14
+ close() {},
15
+ hosts: (options, defaults) => answer(ui.multiselect({
16
+ ...settings, message: '选择宿主(↑↓ 移动,空格勾选,Enter 确认)', options,
17
+ initialValues: defaults, required: true, showInstructions: false,
18
+ })),
19
+ select: (message, options, initialValue) => answer(ui.select({ ...settings, message, options, initialValue })),
20
+ yesNo: (message, initialValue) => answer(ui.confirm({ ...settings, message, initialValue, active: '是', inactive: '否' })),
21
+ text: (message, { initialValue, validate } = {}) => answer(ui.text({
22
+ ...settings, message, initialValue, validate: value => validate?.((value ?? '').trim()),
23
+ })).then(value => value?.trim()),
24
+ };
25
+ }
26
+
27
+ const rl = createInterface({ input, output, terminal: Boolean(input.isTTY && output.isTTY) });
28
+ const lines = rl[Symbol.asyncIterator]();
29
+ rl.on('SIGINT', () => rl.close());
30
+ async function read(message, parse) {
31
+ while (true) {
32
+ print(message);
33
+ const reply = await lines.next();
34
+ if (reply.done) return;
35
+ const value = parse(reply.value.trim());
36
+ if (value !== undefined) return value;
37
+ print('输入无效,请重试。');
38
+ }
39
+ }
40
+ return {
41
+ print,
42
+ close: () => rl.close(),
43
+ hosts(options, defaults) {
44
+ options.forEach(({ label, hint }, i) => print(` ${i + 1}. ${label}(${hint})`));
45
+ return read(`选择宿主 [${defaults.join(',')}],可输入多个名称或编号,0 取消。`, answer => {
46
+ if (answer === '0') return [];
47
+ if (!answer && defaults.length) return defaults;
48
+ const values = answer.toLowerCase().split(/[,,\s]+/).filter(Boolean)
49
+ .map(item => options.find((o, i) => o.value === item || String(i + 1) === item)?.value);
50
+ if (values.length && values.every(Boolean)) return [...new Set(values)];
51
+ });
52
+ },
53
+ select(message, options, initialValue) {
54
+ return read(message + ' ' + options.map(o => o.value + ' ' + o.label).join(',') + '。', value =>
55
+ options.find(o => o.value === (value || initialValue))?.value);
56
+ },
57
+ yesNo(message, initialValue) {
58
+ return read(message + (initialValue ? ' [Y/n]' : ' [y/N]'), value => {
59
+ if (!value) return initialValue;
60
+ if (/^(y|yes|是)$/i.test(value)) return true;
61
+ if (/^(n|no|否)$/i.test(value)) return false;
62
+ });
63
+ },
64
+ text(message, { initialValue = '', validate } = {}) {
65
+ return read(message, value => validate?.(value || initialValue) ? undefined : value || initialValue);
66
+ },
67
+ };
68
+ }
@@ -1,7 +1,7 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import { homedir } from 'node:os';
3
3
  import { resolve } from 'node:path';
4
- import { createInterface } from 'node:readline';
4
+ import { setupPrompts } from './setup-prompts.mjs';
5
5
  import { promisify } from 'node:util';
6
6
 
7
7
  const agents = ['pi', 'codex', 'dsh'];
@@ -37,55 +37,17 @@ function expandHome(path) {
37
37
  }
38
38
 
39
39
  async function configure({ input, output, environment, execute, probeServicePnpm }) {
40
- const terminal = Boolean(input.isTTY && output.isTTY);
41
- const rl = createInterface({ input, output, terminal });
42
- const lines = rl[Symbol.asyncIterator]();
43
- let interrupted = false;
44
- rl.on('SIGINT', () => {
45
- interrupted = true;
46
- rl.close();
47
- });
48
- const print = line => output.write(line + '\n');
49
-
50
- async function ask(prompt) {
51
- if (interrupted) return undefined;
52
- if (terminal) {
53
- rl.setPrompt(prompt + ' ');
54
- rl.prompt();
55
- } else {
56
- output.write(prompt + ' ');
57
- }
58
- const reply = await lines.next();
59
- return interrupted || reply.done ? undefined : reply.value.trim();
60
- }
61
-
62
- async function choose(prompt, parse) {
63
- while (true) {
64
- const answer = await ask(prompt);
65
- if (answer === undefined) return undefined;
66
- const choice = parse(answer);
67
- if (choice !== undefined) return choice;
68
- print('输入无效,请重试。');
69
- }
70
- }
71
-
72
- async function yesNo(prompt, defaultValue) {
73
- return choose(prompt + (defaultValue ? ' [Y/n]' : ' [y/N]'), answer => {
74
- if (!answer) return defaultValue;
75
- if (/^(y|yes|是)$/i.test(answer)) return true;
76
- if (/^(n|no|否)$/i.test(answer)) return false;
77
- });
78
- }
79
-
40
+ const { print, hosts, select, text, yesNo, close } = await setupPrompts(input, output);
80
41
  try {
81
42
  const { available, pnpmAvailable, serviceActive, canConfigureService } = environment;
82
43
  const serviceAvailable = serviceActive && canConfigureService;
83
44
  const defaults = agents.filter(agent => available.includes(agent) || (agent === 'dsh' && serviceAvailable));
84
45
  print('Kitto 环境安装向导');
85
46
  print('为选中的宿主配置当前账号的共享规则与 skills。按 Ctrl+C 可取消。');
86
- for (const [index, agent] of agents.entries()) {
87
- print(` ${index + 1}. ${names[agent]}(${available.includes(agent) ? '已安装 CLI' : '未检测到 CLI'})`);
88
- }
47
+ const hostOptions = agents.map(value => ({
48
+ value, label: names[value],
49
+ hint: value === 'dsh' && serviceAvailable ? serviceUnit : available.includes(value) ? '已安装 CLI' : '未检测到 CLI',
50
+ }));
89
51
  if (serviceActive) {
90
52
  print('检测到正在运行的系统服务 dsh.service。' +
91
53
  (canConfigureService ? '可以配置服务账号。' : '需要 root 权限才能配置服务账号。'));
@@ -95,16 +57,7 @@ async function configure({ input, output, environment, execute, probeServicePnpm
95
57
  let unit;
96
58
  let installAgents;
97
59
  while (true) {
98
- selected = await choose(
99
- `选择宿主,可用逗号分隔编号或名称${defaults.length ? ` [${defaults.join(',')}]` : ''},输入 0 取消。`,
100
- answer => {
101
- if (answer === '0') return [];
102
- if (!answer && defaults.length) return defaults;
103
- const items = answer.toLowerCase().split(/[,,\s]+/).filter(Boolean);
104
- const chosen = items.map(item => /^[1-3]$/.test(item) ? agents[Number(item) - 1] : item);
105
- if (chosen.length && chosen.every(item => agents.includes(item))) return [...new Set(chosen)];
106
- },
107
- );
60
+ selected = await hosts(hostOptions, defaults);
108
61
  if (!selected?.length) return undefined;
109
62
 
110
63
  unit = undefined;
@@ -124,19 +77,17 @@ async function configure({ input, output, environment, execute, probeServicePnpm
124
77
  break;
125
78
  }
126
79
 
127
- print('配置来源');
128
80
  print('完整配置包含仓库的 AGENTS.md、skills 和所选宿主的 Kitto 集成。选择 Pi 时还会同步 Pi 包、扩展和 MCP 设置。');
129
- print(' 1. 使用默认 Kitto 配置,优先复用已有安装');
130
- print(' 2. 指定配置仓库路径或 Git URL');
131
- print(' 3. 仅配置共享规则与 skills');
132
81
  let source;
133
82
  let serviceInstallAgents;
134
83
  let servicePnpmAvailable;
135
84
  while (true) {
136
- const sourceChoice = await choose('选择配置来源 [1],输入 0 取消。', answer => {
137
- if (!answer) return '1';
138
- if (['0', '1', '2', '3'].includes(answer)) return answer;
139
- });
85
+ const sourceChoice = await select('选择配置来源', [
86
+ { value: '1', label: '默认 Kitto 配置', hint: '优先复用已有安装' },
87
+ { value: '2', label: '指定配置仓库路径或 Git URL' },
88
+ { value: '3', label: '仅配置共享规则与 skills' },
89
+ { value: '0', label: '取消' },
90
+ ], '1');
140
91
  if (sourceChoice === undefined || sourceChoice === '0') return;
141
92
 
142
93
  const needsPnpm = sourceChoice !== '3' && selected.includes('dsh') && !unit && pnpmAvailable === false;
@@ -164,7 +115,7 @@ async function configure({ input, output, environment, execute, probeServicePnpm
164
115
  }
165
116
 
166
117
  if (sourceChoice === '2') {
167
- const path = await choose('输入配置仓库路径或 Git URL。', answer => answer || undefined);
118
+ const path = await text('配置仓库路径或 Git URL', { validate: value => value ? undefined : '请输入路径或 Git URL' });
168
119
  if (path === undefined) return;
169
120
  source = expandHome(path);
170
121
  } else if (sourceChoice === '3') {
@@ -175,14 +126,14 @@ async function configure({ input, output, environment, execute, probeServicePnpm
175
126
 
176
127
  const deps = source === false ? false : await yesNo('安装配置中声明的辅助工具和依赖?', false);
177
128
  if (deps === undefined) return undefined;
178
- const workspace = await ask('工作区父目录(可选)。例如未来项目会放在 ~/workspaces/workspace-1 下,就填 ~/workspaces。留空使用全局配置。');
129
+ const workspace = await text('工作区父目录(可选)。例如未来项目会放在 ~/workspaces/workspace-1 下,就填 ~/workspaces。留空使用全局配置。');
179
130
  if (workspace === undefined) return undefined;
180
131
 
181
132
  let dshProfile = 'web';
182
133
  if (selected.includes('dsh')) {
183
- dshProfile = await choose('DSH 配置档名称 [web]。', answer => {
184
- if (!answer) return 'web';
185
- if (/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(answer) && answer !== 'desktop') return answer;
134
+ dshProfile = await text('DSH 配置档名称', {
135
+ initialValue: 'web',
136
+ validate: value => /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(value) && value !== 'desktop' ? undefined : '请输入有效的 DSH 配置档名称',
186
137
  });
187
138
  if (dshProfile === undefined) return undefined;
188
139
  }
@@ -201,27 +152,25 @@ async function configure({ input, output, environment, execute, probeServicePnpm
201
152
  if (serviceInstallAgents) print(` 为 ${unit} 的账号补装 pnpm 是`);
202
153
  if (source !== false) print(` 安装配置声明的辅助依赖 ${deps ? '是' : '否'}`);
203
154
 
204
- let action = await choose('下一步 [1]。1 预览,2 安装,0 取消。', answer => {
205
- if (!answer) return '1';
206
- if (['0', '1', '2'].includes(answer)) return answer;
207
- });
155
+ let action = await select('下一步', [
156
+ { value: '1', label: '预览' }, { value: '2', label: '安装' }, { value: '0', label: '取消' },
157
+ ], '1');
208
158
  if (action === '1') {
209
159
  await execute({ ...plan, dryRun: true });
210
- action = await choose('预览完成 [0]。2 按此计划安装,0 退出。', answer => {
211
- if (!answer || answer === '0') return '0';
212
- if (answer === '2') return answer;
213
- });
160
+ action = await select('预览完成', [
161
+ { value: '0', label: '退出' }, { value: '2', label: '按此计划安装' },
162
+ ], '0');
214
163
  if (action !== '2') {
215
164
  print('已退出,未执行安装。');
216
165
  return true;
217
166
  }
218
167
  }
219
168
  if (action !== '2') return;
220
- rl.close();
169
+ close();
221
170
  await execute({ ...plan, dryRun: false });
222
171
  return true;
223
172
  } finally {
224
- rl.close();
173
+ close();
225
174
  }
226
175
  }
227
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phyzess/kitto",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Portable personal configuration for Pi, Codex and DeepSeek Harness",
5
5
  "type": "module",
6
6
  "bin": { "kitto": "bin/kitto.mjs" },
@@ -8,6 +8,7 @@
8
8
  "publishConfig": { "access": "public" },
9
9
  "repository": { "type": "git", "url": "git+https://github.com/phyzess/kitto.git" },
10
10
  "files": ["bin/*.mjs", "lib/*.mjs", "lib/*.py", "integration/", "sync.sh", "CHANGELOG.md"],
11
+ "dependencies": { "@clack/prompts": "1.9.0" },
11
12
  "scripts": {
12
13
  "test": "node --test tests/kitto.test.mjs tests/scope*.test.mjs tests/setup-wizard.test.mjs",
13
14
  "prepublishOnly": "npm test && python3 -m unittest discover -s tests -v",