@eduardbar/drift 1.1.0 → 1.3.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/.github/workflows/publish-vscode.yml +3 -3
- package/.github/workflows/publish.yml +3 -3
- package/.github/workflows/review-pr.yml +153 -0
- package/AGENTS.md +6 -0
- package/README.md +192 -4
- package/ROADMAP.md +6 -5
- package/dist/analyzer.d.ts +2 -2
- package/dist/analyzer.js +420 -159
- package/dist/benchmark.d.ts +2 -0
- package/dist/benchmark.js +185 -0
- package/dist/cli.js +509 -23
- package/dist/diff.js +74 -10
- package/dist/git.js +12 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -0
- package/dist/map.d.ts +3 -2
- package/dist/map.js +98 -10
- package/dist/plugins.d.ts +2 -1
- package/dist/plugins.js +177 -28
- package/dist/printer.js +4 -0
- package/dist/review.js +2 -2
- package/dist/rules/comments.js +2 -2
- package/dist/rules/complexity.js +2 -7
- package/dist/rules/nesting.js +3 -13
- package/dist/rules/phase0-basic.js +10 -10
- package/dist/rules/shared.d.ts +2 -0
- package/dist/rules/shared.js +27 -3
- package/dist/saas.d.ts +219 -0
- package/dist/saas.js +762 -0
- package/dist/trust-kpi.d.ts +9 -0
- package/dist/trust-kpi.js +445 -0
- package/dist/trust.d.ts +65 -0
- package/dist/trust.js +571 -0
- package/dist/types.d.ts +160 -0
- package/docs/PRD.md +199 -172
- package/docs/plugin-contract.md +61 -0
- package/docs/trust-core-release-checklist.md +55 -0
- package/package.json +5 -3
- package/packages/vscode-drift/src/code-actions.ts +53 -0
- package/packages/vscode-drift/src/extension.ts +11 -0
- package/src/analyzer.ts +484 -155
- package/src/benchmark.ts +244 -0
- package/src/cli.ts +628 -36
- package/src/diff.ts +75 -10
- package/src/git.ts +16 -0
- package/src/index.ts +63 -0
- package/src/map.ts +112 -10
- package/src/plugins.ts +354 -26
- package/src/printer.ts +4 -0
- package/src/review.ts +2 -2
- package/src/rules/comments.ts +2 -2
- package/src/rules/complexity.ts +2 -7
- package/src/rules/nesting.ts +3 -13
- package/src/rules/phase0-basic.ts +11 -12
- package/src/rules/shared.ts +31 -3
- package/src/saas.ts +1031 -0
- package/src/trust-kpi.ts +518 -0
- package/src/trust.ts +774 -0
- package/src/types.ts +177 -0
- package/tests/diff.test.ts +124 -0
- package/tests/new-features.test.ts +98 -0
- package/tests/plugins.test.ts +219 -0
- package/tests/rules.test.ts +23 -1
- package/tests/saas-foundation.test.ts +464 -0
- package/tests/trust-kpi.test.ts +120 -0
- package/tests/trust.test.ts +584 -0
package/dist/types.d.ts
CHANGED
|
@@ -92,6 +92,123 @@ export interface AIIssue {
|
|
|
92
92
|
fix_suggestion: string;
|
|
93
93
|
effort: 'low' | 'medium' | 'high';
|
|
94
94
|
}
|
|
95
|
+
export type MergeRiskLevel = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
96
|
+
export interface TrustGatePolicyPreset {
|
|
97
|
+
branch: string;
|
|
98
|
+
enabled?: boolean;
|
|
99
|
+
minTrust?: number;
|
|
100
|
+
maxRisk?: MergeRiskLevel;
|
|
101
|
+
}
|
|
102
|
+
export interface TrustGatePolicyPack {
|
|
103
|
+
enabled?: boolean;
|
|
104
|
+
minTrust?: number;
|
|
105
|
+
maxRisk?: MergeRiskLevel;
|
|
106
|
+
}
|
|
107
|
+
export interface TrustGatePolicyConfig {
|
|
108
|
+
enabled?: boolean;
|
|
109
|
+
minTrust?: number;
|
|
110
|
+
maxRisk?: MergeRiskLevel;
|
|
111
|
+
presets?: TrustGatePolicyPreset[];
|
|
112
|
+
policyPacks?: Record<string, TrustGatePolicyPack>;
|
|
113
|
+
}
|
|
114
|
+
export interface TrustReason {
|
|
115
|
+
label: string;
|
|
116
|
+
detail: string;
|
|
117
|
+
impact: number;
|
|
118
|
+
}
|
|
119
|
+
export interface TrustFixPriority {
|
|
120
|
+
rank: number;
|
|
121
|
+
rule: string;
|
|
122
|
+
severity: DriftIssue['severity'];
|
|
123
|
+
occurrences: number;
|
|
124
|
+
estimated_trust_gain: number;
|
|
125
|
+
effort: 'low' | 'medium' | 'high';
|
|
126
|
+
suggestion: string;
|
|
127
|
+
confidence?: 'low' | 'medium' | 'high';
|
|
128
|
+
explanation?: string;
|
|
129
|
+
systemic?: boolean;
|
|
130
|
+
}
|
|
131
|
+
export interface TrustAdvancedComparison {
|
|
132
|
+
source: 'previous-trust-json' | 'snapshot-history';
|
|
133
|
+
trend: 'improving' | 'regressing' | 'stable';
|
|
134
|
+
summary: string;
|
|
135
|
+
trust_delta?: number;
|
|
136
|
+
previous_trust_score?: number;
|
|
137
|
+
previous_merge_risk?: MergeRiskLevel;
|
|
138
|
+
snapshot_score_delta?: number;
|
|
139
|
+
snapshot_label?: string;
|
|
140
|
+
snapshot_timestamp?: string;
|
|
141
|
+
}
|
|
142
|
+
export interface TrustAdvancedContext {
|
|
143
|
+
comparison?: TrustAdvancedComparison;
|
|
144
|
+
team_guidance: string[];
|
|
145
|
+
}
|
|
146
|
+
export interface TrustDiffContext {
|
|
147
|
+
baseRef: string;
|
|
148
|
+
status: 'improved' | 'regressed' | 'neutral';
|
|
149
|
+
scoreDelta: number;
|
|
150
|
+
newIssues: number;
|
|
151
|
+
resolvedIssues: number;
|
|
152
|
+
filesChanged: number;
|
|
153
|
+
penalty: number;
|
|
154
|
+
bonus: number;
|
|
155
|
+
netImpact: number;
|
|
156
|
+
}
|
|
157
|
+
export interface DriftTrustReport {
|
|
158
|
+
scannedAt: string;
|
|
159
|
+
targetPath: string;
|
|
160
|
+
trust_score: number;
|
|
161
|
+
merge_risk: MergeRiskLevel;
|
|
162
|
+
top_reasons: TrustReason[];
|
|
163
|
+
fix_priorities: TrustFixPriority[];
|
|
164
|
+
diff_context?: TrustDiffContext;
|
|
165
|
+
advanced_context?: TrustAdvancedContext;
|
|
166
|
+
}
|
|
167
|
+
export interface TrustKpiDiagnostic {
|
|
168
|
+
level: 'warning' | 'error';
|
|
169
|
+
code: 'path-not-found' | 'path-not-supported' | 'read-failed' | 'parse-failed' | 'invalid-shape' | 'invalid-diff-context';
|
|
170
|
+
message: string;
|
|
171
|
+
file?: string;
|
|
172
|
+
}
|
|
173
|
+
export interface TrustScoreStats {
|
|
174
|
+
average: number | null;
|
|
175
|
+
median: number | null;
|
|
176
|
+
min: number | null;
|
|
177
|
+
max: number | null;
|
|
178
|
+
}
|
|
179
|
+
export interface TrustDiffTrendSummary {
|
|
180
|
+
available: boolean;
|
|
181
|
+
samples: number;
|
|
182
|
+
statusDistribution: {
|
|
183
|
+
improved: number;
|
|
184
|
+
regressed: number;
|
|
185
|
+
neutral: number;
|
|
186
|
+
};
|
|
187
|
+
scoreDelta: {
|
|
188
|
+
average: number | null;
|
|
189
|
+
median: number | null;
|
|
190
|
+
};
|
|
191
|
+
issues: {
|
|
192
|
+
newTotal: number;
|
|
193
|
+
resolvedTotal: number;
|
|
194
|
+
netNew: number;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export interface TrustKpiReport {
|
|
198
|
+
generatedAt: string;
|
|
199
|
+
input: string;
|
|
200
|
+
files: {
|
|
201
|
+
matched: number;
|
|
202
|
+
parsed: number;
|
|
203
|
+
malformed: number;
|
|
204
|
+
};
|
|
205
|
+
prsEvaluated: number;
|
|
206
|
+
mergeRiskDistribution: Record<MergeRiskLevel, number>;
|
|
207
|
+
trustScore: TrustScoreStats;
|
|
208
|
+
highRiskRatio: number | null;
|
|
209
|
+
diffTrend: TrustDiffTrendSummary;
|
|
210
|
+
diagnostics: TrustKpiDiagnostic[];
|
|
211
|
+
}
|
|
95
212
|
/**
|
|
96
213
|
* Layer definition for architectural boundary enforcement.
|
|
97
214
|
*/
|
|
@@ -116,11 +233,40 @@ export interface DriftConfig {
|
|
|
116
233
|
layers?: LayerDefinition[];
|
|
117
234
|
modules?: ModuleBoundary[];
|
|
118
235
|
plugins?: string[];
|
|
236
|
+
performance?: DriftPerformanceConfig;
|
|
119
237
|
architectureRules?: {
|
|
120
238
|
controllerNoDb?: boolean;
|
|
121
239
|
serviceNoHttp?: boolean;
|
|
122
240
|
maxFunctionLines?: number;
|
|
123
241
|
};
|
|
242
|
+
saas?: {
|
|
243
|
+
freeUserThreshold?: number;
|
|
244
|
+
maxRunsPerWorkspacePerMonth?: number;
|
|
245
|
+
maxReposPerWorkspace?: number;
|
|
246
|
+
retentionDays?: number;
|
|
247
|
+
strictActorEnforcement?: boolean;
|
|
248
|
+
maxWorkspacesPerOrganizationByPlan?: {
|
|
249
|
+
free?: number;
|
|
250
|
+
sponsor?: number;
|
|
251
|
+
team?: number;
|
|
252
|
+
business?: number;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
trustGate?: TrustGatePolicyConfig;
|
|
256
|
+
}
|
|
257
|
+
export interface DriftPerformanceConfig {
|
|
258
|
+
lowMemory?: boolean;
|
|
259
|
+
chunkSize?: number;
|
|
260
|
+
maxFiles?: number;
|
|
261
|
+
maxFileSizeKb?: number;
|
|
262
|
+
includeSemanticDuplication?: boolean;
|
|
263
|
+
}
|
|
264
|
+
export interface DriftAnalysisOptions {
|
|
265
|
+
lowMemory?: boolean;
|
|
266
|
+
chunkSize?: number;
|
|
267
|
+
maxFiles?: number;
|
|
268
|
+
maxFileSizeKb?: number;
|
|
269
|
+
includeSemanticDuplication?: boolean;
|
|
124
270
|
}
|
|
125
271
|
export interface PluginRuleContext {
|
|
126
272
|
projectRoot: string;
|
|
@@ -128,13 +274,17 @@ export interface PluginRuleContext {
|
|
|
128
274
|
config?: DriftConfig;
|
|
129
275
|
}
|
|
130
276
|
export interface DriftPluginRule {
|
|
277
|
+
id?: string;
|
|
131
278
|
name: string;
|
|
132
279
|
severity?: DriftIssue['severity'];
|
|
133
280
|
weight?: number;
|
|
134
281
|
detect: (file: SourceFile, context: PluginRuleContext) => DriftIssue[];
|
|
282
|
+
fix?: (issue: DriftIssue, file: SourceFile, context: PluginRuleContext) => DriftIssue | void;
|
|
135
283
|
}
|
|
136
284
|
export interface DriftPlugin {
|
|
137
285
|
name: string;
|
|
286
|
+
apiVersion?: number;
|
|
287
|
+
capabilities?: Record<string, string | number | boolean>;
|
|
138
288
|
rules: DriftPluginRule[];
|
|
139
289
|
}
|
|
140
290
|
export interface LoadedPlugin {
|
|
@@ -143,6 +293,16 @@ export interface LoadedPlugin {
|
|
|
143
293
|
}
|
|
144
294
|
export interface PluginLoadError {
|
|
145
295
|
pluginId: string;
|
|
296
|
+
pluginName?: string;
|
|
297
|
+
ruleId?: string;
|
|
298
|
+
code?: string;
|
|
299
|
+
message: string;
|
|
300
|
+
}
|
|
301
|
+
export interface PluginLoadWarning {
|
|
302
|
+
pluginId: string;
|
|
303
|
+
pluginName?: string;
|
|
304
|
+
ruleId?: string;
|
|
305
|
+
code?: string;
|
|
146
306
|
message: string;
|
|
147
307
|
}
|
|
148
308
|
export interface FileDiff {
|
package/docs/PRD.md
CHANGED
|
@@ -1,208 +1,235 @@
|
|
|
1
1
|
# PRD - drift
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Estado: Draft
|
|
5
|
-
Producto: `@eduardbar/drift`
|
|
3
|
+
> **AI Code Audit CLI para recuperar confianza de merge en PRs asistidos por IA.**
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
**Version del PRD**: 1.3.0-scope-refresh
|
|
6
|
+
**Version de producto vigente**: 1.2.0
|
|
7
|
+
**Estado**: Activo
|
|
8
|
+
**Producto**: `@eduardbar/drift`
|
|
9
|
+
**Owner**: Eduardo Barba
|
|
10
|
+
**Fecha**: 2026-03-15
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
---
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
## 1. Contexto y problema
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## 2) Vision de Producto
|
|
16
|
-
|
|
17
|
-
Ser la herramienta de referencia para equipos que usan IA para programar y necesitan detectar, priorizar y corregir deuda tecnica antes de que llegue a produccion.
|
|
18
|
-
|
|
19
|
-
## 3) Killer Feature
|
|
16
|
+
El uso de IA para programar acelera entregas, pero tambien aumenta ruido tecnico en Pull Requests: cambios grandes, deuda encubierta, reglas de arquitectura rotas y riesgo de merge dificil de evaluar rapido.
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
El diferencial principal de drift es detectar patrones de olor tecnico vinculados a codigo IA, estimar probabilidad de origen IA y traducir hallazgos en acciones concretas (fixes, comentarios de PR, reglas de arquitectura y reportes).
|
|
18
|
+
Hoy muchos equipos hacen review "a ojo" o dependen de checks incompletos. Resultado: se mergea codigo con riesgo real porque falta una senial consolidada y accionable para decidir si un PR esta listo.
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- Reducir riesgo de mantenimiento en repos con alto volumen de codigo IA.
|
|
28
|
-
- Dar feedback accionable en el punto de trabajo (CLI, PR y editor).
|
|
29
|
-
- Estandarizar calidad arquitectonica con reglas configurables por equipo.
|
|
30
|
-
- Escalar desde CLI local a experiencia organizacional (dashboard SaaS).
|
|
20
|
+
Drift se reposiciona para cerrar ese gap: pasar de "scanner de deuda" a "decision engine de confianza de merge" para repos TypeScript/JavaScript con flujo local y CI.
|
|
31
21
|
|
|
32
|
-
|
|
22
|
+
---
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
### 5.1 Detector de codigo generado por IA
|
|
37
|
-
|
|
38
|
-
- Objetivo: estimar `ai_likelihood` por archivo y listar `files_suspected`.
|
|
39
|
-
- Alcance MVP:
|
|
40
|
-
- Exponer `ai_likelihood` (0-100) dentro de salida JSON/AI.
|
|
41
|
-
- Agregar lista ordenada de archivos sospechados con score y reglas disparadas.
|
|
42
|
-
- No hacer afirmaciones absolutas; reportar como probabilidad.
|
|
43
|
-
- Criterios de aceptacion:
|
|
44
|
-
- `drift scan <path> --ai` incluye `ai_likelihood` por archivo.
|
|
45
|
-
- Reporte global incluye `files_suspected` y top N archivos.
|
|
46
|
-
- Tests cubren serializacion y orden de prioridad.
|
|
47
|
-
|
|
48
|
-
### 5.2 PR reviewer automatico (`drift review` + comentario en PR)
|
|
49
|
-
|
|
50
|
-
- Objetivo: revisar cambios de PR y publicar feedback tecnico automatico.
|
|
51
|
-
- Alcance MVP:
|
|
52
|
-
- Nuevo comando `drift review` para analizar diff contra base branch.
|
|
53
|
-
- Salida markdown apta para comentario de PR.
|
|
54
|
-
- Integracion base via GitHub CLI (`gh`) en CI.
|
|
55
|
-
- Criterios de aceptacion:
|
|
56
|
-
- `drift review --base main` devuelve score de PR y top issues.
|
|
57
|
-
- En workflow CI se publica un comentario unico actualizable.
|
|
58
|
-
- Si score supera umbral configurable, CI falla.
|
|
59
|
-
|
|
60
|
-
### 5.3 Reglas de arquitectura configurables
|
|
61
|
-
|
|
62
|
-
- Objetivo: habilitar reglas de arquitectura de negocio definidas por el equipo.
|
|
63
|
-
- Alcance MVP:
|
|
64
|
-
- Soporte en `drift.config.ts` para:
|
|
65
|
-
- `controller-no-db`
|
|
66
|
-
- `service-no-http`
|
|
67
|
-
- `max-function-lines`
|
|
68
|
-
- Mensajes de error claros con ubicacion y recomendacion.
|
|
69
|
-
- Criterios de aceptacion:
|
|
70
|
-
- Config valida y tipada.
|
|
71
|
-
- Reglas activas afectan score y aparecen en reporte.
|
|
72
|
-
- Fixtures de test para casos validos e invalidos.
|
|
24
|
+
## 2. Reposicionamiento de producto
|
|
73
25
|
|
|
74
|
-
###
|
|
26
|
+
### 2.1 Nueva tesis
|
|
75
27
|
|
|
76
|
-
|
|
77
|
-
- Alcance MVP:
|
|
78
|
-
- Score global del repo.
|
|
79
|
-
- Breakdown por severidad, regla y carpeta.
|
|
80
|
-
- Tendencia minima (ultimos snapshots locales).
|
|
81
|
-
- Criterios de aceptacion:
|
|
82
|
-
- `drift scan` muestra score repo + breakdown resumido.
|
|
83
|
-
- `--json` expone estructura consumible por CI/dashboard.
|
|
28
|
+
`drift` es un **AI Code Audit CLI** orientado a responder una pregunta critica antes de mergear:
|
|
84
29
|
|
|
85
|
-
|
|
30
|
+
**"Este PR asistido por IA es confiable para merge?"**
|
|
86
31
|
|
|
87
|
-
|
|
88
|
-
- Alcance MVP:
|
|
89
|
-
- Nuevo comando `drift map`.
|
|
90
|
-
- Genera `architecture.svg` desde imports y modulos detectados.
|
|
91
|
-
- Marca ciclos y violaciones de capas.
|
|
92
|
-
- Criterios de aceptacion:
|
|
93
|
-
- `drift map ./src` crea `architecture.svg` sin edicion manual.
|
|
94
|
-
- El SVG es legible en repos medianos (ej. <= 300 archivos TS).
|
|
32
|
+
### 2.2 North Star de posicionamiento
|
|
95
33
|
|
|
96
|
-
|
|
34
|
+
Mover el foco de "contar smells" a "reducir riesgo de merge" con una salida resumida, priorizada y utilizable por developers, reviewers y tech leads.
|
|
97
35
|
|
|
98
|
-
|
|
99
|
-
- Alcance MVP:
|
|
100
|
-
- Diagnosticos por archivo al guardar.
|
|
101
|
-
- Score visible por archivo.
|
|
102
|
-
- Quick actions para sugerencias simples.
|
|
103
|
-
- Criterios de aceptacion:
|
|
104
|
-
- La extension muestra issues drift en panel Problems.
|
|
105
|
-
- La latencia por archivo en save se mantiene en nivel usable.
|
|
36
|
+
---
|
|
106
37
|
|
|
107
|
-
|
|
38
|
+
## 3. Que NO es y que SI es Drift
|
|
108
39
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
40
|
+
| Categoria | Definicion |
|
|
41
|
+
|---|---|
|
|
42
|
+
| No es | Un code generator ni un copiloto para escribir features |
|
|
43
|
+
| No es | Un SaaS dependiente de backend propio para funcionar |
|
|
44
|
+
| No es | Un reemplazo completo de code review humano |
|
|
45
|
+
| No es | Un quality gate magico multi-lenguaje full stack |
|
|
46
|
+
| Si es | Un CLI local/CI de auditoria tecnica para codigo TypeScript/JavaScript |
|
|
47
|
+
| Si es | Un sistema de scoring y priorizacion de deuda con foco en riesgo de merge |
|
|
48
|
+
| Si es | Una herramienta para PRs asistidos por IA con salida accionable |
|
|
49
|
+
| Si es | Un producto operable sin infraestructura propietaria (user-run) |
|
|
118
50
|
|
|
119
|
-
|
|
51
|
+
---
|
|
120
52
|
|
|
121
|
-
|
|
122
|
-
// Antes
|
|
123
|
-
console.log(userData)
|
|
124
|
-
|
|
125
|
-
// Despues (sugerencia simple)
|
|
126
|
-
// Removed debug leftover; use structured logger if needed.
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### 5.8 Reporte tecnico (`drift report` -> `drift-report.html`)
|
|
130
|
-
|
|
131
|
-
- Objetivo: entregar reporte compartible para devs, tech leads y QA.
|
|
132
|
-
- Alcance MVP:
|
|
133
|
-
- Salida HTML `drift-report.html` con score, breakdown y top issues.
|
|
134
|
-
- Secciones por archivo con snippets y sugerencias.
|
|
135
|
-
- Criterios de aceptacion:
|
|
136
|
-
- `drift report ./src --html` genera archivo navegable.
|
|
137
|
-
- El reporte puede adjuntarse en CI artifacts.
|
|
138
|
-
|
|
139
|
-
### 5.9 Metricas de riesgo de mantenimiento (hotspots)
|
|
140
|
-
|
|
141
|
-
- Objetivo: priorizar deuda por impacto real.
|
|
142
|
-
- Alcance MVP:
|
|
143
|
-
- Hotspots combinando score + frecuencia de cambios + criticidad.
|
|
144
|
-
- Ranking de archivos para plan de refactor.
|
|
145
|
-
- Criterios de aceptacion:
|
|
146
|
-
- `drift trend` o salida dedicada muestra top hotspots.
|
|
147
|
-
- Metodo de ranking documentado y testeado.
|
|
148
|
-
|
|
149
|
-
### 5.10 Plugin system (`drift-plugin-*`)
|
|
150
|
-
|
|
151
|
-
- Objetivo: extender drift sin tocar el core.
|
|
152
|
-
- Alcance MVP:
|
|
153
|
-
- Carga de plugins por convension `drift-plugin-*`.
|
|
154
|
-
- API minima para registrar reglas y metadata.
|
|
155
|
-
- Aislamiento de errores de plugins para no romper scan completo.
|
|
156
|
-
- Criterios de aceptacion:
|
|
157
|
-
- Plugin de ejemplo funcional en repo de ejemplo.
|
|
158
|
-
- Si un plugin falla, drift sigue ejecutando y reporta el error.
|
|
53
|
+
## 4. Estado real del producto (v1.2.0)
|
|
159
54
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
### v1.1
|
|
163
|
-
|
|
164
|
-
- `drift review` para PR comments.
|
|
165
|
-
- Score de PR y score de repo con breakdown minimo.
|
|
55
|
+
### 4.1 Capacidades entregadas y activas
|
|
166
56
|
|
|
167
|
-
|
|
57
|
+
| Area | Estado | Capacidades vigentes |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| Analisis AST y scoring | Entregado | Reglas de drift, score por archivo/repositorio, salida CLI/JSON/AI |
|
|
60
|
+
| PR review | Entregado | `drift review` con diff vs base, markdown para PR, delta de issues |
|
|
61
|
+
| Arquitectura | Entregado | `drift map` con `architecture.svg`, cycle edges, layer violations |
|
|
62
|
+
| Fixes | Entregado | `drift fix --preview` y `drift fix --write` con confirmacion (`--yes` para CI) |
|
|
63
|
+
| Reporteria | Entregado | `drift report` HTML self-contained |
|
|
64
|
+
| CI | Entregado | Workflow para comentario unico y actualizable en PR |
|
|
65
|
+
| Editor | Entregado | VSCode quick actions para fixes de bajo riesgo |
|
|
66
|
+
| Extensibilidad | MVP entregado | Plugin system `drift-plugin-*` con aislamiento de errores |
|
|
67
|
+
| Foundations cloud-like | Entregado (base) | `drift cloud ingest|summary|dashboard`, politica free-until-7500 en PRD |
|
|
168
68
|
|
|
169
|
-
|
|
170
|
-
- `drift map` y generacion de `architecture.svg`.
|
|
69
|
+
### 4.2 Abiertos actuales
|
|
171
70
|
|
|
172
|
-
|
|
71
|
+
- Hardening del contrato de plugins para ecosistema externo de largo plazo.
|
|
72
|
+
- Evolucion de foundations cloud-like hacia experiencia multi-tenant completa (auth, roles, billing) cuando corresponda.
|
|
173
73
|
|
|
174
|
-
|
|
175
|
-
- `drift fix` con preview/write y fixes seguros.
|
|
74
|
+
Nota: este PRD no declara como implementado nada fuera de las capacidades ya reflejadas en v1.2.0.
|
|
176
75
|
|
|
177
|
-
|
|
76
|
+
---
|
|
178
77
|
|
|
179
|
-
|
|
78
|
+
## 5. Feature estrella: `drift trust`
|
|
180
79
|
|
|
181
|
-
|
|
80
|
+
### 5.1 Objetivo
|
|
182
81
|
|
|
183
|
-
|
|
184
|
-
- Autofix de reglas de alto riesgo sin confirmacion.
|
|
185
|
-
- Integraciones propietarias cerradas sin API estable.
|
|
82
|
+
Introducir `drift trust` como salida de alto nivel para decision de merge en PRs asistidos por IA.
|
|
186
83
|
|
|
187
|
-
|
|
84
|
+
### 5.2 Output conceptual esperado
|
|
188
85
|
|
|
189
|
-
|
|
190
|
-
- % de PRs con feedback drift resuelto antes de merge.
|
|
191
|
-
- Tiempo medio desde deteccion hasta fix aplicado.
|
|
192
|
-
- Adopcion de reglas de arquitectura por equipo.
|
|
86
|
+
`drift trust` debe sintetizar en un bloque corto y accionable:
|
|
193
87
|
|
|
194
|
-
|
|
88
|
+
| Campo | Proposito |
|
|
89
|
+
|---|---|
|
|
90
|
+
| Trust Score | Puntaje de confianza de merge (0-100) |
|
|
91
|
+
| Merge Risk | Clasificacion de riesgo (`LOW`, `MEDIUM`, `HIGH`, `CRITICAL`) |
|
|
92
|
+
| Top Reasons | Principales razones que explican el riesgo |
|
|
93
|
+
| Fix Priorities | Orden recomendado de correcciones para bajar riesgo rapido |
|
|
195
94
|
|
|
196
|
-
|
|
197
|
-
- Calidad de senial en `ai_likelihood` (riesgo de falsos positivos).
|
|
198
|
-
- Compatibilidad de integraciones CI/PR entre plataformas.
|
|
199
|
-
- Diseno de API de plugins sin romper backward compatibility.
|
|
95
|
+
### 5.3 Alcance funcional del feature
|
|
200
96
|
|
|
201
|
-
|
|
97
|
+
- Usa seniales ya existentes en Drift (reglas, severidad, diff, arquitectura, hotspots) para componer una conclusion ejecutiva.
|
|
98
|
+
- Prioriza interpretabilidad: cada resultado debe explicar por que sube/baja la confianza.
|
|
99
|
+
- Se diseña para uso local y CI sin requerir servicio central.
|
|
202
100
|
|
|
203
|
-
|
|
101
|
+
Importante: en este documento, `drift trust` se define como **scope de producto**; su implementacion tecnica se planifica por etapas.
|
|
204
102
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 6. Scope de producto: Core vs Premium
|
|
106
|
+
|
|
107
|
+
### 6.1 Drift Core (base abierta y utilizable)
|
|
108
|
+
|
|
109
|
+
| Incluido en Core | Notas |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `scan`, `review`, `fix`, `report`, `map`, `ci`, `diff`, `snapshot`, `trend`, `blame` | Mantiene propuesta actual de CLI tecnico |
|
|
112
|
+
| Reglas de drift y score base | Incluye salida JSON/AI para automatizacion |
|
|
113
|
+
| `drift trust` baseline | Trust Score + Merge Risk + Top Reasons + Fix Priorities en modo esencial |
|
|
114
|
+
| Uso local + CI en runners del usuario | Sin infraestructura Drift obligatoria |
|
|
115
|
+
|
|
116
|
+
### 6.2 Drift Premium (valor para equipos)
|
|
117
|
+
|
|
118
|
+
| Incluido en Premium | Propuesta de valor |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `drift trust` avanzado | Mayor contexto historico, comparativas y guidance de remediacion de equipo |
|
|
121
|
+
| Policy packs y controles por equipo | Gates y criterios de merge mas finos |
|
|
122
|
+
| Reportes ejecutivos extendidos | Vistas para liderazgo tecnico y seguimiento de riesgo |
|
|
123
|
+
| Soporte y prioridad | Respuesta mas rapida y acompanamiento de adopcion |
|
|
124
|
+
|
|
125
|
+
Nota: Premium define direccion comercial; la activacion concreta depende del roadmap de producto y capacidad operativa.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 7. Pricing inicial y propuesta comercial
|
|
130
|
+
|
|
131
|
+
### 7.1 Planes
|
|
132
|
+
|
|
133
|
+
| Plan | Precio | Publico objetivo | Valor principal |
|
|
134
|
+
|---|---:|---|---|
|
|
135
|
+
| Free | USD 0 (forever) | Developers individuales + open source | Analisis local ilimitado, output accionable y adopcion sin friccion |
|
|
136
|
+
| Sponsor | USD 8/mes o USD 80/anio | Fans, freelancers y power users | Apoyo al proyecto + rule packs premium ligeros + early access |
|
|
137
|
+
| Team | USD 39/mes por org o USD 390/anio | Equipos pequenos/medianos | Gobernanza inicial: policies, thresholds por branch y suppressions por regla |
|
|
138
|
+
| Business | USD 149/mes por org o USD 1490/anio | Equipos con mayor exigencia | Governance/compliance avanzado, custom rules y soporte prioritario |
|
|
139
|
+
|
|
140
|
+
### 7.2 Hipotesis de monetizacion
|
|
141
|
+
|
|
142
|
+
- Inicio con **GitHub Sponsors** como canal principal de conversion (Sponsor plan).
|
|
143
|
+
- Validar willingness-to-pay antes de escalar complejidad comercial.
|
|
144
|
+
- Evolucionar hacia Team/Business conforme se consolide `drift trust` y demanda de gobierno por equipo.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 8. Estrategia operativa (sin infraestructura propia)
|
|
149
|
+
|
|
150
|
+
### 8.1 Principios
|
|
151
|
+
|
|
152
|
+
- Drift corre donde ya corre el codigo: laptop del developer, CI existente, runners del usuario.
|
|
153
|
+
- No se requiere backend propietario para la propuesta principal de valor.
|
|
154
|
+
- Costos operativos iniciales bajos para maximizar foco en producto y distribucion.
|
|
155
|
+
|
|
156
|
+
### 8.2 Modelo operativo
|
|
157
|
+
|
|
158
|
+
| Dimension | Decision |
|
|
159
|
+
|---|---|
|
|
160
|
+
| Compute | Local/CI del usuario |
|
|
161
|
+
| Storage | Artefactos y reportes en entorno del usuario |
|
|
162
|
+
| Integracion | CLI + GitHub Actions + outputs markdown/JSON/AI |
|
|
163
|
+
| Monetizacion inicial | GitHub Sponsors + futura oferta Team/Business |
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 9. Launch strategy por etapas
|
|
168
|
+
|
|
169
|
+
### Etapa 1 - Reposicionamiento y mensaje (inmediato)
|
|
170
|
+
|
|
171
|
+
- Actualizar narrativa publica: de "deuda tecnica IA" a "merge trust para PRs asistidos por IA".
|
|
172
|
+
- Publicar docs y ejemplos orientados a decision de merge.
|
|
173
|
+
- CTA principal: probar `drift review` y futura experiencia `drift trust`.
|
|
174
|
+
|
|
175
|
+
### Etapa 2 - `drift trust` baseline (producto)
|
|
176
|
+
|
|
177
|
+
- Entregar salida conceptual en CLI/CI con Trust Score, Merge Risk, Top Reasons, Fix Priorities.
|
|
178
|
+
- Incorporar senales de diff/PR de forma deterministica (`--base`) y salida markdown lista para comentarios de PR.
|
|
179
|
+
- Medir adopcion en PR workflows y feedback de interpretabilidad.
|
|
180
|
+
- Ajustar pesos/heuristicas con evidencia de uso real.
|
|
181
|
+
|
|
182
|
+
### Etapa 3 - Conversion y expansion
|
|
183
|
+
|
|
184
|
+
- Activar perks para Sponsor y clarificar diferencia Core vs Premium.
|
|
185
|
+
- Formalizar Team plan con policies y reportes de riesgo compartidos.
|
|
186
|
+
- Preparar oferta Business para cuentas con necesidad de governance.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 10. Positioning copy (taglines y one-liners)
|
|
191
|
+
|
|
192
|
+
### 10.1 Taglines
|
|
193
|
+
|
|
194
|
+
- "Merge con confianza, incluso cuando el PR vino asistido por IA."
|
|
195
|
+
- "Tu AI Code Audit CLI para decidir merge sin adivinar."
|
|
196
|
+
- "Menos ruido de PR, mas confianza de release."
|
|
197
|
+
|
|
198
|
+
### 10.2 One-liners
|
|
199
|
+
|
|
200
|
+
- "Drift convierte senales tecnicas de un PR en una decision clara de merge risk."
|
|
201
|
+
- "Deuda tecnica IA detectada, priorizada y traducida a acciones concretas antes de mergear."
|
|
202
|
+
- "TypeScript AI audit en local y CI, sin depender de infraestructura externa."
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 11. KPIs y metricas de exito
|
|
207
|
+
|
|
208
|
+
| KPI | Objetivo |
|
|
209
|
+
|---|---|
|
|
210
|
+
| % de PRs evaluados con senial de confianza | Medir adopcion de flujo `review/trust` |
|
|
211
|
+
| Reduccion de issues de alto riesgo antes de merge | Medir impacto real en calidad |
|
|
212
|
+
| Tiempo desde deteccion a fix | Medir accionabilidad de la salida |
|
|
213
|
+
| Conversion a Sponsor/Team | Validar monetizacion temprana |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## 12. Riesgos y mitigaciones
|
|
218
|
+
|
|
219
|
+
| Riesgo | Mitigacion |
|
|
220
|
+
|---|---|
|
|
221
|
+
| Falsos positivos en senal de riesgo | Transparencia en Top Reasons + ajuste iterativo de reglas/pesos |
|
|
222
|
+
| Confusion entre "auditoria" y "autofix magico" | Mensaje explicito de que Drift no reemplaza revision humana |
|
|
223
|
+
| Presion por features enterprise tempranas | Enfoque por etapas: Sponsors primero, Team/Business luego |
|
|
224
|
+
| Variabilidad de entornos CI | Mantener salida portable y documentar integraciones recomendadas |
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## 13. Definition of Done para este refresh de scope
|
|
229
|
+
|
|
230
|
+
- PRD unificado con posicionamiento "AI Code Audit CLI".
|
|
231
|
+
- `drift trust` definido como feature estrella con output conceptual completo.
|
|
232
|
+
- Delimitacion explicita de que Drift es/no es.
|
|
233
|
+
- Pricing y Core vs Premium documentados de forma consistente.
|
|
234
|
+
- Estrategia operativa sin infraestructura propia y monetizacion via Sponsors declaradas.
|
|
235
|
+
- Launch strategy por etapas y copy de posicionamiento incluidos.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Drift Plugin Contract (v2)
|
|
2
|
+
|
|
3
|
+
This document defines the external plugin contract for `@eduardbar/drift`.
|
|
4
|
+
|
|
5
|
+
## Minimal plugin shape
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
module.exports = {
|
|
9
|
+
name: 'my-plugin',
|
|
10
|
+
apiVersion: 1,
|
|
11
|
+
capabilities: {
|
|
12
|
+
fixes: true,
|
|
13
|
+
tags: 'security',
|
|
14
|
+
},
|
|
15
|
+
rules: [
|
|
16
|
+
{
|
|
17
|
+
id: 'no-debug-leftovers',
|
|
18
|
+
severity: 'warning',
|
|
19
|
+
weight: 8,
|
|
20
|
+
detect(file, context) {
|
|
21
|
+
return []
|
|
22
|
+
},
|
|
23
|
+
fix(issue, file, context) {
|
|
24
|
+
return issue
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Contract rules
|
|
32
|
+
|
|
33
|
+
- `name`: required non-empty string.
|
|
34
|
+
- `apiVersion`: recommended and currently supported value is `1`.
|
|
35
|
+
- `capabilities`: optional object map with primitive values (`string | number | boolean`).
|
|
36
|
+
- `rules`: required array with at least one valid rule.
|
|
37
|
+
- Rule `id` (or legacy `name` fallback):
|
|
38
|
+
- for `apiVersion: 1` must match `^[a-z][a-z0-9]*(?:[-_/][a-z0-9]+)*$`
|
|
39
|
+
- must be unique within the plugin.
|
|
40
|
+
- `detect(file, context)`: required function returning `DriftIssue[]`.
|
|
41
|
+
|
|
42
|
+
## Legacy compatibility
|
|
43
|
+
|
|
44
|
+
- Plugins without `apiVersion` still load for backward compatibility.
|
|
45
|
+
- Drift emits warning code `plugin-api-version-implicit` and assumes compatibility mode.
|
|
46
|
+
- In compatibility mode, non-standard rule IDs are warnings (`plugin-rule-id-format-legacy`) instead of hard errors.
|
|
47
|
+
|
|
48
|
+
## Failure isolation
|
|
49
|
+
|
|
50
|
+
- Invalid plugin contracts are skipped and reported as diagnostics.
|
|
51
|
+
- Runtime errors thrown by one plugin rule are isolated to that rule; scan continues for other rules/files.
|
|
52
|
+
|
|
53
|
+
## Common diagnostic codes
|
|
54
|
+
|
|
55
|
+
- `plugin-api-version-implicit`: missing `apiVersion`; plugin loaded in legacy mode.
|
|
56
|
+
- `plugin-api-version-invalid`: `apiVersion` is not a positive integer.
|
|
57
|
+
- `plugin-api-version-unsupported`: plugin version is not supported by current drift runtime.
|
|
58
|
+
- `plugin-rule-id-invalid`: rule ID format invalid for explicit API version.
|
|
59
|
+
- `plugin-rule-id-duplicate`: duplicate rule ID inside the same plugin.
|
|
60
|
+
- `plugin-capabilities-invalid`: `capabilities` is not an object.
|
|
61
|
+
- `plugin-capabilities-value-invalid`: capability value is not a primitive.
|