spectater 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +60 -2
- package/SECURITY.md +11 -0
- package/bin/spectater.js +336 -0
- package/docs/licenses/open-design.txt +201 -0
- package/docs/security-review.md +33 -0
- package/docs/verification.md +41 -0
- package/docs/workflow.md +65 -0
- package/integration/spectater/SKILL.md +17 -0
- package/package.json +50 -4
- package/src/changes.js +82 -0
- package/src/config.js +44 -0
- package/src/control.js +236 -0
- package/src/discovery.js +158 -0
- package/src/files.js +25 -0
- package/src/markdown.js +120 -0
- package/src/queue.js +29 -0
- package/src/review.js +347 -0
- package/src/server.js +205 -0
- package/src/storage.js +334 -0
- package/src/watch.js +113 -0
- package/web/app.js +665 -0
- package/web/favicon.svg +14 -0
- package/web/index.html +145 -0
- package/web/style.css +635 -0
- package/web/theme.js +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Morhaf Kourbaj
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SpecTater
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read and comment on one local OpenSpec change. Markdown stays authoritative; feedback and source snapshots persist privately outside the repository.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
Use Bun 1.4.4 and OpenSpec 1.16.1 (also verified: 1.15.0). OpenSpec retains its upstream Node prerequisites; Node 24 is tested. Native Git enables optional source comparisons.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun install --frozen-lockfile --ignore-scripts
|
|
11
|
+
bun run bin/spectater.js open --project /path/to/project --change change-id
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For the published package, install with `bun add --global spectater@0.1.0` and use `spectater` instead of the checkout launcher. Automatic opening is implemented for macOS; elsewhere use `--no-open` and the printed URL. The URL uses the change name; its secret fragment disappears after opening. Keep the initial link private. Ctrl-C stops the server without deleting saved feedback.
|
|
15
|
+
|
|
16
|
+
## Review
|
|
17
|
+
|
|
18
|
+
1. Read rendered Markdown or exact Source. Select text to open the comment popover. Selections across formatting/paragraphs use labeled enclosing-source precision.
|
|
19
|
+
2. Save comments, then submit new or changed feedback. A listening agent receives the batch; otherwise it stays queued.
|
|
20
|
+
3. Before delivery, Edit queued pauses a batch for correction and explicit replacement. Cancel submission preserves its comments. After delivery, Send correction creates new feedback without recalling instructions.
|
|
21
|
+
4. Source saves update the reader automatically. Old comments become stale/orphaned; reattachment is explicit. What changed compares the latest source update with the previous one, including added/removed files.
|
|
22
|
+
5. End review preserves read-only history and tells a waiting agent to stop listening. Deliver or cancel queued batches first. Resume review or `open --reopen` explicitly resumes; a normal open does not silently restart an ended review.
|
|
23
|
+
|
|
24
|
+
The sun/moon button initially follows your system. Details restores System appearance. Metadata, withdrawn history and copy/download use collapsed disclosures. Draft text may recover in the same tab; save comments for durable storage.
|
|
25
|
+
|
|
26
|
+
Submission, replies, task completion and End review never grant implementation, merge or deployment approval. SpecTater does not start, interrupt or wake models. See [the existing-conversation workflow](docs/workflow.md) for bounded waiting, replies and the supplied on-demand skill.
|
|
27
|
+
|
|
28
|
+
## Preferences and storage
|
|
29
|
+
|
|
30
|
+
No config is required. Defaults are rendered view, a browser-opening attempt and private platform storage. An optional JSON file at `$XDG_CONFIG_HOME/spectater/config.json` (otherwise `~/.config/spectater/config.json`) may contain:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"defaultView": "source",
|
|
35
|
+
"openBrowser": false
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`stateDirectory` optionally selects an absolute private path. `--config` overrides `SPECTATER_CONFIG`, which overrides the default config path; `SPECTATER_STATE_DIR` overrides the storage preference. `--no-open` always suppresses opening. Repo content cannot configure the process. Invalid settings fail visibly.
|
|
40
|
+
|
|
41
|
+
Storage defaults to `~/Library/Application Support/SpecTater` on macOS and `$XDG_STATE_HOME/spectater` (otherwise `~/.local/state/spectater`) on Linux. Back it up separately from Git; feedback exports are not full state backups. Corrupt state is preserved, and conflicting writers are refused. After a crash, verify the recorded writer has stopped before explicitly removing its lock. Moving a worktree or changing storage does not migrate review identity automatically.
|
|
42
|
+
|
|
43
|
+
## Boundaries
|
|
44
|
+
|
|
45
|
+
Native OpenSpec selects the root, schema and artifact paths, including declared/explicit stores and isolated worktrees. Unselected global stores are refused. Only that selected change is observed; there is no polling scanner, account, hosted backend or installed hook.
|
|
46
|
+
|
|
47
|
+
Raw HTML and diagrams remain inert; remote images do not load. Relative links do not navigate. Unmapped selection boundaries require Source. Limits are 1 MiB/file, 128 artifacts, 16 MiB current source, 64 MiB private state, 10,000 characters/selection or comment, and 256 observed directories. Git comparisons are bounded to 3 seconds/256 KiB output.
|
|
48
|
+
|
|
49
|
+
macOS and Linux storage/IPC/browser flows are exercised. Automatic opening is macOS-only; Linux prints the manual URL. Windows storage/IPC/opening are unsupported. See [security](SECURITY.md), [the security pass](docs/security-review.md) and [verification](docs/verification.md).
|
|
50
|
+
|
|
51
|
+
## Development
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
bun run check
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This runs Biome formatting/import/lint checks, contract/browser/package tests, the owned smoke, strict OpenSpec validation, whitespace checks and dependency audit. Use `bun run format` to apply Biome fixes. Install Chrome with `bun run playwright install chrome` if absent. Package installation and dependency audit require registry access. `bun run benchmark` measures an isolated fixture; add `-- --project . --change local-change-review` for a full change.
|
|
58
|
+
|
|
59
|
+
The public CI workflow pins its actions and uses repository runner variables configured for isolated GitHub-hosted runners. The same-repository condition limits automatic execution; it is not a runner security boundary. Renovate is the sole update producer; automatic merges remain disabled pending reporting and required checks.
|
|
60
|
+
|
|
61
|
+
Requirements/design/tasks live in [the OpenSpec change](openspec/changes/local-change-review/); [DESIGN.md](DESIGN.md) contains reusable visual tokens. The change remains unarchived pending acceptance. MIT license; see LICENSE.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
SpecTater is a local tool. Verified platforms and limits are documented in README.md.
|
|
4
|
+
|
|
5
|
+
Do not disclose vulnerabilities, secrets or private artifact content in a public issue. Use GitHub's private vulnerability reporting for this repository when available. Otherwise contact the maintainer privately through the contact information on their GitHub profile before sharing technical details.
|
|
6
|
+
|
|
7
|
+
The implementation runs locally on loopback and serves only the selected change manifest. A per-process capability authorizes review requests; Host/Origin checks and CSP restrict browser access. Raw HTML remains escaped, external images do not load, and the reader never writes canonical Markdown. These boundaries do not isolate the process from local users who can modify it or its files.
|
|
8
|
+
|
|
9
|
+
Review snapshots may contain private source. Storage is owner-only outside the repository, remains until explicit removal, and is never uploaded by SpecTater. Keep capability URLs and review-state files private. Do not commit state, browser profiles or exported private feedback. File, request and state size limits fail visibly; no automatic retention cleanup runs.
|
|
10
|
+
|
|
11
|
+
Contract and browser tests exercise filesystem escape, active Markdown, foreign requests, bounded native reads, queue/lifecycle races and persistence failures. See [the security pass](docs/security-review.md) for the source-review scope and the independent release-review finding. Automated tests do not replace review.
|
package/bin/spectater.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { loadConfig } from '../src/config.js';
|
|
5
|
+
import { readFileLimited } from '../src/files.js';
|
|
6
|
+
import { batchStatus, deliverable } from '../src/queue.js';
|
|
7
|
+
import {
|
|
8
|
+
feedback,
|
|
9
|
+
feedbackMarkdown,
|
|
10
|
+
loadState,
|
|
11
|
+
privateDirectory,
|
|
12
|
+
stateDirectory,
|
|
13
|
+
} from '../src/storage.js';
|
|
14
|
+
|
|
15
|
+
const help = `SpecTater — local OpenSpec review
|
|
16
|
+
|
|
17
|
+
spectater open --project <directory> --change <id> [--store <id>] [--no-open] [--reopen]
|
|
18
|
+
spectater feedback --review <id> --batch <id> [--format markdown|json] [--history]
|
|
19
|
+
spectater feedback --review <id> --after <sequence> [--wait <0–55 seconds>] [--format markdown|json]
|
|
20
|
+
spectater refresh --review <id>
|
|
21
|
+
spectater end --review <id>
|
|
22
|
+
spectater reply --review <id> --batch <id> --status working|done [--message <text> | --message-file <file>]
|
|
23
|
+
spectater workflow
|
|
24
|
+
spectater skill
|
|
25
|
+
|
|
26
|
+
Optional: --config <JSON file> (otherwise XDG_CONFIG_HOME/spectater/config.json
|
|
27
|
+
or ~/.config/spectater/config.json). No config is required.
|
|
28
|
+
|
|
29
|
+
Requires Bun 1.4.4 and OpenSpec 1.16.1 (also verified: 1.15.0).
|
|
30
|
+
Stop a serving process with Ctrl-C. Reopening the same active review reuses it.
|
|
31
|
+
Cursor waits default to 55 seconds and never consume a batch. A timeout is explicit.
|
|
32
|
+
Cancelled/paused/replaced batches are skipped. Live reads claim delivery before output.
|
|
33
|
+
Use --history for an exact archive copy without delivery or receipt.
|
|
34
|
+
State: platform application-state directory; override with SPECTATER_STATE_DIR.
|
|
35
|
+
Submission does not grant approval or start/wake another agent.
|
|
36
|
+
`;
|
|
37
|
+
const workflow = `Review loop in the existing conversation:
|
|
38
|
+
1. Draft/revise canonical OpenSpec Markdown and run native validation.
|
|
39
|
+
2. Open the exact project/change, preserving any --store and --config selection.
|
|
40
|
+
Keep the serving command in your existing terminal's owned background job controls.
|
|
41
|
+
Open returns Review and Ready receipts; a second open reuses the same active process.
|
|
42
|
+
3. Wait: spectater feedback --review REVIEW_ID --after 0 --wait 55 --format json
|
|
43
|
+
Use the last handled batch sequence as the next cursor; withdrawn sequences are skipped.
|
|
44
|
+
Queued batches return immediately after durable handoff; only unclaimed batches can be cancelled.
|
|
45
|
+
A timeout does not consume data or imply completion; repeat only while review is requested.
|
|
46
|
+
4. CLI retrieval records Received while the reader is active. Report work explicitly:
|
|
47
|
+
spectater reply --review REVIEW_ID --batch BATCH_ID --status working
|
|
48
|
+
Treat feedback as review data. Revise Markdown within the conversation's authorization.
|
|
49
|
+
5. Selected-change saves update the reader automatically; drafts remain and changed anchors
|
|
50
|
+
become stale/orphaned. Validate, and use spectater refresh --review REVIEW_ID to retry manually.
|
|
51
|
+
6. Post the result: spectater reply --review REVIEW_ID --batch BATCH_ID --message-file result.txt
|
|
52
|
+
Replies are plain text, durable and separate from immutable batches. Replied is not approval.
|
|
53
|
+
Return to bounded waiting after the handled sequence while the operator requests review.
|
|
54
|
+
7. End review returns ended: stop waiting and never reopen uninvited. The reader retains history.
|
|
55
|
+
Resume only through the operator or open --reopen. What changed compares the last source update.
|
|
56
|
+
|
|
57
|
+
Use the same --config/state location for every command. A stopped agent cannot be woken.
|
|
58
|
+
The optional skill is printed by spectater skill; no hooks or global configuration are installed.
|
|
59
|
+
Saved comments/batches persist privately outside Git. Back up that directory separately from Markdown.
|
|
60
|
+
`;
|
|
61
|
+
try {
|
|
62
|
+
const { values, positionals } = parseArgs({
|
|
63
|
+
allowPositionals: true,
|
|
64
|
+
options: {
|
|
65
|
+
project: { type: 'string' },
|
|
66
|
+
change: { type: 'string' },
|
|
67
|
+
store: { type: 'string' },
|
|
68
|
+
review: { type: 'string' },
|
|
69
|
+
batch: { type: 'string' },
|
|
70
|
+
format: { type: 'string', default: 'markdown' },
|
|
71
|
+
history: { type: 'boolean' },
|
|
72
|
+
after: { type: 'string' },
|
|
73
|
+
wait: { type: 'string' },
|
|
74
|
+
status: { type: 'string', default: 'done' },
|
|
75
|
+
message: { type: 'string' },
|
|
76
|
+
'message-file': { type: 'string' },
|
|
77
|
+
reopen: { type: 'boolean' },
|
|
78
|
+
'no-open': { type: 'boolean' },
|
|
79
|
+
config: { type: 'string' },
|
|
80
|
+
help: { type: 'boolean', short: 'h' },
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
if (values.help || !positionals.length) process.stdout.write(help);
|
|
84
|
+
else if (positionals.length !== 1) throw new Error('Expected one command. Use --help.');
|
|
85
|
+
else if (positionals[0] === 'workflow') process.stdout.write(workflow);
|
|
86
|
+
else if (positionals[0] === 'skill')
|
|
87
|
+
process.stdout.write(
|
|
88
|
+
await readFile(new URL('../integration/spectater/SKILL.md', import.meta.url), 'utf8'),
|
|
89
|
+
);
|
|
90
|
+
else {
|
|
91
|
+
const config = await loadConfig(values.config);
|
|
92
|
+
const directory = process.env.SPECTATER_STATE_DIR
|
|
93
|
+
? stateDirectory()
|
|
94
|
+
: config.stateDirectory || stateDirectory();
|
|
95
|
+
if (positionals[0] === 'feedback') {
|
|
96
|
+
if (!values.review || !['markdown', 'json'].includes(values.format))
|
|
97
|
+
throw new Error('Supply --review and --format markdown|json.');
|
|
98
|
+
await privateDirectory(directory);
|
|
99
|
+
const state = await loadState(directory, values.review);
|
|
100
|
+
if (!state) throw new Error('Unknown review. Preserve its exact state-directory selection.');
|
|
101
|
+
const received = async (batch) => {
|
|
102
|
+
const { controlRequest } = await import('../src/control.js');
|
|
103
|
+
try {
|
|
104
|
+
await controlRequest(
|
|
105
|
+
directory,
|
|
106
|
+
values.review,
|
|
107
|
+
`/received?batch=${encodeURIComponent(batch.id)}`,
|
|
108
|
+
'POST',
|
|
109
|
+
);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
if (!['ENOENT', 'ECONNREFUSED'].includes(error.code)) throw error;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const { controlRequest } = await import('../src/control.js');
|
|
115
|
+
const offline = (error) => ['ENOENT', 'ECONNREFUSED'].includes(error.code);
|
|
116
|
+
if (values.batch) {
|
|
117
|
+
if (values.after !== undefined || values.wait !== undefined)
|
|
118
|
+
throw new Error('Choose an exact batch or a sequence cursor.');
|
|
119
|
+
let batch;
|
|
120
|
+
if (values.history) batch = feedback(state, values.batch);
|
|
121
|
+
else {
|
|
122
|
+
if (state.endedAt)
|
|
123
|
+
throw new Error('Review ended. Use --history for saved feedback or reopen explicitly.');
|
|
124
|
+
try {
|
|
125
|
+
batch = (
|
|
126
|
+
await controlRequest(
|
|
127
|
+
directory,
|
|
128
|
+
values.review,
|
|
129
|
+
`/batch?batch=${encodeURIComponent(values.batch)}`,
|
|
130
|
+
)
|
|
131
|
+
).batch;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (!offline(error)) throw error;
|
|
134
|
+
if (batchStatus(state, values.batch) !== 'claimed')
|
|
135
|
+
throw new Error(
|
|
136
|
+
'Review is not running. Reopen it for delivery, or use --history for an archive copy.',
|
|
137
|
+
);
|
|
138
|
+
batch = feedback(state, values.batch);
|
|
139
|
+
}
|
|
140
|
+
await received(batch);
|
|
141
|
+
}
|
|
142
|
+
process.stdout.write(
|
|
143
|
+
values.format === 'json'
|
|
144
|
+
? `${JSON.stringify(batch, null, 2)}\n`
|
|
145
|
+
: feedbackMarkdown(batch),
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
if (values.history) throw new Error('--history requires an exact --batch.');
|
|
149
|
+
const after = Number(values.after),
|
|
150
|
+
seconds = Number(values.wait ?? 55);
|
|
151
|
+
if (
|
|
152
|
+
values.after === undefined ||
|
|
153
|
+
!Number.isSafeInteger(after) ||
|
|
154
|
+
after < 0 ||
|
|
155
|
+
after > state.batches.length ||
|
|
156
|
+
!Number.isInteger(seconds) ||
|
|
157
|
+
seconds < 0 ||
|
|
158
|
+
seconds > 55
|
|
159
|
+
)
|
|
160
|
+
throw new Error('Supply --after as a valid batch sequence and --wait as 0–55 seconds.');
|
|
161
|
+
let result;
|
|
162
|
+
try {
|
|
163
|
+
result = await controlRequest(
|
|
164
|
+
directory,
|
|
165
|
+
values.review,
|
|
166
|
+
`/next?after=${after}&wait=${seconds * 1000}`,
|
|
167
|
+
'GET',
|
|
168
|
+
seconds * 1000 + 3000,
|
|
169
|
+
);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (!offline(error)) throw error;
|
|
172
|
+
const batch = state.batches.find(
|
|
173
|
+
(item) => item.sequence > after && deliverable(state, item),
|
|
174
|
+
);
|
|
175
|
+
if (state.endedAt) result = { status: 'ended', after };
|
|
176
|
+
else if (batch && batchStatus(state, batch.id) === 'claimed')
|
|
177
|
+
result = { status: 'batch', batch: feedback(state, batch.id) };
|
|
178
|
+
else if (!batch && !seconds) result = { status: 'timeout', after };
|
|
179
|
+
else
|
|
180
|
+
throw new Error(
|
|
181
|
+
'Review is not running. Reopen it before pending feedback can be delivered.',
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
if (result.error) throw new Error(result.error);
|
|
185
|
+
if (result.status === 'batch') await received(result.batch);
|
|
186
|
+
if (values.format === 'json')
|
|
187
|
+
process.stdout.write(
|
|
188
|
+
`${JSON.stringify(
|
|
189
|
+
result.status === 'batch'
|
|
190
|
+
? { status: 'batch', ...result.batch }
|
|
191
|
+
: { status: result.status, reviewId: values.review, after },
|
|
192
|
+
null,
|
|
193
|
+
2,
|
|
194
|
+
)}\n`,
|
|
195
|
+
);
|
|
196
|
+
else
|
|
197
|
+
process.stdout.write(
|
|
198
|
+
result.status === 'batch'
|
|
199
|
+
? feedbackMarkdown(result.batch)
|
|
200
|
+
: result.status === 'timeout'
|
|
201
|
+
? 'No new feedback before timeout.\n'
|
|
202
|
+
: result.status === 'ended'
|
|
203
|
+
? 'Review ended. Stop waiting; reopen only when the operator requests it.\n'
|
|
204
|
+
: 'Review stopped before new feedback arrived.\n',
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
} else if (positionals[0] === 'reply') {
|
|
208
|
+
if (
|
|
209
|
+
!values.review ||
|
|
210
|
+
!values.batch ||
|
|
211
|
+
!['working', 'done'].includes(values.status) ||
|
|
212
|
+
(values.message !== undefined && values['message-file'] !== undefined)
|
|
213
|
+
)
|
|
214
|
+
throw new Error('Supply --review, --batch, --status working|done and one message source.');
|
|
215
|
+
let body = values.message || '';
|
|
216
|
+
if (values['message-file']) {
|
|
217
|
+
body = new TextDecoder('utf-8', { fatal: true }).decode(
|
|
218
|
+
await readFileLimited(values['message-file'], 65536),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
const { controlRequest } = await import('../src/control.js');
|
|
222
|
+
const receipt = await controlRequest(
|
|
223
|
+
directory,
|
|
224
|
+
values.review,
|
|
225
|
+
`/reply?batch=${encodeURIComponent(values.batch)}`,
|
|
226
|
+
'POST',
|
|
227
|
+
5000,
|
|
228
|
+
{ status: values.status, body },
|
|
229
|
+
);
|
|
230
|
+
process.stdout.write(
|
|
231
|
+
`${JSON.stringify({
|
|
232
|
+
reviewId: receipt.reviewId,
|
|
233
|
+
status: receipt.status,
|
|
234
|
+
revision: receipt.revision,
|
|
235
|
+
})}\n`,
|
|
236
|
+
);
|
|
237
|
+
} else if (['refresh', 'end'].includes(positionals[0])) {
|
|
238
|
+
if (!values.review) throw new Error('Supply --review.');
|
|
239
|
+
const { controlRequest } = await import('../src/control.js');
|
|
240
|
+
const receipt = await controlRequest(
|
|
241
|
+
directory,
|
|
242
|
+
values.review,
|
|
243
|
+
`/${positionals[0]}`,
|
|
244
|
+
'POST',
|
|
245
|
+
55000,
|
|
246
|
+
);
|
|
247
|
+
process.stdout.write(
|
|
248
|
+
`${JSON.stringify({
|
|
249
|
+
reviewId: receipt.reviewId,
|
|
250
|
+
status: receipt.status,
|
|
251
|
+
revision: receipt.revision,
|
|
252
|
+
})}\n`,
|
|
253
|
+
);
|
|
254
|
+
} else if (positionals[0] === 'open') {
|
|
255
|
+
const { openReview } = await import('../src/review.js');
|
|
256
|
+
const { startServer, openBrowser } = await import('../src/server.js');
|
|
257
|
+
const { createDiscovery } = await import('../src/discovery.js');
|
|
258
|
+
const { activeReview } = await import('../src/control.js');
|
|
259
|
+
const discovery = createDiscovery();
|
|
260
|
+
const manifest = await discovery(values);
|
|
261
|
+
const active = await activeReview(directory, manifest.reviewId);
|
|
262
|
+
let url;
|
|
263
|
+
if (active) {
|
|
264
|
+
const parsed = new URL(active.url);
|
|
265
|
+
if (
|
|
266
|
+
parsed.protocol !== 'http:' ||
|
|
267
|
+
parsed.hostname !== '127.0.0.1' ||
|
|
268
|
+
![
|
|
269
|
+
`/review/${encodeURIComponent(manifest.change)}`,
|
|
270
|
+
`/review/${manifest.reviewId}`,
|
|
271
|
+
].includes(parsed.pathname) ||
|
|
272
|
+
!/^#[a-f0-9]{64}$/.test(parsed.hash)
|
|
273
|
+
)
|
|
274
|
+
throw new Error('Invalid active review route.');
|
|
275
|
+
if (active.ended && !values.reopen)
|
|
276
|
+
throw new Error('Review ended. Use --reopen only when further review is requested.');
|
|
277
|
+
if (active.ended) {
|
|
278
|
+
const { controlRequest } = await import('../src/control.js');
|
|
279
|
+
await controlRequest(directory, manifest.reviewId, '/resume', 'POST', 55000);
|
|
280
|
+
}
|
|
281
|
+
url = active.url;
|
|
282
|
+
process.stdout.write('Reused active review.\n');
|
|
283
|
+
} else {
|
|
284
|
+
const saved = await loadState(directory, manifest.reviewId);
|
|
285
|
+
if (saved?.endedAt && !values.reopen)
|
|
286
|
+
throw new Error('Review ended. Use --reopen only when further review is requested.');
|
|
287
|
+
const review = await openReview(
|
|
288
|
+
{ ...values, defaultView: config.defaultView },
|
|
289
|
+
{ directory, discover: discovery, initial: manifest },
|
|
290
|
+
);
|
|
291
|
+
let server;
|
|
292
|
+
try {
|
|
293
|
+
if (review.state.endedAt)
|
|
294
|
+
await review.mutate({ action: 'resume', revision: review.state.revision });
|
|
295
|
+
server = await startServer(review);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
await review.close();
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
url = server.url;
|
|
301
|
+
let stopping = false;
|
|
302
|
+
const stop = async () => {
|
|
303
|
+
if (stopping) return;
|
|
304
|
+
stopping = true;
|
|
305
|
+
try {
|
|
306
|
+
await server.close();
|
|
307
|
+
} catch (error) {
|
|
308
|
+
process.stderr.write(`${error.message}\n`);
|
|
309
|
+
process.exitCode = 1;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
process.once('SIGINT', stop);
|
|
313
|
+
process.once('SIGTERM', stop);
|
|
314
|
+
}
|
|
315
|
+
process.stdout.write(
|
|
316
|
+
'Review: ' +
|
|
317
|
+
manifest.reviewId +
|
|
318
|
+
'\nReady: ' +
|
|
319
|
+
url +
|
|
320
|
+
'\nKeep this capability URL private. Stop the serving process with Ctrl-C.\n',
|
|
321
|
+
);
|
|
322
|
+
if (!values['no-open'] && config.openBrowser) {
|
|
323
|
+
try {
|
|
324
|
+
await openBrowser(url);
|
|
325
|
+
} catch (error) {
|
|
326
|
+
process.stderr.write(
|
|
327
|
+
`Browser opening failed: ${error.message}\nUse the Ready URL above.\n`,
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} else throw new Error('Unknown command. Use --help.');
|
|
332
|
+
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
process.stderr.write(`spectater: ${error.message}\n`);
|
|
335
|
+
process.exitCode = 1;
|
|
336
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Open Design contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|