Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Change: Add View Dashboard Command

## Why

Users need a quick, at-a-glance overview of their OpenSpec project status without running multiple commands. Currently, users must run `openspec list --changes` and `openspec list --specs` separately to understand the project state. A unified dashboard view would improve developer experience and provide immediate insight into project progress.

## What Changes

### Added `openspec view` Command

The new command provides an interactive dashboard displaying:
- Summary metrics (total specs, requirements, changes, task progress)
- Active changes with visual progress bars
- Completed changes
- Specifications with requirement counts

### Specifications Affected

- **cli-view** (NEW): Complete specification for the view dashboard command

## Implementation Details

### File Structure
- Created `/src/core/view.ts` implementing the `ViewCommand` class
- Registered command in `/src/cli/index.ts`
- Reuses existing utilities from `task-progress.ts` and `MarkdownParser`

### Visual Design
- Uses Unicode box drawing characters for borders
- Color coding: cyan for specs, yellow for active, green for completed
- Progress bars using filled (█) and empty (░) blocks
- Clean alignment with proper padding

### Technical Approach
- Async data fetching from changes and specs directories
- Parallel processing of specs and changes
- Error handling for missing or invalid data
- Maintains consistency with existing list command output
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# CLI View Command - Changes

## ADDED Requirements

### Requirement: Dashboard Display

The system SHALL provide a `view` command that displays a dashboard overview of specs and changes.

#### Scenario: Basic dashboard display

- **WHEN** user runs `openspec view`
- **THEN** system displays a formatted dashboard with sections for summary, active changes, completed changes, and specifications

#### Scenario: No OpenSpec directory

- **WHEN** user runs `openspec view` in a directory without OpenSpec
- **THEN** system displays error message "✗ No openspec directory found"

### Requirement: Summary Section

The dashboard SHALL display a summary section with key project metrics.

#### Scenario: Complete summary display

- **WHEN** dashboard is rendered with specs and changes
- **THEN** system shows total number of specifications and requirements
- **AND** shows number of active changes in progress
- **AND** shows number of completed changes
- **AND** shows overall task progress percentage

#### Scenario: Empty project summary

- **WHEN** no specs or changes exist
- **THEN** summary shows zero counts for all metrics

### Requirement: Active Changes Display

The dashboard SHALL show active changes with visual progress indicators.

#### Scenario: Active changes with progress bars

- **WHEN** there are in-progress changes with tasks
- **THEN** system displays each change with change name left-aligned
- **AND** visual progress bar using Unicode characters
- **AND** percentage completion on the right

#### Scenario: No active changes

- **WHEN** all changes are completed or no changes exist
- **THEN** active changes section is omitted from display

### Requirement: Completed Changes Display

The dashboard SHALL list completed changes in a separate section.

#### Scenario: Completed changes listing

- **WHEN** there are completed changes (all tasks done)
- **THEN** system shows them with checkmark indicators in a dedicated section

#### Scenario: Mixed completion states

- **WHEN** some changes are complete and others active
- **THEN** system separates them into appropriate sections

### Requirement: Specifications Display

The dashboard SHALL display specifications sorted by requirement count.

#### Scenario: Specs listing with counts

- **WHEN** specifications exist in the project
- **THEN** system shows specs sorted by requirement count (descending) with count labels

#### Scenario: Specs with parsing errors

- **WHEN** a spec file cannot be parsed
- **THEN** system includes it with 0 requirement count

### Requirement: Visual Formatting

The dashboard SHALL use consistent visual formatting with colors and symbols.

#### Scenario: Color coding

- **WHEN** dashboard elements are displayed
- **THEN** system uses cyan for specification items
- **AND** yellow for active changes
- **AND** green for completed items
- **AND** dim gray for supplementary text

#### Scenario: Progress bar rendering

- **WHEN** displaying progress bars
- **THEN** system uses filled blocks (█) for completed portions and light blocks (░) for remaining

### Requirement: Error Handling

The view command SHALL handle errors gracefully.

#### Scenario: File system errors

- **WHEN** file system operations fail
- **THEN** system continues with available data and omits inaccessible items

#### Scenario: Invalid data structures

- **WHEN** specs or changes have invalid format
- **THEN** system skips invalid items and continues rendering
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Implementation Tasks

## Design Phase
- [x] Research existing list command implementation
- [x] Design dashboard layout and information architecture
- [x] Choose appropriate command verb (`view`)
- [x] Define visual elements (progress bars, colors, layout)

## Core Implementation
- [x] Create ViewCommand class in `/src/core/view.ts`
- [x] Implement getChangesData method for fetching change information
- [x] Implement getSpecsData method for fetching spec information
- [x] Implement displaySummary method for summary metrics
- [x] Add progress bar visualization with Unicode characters
- [x] Implement color coding using chalk

## Integration
- [x] Import ViewCommand in CLI index
- [x] Register `openspec view` command with commander
- [x] Add proper error handling and ora spinner integration
- [x] Ensure command appears in help documentation

## Data Processing
- [x] Reuse TaskProgress utilities for change progress
- [x] Integrate MarkdownParser for spec requirement counting
- [x] Handle async operations for file system access
- [x] Sort specifications by requirement count

## Testing and Validation
- [x] Build project successfully with new command
- [x] Test command with sample data
- [x] Verify correct requirement counts match list --specs
- [x] Test progress bar display for various completion states
- [x] Run existing test suite to ensure no regressions
- [x] Verify TypeScript compilation with no errors

## Documentation
- [x] Add command description in CLI help
- [x] Create change proposal documentation
- [x] Update README with view command example (if needed)
- [x] Add view command to user documentation (if exists)

## Polish
- [x] Ensure consistent formatting and alignment
- [x] Add helpful footer text referencing list commands
- [x] Optimize for terminal width considerations
- [x] Review and refine color choices for accessibility
112 changes: 112 additions & 0 deletions openspec/specs/cli-view/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# cli-view Specification

## Purpose

The `openspec view` command provides a comprehensive dashboard view of the OpenSpec project state, displaying specifications, changes, and progress metrics in a unified, visually appealing format to help developers quickly understand project status.
## Requirements
### Requirement: Dashboard Display

The system SHALL provide a `view` command that displays a dashboard overview of specs and changes.

#### Scenario: Basic dashboard display

- **WHEN** user runs `openspec view`
- **THEN** system displays a formatted dashboard with sections for summary, active changes, completed changes, and specifications

#### Scenario: No OpenSpec directory

- **WHEN** user runs `openspec view` in a directory without OpenSpec
- **THEN** system displays error message "✗ No openspec directory found"

### Requirement: Summary Section

The dashboard SHALL display a summary section with key project metrics.

#### Scenario: Complete summary display

- **WHEN** dashboard is rendered with specs and changes
- **THEN** system shows total number of specifications and requirements
- **AND** shows number of active changes in progress
- **AND** shows number of completed changes
- **AND** shows overall task progress percentage

#### Scenario: Empty project summary

- **WHEN** no specs or changes exist
- **THEN** summary shows zero counts for all metrics

### Requirement: Active Changes Display

The dashboard SHALL show active changes with visual progress indicators.

#### Scenario: Active changes with progress bars

- **WHEN** there are in-progress changes with tasks
- **THEN** system displays each change with change name left-aligned
- **AND** visual progress bar using Unicode characters
- **AND** percentage completion on the right

#### Scenario: No active changes

- **WHEN** all changes are completed or no changes exist
- **THEN** active changes section is omitted from display

### Requirement: Completed Changes Display

The dashboard SHALL list completed changes in a separate section.

#### Scenario: Completed changes listing

- **WHEN** there are completed changes (all tasks done)
- **THEN** system shows them with checkmark indicators in a dedicated section

#### Scenario: Mixed completion states

- **WHEN** some changes are complete and others active
- **THEN** system separates them into appropriate sections

### Requirement: Specifications Display

The dashboard SHALL display specifications sorted by requirement count.

#### Scenario: Specs listing with counts

- **WHEN** specifications exist in the project
- **THEN** system shows specs sorted by requirement count (descending) with count labels

#### Scenario: Specs with parsing errors

- **WHEN** a spec file cannot be parsed
- **THEN** system includes it with 0 requirement count

### Requirement: Visual Formatting

The dashboard SHALL use consistent visual formatting with colors and symbols.

#### Scenario: Color coding

- **WHEN** dashboard elements are displayed
- **THEN** system uses cyan for specification items
- **AND** yellow for active changes
- **AND** green for completed items
- **AND** dim gray for supplementary text

#### Scenario: Progress bar rendering

- **WHEN** displaying progress bars
- **THEN** system uses filled blocks (█) for completed portions and light blocks (░) for remaining

### Requirement: Error Handling

The view command SHALL handle errors gracefully.

#### Scenario: File system errors

- **WHEN** file system operations fail
- **THEN** system continues with available data and omits inaccessible items

#### Scenario: Invalid data structures

- **WHEN** specs or changes have invalid format
- **THEN** system skips invalid items and continues rendering

15 changes: 15 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { InitCommand } from '../core/init.js';
import { UpdateCommand } from '../core/update.js';
import { ListCommand } from '../core/list.js';
import { ArchiveCommand } from '../core/archive.js';
import { ViewCommand } from '../core/view.js';
import { registerSpecCommand } from '../commands/spec.js';
import { ChangeCommand } from '../commands/change.js';
import { ValidateCommand } from '../commands/validate.js';
Expand Down Expand Up @@ -97,6 +98,20 @@ program
}
});

program
.command('view')
.description('Display an interactive dashboard of specs and changes')
.action(async () => {
try {
const viewCommand = new ViewCommand();
await viewCommand.execute('.');
} catch (error) {
console.log(); // Empty line for spacing
ora().fail(`Error: ${(error as Error).message}`);
process.exit(1);
}
});

// Change command with subcommands
const changeCmd = program
.command('change')
Expand Down
Loading
Loading