heimdal_ai_analyze 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1de7a84ebfd8fd06367312a54270c64bf6c43923238d3b85cdff16dff2e2e25
4
- data.tar.gz: 6cac8c75b7870aa5a56add62d203053ba505d4f397a8c74e67f9f60ce727e603
3
+ metadata.gz: 9f303598cd8959aa063b6fcb89344423566549ce2d45bcb3a9162df7a8c7be3b
4
+ data.tar.gz: 342d5fa9764a1875b246faa8bac4940997c9c82c55da3689fddb8dfe3c08af84
5
5
  SHA512:
6
- metadata.gz: 74670f8e9b9bc96c3a6a7f8d1a58260e0b6d8a3f74c6b4df1aa4eaec5f19733268a6491f33ddf5c3389147230d5e4237e09b610fe498f8982beb57745e0b12e4
7
- data.tar.gz: 9c3b237a19785f0c44ef66e6f84afa15465d056af00b4b780d9b18c67895ef94c9923daeb2d4c0506d3a8dc22ceb89f2c985eb2fdd9a0747e764e230cf4e8bf3
6
+ metadata.gz: ccd5058c6e293bf97d07218f3a798baaa75a7e37d970f2c643410b9314dcb72198c885c291d03d02c36c04943c79060900fc55d519d898687096d91587ca89e7
7
+ data.tar.gz: 5965774f8c7700495bc4a4cdbe7dab264970c6997eb448e34df774bdd96df8ca421008839f7123cd8b6a6b94d0ba471f8b9d9da8f475007ec537a26f80c26f5a
data/README.md CHANGED
@@ -1,19 +1,24 @@
1
1
  # Heimdal AI Analyze
2
2
 
3
- Ruby gem that installs a **git pre-commit** hook for **AI-assisted review** of your **staged diff** via the [Cursor Agent CLI](https://cursor.com/docs/cli/overview). The hook runs only when you commit with analysis enabled (e.g. `git analyze -m "message"`), not on normal commits.
3
+ [![Repo views](https://komarev.com/ghpvc/?username=ffarhhan-heimdal-ai-analyze&label=Repo+views&style=for-the-badge)](https://github.com/ffarhhan/heimdal_ai_analyze)
4
4
 
5
- ## Requirements
5
+ [![Gem Version](https://badge.fury.io/rb/heimdal_ai_analyze.svg)](https://rubygems.org/gems/heimdal_ai_analyze)
6
6
 
7
- 1. **Cursor Agent CLI** install from [cursor.com/install](https://cursor.com/install) and ensure `agent` or `cursor-agent` is on your `PATH` (or set `CURSOR_AGENT_BIN`).
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
+ **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.
9
8
 
10
- ## Install the gem
9
+ _Sees every line. Judges every commit. No bad code crosses the Bifrost._
10
+
11
+ - **Owners:** [@ffarhhan](https://github.com/ffarhhan), [@namanverma98](https://github.com/namanverma98)
12
+ - **RubyGems:** [rubygems.org/gems/heimdal_ai_analyze](https://rubygems.org/gems/heimdal_ai_analyze)
13
+ - **Source:** [github.com/ffarhhan/heimdal_ai_analyze](https://github.com/ffarhhan/heimdal_ai_analyze)
14
+
15
+ ## Installation
11
16
 
12
17
  ```bash
13
18
  gem install heimdal_ai_analyze
14
19
  ```
15
20
 
16
- Or with Bundler:
21
+ With Bundler:
17
22
 
18
23
  ```ruby
19
24
  # Gemfile
@@ -24,59 +29,45 @@ gem "heimdal_ai_analyze", group: :development
24
29
  bundle install
25
30
  ```
26
31
 
27
- ## One-time setup per repository
32
+ Requires **Ruby 3.1**.
28
33
 
29
- From the git repository root:
30
-
31
- ```bash
32
- bundle exec heimdal-ai-analyze-install
33
- # or, if the gem executable is on PATH:
34
- heimdal-ai-analyze-install
35
- ```
34
+ ## How it works
36
35
 
37
- This symlinks `.git/hooks/pre-commit` to the gem’s hook, sets `git analyze` alias (`ANALYZE=true git commit …`), records `heimdalAiAnalyze.gemPath`, and tries to save `cursorHook.agentPath` for the Cursor Agent binary.
36
+ 1. **You run `git analyze -m "message"`** A `git commit` alias that runs Heimdal’s review **before** your changes are committed.
38
37
 
39
- ## Credentials
38
+ 2. **Staged changes only** — Only files in the commit are analyzed; the rest of the tree is untouched.
40
39
 
41
- **Minimum:** set an API key for the Cursor Agent:
40
+ 3. **Five dimensions** **Security**, **duplication**, **complexity**, **style**, and **tests**.
42
41
 
43
- ```bash
44
- export CURSOR_API_KEY="your-key"
45
- ```
42
+ 4. **Severity** — Issues are reported with location, explanation, and a suggested fix (**critical**, **warning**, **info**).
46
43
 
47
- Optional locations (loaded in order; later sources override earlier ones):
44
+ **Result:** **Critical** findings **block** the commit until addressed. With no critical issues, the commit can proceed; lower severities are advisory.
48
45
 
49
- 1. `~/.config/heimdal_ai_analyze/env` or `$XDG_CONFIG_HOME/heimdal_ai_analyze/env` — `export CURSOR_API_KEY=...`
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)`.
46
+ ## One-time setup (per repository)
51
47
 
52
- ## Usage
48
+ Run from the repository root:
53
49
 
54
50
  ```bash
55
- git analyze -m "Your commit message" # runs AI review on staged changes, then commits if allowed
56
- git commit -m "message" # normal commit (hook skips AI unless ANALYZE=true)
57
- git commit --no-verify # bypass hooks when needed
51
+ bundle exec heimdal-ai-analyze-install
52
+ # or, if the executable is on your PATH:
53
+ heimdal-ai-analyze-install
58
54
  ```
59
55
 
60
- ## Development
56
+ 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
57
 
62
- Clone [github.com/ffarhhan/heimdal_ai_analyze](https://github.com/ffarhhan/heimdal_ai_analyze):
58
+ ## API key
63
59
 
64
- ```bash
65
- git clone -o personal git@github.com:ffarhhan/heimdal_ai_analyze.git
66
- cd heimdal_ai_analyze
67
- gem build heimdal_ai_analyze.gemspec
68
- gem install ./heimdal_ai_analyze-*.gem --local
69
- ```
60
+ The hook needs **`CURSOR_API_KEY`** whenever you run `git analyze`.
70
61
 
71
- ## Publish to RubyGems.org (maintainers)
62
+ - **This shell only:** `export CURSOR_API_KEY="…"` lasts for the current terminal session.
63
+ - **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.
72
64
 
73
- 1. [Create an account](https://rubygems.org/sign_up) and enable MFA as required.
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:
65
+ 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-*`).
66
+
67
+ ## Usage
76
68
 
77
69
  ```bash
78
- gem build heimdal_ai_analyze.gemspec
79
- gem push heimdal_ai_analyze-VERSION.gem
70
+ git analyze -m "Your commit message" # review staged changes, then commit if allowed
80
71
  ```
81
72
 
82
73
  ## License
@@ -5,11 +5,11 @@ require_relative "lib/heimdal_ai_analyze/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "heimdal_ai_analyze"
7
7
  spec.version = HeimdalAiAnalyze::VERSION
8
- spec.authors = ["ffarhhan"]
9
- spec.email = ["ffarhhan@users.noreply.github.com"]
8
+ spec.authors = ["ffarhhan", "namanverma98"]
9
+ spec.email = ["ffarhhan@users.noreply.github.com", "namanv98@gmail.com"]
10
10
 
11
- spec.summary = "Heimdal AI Analyze — Cursor Agent pre-commit gate for staged diffs"
12
- spec.description = "Installs a git pre-commit hook that runs Cursor Agent on ANALYZE=true commits (e.g. git analyze). Requires CURSOR_API_KEY and the Cursor Agent CLI."
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`."
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"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeimdalAiAnalyze
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # Copy to scripts/.env.hook (gitignored). Never commit this file.
2
- # Or use ~/.config/heimdal_ai_analyze/env for all repos on your machine (loaded first; this file overrides).
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 overrides.
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,19 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heimdal_ai_analyze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ffarhhan
8
+ - namanverma98
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2026-04-14 00:00:00.000000000 Z
12
+ date: 2026-04-17 00:00:00.000000000 Z
12
13
  dependencies: []
13
- description: Installs a git pre-commit hook that runs Cursor Agent on ANALYZE=true
14
- commits (e.g. git analyze). Requires CURSOR_API_KEY and the Cursor Agent CLI.
14
+ description: Heimdal AI Analyze installs a git pre-commit hook that runs an AI-assisted
15
+ code review of your staged diff when you commit with analysis enabled (e.g. `git
16
+ analyze -m "message"`). Reviews security, duplication, complexity, style, and tests;
17
+ critical issues can block the commit. Requires CURSOR_API_KEY in the environment
18
+ or a repo-local `.env`.
15
19
  email:
16
20
  - ffarhhan@users.noreply.github.com
21
+ - namanv98@gmail.com
17
22
  executables:
18
23
  - heimdal-ai-analyze-install
19
24
  extensions: []
@@ -53,5 +58,6 @@ requirements: []
53
58
  rubygems_version: 3.4.19
54
59
  signing_key:
55
60
  specification_version: 4
56
- summary: Heimdal AI Analyze — Cursor Agent pre-commit gate for staged diffs
61
+ summary: Heimdal AI Analyze — git pre-commit hook for AI-assisted review of staged
62
+ diffs (git analyze)
57
63
  test_files: []