docs.test.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import assert from "node:assert/strict";
  2. import test from "node:test";
  3. import { readFile } from "node:fs/promises";
  4. import { TOOL_DEFINITIONS } from "../src/mcp-server.js";
  5. test("README commands match package scripts and the executable MCP schemas", async () => {
  6. const [readme, packageText, gitVerifier] = await Promise.all([
  7. readFile(new URL("../../README.md", import.meta.url), "utf8"),
  8. readFile(new URL("../../package.json", import.meta.url), "utf8"),
  9. readFile(new URL("../../scripts/verify-git-package.mjs", import.meta.url), "utf8"),
  10. ]);
  11. const packageJson = JSON.parse(packageText) as {
  12. bin: Record<string, string>;
  13. files: string[];
  14. scripts: Record<string, string>;
  15. };
  16. for (const script of [
  17. "typecheck",
  18. "compile",
  19. "test",
  20. "start",
  21. "smoke",
  22. "verify:runtime",
  23. "verify:git-package",
  24. "verify:package",
  25. "pack:verified",
  26. ]) {
  27. assert.equal(typeof packageJson.scripts[script], "string");
  28. assert.equal(
  29. readme.includes(`npm run ${script}`)
  30. || (script === "start" && readme.includes("npm start"))
  31. || (script === "test" && readme.includes("npm test")),
  32. true,
  33. );
  34. }
  35. assert.equal(packageJson.bin["codex-chief-of-staff"], "dist/src/index.js");
  36. assert.deepEqual(packageJson.files, ["dist/src", "README.md"]);
  37. for (const tool of TOOL_DEFINITIONS) {
  38. assert.equal(readme.includes(`\`${tool.name}(`), true, `README is missing ${tool.name}`);
  39. }
  40. assert.match(readme, /codex mcp add codex-chief-of-staff/);
  41. assert.match(readme, /codex mcp remove codex-chief-of-staff/);
  42. assert.match(readme, /npm install --global/);
  43. assert.doesNotMatch(readme, /npm run build|prepack/);
  44. assert.match(readme, /git\+https:\/\/git\.bodicsek\.host\/bodicsek\/codex-chief-of-staff\.git#v0\.1\.1/);
  45. assert.match(readme, /full 40-character commit/i);
  46. assert.match(readme, /Do not use `#main`/);
  47. assert.match(readme, /end-user install intentionally omits `--prefix`/);
  48. assert.match(readme, /Restart Codex CLI after installation/);
  49. assert.match(readme, /0\.1\.0\.tgz/);
  50. assert.match(readme, /npm uninstall --global codex-chief-of-staff/);
  51. assert.match(readme, /command -v codex-chief-of-staff/);
  52. assert.match(readme, /-- codex-chief-of-staff/);
  53. for (const argument of ["--global", "--prefix", "--ignore-scripts", "--cache"]) {
  54. assert.equal(gitVerifier.includes(`"${argument}"`), true, `Git verifier is missing ${argument}`);
  55. }
  56. });