supipowers 0.7.4 → 0.7.6

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.
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ // Wrapper for context-mode MCP server that preserves the project directory.
3
+ // OMP launches MCP servers with cwd set to the project directory, but
4
+ // context-mode's start.mjs immediately does process.chdir(__dirname),
5
+ // losing the project path. This wrapper captures cwd first.
6
+ //
7
+ // Setting CLAUDE_PROJECT_DIR causes start.mjs to also write a CLAUDE.md
8
+ // in the project root. This is harmless (OMP doesn't read it) but the
9
+ // user should gitignore it. We also write .omp/SYSTEM.md with routing
10
+ // rules since that's what OMP actually loads as system prompt.
11
+
12
+ import { resolve, join, dirname } from "node:path";
13
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
14
+ import { fileURLToPath } from "node:url";
15
+ import { homedir } from "node:os";
16
+
17
+ const __wrapperDir = dirname(fileURLToPath(import.meta.url));
18
+
19
+ // Capture the real project directory BEFORE start.mjs clobbers it
20
+ const projectDir = resolve(process.cwd());
21
+ process.env.CLAUDE_PROJECT_DIR = projectDir;
22
+
23
+ // Resolve start.mjs path from the first CLI argument
24
+ const startMjs = process.argv[2];
25
+ if (!startMjs) {
26
+ process.stderr.write("ctx-mode-wrapper: missing start.mjs path argument\n");
27
+ process.exit(1);
28
+ }
29
+
30
+ // Write .omp/SYSTEM.md with routing rules (idempotent — only if marker absent)
31
+ const ROUTING_MARKER = "# context-mode — MANDATORY routing rules";
32
+ try {
33
+ // Find SKILL.md from multiple possible locations
34
+ const skillCandidates = [
35
+ join(homedir(), ".omp", "agent", "skills", "context-mode", "SKILL.md"),
36
+ join(__wrapperDir, "..", "skills", "context-mode", "SKILL.md"),
37
+ ];
38
+ let skillContent = null;
39
+ for (const candidate of skillCandidates) {
40
+ try { skillContent = readFileSync(candidate, "utf-8"); break; } catch { /* next */ }
41
+ }
42
+
43
+ if (skillContent && skillContent.includes(ROUTING_MARKER)) {
44
+ const ompDir = join(projectDir, ".omp");
45
+ const systemMdPath = join(ompDir, "SYSTEM.md");
46
+
47
+ if (!existsSync(ompDir)) mkdirSync(ompDir, { recursive: true });
48
+
49
+ if (!existsSync(systemMdPath)) {
50
+ writeFileSync(systemMdPath, skillContent);
51
+ } else {
52
+ const existing = readFileSync(systemMdPath, "utf-8");
53
+ if (!existing.includes(ROUTING_MARKER)) {
54
+ writeFileSync(systemMdPath, existing.trimEnd() + "\n\n" + skillContent);
55
+ }
56
+ }
57
+ }
58
+ } catch { /* best effort — don't block server startup */ }
59
+
60
+ // Dynamic import to run start.mjs (server starts here)
61
+ await import(startMjs);
package/bin/install.mjs CHANGED
@@ -170,9 +170,10 @@ async function main() {
170
170
  rmSync(extDir, { recursive: true });
171
171
  }
172
172
 
173
- // Copy extension (src/ + package.json) → ~/.omp/agent/extensions/supipowers/
173
+ // Copy extension (src/ + bin/ + package.json) → ~/.omp/agent/extensions/supipowers/
174
174
  mkdirSync(extDir, { recursive: true });
175
175
  cpSync(join(packageRoot, "src"), join(extDir, "src"), { recursive: true });
176
+ cpSync(join(packageRoot, "bin"), join(extDir, "bin"), { recursive: true });
176
177
  cpSync(join(packageRoot, "package.json"), join(extDir, "package.json"));
177
178
 
178
179
  // Copy skills → ~/.omp/agent/skills/<skillname>/SKILL.md
@@ -233,9 +234,12 @@ async function main() {
233
234
  }
234
235
 
235
236
  const startMjs = join(ctxInstallPath, "start.mjs");
237
+ // Use our wrapper script that captures cwd as CLAUDE_PROJECT_DIR
238
+ // before context-mode's start.mjs clobbers it with process.chdir(__dirname)
239
+ const wrapperMjs = join(extDir, "bin", "ctx-mode-wrapper.mjs");
236
240
  mcpConfig.mcpServers["context-mode"] = {
237
241
  command: "node",
238
- args: [startMjs],
242
+ args: [wrapperMjs, startMjs],
239
243
  };
240
244
 
241
245
  const { writeFileSync: writeFs } = await import("node:fs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supipowers",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "OMP-native workflow extension inspired by supipowers.",
5
5
  "type": "module",
6
6
  "scripts": {