phion
Version:
Phion Development Agent and Vite Plugin for seamless code sync and auto-deploy
120 lines (113 loc) • 3.1 kB
text/typescript
import { Plugin } from 'vite';
interface AgentConfig {
projectId: string;
wsUrl: string;
debug?: boolean;
toolbar?: {
enabled?: boolean;
position?: "top" | "bottom";
autoOpen?: boolean;
};
}
interface FileChange {
projectId: string;
filePath: string;
content: string;
hash: string;
timestamp: number;
}
interface FileDelete {
projectId: string;
filePath: string;
timestamp: number;
}
declare class PhionAgent {
private socket;
private watcher;
private envWatcher;
private httpServer;
private isConnected;
private isGitRepo;
private config;
private gitOperationCooldown;
constructor(config: AgentConfig);
start(): Promise<void>;
private startLocalServer;
private checkGitRepository;
private initializeGitRepository;
private connectWebSocket;
private setupEventHandlers;
private discardLocalChanges;
private gitPullWithToken;
private updateLocalFiles;
private startFileWatcher;
private startEnvWatcher;
private handleFileChange;
private handleFileDelete;
private handleEnvFileChange;
private handleEnvFileDelete;
private openPreviewIfEnabled;
stop(): void;
}
interface VersionInfo {
current: string;
latest?: string;
hasUpdate: boolean;
}
/**
* Получает текущую версию из package.json
*/
declare function getCurrentVersion(): string;
/**
* Выполняет полную проверку версии и возвращает информацию
*/
declare function checkForUpdates(wsUrl: string): Promise<VersionInfo>;
interface VSCodeConfig {
autoOpen: boolean;
port: number;
url?: string;
}
/**
* Detects if VS Code or Cursor is running
*/
declare function detectVSCode(): boolean;
/**
* Main function for opening preview
*/
declare function openPreview(config: VSCodeConfig, debug?: boolean): Promise<void>;
interface PhionConfig {
projectId: string;
wsUrl?: string;
debug?: boolean;
toolbar?: {
enabled?: boolean;
position?: "top" | "bottom";
autoOpen?: boolean;
autoUpdate?: boolean;
updateChannel?: "stable" | "beta" | "dev";
};
autoSync?: boolean;
autoStart?: "first" | "always" | "never";
}
interface PhionPluginOptions {
configPath?: string;
websocketUrl?: string;
toolbarUrl?: string;
debug?: boolean;
enabled?: boolean;
autoUpdateToolbar?: boolean;
autoUpdate?: boolean;
updateEndpoint?: string;
}
interface ToolbarVersion {
version: string;
url: string;
checksum?: string;
}
interface UpdateCheckResponse {
hasUpdate: boolean;
latestVersion?: ToolbarVersion;
currentVersion: string;
}
declare function phionPlugin(options?: PhionPluginOptions): Plugin;
export { type AgentConfig, type FileChange, type FileDelete, PhionAgent, type PhionConfig, type PhionPluginOptions, type ToolbarVersion, type UpdateCheckResponse, type VSCodeConfig, checkForUpdates, detectVSCode, getCurrentVersion, openPreview, phionPlugin as plugin };