@alimaandev/ripple 0.4.0 → 0.6.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
@@ -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.4.0
103
+ ripple version # → 0.6.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.6.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.6.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,39 +205,40 @@ 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
- | Command | Flag | Description |
216
- | --------- | --------------------- | ------------------------------------------------------------------ |
217
- | `analyze` | `-j, --json` | Emit the JSON report instead of the terminal report |
218
- | `analyze` | `-v, --verbose` | Include the risk-factor point breakdown |
219
- | `analyze` | `-d, --depth <n>` | Cap the reverse traversal at `n` levels |
220
- | `analyze` | `-c, --config <path>` | Use a specific config file |
221
- | `analyze` | `--no-color` | Disable ANSI colors |
222
- | `graph` | `-j, --json` | Emit the JSON report |
223
- | `graph` | `-r, --reverse` | Show dependents (what imports this file) instead of dependencies |
224
- | `graph` | `-d, --depth <n>` | Cap tree depth |
225
- | `graph` | `-c, --config <path>` | Use a specific config file |
226
- | `graph` | `--no-color` | Disable ANSI colors |
227
- | `doctor` | `-c, --config <path>` | Use a specific config file |
228
- | `doctor` | `-v, --verbose` | Verbose output |
229
- | `doctor` | `--no-color` | Disable ANSI colors |
230
- | `init` | `-f, --force` | Overwrite an existing config |
231
- | `diff` | `-j, --json` | Emit the JSON report instead of the terminal report |
219
+ | Command | Flag | Description |
220
+ | --------- | --------------------- | ---------------------------------------------------------------------------------------------- |
221
+ | `analyze` | `-j, --json` | Emit the JSON report instead of the terminal report |
222
+ | `analyze` | `-v, --verbose` | Include the risk-factor point breakdown |
223
+ | `analyze` | `-d, --depth <n>` | Cap the reverse traversal at `n` levels |
224
+ | `analyze` | `-c, --config <path>` | Use a specific config file |
225
+ | `analyze` | `--no-color` | Disable ANSI colors |
226
+ | `graph` | `-j, --json` | Emit the JSON report |
227
+ | `graph` | `-r, --reverse` | Show dependents (what imports this file) instead of dependencies |
228
+ | `graph` | `-d, --depth <n>` | Cap tree depth |
229
+ | `graph` | `-c, --config <path>` | Use a specific config file |
230
+ | `graph` | `--no-color` | Disable ANSI colors |
231
+ | `doctor` | `-c, --config <path>` | Use a specific config file |
232
+ | `doctor` | `-v, --verbose` | Verbose output |
233
+ | `doctor` | `--no-color` | Disable ANSI colors |
234
+ | `init` | `-f, --force` | Overwrite an existing config |
235
+ | `diff` | `-j, --json` | Emit the JSON report instead of the terminal report |
232
236
  | `diff` | `-b, --base <ref>` | Git ref to diff against (default: `origin/main`, `main`, `HEAD~1`, or `diff.base` from config) |
233
- | `diff` | `-g, --gate <level>` | Blocking level: `medium`, `high`, or `critical` (default: `high`, or `diff.gate` from config) |
234
- | `diff` | `-d, --depth <n>` | Cap reverse traversal per file |
235
- | `diff` | `-c, --config <path>` | Use a specific config file |
236
- | `diff` | `--no-color` | Disable ANSI colors |
237
+ | `diff` | `-g, --gate <level>` | Blocking level: `medium`, `high`, or `critical` (default: `high`, or `diff.gate` from config) |
238
+ | `diff` | `-f, --format <fmt>` | Output: `terminal`, `json`, or `github` (workflow annotations) |
239
+ | `diff` | `-d, --depth <n>` | Cap reverse traversal per file |
240
+ | `diff` | `-c, --config <path>` | Use a specific config file |
241
+ | `diff` | `--no-color` | Disable ANSI colors |
237
242
 
238
243
  ### `ripple doctor`
239
244
 
@@ -262,6 +267,15 @@ $ ripple doctor
262
267
  ### `ripple init`
263
268
 
264
269
  Writes `ripple.config.json` with the recommended defaults, ready to edit.
270
+ The minimal config references the shipped JSON Schema so editors
271
+ autocomplete and validate as you type:
272
+
273
+ ```bash
274
+ ripple init # minimal ripple.config.json + $schema
275
+ ripple init --full # every built-in default, written out
276
+ ripple init --ts # typed ripple.config.ts
277
+ ripple init --ts --full # full defaults as TypeScript
278
+ ```
265
279
 
266
280
  ### `ripple diff`
267
281
 
@@ -275,29 +289,50 @@ cd my-project
275
289
  ripple diff # vs origin/main (then main, then HEAD~1)
276
290
  ripple diff --base HEAD~1 --json # machine-readable gate report
277
291
  ripple diff --gate critical # only CRITICAL blocks the merge
292
+ ripple diff --allow "src/legacy/**" # legacy files never block the gate
278
293
  ```
279
294
 
295
+ Adopting the gate on an existing codebase? Allowlist the files you haven't
296
+ fixed yet — they are still analyzed and shown in the report, marked
297
+ `(allowed)`, but they can't fail CI. The same list lives in config as
298
+ `diff.allow`, so the whole team shares it.
299
+
280
300
  ```text
281
- ╭ ripple ─────────────────────╮
282
- │ ❯ diff vs origin/main │
283
- ╰─────────────────────────────╯
301
+ ripple · diff vs origin/main
284
302
 
285
303
  Changed 2 files
286
304
  Source 2 files
305
+ Allowed 1 file
287
306
  Duration 118ms
288
307
 
289
- ✖ Gate blocked — 1 CRITICAL (no HIGH or CRITICAL)
308
+ ✔ Gate passed — none (no HIGH or CRITICAL)
290
309
 
291
- ─────────────────────────────────────
292
- Risk analysis (2 files)
310
+ › Risk analysis (2 files)
293
311
  ✖ src/auth/token.ts CRITICAL · 88.2/100 ████████░░
294
- ● src/auth/session.ts LOW · 12.4/100 █░░░░░░░░░
312
+ ✔ src/legacy/session.ts LOW · 12.4/100 █░░░░░░░░░ (allowed)
295
313
  … src/api/legacy.js (not a source file)
296
314
  ```
297
315
 
298
316
  Run `ripple diff` locally before opening a PR, and in CI as the same gate —
299
317
  identical code, identical verdict.
300
318
 
319
+ ```bash
320
+ ripple diff --format github
321
+ ```
322
+
323
+ `--format github` emits GitHub Actions workflow commands. Each risky change
324
+ shows as a warning or error annotation right on the PR's Files tab —
325
+ `::error` when a file blocks the gate, `::warning` otherwise — plus a
326
+ `::notice` line with the gate verdict. The exit code still carries the
327
+ verdict, so the job fails when the gate blocks:
328
+
329
+ ```yaml
330
+ - run: npx @alimaandev/ripple diff --format github
331
+ ```
332
+
333
+ (`--json` is shorthand for `--format json`; the format flag also accepts
334
+ `terminal`, the default.)
335
+
301
336
  ## Configuration
302
337
 
303
338
  Ripple discovers `ripple.config.ts`, `.js`, `.cjs`, `.mjs`, or `.json` in the
@@ -306,6 +341,7 @@ defaults — every field is optional.
306
341
 
307
342
  ```json
308
343
  {
344
+ "$schema": "./node_modules/@alimaandev/ripple/ripple.schema.json",
309
345
  "include": ["**/*.{ts,tsx,js,jsx}"],
310
346
  "ignore": ["node_modules", "dist", "build", "coverage", ".next", "out"],
311
347
  "aliases": { "@": "./src" },
@@ -324,11 +360,16 @@ defaults — every field is optional.
324
360
  },
325
361
  "diff": {
326
362
  "base": "origin/main",
327
- "gate": "high"
363
+ "gate": "high",
364
+ "allow": ["src/legacy/**"]
328
365
  }
329
366
  }
330
367
  ```
331
368
 
369
+ > [!TIP]
370
+ > The `$schema` line powers editor autocomplete and validation for
371
+ > `ripple.config.json` — the package ships `ripple.schema.json` for it.
372
+
332
373
  | Field | Default | Purpose |
333
374
  | ----------------- | ----------------------------------------------------------- | ------------------------------------------------------ |
334
375
  | `include` | `**/*.{ts,tsx,js,jsx}` | Source globs to analyze |
@@ -338,6 +379,7 @@ defaults — every field is optional.
338
379
  | `risk.weights` | see example | Risk signal weights |
339
380
  | `risk.thresholds` | 30 / 55 / 80 | Score thresholds for MEDIUM / HIGH / CRITICAL |
340
381
  | `diff.base` | `origin/main` → `main` → `HEAD~1` | Git ref to diff against when `--base` is not given |
382
+ | `diff.allow` | `[]` | Globs of files that never block the gate |
341
383
  | `diff.gate` | `high` | Blocking level when `--gate` is not given |
342
384
 
343
385
  `node_modules` is always excluded, regardless of config.
@@ -400,7 +442,7 @@ error-tolerant recovery, `graph/` resolves specifiers and detects cycles, and
400
442
  ```json
401
443
  {
402
444
  "tool": "ripple",
403
- "version": "0.1.0",
445
+ "version": "0.5.0",
404
446
  "command": "analyze",
405
447
  "file": "src/authentication/login.ts",
406
448
  "risk": { "score": 34.4, "level": "MEDIUM", "factors": [] },
@@ -451,7 +493,7 @@ verdict:
451
493
  ```json
452
494
  {
453
495
  "tool": "ripple",
454
- "version": "0.3.0",
496
+ "version": "0.5.0",
455
497
  "command": "diff",
456
498
  "base": "origin/main",
457
499
  "changedFiles": 2,
@@ -561,6 +603,11 @@ pnpm run build # tsup
561
603
  Architecture and design decisions live in [docs/architecture.md](docs/architecture.md).
562
604
  Before contributing, read [CONTRIBUTING.md](CONTRIBUTING.md).
563
605
 
606
+ Quality gates run on every pull request: lint, typecheck, build, unit tests
607
+ (against a global coverage floor for `src/**`), integration tests on Linux
608
+ and Windows, and a dogfood job — Ripple gates its own PRs with
609
+ `ripple diff --format github`.
610
+
564
611
  ## Get started
565
612
 
566
613
  ```bash