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
package/README.md
CHANGED
|
@@ -2,11 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/specpilot)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://smithery.ai/servers/specpilot/specpilot)
|
|
5
6
|
|
|
6
7
|
SpecPilot is a spec-driven development (SDD) CLI for AI coding agents like Claude Code, Cursor, and ChatGPT. It initializes, validates, and syncs a `.specs/` directory so AI-assisted coding stays grounded in living requirements, architecture, and task specs instead of drifting from the codebase.
|
|
7
8
|
|
|
8
9
|

|
|
9
10
|
|
|
11
|
+
## MCP server
|
|
12
|
+
|
|
13
|
+
Prefer to stay inside your editor? SpecPilot also runs as a remote MCP server, so
|
|
14
|
+
Claude Code, Cursor or Copilot can run the whole onboarding itself - answering what
|
|
15
|
+
it can infer from your repo and asking you only the rest.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
claude mcp add --transport http specpilot https://init.specpilot.dev/mcp
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then ask your agent: *"Onboard this project with SpecPilot"*.
|
|
22
|
+
|
|
23
|
+
For Cursor, VS Code and other clients, add it as an HTTP (streamable) server:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"specpilot": {
|
|
29
|
+
"type": "http",
|
|
30
|
+
"url": "https://init.specpilot.dev/mcp"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
No install, no API key. Full setup notes: <https://specpilot.dev/mcp-setup>
|
|
37
|
+
|
|
10
38
|
## Quick Start
|
|
11
39
|
|
|
12
40
|
```bash
|
|
@@ -48,6 +76,7 @@ This AI-assisted approach ensures comprehensive, high-quality specifications tai
|
|
|
48
76
|
| `list` | Show available templates |
|
|
49
77
|
| `migrate` | Convert legacy `.project-spec` folder (rarely needed) |
|
|
50
78
|
| `refine [desc]` | Refine project specifications |
|
|
79
|
+
| `serve` | Serve a read-only local web UI over the current project's `.specs/` |
|
|
51
80
|
|
|
52
81
|
> **Tip — command aliases:** All commands have a short alias you can use instead of the full name.
|
|
53
82
|
> `init` → `i` · `validate` → `v` · `migrate` → `m` · `list` → `ls` · `refine` → `ref` · `archive` → `ar` · `add-specs` → `add` · `backfill` → `bf`
|
|
@@ -65,6 +94,7 @@ This AI-assisted approach ensures comprehensive, high-quality specifications tai
|
|
|
65
94
|
| `archive` | `--dry-run` · `--force` |
|
|
66
95
|
| `add-specs` | `--no-analysis` · `--deep-analysis` · `--no-prompts` |
|
|
67
96
|
| `backfill` | `--dir` · `--specs-name` · `--dry-run` · `--no-prompts` |
|
|
97
|
+
| `serve` | `--port` · `--poll` · `--open` |
|
|
68
98
|
|
|
69
99
|
> Run `specpilot <command> --help` for full flag descriptions and default values.
|
|
70
100
|
|
|
@@ -84,6 +114,27 @@ specpilot refine "REST API for user management" --update
|
|
|
84
114
|
specpilot validate --fix
|
|
85
115
|
```
|
|
86
116
|
|
|
117
|
+
## specpilot serve
|
|
118
|
+
|
|
119
|
+
Serve a read-only local web UI over the current project's `.specs/`. Run it from the project root (the folder that contains `.specs/`); press Ctrl+C to stop.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
specpilot serve # http://127.0.0.1:4321
|
|
123
|
+
specpilot serve --port 5000 --open
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Option | Default | Description |
|
|
127
|
+
| ------------- | ------- | ---------------------------------------------------------------------------------------- |
|
|
128
|
+
| `--port <n>` | `4321` | Port to listen on (127.0.0.1 only) |
|
|
129
|
+
| `--poll <ms>` | `1000` | Change-detection interval in ms (minimum 250); polling runs only while a page is open |
|
|
130
|
+
| `--open` | | Open the UI in the default browser |
|
|
131
|
+
|
|
132
|
+
- **Read-only**: re-reads files on every request and writes nothing.
|
|
133
|
+
- **Loopback only**: binds 127.0.0.1 only; rejects any Host header other than `127.0.0.1:<port>` or `localhost:<port>` (403).
|
|
134
|
+
- **Live reload**: polls allowlisted files with `stat()` every `--poll` ms while a page is open, and pushes changed paths on `/api/events`; open pages update in place.
|
|
135
|
+
- **What it shows**: `.specs/`, `CLAUDE.md`, `AGENTS.md`, `.github/copilot-instructions.md`, `.claude/commands/`, `.claude/skills/` and `.github/prompts/`, as the files' own text.
|
|
136
|
+
- **Limits**: paths through symlinked folders, hidden files and `node_modules` are not shown.
|
|
137
|
+
|
|
87
138
|
## Supported Languages & Frameworks
|
|
88
139
|
|
|
89
140
|
### TypeScript
|
package/dist/cli.js
CHANGED
|
@@ -14,6 +14,7 @@ const refine_1 = require("./commands/refine");
|
|
|
14
14
|
const add_specs_1 = require("./commands/add-specs");
|
|
15
15
|
const archive_1 = require("./commands/archive");
|
|
16
16
|
const backfill_1 = require("./commands/backfill");
|
|
17
|
+
const serve_1 = require("./commands/serve");
|
|
17
18
|
const logger_1 = require("./utils/logger");
|
|
18
19
|
const packageJson = require('../package.json');
|
|
19
20
|
commander_1.program
|
|
@@ -100,6 +101,14 @@ commander_1.program
|
|
|
100
101
|
.option('--dry-run', 'Preview changes without writing any files')
|
|
101
102
|
.option('--no-prompts', 'Accept suggested devPrefix silently when team.devPrefix is missing')
|
|
102
103
|
.action(backfill_1.backfillCommand);
|
|
104
|
+
// Serve command
|
|
105
|
+
commander_1.program
|
|
106
|
+
.command('serve')
|
|
107
|
+
.description('Serve a read-only local web UI over this project\'s .specs/ (127.0.0.1 only)')
|
|
108
|
+
.option('-p, --port <number>', 'Port to listen on', '4321')
|
|
109
|
+
.option('--poll <ms>', 'How often to check spec files for changes, in ms (minimum 250)', '1000')
|
|
110
|
+
.option('--open', 'Open the UI in your default browser')
|
|
111
|
+
.action(serve_1.serveCommand);
|
|
103
112
|
commander_1.program.addHelpText('after', `
|
|
104
113
|
Aliases:
|
|
105
114
|
init → i validate → v migrate → m list → ls
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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oBAAY,CAAC,CAAC;AAExB,mBAAO,CAAC,WAAW,CAAC,OAAO,EAAE;;;;;;CAM5B,CAAC,CAAC;AAEH,+BAA+B;AAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,iDAAiD;AACjD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;IAC5B,MAAM,CAAC,cAAc,EAAE,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,eAAK,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,mBAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ServeOptions {
|
|
2
|
+
port?: string;
|
|
3
|
+
poll?: string;
|
|
4
|
+
open?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Runs until Ctrl+C; exits the process with 1 on any startup error. */
|
|
7
|
+
export declare function serveCommand(options: ServeOptions): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiBD,wEAAwE;AACxE,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCvE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.serveCommand = serveCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const specServer_1 = require("../utils/specServer");
|
|
12
|
+
const logger_1 = require("../utils/logger");
|
|
13
|
+
const packageJson = require('../../package.json');
|
|
14
|
+
const DEFAULT_PORT = 4321;
|
|
15
|
+
const DEFAULT_POLL_MS = 1000;
|
|
16
|
+
const MIN_POLL_MS = 250;
|
|
17
|
+
/** Open `url` in the default browser. The URL is built here, never taken from input. */
|
|
18
|
+
function openBrowser(url, logger) {
|
|
19
|
+
const [cmd, args] = process.platform === 'darwin' ? ['open', [url]]
|
|
20
|
+
: process.platform === 'win32' ? ['cmd', ['/c', 'start', '', url]]
|
|
21
|
+
: ['xdg-open', [url]];
|
|
22
|
+
const child = (0, child_process_1.spawn)(cmd, args, { stdio: 'ignore', detached: true });
|
|
23
|
+
child.on('error', () => logger.warn(`Could not open a browser. Open ${url} yourself.`));
|
|
24
|
+
child.unref();
|
|
25
|
+
}
|
|
26
|
+
/** Runs until Ctrl+C; exits the process with 1 on any startup error. */
|
|
27
|
+
async function serveCommand(options) {
|
|
28
|
+
const logger = new logger_1.Logger();
|
|
29
|
+
const root = process.cwd();
|
|
30
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(root, '.specs'))) {
|
|
31
|
+
logger.error('No .specs/ folder in this directory. Run `specpilot serve` from a project root, or `specpilot init` first.');
|
|
32
|
+
return process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const port = options.port === undefined ? DEFAULT_PORT : Number(options.port);
|
|
35
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
36
|
+
logger.error(`Invalid --port "${options.port}". Use a whole number from 1 to 65535.`);
|
|
37
|
+
return process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const pollMs = options.poll === undefined ? DEFAULT_POLL_MS : Number(options.poll);
|
|
40
|
+
if (!Number.isInteger(pollMs) || pollMs < MIN_POLL_MS) {
|
|
41
|
+
logger.error(`Invalid --poll "${options.poll}". Use a whole number of milliseconds, ${MIN_POLL_MS} or more.`);
|
|
42
|
+
return process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
let handle;
|
|
45
|
+
try {
|
|
46
|
+
handle = await (0, specServer_1.startSpecServer)(root, port, packageJson.version, { pollMs, log: m => logger.warn(m) });
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
if (err.code === 'EADDRINUSE') {
|
|
50
|
+
logger.error(`Port ${port} is already in use. Pick another with --port, e.g. \`specpilot serve --port ${port === 65535 ? 4322 : port + 1}\`.`);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
logger.error(`Could not start the server: ${err.message}`);
|
|
54
|
+
}
|
|
55
|
+
return process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
const url = `http://127.0.0.1:${port}`;
|
|
58
|
+
console.log(chalk_1.default.green(`SpecPilot is serving ${root} read-only at ${url}`));
|
|
59
|
+
console.log(chalk_1.default.gray('Open pages update when a spec file changes. Press Ctrl+C to stop.'));
|
|
60
|
+
if (options.open)
|
|
61
|
+
openBrowser(url, logger);
|
|
62
|
+
process.once('SIGINT', () => {
|
|
63
|
+
void handle.close().then(() => process.exit(0));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":";;;;;AA+BA,oCAyCC;AAxED,kDAA0B;AAC1B,iDAAsC;AACtC,2BAAgC;AAChC,+BAA4B;AAC5B,oDAAkE;AAClE,4CAAyC;AAEzC,MAAM,WAAW,GAAG,OAAO,CAAC,oBAA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AAK,CAAC,CAAC;QACjJ,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,+BAAgC,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,GAAG,GAAG,oBAAoB,IAAI,EAAE,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,wBAAwB,IAAI,iBAAiB,GAAG,EAAE,CAAC,CAAC,CAAC;IAC7E,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC,CAAC;IAC7F,IAAI,OAAO,CAAC,IAAI;QAAE,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAE3C,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC1B,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface SectionBounds {
|
|
2
|
+
/** Index of the heading line. */
|
|
3
|
+
start: number;
|
|
4
|
+
/** Index of the next `## ` heading, or `lines.length` — a section ends there, not at EOF. */
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Locate a `## ` section. The heading is matched against each line's trimmed text:
|
|
9
|
+
* exactly by default, or as a prefix when `prefix` is true (for headings that carry
|
|
10
|
+
* an ID suffix, e.g. `## Latest Entries [PROMPT-002]`). Returns null when absent.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findSectionBounds(lines: string[], heading: string, prefix?: boolean): SectionBounds | null;
|
|
13
|
+
//# sourceMappingURL=markdownSections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownSections.d.ts","sourceRoot":"","sources":["../../src/utils/markdownSections.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,6FAA6F;IAC7F,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,aAAa,GAAG,IAAI,CAKxG"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findSectionBounds = findSectionBounds;
|
|
4
|
+
/**
|
|
5
|
+
* Locate a `## ` section. The heading is matched against each line's trimmed text:
|
|
6
|
+
* exactly by default, or as a prefix when `prefix` is true (for headings that carry
|
|
7
|
+
* an ID suffix, e.g. `## Latest Entries [PROMPT-002]`). Returns null when absent.
|
|
8
|
+
*/
|
|
9
|
+
function findSectionBounds(lines, heading, prefix = false) {
|
|
10
|
+
const start = lines.findIndex(l => (prefix ? l.trim().startsWith(heading) : l.trim() === heading));
|
|
11
|
+
if (start === -1)
|
|
12
|
+
return null;
|
|
13
|
+
const next = lines.findIndex((l, i) => i > start && /^## /.test(l.trim()));
|
|
14
|
+
return { start, end: next === -1 ? lines.length : next };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=markdownSections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownSections.js","sourceRoot":"","sources":["../../src/utils/markdownSections.ts"],"names":[],"mappings":";;AAYA,8CAKC;AAVD;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,KAAe,EAAE,OAAe,EAAE,MAAM,GAAG,KAAK;IAChF,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC;IACnG,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3E,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashCommandGenerator.d.ts","sourceRoot":"","sources":["../../src/utils/slashCommandGenerator.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"slashCommandGenerator.d.ts","sourceRoot":"","sources":["../../src/utils/slashCommandGenerator.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EA6XxC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,qBAAqB;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAY,EAAmB,GAAG,IAAI;IAkB1F;;;;OAIG;IACH,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,OAAO,EACf,QAAQ,GAAE,YAAY,EAAmB,GACxC,MAAM,EAAE;IAeX,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,kBAAkB;CAG3B"}
|
|
@@ -212,31 +212,51 @@ archive_tasks() {
|
|
|
212
212
|
local file=".specs/planning/tasks.md"
|
|
213
213
|
local archive=".specs/planning/tasks-archive.md"
|
|
214
214
|
[ -f "$file" ] || return 0
|
|
215
|
-
local total
|
|
216
|
-
total=$(wc -l < "$file")
|
|
217
|
-
local completed_line
|
|
218
|
-
completed_line=$(grep -n '^## Completed$' "$file" | head -1 | cut -d: -f1)
|
|
219
|
-
[ -n "$completed_line" ] || return 0
|
|
220
|
-
|
|
221
|
-
local section_size=$((total - completed_line + 1))
|
|
222
|
-
if [ "$section_size" -le "$COMPLETED_LINE_LIMIT" ]; then return 0; fi
|
|
223
|
-
|
|
224
|
-
local entry_start=$((completed_line + 1))
|
|
225
|
-
while [ "$entry_start" -le "$total" ] && ! sed -n "\${entry_start}p" "$file" | grep -qE '^[0-9]+\\.'; do
|
|
226
|
-
entry_start=$((entry_start + 1))
|
|
227
|
-
done
|
|
228
|
-
if [ "$entry_start" -gt "$total" ]; then return 0; fi
|
|
229
|
-
|
|
230
|
-
local entry_count=$((total - entry_start + 1))
|
|
231
|
-
if [ "$entry_count" -le "$COMPLETED_KEEP_ENTRIES" ]; then return 0; fi
|
|
232
|
-
|
|
233
|
-
local archive_count=$((entry_count - COMPLETED_KEEP_ENTRIES))
|
|
234
|
-
local archive_end=$((entry_start + archive_count - 1))
|
|
235
215
|
|
|
236
|
-
|
|
237
|
-
|
|
216
|
+
# Mirrors the CLI's planCompletedArchive() line for line. The section runs from
|
|
217
|
+
# "## Completed" to the next "## " heading, not EOF. Sizes use the CLI's arithmetic,
|
|
218
|
+
# which counts one more line than wc -l at EOF, so the EOF section end is total + 2.
|
|
219
|
+
# Entries are numbered-list lines, or else the body rows of a table (header and
|
|
220
|
+
# separator stay put); a table keeps only as many rows as fit the line limit.
|
|
221
|
+
# Prints "<shape> <first> <last> <header>" as 1-based lines to move, or nothing.
|
|
222
|
+
local plan
|
|
223
|
+
plan=$(awk -v total="$(wc -l < "$file")" -v limit="$COMPLETED_LINE_LIMIT" -v keep_max="$COMPLETED_KEEP_ENTRIES" '
|
|
224
|
+
{ line[NR] = $0; t = $0; gsub(/^[ \\t]+|[ \\t]+$/, "", t); trimmed[NR] = t }
|
|
225
|
+
END {
|
|
226
|
+
for (i = 1; i <= NR; i++) if (trimmed[i] == "## Completed") { start = i; break }
|
|
227
|
+
if (!start) exit
|
|
228
|
+
end_ = total + 2
|
|
229
|
+
for (i = start + 1; i <= NR; i++) if (trimmed[i] ~ /^## /) { end_ = i; break }
|
|
230
|
+
size = end_ - start
|
|
231
|
+
if (size <= limit) exit
|
|
232
|
+
for (i = start + 1; i < end_; i++) if (line[i] ~ /^[0-9]+\\./) {
|
|
233
|
+
if (end_ - i <= keep_max) exit
|
|
234
|
+
print "list", i, end_ - keep_max - 1, 0
|
|
235
|
+
exit
|
|
236
|
+
}
|
|
237
|
+
for (i = start + 1; i < end_ - 1; i++) if (trimmed[i] ~ /^\\|/ && trimmed[i + 1] ~ /^\\|[ \\t:|-]+$/) {
|
|
238
|
+
body = i + 2; stop = body
|
|
239
|
+
while (stop < end_ && trimmed[stop] ~ /^\\|/) stop++
|
|
240
|
+
rows = stop - body
|
|
241
|
+
keep = limit - (size - rows); if (keep < 0) keep = 0; if (keep > keep_max) keep = keep_max
|
|
242
|
+
if (rows <= keep) exit
|
|
243
|
+
print "table", body, stop - keep - 1, i
|
|
244
|
+
exit
|
|
245
|
+
}
|
|
246
|
+
}' "$file")
|
|
247
|
+
[ -n "$plan" ] || return 0
|
|
248
|
+
local shape first last header
|
|
249
|
+
read -r shape first last header <<< "$plan"
|
|
250
|
+
|
|
251
|
+
{
|
|
252
|
+
echo "## Archived on $(timestamp)"; echo
|
|
253
|
+
if [ "$shape" = "table" ]; then sed -n "\${header},$((header + 1))p" "$file"; fi
|
|
254
|
+
sed -n "\${first},\${last}p" "$file"
|
|
255
|
+
echo; echo "---"; echo
|
|
256
|
+
} >> "$archive"
|
|
257
|
+
{ sed -n "1,$((first - 1))p" "$file"; sed -n "$((last + 1)),\\$p" "$file"; } > "$file.tmp"
|
|
238
258
|
mv "$file.tmp" "$file"
|
|
239
|
-
echo "Moved $
|
|
259
|
+
echo "Moved $((last - first + 1)) entries from $file -> $archive"
|
|
240
260
|
}
|
|
241
261
|
|
|
242
262
|
archive_prompts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashCommandGenerator.js","sourceRoot":"","sources":["../../src/utils/slashCommandGenerator.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,2BAA0D;AAW1D;;;GAGG;AACU,QAAA,cAAc,GAAmB;IAC5C;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,2DAA2D;QACxE,IAAI,EAAE;;;;;;;;8FAQoF;KAC3F;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,0DAA0D;QACvE,IAAI,EAAE;;;;;;wIAM8H;KACrI;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,6GAA6G;QAC1H,IAAI,EAAE;;;;;;;;;sOAS4N;KACnO;IACD;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,0EAA0E;QACvF,IAAI,EAAE;;;;;;;;+HAQqH;KAC5H;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oGAAoG;QACjH,YAAY,EAAE,eAAe;QAC7B,IAAI,EAAE;;;;;;;;;;4IAUkI;KACzI;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,qGAAqG;QAClH,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;QAC9B,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ySAiE+R;KACtS;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qGAAqG;QAClH,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACtC,IAAI,EAAE
|
|
1
|
+
{"version":3,"file":"slashCommandGenerator.js","sourceRoot":"","sources":["../../src/utils/slashCommandGenerator.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAC5B,2BAA0D;AAW1D;;;GAGG;AACU,QAAA,cAAc,GAAmB;IAC5C;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,2DAA2D;QACxE,IAAI,EAAE;;;;;;;;8FAQoF;KAC3F;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,0DAA0D;QACvE,IAAI,EAAE;;;;;;wIAM8H;KACrI;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,6GAA6G;QAC1H,IAAI,EAAE;;;;;;;;;sOAS4N;KACnO;IACD;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,0EAA0E;QACvF,IAAI,EAAE;;;;;;;;+HAQqH;KAC5H;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oGAAoG;QACjH,YAAY,EAAE,eAAe;QAC7B,IAAI,EAAE;;;;;;;;;;4IAUkI;KACzI;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,qGAAqG;QAClH,YAAY,EAAE,CAAC,MAAM,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,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAEO,iBAAiB,CAAC,OAAqB;QAC7C,MAAM,KAAK,GAAG,CAAC,gBAAgB,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACtD,IAAI,OAAO,CAAC,YAAY;YAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QAC/E,IAAI,OAAO,CAAC,YAAY;YAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1F,OAAO,QAAQ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;IAC7C,CAAC;IAEO,iBAAiB,CAAC,OAAqB;QAC7C,OAAO,qBAAqB,OAAO,CAAC,WAAW,WAAW,CAAC;IAC7D,CAAC;IAEO,kBAAkB,CAAC,OAAqB;QAC9C,OAAO,kCAAkC,OAAO,CAAC,WAAW,WAAW,CAAC;IAC1E,CAAC;CACF;AAlFD,sDAkFC"}
|
|
@@ -7,6 +7,19 @@ export interface ArchiveResult {
|
|
|
7
7
|
entries: ArchiveEntry[];
|
|
8
8
|
dryRun: boolean;
|
|
9
9
|
}
|
|
10
|
+
export interface CompletedArchivePlan {
|
|
11
|
+
/** Line indices [start, end) moved out of tasks.md. */
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
/** Table header + separator, repeated above the moved rows in the archive; empty for lists. */
|
|
15
|
+
tableHeader: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Decide what `specpilot archive` moves out of tasks.md's `## Completed` section, or null
|
|
19
|
+
* if nothing. The validator warns exactly when this returns non-null, so "validate warns"
|
|
20
|
+
* and "archive acts" can never disagree.
|
|
21
|
+
*/
|
|
22
|
+
export declare function planCompletedArchive(lines: string[]): CompletedArchivePlan | null;
|
|
10
23
|
export declare class SpecArchiver {
|
|
11
24
|
private findSpecsDir;
|
|
12
25
|
archive(projectDir: string, options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specArchiver.d.ts","sourceRoot":"","sources":["../../src/utils/specArchiver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"specArchiver.d.ts","sourceRoot":"","sources":["../../src/utils/specArchiver.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;CACjB;AAaD,MAAM,WAAW,oBAAoB;IACnC,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,+FAA+F;IAC/F,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,oBAAoB,GAAG,IAAI,CAgCjF;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY;IAQd,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBvF,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,YAAY;CA6BrB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpecArchiver = void 0;
|
|
4
|
+
exports.planCompletedArchive = planCompletedArchive;
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const path_1 = require("path");
|
|
7
|
+
const markdownSections_1 = require("./markdownSections");
|
|
6
8
|
const SPECS_DIR_CANDIDATES = ['.specs', '.project-spec', 'specs', 'specifications'];
|
|
7
9
|
/** Trim prompts.md to this many total lines after archiving. */
|
|
8
10
|
const PROMPTS_LINE_LIMIT = 100;
|
|
@@ -11,6 +13,48 @@ const PROMPTS_KEEP_LINES = 80;
|
|
|
11
13
|
const COMPLETED_LINE_LIMIT = 25;
|
|
12
14
|
/** How many Completed entries to retain in the active file. */
|
|
13
15
|
const COMPLETED_KEEP_ENTRIES = 20;
|
|
16
|
+
const TABLE_SEPARATOR = /^\|[\s:|-]+$/;
|
|
17
|
+
/**
|
|
18
|
+
* Decide what `specpilot archive` moves out of tasks.md's `## Completed` section, or null
|
|
19
|
+
* if nothing. The validator warns exactly when this returns non-null, so "validate warns"
|
|
20
|
+
* and "archive acts" can never disagree.
|
|
21
|
+
*/
|
|
22
|
+
function planCompletedArchive(lines) {
|
|
23
|
+
// The Completed section ends at the next `## ` heading, not at EOF — anything
|
|
24
|
+
// after it (e.g. `## Multi-Dev Notes`) is a separate section and must survive.
|
|
25
|
+
const bounds = (0, markdownSections_1.findSectionBounds)(lines, '## Completed');
|
|
26
|
+
if (!bounds)
|
|
27
|
+
return null;
|
|
28
|
+
const { start, end } = bounds;
|
|
29
|
+
const sectionSize = end - start;
|
|
30
|
+
if (sectionSize <= COMPLETED_LINE_LIMIT)
|
|
31
|
+
return null;
|
|
32
|
+
// List shape: skip past the heading and any notes/blank lines to the first numbered entry,
|
|
33
|
+
// then keep the last COMPLETED_KEEP_ENTRIES lines (oldest entries are at the top).
|
|
34
|
+
let entryStart = start + 1;
|
|
35
|
+
while (entryStart < end && !/^\d+\./.test(lines[entryStart]))
|
|
36
|
+
entryStart++;
|
|
37
|
+
if (entryStart < end) {
|
|
38
|
+
const entryCount = end - entryStart;
|
|
39
|
+
if (entryCount <= COMPLETED_KEEP_ENTRIES)
|
|
40
|
+
return null;
|
|
41
|
+
return { start: entryStart, end: entryStart + entryCount - COMPLETED_KEEP_ENTRIES, tableHeader: [] };
|
|
42
|
+
}
|
|
43
|
+
// Table shape: entries are the body rows under the header + separator, oldest first.
|
|
44
|
+
// Keep only as many rows as fit the line limit, so the section passes validation afterwards.
|
|
45
|
+
const header = lines.findIndex((l, i) => i > start && i < end - 1 && l.trim().startsWith('|') && TABLE_SEPARATOR.test(lines[i + 1].trim()));
|
|
46
|
+
if (header === -1)
|
|
47
|
+
return null;
|
|
48
|
+
const bodyStart = header + 2;
|
|
49
|
+
let bodyEnd = bodyStart;
|
|
50
|
+
while (bodyEnd < end && lines[bodyEnd].trim().startsWith('|'))
|
|
51
|
+
bodyEnd++;
|
|
52
|
+
const rows = bodyEnd - bodyStart;
|
|
53
|
+
const keep = Math.min(COMPLETED_KEEP_ENTRIES, Math.max(0, COMPLETED_LINE_LIMIT - (sectionSize - rows)));
|
|
54
|
+
if (rows <= keep)
|
|
55
|
+
return null;
|
|
56
|
+
return { start: bodyStart, end: bodyStart + rows - keep, tableHeader: [lines[header], lines[header + 1]] };
|
|
57
|
+
}
|
|
14
58
|
class SpecArchiver {
|
|
15
59
|
findSpecsDir(projectDir) {
|
|
16
60
|
for (const name of SPECS_DIR_CANDIDATES) {
|
|
@@ -34,9 +78,9 @@ class SpecArchiver {
|
|
|
34
78
|
result.entries.push(tasksEntry);
|
|
35
79
|
return result;
|
|
36
80
|
}
|
|
37
|
-
buildTimestampedBlock(content) {
|
|
81
|
+
buildTimestampedBlock(content, trim = true) {
|
|
38
82
|
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
39
|
-
return `## Archived on ${now}\n\n${content.trimEnd()}\n\n---\n\n`;
|
|
83
|
+
return `## Archived on ${now}\n\n${trim ? content.trimEnd() : content}\n\n---\n\n`;
|
|
40
84
|
}
|
|
41
85
|
archivePrompts(specsDir, dryRun) {
|
|
42
86
|
const filePath = (0, path_1.join)(specsDir, 'development', 'prompts.md');
|
|
@@ -49,7 +93,7 @@ class SpecArchiver {
|
|
|
49
93
|
// Anchor on the "## Latest Entries" heading (falls back to front matter close,
|
|
50
94
|
// then start of file) so boilerplate sections — Re-Anchor Prompt, etc. — are
|
|
51
95
|
// never mistaken for archivable log content.
|
|
52
|
-
let entryStartIdx =
|
|
96
|
+
let entryStartIdx = (0, markdownSections_1.findSectionBounds)(allLines, '## Latest Entries', true)?.start ?? -1;
|
|
53
97
|
if (entryStartIdx === -1) {
|
|
54
98
|
entryStartIdx = allLines[0]?.trim() === '---' ? allLines.findIndex((l, i) => i > 0 && l.trim() === '---') : -1;
|
|
55
99
|
}
|
|
@@ -79,41 +123,21 @@ class SpecArchiver {
|
|
|
79
123
|
const filePath = (0, path_1.join)(specsDir, 'planning', 'tasks.md');
|
|
80
124
|
if (!(0, fs_1.existsSync)(filePath))
|
|
81
125
|
return null;
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
if (completedIdx === -1)
|
|
86
|
-
return null;
|
|
87
|
-
// The Completed section ends at the next `## ` heading, not at EOF — anything
|
|
88
|
-
// after it (e.g. `## Multi-Dev Notes`) is a separate section and must survive.
|
|
89
|
-
let sectionEndIdx = allLines.findIndex((l, i) => i > completedIdx && /^## /.test(l.trim()));
|
|
90
|
-
if (sectionEndIdx === -1)
|
|
91
|
-
sectionEndIdx = allLines.length;
|
|
92
|
-
const trailingLines = allLines.slice(sectionEndIdx);
|
|
93
|
-
// Section size consistent with specValidator's check — measured to the section
|
|
94
|
-
// end, not EOF, so trailing sections never inflate it.
|
|
95
|
-
const sectionSize = sectionEndIdx - completedIdx;
|
|
96
|
-
if (sectionSize <= COMPLETED_LINE_LIMIT)
|
|
97
|
-
return null;
|
|
98
|
-
// Skip past the ## Completed heading and any notes/blank lines to find numbered entries
|
|
99
|
-
let entryStartIdx = completedIdx + 1;
|
|
100
|
-
while (entryStartIdx < sectionEndIdx && !/^\d+\./.test(allLines[entryStartIdx])) {
|
|
101
|
-
entryStartIdx++;
|
|
102
|
-
}
|
|
103
|
-
if (entryStartIdx >= sectionEndIdx)
|
|
104
|
-
return null;
|
|
105
|
-
const entryLines = allLines.slice(entryStartIdx, sectionEndIdx);
|
|
106
|
-
if (entryLines.length <= COMPLETED_KEEP_ENTRIES)
|
|
126
|
+
const allLines = (0, fs_1.readFileSync)(filePath, 'utf-8').split('\n');
|
|
127
|
+
const plan = planCompletedArchive(allLines);
|
|
128
|
+
if (!plan)
|
|
107
129
|
return null;
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const linesMoved = archiveEntries.length;
|
|
130
|
+
const moved = allLines.slice(plan.start, plan.end);
|
|
131
|
+
const linesMoved = moved.length;
|
|
111
132
|
const archivePath = (0, path_1.join)(specsDir, 'planning', 'tasks-archive.md');
|
|
112
|
-
|
|
133
|
+
// Table rows move byte for byte, so the table block is not trimmed.
|
|
134
|
+
const block = plan.tableHeader.length
|
|
135
|
+
? this.buildTimestampedBlock([...plan.tableHeader, ...moved].join('\n'), false)
|
|
136
|
+
: this.buildTimestampedBlock(moved.join('\n'));
|
|
113
137
|
if (!dryRun) {
|
|
114
138
|
const existing = (0, fs_1.existsSync)(archivePath) ? (0, fs_1.readFileSync)(archivePath, 'utf-8') : '';
|
|
115
139
|
(0, fs_1.writeFileSync)(archivePath, existing + block);
|
|
116
|
-
(0, fs_1.writeFileSync)(filePath, [...allLines.slice(0,
|
|
140
|
+
(0, fs_1.writeFileSync)(filePath, [...allLines.slice(0, plan.start), ...allLines.slice(plan.end)].join('\n'));
|
|
117
141
|
}
|
|
118
142
|
return {
|
|
119
143
|
file: 'planning/tasks.md',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specArchiver.js","sourceRoot":"","sources":["../../src/utils/specArchiver.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"specArchiver.js","sourceRoot":"","sources":["../../src/utils/specArchiver.ts"],"names":[],"mappings":";;;AAyCA,oDAgCC;AAzED,2BAA6D;AAC7D,+BAA4B;AAC5B,yDAAuD;AAavD,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,e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OWED_FILES: string[];
|
|
2
|
+
export declare const ALLOWED_DIRS: string[];
|
|
3
|
+
/** Upper bound on files one scan returns, so a huge tree cannot make each poll expensive. */
|
|
4
|
+
export declare const MAX_SCAN_FILES = 2000;
|
|
5
|
+
/**
|
|
6
|
+
* Map a requested project-relative path to a real file the server may read, or null.
|
|
7
|
+
* Rejects NUL, backslashes, absolute paths and `..` segments; no folder on the way may be a
|
|
8
|
+
* symlink (the scanner does not follow them either); after resolving a symlinked file the
|
|
9
|
+
* target must still be inside the project root and still inside the allowlist.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveAllowedPath(root: string, requested: string): string | null;
|
|
12
|
+
export interface AllowedScan {
|
|
13
|
+
/** Project-relative, `/`-joined paths in walk order: the allowlisted files, then each folder sorted. */
|
|
14
|
+
files: string[];
|
|
15
|
+
/** Folders that exist but could not be listed (EACCES, EPERM): their contents are unknown, not gone. */
|
|
16
|
+
unreadable: string[];
|
|
17
|
+
/** True when the scan stopped at `max` files. */
|
|
18
|
+
capped: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Every path a request may name: the allowlisted files, plus every non-hidden file under the
|
|
22
|
+
* allowlisted folders, skipping `node_modules` and dot-folders such as `.git`. Stops at `max`.
|
|
23
|
+
* Only directory listings are read here, never file content, and nothing here throws.
|
|
24
|
+
*/
|
|
25
|
+
export declare function listAllowedFiles(root: string, max?: number): AllowedScan;
|
|
26
|
+
//# sourceMappingURL=specPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specPaths.d.ts","sourceRoot":"","sources":["../../src/utils/specPaths.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,UAAgE,CAAC;AAC3F,eAAO,MAAM,YAAY,UAA0E,CAAC;AAEpG,6FAA6F;AAC7F,eAAO,MAAM,cAAc,OAAO,CAAC;AAYnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiBjF;AAED,MAAM,WAAW,WAAW;IAC1B,wGAAwG;IACxG,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,wGAAwG;IACxG,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAiB,GAAG,WAAW,CAsBhF"}
|