@oh-my-pi/pi-coding-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/CHANGELOG.md +1629 -0
- package/README.md +1041 -0
- package/docs/compaction.md +403 -0
- package/docs/config-usage.md +113 -0
- package/docs/custom-tools.md +541 -0
- package/docs/extension-loading.md +1004 -0
- package/docs/hooks.md +867 -0
- package/docs/rpc.md +1040 -0
- package/docs/sdk.md +994 -0
- package/docs/session-tree-plan.md +441 -0
- package/docs/session.md +240 -0
- package/docs/skills.md +290 -0
- package/docs/theme.md +670 -0
- package/docs/tree.md +197 -0
- package/docs/tui.md +341 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +124 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/custom-tools/question/index.ts +84 -0
- package/examples/custom-tools/subagent/README.md +172 -0
- package/examples/custom-tools/subagent/agents/planner.md +37 -0
- package/examples/custom-tools/subagent/agents/scout.md +50 -0
- package/examples/custom-tools/subagent/agents/worker.md +24 -0
- package/examples/custom-tools/subagent/agents.ts +156 -0
- package/examples/custom-tools/subagent/commands/implement-and-review.md +10 -0
- package/examples/custom-tools/subagent/commands/implement.md +10 -0
- package/examples/custom-tools/subagent/commands/scout-and-plan.md +9 -0
- package/examples/custom-tools/subagent/index.ts +1002 -0
- package/examples/custom-tools/todo/index.ts +212 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +49 -0
- package/examples/hooks/confirm-destructive.ts +59 -0
- package/examples/hooks/custom-compaction.ts +116 -0
- package/examples/hooks/dirty-repo-guard.ts +52 -0
- package/examples/hooks/file-trigger.ts +41 -0
- package/examples/hooks/git-checkpoint.ts +53 -0
- package/examples/hooks/handoff.ts +150 -0
- package/examples/hooks/permission-gate.ts +34 -0
- package/examples/hooks/protected-paths.ts +30 -0
- package/examples/hooks/qna.ts +119 -0
- package/examples/hooks/snake.ts +343 -0
- package/examples/hooks/status-line.ts +40 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +44 -0
- package/examples/sdk/04-skills.ts +44 -0
- package/examples/sdk/05-tools.ts +90 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +36 -0
- package/examples/sdk/08-slash-commands.ts +42 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +55 -0
- package/examples/sdk/10-settings.ts +38 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +95 -0
- package/examples/sdk/README.md +154 -0
- package/package.json +89 -0
- package/src/bun-imports.d.ts +16 -0
- package/src/capability/context-file.ts +40 -0
- package/src/capability/extension.ts +48 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +616 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +52 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +56 -0
- package/src/capability/settings.ts +35 -0
- package/src/capability/skill.ts +49 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/system-prompt.ts +35 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +166 -0
- package/src/cli/args.ts +259 -0
- package/src/cli/file-processor.ts +121 -0
- package/src/cli/list-models.ts +104 -0
- package/src/cli/plugin-cli.ts +661 -0
- package/src/cli/session-picker.ts +41 -0
- package/src/cli/update-cli.ts +274 -0
- package/src/cli.ts +10 -0
- package/src/config.ts +391 -0
- package/src/core/agent-session.ts +2178 -0
- package/src/core/auth-storage.ts +258 -0
- package/src/core/bash-executor.ts +197 -0
- package/src/core/compaction/branch-summarization.ts +315 -0
- package/src/core/compaction/compaction.ts +664 -0
- package/src/core/compaction/index.ts +7 -0
- package/src/core/compaction/utils.ts +153 -0
- package/src/core/custom-commands/bundled/review/index.ts +156 -0
- package/src/core/custom-commands/index.ts +15 -0
- package/src/core/custom-commands/loader.ts +226 -0
- package/src/core/custom-commands/types.ts +112 -0
- package/src/core/custom-tools/index.ts +22 -0
- package/src/core/custom-tools/loader.ts +248 -0
- package/src/core/custom-tools/types.ts +185 -0
- package/src/core/custom-tools/wrapper.ts +29 -0
- package/src/core/exec.ts +139 -0
- package/src/core/export-html/index.ts +159 -0
- package/src/core/export-html/template.css +774 -0
- package/src/core/export-html/template.generated.ts +2 -0
- package/src/core/export-html/template.html +45 -0
- package/src/core/export-html/template.js +1185 -0
- package/src/core/export-html/template.macro.ts +24 -0
- package/src/core/file-mentions.ts +54 -0
- package/src/core/hooks/index.ts +16 -0
- package/src/core/hooks/loader.ts +288 -0
- package/src/core/hooks/runner.ts +434 -0
- package/src/core/hooks/tool-wrapper.ts +98 -0
- package/src/core/hooks/types.ts +770 -0
- package/src/core/index.ts +53 -0
- package/src/core/logger.ts +112 -0
- package/src/core/mcp/client.ts +185 -0
- package/src/core/mcp/config.ts +248 -0
- package/src/core/mcp/index.ts +45 -0
- package/src/core/mcp/loader.ts +99 -0
- package/src/core/mcp/manager.ts +235 -0
- package/src/core/mcp/tool-bridge.ts +156 -0
- package/src/core/mcp/transports/http.ts +316 -0
- package/src/core/mcp/transports/index.ts +6 -0
- package/src/core/mcp/transports/stdio.ts +252 -0
- package/src/core/mcp/types.ts +228 -0
- package/src/core/messages.ts +211 -0
- package/src/core/model-registry.ts +334 -0
- package/src/core/model-resolver.ts +494 -0
- package/src/core/plugins/doctor.ts +67 -0
- package/src/core/plugins/index.ts +38 -0
- package/src/core/plugins/installer.ts +189 -0
- package/src/core/plugins/loader.ts +339 -0
- package/src/core/plugins/manager.ts +672 -0
- package/src/core/plugins/parser.ts +105 -0
- package/src/core/plugins/paths.ts +37 -0
- package/src/core/plugins/types.ts +190 -0
- package/src/core/sdk.ts +900 -0
- package/src/core/session-manager.ts +1837 -0
- package/src/core/settings-manager.ts +860 -0
- package/src/core/skills.ts +352 -0
- package/src/core/slash-commands.ts +132 -0
- package/src/core/system-prompt.ts +442 -0
- package/src/core/timings.ts +25 -0
- package/src/core/title-generator.ts +110 -0
- package/src/core/tools/ask.ts +193 -0
- package/src/core/tools/bash-interceptor.ts +120 -0
- package/src/core/tools/bash.ts +91 -0
- package/src/core/tools/context.ts +32 -0
- package/src/core/tools/edit-diff.ts +487 -0
- package/src/core/tools/edit.ts +140 -0
- package/src/core/tools/exa/company.ts +59 -0
- package/src/core/tools/exa/index.ts +63 -0
- package/src/core/tools/exa/linkedin.ts +59 -0
- package/src/core/tools/exa/mcp-client.ts +368 -0
- package/src/core/tools/exa/render.ts +200 -0
- package/src/core/tools/exa/researcher.ts +90 -0
- package/src/core/tools/exa/search.ts +338 -0
- package/src/core/tools/exa/types.ts +167 -0
- package/src/core/tools/exa/websets.ts +248 -0
- package/src/core/tools/find.ts +244 -0
- package/src/core/tools/grep.ts +584 -0
- package/src/core/tools/index.ts +283 -0
- package/src/core/tools/ls.ts +142 -0
- package/src/core/tools/lsp/client.ts +767 -0
- package/src/core/tools/lsp/clients/biome-client.ts +207 -0
- package/src/core/tools/lsp/clients/index.ts +49 -0
- package/src/core/tools/lsp/clients/lsp-linter-client.ts +98 -0
- package/src/core/tools/lsp/config.ts +845 -0
- package/src/core/tools/lsp/edits.ts +110 -0
- package/src/core/tools/lsp/index.ts +1364 -0
- package/src/core/tools/lsp/render.ts +560 -0
- package/src/core/tools/lsp/rust-analyzer.ts +145 -0
- package/src/core/tools/lsp/types.ts +495 -0
- package/src/core/tools/lsp/utils.ts +526 -0
- package/src/core/tools/notebook.ts +182 -0
- package/src/core/tools/output.ts +198 -0
- package/src/core/tools/path-utils.ts +61 -0
- package/src/core/tools/read.ts +507 -0
- package/src/core/tools/renderers.ts +820 -0
- package/src/core/tools/review.ts +275 -0
- package/src/core/tools/rulebook.ts +124 -0
- package/src/core/tools/task/agents.ts +158 -0
- package/src/core/tools/task/artifacts.ts +114 -0
- package/src/core/tools/task/commands.ts +157 -0
- package/src/core/tools/task/discovery.ts +217 -0
- package/src/core/tools/task/executor.ts +531 -0
- package/src/core/tools/task/index.ts +548 -0
- package/src/core/tools/task/model-resolver.ts +176 -0
- package/src/core/tools/task/parallel.ts +38 -0
- package/src/core/tools/task/render.ts +502 -0
- package/src/core/tools/task/subprocess-tool-registry.ts +89 -0
- package/src/core/tools/task/types.ts +142 -0
- package/src/core/tools/truncate.ts +265 -0
- package/src/core/tools/web-fetch.ts +2511 -0
- package/src/core/tools/web-search/auth.ts +199 -0
- package/src/core/tools/web-search/index.ts +583 -0
- package/src/core/tools/web-search/providers/anthropic.ts +198 -0
- package/src/core/tools/web-search/providers/exa.ts +196 -0
- package/src/core/tools/web-search/providers/perplexity.ts +195 -0
- package/src/core/tools/web-search/render.ts +372 -0
- package/src/core/tools/web-search/types.ts +180 -0
- package/src/core/tools/write.ts +63 -0
- package/src/core/ttsr.ts +211 -0
- package/src/core/utils.ts +187 -0
- package/src/discovery/agents-md.ts +75 -0
- package/src/discovery/builtin.ts +647 -0
- package/src/discovery/claude.ts +623 -0
- package/src/discovery/cline.ts +104 -0
- package/src/discovery/codex.ts +571 -0
- package/src/discovery/cursor.ts +266 -0
- package/src/discovery/gemini.ts +368 -0
- package/src/discovery/github.ts +120 -0
- package/src/discovery/helpers.test.ts +127 -0
- package/src/discovery/helpers.ts +249 -0
- package/src/discovery/index.ts +84 -0
- package/src/discovery/mcp-json.ts +127 -0
- package/src/discovery/vscode.ts +99 -0
- package/src/discovery/windsurf.ts +219 -0
- package/src/index.ts +192 -0
- package/src/main.ts +507 -0
- package/src/migrations.ts +156 -0
- package/src/modes/cleanup.ts +23 -0
- package/src/modes/index.ts +48 -0
- package/src/modes/interactive/components/armin.ts +382 -0
- package/src/modes/interactive/components/assistant-message.ts +86 -0
- package/src/modes/interactive/components/bash-execution.ts +199 -0
- package/src/modes/interactive/components/bordered-loader.ts +41 -0
- package/src/modes/interactive/components/branch-summary-message.ts +42 -0
- package/src/modes/interactive/components/compaction-summary-message.ts +45 -0
- package/src/modes/interactive/components/custom-editor.ts +122 -0
- package/src/modes/interactive/components/diff.ts +147 -0
- package/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/src/modes/interactive/components/extensions/extension-dashboard.ts +296 -0
- package/src/modes/interactive/components/extensions/extension-list.ts +479 -0
- package/src/modes/interactive/components/extensions/index.ts +9 -0
- package/src/modes/interactive/components/extensions/inspector-panel.ts +313 -0
- package/src/modes/interactive/components/extensions/state-manager.ts +558 -0
- package/src/modes/interactive/components/extensions/types.ts +191 -0
- package/src/modes/interactive/components/hook-editor.ts +117 -0
- package/src/modes/interactive/components/hook-input.ts +64 -0
- package/src/modes/interactive/components/hook-message.ts +96 -0
- package/src/modes/interactive/components/hook-selector.ts +91 -0
- package/src/modes/interactive/components/model-selector.ts +560 -0
- package/src/modes/interactive/components/oauth-selector.ts +136 -0
- package/src/modes/interactive/components/plugin-settings.ts +481 -0
- package/src/modes/interactive/components/queue-mode-selector.ts +56 -0
- package/src/modes/interactive/components/session-selector.ts +220 -0
- package/src/modes/interactive/components/settings-defs.ts +597 -0
- package/src/modes/interactive/components/settings-selector.ts +545 -0
- package/src/modes/interactive/components/show-images-selector.ts +45 -0
- package/src/modes/interactive/components/status-line/index.ts +4 -0
- package/src/modes/interactive/components/status-line/presets.ts +94 -0
- package/src/modes/interactive/components/status-line/segments.ts +350 -0
- package/src/modes/interactive/components/status-line/separators.ts +55 -0
- package/src/modes/interactive/components/status-line/types.ts +81 -0
- package/src/modes/interactive/components/status-line-segment-editor.ts +357 -0
- package/src/modes/interactive/components/status-line.ts +384 -0
- package/src/modes/interactive/components/theme-selector.ts +62 -0
- package/src/modes/interactive/components/thinking-selector.ts +64 -0
- package/src/modes/interactive/components/tool-execution.ts +946 -0
- package/src/modes/interactive/components/tree-selector.ts +877 -0
- package/src/modes/interactive/components/ttsr-notification.ts +82 -0
- package/src/modes/interactive/components/user-message-selector.ts +159 -0
- package/src/modes/interactive/components/user-message.ts +18 -0
- package/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/src/modes/interactive/components/welcome.ts +228 -0
- package/src/modes/interactive/interactive-mode.ts +2669 -0
- package/src/modes/interactive/theme/dark.json +102 -0
- package/src/modes/interactive/theme/defaults/dark-arctic.json +111 -0
- package/src/modes/interactive/theme/defaults/dark-catppuccin.json +106 -0
- package/src/modes/interactive/theme/defaults/dark-cyberpunk.json +109 -0
- package/src/modes/interactive/theme/defaults/dark-dracula.json +105 -0
- package/src/modes/interactive/theme/defaults/dark-forest.json +103 -0
- package/src/modes/interactive/theme/defaults/dark-github.json +112 -0
- package/src/modes/interactive/theme/defaults/dark-gruvbox.json +119 -0
- package/src/modes/interactive/theme/defaults/dark-monochrome.json +101 -0
- package/src/modes/interactive/theme/defaults/dark-monokai.json +105 -0
- package/src/modes/interactive/theme/defaults/dark-nord.json +104 -0
- package/src/modes/interactive/theme/defaults/dark-ocean.json +108 -0
- package/src/modes/interactive/theme/defaults/dark-one.json +107 -0
- package/src/modes/interactive/theme/defaults/dark-retro.json +99 -0
- package/src/modes/interactive/theme/defaults/dark-rose-pine.json +95 -0
- package/src/modes/interactive/theme/defaults/dark-solarized.json +96 -0
- package/src/modes/interactive/theme/defaults/dark-sunset.json +106 -0
- package/src/modes/interactive/theme/defaults/dark-synthwave.json +102 -0
- package/src/modes/interactive/theme/defaults/dark-tokyo-night.json +108 -0
- package/src/modes/interactive/theme/defaults/index.ts +67 -0
- package/src/modes/interactive/theme/defaults/light-arctic.json +106 -0
- package/src/modes/interactive/theme/defaults/light-catppuccin.json +105 -0
- package/src/modes/interactive/theme/defaults/light-cyberpunk.json +103 -0
- package/src/modes/interactive/theme/defaults/light-forest.json +107 -0
- package/src/modes/interactive/theme/defaults/light-github.json +114 -0
- package/src/modes/interactive/theme/defaults/light-gruvbox.json +115 -0
- package/src/modes/interactive/theme/defaults/light-monochrome.json +100 -0
- package/src/modes/interactive/theme/defaults/light-ocean.json +106 -0
- package/src/modes/interactive/theme/defaults/light-one.json +105 -0
- package/src/modes/interactive/theme/defaults/light-retro.json +105 -0
- package/src/modes/interactive/theme/defaults/light-solarized.json +101 -0
- package/src/modes/interactive/theme/defaults/light-sunset.json +106 -0
- package/src/modes/interactive/theme/defaults/light-synthwave.json +105 -0
- package/src/modes/interactive/theme/defaults/light-tokyo-night.json +118 -0
- package/src/modes/interactive/theme/light.json +99 -0
- package/src/modes/interactive/theme/theme-schema.json +424 -0
- package/src/modes/interactive/theme/theme.ts +2211 -0
- package/src/modes/print-mode.ts +163 -0
- package/src/modes/rpc/rpc-client.ts +527 -0
- package/src/modes/rpc/rpc-mode.ts +494 -0
- package/src/modes/rpc/rpc-types.ts +203 -0
- package/src/prompts/architect-plan.md +10 -0
- package/src/prompts/branch-summary-preamble.md +3 -0
- package/src/prompts/branch-summary.md +28 -0
- package/src/prompts/browser.md +71 -0
- package/src/prompts/compaction-summary.md +34 -0
- package/src/prompts/compaction-turn-prefix.md +16 -0
- package/src/prompts/compaction-update-summary.md +41 -0
- package/src/prompts/explore.md +82 -0
- package/src/prompts/implement-with-critic.md +11 -0
- package/src/prompts/implement.md +11 -0
- package/src/prompts/init.md +30 -0
- package/src/prompts/plan.md +54 -0
- package/src/prompts/reviewer.md +81 -0
- package/src/prompts/summarization-system.md +3 -0
- package/src/prompts/system-prompt.md +27 -0
- package/src/prompts/task.md +56 -0
- package/src/prompts/title-system.md +8 -0
- package/src/prompts/tools/ask.md +24 -0
- package/src/prompts/tools/bash.md +23 -0
- package/src/prompts/tools/edit.md +9 -0
- package/src/prompts/tools/find.md +6 -0
- package/src/prompts/tools/grep.md +12 -0
- package/src/prompts/tools/lsp.md +14 -0
- package/src/prompts/tools/output.md +23 -0
- package/src/prompts/tools/read.md +25 -0
- package/src/prompts/tools/web-fetch.md +8 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +10 -0
- package/src/utils/changelog.ts +99 -0
- package/src/utils/clipboard.ts +265 -0
- package/src/utils/fuzzy.ts +108 -0
- package/src/utils/mime.ts +30 -0
- package/src/utils/shell-snapshot.ts +218 -0
- package/src/utils/shell.ts +364 -0
- package/src/utils/tools-manager.ts +265 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin settings UI components.
|
|
3
|
+
*
|
|
4
|
+
* Provides a hierarchical settings interface:
|
|
5
|
+
* - Plugin list (shows all installed plugins)
|
|
6
|
+
* - Plugin detail (enable/disable, features, config)
|
|
7
|
+
* - Feature toggles
|
|
8
|
+
* - Config value editor
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
Container,
|
|
13
|
+
Input,
|
|
14
|
+
type SelectItem,
|
|
15
|
+
SelectList,
|
|
16
|
+
type SettingItem,
|
|
17
|
+
SettingsList,
|
|
18
|
+
Spacer,
|
|
19
|
+
Text,
|
|
20
|
+
} from "@oh-my-pi/pi-tui";
|
|
21
|
+
import { PluginManager } from "../../../core/plugins/manager";
|
|
22
|
+
import type { InstalledPlugin, PluginSettingSchema } from "../../../core/plugins/types";
|
|
23
|
+
import { getSelectListTheme, getSettingsListTheme, theme } from "../theme/theme";
|
|
24
|
+
import { DynamicBorder } from "./dynamic-border";
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Plugin List Component
|
|
28
|
+
// =============================================================================
|
|
29
|
+
|
|
30
|
+
export interface PluginListCallbacks {
|
|
31
|
+
onPluginSelect: (plugin: InstalledPlugin) => void;
|
|
32
|
+
onCancel: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Shows list of installed plugins with enable/disable status.
|
|
37
|
+
* Selecting a plugin opens its detail view.
|
|
38
|
+
*/
|
|
39
|
+
export class PluginListComponent extends Container {
|
|
40
|
+
private selectList: SelectList;
|
|
41
|
+
private plugins: InstalledPlugin[];
|
|
42
|
+
|
|
43
|
+
constructor(plugins: InstalledPlugin[], callbacks: PluginListCallbacks) {
|
|
44
|
+
super();
|
|
45
|
+
this.plugins = plugins;
|
|
46
|
+
|
|
47
|
+
// Title
|
|
48
|
+
this.addChild(new DynamicBorder());
|
|
49
|
+
this.addChild(new Text(theme.bold(theme.fg("accent", " Plugins")), 0, 0));
|
|
50
|
+
this.addChild(new Spacer(1));
|
|
51
|
+
|
|
52
|
+
if (plugins.length === 0) {
|
|
53
|
+
this.addChild(new Text(theme.fg("muted", " No plugins installed"), 0, 0));
|
|
54
|
+
this.addChild(new Spacer(1));
|
|
55
|
+
this.addChild(new Text(theme.fg("dim", " Install with: omp plugin install <package>"), 0, 0));
|
|
56
|
+
this.addChild(new Spacer(1));
|
|
57
|
+
this.addChild(new DynamicBorder());
|
|
58
|
+
|
|
59
|
+
// Create empty list that just handles escape
|
|
60
|
+
this.selectList = new SelectList([], 1, getSelectListTheme());
|
|
61
|
+
this.selectList.onCancel = callbacks.onCancel;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const items: SelectItem[] = plugins.map((p) => {
|
|
66
|
+
const status = p.enabled
|
|
67
|
+
? theme.fg("success", theme.status.enabled)
|
|
68
|
+
: theme.fg("muted", theme.status.disabled);
|
|
69
|
+
const featureCount = p.manifest.features ? Object.keys(p.manifest.features).length : 0;
|
|
70
|
+
const enabledCount = p.enabledFeatures?.length ?? featureCount;
|
|
71
|
+
|
|
72
|
+
let details = `v${p.version}`;
|
|
73
|
+
if (featureCount > 0) {
|
|
74
|
+
details += ` ${theme.sep.dot} ${enabledCount}/${featureCount} features`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
value: p.name,
|
|
79
|
+
label: `${status} ${p.name}`,
|
|
80
|
+
description: details,
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
this.selectList = new SelectList(items, Math.min(items.length, 8), getSelectListTheme());
|
|
85
|
+
|
|
86
|
+
this.selectList.onSelect = (item) => {
|
|
87
|
+
const plugin = this.plugins.find((p) => p.name === item.value);
|
|
88
|
+
if (plugin) {
|
|
89
|
+
callbacks.onPluginSelect(plugin);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
this.selectList.onCancel = callbacks.onCancel;
|
|
94
|
+
|
|
95
|
+
this.addChild(this.selectList);
|
|
96
|
+
this.addChild(new Spacer(1));
|
|
97
|
+
this.addChild(new Text(theme.fg("dim", " Enter to configure · Esc to go back"), 0, 0));
|
|
98
|
+
this.addChild(new DynamicBorder());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
handleInput(data: string): void {
|
|
102
|
+
this.selectList.handleInput(data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// =============================================================================
|
|
107
|
+
// Plugin Detail Component
|
|
108
|
+
// =============================================================================
|
|
109
|
+
|
|
110
|
+
export interface PluginDetailCallbacks {
|
|
111
|
+
onEnabledChange: (enabled: boolean) => void;
|
|
112
|
+
onFeatureChange: (feature: string, enabled: boolean) => void;
|
|
113
|
+
onConfigChange: (key: string, value: unknown) => void;
|
|
114
|
+
onBack: () => void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Shows detail settings for a single plugin:
|
|
119
|
+
* - Enable/disable toggle
|
|
120
|
+
* - Feature toggles
|
|
121
|
+
* - Config settings
|
|
122
|
+
*/
|
|
123
|
+
export class PluginDetailComponent extends Container {
|
|
124
|
+
private settingsList!: SettingsList;
|
|
125
|
+
private plugin: InstalledPlugin;
|
|
126
|
+
private manager: PluginManager;
|
|
127
|
+
private callbacks: PluginDetailCallbacks;
|
|
128
|
+
|
|
129
|
+
constructor(plugin: InstalledPlugin, manager: PluginManager, callbacks: PluginDetailCallbacks) {
|
|
130
|
+
super();
|
|
131
|
+
this.plugin = plugin;
|
|
132
|
+
this.manager = manager;
|
|
133
|
+
this.callbacks = callbacks;
|
|
134
|
+
|
|
135
|
+
this.rebuild();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private rebuild(): void {
|
|
139
|
+
this.clear();
|
|
140
|
+
|
|
141
|
+
const plugin = this.plugin;
|
|
142
|
+
const manifest = plugin.manifest;
|
|
143
|
+
|
|
144
|
+
// Header
|
|
145
|
+
this.addChild(new DynamicBorder());
|
|
146
|
+
this.addChild(new Text(theme.bold(theme.fg("accent", ` ${plugin.name}`)), 0, 0));
|
|
147
|
+
if (manifest.description) {
|
|
148
|
+
this.addChild(new Text(theme.fg("muted", ` ${manifest.description}`), 0, 0));
|
|
149
|
+
}
|
|
150
|
+
this.addChild(new Spacer(1));
|
|
151
|
+
|
|
152
|
+
const items: SettingItem[] = [];
|
|
153
|
+
|
|
154
|
+
// Enable/disable toggle
|
|
155
|
+
items.push({
|
|
156
|
+
id: "__enabled__",
|
|
157
|
+
label: "Enabled",
|
|
158
|
+
description: "Enable or disable this plugin",
|
|
159
|
+
currentValue: plugin.enabled ? "true" : "false",
|
|
160
|
+
values: ["true", "false"],
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Feature toggles
|
|
164
|
+
if (manifest.features && Object.keys(manifest.features).length > 0) {
|
|
165
|
+
const enabledSet = new Set(plugin.enabledFeatures ?? []);
|
|
166
|
+
const defaultFeatures = Object.entries(manifest.features)
|
|
167
|
+
.filter(([_, f]) => f.default)
|
|
168
|
+
.map(([name]) => name);
|
|
169
|
+
|
|
170
|
+
// If enabledFeatures is null, use defaults
|
|
171
|
+
const effectiveEnabled = plugin.enabledFeatures === null ? new Set(defaultFeatures) : enabledSet;
|
|
172
|
+
|
|
173
|
+
for (const [featName, feat] of Object.entries(manifest.features)) {
|
|
174
|
+
const isEnabled = effectiveEnabled.has(featName);
|
|
175
|
+
items.push({
|
|
176
|
+
id: `feature:${featName}`,
|
|
177
|
+
label: ` ${featName}`,
|
|
178
|
+
description: feat.description || `Enable ${featName} feature`,
|
|
179
|
+
currentValue: isEnabled ? "true" : "false",
|
|
180
|
+
values: ["true", "false"],
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Config settings
|
|
186
|
+
if (manifest.settings && Object.keys(manifest.settings).length > 0) {
|
|
187
|
+
const settings = this.manager.getPluginSettings(plugin.name);
|
|
188
|
+
|
|
189
|
+
for (const [key, schema] of Object.entries(manifest.settings)) {
|
|
190
|
+
const currentValue = settings[key] ?? schema.default;
|
|
191
|
+
const displayValue = schema.secret && currentValue ? "••••••••" : String(currentValue ?? "(not set)");
|
|
192
|
+
|
|
193
|
+
if (schema.type === "boolean") {
|
|
194
|
+
items.push({
|
|
195
|
+
id: `config:${key}`,
|
|
196
|
+
label: ` ${key}`,
|
|
197
|
+
description: schema.description || `Configure ${key}`,
|
|
198
|
+
currentValue: currentValue ? "true" : "false",
|
|
199
|
+
values: ["true", "false"],
|
|
200
|
+
});
|
|
201
|
+
} else if (schema.type === "enum") {
|
|
202
|
+
items.push({
|
|
203
|
+
id: `config:${key}`,
|
|
204
|
+
label: ` ${key}`,
|
|
205
|
+
description: schema.description || `Configure ${key}`,
|
|
206
|
+
currentValue: String(currentValue ?? schema.default ?? ""),
|
|
207
|
+
submenu: (cv, done) =>
|
|
208
|
+
new ConfigEnumSubmenu(
|
|
209
|
+
key,
|
|
210
|
+
schema.description || `Select value for ${key}`,
|
|
211
|
+
schema.values,
|
|
212
|
+
cv,
|
|
213
|
+
(value) => {
|
|
214
|
+
this.callbacks.onConfigChange(key, value);
|
|
215
|
+
done(value);
|
|
216
|
+
},
|
|
217
|
+
() => done(),
|
|
218
|
+
),
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
// string or number - show as submenu with input
|
|
222
|
+
items.push({
|
|
223
|
+
id: `config:${key}`,
|
|
224
|
+
label: ` ${key}`,
|
|
225
|
+
description: schema.description || `Configure ${key}`,
|
|
226
|
+
currentValue: displayValue,
|
|
227
|
+
submenu: (cv, done) =>
|
|
228
|
+
new ConfigInputSubmenu(
|
|
229
|
+
key,
|
|
230
|
+
schema,
|
|
231
|
+
cv === "(not set)" ? "" : cv,
|
|
232
|
+
(value) => {
|
|
233
|
+
const parsed = schema.type === "number" ? Number(value) : value;
|
|
234
|
+
this.callbacks.onConfigChange(key, parsed);
|
|
235
|
+
done(String(value));
|
|
236
|
+
},
|
|
237
|
+
() => done(),
|
|
238
|
+
),
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
this.settingsList = new SettingsList(
|
|
245
|
+
items,
|
|
246
|
+
Math.min(items.length, 10),
|
|
247
|
+
getSettingsListTheme(),
|
|
248
|
+
(id, newValue) => {
|
|
249
|
+
if (id === "__enabled__") {
|
|
250
|
+
this.callbacks.onEnabledChange(newValue === "true");
|
|
251
|
+
this.plugin = { ...this.plugin, enabled: newValue === "true" };
|
|
252
|
+
} else if (id.startsWith("feature:")) {
|
|
253
|
+
const featName = id.slice(8);
|
|
254
|
+
this.callbacks.onFeatureChange(featName, newValue === "true");
|
|
255
|
+
// Update local state
|
|
256
|
+
const current = new Set(this.plugin.enabledFeatures ?? []);
|
|
257
|
+
if (newValue === "true") {
|
|
258
|
+
current.add(featName);
|
|
259
|
+
} else {
|
|
260
|
+
current.delete(featName);
|
|
261
|
+
}
|
|
262
|
+
this.plugin = { ...this.plugin, enabledFeatures: [...current] };
|
|
263
|
+
} else if (id.startsWith("config:")) {
|
|
264
|
+
const key = id.slice(7);
|
|
265
|
+
const schema = this.plugin.manifest.settings?.[key];
|
|
266
|
+
if (schema?.type === "boolean") {
|
|
267
|
+
this.callbacks.onConfigChange(key, newValue === "true");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
this.callbacks.onBack,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
this.addChild(this.settingsList);
|
|
275
|
+
this.addChild(new Spacer(1));
|
|
276
|
+
this.addChild(new Text(theme.fg("dim", " Enter to edit · Esc to go back"), 0, 0));
|
|
277
|
+
this.addChild(new DynamicBorder());
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
handleInput(data: string): void {
|
|
281
|
+
this.settingsList.handleInput(data);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// =============================================================================
|
|
286
|
+
// Config Submenus
|
|
287
|
+
// =============================================================================
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Submenu for enum config values.
|
|
291
|
+
*/
|
|
292
|
+
class ConfigEnumSubmenu extends Container {
|
|
293
|
+
private selectList: SelectList;
|
|
294
|
+
|
|
295
|
+
constructor(
|
|
296
|
+
key: string,
|
|
297
|
+
description: string,
|
|
298
|
+
values: string[],
|
|
299
|
+
currentValue: string,
|
|
300
|
+
onSelect: (value: string) => void,
|
|
301
|
+
onCancel: () => void,
|
|
302
|
+
) {
|
|
303
|
+
super();
|
|
304
|
+
|
|
305
|
+
this.addChild(new Text(theme.bold(theme.fg("accent", key)), 0, 0));
|
|
306
|
+
if (description) {
|
|
307
|
+
this.addChild(new Spacer(1));
|
|
308
|
+
this.addChild(new Text(theme.fg("muted", description), 0, 0));
|
|
309
|
+
}
|
|
310
|
+
this.addChild(new Spacer(1));
|
|
311
|
+
|
|
312
|
+
const items: SelectItem[] = values.map((v) => ({ value: v, label: v }));
|
|
313
|
+
this.selectList = new SelectList(items, Math.min(items.length, 8), getSelectListTheme());
|
|
314
|
+
|
|
315
|
+
const currentIndex = values.indexOf(currentValue);
|
|
316
|
+
if (currentIndex !== -1) {
|
|
317
|
+
this.selectList.setSelectedIndex(currentIndex);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
this.selectList.onSelect = (item) => onSelect(item.value);
|
|
321
|
+
this.selectList.onCancel = onCancel;
|
|
322
|
+
|
|
323
|
+
this.addChild(this.selectList);
|
|
324
|
+
this.addChild(new Spacer(1));
|
|
325
|
+
this.addChild(new Text(theme.fg("dim", " Enter to select · Esc to cancel"), 0, 0));
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
handleInput(data: string): void {
|
|
329
|
+
this.selectList.handleInput(data);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Submenu for string/number config values with text input.
|
|
335
|
+
*/
|
|
336
|
+
class ConfigInputSubmenu extends Container {
|
|
337
|
+
private input: Input;
|
|
338
|
+
private onSubmit: (value: string) => void;
|
|
339
|
+
private onCancel: () => void;
|
|
340
|
+
|
|
341
|
+
constructor(
|
|
342
|
+
key: string,
|
|
343
|
+
schema: PluginSettingSchema,
|
|
344
|
+
currentValue: string,
|
|
345
|
+
onSubmit: (value: string) => void,
|
|
346
|
+
onCancel: () => void,
|
|
347
|
+
) {
|
|
348
|
+
super();
|
|
349
|
+
this.onSubmit = onSubmit;
|
|
350
|
+
this.onCancel = onCancel;
|
|
351
|
+
|
|
352
|
+
this.addChild(new Text(theme.bold(theme.fg("accent", key)), 0, 0));
|
|
353
|
+
if (schema.description) {
|
|
354
|
+
this.addChild(new Spacer(1));
|
|
355
|
+
this.addChild(new Text(theme.fg("muted", schema.description), 0, 0));
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Type hint
|
|
359
|
+
let hint = `Type: ${schema.type}`;
|
|
360
|
+
if (schema.type === "number") {
|
|
361
|
+
const numSchema = schema as { min?: number; max?: number };
|
|
362
|
+
if (numSchema.min !== undefined || numSchema.max !== undefined) {
|
|
363
|
+
hint += ` (${numSchema.min ?? ""}..${numSchema.max ?? ""})`;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
this.addChild(new Spacer(1));
|
|
367
|
+
this.addChild(new Text(theme.fg("dim", hint), 0, 0));
|
|
368
|
+
|
|
369
|
+
this.addChild(new Spacer(1));
|
|
370
|
+
|
|
371
|
+
// Input field
|
|
372
|
+
this.input = new Input();
|
|
373
|
+
if (!schema.secret && currentValue) {
|
|
374
|
+
this.input.setValue(currentValue);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
this.input.onSubmit = (value) => {
|
|
378
|
+
if (value.trim()) {
|
|
379
|
+
this.onSubmit(value);
|
|
380
|
+
} else {
|
|
381
|
+
this.onCancel();
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
this.addChild(this.input);
|
|
386
|
+
this.addChild(new Spacer(1));
|
|
387
|
+
this.addChild(new Text(theme.fg("dim", " Enter to save · Esc to cancel"), 0, 0));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
handleInput(data: string): void {
|
|
391
|
+
if (data === "\x1b" || data === "\x1b\x1b") {
|
|
392
|
+
this.onCancel();
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
this.input.handleInput(data);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// =============================================================================
|
|
400
|
+
// Main Plugin Settings Selector
|
|
401
|
+
// =============================================================================
|
|
402
|
+
|
|
403
|
+
export interface PluginSettingsCallbacks {
|
|
404
|
+
onClose: () => void;
|
|
405
|
+
onPluginChanged: () => void;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Component with handleInput method */
|
|
409
|
+
interface InputHandler {
|
|
410
|
+
handleInput(data: string): void;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Top-level plugin settings component.
|
|
415
|
+
* Manages navigation between plugin list and plugin detail views.
|
|
416
|
+
*/
|
|
417
|
+
export class PluginSettingsComponent extends Container {
|
|
418
|
+
private manager: PluginManager;
|
|
419
|
+
private callbacks: PluginSettingsCallbacks;
|
|
420
|
+
private viewComponent: (Container & InputHandler) | null = null;
|
|
421
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: state tracking for view management
|
|
422
|
+
private currentView: "list" | "detail" = "list";
|
|
423
|
+
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: state tracking for view management
|
|
424
|
+
private currentPlugin: InstalledPlugin | null = null;
|
|
425
|
+
|
|
426
|
+
constructor(cwd: string, callbacks: PluginSettingsCallbacks) {
|
|
427
|
+
super();
|
|
428
|
+
this.manager = new PluginManager(cwd);
|
|
429
|
+
this.callbacks = callbacks;
|
|
430
|
+
this.showPluginList();
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
private async showPluginList(): Promise<void> {
|
|
434
|
+
this.currentView = "list";
|
|
435
|
+
this.currentPlugin = null;
|
|
436
|
+
this.clear();
|
|
437
|
+
|
|
438
|
+
const plugins = await this.manager.list();
|
|
439
|
+
|
|
440
|
+
this.viewComponent = new PluginListComponent(plugins, {
|
|
441
|
+
onPluginSelect: (plugin) => this.showPluginDetail(plugin),
|
|
442
|
+
onCancel: () => this.callbacks.onClose(),
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
this.addChild(this.viewComponent);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
private showPluginDetail(plugin: InstalledPlugin): void {
|
|
449
|
+
this.currentView = "detail";
|
|
450
|
+
this.currentPlugin = plugin;
|
|
451
|
+
this.clear();
|
|
452
|
+
|
|
453
|
+
this.viewComponent = new PluginDetailComponent(plugin, this.manager, {
|
|
454
|
+
onEnabledChange: async (enabled) => {
|
|
455
|
+
await this.manager.setEnabled(plugin.name, enabled);
|
|
456
|
+
this.callbacks.onPluginChanged();
|
|
457
|
+
},
|
|
458
|
+
onFeatureChange: async (feature, enabled) => {
|
|
459
|
+
const current = new Set(this.manager.getEnabledFeatures(plugin.name) ?? []);
|
|
460
|
+
if (enabled) {
|
|
461
|
+
current.add(feature);
|
|
462
|
+
} else {
|
|
463
|
+
current.delete(feature);
|
|
464
|
+
}
|
|
465
|
+
await this.manager.setEnabledFeatures(plugin.name, [...current]);
|
|
466
|
+
this.callbacks.onPluginChanged();
|
|
467
|
+
},
|
|
468
|
+
onConfigChange: (key, value) => {
|
|
469
|
+
this.manager.setPluginSetting(plugin.name, key, value);
|
|
470
|
+
this.callbacks.onPluginChanged();
|
|
471
|
+
},
|
|
472
|
+
onBack: () => this.showPluginList(),
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
this.addChild(this.viewComponent);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
handleInput(data: string): void {
|
|
479
|
+
this.viewComponent?.handleInput(data);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Container, type SelectItem, SelectList } from "@oh-my-pi/pi-tui";
|
|
2
|
+
import { getSelectListTheme } from "../theme/theme";
|
|
3
|
+
import { DynamicBorder } from "./dynamic-border";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Component that renders a queue mode selector with borders
|
|
7
|
+
*/
|
|
8
|
+
export class QueueModeSelectorComponent extends Container {
|
|
9
|
+
private selectList: SelectList;
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
currentMode: "all" | "one-at-a-time",
|
|
13
|
+
onSelect: (mode: "all" | "one-at-a-time") => void,
|
|
14
|
+
onCancel: () => void,
|
|
15
|
+
) {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
const queueModes: SelectItem[] = [
|
|
19
|
+
{
|
|
20
|
+
value: "one-at-a-time",
|
|
21
|
+
label: "one-at-a-time",
|
|
22
|
+
description: "Process queued messages one by one (recommended)",
|
|
23
|
+
},
|
|
24
|
+
{ value: "all", label: "all", description: "Process all queued messages at once" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
// Add top border
|
|
28
|
+
this.addChild(new DynamicBorder());
|
|
29
|
+
|
|
30
|
+
// Create selector
|
|
31
|
+
this.selectList = new SelectList(queueModes, 2, getSelectListTheme());
|
|
32
|
+
|
|
33
|
+
// Preselect current mode
|
|
34
|
+
const currentIndex = queueModes.findIndex((item) => item.value === currentMode);
|
|
35
|
+
if (currentIndex !== -1) {
|
|
36
|
+
this.selectList.setSelectedIndex(currentIndex);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.selectList.onSelect = (item) => {
|
|
40
|
+
onSelect(item.value as "all" | "one-at-a-time");
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
this.selectList.onCancel = () => {
|
|
44
|
+
onCancel();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.addChild(this.selectList);
|
|
48
|
+
|
|
49
|
+
// Add bottom border
|
|
50
|
+
this.addChild(new DynamicBorder());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getSelectList(): SelectList {
|
|
54
|
+
return this.selectList;
|
|
55
|
+
}
|
|
56
|
+
}
|