@adhdev/daemon-standalone 0.9.82-rc.8 → 0.9.82-rc.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/index.js CHANGED
@@ -28062,8 +28062,14 @@ ${lastSnapshot}`;
28062
28062
  const includeSubmodules = options.includeSubmodules !== false;
28063
28063
  try {
28064
28064
  const repo = await resolveGitRepository(workspace, options);
28065
- const statusOutput = await runGit(repo, ["status", "--porcelain=v2", "--branch"], options);
28066
- const parsed = parsePorcelainV2Status(statusOutput.stdout);
28065
+ let parsed = await readPorcelainStatus(repo, options);
28066
+ let upstreamProbe = getInitialUpstreamProbe(parsed);
28067
+ if (options.refreshUpstream) {
28068
+ upstreamProbe = await refreshTrackedUpstream(repo, parsed, options);
28069
+ if (upstreamProbe.upstreamStatus === "fresh") {
28070
+ parsed = await readPorcelainStatus(repo, options);
28071
+ }
28072
+ }
28067
28073
  const head = await readHead(repo, options);
28068
28074
  const stashCount = await readStashCount(repo, options);
28069
28075
  let submodules;
@@ -28078,6 +28084,9 @@ ${lastSnapshot}`;
28078
28084
  headCommit: head.commit,
28079
28085
  headMessage: head.message,
28080
28086
  upstream: parsed.upstream,
28087
+ upstreamStatus: parsed.upstream ? upstreamProbe.upstreamStatus : "no_upstream",
28088
+ upstreamFetchedAt: upstreamProbe.upstreamFetchedAt,
28089
+ upstreamFetchError: upstreamProbe.upstreamFetchError,
28081
28090
  ahead: parsed.ahead,
28082
28091
  behind: parsed.behind,
28083
28092
  staged: parsed.staged,
@@ -28102,6 +28111,60 @@ ${lastSnapshot}`;
28102
28111
  );
28103
28112
  }
28104
28113
  }
28114
+ async function readPorcelainStatus(repo, options) {
28115
+ const statusOutput = await runGit(repo, ["status", "--porcelain=v2", "--branch"], options);
28116
+ return parsePorcelainV2Status(statusOutput.stdout);
28117
+ }
28118
+ function getInitialUpstreamProbe(parsed) {
28119
+ return {
28120
+ upstreamStatus: parsed.upstream ? "unchecked" : "no_upstream"
28121
+ };
28122
+ }
28123
+ async function refreshTrackedUpstream(repo, parsed, options) {
28124
+ if (!parsed.upstream || !parsed.branch) {
28125
+ return { upstreamStatus: "no_upstream" };
28126
+ }
28127
+ const remoteName = await readBranchRemote(repo, parsed.branch, options) ?? inferRemoteName(parsed.upstream);
28128
+ if (!remoteName) {
28129
+ return {
28130
+ upstreamStatus: "stale",
28131
+ upstreamFetchError: `Unable to resolve remote for upstream '${parsed.upstream}'`
28132
+ };
28133
+ }
28134
+ try {
28135
+ await runGit(repo, ["fetch", "--quiet", "--prune", "--no-tags", remoteName], options);
28136
+ return {
28137
+ upstreamStatus: "fresh",
28138
+ upstreamFetchedAt: Date.now()
28139
+ };
28140
+ } catch (error48) {
28141
+ return {
28142
+ upstreamStatus: "stale",
28143
+ upstreamFetchError: formatGitError(error48)
28144
+ };
28145
+ }
28146
+ }
28147
+ async function readBranchRemote(repo, branch, options) {
28148
+ try {
28149
+ const result = await runGit(repo, ["config", "--get", `branch.${branch}.remote`], options);
28150
+ return result.stdout.trim() || null;
28151
+ } catch {
28152
+ return null;
28153
+ }
28154
+ }
28155
+ function inferRemoteName(upstream) {
28156
+ const [remoteName] = upstream.split("/");
28157
+ return remoteName?.trim() || null;
28158
+ }
28159
+ function formatGitError(error48) {
28160
+ if (error48 instanceof GitCommandError) {
28161
+ return error48.stderr || error48.message;
28162
+ }
28163
+ if (error48 instanceof Error) {
28164
+ return error48.message;
28165
+ }
28166
+ return String(error48);
28167
+ }
28105
28168
  function parsePorcelainV2Status(output) {
28106
28169
  const parsed = {
28107
28170
  branch: null,
@@ -28196,6 +28259,7 @@ ${lastSnapshot}`;
28196
28259
  headCommit: null,
28197
28260
  headMessage: null,
28198
28261
  upstream: null,
28262
+ upstreamStatus: "unavailable",
28199
28263
  ahead: 0,
28200
28264
  behind: 0,
28201
28265
  staged: 0,
@@ -28472,6 +28536,9 @@ ${lastSnapshot}`;
28472
28536
  isGitRepo: status.isGitRepo,
28473
28537
  repoRoot: status.repoRoot,
28474
28538
  branch: status.branch,
28539
+ upstreamStatus: status.upstreamStatus,
28540
+ upstreamFetchedAt: status.upstreamFetchedAt,
28541
+ upstreamFetchError: status.upstreamFetchError,
28475
28542
  dirty: status.staged > 0 || status.modified > 0 || status.untracked > 0 || status.deleted > 0 || status.renamed > 0 || conflictCount > 0 || changedFiles > 0,
28476
28543
  changedFiles,
28477
28544
  ahead: status.ahead,
@@ -28810,7 +28877,7 @@ ${lastSnapshot}`;
28810
28877
  });
28811
28878
  function createDefaultGitCommandServices() {
28812
28879
  return {
28813
- getStatus: ({ workspace }) => getGitRepoStatus(workspace),
28880
+ getStatus: ({ workspace, refreshUpstream }) => getGitRepoStatus(workspace, { refreshUpstream }),
28814
28881
  getDiffSummary: ({ workspace }) => getGitDiffSummary(workspace),
28815
28882
  getDiffFile: ({ workspace, path: filePath }) => getGitFileDiff(workspace, filePath),
28816
28883
  createSnapshot: ({ workspace, reason, sessionId, turnId }) => defaultSnapshotStore.create({
@@ -28896,7 +28963,7 @@ ${lastSnapshot}`;
28896
28963
  switch (command) {
28897
28964
  case "git_status": {
28898
28965
  if (!services.getStatus) return serviceNotImplemented(command);
28899
- const status = await runService(() => services.getStatus({ workspace }));
28966
+ const status = await runService(() => services.getStatus({ workspace, refreshUpstream: optionalBoolean(args?.refreshUpstream) }));
28900
28967
  return "success" in status ? status : { success: true, status };
28901
28968
  }
28902
28969
  case "git_diff_summary": {
@@ -48342,7 +48409,7 @@ ${block}`);
48342
48409
  continue;
48343
48410
  }
48344
48411
  try {
48345
- const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4 });
48412
+ const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4, refreshUpstream: true });
48346
48413
  status.git = gitStatus;
48347
48414
  if (gitStatus.isGitRepo) {
48348
48415
  status.health = deriveMeshNodeHealthFromGit(gitStatus);