supipowers 0.7.1 → 0.7.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/bin/install.mjs +49 -0
- package/package.json +1 -1
- package/src/context-mode/detector.ts +20 -8
package/bin/install.mjs
CHANGED
|
@@ -196,6 +196,55 @@ async function main() {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
// ── Step 2b: Register context-mode MCP server (if installed) ──
|
|
200
|
+
|
|
201
|
+
const ctxSpinner = spinner();
|
|
202
|
+
ctxSpinner.start("Checking for context-mode...");
|
|
203
|
+
|
|
204
|
+
// Find context-mode installation (Claude Code plugin cache)
|
|
205
|
+
const ctxCacheBase = join(homedir(), ".claude", "plugins", "cache", "context-mode", "context-mode");
|
|
206
|
+
let ctxInstallPath = null;
|
|
207
|
+
if (existsSync(ctxCacheBase)) {
|
|
208
|
+
// Find the latest version directory
|
|
209
|
+
const versions = readdirSync(ctxCacheBase, { withFileTypes: true })
|
|
210
|
+
.filter((d) => d.isDirectory())
|
|
211
|
+
.map((d) => d.name)
|
|
212
|
+
.sort()
|
|
213
|
+
.reverse();
|
|
214
|
+
if (versions.length > 0) {
|
|
215
|
+
const candidate = join(ctxCacheBase, versions[0], "start.mjs");
|
|
216
|
+
if (existsSync(candidate)) {
|
|
217
|
+
ctxInstallPath = join(ctxCacheBase, versions[0]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (ctxInstallPath) {
|
|
223
|
+
// Register as MCP server in ~/.omp/agent/mcp.json
|
|
224
|
+
const mcpConfigPath = join(homedir(), ".omp", "agent", "mcp.json");
|
|
225
|
+
let mcpConfig = { mcpServers: {} };
|
|
226
|
+
if (existsSync(mcpConfigPath)) {
|
|
227
|
+
try {
|
|
228
|
+
mcpConfig = JSON.parse(readFileSync(mcpConfigPath, "utf8"));
|
|
229
|
+
if (!mcpConfig.mcpServers) mcpConfig.mcpServers = {};
|
|
230
|
+
} catch {
|
|
231
|
+
mcpConfig = { mcpServers: {} };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const startMjs = join(ctxInstallPath, "start.mjs");
|
|
236
|
+
mcpConfig.mcpServers["context-mode"] = {
|
|
237
|
+
command: "node",
|
|
238
|
+
args: [startMjs],
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const { writeFileSync: writeFs } = await import("node:fs");
|
|
242
|
+
writeFs(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
|
|
243
|
+
ctxSpinner.stop(`context-mode registered as MCP server (${ctxInstallPath})`);
|
|
244
|
+
} else {
|
|
245
|
+
ctxSpinner.stop("context-mode not found (install it as a Claude Code plugin for context window protection)");
|
|
246
|
+
}
|
|
247
|
+
|
|
199
248
|
// ── Step 3: LSP setup (optional, skipped with --skip-lsp) ──
|
|
200
249
|
|
|
201
250
|
if (skipLsp) {
|
package/package.json
CHANGED
|
@@ -24,13 +24,26 @@ const TOOL_SUFFIXES: Array<[string, keyof ContextModeStatus["tools"]]> = [
|
|
|
24
24
|
];
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Check if a tool name matches a context-mode tool suffix.
|
|
28
|
+
* Handles multiple naming conventions:
|
|
29
|
+
* - Bare names: "ctx_execute"
|
|
30
|
+
* - Claude Code MCP: "mcp__plugin_context-mode_context-mode__ctx_execute"
|
|
31
|
+
* - OMP MCP: "mcp_context_mode_ctx_execute"
|
|
32
|
+
*
|
|
33
|
+
* We match by checking if the tool contains a known context-mode server
|
|
34
|
+
* prefix followed by the suffix, or is the bare suffix itself.
|
|
30
35
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const CONTEXT_MODE_PREFIXES = [
|
|
37
|
+
"mcp__plugin_context-mode_context-mode__", // Claude Code
|
|
38
|
+
"mcp_context_mode_", // OMP
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
function matchesSuffix(tool: string, suffix: string): boolean {
|
|
42
|
+
if (tool === suffix) return true;
|
|
43
|
+
for (const prefix of CONTEXT_MODE_PREFIXES) {
|
|
44
|
+
if (tool === prefix + suffix) return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
/** Detect context-mode MCP tool availability from the active tools list */
|
|
@@ -45,9 +58,8 @@ export function detectContextMode(activeTools: string[]): ContextModeStatus {
|
|
|
45
58
|
};
|
|
46
59
|
|
|
47
60
|
for (const tool of activeTools) {
|
|
48
|
-
const shortName = getShortName(tool);
|
|
49
61
|
for (const [suffix, key] of TOOL_SUFFIXES) {
|
|
50
|
-
if (
|
|
62
|
+
if (matchesSuffix(tool, suffix)) {
|
|
51
63
|
tools[key] = true;
|
|
52
64
|
break;
|
|
53
65
|
}
|