@uniqbit/mate-core 0.18.5 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-capability-plugins/companion-mentions/.claude-plugin/marketplace.json +14 -0
- package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +8 -0
- package/claude-capability-plugins/companion-mentions/hooks/companion.ts +457 -0
- package/claude-capability-plugins/companion-mentions/hooks/hooks.json +1 -0
- package/claude-capability-plugins/companion-mentions/hooks/register.ts +403 -0
- package/claude-plugin/hooks/companion-instructions.mjs +9 -0
- package/claude-plugin/hooks/hooks.json +41 -2
- package/claude-plugin/hooks/session-attention.mjs +10 -0
- package/claude-plugin/hooks/session-end.mjs +9 -0
- package/claude-plugin/hooks/session-guidance.mjs +1 -1
- package/claude-plugin/hooks/tokensave-route.mjs +52 -0
- package/opencode-plugin/src/server.ts +17 -2
- package/opencode-plugin/src/tui.tsx +3 -1
- package/opencode-plugin/tui.tsx +4 -1
- package/package.json +52 -15
- package/src/brand/art.generated.ts +69 -0
- package/src/brand/index.ts +12 -0
- package/src/brand/palette.ts +19 -0
- package/src/brand/svg.generated.ts +8 -0
- package/src/brand/terminal.ts +88 -0
- package/src/brand/types.ts +33 -0
- package/src/cli/commands/artifact/apply-context.ts +275 -0
- package/src/cli/commands/artifact/artifact.ts +12 -0
- package/src/cli/commands/artifact/delivery/archive.ts +125 -0
- package/src/cli/commands/artifact/delivery/branch-flags.ts +55 -0
- package/src/cli/commands/artifact/delivery/environment.ts +127 -0
- package/src/cli/commands/artifact/delivery/link.ts +191 -0
- package/src/cli/commands/artifact/delivery/output.ts +97 -0
- package/src/cli/commands/artifact/finish/command.ts +83 -8
- package/src/cli/commands/artifact/finish/engine.ts +91 -14
- package/src/cli/commands/artifact/finish/finisher.ts +10 -0
- package/src/cli/commands/artifact/finish/git.ts +132 -19
- package/src/cli/commands/artifact/finish/openspec.ts +180 -138
- package/src/cli/commands/artifact/finish/secret-scan.ts +43 -0
- package/src/cli/commands/artifact/finish/worktree-cleanup.ts +92 -0
- package/src/cli/commands/artifact/pending/command.ts +31 -3
- package/src/cli/commands/artifact/pending/discovery.ts +21 -57
- package/src/cli/commands/cap/graphify.ts +52 -3
- package/src/cli/commands/cap/index-cmd.ts +71 -15
- package/src/cli/commands/cap/openspec.ts +13 -25
- package/src/cli/commands/cap/tokensave.ts +7 -5
- package/src/cli/commands/companion/companion.ts +1 -1
- package/src/cli/commands/companion/link.ts +50 -5
- package/src/cli/commands/companion/open.ts +101 -51
- package/src/cli/commands/companion/sync.ts +10 -0
- package/src/cli/commands/companion/tui.ts +17 -7
- package/src/cli/commands/companion/update.ts +143 -48
- package/src/cli/commands/doctor.ts +317 -7
- package/src/cli/commands/factory/factory.ts +301 -0
- package/src/cli/commands/install.ts +133 -9
- package/src/cli/commands/launch/shared.ts +16 -11
- package/src/cli/commands/plugin/install.ts +9 -4
- package/src/cli/commands/plugin/plugin.ts +3 -2
- package/src/cli/commands/report/adapter.ts +11 -2
- package/src/cli/commands/report/contract.ts +21 -0
- package/src/cli/commands/report/highlight.ts +34 -4
- package/src/cli/commands/report/index.ts +20 -1
- package/src/cli/commands/report/markdown.ts +110 -0
- package/src/cli/commands/report/palette.ts +118 -0
- package/src/cli/commands/report/renderer.ts +456 -153
- package/src/cli/commands/report/types.ts +16 -0
- package/src/cli/commands/session/context.ts +102 -0
- package/src/cli/commands/session/prepare.ts +32 -4
- package/src/cli/commands/session/registry.ts +90 -0
- package/src/cli/commands/setup.ts +50 -24
- package/src/cli/commands/studio/companion-removal.ts +79 -0
- package/src/cli/commands/studio/factory-credential.ts +49 -0
- package/src/cli/commands/studio/index.ts +29 -2
- package/src/cli/commands/studio/mate-inventory.ts +1 -1
- package/src/cli/commands/studio/openspec-cli.ts +10 -58
- package/src/cli/commands/studio/payload.ts +260 -15
- package/src/cli/commands/studio/routes.ts +41 -6
- package/src/cli/commands/studio/selection.ts +161 -17
- package/src/cli/commands/studio/server.ts +429 -326
- package/src/cli/commands/studio/services.ts +80 -0
- package/src/cli/commands/studio/skill-files.ts +133 -0
- package/src/cli/commands/studio/studio-app.ts +67 -0
- package/src/cli/commands/studio/terminal-assets.ts +21 -33
- package/src/cli/commands/studio/terminal.ts +85 -15
- package/src/cli/commands/studio/vault.ts +218 -44
- package/src/cli/commands/studio/views/model.ts +13 -0
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +518 -0
- package/src/cli/commands/studio/views/vault/view.ts +185 -0
- package/src/cli/commands/studio/workset-session.ts +131 -0
- package/src/cli/commands/unwrap.ts +16 -0
- package/src/cli/commands/update.ts +53 -9
- package/src/cli/commands/vscode/setup.ts +155 -0
- package/src/cli/commands/vscode/vsix.ts +73 -0
- package/src/cli/commands/working/cleanup.ts +44 -11
- package/src/cli/commands/working/link.ts +76 -0
- package/src/cli/commands/working/working.ts +10 -0
- package/src/cli/commands/working/worktree.ts +406 -0
- package/src/cli/commands/wrap.ts +38 -20
- package/src/cli/companion-link-wizard.tsx +2 -0
- package/src/cli/companion-selector.tsx +2 -0
- package/src/cli/confirm.ts +2 -0
- package/src/cli/install-plan.tsx +127 -160
- package/src/cli/launch-selector.tsx +2 -0
- package/src/cli/main.ts +31 -3
- package/src/cli/parse-flags.ts +32 -6
- package/src/cli/repo-list-table.tsx +2 -0
- package/src/cli/setup-selector.tsx +86 -151
- package/src/cli/usage.ts +20 -1
- package/src/create-mate.ts +5 -4
- package/src/hooks/companion-instructions.ts +198 -0
- package/src/hooks/hook-io.ts +78 -0
- package/src/hooks/session-banner.ts +24 -30
- package/src/hooks/session-end.ts +10 -0
- package/src/hooks/session-guidance.ts +18 -22
- package/src/hooks/session-prepare.ts +137 -34
- package/src/hooks/session-register.ts +199 -0
- package/src/hooks/tokensave-route.ts +30 -0
- package/src/hooks/validate-artifact-path.ts +90 -25
- package/src/index.ts +4 -0
- package/src/lib/apply-context/fingerprint.ts +174 -0
- package/src/lib/apply-context/protocol.ts +193 -0
- package/src/lib/change-layout.ts +154 -0
- package/src/lib/components/confirm-prompt.tsx +21 -9
- package/src/lib/components/select-menu.tsx +10 -3
- package/src/lib/components/spinner.tsx +4 -2
- package/src/lib/components/startup-progress.tsx +227 -41
- package/src/lib/components/text-input-display.tsx +2 -0
- package/src/lib/components/wizard-footer.tsx +2 -0
- package/src/lib/components/wizard-header.tsx +16 -12
- package/src/lib/context-mode-package.ts +24 -11
- package/src/lib/delivery/archive-change.ts +165 -0
- package/src/lib/delivery/branches.ts +147 -0
- package/src/lib/delivery/environment.ts +35 -0
- package/src/lib/delivery/forge.ts +279 -0
- package/src/lib/delivery/merge-git.ts +261 -0
- package/src/lib/delivery/overlap.ts +209 -0
- package/src/lib/delivery/record-delivery.ts +338 -0
- package/src/lib/delivery/record.ts +405 -0
- package/src/lib/delivery/refresh.ts +288 -0
- package/src/lib/delivery/repository-access.ts +141 -0
- package/src/lib/delivery/resolve-branch.ts +383 -0
- package/src/lib/delivery/stages.ts +111 -0
- package/src/lib/delivery/token.ts +24 -0
- package/src/lib/factory/attach-client.ts +113 -0
- package/src/lib/factory/attach.ts +178 -0
- package/src/lib/factory/broker.ts +190 -0
- package/src/lib/factory/bun-commands.ts +39 -0
- package/src/lib/factory/client.ts +92 -0
- package/src/lib/factory/command.ts +61 -0
- package/src/lib/factory/credential-store.ts +153 -0
- package/src/lib/factory/frames.ts +77 -0
- package/src/lib/factory/ids.ts +58 -0
- package/src/lib/factory/keyed-serial.ts +27 -0
- package/src/lib/factory/outcomes/actions.ts +114 -0
- package/src/lib/factory/outcomes/index.ts +391 -0
- package/src/lib/factory/outcomes/lifecycle.ts +205 -0
- package/src/lib/factory/outcomes/runs.ts +81 -0
- package/src/lib/factory/outcomes/sessions.ts +38 -0
- package/src/lib/factory/prepare.ts +49 -0
- package/src/lib/factory/pty.ts +103 -0
- package/src/lib/factory/runner/companion-context.ts +178 -0
- package/src/lib/factory/runner/control.ts +92 -0
- package/src/lib/factory/runner/harness-agent.ts +250 -0
- package/src/lib/factory/runner/live.ts +159 -0
- package/src/lib/factory/runner/questions.ts +22 -0
- package/src/lib/factory/runner/rank.ts +26 -0
- package/src/lib/factory/runner/run-policy.ts +12 -0
- package/src/lib/factory/runner/run.ts +199 -0
- package/src/lib/factory/runner/scheduler.ts +416 -0
- package/src/lib/factory/runner/state.ts +233 -0
- package/src/lib/factory/runner/workflow.ts +542 -0
- package/src/lib/factory/runtime.ts +981 -0
- package/src/lib/factory/sandbox.ts +292 -0
- package/src/lib/factory/worktree-branch.ts +17 -0
- package/src/lib/frontmatter.ts +18 -0
- package/src/lib/install.ts +66 -14
- package/src/lib/live-progress.ts +36 -0
- package/src/lib/member-choices.ts +67 -0
- package/src/lib/opencode-plugin-package.ts +5 -5
- package/src/lib/opencode-server.ts +238 -0
- package/src/lib/openspec-cli.ts +116 -0
- package/src/lib/openspec-scopes.ts +86 -0
- package/src/lib/orchestrator/adapters/base.ts +55 -22
- package/src/lib/orchestrator/adapters/claude-args.ts +50 -0
- package/src/lib/orchestrator/adapters/claude.ts +201 -43
- package/src/lib/orchestrator/adapters/opencode.ts +55 -2
- package/src/lib/orchestrator/checkout-adoption.ts +125 -0
- package/src/lib/orchestrator/companion-registry-store.ts +6 -2
- package/src/lib/orchestrator/config-store.ts +3 -2
- package/src/lib/orchestrator/editor.ts +32 -26
- package/src/lib/orchestrator/framework-context.ts +26 -14
- package/src/lib/orchestrator/global-config-store.ts +11 -0
- package/src/lib/orchestrator/launcher.ts +15 -2
- package/src/lib/orchestrator/openspec-store.ts +14 -54
- package/src/lib/orchestrator/projection-claude-commands.ts +36 -0
- package/src/lib/orchestrator/projection-claude-links.ts +206 -0
- package/src/lib/orchestrator/projection-claude-skills.ts +37 -129
- package/src/lib/orchestrator/projection-companion-link.ts +12 -1
- package/src/lib/orchestrator/projection-entries.ts +100 -34
- package/src/lib/orchestrator/projection-opencode-copies.ts +32 -15
- package/src/lib/orchestrator/projection-openspec-store.ts +54 -9
- package/src/lib/orchestrator/projection-runtime-documents.ts +15 -6
- package/src/lib/orchestrator/projection-types.ts +36 -1
- package/src/lib/orchestrator/refresh-working-claude-links.ts +87 -0
- package/src/lib/orchestrator/registry-checkouts.ts +177 -0
- package/src/lib/orchestrator/repository-link.ts +216 -57
- package/src/lib/orchestrator/serving-claude-wrap.ts +43 -0
- package/src/lib/orchestrator/session-context-link.ts +73 -0
- package/src/lib/orchestrator/session-prepare.ts +81 -11
- package/src/lib/orchestrator/setup-compatibilities.ts +56 -70
- package/src/lib/orchestrator/types.ts +12 -2
- package/src/lib/orchestrator/working-repo-projection.ts +50 -7
- package/src/lib/orchestrator/workspace-document.ts +105 -0
- package/src/lib/orchestrator/workspace-inventory.ts +5 -1
- package/src/lib/orchestrator/wrap-pass.ts +22 -1
- package/src/lib/package-paths.ts +37 -0
- package/src/lib/public-npm.ts +17 -0
- package/src/lib/runtime-directory-refresh.ts +17 -1
- package/src/lib/session-attribution.ts +52 -0
- package/src/lib/session-state.ts +285 -0
- package/src/lib/session-stop.ts +64 -0
- package/src/lib/workset/record.ts +533 -0
- package/src/lib/workset/repositories.ts +55 -0
- package/src/lib/workset/stage.ts +148 -0
- package/src/lib/workset/stages.ts +113 -0
- package/src/lib/workset/worktree-index.ts +116 -0
- package/src/lib/workset/worktree.ts +898 -0
- package/src/opencode/background-server.ts +145 -0
- package/src/opencode/companion-hooks.ts +111 -7
- package/src/opencode/companion-policy.ts +39 -20
- package/src/opencode/enter-worktree.ts +72 -0
- package/src/opencode/projected-guidance.ts +6 -2
- package/src/opencode/session-prepare.ts +2 -1
- package/src/opencode/session-register.ts +176 -0
- package/src/opencode/tui.tsx +24 -27
- package/src/plugins.ts +1 -0
- package/src/runtime/artifact-refusal.ts +63 -0
- package/src/runtime/claude-delivery-plan.ts +121 -11
- package/src/runtime/commit-attribution-guard.ts +181 -0
- package/src/runtime/companion-git.ts +52 -10
- package/src/runtime/companion-guidance.ts +20 -8
- package/src/runtime/companion-instructions.ts +340 -0
- package/src/runtime/companion-lock.ts +30 -7
- package/src/runtime/current-branch.ts +10 -0
- package/src/runtime/env.ts +59 -8
- package/src/runtime/error-message.ts +4 -0
- package/src/runtime/git-layout.ts +366 -0
- package/src/runtime/index.ts +29 -0
- package/src/runtime/launch-env-guard.ts +65 -0
- package/src/runtime/managed-block.ts +117 -0
- package/src/runtime/markdown-scan.ts +266 -0
- package/src/runtime/opencode-server-record.ts +136 -0
- package/src/runtime/physical-path.ts +111 -0
- package/src/runtime/policy.ts +50 -2
- package/src/runtime/projected-flag.ts +7 -0
- package/src/runtime/projected-guidance.ts +1 -0
- package/src/runtime/projection.ts +40 -6
- package/src/runtime/repo-local.ts +6 -1
- package/src/runtime/runtime-directory.ts +5 -0
- package/src/runtime/runtime-document-manifest.ts +62 -11
- package/src/runtime/secret-guard.ts +162 -0
- package/src/runtime/secret-patterns.ts +397 -0
- package/src/runtime/secret-scan.ts +90 -0
- package/src/runtime/serving-claude-wrap.ts +28 -0
- package/src/runtime/session-context.ts +99 -0
- package/src/runtime/session-kind.ts +13 -0
- package/src/runtime/session-registry.ts +434 -0
- package/src/runtime/shell-heredoc.ts +81 -0
- package/src/runtime/tokensave-route.ts +157 -0
- package/src/runtime/wrap-state.ts +75 -2
- package/src/runtime/write-atomic.ts +64 -0
- package/src/studio.ts +126 -0
- package/src/templates/capabilities/openspec-cap/mate-minimal/schema.yaml +14 -10
- package/src/templates/capabilities/openspec-cap/mate-minimal/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/mate-v1/schema.yaml +18 -102
- package/src/templates/capabilities/openspec-cap/mate-v1/templates/spec.md +3 -5
- package/src/templates/capabilities/openspec-cap/openspec-conventions.yaml +20 -14
- package/src/templates/mate-skills/THIRD-PARTY-NOTICES.md +40 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +162 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/agents/mate-apply-change/references/openspec-apply-change.md +200 -0
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +81 -0
- package/src/templates/mate-skills/{claude/mate-openspec-backfill → agents/mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +66 -0
- package/src/templates/mate-skills/agents/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/agents/mate-grill-me/SKILL.md +11 -4
- package/src/templates/mate-skills/agents/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/agents/mate-interview-me/SKILL.md +12 -5
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +102 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +45 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-propose.md +169 -0
- package/src/templates/mate-skills/agents/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/agents/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +109 -24
- package/src/templates/mate-skills/{claude/mate-artifact-publish → agents/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +95 -16
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +87 -68
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +162 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/mate-compact-apply.md +47 -0
- package/src/templates/mate-skills/claude/mate-apply-change/references/openspec-apply-change.md +200 -0
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +81 -0
- package/src/templates/mate-skills/{agents/mate-openspec-backfill → claude/mate-backfill-spec}/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-clarify-intent/SKILL.md +110 -0
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +66 -0
- package/src/templates/mate-skills/claude/mate-explore-change/references/openspec-explore.md +350 -0
- package/src/templates/mate-skills/claude/mate-grill-me/SKILL.md +11 -4
- package/src/templates/mate-skills/claude/mate-grill-with-docs/SKILL.md +2 -2
- package/src/templates/mate-skills/claude/mate-interview-me/SKILL.md +12 -5
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +102 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +45 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-propose.md +169 -0
- package/src/templates/mate-skills/claude/mate-propose-change/references/openspec-update-change.md +103 -0
- package/src/templates/mate-skills/claude/{mate-artifact-publish → mate-publish-artifact}/SKILL.md +109 -24
- package/src/templates/mate-skills/{agents/mate-artifact-publish → claude/mate-publish-artifact}/references/openspec.md +8 -5
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +95 -16
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +87 -68
- package/src/templates/mate-skills/openspec-references.ts +142 -0
- package/src/templates/root/TEMPLATE_AGENTS.md +2 -2
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +4340 -419
- package/src/tools/setup/capabilities/companion-mentions.ts +27 -0
- package/src/tools/setup/capabilities/context-mode.ts +56 -7
- package/src/tools/setup/capabilities/graphify-gate.ts +31 -0
- package/src/tools/setup/capabilities/graphify-secrets.ts +243 -0
- package/src/tools/setup/capabilities/graphify.ts +46 -7
- package/src/tools/setup/capabilities/openspec.ts +163 -272
- package/src/tools/setup/capabilities/react-doctor.ts +8 -1
- package/src/tools/setup/capabilities/rtk.ts +4 -0
- package/src/tools/setup/capabilities/tokensave.ts +113 -71
- package/src/tools/setup/context-services.ts +9 -17
- package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -3
- package/src/tools/setup/dynamic-plugins/install.ts +24 -28
- package/src/tools/setup/engine.ts +100 -23
- package/src/tools/setup/install-contract.ts +8 -0
- package/src/tools/setup/managed-output.ts +51 -0
- package/src/tools/setup/mate-skill-copies.ts +51 -0
- package/src/tools/setup/mate.ts +86 -11
- package/src/tools/setup/package-managers/uv.ts +73 -11
- package/src/tools/setup/plugin.ts +40 -0
- package/src/tools/setup/plugins/guidance.ts +7 -4
- package/src/tools/setup/providers/agent-file-sections.ts +4 -2
- package/src/tools/setup/providers/claude-attribution.ts +65 -0
- package/src/tools/setup/providers/claude-plugin-folders.ts +625 -0
- package/src/tools/setup/providers/claude-plugin-hooks.ts +77 -19
- package/src/tools/setup/providers/claude-worktree-plugins.ts +122 -0
- package/src/tools/setup/providers/claude.ts +310 -8
- package/src/tools/setup/providers/opencode.ts +180 -1
- package/src/tools/setup/utils.ts +18 -4
- package/src/tools/setup/working-repo-cleanup.ts +29 -1
- package/src/tools/setup/working-repo-local-state.ts +252 -75
- package/src/tools/setup.ts +183 -26
- package/studio-dist/client/assets/app-CdPiFv59.css +2 -0
- package/studio-dist/client/assets/button-BIIHE0EQ.js +3 -0
- package/studio-dist/client/assets/companion-view-DM6YyXaR.js +1 -0
- package/studio-dist/client/assets/delivery-path-DELxj0Av.js +1 -0
- package/studio-dist/client/assets/dist-Dm7MtyHc.js +5 -0
- package/studio-dist/client/assets/factory-BZy0E8ty.js +4 -0
- package/studio-dist/client/assets/index-B3wkMzjA.js +40 -0
- package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +1 -0
- package/studio-dist/client/assets/panel-CbajlC3p.js +1 -0
- package/studio-dist/client/assets/preload-helper-BLdHbfdN.js +1 -0
- package/studio-dist/client/assets/prepaint-CwSrpdFA.js +27 -0
- package/studio-dist/client/assets/react-CN2GSx7x.js +1 -0
- package/studio-dist/client/assets/reports-DllhYQ5_.js +1 -0
- package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +1 -0
- package/studio-dist/client/assets/routes-COm-G3mK.js +1 -0
- package/studio-dist/client/assets/skills-DmWAy-jZ.js +1 -0
- package/studio-dist/client/assets/specs-BG3Wi3ln.js +1 -0
- package/studio-dist/client/assets/steps-DFsH3Neu.js +1 -0
- package/studio-dist/client/assets/terminal-eU5fzQzv.css +1 -0
- package/studio-dist/client/assets/vault-B2q1nBY5.js +1 -0
- package/studio-dist/client/assets/warnings-BSXIyuSQ.js +1 -0
- package/studio-dist/client/assets/wasm-inline-C2en61B5.js +1 -0
- package/studio-dist/client/assets/workflow-DlsQD6Hc.js +1 -0
- package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-M2GBs8s3.js +4051 -0
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +95 -0
- package/studio-dist/server/assets/actions-Bvgj9eb8.js +54 -0
- package/studio-dist/server/assets/actions-D8erOphH.js +44 -0
- package/studio-dist/server/assets/button-CIJqAhni.js +11929 -0
- package/studio-dist/server/assets/companion-view-DISASvdJ.js +39 -0
- package/studio-dist/server/assets/companions-BYbHWKOZ.js +15 -0
- package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +459 -0
- package/studio-dist/server/assets/createServerRpc-tK2lE9R2.js +11 -0
- package/studio-dist/server/assets/delivery-path-C29fBynY.js +654 -0
- package/studio-dist/server/assets/dist-DpJWKyCm.js +5582 -0
- package/studio-dist/server/assets/empty-plugin-adapters-Cipd4ZH4.js +4 -0
- package/studio-dist/server/assets/factory-DGPmNGbo.js +69 -0
- package/studio-dist/server/assets/factory-DUTa0eDs.js +2172 -0
- package/studio-dist/server/assets/markdown-view-Bn7xPdks.js +86 -0
- package/studio-dist/server/assets/model-PyPALjii.js +18 -0
- package/studio-dist/server/assets/panel-3Jmn4awF.js +169 -0
- package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +45 -0
- package/studio-dist/server/assets/react-Ce6dj15C.js +46 -0
- package/studio-dist/server/assets/reports-C06RXVE2.js +18 -0
- package/studio-dist/server/assets/reports-D6YMqhnO.js +142 -0
- package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +34 -0
- package/studio-dist/server/assets/router-C8MGqlAY.js +13713 -0
- package/studio-dist/server/assets/routes-BcFgvqf7.js +622 -0
- package/studio-dist/server/assets/search-JAKurDNh.js +36 -0
- package/studio-dist/server/assets/shell-DS3wUexh.js +52 -0
- package/studio-dist/server/assets/skills-BEnOxiDl.js +266 -0
- package/studio-dist/server/assets/skills-CtrBAtX3.js +28 -0
- package/studio-dist/server/assets/specs-C8rv34-5.js +211 -0
- package/studio-dist/server/assets/start-h3ICWwd2.js +36 -0
- package/studio-dist/server/assets/steps-Dq_CwY_s.js +181 -0
- package/studio-dist/server/assets/studio-BeltxxKt.js +216 -0
- package/studio-dist/server/assets/utils-C9CX1kcy.js +221 -0
- package/studio-dist/server/assets/vault-BmWnryh3.js +85 -0
- package/studio-dist/server/assets/vault-Fvxt2Tzl.js +1032 -0
- package/studio-dist/server/assets/views-BgYa-za2.js +80 -0
- package/studio-dist/server/assets/warnings-DzR6fyZh.js +23 -0
- package/studio-dist/server/assets/wasm-inline-CNeBKGwC.js +3 -0
- package/studio-dist/server/assets/workflow-liRYecHk.js +73 -0
- package/studio-dist/server/server.js +16066 -0
- package/wrappers/bin/graphify +52 -4
- package/wrappers/bin/openspec +33 -9
- package/wrappers/lib/graphify-gate.mjs +8 -0
- package/src/cli/commands/studio/views/client.ts +0 -654
- package/src/cli/commands/studio/views/companion-picker.tsx +0 -95
- package/src/cli/commands/studio/views/companion-selector.tsx +0 -94
- package/src/cli/commands/studio/views/dashboard/changes.tsx +0 -107
- package/src/cli/commands/studio/views/dashboard/index.tsx +0 -19
- package/src/cli/commands/studio/views/document.tsx +0 -842
- package/src/cli/commands/studio/views/error.tsx +0 -20
- package/src/cli/commands/studio/views/reports/index.tsx +0 -49
- package/src/cli/commands/studio/views/selection-fields.tsx +0 -14
- package/src/cli/commands/studio/views/skills/index.tsx +0 -87
- package/src/cli/commands/studio/views/specs/index.tsx +0 -157
- package/src/cli/commands/studio/views/styles.ts +0 -519
- package/src/cli/commands/studio/views/terminal.tsx +0 -484
- package/src/cli/commands/studio/views/vault/state.ts +0 -43
- package/src/cli/commands/studio/views/warnings.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/index.tsx +0 -21
- package/src/cli/commands/studio/views/workflow/steps.ts +0 -337
- package/src/cli/commands/studio/views/workflow/transcript.tsx +0 -190
- package/src/lib/components/theme.ts +0 -2
- package/src/tools/setup/git-utils.ts +0 -30
- package/src/tools/setup/runtime-documents.ts +0 -291
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource hono/jsx */
|
|
2
|
-
|
|
3
|
-
import type { TerminalAgent } from "../terminal";
|
|
4
|
-
import type { StudioTerminalPage } from "./model";
|
|
5
|
-
|
|
6
|
-
export const TERMINAL_TAB_KEY = "mate-studio-terminal-tab";
|
|
7
|
-
export const TERMINAL_SESSION_KEY = "mate-studio-terminal-session";
|
|
8
|
-
|
|
9
|
-
const AGENT_LABELS: Record<TerminalAgent, string> = {
|
|
10
|
-
claude: "Claude Code",
|
|
11
|
-
opencode: "OpenCode",
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const TERMINAL_WIDTH_KEY = "mate-studio-terminal-width";
|
|
15
|
-
export const TERMINAL_COLLAPSED_KEY = "mate-studio-terminal-collapsed";
|
|
16
|
-
const TERMINAL_MIN_WIDTH = 360;
|
|
17
|
-
const TERMINAL_MAX_WIDTH_RATIO = 0.7;
|
|
18
|
-
|
|
19
|
-
/** Shared by the prepaint and sidebar scripts so both clamp alike. */
|
|
20
|
-
const CLAMP_WIDTH_SOURCE = `function clampWidth(px) {
|
|
21
|
-
return Math.round(Math.max(${TERMINAL_MIN_WIDTH}, Math.min(px, window.innerWidth * ${TERMINAL_MAX_WIDTH_RATIO})));
|
|
22
|
-
}`;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A direct grid child of `.shell`: sticky positioning breaks under an ancestor
|
|
26
|
-
* that sets `overflow`, and `.main` is not guaranteed to stay free of one.
|
|
27
|
-
*/
|
|
28
|
-
export function TerminalSidebar({ terminal }: { terminal: StudioTerminalPage }) {
|
|
29
|
-
const target = terminal.target;
|
|
30
|
-
return (
|
|
31
|
-
<aside
|
|
32
|
-
className="terminal-sidebar"
|
|
33
|
-
id="studio-terminal-panel"
|
|
34
|
-
aria-label="Agent terminal"
|
|
35
|
-
data-terminal-companion={target?.digest}
|
|
36
|
-
data-terminal-state="reconnecting"
|
|
37
|
-
>
|
|
38
|
-
<div
|
|
39
|
-
className="terminal-resize"
|
|
40
|
-
id="terminal-resize"
|
|
41
|
-
role="separator"
|
|
42
|
-
aria-orientation="vertical"
|
|
43
|
-
aria-label="Resize the terminal"
|
|
44
|
-
/>
|
|
45
|
-
<div className="terminal-strip">
|
|
46
|
-
<button
|
|
47
|
-
type="button"
|
|
48
|
-
className="terminal-icon-button"
|
|
49
|
-
id="terminal-expand"
|
|
50
|
-
aria-controls="terminal-body"
|
|
51
|
-
aria-expanded="false"
|
|
52
|
-
aria-label="Expand the terminal"
|
|
53
|
-
>
|
|
54
|
-
‹
|
|
55
|
-
</button>
|
|
56
|
-
<span className="terminal-dot" aria-hidden="true" />
|
|
57
|
-
</div>
|
|
58
|
-
<div className="terminal-body" id="terminal-body">
|
|
59
|
-
<header className="terminal-head">
|
|
60
|
-
<div className="terminal-title">
|
|
61
|
-
<span className="terminal-dot" aria-hidden="true" />
|
|
62
|
-
<h2>Agent terminal</h2>
|
|
63
|
-
<button
|
|
64
|
-
type="button"
|
|
65
|
-
className="terminal-icon-button"
|
|
66
|
-
id="terminal-collapse"
|
|
67
|
-
aria-controls="terminal-body"
|
|
68
|
-
aria-expanded="true"
|
|
69
|
-
aria-label="Collapse the terminal"
|
|
70
|
-
>
|
|
71
|
-
›
|
|
72
|
-
</button>
|
|
73
|
-
<button
|
|
74
|
-
type="button"
|
|
75
|
-
className="terminal-icon-button"
|
|
76
|
-
id="terminal-drawer-close"
|
|
77
|
-
aria-label="Close the terminal"
|
|
78
|
-
>
|
|
79
|
-
×
|
|
80
|
-
</button>
|
|
81
|
-
</div>
|
|
82
|
-
<p className="terminal-target">
|
|
83
|
-
{target ? (
|
|
84
|
-
<>
|
|
85
|
-
Launches against <code>{target.path}</code>
|
|
86
|
-
{terminal.pinned ? " (fixed when Studio started)" : null}
|
|
87
|
-
</>
|
|
88
|
-
) : (
|
|
89
|
-
"Select a registered companion to launch an agent."
|
|
90
|
-
)}
|
|
91
|
-
</p>
|
|
92
|
-
<div className="terminal-actions">
|
|
93
|
-
{target && terminal.agents.length > 0 ? (
|
|
94
|
-
terminal.agents.map((agent) => (
|
|
95
|
-
<button key={agent} type="button" className="button" data-terminal-start={agent}>
|
|
96
|
-
Start {AGENT_LABELS[agent]}
|
|
97
|
-
</button>
|
|
98
|
-
))
|
|
99
|
-
) : target ? (
|
|
100
|
-
<span className="empty">No agent this companion allows is installed.</span>
|
|
101
|
-
) : null}
|
|
102
|
-
<button type="button" className="button" id="terminal-reconnect" hidden>
|
|
103
|
-
Reconnect
|
|
104
|
-
</button>
|
|
105
|
-
</div>
|
|
106
|
-
<div
|
|
107
|
-
className="terminal-choice"
|
|
108
|
-
id="terminal-action-choice"
|
|
109
|
-
role="group"
|
|
110
|
-
aria-label="Choose an agent"
|
|
111
|
-
hidden
|
|
112
|
-
/>
|
|
113
|
-
<p className="terminal-status" id="terminal-status" role="status">
|
|
114
|
-
Connecting…
|
|
115
|
-
</p>
|
|
116
|
-
</header>
|
|
117
|
-
<div className="terminal-view" id="studio-terminal" />
|
|
118
|
-
<footer className="terminal-sessions-footer">
|
|
119
|
-
<h3 className="terminal-sessions-title">Sessions</h3>
|
|
120
|
-
<ul className="terminal-sessions" id="terminal-sessions" />
|
|
121
|
-
</footer>
|
|
122
|
-
</div>
|
|
123
|
-
</aside>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** Outside `.shell`, so it never takes a grid cell; shown only below the side-by-side breakpoint. */
|
|
128
|
-
export function TerminalDrawerButton() {
|
|
129
|
-
return (
|
|
130
|
-
<button
|
|
131
|
-
type="button"
|
|
132
|
-
className="terminal-drawer-open"
|
|
133
|
-
id="terminal-drawer-open"
|
|
134
|
-
aria-controls="studio-terminal-panel"
|
|
135
|
-
aria-expanded="false"
|
|
136
|
-
>
|
|
137
|
-
Terminal
|
|
138
|
-
</button>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Runs in `<head>` with the terminal only, so a navigation paints the
|
|
144
|
-
* remembered width and collapsed state instead of the defaults first.
|
|
145
|
-
*/
|
|
146
|
-
export const STUDIO_TERMINAL_PREPAINT_SCRIPT = `(function () {
|
|
147
|
-
${CLAMP_WIDTH_SOURCE}
|
|
148
|
-
try {
|
|
149
|
-
var width = parseInt(localStorage.getItem(${JSON.stringify(TERMINAL_WIDTH_KEY)}) || "", 10);
|
|
150
|
-
if (width > 0) document.documentElement.style.setProperty("--terminal-width", clampWidth(width) + "px");
|
|
151
|
-
if (localStorage.getItem(${JSON.stringify(TERMINAL_COLLAPSED_KEY)}) === "true") {
|
|
152
|
-
document.documentElement.setAttribute("data-terminal-collapsed", "");
|
|
153
|
-
}
|
|
154
|
-
} catch (error) {
|
|
155
|
-
/* a blocked web store only costs the preference, never the page */
|
|
156
|
-
}
|
|
157
|
-
})();`;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* The sidebar chrome: collapse, drag-to-resize, and the narrow-window drawer.
|
|
161
|
-
* It never touches xterm.js or the socket; the terminal script refits from
|
|
162
|
-
* its own observer whenever this changes the terminal's size.
|
|
163
|
-
*/
|
|
164
|
-
export const STUDIO_TERMINAL_SIDEBAR_SCRIPT = `(function () {
|
|
165
|
-
var root = document.documentElement;
|
|
166
|
-
var panel = document.getElementById("studio-terminal-panel");
|
|
167
|
-
if (!panel) return;
|
|
168
|
-
var collapseButton = document.getElementById("terminal-collapse");
|
|
169
|
-
var expandButton = document.getElementById("terminal-expand");
|
|
170
|
-
var handle = document.getElementById("terminal-resize");
|
|
171
|
-
var opener = document.getElementById("terminal-drawer-open");
|
|
172
|
-
var closer = document.getElementById("terminal-drawer-close");
|
|
173
|
-
${CLAMP_WIDTH_SOURCE}
|
|
174
|
-
function save(key, value) {
|
|
175
|
-
try { localStorage.setItem(key, value); } catch (error) { /* only the preference is lost */ }
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function updateCollapseControls(collapsed) {
|
|
179
|
-
if (collapseButton) collapseButton.setAttribute("aria-expanded", String(!collapsed));
|
|
180
|
-
if (expandButton) expandButton.setAttribute("aria-expanded", String(!collapsed));
|
|
181
|
-
}
|
|
182
|
-
function setCollapsed(collapsed) {
|
|
183
|
-
if (collapsed) root.setAttribute("data-terminal-collapsed", "");
|
|
184
|
-
else root.removeAttribute("data-terminal-collapsed");
|
|
185
|
-
updateCollapseControls(collapsed);
|
|
186
|
-
save(${JSON.stringify(TERMINAL_COLLAPSED_KEY)}, String(collapsed));
|
|
187
|
-
}
|
|
188
|
-
updateCollapseControls(root.hasAttribute("data-terminal-collapsed"));
|
|
189
|
-
if (collapseButton) collapseButton.addEventListener("click", function () { setCollapsed(true); });
|
|
190
|
-
if (expandButton) expandButton.addEventListener("click", function () { setCollapsed(false); });
|
|
191
|
-
|
|
192
|
-
if (handle) {
|
|
193
|
-
var dragging = false;
|
|
194
|
-
var width = 0;
|
|
195
|
-
handle.addEventListener("pointerdown", function (event) {
|
|
196
|
-
dragging = true;
|
|
197
|
-
handle.setPointerCapture(event.pointerId);
|
|
198
|
-
event.preventDefault();
|
|
199
|
-
});
|
|
200
|
-
handle.addEventListener("pointermove", function (event) {
|
|
201
|
-
if (!dragging) return;
|
|
202
|
-
width = clampWidth(window.innerWidth - event.clientX);
|
|
203
|
-
root.style.setProperty("--terminal-width", width + "px");
|
|
204
|
-
});
|
|
205
|
-
var stop = function (event) {
|
|
206
|
-
if (!dragging) return;
|
|
207
|
-
dragging = false;
|
|
208
|
-
if (handle.hasPointerCapture && handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
|
|
209
|
-
if (width > 0) save(${JSON.stringify(TERMINAL_WIDTH_KEY)}, String(width));
|
|
210
|
-
};
|
|
211
|
-
handle.addEventListener("pointerup", stop);
|
|
212
|
-
handle.addEventListener("pointercancel", stop);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function setDrawer(open) {
|
|
216
|
-
if (open) panel.setAttribute("data-drawer-open", "");
|
|
217
|
-
else panel.removeAttribute("data-drawer-open");
|
|
218
|
-
if (opener) opener.setAttribute("aria-expanded", String(open));
|
|
219
|
-
}
|
|
220
|
-
if (opener) opener.addEventListener("click", function () {
|
|
221
|
-
setDrawer(true);
|
|
222
|
-
if (closer) closer.focus();
|
|
223
|
-
});
|
|
224
|
-
if (closer) closer.addEventListener("click", function () {
|
|
225
|
-
setDrawer(false);
|
|
226
|
-
if (opener) opener.focus();
|
|
227
|
-
});
|
|
228
|
-
document.addEventListener("keydown", function (event) {
|
|
229
|
-
if (event.key !== "Escape" || !panel.hasAttribute("data-drawer-open")) return;
|
|
230
|
-
setDrawer(false);
|
|
231
|
-
if (opener) opener.focus();
|
|
232
|
-
});
|
|
233
|
-
})();`;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Drives the xterm.js view over the terminal WebSocket. The tab id lives in
|
|
237
|
-
* `sessionStorage`, so a reload keeps it and a new tab gets its own; a
|
|
238
|
-
* taken-over tab never reconnects on its own.
|
|
239
|
-
*/
|
|
240
|
-
export const STUDIO_TERMINAL_SCRIPT = `(function () {
|
|
241
|
-
var panel = document.getElementById("studio-terminal-panel");
|
|
242
|
-
var mount = document.getElementById("studio-terminal");
|
|
243
|
-
if (!panel || !mount || typeof Terminal === "undefined") return;
|
|
244
|
-
var statusNode = document.getElementById("terminal-status");
|
|
245
|
-
var reconnectButton = document.getElementById("terminal-reconnect");
|
|
246
|
-
var list = document.getElementById("terminal-sessions");
|
|
247
|
-
var companion = panel.getAttribute("data-terminal-companion") || "";
|
|
248
|
-
var MAX_ATTEMPTS = 8;
|
|
249
|
-
var FIRST_DELAY = 2000;
|
|
250
|
-
|
|
251
|
-
function store(key, value) {
|
|
252
|
-
try {
|
|
253
|
-
if (value === null) sessionStorage.removeItem(key);
|
|
254
|
-
else sessionStorage.setItem(key, value);
|
|
255
|
-
} catch (error) { /* a blocked store only costs the reattach */ }
|
|
256
|
-
}
|
|
257
|
-
function load(key) {
|
|
258
|
-
try { return sessionStorage.getItem(key); } catch (error) { return null; }
|
|
259
|
-
}
|
|
260
|
-
var tabId = load(${JSON.stringify(TERMINAL_TAB_KEY)});
|
|
261
|
-
if (!tabId) {
|
|
262
|
-
tabId = (window.crypto && crypto.randomUUID) ? crypto.randomUUID() : String(Math.random()).slice(2);
|
|
263
|
-
store(${JSON.stringify(TERMINAL_TAB_KEY)}, tabId);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
var term = new Terminal({ cursorBlink: true, allowProposedApi: true, fontFamily: getComputedStyle(document.documentElement).getPropertyValue("--mono") || "monospace", fontSize: 13 });
|
|
267
|
-
var fit = new FitAddon.FitAddon();
|
|
268
|
-
term.loadAddon(fit);
|
|
269
|
-
term.loadAddon(new Unicode11Addon.Unicode11Addon());
|
|
270
|
-
term.unicode.activeVersion = "11";
|
|
271
|
-
term.loadAddon(new WebLinksAddon.WebLinksAddon());
|
|
272
|
-
term.loadAddon(new ClipboardAddon.ClipboardAddon());
|
|
273
|
-
var opened = false;
|
|
274
|
-
var frame = 0;
|
|
275
|
-
/**
|
|
276
|
-
* xterm.js measures its cells on open, so a sidebar collapsed at load opens
|
|
277
|
-
* it only once the area is visible. A zero size never fits: it would send a
|
|
278
|
-
* resize the server rejects.
|
|
279
|
-
*/
|
|
280
|
-
function fitNow() {
|
|
281
|
-
frame = 0;
|
|
282
|
-
if (!mount.clientWidth || !mount.clientHeight) return;
|
|
283
|
-
if (!opened) { term.open(mount); opened = true; }
|
|
284
|
-
fit.fit();
|
|
285
|
-
}
|
|
286
|
-
function scheduleFit() { if (!frame) frame = requestAnimationFrame(fitNow); }
|
|
287
|
-
new ResizeObserver(scheduleFit).observe(mount);
|
|
288
|
-
fitNow();
|
|
289
|
-
|
|
290
|
-
var ws = null;
|
|
291
|
-
var attempts = 0;
|
|
292
|
-
var takenOver = false;
|
|
293
|
-
var pending = null;
|
|
294
|
-
|
|
295
|
-
function status(text) { if (statusNode) statusNode.textContent = text; }
|
|
296
|
-
function state(name) { panel.setAttribute("data-terminal-state", name); }
|
|
297
|
-
function currentSession() { return load(${JSON.stringify(TERMINAL_SESSION_KEY)}); }
|
|
298
|
-
var root = document.documentElement;
|
|
299
|
-
var choice = document.getElementById("terminal-action-choice");
|
|
300
|
-
var AGENT_LABELS = ${JSON.stringify(AGENT_LABELS)};
|
|
301
|
-
/** Which agent this connection views, or "pending" until a stored session reattaches; the page hides run buttons while set. */
|
|
302
|
-
function viewing(agent) {
|
|
303
|
-
if (agent) root.setAttribute("data-agent-viewed", agent);
|
|
304
|
-
else root.removeAttribute("data-agent-viewed");
|
|
305
|
-
if (agent && choice) choice.hidden = true;
|
|
306
|
-
}
|
|
307
|
-
if (currentSession()) viewing("pending");
|
|
308
|
-
function size() { return { cols: term.cols, rows: term.rows }; }
|
|
309
|
-
function send(message) {
|
|
310
|
-
if (ws && ws.readyState === 1) { ws.send(JSON.stringify(message)); return true; }
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
function attach(sessionId) {
|
|
314
|
-
var message = { type: "attach", sessionId: sessionId, tabId: tabId, cols: term.cols, rows: term.rows };
|
|
315
|
-
if (!send(message)) { pending = message; connect(); }
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function connect() {
|
|
319
|
-
if (ws && ws.readyState <= 1) return;
|
|
320
|
-
takenOver = false;
|
|
321
|
-
if (reconnectButton) reconnectButton.hidden = true;
|
|
322
|
-
ws = new WebSocket((location.protocol === "https:" ? "wss:" : "ws:") + "//" + location.host + "/api/terminal");
|
|
323
|
-
ws.binaryType = "arraybuffer";
|
|
324
|
-
ws.onopen = function () {
|
|
325
|
-
attempts = 0;
|
|
326
|
-
state("connected");
|
|
327
|
-
status("Connected.");
|
|
328
|
-
if (pending) { ws.send(JSON.stringify(pending)); pending = null; }
|
|
329
|
-
else if (currentSession()) attach(currentSession());
|
|
330
|
-
};
|
|
331
|
-
ws.onmessage = function (event) {
|
|
332
|
-
if (typeof event.data !== "string") { term.write(new Uint8Array(event.data)); return; }
|
|
333
|
-
var message;
|
|
334
|
-
try { message = JSON.parse(event.data); } catch (error) { return; }
|
|
335
|
-
if (message.type === "ready") {
|
|
336
|
-
store(${JSON.stringify(TERMINAL_SESSION_KEY)}, message.sessionId);
|
|
337
|
-
viewing(message.agent);
|
|
338
|
-
term.reset();
|
|
339
|
-
state("connected");
|
|
340
|
-
status("Connected to " + message.agent + " in " + message.companionPath + ".");
|
|
341
|
-
term.focus();
|
|
342
|
-
} else if (message.type === "exit") {
|
|
343
|
-
store(${JSON.stringify(TERMINAL_SESSION_KEY)}, null);
|
|
344
|
-
viewing(null);
|
|
345
|
-
state("detached");
|
|
346
|
-
status("The agent exited with status " + message.status + ".");
|
|
347
|
-
} else if (message.type === "ended") {
|
|
348
|
-
store(${JSON.stringify(TERMINAL_SESSION_KEY)}, null);
|
|
349
|
-
viewing(null);
|
|
350
|
-
state("detached");
|
|
351
|
-
status("The session ended" + (message.reason ? ": " + message.reason : "") + ".");
|
|
352
|
-
} else if (message.type === "detached") {
|
|
353
|
-
viewing(null);
|
|
354
|
-
state("detached");
|
|
355
|
-
status("Detached (" + message.reason + "); the agent keeps running.");
|
|
356
|
-
} else if (message.type === "takenOver") {
|
|
357
|
-
viewing(null);
|
|
358
|
-
takenOver = true;
|
|
359
|
-
state("detached");
|
|
360
|
-
status("Another tab took over this session.");
|
|
361
|
-
if (reconnectButton) reconnectButton.hidden = false;
|
|
362
|
-
} else if (message.type === "gone") {
|
|
363
|
-
store(${JSON.stringify(TERMINAL_SESSION_KEY)}, null);
|
|
364
|
-
viewing(null);
|
|
365
|
-
state("detached");
|
|
366
|
-
status("That session no longer exists.");
|
|
367
|
-
} else if (message.type === "error") {
|
|
368
|
-
status(message.reason);
|
|
369
|
-
}
|
|
370
|
-
refreshSessions();
|
|
371
|
-
};
|
|
372
|
-
ws.onclose = function () {
|
|
373
|
-
ws = null;
|
|
374
|
-
if (takenOver) return;
|
|
375
|
-
if (attempts >= MAX_ATTEMPTS) {
|
|
376
|
-
state("detached");
|
|
377
|
-
status("Disconnected.");
|
|
378
|
-
if (reconnectButton) reconnectButton.hidden = false;
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
var delay = FIRST_DELAY * Math.pow(2, attempts);
|
|
382
|
-
attempts += 1;
|
|
383
|
-
state("reconnecting");
|
|
384
|
-
status("Reconnecting (attempt " + attempts + " of " + MAX_ATTEMPTS + ")…");
|
|
385
|
-
setTimeout(connect, delay);
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
term.onData(function (data) { send({ type: "input", data: data }); });
|
|
390
|
-
var sent = { cols: term.cols, rows: term.rows };
|
|
391
|
-
term.onResize(function (next) {
|
|
392
|
-
if (next.cols === sent.cols && next.rows === sent.rows) return;
|
|
393
|
-
sent = { cols: next.cols, rows: next.rows };
|
|
394
|
-
send({ type: "resize", cols: next.cols, rows: next.rows });
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
/** \`task\` carries a registered action and subject; the server builds the prompt from them. */
|
|
398
|
-
function startAgent(agent, task) {
|
|
399
|
-
var dims = size();
|
|
400
|
-
var message = { type: "start", agent: agent, companion: companion, tabId: tabId, cols: dims.cols, rows: dims.rows };
|
|
401
|
-
if (task) { message.action = task.action; message.subject = task.subject; }
|
|
402
|
-
if (!send(message)) { pending = message; connect(); }
|
|
403
|
-
}
|
|
404
|
-
Array.prototype.forEach.call(document.querySelectorAll("[data-terminal-start]"), function (button) {
|
|
405
|
-
button.addEventListener("click", function () { startAgent(button.getAttribute("data-terminal-start")); });
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
/** The sidebar script owns collapse and drawer state, so reveal the terminal through its controls. */
|
|
409
|
-
function revealTerminal() {
|
|
410
|
-
var expand = document.getElementById("terminal-expand");
|
|
411
|
-
if (root.hasAttribute("data-terminal-collapsed") && expand) expand.click();
|
|
412
|
-
var opener = document.getElementById("terminal-drawer-open");
|
|
413
|
-
if (opener && !panel.hasAttribute("data-drawer-open") && getComputedStyle(opener).display !== "none") opener.click();
|
|
414
|
-
}
|
|
415
|
-
function showChoice(agents, task) {
|
|
416
|
-
if (!choice) return;
|
|
417
|
-
while (choice.firstChild) choice.removeChild(choice.firstChild);
|
|
418
|
-
var label = document.createElement("span");
|
|
419
|
-
label.textContent = "Run " + task.action + " with:";
|
|
420
|
-
choice.appendChild(label);
|
|
421
|
-
agents.forEach(function (agent) {
|
|
422
|
-
choice.appendChild(button(AGENT_LABELS[agent], function () {
|
|
423
|
-
choice.hidden = true;
|
|
424
|
-
startAgent(agent, task);
|
|
425
|
-
}));
|
|
426
|
-
});
|
|
427
|
-
choice.appendChild(button("Cancel", function () { choice.hidden = true; }));
|
|
428
|
-
choice.hidden = false;
|
|
429
|
-
}
|
|
430
|
-
document.addEventListener("studio:terminal-action", function (event) {
|
|
431
|
-
var task = event.detail || {};
|
|
432
|
-
var agents = (task.agents || []).filter(function (agent) { return AGENT_LABELS[agent]; });
|
|
433
|
-
if (!agents.length) return;
|
|
434
|
-
revealTerminal();
|
|
435
|
-
if (root.hasAttribute("data-agent-viewed")) { status("End the current session first."); return; }
|
|
436
|
-
if (agents.length === 1) startAgent(agents[0], task);
|
|
437
|
-
else showChoice(agents, task);
|
|
438
|
-
});
|
|
439
|
-
if (reconnectButton) reconnectButton.addEventListener("click", function () { attempts = 0; connect(); });
|
|
440
|
-
|
|
441
|
-
function age(seconds) {
|
|
442
|
-
if (seconds < 60) return seconds + " s";
|
|
443
|
-
if (seconds < 3600) return Math.floor(seconds / 60) + " min";
|
|
444
|
-
return Math.floor(seconds / 3600) + " h";
|
|
445
|
-
}
|
|
446
|
-
function button(label, onClick) {
|
|
447
|
-
var node = document.createElement("button");
|
|
448
|
-
node.type = "button";
|
|
449
|
-
node.className = "button";
|
|
450
|
-
node.textContent = label;
|
|
451
|
-
node.addEventListener("click", onClick);
|
|
452
|
-
return node;
|
|
453
|
-
}
|
|
454
|
-
function refreshSessions() {
|
|
455
|
-
if (!list) return;
|
|
456
|
-
fetch("/api/terminal/sessions", { credentials: "same-origin" }).then(function (response) {
|
|
457
|
-
return response.ok ? response.json() : { sessions: [] };
|
|
458
|
-
}).then(function (body) {
|
|
459
|
-
while (list.firstChild) list.removeChild(list.firstChild);
|
|
460
|
-
var mine = currentSession();
|
|
461
|
-
if (!body.sessions.length) {
|
|
462
|
-
var empty = document.createElement("li");
|
|
463
|
-
empty.className = "empty";
|
|
464
|
-
empty.textContent = "No sessions are running.";
|
|
465
|
-
list.appendChild(empty);
|
|
466
|
-
}
|
|
467
|
-
body.sessions.forEach(function (session) {
|
|
468
|
-
var item = document.createElement("li");
|
|
469
|
-
var label = document.createElement("span");
|
|
470
|
-
label.textContent = session.agent + " · " + session.companionPath + " · " + (session.id === mine ? "this tab" : session.attached ? "attached elsewhere" : "detached") + " · " + age(session.ageSeconds);
|
|
471
|
-
item.appendChild(label);
|
|
472
|
-
if (session.id !== mine) item.appendChild(button(session.attached ? "Take over" : "Attach", function () { attach(session.id); }));
|
|
473
|
-
item.appendChild(button("End", function () {
|
|
474
|
-
fetch("/api/terminal/sessions/end", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id: session.id }) }).then(refreshSessions);
|
|
475
|
-
}));
|
|
476
|
-
list.appendChild(item);
|
|
477
|
-
});
|
|
478
|
-
}).catch(function () { /* the next refresh retries */ });
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
connect();
|
|
482
|
-
refreshSessions();
|
|
483
|
-
setInterval(refreshSessions, 5000);
|
|
484
|
-
})();`;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { StudioVaultSelection } from "../../selection";
|
|
2
|
-
import type { VaultManager, VaultTreeResult } from "../../vault";
|
|
3
|
-
import type { StudioVaultPage } from "../model";
|
|
4
|
-
|
|
5
|
-
export async function vaultState(
|
|
6
|
-
manager: VaultManager,
|
|
7
|
-
companionPath: string,
|
|
8
|
-
sel: StudioVaultSelection,
|
|
9
|
-
options: { tree: "prefetch" | "await" },
|
|
10
|
-
): Promise<StudioVaultPage> {
|
|
11
|
-
let tree: VaultTreeResult | null = null;
|
|
12
|
-
let failure: string | null = null;
|
|
13
|
-
try {
|
|
14
|
-
tree =
|
|
15
|
-
options.tree === "prefetch"
|
|
16
|
-
? await manager.prefetch(companionPath, sel.refresh)
|
|
17
|
-
: await manager.tree(companionPath, sel.refresh);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
failure = error instanceof Error ? error.message : String(error);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let open: StudioVaultPage["open"] = null;
|
|
23
|
-
let refusal: string | null = null;
|
|
24
|
-
if (sel.openPath) {
|
|
25
|
-
try {
|
|
26
|
-
open = await manager.open(companionPath, sel.openPath);
|
|
27
|
-
} catch (error) {
|
|
28
|
-
refusal = error instanceof Error ? error.message : String(error);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
tree: tree?.tree ?? null,
|
|
34
|
-
open,
|
|
35
|
-
refusal,
|
|
36
|
-
incoming: null,
|
|
37
|
-
overwritten: null,
|
|
38
|
-
watching: tree?.watching ?? false,
|
|
39
|
-
warning: tree?.warning ?? null,
|
|
40
|
-
failure,
|
|
41
|
-
generation: tree?.generation ?? null,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource hono/jsx */
|
|
2
|
-
|
|
3
|
-
interface WarningsProps {
|
|
4
|
-
warnings: string[];
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/** Degraded collection is reported without costing the rest of the page. */
|
|
8
|
-
export function Warnings({ warnings }: WarningsProps) {
|
|
9
|
-
if (warnings.length === 0) return null;
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<section className="panel warnings">
|
|
13
|
-
<h3>Warnings</h3>
|
|
14
|
-
<ul className="plain">
|
|
15
|
-
{warnings.map((warning) => (
|
|
16
|
-
<li key={warning}>{warning}</li>
|
|
17
|
-
))}
|
|
18
|
-
</ul>
|
|
19
|
-
</section>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource hono/jsx */
|
|
2
|
-
|
|
3
|
-
import type { StudioCompanionPayload } from "../../payload";
|
|
4
|
-
import { Warnings } from "../warnings";
|
|
5
|
-
import { WorkflowTranscript } from "./transcript";
|
|
6
|
-
|
|
7
|
-
interface WorkflowProps {
|
|
8
|
-
payload: StudioCompanionPayload;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function Workflow({ payload }: WorkflowProps) {
|
|
12
|
-
return (
|
|
13
|
-
<>
|
|
14
|
-
<div className="workflow-view">
|
|
15
|
-
<div className="workflow-eyebrow">Workflow</div>
|
|
16
|
-
<WorkflowTranscript payload={payload} />
|
|
17
|
-
</div>
|
|
18
|
-
<Warnings warnings={payload.warnings} />
|
|
19
|
-
</>
|
|
20
|
-
);
|
|
21
|
-
}
|