harnery 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +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 +494 -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 +32 -0
- package/dist/lib/readability/client.d.ts.map +1 -0
- package/dist/lib/readability/client.js +119 -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 +564 -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 +156 -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,371 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import type { Command } from "commander";
|
|
3
|
+
import type { EmitContext, HarneryProgramContext } from "../commander.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `grep`: monorepo-aware code search. Thin wrapper over grep -rn with
|
|
7
|
+
* smart default excludes (skip dist/.next/node_modules/.git/...), repo
|
|
8
|
+
* scoping (`--repo <name>` or `--all-repos`), and language presets.
|
|
9
|
+
*
|
|
10
|
+
* Default behavior matches grep's "regex" semantics (`-E` extended). Use
|
|
11
|
+
* `-F` / `--literal` to pin to literal-string mode. Output is line-oriented
|
|
12
|
+
* `file:line:content` in TTY mode, `{rows, total, truncated}` in --json mode.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const DEFAULT_EXCLUDE_DIRS = [
|
|
16
|
+
".git",
|
|
17
|
+
".cache",
|
|
18
|
+
"node_modules",
|
|
19
|
+
"dist",
|
|
20
|
+
"build",
|
|
21
|
+
"out",
|
|
22
|
+
".next",
|
|
23
|
+
"vendor",
|
|
24
|
+
"__pycache__",
|
|
25
|
+
".venv",
|
|
26
|
+
"tmp",
|
|
27
|
+
"tmp-files",
|
|
28
|
+
"coverage",
|
|
29
|
+
".parcel-cache",
|
|
30
|
+
".turbo",
|
|
31
|
+
".harnery",
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
// (no file-name excludes by default).
|
|
35
|
+
const DEFAULT_EXCLUDE_FILES: string[] = [];
|
|
36
|
+
|
|
37
|
+
const LANG_GLOBS: Record<string, string[]> = {
|
|
38
|
+
ts: ["*.ts"],
|
|
39
|
+
tsx: ["*.tsx"],
|
|
40
|
+
js: ["*.js", "*.mjs", "*.cjs"],
|
|
41
|
+
jsx: ["*.jsx"],
|
|
42
|
+
py: ["*.py"],
|
|
43
|
+
php: ["*.php"],
|
|
44
|
+
sql: ["*.sql"],
|
|
45
|
+
md: ["*.md", "*.mdx"],
|
|
46
|
+
sh: ["*.sh", "*.bash"],
|
|
47
|
+
json: ["*.json"],
|
|
48
|
+
yaml: ["*.yaml", "*.yml"],
|
|
49
|
+
rb: ["*.rb"],
|
|
50
|
+
go: ["*.go"],
|
|
51
|
+
rs: ["*.rs"],
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
interface GrepOpts {
|
|
55
|
+
repo?: string;
|
|
56
|
+
allRepos?: boolean;
|
|
57
|
+
lang?: string;
|
|
58
|
+
ignoreCase?: boolean;
|
|
59
|
+
wholeWord?: boolean;
|
|
60
|
+
literal?: boolean;
|
|
61
|
+
filesOnly?: boolean;
|
|
62
|
+
count?: boolean;
|
|
63
|
+
context?: string;
|
|
64
|
+
maxCount?: string;
|
|
65
|
+
limit?: string;
|
|
66
|
+
include?: string[];
|
|
67
|
+
exclude?: string[];
|
|
68
|
+
noDefaultExcludes?: boolean;
|
|
69
|
+
json?: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface Match {
|
|
73
|
+
repo: string;
|
|
74
|
+
file: string;
|
|
75
|
+
line: number;
|
|
76
|
+
text: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function registerGrepCommand(
|
|
80
|
+
program: Command,
|
|
81
|
+
emit: EmitContext,
|
|
82
|
+
context?: HarneryProgramContext,
|
|
83
|
+
): void {
|
|
84
|
+
program
|
|
85
|
+
.command("grep <pattern> [paths...]")
|
|
86
|
+
.description(
|
|
87
|
+
"Monorepo-aware code search. Skips dist/.next/node_modules/.git/... by default. " +
|
|
88
|
+
"Use --repo, --all-repos, --lang for scoping. Regex by default; -F for literal.",
|
|
89
|
+
)
|
|
90
|
+
.option("--repo <name>", "Scope to one submodule (`.` = parent repo root)")
|
|
91
|
+
.option("--all-repos", "Search parent + every submodule")
|
|
92
|
+
.option("--lang <lang>", `File type preset (${Object.keys(LANG_GLOBS).join(", ")})`)
|
|
93
|
+
.option("-i, --ignore-case", "Case-insensitive match")
|
|
94
|
+
.option("-w, --whole-word", "Match whole words only")
|
|
95
|
+
.option("-F, --literal", "Treat <pattern> as a literal string (no regex)")
|
|
96
|
+
.option("-l, --files-only", "Only print file names containing a match")
|
|
97
|
+
.option("-c, --count", "Print match count per file (suppresses content)")
|
|
98
|
+
.option("-C, --context <n>", "Print N lines of context around each match", "0")
|
|
99
|
+
.option("--max-count <n>", "Stop after N matches per file")
|
|
100
|
+
.option("--limit <n>", "Truncate output to N matches total")
|
|
101
|
+
.option("--include <glob>", "Extra --include glob (repeatable)", collect, [] as string[])
|
|
102
|
+
.option("--exclude <glob>", "Extra --exclude glob (repeatable)", collect, [] as string[])
|
|
103
|
+
.option("--no-default-excludes", "Disable the default skip list (node_modules, dist, etc.)")
|
|
104
|
+
.option("--json", "Structured JSON envelope")
|
|
105
|
+
.action(async (pattern: string, paths: string[], opts: GrepOpts) => {
|
|
106
|
+
try {
|
|
107
|
+
const result = await runGrep(pattern, paths, opts, context);
|
|
108
|
+
if (opts.json) {
|
|
109
|
+
emit.config({ format: "json" });
|
|
110
|
+
emit.data(result);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
emit.text(`${renderResult(result, opts)}\n`);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
emit.error({ code: "grep_failed", message: (err as Error).message });
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function collect(value: string, prev: string[]): string[] {
|
|
122
|
+
return [...prev, value];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface GrepResult {
|
|
126
|
+
pattern: string;
|
|
127
|
+
mode: "regex" | "literal";
|
|
128
|
+
repos: { name: string; cwd: string; matches: Match[]; truncated: boolean }[];
|
|
129
|
+
total_matches: number;
|
|
130
|
+
total_files: number;
|
|
131
|
+
truncated: boolean;
|
|
132
|
+
elapsed_ms: number;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function runGrep(
|
|
136
|
+
pattern: string,
|
|
137
|
+
paths: string[],
|
|
138
|
+
opts: GrepOpts,
|
|
139
|
+
context: HarneryProgramContext | undefined,
|
|
140
|
+
): Promise<GrepResult> {
|
|
141
|
+
if (!pattern) throw new Error("pattern required");
|
|
142
|
+
const started = Date.now();
|
|
143
|
+
|
|
144
|
+
const repos = resolveRepos(opts, context);
|
|
145
|
+
const limit = opts.limit ? Number.parseInt(opts.limit, 10) : Number.POSITIVE_INFINITY;
|
|
146
|
+
|
|
147
|
+
const allRepoResults: GrepResult["repos"] = [];
|
|
148
|
+
let totalMatches = 0;
|
|
149
|
+
const filesSeen = new Set<string>();
|
|
150
|
+
let truncated = false;
|
|
151
|
+
|
|
152
|
+
for (const repo of repos) {
|
|
153
|
+
if (truncated) break;
|
|
154
|
+
const repoLimit = Number.isFinite(limit)
|
|
155
|
+
? Math.max(0, limit - totalMatches)
|
|
156
|
+
: Number.POSITIVE_INFINITY;
|
|
157
|
+
if (repoLimit === 0) {
|
|
158
|
+
truncated = true;
|
|
159
|
+
allRepoResults.push({ name: repo.name, cwd: repo.cwd, matches: [], truncated: true });
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
const matches = await runGrepInRepo(pattern, paths, opts, repo.cwd, repo.name, repoLimit);
|
|
163
|
+
let repoTruncated = false;
|
|
164
|
+
if (Number.isFinite(repoLimit) && matches.length >= repoLimit) {
|
|
165
|
+
repoTruncated = true;
|
|
166
|
+
truncated = true;
|
|
167
|
+
}
|
|
168
|
+
totalMatches += matches.length;
|
|
169
|
+
for (const m of matches) filesSeen.add(`${repo.name}/${m.file}`);
|
|
170
|
+
allRepoResults.push({ name: repo.name, cwd: repo.cwd, matches, truncated: repoTruncated });
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
pattern,
|
|
175
|
+
mode: opts.literal ? "literal" : "regex",
|
|
176
|
+
repos: allRepoResults,
|
|
177
|
+
total_matches: totalMatches,
|
|
178
|
+
total_files: filesSeen.size,
|
|
179
|
+
truncated,
|
|
180
|
+
elapsed_ms: Date.now() - started,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function resolveRepos(
|
|
185
|
+
opts: GrepOpts,
|
|
186
|
+
context: HarneryProgramContext | undefined,
|
|
187
|
+
): { name: string; cwd: string }[] {
|
|
188
|
+
const repoRoot = context?.repoRoot;
|
|
189
|
+
const submodules = context?.submodules;
|
|
190
|
+
if (opts.allRepos) {
|
|
191
|
+
if (!repoRoot || !submodules) {
|
|
192
|
+
throw new Error("--all-repos requires harnery to be configured with repoRoot + submodules");
|
|
193
|
+
}
|
|
194
|
+
const out: { name: string; cwd: string }[] = [{ name: "parent", cwd: repoRoot }];
|
|
195
|
+
for (const name of submodules) out.push({ name, cwd: `${repoRoot}/${name}` });
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
if (opts.repo) {
|
|
199
|
+
if (opts.repo === "." || opts.repo === "parent") {
|
|
200
|
+
if (!repoRoot) {
|
|
201
|
+
throw new Error('--repo "." requires harnery to be configured with repoRoot');
|
|
202
|
+
}
|
|
203
|
+
return [{ name: "parent", cwd: repoRoot }];
|
|
204
|
+
}
|
|
205
|
+
if (!submodules || !repoRoot) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
`--repo "${opts.repo}" requires harnery to be configured with repoRoot + submodules`,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
const found = submodules.find((n) => n === opts.repo);
|
|
211
|
+
if (!found) {
|
|
212
|
+
throw new Error(`unknown repo "${opts.repo}". Valid: parent (.), ${submodules.join(", ")}`);
|
|
213
|
+
}
|
|
214
|
+
return [{ name: found, cwd: `${repoRoot}/${found}` }];
|
|
215
|
+
}
|
|
216
|
+
return [{ name: "cwd", cwd: process.cwd() }];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function runGrepInRepo(
|
|
220
|
+
pattern: string,
|
|
221
|
+
paths: string[],
|
|
222
|
+
opts: GrepOpts,
|
|
223
|
+
cwd: string,
|
|
224
|
+
repoName: string,
|
|
225
|
+
limit: number,
|
|
226
|
+
): Promise<Match[]> {
|
|
227
|
+
const args: string[] = ["-rn", "--color=never", "-I"]; // -I: skip binary files
|
|
228
|
+
if (opts.ignoreCase) args.push("-i");
|
|
229
|
+
if (opts.wholeWord) args.push("-w");
|
|
230
|
+
if (opts.literal) args.push("-F");
|
|
231
|
+
else args.push("-E");
|
|
232
|
+
if (opts.filesOnly) args.push("-l");
|
|
233
|
+
if (opts.count) args.push("-c");
|
|
234
|
+
const contextN = Number.parseInt(opts.context ?? "0", 10);
|
|
235
|
+
if (Number.isFinite(contextN) && contextN > 0) args.push(`-C${contextN}`);
|
|
236
|
+
if (opts.maxCount) {
|
|
237
|
+
const n = Number.parseInt(opts.maxCount, 10);
|
|
238
|
+
if (Number.isFinite(n) && n > 0) args.push(`-m${n}`);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (!opts.noDefaultExcludes) {
|
|
242
|
+
for (const d of DEFAULT_EXCLUDE_DIRS) args.push(`--exclude-dir=${d}`);
|
|
243
|
+
for (const f of DEFAULT_EXCLUDE_FILES) args.push(`--exclude=${f}`);
|
|
244
|
+
}
|
|
245
|
+
for (const e of opts.exclude ?? []) args.push(`--exclude=${e}`);
|
|
246
|
+
|
|
247
|
+
const langGlobs = opts.lang ? LANG_GLOBS[opts.lang] : undefined;
|
|
248
|
+
if (opts.lang && !langGlobs) {
|
|
249
|
+
throw new Error(`unknown --lang "${opts.lang}". Valid: ${Object.keys(LANG_GLOBS).join(", ")}`);
|
|
250
|
+
}
|
|
251
|
+
if (langGlobs) for (const g of langGlobs) args.push(`--include=${g}`);
|
|
252
|
+
for (const g of opts.include ?? []) args.push(`--include=${g}`);
|
|
253
|
+
|
|
254
|
+
args.push("--", pattern);
|
|
255
|
+
if (paths.length > 0) args.push(...paths);
|
|
256
|
+
else args.push(".");
|
|
257
|
+
|
|
258
|
+
const matches = await execGrep(args, cwd, limit);
|
|
259
|
+
return matches.map((m) => ({ ...m, repo: repoName }));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function execGrep(args: string[], cwd: string, limit: number): Promise<Omit<Match, "repo">[]> {
|
|
263
|
+
return new Promise((resolveP, reject) => {
|
|
264
|
+
const proc = spawn("grep", args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
265
|
+
const matches: Omit<Match, "repo">[] = [];
|
|
266
|
+
let buffer = "";
|
|
267
|
+
let stderr = "";
|
|
268
|
+
let truncated = false;
|
|
269
|
+
|
|
270
|
+
proc.stdout.setEncoding("utf8");
|
|
271
|
+
proc.stdout.on("data", (chunk: string) => {
|
|
272
|
+
if (truncated) return;
|
|
273
|
+
buffer += chunk;
|
|
274
|
+
let nl = buffer.indexOf("\n");
|
|
275
|
+
while (nl >= 0) {
|
|
276
|
+
const line = buffer.slice(0, nl);
|
|
277
|
+
buffer = buffer.slice(nl + 1);
|
|
278
|
+
if (line.length !== 0) {
|
|
279
|
+
const parsed = parseGrepLine(line);
|
|
280
|
+
if (parsed) matches.push(parsed);
|
|
281
|
+
if (Number.isFinite(limit) && matches.length >= limit) {
|
|
282
|
+
truncated = true;
|
|
283
|
+
proc.kill("SIGTERM");
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
nl = buffer.indexOf("\n");
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
proc.stderr.setEncoding("utf8");
|
|
291
|
+
proc.stderr.on("data", (chunk: string) => {
|
|
292
|
+
stderr += chunk;
|
|
293
|
+
});
|
|
294
|
+
proc.on("error", reject);
|
|
295
|
+
proc.on("close", (code) => {
|
|
296
|
+
if (buffer.length > 0 && !truncated) {
|
|
297
|
+
const parsed = parseGrepLine(buffer);
|
|
298
|
+
if (parsed) matches.push(parsed);
|
|
299
|
+
}
|
|
300
|
+
// grep exits 1 on "no matches": normal, not an error.
|
|
301
|
+
if (code !== null && code !== 0 && code !== 1 && !truncated) {
|
|
302
|
+
reject(new Error(`grep exited ${code}: ${stderr.trim() || "(no stderr)"}`));
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
resolveP(matches);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Parse `path:line:content` from grep -n output. Returns null for ambiguous (no line number) lines. */
|
|
311
|
+
function parseGrepLine(line: string): Omit<Match, "repo"> | null {
|
|
312
|
+
// First colon ends path; second colon ends line number (if numeric).
|
|
313
|
+
const firstColon = line.indexOf(":");
|
|
314
|
+
if (firstColon < 0) {
|
|
315
|
+
// -l mode: just a path. Encode as line=0, text="".
|
|
316
|
+
return { file: line, line: 0, text: "" };
|
|
317
|
+
}
|
|
318
|
+
const after = line.slice(firstColon + 1);
|
|
319
|
+
const secondColon = after.indexOf(":");
|
|
320
|
+
if (secondColon < 0) {
|
|
321
|
+
// -c mode: `path:count`.
|
|
322
|
+
const count = Number.parseInt(after, 10);
|
|
323
|
+
if (Number.isFinite(count)) return { file: line.slice(0, firstColon), line: count, text: "" };
|
|
324
|
+
return { file: line.slice(0, firstColon), line: 0, text: after };
|
|
325
|
+
}
|
|
326
|
+
const lineNum = Number.parseInt(after.slice(0, secondColon), 10);
|
|
327
|
+
if (!Number.isFinite(lineNum)) {
|
|
328
|
+
// Probably a context separator like `--`. Skip.
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
file: line.slice(0, firstColon),
|
|
333
|
+
line: lineNum,
|
|
334
|
+
text: after.slice(secondColon + 1),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function renderResult(r: GrepResult, opts: GrepOpts): string {
|
|
339
|
+
const lines: string[] = [];
|
|
340
|
+
const showRepoHeader = r.repos.length > 1;
|
|
341
|
+
for (const repo of r.repos) {
|
|
342
|
+
if (repo.matches.length === 0) continue;
|
|
343
|
+
if (showRepoHeader) {
|
|
344
|
+
lines.push("");
|
|
345
|
+
lines.push(
|
|
346
|
+
`── ${repo.name} (${repo.matches.length} match${repo.matches.length === 1 ? "" : "es"}) ──`,
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
for (const m of repo.matches) {
|
|
350
|
+
if (opts.filesOnly) {
|
|
351
|
+
lines.push(m.file);
|
|
352
|
+
} else if (opts.count) {
|
|
353
|
+
lines.push(`${m.file}:${m.line}`);
|
|
354
|
+
} else {
|
|
355
|
+
lines.push(`${m.file}:${m.line}:${m.text}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (repo.truncated) {
|
|
359
|
+
lines.push(" (truncated; pass --limit to widen)");
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
if (r.total_matches === 0) {
|
|
363
|
+
lines.push(`(no matches for /${r.pattern}/${r.mode === "literal" ? " (literal)" : ""})`);
|
|
364
|
+
} else if (r.repos.length > 1 || r.truncated) {
|
|
365
|
+
lines.push("");
|
|
366
|
+
const summary = `${r.total_matches} match${r.total_matches === 1 ? "" : "es"} across ${r.total_files} file${r.total_files === 1 ? "" : "s"}`;
|
|
367
|
+
const tail = r.truncated ? " (truncated; use --limit)" : "";
|
|
368
|
+
lines.push(`${summary}${tail} (${r.elapsed_ms}ms)`);
|
|
369
|
+
}
|
|
370
|
+
return lines.join("\n");
|
|
371
|
+
}
|