@alexwkleung/reika 0.9.0 → 0.11.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 (157) hide show
  1. package/dist/THIRD_PARTY_LICENSES.txt +1271 -0
  2. package/dist/chunk-AX767B3T.js +22724 -0
  3. package/dist/chunk-JVOYWUGK.js +279 -0
  4. package/dist/chunk-KI5CTLSX.js +59 -0
  5. package/dist/chunk-SBBXMTSX.js +4050 -0
  6. package/dist/cli.js +153 -53
  7. package/dist/devtools-FYXXYYMR.js +2 -0
  8. package/dist/esm-SND35LIM.js +8494 -0
  9. package/dist/headless-Y2V6WPLB.js +592 -0
  10. package/dist/node-7FRVMBZF.js +69479 -0
  11. package/dist/tui-KWAD5BDE.js +34366 -0
  12. package/package.json +16 -17
  13. package/dist/agent/attachments.js +0 -63
  14. package/dist/agent/bashread.js +0 -177
  15. package/dist/agent/compaction.js +0 -922
  16. package/dist/agent/compactionreport.js +0 -248
  17. package/dist/agent/continuation.js +0 -153
  18. package/dist/agent/decoderate.js +0 -132
  19. package/dist/agent/entropytrace.js +0 -169
  20. package/dist/agent/genreserve.js +0 -75
  21. package/dist/agent/groundcheck.js +0 -195
  22. package/dist/agent/logitrecovery.js +0 -171
  23. package/dist/agent/loop.js +0 -3676
  24. package/dist/agent/mentions.js +0 -118
  25. package/dist/agent/noteslotmonitor.js +0 -82
  26. package/dist/agent/pastedurls.js +0 -203
  27. package/dist/agent/planpressure.js +0 -87
  28. package/dist/agent/plantrack.js +0 -503
  29. package/dist/agent/prefillcost.js +0 -95
  30. package/dist/agent/prefixtrace.js +0 -90
  31. package/dist/agent/prompt.js +0 -349
  32. package/dist/agent/readfirst.js +0 -190
  33. package/dist/agent/readtrace.js +0 -191
  34. package/dist/agent/reasoningtrace.js +0 -242
  35. package/dist/agent/shellruns.js +0 -81
  36. package/dist/agent/subagentpressure.js +0 -70
  37. package/dist/agent/subagentreport.js +0 -117
  38. package/dist/agent/warm.js +0 -163
  39. package/dist/approval.js +0 -59
  40. package/dist/check/typecheck.js +0 -345
  41. package/dist/config.js +0 -509
  42. package/dist/context/bootstrap.js +0 -122
  43. package/dist/context/bundlesize.js +0 -74
  44. package/dist/context/files.js +0 -67
  45. package/dist/context/gitignore.js +0 -102
  46. package/dist/context/repomap.js +0 -304
  47. package/dist/debug.js +0 -197
  48. package/dist/headless/headless.js +0 -440
  49. package/dist/headless/headlessargs.js +0 -108
  50. package/dist/headless/headlessprompt.js +0 -132
  51. package/dist/laststate.js +0 -71
  52. package/dist/limit.js +0 -27
  53. package/dist/mcp/client.js +0 -630
  54. package/dist/mcp/config.js +0 -187
  55. package/dist/mcp/manager.js +0 -158
  56. package/dist/mcp/tools.js +0 -323
  57. package/dist/ocr/select.js +0 -29
  58. package/dist/ocr/system.js +0 -162
  59. package/dist/ocr/types.js +0 -1
  60. package/dist/ocr/vision.js +0 -139
  61. package/dist/provider/budget.js +0 -56
  62. package/dist/provider/cachehints.js +0 -30
  63. package/dist/provider/client.js +0 -573
  64. package/dist/provider/contextwindow.js +0 -78
  65. package/dist/provider/dispatcher.js +0 -126
  66. package/dist/provider/latches.js +0 -31
  67. package/dist/provider/modellimits.js +0 -186
  68. package/dist/provider/noteslot.js +0 -239
  69. package/dist/provider/templatekwargs.js +0 -31
  70. package/dist/provider/tokens.js +0 -32
  71. package/dist/provider/toolcall.js +0 -1088
  72. package/dist/provider/transport.js +0 -264
  73. package/dist/search/_chrome.js +0 -422
  74. package/dist/search/cdp.js +0 -223
  75. package/dist/search/searxng.js +0 -86
  76. package/dist/search/types.js +0 -17
  77. package/dist/session.js +0 -411
  78. package/dist/skills/skillmatch.js +0 -143
  79. package/dist/skills/skills.js +0 -349
  80. package/dist/store/payloads.js +0 -21
  81. package/dist/store/sessions.js +0 -180
  82. package/dist/store/transcript.js +0 -390
  83. package/dist/tools/_carriers.js +0 -119
  84. package/dist/tools/_danger.js +0 -1848
  85. package/dist/tools/_deps.js +0 -203
  86. package/dist/tools/_diff.js +0 -64
  87. package/dist/tools/_exfil.js +0 -168
  88. package/dist/tools/_heredoc.js +0 -419
  89. package/dist/tools/_hosts.js +0 -224
  90. package/dist/tools/_markdown.js +0 -288
  91. package/dist/tools/_net.js +0 -65
  92. package/dist/tools/_paths.js +0 -171
  93. package/dist/tools/_readonly.js +0 -545
  94. package/dist/tools/_sandbox.js +0 -953
  95. package/dist/tools/_spill.js +0 -216
  96. package/dist/tools/_spillstats.js +0 -45
  97. package/dist/tools/_treediff.js +0 -350
  98. package/dist/tools/_urls.js +0 -335
  99. package/dist/tools/_walk.js +0 -24
  100. package/dist/tools/_writetargets.js +0 -96
  101. package/dist/tools/ask.js +0 -194
  102. package/dist/tools/bash.js +0 -638
  103. package/dist/tools/edit.js +0 -439
  104. package/dist/tools/fetch.js +0 -415
  105. package/dist/tools/glob.js +0 -142
  106. package/dist/tools/grep.js +0 -263
  107. package/dist/tools/index.js +0 -171
  108. package/dist/tools/list.js +0 -96
  109. package/dist/tools/read.js +0 -74
  110. package/dist/tools/search.js +0 -134
  111. package/dist/tools/subagent.js +0 -23
  112. package/dist/tools/write.js +0 -107
  113. package/dist/types.js +0 -1
  114. package/dist/ui/App.js +0 -2874
  115. package/dist/ui/Approval.js +0 -148
  116. package/dist/ui/Confirm.js +0 -51
  117. package/dist/ui/DiffView.js +0 -401
  118. package/dist/ui/Input.js +0 -461
  119. package/dist/ui/ModelSelect.js +0 -32
  120. package/dist/ui/PlanProgress.js +0 -50
  121. package/dist/ui/Question.js +0 -238
  122. package/dist/ui/QueuedList.js +0 -17
  123. package/dist/ui/ResumeSelect.js +0 -61
  124. package/dist/ui/Scrollback.js +0 -715
  125. package/dist/ui/Splash.js +0 -42
  126. package/dist/ui/Status.js +0 -207
  127. package/dist/ui/Suggestions.js +0 -50
  128. package/dist/ui/Working.js +0 -242
  129. package/dist/ui/clipboard.js +0 -77
  130. package/dist/ui/commands.js +0 -205
  131. package/dist/ui/dialogspecs.js +0 -38
  132. package/dist/ui/focus.js +0 -56
  133. package/dist/ui/format.js +0 -180
  134. package/dist/ui/framedrops.js +0 -34
  135. package/dist/ui/glyphs.js +0 -48
  136. package/dist/ui/harnessecho.js +0 -24
  137. package/dist/ui/highlight.js +0 -191
  138. package/dist/ui/identity.js +0 -211
  139. package/dist/ui/layout.js +0 -224
  140. package/dist/ui/markdown.js +0 -357
  141. package/dist/ui/models.js +0 -32
  142. package/dist/ui/pastes.js +0 -59
  143. package/dist/ui/paths.js +0 -19
  144. package/dist/ui/pr.js +0 -78
  145. package/dist/ui/queue.js +0 -25
  146. package/dist/ui/reactbuild.js +0 -15
  147. package/dist/ui/reasoningfold.js +0 -63
  148. package/dist/ui/redact.js +0 -51
  149. package/dist/ui/scrub.js +0 -49
  150. package/dist/ui/suggest.js +0 -92
  151. package/dist/ui/summary.js +0 -60
  152. package/dist/ui/syncframe.js +0 -97
  153. package/dist/ui/termtext.js +0 -117
  154. package/dist/ui/theme.js +0 -100
  155. package/dist/ui/tui.js +0 -9
  156. package/dist/ui/warmtrigger.js +0 -37
  157. package/dist/version.js +0 -27
@@ -0,0 +1,279 @@
1
+ import { createRequire as __reikaCreateRequire } from 'node:module';
2
+ const require = __reikaCreateRequire(import.meta.url);
3
+
4
+ // src/version.ts
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { dirname, join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ var PACKAGE_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
9
+ var packageRoot = PACKAGE_ROOT;
10
+ var version = "0.0.0";
11
+ try {
12
+ const pkg = JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8"));
13
+ if (pkg.version) version = pkg.version;
14
+ } catch {
15
+ }
16
+ var VERSION = version;
17
+ var docsDir = join(packageRoot, "docs");
18
+ var DOCS_DIR = existsSync(docsDir) ? docsDir : null;
19
+ var API_USER_AGENT = `reika/${VERSION}`;
20
+ var WEB_USER_AGENT = `Mozilla/5.0 (compatible; reika/${VERSION})`;
21
+
22
+ // src/debug.ts
23
+ import { appendFileSync, mkdirSync, renameSync, symlinkSync, unlinkSync } from "node:fs";
24
+ import { open, readdir, rm, stat } from "node:fs/promises";
25
+ import { randomBytes } from "node:crypto";
26
+ import { homedir } from "node:os";
27
+ import { join as join2 } from "node:path";
28
+ function debugEnabled() {
29
+ return !!process.env.REIKA_DEBUG;
30
+ }
31
+ function sessionStem(startedAt) {
32
+ const stamp = startedAt.toISOString().replace(/[:.]/g, "-");
33
+ return `${stamp}-${randomBytes(3).toString("hex")}`;
34
+ }
35
+ var processStem;
36
+ function processSessionStem() {
37
+ return processStem ??= sessionStem(/* @__PURE__ */ new Date());
38
+ }
39
+ function debugLogDir() {
40
+ return join2(homedir(), ".config", "reika", "logs");
41
+ }
42
+ var LATEST_LOG = "latest.log";
43
+ function debugLogPath() {
44
+ return process.env.REIKA_DEBUG_FILE || join2(debugLogDir(), `${processSessionStem()}.log`);
45
+ }
46
+ var sessionStarted = false;
47
+ function openSessionLog(path) {
48
+ const dir2 = debugLogDir();
49
+ mkdirSync(dir2, { recursive: true });
50
+ appendFileSync(path, `[reika:debug] session pid=${process.pid} version=${VERSION}
51
+ `);
52
+ const tmp = join2(dir2, `.latest-${process.pid}`);
53
+ try {
54
+ symlinkSync(`${processSessionStem()}.log`, tmp);
55
+ renameSync(tmp, join2(dir2, LATEST_LOG));
56
+ } catch {
57
+ try {
58
+ unlinkSync(tmp);
59
+ } catch {
60
+ }
61
+ }
62
+ }
63
+ function debugLog(line) {
64
+ if (!debugEnabled()) return;
65
+ const path = debugLogPath();
66
+ const text = line.endsWith("\n") ? line : `${line}
67
+ `;
68
+ try {
69
+ if (!sessionStarted && !process.env.REIKA_DEBUG_FILE) openSessionLog(path);
70
+ sessionStarted = true;
71
+ appendFileSync(path, text);
72
+ } catch {
73
+ }
74
+ }
75
+ var LOG_MAX_AGE_MS = 14 * 24 * 60 * 60 * 1e3;
76
+ var LOG_MAX_TOTAL_BYTES = 50 * 1024 * 1024;
77
+ var SESSION_LOG_RE = /^\d{4}-\d{2}-\d{2}T[\d-]+Z-[0-9a-f]{6}\.log$/;
78
+ var OWNER_RE = /^\[reika:debug\] session pid=(\d+)/;
79
+ function pidAlive(pid) {
80
+ try {
81
+ process.kill(pid, 0);
82
+ return true;
83
+ } catch (e) {
84
+ return e.code === "EPERM";
85
+ }
86
+ }
87
+ async function ownerPid(path) {
88
+ try {
89
+ const fh = await open(path, "r");
90
+ try {
91
+ const buf = Buffer.alloc(128);
92
+ const { bytesRead } = await fh.read(buf, 0, buf.length, 0);
93
+ const m = OWNER_RE.exec(buf.subarray(0, bytesRead).toString("utf8"));
94
+ return m ? Number(m[1]) : null;
95
+ } finally {
96
+ await fh.close();
97
+ }
98
+ } catch {
99
+ return null;
100
+ }
101
+ }
102
+ async function sweepDebugLogs(dir2 = debugLogDir(), now = Date.now()) {
103
+ const removed = [];
104
+ let names;
105
+ try {
106
+ names = (await readdir(dir2)).filter((n) => SESSION_LOG_RE.test(n));
107
+ } catch {
108
+ return removed;
109
+ }
110
+ const own = process.env.REIKA_DEBUG_FILE || processStem === void 0 ? void 0 : join2(dir2, `${processStem}.log`);
111
+ const logs = [];
112
+ for (const name of names) {
113
+ const path = join2(dir2, name);
114
+ try {
115
+ const s = await stat(path);
116
+ if (s.isFile()) logs.push({ path, size: s.size, mtimeMs: s.mtimeMs });
117
+ } catch {
118
+ }
119
+ }
120
+ logs.sort((a, b) => a.mtimeMs - b.mtimeMs);
121
+ let total = logs.reduce((sum, l) => sum + l.size, 0);
122
+ for (const log of logs) {
123
+ if (now - log.mtimeMs <= LOG_MAX_AGE_MS && total <= LOG_MAX_TOTAL_BYTES) break;
124
+ if (log.path === own) continue;
125
+ const pid = await ownerPid(log.path);
126
+ if (pid !== null && pid > 0 && pidAlive(pid)) continue;
127
+ try {
128
+ await rm(log.path, { force: true });
129
+ removed.push(log.path);
130
+ total -= log.size;
131
+ } catch {
132
+ }
133
+ }
134
+ return removed;
135
+ }
136
+ function formatExperimentFlags() {
137
+ const flags = Object.keys(process.env).filter((k) => k.startsWith("REIKA_")).sort().map((k) => {
138
+ const v = process.env[k] ?? "";
139
+ return `${k.slice("REIKA_".length).toLowerCase().replace(/_/g, "-")}=${/^\d+(\.\d+)?$/.test(v) ? v : v === "" ? "''" : "set"}`;
140
+ });
141
+ return `[reika:debug] flags version=${VERSION} ${flags.join(" ") || "(none set)"}`;
142
+ }
143
+ function formatEndpointLine(profile, model, baseURL) {
144
+ let host = "?";
145
+ try {
146
+ host = new URL(baseURL).hostname || "?";
147
+ } catch {
148
+ }
149
+ const id = /^([/~\\]|[A-Za-z]:[/\\])/.test(model) ? model.split(/[/\\]/).pop() ?? "?" : model;
150
+ return `[reika:debug] endpoint profile=${profile} model=${id || "?"} host=${host}`;
151
+ }
152
+
153
+ // src/tools/_spill.ts
154
+ import { mkdirSync as mkdirSync2, rmSync, writeFileSync } from "node:fs";
155
+ import { readdir as readdir2, readFile, rm as rm2, stat as stat2, writeFile } from "node:fs/promises";
156
+ import { randomBytes as randomBytes2 } from "node:crypto";
157
+ import { tmpdir } from "node:os";
158
+ import { join as join3 } from "node:path";
159
+ function spillEnabled() {
160
+ return process.env.REIKA_SPILL !== "0";
161
+ }
162
+ var dir;
163
+ var seq = 0;
164
+ var MAX_DIR_ATTEMPTS = 8;
165
+ function spillDir() {
166
+ if (dir) return dir;
167
+ for (let attempt = 0; attempt < MAX_DIR_ATTEMPTS; attempt++) {
168
+ const d = join3(tmpdir(), `reika-${randomBytes2(3).toString("hex")}`);
169
+ try {
170
+ mkdirSync2(d, { mode: 448 });
171
+ } catch {
172
+ continue;
173
+ }
174
+ try {
175
+ writeFileSync(join3(d, OWNER_FILE), `${process.pid}
176
+ `, { flag: "wx", mode: 384 });
177
+ } catch {
178
+ }
179
+ process.on("exit", () => {
180
+ try {
181
+ rmSync(d, { recursive: true, force: true });
182
+ } catch {
183
+ }
184
+ });
185
+ dir = d;
186
+ return d;
187
+ }
188
+ throw new Error("could not create a private spill directory");
189
+ }
190
+ var OWNER_FILE = ".pid";
191
+ var SPILL_DIR_RE = /^reika-[0-9a-f]{6}$/;
192
+ var ORPHAN_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
193
+ function pidAlive2(pid) {
194
+ try {
195
+ process.kill(pid, 0);
196
+ return true;
197
+ } catch (e) {
198
+ return e.code === "EPERM";
199
+ }
200
+ }
201
+ async function isAbandoned(d) {
202
+ const owner = Number((await readFile(join3(d, OWNER_FILE), "utf8").catch(() => "")).trim());
203
+ if (Number.isInteger(owner) && owner > 0) return !pidAlive2(owner);
204
+ return Date.now() - (await stat2(d)).mtimeMs > ORPHAN_MAX_AGE_MS;
205
+ }
206
+ async function sweepStaleSpills(root = tmpdir()) {
207
+ const removed = [];
208
+ let entries;
209
+ try {
210
+ entries = await readdir2(root, { withFileTypes: true });
211
+ } catch {
212
+ return removed;
213
+ }
214
+ for (const entry of entries) {
215
+ if (!entry.isDirectory() || !SPILL_DIR_RE.test(entry.name)) continue;
216
+ const d = join3(root, entry.name);
217
+ if (d === dir) continue;
218
+ try {
219
+ if (!await isAbandoned(d)) continue;
220
+ await rm2(d, { recursive: true, force: true });
221
+ removed.push(d);
222
+ } catch {
223
+ }
224
+ }
225
+ return removed;
226
+ }
227
+ var handedOut = /* @__PURE__ */ new Set();
228
+ function referencesSpill(text) {
229
+ for (const path of handedOut) if (text.includes(path)) return true;
230
+ return false;
231
+ }
232
+ async function spillResult(name, content) {
233
+ if (!spillEnabled()) return null;
234
+ try {
235
+ const safe = name.replace(/[^a-zA-Z0-9_-]/g, "-").slice(0, 12) || "result";
236
+ const path = join3(spillDir(), `${safe}-${++seq}.txt`);
237
+ await writeFile(path, content, { flag: "wx", mode: 384 });
238
+ handedOut.add(path);
239
+ return { path, bytes: Buffer.byteLength(content) };
240
+ } catch {
241
+ return null;
242
+ }
243
+ }
244
+ function buildSpillFooter(opts) {
245
+ const { shown, total, unit, ref } = opts;
246
+ const note = opts.note ? `${opts.note} ` : "";
247
+ const saved = opts.saved ?? "Full result";
248
+ return `
249
+
250
+ (Showing ${shown} of ${total} ${unit}. ${note}${saved} saved to ${ref.path} \u2014 read that path with offset/limit to page through it, or grep it to narrow. Do not re-run this ${opts.subject ?? "search"} to see the rest.)`;
251
+ }
252
+ function buildCappedFooter(opts) {
253
+ const note = opts.note ? `${opts.note} ` : "";
254
+ const advice = opts.advice ?? "narrow the pattern or scope to see them";
255
+ return `
256
+
257
+ (Showing ${opts.shown} of ${opts.total} ${opts.unit}. ${note}The rest could not be saved \u2014 ${advice}.)`;
258
+ }
259
+
260
+ export {
261
+ PACKAGE_ROOT,
262
+ VERSION,
263
+ DOCS_DIR,
264
+ API_USER_AGENT,
265
+ WEB_USER_AGENT,
266
+ debugEnabled,
267
+ sessionStem,
268
+ processSessionStem,
269
+ debugLog,
270
+ sweepDebugLogs,
271
+ formatExperimentFlags,
272
+ formatEndpointLine,
273
+ spillEnabled,
274
+ sweepStaleSpills,
275
+ referencesSpill,
276
+ spillResult,
277
+ buildSpillFooter,
278
+ buildCappedFooter
279
+ };
@@ -0,0 +1,59 @@
1
+ import { createRequire as __reikaCreateRequire } from 'node:module';
2
+ const require = __reikaCreateRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __esm = (fn, res, err) => function __init() {
16
+ if (err) throw err[0];
17
+ try {
18
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
19
+ } catch (e) {
20
+ throw err = [e], e;
21
+ }
22
+ };
23
+ var __commonJS = (cb, mod) => function __require2() {
24
+ try {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ } catch (e) {
27
+ throw mod = 0, e;
28
+ }
29
+ };
30
+ var __export = (target, all) => {
31
+ for (var name in all)
32
+ __defProp(target, name, { get: all[name], enumerable: true });
33
+ };
34
+ var __copyProps = (to, from, except, desc) => {
35
+ if (from && typeof from === "object" || typeof from === "function") {
36
+ for (let key of __getOwnPropNames(from))
37
+ if (!__hasOwnProp.call(to, key) && key !== except)
38
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
39
+ }
40
+ return to;
41
+ };
42
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
43
+ // If the importer is in node compatibility mode or this is not an ESM
44
+ // file that has been converted to a CommonJS file using a Babel-
45
+ // compatible transform (i.e. "__esModule" has not been set), then set
46
+ // "default" to the CommonJS "module.exports" for node compatibility.
47
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
48
+ mod
49
+ ));
50
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
51
+
52
+ export {
53
+ __require,
54
+ __esm,
55
+ __commonJS,
56
+ __export,
57
+ __toESM,
58
+ __toCommonJS
59
+ };