codiedev 0.9.82 → 0.9.83

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.
@@ -8,9 +8,14 @@ export declare function launcherPath(): string;
8
8
  /** True iff `cmd` invokes the stable launcher (from any state dir). */
9
9
  export declare function usesLauncher(cmd: string | undefined): boolean;
10
10
  export declare function readInstallRecord(): InstallRecord | null;
11
+ /** True if `p` is inside the OS temp folder (real paths, so /var vs /private/var on macOS match). */
12
+ export declare function isInTempDir(p: string, tmp?: string): boolean;
11
13
  /**
12
14
  * The hook script worth recording: absolute and present, and a global install over an npx cache
13
15
  * copy (npm prunes ~/.npm/_npx, and hooks pointed there go quietly dead). Null = don't record.
16
+ * Never a build in the temp folder: test runs stage one there, delete it, and if that landed in
17
+ * the real install.json every hook went quietly dead. CODIEDEV_ALLOW_TEMP_HOOK=1 (the CLI's own
18
+ * test setup) lets sandboxed tests use one.
14
19
  */
15
20
  export declare function stableHookScript(hookScript: string, globalCandidates?: string[]): string | null;
16
21
  /** Point the launcher at `hookScript`. Atomic, so a hook mid-launch never reads half a file. */
package/dist/launcher.js CHANGED
@@ -48,16 +48,18 @@ exports.LAUNCHER_FILE = void 0;
48
48
  exports.launcherPath = launcherPath;
49
49
  exports.usesLauncher = usesLauncher;
50
50
  exports.readInstallRecord = readInstallRecord;
51
+ exports.isInTempDir = isInTempDir;
51
52
  exports.stableHookScript = stableHookScript;
52
53
  exports.recordCurrentInstall = recordCurrentInstall;
53
54
  exports.ensureLauncher = ensureLauncher;
54
55
  exports.resetLauncherCacheForTests = resetLauncherCacheForTests;
55
56
  const fs = __importStar(require("fs"));
57
+ const os = __importStar(require("os"));
56
58
  const path = __importStar(require("path"));
57
59
  const configDir_1 = require("./configDir");
58
60
  exports.LAUNCHER_FILE = "codiedev-hook-launcher.cjs";
59
61
  // Bump when LAUNCHER_SOURCE changes so existing launchers get rewritten.
60
- const LAUNCHER_REVISION = 1;
62
+ const LAUNCHER_REVISION = 2;
61
63
  function launcherPath() {
62
64
  return path.join((0, configDir_1.codiedevStateDir)(), "bin", exports.LAUNCHER_FILE);
63
65
  }
@@ -85,6 +87,12 @@ try {
85
87
  if (rec && typeof rec.hookScript === "string" && fs.existsSync(rec.hookScript)) target = rec.hookScript;
86
88
  } catch {}
87
89
  if (!target && fs.existsSync(FALLBACK)) target = FALLBACK;
90
+ if (!target) {
91
+ // Both stranded (e.g. a deleted temp build): use a global install next to this node.
92
+ const prefix = path.dirname(path.dirname(process.execPath));
93
+ target = [path.join(prefix, "lib", "node_modules", "codiedev", "dist", "hook.js"),
94
+ path.join(prefix, "node_modules", "codiedev", "dist", "hook.js")].find((p) => fs.existsSync(p)) || null;
95
+ }
88
96
  if (!target) process.exit(0);
89
97
  process.env.CODIEDEV_VIA_LAUNCHER = "1";
90
98
  process.argv[1] = target;
@@ -115,15 +123,34 @@ function packageVersionFor(hookScript) {
115
123
  return undefined;
116
124
  }
117
125
  }
126
+ /** True if `p` is inside the OS temp folder (real paths, so /var vs /private/var on macOS match). */
127
+ function isInTempDir(p, tmp = os.tmpdir()) {
128
+ const real = (x) => {
129
+ try {
130
+ return fs.realpathSync(x);
131
+ }
132
+ catch {
133
+ return path.resolve(x);
134
+ }
135
+ };
136
+ const rel = path.relative(real(tmp), real(p));
137
+ return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
138
+ }
118
139
  /**
119
140
  * The hook script worth recording: absolute and present, and a global install over an npx cache
120
141
  * copy (npm prunes ~/.npm/_npx, and hooks pointed there go quietly dead). Null = don't record.
142
+ * Never a build in the temp folder: test runs stage one there, delete it, and if that landed in
143
+ * the real install.json every hook went quietly dead. CODIEDEV_ALLOW_TEMP_HOOK=1 (the CLI's own
144
+ * test setup) lets sandboxed tests use one.
121
145
  */
122
146
  function stableHookScript(hookScript, globalCandidates = globalHookScripts()) {
123
147
  if (!hookScript || !path.isAbsolute(hookScript) || hookScript.includes(`${path.sep}~${path.sep}`))
124
148
  return null;
125
149
  if (!fs.existsSync(hookScript))
126
150
  return null;
151
+ if (process.env.CODIEDEV_ALLOW_TEMP_HOOK !== "1" && isInTempDir(hookScript)) {
152
+ return globalCandidates.find((p) => path.isAbsolute(p) && fs.existsSync(p) && !isInTempDir(p)) ?? null;
153
+ }
127
154
  if (hookScript.includes(`${path.sep}_npx${path.sep}`)) {
128
155
  const global = globalCandidates.find((p) => path.isAbsolute(p) && fs.existsSync(p));
129
156
  if (global)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codiedev",
3
- "version": "0.9.82",
3
+ "version": "0.9.83",
4
4
  "description": "Connect Claude Code, Codex, Cursor, OpenCode, or VS Code Copilot to Codiedev for team session capture and artifact collaboration — and run the governed Codie harness",
5
5
  "bin": {
6
6
  "codiedev": "dist/cli.js",