@johnhenry/mallory-cli 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/README.md +60 -2
- package/bin/mallory.mjs +51 -0
- package/package.json +51 -4
- package/src/a2a/client.js +511 -0
- package/src/a2a/demo-agent.js +396 -0
- package/src/a2a/hub.js +578 -0
- package/src/a2a/settings.js +88 -0
- package/src/a2a/task.js +358 -0
- package/src/acp/client.js +573 -0
- package/src/acp/demo-agent.js +332 -0
- package/src/acp/hub.js +632 -0
- package/src/acp/settings.js +78 -0
- package/src/actions/map.js +524 -0
- package/src/agent/cloud.js +77 -0
- package/src/agent/compact.js +84 -0
- package/src/agent/constants.js +39 -0
- package/src/agent/diff.js +101 -0
- package/src/agent/fork.js +159 -0
- package/src/agent/grounding.js +73 -0
- package/src/agent/guards.js +129 -0
- package/src/agent/local-transport.js +152 -0
- package/src/agent/loop.js +479 -0
- package/src/agent/park-store.js +77 -0
- package/src/agent/park.js +76 -0
- package/src/agent/ports.js +28 -0
- package/src/agent/providers.js +591 -0
- package/src/agent/restart.js +51 -0
- package/src/agent/router.js +380 -0
- package/src/agent/run.js +861 -0
- package/src/agent/tools.js +247 -0
- package/src/agent-library/engine.js +43 -0
- package/src/ai/bridge.js +155 -0
- package/src/ai/policy.js +131 -0
- package/src/aimatey/vendor.js +18 -0
- package/src/audio/container-duration.js +35 -0
- package/src/audio/instruments.js +776 -0
- package/src/audio/lanes.js +230 -0
- package/src/audio/patch.js +1410 -0
- package/src/audio/plan.js +276 -0
- package/src/audio/rack.js +1006 -0
- package/src/audio/sample-trim.js +293 -0
- package/src/audio/soundfont.js +243 -0
- package/src/audio/take-store.js +87 -0
- package/src/audio/takes.js +129 -0
- package/src/audio/wav.js +170 -0
- package/src/audio/zzfx.js +333 -0
- package/src/autonomy/bundle.js +207 -0
- package/src/autonomy/confine.js +61 -0
- package/src/autonomy/enforce.js +155 -0
- package/src/autonomy/file-kv.js +88 -0
- package/src/autonomy/ledger.js +203 -0
- package/src/autonomy/pins.js +50 -0
- package/src/autonomy/psl/index.js +32 -0
- package/src/autonomy/psl/suffixes.json +1 -0
- package/src/autonomy/record.js +28 -0
- package/src/autonomy/routines.js +107 -0
- package/src/autonomy/server.js +175 -0
- package/src/autonomy/signer-node.js +167 -0
- package/src/autonomy/store.js +43 -0
- package/src/autonomy/unattended.js +13 -0
- package/src/bytes/bytes.js +378 -0
- package/src/calc/syntax.js +125 -0
- package/src/calc/tex.js +28 -0
- package/src/calendar/vendor.js +2 -0
- package/src/clipboard.js +130 -0
- package/src/clsh/clsh.js +3417 -0
- package/src/codec/capnp.js +1804 -0
- package/src/codec/core.js +2043 -0
- package/src/codec/vendor/avro.js +136 -0
- package/src/codec/vendor/cbor.js +25 -0
- package/src/codec/vendor/flatbuffers.js +206 -0
- package/src/codec/vendor/msgpack.js +9 -0
- package/src/codec/vendor/protobuf.js +53 -0
- package/src/delegation/caps.js +60 -0
- package/src/delegation/config.js +32 -0
- package/src/device/model.js +246 -0
- package/src/device/recording.js +198 -0
- package/src/device/stream-model.js +151 -0
- package/src/documents/documents.js +1224 -0
- package/src/effects/catalog.js +63 -0
- package/src/effects/extras.js +133 -0
- package/src/effects/parse.js +339 -0
- package/src/embed/protocol.js +131 -0
- package/src/env/env.js +159 -0
- package/src/exact/vendor.js +45 -0
- package/src/example-meta.js +164 -0
- package/src/examples.js +94 -0
- package/src/export/canvas-image.js +217 -0
- package/src/export/expr-latex-lazy.js +8 -0
- package/src/export/formats.js +322 -0
- package/src/export/latex.js +183 -0
- package/src/export/pane.js +184 -0
- package/src/export/value.js +452 -0
- package/src/export/zip.js +214 -0
- package/src/ext/access.js +58 -0
- package/src/ext/btasks.js +225 -0
- package/src/ext/client.js +209 -0
- package/src/ext/tools.js +69 -0
- package/src/ext/view.js +105 -0
- package/src/ext/webmcp-tabs.js +299 -0
- package/src/files/archive.js +232 -0
- package/src/files/files.js +317 -0
- package/src/formats/json.js +24 -0
- package/src/formats/jupyter.js +188 -0
- package/src/formats/markdown.js +254 -0
- package/src/formats/n8n.js +276 -0
- package/src/formats/node-red.js +363 -0
- package/src/formats/registry.js +177 -0
- package/src/formats/rivet.js +259 -0
- package/src/formats/shared.js +98 -0
- package/src/formats/structure.js +182 -0
- package/src/formats/yaml.js +127 -0
- package/src/frame/frame.js +962 -0
- package/src/frame/vendor.js +1484 -0
- package/src/gate/audit.js +116 -0
- package/src/gate/gate.js +365 -0
- package/src/gate/policy.js +295 -0
- package/src/gate/scripted.js +110 -0
- package/src/gate/seams.js +32 -0
- package/src/gate/store.js +66 -0
- package/src/geometry/model.js +533 -0
- package/src/grant-key.js +149 -0
- package/src/graph/model.js +381 -0
- package/src/headless/a2a-push.js +123 -0
- package/src/headless/channels/config.js +142 -0
- package/src/headless/channels/connectors.js +283 -0
- package/src/headless/channels/index.js +257 -0
- package/src/headless/channels/mail.js +197 -0
- package/src/headless/channels/mailnet.js +223 -0
- package/src/headless/channels/platforms.js +194 -0
- package/src/headless/channels/replay.js +49 -0
- package/src/headless/cli.js +1397 -0
- package/src/headless/companion-client.js +182 -0
- package/src/headless/cost-cli.js +177 -0
- package/src/headless/deprecations-cli.js +102 -0
- package/src/headless/examples.js +48 -0
- package/src/headless/ffmpeg-exec.js +217 -0
- package/src/headless/gateways/config.js +213 -0
- package/src/headless/gateways/homeassistant.js +159 -0
- package/src/headless/gateways/index.js +121 -0
- package/src/headless/gateways/matter.js +150 -0
- package/src/headless/gateways/mqtt-client.js +177 -0
- package/src/headless/gateways/mqtt.js +70 -0
- package/src/headless/gateways/netway.js +226 -0
- package/src/headless/gateways/serverpod-worker.mjs +16 -0
- package/src/headless/gateways/serverpod.js +71 -0
- package/src/headless/gateways/util.js +27 -0
- package/src/headless/grant-cli.js +208 -0
- package/src/headless/guard.js +125 -0
- package/src/headless/guards.js +124 -0
- package/src/headless/machine-cli.js +853 -0
- package/src/headless/mcp-endpoint.js +287 -0
- package/src/headless/mcp-roots.js +38 -0
- package/src/headless/model-endpoint.js +88 -0
- package/src/headless/net.js +151 -0
- package/src/headless/node.js +263 -0
- package/src/headless/npm-tarball.js +29 -0
- package/src/headless/operator-page.js +112 -0
- package/src/headless/operator.js +242 -0
- package/src/headless/people.js +34 -0
- package/src/headless/pkg-cli.js +1103 -0
- package/src/headless/pkg-serve.js +138 -0
- package/src/headless/process-worker.js +88 -0
- package/src/headless/runner-remote.js +477 -0
- package/src/headless/sandbox-child.mjs +21 -0
- package/src/headless/scheduled.js +557 -0
- package/src/headless/serve-stream.js +97 -0
- package/src/headless/serve.js +2238 -0
- package/src/headless/short-links.js +158 -0
- package/src/headless/static-dirs.js +207 -0
- package/src/headless/trust-file.js +51 -0
- package/src/headless/watch.js +291 -0
- package/src/headless/ws-connect.js +65 -0
- package/src/headless/ws-connections.js +44 -0
- package/src/headless/ws-echo.js +150 -0
- package/src/headless/ws-proxy.js +354 -0
- package/src/headless/ws-ticket.js +48 -0
- package/src/hooks/config.js +50 -0
- package/src/hooks/engine.js +189 -0
- package/src/input/log.js +613 -0
- package/src/input/player.js +217 -0
- package/src/input/replay.js +209 -0
- package/src/jth/vendor.js +28 -0
- package/src/ledger/tx.js +94 -0
- package/src/machine/apply.js +193 -0
- package/src/machine/diff.js +168 -0
- package/src/machine/drive.js +296 -0
- package/src/machine/engine.js +478 -0
- package/src/machine/files-tool.js +76 -0
- package/src/machine/lint.js +139 -0
- package/src/machine/llmtm-trace.js +117 -0
- package/src/machine/llmtm.js +475 -0
- package/src/machine/otel.js +80 -0
- package/src/machine/pane-provider.js +51 -0
- package/src/machine/propose.js +159 -0
- package/src/machine/random.js +52 -0
- package/src/machine/risk.js +107 -0
- package/src/machine/session.js +1017 -0
- package/src/machine/shell-tool.js +45 -0
- package/src/machine/tape.js +349 -0
- package/src/machine/templates.js +104 -0
- package/src/machine/trace.js +664 -0
- package/src/machine/view.js +73 -0
- package/src/machine/vm-tool.js +47 -0
- package/src/machine/watchdog.js +46 -0
- package/src/mcp/app-args.js +51 -0
- package/src/mcp/app-run.js +56 -0
- package/src/mcp/apps.js +468 -0
- package/src/mcp/cache.js +232 -0
- package/src/mcp/client.js +507 -0
- package/src/mcp/demo-app.js +183 -0
- package/src/mcp/demo-server.js +602 -0
- package/src/mcp/elicitation.js +116 -0
- package/src/mcp/hub.js +1326 -0
- package/src/mcp/roots.js +139 -0
- package/src/mcp/sampling.js +105 -0
- package/src/mcp/settings.js +125 -0
- package/src/mcp/tape.js +292 -0
- package/src/mcp/uri-template.js +156 -0
- package/src/mcp/wsh-client.js +164 -0
- package/src/media/animated-codec.js +7 -0
- package/src/media/animated.js +623 -0
- package/src/media/compare-agent.js +70 -0
- package/src/media/compare-job.js +63 -0
- package/src/media/compare-page.js +296 -0
- package/src/media/compare-worker.js +14 -0
- package/src/media/compare.js +600 -0
- package/src/media/contract.js +62 -0
- package/src/media/decode-frame.js +57 -0
- package/src/media/decode-pool.js +188 -0
- package/src/media/ffmpeg-edit.js +344 -0
- package/src/media/ffmpeg-wasm-client.js +121 -0
- package/src/media/ffmpeg-wasm-session.js +79 -0
- package/src/media/ffmpeg-wasm.js +139 -0
- package/src/media/ffmpeg-worker.js +23 -0
- package/src/media/ffmpeg.js +903 -0
- package/src/media/helpers.js +419 -0
- package/src/media/keep.js +108 -0
- package/src/media/metadata-worker.js +16 -0
- package/src/media/metadata.js +2518 -0
- package/src/media/mime.js +102 -0
- package/src/media/page-decode.js +74 -0
- package/src/media/persist.js +114 -0
- package/src/media/png.js +226 -0
- package/src/media/sample-input.js +67 -0
- package/src/media/store.js +86 -0
- package/src/media/wav.js +109 -0
- package/src/midi/mappings.js +250 -0
- package/src/midi/message.js +125 -0
- package/src/model/action-hub.js +143 -0
- package/src/model/adapters.js +284 -0
- package/src/model/agent-runs.js +12 -0
- package/src/model/arrange.js +308 -0
- package/src/model/automation-clock.js +494 -0
- package/src/model/automation.js +653 -0
- package/src/model/batches.js +78 -0
- package/src/model/binary-view.js +195 -0
- package/src/model/breakpoints.js +392 -0
- package/src/model/calc-settings.js +65 -0
- package/src/model/calendar.js +254 -0
- package/src/model/canvas-id.js +5 -0
- package/src/model/canvas.js +5048 -0
- package/src/model/channel-names.js +29 -0
- package/src/model/channels.js +692 -0
- package/src/model/chart-clock.js +631 -0
- package/src/model/chart-code.js +69 -0
- package/src/model/codecs.js +60 -0
- package/src/model/companion-access.js +271 -0
- package/src/model/companion-pane.js +50 -0
- package/src/model/composite.js +324 -0
- package/src/model/context.js +380 -0
- package/src/model/controls.js +231 -0
- package/src/model/converter-presets.js +368 -0
- package/src/model/cost.js +580 -0
- package/src/model/curve-transform.js +122 -0
- package/src/model/cycles.js +176 -0
- package/src/model/debug-log.js +168 -0
- package/src/model/decision-clock.js +100 -0
- package/src/model/decisions.js +265 -0
- package/src/model/desk.js +87 -0
- package/src/model/device-hub.js +400 -0
- package/src/model/diff.js +445 -0
- package/src/model/emit-events.js +179 -0
- package/src/model/errors.js +238 -0
- package/src/model/event-presets.js +297 -0
- package/src/model/events.js +1303 -0
- package/src/model/explicit-setters.js +139 -0
- package/src/model/field-mapping.js +623 -0
- package/src/model/files-pane.js +263 -0
- package/src/model/flow-idle.js +89 -0
- package/src/model/foreach.js +549 -0
- package/src/model/frame-loop.js +71 -0
- package/src/model/frame-pressure.js +180 -0
- package/src/model/function-scaffold.js +1000 -0
- package/src/model/geometry-settings.js +54 -0
- package/src/model/goals.js +176 -0
- package/src/model/graph-settings.js +76 -0
- package/src/model/grid-widget.js +175 -0
- package/src/model/groups.js +332 -0
- package/src/model/hash.js +21 -0
- package/src/model/history.js +259 -0
- package/src/model/http-copy.js +88 -0
- package/src/model/http-send-companion.js +110 -0
- package/src/model/http-send.js +163 -0
- package/src/model/http-tap.js +521 -0
- package/src/model/http-tools.js +1138 -0
- package/src/model/import-lock.js +78 -0
- package/src/model/imports.js +258 -0
- package/src/model/infer-outputs.js +822 -0
- package/src/model/ink-connect.js +150 -0
- package/src/model/ink-diff.js +75 -0
- package/src/model/ink-gone.js +71 -0
- package/src/model/ink-route.js +120 -0
- package/src/model/ink-svg.js +206 -0
- package/src/model/ink.js +739 -0
- package/src/model/input-log-hub.js +456 -0
- package/src/model/input-split.js +69 -0
- package/src/model/json-schema-host.js +9 -0
- package/src/model/json-schema.js +368 -0
- package/src/model/jth.js +78 -0
- package/src/model/latex-expr.js +528 -0
- package/src/model/layout-history.js +120 -0
- package/src/model/lazy-map.js +88 -0
- package/src/model/ledger-pane.js +101 -0
- package/src/model/legacy-viaframe.js +90 -0
- package/src/model/lessons.js +448 -0
- package/src/model/links.js +981 -0
- package/src/model/live.js +411 -0
- package/src/model/math-widget.js +53 -0
- package/src/model/memory-settings.js +33 -0
- package/src/model/midi-controls.js +350 -0
- package/src/model/nl-time.js +408 -0
- package/src/model/notebook.js +137 -0
- package/src/model/pane-view-store.js +15 -0
- package/src/model/partial.js +115 -0
- package/src/model/pause-clock.js +53 -0
- package/src/model/peer-pane.js +32 -0
- package/src/model/persist-state.js +290 -0
- package/src/model/person-only.js +122 -0
- package/src/model/pin.js +209 -0
- package/src/model/plot-3d.js +213 -0
- package/src/model/plot-series.js +157 -0
- package/src/model/plot-settings.js +531 -0
- package/src/model/ports.js +312 -0
- package/src/model/presentation.js +222 -0
- package/src/model/preset-apply.js +316 -0
- package/src/model/preset-banks.js +335 -0
- package/src/model/preset-morph.js +263 -0
- package/src/model/preset-ops.js +205 -0
- package/src/model/preset-player.js +283 -0
- package/src/model/preset-states.js +172 -0
- package/src/model/profile-settings.js +109 -0
- package/src/model/promote.js +103 -0
- package/src/model/protected.js +10 -0
- package/src/model/proxy-log.js +230 -0
- package/src/model/proxy.js +367 -0
- package/src/model/quantity-widget.js +61 -0
- package/src/model/queue-book.js +359 -0
- package/src/model/quick-add.js +224 -0
- package/src/model/rate-limit.js +313 -0
- package/src/model/rate.js +95 -0
- package/src/model/recovery.js +216 -0
- package/src/model/rename-follow.js +113 -0
- package/src/model/repeater.js +1126 -0
- package/src/model/retention.js +664 -0
- package/src/model/route-edit.js +132 -0
- package/src/model/router.js +155 -0
- package/src/model/runaway.js +232 -0
- package/src/model/runlog.js +1033 -0
- package/src/model/runners/a2a.js +2 -0
- package/src/model/runners/acp.js +2 -0
- package/src/model/runners/actions.js +4 -0
- package/src/model/runners/agent.js +4 -0
- package/src/model/runners/audio.js +21 -0
- package/src/model/runners/automation.js +2 -0
- package/src/model/runners/calc.js +23 -0
- package/src/model/runners/catch.js +10 -0
- package/src/model/runners/codec.js +24 -0
- package/src/model/runners/companion-run.js +2 -0
- package/src/model/runners/device.js +7 -0
- package/src/model/runners/dom.js +13 -0
- package/src/model/runners/effects.js +2 -0
- package/src/model/runners/embed.js +11 -0
- package/src/model/runners/eval.js +2 -0
- package/src/model/runners/files.js +19 -0
- package/src/model/runners/geometry.js +23 -0
- package/src/model/runners/goals.js +18 -0
- package/src/model/runners/graph.js +23 -0
- package/src/model/runners/html.js +2 -0
- package/src/model/runners/http-proxy.js +185 -0
- package/src/model/runners/http-send.js +61 -0
- package/src/model/runners/http-static.js +83 -0
- package/src/model/runners/http-tap.js +26 -0
- package/src/model/runners/http.js +40 -0
- package/src/model/runners/import.js +2 -0
- package/src/model/runners/index.js +74 -0
- package/src/model/runners/input.js +14 -0
- package/src/model/runners/inputlog.js +7 -0
- package/src/model/runners/ledger.js +15 -0
- package/src/model/runners/machine.js +4 -0
- package/src/model/runners/mcp.js +2 -0
- package/src/model/runners/mcpapp.js +2 -0
- package/src/model/runners/media.js +18 -0
- package/src/model/runners/memory.js +28 -0
- package/src/model/runners/mesh-inspect.js +13 -0
- package/src/model/runners/peer.js +14 -0
- package/src/model/runners/plot.js +22 -0
- package/src/model/runners/render.js +14 -0
- package/src/model/runners/respond.js +2 -0
- package/src/model/runners/sample-soundfont.js +85 -0
- package/src/model/runners/sample.js +159 -0
- package/src/model/runners/scene.js +8 -0
- package/src/model/runners/score.js +24 -0
- package/src/model/runners/secret.js +10 -0
- package/src/model/runners/select.js +2 -0
- package/src/model/runners/shared.js +4 -0
- package/src/model/runners/shares.js +15 -0
- package/src/model/runners/shell.js +7 -0
- package/src/model/runners/skill.js +26 -0
- package/src/model/runners/state.js +2 -0
- package/src/model/runners/statechart.js +4 -0
- package/src/model/runners/subgraph.js +9 -0
- package/src/model/runners/tabs.js +25 -0
- package/src/model/runners/terminal.js +5 -0
- package/src/model/runners/text.js +4 -0
- package/src/model/runners/timer.js +7 -0
- package/src/model/runners/traffic.js +65 -0
- package/src/model/runners/trigger.js +2 -0
- package/src/model/runners/verdict.js +29 -0
- package/src/model/runners/vm.js +7 -0
- package/src/model/runners/wait.js +4 -0
- package/src/model/runners/ws-client.js +57 -0
- package/src/model/safe-regex.js +719 -0
- package/src/model/sample-settings.js +43 -0
- package/src/model/sample-source.js +47 -0
- package/src/model/saved-mapping.js +153 -0
- package/src/model/score-controllers.js +87 -0
- package/src/model/score-edit.js +399 -0
- package/src/model/score-instruments.js +300 -0
- package/src/model/score-library.js +407 -0
- package/src/model/score-markup.js +235 -0
- package/src/model/score-mix.js +248 -0
- package/src/model/score-patterns.js +276 -0
- package/src/model/score-selection.js +34 -0
- package/src/model/score-time.js +139 -0
- package/src/model/score-transforms.js +336 -0
- package/src/model/score-transport.js +192 -0
- package/src/model/selection.js +351 -0
- package/src/model/serial-controls.js +328 -0
- package/src/model/shares-pane.js +17 -0
- package/src/model/shell-pane.js +106 -0
- package/src/model/signature.js +1122 -0
- package/src/model/size-hints.js +106 -0
- package/src/model/size-ratio.js +12 -0
- package/src/model/skill-settings.js +23 -0
- package/src/model/snapping.js +466 -0
- package/src/model/split.js +375 -0
- package/src/model/spring-player.js +222 -0
- package/src/model/statecharts.js +1369 -0
- package/src/model/states-preset.js +208 -0
- package/src/model/static-route.js +100 -0
- package/src/model/step-words.js +45 -0
- package/src/model/subgraph.js +1042 -0
- package/src/model/switch.js +98 -0
- package/src/model/tabs-store.js +10 -0
- package/src/model/tensor-view.js +146 -0
- package/src/model/timer-clock.js +361 -0
- package/src/model/timers.js +422 -0
- package/src/model/timing.js +212 -0
- package/src/model/traffic-agent.js +111 -0
- package/src/model/traffic-store.js +20 -0
- package/src/model/traffic.js +665 -0
- package/src/model/transport.js +364 -0
- package/src/model/turns.js +86 -0
- package/src/model/types.js +425 -0
- package/src/model/value-path.js +138 -0
- package/src/model/versions.js +535 -0
- package/src/model/view-outputs.js +144 -0
- package/src/model/viewport-bookmarks.js +194 -0
- package/src/model/virtual-clock.js +85 -0
- package/src/model/vm-pane.js +258 -0
- package/src/model/wait-clock.js +715 -0
- package/src/model/wait-persist.js +248 -0
- package/src/model/waits.js +431 -0
- package/src/model/watch.js +80 -0
- package/src/model/webhook.js +496 -0
- package/src/model/when.js +48 -0
- package/src/model/widget-values.js +392 -0
- package/src/model/window-commands.js +278 -0
- package/src/model/windows.js +348 -0
- package/src/model/wire-inspect.js +343 -0
- package/src/model/wire-ops.js +324 -0
- package/src/model/wire-pipeline.js +378 -0
- package/src/model/wire-route.js +637 -0
- package/src/model/workspaces.js +122 -0
- package/src/model/ws-client.js +155 -0
- package/src/model/ws-demo.js +31 -0
- package/src/model/ws-frames.js +141 -0
- package/src/model/ws-hub.js +219 -0
- package/src/model/ws-served.js +13 -0
- package/src/model/xstate.js +374 -0
- package/src/narrative/narrative.js +1557 -0
- package/src/network/auth.js +224 -0
- package/src/network/csp-frame.js +197 -0
- package/src/network/declarative-shadow.js +27 -0
- package/src/network/frame-net-shim.js +962 -0
- package/src/network/hosts.js +157 -0
- package/src/network/policy.js +520 -0
- package/src/network/rtc-shim.js +418 -0
- package/src/network/secret-gate.js +78 -0
- package/src/network/secrets.js +261 -0
- package/src/network/sockets.js +287 -0
- package/src/network/store.js +186 -0
- package/src/network/streams.js +99 -0
- package/src/packages/asset-values.js +50 -0
- package/src/packages/assets.js +99 -0
- package/src/packages/deprecation.js +203 -0
- package/src/packages/fetch.js +152 -0
- package/src/packages/function-canvas.js +73 -0
- package/src/packages/module.js +120 -0
- package/src/packages/package.js +474 -0
- package/src/packages/published.js +27 -0
- package/src/packages/requires.js +83 -0
- package/src/packages/signing.js +145 -0
- package/src/packages/trust.js +107 -0
- package/src/panes/a2a.js +51 -0
- package/src/panes/acp.js +60 -0
- package/src/panes/actions.js +54 -0
- package/src/panes/agent.js +83 -0
- package/src/panes/audio.js +103 -0
- package/src/panes/automation.js +112 -0
- package/src/panes/calc.js +67 -0
- package/src/panes/catch.js +52 -0
- package/src/panes/codec.js +59 -0
- package/src/panes/colors.js +12 -0
- package/src/panes/companion.js +54 -0
- package/src/panes/decision.js +65 -0
- package/src/panes/device.js +56 -0
- package/src/panes/dom.js +37 -0
- package/src/panes/effects.js +118 -0
- package/src/panes/embed.js +30 -0
- package/src/panes/eval.js +186 -0
- package/src/panes/fields.js +299 -0
- package/src/panes/files.js +45 -0
- package/src/panes/gate.js +70 -0
- package/src/panes/geometry.js +64 -0
- package/src/panes/goals.js +75 -0
- package/src/panes/graph.js +66 -0
- package/src/panes/html.js +54 -0
- package/src/panes/http.js +82 -0
- package/src/panes/import.js +38 -0
- package/src/panes/input.js +124 -0
- package/src/panes/inputlog.js +66 -0
- package/src/panes/ledger.js +56 -0
- package/src/panes/machine.js +138 -0
- package/src/panes/mcp.js +85 -0
- package/src/panes/mcpapp.js +64 -0
- package/src/panes/media.js +38 -0
- package/src/panes/memory.js +46 -0
- package/src/panes/mesh-inspect.js +49 -0
- package/src/panes/note.js +38 -0
- package/src/panes/peer.js +44 -0
- package/src/panes/plot.js +196 -0
- package/src/panes/registry.js +475 -0
- package/src/panes/render.js +87 -0
- package/src/panes/respond.js +44 -0
- package/src/panes/router.js +84 -0
- package/src/panes/sample.js +75 -0
- package/src/panes/scene.js +55 -0
- package/src/panes/score.js +87 -0
- package/src/panes/secret.js +38 -0
- package/src/panes/select.js +67 -0
- package/src/panes/shader.js +166 -0
- package/src/panes/shared.js +33 -0
- package/src/panes/shares.js +43 -0
- package/src/panes/shell.js +47 -0
- package/src/panes/skill.js +44 -0
- package/src/panes/state.js +91 -0
- package/src/panes/statechart.js +63 -0
- package/src/panes/story.js +33 -0
- package/src/panes/subgraph.js +94 -0
- package/src/panes/tabs.js +52 -0
- package/src/panes/terminal.js +57 -0
- package/src/panes/text.js +36 -0
- package/src/panes/timer.js +55 -0
- package/src/panes/traffic.js +59 -0
- package/src/panes/verdict.js +62 -0
- package/src/panes/vm.js +46 -0
- package/src/panes/wait.js +61 -0
- package/src/panes/watch.js +57 -0
- package/src/panes/webhook.js +67 -0
- package/src/panes/ws-client.js +67 -0
- package/src/persist.js +281 -0
- package/src/plot/tex.js +19 -0
- package/src/plot/vendor.js +59 -0
- package/src/plot/view-vendor.js +5 -0
- package/src/privacy/levels.js +108 -0
- package/src/protocol/devtools.js +116 -0
- package/src/protocol/inspector.js +368 -0
- package/src/render/time.js +381 -0
- package/src/rooms/mesh-metrics.js +162 -0
- package/src/run/companion.js +355 -0
- package/src/run/describe.js +114 -0
- package/src/run/local-model.js +150 -0
- package/src/run/monitor.js +208 -0
- package/src/run/publish.js +360 -0
- package/src/run/respond-outcome.js +12 -0
- package/src/run/run.js +820 -0
- package/src/run/runner-pairing.js +243 -0
- package/src/run/values.js +122 -0
- package/src/runtime/compile.js +122 -0
- package/src/runtime/console-tag.js +64 -0
- package/src/runtime/frame-signals.js +126 -0
- package/src/runtime/iteration-push.js +19 -0
- package/src/runtime/keys.js +474 -0
- package/src/runtime/midi-input.js +170 -0
- package/src/runtime/person-waits.js +140 -0
- package/src/runtime/resource-timing.js +56 -0
- package/src/runtime/runtime.js +2150 -0
- package/src/runtime/sandbox-modules.js +163 -0
- package/src/runtime/spring.js +246 -0
- package/src/runtime/strict.js +215 -0
- package/src/runtime/transfer.js +75 -0
- package/src/runtime/tween.js +158 -0
- package/src/runtime/wasm-fuel.js +596 -0
- package/src/runtime/worker/00-prelude.js +88 -0
- package/src/runtime/worker/10-helpers.js +295 -0
- package/src/runtime/worker/20-io.js +645 -0
- package/src/runtime/worker/30-previews.js +210 -0
- package/src/runtime/worker/40-profile-lineage.js +278 -0
- package/src/runtime/worker/50-own-worker.js +233 -0
- package/src/runtime/worker/60-timers.js +172 -0
- package/src/runtime/worker/70-state-keyed.js +193 -0
- package/src/runtime/worker/80-each-compile-generators.js +619 -0
- package/src/runtime/worker/90-events-operators.js +655 -0
- package/src/runtime/worker/95-agents-batches.js +1820 -0
- package/src/runtime/worker/96-plot.js +47 -0
- package/src/runtime/worker/97-calc.js +28 -0
- package/src/runtime/worker/98-geometry.js +24 -0
- package/src/runtime/worker/99-graph.js +30 -0
- package/src/runtime/worker/99-shell.js +30 -0
- package/src/safety/config.js +57 -0
- package/src/safety/engine.js +324 -0
- package/src/scene/pixi-scene.js +806 -0
- package/src/scene/scene-assets.js +241 -0
- package/src/scene/scene-edit.js +319 -0
- package/src/secret/settings.js +41 -0
- package/src/security/multipart.js +257 -0
- package/src/security/redact.js +261 -0
- package/src/serial/broker.js +473 -0
- package/src/serial/config.js +185 -0
- package/src/serial/framers.js +389 -0
- package/src/serial/packets.js +64 -0
- package/src/shader/audio-texture.js +87 -0
- package/src/shader/channels.js +496 -0
- package/src/shader/common.js +90 -0
- package/src/shader/model.js +867 -0
- package/src/shader/passes.js +150 -0
- package/src/shader/shadertoy.js +198 -0
- package/src/shell/hub.js +287 -0
- package/src/sim/checkpoints.js +850 -0
- package/src/sim/compile.js +37 -0
- package/src/sim/fixed.js +377 -0
- package/src/sim/headless.js +205 -0
- package/src/sim/physics.js +399 -0
- package/src/smf-helper/vendor.js +2 -0
- package/src/sources/config.js +435 -0
- package/src/storage.js +153 -0
- package/src/table/table-geo.js +2344 -0
- package/src/table/table-lineage.js +808 -0
- package/src/table/table-quality.js +355 -0
- package/src/table/table-schema.js +392 -0
- package/src/table/table-sql.js +1650 -0
- package/src/table/table-stats.js +480 -0
- package/src/table/table.js +2102 -0
- package/src/tensor/tensor.js +1153 -0
- package/src/terminal/hub.js +715 -0
- package/src/terminal/screen.js +516 -0
- package/src/tests/capture.js +88 -0
- package/src/tests/compare.js +480 -0
- package/src/tests/dataset.js +170 -0
- package/src/tests/evaluate.js +286 -0
- package/src/tests/from-runs.js +99 -0
- package/src/tests/judge.js +134 -0
- package/src/tests/matchers.js +263 -0
- package/src/tests/matrix-spec.js +87 -0
- package/src/tests/matrix.js +397 -0
- package/src/tests/metrics.js +369 -0
- package/src/tests/no-value.js +42 -0
- package/src/tests/pane-check.js +45 -0
- package/src/tests/report.js +124 -0
- package/src/tests/reporters.js +140 -0
- package/src/tests/run.js +155 -0
- package/src/tilemap/tilemap.js +1122 -0
- package/src/units/units.js +3 -0
- package/src/util/bytes-text.js +21 -0
- package/src/util/num.js +10 -0
- package/src/util/regexp.js +2 -0
- package/src/util/text.js +38 -0
- package/src/verdict/engine.js +154 -0
- package/src/vm/guest-wsh.js +108 -0
- package/src/vm/hub.js +457 -0
- package/src/vm/image-files.js +4 -0
- package/src/vm/image.js +33 -0
- package/src/vm/image.lock.json +13 -0
- package/src/vm/link.js +266 -0
- package/src/vm/mount.js +212 -0
- package/src/vm/net.js +85 -0
- package/src/vm/pipe-ws.js +187 -0
- package/src/vm/v86-loader.js +11 -0
- package/src/webmcp/args.js +212 -0
- package/src/webmcp/hidden.js +218 -0
- package/src/webmcp/text.js +250 -0
- package/src/webmcp/tools/bookmark-tools.js +106 -0
- package/src/webmcp/tools/breakpoint-tools.js +48 -0
- package/src/webmcp/tools/canvases.js +208 -0
- package/src/webmcp/tools/context-tools.js +84 -0
- package/src/webmcp/tools/core.js +170 -0
- package/src/webmcp/tools/devices.js +41 -0
- package/src/webmcp/tools/edit.js +357 -0
- package/src/webmcp/tools/event-tools.js +145 -0
- package/src/webmcp/tools/image-tools.js +173 -0
- package/src/webmcp/tools/ink-tools.js +247 -0
- package/src/webmcp/tools/input-log-tools.js +163 -0
- package/src/webmcp/tools/live.js +166 -0
- package/src/webmcp/tools/machine-tools.js +74 -0
- package/src/webmcp/tools/media.js +161 -0
- package/src/webmcp/tools/midi-tools.js +32 -0
- package/src/webmcp/tools/preset-tools.js +184 -0
- package/src/webmcp/tools/quick-add-tools.js +95 -0
- package/src/webmcp/tools/reshape.js +152 -0
- package/src/webmcp/tools/run-tools.js +309 -0
- package/src/webmcp/tools/runs.js +101 -0
- package/src/webmcp/tools/scaffold-tools.js +161 -0
- package/src/webmcp/tools/serial-tools.js +36 -0
- package/src/webmcp/tools/shared.js +338 -0
- package/src/webmcp/tools/subgraphs.js +360 -0
- package/src/webmcp/tools/tests.js +170 -0
- package/src/webmcp/tools/traffic-tools.js +70 -0
- package/src/webmcp/tools/transport-tools.js +65 -0
- package/src/webmcp/tools/version-tools.js +126 -0
- package/src/webmcp/tools/versions.js +11 -0
- package/src/webmcp/tools/wire-tools.js +90 -0
- package/src/webmcp/tools/workspace-tools.js +93 -0
- package/src/webmcp/tools.js +1323 -0
- package/src/wsh/connect.js +347 -0
- package/src/wsh/demo-host.js +361 -0
- package/src/wsh/e2e.js +27 -0
- package/src/wsh/keys.js +154 -0
- package/src/wsh/known-hosts.js +39 -0
- package/src/wsh/private-key.js +95 -0
- package/src/wsh/reverse.js +34 -0
- package/src/wsh/settings.js +118 -0
- package/src/wsh/transfer.js +62 -0
- package/src/wsh/vendor.js +5 -0
- package/src/x402/challenge.js +171 -0
- package/src/x402/demo-server.js +127 -0
- package/src/x402/pay.js +125 -0
- package/src/x402/retry.js +95 -0
- package/src/x402/store.js +76 -0
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
// `mallory pkg`: author tooling for pane packages (#661), with no UI.
|
|
2
|
+
//
|
|
3
|
+
// mallory pkg check <file|folder> check a package against the spec (docs/pane-package-spec.md),
|
|
4
|
+
// and report on it as the install review does
|
|
5
|
+
// mallory pkg test <file|folder> run every pane's tests in an isolated sandbox, as the review's
|
|
6
|
+
// "run its tests" does (no variables, no API keys, no hosts)
|
|
7
|
+
// mallory pkg pack <folder> build the .mallory-pkg.json from a folder of canvases
|
|
8
|
+
// mallory pkg new <name> start a package: a function canvas, a test, package.json and CI
|
|
9
|
+
// mallory pkg keygen <key file> make an Ed25519 signing key (#664): the private key into that file only
|
|
10
|
+
// mallory pkg sign <file|folder> sign a package with --key (src/packages/signing.js)
|
|
11
|
+
// mallory pkg trust [name] the headless trust file's pinned keys: list, --pin, --forget
|
|
12
|
+
// mallory pkg serve <tarball|folder> a stand-in npm CDN on this computer, to try the npm install path (#726)
|
|
13
|
+
//
|
|
14
|
+
// Everything a package is checked with is src/packages/ (checkPackage, the same as an install);
|
|
15
|
+
// tests run through src/tests/run.js and print through the #564 reporters. Node-only (src/headless/).
|
|
16
|
+
import { readFile, writeFile, readdir, stat, mkdir, open as openFile } from "node:fs/promises";
|
|
17
|
+
import { createPrivateKey, createPublicKey, generateKeyPairSync, sign as nodeSign } from "node:crypto";
|
|
18
|
+
import { join, resolve, relative, dirname, basename, sep, isAbsolute } from "node:path";
|
|
19
|
+
import { hasPackageKeyword, parsePackage, checkPackage, readPackageData, packageSignature, integrityOf, paneDoc, signatureLine, packageHosts, packageFileName, isPackageNameValid, isPackageName, typesUsed, PACKAGE_FORMAT, PACKAGE_VERSION, PACKAGE_SCHEMA_URL, NPM_KEYWORD } from "../packages/package.js";
|
|
20
|
+
import { assetsSummary, formatBytes, sha256Of } from "../packages/assets.js";
|
|
21
|
+
import { moduleSummary, moduleFor, moduleIntegrity, moduleMatches, MODULE_HELPER } from "../packages/module.js";
|
|
22
|
+
import { deprecationLine } from "../packages/deprecation.js";
|
|
23
|
+
import { importCanvas, exportCanvas, formatForName } from "../formats/registry.js";
|
|
24
|
+
import { readYaml } from "../formats/yaml.js";
|
|
25
|
+
import { typeFromName } from "../media/mime.js";
|
|
26
|
+
import { toBase64 } from "../media/persist.js";
|
|
27
|
+
import { runTests, formatReport } from "../tests/run.js";
|
|
28
|
+
import { REPORTERS, formatWith } from "../tests/reporters.js";
|
|
29
|
+
import { normalizeHost } from "../network/hosts.js";
|
|
30
|
+
import { signData, signingPayload, fingerprintOf, fromB64, FINGERPRINT } from "../packages/signing.js";
|
|
31
|
+
import { signatureLabel } from "../packages/trust.js";
|
|
32
|
+
import { holdsPackage } from "../packages/published.js";
|
|
33
|
+
import { openTrustFile } from "./trust-file.js";
|
|
34
|
+
import { functionCanvas } from "../packages/function-canvas.js";
|
|
35
|
+
import { pathToFileURL } from "node:url";
|
|
36
|
+
|
|
37
|
+
export const PKG_HELP = `mallory pkg: make, check and test pane packages without the UI.
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
mallory pkg check <package> [--json] [--strict]
|
|
41
|
+
mallory pkg test <package> [--reporter tap|junit|json] [--json] [--allow-host host]... [--timeout seconds]
|
|
42
|
+
mallory pkg pack <folder> [--output file] [--check]
|
|
43
|
+
mallory pkg new <name> [--dir folder] [--description text] [--license id]
|
|
44
|
+
mallory pkg keygen <key file>
|
|
45
|
+
mallory pkg sign <package> --key <key file> [--output file]
|
|
46
|
+
mallory pkg trust [name] --trust-file <file> [--pin fingerprint | --forget] [--json]
|
|
47
|
+
mallory pkg serve <tarball or folder> [--port n] [--host address] [--sources file] [--check]
|
|
48
|
+
|
|
49
|
+
<package> is a package file (.mallory-pkg.json or .mallory-pkg.yaml), or a folder
|
|
50
|
+
with one: the file its package.json's "mallory" field names, else the only
|
|
51
|
+
package file in it.
|
|
52
|
+
|
|
53
|
+
check Reads the package as an install does (docs/pane-package-spec.md: every
|
|
54
|
+
rule, including those a JSON Schema can't check) and prints what the
|
|
55
|
+
install review shows: name, version, licence, integrity, each pane with
|
|
56
|
+
its signature, tests and hosts, what it requires, its files and notices.
|
|
57
|
+
Beside a package.json it also checks what npm installs need: the same
|
|
58
|
+
name, the "mallory" field naming this file, "files" including it, and
|
|
59
|
+
the "${NPM_KEYWORD}" keyword. It says whether the package is signed and
|
|
60
|
+
by which key; a signature that doesn't match fails, and --expect-key
|
|
61
|
+
fails unless the package is signed by that key. In a folder that packs (see pack), a
|
|
62
|
+
package file older than its sources is a problem. Problems fail; warnings
|
|
63
|
+
(a pane without tests, no licence, no $schema, a version unlike
|
|
64
|
+
package.json's) fail only with --strict.
|
|
65
|
+
test Runs every pane's tests in a sandbox of their own, as the review's "run
|
|
66
|
+
its tests" does: no variables, no API keys, and no network unless
|
|
67
|
+
--allow-host names a host the package's panes say they use (for this
|
|
68
|
+
run only). The package's files are there as assets, and its shared
|
|
69
|
+
module as pkg.module.
|
|
70
|
+
pack Builds the package file from a folder, so a package can live as
|
|
71
|
+
readable canvases in git: package.json gives the name, version,
|
|
72
|
+
description and licence (and, in "mallory", the file to write);
|
|
73
|
+
mallory-package.yaml (or .json), if there is one, lists the panes with
|
|
74
|
+
their titles, descriptions, icons and hosts, and the examples, assets,
|
|
75
|
+
requires and deprecations. Without it every canvas in panes/ is a pane
|
|
76
|
+
(its id the file name, its title the canvas's name), every canvas in
|
|
77
|
+
examples/ an example and every file in assets/ an asset. A pane's tests
|
|
78
|
+
are its canvas's. Writes JSON with $schema, the same bytes for the same
|
|
79
|
+
sources; --check writes nothing and fails when the file is out of date.
|
|
80
|
+
"generate: build/panes.mjs" in the manifest runs that module for panes
|
|
81
|
+
made by code: its default export is the panes (each { id, title,
|
|
82
|
+
description, icon, canvas: a canvas object, tests, hosts }), or a
|
|
83
|
+
function, called with { functionCanvas }, that returns them (or
|
|
84
|
+
{ panes, examples, module }); they follow the manifest's own panes.
|
|
85
|
+
"module: lib/bundle.js" (or { file, name }) ships one shared module
|
|
86
|
+
every pane reads as pkg.module: a self-contained ES module (bundle its
|
|
87
|
+
library into it first), written with its integrity, and the package
|
|
88
|
+
then requires the pkg helper (pack adds it).
|
|
89
|
+
A signature the file has is kept while it still matches what pack
|
|
90
|
+
writes (sign again after any change).
|
|
91
|
+
new Writes a starter package into a new folder (default: the name without
|
|
92
|
+
its scope): a function canvas with a test, mallory-package.yaml,
|
|
93
|
+
package.json (the "mallory" field and the "${NPM_KEYWORD}" keyword),
|
|
94
|
+
a README, a GitHub Actions workflow that packs, checks and tests it, and
|
|
95
|
+
the packed package file, which passes check and test as it is.
|
|
96
|
+
keygen Makes an Ed25519 signing key and writes the private key (PKCS#8 PEM, or
|
|
97
|
+
a JWK for a name ending .jwk or .json) to the file named, readable by
|
|
98
|
+
you only; it refuses to overwrite a file. Prints the public key and its
|
|
99
|
+
fingerprint, which people see in the install review. Keep the file out
|
|
100
|
+
of the package and out of git.
|
|
101
|
+
sign Signs a package with the private key in --key (PKCS#8 PEM or DER, or a
|
|
102
|
+
JWK): the signature and the public key go into the package file, over
|
|
103
|
+
everything else in it (docs/pane-package-spec.md, "Signature"). A JSON
|
|
104
|
+
file is rewritten as pack writes it; a YAML file keeps its text and
|
|
105
|
+
gets a signature block at the end. The key is read and used in memory:
|
|
106
|
+
it is never written anywhere or printed. Sign last, after pack.
|
|
107
|
+
trust The trust file headless runs use with --trust-file (docs/guide/settings-and-storage.md, "Publisher
|
|
108
|
+
trust"): lists the pinned keys; with a name, --pin sets its key (to
|
|
109
|
+
accept a new one) and --forget removes it.
|
|
110
|
+
serve Tries the npm install path before you publish: serves an npm pack
|
|
111
|
+
tarball (or a package folder: package.json, the file its "mallory"
|
|
112
|
+
field names, the README) on this computer the way a raw npm CDN does,
|
|
113
|
+
and prints the package source that sends this one name there. Import
|
|
114
|
+
it in mallory (settings, package sources), turn on "Allow local
|
|
115
|
+
network", and install the package by name as people will. --sources
|
|
116
|
+
also writes it to a file (for mallory run --sources). Runs until
|
|
117
|
+
Ctrl+C. With --check it installs the package by name through that
|
|
118
|
+
source itself, as the page does, prints what the review shows, and
|
|
119
|
+
stops (exit 1 when the install or a check fails).
|
|
120
|
+
|
|
121
|
+
Options:
|
|
122
|
+
--json check: the report as JSON. test: the results as JSON (--reporter json).
|
|
123
|
+
--strict check: warnings fail too.
|
|
124
|
+
--reporter tap|junit|json
|
|
125
|
+
test: print the results for a CI step (TAP 13, JUnit XML, JSON).
|
|
126
|
+
--allow-host host test: let the tests reach this host (one the package's panes list in
|
|
127
|
+
"hosts"). Repeatable.
|
|
128
|
+
--timeout seconds test: how long one pane may run (default 15).
|
|
129
|
+
--output file, -o file pack: write here instead of the file package.json names.
|
|
130
|
+
--check pack: write nothing; exit 1 when the file isn't what pack would write.
|
|
131
|
+
--dir folder new: the folder to create (it must not exist, or be empty).
|
|
132
|
+
--description text new: the package's description.
|
|
133
|
+
--license id new: its licence (default MIT).
|
|
134
|
+
--key file sign: the private key (from mallory pkg keygen, or openssl genpkey -algorithm ed25519).
|
|
135
|
+
--expect-key fp check: fail unless the package is signed by this key (SHA256:…).
|
|
136
|
+
--trust-file file trust: the trust file (created when missing).
|
|
137
|
+
--pin fp trust: pin the name to this key fingerprint (SHA256:…).
|
|
138
|
+
--forget trust: forget the name's pinned key.
|
|
139
|
+
--port n serve: the port (default 4874; 0 for any free one).
|
|
140
|
+
--host address serve: the address to listen on (default 127.0.0.1).
|
|
141
|
+
--sources file serve: also write the package sources to this file.
|
|
142
|
+
--check serve: install by name through the stand-in, check it, and stop.
|
|
143
|
+
--help, -h This help.
|
|
144
|
+
|
|
145
|
+
Exit codes: 0 ok; 1 the package is refused, a check failed, a test failed or the
|
|
146
|
+
file is out of date; 2 a usage error, an unreadable file, or no tests to run.`;
|
|
147
|
+
|
|
148
|
+
class UsageError extends Error {}
|
|
149
|
+
|
|
150
|
+
const SUBCOMMANDS = ["check", "test", "pack", "new", "keygen", "sign", "trust", "serve"];
|
|
151
|
+
const MANIFESTS = ["mallory-package.yaml", "mallory-package.yml", "mallory-package.json"];
|
|
152
|
+
|
|
153
|
+
/** Parse `mallory pkg` arguments (without "pkg"). */
|
|
154
|
+
export function parsePkgArgs(argv) {
|
|
155
|
+
const out = { help: false, command: undefined, files: [], json: false, strict: false, reporter: undefined, allowHosts: [], timeoutMs: 15000, output: undefined, check: false, dir: undefined, description: undefined, license: undefined, key: undefined, expectKey: undefined, trustFile: undefined, pin: undefined, forget: false, port: undefined, host: undefined, sourcesFile: undefined };
|
|
156
|
+
const args = [...argv];
|
|
157
|
+
const take = (flag, inline) => {
|
|
158
|
+
const value = inline ?? args.shift();
|
|
159
|
+
if (value === undefined || (value.startsWith("-") && value !== "-" && inline === undefined)) throw new UsageError(`${flag} needs a value`);
|
|
160
|
+
return value;
|
|
161
|
+
};
|
|
162
|
+
while (args.length) {
|
|
163
|
+
const arg = args.shift();
|
|
164
|
+
const [flag, inline] = arg.startsWith("--") && arg.includes("=") ? [arg.slice(0, arg.indexOf("=")), arg.slice(arg.indexOf("=") + 1)] : [arg, undefined];
|
|
165
|
+
if (flag === "-h" || flag === "--help") return { ...out, help: true };
|
|
166
|
+
else if (flag === "--json") out.json = true;
|
|
167
|
+
else if (flag === "--strict") out.strict = true;
|
|
168
|
+
else if (flag === "--check") out.check = true;
|
|
169
|
+
else if (flag === "--reporter") {
|
|
170
|
+
const r = take(flag, inline).toLowerCase();
|
|
171
|
+
if (!REPORTERS.includes(r)) throw new UsageError(`--reporter takes ${REPORTERS.slice(0, -1).join(", ")} or ${REPORTERS.at(-1)} (got "${r}")`);
|
|
172
|
+
out.reporter = r;
|
|
173
|
+
} else if (flag === "--allow-host") out.allowHosts.push(normalizeHost(take(flag, inline)));
|
|
174
|
+
else if (flag === "--timeout") {
|
|
175
|
+
const s = Number(take(flag, inline));
|
|
176
|
+
if (!(s > 0)) throw new UsageError("--timeout takes a number of seconds");
|
|
177
|
+
out.timeoutMs = s * 1000;
|
|
178
|
+
} else if (flag === "--output" || flag === "-o") out.output = take(flag, inline);
|
|
179
|
+
else if (flag === "--dir") out.dir = take(flag, inline);
|
|
180
|
+
else if (flag === "--description") out.description = take(flag, inline);
|
|
181
|
+
else if (flag === "--license") out.license = take(flag, inline);
|
|
182
|
+
else if (flag === "--key") out.key = take(flag, inline);
|
|
183
|
+
else if (flag === "--expect-key") out.expectKey = take(flag, inline);
|
|
184
|
+
else if (flag === "--trust-file") out.trustFile = take(flag, inline);
|
|
185
|
+
else if (flag === "--pin") out.pin = take(flag, inline);
|
|
186
|
+
else if (flag === "--forget") out.forget = true;
|
|
187
|
+
else if (flag === "--port") {
|
|
188
|
+
const n = Number(take(flag, inline));
|
|
189
|
+
if (!Number.isInteger(n) || n < 0 || n > 65535) throw new UsageError("--port takes a port number (0 for any free one)");
|
|
190
|
+
out.port = n;
|
|
191
|
+
} else if (flag === "--host") out.host = take(flag, inline);
|
|
192
|
+
else if (flag === "--sources") out.sourcesFile = take(flag, inline);
|
|
193
|
+
else if (flag === "--") out.files.push(...args.splice(0));
|
|
194
|
+
else if (flag.startsWith("-") && flag !== "-") throw new UsageError(`unknown option ${flag}`);
|
|
195
|
+
else if (!out.command) out.command = arg;
|
|
196
|
+
else out.files.push(arg);
|
|
197
|
+
}
|
|
198
|
+
if (!out.command) return { ...out, help: true };
|
|
199
|
+
if (!SUBCOMMANDS.includes(out.command)) throw new UsageError(`mallory pkg ${out.command}: there is no such command (${SUBCOMMANDS.join(", ")})`);
|
|
200
|
+
const what = { new: "package name", pack: "folder", keygen: "key file", trust: "package name", serve: "npm tarball or package folder" }[out.command] ?? "package file or folder";
|
|
201
|
+
if (out.command === "trust" ? out.files.length > 1 : out.files.length !== 1) throw new UsageError(`mallory pkg ${out.command} takes ${out.command === "trust" ? "at most " : ""}one ${what} (got ${out.files.length})`);
|
|
202
|
+
const only = { check: ["json", "strict", "expectKey"], test: ["json", "reporter", "allowHosts", "timeoutMs"], pack: ["output", "check"], new: ["dir", "description", "license"], keygen: [], sign: ["key", "output"], trust: ["json", "trustFile", "pin", "forget"], serve: ["port", "host", "sourcesFile", "check"] }[out.command];
|
|
203
|
+
const given = { json: out.json, strict: out.strict, reporter: out.reporter !== undefined, allowHosts: out.allowHosts.length > 0, timeoutMs: out.timeoutMs !== 15000, output: out.output !== undefined, check: out.check, dir: out.dir !== undefined, description: out.description !== undefined, license: out.license !== undefined, key: out.key !== undefined, expectKey: out.expectKey !== undefined, trustFile: out.trustFile !== undefined, pin: out.pin !== undefined, forget: out.forget, port: out.port !== undefined, host: out.host !== undefined, sourcesFile: out.sourcesFile !== undefined };
|
|
204
|
+
const wrong = Object.keys(given).filter((k) => given[k] && !only.includes(k));
|
|
205
|
+
const flagName = (k) => ({ allowHosts: "--allow-host", timeoutMs: "--timeout", expectKey: "--expect-key", trustFile: "--trust-file", sourcesFile: "--sources" })[k] ?? `--${k}`;
|
|
206
|
+
if (wrong.length) throw new UsageError(`mallory pkg ${out.command} doesn't take ${wrong.map(flagName).join(", ")}`);
|
|
207
|
+
if (out.command === "sign" && !out.key) throw new UsageError("mallory pkg sign needs --key <file>: the private key to sign with");
|
|
208
|
+
if (out.command === "trust" && !out.trustFile) throw new UsageError("mallory pkg trust needs --trust-file <file>");
|
|
209
|
+
if (out.command === "trust" && out.pin && out.forget) throw new UsageError("--pin and --forget: one or the other");
|
|
210
|
+
if (out.command === "trust" && (out.pin || out.forget) && !out.files.length) throw new UsageError(`${out.pin ? "--pin" : "--forget"} needs the package name`);
|
|
211
|
+
for (const fp of [out.expectKey, out.pin]) if (fp !== undefined && !FINGERPRINT.test(fp)) throw new UsageError(`"${fp}" isn't a key fingerprint (SHA256: and 43 base64 characters, as mallory pkg check prints it)`);
|
|
212
|
+
if (out.reporter && out.json && out.reporter !== "json") throw new UsageError("--reporter and --json both choose the output (--reporter json is --json)");
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ── finding things on disk ─────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
const isDir = async (path) => (await stat(path).catch(() => null))?.isDirectory() ?? false;
|
|
219
|
+
|
|
220
|
+
async function readJson(path) {
|
|
221
|
+
const text = await readFile(path, "utf8");
|
|
222
|
+
try {
|
|
223
|
+
return JSON.parse(text);
|
|
224
|
+
} catch (error) {
|
|
225
|
+
throw new UsageError(`${path} isn't JSON: ${error.message}`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A folder's package.json, or undefined when it has none. */
|
|
230
|
+
async function npmManifest(folder) {
|
|
231
|
+
const path = join(folder, "package.json");
|
|
232
|
+
if (!(await stat(path).catch(() => null))) return undefined;
|
|
233
|
+
return { path, data: await readJson(path) };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** A path that the manifest gives, inside `folder` (a package's sources stay in its folder). */
|
|
237
|
+
function inside(folder, path, what) {
|
|
238
|
+
if (typeof path !== "string" || !path.trim() || isAbsolute(path)) throw new Error(`${what} must be a path inside the folder (got ${JSON.stringify(path)}).`);
|
|
239
|
+
const full = resolve(folder, path);
|
|
240
|
+
const rel = relative(resolve(folder), full);
|
|
241
|
+
if (rel.startsWith("..") || isAbsolute(rel)) throw new Error(`${what} "${path}" is outside the folder.`);
|
|
242
|
+
return full;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The package file a `check` or `test` argument means: the file itself, or in a folder the file
|
|
247
|
+
* package.json's "mallory" field names, else the only package file there. `{ file, folder, npm? }`.
|
|
248
|
+
*/
|
|
249
|
+
export async function locatePackage(path) {
|
|
250
|
+
if (!(await isDir(path))) return { file: path, folder: dirname(path), npm: await npmManifest(dirname(path)).catch(() => undefined) };
|
|
251
|
+
const npm = await npmManifest(path);
|
|
252
|
+
// Legacy: package.json files published before the renames keep their pane package under a "viaframe" or "miso" field.
|
|
253
|
+
const field = npm?.data?.mallory ?? npm?.data?.viaframe ?? npm?.data?.miso;
|
|
254
|
+
if (typeof field === "string") return { file: inside(path, field, `package.json's "mallory" field`), folder: path, npm };
|
|
255
|
+
const found = (await readdir(path)).filter(isPackageName).sort();
|
|
256
|
+
if (found.length === 1) return { file: join(path, found[0]), folder: path, npm };
|
|
257
|
+
throw new UsageError(found.length ? `${path} has ${found.length} package files (${found.join(", ")}): name one, or the one package.json's "mallory" field names` : `${path} has no package file (.mallory-pkg.json) and no package.json "mallory" field naming one${(await hasSources(path)) ? ": run mallory pkg pack first" : ""}`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const hasSources = async (folder) => (await Promise.all([...MANIFESTS.map((m) => stat(join(folder, m)).then(() => true, () => false)), isDir(join(folder, "panes"))])).some(Boolean);
|
|
261
|
+
|
|
262
|
+
// ── check ──────────────────────────────────────────────────────────────────
|
|
263
|
+
|
|
264
|
+
/** Does npm's `files` list publish `file` (a path relative to the package)? Globs can't be told here: undefined. */
|
|
265
|
+
function filesInclude(files, file) {
|
|
266
|
+
if (!Array.isArray(files)) return true;
|
|
267
|
+
if (files.some((f) => typeof f === "string" && /[*?[\]{}!]/.test(f))) return undefined;
|
|
268
|
+
const norm = (p) => String(p).replace(/^\.\//, "").replace(/\/+$/, "");
|
|
269
|
+
return files.some((f) => norm(file) === norm(f) || norm(file).startsWith(`${norm(f)}/`));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* What `check` reports about a package's text: the install review's facts, with problems (which
|
|
274
|
+
* fail) and warnings. `npm` is a package.json beside it (`{ path, data }`) and `file` its path,
|
|
275
|
+
* for the npm checks. Pure but for the integrity hash.
|
|
276
|
+
*/
|
|
277
|
+
export async function checkReport(text, { file = "package", npm, expectKey } = {}) {
|
|
278
|
+
const problems = [];
|
|
279
|
+
const warnings = [];
|
|
280
|
+
let parsed;
|
|
281
|
+
try {
|
|
282
|
+
parsed = parsePackage(text);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return { ok: false, file, problems: [error.message], warnings };
|
|
285
|
+
}
|
|
286
|
+
const { pkg, notes } = parsed;
|
|
287
|
+
let raw;
|
|
288
|
+
try {
|
|
289
|
+
raw = /^\s*[[{]/.test(text) ? JSON.parse(text) : readYaml(text, "package");
|
|
290
|
+
} catch {
|
|
291
|
+
raw = {};
|
|
292
|
+
}
|
|
293
|
+
if (raw.$schema === undefined) warnings.push(`it has no "$schema" (${PACKAGE_SCHEMA_URL}), so editors can't check it as you type`);
|
|
294
|
+
// The second URL is the one packages published before the rename carry.
|
|
295
|
+
else if (raw.$schema !== PACKAGE_SCHEMA_URL && raw.$schema !== "https://viaframe.johnhenry.me/schemas/viaframe-package.v1.schema.json") warnings.push(`its "$schema" is ${raw.$schema}, not this format's (${PACKAGE_SCHEMA_URL})`);
|
|
296
|
+
if (!pkg.license) warnings.push("it states no licence");
|
|
297
|
+
for (const p of pkg.panes) if (!p.tests?.length) warnings.push(`pane "${p.id}" has no tests`);
|
|
298
|
+
for (const n of notes) warnings.push(n);
|
|
299
|
+
if (npm) {
|
|
300
|
+
const d = npm.data ?? {};
|
|
301
|
+
const where = basename(npm.path);
|
|
302
|
+
const rel = relative(dirname(npm.path), file).split(sep).join("/");
|
|
303
|
+
if (!holdsPackage(d.name, pkg.name)) problems.push(`${where} names "${d.name ?? ""}" but the package is "${pkg.name}": an install from npm refuses that (the names must match)`);
|
|
304
|
+
const field = d.mallory ?? d.viaframe ?? d.miso;
|
|
305
|
+
if (field === undefined) problems.push(`${where} has no "mallory" field: an install from npm can't find the package file (set it to "${rel}")`);
|
|
306
|
+
else if (typeof field !== "string" || field.replace(/^\.\//, "") !== rel) problems.push(`${where}'s "mallory" field is ${JSON.stringify(field)}, not this file ("${rel}")`);
|
|
307
|
+
if (d.version !== undefined && d.version !== pkg.packageVersion) warnings.push(`${where}'s version is ${d.version} but packageVersion is ${pkg.packageVersion}: keep them the same`);
|
|
308
|
+
if (!hasPackageKeyword(d.keywords)) warnings.push(`${where} doesn't list the keyword "${NPM_KEYWORD}", which people search npm for (the review notes its absence)`);
|
|
309
|
+
const published = filesInclude(d.files, rel);
|
|
310
|
+
if (published === false) problems.push(`${where}'s "files" doesn't include ${rel}: npm wouldn't publish the package file`);
|
|
311
|
+
if (d.main !== undefined || d.exports !== undefined) warnings.push(`${where} has "main" or "exports": nothing from a pane package is imported, so leave them out`);
|
|
312
|
+
}
|
|
313
|
+
// The publisher signature (#664): one that doesn't match fails, as it fails an install.
|
|
314
|
+
const sig = await packageSignature(text);
|
|
315
|
+
const signature = { state: sig.state, ...(sig.fingerprint ? { fingerprint: sig.fingerprint } : {}), ...(sig.reason ? { reason: sig.reason } : {}) };
|
|
316
|
+
if (sig.state === "invalid") problems.push(`its signature is invalid (${sig.reason}): an install refuses it; sign it again with mallory pkg sign`);
|
|
317
|
+
if (expectKey && !(sig.state === "signed" && sig.fingerprint === expectKey)) problems.push(sig.state === "signed" ? `it is signed by ${sig.fingerprint}, not ${expectKey} (--expect-key)` : `it isn't signed by ${expectKey} (--expect-key): it is ${signatureLabel(sig)}`);
|
|
318
|
+
const assets = assetsSummary(pkg);
|
|
319
|
+
const module = moduleSummary(pkg);
|
|
320
|
+
if (pkg.module && !(await moduleMatches(pkg.module))) problems.push(`its module "${pkg.module.name}" doesn't match its integrity: an install refuses it (run mallory pkg pack again)`);
|
|
321
|
+
return {
|
|
322
|
+
ok: problems.length === 0,
|
|
323
|
+
file,
|
|
324
|
+
name: pkg.name,
|
|
325
|
+
version: pkg.packageVersion,
|
|
326
|
+
format: pkg.version,
|
|
327
|
+
license: pkg.license,
|
|
328
|
+
description: pkg.description,
|
|
329
|
+
integrity: await integrityOf(text),
|
|
330
|
+
signature,
|
|
331
|
+
requires: pkg.requires,
|
|
332
|
+
panes: pkg.panes.map((p) => ({ id: p.id, title: p.title, signature: signatureLine(p), tests: p.tests?.length ?? 0, hosts: p.hosts, types: typesUsed(p.canvas), ...(p.deprecated ? { deprecated: deprecationLine(p.deprecated, { version: pkg.packageVersion }) } : {}) })),
|
|
333
|
+
examples: pkg.examples?.length ?? 0,
|
|
334
|
+
hosts: packageHosts(pkg),
|
|
335
|
+
assets: assets.count ? assets : undefined,
|
|
336
|
+
...(module ? { module } : {}),
|
|
337
|
+
...(pkg.deprecated ? { deprecated: deprecationLine(pkg.deprecated, { version: pkg.packageVersion }) } : {}),
|
|
338
|
+
problems,
|
|
339
|
+
warnings,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** The report for a terminal, laid out like the install review. */
|
|
344
|
+
export function formatCheck(r, { strict = false } = {}) {
|
|
345
|
+
const lines = [];
|
|
346
|
+
if (r.name) {
|
|
347
|
+
lines.push(`${r.name} ${r.version} (package format ${r.format})`);
|
|
348
|
+
if (r.description) lines.push(` ${r.description}`);
|
|
349
|
+
lines.push(` licence ${r.license || "not stated"}`, ` integrity ${r.integrity}`);
|
|
350
|
+
if (r.signature) lines.push(` signature ${r.signature.state === "signed" ? `signed by ${r.signature.fingerprint}` : r.signature.state === "invalid" ? `invalid: ${r.signature.reason}` : "unsigned (the install review labels it unsigned; mallory pkg sign signs it)"}`);
|
|
351
|
+
if (r.requires?.helpers) lines.push(` helpers ${Object.entries(r.requires.helpers).map(([n, v]) => `${n} ${v}`).join(", ")}`);
|
|
352
|
+
if (r.requires?.panes) lines.push(` pane types ${r.requires.panes.join(", ")}`);
|
|
353
|
+
if (r.hosts.length) lines.push(` hosts ${r.hosts.join(", ")} (a hint: allows nothing)`);
|
|
354
|
+
if (r.deprecated) lines.push(` ⚠ ${r.deprecated}`);
|
|
355
|
+
lines.push("", `${r.panes.length} pane${r.panes.length === 1 ? "" : "s"}:`);
|
|
356
|
+
for (const p of r.panes) {
|
|
357
|
+
lines.push(` ${p.id} ${p.title}`, ` ${p.signature}`, ` ${p.tests ? `${p.tests} test${p.tests === 1 ? "" : "s"}` : "no tests"}${p.hosts.length ? `; hosts: ${p.hosts.join(", ")}` : ""}`);
|
|
358
|
+
if (p.deprecated) lines.push(` ⚠ ${p.deprecated}`);
|
|
359
|
+
}
|
|
360
|
+
if (r.examples) lines.push(`${r.examples} example${r.examples === 1 ? "" : "s"}`);
|
|
361
|
+
if (r.module) lines.push(`shared module ${r.module.name} (${formatBytes(r.module.bytes)}, ${r.module.lines} line${r.module.lines === 1 ? "" : "s"}): ${r.module.integrity}; its panes read it as pkg.module`);
|
|
362
|
+
if (r.assets) lines.push(`${r.assets.count} file${r.assets.count === 1 ? "" : "s"} (${formatBytes(r.assets.bytes)}): ${r.assets.items.map((a) => `${a.name} (${a.type}, ${formatBytes(a.size)})`).join(", ")}`);
|
|
363
|
+
}
|
|
364
|
+
if (r.problems.length) lines.push("", "Problems:", ...r.problems.map((p) => ` ✗ ${p}`));
|
|
365
|
+
if (r.warnings.length) lines.push("", `Warnings${strict ? " (--strict: these fail)" : ""}:`, ...r.warnings.map((w) => ` ! ${w}`));
|
|
366
|
+
lines.push("", passed(r, strict) ? `✓ ${r.name} ${r.version} passes the checks an install makes.` : `✗ ${r.name ? `${r.name} ${r.version}` : r.file} doesn't pass.`);
|
|
367
|
+
return lines.join("\n");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const passed = (r, strict) => r.ok && (!strict || r.warnings.length === 0);
|
|
371
|
+
|
|
372
|
+
// ── test ───────────────────────────────────────────────────────────────────
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Run every pane's tests (src/packages/package.js paneDoc, its tests, the package's files as
|
|
376
|
+
* assets), one pane after another in `session`, as the install review does. Each result is named
|
|
377
|
+
* "<pane id>: <test name>". `{ pass, passed, failed, results, panes: [{ id, pass, passed, failed }] }`.
|
|
378
|
+
*/
|
|
379
|
+
export async function runPackageTests(pkg, session, { onPane = () => {} } = {}) {
|
|
380
|
+
const results = [];
|
|
381
|
+
const panes = [];
|
|
382
|
+
for (const pane of pkg.panes) {
|
|
383
|
+
if (!pane.tests?.length) continue;
|
|
384
|
+
const doc = { ...paneDoc(pkg, pane.id), tests: pane.tests };
|
|
385
|
+
const module = moduleFor(pkg.name, pkg.packageVersion, pkg.module); // `pkg.module` in its panes (src/packages/module.js)
|
|
386
|
+
const withAssets = pkg.assets?.length || module ? { run: (d, o) => session.run(d, { ...o, ...(pkg.assets?.length ? { assets: pkg.assets } : {}), ...(module ? { module } : {}) }) } : session;
|
|
387
|
+
const report = await runTests(doc, withAssets);
|
|
388
|
+
for (const r of report.results) results.push({ ...r, name: `${pane.id}: ${r.name}` });
|
|
389
|
+
panes.push({ id: pane.id, pass: report.pass, passed: report.passed, failed: report.failed });
|
|
390
|
+
onPane(pane.id, report);
|
|
391
|
+
}
|
|
392
|
+
const ok = results.filter((r) => r.pass).length;
|
|
393
|
+
return { pass: results.length > 0 && ok === results.length, passed: ok, failed: results.length - ok, results, panes };
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// ── pack ───────────────────────────────────────────────────────────────────
|
|
397
|
+
|
|
398
|
+
// Legacy: ".viaframe.*" and ".miso.*" canvas files saved before the renames.
|
|
399
|
+
const CANVAS_EXT = /\.(mallory|viaframe|miso)\.(json|ya?ml|md)$/i;
|
|
400
|
+
|
|
401
|
+
/** The canvas files in a folder, sorted (none when it doesn't exist): mallory's own, another tool's (a .ipynb, a .rivet-project), or any JSON or YAML; not a README or notes. */
|
|
402
|
+
async function canvasFiles(folder) {
|
|
403
|
+
if (!(await isDir(folder))) return [];
|
|
404
|
+
return (await readdir(folder)).filter((n) => !n.startsWith(".") && !isPackageName(n) && (CANVAS_EXT.test(n) || Boolean(formatForName(n)) || /\.(json|ya?ml)$/i.test(n))).sort().map((n) => join(folder, n));
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** A canvas file as a package pane's canvas: imported (any format), without what a package drops; its tests apart. */
|
|
408
|
+
async function readCanvas(path, note) {
|
|
409
|
+
return canvasFrom(await readFile(path, "utf8"), basename(path), note);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** A canvas (its text in any format, or a canvas object a generator made) as a package pane's canvas: checked like any import. */
|
|
413
|
+
function canvasFrom(source, label, note) {
|
|
414
|
+
const text = typeof source === "string" ? source : JSON.stringify(source);
|
|
415
|
+
let result;
|
|
416
|
+
try {
|
|
417
|
+
result = importCanvas(text, { name: label });
|
|
418
|
+
} catch (error) {
|
|
419
|
+
throw new Error(`${label}: ${error.message}`);
|
|
420
|
+
}
|
|
421
|
+
for (const n of result.notes) note(`${label} (${result.format.title}): ${n}`);
|
|
422
|
+
const { id, trusted, example, lineage, function: fn, tests, ...canvas } = result.doc;
|
|
423
|
+
return { canvas, tests, fn };
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Run a folder's generator module (`generate:` in the manifest, #726): its default export is the panes,
|
|
428
|
+
* or a function (it may be async) that `pack` calls with `{ functionCanvas }` and that returns the panes,
|
|
429
|
+
* or `{ panes, examples }`. Each pane is a manifest entry whose `canvas` is a canvas object (or its text)
|
|
430
|
+
* instead of a file: `{ id, title?, description?, icon?, canvas, tests?, hosts?, deprecated? }`. The module
|
|
431
|
+
* is the author's own code, run here with the rights of whoever runs pack, as a build script would be.
|
|
432
|
+
*/
|
|
433
|
+
async function runGenerator(folder, path, manifestName) {
|
|
434
|
+
const file = inside(folder, path, `${manifestName}'s generate`);
|
|
435
|
+
let mod;
|
|
436
|
+
try {
|
|
437
|
+
// A query string per pack: a second pack in one process (pack --check after pack) reads the module again.
|
|
438
|
+
mod = await import(`${pathToFileURL(file).href}?pack=${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
439
|
+
} catch (error) {
|
|
440
|
+
throw new Error(`${path}: ${error.message}`);
|
|
441
|
+
}
|
|
442
|
+
let made = mod.default ?? mod.panes;
|
|
443
|
+
if (typeof made === "function") made = await made({ functionCanvas });
|
|
444
|
+
if (Array.isArray(made)) made = { panes: made };
|
|
445
|
+
if (!made || typeof made !== "object" || !Array.isArray(made.panes)) throw new Error(`${path} must export (as default) the panes: a list, a { panes, examples } object, or a function that returns one.`);
|
|
446
|
+
if (made.examples !== undefined && !Array.isArray(made.examples)) throw new Error(`${path}: examples must be a list of canvases.`);
|
|
447
|
+
return { panes: made.panes, examples: made.examples ?? [], ...(made.module !== undefined ? { module: made.module } : {}) };
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** A pane entry (from the manifest, or made by a generator) as a package pane, its canvas read and checked. */
|
|
451
|
+
function paneEntry(meta, { canvas, tests }, icon, fallbackId) {
|
|
452
|
+
return {
|
|
453
|
+
id: meta.id ?? fallbackId,
|
|
454
|
+
title: meta.title ?? (canvas.name || fallbackId),
|
|
455
|
+
...(meta.description !== undefined ? { description: meta.description } : {}),
|
|
456
|
+
...(icon !== undefined ? { icon: icon.trim() } : {}),
|
|
457
|
+
canvas,
|
|
458
|
+
...((meta.tests ?? tests)?.length ? { tests: meta.tests ?? tests } : {}),
|
|
459
|
+
...(meta.hosts !== undefined ? { hosts: meta.hosts } : {}),
|
|
460
|
+
...(meta.deprecated !== undefined ? { deprecated: meta.deprecated } : {}),
|
|
461
|
+
...Object.fromEntries(Object.entries(meta).filter(([k]) => !["id", "title", "description", "tests", "hosts", "deprecated"].includes(k))),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const idFromFile = (path) => basename(path).replace(CANVAS_EXT, "").replace(/\.[^.]+$/, "").replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^[^A-Za-z0-9]+/, "").slice(0, 64);
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Build a package from a folder (see PKG_HELP, "pack"): `{ data, text, output, notes }`. `data` is
|
|
469
|
+
* checked like any package (checkPackage) and `text` is what pack writes: JSON, `$schema` first, and
|
|
470
|
+
* the same bytes for the same sources.
|
|
471
|
+
*/
|
|
472
|
+
export async function packFolder(folder, { output } = {}) {
|
|
473
|
+
const notes = [];
|
|
474
|
+
const note = (n) => notes.includes(n) || notes.push(n);
|
|
475
|
+
const npm = await npmManifest(folder);
|
|
476
|
+
let manifest = {};
|
|
477
|
+
let manifestName;
|
|
478
|
+
for (const name of MANIFESTS) {
|
|
479
|
+
const path = join(folder, name);
|
|
480
|
+
const text = await readFile(path, "utf8").catch(() => undefined);
|
|
481
|
+
if (text === undefined) continue;
|
|
482
|
+
manifestName = name;
|
|
483
|
+
try {
|
|
484
|
+
manifest = name.endsWith(".json") ? JSON.parse(text) : readYaml(text, name);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
throw new Error(`${name}: ${error.message}`);
|
|
487
|
+
}
|
|
488
|
+
if (!manifest || typeof manifest !== "object" || Array.isArray(manifest)) throw new Error(`${name} must be an object (panes, examples, assets, requires, …).`);
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
const field = (key, npmKey = key) => {
|
|
492
|
+
const fromNpm = npm?.data?.[npmKey];
|
|
493
|
+
const own = manifest[key];
|
|
494
|
+
if (fromNpm !== undefined && own !== undefined && fromNpm !== own) throw new Error(`package.json's ${npmKey} (${JSON.stringify(fromNpm)}) and ${manifestName}'s ${key} (${JSON.stringify(own)}) differ: give it in one place.`);
|
|
495
|
+
return own ?? fromNpm;
|
|
496
|
+
};
|
|
497
|
+
const name = field("name");
|
|
498
|
+
const packageVersion = field("packageVersion", "version");
|
|
499
|
+
if (name === undefined) throw new Error(`${folder} has no package name: give it in package.json ("name"), or in mallory-package.yaml.`);
|
|
500
|
+
if (packageVersion === undefined) throw new Error(`${folder} has no version: give it in package.json ("version"), or as packageVersion in mallory-package.yaml.`);
|
|
501
|
+
|
|
502
|
+
// A generator module makes panes (and examples) from code (#726).
|
|
503
|
+
const generated = manifest.generate !== undefined ? await runGenerator(folder, manifest.generate, manifestName) : undefined;
|
|
504
|
+
// Panes: the manifest's list, else every canvas in panes/ (none to scan when a generator makes them).
|
|
505
|
+
const paneSpecs = manifest.panes ?? (generated ? [] : (await canvasFiles(join(folder, "panes"))).map((path) => ({ canvas: relative(folder, path) })));
|
|
506
|
+
if (!Array.isArray(paneSpecs)) throw new Error(`${manifestName}'s panes must be a list.`);
|
|
507
|
+
const panes = [];
|
|
508
|
+
for (const [i, spec] of paneSpecs.entries()) {
|
|
509
|
+
const where = `${manifestName ?? "panes/"} pane ${i + 1}`;
|
|
510
|
+
if (!spec || typeof spec !== "object" || Array.isArray(spec)) throw new Error(`${where} must be an object with a "canvas" (a file).`);
|
|
511
|
+
const { canvas: canvasPath, icon, ...meta } = spec;
|
|
512
|
+
const { canvas, tests } = await readCanvas(inside(folder, canvasPath, `${where}'s canvas`), note);
|
|
513
|
+
let iconText = icon;
|
|
514
|
+
if (typeof icon === "string" && !icon.trim().startsWith("<")) iconText = await readFile(inside(folder, icon, `${where}'s icon`), "utf8");
|
|
515
|
+
panes.push(paneEntry(meta, { canvas, tests }, iconText, idFromFile(canvasPath)));
|
|
516
|
+
}
|
|
517
|
+
for (const [i, spec] of (generated?.panes ?? []).entries()) {
|
|
518
|
+
const where = `${manifest.generate} pane ${i + 1}`;
|
|
519
|
+
if (!spec || typeof spec !== "object" || Array.isArray(spec)) throw new Error(`${where} must be an object with an "id" and a "canvas".`);
|
|
520
|
+
const { canvas: source, icon, ...meta } = spec;
|
|
521
|
+
if (typeof meta.id !== "string") throw new Error(`${where} needs an "id" (a generated pane has no file to name it).`);
|
|
522
|
+
if (!source || (typeof source !== "object" && typeof source !== "string")) throw new Error(`${where} ("${meta.id}") needs a "canvas": a canvas object, or its text.`);
|
|
523
|
+
let iconText = icon;
|
|
524
|
+
if (typeof icon === "string" && !icon.trim().startsWith("<")) iconText = await readFile(inside(folder, icon, `${where}'s icon`), "utf8");
|
|
525
|
+
panes.push(paneEntry(meta, canvasFrom(source, `${manifest.generate} (${meta.id})`, note), iconText, meta.id));
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
const exampleSpecs = manifest.examples ?? (await canvasFiles(join(folder, "examples"))).map((path) => relative(folder, path));
|
|
529
|
+
if (!Array.isArray(exampleSpecs)) throw new Error(`${manifestName}'s examples must be a list of canvas files.`);
|
|
530
|
+
const examples = [];
|
|
531
|
+
for (const path of exampleSpecs) {
|
|
532
|
+
const { canvas, tests } = await readCanvas(inside(folder, path, "an example"), note);
|
|
533
|
+
examples.push({ ...canvas, ...(tests?.length ? { tests } : {}) });
|
|
534
|
+
}
|
|
535
|
+
for (const [i, source] of (generated?.examples ?? []).entries()) {
|
|
536
|
+
const { canvas, tests } = canvasFrom(source, `${manifest.generate} example ${i + 1}`, note);
|
|
537
|
+
examples.push({ ...canvas, ...(tests?.length ? { tests } : {}) });
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
let assetSpecs = manifest.assets;
|
|
541
|
+
if (assetSpecs === undefined && (await isDir(join(folder, "assets")))) assetSpecs = (await readdir(join(folder, "assets"))).filter((n) => !n.startsWith(".")).sort().map((n) => ({ file: `assets/${n}` }));
|
|
542
|
+
if (assetSpecs !== undefined && !Array.isArray(assetSpecs)) throw new Error(`${manifestName}'s assets must be a list of { name?, type?, file }.`);
|
|
543
|
+
const assets = [];
|
|
544
|
+
for (const spec of assetSpecs ?? []) {
|
|
545
|
+
if (!spec || typeof spec !== "object" || typeof spec.file !== "string") throw new Error(`An asset in ${manifestName} needs a "file".`);
|
|
546
|
+
const bytes = new Uint8Array(await readFile(inside(folder, spec.file, "an asset's file")));
|
|
547
|
+
const type = spec.type ?? typeFromName(spec.file);
|
|
548
|
+
if (!type) throw new Error(`The asset ${spec.file} needs a "type" (mallory can't tell its media type from the name).`);
|
|
549
|
+
assets.push({ name: spec.name ?? basename(spec.file).replace(/\.[^.]+$/, ""), type, data: toBase64(bytes), size: bytes.length, integrity: await sha256Of(bytes) });
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// The shared module (#723, src/packages/module.js): `module: lib/bundle.js` (or { file, name }) in the manifest, or a generator's
|
|
553
|
+
// `module` (its text, or { source, name }). One self-contained ES module; pack writes its integrity and requires the pkg helper.
|
|
554
|
+
let module;
|
|
555
|
+
if (manifest.module !== undefined && generated?.module !== undefined) throw new Error(`${manifestName} names a module and ${manifest.generate} makes one: give it in one place.`);
|
|
556
|
+
if (manifest.module !== undefined) {
|
|
557
|
+
const spec = typeof manifest.module === "string" ? { file: manifest.module } : manifest.module;
|
|
558
|
+
if (!spec || typeof spec !== "object" || typeof spec.file !== "string") throw new Error(`${manifestName}'s module must be a file (lib/module.js) or { file, name? }.`);
|
|
559
|
+
module = { name: spec.name ?? basename(spec.file).replace(/\.[^.]+$/, "").replace(/[^\w.-]+/g, "-"), source: await readFile(inside(folder, spec.file, `${manifestName}'s module`), "utf8") };
|
|
560
|
+
} else if (generated?.module !== undefined) {
|
|
561
|
+
const made = typeof generated.module === "string" ? { source: generated.module } : generated.module;
|
|
562
|
+
if (!made || typeof made !== "object" || typeof made.source !== "string") throw new Error(`${manifest.generate}: module must be the module's text, or { source, name? }.`);
|
|
563
|
+
module = { name: made.name ?? "module", source: made.source };
|
|
564
|
+
}
|
|
565
|
+
if (module) module.integrity = await moduleIntegrity(module.source);
|
|
566
|
+
let requires = manifest.requires;
|
|
567
|
+
if (module) {
|
|
568
|
+
// Said for it: a mallory without shared modules refuses the package instead of running its panes without one.
|
|
569
|
+
if (requires !== undefined && (!requires || typeof requires !== "object" || Array.isArray(requires))) throw new Error(`${manifestName}'s requires must be an object.`);
|
|
570
|
+
const helpers = requires?.helpers;
|
|
571
|
+
const asObject = Array.isArray(helpers) ? Object.fromEntries(helpers.map((h) => [h, 1])) : { ...(helpers ?? {}) };
|
|
572
|
+
if (!Object.hasOwn(asObject, MODULE_HELPER)) requires = { ...requires, helpers: { ...asObject, [MODULE_HELPER]: 1 } };
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
const description = field("description");
|
|
576
|
+
const license = field("license");
|
|
577
|
+
const data = {
|
|
578
|
+
$schema: PACKAGE_SCHEMA_URL,
|
|
579
|
+
format: PACKAGE_FORMAT,
|
|
580
|
+
version: PACKAGE_VERSION,
|
|
581
|
+
name,
|
|
582
|
+
packageVersion,
|
|
583
|
+
...(description ? { description } : {}),
|
|
584
|
+
...(license ? { license } : {}),
|
|
585
|
+
...(requires !== undefined ? { requires } : {}),
|
|
586
|
+
...(manifest.deprecated !== undefined ? { deprecated: manifest.deprecated } : {}),
|
|
587
|
+
panes,
|
|
588
|
+
...(examples.length ? { examples } : {}),
|
|
589
|
+
...(assets.length ? { assets } : {}),
|
|
590
|
+
...(module ? { module } : {}),
|
|
591
|
+
};
|
|
592
|
+
checkPackage(data);
|
|
593
|
+
const field2 = npm?.data?.mallory;
|
|
594
|
+
const out = output ? resolve(output) : typeof field2 === "string" ? inside(folder, field2, `package.json's "mallory" field`) : join(folder, packageFileName(name));
|
|
595
|
+
// A signature the file has stays while it covers exactly what this pack writes (a rebuild of the same sources); any change drops it.
|
|
596
|
+
const signature = await keptSignature(out, data);
|
|
597
|
+
if (signature) data.signature = signature;
|
|
598
|
+
else if (await hadSignature(out)) note(`${basename(out)} was signed, and its contents changed: sign it again (mallory pkg sign)`);
|
|
599
|
+
return { data, text: `${JSON.stringify(data, null, 2)}\n`, output: out, notes };
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** The data a package file holds, or undefined (no file, or not one). */
|
|
603
|
+
async function existingData(path) {
|
|
604
|
+
try {
|
|
605
|
+
return readPackageData(await readFile(path, "utf8"));
|
|
606
|
+
} catch {
|
|
607
|
+
return undefined;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
const hadSignature = async (path) => (await existingData(path))?.signature !== undefined;
|
|
611
|
+
const sameBytes = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
|
|
612
|
+
|
|
613
|
+
/** The signature of the file at `path` when its signed contents are `data`'s, else undefined. */
|
|
614
|
+
async function keptSignature(path, data) {
|
|
615
|
+
const old = await existingData(path);
|
|
616
|
+
if (!old?.signature) return undefined;
|
|
617
|
+
try {
|
|
618
|
+
return sameBytes(signingPayload(old), signingPayload(data)) ? old.signature : undefined;
|
|
619
|
+
} catch {
|
|
620
|
+
return undefined;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// ── new ────────────────────────────────────────────────────────────────────
|
|
625
|
+
|
|
626
|
+
const ICON = '<svg viewBox="0 0 16 16"><path d="M3 4h10M3 8h7M3 12h9" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linecap="round"/></svg>';
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* The starter's function canvas, in the shape we recommend (#725): input panes for its parameters
|
|
630
|
+
* (`name`, text; `others`, a JSON list with its `valueType` declared, so the signature says
|
|
631
|
+
* `array<string>` instead of `any`) and one leaf eval pane named `result` with named outputs
|
|
632
|
+
* (`greeting`, `count`). A placed pane's value is that leaf's, so people wire `greet.greeting`, and
|
|
633
|
+
* the tests and the signature use the same names (`greeting`, not `result.greeting`).
|
|
634
|
+
*/
|
|
635
|
+
function starterCanvas() {
|
|
636
|
+
return {
|
|
637
|
+
format: "mallory-canvas",
|
|
638
|
+
version: 3,
|
|
639
|
+
name: "Greet",
|
|
640
|
+
viewport: { x: 60, y: 80, zoom: 1 },
|
|
641
|
+
function: true,
|
|
642
|
+
tests: [
|
|
643
|
+
{ name: "greets by name", inputs: { name: "Ada" }, expect: { greeting: "Hello, Ada!", count: 1 } },
|
|
644
|
+
{ name: "greets the world by default", expect: { greeting: "Hello, world!" } },
|
|
645
|
+
{ name: "greets everyone", inputs: { name: "Ada", others: ["Grace", "Alan"] }, expect: { greeting: "Hello, Ada, Grace and Alan!", count: 3 } },
|
|
646
|
+
],
|
|
647
|
+
panes: [
|
|
648
|
+
{ id: "name", type: "input", name: "name", rect: { x: 0, y: 0, width: 240 }, inputs: [], widget: { kind: "text", value: "world" }, description: "Who to greet." },
|
|
649
|
+
{ id: "others", type: "input", name: "others", rect: { x: 0, y: 120, width: 240 }, inputs: [], widget: { kind: "json", value: "[]" }, valueType: "array<string>", description: "More names to greet." },
|
|
650
|
+
{
|
|
651
|
+
id: "result",
|
|
652
|
+
type: "eval",
|
|
653
|
+
name: "result",
|
|
654
|
+
rect: { x: 320, y: 0, width: 320 },
|
|
655
|
+
inputs: [
|
|
656
|
+
{ name: "name", source: "name" },
|
|
657
|
+
{ name: "others", source: "others" },
|
|
658
|
+
],
|
|
659
|
+
mode: "function",
|
|
660
|
+
outputs: [
|
|
661
|
+
{ name: "greeting", type: "string", description: "The greeting." },
|
|
662
|
+
{ name: "count", type: "number", description: "How many people it greets." },
|
|
663
|
+
],
|
|
664
|
+
code: "const all = [name, ...others];\nconst list = all.length > 1 ? `${all.slice(0, -1).join(\", \")} and ${all.at(-1)}` : all[0];\nreturn { greeting: `Hello, ${list}!`, count: all.length };",
|
|
665
|
+
},
|
|
666
|
+
],
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/** The GitHub Actions workflow the starter carries (for the package's own repository). */
|
|
671
|
+
export const STARTER_WORKFLOW = `# Packs, checks and tests this pane package on every push and pull request.
|
|
672
|
+
name: mallory package
|
|
673
|
+
on:
|
|
674
|
+
push:
|
|
675
|
+
pull_request:
|
|
676
|
+
jobs:
|
|
677
|
+
package:
|
|
678
|
+
runs-on: ubuntu-latest
|
|
679
|
+
steps:
|
|
680
|
+
- uses: actions/checkout@v4
|
|
681
|
+
- uses: actions/setup-node@v4
|
|
682
|
+
with:
|
|
683
|
+
node-version: 22
|
|
684
|
+
# The mallory command line for package authors, from npm (@johnhenry/mallory-cli). Set the
|
|
685
|
+
# repository variable MALLORY_CLI to install another version or build (@johnhenry/mallory-cli@0.1.0,
|
|
686
|
+
# a tarball URL), or add it to devDependencies and run npm ci instead.
|
|
687
|
+
- name: Install the mallory command line
|
|
688
|
+
run: npm install --no-save --no-package-lock "\${MALLORY_CLI:-@johnhenry/mallory-cli}"
|
|
689
|
+
env:
|
|
690
|
+
MALLORY_CLI: \${{ vars.MALLORY_CLI }}
|
|
691
|
+
- name: The package file is up to date with its sources
|
|
692
|
+
run: npx mallory pkg pack . --check
|
|
693
|
+
- name: Check it as an install does
|
|
694
|
+
run: npx mallory pkg check . --strict
|
|
695
|
+
- name: Run every pane's tests
|
|
696
|
+
run: npx mallory pkg test . --reporter tap
|
|
697
|
+
`;
|
|
698
|
+
|
|
699
|
+
/** The files of a starter package named `name`: `{ folder name, files: { path: text } }` (the packed file is added by `new`). */
|
|
700
|
+
export function starterFiles(name, { description = "A pane package for mallory.", license = "MIT" } = {}) {
|
|
701
|
+
if (!isPackageNameValid(name)) throw new UsageError(`"${name}" isn't a package name (like @you/mallory-text: lower case letters, digits, - . and _)`);
|
|
702
|
+
const base = name.replace(/^@[^/]+\//, "");
|
|
703
|
+
const file = packageFileName(name);
|
|
704
|
+
const pkgJson = {
|
|
705
|
+
name,
|
|
706
|
+
version: "0.1.0",
|
|
707
|
+
description,
|
|
708
|
+
license,
|
|
709
|
+
keywords: [NPM_KEYWORD],
|
|
710
|
+
mallory: file,
|
|
711
|
+
files: [file, "README.md"],
|
|
712
|
+
scripts: { build: "mallory pkg pack .", check: "mallory pkg pack . --check && mallory pkg check . --strict", test: "mallory pkg test ." },
|
|
713
|
+
};
|
|
714
|
+
const manifest = `# The panes of ${name}, for mallory pkg pack (the name, version, description and licence are package.json's).
|
|
715
|
+
# Each pane is a function canvas: its input panes are its parameters (declare a json input's valueType),
|
|
716
|
+
# and one leaf pane named result, with named outputs, is its value (a placed pane's outputs, the tests' keys).
|
|
717
|
+
# Spec: docs/pane-package-spec.md in mallory; schema: ${PACKAGE_SCHEMA_URL}
|
|
718
|
+
panes:
|
|
719
|
+
- id: greet # keep ids stable: canvases find a pane by package name and id
|
|
720
|
+
title: Greet
|
|
721
|
+
description: Say hello to someone by name, and to others.
|
|
722
|
+
icon: '${ICON}'
|
|
723
|
+
canvas: panes/greet.mallory.yaml
|
|
724
|
+
hosts: [] # the hosts its code reaches: a hint for the review, never a permission
|
|
725
|
+
# requires: { helpers: [table], panes: [statechart] }
|
|
726
|
+
# examples: [ examples/hello.mallory.yaml ]
|
|
727
|
+
# assets: [ { name: pluck, file: assets/pluck.wav } ]
|
|
728
|
+
`;
|
|
729
|
+
const readme = `# ${name}
|
|
730
|
+
|
|
731
|
+
${description}
|
|
732
|
+
|
|
733
|
+
A [mallory](https://mallory.johnhenry.me) pane package: each pane is a function canvas that people insert as a linked subgraph pane. It is data only; every pane's code runs in mallory's sandbox under the canvas's network rules.
|
|
734
|
+
|
|
735
|
+
## Layout
|
|
736
|
+
|
|
737
|
+
- \`panes/*.mallory.yaml\`: one function canvas per pane, with its tests. Open one in mallory ("Open a canvas file…"), change it, and save it back with "Export as…" → Mallory YAML.
|
|
738
|
+
- \`mallory-package.yaml\`: each pane's id, title, description, icon and hosts, and the package's examples, assets and requirements.
|
|
739
|
+
- \`package.json\`: the name, version, description and licence; \`"mallory"\` names the package file and \`"keywords"\` has \`${NPM_KEYWORD}\`, which people search npm for.
|
|
740
|
+
- \`${file}\`: the package file, built from the rest. Commit it, and rebuild it after every change.
|
|
741
|
+
|
|
742
|
+
## Build, check, test
|
|
743
|
+
|
|
744
|
+
\`\`\`sh
|
|
745
|
+
mallory pkg pack . # build ${file}
|
|
746
|
+
mallory pkg check . --strict # check it as an install does
|
|
747
|
+
mallory pkg test . # run every pane's tests in an isolated sandbox
|
|
748
|
+
\`\`\`
|
|
749
|
+
|
|
750
|
+
\`.github/workflows/mallory-package.yml\` runs the same three on every push.
|
|
751
|
+
|
|
752
|
+
## Publish
|
|
753
|
+
|
|
754
|
+
Bump \`version\` in package.json for every change (it is the package's \`packageVersion\`), run \`mallory pkg pack .\`, then \`npm publish\`. People install it in mallory with "Install a pane package from npm or a URL…" and the name \`${name}\`.
|
|
755
|
+
`;
|
|
756
|
+
return {
|
|
757
|
+
folder: base,
|
|
758
|
+
file,
|
|
759
|
+
files: {
|
|
760
|
+
"package.json": `${JSON.stringify(pkgJson, null, 2)}\n`,
|
|
761
|
+
"mallory-package.yaml": manifest,
|
|
762
|
+
"panes/greet.mallory.yaml": exportCanvas(starterCanvas(), "yaml").text,
|
|
763
|
+
"README.md": readme,
|
|
764
|
+
".github/workflows/mallory-package.yml": STARTER_WORKFLOW,
|
|
765
|
+
".gitignore": "node_modules/\n",
|
|
766
|
+
},
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// ── main ───────────────────────────────────────────────────────────────────
|
|
771
|
+
|
|
772
|
+
/** Run `mallory pkg` (argv without "pkg"). Returns the exit code. */
|
|
773
|
+
export async function pkgMain(argv, { stdout = (t) => process.stdout.write(`${t}\n`), stderr = (t) => process.stderr.write(`${t}\n`), createSession, cwd = process.cwd(), until } = {}) {
|
|
774
|
+
let options;
|
|
775
|
+
try {
|
|
776
|
+
options = parsePkgArgs(argv);
|
|
777
|
+
} catch (error) {
|
|
778
|
+
if (!(error instanceof UsageError)) throw error;
|
|
779
|
+
stderr(`mallory pkg: ${error.message}\nRun mallory pkg --help for usage.`);
|
|
780
|
+
return 2;
|
|
781
|
+
}
|
|
782
|
+
if (options.help) {
|
|
783
|
+
stdout(PKG_HELP);
|
|
784
|
+
return 0;
|
|
785
|
+
}
|
|
786
|
+
const usage = (message) => (stderr(`mallory pkg ${options.command}: ${message}`), 2);
|
|
787
|
+
try {
|
|
788
|
+
if (options.command === "trust") return await trustCommand(options, { cwd, stdout });
|
|
789
|
+
if (options.command === "keygen") return await keygen(resolve(cwd, options.files[0]), { cwd, stdout });
|
|
790
|
+
} catch (error) {
|
|
791
|
+
if (error instanceof UsageError) return usage(error.message);
|
|
792
|
+
throw error;
|
|
793
|
+
}
|
|
794
|
+
const target = resolve(cwd, options.files[0]);
|
|
795
|
+
try {
|
|
796
|
+
if (options.command === "new") return await newPackage(options, { cwd, stdout, stderr });
|
|
797
|
+
if (options.command === "sign") return await signCommand(target, options, { cwd, stdout, stderr });
|
|
798
|
+
if (options.command === "serve") return await serveCommand(target, options, { cwd, stdout, stderr, until });
|
|
799
|
+
if (options.command === "pack") {
|
|
800
|
+
if (!(await isDir(target))) return usage(`${options.files[0]} isn't a folder`);
|
|
801
|
+
let packed;
|
|
802
|
+
try {
|
|
803
|
+
packed = await packFolder(target, { output: options.output && resolve(cwd, options.output) });
|
|
804
|
+
} catch (error) {
|
|
805
|
+
stderr(`mallory pkg pack: ${error.message}`);
|
|
806
|
+
return 1;
|
|
807
|
+
}
|
|
808
|
+
for (const n of packed.notes) stderr(`mallory pkg pack: ${n}`);
|
|
809
|
+
const shown = relative(cwd, packed.output) || packed.output;
|
|
810
|
+
if (options.check) {
|
|
811
|
+
const now = await readFile(packed.output, "utf8").catch(() => undefined);
|
|
812
|
+
if (now === packed.text) {
|
|
813
|
+
stdout(`✓ ${shown} is up to date.`);
|
|
814
|
+
return 0;
|
|
815
|
+
}
|
|
816
|
+
stderr(`✗ ${shown} ${now === undefined ? "doesn't exist" : "is out of date"}: run mallory pkg pack ${options.files[0]}`);
|
|
817
|
+
return 1;
|
|
818
|
+
}
|
|
819
|
+
await writeFile(packed.output, packed.text);
|
|
820
|
+
stdout(`Wrote ${shown}: ${packed.data.name} ${packed.data.packageVersion}, ${packed.data.panes.length} pane${packed.data.panes.length === 1 ? "" : "s"}.`);
|
|
821
|
+
return 0;
|
|
822
|
+
}
|
|
823
|
+
let where;
|
|
824
|
+
let text;
|
|
825
|
+
try {
|
|
826
|
+
where = await locatePackage(target);
|
|
827
|
+
text = await readFile(where.file, "utf8");
|
|
828
|
+
} catch (error) {
|
|
829
|
+
return usage(error instanceof UsageError ? error.message : `can't read ${options.files[0]}: ${error.code === "ENOENT" ? "no such file" : error.message}`);
|
|
830
|
+
}
|
|
831
|
+
if (options.command === "check") {
|
|
832
|
+
const report = await checkReport(text, { file: where.file, npm: where.npm, expectKey: options.expectKey });
|
|
833
|
+
// In a folder that packs, the package file must be what its sources make.
|
|
834
|
+
if (report.name && (await hasSources(where.folder))) {
|
|
835
|
+
try {
|
|
836
|
+
const packed = await packFolder(where.folder);
|
|
837
|
+
if (resolve(packed.output) === resolve(where.file) && packed.text !== text) report.problems.push(`${basename(where.file)} is out of date with its sources: run mallory pkg pack`);
|
|
838
|
+
} catch (error) {
|
|
839
|
+
report.problems.push(`its sources don't pack: ${error.message}`);
|
|
840
|
+
}
|
|
841
|
+
report.ok = report.problems.length === 0;
|
|
842
|
+
}
|
|
843
|
+
stdout(options.json ? JSON.stringify(report, null, 2) : formatCheck(report, { strict: options.strict }));
|
|
844
|
+
return passed(report, options.strict) ? 0 : 1;
|
|
845
|
+
}
|
|
846
|
+
// test
|
|
847
|
+
let pkg;
|
|
848
|
+
try {
|
|
849
|
+
pkg = parsePackage(text).pkg;
|
|
850
|
+
} catch (error) {
|
|
851
|
+
stderr(`mallory pkg test: ${where.file}: ${error.message}`);
|
|
852
|
+
return 1;
|
|
853
|
+
}
|
|
854
|
+
if (!pkg.panes.some((p) => p.tests?.length)) return usage(`${pkg.name} has no tests`);
|
|
855
|
+
const declared = packageHosts(pkg);
|
|
856
|
+
const stray = options.allowHosts.filter((h) => !declared.includes(h));
|
|
857
|
+
if (stray.length) return usage(`--allow-host ${stray.join(", ")}: the package's panes don't list ${stray.length === 1 ? "that host" : "those hosts"} in "hosts" (${declared.length ? declared.join(", ") : "they list none"}); as in the install review, only a host a pane says it uses can be let through`);
|
|
858
|
+
const make = createSession ?? (await import("./node.js")).createNodeSession;
|
|
859
|
+
// The review's sandbox: no variables, no API keys, and only the hosts given for this run.
|
|
860
|
+
const session = make({ timeoutMs: options.timeoutMs, allowHosts: options.allowHosts, env: {}, secrets: new Map() });
|
|
861
|
+
let report;
|
|
862
|
+
try {
|
|
863
|
+
report = await runPackageTests(pkg, session);
|
|
864
|
+
} finally {
|
|
865
|
+
await session.dispose?.();
|
|
866
|
+
}
|
|
867
|
+
stdout(options.reporter ? formatWith(options.reporter, report, { name: pkg.name }) : options.json ? JSON.stringify(report, null, 2) : `${pkg.name} ${pkg.packageVersion}\n${formatReport(report)}`);
|
|
868
|
+
return report.pass ? 0 : 1;
|
|
869
|
+
} catch (error) {
|
|
870
|
+
if (error instanceof UsageError) return usage(error.message);
|
|
871
|
+
throw error;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
async function newPackage(options, { cwd, stdout }) {
|
|
876
|
+
const starter = starterFiles(options.files[0], { ...(options.description ? { description: options.description } : {}), ...(options.license ? { license: options.license } : {}) });
|
|
877
|
+
const folder = resolve(cwd, options.dir ?? starter.folder);
|
|
878
|
+
if ((await stat(folder).catch(() => null)) && (!(await isDir(folder)) || (await readdir(folder)).length)) throw new UsageError(`${relative(cwd, folder) || folder} exists and isn't empty: pick another --dir`);
|
|
879
|
+
for (const [path, text] of Object.entries(starter.files)) {
|
|
880
|
+
await mkdir(dirname(join(folder, path)), { recursive: true });
|
|
881
|
+
await writeFile(join(folder, path), text);
|
|
882
|
+
}
|
|
883
|
+
const packed = await packFolder(folder);
|
|
884
|
+
await writeFile(packed.output, packed.text);
|
|
885
|
+
const shown = relative(cwd, folder) || ".";
|
|
886
|
+
stdout(
|
|
887
|
+
[
|
|
888
|
+
`Wrote ${options.files[0]} in ${shown}/: ${Object.keys(starter.files).join(", ")}, and ${starter.file} (packed).`,
|
|
889
|
+
"",
|
|
890
|
+
"Next:",
|
|
891
|
+
` cd ${shown}`,
|
|
892
|
+
" mallory pkg check . --strict # it passes as it is",
|
|
893
|
+
" mallory pkg test . # so do its tests",
|
|
894
|
+
" # edit panes/greet.mallory.yaml (or open it in mallory), then mallory pkg pack .",
|
|
895
|
+
].join("\n"),
|
|
896
|
+
);
|
|
897
|
+
return 0;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// ── serve (#726) ───────────────────────────────────────────────────────────
|
|
901
|
+
|
|
902
|
+
/** Until Ctrl+C (or SIGTERM): how `serve` waits when nothing else says when to stop. */
|
|
903
|
+
const untilSignal = () => new Promise((done) => {
|
|
904
|
+
const stop = () => {
|
|
905
|
+
process.off("SIGINT", stop);
|
|
906
|
+
process.off("SIGTERM", stop);
|
|
907
|
+
done();
|
|
908
|
+
};
|
|
909
|
+
process.on("SIGINT", stop);
|
|
910
|
+
process.on("SIGTERM", stop);
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
async function serveCommand(target, options, { cwd, stdout, stderr, until = untilSignal }) {
|
|
914
|
+
const { servePackage, installByName, SERVE_PORT } = await import("./pkg-serve.js");
|
|
915
|
+
let served;
|
|
916
|
+
try {
|
|
917
|
+
served = await servePackage(target, { port: options.port ?? (options.check ? 0 : SERVE_PORT), host: options.host ?? "127.0.0.1" });
|
|
918
|
+
} catch (error) {
|
|
919
|
+
if (error.code === "EADDRINUSE") throw new UsageError(`port ${options.port ?? SERVE_PORT} is in use: pick another with --port (0 for any free one)`);
|
|
920
|
+
throw new UsageError(error.message);
|
|
921
|
+
}
|
|
922
|
+
const { name, version } = served.manifest;
|
|
923
|
+
try {
|
|
924
|
+
const sourcesText = `${JSON.stringify(served.sources, null, 2)}\n`;
|
|
925
|
+
if (options.sourcesFile) await writeFile(resolve(cwd, options.sourcesFile), sourcesText);
|
|
926
|
+
if (options.check) {
|
|
927
|
+
let got;
|
|
928
|
+
try {
|
|
929
|
+
got = await installByName(name, served.sources);
|
|
930
|
+
} catch (error) {
|
|
931
|
+
stderr(`✗ installing ${name} by name from the stand-in failed: ${error.message}`);
|
|
932
|
+
return 1;
|
|
933
|
+
}
|
|
934
|
+
const report = await checkReport(got.text, { file: got.url });
|
|
935
|
+
for (const n of got.notes) report.warnings.push(n);
|
|
936
|
+
if (got.version !== version) report.problems.push(`the install got version ${got.version}, not ${version}`);
|
|
937
|
+
report.ok = report.problems.length === 0;
|
|
938
|
+
stdout(`Installed ${name} by name from ${got.url} (as the page does, through a package source):\n${formatCheck(report)}`);
|
|
939
|
+
return report.ok ? 0 : 1;
|
|
940
|
+
}
|
|
941
|
+
stdout(
|
|
942
|
+
[
|
|
943
|
+
`Serving ${name} ${version} (from the ${served.from} ${relative(cwd, target) || target}: ${served.files.join(", ")}) at ${served.url}`,
|
|
944
|
+
"",
|
|
945
|
+
"To install it in mallory by name, as people will from npm:",
|
|
946
|
+
` 1. ⚙ settings → package sources → "Import JSON…": ${options.sourcesFile ? relative(cwd, resolve(cwd, options.sourcesFile)) : "the JSON below, saved to a file (or pass --sources file)"}. It sends ${name} here and leaves every other package as it was. Save.`,
|
|
947
|
+
` 2. ⚙ settings → Network: turn on "Allow local network" (${new URL(served.url).hostname} is this computer).`,
|
|
948
|
+
` 3. "Install a pane package from npm or a URL…" → ${name}. Allow ${new URL(served.url).hostname} when asked, then review it and "run its tests".`,
|
|
949
|
+
" Remove the route afterwards (or Reset to defaults) to install from npm again.",
|
|
950
|
+
` Headless: mallory pkg serve ${options.files[0]} --check installs it by name here and prints the review.`,
|
|
951
|
+
...(options.sourcesFile ? [] : ["", sourcesText.trimEnd()]),
|
|
952
|
+
"",
|
|
953
|
+
"Ctrl+C stops it.",
|
|
954
|
+
].join("\n"),
|
|
955
|
+
);
|
|
956
|
+
await until(served);
|
|
957
|
+
return 0;
|
|
958
|
+
} finally {
|
|
959
|
+
await served.close();
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// ── signing (#664) ─────────────────────────────────────────────────────────
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* A private key file as a signer: `{ sign(bytes), publicKey (32 bytes), fingerprint }`. PKCS#8 PEM or DER, or a JWK.
|
|
967
|
+
* The key stays in this process's memory: nothing here writes or prints it, and an error never quotes the file.
|
|
968
|
+
*/
|
|
969
|
+
export async function loadSigningKey(path) {
|
|
970
|
+
let buf;
|
|
971
|
+
try {
|
|
972
|
+
buf = await readFile(path);
|
|
973
|
+
} catch (error) {
|
|
974
|
+
throw new UsageError(`can't read the key ${path}: ${error.code === "ENOENT" ? "no such file" : error.message}`);
|
|
975
|
+
}
|
|
976
|
+
const text = buf.toString("utf8");
|
|
977
|
+
let key;
|
|
978
|
+
try {
|
|
979
|
+
if (/^\s*\{/.test(text)) key = createPrivateKey({ key: JSON.parse(text), format: "jwk" });
|
|
980
|
+
else if (text.includes("-----BEGIN")) key = createPrivateKey(text);
|
|
981
|
+
else key = createPrivateKey({ key: buf, format: "der", type: "pkcs8" });
|
|
982
|
+
} catch {
|
|
983
|
+
throw new UsageError(`${path} isn't a private key (PKCS#8 PEM or DER, or a JWK with "d")`);
|
|
984
|
+
}
|
|
985
|
+
if (key.asymmetricKeyType !== "ed25519") throw new UsageError(`${path} is ${key.asymmetricKeyType ? `an ${key.asymmetricKeyType}` : "another kind of"} key: pane packages are signed with Ed25519 (mallory pkg keygen makes one)`);
|
|
986
|
+
const x = createPublicKey(key).export({ format: "jwk" }).x;
|
|
987
|
+
const publicKey = fromB64(x.replace(/-/g, "+").replace(/_/g, "/").padEnd(44, "="));
|
|
988
|
+
return { sign: (bytes) => nodeSign(null, bytes, key), publicKey, fingerprint: await fingerprintOf(publicKey) };
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** Is a key file readable by others than its owner (where the platform has modes)? */
|
|
992
|
+
const looseMode = async (path) => process.platform !== "win32" && ((await stat(path).catch(() => null))?.mode ?? 0) & 0o077;
|
|
993
|
+
|
|
994
|
+
/** A YAML package's text with its top-level `signature:` block (if any) taken out. */
|
|
995
|
+
function withoutYamlSignature(text) {
|
|
996
|
+
const lines = text.split("\n");
|
|
997
|
+
const at = lines.findIndex((l) => /^signature\s*:/.test(l));
|
|
998
|
+
if (at < 0) return text;
|
|
999
|
+
let end = at + 1;
|
|
1000
|
+
while (end < lines.length && (lines[end] === "" || /^\s/.test(lines[end]))) end++;
|
|
1001
|
+
return [...lines.slice(0, at), ...lines.slice(end)].join("\n");
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/** The text of a package signed with `signer`: JSON as pack writes it; YAML as it was, with a signature block at the end. */
|
|
1005
|
+
export async function signedText(text, signer) {
|
|
1006
|
+
parsePackage(text); // a package an install would refuse isn't signed
|
|
1007
|
+
const data = readPackageData(text);
|
|
1008
|
+
const signed = await signData(data, signer);
|
|
1009
|
+
if (/^\s*[[{]/.test(text)) return `${JSON.stringify(signed, null, 2)}\n`;
|
|
1010
|
+
const { alg, publicKey, value } = signed.signature;
|
|
1011
|
+
const body = withoutYamlSignature(text).replace(/\s*$/, "");
|
|
1012
|
+
return `${body}\nsignature:\n alg: ${alg}\n publicKey: "${publicKey}"\n value: "${value}"\n`;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
async function signCommand(target, options, { cwd, stdout, stderr }) {
|
|
1016
|
+
const where = await locatePackage(target);
|
|
1017
|
+
const keyPath = resolve(cwd, options.key);
|
|
1018
|
+
if (await looseMode(keyPath)) stderr(`mallory pkg sign: ${options.key} can be read by other users: chmod 600 it`);
|
|
1019
|
+
const signer = await loadSigningKey(keyPath);
|
|
1020
|
+
let text;
|
|
1021
|
+
try {
|
|
1022
|
+
text = await readFile(where.file, "utf8");
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
throw new UsageError(`can't read ${where.file}: ${error.code === "ENOENT" ? "no such file" : error.message}`);
|
|
1025
|
+
}
|
|
1026
|
+
let out;
|
|
1027
|
+
try {
|
|
1028
|
+
out = await signedText(text, signer);
|
|
1029
|
+
} catch (error) {
|
|
1030
|
+
stderr(`mallory pkg sign: ${where.file}: ${error.message}`);
|
|
1031
|
+
return 1;
|
|
1032
|
+
}
|
|
1033
|
+
// What was written must check as signed by this key, or nothing is written.
|
|
1034
|
+
const check = await packageSignature(out);
|
|
1035
|
+
if (check.state !== "signed" || check.fingerprint !== signer.fingerprint) {
|
|
1036
|
+
stderr(`mallory pkg sign: the signed copy doesn't check (${check.reason ?? check.state}): nothing written`);
|
|
1037
|
+
return 1;
|
|
1038
|
+
}
|
|
1039
|
+
const dest = options.output ? resolve(cwd, options.output) : where.file;
|
|
1040
|
+
await writeFile(dest, out);
|
|
1041
|
+
const { pkg } = parsePackage(out);
|
|
1042
|
+
stdout(`Signed ${pkg.name} ${pkg.packageVersion} with ${signer.fingerprint}: wrote ${relative(cwd, dest) || dest}.`);
|
|
1043
|
+
return 0;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
async function keygen(path, { cwd, stdout }) {
|
|
1047
|
+
const jwk = /\.(jwk|json)$/i.test(path);
|
|
1048
|
+
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
|
|
1049
|
+
const body = jwk ? `${JSON.stringify(privateKey.export({ format: "jwk" }), null, 2)}\n` : privateKey.export({ type: "pkcs8", format: "pem" });
|
|
1050
|
+
let handle;
|
|
1051
|
+
try {
|
|
1052
|
+
handle = await openFile(path, "wx", 0o600); // never over an existing file, readable by its owner only
|
|
1053
|
+
} catch (error) {
|
|
1054
|
+
throw new UsageError(error.code === "EEXIST" ? `${relative(cwd, path) || path} exists: keygen never overwrites a key` : `can't write ${path}: ${error.message}`);
|
|
1055
|
+
}
|
|
1056
|
+
try {
|
|
1057
|
+
await handle.writeFile(body);
|
|
1058
|
+
} finally {
|
|
1059
|
+
await handle.close();
|
|
1060
|
+
}
|
|
1061
|
+
const raw = fromB64(publicKey.export({ format: "jwk" }).x.replace(/-/g, "+").replace(/_/g, "/").padEnd(44, "="));
|
|
1062
|
+
const fingerprint = await fingerprintOf(raw);
|
|
1063
|
+
stdout(
|
|
1064
|
+
[
|
|
1065
|
+
`Wrote a private Ed25519 key to ${relative(cwd, path) || path} (readable by you only). Keep it out of the package and out of git.`,
|
|
1066
|
+
` fingerprint ${fingerprint}`,
|
|
1067
|
+
` public key ${Buffer.from(raw).toString("base64")}`,
|
|
1068
|
+
"",
|
|
1069
|
+
"Publish the fingerprint where people can check it (your README, website or profile): the install review shows it.",
|
|
1070
|
+
`Sign with: mallory pkg sign <package> --key ${relative(cwd, path) || path}`,
|
|
1071
|
+
].join("\n"),
|
|
1072
|
+
);
|
|
1073
|
+
return 0;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
async function trustCommand(options, { cwd, stdout }) {
|
|
1077
|
+
const name = options.files[0];
|
|
1078
|
+
if (name !== undefined && !isPackageNameValid(name)) throw new UsageError(`"${name}" isn't a package name`);
|
|
1079
|
+
let trust;
|
|
1080
|
+
try {
|
|
1081
|
+
trust = await openTrustFile(resolve(cwd, options.trustFile));
|
|
1082
|
+
} catch (error) {
|
|
1083
|
+
throw new UsageError(error.message);
|
|
1084
|
+
}
|
|
1085
|
+
if (options.pin) {
|
|
1086
|
+
const was = trust.pins.get(name);
|
|
1087
|
+
trust.pins.set(name, { fingerprint: options.pin });
|
|
1088
|
+
await trust.save();
|
|
1089
|
+
stdout(`${name} is pinned to ${options.pin}${was && was.fingerprint !== options.pin ? ` (was ${was.fingerprint})` : ""}.`);
|
|
1090
|
+
return 0;
|
|
1091
|
+
}
|
|
1092
|
+
if (options.forget) {
|
|
1093
|
+
const was = trust.pins.get(name);
|
|
1094
|
+
trust.pins.forget(name);
|
|
1095
|
+
await trust.save();
|
|
1096
|
+
stdout(was ? `Forgot the key pinned for ${name} (${was.fingerprint}): the next signed copy pins its key.` : `${name} had no pinned key.`);
|
|
1097
|
+
return 0;
|
|
1098
|
+
}
|
|
1099
|
+
const list = trust.pins.list().filter((p) => name === undefined || p.name === name);
|
|
1100
|
+
if (options.json) stdout(JSON.stringify(list, null, 2));
|
|
1101
|
+
else stdout(list.length ? list.map((p) => `${p.name} ${p.fingerprint}${p.pinned ? ` (pinned ${new Date(p.pinned).toISOString().slice(0, 10)})` : ""}`).join("\n") : name ? `${name} has no pinned key.` : "No keys are pinned.");
|
|
1102
|
+
return 0;
|
|
1103
|
+
}
|