MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / buddy_command_call

Function buddy_command_call

src/command_system/buddy_command.py:87–167  ·  view source on GitHub ↗

``/buddy`` command body. Parsing precedence (matches TS ``buddy.tsx:104-184``): 1. ``help`` / ``-h`` / ``--help`` → help text 2. ``status`` or any ``COMMON_INFO_ARGS`` entry (incl. ``?``) → status 3. ``mute`` / ``unmute`` → toggle + confirmation 4. any other non-empty arg → hel

(args: str, context: CommandContext)

Source from the content-addressed store, hash-verified

85
86
87def buddy_command_call(args: str, context: CommandContext) -> LocalCommandResult:
88 """``/buddy`` command body.
89
90 Parsing precedence (matches TS ``buddy.tsx:104-184``):
91
92 1. ``help`` / ``-h`` / ``--help`` → help text
93 2. ``status`` or any ``COMMON_INFO_ARGS`` entry (incl. ``?``) → status
94 3. ``mute`` / ``unmute`` → toggle + confirmation
95 4. any other non-empty arg → help text
96 5. empty arg + no companion → hatch
97 6. empty arg + companion exists → pet
98 """
99 arg = (args or '').strip().lower()
100
101 # Note: TS routes '?' to INFO (status), NOT HELP — preserve that mapping.
102 if arg in COMMON_HELP_ARGS:
103 return LocalCommandResult(type='text', value=_HELP_TEXT)
104
105 if arg in COMMON_INFO_ARGS:
106 companion = get_companion()
107 if companion is None:
108 return LocalCommandResult(
109 type='text',
110 value='No buddy hatched yet. Run /buddy to hatch one.',
111 )
112 return LocalCommandResult(
113 type='text',
114 value=(
115 f"{companion.name} is your {_title_case(companion.rarity)} "
116 f"{companion.species}. {companion.personality}"
117 ),
118 )
119
120 if arg in ('mute', 'unmute'):
121 muted = arg == 'mute'
122 _set_companion_muted(muted)
123 return LocalCommandResult(
124 type='text',
125 value=f"Buddy {'muted' if muted else 'unmuted'}.",
126 )
127
128 if arg != '':
129 return LocalCommandResult(type='text', value=_HELP_TEXT)
130
131 # Empty arg: hatch (first time) or pet (subsequent).
132 companion = get_companion()
133 if companion is None:
134 user_id = companion_user_id()
135 stored = create_stored_companion(user_id)
136 _save_companion(stored)
137 # Re-read with fresh bones merged for the species-name line.
138 companion = get_companion()
139 if companion is None:
140 # Defensive: should never happen — _save_companion succeeded.
141 return LocalCommandResult(
142 type='text', value='Failed to hatch companion (state error).',
143 )
144 return LocalCommandResult(

Calls 10

LocalCommandResultClass · 0.90
get_companionFunction · 0.90
companion_user_idFunction · 0.90
create_stored_companionFunction · 0.90
_get_default_managerFunction · 0.90
_title_caseFunction · 0.85
_set_companion_mutedFunction · 0.85
_save_companionFunction · 0.85
_pick_deterministicFunction · 0.70
set_globalMethod · 0.45