golem-cc 0.1.9 → 0.1.10

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.
Files changed (2) hide show
  1. package/bin/golem +53 -5
  2. package/package.json +1 -1
package/bin/golem CHANGED
@@ -236,15 +236,45 @@ Spec file format (save to specs/{topic-name}.md):
236
236
 
237
237
  Keep responses concise. Ask one question at a time."
238
238
 
239
+ local tmp_err=$(mktemp)
240
+ trap "rm -f $tmp_err" EXIT
241
+
242
+ # Helper to run claude and handle errors
243
+ run_claude() {
244
+ local output
245
+ local exit_code
246
+
247
+ output=$(claude "$@" 2>"$tmp_err")
248
+ exit_code=$?
249
+
250
+ if [[ $exit_code -ne 0 ]] || grep -q "API Error" "$tmp_err" 2>/dev/null; then
251
+ local err_msg=$(cat "$tmp_err")
252
+ if [[ "$err_msg" == *"tool_use"* ]] || [[ "$err_msg" == *"invalid_request_error"* ]]; then
253
+ echo ""
254
+ echo -e "${YELLOW}Session corrupted. Starting fresh...${NC}"
255
+ echo ""
256
+ return 1
257
+ else
258
+ echo -e "${RED}Error: $err_msg${NC}"
259
+ return 1
260
+ fi
261
+ fi
262
+
263
+ echo "$output"
264
+ return 0
265
+ }
266
+
239
267
  # First message - starts a new session
240
268
  echo -e "${CYAN}Claude:${NC}"
241
- claude -p \
242
- --dangerously-skip-permissions \
243
- --append-system-prompt "$spec_prompt" \
244
- "Start the spec-building conversation. Ask what I'm building."
269
+ if ! run_claude -p --dangerously-skip-permissions --append-system-prompt "$spec_prompt" \
270
+ "Start the spec-building conversation. Ask what I'm building."; then
271
+ echo -e "${RED}Failed to start session${NC}"
272
+ return 1
273
+ fi
245
274
  echo ""
246
275
 
247
276
  # Conversation loop
277
+ local restart_needed=false
248
278
  while true; do
249
279
  echo -ne "${GREEN}You:${NC} "
250
280
  read -r user_input
@@ -259,7 +289,25 @@ Keep responses concise. Ask one question at a time."
259
289
 
260
290
  echo ""
261
291
  echo -e "${CYAN}Claude:${NC}"
262
- claude -p --continue --dangerously-skip-permissions "$user_input"
292
+ if ! run_claude -p --continue --dangerously-skip-permissions "$user_input"; then
293
+ # Session error - offer to restart
294
+ echo -e "${YELLOW}Would you like to start a new session? (y/n)${NC} "
295
+ read -r restart_choice
296
+ if [[ "$restart_choice" == "y" ]]; then
297
+ echo ""
298
+ echo -e "${BLUE}Starting new session...${NC}"
299
+ echo -e "${DIM}Paste your previous context to continue where you left off.${NC}"
300
+ echo ""
301
+ echo -e "${CYAN}Claude:${NC}"
302
+ if ! run_claude -p --dangerously-skip-permissions --append-system-prompt "$spec_prompt" \
303
+ "Start the spec-building conversation. Ask what I'm building."; then
304
+ echo -e "${RED}Failed to start new session${NC}"
305
+ return 1
306
+ fi
307
+ else
308
+ echo -e "${DIM}Type 'done' to exit or try again${NC}"
309
+ fi
310
+ fi
263
311
  echo ""
264
312
  done
265
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "golem-cc",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Autonomous coding loop with Claude - structured specs, ralph loop execution, code simplification",
5
5
  "bin": {
6
6
  "golem-cc": "./bin/install.cjs"