UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

119 lines (114 loc) • 7.07 kB
/** * System prompt of a spec request: the reusable prefix (with the respond-tool schema) that the * provider can cache, so only the job's samples are billed per request. The examples are spec * objects serialized here, which keeps their regex escapes exact. * Ported from oh-my-pi 9df0457b31 `prompts/system/job-widget-system.md` (MIT, Copyright Can Boluk et al.). */ import { TOOL_CALL_MARK } from "./source-types.js"; export const JOB_WIDGET_RESPOND_TOOL = "respond"; const EXAMPLES = [ [ "`req 8 rps=56 p50=41ms`, goal 60 req/s:", { title: "load test · rps", rules: [{ from: "out", match: String.raw `^req \d+ rps=(?P<rps>[\d.]+) p50=(?P<p50>[\d.]+)ms` }], blocks: [ { kind: "spark", field: "rps", label: "req/s", unit: "req/s", better: "higher", target: 60, targetLabel: "goal 60", }, { kind: "stat", items: [{ field: "p50", agg: "last", label: "p50", unit: "ms", better: "lower" }] }, ], headline: { field: "rps", agg: "last", unit: "req/s", better: "higher" }, }, ], [ "`finish bash openai/gpt-5 t2: reward=1 tests=27/36 turns=5`, 9 trials:", { title: "eval · tests passed per model", rules: [ { from: "out", match: String.raw `^finish \S+ (?P<model>\S+) t\d+: .*tests=(?P<passed>\d+)/\d+`, key: "model", count: "trials", }, ], blocks: [ { kind: "bars", field: "passed", agg: "mean", label: "tests passed", max: 36, better: "higher" }, { kind: "meter", field: "trials", agg: "count", total: 9, label: "trials" }, ], }, ], [ "`✓ lint (1m02s)` / `✗ test-linux (4m11s)` / `* build-macos`:", { title: "CI · 6 jobs", rules: [{ from: "*", match: String.raw `^(?P<mark>[✓✗*-])\s+(?P<name>\S+)`, key: "name", text: "mark" }], blocks: [ { kind: "grid", field: "mark", label: "jobs", tones: { "✓": "success", "✗": "error", "*": "pending", "-": "muted" }, }, ], }, ], [ "nextest, ` PASS [ 0.012s] parser tests::named_groups`:", { title: "nextest · parser", rules: [ { from: "*", match: String.raw `^\s*PASS \[`, count: "pass" }, { from: "*", match: String.raw `^\s*FAIL \[\s*[\d.]+s\] (?P<fail>.+)$`, text: "fail" }, { from: "*", match: String.raw `^\s*(?:PASS|FAIL) \[\s*[\d.]+s\] (?P<current>.+)$`, text: "current" }, ], blocks: [ { kind: "stat", items: [ { field: "pass", agg: "count", label: "passed" }, { field: "fail", agg: "count", label: "failed" }, ], }, { kind: "text", field: "fail" }, ], stage: "current", }, ], ]; export const JOB_WIDGET_PROMPT_EXAMPLES = EXAMPLES.map(([, spec]) => spec); const INSTRUCTIONS = `You design the live status widget of a coding agent's background job (benchmark, eval, CI, tests, build, training, subagent). From the job's purpose and output samples you write a spec once; plain code then runs its regexes on every new line and redraws the widget until the job ends. Nobody can fix it later: its rules MUST match the real lines. A widget charts a quantity that shows how the job is going: throughput, latency, loss, tests or trials passed, progress toward a total the job states. When the output has none, call \`${JOB_WIDGET_RESPOND_TOOL}\` with only \`{"skip":"<why>"}\`; no widget beats a meaningless one. Never chart activity: tool calls, lines or matches seen, words like \`error\` inside file contents. In \`tools\`, lines starting with \`${TOOL_CALL_MARK}\` are the engine's markers of the subagent's tool calls, not output: never match them. Otherwise call \`${JOB_WIDGET_RESPOND_TOOL}\` with: - \`title\` (≤ 48 chars): what is watched. - \`rules\` (1–12) \`{from, match, key?, text?, count?, scale?}\`: - \`from\`: the sample source id carrying the data (\`out\`, \`pipe:1\`, \`tools\`), \`*\` for all, \`pipe:*\` for a prefix. When a \`pipe:N\` source exists for \`cmd | tail\` or \`| tee\`, read the pipe: \`out\` gets the lines late or twice. - \`match\`: RE2 regex on one line; no lookaround or backreferences. Copy the literal text around the data from the samples; allow varying digits (\`[\\d.]+\`) and widths (\`\\s+\`). - Each named group \`(?P<name>…)\` feeds field \`name\` (\`[a-z][a-z0-9_]*\`) with its number (\`1,234\`, \`4.5k\` parse). One rule can capture several fields of a line. - \`key\`: the rule's group naming a series (model, shard, CI job); the rule's fields keep one series per key. Not a field itself. - \`text\`: the rule's group kept as text (status word, test name). - \`count\`: a field counting matching lines. - \`scale\`: multiplies the rule's numbers. - \`blocks\` (1–4, most important first), each on a \`field\`: - \`spark\`: numbers over time. \`label\`, \`key?\` (one key value, e.g. \`gpt-5\`), \`unit?\`, \`better?\` (\`higher\`|\`lower\`), \`target?\` + \`targetLabel?\` (goal line from the brief), \`min?\`, \`max?\`. - \`bars\`: one bar per key, reduced by \`agg\`. \`label\`, \`unit?\`, \`max?\`, \`better?\`. - \`meter\`: \`agg\` out of a \`total\` (a value ref, or a number the job or its output states; never a guess), \`label\`, \`unit?\`. - \`stat\`: \`items\`, 1–4 value refs with \`label\`. - \`grid\`: a cell per key, coloured by latest text. \`label\`, \`tones\`: lowercase status substring → \`success\`|\`error\`|\`warning\`|\`pending\`|\`info\`|\`muted\`|\`neutral\`. - \`text\`: the field's latest text. - \`headline?\`: the value ref to glance at. \`stage?\`: field whose latest text is the current step (not for a subagent: its own words are shown). Value ref: \`{field, agg, label?, key?, unit?, digits?, better?}\`; \`key\` is one key value, \`better\` adds a trend arrow. \`agg\` over numbers: \`last\` \`first\` \`min\` \`max\` \`mean\` \`sum\` \`delta\` \`change\` (%); over matches: \`count\`, \`rate\` (/s, last minute). Chart what a watcher wants: throughput or latency against the goal, progress toward a known total, per-model results, failures. Few accurate blocks; never invent lines the samples lack. Omit optional properties you do not need. Examples:`; export const JOB_WIDGET_SYSTEM_PROMPT = [ INSTRUCTIONS, ...EXAMPLES.map(([sample, spec]) => `\n${sample}\n${JSON.stringify(spec)}`), ].join("\n"); //# sourceMappingURL=author-system-prompt.js.map