docspec 0.2.0 → 0.4.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 (80) hide show
  1. package/README.md +64 -142
  2. package/dist/__tests__/changed.test.d.ts +2 -0
  3. package/dist/__tests__/changed.test.d.ts.map +1 -0
  4. package/dist/__tests__/changed.test.js +98 -0
  5. package/dist/__tests__/changed.test.js.map +1 -0
  6. package/dist/__tests__/cli.test.js +48 -145
  7. package/dist/__tests__/cli.test.js.map +1 -1
  8. package/dist/__tests__/create.test.d.ts +2 -0
  9. package/dist/__tests__/create.test.d.ts.map +1 -0
  10. package/dist/__tests__/{generator.test.js → create.test.js} +31 -27
  11. package/dist/__tests__/create.test.js.map +1 -0
  12. package/dist/__tests__/generate.test.d.ts +2 -0
  13. package/dist/__tests__/generate.test.d.ts.map +1 -0
  14. package/dist/__tests__/generate.test.js +152 -0
  15. package/dist/__tests__/generate.test.js.map +1 -0
  16. package/dist/__tests__/path-utils.test.d.ts +2 -0
  17. package/dist/__tests__/path-utils.test.d.ts.map +1 -0
  18. package/dist/__tests__/path-utils.test.js +49 -0
  19. package/dist/__tests__/path-utils.test.js.map +1 -0
  20. package/dist/__tests__/template.test.d.ts +2 -0
  21. package/dist/__tests__/template.test.d.ts.map +1 -0
  22. package/dist/__tests__/template.test.js +95 -0
  23. package/dist/__tests__/template.test.js.map +1 -0
  24. package/dist/changed.d.ts +25 -0
  25. package/dist/changed.d.ts.map +1 -0
  26. package/dist/changed.js +209 -0
  27. package/dist/changed.js.map +1 -0
  28. package/dist/cli.js +89 -72
  29. package/dist/cli.js.map +1 -1
  30. package/dist/constants.d.ts +2 -0
  31. package/dist/constants.d.ts.map +1 -1
  32. package/dist/constants.js +118 -15
  33. package/dist/constants.js.map +1 -1
  34. package/dist/create.d.ts +14 -0
  35. package/dist/create.d.ts.map +1 -0
  36. package/dist/create.js +97 -0
  37. package/dist/create.js.map +1 -0
  38. package/dist/generate.d.ts +26 -0
  39. package/dist/generate.d.ts.map +1 -0
  40. package/dist/generate.js +176 -0
  41. package/dist/generate.js.map +1 -0
  42. package/dist/index.d.ts +8 -4
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +16 -7
  45. package/dist/index.js.map +1 -1
  46. package/dist/logger.d.ts +40 -0
  47. package/dist/logger.d.ts.map +1 -0
  48. package/dist/logger.js +74 -0
  49. package/dist/logger.js.map +1 -0
  50. package/dist/path-utils.d.ts +17 -0
  51. package/dist/path-utils.d.ts.map +1 -0
  52. package/dist/path-utils.js +76 -0
  53. package/dist/path-utils.js.map +1 -0
  54. package/dist/{format-parser.d.ts → template.d.ts} +5 -8
  55. package/dist/template.d.ts.map +1 -0
  56. package/dist/{format-parser.js → template.js} +33 -57
  57. package/dist/template.js.map +1 -0
  58. package/package.json +1 -1
  59. package/README.docspec.md +0 -180
  60. package/dist/__tests__/generator.test.d.ts +0 -2
  61. package/dist/__tests__/generator.test.d.ts.map +0 -1
  62. package/dist/__tests__/generator.test.js.map +0 -1
  63. package/dist/__tests__/validator.test.d.ts +0 -2
  64. package/dist/__tests__/validator.test.d.ts.map +0 -1
  65. package/dist/__tests__/validator.test.js +0 -331
  66. package/dist/__tests__/validator.test.js.map +0 -1
  67. package/dist/format-parser.d.ts.map +0 -1
  68. package/dist/format-parser.js.map +0 -1
  69. package/dist/generator.d.ts +0 -11
  70. package/dist/generator.d.ts.map +0 -1
  71. package/dist/generator.js +0 -66
  72. package/dist/generator.js.map +0 -1
  73. package/dist/types.d.ts +0 -16
  74. package/dist/types.d.ts.map +0 -1
  75. package/dist/types.js +0 -3
  76. package/dist/types.js.map +0 -1
  77. package/dist/validator.d.ts +0 -7
  78. package/dist/validator.d.ts.map +0 -1
  79. package/dist/validator.js +0 -178
  80. package/dist/validator.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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,mCAAmC;IACxD,CAAC;IACD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,QAAgB;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChE,OAAO,CACL,UAAU,CAAC,UAAU,CAAC,WAAW,GAAG,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAC7E,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- export interface ParsedSection {
1
+ interface ParsedSection {
2
2
  name: string;
3
3
  boilerplate: string;
4
4
  number: number;
@@ -9,15 +9,12 @@ export interface ParsedFormat {
9
9
  agentInstructions?: string;
10
10
  }
11
11
  /**
12
- * Parse the docspec format file
12
+ * Parse the docspec template file (.docspec/docspec.md) into structure and sections.
13
13
  */
14
14
  export declare function parseFormatFile(formatFilePath: string): ParsedFormat;
15
15
  /**
16
- * Parse format content from a string
17
- */
18
- export declare function parseFormatContent(content: string): ParsedFormat;
19
- /**
20
- * Get the path to the format file
16
+ * Path to the template file (.docspec/docspec.md). Seeds from bundled default if missing.
21
17
  */
22
18
  export declare function getFormatFilePath(): string;
23
- //# sourceMappingURL=format-parser.d.ts.map
19
+ export {};
20
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,CAGpE;AA4GD;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAK1C"}
@@ -34,20 +34,16 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.parseFormatFile = parseFormatFile;
37
- exports.parseFormatContent = parseFormatContent;
38
37
  exports.getFormatFilePath = getFormatFilePath;
39
38
  const fs = __importStar(require("fs"));
40
39
  const path = __importStar(require("path"));
41
40
  /**
42
- * Parse the docspec format file
41
+ * Parse the docspec template file (.docspec/docspec.md) into structure and sections.
43
42
  */
44
43
  function parseFormatFile(formatFilePath) {
45
44
  const content = fs.readFileSync(formatFilePath, "utf-8");
46
45
  return parseFormatContent(content);
47
46
  }
48
- /**
49
- * Parse format content from a string
50
- */
51
47
  function parseFormatContent(content) {
52
48
  const lines = content.split("\n");
53
49
  // Look for AGENT INSTRUCTIONS section first
@@ -60,42 +56,32 @@ function parseFormatContent(content) {
60
56
  break;
61
57
  }
62
58
  }
63
- // If AGENT INSTRUCTIONS section found, extract it
64
59
  if (agentInstructionsStart >= 0) {
65
- // Find the end of the AGENT INSTRUCTIONS section
66
- // It ends at the next section header (##) or end of file
67
60
  for (let i = agentInstructionsStart + 1; i < lines.length; i++) {
68
61
  const trimmedLine = lines[i].trim();
69
- // Check if this is a section header (starts with ##)
70
62
  if (trimmedLine.match(/^##\s+/)) {
71
63
  agentInstructionsEnd = i;
72
64
  break;
73
65
  }
74
66
  }
75
- if (agentInstructionsEnd < 0) {
67
+ if (agentInstructionsEnd < 0)
76
68
  agentInstructionsEnd = lines.length;
77
- }
78
- // Extract content between header and next section
79
69
  const agentLines = lines.slice(agentInstructionsStart + 1, agentInstructionsEnd);
80
70
  let agentContent = agentLines.join("\n");
81
- // Remove separator lines (---) from the content
82
71
  agentContent = agentContent
83
72
  .split("\n")
84
- .filter(line => line.trim() !== "---")
73
+ .filter((line) => line.trim() !== "---")
85
74
  .join("\n")
86
75
  .trim();
87
- if (agentContent) {
76
+ if (agentContent)
88
77
  agentInstructions = agentContent;
89
- }
90
78
  }
91
79
  // Find all section headers: ## N. Section Name
92
80
  const sectionHeaderRegex = /^##\s+(\d+)\.\s+(.+)$/;
93
81
  const sectionHeaders = [];
94
82
  for (let i = 0; i < lines.length; i++) {
95
- // Skip the AGENT INSTRUCTIONS header if it exists
96
- if (lines[i].trim() === "## AGENT INSTRUCTIONS") {
83
+ if (lines[i].trim() === "## AGENT INSTRUCTIONS")
97
84
  continue;
98
- }
99
85
  const match = lines[i].match(sectionHeaderRegex);
100
86
  if (match) {
101
87
  sectionHeaders.push({
@@ -106,36 +92,22 @@ function parseFormatContent(content) {
106
92
  }
107
93
  }
108
94
  if (sectionHeaders.length === 0) {
109
- throw new Error("No section headers found in format file. Expected format: ## N. Section Name");
95
+ throw new Error("No section headers found in template. Expected format: ## N. Section Name");
110
96
  }
111
- // Extract template: everything before the first numbered section header
112
- // But exclude the AGENT INSTRUCTIONS section if it exists
113
97
  const firstSectionLine = sectionHeaders[0].lineIndex;
114
- let templateBeforeSections;
115
- if (agentInstructionsStart >= 0 && agentInstructionsStart < firstSectionLine) {
116
- // AGENT INSTRUCTIONS is between title and first section
117
- // Template is everything before AGENT INSTRUCTIONS
118
- templateBeforeSections = lines.slice(0, agentInstructionsStart).join("\n").trim();
119
- }
120
- else {
121
- // No AGENT INSTRUCTIONS, use everything before first section
122
- templateBeforeSections = lines.slice(0, firstSectionLine).join("\n").trim();
123
- }
98
+ const templateBeforeSections = agentInstructionsStart >= 0 && agentInstructionsStart < firstSectionLine
99
+ ? lines.slice(0, agentInstructionsStart).join("\n").trim()
100
+ : lines.slice(0, firstSectionLine).join("\n").trim();
124
101
  const template = templateBeforeSections + "\n\n{{AGENT_INSTRUCTIONS}}\n\n{{SECTIONS}}\n";
125
- // Extract sections
126
102
  const sections = [];
127
103
  for (let i = 0; i < sectionHeaders.length; i++) {
128
104
  const header = sectionHeaders[i];
129
- const nextHeaderLine = i < sectionHeaders.length - 1
130
- ? sectionHeaders[i + 1].lineIndex
131
- : lines.length;
132
- // Extract content between this header and the next header
105
+ const nextHeaderLine = i < sectionHeaders.length - 1 ? sectionHeaders[i + 1].lineIndex : lines.length;
133
106
  const sectionLines = lines.slice(header.lineIndex + 1, nextHeaderLine);
134
107
  let sectionContent = sectionLines.join("\n");
135
- // Remove separator lines (---) from the content
136
108
  sectionContent = sectionContent
137
109
  .split("\n")
138
- .filter(line => line.trim() !== "---")
110
+ .filter((line) => line.trim() !== "---")
139
111
  .join("\n")
140
112
  .trim();
141
113
  sections.push({
@@ -144,7 +116,6 @@ function parseFormatContent(content) {
144
116
  number: header.number,
145
117
  });
146
118
  }
147
- // Sort sections by number to ensure correct order
148
119
  sections.sort((a, b) => a.number - b.number);
149
120
  return {
150
121
  sections,
@@ -153,23 +124,28 @@ function parseFormatContent(content) {
153
124
  };
154
125
  }
155
126
  /**
156
- * Get the path to the format file
127
+ * Seed .docspec/docspec.md from the bundled docspec-format.md if it doesn't exist.
157
128
  */
158
- function getFormatFilePath() {
159
- // In development: use src/docspec-format.md
160
- // In built package: use dist/docspec-format.md or root docspec-format.md
161
- // Try multiple locations
162
- const possiblePaths = [
163
- path.join(__dirname, "..", "docspec-format.md"), // Root of project
164
- path.join(__dirname, "docspec-format.md"), // In dist/ if copied there
165
- path.join(process.cwd(), "docspec-format.md"), // Current working directory
166
- ];
167
- for (const formatPath of possiblePaths) {
168
- if (fs.existsSync(formatPath)) {
169
- return formatPath;
170
- }
129
+ function seedDefaultFormatFile() {
130
+ const cwd = process.cwd();
131
+ const userPath = path.join(cwd, ".docspec", "docspec.md");
132
+ const defaultPath = path.join(__dirname, "..", "docspec-format.md");
133
+ if (!fs.existsSync(defaultPath)) {
134
+ throw new Error(`Default template not found at ${defaultPath}. ` +
135
+ `Create .docspec/docspec.md in your project or ensure the docspec package is installed correctly.`);
171
136
  }
172
- // Default to root if none found (will throw error if file doesn't exist)
173
- return possiblePaths[0];
137
+ fs.mkdirSync(path.join(cwd, ".docspec"), { recursive: true });
138
+ fs.copyFileSync(defaultPath, userPath);
139
+ return userPath;
140
+ }
141
+ /**
142
+ * Path to the template file (.docspec/docspec.md). Seeds from bundled default if missing.
143
+ */
144
+ function getFormatFilePath() {
145
+ const cwd = process.cwd();
146
+ const userPath = path.join(cwd, ".docspec", "docspec.md");
147
+ if (fs.existsSync(userPath))
148
+ return userPath;
149
+ return seedDefaultFormatFile();
174
150
  }
175
- //# sourceMappingURL=format-parser.js.map
151
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,0CAGC;AA+GD,8CAKC;AAzID,uCAAyB;AACzB,2CAA6B;AAc7B;;GAEG;AACH,SAAgB,eAAe,CAAC,cAAsB;IACpD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACzD,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe;IACzC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElC,4CAA4C;IAC5C,IAAI,iBAAqC,CAAC;IAC1C,IAAI,sBAAsB,GAAG,CAAC,CAAC,CAAC;IAChC,IAAI,oBAAoB,GAAG,CAAC,CAAC,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,uBAAuB,EAAE,CAAC;YAChD,sBAAsB,GAAG,CAAC,CAAC;YAC3B,MA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EAAE,CAAC,CAAC;IAC9D,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACvC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC1D,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC7C,OAAO,qBAAqB,EAAE,CAAC;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docspec",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Docspec is a specification format and toolchain for documentation that is maintained by agents.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/README.docspec.md DELETED
@@ -1,180 +0,0 @@
1
- # DOCSPEC: [README.md](/README.md)
2
-
3
- > A specification that defines how the target document should be maintained by agents.
4
-
5
- ## AGENT INSTRUCTIONS
6
-
7
- **Target document:** `README.md`
8
-
9
- **Your task:**
10
-
11
- * Compare the target document against this docspec.
12
- * Update the target document to satisfy this docspec.
13
- * Make the smallest changes necessary.
14
- * Preserve existing content that already complies.
15
- * Do not invent content, sections, or facts not implied by this docspec or the repository.
16
-
17
-
18
-
19
- ## 1. Document Purpose
20
-
21
- This README serves as the primary entry point and comprehensive documentation for the docspec project. It is a technical project overview that must answer:
22
-
23
- - **What is docspec?** - A specification format and toolchain for agent-maintained documentation
24
- - **How do I install it?** - npm installation methods (local and global)
25
- - **How do I use it?** - CLI commands (`validate`, `generate`) and TypeScript API usage
26
- - **How do I integrate it?** - Pre-commit hooks, GitHub Actions (post-merge sync, manual audit)
27
- - **What is the docspec format?** - High-level overview and reference to docspec-format.md
28
- - **How do I develop with it?** - Test and build commands
29
-
30
- **Target audiences:**
31
- - End-users using the CLI for validation and generation
32
- - Library consumers using the TypeScript API in their projects
33
- - GitHub Actions users integrating automated documentation workflows
34
- - CI/CD integrators adding docspec validation to their pipelines
35
- - Contributors developing and testing the project
36
-
37
- **Document type:** Technical project documentation (README/overview)
38
-
39
- ## 2. Update Triggers
40
-
41
- **Changes that SHOULD trigger updates:**
42
-
43
- - **CLI changes** (src/cli.ts): New commands, modified command arguments, changed command behavior
44
- - **Validation logic** (src/validator.ts): New validation rules, changed error messages, modified validation behavior
45
- - **Docspec format definition** (docspec-format.md): Changes to required sections, section names, validation rules
46
- - **GitHub Action configuration** (action.yml): New inputs/outputs, changed defaults, modified descriptions
47
- - **Workflow files** (.github/workflows/docspec-check.yml, docspec-generate.yml): Workflow name changes, trigger changes, new steps or configuration
48
- - **Installation method** (package.json): Package name changes, new installation requirements
49
- - **File naming convention**: Changes to how .docspec.md maps to .md files
50
- - **Required sections** (src/constants.ts): Changes to REQUIRED_SECTIONS array or section definitions
51
- - **Pre-commit hook configuration** (.pre-commit-config.yaml): Changes to hook setup or usage
52
- - **Library API exports** (src/index.ts): New exported functions, types, or constants; removed exports; changed function signatures
53
-
54
- **Changes that SHOULD NOT trigger updates:**
55
-
56
- - Internal implementation details that don't affect public APIs (validator internals, generator internals, format-parser internals)
57
- - Test file changes (src/__tests__/*) unless they reveal new documented behavior
58
- - Build system changes (tsconfig.json, package build scripts) that don't affect installation or usage
59
- - Python script implementation details (docspec_update.py, improve_docspec.py) - these are internal to GitHub Actions
60
- - Dependency version updates that don't change user-facing functionality
61
- - Code refactoring that preserves the same external behavior
62
-
63
- ## 3. Expected Structure
64
-
65
- The README must contain these sections in order:
66
-
67
- 1. **Title and Description**: Package name (`# docspec`) and one-sentence description of what docspec is
68
-
69
- 2. **The Docspec Format**: High-level overview of the format
70
- - Link to docspec-format.md as the definitive format specification
71
- - List the 5 required sections by name
72
- - Explain validation requirements (non-boilerplate content, 50-character minimum)
73
- - Constraint: Do NOT duplicate the full format specification; link to docspec-format.md instead
74
-
75
- 3. **Installation**: npm installation instructions
76
- - Local installation (`npm install docspec`)
77
- - Global installation (`npm install -g docspec`)
78
- - Constraint: Keep concise, no version-specific details
79
-
80
- 4. **Usage**: How to use docspec with subsections:
81
- - **CLI Commands**: Document `validate` and `generate` commands with examples matching src/cli.ts exactly
82
- - **Library Usage**: TypeScript import examples showing exported functions and types from src/index.ts
83
- - Constraint: Code examples must be actual working commands from the codebase
84
-
85
- 5. **Pre-commit Integration**: How to use with pre-commit hooks
86
- - Reference .pre-commit-config.yaml
87
- - Installation command (`pre-commit install`)
88
- - Brief explanation of how validation works
89
- - Constraint: High-level only, link to actual config file
90
-
91
- 6. **GitHub Action Integration**: How to use the GitHub Actions
92
- - Overview of the two workflows (post-merge sync, manual audit)
93
- - **Post-Merge Documentation Updates** subsection:
94
- - Setup instructions (add workflow, configure secrets)
95
- - How it works (discovery strategy, Claude Code CLI invocation, PR creation)
96
- - File naming convention (filename.docspec.md → filename.md)
97
- - Configuration options (reference action.yml inputs)
98
- - Safety features (list specific guardrails)
99
- - **Manual Docspec Audit** subsection:
100
- - What it's for (audit, discover gaps, regenerate)
101
- - How it works (two-phase approach: discovery and implementation)
102
- - Usage instructions (how to trigger workflow)
103
- - Constraint: Link to actual workflow files instead of duplicating YAML; configuration options must match action.yml exactly
104
-
105
- 7. **Development**: Commands for contributors
106
- - Running tests (`npm test`, `npm run test:watch`)
107
- - Building (`npm run build`)
108
- - Constraint: Keep minimal, only essential commands
109
-
110
- 8. **License**: License type (MIT)
111
-
112
- ## 4. Editing Guidelines
113
-
114
- **Tone and audience:**
115
- - Use technical but accessible language
116
- - Target developers familiar with Node.js/npm, GitHub Actions, and CI/CD concepts
117
- - Be concise and direct; avoid marketing language
118
-
119
- **Code examples and accuracy:**
120
- - CLI command documentation must match src/cli.ts exactly
121
- - Library API examples must only show functions/types exported from src/index.ts
122
- - Action inputs/outputs must match action.yml exactly
123
- - File paths in examples must use the actual naming convention (.docspec.md → .md)
124
- - Workflow references should use actual file names (.github/workflows/docspec-check.yml, docspec-generate.yml)
125
-
126
- **Level of detail:**
127
- - Keep workflow configuration sections high-level; link to actual YAML files instead of duplicating content
128
- - Reference the 5 required sections by name when describing validation
129
- - Link to docspec-format.md for the full format specification; don't duplicate it in the README
130
- - Safety features should list specific guardrails without implementation details
131
- - Pre-commit integration should be high-level; link to .pre-commit-config.yaml
132
-
133
- **DO:**
134
- - Use actual command examples that work: `docspec validate`, `docspec generate path/to/README.docspec.md`
135
- - Reference source files when describing behavior: "matches src/cli.ts", "exported from src/index.ts"
136
- - Link to definitive sources: action.yml for configuration options, docspec-format.md for format details
137
- - Mention that docspec-format.md is included in the published package
138
- - Note that validation handles permission errors gracefully
139
-
140
- **DON'T:**
141
- - Invent CLI flags or options that don't exist in src/cli.ts
142
- - Document internal APIs not exported from src/index.ts
143
- - Include version-specific information (except referencing package.json)
144
- - Repeat YAML workflow content verbatim; link to files instead
145
- - Duplicate the docspec format specification from docspec-format.md
146
- - Add exhaustive lists of every possible feature or edge case
147
-
148
- ## 5. Intentional Omissions
149
-
150
- This README deliberately excludes:
151
-
152
- **Internal implementation details:**
153
- - TypeScript implementation internals (src/validator.ts, src/generator.ts, src/format-parser.ts, src/constants.ts)
154
- - Validation algorithm implementation details
155
- - Template rendering and substitution logic
156
- - How the format file is parsed and cached
157
-
158
- **GitHub Action internals:**
159
- - Python script implementation (docspec_update.py, improve_docspec.py) - these are internal automation scripts
160
- - Claude Code CLI prompt templates (.github/actions/*/templates/*.md)
161
- - Action step-by-step implementation details
162
- - How unified diff patches are generated and applied
163
-
164
- **Development and build details:**
165
- - Test implementation and test file structure (src/__tests__/)
166
- - Build configuration (tsconfig.json, build scripts)
167
- - Package.json configuration details beyond installation
168
- - Pre-commit hook internal implementation
169
-
170
- **Docspec format specification:**
171
- - The detailed format specification lives in docspec-format.md
172
- - Section definitions, boilerplate text, validation rules are defined there
173
- - The README provides only a high-level overview and links to the format file
174
-
175
- **Where to find this information:**
176
- - Format specification: docspec-format.md
177
- - API implementation: src/ directory TypeScript files
178
- - GitHub Action implementation: .github/actions/ directory
179
- - Tests: src/__tests__/ directory
180
- - Build configuration: tsconfig.json, package.json
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=generator.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/generator.test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.test.js","sourceRoot":"","sources":["../../src/__tests__/generator.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAC7B,uCAAyB;AACzB,4CAAuE;AACvE,4CAAiD;AAEjD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,OAAe,CAAC;IAEpB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;QACtC,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,OAAO,GAAG,IAAA,kCAAsB,EAAC,WAAW,CAAC,CAAC;YACpD,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,oCAAoC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,OAAO,GAAG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C;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=validator.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validator.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/validator.test.ts"],"names":[],"mappings":""}