From e10b136df6f15cd65d5a020f947289b479676895 Mon Sep 17 00:00:00 2001 From: gavrielc Date: Sat, 21 Mar 2026 16:31:59 +0200 Subject: [PATCH] refactor: move diagnostics into each skill's own directory Replace shared _shared/diagnostics.md with dedicated diagnostics.md files in setup/ and update-nanoclaw/. Each contains only the event types relevant to that skill. References updated to local links. Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/skills/_shared/diagnostics.md | 106 ------------------ .claude/skills/setup/SKILL.md | 2 +- .claude/skills/setup/diagnostics.md | 81 +++++++++++++ .claude/skills/update-nanoclaw/SKILL.md | 2 +- .claude/skills/update-nanoclaw/diagnostics.md | 59 ++++++++++ 5 files changed, 142 insertions(+), 108 deletions(-) delete mode 100644 .claude/skills/_shared/diagnostics.md create mode 100644 .claude/skills/setup/diagnostics.md create mode 100644 .claude/skills/update-nanoclaw/diagnostics.md diff --git a/.claude/skills/_shared/diagnostics.md b/.claude/skills/_shared/diagnostics.md deleted file mode 100644 index ac5994b..0000000 --- a/.claude/skills/_shared/diagnostics.md +++ /dev/null @@ -1,106 +0,0 @@ -# Diagnostics (end-of-skill instructions) - -Follow these steps **after all other skill steps are complete**. - -## 1. Collect all events - -Every skill sends its own diagnostics event — even when invoked from a parent skill. A `/setup` that invokes `/add-telegram` produces **two** events: `skill_applied` (for add-telegram) and `setup_complete` (for setup). A `/setup` with no channels produces just `setup_complete`. - -Build the list of events to send: - -1. If sub-skills were invoked during this run (e.g., `/add-telegram` during `/setup`), add a `skill_applied` event for each. -2. Add the event for the current (outermost) skill. - -**If running a sub-skill standalone** (not called from a parent), there is just one event. - -## 2. Determine event type (for each event) - -- `/setup` → `setup_complete` -- `/update-nanoclaw` → `update_complete` -- Any other skill → `skill_applied` - -## 3. Build event-specific data - -Estimate `error_count` from the conversation (how many errors/retries occurred during the run). - -**For `setup_complete`:** -```json -{ - "channels_selected": ["whatsapp", "telegram"], - "error_count": 0, - "failed_step": null, - "exit_code": null -} -``` -- `channels_selected`: which channels the user chose to install -- `failed_step`: if setup failed, which step (environment / container / groups / register / mounts / service / verify) -- `exit_code`: if a step failed, its exit code - -**For `skill_applied`:** -```json -{ - "skill_name": "add-telegram", - "is_upstream_skill": true, - "conflict_files": ["package.json", "src/index.ts"], - "error_count": 0 -} -``` -- `skill_name`: the skill that was run. Use the upstream skill name if it's an upstream skill, otherwise use `"custom"` -- `is_upstream_skill`: true if this is a known upstream skill -- `conflict_files`: filenames that had merge conflicts (the script will gate these against upstream — pass them all, the script filters) - -**For `update_complete`:** -```json -{ - "version_age_days": 45, - "update_method": "merge", - "conflict_files": ["package.json"], - "breaking_changes_found": false, - "breaking_changes_skills_run": [], - "error_count": 0 -} -``` -- `version_age_days`: estimate from the backup tag or commit date how many days old the previous version was -- `update_method`: "merge" or "rebase" -- `breaking_changes_found`: whether breaking changes were detected during the update -- `breaking_changes_skills_run`: which skills had to be re-run to fix breaking changes - -## 4. Dry run all events - -For **each** event, run with `--dry-run` to get the payload: - -```bash -npx tsx scripts/send-diagnostics.ts --event --success --data '' --dry-run -``` - -Use `--failure` instead of `--success` if that particular skill/step failed. - -If **any** dry-run produces no output, the user has opted out permanently — skip the rest for all events. - -## 5. Show the user and ask once - -Show **all** payloads together and ask **once** (not per-event): - -> "Would you like to send anonymous diagnostics to help improve NanoClaw? Here's exactly what would be sent:" -> -> (show all JSON payloads) -> -> **Yes** / **No** / **Never ask again** - -Use AskUserQuestion. - -## 6. Handle response - -- **Yes**: Send **all** events (run each command without `--dry-run`): - ```bash - npx tsx scripts/send-diagnostics.ts --event --success --data '' - ``` - Confirm: "Diagnostics sent (N events)." or "Diagnostics sent." if only one. - -- **No**: Do nothing. User will be asked again next time. - -- **Never ask again**: Run: - ```bash - npx tsx -e "import { setNeverAsk } from './scripts/send-diagnostics.ts'; setNeverAsk();" - ``` - Confirm: "Got it — you won't be asked again." diff --git a/.claude/skills/setup/SKILL.md b/.claude/skills/setup/SKILL.md index 170e303..c1c5d60 100644 --- a/.claude/skills/setup/SKILL.md +++ b/.claude/skills/setup/SKILL.md @@ -220,4 +220,4 @@ Tell user to test: send a message in their registered chat. Show: `tail -f logs/ ## Diagnostics (Optional) -After completing all steps above, read and follow `.claude/skills/_shared/diagnostics.md`. +After completing all steps above, read and follow [diagnostics.md](diagnostics.md). diff --git a/.claude/skills/setup/diagnostics.md b/.claude/skills/setup/diagnostics.md new file mode 100644 index 0000000..f371e41 --- /dev/null +++ b/.claude/skills/setup/diagnostics.md @@ -0,0 +1,81 @@ +# Diagnostics (end-of-setup instructions) + +Follow these steps **after all other setup steps are complete**. + +## 1. Collect events + +Build the list of events to send: + +1. If channel skills were invoked during setup (e.g., `/add-telegram`), add a `skill_applied` event for each. +2. Add a `setup_complete` event for setup itself. + +A `/setup` with no channels produces just `setup_complete`. + +## 2. Build event data + +Estimate `error_count` from the conversation (how many errors/retries occurred). + +**For `setup_complete`:** +```json +{ + "channels_selected": ["whatsapp", "telegram"], + "error_count": 0, + "failed_step": null, + "exit_code": null +} +``` +- `channels_selected`: which channels the user chose to install +- `failed_step`: if setup failed, which step (environment / container / groups / register / mounts / service / verify) +- `exit_code`: if a step failed, its exit code + +**For each `skill_applied`:** +```json +{ + "skill_name": "add-telegram", + "is_upstream_skill": true, + "conflict_files": ["package.json", "src/index.ts"], + "error_count": 0 +} +``` +- `skill_name`: upstream skill name, or `"custom"` for non-upstream skills +- `conflict_files`: filenames with merge conflicts (the script gates these against upstream) + +## 3. Dry run all events + +For **each** event, run with `--dry-run` to get the payload: + +```bash +npx tsx scripts/send-diagnostics.ts --event --success --data '' --dry-run +``` + +Use `--failure` instead of `--success` if that particular skill/step failed. + +If **any** dry-run produces no output, the user has opted out permanently — skip the rest. + +## 4. Show the user and ask once + +Show **all** payloads together and ask **once** (not per-event): + +> "Would you like to send anonymous diagnostics to help improve NanoClaw? Here's exactly what would be sent:" +> +> (show all JSON payloads) +> +> **Yes** / **No** / **Never ask again** + +Use AskUserQuestion. + +## 5. Handle response + +- **Yes**: Send **all** events (run each command without `--dry-run`): + ```bash + npx tsx scripts/send-diagnostics.ts --event --success --data '' + ``` + Confirm: "Diagnostics sent (N events)." or "Diagnostics sent." if only one. + +- **No**: Do nothing. User will be asked again next time. + +- **Never ask again**: Run: + ```bash + npx tsx -e "import { setNeverAsk } from './scripts/send-diagnostics.ts'; setNeverAsk();" + ``` + Confirm: "Got it — you won't be asked again." diff --git a/.claude/skills/update-nanoclaw/SKILL.md b/.claude/skills/update-nanoclaw/SKILL.md index 5e93c6c..e8197d2 100644 --- a/.claude/skills/update-nanoclaw/SKILL.md +++ b/.claude/skills/update-nanoclaw/SKILL.md @@ -237,4 +237,4 @@ Tell the user: ## Diagnostics (Optional) -After completing all steps above, read and follow `.claude/skills/_shared/diagnostics.md`. +After completing all steps above, read and follow [diagnostics.md](diagnostics.md). diff --git a/.claude/skills/update-nanoclaw/diagnostics.md b/.claude/skills/update-nanoclaw/diagnostics.md new file mode 100644 index 0000000..9028dc8 --- /dev/null +++ b/.claude/skills/update-nanoclaw/diagnostics.md @@ -0,0 +1,59 @@ +# Diagnostics (end-of-update instructions) + +Follow these steps **after all other update steps are complete**. + +## 1. Build event data + +Estimate `error_count` from the conversation (how many errors/retries occurred). + +```json +{ + "version_age_days": 45, + "update_method": "merge", + "conflict_files": ["package.json"], + "breaking_changes_found": false, + "breaking_changes_skills_run": [], + "error_count": 0 +} +``` +- `version_age_days`: estimate from the backup tag or commit date how many days old the previous version was +- `update_method`: "merge" or "rebase" +- `conflict_files`: filenames with merge conflicts (the script gates these against upstream) +- `breaking_changes_found`: whether breaking changes were detected +- `breaking_changes_skills_run`: which skills had to be re-run to fix breaking changes + +## 2. Dry run + +```bash +npx tsx scripts/send-diagnostics.ts --event update_complete --success --data '' --dry-run +``` + +Use `--failure` instead of `--success` if the update failed. + +If the dry-run produces no output, the user has opted out permanently — skip the rest. + +## 3. Show the user and ask + +> "Would you like to send anonymous diagnostics to help improve NanoClaw? Here's exactly what would be sent:" +> +> (show JSON payload) +> +> **Yes** / **No** / **Never ask again** + +Use AskUserQuestion. + +## 4. Handle response + +- **Yes**: Run without `--dry-run`: + ```bash + npx tsx scripts/send-diagnostics.ts --event update_complete --success --data '' + ``` + Confirm: "Diagnostics sent." + +- **No**: Do nothing. User will be asked again next time. + +- **Never ask again**: Run: + ```bash + npx tsx -e "import { setNeverAsk } from './scripts/send-diagnostics.ts'; setNeverAsk();" + ``` + Confirm: "Got it — you won't be asked again."