episoda 0.2.100 → 0.2.102
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 +1 -1
- package/dist/daemon/daemon-process.js.map +1 -1
- package/dist/index.js +83 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3936,7 +3936,9 @@ function findGitRoot(startDir) {
|
|
|
3936
3936
|
async function daemonCommand(options = {}) {
|
|
3937
3937
|
try {
|
|
3938
3938
|
const config = await (0, import_core4.loadConfig)();
|
|
3939
|
-
|
|
3939
|
+
const isCloudMode = process.env.EPISODA_MODE === "cloud";
|
|
3940
|
+
const needsProjectId = !isCloudMode;
|
|
3941
|
+
if (!config || !config.access_token || needsProjectId && !config.project_id) {
|
|
3940
3942
|
status.error("No authentication found. Please run:");
|
|
3941
3943
|
status.info("");
|
|
3942
3944
|
status.info(" episoda auth");
|
|
@@ -3975,40 +3977,54 @@ async function daemonCommand(options = {}) {
|
|
|
3975
3977
|
await new Promise((resolve5) => setTimeout(resolve5, 2e3));
|
|
3976
3978
|
}
|
|
3977
3979
|
}
|
|
3978
|
-
let projectPath;
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3980
|
+
let projectPath = null;
|
|
3981
|
+
if (!isCloudMode) {
|
|
3982
|
+
const serverPath = await fetchProjectPath(config, config.project_id);
|
|
3983
|
+
if (serverPath && fs4.existsSync(serverPath)) {
|
|
3984
|
+
projectPath = serverPath;
|
|
3985
|
+
status.debug(`Using server-synced project path: ${projectPath}`);
|
|
3986
|
+
} else {
|
|
3987
|
+
const detectedRoot = findGitRoot(options.cwd || process.cwd());
|
|
3988
|
+
projectPath = detectedRoot || path5.resolve(options.cwd || process.cwd());
|
|
3989
|
+
if (detectedRoot) {
|
|
3990
|
+
status.debug(`Detected project root: ${projectPath}`);
|
|
3991
|
+
} else {
|
|
3992
|
+
status.warning(`Could not detect git root, using: ${projectPath}`);
|
|
3993
|
+
}
|
|
3994
|
+
syncProjectPath(config, config.project_id, projectPath).catch(() => {
|
|
3995
|
+
});
|
|
3996
|
+
}
|
|
3997
|
+
const episodaProjectRoot = await findProjectRoot(projectPath);
|
|
3998
|
+
if (!episodaProjectRoot) {
|
|
3999
|
+
status.error("Not an Episoda project.");
|
|
4000
|
+
status.info("");
|
|
4001
|
+
status.info("Use `episoda clone {workspace}/{project}` to set up a project.");
|
|
4002
|
+
status.info("");
|
|
4003
|
+
process.exit(1);
|
|
4004
|
+
}
|
|
4005
|
+
projectPath = episodaProjectRoot;
|
|
4006
|
+
const isWorktree = await isWorktreeProject(projectPath);
|
|
4007
|
+
if (!isWorktree) {
|
|
4008
|
+
status.error("Invalid Episoda project configuration.");
|
|
4009
|
+
process.exit(1);
|
|
4010
|
+
}
|
|
4011
|
+
const bareRepoPath = path5.join(projectPath, ".bare");
|
|
4012
|
+
const scriptsExtracted = await extractBootstrapScripts(bareRepoPath, projectPath);
|
|
4013
|
+
if (scriptsExtracted) {
|
|
4014
|
+
status.success("Bootstrap scripts extracted");
|
|
4015
|
+
}
|
|
3983
4016
|
} else {
|
|
3984
4017
|
const detectedRoot = findGitRoot(options.cwd || process.cwd());
|
|
3985
|
-
projectPath = detectedRoot || path5.resolve(options.cwd || process.cwd());
|
|
3986
4018
|
if (detectedRoot) {
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
4019
|
+
const episodaProjectRoot = await findProjectRoot(detectedRoot);
|
|
4020
|
+
if (episodaProjectRoot) {
|
|
4021
|
+
projectPath = episodaProjectRoot;
|
|
4022
|
+
status.debug(`Cloud mode: Found project at ${projectPath}`);
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
if (!projectPath) {
|
|
4026
|
+
status.info("Cloud mode: No project detected. Daemon will wait for worktree creation.");
|
|
3990
4027
|
}
|
|
3991
|
-
syncProjectPath(config, config.project_id, projectPath).catch(() => {
|
|
3992
|
-
});
|
|
3993
|
-
}
|
|
3994
|
-
const episodaProjectRoot = await findProjectRoot(projectPath);
|
|
3995
|
-
if (!episodaProjectRoot) {
|
|
3996
|
-
status.error("Not an Episoda project.");
|
|
3997
|
-
status.info("");
|
|
3998
|
-
status.info("Use `episoda clone {workspace}/{project}` to set up a project.");
|
|
3999
|
-
status.info("");
|
|
4000
|
-
process.exit(1);
|
|
4001
|
-
}
|
|
4002
|
-
projectPath = episodaProjectRoot;
|
|
4003
|
-
const isWorktree = await isWorktreeProject(projectPath);
|
|
4004
|
-
if (!isWorktree) {
|
|
4005
|
-
status.error("Invalid Episoda project configuration.");
|
|
4006
|
-
process.exit(1);
|
|
4007
|
-
}
|
|
4008
|
-
const bareRepoPath = path5.join(projectPath, ".bare");
|
|
4009
|
-
const scriptsExtracted = await extractBootstrapScripts(bareRepoPath, projectPath);
|
|
4010
|
-
if (scriptsExtracted) {
|
|
4011
|
-
status.success("Bootstrap scripts extracted");
|
|
4012
4028
|
}
|
|
4013
4029
|
let daemonPid = isDaemonRunning();
|
|
4014
4030
|
if (!daemonPid) {
|
|
@@ -4028,34 +4044,42 @@ async function daemonCommand(options = {}) {
|
|
|
4028
4044
|
status.error("Daemon is running but not responding. Try: episoda stop && episoda dev");
|
|
4029
4045
|
process.exit(1);
|
|
4030
4046
|
}
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
connected
|
|
4043
|
-
|
|
4044
|
-
|
|
4047
|
+
if (projectPath && config.project_id) {
|
|
4048
|
+
status.info("Connecting project to Episoda...");
|
|
4049
|
+
let connected = false;
|
|
4050
|
+
let lastError;
|
|
4051
|
+
for (let retry = 0; retry < CONNECTION_MAX_RETRIES && !connected; retry++) {
|
|
4052
|
+
if (retry > 0) {
|
|
4053
|
+
status.info(`Retrying connection (attempt ${retry + 1}/${CONNECTION_MAX_RETRIES})...`);
|
|
4054
|
+
await new Promise((resolve5) => setTimeout(resolve5, 1e3));
|
|
4055
|
+
}
|
|
4056
|
+
try {
|
|
4057
|
+
const result = await addProject(config.project_id, projectPath);
|
|
4058
|
+
if (result.connected) {
|
|
4059
|
+
connected = true;
|
|
4060
|
+
} else {
|
|
4061
|
+
lastError = result.error || "Connection failed";
|
|
4062
|
+
}
|
|
4063
|
+
} catch (error) {
|
|
4064
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
4045
4065
|
}
|
|
4046
|
-
} catch (error) {
|
|
4047
|
-
lastError = error instanceof Error ? error.message : String(error);
|
|
4048
4066
|
}
|
|
4067
|
+
if (!connected) {
|
|
4068
|
+
status.error(`Failed to connect: ${lastError}`);
|
|
4069
|
+
status.info("Check server status at https://episoda.dev/api/system/health");
|
|
4070
|
+
process.exit(1);
|
|
4071
|
+
}
|
|
4072
|
+
status.success("Connected to Episoda");
|
|
4073
|
+
} else if (isCloudMode) {
|
|
4074
|
+
status.success("Daemon started in cloud mode (awaiting project)");
|
|
4049
4075
|
}
|
|
4050
|
-
if (!connected) {
|
|
4051
|
-
status.error(`Failed to connect: ${lastError}`);
|
|
4052
|
-
status.info("Check server status at https://episoda.dev/api/system/health");
|
|
4053
|
-
process.exit(1);
|
|
4054
|
-
}
|
|
4055
|
-
status.success("Connected to Episoda");
|
|
4056
4076
|
if (options.foreground) {
|
|
4057
4077
|
status.info("");
|
|
4058
|
-
|
|
4078
|
+
if (isCloudMode && !projectPath) {
|
|
4079
|
+
status.info("Daemon running in cloud mode. Waiting for worktree creation commands.");
|
|
4080
|
+
} else {
|
|
4081
|
+
status.info("Daemon connected! Dev servers start automatically when you begin work on a module.");
|
|
4082
|
+
}
|
|
4059
4083
|
status.info("Press Ctrl+C to disconnect (daemon continues in background).");
|
|
4060
4084
|
status.info("");
|
|
4061
4085
|
const shutdownHandler = (signal) => {
|
|
@@ -4072,7 +4096,11 @@ Received ${signal}. Daemon continues running in background.`);
|
|
|
4072
4096
|
});
|
|
4073
4097
|
} else {
|
|
4074
4098
|
status.info("");
|
|
4075
|
-
|
|
4099
|
+
if (isCloudMode && !projectPath) {
|
|
4100
|
+
status.info("Daemon running in cloud mode. Waiting for worktree creation commands.");
|
|
4101
|
+
} else {
|
|
4102
|
+
status.info("Daemon running in background. Use `episoda status` to check connection.");
|
|
4103
|
+
}
|
|
4076
4104
|
process.exit(0);
|
|
4077
4105
|
}
|
|
4078
4106
|
} catch (error) {
|