@ouro.bot/cli 0.1.0-alpha.95 → 0.1.0-alpha.96
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/changelog.json +6 -0
- package/dist/heart/safe-workspace.js +32 -13
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.96",
|
|
6
|
+
"changes": [
|
|
7
|
+
"ensureSafeRepoWorkspace now re-reads the live branch from the worktree on every call and updates the in-memory and persisted selection when it has drifted, preventing stale workspaceBranch after external branch switches between coding sessions."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
4
10
|
{
|
|
5
11
|
"version": "0.1.0-alpha.95",
|
|
6
12
|
"changes": [
|
|
@@ -207,40 +207,59 @@ function resetSafeWorkspaceSelection(options = {}) {
|
|
|
207
207
|
function getActiveSafeWorkspaceSelection() {
|
|
208
208
|
return activeSelection;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
211
|
-
|
|
212
|
-
|
|
210
|
+
function refreshSelectionWorkspaceBranch(selection, spawnSync) {
|
|
211
|
+
try {
|
|
212
|
+
if (!isGitClone(selection.workspaceRoot, spawnSync)) {
|
|
213
|
+
return selection;
|
|
214
|
+
}
|
|
215
|
+
const liveBranch = readCurrentBranch(selection.workspaceRoot, spawnSync);
|
|
216
|
+
if (liveBranch === selection.workspaceBranch) {
|
|
217
|
+
return selection;
|
|
218
|
+
}
|
|
219
|
+
return { ...selection, workspaceBranch: liveBranch };
|
|
213
220
|
}
|
|
214
|
-
|
|
221
|
+
catch {
|
|
222
|
+
return selection;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function ensureSafeRepoWorkspace(options = {}) {
|
|
215
226
|
const agentName = resolveAgentName(options.agentName);
|
|
216
|
-
const canonicalRepoUrl = options.canonicalRepoUrl ?? identity_1.HARNESS_CANONICAL_REPO_URL;
|
|
217
227
|
const workspaceBase = options.workspaceRoot ?? (0, identity_1.getAgentRepoWorkspacesRoot)(agentName);
|
|
218
228
|
const persistSelection = shouldPersistSelection(options);
|
|
219
229
|
const spawnSync = options.spawnSync ?? child_process_1.spawnSync;
|
|
220
230
|
const existsSync = options.existsSync ?? fs.existsSync;
|
|
221
231
|
const mkdirSync = options.mkdirSync ?? fs.mkdirSync;
|
|
222
232
|
const rmSync = options.rmSync ?? fs.rmSync;
|
|
233
|
+
if (activeSelection) {
|
|
234
|
+
const refreshed = refreshSelectionWorkspaceBranch(activeSelection, spawnSync);
|
|
235
|
+
activeSelection = refreshed;
|
|
236
|
+
return refreshed;
|
|
237
|
+
}
|
|
238
|
+
const repoRoot = options.repoRoot ?? (0, identity_1.getRepoRoot)();
|
|
239
|
+
const canonicalRepoUrl = options.canonicalRepoUrl ?? identity_1.HARNESS_CANONICAL_REPO_URL;
|
|
223
240
|
const now = options.now ?? defaultNow;
|
|
224
241
|
const stamp = String(now());
|
|
225
242
|
registerCleanupHook({ rmSync });
|
|
226
243
|
if (persistSelection) {
|
|
227
244
|
const restored = loadPersistedSelection(workspaceBase, options);
|
|
228
245
|
if (restored) {
|
|
229
|
-
|
|
246
|
+
const refreshed = refreshSelectionWorkspaceBranch(restored, spawnSync);
|
|
247
|
+
activeSelection = refreshed;
|
|
248
|
+
persistSelectionState(workspaceBase, refreshed, options);
|
|
230
249
|
(0, runtime_1.emitNervesEvent)({
|
|
231
250
|
component: "workspace",
|
|
232
251
|
event: "workspace.safe_repo_restored",
|
|
233
252
|
message: "restored safe repo workspace after runtime restart",
|
|
234
253
|
meta: {
|
|
235
|
-
runtimeKind:
|
|
236
|
-
repoRoot:
|
|
237
|
-
workspaceRoot:
|
|
238
|
-
workspaceBranch:
|
|
239
|
-
sourceBranch:
|
|
240
|
-
cleanupAfterMerge:
|
|
254
|
+
runtimeKind: refreshed.runtimeKind,
|
|
255
|
+
repoRoot: refreshed.repoRoot,
|
|
256
|
+
workspaceRoot: refreshed.workspaceRoot,
|
|
257
|
+
workspaceBranch: refreshed.workspaceBranch,
|
|
258
|
+
sourceBranch: refreshed.sourceBranch,
|
|
259
|
+
cleanupAfterMerge: refreshed.cleanupAfterMerge,
|
|
241
260
|
},
|
|
242
261
|
});
|
|
243
|
-
return
|
|
262
|
+
return refreshed;
|
|
244
263
|
}
|
|
245
264
|
}
|
|
246
265
|
let selection;
|