@alisio/core 0.1.0-alpha.5 → 0.1.0-alpha.7

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.
@@ -168,6 +168,15 @@ export class SQLiteStore {
168
168
  this.db.prepare("INSERT INTO messages(session,body) VALUES(?,?)").run(id, row.body);
169
169
  });
170
170
  }
171
+ overwrite(id, messages) {
172
+ this.db.transaction(() => {
173
+ // Retire the active rows (originals stay marked compacted for auditing), then rewrite
174
+ // the reduced transcript in the same order.
175
+ this.db.prepare("UPDATE messages SET compacted=1 WHERE session=? AND compacted=0").run(id);
176
+ for (const message of messages)
177
+ this.append(id, message);
178
+ });
179
+ }
171
180
  acquire(id) {
172
181
  this.db.transaction(() => {
173
182
  this.get(id);
@@ -4,13 +4,24 @@ import { dirname, relative } from "node:path";
4
4
  import { textResult, } from "@alisio/sdk";
5
5
  import { fileSize, readHead, readText } from "../runtime/fs.js";
6
6
  import { safePath } from "../runtime/paths.js";
7
- import { runProcess } from "../runtime/process.js";
7
+ import { isMissingCommand, RIPGREP_INSTALL_HINT, runProcess } from "../runtime/process.js";
8
8
  import { EXECUTE_TIMEOUT_MS, MAX_NESTED_CALLS, runExecute } from "./execute.js";
9
9
  import { searchWithFallback } from "./search.js";
10
10
  import { DEFAULT_TIMEOUT_SECONDS, MAX_RESPONSE_BYTES, MAX_TIMEOUT_SECONDS, webfetch, } from "./webfetch.js";
11
11
  const str = { type: "string" }, integer = { type: "integer", minimum: 0 };
12
12
  export const objectSchema = (properties, required = []) => ({ type: "object", properties, required, additionalProperties: false });
13
13
  export const hash = (text) => createHash("sha256").update(text).digest("hex");
14
+ /** Runs ripgrep and turns a missing binary into an actionable install message. */
15
+ async function runRipgrep(args, options) {
16
+ try {
17
+ return await runProcess("rg", args, options);
18
+ }
19
+ catch (error) {
20
+ if (isMissingCommand(error))
21
+ throw new Error(RIPGREP_INSTALL_HINT);
22
+ throw error;
23
+ }
24
+ }
14
25
  async function existing(path) {
15
26
  const size = await fileSize(path);
16
27
  if (size === undefined)
@@ -120,7 +131,7 @@ execCtx, websearchCtx) {
120
131
  paths: filePaths,
121
132
  async execute(i, c) {
122
133
  const path = await safePath(c.workspace, String(i.path ?? "."));
123
- const result = await runProcess("rg", ["--files", "--glob", "!.git", "--glob", "!node_modules", "--", path], { cwd: c.workspace, signal: c.signal, maxBytes: 200_000 });
134
+ const result = await runRipgrep(["--files", "--glob", "!.git", "--glob", "!node_modules", "--", path], { cwd: c.workspace, signal: c.signal, maxBytes: 200_000 });
124
135
  if (result.exitCode > 1 && !result.truncated)
125
136
  throw new Error(result.stderr);
126
137
  const all = result.stdout
@@ -146,7 +157,7 @@ execCtx, websearchCtx) {
146
157
  paths: filePaths,
147
158
  async execute(i, c) {
148
159
  const path = await safePath(c.workspace, String(i.path ?? "."));
149
- const r = await runProcess("rg", [
160
+ const r = await runRipgrep([
150
161
  "--json",
151
162
  "--max-count",
152
163
  "100",
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Reads the @alisio/core package version at runtime so the MCP client metadata stays in sync
3
+ * with the published package. Resolves the manifest relative to the module (`src/version.ts` →
4
+ * `../package.json` in the source tree; `dist/version.js` → `../package.json` when installed).
5
+ * Standalone binaries inject ALISIO_PACKAGE_VERSION at build time (scripts/binary-build.ts).
6
+ */
7
+ export declare function loadVersion(fromHere: string): string;
@@ -0,0 +1,26 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /**
5
+ * Fallback used when neither the build-time injection nor the package manifest is readable.
6
+ * A development marker, never a publish literal: it cannot silently desync from the package.
7
+ */
8
+ const FALLBACK = "dev";
9
+ /**
10
+ * Reads the @alisio/core package version at runtime so the MCP client metadata stays in sync
11
+ * with the published package. Resolves the manifest relative to the module (`src/version.ts` →
12
+ * `../package.json` in the source tree; `dist/version.js` → `../package.json` when installed).
13
+ * Standalone binaries inject ALISIO_PACKAGE_VERSION at build time (scripts/binary-build.ts).
14
+ */
15
+ export function loadVersion(fromHere) {
16
+ if (process.env.ALISIO_PACKAGE_VERSION)
17
+ return process.env.ALISIO_PACKAGE_VERSION;
18
+ try {
19
+ const manifest = join(dirname(fileURLToPath(fromHere)), "..", "package.json");
20
+ const parsed = JSON.parse(readFileSync(manifest, "utf8"));
21
+ return typeof parsed.version === "string" && parsed.version ? parsed.version : FALLBACK;
22
+ }
23
+ catch {
24
+ return FALLBACK;
25
+ }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alisio/core",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.7",
4
4
  "description": "Embeddable provider-agnostic Alisio agent core: tool loop, context compaction, local tools, MCP, plugin host and SQLite session store. Runs on Node >=22.16 and Bun.",
5
5
  "author": "Gustavo Gutiérrez",
6
6
  "license": "MIT",