@polterware/polter 0.4.1 → 0.4.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/api.js +12 -2
- package/dist/{chunk-ZHVOYB5M.js → chunk-CWBIXRZP.js} +162 -2
- package/dist/{chunk-VYHW3UNY.js → chunk-XCCKD3RZ.js} +1 -1
- package/dist/index.js +294 -151
- package/dist/mcp.js +2 -2
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createIpcClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XCCKD3RZ.js";
|
|
4
4
|
import {
|
|
5
5
|
allCommands,
|
|
6
6
|
applyActions,
|
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
getFlagsForTool,
|
|
23
23
|
getMcpStatusInfo,
|
|
24
24
|
getProcessOutput,
|
|
25
|
+
getSkillContent,
|
|
26
|
+
getSkillPath,
|
|
25
27
|
getSocketPath,
|
|
26
28
|
getToolDisplayName,
|
|
27
29
|
getToolInfo,
|
|
@@ -30,17 +32,20 @@ import {
|
|
|
30
32
|
listProcesses,
|
|
31
33
|
parsePolterYaml,
|
|
32
34
|
planChanges,
|
|
35
|
+
registerForegroundProcess,
|
|
33
36
|
removeMcpServerSilent,
|
|
34
37
|
removeProcess,
|
|
35
38
|
resolvePkgArgs,
|
|
36
39
|
resolveToolCommand,
|
|
37
40
|
runCommand,
|
|
38
41
|
savePipeline,
|
|
42
|
+
setupSkill,
|
|
43
|
+
setupSkillCli,
|
|
39
44
|
startProcess,
|
|
40
45
|
stopProcess,
|
|
41
46
|
toolFlags,
|
|
42
47
|
translateCommand
|
|
43
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-CWBIXRZP.js";
|
|
44
49
|
export {
|
|
45
50
|
allCommands,
|
|
46
51
|
applyActions,
|
|
@@ -63,6 +68,8 @@ export {
|
|
|
63
68
|
getFlagsForTool,
|
|
64
69
|
getMcpStatusInfo,
|
|
65
70
|
getProcessOutput,
|
|
71
|
+
getSkillContent,
|
|
72
|
+
getSkillPath,
|
|
66
73
|
getSocketPath,
|
|
67
74
|
getToolDisplayName,
|
|
68
75
|
getToolInfo,
|
|
@@ -71,12 +78,15 @@ export {
|
|
|
71
78
|
listProcesses,
|
|
72
79
|
parsePolterYaml,
|
|
73
80
|
planChanges,
|
|
81
|
+
registerForegroundProcess,
|
|
74
82
|
removeMcpServerSilent,
|
|
75
83
|
removeProcess,
|
|
76
84
|
resolvePkgArgs,
|
|
77
85
|
resolveToolCommand,
|
|
78
86
|
runCommand,
|
|
79
87
|
savePipeline,
|
|
88
|
+
setupSkill,
|
|
89
|
+
setupSkillCli,
|
|
80
90
|
startProcess,
|
|
81
91
|
stopProcess,
|
|
82
92
|
toolFlags,
|
|
@@ -1030,7 +1030,8 @@ function runCommand(execution, args, cwd = process.cwd(), options) {
|
|
|
1030
1030
|
} catch {
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
1033
|
-
}
|
|
1033
|
+
},
|
|
1034
|
+
child
|
|
1034
1035
|
};
|
|
1035
1036
|
}
|
|
1036
1037
|
function runInteractiveCommand(execution, args, cwd = process.cwd()) {
|
|
@@ -1470,6 +1471,47 @@ function startProcess(id, command, args = [], cwd = process.cwd(), env) {
|
|
|
1470
1471
|
registry.set(id, tracked);
|
|
1471
1472
|
return toProcessInfo(tracked);
|
|
1472
1473
|
}
|
|
1474
|
+
function registerForegroundProcess(id, command, args, cwd, child) {
|
|
1475
|
+
const existing = registry.get(id);
|
|
1476
|
+
if (existing && existing.status === "running") {
|
|
1477
|
+
throw new Error(`Process "${id}" is already running (pid ${existing.child.pid})`);
|
|
1478
|
+
}
|
|
1479
|
+
registerCleanup();
|
|
1480
|
+
const tracked = {
|
|
1481
|
+
id,
|
|
1482
|
+
command,
|
|
1483
|
+
args,
|
|
1484
|
+
cwd,
|
|
1485
|
+
child,
|
|
1486
|
+
status: "running",
|
|
1487
|
+
exitCode: null,
|
|
1488
|
+
signal: null,
|
|
1489
|
+
startedAt: /* @__PURE__ */ new Date(),
|
|
1490
|
+
exitedAt: null,
|
|
1491
|
+
stdout: createRingBuffer(),
|
|
1492
|
+
stderr: createRingBuffer()
|
|
1493
|
+
};
|
|
1494
|
+
child.stdout?.on("data", (data) => {
|
|
1495
|
+
appendToBuffer(tracked.stdout, data.toString());
|
|
1496
|
+
});
|
|
1497
|
+
child.stderr?.on("data", (data) => {
|
|
1498
|
+
appendToBuffer(tracked.stderr, data.toString());
|
|
1499
|
+
});
|
|
1500
|
+
child.on("exit", (code, signal) => {
|
|
1501
|
+
tracked.status = "exited";
|
|
1502
|
+
tracked.exitCode = code;
|
|
1503
|
+
tracked.signal = signal;
|
|
1504
|
+
tracked.exitedAt = /* @__PURE__ */ new Date();
|
|
1505
|
+
});
|
|
1506
|
+
child.on("error", (err) => {
|
|
1507
|
+
tracked.status = "errored";
|
|
1508
|
+
tracked.exitedAt = /* @__PURE__ */ new Date();
|
|
1509
|
+
appendToBuffer(tracked.stderr, `spawn error: ${err.message}
|
|
1510
|
+
`);
|
|
1511
|
+
});
|
|
1512
|
+
registry.set(id, tracked);
|
|
1513
|
+
return toProcessInfo(tracked);
|
|
1514
|
+
}
|
|
1473
1515
|
function stopProcess(id) {
|
|
1474
1516
|
const proc = registry.get(id);
|
|
1475
1517
|
if (!proc) throw new Error(`No tracked process with id "${id}"`);
|
|
@@ -2389,6 +2431,119 @@ async function mcpStatus() {
|
|
|
2389
2431
|
}
|
|
2390
2432
|
}
|
|
2391
2433
|
|
|
2434
|
+
// src/lib/skillSetup.ts
|
|
2435
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, mkdirSync as mkdirSync4, existsSync as existsSync9 } from "fs";
|
|
2436
|
+
import { join as join9 } from "path";
|
|
2437
|
+
import { homedir as homedir2 } from "os";
|
|
2438
|
+
import pc2 from "picocolors";
|
|
2439
|
+
var SKILL_DIR = join9(homedir2(), ".claude", "skills", "polter");
|
|
2440
|
+
var SKILL_PATH = join9(SKILL_DIR, "SKILL.md");
|
|
2441
|
+
var SKILL_CONTENT = `---
|
|
2442
|
+
name: polter
|
|
2443
|
+
description: "Polter - Infrastructure Orchestrator. Use when developing in any project to: monitor dev processes and check logs for errors after code changes, manage pipelines (multi-step command sequences), run CLI commands (Supabase, GitHub, Vercel, Git), manage packages (install, build, publish, audit), and apply declarative infrastructure from polter.yaml."
|
|
2444
|
+
---
|
|
2445
|
+
|
|
2446
|
+
# Polter Skill
|
|
2447
|
+
|
|
2448
|
+
You have access to Polter MCP tools for infrastructure orchestration. Use them proactively during development.
|
|
2449
|
+
|
|
2450
|
+
## Process Monitoring
|
|
2451
|
+
|
|
2452
|
+
**Tools:** \`polter_ps\`, \`polter_logs\`, \`polter_start\`, \`polter_stop\`, \`polter_find_process\`, \`polter_smart_start\`, \`polter_run_script_bg\`
|
|
2453
|
+
|
|
2454
|
+
- At the start of a session, run \`polter_ps\` to check for active dev processes
|
|
2455
|
+
- After significant code edits, check \`polter_logs\` for compilation or runtime errors
|
|
2456
|
+
- Use \`polter_find_process\` to find processes running in the current directory
|
|
2457
|
+
- Use \`polter_smart_start\` to start package.json scripts as background processes (e.g. dev servers)
|
|
2458
|
+
- Use \`polter_run_script_bg\` to run arbitrary scripts in the background
|
|
2459
|
+
- Use \`polter_stop\` to stop processes that are no longer needed
|
|
2460
|
+
|
|
2461
|
+
## CLI Commands
|
|
2462
|
+
|
|
2463
|
+
**Tools:** \`polter_list_commands\`, \`polter_run_command\`, \`polter_status\`
|
|
2464
|
+
|
|
2465
|
+
- Execute commands for Supabase, GitHub CLI, Vercel, and Git via their command IDs
|
|
2466
|
+
- Use \`polter_list_commands\` to discover available commands, optionally filtered by tool
|
|
2467
|
+
- Use \`polter_run_command\` to execute a command by its ID with additional args/flags
|
|
2468
|
+
- Check \`polter_status\` to see which CLI tools are installed and their versions
|
|
2469
|
+
|
|
2470
|
+
## Pipelines
|
|
2471
|
+
|
|
2472
|
+
**Tools:** \`polter_list_pipelines\`, \`polter_run_pipeline\`, \`polter_create_pipeline\`, \`polter_update_pipeline\`, \`polter_delete_pipeline\`
|
|
2473
|
+
|
|
2474
|
+
- List and run saved multi-step command sequences with \`polter_list_pipelines\` and \`polter_run_pipeline\`
|
|
2475
|
+
- Create new pipelines for repetitive workflows (e.g. build + test + deploy) with \`polter_create_pipeline\`
|
|
2476
|
+
- Suggest creating pipelines when you notice the user repeating the same sequence of commands
|
|
2477
|
+
|
|
2478
|
+
## Package Management
|
|
2479
|
+
|
|
2480
|
+
**Tools:** \`polter_pkg_build\`, \`polter_pkg_install\`, \`polter_pkg_publish\`, \`polter_pkg_run_script\`, \`polter_pkg_version_bump\`, \`polter_pkg_audit\`, \`polter_pkg_info\`
|
|
2481
|
+
|
|
2482
|
+
- Auto-detects the package manager (npm, pnpm, yarn, bun) from lockfiles
|
|
2483
|
+
- Use \`polter_pkg_build\` for building, \`polter_pkg_install\` for installing dependencies
|
|
2484
|
+
- Use \`polter_pkg_run_script\` to run package.json scripts
|
|
2485
|
+
- Use \`polter_pkg_audit\` to check for vulnerabilities
|
|
2486
|
+
- Use \`polter_pkg_version_bump\` before publishing, then \`polter_pkg_publish\`
|
|
2487
|
+
|
|
2488
|
+
## Declarative Infrastructure
|
|
2489
|
+
|
|
2490
|
+
**Tools:** \`polter_plan\`, \`polter_apply\`
|
|
2491
|
+
|
|
2492
|
+
- Use \`polter_plan\` to read \`polter.yaml\` and compute a diff of desired vs current state
|
|
2493
|
+
- Use \`polter_apply\` to execute the planned infrastructure changes
|
|
2494
|
+
- Always run \`polter_plan\` first to review changes before applying
|
|
2495
|
+
|
|
2496
|
+
## Workflow Recommendations
|
|
2497
|
+
|
|
2498
|
+
1. **Starting a session:** Run \`polter_ps\` to see what's already running
|
|
2499
|
+
2. **After code changes:** Check \`polter_logs\` for errors in dev server output
|
|
2500
|
+
3. **Setting up a project:** Use \`polter_status\` to verify tools, then \`polter_smart_start\` for dev server
|
|
2501
|
+
4. **Deploying:** Create a pipeline with build + test + deploy steps
|
|
2502
|
+
5. **Infrastructure changes:** Edit \`polter.yaml\`, run \`polter_plan\`, then \`polter_apply\`
|
|
2503
|
+
`;
|
|
2504
|
+
function setupSkill() {
|
|
2505
|
+
if (existsSync9(SKILL_PATH)) {
|
|
2506
|
+
const existing = readFileSync5(SKILL_PATH, "utf-8");
|
|
2507
|
+
if (existing === SKILL_CONTENT) {
|
|
2508
|
+
return { status: "already-up-to-date", path: SKILL_PATH };
|
|
2509
|
+
}
|
|
2510
|
+
writeFileSync3(SKILL_PATH, SKILL_CONTENT, "utf-8");
|
|
2511
|
+
return { status: "updated", path: SKILL_PATH };
|
|
2512
|
+
}
|
|
2513
|
+
mkdirSync4(SKILL_DIR, { recursive: true });
|
|
2514
|
+
writeFileSync3(SKILL_PATH, SKILL_CONTENT, "utf-8");
|
|
2515
|
+
return { status: "created", path: SKILL_PATH };
|
|
2516
|
+
}
|
|
2517
|
+
function setupSkillCli() {
|
|
2518
|
+
const result = setupSkill();
|
|
2519
|
+
switch (result.status) {
|
|
2520
|
+
case "created":
|
|
2521
|
+
process.stdout.write(pc2.green(`
|
|
2522
|
+
Skill installed at ${result.path}
|
|
2523
|
+
`));
|
|
2524
|
+
process.stdout.write(pc2.dim(" Use /polter in Claude Code to activate.\n\n"));
|
|
2525
|
+
break;
|
|
2526
|
+
case "updated":
|
|
2527
|
+
process.stdout.write(pc2.green(`
|
|
2528
|
+
Skill updated at ${result.path}
|
|
2529
|
+
`));
|
|
2530
|
+
process.stdout.write(pc2.dim(" Use /polter in Claude Code to activate.\n\n"));
|
|
2531
|
+
break;
|
|
2532
|
+
case "already-up-to-date":
|
|
2533
|
+
process.stdout.write(pc2.cyan(`
|
|
2534
|
+
Skill already up to date at ${result.path}
|
|
2535
|
+
|
|
2536
|
+
`));
|
|
2537
|
+
break;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
function getSkillContent() {
|
|
2541
|
+
return SKILL_CONTENT;
|
|
2542
|
+
}
|
|
2543
|
+
function getSkillPath() {
|
|
2544
|
+
return SKILL_PATH;
|
|
2545
|
+
}
|
|
2546
|
+
|
|
2392
2547
|
export {
|
|
2393
2548
|
__export,
|
|
2394
2549
|
allCommands,
|
|
@@ -2414,6 +2569,7 @@ export {
|
|
|
2414
2569
|
findNearestPackageRoot,
|
|
2415
2570
|
generateProcessId,
|
|
2416
2571
|
startProcess,
|
|
2572
|
+
registerForegroundProcess,
|
|
2417
2573
|
stopProcess,
|
|
2418
2574
|
listProcesses,
|
|
2419
2575
|
getProcessOutput,
|
|
@@ -2443,5 +2599,9 @@ export {
|
|
|
2443
2599
|
getMcpStatusInfo,
|
|
2444
2600
|
installMcpServerSilent,
|
|
2445
2601
|
removeMcpServerSilent,
|
|
2446
|
-
mcpStatus
|
|
2602
|
+
mcpStatus,
|
|
2603
|
+
setupSkill,
|
|
2604
|
+
setupSkillCli,
|
|
2605
|
+
getSkillContent,
|
|
2606
|
+
getSkillPath
|
|
2447
2607
|
};
|