adpa-enterprise-framework-automation
Version:
Modular, standards-compliant Node.js/TypeScript automation framework for enterprise requirements, project, and data management. Provides CLI and API for BABOK v3, PMBOK 7th Edition, and DMBOK 2.0 (in progress). Production-ready Express.js API with TypeSpe
313 lines (287 loc) ⢠14.6 kB
JavaScript
/**
* Stakeholder Analysis Commands
* Automated stakeholder analysis commands for Requirements Gathering Agent
*
* @version 1.0.0
* @author Requirements Gathering Agent Team
* @created 2025-01-27
*
* @filepath src/commands/stakeholder.ts
*/
import { promises as fs } from 'fs';
import { join } from 'path';
import { StakeholderProcessor } from '../modules/ai/processors/StakeholderProcessor.js';
import { analyzeProjectComprehensively } from '../modules/projectAnalyzer.js';
import { DEFAULT_OUTPUT_DIR } from '../constants.js';
/**
* Generate comprehensive stakeholder analysis
*/
export async function handleStakeholderAnalysisCommand(options = {}) {
console.log('šÆ Generating automated stakeholder analysis...');
try {
const outputDir = options.outputDir || DEFAULT_OUTPUT_DIR;
const analysisDepth = options.analysisDepth || 'comprehensive';
// Analyze project context
const projectAnalysis = await analyzeProjectComprehensively(process.cwd());
const projectContext = JSON.stringify(projectAnalysis, null, 2);
const processor = new StakeholderProcessor();
// Generate stakeholder analysis
console.log('š Generating stakeholder analysis...');
const stakeholderAnalysis = await processor.getStakeholderAnalysis(projectContext);
if (!stakeholderAnalysis) {
throw new Error('Failed to generate stakeholder analysis');
}
const analysisFileName = `stakeholder-analysis-${Date.now()}.md`;
const analysisFilePath = join(outputDir, analysisFileName);
await fs.mkdir(outputDir, { recursive: true });
await fs.writeFile(analysisFilePath, stakeholderAnalysis, 'utf8');
console.log(`ā
Stakeholder analysis generated: ${analysisFilePath}`);
// Generate stakeholder register if requested
if (options.includeRegister !== false) {
console.log('š Generating stakeholder register...');
const stakeholderRegister = await processor.getStakeholderRegister(projectContext);
if (stakeholderRegister) {
const registerFileName = `stakeholder-register-${Date.now()}.md`;
const registerFilePath = join(outputDir, registerFileName);
await fs.writeFile(registerFilePath, stakeholderRegister, 'utf8');
console.log(`ā
Stakeholder register generated: ${registerFilePath}`);
}
}
// Generate engagement plan if requested
if (options.includeEngagementPlan) {
console.log('š¤ Generating stakeholder engagement plan...');
const engagementPlan = await processor.getStakeholderEngagementPlan(projectContext);
if (engagementPlan) {
const planFileName = `stakeholder-engagement-plan-${Date.now()}.md`;
const planFilePath = join(outputDir, planFileName);
await fs.writeFile(planFilePath, engagementPlan, 'utf8');
console.log(`ā
Stakeholder engagement plan generated: ${planFilePath}`);
}
}
if (options.verbose) {
console.log('\nš Analysis Preview:');
console.log(stakeholderAnalysis.substring(0, 500) + '...');
}
console.log('\nš Stakeholder analysis automation completed successfully!');
console.log(`š Output directory: ${outputDir}`);
}
catch (error) {
console.error('ā Failed to generate stakeholder analysis:', error);
process.exit(1);
}
}
/**
* Generate stakeholder register only
*/
export async function handleStakeholderRegisterCommand(options = {}) {
console.log('š Generating stakeholder register...');
try {
const outputDir = options.outputDir || DEFAULT_OUTPUT_DIR;
// Analyze project context
const projectAnalysis = await analyzeProjectComprehensively(process.cwd());
const projectContext = JSON.stringify(projectAnalysis, null, 2);
const processor = new StakeholderProcessor();
const stakeholderRegister = await processor.getStakeholderRegister(projectContext);
if (!stakeholderRegister) {
throw new Error('Failed to generate stakeholder register');
}
const fileName = `stakeholder-register-${Date.now()}.md`;
const filePath = join(outputDir, fileName);
await fs.mkdir(outputDir, { recursive: true });
await fs.writeFile(filePath, stakeholderRegister, 'utf8');
console.log(`ā
Stakeholder register generated: ${filePath}`);
if (options.verbose) {
console.log('\nš Preview:');
console.log(stakeholderRegister.substring(0, 500) + '...');
}
}
catch (error) {
console.error('ā Failed to generate stakeholder register:', error);
process.exit(1);
}
}
/**
* Generate stakeholder engagement plan
*/
export async function handleStakeholderEngagementPlanCommand(options = {}) {
console.log('š¤ Generating stakeholder engagement plan...');
try {
const outputDir = options.outputDir || DEFAULT_OUTPUT_DIR;
// Analyze project context
const projectAnalysis = await analyzeProjectComprehensively(process.cwd());
const projectContext = JSON.stringify(projectAnalysis, null, 2);
const processor = new StakeholderProcessor();
const engagementPlan = await processor.getStakeholderEngagementPlan(projectContext);
if (!engagementPlan) {
throw new Error('Failed to generate stakeholder engagement plan');
}
const fileName = `stakeholder-engagement-plan-${Date.now()}.md`;
const filePath = join(outputDir, fileName);
await fs.mkdir(outputDir, { recursive: true });
await fs.writeFile(filePath, engagementPlan, 'utf8');
console.log(`ā
Stakeholder engagement plan generated: ${filePath}`);
if (options.verbose) {
console.log('\nš Preview:');
console.log(engagementPlan.substring(0, 500) + '...');
}
}
catch (error) {
console.error('ā Failed to generate stakeholder engagement plan:', error);
process.exit(1);
}
}
/**
* Generate all stakeholder documents (comprehensive automation)
*/
export async function handleStakeholderAutomationCommand(options = {}) {
console.log('š Running comprehensive stakeholder analysis automation...');
try {
const outputDir = options.outputDir || DEFAULT_OUTPUT_DIR;
// Analyze project context
const projectAnalysis = await analyzeProjectComprehensively(process.cwd());
const projectContext = JSON.stringify(projectAnalysis, null, 2);
const processor = new StakeholderProcessor();
// Use the new comprehensive package method for better efficiency and consistency
console.log('š¦ Generating comprehensive stakeholder package...');
const stakeholderPackage = await processor.generateComprehensiveStakeholderPackage(projectContext);
// Also generate automated stakeholder identification
console.log('š Generating automated stakeholder identification...');
const stakeholderIdentification = await processor.generateAutomatedStakeholderIdentification(projectContext);
await fs.mkdir(outputDir, { recursive: true });
const timestamp = Date.now();
const documents = [
{ content: stakeholderPackage.analysis, filename: `stakeholder-analysis-${timestamp}.md`, name: 'Stakeholder Analysis' },
{ content: stakeholderPackage.register, filename: `stakeholder-register-${timestamp}.md`, name: 'Stakeholder Register' },
{ content: stakeholderPackage.engagementPlan, filename: `stakeholder-engagement-plan-${timestamp}.md`, name: 'Stakeholder Engagement Plan' },
{ content: stakeholderIdentification, filename: `stakeholder-identification-${timestamp}.md`, name: 'Stakeholder Identification' }
];
const generatedFiles = [];
for (const doc of documents) {
if (doc.content) {
const filePath = join(outputDir, doc.filename);
await fs.writeFile(filePath, doc.content, 'utf8');
generatedFiles.push(filePath);
console.log(`ā
${doc.name} generated: ${filePath}`);
}
else {
console.warn(`ā ļø Failed to generate ${doc.name}`);
}
}
// Generate enhanced summary report
const summaryReport = generateStakeholderAutomationSummary(generatedFiles, projectAnalysis);
const summaryFilePath = join(outputDir, `stakeholder-automation-summary-${timestamp}.md`);
await fs.writeFile(summaryFilePath, summaryReport, 'utf8');
console.log('\nš Comprehensive stakeholder analysis automation completed!');
console.log(`š Output directory: ${outputDir}`);
console.log(`š Generated ${generatedFiles.length} stakeholder documents`);
console.log(`š Summary report: ${summaryFilePath}`);
console.log('\nš Generated Documents:');
generatedFiles.forEach((file, index) => {
console.log(` ${index + 1}. ${file.split('/').pop()}`);
});
if (options.verbose && stakeholderPackage.analysis) {
console.log('\nš Analysis Preview:');
console.log(stakeholderPackage.analysis.substring(0, 500) + '...');
}
}
catch (error) {
console.error('ā Failed to run stakeholder automation:', error);
process.exit(1);
}
}
/**
* Generate a summary report for stakeholder automation
*/
function generateStakeholderAutomationSummary(generatedFiles, projectAnalysis) {
const currentDate = new Date().toISOString();
return `# Stakeholder Analysis Automation Summary
**Generated by:** ADPA (Automated Documentation Project Assistant)
**Category:** stakeholder-management
**Generated:** ${currentDate}
**Project:** ${projectAnalysis.projectName || 'Untitled Project'}
**PMBOK Reference:** 13.0 Project Stakeholder Management
---
## Automation Overview
This report summarizes the automated stakeholder analysis process that was executed for the project. The automation follows PMBOK 7th Edition standards for stakeholder management.
## Generated Documents
${generatedFiles.map((file, index) => `${index + 1}. \`${file.split('/').pop()}\``).join('\n')}
## PMBOK Compliance
The generated stakeholder documents comply with the following PMBOK standards:
### 13.1 Identify Stakeholders
- ā
Stakeholder Register generated with comprehensive stakeholder identification
- ā
Power/Interest grid analysis included
- ā
Stakeholder classification by influence and impact
### 13.2 Plan Stakeholder Engagement
- ā
Stakeholder Engagement Plan generated
- ā
Current and desired engagement levels defined
- ā
Communication requirements specified
### 13.3 Manage Stakeholder Engagement
- ā
Engagement strategies defined for different stakeholder groups
- ā
Communication methods and frequency specified
### 13.4 Monitor Stakeholder Engagement
- ā
Monitoring and review processes included
- ā
Stakeholder satisfaction tracking framework provided
## Project Context Analysis
- **Project Type:** ${projectAnalysis.projectType || 'Not specified'}
- **Stakeholders Identified:** Automated analysis based on project context and user personas
- **Analysis Depth:** Comprehensive PMBOK-compliant analysis
- **Documentation Standard:** PMBOK 7th Edition
## Next Steps
1. **Review Generated Documents:** Validate the automated stakeholder analysis against organizational knowledge
2. **Complete Organizational Data:** Fill in specific contact information and organizational details
3. **Stakeholder Validation:** Conduct stakeholder interviews to validate the analysis
4. **Engagement Implementation:** Begin implementing the stakeholder engagement strategies
5. **Regular Updates:** Update stakeholder documents throughout the project lifecycle
## Quality Assurance
- ā
PMBOK 7th Edition compliance verified
- ā
Cross-document consistency maintained
- ā
Professional documentation standards applied
- ā
Automated validation completed
---
*This summary was generated as part of the automated stakeholder analysis process. Please review all generated documents and customize them based on your specific organizational context and project requirements.*`;
}
/**
* Display help for Stakeholder Analysis commands
*/
export function displayStakeholderHelp() {
console.log(`
šÆ Stakeholder Analysis Automation Commands
Core Commands:
analysis Generate comprehensive stakeholder analysis
register Generate stakeholder register only
engagement-plan Generate stakeholder engagement plan only
automate Generate all stakeholder documents (comprehensive)
help Show stakeholder analysis help
Options:
--output-dir <dir> Output directory (default: generated-documents)
--format <format> Output format: markdown, json (default: markdown)
--verbose Show detailed output and previews
--include-register Include stakeholder register (default: true)
--include-engagement-plan Include engagement plan (default: false)
--analysis-depth <depth> Analysis depth: basic, detailed, comprehensive (default: comprehensive)
Stakeholder Features:
ā
Automated stakeholder identification from project context
ā
Power/Interest grid analysis
ā
Stakeholder register generation
ā
Stakeholder engagement plan generation
ā
Comprehensive stakeholder analysis (basic, detailed, comprehensive)
ā
PMBOK-compliant documentation structure
ā
Cross-document consistency and integration
ā
Professional formatting and organization
ā
Customizable output format (markdown, json)
ā
Verbose output and previews
Examples:
rga stakeholder analysis --verbose
rga stakeholder register --output-dir ./stakeholders
rga stakeholder engagement-plan --verbose
rga stakeholder automate --include-engagement-plan --verbose
PMBOK Compliance:
All generated documents follow PMBOK 7th Edition standards for:
- 13.1 Identify Stakeholders
- 13.2 Plan Stakeholder Engagement
- 13.3 Manage Stakeholder Engagement
- 13.4 Monitor Stakeholder Engagement
For more details, use 'rga stakeholder help' or see the documentation.
`);
}
//# sourceMappingURL=stakeholder.js.map