From 8115951284474ae15a90162d33383ca61eb82d28 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Tue, 31 Mar 2026 23:08:22 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20recursive=20self-improvement=20?= =?UTF-8?q?=E2=80=94=20operational=20learning=20+=20full=20skill=20wiring?= =?UTF-8?q?=20(v0.13.8.0)=20(#647)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: remove dead contributor mode, replace with operational self-improvement slot Contributor mode never fired in 18 days of heavy use (required manual opt-in via gstack-config, gated behind _CONTRIB=true, wrote disconnected markdown). Removes: generateContributorMode(), _CONTRIB bash var, 2 E2E tests, touchfile entry, doc references. Cleans up skip-lists in plan-ceo-review, autoplan, review resolver, and document-release templates. The operational self-improvement system (next commit) replaces this slot with automatic learning capture that requires no opt-in. Co-Authored-By: Claude Opus 4.6 (1M context) * feat: operational self-improvement — every skill learns from failures Adds universal operational learning capture to the preamble completion protocol. At the end of every skill session, the agent reflects on CLI failures, wrong approaches, and project quirks, logging them as type "operational" to the learnings JSONL. Future sessions surface these automatically. - generateCompletionStatus(ctx) now includes operational capture section - Preamble bash shows top 3 learnings inline when count > 5 - New "operational" type in generateLearningsLog alongside pattern/pitfall/etc - Updated unit tests + operational seed entry in learnings E2E Co-Authored-By: Claude Opus 4.6 (1M context) * feat: wire learnings into all insight-producing skills Adds LEARNINGS_SEARCH and/or LEARNINGS_LOG to 10 skill templates that produce reusable insights but were previously disconnected from the learning system: - office-hours, plan-ceo-review, plan-eng-review: add LOG (had SEARCH) - plan-design-review: add both SEARCH + LOG (had neither) - design-review, design-consultation, cso, qa, qa-only: add both - retro: add SEARCH (had LOG) 13 skills now fully participate in the learning loop (read + write). Every review, QA, investigation, and design session both consults prior learnings and contributes new ones. Co-Authored-By: Claude Opus 4.6 (1M context) * test: add operational-learning E2E test (gate-tier) Validates the write path: agent encounters a CLI failure, logs an operational learning to JSONL via gstack-learnings-log. Replaces the removed contributor-mode E2E test. Setup: temp git repo, copy bin scripts, set GSTACK_HOME. Prompt: simulated npm test failure needing --experimental-vm-modules. Assert: learnings.jsonl exists with type=operational entry. Co-Authored-By: Claude Opus 4.6 (1M context) * fix: learnings-show E2E slug mismatch — seed at computed slug, not hardcoded The test seeded learnings at projects/test-project/ but gstack-slug computes the slug from basename(workDir) when no git remote exists. The agent's search looked at the wrong path and found nothing. Fix: compute slug the same way gstack-slug does (basename + sanitize) and seed the learnings there. Co-Authored-By: Claude Opus 4.6 (1M context) * chore: bump version and changelog (v0.13.8.0) Co-Authored-By: Claude Opus 4.6 (1M context) --------- Co-authored-by: Claude Opus 4.6 (1M context) --- ARCHITECTURE.md | 2 +- CHANGELOG.md | 18 +++++ CONTRIBUTING.md | 23 ++---- SKILL.md | 64 +++++++-------- VERSION | 2 +- autoplan/SKILL.md | 65 +++++++-------- autoplan/SKILL.md.tmpl | 1 - benchmark/SKILL.md | 64 +++++++-------- browse/SKILL.md | 64 +++++++-------- canary/SKILL.md | 64 +++++++-------- codex/SKILL.md | 64 +++++++-------- connect-chrome/SKILL.md | 64 +++++++-------- cso/SKILL.md | 127 ++++++++++++++++++++++-------- cso/SKILL.md.tmpl | 4 + design-consultation/SKILL.md | 127 ++++++++++++++++++++++-------- design-consultation/SKILL.md.tmpl | 4 + design-html/SKILL.md | 64 +++++++-------- design-review/SKILL.md | 127 ++++++++++++++++++++++-------- design-review/SKILL.md.tmpl | 4 + design-shotgun/SKILL.md | 64 +++++++-------- document-release/SKILL.md | 66 ++++++++-------- document-release/SKILL.md.tmpl | 2 +- investigate/SKILL.md | 67 ++++++++-------- land-and-deploy/SKILL.md | 64 +++++++-------- learn/SKILL.md | 64 +++++++-------- office-hours/SKILL.md | 89 +++++++++++++-------- office-hours/SKILL.md.tmpl | 2 + package.json | 2 +- plan-ceo-review/SKILL.md | 89 +++++++++++++-------- plan-ceo-review/SKILL.md.tmpl | 2 + plan-design-review/SKILL.md | 127 ++++++++++++++++++++++-------- plan-design-review/SKILL.md.tmpl | 4 + plan-eng-review/SKILL.md | 89 +++++++++++++-------- plan-eng-review/SKILL.md.tmpl | 2 + qa-only/SKILL.md | 127 ++++++++++++++++++++++-------- qa-only/SKILL.md.tmpl | 4 + qa/SKILL.md | 127 ++++++++++++++++++++++-------- qa/SKILL.md.tmpl | 4 + retro/SKILL.md | 105 ++++++++++++++++-------- retro/SKILL.md.tmpl | 2 + review/SKILL.md | 67 ++++++++-------- scripts/resolvers/learnings.ts | 3 +- scripts/resolvers/preamble.ts | 76 +++++++++--------- setup-browser-cookies/SKILL.md | 64 +++++++-------- setup-deploy/SKILL.md | 64 +++++++-------- ship/SKILL.md | 67 ++++++++-------- test/gen-skill-docs.test.ts | 17 +++- test/helpers/touchfiles.ts | 4 +- test/skill-e2e-bws.test.ts | 108 ++++++++++++++++++------- test/skill-e2e-learnings.test.ts | 10 ++- test/skill-e2e.test.ts | 56 ------------- test/skill-validation.test.ts | 41 +--------- test/touchfiles.test.ts | 4 +- 53 files changed, 1597 insertions(+), 1038 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index e9d63d83bc8e2bf2c927f63fd9208c9d51cbb5fe..086bb2e4397df05617611fe0b51ff736e58aa65f 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -217,7 +217,7 @@ Every skill starts with a `{{PREAMBLE}}` block that runs before the skill's own 1. **Update check** — calls `gstack-update-check`, reports if an upgrade is available. 2. **Session tracking** — touches `~/.gstack/sessions/$PPID` and counts active sessions (files modified in the last 2 hours). When 3+ sessions are running, all skills enter "ELI16 mode" — every question re-grounds the user on context because they're juggling windows. -3. **Contributor mode** — reads `gstack_contributor` from config. When true, the agent files casual field reports to `~/.gstack/contributor-logs/` when gstack itself misbehaves. +3. **Operational self-improvement** — at the end of every skill session, the agent reflects on failures (CLI errors, wrong approaches, project quirks) and logs operational learnings to the project's JSONL file for future sessions. 4. **AskUserQuestion format** — universal format: context, question, `RECOMMENDATION: Choose X because ___`, lettered options. Consistent across all skills. 5. **Search Before Building** — before building infrastructure or unfamiliar patterns, search first. Three layers of knowledge: tried-and-true (Layer 1), new-and-popular (Layer 2), first-principles (Layer 3). When first-principles reasoning reveals conventional wisdom is wrong, the agent names the "eureka moment" and logs it. See `ETHOS.md` for the full builder philosophy. diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c2089939063215757ba8544a40f057659372621..422cc96992d5b91626085b1bb1f81b844ea7970f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [0.14.6.0] - 2026-03-31 — Recursive Self-Improvement + +gstack now learns from its own mistakes. Every skill session captures operational failures (CLI errors, wrong approaches, project quirks) and surfaces them in future sessions. No setup needed, just works. + +### Added + +- **Operational self-improvement.** When a command fails or you hit a project-specific gotcha, gstack logs it. Next session, it remembers. "bun test needs --timeout 30000" or "login flow requires cookie import first" ... the kind of stuff that wastes 10 minutes every time you forget it. +- **Learnings summary in preamble.** When your project has 5+ learnings, gstack shows the top 3 at the start of every session so you see them before you start working. +- **13 skills now learn.** office-hours, plan-ceo-review, plan-eng-review, plan-design-review, design-review, design-consultation, cso, qa, qa-only, and retro all now read prior learnings AND contribute new ones. Previously only review, ship, and investigate were wired. + +### Changed + +- **Contributor mode replaced.** The old contributor mode (manual opt-in, markdown reports to ~/.gstack/contributor-logs/) never fired in 18 days of heavy use. Replaced with automatic operational learning that captures the same insights without any setup. + +### Fixed + +- **learnings-show E2E test slug mismatch.** The test seeded learnings at a hardcoded path but gstack-slug computed a different path at runtime. Now computes the slug dynamically. + ## [0.14.5.0] - 2026-03-31 — Ship Idempotency + Skill Prefix Fix Re-running `/ship` after a failed push or PR creation no longer double-bumps your version or duplicates your CHANGELOG. And if you use `--prefix` mode, your skill names actually work now. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b6dba47cdc10d3af555604fabc8fec4adc2d9d54..fcb9c279aa7ad208c523099b1f1622cb9e177d6b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,26 +20,19 @@ Now edit any `SKILL.md`, invoke it in Claude Code (e.g. `/review`), and see your bin/dev-teardown # deactivate — back to your global install ``` -## Contributor mode +## Operational self-improvement -Contributor mode turns gstack into a self-improving tool. Enable it and Claude Code -will periodically reflect on its gstack experience — rating it 0-10 at the end of -each major workflow step. When something isn't a 10, it thinks about why and files -a report to `~/.gstack/contributor-logs/` with what happened, repro steps, and what -would make it better. +gstack automatically learns from failures. At the end of every skill session, the agent +reflects on what went wrong (CLI errors, wrong approaches, project quirks) and logs +operational learnings to `~/.gstack/projects/{slug}/learnings.jsonl`. Future sessions +surface these learnings automatically, so gstack gets smarter on your codebase over time. -```bash -~/.claude/skills/gstack/bin/gstack-config set gstack_contributor true -``` - -The logs are for **you**. When something bugs you enough to fix, the report is -already written. Fork gstack, symlink your fork into the project where you hit -the issue, fix it, and open a PR. +No setup needed. Learnings are logged automatically. View them with `/learn`. ### The contributor workflow -1. **Use gstack normally** — contributor mode reflects and logs issues automatically -2. **Check your logs:** `ls ~/.gstack/contributor-logs/` +1. **Use gstack normally** — operational learnings are captured automatically +2. **Check your learnings:** `/learn` or `ls ~/.gstack/projects/*/learnings.jsonl` 3. **Fork and clone gstack** (if you haven't already) 4. **Symlink your fork into the project where you hit the bug:** ```bash diff --git a/SKILL.md b/SKILL.md index 29b3110c16dfe71c518b827a3a10e00ecec84626..958f9dc067b396461c2b89d6695df9e1cc34dcdd 100644 --- a/SKILL.md +++ b/SKILL.md @@ -25,7 +25,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -46,8 +45,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"gstack","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"gstack","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -65,6 +64,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -208,24 +210,6 @@ This only happens once per project. If `HAS_ROUTING` is `yes` or `ROUTING_DECLIN The user always has context you don't. Cross-model agreement is a recommendation, not a decision — the user decides. -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -251,6 +235,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -269,22 +271,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/VERSION b/VERSION index 8d14e1d793ef2d7fdcfb44dca7b5707b38f2ef23..0062e6bedf9e0ea8b84991a44a2ead79fc3050fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.14.5.0 +0.14.6.0 diff --git a/autoplan/SKILL.md b/autoplan/SKILL.md index 31ae9ab2184b0c9c8493506c6768b06e8817e4db..baa86d2f19c453982498facbdee5f674602a691c 100644 --- a/autoplan/SKILL.md +++ b/autoplan/SKILL.md @@ -34,7 +34,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -55,8 +54,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"autoplan","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"autoplan","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -74,6 +73,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -300,24 +302,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -343,6 +327,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -361,22 +363,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -698,7 +700,6 @@ Read each file using the Read tool: - AskUserQuestion Format - Completeness Principle — Boil the Lake - Search Before Building -- Contributor Mode - Completion Status Protocol - Telemetry (run last) - Step 0: Detect base branch diff --git a/autoplan/SKILL.md.tmpl b/autoplan/SKILL.md.tmpl index 38ab2816e0485af6883c7002e73e1d89e22643c9..41a1d4b34f1f11db35222ab6a24d7ff337e83feb 100644 --- a/autoplan/SKILL.md.tmpl +++ b/autoplan/SKILL.md.tmpl @@ -202,7 +202,6 @@ Read each file using the Read tool: - AskUserQuestion Format - Completeness Principle — Boil the Lake - Search Before Building -- Contributor Mode - Completion Status Protocol - Telemetry (run last) - Step 0: Detect base branch diff --git a/benchmark/SKILL.md b/benchmark/SKILL.md index aa6567df30bc446f2829585dca879c7dd044ea2c..7bee4a6eb9ac5400135fc99cfef438559d3fb9de 100644 --- a/benchmark/SKILL.md +++ b/benchmark/SKILL.md @@ -27,7 +27,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -48,8 +47,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"benchmark","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"benchmark","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -67,6 +66,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -210,24 +212,6 @@ This only happens once per project. If `HAS_ROUTING` is `yes` or `ROUTING_DECLIN The user always has context you don't. Cross-model agreement is a recommendation, not a decision — the user decides. -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -253,6 +237,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -271,22 +273,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/browse/SKILL.md b/browse/SKILL.md index 464c03ae1ae382abff8b2a5503914862e19c414a..25fbc568bfc6310a20766b7b4e1b0e36e43d96e4 100644 --- a/browse/SKILL.md +++ b/browse/SKILL.md @@ -27,7 +27,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -48,8 +47,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"browse","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"browse","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -67,6 +66,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -210,24 +212,6 @@ This only happens once per project. If `HAS_ROUTING` is `yes` or `ROUTING_DECLIN The user always has context you don't. Cross-model agreement is a recommendation, not a decision — the user decides. -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -253,6 +237,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -271,22 +273,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/canary/SKILL.md b/canary/SKILL.md index 48c6e0b904f7710cc641caff0609c38ab5a32a29..bc0b23f9ef61208549f5ee8421eacc2e96d98dea 100644 --- a/canary/SKILL.md +++ b/canary/SKILL.md @@ -27,7 +27,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -48,8 +47,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"canary","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"canary","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -67,6 +66,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -275,24 +277,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -318,6 +302,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -336,22 +338,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/codex/SKILL.md b/codex/SKILL.md index 34c1b121af760f27529b2ce8e2a9799131ecb4e1..a60088ee81f07217fd14710568edd30b78f70972 100644 --- a/codex/SKILL.md +++ b/codex/SKILL.md @@ -28,7 +28,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -49,8 +48,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"codex","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"codex","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -68,6 +67,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -294,24 +296,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -337,6 +321,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -355,22 +357,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/connect-chrome/SKILL.md b/connect-chrome/SKILL.md index d1736f29f6f9b17a75ed5e47d10eacfeb77bfb9a..352ef445494d91bcb4511237e90f1430fea26e7a 100644 --- a/connect-chrome/SKILL.md +++ b/connect-chrome/SKILL.md @@ -25,7 +25,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -46,8 +45,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"connect-chrome","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"connect-chrome","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -65,6 +64,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -291,24 +293,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -334,6 +318,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -352,22 +354,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/cso/SKILL.md b/cso/SKILL.md index ca79f2235f12199e8f913056d64ae52298757b0a..9cb27f4f039d6680eaed2a002c17dbf2662934e6 100644 --- a/cso/SKILL.md +++ b/cso/SKILL.md @@ -31,7 +31,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -52,8 +51,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"cso","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"cso","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -71,6 +70,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -279,24 +281,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -322,6 +306,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -340,22 +342,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -488,6 +490,44 @@ grep -q "laravel" composer.json 2>/dev/null && echo "FRAMEWORK: Laravel" This is NOT a checklist — it's a reasoning phase. The output is understanding, not findings. +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ### Phase 1: Attack Surface Census Map what an attacker sees — both code surface and infrastructure surface. @@ -1007,6 +1047,31 @@ Write findings to `.gstack/security-reports/{date}-{HHMMSS}.json` using this sch If `.gstack/` is not in `.gitignore`, note it in findings — security reports should stay local. +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"cso","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Important Rules - **Think like an attacker, report like a defender.** Show the exploit path, then the fix. diff --git a/cso/SKILL.md.tmpl b/cso/SKILL.md.tmpl index 120319f65cd4897532bd49bf45cefd32eb9db388..b4e9f7bfe61db988fbe72581e1f4646f88adb617 100644 --- a/cso/SKILL.md.tmpl +++ b/cso/SKILL.md.tmpl @@ -102,6 +102,8 @@ grep -q "laravel" composer.json 2>/dev/null && echo "FRAMEWORK: Laravel" This is NOT a checklist — it's a reasoning phase. The output is understanding, not findings. +{{LEARNINGS_SEARCH}} + ### Phase 1: Attack Surface Census Map what an attacker sees — both code surface and infrastructure surface. @@ -598,6 +600,8 @@ Write findings to `.gstack/security-reports/{date}-{HHMMSS}.json` using this sch If `.gstack/` is not in `.gitignore`, note it in findings — security reports should stay local. +{{LEARNINGS_LOG}} + ## Important Rules - **Think like an attacker, report like a defender.** Show the exploit path, then the fix. diff --git a/design-consultation/SKILL.md b/design-consultation/SKILL.md index ff6b030ca11f8020280c372e2dd5b8f44eb8e238..f6927109fea532db86ce9564eb47505568449c84 100644 --- a/design-consultation/SKILL.md +++ b/design-consultation/SKILL.md @@ -32,7 +32,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -53,8 +52,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"design-consultation","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"design-consultation","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -72,6 +71,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -298,24 +300,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -341,6 +325,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -359,22 +361,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -558,6 +560,44 @@ If `DESIGN_NOT_AVAILABLE`: Phase 5 falls back to the HTML preview page (still go --- +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ## Phase 1: Product Context Ask the user a single question that covers everything you need to know. Pre-fill what you can infer from the codebase. @@ -1062,6 +1102,31 @@ After shipping DESIGN.md, if the session produced screen-level mockups or page l --- +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"design-consultation","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Important Rules 1. **Propose, don't present menus.** You are a consultant, not a form. Make opinionated recommendations based on the product context, then let the user adjust. diff --git a/design-consultation/SKILL.md.tmpl b/design-consultation/SKILL.md.tmpl index 7ff4ad99d378b8bab52dbcbbe449afe135a47933..247b63e2021bd790008d07bf69438af280899154 100644 --- a/design-consultation/SKILL.md.tmpl +++ b/design-consultation/SKILL.md.tmpl @@ -79,6 +79,8 @@ If `DESIGN_NOT_AVAILABLE`: Phase 5 falls back to the HTML preview page (still go --- +{{LEARNINGS_SEARCH}} + ## Phase 1: Product Context Ask the user a single question that covers everything you need to know. Pre-fill what you can infer from the codebase. @@ -419,6 +421,8 @@ After shipping DESIGN.md, if the session produced screen-level mockups or page l --- +{{LEARNINGS_LOG}} + ## Important Rules 1. **Propose, don't present menus.** You are a consultant, not a form. Make opinionated recommendations based on the product context, then let the user adjust. diff --git a/design-html/SKILL.md b/design-html/SKILL.md index 24183b90591a6373b71fd1d02147c5c2ea81a36d..bb861f04a49c55e1583bc530896aa00f7c7086cb 100644 --- a/design-html/SKILL.md +++ b/design-html/SKILL.md @@ -32,7 +32,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -53,8 +52,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"design-html","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"design-html","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -72,6 +71,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -280,24 +282,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -323,6 +307,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -341,22 +343,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/design-review/SKILL.md b/design-review/SKILL.md index 3be5a7c417b4491ebc2c55f614a10de84c6fb91b..aae65fe0c310bef38cc847d95938feb7827a4294 100644 --- a/design-review/SKILL.md +++ b/design-review/SKILL.md @@ -32,7 +32,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -53,8 +52,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"design-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"design-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -72,6 +71,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -298,24 +300,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -341,6 +325,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -359,22 +361,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -728,6 +730,44 @@ echo "REPORT_DIR: $REPORT_DIR" --- +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ## Phases 1-6: Design Audit Baseline ## Modes @@ -1394,6 +1434,31 @@ If the repo has a `TODOS.md`: --- +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"design-review","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Additional Rules (design-review specific) 11. **Clean working tree required.** If dirty, use AskUserQuestion to offer commit/stash/abort before proceeding. diff --git a/design-review/SKILL.md.tmpl b/design-review/SKILL.md.tmpl index de57c217b92b1f8e02f21bdd4dc5ff0e1cb86b6e..adca09913fe0ba24a52b16b4b7b19ff103abeec8 100644 --- a/design-review/SKILL.md.tmpl +++ b/design-review/SKILL.md.tmpl @@ -97,6 +97,8 @@ echo "REPORT_DIR: $REPORT_DIR" --- +{{LEARNINGS_SEARCH}} + ## Phases 1-6: Design Audit Baseline {{DESIGN_METHODOLOGY}} @@ -287,6 +289,8 @@ If the repo has a `TODOS.md`: --- +{{LEARNINGS_LOG}} + ## Additional Rules (design-review specific) 11. **Clean working tree required.** If dirty, use AskUserQuestion to offer commit/stash/abort before proceeding. diff --git a/design-shotgun/SKILL.md b/design-shotgun/SKILL.md index 5e29bfccccbef612dd44545fce3300a96056dc21..f57d4788e9d7e2835efa7ae99cb7a213a9998d52 100644 --- a/design-shotgun/SKILL.md +++ b/design-shotgun/SKILL.md @@ -29,7 +29,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -50,8 +49,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"design-shotgun","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"design-shotgun","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -69,6 +68,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -277,24 +279,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -320,6 +304,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -338,22 +340,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/document-release/SKILL.md b/document-release/SKILL.md index 7001fd6cacc505a81cb28c537970e2a373893fec..be535ceefd59754e3622dc7f39dc3ccbd9b23360 100644 --- a/document-release/SKILL.md +++ b/document-release/SKILL.md @@ -29,7 +29,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -50,8 +49,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"document-release","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"document-release","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -69,6 +68,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -277,24 +279,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -320,6 +304,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -338,22 +340,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -531,7 +533,7 @@ Read each documentation file and cross-reference it against the diff. Use these - Walk through the setup instructions as if you are a brand new contributor. - Are the listed commands accurate? Would each step succeed? - Do test tier descriptions match the current test infrastructure? -- Are workflow descriptions (dev setup, contributor mode, etc.) current? +- Are workflow descriptions (dev setup, operational learnings, etc.) current? - Flag anything that would fail or confuse a first-time contributor. **CLAUDE.md / project instructions:** diff --git a/document-release/SKILL.md.tmpl b/document-release/SKILL.md.tmpl index b1b6f684aeeaaf5caba96f8e50c09d3702d181e5..4285525c2c78e8047debac7df024d0d6e9420870 100644 --- a/document-release/SKILL.md.tmpl +++ b/document-release/SKILL.md.tmpl @@ -108,7 +108,7 @@ Read each documentation file and cross-reference it against the diff. Use these - Walk through the setup instructions as if you are a brand new contributor. - Are the listed commands accurate? Would each step succeed? - Do test tier descriptions match the current test infrastructure? -- Are workflow descriptions (dev setup, contributor mode, etc.) current? +- Are workflow descriptions (dev setup, operational learnings, etc.) current? - Flag anything that would fail or confuse a first-time contributor. **CLAUDE.md / project instructions:** diff --git a/investigate/SKILL.md b/investigate/SKILL.md index a65025ec8d7cf6d1732a4e70147050e624fc7a6c..a782849ec5fb0111e89e137de27990df8f81142b 100644 --- a/investigate/SKILL.md +++ b/investigate/SKILL.md @@ -44,7 +44,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -65,8 +64,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"investigate","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"investigate","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -84,6 +83,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -292,24 +294,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -335,6 +319,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -353,22 +355,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -618,7 +620,8 @@ this session, log it for future sessions: ``` **Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` -(user stated), `architecture` (structural decision), `tool` (library/framework insight). +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). **Sources:** `observed` (you found this in the code), `user-stated` (user told you), `inferred` (AI deduction), `cross-model` (both Claude and Codex agree). diff --git a/land-and-deploy/SKILL.md b/land-and-deploy/SKILL.md index 2cca312ebcc24b8709067c17e03bbbcb564c3962..9a49a19cf34ed475872c76ff8938e47f30cb45af 100644 --- a/land-and-deploy/SKILL.md +++ b/land-and-deploy/SKILL.md @@ -26,7 +26,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -47,8 +46,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"land-and-deploy","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"land-and-deploy","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -66,6 +65,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -292,24 +294,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -335,6 +319,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -353,22 +355,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/learn/SKILL.md b/learn/SKILL.md index 9d344eebd3e6790ccfb234962237c5a01ee819e5..2fa2841e02490948105c6dc15eb965ca971c38cd 100644 --- a/learn/SKILL.md +++ b/learn/SKILL.md @@ -29,7 +29,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -50,8 +49,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"learn","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"learn","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -69,6 +68,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -277,24 +279,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -320,6 +304,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -338,22 +340,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/office-hours/SKILL.md b/office-hours/SKILL.md index 9c8de4ce66cfdd11b035170d1149aeb432694c5e..a29e733b2b1968a09a1736596cbc89d5729ad583 100644 --- a/office-hours/SKILL.md +++ b/office-hours/SKILL.md @@ -36,7 +36,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -57,8 +56,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"office-hours","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"office-hours","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -76,6 +75,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -302,24 +304,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -345,6 +329,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -363,22 +365,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -1549,6 +1551,31 @@ The design doc at `~/.gstack/projects/` is automatically discoverable by downstr --- +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"office-hours","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Important Rules - **Never start implementation.** This skill produces design docs, not code. Not even scaffolding. diff --git a/office-hours/SKILL.md.tmpl b/office-hours/SKILL.md.tmpl index 73b9fe5bd6d9dc84c6f97cffe46a25150136679e..d461b9988db4d1aeefdb391a0caa751466bcde59 100644 --- a/office-hours/SKILL.md.tmpl +++ b/office-hours/SKILL.md.tmpl @@ -757,6 +757,8 @@ The design doc at `~/.gstack/projects/` is automatically discoverable by downstr --- +{{LEARNINGS_LOG}} + ## Important Rules - **Never start implementation.** This skill produces design docs, not code. Not even scaffolding. diff --git a/package.json b/package.json index ba298c89dc272f637f79ccc1e0b74115a9427f79..8ac19037766604cfdfe34abec819de7b1f6c34d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gstack", - "version": "0.14.5.0", + "version": "0.14.6.0", "description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.", "license": "MIT", "type": "module", diff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.md index 48a8ab4097986f23bf19f6e7a13a94baaced9ca5..15991512f27c952bb60a9ac562b2b3e645536a58 100644 --- a/plan-ceo-review/SKILL.md +++ b/plan-ceo-review/SKILL.md @@ -32,7 +32,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -53,8 +52,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"plan-ceo-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"plan-ceo-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -72,6 +71,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -298,24 +300,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -341,6 +325,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -359,22 +361,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -1637,6 +1639,31 @@ If promoted, copy the CEO plan content to `docs/designs/{FEATURE}.md` (create th * After each section, pause and wait for feedback. * Use **CRITICAL GAP** / **WARNING** / **OK** for scannability. +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"plan-ceo-review","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Mode Quick Reference ``` ┌────────────────────────────────────────────────────────────────────────────────┐ diff --git a/plan-ceo-review/SKILL.md.tmpl b/plan-ceo-review/SKILL.md.tmpl index b33aaa30c5c258b051bcb0981d297590893d56d2..319c3c1a75d7ec9a6e114920243e522026bdfeaa 100644 --- a/plan-ceo-review/SKILL.md.tmpl +++ b/plan-ceo-review/SKILL.md.tmpl @@ -779,6 +779,8 @@ If promoted, copy the CEO plan content to `docs/designs/{FEATURE}.md` (create th * After each section, pause and wait for feedback. * Use **CRITICAL GAP** / **WARNING** / **OK** for scannability. +{{LEARNINGS_LOG}} + ## Mode Quick Reference ``` ┌────────────────────────────────────────────────────────────────────────────────┐ diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.md index 3c973b108b361ec38716f443a2a41844336d6048..255fa337ad5e4c7a2169ef62f15bb9e94b997388 100644 --- a/plan-design-review/SKILL.md +++ b/plan-design-review/SKILL.md @@ -30,7 +30,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -51,8 +50,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"plan-design-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"plan-design-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -70,6 +69,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -296,24 +298,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -339,6 +323,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -357,22 +359,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -944,6 +946,44 @@ descriptions of what 10/10 looks like. ## Review Sections (7 passes, after scope is agreed) +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ### Pass 1: Information Architecture Rate 0-10: Does the plan define what the user sees first, second, third? FIX TO 10: Add information hierarchy to the plan. Include ASCII diagram of screen/page structure and navigation flow. Apply "constraint worship" — if you can only show 3 things, which 3? @@ -1300,6 +1340,31 @@ plan's living status. - Always place it as the very last section in the plan file. If it was found mid-file, move it: delete the old location and append at the end. +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"plan-design-review","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Next Steps — Review Chaining After displaying the Review Readiness Dashboard, recommend the next review(s) based on what this design review discovered. Read the dashboard output to see which reviews have already been run and whether they are stale. diff --git a/plan-design-review/SKILL.md.tmpl b/plan-design-review/SKILL.md.tmpl index 3670f405b591988e0d43f4c7ebfe1c6a806999c6..4d12d2f62bc327a190fdeb56bd2b8b294c46871f 100644 --- a/plan-design-review/SKILL.md.tmpl +++ b/plan-design-review/SKILL.md.tmpl @@ -256,6 +256,8 @@ descriptions of what 10/10 looks like. ## Review Sections (7 passes, after scope is agreed) +{{LEARNINGS_SEARCH}} + ### Pass 1: Information Architecture Rate 0-10: Does the plan define what the user sees first, second, third? FIX TO 10: Add information hierarchy to the plan. Include ASCII diagram of screen/page structure and navigation flow. Apply "constraint worship" — if you can only show 3 things, which 3? @@ -431,6 +433,8 @@ Substitute values from the Completion Summary: {{PLAN_FILE_REVIEW_REPORT}} +{{LEARNINGS_LOG}} + ## Next Steps — Review Chaining After displaying the Review Readiness Dashboard, recommend the next review(s) based on what this design review discovered. Read the dashboard output to see which reviews have already been run and whether they are stale. diff --git a/plan-eng-review/SKILL.md b/plan-eng-review/SKILL.md index d2715aac09bba138b3923b409832cb1bbd08012a..a8790469cb7eda99d6bfa12f242a78a1ed045e7e 100644 --- a/plan-eng-review/SKILL.md +++ b/plan-eng-review/SKILL.md @@ -31,7 +31,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -52,8 +51,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"plan-eng-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"plan-eng-review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -71,6 +70,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -297,24 +299,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -340,6 +324,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -358,22 +360,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -1249,6 +1251,31 @@ plan's living status. - Always place it as the very last section in the plan file. If it was found mid-file, move it: delete the old location and append at the end. +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"plan-eng-review","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Next Steps — Review Chaining After displaying the Review Readiness Dashboard, check if additional reviews would be valuable. Read the dashboard output to see which reviews have already been run and whether they are stale. diff --git a/plan-eng-review/SKILL.md.tmpl b/plan-eng-review/SKILL.md.tmpl index f15fc7f5890b554c55a5e61b5d6e5e1a18e93e00..fca7535efa36fd285614bea35098a2d8813baed0 100644 --- a/plan-eng-review/SKILL.md.tmpl +++ b/plan-eng-review/SKILL.md.tmpl @@ -287,6 +287,8 @@ Substitute values from the Completion Summary: {{PLAN_FILE_REVIEW_REPORT}} +{{LEARNINGS_LOG}} + ## Next Steps — Review Chaining After displaying the Review Readiness Dashboard, check if additional reviews would be valuable. Read the dashboard output to see which reviews have already been run and whether they are stale. diff --git a/qa-only/SKILL.md b/qa-only/SKILL.md index 63c970ad63a27c819ad1ab04d91900f31e162e14..d2764dc9907398baae8daa87c7464eed7c3a58d2 100644 --- a/qa-only/SKILL.md +++ b/qa-only/SKILL.md @@ -27,7 +27,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -48,8 +47,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"qa-only","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"qa-only","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -67,6 +66,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -293,24 +295,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -336,6 +320,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -354,22 +356,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -487,6 +489,44 @@ mkdir -p "$REPORT_DIR/screenshots" --- +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ## Test Plan Context Before falling back to git diff heuristics, check for richer test plan sources: @@ -811,6 +851,31 @@ Report filenames use the domain and date: `qa-report-myapp-com-2026-03-12.md` --- +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"qa-only","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Additional Rules (qa-only specific) 11. **Never fix bugs.** Find and document only. Do not read source code, edit files, or suggest fixes in the report. Your job is to report what's broken, not to fix it. Use `/qa` for the test-fix-verify loop. diff --git a/qa-only/SKILL.md.tmpl b/qa-only/SKILL.md.tmpl index d9fc965850a3bf04b6baea4a5f19000e3aa990c8..1aea67e0bf4ed4b4e2e9ec1e1b1d4399ac813a1e 100644 --- a/qa-only/SKILL.md.tmpl +++ b/qa-only/SKILL.md.tmpl @@ -49,6 +49,8 @@ mkdir -p "$REPORT_DIR/screenshots" --- +{{LEARNINGS_SEARCH}} + ## Test Plan Context Before falling back to git diff heuristics, check for richer test plan sources: @@ -97,6 +99,8 @@ Report filenames use the domain and date: `qa-report-myapp-com-2026-03-12.md` --- +{{LEARNINGS_LOG}} + ## Additional Rules (qa-only specific) 11. **Never fix bugs.** Find and document only. Do not read source code, edit files, or suggest fixes in the report. Your job is to report what's broken, not to fix it. Use `/qa` for the test-fix-verify loop. diff --git a/qa/SKILL.md b/qa/SKILL.md index e2a0322632dc42ada1132fa4284d0fc5e07f25ec..ff830daf265aae0466d231764915e224769bc907 100644 --- a/qa/SKILL.md +++ b/qa/SKILL.md @@ -33,7 +33,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -54,8 +53,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"qa","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"qa","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -73,6 +72,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -299,24 +301,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -342,6 +326,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -360,22 +362,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -717,6 +719,44 @@ mkdir -p .gstack/qa-reports/screenshots --- +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ## Test Plan Context Before falling back to git diff heuristics, check for richer test plan sources: @@ -1218,6 +1258,31 @@ If the repo has a `TODOS.md`: --- +## Capture Learnings + +If you discovered a non-obvious pattern, pitfall, or architectural insight during +this session, log it for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"qa","type":"TYPE","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"SOURCE","files":["path/to/relevant/file"]}' +``` + +**Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). + +**Sources:** `observed` (you found this in the code), `user-stated` (user told you), +`inferred` (AI deduction), `cross-model` (both Claude and Codex agree). + +**Confidence:** 1-10. Be honest. An observed pattern you verified in the code is 8-9. +An inference you're not sure about is 4-5. A user preference they explicitly stated is 10. + +**files:** Include the specific file paths this learning references. This enables +staleness detection: if those files are later deleted, the learning can be flagged. + +**Only log genuine discoveries.** Don't log obvious things. Don't log things the user +already knows. A good test: would this insight save time in a future session? If yes, log it. + ## Additional Rules (qa-specific) 11. **Clean working tree required.** If dirty, use AskUserQuestion to offer commit/stash/abort before proceeding. diff --git a/qa/SKILL.md.tmpl b/qa/SKILL.md.tmpl index 20f70ef94c0750471f63764da9d94444b6e6a540..697853953ae640ee16d872af07dc1aa8a3a543ab 100644 --- a/qa/SKILL.md.tmpl +++ b/qa/SKILL.md.tmpl @@ -90,6 +90,8 @@ mkdir -p .gstack/qa-reports/screenshots --- +{{LEARNINGS_SEARCH}} + ## Test Plan Context Before falling back to git diff heuristics, check for richer test plan sources: @@ -315,6 +317,8 @@ If the repo has a `TODOS.md`: --- +{{LEARNINGS_LOG}} + ## Additional Rules (qa-specific) 11. **Clean working tree required.** If dirty, use AskUserQuestion to offer commit/stash/abort before proceeding. diff --git a/retro/SKILL.md b/retro/SKILL.md index 52af68daf460dc0fed5d46671ce1306741b59337..cad5ed93071ea111ca150e757baff20e7c01c809 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -27,7 +27,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -48,8 +47,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"retro","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"retro","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -67,6 +66,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -275,24 +277,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -318,6 +302,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -336,22 +338,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -481,6 +483,44 @@ Usage: /retro [window | compare | global] **If the first argument is `global`:** Skip the normal repo-scoped retro (Steps 1-14). Instead, follow the **Global Retrospective** flow at the end of this document. The optional second argument is the time window (default 7d). This mode does NOT require being inside a git repo. +## Prior Learnings + +Search for relevant learnings from previous sessions: + +```bash +_CROSS_PROJ=$(~/.claude/skills/gstack/bin/gstack-config get cross_project_learnings 2>/dev/null || echo "unset") +echo "CROSS_PROJECT: $_CROSS_PROJ" +if [ "$_CROSS_PROJ" = "true" ]; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 --cross-project 2>/dev/null || true +else + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 10 2>/dev/null || true +fi +``` + +If `CROSS_PROJECT` is `unset` (first time): Use AskUserQuestion: + +> gstack can search learnings from your other projects on this machine to find +> patterns that might apply here. This stays local (no data leaves your machine). +> Recommended for solo developers. Skip if you work on multiple client codebases +> where cross-contamination would be a concern. + +Options: +- A) Enable cross-project learnings (recommended) +- B) Keep learnings project-scoped only + +If A: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings true` +If B: run `~/.claude/skills/gstack/bin/gstack-config set cross_project_learnings false` + +Then re-run the search with the appropriate flag. + +If learnings are found, incorporate them into your analysis. When a review finding +matches a past learning, display: + +**"Prior learning applied: [key] (confidence N/10, from [date])"** + +This makes the compounding visible. The user should see that gstack is getting +smarter on their codebase over time. + ### Step 1: Gather Raw Data First, fetch origin and identify the current user: @@ -710,7 +750,8 @@ this session, log it for future sessions: ``` **Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` -(user stated), `architecture` (structural decision), `tool` (library/framework insight). +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). **Sources:** `observed` (you found this in the code), `user-stated` (user told you), `inferred` (AI deduction), `cross-model` (both Claude and Codex agree). diff --git a/retro/SKILL.md.tmpl b/retro/SKILL.md.tmpl index 5b201cf6640aadac0c2486eebd1019d79e319653..d89cb717523090d24ba348c22524de281296edc9 100644 --- a/retro/SKILL.md.tmpl +++ b/retro/SKILL.md.tmpl @@ -58,6 +58,8 @@ Usage: /retro [window | compare | global] **If the first argument is `global`:** Skip the normal repo-scoped retro (Steps 1-14). Instead, follow the **Global Retrospective** flow at the end of this document. The optional second argument is the time window (default 7d). This mode does NOT require being inside a git repo. +{{LEARNINGS_SEARCH}} + ### Step 1: Gather Raw Data First, fetch origin and identify the current user: diff --git a/review/SKILL.md b/review/SKILL.md index 177080ebe7b87892988c1b351c8924eecc51e038..4ef3009f4b449c06e4802830a40c202172f77edf 100644 --- a/review/SKILL.md +++ b/review/SKILL.md @@ -30,7 +30,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -51,8 +50,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"review","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -70,6 +69,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -296,24 +298,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -339,6 +323,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -357,22 +359,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -1229,7 +1231,8 @@ this session, log it for future sessions: ``` **Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` -(user stated), `architecture` (structural decision), `tool` (library/framework insight). +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). **Sources:** `observed` (you found this in the code), `user-stated` (user told you), `inferred` (AI deduction), `cross-model` (both Claude and Codex agree). diff --git a/scripts/resolvers/learnings.ts b/scripts/resolvers/learnings.ts index 3bcba7b1fae535bb51d80abfb4c1a0f67afbcf94..685188fb2e711450bd881f354669dc25fffa67cf 100644 --- a/scripts/resolvers/learnings.ts +++ b/scripts/resolvers/learnings.ts @@ -80,7 +80,8 @@ ${binDir}/gstack-learnings-log '{"skill":"${ctx.skillName}","type":"TYPE","key": \`\`\` **Types:** \`pattern\` (reusable approach), \`pitfall\` (what NOT to do), \`preference\` -(user stated), \`architecture\` (structural decision), \`tool\` (library/framework insight). +(user stated), \`architecture\` (structural decision), \`tool\` (library/framework insight), +\`operational\` (project environment/CLI/workflow knowledge). **Sources:** \`observed\` (you found this in the code), \`user-stated\` (user told you), \`inferred\` (AI deduction), \`cross-model\` (both Claude and Codex agree). diff --git a/scripts/resolvers/preamble.ts b/scripts/resolvers/preamble.ts index 7b144b2f8bd95e5bd3d0517c90d36455f14b9071..e131430075c6e87a92c639b44300270976338103 100644 --- a/scripts/resolvers/preamble.ts +++ b/scripts/resolvers/preamble.ts @@ -8,9 +8,8 @@ import type { TemplateContext } from './types'; * repo mode detection, and telemetry. * * Telemetry data flow: - * 1. If _TEL != "off": local JSONL append to ~/.gstack/analytics/ (inline, inspectable) + * 1. Always: local JSONL append to ~/.gstack/analytics/ (inline, inspectable) * 2. If _TEL != "off" AND binary exists: gstack-telemetry-log for remote reporting - * When telemetry is off, nothing is written anywhere. Clean trust contract. */ function generatePreambleBash(ctx: TemplateContext): string { @@ -34,7 +33,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(${ctx.paths.binDir}/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(${ctx.paths.binDir}/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -55,8 +53,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: \${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "\${_TEL:-off}" != "off" ]; then - echo '{"skill":"${ctx.skillName}","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"${ctx.skillName}","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -74,6 +72,9 @@ _LEARN_FILE="\${GSTACK_HOME:-$HOME/.gstack}/projects/\${SLUG:-unknown}/learnings if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ${ctx.paths.binDir}/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -379,27 +380,7 @@ jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg b \`\`\``; } -function generateContributorMode(): string { - return `## Contributor Mode - -If \`_CONTRIB\` is \`true\`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write \`~/.gstack/contributor-logs/{slug}.md\`: -\`\`\` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -\`\`\` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop.`; -} - -function generateCompletionStatus(): string { +function generateCompletionStatus(ctx: TemplateContext): string { return `## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -425,6 +406,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] \`\`\` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +\`\`\`bash +${ctx.paths.binDir}/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +\`\`\` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -443,22 +442,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \\ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \\ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \\ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \\ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi \`\`\` Replace \`SKILL_NAME\` with the actual skill name from frontmatter, \`OUTCOME\` with success/error/abort, and \`USED_BROWSE\` with true/false based on whether \`$B\` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -572,7 +571,7 @@ Avoid filler, throat-clearing, generic optimism, founder cosplay, and unsupporte // Preamble Composition (tier → sections) // ───────────────────────────────────────────── -// T1: core + upgrade + lake + telemetry + voice(trimmed) + contributor + completion +// T1: core + upgrade + lake + telemetry + voice(trimmed) + completion // T2: T1 + voice(full) + ask + completeness // T3: T2 + repo-mode + search // T4: (same as T3 — TEST_FAILURE_TRIAGE is a separate {{}} placeholder, not preamble) @@ -597,8 +596,7 @@ export function generatePreamble(ctx: TemplateContext): string { generateVoiceDirective(tier), ...(tier >= 2 ? [generateAskUserFormat(ctx), generateCompletenessSection()] : []), ...(tier >= 3 ? [generateRepoModeSection(), generateSearchBeforeBuildingSection(ctx)] : []), - generateContributorMode(), - generateCompletionStatus(), + generateCompletionStatus(ctx), ]; return sections.join('\n\n'); } diff --git a/setup-browser-cookies/SKILL.md b/setup-browser-cookies/SKILL.md index 9724e928e3196f4a5e490eaebb2d80d71c009ad3..b7c07511a03012657a63513a7d79de57bfff0581 100644 --- a/setup-browser-cookies/SKILL.md +++ b/setup-browser-cookies/SKILL.md @@ -24,7 +24,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -45,8 +44,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"setup-browser-cookies","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"setup-browser-cookies","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -64,6 +63,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -207,24 +209,6 @@ This only happens once per project. If `HAS_ROUTING` is `yes` or `ROUTING_DECLIN The user always has context you don't. Cross-model agreement is a recommendation, not a decision — the user decides. -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -250,6 +234,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -268,22 +270,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/setup-deploy/SKILL.md b/setup-deploy/SKILL.md index 4d174c72a1c5ce90aa1591bd337eba5d7cb08624..a1f6d93e112ccdaccc8812ee8dd4f6bddf94688e 100644 --- a/setup-deploy/SKILL.md +++ b/setup-deploy/SKILL.md @@ -30,7 +30,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -51,8 +50,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"setup-deploy","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"setup-deploy","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -70,6 +69,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -278,24 +280,6 @@ AI makes completeness near-free. Always recommend the complete option over short Include `Completeness: X/10` for each option (10=all edge cases, 7=happy path, 3=shortcut). -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -321,6 +305,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -339,22 +341,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations diff --git a/ship/SKILL.md b/ship/SKILL.md index c58dbbbf77975805a04c788e183f633585642ef4..efcd9c0aced6a668d3e841895b84b7444ecee4c0 100644 --- a/ship/SKILL.md +++ b/ship/SKILL.md @@ -31,7 +31,6 @@ mkdir -p ~/.gstack/sessions touch ~/.gstack/sessions/"$PPID" _SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') find ~/.gstack/sessions -mmin +120 -type f -exec rm {} + 2>/dev/null || true -_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) _PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") _PROACTIVE_PROMPTED=$([ -f ~/.gstack/.proactive-prompted ] && echo "yes" || echo "no") _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") @@ -52,8 +51,8 @@ _SESSION_ID="$$-$(date +%s)" echo "TELEMETRY: ${_TEL:-off}" echo "TEL_PROMPTED: $_TEL_PROMPTED" mkdir -p ~/.gstack/analytics -if [ "${_TEL:-off}" != "off" ]; then - echo '{"skill":"ship","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +if [ "$_TEL" != "off" ]; then +echo '{"skill":"ship","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true fi # zsh-compatible: use find instead of glob to avoid NOMATCH error for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do @@ -71,6 +70,9 @@ _LEARN_FILE="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}/learnings.j if [ -f "$_LEARN_FILE" ]; then _LEARN_COUNT=$(wc -l < "$_LEARN_FILE" 2>/dev/null | tr -d ' ') echo "LEARNINGS: $_LEARN_COUNT entries loaded" + if [ "$_LEARN_COUNT" -gt 5 ] 2>/dev/null; then + ~/.claude/skills/gstack/bin/gstack-learnings-search --limit 3 2>/dev/null || true + fi else echo "LEARNINGS: 0" fi @@ -297,24 +299,6 @@ Before building anything unfamiliar, **search first.** See `~/.claude/skills/gst jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true ``` -## Contributor Mode - -If `_CONTRIB` is `true`: you are in **contributor mode**. At the end of each major workflow step, rate your gstack experience 0-10. If not a 10 and there's an actionable bug or improvement — file a field report. - -**File only:** gstack tooling bugs where the input was reasonable but gstack failed. **Skip:** user app bugs, network errors, auth failures on user's site. - -**To file:** write `~/.gstack/contributor-logs/{slug}.md`: -``` -# {Title} -**What I tried:** {action} | **What happened:** {result} | **Rating:** {0-10} -## Repro -1. {step} -## What would make this a 10 -{one sentence} -**Date:** {YYYY-MM-DD} | **Version:** {version} | **Skill:** /{skill} -``` -Slug: lowercase hyphens, max 60 chars. Skip if exists. Max 3/session. File inline, don't stop. - ## Completion Status Protocol When completing a skill workflow, report status using one of: @@ -340,6 +324,24 @@ ATTEMPTED: [what you tried] RECOMMENDATION: [what the user should do next] ``` +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? +- Did you take a wrong approach and have to backtrack? +- Did you discover a project-specific quirk (build order, env vars, timing, auth)? +- Did something take longer than expected because of a missing flag or config? + +If yes, log an operational learning for future sessions: + +```bash +~/.claude/skills/gstack/bin/gstack-learnings-log '{"skill":"SKILL_NAME","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +``` + +Replace SKILL_NAME with the current skill name. Only log genuine operational discoveries. +Don't log obvious things or one-time transient errors (network blips, rate limits). +A good test: would knowing this save 5+ minutes in a future session? If yes, log it. + ## Telemetry (run last) After the skill workflow completes (success, error, or abort), log the telemetry event. @@ -358,22 +360,22 @@ Run this bash: _TEL_END=$(date +%s) _TEL_DUR=$(( _TEL_END - _TEL_START )) rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true -# Local + remote telemetry (both gated by _TEL setting) +# Local analytics (gated on telemetry setting) if [ "$_TEL" != "off" ]; then - echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true - if [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then - ~/.claude/skills/gstack/bin/gstack-telemetry-log \ - --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ - --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & - fi +echo '{"skill":"SKILL_NAME","duration_s":"'"$_TEL_DUR"'","outcome":"OUTCOME","browse":"USED_BROWSE","session":"'"$_SESSION_ID"'","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +fi +# Remote telemetry (opt-in, requires binary) +if [ "$_TEL" != "off" ] && [ -x ~/.claude/skills/gstack/bin/gstack-telemetry-log ]; then + ~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & fi ``` Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. -If you cannot determine the outcome, use "unknown". Both local JSONL and remote -telemetry only run if telemetry is not off. The remote binary additionally requires -the binary to exist. +If you cannot determine the outcome, use "unknown". The local JSONL always logs. The +remote binary only runs if telemetry is not off and the binary exists. ## Plan Mode Safe Operations @@ -1775,7 +1777,8 @@ this session, log it for future sessions: ``` **Types:** `pattern` (reusable approach), `pitfall` (what NOT to do), `preference` -(user stated), `architecture` (structural decision), `tool` (library/framework insight). +(user stated), `architecture` (structural decision), `tool` (library/framework insight), +`operational` (project environment/CLI/workflow knowledge). **Sources:** `observed` (you found this in the code), `user-stated` (user told you), `inferred` (AI deduction), `cross-model` (both Claude and Codex agree). diff --git a/test/gen-skill-docs.test.ts b/test/gen-skill-docs.test.ts index fff58a5e7b665c44a2928a8de2d35dde07934b9d..4a25195defd44f4cadc5e71b57390a4e02074d09 100644 --- a/test/gen-skill-docs.test.ts +++ b/test/gen-skill-docs.test.ts @@ -213,11 +213,20 @@ describe('gen-skill-docs', () => { expect(browseTmpl).toContain('{{PREAMBLE}}'); }); - test('generated SKILL.md contains contributor mode check', () => { + test('generated SKILL.md contains operational self-improvement (replaced contributor mode)', () => { const content = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); - expect(content).toContain('Contributor Mode'); - expect(content).toContain('gstack_contributor'); - expect(content).toContain('contributor-logs'); + expect(content).not.toContain('Contributor Mode'); + expect(content).not.toContain('gstack_contributor'); + expect(content).not.toContain('contributor-logs'); + expect(content).toContain('Operational Self-Improvement'); + expect(content).toContain('gstack-learnings-log'); + expect(content).toContain('gstack-learnings-search --limit 3'); + }); + + test('generated SKILL.md with LEARNINGS_LOG contains operational type', () => { + // Check a skill that has LEARNINGS_LOG (e.g., review) + const content = fs.readFileSync(path.join(ROOT, 'review', 'SKILL.md'), 'utf-8'); + expect(content).toContain('operational'); }); test('generated SKILL.md contains session awareness', () => { diff --git a/test/helpers/touchfiles.ts b/test/helpers/touchfiles.ts index efa5cd15e962813432954ce7d662df5033c95a9e..0f6c472a4e945a49638c53ed62aa1a041db829bb 100644 --- a/test/helpers/touchfiles.ts +++ b/test/helpers/touchfiles.ts @@ -41,8 +41,8 @@ export const E2E_TOUCHFILES: Record = { 'skillmd-no-local-binary': ['SKILL.md', 'SKILL.md.tmpl', 'scripts/gen-skill-docs.ts'], 'skillmd-outside-git': ['SKILL.md', 'SKILL.md.tmpl', 'scripts/gen-skill-docs.ts'], - 'contributor-mode': ['SKILL.md.tmpl', 'scripts/gen-skill-docs.ts'], 'session-awareness': ['SKILL.md', 'SKILL.md.tmpl', 'scripts/gen-skill-docs.ts'], + 'operational-learning': ['scripts/resolvers/preamble.ts', 'bin/gstack-learnings-log'], // QA (+ test-server dependency) 'qa-quick': ['qa/**', 'browse/src/**', 'browse/test/test-server.ts'], @@ -193,8 +193,8 @@ export const E2E_TIERS: Record = { 'skillmd-setup-discovery': 'gate', 'skillmd-no-local-binary': 'gate', 'skillmd-outside-git': 'gate', - 'contributor-mode': 'gate', 'session-awareness': 'gate', + 'operational-learning': 'gate', // QA — gate for functional, periodic for quality/benchmarks 'qa-quick': 'gate', diff --git a/test/skill-e2e-bws.test.ts b/test/skill-e2e-bws.test.ts index 6a611fe7c218ca7138d1617734637a5a3bfc039e..c1a1be15d2bce7c8e10c660878f38332cd06fa7c 100644 --- a/test/skill-e2e-bws.test.ts +++ b/test/skill-e2e-bws.test.ts @@ -20,6 +20,7 @@ let tmpDir: string; describeIfSelected('Skill E2E tests', [ 'browse-basic', 'browse-snapshot', 'skillmd-setup-discovery', 'skillmd-no-local-binary', 'skillmd-outside-git', 'session-awareness', + 'operational-learning', ], () => { beforeAll(() => { testServer = startTestServer(); @@ -177,49 +178,96 @@ Report the exact output — either "READY: " or "NEEDS_SETUP".`, try { fs.rmSync(nonGitDir, { recursive: true, force: true }); } catch {} }, 60_000); - testConcurrentIfSelected('contributor-mode', async () => { - const contribDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-contrib-')); - const logsDir = path.join(contribDir, 'contributor-logs'); - fs.mkdirSync(logsDir, { recursive: true }); + testConcurrentIfSelected('operational-learning', async () => { + const opDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-oplearn-')); + const gstackHome = path.join(opDir, '.gstack-home'); + + // Init git repo + const run = (cmd: string, args: string[]) => + spawnSync(cmd, args, { cwd: opDir, stdio: 'pipe', timeout: 5000 }); + run('git', ['init', '-b', 'main']); + run('git', ['config', 'user.email', 'test@test.com']); + run('git', ['config', 'user.name', 'Test']); + fs.writeFileSync(path.join(opDir, 'app.ts'), 'console.log("hello");\n'); + run('git', ['add', '.']); + run('git', ['commit', '-m', 'initial']); + + // Copy bin scripts + const binDir = path.join(opDir, 'bin'); + fs.mkdirSync(binDir, { recursive: true }); + for (const script of ['gstack-learnings-log', 'gstack-slug']) { + fs.copyFileSync(path.join(ROOT, 'bin', script), path.join(binDir, script)); + fs.chmodSync(path.join(binDir, script), 0o755); + } + + // gstack-learnings-log will create the project dir automatically via gstack-slug const result = await runSkillTest({ - prompt: `You are in contributor mode (gstack_contributor=true). You just ran this browse command and it failed: + prompt: `You just ran \`npm test\` in this project and it failed with this error: -$ /nonexistent/browse goto https://example.com -/nonexistent/browse: No such file or directory +Error: --experimental-vm-modules flag is required for ESM support in this project. +Run: npm test --experimental-vm-modules -Per the contributor mode instructions, file a field report to ${logsDir}/browse-missing-binary.md using the Write tool. Include all required sections: title, what you tried, what happened, rating, repro steps, raw output, what would make it a 10, and the date/version footer.`, - workingDirectory: contribDir, +Per the Operational Self-Improvement instructions below, log an operational learning about this failure. + +## Operational Self-Improvement + +Before completing, reflect on this session: +- Did any commands fail unexpectedly? + +If yes, log an operational learning for future sessions: + +\`\`\`bash +GSTACK_HOME="${gstackHome}" ${binDir}/gstack-learnings-log '{"skill":"qa","type":"operational","key":"SHORT_KEY","insight":"DESCRIPTION","confidence":N,"source":"observed"}' +\`\`\` + +Replace SHORT_KEY with a kebab-case key like "esm-vm-modules-flag". +Replace DESCRIPTION with a one-sentence description of what you learned. +Replace N with a confidence score 1-10. + +Log the operational learning now. Then say what you logged.`, + workingDirectory: opDir, maxTurns: 5, timeout: 30_000, - testName: 'contributor-mode', + testName: 'operational-learning', runId, }); - logCost('contributor mode', result); - // Override passed: this test intentionally triggers a browse error (nonexistent binary) - // so browseErrors will be non-empty — that's expected, not a failure - recordE2E(evalCollector, 'contributor mode report', 'Skill E2E tests', result, { - passed: result.exitReason === 'success', + logCost('operational learning', result); + + const exitOk = ['success', 'error_max_turns'].includes(result.exitReason); + + // Check if learnings file was created with an operational entry + // The slug is derived from the git repo (dirname), so search all project dirs + let hasOperational = false; + const projectsDir = path.join(gstackHome, 'projects'); + if (fs.existsSync(projectsDir)) { + for (const slug of fs.readdirSync(projectsDir)) { + const lPath = path.join(projectsDir, slug, 'learnings.jsonl'); + if (fs.existsSync(lPath)) { + const jsonl = fs.readFileSync(lPath, 'utf-8').trim(); + if (jsonl) { + const entries = jsonl.split('\n').map(l => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); + const opEntry = entries.find(e => e.type === 'operational'); + if (opEntry) { + hasOperational = true; + console.log(`Operational learning logged: key="${opEntry.key}" insight="${opEntry.insight}" (slug: ${slug})`); + break; + } + } + } + } + } + + recordE2E(evalCollector, 'operational learning', 'Skill E2E tests', result, { + passed: exitOk && hasOperational, }); - // Verify a contributor log was created with expected format - const logFiles = fs.readdirSync(logsDir).filter(f => f.endsWith('.md')); - expect(logFiles.length).toBeGreaterThan(0); - - // Verify report has key structural sections (agent may phrase differently) - const logContent = fs.readFileSync(path.join(logsDir, logFiles[0]), 'utf-8'); - // Must have a title (# heading) - expect(logContent).toMatch(/^#\s/m); - // Must mention the failed command or browse - expect(logContent).toMatch(/browse|nonexistent|not found|no such file/i); - // Must have some kind of rating - expect(logContent).toMatch(/rating|\/10/i); - // Must have steps or reproduction info - expect(logContent).toMatch(/step|repro|reproduce/i); + expect(exitOk).toBe(true); + expect(hasOperational).toBe(true); // Clean up - try { fs.rmSync(contribDir, { recursive: true, force: true }); } catch {} + try { fs.rmSync(opDir, { recursive: true, force: true }); } catch {} }, 90_000); testConcurrentIfSelected('session-awareness', async () => { diff --git a/test/skill-e2e-learnings.test.ts b/test/skill-e2e-learnings.test.ts index dfd1851351b9476d3bc12dccd853ce8661b91ee4..8b6dec944d031e70cfe8818e791d8cb775ff3084 100644 --- a/test/skill-e2e-learnings.test.ts +++ b/test/skill-e2e-learnings.test.ts @@ -44,8 +44,9 @@ describeIfSelected('Learnings E2E', ['learnings-show'], () => { fs.chmodSync(path.join(binDir, script), 0o755); } - // Seed learnings JSONL with 3 entries of different types - const slug = 'test-project'; + // Seed learnings JSONL — slug must match what gstack-slug computes. + // With no git remote, gstack-slug falls back to basename(workDir). + const slug = path.basename(workDir).replace(/[^a-zA-Z0-9._-]/g, ''); const projectDir = path.join(gstackHome, 'projects', slug); fs.mkdirSync(projectDir, { recursive: true }); @@ -67,6 +68,11 @@ describeIfSelected('Learnings E2E', ['learnings-show'], () => { insight: 'User wants rubocop to run before every commit, no exceptions.', confidence: 10, source: 'user-stated', ts: new Date().toISOString(), }, + { + skill: 'qa', type: 'operational', key: 'test-timeout-flag', + insight: 'bun test requires --timeout 30000 for E2E tests in this project.', + confidence: 9, source: 'observed', ts: new Date().toISOString(), + }, ]; fs.writeFileSync( diff --git a/test/skill-e2e.test.ts b/test/skill-e2e.test.ts index 2f92d095ff4de18a79aeba2d7a1fc5c4b7699ee5..9c314cb39e2f703f0aa4b42cb23f063d9a76e638 100644 --- a/test/skill-e2e.test.ts +++ b/test/skill-e2e.test.ts @@ -325,62 +325,6 @@ Report the exact output — either "READY: " or "NEEDS_SETUP".`, try { fs.rmSync(nonGitDir, { recursive: true, force: true }); } catch {} }, 60_000); - testIfSelected('contributor-mode', async () => { - const contribDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-contrib-')); - const logsDir = path.join(contribDir, 'contributor-logs'); - fs.mkdirSync(logsDir, { recursive: true }); - - // Extract contributor mode instructions from generated SKILL.md - const skillMd = fs.readFileSync(path.join(ROOT, 'SKILL.md'), 'utf-8'); - const contribStart = skillMd.indexOf('## Contributor Mode'); - const contribEnd = skillMd.indexOf('\n## ', contribStart + 1); - const contribBlock = skillMd.slice(contribStart, contribEnd > 0 ? contribEnd : undefined); - - const result = await runSkillTest({ - prompt: `You are in contributor mode (_CONTRIB=true). - -${contribBlock} - -OVERRIDE: Write contributor logs to ${logsDir}/ instead of ~/.gstack/contributor-logs/ - -Now try this browse command (it will fail — there is no binary at this path): -/nonexistent/path/browse goto https://example.com - -This is a gstack issue (the browse binary is missing/misconfigured). -File a contributor report about this issue. Then tell me what you filed.`, - workingDirectory: contribDir, - maxTurns: 8, - timeout: 60_000, - testName: 'contributor-mode', - runId, - }); - - logCost('contributor mode', result); - // Override passed: this test intentionally triggers a browse error (nonexistent binary) - // so browseErrors will be non-empty — that's expected, not a failure - recordE2E('contributor mode report', 'Skill E2E tests', result, { - passed: result.exitReason === 'success', - }); - - // Verify a contributor log was created with expected format - const logFiles = fs.readdirSync(logsDir).filter(f => f.endsWith('.md')); - expect(logFiles.length).toBeGreaterThan(0); - - // Verify new reflection-based format - const logContent = fs.readFileSync(path.join(logsDir, logFiles[0]), 'utf-8'); - expect(logContent).toContain('Hey gstack team'); - expect(logContent).toContain('What I was trying to do'); - expect(logContent).toContain('What happened instead'); - expect(logContent).toMatch(/rating/i); - // Verify report has repro steps (agent may use "Steps to reproduce", "Repro Steps", etc.) - expect(logContent).toMatch(/repro|steps to reproduce|how to reproduce/i); - // Verify report has date/version footer (agent may format differently) - expect(logContent).toMatch(/date.*2026|2026.*date/i); - - // Clean up - try { fs.rmSync(contribDir, { recursive: true, force: true }); } catch {} - }, 90_000); - testIfSelected('session-awareness', async () => { const sessionDir = fs.mkdtempSync(path.join(os.tmpdir(), 'skill-e2e-session-')); diff --git a/test/skill-validation.test.ts b/test/skill-validation.test.ts index 91240e235311fd2b45b77c386b37f2a76abb44d0..26a0870d1679f0df7d5e70627f13d5c89cd8e062 100644 --- a/test/skill-validation.test.ts +++ b/test/skill-validation.test.ts @@ -735,45 +735,8 @@ describe('investigate skill structure', () => { } }); -// --- Contributor mode preamble structure validation --- - -describe('Contributor mode preamble structure', () => { - const skillsWithPreamble = [ - 'SKILL.md', 'browse/SKILL.md', 'qa/SKILL.md', - 'qa-only/SKILL.md', - 'setup-browser-cookies/SKILL.md', - 'ship/SKILL.md', 'review/SKILL.md', - 'plan-ceo-review/SKILL.md', 'plan-eng-review/SKILL.md', - 'retro/SKILL.md', - 'plan-design-review/SKILL.md', - 'design-review/SKILL.md', - 'design-consultation/SKILL.md', - 'document-release/SKILL.md', - 'canary/SKILL.md', - 'benchmark/SKILL.md', - 'land-and-deploy/SKILL.md', - 'setup-deploy/SKILL.md', - ]; - - for (const skill of skillsWithPreamble) { - test(`${skill} has 0-10 rating in contributor mode`, () => { - const content = fs.readFileSync(path.join(ROOT, skill), 'utf-8'); - expect(content).toContain('0-10'); - expect(content).toContain('Rating'); - }); - - test(`${skill} has "what would make this a 10" field`, () => { - const content = fs.readFileSync(path.join(ROOT, skill), 'utf-8'); - expect(content).toContain('What would make this a 10'); - }); - - test(`${skill} uses periodic reflection (not per-command)`, () => { - const content = fs.readFileSync(path.join(ROOT, skill), 'utf-8'); - expect(content).toContain('workflow step'); - expect(content).not.toContain('After you use gstack-provided CLIs'); - }); - } -}); +// Contributor mode was removed in v0.13.10.0 — replaced by operational self-improvement. +// Tests for contributor mode preamble structure are no longer applicable. describe('Enum & Value Completeness in review checklist', () => { const checklist = fs.readFileSync(path.join(ROOT, 'review', 'checklist.md'), 'utf-8'); diff --git a/test/touchfiles.test.ts b/test/touchfiles.test.ts index 2bce835b5ac806923d7970e29c8af511f475c1ec..d4aee2027c5c27454591fea84ad1edd0910e3b42 100644 --- a/test/touchfiles.test.ts +++ b/test/touchfiles.test.ts @@ -101,7 +101,7 @@ describe('selectTests', () => { expect(result.reason).toBe('diff'); // Should include tests that depend on gen-skill-docs.ts expect(result.selected).toContain('skillmd-setup-discovery'); - expect(result.selected).toContain('contributor-mode'); + expect(result.selected).toContain('session-awareness'); expect(result.selected).toContain('journey-ideation'); // Should NOT include tests that don't depend on it expect(result.selected).not.toContain('retro'); @@ -144,7 +144,7 @@ describe('selectTests', () => { const result = selectTests(['SKILL.md.tmpl'], E2E_TOUCHFILES); // Should select the 7 tests that depend on root SKILL.md expect(result.selected).toContain('skillmd-setup-discovery'); - expect(result.selected).toContain('contributor-mode'); + expect(result.selected).toContain('session-awareness'); expect(result.selected).toContain('session-awareness'); // Also selects journey routing tests (SKILL.md.tmpl in their touchfiles) expect(result.selected).toContain('journey-ideation');