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
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+ const { cppdb } = require('../util');
3
+ const controllers = new WeakMap();
4
+
5
+ module.exports = function transaction(fn) {
6
+ if (typeof fn !== 'function') throw new TypeError('Expected first argument to be a function');
7
+
8
+ const db = this[cppdb];
9
+ const controller = getController(db, this);
10
+ const { apply } = Function.prototype;
11
+
12
+ // Each version of the transaction function has these same properties
13
+ const properties = {
14
+ default: { value: wrapTransaction(apply, fn, db, controller.default) },
15
+ deferred: { value: wrapTransaction(apply, fn, db, controller.deferred) },
16
+ immediate: { value: wrapTransaction(apply, fn, db, controller.immediate) },
17
+ exclusive: { value: wrapTransaction(apply, fn, db, controller.exclusive) },
18
+ database: { value: this, enumerable: true },
19
+ };
20
+
21
+ Object.defineProperties(properties.default.value, properties);
22
+ Object.defineProperties(properties.deferred.value, properties);
23
+ Object.defineProperties(properties.immediate.value, properties);
24
+ Object.defineProperties(properties.exclusive.value, properties);
25
+
26
+ // Return the default version of the transaction function
27
+ return properties.default.value;
28
+ };
29
+
30
+ // Return the database's cached transaction controller, or create a new one
31
+ const getController = (db, self) => {
32
+ let controller = controllers.get(db);
33
+ if (!controller) {
34
+ const shared = {
35
+ commit: db.prepare('COMMIT', self, false, false),
36
+ rollback: db.prepare('ROLLBACK', self, false, false),
37
+ savepoint: db.prepare('SAVEPOINT `\t_bs3.\t`', self, false, false),
38
+ release: db.prepare('RELEASE `\t_bs3.\t`', self, false, false),
39
+ rollbackTo: db.prepare('ROLLBACK TO `\t_bs3.\t`', self, false, false),
40
+ };
41
+ controllers.set(db, controller = {
42
+ default: Object.assign({ begin: db.prepare('BEGIN', self, false, false) }, shared),
43
+ deferred: Object.assign({ begin: db.prepare('BEGIN DEFERRED', self, false, false) }, shared),
44
+ immediate: Object.assign({ begin: db.prepare('BEGIN IMMEDIATE', self, false, false) }, shared),
45
+ exclusive: Object.assign({ begin: db.prepare('BEGIN EXCLUSIVE', self, false, false) }, shared),
46
+ });
47
+ }
48
+ return controller;
49
+ };
50
+
51
+ // Return a new transaction function by wrapping the given function
52
+ const wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {
53
+ let before, after, undo;
54
+ if (db.inTransaction) {
55
+ before = savepoint;
56
+ after = release;
57
+ undo = rollbackTo;
58
+ } else {
59
+ before = begin;
60
+ after = commit;
61
+ undo = rollback;
62
+ }
63
+ before.run();
64
+ try {
65
+ const result = apply.call(fn, this, arguments);
66
+ if (result && typeof result.then === 'function') {
67
+ throw new TypeError('Transaction function cannot return a promise');
68
+ }
69
+ after.run();
70
+ return result;
71
+ } catch (ex) {
72
+ if (db.inTransaction) {
73
+ undo.run();
74
+ if (undo !== rollback) after.run();
75
+ }
76
+ throw ex;
77
+ }
78
+ };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+ const { cppdb } = require('../util');
3
+
4
+ exports.prepare = function prepare(sql) {
5
+ return this[cppdb].prepare(sql, this, false, false);
6
+ };
7
+
8
+ exports.exec = function exec(sql) {
9
+ this[cppdb].exec(sql);
10
+ return this;
11
+ };
12
+
13
+ exports.close = function close() {
14
+ this[cppdb].close();
15
+ return this;
16
+ };
17
+
18
+ exports.loadExtension = function loadExtension(...args) {
19
+ this[cppdb].loadExtension(...args);
20
+ return this;
21
+ };
22
+
23
+ exports.defaultSafeIntegers = function defaultSafeIntegers(...args) {
24
+ this[cppdb].defaultSafeIntegers(...args);
25
+ return this;
26
+ };
27
+
28
+ exports.unsafeMode = function unsafeMode(...args) {
29
+ this[cppdb].unsafeMode(...args);
30
+ return this;
31
+ };
32
+
33
+ exports.getters = {
34
+ name: {
35
+ get: function name() { return this[cppdb].name; },
36
+ enumerable: true,
37
+ },
38
+ open: {
39
+ get: function open() { return this[cppdb].open; },
40
+ enumerable: true,
41
+ },
42
+ inTransaction: {
43
+ get: function inTransaction() { return this[cppdb].inTransaction; },
44
+ enumerable: true,
45
+ },
46
+ readonly: {
47
+ get: function readonly() { return this[cppdb].readonly; },
48
+ enumerable: true,
49
+ },
50
+ memory: {
51
+ get: function memory() { return this[cppdb].memory; },
52
+ enumerable: true,
53
+ },
54
+ };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ class SqliteError extends Error {
4
+ constructor(message, code) {
5
+ if (typeof code !== 'string') {
6
+ throw new TypeError('Expected second argument to be a string');
7
+ }
8
+
9
+ super('' + message);
10
+ this.code = code;
11
+
12
+ if (typeof Error.captureStackTrace === 'function') {
13
+ Error.captureStackTrace(this, SqliteError);
14
+ }
15
+ }
16
+ }
17
+
18
+ Object.defineProperty(SqliteError.prototype, 'name', {
19
+ value: 'SqliteError',
20
+ writable: true,
21
+ enumerable: false,
22
+ configurable: true,
23
+ });
24
+
25
+ module.exports = SqliteError;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ exports.getBooleanOption = (options, key) => {
4
+ let value = false;
5
+ if (key in options && typeof (value = options[key]) !== 'boolean') {
6
+ throw new TypeError(`Expected the "${key}" option to be a boolean`);
7
+ }
8
+ return value;
9
+ };
10
+
11
+ exports.cppdb = Symbol();
12
+ exports.inspect = Symbol.for('nodejs.util.inspect.custom');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ module.exports = require('./database')(() => require('../prebuilds/win32-arm64.node'), false);
3
+ module.exports.SqliteError = require('./sqlite-error');
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ module.exports = require('./database')(() => require('../prebuilds/win32-x64.node'), false);
3
+ module.exports.SqliteError = require('./sqlite-error');
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "better-sqlite3",
3
+ "version": "13.0.3",
4
+ "description": "The fastest and simplest library for SQLite in Node.js.",
5
+ "homepage": "http://github.com/WiseLibs/better-sqlite3",
6
+ "author": "Joshua Wise <joshuathomaswise@gmail.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git://github.com/WiseLibs/better-sqlite3.git"
10
+ },
11
+ "main": "lib/index.js",
12
+ "exports": {
13
+ ".": "./lib/index.js",
14
+ "./linux-x64": "./lib/linux-x64.js",
15
+ "./linux-arm64": "./lib/linux-arm64.js",
16
+ "./linuxmusl-x64": "./lib/linuxmusl-x64.js",
17
+ "./linuxmusl-arm64": "./lib/linuxmusl-arm64.js",
18
+ "./darwin-x64": "./lib/darwin-x64.js",
19
+ "./darwin-arm64": "./lib/darwin-arm64.js",
20
+ "./win32-x64": "./lib/win32-x64.js",
21
+ "./win32-arm64": "./lib/win32-arm64.js",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "binding.gyp",
26
+ "src/**/*.[ch]pp",
27
+ "lib/**",
28
+ "deps/**",
29
+ "prebuilds/**"
30
+ ],
31
+ "gypfile": false,
32
+ "engines": {
33
+ "node": ">=22"
34
+ },
35
+ "dependencies": {
36
+ "node-addon-api": "^8.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "chai": "^4.3.8",
40
+ "cli-color": "^2.0.3",
41
+ "fs-extra": "^11.1.1",
42
+ "mocha": "^11.7.5",
43
+ "node-gyp": "^10.3.1",
44
+ "nodemark": "^0.3.0",
45
+ "sqlite": "^5.0.1",
46
+ "sqlite3": "^5.1.6"
47
+ },
48
+ "scripts": {
49
+ "build-release": "node-gyp clean && node-gyp rebuild --release --force_build=1",
50
+ "build-debug": "node-gyp clean && node-gyp rebuild --debug --force_build=1",
51
+ "test": "mocha --exit --slow=75 --timeout=5000",
52
+ "benchmark": "node benchmark",
53
+ "download": "bash ./deps/download.sh",
54
+ "clean": "rm -rf node_modules build prebuilds"
55
+ },
56
+ "license": "MIT",
57
+ "keywords": [
58
+ "sql",
59
+ "sqlite",
60
+ "sqlite3",
61
+ "transactions",
62
+ "user-defined functions",
63
+ "aggregate functions",
64
+ "window functions",
65
+ "database"
66
+ ]
67
+ }
@@ -0,0 +1,8 @@
1
+ import { type StagePersistentRuntimeOptions, type StagePersistentRuntimeResult } from "./types.js";
2
+ export declare function getPersistentRuntimeDir(homeDir: string): string;
3
+ export declare function isSameRuntimeDir(dirA: string, dirB: string): boolean;
4
+ export declare function isEphemeralRuntimeDir(runtimeDir: string, options?: {
5
+ readonly tmpDir?: string | undefined;
6
+ }): boolean;
7
+ export declare function stagePersistentRuntime(options: StagePersistentRuntimeOptions): StagePersistentRuntimeResult;
8
+ //# sourceMappingURL=runtime-stage.d.ts.map
@@ -0,0 +1,159 @@
1
+ import { cpSync, existsSync, mkdirSync, realpathSync, renameSync, rmSync } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { CausorynCliError, } from "./types.js";
5
+ /**
6
+ * Geçici `_npx` / `os.tmpdir()` çalışma dizini tespiti ve `~/.causoryn/runtime`
7
+ * altına atomik sahneleme yardımcısı (`K-021`).
8
+ */
9
+ const RUNTIME_STAGE_ENTRIES = [
10
+ "package.json",
11
+ "scripts",
12
+ "dist",
13
+ "native",
14
+ "skills",
15
+ "LICENSE",
16
+ "THIRD-PARTY-NOTICES.md",
17
+ "licenses",
18
+ "README.md",
19
+ "plugin.json",
20
+ "mcp_config.json",
21
+ ".claude-plugin",
22
+ ".zcode-plugin",
23
+ ".codex-plugin",
24
+ ];
25
+ function normalizeForComparison(targetPath) {
26
+ const resolved = path.resolve(targetPath);
27
+ return process.platform === "win32" ? resolved.toLowerCase() : resolved;
28
+ }
29
+ function safeRealpath(targetPath) {
30
+ try {
31
+ return realpathSync(targetPath);
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ function isWithinDir(candidatePath, parentDir) {
38
+ const cand = normalizeForComparison(candidatePath);
39
+ const parent = normalizeForComparison(parentDir);
40
+ if (cand === parent)
41
+ return true;
42
+ const boundary = parent.endsWith(path.sep) ? parent : `${parent}${path.sep}`;
43
+ return cand.startsWith(boundary);
44
+ }
45
+ export function getPersistentRuntimeDir(homeDir) {
46
+ return path.join(homeDir, ".causoryn", "runtime");
47
+ }
48
+ export function isSameRuntimeDir(dirA, dirB) {
49
+ const normA = normalizeForComparison(dirA);
50
+ const normB = normalizeForComparison(dirB);
51
+ if (normA === normB) {
52
+ return true;
53
+ }
54
+ const realA = safeRealpath(dirA);
55
+ const realB = safeRealpath(dirB);
56
+ if (realA !== null && normalizeForComparison(realA) === normB) {
57
+ return true;
58
+ }
59
+ if (realB !== null && normA === normalizeForComparison(realB)) {
60
+ return true;
61
+ }
62
+ if (realA !== null && realB !== null && normalizeForComparison(realA) === normalizeForComparison(realB)) {
63
+ return true;
64
+ }
65
+ return false;
66
+ }
67
+ export function isEphemeralRuntimeDir(runtimeDir, options) {
68
+ const resolved = path.resolve(runtimeDir);
69
+ const segments = resolved.split(/[\\/]+/).map((seg) => seg.toLowerCase());
70
+ if (segments.includes("_npx") || segments.includes(".npx")) {
71
+ return true;
72
+ }
73
+ const effectiveTmp = options?.tmpDir ?? os.tmpdir();
74
+ if (isWithinDir(resolved, effectiveTmp)) {
75
+ return true;
76
+ }
77
+ const realCandidate = safeRealpath(resolved);
78
+ const realTmp = safeRealpath(effectiveTmp);
79
+ if (realCandidate !== null && isWithinDir(realCandidate, effectiveTmp)) {
80
+ return true;
81
+ }
82
+ if (realTmp !== null && isWithinDir(resolved, realTmp)) {
83
+ return true;
84
+ }
85
+ if (realCandidate !== null && realTmp !== null && isWithinDir(realCandidate, realTmp)) {
86
+ return true;
87
+ }
88
+ return false;
89
+ }
90
+ export function stagePersistentRuntime(options) {
91
+ const sourceDir = path.resolve(options.sourcePackageDir);
92
+ const requiredFiles = [
93
+ path.join(sourceDir, "package.json"),
94
+ path.join(sourceDir, "scripts", "causoryn.mjs"),
95
+ path.join(sourceDir, "dist", "mcp-server.mjs"),
96
+ ];
97
+ for (const reqFile of requiredFiles) {
98
+ if (!existsSync(reqFile)) {
99
+ throw new CausorynCliError("cli/runtime-stage-failed", `Sahnelenecek çalışma zamanı dosyası eksik: ${reqFile}`);
100
+ }
101
+ }
102
+ const baseCausorynDir = path.join(path.resolve(options.homeDir), ".causoryn");
103
+ const targetDir = path.join(baseCausorynDir, "runtime");
104
+ if (isSameRuntimeDir(sourceDir, targetDir)) {
105
+ return {
106
+ runtimeDir: targetDir,
107
+ cliEntryPath: path.join(targetDir, "scripts", "causoryn.mjs"),
108
+ launcherPath: path.join(targetDir, "scripts", "plugin-mcp-launcher.mjs"),
109
+ };
110
+ }
111
+ mkdirSync(baseCausorynDir, { recursive: true, mode: 0o700 });
112
+ const stamp = `${String(process.pid)}-${String(Date.now())}`;
113
+ const stagingDir = path.join(baseCausorynDir, `.runtime-stage-${stamp}`);
114
+ const backupDir = path.join(baseCausorynDir, `.runtime-prev-${stamp}`);
115
+ rmSync(stagingDir, { recursive: true, force: true });
116
+ mkdirSync(stagingDir, { recursive: true, mode: 0o700 });
117
+ try {
118
+ for (const entry of RUNTIME_STAGE_ENTRIES) {
119
+ const srcEntry = path.join(sourceDir, entry);
120
+ if (!existsSync(srcEntry))
121
+ continue;
122
+ cpSync(srcEntry, path.join(stagingDir, entry), { recursive: true });
123
+ }
124
+ const hadPrevious = existsSync(targetDir);
125
+ if (hadPrevious) {
126
+ rmSync(backupDir, { recursive: true, force: true });
127
+ renameSync(targetDir, backupDir);
128
+ }
129
+ try {
130
+ renameSync(stagingDir, targetDir);
131
+ }
132
+ catch (swapError) {
133
+ if (hadPrevious && existsSync(backupDir) && !existsSync(targetDir)) {
134
+ try {
135
+ renameSync(backupDir, targetDir);
136
+ }
137
+ catch {
138
+ // Yedek geri yükleme başarısızsa orijinal hatayı yükselt
139
+ }
140
+ }
141
+ throw swapError;
142
+ }
143
+ if (hadPrevious && existsSync(backupDir)) {
144
+ rmSync(backupDir, { recursive: true, force: true });
145
+ }
146
+ }
147
+ catch (error) {
148
+ rmSync(stagingDir, { recursive: true, force: true });
149
+ if (error instanceof CausorynCliError)
150
+ throw error;
151
+ throw new CausorynCliError("cli/runtime-stage-failed", `Kalıcı çalışma zamanı sahnelenemedi: ${error instanceof Error ? error.message : String(error)}`);
152
+ }
153
+ return {
154
+ runtimeDir: targetDir,
155
+ cliEntryPath: path.join(targetDir, "scripts", "causoryn.mjs"),
156
+ launcherPath: path.join(targetDir, "scripts", "plugin-mcp-launcher.mjs"),
157
+ };
158
+ }
159
+ //# sourceMappingURL=runtime-stage.js.map
@@ -0,0 +1,15 @@
1
+ import { type HostClientId, type SetupOptions, type SetupResult } from "./types.js";
2
+ export declare function resolveDefaultPackageRoot(): string;
3
+ export declare function resolveEffectiveHomeDir(explicitHomeDir?: string): string;
4
+ export declare function resolveEffectiveCodexHomeDir(homeDir: string, explicitCodexHomeDir?: string, explicitHomeProvided?: boolean, env?: NodeJS.ProcessEnv): string;
5
+ export declare function resolveEffectiveClaudeConfigDir(explicitClaudeConfigDir?: string, explicitHomeProvided?: boolean, env?: NodeJS.ProcessEnv): string | null;
6
+ export declare function getClaudeConfigFilePath(homeDir: string, claudeConfigDir?: string | null): string;
7
+ export declare function getHostSkillsDir(homeDir: string, client: HostClientId, claudeConfigDir?: string | null): string;
8
+ export declare function detectInstalledClients(homeDir: string, codexHomeDir: string, claudeConfigDir?: string | null): HostClientId[];
9
+ type ExtendedSetupOptions = SetupOptions & {
10
+ readonly claudeConfigDir?: string | undefined;
11
+ readonly env?: NodeJS.ProcessEnv | undefined;
12
+ };
13
+ export declare function runSetup(options?: ExtendedSetupOptions): Promise<SetupResult>;
14
+ export {};
15
+ //# sourceMappingURL=setup.d.ts.map