cortexhawk 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cortexhawk-lint.yml.example +21 -0
- package/.gitmessage +10 -0
- package/CHANGELOG.md +45 -0
- package/CLAUDE.md +12 -4
- package/agents/git-manager.md +6 -2
- package/commands/backlog.md +1 -1
- package/commands/cleanup.md +37 -0
- package/commands/review-pr.md +31 -0
- package/commands/ship.md +1 -0
- package/commands/task.md +1 -1
- package/cortexhawk +9 -3
- package/hooks/branch-guard.sh +8 -1
- package/hooks/codex-dispatcher.sh +3 -0
- package/hooks/compose.yml +6 -0
- package/hooks/file-guard.sh +4 -0
- package/hooks/hooks.json +6 -0
- package/hooks/lint-guard.sh +46 -0
- package/hooks/post-merge.sh +12 -0
- package/hooks/session-start.sh +1 -1
- package/install.sh +159 -962
- package/mcp/README.md +36 -0
- package/mcp/context7.json +1 -1
- package/mcp/github.json +11 -0
- package/mcp/puppeteer.json +1 -1
- package/mcp/sequential-thinking.json +1 -1
- package/package.json +1 -1
- package/profiles/api.json +2 -1
- package/profiles/fullstack.json +2 -1
- package/scripts/autodetect-profile.sh +1 -1
- package/scripts/doctor.sh +164 -0
- package/scripts/install-claude.sh +179 -0
- package/scripts/interactive-init.sh +3 -2
- package/scripts/lint-guard-runner.sh +132 -0
- package/scripts/post-merge-cleanup.sh +233 -0
- package/scripts/restore.sh +212 -0
- package/scripts/snapshot.sh +163 -0
- package/scripts/update.sh +280 -0
- package/settings.json +12 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# .cortexhawk-lint.yml — per-project lint-guard config (optional)
|
|
2
|
+
# Copy to .cortexhawk-lint.yml to override defaults.
|
|
3
|
+
# By default, all tools are auto-detected via their config files.
|
|
4
|
+
# Set a tool to false to disable it even if its config file is present.
|
|
5
|
+
|
|
6
|
+
formatters:
|
|
7
|
+
prettier: true # .prettierrc* / prettier.config.* / package.json "prettier"
|
|
8
|
+
black: true # pyproject.toml [tool.black]
|
|
9
|
+
gofmt: true # active if .go files staged (no config file required)
|
|
10
|
+
rustfmt: true # rustfmt.toml / .rustfmt.toml
|
|
11
|
+
stylelint: true # .stylelintrc* / stylelint.config.*
|
|
12
|
+
|
|
13
|
+
linters:
|
|
14
|
+
eslint: true # .eslintrc* / eslint.config.*
|
|
15
|
+
flake8: true # .flake8 / setup.cfg [flake8]
|
|
16
|
+
mypy: false # pyproject.toml [tool.mypy] / mypy.ini — set to false to disable (can be slow)
|
|
17
|
+
|
|
18
|
+
options:
|
|
19
|
+
run_on_push: false # run on git push too (overrides LINT_ON_PUSH in git-workflow.conf)
|
|
20
|
+
fail_on_formatter: false # block commit if a formatter fails (default: non-blocking)
|
|
21
|
+
timeout: 30 # max seconds per tool (requires timeout/gtimeout in PATH)
|
package/.gitmessage
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
# type(scope): subject
|
|
3
|
+
#
|
|
4
|
+
# Types: feat, fix, docs, style, refactor, test, chore, perf, security
|
|
5
|
+
# Scope: optional module/component name
|
|
6
|
+
# Subject: imperative mood, lowercase, no period, max 72 chars
|
|
7
|
+
#
|
|
8
|
+
# Body: explain WHY, not WHAT (the diff shows the what)
|
|
9
|
+
#
|
|
10
|
+
# Footer: BREAKING CHANGE: description | Closes #123 | Backlog #N
|
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,54 @@
|
|
|
3
3
|
All notable changes to CortexHawk are documented here.
|
|
4
4
|
Format: [Keep a Changelog](https://keepachangelog.com/)
|
|
5
5
|
|
|
6
|
+
## [3.3.1] - 2026-02-20
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- Native git `post-merge` hook opt-in: `cortexhawk post-merge-hook` (or `install --post-merge-hook`) installs `.git/hooks/post-merge` that auto-runs cleanup after every `git merge`; also offered interactively during `cortexhawk install` (#150)
|
|
10
|
+
- Gitflow strategy support in `post-merge-cleanup.sh`: dual-target merge detection (feat→develop, release/hotfix→main), conditional `release/*`/`hotfix/*` protection, resync `develop ← main` after release merges (#151)
|
|
11
|
+
|
|
12
|
+
### Security
|
|
13
|
+
- `codex-dispatcher.sh`: reject paths containing `../` before dispatch to hooks, preventing arbitrary file scanning via path traversal (#152)
|
|
14
|
+
- MCP configs: pin all `npx -y` packages to exact versions — context7@2.1.1, sequential-thinking@2025.12.18, puppeteer@2025.5.12, github@2025.4.8; also fix puppeteer package name (`@modelcontextprotocol/server-puppeteer` replaces removed `@anthropic-ai/mcp-server-puppeteer`) (#153)
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- `post-merge-cleanup.sh` refactored to dispatch-by-strategy architecture: central `PROTECTED_BRANCHES` list + `is_protected()`, extracted helpers (`delete_branch`, `delete_merged_branches`, `resync_work_branch`, `prompt_new_feature_branch`), strategy dispatch via `strategy_*()` functions + `case` (#149)
|
|
18
|
+
- `install.sh` modularized: extracted `install_claude()`, `do_update()`, `do_snapshot()`, `do_restore()`, `do_doctor()` into `scripts/` modules (4114 → 3168 lines, -23%); install.sh sources them before dispatch (#137)
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- `post-merge-cleanup.sh`: `MAIN_BRANCH` was assigned `WORK_BRANCH` value (e.g. `dev`) for `dev-branch` and `gitflow` strategies — merged-branch detection, resync, and post-cleanup were all targeting the wrong branch; now always `MAIN_BRANCH="main"` (#148)
|
|
22
|
+
- `post-merge-cleanup.sh`: script exited early when no merged branches, skipping resync for `dev-branch`/`gitflow`; resync now always runs after cleanup (#148)
|
|
23
|
+
- `post-merge-cleanup.sh`: added `--dry-run` flag (preview actions without executing) and resync block `WORK_BRANCH ← MAIN_BRANCH` with `--ff-only` + interactive merge fallback (#148)
|
|
24
|
+
- `cortexhawk update` crash when installed via npm: manifest's `source: "git"` was overriding runtime detection, causing `git pull` to run on the npm global dir (not a git repo); now validates SCRIPT_DIR is a real git repo before trusting manifest source (#154)
|
|
25
|
+
- `get_version()` in `cortexhawk` wrapper now skips `[Unreleased]` heading (fixes `self-update` version display)
|
|
26
|
+
- `branch-guard`: work branch (dev) was incorrectly added to `PROTECTED_BRANCHES` for `dev-branch` strategy, blocking all regular `git push origin dev` operations
|
|
27
|
+
|
|
28
|
+
## [3.3.0] - 2026-02-19
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- `lint-guard` Phase 3 performance: linters run in parallel (`&` + `wait` + tmpdir error signaling); detection results cached in `.claude/lint-guard-cache` (1hr TTL, safe key=value); hook extracted to `scripts/lint-guard-runner.sh` to stay within 150-line limit (#142)
|
|
32
|
+
- `lint-guard` advanced YAML options: `timeout` (per-tool kill with `timeout`/`gtimeout`, default 30s), `fail_on_formatter` (block commit on formatter failure, default false), `run_on_push` in yml (overrides git-workflow.conf) (#141)
|
|
33
|
+
- `lint-guard` pre-commit delegation: if `.pre-commit-config.yaml` + `pre-commit` CLI are present, lint-guard delegates entirely to the framework — no duplication for projects already using pre-commit (#143)
|
|
34
|
+
- `lint-guard` hook (PreToolUse): auto-detects formatters and linters on staged files before commit — formatters auto-fix + re-stage (prettier, black, gofmt, rustfmt, stylelint), linters check-only + block on errors (eslint, flake8, mypy); opt-out via `LINT_SKIP` in `git-workflow.conf` or `.cortexhawk-lint.yml` (#140)
|
|
35
|
+
- `/review-pr` command: fetch, triage, and address PR review comments — batch mode by default (one commit + one batched review reply = one notification); `--sequential` flag for complex interdependent threads (#145)
|
|
36
|
+
- MCP GitHub config: `mcp/github.json` (`@modelcontextprotocol/server-github`) — unlocks native GitHub API for `git-manager`, `/ship`, `pr-review-comments`, `/review-pr`; listed as recommended in fullstack + api profiles (#146)
|
|
37
|
+
- `/cleanup` command: delete merged local/remote branches, optional post-merge hook for auto-cleanup after PR merges (#139)
|
|
38
|
+
- Smart PR detection in `/ship`: reuses existing PR branch instead of creating duplicate branches when iterating with `/task` followed by review feedback (#138)
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- `branch-guard` hook: `git push --delete` (remote branch deletion) was incorrectly blocked when on a protected branch — `/cleanup` remote cleanup now works correctly
|
|
42
|
+
- `post-merge-cleanup.sh`: auto-detects missing TTY (`[ ! -t 0 ]`) and switches to auto mode — `/cleanup` called via Claude Bash tool or CI no longer hangs on `read` prompt
|
|
43
|
+
- `.gitignore`: add `docs/.context/` and `docs/.metrics/` — auto-generated session artifacts (snapshots, analytics logs, agent context) are ephemeral and should not be committed
|
|
44
|
+
- GitHub Actions (`claude.yml`, `claude-code-review.yml`): grant `pull-requests: write` + `issues: write` — Claude could read PRs but not post reviews or replies
|
|
45
|
+
- **Security (MEDIUM)**: replace predictable PID/timestamp temp paths with `mktemp` (portable, no `.json` suffix) in `autodetect-profile.sh` and `interactive-init.sh`
|
|
46
|
+
- **Security (MEDIUM)**: extend `.env` parser blocklist (`PYTHONPATH`, `GIT_SSH_COMMAND`, `NPM_CONFIG_*`, `NODE_OPTIONS`, `RUBYLIB`, `LD_AUDIT`, etc.) + add key format validation (`^[A-Z_][A-Z0-9_]{0,63}$`) to reject malformed variable names
|
|
47
|
+
- **Security (LOW)**: atomic `cache_set` in `lint-guard-runner.sh` via `mktemp` unique tmp + `mv` — eliminates race condition on concurrent hook invocations
|
|
48
|
+
- **Security**: replace `eval` with `xargs -0` in `lint-guard-runner.sh` — prevents command injection via crafted filenames in staged file lists
|
|
49
|
+
|
|
6
50
|
## [3.2.0] - 2026-02-15
|
|
7
51
|
|
|
8
52
|
### Added
|
|
53
|
+
- Component registry: `COMPONENTS` array + `copy_all_components`/`sync_all_components`/`count_component_files` — adding a new component is 1 line instead of modifying 5 functions
|
|
9
54
|
- `/commit` command: lightweight conventional commit + push without review or PR — use `/ship` for full workflow, `/commit` for quick iterations
|
|
10
55
|
- Install auto-detects existing PR/commit templates; generates CortexHawk defaults (`.github/PULL_REQUEST_TEMPLATE.md`, `.gitmessage`) if missing — agents (`git-manager`, `/ship`, `/commit`) read templates at runtime
|
|
11
56
|
- `--version` / `-v` flag: displays CortexHawk version
|
package/CLAUDE.md
CHANGED
|
@@ -6,13 +6,13 @@ Open-source development toolkit for Claude Code — optimized agents, skills, co
|
|
|
6
6
|
|
|
7
7
|
```
|
|
8
8
|
agents/ — 20 specialized AI agents
|
|
9
|
-
commands/ —
|
|
9
|
+
commands/ — 35 slash commands
|
|
10
10
|
scripts/ — Validation and post-install audit scripts
|
|
11
11
|
skills/ — 36 domain-specific knowledge modules
|
|
12
|
-
hooks/ —
|
|
12
|
+
hooks/ — 11 lifecycle hooks
|
|
13
13
|
modes/ — 7 behavioral presets
|
|
14
14
|
profiles/ — 3 install profiles (fullstack, api, data)
|
|
15
|
-
mcp/ — Pre-configured MCP server configs
|
|
15
|
+
mcp/ — Pre-configured MCP server configs (github, context7, sequential-thinking, puppeteer)
|
|
16
16
|
docs/ — Agent outputs (brainstorms, plans, decisions, research, audits, conversations, chains)
|
|
17
17
|
templates/ — Templates for contributing new components (agents, commands, skills, chain presets, personas)
|
|
18
18
|
CONTRIBUTING.md — Contribution guidelines
|
|
@@ -49,7 +49,7 @@ Custom agents in `.cortexhawk-agents/` at project root. Each `.md` file uses `ex
|
|
|
49
49
|
|
|
50
50
|
## Commands
|
|
51
51
|
|
|
52
|
-
`/plan` `/build` `/test` `/review` `/ship` `/commit` `/debug` `/scan` `/check` `/refactor` `/research` `/doc` `/bootstrap` `/tdd` `/optimize` `/migrate` `/monitor` `/api-gen` `/changelog` `/journal` `/brainstorm` `/simplify` `/deploy` `/export` `/backlog` `/pulse` `/map` `/learn` `/chain` `/task` `/ci` `/context` `/upgrade`
|
|
52
|
+
`/plan` `/build` `/test` `/review` `/review-pr` `/ship` `/commit` `/cleanup` `/debug` `/scan` `/check` `/refactor` `/research` `/doc` `/bootstrap` `/tdd` `/optimize` `/migrate` `/monitor` `/api-gen` `/changelog` `/journal` `/brainstorm` `/simplify` `/deploy` `/export` `/backlog` `/pulse` `/map` `/learn` `/chain` `/task` `/ci` `/context` `/upgrade`
|
|
53
53
|
|
|
54
54
|
## Skills
|
|
55
55
|
|
|
@@ -80,6 +80,7 @@ Custom agents in `.cortexhawk-agents/` at project root. Each `.md` file uses `ex
|
|
|
80
80
|
- `file-guard` (PreToolUse) — Blocks access to .env, secrets, keys
|
|
81
81
|
- `branch-guard` (PreToolUse) — Prevents direct push to protected branches
|
|
82
82
|
- `commit-guard` (PreToolUse) — Validates conventional commits, checks staged secrets
|
|
83
|
+
- `lint-guard` (PreToolUse) — Auto-detects formatters/linters on staged files; auto-fix for prettier/black/gofmt/rustfmt/stylelint, check-only for eslint/flake8/mypy
|
|
83
84
|
- `self-review` (PostToolUse) — Checks for TODO/FIXME, secrets, debug artifacts
|
|
84
85
|
- `dependency-check` (PostToolUse) — Alerts when dependency files are modified
|
|
85
86
|
- `test-reminder` (PostToolUse) — Reminds to update tests for modified source files
|
|
@@ -94,3 +95,10 @@ Custom agents in `.cortexhawk-agents/` at project root. Each `.md` file uses `ex
|
|
|
94
95
|
- Checklists > paragraphs, code examples > prose
|
|
95
96
|
- One responsibility per component
|
|
96
97
|
- All agents follow: frontmatter → description → Process → Output Format → Rules
|
|
98
|
+
|
|
99
|
+
## Git Workflow
|
|
100
|
+
|
|
101
|
+
- **Branching**: dev-branch (working branch: dev)
|
|
102
|
+
- **Commits**: conventional
|
|
103
|
+
- **PR preference**: on-demand
|
|
104
|
+
- **Auto-push**: after-commit
|
package/agents/git-manager.md
CHANGED
|
@@ -11,9 +11,10 @@ You are a release engineer managing version control workflows.
|
|
|
11
11
|
|
|
12
12
|
0. **Context** — Read `docs/.context/_shared.md` and `docs/.context/git-manager.md`
|
|
13
13
|
1. **Assess** — Review current branch state, staged changes, and recent history
|
|
14
|
+
1.5. **Detect PR** — Run `gh pr view --json state,url 2>/dev/null`, parse output; if PR exists with state=OPEN, note branch has active PR (skip creation later); if gh fails or no PR, proceed normally
|
|
14
15
|
2. **Stage** — Select files for commit, verify no secrets or debug artifacts
|
|
15
16
|
3. **Commit** — Generate conventional commit message matching change scope
|
|
16
|
-
4. **Push** — Push to remote, create PR with description and checklist
|
|
17
|
+
4. **Push** — Push to remote, create PR with description and checklist (skip if active PR detected in step 1.5)
|
|
17
18
|
5. **Manage** — Handle branching, tagging, merging, and release prep
|
|
18
19
|
|
|
19
20
|
## Commit Convention
|
|
@@ -63,5 +64,8 @@ Description: imperative mood, lowercase, no period, max 72 chars
|
|
|
63
64
|
- Always verify no secrets in staged files before commit
|
|
64
65
|
- Read `## Git Workflow` in CLAUDE.md for project preferences (branching, commits, PRs, auto-push)
|
|
65
66
|
- Respect configured branching strategy, PR preference, and auto-push behavior
|
|
66
|
-
- If no Git Workflow section
|
|
67
|
+
- If no Git Workflow section and no `.claude/config/git-workflow.conf`, default to: feature branches, conventional commits, on-demand PR, auto-push
|
|
68
|
+
- Before creating a feature branch, check if current branch has open PR — if yes, reuse branch and push to update PR; if no or state!=OPEN, create new branch
|
|
69
|
+
- PR detection edge cases: gh CLI not installed (skip detection, proceed with branch creation), detached HEAD (skip detection, create new branch), gh fails (silent fail with warning, continue with branch creation), no remote configured (warn and stop)
|
|
70
|
+
- Silent fail on PR detection errors — log warning to user, continue with normal branch creation flow
|
|
67
71
|
- Update `docs/.context/git-manager.md` with patterns, decisions, and key files discovered
|
package/commands/backlog.md
CHANGED
|
@@ -12,7 +12,7 @@ Activate the **project-manager** agent in backlog mode.
|
|
|
12
12
|
3. Score: impact (H/M/L), effort (H/M/L), feasibility (H/M/L)
|
|
13
13
|
4. Update `docs/backlog.md` — add new items, re-prioritize existing ones
|
|
14
14
|
5. Mark items already implemented as done
|
|
15
|
-
6. Run `bash scripts/refresh-context.sh` to update shared context
|
|
15
|
+
6. Run `bash .claude/scripts/refresh-context.sh` to update shared context
|
|
16
16
|
|
|
17
17
|
Backlog format in `docs/backlog.md`:
|
|
18
18
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cleanup
|
|
3
|
+
description: Delete merged branches and optionally enable auto-cleanup hook
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /cleanup
|
|
7
|
+
|
|
8
|
+
Delete merged local branches and optionally delete remote branches.
|
|
9
|
+
|
|
10
|
+
## Process
|
|
11
|
+
|
|
12
|
+
1. Check if `.claude/.cleanup-configured` exists — if not, prompt for hook opt-in
|
|
13
|
+
2. If marker missing, ask: "Enable auto-cleanup hook after merging PRs? [y/N]"
|
|
14
|
+
3. If user chooses yes:
|
|
15
|
+
- Uncomment post-merge composition in `.claude/hooks/compose.yml` via sed
|
|
16
|
+
- Create marker: `echo 'enabled' > .claude/.cleanup-configured`
|
|
17
|
+
- Notify: "Auto-cleanup hook enabled. Runs automatically after git merge."
|
|
18
|
+
4. If user chooses no:
|
|
19
|
+
- Create marker: `echo 'manual' > .claude/.cleanup-configured`
|
|
20
|
+
5. Run cleanup script: `.claude/scripts/post-merge-cleanup.sh` (interactive mode)
|
|
21
|
+
6. Script detects branching strategy from `.claude/git-workflow.conf` or `CLAUDE.md`
|
|
22
|
+
7. Lists merged branches (excluding main/master/dev/develop/current)
|
|
23
|
+
8. Prompts before deleting each local branch
|
|
24
|
+
9. Prompts before deleting each remote branch (default: no)
|
|
25
|
+
10. If on main branch: pulls latest changes
|
|
26
|
+
11. If `BRANCHING=feature-branches`: optionally creates new feature branch
|
|
27
|
+
|
|
28
|
+
## Rules
|
|
29
|
+
|
|
30
|
+
- First-run hook prompt only shows once (marker file persists preference)
|
|
31
|
+
- Remote deletion requires explicit confirmation (default: no)
|
|
32
|
+
- Never delete main/master/dev/develop or current branch
|
|
33
|
+
- Handle missing config files gracefully (fallback to defaults)
|
|
34
|
+
- Handle git errors without crashing (network, permissions, no remote)
|
|
35
|
+
- If compose.yml missing, warn and skip hook enablement
|
|
36
|
+
- If sed fails, report error but continue cleanup
|
|
37
|
+
- For a native git hook (fires on all `git merge`, not just via Claude): `cortexhawk post-merge-hook`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-pr
|
|
3
|
+
description: Fetch, triage, and address PR review comments in batch — one commit, one notification.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /review-pr
|
|
7
|
+
|
|
8
|
+
Activate the **reviewer** agent using the `pr-review-comments` skill. Target PR: current branch.
|
|
9
|
+
|
|
10
|
+
1. **Auth** — Check MCP GitHub (`mcp__github__list_pull_requests`); fall back to `gh pr view` if unavailable
|
|
11
|
+
2. **Fetch** — Get all open inline threads, review submissions, and conversation comments
|
|
12
|
+
3. **Triage** — Group by author: Copilot / human reviewers / bots; skip resolved and outdated
|
|
13
|
+
4. **Present** — Show numbered threads with `file:line`, author, summary, and proposed fix
|
|
14
|
+
5. **Confirm** — Ask which to address (`1, 3, 5` or `all`) before touching any file
|
|
15
|
+
6. **Fix** (batch, default) — Apply all selected fixes in one pass
|
|
16
|
+
7. **Commit** — `fix: address PR review comments` (single commit)
|
|
17
|
+
8. **Push** — Push to remote
|
|
18
|
+
9. **Reply** — `mcp__github__create_pull_request_review` (batch) or `gh pr comment` — one reply per thread, referencing the commit sha
|
|
19
|
+
|
|
20
|
+
## Flags
|
|
21
|
+
|
|
22
|
+
- `--sequential` — fix → commit → reply per thread; use when comments are complex or interdependent
|
|
23
|
+
|
|
24
|
+
## Rules
|
|
25
|
+
|
|
26
|
+
- Always present threads and wait for user selection before fixing
|
|
27
|
+
- Batch mode: one commit + one review submission = one notification to reviewers
|
|
28
|
+
- Sequential mode: one commit per thread, reply immediately after each fix
|
|
29
|
+
- Never fix resolved or outdated threads unless explicitly requested
|
|
30
|
+
- If no open threads, report and stop
|
|
31
|
+
- If auth fails, prompt `gh auth login` or check `GITHUB_PERSONAL_ACCESS_TOKEN`
|
package/commands/ship.md
CHANGED
|
@@ -8,6 +8,7 @@ description: Commit, create PR, and prepare for deployment.
|
|
|
8
8
|
Activate the **git-manager** agent, then the **reviewer** agent. Ship: `$ARGUMENTS`
|
|
9
9
|
|
|
10
10
|
0. Read `## Git Workflow` from CLAUDE.md if present — respect PR preference and auto-push settings
|
|
11
|
+
0.5. Check if current branch has open PR — run `gh pr view --json state,url 2>/dev/null`; if PR exists and state=OPEN, skip branch creation (update existing PR); if gh unavailable or no PR found, proceed with normal flow
|
|
11
12
|
1. Stage changes and generate conventional commit message
|
|
12
13
|
2. Run quick review pass — reviewer runs Pass 1 (Correctness) and Pass 2 (Security) only, reporting Critical findings exclusively
|
|
13
14
|
3. If review passes, commit and push
|
package/commands/task.md
CHANGED
|
@@ -16,7 +16,7 @@ Activate the **project-manager** agent as orchestrator. Execute backlog item `$A
|
|
|
16
16
|
6. Update `CHANGELOG.md` with a one-line entry under the current version's `### Added` section
|
|
17
17
|
7. If chain completes without critical blockers, execute `/ship`
|
|
18
18
|
8. Mark item as `done` in backlog
|
|
19
|
-
9. Run `bash scripts/refresh-context.sh` to update shared context
|
|
19
|
+
9. Run `bash .claude/scripts/refresh-context.sh` to update shared context
|
|
20
20
|
|
|
21
21
|
## Save Rules
|
|
22
22
|
|
package/cortexhawk
CHANGED
|
@@ -29,7 +29,7 @@ yellow() { printf "\033[33m%s\033[0m\n" "$1"; }
|
|
|
29
29
|
red() { printf "\033[31m%s\033[0m\n" "$1"; }
|
|
30
30
|
|
|
31
31
|
get_version() {
|
|
32
|
-
grep -m1 '## \[' "$CORTEXHAWK_HOME/CHANGELOG.md" 2>/dev/null | sed 's/.*\[\([^]]*\)\].*/\1/' || echo "unknown"
|
|
32
|
+
grep -m1 '## \[[0-9]' "$CORTEXHAWK_HOME/CHANGELOG.md" 2>/dev/null | sed 's/.*\[\([^]]*\)\].*/\1/' || echo "unknown"
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
# --- validate command ---
|
|
@@ -120,8 +120,8 @@ do_validate() {
|
|
|
120
120
|
|
|
121
121
|
# settings.json
|
|
122
122
|
if [ -f "$target_dir/settings.json" ]; then
|
|
123
|
-
if python3 -c "import json; json.load(open(
|
|
124
|
-
node -e "JSON.parse(require('fs').readFileSync(
|
|
123
|
+
if python3 -c "import json,sys; json.load(open(sys.argv[1]))" "$target_dir/settings.json" 2>/dev/null || \
|
|
124
|
+
node -e "JSON.parse(require('fs').readFileSync(process.argv[1]))" "$target_dir/settings.json" 2>/dev/null; then
|
|
125
125
|
check "settings.json valid JSON" "ok"
|
|
126
126
|
else
|
|
127
127
|
check "settings.json invalid JSON" "fail"
|
|
@@ -383,6 +383,7 @@ show_help() {
|
|
|
383
383
|
echo " enable-hook <name> Enable a hook"
|
|
384
384
|
echo " disable-hook <name> Disable a hook"
|
|
385
385
|
echo " test-hooks Dry-run hooks with synthetic inputs"
|
|
386
|
+
echo " post-merge-hook Install native git post-merge hook (auto-cleanup)"
|
|
386
387
|
echo ""
|
|
387
388
|
echo "Other:"
|
|
388
389
|
echo " self-update Update CortexHawk source (git pull)"
|
|
@@ -501,6 +502,11 @@ case "$cmd" in
|
|
|
501
502
|
shift
|
|
502
503
|
bash "$INSTALL_SH" --test-hooks "$@"
|
|
503
504
|
;;
|
|
505
|
+
post-merge-hook)
|
|
506
|
+
check_home
|
|
507
|
+
shift
|
|
508
|
+
bash "$INSTALL_SH" --post-merge-hook "$@"
|
|
509
|
+
;;
|
|
504
510
|
self-update)
|
|
505
511
|
check_home
|
|
506
512
|
if [ ! -d "$CORTEXHAWK_HOME/.git" ]; then
|
package/hooks/branch-guard.sh
CHANGED
|
@@ -21,17 +21,24 @@ fi
|
|
|
21
21
|
|
|
22
22
|
PROTECTED_BRANCHES=("main" "master" "production" "release")
|
|
23
23
|
|
|
24
|
-
# Load git workflow config —
|
|
24
|
+
# Load git workflow config — adjust protected branches based on branching strategy
|
|
25
25
|
CONF_FILE="$(git rev-parse --show-toplevel 2>/dev/null)/.claude/git-workflow.conf"
|
|
26
26
|
if [[ -f "$CONF_FILE" ]]; then
|
|
27
27
|
_BRANCHING=$(grep '^BRANCHING=' "$CONF_FILE" | cut -d= -f2)
|
|
28
28
|
if [[ "$_BRANCHING" == "direct-main" ]]; then
|
|
29
29
|
PROTECTED_BRANCHES=("master" "production" "release")
|
|
30
|
+
elif [[ "$_BRANCHING" == "dev-branch" ]]; then
|
|
31
|
+
: # Work branch is the normal push target — only main stays protected
|
|
30
32
|
fi
|
|
31
33
|
fi
|
|
32
34
|
|
|
33
35
|
# Check for git push to protected branches
|
|
34
36
|
if echo "$CMD" | grep -qE 'git\s+push'; then
|
|
37
|
+
# Allow --delete operations (deleting remote branches, not pushing code)
|
|
38
|
+
if echo "$CMD" | grep -qE 'git\s+push\s+.*--delete|git\s+push\s+.*-d\s'; then
|
|
39
|
+
exit 0
|
|
40
|
+
fi
|
|
41
|
+
|
|
35
42
|
CURRENT_BRANCH=$(git branch --show-current 2>/dev/null)
|
|
36
43
|
|
|
37
44
|
for branch in "${PROTECTED_BRANCHES[@]}"; do
|
|
@@ -59,6 +59,9 @@ HOOKS_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
59
59
|
while IFS= read -r file; do
|
|
60
60
|
[ -z "$file" ] && continue
|
|
61
61
|
|
|
62
|
+
# Reject path traversal attempts
|
|
63
|
+
case "$file" in "."|".."|*../*|*/..*) continue ;; esac
|
|
64
|
+
|
|
62
65
|
# Resolve to absolute path
|
|
63
66
|
if [[ "$file" != /* ]]; then
|
|
64
67
|
file="$CWD/$file"
|
package/hooks/compose.yml
CHANGED
package/hooks/file-guard.sh
CHANGED
|
@@ -9,12 +9,16 @@ BLOCKED_PATTERNS=(
|
|
|
9
9
|
"*.key"
|
|
10
10
|
"id_rsa"
|
|
11
11
|
"id_ed25519"
|
|
12
|
+
"id_ecdsa"
|
|
12
13
|
"*.p12"
|
|
13
14
|
"*.pfx"
|
|
14
15
|
"*.keystore"
|
|
16
|
+
"*.jks"
|
|
15
17
|
"credentials.json"
|
|
16
18
|
"credentials.yml"
|
|
17
19
|
"credentials.yaml"
|
|
20
|
+
"*secret*"
|
|
21
|
+
"service-account*.json"
|
|
18
22
|
)
|
|
19
23
|
|
|
20
24
|
# Basename patterns that are .env.* but NOT .env.example/.env.sample/.env.template
|
package/hooks/hooks.json
CHANGED
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
"script": "hooks/commit-guard.sh",
|
|
37
37
|
"description": "Validates commit format and checks for staged secrets"
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
"name": "lint-guard",
|
|
41
|
+
"type": "PreToolUse",
|
|
42
|
+
"script": "hooks/lint-guard.sh",
|
|
43
|
+
"description": "Auto-detect and run formatters/linters on staged files before commit"
|
|
44
|
+
},
|
|
39
45
|
{
|
|
40
46
|
"name": "test-reminder",
|
|
41
47
|
"type": "PostToolUse",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# lint-guard — Auto-detect formatters/linters and run before git commit/push
|
|
3
|
+
# Hook type: PreToolUse (Bash)
|
|
4
|
+
# Delegates heavy work to scripts/lint-guard-runner.sh
|
|
5
|
+
|
|
6
|
+
# --- 1. PARSE COMMAND ---
|
|
7
|
+
if [ -n "$CORTEXHAWK_COMMAND" ]; then
|
|
8
|
+
CMD="$CORTEXHAWK_COMMAND"
|
|
9
|
+
else
|
|
10
|
+
INPUT=$(cat)
|
|
11
|
+
if command -v jq &>/dev/null; then
|
|
12
|
+
CMD=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
|
|
13
|
+
fi
|
|
14
|
+
[ -z "$CMD" ] && CMD=$(printf '%s' "$INPUT" \
|
|
15
|
+
| grep -o '"command" *: *"[^"]*"' | head -1 | sed 's/.*: *"//;s/"$//')
|
|
16
|
+
fi
|
|
17
|
+
[ -z "$CMD" ] && exit 0
|
|
18
|
+
echo "$CMD" | grep -qE 'git\s+(commit|push)' || exit 0
|
|
19
|
+
|
|
20
|
+
# --- 2. PUSH CHECK — yml takes priority over git-workflow.conf ---
|
|
21
|
+
if echo "$CMD" | grep -qE 'git\s+push'; then
|
|
22
|
+
_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
23
|
+
_YML_PUSH=$(grep -E "^\s+run_on_push:" "$_ROOT/.cortexhawk-lint.yml" 2>/dev/null \
|
|
24
|
+
| sed 's/.*: *//' | tr -d ' \r')
|
|
25
|
+
if [ "$_YML_PUSH" = "true" ]; then
|
|
26
|
+
:
|
|
27
|
+
elif [ "$_YML_PUSH" = "false" ]; then
|
|
28
|
+
exit 0
|
|
29
|
+
else
|
|
30
|
+
LINT_ON_PUSH=$(grep '^LINT_ON_PUSH=' "$_ROOT/.claude/git-workflow.conf" 2>/dev/null | cut -d= -f2)
|
|
31
|
+
[ "$LINT_ON_PUSH" != "true" ] && exit 0
|
|
32
|
+
fi
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# --- 3. DELEGATE ---
|
|
36
|
+
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
37
|
+
[ -z "$REPO_ROOT" ] && exit 0
|
|
38
|
+
|
|
39
|
+
if command -v pre-commit &>/dev/null && [ -f "$REPO_ROOT/.pre-commit-config.yaml" ]; then
|
|
40
|
+
echo "lint-guard: pre-commit detected — delegating to pre-commit framework"
|
|
41
|
+
pre-commit run
|
|
42
|
+
exit $?
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
bash "$REPO_ROOT/.claude/scripts/lint-guard-runner.sh"
|
|
46
|
+
exit $?
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# post-merge — Auto-cleanup merged branches after PR merge
|
|
3
|
+
# Hook type: GitHook
|
|
4
|
+
# Disabled by default — enable via /cleanup first run
|
|
5
|
+
|
|
6
|
+
# Call cleanup script in auto mode (silent, no prompts, skip remote deletion)
|
|
7
|
+
if [ -f ".claude/scripts/post-merge-cleanup.sh" ]; then
|
|
8
|
+
bash ".claude/scripts/post-merge-cleanup.sh" --auto 2>/dev/null || true
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
# Exit silently — don't block merge operation on script failures
|
|
12
|
+
exit 0
|
package/hooks/session-start.sh
CHANGED
|
@@ -132,4 +132,4 @@ if [ -d "$SKILL_DIR" ]; then
|
|
|
132
132
|
fi
|
|
133
133
|
|
|
134
134
|
echo ""
|
|
135
|
-
echo "Commands: /plan /build /test /review /ship /debug /scan /check /refactor /research /doc /bootstrap /tdd /optimize /migrate /monitor /api-gen /changelog /journal /brainstorm /simplify /deploy /export /backlog /pulse /map /learn /chain /task /ci /context"
|
|
135
|
+
echo "Commands: /plan /build /test /review /ship /commit /cleanup /debug /scan /check /refactor /research /doc /bootstrap /tdd /optimize /migrate /monitor /api-gen /changelog /journal /brainstorm /simplify /deploy /export /backlog /pulse /map /learn /chain /task /ci /context /upgrade"
|