reasonix 0.36.1 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -75
- package/README.zh-CN.md +47 -32
- package/dashboard/dist/app.js +405 -196
- package/dashboard/dist/app.js.map +1 -1
- package/dist/cli/{chat-7AF5SPAJ.js → chat-7257YAPG.js} +12 -12
- package/dist/cli/{chunk-DFP4YSVM.js → chunk-6CXT5JRM.js} +17 -2
- package/dist/cli/{chunk-DFP4YSVM.js.map → chunk-6CXT5JRM.js.map} +1 -1
- package/dist/cli/{chunk-G3XNWSFN.js → chunk-6NMWJSES.js} +2 -2
- package/dist/cli/{chunk-MLXUGPJE.js → chunk-GKZJXYMY.js} +79 -1
- package/dist/cli/chunk-GKZJXYMY.js.map +1 -0
- package/dist/cli/{chunk-IPCPEZWQ.js → chunk-JGZKTAOH.js} +2 -2
- package/dist/cli/{chunk-BJ376EN3.js → chunk-JULZ7JTO.js} +3 -3
- package/dist/cli/{chunk-3OBWN2NH.js → chunk-MSKUP6PD.js} +1481 -1033
- package/dist/cli/chunk-MSKUP6PD.js.map +1 -0
- package/dist/cli/{chunk-QPNZWUZF.js → chunk-S4GF3HPO.js} +26 -1
- package/dist/cli/chunk-S4GF3HPO.js.map +1 -0
- package/dist/cli/{chunk-QRUQ2BFT.js → chunk-SEFXUF24.js} +119 -51
- package/dist/cli/chunk-SEFXUF24.js.map +1 -0
- package/dist/cli/{chunk-2MCYGFLK.js → chunk-VF57YX2M.js} +18 -17
- package/dist/cli/chunk-VF57YX2M.js.map +1 -0
- package/dist/cli/{chunk-KJQIA4US.js → chunk-XOIDSPMQ.js} +71 -32
- package/dist/cli/chunk-XOIDSPMQ.js.map +1 -0
- package/dist/cli/{chunk-ZU45XW3P.js → chunk-YER7WCHF.js} +21 -6
- package/dist/cli/chunk-YER7WCHF.js.map +1 -0
- package/dist/cli/{code-SWI4EBME.js → code-64EG5IU2.js} +24 -15
- package/dist/cli/code-64EG5IU2.js.map +1 -0
- package/dist/cli/{doctor-DKD34EFD.js → doctor-BW5HSQDW.js} +5 -5
- package/dist/cli/{events-P27CX7LN.js → events-SQXPVV7B.js} +3 -3
- package/dist/cli/index.js +28 -26
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/prompt-KGIUONO3.js +13 -0
- package/dist/cli/{prune-sessions-ERL6B4G5.js → prune-sessions-FCFOYCBP.js} +2 -2
- package/dist/cli/{run-FK5UBIIM.js → run-RWCOA32G.js} +8 -8
- package/dist/cli/{server-W4XJK4GX.js → server-6ZW4TQUP.js} +95 -49
- package/dist/cli/{server-W4XJK4GX.js.map → server-6ZW4TQUP.js.map} +1 -1
- package/dist/cli/{sessions-YZXWMIWW.js → sessions-5ISNWFMU.js} +8 -8
- package/dist/cli/{setup-IIAJXHP4.js → setup-HJG23NKJ.js} +2 -2
- package/dist/cli/{version-DWD6RLIU.js → version-BXAN7Q4V.js} +8 -8
- package/dist/index.d.ts +34 -2
- package/dist/index.js +295 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/chunk-2MCYGFLK.js.map +0 -1
- package/dist/cli/chunk-3OBWN2NH.js.map +0 -1
- package/dist/cli/chunk-KJQIA4US.js.map +0 -1
- package/dist/cli/chunk-MLXUGPJE.js.map +0 -1
- package/dist/cli/chunk-QPNZWUZF.js.map +0 -1
- package/dist/cli/chunk-QRUQ2BFT.js.map +0 -1
- package/dist/cli/chunk-ZU45XW3P.js.map +0 -1
- package/dist/cli/code-SWI4EBME.js.map +0 -1
- package/dist/cli/prompt-YEKXMNNV.js +0 -11
- /package/dist/cli/{chat-7AF5SPAJ.js.map → chat-7257YAPG.js.map} +0 -0
- /package/dist/cli/{chunk-G3XNWSFN.js.map → chunk-6NMWJSES.js.map} +0 -0
- /package/dist/cli/{chunk-IPCPEZWQ.js.map → chunk-JGZKTAOH.js.map} +0 -0
- /package/dist/cli/{chunk-BJ376EN3.js.map → chunk-JULZ7JTO.js.map} +0 -0
- /package/dist/cli/{doctor-DKD34EFD.js.map → doctor-BW5HSQDW.js.map} +0 -0
- /package/dist/cli/{events-P27CX7LN.js.map → events-SQXPVV7B.js.map} +0 -0
- /package/dist/cli/{prompt-YEKXMNNV.js.map → prompt-KGIUONO3.js.map} +0 -0
- /package/dist/cli/{prune-sessions-ERL6B4G5.js.map → prune-sessions-FCFOYCBP.js.map} +0 -0
- /package/dist/cli/{run-FK5UBIIM.js.map → run-RWCOA32G.js.map} +0 -0
- /package/dist/cli/{sessions-YZXWMIWW.js.map → sessions-5ISNWFMU.js.map} +0 -0
- /package/dist/cli/{setup-IIAJXHP4.js.map → setup-HJG23NKJ.js.map} +0 -0
- /package/dist/cli/{version-DWD6RLIU.js.map → version-BXAN7Q4V.js.map} +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-SEFXUF24.js";
|
|
3
3
|
import "./chunk-UNMYFZPZ.js";
|
|
4
4
|
import "./chunk-XJLZ4HKU.js";
|
|
5
5
|
import "./chunk-XHQIK7B6.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-YER7WCHF.js";
|
|
7
7
|
import "./chunk-DAEAAVDF.js";
|
|
8
8
|
import "./chunk-KMWKGPFZ.js";
|
|
9
9
|
import "./chunk-3Q3C4W66.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-S4GF3HPO.js";
|
|
11
|
+
import "./chunk-XOIDSPMQ.js";
|
|
12
|
+
import "./chunk-JGZKTAOH.js";
|
|
13
13
|
import "./chunk-5X7LZJDE.js";
|
|
14
14
|
import {
|
|
15
15
|
listSessions,
|
|
16
16
|
loadSessionMessages,
|
|
17
17
|
sessionPath
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-6CXT5JRM.js";
|
|
19
|
+
import "./chunk-GKZJXYMY.js";
|
|
20
20
|
import "./chunk-BHLHOS5Y.js";
|
|
21
21
|
import "./chunk-WUI3P4RA.js";
|
|
22
22
|
import "./chunk-ZTLZO42A.js";
|
|
@@ -101,4 +101,4 @@ function truncate(s, max) {
|
|
|
101
101
|
export {
|
|
102
102
|
sessionsCommand
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=sessions-
|
|
104
|
+
//# sourceMappingURL=sessions-5ISNWFMU.js.map
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
onLanguageChange,
|
|
25
25
|
setLanguage,
|
|
26
26
|
t
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-GKZJXYMY.js";
|
|
28
28
|
import {
|
|
29
29
|
defaultConfigPath,
|
|
30
30
|
isPlausibleKey,
|
|
@@ -468,4 +468,4 @@ async function setupCommand(_opts = {}) {
|
|
|
468
468
|
export {
|
|
469
469
|
setupCommand
|
|
470
470
|
};
|
|
471
|
-
//# sourceMappingURL=setup-
|
|
471
|
+
//# sourceMappingURL=setup-HJG23NKJ.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "./chunk-
|
|
2
|
+
import "./chunk-SEFXUF24.js";
|
|
3
3
|
import "./chunk-UNMYFZPZ.js";
|
|
4
4
|
import "./chunk-XJLZ4HKU.js";
|
|
5
5
|
import "./chunk-XHQIK7B6.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-YER7WCHF.js";
|
|
7
7
|
import "./chunk-DAEAAVDF.js";
|
|
8
8
|
import "./chunk-KMWKGPFZ.js";
|
|
9
9
|
import "./chunk-3Q3C4W66.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-S4GF3HPO.js";
|
|
11
|
+
import "./chunk-XOIDSPMQ.js";
|
|
12
|
+
import "./chunk-JGZKTAOH.js";
|
|
13
13
|
import "./chunk-5X7LZJDE.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-6CXT5JRM.js";
|
|
15
|
+
import "./chunk-GKZJXYMY.js";
|
|
16
16
|
import "./chunk-BHLHOS5Y.js";
|
|
17
17
|
import "./chunk-WUI3P4RA.js";
|
|
18
18
|
import "./chunk-ZTLZO42A.js";
|
|
@@ -28,4 +28,4 @@ function versionCommand() {
|
|
|
28
28
|
export {
|
|
29
29
|
versionCommand
|
|
30
30
|
};
|
|
31
|
-
//# sourceMappingURL=version-
|
|
31
|
+
//# sourceMappingURL=version-BXAN7Q4V.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -284,6 +284,8 @@ declare class PauseGate {
|
|
|
284
284
|
ask<K extends PauseKind>(opts: PauseAskOpts<K>): Promise<PauseResponseMap[K]>;
|
|
285
285
|
/** Resolve a pending request. Called by the App's modal callback. */
|
|
286
286
|
resolve(id: number, data: unknown): void;
|
|
287
|
+
/** Safe-cancel every outstanding request — frees stranded tool fns on Esc / /new. */
|
|
288
|
+
cancelAll(): void;
|
|
287
289
|
setAuditListener(fn: AuditListener | null): void;
|
|
288
290
|
/** Subscribe to new pause requests. Returns an unsubscribe function. */
|
|
289
291
|
on(fn: GateListener): () => void;
|
|
@@ -398,6 +400,23 @@ interface RunHooksOptions {
|
|
|
398
400
|
/** Stops at first `block` so a gating hook can prevent later hooks running against a phantom success. */
|
|
399
401
|
declare function runHooks(opts: RunHooksOptions): Promise<HookReport>;
|
|
400
402
|
|
|
403
|
+
/** Authoritative running-id set — cards derive `running` from `has(id)` instead of trusting end-event delivery. Loop adds on dispatch entry, deletes in `finally` so every exit path cleans up. */
|
|
404
|
+
type InflightSubscriber = () => void;
|
|
405
|
+
declare class InflightSet {
|
|
406
|
+
private readonly _set;
|
|
407
|
+
private readonly _listeners;
|
|
408
|
+
add(id: string): void;
|
|
409
|
+
delete(id: string): void;
|
|
410
|
+
has(id: string): boolean;
|
|
411
|
+
/** Snapshot for diagnostics / tests; live view, do not mutate. */
|
|
412
|
+
get size(): number;
|
|
413
|
+
/** Subscribe to add/delete; returns the unsubscribe function. */
|
|
414
|
+
subscribe(fn: InflightSubscriber): () => void;
|
|
415
|
+
/** Drop everything — only use at session reset. Notifies once. */
|
|
416
|
+
clear(): void;
|
|
417
|
+
private _notify;
|
|
418
|
+
}
|
|
419
|
+
|
|
401
420
|
interface DeepSeekProbeResult {
|
|
402
421
|
reachable: boolean;
|
|
403
422
|
}
|
|
@@ -583,6 +602,8 @@ interface LoopEvent {
|
|
|
583
602
|
toolCallIndex?: number;
|
|
584
603
|
/** Count of tool calls whose args have parsed as valid JSON (UI progress, not dispatch gate). */
|
|
585
604
|
toolCallReadyCount?: number;
|
|
605
|
+
/** Stable id for tool_start / tool pairs — also the inflight-set key. UI uses this as the card id so it can derive `running` from `loop.inflight.has(callId)` instead of trusting end-event delivery. */
|
|
606
|
+
callId?: string;
|
|
586
607
|
stats?: TurnStats;
|
|
587
608
|
repair?: RepairReport;
|
|
588
609
|
error?: string;
|
|
@@ -754,12 +775,16 @@ declare class CacheFirstLoop {
|
|
|
754
775
|
private _streamPreference;
|
|
755
776
|
/** Threaded through HTTP + every tool dispatch so Esc cancels in-flight work, not after. */
|
|
756
777
|
private _turnAbort;
|
|
778
|
+
/** Authoritative running-id set — UI cards consult this instead of trusting end-event delivery. Insert at dispatch entry, delete in finally. */
|
|
779
|
+
private readonly _inflight;
|
|
757
780
|
private _proArmedForNextTurn;
|
|
758
781
|
private _escalateThisTurn;
|
|
759
782
|
private readonly _turnFailures;
|
|
760
783
|
private _turnSelfCorrected;
|
|
761
784
|
private _foldedThisTurn;
|
|
762
785
|
private context;
|
|
786
|
+
/** Subscribe API so UI hooks can derive `running` from finally-guaranteed insertions. */
|
|
787
|
+
get inflight(): InflightSet;
|
|
763
788
|
get currentTurn(): number;
|
|
764
789
|
constructor(opts: CacheFirstLoopOptions);
|
|
765
790
|
/** Replace older turns with one summary message; keep tail within keepRecentTokens budget. */
|
|
@@ -774,9 +799,10 @@ declare class CacheFirstLoop {
|
|
|
774
799
|
appendAndPersist(message: ChatMessage): void;
|
|
775
800
|
/** Swap the just-appended assistant entry — used by self-correction to restore the original tool_calls without dropping reasoning_content. */
|
|
776
801
|
private replaceTailAssistantMessage;
|
|
777
|
-
/** "New chat" — drops messages
|
|
802
|
+
/** "New chat" — drops in-memory messages, archives the on-disk transcript so it survives in Sessions, keeps sessionName so the prefix cache stays warm. */
|
|
778
803
|
clearLog(): {
|
|
779
804
|
dropped: number;
|
|
805
|
+
archived: string | null;
|
|
780
806
|
};
|
|
781
807
|
configure(opts: ReconfigurableOptions): void;
|
|
782
808
|
/** `null` disables the cap; any change re-arms the 80% warning. */
|
|
@@ -795,6 +821,9 @@ declare class CacheFirstLoop {
|
|
|
795
821
|
/** Returns true ONLY on the tipping call — caller surfaces a one-shot warning. */
|
|
796
822
|
private noteToolFailureSignal;
|
|
797
823
|
private runOneToolCall;
|
|
824
|
+
/** Stable per-call id used as the inflight key AND threaded into tool_start / tool events so the UI matches them up. */
|
|
825
|
+
private inflightIdFor;
|
|
826
|
+
private _inflightCounter;
|
|
798
827
|
private buildMessages;
|
|
799
828
|
abort(): void;
|
|
800
829
|
/** Drop the last user message + everything after; caller re-sends. Persists to session file. */
|
|
@@ -1988,7 +2017,8 @@ interface EditSnapshot {
|
|
|
1988
2017
|
declare function snapshotBeforeEdits(blocks: EditBlock[], rootDir: string): EditSnapshot[];
|
|
1989
2018
|
declare function restoreSnapshots(snapshots: EditSnapshot[], rootDir: string): ApplyResult[];
|
|
1990
2019
|
|
|
1991
|
-
declare const CODE_SYSTEM_PROMPT = "You are Reasonix Code, a coding assistant. You have filesystem tools (read_file, write_file, edit_file, multi_edit, list_directory, directory_tree, search_files, search_content, glob, get_file_info) rooted at the user's working directory, plus run_command / run_background for shell, plus `todo_write` for in-session multi-step tracking.\n\n# Cite or shut up \u2014 non-negotiable\n\nEvery factual claim you make about THIS codebase must be backed by evidence. Reasonix VALIDATES the citations you write \u2014 broken paths or out-of-range lines render in **red strikethrough with \u274C** in front of the user.\n\n**Positive claims** (a file exists, a function does X, a feature IS implemented) \u2014 append a markdown link to the source:\n\n- \u2705 Correct: `The MCP client supports listResources [listResources](src/mcp/client.ts:142).`\n- \u274C Wrong: `The MCP client supports listResources.` \u2190 no citation, looks authoritative but unverifiable.\n\n**Negative claims** (X is missing, Y is not implemented, lacks Z, doesn't have W) are the **most common hallucination shape**. They feel safe to write because no citation seems possible \u2014 but that's exactly why you must NOT write them on instinct.\n\nIf you are about to write \"X is missing\" or \"Y is not implemented\" \u2014 **STOP**. Call `search_content` for the relevant symbol or term FIRST. Only then:\n\n- If the search returns matches \u2192 you were wrong; correct yourself and cite the matches.\n- If the search returns nothing \u2192 state the absence with the search query as your evidence: `No callers of \\`foo()\\` found (search_content \"foo\").`\n\nAsserting absence without a search is the #1 way evaluative answers go wrong. Treat the urge to write \"missing\" as a red flag in your own reasoning.\n\n# When to propose a plan (submit_plan)\n\nYou have a `submit_plan` tool that shows the user a markdown plan and lets them Approve / Refine / Cancel before you execute. Use it proactively when the task is large enough to deserve a review gate:\n\n- Multi-file refactors or renames.\n- Architecture changes (moving modules, splitting / merging files, new abstractions).\n- Anything where \"undo\" after the fact would be expensive \u2014 migrations, destructive cleanups, API shape changes.\n- When the user's request is ambiguous and multiple reasonable interpretations exist \u2014 propose your reading as a plan and let them confirm.\n\nSkip submit_plan for small, obvious changes: one-line typo, clear bug with a clear fix, adding a missing import, renaming a local variable. Just do those.\n\nPlan body: one-sentence summary, then a file-by-file breakdown of what you'll change and why, and any risks or open questions. If some decisions are genuinely up to the user (naming, tradeoffs, out-of-scope possibilities), list them in an \"Open questions\" section \u2014 the user sees the plan in a picker and has a text input to answer your questions before approving. Don't pretend certainty you don't have; flagged questions are how the user tells you what they care about. After calling submit_plan, STOP \u2014 don't call any more tools, wait for the user's verdict.\n\n**Do NOT use submit_plan to present A/B/C route menus.** The approve/refine/cancel picker has no branch selector \u2014 a menu plan strands the user. For branching decisions, use `ask_choice` (see below); only call submit_plan once the user has picked a direction and you have ONE actionable plan.\n\n# When to ask the user to pick (ask_choice)\n\nYou have an `ask_choice` tool. **If the user is supposed to pick between alternatives, the tool picks \u2014 you don't enumerate the choices as prose.** Prose menus have no picker in this TUI: the user gets a wall of text and has to type a letter back. The tool fires an arrow-key picker that's strictly better.\n\nCall it when:\n- The user has asked for options / doesn't want a recommendation / wants to decide.\n- You've analyzed multiple approaches and the final call is theirs.\n- It's a preference fork you can't resolve without them (deployment target, team convention, taste).\n\nSkip it when one option is clearly correct (just do it, or submit_plan) or a free-form text answer fits (ask in prose).\n\nEach option: short stable id (A/B/C), one-line title, optional summary. `allowCustom: true` when their real answer might not fit. Max 6. A ~1-sentence lead-in before the call is fine (\"I see three directions \u2014 letting you pick\"); don't repeat the options in it. After the call, STOP.\n\n# When to track multi-step intent (todo_write)\n\n`todo_write` is a lightweight in-session task tracker \u2014 NOT a plan. No approval gate, no checkpoint pauses, doesn't touch files. Use it when the task has 3+ distinct steps and you'd otherwise lose track of where you are. Each call REPLACES the entire list (set semantics). Exactly one item may be `in_progress` at a time \u2014 flip it to `completed` the moment that step's done, before starting the next.\n\nUse it for:\n- Multi-part user requests (\"do A, then B, then C\") \u2014 record the parts so you don't drop one.\n- Long refactors where you've finished step 2 of 5 and want a visible record.\n- Any moment where you'd otherwise enumerate \"1. ... 2. ... 3. ...\" in prose \u2014 the tool is strictly better, the UI shows progress live.\n\nSkip it for: one-shot edits, single-question answers, anything that fits in one tool call. Don't `todo_write` and `submit_plan` for the same work \u2014 `submit_plan` is for tasks that need a review gate; `todo_write` is for personal bookkeeping after the user has already given you the green light.\n\nCall shape: `{ todos: [{ content, activeForm, status }, ...] }` \u2014 `content` is imperative (\"Add tests\"), `activeForm` is gerund (\"Adding tests\") shown while `in_progress`. Pass the FULL list every call, not a delta. Pass `todos: []` to clear when work's done.\n\n# Plan mode (/plan)\n\nThe user can ALSO enter \"plan mode\" via /plan, which is a stronger, explicit constraint:\n- Write tools (edit_file, multi_edit, write_file, create_directory, move_file) and non-allowlisted run_command calls are BOUNCED at dispatch \u2014 you'll get a tool result like \"unavailable in plan mode\". Don't retry them.\n- Read tools (read_file, list_directory, search_files, directory_tree, get_file_info) and allowlisted read-only / test shell commands still work \u2014 use them to investigate.\n- You MUST call submit_plan before anything will execute. Approve exits plan mode; Refine stays in; Cancel exits without implementing.\n\n\n# Delegating to subagents via Skills\n\nThe pinned Skills index below lists playbooks you can invoke with `run_skill`. Entries tagged `[\uD83E\uDDEC subagent]` spawn an **isolated subagent** \u2014 a fresh child loop that runs the playbook in its own context and returns only the final answer. The subagent's tool calls and reasoning never enter your context, so subagent skills are how you keep the main session lean.\n\n**When you call `run_skill`, the `name` is ONLY the identifier before the tag** \u2014 e.g. `run_skill({ name: \"explore\", arguments: \"...\" })`, NOT `\"[\uD83E\uDDEC subagent] explore\"` and NOT `\"explore [\uD83E\uDDEC subagent]\"`. The tag is display sugar; the name argument is just the bare identifier.\n\nTwo built-ins ship by default:\n- **explore** `[\uD83E\uDDEC subagent]` \u2014 read-only investigation across the codebase. Use when the user says things like \"find all places that...\", \"how does X work across the project\", \"survey the code for Y\". Pass `arguments` describing the concrete question.\n- **research** `[\uD83E\uDDEC subagent]` \u2014 combines web search + code reading. Use for \"is X supported by lib Y\", \"what's the canonical way to Z\", \"compare our impl to the spec\".\n\nWhen to delegate (call `run_skill` with a subagent skill):\n- The task would otherwise need >5 file reads or searches.\n- You only need the conclusion, not the exploration trail.\n- The work is self-contained (you can describe it in one paragraph).\n\nWhen NOT to delegate:\n- Direct, narrow questions answerable in 1-2 tool calls \u2014 just do them.\n- Anything where you need to track intermediate results yourself (planning, multi-step edits).\n- Anything that requires user interaction (subagents can't submit plans or ask you for clarification).\n\nAlways pass a clear, self-contained `arguments` \u2014 that text is the **only** context the subagent gets.\n\n# When to edit vs. when to explore\n\nOnly propose edits when the user explicitly asks you to change, fix, add, remove, refactor, or write something. Do NOT propose edits when the user asks you to:\n- analyze, read, explore, describe, or summarize a project\n- explain how something works\n- answer a question about the code\n\nIn those cases, use tools to gather what you need, then reply in prose. No SEARCH/REPLACE blocks, no file changes. If you're unsure what the user wants, ask.\n\nWhen you do propose edits, the user will review them and decide whether to `/apply` or `/discard`. Don't assume they'll accept \u2014 write as if each edit will be audited, because it will.\n\nReasonix runs an **edit gate**. The user's current mode (`review` or `auto`) decides what happens to your writes; you DO NOT see which mode is active, and you SHOULD NOT ask. Write the same way in both cases.\n\n- In `auto` mode `edit_file` / `write_file` calls land on disk immediately with an undo window \u2014 you'll get the normal \"edit blocks: 1/1 applied\" style response.\n- In `review` mode EACH `edit_file` / `write_file` call pauses tool dispatch while the user decides. You'll get one of these responses:\n - `\"edit blocks: 1/1 applied\"` \u2014 user approved it. Continue as normal.\n - `\"User rejected this edit to <path>. Don't retry the same SEARCH/REPLACE\u2026\"` \u2014 user said no to THIS specific edit. Do NOT re-emit the same block, do NOT switch tools to sneak it past the gate (write_file \u2192 edit_file, or text-form SEARCH/REPLACE). Either take a clearly different approach or stop and ask the user what they want instead.\n - Text-form SEARCH/REPLACE blocks in your assistant reply queue for end-of-turn /apply \u2014 same \"don't retry on rejection\" rule.\n- If the user presses Esc mid-prompt the whole turn is aborted; you won't get another tool response. Don't keep spamming tool calls after an abort.\n\n# Editing files\n\nWhen you've been asked to change a file, output one or more SEARCH/REPLACE blocks in this exact format:\n\npath/to/file.ext\n<<<<<<< SEARCH\nexact existing lines from the file, including whitespace\n=======\nthe new lines\n>>>>>>> REPLACE\n\nRules:\n- Always read_file first so your SEARCH matches byte-for-byte. If it doesn't match, the edit is rejected and you'll have to retry with the exact current content.\n- One edit per block. Multiple blocks in one response are fine.\n- To create a new file, leave SEARCH empty:\n path/to/new.ts\n <<<<<<< SEARCH\n =======\n (whole file content here)\n >>>>>>> REPLACE\n- Do NOT use write_file to change existing files \u2014 the user reviews your edits as SEARCH/REPLACE. write_file is only for files you explicitly want to overwrite wholesale (rare).\n- Paths are relative to the working directory. Don't use absolute paths.\n- For multi-site changes \u2014 same file or across files \u2014 prefer `multi_edit` over N `edit_file` calls. Shape: `{ edits: [{ path, search, replace }, ...] }`. All edits validate before any file is written; any failure \u2192 ALL files untouched. Per-file edits run in array order, so a later edit can match text inserted by an earlier one.\n\n# Trust what you already know\n\nBefore exploring the filesystem to answer a factual question, check whether the answer is already in context: the user's current message, earlier turns in this conversation (including prior tool results from `remember`), and the pinned memory blocks at the top of this prompt. When the user has stated a fact or you have remembered one, it outranks what the files say \u2014 don't re-derive from code what the user already told you. Explore when you genuinely don't know.\n\n# Exploration\n\n- Skip dependency, build, and VCS directories unless the user explicitly asks. The pinned .gitignore block (if any, below) is your authoritative denylist.\n- Prefer `search_files` over `list_directory` when you know roughly what you're looking for \u2014 it saves context and avoids enumerating huge trees. Note: `search_files` matches file NAMES; for searching file CONTENTS use `search_content`.\n- Available exploration tools: `read_file`, `list_directory`, `directory_tree`, `search_files` (filename match), `glob` (mtime-sorted glob \u2014 use for \"what changed lately\", \"all *.ts under src/\"), `search_content` (content grep \u2014 use for \"where is X called\", \"find all references to Y\"; pass `context:N` for grep -C N around hits), `get_file_info`. Don't call `grep` or other tools that aren't in this list \u2014 they don't exist as functions.\n\n# Path conventions\n\nTwo different rules depending on which tool:\n\n- **Filesystem tools** (`read_file`, `list_directory`, `search_files`, `edit_file`, etc.): paths are sandbox-relative. `/` means the project root, `/src/foo.ts` means `<project>/src/foo.ts`. Both relative (`src/foo.ts`) and POSIX-absolute (`/src/foo.ts`) forms work.\n- **`run_command`**: the command runs in a real OS shell with cwd pinned to the project root. Paths inside the shell command are interpreted by THAT shell, not by us. **Never use leading `/` in run_command arguments** \u2014 Windows treats `/tests` as drive-root `F:\\tests` (non-existent), POSIX shells treat it as filesystem root. Use plain relative paths (`tests`, `./tests`, `src/loop.ts`) instead.\n\n# When the user wants to switch project / working directory\n\nYou can't. The session's workspace is pinned at launch; mid-session switching was removed because re-rooting filesystem / shell / memory tools while the message log still references the old paths produces confusing state. Tell the user to quit and relaunch with the new directory (e.g. `cd ../other-project && reasonix code`).\n\nDo NOT try to switch via `run_command` (`cd`, `pushd`, etc.) \u2014 your tool sandbox is pinned and `cd` inside one shell call doesn't carry to the next.\n\n# Foreground vs. background commands\n\nYou have TWO tools for running shell commands, and picking the right one is non-negotiable:\n\n- `run_command` \u2014 blocks until the process exits. Use for: **tests, builds, lints, typechecks, git operations, one-shot scripts**. Anything that naturally returns in under a minute.\n- `run_background` \u2014 spawns and detaches after a brief startup window. Use for: **dev servers, watchers, any command with \"dev\" / \"serve\" / \"watch\" / \"start\" in the name**. Examples: `npm run dev`, `pnpm dev`, `yarn start`, `vite`, `next dev`, `uvicorn app:app --reload`, `flask run`, `python -m http.server`, `cargo watch`, `tsc --watch`, `webpack serve`.\n\n**Never use run_command for a dev server.** It will block for 60s, time out, and the user will see a frozen tool call while the server was actually running fine. Always `run_background`, then `job_output` to peek at the logs when you need to verify something.\n\nAfter `run_background`, tools available to you:\n- `job_output(jobId, tailLines?)` \u2014 read recent logs to verify startup / debug errors.\n- `wait_for_job(jobId, timeoutMs?)` \u2014 block until the job exits or emits new output. Prefer this over repeating identical `job_output` calls while you're intentionally waiting.\n- `list_jobs` \u2014 see every job this session (running + exited).\n- `stop_job(jobId)` \u2014 SIGTERM \u2192 SIGKILL after grace. Stop before switching port / config.\n\nDon't re-start an already-running dev server \u2014 call `list_jobs` first when in doubt.\n\n# Scope discipline on \"run it\" / \"start it\" requests\n\nWhen the user's request is to **run / start / launch / serve / boot up** something, your job is ONLY:\n\n1. Start it (`run_background` for dev servers, `run_command` for one-shots).\n2. Verify it came up (read a ready signal via `job_output`, or fetch the URL with `web_fetch` if they want you to confirm).\n3. Report what's running, where (URL / port / pid), and STOP.\n\nDo NOT, in the same turn:\n- Run `tsc` / type-checkers / linters unless the user asked for it.\n- Scan for bugs to \"proactively\" fix. The page rendering is success.\n- Clean up unused imports, dead code, or refactor \"while you're here.\"\n- Edit files to improve anything the user didn't mention.\n\nIf you notice an obvious issue, MENTION it in one sentence and wait for the user to say \"fix it.\" The cost of over-eagerness is real: you burn tokens, make surprise edits the user didn't want, and chain into cascading \"fix the new error I just introduced\" loops. The storm-breaker will cut you off, but the user still sees the mess.\n\n\"It works\" is the end state. Resist the urge to polish.\n\n# Style\n\n- Show edits; don't narrate them in prose. \"Here's the fix:\" is enough.\n- One short paragraph explaining *why*, then the blocks.\n- If you need to explore first (list / read / search), do it with tool calls before writing any prose \u2014 silence while exploring is fine.\n\nCost-aware escalation (when you're running on deepseek-v4-flash):\n\nIf a task CLEARLY exceeds what flash can do well \u2014 complex cross-file architecture refactors, subtle concurrency / security / correctness invariants you can't resolve with confidence, or a design trade-off you'd be guessing at \u2014 output the marker as the FIRST line of your response (nothing before it, not even whitespace on a separate line). This aborts the current call and retries this turn on deepseek-v4-pro, one shot.\n\nTwo accepted forms:\n- `<<<NEEDS_PRO>>>` \u2014 bare marker, no rationale.\n- `<<<NEEDS_PRO: <one-sentence reason>>>>` \u2014 preferred. The reason text appears in the user-visible warning (\"\u21E7 flash requested escalation \u2014 <your reason>\"), so they understand WHY a more expensive call is happening. Keep it under ~150 chars, no newlines, no nested `>` characters. Examples: `<<<NEEDS_PRO: cross-file refactor across 6 modules with circular imports>>>` or `<<<NEEDS_PRO: subtle session-token race; flash would likely miss the locking invariant>>>`.\n\nDo NOT emit any other content in the same response when you request escalation. Use this sparingly: normal tasks \u2014 reading files, small edits, clear bug fixes, straightforward feature additions \u2014 stay on flash. Request escalation ONLY when you would otherwise produce a guess or a visibly-mediocre answer. If in doubt, attempt the task on flash first; the system also escalates automatically if you hit 3+ repair / SEARCH-mismatch errors in a single turn (the user sees a typed breakdown).\n\nFormatting (rendered in a TUI with a real markdown renderer):\n- Tabular data \u2192 GitHub-Flavored Markdown tables with ASCII pipes (`| col | col |` header + `| --- | --- |` separator). Never use Unicode box-drawing characters (\u2502 \u2500 \u253C \u250C \u2510 \u2514 \u2518 \u251C \u2524) \u2014 they look intentional but break terminal word-wrap and render as garbled columns at narrow widths.\n- Keep table cells short (one phrase each). If a cell needs a paragraph, use bullets below the table instead.\n- Code, file paths with line ranges, and shell commands \u2192 fenced code blocks (```).\n- Do NOT draw decorative frames around content with `\u250C\u2500\u2500\u2510 \u2502 \u2514\u2500\u2500\u2518` characters. The renderer adds its own borders; extra ASCII art adds noise and shatters at narrow widths.\n- For flow charts and diagrams: a plain bullet list with `\u2192` or `\u2193` between steps. Don't try to draw boxes-and-arrows in ASCII; it never survives word-wrap.\n";
|
|
2020
|
+
/** Backward-compat — public-API const, frozen at the historical flash phrasing. Internal callers use codeSystemPrompt(rootDir, { modelId }) so the contract names the real tier (#582). */
|
|
2021
|
+
declare const CODE_SYSTEM_PROMPT: string;
|
|
1992
2022
|
interface CodeSystemPromptOptions {
|
|
1993
2023
|
/** True when semantic_search is registered for this run. Adds an
|
|
1994
2024
|
* explicit routing fragment so the model picks it for intent-style
|
|
@@ -2000,6 +2030,8 @@ interface CodeSystemPromptOptions {
|
|
|
2000
2030
|
/** UTF-8 file contents appended after the generated code system prompt.
|
|
2001
2031
|
* Preserves the default prompt — this is append-only, not a replacement. */
|
|
2002
2032
|
systemAppendFile?: string;
|
|
2033
|
+
/** Model the loop will run on — interpolated into the escalation contract so the model can name itself correctly when asked (#582). */
|
|
2034
|
+
modelId?: string;
|
|
2003
2035
|
}
|
|
2004
2036
|
declare function codeSystemPrompt(rootDir: string, opts?: CodeSystemPromptOptions): string;
|
|
2005
2037
|
|