@makerkit/prd 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +64 -2
- package/index.d.ts +227 -0
- package/index.js +1897 -0
- package/index.mjs +1791 -0
- package/mcp.d.ts +9 -0
- package/mcp.js +532 -0
- package/mcp.mjs +531 -0
- package/node.d.ts +19 -0
- package/node.js +94 -0
- package/node.mjs +92 -0
- package/package.json +47 -4
- package/prd.service-DSBp8sMl.d.ts +2327 -0
- package/prompts-Bber0S1Z.mjs +778 -0
- package/prompts-CIX8IeAx.js +1233 -0
package/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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makerkit/prd",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
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.1",
|
|
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
|
+
}
|