codiedev 0.9.8 → 0.9.9

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/dist/hook.js CHANGED
@@ -254,8 +254,11 @@ async function main() {
254
254
  const transcriptBase64 = Buffer.from(transcriptContent, "utf8").toString("base64");
255
255
  // Session→merge join keys: the branch + HEAD sha the work happened on. Matched
256
256
  // server-side against a merged MR/PR's source_branch / commits for AI attribution.
257
- const branch = (0, utils_1.getGitBranch)(workspaceRoot);
258
- const headSha = (0, utils_1.getGitHeadSha)(workspaceRoot);
257
+ // Capture from the worktree the agent actually worked in (the launch dir stays
258
+ // on main/detached when work happens in a `git worktree`), not workspaceRoot.
259
+ const captureDir = (0, utils_1.resolveCaptureDir)(transcriptContent, workspaceRoot);
260
+ const branch = (0, utils_1.getGitBranch)(captureDir);
261
+ const headSha = (0, utils_1.getGitHeadSha)(captureDir);
259
262
  // Cost/velocity/steering signals parsed straight from the transcript we're
260
263
  // already holding — no extra hooks, no extra git/process calls.
261
264
  const usage = (0, utils_1.parseUsage)(transcriptContent, mode);
package/dist/utils.d.ts CHANGED
@@ -27,6 +27,7 @@ export declare function matchRepo(remoteUrl: string, repos: Array<{
27
27
  url: string;
28
28
  fullName: string;
29
29
  } | null;
30
+ export declare function resolveCaptureDir(transcriptContent: string, workspaceRoot: string): string;
30
31
  export declare function getGitBranch(cwd: string): string | null;
31
32
  export declare function getGitHeadSha(cwd: string): string | null;
32
33
  export interface CapturePayloadInput {
package/dist/utils.js CHANGED
@@ -40,6 +40,7 @@ exports.readGitRemoteFromConfig = readGitRemoteFromConfig;
40
40
  exports.getGitRemoteUrl = getGitRemoteUrl;
41
41
  exports.normalizeRepoUrl = normalizeRepoUrl;
42
42
  exports.matchRepo = matchRepo;
43
+ exports.resolveCaptureDir = resolveCaptureDir;
43
44
  exports.getGitBranch = getGitBranch;
44
45
  exports.getGitHeadSha = getGitHeadSha;
45
46
  exports.buildCapturePayload = buildCapturePayload;
@@ -254,6 +255,44 @@ function matchRepo(remoteUrl, repos) {
254
255
  }
255
256
  return null;
256
257
  }
258
+ // Resolve the directory to capture git branch/headSha from.
259
+ //
260
+ // The session→merge join keys must describe the work that becomes the PR. But
261
+ // agents do that work in a `git worktree` (.claude/worktrees/<name> or a
262
+ // sibling dir) on a feature branch, while the session's LAUNCH dir
263
+ // (workspaceRoot) stays on main/detached — a feature branch checked out in a
264
+ // worktree cannot also be checked out in the launch dir. Capturing from the
265
+ // launch dir therefore recorded main/null, matching no PR (velocity starved).
266
+ //
267
+ // Fix: scan the transcript for the cwd the agent actually worked in — the
268
+ // most-recent one that is a SEPARATE worktree (its resolved gitdir differs from
269
+ // the launch root's; a worktree's gitdir is .git/worktrees/<name>, while the
270
+ // root and its subdirs share .git). Fall back to the launch root when no
271
+ // separate worktree was used (work done directly in the repo).
272
+ function resolveCaptureDir(transcriptContent, workspaceRoot) {
273
+ const rootGitDir = resolveGitDir(workspaceRoot);
274
+ const cwds = [];
275
+ for (const line of transcriptContent.split("\n")) {
276
+ if (!line.trim())
277
+ continue;
278
+ try {
279
+ const entry = JSON.parse(line);
280
+ if (typeof entry?.cwd === "string" && entry.cwd)
281
+ cwds.push(entry.cwd);
282
+ }
283
+ catch {
284
+ // non-JSON / partial line — skip
285
+ }
286
+ }
287
+ // Most-recent first: the last worktree touched is the one most likely to have
288
+ // produced the PR.
289
+ for (let i = cwds.length - 1; i >= 0; i--) {
290
+ const gitDir = resolveGitDir(cwds[i]);
291
+ if (gitDir && (!rootGitDir || gitDir !== rootGitDir))
292
+ return cwds[i];
293
+ }
294
+ return workspaceRoot;
295
+ }
257
296
  // Current branch via direct .git/HEAD read (no git binary required, same
258
297
  // robustness as getGitRemoteUrl). Returns null on detached HEAD or when
259
298
  // unresolvable. This is the session→merge join key: a captured session's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codiedev",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "Connect Claude Code, Codex, Cursor, or VS Code Copilot to Codiedev for org-wide session capture and artifact collaboration",
5
5
  "bin": {
6
6
  "codiedev": "dist/cli.js",