Commit Graph

196 Commits

Author SHA1 Message Date
NCBM 5d2f0c5539 core/cli: Rich markdown for assistant text at end of turn
Stream plain tokens; on TTY re-render with Rich. /markdown and PLYNGENT_PLAIN.
2026-07-15 22:21:18 +08:00
NCBM d267a5f869 ci/lint: apply ruff format and import sort fixes 2026-07-15 22:09:52 +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 84a83e0485 core/config: default OpenAI preset and model catalog
Missing preset becomes openai; omitted models seed gpt-5.4 / mini / nano.
2026-07-15 21:40:43 +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 1f75cde3dd core/agent: clear basedpyright warnings on Responses adapter 2026-07-15 21:01:57 +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 61582ffd7d scripts: install Windows Python via Wine uv and full ci check
Short WIN_PYTHON request under wine uv.exe; check/test/ci cover ruff, basedpyright, pytest.
2026-07-15 20:20:25 +08:00
NCBM fbba2c2a14 core/tools+test: make process and path checks Windows-portable
Use sys.executable for process tests; normalize denylist/glob paths; skip readline when missing.
2026-07-15 20:20:25 +08:00
NCBM e1547a242c scripts: portable Wine + uv + PDM helpers for Windows checks
Isolated project-view setup without touching the host venv; typings linked for basedpyright.
2026-07-15 20:01:54 +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 611147b0a5 core/config+cli: recover empty-models providers via models()
Keep empty models as recoverable; promote to ready after remote list or --model.
2026-07-15 17:32:10 +08:00
NCBM 6bd80cb915 core/cli: /models and remote catalog for model selection
Cache GET /models, merge with config ids for Tab and choose; free-form model ids allowed.
2026-07-15 17:32:04 +08:00
NCBM e1ea43cb8f core/lmproto: add OpenAI-compatible models() list API
Decode GET /models into ModelsResponse and return sorted unique ids.
2026-07-15 17:31:57 +08:00
NCBM 4ea3362058 project: add MIT License file 2026-07-15 15:37:37 +08:00
NCBM 69a8545141 ci: add GitHub Actions for checks and PyPI release
PDM-based CI on 3.14 (ruff, basedpyright, pytest); tag publish without git-cliff.
2026-07-15 15:34:08 +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 54712b541a core/cli: /config opens plyngent.toml and reloads
Add slash /config to edit the active config path in $EDITOR, then reload
providers/agent settings while keeping a valid provider/model selection.
2026-07-15 14:52:19 +08:00
NCBM 95df11713d core/agent+config: configurable compact prompts
Add agent config compact_system_prompt, compact_user_prefix, and
compact_seed_text; wire through summarize and seed messages. Fix default
user prefix to include {transcript}; use safe seed substitution so braces
in summaries do not break formatting.
2026-07-15 14:45:12 +08:00
NCBM 9cc2216807 core/lmproto: allow null logprobs and usage on stream chunks
Providers send logprobs=null (and sometimes usage=null) on SSE choices;
accept None so decode does not fail mid-stream.
2026-07-15 14:23:23 +08:00
NCBM 366752efb9 core/lmproto: allow null content on stream deltas
OpenAI-compatible and DeepSeek SSE chunks often set content and
reasoning_content to null; accept None so decode does not fail mid-stream.
2026-07-15 14:21:50 +08:00
NCBM 553d491cbc core/config+cli: empty models are bad; prompt model on provider switch
Reject providers with no models into bad_providers and warn with reasons
on chat/providers. When /provider changes and the current model is not
listed, prompt for a new model (keep it when still supported).
2026-07-15 14:17:34 +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 cc298c6cd2 core/runtime: DeepSeek default base URL without /v1
Use https://api.deepseek.com as the empty-url default for deepseek preset.
2026-07-15 13:58:17 +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 3a0d9ac3cc core/cli: drive Tab completion from Click ParamTypes
Add shell_complete on OnOff/export/provider/model/help param types and
complete_slash_args so readline no longer keeps a parallel arg table.
2026-07-15 13:20:53 +08:00
NCBM 00c3350225 core/cli: clearer /stream /tools /verbose help text
Use metavar [on|off] and document default/effect so /help stream is
readable without guessing ENABLED.
2026-07-15 13:17:51 +08:00
NCBM ffab066cab core/cli: drop Click --help from slash commands
Slash commands use add_help_option=False and empty options_metavar so
/help shows Usage: /history [N] without a fake Options/--help section.
2026-07-15 13:14:47 +08:00
NCBM 5e016c012b core/cli: fix /help command usage line and help Tab completion
Use a standalone Click context so /help compact shows Usage: /compact,
not nested under help. Complete /help <cmd> from the slash registry.
2026-07-15 13:09:24 +08:00
NCBM 972bcd78ee ci/typecheck: clear slash.py basedpyright warnings
Raise BadParameter instead of fail()+return; drop unnecessary pyright ignore.
2026-07-15 13:06:21 +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 e566da596b ci/typecheck: cast JSON parses; drop mypy-style type ignores
Narrow chat tool JSON with typing.cast; remove obsolete type: ignore
comments that basedpyright does not treat as pyright suppresses.
2026-07-15 11:54:26 +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 aaf7fe8e7b ci/lint: ruff format pass and fix compact seed test typing
Apply pending ruff format; narrow AssistantChatMessage.content before
membership checks so basedpyright accepts Unset|None unions.
2026-07-15 11:36:01 +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 6bdf7ea283 core/agent: always emit UsageEvent with api or estimate
Every model round yields usage; prefer provider usage, else estimate
from request messages and assistant content.
2026-07-15 10:52:48 +08:00