diff --git a/shannon.mjs b/shannon.mjs index 4315256..419089b 100755 --- a/shannon.mjs +++ b/shannon.mjs @@ -13,7 +13,7 @@ import { runPhase, getGitCommitHash } from './src/checkpoint-manager.js'; // Setup and Deliverables import { setupLocalRepo, cleanupMCP } from './src/setup/environment.js'; -import { saveRunMetadata, savePermanentDeliverables } from './src/setup/deliverables.js'; +import { saveRunMetadata } from './src/setup/deliverables.js'; // AI and Prompts import { runClaudePromptWithRetry } from './src/ai/claude-executor.js'; @@ -350,19 +350,6 @@ async function main(webUrl, repoPath, configPath = null, pipelineTestingMode = f costBreakdown }); - // Save deliverables to permanent location in Documents - const permanentPath = await savePermanentDeliverables( - sourceDir, webUrl, repoPath, session, timingBreakdown, costBreakdown - ); - if (permanentPath) { - console.log(chalk.green(`📂 Deliverables permanently saved to: ${permanentPath}`)); - } - - // Keep files for manual review - console.log(chalk.blue(`📁 Files preserved for review at: ${sourceDir}`)); - console.log(chalk.gray(` Deliverables: ${sourceDir}/deliverables/`)); - console.log(chalk.gray(` Source code: ${sourceDir}/`)); - // Display comprehensive timing summary displayTimingSummary(); diff --git a/src/setup/deliverables.js b/src/setup/deliverables.js index c97ab32..96f0fb6 100644 --- a/src/setup/deliverables.js +++ b/src/setup/deliverables.js @@ -1,76 +1,7 @@ -import { fs, path, os } from 'zx'; +import { fs, path } from 'zx'; import chalk from 'chalk'; import { PentestError, logError } from '../error-handling.js'; -// Pure function: Save deliverables permanently to user directory -export async function savePermanentDeliverables(sourceDir, webUrl, repoPath, session, timingBreakdown, costBreakdown) { - try { - // Simple universal approach - try Documents, fallback to home - const homeDir = os.homedir(); - const documentsDir = path.join(homeDir, 'Documents'); - - // Use Documents if it exists, otherwise use home directory - const baseDir = await fs.pathExists(documentsDir) ? documentsDir : homeDir; - const permanentBaseDir = path.join(baseDir, 'pentest-deliverables'); - - // Generate directory name from repo path and web URL - const repoName = path.basename(repoPath); - const webDomain = new URL(webUrl).hostname.replace(/[^a-zA-Z0-9-]/g, '-'); - const timestamp = new Date().toISOString().replace(/[-:]/g, '').replace(/T/, '-').split('.')[0]; - const dirName = `${webDomain}_${repoName}_${timestamp}`; - const permanentDir = path.join(permanentBaseDir, dirName); - - // Ensure base directory exists - await fs.ensureDir(permanentBaseDir); - - // Create the specific pentest directory - await fs.ensureDir(permanentDir); - - // Copy deliverables folder if it exists - const deliverablesSource = path.join(sourceDir, 'deliverables'); - const deliverablesDest = path.join(permanentDir, 'deliverables'); - - if (await fs.pathExists(deliverablesSource)) { - await fs.copy(deliverablesSource, deliverablesDest, { overwrite: true }); - } - - // Save metadata with session information - const metadata = { - session: { - id: session.id, - webUrl, - repoPath, - configFile: session.configFile, - status: session.status, - completedAgents: session.completedAgents, - createdAt: session.createdAt, - completedAt: new Date().toISOString() - }, - timing: timingBreakdown, - cost: costBreakdown, - sourceDirectory: sourceDir, - savedAt: new Date().toISOString() - }; - - await fs.writeJSON(path.join(permanentDir, 'metadata.json'), metadata, { spaces: 2 }); - - // Copy prompts directory for reproducibility - const promptsSource = path.join(import.meta.dirname, '..', '..', 'prompts'); - const promptsDest = path.join(permanentDir, 'prompts'); - - if (await fs.pathExists(promptsSource)) { - await fs.copy(promptsSource, promptsDest, { overwrite: true }); - } - - console.log(chalk.green(`✅ Deliverables saved to permanent location: ${permanentDir}`)); - return permanentDir; - } catch (error) { - // Non-fatal error - log but don't throw - console.log(chalk.yellow(`⚠️ Failed to save permanent deliverables: ${error.message}`)); - return null; - } -} - // Pure function: Save run metadata for debugging and reproducibility export async function saveRunMetadata(sourceDir, webUrl, repoPath) { console.log(chalk.blue('💾 Saving run metadata...'));