Agent Markdown

This commit is contained in:
2026-08-18 14:54:31 -04:00
parent 1ad9d5781e
commit e7e1deabee
14 changed files with 692 additions and 167 deletions
+29 -1
View File
@@ -267,6 +267,18 @@ Prefer tools over guessing for filesystem and shell facts.
Reply format (mandatory): Every message you stream to the user must be plain text only — readable in a terminal without a Markdown renderer. Do not use Markdown or similar markup: no emphasis/backtick/code-fence/link syntax, no # headings, no list markers used as markup. Structure with blank lines, short paragraphs, indentation, ALL CAPS or dashed lines for section breaks if needed, and bare URLs when linking. Paths and commands appear as normal text.`
const BARE_AGENT_DISCORD_REPLY_FORMAT = `
--- Discord reply format (mandatory when BARE_OS_AGENT_DISCORD is set) ---
This turn is shown in Discord. Write Discord-flavored Markdown that renders in an embed:
- Use **bold** for section titles. Do not use # headings (Discord embeds show the hash).
- Use - or 1. lists. Use blank lines between sections.
- Use \`inline code\` for paths, commands, ids, and env vars.
- Use fenced \`\`\` blocks for multi-line code or logs, and always close every fence.
- Use [label](https://url) for links. Do not wrap the entire reply in one fence.
- Keep the final user-facing answer as Markdown. Tool chatter belongs in tools, not the reply.`
const BARE_AGENT_OPERATING_CONTRACT = `
--- Operating contract (Bare OS repo alignment) ---
@@ -1360,9 +1372,17 @@ async function bareOsRunAgentSession(ctx, argv0, task, runOpts) {
skillsBudget
)
const envForFormat =
ctx.env && typeof ctx.env === 'object'
? /** @type {Record<string, string>} */ (ctx.env)
: {}
const discordReply =
/^(1|true|yes)$/i.test(String(envForFormat.BARE_OS_AGENT_DISCORD || '').trim())
let systemContent =
BARE_AGENT_STATIC_SYSTEM +
BARE_AGENT_OPERATING_CONTRACT +
(discordReply ? BARE_AGENT_DISCORD_REPLY_FORMAT : '') +
'\n\n' +
bareAgentSessionHomeBlock(ctx, home, paths) +
'\n\n' +
@@ -1819,8 +1839,16 @@ async function bareOsRunAgentSession(ctx, argv0, task, runOpts) {
const hideMdEnv = String(envBag.BARE_OS_AGENT_PLAIN || '')
.trim()
.toLowerCase()
const discordEnv = String(envBag.BARE_OS_AGENT_DISCORD || '')
.trim()
.toLowerCase()
const plainReply =
hideMdEnv === '1' || hideMdEnv === 'true' || hideMdEnv === 'yes'
hideMdEnv === '1' ||
hideMdEnv === 'true' ||
hideMdEnv === 'yes' ||
discordEnv === '1' ||
discordEnv === 'true' ||
discordEnv === 'yes'
const thinkPanel =
!hideThink &&
stdout &&
@@ -178,6 +178,8 @@ test('agent-tui contains autonomous loop controls and completion gates', async (
test('agent-tui embeds operating contract appendix', async (t) => {
t.ok(TUI.includes('BARE_AGENT_OPERATING_CONTRACT'))
t.ok(TUI.includes('BARE_AGENT_DISCORD_REPLY_FORMAT'))
t.ok(TUI.includes('BARE_OS_AGENT_DISCORD'))
t.ok(TUI.includes('verification_hints'))
t.ok(TUI.includes('NEVER ASK'))
t.ok(!TUI.includes('ASK FIRST'))