Skip to content

feat(agent): enable codemode in interactive sessions - #103

Merged
maelcaldas merged 3 commits into
mainfrom
feat/agent-codemode
Oct 1, 2026
Merged

maelcaldas merged 3 commits into
mainfrom
feat/agent-codemode

Conversation

@maelcaldas

Copy link
Copy Markdown
Member

User impact

The Bkper agent can now run several tool calls in one JavaScript script (codemode). Repeated bkper commands across books or items, chained commands, and large outputs are handled in one step, and only the script's result reaches the conversation.

Book writes from a script follow the same rule as single commands: the agent resolves the targets read-only, shows the exact script and every change, and runs it only after the user confirms.

Changes

  • Register pi's codemode tool with the Bkper agent built-ins (SDK sessions do not load pi's built-in extensions) and select it in the Bkper default tool lists. The tool set stays stable across turns, which keeps the prompt cache warm.
  • Describe codemode in the Bkper system prompt, which replaces pi's prompt and so drops the tool's own snippet and guidelines.
  • defaultTools settings that contain only +name/-name entries now apply to the Bkper defaults instead of pi's, which lack codemode and PowerShell. Plain tool lists are kept as configured.

Verification

  • bun run build and bun run test:unit pass.
  • Three fresh interactive sessions (Claude Opus, high thinking) asked for account counts and last transaction dates across 580 books. All three used codemode for the fan-out without being asked; two rows spot-checked against direct bkper reads matched.

Not verified

  • Windows hosts (PowerShell inside codemode scripts).
  • Live runs of the Book write confirmation flow from a script.
  • MCP is not enabled in interactive mode; out of scope.

Register pi's codemode tool with the Bkper built-ins and select it in
the Bkper default tool lists, so the tool set stays stable across turns.
Explicit defaultTools settings are kept.

Describe codemode in the Bkper system prompt, which replaces pi's and so
drops the tool's own snippet and guidelines. Book writes from scripts
follow the single-command confirmation rule: resolve targets read-only,
show the exact script and changes, run after confirmation, and return
per-item results.
Pi resolves a defaultTools selection with only +name/-name entries in
every settings layer against its own defaults, which lack codemode and
PowerShell. A shared ~/.pi/agent setting such as ["+grep"] therefore
dropped codemode, and on Windows replaced PowerShell with Bash.

Read the raw global and project layers; when no layer lists plain tool
names, apply their modifiers to the Bkper defaults instead. Shells added
by a modifier still go through the unavailable-shell filter.
With the generic codemode guideline the model fanned out bkper commands
with shell loops and jq instead. Name those alternatives in a shorter
guideline, and shorten the Book write confirmation guideline without
dropping a step.

Drop the test that matched the guideline wording; the tool listing and
the codemode-off case stay covered.
@maelcaldas
maelcaldas merged commit 619d1a0 into main Oct 1, 2026
2 checks passed
@maelcaldas
maelcaldas deleted the feat/agent-codemode branch October 1, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant