@alimaandev/ripple 0.5.0 → 0.7.0

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/README.md CHANGED
@@ -21,7 +21,7 @@ Change less. Break less. Know the blast radius of any file before you touch it.
21
21
  # or try it without installing anything:
22
22
  npx @alimaandev/ripple analyze src/your-file.ts</code></pre>
23
23
 
24
- <img src="https://raw.githubusercontent.com/alimaandev/ripple/main/assets/hero.svg" alt="Terminal output of `ripple analyze` — risk, affected files, routes, components, tests, and confidence score" title="ripple analyze" width="100%" />
24
+ <img src="https://raw.githubusercontent.com/alimaandev/ripple/main/assets/hero-animated.svg" alt="Animated terminal demo of `ripple analyze` — command types in, then the report builds up: risk score with gauge, affected files, routes, components, tests, and confidence" title="ripple analyze" width="100%" />
25
25
 
26
26
  </div>
27
27
 
@@ -69,19 +69,22 @@ Just deterministic analysis against the code you actually have.
69
69
 
70
70
  ## Features
71
71
 
72
- | Feature | What it does |
73
- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------- |
74
- | **Impact analysis** | Reverse dependency traversal, transitively, with depth caps. Know who imports a target file. |
75
- | **Risk scoring** | A transparent 0–100 score from seven weighted signals, with a per-factor breakdown in `--verbose`. |
76
- | **Cycle detection** | Strongly-connected components with a concrete cycle path — `a → c → b → a`, not just a list of names. |
77
- | **Alias & path support** | tsconfig `paths` and custom aliases like `{ "@": "./src" }`, including single-wildcard patterns. |
78
- | **Real-world resolution** | Extension probing, index files, `.js` → `.ts` rewriting, dynamic `import()`, `require()`, `export … from`. |
79
- | **Categorized results** | Routes, layouts, components, utilities, and tests detected by path conventions — not a raw string of file names. |
80
- | **Entry-point intelligence** | `package.json` `main`/`bin` plus conventional root and `src` entry files, flagged in the report. |
81
- | **Stable JSON contract** | A machine-readable report for CI gates, dashboards, and tooling — additive-only compatibility. |
82
- | **Change-set gating** | `ripple diff` analyzes every changed file since a base ref and blocks the merge on risky code. |
83
- | **Error-tolerant parsing** | A broken file lowers confidence instead of aborting the run. No false precision. |
84
- | **Deterministic & offline** | Same input, same output, every time. No hidden network dependency. |
72
+ | Feature | What it does |
73
+ | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
74
+ | **Impact analysis** | Reverse dependency traversal, transitively, with depth caps. Know who imports a target file. |
75
+ | **Risk scoring** | A transparent 0–100 score from seven weighted signals, with a per-factor breakdown in `--verbose`. |
76
+ | **Cycle detection** | Strongly-connected components with a concrete cycle path — `a → c → b → a`, not just a list of names. |
77
+ | **Alias & path support** | tsconfig `paths` and custom aliases like `{ "@": "./src" }`, including single-wildcard patterns. |
78
+ | **Real-world resolution** | Extension probing, index files, `.js` → `.ts` rewriting, dynamic `import()`, `require()`, `export … from`. |
79
+ | **Categorized results** | Routes, layouts, components, utilities, and tests detected by path conventions — not a raw string of file names. |
80
+ | **Entry-point intelligence** | `package.json` `main`/`bin` plus conventional root and `src` entry files, flagged in the report. |
81
+ | **Stable JSON contract** | A machine-readable report for CI gates, dashboards, and tooling — additive-only compatibility. |
82
+ | **Change-set gating** | `ripple diff` analyzes every changed file since a base ref and blocks the merge on risky code. |
83
+ | **Diff allowlist** | `--allow <glob>` (or `diff.allow` in config) exempts legacy files from blocking the gate — analyze, report, don't fail. |
84
+ | **Graph exports** | `ripple graph --format mermaid | dot | html` renders the project graph as a Mermaid flowchart, Graphviz digraph, or a self-contained HTML report. |
85
+ | **Config JSON Schema** | Editors autocomplete and validate `ripple.config.json` against the shipped `ripple.schema.json` via `$schema`. |
86
+ | **Error-tolerant parsing** | A broken file lowers confidence instead of aborting the run. No false precision. |
87
+ | **Deterministic & offline** | Same input, same output, every time. No hidden network dependency. |
85
88
 
86
89
  ## Quick start
87
90
 
@@ -97,7 +100,7 @@ Everything below is real output against a shipped example project in `tests/fixt
97
100
  ```bash
98
101
  npm install -g @alimaandev/ripple
99
102
 
100
- ripple version # → 0.5.0
103
+ ripple version # → 0.7.0
101
104
  ```
102
105
 
103
106
  Or install from source:
@@ -129,9 +132,7 @@ ripple analyze src/authentication/login.ts
129
132
  Expected output:
130
133
 
131
134
  ```text
132
- ╭ ripple ────────────────────────────╮
133
- │ ❯ impact analysis · v0.2.0 │
134
- ╰────────────────────────────────────╯
135
+ ripple · impact analysis · v0.7.0
135
136
 
136
137
  File src/authentication/login.ts
137
138
  Risk MEDIUM · 34.7/100 ███░░░░░░░
@@ -140,18 +141,15 @@ Affected 7 files
140
141
  Max depth 2
141
142
  Confidence 100%
142
143
 
143
- ────────────────────────────────────
144
- Top impact
144
+ › Top impact
145
145
  ● Dashboard (2)
146
146
  ● Admin (1)
147
147
  ● Index TS (1)
148
148
 
149
- ────────────────────────────────────
150
- Circular dependencies
149
+ › Circular dependencies
151
150
  ◯ src/circular/a.ts → src/circular/c.ts → src/circular/b.ts → src/circular/a.ts
152
151
 
153
- ────────────────────────────────────
154
- Affected files (7)
152
+ › Affected files (7)
155
153
  ├─ src/admin/page.tsx · depth 1
156
154
  ├─ src/dashboard/page.tsx · depth 1
157
155
  └─ src/main.ts · depth 2
@@ -167,9 +165,7 @@ ripple graph
167
165
  ```
168
166
 
169
167
  ```text
170
- ╭ ripple ────────────────────────────╮
171
- │ ❯ dependency graph · v0.2.0 │
172
- ╰────────────────────────────────────╯
168
+ ripple · dependency graph · v0.7.0
173
169
 
174
170
  Files 25
175
171
  Edges 28
@@ -177,11 +173,19 @@ External 4
177
173
  Unresolved 0
178
174
  Circular groups 1
179
175
 
180
- ────────────────────────────────────
181
- Circular dependencies
176
+ › Circular dependencies
182
177
  ◯ src/circular/a.ts → src/circular/c.ts → src/circular/b.ts → src/circular/a.ts
183
178
  ```
184
179
 
180
+ Export the graph for documentation or a team wiki — no extra tooling needed:
181
+
182
+ ```bash
183
+ ripple graph --format mermaid # Mermaid flowchart (GitHub renders it natively)
184
+ ripple graph --format dot # Graphviz digraph
185
+ ripple graph --format html # self-contained dark-themed HTML report
186
+ ripple graph src/authentication/login.ts --format mermaid # just a file's blast radius
187
+ ```
188
+
185
189
  Point it at a file to see its dependency tree — forwards (what it imports)
186
190
  or, with `-r`, backwards (what imports it):
187
191
 
@@ -201,20 +205,21 @@ Dependents (reverse)
201
205
  ripple <command> [options]
202
206
  ```
203
207
 
204
- | Command | Description |
205
- | ---------------- | ------------------------------------------------- |
206
- | `analyze <file>` | Impact analysis for a target file |
207
- | `graph [file]` | Project stats, or a single file's dependency tree |
208
- | `diff` | Gate all files changed since a git base ref |
209
- | `doctor` | Project and environment health check |
210
- | `init` | Scaffold a `ripple.config.json` |
211
- | `version` | Print the current version |
208
+ | Command | Description | Example |
209
+ | ---------------- | ------------------------------------------------- | -------------------------------------------- |
210
+ | `analyze <file>` | Impact analysis for a target file | `ripple analyze src/authentication/login.ts` |
211
+ | `graph [file]` | Project stats, or a single file's dependency tree | `ripple graph src/circular/b.ts -r` |
212
+ | `diff` | Gate all files changed since a git base ref | `ripple diff --base main --gate critical` |
213
+ | `doctor` | Project and environment health check | `ripple doctor -v` |
214
+ | `init` | Scaffold a `ripple.config.json` | `ripple init` |
215
+ | `version` | Print the current version | `ripple version` |
212
216
 
213
217
  ### Options
214
218
 
215
219
  | Command | Flag | Description |
216
220
  | --------- | --------------------- | ---------------------------------------------------------------------------------------------- |
217
221
  | `analyze` | `-j, --json` | Emit the JSON report instead of the terminal report |
222
+ | `analyze` | `--sarif` | Emit a SARIF 2.1.0 report for code scanning |
218
223
  | `analyze` | `-v, --verbose` | Include the risk-factor point breakdown |
219
224
  | `analyze` | `-d, --depth <n>` | Cap the reverse traversal at `n` levels |
220
225
  | `analyze` | `-c, --config <path>` | Use a specific config file |
@@ -231,11 +236,16 @@ ripple <command> [options]
231
236
  | `diff` | `-j, --json` | Emit the JSON report instead of the terminal report |
232
237
  | `diff` | `-b, --base <ref>` | Git ref to diff against (default: `origin/main`, `main`, `HEAD~1`, or `diff.base` from config) |
233
238
  | `diff` | `-g, --gate <level>` | Blocking level: `medium`, `high`, or `critical` (default: `high`, or `diff.gate` from config) |
234
- | `diff` | `-f, --format <fmt>` | Output: `terminal`, `json`, or `github` (workflow annotations) |
239
+ | `diff` | `-f, --format <fmt>` | Output: `terminal`, `json`, `github` (workflow annotations), or `sarif` |
235
240
  | `diff` | `-d, --depth <n>` | Cap reverse traversal per file |
236
241
  | `diff` | `-c, --config <path>` | Use a specific config file |
237
242
  | `diff` | `--no-color` | Disable ANSI colors |
238
243
 
244
+ ### `ripple mcp`
245
+
246
+ Serve Ripple's analysis tools over the Model Context Protocol (see
247
+ [the MCP section](#ripple-mcp-1) below).
248
+
239
249
  ### `ripple doctor`
240
250
 
241
251
  Independent health checks — config validity, tsconfig presence, source
@@ -263,6 +273,15 @@ $ ripple doctor
263
273
  ### `ripple init`
264
274
 
265
275
  Writes `ripple.config.json` with the recommended defaults, ready to edit.
276
+ The minimal config references the shipped JSON Schema so editors
277
+ autocomplete and validate as you type:
278
+
279
+ ```bash
280
+ ripple init # minimal ripple.config.json + $schema
281
+ ripple init --full # every built-in default, written out
282
+ ripple init --ts # typed ripple.config.ts
283
+ ripple init --ts --full # full defaults as TypeScript
284
+ ```
266
285
 
267
286
  ### `ripple diff`
268
287
 
@@ -276,23 +295,27 @@ cd my-project
276
295
  ripple diff # vs origin/main (then main, then HEAD~1)
277
296
  ripple diff --base HEAD~1 --json # machine-readable gate report
278
297
  ripple diff --gate critical # only CRITICAL blocks the merge
298
+ ripple diff --allow "src/legacy/**" # legacy files never block the gate
279
299
  ```
280
300
 
301
+ Adopting the gate on an existing codebase? Allowlist the files you haven't
302
+ fixed yet — they are still analyzed and shown in the report, marked
303
+ `(allowed)`, but they can't fail CI. The same list lives in config as
304
+ `diff.allow`, so the whole team shares it.
305
+
281
306
  ```text
282
- ╭ ripple ─────────────────────╮
283
- │ ❯ diff vs origin/main │
284
- ╰─────────────────────────────╯
307
+ ripple · diff vs origin/main
285
308
 
286
309
  Changed 2 files
287
310
  Source 2 files
311
+ Allowed 1 file
288
312
  Duration 118ms
289
313
 
290
- ✖ Gate blocked — 1 CRITICAL (no HIGH or CRITICAL)
314
+ ✔ Gate passed — none (no HIGH or CRITICAL)
291
315
 
292
- ─────────────────────────────────────
293
- Risk analysis (2 files)
316
+ › Risk analysis (2 files)
294
317
  ✖ src/auth/token.ts CRITICAL · 88.2/100 ████████░░
295
- ● src/auth/session.ts LOW · 12.4/100 █░░░░░░░░░
318
+ ✔ src/legacy/session.ts LOW · 12.4/100 █░░░░░░░░░ (allowed)
296
319
  … src/api/legacy.js (not a source file)
297
320
  ```
298
321
 
@@ -316,6 +339,57 @@ verdict, so the job fails when the gate blocks:
316
339
  (`--json` is shorthand for `--format json`; the format flag also accepts
317
340
  `terminal`, the default.)
318
341
 
342
+ `--format sarif` emits SARIF 2.1.0, the format GitHub Code Scanning speaks:
343
+
344
+ ```bash
345
+ ripple diff --format sarif > ripple.sarif
346
+ ```
347
+
348
+ Each analyzed change becomes a finding on the file — `error` when it is
349
+ CRITICAL/HIGH, `warning` for MEDIUM, `note` for LOW — with a stable
350
+ `primaryLocationLineHash` fingerprint so results deduplicate across runs.
351
+ Allowlisted files are emitted as `note` with an in-source suppression, so
352
+ they show as exempted rather than failing. Upload the report straight into
353
+ Code Scanning alerts:
354
+
355
+ ```yaml
356
+ - uses: actions/upload-sarif@v3
357
+ with:
358
+ sarif_file: ripple.sarif
359
+ ```
360
+
361
+ The exit code still carries the gate verdict regardless of format.
362
+
363
+ ### `ripple mcp`
364
+
365
+ `ripple mcp` exposes Ripple's analysis to AI coding agents as a Model
366
+ Context Protocol server over stdio. Point any MCP client at the command and
367
+ the agent can check a file's blast radius before touching it:
368
+
369
+ ```json
370
+ {
371
+ "mcpServers": {
372
+ "ripple": { "command": "npx", "args": ["@alimaandev/ripple", "mcp"] }
373
+ }
374
+ }
375
+ ```
376
+
377
+ Four tools are served:
378
+
379
+ | Tool | Inputs | Returns |
380
+ | ------------- | ------------------- | ----------------------------------------------------------------------- |
381
+ | `impact` | `file`, `maxDepth?` | Blast radius: affected files, routes, tests, components, risk level |
382
+ | `dependents` | `file`, `depth?` | Who imports the file, up to a depth (default 1, direct) |
383
+ | `risk` | `file` | Risk score with the factor breakdown behind it |
384
+ | `gate_status` | `base?`, `gate?` | Current change set vs the merge gate: files, levels, pass/block verdict |
385
+
386
+ A typical agent loop: `impact src/auth/session.ts` before refactoring,
387
+ `dependents` to see who breaks, then `gate_status` after editing to confirm
388
+ the gate still passes. Tool results are JSON text; failures return
389
+ `isError` results instead of crashing the session.
390
+
391
+ <img src="https://raw.githubusercontent.com/alimaandev/ripple/main/assets/mcp-demo.svg" alt="Flow diagram — an AI agent calls impact on src/auth/session.ts through ripple mcp and gets the blast radius back: 7 affected files, 4 routes, MEDIUM risk" title="ripple mcp flow" width="100%" />
392
+
319
393
  ## Configuration
320
394
 
321
395
  Ripple discovers `ripple.config.ts`, `.js`, `.cjs`, `.mjs`, or `.json` in the
@@ -324,6 +398,7 @@ defaults — every field is optional.
324
398
 
325
399
  ```json
326
400
  {
401
+ "$schema": "./node_modules/@alimaandev/ripple/ripple.schema.json",
327
402
  "include": ["**/*.{ts,tsx,js,jsx}"],
328
403
  "ignore": ["node_modules", "dist", "build", "coverage", ".next", "out"],
329
404
  "aliases": { "@": "./src" },
@@ -342,11 +417,16 @@ defaults — every field is optional.
342
417
  },
343
418
  "diff": {
344
419
  "base": "origin/main",
345
- "gate": "high"
420
+ "gate": "high",
421
+ "allow": ["src/legacy/**"]
346
422
  }
347
423
  }
348
424
  ```
349
425
 
426
+ > [!TIP]
427
+ > The `$schema` line powers editor autocomplete and validation for
428
+ > `ripple.config.json` — the package ships `ripple.schema.json` for it.
429
+
350
430
  | Field | Default | Purpose |
351
431
  | ----------------- | ----------------------------------------------------------- | ------------------------------------------------------ |
352
432
  | `include` | `**/*.{ts,tsx,js,jsx}` | Source globs to analyze |
@@ -356,6 +436,7 @@ defaults — every field is optional.
356
436
  | `risk.weights` | see example | Risk signal weights |
357
437
  | `risk.thresholds` | 30 / 55 / 80 | Score thresholds for MEDIUM / HIGH / CRITICAL |
358
438
  | `diff.base` | `origin/main` → `main` → `HEAD~1` | Git ref to diff against when `--base` is not given |
439
+ | `diff.allow` | `[]` | Globs of files that never block the gate |
359
440
  | `diff.gate` | `high` | Blocking level when `--gate` is not given |
360
441
 
361
442
  `node_modules` is always excluded, regardless of config.
@@ -418,7 +499,7 @@ error-tolerant recovery, `graph/` resolves specifiers and detects cycles, and
418
499
  ```json
419
500
  {
420
501
  "tool": "ripple",
421
- "version": "0.1.0",
502
+ "version": "0.5.0",
422
503
  "command": "analyze",
423
504
  "file": "src/authentication/login.ts",
424
505
  "risk": { "score": 34.4, "level": "MEDIUM", "factors": [] },
@@ -469,7 +550,7 @@ verdict:
469
550
  ```json
470
551
  {
471
552
  "tool": "ripple",
472
- "version": "0.3.0",
553
+ "version": "0.5.0",
473
554
  "command": "diff",
474
555
  "base": "origin/main",
475
556
  "changedFiles": 2,
@@ -579,6 +660,11 @@ pnpm run build # tsup
579
660
  Architecture and design decisions live in [docs/architecture.md](docs/architecture.md).
580
661
  Before contributing, read [CONTRIBUTING.md](CONTRIBUTING.md).
581
662
 
663
+ Quality gates run on every pull request: lint, typecheck, build, unit tests
664
+ (against a global coverage floor for `src/**`), integration tests on Linux
665
+ and Windows, and a dogfood job — Ripple gates its own PRs with
666
+ `ripple diff --format github`.
667
+
582
668
  ## Get started
583
669
 
584
670
  ```bash