golem-cc 0.1.8 → 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 +50 -29
  2. package/package.json +1 -1
package/bin/golem CHANGED
@@ -236,34 +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
- # Load agent prompt if available
240
- if [[ -f ".golem/agents/spec-builder.md" ]]; then
241
- spec_prompt=$(sed '1,/^---$/d' .golem/agents/spec-builder.md | sed '1,/^---$/d')
242
- fi
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
243
246
 
244
- local tmp_file=$(mktemp)
245
- trap "rm -f $tmp_file" EXIT
247
+ output=$(claude "$@" 2>"$tmp_err")
248
+ exit_code=$?
246
249
 
247
- # Get initial response with session ID
248
- claude -p \
249
- --dangerously-skip-permissions \
250
- --output-format json \
251
- --append-system-prompt "$spec_prompt" \
252
- "Start the spec-building conversation. Ask what I'm building." \
253
- > "$tmp_file" 2>/dev/null
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
254
262
 
255
- local session_id=$(jq -r '.session_id // empty' "$tmp_file" 2>/dev/null)
256
- local response=$(jq -r '.result // empty' "$tmp_file" 2>/dev/null)
263
+ echo "$output"
264
+ return 0
265
+ }
257
266
 
258
- if [[ -z "$session_id" ]]; then
259
- echo -e "${RED}Failed to start session. Make sure Claude CLI is working.${NC}"
267
+ # First message - starts a new session
268
+ echo -e "${CYAN}Claude:${NC}"
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}"
260
272
  return 1
261
273
  fi
262
-
263
- echo -e "${CYAN}Claude:${NC} $response"
264
274
  echo ""
265
275
 
266
276
  # Conversation loop
277
+ local restart_needed=false
267
278
  while true; do
268
279
  echo -ne "${GREEN}You:${NC} "
269
280
  read -r user_input
@@ -276,17 +287,27 @@ Keep responses concise. Ask one question at a time."
276
287
  break
277
288
  }
278
289
 
279
- # Continue conversation with session ID
280
- claude -p \
281
- --dangerously-skip-permissions \
282
- --output-format json \
283
- --resume "$session_id" \
284
- "$user_input" \
285
- > "$tmp_file" 2>/dev/null
286
-
287
- response=$(jq -r '.result // empty' "$tmp_file" 2>/dev/null)
288
290
  echo ""
289
- echo -e "${CYAN}Claude:${NC} $response"
291
+ echo -e "${CYAN}Claude:${NC}"
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
290
311
  echo ""
291
312
  done
292
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "golem-cc",
3
- "version": "0.1.8",
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"