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,509 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { extname, resolve } from "node:path";
|
|
3
|
+
import { resolveBinName } from "../core/config.js";
|
|
4
|
+
/**
|
|
5
|
+
* `typescript` is a devDependency, not a runtime dependency, so it is loaded
|
|
6
|
+
* lazily here and only when outlining a TS/JS file. A static top-level import
|
|
7
|
+
* would make the whole CLI fail to boot for an end user who installed harnery
|
|
8
|
+
* without dev deps (every command is registered at startup). PHP/Python
|
|
9
|
+
* outlines use regex and never touch this.
|
|
10
|
+
*/
|
|
11
|
+
async function loadTypeScript() {
|
|
12
|
+
try {
|
|
13
|
+
return (await import("typescript"));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
throw new Error("outlining TS/JS files needs the `typescript` package; install it (npm i -D typescript) or use outline on PHP/Python files");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function registerOutlineCommand(program, emit) {
|
|
20
|
+
program
|
|
21
|
+
.command("outline <file>")
|
|
22
|
+
.description(`Print the structural skeleton of a code file (imports + top-level decls + line numbers). Supports TS/JS/TSX/JSX (AST), PHP/Python (regex). Use \`${resolveBinName()} toc\` for markdown.`)
|
|
23
|
+
.option("--json", "Structured JSON envelope")
|
|
24
|
+
.option("--exports-only", "Only show exported symbols")
|
|
25
|
+
.option("--no-imports", "Skip the imports summary block")
|
|
26
|
+
.option("--no-members", "Don't expand class/interface members")
|
|
27
|
+
.action(async (file, opts) => {
|
|
28
|
+
try {
|
|
29
|
+
const result = await runOutline(file, opts);
|
|
30
|
+
if (opts.json) {
|
|
31
|
+
emit.config({ format: "json" });
|
|
32
|
+
emit.data(result);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
emit.text(`${renderOutline(result, opts)}\n`);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
emit.error({ code: "outline_failed", message: err.message });
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function runOutline(file, opts) {
|
|
44
|
+
const absPath = resolve(file);
|
|
45
|
+
if (!existsSync(absPath))
|
|
46
|
+
throw new Error(`no such file: ${file}`);
|
|
47
|
+
const content = readFileSync(absPath, "utf8");
|
|
48
|
+
const total_lines = content.split("\n").length;
|
|
49
|
+
const ext = extname(absPath).toLowerCase();
|
|
50
|
+
let language = "";
|
|
51
|
+
let parsed;
|
|
52
|
+
if ([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"].includes(ext)) {
|
|
53
|
+
language = ext.slice(1);
|
|
54
|
+
parsed = await outlineTypeScript(content, absPath, ext);
|
|
55
|
+
}
|
|
56
|
+
else if (ext === ".php") {
|
|
57
|
+
language = "php";
|
|
58
|
+
parsed = outlinePhp(content);
|
|
59
|
+
}
|
|
60
|
+
else if (ext === ".py") {
|
|
61
|
+
language = "python";
|
|
62
|
+
parsed = outlinePython(content);
|
|
63
|
+
}
|
|
64
|
+
else if ([".md", ".mdx"].includes(ext)) {
|
|
65
|
+
throw new Error(`use \`${resolveBinName()} toc ${file}\` for markdown files`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new Error(`unsupported file type: ${ext || "(no extension)"} (supported: ts/tsx/js/jsx/php/py)`);
|
|
69
|
+
}
|
|
70
|
+
if (opts.exportsOnly) {
|
|
71
|
+
parsed.symbols = parsed.symbols.filter((s) => s.exported);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
file,
|
|
75
|
+
language,
|
|
76
|
+
total_lines,
|
|
77
|
+
imports: parsed.imports,
|
|
78
|
+
symbols: parsed.symbols,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async function outlineTypeScript(content, path, ext) {
|
|
82
|
+
const ts = await loadTypeScript();
|
|
83
|
+
const isTsx = ext === ".tsx" || ext === ".jsx";
|
|
84
|
+
const scriptKind = isTsx ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
85
|
+
const source = ts.createSourceFile(path, content, ts.ScriptTarget.Latest, true, scriptKind);
|
|
86
|
+
const imports = [];
|
|
87
|
+
const symbols = [];
|
|
88
|
+
const lineOf = (node) => source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1;
|
|
89
|
+
const text = (node) => content.slice(node.getStart(source), node.getEnd()).replace(/\s+/g, " ").trim();
|
|
90
|
+
const isExported = (node) => {
|
|
91
|
+
const mods = node.modifiers;
|
|
92
|
+
return mods?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword) ?? false;
|
|
93
|
+
};
|
|
94
|
+
for (const stmt of source.statements) {
|
|
95
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
96
|
+
const moduleSpec = stmt.moduleSpecifier.text;
|
|
97
|
+
const clause = stmt.importClause;
|
|
98
|
+
const isTypeOnly = clause?.isTypeOnly ? "type " : "";
|
|
99
|
+
let what = "";
|
|
100
|
+
if (clause?.name)
|
|
101
|
+
what = clause.name.text;
|
|
102
|
+
if (clause?.namedBindings) {
|
|
103
|
+
if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
104
|
+
what = `${what ? `${what}, ` : ""}* as ${clause.namedBindings.name.text}`;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const names = clause.namedBindings.elements.map((e) => e.name.text).join(", ");
|
|
108
|
+
what = `${what ? `${what}, ` : ""}{${names}}`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
imports.push(`${isTypeOnly}${what || "(side-effect)"} from "${moduleSpec}"`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const exported = isExported(stmt);
|
|
115
|
+
if (ts.isFunctionDeclaration(stmt) && stmt.name) {
|
|
116
|
+
symbols.push({
|
|
117
|
+
kind: "function",
|
|
118
|
+
name: stmt.name.text,
|
|
119
|
+
signature: renderFnSig(ts, stmt, content, source),
|
|
120
|
+
line: lineOf(stmt),
|
|
121
|
+
exported,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else if (ts.isClassDeclaration(stmt) && stmt.name) {
|
|
125
|
+
const heritage = (stmt.heritageClauses || [])
|
|
126
|
+
.map((h) => (h.token === ts.SyntaxKind.ExtendsKeyword ? "extends " : "implements ") +
|
|
127
|
+
h.types.map((t) => text(t.expression)).join(", "))
|
|
128
|
+
.join(" ");
|
|
129
|
+
const members = [];
|
|
130
|
+
for (const member of stmt.members) {
|
|
131
|
+
if (ts.isMethodDeclaration(member) && member.name) {
|
|
132
|
+
members.push({
|
|
133
|
+
kind: "method",
|
|
134
|
+
name: member.name.text || text(member.name),
|
|
135
|
+
signature: renderFnSig(ts, member, content, source),
|
|
136
|
+
line: lineOf(member),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else if (ts.isConstructorDeclaration(member)) {
|
|
140
|
+
members.push({
|
|
141
|
+
kind: "method",
|
|
142
|
+
name: "constructor",
|
|
143
|
+
signature: renderFnSig(ts, member, content, source),
|
|
144
|
+
line: lineOf(member),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else if (ts.isPropertyDeclaration(member) && member.name) {
|
|
148
|
+
members.push({
|
|
149
|
+
kind: "property",
|
|
150
|
+
name: member.name.text || text(member.name),
|
|
151
|
+
signature: member.type ? `: ${text(member.type)}` : "",
|
|
152
|
+
line: lineOf(member),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
symbols.push({
|
|
157
|
+
kind: "class",
|
|
158
|
+
name: stmt.name.text,
|
|
159
|
+
signature: heritage,
|
|
160
|
+
line: lineOf(stmt),
|
|
161
|
+
exported,
|
|
162
|
+
members,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else if (ts.isInterfaceDeclaration(stmt)) {
|
|
166
|
+
const heritage = (stmt.heritageClauses || [])
|
|
167
|
+
.flatMap((h) => h.types.map((t) => text(t.expression)))
|
|
168
|
+
.join(", ");
|
|
169
|
+
const members = [];
|
|
170
|
+
for (const member of stmt.members) {
|
|
171
|
+
if (ts.isPropertySignature(member) && member.name) {
|
|
172
|
+
members.push({
|
|
173
|
+
kind: "property",
|
|
174
|
+
name: member.name.text || text(member.name),
|
|
175
|
+
signature: member.type ? `: ${text(member.type)}` : "",
|
|
176
|
+
line: lineOf(member),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else if (ts.isMethodSignature(member) && member.name) {
|
|
180
|
+
members.push({
|
|
181
|
+
kind: "method",
|
|
182
|
+
name: member.name.text || text(member.name),
|
|
183
|
+
signature: renderFnSig(ts, member, content, source),
|
|
184
|
+
line: lineOf(member),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
symbols.push({
|
|
189
|
+
kind: "interface",
|
|
190
|
+
name: stmt.name.text,
|
|
191
|
+
signature: heritage ? `extends ${heritage}` : "",
|
|
192
|
+
line: lineOf(stmt),
|
|
193
|
+
exported,
|
|
194
|
+
members,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else if (ts.isTypeAliasDeclaration(stmt)) {
|
|
198
|
+
const sigText = text(stmt.type);
|
|
199
|
+
symbols.push({
|
|
200
|
+
kind: "type",
|
|
201
|
+
name: stmt.name.text,
|
|
202
|
+
signature: `= ${sigText.slice(0, 80)}${sigText.length > 80 ? "…" : ""}`,
|
|
203
|
+
line: lineOf(stmt),
|
|
204
|
+
exported,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
else if (ts.isEnumDeclaration(stmt)) {
|
|
208
|
+
symbols.push({
|
|
209
|
+
kind: "enum",
|
|
210
|
+
name: stmt.name.text,
|
|
211
|
+
line: lineOf(stmt),
|
|
212
|
+
exported,
|
|
213
|
+
members: stmt.members.map((m) => ({
|
|
214
|
+
kind: "enumMember",
|
|
215
|
+
name: m.name.text || text(m.name),
|
|
216
|
+
line: lineOf(m),
|
|
217
|
+
})),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else if (ts.isVariableStatement(stmt)) {
|
|
221
|
+
const flags = stmt.declarationList.flags;
|
|
222
|
+
const isConst = (flags & ts.NodeFlags.Const) !== 0;
|
|
223
|
+
const isLet = (flags & ts.NodeFlags.Let) !== 0;
|
|
224
|
+
const kind = isConst ? "const" : isLet ? "let" : "var";
|
|
225
|
+
const stmtExported = isExported(stmt);
|
|
226
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
227
|
+
if (!ts.isIdentifier(decl.name))
|
|
228
|
+
continue;
|
|
229
|
+
let sig = "";
|
|
230
|
+
if (decl.type)
|
|
231
|
+
sig = `: ${text(decl.type)}`;
|
|
232
|
+
else if (decl.initializer &&
|
|
233
|
+
(ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer))) {
|
|
234
|
+
sig = renderFnSig(ts, decl.initializer, content, source);
|
|
235
|
+
}
|
|
236
|
+
symbols.push({
|
|
237
|
+
kind,
|
|
238
|
+
name: decl.name.text,
|
|
239
|
+
signature: sig,
|
|
240
|
+
line: lineOf(decl),
|
|
241
|
+
exported: stmtExported,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
246
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
247
|
+
const names = stmt.exportClause.elements.map((e) => e.name.text).join(", ");
|
|
248
|
+
const fromText = stmt.moduleSpecifier
|
|
249
|
+
? ` from "${stmt.moduleSpecifier.text}"`
|
|
250
|
+
: "";
|
|
251
|
+
symbols.push({
|
|
252
|
+
kind: "re-export",
|
|
253
|
+
name: `{${names}}${fromText}`,
|
|
254
|
+
line: lineOf(stmt),
|
|
255
|
+
exported: true,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
else if (stmt.moduleSpecifier) {
|
|
259
|
+
symbols.push({
|
|
260
|
+
kind: "re-export",
|
|
261
|
+
name: `* from "${stmt.moduleSpecifier.text}"`,
|
|
262
|
+
line: lineOf(stmt),
|
|
263
|
+
exported: true,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else if (ts.isModuleDeclaration(stmt) && stmt.name) {
|
|
268
|
+
symbols.push({
|
|
269
|
+
kind: "namespace",
|
|
270
|
+
name: stmt.name.text || text(stmt.name),
|
|
271
|
+
line: lineOf(stmt),
|
|
272
|
+
exported,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return { imports, symbols };
|
|
277
|
+
}
|
|
278
|
+
function renderFnSig(ts, fn, content, source) {
|
|
279
|
+
const params = (fn.parameters || [])
|
|
280
|
+
.map((p) => {
|
|
281
|
+
const name = ts.isIdentifier(p.name)
|
|
282
|
+
? p.name.text
|
|
283
|
+
: content.slice(p.name.getStart(source), p.name.getEnd());
|
|
284
|
+
const type = p.type
|
|
285
|
+
? content.slice(p.type.getStart(source), p.type.getEnd()).replace(/\s+/g, " ").trim()
|
|
286
|
+
: "";
|
|
287
|
+
const optional = p.questionToken ? "?" : "";
|
|
288
|
+
return type ? `${name}${optional}: ${type}` : `${name}${optional}`;
|
|
289
|
+
})
|
|
290
|
+
.join(", ");
|
|
291
|
+
const ret = fn.type
|
|
292
|
+
? `: ${content.slice(fn.type.getStart(source), fn.type.getEnd()).replace(/\s+/g, " ").trim()}`
|
|
293
|
+
: "";
|
|
294
|
+
return `(${params})${ret}`;
|
|
295
|
+
}
|
|
296
|
+
function outlinePhp(content) {
|
|
297
|
+
const lines = content.split("\n");
|
|
298
|
+
const imports = [];
|
|
299
|
+
const symbols = [];
|
|
300
|
+
let currentContainer = null;
|
|
301
|
+
for (let i = 0; i < lines.length; i++) {
|
|
302
|
+
const line = lines[i];
|
|
303
|
+
const lineNum = i + 1;
|
|
304
|
+
const trimmed = line.trim();
|
|
305
|
+
const isIndented = /^[ \t]/.test(line);
|
|
306
|
+
if (trimmed === "" ||
|
|
307
|
+
trimmed.startsWith("//") ||
|
|
308
|
+
trimmed.startsWith("#") ||
|
|
309
|
+
trimmed.startsWith("*") ||
|
|
310
|
+
trimmed.startsWith("/*"))
|
|
311
|
+
continue;
|
|
312
|
+
const nsMatch = trimmed.match(/^namespace\s+([\w\\]+)\s*;/);
|
|
313
|
+
if (nsMatch && !isIndented) {
|
|
314
|
+
symbols.push({ kind: "namespace", name: nsMatch[1], line: lineNum });
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
const useMatch = trimmed.match(/^use\s+([\w\\]+)(?:\s+as\s+(\w+))?\s*;/);
|
|
318
|
+
if (useMatch && !isIndented) {
|
|
319
|
+
imports.push(useMatch[2] ? `${useMatch[1]} as ${useMatch[2]}` : useMatch[1]);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
if (!isIndented) {
|
|
323
|
+
const classMatch = trimmed.match(/^(?:abstract\s+|final\s+)?class\s+(\w+)(?:\s+extends\s+(\w+))?(?:\s+implements\s+([\w,\s]+))?/);
|
|
324
|
+
if (classMatch) {
|
|
325
|
+
currentContainer = {
|
|
326
|
+
kind: "class",
|
|
327
|
+
name: classMatch[1],
|
|
328
|
+
signature: [
|
|
329
|
+
classMatch[2] ? `extends ${classMatch[2]}` : "",
|
|
330
|
+
classMatch[3] ? `implements ${classMatch[3].trim()}` : "",
|
|
331
|
+
]
|
|
332
|
+
.filter(Boolean)
|
|
333
|
+
.join(" "),
|
|
334
|
+
line: lineNum,
|
|
335
|
+
members: [],
|
|
336
|
+
};
|
|
337
|
+
symbols.push(currentContainer);
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const interfaceMatch = trimmed.match(/^interface\s+(\w+)/);
|
|
341
|
+
if (interfaceMatch) {
|
|
342
|
+
currentContainer = {
|
|
343
|
+
kind: "interface",
|
|
344
|
+
name: interfaceMatch[1],
|
|
345
|
+
line: lineNum,
|
|
346
|
+
members: [],
|
|
347
|
+
};
|
|
348
|
+
symbols.push(currentContainer);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
const traitMatch = trimmed.match(/^trait\s+(\w+)/);
|
|
352
|
+
if (traitMatch) {
|
|
353
|
+
currentContainer = { kind: "trait", name: traitMatch[1], line: lineNum, members: [] };
|
|
354
|
+
symbols.push(currentContainer);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const fnMatch = trimmed.match(/^(?:public\s+|private\s+|protected\s+)?(?:static\s+)?function\s+(\w+)\s*\(([^)]*)\)/);
|
|
359
|
+
if (fnMatch) {
|
|
360
|
+
const entry = {
|
|
361
|
+
kind: isIndented && currentContainer ? "method" : "function",
|
|
362
|
+
name: fnMatch[1],
|
|
363
|
+
signature: `(${fnMatch[2].trim()})`,
|
|
364
|
+
line: lineNum,
|
|
365
|
+
};
|
|
366
|
+
if (isIndented && currentContainer) {
|
|
367
|
+
currentContainer.members.push(entry);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
symbols.push(entry);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return { imports, symbols };
|
|
375
|
+
}
|
|
376
|
+
function outlinePython(content) {
|
|
377
|
+
const lines = content.split("\n");
|
|
378
|
+
const imports = [];
|
|
379
|
+
const symbols = [];
|
|
380
|
+
let currentClass = null;
|
|
381
|
+
for (let i = 0; i < lines.length; i++) {
|
|
382
|
+
const line = lines[i];
|
|
383
|
+
const lineNum = i + 1;
|
|
384
|
+
const trimmed = line.trim();
|
|
385
|
+
const indent = line.match(/^ */)[0].length;
|
|
386
|
+
if (trimmed === "" || trimmed.startsWith("#"))
|
|
387
|
+
continue;
|
|
388
|
+
const importMatch = trimmed.match(/^import\s+(.+)$/);
|
|
389
|
+
const fromMatch = trimmed.match(/^from\s+(\S+)\s+import\s+(.+)$/);
|
|
390
|
+
if (importMatch && indent === 0) {
|
|
391
|
+
imports.push(importMatch[1]);
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (fromMatch && indent === 0) {
|
|
395
|
+
imports.push(`${fromMatch[2].trim()} from ${fromMatch[1]}`);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const classMatch = trimmed.match(/^class\s+(\w+)(?:\(([^)]*)\))?:/);
|
|
399
|
+
if (classMatch && indent === 0) {
|
|
400
|
+
currentClass = {
|
|
401
|
+
kind: "class",
|
|
402
|
+
name: classMatch[1],
|
|
403
|
+
signature: classMatch[2] ? `(${classMatch[2]})` : "",
|
|
404
|
+
line: lineNum,
|
|
405
|
+
members: [],
|
|
406
|
+
};
|
|
407
|
+
symbols.push(currentClass);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
const methodMatch = trimmed.match(/^(?:async\s+)?def\s+(\w+)\s*\(([^)]*)\)/);
|
|
411
|
+
if (methodMatch) {
|
|
412
|
+
if (indent === 0) {
|
|
413
|
+
symbols.push({
|
|
414
|
+
kind: "function",
|
|
415
|
+
name: methodMatch[1],
|
|
416
|
+
signature: `(${methodMatch[2].trim()})`,
|
|
417
|
+
line: lineNum,
|
|
418
|
+
});
|
|
419
|
+
currentClass = null;
|
|
420
|
+
}
|
|
421
|
+
else if (currentClass) {
|
|
422
|
+
currentClass.members.push({
|
|
423
|
+
kind: "method",
|
|
424
|
+
name: methodMatch[1],
|
|
425
|
+
signature: `(${methodMatch[2].trim()})`,
|
|
426
|
+
line: lineNum,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if (indent === 0 && trimmed.length > 0 && currentClass) {
|
|
432
|
+
currentClass = null;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return { imports, symbols };
|
|
436
|
+
}
|
|
437
|
+
function renderOutline(r, opts) {
|
|
438
|
+
const lines = [];
|
|
439
|
+
const symbolCount = r.symbols.length;
|
|
440
|
+
lines.push(`outline · ${r.file} (${r.language}, ${r.total_lines} lines, ${symbolCount} top-level symbol${symbolCount === 1 ? "" : "s"})`);
|
|
441
|
+
if (opts.imports !== false && r.imports.length > 0) {
|
|
442
|
+
lines.push("");
|
|
443
|
+
if (r.imports.length <= 4) {
|
|
444
|
+
lines.push(`imports: ${r.imports.join(" · ")}`);
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
lines.push(`imports (${r.imports.length}):`);
|
|
448
|
+
for (const imp of r.imports)
|
|
449
|
+
lines.push(` ${imp}`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (r.symbols.length > 0) {
|
|
453
|
+
lines.push("");
|
|
454
|
+
for (const sym of r.symbols) {
|
|
455
|
+
lines.push(renderSymbol(sym, 0, opts));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
lines.push("");
|
|
460
|
+
lines.push("(no top-level symbols)");
|
|
461
|
+
}
|
|
462
|
+
return lines.join("\n");
|
|
463
|
+
}
|
|
464
|
+
function renderSymbol(s, depth, opts) {
|
|
465
|
+
const indent = " ".repeat(depth);
|
|
466
|
+
const lineMark = `L${s.line}`.padEnd(6);
|
|
467
|
+
const exp = s.exported ? "★ " : " ";
|
|
468
|
+
const kindAbbr = kindToAbbr(s.kind);
|
|
469
|
+
const sig = s.signature ? ` ${s.signature}` : "";
|
|
470
|
+
const head = `${indent}${exp}${lineMark} ${kindAbbr} ${s.name}${sig}`;
|
|
471
|
+
if (opts.members !== false && s.members && s.members.length > 0) {
|
|
472
|
+
return [head, ...s.members.map((m) => renderSymbol(m, depth + 1, opts))].join("\n");
|
|
473
|
+
}
|
|
474
|
+
return head;
|
|
475
|
+
}
|
|
476
|
+
function kindToAbbr(kind) {
|
|
477
|
+
switch (kind) {
|
|
478
|
+
case "function":
|
|
479
|
+
return "fn ";
|
|
480
|
+
case "class":
|
|
481
|
+
return "cl ";
|
|
482
|
+
case "interface":
|
|
483
|
+
return "if ";
|
|
484
|
+
case "type":
|
|
485
|
+
return "ty ";
|
|
486
|
+
case "const":
|
|
487
|
+
return "ct ";
|
|
488
|
+
case "let":
|
|
489
|
+
return "let ";
|
|
490
|
+
case "var":
|
|
491
|
+
return "var ";
|
|
492
|
+
case "enum":
|
|
493
|
+
return "en ";
|
|
494
|
+
case "enumMember":
|
|
495
|
+
return "em ";
|
|
496
|
+
case "method":
|
|
497
|
+
return "mt ";
|
|
498
|
+
case "property":
|
|
499
|
+
return "pr ";
|
|
500
|
+
case "namespace":
|
|
501
|
+
return "ns ";
|
|
502
|
+
case "trait":
|
|
503
|
+
return "tr ";
|
|
504
|
+
case "re-export":
|
|
505
|
+
return "rx ";
|
|
506
|
+
default:
|
|
507
|
+
return kind.slice(0, 4).padEnd(4);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { EmitContext } from "../commander.js";
|
|
3
|
+
/**
|
|
4
|
+
* `presence`: mobile/office state for agents (~/.claude/presence).
|
|
5
|
+
*
|
|
6
|
+
* Uses the injected EmitContext so composed and standalone consumers share
|
|
7
|
+
* one code path. The state file path is Claude-Code-specific (lives under
|
|
8
|
+
* ~/.claude/) but the detect/set/clear logic is generic: any agent harness
|
|
9
|
+
* can adopt the same convention.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerPresenceCommand(program: Command, emit: EmitContext): void;
|
|
12
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presence.d.ts","sourceRoot":"","sources":["../../src/commands/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkBnD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,CAoFjF"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { emitCanonical, normalizeHarness, readHeartbeat, resolveOwner, } from "../core/agents/index.js";
|
|
2
|
+
import { ageSeconds, applyDetection, clearPresence, formatAge, presenceFilePath, readPresence, writePresence, } from "../lib/presence.js";
|
|
3
|
+
/**
|
|
4
|
+
* `presence`: mobile/office state for agents (~/.claude/presence).
|
|
5
|
+
*
|
|
6
|
+
* Uses the injected EmitContext so composed and standalone consumers share
|
|
7
|
+
* one code path. The state file path is Claude-Code-specific (lives under
|
|
8
|
+
* ~/.claude/) but the detect/set/clear logic is generic: any agent harness
|
|
9
|
+
* can adopt the same convention.
|
|
10
|
+
*/
|
|
11
|
+
export function registerPresenceCommand(program, emit) {
|
|
12
|
+
const cmd = program
|
|
13
|
+
.command("presence")
|
|
14
|
+
.description("Mobile/office state for agents (~/.claude/presence)")
|
|
15
|
+
.action(() => {
|
|
16
|
+
printStatus(emit);
|
|
17
|
+
});
|
|
18
|
+
cmd
|
|
19
|
+
.command("get")
|
|
20
|
+
.description('Print just the state ("mobile" / "office"), or full record with --json')
|
|
21
|
+
.option("--json", "Print the full record as JSON")
|
|
22
|
+
.action((opts) => {
|
|
23
|
+
const r = readPresence();
|
|
24
|
+
if (opts.json) {
|
|
25
|
+
emit.config({ format: "json" });
|
|
26
|
+
emit.data({
|
|
27
|
+
state: r.state,
|
|
28
|
+
updated_at: r.updated_at,
|
|
29
|
+
source: r.source,
|
|
30
|
+
is_default: r.is_default,
|
|
31
|
+
path: presenceFilePath(),
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
emit.text(`${r.state}\n`);
|
|
36
|
+
});
|
|
37
|
+
cmd
|
|
38
|
+
.command("set")
|
|
39
|
+
.argument("<state>", "mobile | office")
|
|
40
|
+
.description("Set state explicitly (source=cli). Hook auto-detection can still overwrite.")
|
|
41
|
+
.action((state) => {
|
|
42
|
+
if (state !== "mobile" && state !== "office") {
|
|
43
|
+
emit.error({
|
|
44
|
+
code: "invalid_state",
|
|
45
|
+
message: `state must be "mobile" or "office" (got: ${JSON.stringify(state)})`,
|
|
46
|
+
});
|
|
47
|
+
process.exit(2);
|
|
48
|
+
}
|
|
49
|
+
const before = readPresence();
|
|
50
|
+
writePresence(state, "cli");
|
|
51
|
+
emitPresenceChange(before.state, state, "cli");
|
|
52
|
+
printStatus(emit);
|
|
53
|
+
});
|
|
54
|
+
cmd
|
|
55
|
+
.command("clear")
|
|
56
|
+
.description('Delete the state file (next read returns the default, "office")')
|
|
57
|
+
.action(() => {
|
|
58
|
+
const removed = clearPresence();
|
|
59
|
+
emit.data({
|
|
60
|
+
ok: true,
|
|
61
|
+
removed,
|
|
62
|
+
path: presenceFilePath(),
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
cmd
|
|
66
|
+
.command("detect")
|
|
67
|
+
.description("Internal: read prompt text from stdin, apply detection rules, update state if signal is clear")
|
|
68
|
+
.option("--from-stdin", "Read prompt from stdin (the only supported input mode today)")
|
|
69
|
+
.option("--verbose", "Print the detection result to stderr")
|
|
70
|
+
.action(async (opts) => {
|
|
71
|
+
const prompt = await readStdin();
|
|
72
|
+
if (!prompt) {
|
|
73
|
+
if (opts.verbose)
|
|
74
|
+
emit.log("(no input on stdin; skipping)", "info");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const result = applyDetection(prompt);
|
|
78
|
+
if (opts.verbose) {
|
|
79
|
+
emit.log(JSON.stringify({
|
|
80
|
+
detected: result.detected,
|
|
81
|
+
before: result.before,
|
|
82
|
+
after: result.after,
|
|
83
|
+
changed: result.changed,
|
|
84
|
+
}), "info");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function printStatus(emit) {
|
|
89
|
+
const r = readPresence();
|
|
90
|
+
emit.data({
|
|
91
|
+
state: r.state,
|
|
92
|
+
updated_at: r.updated_at,
|
|
93
|
+
source: r.source,
|
|
94
|
+
is_default: r.is_default,
|
|
95
|
+
age_seconds: r.is_default ? null : ageSeconds(r.updated_at),
|
|
96
|
+
age_human: r.is_default ? "(default: file missing)" : formatAge(ageSeconds(r.updated_at)),
|
|
97
|
+
path: presenceFilePath(),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function readStdin() {
|
|
101
|
+
if (process.stdin.isTTY)
|
|
102
|
+
return "";
|
|
103
|
+
const chunks = [];
|
|
104
|
+
for await (const chunk of process.stdin) {
|
|
105
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
106
|
+
}
|
|
107
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
108
|
+
}
|
|
109
|
+
function emitPresenceChange(from, to, source) {
|
|
110
|
+
if (from === to)
|
|
111
|
+
return;
|
|
112
|
+
const owner = resolveOwner();
|
|
113
|
+
if (!owner)
|
|
114
|
+
return;
|
|
115
|
+
const hb = readHeartbeat(owner);
|
|
116
|
+
emitCanonical({
|
|
117
|
+
type: "state.presence_change",
|
|
118
|
+
owner,
|
|
119
|
+
session: hb?.session_id ?? owner,
|
|
120
|
+
harness: normalizeHarness(hb?.platform),
|
|
121
|
+
data: { from, to, source },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { EmitContext } from "../commander.js";
|
|
3
|
+
/**
|
|
4
|
+
* `harn read`: extract clean readable markdown from HTML.
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerReadCommand(program: Command, emitParam: EmitContext): void;
|
|
7
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/commands/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQnD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,CAwBlF"}
|