@polterware/polter 0.4.1 → 0.5.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.
- package/README.md +0 -70
- package/dist/api.js +68 -26
- package/dist/app-HGIGWI7F.js +393 -0
- package/dist/appPanel-EZOHLTBX.js +1365 -0
- package/dist/applier-OEXIUYYO.js +10 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-45CQFZU7.js +262 -0
- package/dist/chunk-57CZSEY5.js +5398 -0
- package/dist/chunk-6IBRTRLX.js +257 -0
- package/dist/chunk-AK3NTS3Y.js +220 -0
- package/dist/chunk-BGT5TT2A.js +32 -0
- package/dist/chunk-BIN7BDA2.js +77 -0
- package/dist/chunk-E2B5FFBU.js +81 -0
- package/dist/chunk-EAMHFQKU.js +222 -0
- package/dist/chunk-ELSIHPJL.js +455 -0
- package/dist/{chunk-VYHW3UNY.js → chunk-GCS7JEYU.js} +7 -3
- package/dist/chunk-GKROVUDG.js +15 -0
- package/dist/chunk-GVIKF6UI.js +738 -0
- package/dist/chunk-JQB2A3CA.js +72 -0
- package/dist/chunk-KEGROLGX.js +50 -0
- package/dist/chunk-OKHPN6X7.js +49 -0
- package/dist/chunk-RVMOIUSL.js +22 -0
- package/dist/chunk-TD6YNU6L.js +22 -0
- package/dist/chunk-U64WZOJ3.js +101 -0
- package/dist/chunk-U6725U7K.js +138 -0
- package/dist/chunk-XNRIN3VM.js +125 -0
- package/dist/chunk-ZU5VZHYD.js +28 -0
- package/dist/commands-BIIWGCVS.js +15 -0
- package/dist/editor-AUFJZ4PE.js +11 -0
- package/dist/engine-EZQ26HDJ.js +11 -0
- package/dist/globalConf-AGMMIKSL.js +7 -0
- package/dist/index.js +55 -7464
- package/dist/ipcServer-HXOPKNBP.js +10 -0
- package/dist/mcp.js +182 -13892
- package/dist/mcpInstaller-J2AGFNWR.js +19 -0
- package/dist/parser-4ZBGSI2U.js +10 -0
- package/dist/planner-ZVBA66V6.js +9 -0
- package/dist/processManager-6T5DBURV.js +37 -0
- package/dist/projectConfig-TRCJS3VI.js +21 -0
- package/dist/skillSetup-ZQEHJ5ZG.js +14 -0
- package/dist/status-QMRCV4XJ.js +8 -0
- package/dist/storage-C3D7TLJW.js +17 -0
- package/dist/toolResolver-A2BUT3NK.js +17 -0
- package/package.json +20 -2
- package/dist/chunk-ZHVOYB5M.js +0 -2447
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
__require
|
|
10
|
+
};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
commandExists
|
|
3
|
+
} from "./chunk-RVMOIUSL.js";
|
|
4
|
+
import {
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
readFileSync,
|
|
8
|
+
writeFileSync
|
|
9
|
+
} from "./chunk-TD6YNU6L.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/mcpInstaller.ts
|
|
12
|
+
import { spawnSync } from "child_process";
|
|
13
|
+
import { join, dirname } from "path";
|
|
14
|
+
import { fileURLToPath } from "url";
|
|
15
|
+
import { homedir } from "os";
|
|
16
|
+
import pc from "picocolors";
|
|
17
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
function readPkgVersion() {
|
|
19
|
+
for (const rel of ["../../package.json", "../package.json"]) {
|
|
20
|
+
const p = join(__dirname, rel);
|
|
21
|
+
if (existsSync(p)) {
|
|
22
|
+
const pkg = JSON.parse(readFileSync(p, "utf-8"));
|
|
23
|
+
return pkg.version;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return "0.0.0";
|
|
27
|
+
}
|
|
28
|
+
var MCP_ARGS = ["npx", "-y", "-p", "@polterware/polter@latest", "polter-mcp"];
|
|
29
|
+
var SCOPE_LABELS = {
|
|
30
|
+
local: "local (this machine)",
|
|
31
|
+
project: "project (shared via repo)",
|
|
32
|
+
user: "global (all projects)"
|
|
33
|
+
};
|
|
34
|
+
function tryClaudeCli(scope) {
|
|
35
|
+
if (!commandExists("claude")) return false;
|
|
36
|
+
const result = spawnSync("claude", ["mcp", "add", "-s", scope, "polter", "--", ...MCP_ARGS], {
|
|
37
|
+
stdio: "inherit",
|
|
38
|
+
shell: true
|
|
39
|
+
});
|
|
40
|
+
return result.status === 0;
|
|
41
|
+
}
|
|
42
|
+
function getSettingsPath(scope) {
|
|
43
|
+
if (scope === "project") {
|
|
44
|
+
return join(process.cwd(), ".mcp.json");
|
|
45
|
+
}
|
|
46
|
+
return join(homedir(), ".claude", "settings.json");
|
|
47
|
+
}
|
|
48
|
+
function tryManualInstall(scope) {
|
|
49
|
+
const settingsPath = getSettingsPath(scope);
|
|
50
|
+
const dir = join(settingsPath, "..");
|
|
51
|
+
let settings = {};
|
|
52
|
+
if (existsSync(settingsPath)) {
|
|
53
|
+
try {
|
|
54
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
55
|
+
} catch {
|
|
56
|
+
process.stderr.write(pc.red(`Failed to parse ${settingsPath}
|
|
57
|
+
`));
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
mkdirSync(dir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
const mcpServers = settings.mcpServers ?? {};
|
|
64
|
+
mcpServers.polter = {
|
|
65
|
+
command: "npx",
|
|
66
|
+
args: ["-y", "-p", "@polterware/polter@latest", "polter-mcp"]
|
|
67
|
+
};
|
|
68
|
+
settings.mcpServers = mcpServers;
|
|
69
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
async function installMcpServer(scope) {
|
|
73
|
+
process.stdout.write(pc.bold(`Installing Polter MCP server \u2014 ${SCOPE_LABELS[scope]}
|
|
74
|
+
|
|
75
|
+
`));
|
|
76
|
+
if (commandExists("claude")) {
|
|
77
|
+
process.stdout.write(` Using 'claude mcp add -s ${scope}'...
|
|
78
|
+
`);
|
|
79
|
+
if (tryClaudeCli(scope)) {
|
|
80
|
+
process.stdout.write(pc.green("\n Done! Restart Claude Code to use Polter tools.\n"));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
process.stdout.write(pc.yellow(" 'claude mcp add' failed, falling back to manual install...\n\n"));
|
|
84
|
+
}
|
|
85
|
+
const settingsPath = getSettingsPath(scope);
|
|
86
|
+
process.stdout.write(` Writing to ${settingsPath}...
|
|
87
|
+
`);
|
|
88
|
+
if (tryManualInstall(scope)) {
|
|
89
|
+
process.stdout.write(pc.green("\n Done! Restart Claude Code to use Polter tools.\n"));
|
|
90
|
+
} else {
|
|
91
|
+
process.stderr.write(pc.red("\n Failed to install. Add manually:\n\n"));
|
|
92
|
+
process.stderr.write(` ${pc.dim(JSON.stringify({ mcpServers: { polter: { command: "npx", args: ["-y", "-p", "@polterware/polter@latest", "polter-mcp"] } } }, null, 2))}
|
|
93
|
+
`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function removeMcpServer(scope) {
|
|
98
|
+
process.stdout.write(pc.bold(`Removing Polter MCP server \u2014 ${SCOPE_LABELS[scope]}
|
|
99
|
+
|
|
100
|
+
`));
|
|
101
|
+
if (commandExists("claude")) {
|
|
102
|
+
const result = spawnSync("claude", ["mcp", "remove", "-s", scope, "polter"], {
|
|
103
|
+
stdio: "inherit",
|
|
104
|
+
shell: true
|
|
105
|
+
});
|
|
106
|
+
if (result.status === 0) {
|
|
107
|
+
process.stdout.write(pc.green("\n Done! Polter MCP server removed.\n"));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
process.stdout.write(pc.yellow(" 'claude mcp remove' failed, falling back to manual removal...\n\n"));
|
|
111
|
+
}
|
|
112
|
+
const settingsPath = getSettingsPath(scope);
|
|
113
|
+
if (!existsSync(settingsPath)) {
|
|
114
|
+
process.stdout.write(pc.yellow(" No settings file found. Nothing to remove.\n"));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
let settings;
|
|
118
|
+
try {
|
|
119
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
120
|
+
} catch {
|
|
121
|
+
process.stderr.write(pc.red(` Failed to parse ${settingsPath}
|
|
122
|
+
`));
|
|
123
|
+
process.exit(1);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const mcpServers = settings.mcpServers;
|
|
127
|
+
if (!mcpServers?.polter) {
|
|
128
|
+
process.stdout.write(pc.yellow(" Polter MCP server not found in settings. Nothing to remove.\n"));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
delete mcpServers.polter;
|
|
132
|
+
settings.mcpServers = mcpServers;
|
|
133
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
134
|
+
process.stdout.write(pc.green(" Done! Polter MCP server removed.\n"));
|
|
135
|
+
}
|
|
136
|
+
function getMcpStatusInfo() {
|
|
137
|
+
const version = readPkgVersion();
|
|
138
|
+
const scopeDefs = [
|
|
139
|
+
{ label: "Project (.mcp.json)", path: join(process.cwd(), ".mcp.json"), scope: "project" },
|
|
140
|
+
{ label: "User (~/.claude/settings.json)", path: join(homedir(), ".claude", "settings.json"), scope: "user" }
|
|
141
|
+
];
|
|
142
|
+
const scopes = scopeDefs.map((s) => {
|
|
143
|
+
if (!existsSync(s.path)) {
|
|
144
|
+
return { label: s.label, scope: s.scope, registered: false };
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const settings = JSON.parse(readFileSync(s.path, "utf-8"));
|
|
148
|
+
const mcpServers = settings.mcpServers;
|
|
149
|
+
return { label: s.label, scope: s.scope, registered: !!mcpServers?.polter };
|
|
150
|
+
} catch {
|
|
151
|
+
return { label: s.label, scope: s.scope, registered: false, error: "error reading file" };
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return { installedVersion: version, latestVersion: null, scopes };
|
|
155
|
+
}
|
|
156
|
+
async function installMcpServerSilent(scope) {
|
|
157
|
+
const messages = [];
|
|
158
|
+
messages.push(`Installing Polter MCP server \u2014 ${SCOPE_LABELS[scope]}`);
|
|
159
|
+
if (commandExists("claude")) {
|
|
160
|
+
messages.push(`Using 'claude mcp add -s ${scope}'...`);
|
|
161
|
+
if (tryClaudeCli(scope)) {
|
|
162
|
+
messages.push("Done! Restart Claude Code to use Polter tools.");
|
|
163
|
+
return { success: true, message: messages.join("\n") };
|
|
164
|
+
}
|
|
165
|
+
messages.push("'claude mcp add' failed, falling back to manual install...");
|
|
166
|
+
}
|
|
167
|
+
const settingsPath = getSettingsPath(scope);
|
|
168
|
+
messages.push(`Writing to ${settingsPath}...`);
|
|
169
|
+
if (tryManualInstall(scope)) {
|
|
170
|
+
messages.push("Done! Restart Claude Code to use Polter tools.");
|
|
171
|
+
return { success: true, message: messages.join("\n") };
|
|
172
|
+
}
|
|
173
|
+
return { success: false, message: "Failed to install. Try manual installation." };
|
|
174
|
+
}
|
|
175
|
+
async function removeMcpServerSilent(scope) {
|
|
176
|
+
const messages = [];
|
|
177
|
+
messages.push(`Removing Polter MCP server \u2014 ${SCOPE_LABELS[scope]}`);
|
|
178
|
+
if (commandExists("claude")) {
|
|
179
|
+
const result = spawnSync("claude", ["mcp", "remove", "-s", scope, "polter"], {
|
|
180
|
+
encoding: "utf-8",
|
|
181
|
+
shell: true
|
|
182
|
+
});
|
|
183
|
+
if (result.status === 0) {
|
|
184
|
+
messages.push("Done! Polter MCP server removed.");
|
|
185
|
+
return { success: true, message: messages.join("\n") };
|
|
186
|
+
}
|
|
187
|
+
messages.push("'claude mcp remove' failed, falling back to manual removal...");
|
|
188
|
+
}
|
|
189
|
+
const settingsPath = getSettingsPath(scope);
|
|
190
|
+
if (!existsSync(settingsPath)) {
|
|
191
|
+
messages.push("No settings file found. Nothing to remove.");
|
|
192
|
+
return { success: true, message: messages.join("\n") };
|
|
193
|
+
}
|
|
194
|
+
let settings;
|
|
195
|
+
try {
|
|
196
|
+
settings = JSON.parse(readFileSync(settingsPath, "utf-8"));
|
|
197
|
+
} catch {
|
|
198
|
+
return { success: false, message: `Failed to parse ${settingsPath}` };
|
|
199
|
+
}
|
|
200
|
+
const mcpServers = settings.mcpServers;
|
|
201
|
+
if (!mcpServers?.polter) {
|
|
202
|
+
messages.push("Polter MCP server not found in settings. Nothing to remove.");
|
|
203
|
+
return { success: true, message: messages.join("\n") };
|
|
204
|
+
}
|
|
205
|
+
delete mcpServers.polter;
|
|
206
|
+
settings.mcpServers = mcpServers;
|
|
207
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
208
|
+
messages.push("Done! Polter MCP server removed.");
|
|
209
|
+
return { success: true, message: messages.join("\n") };
|
|
210
|
+
}
|
|
211
|
+
async function mcpStatus() {
|
|
212
|
+
process.stdout.write(pc.bold("Polter MCP Server Status\n\n"));
|
|
213
|
+
const pkgVersion = readPkgVersion();
|
|
214
|
+
process.stdout.write(` Installed version: ${pc.cyan(pkgVersion)}
|
|
215
|
+
`);
|
|
216
|
+
const latestResult = spawnSync("npm", ["view", "@polterware/polter", "version"], {
|
|
217
|
+
encoding: "utf-8",
|
|
218
|
+
shell: true,
|
|
219
|
+
timeout: 1e4
|
|
220
|
+
});
|
|
221
|
+
const latest = latestResult.stdout?.trim();
|
|
222
|
+
if (latest) {
|
|
223
|
+
const upToDate = latest === pkgVersion;
|
|
224
|
+
process.stdout.write(` Latest version: ${upToDate ? pc.green(latest) : pc.yellow(`${latest} (update available)`)}
|
|
225
|
+
`);
|
|
226
|
+
}
|
|
227
|
+
process.stdout.write("\n");
|
|
228
|
+
const scopes = [
|
|
229
|
+
{ label: "Project (.mcp.json)", path: join(process.cwd(), ".mcp.json"), key: "project" },
|
|
230
|
+
{ label: "User (~/.claude/settings.json)", path: join(homedir(), ".claude", "settings.json"), key: "user" }
|
|
231
|
+
];
|
|
232
|
+
for (const scope of scopes) {
|
|
233
|
+
if (!existsSync(scope.path)) {
|
|
234
|
+
process.stdout.write(` ${scope.label}: ${pc.dim("not found")}
|
|
235
|
+
`);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
const settings = JSON.parse(readFileSync(scope.path, "utf-8"));
|
|
240
|
+
const mcpServers = settings.mcpServers;
|
|
241
|
+
if (mcpServers?.polter) {
|
|
242
|
+
process.stdout.write(` ${scope.label}: ${pc.green("registered")}
|
|
243
|
+
`);
|
|
244
|
+
} else {
|
|
245
|
+
process.stdout.write(` ${scope.label}: ${pc.dim("not registered")}
|
|
246
|
+
`);
|
|
247
|
+
}
|
|
248
|
+
} catch {
|
|
249
|
+
process.stdout.write(` ${scope.label}: ${pc.red("error reading file")}
|
|
250
|
+
`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
installMcpServer,
|
|
257
|
+
removeMcpServer,
|
|
258
|
+
getMcpStatusInfo,
|
|
259
|
+
installMcpServerSilent,
|
|
260
|
+
removeMcpServerSilent,
|
|
261
|
+
mcpStatus
|
|
262
|
+
};
|