@fleettools/opencode-plugin 0.1.1

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,65 @@
1
+ export interface OpenCodeCommand {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ handler: () => Promise<void>;
6
+ }
7
+ export interface OpenCodeCommandRegistry {
8
+ registerCommand: (command: OpenCodeCommand) => void;
9
+ }
10
+ export interface FleetToolsOpenCodePlugin {
11
+ name: string;
12
+ version: string;
13
+ registerCommands: (commands: OpenCodeCommandRegistry) => Promise<void>;
14
+ }
15
+ export interface FleetToolsStatus {
16
+ mode?: 'local' | 'synced';
17
+ config?: {
18
+ fleet?: {
19
+ user_id?: string;
20
+ workspace_id?: string;
21
+ };
22
+ };
23
+ podman?: {
24
+ available?: boolean;
25
+ zero?: {
26
+ url?: string;
27
+ };
28
+ api?: {
29
+ url?: string;
30
+ };
31
+ };
32
+ sync?: {
33
+ zero?: {
34
+ url?: string;
35
+ };
36
+ api?: {
37
+ url?: string;
38
+ };
39
+ };
40
+ }
41
+ export declare class FleetToolsOpenCodePluginImpl implements FleetToolsOpenCodePlugin {
42
+ /** Plugin name */
43
+ name: string;
44
+ /** Plugin version */
45
+ version: string;
46
+ registerCommands(commands: OpenCodeCommandRegistry): Promise<void>;
47
+ private handleStatus;
48
+ private handleSetup;
49
+ private handleDoctor;
50
+ private handleServices;
51
+ private handleHelp;
52
+ private showMessage;
53
+ private showError;
54
+ private showOutput;
55
+ private showInOutputPane;
56
+ }
57
+ export declare function createPlugin(): FleetToolsOpenCodePluginImpl;
58
+ export declare const fleetToolsPlugin: {
59
+ name: string;
60
+ version: string;
61
+ register: (commands: OpenCodeCommandRegistry) => Promise<void>;
62
+ };
63
+ export declare function fallbackRegister(): Promise<void>;
64
+ export default fleetToolsPlugin;
65
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,174 @@
1
+ import { exec } from 'child_process';
2
+ import { promisify } from 'util';
3
+ const execAsync = promisify(exec);
4
+ export class FleetToolsOpenCodePluginImpl {
5
+ /** Plugin name */
6
+ name = 'FleetTools';
7
+ /** Plugin version */
8
+ version = '0.1.0';
9
+ async registerCommands(commands) {
10
+ commands.registerCommand({
11
+ id: 'fleet-status',
12
+ name: '/fleet status',
13
+ description: 'Show FleetTools status and configuration',
14
+ handler: this.handleStatus.bind(this),
15
+ });
16
+ commands.registerCommand({
17
+ id: 'fleet-setup',
18
+ name: '/fleet setup',
19
+ description: 'Initialize FleetTools configuration',
20
+ handler: this.handleSetup.bind(this),
21
+ });
22
+ commands.registerCommand({
23
+ id: 'fleet-doctor',
24
+ name: '/fleet doctor',
25
+ description: 'Diagnose FleetTools installation and configuration',
26
+ handler: this.handleDoctor.bind(this),
27
+ });
28
+ commands.registerCommand({
29
+ id: 'fleet-services',
30
+ name: '/fleet services',
31
+ description: 'Manage local services (up/down/status/logs)',
32
+ handler: this.handleServices.bind(this),
33
+ });
34
+ commands.registerCommand({
35
+ id: 'fleet-help',
36
+ name: '/fleet help',
37
+ description: 'Show FleetTools help information',
38
+ handler: this.handleHelp.bind(this),
39
+ });
40
+ }
41
+ async handleStatus() {
42
+ this.showMessage('Fetching FleetTools status...');
43
+ try {
44
+ const { stdout } = await execAsync('fleet status --json');
45
+ try {
46
+ const status = JSON.parse(stdout);
47
+ const output = [
48
+ 'FleetTools Status',
49
+ '================',
50
+ '',
51
+ `Mode: ${status.mode?.toUpperCase() || 'LOCAL'}`,
52
+ '',
53
+ `User: ${status.config?.fleet?.user_id || 'Not enrolled'}`,
54
+ '',
55
+ ];
56
+ if (status.mode === 'synced') {
57
+ output.push('Sync Status:');
58
+ output.push(` Zero: ${status.sync?.zero?.url ? 'Connected' : 'Not configured'}`);
59
+ output.push(` API: ${status.sync?.api?.url || 'Not configured'}`);
60
+ }
61
+ if (status.podman) {
62
+ output.push('');
63
+ output.push('Podman:');
64
+ output.push(` Available: ${status.podman.available ? 'āœ“' : 'āœ—'}`);
65
+ }
66
+ this.showOutput(output);
67
+ const details = JSON.stringify(status, null, 2);
68
+ this.showInOutputPane('Status Details', details);
69
+ }
70
+ catch {
71
+ this.showOutput(['Failed to parse status output']);
72
+ this.showInOutputPane('Status Details', stdout);
73
+ }
74
+ }
75
+ catch (error) {
76
+ this.showError('Failed to get FleetTools status', error);
77
+ }
78
+ }
79
+ async handleSetup() {
80
+ this.showMessage('Running FleetTools setup...');
81
+ try {
82
+ const { stdout } = await execAsync('fleet setup');
83
+ this.showOutput(stdout);
84
+ this.showInOutputPane('Setup Output', stdout);
85
+ }
86
+ catch (error) {
87
+ this.showError('Failed to run FleetTools setup', error);
88
+ }
89
+ }
90
+ async handleDoctor() {
91
+ this.showMessage('Running FleetTools diagnostics...');
92
+ try {
93
+ const { stdout } = await execAsync('fleet doctor');
94
+ this.showOutput(stdout);
95
+ this.showInOutputPane('Diagnostics Output', stdout);
96
+ }
97
+ catch (error) {
98
+ this.showError('Failed to run FleetTools doctor', error);
99
+ }
100
+ }
101
+ async handleServices() {
102
+ this.showMessage('Opening FleetTools services menu...');
103
+ try {
104
+ const { stdout } = await execAsync('fleet services');
105
+ this.showOutput(stdout);
106
+ this.showInOutputPane('Services Menu', stdout);
107
+ }
108
+ catch (error) {
109
+ this.showError('Failed to open services menu', error);
110
+ }
111
+ }
112
+ async handleHelp() {
113
+ const output = [
114
+ 'FleetTools Plugin for OpenCode',
115
+ '=============================',
116
+ '',
117
+ 'Commands:',
118
+ ' /fleet status - Show FleetTools status',
119
+ ' /fleet setup - Initialize FleetTools configuration',
120
+ ' /fleet doctor - Diagnose installation and configuration',
121
+ ' /fleet services - Manage local services',
122
+ ' /fleet help - Show this help',
123
+ '',
124
+ 'For more information, see: https://github.com/v1truv1us/fleettools',
125
+ ];
126
+ this.showOutput(output);
127
+ }
128
+ // ==========================================================================
129
+ // ==========================================================================
130
+ showMessage(message) {
131
+ this.showOutput(`\n${message}\n`);
132
+ }
133
+ showError(message, error) {
134
+ this.showOutput(`\nāŒ Error: ${message}\n`);
135
+ this.showOutput(` ${error.message}\n`);
136
+ }
137
+ showOutput(message) {
138
+ if (Array.isArray(message)) {
139
+ message.forEach((line) => console.log(line));
140
+ }
141
+ else {
142
+ console.log(message);
143
+ }
144
+ }
145
+ showInOutputPane(title, content) {
146
+ console.log(`\n--- ${title} ---\n${content}\n`);
147
+ }
148
+ }
149
+ let plugin = null;
150
+ export function createPlugin() {
151
+ if (!plugin) {
152
+ plugin = new FleetToolsOpenCodePluginImpl();
153
+ }
154
+ return plugin;
155
+ }
156
+ export const fleetToolsPlugin = {
157
+ name: 'FleetTools',
158
+ version: '0.1.0',
159
+ register: async (commands) => {
160
+ const fleetPlugin = createPlugin();
161
+ await fleetPlugin.registerCommands(commands);
162
+ },
163
+ };
164
+ export async function fallbackRegister() {
165
+ console.warn('[FleetTools] OpenCode SDK not available. Running in CLI fallback mode.');
166
+ console.warn('[FleetTools] The following commands are available via fleet CLI:');
167
+ console.warn(' - fleet status');
168
+ console.warn(' - fleet setup');
169
+ console.warn(' - fleet doctor');
170
+ console.warn(' - fleet services');
171
+ console.warn(' - fleet help');
172
+ }
173
+ export default fleetToolsPlugin;
174
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@fleettools/opencode-plugin",
3
+ "version": "0.1.1",
4
+ "description": "FleetTools plugin for OpenCode editor - /fleet commands",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ },
12
+ "bin": {
13
+ "fleet-opencode": "./dist/index.js"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc --project tsconfig.json",
17
+ "test": "echo 'No tests configured'",
18
+ "clean": "rm -rf dist"
19
+ },
20
+ "keywords": [
21
+ "fleettools",
22
+ "opencode",
23
+ "plugin",
24
+ "cli"
25
+ ],
26
+ "author": "FleetTools Contributors",
27
+ "license": "MIT",
28
+ "engines": {
29
+ "bun": ">=1.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "^5.9.3",
33
+ "@types/node": "^20.10.6"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ }
38
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true,
17
+ "noImplicitAny": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noImplicitReturns": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedIndexedAccess": true
23
+ },
24
+ "include": [
25
+ "src/**/*.ts"
26
+ ],
27
+ "exclude": [
28
+ "node_modules",
29
+ "dist"
30
+ ]
31
+ }