You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@rivus/agent-kit 0.7.0 / @rivus/agent-kit-collab 0.7.0 now maintain the coding-agent knowledge this package duplicates, and the copies have drifted (agent-presence #85 timeout units, #86 Gemini event names):
Usage scanning for 6 sources in src/usage/ (scan-claude.ts, scan-codex.ts, scan-gemini.ts, scan-opencode.ts, scan-pi.ts, scan-dsh.ts), with dedup / replay-skip / cache-split / reasoning-fold rules in read-jsonl.ts and index.ts.
The pricing formula in src/usage/pricing.ts next to the committed LiteLLM snapshot src/usage/litellm-pricing.json.
Hook payload dialects for six agents in src/hooks/ and lifecycle reduce in src/state.ts (normalizeEvent / applyAgentEvent).
Install / uninstall / verify across agents: src/installers.ts, the scripts/install-* / uninstall-* scripts, orchestrated by src/setup.ts, JSON editing in src/json-file.ts.
Two hand-rolled locks: the mkdir lock withStateLock in src/state.ts and the hardlink owner-token lock in src/log-retention.ts.
src/cli/app.ts statically imports the setup command, so every hook invocation loads all installer code (plain tsc build, no bundling).
Proposed Solution
Adoption per the kit's docs/development/adoption.md ("Presence"), pinning both packages at 0.7.0 (lockstep release) in the lockfile, split into PRs by kit area. Each PR replaces the old code it covers, deletes it and carries its own old/new evidence; PRs are reviewed and merged by the owner one at a time. The repo's lint-config v0.6.0 and Vite+ issues land first, and this repo is finished before the next one starts.
Before starting: settle the open PRs that touch the same code (#83 dsh lifecycle mapping, #84 pricing snapshot). Order:
Vite+ ([Task]: Move the toolchain to Vite+ #91): vp pack replaces the tsc build; keep dist/src/cli.js (the bin target and the legacy hook marker dist/src/cli.js hook).
Process lock: step 5 below (first kit dependency, so it also bumps engines.node and adds minimumReleaseAgeExclude if the repo has a release-age rule).
After merge: the owner merges the release PR; real-home upgrade and real Cursor/Codex checks only with the owner's go.
Steps:
Replace the five agent scanners with /transcript/usage (scanUsage, decodeUsage, listUsageSources) and the pricing formula with /cost (createPricing, costOf). The dsh scanner stays — it reads presence's own usage-events protocol, which the kit does not cover; the kit adds Grok, which presence does not scan today. Keep the LiteLLM snapshot, scripts/update-pricing.mjs and the weekly workflow, injecting the table into /cost; persist UsageScanState with the same since window across scans.
Split hook and setup build outputs first (today plain tsc): bundle a hook entry whose import graph contains neither setup nor effect, and measure its cold start. A static setup import anywhere in the hook graph defeats the split.
Hook: use /harness/events (readHookEvent, reduceLifecycle, heartbeatSignal, builtinHookDialects) in place of src/hooks/*; keep the online-state policy in src/state.ts; respect the dialect's permission semantics — an observer must not silently block a gate.
Setup: use /harness — planInstall (display changes, commands, expectedTrustPrompts, droppedHooks; resolve only allowed conflicts; re-plan after restart) then applyInstall with the same plan handle; expose verify, doctor, inventory, uninstall. Supply the Bundle (owner, version, digest, hooks/skills, legacy command markers) so old hooks are replaced, and keep the shim command stable with {agent}. This is the only Effect touchpoint: a one-shot Effect.runPromiseExit mapping failure to the CLI exit code, with effect@4.0.1 as the exact peer.
Replace the mkdir withStateLock with collab /process-lock (acquireProcessLock, handle ProcessLockHeld, release on exit); the log-retention lock can follow.
Stays in presence: dsh source plugin and usage-events log, badge/window rendering and the state cache, source-plugin mechanism, provider backends, keyring, power watcher.
Acceptance Criteria
usage-ccusage-parity, usage-scan*, usage-pricing tests pass ported onto the kit entries.
On real local logs, old and new token and cost totals are equal per agent over the same window and price table — covering self-reported cost, one-hour cache writes and the priority multiplier — after accounting for scan finalization of still-running sources.
Install / verify / uninstall pass under an isolated HOME; old hooks are replaced; verify and doctor report no new/legacy duplicate hooks.
Hook cold start is measured and not slower than today; the hook dist imports no setup or effect code.
Two processes contending for the state lock: one holder, the other gets ProcessLockHeld; recovery after the holder is killed.
The duplicated modules are deleted: src/usage/scan-{claude,codex,gemini,opencode,pi}.ts, src/usage/pricing.ts, src/hooks/*, src/installers.ts, scripts/install-*/uninstall-*, the mkdir lock.
engines.node bumped to >=22.13 (kit's Node adapters requirement; the repo currently allows >=22).
Problem
@rivus/agent-kit0.7.0 /@rivus/agent-kit-collab0.7.0 now maintain the coding-agent knowledge this package duplicates, and the copies have drifted (agent-presence #85 timeout units, #86 Gemini event names):src/usage/(scan-claude.ts,scan-codex.ts,scan-gemini.ts,scan-opencode.ts,scan-pi.ts,scan-dsh.ts), with dedup / replay-skip / cache-split / reasoning-fold rules inread-jsonl.tsandindex.ts.src/usage/pricing.tsnext to the committed LiteLLM snapshotsrc/usage/litellm-pricing.json.src/hooks/and lifecycle reduce insrc/state.ts(normalizeEvent/applyAgentEvent).src/installers.ts, thescripts/install-*/uninstall-*scripts, orchestrated bysrc/setup.ts, JSON editing insrc/json-file.ts.withStateLockinsrc/state.tsand the hardlink owner-token lock insrc/log-retention.ts.src/cli/app.tsstatically imports the setup command, so every hook invocation loads all installer code (plaintscbuild, no bundling).Proposed Solution
Adoption per the kit's
docs/development/adoption.md("Presence"), pinning both packages at 0.7.0 (lockstep release) in the lockfile, split into PRs by kit area. Each PR replaces the old code it covers, deletes it and carries its own old/new evidence; PRs are reviewed and merged by the owner one at a time. The repo's lint-config v0.6.0 and Vite+ issues land first, and this repo is finished before the next one starts.Before starting: settle the open PRs that touch the same code (#83 dsh lifecycle mapping, #84 pricing snapshot). Order:
vp packreplaces thetscbuild; keepdist/src/cli.js(thebintarget and the legacy hook markerdist/src/cli.js hook).engines.nodeand addsminimumReleaseAgeExcludeif the repo has a release-age rule)./harness: step 4 (closes [Bug]: Claude Code hooks get a 5000-second timeout #85, [Bug]: Gemini CLI hooks use Claude Code event names #86; [Bug]: Cursor may block every tool call through the Claude PreToolUse hook #89 across 6 and 7).Steps:
/transcript/usage(scanUsage,decodeUsage,listUsageSources) and the pricing formula with/cost(createPricing,costOf). The dsh scanner stays — it reads presence's own usage-events protocol, which the kit does not cover; the kit adds Grok, which presence does not scan today. Keep the LiteLLM snapshot,scripts/update-pricing.mjsand the weekly workflow, injecting the table into/cost; persistUsageScanStatewith the samesincewindow across scans.tsc): bundle a hook entry whose import graph contains neither setup noreffect, and measure its cold start. A static setup import anywhere in the hook graph defeats the split./harness/events(readHookEvent,reduceLifecycle,heartbeatSignal,builtinHookDialects) in place ofsrc/hooks/*; keep the online-state policy insrc/state.ts; respect the dialect's permission semantics — an observer must not silently block a gate./harness—planInstall(displaychanges,commands,expectedTrustPrompts,droppedHooks; resolve only allowed conflicts; re-plan after restart) thenapplyInstallwith the same plan handle; exposeverify,doctor,inventory,uninstall. Supply theBundle(owner, version, digest, hooks/skills, legacy command markers) so old hooks are replaced, and keep the shim command stable with{agent}. This is the only Effect touchpoint: a one-shotEffect.runPromiseExitmapping failure to the CLI exit code, witheffect@4.0.1as the exact peer.withStateLockwith collab/process-lock(acquireProcessLock, handleProcessLockHeld, release on exit); the log-retention lock can follow.Acceptance Criteria
usage-ccusage-parity,usage-scan*,usage-pricingtests pass ported onto the kit entries.HOME; old hooks are replaced;verifyanddoctorreport no new/legacy duplicate hooks.HOME: new install → new uninstall → old install/setup fires each event once; Codex does not re-ask trust after an upgrade; the Cursor gate issue [Bug]: Cursor may block every tool call through the Claude PreToolUse hook #89 is checked and handled.effectcode.ProcessLockHeld; recovery after the holder is killed.src/usage/scan-{claude,codex,gemini,opencode,pi}.ts,src/usage/pricing.ts,src/hooks/*,src/installers.ts,scripts/install-*/uninstall-*, the mkdir lock.engines.nodebumped to >=22.13 (kit's Node adapters requirement; the repo currently allows >=22).