@makerkit/prd 0.0.0-stage → 0.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 (54) hide show
  1. package/.turbo/turbo-build.log +46 -0
  2. package/.turbo/turbo-test.log +21 -0
  3. package/.turbo/turbo-typecheck.log +1 -0
  4. package/README.md +64 -2
  5. package/dist/LICENSE +21 -0
  6. package/dist/README.md +65 -0
  7. package/dist/index.d.ts +227 -0
  8. package/dist/index.js +1897 -0
  9. package/dist/index.mjs +1791 -0
  10. package/dist/mcp.d.ts +9 -0
  11. package/dist/mcp.js +532 -0
  12. package/dist/mcp.mjs +531 -0
  13. package/dist/node.d.ts +19 -0
  14. package/dist/node.js +94 -0
  15. package/dist/node.mjs +92 -0
  16. package/dist/package.json +49 -0
  17. package/dist/prd.service-DSBp8sMl.d.ts +2327 -0
  18. package/dist/prompts-Bber0S1Z.mjs +778 -0
  19. package/dist/prompts-CIX8IeAx.js +1233 -0
  20. package/package.json +66 -4
  21. package/src/__tests__/agent-workflow.test.ts +377 -0
  22. package/src/__tests__/attachments.test.ts +475 -0
  23. package/src/__tests__/node.test.ts +141 -0
  24. package/src/__tests__/plan-check.test.ts +229 -0
  25. package/src/__tests__/planning.test.ts +1059 -0
  26. package/src/__tests__/prd-operations.test.ts +423 -0
  27. package/src/__tests__/prd.service.test.ts +477 -0
  28. package/src/__tests__/prd.tool.test.ts +282 -0
  29. package/src/__tests__/templates.test.ts +141 -0
  30. package/src/applicability.ts +73 -0
  31. package/src/attachment-paths.ts +78 -0
  32. package/src/attachments.ts +160 -0
  33. package/src/edge-cases.ts +52 -0
  34. package/src/index.ts +35 -0
  35. package/src/markdown.ts +268 -0
  36. package/src/mcp/index.ts +839 -0
  37. package/src/mcp/tool-response.ts +85 -0
  38. package/src/node.ts +146 -0
  39. package/src/open-questions.ts +93 -0
  40. package/src/plan-check.ts +282 -0
  41. package/src/planning-operations.ts +429 -0
  42. package/src/prd-operations.ts +690 -0
  43. package/src/prd.service.ts +1051 -0
  44. package/src/prompts.ts +110 -0
  45. package/src/safe-file-name.ts +42 -0
  46. package/src/schema.ts +976 -0
  47. package/src/templates.ts +173 -0
  48. package/src/testing/fake-mcp-server.ts +81 -0
  49. package/src/types.ts +333 -0
  50. package/tsconfig.json +23 -0
  51. package/tsconfig.lib.json +8 -0
  52. package/tsconfig.spec.json +7 -0
  53. package/tsdown.config.mts +11 -0
  54. package/vitest.config.mts +8 -0
package/dist/node.mjs ADDED
@@ -0,0 +1,92 @@
1
+ import { join } from "node:path";
2
+ import { createRepoChecksServices } from "@makerkit/repo-checks/node";
3
+ import { access, mkdir, readFile, readdir, unlink, writeFile } from "node:fs/promises";
4
+ //#region src/node.ts
5
+ /** Check-only scripts that gate marking a story as completed. */
6
+ const DEFAULT_COMPLETION_CHECKS = ["typecheck", "lint"];
7
+ /** PRD dependencies backed by the local filesystem, rooted at `rootPath`. */
8
+ function createNodePrdDeps(rootPath = process.cwd(), options = {}) {
9
+ return {
10
+ rootPath,
11
+ readdir(path) {
12
+ return readdir(path);
13
+ },
14
+ readFile(path) {
15
+ return readFile(path, "utf8");
16
+ },
17
+ writeFile(path, content) {
18
+ return writeFile(path, content, "utf8");
19
+ },
20
+ async mkdir(path) {
21
+ await mkdir(path, { recursive: true });
22
+ },
23
+ unlink(path) {
24
+ return unlink(path);
25
+ },
26
+ fileExists,
27
+ now() {
28
+ return /* @__PURE__ */ new Date();
29
+ },
30
+ verifyCompletion: options.verifyCompletion ?? createScriptVerifier(rootPath)
31
+ };
32
+ }
33
+ /**
34
+ * Verifies completion by running the project's package.json scripts with its
35
+ * package manager (via @makerkit/repo-checks), so a failure comes back as
36
+ * file-and-line diagnostics. Scripts the project does not define are skipped,
37
+ * so a repo without e.g. `lint` can still complete stories.
38
+ */
39
+ function createScriptVerifier(rootPath, scripts = DEFAULT_COMPLETION_CHECKS) {
40
+ return async () => {
41
+ if (!await fileExists(join(rootPath, "package.json"))) return {
42
+ passed: true,
43
+ checks: [],
44
+ errors: 0,
45
+ warnings: 0,
46
+ diagnostics: [],
47
+ messages: ["No package.json: there are no project checks to run."]
48
+ };
49
+ const checks = createRepoChecksServices(rootPath);
50
+ const { scripts: available } = await checks.scripts.list();
51
+ const defined = new Set(available.map((script) => script.name));
52
+ const toRun = scripts.filter((script) => defined.has(script));
53
+ const messages = scripts.filter((script) => !defined.has(script)).map((script) => `${script}: skipped (no "${script}" script in package.json)`);
54
+ if (toRun.length === 0) return {
55
+ passed: true,
56
+ checks: [],
57
+ errors: 0,
58
+ warnings: 0,
59
+ diagnostics: [],
60
+ messages
61
+ };
62
+ const result = await checks.runChecks.run({ scripts: toRun });
63
+ const unexplained = result.checks.filter((check) => check.status !== "pass" && check.diagnostics.length === 0);
64
+ for (const check of unexplained) {
65
+ const detail = (check.stderr.trim() || check.stdout.trim()).slice(-300);
66
+ messages.push(`${check.script}: ${check.status}${detail ? ` (${detail})` : ""}`);
67
+ }
68
+ return {
69
+ passed: result.overall === "pass",
70
+ checks: result.scripts_requested,
71
+ errors: result.summary.errors + unexplained.length,
72
+ warnings: result.summary.warnings,
73
+ diagnostics: result.diagnostics.map((diagnostic) => ({
74
+ file: diagnostic.file,
75
+ line: diagnostic.line,
76
+ message: diagnostic.message,
77
+ severity: diagnostic.severity
78
+ })),
79
+ messages
80
+ };
81
+ };
82
+ }
83
+ async function fileExists(path) {
84
+ try {
85
+ await access(path);
86
+ return true;
87
+ } catch {
88
+ return false;
89
+ }
90
+ }
91
+ //#endregion
92
+ export { createNodePrdDeps, createScriptVerifier };
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@makerkit/prd",
3
+ "version": "0.0.0",
4
+ "description": "Structured PRDs as JSON files: the format, a service to manage them, and MCP tools so coding agents can read and update them.",
5
+ "keywords": [
6
+ "ai-agents",
7
+ "claude-code",
8
+ "codex",
9
+ "mcp",
10
+ "prd",
11
+ "product-requirements"
12
+ ],
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/makerkit/makerkit",
17
+ "directory": "packages/prd"
18
+ },
19
+ "main": "./index.js",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "import": "./index.mjs",
24
+ "require": "./index.js"
25
+ },
26
+ "./node": {
27
+ "types": "./node.d.ts",
28
+ "import": "./node.mjs",
29
+ "require": "./node.js"
30
+ },
31
+ "./mcp": {
32
+ "types": "./mcp.d.ts",
33
+ "import": "./mcp.mjs",
34
+ "require": "./mcp.js"
35
+ }
36
+ },
37
+ "dependencies": {
38
+ "@makerkit/repo-checks": "^0.0.0",
39
+ "zod": "^3.25.0 || ^4.0.0"
40
+ },
41
+ "peerDependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.32.0"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "@modelcontextprotocol/sdk": {
46
+ "optional": true
47
+ }
48
+ }
49
+ }