+
Skip to content

Conversation

amikofalvy
Copy link
Collaborator

Summary

Implements separate OpenAPI documentation generation for the Run API and Manage API with automated fetching from running services. This replaces the previous combined API reference with two distinct, independently maintained API documentation pages.

Changes

New Scripts

  • agents-docs/scripts/fetch-openapi-specs.mjs: Fetches latest OpenAPI specs from both running APIs
    • Run API (localhost:3003) → src/lib/run-api.json (34KB, 5 endpoints)
    • Manage API (localhost:3002) → src/lib/manage-api.json (956KB, 44 endpoints)
    • Includes error handling and detailed console output

Updated Scripts

  • agents-docs/scripts/generate-openapi-docs.mjs: Now generates separate documentation for each API

New NPM Commands

  • pnpm fetch-openapi - Download latest specs from running APIs
  • pnpm generate-openapi - Generate static docs from specs
  • pnpm update-api-docs - Combined command: fetch + generate

Documentation Structure

  • New: api-reference/run-api.mdx - Run API reference page
  • New: api-reference/manage-api.mdx - Manage API reference page
  • Updated: api-reference/index.mdx - Overview page explaining both APIs
  • Updated: navigation.ts - Separate sidebar entries for each API
  • Updated: CLAUDE.md - Documented new workflow

Generated Files

  • src/lib/run-api.json - Run API OpenAPI specification
  • src/lib/manage-api.json - Manage API OpenAPI specification
  • Auto-generated MDX files for each API's operations

Why These Changes?

  1. Separation of Concerns: Run API (runtime) and Manage API (configuration) serve different purposes and should have separate documentation
  2. Automated Updates: New fetch script pulls latest specs directly from running APIs
  3. Better Navigation: Users can quickly find the specific API they need
  4. Maintainability: Changes to either API are reflected independently

Usage

# Start both APIs (from project root)
pnpm dev:apis

# Update API documentation (from agents-docs/)
pnpm update-api-docs

Test Plan

  • Created fetch script and successfully downloaded specs from both APIs
  • Generated documentation for both APIs separately
  • Verified navigation shows two separate API reference entries
  • Verified overview page explains both APIs clearly

Screenshots

Navigation sidebar now shows separate Run API and Manage API entries under API Reference

🤖 Generated with Claude Code

Implements separate OpenAPI documentation generation for Run API and Manage API with automated fetching from running services.

## Changes

### New Scripts
- `agents-docs/scripts/fetch-openapi-specs.mjs`: Fetch latest OpenAPI specs from both APIs
- Run API (localhost:3003) → `src/lib/run-api.json`
- Manage API (localhost:3002) → `src/lib/manage-api.json`

### Updated Scripts
- `agents-docs/scripts/generate-openapi-docs.mjs`: Generate separate docs for each API

### New NPM Commands
- `pnpm fetch-openapi`: Download latest specs from running APIs
- `pnpm update-api-docs`: Combined fetch + generate command

### Documentation
- New `api-reference/run-api.mdx`: Run API reference page
- New `api-reference/manage-api.mdx`: Manage API reference page
- Updated `api-reference/index.mdx`: Overview explaining both APIs
- Updated `navigation.ts`: Separate sidebar entries for each API
- Updated `CLAUDE.md`: Documented new workflow

### Generated Files
- `src/lib/run-api.json`: Run API OpenAPI spec (34KB, 5 endpoints)
- `src/lib/manage-api.json`: Manage API OpenAPI spec (956KB, 44 endpoints)
- Auto-generated MDX files for each API's operations

## Usage

```bash
# Start both APIs (from project root)
pnpm dev:apis

# Update API documentation (from agents-docs/)
pnpm update-api-docs
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
agents-docs Ready Ready Preview Comment Sep 30, 2025 7:16pm
agents-manage-api Ready Ready Preview Comment Sep 30, 2025 7:16pm
agents-manage-ui Ready Ready Preview Comment Sep 30, 2025 7:16pm
agents-run-api Ready Ready Preview Comment Sep 30, 2025 7:16pm

Copy link

claude bot commented Sep 30, 2025

Claude finished @amikofalvy's task —— View job


Code Review Complete

I've conducted a comprehensive architectural and engineering review of the API documentation separation changes. Here's my analysis:

Strengths

1. Excellent Architectural Separation

  • Clear separation of concerns: Run API (runtime) vs Manage API (configuration) reflects the actual system architecture
  • Proper abstraction: Each API serves distinct purposes with minimal overlap
  • Future-proof design: Allows independent evolution of runtime and management capabilities

2. Robust Implementation Quality

  • Environment-aware configuration: Proper environment variable support (RUN_API_URL, MANAGE_API_URL)
  • Comprehensive error handling: Good validation and user-friendly error messages in fetch script
  • Professional tooling: Uses established fumadocs-openapi library instead of reinventing documentation generation

3. Developer Experience Excellence

  • Streamlined workflow: pnpm update-api-docs combines fetch + generate in single command
  • Clear documentation: Good inline comments and usage instructions
  • Automated updates: Live specs fetched directly from running services

⚠️ Areas for Consideration

1. Critical: Missing Error Recovery & Resilience

Severity: High

// agents-docs/scripts/fetch-openapi-specs.mjs:111-112
if (failCount > 0) {
  process.exit(1); // ❌ Hard failure breaks entire workflow
}

Issue: If one API is down, entire documentation update fails. This could break CI/CD pipelines.

Recommendation: Implement graceful degradation:

// Proposed improvement
const ALLOW_PARTIAL_FAILURE = process.env.ALLOW_PARTIAL_DOCS_UPDATE === 'true';
if (failCount > 0 && !ALLOW_PARTIAL_FAILURE) {
  console.warn('⚠️ Partial failure mode enabled, continuing with available specs...');
} else if (failCount > 0) {
  process.exit(1);
}

2. System Design: Potential Data Consistency Issues

Severity: Medium

The workflow fetch → generate creates a window where specs could be inconsistent between APIs if:

  • APIs are updated at different times
  • Network issues cause partial failures
  • Race conditions during concurrent API updates

Recommendations:

  • Add spec versioning/timestamps validation
  • Consider atomic updates with rollback capability
  • Add health check validation before generation

3. Scalability & Performance Concerns

Severity: Medium

File Size Growth: Manage API spec is 956KB (27K lines) vs Run API's 36KB. This pattern suggests potential issues:

  • Large bundle sizes affecting docs site performance
  • Memory usage during generation
  • Slower CI/CD builds

Browser Performance: Generated API docs will be large:

// Consider lazy loading large API sections
<APIPage document={"./src/lib/manage-api.json"} hasHead={true} />

Recommendation: Implement:

  • Lazy loading for large API sections
  • Pagination for endpoints
  • Bundle analysis to track size growth

4. Maintenance & Extensibility Issues

Severity: Medium

Hard-coded Configuration:

// agents-docs/scripts/generate-openapi-docs.mjs:17-28
const APIS = [
  { name: 'Run API', input: './src/lib/run-api.json', output: './content/docs/api-reference/run-api' },
  { name: 'Manage API', input: './src/lib/manage-api.json', output: './content/docs/api-reference/manage-api' }
];

This doesn't scale well for future APIs (Analytics API, Billing API, etc.).

Recommendation: Move to configuration file:

// config/api-docs.config.js
export const API_CONFIGS = {
  'run-api': {
    name: 'Run API',
    url: process.env.RUN_API_URL || 'http://localhost:3003',
    description: 'Runtime execution API for agent interactions'
  }
  // ... more APIs
};

🔧 Technical Improvements

5. Enhanced Error Boundaries

// Add to fetch-openapi-specs.mjs
async function fetchWithRetry(url, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fetchSpec(url);
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      console.log(`⏳ Retry ${i + 1}/${maxRetries} for ${url}...`);
      await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
    }
  }
}

6. Validation & Schema Checks

Add OpenAPI spec validation:

// Validate critical fields exist
if (!spec.info?.version || !spec.paths || Object.keys(spec.paths).length === 0) {
  throw new Error(`Invalid or incomplete OpenAPI spec: missing critical sections`);
}

🏗️ Architectural Considerations

7. Documentation Navigation Structure

Current: Flat structure under "API Reference"
Concern: Will become cluttered as more APIs are added

Recommendation: Consider hierarchical organization:

API Reference/
├── Runtime APIs/
│   ├── Run API
│   └── Webhook API
├── Management APIs/
│   ├── Manage API
│   └── Analytics API
└── Authentication/

8. Versioning Strategy Missing

No strategy for handling API versioning in documentation.

Recommendation: Plan for:

  • Version-specific documentation branches
  • Deprecation notices in old versions
  • Migration guides between versions

📊 Metrics & Observability

9. Missing Monitoring

No tracking of documentation generation success/failure rates or performance.

Recommendation: Add:

// Track generation metrics
console.log(`📊 Generation completed: ${Date.now() - startTime}ms`);
// Consider sending metrics to observability platform

🎯 Overall Assessment

Grade: B+ (Good with Important Improvements Needed)

This is a well-architected solution that properly separates concerns and provides excellent developer experience. The implementation quality is high with good error handling and clear documentation.

Key Strengths: Clean separation, robust tooling, developer-friendly workflow
Critical Gap: Resilience and error recovery need improvement for production use
Recommendation: Address the error recovery and scalability concerns before merge, as these could impact production reliability.

The architectural decisions set a strong foundation for the framework's documentation strategy, and with the suggested improvements, this will be an excellent documentation system.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载