specpilot 2.2.3 → 2.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 +51 -0
- package/dist/cli.js +9 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +66 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/utils/markdownSections.d.ts +13 -0
- package/dist/utils/markdownSections.d.ts.map +1 -0
- package/dist/utils/markdownSections.js +16 -0
- package/dist/utils/markdownSections.js.map +1 -0
- package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
- package/dist/utils/slashCommandGenerator.js +43 -23
- package/dist/utils/slashCommandGenerator.js.map +1 -1
- package/dist/utils/specArchiver.d.ts +13 -0
- package/dist/utils/specArchiver.d.ts.map +1 -1
- package/dist/utils/specArchiver.js +57 -33
- package/dist/utils/specArchiver.js.map +1 -1
- package/dist/utils/specPaths.d.ts +26 -0
- package/dist/utils/specPaths.d.ts.map +1 -0
- package/dist/utils/specPaths.js +92 -0
- package/dist/utils/specPaths.js.map +1 -0
- package/dist/utils/specPoller.d.ts +22 -0
- package/dist/utils/specPoller.d.ts.map +1 -0
- package/dist/utils/specPoller.js +119 -0
- package/dist/utils/specPoller.js.map +1 -0
- package/dist/utils/specReader.d.ts +30 -0
- package/dist/utils/specReader.d.ts.map +1 -0
- package/dist/utils/specReader.js +120 -0
- package/dist/utils/specReader.js.map +1 -0
- package/dist/utils/specServer.d.ts +60 -0
- package/dist/utils/specServer.d.ts.map +1 -0
- package/dist/utils/specServer.js +259 -0
- package/dist/utils/specServer.js.map +1 -0
- package/dist/utils/specValidator.d.ts.map +1 -1
- package/dist/utils/specValidator.js +5 -13
- package/dist/utils/specValidator.js.map +1 -1
- package/package.json +11 -4
- package/ui/app.css +299 -0
- package/ui/app.js +340 -0
- package/ui/favicon.svg +25 -0
- package/ui/index.html +171 -0
- package/ui/md.js +81 -0
- package/ui/route.js +25 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_SCAN_FILES = exports.ALLOWED_DIRS = exports.ALLOWED_FILES = void 0;
|
|
4
|
+
exports.resolveAllowedPath = resolveAllowedPath;
|
|
5
|
+
exports.listAllowedFiles = listAllowedFiles;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
// What `specpilot serve` may read (REQ-002.H.4, SEC-004.8), shared by the server and the
|
|
9
|
+
// live-reload poller so both see exactly the same set of files (ARCH-003.16).
|
|
10
|
+
exports.ALLOWED_FILES = ['CLAUDE.md', 'AGENTS.md', '.github/copilot-instructions.md'];
|
|
11
|
+
exports.ALLOWED_DIRS = ['.specs/', '.claude/commands/', '.claude/skills/', '.github/prompts/'];
|
|
12
|
+
/** Upper bound on files one scan returns, so a huge tree cannot make each poll expensive. */
|
|
13
|
+
exports.MAX_SCAN_FILES = 2000;
|
|
14
|
+
/**
|
|
15
|
+
* Allowlisted, and below an allowlisted folder no segment is hidden or `node_modules`: the same
|
|
16
|
+
* rule `listAllowedFiles()` walks by, so what the server serves is exactly what the poller watches.
|
|
17
|
+
*/
|
|
18
|
+
function isAllowlisted(rel) {
|
|
19
|
+
if (exports.ALLOWED_FILES.includes(rel))
|
|
20
|
+
return true;
|
|
21
|
+
const dir = exports.ALLOWED_DIRS.find(d => rel.startsWith(d) && rel.length > d.length);
|
|
22
|
+
return !!dir && rel.slice(dir.length).split('/').every(s => s !== '' && !s.startsWith('.') && s !== 'node_modules');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Map a requested project-relative path to a real file the server may read, or null.
|
|
26
|
+
* Rejects NUL, backslashes, absolute paths and `..` segments; no folder on the way may be a
|
|
27
|
+
* symlink (the scanner does not follow them either); after resolving a symlinked file the
|
|
28
|
+
* target must still be inside the project root and still inside the allowlist.
|
|
29
|
+
*/
|
|
30
|
+
function resolveAllowedPath(root, requested) {
|
|
31
|
+
if (!requested || requested.includes('\0') || requested.includes('\\'))
|
|
32
|
+
return null;
|
|
33
|
+
if ((0, path_1.isAbsolute)(requested) || path_1.posix.isAbsolute(requested))
|
|
34
|
+
return null;
|
|
35
|
+
if (requested.split('/').includes('..'))
|
|
36
|
+
return null;
|
|
37
|
+
const rel = path_1.posix.normalize(requested);
|
|
38
|
+
if (!isAllowlisted(rel))
|
|
39
|
+
return null;
|
|
40
|
+
try {
|
|
41
|
+
const realRoot = (0, fs_1.realpathSync)(root);
|
|
42
|
+
if ((0, fs_1.realpathSync)((0, path_1.dirname)((0, path_1.join)(root, rel))) !== (0, path_1.join)(realRoot, (0, path_1.dirname)(rel)))
|
|
43
|
+
return null;
|
|
44
|
+
const real = (0, fs_1.realpathSync)((0, path_1.join)(root, rel));
|
|
45
|
+
const back = (0, path_1.relative)(realRoot, real);
|
|
46
|
+
if (!back || back === '..' || back.startsWith('..' + path_1.sep) || (0, path_1.isAbsolute)(back))
|
|
47
|
+
return null;
|
|
48
|
+
if (!isAllowlisted(back.split(path_1.sep).join('/')))
|
|
49
|
+
return null;
|
|
50
|
+
return (0, fs_1.statSync)(real).isFile() ? real : null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Every path a request may name: the allowlisted files, plus every non-hidden file under the
|
|
58
|
+
* allowlisted folders, skipping `node_modules` and dot-folders such as `.git`. Stops at `max`.
|
|
59
|
+
* Only directory listings are read here, never file content, and nothing here throws.
|
|
60
|
+
*/
|
|
61
|
+
function listAllowedFiles(root, max = exports.MAX_SCAN_FILES) {
|
|
62
|
+
const scan = { files: [...exports.ALLOWED_FILES], unreadable: [], capped: false };
|
|
63
|
+
const walk = (rel) => {
|
|
64
|
+
let entries;
|
|
65
|
+
try {
|
|
66
|
+
entries = (0, fs_1.readdirSync)((0, path_1.join)(root, rel), { withFileTypes: true });
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
const code = err.code;
|
|
70
|
+
if (code !== 'ENOENT' && code !== 'ENOTDIR')
|
|
71
|
+
scan.unreadable.push(rel);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
for (const e of entries.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
|
|
75
|
+
if (scan.capped)
|
|
76
|
+
return;
|
|
77
|
+
if (e.name.startsWith('.') || e.name === 'node_modules')
|
|
78
|
+
continue;
|
|
79
|
+
const p = `${rel}/${e.name}`;
|
|
80
|
+
if (e.isDirectory())
|
|
81
|
+
walk(p);
|
|
82
|
+
else if (scan.files.length >= max)
|
|
83
|
+
scan.capped = true;
|
|
84
|
+
else
|
|
85
|
+
scan.files.push(p);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
for (const d of exports.ALLOWED_DIRS)
|
|
89
|
+
walk(d.slice(0, -1));
|
|
90
|
+
return scan;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=specPaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specPaths.js","sourceRoot":"","sources":["../../src/utils/specPaths.ts"],"names":[],"mappings":";;;AA4BA,gDAiBC;AAgBD,4CAsBC;AAnFD,2BAAyD;AACzD,+BAAuE;AAEvE,yFAAyF;AACzF,8EAA8E;AAEjE,QAAA,aAAa,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,iCAAiC,CAAC,CAAC;AAC9E,QAAA,YAAY,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AAEpG,6FAA6F;AAChF,QAAA,cAAc,GAAG,IAAI,CAAC;AAEnC;;;GAGG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,qBAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;I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AI,IAAI,KAAK,SAAS;gBAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvE,OAAO;QACT,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACzF,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO;YACxB,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc;gBAAE,SAAS;YAClE,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7B,IAAI,CAAC,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,CAAC,CAAC,CAAC;iBACxB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG;gBAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;;gBACjD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,oBAAY;QAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface PollerOptions {
|
|
2
|
+
/** Idle interval between scans. */
|
|
3
|
+
intervalMs: number;
|
|
4
|
+
/** After a change, re-check this often until a check finds nothing new. */
|
|
5
|
+
settleMs?: number;
|
|
6
|
+
/** Emit anyway once a burst has lasted this long. */
|
|
7
|
+
maxSettleMs?: number;
|
|
8
|
+
/** Called once per settled burst with the changed project-relative paths, sorted. */
|
|
9
|
+
onChange: (paths: string[]) => void;
|
|
10
|
+
/** Where the one-time "scan capped" notice goes. */
|
|
11
|
+
log?: (message: string) => void;
|
|
12
|
+
maxFiles?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Poller {
|
|
15
|
+
start(): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
readonly running: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** The paths one scan would watch right now (for tests and diagnostics). */
|
|
20
|
+
export declare function watchedFiles(root: string, maxFiles?: number): string[];
|
|
21
|
+
export declare function createPoller(root: string, opts: PollerOptions): Poller;
|
|
22
|
+
//# sourceMappingURL=specPoller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specPoller.d.ts","sourceRoot":"","sources":["../../src/utils/specPoller.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpC,oDAAoD;IACpD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;IACb,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAwBD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAiB,GAAG,MAAM,EAAE,CAE9E;AAYD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAiEtE"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watchedFiles = watchedFiles;
|
|
4
|
+
exports.createPoller = createPoller;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const specPaths_1 = require("./specPaths");
|
|
8
|
+
/** stat() every allowlisted file. ENOENT (gone since readdir) → absent; EACCES or any other error → keep what we knew. */
|
|
9
|
+
function scan(root, prev, maxFiles) {
|
|
10
|
+
const { files, unreadable, capped } = (0, specPaths_1.listAllowedFiles)(root, maxFiles);
|
|
11
|
+
const snap = new Map();
|
|
12
|
+
for (const path of files) {
|
|
13
|
+
try {
|
|
14
|
+
const st = (0, fs_1.statSync)((0, path_1.join)(root, path));
|
|
15
|
+
// Only what the server would actually serve (regular file, symlinks resolved inside the allowlist).
|
|
16
|
+
if (st.isFile() && (0, specPaths_1.resolveAllowedPath)(root, path))
|
|
17
|
+
snap.set(path, { mtimeMs: st.mtimeMs, size: st.size, ino: st.ino });
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err.code === 'ENOENT')
|
|
21
|
+
continue;
|
|
22
|
+
const known = prev.get(path);
|
|
23
|
+
if (known)
|
|
24
|
+
snap.set(path, known);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// A folder we could not list: its files are unknown this time, not deleted.
|
|
28
|
+
for (const dir of unreadable) {
|
|
29
|
+
for (const [path, entry] of prev)
|
|
30
|
+
if (path.startsWith(dir + '/') && !snap.has(path))
|
|
31
|
+
snap.set(path, entry);
|
|
32
|
+
}
|
|
33
|
+
return { snap, capped };
|
|
34
|
+
}
|
|
35
|
+
/** The paths one scan would watch right now (for tests and diagnostics). */
|
|
36
|
+
function watchedFiles(root, maxFiles = specPaths_1.MAX_SCAN_FILES) {
|
|
37
|
+
return [...scan(root, new Map(), maxFiles).snap.keys()].sort();
|
|
38
|
+
}
|
|
39
|
+
function diff(a, b) {
|
|
40
|
+
const changed = new Set();
|
|
41
|
+
for (const [path, x] of a) {
|
|
42
|
+
const y = b.get(path);
|
|
43
|
+
if (!y || y.mtimeMs !== x.mtimeMs || y.size !== x.size || y.ino !== x.ino)
|
|
44
|
+
changed.add(path);
|
|
45
|
+
}
|
|
46
|
+
for (const path of b.keys())
|
|
47
|
+
if (!a.has(path))
|
|
48
|
+
changed.add(path);
|
|
49
|
+
return [...changed].sort();
|
|
50
|
+
}
|
|
51
|
+
function createPoller(root, opts) {
|
|
52
|
+
const settleMs = opts.settleMs ?? 150;
|
|
53
|
+
const maxSettleMs = opts.maxSettleMs ?? 2000;
|
|
54
|
+
const maxFiles = opts.maxFiles ?? specPaths_1.MAX_SCAN_FILES;
|
|
55
|
+
let timer = null;
|
|
56
|
+
let prev = new Map();
|
|
57
|
+
let pending = new Set();
|
|
58
|
+
let burstStart = 0;
|
|
59
|
+
let warnedCap = false;
|
|
60
|
+
const check = () => {
|
|
61
|
+
const { snap, capped } = scan(root, prev, maxFiles);
|
|
62
|
+
if (capped && !warnedCap) {
|
|
63
|
+
warnedCap = true;
|
|
64
|
+
opts.log?.(`specpilot serve: watching the first ${maxFiles} files only; changes to the rest are not detected.`);
|
|
65
|
+
}
|
|
66
|
+
const changed = diff(prev, snap);
|
|
67
|
+
prev = snap;
|
|
68
|
+
return changed;
|
|
69
|
+
};
|
|
70
|
+
const tick = () => {
|
|
71
|
+
timer = null;
|
|
72
|
+
let changed = [];
|
|
73
|
+
try {
|
|
74
|
+
changed = check();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Nothing in a scan should throw; if something does, keep polling rather than die.
|
|
78
|
+
}
|
|
79
|
+
changed.forEach(p => pending.add(p));
|
|
80
|
+
const settling = pending.size > 0;
|
|
81
|
+
if (settling && !burstStart)
|
|
82
|
+
burstStart = Date.now();
|
|
83
|
+
if (settling && changed.length && Date.now() - burstStart < maxSettleMs) {
|
|
84
|
+
timer = setTimeout(tick, settleMs);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (settling) {
|
|
88
|
+
const paths = [...pending].sort();
|
|
89
|
+
pending = new Set();
|
|
90
|
+
burstStart = 0;
|
|
91
|
+
opts.onChange(paths);
|
|
92
|
+
}
|
|
93
|
+
if (poller.running)
|
|
94
|
+
timer = setTimeout(tick, opts.intervalMs);
|
|
95
|
+
};
|
|
96
|
+
let active = false;
|
|
97
|
+
const poller = {
|
|
98
|
+
start() {
|
|
99
|
+
if (active)
|
|
100
|
+
return;
|
|
101
|
+
active = true;
|
|
102
|
+
prev = scan(root, new Map(), maxFiles).snap;
|
|
103
|
+
timer = setTimeout(tick, opts.intervalMs);
|
|
104
|
+
},
|
|
105
|
+
stop() {
|
|
106
|
+
active = false;
|
|
107
|
+
if (timer)
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
timer = null;
|
|
110
|
+
pending = new Set();
|
|
111
|
+
burstStart = 0;
|
|
112
|
+
},
|
|
113
|
+
get running() {
|
|
114
|
+
return active;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
return poller;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=specPoller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specPoller.js","sourceRoot":"","sources":["../../src/utils/specPoller.ts"],"names":[],"mappings":";;AA4DA,oCAEC;AAYD,oCAiEC;AA3ID,2BAA8B;AAC9B,+BAA4B;AAC5B,2CAAmF;AAmCnF,0HAA0H;AAC1H,SAAS,IAAI,CAAC,IAAY,EAAE,IAAc,EAAE,QAAgB;IAC1D,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAA,4BAAgB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACvE,MAAM,IAAI,GAAa,I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,GAAG,CAAC,CAAC;YACf,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,MAAM,CAAC,OAAO;YAAE,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAChE,CAAC,CAAC;IAEF,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,MAAM,MAAM,GAAW;QACrB,KAAK;YACH,IAAI,MAAM;gBAAE,OAAO;YACnB,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC;YAC5C,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI;YACF,MAAM,GAAG,KAAK,CAAC;YACf,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,KAAK,GAAG,IAAI,CAAC;YACb,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;YACpB,UAAU,GAAG,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,OAAO;YACT,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface SpecMeta {
|
|
2
|
+
fileID?: string;
|
|
3
|
+
version?: string;
|
|
4
|
+
lastUpdated?: string;
|
|
5
|
+
contributors?: string[];
|
|
6
|
+
relatedFiles?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface TaskRow {
|
|
9
|
+
id: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CompletedRow {
|
|
13
|
+
num: string;
|
|
14
|
+
id: string;
|
|
15
|
+
description: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TasksData {
|
|
18
|
+
backlog: TaskRow[];
|
|
19
|
+
currentSprint: TaskRow[];
|
|
20
|
+
completed: CompletedRow[];
|
|
21
|
+
/** Table rows with fewer cells than their section's columns, verbatim. */
|
|
22
|
+
malformed: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface SpecsData {
|
|
25
|
+
files: Record<string, SpecMeta>;
|
|
26
|
+
tasks?: TasksData;
|
|
27
|
+
}
|
|
28
|
+
/** Parse `.specs/`-relative path → contents into per-file metadata and tasks.md rows. */
|
|
29
|
+
export declare function readSpecs(files: Record<string, string>): SpecsData;
|
|
30
|
+
//# sourceMappingURL=specReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specReader.d.ts","sourceRoot":"","sources":["../../src/utils/specReader.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,0EAA0E;IAC1E,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAKD,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAQlE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readSpecs = readSpecs;
|
|
4
|
+
const markdownSections_1 = require("./markdownSections");
|
|
5
|
+
const SCALAR_KEYS = ['fileID', 'version', 'lastUpdated'];
|
|
6
|
+
const LIST_KEYS = ['contributors', 'relatedFiles'];
|
|
7
|
+
/** Parse `.specs/`-relative path → contents into per-file metadata and tasks.md rows. */
|
|
8
|
+
function readSpecs(files) {
|
|
9
|
+
const result = { files: {} };
|
|
10
|
+
for (const [path, content] of Object.entries(files)) {
|
|
11
|
+
const lines = content.split('\n');
|
|
12
|
+
result.files[path] = parseMeta(/\.ya?ml$/.test(path) ? yamlCommentLines(lines) : frontMatterLines(lines));
|
|
13
|
+
if (path === 'planning/tasks.md')
|
|
14
|
+
result.tasks = parseTasks(lines);
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
function frontMatterLines(lines) {
|
|
19
|
+
if (lines[0]?.trim() !== '---')
|
|
20
|
+
return [];
|
|
21
|
+
const close = lines.findIndex((l, i) => i > 0 && l.trim() === '---');
|
|
22
|
+
return close === -1 ? [] : lines.slice(1, close);
|
|
23
|
+
}
|
|
24
|
+
function yamlCommentLines(lines) {
|
|
25
|
+
const out = [];
|
|
26
|
+
for (const l of lines) {
|
|
27
|
+
if (!l.trim().startsWith('#'))
|
|
28
|
+
break;
|
|
29
|
+
out.push(l.trim().replace(/^#\s?/, ''));
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
function unquote(v) {
|
|
34
|
+
return /^(["']).*\1$/.test(v) ? v.slice(1, -1) : v;
|
|
35
|
+
}
|
|
36
|
+
// Hand-parsed rather than js-yaml: real front matter such as
|
|
37
|
+
// `lastUpdated: 2026-09-05 (BL-049 cross-ref: …)` makes js-yaml throw, and its
|
|
38
|
+
// default schema would coerce dates and versions (`5.10` → 5.1).
|
|
39
|
+
function parseMeta(lines) {
|
|
40
|
+
const meta = {};
|
|
41
|
+
for (let i = 0; i < lines.length; i++) {
|
|
42
|
+
const m = /^(\w+):\s*(.*)$/.exec(lines[i]);
|
|
43
|
+
if (!m)
|
|
44
|
+
continue;
|
|
45
|
+
const [, key, raw] = m;
|
|
46
|
+
const value = raw.trim();
|
|
47
|
+
if (SCALAR_KEYS.includes(key)) {
|
|
48
|
+
meta[key] = unquote(value);
|
|
49
|
+
}
|
|
50
|
+
else if (LIST_KEYS.includes(key)) {
|
|
51
|
+
let text = value;
|
|
52
|
+
if (text === '' && lines[i + 1]?.trim().startsWith('['))
|
|
53
|
+
text = lines[++i].trim();
|
|
54
|
+
let items;
|
|
55
|
+
if (text === '') {
|
|
56
|
+
// Block list: `contributors:\n - a`
|
|
57
|
+
items = [];
|
|
58
|
+
while (lines[i + 1]?.trim().startsWith('- '))
|
|
59
|
+
items.push(lines[++i].trim().slice(2));
|
|
60
|
+
}
|
|
61
|
+
else if (text.startsWith('[')) {
|
|
62
|
+
// Flow list, possibly spread over lines: `relatedFiles:\n [\n a,\n b,\n ]`
|
|
63
|
+
while (!text.includes(']') && i + 1 < lines.length)
|
|
64
|
+
text += ' ' + lines[++i].trim();
|
|
65
|
+
const close = text.indexOf(']');
|
|
66
|
+
items = text.slice(1, close === -1 ? undefined : close).split(',');
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
items = [text];
|
|
70
|
+
}
|
|
71
|
+
meta[key] = items.map(s => unquote(s.trim())).filter(Boolean);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return meta;
|
|
75
|
+
}
|
|
76
|
+
function parseTasks(lines) {
|
|
77
|
+
const malformed = [];
|
|
78
|
+
const rows = (heading, cols) => {
|
|
79
|
+
const b = (0, markdownSections_1.findSectionBounds)(lines, heading);
|
|
80
|
+
return b ? tableRows(lines, b, cols, malformed) : [];
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
backlog: rows('## Backlog', 2).map(([id, description]) => ({ id, description })),
|
|
84
|
+
currentSprint: rows('## Current Sprint', 2).map(([id, description]) => ({ id, description })),
|
|
85
|
+
completed: rows('## Completed', 3).map(([num, id, description]) => ({ num, id, description })),
|
|
86
|
+
malformed,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const SEPARATOR = /^\|[\s:|-]+$/;
|
|
90
|
+
// Splits on the first `cols - 1` pipes only; the last cell takes the rest of the row,
|
|
91
|
+
// because descriptions contain literal `|` inside backticks (e.g. `'rest' | 'cli'`).
|
|
92
|
+
function tableRows(lines, { start, end }, cols, malformed) {
|
|
93
|
+
const out = [];
|
|
94
|
+
for (let i = start + 1; i < end; i++) {
|
|
95
|
+
const line = lines[i].trim();
|
|
96
|
+
if (!line.startsWith('|') || SEPARATOR.test(line))
|
|
97
|
+
continue;
|
|
98
|
+
if (SEPARATOR.test(lines[i + 1]?.trim() ?? ''))
|
|
99
|
+
continue; // header row
|
|
100
|
+
let rest = line.slice(1);
|
|
101
|
+
if (rest.endsWith('|'))
|
|
102
|
+
rest = rest.slice(0, -1);
|
|
103
|
+
const cells = [];
|
|
104
|
+
for (let c = 0; c < cols - 1; c++) {
|
|
105
|
+
const p = rest.indexOf('|');
|
|
106
|
+
if (p === -1)
|
|
107
|
+
break;
|
|
108
|
+
cells.push(rest.slice(0, p).trim());
|
|
109
|
+
rest = rest.slice(p + 1);
|
|
110
|
+
}
|
|
111
|
+
if (cells.length < cols - 1) {
|
|
112
|
+
malformed.push(lines[i]);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
cells.push(rest.trim());
|
|
116
|
+
out.push(cells);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=specReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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C,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACzB,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACxB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Server } from 'http';
|
|
2
|
+
/** DNS-rebinding guard: only the loopback names this server was reached on. */
|
|
3
|
+
export declare function isAllowedHost(host: string | undefined, port: number): boolean;
|
|
4
|
+
/** Current branch from .git/HEAD (worktree `.git` files and detached HEADs included), or null. */
|
|
5
|
+
export declare function readBranch(root: string): string | null;
|
|
6
|
+
export interface NavFile {
|
|
7
|
+
path: string;
|
|
8
|
+
frontMatter: Record<string, string> | null;
|
|
9
|
+
}
|
|
10
|
+
/** Everything `GET /api/specs` returns: project metadata, readSpecs() output, the nav tree. */
|
|
11
|
+
export declare function buildSpecsPayload(root: string, specpilotVersion: string): {
|
|
12
|
+
project: {
|
|
13
|
+
name: string | null;
|
|
14
|
+
root: string;
|
|
15
|
+
branch: string | null;
|
|
16
|
+
specpilotVersion: string;
|
|
17
|
+
};
|
|
18
|
+
files: Record<string, import("./specReader").SpecMeta>;
|
|
19
|
+
tasks: {
|
|
20
|
+
intro: string;
|
|
21
|
+
backlog: import("./specReader").TaskRow[];
|
|
22
|
+
currentSprint: import("./specReader").TaskRow[];
|
|
23
|
+
completed: import("./specReader").CompletedRow[];
|
|
24
|
+
malformed: string[];
|
|
25
|
+
} | null;
|
|
26
|
+
nav: {
|
|
27
|
+
specs: string[];
|
|
28
|
+
instructions: {
|
|
29
|
+
path: string;
|
|
30
|
+
exists: boolean;
|
|
31
|
+
bytes: number;
|
|
32
|
+
}[];
|
|
33
|
+
commands: NavFile[];
|
|
34
|
+
skills: NavFile[];
|
|
35
|
+
prompts: NavFile[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/** Most `/api/events` streams open at once; the next one gets 503 (SEC-004.9). */
|
|
39
|
+
export declare const MAX_EVENT_STREAMS = 8;
|
|
40
|
+
export interface SpecServerOptions {
|
|
41
|
+
/** Change-detection interval in ms (`--poll`). */
|
|
42
|
+
pollMs?: number;
|
|
43
|
+
/** Heartbeat comment interval for event streams. */
|
|
44
|
+
heartbeatMs?: number;
|
|
45
|
+
/** Poller settle interval after a change (tests shorten it). */
|
|
46
|
+
settleMs?: number;
|
|
47
|
+
/** One-time notices, e.g. the scan cap. */
|
|
48
|
+
log?: (message: string) => void;
|
|
49
|
+
}
|
|
50
|
+
export interface SpecServer {
|
|
51
|
+
server: Server;
|
|
52
|
+
/** Open event streams right now. */
|
|
53
|
+
streams(): number;
|
|
54
|
+
/** End every event stream, clear every timer, then close the listener. */
|
|
55
|
+
close(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export declare function createSpecServer(root: string, specpilotVersion: string, opts?: SpecServerOptions): SpecServer;
|
|
58
|
+
/** Listen on 127.0.0.1 only. Rejects with the listen error (e.g. EADDRINUSE). */
|
|
59
|
+
export declare function startSpecServer(root: string, port: number, specpilotVersion: string, opts?: SpecServerOptions): Promise<SpecServer>;
|
|
60
|
+
//# sourceMappingURL=specServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specServer.d.ts","sourceRoot":"","sources":["../../src/utils/specServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,EAAkB,MAAM,MAAM,CAAC;AAwB7E,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG7E;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAetD;AAgBD,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,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