context-mode 1.0.21 → 1.0.23

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.
Files changed (59) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +4 -2
  3. package/.openclaw-plugin/index.ts +11 -0
  4. package/.openclaw-plugin/openclaw.plugin.json +23 -0
  5. package/.openclaw-plugin/package.json +28 -0
  6. package/README.md +165 -26
  7. package/build/adapters/antigravity/index.d.ts +49 -0
  8. package/build/adapters/antigravity/index.js +217 -0
  9. package/build/adapters/client-map.d.ts +10 -0
  10. package/build/adapters/client-map.js +18 -0
  11. package/build/adapters/detect.d.ts +8 -1
  12. package/build/adapters/detect.js +58 -1
  13. package/build/adapters/kiro/hooks.d.ts +32 -0
  14. package/build/adapters/kiro/hooks.js +47 -0
  15. package/build/adapters/kiro/index.d.ts +50 -0
  16. package/build/adapters/kiro/index.js +325 -0
  17. package/build/adapters/openclaw/config.d.ts +8 -0
  18. package/build/adapters/openclaw/config.js +8 -0
  19. package/build/adapters/openclaw/hooks.d.ts +50 -0
  20. package/build/adapters/openclaw/hooks.js +61 -0
  21. package/build/adapters/openclaw/index.d.ts +51 -0
  22. package/build/adapters/openclaw/index.js +459 -0
  23. package/build/adapters/openclaw/session-db.d.ts +55 -0
  24. package/build/adapters/openclaw/session-db.js +88 -0
  25. package/build/adapters/types.d.ts +1 -1
  26. package/build/cli.js +5 -3
  27. package/build/executor.js +99 -112
  28. package/build/openclaw/workspace-router.d.ts +29 -0
  29. package/build/openclaw/workspace-router.js +64 -0
  30. package/build/openclaw-plugin.d.ts +121 -0
  31. package/build/openclaw-plugin.js +525 -0
  32. package/build/server.js +45 -10
  33. package/build/session/db.d.ts +9 -0
  34. package/build/session/db.js +38 -0
  35. package/cli.bundle.mjs +136 -124
  36. package/configs/antigravity/GEMINI.md +58 -0
  37. package/configs/antigravity/mcp_config.json +7 -0
  38. package/configs/kiro/mcp_config.json +7 -0
  39. package/configs/openclaw/AGENTS.md +58 -0
  40. package/configs/openclaw/openclaw.json +13 -0
  41. package/hooks/core/routing.mjs +16 -8
  42. package/hooks/kiro/posttooluse.mjs +58 -0
  43. package/hooks/kiro/pretooluse.mjs +63 -0
  44. package/hooks/posttooluse.mjs +6 -5
  45. package/hooks/precompact.mjs +5 -4
  46. package/hooks/session-db.bundle.mjs +57 -0
  47. package/hooks/session-extract.bundle.mjs +1 -0
  48. package/hooks/session-helpers.mjs +41 -3
  49. package/hooks/session-loaders.mjs +28 -0
  50. package/hooks/session-snapshot.bundle.mjs +14 -0
  51. package/hooks/sessionstart.mjs +6 -5
  52. package/hooks/userpromptsubmit.mjs +6 -5
  53. package/hooks/vscode-copilot/posttooluse.mjs +5 -4
  54. package/hooks/vscode-copilot/precompact.mjs +5 -4
  55. package/hooks/vscode-copilot/sessionstart.mjs +5 -4
  56. package/openclaw.plugin.json +23 -0
  57. package/package.json +13 -2
  58. package/server.bundle.mjs +94 -82
  59. package/start.mjs +1 -0
@@ -7,6 +7,44 @@
7
7
  */
8
8
  import { SQLiteBase, defaultDBPath } from "../db-base.js";
9
9
  import { createHash } from "node:crypto";
10
+ import { execFileSync } from "node:child_process";
11
+ // ─────────────────────────────────────────────────────────
12
+ // Worktree isolation
13
+ // ─────────────────────────────────────────────────────────
14
+ /**
15
+ * Returns the worktree suffix to append to session identifiers.
16
+ * Returns empty string when running in the main working tree.
17
+ *
18
+ * Set CONTEXT_MODE_SESSION_SUFFIX to an explicit value to override
19
+ * (useful in CI environments or when git is unavailable).
20
+ * Set to empty string to disable isolation entirely.
21
+ */
22
+ export function getWorktreeSuffix() {
23
+ const envSuffix = process.env.CONTEXT_MODE_SESSION_SUFFIX;
24
+ if (envSuffix !== undefined) {
25
+ return envSuffix ? `__${envSuffix}` : "";
26
+ }
27
+ try {
28
+ const cwd = process.cwd();
29
+ const mainWorktree = execFileSync("git", ["worktree", "list", "--porcelain"], {
30
+ encoding: "utf-8",
31
+ timeout: 2000,
32
+ stdio: ["ignore", "pipe", "ignore"],
33
+ })
34
+ .split(/\r?\n/)
35
+ .find((l) => l.startsWith("worktree "))
36
+ ?.replace("worktree ", "")
37
+ ?.trim();
38
+ if (mainWorktree && cwd !== mainWorktree) {
39
+ const suffix = createHash("sha256").update(cwd).digest("hex").slice(0, 8);
40
+ return `__${suffix}`;
41
+ }
42
+ }
43
+ catch {
44
+ // git not available or not a git repo — no suffix
45
+ }
46
+ return "";
47
+ }
10
48
  // ─────────────────────────────────────────────────────────
11
49
  // Constants
12
50
  // ─────────────────────────────────────────────────────────