heimdal_ai_analyze 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +29 -41
- data/heimdal_ai_analyze.gemspec +2 -2
- data/lib/heimdal_ai_analyze/version.rb +1 -1
- data/templates/env.hook.example +2 -1
- data/templates/pre-commit +6 -4
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc0b28182c96cbd7d687b4e1b219a7010d1773756d5abb17855ebe855fdf5b00
|
|
4
|
+
data.tar.gz: 948d0b8a93c07c392290a6807d6e8010743bf5158e620cf2afaed25b0cb6fa30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfb229eb3a88b328ae677fb235ba09447acc5550cf9981b8245fe88567eba63846f89cf9bea1a8d6f991e5307c7c08799eccd5eca5d459fefa49f464814d0b6d
|
|
7
|
+
data.tar.gz: eafa7b0af64cbbc3d2a161497ec3d3f0a596ecdfa0d8d72600af228cf0883c4edf9703b6c950d826f4d2c78edc425c506637bc01506645c4cf7d561d44ae6e8a
|
data/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# Heimdal AI Analyze
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://rubygems.org/gems/heimdal_ai_analyze)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Heimdal AI Analyze** is a Ruby gem that adds a **git pre-commit** hook for **AI-assisted review** of your **staged diff**. Use `git analyze` to run the review before your commit; a normal `git commit` does not trigger analysis unless you opt in.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
2. **`CURSOR_API_KEY`** — export in your environment, or use a repo-local `scripts/.env.hook`, or `~/.config/heimdal_ai_analyze/env` (see below).
|
|
7
|
+
_Sees every line. Judges every commit. No bad code crosses the Bifrost._
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- **RubyGems:** [rubygems.org/gems/heimdal_ai_analyze](https://rubygems.org/gems/heimdal_ai_analyze)
|
|
10
|
+
- **Source:** [github.com/ffarhhan/heimdal_ai_analyze](https://github.com/ffarhhan/heimdal_ai_analyze)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
11
13
|
|
|
12
14
|
```bash
|
|
13
15
|
gem install heimdal_ai_analyze
|
|
14
16
|
```
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
With Bundler:
|
|
17
19
|
|
|
18
20
|
```ruby
|
|
19
21
|
# Gemfile
|
|
@@ -24,59 +26,45 @@ gem "heimdal_ai_analyze", group: :development
|
|
|
24
26
|
bundle install
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
Requires **Ruby ≥ 3.1**.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
## How it works
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
bundle exec heimdal-ai-analyze-install
|
|
33
|
-
# or, if the gem executable is on PATH:
|
|
34
|
-
heimdal-ai-analyze-install
|
|
35
|
-
```
|
|
33
|
+
1. **You run `git analyze -m "message"`** — A `git commit` alias that runs Heimdal’s review **before** your changes are committed.
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
2. **Staged changes only** — Only files in the commit are analyzed; the rest of the tree is untouched.
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
3. **Five dimensions** — **Security**, **duplication**, **complexity**, **style**, and **tests**.
|
|
40
38
|
|
|
41
|
-
**
|
|
39
|
+
4. **Severity** — Issues are reported with location, explanation, and a suggested fix (**critical**, **warning**, **info**).
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
export CURSOR_API_KEY="your-key"
|
|
45
|
-
```
|
|
41
|
+
**Result:** **Critical** findings **block** the commit until addressed. With no critical issues, the commit can proceed; lower severities are advisory.
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
## One-time setup (per repository)
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
2. `scripts/.env.hook` in the project (gitignored) — copy from `templates/env.hook.example` in this gem if you open the installed path under `$(gem env gemdir)`.
|
|
51
|
-
|
|
52
|
-
## Usage
|
|
45
|
+
Run from the repository root:
|
|
53
46
|
|
|
54
47
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
bundle exec heimdal-ai-analyze-install
|
|
49
|
+
# or, if the executable is on your PATH:
|
|
50
|
+
heimdal-ai-analyze-install
|
|
58
51
|
```
|
|
59
52
|
|
|
60
|
-
|
|
53
|
+
This links the gem’s pre-commit hook, registers the `git analyze` alias (`ANALYZE=true git commit …`), and stores the gem path in local git config. If an analysis binary is found, its path may be saved locally as well.
|
|
61
54
|
|
|
62
|
-
|
|
55
|
+
## API key
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
gem install ./heimdal_ai_analyze-*.gem --local
|
|
69
|
-
```
|
|
57
|
+
The hook needs **`CURSOR_API_KEY`** whenever you run `git analyze`.
|
|
58
|
+
|
|
59
|
+
- **This shell only:** `export CURSOR_API_KEY="…"` lasts for the current terminal session.
|
|
60
|
+
- **Every session:** add that `export` to your shell profile (for example `~/.zshrc` or `~/.bashrc`), **or** keep the key in a **repository-root `.env`** file and add `.env` to `.gitignore` so it is never committed. The hook loads supported env files when it runs.
|
|
70
61
|
|
|
71
|
-
|
|
62
|
+
For additional options and examples, see **`templates/env.hook.example`** inside the installed gem (`gem contents heimdal_ai_analyze` or `$(gem env gemdir)/gems/heimdal_ai_analyze-*`).
|
|
72
63
|
|
|
73
|
-
|
|
74
|
-
2. `gem signin` with a [RubyGems API key](https://rubygems.org/profile/edit) (push scope).
|
|
75
|
-
3. Bump `lib/heimdal_ai_analyze/version.rb`, then:
|
|
64
|
+
## Usage
|
|
76
65
|
|
|
77
66
|
```bash
|
|
78
|
-
|
|
79
|
-
gem push heimdal_ai_analyze-VERSION.gem
|
|
67
|
+
git analyze -m "Your commit message" # review staged changes, then commit if allowed
|
|
80
68
|
```
|
|
81
69
|
|
|
82
70
|
## License
|
data/heimdal_ai_analyze.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ["ffarhhan"]
|
|
9
9
|
spec.email = ["ffarhhan@users.noreply.github.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = "Heimdal AI Analyze —
|
|
12
|
-
spec.description = "
|
|
11
|
+
spec.summary = "Heimdal AI Analyze — git pre-commit hook for AI-assisted review of staged diffs (git analyze)"
|
|
12
|
+
spec.description = "Heimdal AI Analyze installs a git pre-commit hook that runs an AI-assisted code review of your staged diff when you commit with analysis enabled (e.g. `git analyze -m \"message\"`). Reviews security, duplication, complexity, style, and tests; critical issues can block the commit. Requires CURSOR_API_KEY in the environment or a repo-local `.env` (gitignored)."
|
|
13
13
|
spec.homepage = "https://github.com/ffarhhan/heimdal_ai_analyze"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
spec.required_ruby_version = ">= 3.1.0"
|
data/templates/env.hook.example
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Copy to scripts/.env.hook (gitignored). Never commit this file.
|
|
2
|
-
#
|
|
2
|
+
# Alternatively use a repo-root .env file (gitignored); the hook loads ~/.config/.../env, then .env, then this file.
|
|
3
|
+
# Or use ~/.config/heimdal_ai_analyze/env for all repos on your machine (loaded first; repo .env and this file override).
|
|
3
4
|
#
|
|
4
5
|
# Copy this file to scripts/.env.hook in your app repo (see gem README).
|
|
5
6
|
#
|
data/templates/pre-commit
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
#
|
|
12
12
|
# Requirements:
|
|
13
13
|
# • Cursor Agent CLI — https://cursor.com/install
|
|
14
|
-
# • CURSOR_API_KEY — export in env, or ~/.config/heimdal_ai_analyze/env, or scripts/.env.hook (gitignored)
|
|
14
|
+
# • CURSOR_API_KEY — export in env, or ~/.config/heimdal_ai_analyze/env, or repo .env / scripts/.env.hook (gitignored)
|
|
15
15
|
#
|
|
16
|
-
# Env file load order (later overrides earlier): user config → repo scripts/.env.hook
|
|
16
|
+
# Env file load order (later overrides earlier): user config → repo .env → scripts/.env.hook
|
|
17
17
|
#
|
|
18
18
|
# Agent binary lookup (first match):
|
|
19
19
|
# 1. $CURSOR_AGENT_BIN 2. scripts/.env.hook exports 3. git config cursorHook.agentPath
|
|
@@ -32,11 +32,13 @@ set -euo pipefail
|
|
|
32
32
|
# │ Bootstrap │
|
|
33
33
|
# └─────────────────────────────────────────────────────────────────────┘
|
|
34
34
|
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || REPO_ROOT=""
|
|
35
|
-
# User-level config first (Heimdal gem); repo scripts/.env.hook
|
|
35
|
+
# User-level config first (Heimdal gem); repo .env then scripts/.env.hook override.
|
|
36
36
|
for f in "${XDG_CONFIG_HOME:+$XDG_CONFIG_HOME/heimdal_ai_analyze/env}" \
|
|
37
37
|
"${HOME}/.config/heimdal_ai_analyze/env"; do
|
|
38
38
|
[[ -n "$f" && -f "$f" ]] && { set -a; . "$f"; set +a; }
|
|
39
39
|
done
|
|
40
|
+
REPO_DOTENV="${REPO_ROOT:+$REPO_ROOT/.env}"
|
|
41
|
+
[[ -n "$REPO_DOTENV" && -f "$REPO_DOTENV" ]] && { set -a; . "$REPO_DOTENV"; set +a; }
|
|
40
42
|
ENV_HOOK="${REPO_ROOT:+$REPO_ROOT/scripts/.env.hook}"
|
|
41
43
|
[[ -n "$ENV_HOOK" && -f "$ENV_HOOK" ]] && { set -a; . "$ENV_HOOK"; set +a; }
|
|
42
44
|
|
|
@@ -139,7 +141,7 @@ if [[ -z "${CURSOR_API_KEY:-}" ]]; then
|
|
|
139
141
|
cat >&2 <<'MSG'
|
|
140
142
|
pre-commit (analyze): CURSOR_API_KEY is required.
|
|
141
143
|
→ export CURSOR_API_KEY="…"
|
|
142
|
-
→ Or ~/.config/heimdal_ai_analyze/env or scripts/.env.hook (see gem README / env.hook.example)
|
|
144
|
+
→ Or ~/.config/heimdal_ai_analyze/env, .env, or scripts/.env.hook (see gem README / env.hook.example)
|
|
143
145
|
MSG
|
|
144
146
|
exit 1
|
|
145
147
|
fi
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: heimdal_ai_analyze
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ffarhhan
|
|
@@ -10,8 +10,11 @@ bindir: exe
|
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2026-04-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
14
|
-
|
|
13
|
+
description: Heimdal AI Analyze installs a git pre-commit hook that runs an AI-assisted
|
|
14
|
+
code review of your staged diff when you commit with analysis enabled (e.g. `git
|
|
15
|
+
analyze -m "message"`). Reviews security, duplication, complexity, style, and tests;
|
|
16
|
+
critical issues can block the commit. Requires CURSOR_API_KEY in the environment
|
|
17
|
+
or a repo-local `.env` (gitignored).
|
|
15
18
|
email:
|
|
16
19
|
- ffarhhan@users.noreply.github.com
|
|
17
20
|
executables:
|
|
@@ -53,5 +56,6 @@ requirements: []
|
|
|
53
56
|
rubygems_version: 3.4.19
|
|
54
57
|
signing_key:
|
|
55
58
|
specification_version: 4
|
|
56
|
-
summary: Heimdal AI Analyze —
|
|
59
|
+
summary: Heimdal AI Analyze — git pre-commit hook for AI-assisted review of staged
|
|
60
|
+
diffs (git analyze)
|
|
57
61
|
test_files: []
|