nikcli 0.0.6
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/.turbo/turbo-typecheck.log +1 -0
- package/AGENTS.md +27 -0
- package/Dockerfile +18 -0
- package/README.md +15 -0
- package/bin/nikcli +84 -0
- package/config.json +13 -0
- package/docs/tailscale-mobile/01-tailscale-setup.md +94 -0
- package/docs/tailscale-mobile/02-host-setup.md +115 -0
- package/docs/tailscale-mobile/03-phone-and-serve.md +134 -0
- package/docs/tailscale-mobile/README.md +59 -0
- package/examples/README.md +54 -0
- package/package.json +147 -0
- package/parsers-config.ts +253 -0
- package/script/build.ts +179 -0
- package/script/postinstall.mjs +125 -0
- package/script/publish-registries.ts +187 -0
- package/script/publish.ts +100 -0
- package/script/schema.ts +47 -0
- package/script/seed-e2e.ts +50 -0
- package/sequential-prancing-forest.md +373 -0
- package/src/acp/README.md +164 -0
- package/src/acp/agent.ts +1303 -0
- package/src/acp/session.ts +105 -0
- package/src/acp/types.ts +22 -0
- package/src/agent/agent.ts +528 -0
- package/src/agent/generate.txt +32 -0
- package/src/agent/prompt/compaction.txt +14 -0
- package/src/agent/prompt/explore.txt +18 -0
- package/src/agent/prompt/summary.txt +11 -0
- package/src/agent/prompt/title.txt +44 -0
- package/src/auth/index.ts +73 -0
- package/src/bun/index.ts +119 -0
- package/src/bun/registry.ts +54 -0
- package/src/bus/bus-event.ts +43 -0
- package/src/bus/global.ts +10 -0
- package/src/bus/index.ts +105 -0
- package/src/chatbot/handlers.ts +150 -0
- package/src/chatbot/index.ts +132 -0
- package/src/cli/bootstrap.ts +17 -0
- package/src/cli/cmd/acp.ts +69 -0
- package/src/cli/cmd/ads.ts +377 -0
- package/src/cli/cmd/agent.ts +259 -0
- package/src/cli/cmd/auth.ts +400 -0
- package/src/cli/cmd/chatbot.ts +420 -0
- package/src/cli/cmd/cmd.ts +7 -0
- package/src/cli/cmd/companion.ts +81 -0
- package/src/cli/cmd/connectors.ts +593 -0
- package/src/cli/cmd/debug/agent.ts +166 -0
- package/src/cli/cmd/debug/config.ts +16 -0
- package/src/cli/cmd/debug/file.ts +97 -0
- package/src/cli/cmd/debug/index.ts +48 -0
- package/src/cli/cmd/debug/lsp.ts +52 -0
- package/src/cli/cmd/debug/ripgrep.ts +87 -0
- package/src/cli/cmd/debug/scrap.ts +16 -0
- package/src/cli/cmd/debug/skill.ts +16 -0
- package/src/cli/cmd/debug/snapshot.ts +52 -0
- package/src/cli/cmd/export.ts +88 -0
- package/src/cli/cmd/generate.ts +38 -0
- package/src/cli/cmd/github.ts +412 -0
- package/src/cli/cmd/image-model.ts +128 -0
- package/src/cli/cmd/import.ts +201 -0
- package/src/cli/cmd/lovable.ts +128 -0
- package/src/cli/cmd/mcp.ts +738 -0
- package/src/cli/cmd/mobile.ts +223 -0
- package/src/cli/cmd/models.ts +77 -0
- package/src/cli/cmd/plug.ts +231 -0
- package/src/cli/cmd/pr.ts +104 -0
- package/src/cli/cmd/rag-model.ts +167 -0
- package/src/cli/cmd/remote.ts +416 -0
- package/src/cli/cmd/run.ts +589 -0
- package/src/cli/cmd/serve.ts +51 -0
- package/src/cli/cmd/session.ts +133 -0
- package/src/cli/cmd/speak-model.ts +204 -0
- package/src/cli/cmd/stats.ts +402 -0
- package/src/cli/cmd/tui/app.tsx +841 -0
- package/src/cli/cmd/tui/attach.ts +31 -0
- package/src/cli/cmd/tui/component/border.tsx +75 -0
- package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-command.tsx +172 -0
- package/src/cli/cmd/tui/component/dialog-config.tsx +291 -0
- package/src/cli/cmd/tui/component/dialog-connectors.tsx +440 -0
- package/src/cli/cmd/tui/component/dialog-image-model.tsx +97 -0
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
- package/src/cli/cmd/tui/component/dialog-model.tsx +234 -0
- package/src/cli/cmd/tui/component/dialog-provider.tsx +260 -0
- package/src/cli/cmd/tui/component/dialog-rag-model.tsx +217 -0
- package/src/cli/cmd/tui/component/dialog-remote.tsx +489 -0
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +170 -0
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-settings/index.tsx +59 -0
- package/src/cli/cmd/tui/component/dialog-settings/prompt.tsx +40 -0
- package/src/cli/cmd/tui/component/dialog-settings/sidebar.tsx +39 -0
- package/src/cli/cmd/tui/component/dialog-settings/spinner.tsx +62 -0
- package/src/cli/cmd/tui/component/dialog-settings/ui.tsx +58 -0
- package/src/cli/cmd/tui/component/dialog-skills.tsx +117 -0
- package/src/cli/cmd/tui/component/dialog-speak-model.tsx +304 -0
- package/src/cli/cmd/tui/component/dialog-stash.tsx +87 -0
- package/src/cli/cmd/tui/component/dialog-status.tsx +165 -0
- package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
- package/src/cli/cmd/tui/component/dialog-theme-create.tsx +717 -0
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +52 -0
- package/src/cli/cmd/tui/component/dialog-workspace-list.tsx +350 -0
- package/src/cli/cmd/tui/component/error-component.tsx +91 -0
- package/src/cli/cmd/tui/component/logo.tsx +103 -0
- package/src/cli/cmd/tui/component/plugin-route-missing.tsx +14 -0
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +669 -0
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +89 -0
- package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
- package/src/cli/cmd/tui/component/prompt/index.tsx +2165 -0
- package/src/cli/cmd/tui/component/prompt/stash.tsx +63 -0
- package/src/cli/cmd/tui/component/spinner.tsx +24 -0
- package/src/cli/cmd/tui/component/startup-loading.tsx +63 -0
- package/src/cli/cmd/tui/component/table/markdown-table.tsx +267 -0
- package/src/cli/cmd/tui/component/table-db/db/connections.ts +75 -0
- package/src/cli/cmd/tui/component/table-db/db/db-connection.ts +223 -0
- package/src/cli/cmd/tui/component/table-db/db/db-preview.ts +202 -0
- package/src/cli/cmd/tui/component/table-db/db/factory.ts +77 -0
- package/src/cli/cmd/tui/component/table-db/db/index.ts +9 -0
- package/src/cli/cmd/tui/component/table-db/db/mysql-connection.ts +330 -0
- package/src/cli/cmd/tui/component/table-db/db/postgres-connection.ts +338 -0
- package/src/cli/cmd/tui/component/table-db/db/sqlite-connection.ts +302 -0
- package/src/cli/cmd/tui/component/table-db/db/types.ts +108 -0
- package/src/cli/cmd/tui/component/table-db/table/dbedit-hooks.ts +74 -0
- package/src/cli/cmd/tui/component/table-db/table/index.ts +15 -0
- package/src/cli/cmd/tui/component/table-db/table/table-events.ts +54 -0
- package/src/cli/cmd/tui/component/table-db/table/table-formatters.ts +191 -0
- package/src/cli/cmd/tui/component/table-db/table/table-hooks.ts +105 -0
- package/src/cli/cmd/tui/component/table-db/table/table-keyboard-handler.ts +255 -0
- package/src/cli/cmd/tui/component/table-db/table/table-layout-engine.ts +208 -0
- package/src/cli/cmd/tui/component/table-db/table/table-renderable.ts +486 -0
- package/src/cli/cmd/tui/component/table-db/table/table-selection-manager.ts +136 -0
- package/src/cli/cmd/tui/component/table-db/table/table-state.ts +198 -0
- package/src/cli/cmd/tui/component/table-db/table/types.ts +69 -0
- package/src/cli/cmd/tui/component/table-db/ui/db-visualizer.tsx +71 -0
- package/src/cli/cmd/tui/component/table-db/ui/index.ts +2 -0
- package/src/cli/cmd/tui/component/table-db/ui/table-renderer.ts +607 -0
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +73 -0
- package/src/cli/cmd/tui/component/tips.tsx +195 -0
- package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
- package/src/cli/cmd/tui/context/args.tsx +14 -0
- package/src/cli/cmd/tui/context/directory.ts +13 -0
- package/src/cli/cmd/tui/context/exit.tsx +24 -0
- package/src/cli/cmd/tui/context/helper.tsx +25 -0
- package/src/cli/cmd/tui/context/keybind.tsx +102 -0
- package/src/cli/cmd/tui/context/kv.tsx +52 -0
- package/src/cli/cmd/tui/context/local.tsx +458 -0
- package/src/cli/cmd/tui/context/plugin-keybinds.ts +41 -0
- package/src/cli/cmd/tui/context/prompt.tsx +18 -0
- package/src/cli/cmd/tui/context/route.tsx +54 -0
- package/src/cli/cmd/tui/context/sdk.tsx +128 -0
- package/src/cli/cmd/tui/context/server.tsx +8 -0
- package/src/cli/cmd/tui/context/sync.tsx +510 -0
- package/src/cli/cmd/tui/context/theme/abyss.json +233 -0
- package/src/cli/cmd/tui/context/theme/apple.json +235 -0
- package/src/cli/cmd/tui/context/theme/arctic.json +232 -0
- package/src/cli/cmd/tui/context/theme/aura.json +69 -0
- package/src/cli/cmd/tui/context/theme/ayu.json +80 -0
- package/src/cli/cmd/tui/context/theme/ayuai.json +229 -0
- package/src/cli/cmd/tui/context/theme/blood.json +229 -0
- package/src/cli/cmd/tui/context/theme/carbonfox.json +248 -0
- package/src/cli/cmd/tui/context/theme/catmoe.json +235 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-latte.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin.json +259 -0
- package/src/cli/cmd/tui/context/theme/charcoal.json +230 -0
- package/src/cli/cmd/tui/context/theme/chromatic.json +235 -0
- package/src/cli/cmd/tui/context/theme/cobalt2.json +228 -0
- package/src/cli/cmd/tui/context/theme/cosmic.json +234 -0
- package/src/cli/cmd/tui/context/theme/cursor.json +249 -0
- package/src/cli/cmd/tui/context/theme/cyber.json +235 -0
- package/src/cli/cmd/tui/context/theme/dawnfox.json +229 -0
- package/src/cli/cmd/tui/context/theme/dimension.json +235 -0
- package/src/cli/cmd/tui/context/theme/dracula-official.json +222 -0
- package/src/cli/cmd/tui/context/theme/dracula.json +219 -0
- package/src/cli/cmd/tui/context/theme/dream.json +235 -0
- package/src/cli/cmd/tui/context/theme/duo.json +235 -0
- package/src/cli/cmd/tui/context/theme/dusk.json +235 -0
- package/src/cli/cmd/tui/context/theme/ebony.json +232 -0
- package/src/cli/cmd/tui/context/theme/equilibrium.json +232 -0
- package/src/cli/cmd/tui/context/theme/ethereal.json +235 -0
- package/src/cli/cmd/tui/context/theme/everforest.json +241 -0
- package/src/cli/cmd/tui/context/theme/flexoki.json +237 -0
- package/src/cli/cmd/tui/context/theme/fusion.json +235 -0
- package/src/cli/cmd/tui/context/theme/ghost.json +235 -0
- package/src/cli/cmd/tui/context/theme/github-dark.json +229 -0
- package/src/cli/cmd/tui/context/theme/github-dimmed.json +231 -0
- package/src/cli/cmd/tui/context/theme/github-light.json +229 -0
- package/src/cli/cmd/tui/context/theme/github.json +233 -0
- package/src/cli/cmd/tui/context/theme/glass.json +235 -0
- package/src/cli/cmd/tui/context/theme/gold.json +235 -0
- package/src/cli/cmd/tui/context/theme/gone.json +234 -0
- package/src/cli/cmd/tui/context/theme/greyscale.json +229 -0
- package/src/cli/cmd/tui/context/theme/gruvbox.json +242 -0
- package/src/cli/cmd/tui/context/theme/hacker.json +229 -0
- package/src/cli/cmd/tui/context/theme/holo.json +235 -0
- package/src/cli/cmd/tui/context/theme/ink.json +235 -0
- package/src/cli/cmd/tui/context/theme/jet.json +233 -0
- package/src/cli/cmd/tui/context/theme/kanagawa.json +227 -0
- package/src/cli/cmd/tui/context/theme/lavender.json +236 -0
- package/src/cli/cmd/tui/context/theme/lightph.json +235 -0
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +237 -0
- package/src/cli/cmd/tui/context/theme/material-ocean.json +230 -0
- package/src/cli/cmd/tui/context/theme/material.json +235 -0
- package/src/cli/cmd/tui/context/theme/matrix.json +227 -0
- package/src/cli/cmd/tui/context/theme/mercury.json +245 -0
- package/src/cli/cmd/tui/context/theme/midnight.json +235 -0
- package/src/cli/cmd/tui/context/theme/modern.json +235 -0
- package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
- package/src/cli/cmd/tui/context/theme/muted.json +229 -0
- package/src/cli/cmd/tui/context/theme/neon.json +229 -0
- package/src/cli/cmd/tui/context/theme/neonfusion.json +235 -0
- package/src/cli/cmd/tui/context/theme/neutral.json +235 -0
- package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
- package/src/cli/cmd/tui/context/theme/nikcli.json +245 -0
- package/src/cli/cmd/tui/context/theme/nord.json +223 -0
- package/src/cli/cmd/tui/context/theme/nordic.json +235 -0
- package/src/cli/cmd/tui/context/theme/nova.json +235 -0
- package/src/cli/cmd/tui/context/theme/obsidian.json +234 -0
- package/src/cli/cmd/tui/context/theme/one-dark.json +231 -0
- package/src/cli/cmd/tui/context/theme/one-pro.json +229 -0
- package/src/cli/cmd/tui/context/theme/onyx.json +233 -0
- package/src/cli/cmd/tui/context/theme/orng.json +249 -0
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +240 -0
- package/src/cli/cmd/tui/context/theme/oxocarbon.json +229 -0
- package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
- package/src/cli/cmd/tui/context/theme/poimandres.json +230 -0
- package/src/cli/cmd/tui/context/theme/prism.json +235 -0
- package/src/cli/cmd/tui/context/theme/radiant.json +235 -0
- package/src/cli/cmd/tui/context/theme/rosepine.json +234 -0
- package/src/cli/cmd/tui/context/theme/shadow.json +235 -0
- package/src/cli/cmd/tui/context/theme/silicon.json +235 -0
- package/src/cli/cmd/tui/context/theme/slate.json +233 -0
- package/src/cli/cmd/tui/context/theme/soft.json +235 -0
- package/src/cli/cmd/tui/context/theme/solarized.json +223 -0
- package/src/cli/cmd/tui/context/theme/spectrum.json +235 -0
- package/src/cli/cmd/tui/context/theme/starlight.json +233 -0
- package/src/cli/cmd/tui/context/theme/sunrise.json +235 -0
- package/src/cli/cmd/tui/context/theme/synthwave84.json +226 -0
- package/src/cli/cmd/tui/context/theme/tech.json +235 -0
- package/src/cli/cmd/tui/context/theme/tokyonight-storm.json +245 -0
- package/src/cli/cmd/tui/context/theme/tokyonight.json +243 -0
- package/src/cli/cmd/tui/context/theme/vapor.json +235 -0
- package/src/cli/cmd/tui/context/theme/vercel.json +245 -0
- package/src/cli/cmd/tui/context/theme/vesper.json +218 -0
- package/src/cli/cmd/tui/context/theme/vivid.json +232 -0
- package/src/cli/cmd/tui/context/theme/void.json +235 -0
- package/src/cli/cmd/tui/context/theme/vscode.json +235 -0
- package/src/cli/cmd/tui/context/theme/zenburn.json +223 -0
- package/src/cli/cmd/tui/context/theme/zinc.json +236 -0
- package/src/cli/cmd/tui/context/theme.tsx +1303 -0
- package/src/cli/cmd/tui/event.ts +48 -0
- package/src/cli/cmd/tui/feature-plugins/home/tips-view.tsx +152 -0
- package/src/cli/cmd/tui/feature-plugins/home/tips.tsx +50 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx +63 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/files.tsx +62 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/footer.tsx +93 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/lsp.tsx +66 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/mcp.tsx +96 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/todo.tsx +48 -0
- package/src/cli/cmd/tui/feature-plugins/system/plugins.tsx +288 -0
- package/src/cli/cmd/tui/plugin/api.tsx +407 -0
- package/src/cli/cmd/tui/plugin/index.ts +3 -0
- package/src/cli/cmd/tui/plugin/internal.ts +25 -0
- package/src/cli/cmd/tui/plugin/runtime.ts +1048 -0
- package/src/cli/cmd/tui/plugin/slots.tsx +61 -0
- package/src/cli/cmd/tui/routes/home.tsx +153 -0
- package/src/cli/cmd/tui/routes/session/dbedit.tsx +474 -0
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +65 -0
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +110 -0
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +105 -0
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/cli/cmd/tui/routes/session/footer.tsx +75 -0
- package/src/cli/cmd/tui/routes/session/header.tsx +177 -0
- package/src/cli/cmd/tui/routes/session/index.tsx +2280 -0
- package/src/cli/cmd/tui/routes/session/permission.tsx +540 -0
- package/src/cli/cmd/tui/routes/session/question.tsx +435 -0
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +313 -0
- package/src/cli/cmd/tui/thread.ts +174 -0
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +57 -0
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +83 -0
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +204 -0
- package/src/cli/cmd/tui/ui/dialog-help.tsx +38 -0
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +102 -0
- package/src/cli/cmd/tui/ui/dialog-select.tsx +389 -0
- package/src/cli/cmd/tui/ui/dialog.tsx +180 -0
- package/src/cli/cmd/tui/ui/link.tsx +34 -0
- package/src/cli/cmd/tui/ui/spinner.ts +368 -0
- package/src/cli/cmd/tui/ui/toast.tsx +138 -0
- package/src/cli/cmd/tui/util/clipboard.ts +154 -0
- package/src/cli/cmd/tui/util/editor.ts +32 -0
- package/src/cli/cmd/tui/util/signal.ts +7 -0
- package/src/cli/cmd/tui/util/terminal.ts +114 -0
- package/src/cli/cmd/tui/util/transcript.ts +98 -0
- package/src/cli/cmd/tui/win32.ts +110 -0
- package/src/cli/cmd/tui/worker.ts +156 -0
- package/src/cli/cmd/uninstall.ts +357 -0
- package/src/cli/cmd/upgrade.ts +72 -0
- package/src/cli/cmd/web.ts +87 -0
- package/src/cli/cmd/workspace-serve.ts +16 -0
- package/src/cli/error.ts +57 -0
- package/src/cli/network.ts +55 -0
- package/src/cli/remote/index.ts +36 -0
- package/src/cli/remote/notifications.ts +104 -0
- package/src/cli/remote/qr-renderer.ts +86 -0
- package/src/cli/remote/remote-service.ts +757 -0
- package/src/cli/remote/session-manager.ts +284 -0
- package/src/cli/remote/subagent-hooks.ts +151 -0
- package/src/cli/remote/types.ts +121 -0
- package/src/cli/ui.ts +96 -0
- package/src/cli/upgrade.ts +25 -0
- package/src/command/index.ts +174 -0
- package/src/command/template/initialize.txt +10 -0
- package/src/command/template/review.txt +99 -0
- package/src/config/config.ts +1760 -0
- package/src/config/markdown.ts +88 -0
- package/src/config/migrate-tui-config.ts +155 -0
- package/src/config/paths.ts +174 -0
- package/src/config/tui-schema.ts +36 -0
- package/src/config/tui.ts +209 -0
- package/src/connectors/api/base.ts +75 -0
- package/src/connectors/api/figma.ts +103 -0
- package/src/connectors/api/github.ts +247 -0
- package/src/connectors/api/lovable.ts +126 -0
- package/src/connectors/api/slack.ts +137 -0
- package/src/connectors/auth.ts +68 -0
- package/src/connectors/cache.ts +119 -0
- package/src/connectors/credentials.ts +81 -0
- package/src/connectors/index.ts +202 -0
- package/src/connectors/registry.ts +358 -0
- package/src/docs/context.ts +120 -0
- package/src/docs/library.ts +189 -0
- package/src/env/index.ts +26 -0
- package/src/file/ignore.ts +83 -0
- package/src/file/index.ts +411 -0
- package/src/file/ripgrep.ts +402 -0
- package/src/file/time.ts +65 -0
- package/src/file/watcher.ts +127 -0
- package/src/flag/flag.ts +128 -0
- package/src/format/formatter.ts +356 -0
- package/src/format/index.ts +137 -0
- package/src/global/index.ts +57 -0
- package/src/id/id.ts +83 -0
- package/src/ide/index.ts +76 -0
- package/src/index.ts +184 -0
- package/src/installation/index.ts +246 -0
- package/src/lsp/client.ts +250 -0
- package/src/lsp/index.ts +483 -0
- package/src/lsp/language.ts +119 -0
- package/src/lsp/server.ts +2046 -0
- package/src/mcp/auth.ts +121 -0
- package/src/mcp/index.ts +860 -0
- package/src/mcp/oauth-callback.ts +198 -0
- package/src/mcp/oauth-provider.ts +148 -0
- package/src/mobile/auth.ts +97 -0
- package/src/mobile/github-repo.ts +185 -0
- package/src/patch/index.ts +631 -0
- package/src/permission/arity.ts +150 -0
- package/src/permission/dbedit.ts +236 -0
- package/src/permission/index.ts +210 -0
- package/src/permission/next.ts +287 -0
- package/src/plugin/codex.ts +493 -0
- package/src/plugin/copilot.ts +261 -0
- package/src/plugin/index.ts +714 -0
- package/src/plugin/install.ts +379 -0
- package/src/plugin/meta.ts +165 -0
- package/src/plugin/shared.ts +188 -0
- package/src/project/bootstrap.ts +35 -0
- package/src/project/instance.ts +84 -0
- package/src/project/project.ts +373 -0
- package/src/project/state.ts +66 -0
- package/src/project/vcs.ts +76 -0
- package/src/prompt/stash-store.ts +93 -0
- package/src/provider/auth.ts +147 -0
- package/src/provider/models-macro.ts +22 -0
- package/src/provider/models.ts +216 -0
- package/src/provider/provider.ts +1483 -0
- package/src/provider/sdk/openai-compatible/src/README.md +5 -0
- package/src/provider/sdk/openai-compatible/src/index.ts +2 -0
- package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +100 -0
- package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +303 -0
- package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +22 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +18 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +22 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +207 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +1732 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +177 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +1 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +88 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +128 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +115 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +65 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +104 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +103 -0
- package/src/provider/transform.ts +828 -0
- package/src/pty/index.ts +241 -0
- package/src/question/index.ts +171 -0
- package/src/rag/chunk.ts +43 -0
- package/src/rag/embed.ts +179 -0
- package/src/rag/index.ts +376 -0
- package/src/rag/storage.ts +76 -0
- package/src/scheduler/index.ts +61 -0
- package/src/server/error.ts +36 -0
- package/src/server/event.ts +7 -0
- package/src/server/mdns.ts +59 -0
- package/src/server/routes/chatbot.ts +205 -0
- package/src/server/routes/companion.ts +729 -0
- package/src/server/routes/config.ts +92 -0
- package/src/server/routes/connectors.ts +121 -0
- package/src/server/routes/dbedit.ts +76 -0
- package/src/server/routes/experimental.ts +210 -0
- package/src/server/routes/file.ts +197 -0
- package/src/server/routes/global.ts +135 -0
- package/src/server/routes/mcp.ts +225 -0
- package/src/server/routes/mobile.ts +2044 -0
- package/src/server/routes/permission.ts +68 -0
- package/src/server/routes/project.ts +82 -0
- package/src/server/routes/provider.ts +235 -0
- package/src/server/routes/pty.ts +169 -0
- package/src/server/routes/question.ts +98 -0
- package/src/server/routes/session.ts +968 -0
- package/src/server/routes/tui.ts +379 -0
- package/src/server/routes/workspace.ts +104 -0
- package/src/server/server.ts +761 -0
- package/src/server/ssh.ts +207 -0
- package/src/session/auth.ts +402 -0
- package/src/session/compaction.ts +253 -0
- package/src/session/generate.ts +38 -0
- package/src/session/index.ts +598 -0
- package/src/session/llm.ts +273 -0
- package/src/session/message-v2.ts +836 -0
- package/src/session/message.ts +189 -0
- package/src/session/processor.ts +408 -0
- package/src/session/prompt/anthropic-20250930.txt +165 -0
- package/src/session/prompt/anthropic.txt +105 -0
- package/src/session/prompt/anthropic_spoof.txt +1 -0
- package/src/session/prompt/beast.txt +147 -0
- package/src/session/prompt/build-switch.txt +5 -0
- package/src/session/prompt/codex_header.txt +79 -0
- package/src/session/prompt/copilot-gpt-5.txt +143 -0
- package/src/session/prompt/gemini.txt +155 -0
- package/src/session/prompt/max-steps.txt +16 -0
- package/src/session/prompt/plan-reminder-anthropic.txt +67 -0
- package/src/session/prompt/plan.txt +25 -0
- package/src/session/prompt/qwen.txt +108 -0
- package/src/session/prompt.ts +1942 -0
- package/src/session/retry.ts +90 -0
- package/src/session/revert.ts +120 -0
- package/src/session/stats.ts +404 -0
- package/src/session/status.ts +84 -0
- package/src/session/summary.ts +184 -0
- package/src/session/system.ts +195 -0
- package/src/session/toast.tsx +105 -0
- package/src/session/todo.ts +258 -0
- package/src/session/uninstall.ts +357 -0
- package/src/share/share-next.ts +421 -0
- package/src/share/share.ts +92 -0
- package/src/shell/shell.ts +65 -0
- package/src/skill/index.ts +1 -0
- package/src/skill/skill.ts +232 -0
- package/src/snapshot/index.ts +297 -0
- package/src/storage/storage.ts +227 -0
- package/src/tool/apply_patch.ts +288 -0
- package/src/tool/apply_patch.txt +33 -0
- package/src/tool/bash.ts +252 -0
- package/src/tool/bash.txt +115 -0
- package/src/tool/batch.ts +175 -0
- package/src/tool/batch.txt +24 -0
- package/src/tool/codesearch.ts +132 -0
- package/src/tool/codesearch.txt +12 -0
- package/src/tool/context_collect.ts +152 -0
- package/src/tool/context_collect.txt +9 -0
- package/src/tool/context_diagnostics.ts +81 -0
- package/src/tool/context_diagnostics.txt +5 -0
- package/src/tool/context_related.ts +117 -0
- package/src/tool/context_related.txt +5 -0
- package/src/tool/context_search.ts +108 -0
- package/src/tool/context_search.txt +8 -0
- package/src/tool/db-diff.ts +434 -0
- package/src/tool/db-table.txt +15 -0
- package/src/tool/docs_add.ts +50 -0
- package/src/tool/docs_add.txt +5 -0
- package/src/tool/docs_context.ts +56 -0
- package/src/tool/docs_context.txt +4 -0
- package/src/tool/docs_gap_report.ts +79 -0
- package/src/tool/docs_gap_report.txt +7 -0
- package/src/tool/docs_load.ts +41 -0
- package/src/tool/docs_load.txt +4 -0
- package/src/tool/docs_request.ts +129 -0
- package/src/tool/docs_request.txt +7 -0
- package/src/tool/docs_search.ts +51 -0
- package/src/tool/docs_search.txt +6 -0
- package/src/tool/docs_unload.ts +38 -0
- package/src/tool/docs_unload.txt +5 -0
- package/src/tool/edit.ts +614 -0
- package/src/tool/edit.txt +10 -0
- package/src/tool/external-directory.ts +32 -0
- package/src/tool/generate_image.ts +174 -0
- package/src/tool/generate_image.txt +12 -0
- package/src/tool/glob.ts +79 -0
- package/src/tool/glob.txt +6 -0
- package/src/tool/grep.ts +153 -0
- package/src/tool/grep.txt +8 -0
- package/src/tool/invalid.ts +17 -0
- package/src/tool/ls.ts +116 -0
- package/src/tool/ls.txt +1 -0
- package/src/tool/lsp.ts +96 -0
- package/src/tool/lsp.txt +19 -0
- package/src/tool/memory_search.ts +141 -0
- package/src/tool/memory_search.txt +8 -0
- package/src/tool/multiedit.ts +46 -0
- package/src/tool/multiedit.txt +41 -0
- package/src/tool/plan-enter.txt +14 -0
- package/src/tool/plan-exit.txt +13 -0
- package/src/tool/plan.ts +130 -0
- package/src/tool/question.ts +33 -0
- package/src/tool/question.txt +10 -0
- package/src/tool/rag_index.ts +77 -0
- package/src/tool/rag_index.txt +10 -0
- package/src/tool/rag_reset.ts +26 -0
- package/src/tool/rag_reset.txt +4 -0
- package/src/tool/rag_search.ts +62 -0
- package/src/tool/rag_search.txt +6 -0
- package/src/tool/rag_status.ts +45 -0
- package/src/tool/rag_status.txt +4 -0
- package/src/tool/read.ts +203 -0
- package/src/tool/read.txt +12 -0
- package/src/tool/registry.ts +214 -0
- package/src/tool/skill.ts +169 -0
- package/src/tool/skill.txt +3 -0
- package/src/tool/smart_docs.ts +74 -0
- package/src/tool/smart_docs.txt +7 -0
- package/src/tool/speak/elevenlabs.ts +201 -0
- package/src/tool/speak/openrouter.ts +240 -0
- package/src/tool/speak/provider.ts +83 -0
- package/src/tool/speak.ts +440 -0
- package/src/tool/task.ts +194 -0
- package/src/tool/task.txt +60 -0
- package/src/tool/todo.ts +53 -0
- package/src/tool/todoread.txt +14 -0
- package/src/tool/todowrite.txt +167 -0
- package/src/tool/tool.ts +87 -0
- package/src/tool/tree.ts +218 -0
- package/src/tool/tree.txt +8 -0
- package/src/tool/truncation.ts +106 -0
- package/src/tool/use-connector.ts +47 -0
- package/src/tool/voice.ts +188 -0
- package/src/tool/webfetch.ts +205 -0
- package/src/tool/webfetch.txt +13 -0
- package/src/tool/websearch.ts +150 -0
- package/src/tool/websearch.txt +14 -0
- package/src/tool/write.ts +80 -0
- package/src/tool/write.txt +8 -0
- package/src/util/archive.ts +16 -0
- package/src/util/color.ts +19 -0
- package/src/util/context.ts +25 -0
- package/src/util/defer.ts +12 -0
- package/src/util/error.ts +77 -0
- package/src/util/eventloop.ts +20 -0
- package/src/util/filesystem.ts +125 -0
- package/src/util/flock.ts +329 -0
- package/src/util/fn.ts +11 -0
- package/src/util/format.ts +20 -0
- package/src/util/hash.ts +7 -0
- package/src/util/iife.ts +3 -0
- package/src/util/keybind.ts +103 -0
- package/src/util/lazy.ts +18 -0
- package/src/util/locale.ts +81 -0
- package/src/util/lock.ts +98 -0
- package/src/util/log.ts +180 -0
- package/src/util/network.ts +9 -0
- package/src/util/process.ts +15 -0
- package/src/util/queue.ts +32 -0
- package/src/util/record.ts +3 -0
- package/src/util/rpc.ts +66 -0
- package/src/util/scrap.ts +10 -0
- package/src/util/signal.ts +12 -0
- package/src/util/timeout.ts +14 -0
- package/src/util/token.ts +7 -0
- package/src/util/wildcard.ts +56 -0
- package/src/workspace/adaptors/index.ts +271 -0
- package/src/workspace/adaptors/types.ts +14 -0
- package/src/workspace/adaptors/worktree.ts +31 -0
- package/src/workspace/config.ts +19 -0
- package/src/workspace/index.ts +223 -0
- package/src/workspace/session-proxy-middleware.ts +97 -0
- package/src/workspace/sse.ts +66 -0
- package/src/workspace/workspace-context.ts +23 -0
- package/src/workspace/workspace-server/routes.ts +33 -0
- package/src/workspace/workspace-server/server.ts +47 -0
- package/src/worktree/index.ts +487 -0
- package/sst-env.d.ts +10 -0
- package/test/benchmark.test.ts +121 -0
- package/test/build-optimizations.test.ts +124 -0
- package/test/id-benchmark.test.ts +132 -0
- package/test/optimizations.test.ts +302 -0
- package/test/preload.ts +1 -0
- package/test/solidjs-benchmark.test.ts +262 -0
- package/test/solidjs-optimizations.test.ts +259 -0
- package/test/tui-benchmark.test.ts +230 -0
- package/test/wildcard-benchmark.test.ts +180 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
import { Hono } from "hono"
|
|
2
|
+
import { cors } from "hono/cors"
|
|
3
|
+
import { Session } from "../../session"
|
|
4
|
+
import { lazy } from "../../util/lazy"
|
|
5
|
+
import { upgradeWebSocket } from "hono/bun"
|
|
6
|
+
|
|
7
|
+
const sessions = new Map<string, any>()
|
|
8
|
+
const cliSockets = new Map<string, any>()
|
|
9
|
+
const browserSockets = new Map<string, any[]>()
|
|
10
|
+
|
|
11
|
+
const CSS = `
|
|
12
|
+
:root {
|
|
13
|
+
--bg-primary: #0d1117;
|
|
14
|
+
--bg-secondary: #161b22;
|
|
15
|
+
--bg-tertiary: #21262d;
|
|
16
|
+
--border: #30363d;
|
|
17
|
+
--text-primary: #c9d1d9;
|
|
18
|
+
--text-secondary: #8b949e;
|
|
19
|
+
--accent: #58a6ff;
|
|
20
|
+
--green: #238636;
|
|
21
|
+
--green-hover: #2ea043;
|
|
22
|
+
--blue: #1f6feb;
|
|
23
|
+
--blue-hover: #388bfd;
|
|
24
|
+
--orange: #f0883e;
|
|
25
|
+
--red: #da3633;
|
|
26
|
+
--purple: #a371f7;
|
|
27
|
+
--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
28
|
+
--font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;
|
|
29
|
+
}
|
|
30
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
31
|
+
html, body, #app { height: 100%; width: 100%; }
|
|
32
|
+
body {
|
|
33
|
+
font-family: var(--font-sans);
|
|
34
|
+
background: var(--bg-primary); color: var(--text-primary);
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
}
|
|
37
|
+
.app { display: flex; height: 100%; width: 100%; }
|
|
38
|
+
|
|
39
|
+
/* Sidebar */
|
|
40
|
+
.sidebar {
|
|
41
|
+
width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border);
|
|
42
|
+
display: flex; flex-direction: column; flex-shrink: 0;
|
|
43
|
+
}
|
|
44
|
+
.sidebar-header {
|
|
45
|
+
padding: 16px; border-bottom: 1px solid var(--border);
|
|
46
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
47
|
+
}
|
|
48
|
+
.sidebar-header h1 { font-size: 16px; color: var(--accent); font-weight: 600; }
|
|
49
|
+
.sidebar-content { flex: 1; overflow-y: auto; padding: 8px; }
|
|
50
|
+
.sidebar-section { margin-bottom: 16px; }
|
|
51
|
+
.sidebar-section-title {
|
|
52
|
+
font-size: 11px; text-transform: uppercase; color: var(--text-secondary);
|
|
53
|
+
padding: 8px 8px 4px; font-weight: 600; letter-spacing: 0.5px;
|
|
54
|
+
}
|
|
55
|
+
.session-item {
|
|
56
|
+
display: flex; align-items: center; padding: 8px 12px; border-radius: 6px;
|
|
57
|
+
cursor: pointer; transition: background 0.15s; gap: 8px;
|
|
58
|
+
}
|
|
59
|
+
.session-item:hover { background: var(--bg-tertiary); }
|
|
60
|
+
.session-item.active { background: var(--blue); }
|
|
61
|
+
.session-item .title { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
62
|
+
.session-item .status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
|
|
63
|
+
.session-item .status-dot.running { background: var(--green); }
|
|
64
|
+
.session-item .status-dot.idle { background: var(--text-secondary); }
|
|
65
|
+
.session-item .status-dot.busy { background: var(--orange); animation: pulse 1s infinite; }
|
|
66
|
+
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
|
|
67
|
+
.new-session-btn {
|
|
68
|
+
margin: 8px; padding: 10px; background: var(--green); color: #fff;
|
|
69
|
+
border: none; border-radius: 6px; cursor: pointer; font-size: 13px;
|
|
70
|
+
font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 6px;
|
|
71
|
+
}
|
|
72
|
+
.new-session-btn:hover { background: var(--green-hover); }
|
|
73
|
+
|
|
74
|
+
/* Main area */
|
|
75
|
+
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
|
|
76
|
+
|
|
77
|
+
/* Top bar */
|
|
78
|
+
.topbar {
|
|
79
|
+
height: 48px; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
|
|
80
|
+
display: flex; align-items: center; padding: 0 16px; gap: 8px; flex-shrink: 0;
|
|
81
|
+
}
|
|
82
|
+
.topbar-tabs { display: flex; gap: 4px; flex: 1; }
|
|
83
|
+
.topbar-tab {
|
|
84
|
+
padding: 8px 16px; font-size: 13px; color: var(--text-secondary);
|
|
85
|
+
background: transparent; border: none; border-radius: 6px; cursor: pointer;
|
|
86
|
+
transition: all 0.15s;
|
|
87
|
+
}
|
|
88
|
+
.topbar-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
|
|
89
|
+
.topbar-tab.active { background: var(--bg-tertiary); color: var(--accent); }
|
|
90
|
+
.topbar-actions { display: flex; gap: 8px; }
|
|
91
|
+
.icon-btn {
|
|
92
|
+
width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
|
|
93
|
+
background: transparent; border: none; border-radius: 6px; cursor: pointer;
|
|
94
|
+
color: var(--text-secondary); font-size: 16px;
|
|
95
|
+
}
|
|
96
|
+
.icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
|
|
97
|
+
|
|
98
|
+
/* Messages area */
|
|
99
|
+
.messages-container { flex: 1; display: flex; overflow: hidden; }
|
|
100
|
+
.messages { flex: 1; overflow-y: auto; padding: 16px; }
|
|
101
|
+
.message { margin-bottom: 16px; animation: fadeIn 0.2s; max-width: 85%; }
|
|
102
|
+
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
|
|
103
|
+
.message.user { margin-left: auto; }
|
|
104
|
+
.message.assistant { margin-right: auto; }
|
|
105
|
+
.message-role {
|
|
106
|
+
font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; text-transform: uppercase; font-weight: 600;
|
|
107
|
+
}
|
|
108
|
+
.message-content {
|
|
109
|
+
background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px;
|
|
110
|
+
padding: 12px 16px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.5; font-size: 14px;
|
|
111
|
+
}
|
|
112
|
+
.message.user .message-content { background: var(--blue); border-color: var(--blue); }
|
|
113
|
+
.message.assistant .message-content { border-radius: 12px 12px 12px 4px; }
|
|
114
|
+
.message.user .message-content { border-radius: 12px 12px 4px 12px; }
|
|
115
|
+
|
|
116
|
+
/* Tools */
|
|
117
|
+
.tool-block {
|
|
118
|
+
background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px;
|
|
119
|
+
margin: 8px 0; overflow: hidden;
|
|
120
|
+
}
|
|
121
|
+
.tool-header {
|
|
122
|
+
display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg-tertiary);
|
|
123
|
+
border-bottom: 1px solid var(--border); font-size: 13px;
|
|
124
|
+
}
|
|
125
|
+
.tool-icon { font-size: 14px; }
|
|
126
|
+
.tool-name { color: var(--purple); font-weight: 600; }
|
|
127
|
+
.tool-input {
|
|
128
|
+
padding: 12px; font-family: var(--font-mono); font-size: 12px; background: var(--bg-primary);
|
|
129
|
+
white-space: pre; overflow-x: auto; max-height: 200px; color: var(--text-primary);
|
|
130
|
+
}
|
|
131
|
+
.tool-result {
|
|
132
|
+
padding: 12px; font-family: var(--font-mono); font-size: 12px;
|
|
133
|
+
background: var(--bg-primary); border-top: 1px solid var(--border);
|
|
134
|
+
white-space: pre-wrap; max-height: 200px; overflow-y: auto; color: #7ee787;
|
|
135
|
+
}
|
|
136
|
+
.tool-result.error { color: var(--red); }
|
|
137
|
+
|
|
138
|
+
/* Composer */
|
|
139
|
+
.composer {
|
|
140
|
+
background: var(--bg-secondary); border-top: 1px solid var(--border); padding: 12px 16px;
|
|
141
|
+
display: flex; gap: 12px; flex-shrink: 0;
|
|
142
|
+
}
|
|
143
|
+
.composer textarea {
|
|
144
|
+
flex: 1; background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary);
|
|
145
|
+
padding: 12px 16px; border-radius: 8px; font-size: 14px; font-family: inherit;
|
|
146
|
+
resize: none; min-height: 48px; max-height: 150px;
|
|
147
|
+
}
|
|
148
|
+
.composer textarea:focus { outline: none; border-color: var(--accent); }
|
|
149
|
+
.composer textarea:disabled { opacity: 0.5; }
|
|
150
|
+
.composer button {
|
|
151
|
+
background: var(--green); color: #fff; border: none; padding: 12px 24px;
|
|
152
|
+
border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500;
|
|
153
|
+
transition: background 0.15s; align-self: flex-end;
|
|
154
|
+
}
|
|
155
|
+
.composer button:hover { background: var(--green-hover); }
|
|
156
|
+
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
157
|
+
|
|
158
|
+
/* Permission banner */
|
|
159
|
+
.permission-banner {
|
|
160
|
+
background: rgba(240, 136, 62, 0.1); border: 1px solid var(--orange); border-radius: 8px;
|
|
161
|
+
padding: 12px 16px; margin: 8px 16px;
|
|
162
|
+
}
|
|
163
|
+
.permission-title { color: var(--orange); font-weight: 600; font-size: 13px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
|
|
164
|
+
.permission-details {
|
|
165
|
+
background: var(--bg-primary); padding: 10px; border-radius: 6px; font-family: var(--font-mono);
|
|
166
|
+
font-size: 12px; overflow-x: auto; margin-bottom: 10px;
|
|
167
|
+
}
|
|
168
|
+
.permission-actions { display: flex; gap: 8px; }
|
|
169
|
+
.permission-actions button {
|
|
170
|
+
padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; border: none;
|
|
171
|
+
}
|
|
172
|
+
.btn-deny { background: var(--bg-tertiary); color: var(--text-primary); }
|
|
173
|
+
.btn-deny:hover { background: var(--red); color: #fff; }
|
|
174
|
+
.btn-allow { background: var(--green); color: #fff; }
|
|
175
|
+
.btn-allow:hover { background: var(--green-hover); }
|
|
176
|
+
|
|
177
|
+
/* Status */
|
|
178
|
+
.status-indicator {
|
|
179
|
+
display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary);
|
|
180
|
+
}
|
|
181
|
+
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
|
|
182
|
+
.status-dot.connected { background: var(--green); }
|
|
183
|
+
.status-dot.disconnected { background: var(--red); }
|
|
184
|
+
.status-dot.thinking { background: var(--orange); animation: pulse 1s infinite; }
|
|
185
|
+
|
|
186
|
+
/* Diff panel */
|
|
187
|
+
.diff-panel { flex: 1; border-left: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; }
|
|
188
|
+
.diff-header {
|
|
189
|
+
padding: 12px 16px; background: var(--bg-tertiary); border-bottom: 1px solid var(--border);
|
|
190
|
+
font-size: 13px; font-weight: 600;
|
|
191
|
+
}
|
|
192
|
+
.diff-content { flex: 1; overflow: auto; padding: 12px; font-family: var(--font-mono); font-size: 12px; }
|
|
193
|
+
.diff-file { margin-bottom: 16px; }
|
|
194
|
+
.diff-file-name { color: var(--accent); margin-bottom: 8px; font-weight: 600; }
|
|
195
|
+
.diff-hunk { background: var(--bg-secondary); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
|
|
196
|
+
.diff-add { color: #7ee787; }
|
|
197
|
+
.diff-del { color: #f85149; }
|
|
198
|
+
.diff-line { white-space: pre; }
|
|
199
|
+
|
|
200
|
+
/* Empty states */
|
|
201
|
+
.empty-state {
|
|
202
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
203
|
+
height: 100%; color: var(--text-secondary); gap: 12px;
|
|
204
|
+
}
|
|
205
|
+
.empty-state h2 { font-size: 20px; color: var(--text-primary); }
|
|
206
|
+
.empty-state p { font-size: 14px; }
|
|
207
|
+
|
|
208
|
+
/* Home page */
|
|
209
|
+
.home-container {
|
|
210
|
+
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
|
211
|
+
height: 100%; padding: 40px; text-align: center;
|
|
212
|
+
}
|
|
213
|
+
.home-logo { font-size: 48px; margin-bottom: 16px; }
|
|
214
|
+
.home-title { font-size: 28px; color: var(--accent); margin-bottom: 8px; }
|
|
215
|
+
.home-subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 16px; }
|
|
216
|
+
.home-actions { display: flex; gap: 12px; }
|
|
217
|
+
.home-btn {
|
|
218
|
+
padding: 14px 28px; font-size: 15px; font-weight: 500; border-radius: 8px; cursor: pointer;
|
|
219
|
+
border: none; transition: all 0.15s;
|
|
220
|
+
}
|
|
221
|
+
.home-btn.primary { background: var(--green); color: #fff; }
|
|
222
|
+
.home-btn.primary:hover { background: var(--green-hover); }
|
|
223
|
+
.home-btn.secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
|
|
224
|
+
.home-btn.secondary:hover { background: var(--border); }
|
|
225
|
+
|
|
226
|
+
/* Responsive */
|
|
227
|
+
@media (max-width: 768px) {
|
|
228
|
+
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100;
|
|
229
|
+
transform: translateX(-100%); transition: transform 0.2s; }
|
|
230
|
+
.sidebar.open { transform: translateX(0); }
|
|
231
|
+
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }
|
|
232
|
+
}
|
|
233
|
+
`
|
|
234
|
+
|
|
235
|
+
const JS = `
|
|
236
|
+
const API_BASE = '';
|
|
237
|
+
let currentSessionId = null;
|
|
238
|
+
let eventSource = null;
|
|
239
|
+
let isLoading = false;
|
|
240
|
+
let pendingPermission = null;
|
|
241
|
+
let messages = [];
|
|
242
|
+
let diffs = [];
|
|
243
|
+
let activeTab = 'chat';
|
|
244
|
+
|
|
245
|
+
function $(sel) { return document.querySelector(sel); }
|
|
246
|
+
function $$(sel) { return document.querySelectorAll(sel); }
|
|
247
|
+
|
|
248
|
+
function escapeHtml(text) {
|
|
249
|
+
if (!text) return '';
|
|
250
|
+
const div = document.createElement('div');
|
|
251
|
+
div.textContent = text;
|
|
252
|
+
return div.innerHTML;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function api(endpoint, options = {}) {
|
|
256
|
+
const res = await fetch(API_BASE + endpoint, {
|
|
257
|
+
...options,
|
|
258
|
+
headers: { 'Content-Type': 'application/json', ...options.headers }
|
|
259
|
+
});
|
|
260
|
+
if (!res.ok) {
|
|
261
|
+
const text = await res.text();
|
|
262
|
+
throw new Error(text || ("HTTP " + res.status + ": " + res.statusText));
|
|
263
|
+
}
|
|
264
|
+
return res.json();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async function loadSessions() {
|
|
268
|
+
const sessions = await api('/session?limit=50');
|
|
269
|
+
renderSidebar(sessions);
|
|
270
|
+
return sessions;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function renderSidebar(sessions) {
|
|
274
|
+
const sidebar = $('#sidebar-sessions');
|
|
275
|
+
if (!sessions || sessions.length === 0) {
|
|
276
|
+
sidebar.innerHTML = '<div style="padding: 16px; color: var(--text-secondary); font-size: 13px;">No sessions</div>';
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
sidebar.innerHTML = sessions.map(s => \`
|
|
281
|
+
<div class="session-item \${s.id === currentSessionId ? 'active' : ''}" data-id="\${s.id}" onclick="selectSession('\${s.id}')">
|
|
282
|
+
<span class="status-dot \${getSessionStatus(s)}"></span>
|
|
283
|
+
<span class="title">\${escapeHtml(s.title || s.id.slice(0, 8))}</span>
|
|
284
|
+
</div>
|
|
285
|
+
\`).join('');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function getSessionStatus(session) {
|
|
289
|
+
return 'idle';
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
async function selectSession(sessionId) {
|
|
293
|
+
if (currentSessionId === sessionId) return;
|
|
294
|
+
currentSessionId = sessionId;
|
|
295
|
+
|
|
296
|
+
renderSidebar(await loadSessions());
|
|
297
|
+
loadSessionData(sessionId);
|
|
298
|
+
showChatView();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async function loadSessionData(sessionId) {
|
|
302
|
+
try {
|
|
303
|
+
const [msgs, sessionInfo] = await Promise.all([
|
|
304
|
+
api('/session/' + sessionId + '/message?limit=100'),
|
|
305
|
+
api('/session/' + sessionId)
|
|
306
|
+
]);
|
|
307
|
+
|
|
308
|
+
messages = msgs || [];
|
|
309
|
+
renderMessages();
|
|
310
|
+
|
|
311
|
+
if (sessionInfo.summary?.diffs?.length > 0) {
|
|
312
|
+
diffs = sessionInfo.summary.diffs;
|
|
313
|
+
}
|
|
314
|
+
} catch (e) {
|
|
315
|
+
console.error('Failed to load session:', e);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function renderMessages() {
|
|
320
|
+
const container = $('#messages');
|
|
321
|
+
if (!container) return;
|
|
322
|
+
|
|
323
|
+
if (messages.length === 0) {
|
|
324
|
+
container.innerHTML = '<div class="empty-state"><h2>Start a conversation</h2><p>Send a message to begin</p></div>';
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
let html = '';
|
|
329
|
+
messages.forEach(msg => {
|
|
330
|
+
if (!msg.info || !msg.info.role) return;
|
|
331
|
+
|
|
332
|
+
const role = msg.info.role;
|
|
333
|
+
let messageText = '';
|
|
334
|
+
|
|
335
|
+
if (msg.parts) {
|
|
336
|
+
msg.parts.forEach(part => {
|
|
337
|
+
if (part.type === 'text') {
|
|
338
|
+
messageText += part.text;
|
|
339
|
+
} else if (part.type === 'tool-use') {
|
|
340
|
+
let inputStr = '';
|
|
341
|
+
try { inputStr = JSON.stringify(part.input, null, 2); } catch(e) { inputStr = String(part.input); }
|
|
342
|
+
html += \`<div class="tool-block">
|
|
343
|
+
<div class="tool-header"><span class="tool-icon">🔧</span><span class="tool-name">\${escapeHtml(part.name)}</span></div>
|
|
344
|
+
<pre class="tool-input">\${escapeHtml(inputStr)}</pre>
|
|
345
|
+
</div>\`;
|
|
346
|
+
} else if (part.type === 'tool-result') {
|
|
347
|
+
let resultStr = '';
|
|
348
|
+
try { resultStr = typeof part.content === 'object' ? JSON.stringify(part.content, null, 2) : String(part.content); }
|
|
349
|
+
catch(e) { resultStr = String(part.content); }
|
|
350
|
+
const isError = part.isError;
|
|
351
|
+
html += \`<pre class="tool-result \${isError ? 'error' : ''}">\${escapeHtml(resultStr)}</pre>\`;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (messageText) {
|
|
357
|
+
html += \`<div class="message \${role}">
|
|
358
|
+
<div class="message-role">\${role}</div>
|
|
359
|
+
<div class="message-content">\${escapeHtml(messageText)}</div>
|
|
360
|
+
</div>\`;
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
container.innerHTML = html;
|
|
365
|
+
container.scrollTop = container.scrollHeight;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function showChatView() {
|
|
369
|
+
$('#app').innerHTML = \`
|
|
370
|
+
<div class="sidebar">
|
|
371
|
+
<div class="sidebar-header">
|
|
372
|
+
<h1>nikcli</h1>
|
|
373
|
+
</div>
|
|
374
|
+
<button class="new-session-btn" onclick="createSession()">+ New Session</button>
|
|
375
|
+
<div class="sidebar-content">
|
|
376
|
+
<div class="sidebar-section-title">Sessions</div>
|
|
377
|
+
<div id="sidebar-sessions"></div>
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
<div class="main">
|
|
381
|
+
<div class="topbar">
|
|
382
|
+
<div class="topbar-tabs">
|
|
383
|
+
<button class="topbar-tab active" onclick="setTab('chat')">Chat</button>
|
|
384
|
+
<button class="topbar-tab" onclick="setTab('diff')">Diff</button>
|
|
385
|
+
</div>
|
|
386
|
+
<div class="status-indicator">
|
|
387
|
+
<span class="status-dot" id="statusDot"></span>
|
|
388
|
+
<span id="statusText">Connected</span>
|
|
389
|
+
</div>
|
|
390
|
+
<div class="topbar-actions">
|
|
391
|
+
<button class="icon-btn" onclick="interruptSession()" title="Interrupt">⏹</button>
|
|
392
|
+
<button class="icon-btn" onclick="deleteCurrentSession()" title="Delete">🗑</button>
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
<div id="permissionBanner" style="display:none;"></div>
|
|
396
|
+
<div class="messages-container">
|
|
397
|
+
<div class="messages" id="messages"></div>
|
|
398
|
+
<div class="diff-panel" id="diffPanel" style="display:none;">
|
|
399
|
+
<div class="diff-header">Changes</div>
|
|
400
|
+
<div class="diff-content" id="diffContent"></div>
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
<form class="composer" id="composer">
|
|
404
|
+
<textarea id="input" placeholder="Type a message..." rows="1"></textarea>
|
|
405
|
+
<button type="submit" id="sendBtn">Send</button>
|
|
406
|
+
</form>
|
|
407
|
+
</div>
|
|
408
|
+
\`;
|
|
409
|
+
|
|
410
|
+
loadSessions();
|
|
411
|
+
renderMessages();
|
|
412
|
+
connectEvents();
|
|
413
|
+
setupComposer();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function setTab(tab) {
|
|
417
|
+
activeTab = tab;
|
|
418
|
+
$$('.topbar-tab').forEach(t => t.classList.remove('active'));
|
|
419
|
+
event.target.classList.add('active');
|
|
420
|
+
|
|
421
|
+
$('#diffPanel').style.display = tab === 'diff' ? 'flex' : 'none';
|
|
422
|
+
$('#messages').style.display = tab === 'chat' ? 'block' : 'none';
|
|
423
|
+
|
|
424
|
+
if (tab === 'diff') {
|
|
425
|
+
renderDiffs();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function renderDiffs() {
|
|
430
|
+
const container = $('#diffContent');
|
|
431
|
+
if (!diffs || diffs.length === 0) {
|
|
432
|
+
container.innerHTML = '<div class="empty-state"><p>No changes yet</p></div>';
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
let html = '';
|
|
437
|
+
diffs.forEach(diff => {
|
|
438
|
+
html += \`<div class="diff-file">
|
|
439
|
+
<div class="diff-file-name">\${escapeHtml(diff.path || diff.file || 'Unknown')}</div>\`;
|
|
440
|
+
|
|
441
|
+
if (diff.hunks) {
|
|
442
|
+
diff.hunks.forEach(hunk => {
|
|
443
|
+
html += \`<div class="diff-hunk">\`;
|
|
444
|
+
hunk.lines.forEach(line => {
|
|
445
|
+
const prefix = line.startsWith('+') ? '+' : line.startsWith('-') ? '-' : ' ';
|
|
446
|
+
const cls = line.startsWith('+') ? 'diff-add' : line.startsWith('-') ? 'diff-del' : '';
|
|
447
|
+
html += \`<div class="diff-line \${cls}">\${escapeHtml(line)}</div>\`;
|
|
448
|
+
});
|
|
449
|
+
html += \`</div>\`;
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
html += \`</div>\`;
|
|
453
|
+
});
|
|
454
|
+
container.innerHTML = html;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
async function createSession() {
|
|
458
|
+
try {
|
|
459
|
+
const session = await api('/session', { method: 'POST', body: JSON.stringify({}) });
|
|
460
|
+
currentSessionId = session.id;
|
|
461
|
+
messages = [];
|
|
462
|
+
diffs = [];
|
|
463
|
+
showChatView();
|
|
464
|
+
} catch (e) {
|
|
465
|
+
console.error('Failed to create session:', e);
|
|
466
|
+
alert('Failed to create session');
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async function deleteCurrentSession() {
|
|
471
|
+
if (!currentSessionId) return;
|
|
472
|
+
if (!confirm('Delete this session?')) return;
|
|
473
|
+
|
|
474
|
+
try {
|
|
475
|
+
await api('/session/' + currentSessionId, { method: 'DELETE' });
|
|
476
|
+
currentSessionId = null;
|
|
477
|
+
showHome();
|
|
478
|
+
} catch (e) {
|
|
479
|
+
console.error('Failed to delete session:', e);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
async function interruptSession() {
|
|
484
|
+
if (!currentSessionId) return;
|
|
485
|
+
try {
|
|
486
|
+
await api('/session/' + currentSessionId + '/abort', { method: 'POST' });
|
|
487
|
+
setStatus('idle');
|
|
488
|
+
} catch (e) {
|
|
489
|
+
console.error('Failed to abort:', e);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function setupComposer() {
|
|
494
|
+
const composer = $('#composer');
|
|
495
|
+
const input = $('#input');
|
|
496
|
+
const sendBtn = $('#sendBtn');
|
|
497
|
+
|
|
498
|
+
if (!composer) return;
|
|
499
|
+
|
|
500
|
+
input.addEventListener('input', function() {
|
|
501
|
+
this.style.height = 'auto';
|
|
502
|
+
this.style.height = Math.min(this.scrollHeight, 150) + 'px';
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
input.addEventListener('keydown', function(e) {
|
|
506
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
507
|
+
e.preventDefault();
|
|
508
|
+
composer.dispatchEvent(new Event('submit'));
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
composer.addEventListener('submit', async (e) => {
|
|
513
|
+
e.preventDefault();
|
|
514
|
+
const content = input.value.trim();
|
|
515
|
+
if (!content || isLoading) return;
|
|
516
|
+
|
|
517
|
+
input.value = '';
|
|
518
|
+
input.style.height = 'auto';
|
|
519
|
+
input.disabled = true;
|
|
520
|
+
sendBtn.disabled = true;
|
|
521
|
+
setStatus('thinking');
|
|
522
|
+
|
|
523
|
+
try {
|
|
524
|
+
const result = await api('/session/' + currentSessionId + '/message', {
|
|
525
|
+
method: 'POST',
|
|
526
|
+
body: JSON.stringify({ parts: [{ type: 'text', text: content }] })
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
if (result.info) {
|
|
530
|
+
await loadSessionData(currentSessionId);
|
|
531
|
+
}
|
|
532
|
+
setStatus('idle');
|
|
533
|
+
} catch (e) {
|
|
534
|
+
console.error('Failed to send:', e);
|
|
535
|
+
setStatus('idle');
|
|
536
|
+
alert('Failed to send message: ' + e.message);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
input.disabled = false;
|
|
540
|
+
sendBtn.disabled = false;
|
|
541
|
+
input.focus();
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function setStatus(status) {
|
|
546
|
+
const dot = $('#statusDot');
|
|
547
|
+
const text = $('#statusText');
|
|
548
|
+
if (!dot || !text) return;
|
|
549
|
+
|
|
550
|
+
dot.className = 'status-dot ' + (status === 'thinking' ? 'thinking' : status === 'idle' ? 'connected' : 'disconnected');
|
|
551
|
+
text.textContent = status === 'thinking' ? 'Thinking...' : status === 'idle' ? 'Connected' : 'Disconnected';
|
|
552
|
+
isLoading = status === 'thinking';
|
|
553
|
+
|
|
554
|
+
const input = $('#input');
|
|
555
|
+
const sendBtn = $('#sendBtn');
|
|
556
|
+
if (input) input.disabled = isLoading;
|
|
557
|
+
if (sendBtn) sendBtn.disabled = isLoading;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function connectEvents() {
|
|
561
|
+
if (eventSource) eventSource.close();
|
|
562
|
+
|
|
563
|
+
eventSource = new EventSource(API_BASE + '/global/event');
|
|
564
|
+
|
|
565
|
+
eventSource.onmessage = (event) => {
|
|
566
|
+
try {
|
|
567
|
+
const data = JSON.parse(event.data);
|
|
568
|
+
const payload = data.payload || data;
|
|
569
|
+
handleEvent(payload);
|
|
570
|
+
} catch (e) {
|
|
571
|
+
// Ignore parse errors
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
eventSource.onerror = () => {
|
|
576
|
+
setStatus('disconnected');
|
|
577
|
+
setTimeout(connectEvents, 3000);
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function handleEvent(data) {
|
|
582
|
+
const sessionID = data.properties?.sessionID;
|
|
583
|
+
if (sessionID && sessionID !== currentSessionId) return;
|
|
584
|
+
|
|
585
|
+
if (data.type === 'messagev2.updated') {
|
|
586
|
+
const msg = data.properties;
|
|
587
|
+
if (msg && msg.info && msg.info.sessionID === currentSessionId) {
|
|
588
|
+
loadSessionData(currentSessionId);
|
|
589
|
+
}
|
|
590
|
+
} else if (data.type === 'session.error') {
|
|
591
|
+
setStatus('idle');
|
|
592
|
+
} else if (data.type === 'permission.asked') {
|
|
593
|
+
const perm = data.properties;
|
|
594
|
+
if (perm && perm.sessionID === currentSessionId) {
|
|
595
|
+
showPermission(perm);
|
|
596
|
+
}
|
|
597
|
+
} else if (data.type === 'session.status') {
|
|
598
|
+
const status = data.properties?.status;
|
|
599
|
+
if (status === 'busy' || status === 'generating') {
|
|
600
|
+
setStatus('thinking');
|
|
601
|
+
} else if (status === 'idle') {
|
|
602
|
+
setStatus('idle');
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function showPermission(permission) {
|
|
608
|
+
pendingPermission = permission;
|
|
609
|
+
const banner = $('#permissionBanner');
|
|
610
|
+
if (!banner) return;
|
|
611
|
+
|
|
612
|
+
let details = '';
|
|
613
|
+
try {
|
|
614
|
+
details = JSON.stringify({ permission: permission.permission, patterns: permission.patterns, metadata: permission.metadata }, null, 2);
|
|
615
|
+
} catch(e) { details = String(permission.permission); }
|
|
616
|
+
|
|
617
|
+
banner.style.display = 'block';
|
|
618
|
+
banner.innerHTML = \`
|
|
619
|
+
<div class="permission-banner">
|
|
620
|
+
<div class="permission-title"><span>⚠️</span> Permission: \${escapeHtml(permission.permission)}</div>
|
|
621
|
+
<pre class="permission-details">\${escapeHtml(details)}</pre>
|
|
622
|
+
<div class="permission-actions">
|
|
623
|
+
<button class="btn-deny" onclick="respondPermission(false)">Deny</button>
|
|
624
|
+
<button class="btn-allow" onclick="respondPermission(true)">Allow</button>
|
|
625
|
+
</div>
|
|
626
|
+
</div>
|
|
627
|
+
\`;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
async function respondPermission(allowed) {
|
|
631
|
+
if (!pendingPermission || !currentSessionId) return;
|
|
632
|
+
|
|
633
|
+
const id = pendingPermission.id;
|
|
634
|
+
try {
|
|
635
|
+
await api('/session/' + currentSessionId + '/permissions/' + id, {
|
|
636
|
+
method: 'POST',
|
|
637
|
+
body: JSON.stringify({ response: allowed ? 'once' : 'reject' })
|
|
638
|
+
});
|
|
639
|
+
} catch(e) {
|
|
640
|
+
console.error('Failed to respond:', e);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
pendingPermission = null;
|
|
644
|
+
$('#permissionBanner').style.display = 'none';
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function showHome() {
|
|
648
|
+
$('#app').innerHTML = \`
|
|
649
|
+
<div class="sidebar">
|
|
650
|
+
<div class="sidebar-header">
|
|
651
|
+
<h1>nikcli</h1>
|
|
652
|
+
</div>
|
|
653
|
+
<button class="new-session-btn" onclick="createSession()">+ New Session</button>
|
|
654
|
+
<div class="sidebar-content">
|
|
655
|
+
<div class="sidebar-section-title">Sessions</div>
|
|
656
|
+
<div id="sidebar-sessions"></div>
|
|
657
|
+
</div>
|
|
658
|
+
</div>
|
|
659
|
+
<div class="main">
|
|
660
|
+
<div class="home-container">
|
|
661
|
+
<div class="home-logo">🤖</div>
|
|
662
|
+
<h1 class="home-title">nikcli</h1>
|
|
663
|
+
<p class="home-subtitle">Web interface for nikcli sessions</p>
|
|
664
|
+
<div class="home-actions">
|
|
665
|
+
<button class="home-btn primary" onclick="createSession()">New Session</button>
|
|
666
|
+
</div>
|
|
667
|
+
</div>
|
|
668
|
+
</div>
|
|
669
|
+
\`;
|
|
670
|
+
|
|
671
|
+
loadSessions();
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// Initialize
|
|
675
|
+
async function init() {
|
|
676
|
+
const hash = window.location.hash;
|
|
677
|
+
const match = hash.match(/[#?]session=([^&]+)/);
|
|
678
|
+
|
|
679
|
+
if (match && match[1]) {
|
|
680
|
+
currentSessionId = match[1];
|
|
681
|
+
showChatView();
|
|
682
|
+
} else {
|
|
683
|
+
showHome();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
init();
|
|
688
|
+
`
|
|
689
|
+
|
|
690
|
+
const HTML = `
|
|
691
|
+
<!DOCTYPE html>
|
|
692
|
+
<html>
|
|
693
|
+
<head>
|
|
694
|
+
<title>nikcli Companion</title>
|
|
695
|
+
<meta charset="utf-8">
|
|
696
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
697
|
+
<style>${CSS}</style>
|
|
698
|
+
</head>
|
|
699
|
+
<body>
|
|
700
|
+
<div id="app"></div>
|
|
701
|
+
<script>${JS}</script>
|
|
702
|
+
</body>
|
|
703
|
+
</html>
|
|
704
|
+
`
|
|
705
|
+
|
|
706
|
+
export const CompanionRoutes = lazy(() => {
|
|
707
|
+
const app = new Hono()
|
|
708
|
+
|
|
709
|
+
app.use(
|
|
710
|
+
"*",
|
|
711
|
+
cors({
|
|
712
|
+
origin: "*",
|
|
713
|
+
allowMethods: ["GET", "POST", "DELETE", "OPTIONS"],
|
|
714
|
+
allowHeaders: ["Content-Type", "Authorization"],
|
|
715
|
+
}),
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
app.get("/", (c) => {
|
|
719
|
+
const host = c.req.query("host")
|
|
720
|
+
if (host) {
|
|
721
|
+
const protocol = host.startsWith("https") ? "https" : "http"
|
|
722
|
+
const hostPart = host.replace(/^https?:\/\//, "")
|
|
723
|
+
return c.html(HTML.replace("const API_BASE = '';", `const API_BASE = '${protocol}://${hostPart}';`))
|
|
724
|
+
}
|
|
725
|
+
return c.html(HTML)
|
|
726
|
+
})
|
|
727
|
+
|
|
728
|
+
return app
|
|
729
|
+
})
|