Skip to content

Comments

Add cli docs command for agents#69

Open
mickmister wants to merge 21 commits intomainfrom
vk/e9bf-analyze-svelte-m
Open

Add cli docs command for agents#69
mickmister wants to merge 21 commits intomainfrom
vk/e9bf-analyze-svelte-m

Conversation

@mickmister
Copy link
Member

This PR adds a sb docs command for agents to run when working in a springboard project

Vibe Kanban and others added 14 commits February 6, 2026 21:15
Analyzes svelte-mcp architecture patterns for creating a similar MCP server
for springboard. Documents key patterns including:
- Tool orchestration (list-sections → get-documentation → autofixer)
- Use cases as keywords for smart doc selection
- Iterative validation with AST visitors
- Context-efficient workflow design

Proposes springboard-mcp design with validator patterns for:
- State mutation detection
- Missing cleanup handlers
- Route conflicts
- Module interface merging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Redesign springboard-ai as a CLI tool instead of MCP server for:
- Simpler integration (any AI agent can run shell commands)
- No protocol overhead (direct stdin/stdout)
- Easier testing (run commands manually)
- Portability (works with any AI tool)

CLI commands:
- sb-ai list-sections: Discover docs with use_cases
- sb-ai get-docs: Fetch documentation
- sb-ai validate: Validate module code (issues/suggestions)
- sb-ai scaffold: Generate module templates
- sb-ai context: Output full agent context prompt
- sb-ai types: Output TypeScript definitions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Integrate with existing `sb` CLI rather than separate tool:
- sb docs list - List docs with use_cases
- sb docs get - Fetch documentation
- sb docs validate - Validate module code
- sb docs scaffold - Generate templates
- sb docs context - Agent context prompt
- sb docs types - TypeScript definitions

Implementation extends /packages/springboard/cli/ instead of new package.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Creates new `sb docs` subcommand with placeholder implementations for:
- sb docs list: List documentation sections with use_cases
- sb docs get: Fetch specific documentation
- sb docs validate: Validate module code
- sb docs scaffold: Generate module templates (module/feature/utility)
- sb docs context: Output agent context prompt
- sb docs types: Output TypeScript definitions

All commands return TODO messages and will be implemented in follow-up
commits.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes:
1. Make `sb docs` (without subcommand) show help output
2. Add CLAUDE.md creation in create-springboard-app with:
   - Instructions to run `npx sb docs --help` before coding
   - Key commands and workflow for Claude Code agents
   - Emphasis on using docs tools to ensure correct code

3. Add AGENTS.md creation in create-springboard-app with:
   - Similar instructions for other AI coding assistants
   - Clear workflow recommendations
   - Guidance to lean on `sb docs` commands

Both files are created automatically when running create-springboard-app,
ensuring AI agents have immediate context about available documentation
tools.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes based on analysis of svelte-mcp's approach:

1. Add helpful text to `sb docs --help`:
   - Guides AI agents to run `sb docs context` first
   - Explains that context includes full docs list
   - Shows recommended workflow: context → validate → get

2. Update CLAUDE.md and AGENTS.md:
   - Emphasize `sb docs context` as the single starting point
   - Explain that context includes everything (framework info + docs list)
   - Clarify that `list` is redundant if you've run `context`
   - Simplify workflow to match svelte-mcp pattern

Following svelte-mcp's pattern where the prompt pre-loads all available
docs and explicitly tells agents "you do not need to call list-sections
again."

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Creates bundled examples system similar to svelte-mcp's approach:

1. Add `sb docs examples` commands:
   - `sb docs examples list` - List all available examples
   - `sb docs examples show <name>` - Display full code for an example

2. Create three example modules:
   - basic-feature-module: Shared state + actions + routes
   - persistent-state-module: Database-backed state
   - user-agent-state-module: localStorage-backed UI state

3. Examples are stored as .txt files and bundled in npm package
   - Copied to dist/examples/ during build
   - Read at runtime via fs.readFileSync
   - Categorized by type (state, actions, routing, patterns)
   - Tagged for discoverability

4. Add comparison document (.planning/sb-docs-vs-svelte-mcp.md):
   - Documents what svelte-mcp has vs what we have
   - Key differences: MCP vs CLI, playground-link vs examples
   - Missing features: live docs fetching, use_cases metadata
   - Architecture decisions needed

This follows svelte-mcp's pattern of providing concrete examples,
though via bundled files instead of playground links (no playground
equivalent for Springboard yet).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Created comprehensive questionnaire based on deep research of:
- Springboard core APIs (ModuleAPI, StatesAPI, Actions, Routing, etc.)
- Real-world usage in songdrive (19+ modules, patterns, anti-patterns)

Questionnaire covers 25 questions across:
- General architecture (doc source, format, use_cases metadata)
- Command-specific decisions for each sb docs command
- Validation patterns to detect (from songdrive analysis)
- Implementation priority and MVP scope
- Integration with CLAUDE.md/AGENTS.md

Key decisions needed:
- Documentation source: Bundle vs Runtime vs Hosted
- Use cases generation: Claude Batch vs Manual vs Skip
- Validation scope: Which patterns to detect
- Scaffold: Keep vs Remove vs Replace with examples
- MVP: Which commands are minimum viable

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add full implementation of sb docs CLI commands for AI agent support:

- sb docs list: Lists 13 documentation sections with use_cases keywords
- sb docs get <section>: Fetches specific documentation content
- sb docs context: Outputs comprehensive context prompt for AI agents
- sb docs types: Shows TypeScript type definitions
- sb docs validate: Placeholder for future AST-based validation
- sb docs scaffold: Redirects to examples system

Create LLM-optimized documentation covering:
- Module API, state management, actions, routing
- Module types and communication patterns
- Core dependencies and lifecycle
- Platform support and server modules
- Common patterns and anti-patterns

Add build scripts to copy docs to dist during npm build.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These commands don't match svelte-mcp patterns:
- validate: svelte-mcp has real AST validation, ours was just a placeholder
- scaffold: svelte-mcp doesn't have scaffolding, uses playground-link instead

Remaining commands match svelte-mcp interface:
- list: matches list-sections tool
- get: matches get-documentation tool
- context: matches svelte-task prompt
- types: Springboard-specific addition
- examples: replaces playground-link for offline use

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Port the useModule pattern from SongDrive to Springboard core.
This hook provides type-safe module access from React components:

  const audioPlayer = useModule('AudioPlayer');
  const currentFile = audioPlayer.currentlyPlayingFile.useState();

Use this instead of moduleAPI.getModule() when in React components.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update the generated agent instruction files to reflect the removal of
sb docs validate. Replace with examples commands in the workflow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
No benefit to maintaining two different versions of the same content.
Use one string for both files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 16, 2026

Deploying jamtools-docs-new with  Cloudflare Pages  Cloudflare Pages

Latest commit: 72a1841
Status: ✅  Deploy successful!
Preview URL: https://ad75adf3.jamtools-docs-new.pages.dev
Branch Preview URL: https://vk-e9bf-analyze-svelte-m.jamtools-docs-new.pages.dev

View logs

@claude
Copy link

claude bot commented Feb 16, 2026

Claude finished @mickmister's task —— View job


PR Review: Add cli docs command for agents

I've completed my review of this PR. This is a well-implemented feature that adds comprehensive documentation support for AI agents working with Springboard projects.

Todo List:

  • Read repository guidelines and context
  • Analyze main CLI implementation changes
  • Review docs command implementation
  • Examine documentation content structure
  • Check for security concerns and bugs
  • Evaluate performance considerations
  • Assess test coverage
  • Provide comprehensive feedback

Strengths

Architecture & Design:

  • Clean separation of concerns: docs command (docs_command.ts) is well-separated from main CLI
  • Good command structure: Intuitive subcommands (list, get, context, types, examples)
  • AI-first design: The context command provides excellent comprehensive context for AI agents
  • Extensible: Easy to add new documentation sections via JSON configuration

Code Quality:

  • TypeScript interfaces: Well-defined types for DocSection and Example
  • Error handling: Proper error messages when sections/examples not found
  • Consistent patterns: Similar structure between docs and examples systems
  • Good abstractions: formatSectionsList(), getDocContent() etc.

Documentation Content:

  • Comprehensive coverage: 13 documentation sections covering all major Springboard concepts
  • AI-optimized: Clear use cases and tags make content discoverable
  • Practical examples: 3 working code examples for different state types
  • Good organization: Logical grouping of related concepts

Build System:

  • Proper asset copying: copy-docs and copy-examples scripts ensure content is bundled
  • File inclusion: src and dist properly included in package files

⚠️ Areas for Improvement

Test Coverage (Critical):

  • No tests found for the new docs command functionality
  • Should test: section lookup, content retrieval, JSON output, error cases
  • Examples: getSection('invalid'), getDocContent('missing-file')

Security & Robustness:

// packages/springboard/cli/src/docs/index.ts:54-58
try {
    return readFileSync(join(docsDir, 'content', filename), 'utf-8');
} catch {
    return null;
}
  • Path traversal risk: No validation of filename - could theoretically read files outside content/ directory
  • Recommendation: Validate filename against known sections before file operations

Performance Considerations:

  • Synchronous file reads: readFileSync blocks event loop, but acceptable for CLI usage
  • Multiple reads: Each sb docs get section1 section2 section3 reads files sequentially vs. in parallel
  • Memory usage: Loading all examples into memory at module init - fine for current 3 examples but could scale poorly

API Inconsistencies:

// packages/springboard/cli/src/docs/index.ts:35-41
export function getSection(slug: string): DocSection | undefined {
    return sections.find(s =>
        s.slug === slug ||
        s.slug.endsWith(`/${slug}`) ||  // Allow partial matching
        s.title.toLowerCase() === slug.toLowerCase()  // Case insensitive
    );
}
  • Multiple matching strategies could be confusing - may match unintended sections
  • Recommendation: Be more explicit about partial vs exact matching

CLI Implementation Issues:

// packages/springboard/cli/src/cli.ts:91-113
// Dev and build commands have all code commented out
  • Incomplete implementation: Main CLI commands are stubbed out
  • Potential confusion: Users may expect sb dev and sb build to work

Error Handling:

  • Generic catch blocks: Some error handling could be more specific
  • No validation: Commands don't validate file existence before operations

📋 Minor Issues

Code Style:

  • Mixed quote styles: Some files use single quotes, others double quotes
  • Console.log formatting: Could be more consistent across commands
  • Import organization: Some imports could be better organized

Documentation:

  • JSDoc coverage: Some functions lack comprehensive JSDoc comments
  • Usage examples: Could benefit from more usage examples in help text

🔒 Security Assessment

Overall: Low Risk - This is a CLI tool for development use, not production deployment.

Potential Issues:

  • File system access limited to bundled documentation
  • No external network requests
  • No user input sanitization needed beyond path validation

🎯 Recommendations

High Priority:

  1. Add comprehensive tests for docs command functionality
  2. Implement path validation in getDocContent() to prevent directory traversal
  3. Complete or remove commented code in main CLI commands

Medium Priority:

  1. Parallel file reading for multiple sections in get command
  2. Consistent error handling patterns across all commands
  3. Add JSDoc to public functions

Low Priority:

  1. Code style consistency (quotes, imports)
  2. Performance monitoring for large documentation sets

🏆 Overall Assessment

This is a high-quality implementation that successfully addresses the need for AI agent documentation support. The code is well-structured, the documentation is comprehensive, and the user experience is thoughtful.

Strengths outweigh concerns - the missing test coverage and minor security considerations are addressable in follow-up PRs without blocking this valuable feature.

Recommendation: ✅ APPROVE with the understanding that test coverage should be addressed in a follow-up PR.


Job Run | Branch: vk/e9bf-analyze-svelte-m

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7646ba7ad7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const packageJSON = require('../package.json');

import type { SpringboardPlatform, Plugin } from './types.js';
import {createDocsCommand} from './docs_command';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Add .js extension to docs command import

This package is published as ESM ("type": "module"), but this relative import is emitted without an extension in dist/cli.js, so Node cannot resolve it at runtime. Running the built CLI (node dist/cli.js --help) immediately throws ERR_MODULE_NOT_FOUND for ./docs_command, which makes every sb command unusable before argument parsing.

Useful? React with 👍 / 👎.

sections: DocSection[];
}

const docsDir = __dirname;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve docs directory without __dirname in ESM

The docs loader runs as an ES module, where __dirname is not defined, so sb docs list/get/context crashes during import with ReferenceError: __dirname is not defined in ES module scope (reproduced via npx tsx src/cli.ts docs list). This should derive paths from import.meta.url instead of relying on CommonJS globals.

Useful? React with 👍 / 👎.

code: string;
}

const examplesDir = __dirname;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve examples directory without __dirname in ESM

The examples loader has the same ESM/CJS mismatch: __dirname is undefined in this module format, so sb docs examples list/show fails at runtime with ReferenceError as soon as this file is imported. Using an import.meta.url-based path is required for these commands to work.

Useful? React with 👍 / 👎.

**Before writing any code, run:**

\`\`\`bash
npx sb docs context

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Install sb CLI before telling agents to run it

The scaffolded AGENTS/CLAUDE guidance tells users to run npx sb docs context, but this generator does not install springboard-cli (only springboard and runtime deps are installed earlier), so fresh projects have no local sb binary. In that state the first recommended command fails (or may resolve an unrelated package via npx), which breaks the onboarding flow this change introduces.

Useful? React with 👍 / 👎.

Vibe Kanban and others added 7 commits February 16, 2026 07:20
Add the CLI to the main springboard package:
- Add bin entry pointing to cli/dist/cli.js as 'sb' command
- Include cli/dist in published files
- Update build-all.sh to build CLI
- Update prepublishOnly to use build:all

This allows users to run 'sb docs' commands after installing springboard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace __dirname with ES module equivalent using import.meta.url:
- import { fileURLToPath } from 'url'
- import { dirname } from 'path'
- const __filename = fileURLToPath(import.meta.url)
- const __dirname = dirname(__filename)

Fixes ReferenceError when CLI is run from published package.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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