@episoda/cli 0.2.160 → 0.2.162
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 +11 -84
- package/dist/daemon/daemon-process.js.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2141,7 +2141,7 @@ var require_websocket_client = __commonJS({
|
|
|
2141
2141
|
* @param url - WebSocket URL (wss://episoda.dev/cli)
|
|
2142
2142
|
* @param token - OAuth access token
|
|
2143
2143
|
* @param machineId - Optional machine identifier for multi-machine support
|
|
2144
|
-
* @param deviceInfo - Optional device information (hostname, OS, daemonPid)
|
|
2144
|
+
* @param deviceInfo - Optional device information (hostname, OS, daemonPid, cliVersion)
|
|
2145
2145
|
* EP1119: Added environment and containerId for cloud routing
|
|
2146
2146
|
*/
|
|
2147
2147
|
async connect(url, token, machineId, deviceInfo) {
|
|
@@ -2152,6 +2152,7 @@ var require_websocket_client = __commonJS({
|
|
|
2152
2152
|
this.osPlatform = deviceInfo?.osPlatform;
|
|
2153
2153
|
this.osArch = deviceInfo?.osArch;
|
|
2154
2154
|
this.daemonPid = deviceInfo?.daemonPid;
|
|
2155
|
+
this.cliVersion = deviceInfo?.cliVersion;
|
|
2155
2156
|
this.environment = deviceInfo?.environment;
|
|
2156
2157
|
this.containerId = deviceInfo?.containerId;
|
|
2157
2158
|
this.isDisconnecting = false;
|
|
@@ -2190,7 +2191,7 @@ var require_websocket_client = __commonJS({
|
|
|
2190
2191
|
this.send({
|
|
2191
2192
|
type: "auth",
|
|
2192
2193
|
token,
|
|
2193
|
-
version: version_1.VERSION,
|
|
2194
|
+
version: this.cliVersion || version_1.VERSION,
|
|
2194
2195
|
environment: this.environment,
|
|
2195
2196
|
machineId,
|
|
2196
2197
|
containerId: this.containerId,
|
|
@@ -2509,6 +2510,7 @@ var require_websocket_client = __commonJS({
|
|
|
2509
2510
|
osPlatform: this.osPlatform,
|
|
2510
2511
|
osArch: this.osArch,
|
|
2511
2512
|
daemonPid: this.daemonPid,
|
|
2513
|
+
cliVersion: this.cliVersion,
|
|
2512
2514
|
environment: this.environment,
|
|
2513
2515
|
containerId: this.containerId
|
|
2514
2516
|
}).then(() => {
|
|
@@ -2909,7 +2911,7 @@ var require_package = __commonJS({
|
|
|
2909
2911
|
"package.json"(exports2, module2) {
|
|
2910
2912
|
module2.exports = {
|
|
2911
2913
|
name: "@episoda/cli",
|
|
2912
|
-
version: "0.2.
|
|
2914
|
+
version: "0.2.162",
|
|
2913
2915
|
description: "CLI tool for Episoda local development workflow orchestration",
|
|
2914
2916
|
main: "dist/index.js",
|
|
2915
2917
|
types: "dist/index.d.ts",
|
|
@@ -11514,45 +11516,6 @@ function getPreviewManager() {
|
|
|
11514
11516
|
var import_core13 = __toESM(require_dist());
|
|
11515
11517
|
|
|
11516
11518
|
// src/api/worktree-api.ts
|
|
11517
|
-
async function updateWorktree(config, request2) {
|
|
11518
|
-
const machineUuid = config.machine_uuid || config.device_id;
|
|
11519
|
-
if (!machineUuid || !config.access_token) {
|
|
11520
|
-
console.debug("[WorktreeAPI] updateWorktree: no machineUuid or access_token");
|
|
11521
|
-
return false;
|
|
11522
|
-
}
|
|
11523
|
-
const serverUrl = config.api_url || "https://episoda.dev";
|
|
11524
|
-
const url = `${serverUrl}/api/dev/worktrees`;
|
|
11525
|
-
try {
|
|
11526
|
-
const response = await fetch(url, {
|
|
11527
|
-
method: "POST",
|
|
11528
|
-
headers: {
|
|
11529
|
-
"Authorization": `Bearer ${config.access_token}`,
|
|
11530
|
-
"Content-Type": "application/json"
|
|
11531
|
-
},
|
|
11532
|
-
body: JSON.stringify({
|
|
11533
|
-
module_id: request2.moduleId,
|
|
11534
|
-
// EP1143: For cloud containers, use container_id; for local, use machine_id
|
|
11535
|
-
local_machine_id: process.env.EPISODA_MODE === "cloud" ? void 0 : machineUuid,
|
|
11536
|
-
cloud_container_id: process.env.EPISODA_MODE === "cloud" ? process.env.EPISODA_CONTAINER_ID : void 0,
|
|
11537
|
-
worktree_path: request2.worktreePath,
|
|
11538
|
-
branch_name: request2.branchName,
|
|
11539
|
-
status: request2.status,
|
|
11540
|
-
port: request2.port,
|
|
11541
|
-
preview_url: request2.previewUrl,
|
|
11542
|
-
error: request2.error
|
|
11543
|
-
})
|
|
11544
|
-
});
|
|
11545
|
-
if (!response.ok) {
|
|
11546
|
-
const text = await response.text();
|
|
11547
|
-
console.debug(`[WorktreeAPI] updateWorktree failed: ${response.status} ${text}`);
|
|
11548
|
-
return false;
|
|
11549
|
-
}
|
|
11550
|
-
return true;
|
|
11551
|
-
} catch (error) {
|
|
11552
|
-
console.debug(`[WorktreeAPI] updateWorktree network error:`, error);
|
|
11553
|
-
return false;
|
|
11554
|
-
}
|
|
11555
|
-
}
|
|
11556
11519
|
async function deleteWorktree(config, moduleUid) {
|
|
11557
11520
|
const machineUuid = config.machine_uuid || config.device_id;
|
|
11558
11521
|
if (!machineUuid || !config.access_token) {
|
|
@@ -11843,7 +11806,7 @@ async function handleWorktreeCreate(request2) {
|
|
|
11843
11806
|
console.log(`[Worktree] K1273: Clone successful`);
|
|
11844
11807
|
await execAsync2(`git -C "${bareRepoPath}" config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`, { env: gitEnv });
|
|
11845
11808
|
const configPath = path23.join(episodaDir, "config.json");
|
|
11846
|
-
const
|
|
11809
|
+
const config = {
|
|
11847
11810
|
projectId,
|
|
11848
11811
|
workspaceSlug,
|
|
11849
11812
|
projectSlug,
|
|
@@ -11851,7 +11814,7 @@ async function handleWorktreeCreate(request2) {
|
|
|
11851
11814
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11852
11815
|
worktrees: []
|
|
11853
11816
|
};
|
|
11854
|
-
fs22.writeFileSync(configPath, JSON.stringify(
|
|
11817
|
+
fs22.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
11855
11818
|
console.log(`[Worktree] K1273: Project initialized at ${projectPath}`);
|
|
11856
11819
|
} catch (cloneError) {
|
|
11857
11820
|
console.error(`[Worktree] K1273: Git clone failed: ${cloneError.message}`);
|
|
@@ -11882,18 +11845,8 @@ async function handleWorktreeCreate(request2) {
|
|
|
11882
11845
|
const worktreePath = result.worktreePath;
|
|
11883
11846
|
console.log(`[Worktree] EP1373: worktree_add phase=worktree_add durationMs=${Date.now() - worktreeAddStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"}`);
|
|
11884
11847
|
console.log(`[Worktree] EP1143: Worktree created at ${worktreePath}`);
|
|
11885
|
-
const config = await getConfigForApi();
|
|
11886
11848
|
let finalStatus = "ready";
|
|
11887
11849
|
let finalError;
|
|
11888
|
-
if (config?.access_token) {
|
|
11889
|
-
await updateWorktree(config, {
|
|
11890
|
-
moduleId,
|
|
11891
|
-
worktreePath,
|
|
11892
|
-
branchName,
|
|
11893
|
-
status: "pending"
|
|
11894
|
-
}).catch(() => {
|
|
11895
|
-
});
|
|
11896
|
-
}
|
|
11897
11850
|
if (envVars && Object.keys(envVars).length > 0) {
|
|
11898
11851
|
const envContent = Object.entries(envVars).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
11899
11852
|
const envPath = path23.join(worktreePath, ".env");
|
|
@@ -11914,15 +11867,6 @@ ${buildCmd}` : buildCmd;
|
|
|
11914
11867
|
if (effectiveSetupScript) {
|
|
11915
11868
|
const setupStartMs = Date.now();
|
|
11916
11869
|
await manager.updateWorktreeStatus(moduleUid, "setup");
|
|
11917
|
-
if (config?.access_token) {
|
|
11918
|
-
await updateWorktree(config, {
|
|
11919
|
-
moduleId,
|
|
11920
|
-
worktreePath,
|
|
11921
|
-
branchName,
|
|
11922
|
-
status: "setup"
|
|
11923
|
-
}).catch(() => {
|
|
11924
|
-
});
|
|
11925
|
-
}
|
|
11926
11870
|
console.log(`[Worktree] EP1143: Running setup script...`);
|
|
11927
11871
|
const scriptResult = await manager.runSetupScript(moduleUid, effectiveSetupScript);
|
|
11928
11872
|
console.log(`[Worktree] EP1373: setup_script phase=worktree_setup durationMs=${Date.now() - setupStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} success=${scriptResult.success}`);
|
|
@@ -11965,33 +11909,15 @@ ${buildCmd}` : buildCmd;
|
|
|
11965
11909
|
} else if (finalStatus === "ready" && isCloud) {
|
|
11966
11910
|
console.log(`[Worktree] EP1262: Skipping preview start in cloud mode (server orchestrates)`);
|
|
11967
11911
|
}
|
|
11968
|
-
if (config?.access_token) {
|
|
11969
|
-
try {
|
|
11970
|
-
const updated = await updateWorktree(config, {
|
|
11971
|
-
moduleId,
|
|
11972
|
-
worktreePath,
|
|
11973
|
-
branchName,
|
|
11974
|
-
status: finalStatus,
|
|
11975
|
-
port,
|
|
11976
|
-
previewUrl,
|
|
11977
|
-
error: finalError
|
|
11978
|
-
});
|
|
11979
|
-
if (updated) {
|
|
11980
|
-
console.log(`[Worktree] EP1143: Updated worktrees table with status '${finalStatus}'`);
|
|
11981
|
-
} else {
|
|
11982
|
-
console.warn(`[Worktree] EP1143: Failed to update worktrees table`);
|
|
11983
|
-
}
|
|
11984
|
-
} catch (apiError) {
|
|
11985
|
-
console.error(`[Worktree] EP1143: Failed to update worktrees table: ${apiError.message}`);
|
|
11986
|
-
}
|
|
11987
|
-
}
|
|
11988
11912
|
console.log(`[Worktree] EP1373: worktree_create_total phase=worktree_create_total durationMs=${Date.now() - worktreeStartMs} moduleUid=${moduleUid} correlationId=${correlationId || "none"} status=${finalStatus}`);
|
|
11989
11913
|
console.log(`[Worktree] EP1143: Worktree ready for ${moduleUid}`);
|
|
11990
11914
|
return {
|
|
11991
11915
|
success: true,
|
|
11992
11916
|
worktreePath,
|
|
11993
11917
|
previewUrl,
|
|
11994
|
-
port
|
|
11918
|
+
port,
|
|
11919
|
+
status: finalStatus,
|
|
11920
|
+
error: finalError
|
|
11995
11921
|
};
|
|
11996
11922
|
} catch (error) {
|
|
11997
11923
|
console.error(`[Worktree] EP1143: Create failed: ${error.message}`);
|
|
@@ -15085,6 +15011,7 @@ var Daemon = class _Daemon {
|
|
|
15085
15011
|
osPlatform: os12.platform(),
|
|
15086
15012
|
osArch: os12.arch(),
|
|
15087
15013
|
daemonPid,
|
|
15014
|
+
cliVersion: packageJson.version,
|
|
15088
15015
|
environment,
|
|
15089
15016
|
containerId
|
|
15090
15017
|
});
|