cadr-cli 0.0.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/adr.d.ts +50 -0
  2. package/dist/adr.d.ts.map +1 -0
  3. package/dist/adr.js +156 -0
  4. package/dist/adr.js.map +1 -0
  5. package/dist/adr.test.d.ts +8 -0
  6. package/dist/adr.test.d.ts.map +1 -0
  7. package/dist/adr.test.js +256 -0
  8. package/dist/adr.test.js.map +1 -0
  9. package/dist/analysis.d.ts +24 -0
  10. package/dist/analysis.d.ts.map +1 -0
  11. package/dist/analysis.js +281 -0
  12. package/dist/analysis.js.map +1 -0
  13. package/dist/analysis.test.d.ts +8 -0
  14. package/dist/analysis.test.d.ts.map +1 -0
  15. package/dist/analysis.test.js +351 -0
  16. package/dist/analysis.test.js.map +1 -0
  17. package/dist/commands/analyze.d.ts +14 -0
  18. package/dist/commands/analyze.d.ts.map +1 -0
  19. package/dist/commands/analyze.js +56 -0
  20. package/dist/commands/analyze.js.map +1 -0
  21. package/dist/commands/init.d.ts +12 -0
  22. package/dist/commands/init.d.ts.map +1 -0
  23. package/dist/commands/init.js +93 -0
  24. package/dist/commands/init.js.map +1 -0
  25. package/dist/commands/init.test.d.ts +2 -0
  26. package/dist/commands/init.test.d.ts.map +1 -0
  27. package/dist/commands/init.test.js +56 -0
  28. package/dist/commands/init.test.js.map +1 -0
  29. package/dist/config.d.ts +40 -0
  30. package/dist/config.d.ts.map +1 -0
  31. package/dist/config.js +208 -0
  32. package/dist/config.js.map +1 -0
  33. package/dist/config.test.d.ts +2 -0
  34. package/dist/config.test.d.ts.map +1 -0
  35. package/dist/config.test.js +97 -0
  36. package/dist/config.test.js.map +1 -0
  37. package/dist/git.d.ts +42 -0
  38. package/dist/git.d.ts.map +1 -1
  39. package/dist/git.js +157 -0
  40. package/dist/git.js.map +1 -1
  41. package/dist/index.d.ts +2 -3
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +78 -62
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.test.d.ts +2 -0
  46. package/dist/index.test.d.ts.map +1 -0
  47. package/dist/index.test.js +51 -0
  48. package/dist/index.test.js.map +1 -0
  49. package/dist/llm.d.ts +73 -0
  50. package/dist/llm.d.ts.map +1 -0
  51. package/dist/llm.js +263 -0
  52. package/dist/llm.js.map +1 -0
  53. package/dist/llm.test.d.ts +2 -0
  54. package/dist/llm.test.d.ts.map +1 -0
  55. package/dist/llm.test.js +592 -0
  56. package/dist/llm.test.js.map +1 -0
  57. package/dist/logger.d.ts.map +1 -1
  58. package/dist/logger.js +5 -3
  59. package/dist/logger.js.map +1 -1
  60. package/dist/logger.test.d.ts +2 -0
  61. package/dist/logger.test.d.ts.map +1 -0
  62. package/dist/logger.test.js +78 -0
  63. package/dist/logger.test.js.map +1 -0
  64. package/dist/prompts.d.ts +49 -0
  65. package/dist/prompts.d.ts.map +1 -0
  66. package/dist/prompts.js +195 -0
  67. package/dist/prompts.js.map +1 -0
  68. package/dist/prompts.test.d.ts +2 -0
  69. package/dist/prompts.test.d.ts.map +1 -0
  70. package/dist/prompts.test.js +427 -0
  71. package/dist/prompts.test.js.map +1 -0
  72. package/dist/providers/gemini.d.ts +3 -0
  73. package/dist/providers/gemini.d.ts.map +1 -0
  74. package/dist/providers/gemini.js +39 -0
  75. package/dist/providers/gemini.js.map +1 -0
  76. package/dist/providers/index.d.ts +2 -0
  77. package/dist/providers/index.d.ts.map +1 -0
  78. package/dist/providers/index.js +6 -0
  79. package/dist/providers/index.js.map +1 -0
  80. package/dist/providers/openai.d.ts +3 -0
  81. package/dist/providers/openai.d.ts.map +1 -0
  82. package/dist/providers/openai.js +25 -0
  83. package/dist/providers/openai.js.map +1 -0
  84. package/dist/providers/registry.d.ts +4 -0
  85. package/dist/providers/registry.d.ts.map +1 -0
  86. package/dist/providers/registry.js +16 -0
  87. package/dist/providers/registry.js.map +1 -0
  88. package/dist/providers/types.d.ts +12 -0
  89. package/dist/providers/types.d.ts.map +1 -0
  90. package/dist/providers/types.js +5 -0
  91. package/dist/providers/types.js.map +1 -0
  92. package/dist/version.test.d.ts +3 -0
  93. package/dist/version.test.d.ts.map +1 -0
  94. package/dist/version.test.js +25 -0
  95. package/dist/version.test.js.map +1 -0
  96. package/package.json +14 -5
  97. package/src/adr.test.ts +278 -0
  98. package/src/adr.ts +136 -0
  99. package/src/analysis.test.ts +396 -0
  100. package/src/analysis.ts +262 -0
  101. package/src/commands/analyze.ts +56 -0
  102. package/src/commands/init.test.ts +27 -0
  103. package/src/commands/init.ts +99 -0
  104. package/src/config.test.ts +79 -0
  105. package/src/config.ts +214 -0
  106. package/src/git.ts +240 -0
  107. package/src/index.test.ts +59 -0
  108. package/src/index.ts +80 -60
  109. package/src/llm.test.ts +701 -0
  110. package/src/llm.ts +344 -0
  111. package/src/logger.test.ts +90 -0
  112. package/src/logger.ts +6 -3
  113. package/src/prompts.test.ts +515 -0
  114. package/src/prompts.ts +174 -0
  115. package/src/providers/gemini.ts +41 -0
  116. package/src/providers/index.ts +1 -0
  117. package/src/providers/openai.ts +22 -0
  118. package/src/providers/registry.ts +16 -0
  119. package/src/providers/types.ts +14 -0
  120. package/src/version.test.ts +29 -0
  121. package/bin/cadr.js +0 -16
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const logger_1 = require("./logger");
4
+ describe('LoggerModule', () => {
5
+ // Suppress Pino logs during tests
6
+ beforeEach(() => {
7
+ jest.spyOn(console, 'log').mockImplementation();
8
+ jest.spyOn(console, 'warn').mockImplementation();
9
+ jest.spyOn(console, 'error').mockImplementation();
10
+ });
11
+ afterEach(() => {
12
+ jest.restoreAllMocks();
13
+ });
14
+ describe('Logger class', () => {
15
+ let logger;
16
+ beforeEach(() => {
17
+ logger = new logger_1.Logger();
18
+ });
19
+ it('should create logger instance', () => {
20
+ expect(logger).toBeDefined();
21
+ expect(typeof logger.info).toBe('function');
22
+ expect(typeof logger.warn).toBe('function');
23
+ expect(typeof logger.error).toBe('function');
24
+ });
25
+ it('should log info message without context', () => {
26
+ // Just verify the method doesn't throw
27
+ expect(() => logger.info('Test info message')).not.toThrow();
28
+ });
29
+ it('should log info message with context', () => {
30
+ // Just verify the method doesn't throw
31
+ expect(() => logger.info('Test info message', { userId: 123, action: 'test' })).not.toThrow();
32
+ });
33
+ it('should log warn message without context', () => {
34
+ // Just verify the method doesn't throw
35
+ expect(() => logger.warn('Test warning message')).not.toThrow();
36
+ });
37
+ it('should log warn message with context', () => {
38
+ // Just verify the method doesn't throw
39
+ expect(() => logger.warn('Test warning message', { warning: 'deprecated' })).not.toThrow();
40
+ });
41
+ it('should log error message without context', () => {
42
+ // Just verify the method doesn't throw
43
+ expect(() => logger.error('Test error message')).not.toThrow();
44
+ });
45
+ it('should log error message with context', () => {
46
+ // Just verify the method doesn't throw
47
+ expect(() => logger.error('Test error message', { error: 'validation failed' })).not.toThrow();
48
+ });
49
+ });
50
+ describe('loggerInstance singleton', () => {
51
+ it('should be an instance of Logger', () => {
52
+ expect(logger_1.loggerInstance).toBeDefined();
53
+ expect(typeof logger_1.loggerInstance.info).toBe('function');
54
+ expect(typeof logger_1.loggerInstance.warn).toBe('function');
55
+ expect(typeof logger_1.loggerInstance.error).toBe('function');
56
+ });
57
+ it('should log messages without throwing', () => {
58
+ expect(() => logger_1.loggerInstance.info('Singleton test message')).not.toThrow();
59
+ expect(() => logger_1.loggerInstance.warn('Warning message')).not.toThrow();
60
+ expect(() => logger_1.loggerInstance.error('Error message')).not.toThrow();
61
+ });
62
+ });
63
+ describe('Pino logger functionality', () => {
64
+ it('should use Pino for structured logging', () => {
65
+ expect(() => logger_1.loggerInstance.info('Pino test message', { test: true })).not.toThrow();
66
+ expect(() => logger_1.loggerInstance.warn('Pino warning', { level: 'warning' })).not.toThrow();
67
+ expect(() => logger_1.loggerInstance.error('Pino error', { error: 'test error' })).not.toThrow();
68
+ });
69
+ it('should handle various data types in context', () => {
70
+ expect(() => logger_1.loggerInstance.info('String context', { message: 'test' })).not.toThrow();
71
+ expect(() => logger_1.loggerInstance.info('Number context', { count: 42 })).not.toThrow();
72
+ expect(() => logger_1.loggerInstance.info('Boolean context', { enabled: true })).not.toThrow();
73
+ expect(() => logger_1.loggerInstance.info('Object context', { data: { nested: 'value' } })).not.toThrow();
74
+ expect(() => logger_1.loggerInstance.info('Array context', { items: [1, 2, 3] })).not.toThrow();
75
+ });
76
+ });
77
+ });
78
+ //# sourceMappingURL=logger.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.test.js","sourceRoot":"","sources":["../src/logger.test.ts"],"names":[],"mappings":";;AAAA,qCAAkD;AAElD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,kCAAkC;IAClC,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,kBAAkB,EAAE,CAAC;QAChD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,EAAE,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,IAAI,MAAc,CAAC;QAEnB,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC7B,MAAM,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5C,MAAM,C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EAAE,CAAC,uBAAc,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACzF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Prompts Module
3
+ *
4
+ * Contains versioned prompt templates for LLM analysis and ADR generation.
5
+ * Follows the constitution requirement for versioned prompts.
6
+ */
7
+ /**
8
+ * Version 1 of the analysis prompt template.
9
+ *
10
+ * This prompt is designed to analyze code changes for architectural significance.
11
+ * It uses specific criteria for determining significance and enforces strict JSON output.
12
+ */
13
+ export declare const ANALYSIS_PROMPT_V1 = "\nYou are an expert principal engineer and software architect acting as a meticulous code reviewer. Your sole task is to determine if the provided git diff represents an architecturally significant change that warrants an Architectural Decision Record (ADR).\n\nGiven the following staged changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nA change is considered architecturally significant if it:\n- Introduces a new external dependency, library, or service.\n- Adds, removes, or modifies infrastructure components (e.g., databases, caches, queues, Docker services).\n- Changes a public API contract, a data schema, or a critical data model.\n- Alters authentication, authorization, or other core security patterns.\n- Modifies cross-cutting concerns like logging, observability, or CI/CD pipelines.\n\nRespond ONLY with a single, minified JSON object with no preamble, no markdown, and no additional text. The JSON object must adhere to the following schema:\n{\"is_significant\": boolean, \"reason\": string}\n\nThe \"reason\" should be a concise, one-sentence explanation for your decision, suitable for showing to a developer. If the change is not significant, the reason should be an empty string.\n";
14
+ /**
15
+ * Formats a prompt template by replacing placeholders with actual data.
16
+ *
17
+ * @param template - The prompt template with placeholders
18
+ * @param data - Object containing file_paths and diff_content
19
+ * @returns Formatted prompt with placeholders replaced
20
+ */
21
+ export declare function formatPrompt(template: string, data: {
22
+ file_paths: string[];
23
+ diff_content: string;
24
+ }): string;
25
+ /**
26
+ * Version 1 of the generation prompt template.
27
+ *
28
+ * This prompt generates ADRs following the MADR (Markdown Architectural Decision Records) format.
29
+ * MADR is a lean template for documenting architectural decisions in a structured way.
30
+ */
31
+ export declare const GENERATION_PROMPT_V1 = "\nYou are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.\n\nGiven the following code changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nGenerate an ADR that follows this EXACT structure:\n\n# [Short title of solved problem and solution]\n\n* Status: [proposed | rejected | accepted | deprecated | superseded by [ADR-0005](0005-example.md)]\n* Date: {current_date}\n\n## Context and Problem Statement\n\n[Describe the context and problem statement in 2-3 sentences. What is the issue that we're addressing?]\n\n## Decision Drivers\n\n* [decision driver 1, e.g., a force, constraint, requirement]\n* [decision driver 2]\n* [etc.]\n\n## Considered Options\n\n* [option 1]\n* [option 2]\n* [option 3]\n\n## Decision Outcome\n\nChosen option: \"[option 1]\", because [justification. e.g., only option which meets KO criterion decision driver | which resolves force 1 | etc.].\n\n### Consequences\n\n* Good, because [positive consequence 1]\n* Good, because [positive consequence 2]\n* Bad, because [negative consequence 1]\n* Bad, because [negative consequence 2]\n\n## More Information\n\n[Any additional context, links to related discussions, or implementation notes]\n\nIMPORTANT INSTRUCTIONS:\n1. Use the EXACT markdown structure shown above\n2. Set Status to \"accepted\" (since this change is being committed)\n3. The title should be concise, action-oriented, and describe the decision made\n4. Keep Context and Problem Statement brief but clear (2-4 sentences)\n5. List at least 2-3 decision drivers that influenced this choice\n6. Include at least 2 considered options (including the chosen one)\n7. Be specific about consequences - list both benefits and drawbacks\n8. In \"More Information\", mention any technical details, related files, or future considerations\n\nRespond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.\n";
32
+ /**
33
+ * Formats the generation prompt with actual diff data
34
+ *
35
+ * @param data - Object containing file_paths and diff_content
36
+ * @returns Formatted generation prompt
37
+ */
38
+ export declare function formatGenerationPrompt(data: {
39
+ file_paths: string[];
40
+ diff_content: string;
41
+ }): string;
42
+ /**
43
+ * Prompt user for ADR generation confirmation
44
+ *
45
+ * @param reason - The reason why this change is architecturally significant
46
+ * @returns Promise<boolean> - true if user wants to generate, false otherwise
47
+ */
48
+ export declare function promptForGeneration(reason: string): Promise<boolean>;
49
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,ksCAoB9B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnD,MAAM,CAUR;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,ihEA0DhC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnD,MAAM,CAWR;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqB1E"}
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ /**
3
+ * Prompts Module
4
+ *
5
+ * Contains versioned prompt templates for LLM analysis and ADR generation.
6
+ * Follows the constitution requirement for versioned prompts.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.GENERATION_PROMPT_V1 = exports.ANALYSIS_PROMPT_V1 = void 0;
43
+ exports.formatPrompt = formatPrompt;
44
+ exports.formatGenerationPrompt = formatGenerationPrompt;
45
+ exports.promptForGeneration = promptForGeneration;
46
+ const readline = __importStar(require("readline"));
47
+ /**
48
+ * Version 1 of the analysis prompt template.
49
+ *
50
+ * This prompt is designed to analyze code changes for architectural significance.
51
+ * It uses specific criteria for determining significance and enforces strict JSON output.
52
+ */
53
+ exports.ANALYSIS_PROMPT_V1 = `
54
+ You are an expert principal engineer and software architect acting as a meticulous code reviewer. Your sole task is to determine if the provided git diff represents an architecturally significant change that warrants an Architectural Decision Record (ADR).
55
+
56
+ Given the following staged changes:
57
+ {file_paths}
58
+
59
+ Diff content:
60
+ {diff_content}
61
+
62
+ A change is considered architecturally significant if it:
63
+ - Introduces a new external dependency, library, or service.
64
+ - Adds, removes, or modifies infrastructure components (e.g., databases, caches, queues, Docker services).
65
+ - Changes a public API contract, a data schema, or a critical data model.
66
+ - Alters authentication, authorization, or other core security patterns.
67
+ - Modifies cross-cutting concerns like logging, observability, or CI/CD pipelines.
68
+
69
+ Respond ONLY with a single, minified JSON object with no preamble, no markdown, and no additional text. The JSON object must adhere to the following schema:
70
+ {"is_significant": boolean, "reason": string}
71
+
72
+ The "reason" should be a concise, one-sentence explanation for your decision, suitable for showing to a developer. If the change is not significant, the reason should be an empty string.
73
+ `;
74
+ /**
75
+ * Formats a prompt template by replacing placeholders with actual data.
76
+ *
77
+ * @param template - The prompt template with placeholders
78
+ * @param data - Object containing file_paths and diff_content
79
+ * @returns Formatted prompt with placeholders replaced
80
+ */
81
+ function formatPrompt(template, data) {
82
+ // Format file paths as a readable list
83
+ const formattedFilePaths = data.file_paths.length > 0
84
+ ? data.file_paths.join('\n')
85
+ : 'No files';
86
+ // Replace placeholders with actual data
87
+ return template
88
+ .replace('{file_paths}', formattedFilePaths)
89
+ .replace('{diff_content}', data.diff_content);
90
+ }
91
+ /**
92
+ * Version 1 of the generation prompt template.
93
+ *
94
+ * This prompt generates ADRs following the MADR (Markdown Architectural Decision Records) format.
95
+ * MADR is a lean template for documenting architectural decisions in a structured way.
96
+ */
97
+ exports.GENERATION_PROMPT_V1 = `
98
+ You are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.
99
+
100
+ Given the following code changes:
101
+ {file_paths}
102
+
103
+ Diff content:
104
+ {diff_content}
105
+
106
+ Generate an ADR that follows this EXACT structure:
107
+
108
+ # [Short title of solved problem and solution]
109
+
110
+ * Status: [proposed | rejected | accepted | deprecated | superseded by [ADR-0005](0005-example.md)]
111
+ * Date: {current_date}
112
+
113
+ ## Context and Problem Statement
114
+
115
+ [Describe the context and problem statement in 2-3 sentences. What is the issue that we're addressing?]
116
+
117
+ ## Decision Drivers
118
+
119
+ * [decision driver 1, e.g., a force, constraint, requirement]
120
+ * [decision driver 2]
121
+ * [etc.]
122
+
123
+ ## Considered Options
124
+
125
+ * [option 1]
126
+ * [option 2]
127
+ * [option 3]
128
+
129
+ ## Decision Outcome
130
+
131
+ Chosen option: "[option 1]", because [justification. e.g., only option which meets KO criterion decision driver | which resolves force 1 | etc.].
132
+
133
+ ### Consequences
134
+
135
+ * Good, because [positive consequence 1]
136
+ * Good, because [positive consequence 2]
137
+ * Bad, because [negative consequence 1]
138
+ * Bad, because [negative consequence 2]
139
+
140
+ ## More Information
141
+
142
+ [Any additional context, links to related discussions, or implementation notes]
143
+
144
+ IMPORTANT INSTRUCTIONS:
145
+ 1. Use the EXACT markdown structure shown above
146
+ 2. Set Status to "accepted" (since this change is being committed)
147
+ 3. The title should be concise, action-oriented, and describe the decision made
148
+ 4. Keep Context and Problem Statement brief but clear (2-4 sentences)
149
+ 5. List at least 2-3 decision drivers that influenced this choice
150
+ 6. Include at least 2 considered options (including the chosen one)
151
+ 7. Be specific about consequences - list both benefits and drawbacks
152
+ 8. In "More Information", mention any technical details, related files, or future considerations
153
+
154
+ Respond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.
155
+ `;
156
+ /**
157
+ * Formats the generation prompt with actual diff data
158
+ *
159
+ * @param data - Object containing file_paths and diff_content
160
+ * @returns Formatted generation prompt
161
+ */
162
+ function formatGenerationPrompt(data) {
163
+ const formattedFilePaths = data.file_paths.length > 0
164
+ ? data.file_paths.join('\n')
165
+ : 'No files';
166
+ const currentDate = new Date().toISOString().split('T')[0];
167
+ return exports.GENERATION_PROMPT_V1
168
+ .replace('{file_paths}', formattedFilePaths)
169
+ .replace('{diff_content}', data.diff_content)
170
+ .replace('{current_date}', currentDate);
171
+ }
172
+ /**
173
+ * Prompt user for ADR generation confirmation
174
+ *
175
+ * @param reason - The reason why this change is architecturally significant
176
+ * @returns Promise<boolean> - true if user wants to generate, false otherwise
177
+ */
178
+ async function promptForGeneration(reason) {
179
+ return new Promise((resolve) => {
180
+ const rl = readline.createInterface({
181
+ input: process.stdin,
182
+ output: process.stdout,
183
+ });
184
+ // eslint-disable-next-line no-console
185
+ console.log(`\nšŸ’­ ${reason}\n`);
186
+ rl.question('šŸ“ Would you like to generate an ADR for this change? (Press ENTER or type "yes" to confirm, "no" to skip): ', (answer) => {
187
+ rl.close();
188
+ const normalized = answer.trim().toLowerCase();
189
+ // Accept: empty (ENTER), "y", "yes"
190
+ const confirmed = normalized === '' || normalized === 'y' || normalized === 'yes';
191
+ resolve(confirmed);
192
+ });
193
+ });
194
+ }
195
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCH,oCAaC;AA0ED,wDAaC;AAQD,kDAqBC;AAtKD,mDAAqC;AAErC;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBjC,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,YAAY,CAC1B,QAAgB,EAChB,IAAoD;IAEpD,uCAAuC;IACvC,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QACnD,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,CAAC,CAAC,UAAU,CAAC;IAEf,wCAAwC;IACxC,OAAO,QAAQ;SACZ,OAAO,CAAC,cAAc,EAAE,kBAAkB,CAAC;SAC3C,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;AAClD,CAAC;AAED;;;;;GAKG;AACU,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DnC,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,IAAoD;IAEpD,MAAM,kBAAkB,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;QACnD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