causoryn 0.0.0-stage → 0.2.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/.claude-plugin/plugin.json +36 -0
- package/.codex-plugin/mcp.json +19 -0
- package/.codex-plugin/plugin.json +38 -0
- package/.zcode-plugin/plugin.json +42 -0
- package/LICENSE +21 -0
- package/README.md +171 -2
- package/THIRD-PARTY-NOTICES.md +443 -0
- package/dist/bundle-manifest.json +39 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +253 -0
- package/dist/doctor.d.ts +13 -0
- package/dist/doctor.js +507 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/mcp-server.mjs +288477 -0
- package/dist/mcp-server.mjs.LEGAL.txt +17 -0
- package/dist/node_modules/better-sqlite3/LICENSE +21 -0
- package/dist/node_modules/better-sqlite3/lib/binding.js +62 -0
- package/dist/node_modules/better-sqlite3/lib/darwin-arm64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/darwin-x64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/database.js +109 -0
- package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/linux-arm64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/linux-x64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/linuxmusl-arm64.js +4 -0
- package/dist/node_modules/better-sqlite3/lib/linuxmusl-x64.js +4 -0
- package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/node_modules/better-sqlite3/lib/methods/explain.js +9 -0
- package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/node_modules/better-sqlite3/lib/methods/table.js +195 -0
- package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +25 -0
- package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/win32-arm64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/win32-x64.js +3 -0
- package/dist/node_modules/better-sqlite3/package.json +67 -0
- package/dist/node_modules/better-sqlite3/prebuilds/darwin-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/darwin-x64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linux-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linux-x64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linuxmusl-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linuxmusl-x64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/win32-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/win32-x64.node +0 -0
- package/dist/runtime-stage.d.ts +8 -0
- package/dist/runtime-stage.js +159 -0
- package/dist/setup.d.ts +15 -0
- package/dist/setup.js +735 -0
- package/dist/toml-patch.d.ts +10 -0
- package/dist/toml-patch.js +587 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +35 -0
- package/dist/typescript-lib/lib.d.ts +22 -0
- package/dist/typescript-lib/lib.decorators.d.ts +384 -0
- package/dist/typescript-lib/lib.decorators.legacy.d.ts +22 -0
- package/dist/typescript-lib/lib.dom.asynciterable.d.ts +41 -0
- package/dist/typescript-lib/lib.dom.d.ts +39429 -0
- package/dist/typescript-lib/lib.dom.iterable.d.ts +571 -0
- package/dist/typescript-lib/lib.es2015.collection.d.ts +147 -0
- package/dist/typescript-lib/lib.es2015.core.d.ts +597 -0
- package/dist/typescript-lib/lib.es2015.d.ts +28 -0
- package/dist/typescript-lib/lib.es2015.generator.d.ts +77 -0
- package/dist/typescript-lib/lib.es2015.iterable.d.ts +605 -0
- package/dist/typescript-lib/lib.es2015.promise.d.ts +81 -0
- package/dist/typescript-lib/lib.es2015.proxy.d.ts +128 -0
- package/dist/typescript-lib/lib.es2015.reflect.d.ts +144 -0
- package/dist/typescript-lib/lib.es2015.symbol.d.ts +46 -0
- package/dist/typescript-lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/dist/typescript-lib/lib.es2016.array.include.d.ts +116 -0
- package/dist/typescript-lib/lib.es2016.d.ts +21 -0
- package/dist/typescript-lib/lib.es2016.full.d.ts +23 -0
- package/dist/typescript-lib/lib.es2016.intl.d.ts +31 -0
- package/dist/typescript-lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/dist/typescript-lib/lib.es2017.d.ts +26 -0
- package/dist/typescript-lib/lib.es2017.date.d.ts +31 -0
- package/dist/typescript-lib/lib.es2017.full.d.ts +23 -0
- package/dist/typescript-lib/lib.es2017.intl.d.ts +44 -0
- package/dist/typescript-lib/lib.es2017.object.d.ts +49 -0
- package/dist/typescript-lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/dist/typescript-lib/lib.es2017.string.d.ts +45 -0
- package/dist/typescript-lib/lib.es2017.typedarrays.d.ts +53 -0
- package/dist/typescript-lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/dist/typescript-lib/lib.es2018.asynciterable.d.ts +53 -0
- package/dist/typescript-lib/lib.es2018.d.ts +24 -0
- package/dist/typescript-lib/lib.es2018.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2018.intl.d.ts +83 -0
- package/dist/typescript-lib/lib.es2018.promise.d.ts +30 -0
- package/dist/typescript-lib/lib.es2018.regexp.d.ts +37 -0
- package/dist/typescript-lib/lib.es2019.array.d.ts +79 -0
- package/dist/typescript-lib/lib.es2019.d.ts +24 -0
- package/dist/typescript-lib/lib.es2019.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2019.intl.d.ts +23 -0
- package/dist/typescript-lib/lib.es2019.object.d.ts +33 -0
- package/dist/typescript-lib/lib.es2019.string.d.ts +37 -0
- package/dist/typescript-lib/lib.es2019.symbol.d.ts +24 -0
- package/dist/typescript-lib/lib.es2020.bigint.d.ts +765 -0
- package/dist/typescript-lib/lib.es2020.d.ts +27 -0
- package/dist/typescript-lib/lib.es2020.date.d.ts +42 -0
- package/dist/typescript-lib/lib.es2020.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2020.intl.d.ts +474 -0
- package/dist/typescript-lib/lib.es2020.number.d.ts +28 -0
- package/dist/typescript-lib/lib.es2020.promise.d.ts +47 -0
- package/dist/typescript-lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/dist/typescript-lib/lib.es2020.string.d.ts +44 -0
- package/dist/typescript-lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/dist/typescript-lib/lib.es2021.d.ts +23 -0
- package/dist/typescript-lib/lib.es2021.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2021.intl.d.ts +166 -0
- package/dist/typescript-lib/lib.es2021.promise.d.ts +48 -0
- package/dist/typescript-lib/lib.es2021.string.d.ts +33 -0
- package/dist/typescript-lib/lib.es2021.weakref.d.ts +78 -0
- package/dist/typescript-lib/lib.es2022.array.d.ts +121 -0
- package/dist/typescript-lib/lib.es2022.d.ts +25 -0
- package/dist/typescript-lib/lib.es2022.error.d.ts +75 -0
- package/dist/typescript-lib/lib.es2022.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2022.intl.d.ts +145 -0
- package/dist/typescript-lib/lib.es2022.object.d.ts +26 -0
- package/dist/typescript-lib/lib.es2022.regexp.d.ts +39 -0
- package/dist/typescript-lib/lib.es2022.string.d.ts +25 -0
- package/dist/typescript-lib/lib.es2023.array.d.ts +924 -0
- package/dist/typescript-lib/lib.es2023.collection.d.ts +21 -0
- package/dist/typescript-lib/lib.es2023.d.ts +22 -0
- package/dist/typescript-lib/lib.es2023.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2023.intl.d.ts +56 -0
- package/dist/typescript-lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/dist/typescript-lib/lib.es2024.collection.d.ts +29 -0
- package/dist/typescript-lib/lib.es2024.d.ts +26 -0
- package/dist/typescript-lib/lib.es2024.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2024.object.d.ts +29 -0
- package/dist/typescript-lib/lib.es2024.promise.d.ts +35 -0
- package/dist/typescript-lib/lib.es2024.regexp.d.ts +25 -0
- package/dist/typescript-lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/dist/typescript-lib/lib.es2024.string.d.ts +29 -0
- package/dist/typescript-lib/lib.es5.d.ts +4601 -0
- package/dist/typescript-lib/lib.es6.d.ts +23 -0
- package/dist/typescript-lib/lib.esnext.array.d.ts +35 -0
- package/dist/typescript-lib/lib.esnext.collection.d.ts +96 -0
- package/dist/typescript-lib/lib.esnext.d.ts +29 -0
- package/dist/typescript-lib/lib.esnext.decorators.d.ts +28 -0
- package/dist/typescript-lib/lib.esnext.disposable.d.ts +193 -0
- package/dist/typescript-lib/lib.esnext.error.d.ts +24 -0
- package/dist/typescript-lib/lib.esnext.float16.d.ts +445 -0
- package/dist/typescript-lib/lib.esnext.full.d.ts +24 -0
- package/dist/typescript-lib/lib.esnext.intl.d.ts +21 -0
- package/dist/typescript-lib/lib.esnext.iterator.d.ts +148 -0
- package/dist/typescript-lib/lib.esnext.promise.d.ts +34 -0
- package/dist/typescript-lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/dist/typescript-lib/lib.scripthost.d.ts +322 -0
- package/dist/typescript-lib/lib.webworker.asynciterable.d.ts +41 -0
- package/dist/typescript-lib/lib.webworker.d.ts +13150 -0
- package/dist/typescript-lib/lib.webworker.importscripts.d.ts +23 -0
- package/dist/typescript-lib/lib.webworker.iterable.d.ts +340 -0
- package/licenses/Apache-2.0.txt +55 -0
- package/licenses/TypeScript-ThirdPartyNoticeText.txt +193 -0
- package/licenses/better-sqlite3-LICENSE.txt +21 -0
- package/mcp_config.json +16 -0
- package/native/go-worker/PROTOCOL.md +316 -0
- package/native/go-worker/cmd/worker/main.go +440 -0
- package/native/go-worker/go.mod +3 -0
- package/native/go-worker/internal/analyze/analyze.go +820 -0
- package/native/go-worker/internal/analyze/model.go +182 -0
- package/native/go-worker/internal/analyze/routes.go +181 -0
- package/native/python-worker/PROTOCOL.md +342 -0
- package/native/python-worker/worker.py +1190 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.csproj +40 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.deps.json +59 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.dll +0 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.runtimeconfig.json +13 -0
- package/native/roslyn-worker/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/native/roslyn-worker/Microsoft.CodeAnalysis.dll +0 -0
- package/native/roslyn-worker/PROTOCOL.md +285 -0
- package/native/roslyn-worker/Program.cs +249 -0
- package/native/roslyn-worker/Protocol.cs +397 -0
- package/native/roslyn-worker/ReferenceResolver.cs +235 -0
- package/native/roslyn-worker/WorkerAnalyzer.cs +1669 -0
- package/native/roslyn-worker/packages.lock.json +30 -0
- package/native/rust-worker/Cargo.lock +107 -0
- package/native/rust-worker/Cargo.toml +23 -0
- package/native/rust-worker/PROTOCOL.md +294 -0
- package/native/rust-worker/src/analyzer.rs +1209 -0
- package/native/rust-worker/src/main.rs +127 -0
- package/native/rust-worker/src/protocol.rs +284 -0
- package/native/rust-worker/src/sha256.rs +136 -0
- package/package.json +71 -4
- package/plugin.json +17 -0
- package/scripts/causoryn.mjs +40 -0
- package/scripts/lib/node-version-guard.mjs +24 -0
- package/scripts/plugin-mcp-launcher.mjs +111 -0
- package/skills/causoryn/SKILL.md +53 -0
- package/skills/map-system/SKILL.md +69 -0
- package/skills/preflight-change/SKILL.md +38 -0
- package/skills/verify-change/SKILL.md +31 -0
package/dist/setup.js
ADDED
|
@@ -0,0 +1,735 @@
|
|
|
1
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { getPersistentRuntimeDir, isEphemeralRuntimeDir, isSameRuntimeDir, stagePersistentRuntime, } from "./runtime-stage.js";
|
|
6
|
+
import { readCodexMcpServer, removeCodexMcpServer, upsertCodexMcpServer, } from "./toml-patch.js";
|
|
7
|
+
import { CANONICAL_SKILL_NAMES, CausorynCliError, HOST_CLIENT_IDS, } from "./types.js";
|
|
8
|
+
function assertRegularOrAbsentTarget(filePath) {
|
|
9
|
+
let st;
|
|
10
|
+
try {
|
|
11
|
+
st = lstatSync(filePath);
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
if (err.code === "ENOENT") {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
throw new CausorynCliError("cli/io-error", `Hedef dosya durumu okunamadı (${filePath}): ${err instanceof Error ? err.message : String(err)}`);
|
|
18
|
+
}
|
|
19
|
+
if (st.isSymbolicLink()) {
|
|
20
|
+
throw new CausorynCliError("cli/io-error", `Güvenlik nedeniyle sembolik bağlantı üzerine yazılamaz (CWE-59): ${filePath}`);
|
|
21
|
+
}
|
|
22
|
+
if (!st.isFile()) {
|
|
23
|
+
throw new CausorynCliError("cli/io-error", `Hedef yol düzenli bir dosya değil: ${filePath}`);
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function assertConfigAndBackupTargetsSafe(targetPath) {
|
|
28
|
+
const existed = assertRegularOrAbsentTarget(targetPath);
|
|
29
|
+
assertRegularOrAbsentTarget(`${targetPath}.causoryn.backup`);
|
|
30
|
+
return existed;
|
|
31
|
+
}
|
|
32
|
+
export function resolveDefaultPackageRoot() {
|
|
33
|
+
return path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
34
|
+
}
|
|
35
|
+
export function resolveEffectiveHomeDir(explicitHomeDir) {
|
|
36
|
+
if (explicitHomeDir !== undefined && explicitHomeDir.trim().length > 0) {
|
|
37
|
+
return path.resolve(explicitHomeDir);
|
|
38
|
+
}
|
|
39
|
+
const envHome = process.env["HOME"] ?? process.env["USERPROFILE"];
|
|
40
|
+
if (envHome !== undefined && envHome.trim().length > 0) {
|
|
41
|
+
return path.resolve(envHome);
|
|
42
|
+
}
|
|
43
|
+
return path.resolve(os.homedir());
|
|
44
|
+
}
|
|
45
|
+
export function resolveEffectiveCodexHomeDir(homeDir, explicitCodexHomeDir, explicitHomeProvided = false, env = process.env) {
|
|
46
|
+
if (explicitCodexHomeDir !== undefined && explicitCodexHomeDir.trim().length > 0) {
|
|
47
|
+
return path.resolve(explicitCodexHomeDir);
|
|
48
|
+
}
|
|
49
|
+
if (!explicitHomeProvided || env !== process.env) {
|
|
50
|
+
const envCodex = env["CODEX_HOME"];
|
|
51
|
+
if (envCodex !== undefined && envCodex.trim().length > 0) {
|
|
52
|
+
return path.resolve(envCodex);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return path.join(homeDir, ".codex");
|
|
56
|
+
}
|
|
57
|
+
export function resolveEffectiveClaudeConfigDir(explicitClaudeConfigDir, explicitHomeProvided = false, env = process.env) {
|
|
58
|
+
if (explicitClaudeConfigDir !== undefined && explicitClaudeConfigDir.trim().length > 0) {
|
|
59
|
+
return path.resolve(explicitClaudeConfigDir);
|
|
60
|
+
}
|
|
61
|
+
if (!explicitHomeProvided || env !== process.env) {
|
|
62
|
+
const envClaude = env["CLAUDE_CONFIG_DIR"];
|
|
63
|
+
if (envClaude !== undefined && envClaude.trim().length > 0) {
|
|
64
|
+
return path.resolve(envClaude);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
export function getClaudeConfigFilePath(homeDir, claudeConfigDir) {
|
|
70
|
+
return claudeConfigDir !== undefined && claudeConfigDir !== null
|
|
71
|
+
? path.join(claudeConfigDir, ".claude.json")
|
|
72
|
+
: path.join(homeDir, ".claude.json");
|
|
73
|
+
}
|
|
74
|
+
export function getHostSkillsDir(homeDir, client, claudeConfigDir) {
|
|
75
|
+
switch (client) {
|
|
76
|
+
case "antigravity":
|
|
77
|
+
return path.join(homeDir, ".gemini", "config", "skills");
|
|
78
|
+
case "claude-code":
|
|
79
|
+
return claudeConfigDir !== undefined && claudeConfigDir !== null
|
|
80
|
+
? path.join(claudeConfigDir, "skills")
|
|
81
|
+
: path.join(homeDir, ".claude", "skills");
|
|
82
|
+
case "codex":
|
|
83
|
+
return path.join(homeDir, ".agents", "skills");
|
|
84
|
+
case "zcode":
|
|
85
|
+
return path.join(homeDir, ".zcode", "skills");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function detectInstalledClients(homeDir, codexHomeDir, claudeConfigDir) {
|
|
89
|
+
const detected = [];
|
|
90
|
+
if (existsSync(path.join(homeDir, ".gemini", "config")) ||
|
|
91
|
+
existsSync(path.join(homeDir, ".gemini", "antigravity")) ||
|
|
92
|
+
existsSync(path.join(homeDir, ".gemini"))) {
|
|
93
|
+
detected.push("antigravity");
|
|
94
|
+
}
|
|
95
|
+
const claudeDetected = claudeConfigDir !== undefined && claudeConfigDir !== null
|
|
96
|
+
? existsSync(claudeConfigDir) || existsSync(path.join(claudeConfigDir, ".claude.json"))
|
|
97
|
+
: existsSync(path.join(homeDir, ".claude.json")) || existsSync(path.join(homeDir, ".claude"));
|
|
98
|
+
if (claudeDetected) {
|
|
99
|
+
detected.push("claude-code");
|
|
100
|
+
}
|
|
101
|
+
if (existsSync(codexHomeDir) ||
|
|
102
|
+
existsSync(path.join(codexHomeDir, "config.toml"))) {
|
|
103
|
+
detected.push("codex");
|
|
104
|
+
}
|
|
105
|
+
if (existsSync(path.join(homeDir, ".zcode")) ||
|
|
106
|
+
existsSync(path.join(homeDir, ".zcode", "cli", "config.json"))) {
|
|
107
|
+
detected.push("zcode");
|
|
108
|
+
}
|
|
109
|
+
return detected;
|
|
110
|
+
}
|
|
111
|
+
function isPlainObject(value) {
|
|
112
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
113
|
+
}
|
|
114
|
+
function parseJsonObjectStrict(raw, filePath) {
|
|
115
|
+
let parsed;
|
|
116
|
+
try {
|
|
117
|
+
parsed = JSON.parse(raw);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new CausorynCliError("cli/malformed-json", `Bozuk JSON konfigürasyon dosyası (${filePath}): ${error instanceof Error ? error.message : String(error)}`);
|
|
121
|
+
}
|
|
122
|
+
if (!isPlainObject(parsed)) {
|
|
123
|
+
throw new CausorynCliError("cli/malformed-json", `JSON kök değeri bir nesne olmalı (${filePath})`);
|
|
124
|
+
}
|
|
125
|
+
return parsed;
|
|
126
|
+
}
|
|
127
|
+
function resolveSkillsSourceDir(packageRoot) {
|
|
128
|
+
const inPkg = path.join(packageRoot, "skills");
|
|
129
|
+
if (existsSync(path.join(inPkg, "causoryn", "SKILL.md"))) {
|
|
130
|
+
return inPkg;
|
|
131
|
+
}
|
|
132
|
+
const repoCandidate = path.join(path.dirname(path.dirname(packageRoot)), "skills");
|
|
133
|
+
if (existsSync(path.join(repoCandidate, "causoryn", "SKILL.md"))) {
|
|
134
|
+
return repoCandidate;
|
|
135
|
+
}
|
|
136
|
+
return inPkg;
|
|
137
|
+
}
|
|
138
|
+
function buildMcpArgs(cliScriptPath, client) {
|
|
139
|
+
return [
|
|
140
|
+
cliScriptPath,
|
|
141
|
+
"mcp",
|
|
142
|
+
"--allow-cwd",
|
|
143
|
+
"--auto-data-dir",
|
|
144
|
+
"--client",
|
|
145
|
+
client,
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
function planMcpServersJsonFile(params) {
|
|
149
|
+
const { client, targetPath, cliScriptPath, uninstall, includeStdioType, actions, writes, projectedConfigs, } = params;
|
|
150
|
+
const existed = assertConfigAndBackupTargetsSafe(targetPath);
|
|
151
|
+
let doc = {};
|
|
152
|
+
if (existed) {
|
|
153
|
+
doc = parseJsonObjectStrict(readFileSync(targetPath, "utf8"), targetPath);
|
|
154
|
+
}
|
|
155
|
+
const existingServersRaw = doc["mcpServers"];
|
|
156
|
+
if (existingServersRaw !== undefined && !isPlainObject(existingServersRaw)) {
|
|
157
|
+
throw new CausorynCliError("cli/malformed-json", `"mcpServers" alanı bir JSON nesnesi olmalı (${targetPath})`);
|
|
158
|
+
}
|
|
159
|
+
const servers = existingServersRaw
|
|
160
|
+
? { ...existingServersRaw }
|
|
161
|
+
: {};
|
|
162
|
+
if (uninstall) {
|
|
163
|
+
if (!existed || !("causoryn" in servers)) {
|
|
164
|
+
actions.push({
|
|
165
|
+
client,
|
|
166
|
+
kind: "mcp-config",
|
|
167
|
+
operation: "noop",
|
|
168
|
+
targetPath,
|
|
169
|
+
backupPath: null,
|
|
170
|
+
detail: "causoryn MCP kaydı zaten mevcut değil",
|
|
171
|
+
});
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
delete servers["causoryn"];
|
|
175
|
+
const nextDoc = {
|
|
176
|
+
...doc,
|
|
177
|
+
mcpServers: servers,
|
|
178
|
+
};
|
|
179
|
+
const nextRaw = `${JSON.stringify(nextDoc, null, 2)}\n`;
|
|
180
|
+
writes.push({ targetPath, content: nextRaw, createBackup: true, defaultMode: 0o600 });
|
|
181
|
+
projectedConfigs.set(path.resolve(targetPath), nextRaw);
|
|
182
|
+
actions.push({
|
|
183
|
+
client,
|
|
184
|
+
kind: "mcp-config",
|
|
185
|
+
operation: "remove",
|
|
186
|
+
targetPath,
|
|
187
|
+
backupPath: `${targetPath}.causoryn.backup`,
|
|
188
|
+
detail: "mcpServers.causoryn kaldırıldı",
|
|
189
|
+
});
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const entry = {
|
|
193
|
+
...(includeStdioType ? { type: "stdio" } : {}),
|
|
194
|
+
command: "node",
|
|
195
|
+
args: buildMcpArgs(cliScriptPath, client),
|
|
196
|
+
};
|
|
197
|
+
servers["causoryn"] = entry;
|
|
198
|
+
const nextDoc = {
|
|
199
|
+
...doc,
|
|
200
|
+
mcpServers: servers,
|
|
201
|
+
};
|
|
202
|
+
const nextRaw = `${JSON.stringify(nextDoc, null, 2)}\n`;
|
|
203
|
+
writes.push({ targetPath, content: nextRaw, createBackup: existed, defaultMode: 0o600 });
|
|
204
|
+
projectedConfigs.set(path.resolve(targetPath), nextRaw);
|
|
205
|
+
actions.push({
|
|
206
|
+
client,
|
|
207
|
+
kind: "mcp-config",
|
|
208
|
+
operation: existed ? "update" : "create",
|
|
209
|
+
targetPath,
|
|
210
|
+
backupPath: existed ? `${targetPath}.causoryn.backup` : null,
|
|
211
|
+
detail: "mcpServers.causoryn yapılandırıldı",
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function planZcodeMcpConfig(params) {
|
|
215
|
+
const { homeDir, cliScriptPath, uninstall, actions, writes, projectedConfigs } = params;
|
|
216
|
+
const targetPath = path.join(homeDir, ".zcode", "cli", "config.json");
|
|
217
|
+
const fallbackPath = path.join(homeDir, ".agents", "mcp.json");
|
|
218
|
+
const existed = assertConfigAndBackupTargetsSafe(targetPath);
|
|
219
|
+
let doc = {};
|
|
220
|
+
if (existed) {
|
|
221
|
+
doc = parseJsonObjectStrict(readFileSync(targetPath, "utf8"), targetPath);
|
|
222
|
+
}
|
|
223
|
+
const mcpRaw = doc["mcp"];
|
|
224
|
+
if (mcpRaw !== undefined && !isPlainObject(mcpRaw)) {
|
|
225
|
+
throw new CausorynCliError("cli/malformed-json", `"mcp" alanı bir JSON nesnesi olmalı (${targetPath})`);
|
|
226
|
+
}
|
|
227
|
+
const mcpObj = mcpRaw ? { ...mcpRaw } : {};
|
|
228
|
+
const serversRaw = mcpObj["servers"];
|
|
229
|
+
if (serversRaw !== undefined && !isPlainObject(serversRaw)) {
|
|
230
|
+
throw new CausorynCliError("cli/malformed-json", `"mcp.servers" alanı bir JSON nesnesi olmalı (${targetPath})`);
|
|
231
|
+
}
|
|
232
|
+
const hadServersDefined = isPlainObject(serversRaw);
|
|
233
|
+
const servers = hadServersDefined ? { ...serversRaw } : {};
|
|
234
|
+
if (uninstall) {
|
|
235
|
+
if (!existed || !("causoryn" in servers)) {
|
|
236
|
+
actions.push({
|
|
237
|
+
client: "zcode",
|
|
238
|
+
kind: "mcp-config",
|
|
239
|
+
operation: "noop",
|
|
240
|
+
targetPath,
|
|
241
|
+
backupPath: null,
|
|
242
|
+
detail: "ZCode mcp.servers.causoryn kaydı mevcut değil",
|
|
243
|
+
});
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
delete servers["causoryn"];
|
|
247
|
+
let nextMcp;
|
|
248
|
+
if (Object.keys(servers).length === 0) {
|
|
249
|
+
delete mcpObj["servers"];
|
|
250
|
+
nextMcp = Object.keys(mcpObj).length > 0 ? mcpObj : undefined;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
nextMcp = { ...mcpObj, servers };
|
|
254
|
+
}
|
|
255
|
+
const nextDoc = { ...doc };
|
|
256
|
+
if (nextMcp === undefined) {
|
|
257
|
+
delete nextDoc["mcp"];
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
nextDoc["mcp"] = nextMcp;
|
|
261
|
+
}
|
|
262
|
+
const nextRaw = `${JSON.stringify(nextDoc, null, 2)}\n`;
|
|
263
|
+
writes.push({ targetPath, content: nextRaw, createBackup: true, defaultMode: 0o600 });
|
|
264
|
+
projectedConfigs.set(path.resolve(targetPath), nextRaw);
|
|
265
|
+
actions.push({
|
|
266
|
+
client: "zcode",
|
|
267
|
+
kind: "mcp-config",
|
|
268
|
+
operation: "remove",
|
|
269
|
+
targetPath,
|
|
270
|
+
backupPath: `${targetPath}.causoryn.backup`,
|
|
271
|
+
detail: "ZCode mcp.servers.causoryn kaldırıldı",
|
|
272
|
+
});
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
// ZCode fallback kuralı: mcp.servers ilk kez oluşturuluyorsa ~/.agents/mcp.json
|
|
276
|
+
// altındaki mevcut mcpServers kayıtlarını ezmeden taşı!
|
|
277
|
+
if (!hadServersDefined && existsSync(fallbackPath)) {
|
|
278
|
+
const fallbackDoc = parseJsonObjectStrict(readFileSync(fallbackPath, "utf8"), fallbackPath);
|
|
279
|
+
const fallbackServers = fallbackDoc["mcpServers"];
|
|
280
|
+
if (fallbackServers !== undefined && !isPlainObject(fallbackServers)) {
|
|
281
|
+
throw new CausorynCliError("cli/malformed-json", `"mcpServers" alanı bir JSON nesnesi olmalı (${fallbackPath})`);
|
|
282
|
+
}
|
|
283
|
+
if (isPlainObject(fallbackServers)) {
|
|
284
|
+
for (const [name, entry] of Object.entries(fallbackServers)) {
|
|
285
|
+
if (name === "causoryn")
|
|
286
|
+
continue;
|
|
287
|
+
if (isPlainObject(entry)) {
|
|
288
|
+
const normalized = typeof entry["command"] === "string" && entry["type"] === undefined
|
|
289
|
+
? { type: "stdio", ...entry }
|
|
290
|
+
: { ...entry };
|
|
291
|
+
servers[name] = normalized;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
servers[name] = entry;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
servers["causoryn"] = {
|
|
300
|
+
type: "stdio",
|
|
301
|
+
command: "node",
|
|
302
|
+
args: buildMcpArgs(cliScriptPath, "zcode"),
|
|
303
|
+
};
|
|
304
|
+
const nextDoc = {
|
|
305
|
+
...doc,
|
|
306
|
+
mcp: {
|
|
307
|
+
...mcpObj,
|
|
308
|
+
servers,
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
const nextRaw = `${JSON.stringify(nextDoc, null, 2)}\n`;
|
|
312
|
+
writes.push({ targetPath, content: nextRaw, createBackup: existed, defaultMode: 0o600 });
|
|
313
|
+
projectedConfigs.set(path.resolve(targetPath), nextRaw);
|
|
314
|
+
actions.push({
|
|
315
|
+
client: "zcode",
|
|
316
|
+
kind: "mcp-config",
|
|
317
|
+
operation: existed ? "update" : "create",
|
|
318
|
+
targetPath,
|
|
319
|
+
backupPath: existed ? `${targetPath}.causoryn.backup` : null,
|
|
320
|
+
detail: !hadServersDefined && existsSync(fallbackPath)
|
|
321
|
+
? "mcp.servers.causoryn yapılandırıldı (~/.agents/mcp.json fallback sunucuları korundu)"
|
|
322
|
+
: "mcp.servers.causoryn yapılandırıldı",
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
function planCodexMcpConfig(params) {
|
|
326
|
+
const { codexHomeDir, cliScriptPath, uninstall, actions, writes, projectedConfigs } = params;
|
|
327
|
+
const targetPath = path.join(codexHomeDir, "config.toml");
|
|
328
|
+
const existed = assertConfigAndBackupTargetsSafe(targetPath);
|
|
329
|
+
const existingRaw = existed ? readFileSync(targetPath, "utf8") : "";
|
|
330
|
+
if (uninstall) {
|
|
331
|
+
if (!existed) {
|
|
332
|
+
actions.push({
|
|
333
|
+
client: "codex",
|
|
334
|
+
kind: "mcp-config",
|
|
335
|
+
operation: "noop",
|
|
336
|
+
targetPath,
|
|
337
|
+
backupPath: null,
|
|
338
|
+
detail: "Codex config.toml mevcut değil",
|
|
339
|
+
});
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const removed = removeCodexMcpServer(existingRaw);
|
|
343
|
+
if (!removed.removed) {
|
|
344
|
+
actions.push({
|
|
345
|
+
client: "codex",
|
|
346
|
+
kind: "mcp-config",
|
|
347
|
+
operation: "noop",
|
|
348
|
+
targetPath,
|
|
349
|
+
backupPath: null,
|
|
350
|
+
detail: "[mcp_servers.causoryn] zaten mevcut değil",
|
|
351
|
+
});
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
writes.push({ targetPath, content: removed.content, createBackup: true, defaultMode: 0o600 });
|
|
355
|
+
projectedConfigs.set(path.resolve(targetPath), removed.content);
|
|
356
|
+
actions.push({
|
|
357
|
+
client: "codex",
|
|
358
|
+
kind: "mcp-config",
|
|
359
|
+
operation: "remove",
|
|
360
|
+
targetPath,
|
|
361
|
+
backupPath: `${targetPath}.causoryn.backup`,
|
|
362
|
+
detail: "[mcp_servers.causoryn] kaldırıldı",
|
|
363
|
+
});
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const updated = upsertCodexMcpServer(existingRaw, {
|
|
367
|
+
command: "node",
|
|
368
|
+
args: buildMcpArgs(cliScriptPath, "codex"),
|
|
369
|
+
startupTimeoutSec: 30,
|
|
370
|
+
});
|
|
371
|
+
writes.push({ targetPath, content: updated, createBackup: existed, defaultMode: 0o600 });
|
|
372
|
+
projectedConfigs.set(path.resolve(targetPath), updated);
|
|
373
|
+
actions.push({
|
|
374
|
+
client: "codex",
|
|
375
|
+
kind: "mcp-config",
|
|
376
|
+
operation: existed ? "update" : "create",
|
|
377
|
+
targetPath,
|
|
378
|
+
backupPath: existed ? `${targetPath}.causoryn.backup` : null,
|
|
379
|
+
detail: "[mcp_servers.causoryn] yapılandırıldı (startup_timeout_sec = 30)",
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function planSkillsForClient(params) {
|
|
383
|
+
const { homeDir, claudeConfigDir, client, skillsSourceDir, uninstall, actions, writes, removals } = params;
|
|
384
|
+
const hostSkillsRoot = getHostSkillsDir(homeDir, client, claudeConfigDir);
|
|
385
|
+
for (const skillName of CANONICAL_SKILL_NAMES) {
|
|
386
|
+
const destSkillDir = path.join(hostSkillsRoot, skillName);
|
|
387
|
+
const destSkillFile = path.join(destSkillDir, "SKILL.md");
|
|
388
|
+
if (uninstall) {
|
|
389
|
+
if (existsSync(destSkillDir)) {
|
|
390
|
+
removals.push({ targetPath: destSkillDir });
|
|
391
|
+
actions.push({
|
|
392
|
+
client,
|
|
393
|
+
kind: "skill",
|
|
394
|
+
operation: "remove",
|
|
395
|
+
targetPath: destSkillFile,
|
|
396
|
+
backupPath: null,
|
|
397
|
+
detail: `Skill kaldırıldı: ${skillName}`,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
const srcSkillFile = path.join(skillsSourceDir, skillName, "SKILL.md");
|
|
403
|
+
if (!existsSync(srcSkillFile) || !statSync(srcSkillFile).isFile()) {
|
|
404
|
+
throw new CausorynCliError("cli/io-error", `Kaynak skill dosyası bulunamadı: ${srcSkillFile}`);
|
|
405
|
+
}
|
|
406
|
+
const content = readFileSync(srcSkillFile, "utf8");
|
|
407
|
+
const existed = assertRegularOrAbsentTarget(destSkillFile);
|
|
408
|
+
writes.push({ targetPath: destSkillFile, content, createBackup: false, defaultMode: 0o644 });
|
|
409
|
+
actions.push({
|
|
410
|
+
client,
|
|
411
|
+
kind: "skill",
|
|
412
|
+
operation: existed ? "update" : "create",
|
|
413
|
+
targetPath: destSkillFile,
|
|
414
|
+
backupPath: null,
|
|
415
|
+
detail: `Skill kuruldu: ${skillName}`,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function normalizePathSlashes(value) {
|
|
420
|
+
const normalized = value.replace(/[\\/]+/g, "/");
|
|
421
|
+
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
422
|
+
}
|
|
423
|
+
function jsonContainsMarker(node, marker) {
|
|
424
|
+
if (typeof node === "string") {
|
|
425
|
+
return normalizePathSlashes(node).includes(marker);
|
|
426
|
+
}
|
|
427
|
+
if (Array.isArray(node)) {
|
|
428
|
+
return node.some((item) => jsonContainsMarker(item, marker));
|
|
429
|
+
}
|
|
430
|
+
if (isPlainObject(node)) {
|
|
431
|
+
return Object.values(node).some((val) => jsonContainsMarker(val, marker));
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
function anyRemainingHostReferencesRuntime(params) {
|
|
436
|
+
const { homeDir, codexHomeDir, claudeConfigDir, runtimeDir, projectedConfigs } = params;
|
|
437
|
+
const runtimeMarker = normalizePathSlashes(path.resolve(runtimeDir));
|
|
438
|
+
const readEffective = (filePath) => {
|
|
439
|
+
const resolved = path.resolve(filePath);
|
|
440
|
+
if (projectedConfigs.has(resolved)) {
|
|
441
|
+
return projectedConfigs.get(resolved) ?? null;
|
|
442
|
+
}
|
|
443
|
+
if (!existsSync(resolved))
|
|
444
|
+
return null;
|
|
445
|
+
try {
|
|
446
|
+
return readFileSync(resolved, "utf8");
|
|
447
|
+
}
|
|
448
|
+
catch {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const jsonFiles = [
|
|
453
|
+
path.join(homeDir, ".gemini", "config", "mcp_config.json"),
|
|
454
|
+
path.join(homeDir, ".gemini", "antigravity", "mcp_config.json"),
|
|
455
|
+
getClaudeConfigFilePath(homeDir, claudeConfigDir),
|
|
456
|
+
path.join(homeDir, ".zcode", "cli", "config.json"),
|
|
457
|
+
];
|
|
458
|
+
for (const jsonPath of jsonFiles) {
|
|
459
|
+
const raw = readEffective(jsonPath);
|
|
460
|
+
if (raw === null)
|
|
461
|
+
continue;
|
|
462
|
+
try {
|
|
463
|
+
const parsed = JSON.parse(raw);
|
|
464
|
+
if (jsonContainsMarker(parsed, runtimeMarker)) {
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
if (normalizePathSlashes(raw).includes(runtimeMarker)) {
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const codexTomlRaw = readEffective(path.join(codexHomeDir, "config.toml"));
|
|
475
|
+
if (codexTomlRaw !== null) {
|
|
476
|
+
try {
|
|
477
|
+
const parsed = readCodexMcpServer(codexTomlRaw);
|
|
478
|
+
if (parsed !== null) {
|
|
479
|
+
const joined = [parsed.command, ...parsed.args].map(normalizePathSlashes).join(" ");
|
|
480
|
+
if (joined.includes(runtimeMarker))
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
catch {
|
|
485
|
+
if (normalizePathSlashes(codexTomlRaw).includes(runtimeMarker))
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
function writeFileAtomicWithBackup(instruction) {
|
|
492
|
+
const { targetPath, content, createBackup, defaultMode = 0o600 } = instruction;
|
|
493
|
+
const parentDir = path.dirname(targetPath);
|
|
494
|
+
mkdirSync(parentDir, { recursive: true });
|
|
495
|
+
const existed = assertRegularOrAbsentTarget(targetPath);
|
|
496
|
+
const effectiveMode = existed ? (statSync(targetPath).mode & 0o777) || defaultMode : defaultMode;
|
|
497
|
+
const suffix = `${String(process.pid)}-${String(Date.now())}`;
|
|
498
|
+
if (createBackup && existed) {
|
|
499
|
+
const backupPath = `${targetPath}.causoryn.backup`;
|
|
500
|
+
assertRegularOrAbsentTarget(backupPath);
|
|
501
|
+
const originalBytes = readFileSync(targetPath);
|
|
502
|
+
const backupTmp = `${backupPath}.${suffix}.tmp`;
|
|
503
|
+
writeFileSync(backupTmp, originalBytes, { mode: effectiveMode });
|
|
504
|
+
if (process.platform !== "win32") {
|
|
505
|
+
chmodSync(backupTmp, effectiveMode);
|
|
506
|
+
}
|
|
507
|
+
renameSync(backupTmp, backupPath);
|
|
508
|
+
}
|
|
509
|
+
const tmpPath = `${targetPath}.causoryn.${suffix}.tmp`;
|
|
510
|
+
writeFileSync(tmpPath, content, { encoding: "utf8", mode: effectiveMode });
|
|
511
|
+
if (process.platform !== "win32") {
|
|
512
|
+
chmodSync(tmpPath, effectiveMode);
|
|
513
|
+
}
|
|
514
|
+
renameSync(tmpPath, targetPath);
|
|
515
|
+
}
|
|
516
|
+
function buildExecutionPlan(options) {
|
|
517
|
+
const effectiveEnv = options.env ?? process.env;
|
|
518
|
+
const explicitHomeProvided = options.homeDir !== undefined;
|
|
519
|
+
const homeDir = resolveEffectiveHomeDir(options.homeDir);
|
|
520
|
+
const codexHomeDir = resolveEffectiveCodexHomeDir(homeDir, options.codexHomeDir, explicitHomeProvided, effectiveEnv);
|
|
521
|
+
const claudeConfigDir = resolveEffectiveClaudeConfigDir(options.claudeConfigDir, explicitHomeProvided, effectiveEnv);
|
|
522
|
+
const packageRoot = path.resolve(options.packageRoot ?? resolveDefaultPackageRoot());
|
|
523
|
+
const uninstall = options.uninstall === true;
|
|
524
|
+
const installSkills = options.installSkills ?? true;
|
|
525
|
+
let selectedClients;
|
|
526
|
+
if (options.clients !== undefined && options.clients.length > 0) {
|
|
527
|
+
selectedClients = [...new Set(options.clients)];
|
|
528
|
+
}
|
|
529
|
+
else if (options.allDetected === true) {
|
|
530
|
+
selectedClients = detectInstalledClients(homeDir, codexHomeDir, claudeConfigDir);
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
const detected = detectInstalledClients(homeDir, codexHomeDir, claudeConfigDir);
|
|
534
|
+
selectedClients = detected.length > 0 ? detected : [...HOST_CLIENT_IDS];
|
|
535
|
+
}
|
|
536
|
+
const targetRuntimeDir = getPersistentRuntimeDir(homeDir);
|
|
537
|
+
const needsRuntimeStage = !uninstall &&
|
|
538
|
+
selectedClients.length > 0 &&
|
|
539
|
+
!isSameRuntimeDir(packageRoot, targetRuntimeDir) &&
|
|
540
|
+
isEphemeralRuntimeDir(packageRoot, { tmpDir: options.ephemeralTmpDir });
|
|
541
|
+
const effectiveRuntimePkg = needsRuntimeStage ? targetRuntimeDir : packageRoot;
|
|
542
|
+
const cliScriptPath = path.join(effectiveRuntimePkg, "scripts", "causoryn.mjs");
|
|
543
|
+
const skillsSourceDir = resolveSkillsSourceDir(packageRoot);
|
|
544
|
+
const actions = [];
|
|
545
|
+
const writes = [];
|
|
546
|
+
const removals = [];
|
|
547
|
+
const projectedConfigs = new Map();
|
|
548
|
+
for (const client of selectedClients) {
|
|
549
|
+
switch (client) {
|
|
550
|
+
case "antigravity": {
|
|
551
|
+
const primaryPath = path.join(homeDir, ".gemini", "config", "mcp_config.json");
|
|
552
|
+
planMcpServersJsonFile({
|
|
553
|
+
client: "antigravity",
|
|
554
|
+
targetPath: primaryPath,
|
|
555
|
+
cliScriptPath,
|
|
556
|
+
uninstall,
|
|
557
|
+
includeStdioType: false,
|
|
558
|
+
actions,
|
|
559
|
+
writes,
|
|
560
|
+
projectedConfigs,
|
|
561
|
+
});
|
|
562
|
+
const secondaryPath = path.join(homeDir, ".gemini", "antigravity", "mcp_config.json");
|
|
563
|
+
let secondaryPresent = false;
|
|
564
|
+
try {
|
|
565
|
+
lstatSync(secondaryPath);
|
|
566
|
+
secondaryPresent = true;
|
|
567
|
+
}
|
|
568
|
+
catch (err) {
|
|
569
|
+
if (err.code !== "ENOENT") {
|
|
570
|
+
throw new CausorynCliError("cli/io-error", `Hedef dosya durumu okunamadı (${secondaryPath}): ${err instanceof Error ? err.message : String(err)}`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (secondaryPresent) {
|
|
574
|
+
planMcpServersJsonFile({
|
|
575
|
+
client: "antigravity",
|
|
576
|
+
targetPath: secondaryPath,
|
|
577
|
+
cliScriptPath,
|
|
578
|
+
uninstall,
|
|
579
|
+
includeStdioType: false,
|
|
580
|
+
actions,
|
|
581
|
+
writes,
|
|
582
|
+
projectedConfigs,
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
case "claude-code": {
|
|
588
|
+
planMcpServersJsonFile({
|
|
589
|
+
client: "claude-code",
|
|
590
|
+
targetPath: getClaudeConfigFilePath(homeDir, claudeConfigDir),
|
|
591
|
+
cliScriptPath,
|
|
592
|
+
uninstall,
|
|
593
|
+
includeStdioType: true,
|
|
594
|
+
actions,
|
|
595
|
+
writes,
|
|
596
|
+
projectedConfigs,
|
|
597
|
+
});
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
case "codex": {
|
|
601
|
+
planCodexMcpConfig({
|
|
602
|
+
codexHomeDir,
|
|
603
|
+
cliScriptPath,
|
|
604
|
+
uninstall,
|
|
605
|
+
actions,
|
|
606
|
+
writes,
|
|
607
|
+
projectedConfigs,
|
|
608
|
+
});
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
case "zcode": {
|
|
612
|
+
planZcodeMcpConfig({
|
|
613
|
+
homeDir,
|
|
614
|
+
cliScriptPath,
|
|
615
|
+
uninstall,
|
|
616
|
+
actions,
|
|
617
|
+
writes,
|
|
618
|
+
projectedConfigs,
|
|
619
|
+
});
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (installSkills) {
|
|
624
|
+
planSkillsForClient({
|
|
625
|
+
homeDir,
|
|
626
|
+
claudeConfigDir,
|
|
627
|
+
client,
|
|
628
|
+
skillsSourceDir,
|
|
629
|
+
uninstall,
|
|
630
|
+
actions,
|
|
631
|
+
writes,
|
|
632
|
+
removals,
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
homeDir,
|
|
638
|
+
codexHomeDir,
|
|
639
|
+
claudeConfigDir,
|
|
640
|
+
packageRoot,
|
|
641
|
+
plan: {
|
|
642
|
+
selectedClients,
|
|
643
|
+
needsRuntimeStage,
|
|
644
|
+
targetRuntimeDir,
|
|
645
|
+
actions,
|
|
646
|
+
writes,
|
|
647
|
+
removals,
|
|
648
|
+
projectedConfigs,
|
|
649
|
+
},
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
export async function runSetup(options = {}) {
|
|
653
|
+
const dryRun = options.dryRun === true;
|
|
654
|
+
const uninstall = options.uninstall === true;
|
|
655
|
+
const { homeDir, codexHomeDir, claudeConfigDir, packageRoot, plan } = buildExecutionPlan(options);
|
|
656
|
+
if (dryRun) {
|
|
657
|
+
return {
|
|
658
|
+
dryRun: true,
|
|
659
|
+
applied: false,
|
|
660
|
+
uninstall,
|
|
661
|
+
selectedClients: plan.selectedClients,
|
|
662
|
+
stagedRuntimeDir: plan.needsRuntimeStage ? plan.targetRuntimeDir : null,
|
|
663
|
+
runtimeCleanedUp: false,
|
|
664
|
+
actions: plan.actions,
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
const hasMutations = plan.needsRuntimeStage || plan.writes.length > 0 || plan.removals.length > 0;
|
|
668
|
+
if (!hasMutations) {
|
|
669
|
+
return {
|
|
670
|
+
dryRun: false,
|
|
671
|
+
applied: false,
|
|
672
|
+
uninstall,
|
|
673
|
+
selectedClients: plan.selectedClients,
|
|
674
|
+
stagedRuntimeDir: null,
|
|
675
|
+
runtimeCleanedUp: false,
|
|
676
|
+
actions: plan.actions,
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const autoApprove = options.yes ?? true;
|
|
680
|
+
if (!autoApprove) {
|
|
681
|
+
if (options.confirm === undefined) {
|
|
682
|
+
throw new CausorynCliError("cli/confirmation-required", "Kurulum onayı gerekli: değişiklikleri uygulamak için `--yes` veya önizlemek için `--dry-run` kullanın.");
|
|
683
|
+
}
|
|
684
|
+
const approved = await options.confirm(plan.actions);
|
|
685
|
+
if (!approved) {
|
|
686
|
+
return {
|
|
687
|
+
dryRun: false,
|
|
688
|
+
applied: false,
|
|
689
|
+
uninstall,
|
|
690
|
+
selectedClients: plan.selectedClients,
|
|
691
|
+
stagedRuntimeDir: null,
|
|
692
|
+
runtimeCleanedUp: false,
|
|
693
|
+
actions: plan.actions,
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
let stagedRuntimeDir = null;
|
|
698
|
+
if (plan.needsRuntimeStage) {
|
|
699
|
+
const staged = stagePersistentRuntime({
|
|
700
|
+
homeDir,
|
|
701
|
+
sourcePackageDir: packageRoot,
|
|
702
|
+
});
|
|
703
|
+
stagedRuntimeDir = staged.runtimeDir;
|
|
704
|
+
}
|
|
705
|
+
for (const writeOp of plan.writes) {
|
|
706
|
+
writeFileAtomicWithBackup(writeOp);
|
|
707
|
+
}
|
|
708
|
+
for (const removeOp of plan.removals) {
|
|
709
|
+
rmSync(removeOp.targetPath, { recursive: true, force: true });
|
|
710
|
+
}
|
|
711
|
+
let runtimeCleanedUp = false;
|
|
712
|
+
if (uninstall && existsSync(plan.targetRuntimeDir)) {
|
|
713
|
+
const stillReferenced = anyRemainingHostReferencesRuntime({
|
|
714
|
+
homeDir,
|
|
715
|
+
codexHomeDir,
|
|
716
|
+
claudeConfigDir,
|
|
717
|
+
runtimeDir: plan.targetRuntimeDir,
|
|
718
|
+
projectedConfigs: plan.projectedConfigs,
|
|
719
|
+
});
|
|
720
|
+
if (!stillReferenced) {
|
|
721
|
+
rmSync(plan.targetRuntimeDir, { recursive: true, force: true });
|
|
722
|
+
runtimeCleanedUp = true;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return {
|
|
726
|
+
dryRun: false,
|
|
727
|
+
applied: true,
|
|
728
|
+
uninstall,
|
|
729
|
+
selectedClients: plan.selectedClients,
|
|
730
|
+
stagedRuntimeDir,
|
|
731
|
+
runtimeCleanedUp,
|
|
732
|
+
actions: plan.actions,
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
//# sourceMappingURL=setup.js.map
|