From f97394656c7c358edd495b1ea133a7eb00c3e2e4 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Sat, 21 Mar 2026 18:47:54 +0200 Subject: [PATCH] cross-skill opt-out and gather system info via shell - "Never ask again" now removes diagnostics from both skills - Added shell commands to gather version, platform, arch, node version - Show only properties object to user, not api_key/distinct_id - Write full PostHog payload to temp file, send with curl -d @file Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/skills/setup/diagnostics.md | 42 ++++++++++------- .claude/skills/update-nanoclaw/diagnostics.md | 45 ++++++++++++------- 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/.claude/skills/setup/diagnostics.md b/.claude/skills/setup/diagnostics.md index deb6509..2511d06 100644 --- a/.claude/skills/setup/diagnostics.md +++ b/.claude/skills/setup/diagnostics.md @@ -2,15 +2,26 @@ After setup is complete, offer to send anonymous diagnostics. -## 1. Write the event +## 1. Gather system info -Write a JSON file to `/tmp/nanoclaw-diagnostics.json` with the setup outcome. Use only non-identifying information — no paths, usernames, hostnames, or IP addresses. +```bash +node -p "require('./package.json').version" +uname -s +uname -m +node -p "process.versions.node.split('.')[0]" +``` + +## 2. Write the event + +Write a JSON file to `/tmp/nanoclaw-diagnostics.json`. Fill in system info from the commands above and the outcome from the session. Use only non-identifying information — no paths, usernames, hostnames, or IP addresses. ```json { + "api_key": "phc_fx1Hhx9ucz8GuaJC8LVZWO8u03yXZZJJ6ObS4yplnaP", "event": "setup_complete", - "success": true, + "distinct_id": "", "properties": { + "success": true, "nanoclaw_version": "1.2.21", "os_platform": "darwin", "arch": "arm64", @@ -22,36 +33,33 @@ Write a JSON file to `/tmp/nanoclaw-diagnostics.json` with the setup outcome. Us } ``` -Fill in the values based on what happened during the session. - -## 2. Show and ask +## 3. Show and ask Show the contents of the file to the user and ask: > "Would you like to send anonymous diagnostics to help improve NanoClaw? Here's exactly what would be sent:" > -> (show JSON) +> (show the properties object only — not the api_key or distinct_id) > > **Yes** / **No** / **Never ask again** Use AskUserQuestion. -## 3. Handle response +## 4. Handle response -**Yes**: Send it: +**Yes**: ```bash -curl -s -X POST https://us.i.posthog.com/capture/ \ - -H 'Content-Type: application/json' \ - -d "{\"api_key\":\"phc_fx1Hhx9ucz8GuaJC8LVZWO8u03yXZZJJ6ObS4yplnaP\",\"event\":\"$(jq -r .event /tmp/nanoclaw-diagnostics.json)\",\"distinct_id\":\"$(uuidgen)\",\"properties\":$(jq .properties /tmp/nanoclaw-diagnostics.json)}" +curl -s -X POST https://us.i.posthog.com/capture/ -H 'Content-Type: application/json' -d @/tmp/nanoclaw-diagnostics.json rm /tmp/nanoclaw-diagnostics.json ``` Confirm: "Diagnostics sent." **No**: `rm /tmp/nanoclaw-diagnostics.json` — do nothing else. -**Never ask again**: Replace the contents of this file (`diagnostics.md`) with: -``` -# Diagnostics — opted out -``` -Then remove the "Diagnostics (Optional)" section from the end of `SKILL.md` in this skill directory. Delete `/tmp/nanoclaw-diagnostics.json`. +**Never ask again**: Opt out of diagnostics in both setup and update-nanoclaw: +1. Replace the contents of `.claude/skills/setup/diagnostics.md` with just `# Diagnostics — opted out` +2. Replace the contents of `.claude/skills/update-nanoclaw/diagnostics.md` with just `# Diagnostics — opted out` +3. Remove the "Diagnostics (Optional)" section from the end of both `.claude/skills/setup/SKILL.md` and `.claude/skills/update-nanoclaw/SKILL.md` +4. `rm /tmp/nanoclaw-diagnostics.json` + Confirm: "Got it — you won't be asked again." diff --git a/.claude/skills/update-nanoclaw/diagnostics.md b/.claude/skills/update-nanoclaw/diagnostics.md index 5d98855..1ab9bad 100644 --- a/.claude/skills/update-nanoclaw/diagnostics.md +++ b/.claude/skills/update-nanoclaw/diagnostics.md @@ -2,15 +2,29 @@ After the update is complete, offer to send anonymous diagnostics. -## 1. Write the event +## 1. Gather system info -Write a JSON file to `/tmp/nanoclaw-diagnostics.json` with the update outcome. Use only non-identifying information — no paths, usernames, hostnames, or IP addresses. +```bash +node -p "require('./package.json').version" +uname -s +uname -m +node -p "process.versions.node.split('.')[0]" +git log -1 --format=%ci HEAD@{1} 2>/dev/null || echo "unknown" +``` + +The last command gets the date of the previous HEAD (before the update) to estimate version age. + +## 2. Write the event + +Write a JSON file to `/tmp/nanoclaw-diagnostics.json`. Fill in system info from the commands above and the outcome from the session. Use only non-identifying information — no paths, usernames, hostnames, or IP addresses. ```json { + "api_key": "phc_fx1Hhx9ucz8GuaJC8LVZWO8u03yXZZJJ6ObS4yplnaP", "event": "update_complete", - "success": true, + "distinct_id": "", "properties": { + "success": true, "nanoclaw_version": "1.2.21", "os_platform": "darwin", "arch": "arm64", @@ -24,36 +38,33 @@ Write a JSON file to `/tmp/nanoclaw-diagnostics.json` with the update outcome. U } ``` -Fill in the values based on what happened during the session. - -## 2. Show and ask +## 3. Show and ask Show the contents of the file to the user and ask: > "Would you like to send anonymous diagnostics to help improve NanoClaw? Here's exactly what would be sent:" > -> (show JSON) +> (show the properties object only — not the api_key or distinct_id) > > **Yes** / **No** / **Never ask again** Use AskUserQuestion. -## 3. Handle response +## 4. Handle response -**Yes**: Send it: +**Yes**: ```bash -curl -s -X POST https://us.i.posthog.com/capture/ \ - -H 'Content-Type: application/json' \ - -d "{\"api_key\":\"phc_fx1Hhx9ucz8GuaJC8LVZWO8u03yXZZJJ6ObS4yplnaP\",\"event\":\"$(jq -r .event /tmp/nanoclaw-diagnostics.json)\",\"distinct_id\":\"$(uuidgen)\",\"properties\":$(jq .properties /tmp/nanoclaw-diagnostics.json)}" +curl -s -X POST https://us.i.posthog.com/capture/ -H 'Content-Type: application/json' -d @/tmp/nanoclaw-diagnostics.json rm /tmp/nanoclaw-diagnostics.json ``` Confirm: "Diagnostics sent." **No**: `rm /tmp/nanoclaw-diagnostics.json` — do nothing else. -**Never ask again**: Replace the contents of this file (`diagnostics.md`) with: -``` -# Diagnostics — opted out -``` -Then remove the "Diagnostics (Optional)" section from the end of `SKILL.md` in this skill directory. Delete `/tmp/nanoclaw-diagnostics.json`. +**Never ask again**: Opt out of diagnostics in both setup and update-nanoclaw: +1. Replace the contents of `.claude/skills/setup/diagnostics.md` with just `# Diagnostics — opted out` +2. Replace the contents of `.claude/skills/update-nanoclaw/diagnostics.md` with just `# Diagnostics — opted out` +3. Remove the "Diagnostics (Optional)" section from the end of both `.claude/skills/setup/SKILL.md` and `.claude/skills/update-nanoclaw/SKILL.md` +4. `rm /tmp/nanoclaw-diagnostics.json` + Confirm: "Got it — you won't be asked again."