@stigmer/runner 3.1.4 → 3.1.6
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/.build-fingerprint +1 -1
- package/dist/activities/execute-cursor/attachment-resolver.js +1 -1
- package/dist/activities/execute-cursor/attachment-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/index.js +40 -2
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/skill-resolver.js +1 -1
- package/dist/activities/execute-cursor/skill-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/workspace-provision.d.ts +23 -4
- package/dist/activities/execute-cursor/workspace-provision.js +17 -6
- package/dist/activities/execute-cursor/workspace-provision.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.js +39 -6
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/inline-publisher.d.ts +1 -1
- package/dist/activities/execute-deep-agent/post-stream.d.ts +1 -1
- package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +1 -1
- package/dist/activities/execute-deep-agent/streaming-terminal.d.ts +1 -1
- package/dist/activities/execute-deep-agent/streaming.d.ts +1 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.d.ts +1 -1
- package/dist/shared/execution-status-writer.d.ts +31 -0
- package/dist/shared/execution-status-writer.js +43 -0
- package/dist/shared/execution-status-writer.js.map +1 -0
- package/dist/shared/filereview/git-substrate.js +4 -0
- package/dist/shared/filereview/git-substrate.js.map +1 -1
- package/dist/shared/workspace/git-identity.d.ts +36 -0
- package/dist/shared/workspace/git-identity.js +39 -0
- package/dist/shared/workspace/git-identity.js.map +1 -0
- package/dist/shared/workspace/local-backend.d.ts +6 -2
- package/dist/shared/workspace/local-backend.js +6 -2
- package/dist/shared/workspace/local-backend.js.map +1 -1
- package/dist/shared/workspace/stigmer-link.d.ts +54 -0
- package/dist/shared/workspace/stigmer-link.js +92 -0
- package/dist/shared/workspace/stigmer-link.js.map +1 -0
- package/dist/shared/workspace/types.d.ts +6 -4
- package/dist/shared/workspace/writeback-coordinator.d.ts +120 -0
- package/dist/shared/workspace/writeback-coordinator.js +393 -0
- package/dist/shared/workspace/writeback-coordinator.js.map +1 -0
- package/package.json +2 -2
- package/src/activities/execute-cursor/__tests__/workspace-provision.test.ts +23 -15
- package/src/activities/execute-cursor/attachment-resolver.ts +1 -1
- package/src/activities/execute-cursor/index.ts +42 -2
- package/src/activities/execute-cursor/skill-resolver.ts +1 -1
- package/src/activities/execute-cursor/workspace-provision.ts +39 -7
- package/src/activities/execute-deep-agent/__tests__/post-stream.test.ts +1 -1
- package/src/activities/execute-deep-agent/index.ts +44 -6
- package/src/activities/execute-deep-agent/inline-publisher.ts +1 -1
- package/src/activities/execute-deep-agent/post-stream.ts +1 -1
- package/src/activities/execute-deep-agent/status-builder.ts +1 -1
- package/src/activities/execute-deep-agent/streaming-side-effects.ts +1 -1
- package/src/activities/execute-deep-agent/streaming-terminal.ts +1 -1
- package/src/activities/execute-deep-agent/streaming.ts +1 -1
- package/src/activities/execute-deep-agent/v3-status-builder.ts +1 -1
- package/src/shared/execution-status-writer.ts +56 -0
- package/src/shared/filereview/git-substrate.ts +4 -0
- package/src/shared/workspace/__tests__/git-identity.test.ts +124 -0
- package/src/shared/workspace/__tests__/stigmer-link.test.ts +173 -0
- package/src/shared/workspace/__tests__/writeback-coordinator.integration.test.ts +230 -0
- package/src/shared/workspace/__tests__/writeback-coordinator.test.ts +477 -0
- package/src/shared/workspace/git-identity.ts +41 -0
- package/src/shared/workspace/local-backend.ts +6 -2
- package/src/shared/workspace/stigmer-link.ts +97 -0
- package/src/shared/workspace/types.ts +6 -4
- package/src/{activities/execute-deep-agent → shared/workspace}/writeback-coordinator.ts +209 -93
- package/dist/activities/execute-cursor/stigmer-link.d.ts +0 -35
- package/dist/activities/execute-cursor/stigmer-link.js +0 -73
- package/dist/activities/execute-cursor/stigmer-link.js.map +0 -1
- package/dist/activities/execute-deep-agent/execution-status-writer.d.ts +0 -17
- package/dist/activities/execute-deep-agent/execution-status-writer.js +0 -9
- package/dist/activities/execute-deep-agent/execution-status-writer.js.map +0 -1
- package/dist/activities/execute-deep-agent/writeback-coordinator.d.ts +0 -71
- package/dist/activities/execute-deep-agent/writeback-coordinator.js +0 -295
- package/dist/activities/execute-deep-agent/writeback-coordinator.js.map +0 -1
- package/src/activities/execute-cursor/stigmer-link.ts +0 -78
- package/src/activities/execute-deep-agent/__tests__/writeback-coordinator.test.ts +0 -399
- package/src/activities/execute-deep-agent/execution-status-writer.ts +0 -19
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Incremental git write-back coordinator for workspace entries.
|
|
3
|
-
*
|
|
4
|
-
* During agent execution, each file-modifying tool call triggers an
|
|
5
|
-
* incremental commit-and-push cycle for the affected git workspace.
|
|
6
|
-
* The first cycle creates the branch and PR; subsequent cycles add
|
|
7
|
-
* commits to the same branch — the PR updates automatically on GitHub.
|
|
8
|
-
*
|
|
9
|
-
* DD-5: Incremental writeback, not batch.
|
|
10
|
-
*
|
|
11
|
-
* Lifecycle:
|
|
12
|
-
* 1. Created after workspace provisioning in index.ts.
|
|
13
|
-
* 2. `onFileModified(path)` called from streaming on each write/edit tool end.
|
|
14
|
-
* 3. `finalize()` called from post-stream as a safety net.
|
|
15
|
-
*
|
|
16
|
-
* Concurrency: one mutex per workspace entry serializes git operations.
|
|
17
|
-
*/
|
|
18
|
-
import type { WorkspaceEntry } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
|
|
19
|
-
import type { WorkspaceBackend, ProvisionResult } from "../../shared/workspace/types.js";
|
|
20
|
-
import type { ExecutionStatusWriter } from "./execution-status-writer.js";
|
|
21
|
-
export declare class WriteBackCoordinator {
|
|
22
|
-
private readonly statusWriter;
|
|
23
|
-
private readonly executionId;
|
|
24
|
-
private readonly workspaceBackend;
|
|
25
|
-
private readonly shortId;
|
|
26
|
-
private readonly branchName;
|
|
27
|
-
private readonly eligible;
|
|
28
|
-
private readonly state;
|
|
29
|
-
private readonly locks;
|
|
30
|
-
constructor(opts: {
|
|
31
|
-
statusWriter: ExecutionStatusWriter;
|
|
32
|
-
executionId: string;
|
|
33
|
-
provisionResults: readonly ProvisionResult[];
|
|
34
|
-
workspaceEntries: readonly WorkspaceEntry[];
|
|
35
|
-
workspaceBackend: WorkspaceBackend;
|
|
36
|
-
});
|
|
37
|
-
get hasEligibleEntries(): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Called after a file-modifying tool completes. Resolves the path to
|
|
40
|
-
* a workspace entry and runs an incremental commit/push cycle.
|
|
41
|
-
* Fire-and-forget: errors are logged, never thrown.
|
|
42
|
-
*/
|
|
43
|
-
onFileModified(path: string): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Post-execution safety net. Checks every eligible workspace entry
|
|
46
|
-
* for remaining uncommitted changes and commits/pushes them.
|
|
47
|
-
*/
|
|
48
|
-
finalize(): Promise<void>;
|
|
49
|
-
private initEligibleEntries;
|
|
50
|
-
private resolveEntry;
|
|
51
|
-
private incrementalWriteBack;
|
|
52
|
-
private hasChanges;
|
|
53
|
-
private createBranch;
|
|
54
|
-
private commitAndPush;
|
|
55
|
-
private createPr;
|
|
56
|
-
private updateStatus;
|
|
57
|
-
private withLock;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Extract GitHub owner and repo from a clone URL.
|
|
61
|
-
* Supports HTTPS (with or without .git) and SSH formats.
|
|
62
|
-
*/
|
|
63
|
-
export declare function parseGithubRepo(repoUrl: string): {
|
|
64
|
-
owner: string;
|
|
65
|
-
repo: string;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Extract a GitHub token from an HTTPS clone URL that has credentials embedded.
|
|
69
|
-
* Format: https://{token}@github.com/...
|
|
70
|
-
*/
|
|
71
|
-
export declare function extractGithubToken(repoUrl: string): string;
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Incremental git write-back coordinator for workspace entries.
|
|
3
|
-
*
|
|
4
|
-
* During agent execution, each file-modifying tool call triggers an
|
|
5
|
-
* incremental commit-and-push cycle for the affected git workspace.
|
|
6
|
-
* The first cycle creates the branch and PR; subsequent cycles add
|
|
7
|
-
* commits to the same branch — the PR updates automatically on GitHub.
|
|
8
|
-
*
|
|
9
|
-
* DD-5: Incremental writeback, not batch.
|
|
10
|
-
*
|
|
11
|
-
* Lifecycle:
|
|
12
|
-
* 1. Created after workspace provisioning in index.ts.
|
|
13
|
-
* 2. `onFileModified(path)` called from streaming on each write/edit tool end.
|
|
14
|
-
* 3. `finalize()` called from post-stream as a safety net.
|
|
15
|
-
*
|
|
16
|
-
* Concurrency: one mutex per workspace entry serializes git operations.
|
|
17
|
-
*/
|
|
18
|
-
import { create } from "@bufbuild/protobuf";
|
|
19
|
-
import { WorkspaceWriteBackSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/writeback_pb";
|
|
20
|
-
import { WorkspaceWriteBackPhase, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/writeback_pb";
|
|
21
|
-
import { GitWriteBackMode } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
22
|
-
import { SourceType } from "../../shared/workspace/types.js";
|
|
23
|
-
const WRITE_BACK_ENABLED_MODES = new Set([
|
|
24
|
-
GitWriteBackMode.GIT_WRITE_BACK_MODE_UNSPECIFIED,
|
|
25
|
-
GitWriteBackMode.GIT_WRITE_BACK_BRANCH_AND_PR,
|
|
26
|
-
]);
|
|
27
|
-
export class WriteBackCoordinator {
|
|
28
|
-
statusWriter;
|
|
29
|
-
executionId;
|
|
30
|
-
workspaceBackend;
|
|
31
|
-
shortId;
|
|
32
|
-
branchName;
|
|
33
|
-
eligible = new Map();
|
|
34
|
-
state = new Map();
|
|
35
|
-
locks = new Map();
|
|
36
|
-
constructor(opts) {
|
|
37
|
-
this.statusWriter = opts.statusWriter;
|
|
38
|
-
this.executionId = opts.executionId;
|
|
39
|
-
this.workspaceBackend = opts.workspaceBackend;
|
|
40
|
-
this.shortId = opts.executionId.slice(0, 8);
|
|
41
|
-
this.branchName = `stigmer/${this.shortId}`;
|
|
42
|
-
this.initEligibleEntries(opts.provisionResults, opts.workspaceEntries);
|
|
43
|
-
}
|
|
44
|
-
get hasEligibleEntries() {
|
|
45
|
-
return this.eligible.size > 0;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Called after a file-modifying tool completes. Resolves the path to
|
|
49
|
-
* a workspace entry and runs an incremental commit/push cycle.
|
|
50
|
-
* Fire-and-forget: errors are logged, never thrown.
|
|
51
|
-
*/
|
|
52
|
-
async onFileModified(path) {
|
|
53
|
-
try {
|
|
54
|
-
const entryName = this.resolveEntry(path);
|
|
55
|
-
if (!entryName)
|
|
56
|
-
return;
|
|
57
|
-
await this.withLock(entryName, () => this.incrementalWriteBack(entryName));
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
console.warn(`[WriteBack] execution=${this.executionId} — ` +
|
|
61
|
-
`onFileModified error for '${path}': ${err}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Post-execution safety net. Checks every eligible workspace entry
|
|
66
|
-
* for remaining uncommitted changes and commits/pushes them.
|
|
67
|
-
*/
|
|
68
|
-
async finalize() {
|
|
69
|
-
for (const entryName of this.eligible.keys()) {
|
|
70
|
-
try {
|
|
71
|
-
await this.withLock(entryName, () => this.incrementalWriteBack(entryName));
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
console.warn(`[WriteBack] execution=${this.executionId} entry=${entryName} — ` +
|
|
75
|
-
`finalize error: ${err}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
// ── Initialization ──────────────────────────────────────────────────
|
|
80
|
-
initEligibleEntries(provisionResults, workspaceEntries) {
|
|
81
|
-
const modeMap = new Map();
|
|
82
|
-
for (const entry of workspaceEntries) {
|
|
83
|
-
const source = entry.source;
|
|
84
|
-
if (source?.source.case === "gitRepo") {
|
|
85
|
-
modeMap.set(entry.name, source.source.value.writeBackMode);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
for (const pr of provisionResults) {
|
|
89
|
-
if (pr.sourceType !== SourceType.GIT_REPO)
|
|
90
|
-
continue;
|
|
91
|
-
if (!pr.gitMetadata)
|
|
92
|
-
continue;
|
|
93
|
-
if (!pr.gitMetadata.gitCredentialsConfigured)
|
|
94
|
-
continue;
|
|
95
|
-
const mode = modeMap.get(pr.entryName) ?? GitWriteBackMode.GIT_WRITE_BACK_MODE_UNSPECIFIED;
|
|
96
|
-
if (!WRITE_BACK_ENABLED_MODES.has(mode))
|
|
97
|
-
continue;
|
|
98
|
-
this.eligible.set(pr.entryName, {
|
|
99
|
-
provisionResult: pr,
|
|
100
|
-
baseBranch: pr.gitMetadata.branch,
|
|
101
|
-
rootDir: pr.rootDir,
|
|
102
|
-
entryName: pr.entryName,
|
|
103
|
-
});
|
|
104
|
-
this.state.set(pr.entryName, {
|
|
105
|
-
branchCreated: false,
|
|
106
|
-
prCreated: false,
|
|
107
|
-
prUrl: "",
|
|
108
|
-
prNumber: 0,
|
|
109
|
-
commitCount: 0,
|
|
110
|
-
lastCommitSha: "",
|
|
111
|
-
githubToken: "",
|
|
112
|
-
githubOwner: "",
|
|
113
|
-
githubRepo: "",
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
if (this.eligible.size > 0) {
|
|
117
|
-
console.log(`[WriteBack] execution=${this.executionId} — coordinator initialized with ` +
|
|
118
|
-
`${this.eligible.size} eligible workspace(s): ${[...this.eligible.keys()].join(", ")}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// ── Path Resolution ─────────────────────────────────────────────────
|
|
122
|
-
resolveEntry(path) {
|
|
123
|
-
if (this.eligible.size === 0)
|
|
124
|
-
return null;
|
|
125
|
-
if (this.eligible.size === 1)
|
|
126
|
-
return this.eligible.keys().next().value;
|
|
127
|
-
const normalized = path.replace(/^\/+/, "");
|
|
128
|
-
for (const entryName of this.eligible.keys()) {
|
|
129
|
-
if (normalized.startsWith(entryName + "/") || normalized === entryName) {
|
|
130
|
-
return entryName;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
// ── Core Incremental Write-Back ─────────────────────────────────────
|
|
136
|
-
async incrementalWriteBack(entryName) {
|
|
137
|
-
const entry = this.eligible.get(entryName);
|
|
138
|
-
const entryState = this.state.get(entryName);
|
|
139
|
-
const rootDir = entry.rootDir;
|
|
140
|
-
const exec = async (cmd) => {
|
|
141
|
-
return this.workspaceBackend.execute(`cd ${rootDir} && ${cmd}`);
|
|
142
|
-
};
|
|
143
|
-
let mutationStarted = false;
|
|
144
|
-
try {
|
|
145
|
-
const hasChanges = await this.hasChanges(exec);
|
|
146
|
-
if (!hasChanges)
|
|
147
|
-
return;
|
|
148
|
-
mutationStarted = true;
|
|
149
|
-
if (!entryState.branchCreated) {
|
|
150
|
-
await this.createBranch(entryName, entryState, exec);
|
|
151
|
-
}
|
|
152
|
-
const commitMsg = `agent changes (${entryState.commitCount + 1})`;
|
|
153
|
-
await this.commitAndPush(entryName, entryState, exec, commitMsg);
|
|
154
|
-
if (!entryState.prCreated) {
|
|
155
|
-
await this.createPr(entryName, entryState, entry, exec);
|
|
156
|
-
}
|
|
157
|
-
await this.updateStatus(entryName, entryState, entry, exec);
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
console.warn(`[WriteBack] execution=${this.executionId} entry=${entryName} — ` +
|
|
161
|
-
`incremental error: ${err}`);
|
|
162
|
-
if (!mutationStarted)
|
|
163
|
-
return;
|
|
164
|
-
const wb = create(WorkspaceWriteBackSchema, {
|
|
165
|
-
workspaceEntryName: entryName,
|
|
166
|
-
baseBranch: entry.baseBranch,
|
|
167
|
-
branchName: entryState.branchCreated ? this.branchName : "",
|
|
168
|
-
phase: WorkspaceWriteBackPhase.WORKSPACE_WRITE_BACK_FAILED,
|
|
169
|
-
error: String(err),
|
|
170
|
-
});
|
|
171
|
-
if (entryState.prCreated) {
|
|
172
|
-
wb.pullRequestUrl = entryState.prUrl;
|
|
173
|
-
wb.pullRequestNumber = entryState.prNumber;
|
|
174
|
-
}
|
|
175
|
-
this.statusWriter.addWriteBack(wb);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// ── Git Operations ──────────────────────────────────────────────────
|
|
179
|
-
async hasChanges(exec) {
|
|
180
|
-
const diff = await exec("git diff --stat").catch(() => "");
|
|
181
|
-
const staged = await exec("git diff --cached --stat").catch(() => "");
|
|
182
|
-
if (diff.trim() || staged.trim())
|
|
183
|
-
return true;
|
|
184
|
-
const untracked = await exec("git ls-files --others --exclude-standard").catch(() => "");
|
|
185
|
-
return untracked.trim().length > 0;
|
|
186
|
-
}
|
|
187
|
-
async createBranch(entryName, entryState, exec) {
|
|
188
|
-
await exec(`git checkout -b ${this.branchName}`);
|
|
189
|
-
entryState.branchCreated = true;
|
|
190
|
-
console.log(`[WriteBack] execution=${this.executionId} entry=${entryName} — ` +
|
|
191
|
-
`created branch ${this.branchName}`);
|
|
192
|
-
}
|
|
193
|
-
async commitAndPush(entryName, entryState, exec, commitMsg) {
|
|
194
|
-
await exec("git add -A");
|
|
195
|
-
await exec(`git commit -m "${commitMsg}"`);
|
|
196
|
-
entryState.commitCount++;
|
|
197
|
-
const shaOutput = await exec("git rev-parse HEAD");
|
|
198
|
-
entryState.lastCommitSha = shaOutput.trim();
|
|
199
|
-
if (entryState.commitCount === 1) {
|
|
200
|
-
await exec(`git push -u origin ${this.branchName}`);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
await exec("git push");
|
|
204
|
-
}
|
|
205
|
-
console.log(`[WriteBack] execution=${this.executionId} entry=${entryName} — ` +
|
|
206
|
-
`commit #${entryState.commitCount} pushed (sha=${entryState.lastCommitSha.slice(0, 12)})`);
|
|
207
|
-
}
|
|
208
|
-
async createPr(entryName, entryState, entry, _exec) {
|
|
209
|
-
const meta = entry.provisionResult.gitMetadata;
|
|
210
|
-
const { owner, repo } = parseGithubRepo(meta.repoUrl);
|
|
211
|
-
if (!entryState.githubToken) {
|
|
212
|
-
entryState.githubToken = extractGithubToken(meta.repoUrl);
|
|
213
|
-
entryState.githubOwner = owner;
|
|
214
|
-
entryState.githubRepo = repo;
|
|
215
|
-
}
|
|
216
|
-
const prTitle = `Agent changes (${this.shortId})`;
|
|
217
|
-
const prBody = `Automated pull request from Stigmer agent execution.\n\n` +
|
|
218
|
-
`**Execution:** \`${this.executionId}\`\n` +
|
|
219
|
-
`**Workspace:** \`${entryName}\`\n`;
|
|
220
|
-
const resp = await fetch(`https://api.github.com/repos/${entryState.githubOwner}/${entryState.githubRepo}/pulls`, {
|
|
221
|
-
method: "POST",
|
|
222
|
-
headers: {
|
|
223
|
-
"Authorization": `Bearer ${entryState.githubToken}`,
|
|
224
|
-
"Accept": "application/vnd.github+json",
|
|
225
|
-
"Content-Type": "application/json",
|
|
226
|
-
},
|
|
227
|
-
body: JSON.stringify({
|
|
228
|
-
title: prTitle,
|
|
229
|
-
body: prBody,
|
|
230
|
-
head: this.branchName,
|
|
231
|
-
base: entry.baseBranch,
|
|
232
|
-
}),
|
|
233
|
-
});
|
|
234
|
-
if (!resp.ok) {
|
|
235
|
-
const body = await resp.text();
|
|
236
|
-
throw new Error(`GitHub API error (HTTP ${resp.status}): ${body}`);
|
|
237
|
-
}
|
|
238
|
-
const data = await resp.json();
|
|
239
|
-
entryState.prCreated = true;
|
|
240
|
-
entryState.prUrl = data.html_url ?? "";
|
|
241
|
-
entryState.prNumber = data.number ?? 0;
|
|
242
|
-
console.log(`[WriteBack] execution=${this.executionId} entry=${entryName} — ` +
|
|
243
|
-
`PR #${entryState.prNumber} created: ${entryState.prUrl}`);
|
|
244
|
-
}
|
|
245
|
-
async updateStatus(entryName, entryState, entry, exec) {
|
|
246
|
-
const summaryOutput = await exec(`git diff --stat ${entry.baseBranch}...HEAD`).catch(() => "");
|
|
247
|
-
const phase = entryState.prCreated
|
|
248
|
-
? WorkspaceWriteBackPhase.WORKSPACE_WRITE_BACK_PR_CREATED
|
|
249
|
-
: WorkspaceWriteBackPhase.WORKSPACE_WRITE_BACK_PUSHED;
|
|
250
|
-
const wb = create(WorkspaceWriteBackSchema, {
|
|
251
|
-
workspaceEntryName: entryName,
|
|
252
|
-
branchName: this.branchName,
|
|
253
|
-
baseBranch: entry.baseBranch,
|
|
254
|
-
commitSha: entryState.lastCommitSha,
|
|
255
|
-
pullRequestUrl: entryState.prUrl,
|
|
256
|
-
pullRequestNumber: entryState.prNumber,
|
|
257
|
-
diffSummary: summaryOutput.trim(),
|
|
258
|
-
phase,
|
|
259
|
-
});
|
|
260
|
-
this.statusWriter.addWriteBack(wb);
|
|
261
|
-
}
|
|
262
|
-
// ── Concurrency ─────────────────────────────────────────────────────
|
|
263
|
-
async withLock(entryName, fn) {
|
|
264
|
-
const existing = this.locks.get(entryName) ?? Promise.resolve();
|
|
265
|
-
const next = existing.then(fn, fn);
|
|
266
|
-
this.locks.set(entryName, next);
|
|
267
|
-
await next;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
// ── Helpers ───────────────────────────────────────────────────────────
|
|
271
|
-
/**
|
|
272
|
-
* Extract GitHub owner and repo from a clone URL.
|
|
273
|
-
* Supports HTTPS (with or without .git) and SSH formats.
|
|
274
|
-
*/
|
|
275
|
-
export function parseGithubRepo(repoUrl) {
|
|
276
|
-
const httpsMatch = repoUrl.match(/github\.com[/:]([^/]+)\/([^/.]+?)(?:\.git)?$/);
|
|
277
|
-
if (httpsMatch) {
|
|
278
|
-
return { owner: httpsMatch[1], repo: httpsMatch[2] };
|
|
279
|
-
}
|
|
280
|
-
throw new Error(`Cannot parse GitHub owner/repo from URL: ${repoUrl}`);
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Extract a GitHub token from an HTTPS clone URL that has credentials embedded.
|
|
284
|
-
* Format: https://{token}@github.com/...
|
|
285
|
-
*/
|
|
286
|
-
export function extractGithubToken(repoUrl) {
|
|
287
|
-
const match = repoUrl.match(/https?:\/\/([^@]+)@github\.com/);
|
|
288
|
-
if (match)
|
|
289
|
-
return match[1];
|
|
290
|
-
const envToken = process.env.GITHUB_TOKEN;
|
|
291
|
-
if (envToken)
|
|
292
|
-
return envToken;
|
|
293
|
-
throw new Error("Cannot extract GitHub token from repo URL and GITHUB_TOKEN is not set");
|
|
294
|
-
}
|
|
295
|
-
//# sourceMappingURL=writeback-coordinator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"writeback-coordinator.js","sourceRoot":"","sources":["../../../src/activities/execute-deep-agent/writeback-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,wBAAwB,GACzB,MAAM,mEAAmE,CAAC;AAC3E,OAAO,EACL,uBAAuB,GACxB,MAAM,mEAAmE,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uDAAuD,CAAC;AAGzF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC;IACvC,gBAAgB,CAAC,+BAA+B;IAChD,gBAAgB,CAAC,4BAA4B;CAC9C,CAAC,CAAC;AAqBH,MAAM,OAAO,oBAAoB;IACd,YAAY,CAAwB;IACpC,WAAW,CAAS;IACpB,gBAAgB,CAAmB;IACnC,OAAO,CAAS;IAChB,UAAU,CAAS;IAEnB,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC5C,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IACtC,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE1D,YAAY,IAMX;QACC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAA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I,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAChC,MAAM,IAAI,CAAC;IACb,CAAC;CACF;AAED,yEAAyE;AAEzE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAC9B,8CAA8C,CAC/C,CAAC;IACF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;IAC9D,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAC1C,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;AACJ,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The workspace `.stigmer` symlink — the Cursor harness's bridge from the
|
|
3
|
-
* user's workspace to the session's platform-managed directory
|
|
4
|
-
* (~/.stigmer/sessions/{id}/platform/, see shared/workspace/platform-dir.ts).
|
|
5
|
-
*
|
|
6
|
-
* The Cursor SDK reads files from the workspace CWD, so platform-injected
|
|
7
|
-
* content (skills, attachment inputs) must be reachable there; the symlink is
|
|
8
|
-
* how, without ever writing platform files into the user's repo (issue #173).
|
|
9
|
-
* This mechanism is deliberately harness-local: the native harness routes
|
|
10
|
-
* `.stigmer/` paths through its WorkspaceBackend instead and never symlinks.
|
|
11
|
-
*
|
|
12
|
-
* Both resolvers that populate the platform dir (skills, attachments) call
|
|
13
|
-
* {@link ensureStigmerSymlink}; it is idempotent, so either may run first and
|
|
14
|
-
* an agent with only one kind of content still gets the link. The activity's
|
|
15
|
-
* cleanup calls {@link removeStigmerSymlink} so a real repo is left untouched
|
|
16
|
-
* once the turn ends; a multi-turn session recreates the link on the next turn.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { symlink, readlink, unlink, rm, lstat } from "node:fs/promises";
|
|
20
|
-
import { join } from "node:path";
|
|
21
|
-
|
|
22
|
-
/** The workspace-visible name of the platform namespace. */
|
|
23
|
-
export const STIGMER_LOCAL_STATE_DIR = ".stigmer";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Ensure the workspace `.stigmer` symlink points to the platform dir.
|
|
27
|
-
* Idempotent: an existing correct link is kept; a stale link (or a non-link
|
|
28
|
-
* left behind by an older runner) is replaced.
|
|
29
|
-
*/
|
|
30
|
-
export async function ensureStigmerSymlink(
|
|
31
|
-
workspaceDir: string,
|
|
32
|
-
platformDir: string,
|
|
33
|
-
): Promise<void> {
|
|
34
|
-
const linkPath = join(workspaceDir, STIGMER_LOCAL_STATE_DIR);
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
const existing = await readlink(linkPath);
|
|
38
|
-
if (existing === platformDir) return;
|
|
39
|
-
await unlink(linkPath);
|
|
40
|
-
} catch (err: any) {
|
|
41
|
-
if (err.code === "ENOENT") {
|
|
42
|
-
// No existing symlink
|
|
43
|
-
} else if (err.code === "EINVAL") {
|
|
44
|
-
// Exists but is not a symlink — remove the directory
|
|
45
|
-
await rm(linkPath, { recursive: true, force: true });
|
|
46
|
-
} else {
|
|
47
|
-
throw err;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
await symlink(platformDir, linkPath, "dir");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Remove the workspace `.stigmer` symlink created by
|
|
56
|
-
* {@link ensureStigmerSymlink}.
|
|
57
|
-
*
|
|
58
|
-
* Called in the activity's finally so attaching a real repo leaves no Stigmer
|
|
59
|
-
* symlink behind once the turn ends (issue #173). Only ever removes a
|
|
60
|
-
* SYMLINK — a real `.stigmer` directory (which would be the user's own, not
|
|
61
|
-
* ours) is left untouched. Best-effort.
|
|
62
|
-
*/
|
|
63
|
-
export async function removeStigmerSymlink(workspaceDir: string): Promise<void> {
|
|
64
|
-
const linkPath = join(workspaceDir, STIGMER_LOCAL_STATE_DIR);
|
|
65
|
-
try {
|
|
66
|
-
const stat = await lstat(linkPath);
|
|
67
|
-
if (stat.isSymbolicLink()) {
|
|
68
|
-
await unlink(linkPath);
|
|
69
|
-
}
|
|
70
|
-
} catch (err: any) {
|
|
71
|
-
if (err?.code !== "ENOENT") {
|
|
72
|
-
console.warn(
|
|
73
|
-
`removeStigmerSymlink: failed to remove ${linkPath} (non-fatal): ` +
|
|
74
|
-
`${err instanceof Error ? err.message : err}`,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|