statusbar-quick-actions 0.0.10

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.
@@ -0,0 +1,3 @@
1
+ github: involvex
2
+ buy_me_a_coffee: involvex
3
+ custom: ["https://paypal.me/involvex"]
package/.vscodeignore ADDED
@@ -0,0 +1,11 @@
1
+ .vscode/**
2
+ typings/**
3
+ out/test/**
4
+ test/**
5
+ src/**
6
+ **/*.map
7
+ .gitignore
8
+ tsconfig.json
9
+ vsc-extension-quickstart.md
10
+ .claude
11
+ .mira
package/CLAUDE.md ADDED
@@ -0,0 +1,230 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **StatusBar Quick Actions** is a VSCode extension that provides highly customizable status bar buttons for executing user-defined scripts and commands. It supports multiple package managers (npm, yarn, pnpm, bun), VSCode tasks, shell commands, and GitHub CLI integration with advanced features like theme support, execution tracking, and intelligent visibility conditions.
8
+
9
+ ## Development Commands
10
+
11
+ ### Essential Commands
12
+
13
+ - `bun install` - Install all dependencies
14
+ - `bun run compile` - Compile TypeScript to JavaScript (outputs to `out/`)
15
+ - `bun run watch` - Compile TypeScript in watch mode
16
+ - `bun run lint` - Check code for linting errors
17
+ - `bun run lint:fix` - Auto-fix linting errors
18
+ - `bun run format` - Format code with Prettier
19
+ - `bun run format:check` - Check code formatting without modifying
20
+
21
+ ### Build & Package
22
+
23
+ - `bun run clean` - Remove `out/` directory
24
+ - `bun run rebuild` - Clean and compile from scratch
25
+ - `bun run dev` - Clean and start watch mode
26
+ - `bun run package` - Create .vsix extension package
27
+ - `bun run package:install` - Package and install the extension in VSCode
28
+
29
+ ### Important Notes
30
+
31
+ - This project uses **Bun** as the package manager and runtime (not npm/yarn)
32
+ - All scripts in package.json are prefixed with `bun run`
33
+ - The extension requires VSCode engine version ^1.100.0
34
+ - TypeScript target is ES2024 with strict mode enabled
35
+
36
+ ## Architecture Overview
37
+
38
+ ### Core Class Structure
39
+
40
+ The extension follows a modular architecture with clear separation of concerns:
41
+
42
+ **Main Extension Class** (`extension.ts`):
43
+
44
+ - Entry point and orchestrator for the entire extension
45
+ - Manages lifecycle (activate/deactivate)
46
+ - Owns instances of all manager classes
47
+ - Maintains `buttonStates` Map that tracks all status bar buttons
48
+ - Handles VSCode command registration and configuration watching
49
+
50
+ **Manager Classes** (each handles a specific domain):
51
+
52
+ - `ConfigManager` (`configuration.ts`) - Configuration loading, validation, and watching
53
+ - `CommandExecutor` (`executor.ts`) - Command execution with child_process
54
+ - `ThemeManager` (`theme.ts`) - Theme detection and color application
55
+ - `VisibilityManager` (`visibility.ts`) - Conditional button visibility evaluation
56
+
57
+ ### Key Architectural Patterns
58
+
59
+ **1. ButtonState Lifecycle**
60
+ Each button goes through this lifecycle:
61
+
62
+ - Configuration loaded from VSCode settings → `StatusBarButtonConfig`
63
+ - Status bar item created → `vscode.StatusBarItem`
64
+ - Button state object created → `ButtonState` (stored in Map with button ID as key)
65
+ - Button registered with click handler
66
+ - On configuration change: existing buttons disposed, new ones created
67
+
68
+ **2. Command Execution Flow**
69
+
70
+ ```
71
+ User clicks button → extension.ts executes button
72
+ → CommandExecutor.execute() called with ButtonCommand + ExecutionOptions
73
+ → Command type determines execution strategy (npm/yarn/pnpm/bun/shell/vscode/task/github/detect)
74
+ → child_process.exec() runs command (except vscode/task types which use VSCode APIs)
75
+ → ExecutionResult returned with stdout/stderr/exitCode/duration
76
+ → Result saved to history via global state persistence
77
+ → Notifications shown based on execution config
78
+ ```
79
+
80
+ **3. Visibility Evaluation**
81
+ Buttons can be conditionally shown/hidden based on context:
82
+
83
+ - `VisibilityManager.getCurrentContext()` gathers current editor state
84
+ - `VisibilityManager.isVisible()` evaluates all conditions (AND logic)
85
+ - Supports: fileType (glob patterns via minimatch), fileExists, gitStatus (via git extension API), workspaceFolder
86
+ - Each condition supports `invert` flag for negation logic
87
+
88
+ **4. History Persistence**
89
+
90
+ - History stored in VSCode global state (survives restarts)
91
+ - Key format: `history_{buttonId}`
92
+ - Each button maintains its own history array
93
+ - Max entries configurable per button (default 20)
94
+ - History loaded on extension activation and updated after each execution
95
+
96
+ **5. Theme Integration**
97
+
98
+ - Theme auto-detected from VSCode color theme
99
+ - Supports dark/light/high-contrast modes
100
+ - Colors can be overridden per-button via `colors` config
101
+ - Theme manager watches for theme changes and updates buttons dynamically
102
+
103
+ ### Type System
104
+
105
+ All types defined in `types.ts` with strict TypeScript checking enabled:
106
+
107
+ **Core Interfaces**:
108
+
109
+ - `StatusBarButtonConfig` - Full button configuration from settings
110
+ - `ButtonState` - Runtime state including VSCode StatusBarItem reference
111
+ - `ButtonCommand` - Command configuration with discriminated union for type
112
+ - `ExecutionResult` - Command execution output and metadata
113
+ - `VisibilityContext` - Current editor/workspace context for visibility checks
114
+ - `ThemeConfig` - Theme configuration with mode-specific color schemes
115
+
116
+ **Important Type Details**:
117
+
118
+ - `ButtonCommand.type` is a discriminated union with 9 possible values
119
+ - `ButtonState.history` is `ExecutionResult[]` (not `CommandHistoryEntry[]`)
120
+ - All manager classes use interfaces from types.ts (no inline types)
121
+
122
+ ### Configuration System
123
+
124
+ **Settings Structure**:
125
+
126
+ ```json
127
+ {
128
+ "statusbarQuickActions.buttons": [ /* array of StatusBarButtonConfig */ ],
129
+ "statusbarQuickActions.settings.theme": { /* ThemeConfig */ },
130
+ "statusbarQuickActions.settings.debug": boolean
131
+ }
132
+ ```
133
+
134
+ **Configuration Watching**:
135
+
136
+ - Uses `vscode.workspace.onDidChangeConfiguration`
137
+ - On change: disposes all buttons and recreates from new config
138
+ - ConfigManager validates configuration before applying
139
+ - Invalid configs show error notification and fall back to previous state
140
+
141
+ ### Package Manager Detection
142
+
143
+ The `detect` command type auto-detects package managers:
144
+
145
+ 1. Checks for lock files in priority order: bun.lockb → pnpm-lock.yaml → yarn.lock → package-lock.json
146
+ 2. Verifies detected package manager is actually installed on system
147
+ 3. Constructs appropriate command (note: yarn doesn't use `run` subcommand)
148
+ 4. Fallback: if package.json exists, uses first available package manager
149
+
150
+ ### Interactive Settings Menu
151
+
152
+ The extension provides a comprehensive QuickPick UI for button management:
153
+
154
+ - Add New Button - Wizard-based button creation
155
+ - Edit Existing Button - Modify button properties
156
+ - Delete Button - Remove buttons
157
+ - Duplicate Button - Clone existing buttons
158
+ - Toggle Button - Enable/disable without deleting
159
+ - Export/Import Configuration - JSON-based config backup/restore
160
+
161
+ Access via command palette: "StatusBar Quick Actions: Edit Button"
162
+
163
+ ## File Organization
164
+
165
+ ```
166
+ src/
167
+ ├── extension.ts - Main extension class & activation
168
+ ├── types.ts - All TypeScript interfaces
169
+ ├── configuration.ts - Config loading & validation
170
+ ├── executor.ts - Command execution logic
171
+ ├── theme.ts - Theme detection & application
172
+ ├── visibility.ts - Visibility condition evaluation
173
+ ├── history.ts - History management utilities
174
+ └── notifications.ts - Notification display logic
175
+ ```
176
+
177
+ ## Common Pitfalls & Solutions
178
+
179
+ **Child Process Execution**:
180
+
181
+ - Always use `promisify(exec)` from `child_process`, not VSCode terminal API
182
+ - Terminal API doesn't capture stdout/stderr properly
183
+ - Set `windowsHide: true` option to hide console windows on Windows
184
+ - Handle both success and error cases (exec throws on non-zero exit codes)
185
+
186
+ **VSCode Git Extension Integration**:
187
+
188
+ - Git extension must be checked with `vscode.extensions.getExtension('vscode.git')`
189
+ - API accessed via `gitExtension.exports.getAPI(1)`
190
+ - Repository state accessed via `git.repositories[0].state`
191
+ - Always check if repository exists before accessing state
192
+
193
+ **History Persistence**:
194
+
195
+ - Use `context.globalState` not `context.workspaceState` (workspace state is per-workspace)
196
+ - Always load history on activation for each button
197
+ - Update both global state AND ButtonState.history on execution
198
+ - Trim history to maxEntries after adding new entries
199
+
200
+ **Configuration Types**:
201
+
202
+ - VSCode config returns `any` by default, always use `.get<Type>()` with explicit type
203
+ - Validate all config before using (check required fields)
204
+ - Handle missing optional fields with defaults
205
+
206
+ **Minimatch for Glob Patterns**:
207
+
208
+ - Use `{ matchBase: true }` option for filename-only matching
209
+ - Pattern `*.ts` should match `file.ts` regardless of path
210
+ - Check for `*` or `?` to detect glob patterns vs plain extensions
211
+
212
+ ## Extension Development Workflow
213
+
214
+ 1. Make code changes
215
+ 2. Run `bun run compile` (or use watch mode with `bun run watch`)
216
+ 3. Press F5 in VSCode to launch Extension Development Host
217
+ 4. Test changes in the development window
218
+ 5. Run `bun run lint:fix` before committing
219
+ 6. Run `bun run format` to ensure consistent code style
220
+
221
+ ## Testing the Extension
222
+
223
+ While there are no automated tests currently (`test` script exits 0), manual testing workflow:
224
+
225
+ 1. Create test button configurations in `.vscode/settings.json`
226
+ 2. Test different command types (npm, bun, shell, vscode, task)
227
+ 3. Verify visibility conditions work with different file types
228
+ 4. Check history persistence by reloading VSCode
229
+ 5. Test theme switching (View → Appearance → Color Theme)
230
+ 6. Verify execution with success/error cases
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Involvex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.