sticky-note-cli 3.1.25 → 3.1.27

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/cli.js CHANGED
@@ -369,6 +369,30 @@ function ensureMcpInCopilotCliConfig(serverName, serverConfig) {
369
369
  }
370
370
  }
371
371
 
372
+ // ──────────────────────────────────────────────
373
+ // Sticky dir resolution (mirrors mcp-server.js stickyDir())
374
+ // ──────────────────────────────────────────────
375
+
376
+ // Returns the active sticky-note data directory for the current project.
377
+ // Mirrors the same logic as stickyDir() in mcp-server.js: prefers the
378
+ // data-branch worktree at <git-dir>/sticky-note/ if it has sticky-note.json,
379
+ // falls back to the in-tree .sticky-note/ directory.
380
+ function getActiveStickyDir(cwd) {
381
+ const root = cwd || process.cwd();
382
+ try {
383
+ const gitDir = execFileSync("git", ["rev-parse", "--absolute-git-dir"], {
384
+ encoding: "utf-8", timeout: 3000, stdio: ["pipe", "pipe", "pipe"], cwd: root,
385
+ }).trim();
386
+ const dataBranchDir = path.join(gitDir, "sticky-note");
387
+ if (fs.existsSync(path.join(dataBranchDir, "sticky-note.json"))) {
388
+ return dataBranchDir;
389
+ }
390
+ } catch (_) {
391
+ // not a git repo or git unavailable — fall through
392
+ }
393
+ return path.join(root, ".sticky-note");
394
+ }
395
+
372
396
  // ──────────────────────────────────────────────
373
397
  // Auto-detection
374
398
  // ──────────────────────────────────────────────
@@ -1088,8 +1112,9 @@ async function cmdInit() {
1088
1112
  print(" [OK] Skipping git pre/post-commit hooks (data branch sync handles this now)");
1089
1113
  print(" Run `npx sticky-note migrate` to migrate existing .sticky-note/ data.");
1090
1114
 
1091
- // Create environment directory structure
1092
- const envDir = path.join(stickyNoteDir, "environment");
1115
+ // Create environment directory structure.
1116
+ // Uses getActiveStickyDir() so re-runs on repos with a data branch write to the right place.
1117
+ const envDir = path.join(getActiveStickyDir(), "environment");
1093
1118
  const envManifestDest = path.join(envDir, "manifest.json");
1094
1119
  mkdirSafe(path.join(envDir, "skills"));
1095
1120
  mkdirSafe(path.join(envDir, "agents"));
@@ -1394,20 +1419,23 @@ function cmdUpdate() {
1394
1419
  print(" [OK] .claude/sticky-note-mcp.js (MCP entry point updated)");
1395
1420
  }
1396
1421
 
1397
- // Migrate .mcp.json to use "node .claude/sticky-note-mcp.js" instead of npx subcommand.
1422
+ // Ensure .mcp.json has a correct sticky-note entry using "node .claude/sticky-note-mcp.js".
1398
1423
  // The old npx approach goes through multiple .cmd shim layers on Windows, causing
1399
1424
  // Claude Code to silently skip the server. The node approach is a direct single process.
1400
1425
  const correctMcpEntry = { type: "stdio", command: "node", args: [".claude/sticky-note-mcp.js"] };
1401
1426
  try {
1402
1427
  const mcpJsonPath = path.join(process.cwd(), ".mcp.json");
1403
- if (fs.existsSync(mcpJsonPath)) {
1404
- const mcpJson = readJsonSafe(mcpJsonPath, {});
1405
- const projectEntry = mcpJson.mcpServers && mcpJson.mcpServers["sticky-note"];
1406
- if (projectEntry && (projectEntry.command !== "node" || JSON.stringify(projectEntry.args) !== JSON.stringify(correctMcpEntry.args))) {
1407
- mcpJson.mcpServers["sticky-note"] = correctMcpEntry;
1408
- fs.writeFileSync(mcpJsonPath, JSON.stringify(mcpJson, null, 2) + "\n");
1409
- print(" [OK] .mcp.json: migrated sticky-note to direct node invocation (Windows MCP fix)");
1410
- }
1428
+ const mcpJson = fs.existsSync(mcpJsonPath) ? readJsonSafe(mcpJsonPath, {}) : {};
1429
+ if (!mcpJson.mcpServers) mcpJson.mcpServers = {};
1430
+ const projectEntry = mcpJson.mcpServers["sticky-note"];
1431
+ if (!projectEntry) {
1432
+ mcpJson.mcpServers["sticky-note"] = correctMcpEntry;
1433
+ fs.writeFileSync(mcpJsonPath, JSON.stringify(mcpJson, null, 2) + "\n");
1434
+ print(" [OK] .mcp.json: added sticky-note MCP entry");
1435
+ } else if (projectEntry.command !== "node" || JSON.stringify(projectEntry.args) !== JSON.stringify(correctMcpEntry.args)) {
1436
+ mcpJson.mcpServers["sticky-note"] = correctMcpEntry;
1437
+ fs.writeFileSync(mcpJsonPath, JSON.stringify(mcpJson, null, 2) + "\n");
1438
+ print(" [OK] .mcp.json: migrated sticky-note to direct node invocation (Windows MCP fix)");
1411
1439
  }
1412
1440
  } catch (_) { /* non-fatal */ }
1413
1441
 
@@ -1423,8 +1451,10 @@ function cmdUpdate() {
1423
1451
  }
1424
1452
  } catch (_) { /* non-fatal */ }
1425
1453
 
1426
- // Create environment directory if missing (idempotent — skips if manifest already exists)
1427
- const envDir = path.join(stickyDir, "environment");
1454
+ // Create environment directory if missing (idempotent — skips if manifest already exists).
1455
+ // Uses getActiveStickyDir() to resolve the data-branch worktree path when applicable,
1456
+ // so it matches the same path the MCP server's stickyDir() resolves.
1457
+ const envDir = path.join(getActiveStickyDir(), "environment");
1428
1458
  const envManifestDest = path.join(envDir, "manifest.json");
1429
1459
  mkdirSafe(path.join(envDir, "skills"));
1430
1460
  mkdirSafe(path.join(envDir, "agents"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sticky-note-cli",
3
- "version": "3.1.25",
3
+ "version": "3.1.27",
4
4
  "description": "Human-to-human handoff for AI coding assistants. Git-backed shared memory for Claude Code and Copilot CLI.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -2,4 +2,7 @@
2
2
  // sticky-note MCP server entry point
3
3
  // Auto-generated by sticky-note-cli init/update. Do not edit manually.
4
4
  // Runs the sticky-note MCP server in-process using the installed package.
5
+ // Injects --project so the server always reads from this project's root,
6
+ // regardless of the CWD Claude Code uses when spawning the MCP process.
7
+ process.argv.push("--project", require("path").resolve(__dirname, ".."));
5
8
  require("sticky-note-cli/bin/mcp-server.js");