episoda 0.2.98 → 0.2.99

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.
@@ -2786,7 +2786,7 @@ var require_package = __commonJS({
2786
2786
  "package.json"(exports2, module2) {
2787
2787
  module2.exports = {
2788
2788
  name: "episoda",
2789
- version: "0.2.98",
2789
+ version: "0.2.99",
2790
2790
  description: "CLI tool for Episoda local development workflow orchestration",
2791
2791
  main: "dist/index.js",
2792
2792
  types: "dist/index.d.ts",
@@ -10924,130 +10924,8 @@ var Daemon = class _Daemon {
10924
10924
  }
10925
10925
  }
10926
10926
  // EP1025: Removed cleanupModuleWorktree - was dead code (never called).
10927
- // Worktree cleanup is handled by server's cleanupWorktreeAsync which sends
10928
- // worktree_remove command via WebSocket, handled by GitExecutor.executeWorktreeRemove.
10929
- /**
10930
- * EP1047: Process pending cleanup queue entries for this machine
10931
- *
10932
- * @deprecated EP1091: No longer called on connect. Server-side cron now processes
10933
- * the cleanup queue and sends WebSocket commands to connected daemons. This is
10934
- * more reliable than daemon-side polling since it works even if daemon stays connected.
10935
- *
10936
- * Kept for potential manual invocation or debugging purposes.
10937
- *
10938
- * Flow:
10939
- * 1. Query server for pending cleanup tasks for this machine
10940
- * 2. For each task, attempt worktree removal
10941
- * 3. Report success/failure back to server
10942
- */
10943
- async reconcilePendingCleanups(projectId, projectPath) {
10944
- if (!this.machineUuid) {
10945
- console.log("[Daemon] EP1047: Cannot reconcile cleanups - machineUuid not available yet");
10946
- return;
10947
- }
10948
- console.log(`[Daemon] EP1047: Checking for pending cleanup tasks for machine ${this.machineUuid}`);
10949
- try {
10950
- const config = await (0, import_core13.loadConfig)();
10951
- if (!config) {
10952
- console.log("[Daemon] EP1047: No config loaded, skipping cleanup reconciliation");
10953
- return;
10954
- }
10955
- const apiUrl = config.api_url || "https://episoda.dev";
10956
- const controller = new AbortController();
10957
- const timeoutId = setTimeout(() => controller.abort(), 1e4);
10958
- let response;
10959
- try {
10960
- response = await fetchWithAuth(
10961
- `${apiUrl}/api/cli/background-ops?machine_id=${this.machineUuid}`,
10962
- { signal: controller.signal }
10963
- );
10964
- } finally {
10965
- clearTimeout(timeoutId);
10966
- }
10967
- if (!response.ok) {
10968
- console.warn(`[Daemon] EP1051: Failed to fetch background operations: ${response.status}`);
10969
- return;
10970
- }
10971
- const data = await response.json();
10972
- const tasks = data.tasks || [];
10973
- if (tasks.length === 0) {
10974
- console.log("[Daemon] EP1051: No pending background operations");
10975
- return;
10976
- }
10977
- console.log(`[Daemon] EP1051: Processing ${tasks.length} pending operation(s)`);
10978
- const projectRoot = await findProjectRoot(projectPath);
10979
- if (!projectRoot) {
10980
- console.warn("[Daemon] EP1051: Could not find project root, skipping operation reconciliation");
10981
- return;
10982
- }
10983
- const worktreeManager = new WorktreeManager(projectRoot);
10984
- if (!await worktreeManager.initialize()) {
10985
- console.warn("[Daemon] EP1051: Failed to initialize worktree manager");
10986
- return;
10987
- }
10988
- for (const task of tasks) {
10989
- const moduleUid = task.payload.module_uid || task.target_id;
10990
- console.log(`[Daemon] EP1051: Processing ${task.operation_type} for ${moduleUid} (task ${task.id})`);
10991
- try {
10992
- if (task.operation_type === "worktree_cleanup") {
10993
- const result = await worktreeManager.removeWorktree(moduleUid, true);
10994
- if (result.success) {
10995
- console.log(`[Daemon] EP1051: Successfully cleaned up worktree for ${moduleUid}`);
10996
- await this.reportOperationResult(apiUrl, task.id, "complete");
10997
- } else {
10998
- if (result.error?.includes("not found") || result.error?.includes("No worktree found")) {
10999
- console.log(`[Daemon] EP1051: Worktree ${moduleUid} already removed, marking complete`);
11000
- await this.reportOperationResult(apiUrl, task.id, "complete");
11001
- } else {
11002
- console.warn(`[Daemon] EP1051: Cleanup failed for ${moduleUid}: ${result.error}`);
11003
- await this.reportOperationResult(apiUrl, task.id, "retry", {
11004
- code: "OPERATION_ERROR",
11005
- message: result.error || "Unknown error"
11006
- });
11007
- }
11008
- }
11009
- } else {
11010
- console.warn(`[Daemon] EP1051: Unknown operation type: ${task.operation_type}`);
11011
- await this.reportOperationResult(apiUrl, task.id, "fail", {
11012
- code: "UNKNOWN_OPERATION_TYPE",
11013
- message: `Daemon cannot process operation type: ${task.operation_type}`
11014
- });
11015
- }
11016
- } catch (error) {
11017
- console.error(`[Daemon] EP1051: Error processing operation for ${moduleUid}:`, error.message);
11018
- await this.reportOperationResult(apiUrl, task.id, "retry", {
11019
- code: "OPERATION_EXCEPTION",
11020
- message: error.message
11021
- });
11022
- }
11023
- }
11024
- console.log("[Daemon] EP1051: Operation reconciliation complete");
11025
- } catch (error) {
11026
- console.error("[Daemon] EP1051: Operation reconciliation error:", error instanceof Error ? error.message : error);
11027
- throw error;
11028
- }
11029
- }
11030
- /**
11031
- * EP1051: Report background operation result to server
11032
- */
11033
- async reportOperationResult(apiUrl, taskId, action, error) {
11034
- try {
11035
- const response = await fetchWithAuth(`${apiUrl}/api/cli/background-ops`, {
11036
- method: "POST",
11037
- headers: { "Content-Type": "application/json" },
11038
- body: JSON.stringify({
11039
- task_id: taskId,
11040
- action,
11041
- error
11042
- })
11043
- });
11044
- if (!response.ok) {
11045
- console.warn(`[Daemon] EP1051: Failed to report operation result: ${response.status}`);
11046
- }
11047
- } catch (err) {
11048
- console.warn(`[Daemon] EP1051: Error reporting operation result: ${err.message}`);
11049
- }
11050
- }
10927
+ // EP1188: Background ops queue removed - worktree cleanup now handled by Inngest events
10928
+ // (worktree/cleanup) which send WebSocket commands to connected daemons via ws-proxy.
11051
10929
  /**
11052
10930
  * EP1002: Handle worktree_setup command from server
11053
10931
  * This provides a unified setup flow for both local and cloud environments.