diff --git a/scripts/AfterInstall.php b/scripts/AfterInstall.php index 41e33ab..11d2086 100644 --- a/scripts/AfterInstall.php +++ b/scripts/AfterInstall.php @@ -2,9 +2,11 @@ /************************************************************************ * LegalAssistance Extension — AfterInstall * - * 1. Deploy plugin files to ai-gateway plugins/ directory - * 2. Create DocumentTemplate for the direct access report - * 3. Clear cache + * 1. Create DocumentTemplate for the direct access report + * 2. Clear cache + * + * Note: ai-gateway plugin deployment removed — legal tools are now + * built into shira-hermes (api/services/legal_tools.py) since Phase 3. ************************************************************************/ use Espo\Core\Container; @@ -28,13 +30,10 @@ class AfterInstall $config = $container->getByClass(Config::class); $this->ensureI18nDirectories($config, $log); - // 1. Deploy ai-gateway plugin files - $this->deployPluginFiles($log); - - // 2. Create DocumentTemplate + // 1. Create DocumentTemplate $this->createDocumentTemplate($entityManager, $log); - // 3. Clear cache + // 2. Clear cache try { $dataManager = $container->getByClass(DataManager::class); $dataManager->clearCache(); @@ -67,52 +66,6 @@ class AfterInstall } } - private function deployPluginFiles(Log $log): void - { - // Source: extension's plugins/ directory (relative to EspoCRM root after install) - $sourceDir = 'custom/Espo/Modules/LegalAssistance/../../../../../../plugins/legal-assistance'; - - // Try common ai-gateway locations - $gatewayPaths = [ - '/home/chaim/ai-gateway/plugins/legal-assistance', - '/opt/ai-gateway/plugins/legal-assistance', - ]; - - // Find actual source files within the extension package - $extPluginDir = __DIR__ . '/../plugins/legal-assistance'; - - if (!is_dir($extPluginDir)) { - $log->warning("LegalAssistance: Plugin source directory not found at {$extPluginDir}"); - return; - } - - foreach ($gatewayPaths as $targetDir) { - $parentDir = dirname($targetDir); - if (!is_dir($parentDir)) { - continue; - } - - if (!is_dir($targetDir)) { - mkdir($targetDir, 0755, true); - } - - $files = ['tools.json', 'prompts.json']; - foreach ($files as $file) { - $src = $extPluginDir . '/' . $file; - $dst = $targetDir . '/' . $file; - if (file_exists($src)) { - copy($src, $dst); - $log->info("LegalAssistance: Deployed {$file} to {$targetDir}"); - } - } - - $log->info("LegalAssistance: Plugin files deployed to {$targetDir}"); - return; - } - - $log->warning('LegalAssistance: Could not find ai-gateway plugins directory. Deploy manually.'); - } - private function createDocumentTemplate(EntityManager $entityManager, Log $log): void { // Check if template already exists diff --git a/scripts/AfterUninstall.php b/scripts/AfterUninstall.php index 3a739b6..ae8c75e 100644 --- a/scripts/AfterUninstall.php +++ b/scripts/AfterUninstall.php @@ -2,11 +2,13 @@ /************************************************************************ * LegalAssistance Extension — AfterUninstall * - * 1. Remove plugin files from ai-gateway - * 2. Drop LegalAid and DirectAccessReport DB tables (with warning log) - * 3. Remove LegalAssistance-specific columns from Case table - * 4. Remove DocumentTemplate records created by this extension - * 5. Clear cache + * 1. Drop LegalAid and DirectAccessReport DB tables (with warning log) + * 2. Remove LegalAssistance-specific columns from Case table + * 3. Remove DocumentTemplate records created by this extension + * 4. Clear cache + * + * Note: ai-gateway plugin cleanup removed — legal tools are now + * built into shira-hermes since Phase 3. ************************************************************************/ use Espo\Core\Container; @@ -25,22 +27,19 @@ class AfterUninstall $log->info('LegalAssistance: Running AfterUninstall...'); - // 1. Remove ai-gateway plugin files - $this->removePluginFiles($log); - - // 2. Drop tables created by this extension + // 1. Drop tables created by this extension $this->dropTables($entityManager, $log); - // 3. Remove LegalAssistance-specific columns from Case + // 2. Remove LegalAssistance-specific columns from Case $this->cleanCaseColumns($entityManager, $log); - // 4. Remove DocumentTemplate records + // 3. Remove DocumentTemplate records $this->removeDocumentTemplates($entityManager, $log); - // 5. Remove custom i18n files + // 4. Remove custom i18n files $this->removeCustomI18n($log); - // 6. Clear cache + // 5. Clear cache try { $dataManager = $container->getByClass(DataManager::class); $dataManager->clearCache(); @@ -52,27 +51,6 @@ class AfterUninstall $log->info('LegalAssistance: AfterUninstall completed.'); } - private function removePluginFiles(Log $log): void - { - $gatewayPaths = [ - '/home/chaim/ai-gateway/plugins/legal-assistance', - '/opt/ai-gateway/plugins/legal-assistance', - ]; - - foreach ($gatewayPaths as $dir) { - if (is_dir($dir)) { - $files = glob($dir . '/*'); - foreach ($files as $file) { - if (is_file($file)) { - unlink($file); - } - } - rmdir($dir); - $log->info("LegalAssistance: Removed plugin files from {$dir}"); - } - } - } - private function dropTables(EntityManager $entityManager, Log $log): void { $pdo = $entityManager->getPDO();