agent-rules-init 0.1.3 → 0.2.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.
@@ -0,0 +1,86 @@
1
+ const FRAMEWORKS = {
2
+ next: "next",
3
+ "@nestjs/core": "nestjs",
4
+ react: "react",
5
+ vue: "vue",
6
+ "@angular/core": "angular",
7
+ svelte: "svelte",
8
+ fastify: "fastify",
9
+ koa: "koa",
10
+ express: "express",
11
+ };
12
+ const TEST_RUNNERS = {
13
+ vitest: "vitest",
14
+ jest: "jest",
15
+ mocha: "mocha",
16
+ };
17
+ const LINTERS = {
18
+ eslint: "eslint",
19
+ biome: "biome",
20
+ };
21
+ function detectFromDeps(deps, table) {
22
+ for (const [depName, label] of Object.entries(table)) {
23
+ if (deps[depName])
24
+ return { value: label, confidence: "high" };
25
+ }
26
+ return undefined;
27
+ }
28
+ function detect(signals) {
29
+ if (!signals.packageJson)
30
+ return null;
31
+ const allDeps = { ...signals.packageJson.dependencies, ...signals.packageJson.devDependencies };
32
+ const framework = detectFromDeps(allDeps, FRAMEWORKS) ?? {
33
+ value: "none",
34
+ confidence: "low",
35
+ };
36
+ const testRunner = detectFromDeps(allDeps, TEST_RUNNERS) ?? {
37
+ value: "unknown",
38
+ confidence: "low",
39
+ };
40
+ const linter = detectFromDeps(allDeps, LINTERS) ?? { value: "unknown", confidence: "low" };
41
+ const packageManager = signals.hasFile("pnpm-lock.yaml")
42
+ ? { value: "pnpm", confidence: "high" }
43
+ : signals.hasFile("yarn.lock")
44
+ ? { value: "yarn", confidence: "high" }
45
+ : signals.hasFile("package-lock.json")
46
+ ? { value: "npm", confidence: "high" }
47
+ : { value: "npm", confidence: "low" };
48
+ return { packId: "js-ts", language: "TypeScript/JavaScript", framework, testRunner, linter, packageManager };
49
+ }
50
+ function rules(detection) {
51
+ const framework = detection.framework?.value ?? "none";
52
+ const testRunner = detection.testRunner?.value ?? "unknown";
53
+ return {
54
+ summary: `Proyecto JavaScript/TypeScript${framework !== "none" ? ` con ${framework}` : ""}.`,
55
+ conventions: [
56
+ "Usa TypeScript estricto; evita `any` salvo justificación explícita.",
57
+ `Ejecuta los tests con ${testRunner === "unknown" ? "el test runner del proyecto" : testRunner} antes de dar por terminada una tarea.`,
58
+ "Sigue el estilo de módulos ES existente (import/export), no mezcles con require().",
59
+ ],
60
+ architectureNotes: [
61
+ "Mantén los componentes/módulos pequeños y con una responsabilidad clara.",
62
+ "Coloca los tests junto al código que prueban o en un directorio `test/` espejo, según lo que ya use el repo.",
63
+ ],
64
+ };
65
+ }
66
+ function promptTemplates(detection) {
67
+ const framework = detection.framework?.value ?? "el framework del proyecto";
68
+ return [
69
+ {
70
+ id: "review",
71
+ title: "Code Review (JS/TS)",
72
+ 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.`,
73
+ },
74
+ {
75
+ id: "refactor",
76
+ title: "Refactor (JS/TS)",
77
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable. Respeta los tipos existentes.`,
78
+ },
79
+ {
80
+ id: "testing",
81
+ title: "Testing (JS/TS)",
82
+ 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.`,
83
+ },
84
+ ];
85
+ }
86
+ export const jsTsPack = { id: "js-ts", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const kotlinPack: Pack;
@@ -0,0 +1,62 @@
1
+ function detect(signals) {
2
+ const source = signals.buildGradle;
3
+ if (!source)
4
+ return null;
5
+ if (!/kotlin\(|org\.jetbrains\.kotlin/i.test(source))
6
+ return null;
7
+ const framework = /ktor/i.test(source)
8
+ ? { value: "ktor", confidence: "high" }
9
+ : /com\.android\.application|com\.android\.library/i.test(source)
10
+ ? { value: "android", confidence: "high" }
11
+ : /spring/i.test(source)
12
+ ? { value: "spring", confidence: "high" }
13
+ : { value: "none", confidence: "low" };
14
+ const testRunner = /kotlin\.test|kotest/i.test(source)
15
+ ? { value: "kotest", confidence: "high" }
16
+ : /junit/i.test(source)
17
+ ? { value: "junit", confidence: "high" }
18
+ : { value: "unknown", confidence: "low" };
19
+ return {
20
+ packId: "kotlin",
21
+ language: "Kotlin",
22
+ framework,
23
+ testRunner,
24
+ packageManager: { value: "gradle", confidence: "high" },
25
+ };
26
+ }
27
+ function rules(detection) {
28
+ const framework = detection.framework?.value ?? "none";
29
+ return {
30
+ summary: `Proyecto Kotlin${framework !== "none" ? ` con ${framework}` : ""} (gradle).`,
31
+ conventions: [
32
+ "Sigue las convenciones de estilo oficiales de Kotlin (kotlinlang.org/docs/coding-conventions.html).",
33
+ "Ejecuta los tests con `gradle test` antes de terminar una tarea.",
34
+ "Prefiere tipos no-nulos y `val` sobre `var` salvo que la mutabilidad sea necesaria.",
35
+ ],
36
+ architectureNotes: [
37
+ "Respeta la separación en capas (controller/service/repository) si el proyecto ya la usa.",
38
+ "Prefiere inyección de dependencias sobre instanciación manual cuando el framework ya la ofrezca.",
39
+ ],
40
+ };
41
+ }
42
+ function promptTemplates(detection) {
43
+ const framework = detection.framework?.value ?? "el framework del proyecto";
44
+ return [
45
+ {
46
+ id: "review",
47
+ title: "Code Review (Kotlin)",
48
+ 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.`,
49
+ },
50
+ {
51
+ id: "refactor",
52
+ title: "Refactor (Kotlin)",
53
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
54
+ },
55
+ {
56
+ id: "testing",
57
+ title: "Testing (Kotlin)",
58
+ 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.`,
59
+ },
60
+ ];
61
+ }
62
+ export const kotlinPack = { id: "kotlin", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const phpPack: Pack;
@@ -0,0 +1,63 @@
1
+ const FRAMEWORKS = {
2
+ "laravel/framework": "laravel",
3
+ "symfony/symfony": "symfony",
4
+ "codeigniter4/framework": "codeigniter",
5
+ };
6
+ function detect(signals) {
7
+ if (!signals.composerJson)
8
+ return null;
9
+ const allDeps = { ...signals.composerJson.require, ...signals.composerJson.requireDev };
10
+ let framework = { value: "none", confidence: "low" };
11
+ for (const [dep, label] of Object.entries(FRAMEWORKS)) {
12
+ if (allDeps[dep]) {
13
+ framework = { value: label, confidence: "high" };
14
+ break;
15
+ }
16
+ }
17
+ const testRunner = allDeps["phpunit/phpunit"]
18
+ ? { value: "phpunit", confidence: "high" }
19
+ : { value: "unknown", confidence: "low" };
20
+ return {
21
+ packId: "php",
22
+ language: "PHP",
23
+ framework,
24
+ testRunner,
25
+ packageManager: { value: "composer", confidence: "high" },
26
+ };
27
+ }
28
+ function rules(detection) {
29
+ const framework = detection.framework?.value ?? "none";
30
+ return {
31
+ summary: `Proyecto PHP${framework !== "none" ? ` con ${framework}` : ""} (composer).`,
32
+ conventions: [
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: [
38
+ "Respeta la estructura MVC del framework si el proyecto ya la sigue.",
39
+ "Evita lógica de negocio en los controladores cuando el proyecto ya use capas de servicio.",
40
+ ],
41
+ };
42
+ }
43
+ function promptTemplates(detection) {
44
+ const framework = detection.framework?.value ?? "el framework del proyecto";
45
+ return [
46
+ {
47
+ id: "review",
48
+ title: "Code Review (PHP)",
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
+ ];
62
+ }
63
+ export const phpPack = { id: "php", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const pythonPack: Pack;
@@ -0,0 +1,68 @@
1
+ const FRAMEWORKS = [
2
+ ["fastapi", "fastapi"],
3
+ ["django", "django"],
4
+ ["flask", "flask"],
5
+ ];
6
+ const TEST_RUNNERS = [
7
+ ["pytest", "pytest"],
8
+ ["unittest", "unittest"],
9
+ ];
10
+ function findIn(haystack, table) {
11
+ const lower = haystack.toLowerCase();
12
+ for (const [needle, label] of table) {
13
+ if (lower.includes(needle))
14
+ return { value: label, confidence: "high" };
15
+ }
16
+ return undefined;
17
+ }
18
+ function detect(signals) {
19
+ const source = signals.pyprojectToml ?? signals.requirementsTxt ?? signals.environmentYml;
20
+ if (!source)
21
+ return null;
22
+ const framework = findIn(source, FRAMEWORKS) ?? { value: "none", confidence: "low" };
23
+ const testRunner = findIn(source, TEST_RUNNERS) ?? { value: "unknown", confidence: "low" };
24
+ const packageManager = signals.environmentYml
25
+ ? { value: "conda", confidence: "high" }
26
+ : signals.hasFile("poetry.lock")
27
+ ? { value: "poetry", confidence: "high" }
28
+ : signals.pyprojectToml
29
+ ? { value: "pip (pyproject.toml)", confidence: "low" }
30
+ : { value: "pip", confidence: "low" };
31
+ return { packId: "python", language: "Python", framework, testRunner, packageManager };
32
+ }
33
+ function rules(detection) {
34
+ const framework = detection.framework?.value ?? "none";
35
+ return {
36
+ summary: `Proyecto Python${framework !== "none" ? ` con ${framework}` : ""}.`,
37
+ conventions: [
38
+ "Sigue PEP 8; usa type hints en funciones públicas.",
39
+ `Ejecuta los tests con ${detection.testRunner?.value ?? "el test runner del proyecto"} antes de terminar una tarea.`,
40
+ "No introduzcas dependencias nuevas sin añadirlas al manifiesto de dependencias existente.",
41
+ ],
42
+ architectureNotes: [
43
+ "Mantén la lógica de negocio separada de la capa de framework cuando el proyecto ya siga ese patrón.",
44
+ "Usa entornos virtuales; no instales paquetes globalmente.",
45
+ ],
46
+ };
47
+ }
48
+ function promptTemplates(detection) {
49
+ const framework = detection.framework?.value ?? "el framework del proyecto";
50
+ return [
51
+ {
52
+ id: "review",
53
+ title: "Code Review (Python)",
54
+ 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.`,
55
+ },
56
+ {
57
+ id: "refactor",
58
+ title: "Refactor (Python)",
59
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable. Respeta los type hints existentes.`,
60
+ },
61
+ {
62
+ id: "testing",
63
+ title: "Testing (Python)",
64
+ 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.`,
65
+ },
66
+ ];
67
+ }
68
+ export const pythonPack = { id: "python", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const rPack: Pack;
@@ -0,0 +1,60 @@
1
+ const FRAMEWORKS = [
2
+ ["shiny", "shiny"],
3
+ ["plumber", "plumber"],
4
+ ];
5
+ function detect(signals) {
6
+ const source = signals.rDescription ?? signals.renvLock;
7
+ if (!source)
8
+ return null;
9
+ const lower = source.toLowerCase();
10
+ let framework = { value: "none", confidence: "low" };
11
+ for (const [needle, label] of FRAMEWORKS) {
12
+ if (lower.includes(needle)) {
13
+ framework = { value: label, confidence: "high" };
14
+ break;
15
+ }
16
+ }
17
+ const testRunner = lower.includes("testthat")
18
+ ? { value: "testthat", confidence: "high" }
19
+ : { value: "unknown", confidence: "low" };
20
+ const packageManager = signals.renvLock
21
+ ? { value: "renv", confidence: "high" }
22
+ : { value: "CRAN", confidence: "low" };
23
+ return { packId: "r", language: "R", framework, testRunner, packageManager };
24
+ }
25
+ function rules(detection) {
26
+ const framework = detection.framework?.value ?? "none";
27
+ return {
28
+ summary: `Proyecto R${framework !== "none" ? ` con ${framework}` : ""} (${detection.packageManager?.value}).`,
29
+ conventions: [
30
+ "Sigue la guía de estilo tidyverse (style.tidyverse.org) salvo que el proyecto ya use otra.",
31
+ `Ejecuta los tests con ${detection.testRunner?.value === "testthat" ? "testthat::test_dir(\"tests\")" : "el test runner del proyecto"} antes de terminar una tarea.`,
32
+ "Declara toda dependencia nueva en DESCRIPTION y actualiza renv.lock si el proyecto usa renv.",
33
+ ],
34
+ architectureNotes: [
35
+ "Mantén las funciones puras y con una responsabilidad clara; evita modificar el entorno global.",
36
+ "Separa el análisis/scripts de la lógica reutilizable empaquetada en funciones.",
37
+ ],
38
+ };
39
+ }
40
+ function promptTemplates(detection) {
41
+ const framework = detection.framework?.value ?? "el framework del proyecto";
42
+ return [
43
+ {
44
+ id: "review",
45
+ title: "Code Review (R)",
46
+ body: `Revisa el diff actual buscando bugs y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
47
+ },
48
+ {
49
+ id: "refactor",
50
+ title: "Refactor (R)",
51
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
52
+ },
53
+ {
54
+ id: "testing",
55
+ title: "Testing (R)",
56
+ 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.`,
57
+ },
58
+ ];
59
+ }
60
+ export const rPack = { id: "r", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const rubyPack: Pack;
@@ -0,0 +1,59 @@
1
+ function detect(signals) {
2
+ const source = signals.gemfile;
3
+ if (!source)
4
+ return null;
5
+ const lower = source.toLowerCase();
6
+ const framework = /gem\s+['"]rails['"]/.test(lower)
7
+ ? { value: "rails", confidence: "high" }
8
+ : /gem\s+['"]sinatra['"]/.test(lower)
9
+ ? { value: "sinatra", confidence: "high" }
10
+ : { value: "none", confidence: "low" };
11
+ const testRunner = /gem\s+['"]rspec/.test(lower)
12
+ ? { value: "rspec", confidence: "high" }
13
+ : /gem\s+['"]minitest['"]/.test(lower)
14
+ ? { value: "minitest", confidence: "high" }
15
+ : { value: "unknown", confidence: "low" };
16
+ return {
17
+ packId: "ruby",
18
+ language: "Ruby",
19
+ framework,
20
+ testRunner,
21
+ packageManager: { value: "bundler", confidence: "high" },
22
+ };
23
+ }
24
+ function rules(detection) {
25
+ const framework = detection.framework?.value ?? "none";
26
+ return {
27
+ summary: `Proyecto Ruby${framework !== "none" ? ` con ${framework}` : ""} (bundler).`,
28
+ conventions: [
29
+ "Sigue la guía de estilo Ruby estándar (snake_case para métodos/variables, CamelCase para clases).",
30
+ `Ejecuta los tests con ${detection.testRunner?.value === "rspec" ? "bundle exec rspec" : detection.testRunner?.value === "minitest" ? "bundle exec rake test" : "el test runner del proyecto"} antes de terminar una tarea.`,
31
+ "Declara toda dependencia nueva en el Gemfile, nunca instales una gema sin registrarla.",
32
+ ],
33
+ architectureNotes: [
34
+ "Respeta la estructura MVC del framework si el proyecto ya la sigue.",
35
+ "Evita lógica de negocio en los controladores cuando el proyecto ya use capas de servicio.",
36
+ ],
37
+ };
38
+ }
39
+ function promptTemplates(detection) {
40
+ const framework = detection.framework?.value ?? "el framework del proyecto";
41
+ return [
42
+ {
43
+ id: "review",
44
+ title: "Code Review (Ruby)",
45
+ body: `Revisa el diff actual buscando bugs 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 (Ruby)",
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 (Ruby)",
55
+ 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.`,
56
+ },
57
+ ];
58
+ }
59
+ export const rubyPack = { id: "ruby", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const rustPack: Pack;
@@ -0,0 +1,61 @@
1
+ const FRAMEWORKS = [
2
+ ["actix-web", "actix-web"],
3
+ ["axum", "axum"],
4
+ ["rocket", "rocket"],
5
+ ];
6
+ function detect(signals) {
7
+ const source = signals.cargoToml;
8
+ if (!source)
9
+ return null;
10
+ const lower = source.toLowerCase();
11
+ let framework = { value: "none", confidence: "low" };
12
+ for (const [needle, label] of FRAMEWORKS) {
13
+ if (lower.includes(needle)) {
14
+ framework = { value: label, confidence: "high" };
15
+ break;
16
+ }
17
+ }
18
+ return {
19
+ packId: "rust",
20
+ language: "Rust",
21
+ framework,
22
+ testRunner: { value: "cargo test", confidence: "high" },
23
+ packageManager: { value: "cargo", confidence: "high" },
24
+ };
25
+ }
26
+ function rules(detection) {
27
+ const framework = detection.framework?.value ?? "none";
28
+ return {
29
+ summary: `Proyecto Rust${framework !== "none" ? ` con ${framework}` : ""} (cargo).`,
30
+ conventions: [
31
+ "Sigue el formato estándar de `rustfmt`; corre `cargo clippy` para detectar problemas idiomáticos.",
32
+ "Ejecuta los tests con `cargo test` antes de terminar una tarea.",
33
+ "Evita `unwrap()`/`expect()` en código de producción salvo que la invariante esté justificada.",
34
+ ],
35
+ architectureNotes: [
36
+ "Mantén los módulos con una responsabilidad clara; usa `mod.rs` o archivos de módulo con nombre explícito según lo que ya use el repo.",
37
+ "Declara toda dependencia nueva en Cargo.toml y mantén Cargo.lock sincronizado.",
38
+ ],
39
+ };
40
+ }
41
+ function promptTemplates(detection) {
42
+ const framework = detection.framework?.value ?? "el framework del proyecto";
43
+ return [
44
+ {
45
+ id: "review",
46
+ title: "Code Review (Rust)",
47
+ body: `Revisa el diff actual buscando bugs, usos innecesarios de \`unwrap()\`/\`clone()\` 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 (Rust)",
52
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable. Respeta el sistema de ownership existente.`,
53
+ },
54
+ {
55
+ id: "testing",
56
+ title: "Testing (Rust)",
57
+ body: `Escribe tests con \`cargo test\` para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
58
+ },
59
+ ];
60
+ }
61
+ export const rustPack = { id: "rust", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const scalaPack: Pack;
@@ -0,0 +1,72 @@
1
+ const FRAMEWORKS = [
2
+ ["playframework", "play"],
3
+ ["akka-http", "akka"],
4
+ ["akka.actor", "akka"],
5
+ ];
6
+ const TEST_RUNNERS = [
7
+ ["scalatest", "scalatest"],
8
+ ["munit", "munit"],
9
+ ];
10
+ function detect(signals) {
11
+ const source = signals.buildSbt;
12
+ if (!source)
13
+ return null;
14
+ const lower = source.toLowerCase();
15
+ let framework = { value: "none", confidence: "low" };
16
+ for (const [needle, label] of FRAMEWORKS) {
17
+ if (lower.includes(needle)) {
18
+ framework = { value: label, confidence: "high" };
19
+ break;
20
+ }
21
+ }
22
+ let testRunner = { value: "unknown", confidence: "low" };
23
+ for (const [needle, label] of TEST_RUNNERS) {
24
+ if (lower.includes(needle)) {
25
+ testRunner = { value: label, confidence: "high" };
26
+ break;
27
+ }
28
+ }
29
+ return {
30
+ packId: "scala",
31
+ language: "Scala",
32
+ framework,
33
+ testRunner,
34
+ packageManager: { value: "sbt", confidence: "high" },
35
+ };
36
+ }
37
+ function rules(detection) {
38
+ const framework = detection.framework?.value ?? "none";
39
+ return {
40
+ summary: `Proyecto Scala${framework !== "none" ? ` con ${framework}` : ""} (sbt).`,
41
+ conventions: [
42
+ "Sigue la guía de estilo oficial de Scala; ejecuta `scalafmt` si el proyecto ya lo usa.",
43
+ `Ejecuta los tests con \`sbt test\` antes de terminar una tarea.`,
44
+ "Prefiere estructuras inmutables y funciones puras cuando el proyecto ya siga ese estilo.",
45
+ ],
46
+ architectureNotes: [
47
+ "Mantén los módulos con una responsabilidad clara; usa `case class` para modelos de datos.",
48
+ "Declara toda dependencia nueva en `build.sbt`.",
49
+ ],
50
+ };
51
+ }
52
+ function promptTemplates(detection) {
53
+ const framework = detection.framework?.value ?? "el framework del proyecto";
54
+ return [
55
+ {
56
+ id: "review",
57
+ title: "Code Review (Scala)",
58
+ body: `Revisa el diff actual buscando bugs, usos innecesarios de mutabilidad y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
59
+ },
60
+ {
61
+ id: "refactor",
62
+ title: "Refactor (Scala)",
63
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
64
+ },
65
+ {
66
+ id: "testing",
67
+ title: "Testing (Scala)",
68
+ 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.`,
69
+ },
70
+ ];
71
+ }
72
+ export const scalaPack = { id: "scala", detect, rules, promptTemplates };
@@ -0,0 +1,2 @@
1
+ import type { Pack } from "../core/types.js";
2
+ export declare const swiftPack: Pack;
@@ -0,0 +1,52 @@
1
+ function detect(signals) {
2
+ const source = signals.packageSwift;
3
+ if (!source)
4
+ return null;
5
+ const lower = source.toLowerCase();
6
+ const framework = lower.includes("vapor")
7
+ ? { value: "vapor", confidence: "high" }
8
+ : { value: "none", confidence: "low" };
9
+ return {
10
+ packId: "swift",
11
+ language: "Swift",
12
+ framework,
13
+ testRunner: { value: "swift test", confidence: "high" },
14
+ packageManager: { value: "swift package manager", confidence: "high" },
15
+ };
16
+ }
17
+ function rules(detection) {
18
+ const framework = detection.framework?.value ?? "none";
19
+ return {
20
+ summary: `Proyecto Swift${framework !== "none" ? ` con ${framework}` : ""} (Swift Package Manager).`,
21
+ conventions: [
22
+ "Sigue la guía de estilo de la API de Swift (swift.org/documentation/api-design-guidelines).",
23
+ "Ejecuta los tests con `swift test` antes de terminar una tarea.",
24
+ "Declara toda dependencia nueva en Package.swift, nunca la añadas solo en Xcode.",
25
+ ],
26
+ architectureNotes: [
27
+ "Prefiere `struct` sobre `class` salvo que se necesite semántica de referencia.",
28
+ "Evita forzar el desenvuelto de opcionales (`!`) fuera de contextos donde la invariante esté garantizada.",
29
+ ],
30
+ };
31
+ }
32
+ function promptTemplates(detection) {
33
+ const framework = detection.framework?.value ?? "el framework del proyecto";
34
+ return [
35
+ {
36
+ id: "review",
37
+ title: "Code Review (Swift)",
38
+ body: `Revisa el diff actual buscando bugs, desenvueltos forzados de opcionales y desviaciones de las convenciones de ${framework}. Señala solo problemas concretos con línea de archivo.`,
39
+ },
40
+ {
41
+ id: "refactor",
42
+ title: "Refactor (Swift)",
43
+ body: `Propón refactors que reduzcan duplicación y mejoren la legibilidad sin cambiar comportamiento observable.`,
44
+ },
45
+ {
46
+ id: "testing",
47
+ title: "Testing (Swift)",
48
+ body: `Escribe tests con \`swift test\` para el código señalado. Cubre el camino feliz y al menos un caso límite.`,
49
+ },
50
+ ];
51
+ }
52
+ export const swiftPack = { id: "swift", detect, rules, promptTemplates };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "agent-rules-init",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Generates CLAUDE.md, AGENTS.md, copilot-instructions.md and prompt files from what your repo actually is.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "dist/cli.js",
8
8
  "types": "dist/cli.d.ts",
9
9
  "bin": {
10
- "agent-rules-init": "dist/cli.js"
10
+ "agent-rules-init": "dist/bin.js"
11
11
  },
12
12
  "files": [
13
13
  "dist"
@@ -39,12 +39,7 @@
39
39
  "lint": "tsc -p tsconfig.json --noEmit"
40
40
  },
41
41
  "dependencies": {
42
- "@clack/prompts": "^0.9.1",
43
- "agent-rules-pack-java": "0.1.1",
44
- "agent-rules-pack-js-ts": "0.1.1",
45
- "agent-rules-pack-php": "0.1.1",
46
- "agent-rules-pack-python": "0.1.1",
47
- "agent-rules-pack-types": "0.1.1"
42
+ "@clack/prompts": "^0.9.1"
48
43
  },
49
44
  "devDependencies": {
50
45
  "typescript": "^5.6.0",
@@ -1 +0,0 @@
1
- export declare function renderAssistantGreeting(assistantName: string): string;