@eduardbar/drift 0.9.0 → 1.0.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.
Files changed (69) hide show
  1. package/.github/workflows/publish-vscode.yml +76 -0
  2. package/AGENTS.md +30 -12
  3. package/CHANGELOG.md +9 -0
  4. package/README.md +273 -168
  5. package/ROADMAP.md +130 -98
  6. package/dist/analyzer.d.ts +4 -38
  7. package/dist/analyzer.js +85 -1510
  8. package/dist/cli.js +47 -4
  9. package/dist/config.js +1 -1
  10. package/dist/fix.d.ts +13 -0
  11. package/dist/fix.js +120 -0
  12. package/dist/git/blame.d.ts +22 -0
  13. package/dist/git/blame.js +227 -0
  14. package/dist/git/helpers.d.ts +36 -0
  15. package/dist/git/helpers.js +152 -0
  16. package/dist/git/trend.d.ts +21 -0
  17. package/dist/git/trend.js +80 -0
  18. package/dist/git.d.ts +0 -4
  19. package/dist/git.js +2 -2
  20. package/dist/report.js +620 -293
  21. package/dist/rules/phase0-basic.d.ts +11 -0
  22. package/dist/rules/phase0-basic.js +176 -0
  23. package/dist/rules/phase1-complexity.d.ts +31 -0
  24. package/dist/rules/phase1-complexity.js +277 -0
  25. package/dist/rules/phase2-crossfile.d.ts +27 -0
  26. package/dist/rules/phase2-crossfile.js +122 -0
  27. package/dist/rules/phase3-arch.d.ts +31 -0
  28. package/dist/rules/phase3-arch.js +148 -0
  29. package/dist/rules/phase5-ai.d.ts +8 -0
  30. package/dist/rules/phase5-ai.js +262 -0
  31. package/dist/rules/phase8-semantic.d.ts +22 -0
  32. package/dist/rules/phase8-semantic.js +109 -0
  33. package/dist/rules/shared.d.ts +7 -0
  34. package/dist/rules/shared.js +27 -0
  35. package/package.json +8 -3
  36. package/packages/vscode-drift/.vscodeignore +9 -0
  37. package/packages/vscode-drift/LICENSE +21 -0
  38. package/packages/vscode-drift/README.md +64 -0
  39. package/packages/vscode-drift/images/icon.png +0 -0
  40. package/packages/vscode-drift/images/icon.svg +30 -0
  41. package/packages/vscode-drift/package-lock.json +485 -0
  42. package/packages/vscode-drift/package.json +119 -0
  43. package/packages/vscode-drift/src/analyzer.ts +38 -0
  44. package/packages/vscode-drift/src/diagnostics.ts +55 -0
  45. package/packages/vscode-drift/src/extension.ts +111 -0
  46. package/packages/vscode-drift/src/statusbar.ts +47 -0
  47. package/packages/vscode-drift/src/treeview.ts +108 -0
  48. package/packages/vscode-drift/tsconfig.json +18 -0
  49. package/packages/vscode-drift/vscode-drift-0.1.0.vsix +0 -0
  50. package/packages/vscode-drift/vscode-drift-0.1.1.vsix +0 -0
  51. package/src/analyzer.ts +124 -1726
  52. package/src/cli.ts +53 -4
  53. package/src/config.ts +1 -1
  54. package/src/fix.ts +154 -0
  55. package/src/git/blame.ts +279 -0
  56. package/src/git/helpers.ts +198 -0
  57. package/src/git/trend.ts +116 -0
  58. package/src/git.ts +2 -2
  59. package/src/report.ts +631 -296
  60. package/src/rules/phase0-basic.ts +187 -0
  61. package/src/rules/phase1-complexity.ts +302 -0
  62. package/src/rules/phase2-crossfile.ts +149 -0
  63. package/src/rules/phase3-arch.ts +179 -0
  64. package/src/rules/phase5-ai.ts +292 -0
  65. package/src/rules/phase8-semantic.ts +132 -0
  66. package/src/rules/shared.ts +39 -0
  67. package/tests/helpers.ts +45 -0
  68. package/tests/rules.test.ts +1269 -0
  69. package/vitest.config.ts +15 -0
@@ -0,0 +1,76 @@
1
+ name: Publish VS Code Extension
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ inputs:
8
+ version:
9
+ description: 'Version to publish (e.g. 0.1.1)'
10
+ required: true
11
+ type: string
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ publish:
18
+ runs-on: ubuntu-latest
19
+ defaults:
20
+ run:
21
+ working-directory: packages/vscode-drift
22
+
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v4
26
+ with:
27
+ ref: ${{ github.event_name == 'release' && github.ref || github.event.repository.default_branch }}
28
+
29
+ - name: Setup Node.js
30
+ uses: actions/setup-node@v4
31
+ with:
32
+ node-version: '20'
33
+ cache: 'npm'
34
+ cache-dependency-path: packages/vscode-drift/package-lock.json
35
+
36
+ - name: Verify version matches tag
37
+ if: github.event_name == 'release'
38
+ run: |
39
+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
40
+ TAG_VERSION="${{ inputs.version }}"
41
+ else
42
+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
43
+ fi
44
+ PKG_VERSION=$(node -p "require('./package.json').version")
45
+ if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
46
+ echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
47
+ exit 1
48
+ fi
49
+ echo "Version check passed: $PKG_VERSION"
50
+
51
+ - name: Check if version already published
52
+ run: |
53
+ PKG_VERSION=$(node -p "require('./package.json').version")
54
+ PUBLISHED=$(npx @vscode/vsce show eduardbar.vscode-drift 2>&1 | grep "Version:" | awk '{print $2}' || echo "none")
55
+ if [ "$PUBLISHED" = "$PKG_VERSION" ]; then
56
+ echo "Version $PKG_VERSION already published on Marketplace. Skipping."
57
+ echo "skip_publish=true" >> $GITHUB_ENV
58
+ fi
59
+
60
+ - name: Install dependencies
61
+ if: env.skip_publish != 'true'
62
+ run: npm ci
63
+
64
+ - name: Build extension
65
+ if: env.skip_publish != 'true'
66
+ run: npm run build
67
+
68
+ - name: Package extension
69
+ if: env.skip_publish != 'true'
70
+ run: npx @vscode/vsce package --no-dependencies
71
+
72
+ - name: Publish to VS Code Marketplace
73
+ if: env.skip_publish != 'true'
74
+ run: npx @vscode/vsce publish --no-dependencies
75
+ env:
76
+ VSCE_PAT: ${{ secrets.VSCE_PAT }}
package/AGENTS.md CHANGED
@@ -88,18 +88,35 @@ npx @eduardbar/drift scan ./src -o report.md # exportar Markdown
88
88
 
89
89
  ## Reglas del analyzer
90
90
 
91
- | Regla | Severidad | Peso | Qué detecta |
92
- |-------|-----------|------|-------------|
93
- | `large-file` | error | 20 | Archivos > 300 líneas |
94
- | `large-function` | error | 15 | Funciones > 50 líneas |
95
- | `duplicate-function-name` | error | 18 | Nombres de función duplicados (case-insensitive) |
96
- | `debug-leftover` | warning | 10 | `console.log/warn/error` + `TODO/FIXME/HACK/XXX/TEMP` |
97
- | `catch-swallow` | warning | 10 | Bloques `catch {}` vacíos |
98
- | `dead-code` | warning | 8 | Imports nombrados sin usar |
99
- | `any-abuse` | warning | 8 | Uso explícito de `any` como tipo |
100
- | `comment-contradiction` | warning | 12 | (reservado — definido en RULE_WEIGHTS) |
101
- | `no-return-type` | info | 5 | Funciones sin tipo de retorno explícito |
102
- | `magic-number` | info | 3 | (reservado — definido en RULE_WEIGHTS) |
91
+ | Regla | Severidad | Peso |
92
+ |-------|-----------|------|
93
+ | `large-file` | error | 20 |
94
+ | `large-function` | error | 15 |
95
+ | `duplicate-function-name` | error | 18 |
96
+ | `high-complexity` | error | 15 |
97
+ | `circular-dependency` | error | 14 |
98
+ | `layer-violation` | error | 16 |
99
+ | `comment-contradiction` | warning | 12 |
100
+ | `deep-nesting` | warning | 12 |
101
+ | `semantic-duplication` | warning | 12 |
102
+ | `debug-leftover` | warning | 10 |
103
+ | `catch-swallow` | warning | 10 |
104
+ | `high-coupling` | warning | 10 |
105
+ | `dead-file` | warning | 10 |
106
+ | `hardcoded-config` | warning | 10 |
107
+ | `cross-boundary-import` | warning | 10 |
108
+ | `dead-code` | warning | 8 |
109
+ | `any-abuse` | warning | 8 |
110
+ | `too-many-params` | warning | 8 |
111
+ | `unused-export` | warning | 8 |
112
+ | `inconsistent-error-handling` | warning | 8 |
113
+ | `promise-style-mix` | warning | 7 |
114
+ | `unnecessary-abstraction` | warning | 7 |
115
+ | `naming-inconsistency` | warning | 6 |
116
+ | `unused-dependency` | warning | 6 |
117
+ | `no-return-type` | info | 5 |
118
+ | `over-commented` | info | 4 |
119
+ | `magic-number` | info | 3 |
103
120
 
104
121
  **Score = suma de pesos capped a 100. Score del proyecto = promedio de archivos.**
105
122
 
@@ -199,6 +216,7 @@ Sin esto, Windows no ejecuta el shebang correctamente con ES modules.
199
216
 
200
217
  | Versión | Cambios principales |
201
218
  |---------|---------------------|
219
+ | **1.0.0** | 26 reglas, 131 tests, modular rules, JS/JSX, drift fix/report/diff/ci/badge/trend/blame, VS Code extension |
202
220
  | **0.3.0** | `--ai` (LLM-optimized JSON output) + `--fix` (inline suggestions) |
203
221
  | **0.2.3** | Fix: bin wrapper para compatibilidad Windows npx |
204
222
  | **0.2.2** | Refactor: `formatMarkdown` dividido en helpers + fix CI doble publish |
package/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.9.1] — 2026-02-25
11
+
12
+ ### Fixed
13
+ - `drift trend`: `analyzeSingleCommit` now analyses the full project snapshot at each commit instead of only the files changed in the diff. Uses `git ls-tree -r <hash> --name-only` to enumerate all tracked `.ts/.tsx` files, writes them to a temp directory via `git show <hash>:<file>`, runs `analyzeProject` on the snapshot, then cleans up. Score in each `TrendDataPoint` now reflects the total project health, not just the files touched in that commit.
14
+ - `drift trend`: added sampling to `analyzeHistoricalCommits` — selects at most 10 commits distributed evenly across the period (configurable via `maxSamples`). Prevents timeouts on repos with 100+ commits.
15
+ - `drift trend` / `drift blame`: propagate `DriftConfig` through the full call chain (`analyzeTrend` → `analyzeHistoricalCommits` → `analyzeSingleCommit` → `analyzeProject`) so custom rule configs are respected in historical analysis.
16
+
17
+ ---
18
+
10
19
  ## [Unreleased]
11
20
 
12
21
  ---