specpilot 2.7.1 → 2.9.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 +10 -6
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +31 -92
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/serve.d.ts +3 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +55 -6
- package/dist/commands/serve.js.map +1 -1
- package/dist/utils/addSpecsQuestions.d.ts +16 -0
- package/dist/utils/addSpecsQuestions.d.ts.map +1 -1
- package/dist/utils/addSpecsQuestions.js +28 -1
- package/dist/utils/addSpecsQuestions.js.map +1 -1
- package/dist/utils/gitClone.d.ts +62 -0
- package/dist/utils/gitClone.d.ts.map +1 -0
- package/dist/utils/gitClone.js +222 -0
- package/dist/utils/gitClone.js.map +1 -0
- package/dist/utils/initQuestions.d.ts +57 -0
- package/dist/utils/initQuestions.d.ts.map +1 -0
- package/dist/utils/initQuestions.js +49 -0
- package/dist/utils/initQuestions.js.map +1 -0
- package/dist/utils/projectRegistry.d.ts +65 -0
- package/dist/utils/projectRegistry.d.ts.map +1 -0
- package/dist/utils/projectRegistry.js +242 -0
- package/dist/utils/projectRegistry.js.map +1 -0
- package/dist/utils/specFileGenerator.d.ts +5 -4
- package/dist/utils/specFileGenerator.d.ts.map +1 -1
- package/dist/utils/specFileGenerator.js +53 -28
- package/dist/utils/specFileGenerator.js.map +1 -1
- package/dist/utils/specGenerator.d.ts +5 -0
- package/dist/utils/specGenerator.d.ts.map +1 -1
- package/dist/utils/specGenerator.js +7 -0
- package/dist/utils/specGenerator.js.map +1 -1
- package/dist/utils/specServer.d.ts +8 -2
- package/dist/utils/specServer.d.ts.map +1 -1
- package/dist/utils/specServer.js +284 -19
- package/dist/utils/specServer.js.map +1 -1
- package/dist/utils/specSetup.d.ts +69 -4
- package/dist/utils/specSetup.d.ts.map +1 -1
- package/dist/utils/specSetup.js +226 -18
- package/dist/utils/specSetup.js.map +1 -1
- package/package.json +1 -1
- package/ui/app.css +135 -9
- package/ui/app.js +301 -67
- package/ui/index.html +60 -8
- package/ui/route.js +179 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const MAX_URL_LENGTH = 2048;
|
|
2
|
+
/** A clone that runs longer is killed, with its helpers. */
|
|
3
|
+
export declare const CLONE_TIMEOUT_MS: number;
|
|
4
|
+
/** Longest git message returned to the page. */
|
|
5
|
+
export declare const MAX_GIT_LINE = 300;
|
|
6
|
+
/** What is wrong with a repository URL, or null. Pure string checks: the URL is never parsed or rewritten. */
|
|
7
|
+
export declare function cloneUrlError(url: string): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The folder `git clone` would make for a URL: its last path segment without `.git`. The rule lives in
|
|
10
|
+
* the page's `ui/route.js`, which fills the Folder name field with it, so there is one copy.
|
|
11
|
+
*/
|
|
12
|
+
export declare const repoNameFromUrl: (url: string) => string;
|
|
13
|
+
/** Shape of a clone body, checked before anything runs. Null when fine. */
|
|
14
|
+
export declare function cloneShapeError(body: unknown): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Is git there? And, on Windows only, where the child has a console ssh could ask in: has the user an
|
|
17
|
+
* ssh command of their own (`GIT_SSH_COMMAND`, `GIT_SSH`, `core.sshCommand`)? `batchSsh` says ssh may
|
|
18
|
+
* be put in batch mode without replacing one. On POSIX it is always false: the child has no terminal
|
|
19
|
+
* and no askpass, so ssh cannot ask, and the user's ssh setup is never touched. Run at the file-system
|
|
20
|
+
* root, so no repository's local configuration answers.
|
|
21
|
+
*/
|
|
22
|
+
export declare function probeGit(home: string, platform?: NodeJS.Platform): Promise<{
|
|
23
|
+
batchSsh: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
error: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* What the page shows of git's stderr, as one line: its last `fatal:` line with the line just before
|
|
29
|
+
* it, which over ssh is the one that says why (`Host key verification failed.`). `remote:` lines, text
|
|
30
|
+
* the remote host chooses, and git's own `Cloning into` line are never shown. Without a `fatal:` line,
|
|
31
|
+
* the last line left.
|
|
32
|
+
*/
|
|
33
|
+
export declare function gitErrorLine(stderr: string): string | null;
|
|
34
|
+
export interface CloneOptions {
|
|
35
|
+
/** Put ssh in batch mode (Windows only; `probeGit()` says when that replaces nothing of the user's). */
|
|
36
|
+
batchSsh?: boolean;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
/** Aborting kills the clone: the page went away, or the server is closing. */
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
/** Tests only (a local bare repository needs `file`). The server never passes it and no request field maps to it. */
|
|
41
|
+
allowProtocols?: string;
|
|
42
|
+
}
|
|
43
|
+
export type CloneResult = {
|
|
44
|
+
ok: true;
|
|
45
|
+
} | {
|
|
46
|
+
ok: false;
|
|
47
|
+
aborted: boolean;
|
|
48
|
+
error: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* `git clone --no-recurse-submodules -- <url> <target>` in the target's parent, without a shell, with
|
|
52
|
+
* stdin closed and, on POSIX, in its own session (no controlling terminal; one process group to kill).
|
|
53
|
+
* `spawn` and not `execFile`, which cannot start a detached child; both take an argument array.
|
|
54
|
+
*/
|
|
55
|
+
export declare function cloneRepository(url: string, target: string, opts?: CloneOptions): Promise<CloneResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Remove what a clone put into `target`: only while it is still a real folder, every entry in it (links
|
|
58
|
+
* are removed, never followed), and the folder itself only when this request `created` it. The folder
|
|
59
|
+
* was empty when the clone started, so everything in it is the clone's. Resolves to an error code, or null.
|
|
60
|
+
*/
|
|
61
|
+
export declare function emptyTarget(target: string, created: boolean): Promise<string | null>;
|
|
62
|
+
//# sourceMappingURL=gitClone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitClone.d.ts","sourceRoot":"","sources":["../../src/utils/gitClone.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,OAA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AW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW1F"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repoNameFromUrl = exports.MAX_GIT_LINE = exports.CLONE_TIMEOUT_MS = exports.MAX_URL_LENGTH = void 0;
|
|
4
|
+
exports.cloneUrlError = cloneUrlError;
|
|
5
|
+
exports.cloneShapeError = cloneShapeError;
|
|
6
|
+
exports.probeGit = probeGit;
|
|
7
|
+
exports.gitErrorLine = gitErrorLine;
|
|
8
|
+
exports.cloneRepository = cloneRepository;
|
|
9
|
+
exports.emptyTarget = emptyTarget;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const initQuestions_1 = require("./initQuestions");
|
|
14
|
+
const projectRegistry_1 = require("./projectRegistry");
|
|
15
|
+
// Clone a repository for `specpilot serve` (BL-PM-002, ARCH-003.23, SEC-004.15): the one module that
|
|
16
|
+
// starts a process for a request. git is the user's own, started without a shell; only the URL (after
|
|
17
|
+
// `--`) and the target folder reach its command line, and nothing it does can wait on a prompt.
|
|
18
|
+
exports.MAX_URL_LENGTH = 2048;
|
|
19
|
+
/** A clone that runs longer is killed, with its helpers. */
|
|
20
|
+
exports.CLONE_TIMEOUT_MS = 10 * 60 * 1000;
|
|
21
|
+
/** Longest git message returned to the page. */
|
|
22
|
+
exports.MAX_GIT_LINE = 300;
|
|
23
|
+
const HOST = '[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?';
|
|
24
|
+
const USER = '[A-Za-z0-9_][A-Za-z0-9._-]*';
|
|
25
|
+
const PORT = '(?::[0-9]{1,5})?';
|
|
26
|
+
const REPO_PATH = '(?!-)[A-Za-z0-9._~/+%-]+';
|
|
27
|
+
/** The only URLs cloned: https, ssh:// and user@host:path, each matched from the first character to the last. */
|
|
28
|
+
const URL_FORMS = [
|
|
29
|
+
new RegExp(`^https://${HOST}${PORT}/${REPO_PATH}$`),
|
|
30
|
+
new RegExp(`^ssh://(?:${USER}@)?${HOST}${PORT}/${REPO_PATH}$`),
|
|
31
|
+
new RegExp(`^${USER}@${HOST}:${REPO_PATH}$`),
|
|
32
|
+
];
|
|
33
|
+
// eslint-disable-next-line no-control-regex
|
|
34
|
+
const SPACE_OR_CONTROL = /[\s\u0000-\u0020\u007f-\u00a0\u2028\u2029]/;
|
|
35
|
+
// eslint-disable-next-line no-control-regex
|
|
36
|
+
const ANSI_AND_CONTROL = /\u001b\[[0-9;?]*[ -/]*[@-~]|[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g;
|
|
37
|
+
/** What is wrong with a repository URL, or null. Pure string checks: the URL is never parsed or rewritten. */
|
|
38
|
+
function cloneUrlError(url) {
|
|
39
|
+
if (!url.length || url.length > exports.MAX_URL_LENGTH)
|
|
40
|
+
return `url must be a string of 1 to ${exports.MAX_URL_LENGTH} characters.`;
|
|
41
|
+
if (SPACE_OR_CONTROL.test(url))
|
|
42
|
+
return 'The repository URL must not contain spaces or control characters.';
|
|
43
|
+
if (URL_FORMS.some(form => form.test(url)))
|
|
44
|
+
return null;
|
|
45
|
+
if (/^https:\/\/[^/]*@/.test(url))
|
|
46
|
+
return 'Remove the user name and password from the URL. git reads them from your credential helper.';
|
|
47
|
+
return 'Only https://host/path, git@host:path and ssh://host/path repository URLs can be cloned.';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The folder `git clone` would make for a URL: its last path segment without `.git`. The rule lives in
|
|
51
|
+
* the page's `ui/route.js`, which fills the Folder name field with it, so there is one copy.
|
|
52
|
+
*/
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
54
|
+
exports.repoNameFromUrl = require('../../ui/route.js').repoNameFromUrl;
|
|
55
|
+
const CLONE_KEYS = ['url', 'parent', 'name'];
|
|
56
|
+
/** Shape of a clone body, checked before anything runs. Null when fine. */
|
|
57
|
+
function cloneShapeError(body) {
|
|
58
|
+
const b = body;
|
|
59
|
+
if (!b || typeof b !== 'object' || Array.isArray(b))
|
|
60
|
+
return 'The request must be a JSON object with url, parent and name.';
|
|
61
|
+
for (const key of Object.keys(b))
|
|
62
|
+
if (!CLONE_KEYS.includes(key))
|
|
63
|
+
return `Unexpected field "${key}".`;
|
|
64
|
+
for (const key of CLONE_KEYS) {
|
|
65
|
+
if (!(key in b))
|
|
66
|
+
return `"${key}" is missing.`;
|
|
67
|
+
if (typeof b[key] !== 'string')
|
|
68
|
+
return `"${key}" must be a string.`;
|
|
69
|
+
}
|
|
70
|
+
const s = b;
|
|
71
|
+
const parentProblem = (0, projectRegistry_1.pathShapeError)({ path: s.parent });
|
|
72
|
+
if (parentProblem)
|
|
73
|
+
return parentProblem.replace('"path"', '"parent"');
|
|
74
|
+
const urlProblem = cloneUrlError(s.url);
|
|
75
|
+
if (urlProblem)
|
|
76
|
+
return urlProblem;
|
|
77
|
+
if (s.name) {
|
|
78
|
+
const nameProblem = (0, initQuestions_1.projectNameError)(s.name);
|
|
79
|
+
if (nameProblem)
|
|
80
|
+
return `${nameProblem.message}.`;
|
|
81
|
+
}
|
|
82
|
+
else if ((0, initQuestions_1.projectNameError)((0, exports.repoNameFromUrl)(s.url)))
|
|
83
|
+
return 'Type a folder name. One could not be taken from this URL.';
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
/** The server's environment plus what keeps git to https and ssh and stops it asking anything. */
|
|
87
|
+
function gitEnv(allowProtocols) {
|
|
88
|
+
const env = { ...process.env, GIT_ALLOW_PROTOCOL: allowProtocols, GIT_TERMINAL_PROMPT: '0', GIT_ASKPASS: '', SSH_ASKPASS_REQUIRE: 'never', GCM_INTERACTIVE: 'never' };
|
|
89
|
+
// These two would point git at another repository or work tree than the target.
|
|
90
|
+
delete env.GIT_DIR;
|
|
91
|
+
delete env.GIT_WORK_TREE;
|
|
92
|
+
// English messages, because `fatal:` and `Cloning into` are matched (gitErrorLine()). Only the message
|
|
93
|
+
// language changes: an LC_ALL, which would override LC_MESSAGES, is kept as LC_CTYPE, so file names
|
|
94
|
+
// are handled as before.
|
|
95
|
+
if (env.LC_ALL) {
|
|
96
|
+
env.LC_CTYPE = env.LC_ALL;
|
|
97
|
+
delete env.LC_ALL;
|
|
98
|
+
}
|
|
99
|
+
delete env.LANGUAGE;
|
|
100
|
+
env.LC_MESSAGES = 'C';
|
|
101
|
+
return env;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Is git there? And, on Windows only, where the child has a console ssh could ask in: has the user an
|
|
105
|
+
* ssh command of their own (`GIT_SSH_COMMAND`, `GIT_SSH`, `core.sshCommand`)? `batchSsh` says ssh may
|
|
106
|
+
* be put in batch mode without replacing one. On POSIX it is always false: the child has no terminal
|
|
107
|
+
* and no askpass, so ssh cannot ask, and the user's ssh setup is never touched. Run at the file-system
|
|
108
|
+
* root, so no repository's local configuration answers.
|
|
109
|
+
*/
|
|
110
|
+
function probeGit(home, platform = process.platform) {
|
|
111
|
+
return new Promise(done => {
|
|
112
|
+
const child = (0, child_process_1.execFile)('git', ['config', '--get', 'core.sshCommand'], { cwd: (0, path_1.parse)(home).root, env: gitEnv('https:ssh'), windowsHide: true }, (err, stdout) => {
|
|
113
|
+
const code = err ? err.code : 0;
|
|
114
|
+
if (code === 'ENOENT')
|
|
115
|
+
return done({ error: 'git is not installed.' });
|
|
116
|
+
if (code !== 0 && code !== 1)
|
|
117
|
+
return done({ error: `git could not be run (${code}).` }); // 1 = not set
|
|
118
|
+
done({ batchSsh: platform === 'win32' && !stdout.trim() && !process.env.GIT_SSH_COMMAND && !process.env.GIT_SSH });
|
|
119
|
+
});
|
|
120
|
+
child.stdin?.end();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* What the page shows of git's stderr, as one line: its last `fatal:` line with the line just before
|
|
125
|
+
* it, which over ssh is the one that says why (`Host key verification failed.`). `remote:` lines, text
|
|
126
|
+
* the remote host chooses, and git's own `Cloning into` line are never shown. Without a `fatal:` line,
|
|
127
|
+
* the last line left.
|
|
128
|
+
*/
|
|
129
|
+
function gitErrorLine(stderr) {
|
|
130
|
+
const lines = stderr.split(/\r?\n|\r/).map(line => line.replace(ANSI_AND_CONTROL, '').trim()).filter(l => l && !l.startsWith('remote:') && !l.startsWith('Cloning into '));
|
|
131
|
+
if (!lines.length)
|
|
132
|
+
return null;
|
|
133
|
+
const fatal = lines.map(l => l.startsWith('fatal:')).lastIndexOf(true);
|
|
134
|
+
if (fatal <= 0)
|
|
135
|
+
return lines[fatal < 0 ? lines.length - 1 : 0].slice(0, exports.MAX_GIT_LINE);
|
|
136
|
+
const last = lines[fatal].slice(0, exports.MAX_GIT_LINE);
|
|
137
|
+
const room = exports.MAX_GIT_LINE - last.length - 1; // the fatal: line is never pushed out by a long line before it
|
|
138
|
+
return room > 0 ? `${lines[fatal - 1].slice(0, room)} ${last}` : last;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* `git clone --no-recurse-submodules -- <url> <target>` in the target's parent, without a shell, with
|
|
142
|
+
* stdin closed and, on POSIX, in its own session (no controlling terminal; one process group to kill).
|
|
143
|
+
* `spawn` and not `execFile`, which cannot start a detached child; both take an argument array.
|
|
144
|
+
*/
|
|
145
|
+
function cloneRepository(url, target, opts = {}) {
|
|
146
|
+
return new Promise(done => {
|
|
147
|
+
if (opts.signal?.aborted)
|
|
148
|
+
return done({ ok: false, aborted: true, error: '' });
|
|
149
|
+
const posix = process.platform !== 'win32';
|
|
150
|
+
const env = gitEnv(opts.allowProtocols ?? 'https:ssh');
|
|
151
|
+
if (opts.batchSsh)
|
|
152
|
+
env.GIT_SSH_COMMAND = 'ssh -oBatchMode=yes';
|
|
153
|
+
const child = (0, child_process_1.spawn)('git', ['clone', '--no-recurse-submodules', '--', url, target], {
|
|
154
|
+
cwd: (0, path_1.dirname)(target), env, stdio: ['ignore', 'ignore', 'pipe'], detached: posix, windowsHide: true,
|
|
155
|
+
});
|
|
156
|
+
let stderr = '';
|
|
157
|
+
let stopped = null;
|
|
158
|
+
const kill = (why) => {
|
|
159
|
+
stopped = stopped ?? why;
|
|
160
|
+
try {
|
|
161
|
+
if (posix && child.pid)
|
|
162
|
+
process.kill(-child.pid, 'SIGKILL'); // the group: git-remote-https and ssh go too
|
|
163
|
+
else
|
|
164
|
+
child.kill('SIGKILL');
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
/* already gone */
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const onAbort = () => kill('aborted');
|
|
171
|
+
const timer = setTimeout(() => kill('limit'), opts.timeoutMs ?? exports.CLONE_TIMEOUT_MS);
|
|
172
|
+
opts.signal?.addEventListener('abort', onAbort);
|
|
173
|
+
let finished = false;
|
|
174
|
+
const finish = (result) => {
|
|
175
|
+
if (finished)
|
|
176
|
+
return;
|
|
177
|
+
finished = true;
|
|
178
|
+
clearTimeout(timer);
|
|
179
|
+
opts.signal?.removeEventListener('abort', onAbort);
|
|
180
|
+
done(result);
|
|
181
|
+
};
|
|
182
|
+
child.stderr.on('data', (chunk) => {
|
|
183
|
+
stderr = (stderr + chunk.toString('utf-8')).slice(-65536);
|
|
184
|
+
});
|
|
185
|
+
child.on('error', err => {
|
|
186
|
+
const code = err.code;
|
|
187
|
+
finish({ ok: false, aborted: false, error: code === 'ENOENT' ? 'git is not installed.' : `git could not be run (${code}).` });
|
|
188
|
+
});
|
|
189
|
+
child.on('close', (code, signal) => {
|
|
190
|
+
if (stopped === 'aborted')
|
|
191
|
+
return finish({ ok: false, aborted: true, error: '' });
|
|
192
|
+
if (stopped === 'limit')
|
|
193
|
+
return finish({ ok: false, aborted: false, error: `The clone was stopped after ${exports.CLONE_TIMEOUT_MS / 60000} minutes. What it had downloaded was removed.` });
|
|
194
|
+
if (code === 0)
|
|
195
|
+
return finish({ ok: true });
|
|
196
|
+
const line = gitErrorLine(stderr);
|
|
197
|
+
finish({ ok: false, aborted: false, error: line ? `git clone failed: ${line}` : `git clone failed (exit code ${code ?? signal}).` });
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Remove what a clone put into `target`: only while it is still a real folder, every entry in it (links
|
|
203
|
+
* are removed, never followed), and the folder itself only when this request `created` it. The folder
|
|
204
|
+
* was empty when the clone started, so everything in it is the clone's. Resolves to an error code, or null.
|
|
205
|
+
*/
|
|
206
|
+
async function emptyTarget(target, created) {
|
|
207
|
+
try {
|
|
208
|
+
if (!(await fs_1.promises.lstat(target)).isDirectory())
|
|
209
|
+
return null;
|
|
210
|
+
// Asynchronous, so a stop signal's time limit can end the wait for a large tree (serve.ts).
|
|
211
|
+
for (const entry of await fs_1.promises.readdir(target))
|
|
212
|
+
await fs_1.promises.rm((0, path_1.join)(target, entry), { recursive: true, force: true });
|
|
213
|
+
if (created)
|
|
214
|
+
await fs_1.promises.rmdir(target);
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
const code = err.code;
|
|
219
|
+
return code === 'ENOENT' ? null : (code ?? 'error');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=gitClone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitClone.js","sourceRoot":"","sources":["../../src/utils/gitClone.ts"],"names":[],"mappings":";;;AAgCA,sCAMC;AAYD,0CAkBC;AA2BD,4BAUC;AAQD,oCAQC;AAmBD,0CA8CC;AAOD,kCAWC;AA5MD,iDAAgD;AAChD,2BAAoC;AACpC,+BAA4C;AAC5C,mDAAmD;AACnD,uDAAmD;AAEnD,qGAAqG;AACrG,sGAAsG;AACtG,gGAAgG;AAEnF,QAAA,cAAc,GAAG,IAAI,CAAC;AACnC,4DAA4D;AAC/C,QAAA,gBAAgB,GAAG,EAAE,GAAG,EAAE,GA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AK,UAAU,WAAW,CAAC,MAAc,EAAE,OAAgB;IAChE,IAAI,CAAC;QACH,IAAI,CAAC,CAAC,MAAM,aAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE;YAAE,OAAO,IAAI,CAAC;QACzD,4FAA4F;QAC5F,KAAK,MAAM,KAAK,IAAI,MAAM,aAAE,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,MAAM,aAAE,CAAC,EAAE,CAAC,IAAA,WAAI,EAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACjH,IAAI,OAAO;YAAE,MAAM,aAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,GAAI,GAA6B,CAAC,IAAI,CAAC;QACjD,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AddSpecsAnswers } from './addSpecsQuestions';
|
|
2
|
+
import { SpecGeneratorOptions } from './specGenerator';
|
|
3
|
+
/** `init` lists Greenfield first. */
|
|
4
|
+
export declare const INIT_PROJECT_TYPE_CHOICES: {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[];
|
|
8
|
+
/**
|
|
9
|
+
* What is wrong with a project name, in `init`'s words (`hint` is the terminal's extra line), or null.
|
|
10
|
+
* The allowlist prevents filesystem issues and Handlebars template injection (SEC-004.1). The rule lives
|
|
11
|
+
* in the page's `ui/route.js`, which checks the name as it is typed in, so there is one copy (BL-PM-004).
|
|
12
|
+
*/
|
|
13
|
+
export declare const projectNameError: (name: string) => {
|
|
14
|
+
message: string;
|
|
15
|
+
hint?: string;
|
|
16
|
+
} | null;
|
|
17
|
+
/** The four project-context questions, in order; only the first is required. */
|
|
18
|
+
export declare const CONTEXT_QUESTIONS: readonly [{
|
|
19
|
+
readonly key: "whatItDoes";
|
|
20
|
+
readonly message: "What does your project do? (required):";
|
|
21
|
+
readonly required: true;
|
|
22
|
+
readonly when: {
|
|
23
|
+
projectType: string;
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
readonly key: "targetUsers";
|
|
27
|
+
readonly message: "Who are the target users? (Enter to skip):";
|
|
28
|
+
readonly required: false;
|
|
29
|
+
readonly when: {
|
|
30
|
+
projectType: string;
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
readonly key: "expectedScale";
|
|
34
|
+
readonly message: "What's the expected scale? (Enter to skip):";
|
|
35
|
+
readonly required: false;
|
|
36
|
+
readonly when: {
|
|
37
|
+
projectType: string;
|
|
38
|
+
};
|
|
39
|
+
}, {
|
|
40
|
+
readonly key: "constraints";
|
|
41
|
+
readonly message: "Any key constraints or requirements? (Enter to skip):";
|
|
42
|
+
readonly required: false;
|
|
43
|
+
readonly when: {
|
|
44
|
+
projectType: string;
|
|
45
|
+
};
|
|
46
|
+
}];
|
|
47
|
+
export declare const NOT_SPECIFIED = "Not specified \u2014 use your judgment and mark as [ASSUMPTION]";
|
|
48
|
+
/** `init`'s answers; a context answer left empty becomes NOT_SPECIFIED. */
|
|
49
|
+
export interface InitAnswers extends AddSpecsAnswers {
|
|
50
|
+
whatItDoes: string;
|
|
51
|
+
targetUsers: string;
|
|
52
|
+
expectedScale: string;
|
|
53
|
+
constraints: string;
|
|
54
|
+
}
|
|
55
|
+
/** The `generateSpecs()` options `init` builds from the project name and the answers. */
|
|
56
|
+
export declare function initOptions(targetDir: string, projectName: string, answers: InitAnswers, specsName?: string): SpecGeneratorOptions;
|
|
57
|
+
//# sourceMappingURL=initQuestions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initQuestions.d.ts","sourceRoot":"","sources":["../../src/utils/initQuestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAMvD,qCAAqC;AACrC,eAAO,MAAM,yBAAyB;;;GAAqD,CAAC;AAE5F;;;;GAIG;AAEH,eAAO,MAAQ,gBAAgB,SAAgE,MAAM,KAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAM,CAAC;AAItJ,gFAAgF;AAChF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKpB,CAAC;AAEX,eAAO,MAAM,aAAa,oEAA+D,CAAC;AAE1F,2EAA2E;AAC3E,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,SAAW,GAAG,oBAAoB,CAmBpI"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NOT_SPECIFIED = exports.CONTEXT_QUESTIONS = exports.projectNameError = exports.INIT_PROJECT_TYPE_CHOICES = void 0;
|
|
4
|
+
exports.initOptions = initOptions;
|
|
5
|
+
const addSpecsQuestions_1 = require("./addSpecsQuestions");
|
|
6
|
+
// What only `specpilot init` asks, and how its answers become generator options: one copy, used by the
|
|
7
|
+
// command's inquirer prompts and by `specpilot serve`'s new-project route (BL-075, BL-PM-003,
|
|
8
|
+
// ARCH-003.22). The lists `init` shares with `add-specs` are in addSpecsQuestions.ts.
|
|
9
|
+
/** `init` lists Greenfield first. */
|
|
10
|
+
exports.INIT_PROJECT_TYPE_CHOICES = [addSpecsQuestions_1.PROJECT_TYPE_CHOICES[1], addSpecsQuestions_1.PROJECT_TYPE_CHOICES[0]];
|
|
11
|
+
/**
|
|
12
|
+
* What is wrong with a project name, in `init`'s words (`hint` is the terminal's extra line), or null.
|
|
13
|
+
* The allowlist prevents filesystem issues and Handlebars template injection (SEC-004.1). The rule lives
|
|
14
|
+
* in the page's `ui/route.js`, which checks the name as it is typed in, so there is one copy (BL-PM-004).
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
|
+
exports.projectNameError = require('../../ui/route.js').projectNameError;
|
|
18
|
+
/** `specpilot serve` asks the context questions only for Greenfield: `init` writes them nowhere for Brownfield (BL-082). */
|
|
19
|
+
const GREENFIELD_ONLY = { projectType: 'greenfield' };
|
|
20
|
+
/** The four project-context questions, in order; only the first is required. */
|
|
21
|
+
exports.CONTEXT_QUESTIONS = [
|
|
22
|
+
{ key: 'whatItDoes', message: 'What does your project do? (required):', required: true, when: GREENFIELD_ONLY },
|
|
23
|
+
{ key: 'targetUsers', message: 'Who are the target users? (Enter to skip):', required: false, when: GREENFIELD_ONLY },
|
|
24
|
+
{ key: 'expectedScale', message: 'What\'s the expected scale? (Enter to skip):', required: false, when: GREENFIELD_ONLY },
|
|
25
|
+
{ key: 'constraints', message: 'Any key constraints or requirements? (Enter to skip):', required: false, when: GREENFIELD_ONLY },
|
|
26
|
+
];
|
|
27
|
+
exports.NOT_SPECIFIED = 'Not specified — use your judgment and mark as [ASSUMPTION]';
|
|
28
|
+
/** The `generateSpecs()` options `init` builds from the project name and the answers. */
|
|
29
|
+
function initOptions(targetDir, projectName, answers, specsName = '.specs') {
|
|
30
|
+
return {
|
|
31
|
+
projectName,
|
|
32
|
+
language: answers.language,
|
|
33
|
+
framework: answers.framework,
|
|
34
|
+
targetDir,
|
|
35
|
+
specsName,
|
|
36
|
+
author: answers.handle,
|
|
37
|
+
ide: answers.ide,
|
|
38
|
+
mode: 'new',
|
|
39
|
+
projectType: answers.projectType,
|
|
40
|
+
apiParadigm: answers.apiParadigm,
|
|
41
|
+
projectContext: {
|
|
42
|
+
whatItDoes: answers.whatItDoes || exports.NOT_SPECIFIED,
|
|
43
|
+
targetUsers: answers.targetUsers || exports.NOT_SPECIFIED,
|
|
44
|
+
expectedScale: answers.expectedScale || exports.NOT_SPECIFIED,
|
|
45
|
+
constraints: answers.constraints || exports.NOT_SPECIFIED,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=initQuestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initQuestions.js","sourceRoot":"","sources":["../../src/utils/initQuestions.ts"],"names":[],"mappings":";;;AAuCA,kCAmBC;AA1DD,2DAA4E;AAG5E,uGAAuG;AACvG,8FAA8F;AAC9F,sFAAsF;AAEtF,qCAAqC;AACxB,QAAA,yBAAyB,GAAG,CAAC,wCAAoB,CAAC,CAAC,CAAC,EAAE,wCAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5F;;;;GAIG;AACH,8DAA8D;AAC/C,wBAAgB,GAAK,OAAO,CAAC,mBAAmB,CAAsF,kBAAC;AAEtJ,4HAA4H;AAC5H,MAAM,eAAe,GAAG,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;AACtD,gFAAgF;AACnE,QAAA,iBAAiB,GAAG;IAC/B,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,wCAAwC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE;IAC/G,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,4CAA4C,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE;IACrH,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,8CAA8C,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE;IACzH,EAAE,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,uDAAuD,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE;CACxH,CAAC;AAEE,QAAA,aAAa,GAAG,4DAA4D,CAAC;AAU1F,yFAAyF;AACzF,SAAgB,WAAW,CAAC,SAAiB,EAAE,WAAmB,EAAE,OAAoB,EAAE,SAAS,GAAG,QAAQ;IAC5G,OAAO;QACL,WAAW;QACX,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS;QACT,SAAS;QACT,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,cAAc,EAAE;YACd,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,qBAAa;YAC/C,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,qBAAa;YACjD,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,qBAAa;YACrD,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,qBAAa;SAClD;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
/** `checkOpenPath()`'s refusal of the home folder and of a file-system root. */
|
|
51
|
+
export declare const HOME_OR_ROOT_ERROR = "SpecPilot does not open your home folder or the root of a drive.";
|
|
52
|
+
export type OpenCheck = {
|
|
53
|
+
root: string;
|
|
54
|
+
} | {
|
|
55
|
+
status: 409 | 422;
|
|
56
|
+
error: string;
|
|
57
|
+
project?: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* The add route's path rule, in one place: `~` expanded against `home`, absolute, realpath-resolved,
|
|
61
|
+
* a directory, not the home folder, not a file-system root, not a served root. Makes no call on the
|
|
62
|
+
* folder but `realpath` and `stat`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function checkOpenPath(input: string, roots: string[], home: string): OpenCheck;
|
|
65
|
+
//# 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;I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