@0perator/operator 0.1.34 → 0.1.35

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/dist/cli.js CHANGED
@@ -15,10 +15,11 @@ import { BackgroundAgents } from "./background/index.js";
15
15
  import { loadSettings } from "./config/settings.js";
16
16
  import { EventSink } from "./telemetry/events.js";
17
17
  import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
18
+ import { expandFileMentions } from "./util/mentions.js";
18
19
  import { join } from "node:path";
19
20
  import { homedir, hostname } from "node:os";
20
21
  import { createHash } from "node:crypto";
21
- const VERSION = "0.1.34";
22
+ const VERSION = "0.1.35";
22
23
  // operator/settings.json (override path via KODE_TSI_SETTINGS), env vars still win — see config/settings.ts.
23
24
  const settings = loadSettings();
24
25
  // Propagate the resolved sandbox mode to the tool layer (registry reads KODE_SANDBOX at exec time).
@@ -370,7 +371,7 @@ function Root() {
370
371
  setElapsed(0);
371
372
  setStat("thinking");
372
373
  try {
373
- const outcome = await session.send(text, {
374
+ const outcome = await session.send(expandFileMentions(text), {
374
375
  onRoute: (label, pct) => { setRoute(label); setCtxPct(pct); remoteRef.current?.setStatus(pct, label); },
375
376
  onDelta: (chunk) => {
376
377
  liveText.current += chunk;
@@ -0,0 +1,34 @@
1
+ // @file mentions (Claude-Code parity): when the owner types `@path`, inline that file's content into the
2
+ // SENT prompt (the visible message keeps the @path as typed). Only tokens that resolve to a real file are
3
+ // expanded — `@someone` that isn't a path is left untouched — and each file is bounded + oversized/dir
4
+ // paths are skipped, so a stray `@node_modules/...` can't blow the context. Matched at a word boundary so
5
+ // email addresses don't trigger it. Pure + node-lazy-free at module load isn't needed (CLI-only caller).
6
+ import { readFileSync, statSync } from "node:fs";
7
+ import { join } from "node:path";
8
+ import { homedir } from "node:os";
9
+ const MENTION_RE = /(?:^|\s)@([^\s`'"]+)/g;
10
+ const MAX_FILE_BYTES = 256 * 1024; // skip anything larger — a mention shouldn't pull a huge blob
11
+ const INLINE_CAP = 32 * 1024; // per-file cap on what we actually inline
12
+ /** Return `text` with each `@path` that resolves to a real file appended as a fenced, labeled block.
13
+ * Unresolvable `@tokens` are left as-is. `cwd` defaults to process.cwd(); injectable for tests. */
14
+ export function expandFileMentions(text, cwd = process.cwd()) {
15
+ const blocks = [];
16
+ const seen = new Set();
17
+ let m;
18
+ MENTION_RE.lastIndex = 0;
19
+ while ((m = MENTION_RE.exec(text))) {
20
+ const raw = m[1];
21
+ const p = raw.startsWith("~/") ? join(homedir(), raw.slice(2)) : raw.startsWith("/") ? raw : join(cwd, raw);
22
+ if (seen.has(p))
23
+ continue;
24
+ try {
25
+ const st = statSync(p);
26
+ if (!st.isFile() || st.size > MAX_FILE_BYTES)
27
+ continue;
28
+ seen.add(p);
29
+ blocks.push(`## @${raw} (inlined)\n\`\`\`\n${readFileSync(p, "utf8").slice(0, INLINE_CAP)}\n\`\`\``);
30
+ }
31
+ catch { /* not a real file — leave the @token as literal text */ }
32
+ }
33
+ return blocks.length ? `${text}\n\n${blocks.join("\n\n")}` : text;
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
5
5
  "type": "module",
6
6
  "bin": {