@adhdev/daemon-core 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/git/git-commands.d.ts +1 -0
- package/dist/git/git-status.d.ts +5 -0
- package/dist/git/git-types.d.ts +10 -0
- package/dist/index.js +72 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +1 -1
- package/src/git/git-commands.ts +3 -3
- package/src/git/git-status.ts +97 -6
- package/src/git/git-summary.ts +3 -0
- package/src/git/git-types.ts +11 -0
package/dist/index.mjs
CHANGED
|
@@ -5676,8 +5676,14 @@ async function getGitRepoStatus(workspace, options = {}) {
|
|
|
5676
5676
|
const includeSubmodules = options.includeSubmodules !== false;
|
|
5677
5677
|
try {
|
|
5678
5678
|
const repo = await resolveGitRepository(workspace, options);
|
|
5679
|
-
|
|
5680
|
-
|
|
5679
|
+
let parsed = await readPorcelainStatus(repo, options);
|
|
5680
|
+
let upstreamProbe = getInitialUpstreamProbe(parsed);
|
|
5681
|
+
if (options.refreshUpstream) {
|
|
5682
|
+
upstreamProbe = await refreshTrackedUpstream(repo, parsed, options);
|
|
5683
|
+
if (upstreamProbe.upstreamStatus === "fresh") {
|
|
5684
|
+
parsed = await readPorcelainStatus(repo, options);
|
|
5685
|
+
}
|
|
5686
|
+
}
|
|
5681
5687
|
const head = await readHead(repo, options);
|
|
5682
5688
|
const stashCount = await readStashCount(repo, options);
|
|
5683
5689
|
let submodules;
|
|
@@ -5692,6 +5698,9 @@ async function getGitRepoStatus(workspace, options = {}) {
|
|
|
5692
5698
|
headCommit: head.commit,
|
|
5693
5699
|
headMessage: head.message,
|
|
5694
5700
|
upstream: parsed.upstream,
|
|
5701
|
+
upstreamStatus: parsed.upstream ? upstreamProbe.upstreamStatus : "no_upstream",
|
|
5702
|
+
upstreamFetchedAt: upstreamProbe.upstreamFetchedAt,
|
|
5703
|
+
upstreamFetchError: upstreamProbe.upstreamFetchError,
|
|
5695
5704
|
ahead: parsed.ahead,
|
|
5696
5705
|
behind: parsed.behind,
|
|
5697
5706
|
staged: parsed.staged,
|
|
@@ -5716,6 +5725,60 @@ async function getGitRepoStatus(workspace, options = {}) {
|
|
|
5716
5725
|
);
|
|
5717
5726
|
}
|
|
5718
5727
|
}
|
|
5728
|
+
async function readPorcelainStatus(repo, options) {
|
|
5729
|
+
const statusOutput = await runGit(repo, ["status", "--porcelain=v2", "--branch"], options);
|
|
5730
|
+
return parsePorcelainV2Status(statusOutput.stdout);
|
|
5731
|
+
}
|
|
5732
|
+
function getInitialUpstreamProbe(parsed) {
|
|
5733
|
+
return {
|
|
5734
|
+
upstreamStatus: parsed.upstream ? "unchecked" : "no_upstream"
|
|
5735
|
+
};
|
|
5736
|
+
}
|
|
5737
|
+
async function refreshTrackedUpstream(repo, parsed, options) {
|
|
5738
|
+
if (!parsed.upstream || !parsed.branch) {
|
|
5739
|
+
return { upstreamStatus: "no_upstream" };
|
|
5740
|
+
}
|
|
5741
|
+
const remoteName = await readBranchRemote(repo, parsed.branch, options) ?? inferRemoteName(parsed.upstream);
|
|
5742
|
+
if (!remoteName) {
|
|
5743
|
+
return {
|
|
5744
|
+
upstreamStatus: "stale",
|
|
5745
|
+
upstreamFetchError: `Unable to resolve remote for upstream '${parsed.upstream}'`
|
|
5746
|
+
};
|
|
5747
|
+
}
|
|
5748
|
+
try {
|
|
5749
|
+
await runGit(repo, ["fetch", "--quiet", "--prune", "--no-tags", remoteName], options);
|
|
5750
|
+
return {
|
|
5751
|
+
upstreamStatus: "fresh",
|
|
5752
|
+
upstreamFetchedAt: Date.now()
|
|
5753
|
+
};
|
|
5754
|
+
} catch (error) {
|
|
5755
|
+
return {
|
|
5756
|
+
upstreamStatus: "stale",
|
|
5757
|
+
upstreamFetchError: formatGitError(error)
|
|
5758
|
+
};
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
async function readBranchRemote(repo, branch, options) {
|
|
5762
|
+
try {
|
|
5763
|
+
const result = await runGit(repo, ["config", "--get", `branch.${branch}.remote`], options);
|
|
5764
|
+
return result.stdout.trim() || null;
|
|
5765
|
+
} catch {
|
|
5766
|
+
return null;
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
function inferRemoteName(upstream) {
|
|
5770
|
+
const [remoteName] = upstream.split("/");
|
|
5771
|
+
return remoteName?.trim() || null;
|
|
5772
|
+
}
|
|
5773
|
+
function formatGitError(error) {
|
|
5774
|
+
if (error instanceof GitCommandError) {
|
|
5775
|
+
return error.stderr || error.message;
|
|
5776
|
+
}
|
|
5777
|
+
if (error instanceof Error) {
|
|
5778
|
+
return error.message;
|
|
5779
|
+
}
|
|
5780
|
+
return String(error);
|
|
5781
|
+
}
|
|
5719
5782
|
function parsePorcelainV2Status(output) {
|
|
5720
5783
|
const parsed = {
|
|
5721
5784
|
branch: null,
|
|
@@ -5810,6 +5873,7 @@ function emptyStatus(workspace, lastCheckedAt, error) {
|
|
|
5810
5873
|
headCommit: null,
|
|
5811
5874
|
headMessage: null,
|
|
5812
5875
|
upstream: null,
|
|
5876
|
+
upstreamStatus: "unavailable",
|
|
5813
5877
|
ahead: 0,
|
|
5814
5878
|
behind: 0,
|
|
5815
5879
|
staged: 0,
|
|
@@ -6090,6 +6154,9 @@ function createGitCompactSummary(status, diffSummary) {
|
|
|
6090
6154
|
isGitRepo: status.isGitRepo,
|
|
6091
6155
|
repoRoot: status.repoRoot,
|
|
6092
6156
|
branch: status.branch,
|
|
6157
|
+
upstreamStatus: status.upstreamStatus,
|
|
6158
|
+
upstreamFetchedAt: status.upstreamFetchedAt,
|
|
6159
|
+
upstreamFetchError: status.upstreamFetchError,
|
|
6093
6160
|
dirty: status.staged > 0 || status.modified > 0 || status.untracked > 0 || status.deleted > 0 || status.renamed > 0 || conflictCount > 0 || changedFiles > 0,
|
|
6094
6161
|
changedFiles,
|
|
6095
6162
|
ahead: status.ahead,
|
|
@@ -6434,7 +6501,7 @@ var defaultSnapshotStore = createGitSnapshotStore({
|
|
|
6434
6501
|
});
|
|
6435
6502
|
function createDefaultGitCommandServices() {
|
|
6436
6503
|
return {
|
|
6437
|
-
getStatus: ({ workspace }) => getGitRepoStatus(workspace),
|
|
6504
|
+
getStatus: ({ workspace, refreshUpstream }) => getGitRepoStatus(workspace, { refreshUpstream }),
|
|
6438
6505
|
getDiffSummary: ({ workspace }) => getGitDiffSummary(workspace),
|
|
6439
6506
|
getDiffFile: ({ workspace, path: filePath }) => getGitFileDiff(workspace, filePath),
|
|
6440
6507
|
createSnapshot: ({ workspace, reason, sessionId, turnId }) => defaultSnapshotStore.create({
|
|
@@ -6520,7 +6587,7 @@ async function handleGitCommand(command, args, services = defaultGitCommandServi
|
|
|
6520
6587
|
switch (command) {
|
|
6521
6588
|
case "git_status": {
|
|
6522
6589
|
if (!services.getStatus) return serviceNotImplemented(command);
|
|
6523
|
-
const status = await runService(() => services.getStatus({ workspace }));
|
|
6590
|
+
const status = await runService(() => services.getStatus({ workspace, refreshUpstream: optionalBoolean(args?.refreshUpstream) }));
|
|
6524
6591
|
return "success" in status ? status : { success: true, status };
|
|
6525
6592
|
}
|
|
6526
6593
|
case "git_diff_summary": {
|
|
@@ -26133,7 +26200,7 @@ ${block}`);
|
|
|
26133
26200
|
continue;
|
|
26134
26201
|
}
|
|
26135
26202
|
try {
|
|
26136
|
-
const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4 });
|
|
26203
|
+
const gitStatus = await getGitRepoStatus(node.workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
26137
26204
|
status.git = gitStatus;
|
|
26138
26205
|
if (gitStatus.isGitRepo) {
|
|
26139
26206
|
status.health = deriveMeshNodeHealthFromGit(gitStatus);
|