episoda 0.2.57 → 0.2.58

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.
@@ -2726,7 +2726,7 @@ var require_package = __commonJS({
2726
2726
  "package.json"(exports2, module2) {
2727
2727
  module2.exports = {
2728
2728
  name: "episoda",
2729
- version: "0.2.57",
2729
+ version: "0.2.58",
2730
2730
  description: "CLI tool for Episoda local development workflow orchestration",
2731
2731
  main: "dist/index.js",
2732
2732
  types: "dist/index.d.ts",
@@ -9261,73 +9261,81 @@ var Daemon = class _Daemon {
9261
9261
  let response;
9262
9262
  try {
9263
9263
  response = await fetchWithAuth(
9264
- `${apiUrl}/api/cli/cleanup-queue?machine_id=${this.deviceId}`,
9264
+ `${apiUrl}/api/cli/background-ops?machine_id=${this.deviceId}`,
9265
9265
  { signal: controller.signal }
9266
9266
  );
9267
9267
  } finally {
9268
9268
  clearTimeout(timeoutId);
9269
9269
  }
9270
9270
  if (!response.ok) {
9271
- console.warn(`[Daemon] EP1047: Failed to fetch cleanup tasks: ${response.status}`);
9271
+ console.warn(`[Daemon] EP1051: Failed to fetch background operations: ${response.status}`);
9272
9272
  return;
9273
9273
  }
9274
9274
  const data = await response.json();
9275
9275
  const tasks = data.data?.tasks || [];
9276
9276
  if (tasks.length === 0) {
9277
- console.log("[Daemon] EP1047: No pending cleanup tasks");
9277
+ console.log("[Daemon] EP1051: No pending background operations");
9278
9278
  return;
9279
9279
  }
9280
- console.log(`[Daemon] EP1047: Processing ${tasks.length} pending cleanup task(s)`);
9280
+ console.log(`[Daemon] EP1051: Processing ${tasks.length} pending operation(s)`);
9281
9281
  const projectRoot = await findProjectRoot(projectPath);
9282
9282
  if (!projectRoot) {
9283
- console.warn("[Daemon] EP1047: Could not find project root, skipping cleanup reconciliation");
9283
+ console.warn("[Daemon] EP1051: Could not find project root, skipping operation reconciliation");
9284
9284
  return;
9285
9285
  }
9286
9286
  const worktreeManager = new WorktreeManager(projectRoot);
9287
9287
  if (!await worktreeManager.initialize()) {
9288
- console.warn("[Daemon] EP1047: Failed to initialize worktree manager");
9288
+ console.warn("[Daemon] EP1051: Failed to initialize worktree manager");
9289
9289
  return;
9290
9290
  }
9291
9291
  for (const task of tasks) {
9292
9292
  const moduleUid = task.payload.module_uid || task.target_id;
9293
- console.log(`[Daemon] EP1047: Processing cleanup for ${moduleUid} (task ${task.id})`);
9293
+ console.log(`[Daemon] EP1051: Processing ${task.operation_type} for ${moduleUid} (task ${task.id})`);
9294
9294
  try {
9295
- const result = await worktreeManager.removeWorktree(moduleUid, true);
9296
- if (result.success) {
9297
- console.log(`[Daemon] EP1047: Successfully cleaned up worktree for ${moduleUid}`);
9298
- await this.reportCleanupResult(apiUrl, task.id, "complete");
9299
- } else {
9300
- if (result.error?.includes("not found") || result.error?.includes("No worktree found")) {
9301
- console.log(`[Daemon] EP1047: Worktree ${moduleUid} already removed, marking complete`);
9302
- await this.reportCleanupResult(apiUrl, task.id, "complete");
9295
+ if (task.operation_type === "worktree_cleanup") {
9296
+ const result = await worktreeManager.removeWorktree(moduleUid, true);
9297
+ if (result.success) {
9298
+ console.log(`[Daemon] EP1051: Successfully cleaned up worktree for ${moduleUid}`);
9299
+ await this.reportOperationResult(apiUrl, task.id, "complete");
9303
9300
  } else {
9304
- console.warn(`[Daemon] EP1047: Cleanup failed for ${moduleUid}: ${result.error}`);
9305
- await this.reportCleanupResult(apiUrl, task.id, "retry", {
9306
- code: "CLEANUP_ERROR",
9307
- message: result.error || "Unknown error"
9308
- });
9301
+ if (result.error?.includes("not found") || result.error?.includes("No worktree found")) {
9302
+ console.log(`[Daemon] EP1051: Worktree ${moduleUid} already removed, marking complete`);
9303
+ await this.reportOperationResult(apiUrl, task.id, "complete");
9304
+ } else {
9305
+ console.warn(`[Daemon] EP1051: Cleanup failed for ${moduleUid}: ${result.error}`);
9306
+ await this.reportOperationResult(apiUrl, task.id, "retry", {
9307
+ code: "OPERATION_ERROR",
9308
+ message: result.error || "Unknown error"
9309
+ });
9310
+ }
9309
9311
  }
9312
+ } else {
9313
+ console.warn(`[Daemon] EP1051: Unknown operation type: ${task.operation_type}`);
9314
+ await this.reportOperationResult(apiUrl, task.id, "fail", {
9315
+ code: "UNKNOWN_OPERATION_TYPE",
9316
+ message: `Daemon cannot process operation type: ${task.operation_type}`
9317
+ });
9310
9318
  }
9311
9319
  } catch (error) {
9312
- console.error(`[Daemon] EP1047: Error processing cleanup for ${moduleUid}:`, error.message);
9313
- await this.reportCleanupResult(apiUrl, task.id, "retry", {
9314
- code: "CLEANUP_EXCEPTION",
9320
+ console.error(`[Daemon] EP1051: Error processing operation for ${moduleUid}:`, error.message);
9321
+ await this.reportOperationResult(apiUrl, task.id, "retry", {
9322
+ code: "OPERATION_EXCEPTION",
9315
9323
  message: error.message
9316
9324
  });
9317
9325
  }
9318
9326
  }
9319
- console.log("[Daemon] EP1047: Cleanup reconciliation complete");
9327
+ console.log("[Daemon] EP1051: Operation reconciliation complete");
9320
9328
  } catch (error) {
9321
- console.error("[Daemon] EP1047: Cleanup reconciliation error:", error instanceof Error ? error.message : error);
9329
+ console.error("[Daemon] EP1051: Operation reconciliation error:", error instanceof Error ? error.message : error);
9322
9330
  throw error;
9323
9331
  }
9324
9332
  }
9325
9333
  /**
9326
- * EP1047: Report cleanup task result to server
9334
+ * EP1051: Report background operation result to server
9327
9335
  */
9328
- async reportCleanupResult(apiUrl, taskId, action, error) {
9336
+ async reportOperationResult(apiUrl, taskId, action, error) {
9329
9337
  try {
9330
- const response = await fetchWithAuth(`${apiUrl}/api/cli/cleanup-queue`, {
9338
+ const response = await fetchWithAuth(`${apiUrl}/api/cli/background-ops`, {
9331
9339
  method: "POST",
9332
9340
  headers: { "Content-Type": "application/json" },
9333
9341
  body: JSON.stringify({
@@ -9337,10 +9345,10 @@ var Daemon = class _Daemon {
9337
9345
  })
9338
9346
  });
9339
9347
  if (!response.ok) {
9340
- console.warn(`[Daemon] EP1047: Failed to report cleanup result: ${response.status}`);
9348
+ console.warn(`[Daemon] EP1051: Failed to report operation result: ${response.status}`);
9341
9349
  }
9342
9350
  } catch (err) {
9343
- console.warn(`[Daemon] EP1047: Error reporting cleanup result: ${err.message}`);
9351
+ console.warn(`[Daemon] EP1051: Error reporting operation result: ${err.message}`);
9344
9352
  }
9345
9353
  }
9346
9354
  /**