stashes 0.1.19 → 0.1.21
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/cli.js +213 -31
- package/dist/commands/setup.d.ts +13 -0
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +3 -3
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/update.d.ts +2 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +115 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +173 -28
- package/dist/web/assets/{index-_bKtJYAZ.js → index-CMBT005S.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19,9 +19,9 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
var __require = import.meta.require;
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
|
-
import { readFileSync as
|
|
23
|
-
import { join as
|
|
24
|
-
import { fileURLToPath as
|
|
22
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
23
|
+
import { join as join12, dirname as dirname5 } from "path";
|
|
24
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
25
25
|
import { Command } from "commander";
|
|
26
26
|
|
|
27
27
|
// src/commands/start.ts
|
|
@@ -656,6 +656,7 @@ function killAiProcess(id) {
|
|
|
656
656
|
}
|
|
657
657
|
return false;
|
|
658
658
|
}
|
|
659
|
+
var toolNameMap = new Map;
|
|
659
660
|
async function* parseClaudeStream(proc) {
|
|
660
661
|
const stdout = proc.stdout;
|
|
661
662
|
if (!stdout || typeof stdout === "number") {
|
|
@@ -692,15 +693,58 @@ async function* parseClaudeStream(proc) {
|
|
|
692
693
|
} else if (block.type === "thinking" && block.thinking) {
|
|
693
694
|
yield { type: "thinking", content: block.thinking };
|
|
694
695
|
} else if (block.type === "tool_use") {
|
|
695
|
-
|
|
696
|
-
|
|
696
|
+
const toolId = block.id;
|
|
697
|
+
const toolName = block.name;
|
|
698
|
+
toolNameMap.set(toolId, toolName);
|
|
699
|
+
logger.debug("claude", `tool_use: ${toolName}`);
|
|
700
|
+
yield {
|
|
701
|
+
type: "tool_use",
|
|
702
|
+
content: JSON.stringify({ tool: toolName, input: block.input }),
|
|
703
|
+
toolName,
|
|
704
|
+
toolInput: block.input,
|
|
705
|
+
toolUseId: toolId
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
if (parsed.type === "user" && parsed.message) {
|
|
711
|
+
const message = parsed.message;
|
|
712
|
+
for (const block of message.content || []) {
|
|
713
|
+
if (block.type === "tool_result") {
|
|
714
|
+
const toolUseId = block.tool_use_id;
|
|
715
|
+
const isError = block.is_error || false;
|
|
716
|
+
const toolName = toolNameMap.get(toolUseId) || "unknown";
|
|
717
|
+
let resultContent;
|
|
718
|
+
if (typeof block.content === "string") {
|
|
719
|
+
resultContent = block.content;
|
|
720
|
+
} else if (Array.isArray(block.content)) {
|
|
721
|
+
resultContent = block.content.filter((c) => c.type === "text").map((c) => c.text).join(`
|
|
722
|
+
`);
|
|
723
|
+
} else {
|
|
724
|
+
resultContent = "";
|
|
725
|
+
}
|
|
726
|
+
yield {
|
|
727
|
+
type: "tool_result",
|
|
728
|
+
content: resultContent.substring(0, 500),
|
|
729
|
+
toolName,
|
|
730
|
+
toolUseId,
|
|
731
|
+
isError
|
|
732
|
+
};
|
|
697
733
|
}
|
|
698
734
|
}
|
|
699
735
|
}
|
|
736
|
+
if (parsed.type === "result") {
|
|
737
|
+
yield {
|
|
738
|
+
type: "result",
|
|
739
|
+
content: "",
|
|
740
|
+
resultSubtype: parsed.subtype
|
|
741
|
+
};
|
|
742
|
+
}
|
|
700
743
|
}
|
|
701
744
|
}
|
|
702
745
|
} finally {
|
|
703
746
|
logger.debug("claude", `stream ended`, { totalChunks: chunkCount });
|
|
747
|
+
toolNameMap.clear();
|
|
704
748
|
reader.releaseLock();
|
|
705
749
|
}
|
|
706
750
|
}
|
|
@@ -1352,9 +1396,12 @@ ${refs.join(`
|
|
|
1352
1396
|
}
|
|
1353
1397
|
const chatPrompt = [
|
|
1354
1398
|
"You are helping the user explore UI design variations for their project.",
|
|
1355
|
-
"You have access to stashes MCP tools to generate, list, browse, vary, and apply stashes.",
|
|
1399
|
+
"You have access to stashes MCP tools to generate, list, show, browse, vary, and apply stashes.",
|
|
1356
1400
|
"If the user asks you to generate, create, or make variations, use the stashes_generate tool.",
|
|
1357
1401
|
"If the user asks to vary an existing stash, use the stashes_vary tool.",
|
|
1402
|
+
"If the user asks about what a stash changed, its diff, or its contents, use stashes_show to inspect it.",
|
|
1403
|
+
'IMPORTANT: NEVER call stashes_apply unless the user explicitly asks to "apply" or "merge" a stash.',
|
|
1404
|
+
'IMPORTANT: NEVER call stashes_remove unless the user explicitly asks to "delete" or "remove" a stash.',
|
|
1358
1405
|
"Otherwise, respond conversationally about their project and stashes.",
|
|
1359
1406
|
"",
|
|
1360
1407
|
component ? `Component: ${component.name}` : "",
|
|
@@ -1370,11 +1417,27 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1370
1417
|
].filter(Boolean).join(`
|
|
1371
1418
|
`);
|
|
1372
1419
|
const aiProcess = startAiProcess("chat", chatPrompt, this.projectPath);
|
|
1373
|
-
let
|
|
1420
|
+
let thinkingBuf = "";
|
|
1421
|
+
let textBuf = "";
|
|
1422
|
+
const pendingMessages = [];
|
|
1423
|
+
const now = new Date().toISOString();
|
|
1424
|
+
function flushThinking() {
|
|
1425
|
+
if (!thinkingBuf)
|
|
1426
|
+
return;
|
|
1427
|
+
pendingMessages.push({ id: crypto.randomUUID(), role: "assistant", content: thinkingBuf, type: "thinking", createdAt: now });
|
|
1428
|
+
thinkingBuf = "";
|
|
1429
|
+
}
|
|
1430
|
+
function flushText() {
|
|
1431
|
+
if (!textBuf)
|
|
1432
|
+
return;
|
|
1433
|
+
pendingMessages.push({ id: crypto.randomUUID(), role: "assistant", content: textBuf, type: "text", createdAt: now });
|
|
1434
|
+
textBuf = "";
|
|
1435
|
+
}
|
|
1374
1436
|
try {
|
|
1375
1437
|
for await (const chunk of parseClaudeStream(aiProcess.process)) {
|
|
1376
1438
|
if (chunk.type === "text") {
|
|
1377
|
-
|
|
1439
|
+
flushThinking();
|
|
1440
|
+
textBuf += chunk.content;
|
|
1378
1441
|
this.broadcast({
|
|
1379
1442
|
type: "ai_stream",
|
|
1380
1443
|
content: chunk.content,
|
|
@@ -1382,6 +1445,7 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1382
1445
|
source: "chat"
|
|
1383
1446
|
});
|
|
1384
1447
|
} else if (chunk.type === "thinking") {
|
|
1448
|
+
thinkingBuf += chunk.content;
|
|
1385
1449
|
this.broadcast({
|
|
1386
1450
|
type: "ai_stream",
|
|
1387
1451
|
content: chunk.content,
|
|
@@ -1389,13 +1453,25 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1389
1453
|
source: "chat"
|
|
1390
1454
|
});
|
|
1391
1455
|
} else if (chunk.type === "tool_use") {
|
|
1456
|
+
flushThinking();
|
|
1457
|
+
flushText();
|
|
1392
1458
|
let toolName = "unknown";
|
|
1393
1459
|
let toolParams = {};
|
|
1394
1460
|
try {
|
|
1395
1461
|
const parsed = JSON.parse(chunk.content);
|
|
1396
|
-
toolName = parsed.tool
|
|
1397
|
-
toolParams = parsed.input
|
|
1462
|
+
toolName = parsed.tool ?? "unknown";
|
|
1463
|
+
toolParams = parsed.input ?? {};
|
|
1398
1464
|
} catch {}
|
|
1465
|
+
pendingMessages.push({
|
|
1466
|
+
id: crypto.randomUUID(),
|
|
1467
|
+
role: "assistant",
|
|
1468
|
+
content: chunk.content,
|
|
1469
|
+
type: "tool_start",
|
|
1470
|
+
toolName,
|
|
1471
|
+
toolParams,
|
|
1472
|
+
toolStatus: "running",
|
|
1473
|
+
createdAt: now
|
|
1474
|
+
});
|
|
1399
1475
|
this.broadcast({
|
|
1400
1476
|
type: "ai_stream",
|
|
1401
1477
|
content: chunk.content,
|
|
@@ -1406,35 +1482,37 @@ ${sourceCode.substring(0, 3000)}
|
|
|
1406
1482
|
toolStatus: "running"
|
|
1407
1483
|
});
|
|
1408
1484
|
} else if (chunk.type === "tool_result") {
|
|
1409
|
-
let
|
|
1410
|
-
let
|
|
1485
|
+
let toolResult = chunk.content;
|
|
1486
|
+
let isError = false;
|
|
1411
1487
|
try {
|
|
1412
1488
|
const parsed = JSON.parse(chunk.content);
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
} catch {
|
|
1416
|
-
|
|
1417
|
-
|
|
1489
|
+
toolResult = parsed.result ?? chunk.content;
|
|
1490
|
+
isError = !!parsed.is_error;
|
|
1491
|
+
} catch {}
|
|
1492
|
+
pendingMessages.push({
|
|
1493
|
+
id: crypto.randomUUID(),
|
|
1494
|
+
role: "assistant",
|
|
1495
|
+
content: chunk.content,
|
|
1496
|
+
type: "tool_end",
|
|
1497
|
+
toolStatus: isError ? "error" : "completed",
|
|
1498
|
+
toolResult: toolResult.substring(0, 300),
|
|
1499
|
+
createdAt: now
|
|
1500
|
+
});
|
|
1418
1501
|
this.broadcast({
|
|
1419
1502
|
type: "ai_stream",
|
|
1420
1503
|
content: chunk.content,
|
|
1421
1504
|
streamType: "tool_end",
|
|
1422
1505
|
source: "chat",
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
toolResult
|
|
1506
|
+
toolStatus: isError ? "error" : "completed",
|
|
1507
|
+
toolResult: toolResult.substring(0, 300)
|
|
1426
1508
|
});
|
|
1427
1509
|
}
|
|
1428
1510
|
}
|
|
1429
1511
|
await aiProcess.process.exited;
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
content: fullResponse,
|
|
1435
|
-
type: "text",
|
|
1436
|
-
createdAt: new Date().toISOString()
|
|
1437
|
-
});
|
|
1512
|
+
flushThinking();
|
|
1513
|
+
flushText();
|
|
1514
|
+
for (const msg of pendingMessages) {
|
|
1515
|
+
this.persistence.saveChatMessage(projectId, chatId, msg);
|
|
1438
1516
|
}
|
|
1439
1517
|
} catch (err) {
|
|
1440
1518
|
this.broadcast({
|
|
@@ -2444,10 +2522,113 @@ async function setupCommand(options) {
|
|
|
2444
2522
|
}
|
|
2445
2523
|
}
|
|
2446
2524
|
|
|
2525
|
+
// src/commands/update.ts
|
|
2526
|
+
import { spawn as spawn5, execSync } from "child_process";
|
|
2527
|
+
import { writeFileSync as writeFileSync3, chmodSync, readFileSync as readFileSync8 } from "fs";
|
|
2528
|
+
import { tmpdir } from "os";
|
|
2529
|
+
import { join as join11, dirname as dirname4 } from "path";
|
|
2530
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2531
|
+
import * as p2 from "@clack/prompts";
|
|
2532
|
+
import pc2 from "picocolors";
|
|
2533
|
+
function getCurrentVersion() {
|
|
2534
|
+
const selfDir = dirname4(fileURLToPath2(import.meta.url));
|
|
2535
|
+
const pkgPath = join11(selfDir, "..", "package.json");
|
|
2536
|
+
return JSON.parse(readFileSync8(pkgPath, "utf-8")).version;
|
|
2537
|
+
}
|
|
2538
|
+
function fetchLatestVersion() {
|
|
2539
|
+
try {
|
|
2540
|
+
return execSync("npm view stashes version", {
|
|
2541
|
+
encoding: "utf-8",
|
|
2542
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
2543
|
+
}).trim();
|
|
2544
|
+
} catch {
|
|
2545
|
+
return null;
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
function buildUpdateScript(scriptPath) {
|
|
2549
|
+
return [
|
|
2550
|
+
"#!/bin/bash",
|
|
2551
|
+
"set -e",
|
|
2552
|
+
"",
|
|
2553
|
+
'echo ""',
|
|
2554
|
+
'echo "Uninstalling current version..."',
|
|
2555
|
+
"npm uninstall -g stashes 2>/dev/null || true",
|
|
2556
|
+
"",
|
|
2557
|
+
'echo "Installing stashes@latest..."',
|
|
2558
|
+
"npm install -g stashes@latest",
|
|
2559
|
+
"",
|
|
2560
|
+
'echo ""',
|
|
2561
|
+
'echo "Re-registering with AI tools..."',
|
|
2562
|
+
"stashes setup",
|
|
2563
|
+
"",
|
|
2564
|
+
"NEW_VERSION=$(stashes --version)",
|
|
2565
|
+
'echo ""',
|
|
2566
|
+
'echo "\u2713 Updated to stashes v${NEW_VERSION}"',
|
|
2567
|
+
"",
|
|
2568
|
+
"# Self-cleanup",
|
|
2569
|
+
`rm -f "${scriptPath}"`
|
|
2570
|
+
].join(`
|
|
2571
|
+
`);
|
|
2572
|
+
}
|
|
2573
|
+
async function updateCommand() {
|
|
2574
|
+
p2.intro(pc2.bgMagenta(pc2.black(" stashes update ")));
|
|
2575
|
+
const currentVersion = getCurrentVersion();
|
|
2576
|
+
const s = p2.spinner();
|
|
2577
|
+
s.start("Checking for updates...");
|
|
2578
|
+
const latestVersion = fetchLatestVersion();
|
|
2579
|
+
if (!latestVersion) {
|
|
2580
|
+
s.stop("Failed to check for updates");
|
|
2581
|
+
p2.log.error("Could not reach the npm registry. Check your internet connection.");
|
|
2582
|
+
p2.outro("Update aborted.");
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
s.stop(`Latest version: ${pc2.green(latestVersion)}`);
|
|
2586
|
+
if (currentVersion === latestVersion) {
|
|
2587
|
+
p2.log.success(`Already on the latest version ${pc2.bold(currentVersion)}`);
|
|
2588
|
+
p2.outro("Nothing to update.");
|
|
2589
|
+
return;
|
|
2590
|
+
}
|
|
2591
|
+
p2.log.info(`${pc2.yellow(currentVersion)} \u2192 ${pc2.green(latestVersion)}`);
|
|
2592
|
+
const shouldProceed = await p2.confirm({
|
|
2593
|
+
message: "Proceed with update?"
|
|
2594
|
+
});
|
|
2595
|
+
if (p2.isCancel(shouldProceed) || !shouldProceed) {
|
|
2596
|
+
p2.cancel("Update cancelled.");
|
|
2597
|
+
return;
|
|
2598
|
+
}
|
|
2599
|
+
const tools = buildToolDefinitions();
|
|
2600
|
+
const configuredTools = tools.filter((t) => {
|
|
2601
|
+
try {
|
|
2602
|
+
return t.detect() && isConfigured(t);
|
|
2603
|
+
} catch {
|
|
2604
|
+
return false;
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
if (configuredTools.length > 0) {
|
|
2608
|
+
s.start("Removing MCP registrations...");
|
|
2609
|
+
for (const tool of configuredTools) {
|
|
2610
|
+
try {
|
|
2611
|
+
removeMcp(tool);
|
|
2612
|
+
} catch {}
|
|
2613
|
+
}
|
|
2614
|
+
s.stop(`Removed from ${configuredTools.length} tool${configuredTools.length === 1 ? "" : "s"}`);
|
|
2615
|
+
}
|
|
2616
|
+
const scriptPath = join11(tmpdir(), `stashes-update-${Date.now()}.sh`);
|
|
2617
|
+
writeFileSync3(scriptPath, buildUpdateScript(scriptPath), "utf-8");
|
|
2618
|
+
chmodSync(scriptPath, 493);
|
|
2619
|
+
p2.outro("Handing off to updater...");
|
|
2620
|
+
const child = spawn5("bash", [scriptPath], {
|
|
2621
|
+
detached: true,
|
|
2622
|
+
stdio: "inherit"
|
|
2623
|
+
});
|
|
2624
|
+
child.unref();
|
|
2625
|
+
process.exit(0);
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2447
2628
|
// src/index.ts
|
|
2448
|
-
var selfDir =
|
|
2449
|
-
var pkgPath =
|
|
2450
|
-
var version = JSON.parse(
|
|
2629
|
+
var selfDir = dirname5(fileURLToPath3(import.meta.url));
|
|
2630
|
+
var pkgPath = join12(selfDir, "..", "package.json");
|
|
2631
|
+
var version = JSON.parse(readFileSync9(pkgPath, "utf-8")).version;
|
|
2451
2632
|
var program = new Command;
|
|
2452
2633
|
program.name("stashes").description("Generate AI-powered UI design explorations in your project").version(version, "-v, --version");
|
|
2453
2634
|
program.command("browse", { isDefault: true }).description("Start the Stashes server and open the web UI").argument("[path]", "Project directory", ".").option("-p, --port <port>", "Stashes server port", "4000").option("-d, --dev-port <port>", "Your app dev server port (auto-detected)").option("-n, --stashes <count>", "Default stash count", "3").option("--no-open", "Do not open the browser").action(startCommand);
|
|
@@ -2458,4 +2639,5 @@ program.command("vary").description("Create a variation of an existing stash").a
|
|
|
2458
2639
|
program.command("remove").description("Delete a stash and its git branch").argument("<stashId>", "Stash ID to remove").action(removeCommand);
|
|
2459
2640
|
program.command("cleanup").description("Remove all worktrees and stash branches").action(cleanupCommand);
|
|
2460
2641
|
program.command("setup").description("Detect AI tools and register the Stashes MCP server").option("--status", "Show which tools are detected and configured").option("--remove", "Remove Stashes MCP from all tools").action(setupCommand);
|
|
2642
|
+
program.command("update").description("Update stashes to the latest version").action(updateCommand);
|
|
2461
2643
|
program.parse();
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
export interface ToolDefinition {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly configPath: string;
|
|
5
|
+
/** JSON key that holds the MCP servers object */
|
|
6
|
+
readonly serversKey: string;
|
|
7
|
+
/** Zed uses a nested command/settings structure instead of flat command/args */
|
|
8
|
+
readonly format: 'standard' | 'zed';
|
|
9
|
+
detect(): boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildToolDefinitions(): readonly ToolDefinition[];
|
|
12
|
+
export declare function isConfigured(tool: ToolDefinition): boolean;
|
|
13
|
+
export declare function removeMcp(tool: ToolDefinition): void;
|
|
1
14
|
interface SetupOptions {
|
|
2
15
|
status?: boolean;
|
|
3
16
|
remove?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,CAAC;IACpC,MAAM,IAAI,OAAO,CAAC;CACnB;AAsBD,wBAAgB,oBAAoB,IAAI,SAAS,cAAc,EAAE,CA0DhE;AAsBD,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAI1D;AAaD,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAYpD;AA0ID,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvE"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -18,7 +18,7 @@ const MCP_ENTRY_ZED = {
|
|
|
18
18
|
settings: {},
|
|
19
19
|
};
|
|
20
20
|
// ── Tool definitions ────────────────────────────────────────────────────────────
|
|
21
|
-
function buildToolDefinitions() {
|
|
21
|
+
export function buildToolDefinitions() {
|
|
22
22
|
const home = homedir();
|
|
23
23
|
const appSupport = join(home, 'Library', 'Application Support');
|
|
24
24
|
return [
|
|
@@ -93,7 +93,7 @@ function writeJsonFile(path, data) {
|
|
|
93
93
|
writeFileSync(path, JSON.stringify(data, null, 2) + '\n');
|
|
94
94
|
}
|
|
95
95
|
// ── Config operations ───────────────────────────────────────────────────────────
|
|
96
|
-
function isConfigured(tool) {
|
|
96
|
+
export function isConfigured(tool) {
|
|
97
97
|
const config = readJsonFile(tool.configPath);
|
|
98
98
|
const servers = config[tool.serversKey];
|
|
99
99
|
return !!servers?.[MCP_SERVER_NAME];
|
|
@@ -106,7 +106,7 @@ function installMcp(tool) {
|
|
|
106
106
|
config[tool.serversKey] = servers;
|
|
107
107
|
writeJsonFile(tool.configPath, config);
|
|
108
108
|
}
|
|
109
|
-
function removeMcp(tool) {
|
|
109
|
+
export function removeMcp(tool) {
|
|
110
110
|
const config = readJsonFile(tool.configPath);
|
|
111
111
|
const servers = config[tool.serversKey];
|
|
112
112
|
if (!servers)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAe5B,mFAAmF;AAEnF,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,aAAa,CAAC;IACnD,WAAW,EAAE,4CAA4C;CAC1D,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE;QACP,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,EAAE,aAAa,CAAC;KACpD;IACD,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,mFAAmF;AAEnF,
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACp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,IAAI,MAAO,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,CAAC,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;AACzG,CAAC;AASD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqB;IACtD,MAAM,KAAK,GAAG,oBAAoB,EAAE,CAAC;IAErC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,UAAU,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;SAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAuDA,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CA6EnD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { spawn, execSync } from 'node:child_process';
|
|
2
|
+
import { writeFileSync, chmodSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, dirname } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import * as p from '@clack/prompts';
|
|
7
|
+
import pc from 'picocolors';
|
|
8
|
+
import { buildToolDefinitions, removeMcp, isConfigured } from './setup.js';
|
|
9
|
+
// ── Helpers ─────────────────────────────────────────────────────────────────────
|
|
10
|
+
function getCurrentVersion() {
|
|
11
|
+
const selfDir = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const pkgPath = join(selfDir, '..', 'package.json');
|
|
13
|
+
return JSON.parse(readFileSync(pkgPath, 'utf-8')).version;
|
|
14
|
+
}
|
|
15
|
+
function fetchLatestVersion() {
|
|
16
|
+
try {
|
|
17
|
+
return execSync('npm view stashes version', {
|
|
18
|
+
encoding: 'utf-8',
|
|
19
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
20
|
+
}).trim();
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function buildUpdateScript(scriptPath) {
|
|
27
|
+
return [
|
|
28
|
+
'#!/bin/bash',
|
|
29
|
+
'set -e',
|
|
30
|
+
'',
|
|
31
|
+
'echo ""',
|
|
32
|
+
'echo "Uninstalling current version..."',
|
|
33
|
+
'npm uninstall -g stashes 2>/dev/null || true',
|
|
34
|
+
'',
|
|
35
|
+
'echo "Installing stashes@latest..."',
|
|
36
|
+
'npm install -g stashes@latest',
|
|
37
|
+
'',
|
|
38
|
+
'echo ""',
|
|
39
|
+
'echo "Re-registering with AI tools..."',
|
|
40
|
+
'stashes setup',
|
|
41
|
+
'',
|
|
42
|
+
'NEW_VERSION=$(stashes --version)',
|
|
43
|
+
'echo ""',
|
|
44
|
+
'echo "✓ Updated to stashes v${NEW_VERSION}"',
|
|
45
|
+
'',
|
|
46
|
+
'# Self-cleanup',
|
|
47
|
+
`rm -f "${scriptPath}"`,
|
|
48
|
+
].join('\n');
|
|
49
|
+
}
|
|
50
|
+
// ── Command ─────────────────────────────────────────────────────────────────────
|
|
51
|
+
export async function updateCommand() {
|
|
52
|
+
p.intro(pc.bgMagenta(pc.black(' stashes update ')));
|
|
53
|
+
const currentVersion = getCurrentVersion();
|
|
54
|
+
// Check latest version from npm registry
|
|
55
|
+
const s = p.spinner();
|
|
56
|
+
s.start('Checking for updates...');
|
|
57
|
+
const latestVersion = fetchLatestVersion();
|
|
58
|
+
if (!latestVersion) {
|
|
59
|
+
s.stop('Failed to check for updates');
|
|
60
|
+
p.log.error('Could not reach the npm registry. Check your internet connection.');
|
|
61
|
+
p.outro('Update aborted.');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
s.stop(`Latest version: ${pc.green(latestVersion)}`);
|
|
65
|
+
if (currentVersion === latestVersion) {
|
|
66
|
+
p.log.success(`Already on the latest version ${pc.bold(currentVersion)}`);
|
|
67
|
+
p.outro('Nothing to update.');
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
p.log.info(`${pc.yellow(currentVersion)} → ${pc.green(latestVersion)}`);
|
|
71
|
+
// Confirm with user
|
|
72
|
+
const shouldProceed = await p.confirm({
|
|
73
|
+
message: 'Proceed with update?',
|
|
74
|
+
});
|
|
75
|
+
if (p.isCancel(shouldProceed) || !shouldProceed) {
|
|
76
|
+
p.cancel('Update cancelled.');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Remove MCP from all configured tools (in-process, while binary still exists)
|
|
80
|
+
const tools = buildToolDefinitions();
|
|
81
|
+
const configuredTools = tools.filter((t) => {
|
|
82
|
+
try {
|
|
83
|
+
return t.detect() && isConfigured(t);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (configuredTools.length > 0) {
|
|
90
|
+
s.start('Removing MCP registrations...');
|
|
91
|
+
for (const tool of configuredTools) {
|
|
92
|
+
try {
|
|
93
|
+
removeMcp(tool);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// Best effort — continue with remaining tools
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
s.stop(`Removed from ${configuredTools.length} tool${configuredTools.length === 1 ? '' : 's'}`);
|
|
100
|
+
}
|
|
101
|
+
// Write a detached shell script to handle uninstall → install → setup.
|
|
102
|
+
// This avoids the self-destruct problem: the current Node process exits
|
|
103
|
+
// cleanly before npm removes the binary from disk.
|
|
104
|
+
const scriptPath = join(tmpdir(), `stashes-update-${Date.now()}.sh`);
|
|
105
|
+
writeFileSync(scriptPath, buildUpdateScript(scriptPath), 'utf-8');
|
|
106
|
+
chmodSync(scriptPath, 0o755);
|
|
107
|
+
p.outro('Handing off to updater...');
|
|
108
|
+
const child = spawn('bash', [scriptPath], {
|
|
109
|
+
detached: true,
|
|
110
|
+
stdio: 'inherit',
|
|
111
|
+
});
|
|
112
|
+
child.unref();
|
|
113
|
+
process.exit(0);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3E,mFAAmF;AAEnF,SAAS,iBAAiB;IACxB,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,OAAiB,CAAC;AACtE,CAAC;AAED,SAAS,kBAAkB;IACzB,IAAI,CAAC;Q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