@difflab/pi 0.1.0-rc.202609140747.4d45e72.2

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/dist/index.js ADDED
@@ -0,0 +1,510 @@
1
+ // src/mcp.ts
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { dirname, join } from "node:path";
5
+ var mcp = {
6
+ globalConfigPath(homeDir = homedir()) {
7
+ return join(homeDir, ".config", "mcp", "mcp.json");
8
+ },
9
+ async serversEnsure(servers, options = {}) {
10
+ const path = options.path ?? mcp.globalConfigPath();
11
+ const currentText = await readOptional(path);
12
+ const current = parseConfig(currentText, path);
13
+ const nextServers = { ...current.mcpServers };
14
+ for (const [name, entry] of Object.entries(servers)) {
15
+ nextServers[name] = mergeEntry(nextServers[name], entry);
16
+ }
17
+ const next = { ...current, mcpServers: nextServers };
18
+ const changed = JSON.stringify(current) !== JSON.stringify(next);
19
+ if (changed && !options.dryRun) {
20
+ await mkdir(dirname(path), { recursive: true });
21
+ await writeFile(path, `${JSON.stringify(next, null, 2)}
22
+ `, "utf8");
23
+ }
24
+ return { path, changed, existed: currentText !== undefined, planned: changed && options.dryRun === true };
25
+ }
26
+ };
27
+ function mergeEntry(current, required) {
28
+ const merged = { ...current, ...required };
29
+ if (current?.env || required.env)
30
+ merged.env = { ...current?.env, ...required.env };
31
+ return merged;
32
+ }
33
+ function parseConfig(content, path) {
34
+ if (!content?.trim())
35
+ return { mcpServers: {} };
36
+ try {
37
+ const value = JSON.parse(content);
38
+ if (!isRecord(value))
39
+ throw new Error("not an object");
40
+ const servers = value.mcpServers;
41
+ if (servers !== undefined && !isRecord(servers))
42
+ throw new Error("mcpServers is not an object");
43
+ return { ...value, mcpServers: servers ?? {} };
44
+ } catch {
45
+ throw new Error(`Expected a valid pi-mcp-adapter configuration in ${path}.`);
46
+ }
47
+ }
48
+ async function readOptional(path) {
49
+ try {
50
+ return await readFile(path, "utf8");
51
+ } catch (error) {
52
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
53
+ return;
54
+ throw error;
55
+ }
56
+ }
57
+ function isRecord(value) {
58
+ return value !== null && typeof value === "object" && !Array.isArray(value);
59
+ }
60
+ // src/mise.ts
61
+ import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
62
+ import { homedir as homedir2 } from "node:os";
63
+ import { basename, dirname as dirname2, join as join3 } from "node:path";
64
+
65
+ // src/process.ts
66
+ import { constants } from "node:fs";
67
+ import { access } from "node:fs/promises";
68
+ import { delimiter, join as join2 } from "node:path";
69
+ import { spawn } from "node:child_process";
70
+ async function findExecutable(name) {
71
+ if (name.includes("/")) {
72
+ try {
73
+ await access(name, constants.X_OK);
74
+ return name;
75
+ } catch {
76
+ return;
77
+ }
78
+ }
79
+ for (const directory of (process.env.PATH ?? "").split(delimiter)) {
80
+ if (!directory)
81
+ continue;
82
+ const candidate = join2(directory, name);
83
+ try {
84
+ await access(candidate, constants.X_OK);
85
+ return candidate;
86
+ } catch {}
87
+ }
88
+ return;
89
+ }
90
+ function run(command, args, options = {}) {
91
+ return new Promise((resolve, reject) => {
92
+ const child = spawn(command, args, {
93
+ cwd: options.cwd,
94
+ env: options.env ?? process.env,
95
+ stdio: ["ignore", "pipe", "pipe"]
96
+ });
97
+ let stdout = "";
98
+ let stderr = "";
99
+ child.stdout.on("data", (chunk) => {
100
+ stdout = appendBounded(stdout, chunk.toString());
101
+ });
102
+ child.stderr.on("data", (chunk) => {
103
+ stderr = appendBounded(stderr, chunk.toString());
104
+ });
105
+ child.on("error", reject);
106
+ child.on("close", (code) => resolve({ code: code ?? 1, stdout, stderr }));
107
+ });
108
+ }
109
+ async function runChecked(command, args, options = {}) {
110
+ const result = await run(command, args, options);
111
+ if (result.code === 0)
112
+ return result;
113
+ const detail = result.stderr.trim() || result.stdout.trim() || `exit code ${result.code}`;
114
+ throw new Error(`${command} ${args.join(" ")} failed: ${detail}`);
115
+ }
116
+ function appendBounded(current, next) {
117
+ const combined = current + next;
118
+ return combined.length <= 65536 ? combined : combined.slice(-65536);
119
+ }
120
+
121
+ // src/mise.ts
122
+ var mise = {
123
+ async executableCheck(name = "mise") {
124
+ return findExecutable(name);
125
+ },
126
+ async install(options = {}) {
127
+ const homeDir = options.homeDir ?? homedir2();
128
+ const platform = options.platform ?? process.platform;
129
+ if (platform === "win32")
130
+ throw new Error("Automatic mise installation supports macOS and Linux only.");
131
+ const installedPath = join3(homeDir, ".local", "bin", "mise");
132
+ if (options.dryRun)
133
+ return installedPath;
134
+ await runChecked("sh", ["-c", "curl -fsSL https://mise.run | sh"]);
135
+ const executable = await findExecutable(installedPath) ?? await findExecutable("mise");
136
+ if (!executable)
137
+ throw new Error(`mise installation completed, but ${installedPath} was not found.`);
138
+ return executable;
139
+ },
140
+ async hookEnsure(executable, options = {}) {
141
+ const homeDir = options.homeDir ?? homedir2();
142
+ const hook = shellHook(basename(options.shell ?? process.env.SHELL ?? ""), executable, homeDir);
143
+ const current = await readOptional2(hook.path);
144
+ if (current.includes(MISE_HOOK_START))
145
+ return { path: hook.path, changed: false, planned: false };
146
+ if (options.dryRun)
147
+ return { path: hook.path, changed: true, planned: true };
148
+ const separator = current.length === 0 || current.endsWith(`
149
+ `) ? "" : `
150
+ `;
151
+ await mkdir2(dirname2(hook.path), { recursive: true });
152
+ await writeFile2(hook.path, `${current}${separator}${hook.content}`, "utf8");
153
+ return { path: hook.path, changed: true, planned: false };
154
+ },
155
+ async toolCheckGlobal(executable, tool, minimumMajor = 0) {
156
+ const result = await run(executable, ["ls", "--global", "--installed", tool, "--json"]);
157
+ return result.code === 0 && hasInstalledTool(result.stdout, minimumMajor);
158
+ },
159
+ async toolInstallGlobal(executable, specification) {
160
+ await runChecked(executable, ["use", "--global", specification]);
161
+ },
162
+ async toolCheckLocal(executable, tool, cwd = process.cwd()) {
163
+ const result = await run(executable, ["ls", "--local", "--installed", tool, "--json"], { cwd });
164
+ return result.code === 0 && hasInstalledTool(result.stdout);
165
+ },
166
+ async toolInstallLocal(executable, specification, cwd = process.cwd()) {
167
+ await runChecked(executable, ["use", "--path", cwd, specification], { cwd });
168
+ },
169
+ async toolUpdateAllGlobal(executable, homeDir = homedir2()) {
170
+ await runChecked(executable, ["upgrade"], { cwd: homeDir });
171
+ }
172
+ };
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}
190
+ eval "$(${command} activate zsh)"
191
+ ${MISE_HOOK_END}
192
+ `
193
+ };
194
+ }
195
+ if (shell === "fish") {
196
+ return {
197
+ path: join3(homeDir, ".config", "fish", "config.fish"),
198
+ content: `${MISE_HOOK_START}
199
+ ${command} activate fish | source
200
+ ${MISE_HOOK_END}
201
+ `
202
+ };
203
+ }
204
+ throw new Error(`Unsupported shell "${shell || "unknown"}". Supported shells: bash, zsh, fish.`);
205
+ }
206
+ function hasInstalledTool(output, minimumMajor = 0) {
207
+ try {
208
+ const value = JSON.parse(output);
209
+ if (!Array.isArray(value))
210
+ return false;
211
+ return value.some((entry) => {
212
+ if (!entry || typeof entry !== "object" || !("installed" in entry) || entry.installed !== true)
213
+ return false;
214
+ if (minimumMajor === 0)
215
+ return true;
216
+ if (!("version" in entry) || typeof entry.version !== "string")
217
+ return false;
218
+ return Number.parseInt(entry.version, 10) >= minimumMajor;
219
+ });
220
+ } catch {
221
+ return false;
222
+ }
223
+ }
224
+ async function readOptional2(path) {
225
+ try {
226
+ return await readFile2(path, "utf8");
227
+ } catch (error) {
228
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
229
+ return "";
230
+ throw error;
231
+ }
232
+ }
233
+ function shellQuote(value) {
234
+ return `'${value.replaceAll("'", "'\\''")}'`;
235
+ }
236
+ // src/pi.ts
237
+ import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
238
+ import { homedir as homedir3 } from "node:os";
239
+ import { dirname as dirname3, join as join4 } from "node:path";
240
+ var pi = {
241
+ async executableCheck() {
242
+ return findExecutable("pi");
243
+ },
244
+ async packageList(executable) {
245
+ return (await runChecked(executable, ["list"])).stdout;
246
+ },
247
+ packageCheck(listOutput, source) {
248
+ if (listOutput.includes(source))
249
+ return true;
250
+ return source.startsWith("https://") && listOutput.includes(source.slice("https://".length));
251
+ },
252
+ async packageInstall(executable, source) {
253
+ await runChecked(executable, ["install", source]);
254
+ },
255
+ agentDir(homeDir = homedir3()) {
256
+ return resolveAgentDir(homeDir);
257
+ },
258
+ async skillCheckGlobal(name, agentDir = resolveAgentDir(), sharedSkillsDir = join4(homedir3(), ".agents", "skills")) {
259
+ const roots = [join4(agentDir, "skills"), sharedSkillsDir];
260
+ for (const root of roots) {
261
+ if (await readOptional3(join4(root, name, "SKILL.md")) !== undefined)
262
+ return true;
263
+ }
264
+ return false;
265
+ },
266
+ async skillInstallGlobal(miseExecutable, source, names) {
267
+ const selection = names.flatMap((name) => ["--skill", name]);
268
+ await runChecked(miseExecutable, [
269
+ "x",
270
+ "node@22",
271
+ "--",
272
+ "npx",
273
+ "-y",
274
+ "skills",
275
+ "add",
276
+ source,
277
+ ...selection,
278
+ "--global",
279
+ "--agent",
280
+ "pi",
281
+ "--yes"
282
+ ]);
283
+ },
284
+ async configEnsure(path, update, dryRun = false) {
285
+ const currentText = await readOptional3(path);
286
+ const current = parseObject(currentText, path);
287
+ const next = update(current);
288
+ const changed = JSON.stringify(current) !== JSON.stringify(next);
289
+ if (changed && !dryRun) {
290
+ await mkdir3(dirname3(path), { recursive: true });
291
+ await writeFile3(path, `${JSON.stringify(next, null, 2)}
292
+ `, "utf8");
293
+ }
294
+ return { path, changed, existed: currentText !== undefined, planned: changed && dryRun };
295
+ }
296
+ };
297
+ function resolveAgentDir(homeDir = homedir3()) {
298
+ return process.env.PI_CODING_AGENT_DIR ?? (process.env.XDG_CONFIG_HOME ? join4(process.env.XDG_CONFIG_HOME, "pi") : join4(homeDir, ".pi", "agent"));
299
+ }
300
+ async function readOptional3(path) {
301
+ try {
302
+ return await readFile3(path, "utf8");
303
+ } catch (error) {
304
+ if (error instanceof Error && "code" in error && error.code === "ENOENT")
305
+ return;
306
+ throw error;
307
+ }
308
+ }
309
+ function parseObject(content, path) {
310
+ if (!content?.trim())
311
+ return {};
312
+ try {
313
+ const value = JSON.parse(content);
314
+ if (value && typeof value === "object" && !Array.isArray(value))
315
+ return value;
316
+ } catch {}
317
+ throw new Error(`Expected valid JSON object in ${path}.`);
318
+ }
319
+ // src/setup.ts
320
+ import { homedir as homedir4 } from "node:os";
321
+ import { join as join5 } from "node:path";
322
+ async function ensureMise(options = {}) {
323
+ const homeDir = options.homeDir ?? homedir4();
324
+ const current = await mise.executableCheck() ?? await mise.executableCheck(join5(homeDir, ".local", "bin", "mise"));
325
+ if (current)
326
+ return { executable: current, action: action("mise", "ready", current) };
327
+ progress(options, "Installing mise");
328
+ const executable = await mise.install({
329
+ dryRun: options.dryRun,
330
+ homeDir: options.homeDir,
331
+ platform: options.platform
332
+ });
333
+ return { executable, action: action("mise", options.dryRun ? "planned" : "installed", executable) };
334
+ }
335
+ async function ensureMiseHooks(miseExecutable, options = {}) {
336
+ if (options.installMiseHook === false)
337
+ return action("mise shell hook", "skipped", "disabled");
338
+ const result = await mise.hookEnsure(miseExecutable, {
339
+ dryRun: options.dryRun,
340
+ homeDir: options.homeDir,
341
+ shell: options.shell
342
+ });
343
+ if (!result.changed)
344
+ return action("mise shell hook", "ready", result.path);
345
+ return action("mise shell hook", result.planned ? "planned" : "installed", result.path);
346
+ }
347
+ async function ensureMiseDeps(miseExecutable, options = {}) {
348
+ const canRunMise = Boolean(await mise.executableCheck(miseExecutable));
349
+ const actions = [];
350
+ for (const dependency of MISE_DEPENDENCIES) {
351
+ const installed = canRunMise && await mise.toolCheckGlobal(miseExecutable, dependency.tool, dependency.minimumMajor);
352
+ if (installed) {
353
+ actions.push(action(dependency.name, "ready", dependency.spec));
354
+ continue;
355
+ }
356
+ progress(options, `Installing ${dependency.name} with mise`);
357
+ if (!options.dryRun)
358
+ await mise.toolInstallGlobal(miseExecutable, dependency.spec);
359
+ actions.push(action(dependency.name, options.dryRun ? "planned" : "installed", dependency.spec));
360
+ }
361
+ return actions;
362
+ }
363
+ async function ensurePiPlugins(options = {}) {
364
+ const actions = await ensurePiPackages(PI_PACKAGES, options);
365
+ const agentDir = options.agentDir ?? pi.agentDir(options.homeDir);
366
+ 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));
368
+ const lsp = await pi.configEnsure(join5(agentDir, "pi-lsp.json"), (config) => ({
369
+ ...config,
370
+ progressive: { ...record(config.progressive), enabled: true, inject: "none" }
371
+ }), options.dryRun);
372
+ actions.push(configAction("pi-lsp settings", lsp));
373
+ return actions;
374
+ }
375
+ async function ensurePiSkills(miseExecutable, options = {}) {
376
+ const agentDir = options.agentDir ?? pi.agentDir(options.homeDir);
377
+ const sharedSkillsDir = join5(options.homeDir ?? homedir4(), ".agents", "skills");
378
+ const actions = [];
379
+ for (const source of PI_SKILL_SOURCES) {
380
+ const missing = [];
381
+ for (const name of source.skills) {
382
+ if (await pi.skillCheckGlobal(name, agentDir, sharedSkillsDir))
383
+ actions.push(action(`pi skill ${name}`, "ready", source.repository));
384
+ else
385
+ missing.push(name);
386
+ }
387
+ if (missing.length === 0)
388
+ continue;
389
+ progress(options, `Installing skills from ${source.repository}`);
390
+ if (!options.dryRun)
391
+ await pi.skillInstallGlobal(miseExecutable, source.repository, missing);
392
+ for (const name of missing) {
393
+ actions.push(action(`pi skill ${name}`, options.dryRun ? "planned" : "installed", source.repository));
394
+ }
395
+ }
396
+ return actions;
397
+ }
398
+ async function ensureMcpAdapters(miseExecutable, options = {}) {
399
+ const actions = await ensurePiPackages([MCP_ADAPTER_PACKAGE], options);
400
+ const projectDir = options.projectDir ?? process.cwd();
401
+ const servers = {
402
+ "docs-mcp-server": {
403
+ command: miseExecutable,
404
+ args: ["x", "node@22", "--", "npx", "-y", "@arabold/docs-mcp-server@latest"]
405
+ },
406
+ mise: {
407
+ command: miseExecutable,
408
+ args: ["--cd", projectDir, "mcp"],
409
+ env: { MISE_EXPERIMENTAL: "1" }
410
+ },
411
+ "context-mode": {
412
+ command: miseExecutable,
413
+ args: ["x", "npm:context-mode@latest", "--", "context-mode"]
414
+ }
415
+ };
416
+ if (options.issueTracker === "linear") {
417
+ servers.linear = { url: "https://mcp.linear.app/mcp", auth: "oauth", protocolVersion: "auto" };
418
+ } else if (options.issueTracker === "jira") {
419
+ servers.atlassian = { url: "https://mcp.atlassian.com/v1/mcp", auth: "oauth", protocolVersion: "auto" };
420
+ }
421
+ const result = await mcp.serversEnsure(servers, {
422
+ dryRun: options.dryRun,
423
+ path: mcp.globalConfigPath(options.homeDir)
424
+ });
425
+ actions.push(configAction("MCP configuration", result));
426
+ return actions;
427
+ }
428
+ async function setupPi(options = {}) {
429
+ const miseResult = await ensureMise(options);
430
+ const actions = [miseResult.action];
431
+ actions.push(await ensureMiseHooks(miseResult.executable, options));
432
+ actions.push(...await ensureMiseDeps(miseResult.executable, options));
433
+ actions.push(...await ensurePiPlugins(options));
434
+ actions.push(...await ensurePiSkills(miseResult.executable, options));
435
+ actions.push(...await ensureMcpAdapters(miseResult.executable, options));
436
+ return {
437
+ actions,
438
+ 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
+ };
440
+ }
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
+ async function ensurePiPackages(packages, options) {
463
+ const executable = await pi.executableCheck();
464
+ if (!executable && !options.dryRun)
465
+ throw new Error("Install pi before you run diffpi_setup.");
466
+ let installed = executable ? await pi.packageList(executable) : "";
467
+ const actions = [];
468
+ for (const source of packages) {
469
+ if (pi.packageCheck(installed, source)) {
470
+ actions.push(action(`pi package ${source}`, "ready", source));
471
+ continue;
472
+ }
473
+ progress(options, `Installing pi package ${source}`);
474
+ if (!options.dryRun) {
475
+ await pi.packageInstall(executable, source);
476
+ installed += `
477
+ ${source}`;
478
+ }
479
+ actions.push(action(`pi package ${source}`, options.dryRun ? "planned" : "installed", source));
480
+ }
481
+ return actions;
482
+ }
483
+ function configAction(name, result) {
484
+ if (!result.changed)
485
+ return action(name, "ready", result.path);
486
+ if (result.planned)
487
+ return action(name, "planned", result.path);
488
+ return action(name, result.existed ? "updated" : "installed", result.path);
489
+ }
490
+ function action(name, status, detail) {
491
+ return { name, status, detail };
492
+ }
493
+ function progress(options, message) {
494
+ options.onProgress?.(message);
495
+ }
496
+ function record(value) {
497
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
498
+ }
499
+ export {
500
+ ensureMcpAdapters,
501
+ ensureMise,
502
+ ensureMiseDeps,
503
+ ensureMiseHooks,
504
+ ensurePiPlugins,
505
+ ensurePiSkills,
506
+ mcp,
507
+ mise,
508
+ pi,
509
+ setupPi
510
+ };
package/dist/mcp.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type { ServerEntry } from 'pi-mcp-adapter/types';
2
+ export interface McpEnsureOptions {
3
+ dryRun?: boolean;
4
+ path?: string;
5
+ }
6
+ export interface McpEnsureResult {
7
+ path: string;
8
+ changed: boolean;
9
+ existed: boolean;
10
+ planned: boolean;
11
+ }
12
+ export declare const mcp: {
13
+ globalConfigPath(homeDir?: string): string;
14
+ serversEnsure(servers: Readonly<Record<string, ServerEntry>>, options?: McpEnsureOptions): Promise<McpEnsureResult>;
15
+ };
16
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +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"}
package/dist/mise.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export interface MiseInstallOptions {
2
+ dryRun?: boolean;
3
+ homeDir?: string;
4
+ platform?: NodeJS.Platform;
5
+ }
6
+ export interface MiseHookOptions {
7
+ dryRun?: boolean;
8
+ homeDir?: string;
9
+ shell?: string;
10
+ }
11
+ export interface MiseHookResult {
12
+ path: string;
13
+ changed: boolean;
14
+ planned: boolean;
15
+ }
16
+ export declare const mise: {
17
+ executableCheck(name?: string): Promise<string | undefined>;
18
+ install(options?: MiseInstallOptions): Promise<string>;
19
+ hookEnsure(executable: string, options?: MiseHookOptions): Promise<MiseHookResult>;
20
+ toolCheckGlobal(executable: string, tool: string, minimumMajor?: number): Promise<boolean>;
21
+ toolInstallGlobal(executable: string, specification: string): Promise<void>;
22
+ toolCheckLocal(executable: string, tool: string, cwd?: string): Promise<boolean>;
23
+ toolInstallLocal(executable: string, specification: string, cwd?: string): Promise<void>;
24
+ toolUpdateAllGlobal(executable: string, homeDir?: string): Promise<void>;
25
+ };
26
+ //# sourceMappingURL=mise.d.ts.map
@@ -0,0 +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,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,IAAI;oCACuB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;sBAI1C,kBAAkB,GAAQ,OAAO,CAAC,MAAM,CAAC;2BAcnC,MAAM,YAAW,eAAe,GAAQ,OAAO,CAAC,cAAc,CAAC;gCAc1D,MAAM,QAAQ,MAAM,0BAAqB,OAAO,CAAC,OAAO,CAAC;kCAKvD,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 ADDED
@@ -0,0 +1,19 @@
1
+ type JsonObject = Record<string, unknown>;
2
+ export interface PiConfigResult {
3
+ path: string;
4
+ changed: boolean;
5
+ existed: boolean;
6
+ planned: boolean;
7
+ }
8
+ export declare const pi: {
9
+ executableCheck(): Promise<string | undefined>;
10
+ packageList(executable: string): Promise<string>;
11
+ packageCheck(listOutput: string, source: string): boolean;
12
+ packageInstall(executable: string, source: string): Promise<void>;
13
+ agentDir(homeDir?: string): string;
14
+ skillCheckGlobal(name: string, agentDir?: string, sharedSkillsDir?: string): Promise<boolean>;
15
+ skillInstallGlobal(miseExecutable: string, source: string, names: readonly string[]): Promise<void>;
16
+ configEnsure(path: string, update: (config: JsonObject) => JsonObject, dryRun?: boolean): Promise<PiConfigResult>;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=pi.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,13 @@
1
+ export interface CommandResult {
2
+ code: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ }
6
+ export interface CommandOptions {
7
+ cwd?: string;
8
+ env?: NodeJS.ProcessEnv;
9
+ }
10
+ export declare function findExecutable(name: string): Promise<string | undefined>;
11
+ export declare function run(command: string, args: string[], options?: CommandOptions): Promise<CommandResult>;
12
+ export declare function runChecked(command: string, args: string[], options?: CommandOptions): Promise<CommandResult>;
13
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAKA,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;AAED,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"}
@@ -0,0 +1,33 @@
1
+ export type IssueTracker = 'none' | 'linear' | 'jira';
2
+ export type SetupStatus = 'ready' | 'installed' | 'updated' | 'skipped' | 'planned';
3
+ export interface SetupAction {
4
+ name: string;
5
+ status: SetupStatus;
6
+ detail: string;
7
+ }
8
+ export interface SetupOptions {
9
+ issueTracker?: IssueTracker;
10
+ installMiseHook?: boolean;
11
+ dryRun?: boolean;
12
+ homeDir?: string;
13
+ agentDir?: string;
14
+ shell?: string;
15
+ platform?: NodeJS.Platform;
16
+ projectDir?: string;
17
+ onProgress?: (message: string) => void;
18
+ }
19
+ export interface SetupResult {
20
+ actions: SetupAction[];
21
+ restartPi: boolean;
22
+ }
23
+ export declare function ensureMise(options?: SetupOptions): Promise<{
24
+ executable: string;
25
+ action: SetupAction;
26
+ }>;
27
+ export declare function ensureMiseHooks(miseExecutable: string, options?: SetupOptions): Promise<SetupAction>;
28
+ export declare function ensureMiseDeps(miseExecutable: string, options?: SetupOptions): Promise<SetupAction[]>;
29
+ export declare function ensurePiPlugins(options?: SetupOptions): Promise<SetupAction[]>;
30
+ export declare function ensurePiSkills(miseExecutable: string, options?: SetupOptions): Promise<SetupAction[]>;
31
+ export declare function ensureMcpAdapters(miseExecutable: string, options?: SetupOptions): Promise<SetupAction[]>;
32
+ export declare function setupPi(options?: SetupOptions): Promise<SetupResult>;
33
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +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,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,UAAU,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC,CAajH;AAED,wBAAsB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAU9G;AAED,wBAAsB,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAkB/G;AAED,wBAAsB,eAAe,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAqBxF;AAED,wBAAsB,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;AAED,wBAAsB,OAAO,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAsB9E"}
@@ -0,0 +1,9 @@
1
+ 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>];
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}