Initialize remote IDE scaffold

This commit is contained in:
2026-05-10 14:08:25 +00:00
commit 138eea3231
97 changed files with 21129 additions and 0 deletions
@@ -0,0 +1,22 @@
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command.js';
import { MenuContribution, MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry.js';
import { MessageService } from '@theia/core/lib/common/message-service.js';
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
import { type IGitZoneOpenCodeServer } from '../common/gitzone-opencode-protocol.js';
export declare const GitZoneOpenCodeHealthCommand: {
id: string;
label: string;
};
export declare const GitZoneOpenCodeNewSessionCommand: {
id: string;
label: string;
};
export declare class GitZoneOpenCodeContribution implements CommandContribution, MenuContribution {
protected readonly openCodeServer: IGitZoneOpenCodeServer;
protected readonly messages: MessageService;
registerCommands(registry: CommandRegistry): void;
registerMenus(menus: MenuModelRegistry): void;
}
declare const _default: ContainerModule;
export default _default;
//# sourceMappingURL=gitzone-opencode-frontend-module.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/gitzone-opencode-frontend-module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAsB,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,wCAAwC,CAAC;AAEhD,eAAO,MAAM,4BAA4B;;;CAGxC,CAAC;AAEF,eAAO,MAAM,gCAAgC;;;CAG5C,CAAC;AAEF,qBACa,2BAA4B,YAAW,mBAAmB,EAAE,gBAAgB;IAEvF,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAG,sBAAsB,CAAC;IAG3D,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,cAAc,CAAC;IAE7C,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAejD,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAU9C;;AAQD,wBAWG"}
@@ -0,0 +1,83 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneOpenCodeContribution = exports.GitZoneOpenCodeNewSessionCommand = exports.GitZoneOpenCodeHealthCommand = void 0;
const common_menus_js_1 = require("@theia/core/lib/browser/common-menus.js");
const ws_connection_provider_js_1 = require("@theia/core/lib/browser/messaging/ws-connection-provider.js");
const command_js_1 = require("@theia/core/lib/common/command.js");
const menu_model_registry_js_1 = require("@theia/core/lib/common/menu/menu-model-registry.js");
const message_service_js_1 = require("@theia/core/lib/common/message-service.js");
const index_js_1 = require("@theia/core/shared/inversify/index.js");
const gitzone_opencode_protocol_js_1 = require("../common/gitzone-opencode-protocol.js");
exports.GitZoneOpenCodeHealthCommand = {
id: 'gitzone.opencode.health',
label: 'OpenCode: Check Health',
};
exports.GitZoneOpenCodeNewSessionCommand = {
id: 'gitzone.opencode.newSession',
label: 'OpenCode: New Session',
};
let GitZoneOpenCodeContribution = class GitZoneOpenCodeContribution {
openCodeServer;
messages;
registerCommands(registry) {
registry.registerCommand(exports.GitZoneOpenCodeHealthCommand, {
execute: async () => {
const health = await this.openCodeServer.health();
await this.messages.info(`OpenCode health: ${JSON.stringify(health)}`);
},
});
registry.registerCommand(exports.GitZoneOpenCodeNewSessionCommand, {
execute: async () => {
const session = await this.openCodeServer.createSession('Git.Zone IDE Session');
await this.messages.info(`OpenCode session created: ${JSON.stringify(session)}`);
},
});
}
registerMenus(menus) {
menus.registerMenuAction(common_menus_js_1.CommonMenus.VIEW_VIEWS, {
commandId: exports.GitZoneOpenCodeHealthCommand.id,
label: exports.GitZoneOpenCodeHealthCommand.label,
});
menus.registerMenuAction(common_menus_js_1.CommonMenus.VIEW_VIEWS, {
commandId: exports.GitZoneOpenCodeNewSessionCommand.id,
label: exports.GitZoneOpenCodeNewSessionCommand.label,
});
}
};
exports.GitZoneOpenCodeContribution = GitZoneOpenCodeContribution;
__decorate([
(0, index_js_1.inject)(gitzone_opencode_protocol_js_1.GitZoneOpenCodeServer),
__metadata("design:type", Object)
], GitZoneOpenCodeContribution.prototype, "openCodeServer", void 0);
__decorate([
(0, index_js_1.inject)(message_service_js_1.MessageService),
__metadata("design:type", message_service_js_1.MessageService)
], GitZoneOpenCodeContribution.prototype, "messages", void 0);
exports.GitZoneOpenCodeContribution = GitZoneOpenCodeContribution = __decorate([
(0, index_js_1.injectable)()
], GitZoneOpenCodeContribution);
const openCodeClient = {
onOpenCodeEvent: (event) => {
globalThis.dispatchEvent(new CustomEvent('gitzone-opencode-event', { detail: event }));
},
};
exports.default = new index_js_1.ContainerModule((bind) => {
bind(gitzone_opencode_protocol_js_1.GitZoneOpenCodeServer)
.toDynamicValue((context) => context.container
.get(ws_connection_provider_js_1.WebSocketConnectionProvider)
.createProxy(gitzone_opencode_protocol_js_1.gitZoneOpenCodePath, openCodeClient))
.inSingletonScope();
bind(GitZoneOpenCodeContribution).toSelf().inSingletonScope();
bind(command_js_1.CommandContribution).toService(GitZoneOpenCodeContribution);
bind(menu_model_registry_js_1.MenuContribution).toService(GitZoneOpenCodeContribution);
});
//# sourceMappingURL=gitzone-opencode-frontend-module.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-frontend-module.js","sourceRoot":"","sources":["../../src/browser/gitzone-opencode-frontend-module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6EAAsE;AACtE,2GAA0G;AAC1G,kEAAyF;AACzF,+FAAyG;AACzG,kFAA2E;AAC3E,oEAA4F;AAC5F,yFAKgD;AAEnC,QAAA,4BAA4B,GAAG;IAC1C,EAAE,EAAE,yBAAyB;IAC7B,KAAK,EAAE,wBAAwB;CAChC,CAAC;AAEW,QAAA,gCAAgC,GAAG;IAC9C,EAAE,EAAE,6BAA6B;IACjC,KAAK,EAAE,uBAAuB;CAC/B,CAAC;AAGK,IAAM,2BAA2B,GAAjC,MAAM,2BAA2B;IAEnB,cAAc,CAA0B;IAGxC,QAAQ,CAAkB;IAE7C,gBAAgB,CAAC,QAAyB;QACxC,QAAQ,CAAC,eAAe,CAAC,oCAA4B,EAAE;YACrD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;gBAClD,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACzE,CAAC;SACF,CAAC,CAAC;QACH,QAAQ,CAAC,eAAe,CAAC,wCAAgC,EAAE;YACzD,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;gBAChF,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACnF,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAwB;QACpC,KAAK,CAAC,kBAAkB,CAAC,6BAAW,CAAC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oneOpenCodePath = "/services/git-zone/opencode";
export declare const GitZoneOpenCodeServer: unique symbol;
export interface IGitZoneOpenCodeConnectionInfo {
baseUrl: string;
port: number;
workspacePath: string;
autoStart: boolean;
}
export interface IGitZoneOpenCodeEvent {
type: string;
id?: string;
retry?: number;
data?: unknown;
raw: string;
}
export interface IGitZoneOpenCodeClient {
onOpenCodeEvent(event: IGitZoneOpenCodeEvent): void;
}
export interface IGitZoneOpenCodePromptBody {
messageID?: string;
model?: {
providerID: string;
modelID: string;
};
agent?: string;
noReply?: boolean;
system?: string;
tools?: Record<string, boolean>;
parts: Array<{
type: string;
[key: string]: unknown;
}>;
}
export interface IGitZoneOpenCodeServer {
setClient(client: IGitZoneOpenCodeClient | undefined): void;
getConnectionInfo(): Promise<IGitZoneOpenCodeConnectionInfo>;
health(): Promise<unknown>;
providers(): Promise<unknown>;
agents(): Promise<unknown>;
sessions(): Promise<unknown>;
createSession(title?: string): Promise<unknown>;
messages(sessionId: string, limit?: number): Promise<unknown>;
prompt(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<unknown>;
promptAsync(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<void>;
command(sessionId: string, command: string, commandArguments?: string): Promise<unknown>;
abort(sessionId: string): Promise<unknown>;
diff(sessionId: string, messageId?: string): Promise<unknown>;
todo(sessionId: string): Promise<unknown>;
respondToPermission(sessionId: string, permissionId: string, response: string, remember?: boolean): Promise<unknown>;
}
//# sourceMappingURL=gitzone-opencode-protocol.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-protocol.d.ts","sourceRoot":"","sources":["../../src/common/gitzone-opencode-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AAEjE,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AAErE,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAA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,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9E,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzF,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9D,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtH"}
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneOpenCodeServer = exports.gitZoneOpenCodePath = void 0;
exports.gitZoneOpenCodePath = '/services/git-zone/opencode';
exports.GitZoneOpenCodeServer = Symbol('GitZoneOpenCodeServer');
//# sourceMappingURL=gitzone-opencode-protocol.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-protocol.js","sourceRoot":"","sources":["../../src/common/gitzone-opencode-protocol.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,6BAA6B,CAAC;AAEpD,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
declare const _default: ContainerModule;
export default _default;
//# sourceMappingURL=gitzone-opencode-backend-module.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/gitzone-opencode-backend-module.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;;AASxE,wBAaG"}
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const backend_application_js_1 = require("@theia/core/lib/node/backend-application.js");
const handler_js_1 = require("@theia/core/lib/common/messaging/handler.js");
const proxy_factory_js_1 = require("@theia/core/lib/common/messaging/proxy-factory.js");
const index_js_1 = require("@theia/core/shared/inversify/index.js");
const gitzone_opencode_protocol_js_1 = require("../common/gitzone-opencode-protocol.js");
const gitzone_opencode_node_service_js_1 = require("./gitzone-opencode-node-service.js");
exports.default = new index_js_1.ContainerModule((bind) => {
bind(gitzone_opencode_node_service_js_1.GitZoneOpenCodeNodeService).toSelf().inSingletonScope();
bind(gitzone_opencode_protocol_js_1.GitZoneOpenCodeServer).toService(gitzone_opencode_node_service_js_1.GitZoneOpenCodeNodeService);
bind(backend_application_js_1.BackendApplicationContribution).toService(gitzone_opencode_node_service_js_1.GitZoneOpenCodeNodeService);
bind(handler_js_1.ConnectionHandler)
.toDynamicValue((context) => new proxy_factory_js_1.RpcConnectionHandler(gitzone_opencode_protocol_js_1.gitZoneOpenCodePath, (client) => {
const server = context.container.get(gitzone_opencode_protocol_js_1.GitZoneOpenCodeServer);
server.setClient(client);
return server;
}))
.inSingletonScope();
});
//# sourceMappingURL=gitzone-opencode-backend-module.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-backend-module.js","sourceRoot":"","sources":["../../src/node/gitzone-opencode-backend-module.ts"],"names":[],"mappings":";;AAAA,wFAA6F;AAC7F,4EAAgF;AAChF,wFAAyF;AACzF,oEAAwE;AACxE,yFAKgD;AAChD,yFAAgF;AAEhF,kBAAe,IAAI,0BAAe,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1C,IAAI,CAAC,6DAA0B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC7D,IAAI,CAAC,oDAAqB,CAAC,CAAC,SAAS,CAAC,6DAA0B,CAAC,CAAC;IAClE,IAAI,CAAC,uDAA8B,CAAC,CAAC,SAAS,CAAC,6DAA0B,CAAC,CAAC;IAC3E,IAAI,CAAC,8BAAiB,CAAC;SACpB,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE,CAC1B,IAAI,uCAAoB,CAAyB,kDAAmB,EAAE,CAAC,MAAM,EAAE,EAAE;QAC/E,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAyB,oDAAqB,CAAC,CAAC;QACpF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzB,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CACH;SACA,gBAAgB,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,36 @@
import { OpenCodeServerClient } from '@git.zone/ide-opencode-bridge';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application.js';
import type { IGitZoneOpenCodeClient, IGitZoneOpenCodeConnectionInfo, IGitZoneOpenCodePromptBody, IGitZoneOpenCodeServer } from '../common/gitzone-opencode-protocol.js';
import * as plugins from './plugins.js';
export declare class GitZoneOpenCodeNodeService implements IGitZoneOpenCodeServer, BackendApplicationContribution {
protected client: IGitZoneOpenCodeClient | undefined;
protected eventAbortController: AbortController | undefined;
protected openCodeProcess: plugins.childProcess.ChildProcess | undefined;
initialize(): void;
onStop(): void;
setClient(client: IGitZoneOpenCodeClient | undefined): void;
getConnectionInfo(): Promise<IGitZoneOpenCodeConnectionInfo>;
health(): Promise<unknown>;
providers(): Promise<unknown>;
agents(): Promise<unknown>;
sessions(): Promise<unknown>;
createSession(title?: string): Promise<unknown>;
messages(sessionId: string, limit?: number): Promise<unknown>;
prompt(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<unknown>;
promptAsync(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<void>;
command(sessionId: string, command: string, commandArguments?: string): Promise<unknown>;
abort(sessionId: string): Promise<unknown>;
diff(sessionId: string, messageId?: string): Promise<unknown>;
todo(sessionId: string): Promise<unknown>;
respondToPermission(sessionId: string, permissionId: string, response: string, remember?: boolean): Promise<unknown>;
protected ensureOpenCodeStarted(): Promise<void>;
protected restartEventStream(): void;
protected createClient(): OpenCodeServerClient;
protected get workspacePath(): string;
protected get port(): number;
protected get baseUrl(): string;
protected get username(): string;
protected get password(): string;
protected get autoStart(): boolean;
}
//# sourceMappingURL=gitzone-opencode-node-service.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-node-service.d.ts","sourceRoot":"","sources":["../../src/node/gitzone-opencode-node-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAE7F,OAAO,KAAK,EACV,sBAAsB,EACtB,8BAA8B,EAC9B,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,qBACa,0BAA2B,YAAW,sBAAsB,EAAE,8BAA8B;IACvG,SAAS,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACrD,SAAS,CAAC,oBAAoB,EAAE,eAAe,GAAG,SAAS,CAAC;IAC5D,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC,YAAY,CAAC,YAAY,GAAG,SAAS,CAAC;IAEzE,UAAU,IAAI,IAAI;IAIlB,MAAM,IAAI,IAAI;IAOd,SAAS,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,GAAG,IA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AS,KAAK,IAAI,WAGjB;IAED,SAAS,KAAK,OAAO,WAEpB;IAED,SAAS,KAAK,QAAQ,WAErB;IAED,SAAS,KAAK,QAAQ,WAErB;IAED,SAAS,KAAK,SAAS,YAEtB;CACF"}
@@ -0,0 +1,173 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneOpenCodeNodeService = void 0;
const ide_opencode_bridge_1 = require("@git.zone/ide-opencode-bridge");
const index_js_1 = require("@theia/core/shared/inversify/index.js");
const plugins = __importStar(require("./plugins.js"));
let GitZoneOpenCodeNodeService = class GitZoneOpenCodeNodeService {
client;
eventAbortController;
openCodeProcess;
initialize() {
void this.ensureOpenCodeStarted();
}
onStop() {
this.eventAbortController?.abort();
if (this.openCodeProcess && this.openCodeProcess.exitCode === null) {
this.openCodeProcess.kill('SIGTERM');
}
}
setClient(client) {
this.client = client;
this.restartEventStream();
}
async getConnectionInfo() {
return {
baseUrl: this.baseUrl,
port: this.port,
workspacePath: this.workspacePath,
autoStart: this.autoStart,
};
}
async health() {
await this.ensureOpenCodeStarted();
return this.createClient().health();
}
async providers() {
return this.createClient().providers();
}
async agents() {
return this.createClient().agents();
}
async sessions() {
return this.createClient().sessions();
}
async createSession(title) {
return this.createClient().createSession(title ? { title } : {});
}
async messages(sessionId, limit) {
return this.createClient().messages(sessionId, limit);
}
async prompt(sessionId, body) {
return this.createClient().prompt(sessionId, body);
}
async promptAsync(sessionId, body) {
await this.createClient().promptAsync(sessionId, body);
}
async command(sessionId, command, commandArguments = '') {
return this.createClient().command(sessionId, { command, arguments: commandArguments });
}
async abort(sessionId) {
return this.createClient().abort(sessionId);
}
async diff(sessionId, messageId) {
return this.createClient().diff(sessionId, messageId);
}
async todo(sessionId) {
return this.createClient().todo(sessionId);
}
async respondToPermission(sessionId, permissionId, response, remember) {
return this.createClient().respondToPermission(sessionId, permissionId, { response, remember });
}
async ensureOpenCodeStarted() {
try {
await this.createClient().health();
return;
}
catch {
if (!this.autoStart || this.openCodeProcess) {
return;
}
}
this.openCodeProcess = plugins.childProcess.spawn('opencode', ['serve', '--hostname', '127.0.0.1', '--port', `${this.port}`], {
cwd: this.workspacePath,
env: {
...process.env,
OPENCODE_SERVER_USERNAME: this.username,
OPENCODE_SERVER_PASSWORD: this.password,
},
shell: false,
stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true,
});
}
restartEventStream() {
this.eventAbortController?.abort();
if (!this.client) {
return;
}
const abortController = new AbortController();
this.eventAbortController = abortController;
void (async () => {
try {
await this.ensureOpenCodeStarted();
for await (const event of this.createClient().events(abortController.signal)) {
this.client?.onOpenCodeEvent(event);
}
}
catch {
// The UI can explicitly call health() for detailed connection diagnostics.
}
})();
}
createClient() {
return new ide_opencode_bridge_1.OpenCodeServerClient({
baseUrl: this.baseUrl,
username: this.username,
password: this.password,
});
}
get workspacePath() {
return process.env.GITZONE_IDE_WORKSPACE || process.cwd();
}
get port() {
const port = Number(process.env.GITZONE_IDE_OPENCODE_PORT || '4096');
return Number.isInteger(port) && port > 0 ? port : 4096;
}
get baseUrl() {
return `http://127.0.0.1:${this.port}`;
}
get username() {
return process.env.OPENCODE_SERVER_USERNAME || 'opencode';
}
get password() {
return process.env.OPENCODE_SERVER_PASSWORD || '';
}
get autoStart() {
return process.env.GITZONE_IDE_DISABLE_OPENCODE_AUTOSTART !== '1';
}
};
exports.GitZoneOpenCodeNodeService = GitZoneOpenCodeNodeService;
exports.GitZoneOpenCodeNodeService = GitZoneOpenCodeNodeService = __decorate([
(0, index_js_1.injectable)()
], GitZoneOpenCodeNodeService);
//# sourceMappingURL=gitzone-opencode-node-service.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-opencode-node-service.js","sourceRoot":"","sources":["../../src/node/gitzone-opencode-node-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uEAAqE;AAErE,oEAAmE;AAOnE,sDAAwC;AAGjC,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAC3B,MAAM,CAAqC;IAC3C,oBAAoB,CAA8B;IAClD,eAAe,CAAgD;IAEzE,UAAU;QACR,KAAK,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACpC,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,oBAAoB,EAAE,KAAK,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YACnE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,SAAS,CAAC,MAA0C;QAClD,IAAI,CAAC,MAAM,G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zB,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAED,IAAc,IAAI;QAChB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,MAAM,CAAC,CAAC;QACrE,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,CAAC;IAED,IAAc,OAAO;QACnB,OAAO,oBAAoB,IAAI,CAAC,IAAI,EAAE,CAAC;IACzC,CAAC;IAED,IAAc,QAAQ;QACpB,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,UAAU,CAAC;IAC5D,CAAC;IAED,IAAc,QAAQ;QACpB,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,EAAE,CAAC;IACpD,CAAC;IAED,IAAc,SAAS;QACrB,OAAO,OAAO,CAAC,GAAG,CAAC,sCAAsC,KAAK,GAAG,CAAC;IACpE,CAAC;CACF,CAAA;AAtKY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,qBAAU,GAAE;GACA,0BAA0B,CAsKtC"}
@@ -0,0 +1,3 @@
import * as childProcess from 'node:child_process';
export { childProcess };
//# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/node/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,29 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.childProcess = void 0;
const childProcess = __importStar(require("node:child_process"));
exports.childProcess = childProcess;
//# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/node/plugins.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAmD;AAE1C,oCAAY"}
@@ -0,0 +1,20 @@
{
"name": "@git.zone/ide-extension-opencode",
"version": "0.1.0",
"private": true,
"keywords": ["theia-extension"],
"scripts": {
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@git.zone/ide-opencode-bridge": "workspace:*",
"@theia/core": "1.71.0"
},
"theiaExtensions": [
{
"frontend": "lib/browser/gitzone-opencode-frontend-module",
"backend": "lib/node/gitzone-opencode-backend-module"
}
],
"files": ["src", "lib"]
}
@@ -0,0 +1,76 @@
import { CommonMenus } from '@theia/core/lib/browser/common-menus.js';
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider.js';
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command.js';
import { MenuContribution, MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry.js';
import { MessageService } from '@theia/core/lib/common/message-service.js';
import { ContainerModule, inject, injectable } from '@theia/core/shared/inversify/index.js';
import {
GitZoneOpenCodeServer,
gitZoneOpenCodePath,
type IGitZoneOpenCodeClient,
type IGitZoneOpenCodeServer,
} from '../common/gitzone-opencode-protocol.js';
export const GitZoneOpenCodeHealthCommand = {
id: 'gitzone.opencode.health',
label: 'OpenCode: Check Health',
};
export const GitZoneOpenCodeNewSessionCommand = {
id: 'gitzone.opencode.newSession',
label: 'OpenCode: New Session',
};
@injectable()
export class GitZoneOpenCodeContribution implements CommandContribution, MenuContribution {
@inject(GitZoneOpenCodeServer)
protected readonly openCodeServer!: IGitZoneOpenCodeServer;
@inject(MessageService)
protected readonly messages!: MessageService;
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(GitZoneOpenCodeHealthCommand, {
execute: async () => {
const health = await this.openCodeServer.health();
await this.messages.info(`OpenCode health: ${JSON.stringify(health)}`);
},
});
registry.registerCommand(GitZoneOpenCodeNewSessionCommand, {
execute: async () => {
const session = await this.openCodeServer.createSession('Git.Zone IDE Session');
await this.messages.info(`OpenCode session created: ${JSON.stringify(session)}`);
},
});
}
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.VIEW_VIEWS, {
commandId: GitZoneOpenCodeHealthCommand.id,
label: GitZoneOpenCodeHealthCommand.label,
});
menus.registerMenuAction(CommonMenus.VIEW_VIEWS, {
commandId: GitZoneOpenCodeNewSessionCommand.id,
label: GitZoneOpenCodeNewSessionCommand.label,
});
}
}
const openCodeClient: IGitZoneOpenCodeClient = {
onOpenCodeEvent: (event) => {
globalThis.dispatchEvent(new CustomEvent('gitzone-opencode-event', { detail: event }));
},
};
export default new ContainerModule((bind) => {
bind(GitZoneOpenCodeServer)
.toDynamicValue((context) =>
context.container
.get(WebSocketConnectionProvider)
.createProxy<IGitZoneOpenCodeServer>(gitZoneOpenCodePath, openCodeClient),
)
.inSingletonScope();
bind(GitZoneOpenCodeContribution).toSelf().inSingletonScope();
bind(CommandContribution).toService(GitZoneOpenCodeContribution);
bind(MenuContribution).toService(GitZoneOpenCodeContribution);
});
@@ -0,0 +1,53 @@
export const gitZoneOpenCodePath = '/services/git-zone/opencode';
export const GitZoneOpenCodeServer = Symbol('GitZoneOpenCodeServer');
export interface IGitZoneOpenCodeConnectionInfo {
baseUrl: string;
port: number;
workspacePath: string;
autoStart: boolean;
}
export interface IGitZoneOpenCodeEvent {
type: string;
id?: string;
retry?: number;
data?: unknown;
raw: string;
}
export interface IGitZoneOpenCodeClient {
onOpenCodeEvent(event: IGitZoneOpenCodeEvent): void;
}
export interface IGitZoneOpenCodePromptBody {
messageID?: string;
model?: {
providerID: string;
modelID: string;
};
agent?: string;
noReply?: boolean;
system?: string;
tools?: Record<string, boolean>;
parts: Array<{ type: string; [key: string]: unknown }>;
}
export interface IGitZoneOpenCodeServer {
setClient(client: IGitZoneOpenCodeClient | undefined): void;
getConnectionInfo(): Promise<IGitZoneOpenCodeConnectionInfo>;
health(): Promise<unknown>;
providers(): Promise<unknown>;
agents(): Promise<unknown>;
sessions(): Promise<unknown>;
createSession(title?: string): Promise<unknown>;
messages(sessionId: string, limit?: number): Promise<unknown>;
prompt(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<unknown>;
promptAsync(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<void>;
command(sessionId: string, command: string, commandArguments?: string): Promise<unknown>;
abort(sessionId: string): Promise<unknown>;
diff(sessionId: string, messageId?: string): Promise<unknown>;
todo(sessionId: string): Promise<unknown>;
respondToPermission(sessionId: string, permissionId: string, response: string, remember?: boolean): Promise<unknown>;
}
@@ -0,0 +1,26 @@
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application.js';
import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler.js';
import { RpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory.js';
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
import {
GitZoneOpenCodeServer,
gitZoneOpenCodePath,
type IGitZoneOpenCodeClient,
type IGitZoneOpenCodeServer,
} from '../common/gitzone-opencode-protocol.js';
import { GitZoneOpenCodeNodeService } from './gitzone-opencode-node-service.js';
export default new ContainerModule((bind) => {
bind(GitZoneOpenCodeNodeService).toSelf().inSingletonScope();
bind(GitZoneOpenCodeServer).toService(GitZoneOpenCodeNodeService);
bind(BackendApplicationContribution).toService(GitZoneOpenCodeNodeService);
bind(ConnectionHandler)
.toDynamicValue((context) =>
new RpcConnectionHandler<IGitZoneOpenCodeClient>(gitZoneOpenCodePath, (client) => {
const server = context.container.get<IGitZoneOpenCodeServer>(GitZoneOpenCodeServer);
server.setClient(client);
return server;
}),
)
.inSingletonScope();
});
@@ -0,0 +1,179 @@
import { OpenCodeServerClient } from '@git.zone/ide-opencode-bridge';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application.js';
import { injectable } from '@theia/core/shared/inversify/index.js';
import type {
IGitZoneOpenCodeClient,
IGitZoneOpenCodeConnectionInfo,
IGitZoneOpenCodePromptBody,
IGitZoneOpenCodeServer,
} from '../common/gitzone-opencode-protocol.js';
import * as plugins from './plugins.js';
@injectable()
export class GitZoneOpenCodeNodeService implements IGitZoneOpenCodeServer, BackendApplicationContribution {
protected client: IGitZoneOpenCodeClient | undefined;
protected eventAbortController: AbortController | undefined;
protected openCodeProcess: plugins.childProcess.ChildProcess | undefined;
initialize(): void {
void this.ensureOpenCodeStarted();
}
onStop(): void {
this.eventAbortController?.abort();
if (this.openCodeProcess && this.openCodeProcess.exitCode === null) {
this.openCodeProcess.kill('SIGTERM');
}
}
setClient(client: IGitZoneOpenCodeClient | undefined): void {
this.client = client;
this.restartEventStream();
}
async getConnectionInfo(): Promise<IGitZoneOpenCodeConnectionInfo> {
return {
baseUrl: this.baseUrl,
port: this.port,
workspacePath: this.workspacePath,
autoStart: this.autoStart,
};
}
async health(): Promise<unknown> {
await this.ensureOpenCodeStarted();
return this.createClient().health();
}
async providers(): Promise<unknown> {
return this.createClient().providers();
}
async agents(): Promise<unknown> {
return this.createClient().agents();
}
async sessions(): Promise<unknown> {
return this.createClient().sessions();
}
async createSession(title?: string): Promise<unknown> {
return this.createClient().createSession(title ? { title } : {});
}
async messages(sessionId: string, limit?: number): Promise<unknown> {
return this.createClient().messages(sessionId, limit);
}
async prompt(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<unknown> {
return this.createClient().prompt(sessionId, body);
}
async promptAsync(sessionId: string, body: IGitZoneOpenCodePromptBody): Promise<void> {
await this.createClient().promptAsync(sessionId, body);
}
async command(sessionId: string, command: string, commandArguments = ''): Promise<unknown> {
return this.createClient().command(sessionId, { command, arguments: commandArguments });
}
async abort(sessionId: string): Promise<unknown> {
return this.createClient().abort(sessionId);
}
async diff(sessionId: string, messageId?: string): Promise<unknown> {
return this.createClient().diff(sessionId, messageId);
}
async todo(sessionId: string): Promise<unknown> {
return this.createClient().todo(sessionId);
}
async respondToPermission(
sessionId: string,
permissionId: string,
response: string,
remember?: boolean,
): Promise<unknown> {
return this.createClient().respondToPermission(sessionId, permissionId, { response, remember });
}
protected async ensureOpenCodeStarted(): Promise<void> {
try {
await this.createClient().health();
return;
} catch {
if (!this.autoStart || this.openCodeProcess) {
return;
}
}
this.openCodeProcess = plugins.childProcess.spawn(
'opencode',
['serve', '--hostname', '127.0.0.1', '--port', `${this.port}`],
{
cwd: this.workspacePath,
env: {
...process.env,
OPENCODE_SERVER_USERNAME: this.username,
OPENCODE_SERVER_PASSWORD: this.password,
},
shell: false,
stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true,
},
);
}
protected restartEventStream(): void {
this.eventAbortController?.abort();
if (!this.client) {
return;
}
const abortController = new AbortController();
this.eventAbortController = abortController;
void (async () => {
try {
await this.ensureOpenCodeStarted();
for await (const event of this.createClient().events(abortController.signal)) {
this.client?.onOpenCodeEvent(event);
}
} catch {
// The UI can explicitly call health() for detailed connection diagnostics.
}
})();
}
protected createClient() {
return new OpenCodeServerClient({
baseUrl: this.baseUrl,
username: this.username,
password: this.password,
});
}
protected get workspacePath() {
return process.env.GITZONE_IDE_WORKSPACE || process.cwd();
}
protected get port() {
const port = Number(process.env.GITZONE_IDE_OPENCODE_PORT || '4096');
return Number.isInteger(port) && port > 0 ? port : 4096;
}
protected get baseUrl() {
return `http://127.0.0.1:${this.port}`;
}
protected get username() {
return process.env.OPENCODE_SERVER_USERNAME || 'opencode';
}
protected get password() {
return process.env.OPENCODE_SERVER_PASSWORD || '';
}
protected get autoStart() {
return process.env.GITZONE_IDE_DISABLE_OPENCODE_AUTOSTART !== '1';
}
}
@@ -0,0 +1,3 @@
import * as childProcess from 'node:child_process';
export { childProcess };
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"verbatimModuleSyntax": false,
"rootDir": "src",
"outDir": "lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
@@ -0,0 +1,16 @@
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command.js';
import { MenuContribution, MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry.js';
import { MessageService } from '@theia/core/lib/common/message-service.js';
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
export declare const GitZoneWelcomeCommand: {
id: string;
label: string;
};
export declare class GitZoneProductContribution implements CommandContribution, MenuContribution {
protected readonly messages: MessageService;
registerCommands(registry: CommandRegistry): void;
registerMenus(menus: MenuModelRegistry): void;
}
declare const _default: ContainerModule;
export default _default;
//# sourceMappingURL=gitzone-product-frontend-module.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-product-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/gitzone-product-frontend-module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAsB,MAAM,uCAAuC,CAAC;AAE5F,eAAO,MAAM,qBAAqB;;;CAGjC,CAAC;AAEF,qBACa,0BAA2B,YAAW,mBAAmB,EAAE,gBAAgB;IAEtF,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,cAAc,CAAC;IAE7C,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAMjD,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAM9C;;AAED,wBAIG"}
@@ -0,0 +1,49 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneProductContribution = exports.GitZoneWelcomeCommand = void 0;
const common_menus_js_1 = require("@theia/core/lib/browser/common-menus.js");
const command_js_1 = require("@theia/core/lib/common/command.js");
const menu_model_registry_js_1 = require("@theia/core/lib/common/menu/menu-model-registry.js");
const message_service_js_1 = require("@theia/core/lib/common/message-service.js");
const index_js_1 = require("@theia/core/shared/inversify/index.js");
exports.GitZoneWelcomeCommand = {
id: 'gitzone.product.welcome',
label: 'Git.Zone: Welcome',
};
let GitZoneProductContribution = class GitZoneProductContribution {
messages;
registerCommands(registry) {
registry.registerCommand(exports.GitZoneWelcomeCommand, {
execute: () => this.messages.info('Git.Zone IDE is connected to a remote-first Theia workspace.'),
});
}
registerMenus(menus) {
menus.registerMenuAction(common_menus_js_1.CommonMenus.HELP, {
commandId: exports.GitZoneWelcomeCommand.id,
label: exports.GitZoneWelcomeCommand.label,
});
}
};
exports.GitZoneProductContribution = GitZoneProductContribution;
__decorate([
(0, index_js_1.inject)(message_service_js_1.MessageService),
__metadata("design:type", message_service_js_1.MessageService)
], GitZoneProductContribution.prototype, "messages", void 0);
exports.GitZoneProductContribution = GitZoneProductContribution = __decorate([
(0, index_js_1.injectable)()
], GitZoneProductContribution);
exports.default = new index_js_1.ContainerModule((bind) => {
bind(GitZoneProductContribution).toSelf().inSingletonScope();
bind(command_js_1.CommandContribution).toService(GitZoneProductContribution);
bind(menu_model_registry_js_1.MenuContribution).toService(GitZoneProductContribution);
});
//# sourceMappingURL=gitzone-product-frontend-module.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-product-frontend-module.js","sourceRoot":"","sources":["../../src/browser/gitzone-product-frontend-module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6EAAsE;AACtE,kEAAyF;AACzF,+FAAyG;AACzG,kFAA2E;AAC3E,oEAA4F;AAE/E,QAAA,qBAAqB,GAAG;IACnC,EAAE,EAAE,yBAAyB;IAC7B,KAAK,EAAE,mBAAmB;CAC3B,CAAC;AAGK,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAElB,QAAQ,CAAkB;IAE7C,gBAAgB,CAAC,QAAyB;QACxC,QAAQ,CAAC,eAAe,CAAC,6BAAqB,EAAE;YAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,8DAA8D,CAAC;SAClG,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAwB;QACpC,KAAK,CAAC,kBAAkB,CAAC,6BAAW,CAAC,IAAI,EAAE;YACzC,SAAS,EAAE,6BAAqB,CAAC,EAAE;YACnC,KAAK,EAAE,6BAAqB,CAAC,KAAK;SACnC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAhBY,gEAA0B;AAElB;IADlB,IAAA,iBAAM,EAAC,mCAAc,CAAC;8BACO,mCAAc;4DAAC;qCAFlC,0BAA0B;IADtC,IAAA,qBAAU,GAAE;GACA,0BAA0B,CAgBtC;AAED,kBAAe,IAAI,0BAAe,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1C,IAAI,CAAC,0BAA0B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC7D,IAAI,CAAC,gCAAmB,CAAC,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;IAChE,IAAI,CAAC,yCAAgB,CAAC,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
{
"name": "@git.zone/ide-extension-product",
"version": "0.1.0",
"private": true,
"keywords": ["theia-extension"],
"scripts": {
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@theia/core": "1.71.0"
},
"theiaExtensions": [
{
"frontend": "lib/browser/gitzone-product-frontend-module"
}
],
"files": ["src", "lib"]
}
@@ -0,0 +1,35 @@
import { CommonMenus } from '@theia/core/lib/browser/common-menus.js';
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command.js';
import { MenuContribution, MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry.js';
import { MessageService } from '@theia/core/lib/common/message-service.js';
import { ContainerModule, inject, injectable } from '@theia/core/shared/inversify/index.js';
export const GitZoneWelcomeCommand = {
id: 'gitzone.product.welcome',
label: 'Git.Zone: Welcome',
};
@injectable()
export class GitZoneProductContribution implements CommandContribution, MenuContribution {
@inject(MessageService)
protected readonly messages!: MessageService;
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(GitZoneWelcomeCommand, {
execute: () => this.messages.info('Git.Zone IDE is connected to a remote-first Theia workspace.'),
});
}
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.HELP, {
commandId: GitZoneWelcomeCommand.id,
label: GitZoneWelcomeCommand.label,
});
}
}
export default new ContainerModule((bind) => {
bind(GitZoneProductContribution).toSelf().inSingletonScope();
bind(CommandContribution).toService(GitZoneProductContribution);
bind(MenuContribution).toService(GitZoneProductContribution);
});
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"verbatimModuleSyntax": false,
"rootDir": "src",
"outDir": "lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
@@ -0,0 +1,18 @@
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command.js';
import { MenuContribution, MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry.js';
import { MessageService } from '@theia/core/lib/common/message-service.js';
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
import { type IGitZoneRemoteServer } from '../common/gitzone-remote-protocol.js';
export declare const GitZoneRemoteEnvironmentCommand: {
id: string;
label: string;
};
export declare class GitZoneRemoteContribution implements CommandContribution, MenuContribution {
protected readonly remoteServer: IGitZoneRemoteServer;
protected readonly messages: MessageService;
registerCommands(registry: CommandRegistry): void;
registerMenus(menus: MenuModelRegistry): void;
}
declare const _default: ContainerModule;
export default _default;
//# sourceMappingURL=gitzone-remote-frontend-module.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/gitzone-remote-frontend-module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAsB,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAC;AAE9C,eAAO,MAAM,+BAA+B;;;CAG3C,CAAC;AAEF,qBACa,yBAA0B,YAAW,mBAAmB,EAAE,gBAAgB;IAErF,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAG,oBAAoB,CAAC;IAGvD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAG,cAAc,CAAC;IAE7C,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IASjD,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAM9C;;AAED,wBAWG"}
@@ -0,0 +1,64 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneRemoteContribution = exports.GitZoneRemoteEnvironmentCommand = void 0;
const ws_connection_provider_js_1 = require("@theia/core/lib/browser/messaging/ws-connection-provider.js");
const common_menus_js_1 = require("@theia/core/lib/browser/common-menus.js");
const command_js_1 = require("@theia/core/lib/common/command.js");
const menu_model_registry_js_1 = require("@theia/core/lib/common/menu/menu-model-registry.js");
const message_service_js_1 = require("@theia/core/lib/common/message-service.js");
const index_js_1 = require("@theia/core/shared/inversify/index.js");
const gitzone_remote_protocol_js_1 = require("../common/gitzone-remote-protocol.js");
exports.GitZoneRemoteEnvironmentCommand = {
id: 'gitzone.remote.environment',
label: 'Git.Zone: Show Remote Environment',
};
let GitZoneRemoteContribution = class GitZoneRemoteContribution {
remoteServer;
messages;
registerCommands(registry) {
registry.registerCommand(exports.GitZoneRemoteEnvironmentCommand, {
execute: async () => {
const environment = await this.remoteServer.getEnvironment();
await this.messages.info(`Remote workspace: ${environment.workspacePath}`);
},
});
}
registerMenus(menus) {
menus.registerMenuAction(common_menus_js_1.CommonMenus.FILE_OPEN, {
commandId: exports.GitZoneRemoteEnvironmentCommand.id,
label: exports.GitZoneRemoteEnvironmentCommand.label,
});
}
};
exports.GitZoneRemoteContribution = GitZoneRemoteContribution;
__decorate([
(0, index_js_1.inject)(gitzone_remote_protocol_js_1.GitZoneRemoteServer),
__metadata("design:type", Object)
], GitZoneRemoteContribution.prototype, "remoteServer", void 0);
__decorate([
(0, index_js_1.inject)(message_service_js_1.MessageService),
__metadata("design:type", message_service_js_1.MessageService)
], GitZoneRemoteContribution.prototype, "messages", void 0);
exports.GitZoneRemoteContribution = GitZoneRemoteContribution = __decorate([
(0, index_js_1.injectable)()
], GitZoneRemoteContribution);
exports.default = new index_js_1.ContainerModule((bind) => {
bind(gitzone_remote_protocol_js_1.GitZoneRemoteServer)
.toDynamicValue((context) => context.container
.get(ws_connection_provider_js_1.WebSocketConnectionProvider)
.createProxy(gitzone_remote_protocol_js_1.gitZoneRemotePath))
.inSingletonScope();
bind(GitZoneRemoteContribution).toSelf().inSingletonScope();
bind(command_js_1.CommandContribution).toService(GitZoneRemoteContribution);
bind(menu_model_registry_js_1.MenuContribution).toService(GitZoneRemoteContribution);
});
//# sourceMappingURL=gitzone-remote-frontend-module.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-frontend-module.js","sourceRoot":"","sources":["../../src/browser/gitzone-remote-frontend-module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2GAA0G;AAC1G,6EAAsE;AACtE,kEAAyF;AACzF,+FAAyG;AACzG,kFAA2E;AAC3E,oEAA4F;AAC5F,qFAI8C;AAEjC,QAAA,+BAA+B,GAAG;IAC7C,EAAE,EAAE,4BAA4B;IAChC,KAAK,EAAE,mCAAmC;CAC3C,CAAC;AAGK,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAEjB,YAAY,CAAwB;IAGpC,QAAQ,CAAkB;IAE7C,gBAAgB,CAAC,QAAyB;QACxC,QAAQ,CAAC,e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are const GitZoneRemoteServer: unique symbol;
export interface IGitZoneRemoteEnvironment {
workspacePath: string;
processId: number;
opencodePort?: number;
theiaPort?: number;
serverVersion?: string;
}
export interface IGitZoneRemoteServer {
getEnvironment(): Promise<IGitZoneRemoteEnvironment>;
}
//# sourceMappingURL=gitzone-remote-protocol.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-protocol.d.ts","sourceRoot":"","sources":["../../src/common/gitzone-remote-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACtD"}
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneRemoteServer = exports.gitZoneRemotePath = void 0;
exports.gitZoneRemotePath = '/services/git-zone/remote';
exports.GitZoneRemoteServer = Symbol('GitZoneRemoteServer');
//# sourceMappingURL=gitzone-remote-protocol.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-protocol.js","sourceRoot":"","sources":["../../src/common/gitzone-remote-protocol.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,2BAA2B,CAAC;AAEhD,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
declare const _default: ContainerModule;
export default _default;
//# sourceMappingURL=gitzone-remote-backend-module.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-backend-module.d.ts","sourceRoot":"","sources":["../../src/node/gitzone-remote-backend-module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;;AAQxE,wBAUG"}
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const handler_js_1 = require("@theia/core/lib/common/messaging/handler.js");
const proxy_factory_js_1 = require("@theia/core/lib/common/messaging/proxy-factory.js");
const index_js_1 = require("@theia/core/shared/inversify/index.js");
const gitzone_remote_protocol_js_1 = require("../common/gitzone-remote-protocol.js");
const gitzone_remote_node_service_js_1 = require("./gitzone-remote-node-service.js");
exports.default = new index_js_1.ContainerModule((bind) => {
bind(gitzone_remote_node_service_js_1.GitZoneRemoteNodeService).toSelf().inSingletonScope();
bind(gitzone_remote_protocol_js_1.GitZoneRemoteServer).toService(gitzone_remote_node_service_js_1.GitZoneRemoteNodeService);
bind(handler_js_1.ConnectionHandler)
.toDynamicValue((context) => new proxy_factory_js_1.RpcConnectionHandler(gitzone_remote_protocol_js_1.gitZoneRemotePath, () => context.container.get(gitzone_remote_protocol_js_1.GitZoneRemoteServer)))
.inSingletonScope();
});
//# sourceMappingURL=gitzone-remote-backend-module.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-backend-module.js","sourceRoot":"","sources":["../../src/node/gitzone-remote-backend-module.ts"],"names":[],"mappings":";;AAAA,4EAAgF;AAChF,wFAAyF;AACzF,oEAAwE;AACxE,qFAI8C;AAC9C,qFAA4E;AAE5E,kBAAe,IAAI,0BAAe,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1C,IAAI,CAAC,yDAAwB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC3D,IAAI,CAAC,gDAAmB,CAAC,CAAC,SAAS,CAAC,yDAAwB,CAAC,CAAC;IAC9D,IAAI,CAAC,8BAAiB,CAAC;SACpB,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE,CAC1B,IAAI,uCAAoB,CAAQ,8CAAiB,EAAE,GAAG,EAAE,CACtD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAuB,gDAAmB,CAAC,CACjE,CACF;SACA,gBAAgB,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
import type { IGitZoneRemoteEnvironment, IGitZoneRemoteServer } from '../common/gitzone-remote-protocol.js';
export declare class GitZoneRemoteNodeService implements IGitZoneRemoteServer {
getEnvironment(): Promise<IGitZoneRemoteEnvironment>;
}
//# sourceMappingURL=gitzone-remote-node-service.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-node-service.d.ts","sourceRoot":"","sources":["../../src/node/gitzone-remote-node-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5G,qBACa,wBAAyB,YAAW,oBAAoB;IAC7D,cAAc,IAAI,OAAO,CAAC,yBAAyB,CAAC;CAS3D"}
@@ -0,0 +1,33 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GitZoneRemoteNodeService = void 0;
const index_js_1 = require("@theia/core/shared/inversify/index.js");
let GitZoneRemoteNodeService = class GitZoneRemoteNodeService {
async getEnvironment() {
return {
workspacePath: process.env.GITZONE_IDE_WORKSPACE || process.cwd(),
processId: process.pid,
opencodePort: parseOptionalPort(process.env.GITZONE_IDE_OPENCODE_PORT),
theiaPort: parseOptionalPort(process.env.THEIA_PORT),
serverVersion: process.env.GITZONE_IDE_SERVER_VERSION,
};
}
};
exports.GitZoneRemoteNodeService = GitZoneRemoteNodeService;
exports.GitZoneRemoteNodeService = GitZoneRemoteNodeService = __decorate([
(0, index_js_1.injectable)()
], GitZoneRemoteNodeService);
const parseOptionalPort = (value) => {
if (!value) {
return undefined;
}
const port = Number(value);
return Number.isInteger(port) && port > 0 ? port : undefined;
};
//# sourceMappingURL=gitzone-remote-node-service.js.map
@@ -0,0 +1 @@
{"version":3,"file":"gitzone-remote-node-service.js","sourceRoot":"","sources":["../../src/node/gitzone-remote-node-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oEAAmE;AAI5D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACnC,KAAK,CAAC,cAAc;QAClB,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,GAAG,EAAE;YACjE,SAAS,EAAE,OAAO,CAAC,GAAG;YACtB,YAAY,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;YACtE,SAAS,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;YACpD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B;SACtD,CAAC;IACJ,CAAC;CACF,CAAA;AAVY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,qBAAU,GAAE;GACA,wBAAwB,CAUpC;AAED,MAAM,iBAAiB,GAAG,CAAC,KAAyB,EAAE,EAAE;IACtD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC,CAAC"}
@@ -0,0 +1,20 @@
{
"name": "@git.zone/ide-extension-remote",
"version": "0.1.0",
"private": true,
"keywords": ["theia-extension"],
"scripts": {
"build": "tsc -p tsconfig.json"
},
"dependencies": {
"@git.zone/ide-protocol": "workspace:*",
"@theia/core": "1.71.0"
},
"theiaExtensions": [
{
"frontend": "lib/browser/gitzone-remote-frontend-module",
"backend": "lib/node/gitzone-remote-backend-module"
}
],
"files": ["src", "lib"]
}
@@ -0,0 +1,54 @@
import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider.js';
import { CommonMenus } from '@theia/core/lib/browser/common-menus.js';
import { CommandContribution, CommandRegistry } from '@theia/core/lib/common/command.js';
import { MenuContribution, MenuModelRegistry } from '@theia/core/lib/common/menu/menu-model-registry.js';
import { MessageService } from '@theia/core/lib/common/message-service.js';
import { ContainerModule, inject, injectable } from '@theia/core/shared/inversify/index.js';
import {
GitZoneRemoteServer,
gitZoneRemotePath,
type IGitZoneRemoteServer,
} from '../common/gitzone-remote-protocol.js';
export const GitZoneRemoteEnvironmentCommand = {
id: 'gitzone.remote.environment',
label: 'Git.Zone: Show Remote Environment',
};
@injectable()
export class GitZoneRemoteContribution implements CommandContribution, MenuContribution {
@inject(GitZoneRemoteServer)
protected readonly remoteServer!: IGitZoneRemoteServer;
@inject(MessageService)
protected readonly messages!: MessageService;
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(GitZoneRemoteEnvironmentCommand, {
execute: async () => {
const environment = await this.remoteServer.getEnvironment();
await this.messages.info(`Remote workspace: ${environment.workspacePath}`);
},
});
}
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.FILE_OPEN, {
commandId: GitZoneRemoteEnvironmentCommand.id,
label: GitZoneRemoteEnvironmentCommand.label,
});
}
}
export default new ContainerModule((bind) => {
bind(GitZoneRemoteServer)
.toDynamicValue((context) =>
context.container
.get(WebSocketConnectionProvider)
.createProxy<IGitZoneRemoteServer>(gitZoneRemotePath),
)
.inSingletonScope();
bind(GitZoneRemoteContribution).toSelf().inSingletonScope();
bind(CommandContribution).toService(GitZoneRemoteContribution);
bind(MenuContribution).toService(GitZoneRemoteContribution);
});
@@ -0,0 +1,15 @@
export const gitZoneRemotePath = '/services/git-zone/remote';
export const GitZoneRemoteServer = Symbol('GitZoneRemoteServer');
export interface IGitZoneRemoteEnvironment {
workspacePath: string;
processId: number;
opencodePort?: number;
theiaPort?: number;
serverVersion?: string;
}
export interface IGitZoneRemoteServer {
getEnvironment(): Promise<IGitZoneRemoteEnvironment>;
}
@@ -0,0 +1,21 @@
import { ConnectionHandler } from '@theia/core/lib/common/messaging/handler.js';
import { RpcConnectionHandler } from '@theia/core/lib/common/messaging/proxy-factory.js';
import { ContainerModule } from '@theia/core/shared/inversify/index.js';
import {
GitZoneRemoteServer,
gitZoneRemotePath,
type IGitZoneRemoteServer,
} from '../common/gitzone-remote-protocol.js';
import { GitZoneRemoteNodeService } from './gitzone-remote-node-service.js';
export default new ContainerModule((bind) => {
bind(GitZoneRemoteNodeService).toSelf().inSingletonScope();
bind(GitZoneRemoteServer).toService(GitZoneRemoteNodeService);
bind(ConnectionHandler)
.toDynamicValue((context) =>
new RpcConnectionHandler<never>(gitZoneRemotePath, () =>
context.container.get<IGitZoneRemoteServer>(GitZoneRemoteServer),
),
)
.inSingletonScope();
});
@@ -0,0 +1,23 @@
import { injectable } from '@theia/core/shared/inversify/index.js';
import type { IGitZoneRemoteEnvironment, IGitZoneRemoteServer } from '../common/gitzone-remote-protocol.js';
@injectable()
export class GitZoneRemoteNodeService implements IGitZoneRemoteServer {
async getEnvironment(): Promise<IGitZoneRemoteEnvironment> {
return {
workspacePath: process.env.GITZONE_IDE_WORKSPACE || process.cwd(),
processId: process.pid,
opencodePort: parseOptionalPort(process.env.GITZONE_IDE_OPENCODE_PORT),
theiaPort: parseOptionalPort(process.env.THEIA_PORT),
serverVersion: process.env.GITZONE_IDE_SERVER_VERSION,
};
}
}
const parseOptionalPort = (value: string | undefined) => {
if (!value) {
return undefined;
}
const port = Number(value);
return Number.isInteger(port) && port > 0 ? port : undefined;
};
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"verbatimModuleSyntax": false,
"rootDir": "src",
"outDir": "lib",
"declaration": true,
"declarationMap": true,
"sourceMap": true
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}