From e530e0051cb374178b69fe791cdcba6a02609681 Mon Sep 17 00:00:00 2001 From: Brent Miller Date: Tue, 17 Nov 2026 07:20:11 -0600 Subject: [PATCH] feat(tooling): add script tools, prune prompts, forbid attribution - Add pkg-path.sh to resolve a NuGet package ref and lib directories - Add --range mode to code-read.sh for multi-file line reads - Run the analyzer release check inside check.sh on analyzer diffs - Drop the attribution trailer and reject tool attribution - Delete 19 dead prompts, keep 5 samples, and add a keep rule - Point the check.sh docs at the script catalog --- .claude/agents/smart-commit.md | 5 +- .claude/rules/deterministic-scripts.md | 1 + .claude/skills/yeet/SKILL.md | 5 +- .opencode/agents/smart-commit.md | 5 +- AGENTS.md | 2 +- README.md | 2 +- docs/engineering/getting-started.md | 2 +- docs/reference/cli-commands.md | 2 +- lode/dotnet/release-tracking.md | 13 +-- lode/infrastructure/shipping.md | 6 +- prompts/README.md | 7 ++ prompts/blazing-fast-net.md | 7 ++ prompts/clean-up-rules.md | 3 + prompts/code-review.md | 1 - prompts/find-inefficiencies.md | 9 +- prompts/lode-prompt-update.md | 2 - prompts/lode-update.md | 8 -- prompts/skill-agent-script.md | 21 ----- prompts/token-waster.md | 1 - prompts/untangle-codebase.md | 4 +- scripts/README.md | 7 +- scripts/check.sh | 19 +++- scripts/code-read.sh | 121 ++++++++++++++++--------- scripts/internal/commit.sh | 23 ++--- scripts/pkg-path.sh | 96 ++++++++++++++++++++ scripts/verify-and-ship-test.sh | 2 +- 26 files changed, 256 insertions(+), 118 deletions(-) create mode 100644 prompts/README.md create mode 100644 prompts/blazing-fast-net.md create mode 100644 prompts/clean-up-rules.md delete mode 100644 prompts/code-review.md delete mode 100644 prompts/lode-prompt-update.md delete mode 100644 prompts/lode-update.md delete mode 100644 prompts/skill-agent-script.md delete mode 100644 prompts/token-waster.md create mode 100755 scripts/pkg-path.sh diff --git a/.claude/agents/smart-commit.md b/.claude/agents/smart-commit.md index 43afc9d0..7bb1340f 100644 --- a/.claude/agents/smart-commit.md +++ b/.claude/agents/smart-commit.md @@ -54,8 +54,9 @@ One-shot autonomous commit. No per-step gates, no "does this look right?", no pe ## Rules - **Never put an email address in the commit message**: no `noreply@` line, no email in any - trailer. `commit.sh` and `precommit.sh` enforce this and will reject the commit. `commit.sh` - appends a name-only `Co-Authored-By: Claude` trailer automatically. + trailer. `commit.sh` and `precommit.sh` enforce this and will reject the commit. +- **Never name Claude Code or Anthropic**: no attribution trailer, no footer. `commit.sh` + rejects the phrase. - **Do not push**: leave push to `/yeet` or explicit user instruction - **One commit only**: if changes span clearly unrelated concerns, note it in the output but still commit everything together (user can split manually if they want) diff --git a/.claude/rules/deterministic-scripts.md b/.claude/rules/deterministic-scripts.md index bd8104b2..82962098 100644 --- a/.claude/rules/deterministic-scripts.md +++ b/.claude/rules/deterministic-scripts.md @@ -48,6 +48,7 @@ print terse JSON by default. Use the script help for supported flags. | `dotnet list ... --outdated\|--vulnerable` | `scripts/dep-check.sh [--outdated] [--json]` | | parsing raw MSBuild `File.cs(l,c): error CODE` lines | `scripts/diagnostics.sh [--group\|--code ID\|--diff a b]` | | ad-hoc `PackageReference` classify or cross-project heat map | `scripts/nuget-heat-map.sh [--json]` | +| ad-hoc `~/.nuget/packages` probes for package paths | `scripts/pkg-path.sh PACKAGE [--version V] [--ref\|--lib]` | | ad-hoc SDK, `TargetFramework`, or Docker `FROM` pin scans | `scripts/runtime-matrix.sh [--json]` | | ad-hoc `#pragma warning disable` or `[SuppressMessage]` greps | `scripts/suppression-scan.sh [--json]` | | ad-hoc `PackageVersion` orphan or `ProjectReference` set-diff | `scripts/deps-graph.sh [--orphans] [--json]` | diff --git a/.claude/skills/yeet/SKILL.md b/.claude/skills/yeet/SKILL.md index e3ef2082..9f430432 100644 --- a/.claude/skills/yeet/SKILL.md +++ b/.claude/skills/yeet/SKILL.md @@ -188,6 +188,7 @@ Skip with "Agent mirror skipped: no agent definition changes" when neither path - Subject line must be <=72 chars. Use a body for detail when > 1 major concern - Never truncate the subject: if the auto-generated one ends in `...`, it is wrong - **No email addresses**: never put an email in the message or any trailer, `commit.sh` rejects it + - **Never name Claude Code or Anthropic**: no attribution trailer, no footer. `commit.sh` rejects the phrase - **Commit**: `scripts/internal/commit.sh --skip-precommit "message"` (precommit already ran above) **Both paths converge here:** @@ -197,7 +198,8 @@ Skip with "Agent mirror skipped: no agent definition changes" when neither path gh pr create --title "" --body "" ``` - Title: reuse the commit subject line (the `type(scope): summary` part) - - Body: use these sections, and omit one that does not apply: `## Executive Summary` (problem, cause, fix, and measured results with test conditions), `## Code Changes`, `## Tests and Tooling` (name what did not run), `## Review Guide`, `## Rollback`, and `## Links` for work items. Do not invent causes, measurements, or test results. End with the Claude Code footer. Never include an email address anywhere in the body + - Body: use these sections, and omit one that does not apply: `## Executive Summary` (problem, cause, fix, and measured results with test conditions), `## Code Changes`, `## Tests and Tooling` (name what did not run), `## Review Guide`, `## Rollback`, and `## Links` for work items. Do not invent causes, measurements, or test results. Never name Claude Code or Anthropic. End with no footer. Never include an email address anywhere in the body + - Before `gh pr create`, scan the title and body for `Claude Code` and `Anthropic`. Remove every hit - If a PR already exists for this branch, skip PR creation silently - Report the PR URL at the end @@ -207,6 +209,7 @@ Skip with "Agent mirror skipped: no agent definition changes" when neither path - **Fully autonomous**: no user prompts during execution. Invoking `/yeet` is the user's approval for the push and the PR (`.claude/rules/auto-approvals.md`). - **Stop on failure**: PII fail, build fail, or test fail halts the pipeline - **No email addresses**: never in a commit message, trailer, or PR body. The PII scan blocks real emails in the staged diff and `commit.sh` rejects an email in the message, `user@example.com` placeholders are allowed +- **No Claude Code attribution**: never name Claude Code or Anthropic in a commit message, trailer, or PR body. `commit.sh` rejects the phrase and the PR step scans the body - **Single commit per push, always**: squash every unpushed local commit, with any new changes, into one commit before `git push`. Count with `unpushed`, never `ahead`. Skip the squash only when `unpushed == 1` and there are no new changes. - **Unpushed local commits always ship**: a clean working tree is not a reason to stop if `unpushed > 0`. Check `scripts/branch.sh --json` unconditionally. Never rely on working-tree state alone to decide whether a push is needed. - **Do NOT auto-commit or push again** after completing these steps, one-time action diff --git a/.opencode/agents/smart-commit.md b/.opencode/agents/smart-commit.md index 43346dd1..3d8d6c03 100644 --- a/.opencode/agents/smart-commit.md +++ b/.opencode/agents/smart-commit.md @@ -55,8 +55,9 @@ One-shot autonomous commit. No per-step gates, no "does this look right?", no pe ## Rules - **Never put an email address in the commit message**: no `noreply@` line, no email in any - trailer. `commit.sh` and `precommit.sh` enforce this and will reject the commit. `commit.sh` - appends a name-only `Co-Authored-By: Claude` trailer automatically. + trailer. `commit.sh` and `precommit.sh` enforce this and will reject the commit. +- **Never name Claude Code or Anthropic**: no attribution trailer, no footer. `commit.sh` + rejects the phrase. - **Do not push**: leave push to `/yeet` or explicit user instruction - **One commit only**: if changes span clearly unrelated concerns, note it in the output but still commit everything together (user can split manually if they want) diff --git a/AGENTS.md b/AGENTS.md index c771ce24..8316cb29 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -54,7 +54,7 @@ After an agent definition changes, run `scripts/internal/opencode-agents.sh sync - Commit or ship only when requested. Use the `smart-commit` agent for commits and `/yeet` for shipping. - On a harness without agents or skills, use the scripts named in the routing table with the same approval policy. - Write concise imperative commit summaries. -- Never add a `Co-Authored-By` trailer yourself. `scripts/internal/commit.sh` appends the name-only trailer. +- Do not name Claude Code or Anthropic in a commit message or PR body. Add no attribution trailer. `scripts/internal/commit.sh` rejects the phrase. - Squash only unpushed commits. Preserve pushed history and ship one clean commit per PR. - Run `scripts/status.sh` before staging. Treat concurrent staged, added, or removed files as existing work. - Preserve unrelated work. Take no destructive, production, or external action beyond the authorization given. diff --git a/README.md b/README.md index 4cdd0d58..0901341e 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ scripts/podman.sh test ├── nuget.config # Single source, source mapping, and 72-hour publish age ├── opencode.json # opencode v2 config: model, instructions, MCP, permissions, policies ├── plans/ # Structured planning documents -├── prompts/ # System prompt for Lode sessions +├── prompts/ # Lode system prompt and sample prompts ├── renovate.json # Renovate dependency update config ├── scripts/ # Bash development scripts ([catalog](scripts/README.md)) ├── src/ diff --git a/docs/engineering/getting-started.md b/docs/engineering/getting-started.md index 0baf0aa7..f2df83dc 100644 --- a/docs/engineering/getting-started.md +++ b/docs/engineering/getting-started.md @@ -41,7 +41,7 @@ scripts/build.sh --project Web # build one project scripts/test.sh # CI-trait tests, the fast path scripts/test.sh GreeterTests # one test class scripts/test.sh --all # the full suite -scripts/check.sh # shell lint, format, build, and test +scripts/check.sh # composed gate, steps in scripts/README.md scripts/ci.sh # the full CI pipeline locally scripts/help.sh # every script and its purpose ``` diff --git a/docs/reference/cli-commands.md b/docs/reference/cli-commands.md index 6c2ac204..3235a6b9 100644 --- a/docs/reference/cli-commands.md +++ b/docs/reference/cli-commands.md @@ -25,7 +25,7 @@ flowchart LR | Test, full suite | `scripts/test.sh --all` | includes the Podman and Manual categories | | Format, apply | `scripts/format.sh --changed` | jb cleanup then `dotnet format` | | Format, check | `scripts/format.sh --check` | verify only | -| Composed gate | `scripts/check.sh` | shell lint, format, build, test | +| Composed gate | `scripts/check.sh` | steps in `scripts/README.md` | | Full CI | `scripts/ci.sh` | mirrors the `ci` job | | Session context | `scripts/context.sh` | status, diff, and plans | | Git status | `scripts/status.sh --json` | structured | diff --git a/lode/dotnet/release-tracking.md b/lode/dotnet/release-tracking.md index 4a722e24..4c0f9599 100644 --- a/lode/dotnet/release-tracking.md +++ b/lode/dotnet/release-tracking.md @@ -1,5 +1,5 @@ # Roslyn Analyzer Release Tracking -*Updated: 2026-11-14T00:47:21Z* +*Updated: 2026-11-17T13:14:44Z* ## Overview @@ -92,11 +92,12 @@ nuget.org already carries, because the publish job skips an existing version. **Pre-first-release:** keep all rules in `Unshipped.md`; `Shipped.md` starts with `; No shipped releases yet.` -The `/yeet` skill enforces the whole workflow on every run. It calls -`scripts/internal/analyzer-release-check.sh` for the release files, -`scripts/readme-table-diff.sh --analyzer` for the analyzer README, and -`scripts/internal/analyzer-promote.sh` after the version bump. A rule that is -missing from either file blocks the ship, even on a docs-only change set. +The `/yeet` skill enforces the whole workflow on every run. `scripts/check.sh` +runs `scripts/internal/analyzer-release-check.sh` when the diff touches +`src/E128.Analyzers/`. The skill also calls that script directly for the release +files. It calls `scripts/readme-table-diff.sh --analyzer` for the analyzer +README and `scripts/internal/analyzer-promote.sh` after the version bump. A rule +that is missing from either file blocks the ship, even on a docs-only change set. ## Consumers diff --git a/lode/infrastructure/shipping.md b/lode/infrastructure/shipping.md index ca64539e..eea4b112 100644 --- a/lode/infrastructure/shipping.md +++ b/lode/infrastructure/shipping.md @@ -1,5 +1,5 @@ # Shipping -*Updated: 2026-11-12T00:54:46Z* +*Updated: 2026-11-17T13:17:39Z* `scripts/verify-and-ship.sh` ships the current feature branch as one squashed commit. It formats, bumps the version, runs the canonical check, squashes, scans, commits, and pushes. The script runs only when an operator asks for it, because it commits and pushes. @@ -36,10 +36,10 @@ The diagram shows seven steps after validation. Each step runs only when the ste 1. Format the changed files. 2. Bump the version. The bump comes before the check, so the check verifies the final file contents. -3. Run `scripts/check.sh --all`. The check includes the format check. The script never passes `--no-format`. +3. Run `scripts/check.sh --all`. The check includes the format check. The script never passes `--no-format`. It also runs the analyzer release check when the diff touches `src/E128.Analyzers/`. 4. Stage every change, including new files. 5. Squash the unpushed commits with a soft reset. -6. Run `scripts/internal/commit.sh`. It runs the precommit scan over the whole squashed index, then commits. The scan therefore sees the contents of every earlier unpushed commit. +6. Run `scripts/internal/commit.sh`. It runs the precommit scan over the whole squashed index, then commits. The scan therefore sees the contents of every earlier unpushed commit. The script rejects an email address or a Claude Code mention in the message. It adds no attribution trailer. 7. Push the branch. ## Version Inference diff --git a/prompts/README.md b/prompts/README.md new file mode 100644 index 00000000..ad41880e --- /dev/null +++ b/prompts/README.md @@ -0,0 +1,7 @@ +# Prompts + +Reusable sample prompts for this repository. + +Keep a prompt here only when no skill, agent, or rule file owns its behavior. +A prompt that duplicates an owner drifts from that owner. Delete it instead. +`SystemPrompt.txt` is the Lode method bootstrap, not a sample prompt. diff --git a/prompts/blazing-fast-net.md b/prompts/blazing-fast-net.md new file mode 100644 index 00000000..b00be39e --- /dev/null +++ b/prompts/blazing-fast-net.md @@ -0,0 +1,7 @@ +# .NET Safety and Anti-Pattern Audit + +Inspect the current codebase for issues listed in https://raw.githubusercontent.com/dotnet/docs/refs/heads/main/docs/standard/unsafe-code/best-practices.md + +Do not attempt to make minimal reproductions or fixes. Focus on identifying potential safety and code quality issues. + +Report two groups: 1) correctness issues, 2) anti-patterns. diff --git a/prompts/clean-up-rules.md b/prompts/clean-up-rules.md new file mode 100644 index 00000000..a7e288a6 --- /dev/null +++ b/prompts/clean-up-rules.md @@ -0,0 +1,3 @@ +let's review claude.md and other rules for contradictions to resolve. suggest up to 5. use the askusertool to ask me how to resolve each one. + +let's review claude.md and other rules to trim some. suggest 5 things to remove diff --git a/prompts/code-review.md b/prompts/code-review.md deleted file mode 100644 index 02bc64d4..00000000 --- a/prompts/code-review.md +++ /dev/null @@ -1 +0,0 @@ -code review the last 24 hours worth of .cs file changes. diff --git a/prompts/find-inefficiencies.md b/prompts/find-inefficiencies.md index 2e80ca0e..758be8bb 100644 --- a/prompts/find-inefficiencies.md +++ b/prompts/find-inefficiencies.md @@ -1,10 +1,9 @@ -Scrape all of my Claude session on this computer. Analyze my usage patterns and give me a breakdown of: +# Session Usage Analysis + +Scrape all of my Claude sessions on this computer. Analyze my usage patterns and give me a breakdown of: - What I do most frequently - What should become skills (reusable workflows/knowledge) - What should become plugins (standalone tools) - What should become agents (autonomous subagents) -- What belongs in CLAUDE. md (project-level instructions) - - -Audit the last 48 hours of claude use. Find operations that used a lot of tokens. Of those operations, suggest new scripts to be created to reduce that token use and improve wall-clock time. +- What belongs in CLAUDE.md (project-level instructions) diff --git a/prompts/lode-prompt-update.md b/prompts/lode-prompt-update.md deleted file mode 100644 index caa9202c..00000000 --- a/prompts/lode-prompt-update.md +++ /dev/null @@ -1,2 +0,0 @@ -is there anything that should be promoted to systemprompt.txt that would provide higher quality and more consistent instructions? -fix systemprompt.txt itself per instructions. \ No newline at end of file diff --git a/prompts/lode-update.md b/prompts/lode-update.md deleted file mode 100644 index 01d1e018..00000000 --- a/prompts/lode-update.md +++ /dev/null @@ -1,8 +0,0 @@ -# Request lode update -remove code comments that provide historical commentary. -update lodes with concise information, -do not leave historical commentary, -the lode is a snapshot for AI agents. - - -audit the lode and ensure it correctly describes the system as implemented diff --git a/prompts/skill-agent-script.md b/prompts/skill-agent-script.md deleted file mode 100644 index 7aa51c72..00000000 --- a/prompts/skill-agent-script.md +++ /dev/null @@ -1,21 +0,0 @@ -**Review and Refactor Agents & Skills** - -1. **Deterministic Shell Scripts** - Review all agents and skills. Extract any logic that can be made fully deterministic into new shell scripts. Update the affected agents and skills to call these scripts instead. - -2. **Single AI-Focused Purpose** - Ensure every skill and agent performs **one clear AI-focused task** exceptionally well. Multiple script calls are allowed, but the AI-specific value (reasoning, decision-making, generation, etc.) must remain singular. - Suggest breaking apart any skills/agents that have too much AI variance or try to do multiple distinct things. - -3. **Agent Directory Review** - Review all agents in `.claude/agents` using the latest Anthropic Claude agent/code guidelines. - Identify and address: - - Overcomplexity - - Redundancy - - Obsolescence - -4. **Optimization Recommendations** - Suggest specific improvements to make each agent: - - Focused on a single, well-defined task - - More efficient - - More autonomous diff --git a/prompts/token-waster.md b/prompts/token-waster.md deleted file mode 100644 index d000fa9a..00000000 --- a/prompts/token-waster.md +++ /dev/null @@ -1 +0,0 @@ -Review the last 48 hours of sessions. Find the highest uses of tokens and suggest ways to reduce token use by creating or editing new scripts. \ No newline at end of file diff --git a/prompts/untangle-codebase.md b/prompts/untangle-codebase.md index 9e6f36cf..a1304cab 100644 --- a/prompts/untangle-codebase.md +++ b/prompts/untangle-codebase.md @@ -1 +1,3 @@ -create a branch for https://raw.githubusercontent.com/caldoai/skills/refs/heads/main/skills/untangle-codebase/SKILL.md invoke and run it. let me review \ No newline at end of file +# Untangle Codebase + +Create a branch for https://raw.githubusercontent.com/caldoai/skills/refs/heads/main/skills/untangle-codebase/SKILL.md. Invoke and run it. Let me review. diff --git a/scripts/README.md b/scripts/README.md index 7c8f6b5b..6f6c46f0 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -30,7 +30,7 @@ Other required tools: see [Shell Authoring](../lode/infrastructure/shell-authori | `build.sh` | Build the solution or a specific project | `--verbose`, `--project`, `--errors`, `--warnings`, `--fix`, `--fast` | | `test.sh` | Run tests (defaults to CI category) | `--all`, `--verbose`, `--dry-run`, `--trait`, `--framework` | | `format.sh` | Run jb cleanupcode then dotnet format | `--check`, `--changed`, `--no-jb` | -| `check.sh` | Composed: shell lint, shipping tests (--all, if changed), format, build, test | `--all`, `--no-format`, `--json` | +| `check.sh` | Composed: shell lint, shipping tests, analyzer release, format, build, test | `--all`, `--no-format`, `--json` | | `ci.sh` | Full CI pipeline: shell lint, shipping tests, format, build, test | `--human`, `--json`, `--skip-format`, `--skip-build`, `--skip-test` | | `podman.sh` | Podman build/run/test/stop/clean | `--no-cache` | | `verify-and-ship.sh` | Ship the branch as one squashed commit (format, bump, check, squash, scan, commit, push) | `--message`/`-m` (required), `--no-version-bump`, `--json` | @@ -82,8 +82,9 @@ Other required tools: see [Shell Authoring](../lode/infrastructure/shell-authori | -------------------- | -------------------------------------------------------------- | ---------------------------------------------------------------- | | `find.sh` | Deterministic symbol lookup (class/method/callers/refs/file) | `--class`, `--method`, `--callers`, `--refs`, `--file`, `--json` | | `file-outline.sh` | File structure outline with line ranges for targeted reading | `--json`, `--method`, `--section` | -| `code-read.sh` | Extract method/class/section source by name | `--method`, `--class`, `--section`, `--line`, `--json` | +| `code-read.sh` | Extract method/class/section or line ranges by name | `--method`, `--class`, `--section`, `--line`/`--range`, `--json` | | `deps.sh` | Type dependency graph (callers, callees, interfaces) | `--callers`, `--callees`, `--interfaces`, `--json` | +| `pkg-path.sh` | Resolve a NuGet package's ref and lib dirs | `--version`, `--ref`, `--lib`, `--json` | ## Coverage & Analysis @@ -114,7 +115,7 @@ These are invoked by skills and agents only — not intended for direct use: | ------------------------------------ | ------------------------------------------------------------------------------------------ | | `internal/analyzer-release-check.sh` | Validate analyzer release files (Unshipped/Shipped) against source DiagnosticId constants | | `internal/analyzer-promote.sh` | Move Unshipped rule rows into a new Shipped release section | -| `internal/commit.sh` | Commit helper: blocks emails, adds a name-only co-author trailer unless one is present | +| `internal/commit.sh` | Commit helper: blocks email addresses and Claude Code attribution in the message | | `internal/cr-diff-deliver.sh` | Decide code-review diff delivery mode by size: inline (≤30KB), write (30-40KB), or split (>40KB) | | `internal/cr-target.sh` | Resolve a code-review target to base, changed files, and the reviewers to run | | `internal/mechanical-diff.sh` | Classify each changed file in the working diff as MECHANICAL (namespace rename) or SUBSTANTIVE | diff --git a/scripts/check.sh b/scripts/check.sh index 65cff0bf..ee29a239 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Composed verify: shell lint → shipping tests (--all, when shipping scripts changed) → format → build → test. +# Composed verify: shell lint → shipping tests → analyzer release → format → build → test. # Usage: check.sh [--all] [--no-format] [--json] source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" @@ -29,16 +29,17 @@ else EXIT=1 fi +ROOT="$(find_repo_root)" +base="$(git -C "$ROOT" merge-base origin/main HEAD 2> /dev/null || git -C "$ROOT" rev-parse HEAD)" + # Step 1b: Shipping tests. The suite takes about a minute, so --all runs it only # when a script it covers differs from the merge base with main. if [[ "$ALL" == true ]]; then - ROOT="$(find_repo_root)" SHIP_FILES=( scripts/verify-and-ship.sh scripts/verify-and-ship-test.sh scripts/lib.sh scripts/internal/version-bump.sh scripts/internal/commit.sh scripts/internal/stage.sh scripts/internal/precommit.sh ) - base="$(git -C "$ROOT" merge-base origin/main HEAD 2> /dev/null || git -C "$ROOT" rev-parse HEAD)" if [[ -n "$(git -C "$ROOT" diff --name-only "$base" -- "${SHIP_FILES[@]}")" ]]; then STEPS+=("shell-tests") if "$SCRIPTS/verify-and-ship-test.sh" > /dev/null 2>&1; then @@ -50,6 +51,18 @@ if [[ "$ALL" == true ]]; then fi fi +# Step 1c: Analyzer release files. Runs only when the diff touches analyzer +# source or the release files. The check is clean today, so a hit fails the gate. +if [[ -n "$(git -C "$ROOT" diff --name-only "$base" -- src/E128.Analyzers)" ]]; then + STEPS+=("analyzer-release") + if "$SCRIPTS/internal/analyzer-release-check.sh" > /dev/null 2>&1; then + RESULTS+=("ok") + else + RESULTS+=("fail") + EXIT=1 + fi +fi + # Step 2: Format check if [[ "$NO_FORMAT" == false ]]; then STEPS+=("format") diff --git a/scripts/code-read.sh b/scripts/code-read.sh index a4e5ee94..1e51ac47 100755 --- a/scripts/code-read.sh +++ b/scripts/code-read.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash -# Extract source code for a method, class, or section by name. -# Usage: code-read.sh --method|--class|--section|--line NAME PATH [--json] +# Extract source code for a method, class, or section by name, or line ranges from several files. +# Usage: code-read.sh --method|--class|--section|--line|--range NAME PATH... [--json] set -euo pipefail source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" MODE="" QUERY="" -FILE="" JSON=false +FILES=() while [[ $# -gt 0 ]]; do case "$1" in @@ -16,23 +16,35 @@ while [[ $# -gt 0 ]]; do --class) MODE="class"; QUERY="$2"; shift 2 ;; --section) MODE="section"; QUERY="$2"; shift 2 ;; --line) MODE="line"; QUERY="$2"; shift 2 ;; + --range) MODE="line"; QUERY="$2"; shift 2 ;; --json) JSON=true; shift ;; -h|--help) - echo "Usage: code-read.sh --method|--class|--section|--line NAME PATH [--json]" + echo "Usage: code-read.sh --method|--class|--section|--line|--range NAME PATH... [--json]" + echo " --line and --range accept A-B and one or more PATH arguments." exit 0 ;; -*) err "Unknown option: $1"; exit 1 ;; - *) FILE="$1"; shift ;; + *) FILES+=("$1"); shift ;; esac done if [[ -z "$MODE" || -z "$QUERY" ]]; then - err "Specify one of: --method, --class, --section, --line" + err "Specify one of: --method, --class, --section, --line, --range" exit 1 fi -if [[ -z "$FILE" || ! -f "$FILE" ]]; then - err "File not found: ${FILE:-}" +if [[ ${#FILES[@]} -eq 0 ]]; then + err "File not found: " exit 1 fi +if [[ "$MODE" != "line" && ${#FILES[@]} -gt 1 ]]; then + err "Only --line and --range accept more than one file" + exit 1 +fi +for f in "${FILES[@]}"; do + if [[ ! -f "$f" ]]; then + err "File not found: $f" + exit 1 + fi +done # Find the start line of a symbol find_start_line() { @@ -107,50 +119,77 @@ find_brace_end() { ' "$file" } -# Handle --line mode -if [[ "$MODE" == "line" ]]; then - if [[ "$QUERY" == *-* ]]; then - START_LINE="${QUERY%-*}" - END_LINE="${QUERY#*-}" - else - START_LINE="$QUERY" - END_LINE="$QUERY" - fi -else - START_LINE="$(find_start_line "$QUERY" "$MODE" "$FILE")" +# Resolve the range for one file. Sets START_LINE and END_LINE. Returns 1 when the symbol is absent. +extract_lines() { + local file="$1" - if [[ "$START_LINE" -eq 0 ]]; then - if $JSON; then - jq -n --arg query "$QUERY" --arg type "$MODE" --arg file "$FILE" \ - '{found: false, query: $query, type: $type, file: $file}' + if [[ "$MODE" == "line" ]]; then + if [[ "$QUERY" == *-* ]]; then + START_LINE="${QUERY%-*}" + END_LINE="${QUERY#*-}" else - err "No $MODE match for '$QUERY' in $FILE" + START_LINE="$QUERY" + END_LINE="$QUERY" fi - exit 1 + return 0 + fi + + START_LINE="$(find_start_line "$QUERY" "$MODE" "$file")" + if [[ "$START_LINE" -eq 0 ]]; then + return 1 fi # Walk back for methods to include attributes if [[ "$MODE" == "method" ]]; then - START_LINE="$(walk_back_sig "$FILE" "$START_LINE")" + START_LINE="$(walk_back_sig "$file" "$START_LINE")" fi - END_LINE="$(find_brace_end "$FILE" "$START_LINE")" + END_LINE="$(find_brace_end "$file" "$START_LINE")" +} + +TARGETS=("${FILES[0]}") +if [[ "$MODE" == "line" ]]; then + TARGETS=("${FILES[@]}") fi -# Extract content -CONTENT="$(sed -n "${START_LINE},${END_LINE}p" "$FILE")" +RECORDS=() +RC=0 +for file in "${TARGETS[@]}"; do + if ! extract_lines "$file"; then + if $JSON; then + RECORDS+=("$(jq -n --arg query "$QUERY" --arg type "$MODE" --arg file "$file" \ + '{found: false, query: $query, type: $type, file: $file}')") + else + err "No $MODE match for '$QUERY' in $file" + fi + RC=1 + continue + fi + + CONTENT="$(sed -n "${START_LINE},${END_LINE}p" "$file")" + + if $JSON; then + RECORDS+=("$(jq -n \ + --arg query "$QUERY" \ + --arg type "$MODE" \ + --arg file "$file" \ + --argjson start_line "$START_LINE" \ + --argjson end_line "$END_LINE" \ + --arg content "$CONTENT" \ + '{found: true, query: $query, type: $type, file: $file, start_line: $start_line, end_line: $end_line, content: $content}')") + else + echo "─── $MODE: $QUERY ─── $file:${START_LINE}-${END_LINE}" + echo "$CONTENT" + echo "───" + fi +done if $JSON; then - jq -n \ - --arg query "$QUERY" \ - --arg type "$MODE" \ - --arg file "$FILE" \ - --argjson start_line "$START_LINE" \ - --argjson end_line "$END_LINE" \ - --arg content "$CONTENT" \ - '{found: true, query: $query, type: $type, file: $file, start_line: $start_line, end_line: $end_line, content: $content}' -else - echo "─── $MODE: $QUERY ─── $FILE:${START_LINE}-${END_LINE}" - echo "$CONTENT" - echo "───" + if [[ ${#RECORDS[@]} -eq 1 ]]; then + printf '%s\n' "${RECORDS[0]}" | jq . + else + printf '%s\n' "${RECORDS[@]}" | jq -s . + fi fi + +exit $RC diff --git a/scripts/internal/commit.sh b/scripts/internal/commit.sh index 46005892..76c030c0 100755 --- a/scripts/internal/commit.sh +++ b/scripts/internal/commit.sh @@ -1,11 +1,8 @@ #!/usr/bin/env bash -# Commit helper. Appends a name-only Co-Authored-By trailer (never an email). +# Commit helper. Rejects email addresses and Claude Code attribution in the message. # Usage: commit.sh [--skip-precommit] MESSAGE source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh" -# Name-only co-author trailer — no email, per the global privacy rule. -COAUTHOR_TRAILER="Co-Authored-By: Claude" - SKIP_PRECOMMIT=false; MSG="" while [[ $# -gt 0 ]]; do @@ -24,11 +21,16 @@ if [[ -z "$MSG" ]]; then fi # Block any email address in the commit message (global privacy rule). -# A co-author trailer, if wanted, must be name-only; email placeholders use example.com. if contains_real_email "$MSG"; then err "Commit message contains an email address — blocked by the privacy rule:" real_emails_in "$MSG" | while IFS= read -r e; do printf " %s\n" "$e" >&2; done - err "Remove it (use a name-only trailer, or a user@example.com placeholder)." + err "Remove it (use a user@example.com placeholder)." + exit 1 +fi + +# Block tool attribution (AGENTS.md: never name Claude Code in a commit or PR). +if printf '%s\n' "$MSG" | rg -qi 'claude[ -]code|generated with claude|co-authored-by: *claude'; then + err "Commit message names Claude Code — blocked by the attribution rule." exit 1 fi @@ -42,12 +44,7 @@ if [[ "$SKIP_PRECOMMIT" == false ]]; then fi fi -# Commit with the message plus a name-only co-author trailer (no email — global privacy rule). -# Skip the append when the message already carries a trailer, so it never ships twice. -if printf '%s\n' "$MSG" | rg -qi '^Co-Authored-By:'; then - git commit -m "$MSG" -else - git commit -m "$MSG" -m "$COAUTHOR_TRAILER" -fi +# Commit the message as written. No attribution trailer is appended. +git commit -m "$MSG" ok "Committed: $MSG" diff --git a/scripts/pkg-path.sh b/scripts/pkg-path.sh new file mode 100755 index 00000000..ba61fdf9 --- /dev/null +++ b/scripts/pkg-path.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# Resolve a NuGet package's ref and lib directories and their assemblies. +# Usage: pkg-path.sh PACKAGE [--version V] [--ref|--lib] [--json] +set -euo pipefail + +source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" + +PACKAGE="" +VERSION="" +KIND="" +JSON=false + +while [[ $# -gt 0 ]]; do + case "$1" in + --version) VERSION="$2"; shift 2 ;; + --ref) KIND="ref"; shift ;; + --lib) KIND="lib"; shift ;; + --json) JSON=true; shift ;; + -h|--help) + echo "Usage: pkg-path.sh PACKAGE [--version V] [--ref|--lib] [--json]" + echo "Prints the package's ref and lib directories with their assemblies." + echo "Without --version it selects the highest installed version." + exit 0 ;; + -*) err "Unknown option: $1"; exit 1 ;; + *) PACKAGE="$1"; shift ;; + esac +done + +if [[ -z "$PACKAGE" ]]; then + err "Usage: pkg-path.sh PACKAGE [--version V] [--ref|--lib] [--json]" + exit 1 +fi + +ROOT="${NUGET_PACKAGES:-$HOME/.nuget/packages}/$(printf '%s' "$PACKAGE" | tr '[:upper:]' '[:lower:]')" +if [[ ! -d "$ROOT" ]]; then + err "Package not found: $PACKAGE" + dim "Looked in $ROOT" + exit 1 +fi + +if [[ -z "$VERSION" ]]; then + VERSION="$(find "$ROOT" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -V | tail -1)" +fi +if [[ -z "$VERSION" || ! -d "$ROOT/$VERSION" ]]; then + err "Version not found: ${VERSION:-} in $ROOT" + exit 1 +fi + +KINDS=(ref lib) +if [[ -n "$KIND" ]]; then + KINDS=("$KIND") +fi + +DIRS=() +ASSEMBLIES=() +for kind in "${KINDS[@]}"; do + for dir in "$ROOT/$VERSION/$kind"/*/; do + dir="${dir%/}" + [[ -d "$dir" ]] || continue + DIRS+=("$dir") + while IFS= read -r dll; do + ASSEMBLIES+=("$dll") + done < <(find "$dir" -maxdepth 1 -name '*.dll' -type f 2> /dev/null | sort) + done +done + +if [[ ${#DIRS[@]} -eq 0 ]]; then + err "No ${KIND:-ref or lib} directory in $ROOT/$VERSION" + exit 1 +fi + +if $JSON; then + dirs_json="$(printf '%s\n' "${DIRS[@]}" | jq -R . | jq -s .)" + asm_json='[]' + if [[ ${#ASSEMBLIES[@]} -gt 0 ]]; then + asm_json="$(printf '%s\n' "${ASSEMBLIES[@]}" | jq -R . | jq -s .)" + fi + jq -n \ + --arg package "$PACKAGE" \ + --arg version "$VERSION" \ + --argjson dirs "$dirs_json" \ + --argjson assemblies "$asm_json" \ + '{package: $package, version: $version, dirs: $dirs, assemblies: $assemblies}' +else + ok "$PACKAGE $VERSION" + for dir in "${DIRS[@]}"; do + echo "$dir" + if [[ ${#ASSEMBLIES[@]} -gt 0 ]]; then + for dll in "${ASSEMBLIES[@]}"; do + if [[ "$(dirname "$dll")" == "$dir" ]]; then + dim " $(basename "$dll")" + fi + done + fi + done +fi diff --git a/scripts/verify-and-ship-test.sh b/scripts/verify-and-ship-test.sh index dda137b4..fb89ce1d 100755 --- a/scripts/verify-and-ship-test.sh +++ b/scripts/verify-and-ship-test.sh @@ -378,7 +378,7 @@ case_ships_one_commit_over_existing_upstream() { expect "second unpushed file is kept" g cat-file -e HEAD:u2.txt expect "new file is kept" g cat-file -e HEAD:new.txt expect "commit subject is the message" test "$(g log -1 --format=%s)" = "feat: ship it" - expect "one name-only trailer" test "$(g log -1 --format=%B | rg -c '^Co-Authored-By: Claude$')" = 1 + expect "no co-author trailer" test -z "$(g log -1 --format=%B | rg '^Co-Authored-By:' || true)" expect "working tree is clean" test -z "$(g status --porcelain)" }