reasonix 0.32.0 → 0.33.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.
Files changed (118) hide show
  1. package/dist/cli/chat-EIFLHBZ6.js +39 -0
  2. package/dist/cli/chunk-2AWTGJ2C.js +110 -0
  3. package/dist/cli/chunk-2AWTGJ2C.js.map +1 -0
  4. package/dist/cli/chunk-3Q3C4W66.js +30 -0
  5. package/dist/cli/chunk-3Q3C4W66.js.map +1 -0
  6. package/dist/cli/chunk-4DCHFFEY.js +149 -0
  7. package/dist/cli/chunk-4DCHFFEY.js.map +1 -0
  8. package/dist/cli/chunk-5X7LZJDE.js +36 -0
  9. package/dist/cli/chunk-5X7LZJDE.js.map +1 -0
  10. package/dist/cli/chunk-6TMHAK5D.js +576 -0
  11. package/dist/cli/chunk-6TMHAK5D.js.map +1 -0
  12. package/dist/cli/chunk-APPB3ZPQ.js +43 -0
  13. package/dist/cli/chunk-APPB3ZPQ.js.map +1 -0
  14. package/dist/cli/chunk-BQNUJJN7.js +42 -0
  15. package/dist/cli/chunk-BQNUJJN7.js.map +1 -0
  16. package/dist/cli/chunk-CPOV2O73.js +39 -0
  17. package/dist/cli/chunk-CPOV2O73.js.map +1 -0
  18. package/dist/cli/chunk-D5DKXIP5.js +368 -0
  19. package/dist/cli/chunk-D5DKXIP5.js.map +1 -0
  20. package/dist/cli/chunk-DFP4YSVM.js +247 -0
  21. package/dist/cli/chunk-DFP4YSVM.js.map +1 -0
  22. package/dist/cli/chunk-DULSP7JH.js +410 -0
  23. package/dist/cli/chunk-DULSP7JH.js.map +1 -0
  24. package/dist/cli/chunk-FM57FNPJ.js +46 -0
  25. package/dist/cli/chunk-FM57FNPJ.js.map +1 -0
  26. package/dist/cli/chunk-FWGEHRB7.js +54 -0
  27. package/dist/cli/chunk-FWGEHRB7.js.map +1 -0
  28. package/dist/cli/chunk-FXGQ5NHE.js +513 -0
  29. package/dist/cli/chunk-FXGQ5NHE.js.map +1 -0
  30. package/dist/cli/chunk-G3XNWSFN.js +53 -0
  31. package/dist/cli/chunk-G3XNWSFN.js.map +1 -0
  32. package/dist/cli/chunk-I6YIAK6C.js +757 -0
  33. package/dist/cli/chunk-I6YIAK6C.js.map +1 -0
  34. package/dist/cli/chunk-J5VLP23S.js +94 -0
  35. package/dist/cli/chunk-J5VLP23S.js.map +1 -0
  36. package/dist/cli/chunk-KMWKGPFZ.js +303 -0
  37. package/dist/cli/chunk-KMWKGPFZ.js.map +1 -0
  38. package/dist/cli/chunk-LVQX5KGF.js +14934 -0
  39. package/dist/cli/chunk-LVQX5KGF.js.map +1 -0
  40. package/dist/cli/chunk-MHDNZXJJ.js +48 -0
  41. package/dist/cli/chunk-MHDNZXJJ.js.map +1 -0
  42. package/dist/cli/chunk-ORM6PK57.js +140 -0
  43. package/dist/cli/chunk-ORM6PK57.js.map +1 -0
  44. package/dist/cli/chunk-Q5GRLZJF.js +99 -0
  45. package/dist/cli/chunk-Q5GRLZJF.js.map +1 -0
  46. package/dist/cli/chunk-Q6YFXW7H.js +4986 -0
  47. package/dist/cli/chunk-Q6YFXW7H.js.map +1 -0
  48. package/dist/cli/chunk-QGE6AF76.js +1467 -0
  49. package/dist/cli/chunk-QGE6AF76.js.map +1 -0
  50. package/dist/cli/chunk-RFX7TYVV.js +28 -0
  51. package/dist/cli/chunk-RFX7TYVV.js.map +1 -0
  52. package/dist/cli/chunk-RZILUXUC.js +940 -0
  53. package/dist/cli/chunk-RZILUXUC.js.map +1 -0
  54. package/dist/cli/chunk-SDE5U32Z.js +535 -0
  55. package/dist/cli/chunk-SDE5U32Z.js.map +1 -0
  56. package/dist/cli/chunk-SOZE7V7V.js +340 -0
  57. package/dist/cli/chunk-SOZE7V7V.js.map +1 -0
  58. package/dist/cli/chunk-U3V2ZQ5J.js +479 -0
  59. package/dist/cli/chunk-U3V2ZQ5J.js.map +1 -0
  60. package/dist/cli/chunk-W4LDFAZ6.js +1544 -0
  61. package/dist/cli/chunk-W4LDFAZ6.js.map +1 -0
  62. package/dist/cli/chunk-WBDE4IRI.js +208 -0
  63. package/dist/cli/chunk-WBDE4IRI.js.map +1 -0
  64. package/dist/cli/chunk-XHQIK7B6.js +189 -0
  65. package/dist/cli/chunk-XHQIK7B6.js.map +1 -0
  66. package/dist/cli/chunk-XJLZ4HKU.js +307 -0
  67. package/dist/cli/chunk-XJLZ4HKU.js.map +1 -0
  68. package/dist/cli/chunk-ZPTSJGX5.js +88 -0
  69. package/dist/cli/chunk-ZPTSJGX5.js.map +1 -0
  70. package/dist/cli/chunk-ZTLZO42A.js +231 -0
  71. package/dist/cli/chunk-ZTLZO42A.js.map +1 -0
  72. package/dist/cli/code-F4KJOE3K.js +151 -0
  73. package/dist/cli/code-F4KJOE3K.js.map +1 -0
  74. package/dist/cli/commands-JWT2MWVH.js +352 -0
  75. package/dist/cli/commands-JWT2MWVH.js.map +1 -0
  76. package/dist/cli/commit-RPZBOZS2.js +288 -0
  77. package/dist/cli/commit-RPZBOZS2.js.map +1 -0
  78. package/dist/cli/diff-NTEHCSDW.js +145 -0
  79. package/dist/cli/diff-NTEHCSDW.js.map +1 -0
  80. package/dist/cli/doctor-3TGB2NZN.js +19 -0
  81. package/dist/cli/doctor-3TGB2NZN.js.map +1 -0
  82. package/dist/cli/events-P27CX7LN.js +338 -0
  83. package/dist/cli/events-P27CX7LN.js.map +1 -0
  84. package/dist/cli/index.js +80 -33693
  85. package/dist/cli/index.js.map +1 -1
  86. package/dist/cli/mcp-ARTNQ24O.js +266 -0
  87. package/dist/cli/mcp-ARTNQ24O.js.map +1 -0
  88. package/dist/cli/mcp-browse-HLO2ENDL.js +163 -0
  89. package/dist/cli/mcp-browse-HLO2ENDL.js.map +1 -0
  90. package/dist/cli/mcp-inspect-T2HBR22P.js +103 -0
  91. package/dist/cli/mcp-inspect-T2HBR22P.js.map +1 -0
  92. package/dist/cli/{prompt-XHICFAYN.js → prompt-V47QKSAR.js} +3 -2
  93. package/dist/cli/prompt-V47QKSAR.js.map +1 -0
  94. package/dist/cli/prune-sessions-ERL6B4G5.js +42 -0
  95. package/dist/cli/prune-sessions-ERL6B4G5.js.map +1 -0
  96. package/dist/cli/replay-TMJASRC4.js +273 -0
  97. package/dist/cli/replay-TMJASRC4.js.map +1 -0
  98. package/dist/cli/run-JMEOTQCG.js +215 -0
  99. package/dist/cli/run-JMEOTQCG.js.map +1 -0
  100. package/dist/cli/server-SYC3OVOP.js +2967 -0
  101. package/dist/cli/server-SYC3OVOP.js.map +1 -0
  102. package/dist/cli/sessions-MOJAALJI.js +102 -0
  103. package/dist/cli/sessions-MOJAALJI.js.map +1 -0
  104. package/dist/cli/setup-CCJZAWTY.js +404 -0
  105. package/dist/cli/setup-CCJZAWTY.js.map +1 -0
  106. package/dist/cli/stats-5RJCATCE.js +12 -0
  107. package/dist/cli/stats-5RJCATCE.js.map +1 -0
  108. package/dist/cli/update-4TJWRUIN.js +90 -0
  109. package/dist/cli/update-4TJWRUIN.js.map +1 -0
  110. package/dist/cli/version-3MYFE4G6.js +29 -0
  111. package/dist/cli/version-3MYFE4G6.js.map +1 -0
  112. package/dist/index.d.ts +13 -2
  113. package/dist/index.js +493 -89
  114. package/dist/index.js.map +1 -1
  115. package/package.json +1 -1
  116. package/dist/cli/chunk-VWFJNLIK.js +0 -1031
  117. package/dist/cli/chunk-VWFJNLIK.js.map +0 -1
  118. /package/dist/cli/{prompt-XHICFAYN.js.map → chat-EIFLHBZ6.js.map} +0 -0
@@ -0,0 +1,479 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/prompt-fragments.ts
4
+ var TUI_FORMATTING_RULES = `Formatting (rendered in a TUI with a real markdown renderer):
5
+ - 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.
6
+ - Keep table cells short (one phrase each). If a cell needs a paragraph, use bullets below the table instead.
7
+ - Code, file paths with line ranges, and shell commands \u2192 fenced code blocks (\`\`\`).
8
+ - 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.
9
+ - 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.`;
10
+ var ESCALATION_CONTRACT = `Cost-aware escalation (when you're running on deepseek-v4-flash):
11
+
12
+ If 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.
13
+
14
+ Two accepted forms:
15
+ - \`<<<NEEDS_PRO>>>\` \u2014 bare marker, no rationale.
16
+ - \`<<<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>>>\`.
17
+
18
+ Do 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).`;
19
+ var NEGATIVE_CLAIM_RULE = `Negative claims ("X is missing", "Y isn't implemented", "there's no Z") are the #1 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.
20
+
21
+ If you have a search tool (\`search_content\`, \`grep\`, web search), call it FIRST before asserting absence:
22
+ - Returns matches \u2192 you were wrong; correct yourself and cite the matches.
23
+ - Returns nothing \u2192 state the absence WITH the search query as evidence: \`No callers of \\\`foo()\\\` found (search_content "foo").\`
24
+
25
+ If you have no search tool, qualify hard: "I haven't verified \u2014 this is a guess." Never assert absence with fake authority.`;
26
+
27
+ // src/memory/project.ts
28
+ import { existsSync, readFileSync } from "fs";
29
+ import { join } from "path";
30
+ var PROJECT_MEMORY_FILE = "REASONIX.md";
31
+ var PROJECT_MEMORY_MAX_CHARS = 8e3;
32
+ function readProjectMemory(rootDir) {
33
+ const path = join(rootDir, PROJECT_MEMORY_FILE);
34
+ if (!existsSync(path)) return null;
35
+ let raw;
36
+ try {
37
+ raw = readFileSync(path, "utf8");
38
+ } catch {
39
+ return null;
40
+ }
41
+ const trimmed = raw.trim();
42
+ if (!trimmed) return null;
43
+ const originalChars = trimmed.length;
44
+ const truncated = originalChars > PROJECT_MEMORY_MAX_CHARS;
45
+ const content = truncated ? `${trimmed.slice(0, PROJECT_MEMORY_MAX_CHARS)}
46
+ \u2026 (truncated ${originalChars - PROJECT_MEMORY_MAX_CHARS} chars)` : trimmed;
47
+ return { path, content, originalChars, truncated };
48
+ }
49
+ function memoryEnabled() {
50
+ const env = process.env.REASONIX_MEMORY;
51
+ if (env === "off" || env === "false" || env === "0") return false;
52
+ return true;
53
+ }
54
+ function applyProjectMemory(basePrompt, rootDir) {
55
+ if (!memoryEnabled()) return basePrompt;
56
+ const mem = readProjectMemory(rootDir);
57
+ if (!mem) return basePrompt;
58
+ return `${basePrompt}
59
+
60
+ # Project memory (REASONIX.md)
61
+
62
+ The user pinned these notes about this project \u2014 treat them as authoritative context for every turn:
63
+
64
+ \`\`\`
65
+ ${mem.content}
66
+ \`\`\`
67
+ `;
68
+ }
69
+
70
+ // src/skills.ts
71
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, readdirSync, statSync, writeFileSync } from "fs";
72
+ import { homedir } from "os";
73
+ import { dirname, join as join2, resolve } from "path";
74
+ var SKILLS_DIRNAME = "skills";
75
+ var SKILL_FILE = "SKILL.md";
76
+ var SKILLS_INDEX_MAX_CHARS = 4e3;
77
+ var VALID_SKILL_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/;
78
+ function parseFrontmatter(raw) {
79
+ const lines = raw.split(/\r?\n/);
80
+ if (lines[0] !== "---") return { data: {}, body: raw };
81
+ const end = lines.indexOf("---", 1);
82
+ if (end < 0) return { data: {}, body: raw };
83
+ const data = {};
84
+ for (let i = 1; i < end; i++) {
85
+ const line = lines[i];
86
+ if (!line) continue;
87
+ const m = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*):\s*(.*)$/);
88
+ if (m?.[1]) data[m[1]] = (m[2] ?? "").trim();
89
+ }
90
+ return {
91
+ data,
92
+ body: lines.slice(end + 1).join("\n").replace(/^\n+/, "")
93
+ };
94
+ }
95
+ function isValidSkillName(name) {
96
+ return VALID_SKILL_NAME.test(name);
97
+ }
98
+ function parseAllowedTools(raw) {
99
+ if (raw === void 0) return void 0;
100
+ const names = raw.split(",").map((s) => s.trim()).filter(Boolean);
101
+ return names.length > 0 ? Object.freeze(names) : void 0;
102
+ }
103
+ var SkillStore = class {
104
+ homeDir;
105
+ projectRoot;
106
+ disableBuiltins;
107
+ constructor(opts = {}) {
108
+ this.homeDir = opts.homeDir ?? homedir();
109
+ this.projectRoot = opts.projectRoot ? resolve(opts.projectRoot) : void 0;
110
+ this.disableBuiltins = opts.disableBuiltins === true;
111
+ }
112
+ /** True iff this store was configured with a project root. */
113
+ hasProjectScope() {
114
+ return this.projectRoot !== void 0;
115
+ }
116
+ /** Project scope first so per-repo skill overrides a global with the same name. */
117
+ roots() {
118
+ const out = [];
119
+ if (this.projectRoot) {
120
+ out.push({
121
+ dir: join2(this.projectRoot, ".reasonix", SKILLS_DIRNAME),
122
+ scope: "project"
123
+ });
124
+ }
125
+ out.push({ dir: join2(this.homeDir, ".reasonix", SKILLS_DIRNAME), scope: "global" });
126
+ return out;
127
+ }
128
+ /** Higher-priority root wins on collision (project > global > builtin); sorted for stable prefix hash. */
129
+ list() {
130
+ const byName = /* @__PURE__ */ new Map();
131
+ for (const { dir, scope } of this.roots()) {
132
+ if (!existsSync2(dir)) continue;
133
+ let entries;
134
+ try {
135
+ entries = readdirSync(dir, { withFileTypes: true });
136
+ } catch {
137
+ continue;
138
+ }
139
+ for (const entry of entries) {
140
+ const skill = this.readEntry(dir, scope, entry);
141
+ if (!skill) continue;
142
+ if (!byName.has(skill.name)) byName.set(skill.name, skill);
143
+ }
144
+ }
145
+ if (!this.disableBuiltins) {
146
+ for (const skill of BUILTIN_SKILLS) {
147
+ if (!byName.has(skill.name)) byName.set(skill.name, skill);
148
+ }
149
+ }
150
+ return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
151
+ }
152
+ /** Scaffold a new skill stub at the chosen scope. Refuses to overwrite. */
153
+ create(name, scope) {
154
+ if (!isValidSkillName(name)) {
155
+ return { error: `invalid skill name: "${name}" \u2014 use letters, digits, _, -, .` };
156
+ }
157
+ if (scope === "project" && !this.projectRoot) {
158
+ return { error: "project scope requires a workspace \u2014 run from `reasonix code`" };
159
+ }
160
+ const root = scope === "project" ? join2(this.projectRoot ?? "", ".reasonix", SKILLS_DIRNAME) : join2(this.homeDir, ".reasonix", SKILLS_DIRNAME);
161
+ const flat = join2(root, `${name}.md`);
162
+ const folder = join2(root, name, SKILL_FILE);
163
+ if (existsSync2(folder)) {
164
+ return { error: `skill "${name}" already exists at ${folder}` };
165
+ }
166
+ mkdirSync(dirname(flat), { recursive: true });
167
+ try {
168
+ writeFileSync(flat, skillStubBody(name), { encoding: "utf8", flag: "wx" });
169
+ } catch (err) {
170
+ if (err.code === "EEXIST") {
171
+ return { error: `skill "${name}" already exists at ${flat}` };
172
+ }
173
+ throw err;
174
+ }
175
+ return { path: flat };
176
+ }
177
+ /** Resolve one skill by name. Returns `null` if not found or malformed. */
178
+ read(name) {
179
+ if (!isValidSkillName(name)) return null;
180
+ for (const { dir, scope } of this.roots()) {
181
+ if (!existsSync2(dir)) continue;
182
+ const dirCandidate = join2(dir, name, SKILL_FILE);
183
+ if (existsSync2(dirCandidate) && statSync(dirCandidate).isFile()) {
184
+ return this.parse(dirCandidate, name, scope);
185
+ }
186
+ const flatCandidate = join2(dir, `${name}.md`);
187
+ if (existsSync2(flatCandidate) && statSync(flatCandidate).isFile()) {
188
+ return this.parse(flatCandidate, name, scope);
189
+ }
190
+ }
191
+ if (!this.disableBuiltins) {
192
+ for (const skill of BUILTIN_SKILLS) {
193
+ if (skill.name === name) return skill;
194
+ }
195
+ }
196
+ return null;
197
+ }
198
+ readEntry(dir, scope, entry) {
199
+ if (entry.isDirectory()) {
200
+ if (!isValidSkillName(entry.name)) return null;
201
+ const file = join2(dir, entry.name, SKILL_FILE);
202
+ if (!existsSync2(file)) return null;
203
+ return this.parse(file, entry.name, scope);
204
+ }
205
+ if (entry.isFile() && entry.name.endsWith(".md")) {
206
+ const stem = entry.name.slice(0, -3);
207
+ if (!isValidSkillName(stem)) return null;
208
+ return this.parse(join2(dir, entry.name), stem, scope);
209
+ }
210
+ return null;
211
+ }
212
+ parse(path, stem, scope) {
213
+ let raw;
214
+ try {
215
+ raw = readFileSync2(path, "utf8");
216
+ } catch {
217
+ return null;
218
+ }
219
+ const { data, body } = parseFrontmatter(raw);
220
+ const name = data.name && isValidSkillName(data.name) ? data.name : stem;
221
+ return {
222
+ name,
223
+ description: (data.description ?? "").trim(),
224
+ body: body.trim(),
225
+ scope,
226
+ path,
227
+ allowedTools: parseAllowedTools(data["allowed-tools"]),
228
+ runAs: parseRunAs(data.runAs),
229
+ model: data.model?.startsWith("deepseek-") ? data.model : void 0
230
+ };
231
+ }
232
+ };
233
+ function parseRunAs(raw) {
234
+ return raw?.trim() === "subagent" ? "subagent" : "inline";
235
+ }
236
+ function skillStubBody(name) {
237
+ return `---
238
+ name: ${name}
239
+ description: One-liner \u2014 what does this skill do?
240
+ ---
241
+
242
+ # ${name}
243
+
244
+ Replace this body with the playbook the model should follow when this skill is invoked.
245
+
246
+ Tips:
247
+ - Reference tools by name (run_command, edit_file, search_content, ...)
248
+ - Add \`runAs: subagent\` to frontmatter to spawn an isolated subagent loop
249
+ - Add \`allowed-tools: read_file, search_content\` to scope a subagent's tools
250
+ `;
251
+ }
252
+ function skillIndexLine(s) {
253
+ const safeDesc = s.description.replace(/\n/g, " ").trim();
254
+ const tag = s.runAs === "subagent" ? " [\u{1F9EC} subagent]" : "";
255
+ const max = 130 - s.name.length - tag.length;
256
+ const clipped = safeDesc.length > max ? `${safeDesc.slice(0, Math.max(1, max - 1))}\u2026` : safeDesc;
257
+ return clipped ? `- ${s.name}${tag} \u2014 ${clipped}` : `- ${s.name}${tag}`;
258
+ }
259
+ function applySkillsIndex(basePrompt, opts = {}) {
260
+ const store = new SkillStore(opts);
261
+ const skills = store.list().filter((s) => s.description);
262
+ if (skills.length === 0) return basePrompt;
263
+ const lines = skills.map(skillIndexLine);
264
+ const joined = lines.join("\n");
265
+ const truncated = joined.length > SKILLS_INDEX_MAX_CHARS ? `${joined.slice(0, SKILLS_INDEX_MAX_CHARS)}
266
+ \u2026 (truncated ${joined.length - SKILLS_INDEX_MAX_CHARS} chars)` : joined;
267
+ return [
268
+ basePrompt,
269
+ "",
270
+ "# Skills \u2014 playbooks you can invoke",
271
+ "",
272
+ 'One-liner index. Each entry is either a built-in or a user-authored playbook. Call `run_skill({ name: "<skill-name>", arguments: "<task>" })` \u2014 the `name` is JUST the skill identifier (e.g. `"explore"`), NOT the `[\u{1F9EC} subagent]` tag that appears after it. Entries tagged `[\u{1F9EC} subagent]` spawn an **isolated subagent** \u2014 its tool calls and reasoning never enter your context, only its final answer does. Use subagent skills for tasks that would otherwise flood your context (deep exploration, multi-step research, anything where you only need the conclusion). Plain skills are inlined: their body becomes a tool result you read and act on directly. The user can also invoke a skill via `/skill <name>`.',
273
+ "",
274
+ "```",
275
+ truncated,
276
+ "```"
277
+ ].join("\n");
278
+ }
279
+ var BUILTIN_EXPLORE_BODY = `You are running as an exploration subagent. Your job is to investigate the codebase the parent agent pointed you at, then return one focused, distilled answer.
280
+
281
+ How to operate:
282
+ - Use read_file, search_files, search_content, directory_tree, list_directory, get_file_info as your primary tools. Stay read-only.
283
+ - For "find all places that call / reference / use X" questions, use \`search_content\` (content grep) \u2014 NOT \`search_files\` (which only matches file names). This is the most common subagent mistake; using the wrong tool gives empty results and you waste your iter budget chasing a phantom.
284
+ - Cast a wide net first (search_content for symbol references, directory_tree for structure) to map the territory; then read the 3-10 most relevant files in full.
285
+ - Don't read every file \u2014 be selective. Aim for breadth on the first pass, depth only where the question demands it.
286
+ - Stop exploring as soon as you can answer the question. The parent doesn't see your tool calls, so over-exploration is pure waste.
287
+
288
+ Your final answer:
289
+ - One paragraph (or a few short bullets). Lead with the conclusion.
290
+ - Cite specific file paths + line ranges when they support the answer.
291
+ - If the question can't be answered from what you found, say so plainly and suggest where to look next.
292
+ - No follow-up offers, no "let me know if you need more." The parent will ask again if they need more.
293
+
294
+ ${NEGATIVE_CLAIM_RULE}
295
+
296
+ ${TUI_FORMATTING_RULES}
297
+
298
+ The 'task' the parent gave you is the question you must answer. Treat any other reading of it as scope creep.`;
299
+ var BUILTIN_RESEARCH_BODY = `You are running as a research subagent. Your job is to gather information from code AND the web, synthesize it, and return one focused conclusion.
300
+
301
+ How to operate:
302
+ - Combine code reading (read_file, search_files) with web tools (web_search, web_fetch) as appropriate to the question.
303
+ - For "how does X work" / "is Y supported" questions: web first to find the canonical reference, then verify against the local code.
304
+ - For "what's our policy on Z" / "where do we use Q": local code first, web only if you need to compare against external standards.
305
+ - Cap yourself at ~10 tool calls. If you can't converge in 10, return what you have plus a note about what's missing.
306
+
307
+ Your final answer:
308
+ - One paragraph (or short bullets). Lead with the conclusion.
309
+ - Cite both code (file:line) AND web sources (URL) when they back the answer.
310
+ - Distinguish "I verified this in code" from "I read this on a docs page" \u2014 the parent will trust the former more.
311
+ - If the answer is uncertain, say so. Don't invent confidence.
312
+
313
+ ${NEGATIVE_CLAIM_RULE}
314
+
315
+ ${TUI_FORMATTING_RULES}
316
+
317
+ The 'task' the parent gave you is the research question. Stay on it.`;
318
+ var BUILTIN_REVIEW_BODY = `You are running as a code-review subagent. Your job is to inspect the changes the user is about to ship \u2014 usually the current git branch vs its upstream \u2014 and produce a focused review the parent can hand back to the user.
319
+
320
+ How to operate:
321
+ - Default scope: the current branch's diff vs the default branch. If the user's task names a specific commit range or files, honor that instead.
322
+ - Discover scope first: \`run_command git status\`, \`git diff --stat\`, \`git log --oneline\` to see what changed. Then \`git diff\` (or \`git diff <base>...HEAD\`) for the actual hunks.
323
+ - Read the touched files (\`read_file\`) when the diff alone doesn't carry enough context \u2014 function signatures, surrounding invariants, callers.
324
+ - For "any callers depending on this?" questions: \`search_content\` against the symbol BEFORE asserting impact.
325
+ - Stay read-only. Never \`run_command git commit\`, never write files, never propose SEARCH/REPLACE blocks. The parent decides whether to act on your findings.
326
+ - Cap yourself at ~12 tool calls. If the diff is too big to review in one pass, pick the riskiest 2-3 files and say so explicitly.
327
+
328
+ What to look for, in priority order:
329
+ 1. **Correctness bugs** \u2014 off-by-one, null/undefined handling, race conditions, wrong sign / wrong operator, edge cases the code doesn't handle.
330
+ 2. **Security** \u2014 injection (SQL, shell, path traversal), secrets in code, missing authz checks, unsafe deserialization.
331
+ 3. **Behavior changes the diff hides** \u2014 renames that miss callers, removed branches that were load-bearing, error-handling that now swallows what used to surface.
332
+ 4. **Tests** \u2014 does the change have tests for the new behavior? Are existing tests still meaningful, or did the change make them tautological?
333
+ 5. **Style + consistency** \u2014 only flag deviations that matter (unsafe \`any\`, missing types in TypeScript, inconsistent error shape). Don't pile on cosmetic nits if the substance is clean.
334
+
335
+ Your final answer:
336
+ - Lead with a one-sentence verdict: "ship as-is" / "minor nits, OK to ship after" / "blocking issues, do not ship".
337
+ - Then a short bulleted list of issues, each with: file:line citation + the problem in one sentence + what to change.
338
+ - Group by severity if you have more than 4 items: **Blocking**, **Should-fix**, **Nits**.
339
+ - If everything looks clean, say so plainly. Don't manufacture concerns.
340
+
341
+ ${NEGATIVE_CLAIM_RULE}
342
+
343
+ ${TUI_FORMATTING_RULES}
344
+
345
+ The 'task' the parent gave you describes WHAT to review (a branch, a file set, or "the pending changes"). Stay on it; don't redesign the feature.`;
346
+ var BUILTIN_SECURITY_REVIEW_BODY = `You are running as a security-review subagent. Your job is to inspect the changes the user is about to ship \u2014 usually the current git branch vs its upstream \u2014 through a security lens specifically, and report exploitable issues.
347
+
348
+ How to operate:
349
+ - Default scope: the current branch's diff vs the default branch. If the user names a different range or a directory, honor that.
350
+ - Discover scope first: \`git status\`, \`git diff --stat\`, \`git diff <base>...HEAD\`. Read touched files (\`read_file\`) when the diff alone doesn't carry security context \u2014 auth checks, input validation, the actual handler that calls into the changed function.
351
+ - Use \`search_content\` to verify "is this user-controlled input ever sanitized later?" / "are there other call sites that depend on this validation?" before asserting impact.
352
+ - Stay read-only. Never write, never run destructive commands, never propose SEARCH/REPLACE blocks. The parent decides what to act on.
353
+ - Cap yourself at ~12 tool calls. If the diff is too big, focus on the riskiest 2-3 files and say so explicitly.
354
+
355
+ Threat model \u2014 flag with severity:
356
+
357
+ **CRITICAL** (do-not-ship):
358
+ - SQL / NoSQL / shell / template injection \u2014 user input concatenated into a query, command, or template without parameterization.
359
+ - Path traversal \u2014 user-controlled filenames touching the filesystem without canonicalization + sandbox check.
360
+ - Authentication / authorization missing \u2014 endpoints / actions that should require a session check but don't.
361
+ - Hardcoded secrets \u2014 API keys, passwords, signing tokens visible in the diff.
362
+ - Deserialization of untrusted input \u2014 \`pickle.loads\`, \`yaml.load\` (non-safe), \`eval\`, \`Function()\`, \`unserialize()\`.
363
+ - Cryptographic mistakes \u2014 homemade crypto, weak hashes (MD5/SHA-1) for passwords, missing IVs, ECB mode, predictable nonces.
364
+
365
+ **HIGH**:
366
+ - XSS \u2014 user input rendered into HTML without escaping (or wrong escaping context).
367
+ - SSRF \u2014 fetching URLs from user input without an allowlist.
368
+ - Race conditions in security-relevant code \u2014 TOCTOU on auth/file checks.
369
+ - Open redirects \u2014 user-controlled URL passed to a redirect helper.
370
+ - Insufficient logging on security events (login failure, permission denial) \u2014 only flag if the codebase clearly DOES log elsewhere.
371
+
372
+ **MEDIUM**:
373
+ - Verbose error messages leaking internal paths / stack traces / SQL.
374
+ - Missing rate limiting on a credential / token endpoint.
375
+ - Cross-origin / cookie-flag issues (missing \`Secure\` / \`HttpOnly\` / \`SameSite\`).
376
+
377
+ Things to NOT pile on (out of scope here \u2014 the regular /review covers them):
378
+ - Style, formatting, naming.
379
+ - Performance, refactor opportunities, test coverage gaps that aren't security-relevant.
380
+ - "Should be a constant" / "extract this helper" \u2014 irrelevant to ship-blocking.
381
+
382
+ Your final answer:
383
+ - Lead with a one-sentence verdict: "no security issues found", "minor concerns", or "blocking issues".
384
+ - Then a list grouped by severity. Each item: file:line + 1-sentence threat + 1-sentence fix direction (no full SEARCH/REPLACE \u2014 the user / parent agent will write that).
385
+ - If clean, say so plainly. Don't manufacture findings.
386
+
387
+ ${NEGATIVE_CLAIM_RULE}
388
+
389
+ ${TUI_FORMATTING_RULES}
390
+
391
+ The 'task' the parent gave you names what to review. Stay on it; don't redesign the feature.`;
392
+ var BUILTIN_TEST_BODY = `You are running as the parent agent \u2014 this skill is INLINED, not a subagent. The user invoked /test (or asked you to "run the tests and fix failures"). Your job: run the project's test suite, diagnose any failure, propose fixes as SEARCH/REPLACE edit blocks, then re-run. Repeat until green or you hit a wall you should escalate.
393
+
394
+ How to operate:
395
+
396
+ 1. **Detect the test command**.
397
+ - Look for \`package.json\` \u2192 \`scripts.test\` first (most common: \`npm test\`, \`pnpm test\`, \`yarn test\`).
398
+ - If no package.json or no test script: try \`pytest\`, \`go test ./...\`, \`cargo test\` based on what files exist (pyproject.toml/requirements.txt \u2192 pytest; go.mod \u2192 go test; Cargo.toml \u2192 cargo test).
399
+ - If you can't tell, ASK the user for the command \u2014 don't guess. One question, one tool call to confirm.
400
+
401
+ 2. **Run it via run_command** (typical timeout 120s, bigger if the suite is large). Capture stdout + stderr.
402
+
403
+ 3. **Read the failures**. Pull out: which test names failed, the actual error/traceback, the file + line that threw. Don't just paraphrase \u2014 locate the exact assertion or stack frame.
404
+
405
+ 4. **Propose fixes**. For each distinct failure:
406
+ - If the failure is in PRODUCTION code (test catches a real bug) \u2192 propose a SEARCH/REPLACE that fixes the production code.
407
+ - If the failure is in TEST code (test is wrong, codebase is right) \u2192 propose a SEARCH/REPLACE that updates the test, AND say so explicitly: "This is a test bug, not a production bug \u2014 updating the assertion."
408
+ - If the failure is environmental (missing dep, wrong node version, missing fixture file) \u2192 say so and stop. Don't try to install packages or change config without checking with the user.
409
+
410
+ 5. **Apply + re-run**. After the user accepts the edit blocks, run the test command again. Iterate.
411
+
412
+ 6. **Stop conditions**:
413
+ - All tests pass \u2192 report green, summarize what changed.
414
+ - Same test still failing after 2 fix attempts on the same line \u2192 STOP. Tell the user "I've tried twice, it's still failing \u2014 here's what I think is happening, want me to try a different angle?". Don't loop indefinitely.
415
+ - 3+ unrelated failures \u2192 fix one at a time, smallest first, so each pass narrows the surface.
416
+
417
+ Don't:
418
+ - Run \`npm install\` / \`pip install\` / \`cargo update\` without asking \u2014 those mutate lockfiles and have global effects.
419
+ - Disable, skip, or delete failing tests to "make it green". If a test seems wrong, update its assertion with a one-sentence explanation, but never add \`.skip\` / \`it.skip\` / \`@pytest.mark.skip\`.
420
+ - Modify the test runner config (vitest.config, jest.config, etc.) to silence failures.
421
+
422
+ Lead each turn with a one-line status: "\u25B8 running \`npm test\` ..." \u2192 "\u25B8 2 failures in tests/foo.test.ts \u2014 first is \u2026" \u2192 so the user always knows where you are without scrolling tool output.`;
423
+ var BUILTIN_SKILLS = Object.freeze([
424
+ Object.freeze({
425
+ name: "explore",
426
+ description: "Explore the codebase in an isolated subagent \u2014 wide-net read-only investigation that returns one distilled answer. Best for: 'find all places that...', 'how does X work across the project', 'survey the code for Y'.",
427
+ body: BUILTIN_EXPLORE_BODY,
428
+ scope: "builtin",
429
+ path: "(builtin)",
430
+ runAs: "subagent"
431
+ }),
432
+ Object.freeze({
433
+ name: "research",
434
+ description: "Research a question by combining web search + code reading in an isolated subagent. Best for: 'is X feature supported by lib Y', 'what's the canonical way to do Z', 'compare our impl against the spec'.",
435
+ body: BUILTIN_RESEARCH_BODY,
436
+ scope: "builtin",
437
+ path: "(builtin)",
438
+ runAs: "subagent"
439
+ }),
440
+ Object.freeze({
441
+ name: "review",
442
+ description: "Review the pending changes (current branch diff by default) in an isolated subagent \u2014 flags correctness, security, missing tests, hidden behavior changes; reports verdict + per-issue file:line. Read-only; the parent decides what to act on.",
443
+ body: BUILTIN_REVIEW_BODY,
444
+ scope: "builtin",
445
+ path: "(builtin)",
446
+ runAs: "subagent"
447
+ }),
448
+ Object.freeze({
449
+ name: "security-review",
450
+ description: "Security-focused review of the current branch diff in an isolated subagent \u2014 flags injection/authz/secrets/deserialization/path-traversal/crypto issues, severity-tagged. Read-only. Use when shipping changes that touch auth, input parsing, file IO, or external requests.",
451
+ body: BUILTIN_SECURITY_REVIEW_BODY,
452
+ scope: "builtin",
453
+ path: "(builtin)",
454
+ runAs: "subagent"
455
+ }),
456
+ Object.freeze({
457
+ name: "test",
458
+ description: "Run the project's test suite, diagnose failures, propose SEARCH/REPLACE fixes, re-run until green (or stop after 2 fix attempts on the same failure). Inlined \u2014 runs in the parent loop so you see the edit blocks and can /apply them. Detects npm/pnpm/yarn/pytest/go/cargo.",
459
+ body: BUILTIN_TEST_BODY,
460
+ scope: "builtin",
461
+ path: "(builtin)",
462
+ runAs: "inline"
463
+ })
464
+ ]);
465
+
466
+ export {
467
+ PROJECT_MEMORY_FILE,
468
+ readProjectMemory,
469
+ memoryEnabled,
470
+ applyProjectMemory,
471
+ TUI_FORMATTING_RULES,
472
+ ESCALATION_CONTRACT,
473
+ NEGATIVE_CLAIM_RULE,
474
+ SKILLS_DIRNAME,
475
+ SKILL_FILE,
476
+ SkillStore,
477
+ applySkillsIndex
478
+ };
479
+ //# sourceMappingURL=chunk-U3V2ZQ5J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/prompt-fragments.ts","../../src/memory/project.ts","../../src/skills.ts"],"sourcesContent":["/** Shared prompt fragments — single source so house-style rules can't drift across agent/subagent/skill prompts. */\n\n/** Embedded literally — no interpolation, so prefix-cache hash stays stable across sessions. */\nexport const TUI_FORMATTING_RULES = `Formatting (rendered in a TUI with a real markdown renderer):\n- Tabular data → GitHub-Flavored Markdown tables with ASCII pipes (\\`| col | col |\\` header + \\`| --- | --- |\\` separator). Never use Unicode box-drawing characters (│ ─ ┼ ┌ ┐ └ ┘ ├ ┤) — 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 → fenced code blocks (\\`\\`\\`).\n- Do NOT draw decorative frames around content with \\`┌──┐ │ └──┘\\` 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 \\`→\\` or \\`↓\\` between steps. Don't try to draw boxes-and-arrows in ASCII; it never survives word-wrap.`;\n\nexport const ESCALATION_CONTRACT = `Cost-aware escalation (when you're running on deepseek-v4-flash):\n\nIf a task CLEARLY exceeds what flash can do well — 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 — 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>>>\\` — bare marker, no rationale.\n- \\`<<<NEEDS_PRO: <one-sentence reason>>>>\\` — preferred. The reason text appears in the user-visible warning (\"⇧ flash requested escalation — <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 — reading files, small edits, clear bug fixes, straightforward feature additions — 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\nexport const NEGATIVE_CLAIM_RULE = `Negative claims (\"X is missing\", \"Y isn't implemented\", \"there's no Z\") are the #1 hallucination shape. They feel safe to write because no citation seems possible — but that's exactly why you must NOT write them on instinct.\n\nIf you have a search tool (\\`search_content\\`, \\`grep\\`, web search), call it FIRST before asserting absence:\n- Returns matches → you were wrong; correct yourself and cite the matches.\n- Returns nothing → state the absence WITH the search query as evidence: \\`No callers of \\\\\\`foo()\\\\\\` found (search_content \"foo\").\\`\n\nIf you have no search tool, qualify hard: \"I haven't verified — this is a guess.\" Never assert absence with fake authority.`;\n","/** REASONIX.md pinned into ImmutablePrefix.system; edits invalidate the prefix-cache fingerprint. */\n\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nexport const PROJECT_MEMORY_FILE = \"REASONIX.md\";\nexport const PROJECT_MEMORY_MAX_CHARS = 8000;\n\nexport interface ProjectMemory {\n /** Absolute path the memory was read from. */\n path: string;\n /** Post-truncation content (may include a \"… (truncated N chars)\" marker). */\n content: string;\n /** Original byte length before truncation. */\n originalChars: number;\n /** True iff `originalChars > PROJECT_MEMORY_MAX_CHARS`. */\n truncated: boolean;\n}\n\n/** Empty / whitespace-only files return null so they don't perturb the cache prefix. */\nexport function readProjectMemory(rootDir: string): ProjectMemory | null {\n const path = join(rootDir, PROJECT_MEMORY_FILE);\n if (!existsSync(path)) return null;\n let raw: string;\n try {\n raw = readFileSync(path, \"utf8\");\n } catch {\n return null;\n }\n const trimmed = raw.trim();\n if (!trimmed) return null;\n const originalChars = trimmed.length;\n const truncated = originalChars > PROJECT_MEMORY_MAX_CHARS;\n const content = truncated\n ? `${trimmed.slice(0, PROJECT_MEMORY_MAX_CHARS)}\\n… (truncated ${\n originalChars - PROJECT_MEMORY_MAX_CHARS\n } chars)`\n : trimmed;\n return { path, content, originalChars, truncated };\n}\n\nexport function memoryEnabled(): boolean {\n const env = process.env.REASONIX_MEMORY;\n if (env === \"off\" || env === \"false\" || env === \"0\") return false;\n return true;\n}\n\n/** Deterministic — same memory file always yields the same prefix hash. */\nexport function applyProjectMemory(basePrompt: string, rootDir: string): string {\n if (!memoryEnabled()) return basePrompt;\n const mem = readProjectMemory(rootDir);\n if (!mem) return basePrompt;\n return `${basePrompt}\n\n# Project memory (REASONIX.md)\n\nThe user pinned these notes about this project — treat them as authoritative context for every turn:\n\n\\`\\`\\`\n${mem.content}\n\\`\\`\\`\n`;\n}\n","/** Project scope wins over global. Only names+descriptions enter the prefix; bodies load lazily into the append-only log. */\n\nimport { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { NEGATIVE_CLAIM_RULE, TUI_FORMATTING_RULES } from \"./prompt-fragments.js\";\n\nexport const SKILLS_DIRNAME = \"skills\";\nexport const SKILL_FILE = \"SKILL.md\";\n/** Cap on the pinned skills-index block, mirrors memory-index cap. */\nexport const SKILLS_INDEX_MAX_CHARS = 4000;\n/** Skill identifier shape — alnum + `_` + `-` + interior `.`, 1-64 chars. */\nconst VALID_SKILL_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/;\n\nexport type SkillScope = \"project\" | \"global\" | \"builtin\";\n\n/** inline = body enters parent log; subagent = isolated child loop, only final answer returns. */\nexport type SkillRunAs = \"inline\" | \"subagent\";\n\nexport interface Skill {\n /** Canonical name — sanitized, matches the directory / filename stem. */\n name: string;\n /** One-line description shown in the pinned index. */\n description: string;\n /** Full markdown body (post-frontmatter). Loaded on demand. */\n body: string;\n /** Which scope this skill was loaded from. */\n scope: SkillScope;\n /** Absolute path to the SKILL.md (or {name}.md) file, or \"(builtin)\" for shipped defaults. */\n path: string;\n /** Parsed `allowed-tools` frontmatter — when present, the spawned subagent's registry is scoped to these literal tool names. */\n allowedTools?: readonly string[];\n runAs: SkillRunAs;\n /** Subagent model override; only meaningful when `runAs === \"subagent\"`. */\n model?: string;\n}\n\nexport interface SkillStoreOptions {\n /** Override `$HOME` — tests point this at a tmpdir. */\n homeDir?: string;\n /** Required for project-scope skills; omit to read only the global scope. */\n projectRoot?: string;\n /** Suppress bundled built-ins — for tests asserting exact list contents. */\n disableBuiltins?: boolean;\n}\n\nfunction parseFrontmatter(raw: string): { data: Record<string, string>; body: string } {\n const lines = raw.split(/\\r?\\n/);\n if (lines[0] !== \"---\") return { data: {}, body: raw };\n const end = lines.indexOf(\"---\", 1);\n if (end < 0) return { data: {}, body: raw };\n const data: Record<string, string> = {};\n for (let i = 1; i < end; i++) {\n const line = lines[i];\n if (!line) continue;\n const m = line.match(/^([a-zA-Z_][a-zA-Z0-9_-]*):\\s*(.*)$/);\n if (m?.[1]) data[m[1]] = (m[2] ?? \"\").trim();\n }\n return {\n data,\n body: lines\n .slice(end + 1)\n .join(\"\\n\")\n .replace(/^\\n+/, \"\"),\n };\n}\n\nfunction isValidSkillName(name: string): boolean {\n return VALID_SKILL_NAME.test(name);\n}\n\nfunction parseAllowedTools(raw: string | undefined): readonly string[] | undefined {\n if (raw === undefined) return undefined;\n const names = raw\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean);\n return names.length > 0 ? Object.freeze(names) : undefined;\n}\n\nexport class SkillStore {\n private readonly homeDir: string;\n private readonly projectRoot: string | undefined;\n private readonly disableBuiltins: boolean;\n\n constructor(opts: SkillStoreOptions = {}) {\n this.homeDir = opts.homeDir ?? homedir();\n this.projectRoot = opts.projectRoot ? resolve(opts.projectRoot) : undefined;\n this.disableBuiltins = opts.disableBuiltins === true;\n }\n\n /** True iff this store was configured with a project root. */\n hasProjectScope(): boolean {\n return this.projectRoot !== undefined;\n }\n\n /** Project scope first so per-repo skill overrides a global with the same name. */\n roots(): Array<{ dir: string; scope: SkillScope }> {\n const out: Array<{ dir: string; scope: SkillScope }> = [];\n if (this.projectRoot) {\n out.push({\n dir: join(this.projectRoot, \".reasonix\", SKILLS_DIRNAME),\n scope: \"project\",\n });\n }\n out.push({ dir: join(this.homeDir, \".reasonix\", SKILLS_DIRNAME), scope: \"global\" });\n return out;\n }\n\n /** Higher-priority root wins on collision (project > global > builtin); sorted for stable prefix hash. */\n list(): Skill[] {\n const byName = new Map<string, Skill>();\n for (const { dir, scope } of this.roots()) {\n if (!existsSync(dir)) continue;\n let entries: import(\"node:fs\").Dirent[];\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n continue;\n }\n for (const entry of entries) {\n const skill = this.readEntry(dir, scope, entry);\n if (!skill) continue;\n if (!byName.has(skill.name)) byName.set(skill.name, skill);\n }\n }\n // Builtins last so user/project files override on name collision.\n if (!this.disableBuiltins) {\n for (const skill of BUILTIN_SKILLS) {\n if (!byName.has(skill.name)) byName.set(skill.name, skill);\n }\n }\n return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));\n }\n\n /** Scaffold a new skill stub at the chosen scope. Refuses to overwrite. */\n create(name: string, scope: \"project\" | \"global\"): { path: string } | { error: string } {\n if (!isValidSkillName(name)) {\n return { error: `invalid skill name: \"${name}\" — use letters, digits, _, -, .` };\n }\n if (scope === \"project\" && !this.projectRoot) {\n return { error: \"project scope requires a workspace — run from `reasonix code`\" };\n }\n const root =\n scope === \"project\"\n ? join(this.projectRoot ?? \"\", \".reasonix\", SKILLS_DIRNAME)\n : join(this.homeDir, \".reasonix\", SKILLS_DIRNAME);\n const flat = join(root, `${name}.md`);\n const folder = join(root, name, SKILL_FILE);\n if (existsSync(folder)) {\n return { error: `skill \"${name}\" already exists at ${folder}` };\n }\n mkdirSync(dirname(flat), { recursive: true });\n try {\n writeFileSync(flat, skillStubBody(name), { encoding: \"utf8\", flag: \"wx\" });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"EEXIST\") {\n return { error: `skill \"${name}\" already exists at ${flat}` };\n }\n throw err;\n }\n return { path: flat };\n }\n\n /** Resolve one skill by name. Returns `null` if not found or malformed. */\n read(name: string): Skill | null {\n if (!isValidSkillName(name)) return null;\n for (const { dir, scope } of this.roots()) {\n if (!existsSync(dir)) continue;\n const dirCandidate = join(dir, name, SKILL_FILE);\n if (existsSync(dirCandidate) && statSync(dirCandidate).isFile()) {\n return this.parse(dirCandidate, name, scope);\n }\n const flatCandidate = join(dir, `${name}.md`);\n if (existsSync(flatCandidate) && statSync(flatCandidate).isFile()) {\n return this.parse(flatCandidate, name, scope);\n }\n }\n if (!this.disableBuiltins) {\n for (const skill of BUILTIN_SKILLS) {\n if (skill.name === name) return skill;\n }\n }\n return null;\n }\n\n private readEntry(dir: string, scope: SkillScope, entry: import(\"node:fs\").Dirent): Skill | null {\n if (entry.isDirectory()) {\n if (!isValidSkillName(entry.name)) return null;\n const file = join(dir, entry.name, SKILL_FILE);\n if (!existsSync(file)) return null;\n return this.parse(file, entry.name, scope);\n }\n if (entry.isFile() && entry.name.endsWith(\".md\")) {\n const stem = entry.name.slice(0, -3);\n if (!isValidSkillName(stem)) return null;\n return this.parse(join(dir, entry.name), stem, scope);\n }\n return null;\n }\n\n private parse(path: string, stem: string, scope: SkillScope): Skill | null {\n let raw: string;\n try {\n raw = readFileSync(path, \"utf8\");\n } catch {\n return null;\n }\n const { data, body } = parseFrontmatter(raw);\n const name = data.name && isValidSkillName(data.name) ? data.name : stem;\n return {\n name,\n description: (data.description ?? \"\").trim(),\n body: body.trim(),\n scope,\n path,\n allowedTools: parseAllowedTools(data[\"allowed-tools\"]),\n runAs: parseRunAs(data.runAs),\n model: data.model?.startsWith(\"deepseek-\") ? data.model : undefined,\n };\n }\n}\n\n/** Unknown values default to the safe (non-spawning) `inline` mode. */\nfunction parseRunAs(raw: string | undefined): SkillRunAs {\n return raw?.trim() === \"subagent\" ? \"subagent\" : \"inline\";\n}\n\n/** Stub markdown for `/skill new` — minimal frontmatter + scaffolding the user fills in. */\nfunction skillStubBody(name: string): string {\n return `---\nname: ${name}\ndescription: One-liner — what does this skill do?\n---\n\n# ${name}\n\nReplace this body with the playbook the model should follow when this skill is invoked.\n\nTips:\n- Reference tools by name (run_command, edit_file, search_content, ...)\n- Add \\`runAs: subagent\\` to frontmatter to spawn an isolated subagent loop\n- Add \\`allowed-tools: read_file, search_content\\` to scope a subagent's tools\n`;\n}\n\n/** Subagent tag goes AFTER the name in brackets — leading-marker tags get copied into `name` arg verbatim. */\nfunction skillIndexLine(s: Pick<Skill, \"name\" | \"description\" | \"runAs\">): string {\n const safeDesc = s.description.replace(/\\n/g, \" \").trim();\n const tag = s.runAs === \"subagent\" ? \" [🧬 subagent]\" : \"\";\n const max = 130 - s.name.length - tag.length;\n const clipped = safeDesc.length > max ? `${safeDesc.slice(0, Math.max(1, max - 1))}…` : safeDesc;\n return clipped ? `- ${s.name}${tag} — ${clipped}` : `- ${s.name}${tag}`;\n}\n\n/** Bodies stay out — prefix must stay short + cacheable; bodies load on demand. */\nexport function applySkillsIndex(basePrompt: string, opts: SkillStoreOptions = {}): string {\n const store = new SkillStore(opts);\n const skills = store.list().filter((s) => s.description);\n if (skills.length === 0) return basePrompt;\n const lines = skills.map(skillIndexLine);\n const joined = lines.join(\"\\n\");\n const truncated =\n joined.length > SKILLS_INDEX_MAX_CHARS\n ? `${joined.slice(0, SKILLS_INDEX_MAX_CHARS)}\\n… (truncated ${\n joined.length - SKILLS_INDEX_MAX_CHARS\n } chars)`\n : joined;\n return [\n basePrompt,\n \"\",\n \"# Skills — playbooks you can invoke\",\n \"\",\n 'One-liner index. Each entry is either a built-in or a user-authored playbook. Call `run_skill({ name: \"<skill-name>\", arguments: \"<task>\" })` — the `name` is JUST the skill identifier (e.g. `\"explore\"`), NOT the `[🧬 subagent]` tag that appears after it. Entries tagged `[🧬 subagent]` spawn an **isolated subagent** — its tool calls and reasoning never enter your context, only its final answer does. Use subagent skills for tasks that would otherwise flood your context (deep exploration, multi-step research, anything where you only need the conclusion). Plain skills are inlined: their body becomes a tool result you read and act on directly. The user can also invoke a skill via `/skill <name>`.',\n \"\",\n \"```\",\n truncated,\n \"```\",\n ].join(\"\\n\");\n}\n\nconst BUILTIN_EXPLORE_BODY = `You are running as an exploration subagent. Your job is to investigate the codebase the parent agent pointed you at, then return one focused, distilled answer.\n\nHow to operate:\n- Use read_file, search_files, search_content, directory_tree, list_directory, get_file_info as your primary tools. Stay read-only.\n- For \"find all places that call / reference / use X\" questions, use \\`search_content\\` (content grep) — NOT \\`search_files\\` (which only matches file names). This is the most common subagent mistake; using the wrong tool gives empty results and you waste your iter budget chasing a phantom.\n- Cast a wide net first (search_content for symbol references, directory_tree for structure) to map the territory; then read the 3-10 most relevant files in full.\n- Don't read every file — be selective. Aim for breadth on the first pass, depth only where the question demands it.\n- Stop exploring as soon as you can answer the question. The parent doesn't see your tool calls, so over-exploration is pure waste.\n\nYour final answer:\n- One paragraph (or a few short bullets). Lead with the conclusion.\n- Cite specific file paths + line ranges when they support the answer.\n- If the question can't be answered from what you found, say so plainly and suggest where to look next.\n- No follow-up offers, no \"let me know if you need more.\" The parent will ask again if they need more.\n\n${NEGATIVE_CLAIM_RULE}\n\n${TUI_FORMATTING_RULES}\n\nThe 'task' the parent gave you is the question you must answer. Treat any other reading of it as scope creep.`;\n\nconst BUILTIN_RESEARCH_BODY = `You are running as a research subagent. Your job is to gather information from code AND the web, synthesize it, and return one focused conclusion.\n\nHow to operate:\n- Combine code reading (read_file, search_files) with web tools (web_search, web_fetch) as appropriate to the question.\n- For \"how does X work\" / \"is Y supported\" questions: web first to find the canonical reference, then verify against the local code.\n- For \"what's our policy on Z\" / \"where do we use Q\": local code first, web only if you need to compare against external standards.\n- Cap yourself at ~10 tool calls. If you can't converge in 10, return what you have plus a note about what's missing.\n\nYour final answer:\n- One paragraph (or short bullets). Lead with the conclusion.\n- Cite both code (file:line) AND web sources (URL) when they back the answer.\n- Distinguish \"I verified this in code\" from \"I read this on a docs page\" — the parent will trust the former more.\n- If the answer is uncertain, say so. Don't invent confidence.\n\n${NEGATIVE_CLAIM_RULE}\n\n${TUI_FORMATTING_RULES}\n\nThe 'task' the parent gave you is the research question. Stay on it.`;\n\nconst BUILTIN_REVIEW_BODY = `You are running as a code-review subagent. Your job is to inspect the changes the user is about to ship — usually the current git branch vs its upstream — and produce a focused review the parent can hand back to the user.\n\nHow to operate:\n- Default scope: the current branch's diff vs the default branch. If the user's task names a specific commit range or files, honor that instead.\n- Discover scope first: \\`run_command git status\\`, \\`git diff --stat\\`, \\`git log --oneline\\` to see what changed. Then \\`git diff\\` (or \\`git diff <base>...HEAD\\`) for the actual hunks.\n- Read the touched files (\\`read_file\\`) when the diff alone doesn't carry enough context — function signatures, surrounding invariants, callers.\n- For \"any callers depending on this?\" questions: \\`search_content\\` against the symbol BEFORE asserting impact.\n- Stay read-only. Never \\`run_command git commit\\`, never write files, never propose SEARCH/REPLACE blocks. The parent decides whether to act on your findings.\n- Cap yourself at ~12 tool calls. If the diff is too big to review in one pass, pick the riskiest 2-3 files and say so explicitly.\n\nWhat to look for, in priority order:\n1. **Correctness bugs** — off-by-one, null/undefined handling, race conditions, wrong sign / wrong operator, edge cases the code doesn't handle.\n2. **Security** — injection (SQL, shell, path traversal), secrets in code, missing authz checks, unsafe deserialization.\n3. **Behavior changes the diff hides** — renames that miss callers, removed branches that were load-bearing, error-handling that now swallows what used to surface.\n4. **Tests** — does the change have tests for the new behavior? Are existing tests still meaningful, or did the change make them tautological?\n5. **Style + consistency** — only flag deviations that matter (unsafe \\`any\\`, missing types in TypeScript, inconsistent error shape). Don't pile on cosmetic nits if the substance is clean.\n\nYour final answer:\n- Lead with a one-sentence verdict: \"ship as-is\" / \"minor nits, OK to ship after\" / \"blocking issues, do not ship\".\n- Then a short bulleted list of issues, each with: file:line citation + the problem in one sentence + what to change.\n- Group by severity if you have more than 4 items: **Blocking**, **Should-fix**, **Nits**.\n- If everything looks clean, say so plainly. Don't manufacture concerns.\n\n${NEGATIVE_CLAIM_RULE}\n\n${TUI_FORMATTING_RULES}\n\nThe 'task' the parent gave you describes WHAT to review (a branch, a file set, or \"the pending changes\"). Stay on it; don't redesign the feature.`;\n\nconst BUILTIN_SECURITY_REVIEW_BODY = `You are running as a security-review subagent. Your job is to inspect the changes the user is about to ship — usually the current git branch vs its upstream — through a security lens specifically, and report exploitable issues.\n\nHow to operate:\n- Default scope: the current branch's diff vs the default branch. If the user names a different range or a directory, honor that.\n- Discover scope first: \\`git status\\`, \\`git diff --stat\\`, \\`git diff <base>...HEAD\\`. Read touched files (\\`read_file\\`) when the diff alone doesn't carry security context — auth checks, input validation, the actual handler that calls into the changed function.\n- Use \\`search_content\\` to verify \"is this user-controlled input ever sanitized later?\" / \"are there other call sites that depend on this validation?\" before asserting impact.\n- Stay read-only. Never write, never run destructive commands, never propose SEARCH/REPLACE blocks. The parent decides what to act on.\n- Cap yourself at ~12 tool calls. If the diff is too big, focus on the riskiest 2-3 files and say so explicitly.\n\nThreat model — flag with severity:\n\n**CRITICAL** (do-not-ship):\n- SQL / NoSQL / shell / template injection — user input concatenated into a query, command, or template without parameterization.\n- Path traversal — user-controlled filenames touching the filesystem without canonicalization + sandbox check.\n- Authentication / authorization missing — endpoints / actions that should require a session check but don't.\n- Hardcoded secrets — API keys, passwords, signing tokens visible in the diff.\n- Deserialization of untrusted input — \\`pickle.loads\\`, \\`yaml.load\\` (non-safe), \\`eval\\`, \\`Function()\\`, \\`unserialize()\\`.\n- Cryptographic mistakes — homemade crypto, weak hashes (MD5/SHA-1) for passwords, missing IVs, ECB mode, predictable nonces.\n\n**HIGH**:\n- XSS — user input rendered into HTML without escaping (or wrong escaping context).\n- SSRF — fetching URLs from user input without an allowlist.\n- Race conditions in security-relevant code — TOCTOU on auth/file checks.\n- Open redirects — user-controlled URL passed to a redirect helper.\n- Insufficient logging on security events (login failure, permission denial) — only flag if the codebase clearly DOES log elsewhere.\n\n**MEDIUM**:\n- Verbose error messages leaking internal paths / stack traces / SQL.\n- Missing rate limiting on a credential / token endpoint.\n- Cross-origin / cookie-flag issues (missing \\`Secure\\` / \\`HttpOnly\\` / \\`SameSite\\`).\n\nThings to NOT pile on (out of scope here — the regular /review covers them):\n- Style, formatting, naming.\n- Performance, refactor opportunities, test coverage gaps that aren't security-relevant.\n- \"Should be a constant\" / \"extract this helper\" — irrelevant to ship-blocking.\n\nYour final answer:\n- Lead with a one-sentence verdict: \"no security issues found\", \"minor concerns\", or \"blocking issues\".\n- Then a list grouped by severity. Each item: file:line + 1-sentence threat + 1-sentence fix direction (no full SEARCH/REPLACE — the user / parent agent will write that).\n- If clean, say so plainly. Don't manufacture findings.\n\n${NEGATIVE_CLAIM_RULE}\n\n${TUI_FORMATTING_RULES}\n\nThe 'task' the parent gave you names what to review. Stay on it; don't redesign the feature.`;\n\nconst BUILTIN_TEST_BODY = `You are running as the parent agent — this skill is INLINED, not a subagent. The user invoked /test (or asked you to \"run the tests and fix failures\"). Your job: run the project's test suite, diagnose any failure, propose fixes as SEARCH/REPLACE edit blocks, then re-run. Repeat until green or you hit a wall you should escalate.\n\nHow to operate:\n\n1. **Detect the test command**.\n - Look for \\`package.json\\` → \\`scripts.test\\` first (most common: \\`npm test\\`, \\`pnpm test\\`, \\`yarn test\\`).\n - If no package.json or no test script: try \\`pytest\\`, \\`go test ./...\\`, \\`cargo test\\` based on what files exist (pyproject.toml/requirements.txt → pytest; go.mod → go test; Cargo.toml → cargo test).\n - If you can't tell, ASK the user for the command — don't guess. One question, one tool call to confirm.\n\n2. **Run it via run_command** (typical timeout 120s, bigger if the suite is large). Capture stdout + stderr.\n\n3. **Read the failures**. Pull out: which test names failed, the actual error/traceback, the file + line that threw. Don't just paraphrase — locate the exact assertion or stack frame.\n\n4. **Propose fixes**. For each distinct failure:\n - If the failure is in PRODUCTION code (test catches a real bug) → propose a SEARCH/REPLACE that fixes the production code.\n - If the failure is in TEST code (test is wrong, codebase is right) → propose a SEARCH/REPLACE that updates the test, AND say so explicitly: \"This is a test bug, not a production bug — updating the assertion.\"\n - If the failure is environmental (missing dep, wrong node version, missing fixture file) → say so and stop. Don't try to install packages or change config without checking with the user.\n\n5. **Apply + re-run**. After the user accepts the edit blocks, run the test command again. Iterate.\n\n6. **Stop conditions**:\n - All tests pass → report green, summarize what changed.\n - Same test still failing after 2 fix attempts on the same line → STOP. Tell the user \"I've tried twice, it's still failing — here's what I think is happening, want me to try a different angle?\". Don't loop indefinitely.\n - 3+ unrelated failures → fix one at a time, smallest first, so each pass narrows the surface.\n\nDon't:\n- Run \\`npm install\\` / \\`pip install\\` / \\`cargo update\\` without asking — those mutate lockfiles and have global effects.\n- Disable, skip, or delete failing tests to \"make it green\". If a test seems wrong, update its assertion with a one-sentence explanation, but never add \\`.skip\\` / \\`it.skip\\` / \\`@pytest.mark.skip\\`.\n- Modify the test runner config (vitest.config, jest.config, etc.) to silence failures.\n\nLead each turn with a one-line status: \"▸ running \\`npm test\\` ...\" → \"▸ 2 failures in tests/foo.test.ts — first is …\" → so the user always knows where you are without scrolling tool output.`;\n\nconst BUILTIN_SKILLS: readonly Skill[] = Object.freeze([\n Object.freeze<Skill>({\n name: \"explore\",\n description:\n \"Explore the codebase in an isolated subagent — wide-net read-only investigation that returns one distilled answer. Best for: 'find all places that...', 'how does X work across the project', 'survey the code for Y'.\",\n body: BUILTIN_EXPLORE_BODY,\n scope: \"builtin\",\n path: \"(builtin)\",\n runAs: \"subagent\",\n }),\n Object.freeze<Skill>({\n name: \"research\",\n description:\n \"Research a question by combining web search + code reading in an isolated subagent. Best for: 'is X feature supported by lib Y', 'what's the canonical way to do Z', 'compare our impl against the spec'.\",\n body: BUILTIN_RESEARCH_BODY,\n scope: \"builtin\",\n path: \"(builtin)\",\n runAs: \"subagent\",\n }),\n Object.freeze<Skill>({\n name: \"review\",\n description:\n \"Review the pending changes (current branch diff by default) in an isolated subagent — flags correctness, security, missing tests, hidden behavior changes; reports verdict + per-issue file:line. Read-only; the parent decides what to act on.\",\n body: BUILTIN_REVIEW_BODY,\n scope: \"builtin\",\n path: \"(builtin)\",\n runAs: \"subagent\",\n }),\n Object.freeze<Skill>({\n name: \"security-review\",\n description:\n \"Security-focused review of the current branch diff in an isolated subagent — flags injection/authz/secrets/deserialization/path-traversal/crypto issues, severity-tagged. Read-only. Use when shipping changes that touch auth, input parsing, file IO, or external requests.\",\n body: BUILTIN_SECURITY_REVIEW_BODY,\n scope: \"builtin\",\n path: \"(builtin)\",\n runAs: \"subagent\",\n }),\n Object.freeze<Skill>({\n name: \"test\",\n description:\n \"Run the project's test suite, diagnose failures, propose SEARCH/REPLACE fixes, re-run until green (or stop after 2 fix attempts on the same failure). Inlined — runs in the parent loop so you see the edit blocks and can /apply them. Detects npm/pnpm/yarn/pytest/go/cargo.\",\n body: BUILTIN_TEST_BODY,\n scope: \"builtin\",\n path: \"(builtin)\",\n runAs: \"inline\",\n }),\n]);\n"],"mappings":";;;AAGO,IAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAO7B,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAU5B,IAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AClBnC,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAEd,IAAM,sBAAsB;AAC5B,IAAM,2BAA2B;AAcjC,SAAS,kBAAkB,SAAuC;AACvE,QAAM,OAAO,KAAK,SAAS,mBAAmB;AAC9C,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACJ,MAAI;AACF,UAAM,aAAa,MAAM,MAAM;AAAA,EACjC,QAAQ;AACN,WAAO;AAAA,EACT;AACA,QAAM,UAAU,IAAI,KAAK;AACzB,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,gBAAgB,QAAQ;AAC9B,QAAM,YAAY,gBAAgB;AAClC,QA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