@makerkit/prd 0.0.0 → 0.0.1

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 (53) hide show
  1. package/package.json +2 -21
  2. package/.turbo/turbo-build.log +0 -46
  3. package/.turbo/turbo-test.log +0 -21
  4. package/.turbo/turbo-typecheck.log +0 -1
  5. package/dist/README.md +0 -65
  6. package/dist/package.json +0 -49
  7. package/src/__tests__/agent-workflow.test.ts +0 -377
  8. package/src/__tests__/attachments.test.ts +0 -475
  9. package/src/__tests__/node.test.ts +0 -141
  10. package/src/__tests__/plan-check.test.ts +0 -229
  11. package/src/__tests__/planning.test.ts +0 -1059
  12. package/src/__tests__/prd-operations.test.ts +0 -423
  13. package/src/__tests__/prd.service.test.ts +0 -477
  14. package/src/__tests__/prd.tool.test.ts +0 -282
  15. package/src/__tests__/templates.test.ts +0 -141
  16. package/src/applicability.ts +0 -73
  17. package/src/attachment-paths.ts +0 -78
  18. package/src/attachments.ts +0 -160
  19. package/src/edge-cases.ts +0 -52
  20. package/src/index.ts +0 -35
  21. package/src/markdown.ts +0 -268
  22. package/src/mcp/index.ts +0 -839
  23. package/src/mcp/tool-response.ts +0 -85
  24. package/src/node.ts +0 -146
  25. package/src/open-questions.ts +0 -93
  26. package/src/plan-check.ts +0 -282
  27. package/src/planning-operations.ts +0 -429
  28. package/src/prd-operations.ts +0 -690
  29. package/src/prd.service.ts +0 -1051
  30. package/src/prompts.ts +0 -110
  31. package/src/safe-file-name.ts +0 -42
  32. package/src/schema.ts +0 -976
  33. package/src/templates.ts +0 -173
  34. package/src/testing/fake-mcp-server.ts +0 -81
  35. package/src/types.ts +0 -333
  36. package/tsconfig.json +0 -23
  37. package/tsconfig.lib.json +0 -8
  38. package/tsconfig.spec.json +0 -7
  39. package/tsdown.config.mts +0 -11
  40. package/vitest.config.mts +0 -8
  41. /package/{dist/LICENSE → LICENSE} +0 -0
  42. /package/{dist/index.d.ts → index.d.ts} +0 -0
  43. /package/{dist/index.js → index.js} +0 -0
  44. /package/{dist/index.mjs → index.mjs} +0 -0
  45. /package/{dist/mcp.d.ts → mcp.d.ts} +0 -0
  46. /package/{dist/mcp.js → mcp.js} +0 -0
  47. /package/{dist/mcp.mjs → mcp.mjs} +0 -0
  48. /package/{dist/node.d.ts → node.d.ts} +0 -0
  49. /package/{dist/node.js → node.js} +0 -0
  50. /package/{dist/node.mjs → node.mjs} +0 -0
  51. /package/{dist/prd.service-DSBp8sMl.d.ts → prd.service-DSBp8sMl.d.ts} +0 -0
  52. /package/{dist/prompts-Bber0S1Z.mjs → prompts-Bber0S1Z.mjs} +0 -0
  53. /package/{dist/prompts-CIX8IeAx.js → prompts-CIX8IeAx.js} +0 -0
@@ -1,229 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import { checkPlan } from '../plan-check';
4
- import { normalizePrd } from '../prd.service';
5
- import type { StructuredPRD, UserStory } from '../types';
6
-
7
- function story(id: string, overrides: Partial<UserStory> = {}): UserStory {
8
- return {
9
- id,
10
- title: id,
11
- userStory: 'As a founder, I want to do it so that it helps',
12
- businessValue: 'it helps',
13
- acceptanceCriteria: ['First', 'Second'],
14
- status: 'not_started',
15
- priority: 'P2',
16
- estimatedComplexity: 'S',
17
- dependencies: [],
18
- testSeams: ['someAction'],
19
- ...overrides,
20
- };
21
- }
22
-
23
- function prd(overrides: Partial<StructuredPRD> = {}): StructuredPRD {
24
- return { ...normalizePrd({}, '2026-10-14'), ...overrides };
25
- }
26
-
27
- const ids = (result: ReturnType<typeof checkPlan>) =>
28
- result.items.map((item) => `${item.severity}:${item.id}`);
29
-
30
- describe('checkPlan', () => {
31
- it('blocks an empty plan', () => {
32
- const result = checkPlan(prd());
33
-
34
- expect(result.ready_to_build).toBe(false);
35
- expect(ids(result)).toEqual(
36
- expect.arrayContaining(['required:stories', 'required:scope']),
37
- );
38
- });
39
-
40
- it('is ready once the required items are covered, leaving recommendations', () => {
41
- const result = checkPlan(
42
- prd({
43
- userStories: [story('US001')],
44
- nonGoals: ['Email sync'],
45
- edgeCases: [
46
- {
47
- id: 'EC001',
48
- case: 'Email already invited',
49
- expectedBehavior: 'Resend the invite',
50
- status: 'decided',
51
- },
52
- ],
53
- }),
54
- );
55
-
56
- expect(result.ready_to_build).toBe(true);
57
- expect(ids(result)).toEqual([
58
- 'recommended:design-guidance',
59
- 'recommended:security',
60
- 'recommended:scope',
61
- 'recommended:success-metrics',
62
- 'recommended:global-acceptance-criteria',
63
- 'recommended:target-metrics',
64
- 'recommended:rollout',
65
- 'recommended:data-models',
66
- ]);
67
- });
68
-
69
- it('requires permissions once there is data or an outside service to protect', () => {
70
- const base = {
71
- userStories: [story('US001')],
72
- nonGoals: ['x'],
73
- outOfScope: ['y'],
74
- edgeCases: [{ id: 'EC001', case: 'c', expectedBehavior: 'b', status: 'decided' as const }],
75
- };
76
-
77
- expect(ids(checkPlan(prd(base)))).not.toContain('required:permissions');
78
-
79
- const withData = checkPlan(
80
- prd({
81
- ...base,
82
- technicalContracts: { ...prd().technicalContracts, dataModels: ['Invoice: ...'] },
83
- }),
84
- );
85
-
86
- expect(withData.ready_to_build).toBe(false);
87
- expect(ids(withData)).toContain('required:permissions');
88
- });
89
-
90
- it('stops asking for parts marked not applicable, but not for open edge cases', () => {
91
- const result = checkPlan(
92
- prd({
93
- userStories: [story('US001')],
94
- nonGoals: ['x'],
95
- outOfScope: ['y'],
96
- technicalContracts: { ...prd().technicalContracts, dataModels: ['Invoice'] },
97
- edgeCases: [{ id: 'EC001', case: 'c', expectedBehavior: '', status: 'open' }],
98
- notApplicable: { rollout: 'Internal tool', measurement: '', security: 'Local only' },
99
- }),
100
- );
101
-
102
- expect(ids(result)).not.toContain('recommended:rollout');
103
- expect(ids(result)).not.toContain('recommended:target-metrics');
104
- expect(ids(result)).not.toContain('required:permissions');
105
- expect(ids(result)).not.toContain('recommended:security');
106
- expect(ids(result)).toContain('required:open-edge-cases');
107
- });
108
-
109
- it('requires edge cases once there are stories', () => {
110
- const result = checkPlan(
111
- prd({ userStories: [story('US001')], nonGoals: ['x'], outOfScope: ['y'] }),
112
- );
113
-
114
- expect(result.ready_to_build).toBe(false);
115
- expect(ids(result)).toContain('required:edge-cases');
116
- });
117
-
118
- it('blocks while an edge case is open, naming its stories', () => {
119
- const result = checkPlan(
120
- prd({
121
- userStories: [story('US001'), story('US002')],
122
- nonGoals: ['x'],
123
- outOfScope: ['y'],
124
- designGuidance: ['Use the kit components'],
125
- edgeCases: [
126
- { id: 'EC001', case: 'Partial payment', expectedBehavior: '', status: 'open', storyIds: ['US002'] },
127
- { id: 'EC002', case: 'Bounce', expectedBehavior: 'Pause', status: 'decided' },
128
- ],
129
- }),
130
- );
131
-
132
- const open = result.items.find((item) => item.id === 'open-edge-cases');
133
-
134
- expect(result.ready_to_build).toBe(false);
135
- expect(open).toMatchObject({ severity: 'required', storyIds: ['US002'] });
136
- expect(open?.message).toMatch(/^1 edge cases are still open/);
137
- expect(ids(result)).not.toContain('recommended:design-guidance');
138
- });
139
-
140
- it('names the stories an item is about', () => {
141
- const result = checkPlan(
142
- prd({
143
- nonGoals: ['x'],
144
- outOfScope: ['y'],
145
- userStories: [
146
- story('US001', { acceptanceCriteria: [] }),
147
- story('US002', { acceptanceCriteria: ['Only one'] }),
148
- story('US003', { testSeams: undefined }),
149
- story('US004', { status: 'blocked' }),
150
- ],
151
- }),
152
- );
153
-
154
- const byId = Object.fromEntries(
155
- result.items.map((item) => [item.id, item]),
156
- );
157
-
158
- expect(result.ready_to_build).toBe(false);
159
- expect(byId['stories-without-criteria']?.storyIds).toEqual(['US001']);
160
- expect(byId['vague-stories']?.storyIds).toEqual(['US002']);
161
- expect(byId['test-seams']?.storyIds).toEqual(['US003']);
162
- expect(byId['blocked-stories']?.storyIds).toEqual(['US004']);
163
- });
164
-
165
- it('recommends phases only once there are more than five stories', () => {
166
- const five = ['1', '2', '3', '4', '5'].map((n) => story(`US00${n}`));
167
-
168
- expect(ids(checkPlan(prd({ userStories: five })))).not.toContain(
169
- 'recommended:phases',
170
- );
171
- expect(
172
- ids(checkPlan(prd({ userStories: [...five, story('US006')] }))),
173
- ).toContain('recommended:phases');
174
- });
175
-
176
- it('asks for data models once there are stories', () => {
177
- const base = prd();
178
-
179
- expect(ids(checkPlan(base))).not.toContain('recommended:data-models');
180
- expect(ids(checkPlan(prd({ userStories: [story('US001')] })))).toContain(
181
- 'recommended:data-models',
182
- );
183
- expect(
184
- ids(
185
- checkPlan(
186
- prd({
187
- userStories: [story('US001')],
188
- technicalContracts: {
189
- ...base.technicalContracts,
190
- dataModels: ['Bookmark: a saved link. Belongs to one account.'],
191
- },
192
- }),
193
- ),
194
- ),
195
- ).not.toContain('recommended:data-models');
196
- });
197
-
198
- it('does not ask completed stories for test seams', () => {
199
- const result = checkPlan(
200
- prd({
201
- userStories: [story('US001', { status: 'completed', testSeams: [] })],
202
- }),
203
- );
204
-
205
- expect(ids(result)).not.toContain('recommended:test-seams');
206
- });
207
-
208
- it('requires answers to questions that block unfinished stories', () => {
209
- const result = checkPlan(
210
- prd({
211
- userStories: [story('US001'), story('US002', { status: 'completed' })],
212
- nonGoals: ['x'],
213
- outOfScope: ['y'],
214
- edgeCases: [{ id: 'EC001', case: 'c', expectedBehavior: 'b', status: 'decided' }],
215
- openQuestions: [
216
- { id: 'Q001', question: 'Blocks US001', storyIds: ['US001'] },
217
- { id: 'Q002', question: 'Only blocks a completed story', storyIds: ['US002'] },
218
- { id: 'Q003', question: 'Blocks nothing' },
219
- ],
220
- }),
221
- );
222
-
223
- const byId = Object.fromEntries(result.items.map((item) => [item.id, item]));
224
-
225
- expect(result.ready_to_build).toBe(false);
226
- expect(byId['blocking-questions']).toMatchObject({ severity: 'required', storyIds: ['US001'] });
227
- expect(byId['open-questions']?.message).toMatch(/^2 open questions/);
228
- });
229
- });