@northflare/runner 0.0.34 → 0.0.36
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/index.d.ts +1 -0
- package/dist/index.js +39 -27
- package/dist/index.js.map +1 -1
- package/package.json +19 -18
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7079,6 +7079,19 @@ var EnhancedRepositoryManager = class extends RepositoryManager {
|
|
|
7079
7079
|
}
|
|
7080
7080
|
}
|
|
7081
7081
|
}
|
|
7082
|
+
async isUsableTaskWorktree(worktreePath) {
|
|
7083
|
+
const gitEntryExists = await fs6.access(path7.join(worktreePath, ".git")).then(() => true).catch(() => false);
|
|
7084
|
+
if (!gitEntryExists) {
|
|
7085
|
+
return false;
|
|
7086
|
+
}
|
|
7087
|
+
try {
|
|
7088
|
+
const git = simpleGit5(worktreePath);
|
|
7089
|
+
const isWorktree = await git.raw(["rev-parse", "--is-inside-work-tree"]);
|
|
7090
|
+
return isWorktree.trim() === "true";
|
|
7091
|
+
} catch {
|
|
7092
|
+
return false;
|
|
7093
|
+
}
|
|
7094
|
+
}
|
|
7082
7095
|
/**
|
|
7083
7096
|
* Ensure control repository exists
|
|
7084
7097
|
*/
|
|
@@ -7153,33 +7166,7 @@ var EnhancedRepositoryManager = class extends RepositoryManager {
|
|
|
7153
7166
|
existing.taskState.updatedAt = /* @__PURE__ */ new Date();
|
|
7154
7167
|
await this.updateTaskStateByTaskId(taskId, existing.taskState);
|
|
7155
7168
|
}
|
|
7156
|
-
|
|
7157
|
-
await fs6.access(worktreePath);
|
|
7158
|
-
return {
|
|
7159
|
-
taskId,
|
|
7160
|
-
worktreePath,
|
|
7161
|
-
branch: existing.taskState.branch,
|
|
7162
|
-
baseBranch: existing.taskState.baseBranch
|
|
7163
|
-
};
|
|
7164
|
-
} catch {
|
|
7165
|
-
const git = simpleGit5(existing.repo.controlPath);
|
|
7166
|
-
await this.ensureDirectory(path7.dirname(worktreePath));
|
|
7167
|
-
try {
|
|
7168
|
-
await git.raw(["worktree", "add", worktreePath, existing.taskState.branch]);
|
|
7169
|
-
} catch (error) {
|
|
7170
|
-
console6.error(`Failed to recreate worktree for task ${taskId}:`, error);
|
|
7171
|
-
await this.cleanupDirectory(worktreePath);
|
|
7172
|
-
throw error;
|
|
7173
|
-
}
|
|
7174
|
-
const worktreeGit = simpleGit5(worktreePath);
|
|
7175
|
-
await worktreeGit.addConfig("user.name", "Northflare");
|
|
7176
|
-
await worktreeGit.addConfig("user.email", "runner@northflare.ai");
|
|
7177
|
-
existing.taskState.worktreePath = worktreePath;
|
|
7178
|
-
existing.taskState.workspaceId = workspaceId;
|
|
7179
|
-
existing.taskState.baseBranch = baseBranch;
|
|
7180
|
-
existing.taskState.status = "active";
|
|
7181
|
-
existing.taskState.updatedAt = /* @__PURE__ */ new Date();
|
|
7182
|
-
await this.updateTaskState(existing.repoKey, existing.taskState);
|
|
7169
|
+
if (await this.isUsableTaskWorktree(worktreePath)) {
|
|
7183
7170
|
return {
|
|
7184
7171
|
taskId,
|
|
7185
7172
|
worktreePath,
|
|
@@ -7187,6 +7174,31 @@ var EnhancedRepositoryManager = class extends RepositoryManager {
|
|
|
7187
7174
|
baseBranch: existing.taskState.baseBranch
|
|
7188
7175
|
};
|
|
7189
7176
|
}
|
|
7177
|
+
const git = simpleGit5(existing.repo.controlPath);
|
|
7178
|
+
await this.cleanupDirectory(worktreePath);
|
|
7179
|
+
await this.ensureDirectory(path7.dirname(worktreePath));
|
|
7180
|
+
try {
|
|
7181
|
+
await git.raw(["worktree", "add", worktreePath, existing.taskState.branch]);
|
|
7182
|
+
} catch (error) {
|
|
7183
|
+
console6.error(`Failed to recreate worktree for task ${taskId}:`, error);
|
|
7184
|
+
await this.cleanupDirectory(worktreePath);
|
|
7185
|
+
throw error;
|
|
7186
|
+
}
|
|
7187
|
+
const worktreeGit = simpleGit5(worktreePath);
|
|
7188
|
+
await worktreeGit.addConfig("user.name", "Northflare");
|
|
7189
|
+
await worktreeGit.addConfig("user.email", "runner@northflare.ai");
|
|
7190
|
+
existing.taskState.worktreePath = worktreePath;
|
|
7191
|
+
existing.taskState.workspaceId = workspaceId;
|
|
7192
|
+
existing.taskState.baseBranch = baseBranch;
|
|
7193
|
+
existing.taskState.status = "active";
|
|
7194
|
+
existing.taskState.updatedAt = /* @__PURE__ */ new Date();
|
|
7195
|
+
await this.updateTaskState(existing.repoKey, existing.taskState);
|
|
7196
|
+
return {
|
|
7197
|
+
taskId,
|
|
7198
|
+
worktreePath,
|
|
7199
|
+
branch: existing.taskState.branch,
|
|
7200
|
+
baseBranch: existing.taskState.baseBranch
|
|
7201
|
+
};
|
|
7190
7202
|
}
|
|
7191
7203
|
const isLocalRepo = repoUrl.startsWith("file://");
|
|
7192
7204
|
let controlPath;
|