supipowers 0.7.5 → 0.7.7

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.
@@ -3,13 +3,57 @@
3
3
  // OMP launches MCP servers with cwd set to the project directory, but
4
4
  // context-mode's start.mjs immediately does process.chdir(__dirname),
5
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.
6
11
 
7
- import { resolve } from "node:path";
12
+ import { resolve, join, dirname } from "node:path";
13
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, copyFileSync } from "node:fs";
14
+ import { fileURLToPath } from "node:url";
15
+ import { homedir } from "node:os";
16
+ import os from "node:os";
17
+
18
+ const __wrapperDir = dirname(fileURLToPath(import.meta.url));
8
19
 
9
20
  // Capture the real project directory BEFORE start.mjs clobbers it
10
21
  const projectDir = resolve(process.cwd());
11
22
  process.env.CLAUDE_PROJECT_DIR = projectDir;
12
23
 
24
+ // Redirect context-mode's FTS5 database to a project-scoped directory.
25
+ // ContentStore uses `join(tmpdir(), "context-mode-<pid>.db")`.
26
+ // By patching os.tmpdir, the DB lives in .omp/context-mode/ instead of /tmp/.
27
+ // We also copy the previous session's DB to the new PID filename so indexed
28
+ // content persists across sessions (context-mode creates per-PID filenames).
29
+ const ctxDbDir = join(projectDir, ".omp", "context-mode");
30
+ if (!existsSync(ctxDbDir)) mkdirSync(ctxDbDir, { recursive: true });
31
+
32
+ // Find the most recent existing DB and copy it for the new session
33
+ const currentDbName = `context-mode-${process.pid}.db`;
34
+ try {
35
+ const existing = readdirSync(ctxDbDir)
36
+ .filter(f => f.match(/^context-mode-\d+\.db$/) && f !== currentDbName);
37
+ if (existing.length > 0) {
38
+ // Pick the newest by mtime
39
+ const newest = existing
40
+ .map(f => ({ name: f, mtime: statSync(join(ctxDbDir, f)).mtimeMs }))
41
+ .sort((a, b) => b.mtime - a.mtime)[0];
42
+ if (newest) {
43
+ copyFileSync(join(ctxDbDir, newest.name), join(ctxDbDir, currentDbName));
44
+ // Also copy WAL/SHM if they exist
45
+ for (const suffix of ["-wal", "-shm"]) {
46
+ const src = join(ctxDbDir, newest.name + suffix);
47
+ if (existsSync(src)) {
48
+ copyFileSync(src, join(ctxDbDir, currentDbName + suffix));
49
+ }
50
+ }
51
+ }
52
+ }
53
+ } catch { /* best effort */ }
54
+
55
+ os.tmpdir = () => ctxDbDir;
56
+
13
57
  // Resolve start.mjs path from the first CLI argument
14
58
  const startMjs = process.argv[2];
15
59
  if (!startMjs) {
@@ -17,5 +61,35 @@ if (!startMjs) {
17
61
  process.exit(1);
18
62
  }
19
63
 
20
- // Dynamic import to run start.mjs
64
+ // Write .omp/SYSTEM.md with routing rules (idempotent — only if marker absent)
65
+ const ROUTING_MARKER = "# context-mode — MANDATORY routing rules";
66
+ try {
67
+ // Find SKILL.md from multiple possible locations
68
+ const skillCandidates = [
69
+ join(homedir(), ".omp", "agent", "skills", "context-mode", "SKILL.md"),
70
+ join(__wrapperDir, "..", "skills", "context-mode", "SKILL.md"),
71
+ ];
72
+ let skillContent = null;
73
+ for (const candidate of skillCandidates) {
74
+ try { skillContent = readFileSync(candidate, "utf-8"); break; } catch { /* next */ }
75
+ }
76
+
77
+ if (skillContent && skillContent.includes(ROUTING_MARKER)) {
78
+ const ompDir = join(projectDir, ".omp");
79
+ const systemMdPath = join(ompDir, "SYSTEM.md");
80
+
81
+ if (!existsSync(ompDir)) mkdirSync(ompDir, { recursive: true });
82
+
83
+ if (!existsSync(systemMdPath)) {
84
+ writeFileSync(systemMdPath, skillContent);
85
+ } else {
86
+ const existing = readFileSync(systemMdPath, "utf-8");
87
+ if (!existing.includes(ROUTING_MARKER)) {
88
+ writeFileSync(systemMdPath, existing.trimEnd() + "\n\n" + skillContent);
89
+ }
90
+ }
91
+ }
92
+ } catch { /* best effort — don't block server startup */ }
93
+
94
+ // Dynamic import to run start.mjs (server starts here)
21
95
  await import(startMjs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supipowers",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "OMP-native workflow extension inspired by supipowers.",
5
5
  "type": "module",
6
6
  "scripts": {