Commit 0311158
feat(cli): persistent skill cache to skip prpm install on repeat launches (#124)
* feat(cli): persistent skill cache to skip prpm install on repeat launches
Every `agentworkforce agent <persona>` previously spawned a fresh
`npx prpm install …` per declared skill, even when the skill set hadn't
changed — `npx` resolution + registry lookups + tarball fetches added
several seconds of latency to every launch.
Introduce a content-addressed cache under
`~/.agentworkforce/workforce/cache/plugins/<fingerprint>/` keyed by a
SHA-256 of `(harness, sorted skill sources, local file contents)`. On a
hit, the install subprocess is skipped entirely:
- claude reuses the cache dir directly as `--plugin-dir <cacheDir>`.
- opencode / codex mirror the cache contents into the relayfile mount
before launch (mount-ignored patterns keep this from syncing back to
the user's repo).
Invalidation is conservative: changing a skill source string (or editing
a local `.md` skill) rotates the fingerprint and produces a fresh cache
entry. To force-refresh past unchanged remote sources, pass
`--refresh-skills`; to bypass the cache entirely, pass `--no-skill-cache`
or set `AGENTWORKFORCE_NO_SKILL_CACHE=1`.
`--install-in-repo` disengages caching — the user explicitly opted into
having installs land in their working tree, so mirroring a cache back
into the repo would silently re-introduce the leakage that flag is
designed to surface.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(cli): avoid duplicate 'Setting up sandbox mount' line on mount cache hit
The pure cache-hit path is a near-instant cpSync that doesn't print its own
spinner — but the surrounding setupSpinner.stop()/start() was redrawing the
"Setting up sandbox mount…" line a second time. Only stop/start the setup
spinner around branches that actually run an install spinner of their own.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feat(cli): opt-in upstream drift detection for the skill cache
The source-key fingerprint never rotates on an upstream publish when the
persona's `source` string is unchanged (floating refs like `@org/skill`
or `github.com/org/repo#x`). This adds a cheap, opt-in second check so a
new upstream version is actually consumed without a manual refresh.
Marker schema bumped to v2 (v1 stays read-compatible, upgraded in place
with no upstream records). At install time each remote skill's upstream
identity is recorded from the installer lockfiles:
- prpm → resolved `version` from prpm.lock
- skill.sh → GitHub blob SHA of the installed SKILL.md, located via
skills-lock.json `skillPath`
On launch, if the marker's `lastUpstreamCheckAt` is older than the
interval (default 24h), parallel lightweight probes compare recorded vs.
current — prpm registry GET, GitHub Contents API with `If-None-Match`
(304, no body, when unchanged). Any drift downgrades the cache hit to a
miss so the reinstall picks up the new content; the marker then
self-heals. Every probe fails OPEN: a network error, timeout, 4xx/5xx,
or malformed body counts as "no drift" so a flaky registry never blocks
or slows a launch beyond the timeout.
Control surface:
- `--check-upstream` force a probe this launch (ignore the TTL)
- `--no-check-upstream` skip the probe this launch
- `AGENTWORKFORCE_SKILL_CACHE_CHECK_INTERVAL` (24h default; `0`=always,
`never`/`off`=disable; accepts ms/s/m/h/d, bare number = hours)
Tests: 22 new persona-kit unit tests (mocked HTTP — prpm/github
success, 304, 404/5xx fail-open, timeout, mixed sets, v1→v2 migration,
marker round-trip, TTL math) + 1 CLI flag-parse test. Verified
end-to-end against live prpm.dev and api.github.com: install records
the resolved version, in-TTL launches skip probing, a tampered stale
version triggers a live-detected reinstall (1.0.0 → 1.1.3), the marker
self-heals, and --no-check-upstream bypasses.
A decision trajectory for this work is recorded under
.trajectories/completed/2026-05/traj_47ulsb0rwbid.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(cli): address PR #124 review — refresh-clean, install lock, never-interval
Four reviewer findings (CodeRabbit / Devin / cubic):
1. `AGENTWORKFORCE_SKILL_CACHE_CHECK_INTERVAL=never` was ignored:
`parseCheckInterval` returns `null` for never/off/false, but the
`?? DEFAULT` coalesced `null` back to the 24h default, silently
re-enabling drift checks the user disabled. New
`resolveEnvCheckIntervalMs()` only falls back on `undefined`.
2. `--refresh-skills` now wipes the cache dir before reinstalling, so a
refresh is a true rebuild — stale files from a prior skill version no
longer linger, and a partial-failure reinstall can't leave the old
marker behind to fake a later cache hit. Applied to both the claude
pre-mount path and the mount-deferred path.
3. Added a per-fingerprint advisory install lock
(`<cacheDir>.lock`, sibling so a refresh-wipe can't delete a live
lock). Two concurrent launches of the same persona no longer both
miss and install into the same dir. Stale/dead-pid locks are stolen;
if the wait budget is exceeded we proceed unlocked (never hang a
launch). After acquiring, validity is re-checked so a peer's
just-finished install is reused instead of redundantly reinstalled.
4. Test isolation: the parseAgentArgs flag test now saves/clears/
restores AGENTWORKFORCE_NO_SKILL_CACHE so a machine with that env set
can't flake the default-false assertions.
Tests: +5 (resolveEnvCheckIntervalMs never/default/0; lock acquire-
block-release, stale-steal, dead-pid-steal). Full repo 595/595 green.
E2E re-verified: a planted stale file is gone after --refresh-skills
and no lock file is left behind.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* stale lock check fix
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
* fix(cli): heartbeat skill cache locks
---------
Co-authored-by: Ricky Schema Cascade <ricky@agent-relay.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: kjgbot <kjgbot@agentrelay.dev>1 parent 2273032 commit 0311158
10 files changed
Lines changed: 2442 additions & 15 deletions
File tree
- .trajectories
- completed/2026-05
- packages
- cli/src
- persona-kit/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
0 commit comments