Scripts Reference

PowerShell automation scripts for Portfolio OS development and operations

Scripts Reference

Portfolio OS includes a comprehensive suite of PowerShell automation scripts for development workflow, project management, and operations.

Note:

All scripts are located in the scripts/ directory and use PowerShell for cross-platform compatibility.

Script Categories

Quick Start

Prerequisites

RequirementPurpose
PowerShell 7+Script execution engine
GitHub CLI (gh)GitHub API operations
GitVersion control operations
Node.js & PNPMFor build operations

Basic Usage

# Navigate to scripts directory
cd scripts/category-name

# View help
Get-Help .\script-name.ps1 -Full

# Execute script
.\script-name.ps1 -Parameter Value

Common Workflows

1. Create and Manage PR

# Create PR automatically
.\pr-management\automate-pr-unified.ps1 `
  -Title "feat: add dark mode" `
  -Body "Implements dark mode toggle"

# Analyze PR quality
.\pr-management\pr-quality-checker.ps1 -PRNumber 123

# Monitor PR status
.\pr-management\pr-monitor.ps1

2. Multi-Agent Development

# Setup agent worktree
.\agent-management\setup-agent-development.ps1 -AgentName "agent-1"

# Start multi-agent workflow
.\agent-management\start-multi-agent-e2e-unified.ps1 `
  -NumAgents 2 `
  -Tasks "Implement feature A", "Implement feature B"

# Update agent status
.\agent-management\update-agent-status.ps1 -AgentName "agent-1" -Status "in-progress"

3. Documentation Updates

# Update docs for PR
.\core-utilities\docs-updater.ps1 `
  -PRNumber 123 `
  -UpdateChangelog `
  -GenerateDocs

# Generate full changelog
.\documentation\generate-full-changelog.ps1

4. Project Management

# Update project fields
.\project-management\manage-projects.ps1 `
  -Action update `
  -IssueNumber 123 `
  -Status "In Progress"

# Create release
.\project-management\create-release.ps1 -Version "1.2.0"

Script Directory Structure

scripts/
├── agent-management/         # Multi-agent development
│   ├── setup-agent-development.ps1
│   ├── manage-multi-agent-system.ps1
│   └── start-multi-agent-e2e-unified.ps1
├── pr-management/           # PR automation
│   ├── automate-pr-unified.ps1
│   ├── pr-quality-checker.ps1
│   └── pr-analyzer.ps1
├── issue-management/        # Issue automation
│   ├── management/
│   ├── analysis/
│   └── implementation/
├── core-utilities/          # Essential tools
│   ├── get-github-utilities.ps1
│   ├── docs-updater.ps1
│   └── manage-ai-services.ps1
├── project-management/      # Project operations
│   ├── manage-projects.ps1
│   ├── create-release.ps1
│   └── backfill-project-fields.ps1
├── monitoring/              # System monitoring
│   ├── real-time-dashboard.ps1
│   ├── performance-analyzer.ps1
│   └── automation-metrics.ps1
├── housekeeping/           # Maintenance
│   ├── clean-house-main.ps1
│   └── clean-folder-intelligent.ps1
└── branch-management/       # Git operations
    ├── create-branch-from-develop.ps1
    └── manage-branches.ps1

Configuration

Environment Variables

Scripts use these environment variables:

# GitHub token (required for API access)
$env:GITHUB_TOKEN = "ghp_..."

# OpenAI API key (for AI-powered features)
$env:OPENAI_API_KEY = "sk-..."

# Repository information
$env:GITHUB_REPOSITORY = "jschibelli/portfolio-os"

GitHub CLI

Ensure GitHub CLI is authenticated:

gh auth status

# If not authenticated
gh auth login

Error Handling

All scripts include comprehensive error handling:

# Scripts check prerequisites
if (-not (Get-Command gh -ErrorAction SilentlyContinue)) {
    Write-Error "GitHub CLI not installed"
    exit 1
}

# Dry run mode available
.\script-name.ps1 -DryRun

Common Parameters

Most scripts support these parameters:

ParameterTypeDescription
-DryRunSwitchPreview changes without executing
-VerboseSwitchShow detailed output
-ForceSwitchSkip confirmations
-HelpSwitchShow help information

Best Practices

Note:

Script Execution Tips:

  1. Always review script help with Get-Help first
  2. Use -DryRun to preview changes
  3. Check GitHub CLI authentication before running
  4. Review output logs for errors
  5. Use -Verbose for debugging

Advanced Features

1. Retry Logic

Scripts include automatic retry for API calls:

# Automatically retries on failure
$prInfo = Get-PRInfo -PRNumber "123" -MaxRetries 3

2. Caching

Common operations are cached:

# Repository info is cached
$repo = Get-RepoInfo # Cached after first call

3. Logging

Comprehensive logging to track operations:

# Logs saved to logs/
.\script-name.ps1 # Creates logs/script-name-YYYY-MM-DD.log

Troubleshooting

Script Won't Run

# Check execution policy
Get-ExecutionPolicy

# If restricted, allow scripts
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

API Rate Limits

# Check rate limit
gh api rate_limit

# Use personal access token with higher limits
$env:GITHUB_TOKEN = "your-token"

Module Not Found

# Install required modules
Install-Module -Name SomeModule -Scope CurrentUser

Next Steps

Note:

For detailed information on each script category, explore the links above. Each page includes usage examples and parameters.