agent-rules-init 0.1.2 → 0.1.3

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.js CHANGED
@@ -4,7 +4,7 @@ import { pathToFileURL } from "node:url";
4
4
  import { scanRepo } from "./core/scanner.js";
5
5
  import { writeGeneratedFiles } from "./core/writer.js";
6
6
  import { renderClaudeMd, renderAgentsMd, renderCopilotInstructions, renderPromptFiles, } from "./core/templates.js";
7
- import { collectLowConfidenceQuestions, askQuestions, applyAnswers, defaultPromptFn, } from "./core/prompt-engine.js";
7
+ import { collectLowConfidenceQuestions, askQuestions, applyAnswers, defaultPromptFn, hasInteractiveTty, } from "./core/prompt-engine.js";
8
8
  import { detectAvailableAssistants, polishWithAssistant, defaultExecFn } from "./core/llm-bridge.js";
9
9
  import { jsTsPack } from "agent-rules-pack-js-ts";
10
10
  import { pythonPack } from "agent-rules-pack-python";
@@ -44,10 +44,11 @@ export async function runCli(rootPath, options = {}) {
44
44
  content: "# CLAUDE.md\n\nNo se detectó ningún stack conocido. Completa este archivo manualmente.\n",
45
45
  });
46
46
  }
47
- if (!options.skipLlm) {
47
+ if (!options.skipLlm && hasInteractiveTty()) {
48
48
  const assistants = await detectAvailableAssistants(execFn);
49
49
  if (assistants.length > 0) {
50
50
  const chosenAssistant = assistants[0];
51
+ clack.log.info(`${chosenAssistant} detectado — puede ayudar a pulir la redacción final.`);
51
52
  const usePolish = await clack.confirm({
52
53
  message: `Se detectó ${chosenAssistant}. ¿Quieres que pula la redacción final?`,
53
54
  });
@@ -62,26 +63,36 @@ export async function runCli(rootPath, options = {}) {
62
63
  }
63
64
  async function main() {
64
65
  clack.intro("agent-rules-init");
65
- const results = await runCli(process.cwd());
66
- const written = results.filter((r) => r.status === "written");
67
- const failures = results.filter((r) => r.status === "error");
68
- for (const result of results) {
69
- if (result.status === "written") {
70
- clack.log.success(result.path);
66
+ if (!hasInteractiveTty()) {
67
+ console.warn("No se detectó una terminal interactiva (esto pasa a veces en Git Bash en Windows). " +
68
+ "Continuando sin preguntas ni oferta de pulido con IA; se usarán los valores detectados.");
69
+ }
70
+ try {
71
+ const results = await runCli(process.cwd());
72
+ const written = results.filter((r) => r.status === "written");
73
+ const failures = results.filter((r) => r.status === "error");
74
+ for (const result of results) {
75
+ if (result.status === "written") {
76
+ clack.log.success(result.path);
77
+ }
78
+ else {
79
+ clack.log.warn(`${result.path}: ${result.error}`);
80
+ }
81
+ }
82
+ if (written.length > 0) {
83
+ clack.outro("Revisa los archivos *.generated.* y, cuando estés conforme, quita el sufijo " +
84
+ '".generated" (ej. "CLAUDE.generated.md" → "CLAUDE.md") para activarlos — ' +
85
+ "tu asistente de IA solo lee el nombre final, no el generado.");
71
86
  }
72
87
  else {
73
- clack.log.warn(`${result.path}: ${result.error}`);
88
+ clack.outro("No se generó ningún archivo nuevo.");
89
+ }
90
+ if (failures.length > 0) {
91
+ process.exitCode = 1;
74
92
  }
75
93
  }
76
- if (written.length > 0) {
77
- clack.outro("Revisa los archivos *.generated.* y, cuando estés conforme, quita el sufijo " +
78
- '".generated" (ej. "CLAUDE.generated.md" → "CLAUDE.md") para activarlos — ' +
79
- "tu asistente de IA solo lee el nombre final, no el generado.");
80
- }
81
- else {
82
- clack.outro("No se generó ningún archivo nuevo.");
83
- }
84
- if (failures.length > 0) {
94
+ catch (err) {
95
+ clack.log.error(`Fallo inesperado: ${err.message}`);
85
96
  process.exitCode = 1;
86
97
  }
87
98
  }
@@ -0,0 +1 @@
1
+ export declare function renderAssistantGreeting(assistantName: string): string;
@@ -0,0 +1,9 @@
1
+ export function renderAssistantGreeting(assistantName) {
2
+ return [
3
+ " ╭───────╮",
4
+ " │ ◕ ◕ │ ノ)ノ",
5
+ " │ ‿ │",
6
+ " ╰───────╯",
7
+ ` ¡${assistantName} está por aquí!`,
8
+ ].join("\n");
9
+ }
@@ -7,6 +7,7 @@ export interface Question {
7
7
  }
8
8
  export declare function collectLowConfidenceQuestions(detections: DetectionResult[]): Question[];
9
9
  export type PromptFn = (message: string) => Promise<string>;
10
+ export declare function hasInteractiveTty(): boolean;
10
11
  export declare const defaultPromptFn: PromptFn;
11
12
  export declare function askQuestions(questions: Question[], promptFn?: PromptFn): Promise<Record<string, string>>;
12
13
  export declare function applyAnswers(detections: DetectionResult[], answers: Record<string, string>): DetectionResult[];
@@ -16,7 +16,14 @@ export function collectLowConfidenceQuestions(detections) {
16
16
  }
17
17
  return questions;
18
18
  }
19
+ export function hasInteractiveTty() {
20
+ return Boolean(process.stdin.isTTY && process.stdout.isTTY);
21
+ }
19
22
  export const defaultPromptFn = async (message) => {
23
+ if (!hasInteractiveTty()) {
24
+ console.warn(`No se detectó una terminal interactiva; se omite la pregunta "${message}" y se usa el valor detectado.`);
25
+ return "";
26
+ }
20
27
  const answer = await clack.text({ message });
21
28
  if (clack.isCancel(answer)) {
22
29
  clack.cancel("Operación cancelada.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-rules-init",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
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",