77 Commits

Author SHA1 Message Date
NCBM 59017fd61b core/agent: synthetic_tool nag uses real todo_list render body
developer/user keep OPEN WORK prose; synthetic_tool injects forged
todo_list call with stack.render() only so the result matches a real
tool output.
2026-07-20 04:10:21 +08:00
NCBM 2e6cb3834a core/agent: drop system todo nag; emit events for synthetic_tool
Remove system strategy (legacy maps to developer). synthetic_tool still
forges the call but uses real stack text as the tool result, and now
yields ToolCall/Result events so the CLI flushes and does not glue nag
text to the next assistant stream.
2026-07-20 03:55:50 +08:00
NCBM f6d14ed549 core/agent: configurable todo nag strategies
Add [agent] todo_nag_strategy: developer (default), system, user,
synthetic_tool (forged todo_list pair), or none. Shared inject helper
used for turn-start and end-of-turn nags; CLI wires agent config.
2026-07-20 03:33:02 +08:00
NCBM a4ab11c9a2 core/agent: stronger open-work signals in todo stack prompts
Split tags: [TODO OPEN WORK] for pending/in_progress (undone work) vs
[TODO HYGIENE] for all-terminal leftover groups. End-of-turn review lists
open titles; tool docs stress open items as unfinished work.
2026-07-20 03:17:44 +08:00
NCBM d6616d0da3 core/tools: timed human allow for denylisted commands
Denylist hits ask the user (default deny, timeout) instead of only hard
rejecting when a policy hook is installed. Independent of YOLO soft-confirm;
session grants skip re-prompt for the same basename. CLI installs the hook
via install_cli_limit_hooks.
2026-07-20 03:02:34 +08:00
NCBM a677e06af4 core/tools: add ask_into_pty for human-local PTY input
Prompt the human (optional no-echo secret) and write only to the PTY.
Tool results never include the answer so secrets stay off external APIs.
Empty/Ctrl-C cancel without writing; submit defaults to trailing newline.
2026-07-20 02:47:19 +08:00
NCBM 58ff646034 core/cli: config open via VISUAL/EDITOR or system default
Prefer $VISUAL then $EDITOR (blocking). Without either, fall back to
xdg-open / open / startfile (non-blocking) for config paths only.
/edit stays blocking-only so the temp buffer can be re-read.
2026-07-19 22:33:02 +08:00
NCBM d528f65c4c core/tools: edit_replace max_replaces and richer match messages
Default still replaces first match only. Report how many matches were
found, how many replaced, and remaining hits so agents can raise
max_replaces or narrow old_string.
2026-07-19 21:55:16 +08:00
NCBM 0ec0d542e8 core/cli: keep database url :memory:; default url None
Unset/empty url still maps to durable user-data chat.db.
Explicit :memory: is not rewritten; CLI warns when not quiet.
DatabaseConfig.url default is None; engine treats None as memory.
2026-07-19 21:38:21 +08:00
NCBM e1e4df0f3f core/agent: strengthen todo prompts when stack not empty
Inject turn-start [TODO REMINDER] for non-empty stacks; rewrite end-of-turn
[TODO OPEN] copy so open items read as unfinished work. needs_review now
always true while open items remain (even if todo_* ran this turn); terminal-only
stacks still need review if untouched. Update tool docs and tests.
2026-07-19 20:34:01 +08:00
NCBM f51d11d46f core/tools/process: add run_command_batch with pipe_out and mix_stderr 2026-07-19 02:46:21 +08:00
NCBM 020e9215bf tools: new_temporary_workspace with cross-platform allowlist
Create scratch dirs under system temp (tempfile), allow absolute paths
under them without rebinding the project workspace or session. Cleanup
owned temps on chat exit. Cap 16 concurrent temps; sanitize prefix.
2026-07-18 18:16:06 +08:00
NCBM b1a8c23582 core/tools: soft-confirm shells, REPLs, and python/bash -c one-liners
classify_danger prompts on interactive shell/runtime launches and any -c
code (with argv + snippet preview). Confirm deny can attach a user comment
for the model. Restores ToolRegistry.execute after WIP breakage.
2026-07-18 17:41:44 +08:00
NCBM edd54a427c core/tools/process: drop host TTY restore; rely on CSI sanitize only 2026-07-18 16:26:23 +08:00
NCBM 29230af911 core/tools/process: split write_pty (literal) vs write_pty_keys 2026-07-18 15:46:11 +08:00
NCBM 4ff03d8135 core/tools/process: host TTY restore, sanitize read_pty CSI, write_pty key escapes 2026-07-18 15:20:36 +08:00
NCBM a7166d863b core/agent: todo stack is LIFO of task groups, not per-task push
push(titles) creates one group of siblings; pop removes the whole top
group. Matches breakdown: push[T1,T2] → push[T1.1,T1.2] → pop → push[T2.1].
2026-07-18 14:47:38 +08:00
NCBM 9b38a3b333 ci/lint: prek commit gateway (ruff check/format + basedpyright)
Add prek.toml so git commit runs ruff-pre-commit (fix then format) and
pdm-based basedpyright. Document install/install-hook; clear type warnings
that made basedpyright exit non-zero under recommended mode.
2026-07-18 14:10:04 +08:00
NCBM 7f49c47105 core/agent: todo is a real LIFO stack (not a queue or frame list)
TOP = last element only for pop; multi-push puts first title on top for DFS
breakdown. Dropped nested-frame model; migrate old frames JSON to flat stack.
2026-07-18 13:20:37 +08:00
NCBM c95d1df028 core/agent: nested todo frames for hierarchical push/pop breakdown
push of one or more titles opens a new frame (siblings at one depth);
pop leaves the frame. Supports T1,T2 → T1.1,T1.2 → pop → T2.1 pattern.
Legacy flat session JSON migrates to a single root frame.
2026-07-18 13:15:57 +08:00
NCBM 596af1ea1b core/agent+tools: session todo/task stack with review nag
Sub-task stack stored on session.todo_stack; model tools todo_*; slash
/todos for human ops; agent loop injects a review user message when open
todos exist and no todo_* tool ran this turn. Stack carries across /compact.
2026-07-18 01:59:13 +08:00
NCBM 57236937eb docs: model --persist and tree skip_dirs filtering 2026-07-18 01:32:06 +08:00
NCBM a282231082 docs+ci: document ruff format --check; format app.py 2026-07-17 17:57:00 +08:00
NCBM 39acd5967e tools/chat: rename tools to ask_user_line, ask_user_choice, ask_user_form
Model-facing names via @tool(name=…); Python symbols unchanged.
2026-07-17 15:36:29 +08:00
NCBM 18008de7f1 docs: document /yolo and --yes soft-confirm overrides 2026-07-17 14:55:34 +08:00
NCBM 074a3313ce core/config: default OpenAI provider_tools to web_search
Omitted provider_tools enables web_search; use [] to disable hosted tools.
2026-07-15 21:43:39 +08:00
NCBM 16992be743 core/config+agent: OpenAI provider_tools for hosted Responses tools
Merge opaque tool dicts (web_search, file_search, …) into POST /responses; local ToolRegistry unchanged.
2026-07-15 21:16:05 +08:00
NCBM 5dd102a016 core/agent: route OpenAI provider through Responses API
ResponsesChatClient adapts chat-shaped agent history/tools to POST /responses; compat and DeepSeek unchanged.
2026-07-15 20:59:47 +08:00
NCBM 38edc09854 core/lmproto: move Responses API into openai package
openai_compatible stays chat-completions-only; OpenAI provider uses lmproto.openai.OpenAIClient.
2026-07-15 20:52:17 +08:00
NCBM 3e20b1559c core/lmproto: add OpenAI Responses API models and client
POST/GET/DELETE /responses with stream events; helpers for output_text and function_call items.
2026-07-15 20:43:11 +08:00
NCBM c466d09173 core/process: cross-platform PTY via backend and pywinpty
POSIX openpty/fork and Windows ConPTY; win32 marker dep plus typings stub.
2026-07-15 20:01:43 +08:00
NCBM cf7d331634 core/agent: checkpoint tool rounds so /retry does not redo side effects
After each completed assistant+tool batch, persist and keep that prefix on
failure. Rollback only unfinished assistant/stream suffix. pending_retry
and /retry also apply when history ends with tool results (continue model
without re-executing tools).
2026-07-15 15:01:15 +08:00
NCBM 64d288a9b1 core/memory+cli: remember session LLM; readline prompts
Store provider_name/model on sessions (SQLite migrate); restore on
resume and persist on create//model//provider. Startup prefers session
selection over re-asking. ask/choose and provider/model pick use
readline with Tab completion when available.
2026-07-15 14:12:10 +08:00
NCBM 2052967824 core/config: default DeepSeek models v4-flash and v4-pro
When preset deepseek omits models, seed deepseek-v4-flash and
deepseek-v4-pro as text-capable entries for selection and docs.
2026-07-15 13:57:29 +08:00
NCBM fb61f6bc32 docs: README, example config, and Phase G completion notes
Document install, config, chat/one-shot, slash commands, workspace and
safety model. Add doc/plyngent.example.toml; refresh CLAUDE and architecture.
2026-07-15 13:51:11 +08:00
NCBM 0dc5c876ee core/process+cli: PTY hardening and config/log polish
Mark PTY master FD non-inheritable; run read_pty/close_pty via to_thread;
close_all PTY sessions on chat exit. Add --log-level; clearer invalid
TOML errors. Keep export/status free of provider secrets.
2026-07-15 13:48:58 +08:00
NCBM 723fa85879 core/cli: one-shot chat with -p/stdin and exit codes
Add plyngent chat -p/--prompt (and non-TTY stdin), --stream/--no-stream,
--yes, --quiet. Non-interactive mode uses NonInteractiveBackend and
disables limit prompts. Exit codes: 0 ok, 1 config, 2 cancelled, 3 failed.
2026-07-15 13:33:18 +08:00
NCBM ec5e6ab0f4 core/cli: multiline \"\"\" input and /edit via EDITOR
Add triple-quote block messages in the REPL and /edit to compose a turn
in $EDITOR (temp file). Empty multiline or empty edit cancels.
2026-07-15 13:29:00 +08:00
NCBM 5b0c9be90b core/cli: Click slash registry with awaitlet bridge
Register REPL slash commands as a Click Group (params, UsageError, help).
Dispatch via awaitlet.async_def so sync command bodies can awaitlet()
async memory/confirm work. Completer and /help derive from the registry.
2026-07-15 13:03:55 +08:00
NCBM 9d05988245 core/memory+cli: session rename, delete, and export
Add MemoryStore rename/delete with explicit message cleanup. Slash
commands /rename, /delete (confirm), /export md|json write transcripts
from DB; deleting the current session starts a fresh empty one.
2026-07-15 12:26:52 +08:00
NCBM 04d421a4b5 core/agent+cli: reasoning deltas, /stream and /verbose
Decode and stream reasoning_content as ReasoningDeltaEvent; keep it on
assistant messages. CLI shows dim reasoning, toggles stream/verbose, and
prints full tool results when verbose.
2026-07-15 12:11:19 +08:00
NCBM f77ac7eea8 core/prompting+tools: shared ask/choose/form and chat tools
Add process-wide prompting backends for interactive human I/O; wire CLI
limit/confirm/workspace prompts through it. Expose ask_user, choose_user,
and form_user under tools/chat and include them in DEFAULT_TOOLS.
2026-07-15 11:51:44 +08:00
NCBM 6e9e034de4 core/agent: derive pending_retry_text from trailing user message
Drop stored pending field; incomplete turns are just history ending in
UserChatMessage. Compact seeds use an assistant summary so they are not
mistaken for retryable orphans.
2026-07-15 11:27:29 +08:00
NCBM 00a8ed3a9c core/agent+cli: persist user immediately; /retry reuses DB turn
Keep incomplete user messages in memory/DB; roll back only
assistant/tool on failure. /retry and resume of orphan-user sessions
re-run without duplicating the user message.
2026-07-15 11:21:01 +08:00
NCBM b1223c8189 core/agent: calibrate soft-compact with last-request prompt_tokens
After the first model call, scale char-based token estimates by
API/resolved prompt size so budget checks track near-real tokens.
/compact uses the same calibration when available.
2026-07-15 11:11:15 +08:00
NCBM c9e805f38d core/agent+cli: treat last-request prompt_tokens as context size
context_tokens prefers API usage from the last model call; char est.
is only a pre-call fallback. Clarify billed turn/session totals in UI.
2026-07-15 11:07:52 +08:00
NCBM a61b536243 core/agent+cli: separate last-request usage from billed turn totals
Tool-loop rounds re-send history, so summed prompt tokens are billing
not context size. Track last_request_usage and label turn/session as
billed; clarify /status and end-of-turn lines.
2026-07-15 11:04:41 +08:00
NCBM 58041c6c87 core/agent+config: soft context budget in estimated tokens
Replace max_context_chars with max_context_tokens (default 200k est.
tokens via char/4); compact and /status use the token budget.
2026-07-15 10:58:01 +08:00
NCBM d2cab4198b core/cli: show estimated context tokens and usage source tags
/status adds context_tokens~=(est); docs note api/estimate/mixed labels.
2026-07-15 10:52:58 +08:00
NCBM d81e168f3b core/agent+cli: accumulate usage and show on turn end /status
ChatAgent tracks session_usage and last_turn_usage; CLI prints a quiet
token line after successful turns and includes totals in /status.
2026-07-15 10:48:07 +08:00