@difflab/pi 0.1.0-rc.202609140747.4d45e72.2 → 0.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,OAAO,GACR,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -8,8 +8,8 @@ var mcp = {
8
8
  },
9
9
  async serversEnsure(servers, options = {}) {
10
10
  const path = options.path ?? mcp.globalConfigPath();
11
- const currentText = await readOptional(path);
12
- const current = parseConfig(currentText, path);
11
+ const currentText = await getOptionalFile(path);
12
+ const current = getParsedConfig(currentText, path);
13
13
  const nextServers = { ...current.mcpServers };
14
14
  for (const [name, entry] of Object.entries(servers)) {
15
15
  nextServers[name] = mergeEntry(nextServers[name], entry);
@@ -30,7 +30,7 @@ function mergeEntry(current, required) {
30
30
  merged.env = { ...current?.env, ...required.env };
31
31
  return merged;
32
32
  }
33
- function parseConfig(content, path) {
33
+ function getParsedConfig(content, path) {
34
34
  if (!content?.trim())
35
35
  return { mcpServers: {} };
36
36
  try {
@@ -45,7 +45,7 @@ function parseConfig(content, path) {
45
45
  throw new Error(`Expected a valid pi-mcp-adapter configuration in ${path}.`);
46
46
  }
47
47
  }
48
- async function readOptional(path) {
48
+ async function getOptionalFile(path) {
49
49
  try {
50
50
  return await readFile(path, "utf8");
51
51
  } catch (error) {
@@ -67,6 +67,7 @@ import { constants } from "node:fs";
67
67
  import { access } from "node:fs/promises";
68
68
  import { delimiter, join as join2 } from "node:path";
69
69
  import { spawn } from "node:child_process";
70
+ var MAX_CAPTURED_OUTPUT_LENGTH = 65536;
70
71
  async function findExecutable(name) {
71
72
  if (name.includes("/")) {
72
73
  try {
@@ -115,10 +116,12 @@ async function runChecked(command, args, options = {}) {
115
116
  }
116
117
  function appendBounded(current, next) {
117
118
  const combined = current + next;
118
- return combined.length <= 65536 ? combined : combined.slice(-65536);
119
+ return combined.length <= MAX_CAPTURED_OUTPUT_LENGTH ? combined : combined.slice(-MAX_CAPTURED_OUTPUT_LENGTH);
119
120
  }
120
121
 
121
122
  // src/mise.ts
123
+ var MISE_HOOK_START = "# >>> @difflab/pi mise >>>";
124
+ var MISE_HOOK_END = "# <<< @difflab/pi mise <<<";
122
125
  var mise = {
123
126
  async executableCheck(name = "mise") {
124
127
  return findExecutable(name);
@@ -139,8 +142,8 @@ var mise = {
139
142
  },
140
143
  async hookEnsure(executable, options = {}) {
141
144
  const homeDir = options.homeDir ?? homedir2();
142
- const hook = shellHook(basename(options.shell ?? process.env.SHELL ?? ""), executable, homeDir);
143
- const current = await readOptional2(hook.path);
145
+ const hook = getShellHook(basename(options.shell ?? process.env.SHELL ?? ""), executable, homeDir);
146
+ const current = await getOptionalFile2(hook.path);
144
147
  if (current.includes(MISE_HOOK_START))
145
148
  return { path: hook.path, changed: false, planned: false };
146
149
  if (options.dryRun)
@@ -152,16 +155,16 @@ var mise = {
152
155
  await writeFile2(hook.path, `${current}${separator}${hook.content}`, "utf8");
153
156
  return { path: hook.path, changed: true, planned: false };
154
157
  },
155
- async toolCheckGlobal(executable, tool, minimumMajor = 0) {
158
+ async toolCheckGlobal(executable, tool, minimumVersion) {
156
159
  const result = await run(executable, ["ls", "--global", "--installed", tool, "--json"]);
157
- return result.code === 0 && hasInstalledTool(result.stdout, minimumMajor);
160
+ return result.code === 0 && isToolInstalled(result.stdout, minimumVersion);
158
161
  },
159
162
  async toolInstallGlobal(executable, specification) {
160
163
  await runChecked(executable, ["use", "--global", specification]);
161
164
  },
162
165
  async toolCheckLocal(executable, tool, cwd = process.cwd()) {
163
166
  const result = await run(executable, ["ls", "--local", "--installed", tool, "--json"], { cwd });
164
- return result.code === 0 && hasInstalledTool(result.stdout);
167
+ return result.code === 0 && isToolInstalled(result.stdout);
165
168
  },
166
169
  async toolInstallLocal(executable, specification, cwd = process.cwd()) {
167
170
  await runChecked(executable, ["use", "--path", cwd, specification], { cwd });
@@ -170,40 +173,76 @@ var mise = {
170
173
  await runChecked(executable, ["upgrade"], { cwd: homeDir });
171
174
  }
172
175
  };
173
- var MISE_HOOK_START = "# >>> @difflab/pi mise >>>";
174
- var MISE_HOOK_END = "# <<< @difflab/pi mise <<<";
175
- function shellHook(shell, executable, homeDir) {
176
- const command = shellQuote(executable);
177
- if (shell === "bash") {
178
- return {
179
- path: join3(homeDir, ".bashrc"),
180
- content: `${MISE_HOOK_START}
181
- eval "$(${command} activate bash)"
182
- ${MISE_HOOK_END}
183
- `
184
- };
185
- }
186
- if (shell === "zsh") {
187
- return {
188
- path: join3(homeDir, ".zshrc"),
189
- content: `${MISE_HOOK_START}
176
+ function getShellHook(shell, executable, homeDir) {
177
+ const command = getShellQuoted(executable);
178
+ switch (shell.toLowerCase()) {
179
+ case "zsh":
180
+ return {
181
+ path: join3(homeDir, ".zshrc"),
182
+ content: `${MISE_HOOK_START}
190
183
  eval "$(${command} activate zsh)"
191
184
  ${MISE_HOOK_END}
192
185
  `
193
- };
194
- }
195
- if (shell === "fish") {
196
- return {
197
- path: join3(homeDir, ".config", "fish", "config.fish"),
198
- content: `${MISE_HOOK_START}
186
+ };
187
+ case "fish":
188
+ return {
189
+ path: join3(homeDir, ".config", "fish", "config.fish"),
190
+ content: `${MISE_HOOK_START}
199
191
  ${command} activate fish | source
200
192
  ${MISE_HOOK_END}
201
193
  `
202
- };
194
+ };
195
+ case "nu":
196
+ case "nushell":
197
+ return {
198
+ path: join3(homeDir, ".config", "nushell", "config.nu"),
199
+ content: `${MISE_HOOK_START}
200
+ let mise_bin = ${command}
201
+ let mise_path = $nu.default-config-dir | path join mise.nu
202
+ ^$mise_bin activate nu | save $mise_path --force
203
+ use ($nu.default-config-dir | path join mise.nu)
204
+ ${MISE_HOOK_END}
205
+ `
206
+ };
207
+ case "xonsh":
208
+ return {
209
+ path: join3(homeDir, ".xonshrc"),
210
+ content: `${MISE_HOOK_START}
211
+ execx($(${command} activate xonsh))
212
+ ${MISE_HOOK_END}
213
+ `
214
+ };
215
+ case "elvish":
216
+ return {
217
+ path: join3(homeDir, ".config", "elvish", "rc.elv"),
218
+ content: `${MISE_HOOK_START}
219
+ var mise: = (ns [&])
220
+ eval (${command} activate elvish | slurp) &ns=$mise: &on-end={|ns| set mise: = $ns }
221
+ mise:activate
222
+ ${MISE_HOOK_END}
223
+ `
224
+ };
225
+ case "pwsh":
226
+ case "powershell":
227
+ return {
228
+ path: join3(homeDir, ".config", "powershell", "Microsoft.PowerShell_profile.ps1"),
229
+ content: `${MISE_HOOK_START}
230
+ (& ${command} activate pwsh) | Out-String | Invoke-Expression
231
+ ${MISE_HOOK_END}
232
+ `
233
+ };
234
+ case "bash":
235
+ default:
236
+ return {
237
+ path: join3(homeDir, ".bashrc"),
238
+ content: `${MISE_HOOK_START}
239
+ eval "$(${command} activate bash)"
240
+ ${MISE_HOOK_END}
241
+ `
242
+ };
203
243
  }
204
- throw new Error(`Unsupported shell "${shell || "unknown"}". Supported shells: bash, zsh, fish.`);
205
244
  }
206
- function hasInstalledTool(output, minimumMajor = 0) {
245
+ function isToolInstalled(output, minimumVersion) {
207
246
  try {
208
247
  const value = JSON.parse(output);
209
248
  if (!Array.isArray(value))
@@ -211,17 +250,28 @@ function hasInstalledTool(output, minimumMajor = 0) {
211
250
  return value.some((entry) => {
212
251
  if (!entry || typeof entry !== "object" || !("installed" in entry) || entry.installed !== true)
213
252
  return false;
214
- if (minimumMajor === 0)
253
+ if (!minimumVersion)
215
254
  return true;
216
255
  if (!("version" in entry) || typeof entry.version !== "string")
217
256
  return false;
218
- return Number.parseInt(entry.version, 10) >= minimumMajor;
257
+ return isVersionAtLeast(entry.version, minimumVersion);
219
258
  });
220
259
  } catch {
221
260
  return false;
222
261
  }
223
262
  }
224
- async function readOptional2(path) {
263
+ function isVersionAtLeast(version, minimumVersion) {
264
+ const current = version.match(/^v?(\d+)\.(\d+)\.(\d+)/)?.slice(1).map(Number);
265
+ const minimum = minimumVersion.match(/^v?(\d+)\.(\d+)\.(\d+)/)?.slice(1).map(Number);
266
+ if (!current || !minimum)
267
+ return false;
268
+ for (let index = 0;index < minimum.length; index += 1) {
269
+ if (current[index] !== minimum[index])
270
+ return current[index] > minimum[index];
271
+ }
272
+ return true;
273
+ }
274
+ async function getOptionalFile2(path) {
225
275
  try {
226
276
  return await readFile2(path, "utf8");
227
277
  } catch (error) {
@@ -230,7 +280,7 @@ async function readOptional2(path) {
230
280
  throw error;
231
281
  }
232
282
  }
233
- function shellQuote(value) {
283
+ function getShellQuoted(value) {
234
284
  return `'${value.replaceAll("'", "'\\''")}'`;
235
285
  }
236
286
  // src/pi.ts
@@ -253,12 +303,12 @@ var pi = {
253
303
  await runChecked(executable, ["install", source]);
254
304
  },
255
305
  agentDir(homeDir = homedir3()) {
256
- return resolveAgentDir(homeDir);
306
+ return getAgentDir(homeDir);
257
307
  },
258
- async skillCheckGlobal(name, agentDir = resolveAgentDir(), sharedSkillsDir = join4(homedir3(), ".agents", "skills")) {
308
+ async skillCheckGlobal(name, agentDir = getAgentDir(), sharedSkillsDir = join4(homedir3(), ".agents", "skills")) {
259
309
  const roots = [join4(agentDir, "skills"), sharedSkillsDir];
260
310
  for (const root of roots) {
261
- if (await readOptional3(join4(root, name, "SKILL.md")) !== undefined)
311
+ if (await getOptionalFile3(join4(root, name, "SKILL.md")) !== undefined)
262
312
  return true;
263
313
  }
264
314
  return false;
@@ -282,8 +332,8 @@ var pi = {
282
332
  ]);
283
333
  },
284
334
  async configEnsure(path, update, dryRun = false) {
285
- const currentText = await readOptional3(path);
286
- const current = parseObject(currentText, path);
335
+ const currentText = await getOptionalFile3(path);
336
+ const current = getParsedObject(currentText, path);
287
337
  const next = update(current);
288
338
  const changed = JSON.stringify(current) !== JSON.stringify(next);
289
339
  if (changed && !dryRun) {
@@ -294,10 +344,10 @@ var pi = {
294
344
  return { path, changed, existed: currentText !== undefined, planned: changed && dryRun };
295
345
  }
296
346
  };
297
- function resolveAgentDir(homeDir = homedir3()) {
347
+ function getAgentDir(homeDir = homedir3()) {
298
348
  return process.env.PI_CODING_AGENT_DIR ?? (process.env.XDG_CONFIG_HOME ? join4(process.env.XDG_CONFIG_HOME, "pi") : join4(homeDir, ".pi", "agent"));
299
349
  }
300
- async function readOptional3(path) {
350
+ async function getOptionalFile3(path) {
301
351
  try {
302
352
  return await readFile3(path, "utf8");
303
353
  } catch (error) {
@@ -306,7 +356,7 @@ async function readOptional3(path) {
306
356
  throw error;
307
357
  }
308
358
  }
309
- function parseObject(content, path) {
359
+ function getParsedObject(content, path) {
310
360
  if (!content?.trim())
311
361
  return {};
312
362
  try {
@@ -319,44 +369,77 @@ function parseObject(content, path) {
319
369
  // src/setup.ts
320
370
  import { homedir as homedir4 } from "node:os";
321
371
  import { join as join5 } from "node:path";
372
+ var MISE_DEPENDENCIES = [
373
+ { name: "node", tool: "node", spec: "node@22", minimumVersion: "22.19.0" },
374
+ { name: "zellij", tool: "zellij", spec: "zellij@latest", minimumVersion: undefined },
375
+ { name: "helix", tool: "helix", spec: "helix@latest", minimumVersion: undefined },
376
+ {
377
+ name: "tuicr",
378
+ tool: "github:agavra/tuicr",
379
+ spec: "github:agavra/tuicr@latest",
380
+ minimumVersion: undefined
381
+ },
382
+ {
383
+ name: "context-mode",
384
+ tool: "npm:context-mode",
385
+ spec: "npm:context-mode@latest",
386
+ minimumVersion: undefined
387
+ }
388
+ ];
389
+ var PI_PACKAGES = [
390
+ "npm:@tintinweb/pi-subagents",
391
+ "npm:pi-schedule-prompt",
392
+ "npm:@narumitw/pi-btw",
393
+ "npm:pi-web-access",
394
+ "npm:@gitawego/pi-lsp",
395
+ "npm:context-mode"
396
+ ];
397
+ var PI_SKILL_SOURCES = [
398
+ { repository: "arabold/docs-mcp-server", skills: ["docs-manage", "docs-search", "fetch-url"] },
399
+ { repository: "AminBlg/SimpleEnglish", skills: ["simple-english"] }
400
+ ];
401
+ var MCP_ADAPTER_PACKAGE = "npm:pi-mcp-adapter";
322
402
  async function ensureMise(options = {}) {
323
403
  const homeDir = options.homeDir ?? homedir4();
324
404
  const current = await mise.executableCheck() ?? await mise.executableCheck(join5(homeDir, ".local", "bin", "mise"));
325
405
  if (current)
326
- return { executable: current, action: action("mise", "ready", current) };
327
- progress(options, "Installing mise");
406
+ return { executable: current, action: createSetupAction("mise", "ready", current) };
407
+ reportProgress(options, "Installing mise");
328
408
  const executable = await mise.install({
329
409
  dryRun: options.dryRun,
330
410
  homeDir: options.homeDir,
331
411
  platform: options.platform
332
412
  });
333
- return { executable, action: action("mise", options.dryRun ? "planned" : "installed", executable) };
413
+ return {
414
+ executable,
415
+ action: createSetupAction("mise", options.dryRun ? "planned" : "installed", executable)
416
+ };
334
417
  }
335
418
  async function ensureMiseHooks(miseExecutable, options = {}) {
336
419
  if (options.installMiseHook === false)
337
- return action("mise shell hook", "skipped", "disabled");
420
+ return createSetupAction("mise shell hook", "skipped", "disabled");
338
421
  const result = await mise.hookEnsure(miseExecutable, {
339
422
  dryRun: options.dryRun,
340
423
  homeDir: options.homeDir,
341
424
  shell: options.shell
342
425
  });
343
426
  if (!result.changed)
344
- return action("mise shell hook", "ready", result.path);
345
- return action("mise shell hook", result.planned ? "planned" : "installed", result.path);
427
+ return createSetupAction("mise shell hook", "ready", result.path);
428
+ return createSetupAction("mise shell hook", result.planned ? "planned" : "installed", result.path);
346
429
  }
347
430
  async function ensureMiseDeps(miseExecutable, options = {}) {
348
431
  const canRunMise = Boolean(await mise.executableCheck(miseExecutable));
349
432
  const actions = [];
350
433
  for (const dependency of MISE_DEPENDENCIES) {
351
- const installed = canRunMise && await mise.toolCheckGlobal(miseExecutable, dependency.tool, dependency.minimumMajor);
434
+ const installed = canRunMise && await mise.toolCheckGlobal(miseExecutable, dependency.tool, dependency.minimumVersion);
352
435
  if (installed) {
353
- actions.push(action(dependency.name, "ready", dependency.spec));
436
+ actions.push(createSetupAction(dependency.name, "ready", dependency.spec));
354
437
  continue;
355
438
  }
356
- progress(options, `Installing ${dependency.name} with mise`);
439
+ reportProgress(options, `Installing ${dependency.name} with mise`);
357
440
  if (!options.dryRun)
358
441
  await mise.toolInstallGlobal(miseExecutable, dependency.spec);
359
- actions.push(action(dependency.name, options.dryRun ? "planned" : "installed", dependency.spec));
442
+ actions.push(createSetupAction(dependency.name, options.dryRun ? "planned" : "installed", dependency.spec));
360
443
  }
361
444
  return actions;
362
445
  }
@@ -364,12 +447,12 @@ async function ensurePiPlugins(options = {}) {
364
447
  const actions = await ensurePiPackages(PI_PACKAGES, options);
365
448
  const agentDir = options.agentDir ?? pi.agentDir(options.homeDir);
366
449
  const webSearch = await pi.configEnsure(join5(agentDir, "web-search.json"), (config) => ({ ...config, workflow: "auto-summary" }), options.dryRun);
367
- actions.push(configAction("web search settings", webSearch));
450
+ actions.push(getConfigSetupAction("web search settings", webSearch));
368
451
  const lsp = await pi.configEnsure(join5(agentDir, "pi-lsp.json"), (config) => ({
369
452
  ...config,
370
- progressive: { ...record(config.progressive), enabled: true, inject: "none" }
453
+ progressive: { ...getRecord(config.progressive), enabled: true, inject: "none" }
371
454
  }), options.dryRun);
372
- actions.push(configAction("pi-lsp settings", lsp));
455
+ actions.push(getConfigSetupAction("pi-lsp settings", lsp));
373
456
  return actions;
374
457
  }
375
458
  async function ensurePiSkills(miseExecutable, options = {}) {
@@ -380,17 +463,17 @@ async function ensurePiSkills(miseExecutable, options = {}) {
380
463
  const missing = [];
381
464
  for (const name of source.skills) {
382
465
  if (await pi.skillCheckGlobal(name, agentDir, sharedSkillsDir))
383
- actions.push(action(`pi skill ${name}`, "ready", source.repository));
466
+ actions.push(createSetupAction(`pi skill ${name}`, "ready", source.repository));
384
467
  else
385
468
  missing.push(name);
386
469
  }
387
470
  if (missing.length === 0)
388
471
  continue;
389
- progress(options, `Installing skills from ${source.repository}`);
472
+ reportProgress(options, `Installing skills from ${source.repository}`);
390
473
  if (!options.dryRun)
391
474
  await pi.skillInstallGlobal(miseExecutable, source.repository, missing);
392
475
  for (const name of missing) {
393
- actions.push(action(`pi skill ${name}`, options.dryRun ? "planned" : "installed", source.repository));
476
+ actions.push(createSetupAction(`pi skill ${name}`, options.dryRun ? "planned" : "installed", source.repository));
394
477
  }
395
478
  }
396
479
  return actions;
@@ -422,7 +505,7 @@ async function ensureMcpAdapters(miseExecutable, options = {}) {
422
505
  dryRun: options.dryRun,
423
506
  path: mcp.globalConfigPath(options.homeDir)
424
507
  });
425
- actions.push(configAction("MCP configuration", result));
508
+ actions.push(getConfigSetupAction("MCP configuration", result));
426
509
  return actions;
427
510
  }
428
511
  async function setupPi(options = {}) {
@@ -438,27 +521,6 @@ async function setupPi(options = {}) {
438
521
  restartPi: actions.some((item) => (item.status === "installed" || item.status === "updated") && (item.name.startsWith("pi package ") || item.name.startsWith("pi skill ") || item.name === "MCP configuration" || item.name === "web search settings" || item.name === "pi-lsp settings"))
439
522
  };
440
523
  }
441
- var MISE_DEPENDENCIES = [
442
- { name: "node", tool: "node", spec: "node@22", minimumMajor: 22 },
443
- { name: "zellij", tool: "zellij", spec: "zellij@latest", minimumMajor: 0 },
444
- { name: "helix", tool: "helix", spec: "helix@latest", minimumMajor: 0 },
445
- { name: "tuicr", tool: "github:agavra/tuicr", spec: "github:agavra/tuicr@latest", minimumMajor: 0 },
446
- { name: "context-mode", tool: "npm:context-mode", spec: "npm:context-mode@latest", minimumMajor: 0 }
447
- ];
448
- var PI_PACKAGES = [
449
- "npm:@tintinweb/pi-subagents",
450
- "npm:pi-schedule-prompt",
451
- "npm:@narumitw/pi-btw",
452
- "npm:pi-web-access",
453
- "npm:@gitawego/pi-lsp",
454
- "npm:@juicesharp/rpiv-ask-user-question",
455
- "npm:context-mode"
456
- ];
457
- var PI_SKILL_SOURCES = [
458
- { repository: "arabold/docs-mcp-server", skills: ["docs-manage", "docs-search", "fetch-url"] },
459
- { repository: "AminBlg/SimpleEnglish", skills: ["simple-english"] }
460
- ];
461
- var MCP_ADAPTER_PACKAGE = "npm:pi-mcp-adapter";
462
524
  async function ensurePiPackages(packages, options) {
463
525
  const executable = await pi.executableCheck();
464
526
  if (!executable && !options.dryRun)
@@ -467,33 +529,33 @@ async function ensurePiPackages(packages, options) {
467
529
  const actions = [];
468
530
  for (const source of packages) {
469
531
  if (pi.packageCheck(installed, source)) {
470
- actions.push(action(`pi package ${source}`, "ready", source));
532
+ actions.push(createSetupAction(`pi package ${source}`, "ready", source));
471
533
  continue;
472
534
  }
473
- progress(options, `Installing pi package ${source}`);
535
+ reportProgress(options, `Installing pi package ${source}`);
474
536
  if (!options.dryRun) {
475
537
  await pi.packageInstall(executable, source);
476
538
  installed += `
477
539
  ${source}`;
478
540
  }
479
- actions.push(action(`pi package ${source}`, options.dryRun ? "planned" : "installed", source));
541
+ actions.push(createSetupAction(`pi package ${source}`, options.dryRun ? "planned" : "installed", source));
480
542
  }
481
543
  return actions;
482
544
  }
483
- function configAction(name, result) {
545
+ function getConfigSetupAction(name, result) {
484
546
  if (!result.changed)
485
- return action(name, "ready", result.path);
547
+ return createSetupAction(name, "ready", result.path);
486
548
  if (result.planned)
487
- return action(name, "planned", result.path);
488
- return action(name, result.existed ? "updated" : "installed", result.path);
549
+ return createSetupAction(name, "planned", result.path);
550
+ return createSetupAction(name, result.existed ? "updated" : "installed", result.path);
489
551
  }
490
- function action(name, status, detail) {
552
+ function createSetupAction(name, status, detail) {
491
553
  return { name, status, detail };
492
554
  }
493
- function progress(options, message) {
555
+ function reportProgress(options, message) {
494
556
  options.onProgress?.(message);
495
557
  }
496
- function record(value) {
558
+ function getRecord(value) {
497
559
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
498
560
  }
499
561
  export {
package/dist/mcp.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,GAAG;wCACyB,MAAM;2BAKlC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,YACrC,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC;CAmB5B,CAAC"}
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,eAAO,MAAM,GAAG;wCACyB,MAAM;2BAKlC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,YACrC,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC;CAmB5B,CAAC"}
package/dist/mise.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare const mise: {
17
17
  executableCheck(name?: string): Promise<string | undefined>;
18
18
  install(options?: MiseInstallOptions): Promise<string>;
19
19
  hookEnsure(executable: string, options?: MiseHookOptions): Promise<MiseHookResult>;
20
- toolCheckGlobal(executable: string, tool: string, minimumMajor?: number): Promise<boolean>;
20
+ toolCheckGlobal(executable: string, tool: string, minimumVersion?: string): Promise<boolean>;
21
21
  toolInstallGlobal(executable: string, specification: string): Promise<void>;
22
22
  toolCheckLocal(executable: string, tool: string, cwd?: string): Promise<boolean>;
23
23
  toolInstallLocal(executable: string, specification: string, cwd?: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"mise.d.ts","sourceRoot":"","sources":["../src/mise.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,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CAAC;2BAcnC,MAAM,YAAW,eAAe,GAAQ,OAAO,CAAC,cAAc,CAAC;gCAc1D,MAAM,QAAQ,MAAM,mBAAmB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;kCAK9D,MAAM,iBAAiB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;+BAIhD,MAAM,QAAQ,MAAM,iBAAwB,OAAO,CAAC,OAAO,CAAC;iCAK1D,MAAM,iBAAiB,MAAM,iBAAwB,OAAO,CAAC,IAAI,CAAC;oCAI/D,MAAM,qBAAwB,OAAO,CAAC,IAAI,CAAC;CAGlF,CAAC"}
package/dist/pi.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../src/pi.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,EAAE;uBACY,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;4BAItB,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;6BAI7B,MAAM,UAAU,MAAM,GAAG,OAAO;+BAKxB,MAAM,UAAU,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;gCAIxC,MAAM;2BAK7B,MAAM,gDAGX,OAAO,CAAC,OAAO,CAAC;uCAWsB,MAAM,UAAU,MAAM,SAAS,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;uBAoBjG,MAAM,UACJ,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,qBAEzC,OAAO,CAAC,cAAc,CAAC;CAa3B,CAAC"}
1
+ {"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../src/pi.ts"],"names":[],"mappings":"AAOA,KAAK,U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E,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAMxB"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAID,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB9E;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBzG;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAMxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B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AAsB,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsB/G;AAED,wBAAsB,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CA+BlH;AAID,wBAAsB,OAAO,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAsB9E"}
@@ -1,9 +1,5 @@
1
+ import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
+ export { createDiffpiReloadTool } from './reload';
1
3
  export { diffpiSetupTool, diffpiValidateTool } from './setup';
2
- export declare const piTools: readonly [import("@earendil-works/pi-coding-agent").ToolDefinition<import("typebox").TObject<{
3
- issueTracker: import("typebox").TOptional<import("typebox").TString>;
4
- installMiseHook: import("typebox").TOptional<import("typebox").TBoolean>;
5
- }>, import("./setup").ToolDetails, any>, import("@earendil-works/pi-coding-agent").ToolDefinition<import("typebox").TObject<{
6
- issueTracker: import("typebox").TOptional<import("typebox").TString>;
7
- installMiseHook: import("typebox").TOptional<import("typebox").TBoolean>;
8
- }>, import("./setup").ToolDetails, any>];
4
+ export declare function createPiTools(pi: Pick<ExtensionAPI, 'sendUserMessage'>): readonly [import("@earendil-works/pi-coding-agent").ToolDefinition<import("typebox").TSchema, unknown, any>, import("@earendil-works/pi-coding-agent").ToolDefinition<import("typebox").TSchema, unknown, any>, import("@earendil-works/pi-coding-agent").ToolDefinition<import("typebox").TSchema, unknown, any>];
9
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,OAAO;;;;;;wCAAiD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAMpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAI9D,wBAAgB,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC,sTAEtE"}