@anyi61/codex-claude-delegate-mcp 0.1.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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +262 -0
  3. package/dist/claude-cli.d.ts +84 -0
  4. package/dist/claude-cli.js +3123 -0
  5. package/dist/claude-cli.js.map +1 -0
  6. package/dist/cli.d.ts +61 -0
  7. package/dist/cli.js +334 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/codex-config.d.ts +104 -0
  10. package/dist/codex-config.js +446 -0
  11. package/dist/codex-config.js.map +1 -0
  12. package/dist/guard.d.ts +27 -0
  13. package/dist/guard.js +229 -0
  14. package/dist/guard.js.map +1 -0
  15. package/dist/job-runner.d.ts +13 -0
  16. package/dist/job-runner.js +75 -0
  17. package/dist/job-runner.js.map +1 -0
  18. package/dist/jobs.d.ts +46 -0
  19. package/dist/jobs.js +175 -0
  20. package/dist/jobs.js.map +1 -0
  21. package/dist/package-info.d.ts +4 -0
  22. package/dist/package-info.js +14 -0
  23. package/dist/package-info.js.map +1 -0
  24. package/dist/schema.d.ts +779 -0
  25. package/dist/schema.js +325 -0
  26. package/dist/schema.js.map +1 -0
  27. package/dist/server.d.ts +1142 -0
  28. package/dist/server.js +693 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/session.d.ts +35 -0
  31. package/dist/session.js +109 -0
  32. package/dist/session.js.map +1 -0
  33. package/package.json +49 -0
  34. package/plugins/codex-claude-delegate/.codex-plugin/plugin.json +36 -0
  35. package/plugins/codex-claude-delegate/.mcp.json +9 -0
  36. package/plugins/codex-claude-delegate/hooks/hooks.json +16 -0
  37. package/plugins/codex-claude-delegate/hooks/review-gate-stop.mjs +66 -0
  38. package/plugins/codex-claude-delegate/server/job-runner.js +16999 -0
  39. package/plugins/codex-claude-delegate/server/server.js +28048 -0
  40. package/plugins/codex-claude-delegate/skills/claude-delegate.md +30 -0
  41. package/plugins/codex-claude-delegate/skills/claude-rescue.md +52 -0
  42. package/plugins/codex-claude-delegate/skills/claude-review.md +25 -0
package/dist/cli.js ADDED
@@ -0,0 +1,334 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from "node:url";
3
+ import { resolve } from "node:path";
4
+ import { getPackageInfo } from "./package-info.js";
5
+ import { main as startMcpServer } from "./server.js";
6
+ import { DEFAULT_ENABLED_TOOLS, renderClaudeDelegateMcpConfig } from "./codex-config.js";
7
+ async function packageVersion() {
8
+ const info = await getPackageInfo();
9
+ return `${info.name} v${info.version}`;
10
+ }
11
+ async function doctorCommand(deps, json) {
12
+ const { execCapture } = await import("./guard.js");
13
+ const { scanClaudeDelegateConfig } = await import("./codex-config.js");
14
+ const { getAllowRoots } = await import("./guard.js");
15
+ const result = {
16
+ ready: false,
17
+ status: "ready",
18
+ checks: {
19
+ node: { ok: false, version: "", required: ">=20" },
20
+ package: { ok: false, name: "", version: "" },
21
+ claude_cli: { ok: false },
22
+ git: { ok: false, worktree: false },
23
+ codex_config: { ok: false, path: "" },
24
+ mcp_server: { ok: false, name: "claude_delegate" },
25
+ default_tools: { ok: false, enabled_count: 0, enabled: [] },
26
+ allow_roots: { ok: false },
27
+ },
28
+ warnings: [],
29
+ next_step: "",
30
+ };
31
+ const warnings = [];
32
+ let notReady = false;
33
+ let needsSetup = false;
34
+ let needsAttention = false;
35
+ // Node check
36
+ const nodeMajor = Number(process.versions.node.split(".")[0]);
37
+ result.checks.node = { ok: nodeMajor >= 20, version: process.versions.node, required: ">=20" };
38
+ if (!result.checks.node.ok) {
39
+ warnings.push(`Node.js ${process.versions.node} is below required >=20`);
40
+ notReady = true;
41
+ }
42
+ // Package check
43
+ try {
44
+ const info = await getPackageInfo();
45
+ result.checks.package = { ok: true, name: info.name, version: info.version };
46
+ }
47
+ catch {
48
+ result.checks.package = { ok: false, name: "", version: "" };
49
+ warnings.push("Could not read package info");
50
+ notReady = true;
51
+ }
52
+ // Claude CLI check
53
+ const claudeBin = process.env.CLAUDE_BIN ?? "claude";
54
+ try {
55
+ const version = await execCapture(claudeBin, ["--version"], { cwd: process.cwd(), timeoutMs: 10000 });
56
+ result.checks.claude_cli = { ok: true, path: claudeBin !== "claude" ? claudeBin : undefined, version };
57
+ }
58
+ catch {
59
+ result.checks.claude_cli = { ok: false };
60
+ warnings.push("Claude CLI not found in PATH");
61
+ notReady = true;
62
+ }
63
+ // Git check
64
+ try {
65
+ const gitVersion = await execCapture("git", ["--version"], { cwd: process.cwd(), timeoutMs: 5000 });
66
+ let worktreeSupported = false;
67
+ try {
68
+ await execCapture("git", ["worktree", "list"], { cwd: process.cwd(), timeoutMs: 5000 });
69
+ worktreeSupported = true;
70
+ }
71
+ catch {
72
+ worktreeSupported = false;
73
+ }
74
+ result.checks.git = { ok: true, version: gitVersion, worktree: worktreeSupported };
75
+ }
76
+ catch {
77
+ result.checks.git = { ok: false, worktree: false };
78
+ warnings.push("Git not found");
79
+ notReady = true;
80
+ }
81
+ // Codex config check
82
+ let scanResult = undefined;
83
+ try {
84
+ const scan = await scanClaudeDelegateConfig();
85
+ scanResult = scan;
86
+ result.checks.codex_config = { ok: scan.exists, path: scan.configPath };
87
+ if (!scan.exists) {
88
+ needsSetup = true;
89
+ warnings.push("Codex config not found");
90
+ }
91
+ // MCP server check — validate command = "codex-claude"
92
+ if (scan.mcpClassification) {
93
+ const hasCorrectCommand = scan.mcpCommand === "codex-claude";
94
+ result.checks.mcp_server = { ok: hasCorrectCommand, name: "claude_delegate" };
95
+ if (!hasCorrectCommand) {
96
+ needsSetup = true;
97
+ warnings.push(`claude_delegate command is "${scan.mcpCommand ?? "unset"}", expected "codex-claude"`);
98
+ }
99
+ }
100
+ else {
101
+ result.checks.mcp_server = { ok: false, name: "claude_delegate" };
102
+ needsSetup = true;
103
+ warnings.push("claude_delegate MCP server not configured");
104
+ }
105
+ // Default tools check — validate actual enabled_tools list
106
+ if (scan.mcpCommand === "codex-claude" && scan.mcpEnabledTools) {
107
+ const defaultTools = [...DEFAULT_ENABLED_TOOLS];
108
+ const missingTools = defaultTools.filter((t) => !scan.mcpEnabledTools.includes(t));
109
+ const extraTools = scan.mcpEnabledTools.filter((t) => !defaultTools.includes(t));
110
+ if (missingTools.length === 0 && extraTools.length === 0) {
111
+ result.checks.default_tools.ok = true;
112
+ }
113
+ else {
114
+ if (missingTools.length > 0) {
115
+ needsAttention = true;
116
+ warnings.push(`Default tools missing from enabled_tools: ${missingTools.join(", ")}`);
117
+ }
118
+ if (extraTools.length > 0) {
119
+ needsAttention = true;
120
+ warnings.push(`Enabled tools include non-default advanced tools: ${extraTools.join(", ")}. The default config should only include the 6 standard tools.`);
121
+ }
122
+ }
123
+ result.checks.default_tools.enabled_count = scan.mcpEnabledTools.length;
124
+ result.checks.default_tools.enabled = [...scan.mcpEnabledTools];
125
+ }
126
+ else {
127
+ result.checks.default_tools.enabled_count = 0;
128
+ result.checks.default_tools.enabled = [];
129
+ if (scan.mcpCommand === "codex-claude" && scan.mcpEnabledTools === null) {
130
+ needsAttention = true;
131
+ warnings.push("enabled_tools is missing; default config should explicitly enable the 6 standard tools");
132
+ }
133
+ }
134
+ }
135
+ catch {
136
+ result.checks.codex_config = { ok: false, path: "" };
137
+ needsSetup = true;
138
+ }
139
+ // Allow roots check — use config file value first, then env var as fallback
140
+ try {
141
+ const { realpath } = await import("node:fs/promises");
142
+ const cwd = await realpath(process.cwd());
143
+ // Parse allow roots from config file (scan result from above)
144
+ let allowRootPaths = [];
145
+ if (scanResult && scanResult.allowRootsValue) {
146
+ const configValue = scanResult.allowRootsValue;
147
+ const delimiter = configValue.includes(":") ? ":" : configValue.includes(";") ? ";" : ",";
148
+ allowRootPaths = configValue.split(delimiter).map((p) => p.trim()).filter(Boolean);
149
+ }
150
+ // Also include env-var / default roots
151
+ for (const root of getAllowRoots()) {
152
+ if (!allowRootPaths.includes(root))
153
+ allowRootPaths.push(root);
154
+ }
155
+ const cwdAllowed = allowRootPaths.some((root) => cwd === root || cwd.startsWith(root + "/"));
156
+ result.checks.allow_roots = { ok: cwdAllowed, current_repo_allowed: cwdAllowed };
157
+ if (!cwdAllowed) {
158
+ needsAttention = true;
159
+ warnings.push("Current repo is not included in CODEX_CLAUDE_ALLOW_ROOTS");
160
+ }
161
+ }
162
+ catch {
163
+ result.checks.allow_roots = { ok: false };
164
+ needsAttention = true;
165
+ }
166
+ // Determine overall status
167
+ if (notReady) {
168
+ result.status = "not_ready";
169
+ }
170
+ else if (needsSetup) {
171
+ result.status = "needs_setup";
172
+ }
173
+ else if (needsAttention) {
174
+ result.status = "needs_attention";
175
+ }
176
+ else {
177
+ result.status = "ready";
178
+ }
179
+ result.ready = result.status === "ready";
180
+ result.warnings = warnings;
181
+ // Next step
182
+ if (result.status === "ready") {
183
+ result.next_step = 'Restart Codex CLI, then ask: "Use claude_setup to check this repository."';
184
+ }
185
+ else if (result.status === "needs_setup") {
186
+ result.next_step = "codex-claude setup --write";
187
+ }
188
+ else if (result.status === "needs_attention" && needsAttention) {
189
+ result.next_step = 'codex-claude setup --write --allow-root "' + process.cwd() + '"';
190
+ }
191
+ else {
192
+ result.next_step = "Run codex-claude doctor again after fixing issues.";
193
+ }
194
+ if (json) {
195
+ deps.writeOut(JSON.stringify(result, null, 2) + "\n");
196
+ }
197
+ else {
198
+ deps.writeOut("Codex-Claude doctor\n\n");
199
+ const emit = (label, ok) => deps.writeOut(`${ok ? "✓" : "✗"} ${label}\n`);
200
+ emit(`Node.js: ${result.checks.node.version} (${result.checks.node.required})`, result.checks.node.ok);
201
+ emit(`Package: ${result.checks.package.ok ? `${result.checks.package.name} v${result.checks.package.version}` : "unknown"}`, result.checks.package.ok);
202
+ emit(`Claude CLI: ${result.checks.claude_cli.ok ? (result.checks.claude_cli.path ?? "found") : "not found"}`, result.checks.claude_cli.ok);
203
+ if (result.checks.claude_cli.version) {
204
+ deps.writeOut(` Claude version: ${result.checks.claude_cli.version}\n`);
205
+ }
206
+ emit(`Git: ${result.checks.git.version ?? "not found"}`, result.checks.git.ok);
207
+ emit(`Git worktree: supported`, result.checks.git.worktree);
208
+ if (result.checks.codex_config.ok) {
209
+ emit(`Codex config: ${result.checks.codex_config.path}`, true);
210
+ }
211
+ else {
212
+ emit(`Codex config: not found`, false);
213
+ }
214
+ emit(`MCP server: ${result.checks.mcp_server.ok ? "claude_delegate configured" : "claude_delegate not configured"}`, result.checks.mcp_server.ok);
215
+ emit(`Default tools: ${result.checks.default_tools.enabled_count} enabled`, result.checks.default_tools.ok);
216
+ if (result.checks.allow_roots.ok !== undefined) {
217
+ emit(`Allow roots: ${result.checks.allow_roots.current_repo_allowed ? "current repo allowed" : "current repo is not included"}`, result.checks.allow_roots.ok);
218
+ }
219
+ deps.writeOut(`\nStatus: ${result.status}\n`);
220
+ if (result.status !== "ready") {
221
+ deps.writeOut("\n");
222
+ for (const w of warnings) {
223
+ deps.writeOut(` ${w}\n`);
224
+ }
225
+ }
226
+ deps.writeOut(`\nNext step:\n ${result.next_step}\n`);
227
+ }
228
+ return result.ready ? 0 : 1;
229
+ }
230
+ export async function runCli(argv = process.argv, deps = {}) {
231
+ const writeOut = deps.writeOut ?? ((text) => process.stdout.write(text));
232
+ const writeErr = deps.writeErr ?? ((text) => process.stderr.write(text));
233
+ const startMcp = deps.startMcp ?? startMcpServer;
234
+ const args = argv.slice(2);
235
+ const command = args[0];
236
+ try {
237
+ if (!command || command === "mcp") {
238
+ await startMcp();
239
+ return 0;
240
+ }
241
+ if (command === "--version" || command === "-v") {
242
+ writeOut(`${await packageVersion()}\n`);
243
+ return 0;
244
+ }
245
+ if (command === "print-config") {
246
+ if (args.includes("--npx")) {
247
+ writeErr("--npx is not supported. Install globally with npm install -g @anyi61/codex-claude-delegate-mcp.\n");
248
+ return 2;
249
+ }
250
+ if (args.includes("--source")) {
251
+ const sourceIdx = args.indexOf("--source") + 1;
252
+ const sourcePath = args[sourceIdx];
253
+ if (!sourcePath) {
254
+ writeErr("--source requires a path argument\n");
255
+ return 2;
256
+ }
257
+ if (!sourcePath.startsWith("/")) {
258
+ writeErr("--source requires an absolute path\n");
259
+ return 2;
260
+ }
261
+ const toolLines = DEFAULT_ENABLED_TOOLS.map((t) => ` "${t}"`).join(",\n");
262
+ writeOut(`[mcp_servers.claude_delegate]\ncommand = "node"\nargs = ["${sourcePath}/dist/cli.js"]\nstartup_timeout_sec = 20\ntool_timeout_sec = 600\nenabled_tools = [\n${toolLines}\n]\n`);
263
+ return 0;
264
+ }
265
+ if (args.includes("--project")) {
266
+ const toolLines = DEFAULT_ENABLED_TOOLS.map((t) => ` "${t}"`).join(",\n");
267
+ writeOut(`[mcp_servers.claude_delegate]\ncommand = "codex-claude"\nstartup_timeout_sec = 20\ntool_timeout_sec = 600\nenabled_tools = [\n${toolLines}\n]\n`);
268
+ writeOut(`\nTarget path: ./.codex/config.toml\n`);
269
+ return 0;
270
+ }
271
+ writeOut(renderClaudeDelegateMcpConfig());
272
+ return 0;
273
+ }
274
+ if (command === "setup") {
275
+ if (args.includes("--print")) {
276
+ writeOut("Codex-Claude setup --print\n\n");
277
+ writeOut(renderClaudeDelegateMcpConfig());
278
+ return 0;
279
+ }
280
+ if (args.includes("--write")) {
281
+ const { setupWrite } = await import("./codex-config.js");
282
+ const isProject = args.includes("--project");
283
+ const force = args.includes("--force");
284
+ if (isProject && args.includes("--allow-root")) {
285
+ writeErr("--project and --allow-root cannot be combined. Use global setup for allow-root configuration.\n");
286
+ return 2;
287
+ }
288
+ let allowRootPath;
289
+ const allowRootIdx = args.indexOf("--allow-root");
290
+ if (allowRootIdx >= 0) {
291
+ if (args.length <= allowRootIdx + 1 || args[allowRootIdx + 1].startsWith("--")) {
292
+ writeErr("--allow-root requires a path argument\n");
293
+ return 2;
294
+ }
295
+ allowRootPath = args[allowRootIdx + 1];
296
+ }
297
+ const result = await setupWrite({
298
+ isProject,
299
+ force,
300
+ allowRoot: allowRootPath,
301
+ });
302
+ writeOut(`${result.message}\n`);
303
+ return result.exitCode;
304
+ }
305
+ writeErr("Usage: codex-claude setup --write [--force] [--allow-root <path>] [--project]\n");
306
+ writeErr(" codex-claude setup --print\n");
307
+ return 2;
308
+ }
309
+ if (command === "doctor") {
310
+ const isJson = args.includes("--json");
311
+ const io = { writeOut, writeErr };
312
+ return doctorCommand(io, isJson);
313
+ }
314
+ writeErr(`Unknown command: ${command}\n`);
315
+ writeErr("Usage: codex-claude [mcp|--version|print-config|setup|doctor]\n");
316
+ return 2;
317
+ }
318
+ catch (err) {
319
+ writeErr(`${err instanceof Error ? err.message : String(err)}\n`);
320
+ return 1;
321
+ }
322
+ }
323
+ function isDirectRun() {
324
+ if (!process.argv[1])
325
+ return false;
326
+ return fileURLToPath(import.meta.url) === resolve(process.argv[1]);
327
+ }
328
+ if (isDirectRun()) {
329
+ runCli().then((code) => {
330
+ if (code !== 0)
331
+ process.exitCode = code;
332
+ });
333
+ }
334
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAwEzF,KAAK,UAAU,cAAc;IAC3B,MAAM,IAAI,GAAG,MAAM,cAAc,EAAE,CAAC;IACpC,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;AACzC,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,IAA8D,EAAE,IAAc;IACzG,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;IACnD,MAAM,EAAE,wBAAwB,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,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C,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,104 @@
1
+ export interface CodexAllowRootConfiguration {
2
+ config_path: string;
3
+ changed: boolean;
4
+ allow_roots: string[];
5
+ env_value: string;
6
+ message: string;
7
+ }
8
+ /** Classification of an MCP server section in TOML config */
9
+ export interface McpServerClassification {
10
+ origin: "auto" | "env_only" | "manual";
11
+ hasCommand: boolean;
12
+ hasArgs: boolean;
13
+ hasEnv: boolean;
14
+ }
15
+ /**
16
+ * Remove a resolved path from a delimiter-separated allow-roots value.
17
+ * Returns null when the result would be empty, the original value when
18
+ * nothing changed, or the new joined string.
19
+ */
20
+ export declare function removePathFromAllowRootsValue(currentValue: string, pathToRemove: string, delimiter: string): string | null;
21
+ /**
22
+ * Delete a key assignment line from a TOML table section.
23
+ * Does not remove the table header or other keys.
24
+ */
25
+ export declare function deleteTomlTableKey(config: string, tableName: string, key: string): string;
26
+ /** Read the list of key names defined in a TOML table. */
27
+ export declare function readTableKeys(config: string, tableName: string): string[];
28
+ /**
29
+ * Classify the `[mcp_servers.claude_delegate]` section in a TOML config:
30
+ * - "auto": command="node" and args point to this plugin's server script.
31
+ * - "env_only": only an `.env` subsection exists, no command/args.
32
+ * - "manual": anything else (custom command, different args, etc.).
33
+ * Returns null when no claude_delegate MCP section exists.
34
+ */
35
+ export declare function classifyMcpServerSection(config: string): McpServerClassification | null;
36
+ export interface ClaudeDelegateConfigScan {
37
+ configPath: string;
38
+ exists: boolean;
39
+ hasAllowRoots: boolean;
40
+ allowRootsValue: string | null;
41
+ mcpClassification: McpServerClassification | null;
42
+ mcpServerKeys: string[];
43
+ envKeys: string[];
44
+ mcpCommand: string | null;
45
+ mcpEnabledTools: string[] | null;
46
+ }
47
+ /**
48
+ * Read-only scan of ~/.codex/config.toml for claude_delegate related configuration.
49
+ * Returns an empty result when the config file does not exist (never throws).
50
+ */
51
+ export declare function scanClaudeDelegateConfig(): Promise<ClaudeDelegateConfigScan>;
52
+ export interface RemoveAllowRootResult {
53
+ configPath: string;
54
+ changed: boolean;
55
+ message: string;
56
+ }
57
+ /**
58
+ * Remove the given cwd from CODEX_CLAUDE_ALLOW_ROWS in the TOML config.
59
+ * Only operates on `CODEX_CLAUDE_ALLOW_ROOTS`; preserves other keys in the same table.
60
+ * Idempotent: returns changed=false when the path is already absent.
61
+ */
62
+ export declare function removeAllowRoot(cwd: string): Promise<RemoveAllowRootResult>;
63
+ export interface RemoveMcpServerResult {
64
+ configPath: string;
65
+ changed: boolean;
66
+ action: "deleted" | "env_deleted" | "manual_skip" | "not_found";
67
+ message: string;
68
+ }
69
+ /**
70
+ * Remove or flag the `[mcp_servers.claude_delegate]` section:
71
+ * - "auto": delete the entire section (including .env subsection).
72
+ * - "env_only": delete .env subsection; also removes empty parent header.
73
+ * - "manual": no-op, returns manual_skip for caller to decide.
74
+ */
75
+ export declare function removeOrFlagMcpServerSection(): Promise<RemoveMcpServerResult>;
76
+ /**
77
+ * Remove the claude_delegate MCP section after an explicit user confirmation.
78
+ * This is intentionally separate from removeOrFlagMcpServerSection so --yes
79
+ * mode can keep manual MCP config fail-closed.
80
+ */
81
+ export declare function removeConfirmedMcpServerSection(): Promise<RemoveMcpServerResult>;
82
+ export declare function configureCodexAllowRoot(rawCwd: string): Promise<CodexAllowRootConfiguration>;
83
+ export declare const DEFAULT_ENABLED_TOOLS: readonly ["claude_setup", "claude_task", "claude_job_wait", "claude_result", "claude_apply", "claude_cleanup"];
84
+ export interface SetupConfigOptions {
85
+ force?: boolean;
86
+ }
87
+ export interface SetupConfigResult {
88
+ changed: boolean;
89
+ existed: boolean;
90
+ content: string;
91
+ message: string;
92
+ }
93
+ export declare function renderClaudeDelegateMcpConfig(): string;
94
+ export declare function upsertClaudeDelegateMcpServer(config: string, options?: SetupConfigOptions): SetupConfigResult;
95
+ export interface SetupWriteOptions {
96
+ isProject?: boolean;
97
+ force?: boolean;
98
+ allowRoot?: string;
99
+ }
100
+ export interface SetupWriteResult {
101
+ exitCode: number;
102
+ message: string;
103
+ }
104
+ export declare function setupWrite(options?: SetupWriteOptions): Promise<SetupWriteResult>;