teamshare-bridge 0.28.23 → 0.28.25
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/bridge/doctor.js +21 -0
- package/dist/bridge/doctor.js.map +1 -1
- package/dist/bridge/wake-handler.js +11 -3
- package/dist/bridge/wake-handler.js.map +1 -1
- package/dist/cli/commands/blog.js +8 -1
- package/dist/cli/commands/blog.js.map +1 -1
- package/dist/cli/commands/build.js +22 -2
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/insight.js +8 -1
- package/dist/cli/commands/insight.js.map +1 -1
- package/dist/cli/commands/plan.js +6 -2
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/planner.js +9 -0
- package/dist/cli/commands/planner.js.map +1 -1
- package/dist/cli/commands/research.js +13 -2
- package/dist/cli/commands/research.js.map +1 -1
- package/dist/cli/commands/run.js +68 -4
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/worker.js +21 -2
- package/dist/cli/commands/worker.js.map +1 -1
- package/dist/lib/api-agents.d.ts +18 -0
- package/dist/lib/api-agents.js +21 -0
- package/dist/lib/api-agents.js.map +1 -1
- package/dist/lib/api-tasks.d.ts +26 -0
- package/dist/lib/api-tasks.js +16 -0
- package/dist/lib/api-tasks.js.map +1 -1
- package/dist/lib/api-types.d.ts +23 -0
- package/dist/lib/brief.d.ts +12 -10
- package/dist/lib/brief.js +65 -10
- package/dist/lib/brief.js.map +1 -1
- package/dist/lib/chat/board-reply.js +13 -2
- package/dist/lib/chat/board-reply.js.map +1 -1
- package/dist/lib/chat/chat-reply.d.ts +3 -1
- package/dist/lib/chat/chat-reply.js +13 -2
- package/dist/lib/chat/chat-reply.js.map +1 -1
- package/dist/lib/chat/doc-reply.js +12 -2
- package/dist/lib/chat/doc-reply.js.map +1 -1
- package/dist/lib/chat/workflow-author-reply.js +11 -2
- package/dist/lib/chat/workflow-author-reply.js.map +1 -1
- package/dist/lib/git/git-branch.d.ts +105 -1
- package/dist/lib/git/git-branch.js +163 -1
- package/dist/lib/git/git-branch.js.map +1 -1
- package/dist/lib/git/git-core.d.ts +20 -0
- package/dist/lib/git/git-core.js +58 -0
- package/dist/lib/git/git-core.js.map +1 -1
- package/dist/lib/git/git-finalize.d.ts +52 -0
- package/dist/lib/git/git-finalize.js +213 -22
- package/dist/lib/git/git-finalize.js.map +1 -1
- package/dist/lib/git/git-naming.d.ts +111 -0
- package/dist/lib/git/git-naming.js +278 -0
- package/dist/lib/git/git-naming.js.map +1 -0
- package/dist/lib/git/git-prepare.d.ts +7 -0
- package/dist/lib/git/git-prepare.js.map +1 -1
- package/dist/lib/git/index-recovery.js +18 -0
- package/dist/lib/git/index-recovery.js.map +1 -1
- package/dist/lib/harness/harness-adapter.d.ts +10 -0
- package/dist/lib/harness/harness-adapter.js.map +1 -1
- package/dist/lib/harness/spawn.js +60 -1
- package/dist/lib/harness/spawn.js.map +1 -1
- package/dist/lib/orchestrator/handlers/repair.d.ts +7 -0
- package/dist/lib/orchestrator/handlers/repair.js +2 -0
- package/dist/lib/orchestrator/handlers/repair.js.map +1 -1
- package/dist/lib/orchestrator/worktree.js +70 -18
- package/dist/lib/orchestrator/worktree.js.map +1 -1
- package/dist/lib/run-guidance.d.ts +30 -0
- package/dist/lib/run-guidance.js +129 -0
- package/dist/lib/run-guidance.js.map +1 -0
- package/dist/lib/workflow/node-executor.js +10 -0
- package/dist/lib/workflow/node-executor.js.map +1 -1
- package/dist/lib/workspace/isolation-repair.d.ts +9 -0
- package/dist/lib/workspace/isolation-repair.js +2 -0
- package/dist/lib/workspace/isolation-repair.js.map +1 -1
- package/dist/lib/workspace/mirror.d.ts +95 -0
- package/dist/lib/workspace/mirror.js +251 -8
- package/dist/lib/workspace/mirror.js.map +1 -1
- package/dist/lib/workspace/task-base.d.ts +89 -0
- package/dist/lib/workspace/task-base.js +342 -0
- package/dist/lib/workspace/task-base.js.map +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.branchForTask = branchForTask;
|
|
4
4
|
exports.desiredBranch = desiredBranch;
|
|
5
|
+
exports.currentBranchName = currentBranchName;
|
|
6
|
+
exports.nameDetachedHead = nameDetachedHead;
|
|
7
|
+
exports.attachBranchAtHead = attachBranchAtHead;
|
|
8
|
+
exports.syncBranchFrom = syncBranchFrom;
|
|
5
9
|
exports.chooseBaseRef = chooseBaseRef;
|
|
6
10
|
exports.baseBranchName = baseBranchName;
|
|
7
11
|
exports.startPointFor = startPointFor;
|
|
@@ -30,15 +34,173 @@ function branchForTask(taskId, ctx) {
|
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Branch this run should use: an explicit `branchName` (hub-assigned) when
|
|
33
|
-
* present,
|
|
37
|
+
* present, else the branch this task already DELIVERED on (`deliveryBranch`,
|
|
38
|
+
* set by the bridge after a guarded rename), else the readable
|
|
39
|
+
* `branchForTask()` derivation.
|
|
40
|
+
*
|
|
41
|
+
* The middle step is load-bearing for retries: without it a task whose delivery
|
|
42
|
+
* branch an agent named would be re-run on the derived name, which does not
|
|
43
|
+
* contain any of the previous attempt's commits - so the agent would implement
|
|
44
|
+
* the same work a second time.
|
|
34
45
|
*/
|
|
35
46
|
function desiredBranch(opts) {
|
|
36
47
|
return (opts.branchName ||
|
|
48
|
+
opts.deliveryBranch ||
|
|
37
49
|
branchForTask(opts.taskId, {
|
|
38
50
|
projectSlug: opts.projectSlug,
|
|
39
51
|
taskTitle: opts.taskTitle,
|
|
40
52
|
}));
|
|
41
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* The branch checked out in `gitRoot`, or **null when HEAD is DETACHED**.
|
|
56
|
+
*
|
|
57
|
+
* `git rev-parse --abbrev-ref HEAD` answers the LITERAL string `HEAD` when HEAD
|
|
58
|
+
* is detached — a value that looks like a branch name and is not one. Treating
|
|
59
|
+
* it as one is what produced (2026-11-18):
|
|
60
|
+
*
|
|
61
|
+
* Git: committed 2 file(s) on `HEAD` (5dfe7fc)
|
|
62
|
+
* Push failed: `error: The destination you provided is not a full refname
|
|
63
|
+
* (i.e. starting with "refs/"). ...`
|
|
64
|
+
*
|
|
65
|
+
* `git push -u origin HEAD` has to guess a destination, and `HEAD` is not a ref
|
|
66
|
+
* the remote can name. The commit is real but belongs to NO branch: it cannot
|
|
67
|
+
* be pushed, and once the (temporary) mirror is torn down nothing points at it
|
|
68
|
+
* any more. Every caller that names a branch must go through this, not through
|
|
69
|
+
* `abbrev-ref` directly.
|
|
70
|
+
*/
|
|
71
|
+
function currentBranchName(gitRoot) {
|
|
72
|
+
const out = (0, git_core_1.git)(gitRoot, ['rev-parse', '--abbrev-ref', 'HEAD']).out.trim();
|
|
73
|
+
return out && out !== 'HEAD' ? out : null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Give a commit made on a DETACHED HEAD a branch to live on (2026-11-18).
|
|
77
|
+
*
|
|
78
|
+
* Mirrors are created detached (`createWorktree(..., { detach: true })`), so
|
|
79
|
+
* "make the delivery branch" normally happens in `prepare`. When that is not
|
|
80
|
+
* possible — the common case being a mirror based on a NEWER base than the
|
|
81
|
+
* task's own branch already pushed, where `git checkout <branch>` refuses with
|
|
82
|
+
* "local changes would be overwritten" — the run used to commit on the detached
|
|
83
|
+
* HEAD and then try to push `HEAD`. Now the commit is named instead:
|
|
84
|
+
*
|
|
85
|
+
* 1. the branch does not exist -> create it AT THIS COMMIT (safe: there
|
|
86
|
+
* is no other history to lose);
|
|
87
|
+
* 2. it exists and is an ancestor -> move it forward (a fast-forward);
|
|
88
|
+
* 3. it exists with diverging history -> NEVER reset it. Publish this run's
|
|
89
|
+
* commit on `<branch>-run-<sha7>` and let the report say so: the existing
|
|
90
|
+
* branch may carry a previous attempt someone is reviewing, and silently
|
|
91
|
+
* repointing it is how work disappears.
|
|
92
|
+
*
|
|
93
|
+
* Never throws; `ok: false` means git refused (index locked) and the caller must
|
|
94
|
+
* report an unnamed commit rather than pretend it was delivered.
|
|
95
|
+
*/
|
|
96
|
+
function nameDetachedHead(gitRoot, desired, sha) {
|
|
97
|
+
const branch = (desired || '').trim();
|
|
98
|
+
if (!branch)
|
|
99
|
+
return { ok: false, detail: 'no branch name to fall back to' };
|
|
100
|
+
const exists = (0, git_core_1.git)(gitRoot, ['rev-parse', '--verify', '--quiet', branch]).ok;
|
|
101
|
+
if (!exists) {
|
|
102
|
+
const co = (0, git_core_1.git)(gitRoot, ['checkout', '-B', branch, 'HEAD'], git_core_1.GIT_SLOW_TIMEOUT_MS);
|
|
103
|
+
return co.ok
|
|
104
|
+
? { ok: true, branch, mode: 'created' }
|
|
105
|
+
: { ok: false, detail: co.out };
|
|
106
|
+
}
|
|
107
|
+
// Exists: only move it when this commit already CONTAINS its tip.
|
|
108
|
+
const contained = (0, git_core_1.git)(gitRoot, [
|
|
109
|
+
'merge-base',
|
|
110
|
+
'--is-ancestor',
|
|
111
|
+
branch,
|
|
112
|
+
'HEAD',
|
|
113
|
+
]);
|
|
114
|
+
if (contained.ok) {
|
|
115
|
+
const co = (0, git_core_1.git)(gitRoot, ['checkout', '-B', branch, 'HEAD'], git_core_1.GIT_SLOW_TIMEOUT_MS);
|
|
116
|
+
return co.ok
|
|
117
|
+
? { ok: true, branch, mode: 'advanced' }
|
|
118
|
+
: { ok: false, detail: co.out };
|
|
119
|
+
}
|
|
120
|
+
const sibling = `${branch}-run-${(sha || 'detached').slice(0, 7)}`;
|
|
121
|
+
const co = (0, git_core_1.git)(gitRoot, ['checkout', '-B', sibling, 'HEAD'], git_core_1.GIT_SLOW_TIMEOUT_MS);
|
|
122
|
+
return co.ok
|
|
123
|
+
? { ok: true, branch: sibling, mode: 'sibling' }
|
|
124
|
+
: { ok: false, detail: co.out };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Put an existing (detached) tree ON its branch, at the commit it is already on.
|
|
128
|
+
*
|
|
129
|
+
* This is what makes the whole pipeline predictable (2026-11-18): the mirror is
|
|
130
|
+
* created detached at the TASK'S OWN branch tip, and this attaches it. Because
|
|
131
|
+
* HEAD is already the branch's commit, `checkout <branch>` moves no content and
|
|
132
|
+
* `checkout -B <branch>` cannot move history — unlike `prepare`'s old
|
|
133
|
+
* `git checkout <branch>` over a tree cut from a DIFFERENT base, which git
|
|
134
|
+
* refuses ("local changes would be overwritten") and which is how runs ended up
|
|
135
|
+
* committing on a detached HEAD called `HEAD`.
|
|
136
|
+
*
|
|
137
|
+
* Returns `created: true` when the local branch did not exist and was made here
|
|
138
|
+
* (the commit only existed on `origin/<branch>`).
|
|
139
|
+
*/
|
|
140
|
+
function attachBranchAtHead(gitRoot, branch) {
|
|
141
|
+
const name = (branch || '').trim();
|
|
142
|
+
if (!name)
|
|
143
|
+
return { ok: false, out: 'no branch name', created: false, branch: '' };
|
|
144
|
+
if (currentBranchName(gitRoot) === name) {
|
|
145
|
+
return { ok: true, out: '', created: false, branch: name };
|
|
146
|
+
}
|
|
147
|
+
const exists = (0, git_core_1.git)(gitRoot, ['rev-parse', '--verify', '--quiet', name]).ok;
|
|
148
|
+
const co = exists
|
|
149
|
+
? (0, git_core_1.git)(gitRoot, ['checkout', name], git_core_1.GIT_SLOW_TIMEOUT_MS)
|
|
150
|
+
: (0, git_core_1.git)(gitRoot, ['checkout', '-B', name, 'HEAD'], git_core_1.GIT_SLOW_TIMEOUT_MS);
|
|
151
|
+
return { ok: co.ok, out: co.out, created: !exists && co.ok, branch: name };
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Bring the branch up to date with the branch it STARTED from (2026-11-18).
|
|
155
|
+
*
|
|
156
|
+
* The human's rule: "always from your own task branch, but pull to get updated
|
|
157
|
+
* state — nudge the agent to resolve any merge conflict that may have come in."
|
|
158
|
+
*
|
|
159
|
+
* So this merges the recorded base INTO the task branch. A clean merge is a
|
|
160
|
+
* fast-forward (no task commits yet) or a merge commit; a CONFLICT is
|
|
161
|
+
* deliberately left in the tree, because resolving it needs judgement the
|
|
162
|
+
* bridge must not fake. The brief then tells the agent to resolve it first.
|
|
163
|
+
*/
|
|
164
|
+
function syncBranchFrom(gitRoot, ref) {
|
|
165
|
+
const base = (ref || '').trim();
|
|
166
|
+
if (!base)
|
|
167
|
+
return { ok: true, incoming: 0, conflicts: [] };
|
|
168
|
+
if (!(0, git_core_1.git)(gitRoot, ['rev-parse', '--verify', '--quiet', `${base}^{commit}`]).ok) {
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
incoming: 0,
|
|
172
|
+
conflicts: [],
|
|
173
|
+
detail: `${base} does not resolve here`,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const ahead = (0, git_core_1.git)(gitRoot, ['rev-list', '--count', `HEAD..${base}`]);
|
|
177
|
+
const incoming = ahead.ok ? parseInt(ahead.out, 10) || 0 : 0;
|
|
178
|
+
if (incoming === 0)
|
|
179
|
+
return { ok: true, incoming: 0, conflicts: [] };
|
|
180
|
+
const merge = (0, git_core_1.git)(gitRoot, ['merge', '--no-edit', base], git_core_1.GIT_SLOW_TIMEOUT_MS);
|
|
181
|
+
if (merge.ok)
|
|
182
|
+
return { ok: true, incoming, conflicts: [] };
|
|
183
|
+
const unmerged = (0, git_core_1.git)(gitRoot, ['diff', '--name-only', '--diff-filter=U']);
|
|
184
|
+
const conflicts = unmerged.ok
|
|
185
|
+
? unmerged.out
|
|
186
|
+
.split('\n')
|
|
187
|
+
.map((l) => l.trim())
|
|
188
|
+
.filter(Boolean)
|
|
189
|
+
: [];
|
|
190
|
+
if (conflicts.length > 0) {
|
|
191
|
+
// LEFT IN PLACE on purpose: the agent resolves it (the brief says so).
|
|
192
|
+
return { ok: true, incoming, conflicts };
|
|
193
|
+
}
|
|
194
|
+
// Anything else (unrelated histories, a missing identity) must not leave a
|
|
195
|
+
// half-merged index behind a run that will not be told about it.
|
|
196
|
+
(0, git_core_1.git)(gitRoot, ['merge', '--abort'], git_core_1.GIT_TIMEOUT_MS);
|
|
197
|
+
return {
|
|
198
|
+
ok: false,
|
|
199
|
+
incoming,
|
|
200
|
+
conflicts: [],
|
|
201
|
+
detail: `merge of ${base} failed: ${merge.out.slice(0, 160)}`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
42
204
|
/**
|
|
43
205
|
* The base-branch ladder for a fresh task branch (2026-12). THE single source
|
|
44
206
|
* of truth for "where does new work start" - the mirror, `prepareRunGit` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-branch.js","sourceRoot":"","sources":["../../../src/lib/git/git-branch.ts"],"names":[],"mappings":";;AAYA,sCAcC;
|
|
1
|
+
{"version":3,"file":"git-branch.js","sourceRoot":"","sources":["../../../src/lib/git/git-branch.ts"],"names":[],"mappings":";;AAYA,sCAcC;AAaD,sCAeC;AAmBD,8CAGC;AAqCD,4CA+CC;AAgBD,gDAeC;AAwBD,wCAwCC;AAmBD,sCAaC;AAWD,wCAMC;AAmFD,sCAkBC;AArZD;;;GAGG;AACH,sCAA8C;AAC9C,yCAAsE;AACtE,iCAAwC;AAExC;;;GAGG;AACH,SAAgB,aAAa,CAC3B,MAAc,EACd,GAAkD;IAElD,IAAI,GAAG,EAAE,WAAW,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,GAAG,CAAC,WAAW;YAC7B,CAAC,CAAC,IAAA,qBAAc,EAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;YACrC,CAAC,CAAC,OAAO,CAAC;QACZ,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,qBAAc,EAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,OAAO,OAAO;YACZ,CAAC,CAAC,GAAG,OAAO,IAAI,OAAO,EAAE;YACzB,CAAC,CAAC,GAAG,OAAO,IAAI,IAAA,qBAAc,EAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;IAChD,CAAC;IACD,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AE,CAAC;AACZ,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,qBAAqB,CAC5B,OAAe,EACf,IAIC,EACD,KAAc;IAEd,MAAM,UAAU,GACd,IAAI,CAAC,cAAc,EAAE,IAAI,EAAE,IAAI,IAAA,0BAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC;IAC9E,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACpD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;IAC1B,CAAC;IACD,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IAC3B,OAAO,gBAAgB,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,OAAe,EACf,IAQC,EACD,KAAc;IAEd,IAAI,IAAI,CAAC,UAAU;QAAE,OAAO,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACzB,OAAO,qBAAqB,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -20,6 +20,26 @@ export declare function git(cwd: string, args: string[], timeoutMs?: number, opt
|
|
|
20
20
|
ok: boolean;
|
|
21
21
|
out: string;
|
|
22
22
|
};
|
|
23
|
+
/** Paths left unmerged by a conflicted merge (empty when the index is clean). */
|
|
24
|
+
export declare function unmergedPaths(cwd: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Clear git's OWN lock files when a dead process left them behind (2026-11-18).
|
|
27
|
+
*
|
|
28
|
+
* A power cut, a hard kill or a Windows shutdown during `git add`/`git commit`
|
|
29
|
+
* leaves `index.lock` in the tree. Every later command then fails with
|
|
30
|
+
* "Unable to create '…/index.lock': File exists", the run cannot commit, and the
|
|
31
|
+
* human sees a git error on every retry with nothing actually wrong on disk.
|
|
32
|
+
*
|
|
33
|
+
* ONLY for trees this process exclusively owns (an isolation mirror: it lives
|
|
34
|
+
* under `~/.teamshare/workspace`, the run holds the workspace lock, and no human
|
|
35
|
+
* works there). NEVER call it on a linked folder — a human's `git commit` can
|
|
36
|
+
* legitimately hold that lock.
|
|
37
|
+
*
|
|
38
|
+
* The age gate is the second guard: a lock younger than `minAgeMs` may belong to
|
|
39
|
+
* a live command (a backgrounded shell the agent spawned), so it is left alone
|
|
40
|
+
* and the next attempt gets a chance.
|
|
41
|
+
*/
|
|
42
|
+
export declare function clearStaleGitLocks(worktree: string, minAgeMs?: number): string[];
|
|
23
43
|
/**
|
|
24
44
|
* Stage everything for a run commit WITHOUT ever staging the transient
|
|
25
45
|
* `.teamshare-runs/` scope (workspace state, 2026-10-27). Belt-and-braces
|
package/dist/lib/git/git-core.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.GIT_SLOW_TIMEOUT_MS = exports.GIT_TIMEOUT_MS = void 0;
|
|
|
4
4
|
exports.isGitLockError = isGitLockError;
|
|
5
5
|
exports.resolveGitPolicy = resolveGitPolicy;
|
|
6
6
|
exports.git = git;
|
|
7
|
+
exports.unmergedPaths = unmergedPaths;
|
|
8
|
+
exports.clearStaleGitLocks = clearStaleGitLocks;
|
|
7
9
|
exports.gitAddAll = gitAddAll;
|
|
8
10
|
/**
|
|
9
11
|
* git-core: shared primitives for the git pipeline - the timeout-capped `git`
|
|
@@ -12,6 +14,8 @@ exports.gitAddAll = gitAddAll;
|
|
|
12
14
|
* policy (IMP-914).
|
|
13
15
|
*/
|
|
14
16
|
const node_child_process_1 = require("node:child_process");
|
|
17
|
+
const node_fs_1 = require("node:fs");
|
|
18
|
+
const node_path_1 = require("node:path");
|
|
15
19
|
const shims_1 = require("../workspace/shims");
|
|
16
20
|
exports.GIT_TIMEOUT_MS = 30_000;
|
|
17
21
|
exports.GIT_SLOW_TIMEOUT_MS = 60_000;
|
|
@@ -77,6 +81,60 @@ function git(cwd, args, timeoutMs = exports.GIT_TIMEOUT_MS, opts) {
|
|
|
77
81
|
}
|
|
78
82
|
return { ok: false, out: last };
|
|
79
83
|
}
|
|
84
|
+
/** Paths left unmerged by a conflicted merge (empty when the index is clean). */
|
|
85
|
+
function unmergedPaths(cwd) {
|
|
86
|
+
const r = git(cwd, ['diff', '--name-only', '--diff-filter=U']);
|
|
87
|
+
if (!r.ok)
|
|
88
|
+
return [];
|
|
89
|
+
return r.out
|
|
90
|
+
.split('\n')
|
|
91
|
+
.map((l) => l.trim())
|
|
92
|
+
.filter(Boolean);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Clear git's OWN lock files when a dead process left them behind (2026-11-18).
|
|
96
|
+
*
|
|
97
|
+
* A power cut, a hard kill or a Windows shutdown during `git add`/`git commit`
|
|
98
|
+
* leaves `index.lock` in the tree. Every later command then fails with
|
|
99
|
+
* "Unable to create '…/index.lock': File exists", the run cannot commit, and the
|
|
100
|
+
* human sees a git error on every retry with nothing actually wrong on disk.
|
|
101
|
+
*
|
|
102
|
+
* ONLY for trees this process exclusively owns (an isolation mirror: it lives
|
|
103
|
+
* under `~/.teamshare/workspace`, the run holds the workspace lock, and no human
|
|
104
|
+
* works there). NEVER call it on a linked folder — a human's `git commit` can
|
|
105
|
+
* legitimately hold that lock.
|
|
106
|
+
*
|
|
107
|
+
* The age gate is the second guard: a lock younger than `minAgeMs` may belong to
|
|
108
|
+
* a live command (a backgrounded shell the agent spawned), so it is left alone
|
|
109
|
+
* and the next attempt gets a chance.
|
|
110
|
+
*/
|
|
111
|
+
function clearStaleGitLocks(worktree, minAgeMs = 30_000) {
|
|
112
|
+
const dir = git(worktree, ['rev-parse', '--absolute-git-dir']);
|
|
113
|
+
if (!dir.ok || !dir.out)
|
|
114
|
+
return [];
|
|
115
|
+
const gitDir = (0, node_path_1.resolve)(dir.out.trim());
|
|
116
|
+
const cleared = [];
|
|
117
|
+
for (const name of [
|
|
118
|
+
'index.lock',
|
|
119
|
+
'HEAD.lock',
|
|
120
|
+
'config.lock',
|
|
121
|
+
'packed-refs.lock',
|
|
122
|
+
'shallow.lock',
|
|
123
|
+
]) {
|
|
124
|
+
const p = `${gitDir}/${name}`;
|
|
125
|
+
try {
|
|
126
|
+
const age = Date.now() - (0, node_fs_1.statSync)(p).mtimeMs;
|
|
127
|
+
if (age > minAgeMs) {
|
|
128
|
+
(0, node_fs_1.rmSync)(p, { force: true });
|
|
129
|
+
cleared.push(`${name} (${Math.round(age / 1000)}s old)`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
/* absent, or unreadable: nothing to do */
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return cleared;
|
|
137
|
+
}
|
|
80
138
|
/**
|
|
81
139
|
* Stage everything for a run commit WITHOUT ever staging the transient
|
|
82
140
|
* `.teamshare-runs/` scope (workspace state, 2026-10-27). Belt-and-braces
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-core.js","sourceRoot":"","sources":["../../../src/lib/git/git-core.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"git-core.js","sourceRoot":"","sources":["../../../src/lib/git/git-core.ts"],"names":[],"mappings":";;;AAmBA,wCAEC;AA2BD,4CAQC;AAED,kBAkCC;AAGD,sCAOC;AAmBD,gDA2BC;AASD,8BAWC;AAxKD;;;;;GAKG;AACH,2DAA+C;AAC/C,qCAA2C;AAC3C,yCAAoC;AACpC,8CAAqD;AAExC,QAAA,cAAc,GAAG,MAAM,CAAC;AACxB,QAAA,mBAAmB,GAAG,MAAM,CAAC;AAE1C,yFAAyF;AACzF,MAAM,WAAW,GACf,2GAA2G,CAAC;AAE9G,6EAA6E;AAC7E,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACh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AE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,4BAA4B,CAAC,EACtD,SAAS,CACV,CAAC;IACF,IAAI,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC;IAC7B,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GitLogFn, GitPolicy } from './git-core';
|
|
2
|
+
import { type GitNamingProposal } from './git-naming';
|
|
2
3
|
import type { PreparedGit } from './git-prepare';
|
|
3
4
|
export interface FinalizeRunGitOptions {
|
|
4
5
|
taskId: string;
|
|
@@ -9,6 +10,13 @@ export interface FinalizeRunGitOptions {
|
|
|
9
10
|
projectSlug?: string;
|
|
10
11
|
/** Explicit hub-assigned branch name (IMP-743); wins over branchForTask(). */
|
|
11
12
|
branchName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The branch this task already DELIVERED on (2026-12), recorded by the hub
|
|
15
|
+
* after a guarded rename. Sits below `branchName` and above the title
|
|
16
|
+
* derivation in `desiredBranch`, so a retry continues the delivered work
|
|
17
|
+
* instead of cutting a second branch from the base.
|
|
18
|
+
*/
|
|
19
|
+
deliveryBranch?: string | null;
|
|
12
20
|
/** chainMode base branch: start a FRESH branch here (existing branch wins). */
|
|
13
21
|
baseBranch?: string | null;
|
|
14
22
|
/**
|
|
@@ -31,6 +39,21 @@ export interface FinalizeRunGitOptions {
|
|
|
31
39
|
apiKey?: string | null;
|
|
32
40
|
/** Hub base URL for App-token minting (defaults to the public API). */
|
|
33
41
|
apiBaseUrl?: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Reads the agent's delivery-naming proposal (2026-12) AT FINALIZE TIME.
|
|
44
|
+
*
|
|
45
|
+
* It must be a callback and not a value: an agent proposes DURING the run, so
|
|
46
|
+
* a snapshot taken at spawn is always empty. Best-effort - a throw or an
|
|
47
|
+
* offline hub leaves `undefined` and the pipeline uses the task title, exactly
|
|
48
|
+
* as it did before the feature.
|
|
49
|
+
*/
|
|
50
|
+
loadProposal?: () => Promise<GitNamingProposal | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Best-effort report of what the naming pipeline did, so the hub can mark the
|
|
53
|
+
* proposal applied/refused and record the delivered branch (a retry reads it).
|
|
54
|
+
* Never awaited for correctness: a failed call must not fail the run.
|
|
55
|
+
*/
|
|
56
|
+
reportDelivery?: (report: GitDeliveryReport) => Promise<void>;
|
|
34
57
|
/** IMP-914 per-project git automation level (undefined = legacy flags). */
|
|
35
58
|
policy?: GitPolicy;
|
|
36
59
|
/**
|
|
@@ -60,6 +83,35 @@ export interface FinalizedGit {
|
|
|
60
83
|
changedFiles?: number;
|
|
61
84
|
/** Changed file paths (repo-relative, capped) for the run report. */
|
|
62
85
|
changedPaths?: string[];
|
|
86
|
+
/**
|
|
87
|
+
* What the pipeline did with the agent's naming proposal (2026-12).
|
|
88
|
+
* `applied` = at least one part was used; `refused` = it was read and the
|
|
89
|
+
* historical naming kept; `none` = there was no live proposal.
|
|
90
|
+
*/
|
|
91
|
+
naming?: GitNamingOutcome;
|
|
92
|
+
}
|
|
93
|
+
/** The delivery-naming result of one finalize pass (see `out.naming`). */
|
|
94
|
+
export interface GitNamingOutcome {
|
|
95
|
+
naming: 'applied' | 'refused' | 'none';
|
|
96
|
+
/** Why a proposal was not used (present when `refused`). */
|
|
97
|
+
reason?: string;
|
|
98
|
+
/** The branch the work was delivered on (only set when it was renamed). */
|
|
99
|
+
branch?: string;
|
|
100
|
+
}
|
|
101
|
+
/** What the bridge reports back to `POST /tasks/:id/git-delivery`. */
|
|
102
|
+
export interface GitDeliveryReport {
|
|
103
|
+
naming: 'applied' | 'refused' | 'none';
|
|
104
|
+
reason?: string;
|
|
105
|
+
branch?: string;
|
|
106
|
+
sha?: string;
|
|
107
|
+
prUrl?: string;
|
|
108
|
+
prNumber?: number;
|
|
109
|
+
repos?: Array<{
|
|
110
|
+
repo: string;
|
|
111
|
+
branch: string;
|
|
112
|
+
sha?: string;
|
|
113
|
+
prUrl?: string;
|
|
114
|
+
}>;
|
|
63
115
|
}
|
|
64
116
|
/**
|
|
65
117
|
* Post-run phase under an exclusive repo lock (IMP-950): commit/push while
|