From 8a46725b07db0e42f22de2a2448f66e80186cf7e Mon Sep 17 00:00:00 2001 From: "claude[bot]" Date: Tue, 21 Apr 2026 12:27:43 +0000 Subject: [PATCH 1/2] fix: move prepare lifecycle hook to explicit setup-hooks script npm's prepare hook runs on every `npm install` in any environment, causing the package to silently install git hooks into any consumer's repository without their explicit consent. This is unexpected behavior for a plugin package consumed by end users. Rename prepare to setup-hooks so contributors can opt in explicitly by running `npm run setup-hooks` after cloning, as now documented in CONTRIBUTING.md. Co-Authored-By: Claude Code --- CONTRIBUTING.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc8f00bd..0bcf5ca6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,6 +31,17 @@ PRs may receive AI-assisted reviews (Copilot, Claude, Gemini, Codex) at the owne ## Before You Start +### First-Time Setup + +After cloning the repo, install git hooks manually: + +```bash +npm install +npm run setup-hooks +``` + +The `setup-hooks` script installs pre-commit and pre-push hooks into your local `.git/hooks/`. It does **not** run automatically on `npm install` — you must opt in. + ### Multi-File Changes For changes touching multiple files, **read the relevant checklist first**: diff --git a/package.json b/package.json index 59698f81..f3fcb0b1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "detect": "node bin/dev-cli.js detect", "verify": "node bin/dev-cli.js verify", "version": "node scripts/stamp-version.js && git add -A", - "prepare": "node bin/dev-cli.js setup-hooks" + "setup-hooks": "node bin/dev-cli.js setup-hooks" }, "repository": { "type": "git", From 71a5055556c849f690189ab1da9c01fde05a4752 Mon Sep 17 00:00:00 2001 From: Avi Fenesh Date: Thu, 23 Apr 2026 16:20:08 +0300 Subject: [PATCH 2/2] fix(hooks): remove pre-commit placeholder + address bot review - Remove pre-commit hook installation - it was just a no-op placeholder ('lib/ sync now handled by agent-core'), so installing it was pure redundancy. Only the pre-push hook (preflight + /enhance reminder + release tag validation) actually does anything. - CONTRIBUTING.md: replace em-dash with single dash per workspace rule; update text to reflect that only pre-push is installed now. - docs/ARCHITECTURE.md: update setup-hooks.js comment - was 'npm prepare' before xiaolai's PR; now correctly noted as manual. --- CONTRIBUTING.md | 2 +- docs/ARCHITECTURE.md | 2 +- scripts/setup-hooks.js | 14 -------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0bcf5ca6..d88e4af1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,7 @@ npm install npm run setup-hooks ``` -The `setup-hooks` script installs pre-commit and pre-push hooks into your local `.git/hooks/`. It does **not** run automatically on `npm install` — you must opt in. +The `setup-hooks` script installs the pre-push hook into your local `.git/hooks/` (it runs preflight checks, an `/enhance` reminder, and release-tag validation). It does **not** run automatically on `npm install` - you must opt in. ### Multi-File Changes diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index f7cfbb46..fddd56ed 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -63,7 +63,7 @@ agentsys/ │ └── maintain-cross-platform/ # Cross-platform compatibility skill │ └── SKILL.md ├── scripts/ -│ ├── setup-hooks.js # Git hooks installer (npm prepare) +│ ├── setup-hooks.js # Git hooks installer (manual: npm run setup-hooks) │ └── graduate-plugin.js # Extract a plugin to a new standalone repo ├── docs/ # User documentation │ ├── CROSS_PLATFORM.md diff --git a/scripts/setup-hooks.js b/scripts/setup-hooks.js index f093de80..1bdad4d9 100644 --- a/scripts/setup-hooks.js +++ b/scripts/setup-hooks.js @@ -1,7 +1,6 @@ #!/usr/bin/env node /** * Setup git hooks for development - * - pre-commit: Placeholder (lib/ sync handled by agent-core CI) * - pre-push: Runs preflight checks, /enhance reminder, release validation */ @@ -9,13 +8,8 @@ const fs = require('fs'); const path = require('path'); const hookDir = path.join(__dirname, '..', '.git', 'hooks'); -const preCommitPath = path.join(hookDir, 'pre-commit'); const prePushPath = path.join(hookDir, 'pre-push'); -const preCommitHook = `#!/bin/sh -# Pre-commit hook (lib/ sync now handled by agent-core) -`; - const prePushHook = `#!/bin/sh # Pre-push validations: # 1. Run preflight checks (validators + gap checks) @@ -135,14 +129,6 @@ function main() { return 0; } - try { - fs.writeFileSync(preCommitPath, preCommitHook, { mode: 0o755 }); - console.log('Git pre-commit hook installed'); - } catch (err) { - // Non-fatal - might not have write permissions - console.warn('Could not install pre-commit hook:', err.message); - } - try { fs.writeFileSync(prePushPath, prePushHook, { mode: 0o755 }); console.log('Git pre-push hook installed (release tag validation)');