docspec 0.1.0 → 0.3.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 (84) hide show
  1. package/README.md +69 -51
  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 +38 -158
  7. package/dist/__tests__/cli.test.js.map +1 -1
  8. package/dist/__tests__/constants.test.js +8 -18
  9. package/dist/__tests__/constants.test.js.map +1 -1
  10. package/dist/__tests__/create.test.d.ts +2 -0
  11. package/dist/__tests__/create.test.d.ts.map +1 -0
  12. package/dist/__tests__/create.test.js +122 -0
  13. package/dist/__tests__/create.test.js.map +1 -0
  14. package/dist/__tests__/generate.test.d.ts +2 -0
  15. package/dist/__tests__/generate.test.d.ts.map +1 -0
  16. package/dist/__tests__/generate.test.js +113 -0
  17. package/dist/__tests__/generate.test.js.map +1 -0
  18. package/dist/__tests__/generator.test.js +36 -32
  19. package/dist/__tests__/generator.test.js.map +1 -1
  20. package/dist/__tests__/path-utils.test.d.ts +2 -0
  21. package/dist/__tests__/path-utils.test.d.ts.map +1 -0
  22. package/dist/__tests__/path-utils.test.js +49 -0
  23. package/dist/__tests__/path-utils.test.js.map +1 -0
  24. package/dist/__tests__/template.test.d.ts +2 -0
  25. package/dist/__tests__/template.test.d.ts.map +1 -0
  26. package/dist/__tests__/template.test.js +95 -0
  27. package/dist/__tests__/template.test.js.map +1 -0
  28. package/dist/__tests__/validator.test.js +50 -94
  29. package/dist/__tests__/validator.test.js.map +1 -1
  30. package/dist/changed.d.ts +25 -0
  31. package/dist/changed.d.ts.map +1 -0
  32. package/dist/changed.js +210 -0
  33. package/dist/changed.js.map +1 -0
  34. package/dist/cli.js +89 -73
  35. package/dist/cli.js.map +1 -1
  36. package/dist/constants.d.ts +5 -2
  37. package/dist/constants.d.ts.map +1 -1
  38. package/dist/constants.js +155 -40
  39. package/dist/constants.js.map +1 -1
  40. package/dist/create.d.ts +12 -0
  41. package/dist/create.d.ts.map +1 -0
  42. package/dist/create.js +93 -0
  43. package/dist/create.js.map +1 -0
  44. package/dist/docspec-changed.d.ts +25 -0
  45. package/dist/docspec-changed.d.ts.map +1 -0
  46. package/dist/docspec-changed.js +210 -0
  47. package/dist/docspec-changed.js.map +1 -0
  48. package/dist/docspec-generate.d.ts +22 -0
  49. package/dist/docspec-generate.d.ts.map +1 -0
  50. package/dist/docspec-generate.js +171 -0
  51. package/dist/docspec-generate.js.map +1 -0
  52. package/dist/format-parser.d.ts +24 -0
  53. package/dist/format-parser.d.ts.map +1 -0
  54. package/dist/format-parser.js +205 -0
  55. package/dist/format-parser.js.map +1 -0
  56. package/dist/generate.d.ts +26 -0
  57. package/dist/generate.d.ts.map +1 -0
  58. package/dist/generate.js +175 -0
  59. package/dist/generate.js.map +1 -0
  60. package/dist/generator.d.ts +6 -6
  61. package/dist/generator.d.ts.map +1 -1
  62. package/dist/generator.js +38 -26
  63. package/dist/generator.js.map +1 -1
  64. package/dist/index.d.ts +8 -4
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +16 -7
  67. package/dist/index.js.map +1 -1
  68. package/dist/logger.d.ts +40 -0
  69. package/dist/logger.d.ts.map +1 -0
  70. package/dist/logger.js +74 -0
  71. package/dist/logger.js.map +1 -0
  72. package/dist/path-utils.d.ts +17 -0
  73. package/dist/path-utils.d.ts.map +1 -0
  74. package/dist/path-utils.js +76 -0
  75. package/dist/path-utils.js.map +1 -0
  76. package/dist/template.d.ts +20 -0
  77. package/dist/template.d.ts.map +1 -0
  78. package/dist/template.js +151 -0
  79. package/dist/template.js.map +1 -0
  80. package/dist/validator.d.ts.map +1 -1
  81. package/dist/validator.js +39 -1
  82. package/dist/validator.js.map +1 -1
  83. package/docspec-format.md +45 -0
  84. package/package.json +4 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":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eAAM,CAAC,KAAK,CAAC,UAAU,QAAQ,EAAE,CAAC,CAAC;IACnC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;GAGG;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,EAAE,CAAC;QAC5B,eAAM,CAAC,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;QAC/C,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,eAAM,CAAC,KAAK,CAAC,4BAA4B,QAAQ,wBAAwB,CAAC,CAAC;IAC3E,OAAO,qBAAqB,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Prompt building for the "docspec generate" command (create docspec + LLM prompts).
3
+ * Docspec file creation from template: create.ts.
4
+ */
5
+ export interface DocspecGenerateOptions {
6
+ /** Path to the markdown file (repo-relative, e.g. README.md or docs/deploy.md). */
7
+ markdownPath: string;
8
+ /** If true, overwrite existing docspec. If false and docspec exists, throws. */
9
+ overwrite?: boolean;
10
+ /** Repo root (default process.cwd()). */
11
+ repoRoot?: string;
12
+ }
13
+ /**
14
+ * Generate the docspec file (if missing or overwrite), then build plan and implementation prompts.
15
+ * Returns combined prompt (implementation prompt with {{PLAN}} placeholder) and optional paths to write.
16
+ */
17
+ export declare function buildDocspecGeneratePrompts(options: DocspecGenerateOptions & {
18
+ outputPromptPath?: string;
19
+ outputPlanPath?: string;
20
+ }): Promise<{
21
+ planPrompt: string;
22
+ implPrompt: string;
23
+ outputPromptPath?: string;
24
+ outputPlanPath?: string;
25
+ }>;
26
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuFH,MAAM,WAAW,sBAAsB;IACrC,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,sBAAsB,GAAG;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0DzG"}
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ /**
3
+ * Prompt building for the "docspec generate" command (create docspec + LLM prompts).
4
+ * Docspec file creation from template: create.ts.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.buildDocspecGeneratePrompts = buildDocspecGeneratePrompts;
41
+ const fs = __importStar(require("fs/promises"));
42
+ const path = __importStar(require("path"));
43
+ const create_1 = require("./create");
44
+ const path_utils_1 = require("./path-utils");
45
+ const PLAN_TEMPLATE = `You are analyzing a markdown file and its docspec to discover missing or irrelevant information. Do not ask questions - create the plan directly.
46
+
47
+ <markdown path="{{md_path}}">
48
+ {{md_text}}
49
+ </markdown>
50
+
51
+ <docspec path="{{docspec_path}}">
52
+ {{docspec_text}}
53
+ </docspec>
54
+
55
+ Task: Focus on INFORMATION DISCOVERY. Use all of your available tools to explore the repository and understand what actually exists, then analyze both files and create a plan that identifies:
56
+
57
+ 1. **Missing information in the docspec**: What important details about the markdown file are not captured in sections 1-5?
58
+ - What does the markdown actually contain that isn't mentioned in the docspec?
59
+ - What should trigger updates that isn't currently listed?
60
+ - What structure/guidelines are missing?
61
+
62
+ 2. **Irrelevant or incorrect information in the docspec**: What's in the docspec that doesn't match reality?
63
+ - Does the docspec describe things that aren't actually in the markdown?
64
+ - Are there update triggers that don't make sense?
65
+ - Are there structure requirements that don't match the actual document?
66
+
67
+ 3. **Missing information in the markdown**: What should be documented but isn't?
68
+ - Are there important details missing?
69
+ - Are there sections that should exist but don't?
70
+
71
+ IMPORTANT: The docspec structure must be preserved:
72
+ - Keep the header format: \`# DOCSPEC: [filename]\`
73
+ - Keep the one-line description
74
+ - Keep the \`## AGENT INSTRUCTIONS\` section exactly as-is
75
+ - Keep section headers: \`## 1. Document Purpose\`, \`## 2. Update Triggers\`, etc.
76
+ - ONLY update the CONTENT within sections 1-5, not the headers or structure
77
+
78
+ Output your plan in a clear, structured format focusing on information gaps and corrections.
79
+ `;
80
+ const IMPL_TEMPLATE = `Based on this information discovery plan:
81
+ <plan>
82
+ {{PLAN}}
83
+ </plan>
84
+
85
+ You need to update two files:
86
+ 1. {{md_path}} - the markdown file
87
+ 2. {{docspec_path}} - the docspec file
88
+
89
+ CRITICAL CONSTRAINTS FOR DOCSPEC FILE - YOU MUST PRESERVE THE EXACT STRUCTURE:
90
+
91
+ 1. Read the existing {{docspec_path}} file FIRST using the Read tool
92
+ 2. PRESERVE EXACTLY:
93
+ - The exact header format (e.g. \`# DOCSPEC: Readme\` or \`# DOCSPEC: [README.md](/README.md)\`) - keep it EXACTLY as written
94
+ - The exact one-line description format (e.g. \`> A specification that ...\`) - keep it EXACTLY as written
95
+ - The \`## AGENT INSTRUCTIONS\` section if it exists - keep it EXACTLY as-is, do not modify
96
+ - The EXACT section header names and numbers (e.g. \`## 1. Document Purpose\` or \`## 2. Update Triggers\`) - keep them EXACTLY as written
97
+ - The order of sections - do not reorder them
98
+
99
+ 3. ONLY update the CONTENT within sections 1-5 (the text below each section header)
100
+ - Do NOT change section header text, numbers, or names
101
+ - Do NOT change the format of headers
102
+ - Do NOT modify title, description, or AGENT INSTRUCTIONS
103
+
104
+ Task:
105
+ 1. Read {{docspec_path}} and note its EXACT structure
106
+ 2. Read {{md_path}}
107
+ 3. Explore the repository and discover information about:
108
+ - What the codebase actually contains
109
+ - What files exist that relate to the markdown
110
+ - What the actual structure and content of the markdown is
111
+ 4. For {{docspec_path}}: Update ONLY the content text within sections 1-5. Preserve ALL structure, headers, format, and separators exactly as they were.
112
+ 5. For {{md_path}}: Add any missing information identified in the plan
113
+ 6. Make changes directly to the files
114
+ `;
115
+ function substitute(template, vars) {
116
+ let out = template;
117
+ for (const [key, value] of Object.entries(vars)) {
118
+ out = out.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
119
+ }
120
+ return out;
121
+ }
122
+ /**
123
+ * Generate the docspec file (if missing or overwrite), then build plan and implementation prompts.
124
+ * Returns combined prompt (implementation prompt with {{PLAN}} placeholder) and optional paths to write.
125
+ */
126
+ async function buildDocspecGeneratePrompts(options) {
127
+ const repoRoot = path.resolve(options.repoRoot ?? process.cwd());
128
+ const mdPath = path.normalize(options.markdownPath).replace(/\\/g, "/");
129
+ const mdFull = path.join(repoRoot, mdPath);
130
+ const docspecPath = (0, path_utils_1.markdownToDocspecPath)(mdPath);
131
+ const docspecFull = path.join(repoRoot, docspecPath);
132
+ try {
133
+ await fs.access(mdFull);
134
+ }
135
+ catch {
136
+ throw new Error(`Markdown file not found: ${mdFull}`);
137
+ }
138
+ const docspecExists = await fs.access(docspecFull).then(() => true).catch(() => false);
139
+ if (docspecExists && !options.overwrite) {
140
+ throw new Error(`Docspec file already exists: ${docspecPath}. To overwrite, set overwrite to true.`);
141
+ }
142
+ await (0, create_1.generateDocspec)(mdPath);
143
+ const mdText = await fs.readFile(mdFull, "utf-8");
144
+ const docspecText = await fs.readFile(docspecFull, "utf-8");
145
+ const vars = {
146
+ md_path: mdPath,
147
+ md_text: mdText,
148
+ docspec_path: docspecPath,
149
+ docspec_text: docspecText,
150
+ "{{PLAN}}": "{{PLAN}}",
151
+ };
152
+ const planPrompt = substitute(PLAN_TEMPLATE, vars);
153
+ const implPrompt = substitute(IMPL_TEMPLATE, vars);
154
+ const outPrompt = options.outputPromptPath
155
+ ? path.resolve(repoRoot, options.outputPromptPath)
156
+ : undefined;
157
+ const outPlan = options.outputPlanPath
158
+ ? path.resolve(repoRoot, options.outputPlanPath)
159
+ : undefined;
160
+ if (outPrompt) {
161
+ await fs.mkdir(path.dirname(outPrompt), { recursive: true });
162
+ await fs.writeFile(outPrompt, implPrompt, "utf-8");
163
+ }
164
+ if (outPlan) {
165
+ await fs.mkdir(path.dirname(outPlan), { recursive: true });
166
+ await fs.writeFile(outPlan, planPrompt, "utf-8");
167
+ }
168
+ return {
169
+ planPrompt,
170
+ implPrompt,
171
+ outputPromptPath: outPrompt,
172
+ outputPlanPath: outPlan,
173
+ };
174
+ }
175
+ //# sourceMappingURL=generate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGH,kEA+DC;AAjKD,gDAAkC;AAClC,2CAA6B;AAC7B,qCAA2C;AAC3C,6CAAqD;AAErD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCrB,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCrB,CAAC;AAEF,SAAS,UAAU,CAAC,QAAgB,EAAE,IAA4B;IAChE,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,GAAG,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAWD;;;GAGG;AACI,KAAK,UAAU,2BAA2B,CAC/C,OAGC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAA,kCAAqB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CAAC,SAAS,CAAC;IACd,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc;QACpC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC;QAChD,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7D,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3D,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,UAAU;QACV,UAAU;QACV,gBAAgB,EAAE,SAAS;QAC3B,cAAc,EAAE,OAAO;KACxB,CAAC;AACJ,CAAC"}
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Generate a new docspec file at the specified path
3
- * @param filePath Path where the docspec file should be created
4
- * @param name Name of the document (used in the header)
2
+ * Generate a new docspec file. Accepts either a markdown path (e.g. README.md, docs/deploy.md)
3
+ * or a docspec path under .docspec/ (e.g. .docspec/README.docspec.md).
4
+ * Writes to .docspec/ using the convention: markdown P.md -> .docspec/P.docspec.md
5
5
  */
6
- export declare function generateDocspec(filePath: string, name?: string): Promise<void>;
6
+ export declare function generateDocspec(inputPath: string): Promise<void>;
7
7
  /**
8
8
  * Generate docspec content as a string (for library use)
9
- * @param name Name of the document
9
+ * @param targetFilePath Path to the target markdown file (e.g., "README.md")
10
10
  */
11
- export declare function generateDocspecContent(name: string): string;
11
+ export declare function generateDocspecContent(targetFilePath: string): string;
12
12
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAepF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3D"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBtE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAErE"}
package/dist/generator.js CHANGED
@@ -38,40 +38,52 @@ exports.generateDocspecContent = generateDocspecContent;
38
38
  const constants_1 = require("./constants");
39
39
  const fs = __importStar(require("fs/promises"));
40
40
  const path = __importStar(require("path"));
41
+ const logger_1 = require("./logger");
42
+ const path_utils_1 = require("./path-utils");
41
43
  /**
42
- * Generate a new docspec file at the specified path
43
- * @param filePath Path where the docspec file should be created
44
- * @param name Name of the document (used in the header)
44
+ * Resolve input path to docspec path and markdown path.
45
+ * Accepts either a markdown path (e.g. README.md, docs/deploy.md) or a docspec path under .docspec/.
45
46
  */
46
- async function generateDocspec(filePath, name) {
47
- // Extract name from file path if not provided
48
- const docName = name || extractNameFromPath(filePath);
49
- // Generate the template content
50
- const content = (0, constants_1.getDocspecTemplate)(docName);
51
- // Ensure the directory exists (recursive: true is safe even if dir exists)
52
- const dir = path.dirname(filePath);
53
- if (dir !== ".") {
54
- await fs.mkdir(dir, { recursive: true });
47
+ function resolveInput(inputPath) {
48
+ const normalized = path.normalize(inputPath).replace(/\\/g, "/");
49
+ if ((0, path_utils_1.isDocspecPath)(normalized)) {
50
+ return {
51
+ docspecPath: normalized,
52
+ markdownPath: (0, path_utils_1.docspecToMarkdownPath)(normalized),
53
+ };
55
54
  }
56
- // Write the file
57
- await fs.writeFile(filePath, content, "utf-8");
55
+ // Treat as markdown path (e.g. README.md or docs/deploy.md)
56
+ const mdPath = normalized.endsWith(".md") ? normalized : normalized + ".md";
57
+ return {
58
+ docspecPath: (0, path_utils_1.markdownToDocspecPath)(mdPath),
59
+ markdownPath: mdPath,
60
+ };
58
61
  }
59
62
  /**
60
- * Generate docspec content as a string (for library use)
61
- * @param name Name of the document
63
+ * Generate a new docspec file. Accepts either a markdown path (e.g. README.md, docs/deploy.md)
64
+ * or a docspec path under .docspec/ (e.g. .docspec/README.docspec.md).
65
+ * Writes to .docspec/ using the convention: markdown P.md -> .docspec/P.docspec.md
62
66
  */
63
- function generateDocspecContent(name) {
64
- return (0, constants_1.getDocspecTemplate)(name);
67
+ async function generateDocspec(inputPath) {
68
+ logger_1.logger.debug(`Generating docspec for: ${inputPath}`);
69
+ const { docspecPath, markdownPath } = resolveInput(inputPath);
70
+ logger_1.logger.debug(`Docspec file: ${docspecPath}, target markdown: ${markdownPath}`);
71
+ const content = (0, constants_1.getDocspecTemplate)(markdownPath);
72
+ logger_1.logger.debug(`Generated template with ${content.length} characters`);
73
+ const dir = path.dirname(docspecPath);
74
+ if (dir !== ".") {
75
+ logger_1.logger.debug(`Creating directory: ${dir}`);
76
+ await fs.mkdir(dir, { recursive: true });
77
+ }
78
+ logger_1.logger.debug(`Writing file: ${docspecPath}`);
79
+ await fs.writeFile(docspecPath, content, "utf-8");
80
+ logger_1.logger.debug(`File written successfully: ${docspecPath}`);
65
81
  }
66
82
  /**
67
- * Extract a document name from a file path
83
+ * Generate docspec content as a string (for library use)
84
+ * @param targetFilePath Path to the target markdown file (e.g., "README.md")
68
85
  */
69
- function extractNameFromPath(filePath) {
70
- const basename = path.basename(filePath, ".docspec.md");
71
- // Convert kebab-case, snake_case, or camelCase to Title Case
72
- return basename
73
- .split(/[-_]/)
74
- .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
75
- .join(" ");
86
+ function generateDocspecContent(targetFilePath) {
87
+ return (0, constants_1.getDocspecTemplate)(targetFilePath);
76
88
  }
77
89
  //# sourceMappingURL=generator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,0CAeC;AAMD,wDAEC;AAhCD,2CAAiD;AACjD,gDAAkC;AAClC,2CAA6B;AAE7B;;;;GAIG;AACI,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,IAAa;IACnE,8CAA8C;IAC9C,MAAM,OAAO,GAAG,IAAI,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEtD,gCAAgC;IAChC,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,OAAO,CAAC,CAAC;IAE5C,2EAA2E;IAC3E,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QAChB,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,iBAAiB;IACjB,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,IAAY;IACjD,OAAO,IAAA,8BAAkB,EAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IACxD,6DAA6D;IAC7D,OAAO,QAAQ;SACZ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AAK,CAAC,iBAAiB,WAAW,sBAAsB,YAAY,EAAE,CAAC,CAAC;IAE/E,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,YAAY,CAAC,CAAC;IACjD,eAAM,CAAC,KAAK,CAAC,2BAA2B,OAAO,CAAC,MAAM,aAAa,CAAC,CAAC;IAErE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;QAChB,eAAM,CAAC,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAC;QAC3C,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,eAAM,CAAC,KAAK,CAAC,iBAAiB,WAAW,EAAE,CAAC,CAAC;IAC7C,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,eAAM,CAAC,KAAK,CAAC,8BAA8B,WAAW,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,cAAsB;IAC3D,OAAO,IAAA,8BAAkB,EAAC,cAAc,CAAC,CAAC;AAC5C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  /**
2
- * docspec - Generate and validate docspec files
2
+ * docspec - Generate docspec files and prompts
3
3
  */
4
- export { validateDocspec } from "./validator";
5
- export { generateDocspec, generateDocspecContent } from "./generator";
6
- export type { ValidationResult, DocspecSection } from "./types";
4
+ export { generateDocspec, generateDocspecContent } from "./create";
5
+ export { markdownToDocspecPath, docspecToMarkdownPath, isDocspecPath, } from "./path-utils";
6
+ export { buildDocspecChangedPrompt } from "./changed";
7
+ export type { DocspecChangedOptions } from "./changed";
8
+ export { buildDocspecGeneratePrompts } from "./generate";
9
+ export type { DocspecGenerateOptions } from "./generate";
7
10
  export { REQUIRED_SECTIONS, SECTION_BOILERPLATE } from "./constants";
11
+ export { logger, LogLevel } from "./logger";
8
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,15 +1,24 @@
1
1
  "use strict";
2
2
  /**
3
- * docspec - Generate and validate docspec files
3
+ * docspec - Generate docspec files and prompts
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SECTION_BOILERPLATE = exports.REQUIRED_SECTIONS = exports.generateDocspecContent = exports.generateDocspec = exports.validateDocspec = void 0;
7
- var validator_1 = require("./validator");
8
- Object.defineProperty(exports, "validateDocspec", { enumerable: true, get: function () { return validator_1.validateDocspec; } });
9
- var generator_1 = require("./generator");
10
- Object.defineProperty(exports, "generateDocspec", { enumerable: true, get: function () { return generator_1.generateDocspec; } });
11
- Object.defineProperty(exports, "generateDocspecContent", { enumerable: true, get: function () { return generator_1.generateDocspecContent; } });
6
+ exports.LogLevel = exports.logger = exports.SECTION_BOILERPLATE = exports.REQUIRED_SECTIONS = exports.buildDocspecGeneratePrompts = exports.buildDocspecChangedPrompt = exports.isDocspecPath = exports.docspecToMarkdownPath = exports.markdownToDocspecPath = exports.generateDocspecContent = exports.generateDocspec = void 0;
7
+ var create_1 = require("./create");
8
+ Object.defineProperty(exports, "generateDocspec", { enumerable: true, get: function () { return create_1.generateDocspec; } });
9
+ Object.defineProperty(exports, "generateDocspecContent", { enumerable: true, get: function () { return create_1.generateDocspecContent; } });
10
+ var path_utils_1 = require("./path-utils");
11
+ Object.defineProperty(exports, "markdownToDocspecPath", { enumerable: true, get: function () { return path_utils_1.markdownToDocspecPath; } });
12
+ Object.defineProperty(exports, "docspecToMarkdownPath", { enumerable: true, get: function () { return path_utils_1.docspecToMarkdownPath; } });
13
+ Object.defineProperty(exports, "isDocspecPath", { enumerable: true, get: function () { return path_utils_1.isDocspecPath; } });
14
+ var changed_1 = require("./changed");
15
+ Object.defineProperty(exports, "buildDocspecChangedPrompt", { enumerable: true, get: function () { return changed_1.buildDocspecChangedPrompt; } });
16
+ var generate_1 = require("./generate");
17
+ Object.defineProperty(exports, "buildDocspecGeneratePrompts", { enumerable: true, get: function () { return generate_1.buildDocspecGeneratePrompts; } });
12
18
  var constants_1 = require("./constants");
13
19
  Object.defineProperty(exports, "REQUIRED_SECTIONS", { enumerable: true, get: function () { return constants_1.REQUIRED_SECTIONS; } });
14
20
  Object.defineProperty(exports, "SECTION_BOILERPLATE", { enumerable: true, get: function () { return constants_1.SECTION_BOILERPLATE; } });
21
+ var logger_1 = require("./logger");
22
+ Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
23
+ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logger_1.LogLevel; } });
15
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yCAA8C;AAArC,4GAAA,eAAe,OAAA;AACxB,yCAAsE;AAA7D,4GAAA,eAAe,OAAA;AAAE,mHAAA,sBAAsB,OAAA;AAEhD,yCAAqE;AAA5D,8GAAA,iBAAiB,OAAA;AAAE,gHAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mCAAmE;AAA1D,yGAAA,eAAe,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAChD,2CAIsB;AAHpB,mHAAA,qBAAqB,OAAA;AACrB,mHAAA,qBAAqB,OAAA;AACrB,2GAAA,aAAa,OAAA;AAEf,qCAAsD;AAA7C,oHAAA,yBAAyB,OAAA;AAElC,uCAAyD;AAAhD,uHAAA,2BAA2B,OAAA;AAEpC,yCAAqE;AAA5D,8GAAA,iBAAiB,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAC/C,mCAA4C;AAAnC,gGAAA,MAAM,OAAA;AAAE,kGAAA,QAAQ,OAAA"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Simple logger utility with support for different log levels and verbose mode
3
+ */
4
+ export declare enum LogLevel {
5
+ DEBUG = 0,
6
+ INFO = 1,
7
+ WARN = 2,
8
+ ERROR = 3
9
+ }
10
+ declare class Logger {
11
+ private verbose;
12
+ private logLevel;
13
+ /**
14
+ * Enable or disable verbose mode
15
+ */
16
+ setVerbose(enabled: boolean): void;
17
+ /**
18
+ * Log a debug message (only shown in verbose mode)
19
+ */
20
+ debug(message: string, ...args: any[]): void;
21
+ /**
22
+ * Log an info message
23
+ */
24
+ info(message: string, ...args: any[]): void;
25
+ /**
26
+ * Log a warning message
27
+ */
28
+ warn(message: string, ...args: any[]): void;
29
+ /**
30
+ * Log an error message
31
+ */
32
+ error(message: string, ...args: any[]): void;
33
+ /**
34
+ * Log a success message
35
+ */
36
+ success(message: string, ...args: any[]): void;
37
+ }
38
+ export declare const logger: Logger;
39
+ export {};
40
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,cAAM,MAAM;IACV,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,QAAQ,CAA2B;IAE3C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IASlC;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM3C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5C;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAK/C;AAGD,eAAO,MAAM,MAAM,QAAe,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ /**
3
+ * Simple logger utility with support for different log levels and verbose mode
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logger = exports.LogLevel = void 0;
7
+ var LogLevel;
8
+ (function (LogLevel) {
9
+ LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
10
+ LogLevel[LogLevel["INFO"] = 1] = "INFO";
11
+ LogLevel[LogLevel["WARN"] = 2] = "WARN";
12
+ LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
13
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
14
+ class Logger {
15
+ constructor() {
16
+ this.verbose = false;
17
+ this.logLevel = LogLevel.INFO;
18
+ }
19
+ /**
20
+ * Enable or disable verbose mode
21
+ */
22
+ setVerbose(enabled) {
23
+ this.verbose = enabled;
24
+ if (enabled) {
25
+ this.logLevel = LogLevel.DEBUG;
26
+ }
27
+ else {
28
+ this.logLevel = LogLevel.INFO;
29
+ }
30
+ }
31
+ /**
32
+ * Log a debug message (only shown in verbose mode)
33
+ */
34
+ debug(message, ...args) {
35
+ if (this.logLevel <= LogLevel.DEBUG) {
36
+ console.debug(`[DEBUG] ${message}`, ...args);
37
+ }
38
+ }
39
+ /**
40
+ * Log an info message
41
+ */
42
+ info(message, ...args) {
43
+ if (this.logLevel <= LogLevel.INFO) {
44
+ console.log(message, ...args);
45
+ }
46
+ }
47
+ /**
48
+ * Log a warning message
49
+ */
50
+ warn(message, ...args) {
51
+ if (this.logLevel <= LogLevel.WARN) {
52
+ console.warn(`⚠️ ${message}`, ...args);
53
+ }
54
+ }
55
+ /**
56
+ * Log an error message
57
+ */
58
+ error(message, ...args) {
59
+ if (this.logLevel <= LogLevel.ERROR) {
60
+ console.error(`❌ ${message}`, ...args);
61
+ }
62
+ }
63
+ /**
64
+ * Log a success message
65
+ */
66
+ success(message, ...args) {
67
+ if (this.logLevel <= LogLevel.INFO) {
68
+ console.log(`✅ ${message}`, ...args);
69
+ }
70
+ }
71
+ }
72
+ // Export a singleton instance
73
+ exports.logger = new Logger();
74
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
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,IAAI,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,OAAe,EAAE,GAAG,IAAW;QACrC,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;CACF;AAED,8BAA8B;AACjB,QAAA,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Convert a markdown file path to its docspec path under .docspec/.
3
+ * e.g. README.md -> .docspec/README.docspec.md, docs/deploy.md -> .docspec/docs/deploy.docspec.md
4
+ * Absolute paths (e.g. /var/folders/.../file.md) are mapped to .docspec/<basename>.docspec.md
5
+ * so we never create .docspec/var/... under the repo.
6
+ */
7
+ export declare function markdownToDocspecPath(mdPath: string): string;
8
+ /**
9
+ * Convert a docspec file path (under .docspec/) to its target markdown path.
10
+ * e.g. .docspec/README.docspec.md -> README.md, .docspec/docs/deploy.docspec.md -> docs/deploy.md
11
+ */
12
+ export declare function docspecToMarkdownPath(docspecPath: string): string;
13
+ /**
14
+ * Check if a path is under .docspec/ and ends with .docspec.md
15
+ */
16
+ export declare function isDocspecPath(filePath: string): boolean;
17
+ //# sourceMappingURL=path-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK5D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CASjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAKvD"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.markdownToDocspecPath = markdownToDocspecPath;
37
+ exports.docspecToMarkdownPath = docspecToMarkdownPath;
38
+ exports.isDocspecPath = isDocspecPath;
39
+ const path = __importStar(require("path"));
40
+ const DOCSPEC_DIR = ".docspec";
41
+ const DOCSPEC_EXT = ".docspec.md";
42
+ const MD_EXT = ".md";
43
+ /**
44
+ * Convert a markdown file path to its docspec path under .docspec/.
45
+ * e.g. README.md -> .docspec/README.docspec.md, docs/deploy.md -> .docspec/docs/deploy.docspec.md
46
+ * Absolute paths (e.g. /var/folders/.../file.md) are mapped to .docspec/<basename>.docspec.md
47
+ * so we never create .docspec/var/... under the repo.
48
+ */
49
+ function markdownToDocspecPath(mdPath) {
50
+ const normalized = path.normalize(mdPath).replace(/\\/g, "/");
51
+ const base = path.isAbsolute(normalized) ? path.basename(normalized) : normalized;
52
+ const withoutExt = base.endsWith(MD_EXT) ? base.slice(0, -MD_EXT.length) : base;
53
+ return path.join(DOCSPEC_DIR, withoutExt + DOCSPEC_EXT).replace(/\\/g, "/");
54
+ }
55
+ /**
56
+ * Convert a docspec file path (under .docspec/) to its target markdown path.
57
+ * e.g. .docspec/README.docspec.md -> README.md, .docspec/docs/deploy.docspec.md -> docs/deploy.md
58
+ */
59
+ function docspecToMarkdownPath(docspecPath) {
60
+ const normalized = path.normalize(docspecPath).replace(/\\/g, "/");
61
+ const withoutPrefix = normalized.startsWith(DOCSPEC_DIR + "/")
62
+ ? normalized.slice((DOCSPEC_DIR + "/").length)
63
+ : normalized;
64
+ if (!withoutPrefix.endsWith(DOCSPEC_EXT)) {
65
+ return normalized; // not a docspec path, return as-is
66
+ }
67
+ return withoutPrefix.slice(0, -DOCSPEC_EXT.length) + MD_EXT;
68
+ }
69
+ /**
70
+ * Check if a path is under .docspec/ and ends with .docspec.md
71
+ */
72
+ function isDocspecPath(filePath) {
73
+ const normalized = path.normalize(filePath).replace(/\\/g, "/");
74
+ return (normalized.startsWith(DOCSPEC_DIR + "/") && normalized.endsWith(DOCSPEC_EXT));
75
+ }
76
+ //# sourceMappingURL=path-utils.js.map