mirror of
https://github.com/chainbase-labs/Agentkey.git
synced 2026-09-20 14:20:23 +08:00
f830f2947d
## Summary
Skill-side half of the agent-install telemetry rollout (spec §8.1).
`check-update.sh` emits `TELEMETRY ...` lines on stdout, SKILL.md parses
them and dispatches via MCP. Adds 3-layer opt-out (file / env /
installer flag — file path checked here), 24h client-side dedup, and a
bats test harness.
- `skills/agentkey/scripts/check-update.sh` — `emit_telemetry()` +
`auto_upgrade_flag()` helpers, opt-out checks, 7 emit calls at 5 exit
points, 24h heartbeat dedup keyed by `LOCAL_VERSION`. Includes Linux
`stat` order fix (`-c %Y` first, `-f %m` second — `-f` on Linux means
filesystem mountpoint, not mtime)
- `skills/agentkey/SKILL.md` — Step 0 instructions for parsing
`TELEMETRY` lines and dispatching via
`execute_tool(\"agentkey_internal\", {path:\"telemetry/event\", ...})`;
upgrade-flow each branch dispatches `upgrade_decision` /
`upgrade_result` with mapped choice values
- `tests/check-update.bats` + `tests/helpers.bash` — 10 contract tests
with isolated `\$HOME` / `\$TMPDIR` / mocked curl
- `.github/workflows/scripts-test.yml` — bats CI on ubuntu + macos
- `README.md` + `docs/README_zh.md` — FAQ replacement for the old
\"nothing to collect\" sentence, new FAQ entry \"How do I opt out of
telemetry?\" / \"我如何关闭遥测?\"
- `scripts/uninstall.sh` — adds Step 7b to clean `~/.config/agentkey/`
(telemetry-disabled, update-disabled, snooze state)
## Blocked on
**AgentKey-Server PR** that registers the
`agentkey_internal/telemetry/event` MCP tool (must be filtered out of
`list_tools` / `find_tools` so the LLM doesn't accidentally call it).
SKILL.md falls back silently when the tool doesn't exist, so this PR is
safe to merge first — but the telemetry signal isn't recorded until the
server side lands.
Spec §11 mandates server-first merge order to keep the agent-side debug
log clean.
## Test plan
- [x] `bats tests/check-update.bats` — 10/10 passing locally
- [x] E2E smoke (skill-side plan Task 8 steps 1-3, 5):
- Default emit on `up_to_date`
- `~/.config/agentkey/telemetry-disabled` early-return (no TELEMETRY
line)
- `AGENTKEY_TELEMETRY=0` env override
- 24h heartbeat dedup (2nd invocation within window does not re-emit)
- `uninstall.sh` Step 7b cleans `~/.config/agentkey/`
- [ ] **Manual** — open Claude Code, ask an AgentKey-routed query.
Verify SKILL.md silently swallows the missing `agentkey_internal` tool
error (server not shipped yet) and the actual query still completes
- [ ] Verify bats CI runs green on ubuntu + macos matrix
## Pre-existing bug surfaced during testing (not in this PR)
`check-update.sh` line 130-ish cache fast-path uses the same wrong `stat
-f %m ... || stat -c %Y` order. Same Linux bug as the one fixed here in
`emit_telemetry`. Worth a separate one-line fix PR.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: lxcong <lxcong@chainbase.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>