docspec 0.2.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.
- package/README.md +64 -142
- package/dist/__tests__/changed.test.d.ts +2 -0
- package/dist/__tests__/changed.test.d.ts.map +1 -0
- package/dist/__tests__/changed.test.js +98 -0
- package/dist/__tests__/changed.test.js.map +1 -0
- package/dist/__tests__/cli.test.js +34 -142
- package/dist/__tests__/cli.test.js.map +1 -1
- package/dist/__tests__/create.test.d.ts +2 -0
- package/dist/__tests__/create.test.d.ts.map +1 -0
- package/dist/__tests__/create.test.js +122 -0
- package/dist/__tests__/create.test.js.map +1 -0
- package/dist/__tests__/generate.test.d.ts +2 -0
- package/dist/__tests__/generate.test.d.ts.map +1 -0
- package/dist/__tests__/generate.test.js +113 -0
- package/dist/__tests__/generate.test.js.map +1 -0
- package/dist/__tests__/generator.test.js +26 -22
- package/dist/__tests__/generator.test.js.map +1 -1
- package/dist/__tests__/path-utils.test.d.ts +2 -0
- package/dist/__tests__/path-utils.test.d.ts.map +1 -0
- package/dist/__tests__/path-utils.test.js +49 -0
- package/dist/__tests__/path-utils.test.js.map +1 -0
- package/dist/__tests__/template.test.d.ts +2 -0
- package/dist/__tests__/template.test.d.ts.map +1 -0
- package/dist/__tests__/template.test.js +95 -0
- package/dist/__tests__/template.test.js.map +1 -0
- package/dist/changed.d.ts +25 -0
- package/dist/changed.d.ts.map +1 -0
- package/dist/changed.js +210 -0
- package/dist/changed.js.map +1 -0
- package/dist/cli.js +89 -72
- package/dist/cli.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +118 -15
- package/dist/constants.js.map +1 -1
- package/dist/create.d.ts +12 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/create.js +93 -0
- package/dist/create.js.map +1 -0
- package/dist/docspec-changed.d.ts +25 -0
- package/dist/docspec-changed.d.ts.map +1 -0
- package/dist/docspec-changed.js +210 -0
- package/dist/docspec-changed.js.map +1 -0
- package/dist/docspec-generate.d.ts +22 -0
- package/dist/docspec-generate.d.ts.map +1 -0
- package/dist/docspec-generate.js +171 -0
- package/dist/docspec-generate.js.map +1 -0
- package/dist/format-parser.d.ts +2 -1
- package/dist/format-parser.d.ts.map +1 -1
- package/dist/format-parser.js +45 -15
- package/dist/format-parser.js.map +1 -1
- package/dist/generate.d.ts +26 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +175 -0
- package/dist/generate.js.map +1 -0
- package/dist/generator.d.ts +4 -3
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +35 -12
- package/dist/generator.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +40 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +74 -0
- package/dist/logger.js.map +1 -0
- package/dist/path-utils.d.ts +17 -0
- package/dist/path-utils.d.ts.map +1 -0
- package/dist/path-utils.js +76 -0
- package/dist/path-utils.js.map +1 -0
- package/dist/template.d.ts +20 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +151 -0
- package/dist/template.js.map +1 -0
- package/dist/validator.d.ts.map +1 -1
- package/dist/validator.js +34 -1
- package/dist/validator.js.map +1 -1
- package/package.json +1 -1
- package/README.docspec.md +0 -180
package/dist/format-parser.js
CHANGED
|
@@ -38,11 +38,14 @@ exports.parseFormatContent = parseFormatContent;
|
|
|
38
38
|
exports.getFormatFilePath = getFormatFilePath;
|
|
39
39
|
const fs = __importStar(require("fs"));
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
|
+
const logger_1 = require("./logger");
|
|
41
42
|
/**
|
|
42
43
|
* Parse the docspec format file
|
|
43
44
|
*/
|
|
44
45
|
function parseFormatFile(formatFilePath) {
|
|
46
|
+
logger_1.logger.debug(`Reading format file: ${formatFilePath}`);
|
|
45
47
|
const content = fs.readFileSync(formatFilePath, "utf-8");
|
|
48
|
+
logger_1.logger.debug(`Format file read: ${content.length} characters`);
|
|
46
49
|
return parseFormatContent(content);
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
@@ -50,6 +53,7 @@ function parseFormatFile(formatFilePath) {
|
|
|
50
53
|
*/
|
|
51
54
|
function parseFormatContent(content) {
|
|
52
55
|
const lines = content.split("\n");
|
|
56
|
+
logger_1.logger.debug(`Parsing format content: ${lines.length} lines`);
|
|
53
57
|
// Look for AGENT INSTRUCTIONS section first
|
|
54
58
|
let agentInstructions;
|
|
55
59
|
let agentInstructionsStart = -1;
|
|
@@ -57,6 +61,7 @@ function parseFormatContent(content) {
|
|
|
57
61
|
for (let i = 0; i < lines.length; i++) {
|
|
58
62
|
if (lines[i].trim() === "## AGENT INSTRUCTIONS") {
|
|
59
63
|
agentInstructionsStart = i;
|
|
64
|
+
logger_1.logger.debug(`Found AGENT INSTRUCTIONS section at line ${i + 1}`);
|
|
60
65
|
break;
|
|
61
66
|
}
|
|
62
67
|
}
|
|
@@ -86,8 +91,12 @@ function parseFormatContent(content) {
|
|
|
86
91
|
.trim();
|
|
87
92
|
if (agentContent) {
|
|
88
93
|
agentInstructions = agentContent;
|
|
94
|
+
logger_1.logger.debug(`Extracted agent instructions: ${agentContent.length} characters`);
|
|
89
95
|
}
|
|
90
96
|
}
|
|
97
|
+
else {
|
|
98
|
+
logger_1.logger.debug("No AGENT INSTRUCTIONS section found");
|
|
99
|
+
}
|
|
91
100
|
// Find all section headers: ## N. Section Name
|
|
92
101
|
const sectionHeaderRegex = /^##\s+(\d+)\.\s+(.+)$/;
|
|
93
102
|
const sectionHeaders = [];
|
|
@@ -103,11 +112,14 @@ function parseFormatContent(content) {
|
|
|
103
112
|
number: parseInt(match[1], 10),
|
|
104
113
|
name: match[2].trim(),
|
|
105
114
|
});
|
|
115
|
+
logger_1.logger.debug(`Found section header: ${match[1]}. ${match[2].trim()} at line ${i + 1}`);
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
if (sectionHeaders.length === 0) {
|
|
119
|
+
logger_1.logger.debug("No section headers found in format file");
|
|
109
120
|
throw new Error("No section headers found in format file. Expected format: ## N. Section Name");
|
|
110
121
|
}
|
|
122
|
+
logger_1.logger.debug(`Found ${sectionHeaders.length} section header(s)`);
|
|
111
123
|
// Extract template: everything before the first numbered section header
|
|
112
124
|
// But exclude the AGENT INSTRUCTIONS section if it exists
|
|
113
125
|
const firstSectionLine = sectionHeaders[0].lineIndex;
|
|
@@ -116,12 +128,15 @@ function parseFormatContent(content) {
|
|
|
116
128
|
// AGENT INSTRUCTIONS is between title and first section
|
|
117
129
|
// Template is everything before AGENT INSTRUCTIONS
|
|
118
130
|
templateBeforeSections = lines.slice(0, agentInstructionsStart).join("\n").trim();
|
|
131
|
+
logger_1.logger.debug("Template extracted before AGENT INSTRUCTIONS section");
|
|
119
132
|
}
|
|
120
133
|
else {
|
|
121
134
|
// No AGENT INSTRUCTIONS, use everything before first section
|
|
122
135
|
templateBeforeSections = lines.slice(0, firstSectionLine).join("\n").trim();
|
|
136
|
+
logger_1.logger.debug("Template extracted before first section");
|
|
123
137
|
}
|
|
124
138
|
const template = templateBeforeSections + "\n\n{{AGENT_INSTRUCTIONS}}\n\n{{SECTIONS}}\n";
|
|
139
|
+
logger_1.logger.debug(`Template length: ${template.length} characters`);
|
|
125
140
|
// Extract sections
|
|
126
141
|
const sections = [];
|
|
127
142
|
for (let i = 0; i < sectionHeaders.length; i++) {
|
|
@@ -138,6 +153,7 @@ function parseFormatContent(content) {
|
|
|
138
153
|
.filter(line => line.trim() !== "---")
|
|
139
154
|
.join("\n")
|
|
140
155
|
.trim();
|
|
156
|
+
logger_1.logger.debug(`Extracted section "${header.name}": ${sectionContent.length} characters`);
|
|
141
157
|
sections.push({
|
|
142
158
|
name: header.name,
|
|
143
159
|
boilerplate: sectionContent,
|
|
@@ -146,30 +162,44 @@ function parseFormatContent(content) {
|
|
|
146
162
|
}
|
|
147
163
|
// Sort sections by number to ensure correct order
|
|
148
164
|
sections.sort((a, b) => a.number - b.number);
|
|
165
|
+
logger_1.logger.debug(`Parsed ${sections.length} section(s) from format file`);
|
|
149
166
|
return {
|
|
150
167
|
sections,
|
|
151
168
|
template,
|
|
152
169
|
agentInstructions,
|
|
153
170
|
};
|
|
154
171
|
}
|
|
172
|
+
const USER_TEMPLATE = ".docspec/docspec.md";
|
|
155
173
|
/**
|
|
156
|
-
*
|
|
174
|
+
* Seed .docspec/docspec.md from the bundled docspec-format.md if it doesn't exist.
|
|
175
|
+
* Returns the path to .docspec/docspec.md (in cwd).
|
|
176
|
+
*/
|
|
177
|
+
function seedDefaultFormatFile() {
|
|
178
|
+
const cwd = process.cwd();
|
|
179
|
+
const userPath = path.join(cwd, ".docspec", "docspec.md");
|
|
180
|
+
const defaultPath = path.join(__dirname, "..", "docspec-format.md");
|
|
181
|
+
logger_1.logger.debug(`Seeding ${userPath} from ${defaultPath}`);
|
|
182
|
+
if (!fs.existsSync(defaultPath)) {
|
|
183
|
+
throw new Error(`Default template not found at ${defaultPath}. ` +
|
|
184
|
+
`Create .docspec/docspec.md in your project or ensure the docspec package is installed correctly.`);
|
|
185
|
+
}
|
|
186
|
+
fs.mkdirSync(path.join(cwd, ".docspec"), { recursive: true });
|
|
187
|
+
fs.copyFileSync(defaultPath, userPath);
|
|
188
|
+
logger_1.logger.debug(`Seeded ${userPath}`);
|
|
189
|
+
return userPath;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get the path to the format file. Uses .docspec/docspec.md in cwd.
|
|
193
|
+
* If it doesn't exist, seeds it from the bundled docspec-format.md and returns the new path.
|
|
157
194
|
*/
|
|
158
195
|
function getFormatFilePath() {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
}
|
|
196
|
+
const cwd = process.cwd();
|
|
197
|
+
const userPath = path.join(cwd, ".docspec", "docspec.md");
|
|
198
|
+
if (fs.existsSync(userPath)) {
|
|
199
|
+
logger_1.logger.debug(`Format file found: ${userPath}`);
|
|
200
|
+
return userPath;
|
|
171
201
|
}
|
|
172
|
-
|
|
173
|
-
return
|
|
202
|
+
logger_1.logger.debug(`Format file not found at ${userPath}, seeding from default`);
|
|
203
|
+
return seedDefaultFormatFile();
|
|
174
204
|
}
|
|
175
205
|
//# sourceMappingURL=format-parser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-parser.js","sourceRoot":"","sources":["../src/format-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"format-parser.js","sourceRoot":"","sources":["../src/format-parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,0CAKC;AAKD,gDAyIC;AA6BD,8CASC;AA5MD,uCAAyB;AACzB,2CAA6B;AAC7B,qCAAkC;AAclC;;GAEG;AACH,SAAgB,eAAe,CAAC,cAAsB;IACpD,eAAM,CAAC,KAAK,CAAC,wBAAwB,cAAc,EAAE,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACzD,eAAM,CAAC,KAAK,CAAC,qBAAqB,OAAO,CAAC,MAAM,aAAa,CAAC,CAAC;IAC/D,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,eAAM,CAAC,KAAK,CAAC,2BAA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
|
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"}
|
package/dist/generate.js
ADDED
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;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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"}
|
package/dist/generator.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generate a new docspec file
|
|
3
|
-
*
|
|
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
|
|
4
5
|
*/
|
|
5
|
-
export declare function generateDocspec(
|
|
6
|
+
export declare function generateDocspec(inputPath: string): Promise<void>;
|
|
6
7
|
/**
|
|
7
8
|
* Generate docspec content as a string (for library use)
|
|
8
9
|
* @param targetFilePath Path to the target markdown file (e.g., "README.md")
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"
|
|
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,23 +38,46 @@ 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
|
-
*
|
|
43
|
-
*
|
|
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/.
|
|
44
46
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
};
|
|
54
|
+
}
|
|
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
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
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
|
|
66
|
+
*/
|
|
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);
|
|
53
74
|
if (dir !== ".") {
|
|
75
|
+
logger_1.logger.debug(`Creating directory: ${dir}`);
|
|
54
76
|
await fs.mkdir(dir, { recursive: true });
|
|
55
77
|
}
|
|
56
|
-
|
|
57
|
-
await fs.writeFile(
|
|
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}`);
|
|
58
81
|
}
|
|
59
82
|
/**
|
|
60
83
|
* Generate docspec content as a string (for library use)
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,0CAiBC;AAMD,wDAEC;AA/DD,2CAAiD;AACjD,gDAAkC;AAClC,2CAA6B;AAC7B,qCAAkC;AAClC,6CAIsB;AAEtB;;;GAGG;AACH,SAAS,YAAY,CAAC,SAAiB;IAIrC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACjE,IAAI,IAAA,0BAAa,EAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO;YACL,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,IAAA,kCAAqB,EAAC,UAAU,CAAC;SAChD,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IAAA,8BAAkB,EAAC,cAAc,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* docspec - Generate
|
|
2
|
+
* docspec - Generate docspec files and prompts
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
|
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.
|
|
7
|
-
var
|
|
8
|
-
Object.defineProperty(exports, "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "
|
|
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,
|
|
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"}
|
package/dist/logger.d.ts
ADDED
|
@@ -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"}
|