Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

feat(local-installation): allow running a local localmodels checkout in dev

Dongdong Chen14f50c629598
diff --git a/apps/desktop/AGENTS.md b/apps/desktop/AGENTS.md
index 5800c40e..d436fbcd 100644
--- a/apps/desktop/AGENTS.md
+++ b/apps/desktop/AGENTS.md
@@ -369,5 +369,11 @@ building a package.
`runtimeEnvironment` (the local server's runtime: these paths plus
`CODEX_HOME`, `CLAUDE_CONFIG_DIR`, `PI_CODING_AGENT_DIR`) replaces them,
names compared case-insensitively for Windows.
+- `LINGER_LOCALMODELS_DEV_PYTHON`, `LINGER_LOCALMODELS_DEV_MODULE_DIR`:
+ absolute Python and module directory for running a local `localmodels`
+ checkout in Quick Install and the Desktop Computer without fetching the
+ published kit. `LOCALMODELS_DEBUG` (`simulate` or `tiny`) or
+ `~/.config/localmodels/debug.json` enables fast local-model testing in both
+ source and packaged builds.
- Without a display, run with `--ozone-platform=headless --disable-gpu`. The
tray and native menus are skipped in that mode; use Xvfb to check them.
diff --git a/packages/local-installation/AGENTS.md b/packages/local-installation/AGENTS.md
index 250a2993..5ab63538 100644
--- a/packages/local-installation/AGENTS.md
+++ b/packages/local-installation/AGENTS.md
@@ -78,6 +78,11 @@ Move a freshly downloaded or unpacked file or folder into place with
`renameRetrying` from `fs-retry.ts`: on Windows antivirus and indexing hold
new files for a moment, and a plain rename then fails with EPERM.
+Setting `LINGER_LOCALMODELS_DEV_PYTHON` and `LINGER_LOCALMODELS_DEV_MODULE_DIR`
+to absolute paths runs a local `localmodels` checkout instead of fetching the
+published kit, and `LOCALMODELS_DEBUG` (`simulate` or `tiny`, or
+`~/.config/localmodels/debug.json`) passes straight through to `localmodels`.
+
Run `pnpm --filter @linger/local-installation check`; `make check-installer`
also runs its consumer, the installer, and applies to changes that affect its
public behavior.
diff --git a/packages/local-installation/src/localmodels-tool.test.ts b/packages/local-installation/src/localmodels-tool.test.ts
index fece3252..7c3df438 100644
--- a/packages/local-installation/src/localmodels-tool.test.ts
+++ b/packages/local-installation/src/localmodels-tool.test.ts
@@ -538,3 +538,24 @@ test("forwards safe extraction and verification stages after Harness downloads f
});
expect(JSON.stringify(onEvent.mock.calls)).not.toContain("private-secret");
});
+test("uses a configured development localmodels checkout without downloading a kit", async () => {
+ const f = await fixture();
+ vi.stubEnv("LINGER_LOCALMODELS_TOOL_JSON", "");
+ vi.stubEnv(
+ "LINGER_LOCALMODELS_DEV_PYTHON",
+ path.join(f.directory, "python/python"),
+ );
+ vi.stubEnv(
+ "LINGER_LOCALMODELS_DEV_MODULE_DIR",
+ path.join(f.directory, "modules"),
+ );
+ const run = vi.fn(async () => ({ code: 0, stdout: "{}", stderr: "" }));
+ await runLocalmodels(f.home, ["debug", "status", "--json"], {}, { run });
+ expect(run).toHaveBeenCalledWith(
+ path.join(f.directory, "python/python"),
+ ["-P", "-s", "-m", "localmodels", "debug", "status", "--json"],
+ expect.objectContaining({
+ cwd: path.join(f.directory, "modules"),
+ }),
+ );
+});
diff --git a/packages/local-installation/src/localmodels-tool.ts b/packages/local-installation/src/localmodels-tool.ts
index 9b7435ca..cd1fa8fe 100644
--- a/packages/local-installation/src/localmodels-tool.ts
+++ b/packages/local-installation/src/localmodels-tool.ts
@@ -367,13 +367,30 @@ async function prepareLocalmodelsTool(
}
type ToolLocation = Awaited<ReturnType<typeof prepareLocalmodelsTool>>;
const preparing = new Map<string, Promise<ToolLocation>>();
+function configuredDevTool(): ToolLocation | undefined {
+ const python = process.env.LINGER_LOCALMODELS_DEV_PYTHON?.trim();
+ const moduleDir = process.env.LINGER_LOCALMODELS_DEV_MODULE_DIR?.trim();
+ if (!python || !moduleDir) return undefined;
+ if (!path.isAbsolute(python) || !path.isAbsolute(moduleDir))
+ throw new Error(
+ "LINGER_LOCALMODELS_DEV_PYTHON and LINGER_LOCALMODELS_DEV_MODULE_DIR must be absolute paths.",
+ );
+ return { python, moduleDir, sourceCommit: "0".repeat(40) };
+}
export async function ensureLocalmodelsTool(
home: string,
options: Options = {},
dependencies: { source?: LocalmodelsToolSource; fetcher?: typeof fetch } = {},
): Promise<ToolLocation> {
options.signal?.throwIfAborted();
- const key = `${path.resolve(home)}:${JSON.stringify(dependencies.source ?? process.env.LINGER_LOCALMODELS_TOOL_JSON)}`;
+ const devTool = configuredDevTool();
+ if (
+ devTool &&
+ (!dependencies.source ||
+ dependencies.source.url.startsWith("https://dev.invalid/"))
+ )
+ return devTool;
+ const key = `${path.resolve(home)}:${JSON.stringify(dependencies.source ?? pinnedToolSource())}`;
const running = preparing.get(key);
if (running) {
const result = await running;
@@ -542,6 +559,7 @@ export async function stopLocalmodels(
if (failed.length) throw new Error(failed.join("; "));
}
async function hasPinnedTool(home: string): Promise<boolean> {
+ if (configuredDevTool()) return true;
const source = pinnedToolSource();
if (!source) return false;
return !!(await installedKit(kitDirectory(home, source), source).catch(
@@ -550,6 +568,15 @@ async function hasPinnedTool(home: string): Promise<boolean> {
}
/** The kit this release pins, from the installer's published metadata. */
function pinnedToolSource(): LocalmodelsToolSource | undefined {
+ if (configuredDevTool()) {
+ return {
+ url: "https://dev.invalid/localmodels.tgz",
+ sha256: "0".repeat(64),
+ bytes: 1,
+ sourceCommit: "0".repeat(40),
+ manifestSha256: "0".repeat(64),
+ };
+ }
const raw = process.env.LINGER_LOCALMODELS_TOOL_JSON;
return raw ? validateToolSource(JSON.parse(raw)) : undefined;
}
diff --git a/scripts/env-inventory.json b/scripts/env-inventory.json
index d76d2f32..399142b2 100644
--- a/scripts/env-inventory.json
+++ b/scripts/env-inventory.json
@@ -119,6 +119,8 @@
"PYTHONSTARTUP",
"LINGER_COMPUTER_BIN",
"LINGER_HOME",
+ "LINGER_LOCALMODELS_DEV_MODULE_DIR",
+ "LINGER_LOCALMODELS_DEV_PYTHON",
"LINGER_LOCALMODELS_TOOL_JSON",
"LINGER_NATIVE_DEPENDENCIES_JSON",
"LINGER_NATIVE_VOICE_TOOLS_JSON"