shapewall 0.0.0-stage → 0.2.2
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/CHANGELOG.md +139 -0
- package/Dockerfile.agent +45 -0
- package/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +651 -2
- package/THIRD_PARTY.md +165 -0
- package/bin/shapewall.js +29 -0
- package/dist/agent/package-lock.json +8384 -0
- package/dist/client/assets/BoardChat-D5SFd8HE.js +28 -0
- package/dist/client/assets/BuzzDialog-HWXBy52W.js +1 -0
- package/dist/client/assets/ChecksPanel-DTdImWoD.js +1 -0
- package/dist/client/assets/History-CEv6b-av.js +1 -0
- package/dist/client/assets/LocalSettings-C4vriEVQ.js +1 -0
- package/dist/client/assets/Management-DCfhcEUY.js +1 -0
- package/dist/client/assets/QuickConnect-DQGgUsl1.js +1 -0
- package/dist/client/assets/ShareDialog-C_plIto0.js +2 -0
- package/dist/client/assets/app-update-dialog-2hPz_N9G.js +1 -0
- package/dist/client/assets/circle-x-BZMPi8Zf.js +1 -0
- package/dist/client/assets/index-ByQRKVit.css +2 -0
- package/dist/client/assets/index-DweQ8Qtu.js +29 -0
- package/dist/client/assets/refresh-cw-CRow0Nbq.js +1 -0
- package/dist/client/assets/runtime-Bft6x_6E.js +4 -0
- package/dist/client/assets/square-A8EnIYLR.js +1 -0
- package/dist/client/assets/tts-dist-DYlBQmwG.js +18 -0
- package/dist/client/assets/tts-en-g2p-BPUtBFGG.js +1 -0
- package/dist/client/assets/tts-ort-wasm-simd-threaded-qh98TCA_.wasm +0 -0
- package/dist/client/assets/tts-ort.wasm.bundle.min-rEkcs_ow.js +12 -0
- package/dist/client/assets/tts-rolldown-runtime-D8NudN84.js +1 -0
- package/dist/client/assets/tts-spacy-en-tokenizer-6SNMl--A.json +1 -0
- package/dist/client/assets/tts-tts.worker-Bzm6aWbv.js +1 -0
- package/dist/client/assets/tts-us_gold-DcjeNMH1.json +92589 -0
- package/dist/client/assets/tts-us_silver-C964mEB5.json +93363 -0
- package/dist/client/assets/ui-CLbws0rx.js +41 -0
- package/dist/client/build-info.json +1 -0
- package/dist/client/favicon.svg +7 -0
- package/dist/client/icons/apple-touch-icon.png +0 -0
- package/dist/client/icons/icon-192.png +0 -0
- package/dist/client/icons/icon-512.png +0 -0
- package/dist/client/icons/maskable-512.png +0 -0
- package/dist/client/index.html +25 -0
- package/dist/client/manifest.webmanifest +15 -0
- package/dist/client/sw.js +53 -0
- package/dist/client/theme-boot.js +27 -0
- package/dist/console/assets/LocalAccountsApp-BQCcmj3x.js +1 -0
- package/dist/console/assets/LocalConsole-Bb2FUDs7.js +1 -0
- package/dist/console/assets/app-update-dialog-DIeYepLZ.js +1 -0
- package/dist/console/assets/console-C7uJLLOn.js +51 -0
- package/dist/console/assets/console-R8IBY3Am.css +2 -0
- package/dist/console/build-info.json +1 -0
- package/dist/console/console.html +21 -0
- package/dist/console/favicon.svg +7 -0
- package/dist/console/icons/apple-touch-icon.png +0 -0
- package/dist/console/icons/icon-192.png +0 -0
- package/dist/console/icons/icon-512.png +0 -0
- package/dist/console/icons/maskable-512.png +0 -0
- package/dist/console/manifest.webmanifest +15 -0
- package/dist/console/theme-boot.js +27 -0
- package/docs/agent-hardening.md +342 -0
- package/docs/agent-recipes.md +187 -0
- package/docs/agent-workflow.md +320 -0
- package/docs/agents.md +894 -0
- package/docs/architecture.md +242 -0
- package/docs/buzz.md +140 -0
- package/docs/capture-warnings.md +57 -0
- package/docs/config.md +489 -0
- package/docs/deployment.md +289 -0
- package/docs/design-system.md +162 -0
- package/docs/github.md +107 -0
- package/docs/hosted.md +764 -0
- package/docs/images/board-overview.png +0 -0
- package/docs/images/journeys.png +0 -0
- package/docs/images/live-comment.png +0 -0
- package/docs/images/phone-comment.png +0 -0
- package/docs/images/phone-overview.png +0 -0
- package/docs/images/variant.png +0 -0
- package/docs/interaction-audits.md +40 -0
- package/docs/journeys.md +137 -0
- package/docs/local-accounts.md +80 -0
- package/docs/notifications.md +237 -0
- package/docs/page-checks.md +69 -0
- package/docs/performance.md +174 -0
- package/docs/starter-agent.md +325 -0
- package/docs/updates.md +87 -0
- package/examples/audits/interaction.audit.json +17 -0
- package/package.json +132 -4
- package/src/accounts/avatar.js +121 -0
- package/src/accounts/local.js +464 -0
- package/src/agent/acp/command.js +204 -0
- package/src/agent/acp/detect.js +75 -0
- package/src/agent/acp/sandbox.js +160 -0
- package/src/agent/agent-health.js +75 -0
- package/src/agent/backends/acp.js +1297 -0
- package/src/agent/backends/index.js +61 -0
- package/src/agent/backends/openai.js +308 -0
- package/src/agent/composer.js +221 -0
- package/src/agent/config.js +338 -0
- package/src/agent/context.js +191 -0
- package/src/agent/control.js +122 -0
- package/src/agent/errors.js +17 -0
- package/src/agent/feedback-loop.js +137 -0
- package/src/agent/manage.js +94 -0
- package/src/agent/next-steps.js +51 -0
- package/src/agent/owner-mcp.js +38 -0
- package/src/agent/plain-text.js +52 -0
- package/src/agent/ratings-core.js +213 -0
- package/src/agent/ratings.js +100 -0
- package/src/agent/reply-text.js +67 -0
- package/src/agent/routes.js +1065 -0
- package/src/agent/run.js +326 -0
- package/src/agent/settings-routes.js +704 -0
- package/src/agent/showable.js +23 -0
- package/src/agent/starter/approvals.js +181 -0
- package/src/agent/starter/build-image.js +90 -0
- package/src/agent/starter/cli.js +163 -0
- package/src/agent/starter/disk.js +53 -0
- package/src/agent/starter/doctor.js +180 -0
- package/src/agent/starter/egress-proxy.js +351 -0
- package/src/agent/starter/gate.js +90 -0
- package/src/agent/starter/loop.js +114 -0
- package/src/agent/starter/model-relay.js +289 -0
- package/src/agent/starter/pause.js +14 -0
- package/src/agent/starter/probe.js +272 -0
- package/src/agent/starter/prompt.js +41 -0
- package/src/agent/starter/push-guard.js +146 -0
- package/src/agent/starter/rpc.js +164 -0
- package/src/agent/starter/runtime.js +287 -0
- package/src/agent/starter/sandbox-main.js +121 -0
- package/src/agent/starter/settings.js +290 -0
- package/src/agent/starter/source.js +69 -0
- package/src/agent/starter/supervisor.js +755 -0
- package/src/agent/starter/sweep.js +46 -0
- package/src/agent/starter/tools.js +524 -0
- package/src/agent/starter/watch.js +84 -0
- package/src/agent/starter/worktree.js +409 -0
- package/src/agent/text-diff.js +210 -0
- package/src/agent/thread-history.js +223 -0
- package/src/agent/threads.js +399 -0
- package/src/agent/tools.js +200 -0
- package/src/agent/turn-changes.js +424 -0
- package/src/agent/undo-state.js +26 -0
- package/src/agent/user-settings.js +308 -0
- package/src/auth/record.js +375 -0
- package/src/broken-links.js +164 -0
- package/src/buzz/client.js +75 -0
- package/src/buzz/config.js +151 -0
- package/src/buzz/environment.js +13 -0
- package/src/buzz/gateway.js +192 -0
- package/src/buzz/routes.js +61 -0
- package/src/buzz/signer-child.js +205 -0
- package/src/buzz/store.js +89 -0
- package/src/buzz/transport.js +60 -0
- package/src/buzz/verify.js +140 -0
- package/src/capture/actions.js +159 -0
- package/src/capture/capture.js +776 -0
- package/src/capture/dom-names.js +189 -0
- package/src/capture/element-map.js +509 -0
- package/src/capture/live.js +827 -0
- package/src/capture/media-scheme.js +317 -0
- package/src/capture/network-summary.js +86 -0
- package/src/capture/pacing.js +34 -0
- package/src/capture/requests.js +167 -0
- package/src/capture/sanitize.js +752 -0
- package/src/checks/accessibility.js +134 -0
- package/src/checks/budgets.js +58 -0
- package/src/checks/cli.js +55 -0
- package/src/checks/comparison.js +113 -0
- package/src/checks/environments.js +32 -0
- package/src/checks/flow-config.js +82 -0
- package/src/checks/flow-origin.js +53 -0
- package/src/checks/flows.js +398 -0
- package/src/checks/lighthouse-auth.js +145 -0
- package/src/checks/lighthouse-findings.js +130 -0
- package/src/checks/lighthouse.js +395 -0
- package/src/checks/robots.js +85 -0
- package/src/checks/routes.js +52 -0
- package/src/checks/run-control.js +259 -0
- package/src/checks/runner.js +724 -0
- package/src/checks/schema.js +133 -0
- package/src/checks/seo-analysis.js +443 -0
- package/src/checks/seo-probe.js +190 -0
- package/src/checks/seo-snapshot.js +99 -0
- package/src/checks/store.js +214 -0
- package/src/checks/transport.js +47 -0
- package/src/cli/args.js +319 -0
- package/src/cli/capture.js +79 -0
- package/src/cli/commands.js +92 -0
- package/src/cli/comments.js +84 -0
- package/src/cli/help.js +243 -0
- package/src/cli/init.js +214 -0
- package/src/cli/misc.js +64 -0
- package/src/cli/notify.js +87 -0
- package/src/cli/open.js +22 -0
- package/src/cli/serve.js +274 -0
- package/src/cli/variant.js +82 -0
- package/src/cli/watch.js +70 -0
- package/src/cli.js +130 -0
- package/src/comment-fields.js +76 -0
- package/src/comments-cli.js +208 -0
- package/src/config-reload.js +100 -0
- package/src/config.js +1061 -0
- package/src/devices-cli.js +21 -0
- package/src/diff.js +95 -0
- package/src/discover.js +284 -0
- package/src/doctor.js +295 -0
- package/src/event-log.js +268 -0
- package/src/events-cli.js +102 -0
- package/src/events.js +113 -0
- package/src/export.js +119 -0
- package/src/feedback.js +246 -0
- package/src/github.js +551 -0
- package/src/hosted/LICENSE.md +105 -0
- package/src/hosted/access-cli.js +78 -0
- package/src/hosted/admin.js +682 -0
- package/src/hosted/agent-approvals.js +163 -0
- package/src/hosted/agent-policy.js +189 -0
- package/src/hosted/app.js +510 -0
- package/src/hosted/auth-routes.js +540 -0
- package/src/hosted/auth.js +536 -0
- package/src/hosted/backup.js +483 -0
- package/src/hosted/board-context.js +35 -0
- package/src/hosted/board-routes.js +486 -0
- package/src/hosted/board-view.js +94 -0
- package/src/hosted/clean-worker.js +24 -0
- package/src/hosted/cleaner.js +89 -0
- package/src/hosted/comments.js +355 -0
- package/src/hosted/console-routes.js +401 -0
- package/src/hosted/cookies.js +18 -0
- package/src/hosted/crypto.js +80 -0
- package/src/hosted/db.js +496 -0
- package/src/hosted/device-routes.js +175 -0
- package/src/hosted/device.js +233 -0
- package/src/hosted/events.js +63 -0
- package/src/hosted/guards.js +172 -0
- package/src/hosted/guest-view.js +65 -0
- package/src/hosted/http.js +39 -0
- package/src/hosted/import.js +300 -0
- package/src/hosted/mail.js +73 -0
- package/src/hosted/mcp-http.js +71 -0
- package/src/hosted/membership.js +114 -0
- package/src/hosted/operator.js +478 -0
- package/src/hosted/ops-cli.js +345 -0
- package/src/hosted/pages.js +146 -0
- package/src/hosted/permissions.js +113 -0
- package/src/hosted/presence.js +372 -0
- package/src/hosted/projects.js +124 -0
- package/src/hosted/public.js +109 -0
- package/src/hosted/push.js +622 -0
- package/src/hosted/quotas.js +115 -0
- package/src/hosted/ratelimit.js +96 -0
- package/src/hosted/rebind.js +316 -0
- package/src/hosted/retention.js +128 -0
- package/src/hosted/server.js +260 -0
- package/src/hosted/setup-link.js +64 -0
- package/src/hosted/setup.js +323 -0
- package/src/hosted/shares.js +444 -0
- package/src/hosted/tailscale.js +204 -0
- package/src/hosted/tenancy.js +301 -0
- package/src/hosted/token-api.js +455 -0
- package/src/hosted/token-events.js +60 -0
- package/src/hosted/tokens.js +57 -0
- package/src/hosted/turnstile.js +49 -0
- package/src/hosted/usercontent.js +154 -0
- package/src/hosted/zip.js +155 -0
- package/src/invocation.js +58 -0
- package/src/journey-paths.js +282 -0
- package/src/journeys.js +189 -0
- package/src/links.js +106 -0
- package/src/local-projects.js +182 -0
- package/src/lock.js +193 -0
- package/src/mcp.js +417 -0
- package/src/mentions.js +151 -0
- package/src/net.js +15 -0
- package/src/notify/config.js +275 -0
- package/src/notify/index.js +301 -0
- package/src/notify/lease.js +73 -0
- package/src/notify/messages.js +212 -0
- package/src/notify/run.js +174 -0
- package/src/pixeldiff.js +49 -0
- package/src/png.js +143 -0
- package/src/reactions.js +111 -0
- package/src/remote/cli.js +133 -0
- package/src/remote/credentials.js +62 -0
- package/src/remote/ids.js +12 -0
- package/src/remote/login.js +155 -0
- package/src/remote/remote-mcp.js +237 -0
- package/src/remote/remote-watch.js +291 -0
- package/src/remote/remote.js +313 -0
- package/src/remote/share-state.js +78 -0
- package/src/remote/share.js +369 -0
- package/src/remote/terminal.js +13 -0
- package/src/serve-state.js +64 -0
- package/src/server/app.js +824 -0
- package/src/server/devices.js +186 -0
- package/src/server/local-console.js +28 -0
- package/src/server/local-user.js +59 -0
- package/src/server/pairing-routes.js +159 -0
- package/src/server/share-routes.js +89 -0
- package/src/server/tailscale.js +97 -0
- package/src/sitemap.js +431 -0
- package/src/store.js +983 -0
- package/src/tokens.js +11 -0
- package/src/update/routes.js +245 -0
- package/src/watch.js +403 -0
- package/src/which.js +58 -0
package/src/cli/args.js
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// Command line parsing: the flags each command takes, and "did you mean" for typos.
|
|
2
|
+
|
|
3
|
+
import { AUTH_FLAGS, AUTH_BOOLEAN_FLAGS } from '../auth/record.js'
|
|
4
|
+
import { cliCommand } from '../invocation.js'
|
|
5
|
+
|
|
6
|
+
const BOOLEAN_FLAGS = new Set([
|
|
7
|
+
...AUTH_BOOLEAN_FLAGS,
|
|
8
|
+
'seo',
|
|
9
|
+
'no-seo',
|
|
10
|
+
'no-discover',
|
|
11
|
+
'include-checks',
|
|
12
|
+
'accounts',
|
|
13
|
+
'tailscale',
|
|
14
|
+
'lan',
|
|
15
|
+
'no-identity',
|
|
16
|
+
'no-remote-chat',
|
|
17
|
+
'approve-on-host',
|
|
18
|
+
'for-agent',
|
|
19
|
+
'force',
|
|
20
|
+
'read-only',
|
|
21
|
+
'no-capture',
|
|
22
|
+
'open',
|
|
23
|
+
'resolved',
|
|
24
|
+
'all',
|
|
25
|
+
'json',
|
|
26
|
+
'no-comments',
|
|
27
|
+
'browser-comments',
|
|
28
|
+
'noindex',
|
|
29
|
+
'help',
|
|
30
|
+
'version',
|
|
31
|
+
'new-only',
|
|
32
|
+
'once',
|
|
33
|
+
'install-browser',
|
|
34
|
+
'no-launch',
|
|
35
|
+
'trust-proxy',
|
|
36
|
+
'new',
|
|
37
|
+
'status',
|
|
38
|
+
'pass-token',
|
|
39
|
+
'include-guests',
|
|
40
|
+
'dry-run',
|
|
41
|
+
'chat',
|
|
42
|
+
'no-chat',
|
|
43
|
+
'allow-remote-agent',
|
|
44
|
+
'pr',
|
|
45
|
+
'retry',
|
|
46
|
+
'trust-comment',
|
|
47
|
+
'allow-ci-push',
|
|
48
|
+
'no-egress',
|
|
49
|
+
'yes',
|
|
50
|
+
'check-external',
|
|
51
|
+
'broken',
|
|
52
|
+
'follow',
|
|
53
|
+
'no-claim',
|
|
54
|
+
'tailscale',
|
|
55
|
+
'funnel',
|
|
56
|
+
'setup',
|
|
57
|
+
'start',
|
|
58
|
+
'print',
|
|
59
|
+
'run',
|
|
60
|
+
'check',
|
|
61
|
+
'recapture',
|
|
62
|
+
])
|
|
63
|
+
const REPEATABLE = new Set(['only', 'allowed-host', 'exclude', 'allow-host', 'trusted'])
|
|
64
|
+
// Flags that take a value but also work alone ("init --sitemap": the base
|
|
65
|
+
// URL's sitemap.xml). Alone, the flag is true.
|
|
66
|
+
const OPTIONAL_VALUE = new Set(['sitemap'])
|
|
67
|
+
|
|
68
|
+
// The flags each command reads. Anything else is a typo worth stopping for:
|
|
69
|
+
// "capture --onyl home" would otherwise capture every page.
|
|
70
|
+
const GLOBAL_FLAGS = ['config', 'help', 'version']
|
|
71
|
+
const REMOTE_FLAGS = ['remote', 'token-file', 'include-guests']
|
|
72
|
+
export const COMMAND_FLAGS = {
|
|
73
|
+
'buzz-bridge': ['bridge-config'],
|
|
74
|
+
settings: ['port', 'open'],
|
|
75
|
+
auth: AUTH_FLAGS,
|
|
76
|
+
init: ['base-url', 'sitemap', 'no-discover', 'force', 'limit', 'group', 'exclude'],
|
|
77
|
+
sitemap: ['limit', 'group', 'exclude', 'board', 'dry-run', 'json'],
|
|
78
|
+
capture: ['board', 'only', 'env', 'json', 'yes', 'check-external'],
|
|
79
|
+
checks: ['board', 'only', 'env', 'seo', 'no-seo', 'limit', 'source-build', 'json', 'flow-file', 'viewport'],
|
|
80
|
+
audit: [
|
|
81
|
+
'board',
|
|
82
|
+
'only',
|
|
83
|
+
'env',
|
|
84
|
+
'viewports',
|
|
85
|
+
'samples',
|
|
86
|
+
'max-pages',
|
|
87
|
+
'max-runs',
|
|
88
|
+
'cache',
|
|
89
|
+
'production',
|
|
90
|
+
'source-build',
|
|
91
|
+
'browser-version',
|
|
92
|
+
'seo',
|
|
93
|
+
'no-seo',
|
|
94
|
+
'json',
|
|
95
|
+
],
|
|
96
|
+
serve: [
|
|
97
|
+
'buzz-bridge',
|
|
98
|
+
'accounts',
|
|
99
|
+
'accounts-origin',
|
|
100
|
+
'port',
|
|
101
|
+
'host',
|
|
102
|
+
'open',
|
|
103
|
+
'read-only',
|
|
104
|
+
'no-capture',
|
|
105
|
+
'allowed-host',
|
|
106
|
+
'chat',
|
|
107
|
+
'no-chat',
|
|
108
|
+
'agent-acp',
|
|
109
|
+
'allow-remote-agent',
|
|
110
|
+
'tailscale',
|
|
111
|
+
'lan',
|
|
112
|
+
'no-identity',
|
|
113
|
+
'no-remote-chat',
|
|
114
|
+
'approve-on-host',
|
|
115
|
+
'tls-cert',
|
|
116
|
+
'tls-key',
|
|
117
|
+
],
|
|
118
|
+
devices: ['json', 'all'],
|
|
119
|
+
comments: [
|
|
120
|
+
'open',
|
|
121
|
+
'resolved',
|
|
122
|
+
'all',
|
|
123
|
+
'page',
|
|
124
|
+
'mention',
|
|
125
|
+
'since',
|
|
126
|
+
'viewport',
|
|
127
|
+
'selector',
|
|
128
|
+
'json',
|
|
129
|
+
'for-agent',
|
|
130
|
+
'note',
|
|
131
|
+
'ref',
|
|
132
|
+
'body',
|
|
133
|
+
'author',
|
|
134
|
+
'board',
|
|
135
|
+
...REMOTE_FLAGS,
|
|
136
|
+
],
|
|
137
|
+
events: ['follow', 'since', 'limit', 'json', 'board'],
|
|
138
|
+
journeys: ['json', 'board'],
|
|
139
|
+
links: ['broken', 'board', 'env', 'json'],
|
|
140
|
+
watch: ['recapture', 'exec', 'concurrency', 'new-only', 'once', 'timeout', 'mention', 'no-claim', 'board', 'pass-token', ...REMOTE_FLAGS],
|
|
141
|
+
agent: [
|
|
142
|
+
'comment',
|
|
143
|
+
'pr',
|
|
144
|
+
'git-remote',
|
|
145
|
+
'fork-remote',
|
|
146
|
+
'retry',
|
|
147
|
+
'trust-comment',
|
|
148
|
+
'max-turns',
|
|
149
|
+
'max-tokens',
|
|
150
|
+
'max-minutes',
|
|
151
|
+
'max-disk',
|
|
152
|
+
'model-timeout',
|
|
153
|
+
'trusted',
|
|
154
|
+
'runtime',
|
|
155
|
+
'image',
|
|
156
|
+
'profile',
|
|
157
|
+
'allow-host',
|
|
158
|
+
'registry',
|
|
159
|
+
'work-dir',
|
|
160
|
+
'once',
|
|
161
|
+
'no-egress',
|
|
162
|
+
'allow-ci-push',
|
|
163
|
+
'json',
|
|
164
|
+
'board',
|
|
165
|
+
...REMOTE_FLAGS,
|
|
166
|
+
],
|
|
167
|
+
github: ['board', 'json'],
|
|
168
|
+
mcp: ['read-only', 'no-capture', ...REMOTE_FLAGS],
|
|
169
|
+
notify: ['json', 'to', 'board'],
|
|
170
|
+
doctor: ['install-browser', 'port', 'agent-acp', 'json', 'no-launch'],
|
|
171
|
+
variant: ['url', 'path', 'title', 'note', 'source', 'id', 'viewport', 'board', 'json'],
|
|
172
|
+
export: ['out', 'no-comments', 'browser-comments', 'noindex', 'include-checks'],
|
|
173
|
+
push: ['remote', 'token-file', 'board', 'include-checks'],
|
|
174
|
+
share: ['remote', 'token-file', 'board', 'dry-run', 'no-comments', 'include-checks'],
|
|
175
|
+
hosted: [
|
|
176
|
+
'data',
|
|
177
|
+
'origin',
|
|
178
|
+
'port',
|
|
179
|
+
'host',
|
|
180
|
+
'signup',
|
|
181
|
+
'trust-proxy',
|
|
182
|
+
'previous-origin',
|
|
183
|
+
'report-email',
|
|
184
|
+
'new',
|
|
185
|
+
'days',
|
|
186
|
+
'status',
|
|
187
|
+
'tailscale',
|
|
188
|
+
'tailscale-port',
|
|
189
|
+
'funnel',
|
|
190
|
+
'funnel-port',
|
|
191
|
+
'quotas',
|
|
192
|
+
'retention-hours',
|
|
193
|
+
'retention-keep',
|
|
194
|
+
'setup',
|
|
195
|
+
'domain',
|
|
196
|
+
'usercontent-domain',
|
|
197
|
+
'usercontent-origin',
|
|
198
|
+
'email',
|
|
199
|
+
'dir',
|
|
200
|
+
'source',
|
|
201
|
+
'dry-run',
|
|
202
|
+
'force',
|
|
203
|
+
'start',
|
|
204
|
+
'print',
|
|
205
|
+
'operator',
|
|
206
|
+
'json',
|
|
207
|
+
'reason',
|
|
208
|
+
'note',
|
|
209
|
+
'confirm',
|
|
210
|
+
'out',
|
|
211
|
+
'all',
|
|
212
|
+
'keep',
|
|
213
|
+
'run',
|
|
214
|
+
'limit',
|
|
215
|
+
'to',
|
|
216
|
+
'from',
|
|
217
|
+
'keep-days',
|
|
218
|
+
'check',
|
|
219
|
+
],
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Edit distance with swapped neighbours as one edit ("onyl" is one from
|
|
223
|
+
// "only"), for "did you mean".
|
|
224
|
+
function distance(a, b) {
|
|
225
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_, j) => (i ? (j ? 0 : i) : j)))
|
|
226
|
+
for (let i = 1; i <= a.length; i += 1) {
|
|
227
|
+
for (let j = 1; j <= b.length; j += 1) {
|
|
228
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1
|
|
229
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost)
|
|
230
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return d[a.length][b.length]
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// The closest known flag, if it is close enough to be a typo.
|
|
237
|
+
export function suggestFlag(key, known) {
|
|
238
|
+
let best = null
|
|
239
|
+
let bestScore = Infinity
|
|
240
|
+
for (const name of known) {
|
|
241
|
+
const score = distance(key, name)
|
|
242
|
+
if (score < bestScore) {
|
|
243
|
+
best = name
|
|
244
|
+
bestScore = score
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const allowed = Math.max(1, Math.min(3, Math.floor(key.length / 3)))
|
|
248
|
+
return best && (bestScore <= allowed || best.startsWith(key) || key.startsWith(best)) ? best : null
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function unknownFlag(key, command) {
|
|
252
|
+
const known = [...(COMMAND_FLAGS[command] || []), ...GLOBAL_FLAGS]
|
|
253
|
+
const hint = suggestFlag(key, known)
|
|
254
|
+
const error = new Error(
|
|
255
|
+
`unknown option --${key} for "${command}"${hint ? ` (did you mean --${hint}?)` : ''}. "${cliCommand(`${command} --help`)}" lists its options.`,
|
|
256
|
+
)
|
|
257
|
+
error.code = 'unknown_flag'
|
|
258
|
+
return error
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Parses argv into { command, positional, flags }. With `strict`, a flag the
|
|
262
|
+
// command does not take is an error (before it can swallow the next word as
|
|
263
|
+
// its value), with the closest real flag as a hint.
|
|
264
|
+
export function parseArgs(argv, { strict = false } = {}) {
|
|
265
|
+
const positional = []
|
|
266
|
+
const flags = {}
|
|
267
|
+
const seen = []
|
|
268
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
269
|
+
let arg = argv[index]
|
|
270
|
+
if (arg === '-h') arg = '--help'
|
|
271
|
+
if (arg === '-v') arg = '--version'
|
|
272
|
+
if (arg === '-y') arg = '--yes'
|
|
273
|
+
if (!arg.startsWith('--')) {
|
|
274
|
+
positional.push(arg)
|
|
275
|
+
continue
|
|
276
|
+
}
|
|
277
|
+
let key = arg.slice(2)
|
|
278
|
+
let value
|
|
279
|
+
const eq = key.indexOf('=')
|
|
280
|
+
if (eq >= 0) {
|
|
281
|
+
value = key.slice(eq + 1)
|
|
282
|
+
key = key.slice(0, eq)
|
|
283
|
+
}
|
|
284
|
+
const command = positional[0]
|
|
285
|
+
if (strict && command && COMMAND_FLAGS[command] && !GLOBAL_FLAGS.includes(key) && !COMMAND_FLAGS[command].includes(key)) {
|
|
286
|
+
throw unknownFlag(key, command)
|
|
287
|
+
}
|
|
288
|
+
seen.push(key)
|
|
289
|
+
if (eq >= 0) {
|
|
290
|
+
if (BOOLEAN_FLAGS.has(key)) {
|
|
291
|
+
if (value === 'true' || value === 'false') value = value === 'true'
|
|
292
|
+
else if (!['tailscale', 'lan'].includes(key)) throw new Error(`--${key} accepts only true or false.`)
|
|
293
|
+
}
|
|
294
|
+
} else if (BOOLEAN_FLAGS.has(key)) {
|
|
295
|
+
value = true
|
|
296
|
+
} else {
|
|
297
|
+
value = argv[index + 1]
|
|
298
|
+
if (value === undefined || value.startsWith('--')) {
|
|
299
|
+
if (!OPTIONAL_VALUE.has(key)) throw new Error(`--${key} needs a value`)
|
|
300
|
+
value = true
|
|
301
|
+
} else index += 1
|
|
302
|
+
}
|
|
303
|
+
if (REPEATABLE.has(key))
|
|
304
|
+
flags[key] = [
|
|
305
|
+
...(flags[key] || []),
|
|
306
|
+
...String(value)
|
|
307
|
+
.split(',')
|
|
308
|
+
.map((item) => item.trim())
|
|
309
|
+
.filter(Boolean),
|
|
310
|
+
]
|
|
311
|
+
else flags[key] = value
|
|
312
|
+
}
|
|
313
|
+
const command = positional[0] || null
|
|
314
|
+
// Flags written before the command are checked once it is known.
|
|
315
|
+
if (strict && command && COMMAND_FLAGS[command]) {
|
|
316
|
+
for (const key of seen) if (!GLOBAL_FLAGS.includes(key) && !COMMAND_FLAGS[command].includes(key)) throw unknownFlag(key, command)
|
|
317
|
+
}
|
|
318
|
+
return { command, positional: positional.slice(1), flags }
|
|
319
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// `shapewall capture` and `shapewall links`.
|
|
2
|
+
|
|
3
|
+
import { getBoard, getEnvironment, loadConfig } from '../config.js'
|
|
4
|
+
import { runCapture } from '../capture/capture.js'
|
|
5
|
+
import { readManifest } from '../store.js'
|
|
6
|
+
import { cliCommand } from '../invocation.js'
|
|
7
|
+
import { formatBroken } from '../broken-links.js'
|
|
8
|
+
import { pageLinks } from '../links.js'
|
|
9
|
+
|
|
10
|
+
// `capture`: one line per shot and a summary; with --json the summary is one
|
|
11
|
+
// JSON document on stdout and the progress lines go to stderr. --yes is
|
|
12
|
+
// accepted for CI scripts: capture never prompts.
|
|
13
|
+
export async function capture(flags, out, err) {
|
|
14
|
+
const config = loadConfig(flags.config)
|
|
15
|
+
const json = Boolean(flags.json)
|
|
16
|
+
const result = await runCapture({
|
|
17
|
+
config,
|
|
18
|
+
boardId: flags.board,
|
|
19
|
+
envId: flags.env || null,
|
|
20
|
+
only: flags.only,
|
|
21
|
+
log: json ? err : out,
|
|
22
|
+
checkExternal: Boolean(flags['check-external']),
|
|
23
|
+
exitOnSignal: true,
|
|
24
|
+
})
|
|
25
|
+
if (json) {
|
|
26
|
+
out(
|
|
27
|
+
JSON.stringify(
|
|
28
|
+
{
|
|
29
|
+
ok: result.ok,
|
|
30
|
+
board: result.board,
|
|
31
|
+
env: result.env,
|
|
32
|
+
total: result.total,
|
|
33
|
+
okShots: result.done - result.failed,
|
|
34
|
+
failed: result.failed,
|
|
35
|
+
expected: result.expected,
|
|
36
|
+
durationMs: result.durationMs,
|
|
37
|
+
dir: result.dir,
|
|
38
|
+
failedShots: result.shots.filter((shot) => shot.status !== 'ok'),
|
|
39
|
+
shots: result.shots,
|
|
40
|
+
linksChecked: result.linksChecked,
|
|
41
|
+
brokenLinks: result.brokenLinks,
|
|
42
|
+
},
|
|
43
|
+
null,
|
|
44
|
+
2,
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return result.failed ? 2 : 0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// `links`: page-to-page links from the last capture, or (--broken) the links
|
|
52
|
+
// that led to an error.
|
|
53
|
+
export async function links(flags, out) {
|
|
54
|
+
const config = loadConfig(flags.config)
|
|
55
|
+
const board = getBoard(config, flags.board)
|
|
56
|
+
const env = getEnvironment(board, flags.env || null)
|
|
57
|
+
const manifest = readManifest(config, board.id, env.id)
|
|
58
|
+
if (!manifest)
|
|
59
|
+
throw new Error(`Board "${board.id}" has no captures${flags.env ? ` of ${env.id}` : ''} yet. Run "${cliCommand('capture')}" first.`)
|
|
60
|
+
const broken = Array.isArray(manifest.brokenLinks) ? manifest.brokenLinks : []
|
|
61
|
+
if (flags.broken) {
|
|
62
|
+
if (flags.json) out(JSON.stringify({ board: board.id, env: env.id, capturedAt: manifest.capturedAt, brokenLinks: broken }, null, 2))
|
|
63
|
+
else if (!broken.length) out(`No broken links on "${board.id}" (capture of ${manifest.capturedAt}).`)
|
|
64
|
+
else {
|
|
65
|
+
out(`${broken.length} broken link${broken.length === 1 ? '' : 's'} on "${board.id}" (capture of ${manifest.capturedAt}):`)
|
|
66
|
+
for (const line of formatBroken(broken, { max: Infinity })) out(line)
|
|
67
|
+
}
|
|
68
|
+
return broken.length ? 2 : 0
|
|
69
|
+
}
|
|
70
|
+
const graph = pageLinks(manifest, board)
|
|
71
|
+
if (flags.json) {
|
|
72
|
+
out(JSON.stringify({ board: board.id, env: env.id, capturedAt: manifest.capturedAt, links: graph, brokenLinks: broken }, null, 2))
|
|
73
|
+
return 0
|
|
74
|
+
}
|
|
75
|
+
const lines = board.pages.filter((page) => graph[page.id]).map((page) => `${page.id} -> ${graph[page.id].join(', ')}`)
|
|
76
|
+
out(lines.length ? lines.join('\n') : 'No links between the pages on the board.')
|
|
77
|
+
if (broken.length) out(`${broken.length} broken link${broken.length === 1 ? '' : 's'}: "${cliCommand('links --broken')}" lists them.`)
|
|
78
|
+
return 0
|
|
79
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// The commands whose handling used to sit inline in main(): buzz-bridge,
|
|
2
|
+
// settings, journeys, events, mcp and export.
|
|
3
|
+
|
|
4
|
+
import { getBoard, loadConfig } from '../config.js'
|
|
5
|
+
import { formatJourneys, listJourneys } from '../journeys.js'
|
|
6
|
+
import { openBrowser } from './open.js'
|
|
7
|
+
import { withNotifications } from './notify.js'
|
|
8
|
+
|
|
9
|
+
export async function buzzBridge(flags, out) {
|
|
10
|
+
if (typeof flags['bridge-config'] !== 'string') throw new Error('Use --bridge-config FILE for the private operator map.')
|
|
11
|
+
const { startGateway } = await import('../buzz/gateway.js')
|
|
12
|
+
const gateway = await startGateway(flags['bridge-config'])
|
|
13
|
+
out('Private Buzz gateway ready on its owner-only Unix socket. Existing Buzz services and sessions are unchanged.')
|
|
14
|
+
out('Keep this foreground process open; Ctrl-C stops only this gateway.')
|
|
15
|
+
const stop = () => gateway.stop().finally(() => process.exit(0))
|
|
16
|
+
process.once('SIGINT', stop)
|
|
17
|
+
process.once('SIGTERM', stop)
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function settings(flags, out, err) {
|
|
22
|
+
const { startAgentManagement } = await import('../agent/manage.js')
|
|
23
|
+
const management = await startAgentManagement({ config: loadConfig(flags.config), port: Number(flags.port ?? 0), out })
|
|
24
|
+
if (flags.open) openBrowser(`${management.url}${management.app.locals.openLink()}`, out)
|
|
25
|
+
let stopping = false
|
|
26
|
+
const stop = () => {
|
|
27
|
+
if (stopping) return
|
|
28
|
+
stopping = true
|
|
29
|
+
management.close().catch((error) => {
|
|
30
|
+
err(`Agent settings cleanup failed: ${error.message}`)
|
|
31
|
+
process.exitCode = 1
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
process.on('SIGINT', stop)
|
|
35
|
+
process.on('SIGTERM', stop)
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function journeys(positional, flags, out) {
|
|
40
|
+
const action = positional[0] || 'list'
|
|
41
|
+
if (action !== 'list') throw new Error(`unknown journeys action "${action}" (list)`)
|
|
42
|
+
const config = loadConfig(flags.config)
|
|
43
|
+
const board = getBoard(config, flags.board)
|
|
44
|
+
const journeys = listJourneys(config, board)
|
|
45
|
+
out(flags.json ? JSON.stringify({ board: board.id, journeys }, null, 2) : formatJourneys(board, journeys))
|
|
46
|
+
return 0
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function events(flags, out, err) {
|
|
50
|
+
const config = loadConfig(flags.config)
|
|
51
|
+
const { eventsCommand } = await import('../events-cli.js')
|
|
52
|
+
const controller = new AbortController()
|
|
53
|
+
const stop = () => controller.abort()
|
|
54
|
+
process.once('SIGINT', stop)
|
|
55
|
+
process.once('SIGTERM', stop)
|
|
56
|
+
try {
|
|
57
|
+
await eventsCommand(config, flags, out, err, { signal: controller.signal })
|
|
58
|
+
} finally {
|
|
59
|
+
process.removeListener('SIGINT', stop)
|
|
60
|
+
process.removeListener('SIGTERM', stop)
|
|
61
|
+
}
|
|
62
|
+
return 0
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function mcp(flags, err) {
|
|
66
|
+
if (flags.remote !== undefined) {
|
|
67
|
+
const { createRemote, remoteSettings } = await import('../remote/remote.js')
|
|
68
|
+
const { runRemoteMcp } = await import('../remote/remote-mcp.js')
|
|
69
|
+
await runRemoteMcp({ remote: createRemote(remoteSettings(flags)), readOnly: Boolean(flags['read-only']) })
|
|
70
|
+
return 0
|
|
71
|
+
}
|
|
72
|
+
const config = loadConfig(flags.config)
|
|
73
|
+
const { runMcp } = await import('../mcp.js')
|
|
74
|
+
const readOnly = Boolean(flags['read-only'])
|
|
75
|
+
// stdout is the MCP protocol, so notification log lines go to stderr.
|
|
76
|
+
await withNotifications(config, err, () => runMcp({ config, readOnly, allowCapture: !readOnly && !flags['no-capture'] }))
|
|
77
|
+
return 0
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function exportCommand(flags, out) {
|
|
81
|
+
const config = loadConfig(flags.config)
|
|
82
|
+
const { exportStatic } = await import('../export.js')
|
|
83
|
+
const result = await exportStatic(config, {
|
|
84
|
+
out: flags.out || 'shapewall-export',
|
|
85
|
+
includeComments: !flags['no-comments'],
|
|
86
|
+
includeChecks: Boolean(flags['include-checks']),
|
|
87
|
+
browserComments: Boolean(flags['browser-comments']),
|
|
88
|
+
noindex: Boolean(flags.noindex),
|
|
89
|
+
})
|
|
90
|
+
out(`Exported ${result.boards} board${result.boards === 1 ? '' : 's'} (${result.files} files) to ${result.out}`)
|
|
91
|
+
return 0
|
|
92
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// `shapewall comments`: list, get, add, resolve, reopen, reply and status.
|
|
2
|
+
|
|
3
|
+
import { getBoard, loadConfig } from '../config.js'
|
|
4
|
+
import { addComment, authorFlag, showComment, sinceFilter } from '../comments-cli.js'
|
|
5
|
+
import { feedback, formatFeedback, formatFeedbackForAgent, untrustedJson } from '../feedback.js'
|
|
6
|
+
import { AGENT_STATUSES, addReply, setAgentStatus, updateComment } from '../store.js'
|
|
7
|
+
import { mentionFlag, withNotifications } from './notify.js'
|
|
8
|
+
|
|
9
|
+
// Changes (resolve, reply, ...) send their notifications before the command exits.
|
|
10
|
+
export async function comments(positional, flags, out, err) {
|
|
11
|
+
if (flags.remote !== undefined) {
|
|
12
|
+
const { remoteComments } = await import('../remote/cli.js')
|
|
13
|
+
return remoteComments(positional, flags, out)
|
|
14
|
+
}
|
|
15
|
+
const config = loadConfig(flags.config)
|
|
16
|
+
if (['list', 'get', 'show'].includes(positional[0] || 'list')) return commentAction(config, positional, flags, out, err)
|
|
17
|
+
return withNotifications(config, err, () => commentAction(config, positional, flags, out, err))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function commentAction(config, positional, flags, out, err) {
|
|
21
|
+
const board = getBoard(config, flags.board)
|
|
22
|
+
const action = positional[0] || 'list'
|
|
23
|
+
if (action === 'list') {
|
|
24
|
+
const status = flags.all ? 'all' : flags.resolved ? 'resolved' : 'open'
|
|
25
|
+
if (flags.page && !board.pages.some((page) => page.id === flags.page)) throw new Error(`No page "${flags.page}" on board "${board.id}"`)
|
|
26
|
+
const mention = mentionFlag(flags.mention)
|
|
27
|
+
const since = sinceFilter(flags.since)
|
|
28
|
+
const report = feedback(config, { boardId: board.id, status, pageId: flags.page || null, mention })
|
|
29
|
+
if (since) report.comments = report.comments.filter(since)
|
|
30
|
+
report.count = report.comments.length
|
|
31
|
+
out(
|
|
32
|
+
flags['for-agent']
|
|
33
|
+
? formatFeedbackForAgent(report)
|
|
34
|
+
: flags.json
|
|
35
|
+
? JSON.stringify(untrustedJson(report), null, 2)
|
|
36
|
+
: formatFeedback(report),
|
|
37
|
+
)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (action === 'get' || action === 'show') return showComment(config, board, positional, flags, out)
|
|
41
|
+
if (action === 'add') return addComment(config, board, flags, out, err)
|
|
42
|
+
if (action === 'resolve' || action === 'reopen') {
|
|
43
|
+
const id = positional[1]
|
|
44
|
+
if (!id) throw new Error(`usage: shapewall comments ${action} ID`)
|
|
45
|
+
const comment = await updateComment(
|
|
46
|
+
config,
|
|
47
|
+
board.id,
|
|
48
|
+
id,
|
|
49
|
+
{
|
|
50
|
+
status: action === 'resolve' ? 'resolved' : 'open',
|
|
51
|
+
resolution: typeof flags.note === 'string' ? flags.note : undefined,
|
|
52
|
+
...(action === 'resolve' && typeof flags.ref === 'string' ? { fixRef: flags.ref } : {}),
|
|
53
|
+
},
|
|
54
|
+
{ actor: authorFlag(flags) },
|
|
55
|
+
)
|
|
56
|
+
out(flags.json ? JSON.stringify({ comment }, null, 2) : `#${comment.id} is ${comment.status}`)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
if (action === 'reply') {
|
|
60
|
+
const id = positional[1]
|
|
61
|
+
const body = typeof flags.body === 'string' ? flags.body : positional[2]
|
|
62
|
+
if (!id || !body) throw new Error('usage: shapewall comments reply ID --body TEXT [--author NAME]')
|
|
63
|
+
const { comment, reply } = await addReply(config, board.id, id, {
|
|
64
|
+
body,
|
|
65
|
+
author: typeof flags.author === 'string' ? flags.author : 'agent',
|
|
66
|
+
})
|
|
67
|
+
out(flags.json ? JSON.stringify({ comment, reply }, null, 2) : `Replied to #${comment.id} as ${reply.author}`)
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
if (action === 'status') {
|
|
71
|
+
const [, id, value] = positional
|
|
72
|
+
if (!id || !value) throw new Error(`usage: shapewall comments status ID ${[...AGENT_STATUSES, 'clear'].join('|')} [--note TEXT]`)
|
|
73
|
+
if (![...AGENT_STATUSES, 'clear'].includes(value)) {
|
|
74
|
+
throw new Error(`unknown status '${value.slice(0, 40)}' (use: ${[...AGENT_STATUSES, 'clear'].join(', ')})`)
|
|
75
|
+
}
|
|
76
|
+
if (typeof flags.note === 'string' && flags.note.trim()) {
|
|
77
|
+
await addReply(config, board.id, id, { body: flags.note, author: typeof flags.author === 'string' ? flags.author : 'agent' })
|
|
78
|
+
}
|
|
79
|
+
const { comment } = await setAgentStatus(config, board.id, id, value === 'clear' ? null : value, { actor: authorFlag(flags) })
|
|
80
|
+
out(flags.json ? JSON.stringify({ comment }, null, 2) : `#${comment.id} agent status: ${comment.agentStatus || 'none'}`)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`unknown comments action "${action}" (list, get, add, resolve, reopen, reply, status)`)
|
|
84
|
+
}
|