feat(cli)!: merge the daemon into pi2 as the daemon subcommand
`pi2 daemon [start] [flags]` now starts the web-console daemon. The `pi2d` executable, its bin entry and its entry module are removed: the daemon keeps its lock -> token -> plugin socket -> listen -> daemon.json lifecycle, its single stdout line (`pi2 daemon listening on ...`) and the signal handling that leaves managed nvim instances running. Service files are renamed to `pi2.service` / `com.pi2.daemon`, and the smoke and e2e harnesses start the daemon through `pi2 daemon`. BREAKING CHANGE: the `pi2d` command no longer exists; use `pi2 daemon` (or `pi2 daemon start`). Existing systemd/launchd units installed under the old names must be reinstalled with `pi2 install-service --write`.
This commit is contained in:
1 parent
b02f4e9070
commit
7e780515ac
38 files changed
+295
-232
No files matched your search
@@ -49,6 +49,9 @@ const STATE_DIR = process.env.PI2_STATE_DIR ?? join(E2E_ROOT, "state");
|
||||
const WS_URL = `${BASE.replace(/^http/, "ws")}/ws`;
|
||||
const REPORT_DIR = join(E2E_ROOT, "report");
|
||||
const RECON_REPORT = process.env.E2E_RECON_REPORT ?? "/tmp/pi2-e2e-recon/e2e-api-run.md";
|
||||
// Repository root (this driver lives in `<repo>/scripts/e2e/`), so the reports
|
||||
// can print a reproducible command without hardcoding a checkout path.
|
||||
const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
|
||||
const TURN_MS = 120_000;
|
||||
const ABORT_SETTLE_MS = 10_000;
|
||||
@@ -2907,12 +2910,12 @@ function collectLogTails() {
|
||||
const tail = tailOf(path);
|
||||
if (tail) targets.push({ label, path, tail });
|
||||
};
|
||||
push("daemon", join(E2E_ROOT, "logs", "pi2d.log"));
|
||||
push("daemon.stdout", join(E2E_ROOT, "logs", "pi2d.stdout"));
|
||||
push("daemon", join(E2E_ROOT, "logs", "daemon.log"));
|
||||
push("daemon.stdout", join(E2E_ROOT, "logs", "daemon.stdout"));
|
||||
for (const path of findLogs(join(STATE_DIR, "instances"))) push(`instance ${path.split("/").slice(-2).join("/")}`, path);
|
||||
for (const path of findLogs(STATE_DIR)) {
|
||||
if (targets.some((target) => target.path === path)) continue;
|
||||
if (/pi2-web|pi2d|instance/.test(path)) push(`state ${path.split("/").slice(-2).join("/")}`, path);
|
||||
if (/pi2-web|pi2-daemon|instance/.test(path)) push(`state ${path.split("/").slice(-2).join("/")}`, path);
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
@@ -2952,14 +2955,14 @@ function renderSummaryMarkdown(results, counts, durationMs) {
|
||||
lines.push("## Reproduction");
|
||||
lines.push("");
|
||||
lines.push("```bash");
|
||||
lines.push("cd /home/yuez/Workspace/Neovim/pi2d && E2E_SKIP_BUILD=1 bash scripts/e2e/run-api.sh");
|
||||
lines.push(`cd "${REPO_ROOT}" && E2E_SKIP_BUILD=1 bash scripts/e2e/run-api.sh`);
|
||||
lines.push("```");
|
||||
return `${lines.join("\n")}\n`;
|
||||
}
|
||||
|
||||
function renderReconMarkdown(results, counts, durationMs, logs) {
|
||||
const lines = [];
|
||||
lines.push("# pi2d API/WS E2E (A0–A12) — run report");
|
||||
lines.push("# pi2 daemon API/WS E2E (A0–A12) — run report");
|
||||
lines.push("");
|
||||
lines.push(`- driver: \`${join(dirname(fileURLToPath(import.meta.url)), "api-e2e.mjs")}\``);
|
||||
lines.push(`- base: \`${BASE}\` · root: \`${E2E_ROOT}\``);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Test-only pi extension for the pi2d API/WS end-to-end suite (docs/e2e.md A11).
|
||||
* Test-only pi extension for the pi2 daemon API/WS end-to-end suite (docs/e2e.md A11).
|
||||
*
|
||||
* The suite must prove the pre-execution attention/diff contract without a real
|
||||
* terminal UI:
|
||||
@@ -18,7 +18,7 @@
|
||||
*
|
||||
* The title payload uses the web console's documented diff shape
|
||||
* `{toolName, files:[{path, before, after}]}` (see
|
||||
* `pi2d/web/src/features/chat/diff.ts:diffFilesFromPayload`), so the same JSON
|
||||
* `web/src/features/chat/diff.ts:diffFilesFromPayload`), so the same JSON
|
||||
* drives both the plugin's attention classification and the web diff view.
|
||||
*
|
||||
* Determinism: the select is issued from the tool call (no timing tricks). A
|
||||
|
||||
@@ -30,7 +30,7 @@ fail() {
|
||||
echo "--- daemon log ---"; tail -60 "$LOG" 2>/dev/null || true
|
||||
echo "--- instance logs ---"; ls -la "$STATE/instances" 2>/dev/null || true; tail -80 "$STATE"/instances/*.log 2>/dev/null || true
|
||||
echo "--- nvim web log ---"; find "$STATE" -name 'pi2-web.log' -exec tail -80 {} \; 2>/dev/null || true
|
||||
echo "--- processes ---"; ps -eo pid,ppid,etime,args | grep -E "nvim|pi --mode|node .*pi2d" | grep -v grep || true
|
||||
echo "--- processes ---"; ps -eo pid,ppid,etime,args | grep -E "nvim|pi --mode|node .*pi2\.js daemon" | grep -v grep || true
|
||||
echo "--- sessions endpoint ---"; curl -sS -H "Authorization: Bearer $TOKEN" "$BASE/api/v1/workspaces/$WSID/sessions" 2>/dev/null | head -c 2000 || true
|
||||
echo
|
||||
echo "--- state ---"; ls -la "$STATE" "$RUN" 2>/dev/null || true
|
||||
@@ -39,13 +39,13 @@ fail() {
|
||||
|
||||
command -v jq >/dev/null || { echo "jq is required"; exit 2; }
|
||||
command -v pi >/dev/null || { echo "pi CLI is required"; exit 2; }
|
||||
[ -f "$REPO/dist/cli/pi2d.js" ] || { echo "run: npx tsc -p tsconfig.json"; exit 2; }
|
||||
[ -f "$REPO/dist/cli/pi2.js" ] || { echo "run: npx tsc -p tsconfig.json"; exit 2; }
|
||||
|
||||
echo "==> workspace $WS"
|
||||
printf '# e2e\n' > "$WS/README.md"
|
||||
|
||||
echo "==> starting pi2d"
|
||||
node "$REPO/dist/cli/pi2d.js" --foreground --port 0 >"$LOG" 2>&1 &
|
||||
echo "==> starting pi2 daemon"
|
||||
node "$REPO/dist/cli/pi2.js" daemon --foreground --port 0 >"$LOG" 2>&1 &
|
||||
DPID=$!
|
||||
cleanup() {
|
||||
kill "$DPID" 2>/dev/null || true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-- Init used by the pi2d end-to-end harness.
|
||||
-- Init used by the pi2 daemon end-to-end harness.
|
||||
-- Minimal, hermetic: only the plugin under test on the runtimepath, with the
|
||||
-- web console enabled and diagnostics enabled. Setting up the plugin here also
|
||||
-- makes `pi.host` skip its own `setup()` call.
|
||||
|
||||
+7
-7
@@ -71,8 +71,8 @@ e2e_init() {
|
||||
[ -n "$E2E_NVIM_BIN" ] || e2e_fail "nvim not found"
|
||||
[ -f "$E2E_PLUGIN/lua/pi/web/commands.lua" ] ||
|
||||
e2e_fail "plugin worktree has no web layer: $E2E_PLUGIN"
|
||||
[ -f "$E2E_REPO/dist/cli/pi2d.js" ] ||
|
||||
e2e_fail "dist/cli/pi2d.js missing; run e2e_build"
|
||||
[ -f "$E2E_REPO/dist/cli/pi2.js" ] ||
|
||||
e2e_fail "dist/cli/pi2.js missing; run e2e_build"
|
||||
[ -f "$E2E_REPO/scripts/e2e/host-init.lua" ] || e2e_fail "host-init.lua missing"
|
||||
|
||||
e2e_log "==> $suite root: $E2E_ROOT"
|
||||
@@ -95,12 +95,12 @@ e2e_build() {
|
||||
|
||||
# Wait until the daemon publishes run/daemon.json, then environment-ready.
|
||||
e2e_start_daemon() {
|
||||
local log="$E2E_ROOT/logs/pi2d.log"
|
||||
local log="$E2E_ROOT/logs/daemon.log"
|
||||
: >"$log"
|
||||
e2e_log "==> starting pi2d (isolated, port 0)"
|
||||
e2e_log "==> starting pi2 daemon (isolated, port 0)"
|
||||
# `exec` makes $! the node process itself, not the wrapping subshell, so
|
||||
# the trap can actually stop the daemon.
|
||||
(cd "$E2E_REPO" && exec node dist/cli/pi2d.js --foreground >"$E2E_ROOT/logs/pi2d.stdout" 2>"$log") &
|
||||
(cd "$E2E_REPO" && exec node dist/cli/pi2.js daemon --foreground >"$E2E_ROOT/logs/daemon.stdout" 2>"$log") &
|
||||
E2E_DAEMON_PID=$!
|
||||
export E2E_DAEMON_PID
|
||||
|
||||
@@ -109,7 +109,7 @@ e2e_start_daemon() {
|
||||
[ -f "$PI2_RUNTIME_DIR/daemon.json" ] && break
|
||||
kill -0 "$E2E_DAEMON_PID" 2>/dev/null || {
|
||||
tail -40 "$log" >&2 || true
|
||||
e2e_fail "pi2d exited before writing daemon.json"
|
||||
e2e_fail "pi2 daemon exited before writing daemon.json"
|
||||
}
|
||||
sleep 0.05
|
||||
done
|
||||
@@ -202,7 +202,7 @@ e2e_pids() {
|
||||
local pid
|
||||
{
|
||||
ps -eo pid=,args= | grep -F -- "$E2E_ROOT" | grep -v -F -- 'grep -F' | awk '{print $1}' || true
|
||||
for pid in $(pgrep -f 'pi2d|pi\.host|pi --mode rpc|nvim --headless' 2>/dev/null || true); do
|
||||
for pid in $(pgrep -f 'pi2\.js daemon|pi\.host|pi --mode rpc|nvim --headless' 2>/dev/null || true); do
|
||||
if tr '\0' '\n' <"/proc/$pid/environ" 2>/dev/null |
|
||||
grep -Fxq "PI2_RUNTIME_DIR=$PI2_RUNTIME_DIR"; then
|
||||
echo "$pid"
|
||||
|
||||
@@ -62,7 +62,7 @@ fs.mkdirSync(SCREENS, { recursive: true });
|
||||
fs.mkdirSync(REPORT_DIR, { recursive: true });
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* playwright resolution (not a pi2d dependency) */
|
||||
/* playwright resolution (not a daemon dependency) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
const require_ = createRequire(import.meta.url);
|
||||
@@ -1568,7 +1568,7 @@ scenario("B7", "Abort: slow prompt → Abort button → Idle within 10 s, partia
|
||||
ctx.note(`abort status label: ${abortStatusLabel || "(none)"}`);
|
||||
|
||||
const partial = (await streamArticles(page)).filter((article) => article.role === "assistant");
|
||||
ctx.check("partial assistant text remains", partial.length >= 1 && partial[0].text.length > 0, {
|
||||
ctx.check("partial assistant text remains", partial.some((article) => article.text.length > 0), {
|
||||
expected: ">=1 assistant article with text",
|
||||
observed: partial.map((article) => short(article.text, 80)),
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ export PI2_NVIM_BIN="${PI2_NVIM_BIN:-$(command -v nvim)}"
|
||||
export PI2_NVIM_INIT="$REPO/scripts/e2e/host-init.lua"
|
||||
export PI2_E2E_PLUGIN="${PI2_E2E_PLUGIN:-/home/yuez/Workspace/Neovim/pi2.nvim-web}"
|
||||
|
||||
node "$REPO/dist/cli/pi2d.js" --foreground --port 0 >"$LOG" 2>&1 &
|
||||
node "$REPO/dist/cli/pi2.js" daemon --foreground --port 0 >"$LOG" 2>&1 &
|
||||
DPID=$!
|
||||
cleanup() { kill "$DPID" 2>/dev/null || true; wait "$DPID" 2>/dev/null || true; }
|
||||
trap cleanup EXIT
|
||||
|
||||
Reference in new issue
Block a user