@ai-development-environment/control-agent 0.0.43 → 0.0.44
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/control-agent.js +44 -15
- package/package.json +1 -1
package/dist/control-agent.js
CHANGED
|
@@ -4683,6 +4683,18 @@ async function validateGitCodebase(folder, expectedOrigin, timeoutMs, signal) {
|
|
|
4683
4683
|
}
|
|
4684
4684
|
return snapshot.folder;
|
|
4685
4685
|
}
|
|
4686
|
+
var TIP_FORMAT = "%(contents:subject)%00%(committerdate:iso-strict)";
|
|
4687
|
+
function refFields(value) {
|
|
4688
|
+
return value.split("\n").map((line) => line.trimEnd()).filter(Boolean).map((line) => line.split("\0"));
|
|
4689
|
+
}
|
|
4690
|
+
function refField(fields, index) {
|
|
4691
|
+
return fields[index]?.trim() || null;
|
|
4692
|
+
}
|
|
4693
|
+
function isoDate(value) {
|
|
4694
|
+
if (!value) return null;
|
|
4695
|
+
const parsed = new Date(value);
|
|
4696
|
+
return Number.isNaN(parsed.valueOf()) ? null : parsed.toISOString();
|
|
4697
|
+
}
|
|
4686
4698
|
function parsedRefLines(value) {
|
|
4687
4699
|
return value.split("\n").map((line) => line.trimEnd()).filter(Boolean).map((line) => {
|
|
4688
4700
|
const separator = line.indexOf("\0");
|
|
@@ -4739,7 +4751,7 @@ async function inspectCodebaseGitState(folder, timeoutMs, signal) {
|
|
|
4739
4751
|
folder,
|
|
4740
4752
|
[
|
|
4741
4753
|
"for-each-ref",
|
|
4742
|
-
|
|
4754
|
+
`--format=%(refname:strip=2)%00%(worktreepath)%00${TIP_FORMAT}`,
|
|
4743
4755
|
"refs/heads"
|
|
4744
4756
|
],
|
|
4745
4757
|
timeoutMs,
|
|
@@ -4747,7 +4759,11 @@ async function inspectCodebaseGitState(folder, timeoutMs, signal) {
|
|
|
4747
4759
|
),
|
|
4748
4760
|
git(
|
|
4749
4761
|
folder,
|
|
4750
|
-
[
|
|
4762
|
+
[
|
|
4763
|
+
"for-each-ref",
|
|
4764
|
+
`--format=%(refname:strip=3)%00${TIP_FORMAT}`,
|
|
4765
|
+
"refs/remotes/origin"
|
|
4766
|
+
],
|
|
4751
4767
|
timeoutMs,
|
|
4752
4768
|
signal
|
|
4753
4769
|
),
|
|
@@ -4758,28 +4774,41 @@ async function inspectCodebaseGitState(folder, timeoutMs, signal) {
|
|
|
4758
4774
|
requireSuccess(remoteResult, "Could not list remote branches");
|
|
4759
4775
|
const current = currentResult.exitCode === 0 ? currentResult.stdout.trim() : null;
|
|
4760
4776
|
const branches = /* @__PURE__ */ new Map();
|
|
4761
|
-
for (const
|
|
4777
|
+
for (const fields of refFields(localResult.stdout)) {
|
|
4778
|
+
const name = fields[0]?.trim();
|
|
4779
|
+
if (!name) continue;
|
|
4762
4780
|
branches.set(name, {
|
|
4763
4781
|
name,
|
|
4764
4782
|
local: true,
|
|
4765
4783
|
remote: false,
|
|
4766
4784
|
current: name === current,
|
|
4767
|
-
checkedOutPath
|
|
4785
|
+
checkedOutPath: refField(fields, 1),
|
|
4786
|
+
lastCommitMessage: refField(fields, 2),
|
|
4787
|
+
lastCommitAt: isoDate(refField(fields, 3))
|
|
4768
4788
|
});
|
|
4769
4789
|
}
|
|
4770
|
-
for (const
|
|
4790
|
+
for (const fields of refFields(remoteResult.stdout)) {
|
|
4791
|
+
const name = fields[0]?.trim();
|
|
4792
|
+
if (!name || name === "HEAD") continue;
|
|
4771
4793
|
const existing = branches.get(name);
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
current: false,
|
|
4779
|
-
checkedOutPath: null
|
|
4794
|
+
if (existing) {
|
|
4795
|
+
existing.remote = true;
|
|
4796
|
+
const remoteAt = isoDate(refField(fields, 2));
|
|
4797
|
+
if (remoteAt && (!existing.lastCommitAt || remoteAt > existing.lastCommitAt)) {
|
|
4798
|
+
existing.lastCommitMessage = refField(fields, 1);
|
|
4799
|
+
existing.lastCommitAt = remoteAt;
|
|
4780
4800
|
}
|
|
4781
|
-
|
|
4782
|
-
|
|
4801
|
+
continue;
|
|
4802
|
+
}
|
|
4803
|
+
branches.set(name, {
|
|
4804
|
+
name,
|
|
4805
|
+
local: false,
|
|
4806
|
+
remote: true,
|
|
4807
|
+
current: false,
|
|
4808
|
+
checkedOutPath: null,
|
|
4809
|
+
lastCommitMessage: refField(fields, 1),
|
|
4810
|
+
lastCommitAt: isoDate(refField(fields, 2))
|
|
4811
|
+
});
|
|
4783
4812
|
}
|
|
4784
4813
|
const sorted = [...branches.values()].sort(
|
|
4785
4814
|
(first, second) => first.name.localeCompare(second.name)
|