diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 9ebdf08..f2b0364 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -13,7 +13,7 @@ "name": "arn-code", "source": "./plugins/arn-code", "description": "Artifact-driven pipeline — spec, plan, implement, review, ship, plus batch CVE scan & fix. Three ceremony tiers scale process to scope, from a one-file fix to a large refactor. 37 skills, 18 agents.", - "version": "3.8.0", + "version": "3.9.0", "author": { "name": "Fryderyk Benigni", "url": "https://github.com/fredcallagan" diff --git a/.gitattributes b/.gitattributes index 72b30da..e408e95 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,6 @@ # `chmod +x` semantics. Required for the ensure-config cache-check.sh # scripts that run on user machines. plugins/*/skills/*-ensure-config/scripts/*.sh text eol=lf +plugins/*/hooks/*.sh text eol=lf +plugins/*/skills/*/scripts/*.sh text eol=lf +tests/**/*.sh text eol=lf diff --git a/.github/workflows/arn-code-ci.yml b/.github/workflows/arn-code-ci.yml new file mode 100644 index 0000000..7f06341 --- /dev/null +++ b/.github/workflows/arn-code-ci.yml @@ -0,0 +1,48 @@ +name: arn-code CI + +on: + pull_request: + paths: + - "plugins/arn-code/**" + - ".claude-plugin/marketplace.json" + - "scripts/ci/**" + - "tests/arn-code/**" + - ".github/workflows/arn-code-ci.yml" + push: + branches: [main] + +permissions: + contents: read + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Static checks (frontmatter, references, presets, hooks) + run: python3 scripts/ci/validate-arn-code.py + + scripts: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - name: Shell syntax + run: | + for f in plugins/arn-code/hooks/*.sh plugins/arn-code/skills/*/scripts/*.sh tests/arn-code/*.sh; do + bash -n "$f" || exit 1 + done + - name: Tool versions + run: | + bash --version | head -1 + command -v python3 && python3 --version || echo 'no working python3' + command -v python && python --version || echo 'no python' + command -v jq || echo 'no jq' + - name: Script and hook tests (system bash; 3.2 on macOS; Git Bash on Windows) + run: bash tests/arn-code/run-tests.sh diff --git a/CLAUDE.md b/CLAUDE.md index a3c9fc1..c334897 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -115,6 +115,18 @@ When the field is missing, `arn-code-ensure-config` (Layer 2c) prompts the user The analyzer is technology-agnostic: it does not pattern-match against a fixed list of tool names. Instead it scans evidence categories (dependency manifests, tool config files, script entry points, pre-commit-style runners) and recognizes whatever tooling the project actually uses. Linters and formatters are listed separately in `linting.md` because they have different semantics — formatters typically have both a check mode and a write mode, and the gate must invoke the check mode (`Discovered check command`) so files are never silently rewritten. +The analyzer also returns `/tooling.json`: the same commands in machine-readable form (per service: `path`, `extensions`, `lintFiles`, `formatCheckFiles`, `check`, `testFiles`, `test`, `owner`). The plugin hooks read it. Hooks run its commands only after the user approves them (`hooks/tooling-approve.sh` stores a hash in `.arness/tooling.local.sha`); any edit to the file needs a new approval. Entries with `owner: project` are skipped because the project already runs those checks itself. + +## Plugin Hooks (arn-code) + +`plugins/arn-code/hooks/hooks.json` registers hooks that are off by default (on with `- **Hooks:** on` in `## Arness` or `ARNESS_HOOKS=on`; `ARNESS_HOOKS=off` always wins), act only in projects with a `## Arness` section, and fail open when a tool is missing: + +- `SessionStart` → `session-start.sh`: config cache status line; after compaction, a pointer to the most recent plan's `PROGRESS_TRACKER.json`. +- `PreToolUse` (Bash) → `pre-bash.sh`: blocks force-push; scans what a `git commit` will include for private keys, access tokens, key files and `.env`. +- `PostToolUse` (Edit/Write/MultiEdit) → `post-edit-lint.sh`: advisory file-level lint from an approved `tooling.json`, when `Linting: enabled`. + +Hooks must stay language-agnostic: they never name a language or tool; every project-specific command comes from `tooling.json`. Switches: `ARNESS_HOOKS=off`, `ARNESS_HOOKS_DISABLE=session,force-push,secrets,lint`. Tests: `bash tests/arn-code/run-tests.sh`; static checks: `python3 scripts/ci/validate-arn-code.py` (both run in `.github/workflows/arn-code-ci.yml`). + ## Security Scanning Configuration Each project's `## Arness` block carries two fields that together configure CVE discovery, triage, and resolution: diff --git a/plugins/arn-code/CHANGELOG.md b/plugins/arn-code/CHANGELOG.md index ffc9808..0eb0233 100644 --- a/plugins/arn-code/CHANGELOG.md +++ b/plugins/arn-code/CHANGELOG.md @@ -6,6 +6,46 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) Release tags follow Anthropic's official plugin tag convention: `arn-code--v{version}` (double-hyphen `--v`), produced by `claude plugin tag --push` from inside `plugins/arn-code/`. +## [3.9.0] — 2026-10-25 + +### Fixed +- **ensure-config cache never hit.** The checker and the writer hashed the `## Arness` section differently (trailing newline), so every run was a cache miss and the 3.7.0 fast path never worked. Both now share one library (`scripts/lib.sh`); Layer 4 writes the cache with `scripts/cache-write.sh` instead of hand-computed hashes. Cache schema bumped to 2 (one silent miss after upgrade). +- **Plugin version was read from `plugin.json`,** which has no `version` field. New `scripts/plugin-version.sh` resolves it from the marketplace entry or the installed cache path. Used by init, ensure-config, report, doctor and template versioning. +- **Version check skipped for marketplace installs.** The cache looked for `marketplace.json` in the wrong place; it now also reads the version from the install path, so upgrades invalidate the cache. +- **GitHub label check** listed only 30 labels, broke when a repo had extra `arness-*` labels, and printed a garbled count on zero matches. It now checks each expected label by name (`scripts/labels-missing.sh`) and does not fail the cache when `gh` is offline. +- **Cache check portability:** works from a subdirectory, with Windows line endings, and without `jq`. +- **Simplify revert could discard uncommitted work.** A failed finding was reverted with `git apply -R` of the whole working-tree diff. The applier now snapshots only the files it touches (`arn-code-simplify/scripts/snapshot.sh`) and restores only those. Applies to `arn-code-simplify` and `arn-code-batch-simplify`. +- **`save_plan.sh`:** no longer picks the newest plan from other projects in `~/.claude/plans/`; rejects project names with path characters; refuses to guess between several `PLAN_PREVIEW` files; will not overwrite a different `SOURCE_PLAN.md` without `--force`. +- 38 references used repo-relative `plugins/arn-code/...` paths that broke in user projects; they now use `${CLAUDE_PLUGIN_ROOT}`. +- `arn-code-batch-cve-scan` description exceeded the 1,024-character limit; both CVE skills gained a `version`. +- Simplify skills pointed to a "Dispatch convention" section in the wrong file. +- The no-tracker CVE fallback told users to pass `--resolution-plan`, which `arn-code-batch-cve-fix` does not accept; it now says `--proposal-path`. +- **`arn-code-help` could not see any files** in recent Claude Code versions: it allowed only Read, Glob and Grep, and the main session no longer has Glob or Grep. It now falls back to read-only shell commands; `arn-code-review-plan` names the same fallback. +- `arn-code-codebase-analyzer` is read-only, but its text told it to write files. It now returns `linting.md`, `tooling.json` and `security-scanning.md` content and the caller writes them. + +### Added +- **Plugin hooks** (`hooks/hooks.json`), **off by default**, active only in Arness projects and failing open. Turn them on per project with `- **Hooks:** on` in `## Arness` (`arn-code-init` asks), or per user with `ARNESS_HOOKS=on`; `ARNESS_HOOKS=off` always wins: + - `SessionStart`: config status line; after compaction, a pointer to the plan in progress. + - `PreToolUse` on Bash: blocks force-push (`--force-with-lease` allowed); blocks commits containing private keys, access tokens, key files or `.env` (`arness:allow-secret` marks a false positive). + - `PostToolUse` on edits: advisory file-level lint and format checks from the project's own commands, when `Linting: enabled`. + - Switches: `ARNESS_HOOKS=off`, `ARNESS_HOOKS_DISABLE=session,force-push,secrets,lint`. +- **`tooling.json`:** machine-readable lint, format and test commands returned by the codebase analyzer next to `linting.md`. Hooks run its commands only after the user approves them (`hooks/tooling-approve.sh`); an edited file needs new approval. Language-agnostic: every command comes from the project. +- `.arness/.*-tmp/` is added to the project `.gitignore` for scratch directories. +- CI (`.github/workflows/arn-code-ci.yml`): static checks (`scripts/ci/validate-arn-code.py`) and script and hook tests (`tests/arn-code/run-tests.sh`) on Linux, macOS and Windows (Git Bash). +- **Windows:** hooks and scripts accept `C:\` paths from Claude Code, drop carriage returns from tool output, and use `python` when `python3` is missing or is the Microsoft Store stub. Without `jq` or Python, hooks read their input with `awk`, so the force-push and secrets checks still work (lint needs Python and is skipped). Hooks also compare physical paths, so a symlinked project folder (such as the macOS temp folder) works. + +### Changed +- Inner skills no longer repeat the trigger phrases of the entry points (`arn-shipping`, `arn-assessing`, `arn-reviewing-pr`, `arn-implementing`, `arn-planning`), so natural requests route through the entry points. Inner skills still trigger by name. +- `arn-code-ensure-config` is hidden from the `/` menu (`user-invocable: false`). `arn-code-batch-cve-fix` runs only when typed (`disable-model-invocation: true`). Skills that take arguments show an `argument-hint`. +- Long agent descriptions trimmed to under 800 characters; they are loaded into every session. +- Docs say "Agent tool" instead of "Task tool" for subagent dispatch. + +### Compatibility +No breaking changes. After upgrading: one silent ensure-config cache miss (schema 2), then real cache hits. Hooks are off until you turn them on, so nothing changes unless you opt in. The lint hook does nothing until `tooling.json` exists and is approved (next `arn-code-init`, or when `Linting` is set to `enabled`). + +### Known issues +- arn-spark and arn-infra ship their own copies of the old `cache-check.sh` with the same hashing bug; fixed in their next releases. + ## [3.8.0] — 2026-07-06 ### Added diff --git a/plugins/arn-code/README.md b/plugins/arn-code/README.md index 8aa1eac..db048f4 100644 --- a/plugins/arn-code/README.md +++ b/plugins/arn-code/README.md @@ -12,6 +12,17 @@ Structured, artifact-driven development pipeline for Claude Code. Every feature /plugin install arn-code@arn-marketplace ``` +## Hooks + +Since 3.9.0 the plugin ships hooks. They are **off until you turn them on**, and they act only in projects with a `## Arness` section in `CLAUDE.md`. Turn them on for a project with `- **Hooks:** on` in the `## Arness` section (`/arn-code-init` asks), or for yourself with `ARNESS_HOOKS=on` (for example in `.claude/settings.local.json` under `env`). + +- **Session start:** one status line about the Arness config; after a compaction, a pointer to the plan in progress. +- **Before `git push`:** blocks `--force`, `-f` and `+refspec` (`--force-with-lease` is allowed). +- **Before `git commit`:** blocks commits that contain private keys, access tokens, key files or `.env`. Add `arness:allow-secret` on a line to mark a false positive. +- **After an edit:** when `Linting: enabled`, runs the project's own file-level lint and format checks from `.arness/tooling.json` and reports issues to Claude. Advisory only. The commands run only after you approve them during setup. + +`ARNESS_HOOKS=off` turns all hooks off, whatever the project says. Turn some off with `ARNESS_HOOKS_DISABLE=session,force-push,secrets,lint` (for example in `.claude/settings.local.json` under `env`). + ## Documentation Full guide: [docs/plugins/arn-code.md](../../docs/plugins/arn-code.md) · [arness.appsvortex.com](https://arness.appsvortex.com/) diff --git a/plugins/arn-code/agents/arn-code-batch-analyzer.md b/plugins/arn-code/agents/arn-code-batch-analyzer.md index 252f7de..4b093a8 100644 --- a/plugins/arn-code/agents/arn-code-batch-analyzer.md +++ b/plugins/arn-code/agents/arn-code-batch-analyzer.md @@ -11,45 +11,13 @@ description: >- Context: Invoked by arn-code-batch-planning during parallel pre-analysis for a greenfield feature user: "batch planning" assistant: (invokes arn-code-batch-analyzer with greenfield feature F-003 context) - - Batch planning spawns one batch-analyzer per selected feature in parallel. - Each analyzer reads the feature file, UC documents, and codebase patterns, - then writes a DRAFT_FEATURE_*.md to the specs directory. - Context: Invoked by arn-code-batch-planning for a GitHub issue user: "batch planning" assistant: (invokes arn-code-batch-analyzer with GitHub issue #42 reference) - - For GitHub issues, the analyzer fetches the issue via gh CLI, extracts - title/body/labels/comments, and produces a draft spec with moderate detail. - - - - Context: Invoked by arn-code-batch-planning for a Jira issue - user: "batch planning" - assistant: (invokes arn-code-batch-analyzer with Jira issue PROJ-42 reference) - - For Jira issues, the analyzer fetches the issue via MCP, extracts - summary/description/acceptance-criteria, and produces a draft spec. - - - - - Context: Invoked by arn-code-batch-planning for a plain description - user: "batch planning" - assistant: (invokes arn-code-batch-analyzer with a text description) - - For plain descriptions, the analyzer produces a basic draft with architect - analysis and placeholder sections that the user will refine during exploration. - - - - This is a background agent with no user interaction — it runs autonomously - and returns a structured file artifact. tools: [Read, Glob, Grep, Write, Bash] model: opus color: green diff --git a/plugins/arn-code/agents/arn-code-batch-pr-analyzer.md b/plugins/arn-code/agents/arn-code-batch-pr-analyzer.md index a769250..dc740a6 100644 --- a/plugins/arn-code/agents/arn-code-batch-pr-analyzer.md +++ b/plugins/arn-code/agents/arn-code-batch-pr-analyzer.md @@ -12,21 +12,12 @@ description: >- Context: Invoked by arn-code-batch-merge after discovering 5 open batch PRs user: "batch merge" assistant: (invokes arn-code-batch-pr-analyzer with PR list and CHANGE_RECORD paths) - - Batch merge delegates the heavy analysis to this agent to keep the main - session context clean. The agent reads all PR diffs internally and returns - only a distilled summary. - Context: Re-invoked after a PR is merged to refresh remaining PR status user: "batch merge" assistant: (re-invokes arn-code-batch-pr-analyzer with fewer PRs after one was merged) - - After each merge, the agent is re-run with the remaining PRs to refresh - conflict and CI status. Fewer PRs = faster analysis. - tools: [Read, Glob, Grep, Bash] model: opus diff --git a/plugins/arn-code/agents/arn-code-codebase-analyzer.md b/plugins/arn-code/agents/arn-code-codebase-analyzer.md index bce0212..ab116eb 100644 --- a/plugins/arn-code/agents/arn-code-codebase-analyzer.md +++ b/plugins/arn-code/agents/arn-code-codebase-analyzer.md @@ -172,7 +172,7 @@ If step 1 detected a monorepo structure (workspace declarations, multi-package d **Output:** -Write the result to `/linting.md` following this schema: +Return the content for `/linting.md` (the caller writes the file) following this schema: ```md # Linting Patterns @@ -188,7 +188,7 @@ Write the result to `/linting.md` following this schema: (repeat per service/package) ``` -**If no linters or formatters are detected anywhere:** write a single-line `linting.md`: +**If no linters or formatters are detected anywhere:** return a single-line `linting.md`: ```md # Linting Patterns @@ -198,6 +198,28 @@ No linters or formatters detected. The caller (init or ensure-config) will default the `Linting:` config field to `none` in this case. +**Machine-readable tooling (`tooling.json`).** Also return the content for `/tooling.json`, which the plugin's hooks read. One entry per section above. Only fill a command when you found a real entry point or a documented check-mode flag; leave it out otherwise. Use `{files}` where a list of relative file paths can be passed. + +```json +{ + "version": 1, + "services": [ + { + "path": ".", + "extensions": ["\">"], + "lintFiles": "", + "formatCheckFiles": "", + "check": "", + "testFiles": "", + "test": "", + "owner": "arness | project" + } + ] +} +``` + +Set `owner` to `project` when the project already runs these checks itself before commit (a pre-commit-style runner from evidence category 4); the hooks then skip them to avoid running the same check twice. `path` is relative to the repo root. When nothing is detected, return `{"version": 1, "services": []}`. + The discovered check command is a *hint*, not authoritative. Downstream consumers (the executor's per-task lint, the ship pre-commit gate) are expected to adapt to the actual environment — for example, if the project's lockfile indicates a different package manager than the one referenced in the discovered command. ### 3D. Analyze security scanning patterns @@ -221,7 +243,7 @@ If step 1 detected a monorepo structure, repeat the scan inside each service/pac **Output:** -Write the result to `/security-scanning.md` following this schema. Every section MUST appear; use a "None detected" placeholder row when no evidence is found in that category. +Return the content for `/security-scanning.md` (the caller writes the file) following this schema. Every section MUST appear; use a "None detected" placeholder row when no evidence is found in that category. ```md # Security Scanning Patterns @@ -255,7 +277,7 @@ Write the result to `/security-scanning.md` following this sc | None detected | — | — | ``` -**If no scanners, waivers, CI integrations, or advisory-DB hints are detected anywhere:** write a `security-scanning.md` containing each of the four section headers above with a single `None detected` row per table. The caller (init or ensure-config) will default the `Security scanning:` config field to `none` in this case. +**If no scanners, waivers, CI integrations, or advisory-DB hints are detected anywhere:** return a `security-scanning.md` containing each of the four section headers above with a single `None detected` row per table. The caller (init or ensure-config) will default the `Security scanning:` config field to `none` in this case. The discovered check command and evidence sources are *hints*, not authoritative. Downstream consumers (the `arn-code-batch-cve-scan` skill, the `arn-code-cve-analyst` agent) adapt to the actual environment. This step intentionally mirrors the shape of step 3C (linting) — treat the linting step as the design precedent when extending or revising this detection logic. @@ -292,7 +314,7 @@ Output must follow the pattern file schemas. Read `${CLAUDE_PLUGIN_ROOT}/skills/ Your output format is shared with the `arn-code-pattern-architect` agent. Both agents must produce structurally identical output so downstream consumers can use either interchangeably. For projects with a user-facing interface (frontend, fullstack, cli, tui, desktop, mobile), both agents produce a fourth `# UI Patterns` section including a `## Sketch Strategy`. For projects with a security surface, both agents produce a fifth `# Security Patterns` section. -Linting and formatter detection is emitted as a separate file (`/linting.md`) following the schema in step 3C. It is produced regardless of project type; if neither linters nor formatters are detected, the file contains the single-line "No linters or formatters detected." marker so callers can default the `Linting:` config field to `none`. +Linting and formatter detection is returned as two separate files, `/linting.md` and `/tooling.json`, following step 3C. Mark each returned file with a heading line `## FILE: ` so the caller can split them. It is produced regardless of project type; if neither linters nor formatters are detected, the file contains the single-line "No linters or formatters detected." marker so callers can default the `Linting:` config field to `none`. Security scanning detection is emitted as a separate file (`/security-scanning.md`) following the schema in step 3D. It is produced regardless of project type; if no scanners, waivers, CI integrations, or advisory-DB hints are detected, every section contains a `None detected` placeholder row so callers can default the `Security scanning:` config field to `none`. diff --git a/plugins/arn-code/agents/arn-code-cve-analyst.md b/plugins/arn-code/agents/arn-code-cve-analyst.md index 74a39f4..4eb1051 100644 --- a/plugins/arn-code/agents/arn-code-cve-analyst.md +++ b/plugins/arn-code/agents/arn-code-cve-analyst.md @@ -10,12 +10,6 @@ description: >- Context: Invoked by arn-code-batch-cve-scan during triage of a scanner run user: "scan for CVEs" assistant: (after deterministic parsing of scanner output, invokes arn-code-cve-analyst once per CVE with the record + grep paths + scanner-output checksum) - - Each CVE gets its own focused triage call. The agent annotates contextual - fields (reachability verdict, fix strategy, breaking-change risk, grouping - hint) and echoes back the scanner-output checksum for reproducibility — it - never re-derives version-bound fields. - @@ -23,17 +17,6 @@ description: >- user: "analyze CVE-2024-12345 reachability in this repo" assistant: (invokes arn-code-cve-analyst with the CVE record + project code paths) - - - Context: Invoked by arn-code-batch-cve-scan in proposal mode for unattended triage - user: (scheduled run via Claude Code Routines: "scan for CVEs and produce proposal") - assistant: (deterministically parses scanner output, then fans out to arn-code-cve-analyst per CVE; writes CVE_SCAN_PROPOSAL.md for later human review) - - Proposal mode is hard-gated against AskUserQuestion — the agent's structured - output must stand on its own, with explicit confidence levels and a verdict - taxonomy that never collapses uncertainty to "safe". - - tools: [Read, Glob, Grep] model: opus color: orange diff --git a/plugins/arn-code/agents/arn-code-doctor.md b/plugins/arn-code/agents/arn-code-doctor.md index 41e07dc..7bfafb4 100644 --- a/plugins/arn-code/agents/arn-code-doctor.md +++ b/plugins/arn-code/agents/arn-code-doctor.md @@ -15,27 +15,6 @@ description: >- assistant: Invokes arn-code-doctor to check template directory, checksums file, and ## Arness config for template-related issues. - - - Context: User reports strange behavior during plan execution - user: "arn-code-execute-plan kept skipping tasks that should have been unblocked" - assistant: Invokes arn-code-doctor to check task list state, dependency graph, - and execution flow against expected behavior. - - - - Context: User reports arn-code-init didn't set up GitHub labels - user: "I ran arn-code-init but the GitHub labels weren't created" - assistant: Invokes arn-code-doctor to check Git/GitHub detection results, - gh auth status, and label creation step. - - - - Context: arn-code-init upgrade flow needs a full health check - user: "upgrade arness" (triggers arn-code-init, which selects Upgrade) - assistant: Invokes arn-code-doctor for comprehensive check of all config fields, - directories, templates, checksums, Git/GitHub state, labels, and pattern schema. - tools: [Read, Glob, Grep, Bash] model: opus color: red @@ -88,7 +67,7 @@ Provided by the calling skill (`arn-code-report` or `arn-code-init`): ## Diagnostic Report **Skill(s) involved:** [skill names] -**Plugin version:** [from plugin.json] +**Plugin version:** [output of `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh`] **Config state:** [relevant ## Arness fields, or "not configured"] ### Findings @@ -111,7 +90,7 @@ Provided by the calling skill (`arn-code-report` or `arn-code-init`): - NEVER read or include user project source code, business logic, or sensitive data - ONLY check Arness-related configuration, directories, files, and state - Bash usage is LIMITED to these commands ONLY: `git status`, `git remote -v`, `gh auth status`, `gh label list`, `bkt --version`, `bkt auth status`, `ls` for directory checks. Do NOT run any other commands — especially not `claude` CLI commands which are slow or unavailable -- Plugin installation is verified via `${CLAUDE_PLUGIN_ROOT}` (always set when running inside a plugin) and reading `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` — never via CLI commands +- Plugin installation is verified via `${CLAUDE_PLUGIN_ROOT}` (always set when running inside a plugin) and running `skills/arn-code-ensure-config/scripts/plugin-version.sh` — never via CLI commands - Keep the diagnostic report factual and concise — under 30 lines - If no Arness-specific issues are found, say so explicitly - Do NOT suggest fixes to user code — only Arness workflow fixes diff --git a/plugins/arn-code/agents/arn-code-drift-detector.md b/plugins/arn-code/agents/arn-code-drift-detector.md index dd79c40..a86b317 100644 --- a/plugins/arn-code/agents/arn-code-drift-detector.md +++ b/plugins/arn-code/agents/arn-code-drift-detector.md @@ -13,18 +13,6 @@ description: >- user: "/arn-code-plan FEATURE_websocket-notifications" assistant: (invokes arn-code-drift-detector to confirm the spec still matches current code before planning) - - - Context: arn-code-pick-issue is routing an issue whose feature file already exists - user: "/arn-code-pick-issue" - assistant: (after user picks an issue with a pre-existing feature file, invokes arn-code-drift-detector to gate the hand-off) - - - - Context: A spec was written weeks ago and the codebase has moved on - user: (selects an old FEATURE_X spec from the picker) - assistant: (drift detector runs, reports that two referenced files were renamed and one architectural claim no longer holds) - tools: [Glob, Grep, Read, Bash] model: opus color: yellow diff --git a/plugins/arn-code/agents/arn-code-security-specialist.md b/plugins/arn-code/agents/arn-code-security-specialist.md index 6d00ba6..b462307 100644 --- a/plugins/arn-code/agents/arn-code-security-specialist.md +++ b/plugins/arn-code/agents/arn-code-security-specialist.md @@ -11,25 +11,12 @@ description: >- Context: Invoked by arn-code-feature-spec-teams during team debate user: "feature spec teams: add payment processing" assistant: (invokes arn-code-security-specialist with feature idea + codebase context) - - Feature involves payment data. Security specialist joins the debate team to - advocate for secure-by-default design alongside the architect. - Context: User needs security guidance for a specific feature user: "what security considerations should I have for this auth system?" - - - Context: Invoked by arn-code-feature-spec for lightweight security hints - user: "feature spec: add user registration with email verification" - assistant: (invokes arn-code-security-specialist with focused prompt after architect) - - Feature involves authentication. Security specialist provides brief threat/mitigation list. - - tools: [Read, Glob, Grep, LSP, WebSearch, SendMessage] model: opus color: red diff --git a/plugins/arn-code/agents/arn-code-sketch-builder.md b/plugins/arn-code/agents/arn-code-sketch-builder.md index dfe6092..4264fbc 100644 --- a/plugins/arn-code/agents/arn-code-sketch-builder.md +++ b/plugins/arn-code/agents/arn-code-sketch-builder.md @@ -17,24 +17,6 @@ description: >- user: "sketch the deploy command" assistant: (invokes arn-code-sketch-builder with feature context, paradigm=cli, CLI framework, and target module) - - - Context: Invoked by arn-code-sketch skill to create an initial TUI sketch - user: "sketch the dashboard screen" - assistant: (invokes arn-code-sketch-builder with paradigm=tui, Textual framework, and target screen context) - - - - Context: Invoked by arn-code-sketch skill during iteration - user: "move the form to the left and use a Card wrapper" - assistant: (invokes arn-code-sketch-builder with feedback, current sketch files, and component library context) - - - - Context: Invoked by arn-code-sketch skill for promotion - user: "promote this sketch to the real codebase" - assistant: (invokes arn-code-sketch-builder to copy files, update paths, and integrate) - tools: [Read, Write, Glob, Grep, Bash, Edit] model: opus color: purple diff --git a/plugins/arn-code/agents/arn-code-task-executor.md b/plugins/arn-code/agents/arn-code-task-executor.md index b5a7451..2ebcdc7 100644 --- a/plugins/arn-code/agents/arn-code-task-executor.md +++ b/plugins/arn-code/agents/arn-code-task-executor.md @@ -10,30 +10,12 @@ description: >- Context: Invoked by arn-code-execute-plan skill to execute a specific task user: "Execute task 5 — implement Phase 2 data layer" assistant: (spawns arn-code-task-executor for this single task) - - The skill assigns one task. The executor reads pattern docs, executes the - task, generates its report, and returns a completion summary. - Context: Invoked by arn-code-execute-plan skill to run tests for a phase user: "Execute task 8 — test Phase 3 API endpoints" assistant: (spawns arn-code-task-executor for this single testing task) - - Single testing task. The executor reads all pattern docs first, writes and - runs the specified tests, self-heals any failures, and generates the report. - - - - - Context: Invoked by arn-code-execute-task for a single implementation task - user: "execute task 3" - assistant: (spawns arn-code-task-executor for this single task from the task list) - - Single task execution via arn-code-execute-task. The executor reads pattern - docs, implements the task, and generates its report. - tools: [Read, Glob, Grep, Edit, Write, Bash, LSP, SendMessage, TaskUpdate, TaskList, TaskGet] model: opus diff --git a/plugins/arn-code/agents/arn-code-task-reviewer.md b/plugins/arn-code/agents/arn-code-task-reviewer.md index 3f77ebb..833cc87 100644 --- a/plugins/arn-code/agents/arn-code-task-reviewer.md +++ b/plugins/arn-code/agents/arn-code-task-reviewer.md @@ -11,30 +11,12 @@ description: >- Context: Invoked by arn-code-execute-plan after executor completes Task 3 user: "review the implementation of Task 3" assistant: (spawns arn-code-task-reviewer to validate implementation against patterns and acceptance criteria) - - Executor completed Task 3. Reviewer reads pattern docs, re-runs tests, - checks acceptance criteria, and returns a verdict with findings. - Context: Single task review requested by arn-code-execute-task skill user: "review task 5 implementation" assistant: (spawns arn-code-task-reviewer for focused validation) - - Single-task review via arn-code-execute-task. Reviewer validates just this - task's implementation and returns findings. - - - - - Context: Invoked after a failed task needs re-review - user: "re-review task 3 after executor applied fixes" - assistant: (spawns arn-code-task-reviewer to re-validate the fixed implementation) - - Re-review after fixes. Reviewer checks whether previous error findings - are resolved and returns an updated verdict. - tools: [Read, Glob, Grep, Write, Bash, SendMessage, TaskUpdate, TaskList, TaskGet] model: opus diff --git a/plugins/arn-code/agents/arn-code-test-specialist.md b/plugins/arn-code/agents/arn-code-test-specialist.md index 4c0dc96..d41bac0 100644 --- a/plugins/arn-code/agents/arn-code-test-specialist.md +++ b/plugins/arn-code/agents/arn-code-test-specialist.md @@ -2,35 +2,18 @@ name: arn-code-test-specialist description: >- This agent should be used when the user needs to run the project's test suite - and interpret results, or when the arness-assess skill needs test execution + and interpret results, or when the arn-code-assess skill needs test execution as a quality gate before shipping implementation changes. Context: Invoked by arn-code-assess after all improvements are executed user: "assess codebase" assistant: (invokes arn-code-test-specialist to run full test suite before shipping) - - The assess skill triggers this agent at the pre-ship test gate to verify - that all implemented changes pass the existing test suite. - Context: User wants to run tests and get a structured report user: "run the tests and tell me what's failing" - - Direct invocation to run the test suite and identify failures with - structured output including file paths and error details. - - - - - Context: User wants to verify test health before shipping - user: "run the full test suite and give me a report" - - Pre-ship verification — user wants confirmation that all tests pass - before committing or creating a PR. - tools: [Read, Glob, Grep, Bash] model: opus diff --git a/plugins/arn-code/agents/arn-code-ux-specialist.md b/plugins/arn-code/agents/arn-code-ux-specialist.md index bda9494..c72210a 100644 --- a/plugins/arn-code/agents/arn-code-ux-specialist.md +++ b/plugins/arn-code/agents/arn-code-ux-specialist.md @@ -10,25 +10,12 @@ description: >- Context: Invoked by arn-code-feature-spec-teams during team debate user: "feature spec teams: add a dashboard for analytics" assistant: (invokes arn-code-ux-specialist with feature idea + codebase context) - - Feature has UI components. UX specialist joins the debate team to - advocate for user experience alongside the architect. - Context: User needs UI design guidance for a specific feature user: "how should the user interface for the settings page work?" - - - Context: Backend project adding frontend for the first time - user: "we need to add a web UI to our API — what should the frontend look like?" - - No existing frontend. UX specialist operates in recommendation mode, - proposing a UI stack and component patterns from scratch. - - tools: [Read, Glob, Grep, LSP, WebSearch, SendMessage] model: opus color: pink diff --git a/plugins/arn-code/hooks/hooks.json b/plugins/arn-code/hooks/hooks.json new file mode 100644 index 0000000..683a18f --- /dev/null +++ b/plugins/arn-code/hooks/hooks.json @@ -0,0 +1,28 @@ +{ + "description": "arn-code safety and quality hooks. They act only in projects with a '## Arness' section in CLAUDE.md. Turn all off with ARNESS_HOOKS=off, or some with ARNESS_HOOKS_DISABLE=session,force-push,secrets,lint.", + "hooks": { + "SessionStart": [ + { + "hooks": [ + { "type": "command", "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\"", "timeout": 20 } + ] + } + ], + "PreToolUse": [ + { + "matcher": "Bash", + "hooks": [ + { "type": "command", "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/pre-bash.sh\"", "timeout": 30 } + ] + } + ], + "PostToolUse": [ + { + "matcher": "Edit|Write|MultiEdit", + "hooks": [ + { "type": "command", "command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/post-edit-lint.sh\"", "timeout": 130 } + ] + } + ] + } +} diff --git a/plugins/arn-code/hooks/lib-hook.sh b/plugins/arn-code/hooks/lib-hook.sh new file mode 100755 index 0000000..88303f0 --- /dev/null +++ b/plugins/arn-code/hooks/lib-hook.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# Shared helpers for arn-code plugin hooks. +# +# Every hook fails open: when a tool is missing or input cannot be parsed, the +# hook exits 0 and lets Claude Code continue. Hooks only act inside Arness +# projects (CLAUDE.md with a "## Arness" section). +# +# Hooks are off until the user turns them on (ARN_HOOKS_DEFAULT below): +# "- **Hooks:** on" in the ## Arness section on for this project (whole team) +# ARNESS_HOOKS=on on for this user (shell or settings "env") +# ARNESS_HOOKS=off off, whatever the project says +# ARNESS_HOOKS_DISABLE=a,b disable some: session, force-push, secrets, lint + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/skills/arn-code-ensure-config/scripts/lib.sh" + +ARN_HOOK_INPUT="" + +arn_hook_read_input() { + ARN_HOOK_INPUT=$(cat) +} + +ARN_HOOKS_DEFAULT=off + +# arn_hook_enabled : true when hooks are on and this hook is not disabled. +# Call it after arn_hook_enter_project: it reads the Hooks field of the project. +arn_hook_enabled() { + case ",${ARNESS_HOOKS_DISABLE:-}," in *",$1,"*) return 1 ;; esac + local v="${ARNESS_HOOKS:-}" + [ -n "$v" ] || v=$(arn_config_field Hooks 2>/dev/null) + [ -n "$v" ] || v=$ARN_HOOKS_DEFAULT + case "$v" in on|enabled|yes|true) return 0 ;; *) return 1 ;; esac +} + +# arn_hook_json : print a string field from the hook input. +# Carriage returns are dropped (jq and Python on Windows end lines with CR LF). +arn_hook_json() { + local py + if command -v jq >/dev/null 2>&1; then + printf '%s' "$ARN_HOOK_INPUT" | jq -r ".$1 // empty" 2>/dev/null | tr -d '\r' + elif py=$(arn_python); then + printf '%s' "$ARN_HOOK_INPUT" | "$py" -I -c ' +import json, sys +try: + d = json.load(sys.stdin) +except Exception: + sys.exit(0) +for k in sys.argv[1].split("."): + d = d.get(k) if isinstance(d, dict) else None +if isinstance(d, str): + print(d) +elif d is not None: + print(json.dumps(d)) +' "$1" | tr -d '\r' + else + printf '%s' "$ARN_HOOK_INPUT" | arn_json_get "$1" + fi +} + +# arn_json_get : stdin JSON -> the string, number or boolean at the path. +# Plain awk, for machines with neither jq nor Python (common on Windows). Objects and +# arrays print nothing; \u escapes above U+007F stay as written. +arn_json_get() { + awk -v want=".$1" ' + function ws() { while (p <= n && index(" \t\r\n", substr(s, p, 1))) p++ } + function str(keep, out, c, h, i, v) { + p++; out = "" + while (p <= n) { + c = substr(s, p, 1) + if (c == "\"") { p++; return out } + if (c == "\\") { + p++; c = substr(s, p, 1) + if (c == "u") { + h = substr(s, p + 1, 4); p += 4; v = 0 + for (i = 1; i <= 4; i++) v = v * 16 + index("0123456789abcdef", tolower(substr(h, i, 1))) - 1 + c = (v >= 32 && v < 127) ? sprintf("%c", v) : "\\u" h + } else if (c == "n") c = "\n"; else if (c == "t") c = "\t"; else if (c == "r") c = "\r" + else if (c == "b") c = "\b"; else if (c == "f") c = "\f" + } + if (keep) out = out c + p++ + } + return out + } + function value(path, c, k, i, v) { + ws(); c = substr(s, p, 1) + if (c == "{" || c == "[") { + p++; i = 0; ws() + if (substr(s, p, 1) == (c == "{" ? "}" : "]")) { p++; return } + while (p <= n && !found) { + ws() + if (c == "{") { k = str(1); ws(); p++ } else k = i++ + value(path "." k); ws() + v = substr(s, p, 1); p++ + if (v != ",") return + } + } else if (c == "\"") { + v = str(path == want); if (path == want) { print v; found = 1 } + } else { + v = "" + while (p <= n && !index(",]} \t\r\n", substr(s, p, 1))) { v = v substr(s, p, 1); p++ } + if (path == want && v != "null") { print v; found = 1 } + } + } + { s = (NR > 1 ? s "\n" : "") $0 } + END { n = length(s); p = 1; found = 0; value("") } + ' +} + +# arn_hook_path : a path field from the hook input, in Git Bash form on Windows. +arn_hook_path() { + arn_unix_path "$(arn_hook_json "$1")" +} + +# arn_hook_rel_path : print the file's path from the project root (the current +# directory); false when it is outside. Physical paths, so a symlink on either side +# (for example the macOS temp folder) still matches. +arn_hook_rel_path() { + local root dir + root=$(pwd -P) + dir=$(cd "$(dirname "$1")" 2>/dev/null && pwd -P) || return 1 + case "$dir/" in "$root"/*) ;; *) return 1 ;; esac + dir="${dir#"$root"}"; dir="${dir#/}" + printf '%s' "${dir:+$dir/}$(basename "$1")" +} + +# arn_json_escape: stdin -> JSON string body (no surrounding quotes). +arn_json_escape() { + tr -d '\000-\010\013\014\016-\037' | awk 'BEGIN{ORS=""} { + gsub(/\\/, "\\\\"); gsub(/"/, "\\\""); gsub(/\t/, "\\t"); gsub(/\r/, "") + if (NR > 1) printf "\\n" + printf "%s", $0 + }' +} + +# arn_hook_context : add text to Claude's context. +arn_hook_context() { + printf '{"hookSpecificOutput":{"hookEventName":"%s","additionalContext":"%s"}}\n' \ + "$1" "$(printf '%s' "$2" | arn_json_escape)" +} + +# arn_hook_deny : deny the current PreToolUse call; Claude sees the reason. +arn_hook_deny() { + printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"%s"}}\n' \ + "$(printf '%s' "$1" | arn_json_escape)" +} + +# arn_hook_enter_project: cd to the project root; false if not an Arness project. +arn_hook_enter_project() { + local cwd + cwd=$(arn_hook_path cwd) + if [ -n "$cwd" ] && [ -d "$cwd" ]; then cd "$cwd" 2>/dev/null || true; fi + arn_cd_project_root || return 1 + arn_is_arness_project +} + +# Directory holding pattern docs and tooling.json ("Code patterns" field). +arn_patterns_dir() { + local d + d=$(arn_config_field "Code patterns") + printf '%s' "${d:-.arness}" +} diff --git a/plugins/arn-code/hooks/post-edit-lint.sh b/plugins/arn-code/hooks/post-edit-lint.sh new file mode 100755 index 0000000..684ae0c --- /dev/null +++ b/plugins/arn-code/hooks/post-edit-lint.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +# PostToolUse (Edit|Write|MultiEdit): fast lint and format check on the edited +# file, using the project's own commands from /tooling.json. +# Advisory only: findings are added to Claude's context, the edit is never blocked. +# Runs only when "Linting: enabled", tooling.json is approved (tooling-approve.sh), +# and the project does not already own these checks ("owner": "project"). +# Language-neutral: which commands run is decided entirely by tooling.json. + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib-hook.sh" + +arn_hook_read_input +file=$(arn_hook_path tool_input.file_path) +[ -n "$file" ] || exit 0 +arn_hook_enter_project || exit 0 +arn_hook_enabled lint || exit 0 +[ "$(arn_config_field Linting)" = "enabled" ] || exit 0 + +tooling="$(arn_patterns_dir)/tooling.json" +[ -f "$tooling" ] || exit 0 +[ -f .arness/tooling.local.sha ] || exit 0 +[ "$(arn_hash_file "$tooling")" = "$(cat .arness/tooling.local.sha)" ] || exit 0 +py=$(arn_python) || exit 0 + +rel=$(arn_hook_rel_path "$file") || exit 0 +[ -f "$rel" ] || exit 0 + +# Pick the deepest service whose path contains the file and whose extensions +# match; print its file-level check commands, one per line, {files} filled in. +cmds=$("$py" -I - "$tooling" "$rel" <<'PY' +import json, os, shlex, sys +try: + data = json.load(open(sys.argv[1])) +except Exception: + sys.exit(0) +rel = sys.argv[2] +ext = os.path.splitext(rel)[1] +best = None +for svc in data.get("services", []): + p = (svc.get("path") or ".").strip("/") + if p not in ("", ".") and not (rel == p or rel.startswith(p + "/")): + continue + exts = svc.get("extensions") or [] + if exts and ext not in exts: + continue + depth = 0 if p in ("", ".") else p.count("/") + 1 + if best is None or depth > best[0]: + best = (depth, svc) +if best is None or best[1].get("owner") == "project": + sys.exit(0) +for key in ("lintFiles", "formatCheckFiles"): + c = best[1].get(key) + if c and "{files}" in c: + print(c.replace("{files}", shlex.quote(rel))) +PY +) +[ -n "$cmds" ] || exit 0 + +report="" +while IFS= read -r c; do + [ -n "$c" ] || continue + if command -v timeout >/dev/null 2>&1; then + out=$(timeout 60 bash -c "$c" 2>&1); rc=$? + else + out=$(bash -c "$c" 2>&1); rc=$? + fi + if [ $rc -ne 0 ]; then + report="$report +\$ $c (exit $rc) +$(printf '%s\n' "$out" | head -40)" + fi +done <<< "$cmds" + +[ -n "$report" ] || exit 0 +arn_hook_context PostToolUse "Arness lint check (advisory) found issues in $rel. Fix them before finishing the task:$report" diff --git a/plugins/arn-code/hooks/pre-bash.sh b/plugins/arn-code/hooks/pre-bash.sh new file mode 100755 index 0000000..cf6f4ce --- /dev/null +++ b/plugins/arn-code/hooks/pre-bash.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# PreToolUse (Bash): two safety checks inside Arness projects. +# force-push deny "git push --force" / "-f" / "+refspec" (--force-with-lease is allowed) +# secrets before "git commit", scan what will be committed for private keys +# and access tokens; deny on a hit +# Language-neutral: secret formats are credential shapes, not project tooling. + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib-hook.sh" + +arn_hook_read_input +[ "${ARNESS_HOOKS:-}" = "off" ] && exit 0 +cmd=$(arn_hook_json tool_input.command) +[ -n "$cmd" ] || exit 0 +case "$cmd" in *git*) ;; *) exit 0 ;; esac +arn_hook_enter_project || exit 0 + +# Split the command line into simple segments on ; && || | and newlines. +segments=$(printf '%s\n' "$cmd" | awk '{gsub(/&&|\|\||[;|]/, "\n"); print}') + +# Print the words of a segment that come after its git subcommand $1. +words_after() { + printf '%s\n' "$2" | awk -v sub_cmd="$1" '{ + seen_git = 0; seen_sub = 0 + for (i = 1; i <= NF; i++) { + if (!seen_git) { if ($i == "git" || $i ~ /\/git$/) seen_git = 1; continue } + if (!seen_sub) { if ($i == sub_cmd) seen_sub = 1; continue } + print $i + } + }' +} + +# --- force push --- +if arn_hook_enabled force-push; then + forced=$(printf '%s\n' "$segments" | while IFS= read -r seg; do + words_after push "$seg" | awk ' + $0 == "--force" || $0 ~ /^-[A-Za-z]*f[A-Za-z]*$/ || $0 ~ /^\+/ { print "y"; exit }' + done | head -1) + if [ "$forced" = "y" ]; then + arn_hook_deny "Arness blocks force-push in this project. Use --force-with-lease if you must overwrite the remote branch, or ask the user to push manually. (Disable with ARNESS_HOOKS_DISABLE=force-push.)" + exit 0 + fi +fi + +# --- secrets before commit --- +arn_hook_enabled secrets || exit 0 +commit_words=$(printf '%s\n' "$segments" | while IFS= read -r seg; do + if printf '%s\n' "$seg" | awk '{f=0; for(i=1;i<=NF;i++){if($i=="git"||$i~/\/git$/)f=1; else if(f&&$i=="commit"){print "y"; exit}}}' | grep -q y; then + printf 'COMMIT\n'; words_after commit "$seg" + fi +done) +case "$commit_words" in *COMMIT*) ;; *) exit 0 ;; esac +case "$commit_words" in *--dry-run*) exit 0 ;; esac + +include_worktree=0 +printf '%s\n' "$commit_words" | grep -Eqx -- '-[A-Za-z]*a[A-Za-z]*|--all' && include_worktree=1 +printf '%s\n' "$segments" | awk '{f=0; for(i=1;i<=NF;i++){if($i=="git"||$i~/\/git$/)f=1; else if(f&&$i=="add"){print "y"; exit}}}' | grep -q y && include_worktree=2 + +pattern='-----BEGIN ([A-Z]+ )*PRIVATE KEY-----|(AKIA|ASIA)[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{60,}|glpat-[A-Za-z0-9_-]{20,}|xox[abprs]-[A-Za-z0-9-]{10,}|sk-ant-[A-Za-z0-9_-]{20,}|sk_live_[0-9A-Za-z]{24,}|AIza[0-9A-Za-z_-]{35}' + +# Added lines from a unified diff, prefixed with their file name. +added_lines() { + awk '/^\+\+\+ b\//{file=substr($0, 7); next} /^\+\+\+ /{next} /^\+/{print file ": " substr($0, 2)}' +} + +hits=$( + { + git diff --cached -U0 --no-color 2>/dev/null | added_lines + if [ $include_worktree -ge 1 ]; then git diff -U0 --no-color 2>/dev/null | added_lines; fi + if [ $include_worktree -ge 2 ]; then + git ls-files --others --exclude-standard -z 2>/dev/null | while IFS= read -r -d '' f; do + [ -f "$f" ] && [ "$(wc -c < "$f")" -lt 1048576 ] && grep -IH "" "$f" 2>/dev/null | sed 's/^\([^:]*\):/\1: /' + done + fi + } | grep -E -- "$pattern" | grep -v 'arness:allow-secret' | cut -d: -f1 | sort -u | head -10 +) + +key_files=$( + { + git diff --cached --name-only 2>/dev/null + [ $include_worktree -ge 2 ] && git ls-files --others --exclude-standard 2>/dev/null + } | grep -E '(^|/)(id_rsa|id_dsa|id_ecdsa|id_ed25519)$|\.(pem|p12|pfx|key)$|(^|/)\.env$' | sort -u | head -10 +) + +if [ -n "$hits$key_files" ]; then + list=$(printf '%s\n' "$hits" | sed '/^$/d' | paste -sd, - | sed 's/,/, /g') + list2=$(printf '%s\n' "$key_files" | sed '/^$/d' | paste -sd, - | sed 's/,/, /g') + arn_hook_deny "Arness found what looks like a secret in the files being committed. Content matches: ${list:-none}. Key or env files: ${list2:-none}. Do not commit secrets: remove them, add the file to .gitignore, or move the value to an env var. If this is a false positive, add the comment 'arness:allow-secret' on that line, or ask the user to set ARNESS_HOOKS_DISABLE=secrets." +fi +exit 0 diff --git a/plugins/arn-code/hooks/session-start.sh b/plugins/arn-code/hooks/session-start.sh new file mode 100755 index 0000000..42b4b73 --- /dev/null +++ b/plugins/arn-code/hooks/session-start.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# SessionStart: one status line about the Arness config, and after a compaction +# a pointer to the plan in progress so the session can pick up where it was. + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib-hook.sh" + +arn_hook_read_input +arn_hook_enter_project || exit 0 +arn_hook_enabled session || exit 0 + +reason=$(bash "$ARN_LIB_DIR/cache-check.sh" 2>&1 >/dev/null) +if [ -z "$reason" ]; then + msg="Arness (arn-code $(arn_plugin_version)): config cache valid." +else + msg="Arness (arn-code $(arn_plugin_version)): ${reason}. Entry-point skills will run the full config check at Step 0." +fi + +if [ "$(arn_hook_json source)" = "compact" ]; then + plans=$(arn_config_field "Plans directory") + plans="${plans:-.arness/plans}" + latest="" + if [ -d "$plans" ]; then + latest=$(find "$plans" -name PROGRESS_TRACKER.json -mtime -7 2>/dev/null | while IFS= read -r f; do + printf '%s\t%s\n' "$(stat -c %Y "$f" 2>/dev/null || stat -f %m "$f" 2>/dev/null || echo 0)" "$f" + done | sort -rn | head -1 | cut -f2) + fi + if [ -n "$latest" ]; then + dir=$(dirname "$latest") + msg="$msg +Context was compacted. The most recently updated Arness plan is $dir. Before continuing implementation work, re-read $dir/PROGRESS_TRACKER.json and $dir/TASKS.md to find the current phase and next task." + fi +fi + +arn_hook_context SessionStart "$msg" diff --git a/plugins/arn-code/hooks/tooling-approve.sh b/plugins/arn-code/hooks/tooling-approve.sh new file mode 100755 index 0000000..e37f370 --- /dev/null +++ b/plugins/arn-code/hooks/tooling-approve.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Records that the user approved the commands in /tooling.json. +# Hooks only run commands from an approved tooling.json; editing the file +# (or cloning a repo with a different one) requires a new approval. + +set -u + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib-hook.sh" + +arn_cd_project_root || { echo "tooling-approve: cannot resolve project root" >&2; exit 1; } +f="$(arn_patterns_dir)/tooling.json" +[ -f "$f" ] || { echo "tooling-approve: $f not found" >&2; exit 1; } +mkdir -p .arness +arn_hash_file "$f" > .arness/tooling.local.sha +echo "approved: $f" diff --git a/plugins/arn-code/skills/arn-code-assess/SKILL.md b/plugins/arn-code/skills/arn-code-assess/SKILL.md index 34b8430..7bff07d 100644 --- a/plugins/arn-code/skills/arn-code-assess/SKILL.md +++ b/plugins/arn-code/skills/arn-code-assess/SKILL.md @@ -2,14 +2,11 @@ name: arn-code-assess description: >- This skill should be used when the user says "arness code assess", "arn-code-assess", - "assess codebase", - "technical review", "codebase assessment", "find improvements", "what should I improve", - "tech debt review", "tech debt audit", "pattern compliance check", "codebase health check", - "assess the project", "improvement plan", "review my codebase", "what needs fixing", - "code quality check", "audit my code", "run an assessment", + "tech debt audit", "assess the project", or wants a comprehensive technical assessment of the codebase against stored patterns followed by prioritized improvement execution through the full Arness pipeline. version: 1.0.0 +argument-hint: "[scope]" --- # Arness Assess @@ -124,17 +121,17 @@ Read ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-assess/references/assessment-protocol **Agent invocations — launch all applicable agents in parallel:** -**Always invoke the `arn-code-architect` agent** via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +**Always invoke the `arn-code-architect` agent** via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The architect assessment prompt template from the protocol - Codebase context: full content of `code-patterns.md`, `testing-patterns.md`, `architecture.md` - Scope: the scope from G1 -**If `has_ui_patterns` is true**, also invoke the `arn-code-ux-specialist` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +**If `has_ui_patterns` is true**, also invoke the `arn-code-ux-specialist` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The UX specialist assessment prompt template from the protocol - Context: `ui-patterns.md`, `architecture.md`, `code-patterns.md` - Scope from G1 -**If `has_security_patterns` is true**, also invoke the `arn-code-security-specialist` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +**If `has_security_patterns` is true**, also invoke the `arn-code-security-specialist` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The security specialist assessment prompt template from the protocol - Context: `security-patterns.md`, `architecture.md`, `code-patterns.md` - Scope from G1 @@ -303,7 +300,7 @@ Show progress: Arness Assess: scope → assess → prioritize → spec(s) → plan → save → execute → TEST → ship ^^^^ ``` -Invoke the `arn-code-test-specialist` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Invoke the `arn-code-test-specialist` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - **Scope:** "full suite" - **Code patterns directory:** the configured code-patterns path diff --git a/plugins/arn-code/skills/arn-code-batch-cve-fix/SKILL.md b/plugins/arn-code/skills/arn-code-batch-cve-fix/SKILL.md index e175441..6da301b 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-fix/SKILL.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-fix/SKILL.md @@ -2,18 +2,15 @@ name: arn-code-batch-cve-fix description: >- This skill should be used when the user says "fix CVEs", "patch vulnerabilities", - "apply security patches", "resolve security advisories", "batch CVE fix", - "patch dependencies", "fix security findings", "remediate CVEs", - "apply CVE fixes", "batch fix vulnerabilities", "resolve vulnerability tickets", + "apply security patches", "batch CVE fix", "remediate CVEs", "arness CVE fix", "arn-code-batch-cve-fix", "fix all open CVE tickets", "cleanup resolved CVE proposals", or wants Arness to apply per-group dependency - bumps for previously-triaged CVEs and open per-group pull requests that close - their corresponding sub-issues. Reuses arn-code-batch-implement worker isolation - verbatim, opens PRs targeting the configured Security branch, and offers an - interactive post-merge cleanup of fully-resolved past CVE proposals. Interactive - only — no proposal mode, no headless write path; every PR is human-reviewed and - every archive move is confirmed via AskUserQuestion. Requires that - arn-code-batch-cve-scan has produced triage records and sub-issues. + bumps for CVEs already triaged by arn-code-batch-cve-scan and open one + human-reviewed PR per group against the configured Security branch. + Interactive only. +version: 1.0.0 +argument-hint: "[--proposal-path=]" +disable-model-invocation: true --- # Arness Batch CVE Fix @@ -22,7 +19,7 @@ Apply per-group fixes for previously-triaged CVEs, open per-group pull requests **Key architectural constraint:** This skill is a sequencer — it MUST NOT duplicate sub-reference logic. All procedural detail lives in `references/`. Worker isolation (worktree setup, isolation check, cleanup-on-failure) is INHERITED from `arn-code-batch-implement/references/worker-instructions.md` — this skill's own `worker-instructions.md` DELEGATES to that source-of-truth and documents only the per-group fix scope. -**Interactive-only** (per spec FR §30). There is no `--mode=` argument. There is no proposal artifact. There is no headless / scheduled fix path. Every PR is human-reviewed at creation time; every past-plan archive is confirmed via `AskUserQuestion`. The auto-apply boundary (see `references/auto-apply-boundary.md`) controls whether the worker drives the dependency bump itself (when all 5 conditions are met) or pauses for human application — the worker still always opens a PR for review. +**Interactive-only**. There is no `--mode=` argument. There is no proposal artifact. There is no headless / scheduled fix path. Every PR is human-reviewed at creation time; every past-plan archive is confirmed via `AskUserQuestion`. The auto-apply boundary (see `references/auto-apply-boundary.md`) controls whether the worker drives the dependency bump itself (when all 5 conditions are met) or pauses for human application — the worker still always opens a PR for review. Pipeline position: @@ -65,7 +62,7 @@ After ensure-config completes, extract from `## Arness`: - **Platform** — `github | jira | none`. Drives `gh` vs. Atlassian-MCP for PR creation. - **Git** — must be `yes`. If `no`, inform the user: "Batch CVE fix requires git for worktree-based parallel execution. Set `Git: yes` in `## Arness` or apply fixes manually." STOP. -If `Security branch:` is missing, Layer 2c will have prompted the user via `AskUserQuestion` and written the chosen value (see Phase 5 wiring). This skill consumes the field — it does not write it. +If `Security branch:` is missing, Layer 2c will have prompted the user via `AskUserQuestion` and written the chosen value. This skill consumes the field — it does not write it. Resolve a worker count cap: mirror `arn-code-batch-implement`'s `≤5 concurrent workers` policy. If more than 5 groups are formed, batch them into successive waves of 5. @@ -148,7 +145,7 @@ Ask (using `AskUserQuestion`): ## Step 5: Dispatch Parallel Workers -Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-fix/references/worker-instructions.md` and follow its dispatch procedure. The worker-instructions file DELEGATES to `plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md` for worktree setup, isolation enforcement, and cleanup-on-failure semantics — this skill never reimplements that logic. The fix-specific reference adds only: +Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-fix/references/worker-instructions.md` and follow its dispatch procedure. The worker-instructions file DELEGATES to `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-implement/references/worker-instructions.md` for worktree setup, isolation enforcement, and cleanup-on-failure semantics — this skill never reimplements that logic. The fix-specific reference adds only: - The per-group fix scope (single CVE for critical/breaking; bundled cap 8 for others). - Worktree creation baseline: `git worktree add ` (NOT a hardcoded base branch). diff --git a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md index 084e45a..49214d1 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md @@ -1,6 +1,6 @@ # Auto-Apply Boundary — 5-Condition AND-Gate -This file documents the auto-apply eligibility gate per spec FR §10 (updated per FR §22 to anchor the CI baseline check on the configured `Security branch:` rather than a hardcoded `main`). The gate is evaluated PER GROUP (not per CVE) — a group is auto-applied only if EVERY CVE in the group satisfies all 5 conditions. +This file documents the auto-apply eligibility gate (the CI baseline check is anchored on the configured `Security branch:` rather than a hardcoded `main`). The gate is evaluated PER GROUP (not per CVE) — a group is auto-applied only if EVERY CVE in the group satisfies all 5 conditions. The gate output is a single boolean per group: `auto-apply: true | false`. The boolean is passed to the worker via the dispatch prompt (see `worker-instructions.md` field `{auto_apply}`). When `false`, the worker still runs and still opens a PR — but it pauses for human application of the bump and the PR body is marked "Human-applied". @@ -29,11 +29,11 @@ The latest run must satisfy ALL of: - `status == "completed"` - `conclusion == "success"` -- `updatedAt` within the last **N hours** (default `24h` — see OPEN-ITEM-4 decision below). +- `updatedAt` within the last **N hours** (default `24h` — see the baseline-window decision below). If ANY of these fail (e.g., CI is currently red, or the last successful run is older than the window, or no runs exist), the condition is FALSE. -**OPEN-ITEM-4 decision: configurable baseline window, default 24h.** +**Decision: configurable baseline window, default 24h.** The baseline window is configurable at the `## Arness` level via an optional field `Security branch CI baseline window:`. Accepted values: `h` (hours) or `d` (days). Default when unset: `24h`. This trades freshness (a short window catches drift quickly but raises the bar for auto-apply) against availability (a long window is more permissive but raises the risk of approving on stale CI). 24h is the canonical recommendation: most projects with active CI run nightly at minimum, and a 24h window matches typical sleep / weekend rhythms without being so loose that a multi-day red interval slips through. @@ -67,7 +67,7 @@ The triage record's `reachabilityVerdict` field (from `arn-code-cve-analyst`) mu **Rationale:** auto-apply makes sense only for CVEs that actually touch the project's code path — applying an unattended bump for an unreachable CVE creates churn without security benefit and risks introducing breakage with no offsetting risk reduction. Unreachable CVEs always get a human ack so the team can confirm the lack of impact before merging the bump. -Note that v1 reachability is narrowing-only (per spec FR §5) — `high-confidence-unreachable` exists but `safe` does not. A `low-confidence-unreachable` verdict represents grep-no-match plus an honest acknowledgment that grep does not see dynamic dispatch, reflection, FFI, or template engines. Both unreachable verdicts fail this condition; only an explicit `reachable` verdict qualifies for auto-apply. +Note that v1 reachability is narrowing-only — `high-confidence-unreachable` exists but `safe` does not. A `low-confidence-unreachable` verdict represents grep-no-match plus an honest acknowledgment that grep does not see dynamic dispatch, reflection, FFI, or template engines. Both unreachable verdicts fail this condition; only an explicit `reachable` verdict qualifies for auto-apply. --- @@ -85,7 +85,7 @@ These aborts are reported in the parent skill's pre-flight summary so the user u ## Supply-Chain Provenance (v1 TODO marker only) -**OPEN-ITEM-3 decision: v1 ships a TODO marker only.** +**Decision: v1 ships a TODO marker only.** A 6th condition — cryptographic supply-chain provenance verification — is OUT OF SCOPE for v1 per the spec. The intent is to eventually verify each candidate fix version's provenance against: @@ -100,7 +100,7 @@ Until that work lands in v2, this file carries the marker: TODO(security): npm-provenance / sigstore / Go-checksum-DB verification ``` -The marker is intentionally annotated for provenance — `grep -rn "TODO(security)" plugins/arn-code/skills/arn-code-batch-cve-fix/` returns this line, giving v2 a single point of entry. No verification logic ships in v1; auto-apply remains a 5-condition gate (not 6) until the v2 work lands. +The marker is intentionally annotated for provenance — `grep -rn "TODO(security)" ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-fix/` returns this line, giving v2 a single point of entry. No verification logic ships in v1; auto-apply remains a 5-condition gate (not 6) until the v2 work lands. When v2 ships, the new condition will become Condition 6 and the AND-gate evaluation order will append it last (so cheap conditions still short-circuit before the more expensive provenance fetch). diff --git a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/cleanup-resolved.md b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/cleanup-resolved.md index 2a72e42..f755254 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/cleanup-resolved.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/cleanup-resolved.md @@ -128,7 +128,7 @@ Past proposals where `Eligible? == no` are NOT presented for archive. They remai ### Step 5: Interactive Archive Confirmation (per eligible proposal) -For each eligible past proposal, prompt the user via `AskUserQuestion`. Per Pattern 5 (AskUserQuestion Convention), this is the canonical interactive-choice surface: +For each eligible past proposal, prompt the user via `AskUserQuestion`. Per the AskUserQuestion convention, this is the canonical interactive-choice surface: > **Past CVE proposal `CVE_` has all CVEs resolved (both axes satisfied). Archive it to `.arness/plans/CVE_archive/`?** > 1. **Archive** (Recommended) — moves the directory to `.arness/plans/CVE_archive/CVE_/` via `git mv`, preserving git history. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/grouping.md b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/grouping.md index 7074f05..ffc7628 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/grouping.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/grouping.md @@ -54,7 +54,7 @@ The sort is lexicographic on the advisory ID strings (`CVE-2023-12345` < `CVE-20 printf '%s' ",," | (sha256sum || shasum -a 256) | awk '{print $1}' ``` -Pattern 3 hashing fallback applies — `sha256sum || shasum -a 256` covers Linux + macOS + Windows-via-Git-Bash. The first 8 characters of the hex are used as a human-readable prefix in worktree slugs (`arn-batch-cve-a3f9bc01`) and in pre-flight tables. +The cross-platform hashing fallback applies — `sha256sum || shasum -a 256` covers Linux + macOS + Windows-via-Git-Bash. The first 8 characters of the hex are used as a human-readable prefix in worktree slugs (`arn-batch-cve-a3f9bc01`) and in pre-flight tables. **Stability across re-runs.** Re-running the fix skill against the same triage records produces the same `groupId`s (identical hash inputs). This lets the parent skill detect "the same group" across re-invocations — useful when a worker fails mid-run and the user wants to re-dispatch only the failed groups. It also lets `cleanup-resolved.md` correlate past PRs back to original group identities. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/pr-body.md b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/pr-body.md index 7fcb99d..647cf4e 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/pr-body.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/pr-body.md @@ -26,7 +26,7 @@ Fixes CVEs across packages (severity range: .. ### 2. Scanner Verdict Transparency -Per spec FR §17 — this is the load-bearing debuggability section. When the merge ceremony's CI scanner disagrees with the resolution PR's verdict ("you fixed it but I still see it" / "you didn't fix it but I no longer see it"), the reviewer needs to know exactly which scanner produced the verdict, which version of that scanner, and which advisory-DB timestamp was authoritative at scan time. +This is the load-bearing debuggability section. When the merge ceremony's CI scanner disagrees with the resolution PR's verdict ("you fixed it but I still see it" / "you didn't fix it but I no longer see it"), the reviewer needs to know exactly which scanner produced the verdict, which version of that scanner, and which advisory-DB timestamp was authoritative at scan time. Rendered as a sub-block: @@ -96,7 +96,7 @@ A single line distinguishing the two paths: ``` ## Application -Auto-applied per the 5-condition auto-apply boundary (see plugins/arn-code/skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md). +Auto-applied per the 5-condition auto-apply boundary (see the arn-code plugin: skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md). ``` - For groups where `{auto_apply}` was `false`: @@ -163,7 +163,7 @@ Command: `npm test` Result: pass ## Application -Auto-applied per the 5-condition auto-apply boundary (see plugins/arn-code/skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md). +Auto-applied per the 5-condition auto-apply boundary (see the arn-code plugin: skills/arn-code-batch-cve-fix/references/auto-apply-boundary.md). ## PR Target This PR targets `release/2024-Q4` (the project's configured `Security branch:`). diff --git a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/worker-instructions.md b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/worker-instructions.md index c0b191b..2908472 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-fix/references/worker-instructions.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-fix/references/worker-instructions.md @@ -3,12 +3,12 @@ This file documents the per-worker procedure for `arn-code-batch-cve-fix`. **Worker isolation, worktree setup, and cleanup-on-failure semantics are NOT redefined here.** They are inherited verbatim from the source-of-truth at: ``` -plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md +${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-implement/references/worker-instructions.md ``` This file documents ONLY the per-group fix-specific scope, the worktree baseline override (the configured `Security branch:` is the base — not the project's default branch), and the PR target override (also `Security branch:`). Everything else — Step 0 anchoring, ISOLATION FAILURE handling, `git -C "$WORKTREE"` discipline, no-force-push rule, sibling-worktree off-limits rule, isolation-failure-is-fatal rule — applies unchanged. -**Pattern 6 (Worker Isolation):** the canonical contract is `plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md`. This sibling file MUST NOT fork that contract. If a behavior is missing from this file, fall back to batch-implement's worker-instructions. If a behavior conflicts with batch-implement's worker-instructions, batch-implement wins. +**Worker isolation:** the canonical contract is `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-implement/references/worker-instructions.md`. This sibling file MUST NOT fork that contract. If a behavior is missing from this file, fall back to batch-implement's worker-instructions. If a behavior conflicts with batch-implement's worker-instructions, batch-implement wins. --- diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/SKILL.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/SKILL.md index c5c020c..f1bc196 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/SKILL.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/SKILL.md @@ -2,23 +2,20 @@ name: arn-code-batch-cve-scan description: >- This skill should be used when the user says "scan for CVEs", "CVE scan", - "check for vulnerabilities", "find vulnerabilities", "check security advisories", - "dependabot triage", "dependabot scan", "scan dependencies for security issues", - "audit dependencies", "vulnerability triage", "security scan", "run security audit", - "arness CVE scan", "arn-code-batch-cve-scan", "run a scheduled CVE scan", - "produce a CVE proposal", "finalize a CVE proposal", or wants Arness to discover, - triage, and ticket security advisories across project dependencies. Supports - three modes (interactive, proposal, finalize) so the workflow is safe to schedule - unattended via Claude Code Routines and tool-agnostic enough to drive headlessly - via claude -p or any LLM-running CLI. Dual-source discovery (GitHub Dependabot - plus locally-detected scanners), per-CVE triage via arn-code-cve-analyst, - project-native waiver capture, and pre-triage parent plus per-group sub-issue - ticketing on GitHub or Jira. Reads from the configured Security branch. + "check for vulnerabilities", "dependabot triage", "audit dependencies", + "security scan", "arness CVE scan", "arn-code-batch-cve-scan", + "run a scheduled CVE scan", "finalize a CVE proposal", or wants Arness to + discover, triage, and ticket security advisories across project dependencies + (GitHub Dependabot plus locally-detected scanners). Three modes: interactive, + proposal (unattended, safe for Routines or claude -p), and finalize (review a + proposal and file tickets on GitHub or Jira). +version: 1.0.0 +argument-hint: "[--mode=interactive|proposal|finalize] [--proposal-path=]" --- # Arness Batch CVE Scan -Discover, triage, and ticket security advisories across project dependencies. Dual-source CVE discovery (GitHub Dependabot + locally-detected scanners), per-CVE triage via the `arn-code-cve-analyst` agent, project-existing waiver capture, and pre-triage parent + per-group sub-issue ticketing. All scanner / waiver / tracker detection is **evidence-based** — this skill never enumerates tool names; everything delegates to `/security-scanning.md` (written by Phase 1's codebase-analyzer extension). +Discover, triage, and ticket security advisories across project dependencies. Dual-source CVE discovery (GitHub Dependabot + locally-detected scanners), per-CVE triage via the `arn-code-cve-analyst` agent, project-existing waiver capture, and pre-triage parent + per-group sub-issue ticketing. All scanner / waiver / tracker detection is **evidence-based** — this skill never enumerates tool names; everything delegates to `/security-scanning.md` (written by the `arn-code-codebase-analyzer` agent). **Three modes** (`--mode=`): @@ -63,7 +60,7 @@ After ensure-config completes, extract from `## Arness`: - **Plans directory** — base path for proposal-artifact and no-tracker-fallback outputs. - **Platform** — `github | jira | none`. Used for visibility detection. -If `Security scanning:` or `Security branch:` is missing, Layer 2c will have prompted the user via `AskUserQuestion` and written the chosen value (see Phase 5 wiring). This skill consumes the field — it does not write it. +If `Security scanning:` or `Security branch:` is missing, Layer 2c will have prompted the user via `AskUserQuestion` and written the chosen value. This skill consumes the field — it does not write it. If `/security-scanning.md` is missing, inform the user: "Security scanning is enabled but `security-scanning.md` was not found. Re-run `arn-code-ensure-config` or invoke `arn-code-codebase-analyzer` directly to generate it." STOP. @@ -135,7 +132,7 @@ Skip in `finalize` mode. ## Step 7: Triage Dispatch -Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-scan/references/triage-dispatch.md` and follow its dispatch procedure. For each CVE, dispatch the `arn-code-cve-analyst` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). +Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-scan/references/triage-dispatch.md` and follow its dispatch procedure. For each CVE, dispatch the `arn-code-cve-analyst` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Mode-aware graceful degradation: if the LLM runner does not support subagent dispatch (opencode, some `claude -p` configurations), fall back to inline reasoning in the main loop. This preserves tool-agnosticism. @@ -171,7 +168,7 @@ Then read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-scan/references/waive Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-cve-scan/references/proposal-artifact.md` and follow its rendering procedure. Render the fully-formed ticket bodies, waiver `needs-review` entries, and visibility decisions into the proposal artifact's Markdown surface AND JSON sidecar. -Per the canonical contract in `modes.md`: this mode emits ZERO `AskUserQuestion` invocations and ZERO writes to GitHub / Jira / project waiver files. Waiver actions are ALWAYS `noop` in proposal mode (per spec FR §24; documented in `references/waivers.md`). +Per the canonical contract in `modes.md`: this mode emits ZERO `AskUserQuestion` invocations and ZERO writes to GitHub / Jira / project waiver files. Waiver actions are ALWAYS `noop` in proposal mode (documented in `references/waivers.md`). Also write `CVE_RESOLUTION_PLAN.md` per `references/no-tracker-fallback.md` IF `Issue tracker: none` — it lives alongside the proposal artifact in the same per-scan dated directory. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/discovery.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/discovery.md index e75203f..c84fe29 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/discovery.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/discovery.md @@ -4,7 +4,7 @@ This file documents the dual-source discovery procedure: GitHub Dependabot alert **Mode-aware:** identical behavior in `interactive` and `proposal`. Skipped in `finalize`. -**Evidence-based detection (Pattern 8):** this file NEVER enumerates specific scanner names. All scanner detection delegates to `/security-scanning.md` (written by `arn-code-codebase-analyzer`'s Phase 1 extension). When this file references "each detected scanner", the actual list comes from that file. +**Evidence-based detection:** this file NEVER enumerates specific scanner names. All scanner detection delegates to `/security-scanning.md` (written by `arn-code-codebase-analyzer`). When this file references "each detected scanner", the actual list comes from that file. --- @@ -95,7 +95,7 @@ git show ":" > .arness/.cve-scan-tmp/:` into it. -The temp directory `.arness/.cve-scan-tmp/` is the project-local scratch space per Pattern 3 (no `/tmp/`). Clean up after the scan completes successfully. +The temp directory `.arness/.cve-scan-tmp/` is the project-local scratch space (no `/tmp/`). Clean up after the scan completes successfully. Capture each scanner's raw JSON output. Compute the SHA-256 checksum: @@ -103,7 +103,7 @@ Capture each scanner's raw JSON output. Compute the SHA-256 checksum: checksum=$(printf '%s' "$raw_output" | (sha256sum 2>/dev/null || shasum -a 256) | awk '{print $1}') ``` -The `sha256sum || shasum -a 256` fallback handles macOS (which ships `shasum` not `sha256sum`) per Pattern 3. +The `sha256sum || shasum -a 256` fallback handles macOS (which ships `shasum` not `sha256sum`). Map each scanner finding into the same normalized record shape as Source A, with `source: ""` and `rawScannerOutput` carrying the full JSON object plus checksum. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/finalize.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/finalize.md index f55da4a..3339d34 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/finalize.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/finalize.md @@ -15,7 +15,7 @@ Two sources, in priority order: 1. **`--proposal-path=<...>`** explicitly supplied on the command line. Use this path verbatim. If the file does not exist, fail with: `"Proposal not found at . Drop --proposal-path to use the most recent."` and exit non-zero. 2. **Auto-discover most recent** under `/CVE_*/CVE_SCAN_PROPOSAL.json`. Sort directory names lexicographically (the `CVE_` format is sort-stable) and pick the last entry. If no proposal exists at all, fail with: `"No CVE_SCAN_PROPOSAL.json found under /CVE_*/. Run --mode=proposal first."` and exit non-zero. -Read the JSON sidecar. Validate `schemaVersion` matches a supported value (`1.0.0` for this Phase 3 release; future schema bumps must be additive or include a migration step here). +Read the JSON sidecar. Validate `schemaVersion` matches a supported value (`1.0.0` for this release; future schema bumps must be additive or include a migration step here). --- @@ -140,5 +140,5 @@ If any writes failed: - This entire file is reachable ONLY in `finalize` mode (per `modes.md`). Every `AskUserQuestion` invocation above is therefore mode-gated by the outer `if mode == "finalize"` shell in `SKILL.md` Step 9c. - The skill does NOT re-render ticket bodies in finalize. The one bounded exception is `full-details-requested` (Step 4), where the human explicitly approved a body substitution. -- Atomic writes use `.tmp + mv` in the same directory as the target — never `/tmp/` (per Pattern 3). +- Atomic writes use `.tmp + mv` in the same directory as the target — never `/tmp/`. - All paths in instructions use `` and `` as placeholders resolved from `## Arness` config. No user-specific paths. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/modes.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/modes.md index fac2739..7fb9b6d 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/modes.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/modes.md @@ -43,7 +43,7 @@ The skill accepts a small, ordered set of arguments. Parsing order matters: `--m 1. **ZERO `AskUserQuestion` reachability.** There is no user to answer. If any code path reachable in `proposal` mode invokes `AskUserQuestion`, that path is a bug. Every reference file mode-aware section MUST gate `AskUserQuestion` behind an explicit `if mode in {"interactive", "finalize"}` (or equivalent prose check). 2. **ZERO writes to GitHub / Jira / project waiver files.** No `gh issue create`, no `gh issue comment`, no Atlassian MCP write call, no modification of `.trivyignore` / `.snyk` / `package.json` `overrides` / `Gemfile` pins / etc. Reads ARE allowed (discovery is read-only). 3. **Defaults resolve from `## Arness` config + `security-scanning.md` + documented fallbacks.** Whenever a decision would have been a prompt in `interactive` mode, document the fallback in the relevant reference file and apply it silently here. Every applied fallback MUST be recorded in the proposal artifact's per-decision provenance section (see `proposal-artifact.md`) so the human reviewer can audit which defaults fired and where they came from. -4. **Emits the proposal artifact + stable stdout completion line.** Writes `CVE_SCAN_PROPOSAL.md` and `CVE_SCAN_PROPOSAL.json` (atomic `.tmp + mv` per Pattern 3) to `.arness/plans/CVE_/`. After both files flush, emits exactly one stdout line: +4. **Emits the proposal artifact + stable stdout completion line.** Writes `CVE_SCAN_PROPOSAL.md` and `CVE_SCAN_PROPOSAL.json` (atomic `.tmp + mv`) to `.arness/plans/CVE_/`. After both files flush, emits exactly one stdout line: ``` arness::cve-scan::proposal-ready path= @@ -75,18 +75,18 @@ The skill accepts a small, ordered set of arguments. Parsing order matters: `--m This skill must drive cleanly under Claude Code, opencode, Aider, or any LLM-running CLI that supports read/edit/bash. Two design choices preserve this: -1. **Subagent dispatch via the Task tool degrades gracefully to inline reasoning** when the runner doesn't support subagents (see `triage-dispatch.md`'s graceful-degradation section). The triage step still produces a structured record either way — only the dispatch mechanism changes. +1. **Subagent dispatch via the Agent tool degrades gracefully to inline reasoning** when the runner doesn't support subagents (see `triage-dispatch.md`'s graceful-degradation section). The triage step still produces a structured record either way — only the dispatch mechanism changes. 2. **The proposal artifact is plain Markdown + plain JSON.** It carries no tool-specific identifiers, no SDK handles, no transient state. Any LLM-running CLI can read it in `finalize` mode and apply the same pre-rendered POST calls via whatever shell or HTTP primitives it has. The three-mode split is what makes the tool-agnosticism actually safe: schedulers always invoke `proposal` mode (zero writes), and humans always invoke `finalize` mode (consent-gated writes). A misconfigured runner that drops subagent dispatch or quirks `AskUserQuestion` still cannot produce silent writes in `proposal` mode because the writes are structurally absent from that code path. --- -## Verification Invariants for Phase 6 +## Verification Invariants -These invariants are what Phase 6's cross-cutting grep pass will check against this skill. If you change a mode-aware behavior in any reference, ensure these still hold: +These invariants must hold across every reference of this skill. If you change a mode-aware behavior in any reference, ensure these still hold: -- Every `AskUserQuestion` reference under `references/` is inside a paragraph or section that explicitly names `interactive` or `finalize` mode as the gate. (Phase 6 grep: `grep -B 5 "AskUserQuestion" references/*.md` — every match must show a mode gate in the leading context.) -- Every dispatch of `arn-code-cve-analyst` includes the phrase "via the Task tool" with the `.arness/agent-models/code.md` lookup (Pattern 4). (Phase 6 grep: `grep -rn "via the Task tool" .` — must hit at every dispatch site.) -- No reference file enumerates specific scanner / waiver / tracker tool names in detection logic — all detection delegates to `/security-scanning.md` (Pattern 8). +- Every `AskUserQuestion` reference under `references/` is inside a paragraph or section that explicitly names `interactive` or `finalize` mode as the gate. (A `grep -B 5 "AskUserQuestion" references/*.md` check should show a mode gate in the leading context of every match.) +- Every dispatch of `arn-code-cve-analyst` includes the phrase "via the Agent tool" with the `.arness/agent-models/code.md` lookup, per the "Dispatch convention" in `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md`. +- No reference file enumerates specific scanner / waiver / tracker tool names in detection logic — all detection delegates to `/security-scanning.md`. - No reference file embeds user-specific paths (`/home/...`, `~`). All paths use `${CLAUDE_PLUGIN_ROOT}`, repo-relative, or generic placeholders like `/path/to/arness`. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/no-tracker-fallback.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/no-tracker-fallback.md index 5c8ed17..658085e 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/no-tracker-fallback.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/no-tracker-fallback.md @@ -37,7 +37,7 @@ Per-scan dated directory under the configured Plans directory: The `` format matches `proposal-artifact.md`'s convention: `YYYYMMDDTHHMMSSZ` (e.g., `CVE_20260605T143022Z/`). Sort-stable lexicographically, filesystem-safe across platforms, UTC to avoid timezone collisions. -**OPEN-ITEM-5 decision:** per-scan dated directory under `/CVE_/`. Rationale: this matches the proposal artifact location (FR §21) so all per-scan outputs are colocated. A user who opens `/CVE_20260605T143022Z/` gets the full picture of that scan — the resolution plan, plus the proposal artifact if proposal mode was used. Archive, audit, and ship workflows treat the directory as one unit. +**Decision:** per-scan dated directory under `/CVE_/`. Rationale: this matches the proposal artifact location so all per-scan outputs are colocated. A user who opens `/CVE_20260605T143022Z/` gets the full picture of that scan — the resolution plan, plus the proposal artifact if proposal mode was used. Archive, audit, and ship workflows treat the directory as one unit. The alternative (a single `/CVE_RESOLUTION_PLAN.md` overwritten on each scan) was rejected because it destroys the audit trail and forces git to be the only record of prior scans. The per-scan dated dir is more storage but vastly more recoverable. @@ -45,7 +45,7 @@ The alternative (a single `/CVE_RESOLUTION_PLAN.md` overwritten on ea ## Step 3: Atomic Write Protocol -Same as `proposal-artifact.md`: write to `CVE_RESOLUTION_PLAN.md.tmp` in the same directory, then `mv` to the final name. Never write to `/tmp/` (per Pattern 3). +Same as `proposal-artifact.md`: write to `CVE_RESOLUTION_PLAN.md.tmp` in the same directory, then `mv` to the final name. Never write to `/tmp/`. In `proposal` mode, the resolution plan is written BEFORE the `arness::cve-scan::proposal-ready` stdout line is emitted (so a scheduler that chains on the stdout line is guaranteed both files exist when it acts). @@ -130,8 +130,8 @@ ALWAYS use this exact section order so downstream consumers (`arn-code-batch-cve (Branch on mode:) -- **interactive**: "Run `/arn-code-batch-cve-fix --resolution-plan=` to begin fixing. Workers will pick groups in order and create per-group branches." -- **proposal**: "Review this file alongside `CVE_SCAN_PROPOSAL.md` (sibling file). Run `/arn-code-batch-cve-scan --mode=finalize --proposal-path=` to apply any deferred decisions (waiver renewals, full-details substitutions). Then run `/arn-code-batch-cve-fix --resolution-plan=` to begin fixing." +- **interactive**: "Run `/arn-code-batch-cve-fix --proposal-path=` to begin fixing. Workers will pick groups in order and create per-group branches." +- **proposal**: "Review this file alongside `CVE_SCAN_PROPOSAL.md` (sibling file). Run `/arn-code-batch-cve-scan --mode=finalize --proposal-path=` to apply any deferred decisions (waiver renewals, full-details substitutions). Then run `/arn-code-batch-cve-fix --proposal-path=` to begin fixing." - **finalize amendment**: append a new section `## Finalize Applied — ` listing the resolved `needsReview` decisions; preserve all proposal-time content above. ``` @@ -184,4 +184,4 @@ The dedupe does NOT suppress writing new entries — every scan produces a compl - Every `AskUserQuestion` reference reachable through this file is reachable ONLY in `interactive` or `finalize` mode. The `proposal` mode branch contains zero `AskUserQuestion` invocations (waiver collection in proposal mode is `noop` per `waivers.md`). - The artifact is plain Markdown. It carries no tool-specific identifiers or transient state — any LLM-running CLI can read it. - All paths are placeholders (``, ``, etc.) or repo-relative (`.arness/...`, `./...`). No user-specific paths. -- The per-scan dated directory convention matches `proposal-artifact.md` (OPEN-ITEM-5) so all per-scan artifacts are colocated for archive and audit. +- The per-scan dated directory convention matches `proposal-artifact.md` so all per-scan artifacts are colocated for archive and audit. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/parser.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/parser.md index c06ab3a..0876baf 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/parser.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/parser.md @@ -1,10 +1,10 @@ # Deterministic Scanner-Output Parser -This file documents the deterministic semver-aware parsing of scanner JSON output. Per spec FR §3, version-bound fields are parsed deterministically — the `arn-code-cve-analyst` agent NEVER re-parses or re-derives them. This boundary exists because LLMs are unreliable at semver range arithmetic (off-by-one on inclusive/exclusive bounds, misreading caret vs tilde, mishandling pre-release identifiers), and version-bound errors cascade into wrong fix recommendations. +This file documents the deterministic semver-aware parsing of scanner JSON output. Version-bound fields are parsed deterministically — the `arn-code-cve-analyst` agent NEVER re-parses or re-derives them. This boundary exists because LLMs are unreliable at semver range arithmetic (off-by-one on inclusive/exclusive bounds, misreading caret vs tilde, mishandling pre-release identifiers), and version-bound errors cascade into wrong fix recommendations. **Mode-aware:** identical behavior in all three modes. -**Evidence-based (Pattern 8):** the parser routes to per-scanner schema handling based on the scanner identifier in `/security-scanning.md`. This file never enumerates specific scanner names — the routing table is sourced from `security-scanning.md`'s "Detected scanners" section. +**Evidence-based:** the parser routes to per-scanner schema handling based on the scanner identifier in `/security-scanning.md`. This file never enumerates specific scanner names — the routing table is sourced from `security-scanning.md`'s "Detected scanners" section. --- diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/proposal-artifact.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/proposal-artifact.md index 1f48134..10e628c 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/proposal-artifact.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/proposal-artifact.md @@ -1,6 +1,6 @@ # Proposal Artifact Schema -This file defines the artifact emitted by `proposal` mode: a Markdown human-review surface paired with a JSON sidecar consumed by `finalize` mode. The schema is explicit (not prose) because `finalize` parses it field-by-field, and because Phase 6's verification grep validates structure. +This file defines the artifact emitted by `proposal` mode: a Markdown human-review surface paired with a JSON sidecar consumed by `finalize` mode. The schema is explicit (not prose) because `finalize` parses it field-by-field. **Mode-aware:** this artifact is written ONLY in `proposal` mode. `interactive` mode does not produce it (writes happen inline). `finalize` mode reads it but never writes a new one — it amends the existing JSON sidecar with response data per `finalize.md`. @@ -24,13 +24,13 @@ Per-scan dated directory under the configured Plans directory: The directory is per-scan (not shared) because each scan represents an immutable point-in-time view of the configured `Security branch:` HEAD plus scanner DB snapshots. Sharing a directory across scans would conflate the audit trail. -**OPEN-ITEM-5 decision:** per-scan dated directory under `/CVE_/`. This is consistent with the no-tracker-fallback location (`CVE_RESOLUTION_PLAN.md` lives in the same directory when `Issue tracker: none`), keeping all per-scan artifacts colocated for archive and audit. +**Decision:** per-scan dated directory under `/CVE_/`. This is consistent with the no-tracker-fallback location (`CVE_RESOLUTION_PLAN.md` lives in the same directory when `Issue tracker: none`), keeping all per-scan artifacts colocated for archive and audit. --- ## Atomic Write Protocol -Both files are written atomically per Pattern 3 (Cross-Platform Shell): +Both files are written atomically (cross-platform `.tmp + mv`): 1. Write content to `CVE_SCAN_PROPOSAL.md.tmp` (or `.json.tmp`) in the same directory. 2. Rename via `mv CVE_SCAN_PROPOSAL.md.tmp CVE_SCAN_PROPOSAL.md`. @@ -122,7 +122,7 @@ The JSON is the contract `finalize` mode consumes. Every field is required unles { "advisoryId": "...", "action": "noop", - "reason": "", + "reason": "", "needsReview": "", "needsReviewDetail": "" } @@ -161,7 +161,7 @@ The JSON is the contract `finalize` mode consumes. Every field is required unles - `groupId` is deterministic from the sorted advisory-id list of the group's members (e.g., SHA-256 prefix of the joined sorted list). Determinism matters so re-runs produce stable IDs and `finalize`'s idempotency check works. - `renderedTitle` and `renderedBody` are the EXACT strings `finalize` will POST. `finalize` does not re-render — the human reviewed these strings. -- `proposedWaiverActions[].action` is ALWAYS `"noop"` in proposal mode. This is the structural enforcement of FR §24 (waiver default in proposal mode: skip). +- `proposedWaiverActions[].action` is ALWAYS `"noop"` in proposal mode. This is the structural enforcement of the proposal-mode waiver rule (waiver default in proposal mode: skip). - `needsReview` is the canonical list of items `finalize` must walk via `AskUserQuestion`. Any deferred decision goes here. - `decisionProvenance` exists so the human reviewer can audit which `proposal`-mode defaults fired. Every place an `interactive`-mode `AskUserQuestion` would have appeared produces a `decisionProvenance` entry naming the default and its source. - `finalizeState` is initialized to `{"applied": false, "appliedAt": null, "writeResponses": []}` and amended by `finalize` (per `finalize.md`). @@ -228,7 +228,7 @@ The Markdown is for human review. It mirrors the JSON but is organized for scana |---|---|---|---| | ... | noop | | ... | -> Note (FR §24): proposal mode never modifies project waiver files. Stale and near-expiry waivers are listed above as `needs-review` items for finalize. +> Note: proposal mode never modifies project waiver files. Stale and near-expiry waivers are listed above as `needs-review` items for finalize. ## Escalations diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/stale-db.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/stale-db.md index 81e258c..4ed2cc3 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/stale-db.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/stale-db.md @@ -10,7 +10,7 @@ The gate is intentionally STRICT because the failure mode (missing a critical CV - `proposal`: refuses WITHOUT prompting (no user is present). Records `needsReview: stale-db` in the proposal and exits non-zero so the scheduler flags the failure. The `arness::cve-scan::proposal-ready` stdout line is NOT emitted on failure exit. Schedulers configure their notification channel to act on the non-zero exit. - `finalize`: not relevant — finalize works against the proposal's frozen scanner output, which already passed (or failed) the gate at proposal time. -**Evidence-based (Pattern 8):** this file does NOT enumerate specific scanner DB freshness mechanisms. Each detected scanner's freshness hint comes from `/security-scanning.md` under its "Advisory-DB freshness hints" section. +**Evidence-based:** this file does NOT enumerate specific scanner DB freshness mechanisms. Each detected scanner's freshness hint comes from `/security-scanning.md` under its "Advisory-DB freshness hints" section. --- @@ -86,7 +86,7 @@ NEVER prompt. If any scanner is stale: The non-zero exit + machine-readable stderr line is the contract with the scheduler: the human notification will surface "DB needs updating" rather than a silent under-reporting scan. -**OPEN-ITEM-1 decision:** the default in proposal mode is **BLOCK** (refuse to run on stale DB). Rationale: the unattended context cannot judge whether "stale by 16 days" represents an acceptable risk or a critical gap. Refusing forces the human to make the call before the scheduled scan produces a misleading clean bill of health. The configurable downgrade is `--allow-stale-db` (interactive only by design — a downgrade override in unattended mode would defeat the safety purpose of the default). +**Decision:** the default in proposal mode is **BLOCK** (refuse to run on stale DB). Rationale: the unattended context cannot judge whether "stale by 16 days" represents an acceptable risk or a critical gap. Refusing forces the human to make the call before the scheduled scan produces a misleading clean bill of health. The configurable downgrade is `--allow-stale-db` (interactive only by design — a downgrade override in unattended mode would defeat the safety purpose of the default). ### `finalize` mode @@ -120,7 +120,7 @@ The log is append-only (same convention as `waivers.md`'s audit log) and is giti The gitignore entry is added on first write (idempotent — only added if missing): ``` -# arn-code scan-run log (see plugins/arn-code/skills/arn-code-batch-cve-scan/references/stale-db.md) +# arn-code scan-run log (see the arn-code plugin: skills/arn-code-batch-cve-scan/references/stale-db.md) .arness/security/scan-runs.jsonl ``` @@ -147,5 +147,5 @@ In `interactive` mode, the same information is printed to the terminal before th - Every `AskUserQuestion` reference above is reachable ONLY in `interactive` mode. The `proposal` mode subsection explicitly states NEVER prompt and contains zero `AskUserQuestion` invocations. - The 14-day threshold is fixed for v1 — there is no `--stale-db-threshold-days` flag. A future enhancement may add a `Stale-DB threshold:` field to `## Arness` if real-world usage shows projects need different thresholds; for v1 the threshold is calibrated against typical DB update cadences and the override is `--allow-stale-db` with justification. -- This file delegates ALL scanner-specific freshness extraction to `/security-scanning.md` (Pattern 8). No scanner names are enumerated here. +- This file delegates ALL scanner-specific freshness extraction to `/security-scanning.md`. No scanner names are enumerated here. - All paths are repo-relative (`.arness/security/...`). No user-specific paths. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/ticketing.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/ticketing.md index 4dd7d11..e09ec75 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/ticketing.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/ticketing.md @@ -36,7 +36,7 @@ Build the parent title and body: - **Title:** `[arness-security] CVE scan against @ — findings` - **Body:** lists every discovered CVE (advisory-id, ecosystem, package, installed-version, severity, source) in a markdown table. Adds a "Triage in progress" status line. Adds a footer noting the scanner versions and DB timestamps. -Apply the `arness-security` label (the new 8th platform label added in Phase 5). +Apply the `arness-security` label (the 8th Arness platform label). - **github**: `gh issue create --title "" --body "<body>" --label arness-security` - **jira**: Atlassian MCP `createIssue` with the project's CVE issue type (Story or equivalent — read from `## Arness` if configured, else default to Story), labels include `arness-security`. @@ -61,7 +61,7 @@ After triage completes, group CVEs by their `batchGroupingHint`. Apply the group - **Critical-severity** CVEs → always a single-CVE group (`isSingleCveGroup: true, singleCveReason: "critical"`). - **Breaking-change** CVEs (`breakingChangeRisk == "high"`) → always a single-CVE group (`singleCveReason: "breaking-change"`). -- Other CVEs may bundle in groups capped at **8 CVEs per group** (mirrors the PR strategy from FR §11 so each ticket maps cleanly to one fix PR in `arn-code-batch-cve-fix`). +- Other CVEs may bundle in groups capped at **8 CVEs per group** (mirrors the per-group PR strategy so each ticket maps cleanly to one fix PR in `arn-code-batch-cve-fix`). For each group, compute a deterministic `groupId` from the SHA-256 prefix of the sorted advisory-id list (e.g., first 12 hex chars). Determinism matters so re-runs produce stable IDs and the `(advisory-id, status)` idempotency key keeps working across scans. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/triage-dispatch.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/triage-dispatch.md index 542b954..402df82 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/triage-dispatch.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/triage-dispatch.md @@ -2,7 +2,7 @@ This file documents the per-CVE dispatch procedure for the `arn-code-cve-analyst` agent. Triage is the reasoning-heavy step: for each CVE the agent reads the parsed record, greps the codebase for vulnerable symbol references, evaluates breaking-change risk against project pinning conventions, and emits a structured triage record. -**Pattern 4 (Dispatch Convention):** every dispatch site below includes the canonical lookup phrasing. The phrasing is load-bearing for Phase 6's verification grep (`grep -rn "via the Task tool" .` must hit each dispatch site). +**Dispatch convention:** every dispatch site below includes the canonical model-lookup phrasing defined in the "Dispatch convention" section of `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md`. **Mode-aware:** identical dispatch logic across `interactive` and `proposal`. Skipped in `finalize` (triage records are already frozen in the proposal). The output of triage is a structured record; that record's downstream use is mode-aware (inline ticketing vs. proposal rendering) but the dispatch itself is mode-agnostic. @@ -22,11 +22,11 @@ For each parsed CVE record from `parser.md`, assemble the agent's task context: ## Step 2: Dispatch the Agent -For each CVE record, spawn the `arn-code-cve-analyst` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). +For each CVE record, spawn the `arn-code-cve-analyst` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Dispatches MAY be parallelized within reasonable concurrency limits (e.g., spawn up to 5 in a single message and wait for the batch to complete before the next batch). Parallelism cap matches the `arn-code-batch-implement` convention to avoid runaway agent fan-out on large CVE inventories. -For each CVE record, dispatch one `arn-code-cve-analyst` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). The Task tool input contains: +For each CVE record, dispatch one `arn-code-cve-analyst` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). The Agent tool input contains: - The full per-CVE input from Step 1. - An explicit reminder of the deterministic-parser boundary: "The version-bound fields (installedVersion, fixedVersion, vulnerableRange) are deterministic — do NOT re-parse them. Use them as given." @@ -36,7 +36,7 @@ For each CVE record, dispatch one `arn-code-cve-analyst` agent via the Task tool ## Step 3: Collect Triage Records -The agent returns one structured triage record per CVE, conforming to FR §4: +The agent returns one structured triage record per CVE, conforming to this schema: ```json { @@ -54,19 +54,19 @@ The agent returns one structured triage record per CVE, conforming to FR §4: Validate each returned record: - `scannerOutputChecksumEcho` MUST match the input checksum. If it does not, the agent's record is invalid — requeue the CVE for re-dispatch (up to 2 retries). After 3 total attempts, mark the CVE as `escalate` with `rationale: "Triage agent failed to echo scanner output checksum after 3 attempts — record may not reflect actual scanner data."` and surface the issue. -- `reachabilityVerdict == "safe"` MUST NEVER appear in a record. v1 reachability is narrowing-only per spec FR §5; the valid no-match verdict is `low-confidence-unreachable`. If `"safe"` is returned, treat the record as invalid (same retry-then-escalate path as checksum mismatch). +- `reachabilityVerdict == "safe"` MUST NEVER appear in a record. v1 reachability is narrowing-only; the valid no-match verdict is `low-confidence-unreachable`. If `"safe"` is returned, treat the record as invalid (same retry-then-escalate path as checksum mismatch). --- ## Step 4: Graceful Degradation for Tool-Agnostic Runners -The LLM runner may not support subagent dispatch via the Task tool. opencode, some `claude -p` configurations, and bring-your-own-CLI setups can lack this capability. When subagent dispatch is unavailable, fall back to inline reasoning in the main loop: +The LLM runner may not support subagent dispatch via the Agent tool. opencode, some `claude -p` configurations, and bring-your-own-CLI setups can lack this capability. When subagent dispatch is unavailable, fall back to inline reasoning in the main loop: -1. Read the `arn-code-cve-analyst` agent file (`plugins/arn-code/agents/arn-code-cve-analyst.md`) directly. +1. Read the `arn-code-cve-analyst` agent file (`${CLAUDE_PLUGIN_ROOT}/agents/arn-code-cve-analyst.md`) directly. 2. For each CVE, follow the agent's documented procedure inline — read the same inputs, perform the same grep, produce the same structured record shape. 3. The output schema is identical; only the dispatch mechanism changes. Downstream consumers (`ticketing.md`, `proposal-artifact.md`, `finalize.md`) cannot tell the difference. -Detection of subagent availability is implicit: if the Task tool is not present in the runner's tool catalog, the dispatch site falls through to inline reasoning. This preserves tool-agnosticism without requiring runtime probing. +Detection of subagent availability is implicit: if the Agent tool is not present in the runner's tool catalog, the dispatch site falls through to inline reasoning. This preserves tool-agnosticism without requiring runtime probing. **Mode-aware note:** this graceful degradation applies in `interactive` AND `proposal` modes. The fallback path does NOT introduce any `AskUserQuestion` calls (the agent file's procedure is a pure read+reason loop) so `proposal` mode's hard rule (zero `AskUserQuestion`) is preserved. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/visibility.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/visibility.md index 16968f9..8c7b73a 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/visibility.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/visibility.md @@ -10,7 +10,7 @@ The rationale is straightforward: a CVE ticket on a public GitHub repo or an org - `proposal`: `--include-full-details` is **HARD-REJECTED** by `modes.md` CLI parsing (no user is present to consent). The default is REDACTED. If any CVE's advisory body indicates the triage agent needs the full PoC context for accurate reasoning, the proposal records a `needsReview` entry with `kind: "full-details-requested"` so finalize can re-prompt the human. - `finalize`: walks `needsReview` entries with `kind: "full-details-requested"` via `AskUserQuestion` (allowed in this mode); on approval, the rendered ticket body is amended with the full details BEFORE the single consent gate in `finalize.md` Step 5. This is the one bounded exception to "finalize does not re-render". -**Evidence-based (Pattern 8):** this file does NOT enumerate specific tracker product names beyond the supported platforms (github, jira — already named by `Issue tracker:`). Visibility detection delegates to the platform's own visibility API. +**Evidence-based:** this file does NOT enumerate specific tracker product names beyond the supported platforms (github, jira — already named by `Issue tracker:`). Visibility detection delegates to the platform's own visibility API. --- @@ -164,6 +164,6 @@ These let the human reviewer verify both the redaction default and the detected ## Cross-Cutting Reminders - Every `AskUserQuestion` reference above is reachable ONLY in `interactive` or `finalize` mode. The `proposal` mode subsection explicitly hard-rejects `--include-full-details` at CLI parsing and contains zero `AskUserQuestion` invocations. -- Visibility detection delegates to the platform's API (`gh repo view`, Atlassian MCP). This file does NOT enumerate tracker product names beyond the supported set (Pattern 8 — `Issue tracker:` enum is the source of truth). +- Visibility detection delegates to the platform's API (`gh repo view`, Atlassian MCP). This file does NOT enumerate tracker product names beyond the supported set (the `Issue tracker:` enum is the source of truth). - The default-redacted policy is intentional even on private trackers — defense in depth against compromised credentials and against future visibility changes (a private repo that gets open-sourced should not retroactively leak PoC text). - All paths in instructions use placeholders. No user-specific paths. diff --git a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/waivers.md b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/waivers.md index a4ce2a5..382f90f 100644 --- a/plugins/arn-code/skills/arn-code-batch-cve-scan/references/waivers.md +++ b/plugins/arn-code/skills/arn-code-batch-cve-scan/references/waivers.md @@ -7,10 +7,10 @@ Waivers carry real risk: an accepted vulnerability that should have been fixed b **Mode-aware (CRITICAL):** - `interactive`: prompts the user via `AskUserQuestion` (allowed in this mode) before writing any waiver. Writes the waiver in the project's existing format. Appends to the audit log. -- `proposal`: **NEVER writes to project waiver files** (FR §24 hard rule). Stale and near-expiry waivers are recorded as `needsReview` entries in the proposal with `kind: "waiver-expired"` or `kind: "waiver-near-expiry"`. The proposal's `proposedWaiverActions[].action` is ALWAYS `"noop"` in this mode. +- `proposal`: **NEVER writes to project waiver files** (hard rule). Stale and near-expiry waivers are recorded as `needsReview` entries in the proposal with `kind: "waiver-expired"` or `kind: "waiver-near-expiry"`. The proposal's `proposedWaiverActions[].action` is ALWAYS `"noop"` in this mode. - `finalize`: walks `needsReview` waiver items via `AskUserQuestion` (allowed in this mode), applies confirmed waiver writes only behind the single consent gate in `finalize.md` Step 5. -**Evidence-based (Pattern 8):** this file NEVER enumerates waiver file names or scanner-specific waiver formats. Project-specific waiver formats live in `<code-patterns-dir>/security-scanning.md` under its "Detected waiver mechanisms" section. Common waiver categories (ignore files, manifest override blocks, lockfile pins, etc.) are recognized by evidence — never by hardcoded match lists. +**Evidence-based:** this file NEVER enumerates waiver file names or scanner-specific waiver formats. Project-specific waiver formats live in `<code-patterns-dir>/security-scanning.md` under its "Detected waiver mechanisms" section. Common waiver categories (ignore files, manifest override blocks, lockfile pins, etc.) are recognized by evidence — never by hardcoded match lists. --- @@ -57,7 +57,7 @@ Every waiver — regardless of write target (project-native format or sidecar) If any field fails its rule, the waiver write is REFUSED: - **`interactive`**: surface the failing field via `AskUserQuestion` (allowed in this mode) and offer "Edit the field", "Skip this waiver", or "Abort". Loop until the gate passes or the user skips/aborts. -- **`proposal`**: this case does not arise — proposal mode does not write waivers (FR §24). Instead, hygiene-failing PROPOSED waivers (e.g., from a stale existing waiver being re-evaluated) are recorded as `needsReview` with `kind: "waiver-expired"` or `kind: "waiver-near-expiry"` plus `detail` naming the failing field. +- **`proposal`**: this case does not arise — proposal mode does not write waivers. Instead, hygiene-failing PROPOSED waivers (e.g., from a stale existing waiver being re-evaluated) are recorded as `needsReview` with `kind: "waiver-expired"` or `kind: "waiver-near-expiry"` plus `detail` naming the failing field. - **`finalize`**: same as `interactive` — re-prompt the user during the `needsReview` walk (per `finalize.md` Step 4). The gate is intentionally strict because it is the only structural safeguard against waivers becoming permanent invisible deferrals. @@ -82,7 +82,7 @@ On "Yes, grant waiver", collect the hygiene-gate fields via additional `AskUserQ ### `proposal` mode -NEVER prompt. NEVER write to project waiver files. The hard rule from FR §24: +NEVER prompt. NEVER write to project waiver files. The hard rule: > Proposal mode never modifies project waiver files. Period. @@ -92,7 +92,7 @@ For each CVE the triage agent recommends `fixStrategy: "waiver"`, append to the { "advisoryId": "...", "action": "noop", - "reason": "proposal mode never modifies project waiver files; see FR §24", + "reason": "proposal mode never modifies project waiver files", "needsReview": null, "needsReviewDetail": null } @@ -158,12 +158,12 @@ Append-only semantics: - Use `>>` not `>` for the shell append. - The file is created on first write with a leading comment line `# arn-code waiver audit log — append-only` (the comment is a valid JSONL non-record per the convention that lines starting with `#` are ignored by readers; the file is still valid for line-by-line JSON parsing as long as readers filter `#` lines). -**OPEN-ITEM-2 decision:** `waiver-audit.jsonl` is **gitignored by default**. Rationale: the log can carry justifications that include sensitive context (internal customer names, security-incident references, vendor disclosure details) — defaulting to gitignored prevents accidental public exposure on open-source projects. Projects that want the audit committed (for compliance reasons, internal repos, etc.) can opt in by removing the gitignore entry and documenting the choice. A future enhancement may add an `Audit log visibility:` field to `## Arness` to make this an explicit, persisted choice; for v1 the default is gitignored and the opt-in is manual. +**Decision:** `waiver-audit.jsonl` is **gitignored by default**. Rationale: the log can carry justifications that include sensitive context (internal customer names, security-incident references, vendor disclosure details) — defaulting to gitignored prevents accidental public exposure on open-source projects. Projects that want the audit committed (for compliance reasons, internal repos, etc.) can opt in by removing the gitignore entry and documenting the choice. A future enhancement may add an `Audit log visibility:` field to `## Arness` to make this an explicit, persisted choice; for v1 the default is gitignored and the opt-in is manual. The gitignore entry is added on first waiver write (idempotent — only added if missing): ``` -# arn-code waiver audit log (see plugins/arn-code/skills/arn-code-batch-cve-scan/references/waivers.md) +# arn-code waiver audit log (see the arn-code plugin: skills/arn-code-batch-cve-scan/references/waivers.md) .arness/security/waiver-audit.jsonl ``` @@ -187,6 +187,6 @@ This intercept-at-ticketing design means waiver state never affects the scanner- ## Cross-Cutting Reminders - Every `AskUserQuestion` reference above is reachable ONLY in `interactive` or `finalize` mode. The `proposal` mode subsection (Step 3) explicitly states NEVER prompt and contains zero `AskUserQuestion` invocations. -- This file NEVER enumerates specific waiver file names or scanner-specific waiver syntaxes. All project-specific detail comes from `<code-patterns-dir>/security-scanning.md` (Pattern 8). +- This file NEVER enumerates specific waiver file names or scanner-specific waiver syntaxes. All project-specific detail comes from `<code-patterns-dir>/security-scanning.md`. - All paths are placeholders (`<advisoryId>`, `<package>`, etc.) or repo-relative (`.arness/security/...`). No user-specific paths. - The 90-day expiry cap is hard — there is no override flag. A user who needs a longer waiver must renew explicitly every 90 days (which is the whole point of the cap). diff --git a/plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md b/plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md index cd2a95a..45c2989 100644 --- a/plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md +++ b/plugins/arn-code/skills/arn-code-batch-implement/references/worker-instructions.md @@ -71,9 +71,9 @@ Follow the same executor → reviewer → fix cycle as `arn-code-execute-plan`'s a. **Spawn executor**: First **determine the executor model**: - Read PROGRESS_TRACKER.json. Find the phase entry whose `implementation.taskId` matches the current task ID. - If `phase.implementation.modelOverride` is non-null (e.g., `"opus"`), use that value as the `model` parameter for this dispatch. Skip the standard agent-models lookup. Emit a one-line status: `Phase <N> (<phaseTitle>) executor model: <override> (upgraded — complex phase per pipeline.complex-phase-upgrade)`. - - If `phase.implementation.modelOverride` is null or the field is missing, fall through to the standard lookup: pass the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). + - If `phase.implementation.modelOverride` is null or the field is missing, fall through to the standard lookup: pass the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). - Then spawn a `arn-code-task-executor` agent via the Task tool with the determined model. Context: + Then spawn a `arn-code-task-executor` agent via the Agent tool with the determined model. Context: - The task ID and full task description (from TASKS.md) - Project folder path: {plan_path} - Phase plan file path (extracted from the task description) @@ -83,7 +83,7 @@ Follow the same executor → reviewer → fix cycle as `arn-code-execute-plan`'s - Sketch context (manifest path and directory, if applicable) - Instructions: implement the task according to the phase plan, run ONLY targeted tests (precise targeting, never full suite), generate IMPLEMENTATION_REPORT and/or TESTING_REPORT - b. **Spawn reviewer**: After executor completes, spawn a `arn-code-task-reviewer` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: + b. **Spawn reviewer**: After executor completes, spawn a `arn-code-task-reviewer` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The task ID and description - Implementation/testing report paths from the executor - List of files created/modified by the executor diff --git a/plugins/arn-code/skills/arn-code-batch-merge/SKILL.md b/plugins/arn-code/skills/arn-code-batch-merge/SKILL.md index 1759c3f..fb057b4 100644 --- a/plugins/arn-code/skills/arn-code-batch-merge/SKILL.md +++ b/plugins/arn-code/skills/arn-code-batch-merge/SKILL.md @@ -80,7 +80,7 @@ Collect the final list: PR number, URL, feature name, CHANGE_RECORD path, platfo ## Step 2: Cross-PR Analysis (Delegated) -Spawn the `arn-code-batch-pr-analyzer` agent via the Task tool in **foreground** (the results are needed before proceeding), passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). +Spawn the `arn-code-batch-pr-analyzer` agent via the Agent tool in **foreground** (the results are needed before proceeding), passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Pass to the agent: - PR list (number, URL, feature name, CHANGE_RECORD path) diff --git a/plugins/arn-code/skills/arn-code-batch-planning/SKILL.md b/plugins/arn-code/skills/arn-code-batch-planning/SKILL.md index d687173..56784dd 100644 --- a/plugins/arn-code/skills/arn-code-batch-planning/SKILL.md +++ b/plugins/arn-code/skills/arn-code-batch-planning/SKILL.md @@ -331,7 +331,7 @@ Pre-analyzing [K] thorough features in parallel... (Swift and standard features already have plans — skipping pre-analysis for those.) ``` -For each thorough feature, spawn a `arn-code-batch-analyzer` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +For each thorough feature, spawn a `arn-code-batch-analyzer` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - `run_in_background: true` - The feature's input type and source-specific context: - Greenfield: feature ID, feature file path, vision dir, use cases dir @@ -416,7 +416,7 @@ After feature-spec completes and the finalized spec file exists (FEATURE_*.md): 1. Read the finalized spec file 2. Derive the spec name from the filename -3. Spawn the `arn-code-feature-planner` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +3. Spawn the `arn-code-feature-planner` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - `run_in_background: true` - The full spec file content (FEATURE_*.md or BUGFIX_*.md) - The spec file path (for the `Spec:` linkage line in the plan) @@ -497,7 +497,7 @@ Options: If **Approve**: run the **Complex Phase Upgrade Gate** below (Step 3.5c) before invoking save-plan. After the gate completes, invoke `Skill: arn-code:arn-code-save-plan`. Proceed to the next feature's plan. -If **Adjust**: let the user provide feedback. Spawn the `arn-code-feature-planner` agent via the Task tool (foreground), passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback), with revision instructions and the current plan path. Re-present with the same 3 options. Repeat until approved or skipped. +If **Adjust**: let the user provide feedback. Spawn the `arn-code-feature-planner` agent via the Agent tool (foreground), passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback), with revision instructions and the current plan path. Re-present with the same 3 options. Repeat until approved or skipped. If **Skip**: remove this feature from the batch. Revert Feature Tracker status to `pending` if applicable. Continue with the next feature's plan. diff --git a/plugins/arn-code/skills/arn-code-batch-simplify/SKILL.md b/plugins/arn-code/skills/arn-code-batch-simplify/SKILL.md index 3d514b2..a4d4b2a 100644 --- a/plugins/arn-code/skills/arn-code-batch-simplify/SKILL.md +++ b/plugins/arn-code/skills/arn-code-batch-simplify/SKILL.md @@ -116,7 +116,7 @@ Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-batch-simplify/references/cross-feat Build the `{cross_feature_context}` block from the data collected in Step 2 — listing each feature's name, its files, and its change record path. -Dispatch three Agent tool calls **in a single message** so they run in parallel. Each call passes the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-reviewer`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/step-0-fast-path.md` "Dispatch convention" for fallback behavior). The three reviewers share the same synthetic name — apply the multi-agent rule by passing the looked-up value to each call independently. Note: `arn-code-simplify-reviewer` is shared with `arn-code-simplify` since both skills perform the same conceptual review work. +Dispatch three Agent tool calls **in a single message** so they run in parallel. Each call passes the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-reviewer`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback behavior). The three reviewers share the same synthetic name — apply the multi-agent rule by passing the looked-up value to each call independently. Note: `arn-code-simplify-reviewer` is shared with `arn-code-simplify` since both skills perform the same conceptual review work. 1. **Code Reuse Reviewer** — fill the cross-feature-prompts.md template with the file list, pattern documentation, and cross-feature context. Instruct the agent to focus on duplicated logic, missed utilities, and copy-paste patterns, with special attention to utilities created independently by different features. @@ -211,7 +211,7 @@ The user may also change individual finding statuses (e.g., "approve SIM-001 but The orchestrator pre-sorts the approved findings by dependency order (if finding B depends on finding A's changes, A comes first), then dispatches a single anonymous Agent call to perform the apply work. The model is configurable via the agent-models config. -**Dispatch the applier as an anonymous Agent tool call**, passing the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-applier`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/step-0-fast-path.md` "Dispatch convention" for fallback behavior). Do NOT add any tool restriction — the applier inherits `Edit`, `Write`, `Bash`, `Read`, `Grep`, `Glob` from the orchestrator's toolbelt by default, and needs all of them. Note: `arn-code-simplify-applier` is shared with `arn-code-simplify` since both skills perform the same conceptual apply work; the cross-feature scope is conveyed via the findings list itself. +**Dispatch the applier as an anonymous Agent tool call**, passing the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-applier`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback behavior). Do NOT add any tool restriction — the applier inherits `Edit`, `Write`, `Bash`, `Read`, `Grep`, `Glob` from the orchestrator's toolbelt by default, and needs all of them. Note: `arn-code-simplify-applier` is shared with `arn-code-simplify` since both skills perform the same conceptual apply work; the cross-feature scope is conveyed via the findings list itself. **Applier prompt contents:** @@ -223,16 +223,16 @@ The orchestrator pre-sorts the approved findings by dependency order (if finding ``` For each finding in the provided list, IN ORDER: -1. Capture pre-state: `git diff --no-color HEAD > /tmp/pre-{findingId}.diff` +1. Snapshot the files you will touch: `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-simplify/scripts/snapshot.sh save {findingId} {filesAffected}`. If you later need to edit a file not in that list (including during self-healing), run the same `save` command for it BEFORE the edit. 2. Apply the suggested fix (Edit/Write the affected files). 3. Run the targeted test command. Capture stdout+stderr. -4. If tests pass: emit `[FINDING-{findingId}: applied]` to stdout. Record status `"applied"`. Continue to next finding. +4. If tests pass: run `snapshot.sh drop {findingId}`, then emit `[FINDING-{findingId}: applied]` to stdout. Record status `"applied"`. Continue to next finding. 5. If tests fail: attempt self-healing. - Re-read the test output to identify the failure cause. - Make a fix attempt (Edit the file). - Re-run the targeted test command. - Up to 3 self-heal attempts per finding. -6. If tests still fail after 3 attempts: revert this finding's changes via `git apply -R /tmp/pre-{findingId}.diff` (or, if the diff is empty because no prior changes existed, run `git checkout -- {filesAffected}`). Emit `[FINDING-{findingId}: reverted - <reason>]` to stdout. Record status `"reverted"` with the failure reason and last test output. Continue to next finding. +6. If tests still fail after 3 attempts: revert this finding's changes via `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-simplify/scripts/snapshot.sh restore {findingId}`. This restores only the snapshotted files and leaves all other uncommitted work alone. Never use `git checkout`, `git stash` or `git apply -R` here. Emit `[FINDING-{findingId}: reverted - <reason>]` to stdout. Record status `"reverted"` with the failure reason and last test output. Continue to next finding. 7. Always emit a per-finding status line so the user sees progress in the transcript. After processing all findings, run ONE final targeted test pass to verify the cumulative state is consistent. Capture the result. diff --git a/plugins/arn-code/skills/arn-code-bug-spec/SKILL.md b/plugins/arn-code/skills/arn-code-bug-spec/SKILL.md index 381a2a1..a90753d 100644 --- a/plugins/arn-code/skills/arn-code-bug-spec/SKILL.md +++ b/plugins/arn-code/skills/arn-code-bug-spec/SKILL.md @@ -81,7 +81,7 @@ Hold this context for use throughout the conversation. Do not dump all of it on ### Step 3: Initial Investigation + Architectural Validation -Invoke the `arn-code-investigator` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Invoke the `arn-code-investigator` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: **Bug description:** The user's report from Step 1. @@ -89,7 +89,7 @@ Invoke the `arn-code-investigator` agent via the Task tool, passing the model fr **Specific hypothesis:** None for the initial invocation. -Once the investigator returns with a root cause and proposed fix direction, invoke the `arn-code-architect` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Once the investigator returns with a root cause and proposed fix direction, invoke the `arn-code-architect` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: **Feature idea:** The investigator's findings -- root cause, scope assessment, and proposed fix direction. @@ -137,7 +137,7 @@ Present the fix proposal with specific files and test plan, offer the user a cho 1. Inform the user: "This fix is complex enough to benefit from a structured plan. Let me capture the investigation results in a specification." -2. Invoke the `arn-code-architect` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +2. Invoke the `arn-code-architect` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The root cause analysis from the investigator - The full codebase context from Step 2 - A fix design question: "Design a fix approach for this bug that aligns with the system architecture." diff --git a/plugins/arn-code/skills/arn-code-catch-up/SKILL.md b/plugins/arn-code/skills/arn-code-catch-up/SKILL.md index 8a0cd67..dbcb989 100644 --- a/plugins/arn-code/skills/arn-code-catch-up/SKILL.md +++ b/plugins/arn-code/skills/arn-code-catch-up/SKILL.md @@ -7,6 +7,7 @@ description: >- "catch up on commits", "document past work", "backfill records", or wants to retroactively document commits that were made outside the Arness pipeline. version: 1.0.0 +argument-hint: "[since-date-or-commit]" --- # Arness Catch-Up diff --git a/plugins/arn-code/skills/arn-code-ensure-config/SKILL.md b/plugins/arn-code/skills/arn-code-ensure-config/SKILL.md index 3e5bc19..1614cd4 100644 --- a/plugins/arn-code/skills/arn-code-ensure-config/SKILL.md +++ b/plugins/arn-code/skills/arn-code-ensure-config/SKILL.md @@ -9,6 +9,7 @@ description: >- arn-code-swift, arn-code-standard) which read the `references/step-0-fast-path.md` reference as Step 0 before proceeding with their workflow. version: 1.3.0 +user-invocable: false --- # Arness Code Ensure Config diff --git a/plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md b/plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md index 6a6e4ac..43cfe8f 100644 --- a/plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md +++ b/plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md @@ -101,10 +101,11 @@ expertise_aware: true | false 3. Verify `.claude/*.local.md`, `.claude/settings.local.json`, and `.arness/*.local.*` are in the project's `.gitignore`: - Read `.gitignore` in the project root - - If `.gitignore` does not exist, create it with `.claude/settings.local.json`, `.claude/*.local.md`, and `.arness/*.local.*` as entries + - If `.gitignore` does not exist, create it with `.claude/settings.local.json`, `.claude/*.local.md`, `.arness/*.local.*` and `.arness/.*-tmp/` as entries - If `.gitignore` exists but does not contain `.claude/*.local.md`, append `.claude/*.local.md` on a new line - If `.gitignore` exists but does not contain `.claude/settings.local.json`, append `.claude/settings.local.json` on a new line - If `.gitignore` exists but does not contain `.arness/*.local.*`, append `.arness/*.local.*` on a new line + - If `.gitignore` exists but does not contain `.arness/.*-tmp/`, append `.arness/.*-tmp/` on a new line (scratch dirs such as `.simplify-tmp/` and `.cve-scan-tmp/`) - **Important:** Do NOT gitignore the entire `.claude/` directory — `.claude/settings.json` and other project-level Claude Code settings should remain committable for team sharing. - **Important:** Do NOT gitignore the entire `.arness/` directory — `.arness/preferences.yaml` (team technology preferences) and other Arness project files must remain committable. 4. Optionally create `.claude/arness-profile.local.md` if the user wants project-specific adjustments @@ -216,7 +217,7 @@ Run via Bash: `mkdir -p` for each configured directory (plans, specs, templates, Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-init/references/template-setup.md` and follow the Default Templates procedure. This copies report templates and generates SHA-256 checksums. This is a silent operation (~5 seconds). -Read the plugin version from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` and write: +Get the plugin version by running `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh` and write: - `Template version` field to `## Arness` with the plugin version ### 2c. If `## Arness` Exists But ANY Required Field Is Missing (including Linting) @@ -245,7 +246,7 @@ If the `Linting:` field is missing (separate logic — this field is not a direc > 3. **Skip** — keep the lint gate disabled (you can change this later) 3. Apply the choice: - - **Enabled** — if `<code-patterns-dir>/linting.md` does not exist, invoke `arn-code-codebase-analyzer` to generate it (the analyzer's step 3C produces this file). Write `Linting: enabled` to the config block. + - **Enabled** — if `<code-patterns-dir>/linting.md` or `<code-patterns-dir>/tooling.json` does not exist, invoke `arn-code-codebase-analyzer` and write the `linting.md` and `tooling.json` content it returns (its step 3C). Show the user the commands in `tooling.json` and ask (using `AskUserQuestion`): **Allow Arness hooks to run these check commands?** 1. Yes 2. No. On Yes, run `bash ${CLAUDE_PLUGIN_ROOT}/hooks/tooling-approve.sh`. The hooks only run commands from an approved `tooling.json`; any later edit to the file needs approval again. Write `Linting: enabled` to the config block. - **None** — write `Linting: none` to the config block. Do not invoke the analyzer. - **Skip** — write `Linting: skip` to the config block. Do not invoke the analyzer. @@ -264,7 +265,7 @@ If the `Security scanning:` field is missing (separate logic — this field is n > 3. **Skip** — keep security scanning disabled (you can change this later) 3. Apply the choice: - - **Enabled** — if `<code-patterns-dir>/security-scanning.md` does not exist, invoke `arn-code-codebase-analyzer` to generate it (the analyzer's security-scanning detection step produces this file, mirroring Phase 1's new step). Write `Security scanning: enabled` to the config block. + - **Enabled** — if `<code-patterns-dir>/security-scanning.md` does not exist, invoke `arn-code-codebase-analyzer` to generate it (the analyzer's security-scanning detection step produces this file). Write `Security scanning: enabled` to the config block. - **None** — write `Security scanning: none` to the config block. Do not invoke the analyzer. - **Skip** — write `Security scanning: skip` to the config block. Do not invoke the analyzer. @@ -337,9 +338,9 @@ Read the `Platform` field from `## Arness`. If Platform is `none` or absent, ski If Platform is `github`: -1. **Fast-path check:** Run via Bash: `gh label list --json name --jq '.[].name' | grep -c '^arness-'` -2. If count is **8** (all labels exist): skip. No action needed. -3. If count is **less than 8**: Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-init/references/platform-labels.md` for the full label definitions (names, colors, descriptions). Run `gh label create <name> --color <color> --description "<desc>" --force` for each of the 8 labels. The `--force` flag makes this idempotent — it updates existing labels and creates missing ones. +1. **Fast-path check:** Run `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/labels-missing.sh`. It prints each missing `arness-*` label, one per line. +2. If it prints nothing (all labels exist), or exits 3 (`gh` offline or not authenticated): skip. No action needed. +3. If it prints label names: Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-init/references/platform-labels.md` for the label definitions (colors, descriptions). Run `gh label create <name> --color <color> --description "<desc>" --force` for each missing label. The `--force` flag makes this idempotent. 4. This is a **silent operation** — no user prompt. Log only if labels were created: "Created N missing GitHub labels." ### 3c. Jira / Bitbucket @@ -364,7 +365,7 @@ Entry-point skills invoke ensure-config as Step 0 on every workflow trigger (~30 ```json { - "schemaVersion": 1, + "schemaVersion": 2, "validatedAt": "2026-05-10T12:34:56Z", "pluginVersion": "3.7.0", "fingerprints": { @@ -382,29 +383,16 @@ Entry-point skills invoke ensure-config as Step 0 on every workflow trigger (~30 ### Write procedure -1. **Compute the 7 fingerprints** using `sha256sum` (Linux + Git Bash) || `shasum -a 256` (Mac BSD). For the `claudeMdArnessSection` hash, extract the `## Arness` block via `awk '/^## Arness$/{flag=1;next} /^## /{flag=0} flag' CLAUDE.md` then pipe to the hasher. For each file fingerprint: if the file does not exist, use the literal string `MISSING` instead of computing a hash. +Run `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/cache-write.sh`. -2. **Read plugin version** from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` if present (legacy), else from the marketplace's `marketplace.json` entry for `arn-code`. Use the empty string if neither is resolvable (cache will not enforce version match in that case). - -3. **Construct the JSON object** with the schema above. `validatedAt` is the current ISO 8601 UTC timestamp. `validationStatus` is `"pass"` (only written on successful Layers 1–3). - -4. **Write atomically** using a project-local temp file (NOT `/tmp/` — Windows compat): - - ```bash - <json content> > .arness/arn-code-ensure-config.local.json.tmp - mv .arness/arn-code-ensure-config.local.json.tmp .arness/arn-code-ensure-config.local.json - ``` - - The `mv` is atomic on POSIX filesystems (Linux ext4, Mac APFS, Windows NTFS via Git Bash). On any Ctrl-C between the write and the mv, the partial file lives at `.local.json.tmp` and the previous cache (if any) is untouched. - -5. **Verify** by reading the file back and confirming valid JSON. If the verify fails, surface as a warning but do not block — the next invocation will simply cache-miss. +The script computes every fingerprint with the same functions `cache-check.sh` uses, resolves the plugin version, and writes the file atomically through a project-local temp file. Do not write the cache JSON by hand: a hand-computed hash will not match the checker and every later run will miss. If the script exits non-zero, surface its stderr as a warning and continue — the next invocation will simply cache-miss. ### When the cache invalidates - `pluginVersion` differs from current (plugin upgrade) - `schemaVersion` differs from current (cache schema bump — silently invalidates) - Any of the 7 fingerprints differs from current state (user edited CLAUDE.md `## Arness`, agent-models file, gitignore, profile, etc.). The `claudeMdArnessSection` fingerprint covers ALL `## Arness` fields including `Linting`, `Security scanning`, and `Security branch`, so changes to those fields invalidate the cache automatically — no separate fingerprint is needed. -- GitHub `arness-*` label count != 8 (when Platform=github and `gh` CLI available — checked inline in `cache-check.sh`, not stored in the JSON) +- Any expected `arness-*` GitHub label is missing (when Platform=github and `gh` is available and authenticated — checked inline in `cache-check.sh`, not stored in the JSON) All invalidation paths trigger a cache miss, which causes the entry-point to read the full ensure-config.md and re-run Layers 1–3 — at the end of which this Layer 4 step writes a new cache. @@ -488,27 +476,27 @@ Layer 2c runs steps 1-3 of the following whenever the field is present: 5. **Profile YAML uses structured `technology_preferences`** with separate `languages`, `frameworks`, `databases`, `infrastructure` arrays. Do not store technologies as a flat string. 6. **Profile data is non-sensitive** (role, technology preferences — no credentials or secrets). The `.claude/*.local.md` gitignore pattern protects against accidental commits of the project-level override while keeping `.claude/settings.json` committable for team sharing. 7. **Folder preference coordination:** When setting `Folder preference`, this value is shared across all three plugins. If another plugin already set it, respect that value. -8. **Template version field** must be set from the plugin version in `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json`, not hardcoded. +8. **Template version field** must be set from the output of `scripts/plugin-version.sh`, not hardcoded. `plugin.json` has no `version` field. --- ## Dispatch convention (agent model lookup) -Every skill in this plugin that dispatches a subagent via the Task tool consults a per-plugin model profile to decide which model the agent runs on. The profile lives at `.arness/agent-models/code.md` (project-relative, NOT plugin-relative — this path is project-rooted while plugin assets use `${CLAUDE_PLUGIN_ROOT}` per Pattern 8 in INTRODUCTION.md). The file is created during init and is one of the presets shipped under `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-init/references/agent-models-presets/`. +Every skill in this plugin that dispatches a subagent via the Agent tool consults a per-plugin model profile to decide which model the agent runs on. The profile lives at `.arness/agent-models/code.md` (project-relative, NOT plugin-relative — this path is project-rooted while plugin assets use `${CLAUDE_PLUGIN_ROOT}`). The file is created during init and is one of the presets shipped under `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-init/references/agent-models-presets/`. ### Lookup procedure (apply at every dispatch site) 1. **Read `.arness/agent-models/code.md`** (project-relative). -2. **If the file is missing or unparseable:** omit the `model:` parameter when invoking the Task tool. The agent's frontmatter default (`opus`) applies. Do not surface an error — fallback is silent. +2. **If the file is missing or unparseable:** omit the `model:` parameter when invoking the Agent tool. The agent's frontmatter default (`opus`) applies. Do not surface an error — fallback is silent. 3. **Look up the agent's name** (e.g., `arn-code-feature-planner`, `arn-code-task-executor`) in the file's mapping. -4. **If the agent name is found:** pass the mapped value (e.g., `opus`, `sonnet`, `haiku`) as the Task tool's `model` parameter. This overrides the agent's `model:` frontmatter. +4. **If the agent name is found:** pass the mapped value (e.g., `opus`, `sonnet`, `haiku`) as the Agent tool's `model` parameter. This overrides the agent's `model:` frontmatter. 5. **If the agent name is NOT found in the file:** omit the `model:` parameter — frontmatter fallback applies. This keeps user-edited `custom` profiles forward-compatible: agents added to the plugin after the user customized their profile still run on their frontmatter default (`opus`) until the user adds them to the file. 6. **Multi-agent parallel dispatches:** apply the lookup to each agent independently. A single instruction that spawns three agents in parallel produces three independent lookups, each potentially passing a different `model:` value. -7. **Resume-mode dispatches** (calls that pass an existing agent ID via the Task tool's `resume` parameter): do NOT consult the profile. Resume calls inherit the model from the original invocation. Dispatch sites that resume an existing agent do not include the model-lookup phrasing. +7. **Resume-mode dispatches** (calls that pass an existing agent ID via the Agent tool's `resume` parameter): do NOT consult the profile. Resume calls inherit the model from the original invocation. Dispatch sites that resume an existing agent do not include the model-lookup phrasing. ### Why this design -- **Native Task tool support.** The Task tool's `model:` parameter takes precedence over agent frontmatter (Pattern 2 in INTRODUCTION.md). No wrapper or shim is needed. -- **Self-documenting.** Every dispatch site explicitly references this convention, so the lookup behavior is visible at the point of dispatch rather than buried in a global default. A static grep for `via the Task tool` confirms coverage. +- **Native Agent tool support.** The Agent tool's `model:` parameter takes precedence over agent frontmatter. No wrapper or shim is needed. +- **Self-documenting.** Every dispatch site explicitly references this convention, so the lookup behavior is visible at the point of dispatch rather than buried in a global default. A static grep for `"Dispatch convention" for fallback` lists every model-looked-up dispatch site (resume-mode sites intentionally omit it). - **Graceful degradation.** Missing file, missing agent entry, and unparseable content all fall back to frontmatter — there is no failure mode where dispatch hangs or errors on a config issue. -- **Single source of truth.** `.arness/agent-models/code.md` is the only place a user edits to change behavior across all arn-code dispatches. The file is template-managed (Pattern 6) so version bumps, drift detection, and the `Template updates: ask | auto | manual` policy all apply. +- **Single source of truth.** `.arness/agent-models/code.md` is the only place a user edits to change behavior across all arn-code dispatches. The file is template-managed so version bumps, drift detection, and the `Template updates: ask | auto | manual` policy all apply. diff --git a/plugins/arn-code/skills/arn-code-ensure-config/references/step-0-fast-path.md b/plugins/arn-code/skills/arn-code-ensure-config/references/step-0-fast-path.md index 3f0e60e..44dedc5 100644 --- a/plugins/arn-code/skills/arn-code-ensure-config/references/step-0-fast-path.md +++ b/plugins/arn-code/skills/arn-code-ensure-config/references/step-0-fast-path.md @@ -11,15 +11,15 @@ This is the **first read** for entry-point skills' Step 0. It runs a shell-only ``` 2. **If exit 0 (cache hit):** - - Emit a one-line status to the user: `Ensure-config: cache valid (arn-code, last validated <duration> ago)`. Read the `validatedAt` timestamp from `.arness/arn-code-ensure-config.local.json` to format the duration; if reading fails, just say "cache valid". + - Emit a one-line status to the user: `Ensure-config: cache valid (arn-code)`. - Return immediately. The entry-point skill's own workflow proceeds with no further config work. - **Do NOT read `references/ensure-config.md`** — that is the whole point of the fast path. 3. **If exit non-zero (cache miss):** - The script's stderr output includes the reason (e.g., `cache miss: pluginVersion changed`, `cache miss: fingerprint claudeMdArnessSection changed`). Surface it as an info-level note: `Ensure-config: cache miss (<reason>) — running full validation.` - **Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md`** and follow ALL its instructions (Layer 1: Profile, Layer 2: Config, Layer 3: Platform Labels). - - At the end of successful validation, the ensure-config.md flow's "Cache Write" step (final step of Layer 3) writes the new `.arness/arn-code-ensure-config.local.json` per the cache schema documented inline there. + - At the end of successful validation, Layer 4 runs `scripts/cache-write.sh`, which writes the new `.arness/arn-code-ensure-config.local.json`. ## Cross-platform notes -The cache-check script works on Linux, Mac, and Windows-via-Git-Bash. It requires `bash`, `sha256sum` or `shasum`, `awk`, `grep`, `cat`, and `jq`. The `gh` CLI is optional (used only for GitHub label count verification). If any required tool is missing, the script exits non-zero and full validation runs as the fallback. +The cache-check script works on Linux, Mac, and Windows-via-Git-Bash. It requires `bash`, `sha256sum` or `shasum`, `awk` and `grep`. The `gh` CLI is optional (used only to check the GitHub labels). If any required tool is missing, the script exits non-zero and full validation runs as the fallback. diff --git a/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-check.sh b/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-check.sh index ea3d8da..a49f6f6 100755 --- a/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-check.sh +++ b/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-check.sh @@ -6,132 +6,52 @@ # stderr reason on miss. # # Cross-platform: works on Linux, Mac, and Windows-via-Git-Bash. -# Required tools: bash, sha256sum or shasum, awk, grep, mv, cat, jq. -# Optional tool: gh (only used for GitHub label count check). +# Required tools: bash, sha256sum or shasum, awk, grep. +# Optional tool: gh (only used for the GitHub label check). set -u -PLUGIN_NAME="arn-code" -SHORT_NAME="code" -SCHEMA_VERSION=1 -EXPECTED_LABELS_COUNT=8 -CACHE_FILE=".arness/${PLUGIN_NAME}-ensure-config.local.json" +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh" -# --- Helper: fail fast with reason --- miss() { echo "cache miss: $1" >&2 exit 1 } -# --- Helper: cross-platform SHA-256 --- -hash_str() { - local data="$1" - if command -v sha256sum >/dev/null 2>&1; then - printf '%s' "$data" | sha256sum | awk '{print $1}' - elif command -v shasum >/dev/null 2>&1; then - printf '%s' "$data" | shasum -a 256 | awk '{print $1}' - else - echo "ERROR: neither sha256sum nor shasum available" >&2 - exit 2 - fi -} - -hash_file() { - local path="$1" - if [ ! -f "$path" ]; then - echo "MISSING" - return 0 - fi - if command -v sha256sum >/dev/null 2>&1; then - sha256sum "$path" | awk '{print $1}' - elif command -v shasum >/dev/null 2>&1; then - shasum -a 256 "$path" | awk '{print $1}' - else - echo "ERROR: neither sha256sum nor shasum available" >&2 - exit 2 - fi -} +arn_cd_project_root || miss "cannot resolve project root" +CACHE_FILE=".arness/${ARN_PLUGIN_NAME}-ensure-config.local.json" # --- 1. Cache file present? --- [ -f "$CACHE_FILE" ] || miss "no cache file at $CACHE_FILE" -# --- 2. jq available for parsing? --- -command -v jq >/dev/null 2>&1 || miss "jq not available (required for cache parsing)" - -# --- 3. Schema version matches? --- -cached_schema=$(jq -r '.schemaVersion // empty' "$CACHE_FILE" 2>/dev/null) -[ "$cached_schema" = "$SCHEMA_VERSION" ] || miss "schemaVersion mismatch (cache: ${cached_schema:-empty}, expected: $SCHEMA_VERSION)" +# --- 2. Schema version matches? --- +cached_schema=$(sed -n 's/.*"schemaVersion"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$CACHE_FILE" | head -1) +[ "$cached_schema" = "$ARN_CACHE_SCHEMA_VERSION" ] || miss "schemaVersion mismatch (cache: ${cached_schema:-empty}, expected: $ARN_CACHE_SCHEMA_VERSION)" -# --- 4. Plugin version matches? --- -# Try to find marketplace.json relative to this script's location. -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# Script: <plugin-root>/skills/arn-code-ensure-config/scripts/cache-check.sh -# Plugin root: ../../.. -# Marketplace root: ../../../.. (when installed via relative path / local marketplace) -PLUGIN_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)" -MARKETPLACE_JSON="$(cd "$PLUGIN_ROOT/.." && pwd)/.claude-plugin/marketplace.json" - -if [ -f "$MARKETPLACE_JSON" ]; then - current_version=$(jq -r --arg name "$PLUGIN_NAME" '.plugins[] | select(.name==$name) | .version' "$MARKETPLACE_JSON" 2>/dev/null) - cached_version=$(jq -r '.pluginVersion // empty' "$CACHE_FILE") - if [ -n "$current_version" ] && [ "$current_version" != "$cached_version" ]; then - miss "pluginVersion changed (cache: $cached_version, current: $current_version)" - fi -fi -# If marketplace.json is unfindable (Anthropic Community Plugin Directory install, etc.), -# skip the version check and rely on file-hash invalidation. - -# --- 5. Compute current fingerprints --- -# Hash the ## Arness section of CLAUDE.md -if [ -f "CLAUDE.md" ]; then - arness_section=$(awk '/^## Arness$/{flag=1;next} /^## /{flag=0} flag' CLAUDE.md) - current_arness_section_hash=$(hash_str "$arness_section") -else - current_arness_section_hash="MISSING" +# --- 3. Plugin version matches? --- +current_version=$(arn_plugin_version) +cached_version=$(arn_json_get "$CACHE_FILE" pluginVersion) +if [ -n "$current_version" ] && [ "$current_version" != "$cached_version" ]; then + miss "pluginVersion changed (cache: ${cached_version:-empty}, current: $current_version)" fi -current_agent_models_hash=$(hash_file ".arness/agent-models/${SHORT_NAME}.md") -current_agent_models_checksums_hash=$(hash_file ".arness/agent-models/.checksums.json") -current_templates_checksums_hash=$(hash_file ".arness/templates/.checksums.json") -current_user_profile_hash=$(hash_file "$HOME/.arness/user-profile.yaml") -current_profile_override_hash=$(hash_file ".claude/arness-profile.local.md") -current_gitignore_hash=$(hash_file ".gitignore") - -# --- 6. Compare against cache --- -# Use parallel indexed arrays (bash 3.2 compatible — Mac's default /bin/bash is 3.2, -# associative arrays via 'declare -A' are bash 4+ only). -KEYS=(claudeMdArnessSection agentModelsCodeMd agentModelsChecksums templatesChecksums userProfile profileOverride gitignoreContent) -VALUES=( - "$current_arness_section_hash" - "$current_agent_models_hash" - "$current_agent_models_checksums_hash" - "$current_templates_checksums_hash" - "$current_user_profile_hash" - "$current_profile_override_hash" - "$current_gitignore_hash" -) - -i=0 -while [ $i -lt ${#KEYS[@]} ]; do - key="${KEYS[$i]}" - current="${VALUES[$i]}" - cached=$(jq -r ".fingerprints.${key} // empty" "$CACHE_FILE") +# --- 4. Fingerprints match? --- +for key in $ARN_FINGERPRINT_KEYS; do + current=$(arn_fingerprint "$key") + cached=$(arn_json_get "$CACHE_FILE" "$key") if [ "$cached" != "$current" ]; then - miss "fingerprint $key changed (cache: ${cached:0:16}..., current: ${current:0:16}...)" + miss "fingerprint $key changed (cache: $(printf '%.16s' "$cached")..., current: $(printf '%.16s' "$current")...)" fi - i=$((i + 1)) done -# --- 7. GitHub labels check (only if Platform=github AND gh available) --- -if [ -f "CLAUDE.md" ]; then - platform=$(grep -E '^- \*\*Platform:\*\*' CLAUDE.md 2>/dev/null | head -1 | sed -E 's/.*Platform:\*\*\s*//') - if [ "$platform" = "github" ] && command -v gh >/dev/null 2>&1; then - label_count=$(gh label list --json name --jq '.[].name' 2>/dev/null | grep -c '^arness-' || echo 0) - if [ "$label_count" != "$EXPECTED_LABELS_COUNT" ]; then - miss "GitHub arness-* label count is $label_count, expected $EXPECTED_LABELS_COUNT" - fi +# --- 5. GitHub labels present? (only if Platform=github and gh available) --- +if [ "$(arn_config_field Platform)" = "github" ] && command -v gh >/dev/null 2>&1; then + missing=$(arn_missing_labels) + rc=$? + if [ $rc -eq 0 ] && [ -n "$missing" ]; then + miss "GitHub labels missing: $missing" fi + # rc 3 = gh could not answer (offline, no auth). Do not fail the cache for that. fi -# --- All checks passed --- exit 0 diff --git a/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-write.sh b/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-write.sh new file mode 100755 index 0000000..82a9785 --- /dev/null +++ b/plugins/arn-code/skills/arn-code-ensure-config/scripts/cache-write.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# arn-code-ensure-config cache-write.sh +# +# Writes .arness/arn-code-ensure-config.local.json after a successful full +# validation (ensure-config Layer 4). Uses the same fingerprint functions as +# cache-check.sh, so a cache written here is read back as a hit. +# +# Exit 0 on success, non-zero with a stderr reason on failure. + +set -u + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh" + +arn_cd_project_root || { echo "cache write: cannot resolve project root" >&2; exit 1; } +mkdir -p .arness || { echo "cache write: cannot create .arness/" >&2; exit 1; } + +CACHE_FILE=".arness/${ARN_PLUGIN_NAME}-ensure-config.local.json" +TMP_FILE="${CACHE_FILE}.tmp" + +{ + printf '{\n' + printf ' "schemaVersion": %s,\n' "$ARN_CACHE_SCHEMA_VERSION" + printf ' "validatedAt": "%s",\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" + printf ' "pluginVersion": "%s",\n' "$(arn_plugin_version)" + printf ' "fingerprints": {\n' + sep="" + for key in $ARN_FINGERPRINT_KEYS; do + printf '%s "%s": "%s"' "$sep" "$key" "$(arn_fingerprint "$key")" + sep=$',\n' + done + printf '\n },\n' + printf ' "validationStatus": "pass"\n' + printf '}\n' +} > "$TMP_FILE" || { echo "cache write: cannot write $TMP_FILE" >&2; exit 1; } + +mv "$TMP_FILE" "$CACHE_FILE" || { echo "cache write: cannot move cache into place" >&2; exit 1; } +echo "cache written: $CACHE_FILE" diff --git a/plugins/arn-code/skills/arn-code-ensure-config/scripts/labels-missing.sh b/plugins/arn-code/skills/arn-code-ensure-config/scripts/labels-missing.sh new file mode 100755 index 0000000..5b30e65 --- /dev/null +++ b/plugins/arn-code/skills/arn-code-ensure-config/scripts/labels-missing.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Prints the arness-* GitHub labels that are missing on the current repo, one +# per line. Prints nothing when all are present. Exit 3 when gh cannot answer. + +set -u + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh" + +missing=$(arn_missing_labels) || exit 3 +for l in $missing; do printf '%s\n' "$l"; done diff --git a/plugins/arn-code/skills/arn-code-ensure-config/scripts/lib.sh b/plugins/arn-code/skills/arn-code-ensure-config/scripts/lib.sh new file mode 100755 index 0000000..45364eb --- /dev/null +++ b/plugins/arn-code/skills/arn-code-ensure-config/scripts/lib.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash +# arn-code-ensure-config shared helpers. +# +# Sourced by cache-check.sh, cache-write.sh, plugin-version.sh and the plugin +# hooks so that every reader and writer computes fingerprints the same way. +# Bash 3.2 compatible (macOS default). Required: sha256sum or shasum, awk. + +ARN_PLUGIN_NAME="arn-code" +ARN_SHORT_NAME="code" +ARN_CACHE_SCHEMA_VERSION=2 +ARN_EXPECTED_LABELS="arness-backlog arness-bug-issue arness-feature-issue arness-priority-high arness-priority-low arness-priority-medium arness-rejected arness-security" + +ARN_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Script dir: <plugin-root>/skills/arn-code-ensure-config/scripts +ARN_PLUGIN_ROOT="$(cd "$ARN_LIB_DIR/../../.." && pwd)" # own location; CLAUDE_PLUGIN_ROOT may name another plugin + +# Move to the project root so relative paths (CLAUDE.md, .arness/) resolve +# even when Claude's cwd is a subdirectory. +arn_cd_project_root() { + local root + if [ -n "${CLAUDE_PROJECT_DIR:-}" ] && [ -d "$(arn_unix_path "$CLAUDE_PROJECT_DIR")" ]; then + root=$(arn_unix_path "$CLAUDE_PROJECT_DIR") + else + root=$(git rev-parse --show-toplevel 2>/dev/null) || root="$(pwd)" + fi + cd "$root" || return 1 +} + +# arn_python: print the command of a working Python 3, or nothing. On Windows, +# "python3" is often a Microsoft Store stub that only prints a message; Python is "python". +arn_python() { + local p + for p in python3 python; do + command -v "$p" >/dev/null 2>&1 || continue + "$p" -c 'import sys; sys.exit(sys.version_info[0] < 3)' >/dev/null 2>&1 && { printf '%s' "$p"; return 0; } + done + return 1 +} + +# arn_unix_path <path>: turn a Windows path (C:\x\y or C:/x/y) into the form Git Bash +# uses (/c/x/y). Other paths are printed unchanged. +arn_unix_path() { + case "$1" in + [A-Za-z]:[\\/]*|[A-Za-z]:) + if command -v cygpath >/dev/null 2>&1; then cygpath -u "$1" + else printf '%s' "$1" | awk '{ gsub(/\\/, "/"); print "/" tolower(substr($0, 1, 1)) substr($0, 3) }' + fi ;; + *) printf '%s' "$1" ;; + esac +} + +arn_sha256() { + if command -v sha256sum >/dev/null 2>&1; then + sha256sum | awk '{print $1}' + elif command -v shasum >/dev/null 2>&1; then + shasum -a 256 | awk '{print $1}' + else + echo "ERROR: neither sha256sum nor shasum available" >&2 + return 2 + fi +} + +arn_hash_str() { + printf '%s' "$1" | arn_sha256 +} + +arn_hash_file() { + if [ ! -f "$1" ]; then + echo "MISSING" + return 0 + fi + arn_sha256 < "$1" +} + +# Print the body of the "## Arness" section of CLAUDE.md, CR stripped. +arn_arness_section() { + [ -f CLAUDE.md ] || return 1 + awk '{sub(/\r$/, "")} /^## Arness$/{flag=1; next} /^## /{flag=0} flag' CLAUDE.md +} + +# Read one "- **Field:** value" line from the ## Arness section. +arn_config_field() { + arn_arness_section 2>/dev/null | awk -v key="$1" ' + index($0, "- **" key ":**") == 1 { + sub(/^- \*\*[^*]+:\*\*[ \t]*/, ""); sub(/[ \t]+$/, ""); print; exit + }' +} + +# Resolve the installed plugin version. Order: +# 1. version in plugin.json (if a future release sets it) +# 2. marketplace.json next to the plugin (local / relative-path installs) +# 3. the installed cache directory name: ~/.claude/plugins/cache/<mkt>/<plugin>/<version> +# Prints an empty string when none resolves. +arn_plugin_version() { + local v="" mj base + if [ -f "$ARN_PLUGIN_ROOT/.claude-plugin/plugin.json" ]; then + v=$(awk -F'"' '/"version"[ \t]*:/{print $4; exit}' "$ARN_PLUGIN_ROOT/.claude-plugin/plugin.json") + fi + if [ -z "$v" ]; then + mj="$(cd "$ARN_PLUGIN_ROOT/../.." 2>/dev/null && pwd)/.claude-plugin/marketplace.json" + if [ -f "$mj" ]; then + v=$(awk -v name="$ARN_PLUGIN_NAME" -F'"' ' + $2 == "name" && $4 == name {hit=1; next} + hit && $2 == "version" {print $4; exit} + hit && $2 == "name" {hit=0}' "$mj") + fi + fi + if [ -z "$v" ]; then + base=$(basename "$ARN_PLUGIN_ROOT") + case "$base" in + [0-9]*.[0-9]*.[0-9]*) v="$base" ;; + esac + fi + printf '%s' "$v" +} + +# The fingerprint keys, in a fixed order. Values come from arn_fingerprint. +ARN_FINGERPRINT_KEYS="claudeMdArnessSection agentModelsCodeMd agentModelsChecksums templatesChecksums userProfile profileOverride gitignoreContent" + +arn_fingerprint() { + case "$1" in + claudeMdArnessSection) + if [ -f CLAUDE.md ]; then arn_hash_str "$(arn_arness_section)"; else echo "MISSING"; fi ;; + agentModelsCodeMd) arn_hash_file ".arness/agent-models/${ARN_SHORT_NAME}.md" ;; + agentModelsChecksums) arn_hash_file ".arness/agent-models/.checksums.json" ;; + templatesChecksums) arn_hash_file ".arness/templates/.checksums.json" ;; + userProfile) arn_hash_file "$HOME/.arness/user-profile.yaml" ;; + profileOverride) arn_hash_file ".claude/arness-profile.local.md" ;; + gitignoreContent) arn_hash_file ".gitignore" ;; + esac +} + +# Read a flat string value from the cache JSON without jq. +# Works for the keys this plugin writes (no nested quotes in values). +arn_json_get() { + awk -v key="$2" -F'"' '{for (i = 2; i < NF; i++) if ($i == key) {print $(i + 2); exit}}' "$1" +} + +# List the expected labels that are missing on the GitHub repo. +# Prints nothing when all are present. Returns 3 when gh cannot answer. +arn_missing_labels() { + local have l missing="" + have=$(gh label list --limit 500 --json name --jq '.[].name' 2>/dev/null) || return 3 + for l in $ARN_EXPECTED_LABELS; do + printf '%s\n' "$have" | grep -qx "$l" || missing="$missing $l" + done + printf '%s' "${missing# }" +} + +# True when the current directory is an Arness project. +arn_is_arness_project() { + [ -f CLAUDE.md ] && grep -q '^## Arness' CLAUDE.md 2>/dev/null +} diff --git a/plugins/arn-code/skills/arn-code-ensure-config/scripts/plugin-version.sh b/plugins/arn-code/skills/arn-code-ensure-config/scripts/plugin-version.sh new file mode 100755 index 0000000..b4d3d60 --- /dev/null +++ b/plugins/arn-code/skills/arn-code-ensure-config/scripts/plugin-version.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Prints the installed arn-code version, or "unknown" when it cannot be resolved. +# plugin.json intentionally has no version; see lib.sh arn_plugin_version. + +set -u + +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/lib.sh" + +v=$(arn_plugin_version) +printf '%s\n' "${v:-unknown}" diff --git a/plugins/arn-code/skills/arn-code-execute-plan/SKILL.md b/plugins/arn-code/skills/arn-code-execute-plan/SKILL.md index a0944bc..4696832 100644 --- a/plugins/arn-code/skills/arn-code-execute-plan/SKILL.md +++ b/plugins/arn-code/skills/arn-code-execute-plan/SKILL.md @@ -2,7 +2,7 @@ name: arn-code-execute-plan description: >- This skill should be used when the user says "execute plan", "run the plan", - "start execution", "execute project", "execute all tasks", "run all tasks", + "execute project", "execute all tasks", "run all tasks", "run plan in parallel", "execute with review gates", or wants to execute a full structured project plan after tasks have been created via arn-code-taskify. This skill runs ALL tasks from the task list — for executing a single specific diff --git a/plugins/arn-code/skills/arn-code-execute-plan/references/dispatch-loop.md b/plugins/arn-code/skills/arn-code-execute-plan/references/dispatch-loop.md index 4358b5d..de6566b 100644 --- a/plugins/arn-code/skills/arn-code-execute-plan/references/dispatch-loop.md +++ b/plugins/arn-code/skills/arn-code-execute-plan/references/dispatch-loop.md @@ -1,6 +1,6 @@ # Dispatch Loop Algorithm -This is the core orchestration loop for arn-code-execute-plan. It runs entirely in the main session. All agent spawning uses the `Task` tool. +This is the core orchestration loop for arn-code-execute-plan. It runs entirely in the main session. All agent spawning uses the `Agent` tool. ``` -- 0. Initialize progress tracking ------------------------------------ @@ -37,8 +37,8 @@ WHILE there are pending tasks: b. **Determine the executor model.** First check the per-phase upgrade override: - Read PROGRESS_TRACKER.json. Find the phase entry whose `implementation.taskId` matches the current task ID. - If `phase.implementation.modelOverride` is non-null (e.g., `"opus"`), use that value as the `model` parameter for this dispatch. Skip the standard agent-models lookup. Emit a one-line status to the user: `Phase <N> (<phaseTitle>) executor model: <override> (upgraded — complex phase per pipeline.complex-phase-upgrade)`. - - If `phase.implementation.modelOverride` is null or the field is missing, fall through to the standard lookup: pass the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). - Then spawn a arn-code-task-executor agent via the Task tool with the determined model. Context for the prompt: + - If `phase.implementation.modelOverride` is null or the field is missing, fall through to the standard lookup: pass the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). + Then spawn a arn-code-task-executor agent via the Agent tool with the determined model. Context for the prompt: - Task ID and full task description (from TaskGet) - Project name: <PROJECT_NAME> - Project folder path: <plans-dir>/<PROJECT_NAME>/ @@ -73,7 +73,7 @@ WHILE there are pending tasks: testing report (TESTING_REPORT_TEMPLATE.json) as appropriate - Return: report file path(s), list of files created/modified, and visual capture directory path (if captures were taken) - c. Record the agent ID returned by the Task tool (needed for resume mode) + c. Record the agent ID returned by the Agent tool (needed for resume mode) ALL executors in this batch are dispatched in a SINGLE message (multiple Task tool calls in one response) so they run in PARALLEL. @@ -88,7 +88,7 @@ WHILE there are pending tasks: a. Read the executor's output to extract: - Report file path(s) (implementation report and/or testing report) - List of files created and modified - b. Spawn a arn-code-task-reviewer agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context for the prompt: + b. Spawn a arn-code-task-reviewer agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context for the prompt: - Task ID and full task description - Project name: <PROJECT_NAME> - Project folder path: <plans-dir>/<PROJECT_NAME>/ @@ -149,7 +149,7 @@ WHILE there are pending tasks: - IF retry count <= 2: - IF review feedback mode = "resume": - Resume the original executor agent (using the resume parameter of the - Task tool, passing the agent ID recorded in step 2c) with a new prompt + Agent tool, passing the agent ID recorded in step 2c) with a new prompt containing: - The reviewer's specific error findings (errors that must be fixed) - The review report path for full context @@ -158,7 +158,7 @@ WHILE there are pending tasks: - After the executor returns, go back to step 4 for this task only (re-run the reviewer) - IF review feedback mode = "fresh": - - Spawn a NEW arn-code-task-executor agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: + - Spawn a NEW arn-code-task-executor agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - All original task context (same as step 2b) - PLUS: the review report path - PLUS: specific findings to fix from the reviewer diff --git a/plugins/arn-code/skills/arn-code-execute-plan/references/pattern-refresh.md b/plugins/arn-code/skills/arn-code-execute-plan/references/pattern-refresh.md index 35d456a..6b1c258 100644 --- a/plugins/arn-code/skills/arn-code-execute-plan/references/pattern-refresh.md +++ b/plugins/arn-code/skills/arn-code-execute-plan/references/pattern-refresh.md @@ -19,7 +19,7 @@ Automatic post-implementation refresh of stored pattern documentation. After imp - If **none exist** AND this **is** a catch-up context: invoke the `arn-code-codebase-analyzer` agent with full analysis mode to generate pattern docs from scratch. Write the output to the Code patterns directory. Print: "Pattern documentation generated from scratch." Return. - If **at least one exists**: proceed to step 3. -3. **Invoke the `arn-code-codebase-analyzer` agent via the Task tool**, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback), with full analysis mode. Pass the current Code patterns directory path and instruct the agent to analyze the full codebase for patterns, architecture, and testing conventions. +3. **Invoke the `arn-code-codebase-analyzer` agent via the Agent tool**, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback), with full analysis mode. Pass the current Code patterns directory path and instruct the agent to analyze the full codebase for patterns, architecture, and testing conventions. 4. **Compare fresh analysis against stored pattern files.** Identify: - **New patterns** -- patterns found in the analysis that do not appear in stored docs diff --git a/plugins/arn-code/skills/arn-code-execute-task/SKILL.md b/plugins/arn-code/skills/arn-code-execute-task/SKILL.md index 3376afe..01f2de7 100644 --- a/plugins/arn-code/skills/arn-code-execute-task/SKILL.md +++ b/plugins/arn-code/skills/arn-code-execute-task/SKILL.md @@ -7,6 +7,7 @@ description: >- review. This is for ONE task only — for executing the full plan (all tasks), use arn-code-execute-plan instead. version: 0.4.0 +argument-hint: "[task-number-or-description]" --- # Arness Execute Task @@ -99,9 +100,9 @@ Store the choice for the execution session. 5. **Determine the executor model.** First check the per-phase upgrade override: - Read PROGRESS_TRACKER.json. Find the phase entry whose `implementation.taskId` matches the current task ID. - If `phase.implementation.modelOverride` is non-null (e.g., `"opus"`), use that value as the `model` parameter for this dispatch. Skip the standard agent-models lookup. Emit a one-line status to the user: `Phase <N> (<phaseTitle>) executor model: <override> (upgraded — complex phase per pipeline.complex-phase-upgrade)`. - - If `phase.implementation.modelOverride` is null or the field is missing, fall through to the standard lookup: pass the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). + - If `phase.implementation.modelOverride` is null or the field is missing, fall through to the standard lookup: pass the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). - Then spawn `arn-code-task-executor` via the Task tool with the determined model. Full context: + Then spawn `arn-code-task-executor` via the Agent tool with the determined model. Full context: - Task ID and full task description - Project name: `<PROJECT_NAME>` - Project folder path: `<plans-dir>/<PROJECT_NAME>/` @@ -111,7 +112,7 @@ Store the choice for the execution session. - Specs directory path: `<specs-dir>/` (if relevant to the task) - Report template path: `<template-path>/` - Visual testing config (if configured): capture script path, compare script path, baseline directory, diff threshold -6. Record the agent ID returned by the Task tool (needed for resume mode) +6. Record the agent ID returned by the Agent tool (needed for resume mode) 7. Wait for executor to complete --- @@ -122,7 +123,7 @@ Store the choice for the execution session. - Report file path(s) - List of files created and modified - Visual capture directory path (if reported) -2. Spawn `arn-code-task-reviewer` via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +2. Spawn `arn-code-task-reviewer` via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - Task ID and full task description - Project name and folder path - INTRODUCTION.md path @@ -137,7 +138,7 @@ Store the choice for the execution session. - **pass** -- mark task as completed via TaskUpdate - **pass-with-warnings** -- append warnings to implementation report (`reviewFindings` section), mark task as completed via TaskUpdate - **needs-fixes** -- apply chosen feedback mode: - - **Resume mode:** resume the original executor agent (using its agent ID from Step 4.6, via the `resume` parameter of the Task tool) with review feedback, then re-run reviewer + - **Resume mode:** resume the original executor agent (using its agent ID from Step 4.6, via the `resume` parameter of the Agent tool) with review feedback, then re-run reviewer - **Fresh dispatch mode:** spawn a new executor with the review report + original context, then re-run reviewer - Maximum 2 review cycles, then escalate to user with full findings 4. After marking the task as completed (pass or pass-with-warnings), update `PROGRESS_TRACKER.json`: diff --git a/plugins/arn-code/skills/arn-code-feature-spec/SKILL.md b/plugins/arn-code/skills/arn-code-feature-spec/SKILL.md index 1631a3f..9ab1e55 100644 --- a/plugins/arn-code/skills/arn-code-feature-spec/SKILL.md +++ b/plugins/arn-code/skills/arn-code-feature-spec/SKILL.md @@ -108,7 +108,7 @@ Hold this context for use throughout the conversation. Do not dump all of it on **Sketch detection:** Check if a `arness-sketches/` directory exists at the project root. If it does, scan for a subdirectory whose name matches the feature being specified (by feature name, F-NNN ID, or keyword overlap). If a matching sketch directory is found: 1. Read `arness-sketches/<sketch-name>/sketch-manifest.json` 2. If the manifest file cannot be read or parsed (malformed JSON, empty file, permission error), set `sketch_context_loaded = false` and proceed normally — treat as if no sketch exists. -3. Verify the manifest has `componentMapping` and `composition` fields (Phase 1 enrichment) +3. Verify the manifest has `componentMapping` and `composition` fields 4. If both fields are present, set `sketch_context_loaded = true` and hold the manifest data (sketch directory path, manifest path, status, paradigm, componentMapping entries, composition metadata) for use in Step 5 5. If the manifest exists but lacks `componentMapping` or `composition`, set `sketch_context_loaded = false` — the sketch predates the enrichment and cannot be referenced in the spec 6. If no matching sketch directory is found, set `sketch_context_loaded = false` and proceed normally diff --git a/plugins/arn-code/skills/arn-code-help/SKILL.md b/plugins/arn-code/skills/arn-code-help/SKILL.md index 22c13fc..d7e69de 100644 --- a/plugins/arn-code/skills/arn-code-help/SKILL.md +++ b/plugins/arn-code/skills/arn-code-help/SKILL.md @@ -13,7 +13,7 @@ version: 1.2.0 Detect the user's current position in the Arness workflow pipeline, render an ASCII diagram with the active stage marked, and suggest the next command to run. Supports cross-plugin awareness — detects activity in Arness Spark and Arness Infra and provides hints at the bottom of the output. This skill is strictly read-only -- it never modifies files or project state. -**Allowed tools:** Read, Glob, Grep only. This skill MUST NOT use Write, Edit, Bash, or Task tools. This skill MUST NOT invoke any agents. +**Allowed tools:** Read, Glob and Grep. When Glob or Grep is not available in the session, use read-only shell commands instead (`ls`, `find`, `test -e`, `grep -r`, `git status`, `git log`). This skill MUST NOT use Write or Edit, MUST NOT run a shell command that changes a file, and MUST NOT invoke any agents. ## Workflow @@ -136,5 +136,5 @@ Common questions the user might ask: - This skill MUST NOT write or modify any files. - This skill MUST NOT invoke any agents. -- All tools used must be read-only: Read, Glob, Grep. +- All tools used must be read-only: Read, Glob, Grep, or the read-only shell commands listed above. - All command suggestions must use bare skill names without the plugin prefix (e.g., `/arn-code-init`, `/arn-code-plan`, `/arn-spark-discover`). Do not use the fully qualified `plugin:skill` format in user-facing text. diff --git a/plugins/arn-code/skills/arn-code-init/SKILL.md b/plugins/arn-code/skills/arn-code-init/SKILL.md index 4578e52..5a965f0 100644 --- a/plugins/arn-code/skills/arn-code-init/SKILL.md +++ b/plugins/arn-code/skills/arn-code-init/SKILL.md @@ -27,7 +27,7 @@ Read the project's CLAUDE.md and look for a `## Arness` section. If no CLAUDE.md **If the section exists:** 1. Parse all config fields from the existing `## Arness` block -2. Read the current plugin version from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` +2. Get the current plugin version by running `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh` 3. Show the user their current configuration and version comparison: - Config template version vs current plugin version - Number of config fields present vs expected @@ -126,7 +126,7 @@ Check if the project uses Git, determine the code hosting platform, and identify ### Step 3A: Analyze Codebase Patterns -Invoke the `arn-code-codebase-analyzer` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Invoke the `arn-code-codebase-analyzer` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The detected project type (backend/frontend/fullstack — infer from the codebase) - The source root path (infer from project structure) - Any framework hint (infer from manifests/markers) @@ -166,7 +166,7 @@ Be conversational, not rigid. Skip questions where the answer is obvious from pr ### Step 3B-2: Generate Recommended Patterns -Invoke the `arn-code-pattern-architect` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback), with all the technology choices gathered above. +Invoke the `arn-code-pattern-architect` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback), with all the technology choices gathered above. The agent returns recommended code patterns, testing patterns, and architecture — with concrete best-practice examples marked as "Recommended" rather than real file references. @@ -244,6 +244,7 @@ Write the files to the chosen pattern docs location: handling, sensitive data). Do not write it for projects with no security surface (pure utility libraries, CLI tools with no auth/API/user input). 6. **`linting.md`** — Linter detection per service/package, produced by the codebase analyzer (step 3C of `arn-code-codebase-analyzer`). Always write this file: if no linters were detected, the analyzer returns the single-line "No linters detected." marker, which is what gets written. The lint configuration question in Step 8b uses this file to suggest a default. +7. **`tooling.json`** — Machine-readable check and test commands, also returned by the analyzer's step 3C. Always write this file. If the user picks **Enabled** in Step 8b, show its commands and ask (using `AskUserQuestion`): **Allow Arness hooks to run these check commands?** 1. Yes 2. No. On Yes, run `bash ${CLAUDE_PLUGIN_ROOT}/hooks/tooling-approve.sh`. ### Step 7: Configure Plans and Templates @@ -311,6 +312,10 @@ The field write in step 3 of the procedure is captured for the CLAUDE.md write i Record the chosen profile for the config write in Step 9. +### Step 8d: Turn On Arness Hooks + +Arness hooks are off until the project or the user turns them on. Ask (using `AskUserQuestion`): **Turn on Arness hooks for this project?** 1. Yes (Recommended) — session status line, block force-push, block commits with secrets, lint after edits when Linting is enabled 2. No, keep them off. Record `on` or `off` for the config write in Step 9. The field is shared with everyone who uses this repository; one person can override it with `ARNESS_HOOKS=on` or `ARNESS_HOOKS=off`. + --- ### Step 9: Persist Configuration to CLAUDE.md @@ -324,12 +329,13 @@ Write (or update) the `## Arness` section in the project's CLAUDE.md: - **Specs directory:** [chosen-specs-path] - **Report templates:** default | custom - **Template path:** [relative-path, e.g., .arness/templates] -- **Template version:** [version from plugin.json] +- **Template version:** [output of plugin-version.sh] - **Template updates:** ask | auto | manual - **Code patterns:** [chosen-pattern-docs-path] - **Docs directory:** [chosen-docs-path] - **Linting:** enabled | none | skip - **Code agent model profile:** all-opus | balanced | custom +- **Hooks:** on | off - **Git:** yes | no - **Platform:** github | bitbucket | none - **Issue tracker:** github | jira | none @@ -423,11 +429,11 @@ Entered from Step 1 when the user chooses **Upgrade**. Diagnoses gaps using the ### Step U1: Run Diagnostic -Invoke the `arn-code-doctor` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Invoke the `arn-code-doctor` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - Description: "Comprehensive health check for arn-code-init upgrade. Check ALL categories: config fields, directories, template files, checksums, Git/Platform/Issue tracker state, platform labels, and pattern doc schema compliance. Use only Read/Glob/Grep and the allowed Bash commands (git status, git remote -v, gh auth status, gh label list, bkt --version, bkt auth status, ls). Do NOT run claude CLI commands." - Project root path - The parsed `## Arness` config content -- Plugin version from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` +- Plugin version from `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh` - Instruction to read the knowledge base at `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-report/references/arness-knowledge-base.md` The agent should check for: @@ -507,6 +513,7 @@ For each missing config field that needs a user-provided value, ask **one focuse | Report templates | "Use default or custom report templates?" | `default` | Step 7 | | Template updates | "How should Arness handle template updates?" | `ask` | Step 7 | | Docs directory | "Where should Arness save project documentation?" | `.arness/docs/` | Step 8 | +| Hooks | "Turn on Arness hooks for this project?" | `on` | Step 8d | | Jira site | "What is your Atlassian site URL? (e.g., mycompany.atlassian.net)" | none | Step 3 | | Jira project | "Which Jira project should Arness use?" | list via MCP and pick | Step 3 | diff --git a/plugins/arn-code/skills/arn-code-init/references/template-setup.md b/plugins/arn-code/skills/arn-code-init/references/template-setup.md index 3611fa3..40b9b13 100644 --- a/plugins/arn-code/skills/arn-code-init/references/template-setup.md +++ b/plugins/arn-code/skills/arn-code-init/references/template-setup.md @@ -14,7 +14,7 @@ This procedure covers copying report templates to a project and generating check ``` sha256sum .arness/templates/*.json 2>/dev/null || shasum -a 256 .arness/templates/*.json ``` -4. Read the plugin version from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` +4. Get the plugin version by running `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh` 5. Write `.arness/templates/.checksums.json`: ```json { diff --git a/plugins/arn-code/skills/arn-code-pick-issue/SKILL.md b/plugins/arn-code/skills/arn-code-pick-issue/SKILL.md index 2462f88..b6cf1f5 100644 --- a/plugins/arn-code/skills/arn-code-pick-issue/SKILL.md +++ b/plugins/arn-code/skills/arn-code-pick-issue/SKILL.md @@ -13,6 +13,7 @@ description: >- for remote issue browsing. Do NOT use this for creating new issues — use /arn-code-create-issue for that. version: 1.3.0 +argument-hint: "[search-keywords]" --- # Arness Pick Issue @@ -237,7 +238,7 @@ After the user has reviewed the issue details and agent assessment, offer option For brand-new issues with no prior feature file or spec, there is nothing to drift against — skip directly to Step 7. -When the gate applies, spawn the `arn-code-drift-detector` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context (the existing feature file or sub-feature spec is the input spec): +When the gate applies, spawn the `arn-code-drift-detector` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context (the existing feature file or sub-feature spec is the input spec): ``` Verify whether the following feature file / spec still aligns with the current codebase. diff --git a/plugins/arn-code/skills/arn-code-plan/SKILL.md b/plugins/arn-code/skills/arn-code-plan/SKILL.md index a06da5b..46c98a0 100644 --- a/plugins/arn-code/skills/arn-code-plan/SKILL.md +++ b/plugins/arn-code/skills/arn-code-plan/SKILL.md @@ -2,7 +2,6 @@ name: arn-code-plan description: >- This skill should be used when the user says "arness code plan", "arn-code-plan", - "plan this", "write a plan", "create plan", "implementation plan", "plan feature", "plan the spec", "plan from spec", "generate plan", "arness code plan FEATURE_X", "plan the bugfix", "plan bugfix", "make a plan", @@ -11,6 +10,7 @@ description: >- presents it for review, and iterates on user feedback until approved. Produces a PLAN_PREVIEW file that feeds into /arn-code-save-plan. version: 1.1.0 +argument-hint: "[spec-name]" --- # Arness Plan @@ -79,7 +79,7 @@ Then invoke `arn-code-codebase-analyzer` (existing codebase) or `arn-code-patter Specs may have been written days or weeks before being planned. The codebase moves in the meantime — files get renamed, modules refactored, frameworks swapped. Before invoking the planner, verify the spec's concrete references still hold against HEAD. -Spawn the `arn-code-drift-detector` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Spawn the `arn-code-drift-detector` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: ``` Verify whether the following specification still aligns with the current codebase. @@ -118,7 +118,7 @@ The output file path is: `<plans-dir>/PLAN_PREVIEW_<spec-name>.md` **Check for existing PLAN_PREVIEW:** If a PLAN_PREVIEW file already exists at that path, inform the user: "A plan preview already exists for this spec: `<path>`. Would you like to regenerate it from scratch, or review the existing plan?" If review → skip to Step 5. If regenerate → proceed. -Spawn the `arn-code-feature-planner` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Spawn the `arn-code-feature-planner` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: ``` You are generating an implementation plan for the following specification. @@ -148,7 +148,7 @@ Generate a structured implementation plan and write it to the output file. Include `Spec: <specs-dir>/<spec-filename>` near the top for arn-code-save-plan linkage. ``` -Record the agent ID returned by the Task tool (needed for resume in Step 5b). +Record the agent ID returned by the Agent tool (needed for resume in Step 5b). --- @@ -236,7 +236,7 @@ After Step 5a completes (gate applied or skipped), go to Step 6. #### Step 5b: Iterate with Feedback -Try to resume the planner agent using the Task tool's `resume` parameter with the stored agent ID: +Try to resume the planner agent using the Agent tool's `resume` parameter with the stored agent ID: ``` The user has reviewed the current plan and has the following feedback: @@ -250,7 +250,7 @@ to the same file. Summarize what you changed. ``` **If resume fails** (API error, agent ID no longer valid): -Fall back to spawning a fresh `arn-code-feature-planner` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Fall back to spawning a fresh `arn-code-feature-planner` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: ``` You are revising an existing implementation plan based on user feedback. diff --git a/plugins/arn-code/skills/arn-code-report/SKILL.md b/plugins/arn-code/skills/arn-code-report/SKILL.md index 26bae4b..4bbe5ea 100644 --- a/plugins/arn-code/skills/arn-code-report/SKILL.md +++ b/plugins/arn-code/skills/arn-code-report/SKILL.md @@ -65,7 +65,7 @@ Let the user type a free-form description. This becomes the `user_description` f 2. Check `gh auth status` — user must be authenticated to file issues. -3. Read plugin version from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json`. +3. Get the plugin version by running `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh`. 4. Read `## Arness` config from the project's CLAUDE.md (if it exists). @@ -75,7 +75,7 @@ If GitHub access is not available, offer an alternative: generate the diagnostic ### Step 4: Invoke arn-code-doctor -Spawn the `arn-code-doctor` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Spawn the `arn-code-doctor` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: - The user's description of the issue - Project root path - `## Arness` config content (or "not configured") diff --git a/plugins/arn-code/skills/arn-code-report/references/arness-knowledge-base.md b/plugins/arn-code/skills/arn-code-report/references/arness-knowledge-base.md index af04974..3930679 100644 --- a/plugins/arn-code/skills/arn-code-report/references/arness-knowledge-base.md +++ b/plugins/arn-code/skills/arn-code-report/references/arness-knowledge-base.md @@ -172,7 +172,7 @@ The thorough tier also produces a CHANGE_RECORD.json in the project root: | GitHub-dependent skills fail | gh CLI not installed, not authenticated, or no GitHub remote | Run `gh auth status` and `git remote -v` | | Labels not created during arn-code-init | gh auth lacks permission, or GitHub detection returned no | Check Git/GitHub fields in config, run `gh auth status` | | PR creation fails in arn-code-ship | Not on a feature branch, no commits ahead of main, or gh not authenticated | Check `git branch --show-current`, `git log main..HEAD`, `gh auth status` | -| Template version mismatch | Plugin was updated but project templates are from an older version | Compare `Template version` in config with version in plugin.json | +| Template version mismatch | Plugin was updated but project templates are from an older version | Compare `Template version` in config with the output of `plugin-version.sh` | | Pattern docs incomplete | arn-code-codebase-analyzer or arn-code-pattern-architect returned partial output | Check pattern doc files exist and have content | | Bitbucket skills fail | `bkt` not installed or not authenticated | Run `bkt --version` and `bkt auth status` | | Jira skills fail | Atlassian MCP server not configured or auth expired | Run `/mcp` to check server status, check `.mcp.json` | @@ -348,6 +348,6 @@ Maintainers update this section when bumping the plugin version to document what ## Version Information -- Plugin version is in `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json` (field: `version`) +- Plugin version comes from `skills/arn-code-ensure-config/scripts/plugin-version.sh` (`plugin.json` has no `version`; the marketplace entry is authoritative) - Template version in user config tracks which plugin version templates were copied from - Skill versions are in each SKILL.md frontmatter (field: `version`) diff --git a/plugins/arn-code/skills/arn-code-report/references/issue-template.md b/plugins/arn-code/skills/arn-code-report/references/issue-template.md index a28539d..26a0019 100644 --- a/plugins/arn-code/skills/arn-code-report/references/issue-template.md +++ b/plugins/arn-code/skills/arn-code-report/references/issue-template.md @@ -9,7 +9,7 @@ The issue body follows this structure: ```markdown ## Arness Code Report -**Plugin version:** <version from plugin.json> +**Plugin version:** <output of plugin-version.sh> **Skill(s) involved:** <skill names identified by the arn-code-doctor diagnostic> ### User Report diff --git a/plugins/arn-code/skills/arn-code-review-plan/SKILL.md b/plugins/arn-code/skills/arn-code-review-plan/SKILL.md index ab0c915..f09e0af 100644 --- a/plugins/arn-code/skills/arn-code-review-plan/SKILL.md +++ b/plugins/arn-code/skills/arn-code-review-plan/SKILL.md @@ -72,7 +72,7 @@ Suggested fixes must be specific and actionable. Examples: Validate that references in the plan actually exist in the codebase: -1. **Codebase References table** — Check that file paths listed in the INTRODUCTION.md "Codebase References" table actually exist on disk (use Glob for each path) +1. **Codebase References table** — Check that file paths listed in the INTRODUCTION.md "Codebase References" table actually exist on disk (use Glob for each path, or `test -e` when Glob is not available) 2. **Pattern code examples** — Spot-check 2-3 code pattern examples from INTRODUCTION.md: read the referenced file and confirm the code snippet is real and matches 3. **Test fixtures and helpers** — Verify test fixtures/helpers mentioned in INTRODUCTION.md testing patterns actually exist (use Grep to search for fixture/helper names in test files) diff --git a/plugins/arn-code/skills/arn-code-review-pr/SKILL.md b/plugins/arn-code/skills/arn-code-review-pr/SKILL.md index 832653f..2fda16d 100644 --- a/plugins/arn-code/skills/arn-code-review-pr/SKILL.md +++ b/plugins/arn-code/skills/arn-code-review-pr/SKILL.md @@ -1,15 +1,15 @@ --- name: arn-code-review-pr description: >- - This skill should be used when the user says "review PR", "review pull - request", "check PR comments", "review PR feedback", "review PR 123", - "analyze PR comments", "validate PR review", "address PR feedback", - "fix PR issues", "what did the reviewer say", "review Bitbucket PR", + This skill should be used when the user says "arn-code-review-pr", + "review PR feedback", "analyze PR comments", "validate PR review", + "review Bitbucket PR", or wants to validate GitHub or Bitbucket PR review comments, categorize findings, and optionally connect back into the Arness pipeline for fixes. Do NOT use this for creating PRs (use arn-code-ship) or reviewing implementation quality (use arn-code-review-implementation). version: 1.1.0 +argument-hint: "[pr-number-or-url]" --- # Arness Review PR diff --git a/plugins/arn-code/skills/arn-code-save-plan/SKILL.md b/plugins/arn-code/skills/arn-code-save-plan/SKILL.md index e1dbfa4..f4cb3de 100644 --- a/plugins/arn-code/skills/arn-code-save-plan/SKILL.md +++ b/plugins/arn-code/skills/arn-code-save-plan/SKILL.md @@ -10,6 +10,7 @@ description: >- conversation into an actionable phased project structure with implementation and testing plans. version: 2.0.0 +argument-hint: "[project-name]" --- # Arness Save Plan diff --git a/plugins/arn-code/skills/arn-code-save-plan/references/template-versioning.md b/plugins/arn-code/skills/arn-code-save-plan/references/template-versioning.md index 239fbd0..976c7e2 100644 --- a/plugins/arn-code/skills/arn-code-save-plan/references/template-versioning.md +++ b/plugins/arn-code/skills/arn-code-save-plan/references/template-versioning.md @@ -13,7 +13,7 @@ This procedure checks whether a project's report templates are up to date with t 2. Read `Template version` from `## Arness` (e.g., `0.1.0`). -3. Read `version` from `${CLAUDE_PLUGIN_ROOT}/.claude-plugin/plugin.json`. +3. Get the plugin version by running `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/scripts/plugin-version.sh`. 4. If versions match -- templates are up to date. Skip to main workflow. diff --git a/plugins/arn-code/skills/arn-code-save-plan/scripts/save_plan.sh b/plugins/arn-code/skills/arn-code-save-plan/scripts/save_plan.sh index 3ca0e12..8648a12 100755 --- a/plugins/arn-code/skills/arn-code-save-plan/scripts/save_plan.sh +++ b/plugins/arn-code/skills/arn-code-save-plan/scripts/save_plan.sh @@ -1,14 +1,15 @@ #!/bin/bash # save_plan.sh - Find plan file and create project structure -# Usage: save_plan.sh <PROJECT_NAME> <OUTPUT_DIR> [PLAN_FILE_PATH] +# Usage: save_plan.sh <PROJECT_NAME> <OUTPUT_DIR> [PLAN_FILE_PATH] [--force] # # PROJECT_NAME - Name for the project subdirectory (required) # OUTPUT_DIR - Base directory where <PROJECT_NAME>/ will be created (required) # PLAN_FILE_PATH - Path to a plan file. Can be: # 1. An absolute or relative path to a file (used directly) # 2. A filename to resolve in OUTPUT_DIR or OUTPUT_DIR/PLAN_PREVIEW_<name>.md -# 3. Omitted to auto-detect: checks PLAN_PREVIEW_*.md in OUTPUT_DIR, -# then falls back to ~/.claude/plans/ for legacy compatibility +# 3. Omitted to auto-detect: uses the single PLAN_PREVIEW_*.md in +# OUTPUT_DIR (errors if there are none or several) +# --force - Replace an existing SOURCE_PLAN.md that differs from the plan # # Examples: # save_plan.sh my-feature .arness/plans @@ -20,6 +21,7 @@ set -e PROJECT_NAME="$1" OUTPUT_DIR="$2" PLAN_FILE="$3" +FORCE="$4" # --- Validate required arguments --- @@ -35,6 +37,13 @@ if [ -z "$OUTPUT_DIR" ]; then exit 1 fi +case "$PROJECT_NAME" in + .|..|*[!A-Za-z0-9._-]*) + echo "ERROR: PROJECT_NAME may only contain letters, digits, '.', '_' and '-': $PROJECT_NAME" + exit 1 + ;; +esac + # --- Context --- PROJECT_DIR="$OUTPUT_DIR/$PROJECT_NAME" @@ -45,23 +54,23 @@ if [ -n "$PLAN_FILE" ] && [ -f "$PLAN_FILE" ]; then # Explicit path provided and exists — use directly echo "Plan: $(basename "$PLAN_FILE")" elif [ -z "$PLAN_FILE" ]; then - # No plan file specified: check for PLAN_PREVIEW in output dir, then legacy - PLAN_FILE=$(ls -t "$OUTPUT_DIR"/PLAN_PREVIEW_*.md 2>/dev/null | head -1) - if [ -z "$PLAN_FILE" ]; then - LEGACY_DIR="$HOME/.claude/plans" - if [ -d "$LEGACY_DIR" ]; then - PLAN_FILE=$(ls -t "$LEGACY_DIR"/*.md 2>/dev/null | head -1) - if [ -n "$PLAN_FILE" ]; then - echo "Plan (legacy): $(basename "$PLAN_FILE")" - fi - fi - else - echo "Plan: $(basename "$PLAN_FILE")" - fi - if [ -z "$PLAN_FILE" ]; then + # No plan file specified: use the only PLAN_PREVIEW in the output dir. + # Never guess from other projects' plans (e.g. ~/.claude/plans). + count=0 + for f in "$OUTPUT_DIR"/PLAN_PREVIEW_*.md; do + [ -f "$f" ] || continue + count=$((count + 1)) + PLAN_FILE="$f" + done + if [ "$count" -eq 0 ]; then echo "ERROR: No plan found. Run /arn-code-plan to create one first." exit 1 fi + if [ "$count" -gt 1 ]; then + echo "ERROR: Several PLAN_PREVIEW files in $OUTPUT_DIR. Pass the plan file to use." + exit 1 + fi + echo "Plan: $(basename "$PLAN_FILE")" else # Provided value is not a direct file path — try resolving if [ -f "$OUTPUT_DIR/$PLAN_FILE" ]; then @@ -89,6 +98,12 @@ if [ -d "$PROJECT_DIR" ]; then echo "WARNING: Project directory already exists: $PROJECT_DIR" fi +if [ -f "$PROJECT_DIR/SOURCE_PLAN.md" ] && ! cmp -s "$PLAN_FILE" "$PROJECT_DIR/SOURCE_PLAN.md" && [ "$FORCE" != "--force" ]; then + echo "ERROR: $PROJECT_DIR/SOURCE_PLAN.md already exists and differs from $(basename "$PLAN_FILE")." + echo "Re-run with --force as the 4th argument to replace it." + exit 1 +fi + mkdir -p "$PROJECT_DIR/plans" mkdir -p "$PROJECT_DIR/reports" @@ -103,4 +118,4 @@ echo " ├── SOURCE_PLAN.md (from: $(basename "$PLAN_FILE"))" echo " ├── plans/" echo " └── reports/" echo "" -echo "Plan: $(wc -l < "$PLAN_FILE") lines" +echo "Plan: $(wc -l < "$PLAN_FILE" | tr -d ' ') lines" diff --git a/plugins/arn-code/skills/arn-code-ship/SKILL.md b/plugins/arn-code/skills/arn-code-ship/SKILL.md index 2da0992..0043123 100644 --- a/plugins/arn-code/skills/arn-code-ship/SKILL.md +++ b/plugins/arn-code/skills/arn-code-ship/SKILL.md @@ -1,11 +1,8 @@ --- name: arn-code-ship description: >- - This skill should be used when the user says "ship it", "arness code ship", - "create PR", "open pull request", "push and PR", "commit and push", - "wrap up", "ship the feature", "ship the fix", "ready to ship", - "push changes", "finalize", "finish up", or wants - to commit, push, and optionally open a pull request. Guides through branching, + This skill should be used when the user says "arness code ship", "arn-code-ship", + or wants to commit, push, and optionally open a pull request. Guides through branching, staging, committing with meaningful messages, pushing, and PR creation. Works standalone or as the final Arness pipeline step. Do NOT use this for reviewing PRs — use /arn-code-review-pr for that. diff --git a/plugins/arn-code/skills/arn-code-simplify/SKILL.md b/plugins/arn-code/skills/arn-code-simplify/SKILL.md index d9d7bbd..355ea3c 100644 --- a/plugins/arn-code/skills/arn-code-simplify/SKILL.md +++ b/plugins/arn-code/skills/arn-code-simplify/SKILL.md @@ -78,7 +78,7 @@ Hold this context for use throughout the workflow. > Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-simplify/references/review-prompts.md` for the three reviewer prompt templates and output format. -Dispatch three Agent tool calls **in a single message** so they run in parallel. Each call passes the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-reviewer`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/step-0-fast-path.md` "Dispatch convention" for fallback behavior). The three reviewers share the same synthetic name — apply the multi-agent rule by passing the looked-up value to each call independently. +Dispatch three Agent tool calls **in a single message** so they run in parallel. Each call passes the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-reviewer`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback behavior). The three reviewers share the same synthetic name — apply the multi-agent rule by passing the looked-up value to each call independently. 1. **Code Reuse Reviewer** -- fill the review-prompts.md template with the file list and pattern documentation. Instruct the agent to focus on duplicated logic, missed utilities, and copy-paste patterns. @@ -159,7 +159,7 @@ The user may also change individual finding statuses (e.g., "approve SIM-001 but The orchestrator pre-sorts the approved findings by dependency order (if finding B depends on finding A's changes, A comes first), then dispatches a single anonymous Agent call to perform the apply work. The model is configurable via the agent-models config. -**Dispatch the applier as an anonymous Agent tool call**, passing the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-applier`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/step-0-fast-path.md` "Dispatch convention" for fallback behavior). Do NOT add any tool restriction — the applier inherits `Edit`, `Write`, `Bash`, `Read`, `Grep`, `Glob` from the orchestrator's toolbelt by default, and needs all of them. +**Dispatch the applier as an anonymous Agent tool call**, passing the model from `.arness/agent-models/code.md` (look up `arn-code-simplify-applier`) as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback behavior). Do NOT add any tool restriction — the applier inherits `Edit`, `Write`, `Bash`, `Read`, `Grep`, `Glob` from the orchestrator's toolbelt by default, and needs all of them. **Applier prompt contents:** @@ -171,16 +171,16 @@ The orchestrator pre-sorts the approved findings by dependency order (if finding ``` For each finding in the provided list, IN ORDER: -1. Capture pre-state: `git diff --no-color HEAD > /tmp/pre-{findingId}.diff` +1. Snapshot the files you will touch: `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-simplify/scripts/snapshot.sh save {findingId} {filesAffected}`. If you later need to edit a file not in that list (including during self-healing), run the same `save` command for it BEFORE the edit. 2. Apply the suggested fix (Edit/Write the affected files). 3. Run the targeted test command. Capture stdout+stderr. -4. If tests pass: emit `[FINDING-{findingId}: applied]` to stdout. Record status `"applied"`. Continue to next finding. +4. If tests pass: run `snapshot.sh drop {findingId}`, then emit `[FINDING-{findingId}: applied]` to stdout. Record status `"applied"`. Continue to next finding. 5. If tests fail: attempt self-healing. - Re-read the test output to identify the failure cause. - Make a fix attempt (Edit the file). - Re-run the targeted test command. - Up to 3 self-heal attempts per finding. -6. If tests still fail after 3 attempts: revert this finding's changes via `git apply -R /tmp/pre-{findingId}.diff` (or, if the diff is empty because no prior changes existed, run `git checkout -- {filesAffected}`). Emit `[FINDING-{findingId}: reverted - <reason>]` to stdout. Record status `"reverted"` with the failure reason and last test output. Continue to next finding. +6. If tests still fail after 3 attempts: revert this finding's changes via `bash ${CLAUDE_PLUGIN_ROOT}/skills/arn-code-simplify/scripts/snapshot.sh restore {findingId}`. This restores only the snapshotted files and leaves all other uncommitted work alone. Never use `git checkout`, `git stash` or `git apply -R` here. Emit `[FINDING-{findingId}: reverted - <reason>]` to stdout. Record status `"reverted"` with the failure reason and last test output. Continue to next finding. 7. Always emit a per-finding status line so the user sees progress in the transcript. After processing all findings, run ONE final targeted test pass to verify the cumulative state is consistent. Capture the result. diff --git a/plugins/arn-code/skills/arn-code-simplify/scripts/snapshot.sh b/plugins/arn-code/skills/arn-code-simplify/scripts/snapshot.sh new file mode 100755 index 0000000..07f5d4a --- /dev/null +++ b/plugins/arn-code/skills/arn-code-simplify/scripts/snapshot.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Per-finding file snapshots for the simplify applier. +# +# snapshot.sh save <finding-id> <file>... copy files before the first edit +# snapshot.sh restore <finding-id> put those files back exactly +# snapshot.sh drop <finding-id> forget a snapshot after success +# +# Only the files named for a finding are saved and restored, so other +# uncommitted work in the tree is never touched. "save" is idempotent: a file +# already saved for this finding keeps its first copy. A file that did not exist +# at save time is deleted on restore. Snapshots live in .arness/.simplify-tmp/ +# (project-local, so parallel runs in other worktrees do not collide). + +set -u + +die() { echo "snapshot: $1" >&2; exit 1; } + +root=$(git rev-parse --show-toplevel 2>/dev/null) || root=$(pwd) +cd "$root" || die "cannot enter project root" + +cmd="${1:-}"; id="${2:-}" +[ -n "$cmd" ] && [ -n "$id" ] || die "usage: snapshot.sh save|restore|drop <finding-id> [file...]" +case "$id" in *[!A-Za-z0-9._-]*) die "invalid finding id: $id" ;; esac +shift 2 + +dir=".arness/.simplify-tmp/$id" +manifest="$dir/manifest" + +case "$cmd" in + save) + mkdir -p "$dir/files" || die "cannot create $dir" + touch "$manifest" + for f in "$@"; do + case "$f" in /*|*..*) die "path must be relative to the project root: $f" ;; esac + if grep -qxF "E $f" "$manifest" || grep -qxF "N $f" "$manifest"; then continue; fi + if [ -f "$f" ]; then + mkdir -p "$dir/files/$(dirname "$f")" + cp -p "$f" "$dir/files/$f" || die "cannot copy $f" + printf 'E %s\n' "$f" >> "$manifest" + else + printf 'N %s\n' "$f" >> "$manifest" + fi + done + ;; + restore) + [ -f "$manifest" ] || die "no snapshot for $id" + while IFS= read -r line; do + kind="${line%% *}"; f="${line#* }" + if [ "$kind" = "E" ]; then + mkdir -p "$(dirname "$f")" + cp -p "$dir/files/$f" "$f" || die "cannot restore $f" + else + rm -f "$f" + fi + done < "$manifest" + rm -rf "$dir" + ;; + drop) + rm -rf "$dir" + ;; + *) die "unknown command: $cmd" ;; +esac diff --git a/plugins/arn-code/skills/arn-code-sketch/SKILL.md b/plugins/arn-code/skills/arn-code-sketch/SKILL.md index 96e59b2..979c6df 100644 --- a/plugins/arn-code/skills/arn-code-sketch/SKILL.md +++ b/plugins/arn-code/skills/arn-code-sketch/SKILL.md @@ -173,7 +173,7 @@ See the arn-code-sketch-builder agent Step 6 for the full schema including `comp ### Step 5: Spawn the Builder Agent -Spawn the `arn-code-sketch-builder` agent via the Task tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `plugins/arn-code/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: +Spawn the `arn-code-sketch-builder` agent via the Agent tool, passing the model from `.arness/agent-models/code.md` as the `model` parameter (see `${CLAUDE_PLUGIN_ROOT}/skills/arn-code-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context: --- SKETCH CONTEXT --- **Feature:** [feature name and description] diff --git a/plugins/arn-code/skills/arn-code-standard/SKILL.md b/plugins/arn-code/skills/arn-code-standard/SKILL.md index 1cbfae1..5b4b2f7 100644 --- a/plugins/arn-code/skills/arn-code-standard/SKILL.md +++ b/plugins/arn-code/skills/arn-code-standard/SKILL.md @@ -1,8 +1,7 @@ --- name: arn-code-standard description: >- - This skill should be used when the user says "standard", "standard mode", - "standard implementation", "arn-code-standard", "standard change", + This skill should be used when the user says "arn-code-standard", "standard change", "medium change", "standard feature", "standard fix", or wants a mid-ceremony implementation for a change that needs lightweight architectural context (spec-lite) and task-tracked execution but not the full diff --git a/plugins/arn-code/skills/arn-code-swift/SKILL.md b/plugins/arn-code/skills/arn-code-swift/SKILL.md index bb7f281..99900b1 100644 --- a/plugins/arn-code/skills/arn-code-swift/SKILL.md +++ b/plugins/arn-code/skills/arn-code-swift/SKILL.md @@ -1,11 +1,11 @@ --- name: arn-code-swift description: >- - This skill should be used when the user says "swift", "arness code swift", - "quick change", "small change", "just do this", "quick feature", - "quick implementation", "swift fix", "implement this quickly", + This skill should be used when the user says "arness code swift", + "small change", "just do this", "quick feature", + "swift fix", "implement this quickly", "add this quickly", "simple change", "just implement this", - "arn-code-swift", "swift mode", "quick task", + "arn-code-swift", "quick task", or wants a lightweight, pattern-aware implementation for a small feature or enhancement (1-8 files) without going through the full Arness pipeline. Bridges the gap between raw Claude Code and the full feature-spec/plan diff --git a/plugins/arn-code/skills/arn-implementing/SKILL.md b/plugins/arn-code/skills/arn-implementing/SKILL.md index 03e8cb5..f0f745f 100644 --- a/plugins/arn-code/skills/arn-implementing/SKILL.md +++ b/plugins/arn-code/skills/arn-implementing/SKILL.md @@ -30,7 +30,7 @@ After Step 0 completes, extract the following from `## Arness`: ## Workflow -### Step 0: Input Routing +### Step 0.5: Input Routing Check the trigger message for swift or standard intent: diff --git a/scripts/ci/validate-arn-code.py b/scripts/ci/validate-arn-code.py new file mode 100755 index 0000000..07fed18 --- /dev/null +++ b/scripts/ci/validate-arn-code.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +"""Static checks for the arn-code plugin. + +Run from the repository root: python3 scripts/ci/validate-arn-code.py +Exits non-zero and prints one line per problem. +""" + +import json +import os +import re +import sys + +ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +PLUGIN = os.path.join(ROOT, "plugins", "arn-code") +problems = [] + + +def problem(path, msg): + problems.append(f"{os.path.relpath(path, ROOT)}: {msg}") + + +def frontmatter(path): + text = open(path, encoding="utf-8").read() + m = re.match(r"^---\n(.*?)\n---\n", text, re.S) + if not m: + problem(path, "missing YAML frontmatter") + return None, text + fm, fields, key = m.group(1), {}, None + for line in fm.splitlines(): + km = re.match(r"^([A-Za-z][\w-]*):\s*(.*)$", line) + if km: + key = km.group(1) + fields[key] = km.group(2).strip() + elif key and line.startswith((" ", "\t")): + fields[key] += " " + line.strip() + for k, v in fields.items(): + if v.startswith((">-", ">", "|-", "|")): + fields[k] = v.split(" ", 1)[1] if " " in v else "" + fields[k] = fields[k].strip().strip('"').strip("'") + return fields, text + + +# --- skills --- +skills_dir = os.path.join(PLUGIN, "skills") +skill_names = set() +for name in sorted(os.listdir(skills_dir)): + path = os.path.join(skills_dir, name, "SKILL.md") + if not os.path.isfile(path): + continue + skill_names.add(name) + fm, _ = frontmatter(path) + if fm is None: + continue + if fm.get("name") != name: + problem(path, f"name '{fm.get('name')}' does not match directory '{name}'") + desc = fm.get("description", "") + if not desc: + problem(path, "missing description") + elif len(desc) > 1024: + problem(path, f"description is {len(desc)} chars (max 1024)") + if "version" not in fm: + problem(path, "missing version") + +# --- agents --- +agents_dir = os.path.join(PLUGIN, "agents") +agent_names = set() +for fname in sorted(os.listdir(agents_dir)): + if not fname.endswith(".md"): + continue + path = os.path.join(agents_dir, fname) + fm, _ = frontmatter(path) + if fm is None: + continue + name = fname[:-3] + agent_names.add(name) + if fm.get("name") != name: + problem(path, f"name '{fm.get('name')}' does not match file name") + for field in ("description", "tools", "model"): + if not fm.get(field): + problem(path, f"missing {field}") + +# --- agent model presets list every agent --- +presets = os.path.join(skills_dir, "arn-code-init", "references", "agent-models-presets") +if os.path.isdir(presets): + for fname in sorted(os.listdir(presets)): + if not fname.endswith(".md"): + continue + path = os.path.join(presets, fname) + text = open(path, encoding="utf-8").read() + for agent in sorted(agent_names): + if not re.search(rf"\b{re.escape(agent)}\b", text): + problem(path, f"agent '{agent}' has no model entry") + +# --- path references inside the plugin --- +ref_re = re.compile(r"\$\{CLAUDE_PLUGIN_ROOT\}/([A-Za-z0-9_./-]+)(?![<{*A-Za-z0-9_./-])") +bare_re = re.compile(r"(?<!\})/?plugins/arn-code/") +home_re = re.compile(r"/home/(?!user/|username/|<)[a-z][a-z0-9_-]*/|/Users/(?!user/|username/|<)[A-Za-z][\w-]*/") +for dirpath, _, files in os.walk(PLUGIN): + for fname in files: + if not fname.endswith((".md", ".sh", ".json")): + continue + path = os.path.join(dirpath, fname) + text = open(path, encoding="utf-8").read() + for ref in sorted(set(ref_re.findall(text))): + target = ref.rstrip(".") + if "<" in target or "*" in target: + continue + if not os.path.exists(os.path.join(PLUGIN, target)): + problem(path, f"reference to missing file ${{CLAUDE_PLUGIN_ROOT}}/{target}") + if fname != "CHANGELOG.md" and bare_re.search(text): + problem(path, "repo-relative 'plugins/arn-code/' path; use ${CLAUDE_PLUGIN_ROOT}/") + if home_re.search(text): + problem(path, "user-specific absolute path") + +# --- skills named in "Skill:" invocations exist --- +skill_call = re.compile(r"Skill:\s*`?arn-code:([a-z0-9-]+)") +for dirpath, _, files in os.walk(PLUGIN): + for fname in files: + if fname.endswith(".md"): + path = os.path.join(dirpath, fname) + for called in skill_call.findall(open(path, encoding="utf-8").read()): + if called not in skill_names: + problem(path, f"invokes unknown skill arn-code:{called}") + +# --- hooks --- +hooks_json = os.path.join(PLUGIN, "hooks", "hooks.json") +if os.path.isfile(hooks_json): + try: + hooks = json.load(open(hooks_json)) + except ValueError as exc: + problem(hooks_json, f"invalid JSON: {exc}") + hooks = {} + for event, groups in hooks.get("hooks", {}).items(): + for group in groups: + for hook in group.get("hooks", []): + for script in re.findall(r"\$\{CLAUDE_PLUGIN_ROOT\}/([\w./-]+\.sh)", hook.get("command", "")): + if not os.path.isfile(os.path.join(PLUGIN, script)): + problem(hooks_json, f"{event} hook script missing: {script}") + +# --- marketplace entry --- +market = json.load(open(os.path.join(ROOT, ".claude-plugin", "marketplace.json"))) +entry = next((p for p in market["plugins"] if p["name"] == "arn-code"), None) +if not entry or not re.match(r"^\d+\.\d+\.\d+$", entry.get("version", "")): + problem(os.path.join(ROOT, ".claude-plugin", "marketplace.json"), "arn-code entry needs a semver version") +plugin_json = json.load(open(os.path.join(PLUGIN, ".claude-plugin", "plugin.json"))) +if "version" in plugin_json: + problem(os.path.join(PLUGIN, ".claude-plugin", "plugin.json"), "must not set version (marketplace entry is authoritative)") + +for p in problems: + print(p) +print(f"{len(skill_names)} skills, {len(agent_names)} agents checked; {len(problems)} problem(s)") +sys.exit(1 if problems else 0) diff --git a/tests/arn-code/run-tests.sh b/tests/arn-code/run-tests.sh new file mode 100755 index 0000000..3decab6 --- /dev/null +++ b/tests/arn-code/run-tests.sh @@ -0,0 +1,174 @@ +#!/usr/bin/env bash +# Shell tests for arn-code scripts and hooks. Bash 3.2 compatible (macOS). +# Run from anywhere: bash tests/arn-code/run-tests.sh + +set -u + +REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +export CLAUDE_PLUGIN_ROOT="$REPO/plugins/arn-code" +unset CLAUDE_PROJECT_DIR ARNESS_HOOKS ARNESS_HOOKS_DISABLE +CFG="$CLAUDE_PLUGIN_ROOT/skills/arn-code-ensure-config/scripts" +HOOKS="$CLAUDE_PLUGIN_ROOT/hooks" +SNAP="$CLAUDE_PLUGIN_ROOT/skills/arn-code-simplify/scripts/snapshot.sh" +SAVE="$CLAUDE_PLUGIN_ROOT/skills/arn-code-save-plan/scripts/save_plan.sh" + +WORK=$(mktemp -d "${TMPDIR:-/tmp}/arn-code-tests.XXXXXX") +trap 'rm -rf "$WORK"' EXIT +export HOME="$WORK/home"; mkdir -p "$HOME" +export GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t + +pass=0; fail=0 +ok() { pass=$((pass + 1)); echo "ok - $1"; } +nok() { fail=$((fail + 1)); echo "FAIL - $1"; } +check() { if [ "$2" = "$3" ]; then ok "$1"; else nok "$1 (expected '$3', got '$2')"; fi; } + +json_str() { printf '"%s"' "$(printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g')"; } +. "$CFG/lib.sh" +PY=$(arn_python) || echo "note: no Python 3; lint tests skipped" + +hook_input() { printf '{"cwd":%s,"source":%s,"tool_input":{"command":%s,"file_path":%s}}' \ + "$(json_str "$1")" "$(json_str "$2")" "$(json_str "$3")" "$(json_str "$4")"; } +decision() { if [ -n "$1" ]; then echo deny; else echo allow; fi; } + +new_project() { + local d="$WORK/$1" + mkdir -p "$d" && cd "$d" && git init -q + printf '# P\r\n\r\n## Arness\r\n\r\n- **Plans directory:** .arness/plans\r\n- **Code patterns:** .arness\r\n- **Linting:** %s\r\n- **Platform:** none\r\n\r\n## Other\r\n' "$2" > CLAUDE.md + git add -A && git commit -qm init +} + +# ---------------- cache ---------------- +new_project cache skip +bash "$CFG/cache-check.sh" 2>/dev/null; check "cache: miss without a cache file" "$?" 1 +bash "$CFG/cache-write.sh" >/dev/null; check "cache: write succeeds" "$?" 0 +bash "$CFG/cache-check.sh" 2>/dev/null; check "cache: hit right after write (CRLF CLAUDE.md)" "$?" 0 +mkdir -p sub && (cd sub && bash "$CFG/cache-check.sh" 2>/dev/null); check "cache: hit from a subdirectory" "$?" 0 +printf 'extra\n' >> CLAUDE.md +bash "$CFG/cache-check.sh" 2>/dev/null; check "cache: edit outside ## Arness keeps the hit" "$?" 0 +awk '{sub(/Linting:\*\* skip/, "Linting:** none")} {print}' CLAUDE.md > c && mv c CLAUDE.md +bash "$CFG/cache-check.sh" 2>/dev/null; check "cache: edit inside ## Arness misses" "$?" 1 +check "version: resolved from marketplace.json" "$(bash "$CFG/plugin-version.sh")" \ + "$(sed -n '/"name": *"arn-code"/,/"version"/s/.*"version": *"\([^"]*\)".*/\1/p' "$REPO/.claude-plugin/marketplace.json")" + +# ---------------- snapshot ---------------- +new_project snap skip +echo base > keep.txt; echo b > "sp ace.txt"; git add -A && git commit -qm files +echo "uncommitted work" >> keep.txt +bash "$SNAP" save SIM-1 "sp ace.txt" new.txt +echo changed > "sp ace.txt"; echo created > new.txt +bash "$SNAP" restore SIM-1 +check "snapshot: restores the edited file" "$(cat "sp ace.txt")" b +check "snapshot: removes a file that did not exist" "$([ -e new.txt ] && echo yes || echo no)" no +check "snapshot: leaves other uncommitted work alone" "$(tail -1 keep.txt)" "uncommitted work" +bash "$SNAP" save ../x a 2>/dev/null; check "snapshot: rejects a bad id" "$?" 1 + +# ---------------- save_plan ---------------- +new_project save skip +mkdir -p plans +bash "$SAVE" ../evil plans >/dev/null; check "save_plan: rejects path in project name" "$?" 1 +bash "$SAVE" p plans >/dev/null; check "save_plan: no preview is an error" "$?" 1 +echo "# A" > plans/PLAN_PREVIEW_a.md +bash "$SAVE" a plans >/dev/null; check "save_plan: single preview is used" "$?" 0 +echo "# B" > plans/PLAN_PREVIEW_b.md +bash "$SAVE" b plans >/dev/null; check "save_plan: several previews need an explicit file" "$?" 1 +bash "$SAVE" a plans plans/PLAN_PREVIEW_b.md >/dev/null; check "save_plan: no silent overwrite" "$?" 1 +bash "$SAVE" a plans plans/PLAN_PREVIEW_b.md --force >/dev/null; check "save_plan: --force overwrites" "$(cat plans/a/SOURCE_PLAN.md)" "# B" + +# ---------------- hooks: outside Arness ---------------- +mkdir -p "$WORK/plain" && cd "$WORK/plain" && git init -q +check "hooks: silent outside Arness projects" \ + "$(hook_input "$WORK/plain" "" "git push --force" "" | bash "$HOOKS/pre-bash.sh")" "" + +# ---------------- hooks: off by default ---------------- +new_project hooks enabled +check "hooks: off by default" "$(decision "$(hook_input "$PWD" "" "git push --force" "" | bash "$HOOKS/pre-bash.sh")")" allow +check "hooks: ARNESS_HOOKS=on turns them on" "$(decision "$(hook_input "$PWD" "" "git push --force" "" | ARNESS_HOOKS=on bash "$HOOKS/pre-bash.sh")")" deny +awk '/^## Other/{print "- **Hooks:** on"; print ""} {print}' CLAUDE.md > c && mv c CLAUDE.md +check "hooks: the Hooks field turns them on for the project" "$(decision "$(hook_input "$PWD" "" "git push --force" "" | bash "$HOOKS/pre-bash.sh")")" deny +check "hooks: ARNESS_HOOKS=off wins over the Hooks field" "$(decision "$(hook_input "$PWD" "" "git push --force" "" | ARNESS_HOOKS=off bash "$HOOKS/pre-bash.sh")")" allow +check "hooks: session start is silent when off" "$(hook_input "$PWD" startup "" "" | ARNESS_HOOKS=off bash "$HOOKS/session-start.sh")" "" +git add -A && git commit -qm hooks-on + +# ---------------- hooks: session start ---------------- +out=$(hook_input "$PWD" startup "" "" | bash "$HOOKS/session-start.sh") +case "$out" in *'"additionalContext"'*Arness*) ok "session-start: adds a status line" ;; *) nok "session-start: adds a status line ($out)" ;; esac +mkdir -p .arness/plans/feat-x && echo '{}' > .arness/plans/feat-x/PROGRESS_TRACKER.json +out=$(hook_input "$PWD" compact "" "" | bash "$HOOKS/session-start.sh") +case "$out" in *feat-x/PROGRESS_TRACKER.json*) ok "session-start: points at the plan after compaction" ;; *) nok "session-start: compaction pointer ($out)" ;; esac + +# ---------------- hooks: force push ---------------- +for c in "git push --force origin main" "git -C . push -f" "git push origin +main"; do + check "force-push: deny '$c'" "$(decision "$(hook_input "$PWD" "" "$c" "" | bash "$HOOKS/pre-bash.sh")")" deny +done +for c in "git push --force-with-lease origin main" "git push -u origin feat" "git status"; do + check "force-push: allow '$c'" "$(decision "$(hook_input "$PWD" "" "$c" "" | bash "$HOOKS/pre-bash.sh")")" allow +done +check "force-push: switch turns it off" \ + "$(decision "$(hook_input "$PWD" "" "git push -f" "" | ARNESS_HOOKS_DISABLE=force-push bash "$HOOKS/pre-bash.sh")")" allow + +# ---------------- hooks: secrets ---------------- +key="AKIA""ABCDEFGHIJKLMNOP" +echo "x = 1" > ok.txt && git add ok.txt +check "secrets: clean commit allowed" "$(decision "$(hook_input "$PWD" "" 'git commit -m ok' "" | bash "$HOOKS/pre-bash.sh")")" allow +echo "k = \"$key\"" > conf.txt && git add conf.txt +check "secrets: staged key denied" "$(decision "$(hook_input "$PWD" "" 'git commit -m c' "" | bash "$HOOKS/pre-bash.sh")")" deny +echo "k = \"$key\" # arness:allow-secret" > conf.txt && git add conf.txt +check "secrets: allow marker respected" "$(decision "$(hook_input "$PWD" "" 'git commit -m c' "" | bash "$HOOKS/pre-bash.sh")")" allow +git reset -q && rm -f conf.txt +echo "t=ghp_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" > new.txt +check "secrets: untracked key with 'git add .' denied" "$(decision "$(hook_input "$PWD" "" 'git add . && git commit -m x' "" | bash "$HOOKS/pre-bash.sh")")" deny +rm -f new.txt && touch .env +check "secrets: .env with 'git add -A' denied" "$(decision "$(hook_input "$PWD" "" 'git add -A && git commit -m e' "" | bash "$HOOKS/pre-bash.sh")")" deny +rm -f .env + +# ---------------- hooks: lint (needs Python) ---------------- +if [ -n "$PY" ]; then +cat > .arness/tooling.json <<'EOF' +{"version":1,"services":[ + {"path":".","extensions":[".src"],"lintFiles":"! grep -n BAD {files}","owner":"arness"}, + {"path":"svc/b","extensions":[".src"],"lintFiles":"exit 3","owner":"project"}]} +EOF +mkdir -p svc/b; echo "BAD line" > "a file.src"; echo BAD > svc/b/x.src; echo BAD > notes.txt +lint() { hook_input "$PWD" "" "" "$PWD/$1" | bash "$HOOKS/post-edit-lint.sh"; } +check "lint: silent until tooling.json is approved" "$(lint "a file.src")" "" +bash "$HOOKS/tooling-approve.sh" >/dev/null +case "$(lint "a file.src")" in *advisory*"a file.src"*) ok "lint: reports issues after approval" ;; *) nok "lint: reports issues after approval" ;; esac +check "lint: skips services the project owns" "$(lint svc/b/x.src)" "" +check "lint: skips other extensions" "$(lint notes.txt)" "" +echo " " >> .arness/tooling.json +check "lint: edited tooling.json needs new approval" "$(lint "a file.src")" "" +fi + +# ---------------- hooks: JSON without jq or Python ---------------- +. "$HOOKS/lib-hook.sh" +j='{"cwd":"C:\\Users\\me\\a \"b\"","n":3,"t":true,"z":null,"tool_input":{"content":"{\"cwd\":\"x\"}","list":[1,{"k":"v"}],"command":"git push \u002df\nnext"}}' +check "json: top-level string with escapes" "$(printf '%s' "$j" | arn_json_get cwd)" 'C:\Users\me\a "b"' +check "json: nested field after a lookalike in a string" "$(printf '%s' "$j" | arn_json_get tool_input.command)" "git push -f +next" +check "json: number, boolean, null, missing" "$(printf '%s' "$j" | arn_json_get n),$(printf '%s' "$j" | arn_json_get t),$(printf '%s' "$j" | arn_json_get z),$(printf '%s' "$j" | arn_json_get nope)" "3,true,," +check "json: array element" "$(printf '%s' "$j" | arn_json_get tool_input.list.1.k)" v + +# ---------------- Windows ---------------- +check "windows: C:\\ path to Git Bash form" "$(arn_unix_path 'C:\Users\me\my proj')" "/c/Users/me/my proj" +check "windows: D:/ path to Git Bash form" "$(arn_unix_path 'D:/work/x')" "/d/work/x" +check "windows: other paths unchanged" "$(arn_unix_path /home/me)" "/home/me" +if [ -n "$PY" ]; then +mkdir -p "$WORK/stub"; printf '#!/bin/sh\necho "Python was not found; run without arguments to install from the Microsoft Store"\nexit 9009\n' > "$WORK/stub/python3" +printf '#!/bin/sh\nexec "%s" "$@"\n' "$(command -v python3)" > "$WORK/stub/python"; chmod +x "$WORK/stub/python3" "$WORK/stub/python" +check "windows: broken python3 stub falls back to python" "$(PATH="$WORK/stub:$PATH" arn_python)" python +bash "$HOOKS/tooling-approve.sh" >/dev/null +case "$(hook_input "$PWD" "" "" "$PWD/a file.src" | PATH="$WORK/stub:$PATH" bash "$HOOKS/post-edit-lint.sh")" in *advisory*) ok "windows: lint works with a broken python3 stub" ;; *) nok "windows: lint works with a broken python3 stub" ;; esac +fi +if command -v cygpath >/dev/null 2>&1; then + W=$(cygpath -w "$PWD") + [ -n "$PY" ] && case "$(hook_input "$W" "" "" "$W\\a file.src" | bash "$HOOKS/post-edit-lint.sh")" in *advisory*) ok "windows: lint with C:\\ paths" ;; *) nok "windows: lint with C:\\ paths" ;; esac + check "windows: force-push blocked with a C:\\ cwd" "$(decision "$(hook_input "$W" "" "git push --force" "" | bash "$HOOKS/pre-bash.sh")")" deny + check "windows: secrets scan with a C:\\ cwd" "$(decision "$(echo "k = \"AKIA""ABCDEFGHIJKLMNOP\"" > w.txt && git add w.txt && hook_input "$W" "" 'git commit -m w' "" | bash "$HOOKS/pre-bash.sh")")" deny + git reset -q; rm -f w.txt + case "$(hook_input "$W" startup "" "" | bash "$HOOKS/session-start.sh")" in *Arness*) ok "windows: session start with a C:\\ cwd" ;; *) nok "windows: session start with a C:\\ cwd" ;; esac + check "windows: CLAUDE_PROJECT_DIR in C:\\ form" "$(cd / && CLAUDE_PROJECT_DIR="$W" bash -c '. "$1/lib.sh"; arn_cd_project_root && pwd -P' _ "$CFG")" "$(pwd -P)" +fi + +echo +echo "$pass passed, $fail failed" +[ "$fail" -eq 0 ]