reasonix 0.34.1 → 0.35.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/dashboard/app.css +16 -14
- package/dashboard/dist/app.js +35 -15
- package/dashboard/dist/app.js.map +1 -1
- package/dist/cli/{chat-TD6GR3QK.js → chat-AB5D7I3V.js} +9 -9
- package/dist/cli/{chunk-EINEIIIW.js → chunk-GPHBJWCV.js} +278 -91
- package/dist/cli/chunk-GPHBJWCV.js.map +1 -0
- package/dist/cli/{chunk-F3ILWP2L.js → chunk-IDP65VCC.js} +2 -2
- package/dist/cli/{chunk-OERAGRJX.js → chunk-JJTOZPM3.js} +2 -2
- package/dist/cli/{chunk-U3V2ZQ5J.js → chunk-KJQIA4US.js} +6 -2
- package/dist/cli/chunk-KJQIA4US.js.map +1 -0
- package/dist/cli/{chunk-LNTORE5K.js → chunk-N2IC4XDL.js} +149 -35
- package/dist/cli/chunk-N2IC4XDL.js.map +1 -0
- package/dist/cli/{chunk-SA4UGZPG.js → chunk-RJ5GUVS2.js} +6 -1
- package/dist/cli/chunk-RJ5GUVS2.js.map +1 -0
- package/dist/cli/{chunk-Q36KBLSU.js → chunk-SN7YH6FC.js} +125 -1
- package/dist/cli/chunk-SN7YH6FC.js.map +1 -0
- package/dist/cli/{chunk-6TMHAK5D.js → chunk-ZU45XW3P.js} +2 -2
- package/dist/cli/code-XBEFHXVM.js +433 -0
- package/dist/cli/code-XBEFHXVM.js.map +1 -0
- package/dist/cli/{doctor-YASM64X6.js → doctor-A565GMWD.js} +4 -4
- package/dist/cli/index.js +15 -15
- package/dist/cli/{prompt-V47QKSAR.js → prompt-YEKXMNNV.js} +3 -3
- package/dist/cli/{replay-JEDLU7F2.js → replay-P2WC5N5X.js} +2 -2
- package/dist/cli/replay-P2WC5N5X.js.map +1 -0
- package/dist/cli/{run-NHD2RSTD.js → run-QBWJETS3.js} +6 -6
- package/dist/cli/{server-MC4A4WAJ.js → server-SMLVXIW4.js} +5 -5
- package/dist/cli/{sessions-ZHWJEW4L.js → sessions-55RIZVWG.js} +6 -6
- package/dist/cli/{setup-DK43MT47.js → setup-QXMONZ4P.js} +2 -2
- package/dist/cli/{version-O362UKPM.js → version-Q2HA3AAC.js} +6 -6
- package/dist/index.d.ts +5 -0
- package/dist/index.js +273 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/chunk-EINEIIIW.js.map +0 -1
- package/dist/cli/chunk-LNTORE5K.js.map +0 -1
- package/dist/cli/chunk-Q36KBLSU.js.map +0 -1
- package/dist/cli/chunk-SA4UGZPG.js.map +0 -1
- package/dist/cli/chunk-U3V2ZQ5J.js.map +0 -1
- package/dist/cli/code-TGUOQBRJ.js +0 -153
- package/dist/cli/code-TGUOQBRJ.js.map +0 -1
- package/dist/cli/replay-JEDLU7F2.js.map +0 -1
- /package/dist/cli/{chat-TD6GR3QK.js.map → chat-AB5D7I3V.js.map} +0 -0
- /package/dist/cli/{chunk-F3ILWP2L.js.map → chunk-IDP65VCC.js.map} +0 -0
- /package/dist/cli/{chunk-OERAGRJX.js.map → chunk-JJTOZPM3.js.map} +0 -0
- /package/dist/cli/{chunk-6TMHAK5D.js.map → chunk-ZU45XW3P.js.map} +0 -0
- /package/dist/cli/{doctor-YASM64X6.js.map → doctor-A565GMWD.js.map} +0 -0
- /package/dist/cli/{prompt-V47QKSAR.js.map → prompt-YEKXMNNV.js.map} +0 -0
- /package/dist/cli/{run-NHD2RSTD.js.map → run-QBWJETS3.js.map} +0 -0
- /package/dist/cli/{server-MC4A4WAJ.js.map → server-SMLVXIW4.js.map} +0 -0
- /package/dist/cli/{sessions-ZHWJEW4L.js.map → sessions-55RIZVWG.js.map} +0 -0
- /package/dist/cli/{setup-DK43MT47.js.map → setup-QXMONZ4P.js.map} +0 -0
- /package/dist/cli/{version-O362UKPM.js.map → version-Q2HA3AAC.js.map} +0 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
bootstrapSemanticSearchInCodeMode
|
|
4
|
+
} from "./chunk-SW3CCXEV.js";
|
|
5
|
+
import {
|
|
6
|
+
chatCommand
|
|
7
|
+
} from "./chunk-GPHBJWCV.js";
|
|
8
|
+
import "./chunk-BQNUJJN7.js";
|
|
9
|
+
import {
|
|
10
|
+
preflightStdioSpec
|
|
11
|
+
} from "./chunk-RFX7TYVV.js";
|
|
12
|
+
import "./chunk-MRLXEMZ7.js";
|
|
13
|
+
import {
|
|
14
|
+
markPhase
|
|
15
|
+
} from "./chunk-CPOV2O73.js";
|
|
16
|
+
import {
|
|
17
|
+
ToolRegistry,
|
|
18
|
+
registerChoiceTool,
|
|
19
|
+
registerFilesystemTools,
|
|
20
|
+
registerMemoryTools,
|
|
21
|
+
registerPlanTool,
|
|
22
|
+
registerTodoTool
|
|
23
|
+
} from "./chunk-N2IC4XDL.js";
|
|
24
|
+
import {
|
|
25
|
+
parseMcpSpec
|
|
26
|
+
} from "./chunk-I6YIAK6C.js";
|
|
27
|
+
import "./chunk-XJLZ4HKU.js";
|
|
28
|
+
import "./chunk-XHQIK7B6.js";
|
|
29
|
+
import "./chunk-ZU45XW3P.js";
|
|
30
|
+
import "./chunk-KZHMKOJH.js";
|
|
31
|
+
import "./chunk-2EBODRRO.js";
|
|
32
|
+
import "./chunk-MHDNZXJJ.js";
|
|
33
|
+
import "./chunk-IDP65VCC.js";
|
|
34
|
+
import "./chunk-DAEAAVDF.js";
|
|
35
|
+
import "./chunk-KMWKGPFZ.js";
|
|
36
|
+
import "./chunk-3Q3C4W66.js";
|
|
37
|
+
import "./chunk-4DCHFFEY.js";
|
|
38
|
+
import "./chunk-RJ5GUVS2.js";
|
|
39
|
+
import "./chunk-G3XNWSFN.js";
|
|
40
|
+
import "./chunk-SOZE7V7V.js";
|
|
41
|
+
import {
|
|
42
|
+
JobRegistry,
|
|
43
|
+
registerShellTools
|
|
44
|
+
} from "./chunk-SX6L4HZZ.js";
|
|
45
|
+
import {
|
|
46
|
+
SkillStore
|
|
47
|
+
} from "./chunk-KJQIA4US.js";
|
|
48
|
+
import {
|
|
49
|
+
MCP_CATALOG
|
|
50
|
+
} from "./chunk-FM57FNPJ.js";
|
|
51
|
+
import "./chunk-RXGEGA7K.js";
|
|
52
|
+
import "./chunk-JJTOZPM3.js";
|
|
53
|
+
import "./chunk-2AWTGJ2C.js";
|
|
54
|
+
import "./chunk-5X7LZJDE.js";
|
|
55
|
+
import {
|
|
56
|
+
sanitizeName
|
|
57
|
+
} from "./chunk-DFP4YSVM.js";
|
|
58
|
+
import "./chunk-SN7YH6FC.js";
|
|
59
|
+
import {
|
|
60
|
+
defaultConfigPath,
|
|
61
|
+
loadEditMode,
|
|
62
|
+
loadProjectShellAllowed,
|
|
63
|
+
readConfig,
|
|
64
|
+
writeConfig
|
|
65
|
+
} from "./chunk-5JXXEPDM.js";
|
|
66
|
+
import "./chunk-WUI3P4RA.js";
|
|
67
|
+
import "./chunk-ZTLZO42A.js";
|
|
68
|
+
import "./chunk-ORM6PK57.js";
|
|
69
|
+
|
|
70
|
+
// src/cli/commands/code.tsx
|
|
71
|
+
import { readFileSync } from "fs";
|
|
72
|
+
import { basename, resolve } from "path";
|
|
73
|
+
|
|
74
|
+
// src/tools/scaffold.ts
|
|
75
|
+
var VALID_SKILL_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/;
|
|
76
|
+
var VALID_SERVER_NAME = /^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/;
|
|
77
|
+
var VALID_TOOL_NAME = /^[a-zA-Z_][a-zA-Z0-9_-]*$/;
|
|
78
|
+
function registerScaffoldTools(registry, opts = {}) {
|
|
79
|
+
const configPath = opts.configPath ?? defaultConfigPath();
|
|
80
|
+
registry.register({
|
|
81
|
+
name: "create_skill",
|
|
82
|
+
description: 'Scaffold a new skill (`SKILL.md` in `.reasonix/skills/<name>.md`) the user can invoke later via `/skill <name>`. Use this when the user asks the agent to add a playbook, automate a recurring workflow, or capture a multi-step recipe as a named skill. The frontmatter is filled from the structured args here (description / allowed_tools / run_as / model) so the model never has to write raw YAML. Use `run_as: "subagent"` for read-and-synthesize playbooks where only the final answer should come back; default `"inline"` appends the body to the parent log so the user sees the steps. Refuses to overwrite an existing skill \u2014 pick a different name or ask the user to delete the old one.',
|
|
83
|
+
parameters: {
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: {
|
|
86
|
+
name: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description: "Skill identifier \u2014 letters/digits/`_`/`-`/`.`, 1\u201364 chars. Becomes the `name` frontmatter and the `<name>.md` filename."
|
|
89
|
+
},
|
|
90
|
+
description: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: 'One-line summary shown in the pinned skills index. Lead with the verb ("Run X and \u2026") so the parent agent can scan it.'
|
|
93
|
+
},
|
|
94
|
+
body: {
|
|
95
|
+
type: "string",
|
|
96
|
+
description: "Markdown body of the skill \u2014 the playbook the model follows when invoked. Plain prose + bullets; reference tools by name."
|
|
97
|
+
},
|
|
98
|
+
scope: {
|
|
99
|
+
type: "string",
|
|
100
|
+
enum: ["project", "global"],
|
|
101
|
+
description: "`project` = `.reasonix/skills/` under the workspace (default, requires `reasonix code`); `global` = `~/.reasonix/skills/` shared across all repos."
|
|
102
|
+
},
|
|
103
|
+
allowed_tools: {
|
|
104
|
+
type: "array",
|
|
105
|
+
items: { type: "string" },
|
|
106
|
+
description: "Optional whitelist of tool names the subagent registry is scoped to (only meaningful for `run_as: subagent`). Common values: `read_file`, `search_content`, `directory_tree`, `run_command`. Omit to give the subagent the full inherited toolset."
|
|
107
|
+
},
|
|
108
|
+
run_as: {
|
|
109
|
+
type: "string",
|
|
110
|
+
enum: ["inline", "subagent"],
|
|
111
|
+
description: "`inline` (default) appends the body to the parent log as a tool result. `subagent` spawns an isolated child loop and only the final answer comes back \u2014 use for read-and-synthesize playbooks (explore, research, review)."
|
|
112
|
+
},
|
|
113
|
+
model: {
|
|
114
|
+
type: "string",
|
|
115
|
+
enum: ["deepseek-v4-flash", "deepseek-v4-pro"],
|
|
116
|
+
description: "Subagent model override (only meaningful for `run_as: subagent`). Default is the same as `spawn_subagent` \u2014 `deepseek-v4-flash`. Set to `deepseek-v4-pro` only when the playbook empirically needs the stronger model."
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
required: ["name", "description", "body"]
|
|
120
|
+
},
|
|
121
|
+
fn: async (args) => {
|
|
122
|
+
const name = typeof args.name === "string" ? args.name.trim() : "";
|
|
123
|
+
if (!VALID_SKILL_NAME.test(name)) {
|
|
124
|
+
return JSON.stringify({
|
|
125
|
+
error: `invalid skill name: ${JSON.stringify(name)} \u2014 use letters, digits, _, -, .`
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const description = typeof args.description === "string" ? args.description.trim().replace(/\n+/g, " ") : "";
|
|
129
|
+
if (!description) {
|
|
130
|
+
return JSON.stringify({
|
|
131
|
+
error: "create_skill requires a non-empty 'description'"
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const body = typeof args.body === "string" ? args.body : "";
|
|
135
|
+
if (!body.trim()) {
|
|
136
|
+
return JSON.stringify({ error: "create_skill requires a non-empty 'body'" });
|
|
137
|
+
}
|
|
138
|
+
const scope = args.scope === "global" ? "global" : opts.projectRoot ? "project" : "global";
|
|
139
|
+
const runAs = args.run_as === "subagent" ? "subagent" : "inline";
|
|
140
|
+
const allowedTools = parseAllowedTools(args.allowed_tools);
|
|
141
|
+
if (allowedTools && "error" in allowedTools) {
|
|
142
|
+
return JSON.stringify({ error: allowedTools.error });
|
|
143
|
+
}
|
|
144
|
+
const model = typeof args.model === "string" && args.model.startsWith("deepseek-") ? args.model : void 0;
|
|
145
|
+
const content = serializeSkill({
|
|
146
|
+
name,
|
|
147
|
+
description,
|
|
148
|
+
runAs,
|
|
149
|
+
allowedTools: allowedTools ?? void 0,
|
|
150
|
+
model,
|
|
151
|
+
body
|
|
152
|
+
});
|
|
153
|
+
const store = new SkillStore({
|
|
154
|
+
homeDir: opts.homeDir,
|
|
155
|
+
projectRoot: opts.projectRoot
|
|
156
|
+
});
|
|
157
|
+
const result = store.createWithContent(name, scope, content);
|
|
158
|
+
if ("error" in result) {
|
|
159
|
+
return JSON.stringify({ error: result.error });
|
|
160
|
+
}
|
|
161
|
+
return JSON.stringify({
|
|
162
|
+
success: true,
|
|
163
|
+
path: result.path,
|
|
164
|
+
scope,
|
|
165
|
+
name,
|
|
166
|
+
run_as: runAs
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
registry.register({
|
|
171
|
+
name: "add_mcp_server",
|
|
172
|
+
description: 'Register a new MCP server in the user\'s Reasonix config (`mcp` array). Takes effect on the next session \u2014 does NOT spawn the server now. Use stdio for local commands (npx packages, local binaries), `sse` or `streamable-http` for remote endpoints. Pass `from_catalog: "<name>"` (e.g. `"filesystem"`, `"memory"`, `"github"`) to auto-fill `command` + `args` from the bundled catalog \u2014 the user still has to supply user-args (filesystem: a sandbox dir; github: GITHUB_PERSONAL_ACCESS_TOKEN in env). Refuses to add a server whose name collides with an existing entry.',
|
|
173
|
+
parameters: {
|
|
174
|
+
type: "object",
|
|
175
|
+
properties: {
|
|
176
|
+
name: {
|
|
177
|
+
type: "string",
|
|
178
|
+
description: "Server name \u2014 used as the namespace prefix on every tool the server exposes. Letters/digits/`_`/`-`, must start with a letter or `_`."
|
|
179
|
+
},
|
|
180
|
+
transport: {
|
|
181
|
+
type: "string",
|
|
182
|
+
enum: ["stdio", "sse", "streamable-http"],
|
|
183
|
+
description: "`stdio` = spawn a local command and pipe MCP over stdin/stdout. `sse` = HTTP+SSE remote. `streamable-http` = Streamable HTTP remote. Required unless `from_catalog` is set."
|
|
184
|
+
},
|
|
185
|
+
command: {
|
|
186
|
+
type: "string",
|
|
187
|
+
description: 'Argv[0] for stdio servers \u2014 typically `npx` or a binary path. Required when `transport: "stdio"` (and no `from_catalog`).'
|
|
188
|
+
},
|
|
189
|
+
args: {
|
|
190
|
+
type: "array",
|
|
191
|
+
items: { type: "string" },
|
|
192
|
+
description: 'Remaining argv for stdio servers \u2014 e.g. `["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]`. The dir at the tail is enforced to exist by the preflight check.'
|
|
193
|
+
},
|
|
194
|
+
url: {
|
|
195
|
+
type: "string",
|
|
196
|
+
description: "Endpoint URL for `sse` / `streamable-http` transports. Must be `http://` or `https://`."
|
|
197
|
+
},
|
|
198
|
+
from_catalog: {
|
|
199
|
+
type: "string",
|
|
200
|
+
description: "Optional shortcut \u2014 name out of the bundled catalog (`filesystem`, `memory`, `github`, `puppeteer`, `everything`). When set, fills `command` + `args` from the catalog entry; you still supply `name` (defaults to the catalog name) and any user-args via `args`."
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
required: ["name"]
|
|
204
|
+
},
|
|
205
|
+
fn: async (args) => {
|
|
206
|
+
const name = typeof args.name === "string" ? args.name.trim() : "";
|
|
207
|
+
if (!VALID_SERVER_NAME.test(name)) {
|
|
208
|
+
return JSON.stringify({
|
|
209
|
+
error: `invalid server name: ${JSON.stringify(name)} \u2014 must match [a-zA-Z_][a-zA-Z0-9_-]*`
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
const specStr = buildSpecString({
|
|
213
|
+
name,
|
|
214
|
+
transport: typeof args.transport === "string" ? args.transport : void 0,
|
|
215
|
+
command: typeof args.command === "string" ? args.command : void 0,
|
|
216
|
+
argv: Array.isArray(args.args) ? args.args.filter((a) => typeof a === "string") : void 0,
|
|
217
|
+
url: typeof args.url === "string" ? args.url : void 0,
|
|
218
|
+
fromCatalog: typeof args.from_catalog === "string" ? args.from_catalog : void 0
|
|
219
|
+
});
|
|
220
|
+
if ("error" in specStr) {
|
|
221
|
+
return JSON.stringify({ error: specStr.error });
|
|
222
|
+
}
|
|
223
|
+
let parsed;
|
|
224
|
+
try {
|
|
225
|
+
parsed = parseMcpSpec(specStr.spec);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
return JSON.stringify({ error: err.message });
|
|
228
|
+
}
|
|
229
|
+
if (parsed.transport === "stdio") {
|
|
230
|
+
try {
|
|
231
|
+
preflightStdioSpec(parsed);
|
|
232
|
+
} catch (err) {
|
|
233
|
+
return JSON.stringify({ error: err.message });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const cfg = readConfig(configPath);
|
|
237
|
+
const existing = cfg.mcp ?? [];
|
|
238
|
+
const collision = existing.find((s) => parseSpecName(s) === name);
|
|
239
|
+
if (collision) {
|
|
240
|
+
return JSON.stringify({
|
|
241
|
+
error: `MCP server ${JSON.stringify(name)} already registered: ${collision}`
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
cfg.mcp = [...existing, specStr.spec];
|
|
245
|
+
writeConfig(cfg, configPath);
|
|
246
|
+
return JSON.stringify({
|
|
247
|
+
success: true,
|
|
248
|
+
name,
|
|
249
|
+
transport: parsed.transport,
|
|
250
|
+
spec: specStr.spec,
|
|
251
|
+
config_path: configPath,
|
|
252
|
+
active_on_next_launch: true
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
return registry;
|
|
257
|
+
}
|
|
258
|
+
function serializeSkill(args) {
|
|
259
|
+
const lines = ["---", `name: ${args.name}`, `description: ${args.description}`];
|
|
260
|
+
if (args.runAs === "subagent") {
|
|
261
|
+
lines.push("runAs: subagent");
|
|
262
|
+
}
|
|
263
|
+
if (args.allowedTools && args.allowedTools.length > 0) {
|
|
264
|
+
lines.push(`allowed-tools: ${args.allowedTools.join(", ")}`);
|
|
265
|
+
}
|
|
266
|
+
if (args.model) {
|
|
267
|
+
lines.push(`model: ${args.model}`);
|
|
268
|
+
}
|
|
269
|
+
lines.push("---", "");
|
|
270
|
+
return `${lines.join("\n")}
|
|
271
|
+
${args.body.trim()}
|
|
272
|
+
`;
|
|
273
|
+
}
|
|
274
|
+
function parseAllowedTools(raw) {
|
|
275
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
276
|
+
if (!Array.isArray(raw)) {
|
|
277
|
+
return { error: "'allowed_tools' must be an array of tool-name strings" };
|
|
278
|
+
}
|
|
279
|
+
const out = [];
|
|
280
|
+
for (const v of raw) {
|
|
281
|
+
if (typeof v !== "string") {
|
|
282
|
+
return { error: "'allowed_tools' entries must be strings" };
|
|
283
|
+
}
|
|
284
|
+
const trimmed = v.trim();
|
|
285
|
+
if (!trimmed) continue;
|
|
286
|
+
if (!VALID_TOOL_NAME.test(trimmed)) {
|
|
287
|
+
return { error: `invalid tool name in allowed_tools: ${JSON.stringify(trimmed)}` };
|
|
288
|
+
}
|
|
289
|
+
out.push(trimmed);
|
|
290
|
+
}
|
|
291
|
+
return out.length > 0 ? out : void 0;
|
|
292
|
+
}
|
|
293
|
+
function buildSpecString(input) {
|
|
294
|
+
if (input.fromCatalog) {
|
|
295
|
+
const entry = MCP_CATALOG.find((e) => e.name === input.fromCatalog);
|
|
296
|
+
if (!entry) {
|
|
297
|
+
const known = MCP_CATALOG.map((e) => e.name).join(", ");
|
|
298
|
+
return {
|
|
299
|
+
error: `unknown catalog entry: ${JSON.stringify(input.fromCatalog)} \u2014 known: ${known}`
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
const userArgs = input.argv ?? [];
|
|
303
|
+
if (entry.userArgs && userArgs.length === 0) {
|
|
304
|
+
return {
|
|
305
|
+
error: `catalog entry "${entry.name}" needs ${entry.userArgs} \u2014 pass it via the 'args' parameter`
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
const tail = userArgs.map(quoteIfNeeded).join(" ");
|
|
309
|
+
const body = `npx -y ${entry.package}${tail ? ` ${tail}` : ""}`;
|
|
310
|
+
return { spec: `${input.name}=${body}` };
|
|
311
|
+
}
|
|
312
|
+
const transport = input.transport;
|
|
313
|
+
if (!transport) {
|
|
314
|
+
return { error: "add_mcp_server requires 'transport' (or 'from_catalog')" };
|
|
315
|
+
}
|
|
316
|
+
if (transport === "stdio") {
|
|
317
|
+
if (!input.command || !input.command.trim()) {
|
|
318
|
+
return { error: "stdio transport requires 'command'" };
|
|
319
|
+
}
|
|
320
|
+
const tail = (input.argv ?? []).map(quoteIfNeeded).join(" ");
|
|
321
|
+
const body = `${quoteIfNeeded(input.command.trim())}${tail ? ` ${tail}` : ""}`;
|
|
322
|
+
return { spec: `${input.name}=${body}` };
|
|
323
|
+
}
|
|
324
|
+
if (transport === "sse" || transport === "streamable-http") {
|
|
325
|
+
if (!input.url || !/^https?:\/\//i.test(input.url)) {
|
|
326
|
+
return { error: `${transport} transport requires an http(s):// 'url'` };
|
|
327
|
+
}
|
|
328
|
+
const prefix = transport === "streamable-http" ? "streamable+" : "";
|
|
329
|
+
return { spec: `${input.name}=${prefix}${input.url.trim()}` };
|
|
330
|
+
}
|
|
331
|
+
return { error: `unknown transport: ${JSON.stringify(transport)}` };
|
|
332
|
+
}
|
|
333
|
+
function parseSpecName(spec) {
|
|
334
|
+
const m = spec.trim().match(/^([a-zA-Z_][a-zA-Z0-9_-]*)=/);
|
|
335
|
+
return m ? m[1] ?? null : null;
|
|
336
|
+
}
|
|
337
|
+
function quoteIfNeeded(s) {
|
|
338
|
+
return /\s|"/.test(s) ? `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"` : s;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/cli/commands/code.tsx
|
|
342
|
+
async function codeCommand(opts = {}) {
|
|
343
|
+
markPhase("code_command_enter");
|
|
344
|
+
const { codeSystemPrompt } = await import("./prompt-YEKXMNNV.js");
|
|
345
|
+
const rootDir = resolve(opts.dir ?? process.cwd());
|
|
346
|
+
const session = opts.noSession ? void 0 : `code-${sanitizeName(basename(rootDir))}`;
|
|
347
|
+
const tools = new ToolRegistry();
|
|
348
|
+
const jobs = new JobRegistry();
|
|
349
|
+
const registerRootedTools = (root) => {
|
|
350
|
+
registerFilesystemTools(tools, { rootDir: root });
|
|
351
|
+
registerShellTools(tools, {
|
|
352
|
+
rootDir: root,
|
|
353
|
+
// Per-project "always allow" list persisted from prior ShellConfirm
|
|
354
|
+
// choices; merged on top of the built-in allowlist in shell.ts.
|
|
355
|
+
// GETTER form — re-read every dispatch so a prefix the user adds
|
|
356
|
+
// via ShellConfirm mid-session takes effect on the next shell call
|
|
357
|
+
// instead of waiting for `/new` or a relaunch.
|
|
358
|
+
extraAllowed: () => loadProjectShellAllowed(root),
|
|
359
|
+
// `yolo` edit-mode disables shell confirmations entirely. Re-read
|
|
360
|
+
// from config on each dispatch so /mode yolo (or Shift+Tab cycling
|
|
361
|
+
// through to it) flips the gate live without forcing a relaunch.
|
|
362
|
+
allowAll: () => loadEditMode() === "yolo",
|
|
363
|
+
jobs
|
|
364
|
+
});
|
|
365
|
+
registerMemoryTools(tools, { projectRoot: root });
|
|
366
|
+
};
|
|
367
|
+
const reBootstrapSemantic = async (root) => {
|
|
368
|
+
const result = await bootstrapSemanticSearchInCodeMode(tools, root);
|
|
369
|
+
if (!result.enabled) tools.unregister("semantic_search");
|
|
370
|
+
return result;
|
|
371
|
+
};
|
|
372
|
+
registerRootedTools(rootDir);
|
|
373
|
+
registerPlanTool(tools);
|
|
374
|
+
registerChoiceTool(tools);
|
|
375
|
+
registerTodoTool(tools);
|
|
376
|
+
registerScaffoldTools(tools, { projectRoot: rootDir });
|
|
377
|
+
markPhase("semantic_bootstrap_start");
|
|
378
|
+
const semantic = await reBootstrapSemantic(rootDir);
|
|
379
|
+
markPhase(
|
|
380
|
+
semantic.enabled ? "semantic_bootstrap_done_enabled" : "semantic_bootstrap_done_skipped"
|
|
381
|
+
);
|
|
382
|
+
process.stderr.write(
|
|
383
|
+
`\u25B8 reasonix code: rooted at ${rootDir}, session "${session ?? "(ephemeral)"}" \xB7 ${tools.size} native tool(s)${semantic.enabled ? " \xB7 semantic_search on" : ""}
|
|
384
|
+
`
|
|
385
|
+
);
|
|
386
|
+
process.once("exit", () => {
|
|
387
|
+
void jobs.shutdown();
|
|
388
|
+
});
|
|
389
|
+
let systemAppendFileContents;
|
|
390
|
+
if (opts.systemAppend !== void 0 && opts.systemAppend.trim().length === 0) {
|
|
391
|
+
process.stderr.write("--system-append is empty \u2014 no prompt text will be appended\n");
|
|
392
|
+
}
|
|
393
|
+
if (opts.systemAppendFile) {
|
|
394
|
+
const filePath = resolve(opts.systemAppendFile);
|
|
395
|
+
try {
|
|
396
|
+
systemAppendFileContents = readFileSync(filePath, "utf8");
|
|
397
|
+
} catch (err) {
|
|
398
|
+
const e = err;
|
|
399
|
+
process.stderr.write(
|
|
400
|
+
`Error: cannot read --system-append-file "${filePath}": ${e.code ? `[${e.code}] ` : ""}${e.message}
|
|
401
|
+
`
|
|
402
|
+
);
|
|
403
|
+
process.exit(1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
await chatCommand({
|
|
407
|
+
model: opts.model ?? "deepseek-v4-flash",
|
|
408
|
+
budgetUsd: opts.budgetUsd,
|
|
409
|
+
system: codeSystemPrompt(rootDir, {
|
|
410
|
+
hasSemanticSearch: semantic.enabled,
|
|
411
|
+
systemAppend: opts.systemAppend,
|
|
412
|
+
systemAppendFile: systemAppendFileContents
|
|
413
|
+
}),
|
|
414
|
+
transcript: opts.transcript,
|
|
415
|
+
session,
|
|
416
|
+
seedTools: tools,
|
|
417
|
+
codeMode: {
|
|
418
|
+
rootDir,
|
|
419
|
+
jobs,
|
|
420
|
+
reregisterTools: registerRootedTools,
|
|
421
|
+
reBootstrapSemantic
|
|
422
|
+
},
|
|
423
|
+
mcp: readConfig().mcp,
|
|
424
|
+
forceResume: opts.forceResume,
|
|
425
|
+
forceNew: opts.forceNew,
|
|
426
|
+
noDashboard: opts.noDashboard,
|
|
427
|
+
altScreen: opts.altScreen
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
export {
|
|
431
|
+
codeCommand
|
|
432
|
+
};
|
|
433
|
+
//# sourceMappingURL=code-XBEFHXVM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/commands/code.tsx","../../src/tools/scaffold.ts"],"sourcesContent":["/**\n * `reasonix code [dir]` — opinionated wrapper around `reasonix chat` for\n * code-editing workflows.\n *\n * What it does differently from plain chat:\n * - Registers native filesystem tools rooted at the given directory\n * (CWD by default). No subprocess, no `npx install` step, R1-\n * friendly schemas. Replaced the old `@modelcontextprotocol/server-filesystem`\n * subprocess in 0.4.9 because its `edit_file` argv shape was the\n * biggest driver of R1 DSML hallucinations.\n * - Uses a coding-focused system prompt (src/code/prompt.ts) that\n * teaches the model to propose edits as SEARCH/REPLACE blocks.\n * - Defaults to the `smart` preset (reasoner + harvest) because\n * coding tasks pay back R1 thinking.\n * - Scopes its session to the directory so projects don't share\n * conversation history.\n * - Hooks `codeMode` into the TUI so assistant replies get parsed\n * for SEARCH/REPLACE blocks and applied on disk after each turn.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { basename, resolve } from \"node:path\";\nimport { loadEditMode, loadProjectShellAllowed, readConfig } from \"../../config.js\";\nimport { bootstrapSemanticSearchInCodeMode } from \"../../index/semantic/tool.js\";\nimport { sanitizeName } from \"../../memory/session.js\";\nimport { ToolRegistry } from \"../../tools.js\";\nimport { registerChoiceTool } from \"../../tools/choice.js\";\nimport { registerFilesystemTools } from \"../../tools/filesystem.js\";\nimport { JobRegistry } from \"../../tools/jobs.js\";\nimport { registerMemoryTools } from \"../../tools/memory.js\";\nimport { registerPlanTool } from \"../../tools/plan.js\";\nimport { registerScaffoldTools } from \"../../tools/scaffold.js\";\nimport { registerShellTools } from \"../../tools/shell.js\";\nimport { registerTodoTool } from \"../../tools/todo.js\";\nimport { markPhase } from \"../startup-profile.js\";\nimport { chatCommand } from \"./chat.js\";\n\nexport interface CodeOptions {\n /** Directory to root the filesystem tools at. Defaults to process.cwd(). */\n dir?: string;\n /** Override the default `smart` model. */\n model?: string;\n /** Disable session persistence. */\n noSession?: boolean;\n /** Transcript file for replay/diff. */\n transcript?: string;\n /** Skip the session picker — always resume prior messages. */\n forceResume?: boolean;\n /** Skip the session picker — always wipe prior messages and start fresh. */\n forceNew?: boolean;\n /**\n * Soft USD spend cap. Off by default. Same semantics as `chat`:\n * warns at 80%, refuses next turn at 100%. Mid-session adjustable\n * via `/budget <usd>` slash command.\n */\n budgetUsd?: number;\n /** Suppress the auto-launched embedded web dashboard. */\n noDashboard?: boolean;\n /** Inline string appended to the code system prompt after the generated base prompt. */\n systemAppend?: string;\n /** Path to a UTF-8 text file whose contents are appended to the code system prompt. */\n systemAppendFile?: string;\n /** Default true. Pass false (CLI: `--no-alt-screen`) to keep chat output in shell scrollback. */\n altScreen?: boolean;\n}\n\nexport async function codeCommand(opts: CodeOptions = {}): Promise<void> {\n markPhase(\"code_command_enter\");\n const { codeSystemPrompt } = await import(\"../../code/prompt.js\");\n const rootDir = resolve(opts.dir ?? process.cwd());\n // Per-directory session so switching projects doesn't mix histories.\n // `code-<sanitized-basename>` fits the session name rules without\n // truncating most project names.\n const session = opts.noSession ? undefined : `code-${sanitizeName(basename(rootDir))}`;\n\n // Native filesystem tools. No subprocess, ~50-200 ms faster per call\n // than the MCP server was, and `edit_file` takes a flat SEARCH/REPLACE\n // shape instead of the `string=\"false\"` JSON-in-string array that\n // triggered R1's DSML hallucinations all through 0.4.x.\n const tools = new ToolRegistry();\n // Background-process registry shared between the shell tools and the\n // TUI's /jobs + /kill slashes + exit cleanup. One per `reasonix code`\n // run — orphan prevention on SIGINT / process exit kills everything\n // it owns, so dev servers don't outlive the Reasonix process.\n const jobs = new JobRegistry();\n // Bundled re-registration so `/cwd <path>` can swap every rootDir-\n // dependent tool atomically. ToolRegistry.register is keyed by name\n // and overwrites in-place, so re-calling these against the existing\n // registry replaces the closures cleanly without disturbing tool\n // specs (names/descriptions/params don't reference rootDir, so the\n // prefix cache survives).\n const registerRootedTools = (root: string): void => {\n registerFilesystemTools(tools, { rootDir: root });\n registerShellTools(tools, {\n rootDir: root,\n // Per-project \"always allow\" list persisted from prior ShellConfirm\n // choices; merged on top of the built-in allowlist in shell.ts.\n // GETTER form — re-read every dispatch so a prefix the user adds\n // via ShellConfirm mid-session takes effect on the next shell call\n // instead of waiting for `/new` or a relaunch.\n extraAllowed: () => loadProjectShellAllowed(root),\n // `yolo` edit-mode disables shell confirmations entirely. Re-read\n // from config on each dispatch so /mode yolo (or Shift+Tab cycling\n // through to it) flips the gate live without forcing a relaunch.\n allowAll: () => loadEditMode() === \"yolo\",\n jobs,\n });\n // `remember` / `forget` / `recall_memory` — cross-session user memory.\n // Project scope hashes off rootDir so switching projects gets a fresh\n // per-project memory store; the global scope is shared across runs.\n registerMemoryTools(tools, { projectRoot: root });\n };\n // Async tail to `registerRootedTools`. Kept separate because the FS /\n // shell / memory re-registration above is sync and must happen before\n // the next tool dispatch, while semantic-index probing reads disk and\n // can race ahead in the background. On `/cwd`, App.tsx fires this\n // after the sync swap and surfaces the result via postInfo.\n const reBootstrapSemantic = async (root: string): Promise<{ enabled: boolean }> => {\n const result = await bootstrapSemanticSearchInCodeMode(tools, root);\n if (!result.enabled) tools.unregister(\"semantic_search\");\n return result;\n };\n registerRootedTools(rootDir);\n // `submit_plan` is always in the spec list so the prefix cache stays\n // stable across plan-mode toggles (Pillar 1). The tool itself is a\n // no-op outside plan mode and throws `PlanProposedError` when the\n // user has `/plan`-enabled the session.\n registerPlanTool(tools);\n // `ask_choice` — branching primitive. Independent of plan mode: the\n // model uses it to put a 2–4 way choice in front of the user\n // (strategy, style, library pick) without trying to squeeze the\n // menu into a submit_plan body. Keeping it always-registered\n // preserves the prefix cache across plan-mode toggles.\n registerChoiceTool(tools);\n // `todo_write` — lightweight in-session task tracker, no approval gate.\n // Independent of plan mode (readOnly=true so it stays callable in /plan).\n registerTodoTool(tools);\n // `create_skill` / `add_mcp_server` — let the model scaffold from chat.\n // Both writes go through the same paths the wizard / `/skill new` use,\n // so the on-disk shape stays one source of truth. New servers take\n // effect on next launch (no live client churn).\n registerScaffoldTools(tools, { projectRoot: rootDir });\n // `run_skill` is intentionally NOT registered here — App.tsx wires it\n // up with the subagent runner attached, so `runAs: subagent` skills\n // can spawn isolated child loops. Doing it here would mean the App's\n // re-registration would shadow the no-runner version, which works\n // (last write wins) but obscures the wiring.\n\n // Bootstrap semantic_search. Silent: registers the tool when an\n // on-disk index already exists, skips entirely otherwise. Setup\n // happens via the explicit `reasonix index` command — never\n // by surprise on launch.\n markPhase(\"semantic_bootstrap_start\");\n const semantic = await reBootstrapSemantic(rootDir);\n markPhase(\n semantic.enabled ? \"semantic_bootstrap_done_enabled\" : \"semantic_bootstrap_done_skipped\",\n );\n\n process.stderr.write(\n `▸ reasonix code: rooted at ${rootDir}, session \"${session ?? \"(ephemeral)\"}\" · ${tools.size} native tool(s)${\n semantic.enabled ? \" · semantic_search on\" : \"\"\n }\\n`,\n );\n\n // Belt-and-suspenders cleanup: even though spawn(detached:false)\n // should tie child processes to the parent's lifetime, Windows cmd.exe\n // wrappers occasionally leak. We DON'T install SIGINT/SIGTERM\n // handlers here — that overrode Node's default \"exit on Ctrl+C\" with\n // a silent no-op, which made Ctrl+C feel broken in the TUI. App.tsx\n // owns the SIGINT path now (it shows the quit-armed banner and calls\n // exit() on confirmation); this 'exit' hook just guarantees the job\n // registry is drained on the way out, regardless of which exit path\n // fired.\n process.once(\"exit\", () => {\n void jobs.shutdown();\n });\n\n let systemAppendFileContents: string | undefined;\n if (opts.systemAppend !== undefined && opts.systemAppend.trim().length === 0) {\n process.stderr.write(\"--system-append is empty — no prompt text will be appended\\n\");\n }\n if (opts.systemAppendFile) {\n const filePath = resolve(opts.systemAppendFile);\n try {\n systemAppendFileContents = readFileSync(filePath, \"utf8\");\n } catch (err) {\n const e = err as NodeJS.ErrnoException;\n process.stderr.write(\n `Error: cannot read --system-append-file \"${filePath}\": ${e.code ? `[${e.code}] ` : \"\"}${e.message}\\n`,\n );\n process.exit(1);\n }\n }\n\n await chatCommand({\n model: opts.model ?? \"deepseek-v4-flash\",\n budgetUsd: opts.budgetUsd,\n system: codeSystemPrompt(rootDir, {\n hasSemanticSearch: semantic.enabled,\n systemAppend: opts.systemAppend,\n systemAppendFile: systemAppendFileContents,\n }),\n transcript: opts.transcript,\n session,\n seedTools: tools,\n codeMode: {\n rootDir,\n jobs,\n reregisterTools: registerRootedTools,\n reBootstrapSemantic,\n },\n mcp: readConfig().mcp,\n forceResume: opts.forceResume,\n forceNew: opts.forceNew,\n noDashboard: opts.noDashboard,\n altScreen: opts.altScreen,\n });\n}\n","/** Agent-facing tools for scaffolding skills + MCP servers from chat. Persists via the same paths the wizard / `/skill new` use. */\n\nimport { defaultConfigPath, readConfig, writeConfig } from \"../config.js\";\nimport { MCP_CATALOG } from \"../mcp/catalog.js\";\nimport { preflightStdioSpec } from \"../mcp/preflight.js\";\nimport { type McpSpec, parseMcpSpec } from \"../mcp/spec.js\";\nimport { SkillStore } from \"../skills.js\";\nimport type { ToolRegistry } from \"../tools.js\";\n\nexport interface ScaffoldToolsOptions {\n homeDir?: string;\n projectRoot?: string;\n /** Override config path — tests point this at a tmp file. */\n configPath?: string;\n}\n\nconst VALID_SKILL_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/;\nconst VALID_SERVER_NAME = /^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$/;\nconst VALID_TOOL_NAME = /^[a-zA-Z_][a-zA-Z0-9_-]*$/;\n\nexport function registerScaffoldTools(\n registry: ToolRegistry,\n opts: ScaffoldToolsOptions = {},\n): ToolRegistry {\n const configPath = opts.configPath ?? defaultConfigPath();\n\n registry.register({\n name: \"create_skill\",\n description:\n 'Scaffold a new skill (`SKILL.md` in `.reasonix/skills/<name>.md`) the user can invoke later via `/skill <name>`. Use this when the user asks the agent to add a playbook, automate a recurring workflow, or capture a multi-step recipe as a named skill. The frontmatter is filled from the structured args here (description / allowed_tools / run_as / model) so the model never has to write raw YAML. Use `run_as: \"subagent\"` for read-and-synthesize playbooks where only the final answer should come back; default `\"inline\"` appends the body to the parent log so the user sees the steps. Refuses to overwrite an existing skill — pick a different name or ask the user to delete the old one.',\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description:\n \"Skill identifier — letters/digits/`_`/`-`/`.`, 1–64 chars. Becomes the `name` frontmatter and the `<name>.md` filename.\",\n },\n description: {\n type: \"string\",\n description:\n 'One-line summary shown in the pinned skills index. Lead with the verb (\"Run X and …\") so the parent agent can scan it.',\n },\n body: {\n type: \"string\",\n description:\n \"Markdown body of the skill — the playbook the model follows when invoked. Plain prose + bullets; reference tools by name.\",\n },\n scope: {\n type: \"string\",\n enum: [\"project\", \"global\"],\n description:\n \"`project` = `.reasonix/skills/` under the workspace (default, requires `reasonix code`); `global` = `~/.reasonix/skills/` shared across all repos.\",\n },\n allowed_tools: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n \"Optional whitelist of tool names the subagent registry is scoped to (only meaningful for `run_as: subagent`). Common values: `read_file`, `search_content`, `directory_tree`, `run_command`. Omit to give the subagent the full inherited toolset.\",\n },\n run_as: {\n type: \"string\",\n enum: [\"inline\", \"subagent\"],\n description:\n \"`inline` (default) appends the body to the parent log as a tool result. `subagent` spawns an isolated child loop and only the final answer comes back — use for read-and-synthesize playbooks (explore, research, review).\",\n },\n model: {\n type: \"string\",\n enum: [\"deepseek-v4-flash\", \"deepseek-v4-pro\"],\n description:\n \"Subagent model override (only meaningful for `run_as: subagent`). Default is the same as `spawn_subagent` — `deepseek-v4-flash`. Set to `deepseek-v4-pro` only when the playbook empirically needs the stronger model.\",\n },\n },\n required: [\"name\", \"description\", \"body\"],\n },\n fn: async (args: {\n name?: unknown;\n description?: unknown;\n body?: unknown;\n scope?: unknown;\n allowed_tools?: unknown;\n run_as?: unknown;\n model?: unknown;\n }) => {\n const name = typeof args.name === \"string\" ? args.name.trim() : \"\";\n if (!VALID_SKILL_NAME.test(name)) {\n return JSON.stringify({\n error: `invalid skill name: ${JSON.stringify(name)} — use letters, digits, _, -, .`,\n });\n }\n const description =\n typeof args.description === \"string\" ? args.description.trim().replace(/\\n+/g, \" \") : \"\";\n if (!description) {\n return JSON.stringify({\n error: \"create_skill requires a non-empty 'description'\",\n });\n }\n const body = typeof args.body === \"string\" ? args.body : \"\";\n if (!body.trim()) {\n return JSON.stringify({ error: \"create_skill requires a non-empty 'body'\" });\n }\n const scope: \"project\" | \"global\" =\n args.scope === \"global\" ? \"global\" : opts.projectRoot ? \"project\" : \"global\";\n const runAs: \"inline\" | \"subagent\" = args.run_as === \"subagent\" ? \"subagent\" : \"inline\";\n const allowedTools = parseAllowedTools(args.allowed_tools);\n if (allowedTools && \"error\" in allowedTools) {\n return JSON.stringify({ error: allowedTools.error });\n }\n const model =\n typeof args.model === \"string\" && args.model.startsWith(\"deepseek-\")\n ? args.model\n : undefined;\n\n const content = serializeSkill({\n name,\n description,\n runAs,\n allowedTools: allowedTools ?? undefined,\n model,\n body,\n });\n\n const store = new SkillStore({\n homeDir: opts.homeDir,\n projectRoot: opts.projectRoot,\n });\n const result = store.createWithContent(name, scope, content);\n if (\"error\" in result) {\n return JSON.stringify({ error: result.error });\n }\n return JSON.stringify({\n success: true,\n path: result.path,\n scope,\n name,\n run_as: runAs,\n });\n },\n });\n\n registry.register({\n name: \"add_mcp_server\",\n description:\n 'Register a new MCP server in the user\\'s Reasonix config (`mcp` array). Takes effect on the next session — does NOT spawn the server now. Use stdio for local commands (npx packages, local binaries), `sse` or `streamable-http` for remote endpoints. Pass `from_catalog: \"<name>\"` (e.g. `\"filesystem\"`, `\"memory\"`, `\"github\"`) to auto-fill `command` + `args` from the bundled catalog — the user still has to supply user-args (filesystem: a sandbox dir; github: GITHUB_PERSONAL_ACCESS_TOKEN in env). Refuses to add a server whose name collides with an existing entry.',\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description:\n \"Server name — used as the namespace prefix on every tool the server exposes. Letters/digits/`_`/`-`, must start with a letter or `_`.\",\n },\n transport: {\n type: \"string\",\n enum: [\"stdio\", \"sse\", \"streamable-http\"],\n description:\n \"`stdio` = spawn a local command and pipe MCP over stdin/stdout. `sse` = HTTP+SSE remote. `streamable-http` = Streamable HTTP remote. Required unless `from_catalog` is set.\",\n },\n command: {\n type: \"string\",\n description:\n 'Argv[0] for stdio servers — typically `npx` or a binary path. Required when `transport: \"stdio\"` (and no `from_catalog`).',\n },\n args: {\n type: \"array\",\n items: { type: \"string\" },\n description:\n 'Remaining argv for stdio servers — e.g. `[\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/path/to/dir\"]`. The dir at the tail is enforced to exist by the preflight check.',\n },\n url: {\n type: \"string\",\n description:\n \"Endpoint URL for `sse` / `streamable-http` transports. Must be `http://` or `https://`.\",\n },\n from_catalog: {\n type: \"string\",\n description:\n \"Optional shortcut — name out of the bundled catalog (`filesystem`, `memory`, `github`, `puppeteer`, `everything`). When set, fills `command` + `args` from the catalog entry; you still supply `name` (defaults to the catalog name) and any user-args via `args`.\",\n },\n },\n required: [\"name\"],\n },\n fn: async (args: {\n name?: unknown;\n transport?: unknown;\n command?: unknown;\n args?: unknown;\n url?: unknown;\n from_catalog?: unknown;\n }) => {\n const name = typeof args.name === \"string\" ? args.name.trim() : \"\";\n if (!VALID_SERVER_NAME.test(name)) {\n return JSON.stringify({\n error: `invalid server name: ${JSON.stringify(name)} — must match [a-zA-Z_][a-zA-Z0-9_-]*`,\n });\n }\n\n const specStr = buildSpecString({\n name,\n transport: typeof args.transport === \"string\" ? args.transport : undefined,\n command: typeof args.command === \"string\" ? args.command : undefined,\n argv: Array.isArray(args.args)\n ? (args.args.filter((a) => typeof a === \"string\") as string[])\n : undefined,\n url: typeof args.url === \"string\" ? args.url : undefined,\n fromCatalog: typeof args.from_catalog === \"string\" ? args.from_catalog : undefined,\n });\n if (\"error\" in specStr) {\n return JSON.stringify({ error: specStr.error });\n }\n\n let parsed: McpSpec;\n try {\n parsed = parseMcpSpec(specStr.spec);\n } catch (err) {\n return JSON.stringify({ error: (err as Error).message });\n }\n if (parsed.transport === \"stdio\") {\n try {\n preflightStdioSpec(parsed);\n } catch (err) {\n return JSON.stringify({ error: (err as Error).message });\n }\n }\n\n const cfg = readConfig(configPath);\n const existing = cfg.mcp ?? [];\n const collision = existing.find((s) => parseSpecName(s) === name);\n if (collision) {\n return JSON.stringify({\n error: `MCP server ${JSON.stringify(name)} already registered: ${collision}`,\n });\n }\n cfg.mcp = [...existing, specStr.spec];\n writeConfig(cfg, configPath);\n return JSON.stringify({\n success: true,\n name,\n transport: parsed.transport,\n spec: specStr.spec,\n config_path: configPath,\n active_on_next_launch: true,\n });\n },\n });\n\n return registry;\n}\n\ninterface SerializeSkillArgs {\n name: string;\n description: string;\n runAs: \"inline\" | \"subagent\";\n allowedTools?: readonly string[];\n model?: string;\n body: string;\n}\n\nexport function serializeSkill(args: SerializeSkillArgs): string {\n const lines: string[] = [\"---\", `name: ${args.name}`, `description: ${args.description}`];\n if (args.runAs === \"subagent\") {\n lines.push(\"runAs: subagent\");\n }\n if (args.allowedTools && args.allowedTools.length > 0) {\n lines.push(`allowed-tools: ${args.allowedTools.join(\", \")}`);\n }\n if (args.model) {\n lines.push(`model: ${args.model}`);\n }\n lines.push(\"---\", \"\");\n return `${lines.join(\"\\n\")}\\n${args.body.trim()}\\n`;\n}\n\nfunction parseAllowedTools(raw: unknown): readonly string[] | { error: string } | undefined {\n if (raw === undefined || raw === null) return undefined;\n if (!Array.isArray(raw)) {\n return { error: \"'allowed_tools' must be an array of tool-name strings\" };\n }\n const out: string[] = [];\n for (const v of raw) {\n if (typeof v !== \"string\") {\n return { error: \"'allowed_tools' entries must be strings\" };\n }\n const trimmed = v.trim();\n if (!trimmed) continue;\n if (!VALID_TOOL_NAME.test(trimmed)) {\n return { error: `invalid tool name in allowed_tools: ${JSON.stringify(trimmed)}` };\n }\n out.push(trimmed);\n }\n return out.length > 0 ? out : undefined;\n}\n\ninterface BuildSpecInput {\n name: string;\n transport?: string;\n command?: string;\n argv?: string[];\n url?: string;\n fromCatalog?: string;\n}\n\nfunction buildSpecString(input: BuildSpecInput): { spec: string } | { error: string } {\n if (input.fromCatalog) {\n const entry = MCP_CATALOG.find((e) => e.name === input.fromCatalog);\n if (!entry) {\n const known = MCP_CATALOG.map((e) => e.name).join(\", \");\n return {\n error: `unknown catalog entry: ${JSON.stringify(input.fromCatalog)} — known: ${known}`,\n };\n }\n const userArgs = input.argv ?? [];\n if (entry.userArgs && userArgs.length === 0) {\n return {\n error: `catalog entry \"${entry.name}\" needs ${entry.userArgs} — pass it via the 'args' parameter`,\n };\n }\n const tail = userArgs.map(quoteIfNeeded).join(\" \");\n const body = `npx -y ${entry.package}${tail ? ` ${tail}` : \"\"}`;\n return { spec: `${input.name}=${body}` };\n }\n\n const transport = input.transport;\n if (!transport) {\n return { error: \"add_mcp_server requires 'transport' (or 'from_catalog')\" };\n }\n if (transport === \"stdio\") {\n if (!input.command || !input.command.trim()) {\n return { error: \"stdio transport requires 'command'\" };\n }\n const tail = (input.argv ?? []).map(quoteIfNeeded).join(\" \");\n const body = `${quoteIfNeeded(input.command.trim())}${tail ? ` ${tail}` : \"\"}`;\n return { spec: `${input.name}=${body}` };\n }\n if (transport === \"sse\" || transport === \"streamable-http\") {\n if (!input.url || !/^https?:\\/\\//i.test(input.url)) {\n return { error: `${transport} transport requires an http(s):// 'url'` };\n }\n const prefix = transport === \"streamable-http\" ? \"streamable+\" : \"\";\n return { spec: `${input.name}=${prefix}${input.url.trim()}` };\n }\n return { error: `unknown transport: ${JSON.stringify(transport)}` };\n}\n\nfunction parseSpecName(spec: string): string | null {\n const m = spec.trim().match(/^([a-zA-Z_][a-zA-Z0-9_-]*)=/);\n return m ? (m[1] ?? null) : null;\n}\n\nfunction quoteIfNeeded(s: string): string {\n return /\\s|\"/.test(s) ? `\"${s.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"')}\"` : s;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,oBAAoB;AAC7B,SAAS,UAAU,eAAe;;;ACLlC,IAAM,mBAAmB;AACzB,IAAM,oBAA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AO,MAAM,mEAA8D;AAAA,EACrF;AACA,MAAI,KAAK,kBAAkB;AACzB,UAAM,WAAW,QAAQ,KAAK,gBAAgB;AAC9C,QAAI;AACF,iCAA2B,aAAa,UAAU,MAAM;AAAA,IAC1D,SAAS,KAAK;AACZ,YAAM,IAAI;AACV,cAAQ,OAAO;AAAA,QACb,4CAA4C,QAAQ,MAAM,EAAE,OAAO,IAAI,EAAE,IAAI,OAAO,EAAE,GAAG,EAAE,OAAO;AAAA;AAAA,MACpG;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB,OAAO,KAAK,SAAS;AAAA,IACrB,WAAW,KAAK;AAAA,IAChB,QAAQ,iBAAiB,SAAS;AAAA,MAChC,mBAAmB,SAAS;AAAA,MAC5B,cAAc,KAAK;AAAA,MACnB,kBAAkB;AAAA,IACpB,CAAC;AAAA,IACD,YAAY,KAAK;AAAA,IACjB;AAAA,IACA,WAAW;AAAA,IACX,UAAU;AAAA,MACR;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,IACF;AAAA,IACA,KAAK,WAAW,EAAE;AAAA,IAClB,aAAa,KAAK;AAAA,IAClB,UAAU,KAAK;AAAA,IACf,aAAa,KAAK;AAAA,IAClB,WAAW,KAAK;AAAA,EAClB,CAAC;AACH;","names":[]}
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
import {
|
|
3
3
|
doctorCommand,
|
|
4
4
|
runDoctorChecks
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-IDP65VCC.js";
|
|
6
6
|
import "./chunk-DAEAAVDF.js";
|
|
7
7
|
import "./chunk-KMWKGPFZ.js";
|
|
8
8
|
import "./chunk-3Q3C4W66.js";
|
|
9
9
|
import "./chunk-RXGEGA7K.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-JJTOZPM3.js";
|
|
11
11
|
import "./chunk-2AWTGJ2C.js";
|
|
12
12
|
import "./chunk-5X7LZJDE.js";
|
|
13
13
|
import "./chunk-DFP4YSVM.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-SN7YH6FC.js";
|
|
15
15
|
import "./chunk-5JXXEPDM.js";
|
|
16
16
|
import "./chunk-WUI3P4RA.js";
|
|
17
17
|
export {
|
|
18
18
|
doctorCommand,
|
|
19
19
|
runDoctorChecks
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=doctor-
|
|
21
|
+
//# sourceMappingURL=doctor-A565GMWD.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
markPhase
|
|
4
4
|
} from "./chunk-CPOV2O73.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-N2IC4XDL.js";
|
|
6
6
|
import "./chunk-I6YIAK6C.js";
|
|
7
7
|
import "./chunk-XJLZ4HKU.js";
|
|
8
8
|
import "./chunk-XHQIK7B6.js";
|
|
9
9
|
import {
|
|
10
10
|
applyMemoryStack
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ZU45XW3P.js";
|
|
12
12
|
import {
|
|
13
13
|
resolvePreset
|
|
14
14
|
} from "./chunk-MHDNZXJJ.js";
|
|
@@ -18,8 +18,8 @@ import "./chunk-3Q3C4W66.js";
|
|
|
18
18
|
import "./chunk-SX6L4HZZ.js";
|
|
19
19
|
import {
|
|
20
20
|
ESCALATION_CONTRACT
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-KJQIA4US.js";
|
|
22
|
+
import "./chunk-JJTOZPM3.js";
|
|
23
23
|
import {
|
|
24
24
|
VERSION
|
|
25
25
|
} from "./chunk-2AWTGJ2C.js";
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from "./chunk-DFP4YSVM.js";
|
|
30
30
|
import {
|
|
31
31
|
t
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-SN7YH6FC.js";
|
|
33
33
|
import {
|
|
34
34
|
readConfig
|
|
35
35
|
} from "./chunk-5JXXEPDM.js";
|
|
@@ -118,7 +118,7 @@ program.name("reasonix").description(t("cli.description")).version(VERSION).opti
|
|
|
118
118
|
program.action(async (opts) => {
|
|
119
119
|
const cfg = readConfig();
|
|
120
120
|
if (!cfg.setupCompleted) {
|
|
121
|
-
const { setupCommand } = await import("./setup-
|
|
121
|
+
const { setupCommand } = await import("./setup-QXMONZ4P.js");
|
|
122
122
|
await setupCommand({});
|
|
123
123
|
return;
|
|
124
124
|
}
|
|
@@ -130,7 +130,7 @@ program.action(async (opts) => {
|
|
|
130
130
|
(msg) => process.stderr.write(`${msg}
|
|
131
131
|
`)
|
|
132
132
|
);
|
|
133
|
-
const { chatCommand } = await import("./chat-
|
|
133
|
+
const { chatCommand } = await import("./chat-AB5D7I3V.js");
|
|
134
134
|
await chatCommand({
|
|
135
135
|
model: defaults.model,
|
|
136
136
|
system: applyMemoryStack(DEFAULT_SYSTEM, process.cwd()),
|
|
@@ -140,11 +140,11 @@ program.action(async (opts) => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
program.command("setup").description(t("cli.setup")).action(async () => {
|
|
143
|
-
const { setupCommand } = await import("./setup-
|
|
143
|
+
const { setupCommand } = await import("./setup-QXMONZ4P.js");
|
|
144
144
|
await setupCommand({});
|
|
145
145
|
});
|
|
146
146
|
program.command("code [dir]").description(t("cli.code")).option("-m, --model <id>", t("ui.modelOverride")).option("--no-session", t("ui.noSession")).option("-r, --resume", t("ui.resumeHint")).option("-n, --new", t("ui.newHint")).option("--transcript <path>", t("ui.transcriptHint")).option("--budget <usd>", t("ui.budgetHint"), (v) => Number.parseFloat(v)).option("--no-dashboard", t("ui.noDashboard")).option("--no-alt-screen", "keep chat output in shell scrollback (legacy mode, ghost-prone)").option("--system-append <prompt>", t("ui.systemAppendHint")).option("--system-append-file <path>", t("ui.systemAppendFileHint")).action(async (dir, opts) => {
|
|
147
|
-
const { codeCommand } = await import("./code-
|
|
147
|
+
const { codeCommand } = await import("./code-XBEFHXVM.js");
|
|
148
148
|
await codeCommand({
|
|
149
149
|
dir,
|
|
150
150
|
model: opts.model,
|
|
@@ -179,7 +179,7 @@ program.command("chat").description(t("cli.chat")).option("-m, --model <id>", t(
|
|
|
179
179
|
(msg) => process.stderr.write(`${msg}
|
|
180
180
|
`)
|
|
181
181
|
);
|
|
182
|
-
const { chatCommand } = await import("./chat-
|
|
182
|
+
const { chatCommand } = await import("./chat-AB5D7I3V.js");
|
|
183
183
|
await chatCommand({
|
|
184
184
|
model: defaults.model,
|
|
185
185
|
system: applyMemoryStack(opts.system, process.cwd()),
|
|
@@ -206,7 +206,7 @@ program.command("run <task>").description(t("cli.run")).option("-m, --model <id>
|
|
|
206
206
|
preset: opts.preset,
|
|
207
207
|
noConfig: opts.config === false
|
|
208
208
|
});
|
|
209
|
-
const { runCommand } = await import("./run-
|
|
209
|
+
const { runCommand } = await import("./run-QBWJETS3.js");
|
|
210
210
|
await runCommand({
|
|
211
211
|
task,
|
|
212
212
|
model: defaults.model,
|
|
@@ -222,7 +222,7 @@ program.command("stats [transcript]").description(t("cli.stats")).action(async (
|
|
|
222
222
|
statsCommand({ transcript });
|
|
223
223
|
});
|
|
224
224
|
program.command("doctor").description(t("cli.doctor")).action(async () => {
|
|
225
|
-
const { doctorCommand } = await import("./doctor-
|
|
225
|
+
const { doctorCommand } = await import("./doctor-A565GMWD.js");
|
|
226
226
|
await doctorCommand();
|
|
227
227
|
});
|
|
228
228
|
program.command("commit").description(t("cli.commit")).option("-m, --model <id>", t("ui.modelOverrideFlash")).option("-y, --yes", t("ui.skipConfirmHint")).action(async (opts) => {
|
|
@@ -230,7 +230,7 @@ program.command("commit").description(t("cli.commit")).option("-m, --model <id>"
|
|
|
230
230
|
await commitCommand({ model: opts.model, yes: !!opts.yes });
|
|
231
231
|
});
|
|
232
232
|
program.command("sessions [name]").description(t("cli.sessions")).option("-v, --verbose", t("ui.verboseHint")).action(async (name, opts) => {
|
|
233
|
-
const { sessionsCommand } = await import("./sessions-
|
|
233
|
+
const { sessionsCommand } = await import("./sessions-55RIZVWG.js");
|
|
234
234
|
sessionsCommand({ name, verbose: !!opts.verbose });
|
|
235
235
|
});
|
|
236
236
|
program.command("prune-sessions").description(t("cli.pruneSessions")).option("--days <n>", t("ui.pruneDaysHint"), (v) => Number.parseInt(v, 10)).option("--dry-run", t("ui.pruneDryRunHint")).action(async (opts) => {
|
|
@@ -249,7 +249,7 @@ program.command("events <name>").description(t("cli.events")).option("--type <ty
|
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
251
|
program.command("replay <transcript>").description(t("cli.replay")).option("--print", t("ui.printHint")).option("--head <n>", t("ui.headHint"), (v) => Number.parseInt(v, 10)).option("--tail <n>", t("ui.tailHint"), (v) => Number.parseInt(v, 10)).action(async (transcript, opts) => {
|
|
252
|
-
const { replayCommand } = await import("./replay-
|
|
252
|
+
const { replayCommand } = await import("./replay-P2WC5N5X.js");
|
|
253
253
|
await replayCommand({
|
|
254
254
|
path: transcript,
|
|
255
255
|
print: !!opts.print,
|
|
@@ -336,7 +336,7 @@ mcp.command("inspect <spec>").description(t("ui.mcpInspectDescription")).option(
|
|
|
336
336
|
}
|
|
337
337
|
});
|
|
338
338
|
program.command("version").description(t("cli.version")).action(async () => {
|
|
339
|
-
const { versionCommand } = await import("./version-
|
|
339
|
+
const { versionCommand } = await import("./version-Q2HA3AAC.js");
|
|
340
340
|
versionCommand();
|
|
341
341
|
});
|
|
342
342
|
program.command("update").description(t("cli.update")).option("--dry-run", t("ui.dryRunHint")).action(async (opts) => {
|