harnery 0.0.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +84 -2
- package/bin/agent-coord +42 -0
- package/bin/agent-hook +44 -0
- package/bin/harn +40 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/commander.d.ts +128 -0
- package/dist/commander.d.ts.map +1 -0
- package/dist/commander.js +126 -0
- package/dist/commands/agents.d.ts +18 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +3946 -0
- package/dist/commands/backup.d.ts +22 -0
- package/dist/commands/backup.d.ts.map +1 -0
- package/dist/commands/backup.js +262 -0
- package/dist/commands/browse-ai.d.ts +4 -0
- package/dist/commands/browse-ai.d.ts.map +1 -0
- package/dist/commands/browse-ai.js +156 -0
- package/dist/commands/browse.d.ts +4 -0
- package/dist/commands/browse.d.ts.map +1 -0
- package/dist/commands/browse.js +590 -0
- package/dist/commands/callers.d.ts +4 -0
- package/dist/commands/callers.d.ts.map +1 -0
- package/dist/commands/callers.js +276 -0
- package/dist/commands/completion.d.ts +17 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +158 -0
- package/dist/commands/config-get.d.ts +4 -0
- package/dist/commands/config-get.d.ts.map +1 -0
- package/dist/commands/config-get.js +131 -0
- package/dist/commands/context.d.ts +11 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +185 -0
- package/dist/commands/cookies.d.ts +4 -0
- package/dist/commands/cookies.d.ts.map +1 -0
- package/dist/commands/cookies.js +140 -0
- package/dist/commands/docs.d.ts +4 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +137 -0
- package/dist/commands/doctor.d.ts +25 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +200 -0
- package/dist/commands/edit-batch.d.ts +18 -0
- package/dist/commands/edit-batch.d.ts.map +1 -0
- package/dist/commands/edit-batch.js +172 -0
- package/dist/commands/eml.d.ts +4 -0
- package/dist/commands/eml.d.ts.map +1 -0
- package/dist/commands/eml.js +428 -0
- package/dist/commands/env.d.ts +4 -0
- package/dist/commands/env.d.ts.map +1 -0
- package/dist/commands/env.js +201 -0
- package/dist/commands/fetch.d.ts +4 -0
- package/dist/commands/fetch.d.ts.map +1 -0
- package/dist/commands/fetch.js +99 -0
- package/dist/commands/file-history.d.ts +4 -0
- package/dist/commands/file-history.d.ts.map +1 -0
- package/dist/commands/file-history.js +152 -0
- package/dist/commands/grep.d.ts +4 -0
- package/dist/commands/grep.d.ts.map +1 -0
- package/dist/commands/grep.js +317 -0
- package/dist/commands/init.d.ts +82 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +288 -0
- package/dist/commands/outline.d.ts +4 -0
- package/dist/commands/outline.d.ts.map +1 -0
- package/dist/commands/outline.js +509 -0
- package/dist/commands/presence.d.ts +12 -0
- package/dist/commands/presence.d.ts.map +1 -0
- package/dist/commands/presence.js +123 -0
- package/dist/commands/read.d.ts +7 -0
- package/dist/commands/read.d.ts.map +1 -0
- package/dist/commands/read.js +46 -0
- package/dist/commands/scratch.d.ts +4 -0
- package/dist/commands/scratch.d.ts.map +1 -0
- package/dist/commands/scratch.js +426 -0
- package/dist/commands/session.d.ts +4 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +162 -0
- package/dist/commands/sync.d.ts +24 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +275 -0
- package/dist/commands/toc.d.ts +5 -0
- package/dist/commands/toc.d.ts.map +1 -0
- package/dist/commands/toc.js +153 -0
- package/dist/commands/tokens.d.ts +4 -0
- package/dist/commands/tokens.d.ts.map +1 -0
- package/dist/commands/tokens.js +48 -0
- package/dist/commands/tunnel.d.ts +4 -0
- package/dist/commands/tunnel.d.ts.map +1 -0
- package/dist/commands/tunnel.js +513 -0
- package/dist/commands/uninstall.d.ts +22 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +126 -0
- package/dist/commands/web.d.ts +4 -0
- package/dist/commands/web.d.ts.map +1 -0
- package/dist/commands/web.js +165 -0
- package/dist/core/agents/canonical-emit.d.ts +27 -0
- package/dist/core/agents/canonical-emit.d.ts.map +1 -0
- package/dist/core/agents/canonical-emit.js +72 -0
- package/dist/core/agents/cli-emit.d.ts +27 -0
- package/dist/core/agents/cli-emit.d.ts.map +1 -0
- package/dist/core/agents/cli-emit.js +57 -0
- package/dist/core/agents/cli.d.ts +10 -0
- package/dist/core/agents/cli.d.ts.map +1 -0
- package/dist/core/agents/cli.js +757 -0
- package/dist/core/agents/codex-replay.d.ts +29 -0
- package/dist/core/agents/codex-replay.d.ts.map +1 -0
- package/dist/core/agents/codex-replay.js +138 -0
- package/dist/core/agents/coord-client.d.ts +98 -0
- package/dist/core/agents/coord-client.d.ts.map +1 -0
- package/dist/core/agents/coord-client.js +212 -0
- package/dist/core/agents/events/consume.d.ts +59 -0
- package/dist/core/agents/events/consume.d.ts.map +1 -0
- package/dist/core/agents/events/consume.js +147 -0
- package/dist/core/agents/events/emit.d.ts +42 -0
- package/dist/core/agents/events/emit.d.ts.map +1 -0
- package/dist/core/agents/events/emit.js +70 -0
- package/dist/core/agents/events/ulid.d.ts +11 -0
- package/dist/core/agents/events/ulid.d.ts.map +1 -0
- package/dist/core/agents/events/ulid.js +47 -0
- package/dist/core/agents/index.d.ts +14 -0
- package/dist/core/agents/index.d.ts.map +1 -0
- package/dist/core/agents/index.js +13 -0
- package/dist/core/agents/paths.d.ts +6 -0
- package/dist/core/agents/paths.d.ts.map +1 -0
- package/dist/core/agents/paths.js +17 -0
- package/dist/core/agents/render/prompt-context.d.ts +43 -0
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -0
- package/dist/core/agents/render/prompt-context.js +335 -0
- package/dist/core/agents/render/session-context.d.ts +39 -0
- package/dist/core/agents/render/session-context.d.ts.map +1 -0
- package/dist/core/agents/render/session-context.js +283 -0
- package/dist/core/agents/rules/claim-conflict.d.ts +35 -0
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -0
- package/dist/core/agents/rules/claim-conflict.js +244 -0
- package/dist/core/agents/rules/commit-conflict.d.ts +59 -0
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -0
- package/dist/core/agents/rules/commit-conflict.js +244 -0
- package/dist/core/agents/rules/stop-hook.d.ts +44 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -0
- package/dist/core/agents/rules/stop-hook.js +161 -0
- package/dist/core/agents/session-events.d.ts +41 -0
- package/dist/core/agents/session-events.d.ts.map +1 -0
- package/dist/core/agents/session-events.js +205 -0
- package/dist/core/agents/state/activity-log.d.ts +18 -0
- package/dist/core/agents/state/activity-log.d.ts.map +1 -0
- package/dist/core/agents/state/activity-log.js +34 -0
- package/dist/core/agents/state/council.d.ts +39 -0
- package/dist/core/agents/state/council.d.ts.map +1 -0
- package/dist/core/agents/state/council.js +216 -0
- package/dist/core/agents/state/heartbeat-projector.d.ts +59 -0
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -0
- package/dist/core/agents/state/heartbeat-projector.js +436 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts +64 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -0
- package/dist/core/agents/state/heartbeat-writer.js +271 -0
- package/dist/core/agents/state/names.d.ts +35 -0
- package/dist/core/agents/state/names.d.ts.map +1 -0
- package/dist/core/agents/state/names.js +376 -0
- package/dist/core/agents/state/pidmap.d.ts +11 -0
- package/dist/core/agents/state/pidmap.d.ts.map +1 -0
- package/dist/core/agents/state/pidmap.js +32 -0
- package/dist/core/agents/state/scratch.d.ts +27 -0
- package/dist/core/agents/state/scratch.d.ts.map +1 -0
- package/dist/core/agents/state/scratch.js +90 -0
- package/dist/core/agents/state/shell-mutation.d.ts +17 -0
- package/dist/core/agents/state/shell-mutation.d.ts.map +1 -0
- package/dist/core/agents/state/shell-mutation.js +41 -0
- package/dist/core/agents/state/stale-sweep.d.ts +16 -0
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -0
- package/dist/core/agents/state/stale-sweep.js +166 -0
- package/dist/core/config.d.ts +29 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +108 -0
- package/dist/core/hooks/cli.d.ts +21 -0
- package/dist/core/hooks/cli.d.ts.map +1 -0
- package/dist/core/hooks/cli.js +1123 -0
- package/dist/core/hooks/effects/image-capture.d.ts +43 -0
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -0
- package/dist/core/hooks/effects/image-capture.js +288 -0
- package/dist/core/hooks/effects/index.d.ts +64 -0
- package/dist/core/hooks/effects/index.d.ts.map +1 -0
- package/dist/core/hooks/effects/index.js +197 -0
- package/dist/core/hooks/events/emit.d.ts +31 -0
- package/dist/core/hooks/events/emit.d.ts.map +1 -0
- package/dist/core/hooks/events/emit.js +89 -0
- package/dist/core/hooks/events/schema.d.ts +235 -0
- package/dist/core/hooks/events/schema.d.ts.map +1 -0
- package/dist/core/hooks/events/schema.js +12 -0
- package/dist/core/hooks/events/ulid.d.ts +10 -0
- package/dist/core/hooks/events/ulid.d.ts.map +1 -0
- package/dist/core/hooks/events/ulid.js +47 -0
- package/dist/core/hooks/harness/detect.d.ts +9 -0
- package/dist/core/hooks/harness/detect.d.ts.map +1 -0
- package/dist/core/hooks/harness/detect.js +29 -0
- package/dist/core/hooks/harness/events.d.ts +45 -0
- package/dist/core/hooks/harness/events.d.ts.map +1 -0
- package/dist/core/hooks/harness/events.js +71 -0
- package/dist/core/hooks/harness/output.d.ts +46 -0
- package/dist/core/hooks/harness/output.d.ts.map +1 -0
- package/dist/core/hooks/harness/output.js +87 -0
- package/dist/core/hooks/harness/parse.d.ts +67 -0
- package/dist/core/hooks/harness/parse.d.ts.map +1 -0
- package/dist/core/hooks/harness/parse.js +132 -0
- package/dist/core/hooks/index.d.ts +8 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +7 -0
- package/dist/core/hooks/resolve/anchor.d.ts +37 -0
- package/dist/core/hooks/resolve/anchor.d.ts.map +1 -0
- package/dist/core/hooks/resolve/anchor.js +48 -0
- package/dist/core/hooks/resolve/coord-root.d.ts +6 -0
- package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -0
- package/dist/core/hooks/resolve/coord-root.js +27 -0
- package/dist/core/hooks/resolve/intent.d.ts +33 -0
- package/dist/core/hooks/resolve/intent.d.ts.map +1 -0
- package/dist/core/hooks/resolve/intent.js +79 -0
- package/dist/core/hooks/resolve/owner.d.ts +42 -0
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -0
- package/dist/core/hooks/resolve/owner.js +140 -0
- package/dist/core/hooks/resolve/transcript.d.ts +26 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -0
- package/dist/core/hooks/resolve/transcript.js +73 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/lib/agent-browser/client.d.ts +99 -0
- package/dist/lib/agent-browser/client.d.ts.map +1 -0
- package/dist/lib/agent-browser/client.js +177 -0
- package/dist/lib/agent-browser/index.d.ts +2 -0
- package/dist/lib/agent-browser/index.d.ts.map +1 -0
- package/dist/lib/agent-browser/index.js +1 -0
- package/dist/lib/browser/client.d.ts +193 -0
- package/dist/lib/browser/client.d.ts.map +1 -0
- package/dist/lib/browser/client.js +325 -0
- package/dist/lib/browser/dev-overlay.d.ts +23 -0
- package/dist/lib/browser/dev-overlay.d.ts.map +1 -0
- package/dist/lib/browser/dev-overlay.js +153 -0
- package/dist/lib/browser/index.d.ts +5 -0
- package/dist/lib/browser/index.d.ts.map +1 -0
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/browser/layout.d.ts +79 -0
- package/dist/lib/browser/layout.d.ts.map +1 -0
- package/dist/lib/browser/layout.js +220 -0
- package/dist/lib/browser/visibility.d.ts +86 -0
- package/dist/lib/browser/visibility.d.ts.map +1 -0
- package/dist/lib/browser/visibility.js +333 -0
- package/dist/lib/browser/visual-diff.d.ts +38 -0
- package/dist/lib/browser/visual-diff.d.ts.map +1 -0
- package/dist/lib/browser/visual-diff.js +107 -0
- package/dist/lib/completion/bash.d.ts +25 -0
- package/dist/lib/completion/bash.d.ts.map +1 -0
- package/dist/lib/completion/bash.js +284 -0
- package/dist/lib/completion/fish.d.ts +16 -0
- package/dist/lib/completion/fish.d.ts.map +1 -0
- package/dist/lib/completion/fish.js +118 -0
- package/dist/lib/completion/index.d.ts +5 -0
- package/dist/lib/completion/index.d.ts.map +1 -0
- package/dist/lib/completion/index.js +4 -0
- package/dist/lib/completion/walk.d.ts +68 -0
- package/dist/lib/completion/walk.d.ts.map +1 -0
- package/dist/lib/completion/walk.js +102 -0
- package/dist/lib/completion/zsh.d.ts +13 -0
- package/dist/lib/completion/zsh.d.ts.map +1 -0
- package/dist/lib/completion/zsh.js +249 -0
- package/dist/lib/context/index.d.ts +107 -0
- package/dist/lib/context/index.d.ts.map +1 -0
- package/dist/lib/context/index.js +275 -0
- package/dist/lib/cookies/client.d.ts +131 -0
- package/dist/lib/cookies/client.d.ts.map +1 -0
- package/dist/lib/cookies/client.js +239 -0
- package/dist/lib/cookies/index.d.ts +2 -0
- package/dist/lib/cookies/index.d.ts.map +1 -0
- package/dist/lib/cookies/index.js +1 -0
- package/dist/lib/council/index.d.ts +266 -0
- package/dist/lib/council/index.d.ts.map +1 -0
- package/dist/lib/council/index.js +674 -0
- package/dist/lib/docs-index.d.ts +28 -0
- package/dist/lib/docs-index.d.ts.map +1 -0
- package/dist/lib/docs-index.js +169 -0
- package/dist/lib/docs-lint.d.ts +26 -0
- package/dist/lib/docs-lint.d.ts.map +1 -0
- package/dist/lib/docs-lint.js +378 -0
- package/dist/lib/docs-sweep.d.ts +34 -0
- package/dist/lib/docs-sweep.d.ts.map +1 -0
- package/dist/lib/docs-sweep.js +304 -0
- package/dist/lib/docs.d.ts +27 -0
- package/dist/lib/docs.d.ts.map +1 -0
- package/dist/lib/docs.js +142 -0
- package/dist/lib/env.d.ts +11 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +12 -0
- package/dist/lib/exec.d.ts +32 -0
- package/dist/lib/exec.d.ts.map +1 -0
- package/dist/lib/exec.js +54 -0
- package/dist/lib/format.d.ts +29 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +139 -0
- package/dist/lib/http/client.d.ts +56 -0
- package/dist/lib/http/client.d.ts.map +1 -0
- package/dist/lib/http/client.js +160 -0
- package/dist/lib/http/index.d.ts +2 -0
- package/dist/lib/http/index.d.ts.map +1 -0
- package/dist/lib/http/index.js +1 -0
- package/dist/lib/identities/index.d.ts +77 -0
- package/dist/lib/identities/index.d.ts.map +1 -0
- package/dist/lib/identities/index.js +190 -0
- package/dist/lib/machine.d.ts +19 -0
- package/dist/lib/machine.d.ts.map +1 -0
- package/dist/lib/machine.js +61 -0
- package/dist/lib/presence.d.ts +48 -0
- package/dist/lib/presence.d.ts.map +1 -0
- package/dist/lib/presence.js +123 -0
- package/dist/lib/readability/client.d.ts +39 -0
- package/dist/lib/readability/client.d.ts.map +1 -0
- package/dist/lib/readability/client.js +121 -0
- package/dist/lib/readability/index.d.ts +2 -0
- package/dist/lib/readability/index.d.ts.map +1 -0
- package/dist/lib/readability/index.js +1 -0
- package/dist/lib/scratch/index.d.ts +74 -0
- package/dist/lib/scratch/index.d.ts.map +1 -0
- package/dist/lib/scratch/index.js +393 -0
- package/dist/lib/tunnel/gate.d.ts +12 -0
- package/dist/lib/tunnel/gate.d.ts.map +1 -0
- package/dist/lib/tunnel/gate.js +101 -0
- package/dist/lib/tunnel/state.d.ts +34 -0
- package/dist/lib/tunnel/state.d.ts.map +1 -0
- package/dist/lib/tunnel/state.js +132 -0
- package/package.json +160 -8
- package/schemas/.gitkeep +0 -0
- package/schemas/config.schema.json +109 -0
- package/src/cli.ts +22 -0
- package/src/commander.ts +242 -0
- package/src/commands/.gitkeep +0 -0
- package/src/commands/agents.ts +4567 -0
- package/src/commands/backup.ts +305 -0
- package/src/commands/browse-ai.ts +198 -0
- package/src/commands/browse.ts +849 -0
- package/src/commands/callers.ts +363 -0
- package/src/commands/completion.ts +193 -0
- package/src/commands/config-get.ts +161 -0
- package/src/commands/context.ts +209 -0
- package/src/commands/cookies.ts +198 -0
- package/src/commands/docs.ts +174 -0
- package/src/commands/doctor.ts +231 -0
- package/src/commands/edit-batch.ts +233 -0
- package/src/commands/eml.ts +519 -0
- package/src/commands/env.ts +254 -0
- package/src/commands/fetch.ts +136 -0
- package/src/commands/file-history.ts +202 -0
- package/src/commands/grep.ts +371 -0
- package/src/commands/init.ts +335 -0
- package/src/commands/outline.ts +583 -0
- package/src/commands/presence.ts +152 -0
- package/src/commands/read.ts +64 -0
- package/src/commands/scratch.ts +445 -0
- package/src/commands/session.ts +187 -0
- package/src/commands/sync.ts +306 -0
- package/src/commands/toc.ts +218 -0
- package/src/commands/tokens.ts +79 -0
- package/src/commands/tunnel.ts +633 -0
- package/src/commands/uninstall.ts +144 -0
- package/src/commands/web.ts +193 -0
- package/src/core/agents/canonical-emit.ts +77 -0
- package/src/core/agents/cli-emit.ts +64 -0
- package/src/core/agents/cli.ts +838 -0
- package/src/core/agents/codex-replay.ts +163 -0
- package/src/core/agents/coord-client.ts +249 -0
- package/src/core/agents/events/consume.ts +196 -0
- package/src/core/agents/events/emit.ts +108 -0
- package/src/core/agents/events/ulid.ts +51 -0
- package/src/core/agents/index.ts +14 -0
- package/src/core/agents/paths.ts +16 -0
- package/src/core/agents/render/prompt-context.ts +401 -0
- package/src/core/agents/render/session-context.ts +341 -0
- package/src/core/agents/rules/claim-conflict.ts +282 -0
- package/src/core/agents/rules/commit-conflict.ts +303 -0
- package/src/core/agents/rules/stop-hook.ts +229 -0
- package/src/core/agents/session-events.ts +228 -0
- package/src/core/agents/state/activity-log.ts +33 -0
- package/src/core/agents/state/council.ts +265 -0
- package/src/core/agents/state/heartbeat-projector.ts +488 -0
- package/src/core/agents/state/heartbeat-writer.ts +333 -0
- package/src/core/agents/state/names.ts +399 -0
- package/src/core/agents/state/pidmap.ts +38 -0
- package/src/core/agents/state/scratch.ts +121 -0
- package/src/core/agents/state/shell-mutation.ts +44 -0
- package/src/core/agents/state/stale-sweep.ts +190 -0
- package/src/core/config.ts +111 -0
- package/src/core/hooks/cli.ts +1247 -0
- package/src/core/hooks/effects/image-capture.ts +330 -0
- package/src/core/hooks/effects/index.ts +210 -0
- package/src/core/hooks/events/emit.ts +120 -0
- package/src/core/hooks/events/schema.ts +430 -0
- package/src/core/hooks/events/ulid.ts +51 -0
- package/src/core/hooks/harness/detect.ts +30 -0
- package/src/core/hooks/harness/events.ts +102 -0
- package/src/core/hooks/harness/output.ts +100 -0
- package/src/core/hooks/harness/parse.ts +180 -0
- package/src/core/hooks/index.ts +16 -0
- package/src/core/hooks/resolve/anchor.ts +51 -0
- package/src/core/hooks/resolve/coord-root.ts +25 -0
- package/src/core/hooks/resolve/intent.ts +89 -0
- package/src/core/hooks/resolve/owner.ts +140 -0
- package/src/core/hooks/resolve/transcript.ts +72 -0
- package/src/hooks/.gitkeep +0 -0
- package/src/index.ts +15 -0
- package/src/lib/agent-browser/client.ts +239 -0
- package/src/lib/agent-browser/index.ts +1 -0
- package/src/lib/browser/client.ts +449 -0
- package/src/lib/browser/dev-overlay.ts +207 -0
- package/src/lib/browser/index.ts +24 -0
- package/src/lib/browser/layout.ts +288 -0
- package/src/lib/browser/visibility.ts +419 -0
- package/src/lib/browser/visual-diff.ts +150 -0
- package/src/lib/completion/bash.ts +291 -0
- package/src/lib/completion/fish.ts +134 -0
- package/src/lib/completion/index.ts +10 -0
- package/src/lib/completion/walk.ts +184 -0
- package/src/lib/completion/zsh.ts +262 -0
- package/src/lib/context/index.ts +386 -0
- package/src/lib/cookies/client.ts +301 -0
- package/src/lib/cookies/index.ts +13 -0
- package/src/lib/council/index.ts +803 -0
- package/src/lib/docs-index.ts +216 -0
- package/src/lib/docs-lint.ts +413 -0
- package/src/lib/docs-sweep.ts +348 -0
- package/src/lib/docs.ts +199 -0
- package/src/lib/env.ts +12 -0
- package/src/lib/exec.ts +74 -0
- package/src/lib/format.ts +147 -0
- package/src/lib/http/client.ts +211 -0
- package/src/lib/http/index.ts +1 -0
- package/src/lib/identities/index.ts +210 -0
- package/src/lib/machine.ts +61 -0
- package/src/lib/presence.ts +154 -0
- package/src/lib/readability/client.ts +169 -0
- package/src/lib/readability/index.ts +5 -0
- package/src/lib/readability/turndown-plugin-gfm.d.ts +10 -0
- package/src/lib/scratch/index.ts +470 -0
- package/src/lib/tunnel/gate.ts +113 -0
- package/src/lib/tunnel/state.ts +167 -0
- package/src/web/.gitkeep +0 -0
- package/index.js +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `harn backup`: restic-backed snapshots of `.harnery/`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `restic` with sensible defaults so single-user use doesn't require
|
|
5
|
+
* remembering env vars. Repo path + password file live under XDG-style
|
|
6
|
+
* paths and are init'd on first `harn backup init`. Subcommands:
|
|
7
|
+
*
|
|
8
|
+
* init restic init the repo (one-time)
|
|
9
|
+
* snapshot restic backup .harnery/
|
|
10
|
+
* list restic snapshots
|
|
11
|
+
* restore restic restore <id>
|
|
12
|
+
* prune restic forget --keep-daily 7 --keep-weekly 4 --prune
|
|
13
|
+
*
|
|
14
|
+
* Power users override via env vars (HARNERY_RESTIC_REPO, HARNERY_RESTIC_PASSWORD_FILE)
|
|
15
|
+
* or by passing through any restic args after `--`. The wrapper deliberately
|
|
16
|
+
* doesn't try to abstract restic; it surfaces it, with opinionated defaults plus
|
|
17
|
+
* passthrough.
|
|
18
|
+
*/
|
|
19
|
+
import type { Command } from "commander";
|
|
20
|
+
import type { EmitContext } from "../commander.js";
|
|
21
|
+
export declare function registerBackupCommand(program: Command, emit: EmitContext): void;
|
|
22
|
+
//# sourceMappingURL=backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backup.d.ts","sourceRoot":"","sources":["../../src/commands/backup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAgFnD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAkM/E"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `harn backup`: restic-backed snapshots of `.harnery/`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `restic` with sensible defaults so single-user use doesn't require
|
|
5
|
+
* remembering env vars. Repo path + password file live under XDG-style
|
|
6
|
+
* paths and are init'd on first `harn backup init`. Subcommands:
|
|
7
|
+
*
|
|
8
|
+
* init restic init the repo (one-time)
|
|
9
|
+
* snapshot restic backup .harnery/
|
|
10
|
+
* list restic snapshots
|
|
11
|
+
* restore restic restore <id>
|
|
12
|
+
* prune restic forget --keep-daily 7 --keep-weekly 4 --prune
|
|
13
|
+
*
|
|
14
|
+
* Power users override via env vars (HARNERY_RESTIC_REPO, HARNERY_RESTIC_PASSWORD_FILE)
|
|
15
|
+
* or by passing through any restic args after `--`. The wrapper deliberately
|
|
16
|
+
* doesn't try to abstract restic; it surfaces it, with opinionated defaults plus
|
|
17
|
+
* passthrough.
|
|
18
|
+
*/
|
|
19
|
+
import { spawnSync } from "node:child_process";
|
|
20
|
+
import { randomBytes } from "node:crypto";
|
|
21
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
22
|
+
import os from "node:os";
|
|
23
|
+
import path from "node:path";
|
|
24
|
+
function defaultRepo() {
|
|
25
|
+
const home = os.homedir();
|
|
26
|
+
return process.env.HARNERY_RESTIC_REPO ?? path.join(home, ".cache", "harnery", "restic-repo");
|
|
27
|
+
}
|
|
28
|
+
function defaultPasswordFile() {
|
|
29
|
+
const home = os.homedir();
|
|
30
|
+
return (process.env.HARNERY_RESTIC_PASSWORD_FILE ??
|
|
31
|
+
path.join(home, ".config", "harnery", "restic-password"));
|
|
32
|
+
}
|
|
33
|
+
function findHarneryDir() {
|
|
34
|
+
let dir = process.cwd();
|
|
35
|
+
for (let i = 0; i < 8; i++) {
|
|
36
|
+
if (existsSync(path.join(dir, ".harnery"))) {
|
|
37
|
+
return path.join(dir, ".harnery");
|
|
38
|
+
}
|
|
39
|
+
const parent = path.dirname(dir);
|
|
40
|
+
if (parent === dir)
|
|
41
|
+
break;
|
|
42
|
+
dir = parent;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function ensurePasswordFile(file) {
|
|
47
|
+
if (existsSync(file))
|
|
48
|
+
return;
|
|
49
|
+
mkdirSync(path.dirname(file), { recursive: true });
|
|
50
|
+
const pw = randomBytes(24).toString("base64");
|
|
51
|
+
writeFileSync(file, `${pw}\n`, { encoding: "utf-8", mode: 0o600 });
|
|
52
|
+
}
|
|
53
|
+
function runRestic(args, opts = {}) {
|
|
54
|
+
const repo = opts.repo ?? defaultRepo();
|
|
55
|
+
const pwFile = opts.passwordFile ?? defaultPasswordFile();
|
|
56
|
+
const wantInherit = opts.stdio === "inherit";
|
|
57
|
+
const r = spawnSync("restic", [...args, ...(opts.passThrough ?? [])], {
|
|
58
|
+
env: {
|
|
59
|
+
...process.env,
|
|
60
|
+
RESTIC_REPOSITORY: repo,
|
|
61
|
+
RESTIC_PASSWORD_FILE: pwFile,
|
|
62
|
+
},
|
|
63
|
+
encoding: "utf-8",
|
|
64
|
+
stdio: wantInherit ? "inherit" : "pipe",
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
exitCode: r.status ?? 1,
|
|
68
|
+
stdout: wantInherit ? "" : (r.stdout ?? "") + (r.stderr ?? ""),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function checkRestic(emit) {
|
|
72
|
+
const r = spawnSync("restic", ["version"], { encoding: "utf-8" });
|
|
73
|
+
if (r.status !== 0) {
|
|
74
|
+
emit.error({
|
|
75
|
+
code: "restic_missing",
|
|
76
|
+
message: "restic is not on PATH",
|
|
77
|
+
hint: "brew install restic (mac) / apt-get install restic (ubuntu) / https://restic.readthedocs.io/en/stable/020_installation.html",
|
|
78
|
+
});
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
export function registerBackupCommand(program, emit) {
|
|
84
|
+
const backup = program
|
|
85
|
+
.command("backup")
|
|
86
|
+
.description("restic-backed snapshots of .harnery/ (multi-machine recovery insurance)");
|
|
87
|
+
// -- init --
|
|
88
|
+
backup
|
|
89
|
+
.command("init")
|
|
90
|
+
.description("Create the restic repository + password file (one-time).")
|
|
91
|
+
.option("--repo <path>", `Repository path (default: ${defaultRepo()})`)
|
|
92
|
+
.option("--password-file <path>", `Password file (default: ${defaultPasswordFile()}, autogenerated)`)
|
|
93
|
+
.action((opts) => {
|
|
94
|
+
if (!checkRestic(emit)) {
|
|
95
|
+
emit.setExitCode(1);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const repo = opts.repo ?? defaultRepo();
|
|
99
|
+
const pwFile = opts.passwordFile ?? defaultPasswordFile();
|
|
100
|
+
ensurePasswordFile(pwFile);
|
|
101
|
+
mkdirSync(path.dirname(repo), { recursive: true });
|
|
102
|
+
const r = runRestic(["init"], { repo, passwordFile: pwFile, stdio: "inherit" });
|
|
103
|
+
if (r.exitCode === 0) {
|
|
104
|
+
emit.text(`restic repo initialized at ${repo}\npassword file: ${pwFile}`);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
emit.setExitCode(r.exitCode);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
// -- snapshot --
|
|
111
|
+
backup
|
|
112
|
+
.command("snapshot")
|
|
113
|
+
.description("Take a restic snapshot of .harnery/ (excluding events.ndjson and " +
|
|
114
|
+
".lock files by default). Pass --target to back up a different path.")
|
|
115
|
+
.option("--target <path>", "Path to snapshot (default: .harnery/ from cwd walk-up)")
|
|
116
|
+
.option("--tag <tag>", "Restic tag (repeatable)", collect, [])
|
|
117
|
+
.option("--repo <path>", "Repository path")
|
|
118
|
+
.option("--password-file <path>", "Password file")
|
|
119
|
+
.option("--include-events", "Don't exclude events.ndjson (default: excluded; large + machine-local)")
|
|
120
|
+
.action((opts) => {
|
|
121
|
+
if (!checkRestic(emit)) {
|
|
122
|
+
emit.setExitCode(1);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const target = opts.target ?? findHarneryDir();
|
|
126
|
+
if (!target) {
|
|
127
|
+
emit.error({
|
|
128
|
+
code: "target_missing",
|
|
129
|
+
message: "No .harnery/ found above cwd; pass --target explicitly or run from a monorepo with .harnery/",
|
|
130
|
+
});
|
|
131
|
+
emit.setExitCode(1);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const passThrough = [];
|
|
135
|
+
if (!opts.includeEvents) {
|
|
136
|
+
passThrough.push("--exclude", "events.ndjson");
|
|
137
|
+
passThrough.push("--exclude", ".lock");
|
|
138
|
+
passThrough.push("--exclude", ".log.lock");
|
|
139
|
+
}
|
|
140
|
+
for (const t of opts.tag) {
|
|
141
|
+
passThrough.push("--tag", t);
|
|
142
|
+
}
|
|
143
|
+
const r = runRestic(["backup", target], {
|
|
144
|
+
repo: opts.repo,
|
|
145
|
+
passwordFile: opts.passwordFile,
|
|
146
|
+
stdio: "inherit",
|
|
147
|
+
passThrough,
|
|
148
|
+
});
|
|
149
|
+
emit.setExitCode(r.exitCode);
|
|
150
|
+
});
|
|
151
|
+
// -- list --
|
|
152
|
+
backup
|
|
153
|
+
.command("list")
|
|
154
|
+
.description("List snapshots in the repo.")
|
|
155
|
+
.option("--repo <path>", "Repository path")
|
|
156
|
+
.option("--password-file <path>", "Password file")
|
|
157
|
+
.option("--json", "JSON output")
|
|
158
|
+
.action((opts) => {
|
|
159
|
+
if (!checkRestic(emit)) {
|
|
160
|
+
emit.setExitCode(1);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const args = ["snapshots"];
|
|
164
|
+
if (opts.json)
|
|
165
|
+
args.push("--json");
|
|
166
|
+
const r = runRestic(args, {
|
|
167
|
+
repo: opts.repo,
|
|
168
|
+
passwordFile: opts.passwordFile,
|
|
169
|
+
stdio: opts.json ? "pipe" : "inherit",
|
|
170
|
+
});
|
|
171
|
+
if (opts.json && r.exitCode === 0) {
|
|
172
|
+
try {
|
|
173
|
+
emit.data(JSON.parse(r.stdout));
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
emit.text(r.stdout);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
emit.setExitCode(r.exitCode);
|
|
180
|
+
});
|
|
181
|
+
// -- restore --
|
|
182
|
+
backup
|
|
183
|
+
.command("restore <snapshotId>")
|
|
184
|
+
.description("Restore a snapshot to a target directory (default: ./restore-<timestamp>).")
|
|
185
|
+
.option("--target <path>", "Restore destination")
|
|
186
|
+
.option("--repo <path>", "Repository path")
|
|
187
|
+
.option("--password-file <path>", "Password file")
|
|
188
|
+
.action((snapshotId, opts) => {
|
|
189
|
+
if (!checkRestic(emit)) {
|
|
190
|
+
emit.setExitCode(1);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const target = opts.target ?? path.join(process.cwd(), `restore-${Date.now()}`);
|
|
194
|
+
mkdirSync(target, { recursive: true });
|
|
195
|
+
const r = runRestic(["restore", snapshotId, "--target", target], {
|
|
196
|
+
repo: opts.repo,
|
|
197
|
+
passwordFile: opts.passwordFile,
|
|
198
|
+
stdio: "inherit",
|
|
199
|
+
});
|
|
200
|
+
if (r.exitCode === 0) {
|
|
201
|
+
emit.text(`restored to: ${target}`);
|
|
202
|
+
}
|
|
203
|
+
emit.setExitCode(r.exitCode);
|
|
204
|
+
});
|
|
205
|
+
// -- prune --
|
|
206
|
+
backup
|
|
207
|
+
.command("prune")
|
|
208
|
+
.description("Forget + prune snapshots (default policy: keep 7 daily / 4 weekly / 6 monthly).")
|
|
209
|
+
.option("--keep-daily <n>", "Daily snapshots to keep", "7")
|
|
210
|
+
.option("--keep-weekly <n>", "Weekly snapshots to keep", "4")
|
|
211
|
+
.option("--keep-monthly <n>", "Monthly snapshots to keep", "6")
|
|
212
|
+
.option("--dry-run", "Show what would be pruned without actually pruning")
|
|
213
|
+
.option("--repo <path>", "Repository path")
|
|
214
|
+
.option("--password-file <path>", "Password file")
|
|
215
|
+
.action((opts) => {
|
|
216
|
+
if (!checkRestic(emit)) {
|
|
217
|
+
emit.setExitCode(1);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const args = [
|
|
221
|
+
"forget",
|
|
222
|
+
"--keep-daily",
|
|
223
|
+
opts.keepDaily,
|
|
224
|
+
"--keep-weekly",
|
|
225
|
+
opts.keepWeekly,
|
|
226
|
+
"--keep-monthly",
|
|
227
|
+
opts.keepMonthly,
|
|
228
|
+
];
|
|
229
|
+
if (!opts.dryRun)
|
|
230
|
+
args.push("--prune");
|
|
231
|
+
else
|
|
232
|
+
args.push("--dry-run");
|
|
233
|
+
const r = runRestic(args, {
|
|
234
|
+
repo: opts.repo,
|
|
235
|
+
passwordFile: opts.passwordFile,
|
|
236
|
+
stdio: "inherit",
|
|
237
|
+
});
|
|
238
|
+
emit.setExitCode(r.exitCode);
|
|
239
|
+
});
|
|
240
|
+
// -- check --
|
|
241
|
+
backup
|
|
242
|
+
.command("check")
|
|
243
|
+
.description("restic check: verify repo integrity")
|
|
244
|
+
.option("--repo <path>", "Repository path")
|
|
245
|
+
.option("--password-file <path>", "Password file")
|
|
246
|
+
.action((opts) => {
|
|
247
|
+
if (!checkRestic(emit)) {
|
|
248
|
+
emit.setExitCode(1);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const r = runRestic(["check"], {
|
|
252
|
+
repo: opts.repo,
|
|
253
|
+
passwordFile: opts.passwordFile,
|
|
254
|
+
stdio: "inherit",
|
|
255
|
+
});
|
|
256
|
+
emit.setExitCode(r.exitCode);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function collect(value, acc) {
|
|
260
|
+
acc.push(value);
|
|
261
|
+
return acc;
|
|
262
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browse-ai.d.ts","sourceRoot":"","sources":["../../src/commands/browse-ai.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAiDnD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,CA2CtF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { AgentBrowser } from "../lib/agent-browser/index.js";
|
|
4
|
+
import { CookieJar } from "../lib/cookies/index.js";
|
|
5
|
+
// Module-scoped emit assigned by registerBrowseAiCommand. Same pattern as
|
|
6
|
+
// cookies/read/browse: helper functions close over `emit` so action
|
|
7
|
+
// callbacks stay concise.
|
|
8
|
+
let emit;
|
|
9
|
+
/**
|
|
10
|
+
* `harn browse-ai <url>`: wraps Vercel Labs' agent-browser Rust CLI.
|
|
11
|
+
*
|
|
12
|
+
* Sister command to `harn browse` (which uses Playwright). Differences:
|
|
13
|
+
*
|
|
14
|
+
* - **Output shape.** `agent-browser` returns an accessibility-tree
|
|
15
|
+
* snapshot with element refs (`@e1`, `@e2`), purpose-built for LLM
|
|
16
|
+
* consumption. `harn browse` returns DOM/HTML/innerText.
|
|
17
|
+
* - **Process model.** `agent-browser` runs as a daemon: successive
|
|
18
|
+
* calls reuse the same Chrome instance until something explicitly
|
|
19
|
+
* closes it. `harn browse` opens + closes per call.
|
|
20
|
+
* - **Auth model.** `harn browse-ai` doesn't have a `--login` flow; use
|
|
21
|
+
* `harn browse --login` for one-time auth, then both tools share the
|
|
22
|
+
* same cookie jar.
|
|
23
|
+
*
|
|
24
|
+
* Mirrors the agent-side `browse` wrapper (sandbox side) so a script written for one
|
|
25
|
+
* works on the other modulo path differences.
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_STORE = resolve(homedir(), ".cache", "harnery", "cookies.json");
|
|
28
|
+
export function registerBrowseAiCommand(program, emitParam) {
|
|
29
|
+
emit = emitParam;
|
|
30
|
+
program
|
|
31
|
+
.command("browse-ai <url>")
|
|
32
|
+
.description("agent-browser (Vercel Labs) wrapper: accessibility-tree snapshots with element refs (@e1, @e2) for LLM consumption. " +
|
|
33
|
+
"Daemon-mode: successive calls reuse the same browser instance. Sister to harn browse (Playwright).")
|
|
34
|
+
.option("--snapshot", "Print accessibility tree (default action when no other output flag)")
|
|
35
|
+
.option("-i, --interactive", "Snapshot interactive elements only (with --snapshot)")
|
|
36
|
+
.option("--screenshot <path>", "Save a screenshot to the given path")
|
|
37
|
+
.option("--no-full-page", "Capture only the viewport (with --screenshot)")
|
|
38
|
+
.option("--annotate <path>", "Save an annotated screenshot with numbered labels (vision-model friendly)")
|
|
39
|
+
.option("--click <ref>", "Click an element ref (@e5) or CSS selector after open")
|
|
40
|
+
.option("--fill <ref=>value>", "Fill input: '@e3=>hello' (separator is `=>` so attribute selectors don't collide)")
|
|
41
|
+
.option("--press <key>", "Press a key after open/fill (Enter, Tab, etc.)")
|
|
42
|
+
.option("--wait-for <selector|ms>", "Wait for selector OR a number of ms before output")
|
|
43
|
+
.option("--evaluate <js>", "Run JS in the page context (escape-hatch for power users)")
|
|
44
|
+
.option("--batch <commands>", "Run multiple agent-browser steps in one session, semicolon-separated. " +
|
|
45
|
+
'E.g., --batch "click @e5; wait 1000; snapshot"')
|
|
46
|
+
.option("--network-har <path>", "Record a HAR file from open() through end of run")
|
|
47
|
+
.option("--no-cookies", "Skip cookie-jar attach and persist")
|
|
48
|
+
.option("--store <path>", `Cookie store path (default ${DEFAULT_STORE})`)
|
|
49
|
+
.option("--json", "Emit a JSON envelope (snapshot, screenshot path, step results)")
|
|
50
|
+
.option("--timeout <ms>", "Per-step timeout in ms", "60000")
|
|
51
|
+
.action((url, opts) => {
|
|
52
|
+
try {
|
|
53
|
+
runBrowseAi(url, opts);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
57
|
+
emit.error({ code: "browse_ai_error", message: msg });
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function runBrowseAi(url, opts) {
|
|
63
|
+
const jar = opts.cookies === false
|
|
64
|
+
? null
|
|
65
|
+
: new CookieJar({ path: opts.store ?? DEFAULT_STORE, source: "bp-browse-ai" });
|
|
66
|
+
const ab = new AgentBrowser({
|
|
67
|
+
jar,
|
|
68
|
+
timeoutMs: Number.parseInt(opts.timeout, 10),
|
|
69
|
+
});
|
|
70
|
+
const stepLog = [];
|
|
71
|
+
// 1. Open + optional HAR start.
|
|
72
|
+
if (opts.networkHar)
|
|
73
|
+
ab.harStart(opts.networkHar);
|
|
74
|
+
ab.open(url);
|
|
75
|
+
stepLog.push({ step: `open ${url}`, ok: true, output: "" });
|
|
76
|
+
// 2. Pre-output actions, in the order they make sense for typical flows.
|
|
77
|
+
if (opts.fill) {
|
|
78
|
+
const sep = opts.fill.indexOf("=>");
|
|
79
|
+
if (sep < 0) {
|
|
80
|
+
throw new Error(`--fill expects 'ref=>value' (got: ${opts.fill}). Separator is '=>' (not '=').`);
|
|
81
|
+
}
|
|
82
|
+
const ref = opts.fill.slice(0, sep);
|
|
83
|
+
const value = opts.fill.slice(sep + 2);
|
|
84
|
+
const r = ab.fill(ref, value);
|
|
85
|
+
stepLog.push({ step: `fill ${ref}`, ok: r.ok, output: r.stdout.trim() });
|
|
86
|
+
}
|
|
87
|
+
if (opts.click) {
|
|
88
|
+
const r = ab.click(opts.click);
|
|
89
|
+
stepLog.push({ step: `click ${opts.click}`, ok: r.ok, output: r.stdout.trim() });
|
|
90
|
+
}
|
|
91
|
+
if (opts.press) {
|
|
92
|
+
const r = ab.press(opts.press);
|
|
93
|
+
stepLog.push({ step: `press ${opts.press}`, ok: r.ok, output: r.stdout.trim() });
|
|
94
|
+
}
|
|
95
|
+
if (opts.waitFor) {
|
|
96
|
+
const r = ab.wait(opts.waitFor);
|
|
97
|
+
stepLog.push({ step: `wait ${opts.waitFor}`, ok: r.ok, output: r.stdout.trim() });
|
|
98
|
+
}
|
|
99
|
+
if (opts.batch) {
|
|
100
|
+
const steps = opts.batch
|
|
101
|
+
.split(";")
|
|
102
|
+
.map((s) => s.trim())
|
|
103
|
+
.filter(Boolean);
|
|
104
|
+
const results = ab.batch(steps);
|
|
105
|
+
steps.forEach((step, i) => {
|
|
106
|
+
const r = results[i];
|
|
107
|
+
stepLog.push({ step, ok: r?.ok ?? false, output: r?.stdout.trim() ?? "" });
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (opts.evaluate) {
|
|
111
|
+
const out = ab.evaluate(opts.evaluate);
|
|
112
|
+
stepLog.push({ step: "eval", ok: true, output: out });
|
|
113
|
+
}
|
|
114
|
+
// 3. Output capture.
|
|
115
|
+
let snapshot = null;
|
|
116
|
+
if (opts.snapshot || (!opts.screenshot && !opts.annotate && !opts.evaluate)) {
|
|
117
|
+
snapshot = ab.snapshot({ interactive: opts.interactive });
|
|
118
|
+
}
|
|
119
|
+
if (opts.screenshot) {
|
|
120
|
+
ab.screenshot(opts.screenshot, { full: opts.fullPage !== false });
|
|
121
|
+
}
|
|
122
|
+
if (opts.annotate) {
|
|
123
|
+
ab.screenshot(opts.annotate, { annotate: true });
|
|
124
|
+
}
|
|
125
|
+
if (opts.networkHar)
|
|
126
|
+
ab.harStop(opts.networkHar);
|
|
127
|
+
// 4. Cookie sync back to jar.
|
|
128
|
+
const cookieStats = ab.syncCookiesToJar();
|
|
129
|
+
// 5. Output.
|
|
130
|
+
if (opts.json) {
|
|
131
|
+
const envelope = {
|
|
132
|
+
url,
|
|
133
|
+
steps: stepLog,
|
|
134
|
+
cookiesSaved: cookieStats.saved,
|
|
135
|
+
};
|
|
136
|
+
if (snapshot !== null)
|
|
137
|
+
envelope.snapshot = snapshot;
|
|
138
|
+
if (opts.screenshot)
|
|
139
|
+
envelope.screenshot = opts.screenshot;
|
|
140
|
+
if (opts.annotate)
|
|
141
|
+
envelope.annotated = opts.annotate;
|
|
142
|
+
if (opts.networkHar)
|
|
143
|
+
envelope.har = opts.networkHar;
|
|
144
|
+
emit.data(envelope);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (snapshot !== null)
|
|
148
|
+
emit.text(snapshot);
|
|
149
|
+
if (opts.screenshot)
|
|
150
|
+
emit.log(`screenshot: ${opts.screenshot}`, "info");
|
|
151
|
+
if (opts.annotate)
|
|
152
|
+
emit.log(`annotated: ${opts.annotate}`, "info");
|
|
153
|
+
if (cookieStats.saved > 0) {
|
|
154
|
+
emit.log(`saved ${cookieStats.saved} cookie${cookieStats.saved === 1 ? "" : "s"} to ${jar?.path}`, "info");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { EmitContext, HarneryProgramContext } from "../commander.js";
|
|
3
|
+
export declare function registerBrowseCommand(program: Command, emitParam: EmitContext, context?: HarneryProgramContext): void;
|
|
4
|
+
//# sourceMappingURL=browse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browse.d.ts","sourceRoot":"","sources":["../../src/commands/browse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AA0G1E,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,WAAW,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,IAAI,CAwJN"}
|