workflow-agent-vscode 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/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/extension.js +486 -0
- package/dist/extension.js.map +1 -0
- package/package.json +129 -0
- package/src/commands.ts +204 -0
- package/src/config.ts +88 -0
- package/src/extension.ts +54 -0
- package/src/statusBar.ts +71 -0
- package/src/validation.ts +116 -0
- package/tsconfig.json +11 -0
- package/tsup.config.ts +12 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Workflow Agent Team
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Workflow Agent - VS Code Extension
|
|
2
|
+
|
|
3
|
+
Real-time workflow validation and enforcement for VS Code.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### 🔍 Real-Time Validation
|
|
8
|
+
|
|
9
|
+
- **Commit Message Validation**: Validates conventional commit format as you type
|
|
10
|
+
- **Branch Name Validation**: Checks branch naming patterns against your workflow config
|
|
11
|
+
- **Scope Validation**: Ensures scopes match your project's defined scopes
|
|
12
|
+
|
|
13
|
+
### 📊 Status Bar Integration
|
|
14
|
+
|
|
15
|
+
- Shows current branch name and enforcement mode
|
|
16
|
+
- Visual indicators for validation state (green = valid, yellow = warning, red = error)
|
|
17
|
+
- Click to view full configuration
|
|
18
|
+
|
|
19
|
+
### ⌨️ Command Palette
|
|
20
|
+
|
|
21
|
+
Access all Workflow Agent features from the command palette:
|
|
22
|
+
|
|
23
|
+
- `Workflow: Initialize` - Set up workflow configuration
|
|
24
|
+
- `Workflow: Validate Branch` - Validate current branch name (Ctrl+Shift+W / Cmd+Shift+W)
|
|
25
|
+
- `Workflow: Suggest Improvement` - Submit a suggestion to the improvement tracker
|
|
26
|
+
- `Workflow: Run Doctor` - Check for configuration issues
|
|
27
|
+
- `Workflow: Show Configuration` - View current workflow configuration
|
|
28
|
+
|
|
29
|
+
### 💡 IntelliSense
|
|
30
|
+
|
|
31
|
+
- Autocomplete for commit scopes
|
|
32
|
+
- Hover tooltips for validation errors
|
|
33
|
+
- Quick fixes for common issues
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
### From VSIX
|
|
38
|
+
|
|
39
|
+
1. Download the latest `.vsix` file from releases
|
|
40
|
+
2. Open VS Code
|
|
41
|
+
3. Go to Extensions view (Ctrl+Shift+X)
|
|
42
|
+
4. Click the `...` menu → "Install from VSIX..."
|
|
43
|
+
5. Select the downloaded file
|
|
44
|
+
|
|
45
|
+
### From Marketplace
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
code --install-extension workflow-agent
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
### Extension Settings
|
|
54
|
+
|
|
55
|
+
Configure the extension through VS Code settings:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"workflowAgent.enabled": true,
|
|
60
|
+
"workflowAgent.validateOnType": true,
|
|
61
|
+
"workflowAgent.showStatusBar": true,
|
|
62
|
+
"workflowAgent.autoSuggest": false,
|
|
63
|
+
"workflowAgent.strictMode": false
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Workspace Configuration
|
|
68
|
+
|
|
69
|
+
Initialize workflow configuration in your workspace:
|
|
70
|
+
|
|
71
|
+
1. Open command palette (Ctrl+Shift+P / Cmd+Shift+P)
|
|
72
|
+
2. Run `Workflow: Initialize`
|
|
73
|
+
3. Select a preset or create custom configuration
|
|
74
|
+
|
|
75
|
+
Or use the CLI:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
workflow init --preset library --name my-project
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Usage
|
|
82
|
+
|
|
83
|
+
### Validating Commits
|
|
84
|
+
|
|
85
|
+
The extension automatically validates commit messages as you type in:
|
|
86
|
+
|
|
87
|
+
- Git commit input boxes
|
|
88
|
+
- `.git/COMMIT_EDITMSG` files
|
|
89
|
+
- SCM view commit message field
|
|
90
|
+
|
|
91
|
+
Invalid messages will show:
|
|
92
|
+
|
|
93
|
+
- Red squiggly underlines in the editor
|
|
94
|
+
- Diagnostic messages in the Problems panel
|
|
95
|
+
- Error icons in the status bar
|
|
96
|
+
|
|
97
|
+
### Validating Branches
|
|
98
|
+
|
|
99
|
+
Press `Ctrl+Shift+W` (or `Cmd+Shift+W` on Mac) to validate the current branch name.
|
|
100
|
+
|
|
101
|
+
Valid branch format:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
<type>/<scope>/<description>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Examples:
|
|
108
|
+
|
|
109
|
+
- ✅ `feature/auth/add-oauth`
|
|
110
|
+
- ✅ `bugfix/api/fix-rate-limit`
|
|
111
|
+
- ✅ `docs/readme/update-installation`
|
|
112
|
+
- ❌ `fix-bug`
|
|
113
|
+
- ❌ `feature_new_thing`
|
|
114
|
+
|
|
115
|
+
### Suggesting Improvements
|
|
116
|
+
|
|
117
|
+
1. Open command palette
|
|
118
|
+
2. Run `Workflow: Suggest Improvement`
|
|
119
|
+
3. Enter your suggestion
|
|
120
|
+
4. Select a category (feature, bug, documentation, etc.)
|
|
121
|
+
5. Suggestion is submitted to the improvement tracker
|
|
122
|
+
|
|
123
|
+
## Troubleshooting
|
|
124
|
+
|
|
125
|
+
### Extension Not Working
|
|
126
|
+
|
|
127
|
+
1. Check if workflow is initialized: Look for `workflow.config.json` in workspace root
|
|
128
|
+
2. Run `Workflow: Run Doctor` to diagnose issues
|
|
129
|
+
3. Check Output panel → "Workflow Agent" for errors
|
|
130
|
+
|
|
131
|
+
### Validation Not Triggering
|
|
132
|
+
|
|
133
|
+
1. Ensure `workflowAgent.enabled` is `true`
|
|
134
|
+
2. Check if you're in a git repository
|
|
135
|
+
3. Verify `workflow.config.json` exists and is valid
|
|
136
|
+
|
|
137
|
+
### Status Bar Not Showing
|
|
138
|
+
|
|
139
|
+
1. Ensure `workflowAgent.showStatusBar` is `true`
|
|
140
|
+
2. Check if you're in a git repository
|
|
141
|
+
3. Try reloading the window (Ctrl+R)
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
### Building
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
pnpm install
|
|
149
|
+
pnpm build
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Testing
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Launch extension development host
|
|
156
|
+
pnpm dev
|
|
157
|
+
|
|
158
|
+
# Run in VS Code
|
|
159
|
+
# Press F5 to open Extension Development Host
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Packaging
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pnpm package
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Creates a `.vsix` file in the root directory.
|
|
169
|
+
|
|
170
|
+
## License
|
|
171
|
+
|
|
172
|
+
MIT - see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/extension.ts
|
|
31
|
+
var extension_exports = {};
|
|
32
|
+
__export(extension_exports, {
|
|
33
|
+
activate: () => activate,
|
|
34
|
+
deactivate: () => deactivate
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(extension_exports);
|
|
37
|
+
var vscode5 = __toESM(require("vscode"));
|
|
38
|
+
|
|
39
|
+
// src/statusBar.ts
|
|
40
|
+
var vscode = __toESM(require("vscode"));
|
|
41
|
+
var StatusBarManager = class {
|
|
42
|
+
statusBarItem;
|
|
43
|
+
constructor() {
|
|
44
|
+
this.statusBarItem = vscode.window.createStatusBarItem(
|
|
45
|
+
vscode.StatusBarAlignment.Left,
|
|
46
|
+
100
|
|
47
|
+
);
|
|
48
|
+
this.statusBarItem.command = "workflow-agent.showConfig";
|
|
49
|
+
}
|
|
50
|
+
show() {
|
|
51
|
+
this.statusBarItem.show();
|
|
52
|
+
this.update();
|
|
53
|
+
}
|
|
54
|
+
hide() {
|
|
55
|
+
this.statusBarItem.hide();
|
|
56
|
+
}
|
|
57
|
+
update(config) {
|
|
58
|
+
if (!config) {
|
|
59
|
+
this.statusBarItem.text = "$(workflow) Workflow";
|
|
60
|
+
this.statusBarItem.tooltip = "Workflow Agent - Not configured";
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const branch = config.getCurrentBranch();
|
|
64
|
+
const hasConfig = config.hasConfig();
|
|
65
|
+
if (!hasConfig) {
|
|
66
|
+
this.statusBarItem.text = "$(workflow) Workflow: Not initialized";
|
|
67
|
+
this.statusBarItem.tooltip = "Click to initialize Workflow Agent";
|
|
68
|
+
this.statusBarItem.command = "workflow-agent.init";
|
|
69
|
+
this.statusBarItem.backgroundColor = new vscode.ThemeColor(
|
|
70
|
+
"statusBarItem.warningBackground"
|
|
71
|
+
);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const enforcement = config.getEnforcement();
|
|
75
|
+
const icon = enforcement === "strict" ? "$(shield)" : "$(check)";
|
|
76
|
+
this.statusBarItem.text = `${icon} Workflow: ${branch || "Unknown"}`;
|
|
77
|
+
this.statusBarItem.tooltip = `Workflow Agent
|
|
78
|
+
Branch: ${branch}
|
|
79
|
+
Enforcement: ${enforcement}
|
|
80
|
+
Click for details`;
|
|
81
|
+
this.statusBarItem.backgroundColor = void 0;
|
|
82
|
+
}
|
|
83
|
+
updateStatus(valid, message) {
|
|
84
|
+
if (valid) {
|
|
85
|
+
this.statusBarItem.backgroundColor = void 0;
|
|
86
|
+
if (message) {
|
|
87
|
+
this.statusBarItem.tooltip = message;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
this.statusBarItem.backgroundColor = new vscode.ThemeColor(
|
|
91
|
+
"statusBarItem.errorBackground"
|
|
92
|
+
);
|
|
93
|
+
if (message) {
|
|
94
|
+
this.statusBarItem.tooltip = `\u26A0 ${message}`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
dispose() {
|
|
99
|
+
this.statusBarItem.dispose();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// src/validation.ts
|
|
104
|
+
var vscode2 = __toESM(require("vscode"));
|
|
105
|
+
var ValidationProvider = class {
|
|
106
|
+
constructor(configManager) {
|
|
107
|
+
this.configManager = configManager;
|
|
108
|
+
this.diagnosticCollection = vscode2.languages.createDiagnosticCollection("workflow-agent");
|
|
109
|
+
}
|
|
110
|
+
diagnosticCollection;
|
|
111
|
+
activate(context) {
|
|
112
|
+
context.subscriptions.push(this.diagnosticCollection);
|
|
113
|
+
vscode2.workspace.onDidOpenTextDocument((doc) => {
|
|
114
|
+
if (doc.fileName.includes(".git/COMMIT_EDITMSG")) {
|
|
115
|
+
this.validateCommitMessage(doc);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
vscode2.workspace.onDidChangeTextDocument((e) => {
|
|
119
|
+
if (this.configManager.shouldValidateOnType() && e.document.fileName.includes(".git/COMMIT_EDITMSG")) {
|
|
120
|
+
this.validateCommitMessage(e.document);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
validateCommitMessage(document) {
|
|
125
|
+
const text = document.getText();
|
|
126
|
+
const firstLine = text.split("\n")[0];
|
|
127
|
+
if (!firstLine || firstLine.startsWith("#")) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const diagnostics = [];
|
|
131
|
+
const commitPattern = /^(feat|fix|refactor|chore|docs|test|perf|style|ci|build|revert)\(([a-z0-9-]+)\): .{10,}/;
|
|
132
|
+
if (!commitPattern.test(firstLine)) {
|
|
133
|
+
const diagnostic = new vscode2.Diagnostic(
|
|
134
|
+
new vscode2.Range(0, 0, 0, firstLine.length),
|
|
135
|
+
"Commit message must follow format: type(scope): description",
|
|
136
|
+
vscode2.DiagnosticSeverity.Error
|
|
137
|
+
);
|
|
138
|
+
diagnostic.code = "workflow-commit-format";
|
|
139
|
+
diagnostic.source = "workflow-agent";
|
|
140
|
+
diagnostics.push(diagnostic);
|
|
141
|
+
} else {
|
|
142
|
+
const match = firstLine.match(/\(([a-z0-9-]+)\)/);
|
|
143
|
+
if (match) {
|
|
144
|
+
const scope = match[1];
|
|
145
|
+
const validScopes = this.configManager.getScopes();
|
|
146
|
+
if (validScopes.length > 0 && !validScopes.includes(scope)) {
|
|
147
|
+
const diagnostic = new vscode2.Diagnostic(
|
|
148
|
+
new vscode2.Range(
|
|
149
|
+
0,
|
|
150
|
+
firstLine.indexOf(scope),
|
|
151
|
+
0,
|
|
152
|
+
firstLine.indexOf(scope) + scope.length
|
|
153
|
+
),
|
|
154
|
+
`Invalid scope '${scope}'. Valid scopes: ${validScopes.join(", ")}`,
|
|
155
|
+
vscode2.DiagnosticSeverity.Warning
|
|
156
|
+
);
|
|
157
|
+
diagnostic.code = "workflow-invalid-scope";
|
|
158
|
+
diagnostic.source = "workflow-agent";
|
|
159
|
+
diagnostics.push(diagnostic);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
this.diagnosticCollection.set(document.uri, diagnostics);
|
|
164
|
+
}
|
|
165
|
+
validateBranch(branchName) {
|
|
166
|
+
const branchPattern = /^(feature|bugfix|hotfix|chore|refactor|docs|test)\/([a-z0-9-]+)\/[a-z0-9-]+$/;
|
|
167
|
+
if (!branchPattern.test(branchName)) {
|
|
168
|
+
return {
|
|
169
|
+
valid: false,
|
|
170
|
+
message: "Branch name must follow: <type>/<scope>/<description>"
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const parts = branchName.split("/");
|
|
174
|
+
if (parts.length >= 2) {
|
|
175
|
+
const scope = parts[1];
|
|
176
|
+
const validScopes = this.configManager.getScopes();
|
|
177
|
+
if (validScopes.length > 0 && !validScopes.includes(scope)) {
|
|
178
|
+
return {
|
|
179
|
+
valid: false,
|
|
180
|
+
message: `Invalid scope '${scope}'. Valid: ${validScopes.join(", ")}`
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return { valid: true };
|
|
185
|
+
}
|
|
186
|
+
dispose() {
|
|
187
|
+
this.diagnosticCollection.dispose();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/config.ts
|
|
192
|
+
var vscode3 = __toESM(require("vscode"));
|
|
193
|
+
var import_child_process = require("child_process");
|
|
194
|
+
var import_path = require("path");
|
|
195
|
+
var import_fs = require("fs");
|
|
196
|
+
var ConfigManager = class {
|
|
197
|
+
workspaceConfig = null;
|
|
198
|
+
workspaceRoot;
|
|
199
|
+
constructor() {
|
|
200
|
+
this.workspaceRoot = vscode3.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
|
201
|
+
this.reload();
|
|
202
|
+
}
|
|
203
|
+
reload() {
|
|
204
|
+
if (!this.workspaceRoot) {
|
|
205
|
+
this.workspaceConfig = null;
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const configPath = (0, import_path.join)(this.workspaceRoot, "workflow.config.json");
|
|
209
|
+
if ((0, import_fs.existsSync)(configPath)) {
|
|
210
|
+
try {
|
|
211
|
+
delete require.cache[require.resolve(configPath)];
|
|
212
|
+
this.workspaceConfig = require(configPath);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
console.error("Failed to load workflow config:", error);
|
|
215
|
+
this.workspaceConfig = null;
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
this.workspaceConfig = null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
hasConfig() {
|
|
222
|
+
return this.workspaceConfig !== null;
|
|
223
|
+
}
|
|
224
|
+
getScopes() {
|
|
225
|
+
if (!this.workspaceConfig?.scopes) {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
return this.workspaceConfig.scopes.map((s) => s.name);
|
|
229
|
+
}
|
|
230
|
+
getProjectName() {
|
|
231
|
+
return this.workspaceConfig?.projectName;
|
|
232
|
+
}
|
|
233
|
+
getEnforcement() {
|
|
234
|
+
return this.workspaceConfig?.enforcement || "advisory";
|
|
235
|
+
}
|
|
236
|
+
isEnabled() {
|
|
237
|
+
const config = vscode3.workspace.getConfiguration("workflow-agent");
|
|
238
|
+
return config.get("enabled", true);
|
|
239
|
+
}
|
|
240
|
+
shouldValidateOnType() {
|
|
241
|
+
const config = vscode3.workspace.getConfiguration("workflow-agent");
|
|
242
|
+
return config.get("validateOnType", true);
|
|
243
|
+
}
|
|
244
|
+
shouldShowStatusBar() {
|
|
245
|
+
const config = vscode3.workspace.getConfiguration("workflow-agent");
|
|
246
|
+
return config.get("showStatusBar", true);
|
|
247
|
+
}
|
|
248
|
+
isStrictMode() {
|
|
249
|
+
const config = vscode3.workspace.getConfiguration("workflow-agent");
|
|
250
|
+
return config.get("strictMode", false);
|
|
251
|
+
}
|
|
252
|
+
getCurrentBranch() {
|
|
253
|
+
if (!this.workspaceRoot) return null;
|
|
254
|
+
try {
|
|
255
|
+
const branch = (0, import_child_process.execSync)("git rev-parse --abbrev-ref HEAD", {
|
|
256
|
+
cwd: this.workspaceRoot,
|
|
257
|
+
encoding: "utf-8"
|
|
258
|
+
}).trim();
|
|
259
|
+
return branch;
|
|
260
|
+
} catch {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// src/commands.ts
|
|
267
|
+
var vscode4 = __toESM(require("vscode"));
|
|
268
|
+
var CommandRegistry = class {
|
|
269
|
+
constructor(configManager, statusBar, validation) {
|
|
270
|
+
this.configManager = configManager;
|
|
271
|
+
this.statusBar = statusBar;
|
|
272
|
+
this.validation = validation;
|
|
273
|
+
}
|
|
274
|
+
registerAll(context) {
|
|
275
|
+
context.subscriptions.push(
|
|
276
|
+
vscode4.commands.registerCommand(
|
|
277
|
+
"workflow-agent.init",
|
|
278
|
+
() => this.initCommand()
|
|
279
|
+
)
|
|
280
|
+
);
|
|
281
|
+
context.subscriptions.push(
|
|
282
|
+
vscode4.commands.registerCommand(
|
|
283
|
+
"workflow-agent.validate",
|
|
284
|
+
() => this.validateCommand()
|
|
285
|
+
)
|
|
286
|
+
);
|
|
287
|
+
context.subscriptions.push(
|
|
288
|
+
vscode4.commands.registerCommand(
|
|
289
|
+
"workflow-agent.suggest",
|
|
290
|
+
() => this.suggestCommand()
|
|
291
|
+
)
|
|
292
|
+
);
|
|
293
|
+
context.subscriptions.push(
|
|
294
|
+
vscode4.commands.registerCommand(
|
|
295
|
+
"workflow-agent.doctor",
|
|
296
|
+
() => this.doctorCommand()
|
|
297
|
+
)
|
|
298
|
+
);
|
|
299
|
+
context.subscriptions.push(
|
|
300
|
+
vscode4.commands.registerCommand(
|
|
301
|
+
"workflow-agent.showConfig",
|
|
302
|
+
() => this.showConfigCommand()
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
async initCommand() {
|
|
307
|
+
const terminal = vscode4.window.createTerminal("Workflow Agent");
|
|
308
|
+
terminal.show();
|
|
309
|
+
terminal.sendText("workflow init");
|
|
310
|
+
}
|
|
311
|
+
async validateCommand() {
|
|
312
|
+
const branch = this.configManager.getCurrentBranch();
|
|
313
|
+
if (!branch) {
|
|
314
|
+
vscode4.window.showErrorMessage("Not in a git repository");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const result = this.validation.validateBranch(branch);
|
|
318
|
+
if (result.valid) {
|
|
319
|
+
vscode4.window.showInformationMessage(`\u2713 Branch '${branch}' is valid`);
|
|
320
|
+
this.statusBar.updateStatus(true, "Branch is valid");
|
|
321
|
+
} else {
|
|
322
|
+
vscode4.window.showErrorMessage(`\u2717 Invalid branch: ${result.message}`);
|
|
323
|
+
this.statusBar.updateStatus(false, result.message);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async suggestCommand() {
|
|
327
|
+
const feedback = await vscode4.window.showInputBox({
|
|
328
|
+
prompt: "Enter your improvement suggestion",
|
|
329
|
+
placeHolder: "e.g., Add support for GitLab repositories",
|
|
330
|
+
validateInput: (value) => {
|
|
331
|
+
if (value.length < 10) {
|
|
332
|
+
return "Suggestion must be at least 10 characters";
|
|
333
|
+
}
|
|
334
|
+
if (value.length > 1e3) {
|
|
335
|
+
return "Suggestion must be less than 1000 characters";
|
|
336
|
+
}
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
if (!feedback) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const category = await vscode4.window.showQuickPick(
|
|
344
|
+
[
|
|
345
|
+
{ label: "\u2728 Feature Request", value: "feature" },
|
|
346
|
+
{ label: "\u{1F41B} Bug Report", value: "bug" },
|
|
347
|
+
{ label: "\u{1F4DA} Documentation", value: "documentation" },
|
|
348
|
+
{ label: "\u26A1 Performance", value: "performance" },
|
|
349
|
+
{ label: "\u{1F4A1} Other", value: "other" }
|
|
350
|
+
],
|
|
351
|
+
{
|
|
352
|
+
placeHolder: "Select suggestion category"
|
|
353
|
+
}
|
|
354
|
+
);
|
|
355
|
+
if (!category) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const terminal = vscode4.window.createTerminal("Workflow Agent");
|
|
359
|
+
terminal.show();
|
|
360
|
+
terminal.sendText(
|
|
361
|
+
`workflow suggest "${feedback}" --category ${category.value}`
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
async doctorCommand() {
|
|
365
|
+
const terminal = vscode4.window.createTerminal("Workflow Agent");
|
|
366
|
+
terminal.show();
|
|
367
|
+
terminal.sendText("workflow doctor");
|
|
368
|
+
}
|
|
369
|
+
async showConfigCommand() {
|
|
370
|
+
if (!this.configManager.hasConfig()) {
|
|
371
|
+
const action = await vscode4.window.showInformationMessage(
|
|
372
|
+
"Workflow Agent is not initialized in this workspace",
|
|
373
|
+
"Initialize Now"
|
|
374
|
+
);
|
|
375
|
+
if (action === "Initialize Now") {
|
|
376
|
+
this.initCommand();
|
|
377
|
+
}
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const projectName = this.configManager.getProjectName();
|
|
381
|
+
const scopes = this.configManager.getScopes();
|
|
382
|
+
const enforcement = this.configManager.getEnforcement();
|
|
383
|
+
const branch = this.configManager.getCurrentBranch();
|
|
384
|
+
const info = [
|
|
385
|
+
`**Project:** ${projectName || "Unknown"}`,
|
|
386
|
+
`**Branch:** ${branch || "Unknown"}`,
|
|
387
|
+
`**Enforcement:** ${enforcement}`,
|
|
388
|
+
`**Scopes (${scopes.length}):** ${scopes.join(", ") || "None"}`
|
|
389
|
+
].join("\n\n");
|
|
390
|
+
const panel = vscode4.window.createWebviewPanel(
|
|
391
|
+
"workflowConfig",
|
|
392
|
+
"Workflow Configuration",
|
|
393
|
+
vscode4.ViewColumn.One,
|
|
394
|
+
{}
|
|
395
|
+
);
|
|
396
|
+
panel.webview.html = `
|
|
397
|
+
<!DOCTYPE html>
|
|
398
|
+
<html>
|
|
399
|
+
<head>
|
|
400
|
+
<meta charset="UTF-8">
|
|
401
|
+
<style>
|
|
402
|
+
body {
|
|
403
|
+
padding: 20px;
|
|
404
|
+
font-family: var(--vscode-font-family);
|
|
405
|
+
color: var(--vscode-foreground);
|
|
406
|
+
}
|
|
407
|
+
h1 {
|
|
408
|
+
border-bottom: 1px solid var(--vscode-panel-border);
|
|
409
|
+
padding-bottom: 10px;
|
|
410
|
+
}
|
|
411
|
+
.info {
|
|
412
|
+
line-height: 1.8;
|
|
413
|
+
}
|
|
414
|
+
.scope-list {
|
|
415
|
+
margin-top: 10px;
|
|
416
|
+
display: flex;
|
|
417
|
+
flex-wrap: wrap;
|
|
418
|
+
gap: 8px;
|
|
419
|
+
}
|
|
420
|
+
.scope {
|
|
421
|
+
background: var(--vscode-badge-background);
|
|
422
|
+
color: var(--vscode-badge-foreground);
|
|
423
|
+
padding: 4px 12px;
|
|
424
|
+
border-radius: 12px;
|
|
425
|
+
font-size: 0.9em;
|
|
426
|
+
}
|
|
427
|
+
</style>
|
|
428
|
+
</head>
|
|
429
|
+
<body>
|
|
430
|
+
<h1>\u{1F680} Workflow Agent Configuration</h1>
|
|
431
|
+
<div class="info">
|
|
432
|
+
<p><strong>Project:</strong> ${projectName || "Unknown"}</p>
|
|
433
|
+
<p><strong>Current Branch:</strong> ${branch || "Unknown"}</p>
|
|
434
|
+
<p><strong>Enforcement Mode:</strong> ${enforcement}</p>
|
|
435
|
+
<p><strong>Available Scopes:</strong></p>
|
|
436
|
+
<div class="scope-list">
|
|
437
|
+
${scopes.map((s) => `<span class="scope">${s}</span>`).join("")}
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
</body>
|
|
441
|
+
</html>
|
|
442
|
+
`;
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
// src/extension.ts
|
|
447
|
+
function activate(context) {
|
|
448
|
+
console.log("Workflow Agent extension activating...");
|
|
449
|
+
const configManager = new ConfigManager();
|
|
450
|
+
const statusBar = new StatusBarManager();
|
|
451
|
+
const validationProvider = new ValidationProvider(configManager);
|
|
452
|
+
const commands2 = new CommandRegistry(
|
|
453
|
+
configManager,
|
|
454
|
+
statusBar,
|
|
455
|
+
validationProvider
|
|
456
|
+
);
|
|
457
|
+
commands2.registerAll(context);
|
|
458
|
+
statusBar.show();
|
|
459
|
+
context.subscriptions.push(statusBar);
|
|
460
|
+
validationProvider.activate(context);
|
|
461
|
+
context.subscriptions.push(
|
|
462
|
+
vscode5.workspace.onDidChangeConfiguration((e) => {
|
|
463
|
+
if (e.affectsConfiguration("workflow-agent")) {
|
|
464
|
+
configManager.reload();
|
|
465
|
+
statusBar.update();
|
|
466
|
+
}
|
|
467
|
+
})
|
|
468
|
+
);
|
|
469
|
+
context.subscriptions.push(
|
|
470
|
+
vscode5.workspace.onDidChangeTextDocument((e) => {
|
|
471
|
+
if (e.document.fileName.includes(".git/COMMIT_EDITMSG")) {
|
|
472
|
+
validationProvider.validateCommitMessage(e.document);
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
);
|
|
476
|
+
console.log("Workflow Agent extension activated!");
|
|
477
|
+
}
|
|
478
|
+
function deactivate() {
|
|
479
|
+
console.log("Workflow Agent extension deactivating...");
|
|
480
|
+
}
|
|
481
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
482
|
+
0 && (module.exports = {
|
|
483
|
+
activate,
|
|
484
|
+
deactivate
|
|
485
|
+
});
|
|
486
|
+
//# sourceMappingURL=extension.js.map
|