@ryuenn3123/agentic-senior-core 4.3.15 → 5.1.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.
Files changed (198) hide show
  1. package/.agents/plugins/marketplace.json +21 -0
  2. package/.agents/rules/agentic-senior-core.md +126 -0
  3. package/.claude-plugin/marketplace.json +17 -0
  4. package/.claude-plugin/plugin.json +17 -0
  5. package/.clinerules/agentic-senior-core.md +94 -0
  6. package/.codex-plugin/plugin.json +24 -0
  7. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  8. package/.devin-plugin/plugin.json +13 -0
  9. package/.github/copilot-instructions.md +94 -0
  10. package/.github/plugin/marketplace.json +20 -0
  11. package/.github/plugin/plugin.json +16 -0
  12. package/.kiro/steering/agentic-senior-core.md +94 -0
  13. package/.openclaw/skills/asc/SKILL.md +23 -0
  14. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  15. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  16. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  17. package/.windsurf/rules/agentic-senior-core.md +94 -0
  18. package/AGENTS.md +126 -179
  19. package/CONTRIBUTING.md +93 -63
  20. package/README.md +160 -111
  21. package/__init__.py +61 -0
  22. package/bin/agentic-senior-core.js +41 -43
  23. package/commands/asc-audit.md +1 -0
  24. package/commands/asc-audit.toml +2 -0
  25. package/commands/asc-help.md +9 -0
  26. package/commands/asc-help.toml +2 -0
  27. package/commands/asc-refactor.md +1 -0
  28. package/commands/asc-refactor.toml +2 -0
  29. package/commands/asc-review.md +1 -0
  30. package/commands/asc-review.toml +2 -0
  31. package/gemini-extension.json +10 -0
  32. package/hooks/copilot-hooks.json +21 -0
  33. package/hooks/hooks.json +31 -0
  34. package/hooks/session-start.js +36 -0
  35. package/hooks/subagent-start.js +38 -0
  36. package/lib/cli/commands/adapter.mjs +109 -0
  37. package/lib/cli/commands/clean.mjs +63 -0
  38. package/lib/cli/commands/status.mjs +94 -0
  39. package/package.json +43 -67
  40. package/plugin.yaml +16 -0
  41. package/scripts/uninstall.js +38 -0
  42. package/skills/asc/SKILL.md +16 -0
  43. package/skills/asc-audit/SKILL.md +28 -0
  44. package/skills/asc-refactor/SKILL.md +35 -0
  45. package/skills/asc-review/SKILL.md +54 -0
  46. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  47. package/.agent-context/prompts/bootstrap-design.md +0 -63
  48. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  49. package/.agent-context/prompts/init-project.md +0 -60
  50. package/.agent-context/prompts/refactor.md +0 -38
  51. package/.agent-context/prompts/review-code.md +0 -31
  52. package/.agent-context/review-checklists/architecture-review.md +0 -57
  53. package/.agent-context/review-checklists/pr-checklist.md +0 -136
  54. package/.agent-context/rules/api-docs.md +0 -24
  55. package/.agent-context/rules/api-versioning.md +0 -16
  56. package/.agent-context/rules/architecture.md +0 -33
  57. package/.agent-context/rules/background-jobs.md +0 -17
  58. package/.agent-context/rules/config-and-flags.md +0 -16
  59. package/.agent-context/rules/database-design.md +0 -18
  60. package/.agent-context/rules/docker-runtime.md +0 -17
  61. package/.agent-context/rules/error-handling.md +0 -16
  62. package/.agent-context/rules/event-driven.md +0 -16
  63. package/.agent-context/rules/frontend-architecture.md +0 -54
  64. package/.agent-context/rules/microservices.md +0 -16
  65. package/.agent-context/rules/migrations.md +0 -16
  66. package/.agent-context/rules/observability.md +0 -16
  67. package/.agent-context/rules/performance.md +0 -16
  68. package/.agent-context/rules/realtime.md +0 -16
  69. package/.agent-context/rules/resilience.md +0 -18
  70. package/.agent-context/rules/security.md +0 -18
  71. package/.agent-context/rules/testing.md +0 -16
  72. package/.agent-context/state/README.md +0 -25
  73. package/.agent-context/state/architecture-map.md +0 -40
  74. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  75. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  76. package/.agent-context/state/benchmark-thresholds.json +0 -10
  77. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  78. package/.agent-context/state/dependency-map.md +0 -41
  79. package/.agent-context/state/memory-adapter-contract.json +0 -52
  80. package/.agent-context/state/memory-schema-v1.json +0 -88
  81. package/GEMINI.md +0 -1
  82. package/benchmarks/README.md +0 -60
  83. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  84. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  85. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  86. package/lib/cli/adaptive-context/catalog.mjs +0 -390
  87. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  88. package/lib/cli/adaptive-context/implications.mjs +0 -44
  89. package/lib/cli/adaptive-context.mjs +0 -365
  90. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  91. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  92. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  93. package/lib/cli/audits/typography-palette-anti-repeat-audit.mjs +0 -239
  94. package/lib/cli/backup.mjs +0 -210
  95. package/lib/cli/commands/audit-design-anti-repeat.mjs +0 -39
  96. package/lib/cli/commands/context.mjs +0 -140
  97. package/lib/cli/commands/init/project-context.mjs +0 -60
  98. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  99. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  100. package/lib/cli/commands/init.mjs +0 -654
  101. package/lib/cli/commands/launch.mjs +0 -76
  102. package/lib/cli/commands/optimize.mjs +0 -284
  103. package/lib/cli/commands/rollback.mjs +0 -64
  104. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  105. package/lib/cli/commands/upgrade.mjs +0 -451
  106. package/lib/cli/compiler.mjs +0 -570
  107. package/lib/cli/constants.mjs +0 -136
  108. package/lib/cli/detector/constants.mjs +0 -135
  109. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  110. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  111. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  112. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  113. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  114. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  115. package/lib/cli/detector/design-evidence.mjs +0 -25
  116. package/lib/cli/detector/stack-detection.mjs +0 -243
  117. package/lib/cli/detector/ui-signals.mjs +0 -150
  118. package/lib/cli/detector/workspace-scan.mjs +0 -177
  119. package/lib/cli/detector.mjs +0 -23
  120. package/lib/cli/init-detection-flow.mjs +0 -48
  121. package/lib/cli/init-options.mjs +0 -237
  122. package/lib/cli/init-selection.mjs +0 -29
  123. package/lib/cli/memory-continuity.mjs +0 -537
  124. package/lib/cli/preflight.mjs +0 -76
  125. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  126. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  127. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  128. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  129. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  130. package/lib/cli/project-scaffolder.mjs +0 -29
  131. package/lib/cli/rollback.mjs +0 -66
  132. package/lib/cli/token-optimization.mjs +0 -486
  133. package/lib/cli/utils/filesystem.mjs +0 -81
  134. package/lib/cli/utils/managed-surface.mjs +0 -280
  135. package/lib/cli/utils/prompting.mjs +0 -44
  136. package/lib/cli/utils.mjs +0 -479
  137. package/mcp.json +0 -134
  138. package/scripts/adaptive-context/fixtures.mjs +0 -183
  139. package/scripts/adaptive-context-benchmark.mjs +0 -9
  140. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  141. package/scripts/audit-cache-layer-contract.mjs +0 -263
  142. package/scripts/audit-caching-scope-hygiene.mjs +0 -268
  143. package/scripts/audit-file-size.mjs +0 -219
  144. package/scripts/audit-reflection-citations.mjs +0 -163
  145. package/scripts/audit-release-bundle.mjs +0 -170
  146. package/scripts/audit-rule-id-uniqueness.mjs +0 -313
  147. package/scripts/audit-typography-palette-anti-repeat.mjs +0 -120
  148. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  149. package/scripts/benchmark-gate.mjs +0 -121
  150. package/scripts/benchmark-intelligence.mjs +0 -33
  151. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  152. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  153. package/scripts/bump-version.mjs +0 -103
  154. package/scripts/clean-local-artifacts.mjs +0 -78
  155. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  156. package/scripts/context-triggered-audit.mjs +0 -391
  157. package/scripts/detection-benchmark.mjs +0 -127
  158. package/scripts/docs-quality-drift-report.mjs +0 -358
  159. package/scripts/documentation-boundary-audit.mjs +0 -305
  160. package/scripts/explain-on-demand-audit.mjs +0 -427
  161. package/scripts/forbidden-content-check.mjs +0 -123
  162. package/scripts/frontend-usability-audit.mjs +0 -243
  163. package/scripts/generate-sbom.mjs +0 -61
  164. package/scripts/governance-weekly-report.mjs +0 -466
  165. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  166. package/scripts/llm-judge/constants.mjs +0 -66
  167. package/scripts/llm-judge/diff-collection.mjs +0 -74
  168. package/scripts/llm-judge/prompting.mjs +0 -78
  169. package/scripts/llm-judge/providers.mjs +0 -111
  170. package/scripts/llm-judge/verdict.mjs +0 -134
  171. package/scripts/llm-judge.mjs +0 -200
  172. package/scripts/memory-continuity-benchmark.mjs +0 -322
  173. package/scripts/quality-trend-report.mjs +0 -289
  174. package/scripts/release-gate/audit-checks.mjs +0 -441
  175. package/scripts/release-gate/constants.mjs +0 -53
  176. package/scripts/release-gate/runtime.mjs +0 -63
  177. package/scripts/release-gate/static-checks.mjs +0 -182
  178. package/scripts/release-gate.mjs +0 -42
  179. package/scripts/rules-guardian-audit.mjs +0 -580
  180. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  181. package/scripts/sync-thin-adapters.mjs +0 -72
  182. package/scripts/token-optimization-benchmark.mjs +0 -252
  183. package/scripts/ui-design-judge/constants.mjs +0 -13
  184. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  185. package/scripts/ui-design-judge/git-input.mjs +0 -134
  186. package/scripts/ui-design-judge/prompting.mjs +0 -52
  187. package/scripts/ui-design-judge/providers.mjs +0 -102
  188. package/scripts/ui-design-judge/reporting.mjs +0 -183
  189. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  190. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  191. package/scripts/ui-design-judge.mjs +0 -319
  192. package/scripts/ui-rubric-calibration.mjs +0 -35
  193. package/scripts/validate/config.mjs +0 -519
  194. package/scripts/validate/coverage-checks.mjs +0 -446
  195. package/scripts/validate/file-structure.mjs +0 -162
  196. package/scripts/validate/markdown-content.mjs +0 -109
  197. package/scripts/validate/project-metadata.mjs +0 -166
  198. package/scripts/validate.mjs +0 -338
@@ -1,280 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
-
4
- import {
5
- REPOSITORY_ROOT,
6
- entryPointFiles,
7
- directoryCopies,
8
- } from '../constants.mjs';
9
- import {
10
- isAgenticManagedContent,
11
- pathExists,
12
- } from './filesystem.mjs';
13
-
14
- function toPosixRelativePath(relativePath) {
15
- return relativePath.split(path.sep).join('/');
16
- }
17
-
18
- function isPathWithinPrefix(relativePath, prefixPath) {
19
- const normalizedRelativePath = toPosixRelativePath(relativePath).replace(/\/+$/g, '');
20
- const normalizedPrefixPath = toPosixRelativePath(prefixPath).replace(/\/+$/g, '');
21
-
22
- if (!normalizedPrefixPath) {
23
- return false;
24
- }
25
-
26
- return normalizedRelativePath === normalizedPrefixPath
27
- || normalizedRelativePath.startsWith(`${normalizedPrefixPath}/`);
28
- }
29
-
30
- const localOnlyGovernanceFiles = new Set([
31
- '.agent-context/state/active-memory.json',
32
- '.agent-context/state/v3-purge-audit.json',
33
- ]);
34
-
35
- const legacyManagedInstructionFiles = [
36
- '.instructions.md',
37
- '.agent-instructions.md',
38
- '.cursorrules',
39
- '.windsurfrules',
40
- '.clauderc',
41
- '.cursor/rules/agentic-senior-core.mdc',
42
- '.windsurf/rules/agentic-senior-core.md',
43
- '.github/copilot-instructions.md',
44
- '.github/instructions/agentic-senior-core.instructions.md',
45
- '.gemini/instructions.md',
46
- '.agents/workflows/init-project.md',
47
- '.agents/workflows/refactor.md',
48
- '.agents/workflows/review-code.md',
49
- ];
50
-
51
- export const legacyManagedInstructionDirectories = [
52
- '.agents/workflows',
53
- '.agents',
54
- '.cursor/rules',
55
- '.cursor',
56
- '.windsurf/rules',
57
- '.windsurf',
58
- '.github/instructions',
59
- '.github',
60
- '.gemini',
61
- ];
62
-
63
- function isLocalOnlyGovernanceFile(relativePath) {
64
- return localOnlyGovernanceFiles.has(toPosixRelativePath(relativePath));
65
- }
66
-
67
- export async function collectRelativeTreeEntries(baseDirectoryPath, relativeRootPath) {
68
- const files = [];
69
- const directories = [];
70
-
71
- if (!(await pathExists(baseDirectoryPath))) {
72
- return { files, directories };
73
- }
74
-
75
- const normalizedRootPath = toPosixRelativePath(relativeRootPath);
76
- directories.push(normalizedRootPath);
77
-
78
- async function walkDirectory(currentDirectoryPath, currentRelativePath) {
79
- const directoryEntries = await fs.readdir(currentDirectoryPath, { withFileTypes: true });
80
-
81
- for (const directoryEntry of directoryEntries) {
82
- const sourceEntryPath = path.join(currentDirectoryPath, directoryEntry.name);
83
- const relativeEntryPath = toPosixRelativePath(path.join(currentRelativePath, directoryEntry.name));
84
-
85
- if (directoryEntry.isDirectory()) {
86
- directories.push(relativeEntryPath);
87
- await walkDirectory(sourceEntryPath, relativeEntryPath);
88
- continue;
89
- }
90
-
91
- if (isLocalOnlyGovernanceFile(relativeEntryPath)) {
92
- continue;
93
- }
94
-
95
- files.push(relativeEntryPath);
96
- }
97
- }
98
-
99
- await walkDirectory(baseDirectoryPath, normalizedRootPath);
100
- return { files, directories };
101
- }
102
-
103
- async function collectOptionalManagedEntries(baseDirectoryPath, options = {}) {
104
- const files = new Set();
105
- const directories = new Set();
106
-
107
- if (options.includeMcpTemplate === true) {
108
- const mcpServerEntrypointPath = path.join(baseDirectoryPath, 'scripts', 'mcp-server.mjs');
109
- if (await pathExists(mcpServerEntrypointPath)) {
110
- files.add('scripts/mcp-server.mjs');
111
- }
112
-
113
- const mcpServerHelpersDirectoryPath = path.join(baseDirectoryPath, 'scripts', 'mcp-server');
114
- const mcpServerTreeEntries = await collectRelativeTreeEntries(
115
- mcpServerHelpersDirectoryPath,
116
- 'scripts/mcp-server'
117
- );
118
-
119
- for (const relativeFilePath of mcpServerTreeEntries.files) {
120
- files.add(relativeFilePath);
121
- }
122
-
123
- for (const relativeDirectoryPath of mcpServerTreeEntries.directories) {
124
- directories.add(relativeDirectoryPath);
125
- }
126
- }
127
-
128
- return { files, directories };
129
- }
130
-
131
- async function buildManagedSourceManifest(options = {}) {
132
- const sourceFiles = new Set();
133
- const sourceDirectories = new Set();
134
-
135
- for (const sourceDirectoryName of directoryCopies) {
136
- const sourceDirectoryPath = path.join(REPOSITORY_ROOT, sourceDirectoryName);
137
- const sourceTreeEntries = await collectRelativeTreeEntries(sourceDirectoryPath, sourceDirectoryName);
138
-
139
- for (const sourceFilePath of sourceTreeEntries.files) {
140
- sourceFiles.add(sourceFilePath);
141
- }
142
-
143
- for (const sourceDirectoryPathRelative of sourceTreeEntries.directories) {
144
- sourceDirectories.add(sourceDirectoryPathRelative);
145
- }
146
- }
147
-
148
- for (const entryPointFileName of entryPointFiles) {
149
- const sourceFilePath = path.join(REPOSITORY_ROOT, entryPointFileName);
150
- if (!(await pathExists(sourceFilePath))) {
151
- continue;
152
- }
153
-
154
- sourceFiles.add(toPosixRelativePath(entryPointFileName));
155
- }
156
-
157
- const optionalManagedEntries = await collectOptionalManagedEntries(REPOSITORY_ROOT, options);
158
- for (const sourceFilePath of optionalManagedEntries.files) {
159
- sourceFiles.add(sourceFilePath);
160
- }
161
- for (const sourceDirectoryPath of optionalManagedEntries.directories) {
162
- sourceDirectories.add(sourceDirectoryPath);
163
- }
164
-
165
- return {
166
- files: sourceFiles,
167
- directories: sourceDirectories,
168
- };
169
- }
170
-
171
- async function collectManagedTargetManifest(resolvedTargetDirectoryPath, options = {}) {
172
- const targetFiles = new Set();
173
- const targetDirectories = new Set();
174
-
175
- for (const sourceDirectoryName of directoryCopies) {
176
- const targetDirectoryPath = path.join(resolvedTargetDirectoryPath, sourceDirectoryName);
177
- const targetTreeEntries = await collectRelativeTreeEntries(targetDirectoryPath, sourceDirectoryName);
178
-
179
- for (const targetFilePath of targetTreeEntries.files) {
180
- targetFiles.add(targetFilePath);
181
- }
182
-
183
- for (const targetDirectoryPathRelative of targetTreeEntries.directories) {
184
- targetDirectories.add(targetDirectoryPathRelative);
185
- }
186
- }
187
-
188
- for (const entryPointFileName of entryPointFiles) {
189
- const targetFilePath = path.join(resolvedTargetDirectoryPath, entryPointFileName);
190
- if (!(await pathExists(targetFilePath))) {
191
- continue;
192
- }
193
-
194
- targetFiles.add(toPosixRelativePath(entryPointFileName));
195
- }
196
-
197
- const optionalManagedEntries = await collectOptionalManagedEntries(resolvedTargetDirectoryPath, options);
198
- for (const targetFilePath of optionalManagedEntries.files) {
199
- targetFiles.add(targetFilePath);
200
- }
201
- for (const targetDirectoryPath of optionalManagedEntries.directories) {
202
- targetDirectories.add(targetDirectoryPath);
203
- }
204
-
205
- for (const legacyManagedFile of legacyManagedInstructionFiles) {
206
- const targetFilePath = path.join(resolvedTargetDirectoryPath, ...legacyManagedFile.split('/'));
207
- if (!(await pathExists(targetFilePath))) {
208
- continue;
209
- }
210
-
211
- const targetFileContent = await fs.readFile(targetFilePath);
212
- if (isAgenticManagedContent(targetFileContent)) {
213
- targetFiles.add(legacyManagedFile);
214
- }
215
- }
216
-
217
- return {
218
- files: targetFiles,
219
- directories: targetDirectories,
220
- };
221
- }
222
-
223
- export async function analyzeManagedGovernanceSurface(
224
- resolvedTargetDirectoryPath,
225
- options = {}
226
- ) {
227
- const preservePathPrefixes = Array.isArray(options.preservePathPrefixes)
228
- ? options.preservePathPrefixes
229
- : ['.agent-context/state'];
230
-
231
- const sourceManifest = await buildManagedSourceManifest(options);
232
- const targetManifest = await collectManagedTargetManifest(resolvedTargetDirectoryPath, options);
233
-
234
- const staleFiles = [];
235
- const staleDirectories = [];
236
- const preservedFiles = [];
237
- const preservedDirectories = [];
238
-
239
- const sortedTargetFiles = [...targetManifest.files].sort((leftPath, rightPath) => leftPath.localeCompare(rightPath));
240
- const sortedTargetDirectories = [...targetManifest.directories].sort(
241
- (leftPath, rightPath) => rightPath.length - leftPath.length || leftPath.localeCompare(rightPath)
242
- );
243
-
244
- for (const targetFilePath of sortedTargetFiles) {
245
- if (sourceManifest.files.has(targetFilePath)) {
246
- continue;
247
- }
248
-
249
- if (preservePathPrefixes.some((prefixPath) => isPathWithinPrefix(targetFilePath, prefixPath))) {
250
- preservedFiles.push(targetFilePath);
251
- continue;
252
- }
253
-
254
- staleFiles.push(targetFilePath);
255
- }
256
-
257
- for (const targetDirectoryPathRelative of sortedTargetDirectories) {
258
- if (sourceManifest.directories.has(targetDirectoryPathRelative)) {
259
- continue;
260
- }
261
-
262
- if (preservePathPrefixes.some((prefixPath) => isPathWithinPrefix(targetDirectoryPathRelative, prefixPath))) {
263
- preservedDirectories.push(targetDirectoryPathRelative);
264
- continue;
265
- }
266
-
267
- staleDirectories.push(targetDirectoryPathRelative);
268
- }
269
-
270
- return {
271
- staleFiles,
272
- staleDirectories,
273
- preservedFiles,
274
- preservedDirectories,
275
- managedSourceFileCount: sourceManifest.files.size,
276
- managedSourceDirectoryCount: sourceManifest.directories.size,
277
- managedTargetFileCount: targetManifest.files.size,
278
- managedTargetDirectoryCount: targetManifest.directories.size,
279
- };
280
- }
@@ -1,44 +0,0 @@
1
- export async function askChoice(promptMessage, options, userInterface) {
2
- console.log(`\n${promptMessage}`);
3
- options.forEach((choiceLabel, choiceIndex) => {
4
- console.log(` ${choiceIndex + 1}. ${choiceLabel}`);
5
- });
6
-
7
- while (true) {
8
- const selectedRawInput = await userInterface.question('Choose a number (press Enter for 1): ');
9
- const normalizedInput = selectedRawInput.trim();
10
-
11
- if (!normalizedInput) {
12
- return options[0];
13
- }
14
-
15
- const selectedIndex = Number.parseInt(normalizedInput, 10) - 1;
16
-
17
- if (Number.isNaN(selectedIndex) || selectedIndex < 0 || selectedIndex >= options.length) {
18
- console.log('Invalid choice. Please select a valid number.');
19
- continue;
20
- }
21
-
22
- return options[selectedIndex];
23
- }
24
- }
25
-
26
- export async function askYesNo(promptMessage, userInterface, defaultValue) {
27
- const suffix = typeof defaultValue === 'boolean'
28
- ? defaultValue ? ' (Y/n): ' : ' (y/N): '
29
- : ' (y/n): ';
30
-
31
- while (true) {
32
- const answer = await userInterface.question(`\n${promptMessage}${suffix}`);
33
- const normalizedAnswer = answer.trim().toLowerCase();
34
-
35
- if (!normalizedAnswer && typeof defaultValue === 'boolean') {
36
- return defaultValue;
37
- }
38
-
39
- if (normalizedAnswer === 'y' || normalizedAnswer === 'yes') return true;
40
- if (normalizedAnswer === 'n' || normalizedAnswer === 'no') return false;
41
-
42
- console.log("Please answer with 'y' or 'n'.");
43
- }
44
- }