Commit Graph

282 Commits

Author SHA1 Message Date
Adrià Arrufat
b141da30ca agent: verify synthesized scripts during /save
Introduces a multi-step synthesis process for `/save` that derives a
logical JSON output schema and uses a dry-run runtime to verify
candidate scripts. The LLM can now run and self-correct its scripts
using a new `run_script` tool before finalizing the save.
2026-06-09 16:53:39 +02:00
Adrià Arrufat
3baa2726e9 agent: streamline and shorten comments 2026-06-09 09:34:26 +02:00
Adrià Arrufat
6f54c78042 agent: simplify and clean up code comments 2026-06-09 08:43:40 +02:00
Adrià Arrufat
3615e58700 agent: deduplicate option setting and tool handling
- Consolidate `/verbosity` and `/effort` into `setEnumOption`.
- Add `abortSave` helper to clean up `synthesizeSave` error paths.
- Simplify `handleToolCall` by extracting the tool execution outcome.
- Update outdated comments referencing `message_arena`.
2026-06-09 08:16:07 +02:00
Adrià Arrufat
f2b5f05479 agent: extract conversation, welcome, and settings
Extracts chat history and arena management into `Conversation.zig`,
the startup banner into `welcome.zig`, and model/config resolution
helpers into `settings.zig` to simplify `Agent.zig`.
2026-06-09 07:54:32 +02:00
Adrià Arrufat
8e12f6cdf9 agent: exclude version from comptime banner check 2026-06-08 20:08:32 +02:00
Adrià Arrufat
e6ae13717d agent: move up text 2026-06-08 19:52:42 +02:00
Adrià Arrufat
02cf1c582b agent: add colored braille panda logo
Replace the monochrome braille logo with a truecolor ANSI-colored
version. Update logo dimensions and row counting logic, and simplify
the welcome banner printing to stream logo lines directly.
2026-06-08 19:48:05 +02:00
Adrià Arrufat
826fa34cb5 agent: remove schema from slash help
Stop printing the verbose JSON schema for tool parameters when
displaying slash command help.
2026-06-08 19:11:02 +02:00
Adrià Arrufat
378a11d0dd agent: support LLM commands in slash help 2026-06-08 19:08:39 +02:00
Adrià Arrufat
95963e63e8 agent: simplify welcome banner rendering
Statically assert that the banner fits within 80 columns at compile
time. This removes the need to dynamically measure terminal width
and conditionally hide the logo.
2026-06-08 18:50:35 +02:00
Adrià Arrufat
c6b1649b93 repl: update isocline and polish hints 2026-06-08 18:26:27 +02:00
Adrià Arrufat
6a35253368 terminal: remove custom status bar
Updates the isocline dependency to use its native hints for Ctrl-D
and Esc. Removes the custom status bar rendering logic, and prints
the active model and effort level at REPL startup instead.
2026-06-08 18:13:49 +02:00
Adrià Arrufat
c087229b8a agent: add welcome banner with logo
Prints a Braille-art Lightpanda logo alongside the welcome text and
command hints if the terminal is wide enough. Otherwise, falls back
to a text-only layout.

Also exposes `Terminal.displayWidth` to assist with layout calculations.
2026-06-08 11:28:16 +02:00
Adrià Arrufat
04345a5149 fix: resolve agent init crash and mcp stream recovery
- Track initialized providers in Agent.zig to avoid freeing garbage
  memory on error.
- Discard the rest of the line in mcp router on StreamTooLong to
  allow processing subsequent requests.
2026-06-08 10:35:42 +02:00
Adrià Arrufat
2a7bda3608 string: add string.isOneOf and deduplicate helpers 2026-06-08 09:04:36 +02:00
Adrià Arrufat
7bcab1d840 terminal: separate normal and JS REPL history
Store normal and JS history in separate files and swap them
dynamically when toggling modes.
2026-06-06 12:44:59 +02:00
Adrià Arrufat
200cbe623f agent: skip network requests during initialization
Avoids network round trips during agent startup to keep it snappy.
Skips model reconciliation in REPL mode and loads the model-list
cache lazily instead of pre-warming it.
2026-06-05 16:34:29 +02:00
Adrià Arrufat
97dc807810 repl: improve startup help messages 2026-06-05 15:16:41 +02:00
Adrià Arrufat
5ad664a63a agent: allow disabling LLM via /provider null
Adds support for `/provider null` to disable the LLM and persist this
preference in `.lp-agent.zon`. Subsequent REPL launches will start
in basic mode without prompting for API keys. Transient `--no-llm`
runs do not clobber the saved provider.
2026-06-05 15:12:04 +02:00
Adrià Arrufat
ce34ea6625 agent: persist and restore verbosity setting
Saves the agent's verbosity setting to `.lp-agent.zon` and
restores it on initialization, similar to the effort setting.
2026-06-05 14:40:55 +02:00
Adrià Arrufat
c355b0bda8 agent: add /clear and /reset REPL commands
- `/clear` forgets conversation history, usage, and node IDs while
  keeping the loaded page and cookies.
- `/reset` does a full reset, starting a fresh browser session.
2026-06-05 14:13:10 +02:00
Adrià Arrufat
2d2914e878 agent: add /usage slash command to REPL
Adds a new `/usage` meta command to print cumulative token usage and
cache hit rate for the current session. Also updates zenai.
2026-06-05 13:35:34 +02:00
Adrià Arrufat
5f2330bb2f agent: add reasoning effort configuration
Adds the `--effort` CLI flag and `/effort` REPL command to control
the reasoning budget, persisting the setting in `.lp-agent.zon`.
2026-06-05 12:40:34 +02:00
Adrià Arrufat
19485f8640 agent: validate models for all providers
Generalizes model reconciliation to support all providers, not just
Ollama. Also updates the zenai dependency.
2026-06-04 20:01:12 +02:00
Adrià Arrufat
ab540e9bdf agent: auto-detect Ollama and fallback models
Probes local Ollama as a fallback provider when no API keys are set.
Swaps to an installed Ollama model if the default model is missing.
2026-06-04 18:29:29 +02:00
Adrià Arrufat
f2a7367e6d agent: verify Ollama model is installed upfront
Queries Ollama's local catalog during initialization to ensure the
requested model is installed. Aborts one-shot runs if missing, or
warns during interactive sessions.
2026-06-04 18:09:43 +02:00
Adrià Arrufat
d184327376 agent: validate model selection
Check if the selected model exists in the completion models list
before setting it, preventing invalid model configurations.
2026-06-04 18:01:25 +02:00
Adrià Arrufat
3575e1f238 agent: use remembered model when provider matches
Use the remembered model whenever it matches the chosen provider,
instead of only when the provider source is `.remembered`.
2026-06-04 17:30:37 +02:00
Adrià Arrufat
0bb87330a7 agent: abort in-flight LLM requests on cancel
Updates the zenai dependency and integrates `zenai.http.Interrupt`
to immediately abort active LLM requests when cancellation is triggered.
2026-06-04 13:07:06 +02:00
Adrià Arrufat
fded77b3a8 terminal: implement responsive status bar segments
Replaces static left/right status strings with ranked segments.
When the terminal is too narrow, segments are dropped lowest-rank
first to prevent wrapping and layout corruption.
2026-06-03 20:03:11 +02:00
Adrià Arrufat
585ab9f766 agent: update repl evaluation error message 2026-06-03 17:33:55 +02:00
Adrià Arrufat
5dd37af123 tools: rename eval tool to evaluate 2026-06-03 17:30:25 +02:00
Adrià Arrufat
560897ea89 agent: clean up save mode and terminal prompts
- Use `std.meta.fieldNames` for the save mode prompt.
- Update terminal prompt functions to accept null-terminated strings.
- Respect the resolved save mode in `synthesizeSave`.
2026-06-03 17:13:52 +02:00
Adrià Arrufat
ac82551e66 agent: replace -i flag with /save and /load commands
Removes the `-i`/`--interactive` CLI flag and live file-based
recording. Instead, the REPL now supports a `/load <path>` command
to run scripts from disk, and `/save` to export the in-memory
session recording.

The `Recorder` is simplified to be purely in-memory, and the script
runtime is moved to `src/script/Runtime.zig`.

BREAKING CHANGE: The `-i`/`--interactive` flag has been removed. Use
the `/save` and `/load` commands within the REPL instead.
2026-06-03 16:21:10 +02:00
Adrià Arrufat
e208b4b638 repl: add dynamic status bar
Integrates isocline's top and bottom bar APIs to display the active
provider, model, and shortcut hints. Updates the status bar on
terminal resize and mode switches.
2026-06-03 15:09:09 +02:00
Adrià Arrufat
4139252feb mcp: replace recording and healing tools with save
Removes recordStart, recordStop, recordComment, scriptStep, and
scriptHeal MCP tools. Introduces a single 'save' tool that lets
the client synthesize and persist the script directly.
2026-06-03 10:01:38 +02:00
Adrià Arrufat
5f72a15355 style: clean up comments and convert to doc comments 2026-06-03 09:43:43 +02:00
Adrià Arrufat
eaedc94453 agent: stop forcing external stylesheets for LLM 2026-06-03 09:27:56 +02:00
Adrià Arrufat
ee498feb48 agent: expand and highlight env vars in JS mode 2026-06-03 08:58:47 +02:00
Adrià Arrufat
db385cf4db agent: optimize autocomplete and cache providers 2026-06-03 08:52:25 +02:00
Adrià Arrufat
993315c770 agent: handle model safety refusals
Updates the `zenai` dependency to support safety finish reasons. Tracks
when a model refuses a request due to safety, prints a specific warning
message, and avoids re-prompting.
2026-06-02 19:39:37 +02:00
Adrià Arrufat
db21f658f0 agent: prevent use-after-free in synthesizeSave 2026-06-02 15:26:27 +02:00
Adrià Arrufat
8739fbcb4b agent: synthesize scripts on /save using LLM 2026-06-02 15:23:33 +02:00
Adrià Arrufat
3bbe20735f agent: record raw REPL input
- Add `recordRaw` to record raw JS lines in the REPL.
- Only record commands if they succeed without error.
- Fix kitty terminal cursor keys by forcing legacy arrow encoding.
2026-06-02 12:54:37 +02:00
Adrià Arrufat
04ee47c268 Merge branch 'agent' into agent_repl_pimp 2026-06-02 11:23:39 +02:00
Adrià Arrufat
401f73b0f2 agent: echo console logs in REPL
Drains and prints console messages during the REPL loop. This ensures
console output is surfaced in JS mode, where slash commands like
`/consoleLogs` are unreachable.
2026-06-02 11:09:53 +02:00
Francis Bouvier
f54359aef6 agent: improve banner 2026-06-02 10:45:19 +02:00
Adrià Arrufat
8e063f8e83 repl: add JS evaluation mode 2026-06-02 10:19:37 +02:00
Adrià Arrufat
044b34d228 refactor: remove legacy PandaScript self-healing and execution
Removes the `--self-heal` CLI option, the `scriptStep` and `scriptHeal`
MCP tools, and associated verification/iterator machinery. Replaces
"PandaScript" terminology with "slash commands" and moves shared
helpers to `tools.zig`.

BREAKING CHANGE: The `--self-heal` CLI flag and the `scriptStep` and
`scriptHeal` MCP tools have been removed.
2026-06-01 17:29:24 +02:00