@episoda/cli 0.2.158 → 0.2.159
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/daemon/daemon-process.js +168 -63
- package/dist/daemon/daemon-process.js.map +1 -1
- package/dist/index.js +179 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1653,10 +1653,6 @@ var require_git_executor = __commonJS({
|
|
|
1653
1653
|
};
|
|
1654
1654
|
} catch {
|
|
1655
1655
|
}
|
|
1656
|
-
try {
|
|
1657
|
-
await this.runGitCommand(["fetch", "--all", "--prune"], cwd, options);
|
|
1658
|
-
} catch {
|
|
1659
|
-
}
|
|
1660
1656
|
const args = ["worktree", "add"];
|
|
1661
1657
|
if (command.detach) {
|
|
1662
1658
|
args.push("--detach", command.path);
|
|
@@ -2913,7 +2909,7 @@ var require_package = __commonJS({
|
|
|
2913
2909
|
"package.json"(exports2, module2) {
|
|
2914
2910
|
module2.exports = {
|
|
2915
2911
|
name: "@episoda/cli",
|
|
2916
|
-
version: "0.2.
|
|
2912
|
+
version: "0.2.159",
|
|
2917
2913
|
description: "CLI tool for Episoda local development workflow orchestration",
|
|
2918
2914
|
main: "dist/index.js",
|
|
2919
2915
|
types: "dist/index.d.ts",
|
|
@@ -8159,6 +8155,7 @@ var AgentCommandQueue = class {
|
|
|
8159
8155
|
// src/daemon/worktree-manager.ts
|
|
8160
8156
|
var fs11 = __toESM(require("fs"));
|
|
8161
8157
|
var path12 = __toESM(require("path"));
|
|
8158
|
+
var import_child_process11 = require("child_process");
|
|
8162
8159
|
var import_core10 = __toESM(require_dist());
|
|
8163
8160
|
function validateModuleUid(moduleUid) {
|
|
8164
8161
|
if (!moduleUid || typeof moduleUid !== "string" || !moduleUid.trim()) {
|
|
@@ -8175,6 +8172,38 @@ function validateModuleUid(moduleUid) {
|
|
|
8175
8172
|
}
|
|
8176
8173
|
return true;
|
|
8177
8174
|
}
|
|
8175
|
+
function isValidDefaultBranchName(name) {
|
|
8176
|
+
if (!name || typeof name !== "string") return false;
|
|
8177
|
+
const trimmed = name.trim();
|
|
8178
|
+
if (trimmed !== name) return false;
|
|
8179
|
+
if (name.length > 255) return false;
|
|
8180
|
+
if (name.startsWith("-")) return false;
|
|
8181
|
+
if (name.startsWith("/")) return false;
|
|
8182
|
+
if (name.endsWith("/")) return false;
|
|
8183
|
+
if (name.endsWith(".")) return false;
|
|
8184
|
+
if (name.endsWith(".lock")) return false;
|
|
8185
|
+
if (name.includes("..")) return false;
|
|
8186
|
+
if (name.includes("@{")) return false;
|
|
8187
|
+
if (name.includes("//")) return false;
|
|
8188
|
+
if (name.includes("\\")) return false;
|
|
8189
|
+
if (/[ ~^:?*\[\]\s]/.test(name)) return false;
|
|
8190
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(name)) return false;
|
|
8191
|
+
return true;
|
|
8192
|
+
}
|
|
8193
|
+
function runGit(args, cwd, timeoutMs) {
|
|
8194
|
+
const res = (0, import_child_process11.spawnSync)("git", args, {
|
|
8195
|
+
cwd,
|
|
8196
|
+
encoding: "utf-8",
|
|
8197
|
+
timeout: timeoutMs,
|
|
8198
|
+
windowsHide: true,
|
|
8199
|
+
shell: false
|
|
8200
|
+
});
|
|
8201
|
+
return {
|
|
8202
|
+
success: res.status === 0,
|
|
8203
|
+
stdout: (res.stdout || "").toString(),
|
|
8204
|
+
stderr: (res.stderr || "").toString()
|
|
8205
|
+
};
|
|
8206
|
+
}
|
|
8178
8207
|
var WorktreeManager = class _WorktreeManager {
|
|
8179
8208
|
constructor(projectRoot) {
|
|
8180
8209
|
// ============================================================
|
|
@@ -8232,22 +8261,24 @@ var WorktreeManager = class _WorktreeManager {
|
|
|
8232
8261
|
*/
|
|
8233
8262
|
async ensureFetchRefspecConfigured() {
|
|
8234
8263
|
try {
|
|
8235
|
-
const { execSync: execSync10 } = require("child_process");
|
|
8236
8264
|
let fetchRefspec = null;
|
|
8237
8265
|
try {
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
}).trim();
|
|
8266
|
+
const res = runGit(["config", "--get", "remote.origin.fetch"], this.bareRepoPath, 5e3);
|
|
8267
|
+
if (res.success) {
|
|
8268
|
+
fetchRefspec = res.stdout.trim();
|
|
8269
|
+
}
|
|
8243
8270
|
} catch {
|
|
8244
8271
|
}
|
|
8245
8272
|
if (!fetchRefspec) {
|
|
8246
8273
|
console.log("[WorktreeManager] EP1014: Configuring missing fetch refspec for bare repo");
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8274
|
+
const setRes = runGit(
|
|
8275
|
+
["config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"],
|
|
8276
|
+
this.bareRepoPath,
|
|
8277
|
+
5e3
|
|
8278
|
+
);
|
|
8279
|
+
if (!setRes.success) {
|
|
8280
|
+
throw new Error(setRes.stderr || "Failed to configure fetch refspec");
|
|
8281
|
+
}
|
|
8251
8282
|
console.log("[WorktreeManager] EP1014: Fetch refspec configured successfully");
|
|
8252
8283
|
}
|
|
8253
8284
|
} catch (error) {
|
|
@@ -8280,11 +8311,44 @@ var WorktreeManager = class _WorktreeManager {
|
|
|
8280
8311
|
manager.writeConfig(config);
|
|
8281
8312
|
return manager;
|
|
8282
8313
|
}
|
|
8314
|
+
/**
|
|
8315
|
+
* EP1373: Resolve the default branch name using a 3-level fallback:
|
|
8316
|
+
* 1. Explicit defaultBranch parameter (from project GitHub config)
|
|
8317
|
+
* 2. Git-derived: refs/remotes/origin/HEAD symbolic-ref target
|
|
8318
|
+
* 3. Final fallback: 'main' (with warning)
|
|
8319
|
+
*/
|
|
8320
|
+
async resolveDefaultBranch(explicitDefault) {
|
|
8321
|
+
if (explicitDefault) {
|
|
8322
|
+
if (isValidDefaultBranchName(explicitDefault)) {
|
|
8323
|
+
return explicitDefault;
|
|
8324
|
+
}
|
|
8325
|
+
console.warn(`[WorktreeManager] EP1373: Invalid defaultBranch provided ("${explicitDefault}"), ignoring`);
|
|
8326
|
+
}
|
|
8327
|
+
try {
|
|
8328
|
+
const res = runGit(["symbolic-ref", "refs/remotes/origin/HEAD"], this.bareRepoPath, 5e3);
|
|
8329
|
+
if (!res.success) {
|
|
8330
|
+
throw new Error(res.stderr || "symbolic-ref failed");
|
|
8331
|
+
}
|
|
8332
|
+
const symref = res.stdout.trim();
|
|
8333
|
+
const match = symref.match(/^refs\/remotes\/origin\/(.+)$/);
|
|
8334
|
+
if (match && match[1]) {
|
|
8335
|
+
const derived = match[1];
|
|
8336
|
+
if (isValidDefaultBranchName(derived)) {
|
|
8337
|
+
return derived;
|
|
8338
|
+
}
|
|
8339
|
+
console.warn(`[WorktreeManager] EP1373: Derived default branch from origin/HEAD is invalid ("${derived}"), ignoring`);
|
|
8340
|
+
}
|
|
8341
|
+
} catch {
|
|
8342
|
+
}
|
|
8343
|
+
console.warn('[WorktreeManager] EP1373: Could not resolve default branch, falling back to "main"');
|
|
8344
|
+
return "main";
|
|
8345
|
+
}
|
|
8283
8346
|
/**
|
|
8284
8347
|
* Create a worktree for a module
|
|
8285
8348
|
* The entire operation is locked to prevent race conditions
|
|
8349
|
+
* EP1373: Added defaultBranch parameter for explicit default branch resolution
|
|
8286
8350
|
*/
|
|
8287
|
-
async createWorktree(moduleUid, branchName, createBranch = false) {
|
|
8351
|
+
async createWorktree(moduleUid, branchName, createBranch = false, defaultBranch, correlationId) {
|
|
8288
8352
|
if (!validateModuleUid(moduleUid)) {
|
|
8289
8353
|
return {
|
|
8290
8354
|
success: false,
|
|
@@ -8350,25 +8414,63 @@ var WorktreeManager = class _WorktreeManager {
|
|
|
8350
8414
|
console.warn("[WorktreeManager] EP1265: Failed to prune worktrees (continuing):", pruneResult.output);
|
|
8351
8415
|
}
|
|
8352
8416
|
}
|
|
8353
|
-
const
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
};
|
|
8417
|
+
const resolvedDefault = await this.resolveDefaultBranch(defaultBranch);
|
|
8418
|
+
let shouldCreateBranch = createBranch;
|
|
8419
|
+
let startPoint;
|
|
8420
|
+
if (createBranch) {
|
|
8421
|
+
const managerFetchStartMs = Date.now();
|
|
8422
|
+
const fetchResult = await this.gitExecutor.execute({
|
|
8423
|
+
action: "fetch",
|
|
8424
|
+
remote: "origin",
|
|
8425
|
+
branch: `+refs/heads/${resolvedDefault}:refs/remotes/origin/${resolvedDefault}`
|
|
8426
|
+
}, { cwd: this.bareRepoPath });
|
|
8427
|
+
console.log(`[WorktreeManager] EP1373: manager_fetch phase=manager_fetch durationMs=${Date.now() - managerFetchStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} defaultBranch=${resolvedDefault} success=${fetchResult.success}`);
|
|
8428
|
+
if (!fetchResult.success) {
|
|
8429
|
+
console.error("[worktree-manager] Failed to fetch from origin:", fetchResult.output);
|
|
8430
|
+
return {
|
|
8431
|
+
success: false,
|
|
8432
|
+
error: "Failed to fetch latest refs from origin. Cannot create worktree with stale refs."
|
|
8433
|
+
};
|
|
8434
|
+
}
|
|
8435
|
+
startPoint = `origin/${resolvedDefault}`;
|
|
8436
|
+
} else {
|
|
8437
|
+
const existingBranchFetchStartMs = Date.now();
|
|
8438
|
+
const branchFetchResult = await this.gitExecutor.execute({
|
|
8439
|
+
action: "fetch",
|
|
8440
|
+
remote: "origin",
|
|
8441
|
+
branch: `+refs/heads/${branchName}:refs/remotes/origin/${branchName}`
|
|
8442
|
+
}, { cwd: this.bareRepoPath });
|
|
8443
|
+
console.log(`[WorktreeManager] EP1373: existing_branch_fetch phase=existing_branch_fetch durationMs=${Date.now() - existingBranchFetchStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} branch=${branchName} success=${branchFetchResult.success}`);
|
|
8444
|
+
const localBranchExists = runGit(
|
|
8445
|
+
["show-ref", "--verify", `refs/heads/${branchName}`],
|
|
8446
|
+
this.bareRepoPath,
|
|
8447
|
+
5e3
|
|
8448
|
+
).success;
|
|
8449
|
+
const remoteBranchExists = runGit(
|
|
8450
|
+
["show-ref", "--verify", `refs/remotes/origin/${branchName}`],
|
|
8451
|
+
this.bareRepoPath,
|
|
8452
|
+
5e3
|
|
8453
|
+
).success;
|
|
8454
|
+
if (!localBranchExists && remoteBranchExists) {
|
|
8455
|
+
shouldCreateBranch = true;
|
|
8456
|
+
startPoint = `origin/${branchName}`;
|
|
8457
|
+
console.log(`[WorktreeManager] EP1373: remote_only_branch phase=remote_only_branch moduleUid=${moduleUid} correlationId=${correlationId || "none"} branch=${branchName}`);
|
|
8458
|
+
} else if (!localBranchExists && !remoteBranchExists) {
|
|
8459
|
+
return {
|
|
8460
|
+
success: false,
|
|
8461
|
+
error: `Branch "${branchName}" not found locally or on origin`
|
|
8462
|
+
};
|
|
8463
|
+
}
|
|
8364
8464
|
}
|
|
8465
|
+
const gitWorktreeAddStartMs = Date.now();
|
|
8365
8466
|
const result = await this.gitExecutor.execute({
|
|
8366
8467
|
action: "worktree_add",
|
|
8367
8468
|
path: worktreePath,
|
|
8368
8469
|
branch: branchName,
|
|
8369
|
-
create:
|
|
8370
|
-
startPoint
|
|
8470
|
+
create: shouldCreateBranch,
|
|
8471
|
+
startPoint
|
|
8371
8472
|
}, { cwd: this.bareRepoPath });
|
|
8473
|
+
console.log(`[WorktreeManager] EP1373: git_worktree_add phase=git_worktree_add durationMs=${Date.now() - gitWorktreeAddStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} success=${result.success}`);
|
|
8372
8474
|
if (!result.success) {
|
|
8373
8475
|
return {
|
|
8374
8476
|
success: false,
|
|
@@ -10009,7 +10111,7 @@ async function handleFileMkdir(command, projectPath) {
|
|
|
10009
10111
|
}
|
|
10010
10112
|
|
|
10011
10113
|
// src/daemon/handlers/exec-handler.ts
|
|
10012
|
-
var
|
|
10114
|
+
var import_child_process12 = require("child_process");
|
|
10013
10115
|
var DEFAULT_TIMEOUT = 3e4;
|
|
10014
10116
|
var MAX_TIMEOUT = 3e5;
|
|
10015
10117
|
async function handleExec(command, projectPath) {
|
|
@@ -10031,7 +10133,7 @@ async function handleExec(command, projectPath) {
|
|
|
10031
10133
|
resolve4(result);
|
|
10032
10134
|
};
|
|
10033
10135
|
try {
|
|
10034
|
-
const proc = (0,
|
|
10136
|
+
const proc = (0, import_child_process12.spawn)(cmd, {
|
|
10035
10137
|
shell: true,
|
|
10036
10138
|
cwd,
|
|
10037
10139
|
env: { ...process.env, ...env },
|
|
@@ -10095,7 +10197,7 @@ async function handleExec(command, projectPath) {
|
|
|
10095
10197
|
var path23 = __toESM(require("path"));
|
|
10096
10198
|
var fs22 = __toESM(require("fs"));
|
|
10097
10199
|
var os10 = __toESM(require("os"));
|
|
10098
|
-
var
|
|
10200
|
+
var import_child_process15 = require("child_process");
|
|
10099
10201
|
var import_util2 = require("util");
|
|
10100
10202
|
|
|
10101
10203
|
// src/preview/types.ts
|
|
@@ -10122,7 +10224,7 @@ var import_events3 = require("events");
|
|
|
10122
10224
|
var import_fs = require("fs");
|
|
10123
10225
|
|
|
10124
10226
|
// src/preview/dev-server-runner.ts
|
|
10125
|
-
var
|
|
10227
|
+
var import_child_process14 = require("child_process");
|
|
10126
10228
|
var http = __toESM(require("http"));
|
|
10127
10229
|
var fs20 = __toESM(require("fs"));
|
|
10128
10230
|
var path21 = __toESM(require("path"));
|
|
@@ -10260,7 +10362,7 @@ No cached values available as fallback.`
|
|
|
10260
10362
|
var fs19 = __toESM(require("fs"));
|
|
10261
10363
|
var path20 = __toESM(require("path"));
|
|
10262
10364
|
var os9 = __toESM(require("os"));
|
|
10263
|
-
var
|
|
10365
|
+
var import_child_process13 = require("child_process");
|
|
10264
10366
|
var DEV_SERVER_REGISTRY_DIR = path20.join(os9.homedir(), ".episoda", "dev-servers");
|
|
10265
10367
|
var DevServerRegistry = class {
|
|
10266
10368
|
constructor() {
|
|
@@ -10415,7 +10517,7 @@ var DevServerRegistry = class {
|
|
|
10415
10517
|
*/
|
|
10416
10518
|
getProcessCwd(pid) {
|
|
10417
10519
|
try {
|
|
10418
|
-
const output = (0,
|
|
10520
|
+
const output = (0, import_child_process13.execSync)(`lsof -p ${pid} -Fn | grep ^n | grep cwd | head -1`, {
|
|
10419
10521
|
encoding: "utf8",
|
|
10420
10522
|
timeout: 5e3
|
|
10421
10523
|
}).trim();
|
|
@@ -10440,7 +10542,7 @@ var DevServerRegistry = class {
|
|
|
10440
10542
|
findProcessesInWorktree(worktreePath) {
|
|
10441
10543
|
const pids = [];
|
|
10442
10544
|
try {
|
|
10443
|
-
const output = (0,
|
|
10545
|
+
const output = (0, import_child_process13.execSync)(
|
|
10444
10546
|
`lsof -c node -c next | grep "${worktreePath}" | awk '{print $2}' | sort -u`,
|
|
10445
10547
|
{ encoding: "utf8", timeout: 5e3 }
|
|
10446
10548
|
).trim();
|
|
@@ -10501,7 +10603,7 @@ var DevServerRegistry = class {
|
|
|
10501
10603
|
*/
|
|
10502
10604
|
findProcessesOnPort(port) {
|
|
10503
10605
|
try {
|
|
10504
|
-
const output = (0,
|
|
10606
|
+
const output = (0, import_child_process13.execSync)(`lsof -ti:${port} 2>/dev/null || true`, { encoding: "utf8" }).trim();
|
|
10505
10607
|
if (!output) {
|
|
10506
10608
|
return [];
|
|
10507
10609
|
}
|
|
@@ -10755,7 +10857,7 @@ var DevServerRunner = class extends import_events2.EventEmitter {
|
|
|
10755
10857
|
*/
|
|
10756
10858
|
async killProcessOnPort(port) {
|
|
10757
10859
|
try {
|
|
10758
|
-
const result = (0,
|
|
10860
|
+
const result = (0, import_child_process14.execSync)(`lsof -ti:${port} 2>/dev/null || true`, { encoding: "utf8" }).trim();
|
|
10759
10861
|
if (!result) {
|
|
10760
10862
|
return true;
|
|
10761
10863
|
}
|
|
@@ -10763,15 +10865,15 @@ var DevServerRunner = class extends import_events2.EventEmitter {
|
|
|
10763
10865
|
console.log(`[DevServerRunner] Found ${pids.length} process(es) on port ${port}`);
|
|
10764
10866
|
for (const pid of pids) {
|
|
10765
10867
|
try {
|
|
10766
|
-
(0,
|
|
10868
|
+
(0, import_child_process14.execSync)(`kill -15 ${pid} 2>/dev/null || true`);
|
|
10767
10869
|
} catch {
|
|
10768
10870
|
}
|
|
10769
10871
|
}
|
|
10770
10872
|
await this.wait(1e3);
|
|
10771
10873
|
for (const pid of pids) {
|
|
10772
10874
|
try {
|
|
10773
|
-
(0,
|
|
10774
|
-
(0,
|
|
10875
|
+
(0, import_child_process14.execSync)(`kill -0 ${pid} 2>/dev/null`);
|
|
10876
|
+
(0, import_child_process14.execSync)(`kill -9 ${pid} 2>/dev/null || true`);
|
|
10775
10877
|
} catch {
|
|
10776
10878
|
}
|
|
10777
10879
|
}
|
|
@@ -10820,7 +10922,7 @@ var DevServerRunner = class extends import_events2.EventEmitter {
|
|
|
10820
10922
|
PORT: String(port),
|
|
10821
10923
|
NODE_OPTIONS: enhancedNodeOptions
|
|
10822
10924
|
};
|
|
10823
|
-
const proc = (0,
|
|
10925
|
+
const proc = (0, import_child_process14.spawn)(cmd, args, {
|
|
10824
10926
|
cwd: projectPath,
|
|
10825
10927
|
env: mergedEnv,
|
|
10826
10928
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -11621,7 +11723,7 @@ async function getConfigForApi() {
|
|
|
11621
11723
|
}
|
|
11622
11724
|
return (0, import_core13.loadConfig)();
|
|
11623
11725
|
}
|
|
11624
|
-
var execAsync2 = (0, import_util2.promisify)(
|
|
11726
|
+
var execAsync2 = (0, import_util2.promisify)(import_child_process15.exec);
|
|
11625
11727
|
function persistWorkspaceProjectContext(workspaceSlug, projectSlug, projectId) {
|
|
11626
11728
|
if (process.env.EPISODA_MODE !== "cloud") {
|
|
11627
11729
|
return;
|
|
@@ -11694,8 +11796,11 @@ async function handleWorktreeCreate(request2) {
|
|
|
11694
11796
|
envVars,
|
|
11695
11797
|
setupScript,
|
|
11696
11798
|
// EP1229: detachedHead removed - planning worktrees no longer exist
|
|
11697
|
-
moduleType
|
|
11799
|
+
moduleType,
|
|
11800
|
+
defaultBranch,
|
|
11801
|
+
correlationId
|
|
11698
11802
|
} = request2;
|
|
11803
|
+
const worktreeStartMs = Date.now();
|
|
11699
11804
|
console.log(`[Worktree] K1273: Creating worktree for ${moduleUid}`);
|
|
11700
11805
|
console.log(`[Worktree] Project: ${projectSlug}`);
|
|
11701
11806
|
console.log(`[Worktree] Branch: ${branchName} (create: ${createBranch})`);
|
|
@@ -11739,12 +11844,7 @@ async function handleWorktreeCreate(request2) {
|
|
|
11739
11844
|
};
|
|
11740
11845
|
}
|
|
11741
11846
|
} else {
|
|
11742
|
-
console.log(`[Worktree]
|
|
11743
|
-
try {
|
|
11744
|
-
await execAsync2(`git -C "${bareRepoPath}" fetch origin --prune`, { env: gitEnv });
|
|
11745
|
-
} catch (fetchError) {
|
|
11746
|
-
console.warn(`[Worktree] K1273: Fetch failed (continuing anyway): ${fetchError.message}`);
|
|
11747
|
-
}
|
|
11847
|
+
console.log(`[Worktree] EP1373: Project exists, skipping handler-level fetch (manager handles narrow fetch)`);
|
|
11748
11848
|
}
|
|
11749
11849
|
const manager = new WorktreeManager(projectPath);
|
|
11750
11850
|
const initialized2 = await manager.initialize();
|
|
@@ -11754,7 +11854,8 @@ async function handleWorktreeCreate(request2) {
|
|
|
11754
11854
|
error: `Failed to initialize WorktreeManager at ${projectPath}`
|
|
11755
11855
|
};
|
|
11756
11856
|
}
|
|
11757
|
-
const
|
|
11857
|
+
const worktreeAddStartMs = Date.now();
|
|
11858
|
+
const result = await manager.createWorktree(moduleUid, branchName, createBranch, defaultBranch, correlationId);
|
|
11758
11859
|
if (!result.success) {
|
|
11759
11860
|
return {
|
|
11760
11861
|
success: false,
|
|
@@ -11762,6 +11863,7 @@ async function handleWorktreeCreate(request2) {
|
|
|
11762
11863
|
};
|
|
11763
11864
|
}
|
|
11764
11865
|
const worktreePath = result.worktreePath;
|
|
11866
|
+
console.log(`[Worktree] EP1373: worktree_add phase=worktree_add durationMs=${Date.now() - worktreeAddStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"}`);
|
|
11765
11867
|
console.log(`[Worktree] EP1143: Worktree created at ${worktreePath}`);
|
|
11766
11868
|
const config = await getConfigForApi();
|
|
11767
11869
|
let finalStatus = "ready";
|
|
@@ -11793,6 +11895,7 @@ ${buildCmd}` : buildCmd;
|
|
|
11793
11895
|
}
|
|
11794
11896
|
}
|
|
11795
11897
|
if (effectiveSetupScript) {
|
|
11898
|
+
const setupStartMs = Date.now();
|
|
11796
11899
|
await manager.updateWorktreeStatus(moduleUid, "setup");
|
|
11797
11900
|
if (config?.access_token) {
|
|
11798
11901
|
await updateWorktree(config, {
|
|
@@ -11805,6 +11908,7 @@ ${buildCmd}` : buildCmd;
|
|
|
11805
11908
|
}
|
|
11806
11909
|
console.log(`[Worktree] EP1143: Running setup script...`);
|
|
11807
11910
|
const scriptResult = await manager.runSetupScript(moduleUid, effectiveSetupScript);
|
|
11911
|
+
console.log(`[Worktree] EP1373: setup_script phase=worktree_setup durationMs=${Date.now() - setupStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} success=${scriptResult.success}`);
|
|
11808
11912
|
if (!scriptResult.success) {
|
|
11809
11913
|
console.error(`[Worktree] EP1143: Setup script failed: ${scriptResult.error}`);
|
|
11810
11914
|
await manager.updateWorktreeStatus(moduleUid, "error", scriptResult.error);
|
|
@@ -11864,6 +11968,7 @@ ${buildCmd}` : buildCmd;
|
|
|
11864
11968
|
console.error(`[Worktree] EP1143: Failed to update worktrees table: ${apiError.message}`);
|
|
11865
11969
|
}
|
|
11866
11970
|
}
|
|
11971
|
+
console.log(`[Worktree] EP1373: worktree_create_total phase=worktree_create_total durationMs=${Date.now() - worktreeStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} status=${finalStatus}`);
|
|
11867
11972
|
console.log(`[Worktree] EP1143: Worktree ready for ${moduleUid}`);
|
|
11868
11973
|
return {
|
|
11869
11974
|
success: true,
|
|
@@ -12166,7 +12271,7 @@ async function handleProjectSetup(params) {
|
|
|
12166
12271
|
}
|
|
12167
12272
|
|
|
12168
12273
|
// src/utils/dev-server.ts
|
|
12169
|
-
var
|
|
12274
|
+
var import_child_process16 = require("child_process");
|
|
12170
12275
|
var import_core14 = __toESM(require_dist());
|
|
12171
12276
|
var fs24 = __toESM(require("fs"));
|
|
12172
12277
|
var path25 = __toESM(require("path"));
|
|
@@ -12215,7 +12320,7 @@ function writeToLog(logPath, line, isError = false) {
|
|
|
12215
12320
|
}
|
|
12216
12321
|
async function killProcessOnPort(port) {
|
|
12217
12322
|
try {
|
|
12218
|
-
const result = (0,
|
|
12323
|
+
const result = (0, import_child_process16.execSync)(`lsof -ti:${port} 2>/dev/null || true`, { encoding: "utf8" }).trim();
|
|
12219
12324
|
if (!result) {
|
|
12220
12325
|
console.log(`[DevServer] EP929: No process found on port ${port}`);
|
|
12221
12326
|
return true;
|
|
@@ -12224,7 +12329,7 @@ async function killProcessOnPort(port) {
|
|
|
12224
12329
|
console.log(`[DevServer] EP929: Found ${pids.length} process(es) on port ${port}: ${pids.join(", ")}`);
|
|
12225
12330
|
for (const pid of pids) {
|
|
12226
12331
|
try {
|
|
12227
|
-
(0,
|
|
12332
|
+
(0, import_child_process16.execSync)(`kill -15 ${pid} 2>/dev/null || true`, { encoding: "utf8" });
|
|
12228
12333
|
console.log(`[DevServer] EP929: Sent SIGTERM to PID ${pid}`);
|
|
12229
12334
|
} catch {
|
|
12230
12335
|
}
|
|
@@ -12232,8 +12337,8 @@ async function killProcessOnPort(port) {
|
|
|
12232
12337
|
await new Promise((resolve4) => setTimeout(resolve4, 1e3));
|
|
12233
12338
|
for (const pid of pids) {
|
|
12234
12339
|
try {
|
|
12235
|
-
(0,
|
|
12236
|
-
(0,
|
|
12340
|
+
(0, import_child_process16.execSync)(`kill -0 ${pid} 2>/dev/null`, { encoding: "utf8" });
|
|
12341
|
+
(0, import_child_process16.execSync)(`kill -9 ${pid} 2>/dev/null || true`, { encoding: "utf8" });
|
|
12237
12342
|
console.log(`[DevServer] EP929: Force killed PID ${pid}`);
|
|
12238
12343
|
} catch {
|
|
12239
12344
|
}
|
|
@@ -12284,7 +12389,7 @@ function spawnDevServerProcess(projectPath, port, moduleUid, logPath, customComm
|
|
|
12284
12389
|
if (injectedCount > 0) {
|
|
12285
12390
|
console.log(`[DevServer] EP998: Injecting ${injectedCount} env vars from database`);
|
|
12286
12391
|
}
|
|
12287
|
-
const devProcess = (0,
|
|
12392
|
+
const devProcess = (0, import_child_process16.spawn)(cmd, args, {
|
|
12288
12393
|
cwd: projectPath,
|
|
12289
12394
|
env: mergedEnv,
|
|
12290
12395
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -12732,11 +12837,11 @@ var IPCRouter = class {
|
|
|
12732
12837
|
// src/daemon/update-manager.ts
|
|
12733
12838
|
var fs25 = __toESM(require("fs"));
|
|
12734
12839
|
var path26 = __toESM(require("path"));
|
|
12735
|
-
var
|
|
12840
|
+
var import_child_process18 = require("child_process");
|
|
12736
12841
|
var import_core17 = __toESM(require_dist());
|
|
12737
12842
|
|
|
12738
12843
|
// src/utils/update-checker.ts
|
|
12739
|
-
var
|
|
12844
|
+
var import_child_process17 = require("child_process");
|
|
12740
12845
|
var semver = __toESM(require("semver"));
|
|
12741
12846
|
|
|
12742
12847
|
// src/ipc/ipc-client.ts
|
|
@@ -12747,7 +12852,7 @@ var PACKAGE_NAME = "@episoda/cli";
|
|
|
12747
12852
|
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
12748
12853
|
function isFileLinkedInstall() {
|
|
12749
12854
|
try {
|
|
12750
|
-
const output = (0,
|
|
12855
|
+
const output = (0, import_child_process17.execSync)(`npm list -g ${PACKAGE_NAME} --json`, {
|
|
12751
12856
|
stdio: ["pipe", "pipe", "pipe"],
|
|
12752
12857
|
timeout: 1e4
|
|
12753
12858
|
}).toString();
|
|
@@ -12791,7 +12896,7 @@ async function checkForUpdates(currentVersion) {
|
|
|
12791
12896
|
}
|
|
12792
12897
|
function performSyncUpdate(targetVersion) {
|
|
12793
12898
|
try {
|
|
12794
|
-
(0,
|
|
12899
|
+
(0, import_child_process17.execSync)(`npm install -g ${PACKAGE_NAME}@${targetVersion}`, {
|
|
12795
12900
|
stdio: ["pipe", "pipe", "pipe"],
|
|
12796
12901
|
timeout: 12e4
|
|
12797
12902
|
// 2 minute timeout
|
|
@@ -12806,7 +12911,7 @@ function performSyncUpdate(targetVersion) {
|
|
|
12806
12911
|
}
|
|
12807
12912
|
function getInstalledVersion() {
|
|
12808
12913
|
try {
|
|
12809
|
-
const output = (0,
|
|
12914
|
+
const output = (0, import_child_process17.execSync)(`npm list -g ${PACKAGE_NAME} --json`, {
|
|
12810
12915
|
stdio: ["pipe", "pipe", "pipe"],
|
|
12811
12916
|
timeout: 1e4
|
|
12812
12917
|
}).toString();
|
|
@@ -12941,7 +13046,7 @@ var UpdateManager = class _UpdateManager {
|
|
|
12941
13046
|
const configDir = (0, import_core17.getConfigDir)();
|
|
12942
13047
|
const logPath = path26.join(configDir, "daemon.log");
|
|
12943
13048
|
const logFd = fs25.openSync(logPath, "a");
|
|
12944
|
-
const child = (0,
|
|
13049
|
+
const child = (0, import_child_process18.spawn)("node", [this.daemonEntryFile], {
|
|
12945
13050
|
detached: true,
|
|
12946
13051
|
stdio: ["ignore", logFd, logFd],
|
|
12947
13052
|
env: { ...process.env, EPISODA_DAEMON_MODE: "1" }
|