diff options
| author | Morgan Lunt <morganl@anthropic.com> | 2026-09-25 11:29:00 -0700 |
|---|---|---|
| committer | Morgan Lunt <morganl@anthropic.com> | 2026-09-25 11:29:00 -0700 |
| commit | 363af43603ecdb1bdbed7303764b6daeeec7c37f (patch) | |
| tree | f4070c6df279ab2bdc320b5611a6cd7eb9b25703 /plugins/code-modernization/scripts/telemetry.sh | |
| parent | 28abd83ad92c24a4107803bd03e510387f2014c2 (diff) | |
code-modernization: version 1.0.0, usage counts and a README results table
The plugin now has a version and a changelog. Two hooks record whole-number usage counts (which command ran, how far a system got, how many rules and proofs) through the CLI's own telemetry: counts from 100 up are rounded, nothing is sent when the plugin is not in use, and any of three switches turns it off. The README documents every key and lists what the plugin was tried on, checked against the run files.
Diffstat (limited to 'plugins/code-modernization/scripts/telemetry.sh')
| -rw-r--r-- | plugins/code-modernization/scripts/telemetry.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/code-modernization/scripts/telemetry.sh b/plugins/code-modernization/scripts/telemetry.sh new file mode 100644 index 00000000..10f82054 --- /dev/null +++ b/plugins/code-modernization/scripts/telemetry.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# The plugin's two usage-count hooks: telemetry.sh command|state, with the hook's JSON on stdin. +# It starts Python only when the plugin is in use here: a plugin command was typed, or the folder holds files the plugin +# wrote under analysis/. A person who merely has the plugin installed never runs anything, and a Mac without developer +# tools never sees the "install command line tools" dialog that a bare python3 would raise. +# What is counted, and how to turn it off: see the Telemetry section of the README and scripts/telemetry.py. +mode="$1" +input=$(cat) +case "$mode" in + command) printf '%s' "$input" | grep -Eq '"prompt"[[:space:]]*:[[:space:]]*"[[:space:]]*/(code-modernization:)?modernize' || exit 0 ;; + state) + found= + for f in analysis/*/INTENT.md analysis/*/PREFLIGHT.md analysis/*/MODERNIZATION_BRIEF.md analysis/*/BUSINESS_RULES.md \ + analysis/*/DELTA_CATALOG.md analysis/*/VERIFICATION.json analysis/*/RULE_REVIEWS.json analysis/*/AI_NATIVE_SPEC.md; do + [ -f "$f" ] && found=1 && break + done + [ -n "$found" ] || exit 0 ;; + *) exit 0 ;; +esac +py=$(command -v python3) || exit 0 +if [ "$py" = /usr/bin/python3 ] && [ "$(uname)" = Darwin ]; then + xcode-select -p >/dev/null 2>&1 || exit 0 +fi +# never leave bytecode behind in the plugin's own folder +printf '%s' "$input" | PYTHONDONTWRITEBYTECODE=1 "$py" "$(dirname "$0")/telemetry.py" "$mode" +exit 0 |
