@makerkit/prd 0.0.3 → 0.0.5

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 (63) hide show
  1. package/.turbo/turbo-build.log +78 -0
  2. package/.turbo/turbo-test.log +19 -0
  3. package/.turbo/turbo-typecheck.log +6 -0
  4. package/README.md +7 -1
  5. package/dist/README.md +71 -0
  6. package/dist/attachment-paths-BAhRGiib.js +112 -0
  7. package/dist/attachment-paths-C-SWgoSx.mjs +77 -0
  8. package/dist/index.d.ts +81 -0
  9. package/{index.js → dist/index.js} +257 -524
  10. package/{index.mjs → dist/index.mjs} +189 -462
  11. package/{mcp.d.ts → dist/mcp.d.ts} +2 -4
  12. package/{mcp.js → dist/mcp.js} +24 -24
  13. package/{mcp.mjs → dist/mcp.mjs} +24 -24
  14. package/{node.d.ts → dist/node.d.ts} +4 -4
  15. package/{node.js → dist/node.js} +28 -4
  16. package/{node.mjs → dist/node.mjs} +30 -6
  17. package/dist/operations.d.ts +141 -0
  18. package/dist/operations.js +22 -0
  19. package/dist/operations.mjs +1 -0
  20. package/dist/package.json +54 -0
  21. package/dist/prd-operations-BvFxo9bg.mjs +459 -0
  22. package/dist/prd-operations-CcahfbOy.js +584 -0
  23. package/dist/prd.service-CTwKZV-3.d.ts +114 -0
  24. package/{prompts-DJQ4FQ11.js → dist/prompts-1qhax_dj.js} +150 -167
  25. package/{prompts-B0VejF7q.mjs → dist/prompts-BlsYD0gf.mjs} +121 -132
  26. package/{prd.service-x5EpOoMv.d.ts → dist/schema-BwTnt0B9.d.ts} +545 -323
  27. package/package.json +26 -2
  28. package/src/__tests__/agent-workflow.test.ts +417 -0
  29. package/src/__tests__/attachments.test.ts +505 -0
  30. package/src/__tests__/node.test.ts +199 -0
  31. package/src/__tests__/plan-check.test.ts +390 -0
  32. package/src/__tests__/planning.test.ts +1137 -0
  33. package/src/__tests__/prd-operations.test.ts +571 -0
  34. package/src/__tests__/prd.service.test.ts +652 -0
  35. package/src/__tests__/prd.tool.test.ts +282 -0
  36. package/src/__tests__/templates.test.ts +145 -0
  37. package/src/applicability.ts +73 -0
  38. package/src/attachment-paths.ts +83 -0
  39. package/src/attachments.ts +166 -0
  40. package/src/edge-cases.ts +61 -0
  41. package/src/index.ts +33 -0
  42. package/src/markdown.ts +297 -0
  43. package/src/mcp/index.ts +875 -0
  44. package/src/mcp/tool-response.ts +85 -0
  45. package/src/node.ts +184 -0
  46. package/src/open-questions.ts +98 -0
  47. package/src/plan-check.ts +385 -0
  48. package/src/planning-operations.ts +524 -0
  49. package/src/prd-operations.ts +769 -0
  50. package/src/prd.service.ts +1165 -0
  51. package/src/prompts.ts +161 -0
  52. package/src/safe-file-name.ts +42 -0
  53. package/src/schema.ts +1090 -0
  54. package/src/templates.ts +173 -0
  55. package/src/testing/fake-mcp-server.ts +81 -0
  56. package/src/types.ts +381 -0
  57. package/tsconfig.json +23 -0
  58. package/tsconfig.lib.json +8 -0
  59. package/tsconfig.spec.json +7 -0
  60. package/tsdown.config.mts +12 -0
  61. package/vitest.config.mts +8 -0
  62. package/index.d.ts +0 -228
  63. /package/{LICENSE → dist/LICENSE} +0 -0
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Starting points for new PRDs. A template fills sections the author would
3
+ * otherwise start empty, and gives `shape_prd` extra questions that matter for
4
+ * that kind of work. Everything it adds can be edited or removed afterwards.
5
+ */
6
+ export interface PrdTemplate {
7
+ id: TemplateId;
8
+ name: string;
9
+ description: string;
10
+ /** Sentence an agent can use to pick the right template. */
11
+ whenToUse: string;
12
+ defaults: {
13
+ nonGoals?: string[];
14
+ outOfScope?: string[];
15
+ openQuestions?: string[];
16
+ globalAcceptanceCriteria?: string[];
17
+ qualityStandards?: string[];
18
+ technicalConstraints?: string[];
19
+ rolloutPhases?: string[];
20
+ rollbackConditions?: string[];
21
+ };
22
+ /** Extra questions for the shaping interview. */
23
+ interviewFocus: string[];
24
+ }
25
+
26
+ export const TEMPLATE_IDS = [
27
+ 'saas-feature',
28
+ 'internal-tool',
29
+ 'integration',
30
+ 'mvp',
31
+ ] as const;
32
+
33
+ export type TemplateId = (typeof TEMPLATE_IDS)[number];
34
+
35
+ export const PRD_TEMPLATES: readonly PrdTemplate[] = [
36
+ {
37
+ id: 'saas-feature',
38
+ name: 'SaaS feature',
39
+ description:
40
+ 'A new feature in a multi-tenant SaaS: data scoped to accounts or teams, roles and permissions, and possibly plan limits.',
41
+ whenToUse:
42
+ 'Customers of an existing SaaS will use it, and its data belongs to an account or team.',
43
+ defaults: {
44
+ openQuestions: [
45
+ 'Does the data belong to a personal account, a team account, or both?',
46
+ 'Which roles can view, create, edit and delete it?',
47
+ 'Is it limited by billing plan, and what happens when a limit is reached?',
48
+ ],
49
+ globalAcceptanceCriteria: [
50
+ 'Members of one account cannot read or change another account’s data, including through the database API directly.',
51
+ 'Every action respects the role permissions agreed in this PRD.',
52
+ 'Empty, loading and error states are handled on every new screen.',
53
+ ],
54
+ qualityStandards: [
55
+ 'Access rules are enforced in the database (e.g. row-level security), not only in the UI.',
56
+ 'New database changes ship as migrations with tests for the access rules.',
57
+ ],
58
+ technicalConstraints: [
59
+ 'Follow the existing project conventions for data access, server actions and UI components.',
60
+ ],
61
+ rolloutPhases: [
62
+ 'Release behind a feature flag to internal accounts',
63
+ 'Enable for all accounts',
64
+ ],
65
+ rollbackConditions: [
66
+ 'Errors or data-access problems reported after release: turn the flag off',
67
+ ],
68
+ },
69
+ interviewFocus: [
70
+ 'Who owns the data: a personal account, a team, or both?',
71
+ 'Which roles can do what, and is anything limited by plan?',
72
+ 'What does a new account see before any data exists?',
73
+ ],
74
+ },
75
+ {
76
+ id: 'internal-tool',
77
+ name: 'Internal tool',
78
+ description:
79
+ 'A tool for yourself or your own team, where speed matters more than configurability.',
80
+ whenToUse:
81
+ 'Only you or your team will use it; it will not be sold to other organisations.',
82
+ defaults: {
83
+ nonGoals: [
84
+ 'Settings screens for things that can be hard-coded for our own use',
85
+ 'Support for other organisations or tenants',
86
+ ],
87
+ openQuestions: [
88
+ 'Who exactly will use it, and how often?',
89
+ 'What is hard-coded (stages, categories, fields) rather than configurable?',
90
+ ],
91
+ globalAcceptanceCriteria: [
92
+ 'Works on the devices the team actually uses (desktop and phone if needed).',
93
+ 'Only signed-in team members can access it.',
94
+ ],
95
+ qualityStandards: [
96
+ 'Prefer the simplest working version; no configuration UI unless asked for.',
97
+ ],
98
+ },
99
+ interviewFocus: [
100
+ 'What can be hard-coded because only we use it?',
101
+ 'Which existing tool or spreadsheet does this replace, and what annoys us about it?',
102
+ ],
103
+ },
104
+ {
105
+ id: 'integration',
106
+ name: 'Third-party integration',
107
+ description:
108
+ 'Connecting to an external service: an API, webhooks, OAuth, or a data sync.',
109
+ whenToUse: 'The work depends on an external service you do not control.',
110
+ defaults: {
111
+ openQuestions: [
112
+ 'Which direction does data flow: we call them, they call us (webhooks), or both?',
113
+ 'How do users connect their account (API key, OAuth), and where are credentials stored?',
114
+ 'What happens when the service is down, slow or rate-limits us?',
115
+ ],
116
+ globalAcceptanceCriteria: [
117
+ 'Credentials and tokens are stored encrypted or in secrets, never in client code or logs.',
118
+ 'Incoming webhooks are verified (signature) and safe to receive twice.',
119
+ 'Failures are retried or surfaced to the user; nothing fails silently.',
120
+ ],
121
+ qualityStandards: [
122
+ 'The external service is called through one module, so it can be faked in tests.',
123
+ ],
124
+ technicalConstraints: [
125
+ 'Respect the service’s rate limits and terms of use.',
126
+ ],
127
+ rollbackConditions: [
128
+ 'The integration can be disconnected without losing the user’s own data',
129
+ ],
130
+ },
131
+ interviewFocus: [
132
+ 'What exactly do we read from and write to the service?',
133
+ 'What does the user see while the service is unavailable?',
134
+ 'How is the integration disconnected, and what happens to synced data?',
135
+ ],
136
+ },
137
+ {
138
+ id: 'mvp',
139
+ name: 'First version (MVP)',
140
+ description:
141
+ 'The first version of a new product, cut down to what proves the idea.',
142
+ whenToUse:
143
+ 'The product does not exist yet and the goal is to learn whether it works.',
144
+ defaults: {
145
+ openQuestions: [
146
+ 'What is the one thing a first user must be able to do?',
147
+ 'How will we know it works (a number or a behaviour we can observe)?',
148
+ 'What is the deadline or budget for this first version?',
149
+ ],
150
+ outOfScope: ['Features that are not needed to prove the main idea'],
151
+ globalAcceptanceCriteria: [
152
+ 'A new user can sign up and reach the main action without help.',
153
+ ],
154
+ qualityStandards: ['Cut scope before cutting quality on the main flow.'],
155
+ },
156
+ interviewFocus: [
157
+ 'What is the smallest version that proves the idea?',
158
+ 'Which features can wait until after the first users try it?',
159
+ ],
160
+ },
161
+ ];
162
+
163
+ export function getTemplate(id: TemplateId): PrdTemplate {
164
+ const template = PRD_TEMPLATES.find((candidate) => candidate.id === id);
165
+
166
+ if (!template) {
167
+ throw new Error(
168
+ `Unknown template "${id}". Templates: ${TEMPLATE_IDS.join(', ')}.`,
169
+ );
170
+ }
171
+
172
+ return template;
173
+ }
@@ -0,0 +1,81 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
3
+ import type { ZodTypeAny } from 'zod/v3';
4
+
5
+ /**
6
+ * Minimal stand-in for McpServer used by tool adapter tests. Captures every
7
+ * registerTool call so tests can assert names, annotations and that the
8
+ * handler's structuredContent satisfies the declared outputSchema.
9
+ */
10
+ export interface RegisteredTool {
11
+ name: string;
12
+ config: {
13
+ title?: string;
14
+ description?: string;
15
+ inputSchema?: ZodTypeAny;
16
+ outputSchema?: ZodTypeAny;
17
+ annotations?: ToolAnnotations;
18
+ };
19
+ handler: (input: unknown) => Promise<Record<string, unknown>>;
20
+ }
21
+
22
+ export interface RegisteredPrompt {
23
+ name: string;
24
+ handler: (args: Record<string, unknown>) => {
25
+ messages: Array<{ role: string; content: { type: string; text: string } }>;
26
+ };
27
+ }
28
+
29
+ export function createFakeMcpServer() {
30
+ const tools: RegisteredTool[] = [];
31
+ const prompts: RegisteredPrompt[] = [];
32
+
33
+ const server = {
34
+ registerTool(
35
+ name: string,
36
+ config: RegisteredTool['config'],
37
+ handler: RegisteredTool['handler'],
38
+ ) {
39
+ tools.push({ name, config, handler });
40
+ return {};
41
+ },
42
+ registerPrompt(
43
+ name: string,
44
+ _config: unknown,
45
+ handler: RegisteredPrompt['handler'],
46
+ ) {
47
+ prompts.push({ name, handler });
48
+ return {};
49
+ },
50
+ };
51
+
52
+ return {
53
+ server: server as unknown as McpServer,
54
+ tools,
55
+ prompts,
56
+ tool(name: string) {
57
+ const tool = tools.find((item) => item.name === name);
58
+
59
+ if (!tool) {
60
+ throw new Error(`Tool "${name}" was not registered`);
61
+ }
62
+
63
+ return tool;
64
+ },
65
+ /** Call a tool and validate the result against its own outputSchema. */
66
+ async call(name: string, input: unknown = {}) {
67
+ const tool = this.tool(name);
68
+ const result = await tool.handler(input);
69
+
70
+ if (result.isError) {
71
+ return result;
72
+ }
73
+
74
+ if (tool.config.outputSchema) {
75
+ tool.config.outputSchema.parse(result.structuredContent);
76
+ }
77
+
78
+ return result;
79
+ },
80
+ };
81
+ }
package/src/types.ts ADDED
@@ -0,0 +1,381 @@
1
+ export interface CustomPhase {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ color: string;
6
+ order: number;
7
+ userStoryIds: string[];
8
+ }
9
+
10
+ export type StoryStatus =
11
+ | 'not_started'
12
+ | 'research'
13
+ | 'in_progress'
14
+ | 'review'
15
+ | 'completed'
16
+ | 'blocked';
17
+
18
+ export type StoryPriority = 'P0' | 'P1' | 'P2' | 'P3';
19
+
20
+ export type StoryComplexity = 'XS' | 'S' | 'M' | 'L' | 'XL';
21
+
22
+ /**
23
+ * How a criterion is shown to work. `unit`, `integration` and `e2e` are tests
24
+ * the agent writes; `judge` is scored against a rubric by the agent reviewing
25
+ * the story, for judgment that can be written down (tone, clarity, layout);
26
+ * `manual` and `post-deploy` are checks a person does, for truths that live
27
+ * outside the test environment (a real third party, production-only
28
+ * conditions, judgment no rubric captures).
29
+ */
30
+ export type ProofKind =
31
+ | 'unit'
32
+ | 'integration'
33
+ | 'e2e'
34
+ | 'judge'
35
+ | 'manual'
36
+ | 'post-deploy';
37
+
38
+ /** The proof for one of a story's acceptance criteria, decided while planning. */
39
+ export interface CriterionProof {
40
+ /** The acceptance criterion this proves, exactly as written in the story. */
41
+ criterion: string;
42
+ kind: ProofKind;
43
+ /** The entry point or test file the test exercises. */
44
+ seam?: string;
45
+ /**
46
+ * Why a test cannot prove it (manual, post-deploy) or why a lower seam will
47
+ * not do (e2e).
48
+ */
49
+ reason?: string;
50
+ /** For manual and post-deploy: the strongest automated check still made. */
51
+ fallback?: string;
52
+ /** For judge: what the reviewer scores against, one line per point. */
53
+ rubric?: string[];
54
+ }
55
+
56
+ /** Recorded when a story is marked completed and the project checks passed. */
57
+ export interface StoryVerification {
58
+ verifiedAt: string;
59
+ checks: string[];
60
+ passed: true;
61
+ }
62
+
63
+ /**
64
+ * A hand-off note an agent writes when it finishes working on a story, so the
65
+ * next story (often a fresh session with an empty context) knows what changed.
66
+ */
67
+ export interface StoryLogEntry {
68
+ at: string;
69
+ /** Plain-language list of what a human should now be able to try. */
70
+ whatsNew: string[];
71
+ /** Decisions, gotchas and file locations for the next agent. */
72
+ technicalNotes: string[];
73
+ /**
74
+ * Where the work departed from the PRD and why, so the person approving
75
+ * the story and the review_story prompt can judge it. Absent when there
76
+ * were none, and on logs written before it existed.
77
+ */
78
+ deviations?: string[];
79
+ }
80
+
81
+ export interface UserStory {
82
+ id: string;
83
+ title: string;
84
+ userStory: string;
85
+ businessValue: string;
86
+ acceptanceCriteria: string[];
87
+ status: StoryStatus;
88
+ priority: StoryPriority;
89
+ estimatedComplexity: StoryComplexity;
90
+ dependencies: string[];
91
+ notes?: string;
92
+ /** Worker that claimed the active story through update_story_status. */
93
+ workerId?: string;
94
+ completedAt?: string;
95
+ verification?: StoryVerification;
96
+ log?: StoryLogEntry[];
97
+ /**
98
+ * Where this story is tested: the public entry points (a route, a server
99
+ * action, a service function) whose behaviour the tests exercise.
100
+ */
101
+ testSeams?: string[];
102
+ /** How each acceptance criterion is proven; see `CriterionProof`. */
103
+ proofs?: CriterionProof[];
104
+ /** Ids of the PRD's attachments this story uses, e.g. a mockup. */
105
+ attachmentIds?: string[];
106
+ /**
107
+ * Design notes for this story only: layout, states and copy that the PRD's
108
+ * design guidance does not cover. Binding, like the guidance.
109
+ */
110
+ designNotes?: string[];
111
+ /**
112
+ * Security notes for this story only: the specific abuse to defend against
113
+ * and how. Binding, like the PRD's security considerations.
114
+ */
115
+ securityNotes?: string[];
116
+ }
117
+
118
+ /**
119
+ * A file or link the plan refers to: a mockup, a screenshot, reference docs.
120
+ * Files live in the PRD's own folder, `.prds/<prd name>/`, next to its JSON
121
+ * file. Exactly one of `path` and `url` is set.
122
+ */
123
+ export interface Attachment {
124
+ id: string;
125
+ title: string;
126
+ /** Relative to the PRD's folder, e.g. `mockups/approve-view.png`. */
127
+ path?: string;
128
+ url?: string;
129
+ /** What to take from it, e.g. "Layout only; colours are placeholders". */
130
+ note?: string;
131
+ }
132
+
133
+ /**
134
+ * Something that can go wrong or is easy to get wrong (bad input, partial
135
+ * success, retries, permissions, concurrency, time zones, limits...) and what
136
+ * should happen. An open case is undecided: an agent must ask, not assume.
137
+ */
138
+ export interface EdgeCase {
139
+ id: string;
140
+ case: string;
141
+ /** What should happen. Required once the case is decided. */
142
+ expectedBehavior: string;
143
+ status: 'open' | 'decided';
144
+ /** Stories it applies to; absent means the whole PRD. */
145
+ storyIds?: string[];
146
+ }
147
+
148
+ /**
149
+ * A decision the plan still needs. Written so a person can answer it without
150
+ * the conversation it came from: why it matters, the options and the
151
+ * recommended one. Answering it records a decision and removes it.
152
+ */
153
+ export interface OpenQuestion {
154
+ id: string;
155
+ question: string;
156
+ /** What goes wrong if an agent guesses instead. */
157
+ why?: string;
158
+ options?: string[];
159
+ /** The suggested answer, usually one of the options. */
160
+ recommended?: string;
161
+ /** Stories that cannot be built until it is answered. */
162
+ storyIds?: string[];
163
+ }
164
+
165
+ /** Optional parts of a PRD that can be marked not applicable. */
166
+ export type NotApplicableTopic =
167
+ | 'dataModel'
168
+ | 'outsideServices'
169
+ | 'security'
170
+ | 'design'
171
+ | 'qualityBar'
172
+ | 'edgeCases'
173
+ | 'rollout'
174
+ | 'measurement'
175
+ | 'glossary'
176
+ | 'risks';
177
+
178
+ /** A term the team has agreed on, so people and agents use the same words. */
179
+ export interface GlossaryTerm {
180
+ term: string;
181
+ definition: string;
182
+ /** Synonyms that should not be used for this concept. */
183
+ avoid: string[];
184
+ }
185
+
186
+ export interface RiskItem {
187
+ id: string;
188
+ description: string;
189
+ mitigation: string;
190
+ owner: string;
191
+ severity: 'low' | 'medium' | 'high';
192
+ }
193
+
194
+ export interface CrossDependency {
195
+ id: string;
196
+ name: string;
197
+ description: string;
198
+ blocking: boolean;
199
+ owner?: string;
200
+ }
201
+
202
+ export interface DecisionLogEntry {
203
+ id: string;
204
+ date: string;
205
+ decision: string;
206
+ rationale: string;
207
+ owner?: string;
208
+ status: 'proposed' | 'accepted' | 'superseded';
209
+ /**
210
+ * What the decision is about, e.g. `story:US001:dependencies`. Optional so
211
+ * hand-written decision logs stay valid; deleting a story supersedes the
212
+ * accepted decisions whose topic names it.
213
+ */
214
+ topic?: string;
215
+ }
216
+
217
+ export interface AgentTaskPacket {
218
+ id: string;
219
+ title: string;
220
+ scope: string;
221
+ doneCriteria: string[];
222
+ testPlan: string[];
223
+ likelyFiles: string[];
224
+ linkedStoryIds: string[];
225
+ dependencies: string[];
226
+ }
227
+
228
+ export interface StoryTraceabilityMap {
229
+ storyId: string;
230
+ featureId: string;
231
+ acceptanceCriteriaIds: string[];
232
+ successMetricIds: string[];
233
+ }
234
+
235
+ export interface PrdRoadmap {
236
+ order?: number;
237
+ criticality?: 'critical' | 'high' | 'medium' | 'low';
238
+ plan?: string;
239
+ group?: string;
240
+ section?: string;
241
+ }
242
+
243
+ /**
244
+ * Text fields may use Markdown. Longer text (the overview, problem, solution
245
+ * description, story notes, decision rationale) may use any block Markdown;
246
+ * items of a list (acceptance criteria, non-goals, story log entries...) are
247
+ * rendered as bullets, so they keep to inline Markdown: bold, italics, code
248
+ * and links. Raw HTML is not rendered.
249
+ */
250
+ export interface StructuredPRD {
251
+ roadmap?: PrdRoadmap;
252
+
253
+ introduction: {
254
+ title: string;
255
+ overview: string;
256
+ lastUpdated: string;
257
+ };
258
+
259
+ problemStatement: {
260
+ problem: string;
261
+ marketOpportunity: string;
262
+ targetUsers: string[];
263
+ };
264
+
265
+ solutionOverview: {
266
+ description: string;
267
+ keyFeatures: string[];
268
+ successMetrics: string[];
269
+ };
270
+
271
+ nonGoals: string[];
272
+ outOfScope: string[];
273
+ assumptions: string[];
274
+ openQuestions: OpenQuestion[];
275
+ risks: RiskItem[];
276
+ dependencies: CrossDependency[];
277
+
278
+ userStories: UserStory[];
279
+ customPhases: CustomPhase[];
280
+ storyTraceability: StoryTraceabilityMap[];
281
+
282
+ technicalRequirements: {
283
+ constraints: string[];
284
+ integrationNeeds: string[];
285
+ complianceRequirements: string[];
286
+ };
287
+
288
+ technicalContracts: {
289
+ apis: string[];
290
+ dataModels: string[];
291
+ permissions: string[];
292
+ integrationBoundaries: string[];
293
+ };
294
+
295
+ acceptanceCriteria: {
296
+ global: string[];
297
+ qualityStandards: string[];
298
+ };
299
+
300
+ constraints: {
301
+ timeline: string;
302
+ budget?: string;
303
+ resources: string[];
304
+ nonNegotiables: string[];
305
+ };
306
+
307
+ rolloutPlan: {
308
+ featureFlags: string[];
309
+ migrationPlan: string[];
310
+ rolloutPhases: string[];
311
+ rollbackConditions: string[];
312
+ };
313
+
314
+ measurementPlan: {
315
+ events: string[];
316
+ dashboards: string[];
317
+ baselineMetrics: string[];
318
+ targetMetrics: string[];
319
+ guardrailMetrics: string[];
320
+ };
321
+
322
+ /** Things that can go wrong and what should happen. */
323
+ edgeCases: EdgeCase[];
324
+ /**
325
+ * Standing design rules for every story (components to use, tone, layout,
326
+ * empty and error states...). Individual design choices are decisions with a
327
+ * `design:` topic in the decision log.
328
+ */
329
+ designGuidance: string[];
330
+ /**
331
+ * Standing security rules for every story: input validation, secrets,
332
+ * rate limits, tenant isolation... Who can do what is in
333
+ * technicalContracts.permissions; sensitive data and compliance in
334
+ * technicalRequirements.complianceRequirements.
335
+ */
336
+ securityConsiderations: string[];
337
+ /**
338
+ * Parts that do not apply to this PRD, with the reason. The plan check does
339
+ * not ask for them and agents should not invent them.
340
+ */
341
+ notApplicable: Partial<Record<NotApplicableTopic, string>>;
342
+
343
+ decisionLog: DecisionLogEntry[];
344
+ glossary: GlossaryTerm[];
345
+ attachments: Attachment[];
346
+ agentTaskPackets: AgentTaskPacket[];
347
+ changeLog: string[];
348
+
349
+ metadata: {
350
+ version: string;
351
+ created: string;
352
+ lastUpdated: string;
353
+ lastValidatedAt: string;
354
+ approver: string;
355
+ /**
356
+ * High-water mark for story numbering. Story ids are quoted in commits and
357
+ * conversations, so a deleted id must never be handed to a different
358
+ * story: `max(existing) + 1` would recycle US002 as soon as US002 (the
359
+ * highest) was deleted. Absent on PRDs written before this existed, which
360
+ * fall back to the highest id present.
361
+ */
362
+ lastStoryNumber?: number;
363
+ /** High-water mark for attachment ids, for the same reason. */
364
+ lastAttachmentNumber?: number;
365
+ /** High-water mark for open question ids, for the same reason. */
366
+ lastQuestionNumber?: number;
367
+ /**
368
+ * Incremented on every save. A write whose PRD was read at an older
369
+ * revision is rejected, so two writers (an agent and the Board) cannot
370
+ * silently overwrite each other. Absent on files written before it existed.
371
+ */
372
+ revision?: number;
373
+ };
374
+
375
+ progress: {
376
+ overall: number;
377
+ completed: number;
378
+ total: number;
379
+ blocked: number;
380
+ };
381
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "strict": true,
5
+ "noImplicitOverride": true,
6
+ "noImplicitReturns": true,
7
+ "noFallthroughCasesInSwitch": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "target": "es2022",
10
+ "lib": ["es2022"],
11
+ "types": ["node"]
12
+ },
13
+ "files": [],
14
+ "include": [],
15
+ "references": [
16
+ {
17
+ "path": "./tsconfig.lib.json"
18
+ },
19
+ {
20
+ "path": "./tsconfig.spec.json"
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "declaration": true
5
+ },
6
+ "include": ["src/**/*.ts"],
7
+ "exclude": ["src/**/__tests__/**", "src/testing/**"]
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["node", "vitest/globals"]
5
+ },
6
+ "include": ["src/**/*.ts", "vitest.config.mts"]
7
+ }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'tsdown';
2
+
3
+ import { libraryConfig } from '../../tsdown.base.mts';
4
+
5
+ export default defineConfig(
6
+ libraryConfig({
7
+ index: 'src/index.ts',
8
+ operations: 'src/prd-operations.ts',
9
+ node: 'src/node.ts',
10
+ mcp: 'src/mcp/index.ts',
11
+ }),
12
+ );
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ include: ['src/**/*.test.ts'],
7
+ },
8
+ });