agent-rules-init 0.2.1 → 0.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/dist/cli.d.ts +18 -0
- package/dist/cli.js +77 -23
- package/dist/core/i18n.d.ts +44 -0
- package/dist/core/i18n.js +176 -0
- package/dist/core/llm-bridge.d.ts +2 -1
- package/dist/core/llm-bridge.js +4 -4
- package/dist/core/prompt-engine.d.ts +3 -1
- package/dist/core/prompt-engine.js +19 -14
- package/dist/core/repo-facts.d.ts +20 -0
- package/dist/core/repo-facts.js +198 -0
- package/dist/core/scanner.js +26 -3
- package/dist/core/templates.d.ts +6 -4
- package/dist/core/templates.js +48 -23
- package/dist/core/types.d.ts +33 -2
- package/dist/core/writer.d.ts +1 -1
- package/dist/core/writer.js +3 -1
- package/dist/packs/cpp.js +33 -27
- package/dist/packs/csharp.js +32 -27
- package/dist/packs/dart.js +30 -31
- package/dist/packs/elixir.js +31 -27
- package/dist/packs/go.js +31 -27
- package/dist/packs/java.js +33 -27
- package/dist/packs/js-ts.js +42 -32
- package/dist/packs/kotlin.js +32 -27
- package/dist/packs/php.js +30 -27
- package/dist/packs/python.js +35 -27
- package/dist/packs/r.js +30 -27
- package/dist/packs/ruby.js +36 -27
- package/dist/packs/rust.js +33 -27
- package/dist/packs/scala.js +32 -27
- package/dist/packs/swift.js +31 -27
- package/package.json +3 -2
package/dist/packs/dart.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, unknownRunnerLabel, } from "../core/i18n.js";
|
|
1
2
|
function detect(signals) {
|
|
2
3
|
const source = signals.pubspecYaml;
|
|
3
4
|
if (!source)
|
|
@@ -21,41 +22,39 @@ function detect(signals) {
|
|
|
21
22
|
packageManager: { value: "pub", confidence: "high" },
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const TEXTS = {
|
|
26
|
+
es: {
|
|
27
|
+
style: "Sigue la guía de estilo oficial de Dart (dart.dev/effective-dart/style).",
|
|
28
|
+
deps: "Declara toda dependencia nueva en pubspec.yaml, nunca la instales sin registrarla.",
|
|
29
|
+
archFlutter: "Separa la lógica de negocio de los widgets cuando el proyecto ya siga ese patrón (p. ej. BLoC/Provider/Riverpod).",
|
|
30
|
+
archPlain: "Mantén los módulos con una responsabilidad clara.",
|
|
31
|
+
immutability: "Prefiere `final`/`const` sobre variables mutables cuando sea posible.",
|
|
32
|
+
},
|
|
33
|
+
en: {
|
|
34
|
+
style: "Follow the official Dart style guide (dart.dev/effective-dart/style).",
|
|
35
|
+
deps: "Declare every new dependency in pubspec.yaml; never install one without registering it.",
|
|
36
|
+
archFlutter: "Keep business logic out of widgets when the project already follows that pattern (e.g. BLoC/Provider/Riverpod).",
|
|
37
|
+
archPlain: "Keep modules single-purpose.",
|
|
38
|
+
immutability: "Prefer `final`/`const` over mutable variables when possible.",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
function rules(detection, lang) {
|
|
42
|
+
const t = TEXTS[lang];
|
|
43
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
44
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner?.value : undefined;
|
|
26
45
|
return {
|
|
27
|
-
summary:
|
|
28
|
-
conventions: [
|
|
29
|
-
|
|
30
|
-
`Ejecuta los tests con ${detection.testRunner?.value !== "unknown" ? detection.testRunner?.value : "el test runner del proyecto"} antes de terminar una tarea.`,
|
|
31
|
-
"Declara toda dependencia nueva en pubspec.yaml, nunca la instales sin registrarla.",
|
|
32
|
-
],
|
|
33
|
-
architectureNotes: [
|
|
34
|
-
framework === "flutter"
|
|
35
|
-
? "Separa la lógica de negocio de los widgets cuando el proyecto ya siga ese patrón (p. ej. BLoC/Provider/Riverpod)."
|
|
36
|
-
: "Mantén los módulos con una responsabilidad clara.",
|
|
37
|
-
"Prefiere `final`/`const` sobre variables mutables cuando sea posible.",
|
|
38
|
-
],
|
|
46
|
+
summary: summarySentence(lang, "Dart", framework, "pub"),
|
|
47
|
+
conventions: [t.style, runTestsConvention(lang, runner ?? unknownRunnerLabel(lang)), t.deps],
|
|
48
|
+
architectureNotes: [framework === "flutter" ? t.archFlutter : t.archPlain, t.immutability],
|
|
39
49
|
};
|
|
40
50
|
}
|
|
41
|
-
function promptTemplates(detection) {
|
|
42
|
-
const framework = detection.framework?.value
|
|
51
|
+
function promptTemplates(detection, lang) {
|
|
52
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
53
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner.value : unknownRunnerLabel(lang);
|
|
43
54
|
return [
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
body: `Revisa el diff actual buscando bugs y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "refactor",
|
|
51
|
-
title: "Refactor (Dart)",
|
|
52
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: "testing",
|
|
56
|
-
title: "Testing (Dart)",
|
|
57
|
-
body: `Escribe tests con ${detection.testRunner?.value !== "unknown" ? detection.testRunner?.value : "el test runner del proyecto"} para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
|
|
58
|
-
},
|
|
55
|
+
{ id: "review", title: "Code Review (Dart)", body: reviewBody(lang, "", framework) },
|
|
56
|
+
{ id: "refactor", title: "Refactor (Dart)", body: refactorBody(lang) },
|
|
57
|
+
{ id: "testing", title: "Testing (Dart)", body: testingBody(lang, runner) },
|
|
59
58
|
];
|
|
60
59
|
}
|
|
61
60
|
export const dartPack = { id: "dart", detect, rules, promptTemplates };
|
package/dist/packs/elixir.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, } from "../core/i18n.js";
|
|
1
2
|
function detect(signals) {
|
|
2
3
|
const source = signals.mixExs;
|
|
3
4
|
if (!source)
|
|
@@ -18,39 +19,42 @@ function detect(signals) {
|
|
|
18
19
|
packageManager: { value: "mix", confidence: "high" },
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"Sigue la guía de estilo oficial de Elixir; ejecuta `mix format` antes de terminar una tarea.",
|
|
27
|
-
"Ejecuta los tests con `mix test` antes de terminar una tarea.",
|
|
28
|
-
"Prefiere pattern matching y pipelines (`|>`) sobre anidar llamadas de función.",
|
|
29
|
-
],
|
|
30
|
-
architectureNotes: [
|
|
22
|
+
const TEXTS = {
|
|
23
|
+
es: {
|
|
24
|
+
style: "Sigue la guía de estilo oficial de Elixir; ejecuta `mix format` antes de terminar una tarea.",
|
|
25
|
+
patterns: "Prefiere pattern matching y pipelines (`|>`) sobre anidar llamadas de función.",
|
|
26
|
+
arch: [
|
|
31
27
|
"Respeta la separación entre contextos (lógica de negocio) y la capa web si el proyecto ya usa Phoenix.",
|
|
32
28
|
"Declara toda dependencia nueva en `mix.exs` y mantén `mix.lock` sincronizado.",
|
|
33
29
|
],
|
|
30
|
+
reviewFocus: "procesos sin supervisar correctamente",
|
|
31
|
+
},
|
|
32
|
+
en: {
|
|
33
|
+
style: "Follow the official Elixir style guide; run `mix format` before finishing a task.",
|
|
34
|
+
patterns: "Prefer pattern matching and pipelines (`|>`) over nesting function calls.",
|
|
35
|
+
arch: [
|
|
36
|
+
"Respect the separation between contexts (business logic) and the web layer if the project already uses Phoenix.",
|
|
37
|
+
"Declare every new dependency in `mix.exs` and keep `mix.lock` in sync.",
|
|
38
|
+
],
|
|
39
|
+
reviewFocus: "improperly supervised processes",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
function rules(detection, lang) {
|
|
43
|
+
const t = TEXTS[lang];
|
|
44
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
45
|
+
return {
|
|
46
|
+
summary: summarySentence(lang, "Elixir", framework, "mix"),
|
|
47
|
+
conventions: [t.style, runTestsConvention(lang, "`mix test`"), t.patterns],
|
|
48
|
+
architectureNotes: t.arch,
|
|
34
49
|
};
|
|
35
50
|
}
|
|
36
|
-
function promptTemplates(detection) {
|
|
37
|
-
const
|
|
51
|
+
function promptTemplates(detection, lang) {
|
|
52
|
+
const t = TEXTS[lang];
|
|
53
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
38
54
|
return [
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
body: `Revisa el diff actual buscando bugs, procesos sin supervisar correctamente y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
id: "refactor",
|
|
46
|
-
title: "Refactor (Elixir)",
|
|
47
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "testing",
|
|
51
|
-
title: "Testing (Elixir)",
|
|
52
|
-
body: `Escribe tests con \`mix test\` (ExUnit) para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
|
|
53
|
-
},
|
|
55
|
+
{ id: "review", title: "Code Review (Elixir)", body: reviewBody(lang, t.reviewFocus, framework) },
|
|
56
|
+
{ id: "refactor", title: "Refactor (Elixir)", body: refactorBody(lang) },
|
|
57
|
+
{ id: "testing", title: "Testing (Elixir)", body: testingBody(lang, "`mix test` (ExUnit)") },
|
|
54
58
|
];
|
|
55
59
|
}
|
|
56
60
|
export const elixirPack = { id: "elixir", detect, rules, promptTemplates };
|
package/dist/packs/go.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, } from "../core/i18n.js";
|
|
1
2
|
const FRAMEWORKS = [
|
|
2
3
|
["gin-gonic/gin", "gin"],
|
|
3
4
|
["labstack/echo", "echo"],
|
|
@@ -36,39 +37,42 @@ function detect(signals) {
|
|
|
36
37
|
packageManager: { value: "go modules", confidence: "high" },
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"Sigue el formato estándar de `gofmt`; no introduzcas estilos alternativos.",
|
|
45
|
-
"Ejecuta los tests con `go test ./...` antes de terminar una tarea.",
|
|
46
|
-
"Maneja los errores explícitamente (`if err != nil`); no los ignores en silencio.",
|
|
47
|
-
],
|
|
48
|
-
architectureNotes: [
|
|
40
|
+
const TEXTS = {
|
|
41
|
+
es: {
|
|
42
|
+
style: "Sigue el formato estándar de `gofmt`; no introduzcas estilos alternativos.",
|
|
43
|
+
errors: "Maneja los errores explícitamente (`if err != nil`); no los ignores en silencio.",
|
|
44
|
+
arch: [
|
|
49
45
|
"Mantén los paquetes con una responsabilidad clara; evita paquetes `util` genéricos.",
|
|
50
46
|
"Declara toda dependencia nueva vía `go get` y mantén `go.mod`/`go.sum` sincronizados.",
|
|
51
47
|
],
|
|
48
|
+
reviewFocus: "manejo de errores omitido",
|
|
49
|
+
},
|
|
50
|
+
en: {
|
|
51
|
+
style: "Follow the standard `gofmt` formatting; do not introduce alternative styles.",
|
|
52
|
+
errors: "Handle errors explicitly (`if err != nil`); never ignore them silently.",
|
|
53
|
+
arch: [
|
|
54
|
+
"Keep packages single-purpose; avoid generic `util` packages.",
|
|
55
|
+
"Declare every new dependency via `go get` and keep `go.mod`/`go.sum` in sync.",
|
|
56
|
+
],
|
|
57
|
+
reviewFocus: "missing error handling",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
function rules(detection, lang) {
|
|
61
|
+
const t = TEXTS[lang];
|
|
62
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
63
|
+
return {
|
|
64
|
+
summary: summarySentence(lang, "Go", framework, "go modules"),
|
|
65
|
+
conventions: [t.style, runTestsConvention(lang, "`go test ./...`"), t.errors],
|
|
66
|
+
architectureNotes: t.arch,
|
|
52
67
|
};
|
|
53
68
|
}
|
|
54
|
-
function promptTemplates(detection) {
|
|
55
|
-
const
|
|
69
|
+
function promptTemplates(detection, lang) {
|
|
70
|
+
const t = TEXTS[lang];
|
|
71
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
56
72
|
return [
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
body: `Revisa el diff actual buscando bugs, manejo de errores omitido y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: "refactor",
|
|
64
|
-
title: "Refactor (Go)",
|
|
65
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
id: "testing",
|
|
69
|
-
title: "Testing (Go)",
|
|
70
|
-
body: `Escribe tests con \`go test\` para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
|
|
71
|
-
},
|
|
73
|
+
{ id: "review", title: "Code Review (Go)", body: reviewBody(lang, t.reviewFocus, framework) },
|
|
74
|
+
{ id: "refactor", title: "Refactor (Go)", body: refactorBody(lang) },
|
|
75
|
+
{ id: "testing", title: "Testing (Go)", body: testingBody(lang, "`go test`") },
|
|
72
76
|
];
|
|
73
77
|
}
|
|
74
78
|
export const goPack = { id: "go", detect, rules, promptTemplates };
|
package/dist/packs/java.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, unknownRunnerLabel, } from "../core/i18n.js";
|
|
1
2
|
function detect(signals) {
|
|
2
3
|
const source = signals.pomXml ?? signals.buildGradle;
|
|
3
4
|
if (!source)
|
|
@@ -21,39 +22,44 @@ function detect(signals) {
|
|
|
21
22
|
: { value: "unknown", confidence: "low" };
|
|
22
23
|
return { packId: "java", language: "Java", framework, packageManager, testRunner };
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"Sigue las convenciones de nombrado estándar de Java (PascalCase para clases, camelCase para métodos).",
|
|
30
|
-
`Ejecuta los tests con ${detection.packageManager?.value === "maven" ? "mvn test" : "gradle test"} antes de terminar una tarea.`,
|
|
31
|
-
"No añadas dependencias nuevas sin declararlas en el gestor de build existente.",
|
|
32
|
-
],
|
|
33
|
-
architectureNotes: [
|
|
25
|
+
const TEXTS = {
|
|
26
|
+
es: {
|
|
27
|
+
naming: "Sigue las convenciones de nombrado estándar de Java (PascalCase para clases, camelCase para métodos).",
|
|
28
|
+
deps: "No añadas dependencias nuevas sin declararlas en el gestor de build existente.",
|
|
29
|
+
arch: [
|
|
34
30
|
"Respeta la separación en capas (controller/service/repository) si el proyecto ya la usa.",
|
|
35
31
|
"Prefiere inyección de dependencias sobre instanciación manual cuando el framework ya la ofrezca.",
|
|
36
32
|
],
|
|
33
|
+
reviewFocus: "null-safety",
|
|
34
|
+
},
|
|
35
|
+
en: {
|
|
36
|
+
naming: "Follow standard Java naming conventions (PascalCase for classes, camelCase for methods).",
|
|
37
|
+
deps: "Do not add new dependencies without declaring them in the existing build tool.",
|
|
38
|
+
arch: [
|
|
39
|
+
"Respect the layered separation (controller/service/repository) if the project already uses it.",
|
|
40
|
+
"Prefer dependency injection over manual instantiation when the framework already provides it.",
|
|
41
|
+
],
|
|
42
|
+
reviewFocus: "null-safety",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
function rules(detection, lang) {
|
|
46
|
+
const t = TEXTS[lang];
|
|
47
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
48
|
+
const testCmd = detection.packageManager?.value === "maven" ? "mvn test" : "gradle test";
|
|
49
|
+
return {
|
|
50
|
+
summary: summarySentence(lang, "Java", framework, detection.packageManager?.value),
|
|
51
|
+
conventions: [t.naming, runTestsConvention(lang, testCmd), t.deps],
|
|
52
|
+
architectureNotes: t.arch,
|
|
37
53
|
};
|
|
38
54
|
}
|
|
39
|
-
function promptTemplates(detection) {
|
|
40
|
-
const
|
|
55
|
+
function promptTemplates(detection, lang) {
|
|
56
|
+
const t = TEXTS[lang];
|
|
57
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
58
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner.value : unknownRunnerLabel(lang);
|
|
41
59
|
return [
|
|
42
|
-
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
body: `Revisa el diff actual buscando bugs, null-safety y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: "refactor",
|
|
49
|
-
title: "Refactor (Java)",
|
|
50
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: "testing",
|
|
54
|
-
title: "Testing (Java)",
|
|
55
|
-
body: `Escribe tests con ${detection.testRunner?.value ?? "el test runner del proyecto"} para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
|
|
56
|
-
},
|
|
60
|
+
{ id: "review", title: "Code Review (Java)", body: reviewBody(lang, t.reviewFocus, framework) },
|
|
61
|
+
{ id: "refactor", title: "Refactor (Java)", body: refactorBody(lang) },
|
|
62
|
+
{ id: "testing", title: "Testing (Java)", body: testingBody(lang, runner) },
|
|
57
63
|
];
|
|
58
64
|
}
|
|
59
65
|
export const javaPack = { id: "java", detect, rules, promptTemplates };
|
package/dist/packs/js-ts.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, unknownRunnerLabel, } from "../core/i18n.js";
|
|
1
2
|
const FRAMEWORKS = {
|
|
2
3
|
next: "next",
|
|
3
4
|
"@nestjs/core": "nestjs",
|
|
@@ -58,44 +59,53 @@ function detect(signals) {
|
|
|
58
59
|
moduleFormat,
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
conventions.push(`Ejecuta los tests con ${testRunner === "unknown" ? "el test runner del proyecto" : testRunner} antes de dar por terminada una tarea.`);
|
|
69
|
-
conventions.push(detection.moduleFormat === "module"
|
|
70
|
-
? "Sigue el estilo de módulos ES existente (import/export), no mezcles con require()."
|
|
71
|
-
: "Sigue el estilo CommonJS existente (require()/module.exports), no mezcles con import/export.");
|
|
72
|
-
return {
|
|
73
|
-
summary: `Proyecto ${detection.usesTypeScript ? "TypeScript" : "JavaScript"}${framework !== "none" ? ` con ${framework}` : ""}.`,
|
|
74
|
-
conventions,
|
|
75
|
-
architectureNotes: [
|
|
62
|
+
const TEXTS = {
|
|
63
|
+
es: {
|
|
64
|
+
tsStrict: "Usa TypeScript estricto; evita `any` salvo justificación explícita.",
|
|
65
|
+
esModules: "Sigue el estilo de módulos ES existente (import/export), no mezcles con require().",
|
|
66
|
+
commonJs: "Sigue el estilo CommonJS existente (require()/module.exports), no mezcles con import/export.",
|
|
67
|
+
arch: [
|
|
76
68
|
"Mantén los componentes/módulos pequeños y con una responsabilidad clara.",
|
|
77
69
|
"Coloca los tests junto al código que prueban o en un directorio `test/` espejo, según lo que ya use el repo.",
|
|
78
70
|
],
|
|
71
|
+
reviewFocus: "errores de tipado, condiciones de carrera en async/await",
|
|
72
|
+
refactorExtra: "Respeta los tipos existentes.",
|
|
73
|
+
},
|
|
74
|
+
en: {
|
|
75
|
+
tsStrict: "Use strict TypeScript; avoid `any` unless explicitly justified.",
|
|
76
|
+
esModules: "Follow the existing ES modules style (import/export); do not mix in require().",
|
|
77
|
+
commonJs: "Follow the existing CommonJS style (require()/module.exports); do not mix in import/export.",
|
|
78
|
+
arch: [
|
|
79
|
+
"Keep components/modules small and single-purpose.",
|
|
80
|
+
"Place tests next to the code they cover or in a mirrored `test/` directory, following what the repo already uses.",
|
|
81
|
+
],
|
|
82
|
+
reviewFocus: "typing errors, async/await race conditions",
|
|
83
|
+
refactorExtra: "Respect the existing types.",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
function rules(detection, lang) {
|
|
87
|
+
const t = TEXTS[lang];
|
|
88
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
89
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner?.value : undefined;
|
|
90
|
+
const conventions = [];
|
|
91
|
+
if (detection.usesTypeScript)
|
|
92
|
+
conventions.push(t.tsStrict);
|
|
93
|
+
conventions.push(runTestsConvention(lang, runner ?? unknownRunnerLabel(lang)));
|
|
94
|
+
conventions.push(detection.moduleFormat === "module" ? t.esModules : t.commonJs);
|
|
95
|
+
return {
|
|
96
|
+
summary: summarySentence(lang, detection.usesTypeScript ? "TypeScript" : "JavaScript", framework),
|
|
97
|
+
conventions,
|
|
98
|
+
architectureNotes: t.arch,
|
|
79
99
|
};
|
|
80
100
|
}
|
|
81
|
-
function promptTemplates(detection) {
|
|
82
|
-
const
|
|
101
|
+
function promptTemplates(detection, lang) {
|
|
102
|
+
const t = TEXTS[lang];
|
|
103
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
104
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner.value : unknownRunnerLabel(lang);
|
|
83
105
|
return [
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
body: `Revisa el diff actual buscando bugs de tipado, condiciones de carrera en async/await, y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
id: "refactor",
|
|
91
|
-
title: "Refactor (JS/TS)",
|
|
92
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable. Respeta los tipos existentes.`,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
id: "testing",
|
|
96
|
-
title: "Testing (JS/TS)",
|
|
97
|
-
body: `Escribe tests para el código señalado usando el test runner detectado (${detection.testRunner?.value ?? "el del proyecto"}). Cubre el camino feliz y al menos un caso límite.`,
|
|
98
|
-
},
|
|
106
|
+
{ id: "review", title: "Code Review (JS/TS)", body: reviewBody(lang, t.reviewFocus, framework) },
|
|
107
|
+
{ id: "refactor", title: "Refactor (JS/TS)", body: refactorBody(lang, t.refactorExtra) },
|
|
108
|
+
{ id: "testing", title: "Testing (JS/TS)", body: testingBody(lang, runner) },
|
|
99
109
|
];
|
|
100
110
|
}
|
|
101
111
|
export const jsTsPack = { id: "js-ts", detect, rules, promptTemplates };
|
package/dist/packs/kotlin.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, unknownRunnerLabel, } from "../core/i18n.js";
|
|
1
2
|
function detect(signals) {
|
|
2
3
|
const source = signals.buildGradle;
|
|
3
4
|
if (!source)
|
|
@@ -27,39 +28,43 @@ function detect(signals) {
|
|
|
27
28
|
packageManager: { value: "gradle", confidence: "high" },
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"Sigue las convenciones de estilo oficiales de Kotlin (kotlinlang.org/docs/coding-conventions.html).",
|
|
36
|
-
"Ejecuta los tests con `gradle test` antes de terminar una tarea.",
|
|
37
|
-
"Prefiere tipos no-nulos y `val` sobre `var` salvo que la mutabilidad sea necesaria.",
|
|
38
|
-
],
|
|
39
|
-
architectureNotes: [
|
|
31
|
+
const TEXTS = {
|
|
32
|
+
es: {
|
|
33
|
+
style: "Sigue las convenciones de estilo oficiales de Kotlin (kotlinlang.org/docs/coding-conventions.html).",
|
|
34
|
+
nullsafety: "Prefiere tipos no-nulos y `val` sobre `var` salvo que la mutabilidad sea necesaria.",
|
|
35
|
+
arch: [
|
|
40
36
|
"Respeta la separación en capas (controller/service/repository) si el proyecto ya la usa.",
|
|
41
37
|
"Prefiere inyección de dependencias sobre instanciación manual cuando el framework ya la ofrezca.",
|
|
42
38
|
],
|
|
39
|
+
reviewFocus: "uso innecesario de `!!`",
|
|
40
|
+
},
|
|
41
|
+
en: {
|
|
42
|
+
style: "Follow the official Kotlin style conventions (kotlinlang.org/docs/coding-conventions.html).",
|
|
43
|
+
nullsafety: "Prefer non-null types and `val` over `var` unless mutability is required.",
|
|
44
|
+
arch: [
|
|
45
|
+
"Respect the layered separation (controller/service/repository) if the project already uses it.",
|
|
46
|
+
"Prefer dependency injection over manual instantiation when the framework already provides it.",
|
|
47
|
+
],
|
|
48
|
+
reviewFocus: "unnecessary `!!` usage",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
function rules(detection, lang) {
|
|
52
|
+
const t = TEXTS[lang];
|
|
53
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
54
|
+
return {
|
|
55
|
+
summary: summarySentence(lang, "Kotlin", framework, "gradle"),
|
|
56
|
+
conventions: [t.style, runTestsConvention(lang, "`gradle test`"), t.nullsafety],
|
|
57
|
+
architectureNotes: t.arch,
|
|
43
58
|
};
|
|
44
59
|
}
|
|
45
|
-
function promptTemplates(detection) {
|
|
46
|
-
const
|
|
60
|
+
function promptTemplates(detection, lang) {
|
|
61
|
+
const t = TEXTS[lang];
|
|
62
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
63
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner.value : unknownRunnerLabel(lang);
|
|
47
64
|
return [
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
body: `Revisa el diff actual buscando bugs, uso innecesario de \`!!\` y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
id: "refactor",
|
|
55
|
-
title: "Refactor (Kotlin)",
|
|
56
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "testing",
|
|
60
|
-
title: "Testing (Kotlin)",
|
|
61
|
-
body: `Escribe tests con ${detection.testRunner?.value !== "unknown" ? detection.testRunner?.value : "el test runner del proyecto"} para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
|
|
62
|
-
},
|
|
65
|
+
{ id: "review", title: "Code Review (Kotlin)", body: reviewBody(lang, t.reviewFocus, framework) },
|
|
66
|
+
{ id: "refactor", title: "Refactor (Kotlin)", body: refactorBody(lang) },
|
|
67
|
+
{ id: "testing", title: "Testing (Kotlin)", body: testingBody(lang, runner) },
|
|
63
68
|
];
|
|
64
69
|
}
|
|
65
70
|
export const kotlinPack = { id: "kotlin", detect, rules, promptTemplates };
|
package/dist/packs/php.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, unknownRunnerLabel, } from "../core/i18n.js";
|
|
1
2
|
const FRAMEWORKS = {
|
|
2
3
|
"laravel/framework": "laravel",
|
|
3
4
|
"symfony/symfony": "symfony",
|
|
@@ -25,39 +26,41 @@ function detect(signals) {
|
|
|
25
26
|
packageManager: { value: "composer", confidence: "high" },
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"Sigue PSR-12 para el estilo de código.",
|
|
34
|
-
`Ejecuta los tests con ${detection.testRunner?.value === "phpunit" ? "vendor/bin/phpunit" : "el test runner del proyecto"} antes de terminar una tarea.`,
|
|
35
|
-
"Declara toda dependencia nueva en composer.json, nunca la instales sin registrarla.",
|
|
36
|
-
],
|
|
37
|
-
architectureNotes: [
|
|
29
|
+
const TEXTS = {
|
|
30
|
+
es: {
|
|
31
|
+
style: "Sigue PSR-12 para el estilo de código.",
|
|
32
|
+
deps: "Declara toda dependencia nueva en composer.json, nunca la instales sin registrarla.",
|
|
33
|
+
arch: [
|
|
38
34
|
"Respeta la estructura MVC del framework si el proyecto ya la sigue.",
|
|
39
35
|
"Evita lógica de negocio en los controladores cuando el proyecto ya use capas de servicio.",
|
|
40
36
|
],
|
|
37
|
+
},
|
|
38
|
+
en: {
|
|
39
|
+
style: "Follow PSR-12 for code style.",
|
|
40
|
+
deps: "Declare every new dependency in composer.json; never install one without registering it.",
|
|
41
|
+
arch: [
|
|
42
|
+
"Respect the framework's MVC structure if the project already follows it.",
|
|
43
|
+
"Avoid business logic in controllers when the project already uses service layers.",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
function rules(detection, lang) {
|
|
48
|
+
const t = TEXTS[lang];
|
|
49
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
50
|
+
const testCmd = detection.testRunner?.value === "phpunit" ? "vendor/bin/phpunit" : unknownRunnerLabel(lang);
|
|
51
|
+
return {
|
|
52
|
+
summary: summarySentence(lang, "PHP", framework, "composer"),
|
|
53
|
+
conventions: [t.style, runTestsConvention(lang, testCmd), t.deps],
|
|
54
|
+
architectureNotes: t.arch,
|
|
41
55
|
};
|
|
42
56
|
}
|
|
43
|
-
function promptTemplates(detection) {
|
|
44
|
-
const framework = detection.framework?.value
|
|
57
|
+
function promptTemplates(detection, lang) {
|
|
58
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
59
|
+
const runner = detection.testRunner?.value === "phpunit" ? "PHPUnit" : unknownRunnerLabel(lang);
|
|
45
60
|
return [
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
body: `Revisa el diff actual buscando bugs y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: "refactor",
|
|
53
|
-
title: "Refactor (PHP)",
|
|
54
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: "testing",
|
|
58
|
-
title: "Testing (PHP)",
|
|
59
|
-
body: `Escribe tests con ${detection.testRunner?.value === "phpunit" ? "PHPUnit" : "el test runner del proyecto"} para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
|
|
60
|
-
},
|
|
61
|
+
{ id: "review", title: "Code Review (PHP)", body: reviewBody(lang, "", framework) },
|
|
62
|
+
{ id: "refactor", title: "Refactor (PHP)", body: refactorBody(lang) },
|
|
63
|
+
{ id: "testing", title: "Testing (PHP)", body: testingBody(lang, runner) },
|
|
61
64
|
];
|
|
62
65
|
}
|
|
63
66
|
export const phpPack = { id: "php", detect, rules, promptTemplates };
|
package/dist/packs/python.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { refactorBody, reviewBody, runTestsConvention, summarySentence, testingBody, unknownFrameworkLabel, unknownRunnerLabel, } from "../core/i18n.js";
|
|
1
2
|
const FRAMEWORKS = [
|
|
2
3
|
["fastapi", "fastapi"],
|
|
3
4
|
["django", "django"],
|
|
@@ -50,39 +51,46 @@ function detect(signals) {
|
|
|
50
51
|
: { value: "pip", confidence: "low" };
|
|
51
52
|
return { packId: "python", language: "Python", framework, testRunner, packageManager };
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"Sigue PEP 8; usa type hints en funciones públicas.",
|
|
59
|
-
`Ejecuta los tests con ${detection.testRunner?.value ?? "el test runner del proyecto"} antes de terminar una tarea.`,
|
|
60
|
-
"No introduzcas dependencias nuevas sin añadirlas al manifiesto de dependencias existente.",
|
|
61
|
-
],
|
|
62
|
-
architectureNotes: [
|
|
54
|
+
const TEXTS = {
|
|
55
|
+
es: {
|
|
56
|
+
style: "Sigue PEP 8; usa type hints en funciones públicas.",
|
|
57
|
+
deps: "No introduzcas dependencias nuevas sin añadirlas al manifiesto de dependencias existente.",
|
|
58
|
+
arch: [
|
|
63
59
|
"Mantén la lógica de negocio separada de la capa de framework cuando el proyecto ya siga ese patrón.",
|
|
64
60
|
"Usa entornos virtuales; no instales paquetes globalmente.",
|
|
65
61
|
],
|
|
62
|
+
reviewFocus: "manejo de excepciones incorrecto",
|
|
63
|
+
refactorExtra: "Respeta los type hints existentes.",
|
|
64
|
+
},
|
|
65
|
+
en: {
|
|
66
|
+
style: "Follow PEP 8; use type hints on public functions.",
|
|
67
|
+
deps: "Do not introduce new dependencies without adding them to the existing dependency manifest.",
|
|
68
|
+
arch: [
|
|
69
|
+
"Keep business logic separate from the framework layer when the project already follows that pattern.",
|
|
70
|
+
"Use virtual environments; never install packages globally.",
|
|
71
|
+
],
|
|
72
|
+
reviewFocus: "incorrect exception handling",
|
|
73
|
+
refactorExtra: "Respect the existing type hints.",
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
function rules(detection, lang) {
|
|
77
|
+
const t = TEXTS[lang];
|
|
78
|
+
const framework = detection.framework?.value !== "none" ? detection.framework?.value : undefined;
|
|
79
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner?.value : undefined;
|
|
80
|
+
return {
|
|
81
|
+
summary: summarySentence(lang, "Python", framework),
|
|
82
|
+
conventions: [t.style, runTestsConvention(lang, runner ?? unknownRunnerLabel(lang)), t.deps],
|
|
83
|
+
architectureNotes: t.arch,
|
|
66
84
|
};
|
|
67
85
|
}
|
|
68
|
-
function promptTemplates(detection) {
|
|
69
|
-
const
|
|
86
|
+
function promptTemplates(detection, lang) {
|
|
87
|
+
const t = TEXTS[lang];
|
|
88
|
+
const framework = detection.framework?.value !== "none" ? detection.framework.value : unknownFrameworkLabel(lang);
|
|
89
|
+
const runner = detection.testRunner?.value !== "unknown" ? detection.testRunner.value : unknownRunnerLabel(lang);
|
|
70
90
|
return [
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
body: `Revisa el diff actual buscando bugs, manejo de excepciones incorrecto y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: "refactor",
|
|
78
|
-
title: "Refactor (Python)",
|
|
79
|
-
body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable. Respeta los type hints existentes.`,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
id: "testing",
|
|
83
|
-
title: "Testing (Python)",
|
|
84
|
-
body: `Escribe tests para el código señalado usando ${detection.testRunner?.value ?? "el test runner del proyecto"}. Cubre el camino feliz y al menos un caso límite.`,
|
|
85
|
-
},
|
|
91
|
+
{ id: "review", title: "Code Review (Python)", body: reviewBody(lang, t.reviewFocus, framework) },
|
|
92
|
+
{ id: "refactor", title: "Refactor (Python)", body: refactorBody(lang, t.refactorExtra) },
|
|
93
|
+
{ id: "testing", title: "Testing (Python)", body: testingBody(lang, runner) },
|
|
86
94
|
];
|
|
87
95
|
}
|
|
88
96
|
export const pythonPack = { id: "python", detect, rules, promptTemplates };
|