forgecraft 1.2.0 → 1.3.1

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.
@@ -310,6 +310,9 @@ function playSound() {
310
310
  "paplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>/dev/null || printf '\\x07'"
311
311
  );
312
312
  break;
313
+ case "win32":
314
+ exec('powershell -c "[System.Media.SystemSounds]::Exclamation.Play()"');
315
+ break;
313
316
  default:
314
317
  process.stdout.write("\x07");
315
318
  }
@@ -692,31 +695,58 @@ ${context.existingFiles.map((f) => ` - ${f}`).join("\n")}` : "";
692
695
  }
693
696
  async executeQuery(prompt, opts = {}) {
694
697
  let resultText = "";
695
- for await (const msg of query({
696
- prompt,
697
- options: {
698
- model: this.config.model,
699
- systemPrompt: ORCHESTRATOR_SYSTEM_PROMPT,
700
- maxTurns: opts.maxTurns,
701
- allowedTools: []
702
- }
703
- })) {
704
- if (msg.type === "result") {
705
- if ("result" in msg && typeof msg.result === "string") {
706
- resultText = msg.result;
707
- } else if ("errors" in msg && Array.isArray(msg.errors)) {
708
- throw new Error(`Agent error: ${msg.errors.join(", ")}`);
698
+ try {
699
+ for await (const msg of query({
700
+ prompt,
701
+ options: {
702
+ model: this.config.model,
703
+ systemPrompt: ORCHESTRATOR_SYSTEM_PROMPT,
704
+ maxTurns: opts.maxTurns,
705
+ allowedTools: []
709
706
  }
710
- }
711
- if (msg.type === "assistant" && msg.message?.content) {
712
- const textBlocks = msg.message.content.filter((b) => b.type === "text").map((b) => b.text);
713
- if (textBlocks.length > 0) {
714
- resultText = textBlocks.join("\n");
707
+ })) {
708
+ if (msg.type === "result") {
709
+ const hasError = "is_error" in msg && msg.is_error;
710
+ const errors = "errors" in msg && Array.isArray(msg.errors) ? msg.errors : [];
711
+ const subtype = "subtype" in msg ? String(msg.subtype) : "";
712
+ if (hasError || errors.length > 0) {
713
+ const errorParts = [];
714
+ if (subtype) errorParts.push(subtype);
715
+ for (const e of errors) {
716
+ const eStr = typeof e === "string" ? e : JSON.stringify(e);
717
+ if (eStr && eStr.length > 0) errorParts.push(eStr);
718
+ }
719
+ const errorMsg = errorParts.length > 0 ? errorParts.join(" \u2014 ") : "Unknown error from Claude. Check your auth with: claude login";
720
+ throw new Error(errorMsg);
721
+ }
722
+ if ("result" in msg && typeof msg.result === "string") {
723
+ resultText = msg.result;
724
+ }
725
+ }
726
+ if (msg.type === "assistant" && msg.message?.content) {
727
+ const textBlocks = msg.message.content.filter((b) => b.type === "text").map((b) => b.text);
728
+ if (textBlocks.length > 0) {
729
+ resultText = textBlocks.join("\n");
730
+ }
715
731
  }
716
732
  }
733
+ } catch (error) {
734
+ if (error instanceof Error && !error.message.includes("EPIPE") && !error.message.includes("ENOENT")) {
735
+ throw error;
736
+ }
737
+ const msg = error instanceof Error ? error.message : String(error);
738
+ throw new Error(
739
+ `Failed to communicate with Claude. ${msg}
740
+ Possible fixes:
741
+ 1. Run: claude login
742
+ 2. Check your internet connection
743
+ 3. Run: forge doctor`
744
+ );
717
745
  }
718
746
  if (!resultText) {
719
- throw new Error("No response from agent");
747
+ throw new Error(
748
+ "No response from Claude.\n Possible fixes:\n 1. Run: claude login\n 2. Check your internet connection\n 3. Run: forge doctor"
749
+ );
720
750
  }
721
751
  return resultText;
722
752
  }
@@ -1069,11 +1099,19 @@ var Worker = class {
1069
1099
  if ("result" in msg && typeof msg.result === "string") {
1070
1100
  result.summary = msg.result;
1071
1101
  }
1072
- if ("errors" in msg && Array.isArray(msg.errors) && msg.errors.length > 0) {
1073
- result.errors.push(...msg.errors);
1102
+ const hasError = "is_error" in msg && msg.is_error;
1103
+ const errors = "errors" in msg && Array.isArray(msg.errors) ? msg.errors : [];
1104
+ const subtype = "subtype" in msg ? String(msg.subtype || "") : "";
1105
+ if (errors.length > 0) {
1106
+ for (const e of errors) {
1107
+ const eStr = typeof e === "string" ? e : JSON.stringify(e);
1108
+ if (eStr && eStr.length > 0) result.errors.push(eStr);
1109
+ }
1074
1110
  }
1075
- if ("is_error" in msg && msg.is_error) {
1076
- result.errors.push(msg.subtype || "unknown error");
1111
+ if (hasError && result.errors.length === 0) {
1112
+ result.errors.push(
1113
+ subtype || "Claude encountered an error. Run: claude login"
1114
+ );
1077
1115
  }
1078
1116
  if (msg.usage) {
1079
1117
  result.usage.inputTokens = msg.usage.input_tokens || 0;
@@ -1146,7 +1184,7 @@ var Worker = class {
1146
1184
  }
1147
1185
  shortPath(p) {
1148
1186
  if (!p) return "";
1149
- const parts = p.split("/");
1187
+ const parts = p.split(/[/\\]/);
1150
1188
  return parts.length > 2 ? ".../" + parts.slice(-2).join("/") : p;
1151
1189
  }
1152
1190
  };
@@ -2273,9 +2311,13 @@ var AutoPipeline = class {
2273
2311
  this.activeSpinner = null;
2274
2312
  const msg = err instanceof Error ? err.message : String(err);
2275
2313
  console.log(chalk4.red(`
2276
- ${msg}`));
2277
- if (err instanceof Error && err.stack) {
2278
- console.log(chalk4.dim(` ${err.stack.split("\n").slice(1, 3).join("\n ")}`));
2314
+ ${msg}
2315
+ `));
2316
+ if (!msg.includes("Possible fixes")) {
2317
+ console.log(chalk4.dim(" Possible fixes:"));
2318
+ console.log(chalk4.dim(" 1. Run: claude login"));
2319
+ console.log(chalk4.dim(" 2. Check your internet connection"));
2320
+ console.log(chalk4.dim(" 3. Run: forge doctor\n"));
2279
2321
  }
2280
2322
  this.stopChatListener();
2281
2323
  return { success: false, plan: null, errors: [`Plan: ${msg}`] };
@@ -3034,4 +3076,4 @@ export {
3034
3076
  validateConfig,
3035
3077
  loadAndValidateConfig
3036
3078
  };
3037
- //# sourceMappingURL=chunk-P5CLBIGQ.js.map
3079
+ //# sourceMappingURL=chunk-M5MX6CAQ.js.map