clawtan 0.2.2 → 0.2.3

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/clawtan/cli.py +26 -12
  2. package/package.json +1 -1
package/clawtan/cli.py CHANGED
@@ -831,13 +831,8 @@ def cmd_wait(args):
831
831
  print(f"Waiting for players ({pj}/{np})...", file=sys.stderr)
832
832
  phase_shown = "lobby"
833
833
  else:
834
- cur = status.get("current_color", "?")
835
- if phase_shown != "turn" or cur != prev_current:
836
- print(f"Waiting for your turn (current: {cur})...", file=sys.stderr)
837
- phase_shown = "turn"
838
- prev_current = cur
839
-
840
834
  # Live action feed: detect and display new game actions
835
+ # (fetched BEFORE the waiting message so actions print in order)
841
836
  try:
842
837
  live_state = _get(f"/game/{game_id}")
843
838
  records = live_state.get("action_records", [])
@@ -860,6 +855,12 @@ def cmd_wait(args):
860
855
  except (APIError, Exception):
861
856
  pass
862
857
 
858
+ cur = status.get("current_color", "?")
859
+ if phase_shown != "turn" or cur != prev_current:
860
+ print(f"Waiting for your turn (current: {cur})...", file=sys.stderr)
861
+ phase_shown = "turn"
862
+ prev_current = cur
863
+
863
864
  # Our turn!
864
865
  if status.get("your_turn"):
865
866
  break
@@ -980,17 +981,30 @@ def cmd_act(args):
980
981
  except APIError as e:
981
982
  print(f"ERROR: {args.action} failed.", file=sys.stderr)
982
983
  if "not a valid action" in e.detail.lower():
983
- print(
984
- f" '{args.action}' is not available right now.",
985
- file=sys.stderr,
986
- )
987
- # Fetch current state to show what IS available
988
984
  try:
989
985
  state = _get(f"/game/{game_id}")
990
986
  prompt = state.get("current_prompt", "?")
991
987
  current = state.get("current_color", "?")
992
- print(f" Current turn: {current} | Prompt: {prompt}", file=sys.stderr)
993
988
  actions = state.get("current_playable_actions", [])
989
+
990
+ available_types = set()
991
+ for a in actions:
992
+ if isinstance(a, list) and len(a) > 1:
993
+ available_types.add(a[1])
994
+
995
+ if args.action in available_types:
996
+ val_str = json.dumps(value, separators=(",", ":")) if value is not None else "(none)"
997
+ print(
998
+ f" '{args.action}' is available, but the value {val_str} is not a valid option.",
999
+ file=sys.stderr,
1000
+ )
1001
+ else:
1002
+ print(
1003
+ f" '{args.action}' is not available right now.",
1004
+ file=sys.stderr,
1005
+ )
1006
+
1007
+ print(f" Current turn: {current} | Prompt: {prompt}", file=sys.stderr)
994
1008
  if actions:
995
1009
  _print_actions(actions, my_color=color, state=state)
996
1010
  print(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawtan",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "CLI for AI agents playing Settlers of Clawtan -- a lobster-themed Catan board game",
5
5
  "bin": {
6
6
  "clawtan": "./bin/clawtan.js"