@adhdev/daemon-core 0.9.82-rc.265 → 0.9.82-rc.266

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.
@@ -5,87 +5,8 @@
5
5
  * transports, and web-core. Git state is daemon-owned product truth; do not
6
6
  * infer these values from agent transcripts in frontend code.
7
7
  */
8
- export type GitFailureReason = 'not_git_repo' | 'git_not_installed' | 'timeout' | 'path_outside_repo' | 'dirty_index_required' | 'conflict' | 'invalid_args' | 'nothing_to_commit' | 'git_command_failed';
9
- export interface GitRepoIdentity {
10
- workspace: string;
11
- repoRoot: string | null;
12
- isGitRepo: boolean;
13
- }
14
- export interface GitSubmoduleStatus {
15
- /** Submodule path relative to repo root */
16
- path: string;
17
- /** Current commit SHA the submodule is at */
18
- commit: string;
19
- /** Path to the submodule repo (absolute) */
20
- repoPath: string;
21
- /** Whether the submodule has uncommitted changes */
22
- dirty: boolean;
23
- /** Whether the submodule commit differs from what the parent repo expects */
24
- outOfSync: boolean;
25
- /** Last checked timestamp */
26
- lastCheckedAt: number;
27
- /** Error message if submodule status could not be read */
28
- error?: string;
29
- }
30
- export type GitUpstreamFreshness = 'fresh' | 'unchecked' | 'stale' | 'no_upstream' | 'unavailable';
31
- export interface GitRepoStatus extends GitRepoIdentity {
32
- branch: string | null;
33
- headCommit: string | null;
34
- headMessage: string | null;
35
- upstream: string | null;
36
- /** Whether ahead/behind was verified against a freshly fetched upstream ref. */
37
- upstreamStatus: GitUpstreamFreshness;
38
- /** Timestamp for the fetch that refreshed upstream refs when upstreamStatus === 'fresh'. */
39
- upstreamFetchedAt?: number;
40
- /** Error from the last refresh attempt when upstreamStatus === 'stale'. */
41
- upstreamFetchError?: string;
42
- ahead: number;
43
- behind: number;
44
- staged: number;
45
- modified: number;
46
- untracked: number;
47
- deleted: number;
48
- renamed: number;
49
- /** Aggregate dirty flag including root worktree changes, conflicts, stash, and submodule drift. */
50
- dirty: boolean;
51
- hasConflicts: boolean;
52
- conflictFiles: string[];
53
- stashCount: number;
54
- lastCheckedAt: number;
55
- /** Submodule statuses when auto-discover is enabled */
56
- submodules?: GitSubmoduleStatus[];
57
- /**
58
- * Set when the running daemon's build commit is a STRICT ancestor of this
59
- * repo's HEAD (or a submodule HEAD) — i.e. the live daemon predates committed
60
- * code in this workspace and is awaiting a deploy/restart to catch up.
61
- * Omitted entirely when no staleness is provable (unknown build, commit not
62
- * present in repo, or build commit == HEAD) to avoid over-warning.
63
- */
64
- daemonBuildBehind?: DaemonBuildBehind;
65
- error?: string;
66
- reason?: GitFailureReason;
67
- }
68
- export interface DaemonBuildBehind {
69
- /** Full build commit baked into the running daemon. */
70
- buildCommit: string;
71
- /** Short build commit. */
72
- buildCommitShort: string;
73
- /** HEAD commit the build commit is behind (repo or submodule). */
74
- head: string;
75
- /** Where the comparison matched: 'root' or the submodule path. */
76
- scope: string;
77
- /**
78
- * Whether any package changed between buildCommit..HEAD affects the daemon
79
- * runtime (daemon-core, standalone, session-host, terminal-mux, ghostty,
80
- * mcp-server). When false, only web/render packages changed — the daemon does
81
- * NOT need a rebuild/restart; only the web deploy is pending. Conservative:
82
- * when the changed-package set can't be determined it defaults to true.
83
- */
84
- isDaemonAffecting: boolean;
85
- /** Distinct package names changed between buildCommit..HEAD (best-effort). */
86
- affectedPackages?: string[];
87
- warning: string;
88
- }
8
+ export type { GitFailureReason, GitRepoIdentity, GitSubmoduleStatus, GitUpstreamFreshness, GitRepoStatus, DaemonBuildBehind, } from '@adhdev/mesh-shared';
9
+ import type { GitRepoIdentity, GitRepoStatus, GitFailureReason, GitUpstreamFreshness } from '@adhdev/mesh-shared';
89
10
  export type GitFileChangeStatus = 'added' | 'modified' | 'deleted' | 'renamed' | 'copied' | 'untracked' | 'conflict';
90
11
  export interface GitFileChange {
91
12
  path: string;
package/dist/index.js CHANGED
@@ -265,10 +265,10 @@ function readInjected(value) {
265
265
  }
266
266
  function getDaemonBuildInfo() {
267
267
  if (cached) return cached;
268
- const commit = readInjected(true ? "b062e0b564f44876b742641cc25ad182a3e088b3" : void 0) ?? "unknown";
269
- const commitShort = readInjected(true ? "b062e0b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
270
- const version = readInjected(true ? "0.9.82-rc.265" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
271
- const builtAt = readInjected(true ? "2026-06-14T16:39:31.621Z" : void 0);
268
+ const commit = readInjected(true ? "bf805cc2b4d63e722d2e330fa10a9890db3b4668" : void 0) ?? "unknown";
269
+ const commitShort = readInjected(true ? "bf805cc" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
270
+ const version = readInjected(true ? "0.9.82-rc.266" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
271
+ const builtAt = readInjected(true ? "2026-06-14T19:47:36.114Z" : void 0);
272
272
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
273
273
  return cached;
274
274
  }
@@ -39090,6 +39090,207 @@ function getAvailableIdeIds() {
39090
39090
  init_config();
39091
39091
  init_cli_detector();
39092
39092
  init_git_status();
39093
+
39094
+ // ../mesh-shared/dist/index.mjs
39095
+ function readRecord5(value) {
39096
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
39097
+ }
39098
+ function readString6(...values) {
39099
+ for (const value of values) {
39100
+ if (typeof value !== "string") continue;
39101
+ const trimmed = value.trim();
39102
+ if (trimmed) return trimmed;
39103
+ }
39104
+ return void 0;
39105
+ }
39106
+ function readNumber(...values) {
39107
+ for (const value of values) {
39108
+ if (typeof value === "number" && Number.isFinite(value)) return value;
39109
+ }
39110
+ return void 0;
39111
+ }
39112
+ function readBoolean(...values) {
39113
+ for (const value of values) {
39114
+ if (typeof value === "boolean") return value;
39115
+ }
39116
+ return void 0;
39117
+ }
39118
+ function joinRepoPath(root, relativePath) {
39119
+ const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
39120
+ const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
39121
+ if (!normalizedPath) return void 0;
39122
+ if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
39123
+ if (!normalizedRoot) return void 0;
39124
+ return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
39125
+ }
39126
+ function scoreGitUpstreamFreshness(status) {
39127
+ switch (status) {
39128
+ case "fresh":
39129
+ return 30;
39130
+ case "no_upstream":
39131
+ return 4;
39132
+ case "unchecked":
39133
+ case void 0:
39134
+ return 0;
39135
+ case "stale":
39136
+ return -10;
39137
+ case "unavailable":
39138
+ return -15;
39139
+ default:
39140
+ return 0;
39141
+ }
39142
+ }
39143
+ function readGitSubmodules(value, parentRepoRoot) {
39144
+ if (!Array.isArray(value)) return void 0;
39145
+ const submodules = value.map((entry) => {
39146
+ const submodule = readRecord5(entry);
39147
+ const path39 = readString6(submodule.path);
39148
+ const commit = readString6(submodule.commit);
39149
+ const repoPath = readString6(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path39);
39150
+ if (!path39 || !commit) return null;
39151
+ const result = {
39152
+ path: path39,
39153
+ commit,
39154
+ dirty: readBoolean(submodule.dirty) ?? false,
39155
+ outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
39156
+ lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
39157
+ };
39158
+ if (repoPath) result.repoPath = repoPath;
39159
+ const error = readString6(submodule.error);
39160
+ if (error) result.error = error;
39161
+ return result;
39162
+ }).filter((entry) => entry !== null);
39163
+ return submodules.length > 0 ? submodules : void 0;
39164
+ }
39165
+ function hasGitStatusEvidence(status) {
39166
+ return readBoolean(status.isGitRepo) !== void 0 || Boolean(readString6(status.branch, status.upstream, status.upstreamStatus, status.upstream_status, status.headCommit)) || Boolean(readString6(status.repoRoot, status.repo_root, status.workspace)) || readNumber(
39167
+ status.ahead,
39168
+ status.behind,
39169
+ status.staged,
39170
+ status.modified,
39171
+ status.untracked,
39172
+ status.deleted,
39173
+ status.renamed,
39174
+ status.lastCheckedAt,
39175
+ status.last_checked_at
39176
+ ) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
39177
+ }
39178
+ function normalizeGitStatus(status, node, options) {
39179
+ const explicitIsGitRepo = readBoolean(status.isGitRepo);
39180
+ if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
39181
+ const isGitRepo = explicitIsGitRepo ?? true;
39182
+ const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
39183
+ const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
39184
+ const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
39185
+ const repoRoot = readString6(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
39186
+ const submodules = readGitSubmodules(status.submodules, repoRoot);
39187
+ const upstreamStatus = readString6(status.upstreamStatus, status.upstream_status);
39188
+ const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
39189
+ const upstreamFetchError = readString6(status.upstreamFetchError, status.upstream_fetch_error);
39190
+ const error = readString6(status.error);
39191
+ const staged = readNumber(status.staged) ?? 0;
39192
+ const modified = readNumber(status.modified) ?? 0;
39193
+ const untracked = readNumber(status.untracked) ?? 0;
39194
+ const deleted = readNumber(status.deleted) ?? 0;
39195
+ const renamed = readNumber(status.renamed) ?? 0;
39196
+ return {
39197
+ workspace: readString6(status.workspace, node.workspace) || "",
39198
+ repoRoot: repoRoot ?? null,
39199
+ isGitRepo,
39200
+ branch: readString6(status.branch) ?? null,
39201
+ headCommit: readString6(status.headCommit) ?? null,
39202
+ headMessage: readString6(status.headMessage) ?? null,
39203
+ upstream: readString6(status.upstream) ?? null,
39204
+ upstreamStatus: upstreamStatus ?? "unchecked",
39205
+ ...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
39206
+ ...upstreamFetchError ? { upstreamFetchError } : {},
39207
+ ahead: readNumber(status.ahead) ?? 0,
39208
+ behind: readNumber(status.behind) ?? 0,
39209
+ staged,
39210
+ modified,
39211
+ untracked,
39212
+ deleted,
39213
+ renamed,
39214
+ dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
39215
+ hasConflicts,
39216
+ conflictFiles,
39217
+ stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
39218
+ lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
39219
+ ...submodules ? { submodules } : {},
39220
+ ...error ? { error } : {}
39221
+ };
39222
+ }
39223
+ function scoreGitStatusCandidate(git) {
39224
+ if (!git) return Number.NEGATIVE_INFINITY;
39225
+ let score = 0;
39226
+ if (git.isGitRepo === true) score += 50;
39227
+ if (git.isGitRepo === false) score -= 10;
39228
+ if (git.branch) score += 20;
39229
+ if (git.headCommit) score += 20;
39230
+ if (git.upstream) score += 10;
39231
+ score += scoreGitUpstreamFreshness(git.upstreamStatus);
39232
+ if (typeof git.ahead === "number") score += 2;
39233
+ if (typeof git.behind === "number") score += 2;
39234
+ if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
39235
+ if (git.error) score -= 20;
39236
+ return score;
39237
+ }
39238
+ function pickBestTransitGitStatus(node, options) {
39239
+ const rawGit = readRecord5(node.lastGit ?? node.last_git);
39240
+ const gitResult = readRecord5(rawGit.result);
39241
+ const directStatus = readRecord5(rawGit.status);
39242
+ const nestedStatus = readRecord5(gitResult.status);
39243
+ const rawProbe = readRecord5(node.lastProbe ?? node.last_probe);
39244
+ const probeGit = readRecord5(rawProbe.git);
39245
+ const probeGitResult = readRecord5(probeGit.result);
39246
+ const probeDirectStatus = readRecord5(probeGit.status);
39247
+ const probeNestedStatus = readRecord5(probeGitResult.status);
39248
+ const lastCheckedAt = options?.lastCheckedAt;
39249
+ let best = null;
39250
+ for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
39251
+ const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
39252
+ if (!normalized) continue;
39253
+ const score = scoreGitStatusCandidate(normalized);
39254
+ if (!best || score > best.score) best = { git: normalized, score };
39255
+ }
39256
+ return best?.git;
39257
+ }
39258
+ function summarizeGitShape(status) {
39259
+ const record = readRecord5(status);
39260
+ if (!Object.keys(record).length) return null;
39261
+ const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
39262
+ const sub = readRecord5(entry);
39263
+ return {
39264
+ path: readString6(sub.path) ?? null,
39265
+ commit: readString6(sub.commit)?.slice(0, 12) ?? null,
39266
+ dirty: readBoolean(sub.dirty) ?? false,
39267
+ outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
39268
+ };
39269
+ }) : [];
39270
+ return {
39271
+ isGitRepo: readBoolean(record.isGitRepo),
39272
+ workspace: readString6(record.workspace) ?? null,
39273
+ repoRoot: readString6(record.repoRoot, record.repo_root) ?? null,
39274
+ branch: readString6(record.branch) ?? null,
39275
+ upstream: readString6(record.upstream) ?? null,
39276
+ upstreamStatus: readString6(record.upstreamStatus, record.upstream_status) ?? null,
39277
+ headCommit: readString6(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
39278
+ ahead: readNumber(record.ahead) ?? null,
39279
+ behind: readNumber(record.behind) ?? null,
39280
+ dirtyCounts: {
39281
+ staged: readNumber(record.staged) ?? 0,
39282
+ modified: readNumber(record.modified) ?? 0,
39283
+ untracked: readNumber(record.untracked) ?? 0,
39284
+ deleted: readNumber(record.deleted) ?? 0,
39285
+ renamed: readNumber(record.renamed) ?? 0
39286
+ },
39287
+ lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
39288
+ submoduleCount: submodules.length,
39289
+ submodules
39290
+ };
39291
+ }
39292
+
39293
+ // src/commands/router.ts
39093
39294
  init_logger();
39094
39295
 
39095
39296
  // src/logging/command-log.ts
@@ -39349,7 +39550,7 @@ function runGit2(repoRoot, args) {
39349
39550
  return "";
39350
39551
  }
39351
39552
  }
39352
- function readRecord5(repoRoot) {
39553
+ function readRecord6(repoRoot) {
39353
39554
  const path39 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
39354
39555
  if (!(0, import_node_fs4.existsSync)(path39)) return null;
39355
39556
  try {
@@ -39389,7 +39590,7 @@ function readCurrentMainCommit(repoRoot) {
39389
39590
  }
39390
39591
  function buildPreviewFreshness(repoRoot) {
39391
39592
  const current = readCurrentMainCommit(repoRoot);
39392
- const record = readRecord5(repoRoot);
39593
+ const record = readRecord6(repoRoot);
39393
39594
  const lastPreviewCommit = normalizeCommit(record?.lastPreviewCommit);
39394
39595
  const targets = readTargetFreshness(record, current.currentMainCommit);
39395
39596
  let status = "unknown";
@@ -40158,37 +40359,6 @@ function readBooleanValue(...values) {
40158
40359
  }
40159
40360
  return void 0;
40160
40361
  }
40161
- function summarizeRepoMeshDebugGit(git) {
40162
- const record = readObjectRecord(git);
40163
- if (!Object.keys(record).length) return null;
40164
- const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => ({
40165
- path: readStringValue(entry?.path) ?? null,
40166
- commit: readStringValue(entry?.commit)?.slice(0, 12) ?? null,
40167
- dirty: readBooleanValue(entry?.dirty) ?? false,
40168
- outOfSync: readBooleanValue(entry?.outOfSync, entry?.out_of_sync) ?? false
40169
- })) : [];
40170
- return {
40171
- isGitRepo: readBooleanValue(record.isGitRepo),
40172
- workspace: readStringValue(record.workspace) ?? null,
40173
- repoRoot: readStringValue(record.repoRoot, record.repo_root) ?? null,
40174
- branch: readStringValue(record.branch) ?? null,
40175
- upstream: readStringValue(record.upstream) ?? null,
40176
- upstreamStatus: readStringValue(record.upstreamStatus, record.upstream_status) ?? null,
40177
- headCommit: readStringValue(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
40178
- ahead: readNumberValue(record.ahead) ?? null,
40179
- behind: readNumberValue(record.behind) ?? null,
40180
- dirtyCounts: {
40181
- staged: readNumberValue(record.staged) ?? 0,
40182
- modified: readNumberValue(record.modified) ?? 0,
40183
- untracked: readNumberValue(record.untracked) ?? 0,
40184
- deleted: readNumberValue(record.deleted) ?? 0,
40185
- renamed: readNumberValue(record.renamed) ?? 0
40186
- },
40187
- lastCheckedAt: readNumberValue(record.lastCheckedAt, record.last_checked_at) ?? null,
40188
- submoduleCount: submodules.length,
40189
- submodules
40190
- };
40191
- }
40192
40362
  function summarizeRepoMeshStatusDebug(status) {
40193
40363
  const nodes = Array.isArray(status?.nodes) ? status.nodes : [];
40194
40364
  return {
@@ -40212,7 +40382,7 @@ function summarizeRepoMeshStatusDebug(status) {
40212
40382
  } : null,
40213
40383
  gitProbePending: node?.gitProbePending === true,
40214
40384
  launchReady: node?.launchReady === true,
40215
- git: summarizeRepoMeshDebugGit(node?.git),
40385
+ git: summarizeGitShape(node?.git),
40216
40386
  branchConvergence: node?.branchConvergence ?? node?.branch_convergence ?? null
40217
40387
  }))
40218
40388
  };
@@ -40224,34 +40394,6 @@ function logRepoMeshStatusDebug(event, fields) {
40224
40394
  LOG.info("MeshStatusDebug", `[RepoMeshStatusDebug] ${event}`);
40225
40395
  }
40226
40396
  }
40227
- function joinRepoPath(root, relativePath) {
40228
- const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
40229
- const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
40230
- if (!normalizedPath) return void 0;
40231
- if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
40232
- if (!normalizedRoot) return void 0;
40233
- return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
40234
- }
40235
- function readGitSubmodules(value, parentRepoRoot) {
40236
- if (!Array.isArray(value)) return void 0;
40237
- const submodules = value.map((entry) => {
40238
- const submodule = readObjectRecord(entry);
40239
- const path39 = readStringValue(submodule.path);
40240
- const commit = readStringValue(submodule.commit);
40241
- const repoPath = readStringValue(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path39);
40242
- if (!path39 || !commit || !repoPath) return null;
40243
- return {
40244
- path: path39,
40245
- commit,
40246
- repoPath,
40247
- dirty: readBooleanValue(submodule.dirty) ?? false,
40248
- outOfSync: readBooleanValue(submodule.outOfSync, submodule.out_of_sync) ?? false,
40249
- lastCheckedAt: readNumberValue(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now(),
40250
- ...readStringValue(submodule.error) ? { error: readStringValue(submodule.error) } : {}
40251
- };
40252
- }).filter((entry) => entry !== null);
40253
- return submodules.length > 0 ? submodules : void 0;
40254
- }
40255
40397
  function buildMeshNodeDisplayLabel(node, nodeId, providerPriority) {
40256
40398
  const explicit = readStringValue(node.machineLabel, node.machine_label, node.machineNickname, node.machine_nickname, node.alias);
40257
40399
  if (explicit) return explicit;
@@ -40366,72 +40508,10 @@ function buildMeshNodeMachineIdentity(node, opts) {
40366
40508
  };
40367
40509
  }
40368
40510
  function normalizeInlineMeshGitStatus(status, node, options) {
40369
- const isGitRepo = readBooleanValue(status.isGitRepo);
40370
- if (!Object.keys(status).length || isGitRepo === void 0) return void 0;
40371
- const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((value) => typeof value === "string") : [];
40372
- const conflictCount = readNumberValue(status.conflicts) ?? conflictFiles.length;
40373
- const hasConflicts = readBooleanValue(status.hasConflicts) ?? conflictCount > 0;
40374
- const repoRoot = readStringValue(status.repoRoot, status.repo_root, node?.repoRoot, node?.repo_root, status.workspace, node?.workspace) || void 0;
40375
- const submodules = readGitSubmodules(status.submodules, repoRoot);
40376
- return {
40377
- workspace: readStringValue(status.workspace, node?.workspace) || "",
40378
- repoRoot: repoRoot ?? null,
40379
- isGitRepo,
40380
- branch: readStringValue(status.branch) ?? null,
40381
- headCommit: readStringValue(status.headCommit) ?? null,
40382
- headMessage: readStringValue(status.headMessage) ?? null,
40383
- upstream: readStringValue(status.upstream) ?? null,
40384
- upstreamStatus: readStringValue(status.upstreamStatus, status.upstream_status) ?? (readStringValue(status.upstream) ? "unchecked" : "no_upstream"),
40385
- upstreamFetchedAt: readNumberValue(status.upstreamFetchedAt, status.upstream_fetched_at),
40386
- upstreamFetchError: readStringValue(status.upstreamFetchError, status.upstream_fetch_error),
40387
- ahead: readNumberValue(status.ahead) ?? 0,
40388
- behind: readNumberValue(status.behind) ?? 0,
40389
- staged: readNumberValue(status.staged) ?? 0,
40390
- modified: readNumberValue(status.modified) ?? 0,
40391
- untracked: readNumberValue(status.untracked) ?? 0,
40392
- deleted: readNumberValue(status.deleted) ?? 0,
40393
- renamed: readNumberValue(status.renamed) ?? 0,
40394
- hasConflicts,
40395
- conflictFiles,
40396
- stashCount: readNumberValue(status.stashCount) ?? 0,
40397
- lastCheckedAt: options?.lastCheckedAt ?? readNumberValue(status.lastCheckedAt) ?? Date.now(),
40398
- ...submodules ? { submodules } : {}
40399
- };
40400
- }
40401
- function scoreInlineMeshGitStatus(git) {
40402
- if (!git) return Number.NEGATIVE_INFINITY;
40403
- let score = 0;
40404
- if (readBooleanValue(git.isGitRepo) === true) score += 50;
40405
- if (readBooleanValue(git.isGitRepo) === false) score -= 10;
40406
- if (readStringValue(git.branch)) score += 20;
40407
- if (readStringValue(git.headCommit)) score += 20;
40408
- if (readStringValue(git.upstream)) score += 10;
40409
- if (readStringValue(git.upstreamStatus)) score += 5;
40410
- if (readNumberValue(git.ahead) !== void 0) score += 2;
40411
- if (readNumberValue(git.behind) !== void 0) score += 2;
40412
- if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
40413
- if (readStringValue(git.error)) score -= 20;
40414
- return score;
40511
+ return normalizeGitStatus(status, readObjectRecord(node), options);
40415
40512
  }
40416
40513
  function buildInlineMeshTransitGitStatus(node) {
40417
- const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
40418
- const gitResult = readObjectRecord(rawGit.result);
40419
- const directStatus = readObjectRecord(rawGit.status);
40420
- const nestedStatus = readObjectRecord(gitResult.status);
40421
- const rawProbe = readObjectRecord(node?.lastProbe ?? node?.last_probe);
40422
- const probeGit = readObjectRecord(rawProbe.git);
40423
- const probeGitResult = readObjectRecord(probeGit.result);
40424
- const probeDirectStatus = readObjectRecord(probeGit.status);
40425
- const probeNestedStatus = readObjectRecord(probeGitResult.status);
40426
- const candidates = [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus];
40427
- let best = null;
40428
- for (const status of candidates) {
40429
- const normalized = normalizeInlineMeshGitStatus(status, node, { lastCheckedAt: Date.now() });
40430
- if (!normalized) continue;
40431
- const score = scoreInlineMeshGitStatus(normalized);
40432
- if (!best || score > best.score) best = { git: normalized, score };
40433
- }
40434
- return best?.git;
40514
+ return pickBestTransitGitStatus(readObjectRecord(node), { lastCheckedAt: Date.now() });
40435
40515
  }
40436
40516
  function shouldRefreshStalePendingAggregate(snapshot, options) {
40437
40517
  if (options?.requireDirectPeerTruth !== true || !Array.isArray(snapshot?.nodes)) return false;