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.
Files changed (197) hide show
  1. package/.claude-plugin/plugin.json +36 -0
  2. package/.codex-plugin/mcp.json +19 -0
  3. package/.codex-plugin/plugin.json +38 -0
  4. package/.zcode-plugin/plugin.json +42 -0
  5. package/LICENSE +21 -0
  6. package/README.md +171 -2
  7. package/THIRD-PARTY-NOTICES.md +443 -0
  8. package/dist/bundle-manifest.json +39 -0
  9. package/dist/cli.d.ts +3 -0
  10. package/dist/cli.js +253 -0
  11. package/dist/doctor.d.ts +13 -0
  12. package/dist/doctor.js +507 -0
  13. package/dist/index.d.ts +10 -0
  14. package/dist/index.js +10 -0
  15. package/dist/mcp-server.mjs +288477 -0
  16. package/dist/mcp-server.mjs.LEGAL.txt +17 -0
  17. package/dist/node_modules/better-sqlite3/LICENSE +21 -0
  18. package/dist/node_modules/better-sqlite3/lib/binding.js +62 -0
  19. package/dist/node_modules/better-sqlite3/lib/darwin-arm64.js +3 -0
  20. package/dist/node_modules/better-sqlite3/lib/darwin-x64.js +3 -0
  21. package/dist/node_modules/better-sqlite3/lib/database.js +109 -0
  22. package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
  23. package/dist/node_modules/better-sqlite3/lib/linux-arm64.js +3 -0
  24. package/dist/node_modules/better-sqlite3/lib/linux-x64.js +3 -0
  25. package/dist/node_modules/better-sqlite3/lib/linuxmusl-arm64.js +4 -0
  26. package/dist/node_modules/better-sqlite3/lib/linuxmusl-x64.js +4 -0
  27. package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
  28. package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
  29. package/dist/node_modules/better-sqlite3/lib/methods/explain.js +9 -0
  30. package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
  31. package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
  32. package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
  33. package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
  34. package/dist/node_modules/better-sqlite3/lib/methods/table.js +195 -0
  35. package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
  36. package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
  37. package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +25 -0
  38. package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
  39. package/dist/node_modules/better-sqlite3/lib/win32-arm64.js +3 -0
  40. package/dist/node_modules/better-sqlite3/lib/win32-x64.js +3 -0
  41. package/dist/node_modules/better-sqlite3/package.json +67 -0
  42. package/dist/node_modules/better-sqlite3/prebuilds/darwin-arm64.node +0 -0
  43. package/dist/node_modules/better-sqlite3/prebuilds/darwin-x64.node +0 -0
  44. package/dist/node_modules/better-sqlite3/prebuilds/linux-arm64.node +0 -0
  45. package/dist/node_modules/better-sqlite3/prebuilds/linux-x64.node +0 -0
  46. package/dist/node_modules/better-sqlite3/prebuilds/linuxmusl-arm64.node +0 -0
  47. package/dist/node_modules/better-sqlite3/prebuilds/linuxmusl-x64.node +0 -0
  48. package/dist/node_modules/better-sqlite3/prebuilds/win32-arm64.node +0 -0
  49. package/dist/node_modules/better-sqlite3/prebuilds/win32-x64.node +0 -0
  50. package/dist/runtime-stage.d.ts +8 -0
  51. package/dist/runtime-stage.js +159 -0
  52. package/dist/setup.d.ts +15 -0
  53. package/dist/setup.js +735 -0
  54. package/dist/toml-patch.d.ts +10 -0
  55. package/dist/toml-patch.js +587 -0
  56. package/dist/types.d.ts +144 -0
  57. package/dist/types.js +35 -0
  58. package/dist/typescript-lib/lib.d.ts +22 -0
  59. package/dist/typescript-lib/lib.decorators.d.ts +384 -0
  60. package/dist/typescript-lib/lib.decorators.legacy.d.ts +22 -0
  61. package/dist/typescript-lib/lib.dom.asynciterable.d.ts +41 -0
  62. package/dist/typescript-lib/lib.dom.d.ts +39429 -0
  63. package/dist/typescript-lib/lib.dom.iterable.d.ts +571 -0
  64. package/dist/typescript-lib/lib.es2015.collection.d.ts +147 -0
  65. package/dist/typescript-lib/lib.es2015.core.d.ts +597 -0
  66. package/dist/typescript-lib/lib.es2015.d.ts +28 -0
  67. package/dist/typescript-lib/lib.es2015.generator.d.ts +77 -0
  68. package/dist/typescript-lib/lib.es2015.iterable.d.ts +605 -0
  69. package/dist/typescript-lib/lib.es2015.promise.d.ts +81 -0
  70. package/dist/typescript-lib/lib.es2015.proxy.d.ts +128 -0
  71. package/dist/typescript-lib/lib.es2015.reflect.d.ts +144 -0
  72. package/dist/typescript-lib/lib.es2015.symbol.d.ts +46 -0
  73. package/dist/typescript-lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  74. package/dist/typescript-lib/lib.es2016.array.include.d.ts +116 -0
  75. package/dist/typescript-lib/lib.es2016.d.ts +21 -0
  76. package/dist/typescript-lib/lib.es2016.full.d.ts +23 -0
  77. package/dist/typescript-lib/lib.es2016.intl.d.ts +31 -0
  78. package/dist/typescript-lib/lib.es2017.arraybuffer.d.ts +21 -0
  79. package/dist/typescript-lib/lib.es2017.d.ts +26 -0
  80. package/dist/typescript-lib/lib.es2017.date.d.ts +31 -0
  81. package/dist/typescript-lib/lib.es2017.full.d.ts +23 -0
  82. package/dist/typescript-lib/lib.es2017.intl.d.ts +44 -0
  83. package/dist/typescript-lib/lib.es2017.object.d.ts +49 -0
  84. package/dist/typescript-lib/lib.es2017.sharedmemory.d.ts +135 -0
  85. package/dist/typescript-lib/lib.es2017.string.d.ts +45 -0
  86. package/dist/typescript-lib/lib.es2017.typedarrays.d.ts +53 -0
  87. package/dist/typescript-lib/lib.es2018.asyncgenerator.d.ts +77 -0
  88. package/dist/typescript-lib/lib.es2018.asynciterable.d.ts +53 -0
  89. package/dist/typescript-lib/lib.es2018.d.ts +24 -0
  90. package/dist/typescript-lib/lib.es2018.full.d.ts +24 -0
  91. package/dist/typescript-lib/lib.es2018.intl.d.ts +83 -0
  92. package/dist/typescript-lib/lib.es2018.promise.d.ts +30 -0
  93. package/dist/typescript-lib/lib.es2018.regexp.d.ts +37 -0
  94. package/dist/typescript-lib/lib.es2019.array.d.ts +79 -0
  95. package/dist/typescript-lib/lib.es2019.d.ts +24 -0
  96. package/dist/typescript-lib/lib.es2019.full.d.ts +24 -0
  97. package/dist/typescript-lib/lib.es2019.intl.d.ts +23 -0
  98. package/dist/typescript-lib/lib.es2019.object.d.ts +33 -0
  99. package/dist/typescript-lib/lib.es2019.string.d.ts +37 -0
  100. package/dist/typescript-lib/lib.es2019.symbol.d.ts +24 -0
  101. package/dist/typescript-lib/lib.es2020.bigint.d.ts +765 -0
  102. package/dist/typescript-lib/lib.es2020.d.ts +27 -0
  103. package/dist/typescript-lib/lib.es2020.date.d.ts +42 -0
  104. package/dist/typescript-lib/lib.es2020.full.d.ts +24 -0
  105. package/dist/typescript-lib/lib.es2020.intl.d.ts +474 -0
  106. package/dist/typescript-lib/lib.es2020.number.d.ts +28 -0
  107. package/dist/typescript-lib/lib.es2020.promise.d.ts +47 -0
  108. package/dist/typescript-lib/lib.es2020.sharedmemory.d.ts +99 -0
  109. package/dist/typescript-lib/lib.es2020.string.d.ts +44 -0
  110. package/dist/typescript-lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  111. package/dist/typescript-lib/lib.es2021.d.ts +23 -0
  112. package/dist/typescript-lib/lib.es2021.full.d.ts +24 -0
  113. package/dist/typescript-lib/lib.es2021.intl.d.ts +166 -0
  114. package/dist/typescript-lib/lib.es2021.promise.d.ts +48 -0
  115. package/dist/typescript-lib/lib.es2021.string.d.ts +33 -0
  116. package/dist/typescript-lib/lib.es2021.weakref.d.ts +78 -0
  117. package/dist/typescript-lib/lib.es2022.array.d.ts +121 -0
  118. package/dist/typescript-lib/lib.es2022.d.ts +25 -0
  119. package/dist/typescript-lib/lib.es2022.error.d.ts +75 -0
  120. package/dist/typescript-lib/lib.es2022.full.d.ts +24 -0
  121. package/dist/typescript-lib/lib.es2022.intl.d.ts +145 -0
  122. package/dist/typescript-lib/lib.es2022.object.d.ts +26 -0
  123. package/dist/typescript-lib/lib.es2022.regexp.d.ts +39 -0
  124. package/dist/typescript-lib/lib.es2022.string.d.ts +25 -0
  125. package/dist/typescript-lib/lib.es2023.array.d.ts +924 -0
  126. package/dist/typescript-lib/lib.es2023.collection.d.ts +21 -0
  127. package/dist/typescript-lib/lib.es2023.d.ts +22 -0
  128. package/dist/typescript-lib/lib.es2023.full.d.ts +24 -0
  129. package/dist/typescript-lib/lib.es2023.intl.d.ts +56 -0
  130. package/dist/typescript-lib/lib.es2024.arraybuffer.d.ts +65 -0
  131. package/dist/typescript-lib/lib.es2024.collection.d.ts +29 -0
  132. package/dist/typescript-lib/lib.es2024.d.ts +26 -0
  133. package/dist/typescript-lib/lib.es2024.full.d.ts +24 -0
  134. package/dist/typescript-lib/lib.es2024.object.d.ts +29 -0
  135. package/dist/typescript-lib/lib.es2024.promise.d.ts +35 -0
  136. package/dist/typescript-lib/lib.es2024.regexp.d.ts +25 -0
  137. package/dist/typescript-lib/lib.es2024.sharedmemory.d.ts +68 -0
  138. package/dist/typescript-lib/lib.es2024.string.d.ts +29 -0
  139. package/dist/typescript-lib/lib.es5.d.ts +4601 -0
  140. package/dist/typescript-lib/lib.es6.d.ts +23 -0
  141. package/dist/typescript-lib/lib.esnext.array.d.ts +35 -0
  142. package/dist/typescript-lib/lib.esnext.collection.d.ts +96 -0
  143. package/dist/typescript-lib/lib.esnext.d.ts +29 -0
  144. package/dist/typescript-lib/lib.esnext.decorators.d.ts +28 -0
  145. package/dist/typescript-lib/lib.esnext.disposable.d.ts +193 -0
  146. package/dist/typescript-lib/lib.esnext.error.d.ts +24 -0
  147. package/dist/typescript-lib/lib.esnext.float16.d.ts +445 -0
  148. package/dist/typescript-lib/lib.esnext.full.d.ts +24 -0
  149. package/dist/typescript-lib/lib.esnext.intl.d.ts +21 -0
  150. package/dist/typescript-lib/lib.esnext.iterator.d.ts +148 -0
  151. package/dist/typescript-lib/lib.esnext.promise.d.ts +34 -0
  152. package/dist/typescript-lib/lib.esnext.sharedmemory.d.ts +25 -0
  153. package/dist/typescript-lib/lib.scripthost.d.ts +322 -0
  154. package/dist/typescript-lib/lib.webworker.asynciterable.d.ts +41 -0
  155. package/dist/typescript-lib/lib.webworker.d.ts +13150 -0
  156. package/dist/typescript-lib/lib.webworker.importscripts.d.ts +23 -0
  157. package/dist/typescript-lib/lib.webworker.iterable.d.ts +340 -0
  158. package/licenses/Apache-2.0.txt +55 -0
  159. package/licenses/TypeScript-ThirdPartyNoticeText.txt +193 -0
  160. package/licenses/better-sqlite3-LICENSE.txt +21 -0
  161. package/mcp_config.json +16 -0
  162. package/native/go-worker/PROTOCOL.md +316 -0
  163. package/native/go-worker/cmd/worker/main.go +440 -0
  164. package/native/go-worker/go.mod +3 -0
  165. package/native/go-worker/internal/analyze/analyze.go +820 -0
  166. package/native/go-worker/internal/analyze/model.go +182 -0
  167. package/native/go-worker/internal/analyze/routes.go +181 -0
  168. package/native/python-worker/PROTOCOL.md +342 -0
  169. package/native/python-worker/worker.py +1190 -0
  170. package/native/roslyn-worker/Causoryn.RoslynWorker.csproj +40 -0
  171. package/native/roslyn-worker/Causoryn.RoslynWorker.deps.json +59 -0
  172. package/native/roslyn-worker/Causoryn.RoslynWorker.dll +0 -0
  173. package/native/roslyn-worker/Causoryn.RoslynWorker.runtimeconfig.json +13 -0
  174. package/native/roslyn-worker/Microsoft.CodeAnalysis.CSharp.dll +0 -0
  175. package/native/roslyn-worker/Microsoft.CodeAnalysis.dll +0 -0
  176. package/native/roslyn-worker/PROTOCOL.md +285 -0
  177. package/native/roslyn-worker/Program.cs +249 -0
  178. package/native/roslyn-worker/Protocol.cs +397 -0
  179. package/native/roslyn-worker/ReferenceResolver.cs +235 -0
  180. package/native/roslyn-worker/WorkerAnalyzer.cs +1669 -0
  181. package/native/roslyn-worker/packages.lock.json +30 -0
  182. package/native/rust-worker/Cargo.lock +107 -0
  183. package/native/rust-worker/Cargo.toml +23 -0
  184. package/native/rust-worker/PROTOCOL.md +294 -0
  185. package/native/rust-worker/src/analyzer.rs +1209 -0
  186. package/native/rust-worker/src/main.rs +127 -0
  187. package/native/rust-worker/src/protocol.rs +284 -0
  188. package/native/rust-worker/src/sha256.rs +136 -0
  189. package/package.json +71 -4
  190. package/plugin.json +17 -0
  191. package/scripts/causoryn.mjs +40 -0
  192. package/scripts/lib/node-version-guard.mjs +24 -0
  193. package/scripts/plugin-mcp-launcher.mjs +111 -0
  194. package/skills/causoryn/SKILL.md +53 -0
  195. package/skills/map-system/SKILL.md +69 -0
  196. package/skills/preflight-change/SKILL.md +38 -0
  197. package/skills/verify-change/SKILL.md +31 -0
package/dist/doctor.js ADDED
@@ -0,0 +1,507 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { existsSync, readFileSync, statSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { getPersistentRuntimeDir } from "./runtime-stage.js";
5
+ import { detectInstalledClients, getClaudeConfigFilePath, getHostSkillsDir, resolveDefaultPackageRoot, resolveEffectiveClaudeConfigDir, resolveEffectiveCodexHomeDir, resolveEffectiveHomeDir, } from "./setup.js";
6
+ import { readCodexMcpServer, validateTomlStructure } from "./toml-patch.js";
7
+ import { CANONICAL_SKILL_NAMES, CAUSORYN_PACKAGE_VERSION, HOST_CLIENT_IDS, SIDECAR_TOOLCHAIN_IDS, } from "./types.js";
8
+ /**
9
+ * Salt-okunur sağlık ve hizalama denetçisi (`causoryn doctor`, K-021).
10
+ *
11
+ * Kırmızı çizgi: Bu modül HİÇBİR dosya veya dizin oluşturmaz, değiştirmez
12
+ * veya silmez; tüm kontroller salt okunurdur.
13
+ */
14
+ const SIDECAR_PROBE_TIMEOUT_MS = 5_000;
15
+ const REQUIRED_NODE_MAJOR = 24;
16
+ export const DOCTOR_PROBE_ENV_ALLOWLIST = [
17
+ "PATH",
18
+ "SystemRoot",
19
+ "COMSPEC",
20
+ "TEMP",
21
+ "TMP",
22
+ "USERPROFILE",
23
+ "HOME",
24
+ "APPDATA",
25
+ "LOCALAPPDATA",
26
+ "DOTNET_ROOT",
27
+ "DOTNET_CLI_HOME",
28
+ "GOPATH",
29
+ "GOROOT",
30
+ "GOCACHE",
31
+ "GOMODCACHE",
32
+ "GOENV",
33
+ "CARGO_HOME",
34
+ "RUSTUP_HOME",
35
+ ];
36
+ export function buildDoctorProbeEnv(sourceEnv = process.env) {
37
+ const env = {};
38
+ for (const key of DOCTOR_PROBE_ENV_ALLOWLIST) {
39
+ const val = sourceEnv[key];
40
+ if (val !== undefined && val.length > 0) {
41
+ env[key] = val;
42
+ }
43
+ }
44
+ env["PYTHONIOENCODING"] = "utf-8";
45
+ return env;
46
+ }
47
+ function defaultToolchainProbe(command, args, timeoutMs) {
48
+ const probeEnv = buildDoctorProbeEnv();
49
+ const runOnce = (cmd) => {
50
+ const res = spawnSync(cmd, [...args], {
51
+ shell: false,
52
+ timeout: timeoutMs,
53
+ windowsHide: true,
54
+ encoding: "utf8",
55
+ env: probeEnv,
56
+ stdio: ["ignore", "pipe", "pipe"],
57
+ });
58
+ if (res.error !== undefined) {
59
+ const code = res.error.code ?? res.error.message;
60
+ return {
61
+ available: false,
62
+ version: null,
63
+ detail: String(code),
64
+ };
65
+ }
66
+ if (res.status !== 0) {
67
+ const stderrLine = (res.stderr ?? "").trim().split(/\r?\n/)[0] ?? "";
68
+ return {
69
+ available: false,
70
+ version: null,
71
+ detail: stderrLine.length > 0 ? stderrLine : `exit ${String(res.status)}`,
72
+ };
73
+ }
74
+ const combined = `${res.stdout ?? ""}\n${res.stderr ?? ""}`
75
+ .split(/\r?\n/)
76
+ .map((line) => line.trim())
77
+ .find((line) => line.length > 0);
78
+ return {
79
+ available: true,
80
+ version: combined ?? cmd,
81
+ detail: "ok",
82
+ };
83
+ };
84
+ const primary = runOnce(command);
85
+ if (!primary.available && command === "python" && process.platform !== "win32") {
86
+ const py3 = runOnce("python3");
87
+ if (py3.available)
88
+ return py3;
89
+ }
90
+ return primary;
91
+ }
92
+ function checkNodeVersion(rawNodeVersion) {
93
+ const cleaned = rawNodeVersion.trim().replace(/^v/i, "");
94
+ const majorStr = cleaned.split(".")[0] ?? "0";
95
+ const major = Number.parseInt(majorStr, 10);
96
+ const ok = Number.isFinite(major) && major >= REQUIRED_NODE_MAJOR;
97
+ return {
98
+ ok,
99
+ version: cleaned,
100
+ requiredMajor: REQUIRED_NODE_MAJOR,
101
+ detail: ok
102
+ ? `Node.js ${cleaned} (>= ${String(REQUIRED_NODE_MAJOR)})`
103
+ : `Node.js ${cleaned} desteklenmiyor; Node.js >= ${String(REQUIRED_NODE_MAJOR)} gerekli`,
104
+ };
105
+ }
106
+ export function isLinuxMusl(platform = process.platform, getReport = () => process.report?.getReport?.()) {
107
+ if (platform !== "linux") {
108
+ return false;
109
+ }
110
+ try {
111
+ const report = getReport();
112
+ if (isPlainObject(report) && isPlainObject(report["header"])) {
113
+ const glibc = report["header"]["glibcVersionRuntime"];
114
+ return typeof glibc !== "string" || glibc.trim().length === 0;
115
+ }
116
+ return false;
117
+ }
118
+ catch {
119
+ return false;
120
+ }
121
+ }
122
+ function resolveCompiledRoslynDllExists(pkgRoot) {
123
+ const candidates = [
124
+ path.join(pkgRoot, "native", "roslyn-worker", "Causoryn.RoslynWorker.dll"),
125
+ path.join(pkgRoot, "native", "roslyn-worker", "bin", "Release", "net10.0", "Causoryn.RoslynWorker.dll"),
126
+ path.join(pkgRoot, "native", "roslyn-worker", "bin", "Debug", "net10.0", "Causoryn.RoslynWorker.dll"),
127
+ ];
128
+ return candidates.some((candidate) => existsSync(candidate));
129
+ }
130
+ function inspectRuntimeRoot(pkgRoot, platform, arch, musl) {
131
+ const missing = [];
132
+ const bundlePath = path.join(pkgRoot, "dist", "mcp-server.mjs");
133
+ const bundlePresent = existsSync(bundlePath);
134
+ if (!bundlePresent)
135
+ missing.push(bundlePath);
136
+ const prebuildTarget = platform === "linux" && musl ? "linuxmusl" : platform;
137
+ const prebuildPath = path.join(pkgRoot, "dist", "node_modules", "better-sqlite3", "prebuilds", `${prebuildTarget}-${arch}.node`);
138
+ const sqlitePrebuildPresent = existsSync(prebuildPath);
139
+ if (!sqlitePrebuildPresent)
140
+ missing.push(prebuildPath);
141
+ const tsLibPath = path.join(pkgRoot, "dist", "typescript-lib", "lib.es2022.full.d.ts");
142
+ const typescriptLibPresent = existsSync(tsLibPath);
143
+ if (!typescriptLibPresent)
144
+ missing.push(tsLibPath);
145
+ const requiredNativeFiles = [
146
+ path.join(pkgRoot, "native", "python-worker", "worker.py"),
147
+ path.join(pkgRoot, "native", "go-worker", "cmd", "worker", "main.go"),
148
+ path.join(pkgRoot, "native", "rust-worker", "Cargo.toml"),
149
+ path.join(pkgRoot, "native", "roslyn-worker", "Causoryn.RoslynWorker.csproj"),
150
+ ];
151
+ let nativeWorkersPresent = true;
152
+ for (const nativeFile of requiredNativeFiles) {
153
+ if (!existsSync(nativeFile)) {
154
+ nativeWorkersPresent = false;
155
+ missing.push(nativeFile);
156
+ }
157
+ }
158
+ if (!resolveCompiledRoslynDllExists(pkgRoot)) {
159
+ nativeWorkersPresent = false;
160
+ missing.push(path.join(pkgRoot, "native", "roslyn-worker", "Causoryn.RoslynWorker.dll"));
161
+ }
162
+ return {
163
+ bundlePresent,
164
+ sqlitePrebuildPresent,
165
+ typescriptLibPresent,
166
+ nativeWorkersPresent,
167
+ missingPaths: missing,
168
+ };
169
+ }
170
+ function checkRuntime(packageRoot, homeDir, platform, arch, musl) {
171
+ const primary = inspectRuntimeRoot(packageRoot, platform, arch, musl);
172
+ const candidateStaged = getPersistentRuntimeDir(homeDir);
173
+ const hasStaged = existsSync(candidateStaged);
174
+ let stagedRuntimeOk = null;
175
+ const allMissing = [...primary.missingPaths];
176
+ if (hasStaged) {
177
+ const stagedCheck = inspectRuntimeRoot(candidateStaged, platform, arch, musl);
178
+ stagedRuntimeOk =
179
+ stagedCheck.bundlePresent &&
180
+ stagedCheck.sqlitePrebuildPresent &&
181
+ stagedCheck.typescriptLibPresent &&
182
+ stagedCheck.nativeWorkersPresent;
183
+ if (!stagedRuntimeOk) {
184
+ for (const m of stagedCheck.missingPaths) {
185
+ allMissing.push(m);
186
+ }
187
+ }
188
+ }
189
+ const ok = primary.bundlePresent &&
190
+ primary.sqlitePrebuildPresent &&
191
+ primary.typescriptLibPresent &&
192
+ primary.nativeWorkersPresent &&
193
+ (stagedRuntimeOk === null || stagedRuntimeOk);
194
+ return {
195
+ ok,
196
+ packageRoot,
197
+ bundlePresent: primary.bundlePresent,
198
+ sqlitePrebuildPresent: primary.sqlitePrebuildPresent,
199
+ typescriptLibPresent: primary.typescriptLibPresent,
200
+ nativeWorkersPresent: primary.nativeWorkersPresent,
201
+ stagedRuntimeDir: hasStaged ? candidateStaged : null,
202
+ stagedRuntimeOk,
203
+ missingPaths: allMissing,
204
+ };
205
+ }
206
+ function probeSidecarToolchains(probe) {
207
+ const specs = [
208
+ { id: "dotnet", cmd: "dotnet", args: ["--version"] },
209
+ { id: "python", cmd: "python", args: ["--version"] },
210
+ { id: "go", cmd: "go", args: ["version"] },
211
+ { id: "cargo", cmd: "cargo", args: ["--version"] },
212
+ ];
213
+ const out = {};
214
+ for (const spec of specs) {
215
+ const res = probe(spec.cmd, spec.args, SIDECAR_PROBE_TIMEOUT_MS);
216
+ out[spec.id] = {
217
+ id: spec.id,
218
+ available: res.available,
219
+ version: res.version,
220
+ mode: res.available ? "sidecar-ready" : "l0-l1-fallback",
221
+ detail: res.available
222
+ ? `${res.version ?? spec.cmd} (sidecar hazır)`
223
+ : `Bulunamadı (${res.detail}) — bu dil L0/L1 dosya düzeyine zarifçe düşer`,
224
+ };
225
+ }
226
+ return out;
227
+ }
228
+ function isPlainObject(value) {
229
+ return typeof value === "object" && value !== null && !Array.isArray(value);
230
+ }
231
+ function checkEntrypointExists(command, args) {
232
+ if (command !== "node" || !Array.isArray(args) || typeof args[0] !== "string") {
233
+ return null;
234
+ }
235
+ const scriptArg = args[0];
236
+ if (scriptArg.includes("$")) {
237
+ return null;
238
+ }
239
+ return existsSync(scriptArg);
240
+ }
241
+ function inspectSkills(skillsDir) {
242
+ const installed = [];
243
+ const missing = [];
244
+ for (const skillName of CANONICAL_SKILL_NAMES) {
245
+ const file = path.join(skillsDir, skillName, "SKILL.md");
246
+ if (existsSync(file) && statSync(file).isFile()) {
247
+ installed.push(skillName);
248
+ }
249
+ else {
250
+ missing.push(skillName);
251
+ }
252
+ }
253
+ return { installed, missing };
254
+ }
255
+ function inspectSingleHost(client, homeDir, codexHomeDir, claudeConfigDir, detectedSet) {
256
+ const detected = detectedSet.has(client);
257
+ const skillsDir = getHostSkillsDir(homeDir, client, claudeConfigDir);
258
+ const skills = inspectSkills(skillsDir);
259
+ let configPath;
260
+ switch (client) {
261
+ case "antigravity":
262
+ configPath = path.join(homeDir, ".gemini", "config", "mcp_config.json");
263
+ break;
264
+ case "claude-code":
265
+ configPath = getClaudeConfigFilePath(homeDir, claudeConfigDir);
266
+ break;
267
+ case "codex":
268
+ configPath = path.join(codexHomeDir, "config.toml");
269
+ break;
270
+ case "zcode":
271
+ configPath = path.join(homeDir, ".zcode", "cli", "config.json");
272
+ break;
273
+ }
274
+ let configValid = true;
275
+ let mcpConfigured = false;
276
+ let entrypointExists = null;
277
+ let parseDetail = "";
278
+ if (existsSync(configPath)) {
279
+ const raw = readFileSync(configPath, "utf8");
280
+ if (client === "codex") {
281
+ try {
282
+ validateTomlStructure(raw);
283
+ const parsed = readCodexMcpServer(raw);
284
+ if (parsed !== null) {
285
+ mcpConfigured = true;
286
+ entrypointExists = checkEntrypointExists(parsed.command, parsed.args);
287
+ }
288
+ }
289
+ catch (error) {
290
+ configValid = false;
291
+ parseDetail = error instanceof Error ? error.message : String(error);
292
+ }
293
+ }
294
+ else {
295
+ try {
296
+ const parsed = JSON.parse(raw);
297
+ if (!isPlainObject(parsed)) {
298
+ configValid = false;
299
+ parseDetail = "JSON kök değeri nesne değil";
300
+ }
301
+ else if (client === "zcode") {
302
+ const mcp = parsed["mcp"];
303
+ const servers = isPlainObject(mcp) ? mcp["servers"] : undefined;
304
+ if (mcp !== undefined && !isPlainObject(mcp)) {
305
+ configValid = false;
306
+ parseDetail = "mcp alanı nesne değil";
307
+ }
308
+ else if (servers !== undefined && !isPlainObject(servers)) {
309
+ configValid = false;
310
+ parseDetail = "mcp.servers alanı nesne değil";
311
+ }
312
+ else if (isPlainObject(servers) && "causoryn" in servers) {
313
+ const entry = servers["causoryn"];
314
+ if (!isPlainObject(entry)) {
315
+ mcpConfigured = false;
316
+ configValid = false;
317
+ parseDetail = "mcp.servers.causoryn alanı nesne değil";
318
+ }
319
+ else if (typeof entry["command"] !== "string" ||
320
+ entry["command"].trim().length === 0) {
321
+ mcpConfigured = false;
322
+ configValid = false;
323
+ parseDetail = "mcp.servers.causoryn.command boş olmayan bir dizge olmalı";
324
+ }
325
+ else {
326
+ mcpConfigured = true;
327
+ entrypointExists = checkEntrypointExists(entry["command"], entry["args"]);
328
+ }
329
+ }
330
+ }
331
+ else {
332
+ const servers = parsed["mcpServers"];
333
+ if (servers !== undefined && !isPlainObject(servers)) {
334
+ configValid = false;
335
+ parseDetail = "mcpServers alanı nesne değil";
336
+ }
337
+ else if (isPlainObject(servers) && "causoryn" in servers) {
338
+ const entry = servers["causoryn"];
339
+ if (!isPlainObject(entry)) {
340
+ mcpConfigured = false;
341
+ configValid = false;
342
+ parseDetail = "mcpServers.causoryn alanı nesne değil";
343
+ }
344
+ else if (typeof entry["command"] !== "string" ||
345
+ entry["command"].trim().length === 0) {
346
+ mcpConfigured = false;
347
+ configValid = false;
348
+ parseDetail = "mcpServers.causoryn.command boş olmayan bir dizge olmalı";
349
+ }
350
+ else {
351
+ mcpConfigured = true;
352
+ entrypointExists = checkEntrypointExists(entry["command"], entry["args"]);
353
+ }
354
+ }
355
+ }
356
+ }
357
+ catch (error) {
358
+ configValid = false;
359
+ parseDetail = error instanceof Error ? error.message : String(error);
360
+ }
361
+ }
362
+ }
363
+ // Antigravity ikincil mcp_config.json dosyası varsa onun da bozuk olmadığını denetle
364
+ if (client === "antigravity" && configValid) {
365
+ const secondary = path.join(homeDir, ".gemini", "antigravity", "mcp_config.json");
366
+ if (existsSync(secondary)) {
367
+ try {
368
+ const secParsed = JSON.parse(readFileSync(secondary, "utf8"));
369
+ if (!isPlainObject(secParsed)) {
370
+ configValid = false;
371
+ parseDetail = `İkincil Antigravity JSON kök değeri nesne değil (${secondary})`;
372
+ }
373
+ else if (secParsed["mcpServers"] !== undefined &&
374
+ !isPlainObject(secParsed["mcpServers"])) {
375
+ configValid = false;
376
+ parseDetail = `İkincil Antigravity mcpServers alanı nesne değil (${secondary})`;
377
+ }
378
+ else if (isPlainObject(secParsed["mcpServers"]) &&
379
+ "causoryn" in secParsed["mcpServers"]) {
380
+ const secEntry = secParsed["mcpServers"]["causoryn"];
381
+ if (!isPlainObject(secEntry) ||
382
+ typeof secEntry["command"] !== "string" ||
383
+ secEntry["command"].trim().length === 0) {
384
+ configValid = false;
385
+ parseDetail = `İkincil Antigravity mcpServers.causoryn.command boş olmayan bir dizge olmalı (${secondary})`;
386
+ }
387
+ }
388
+ }
389
+ catch (error) {
390
+ configValid = false;
391
+ parseDetail = error instanceof Error ? error.message : String(error);
392
+ }
393
+ }
394
+ }
395
+ const brokenEntrypoint = entrypointExists === false;
396
+ const aligned = configValid &&
397
+ mcpConfigured &&
398
+ !brokenEntrypoint &&
399
+ skills.missing.length === 0;
400
+ let status;
401
+ let detail;
402
+ if (!configValid) {
403
+ status = "error";
404
+ detail = `Bozuk konfigürasyon: ${parseDetail}`;
405
+ }
406
+ else if (brokenEntrypoint) {
407
+ status = "error";
408
+ detail = "MCP sunucu giriş betiği diskte bulunamadı (`npx causoryn setup --yes` ile yenileyin)";
409
+ }
410
+ else if (aligned) {
411
+ status = "ok";
412
+ detail = "MCP sunucusu ve 4 yönlendirme skill dosyası tam hizalı";
413
+ }
414
+ else if (!mcpConfigured && skills.installed.length === 0) {
415
+ status = "not-configured";
416
+ detail = detected
417
+ ? "Host algılandı ancak Causoryn henüz kurulmamış"
418
+ : "Host algılanmadı";
419
+ }
420
+ else {
421
+ status = "warn";
422
+ detail = mcpConfigured
423
+ ? `MCP kurulu ancak eksik skill'ler var: ${skills.missing.join(", ")}`
424
+ : "Skill dosyaları mevcut ancak MCP sunucu kaydı yok";
425
+ }
426
+ return {
427
+ client,
428
+ detected,
429
+ configPath,
430
+ configValid,
431
+ mcpConfigured,
432
+ entrypointExists,
433
+ skillsDir,
434
+ skillsInstalled: skills.installed,
435
+ missingSkills: skills.missing,
436
+ aligned,
437
+ status,
438
+ detail,
439
+ };
440
+ }
441
+ export function runDoctor(options = {}) {
442
+ const effectiveEnv = options.env ?? process.env;
443
+ const explicitHomeProvided = options.homeDir !== undefined;
444
+ const homeDir = resolveEffectiveHomeDir(options.homeDir);
445
+ const codexHomeDir = resolveEffectiveCodexHomeDir(homeDir, options.codexHomeDir, explicitHomeProvided, effectiveEnv);
446
+ const claudeConfigDir = resolveEffectiveClaudeConfigDir(options.claudeConfigDir, explicitHomeProvided, effectiveEnv);
447
+ const packageRoot = path.resolve(options.packageRoot ?? resolveDefaultPackageRoot());
448
+ const nodeVersion = options.nodeVersion ?? process.versions.node;
449
+ const platform = options.platform ?? process.platform;
450
+ const arch = options.arch ?? process.arch;
451
+ const musl = options.isMusl !== undefined
452
+ ? Boolean(options.isMusl)
453
+ : platform === "linux" && process.platform === "linux"
454
+ ? isLinuxMusl(platform)
455
+ : false;
456
+ const probe = options.probeToolchain ?? defaultToolchainProbe;
457
+ const nodeCheck = checkNodeVersion(nodeVersion);
458
+ const runtimeCheck = checkRuntime(packageRoot, homeDir, platform, arch, musl);
459
+ const toolchains = probeSidecarToolchains(probe);
460
+ const detectedSet = new Set(detectInstalledClients(homeDir, codexHomeDir, claudeConfigDir));
461
+ const targetClients = options.clients !== undefined && options.clients.length > 0
462
+ ? [...new Set(options.clients)]
463
+ : HOST_CLIENT_IDS;
464
+ const hosts = {};
465
+ for (const client of HOST_CLIENT_IDS) {
466
+ hosts[client] = inspectSingleHost(client, homeDir, codexHomeDir, claudeConfigDir, detectedSet);
467
+ }
468
+ const hostErrors = targetClients.some((c) => hosts[c].status === "error");
469
+ const healthy = nodeCheck.ok && runtimeCheck.ok && !hostErrors;
470
+ return {
471
+ healthy,
472
+ version: CAUSORYN_PACKAGE_VERSION,
473
+ node: nodeCheck,
474
+ runtime: runtimeCheck,
475
+ toolchains,
476
+ hosts,
477
+ };
478
+ }
479
+ export function formatDoctorReportText(report, selectedClients) {
480
+ const lines = [];
481
+ lines.push(`Causoryn Doctor v${report.version} — ${report.healthy ? "HEALTHY" : "UNHEALTHY"}`);
482
+ lines.push("");
483
+ lines.push(`[Node.js] ${report.node.ok ? "OK" : "ERROR"} — ${report.node.detail}`);
484
+ lines.push(`[Runtime] ${report.runtime.ok ? "OK" : "ERROR"} — root=${report.runtime.packageRoot}`);
485
+ if (report.runtime.missingPaths.length > 0) {
486
+ for (const missing of report.runtime.missingPaths) {
487
+ lines.push(` missing: ${missing}`);
488
+ }
489
+ }
490
+ lines.push("");
491
+ lines.push("[Sidecar Toolchains]");
492
+ for (const tcId of SIDECAR_TOOLCHAIN_IDS) {
493
+ const tc = report.toolchains[tcId];
494
+ lines.push(` - ${tc.id}: ${tc.mode} (${tc.detail})`);
495
+ }
496
+ lines.push("");
497
+ lines.push("[Hosts]");
498
+ const clientsToShow = selectedClients !== undefined && selectedClients.length > 0
499
+ ? selectedClients
500
+ : HOST_CLIENT_IDS;
501
+ for (const client of clientsToShow) {
502
+ const h = report.hosts[client];
503
+ lines.push(` - ${h.client}: ${h.status.toUpperCase()} — ${h.detail}`);
504
+ }
505
+ return `${lines.join("\n")}\n`;
506
+ }
507
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `causoryn` — açık kaynak çoklu-host CLI ve eklenti dağıtım paketi (K-021).
3
+ */
4
+ export { CANONICAL_SKILL_NAMES, CAUSORYN_PACKAGE_NAME, CAUSORYN_PACKAGE_VERSION, CausorynCliError, HOST_CLIENT_IDS, SIDECAR_TOOLCHAIN_IDS, isHostClientId, type CanonicalSkillName, type CausorynCliErrorCode, type CliIo, type CodexMcpServerSpec, type DoctorHostStatus, type DoctorNodeCheck, type DoctorOptions, type DoctorReport, type DoctorRuntimeCheck, type DoctorToolchainStatus, type HostClientId, type ParsedCodexMcpServer, type RunCliOptions, type SetupAction, type SetupOptions, type SetupResult, type SidecarToolchainId, type StagePersistentRuntimeOptions, type StagePersistentRuntimeResult, type ToolchainProbeFn, type ToolchainProbeOutcome, } from "./types.js";
5
+ export { formatTomlBasicString, readCodexMcpServer, removeCodexMcpServer, upsertCodexMcpServer, validateTomlStructure, } from "./toml-patch.js";
6
+ export { getPersistentRuntimeDir, isEphemeralRuntimeDir, stagePersistentRuntime, } from "./runtime-stage.js";
7
+ export { detectInstalledClients, getHostSkillsDir, resolveDefaultPackageRoot, resolveEffectiveCodexHomeDir, resolveEffectiveHomeDir, runSetup, } from "./setup.js";
8
+ export { DOCTOR_PROBE_ENV_ALLOWLIST, buildDoctorProbeEnv, formatDoctorReportText, runDoctor, } from "./doctor.js";
9
+ export { runCli } from "./cli.js";
10
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `causoryn` — açık kaynak çoklu-host CLI ve eklenti dağıtım paketi (K-021).
3
+ */
4
+ export { CANONICAL_SKILL_NAMES, CAUSORYN_PACKAGE_NAME, CAUSORYN_PACKAGE_VERSION, CausorynCliError, HOST_CLIENT_IDS, SIDECAR_TOOLCHAIN_IDS, isHostClientId, } from "./types.js";
5
+ export { formatTomlBasicString, readCodexMcpServer, removeCodexMcpServer, upsertCodexMcpServer, validateTomlStructure, } from "./toml-patch.js";
6
+ export { getPersistentRuntimeDir, isEphemeralRuntimeDir, stagePersistentRuntime, } from "./runtime-stage.js";
7
+ export { detectInstalledClients, getHostSkillsDir, resolveDefaultPackageRoot, resolveEffectiveCodexHomeDir, resolveEffectiveHomeDir, runSetup, } from "./setup.js";
8
+ export { DOCTOR_PROBE_ENV_ALLOWLIST, buildDoctorProbeEnv, formatDoctorReportText, runDoctor, } from "./doctor.js";
9
+ export { runCli } from "./cli.js";
10
+ //# sourceMappingURL=index.js.map