Merge pull request #2602 from gsd-build/refine/decouple-session-forensics-from-worktree
refactor: decouple session-forensics from auto-worktree
This commit is contained in:
commit
1961fd7651
2 changed files with 12 additions and 12 deletions
|
|
@ -38,6 +38,7 @@ import { clearActivityLogState } from "./activity-log.js";
|
|||
import {
|
||||
synthesizeCrashRecovery,
|
||||
getDeepDiagnostic,
|
||||
readActiveMilestoneId,
|
||||
} from "./session-forensics.js";
|
||||
import {
|
||||
writeLock,
|
||||
|
|
@ -980,7 +981,11 @@ function buildLoopDeps(): LoopDeps {
|
|||
startUnitSupervision,
|
||||
|
||||
// Prompt helpers
|
||||
getDeepDiagnostic,
|
||||
getDeepDiagnostic: (basePath: string) => {
|
||||
const mid = readActiveMilestoneId(basePath);
|
||||
const wtPath = mid ? getAutoWorktreePath(basePath, mid) : undefined;
|
||||
return getDeepDiagnostic(basePath, wtPath ?? undefined);
|
||||
},
|
||||
isDbAvailable,
|
||||
reorderForCaching,
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import { truncateWithEllipsis } from "../shared/format-utils.js";
|
|||
import { nativeParseJsonlTail } from "./native-parser-bridge.js";
|
||||
import { MAX_JSONL_BYTES, parseJSONL } from "./jsonl-utils.js";
|
||||
import { nativeWorkingTreeStatus, nativeDiffStat } from "./native-git-bridge.js";
|
||||
import { getAutoWorktreePath } from "./auto-worktree.js";
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
|
@ -295,17 +294,13 @@ export function synthesizeCrashRecovery(
|
|||
* Deep diagnostic from any JSONL source (activity log or session file).
|
||||
* Replaces the old shallow getLastActivityDiagnostic().
|
||||
*/
|
||||
export function getDeepDiagnostic(basePath: string): string | null {
|
||||
// Try worktree activity logs first if an auto-worktree is active
|
||||
export function getDeepDiagnostic(basePath: string, worktreePath?: string): string | null {
|
||||
// Try worktree activity logs first if a worktree path is provided
|
||||
let trace: ExecutionTrace | null = null;
|
||||
try {
|
||||
const mid = readActiveMilestoneId(basePath);
|
||||
if (mid) {
|
||||
const wtPath = getAutoWorktreePath(basePath, mid);
|
||||
if (wtPath) {
|
||||
const wtActivityDir = join(gsdRoot(wtPath), "activity");
|
||||
trace = readLastActivityLog(wtActivityDir);
|
||||
}
|
||||
if (worktreePath) {
|
||||
const wtActivityDir = join(gsdRoot(worktreePath), "activity");
|
||||
trace = readLastActivityLog(wtActivityDir);
|
||||
}
|
||||
} catch { /* non-fatal — fall through to root */ }
|
||||
|
||||
|
|
@ -323,7 +318,7 @@ export function getDeepDiagnostic(basePath: string): string | null {
|
|||
* Read the active milestone ID directly from STATE.md without async deriveState().
|
||||
* Looks for `**Active Milestone:** M001` pattern.
|
||||
*/
|
||||
function readActiveMilestoneId(basePath: string): string | null {
|
||||
export function readActiveMilestoneId(basePath: string): string | null {
|
||||
try {
|
||||
const statePath = join(gsdRoot(basePath), "STATE.md");
|
||||
if (!existsSync(statePath)) return null;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue