@dedesfr/prompter 0.8.23 → 1.0.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 (247) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +105 -77
  3. package/dist/cli/index.js +25 -1
  4. package/dist/cli/index.js.map +1 -1
  5. package/dist/commands/init.d.ts +1 -7
  6. package/dist/commands/init.d.ts.map +1 -1
  7. package/dist/commands/init.js +60 -299
  8. package/dist/commands/init.js.map +1 -1
  9. package/dist/commands/login.d.ts +4 -0
  10. package/dist/commands/login.d.ts.map +1 -0
  11. package/dist/commands/login.js +56 -0
  12. package/dist/commands/login.js.map +1 -0
  13. package/dist/commands/logout.d.ts +4 -0
  14. package/dist/commands/logout.d.ts.map +1 -0
  15. package/dist/commands/logout.js +14 -0
  16. package/dist/commands/logout.js.map +1 -0
  17. package/dist/commands/update.d.ts.map +1 -1
  18. package/dist/commands/update.js +31 -41
  19. package/dist/commands/update.js.map +1 -1
  20. package/dist/commands/whoami.d.ts +4 -0
  21. package/dist/commands/whoami.d.ts.map +1 -0
  22. package/dist/commands/whoami.js +42 -0
  23. package/dist/commands/whoami.js.map +1 -0
  24. package/dist/core/auth-store.d.ts +10 -0
  25. package/dist/core/auth-store.d.ts.map +1 -0
  26. package/dist/core/auth-store.js +39 -0
  27. package/dist/core/auth-store.js.map +1 -0
  28. package/dist/core/configurators/slash/antigravity.d.ts +2 -5
  29. package/dist/core/configurators/slash/antigravity.d.ts.map +1 -1
  30. package/dist/core/configurators/slash/antigravity.js +2 -57
  31. package/dist/core/configurators/slash/antigravity.js.map +1 -1
  32. package/dist/core/configurators/slash/base.d.ts +6 -18
  33. package/dist/core/configurators/slash/base.d.ts.map +1 -1
  34. package/dist/core/configurators/slash/base.js +8 -77
  35. package/dist/core/configurators/slash/base.js.map +1 -1
  36. package/dist/core/configurators/slash/claude.d.ts +2 -5
  37. package/dist/core/configurators/slash/claude.d.ts.map +1 -1
  38. package/dist/core/configurators/slash/claude.js +2 -57
  39. package/dist/core/configurators/slash/claude.js.map +1 -1
  40. package/dist/core/configurators/slash/codex.d.ts +2 -5
  41. package/dist/core/configurators/slash/codex.d.ts.map +1 -1
  42. package/dist/core/configurators/slash/codex.js +2 -57
  43. package/dist/core/configurators/slash/codex.js.map +1 -1
  44. package/dist/core/configurators/slash/droid.d.ts +2 -5
  45. package/dist/core/configurators/slash/droid.d.ts.map +1 -1
  46. package/dist/core/configurators/slash/droid.js +2 -32
  47. package/dist/core/configurators/slash/droid.js.map +1 -1
  48. package/dist/core/configurators/slash/forge.d.ts +2 -5
  49. package/dist/core/configurators/slash/forge.d.ts.map +1 -1
  50. package/dist/core/configurators/slash/forge.js +2 -32
  51. package/dist/core/configurators/slash/forge.js.map +1 -1
  52. package/dist/core/configurators/slash/github-copilot.d.ts +2 -7
  53. package/dist/core/configurators/slash/github-copilot.d.ts.map +1 -1
  54. package/dist/core/configurators/slash/github-copilot.js +2 -96
  55. package/dist/core/configurators/slash/github-copilot.js.map +1 -1
  56. package/dist/core/configurators/slash/index.d.ts +1 -1
  57. package/dist/core/configurators/slash/index.d.ts.map +1 -1
  58. package/dist/core/configurators/slash/index.js +1 -1
  59. package/dist/core/configurators/slash/index.js.map +1 -1
  60. package/dist/core/configurators/slash/kilocode.d.ts +2 -5
  61. package/dist/core/configurators/slash/kilocode.d.ts.map +1 -1
  62. package/dist/core/configurators/slash/kilocode.js +2 -57
  63. package/dist/core/configurators/slash/kilocode.js.map +1 -1
  64. package/dist/core/configurators/slash/opencode.d.ts +2 -5
  65. package/dist/core/configurators/slash/opencode.d.ts.map +1 -1
  66. package/dist/core/configurators/slash/opencode.js +2 -57
  67. package/dist/core/configurators/slash/opencode.js.map +1 -1
  68. package/dist/core/configurators/slash/registry.d.ts +4 -4
  69. package/dist/core/configurators/slash/registry.d.ts.map +1 -1
  70. package/dist/core/configurators/slash/registry.js.map +1 -1
  71. package/dist/core/registry.d.ts +18 -0
  72. package/dist/core/registry.d.ts.map +1 -0
  73. package/dist/core/registry.js +94 -0
  74. package/dist/core/registry.js.map +1 -0
  75. package/dist/core/templates/index.d.ts +0 -1
  76. package/dist/core/templates/index.d.ts.map +1 -1
  77. package/dist/core/templates/index.js +0 -1
  78. package/dist/core/templates/index.js.map +1 -1
  79. package/package.json +7 -1
  80. package/AGENTS.md +0 -123
  81. package/CLAUDE.md +0 -17
  82. package/build.js +0 -20
  83. package/convex-setup.md +0 -403
  84. package/dist/core/templates/slash-command-templates.d.ts +0 -7
  85. package/dist/core/templates/slash-command-templates.d.ts.map +0 -1
  86. package/dist/core/templates/slash-command-templates.js +0 -1041
  87. package/dist/core/templates/slash-command-templates.js.map +0 -1
  88. package/prompt/ai-humanizer.md +0 -45
  89. package/prompt/api-contract-generator.md +0 -234
  90. package/prompt/apply.md +0 -17
  91. package/prompt/archive.md +0 -21
  92. package/prompt/design-system.md +0 -210
  93. package/prompt/document-explainer.md +0 -149
  94. package/prompt/epic-generator.md +0 -198
  95. package/prompt/epic-single.md +0 -47
  96. package/prompt/erd-generator.md +0 -130
  97. package/prompt/fsd-generator.md +0 -157
  98. package/prompt/prd-agent-generator.md +0 -147
  99. package/prompt/prd-generator.md +0 -195
  100. package/prompt/product-brief.md +0 -289
  101. package/prompt/proposal.md +0 -22
  102. package/prompt/qa-test-scenario.md +0 -133
  103. package/prompt/skill-creator.md +0 -350
  104. package/prompt/story-generator.md +0 -278
  105. package/prompt/story-single.md +0 -70
  106. package/prompt/tdd-generator.md +0 -294
  107. package/prompt/tdd-lite-generator.md +0 -224
  108. package/prompt/wireframe-generator.md +0 -219
  109. package/skills/ai-context-generator/SKILL.md +0 -54
  110. package/skills/ai-context-generator/references/AGENTS.template.md +0 -83
  111. package/skills/ai-context-generator/references/CLAUDE.template.md +0 -39
  112. package/skills/ai-context-generator/references/behavioral-guidelines.md +0 -71
  113. package/skills/ai-context-generator/references/discovery-checklist.md +0 -40
  114. package/skills/ai-context-generator/references/examples/AGENTS.good.md +0 -103
  115. package/skills/ai-context-generator/references/extraction-checklist.md +0 -23
  116. package/skills/ai-context-generator/references/overlays/laravel.md +0 -44
  117. package/skills/cerebro/SKILL.md +0 -187
  118. package/skills/cerebro/references/agents.md +0 -213
  119. package/skills/code-review/SKILL.md +0 -373
  120. package/skills/code-review/assets/report-template-agent.md +0 -212
  121. package/skills/code-review/assets/report-template-compact.md +0 -81
  122. package/skills/code-review/assets/report-template-full.md +0 -264
  123. package/skills/code-review/assets/report-template-human.md +0 -168
  124. package/skills/code-review/references/universal-patterns.md +0 -495
  125. package/skills/design-md/README.md +0 -34
  126. package/skills/design-md/SKILL.md +0 -172
  127. package/skills/design-md/examples/DESIGN.md +0 -154
  128. package/skills/design-system-generator/SKILL.md +0 -324
  129. package/skills/design-system-generator/assets/design-system-template.md +0 -348
  130. package/skills/design-system-generator/references/extraction-patterns.md +0 -321
  131. package/skills/doc-builder/SKILL.md +0 -115
  132. package/skills/doc-builder/references/ui-patterns.md +0 -394
  133. package/skills/document-translator/SKILL.md +0 -58
  134. package/skills/enhance-prompt/README.md +0 -34
  135. package/skills/enhance-prompt/SKILL.md +0 -204
  136. package/skills/enhance-prompt/references/KEYWORDS.md +0 -114
  137. package/skills/feature-planner/SKILL.md +0 -305
  138. package/skills/feature-planner/assets/implementation-plan-template.md +0 -85
  139. package/skills/frontend-design/LICENSE.txt +0 -177
  140. package/skills/frontend-design/SKILL.md +0 -42
  141. package/skills/gamma-builder/SKILL.md +0 -134
  142. package/skills/laravel-code-review/SKILL.md +0 -383
  143. package/skills/laravel-code-review/assets/report-template-agent.md +0 -195
  144. package/skills/laravel-code-review/assets/report-template-compact.md +0 -79
  145. package/skills/laravel-code-review/assets/report-template-full.md +0 -253
  146. package/skills/laravel-code-review/assets/report-template-human.md +0 -159
  147. package/skills/laravel-code-review/references/laravel-patterns.md +0 -571
  148. package/skills/laravel-code-review/references/php84-features.md +0 -442
  149. package/skills/mcp-builder/LICENSE.txt +0 -202
  150. package/skills/mcp-builder/SKILL.md +0 -236
  151. package/skills/mcp-builder/reference/evaluation.md +0 -602
  152. package/skills/mcp-builder/reference/mcp_best_practices.md +0 -249
  153. package/skills/mcp-builder/reference/node_mcp_server.md +0 -970
  154. package/skills/mcp-builder/reference/python_mcp_server.md +0 -719
  155. package/skills/mcp-builder/scripts/connections.py +0 -151
  156. package/skills/mcp-builder/scripts/evaluation.py +0 -373
  157. package/skills/mcp-builder/scripts/example_evaluation.xml +0 -22
  158. package/skills/mcp-builder/scripts/requirements.txt +0 -2
  159. package/skills/meeting-notes/SKILL.md +0 -159
  160. package/skills/meeting-notes/evals/evals.json +0 -23
  161. package/skills/project-orchestrator/SKILL.md +0 -487
  162. package/skills/project-orchestrator/assets/caddy-vps-setup.md +0 -180
  163. package/skills/project-orchestrator/assets/plan-summary-template.md +0 -159
  164. package/skills/prompter-specs/SKILL.md +0 -115
  165. package/skills/prompter-workflow/SKILL.md +0 -166
  166. package/skills/prompter-workflow/evals/evals.json +0 -89
  167. package/skills/sph-generator/SKILL.md +0 -488
  168. package/skills/ui-ux-pro/SKILL.md +0 -199
  169. package/skills/ui-ux-pro/assets/design-spec-template.md +0 -173
  170. package/skills/ui-ux-pro/references/component-patterns.md +0 -255
  171. package/skills/ui-ux-pro/references/design-principles.md +0 -167
  172. package/src/cli/index.ts +0 -223
  173. package/src/commands/archive.ts +0 -302
  174. package/src/commands/change.ts +0 -292
  175. package/src/commands/config.ts +0 -233
  176. package/src/commands/guide.ts +0 -50
  177. package/src/commands/init.ts +0 -899
  178. package/src/commands/list.ts +0 -194
  179. package/src/commands/show.ts +0 -138
  180. package/src/commands/spec.ts +0 -251
  181. package/src/commands/update.ts +0 -156
  182. package/src/commands/upgrade.ts +0 -30
  183. package/src/commands/validate.ts +0 -326
  184. package/src/core/artifact-graph/graph.ts +0 -167
  185. package/src/core/artifact-graph/index.ts +0 -44
  186. package/src/core/artifact-graph/instruction-loader.ts +0 -302
  187. package/src/core/artifact-graph/resolver.ts +0 -226
  188. package/src/core/artifact-graph/schema.ts +0 -124
  189. package/src/core/artifact-graph/state.ts +0 -64
  190. package/src/core/artifact-graph/types.ts +0 -65
  191. package/src/core/completions/command-registry.ts +0 -382
  192. package/src/core/completions/completion-provider.ts +0 -128
  193. package/src/core/completions/generators/bash-generator.ts +0 -191
  194. package/src/core/completions/generators/fish-generator.ts +0 -188
  195. package/src/core/completions/generators/powershell-generator.ts +0 -223
  196. package/src/core/completions/generators/zsh-generator.ts +0 -281
  197. package/src/core/completions/templates/bash-templates.ts +0 -24
  198. package/src/core/completions/templates/fish-templates.ts +0 -40
  199. package/src/core/completions/templates/powershell-templates.ts +0 -25
  200. package/src/core/completions/templates/zsh-templates.ts +0 -36
  201. package/src/core/completions/types.ts +0 -90
  202. package/src/core/config-schema.ts +0 -230
  203. package/src/core/config.ts +0 -181
  204. package/src/core/configurators/slash/antigravity.ts +0 -70
  205. package/src/core/configurators/slash/base.ts +0 -203
  206. package/src/core/configurators/slash/claude.ts +0 -70
  207. package/src/core/configurators/slash/codex.ts +0 -70
  208. package/src/core/configurators/slash/droid.ts +0 -44
  209. package/src/core/configurators/slash/forge.ts +0 -44
  210. package/src/core/configurators/slash/github-copilot.ts +0 -114
  211. package/src/core/configurators/slash/index.ts +0 -10
  212. package/src/core/configurators/slash/kilocode.ts +0 -70
  213. package/src/core/configurators/slash/opencode.ts +0 -70
  214. package/src/core/configurators/slash/registry.ts +0 -51
  215. package/src/core/converters/json-converter.ts +0 -62
  216. package/src/core/global-config.ts +0 -136
  217. package/src/core/parsers/change-parser.ts +0 -234
  218. package/src/core/parsers/markdown-parser.ts +0 -237
  219. package/src/core/parsers/requirement-blocks.ts +0 -234
  220. package/src/core/prompt-templates.ts +0 -3504
  221. package/src/core/schemas/base.schema.ts +0 -20
  222. package/src/core/schemas/change.schema.ts +0 -42
  223. package/src/core/schemas/index.ts +0 -20
  224. package/src/core/schemas/spec.schema.ts +0 -17
  225. package/src/core/skill-discovery.ts +0 -68
  226. package/src/core/specs-apply.ts +0 -483
  227. package/src/core/styles/palette.ts +0 -8
  228. package/src/core/templates/agents-template.ts +0 -459
  229. package/src/core/templates/claude-template.ts +0 -2
  230. package/src/core/templates/index.ts +0 -4
  231. package/src/core/templates/project-template.ts +0 -32
  232. package/src/core/templates/slash-command-templates.ts +0 -1068
  233. package/src/core/validation/constants.ts +0 -48
  234. package/src/core/validation/types.ts +0 -19
  235. package/src/core/validation/validator.ts +0 -449
  236. package/src/core/view.ts +0 -219
  237. package/src/index.ts +0 -1
  238. package/src/utils/change-metadata.ts +0 -171
  239. package/src/utils/change-utils.ts +0 -131
  240. package/src/utils/file-system.ts +0 -252
  241. package/src/utils/index.ts +0 -12
  242. package/src/utils/interactive.ts +0 -29
  243. package/src/utils/item-discovery.ts +0 -66
  244. package/src/utils/match.ts +0 -26
  245. package/src/utils/shell-detection.ts +0 -62
  246. package/src/utils/task-progress.ts +0 -43
  247. package/tsconfig.json +0 -28
package/src/core/view.ts DELETED
@@ -1,219 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import chalk from 'chalk';
4
- import { getTaskProgressForChange, formatTaskStatus } from '../utils/task-progress.js';
5
- import { MarkdownParser } from './parsers/markdown-parser.js';
6
-
7
- export class ViewCommand {
8
- async execute(targetPath: string = '.'): Promise<void> {
9
- const prompterDir = path.join(targetPath, 'prompter');
10
-
11
- if (!fs.existsSync(prompterDir)) {
12
- console.error(chalk.red('No prompter directory found'));
13
- process.exit(1);
14
- }
15
-
16
- console.log(chalk.bold('\nPrompter Dashboard\n'));
17
- console.log('═'.repeat(60));
18
-
19
- // Get changes and specs data
20
- const changesData = await this.getChangesData(prompterDir);
21
- const specsData = await this.getSpecsData(prompterDir);
22
-
23
- // Display summary metrics
24
- this.displaySummary(changesData, specsData);
25
-
26
- // Display draft changes
27
- if (changesData.draft.length > 0) {
28
- console.log(chalk.bold.gray('\nDraft Changes'));
29
- console.log('─'.repeat(60));
30
- changesData.draft.forEach((change) => {
31
- console.log(` ${chalk.gray('○')} ${change.name}`);
32
- });
33
- }
34
-
35
- // Display active changes
36
- if (changesData.active.length > 0) {
37
- console.log(chalk.bold.cyan('\nActive Changes'));
38
- console.log('─'.repeat(60));
39
- changesData.active.forEach((change) => {
40
- const progressBar = this.createProgressBar(change.progress.completed, change.progress.total);
41
- const percentage =
42
- change.progress.total > 0
43
- ? Math.round((change.progress.completed / change.progress.total) * 100)
44
- : 0;
45
-
46
- console.log(
47
- ` ${chalk.yellow('◉')} ${chalk.bold(change.name.padEnd(30))} ${progressBar} ${chalk.dim(`${percentage}%`)}`
48
- );
49
- });
50
- }
51
-
52
- // Display completed changes
53
- if (changesData.completed.length > 0) {
54
- console.log(chalk.bold.green('\nCompleted Changes'));
55
- console.log('─'.repeat(60));
56
- changesData.completed.forEach((change) => {
57
- console.log(` ${chalk.green('✓')} ${change.name}`);
58
- });
59
- }
60
-
61
- // Display specifications
62
- if (specsData.length > 0) {
63
- console.log(chalk.bold.blue('\nSpecifications'));
64
- console.log('─'.repeat(60));
65
-
66
- // Sort specs by requirement count (descending)
67
- specsData.sort((a, b) => b.requirementCount - a.requirementCount);
68
-
69
- specsData.forEach(spec => {
70
- const reqLabel = spec.requirementCount === 1 ? 'requirement' : 'requirements';
71
- console.log(
72
- ` ${chalk.blue('▪')} ${chalk.bold(spec.name.padEnd(30))} ${chalk.dim(`${spec.requirementCount} ${reqLabel}`)}`
73
- );
74
- });
75
- }
76
-
77
- console.log('\n' + '═'.repeat(60));
78
- console.log(chalk.dim(`\nUse ${chalk.white('prompter list --changes')} or ${chalk.white('prompter list --specs')} for detailed views`));
79
- }
80
-
81
- private async getChangesData(prompterDir: string): Promise<{
82
- draft: Array<{ name: string }>;
83
- active: Array<{ name: string; progress: { total: number; completed: number } }>;
84
- completed: Array<{ name: string }>;
85
- }> {
86
- const changesDir = path.join(prompterDir, 'changes');
87
-
88
- if (!fs.existsSync(changesDir)) {
89
- return { draft: [], active: [], completed: [] };
90
- }
91
-
92
- const draft: Array<{ name: string }> = [];
93
- const active: Array<{ name: string; progress: { total: number; completed: number } }> = [];
94
- const completed: Array<{ name: string }> = [];
95
-
96
- const entries = fs.readdirSync(changesDir, { withFileTypes: true });
97
-
98
- for (const entry of entries) {
99
- if (entry.isDirectory() && entry.name !== 'archive') {
100
- const progress = await getTaskProgressForChange(changesDir, entry.name);
101
-
102
- if (progress.total === 0) {
103
- // No tasks defined yet - still in planning/draft phase
104
- draft.push({ name: entry.name });
105
- } else if (progress.completed === progress.total) {
106
- // All tasks complete
107
- completed.push({ name: entry.name });
108
- } else {
109
- // Has tasks but not all complete
110
- active.push({ name: entry.name, progress });
111
- }
112
- }
113
- }
114
-
115
- // Sort all categories by name for deterministic ordering
116
- draft.sort((a, b) => a.name.localeCompare(b.name));
117
-
118
- // Sort active changes by completion percentage (ascending) and then by name
119
- active.sort((a, b) => {
120
- const percentageA = a.progress.total > 0 ? a.progress.completed / a.progress.total : 0;
121
- const percentageB = b.progress.total > 0 ? b.progress.completed / b.progress.total : 0;
122
-
123
- if (percentageA < percentageB) return -1;
124
- if (percentageA > percentageB) return 1;
125
- return a.name.localeCompare(b.name);
126
- });
127
- completed.sort((a, b) => a.name.localeCompare(b.name));
128
-
129
- return { draft, active, completed };
130
- }
131
-
132
- private async getSpecsData(prompterDir: string): Promise<Array<{ name: string; requirementCount: number }>> {
133
- const specsDir = path.join(prompterDir, 'specs');
134
-
135
- if (!fs.existsSync(specsDir)) {
136
- return [];
137
- }
138
-
139
- const specs: Array<{ name: string; requirementCount: number }> = [];
140
- const entries = fs.readdirSync(specsDir, { withFileTypes: true });
141
-
142
- for (const entry of entries) {
143
- if (entry.isDirectory()) {
144
- const specFile = path.join(specsDir, entry.name, 'spec.md');
145
-
146
- if (fs.existsSync(specFile)) {
147
- try {
148
- const content = fs.readFileSync(specFile, 'utf-8');
149
- const parser = new MarkdownParser(content);
150
- const spec = parser.parseSpec(entry.name);
151
- const requirementCount = spec.requirements.length;
152
- specs.push({ name: entry.name, requirementCount });
153
- } catch (error) {
154
- // If spec cannot be parsed, include with 0 count
155
- specs.push({ name: entry.name, requirementCount: 0 });
156
- }
157
- }
158
- }
159
- }
160
-
161
- return specs;
162
- }
163
-
164
- private displaySummary(
165
- changesData: { draft: any[]; active: any[]; completed: any[] },
166
- specsData: any[]
167
- ): void {
168
- const totalChanges =
169
- changesData.draft.length + changesData.active.length + changesData.completed.length;
170
- const totalSpecs = specsData.length;
171
- const totalRequirements = specsData.reduce((sum, spec) => sum + spec.requirementCount, 0);
172
-
173
- // Calculate total task progress
174
- let totalTasks = 0;
175
- let completedTasks = 0;
176
-
177
- changesData.active.forEach((change) => {
178
- totalTasks += change.progress.total;
179
- completedTasks += change.progress.completed;
180
- });
181
-
182
- changesData.completed.forEach(() => {
183
- // Completed changes count as 100% done (we don't know exact task count)
184
- // This is a simplification
185
- });
186
-
187
- console.log(chalk.bold('Summary:'));
188
- console.log(
189
- ` ${chalk.cyan('●')} Specifications: ${chalk.bold(totalSpecs)} specs, ${chalk.bold(totalRequirements)} requirements`
190
- );
191
- if (changesData.draft.length > 0) {
192
- console.log(` ${chalk.gray('●')} Draft Changes: ${chalk.bold(changesData.draft.length)}`);
193
- }
194
- console.log(
195
- ` ${chalk.yellow('●')} Active Changes: ${chalk.bold(changesData.active.length)} in progress`
196
- );
197
- console.log(` ${chalk.green('●')} Completed Changes: ${chalk.bold(changesData.completed.length)}`);
198
-
199
- if (totalTasks > 0) {
200
- const overallProgress = Math.round((completedTasks / totalTasks) * 100);
201
- console.log(
202
- ` ${chalk.magenta('●')} Task Progress: ${chalk.bold(`${completedTasks}/${totalTasks}`)} (${overallProgress}% complete)`
203
- );
204
- }
205
- }
206
-
207
- private createProgressBar(completed: number, total: number, width: number = 20): string {
208
- if (total === 0) return chalk.dim('─'.repeat(width));
209
-
210
- const percentage = completed / total;
211
- const filled = Math.round(percentage * width);
212
- const empty = width - filled;
213
-
214
- const filledBar = chalk.green('█'.repeat(filled));
215
- const emptyBar = chalk.dim('░'.repeat(empty));
216
-
217
- return `[${filledBar}${emptyBar}]`;
218
- }
219
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { PrompterConfig } from './core/config.js';
@@ -1,171 +0,0 @@
1
- import * as fs from 'node:fs';
2
- import * as path from 'node:path';
3
- import * as yaml from 'yaml';
4
- import { ChangeMetadataSchema, type ChangeMetadata } from '../core/artifact-graph/types.js';
5
- import { listSchemas } from '../core/artifact-graph/resolver.js';
6
-
7
- const METADATA_FILENAME = '.prompter.yaml';
8
-
9
- /**
10
- * Error thrown when change metadata validation fails.
11
- */
12
- export class ChangeMetadataError extends Error {
13
- constructor(
14
- message: string,
15
- public readonly metadataPath: string,
16
- public readonly cause?: Error
17
- ) {
18
- super(message);
19
- this.name = 'ChangeMetadataError';
20
- }
21
- }
22
-
23
- /**
24
- * Validates that a schema name is valid (exists in available schemas).
25
- *
26
- * @param schemaName - The schema name to validate
27
- * @returns The validated schema name
28
- * @throws Error if schema is not found
29
- */
30
- export function validateSchemaName(schemaName: string): string {
31
- const availableSchemas = listSchemas();
32
- if (!availableSchemas.includes(schemaName)) {
33
- throw new Error(
34
- `Unknown schema '${schemaName}'. Available: ${availableSchemas.join(', ')}`
35
- );
36
- }
37
- return schemaName;
38
- }
39
-
40
- /**
41
- * Writes change metadata to .prompter.yaml in the change directory.
42
- *
43
- * @param changeDir - The path to the change directory
44
- * @param metadata - The metadata to write
45
- * @throws ChangeMetadataError if validation fails or write fails
46
- */
47
- export function writeChangeMetadata(
48
- changeDir: string,
49
- metadata: ChangeMetadata
50
- ): void {
51
- const metaPath = path.join(changeDir, METADATA_FILENAME);
52
-
53
- // Validate schema exists
54
- validateSchemaName(metadata.schema);
55
-
56
- // Validate with Zod
57
- const parseResult = ChangeMetadataSchema.safeParse(metadata);
58
- if (!parseResult.success) {
59
- throw new ChangeMetadataError(
60
- `Invalid metadata: ${parseResult.error.message}`,
61
- metaPath
62
- );
63
- }
64
-
65
- // Write YAML file
66
- const content = yaml.stringify(parseResult.data);
67
- try {
68
- fs.writeFileSync(metaPath, content, 'utf-8');
69
- } catch (err) {
70
- const ioError = err instanceof Error ? err : new Error(String(err));
71
- throw new ChangeMetadataError(
72
- `Failed to write metadata: ${ioError.message}`,
73
- metaPath,
74
- ioError
75
- );
76
- }
77
- }
78
-
79
- /**
80
- * Reads change metadata from .prompter.yaml in the change directory.
81
- *
82
- * @param changeDir - The path to the change directory
83
- * @returns The validated metadata, or null if no metadata file exists
84
- * @throws ChangeMetadataError if the file exists but is invalid
85
- */
86
- export function readChangeMetadata(changeDir: string): ChangeMetadata | null {
87
- const metaPath = path.join(changeDir, METADATA_FILENAME);
88
-
89
- if (!fs.existsSync(metaPath)) {
90
- return null;
91
- }
92
-
93
- let content: string;
94
- try {
95
- content = fs.readFileSync(metaPath, 'utf-8');
96
- } catch (err) {
97
- const ioError = err instanceof Error ? err : new Error(String(err));
98
- throw new ChangeMetadataError(
99
- `Failed to read metadata: ${ioError.message}`,
100
- metaPath,
101
- ioError
102
- );
103
- }
104
-
105
- let parsed: unknown;
106
- try {
107
- parsed = yaml.parse(content);
108
- } catch (err) {
109
- const parseError = err instanceof Error ? err : new Error(String(err));
110
- throw new ChangeMetadataError(
111
- `Invalid YAML in metadata file: ${parseError.message}`,
112
- metaPath,
113
- parseError
114
- );
115
- }
116
-
117
- // Validate with Zod
118
- const parseResult = ChangeMetadataSchema.safeParse(parsed);
119
- if (!parseResult.success) {
120
- throw new ChangeMetadataError(
121
- `Invalid metadata: ${parseResult.error.message}`,
122
- metaPath
123
- );
124
- }
125
-
126
- // Validate that the schema exists
127
- const availableSchemas = listSchemas();
128
- if (!availableSchemas.includes(parseResult.data.schema)) {
129
- throw new ChangeMetadataError(
130
- `Unknown schema '${parseResult.data.schema}'. Available: ${availableSchemas.join(', ')}`,
131
- metaPath
132
- );
133
- }
134
-
135
- return parseResult.data;
136
- }
137
-
138
- /**
139
- * Resolves the schema for a change, with explicit override taking precedence.
140
- *
141
- * Resolution order:
142
- * 1. Explicit schema (if provided)
143
- * 2. Schema from .prompter.yaml metadata (if exists)
144
- * 3. Default 'spec-driven'
145
- *
146
- * @param changeDir - The path to the change directory
147
- * @param explicitSchema - Optional explicit schema override
148
- * @returns The resolved schema name
149
- */
150
- export function resolveSchemaForChange(
151
- changeDir: string,
152
- explicitSchema?: string
153
- ): string {
154
- // 1. Explicit override wins
155
- if (explicitSchema) {
156
- return explicitSchema;
157
- }
158
-
159
- // 2. Try reading from metadata
160
- try {
161
- const metadata = readChangeMetadata(changeDir);
162
- if (metadata?.schema) {
163
- return metadata.schema;
164
- }
165
- } catch {
166
- // If metadata read fails, fall back to default
167
- }
168
-
169
- // 3. Default
170
- return 'spec-driven';
171
- }
@@ -1,131 +0,0 @@
1
- import path from 'path';
2
- import { FileSystemUtils } from './file-system.js';
3
- import { writeChangeMetadata, validateSchemaName } from './change-metadata.js';
4
-
5
- const DEFAULT_SCHEMA = 'spec-driven';
6
-
7
- /**
8
- * Options for creating a change.
9
- */
10
- export interface CreateChangeOptions {
11
- /** The workflow schema to use (default: 'spec-driven') */
12
- schema?: string;
13
- }
14
-
15
- /**
16
- * Result of validating a change name.
17
- */
18
- export interface ValidationResult {
19
- valid: boolean;
20
- error?: string;
21
- }
22
-
23
- /**
24
- * Validates that a change name follows kebab-case conventions.
25
- *
26
- * Valid names:
27
- * - Start with a lowercase letter
28
- * - Contain only lowercase letters, numbers, and hyphens
29
- * - Do not start or end with a hyphen
30
- * - Do not contain consecutive hyphens
31
- *
32
- * @param name - The change name to validate
33
- * @returns Validation result with `valid: true` or `valid: false` with an error message
34
- *
35
- * @example
36
- * validateChangeName('add-auth') // { valid: true }
37
- * validateChangeName('Add-Auth') // { valid: false, error: '...' }
38
- */
39
- export function validateChangeName(name: string): ValidationResult {
40
- // Pattern: starts with lowercase letter, followed by lowercase letters/numbers,
41
- // optionally followed by hyphen + lowercase letters/numbers (repeatable)
42
- const kebabCasePattern = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
43
-
44
- if (!name) {
45
- return { valid: false, error: 'Change name cannot be empty' };
46
- }
47
-
48
- if (!kebabCasePattern.test(name)) {
49
- // Provide specific error messages for common mistakes
50
- if (/[A-Z]/.test(name)) {
51
- return { valid: false, error: 'Change name must be lowercase (use kebab-case)' };
52
- }
53
- if (/\s/.test(name)) {
54
- return { valid: false, error: 'Change name cannot contain spaces (use hyphens instead)' };
55
- }
56
- if (/_/.test(name)) {
57
- return { valid: false, error: 'Change name cannot contain underscores (use hyphens instead)' };
58
- }
59
- if (name.startsWith('-')) {
60
- return { valid: false, error: 'Change name cannot start with a hyphen' };
61
- }
62
- if (name.endsWith('-')) {
63
- return { valid: false, error: 'Change name cannot end with a hyphen' };
64
- }
65
- if (/--/.test(name)) {
66
- return { valid: false, error: 'Change name cannot contain consecutive hyphens' };
67
- }
68
- if (/[^a-z0-9-]/.test(name)) {
69
- return { valid: false, error: 'Change name can only contain lowercase letters, numbers, and hyphens' };
70
- }
71
- if (/^[0-9]/.test(name)) {
72
- return { valid: false, error: 'Change name must start with a letter' };
73
- }
74
-
75
- return { valid: false, error: 'Change name must follow kebab-case convention (e.g., add-auth, refactor-db)' };
76
- }
77
-
78
- return { valid: true };
79
- }
80
-
81
- /**
82
- * Creates a new change directory with metadata file.
83
- *
84
- * @param projectRoot - The root directory of the project (where `prompter/` lives)
85
- * @param name - The change name (must be valid kebab-case)
86
- * @param options - Optional settings for the change
87
- * @throws Error if the change name is invalid
88
- * @throws Error if the schema name is invalid
89
- * @throws Error if the change directory already exists
90
- *
91
- * @example
92
- * // Creates prompter/changes/add-auth/ with default schema
93
- * await createChange('/path/to/project', 'add-auth')
94
- *
95
- * @example
96
- * // Creates prompter/changes/add-auth/ with TDD schema
97
- * await createChange('/path/to/project', 'add-auth', { schema: 'tdd' })
98
- */
99
- export async function createChange(
100
- projectRoot: string,
101
- name: string,
102
- options: CreateChangeOptions = {}
103
- ): Promise<void> {
104
- // Validate the name first
105
- const validation = validateChangeName(name);
106
- if (!validation.valid) {
107
- throw new Error(validation.error);
108
- }
109
-
110
- // Determine schema (validate if provided)
111
- const schemaName = options.schema ?? DEFAULT_SCHEMA;
112
- validateSchemaName(schemaName);
113
-
114
- // Build the change directory path
115
- const changeDir = path.join(projectRoot, 'prompter', 'changes', name);
116
-
117
- // Check if change already exists
118
- if (await FileSystemUtils.directoryExists(changeDir)) {
119
- throw new Error(`Change '${name}' already exists at ${changeDir}`);
120
- }
121
-
122
- // Create the directory (including parent directories if needed)
123
- await FileSystemUtils.createDirectory(changeDir);
124
-
125
- // Write metadata file with schema and creation date
126
- const today = new Date().toISOString().split('T')[0];
127
- writeChangeMetadata(changeDir, {
128
- schema: schemaName,
129
- created: today,
130
- });
131
- }