@pellux/goodvibes-agent 0.1.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/.goodvibes/GOODVIBES.md +35 -0
- package/.goodvibes/agents/reviewer.md +48 -0
- package/.goodvibes/skills/add-provider/SKILL.md +199 -0
- package/CHANGELOG.md +25 -0
- package/README.md +74 -0
- package/bin/goodvibes-agent.ts +2 -0
- package/docs/README.md +23 -0
- package/docs/deployment-and-services.md +57 -0
- package/docs/getting-started.md +53 -0
- package/docs/release-and-publishing.md +46 -0
- package/package.json +134 -0
- package/scripts/check-bun.sh +20 -0
- package/src/audio/player.ts +156 -0
- package/src/audio/spoken-turn-controller.ts +203 -0
- package/src/audio/spoken-turn-model-routing.ts +117 -0
- package/src/audio/spoken-turn-wiring.ts +44 -0
- package/src/audio/text-chunker.ts +110 -0
- package/src/cli/bundle-command.ts +227 -0
- package/src/cli/completion.ts +90 -0
- package/src/cli/config-overrides.ts +159 -0
- package/src/cli/endpoints.ts +63 -0
- package/src/cli/entrypoint.ts +172 -0
- package/src/cli/help.ts +299 -0
- package/src/cli/index.ts +11 -0
- package/src/cli/management-commands.ts +426 -0
- package/src/cli/management.ts +744 -0
- package/src/cli/network-posture.ts +46 -0
- package/src/cli/package-verification.ts +123 -0
- package/src/cli/parser.ts +369 -0
- package/src/cli/provider-auth-routes.ts +22 -0
- package/src/cli/provider-classification.ts +107 -0
- package/src/cli/redaction.ts +105 -0
- package/src/cli/service-command.ts +26 -0
- package/src/cli/service-posture.ts +482 -0
- package/src/cli/status.ts +383 -0
- package/src/cli/surface-command.ts +247 -0
- package/src/cli/tui-startup.ts +32 -0
- package/src/cli/types.ts +69 -0
- package/src/cli-flags.ts +21 -0
- package/src/config/goodvibes-home-audit.ts +465 -0
- package/src/config/index.ts +57 -0
- package/src/config/provider-model.ts +23 -0
- package/src/config/secret-config.ts +119 -0
- package/src/config/secrets.ts +71 -0
- package/src/config/surface.ts +1 -0
- package/src/core/composer-state.ts +61 -0
- package/src/core/conversation-rendering.ts +359 -0
- package/src/core/conversation.ts +551 -0
- package/src/core/history.ts +45 -0
- package/src/core/orchestrator.ts +7 -0
- package/src/core/system-message-router.ts +171 -0
- package/src/daemon/cli.ts +55 -0
- package/src/daemon/safe-serve.ts +61 -0
- package/src/input/agent-workspace.ts +428 -0
- package/src/input/autocomplete.ts +96 -0
- package/src/input/bookmark-modal.ts +115 -0
- package/src/input/command-args-hint.ts +36 -0
- package/src/input/command-registry.ts +329 -0
- package/src/input/commands/agent-externalized-tui.ts +73 -0
- package/src/input/commands/agent-workspace-runtime.ts +17 -0
- package/src/input/commands/branch-runtime.ts +72 -0
- package/src/input/commands/cloudflare-runtime.ts +370 -0
- package/src/input/commands/config.ts +18 -0
- package/src/input/commands/control-room-runtime.ts +255 -0
- package/src/input/commands/conversation-runtime.ts +207 -0
- package/src/input/commands/discovery-runtime.ts +52 -0
- package/src/input/commands/eval.ts +204 -0
- package/src/input/commands/experience-runtime.ts +278 -0
- package/src/input/commands/guidance-runtime.ts +106 -0
- package/src/input/commands/health-runtime.ts +434 -0
- package/src/input/commands/hooks-runtime.ts +148 -0
- package/src/input/commands/incident-runtime.ts +95 -0
- package/src/input/commands/integration-runtime.ts +394 -0
- package/src/input/commands/intelligence-runtime.ts +223 -0
- package/src/input/commands/knowledge.ts +531 -0
- package/src/input/commands/local-auth-runtime.ts +105 -0
- package/src/input/commands/local-provider-runtime.ts +170 -0
- package/src/input/commands/local-runtime.ts +392 -0
- package/src/input/commands/local-setup-review.ts +199 -0
- package/src/input/commands/local-setup-transfer.ts +135 -0
- package/src/input/commands/local-setup.ts +282 -0
- package/src/input/commands/managed-runtime.ts +209 -0
- package/src/input/commands/marketplace-runtime.ts +290 -0
- package/src/input/commands/mcp-runtime.ts +432 -0
- package/src/input/commands/memory-product-runtime.ts +111 -0
- package/src/input/commands/memory.ts +151 -0
- package/src/input/commands/notify-runtime.ts +83 -0
- package/src/input/commands/onboarding-runtime.ts +14 -0
- package/src/input/commands/operator-panel-runtime.ts +146 -0
- package/src/input/commands/operator-runtime.ts +392 -0
- package/src/input/commands/planning-runtime.ts +205 -0
- package/src/input/commands/platform-access-runtime.ts +422 -0
- package/src/input/commands/platform-services-runtime.ts +246 -0
- package/src/input/commands/policy-dispatch.ts +339 -0
- package/src/input/commands/policy.ts +17 -0
- package/src/input/commands/product-runtime.ts +351 -0
- package/src/input/commands/profile-sync-runtime.ts +99 -0
- package/src/input/commands/provider-accounts-runtime.ts +113 -0
- package/src/input/commands/provider.ts +363 -0
- package/src/input/commands/qrcode-runtime.ts +20 -0
- package/src/input/commands/quit-shared.ts +162 -0
- package/src/input/commands/recall-bundle.ts +132 -0
- package/src/input/commands/recall-capture.ts +152 -0
- package/src/input/commands/recall-query.ts +229 -0
- package/src/input/commands/recall-review.ts +98 -0
- package/src/input/commands/recall-shared.ts +22 -0
- package/src/input/commands/remote-runtime-pool.ts +106 -0
- package/src/input/commands/remote-runtime-setup.ts +199 -0
- package/src/input/commands/remote-runtime.ts +431 -0
- package/src/input/commands/replay-runtime.ts +18 -0
- package/src/input/commands/runtime-services.ts +291 -0
- package/src/input/commands/schedule-runtime.ts +91 -0
- package/src/input/commands/services-runtime.ts +209 -0
- package/src/input/commands/session-content.ts +408 -0
- package/src/input/commands/session-workflow.ts +464 -0
- package/src/input/commands/session.ts +375 -0
- package/src/input/commands/settings-sync-runtime.ts +174 -0
- package/src/input/commands/share-runtime.ts +119 -0
- package/src/input/commands/shell-core.ts +307 -0
- package/src/input/commands/skills-runtime.ts +221 -0
- package/src/input/commands/subscription-runtime.ts +434 -0
- package/src/input/commands/tasks-runtime.ts +230 -0
- package/src/input/commands/teamwork-runtime.ts +339 -0
- package/src/input/commands/teleport-runtime.ts +57 -0
- package/src/input/commands/tts-runtime.ts +29 -0
- package/src/input/commands/work-plan-runtime.ts +169 -0
- package/src/input/commands.ts +131 -0
- package/src/input/feed-context-factory.ts +254 -0
- package/src/input/file-picker.ts +192 -0
- package/src/input/handler-command-route.ts +180 -0
- package/src/input/handler-content-actions.ts +497 -0
- package/src/input/handler-feed-routes.ts +648 -0
- package/src/input/handler-feed.ts +452 -0
- package/src/input/handler-interactions.ts +281 -0
- package/src/input/handler-modal-routes.ts +418 -0
- package/src/input/handler-modal-stack.ts +263 -0
- package/src/input/handler-modal-token-routes.ts +329 -0
- package/src/input/handler-onboarding-cloudflare.ts +391 -0
- package/src/input/handler-onboarding.ts +620 -0
- package/src/input/handler-picker-routes.ts +472 -0
- package/src/input/handler-prompt-buffer.ts +320 -0
- package/src/input/handler-shortcuts.ts +213 -0
- package/src/input/handler-ui-state.ts +372 -0
- package/src/input/handler.ts +729 -0
- package/src/input/input-history.ts +297 -0
- package/src/input/keybindings.ts +292 -0
- package/src/input/mcp-workspace.ts +554 -0
- package/src/input/model-picker-provider-filter.ts +28 -0
- package/src/input/model-picker-types.ts +137 -0
- package/src/input/model-picker.ts +797 -0
- package/src/input/onboarding/handler-onboarding-routes.ts +125 -0
- package/src/input/onboarding/onboarding-runtime-status.ts +87 -0
- package/src/input/onboarding/onboarding-wizard-apply.ts +277 -0
- package/src/input/onboarding/onboarding-wizard-cloudflare-step.ts +494 -0
- package/src/input/onboarding/onboarding-wizard-cloudflare.ts +204 -0
- package/src/input/onboarding/onboarding-wizard-constants.ts +158 -0
- package/src/input/onboarding/onboarding-wizard-external-surface-extra-specs.ts +130 -0
- package/src/input/onboarding/onboarding-wizard-external-surfaces.ts +762 -0
- package/src/input/onboarding/onboarding-wizard-helpers.ts +167 -0
- package/src/input/onboarding/onboarding-wizard-rules.ts +256 -0
- package/src/input/onboarding/onboarding-wizard-state.ts +365 -0
- package/src/input/onboarding/onboarding-wizard-steps.ts +798 -0
- package/src/input/onboarding/onboarding-wizard-types.ts +195 -0
- package/src/input/onboarding/onboarding-wizard.ts +711 -0
- package/src/input/panel-integration-actions.ts +78 -0
- package/src/input/profile-picker-modal.ts +222 -0
- package/src/input/search.ts +100 -0
- package/src/input/selection-modal.ts +163 -0
- package/src/input/selection.ts +135 -0
- package/src/input/session-picker-modal.ts +136 -0
- package/src/input/settings-modal-behavior.ts +37 -0
- package/src/input/settings-modal-secrets.ts +41 -0
- package/src/input/settings-modal-subscriptions.ts +95 -0
- package/src/input/settings-modal-types.ts +91 -0
- package/src/input/settings-modal.ts +793 -0
- package/src/input/submission-intent.ts +17 -0
- package/src/input/submission-router.ts +59 -0
- package/src/input/tts-settings-actions.ts +100 -0
- package/src/main.ts +792 -0
- package/src/mcp/runtime-reload.ts +81 -0
- package/src/panels/agent-inspector-panel.ts +521 -0
- package/src/panels/agent-inspector-shared.ts +94 -0
- package/src/panels/agent-logs-panel.ts +559 -0
- package/src/panels/agent-logs-shared.ts +129 -0
- package/src/panels/approval-panel.ts +150 -0
- package/src/panels/automation-control-panel.ts +212 -0
- package/src/panels/base-panel.ts +254 -0
- package/src/panels/builtin/agent.ts +117 -0
- package/src/panels/builtin/development.ts +31 -0
- package/src/panels/builtin/knowledge.ts +26 -0
- package/src/panels/builtin/operations.ts +349 -0
- package/src/panels/builtin/session.ts +129 -0
- package/src/panels/builtin/shared.ts +274 -0
- package/src/panels/builtin-panels.ts +23 -0
- package/src/panels/cockpit-panel.ts +183 -0
- package/src/panels/communication-panel.ts +153 -0
- package/src/panels/confirm-state.ts +61 -0
- package/src/panels/context-visualizer-panel.ts +204 -0
- package/src/panels/control-plane-panel.ts +211 -0
- package/src/panels/cost-tracker-panel.ts +444 -0
- package/src/panels/debug-panel.ts +432 -0
- package/src/panels/diff-panel.ts +520 -0
- package/src/panels/docs-panel.ts +283 -0
- package/src/panels/eval-panel.ts +399 -0
- package/src/panels/file-explorer-panel.ts +584 -0
- package/src/panels/file-preview-panel.ts +434 -0
- package/src/panels/forensics-panel.ts +364 -0
- package/src/panels/git-panel.ts +638 -0
- package/src/panels/hooks-panel.ts +239 -0
- package/src/panels/incident-review-panel.ts +197 -0
- package/src/panels/index.ts +46 -0
- package/src/panels/intelligence-panel.ts +176 -0
- package/src/panels/knowledge-panel.ts +345 -0
- package/src/panels/local-auth-panel.ts +130 -0
- package/src/panels/marketplace-panel.ts +212 -0
- package/src/panels/memory-panel.ts +225 -0
- package/src/panels/ops-control-panel.ts +150 -0
- package/src/panels/ops-strategy-panel.ts +235 -0
- package/src/panels/orchestration-panel.ts +273 -0
- package/src/panels/panel-list-panel.ts +509 -0
- package/src/panels/panel-manager.ts +570 -0
- package/src/panels/panel-picker.ts +106 -0
- package/src/panels/plan-dashboard-panel.ts +274 -0
- package/src/panels/plugins-panel.ts +178 -0
- package/src/panels/policy-panel.ts +308 -0
- package/src/panels/polish.ts +717 -0
- package/src/panels/project-planning-panel.ts +711 -0
- package/src/panels/provider-account-snapshot.ts +259 -0
- package/src/panels/provider-accounts-panel.ts +218 -0
- package/src/panels/provider-health-domains.ts +215 -0
- package/src/panels/provider-health-panel.ts +727 -0
- package/src/panels/provider-health-tracker.ts +115 -0
- package/src/panels/provider-stats-panel.ts +366 -0
- package/src/panels/qr-panel.ts +182 -0
- package/src/panels/remote-panel.ts +449 -0
- package/src/panels/routes-panel.ts +178 -0
- package/src/panels/sandbox-panel.ts +283 -0
- package/src/panels/schedule-panel.ts +329 -0
- package/src/panels/scrollable-list-panel.ts +491 -0
- package/src/panels/search-focus.ts +32 -0
- package/src/panels/security-panel.ts +295 -0
- package/src/panels/services-panel.ts +231 -0
- package/src/panels/session-browser-panel.ts +400 -0
- package/src/panels/session-maintenance.ts +125 -0
- package/src/panels/settings-sync-panel.ts +120 -0
- package/src/panels/skills-panel.ts +431 -0
- package/src/panels/subscription-panel.ts +263 -0
- package/src/panels/symbol-outline-panel.ts +486 -0
- package/src/panels/system-messages-panel.ts +230 -0
- package/src/panels/tasks-panel.ts +399 -0
- package/src/panels/thinking-panel.ts +304 -0
- package/src/panels/token-budget-panel.ts +475 -0
- package/src/panels/tool-inspector-panel.ts +429 -0
- package/src/panels/types.ts +54 -0
- package/src/panels/watchers-panel.ts +193 -0
- package/src/panels/work-plan-panel.ts +175 -0
- package/src/panels/worktree-panel.ts +182 -0
- package/src/panels/wrfc-panel.ts +609 -0
- package/src/permissions/prompt.ts +165 -0
- package/src/planning/project-planning-coordinator.ts +543 -0
- package/src/plugins/loader.ts +15 -0
- package/src/renderer/agent-detail-modal.ts +331 -0
- package/src/renderer/agent-workspace.ts +238 -0
- package/src/renderer/ansi-sanitize.ts +76 -0
- package/src/renderer/autocomplete-overlay.ts +154 -0
- package/src/renderer/block-actions.ts +76 -0
- package/src/renderer/bookmark-modal.ts +101 -0
- package/src/renderer/bottom-bar.ts +58 -0
- package/src/renderer/buffer.ts +113 -0
- package/src/renderer/code-block.ts +373 -0
- package/src/renderer/compositor.ts +283 -0
- package/src/renderer/context-inspector.ts +219 -0
- package/src/renderer/conversation-layout.ts +67 -0
- package/src/renderer/conversation-overlays.ts +140 -0
- package/src/renderer/conversation-surface.ts +260 -0
- package/src/renderer/diff-view.ts +132 -0
- package/src/renderer/diff.ts +130 -0
- package/src/renderer/file-picker-overlay.ts +101 -0
- package/src/renderer/file-tree.ts +153 -0
- package/src/renderer/fullscreen-primitives.ts +130 -0
- package/src/renderer/fullscreen-workspace.ts +199 -0
- package/src/renderer/git-status.ts +89 -0
- package/src/renderer/help-overlay.ts +267 -0
- package/src/renderer/history-search-overlay.ts +73 -0
- package/src/renderer/layout-engine.ts +97 -0
- package/src/renderer/layout.ts +32 -0
- package/src/renderer/live-tail-modal.ts +156 -0
- package/src/renderer/markdown.ts +635 -0
- package/src/renderer/mcp-workspace.ts +237 -0
- package/src/renderer/modal-factory.ts +467 -0
- package/src/renderer/modal-utils.ts +24 -0
- package/src/renderer/model-picker-overlay.ts +473 -0
- package/src/renderer/model-workspace.ts +488 -0
- package/src/renderer/onboarding/onboarding-wizard.ts +615 -0
- package/src/renderer/overlay-box.ts +146 -0
- package/src/renderer/overlay-viewport.ts +104 -0
- package/src/renderer/panel-composite.ts +158 -0
- package/src/renderer/panel-picker-overlay.ts +202 -0
- package/src/renderer/panel-tab-bar.ts +69 -0
- package/src/renderer/panel-workspace-bar.ts +42 -0
- package/src/renderer/process-indicator.ts +96 -0
- package/src/renderer/process-modal.ts +656 -0
- package/src/renderer/process-summary.ts +67 -0
- package/src/renderer/profile-picker-modal.ts +129 -0
- package/src/renderer/progress.ts +98 -0
- package/src/renderer/qr-renderer.ts +120 -0
- package/src/renderer/search-overlay.ts +54 -0
- package/src/renderer/selection-modal-overlay.ts +214 -0
- package/src/renderer/semantic-diff.ts +369 -0
- package/src/renderer/session-picker-modal.ts +127 -0
- package/src/renderer/settings-modal-helpers.ts +193 -0
- package/src/renderer/settings-modal.ts +537 -0
- package/src/renderer/shell-surface.ts +88 -0
- package/src/renderer/status-glyphs.ts +21 -0
- package/src/renderer/status-token.ts +67 -0
- package/src/renderer/surface-layout.ts +101 -0
- package/src/renderer/syntax-highlighter.ts +542 -0
- package/src/renderer/system-message.ts +83 -0
- package/src/renderer/tab-strip.ts +108 -0
- package/src/renderer/text-layout.ts +31 -0
- package/src/renderer/thinking.ts +17 -0
- package/src/renderer/tool-call.ts +234 -0
- package/src/renderer/ui-factory.ts +524 -0
- package/src/renderer/ui-primitives.ts +96 -0
- package/src/runtime/bootstrap-command-context.ts +278 -0
- package/src/runtime/bootstrap-command-parts.ts +386 -0
- package/src/runtime/bootstrap-core.ts +540 -0
- package/src/runtime/bootstrap-hook-bridge.ts +112 -0
- package/src/runtime/bootstrap-shell.ts +283 -0
- package/src/runtime/bootstrap.ts +575 -0
- package/src/runtime/cloudflare-control-plane.ts +349 -0
- package/src/runtime/context.ts +142 -0
- package/src/runtime/diagnostics/panels/index.ts +24 -0
- package/src/runtime/diagnostics/panels/ops.ts +156 -0
- package/src/runtime/diagnostics/panels/panel-resources.ts +118 -0
- package/src/runtime/diagnostics/panels/policy.ts +177 -0
- package/src/runtime/index.ts +662 -0
- package/src/runtime/onboarding/apply.ts +642 -0
- package/src/runtime/onboarding/derivation.ts +534 -0
- package/src/runtime/onboarding/index.ts +7 -0
- package/src/runtime/onboarding/markers.ts +148 -0
- package/src/runtime/onboarding/snapshot.ts +406 -0
- package/src/runtime/onboarding/state.ts +141 -0
- package/src/runtime/onboarding/types.ts +404 -0
- package/src/runtime/onboarding/verify.ts +171 -0
- package/src/runtime/operator-token-cleanup.ts +27 -0
- package/src/runtime/perf/panel-contracts.ts +32 -0
- package/src/runtime/perf/panel-health-monitor.ts +18 -0
- package/src/runtime/sandbox-public-gaps.ts +358 -0
- package/src/runtime/services.ts +670 -0
- package/src/runtime/store/domains/domain-read-matrix.ts +15 -0
- package/src/runtime/store/domains/index.ts +222 -0
- package/src/runtime/store/domains/panels.ts +117 -0
- package/src/runtime/store/domains/ui-perf.ts +103 -0
- package/src/runtime/store/index.ts +305 -0
- package/src/runtime/store/selectors/index.ts +359 -0
- package/src/runtime/store/state.ts +145 -0
- package/src/runtime/surface-feature-flags.ts +65 -0
- package/src/runtime/terminal-output-guard.ts +228 -0
- package/src/runtime/ui/index.ts +39 -0
- package/src/runtime/ui/model-picker/data-provider.ts +182 -0
- package/src/runtime/ui/model-picker/health-enrichment.ts +228 -0
- package/src/runtime/ui/model-picker/index.ts +59 -0
- package/src/runtime/ui/model-picker/types.ts +149 -0
- package/src/runtime/ui/provider-health/data-provider.ts +244 -0
- package/src/runtime/ui/provider-health/fallback-visualizer.ts +71 -0
- package/src/runtime/ui/provider-health/index.ts +46 -0
- package/src/runtime/ui/provider-health/types.ts +146 -0
- package/src/runtime/ui-events.ts +1 -0
- package/src/runtime/ui-read-model-helpers.ts +1 -0
- package/src/runtime/ui-read-models-observability-maintenance.ts +1 -0
- package/src/runtime/ui-read-models-observability-options.ts +1 -0
- package/src/runtime/ui-read-models-observability-remote.ts +1 -0
- package/src/runtime/ui-read-models-observability-security.ts +1 -0
- package/src/runtime/ui-read-models-observability-system.ts +1 -0
- package/src/runtime/ui-read-models-observability.ts +1 -0
- package/src/runtime/ui-read-models.ts +61 -0
- package/src/runtime/ui-service-queries.ts +1 -0
- package/src/runtime/ui-services.ts +190 -0
- package/src/scripts/process-messages.ts +42 -0
- package/src/shell/blocking-input.ts +98 -0
- package/src/shell/service-settings-sync.ts +273 -0
- package/src/shell/ui-openers.ts +352 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/wrfc-agent-guard.ts +49 -0
- package/src/types/grid.ts +48 -0
- package/src/types/sql-js.d.ts +15 -0
- package/src/utils/clipboard.ts +22 -0
- package/src/utils/splash-lines.ts +46 -0
- package/src/utils/terminal-width.ts +185 -0
- package/src/verification/live-verifier.ts +430 -0
- package/src/verification/verification-ledger.ts +242 -0
- package/src/version.ts +17 -0
- package/src/widget/index.ts +2 -0
- package/src/widget/types.ts +9 -0
- package/src/widget/widget.ts +8 -0
- package/src/work-plans/work-plan-store.ts +374 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { join, resolve } from 'path';
|
|
2
|
+
import { existsSync, mkdirSync, unlinkSync } from 'node:fs';
|
|
3
|
+
import { writeFile } from 'node:fs/promises';
|
|
4
|
+
import type { CommandRegistry } from '../command-registry.ts';
|
|
5
|
+
import type { SelectionItem } from '../selection-modal.ts';
|
|
6
|
+
import { exportToMarkdown } from '@pellux/goodvibes-sdk/platform/export';
|
|
7
|
+
import { TemplateManager, parseTemplateArgs } from '@pellux/goodvibes-sdk/platform/templates';
|
|
8
|
+
import { requireSessionManager, requireSessionMemoryStore, requireShellPaths } from './runtime-services.ts';
|
|
9
|
+
import { summarizeError } from '@pellux/goodvibes-sdk/platform/utils';
|
|
10
|
+
|
|
11
|
+
export function registerSessionContentCommands(registry: CommandRegistry): void {
|
|
12
|
+
registry.register({
|
|
13
|
+
name: 'export',
|
|
14
|
+
description: 'Export conversation to a Markdown file',
|
|
15
|
+
usage: '[format] [path]',
|
|
16
|
+
argsHint: '[markdown] [path]',
|
|
17
|
+
async handler(args, ctx) {
|
|
18
|
+
const shellPaths = requireShellPaths(ctx);
|
|
19
|
+
let format = 'markdown';
|
|
20
|
+
let outPath: string | undefined;
|
|
21
|
+
for (const arg of args) {
|
|
22
|
+
if (arg === 'markdown' || arg === 'md' || arg === 'text' || arg === 'txt') {
|
|
23
|
+
format = arg === 'md' ? 'markdown' : arg === 'txt' ? 'text' : arg;
|
|
24
|
+
} else {
|
|
25
|
+
outPath = arg;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!outPath) {
|
|
29
|
+
const ts = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
30
|
+
outPath = `./conversation-${ts}.${format === 'markdown' ? 'md' : 'txt'}`;
|
|
31
|
+
}
|
|
32
|
+
const resolvedPath = shellPaths.resolveWorkspacePath(outPath);
|
|
33
|
+
if (!shellPaths.isWithinWorkingDirectory(resolvedPath)) {
|
|
34
|
+
ctx.print('Error: Export path must be within the current directory.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const data = ctx.session.conversationManager.toJSON() as { messages: Array<Record<string, unknown>> };
|
|
40
|
+
const msgs = data.messages ?? [];
|
|
41
|
+
let fileContent: string;
|
|
42
|
+
if (format === 'markdown') {
|
|
43
|
+
const exportMsgs = msgs.map(m => ({
|
|
44
|
+
role: String(m.role ?? 'user') as 'user' | 'assistant' | 'system' | 'tool',
|
|
45
|
+
content: Array.isArray(m.content)
|
|
46
|
+
? m.content as import('@pellux/goodvibes-sdk/platform/providers').ContentPart[]
|
|
47
|
+
: String(m.content ?? ''),
|
|
48
|
+
toolCalls: m.toolCalls as import('@pellux/goodvibes-sdk/platform/types').ToolCall[] | undefined,
|
|
49
|
+
callId: m.callId as string | undefined,
|
|
50
|
+
toolName: m.toolName as string | undefined,
|
|
51
|
+
reasoningContent: m.reasoningContent as string | undefined,
|
|
52
|
+
reasoningSummary: m.reasoningSummary as string | undefined,
|
|
53
|
+
usage: m.usage as { inputTokens: number; outputTokens: number; cacheReadTokens?: number; cacheWriteTokens?: number } | undefined,
|
|
54
|
+
}));
|
|
55
|
+
fileContent = exportToMarkdown(exportMsgs, {
|
|
56
|
+
model: ctx.session.runtime.model,
|
|
57
|
+
provider: ctx.session.runtime.provider,
|
|
58
|
+
sessionId: ctx.session.runtime.sessionId,
|
|
59
|
+
title: ctx.session.conversationManager.title || undefined,
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
const lines: string[] = [];
|
|
63
|
+
for (const m of msgs) {
|
|
64
|
+
const role = String(m.role ?? 'unknown').toUpperCase();
|
|
65
|
+
const content = typeof m.content === 'string' ? m.content : '';
|
|
66
|
+
if (!content.trim()) continue;
|
|
67
|
+
lines.push(`[${role}]`);
|
|
68
|
+
lines.push(content);
|
|
69
|
+
lines.push('');
|
|
70
|
+
}
|
|
71
|
+
fileContent = lines.join('\n');
|
|
72
|
+
}
|
|
73
|
+
const { dirname } = await import('node:path');
|
|
74
|
+
const dir = dirname(resolvedPath);
|
|
75
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
76
|
+
await writeFile(resolvedPath, fileContent, 'utf-8');
|
|
77
|
+
ctx.print(`Exported ${msgs.length} messages to: ${resolvedPath}`);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
ctx.print(`Export failed: ${summarizeError(err)}`);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
registry.register({
|
|
85
|
+
name: 'title',
|
|
86
|
+
description: 'Show or set the conversation title',
|
|
87
|
+
usage: '[text]',
|
|
88
|
+
argsHint: '[text]',
|
|
89
|
+
handler(args, ctx) {
|
|
90
|
+
if (args.length === 0) ctx.print(ctx.session.conversationManager.title ? `Conversation title: ${ctx.session.conversationManager.title}` : 'No title set.');
|
|
91
|
+
else {
|
|
92
|
+
ctx.session.conversationManager.title = args.join(' ');
|
|
93
|
+
ctx.print(`Title set to: ${ctx.session.conversationManager.title}`);
|
|
94
|
+
ctx.renderRequest();
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
registry.register({
|
|
100
|
+
name: 'save',
|
|
101
|
+
description: 'Save current session to .goodvibes/agent/sessions/',
|
|
102
|
+
usage: '[name]',
|
|
103
|
+
argsHint: '[name]',
|
|
104
|
+
handler(args, ctx) {
|
|
105
|
+
const sessionManager = requireSessionManager(ctx);
|
|
106
|
+
const rawName = args[0] || ctx.session.conversationManager.title || `session-${Date.now()}`;
|
|
107
|
+
const exportData = ctx.session.conversationManager.toJSON() as { messages: object[] };
|
|
108
|
+
const messages = exportData.messages ?? [];
|
|
109
|
+
const meta = {
|
|
110
|
+
title: ctx.session.conversationManager.title,
|
|
111
|
+
model: ctx.session.runtime.model,
|
|
112
|
+
provider: ctx.session.runtime.provider,
|
|
113
|
+
timestamp: Date.now(),
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
const agentManager = ctx.ops.agentManager;
|
|
117
|
+
if (!agentManager) {
|
|
118
|
+
ctx.print('Agent manager is not available in this runtime.');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const agentRecords = agentManager.exportState();
|
|
122
|
+
const { filePath, sanitizedName } = sessionManager.save(rawName, messages, meta, agentRecords);
|
|
123
|
+
ctx.print(`Session saved: ${rawName}${sanitizedName !== rawName ? ` (saved as "${sanitizedName}")` : ''}${agentRecords.length > 0 ? ` [${agentRecords.length} agent records]` : ''}\n → ${filePath}`);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
ctx.print(`Failed to save session: ${summarizeError(e)}`);
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
registry.register({
|
|
131
|
+
name: 'load',
|
|
132
|
+
description: 'Load a saved session',
|
|
133
|
+
usage: '<name>',
|
|
134
|
+
argsHint: '<name>',
|
|
135
|
+
handler(args, ctx) {
|
|
136
|
+
if (!args[0]) {
|
|
137
|
+
ctx.print('Usage: /load <session-name>\nRun /sessions to list available sessions.');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const sessionManager = requireSessionManager(ctx);
|
|
141
|
+
try {
|
|
142
|
+
const { meta, messages, agentRecords } = sessionManager.load(args[0]);
|
|
143
|
+
const agentManager = ctx.ops.agentManager;
|
|
144
|
+
if (!agentManager) {
|
|
145
|
+
ctx.print('Agent manager is not available in this runtime.');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
ctx.session.conversationManager.resetAll();
|
|
149
|
+
ctx.session.conversationManager.fromJSON({ messages: messages as never[] });
|
|
150
|
+
if (meta.title) ctx.session.conversationManager.title = meta.title;
|
|
151
|
+
ctx.session.conversationManager.rebuildHistory();
|
|
152
|
+
agentManager.clear();
|
|
153
|
+
if (agentRecords.length > 0) agentManager.importState(agentRecords);
|
|
154
|
+
ctx.renderRequest();
|
|
155
|
+
ctx.print(`Session loaded: ${args[0]} (${messages.length} messages)${agentRecords.length > 0 ? ` [${agentRecords.length} agent records restored]` : ''}`);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
ctx.print(`Failed to load session: ${summarizeError(e)}`);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
registry.register({
|
|
163
|
+
name: 'undo',
|
|
164
|
+
aliases: [],
|
|
165
|
+
description: 'Undo last action. /undo file — revert last file write/edit. /undo — remove last conversation turn.',
|
|
166
|
+
usage: '[file]',
|
|
167
|
+
argsHint: '[file]',
|
|
168
|
+
handler(args, ctx) {
|
|
169
|
+
if (args[0] === 'file') {
|
|
170
|
+
if (!ctx.workspace.fileUndoManager) {
|
|
171
|
+
ctx.print('File undo not available.');
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const result = ctx.workspace.fileUndoManager.undo();
|
|
176
|
+
ctx.print(result ? `File reverted: ${result.path} (${result.tool} tool). Use /redo file to re-apply.` : 'Nothing to undo. No file operations recorded.');
|
|
177
|
+
} catch (err) {
|
|
178
|
+
ctx.print(`File undo failed: ${summarizeError(err)}`);
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const success = ctx.session.conversationManager.undo();
|
|
183
|
+
if (success) {
|
|
184
|
+
ctx.print('Last turn undone. Use /redo to restore. Tip: /undo file to revert a file write/edit.');
|
|
185
|
+
ctx.renderRequest();
|
|
186
|
+
} else {
|
|
187
|
+
ctx.print('Nothing to undo. Tip: use /undo file to revert the last file write/edit.');
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
registry.register({
|
|
193
|
+
name: 'redo',
|
|
194
|
+
description: 'Redo last undone action. /redo file — re-apply last reverted file. /redo — restore conversation turn.',
|
|
195
|
+
usage: '[file]',
|
|
196
|
+
argsHint: '[file]',
|
|
197
|
+
handler(args, ctx) {
|
|
198
|
+
if (args[0] === 'file') {
|
|
199
|
+
if (!ctx.workspace.fileUndoManager) {
|
|
200
|
+
ctx.print('File redo not available.');
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const result = ctx.workspace.fileUndoManager.redo();
|
|
205
|
+
ctx.print(result ? `File re-applied: ${result.path} (${result.tool} tool).` : 'Nothing to redo.');
|
|
206
|
+
} catch (err) {
|
|
207
|
+
ctx.print(`File redo failed: ${summarizeError(err)}`);
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const success = ctx.session.conversationManager.redo();
|
|
212
|
+
if (success) {
|
|
213
|
+
ctx.print('Turn restored. Tip: /redo file to re-apply a reverted file.');
|
|
214
|
+
ctx.renderRequest();
|
|
215
|
+
} else {
|
|
216
|
+
ctx.print('Nothing to redo. Tip: use /redo file to re-apply the last reverted file.');
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
registry.register({
|
|
222
|
+
name: 'retry',
|
|
223
|
+
aliases: ['r'],
|
|
224
|
+
description: 'Re-send the last user message',
|
|
225
|
+
usage: '[modified text]',
|
|
226
|
+
argsHint: '[modified text]',
|
|
227
|
+
handler(args, ctx) {
|
|
228
|
+
const lastMsg = ctx.session.conversationManager.getLastUserMessage();
|
|
229
|
+
if (!lastMsg) {
|
|
230
|
+
ctx.print('No message to retry.');
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
ctx.session.conversationManager.undo();
|
|
234
|
+
ctx.submitInput?.(args.length > 0 ? args.join(' ') : lastMsg);
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
registry.register({
|
|
239
|
+
name: 'sessions',
|
|
240
|
+
description: 'List saved sessions',
|
|
241
|
+
async handler(_args, ctx) {
|
|
242
|
+
const sessionManager = requireSessionManager(ctx);
|
|
243
|
+
const sessions = sessionManager.list();
|
|
244
|
+
if (ctx.openSelection) {
|
|
245
|
+
const deleteAction = new Map([['d', 'delete' as const]]);
|
|
246
|
+
const items: SelectionItem[] = sessions.length === 0
|
|
247
|
+
? [{ id: '_empty', label: 'No saved sessions', detail: 'Use /save [name] to save' }]
|
|
248
|
+
: sessions.map(s => ({ id: s.name, label: s.name, detail: s.title || '(untitled)', actions: '[d] delete' }));
|
|
249
|
+
ctx.openSelection('Sessions', items, { allowSearch: true, customActions: deleteAction }, (result) => {
|
|
250
|
+
if (!result) return;
|
|
251
|
+
if (result.action === 'delete') {
|
|
252
|
+
try {
|
|
253
|
+
const sessionInfo = sessions.find(s => s.name === result.item.id);
|
|
254
|
+
if (sessionInfo) {
|
|
255
|
+
unlinkSync(sessionInfo.filePath);
|
|
256
|
+
ctx.print(`Session deleted: ${result.item.id}`);
|
|
257
|
+
}
|
|
258
|
+
} catch (e) {
|
|
259
|
+
ctx.print(`Failed to delete session: ${summarizeError(e)}`);
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
try {
|
|
263
|
+
const { meta, messages } = sessionManager.load(result.item.id);
|
|
264
|
+
ctx.session.conversationManager.resetAll();
|
|
265
|
+
ctx.session.conversationManager.fromJSON({ messages: messages as never[] });
|
|
266
|
+
if (meta.title) ctx.session.conversationManager.title = meta.title;
|
|
267
|
+
ctx.session.conversationManager.rebuildHistory();
|
|
268
|
+
ctx.renderRequest();
|
|
269
|
+
ctx.print(`Session loaded: ${result.item.id} (${messages.length} messages)`);
|
|
270
|
+
} catch (e) {
|
|
271
|
+
ctx.print(`Failed to load session: ${summarizeError(e)}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const lines = ['Saved sessions:', ''];
|
|
278
|
+
for (const s of sessions) lines.push(` ${s.name.padEnd(30)} ${(s.title || '(untitled)').padEnd(24)} ${new Date(s.timestamp).toLocaleString()} (${s.messageCount} msgs)`);
|
|
279
|
+
ctx.print(lines.join('\n'));
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
registry.register({
|
|
284
|
+
name: 'template',
|
|
285
|
+
aliases: ['tmpl'],
|
|
286
|
+
description: 'Manage and use prompt templates',
|
|
287
|
+
usage: 'save <name> | use <name> [args] | list | edit <name> | delete <name>',
|
|
288
|
+
argsHint: '<save|use|list|edit|delete> [name]',
|
|
289
|
+
handler(args, ctx) {
|
|
290
|
+
const shellPaths = requireShellPaths(ctx);
|
|
291
|
+
const templateManager = new TemplateManager({
|
|
292
|
+
projectRoot: shellPaths.workingDirectory,
|
|
293
|
+
homeDirectory: shellPaths.homeDirectory,
|
|
294
|
+
});
|
|
295
|
+
const sub = args[0];
|
|
296
|
+
const rest = args.slice(1);
|
|
297
|
+
if (!sub || sub === 'list') {
|
|
298
|
+
const templates = templateManager.list();
|
|
299
|
+
if (ctx.openSelection) {
|
|
300
|
+
const actions = new Map([['d', 'delete' as const], ['e', 'edit' as const]]);
|
|
301
|
+
const items: SelectionItem[] = templates.length === 0
|
|
302
|
+
? [{ id: '_empty', label: 'No templates saved', detail: 'Use /template save <name>' }]
|
|
303
|
+
: templates.map(t => ({ id: t.name, label: t.name, detail: t.preview, category: t.scope === 'project' ? 'project' : 'global', actions: '[d] delete [e] edit' }));
|
|
304
|
+
ctx.openSelection('Templates', items, { allowSearch: true, customActions: actions }, (result) => {
|
|
305
|
+
if (!result) return;
|
|
306
|
+
if (result.action === 'delete') {
|
|
307
|
+
const deleted = templateManager.delete(result.item.id);
|
|
308
|
+
ctx.print(deleted ? `Template deleted: ${result.item.id}` : `Template not found: ${result.item.id}`);
|
|
309
|
+
} else {
|
|
310
|
+
const content = templateManager.load(result.item.id);
|
|
311
|
+
if (content !== null) {
|
|
312
|
+
if (result.action === 'edit') ctx.print(`Template: ${result.item.id}\n\n${content}`);
|
|
313
|
+
else ctx.submitInput?.(content);
|
|
314
|
+
} else {
|
|
315
|
+
ctx.print(`Template not found: ${result.item.id}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
ctx.print(['Templates:', '', ...templates.map(t => ` ${t.scope === 'project' ? '[project]' : '[global] '} ${t.name.padEnd(28)} ${t.preview}`)].join('\n'));
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (sub === 'save') {
|
|
325
|
+
const name = rest[0];
|
|
326
|
+
if (!name) {
|
|
327
|
+
ctx.print('Usage: /template save <name>');
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
try {
|
|
331
|
+
templateManager.save(name, ctx.session.conversationManager.getLastUserMessage() || '# Template\n\nReplace this with your template content.\n');
|
|
332
|
+
ctx.print(`Template saved: ${name}`);
|
|
333
|
+
} catch (e) {
|
|
334
|
+
ctx.print(`Failed to save template: ${summarizeError(e)}`);
|
|
335
|
+
}
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (sub === 'use') {
|
|
339
|
+
const name = rest[0];
|
|
340
|
+
if (!name) {
|
|
341
|
+
ctx.print('Usage: /template use <name> [args...]');
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const templateContent = templateManager.load(name);
|
|
345
|
+
if (templateContent === null) {
|
|
346
|
+
ctx.print(`Template not found: ${name}\nRun /template list to see available templates.`);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
ctx.submitInput?.(templateManager.expand(templateContent, parseTemplateArgs(rest.slice(1))));
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (sub === 'edit') {
|
|
353
|
+
const name = rest[0];
|
|
354
|
+
if (!name) {
|
|
355
|
+
ctx.print('Usage: /template edit <name>');
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const content = templateManager.load(name);
|
|
359
|
+
ctx.print(content === null ? `Template not found: ${name}` : `Template: ${name}\n\n${content}`);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (sub === 'delete') {
|
|
363
|
+
const name = rest[0];
|
|
364
|
+
if (!name) {
|
|
365
|
+
ctx.print('Usage: /template delete <name>');
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
ctx.print(templateManager.delete(name) ? `Template deleted: ${name}` : `Template not found: ${name}`);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
ctx.print(`Unknown subcommand: ${sub}\nUsage: /template save|use|list|edit|delete`);
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
registry.register({
|
|
376
|
+
name: 'memory',
|
|
377
|
+
description: 'Manage session memories (pinned across context compaction)',
|
|
378
|
+
usage: '[list|add <text>|remove <id>]',
|
|
379
|
+
argsHint: '[list|add|remove]',
|
|
380
|
+
handler(args, ctx) {
|
|
381
|
+
const sub = args[0] ?? 'list';
|
|
382
|
+
if (sub === 'list' || args.length === 0) {
|
|
383
|
+
const memories = requireSessionMemoryStore(ctx).list();
|
|
384
|
+
ctx.print(memories.length === 0
|
|
385
|
+
? 'No session memories. Use !# prefix or /memory add <text> to create one.'
|
|
386
|
+
: [`Session Memories (${memories.length}):`, ...memories.map(m => ` [${m.id}] ${m.text}`)].join('\n'));
|
|
387
|
+
} else if (sub === 'add') {
|
|
388
|
+
const text = args.slice(1).join(' ').trim();
|
|
389
|
+
if (!text) {
|
|
390
|
+
ctx.print('Usage: /memory add <text>');
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
const id = requireSessionMemoryStore(ctx).add(text);
|
|
394
|
+
ctx.print(`Memory added: [${id}] ${text}`);
|
|
395
|
+
} else if (sub === 'remove') {
|
|
396
|
+
const id = args[1];
|
|
397
|
+
if (!id) {
|
|
398
|
+
ctx.print('Usage: /memory remove <id>');
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const store = requireSessionMemoryStore(ctx);
|
|
402
|
+
ctx.print(store.remove(id) ? `Memory removed: [${id}]` : `Memory not found: ${id}`);
|
|
403
|
+
} else {
|
|
404
|
+
ctx.print('Usage: /memory [list|add <text>|remove <id>]\n /memory — list all session memories\n /memory list — list all session memories\n /memory add <text> — add a memory without sending a message\n /memory remove <id> — remove a specific memory');
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
});
|
|
408
|
+
}
|