feat: session-first workspace activity and installable daemon
Workspaces page: - list the newest sessions across workspaces in the activity column; the daemon exposes GET /api/v1/sessions/recent as a disk projection and the browser enriches live rows from the per-workspace session relay - put recent activity first below 1100px and fix the mobile page-header flex-basis gap Smoke: - pin PI2_HOST=127.0.0.1 in both smoke scripts and make the startup-line assertion follow the configured host; the daemon default stays 0.0.0.0 Install: - standalone binary build/install scripts, packaging templates, CI/release hooks, CLI-first install docs and the supporting config/doctor changes
This commit is contained in:
1 parent
fc51c3be37
commit
d2e20d428a
50 files changed
+5104
-188
No files matched your search
@@ -0,0 +1,47 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, isAbsolute, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import {
|
||||
defaultStaticDir,
|
||||
executablePath,
|
||||
isBundledRuntime,
|
||||
runtimeDescription,
|
||||
staticDirCandidates,
|
||||
version,
|
||||
} from "../../src/core/install.js";
|
||||
|
||||
describe("install helpers", () => {
|
||||
it("reports version matching package.json when running from a checkout", () => {
|
||||
const pkgPath = fileURLToPath(new URL("../../package.json", import.meta.url));
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, "utf8")) as { version: string };
|
||||
expect(version()).toBe(pkg.version);
|
||||
});
|
||||
|
||||
it("returns three absolute candidates with share/pi2d/web/dist first", () => {
|
||||
const candidates = staticDirCandidates();
|
||||
expect(candidates).toHaveLength(3);
|
||||
for (const candidate of candidates) {
|
||||
expect(isAbsolute(candidate)).toBe(true);
|
||||
}
|
||||
const exeDir = dirname(executablePath());
|
||||
const expectedFirst = resolve(exeDir, "..", "share", "pi2d", "web", "dist");
|
||||
expect(candidates[0]).toBe(expectedFirst);
|
||||
});
|
||||
|
||||
it("resolves defaultStaticDir without throwing and returns dev checkout web/dist", () => {
|
||||
expect(() => defaultStaticDir()).not.toThrow();
|
||||
const dir = defaultStaticDir();
|
||||
expect(isAbsolute(dir)).toBe(true);
|
||||
const expectedDevPath = resolve(fileURLToPath(new URL("../../web/dist", import.meta.url)));
|
||||
expect(dir).toBe(expectedDevPath);
|
||||
});
|
||||
|
||||
it("reports isBundledRuntime as false under vitest", () => {
|
||||
expect(isBundledRuntime()).toBe(false);
|
||||
});
|
||||
|
||||
it("reports runtimeDescription starting with 'node '", () => {
|
||||
expect(runtimeDescription().startsWith("node ")).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { piAgentDir, sessionsRoot } from "../../src/core/paths.js";
|
||||
|
||||
describe("piAgentDir and sessionsRoot", () => {
|
||||
const originalEnv = { ...process.env };
|
||||
|
||||
afterEach(() => {
|
||||
process.env = { ...originalEnv };
|
||||
});
|
||||
|
||||
it("prefers PI2_CODING_AGENT_DIR when both PI2_ and PI_ are set", () => {
|
||||
const env = {
|
||||
PI2_CODING_AGENT_DIR: "/custom/pi2/agent",
|
||||
PI_CODING_AGENT_DIR: "/custom/pi/agent",
|
||||
};
|
||||
expect(piAgentDir(env)).toBe("/custom/pi2/agent");
|
||||
expect(sessionsRoot(env)).toBe(join("/custom/pi2/agent", "sessions"));
|
||||
});
|
||||
|
||||
it("uses PI_CODING_AGENT_DIR when PI2_CODING_AGENT_DIR is unset", () => {
|
||||
const env = {
|
||||
PI_CODING_AGENT_DIR: "/custom/pi/agent",
|
||||
};
|
||||
expect(piAgentDir(env)).toBe("/custom/pi/agent");
|
||||
expect(sessionsRoot(env)).toBe(join("/custom/pi/agent", "sessions"));
|
||||
});
|
||||
|
||||
it("falls back to ~/.pi/agent when neither variable is set", () => {
|
||||
const env = {};
|
||||
const expected = join(homedir(), ".pi", "agent");
|
||||
expect(piAgentDir(env)).toBe(expected);
|
||||
expect(piAgentDir(env).endsWith(join(".pi", "agent"))).toBe(true);
|
||||
expect(sessionsRoot(env)).toBe(join(expected, "sessions"));
|
||||
});
|
||||
|
||||
it("falls through empty strings to the next candidate", () => {
|
||||
// PI2 is empty string -> falls through to PI
|
||||
expect(
|
||||
piAgentDir({
|
||||
PI2_CODING_AGENT_DIR: "",
|
||||
PI_CODING_AGENT_DIR: "/custom/pi/agent",
|
||||
}),
|
||||
).toBe("/custom/pi/agent");
|
||||
|
||||
// Both are empty strings -> falls through to ~/.pi/agent
|
||||
const expected = join(homedir(), ".pi", "agent");
|
||||
expect(
|
||||
piAgentDir({
|
||||
PI2_CODING_AGENT_DIR: "",
|
||||
PI_CODING_AGENT_DIR: "",
|
||||
}),
|
||||
).toBe(expected);
|
||||
|
||||
// PI2 unset, PI is empty string -> falls through to ~/.pi/agent
|
||||
expect(
|
||||
piAgentDir({
|
||||
PI_CODING_AGENT_DIR: "",
|
||||
}),
|
||||
).toBe(expected);
|
||||
});
|
||||
|
||||
it("handles relative paths without crashing", () => {
|
||||
const relative = "some/relative/agent";
|
||||
expect(piAgentDir({ PI2_CODING_AGENT_DIR: relative })).toBe(relative);
|
||||
expect(sessionsRoot({ PI2_CODING_AGENT_DIR: relative })).toBe(join(relative, "sessions"));
|
||||
|
||||
expect(piAgentDir({ PI_CODING_AGENT_DIR: relative })).toBe(relative);
|
||||
expect(sessionsRoot({ PI_CODING_AGENT_DIR: relative })).toBe(join(relative, "sessions"));
|
||||
});
|
||||
|
||||
it("respects daemon ambient environment injection via process.env", () => {
|
||||
delete process.env.PI2_CODING_AGENT_DIR;
|
||||
delete process.env.PI_CODING_AGENT_DIR;
|
||||
|
||||
process.env.PI2_CODING_AGENT_DIR = "/daemon/injected/pi2";
|
||||
expect(piAgentDir()).toBe("/daemon/injected/pi2");
|
||||
expect(sessionsRoot()).toBe(join("/daemon/injected/pi2", "sessions"));
|
||||
|
||||
process.env.PI_CODING_AGENT_DIR = "/daemon/injected/pi";
|
||||
// PI2 still wins
|
||||
expect(piAgentDir()).toBe("/daemon/injected/pi2");
|
||||
|
||||
// When PI2 is empty string in process.env, falls through to PI
|
||||
process.env.PI2_CODING_AGENT_DIR = "";
|
||||
expect(piAgentDir()).toBe("/daemon/injected/pi");
|
||||
|
||||
// When both are empty string in process.env, falls through to default
|
||||
process.env.PI_CODING_AGENT_DIR = "";
|
||||
expect(piAgentDir()).toBe(join(homedir(), ".pi", "agent"));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user