specpilot 2.2.4 → 2.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 +25 -0
- package/dist/cli.js +10 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/archive.d.ts.map +1 -1
- package/dist/commands/archive.js +5 -1
- package/dist/commands/archive.js.map +1 -1
- package/dist/commands/serve.d.ts +9 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +68 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
- package/dist/utils/slashCommandGenerator.js +117 -26
- package/dist/utils/slashCommandGenerator.js.map +1 -1
- package/dist/utils/specArchiver.d.ts +22 -0
- package/dist/utils/specArchiver.d.ts.map +1 -1
- package/dist/utils/specArchiver.js +121 -26
- 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 +21 -0
- package/dist/utils/specReader.d.ts.map +1 -1
- package/dist/utils/specReader.js +26 -3
- package/dist/utils/specReader.js.map +1 -1
- package/dist/utils/specServer.d.ts +65 -0
- package/dist/utils/specServer.d.ts.map +1 -0
- package/dist/utils/specServer.js +345 -0
- package/dist/utils/specServer.js.map +1 -0
- package/dist/utils/specValidator.d.ts +3 -1
- package/dist/utils/specValidator.d.ts.map +1 -1
- package/dist/utils/specValidator.js +44 -11
- package/dist/utils/specValidator.js.map +1 -1
- package/dist/utils/taskMover.d.ts +50 -0
- package/dist/utils/taskMover.d.ts.map +1 -0
- package/dist/utils/taskMover.js +131 -0
- package/dist/utils/taskMover.js.map +1 -0
- package/package.json +2 -3
- package/ui/app.css +306 -0
- package/ui/app.js +408 -0
- package/ui/favicon.svg +25 -0
- package/ui/index.html +172 -0
- package/ui/md.js +81 -0
- package/ui/route.js +25 -0
package/README.md
CHANGED
|
@@ -76,6 +76,7 @@ This AI-assisted approach ensures comprehensive, high-quality specifications tai
|
|
|
76
76
|
| `list` | Show available templates |
|
|
77
77
|
| `migrate` | Convert legacy `.project-spec` folder (rarely needed) |
|
|
78
78
|
| `refine [desc]` | Refine project specifications |
|
|
79
|
+
| `serve` | Serve a local web UI over the current project's `.specs/` (task moves unless `--read-only`) |
|
|
79
80
|
|
|
80
81
|
> **Tip — command aliases:** All commands have a short alias you can use instead of the full name.
|
|
81
82
|
> `init` → `i` · `validate` → `v` · `migrate` → `m` · `list` → `ls` · `refine` → `ref` · `archive` → `ar` · `add-specs` → `add` · `backfill` → `bf`
|
|
@@ -93,6 +94,7 @@ This AI-assisted approach ensures comprehensive, high-quality specifications tai
|
|
|
93
94
|
| `archive` | `--dry-run` · `--force` |
|
|
94
95
|
| `add-specs` | `--no-analysis` · `--deep-analysis` · `--no-prompts` |
|
|
95
96
|
| `backfill` | `--dir` · `--specs-name` · `--dry-run` · `--no-prompts` |
|
|
97
|
+
| `serve` | `--port` · `--poll` · `--read-only` · `--open` |
|
|
96
98
|
|
|
97
99
|
> Run `specpilot <command> --help` for full flag descriptions and default values.
|
|
98
100
|
|
|
@@ -112,6 +114,29 @@ specpilot refine "REST API for user management" --update
|
|
|
112
114
|
specpilot validate --fix
|
|
113
115
|
```
|
|
114
116
|
|
|
117
|
+
## specpilot serve
|
|
118
|
+
|
|
119
|
+
Serve a local web UI over the current project's `.specs/`, where you can also move tasks between Backlog and Current Sprint. 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
|
+
| `--read-only` | | No task moves: the UI only reads, with no drag handles and no write route |
|
|
131
|
+
| `--open` | | Open the UI in the default browser |
|
|
132
|
+
|
|
133
|
+
- **Task moves**: drag a row, or use `Alt+Up/Down` to reorder and `Alt+Left/Right` to move between Backlog and Current Sprint. A move changes exactly one line of `.specs/planning/tasks.md` and nothing else, and offers Undo; Completed rows do not move. If the file changed on disk since the page loaded, the move is refused and the page redraws. Start with `--read-only` to turn moves off.
|
|
134
|
+
- **Nothing else is written**: `.specs/planning/tasks.md` is the only file the server can change; everything else is read on every request.
|
|
135
|
+
- **Loopback only**: binds 127.0.0.1 only; rejects any Host header other than `127.0.0.1:<port>` or `localhost:<port>` (403).
|
|
136
|
+
- **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.
|
|
137
|
+
- **What it shows**: `.specs/`, `CLAUDE.md`, `AGENTS.md`, `.github/copilot-instructions.md`, `.claude/commands/`, `.claude/skills/` and `.github/prompts/`, as the files' own text.
|
|
138
|
+
- **Limits**: paths through symlinked folders, hidden files and `node_modules` are not shown. Task moves are refused, not approximated, when they cannot change exactly one line: a section with no table yet (a fresh project's `[TODO]`), a move involving the file's last line when it has no trailing newline, and a `tasks.md` that is not valid UTF-8. If an editor saves `tasks.md` in the same instant the server writes it, that save can be overwritten; git keeps it recoverable.
|
|
139
|
+
|
|
115
140
|
## Supported Languages & Frameworks
|
|
116
141
|
|
|
117
142
|
### 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,15 @@ 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 local web UI over this project\'s .specs/ (127.0.0.1 only; task moves unless --read-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('--read-only', 'Turn off task moves: the page only reads')
|
|
111
|
+
.option('--open', 'Open the UI in your default browser')
|
|
112
|
+
.action(serve_1.serveCommand);
|
|
103
113
|
commander_1.program.addHelpText('after', `
|
|
104
114
|
Aliases:
|
|
105
115
|
init → i validate → v migrate → m list → ls
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,0CAA8C;AAC9C,kDAAsD;AACtD,gDAAoD;AACpD,0CAA8C;AAC9C,8CAAkD;AAClD,oDAAuD;AACvD,gDAAoD;AACpD,kDAAsD;AACtD,2CAAwC;AAExC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/C,mBAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,qEAAqE,CAAC;KAClF,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAEhC,qBAAqB;AACrB,mBAAO;K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AAI,CAAC,0CAA0C,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,mBAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/commands/archive.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAsBD,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/commands/archive.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAsBD,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,iBA4D3D"}
|
package/dist/commands/archive.js
CHANGED
|
@@ -85,8 +85,12 @@ async function archiveCommand(options) {
|
|
|
85
85
|
}
|
|
86
86
|
const archiver = new specArchiver_1.SpecArchiver();
|
|
87
87
|
const result = await archiver.archive(projectDir, { dryRun: options.dryRun });
|
|
88
|
+
for (const r of result.refused) {
|
|
89
|
+
logger.warn(`⚠ ${r.file} was not archived: ${r.reason}`);
|
|
90
|
+
}
|
|
88
91
|
if (result.entries.length === 0) {
|
|
89
|
-
|
|
92
|
+
if (!result.refused.length)
|
|
93
|
+
logger.success('✅ All .specs/ files are within limits. Nothing to archive.');
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
92
96
|
console.log('');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/commands/archive.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,
|
|
1
|
+
{"version":3,"file":"archive.js","sourceRoot":"","s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
|
+
readOnly?: boolean;
|
|
5
|
+
open?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Runs until Ctrl+C; exits the process with 1 on any startup error. */
|
|
8
|
+
export declare function serveCommand(options: ServeOptions): Promise<void>;
|
|
9
|
+
//# 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,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiBD,wEAAwE;AACxE,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CvE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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, readOnly: !!options.readOnly, 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} at ${url}`));
|
|
59
|
+
console.log(chalk_1.default.gray(options.readOnly
|
|
60
|
+
? 'Read-only: nothing will be written. Open pages update when a spec file changes. Press Ctrl+C to stop.'
|
|
61
|
+
: 'Tasks can be moved in the page (only .specs/planning/tasks.md is written). Open pages update when a spec file changes. Press Ctrl+C to stop.'));
|
|
62
|
+
if (options.open)
|
|
63
|
+
openBrowser(url, logger);
|
|
64
|
+
process.once('SIGINT', () => {
|
|
65
|
+
void handle.close().then(() => process.exit(0));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":";;;;;AAgCA,oCA+CC;AA/ED,kDAA0B;AAC1B,iDAAsC;AACtC,2BAAgC;AAChC,+BAA4B;AAC5B,oDAAkE;AAClE,4CAAyC;AAEzC,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AASlD,MAAM,YAAY,GAAG,IAAI,CAAC;AAC1B,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,wFAAwF;AACxF,SAAS,WAAW,CAAC,GAAW,EAAE,MAAc;IAC9C,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GACf,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,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K,CAAC,IAAI,CACR,OAAO,CAAC,QAAQ;QACd,CAAC,CAAC,uGAAuG;QACzG,CAAC,CAAC,8IAA8I,CACnJ,CACF,CAAC;IACF,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"}
|
|
@@ -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,EAwdxC,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"}
|
|
@@ -178,34 +178,125 @@ archive_prompts() {
|
|
|
178
178
|
local file=".specs/development/prompts.md"
|
|
179
179
|
local archive=".specs/development/prompts-archive.md"
|
|
180
180
|
[ -f "$file" ] || return 0
|
|
181
|
-
local total
|
|
182
|
-
total=$(wc -l < "$file")
|
|
183
|
-
if [ "$total" -le "$PROMPTS_LINE_LIMIT" ]; then return 0; fi
|
|
184
|
-
|
|
185
|
-
# Anchor on "## Latest Entries" so boilerplate (Re-Anchor Prompt, etc.) is never
|
|
186
|
-
# mistaken for archivable log content; fall back to front-matter close, then line 0.
|
|
187
|
-
local anchor_line
|
|
188
|
-
anchor_line=$(grep -n '^## Latest Entries' "$file" | head -1 | cut -d: -f1)
|
|
189
|
-
if [ -z "$anchor_line" ]; then
|
|
190
|
-
if [ "$(sed -n '1p' "$file")" = "---" ]; then
|
|
191
|
-
anchor_line=$(awk 'NR>1 && $0=="---" {print NR; exit}' "$file")
|
|
192
|
-
else
|
|
193
|
-
anchor_line=0
|
|
194
|
-
fi
|
|
195
|
-
fi
|
|
196
|
-
local body_start=$((anchor_line + 1))
|
|
197
|
-
local body_lines=$((total - anchor_line))
|
|
198
|
-
local keep=$((PROMPTS_KEEP_LINES - anchor_line))
|
|
199
|
-
if [ "$keep" -lt 50 ]; then keep=50; fi
|
|
200
|
-
if [ "$body_lines" -le "$keep" ]; then return 0; fi
|
|
201
181
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
182
|
+
# Mirrors the CLI's planPromptsArchive() line for line. The log is the list under
|
|
183
|
+
# "## Latest Entries", else the table under "## Prompt History". Each entry's date is the
|
|
184
|
+
# last "Month D, YYYY", "Mon. D, YYYY" or "YYYY-MM-DD" in it (a table row: its Date cell).
|
|
185
|
+
# All dated entries must run one way; the oldest whole entries then move until the file
|
|
186
|
+
# is within PROMPTS_KEEP_LINES, keeping at least one. Line counts use the CLI's arithmetic
|
|
187
|
+
# (wc -l + 1). Prints "MOVE <first> <last> <header>" (1-based lines; header 0 for a list),
|
|
188
|
+
# "REFUSE <reason>", or nothing.
|
|
189
|
+
local plan
|
|
190
|
+
plan=$(LC_ALL=C awk -v total="$(wc -l < "$file")" -v limit="$PROMPTS_LINE_LIMIT" -v keep="$PROMPTS_KEEP_LINES" '
|
|
191
|
+
function trim(s) { sub(/^[ \\t\\r]+/, "", s); sub(/[ \\t\\r]+$/, "", s); return s }
|
|
192
|
+
function word(c) { return c ~ /[A-Za-z0-9_]/ }
|
|
193
|
+
function iso(k) { return sprintf("%04d-%02d-%02d", int(k / 10000), int(k / 100) % 100, k % 100) }
|
|
194
|
+
function lastdate(s, key, pos, a, b, t, p, m, y, mo, d) {
|
|
195
|
+
key = 0; pos = 0
|
|
196
|
+
while (match(substr(s, pos + 1), /(January|February|March|April|May|June|July|August|September|October|November|December|Sept|Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\.? [0-9][0-9]?, [0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/)) {
|
|
197
|
+
a = pos + RSTART; b = a + RLENGTH; t = substr(s, a, RLENGTH)
|
|
198
|
+
# a > 1 guard: on macOS awk substr(s, 0, 1) returns the first character, not ""
|
|
199
|
+
if ((a > 1 && word(substr(s, a - 1, 1))) || word(substr(s, b, 1))) { pos = a; continue }
|
|
200
|
+
if (t ~ /^[0-9]/) { y = substr(t, 1, 4) + 0; mo = substr(t, 6, 2) + 0; d = substr(t, 9, 2) + 0 }
|
|
201
|
+
else { split(t, p, " "); m = p[1]; sub(/\\.$/, "", m); mo = MON[tolower(m)]; d = p[2] + 0; y = p[3] + 0 }
|
|
202
|
+
if (mo >= 1 && mo <= 12 && d >= 1 && d <= 31) key = y * 10000 + mo * 100 + d
|
|
203
|
+
pos = b - 1
|
|
204
|
+
}
|
|
205
|
+
return key
|
|
206
|
+
}
|
|
207
|
+
function excerpt(s, t, i, c, n, out) {
|
|
208
|
+
t = trim(s); n = 0; out = ""
|
|
209
|
+
for (i = 1; i <= length(t); i++) {
|
|
210
|
+
c = substr(t, i, 1)
|
|
211
|
+
if (ORD[c] < 128 || ORD[c] >= 192) n++
|
|
212
|
+
if (n > 60) return "\\"" out "…\\""
|
|
213
|
+
out = out c
|
|
214
|
+
}
|
|
215
|
+
return "\\"" t "\\""
|
|
216
|
+
}
|
|
217
|
+
BEGIN {
|
|
218
|
+
split("january jan february feb march mar april apr may june jun july jul august aug september sept sep october oct november nov december dec", nm, " ")
|
|
219
|
+
split("1 1 2 2 3 3 4 4 5 6 6 7 7 8 8 9 9 9 10 10 11 11 12 12", nv, " ")
|
|
220
|
+
for (i = 1; i <= 24; i++) MON[nm[i]] = nv[i] + 0
|
|
221
|
+
for (i = 1; i < 256; i++) ORD[sprintf("%c", i)] = i
|
|
222
|
+
}
|
|
223
|
+
{ line[NR] = $0; tl[NR] = trim($0) }
|
|
224
|
+
END {
|
|
225
|
+
L = total + 1
|
|
226
|
+
if (L <= limit) exit
|
|
227
|
+
n = 0; hdr = 0; s = 0
|
|
228
|
+
for (i = 1; i <= NR; i++) if (index(tl[i], "## Latest Entries") == 1) { s = i; break }
|
|
229
|
+
if (s) {
|
|
230
|
+
e = L + 1; for (i = s + 1; i <= NR; i++) if (tl[i] ~ /^## /) { e = i; break }
|
|
231
|
+
cur = 0
|
|
232
|
+
for (i = s + 1; i < e && i <= NR; i++) {
|
|
233
|
+
if (line[i] ~ /^[-*+] /) { n++; st[n] = i; en[n] = i; cur = 1 }
|
|
234
|
+
else if (cur && line[i] ~ /^[ \\t\\r]+[^ \\t\\r]/) en[n] = i
|
|
235
|
+
else cur = 0
|
|
236
|
+
}
|
|
237
|
+
for (k = 1; k <= n; k++) { txt = line[st[k]]; for (i = st[k] + 1; i <= en[k]; i++) txt = txt "\\n" line[i]; dt[k] = lastdate(txt) }
|
|
238
|
+
} else {
|
|
239
|
+
for (i = 1; i <= NR; i++) if (index(tl[i], "## Prompt History") == 1) { s = i; break }
|
|
240
|
+
if (!s) { print "REFUSE development/prompts.md has no \\"## Latest Entries\\" list or \\"## Prompt History\\" table, so there is nothing SpecPilot can archive safely."; exit }
|
|
241
|
+
e = L + 1; for (i = s + 1; i <= NR; i++) if (tl[i] ~ /^## /) { e = i; break }
|
|
242
|
+
for (i = s + 1; i < e - 1 && i < NR; i++) if (tl[i] ~ /^\\|/ && tl[i + 1] ~ /^\\|[ \\t:|-]+$/) { hdr = i; break }
|
|
243
|
+
if (hdr) {
|
|
244
|
+
col = 0; h = tl[hdr]; sub(/^\\|/, "", h); sub(/\\|$/, "", h); m = split(h, hc, "|")
|
|
245
|
+
for (j = 1; j <= m; j++) if (tolower(trim(hc[j])) == "date") { col = j; break }
|
|
246
|
+
for (i = hdr + 2; i < e && i <= NR && tl[i] ~ /^\\|/; i++) {
|
|
247
|
+
n++; st[n] = i; en[n] = i
|
|
248
|
+
if (col) { r = tl[i]; sub(/^\\|/, "", r); sub(/\\|$/, "", r); split(r, rc, "|"); dt[n] = lastdate(trim(rc[col])) }
|
|
249
|
+
else dt[n] = lastdate(line[i])
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (n < 2) exit
|
|
254
|
+
dir = 0; ps = 0; pd = 0
|
|
255
|
+
for (k = 1; k <= n; k++) {
|
|
256
|
+
if (!dt[k]) continue
|
|
257
|
+
if (ps && dt[k] != pd) {
|
|
258
|
+
step = dt[k] > pd ? 1 : -1
|
|
259
|
+
if (!dir) dir = step
|
|
260
|
+
else if (step != dir) {
|
|
261
|
+
print "REFUSE SpecPilot cannot tell which development/prompts.md entries are oldest, because their dates run both ways: " excerpt(line[ps]) " (" iso(pd) ") comes right before " excerpt(line[st[k]]) " (" iso(dt[k]) ") in a log that otherwise runs " (dir < 0 ? "newest first" : "oldest first") ". Put those entries in order and run it again."
|
|
262
|
+
exit
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
ps = st[k]; pd = dt[k]
|
|
266
|
+
}
|
|
267
|
+
if (!dir) { print "REFUSE SpecPilot cannot tell which development/prompts.md entries are oldest: fewer than two entries carry different dates."; exit }
|
|
268
|
+
for (k = 1; k < n; k++) {
|
|
269
|
+
if (dir < 0) { a = st[n - k + 1]; b = en[n] } else { a = st[1]; b = en[k] }
|
|
270
|
+
if (L - (b - a + 1) <= keep) break
|
|
271
|
+
}
|
|
272
|
+
print "MOVE", a, b, hdr
|
|
273
|
+
}' "$file")
|
|
274
|
+
[ -n "$plan" ] || return 0
|
|
275
|
+
case "$plan" in
|
|
276
|
+
REFUSE\\ *) echo "Not archived: \${plan#REFUSE }"; return 0 ;;
|
|
277
|
+
esac
|
|
278
|
+
local kind first last header
|
|
279
|
+
read -r kind first last header <<< "$plan"
|
|
280
|
+
|
|
281
|
+
# A file with no line break after its last line, whose moved block reaches that line: the
|
|
282
|
+
# CLI joins lines with "\\n", so the block still ends with a blank line in the archive and the
|
|
283
|
+
# kept file ends, still without a line break, at the line before the block.
|
|
284
|
+
local at_end=0
|
|
285
|
+
if [ -n "$(tail -c 1 "$file")" ] && [ "$last" -eq $(( $(wc -l < "$file") + 1 )) ]; then at_end=1; fi
|
|
286
|
+
{
|
|
287
|
+
echo "## Archived on $(timestamp)"; echo
|
|
288
|
+
if [ "$header" -gt 0 ]; then sed -n "\${header},$((header + 1))p" "$file"; fi
|
|
289
|
+
sed -n "\${first},\${last}p" "$file"
|
|
290
|
+
if [ "$at_end" = 1 ]; then echo; fi
|
|
291
|
+
echo; echo "---"; echo
|
|
292
|
+
} >> "$archive"
|
|
293
|
+
if [ "$at_end" = 1 ]; then
|
|
294
|
+
awk -v n=$((first - 1)) 'NR <= n { printf "%s%s", (NR > 1 ? "\\n" : ""), $0 }' "$file" > "$file.tmp"
|
|
295
|
+
else
|
|
296
|
+
{ sed -n "1,$((first - 1))p" "$file"; sed -n "$((last + 1)),\\$p" "$file"; } > "$file.tmp"
|
|
297
|
+
fi
|
|
207
298
|
mv "$file.tmp" "$file"
|
|
208
|
-
echo "Moved $
|
|
299
|
+
echo "Moved $((last - first + 1)) lines from $file -> $archive"
|
|
209
300
|
}
|
|
210
301
|
|
|
211
302
|
archive_tasks() {
|
|
@@ -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,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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,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"}
|
|
@@ -5,8 +5,30 @@ export interface ArchiveEntry {
|
|
|
5
5
|
}
|
|
6
6
|
export interface ArchiveResult {
|
|
7
7
|
entries: ArchiveEntry[];
|
|
8
|
+
/** Files over their limit that archive would not touch, and why (BL-061). */
|
|
9
|
+
refused: {
|
|
10
|
+
file: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
}[];
|
|
8
13
|
dryRun: boolean;
|
|
9
14
|
}
|
|
15
|
+
/** Trim prompts.md to this many total lines after archiving. */
|
|
16
|
+
export declare const PROMPTS_LINE_LIMIT = 100;
|
|
17
|
+
/** The last calendar date in the text as yyyymmdd, or null. No Date objects: no time zone can shift a day. */
|
|
18
|
+
export declare function lastDate(text: string): number | null;
|
|
19
|
+
export type PromptsArchivePlan = {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
tableHeader: string[];
|
|
23
|
+
} | {
|
|
24
|
+
refuse: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* Decide what \`specpilot archive\` moves out of prompts.md: the contiguous block of oldest entries
|
|
28
|
+
* that brings the file within PROMPTS_KEEP_LINES, a refusal with a plain reason, or null.
|
|
29
|
+
* The validator reports exactly this, so "validate warns" and "archive acts" cannot disagree.
|
|
30
|
+
*/
|
|
31
|
+
export declare function planPromptsArchive(lines: string[]): PromptsArchivePlan;
|
|
10
32
|
export interface CompletedArchivePlan {
|
|
11
33
|
/** Line indices [start, end) moved out of tasks.md. */
|
|
12
34
|
start: number;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,6EAA6E;IAC7E,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,MAAM,EAAE,OAAO,CAAC;CACjB;AAID,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AActC,8GAA8G;AAC9G,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOpD;AAmCD,MAAM,MAAM,kBAAkB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC;AAQnH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,kBAAkB,CAsCtE;AAOD,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;IA8BtB,OAAO,CAAC,YAAY;CA6BrB"}
|
|
@@ -1,14 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SpecArchiver = void 0;
|
|
3
|
+
exports.SpecArchiver = exports.PROMPTS_LINE_LIMIT = void 0;
|
|
4
|
+
exports.lastDate = lastDate;
|
|
5
|
+
exports.planPromptsArchive = planPromptsArchive;
|
|
4
6
|
exports.planCompletedArchive = planCompletedArchive;
|
|
5
7
|
const fs_1 = require("fs");
|
|
6
8
|
const path_1 = require("path");
|
|
7
9
|
const markdownSections_1 = require("./markdownSections");
|
|
8
10
|
const SPECS_DIR_CANDIDATES = ['.specs', '.project-spec', 'specs', 'specifications'];
|
|
9
11
|
/** Trim prompts.md to this many total lines after archiving. */
|
|
10
|
-
|
|
12
|
+
exports.PROMPTS_LINE_LIMIT = 100;
|
|
11
13
|
const PROMPTS_KEEP_LINES = 80;
|
|
14
|
+
// ---- prompts.md (BL-061): move whole entries, always the oldest, in whichever order the log runs.
|
|
15
|
+
const MONTHS = {
|
|
16
|
+
january: 1, jan: 1, february: 2, feb: 2, march: 3, mar: 3, april: 4, apr: 4, may: 5, june: 6, jun: 6,
|
|
17
|
+
july: 7, jul: 7, august: 8, aug: 8, september: 9, sept: 9, sep: 9, october: 10, oct: 10,
|
|
18
|
+
november: 11, nov: 11, december: 12, dec: 12,
|
|
19
|
+
};
|
|
20
|
+
// Longest names first so "September" beats "Sept" beats "Sep"; an abbreviation may end in a dot.
|
|
21
|
+
const MONTH_NAMES = 'January|February|March|April|May|June|July|August|September|October|November|December|Sept|Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sep|Oct|Nov|Dec';
|
|
22
|
+
const DATE_RE = new RegExp(`\\b(${MONTH_NAMES})\\.? (\\d{1,2}), (\\d{4})\\b|\\b(\\d{4})-(\\d{2})-(\\d{2})\\b`, 'g');
|
|
23
|
+
/** The last calendar date in the text as yyyymmdd, or null. No Date objects: no time zone can shift a day. */
|
|
24
|
+
function lastDate(text) {
|
|
25
|
+
let key = null;
|
|
26
|
+
for (const m of text.matchAll(DATE_RE)) {
|
|
27
|
+
const [y, mo, d] = m[1] ? [+m[3], MONTHS[m[1].toLowerCase()], +m[2]] : [+m[4], +m[5], +m[6]];
|
|
28
|
+
if (mo >= 1 && mo <= 12 && d >= 1 && d <= 31)
|
|
29
|
+
key = y * 10000 + mo * 100 + d;
|
|
30
|
+
}
|
|
31
|
+
return key;
|
|
32
|
+
}
|
|
33
|
+
/** The log's entries: list items under "## Latest Entries", else rows under "## Prompt History". */
|
|
34
|
+
function findLog(lines) {
|
|
35
|
+
const list = (0, markdownSections_1.findSectionBounds)(lines, '## Latest Entries', true);
|
|
36
|
+
if (list) {
|
|
37
|
+
const entries = [];
|
|
38
|
+
let cur = null;
|
|
39
|
+
for (let i = list.start + 1; i < list.end; i++) {
|
|
40
|
+
if (/^[-*+] /.test(lines[i]))
|
|
41
|
+
entries.push((cur = { start: i, end: i + 1, date: null }));
|
|
42
|
+
else if (cur && /^\s+\S/.test(lines[i]))
|
|
43
|
+
cur.end = i + 1; // indented continuation of the item
|
|
44
|
+
else
|
|
45
|
+
cur = null;
|
|
46
|
+
}
|
|
47
|
+
entries.forEach(e => (e.date = lastDate(lines.slice(e.start, e.end).join('\n'))));
|
|
48
|
+
return { entries, tableHeader: [] };
|
|
49
|
+
}
|
|
50
|
+
const table = (0, markdownSections_1.findSectionBounds)(lines, '## Prompt History', true);
|
|
51
|
+
if (!table)
|
|
52
|
+
return null;
|
|
53
|
+
const header = lines.findIndex((l, i) => i > table.start && i < table.end - 1 && l.trim().startsWith('|') && TABLE_SEPARATOR.test(lines[i + 1].trim()));
|
|
54
|
+
if (header === -1)
|
|
55
|
+
return { entries: [], tableHeader: [] };
|
|
56
|
+
const cells = (row) => row.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map(c => c.trim());
|
|
57
|
+
const dateCol = cells(lines[header]).findIndex(c => c.toLowerCase() === 'date');
|
|
58
|
+
const entries = [];
|
|
59
|
+
for (let i = header + 2; i < table.end && lines[i].trim().startsWith('|'); i++) {
|
|
60
|
+
entries.push({ start: i, end: i + 1, date: lastDate(dateCol >= 0 ? cells(lines[i])[dateCol] ?? '' : lines[i]) });
|
|
61
|
+
}
|
|
62
|
+
return { entries, tableHeader: [lines[header], lines[header + 1]] };
|
|
63
|
+
}
|
|
64
|
+
const excerpt = (line) => {
|
|
65
|
+
const t = line.trim();
|
|
66
|
+
return `"${t.length > 60 ? t.slice(0, 60) + '…' : t}"`;
|
|
67
|
+
};
|
|
68
|
+
const iso = (key) => `${Math.floor(key / 10000)}-${String(Math.floor(key / 100) % 100).padStart(2, '0')}-${String(key % 100).padStart(2, '0')}`;
|
|
69
|
+
/**
|
|
70
|
+
* Decide what \`specpilot archive\` moves out of prompts.md: the contiguous block of oldest entries
|
|
71
|
+
* that brings the file within PROMPTS_KEEP_LINES, a refusal with a plain reason, or null.
|
|
72
|
+
* The validator reports exactly this, so "validate warns" and "archive acts" cannot disagree.
|
|
73
|
+
*/
|
|
74
|
+
function planPromptsArchive(lines) {
|
|
75
|
+
if (lines.length <= exports.PROMPTS_LINE_LIMIT)
|
|
76
|
+
return null;
|
|
77
|
+
const log = findLog(lines);
|
|
78
|
+
if (!log) {
|
|
79
|
+
return { refuse: 'development/prompts.md has no "## Latest Entries" list or "## Prompt History" table, so there is nothing SpecPilot can archive safely.' };
|
|
80
|
+
}
|
|
81
|
+
const { entries } = log;
|
|
82
|
+
if (entries.length < 2)
|
|
83
|
+
return null; // at least one entry always stays: nothing movable
|
|
84
|
+
// Order from the entries' own dates: every step between dated entries must go the same way.
|
|
85
|
+
let dir = 0; // -1: newest first, +1: oldest first
|
|
86
|
+
let prevStart = -1;
|
|
87
|
+
let prevDate = 0;
|
|
88
|
+
for (const e of entries) {
|
|
89
|
+
if (e.date === null)
|
|
90
|
+
continue;
|
|
91
|
+
if (prevStart >= 0 && e.date !== prevDate) {
|
|
92
|
+
const step = e.date > prevDate ? 1 : -1;
|
|
93
|
+
if (!dir)
|
|
94
|
+
dir = step;
|
|
95
|
+
else if (step !== dir) {
|
|
96
|
+
return {
|
|
97
|
+
refuse: `SpecPilot cannot tell which development/prompts.md entries are oldest, because their dates run both ways: ${excerpt(lines[prevStart])} (${iso(prevDate)}) comes right before ${excerpt(lines[e.start])} (${iso(e.date)}) in a log that otherwise runs ${dir < 0 ? 'newest first' : 'oldest first'}. Put those entries in order and run it again.`,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
prevStart = e.start;
|
|
102
|
+
prevDate = e.date;
|
|
103
|
+
}
|
|
104
|
+
if (!dir)
|
|
105
|
+
return { refuse: 'SpecPilot cannot tell which development/prompts.md entries are oldest: fewer than two entries carry different dates.' };
|
|
106
|
+
// Move oldest entries, one at a time, until the file is within PROMPTS_KEEP_LINES; keep at least one.
|
|
107
|
+
const n = entries.length;
|
|
108
|
+
let start = 0;
|
|
109
|
+
let end = 0;
|
|
110
|
+
for (let k = 1; k < n; k++) {
|
|
111
|
+
[start, end] = dir < 0 ? [entries[n - k].start, entries[n - 1].end] : [entries[0].start, entries[k - 1].end];
|
|
112
|
+
if (lines.length - (end - start) <= PROMPTS_KEEP_LINES)
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return { start, end, tableHeader: log.tableHeader };
|
|
116
|
+
}
|
|
12
117
|
/** Archive tasks.md Completed section when it exceeds this many lines. */
|
|
13
118
|
const COMPLETED_LINE_LIMIT = 25;
|
|
14
119
|
/** How many Completed entries to retain in the active file. */
|
|
@@ -69,8 +174,8 @@ class SpecArchiver {
|
|
|
69
174
|
if (!specsDir) {
|
|
70
175
|
throw new Error('No .specs directory found. Run `specpilot init` first.');
|
|
71
176
|
}
|
|
72
|
-
const result = { entries: [], dryRun: options.dryRun };
|
|
73
|
-
const promptsEntry = this.archivePrompts(specsDir, options.dryRun);
|
|
177
|
+
const result = { entries: [], refused: [], dryRun: options.dryRun };
|
|
178
|
+
const promptsEntry = this.archivePrompts(specsDir, options.dryRun, result.refused);
|
|
74
179
|
if (promptsEntry)
|
|
75
180
|
result.entries.push(promptsEntry);
|
|
76
181
|
const tasksEntry = this.archiveTasks(specsDir, options.dryRun);
|
|
@@ -82,41 +187,31 @@ class SpecArchiver {
|
|
|
82
187
|
const now = new Date().toISOString().replace('T', ' ').slice(0, 19);
|
|
83
188
|
return `## Archived on ${now}\n\n${trim ? content.trimEnd() : content}\n\n---\n\n`;
|
|
84
189
|
}
|
|
85
|
-
archivePrompts(specsDir, dryRun) {
|
|
190
|
+
archivePrompts(specsDir, dryRun, refused) {
|
|
86
191
|
const filePath = (0, path_1.join)(specsDir, 'development', 'prompts.md');
|
|
87
192
|
if (!(0, fs_1.existsSync)(filePath))
|
|
88
193
|
return null;
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
194
|
+
const allLines = (0, fs_1.readFileSync)(filePath, 'utf-8').split('\n');
|
|
195
|
+
const plan = planPromptsArchive(allLines);
|
|
196
|
+
if (!plan)
|
|
92
197
|
return null;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// never mistaken for archivable log content.
|
|
96
|
-
let entryStartIdx = (0, markdownSections_1.findSectionBounds)(allLines, '## Latest Entries', true)?.start ?? -1;
|
|
97
|
-
if (entryStartIdx === -1) {
|
|
98
|
-
entryStartIdx = allLines[0]?.trim() === '---' ? allLines.findIndex((l, i) => i > 0 && l.trim() === '---') : -1;
|
|
99
|
-
}
|
|
100
|
-
entryStartIdx = entryStartIdx === -1 ? 0 : entryStartIdx + 1;
|
|
101
|
-
const preambleLines = allLines.slice(0, entryStartIdx);
|
|
102
|
-
const entryLines = allLines.slice(entryStartIdx);
|
|
103
|
-
const keepBodyCount = Math.max(50, PROMPTS_KEEP_LINES - preambleLines.length);
|
|
104
|
-
if (entryLines.length <= keepBodyCount)
|
|
198
|
+
if ('refuse' in plan) {
|
|
199
|
+
refused.push({ file: 'development/prompts.md', reason: plan.refuse });
|
|
105
200
|
return null;
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
const linesMoved = archiveLines.length;
|
|
201
|
+
}
|
|
202
|
+
const moved = allLines.slice(plan.start, plan.end);
|
|
109
203
|
const archivePath = (0, path_1.join)(specsDir, 'development', 'prompts-archive.md');
|
|
110
|
-
|
|
204
|
+
// Entries move byte for byte; a table block repeats its header and separator.
|
|
205
|
+
const block = this.buildTimestampedBlock([...plan.tableHeader, ...moved].join('\n'), false);
|
|
111
206
|
if (!dryRun) {
|
|
112
207
|
const existing = (0, fs_1.existsSync)(archivePath) ? (0, fs_1.readFileSync)(archivePath, 'utf-8') : '';
|
|
113
208
|
(0, fs_1.writeFileSync)(archivePath, existing + block);
|
|
114
|
-
(0, fs_1.writeFileSync)(filePath, [...
|
|
209
|
+
(0, fs_1.writeFileSync)(filePath, [...allLines.slice(0, plan.start), ...allLines.slice(plan.end)].join('\n'));
|
|
115
210
|
}
|
|
116
211
|
return {
|
|
117
212
|
file: 'development/prompts.md',
|
|
118
213
|
archiveFile: 'development/prompts-archive.md',
|
|
119
|
-
linesMoved,
|
|
214
|
+
linesMoved: moved.length,
|
|
120
215
|
};
|
|
121
216
|
}
|
|
122
217
|
archiveTasks(specsDir, dryRun) {
|