code-puppy 0.0.67__py3-none-any.whl → 0.0.69__py3-none-any.whl
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.
- code_puppy/command_line/meta_command_handler.py +19 -11
- code_puppy/config.py +12 -0
- code_puppy/main.py +44 -3
- code_puppy/models.json +7 -0
- {code_puppy-0.0.67.data → code_puppy-0.0.69.data}/data/code_puppy/models.json +7 -0
- {code_puppy-0.0.67.dist-info → code_puppy-0.0.69.dist-info}/METADATA +1 -1
- {code_puppy-0.0.67.dist-info → code_puppy-0.0.69.dist-info}/RECORD +10 -10
- {code_puppy-0.0.67.dist-info → code_puppy-0.0.69.dist-info}/WHEEL +0 -0
- {code_puppy-0.0.67.dist-info → code_puppy-0.0.69.dist-info}/entry_points.txt +0 -0
- {code_puppy-0.0.67.dist-info → code_puppy-0.0.69.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,14 +12,18 @@ from code_puppy.command_line.utils import make_directory_table
|
|
|
12
12
|
META_COMMANDS_HELP = """
|
|
13
13
|
[bold magenta]Meta Commands Help[/bold magenta]
|
|
14
14
|
~help, ~h Show this help message
|
|
15
|
-
~cd
|
|
16
|
-
~codemap
|
|
15
|
+
~cd <dir> Change directory or show directories
|
|
16
|
+
~codemap <dir> Show code structure for <dir>
|
|
17
17
|
~m <model> Set active model
|
|
18
|
-
~
|
|
18
|
+
~motd Show the latest message of the day (MOTD)
|
|
19
|
+
~show Show puppy config key-values
|
|
20
|
+
~set Set puppy config key-values
|
|
19
21
|
~<unknown> Show unknown meta command warning
|
|
20
22
|
"""
|
|
21
23
|
|
|
22
24
|
|
|
25
|
+
from code_puppy.command_line.motd import print_motd
|
|
26
|
+
|
|
23
27
|
def handle_meta_command(command: str, console: Console) -> bool:
|
|
24
28
|
"""
|
|
25
29
|
Handle meta/config commands prefixed with '~'.
|
|
@@ -27,6 +31,10 @@ def handle_meta_command(command: str, console: Console) -> bool:
|
|
|
27
31
|
"""
|
|
28
32
|
command = command.strip()
|
|
29
33
|
|
|
34
|
+
if command.strip().startswith("~motd"):
|
|
35
|
+
print_motd(console, force=True)
|
|
36
|
+
return True
|
|
37
|
+
|
|
30
38
|
# ~codemap (code structure visualization)
|
|
31
39
|
if command.startswith("~codemap"):
|
|
32
40
|
from code_puppy.tools.ts_code_map import make_code_map
|
|
@@ -67,20 +75,20 @@ def handle_meta_command(command: str, console: Console) -> bool:
|
|
|
67
75
|
|
|
68
76
|
if command.strip().startswith("~show"):
|
|
69
77
|
from code_puppy.command_line.model_picker_completion import get_active_model
|
|
70
|
-
from code_puppy.config import get_owner_name, get_puppy_name
|
|
71
|
-
|
|
78
|
+
from code_puppy.config import get_owner_name, get_puppy_name, get_yolo_mode, get_message_history_limit
|
|
72
79
|
puppy_name = get_puppy_name()
|
|
73
80
|
owner_name = get_owner_name()
|
|
74
81
|
model = get_active_model()
|
|
75
|
-
from code_puppy.config import get_yolo_mode
|
|
76
|
-
|
|
77
82
|
yolo_mode = get_yolo_mode()
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
msg_limit = get_message_history_limit()
|
|
84
|
+
console.print(f'''[bold magenta]🐶 Puppy Status[/bold magenta]
|
|
85
|
+
|
|
86
|
+
[bold]puppy_name:[/bold] [cyan]{puppy_name}[/cyan]
|
|
80
87
|
[bold]owner_name:[/bold] [cyan]{owner_name}[/cyan]
|
|
81
88
|
[bold]model:[/bold] [green]{model}[/green]
|
|
82
|
-
[bold]YOLO_MODE:[/bold] {
|
|
83
|
-
|
|
89
|
+
[bold]YOLO_MODE:[/bold] {'[red]ON[/red]' if yolo_mode else '[yellow]off[/yellow]'}
|
|
90
|
+
[bold]message_history_limit:[/bold] Keeping last [cyan]{msg_limit}[/cyan] messages in context
|
|
91
|
+
''')
|
|
84
92
|
return True
|
|
85
93
|
|
|
86
94
|
if command.startswith("~set"):
|
code_puppy/config.py
CHANGED
|
@@ -57,6 +57,18 @@ def get_owner_name():
|
|
|
57
57
|
return get_value("owner_name") or "Master"
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
def get_message_history_limit():
|
|
61
|
+
"""
|
|
62
|
+
Returns the user-configured message truncation limit (for remembering context),
|
|
63
|
+
or 40 if unset or misconfigured.
|
|
64
|
+
Configurable by 'message_history_limit' key.
|
|
65
|
+
"""
|
|
66
|
+
val = get_value("message_history_limit")
|
|
67
|
+
try:
|
|
68
|
+
return max(1, int(val)) if val else 40
|
|
69
|
+
except (ValueError, TypeError):
|
|
70
|
+
return 40
|
|
71
|
+
|
|
60
72
|
# --- CONFIG SETTER STARTS HERE ---
|
|
61
73
|
def get_config_keys():
|
|
62
74
|
"""
|
code_puppy/main.py
CHANGED
|
@@ -4,6 +4,7 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
6
|
from dotenv import load_dotenv
|
|
7
|
+
from pydantic_ai.messages import ToolCallPart, ToolReturnPart
|
|
7
8
|
from rich.console import Console, ConsoleOptions, RenderResult
|
|
8
9
|
from rich.markdown import CodeBlock, Markdown
|
|
9
10
|
from rich.syntax import Syntax
|
|
@@ -111,6 +112,12 @@ async def interactive_mode(history_file_path: str) -> None:
|
|
|
111
112
|
from code_puppy.command_line.meta_command_handler import META_COMMANDS_HELP
|
|
112
113
|
|
|
113
114
|
console.print(META_COMMANDS_HELP)
|
|
115
|
+
# Show MOTD if user hasn't seen it after an update
|
|
116
|
+
try:
|
|
117
|
+
from code_puppy.command_line.motd import print_motd
|
|
118
|
+
print_motd(console, force=False)
|
|
119
|
+
except Exception as e:
|
|
120
|
+
console.print(f'[yellow]MOTD error: {e}[/yellow]')
|
|
114
121
|
|
|
115
122
|
# Check if prompt_toolkit is installed
|
|
116
123
|
try:
|
|
@@ -224,10 +231,44 @@ async def interactive_mode(history_file_path: str) -> None:
|
|
|
224
231
|
for m in new_msgs
|
|
225
232
|
if not (isinstance(m, dict) and m.get("role") == "system")
|
|
226
233
|
]
|
|
227
|
-
# 2. Append to existing history and keep only the most recent
|
|
234
|
+
# 2. Append to existing history and keep only the most recent set by config
|
|
235
|
+
from code_puppy.config import get_message_history_limit
|
|
228
236
|
message_history.extend(filtered)
|
|
229
|
-
|
|
230
|
-
|
|
237
|
+
|
|
238
|
+
# --- BEGIN GROUP-AWARE TRUNCATION LOGIC ---
|
|
239
|
+
limit = get_message_history_limit()
|
|
240
|
+
if len(message_history) > limit:
|
|
241
|
+
def group_by_tool_call_id(msgs):
|
|
242
|
+
grouped = {}
|
|
243
|
+
no_group = []
|
|
244
|
+
for m in msgs:
|
|
245
|
+
# Find all tool_call_id in message parts
|
|
246
|
+
tool_call_ids = set()
|
|
247
|
+
for part in getattr(m, 'parts', []):
|
|
248
|
+
if hasattr(part, 'tool_call_id') and part.tool_call_id:
|
|
249
|
+
tool_call_ids.add(part.tool_call_id)
|
|
250
|
+
if tool_call_ids:
|
|
251
|
+
for tcid in tool_call_ids:
|
|
252
|
+
grouped.setdefault(tcid, []).append(m)
|
|
253
|
+
else:
|
|
254
|
+
no_group.append(m)
|
|
255
|
+
return grouped, no_group
|
|
256
|
+
|
|
257
|
+
grouped, no_group = group_by_tool_call_id(message_history)
|
|
258
|
+
# Flatten into groups or singletons
|
|
259
|
+
grouped_msgs = list(grouped.values()) + [[m] for m in no_group]
|
|
260
|
+
# Flattened history (latest groups/singletons last, trunc to N messages total),
|
|
261
|
+
# but always keep complete tool_call_id groups together
|
|
262
|
+
truncated = []
|
|
263
|
+
count = 0
|
|
264
|
+
for group in reversed(grouped_msgs):
|
|
265
|
+
if count + len(group) > limit:
|
|
266
|
+
break
|
|
267
|
+
truncated[:0] = group # insert at front
|
|
268
|
+
count += len(group)
|
|
269
|
+
message_history = truncated
|
|
270
|
+
# --- END GROUP-AWARE TRUNCATION LOGIC ---
|
|
271
|
+
|
|
231
272
|
|
|
232
273
|
if agent_response and agent_response.awaiting_user_input:
|
|
233
274
|
console.print(
|
code_puppy/models.json
CHANGED
|
@@ -59,5 +59,12 @@
|
|
|
59
59
|
"api_version": "2024-12-01-preview",
|
|
60
60
|
"api_key": "$AZURE_OPENAI_API_KEY",
|
|
61
61
|
"azure_endpoint": "$AZURE_OPENAI_ENDPOINT"
|
|
62
|
+
},
|
|
63
|
+
"Llama-4-Scout-17B-16E-Instruct": {
|
|
64
|
+
"type": "azure_openai",
|
|
65
|
+
"name": "Llama-4-Scout-17B-16E-Instruct",
|
|
66
|
+
"api_version": "2024-12-01-preview",
|
|
67
|
+
"api_key": "$AZURE_OPENAI_API_KEY",
|
|
68
|
+
"azure_endpoint": "$AZURE_OPENAI_ENDPOINT"
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -59,5 +59,12 @@
|
|
|
59
59
|
"api_version": "2024-12-01-preview",
|
|
60
60
|
"api_key": "$AZURE_OPENAI_API_KEY",
|
|
61
61
|
"azure_endpoint": "$AZURE_OPENAI_ENDPOINT"
|
|
62
|
+
},
|
|
63
|
+
"Llama-4-Scout-17B-16E-Instruct": {
|
|
64
|
+
"type": "azure_openai",
|
|
65
|
+
"name": "Llama-4-Scout-17B-16E-Instruct",
|
|
66
|
+
"api_version": "2024-12-01-preview",
|
|
67
|
+
"api_key": "$AZURE_OPENAI_API_KEY",
|
|
68
|
+
"azure_endpoint": "$AZURE_OPENAI_ENDPOINT"
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
code_puppy/__init__.py,sha256=-ANvE6Xe5NlWDIRCIfL1x-rgtCZ6zM2Ye9NphFoULSY,82
|
|
2
2
|
code_puppy/agent.py,sha256=QRBid--LcJv8fbhS9u6Foavgt3jI1B-K_1Arv-kXQsc,3420
|
|
3
3
|
code_puppy/agent_prompts.py,sha256=DnPNubiFtD6Ot76cIsxedJEaEVYS5AaxR3JWJM5nXNg,6925
|
|
4
|
-
code_puppy/config.py,sha256=
|
|
5
|
-
code_puppy/main.py,sha256=
|
|
4
|
+
code_puppy/config.py,sha256=YUzcEpR6roYnvbfdZRtw4G707sLmUuCTH2LU0qmfMvY,4316
|
|
5
|
+
code_puppy/main.py,sha256=K-xK1utskaGoH1_e30GLDayLqFse0-HmbZ5wvMDXGLA,12426
|
|
6
6
|
code_puppy/model_factory.py,sha256=jZH96zE5GMTK3RWjUpZB4HjbSO3fSaAzjRoQh8Y8lfg,7711
|
|
7
|
-
code_puppy/models.json,sha256=
|
|
7
|
+
code_puppy/models.json,sha256=AY1dcFd3bMFaJBjU_u-PjsrnmcKbjjtGhjL3uYfqpW8,1692
|
|
8
8
|
code_puppy/session_memory.py,sha256=4sgAAjbXdLSi8hETpd56tgtrG6hqMUuZWDlJOu6BQjA,2735
|
|
9
9
|
code_puppy/version_checker.py,sha256=aRGulzuY4C4CdFvU1rITduyL-1xTFsn4GiD1uSfOl_Y,396
|
|
10
10
|
code_puppy/command_line/__init__.py,sha256=y7WeRemfYppk8KVbCGeAIiTuiOszIURCDjOMZv_YRmU,45
|
|
11
11
|
code_puppy/command_line/file_path_completion.py,sha256=gw8NpIxa6GOpczUJRyh7VNZwoXKKn-yvCqit7h2y6Gg,2931
|
|
12
|
-
code_puppy/command_line/meta_command_handler.py,sha256=
|
|
12
|
+
code_puppy/command_line/meta_command_handler.py,sha256=kP57BU7gH23ten0CHX1XmrCbe89WFxoHzz6ddeRGrCE,6121
|
|
13
13
|
code_puppy/command_line/model_picker_completion.py,sha256=NkyZZG7IhcVWSJ3ADytwCA5f8DpNeVs759Qtqs4fQtY,3733
|
|
14
14
|
code_puppy/command_line/prompt_toolkit_completion.py,sha256=_gP0FIOgHDNHTTWLNL0XNzr6sO0ISe7Mec1uQNo9kcM,8337
|
|
15
15
|
code_puppy/command_line/utils.py,sha256=7eyxDHjPjPB9wGDJQQcXV_zOsGdYsFgI0SGCetVmTqE,1251
|
|
@@ -20,9 +20,9 @@ code_puppy/tools/file_modifications.py,sha256=d0fC2CCnkmv0kEJ8kvKTuUMTww3S_mgF06
|
|
|
20
20
|
code_puppy/tools/file_operations.py,sha256=xqj7MiK6sGTaC8NMrMRTybWlXG32S-DjybqJtnufRcI,11715
|
|
21
21
|
code_puppy/tools/ts_code_map.py,sha256=-CXLzFxFMefoYYdWxfPwFugZhkfVxdiftGb3LZnEttk,17567
|
|
22
22
|
code_puppy/tools/web_search.py,sha256=sA2ierjuuYA517-uhb5s53SgeVsyOe1nExoZsrU1Fps,1284
|
|
23
|
-
code_puppy-0.0.
|
|
24
|
-
code_puppy-0.0.
|
|
25
|
-
code_puppy-0.0.
|
|
26
|
-
code_puppy-0.0.
|
|
27
|
-
code_puppy-0.0.
|
|
28
|
-
code_puppy-0.0.
|
|
23
|
+
code_puppy-0.0.69.data/data/code_puppy/models.json,sha256=AY1dcFd3bMFaJBjU_u-PjsrnmcKbjjtGhjL3uYfqpW8,1692
|
|
24
|
+
code_puppy-0.0.69.dist-info/METADATA,sha256=LKOp_Y_1D5wKqK0SSYyaenHHaHfnTLg5q7fFTxuFdww,4955
|
|
25
|
+
code_puppy-0.0.69.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
26
|
+
code_puppy-0.0.69.dist-info/entry_points.txt,sha256=d8YkBvIUxF-dHNJAj-x4fPEqizbY5d_TwvYpc01U5kw,58
|
|
27
|
+
code_puppy-0.0.69.dist-info/licenses/LICENSE,sha256=31u8x0SPgdOq3izJX41kgFazWsM43zPEF9eskzqbJMY,1075
|
|
28
|
+
code_puppy-0.0.69.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|