Skip to content

styles: output styles, chosen by name and switched with /style (#26 item 7) - #31

Merged
blockmandev merged 2 commits into
mainfrom
feat/output-styles
Oct 22, 2026
Merged

blockmandev merged 2 commits into
mainfrom
feat/output-styles

Conversation

@blockmandev

Copy link
Copy Markdown
Member

#26 item 7. An output style is a Markdown file (.incode/styles/<name>.md, then ~/.incode/styles/<name>.md) whose body the agent follows in every reply. None ships with incode.

  • Chosen by INCODE_OUTPUT_STYLE, else output_style in admin.json; --admin shows it and its source, and a missing name is warned, never silently dropped.
  • Applied on every route (API, claude, codex, agy) and -t: one block, last in the prompt, saying the rules above it still win; kept as high priority when a prompt is cut for a command line.
  • /style lists, /style <name> switches from the next reply, /style off stops (AgentSession::set_output_style → every backend).
  • Not over --acp: ACP dispatches built-ins only from OFFERED (acp_agent/commands.rs), which this change does not extend; an ACP session keeps the style it started with. Documented.

Tests cover discovery and precedence, bad files reported, env over admin.json, a missing name warned, the budget keeping the block, and a swap reaching the backend with exactly one style. Controls: without the priority entry the style is cut; without the removal two styles are in force. incode --admin checked for found, missing and off.

Local (Windows): fmt clean; clippy only the existing with_tool_server warning; bin 59 passed; lib 2183 passed, 1 failed: the desktop UIA live test, which walks whatever window has focus on this machine (a browser page here). It passed on CI's Windows runner in #30.

)

#26 item 7. An output style is a Markdown file whose body the agent is
told to follow in every reply: .incode/styles/<name>.md, then
~/.incode/styles/<name>.md, the project's winning a clash; an optional
front matter gives a `description`. None ships with incode.

Which one: INCODE_OUTPUT_STYLE, else `output_style` in admin.json, else
none (`off`/`none` say none). --admin shows it and its source, and says
when no folder has that name; a session warns the same way rather than
quietly running without it. A file over 64 KB, an empty one, an unknown
front-matter key or a bad file name is left out and said.

Where it goes: one block, pushed LAST in prepare_session (REPL and
--acp) and in task_run (-t), so it reaches the API, claude, codex and
agy routes. It says everything above it still holds: it shapes how
replies read, never what the agent may do. budget_for_spawn keeps it as
high priority when a long prompt is cut for a command line.

/style lists the styles, /style <name> switches from the next reply,
/style off stops: AgentSession::set_output_style takes the old block
out of the standing context, puts the new one in and tells every
backend through carry_context.

/style is a REPL command. --acp dispatches built-in commands only from
the OFFERED list in acp_agent/commands.rs, and this change does not add
/style to it, so an ACP session keeps the style it started with. The
README says so.

Tests: discovery, precedence and descriptions; every kind of bad file
reported; env over admin.json and off; a missing name is a warning;
the block survives the command-line budget; a /style swap reaches the
backend with exactly one style and the rest of the context kept.
Controls: without the priority entry the style is cut; without the
removal two styles are in force. `incode --admin` checked for a found,
a missing and an `off` style.
…t be closed early

From a security review of 754bc5c. Two holes, both through files a cloned
repository can carry:

- A symbolic link was followed. `.incode/styles/x.md` pointing at a key
  file would have put that file in the prompt sent to the model once `x`
  was chosen: read_dir used `path.is_file()`, which follows the link. It
  now reads `symlink_metadata` and refuses a link, in either folder, with
  a reported problem.

- A repository could replace the operator's style. The project's folder
  was read first, so with `output_style: concise` and the operator's own
  ~/.incode/styles/concise.md, a repository's .incode/styles/concise.md
  won, and its text was told to the agent as "the person chose this".
  The operator's folder is now read first and wins a clash. Each style
  carries its Origin: the block says the text is "the person's own" or
  "this project's (from the repository)", /style shows yours / this
  project beside each, and --admin and the session note name the file.

And a body can no longer end the block early: every `</output-style`, in
any letter case, is written `< /output-style`, so only the block's own
close remains.

Tests: through load() itself (INCODE_DIR pointed at a temp folder), the
operator's concise beats a repository's; a symlink to a secret is refused
and reported (it ran here; Windows skips it without symlink rights); a
body's closing tags leave exactly one close; the block names its origin.
Controls: with the project read first, links followed, or the close not
broken up, each of those three tests fails.
@blockmandev
blockmandev merged commit af8354f into main Oct 22, 2026
7 checks passed
@blockmandev
blockmandev deleted the feat/output-styles branch November 15, 2026 20:29
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