specpilot 2.7.0 → 2.8.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 +7 -5
- package/dist/commands/add-specs.d.ts.map +1 -1
- package/dist/commands/add-specs.js +3 -1
- package/dist/commands/add-specs.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/refine.d.ts.map +1 -1
- package/dist/commands/refine.js +2 -1
- package/dist/commands/refine.js.map +1 -1
- package/dist/commands/serve.d.ts +1 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +26 -3
- package/dist/commands/serve.js.map +1 -1
- package/dist/utils/addSpecsQuestions.d.ts +1 -1
- package/dist/utils/addSpecsQuestions.d.ts.map +1 -1
- package/dist/utils/addSpecsQuestions.js +1 -2
- package/dist/utils/addSpecsQuestions.js.map +1 -1
- package/dist/utils/agentConfigGenerator.d.ts +2 -2
- package/dist/utils/agentConfigGenerator.d.ts.map +1 -1
- package/dist/utils/agentConfigGenerator.js +7 -8
- package/dist/utils/agentConfigGenerator.js.map +1 -1
- package/dist/utils/ideConfigGenerator.d.ts +15 -20
- package/dist/utils/ideConfigGenerator.d.ts.map +1 -1
- package/dist/utils/ideConfigGenerator.js +46 -164
- package/dist/utils/ideConfigGenerator.js.map +1 -1
- package/dist/utils/projectRegistry.d.ts +63 -0
- package/dist/utils/projectRegistry.d.ts.map +1 -0
- package/dist/utils/projectRegistry.js +240 -0
- package/dist/utils/projectRegistry.js.map +1 -0
- package/dist/utils/slashCommandGenerator.d.ts +2 -1
- package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
- package/dist/utils/slashCommandGenerator.js +7 -4
- package/dist/utils/slashCommandGenerator.js.map +1 -1
- package/dist/utils/specBackfiller.js +1 -1
- package/dist/utils/specBackfiller.js.map +1 -1
- package/dist/utils/specGenerator.d.ts +11 -1
- package/dist/utils/specGenerator.d.ts.map +1 -1
- package/dist/utils/specGenerator.js +21 -10
- package/dist/utils/specGenerator.js.map +1 -1
- package/dist/utils/specServer.d.ts +3 -1
- package/dist/utils/specServer.d.ts.map +1 -1
- package/dist/utils/specServer.js +123 -10
- package/dist/utils/specServer.js.map +1 -1
- package/dist/utils/specSetup.d.ts.map +1 -1
- package/dist/utils/specSetup.js +1 -1
- package/dist/utils/specSetup.js.map +1 -1
- package/package.json +1 -1
- package/ui/app.css +43 -0
- package/ui/app.js +88 -12
- package/ui/index.html +26 -1
- package/ui/route.js +46 -3
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.IdeConfigGenerator = exports.GITATTRIBUTES_FILE = void 0;
|
|
4
|
+
exports.writeNew = writeNew;
|
|
7
5
|
const path_1 = require("path");
|
|
8
6
|
const fs_1 = require("fs");
|
|
9
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
10
7
|
/** IDE-specific overlay keys appended on top of the shared base settings.
|
|
11
8
|
* NOTE: These keys are aspirational — they are NOT confirmed in each IDE's
|
|
12
9
|
* official documentation. Unknown keys are silently ignored, but they are
|
|
@@ -50,15 +47,30 @@ const COPILOT_INSTRUCTIONS = '.github/copilot-instructions.md';
|
|
|
50
47
|
exports.GITATTRIBUTES_FILE = '.gitattributes';
|
|
51
48
|
/** Project-relative path of a project file, joined for this platform. */
|
|
52
49
|
const at = (projectDir, rel) => (0, path_1.join)(projectDir, ...rel.split('/'));
|
|
50
|
+
/**
|
|
51
|
+
* Create `path` with `content` only if nothing is there (BL-073): an existing file, or a link at the
|
|
52
|
+
* path itself, is never written or written through. Returns false when it was kept (EEXIST).
|
|
53
|
+
*/
|
|
54
|
+
function writeNew(path, content) {
|
|
55
|
+
try {
|
|
56
|
+
(0, fs_1.writeFileSync)(path, content, { flag: 'wx' });
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (err.code === 'EEXIST')
|
|
61
|
+
return false;
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
53
65
|
/**
|
|
54
66
|
* Generates IDE workspace settings (.vscode, .cursor, .windsurf, .antigravity).
|
|
55
67
|
* Each IDE gets a settings.json and extensions.json with a shared base config
|
|
56
68
|
* plus per-IDE overlay keys.
|
|
57
69
|
*/
|
|
58
70
|
class IdeConfigGenerator {
|
|
59
|
-
/** Entry point — routes to the correct IDE settings generator. */
|
|
71
|
+
/** Entry point — routes to the correct IDE settings generator. Returns the kept (existing) files. */
|
|
60
72
|
async generate(projectDir, context, ide) {
|
|
61
|
-
|
|
73
|
+
return this.generateIDESettings(projectDir, context, ide);
|
|
62
74
|
}
|
|
63
75
|
/** The files `generate()` writes, project-relative (BL-055); read from the same table as the writes. */
|
|
64
76
|
settingsTargets(ide) {
|
|
@@ -69,73 +81,26 @@ class IdeConfigGenerator {
|
|
|
69
81
|
aiContextTarget(ide) {
|
|
70
82
|
return AI_CONTEXT_FILES[ide.toLowerCase()] ?? COPILOT_INSTRUCTIONS;
|
|
71
83
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Generates .github/copilot-instructions.md with critical mandates.
|
|
74
|
-
* Read automatically by GitHub Copilot, Cursor, and other AI tools on every request.
|
|
75
|
-
* Always generated regardless of IDE choice.
|
|
76
|
-
*
|
|
77
|
-
* If the file already exists:
|
|
78
|
-
* - noPrompts=false → asks user: overwrite / append / skip
|
|
79
|
-
* - noPrompts=true → auto-skips and prints a warning
|
|
80
|
-
*/
|
|
81
84
|
/**
|
|
82
85
|
* Routes to the correct IDE-native AI context file based on the selected IDE.
|
|
83
86
|
* - vscode / codex → .github/copilot-instructions.md
|
|
84
87
|
* - cursor → .cursor/rules/specpilot.mdc
|
|
85
88
|
* - windsurf → .windsurfrules
|
|
86
89
|
* - antigravity → .antigravity/rules.md
|
|
90
|
+
* - claude-code → CLAUDE.md
|
|
91
|
+
* An existing file is kept (BL-073); returns it as kept, else [].
|
|
87
92
|
*/
|
|
88
|
-
|
|
93
|
+
generateAiContextFile(projectDir, context, ide) {
|
|
89
94
|
const key = ide.toLowerCase();
|
|
90
|
-
const
|
|
95
|
+
const rel = this.aiContextTarget(key);
|
|
96
|
+
const filePath = at(projectDir, rel);
|
|
91
97
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(filePath), { recursive: true });
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(0, fs_1.writeFileSync)(filePath, this.buildCopilotInstructions(context));
|
|
99
|
-
}
|
|
100
|
-
else if (key === 'claude-code') {
|
|
101
|
-
await this.generateClaudeMd(filePath, context, noPrompts);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// vscode, codex, and unknown IDEs → copilot-instructions.md
|
|
105
|
-
await this.generateCopilotInstructions(projectDir, context, noPrompts);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
async generateClaudeMd(filePath, context, noPrompts = false) {
|
|
109
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
110
|
-
(0, fs_1.writeFileSync)(filePath, this.buildClaudeMd(context));
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
// File already exists
|
|
114
|
-
if (noPrompts) {
|
|
115
|
-
console.log('\u26a0\ufe0f CLAUDE.md already exists \u2014 skipping (--no-prompts).\n' +
|
|
116
|
-
' Manually merge the SpecPilot mandates shown below into that file:\n\n' +
|
|
117
|
-
this.buildClaudeMdSection(context));
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const { action } = await inquirer_1.default.prompt([
|
|
121
|
-
{
|
|
122
|
-
type: 'list',
|
|
123
|
-
name: 'action',
|
|
124
|
-
message: '\u26a0\ufe0f CLAUDE.md already exists. What would you like to do?',
|
|
125
|
-
choices: [
|
|
126
|
-
{ name: 'Overwrite with SpecPilot template', value: 'o' },
|
|
127
|
-
{ name: 'Append SpecPilot section to existing file', value: 'a' },
|
|
128
|
-
{ name: 'Skip (keep existing file unchanged)', value: 's' },
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
]);
|
|
132
|
-
if (action === 'o') {
|
|
133
|
-
(0, fs_1.writeFileSync)(filePath, this.buildClaudeMd(context));
|
|
134
|
-
}
|
|
135
|
-
else if (action === 'a') {
|
|
136
|
-
(0, fs_1.appendFileSync)(filePath, '\n\n' + this.buildClaudeMdSection(context));
|
|
137
|
-
}
|
|
138
|
-
// action === 's' → leave file unchanged
|
|
98
|
+
const content = key === 'claude-code'
|
|
99
|
+
? this.buildClaudeMd(context)
|
|
100
|
+
: key === 'cursor'
|
|
101
|
+
? `---\ndescription: Project mandates and AI coding rules\nglobs:\nalwaysApply: true\n---\n\n` + this.buildCopilotInstructions(context)
|
|
102
|
+
: this.buildCopilotInstructions(context);
|
|
103
|
+
return writeNew(filePath, content) ? [] : [rel];
|
|
139
104
|
}
|
|
140
105
|
buildClaudeMd(context) {
|
|
141
106
|
const stack = context.framework
|
|
@@ -171,102 +136,14 @@ If you lose context mid-session, read \`.specs/project/project.yaml\` to restore
|
|
|
171
136
|
For a ready-made re-anchor prompt, see \`.specs/development/prompts.md \u2192 ## Re-Anchor Prompt\`.
|
|
172
137
|
`;
|
|
173
138
|
}
|
|
174
|
-
buildClaudeMdSection(context) {
|
|
175
|
-
const stack = context.framework
|
|
176
|
-
? `${context.language} / ${context.framework}`
|
|
177
|
-
: context.language;
|
|
178
|
-
return `## SpecPilot Mandates \u2014 ${context.projectName}
|
|
179
|
-
|
|
180
|
-
> Added by \`specpilot add-specs\`. These mandates apply alongside your existing instructions.
|
|
181
|
-
> Full context is in \`.specs/project/project.yaml\`.
|
|
182
|
-
|
|
183
|
-
### Project
|
|
184
|
-
|
|
185
|
-
- **Name:** ${context.projectName}
|
|
186
|
-
- **Stack:** ${stack}
|
|
187
|
-
- **Specs location:** \`.specs/\`
|
|
188
|
-
|
|
189
|
-
### \ud83d\udd34 Critical Mandates \u2014 Never violate, no exceptions
|
|
190
|
-
|
|
191
|
-
${this.buildCriticalMandatesMarkdown()}
|
|
192
|
-
|
|
193
|
-
### \ud83d\udfe1 Process Mandates
|
|
194
|
-
|
|
195
|
-
${this.buildProcessMandatesMarkdown()}
|
|
196
|
-
|
|
197
|
-
${this.buildContextRoutingTable()}
|
|
198
|
-
|
|
199
|
-
${this.buildCodePhilosophyMarkdown()}
|
|
200
|
-
`;
|
|
201
|
-
}
|
|
202
|
-
async generateCopilotInstructions(projectDir, context, noPrompts = false) {
|
|
203
|
-
const filePath = at(projectDir, COPILOT_INSTRUCTIONS);
|
|
204
|
-
(0, fs_1.mkdirSync)((0, path_1.dirname)(filePath), { recursive: true });
|
|
205
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
206
|
-
(0, fs_1.writeFileSync)(filePath, this.buildCopilotInstructions(context));
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
// File already exists
|
|
210
|
-
if (noPrompts) {
|
|
211
|
-
console.log('\u26a0\ufe0f .github/copilot-instructions.md already exists \u2014 skipping (--no-prompts).\n' +
|
|
212
|
-
' Manually merge the SpecPilot mandates shown below into that file:\n\n' +
|
|
213
|
-
this.buildCopilotSection(context));
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const { action } = await inquirer_1.default.prompt([
|
|
217
|
-
{
|
|
218
|
-
type: 'list',
|
|
219
|
-
name: 'action',
|
|
220
|
-
message: '⚠️ .github/copilot-instructions.md already exists. What would you like to do?',
|
|
221
|
-
choices: [
|
|
222
|
-
{ name: 'Overwrite with SpecPilot template', value: 'o' },
|
|
223
|
-
{ name: 'Append SpecPilot section to existing file', value: 'a' },
|
|
224
|
-
{ name: 'Skip (keep existing file unchanged)', value: 's' },
|
|
225
|
-
],
|
|
226
|
-
},
|
|
227
|
-
]);
|
|
228
|
-
if (action === 'o') {
|
|
229
|
-
(0, fs_1.writeFileSync)(filePath, this.buildCopilotInstructions(context));
|
|
230
|
-
}
|
|
231
|
-
else if (action === 'a') {
|
|
232
|
-
(0, fs_1.appendFileSync)(filePath, '\n\n' + this.buildCopilotSection(context));
|
|
233
|
-
}
|
|
234
|
-
// action === 's' → leave file unchanged
|
|
235
|
-
}
|
|
236
139
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
140
|
+
* Generates .github/copilot-instructions.md with critical mandates (`specpilot backfill`, when it is
|
|
141
|
+
* missing). Read automatically by GitHub Copilot, Cursor, and other AI tools on every request.
|
|
239
142
|
*/
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return `## SpecPilot Mandates — ${context.projectName}
|
|
245
|
-
|
|
246
|
-
> Added by \`specpilot add-specs\`. These mandates apply alongside your existing instructions.
|
|
247
|
-
> Full context is in \`.specs/project/project.yaml\`.
|
|
248
|
-
|
|
249
|
-
### Project
|
|
250
|
-
|
|
251
|
-
- **Name:** ${context.projectName}
|
|
252
|
-
- **Stack:** ${stack}
|
|
253
|
-
- **Specs location:** \`.specs/\`
|
|
254
|
-
|
|
255
|
-
### 🔴 Critical Mandates — Never violate, no exceptions
|
|
256
|
-
|
|
257
|
-
${this.buildCriticalMandatesMarkdown()}
|
|
258
|
-
|
|
259
|
-
### 🟡 Process Mandates
|
|
260
|
-
|
|
261
|
-
${this.buildProcessMandatesMarkdown()}
|
|
262
|
-
|
|
263
|
-
${this.buildContextRoutingTable()}
|
|
264
|
-
|
|
265
|
-
### Re-Anchor
|
|
266
|
-
|
|
267
|
-
If you lose context mid-session, read \`.specs/project/project.yaml\` to restore full project context.
|
|
268
|
-
For a ready-made re-anchor prompt, see \`.specs/development/prompts.md → ## Re-Anchor Prompt\`.
|
|
269
|
-
`;
|
|
143
|
+
generateCopilotInstructions(projectDir, context) {
|
|
144
|
+
const filePath = at(projectDir, COPILOT_INSTRUCTIONS);
|
|
145
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(filePath), { recursive: true });
|
|
146
|
+
writeNew(filePath, this.buildCopilotInstructions(context));
|
|
270
147
|
}
|
|
271
148
|
buildCopilotInstructions(context) {
|
|
272
149
|
const stack = context.framework
|
|
@@ -357,10 +234,12 @@ If you lose context mid-session, read \`.specs/project/project.yaml\` to restore
|
|
|
357
234
|
async generateIDESettings(projectDir, context, ide) {
|
|
358
235
|
const key = ide.toLowerCase();
|
|
359
236
|
const overrides = IDE_OVERRIDES[key] ?? {};
|
|
360
|
-
const [
|
|
361
|
-
(0, fs_1.mkdirSync)((0, path_1.dirname)(
|
|
237
|
+
const [settingsRel, extensionsRel] = this.settingsTargets(key);
|
|
238
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(at(projectDir, settingsRel)), { recursive: true });
|
|
239
|
+
const kept = [];
|
|
362
240
|
const settingsWithComment = this.buildSettingsJson(ide, context, overrides);
|
|
363
|
-
(
|
|
241
|
+
if (!writeNew(at(projectDir, settingsRel), settingsWithComment))
|
|
242
|
+
kept.push(settingsRel);
|
|
364
243
|
const extensions = {
|
|
365
244
|
recommendations: [
|
|
366
245
|
'esbenp.prettier-vscode',
|
|
@@ -370,7 +249,9 @@ If you lose context mid-session, read \`.specs/project/project.yaml\` to restore
|
|
|
370
249
|
],
|
|
371
250
|
unwantedRecommendations: [],
|
|
372
251
|
};
|
|
373
|
-
(
|
|
252
|
+
if (!writeNew(at(projectDir, extensionsRel), JSON.stringify(extensions, null, 2)))
|
|
253
|
+
kept.push(extensionsRel);
|
|
254
|
+
return kept;
|
|
374
255
|
}
|
|
375
256
|
buildSettingsJson(ide, context, overrides) {
|
|
376
257
|
const displayName = ide === 'vscode' ? 'VS Code' : ide.charAt(0).toUpperCase() + ide.slice(1);
|
|
@@ -427,7 +308,7 @@ If you lose context mid-session, read \`.specs/project/project.yaml\` to restore
|
|
|
427
308
|
/**
|
|
428
309
|
* Generates (or updates) .gitattributes at project root with merge=union rules
|
|
429
310
|
* for append-heavy spec files, preventing git merge conflicts on shared branches.
|
|
430
|
-
* If the file already exists, only missing lines are appended.
|
|
311
|
+
* If the file already exists, only missing lines are appended. Returns how many were appended.
|
|
431
312
|
*/
|
|
432
313
|
generateGitAttributes(projectDir) {
|
|
433
314
|
const GITATTRIBUTES_LINES = [
|
|
@@ -438,7 +319,7 @@ If you lose context mid-session, read \`.specs/project/project.yaml\` to restore
|
|
|
438
319
|
const filePath = (0, path_1.join)(projectDir, exports.GITATTRIBUTES_FILE);
|
|
439
320
|
if (!(0, fs_1.existsSync)(filePath)) {
|
|
440
321
|
(0, fs_1.writeFileSync)(filePath, GITATTRIBUTES_LINES.join('\n') + '\n');
|
|
441
|
-
return;
|
|
322
|
+
return 0;
|
|
442
323
|
}
|
|
443
324
|
const existing = (0, fs_1.readFileSync)(filePath, 'utf8');
|
|
444
325
|
const missing = GITATTRIBUTES_LINES.filter(line => !existing.includes(line));
|
|
@@ -446,6 +327,7 @@ If you lose context mid-session, read \`.specs/project/project.yaml\` to restore
|
|
|
446
327
|
const suffix = existing.endsWith('\n') ? '' : '\n';
|
|
447
328
|
(0, fs_1.appendFileSync)(filePath, suffix + missing.join('\n') + '\n');
|
|
448
329
|
}
|
|
330
|
+
return missing.length;
|
|
449
331
|
}
|
|
450
332
|
}
|
|
451
333
|
exports.IdeConfigGenerator = IdeConfigGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ideConfigGenerator.js","sourceRoot":"","sources":["../../src/utils/ideConfigGenerator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ideConfigGenerator.js","sourceRoot":"","sources":["../../src/utils/ideConfigGenerator.ts"],"names":[],"mappings":";;;AAwDA,4BAQC;AAhED,+BAAqC;AACrC,2BAAwF;AAGxF;;;;;GAKG;AACH,MAAM,aAAa,GAA4C;IAC7D,MAAM,EAAE;QACN,6CAA6C;QAC7C,iBAAiB,EAAE,IAAI;QACvB,w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AI,CAAC,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,IAAA,kBAAa,EAAC,QAAQ,EAAE,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YAC/D,OAAO,CAAC,CAAC;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,IAAA,iBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YACnD,IAAA,mBAAc,EAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;CACF;AA9RD,gDA8RC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface RegistryEntry {
|
|
2
|
+
/** The folder's realpath. */
|
|
3
|
+
path: string;
|
|
4
|
+
/** ISO 8601 UTC. */
|
|
5
|
+
lastOpened: string;
|
|
6
|
+
pinned: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Most entries the registry keeps; the oldest unpinned one goes first. */
|
|
9
|
+
export declare const MAX_REGISTRY_ENTRIES = 50;
|
|
10
|
+
/** Most projects one server serves; `POST /api/projects` refuses past it (the command line is not capped). */
|
|
11
|
+
export declare const MAX_PROJECTS = 20;
|
|
12
|
+
/**
|
|
13
|
+
* The home directory: `HOME`, else `USERPROFILE`, else `os.homedir()`. The same order libuv uses for
|
|
14
|
+
* `os.homedir()`, read from `process.env` so a test that sets the variable before the server starts is
|
|
15
|
+
* honoured (Jest sandboxes `process.env`, which the native `os.homedir()` does not see).
|
|
16
|
+
*/
|
|
17
|
+
export declare function homeDir(): string;
|
|
18
|
+
/** `~/.specpilot/projects.json` for `home`. */
|
|
19
|
+
export declare function registryPath(home?: string): string;
|
|
20
|
+
export type RegistryRead = {
|
|
21
|
+
entries: RegistryEntry[];
|
|
22
|
+
exists: boolean;
|
|
23
|
+
error: null;
|
|
24
|
+
} | {
|
|
25
|
+
entries: null;
|
|
26
|
+
exists: false;
|
|
27
|
+
error: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Read the registry: a missing file is an empty registry; anything that is not a regular, readable,
|
|
31
|
+
* well-formed file is a refusal with a plain reason. Never writes.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readRegistry(file: string): RegistryRead;
|
|
34
|
+
/**
|
|
35
|
+
* Replace the registry with `entries`: the folder is created with mode 0700 when missing, the content
|
|
36
|
+
* goes to a temp file (mode 0600) in that folder, `fsync`, then `rename`. Throws, writing nothing,
|
|
37
|
+
* when `readRegistry()` would refuse the current state.
|
|
38
|
+
*/
|
|
39
|
+
export declare function writeRegistry(file: string, entries: RegistryEntry[]): void;
|
|
40
|
+
/** Display order: pinned first, then newest `lastOpened` first. */
|
|
41
|
+
export declare function sortEntries(entries: RegistryEntry[]): RegistryEntry[];
|
|
42
|
+
/** `path` opened at `now`: its entry refreshed or appended, then the cap applied (oldest unpinned out first). */
|
|
43
|
+
export declare function upsertEntry(entries: RegistryEntry[], path: string, now: Date): RegistryEntry[];
|
|
44
|
+
/** The entries without the one whose stored path equals `path` byte for byte, or null when there is none. */
|
|
45
|
+
export declare function removeEntry(entries: RegistryEntry[], path: string): RegistryEntry[] | null;
|
|
46
|
+
/** Longest path a request may send. */
|
|
47
|
+
export declare const MAX_PATH_LENGTH = 4096;
|
|
48
|
+
/** Shape of a `{path}` body, checked before the lock. Null when fine. */
|
|
49
|
+
export declare function pathShapeError(body: unknown): string | null;
|
|
50
|
+
export type OpenCheck = {
|
|
51
|
+
root: string;
|
|
52
|
+
} | {
|
|
53
|
+
status: 409 | 422;
|
|
54
|
+
error: string;
|
|
55
|
+
project?: number;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The add route's path rule, in one place: `~` expanded against `home`, absolute, realpath-resolved,
|
|
59
|
+
* a directory, not the home folder, not a file-system root, not a served root. Makes no call on the
|
|
60
|
+
* folder but `realpath` and `stat`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function checkOpenPath(input: string, roots: string[], home: string): OpenCheck;
|
|
63
|
+
//# sourceMappingURL=projectRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectRegistry.d.ts","sourceRoot":"","sources":["../../src/utils/projectRegistry.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,8GAA8G;AAC9G,eAAO,MAAM,YAAY,KAAK,CAAC;AAI/B;;;;GAIG;AACH,wBAAgB,OAAO,IAAI,MAAM,CAEhC;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,IAAI,SAAY,GAAG,MAAM,CAErD;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA8CxI;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAmBvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,IAAI,CAqB1E;AAED,mEAAmE;AACnE,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAErE;AAED,iHAAiH;AACjH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,aAAa,EAAE,CAW9F;AAED,6GAA6G;AAC7G,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,GAAG,IAAI,CAG1F;AAED,uCAAuC;AACvC,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAS3D;AAED,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAgCrF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_PATH_LENGTH = exports.MAX_PROJECTS = exports.MAX_REGISTRY_ENTRIES = void 0;
|
|
4
|
+
exports.homeDir = homeDir;
|
|
5
|
+
exports.registryPath = registryPath;
|
|
6
|
+
exports.readRegistry = readRegistry;
|
|
7
|
+
exports.writeRegistry = writeRegistry;
|
|
8
|
+
exports.sortEntries = sortEntries;
|
|
9
|
+
exports.upsertEntry = upsertEntry;
|
|
10
|
+
exports.removeEntry = removeEntry;
|
|
11
|
+
exports.pathShapeError = pathShapeError;
|
|
12
|
+
exports.checkOpenPath = checkOpenPath;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const crypto_1 = require("crypto");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const os_1 = require("os");
|
|
17
|
+
/** Most entries the registry keeps; the oldest unpinned one goes first. */
|
|
18
|
+
exports.MAX_REGISTRY_ENTRIES = 50;
|
|
19
|
+
/** Most projects one server serves; `POST /api/projects` refuses past it (the command line is not capped). */
|
|
20
|
+
exports.MAX_PROJECTS = 20;
|
|
21
|
+
const VERSION = 1;
|
|
22
|
+
/**
|
|
23
|
+
* The home directory: `HOME`, else `USERPROFILE`, else `os.homedir()`. The same order libuv uses for
|
|
24
|
+
* `os.homedir()`, read from `process.env` so a test that sets the variable before the server starts is
|
|
25
|
+
* honoured (Jest sandboxes `process.env`, which the native `os.homedir()` does not see).
|
|
26
|
+
*/
|
|
27
|
+
function homeDir() {
|
|
28
|
+
return process.env.HOME || process.env.USERPROFILE || (0, os_1.homedir)();
|
|
29
|
+
}
|
|
30
|
+
/** `~/.specpilot/projects.json` for `home`. */
|
|
31
|
+
function registryPath(home = homeDir()) {
|
|
32
|
+
return (0, path_1.join)(home, '.specpilot', 'projects.json');
|
|
33
|
+
}
|
|
34
|
+
const code = (err) => err.code;
|
|
35
|
+
/** The folder the registry lives in must not exist, or be a real folder (never a link). Null when fine. */
|
|
36
|
+
function folderProblem(dir) {
|
|
37
|
+
try {
|
|
38
|
+
const st = (0, fs_1.lstatSync)(dir);
|
|
39
|
+
if (st.isSymbolicLink())
|
|
40
|
+
return `${dir} is a symbolic link`;
|
|
41
|
+
if (!st.isDirectory())
|
|
42
|
+
return `${dir} is not a folder`;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
return code(err) === 'ENOENT' ? null : `${dir} could not be read (${code(err)})`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Parse the file's text into entries, or say what is wrong with its shape. */
|
|
50
|
+
function parseEntries(text) {
|
|
51
|
+
let doc;
|
|
52
|
+
try {
|
|
53
|
+
doc = JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return { error: 'it is not valid JSON' };
|
|
57
|
+
}
|
|
58
|
+
const d = doc;
|
|
59
|
+
if (!d || typeof d !== 'object' || Array.isArray(d))
|
|
60
|
+
return { error: 'it is not a JSON object' };
|
|
61
|
+
if (d.version !== VERSION)
|
|
62
|
+
return { error: `its version is not ${VERSION}` };
|
|
63
|
+
if (!Array.isArray(d.projects))
|
|
64
|
+
return { error: 'its projects field is not a list' };
|
|
65
|
+
const seen = new Set();
|
|
66
|
+
const entries = [];
|
|
67
|
+
for (const [i, e] of d.projects.entries()) {
|
|
68
|
+
const at = `entry ${i + 1}`;
|
|
69
|
+
const o = e;
|
|
70
|
+
if (!o || typeof o !== 'object' || Array.isArray(o))
|
|
71
|
+
return { error: `${at} is not an object` };
|
|
72
|
+
const keys = Object.keys(o).sort();
|
|
73
|
+
if (keys.join() !== 'lastOpened,path,pinned')
|
|
74
|
+
return { error: `${at} does not have exactly path, lastOpened and pinned` };
|
|
75
|
+
if (typeof o.path !== 'string' || !(0, path_1.isAbsolute)(o.path))
|
|
76
|
+
return { error: `${at} has no absolute path` };
|
|
77
|
+
if (typeof o.lastOpened !== 'string' || Number.isNaN(Date.parse(o.lastOpened)))
|
|
78
|
+
return { error: `${at} has no valid lastOpened time` };
|
|
79
|
+
if (typeof o.pinned !== 'boolean')
|
|
80
|
+
return { error: `${at} has no boolean pinned flag` };
|
|
81
|
+
if (seen.has(o.path))
|
|
82
|
+
return { error: `${at} repeats a path` };
|
|
83
|
+
seen.add(o.path);
|
|
84
|
+
entries.push({ path: o.path, lastOpened: o.lastOpened, pinned: o.pinned });
|
|
85
|
+
}
|
|
86
|
+
return { entries };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Read the registry: a missing file is an empty registry; anything that is not a regular, readable,
|
|
90
|
+
* well-formed file is a refusal with a plain reason. Never writes.
|
|
91
|
+
*/
|
|
92
|
+
function readRegistry(file) {
|
|
93
|
+
const problem = folderProblem((0, path_1.dirname)(file));
|
|
94
|
+
if (problem)
|
|
95
|
+
return { entries: null, exists: false, error: problem };
|
|
96
|
+
let st;
|
|
97
|
+
try {
|
|
98
|
+
st = (0, fs_1.lstatSync)(file);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
return code(err) === 'ENOENT' ? { entries: [], exists: false, error: null } : { entries: null, exists: false, error: `${file} could not be read (${code(err)})` };
|
|
102
|
+
}
|
|
103
|
+
if (st.isSymbolicLink())
|
|
104
|
+
return { entries: null, exists: false, error: `${file} is a symbolic link` };
|
|
105
|
+
if (!st.isFile())
|
|
106
|
+
return { entries: null, exists: false, error: `${file} is not a regular file` };
|
|
107
|
+
let text;
|
|
108
|
+
try {
|
|
109
|
+
text = (0, fs_1.readFileSync)(file, 'utf-8');
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
return { entries: null, exists: false, error: `${file} could not be read (${code(err)})` };
|
|
113
|
+
}
|
|
114
|
+
const parsed = parseEntries(text);
|
|
115
|
+
return 'error' in parsed ? { entries: null, exists: false, error: `${file} could not be used: ${parsed.error}` } : { entries: parsed.entries, exists: true, error: null };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Replace the registry with `entries`: the folder is created with mode 0700 when missing, the content
|
|
119
|
+
* goes to a temp file (mode 0600) in that folder, `fsync`, then `rename`. Throws, writing nothing,
|
|
120
|
+
* when `readRegistry()` would refuse the current state.
|
|
121
|
+
*/
|
|
122
|
+
function writeRegistry(file, entries) {
|
|
123
|
+
const current = readRegistry(file);
|
|
124
|
+
if (current.error !== null)
|
|
125
|
+
throw new Error(current.error);
|
|
126
|
+
const dir = (0, path_1.dirname)(file);
|
|
127
|
+
try {
|
|
128
|
+
(0, fs_1.mkdirSync)(dir, { mode: 0o700 });
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
if (code(err) !== 'EEXIST')
|
|
132
|
+
throw err;
|
|
133
|
+
}
|
|
134
|
+
const tmp = `${file}.${(0, crypto_1.randomBytes)(6).toString('hex')}.tmp`;
|
|
135
|
+
const fd = (0, fs_1.openSync)(tmp, 'wx', 0o600);
|
|
136
|
+
try {
|
|
137
|
+
(0, fs_1.writeSync)(fd, JSON.stringify({ version: VERSION, projects: entries }, null, 2) + '\n');
|
|
138
|
+
(0, fs_1.fsyncSync)(fd);
|
|
139
|
+
(0, fs_1.closeSync)(fd);
|
|
140
|
+
(0, fs_1.renameSync)(tmp, file);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
try {
|
|
144
|
+
(0, fs_1.closeSync)(fd);
|
|
145
|
+
}
|
|
146
|
+
catch { /* already closed */ }
|
|
147
|
+
try {
|
|
148
|
+
(0, fs_1.unlinkSync)(tmp);
|
|
149
|
+
}
|
|
150
|
+
catch { /* already gone */ }
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Display order: pinned first, then newest `lastOpened` first. */
|
|
155
|
+
function sortEntries(entries) {
|
|
156
|
+
return [...entries].sort((a, b) => Number(b.pinned) - Number(a.pinned) || Date.parse(b.lastOpened) - Date.parse(a.lastOpened));
|
|
157
|
+
}
|
|
158
|
+
/** `path` opened at `now`: its entry refreshed or appended, then the cap applied (oldest unpinned out first). */
|
|
159
|
+
function upsertEntry(entries, path, now) {
|
|
160
|
+
const lastOpened = now.toISOString();
|
|
161
|
+
const found = entries.find(e => e.path === path);
|
|
162
|
+
const next = found ? entries.map(e => (e === found ? { ...e, lastOpened } : e)) : [...entries, { path, lastOpened, pinned: false }];
|
|
163
|
+
while (next.length > exports.MAX_REGISTRY_ENTRIES) {
|
|
164
|
+
const others = next.filter(e => e.path !== path); // never the one just opened
|
|
165
|
+
const pool = others.some(e => !e.pinned) ? others.filter(e => !e.pinned) : others;
|
|
166
|
+
const oldest = pool.reduce((a, b) => (Date.parse(b.lastOpened) < Date.parse(a.lastOpened) ? b : a));
|
|
167
|
+
next.splice(next.indexOf(oldest), 1);
|
|
168
|
+
}
|
|
169
|
+
return next;
|
|
170
|
+
}
|
|
171
|
+
/** The entries without the one whose stored path equals `path` byte for byte, or null when there is none. */
|
|
172
|
+
function removeEntry(entries, path) {
|
|
173
|
+
const i = entries.findIndex(e => e.path === path);
|
|
174
|
+
return i < 0 ? null : [...entries.slice(0, i), ...entries.slice(i + 1)];
|
|
175
|
+
}
|
|
176
|
+
/** Longest path a request may send. */
|
|
177
|
+
exports.MAX_PATH_LENGTH = 4096;
|
|
178
|
+
/** Shape of a `{path}` body, checked before the lock. Null when fine. */
|
|
179
|
+
function pathShapeError(body) {
|
|
180
|
+
const b = body;
|
|
181
|
+
if (!b || typeof b !== 'object' || Array.isArray(b))
|
|
182
|
+
return 'The request must be a JSON object with one field, path.';
|
|
183
|
+
const keys = Object.keys(b);
|
|
184
|
+
if (keys.length !== 1 || keys[0] !== 'path')
|
|
185
|
+
return 'The request must have exactly one field, path.';
|
|
186
|
+
if (typeof b.path !== 'string')
|
|
187
|
+
return '"path" must be a string.';
|
|
188
|
+
if (!b.path.length || b.path.length > exports.MAX_PATH_LENGTH)
|
|
189
|
+
return `"path" must be 1 to ${exports.MAX_PATH_LENGTH} characters.`;
|
|
190
|
+
if (b.path.includes('\0'))
|
|
191
|
+
return '"path" must not contain a NUL character.';
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The add route's path rule, in one place: `~` expanded against `home`, absolute, realpath-resolved,
|
|
196
|
+
* a directory, not the home folder, not a file-system root, not a served root. Makes no call on the
|
|
197
|
+
* folder but `realpath` and `stat`.
|
|
198
|
+
*/
|
|
199
|
+
function checkOpenPath(input, roots, home) {
|
|
200
|
+
const expanded = input === '~' ? home : input.startsWith('~/') ? (0, path_1.join)(home, input.slice(2)) : input;
|
|
201
|
+
if (!(0, path_1.isAbsolute)(expanded))
|
|
202
|
+
return { status: 422, error: 'The path must be absolute, e.g. /Users/you/project or ~/project.' };
|
|
203
|
+
let root;
|
|
204
|
+
try {
|
|
205
|
+
root = (0, fs_1.realpathSync)(expanded);
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return { status: 422, error: `Folder not found: ${input}` };
|
|
209
|
+
}
|
|
210
|
+
let isDir;
|
|
211
|
+
try {
|
|
212
|
+
isDir = (0, fs_1.statSync)(root).isDirectory();
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return { status: 422, error: `Folder not found: ${input}` };
|
|
216
|
+
}
|
|
217
|
+
if (!isDir)
|
|
218
|
+
return { status: 422, error: `Not a folder: ${input}` };
|
|
219
|
+
let realHome;
|
|
220
|
+
try {
|
|
221
|
+
realHome = (0, fs_1.realpathSync)(home);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
realHome = home;
|
|
225
|
+
}
|
|
226
|
+
if (root === realHome || (0, path_1.parse)(root).root === root)
|
|
227
|
+
return { status: 422, error: 'SpecPilot does not open your home folder or the root of a drive.' };
|
|
228
|
+
const served = roots.findIndex(r => {
|
|
229
|
+
try {
|
|
230
|
+
return (0, fs_1.realpathSync)(r) === root;
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return r === root;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
if (served >= 0)
|
|
237
|
+
return { status: 409, error: `${root} is already open as project ${served}.`, project: served };
|
|
238
|
+
return { root };
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=projectRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectRegistry.js","sourceRoot":"","sources":["../../src/utils/projectRegistry.ts"],"names":[],"mappings":";;;AA8BA,0BAEC;AAGD,oCAEC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