@susu-eng/trunk-sync 2.3.2 → 2.3.4

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trunk-sync",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Maximum continuous integration for multi-agent coding — every edit is committed and pushed to trunk immediately",
5
5
  "author": {
6
6
  "name": "Eli Mydlarz"
@@ -70,7 +70,10 @@ function rewindTranscript(transcriptPath, commitTimestamp, worktreePath) {
70
70
  const expandedPath = transcriptPath.replace(/^~/, process.env.HOME || "~");
71
71
  if (!existsSync(expandedPath))
72
72
  return null;
73
- const cutoff = new Date(commitTimestamp).getTime();
73
+ // Git timestamps have second precision; transcript timestamps have millisecond
74
+ // precision. Adding 999ms includes the full second of the commit so we don't
75
+ // cut off transcript entries that fall within the same second as the commit.
76
+ const cutoff = new Date(commitTimestamp).getTime() + 999;
74
77
  const lines = readFileSync(expandedPath, "utf-8").split("\n").filter(Boolean);
75
78
  // Find the last line whose timestamp is <= the commit timestamp.
76
79
  let cutIndex = -1;
@@ -113,7 +116,9 @@ function rewindTranscript(transcriptPath, commitTimestamp, worktreePath) {
113
116
  }
114
117
  function inspectOrLaunch(fileRef, inspect) {
115
118
  const { file, line } = parseFileRef(fileRef);
116
- const sha = blame(file, line);
119
+ const blameResult = blame(file, line);
120
+ const sha = blameResult.sha;
121
+ const origLine = blameResult.origLine;
117
122
  if (/^0+$/.test(sha)) {
118
123
  console.error(`Line ${line} has uncommitted changes.`);
119
124
  process.exit(1);
@@ -149,7 +154,7 @@ function inspectOrLaunch(fileRef, inspect) {
149
154
  process.exit(1);
150
155
  }
151
156
  const relFile = relative(root, resolve(file));
152
- const prompt = `*STOP*. *HALT ALL PREVIOUS OPERATIONS AND STOP IMMEDIATELY*. *DO NOT CONTINUE YOUR CURRENT CHAIN OF THOUGHT*. This session already ended. It has been resumed and rewound — including the code — so you can answer questions about why it was written this way. *DO NOT* change any code. Start by explaining ${relFile}:${line} (commit ${shortSha(sha)}) — what does it do, how does it work, and why is it written this way?`;
157
+ const prompt = `*STOP*. *HALT ALL PREVIOUS OPERATIONS AND STOP IMMEDIATELY*. *DO NOT CONTINUE YOUR CURRENT CHAIN OF THOUGHT*. This session already ended. It has been resumed and rewound — including the code — so you can answer questions about why it was written this way. *DO NOT* change any code. Start by explaining ${relFile}:${origLine} (commit ${shortSha(sha)}) — what does it do, how does it work, and why is it written this way?`;
153
158
  // Rewind the session transcript to the commit point.
154
159
  // Try snapshot from .transcripts/ in the commit first, fall back to Transcript: field.
155
160
  const snapshotRelPath = findSnapshotInCommit(sha);
package/dist/lib/git.d.ts CHANGED
@@ -3,7 +3,10 @@ export declare function parseFileRef(ref: string): {
3
3
  file: string;
4
4
  line: number;
5
5
  };
6
- export declare function blame(file: string, line: number, cwd?: string): string;
6
+ export declare function blame(file: string, line: number, cwd?: string): {
7
+ sha: string;
8
+ origLine: number;
9
+ };
7
10
  export declare function getCommitBody(sha: string, cwd?: string): string;
8
11
  export declare function getCommitSubject(sha: string, cwd?: string): string;
9
12
  export declare function getCommitDate(sha: string, cwd?: string): string;
package/dist/lib/git.js CHANGED
@@ -29,8 +29,9 @@ export function blame(file, line, cwd) {
29
29
  encoding: "utf-8",
30
30
  cwd,
31
31
  });
32
- const sha = output.split("\n")[0].split(" ")[0];
33
- return sha;
32
+ // Porcelain format first line: <sha> <orig-line> <final-line> <num-lines>
33
+ const parts = output.split("\n")[0].split(" ");
34
+ return { sha: parts[0], origLine: Number(parts[1]) };
34
35
  }
35
36
  export function getCommitBody(sha, cwd) {
36
37
  return execSync(`git log -1 --format=%b "${sha}"`, { encoding: "utf-8", cwd }).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@susu-eng/trunk-sync",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "type": "module",
5
5
  "description": "Maximum continuous integration for multi-agent coding — every edit is committed and pushed to trunk immediately",
6
6
  "bin": {