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.
- 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 +48 -145
- 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__/{generator.test.js → create.test.js} +31 -27
- 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 +152 -0
- package/dist/__tests__/generate.test.js.map +1 -0
- 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 +209 -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 +14 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/create.js +97 -0
- package/dist/create.js.map +1 -0
- package/dist/generate.d.ts +26 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +176 -0
- package/dist/generate.js.map +1 -0
- 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/{format-parser.d.ts → template.d.ts} +5 -8
- package/dist/template.d.ts.map +1 -0
- package/dist/{format-parser.js → template.js} +33 -57
- package/dist/template.js.map +1 -0
- package/package.json +1 -1
- package/README.docspec.md +0 -180
- package/dist/__tests__/generator.test.d.ts +0 -2
- package/dist/__tests__/generator.test.d.ts.map +0 -1
- package/dist/__tests__/generator.test.js.map +0 -1
- package/dist/__tests__/validator.test.d.ts +0 -2
- package/dist/__tests__/validator.test.d.ts.map +0 -1
- package/dist/__tests__/validator.test.js +0 -331
- package/dist/__tests__/validator.test.js.map +0 -1
- package/dist/format-parser.d.ts.map +0 -1
- package/dist/format-parser.js.map +0 -1
- package/dist/generator.d.ts +0 -11
- package/dist/generator.d.ts.map +0 -1
- package/dist/generator.js +0 -66
- package/dist/generator.js.map +0 -1
- package/dist/types.d.ts +0 -16
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/validator.d.ts +0 -7
- package/dist/validator.d.ts.map +0 -1
- package/dist/validator.js +0 -178
- package/dist/validator.js.map +0 -1
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AA+IA,gDAmCC;AAlLD,yCAA8E;AAC9E,qCAAkC;AAElC,IAAI,YAAY,GAAwB,IAAI,CAAC;AAC7C,IAAI,sBAAsB,GAA6B,IAAI,CAAC;AAC5D,IA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QAC7B,eAAM,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QAChE,gDAAgD;QAChD,MAAM,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;QAC9F,wBAAwB,GAAG,4BAA4B,YAAY,MAAM,CAAC;IAC5E,CAAC;SAAM,CAAC;QACN,eAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC9C,CAAC;IAED,6CAA6C;IAC7C,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,6BAA6B,EAAE,wBAAwB,CAAC,CAAC;IACrF,eAAM,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;IAE5D,oBAAoB;IACpB,eAAM,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,QAAQ,CAAC,MAAM,aAAa,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC/C,OAAO,MAAM,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;IAC3E,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,mCAAmC;IACnC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IAC3D,eAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAElD,eAAM,CAAC,KAAK,CAAC,iCAAiC,QAAQ,CAAC,MAAM,aAAa,CAAC,CAAC;IAC5E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/create.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
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
|
+
* @param inputPath Markdown or docspec path (repo-relative).
|
|
6
|
+
* @param repoRoot Optional repo root; when provided, the file is written under this directory instead of process.cwd().
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateDocspec(inputPath: string, repoRoot?: string): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Generate docspec content as a string (for library use)
|
|
11
|
+
* @param targetFilePath Path to the target markdown file (e.g., "README.md")
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateDocspecContent(targetFilePath: string): string;
|
|
14
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAqCA;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBzF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAErE"}
|
package/dist/create.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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.generateDocspec = generateDocspec;
|
|
37
|
+
exports.generateDocspecContent = generateDocspecContent;
|
|
38
|
+
/**
|
|
39
|
+
* Creates docspec files from the template (file generation).
|
|
40
|
+
* For the "docspec generate" command and prompt building, see generate.ts.
|
|
41
|
+
*/
|
|
42
|
+
const constants_1 = require("./constants");
|
|
43
|
+
const fs = __importStar(require("fs/promises"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const logger_1 = require("./logger");
|
|
46
|
+
const path_utils_1 = require("./path-utils");
|
|
47
|
+
/**
|
|
48
|
+
* Resolve input path to docspec path and markdown path.
|
|
49
|
+
* Accepts either a markdown path (e.g. README.md, docs/deploy.md) or a docspec path under .docspec/.
|
|
50
|
+
*/
|
|
51
|
+
function resolveInput(inputPath) {
|
|
52
|
+
const normalized = path.normalize(inputPath).replace(/\\/g, "/");
|
|
53
|
+
if ((0, path_utils_1.isDocspecPath)(normalized)) {
|
|
54
|
+
return {
|
|
55
|
+
docspecPath: normalized,
|
|
56
|
+
markdownPath: (0, path_utils_1.docspecToMarkdownPath)(normalized),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Treat as markdown path (e.g. README.md or docs/deploy.md)
|
|
60
|
+
const mdPath = normalized.endsWith(".md") ? normalized : normalized + ".md";
|
|
61
|
+
return {
|
|
62
|
+
docspecPath: (0, path_utils_1.markdownToDocspecPath)(mdPath),
|
|
63
|
+
markdownPath: mdPath,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate a new docspec file. Accepts either a markdown path (e.g. README.md, docs/deploy.md)
|
|
68
|
+
* or a docspec path under .docspec/ (e.g. .docspec/README.docspec.md).
|
|
69
|
+
* Writes to .docspec/ using the convention: markdown P.md -> .docspec/P.docspec.md
|
|
70
|
+
* @param inputPath Markdown or docspec path (repo-relative).
|
|
71
|
+
* @param repoRoot Optional repo root; when provided, the file is written under this directory instead of process.cwd().
|
|
72
|
+
*/
|
|
73
|
+
async function generateDocspec(inputPath, repoRoot) {
|
|
74
|
+
logger_1.logger.debug(`Generating docspec for: ${inputPath}`);
|
|
75
|
+
const { docspecPath, markdownPath } = resolveInput(inputPath);
|
|
76
|
+
logger_1.logger.debug(`Docspec file: ${docspecPath}, target markdown: ${markdownPath}`);
|
|
77
|
+
const content = (0, constants_1.getDocspecTemplate)(markdownPath);
|
|
78
|
+
logger_1.logger.debug(`Generated template with ${content.length} characters`);
|
|
79
|
+
const baseDir = repoRoot ? path.resolve(repoRoot) : process.cwd();
|
|
80
|
+
const docspecFull = path.join(baseDir, docspecPath);
|
|
81
|
+
const dir = path.dirname(docspecFull);
|
|
82
|
+
if (dir !== baseDir && dir !== ".") {
|
|
83
|
+
logger_1.logger.debug(`Creating directory: ${dir}`);
|
|
84
|
+
await fs.mkdir(dir, { recursive: true });
|
|
85
|
+
}
|
|
86
|
+
logger_1.logger.debug(`Writing file: ${docspecFull}`);
|
|
87
|
+
await fs.writeFile(docspecFull, content, "utf-8");
|
|
88
|
+
logger_1.logger.debug(`File written successfully: ${docspecFull}`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Generate docspec content as a string (for library use)
|
|
92
|
+
* @param targetFilePath Path to the target markdown file (e.g., "README.md")
|
|
93
|
+
*/
|
|
94
|
+
function generateDocspecContent(targetFilePath) {
|
|
95
|
+
return (0, constants_1.getDocspecTemplate)(targetFilePath);
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,0CAmBC;AAMD,wDAEC;AAvED;;;GAGG;AACH,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,CAAC;IACJ,CAAC;IACD,4DAA4D;IAC5D,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5E,OAAO;QACL,WAAW,EAAE,IAAA,kCAAqB,EAAC,MAAM,CAAC;QAC1C,YAAY,EAAE,MAAM;KACrB,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,eAAe,CAAC,SAAiB,EAAE,QAAiB;IACxE,eA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**
|
|
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;AAyFH,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,CAyDzG"}
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
// Use a function replacer so the value is inserted literally. A string replacer
|
|
119
|
+
// would interpret $&, $', $`, $n in the value as replacement patterns.
|
|
120
|
+
out = out.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), () => value);
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Generate the docspec file (if missing or overwrite), then build plan and implementation prompts.
|
|
126
|
+
* Returns combined prompt (implementation prompt with {{PLAN}} placeholder) and optional paths to write.
|
|
127
|
+
*/
|
|
128
|
+
async function buildDocspecGeneratePrompts(options) {
|
|
129
|
+
const repoRoot = path.resolve(options.repoRoot ?? process.cwd());
|
|
130
|
+
const mdPath = path.normalize(options.markdownPath).replace(/\\/g, "/");
|
|
131
|
+
const mdFull = path.join(repoRoot, mdPath);
|
|
132
|
+
const docspecPath = (0, path_utils_1.markdownToDocspecPath)(mdPath);
|
|
133
|
+
const docspecFull = path.join(repoRoot, docspecPath);
|
|
134
|
+
try {
|
|
135
|
+
await fs.access(mdFull);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new Error(`Markdown file not found: ${mdFull}`);
|
|
139
|
+
}
|
|
140
|
+
const docspecExists = await fs.access(docspecFull).then(() => true).catch(() => false);
|
|
141
|
+
if (docspecExists && !options.overwrite) {
|
|
142
|
+
throw new Error(`Docspec file already exists: ${docspecPath}. To overwrite, set overwrite to true.`);
|
|
143
|
+
}
|
|
144
|
+
await (0, create_1.generateDocspec)(mdPath, repoRoot);
|
|
145
|
+
const mdText = await fs.readFile(mdFull, "utf-8");
|
|
146
|
+
const docspecText = await fs.readFile(docspecFull, "utf-8");
|
|
147
|
+
const vars = {
|
|
148
|
+
md_path: mdPath,
|
|
149
|
+
md_text: mdText,
|
|
150
|
+
docspec_path: docspecPath,
|
|
151
|
+
docspec_text: docspecText,
|
|
152
|
+
};
|
|
153
|
+
const planPrompt = substitute(PLAN_TEMPLATE, vars);
|
|
154
|
+
const implPrompt = substitute(IMPL_TEMPLATE, vars);
|
|
155
|
+
const outPrompt = options.outputPromptPath
|
|
156
|
+
? path.resolve(repoRoot, options.outputPromptPath)
|
|
157
|
+
: undefined;
|
|
158
|
+
const outPlan = options.outputPlanPath
|
|
159
|
+
? path.resolve(repoRoot, options.outputPlanPath)
|
|
160
|
+
: undefined;
|
|
161
|
+
if (outPrompt) {
|
|
162
|
+
await fs.mkdir(path.dirname(outPrompt), { recursive: true });
|
|
163
|
+
await fs.writeFile(outPrompt, implPrompt, "utf-8");
|
|
164
|
+
}
|
|
165
|
+
if (outPlan) {
|
|
166
|
+
await fs.mkdir(path.dirname(outPlan), { recursive: true });
|
|
167
|
+
await fs.writeFile(outPlan, planPrompt, "utf-8");
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
planPrompt,
|
|
171
|
+
implPrompt,
|
|
172
|
+
outputPromptPath: outPrompt,
|
|
173
|
+
outputPlanPath: outPlan,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGH,kEA8DC;AAlKD,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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"}
|
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"}
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;AACX,CAAC,EALW,QAAQ,wBAAR,QAAQ,QAKnB;AAED,MAAM,MAAM;IAAZ;QACU,YAAO,GAAY,KAAK,CAAC;QACzB,aAAQ,GAAa,QAAQ,CAAC,IAAI,CAAC;IA0D7C,CAAC;IAxDC;;OAEG;IACH,UAAU,CAAC,OAAgB;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;QAChC,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,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,OAAO,OAAO,EAAE,EAAE,GAAG,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
|