Skip to content

Conversation

@ZEDce
Copy link

@ZEDce ZEDce commented Dec 23, 2025

Summary

  • Add --archived flag to openspec list command to show only archived changes
  • Add --all flag to openspec list command to show both active and archived changes
  • Add "Archived Changes" section to openspec view dashboard with count in summary

Test plan

  • Run openspec list --archived to verify only archived changes are displayed
  • Run openspec list --all to verify both active and archived changes are displayed
  • Run openspec view to verify the "Archived Changes" section appears in the dashboard
  • Verify existing openspec list behavior (without flags) is unchanged

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added --archived and --all CLI options to filter and display archived items.
    • Archived changes can now be viewed in a dedicated section alongside active changes.
    • Archive item count is now included in summary metrics.
    • Support for reading and organizing archived change entries in the system.

✏️ Tip: You can customize this high-level summary in your review settings.

Add --archived and --all flags to the list command to display archived changes.
The view dashboard now includes an "Archived Changes" section with a count in
the summary.

- list --archived: shows only archived changes
- list --all: shows both active and archived changes
- view: displays archived changes section in dashboard

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ZEDce ZEDce requested a review from TabishB as a code owner December 23, 2025 11:43
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

The changes add support for listing and displaying archived changes through new CLI options --archived and --all. The core list command is extended to read archived changes from a dedicated archive directory and display them separately, alongside active changes, with context-sensitive messaging when no changes exist.

Changes

Cohort / File(s) Summary
CLI Option Extensions
src/cli/index.ts
Adds --archived and --all options to the list command; updates action handler to pass these options to ListCommand.execute.
Core List Command
src/core/list.ts
Introduces ListOptions interface; extends execute signature to accept options parameter; implements logic to read archived changes from archive subdirectory; adds filtered display of active/archived changes with context-sensitive "no changes found" messages; extends ChangeInfo with optional archived field.
View/Display Logic
src/core/view.ts
Adds getArchivedChangesData() function to read archived changes; updates displaySummary to show archived changes count; enables separate "Archived Changes:" section in UI output.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant CLI as CLI Handler
    participant ListCmd as ListCommand
    participant FS as FileSystem
    participant View as View/Display
    
    User->>CLI: list --archived / --all
    CLI->>ListCmd: execute(path, mode, {archived, all})
    
    rect rgb(240, 248, 255)
        Note over ListCmd: Determine display flags
        ListCmd->>ListCmd: showArchived, showActive = computed from options
    end
    
    rect rgb(240, 250, 240)
        Note over ListCmd: Fetch Active Changes
        ListCmd->>FS: read active changes (exclude "archive")
    end
    
    alt options.archived or options.all
        rect rgb(255, 250, 240)
            Note over ListCmd: Fetch Archived Changes
            ListCmd->>FS: read archive directory
            FS-->>ListCmd: archived change entries (or empty if dir missing)
        end
    end
    
    rect rgb(245, 245, 245)
        Note over ListCmd: Validate & Merge
        ListCmd->>ListCmd: Check if changes exist<br/>Mark archived entries with archived: true<br/>Prepare display data
    end
    
    alt Changes found
        ListCmd->>View: Display active + archived sections
        View->>View: Render "Active Changes:" section
        View->>View: Render "Archived Changes:" section
    else No changes found
        ListCmd->>View: Display context message<br/>(No active/archived/any changes)
    end
    
    View-->>User: Output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and accurately summarizes the main changes: adding archived changes display to list and view commands.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/core/view.ts (2)

154-172: Consider removing unnecessary async modifier.

The getArchivedChangesData method is marked async but only uses synchronous filesystem operations (fs.existsSync, fs.readdirSync). This is inconsistent with other methods like getChangesData and getSpecsData which are also async but use sync operations.

While this works, consider either:

  1. Removing async from all these methods since they don't use await
  2. Converting to async fs operations (fs.promises) for consistency

174-177: Consider stronger typing for parameters.

The changesData.active and specsData parameters use any[] which loses type safety. Consider using the actual types or defining interfaces:

🔎 Suggested type improvement
 private displaySummary(
-  changesData: { active: any[]; completed: any[] },
-  specsData: any[],
+  changesData: { active: Array<{ name: string; progress: { total: number; completed: number } }>; completed: Array<{ name: string }> },
+  specsData: Array<{ name: string; requirementCount: number }>,
   archivedData: Array<{ name: string }> = []
 ): void {
src/core/list.ts (1)

43-56: Minor duplication: archiveDir is computed twice.

The archive directory path is computed on line 46 and again on line 83. Consider computing it once at the top of the changes mode block.

🔎 Suggested refactor
     const changesDir = path.join(targetPath, 'openspec', 'changes');
+    const archiveDir = path.join(changesDir, 'archive');

     // Check if changes directory exists
     try {
       await fs.access(changesDir);
     } catch {
       throw new Error("No OpenSpec changes directory found. Run 'openspec init' first.");
     }

     const showArchived = options.archived || options.all;
     const showActive = !options.archived || options.all;

     // Get all directories in changes (excluding archive)
     const entries = await fs.readdir(changesDir, { withFileTypes: true });
     const changeDirs = showActive
       ? entries
           .filter(entry => entry.isDirectory() && entry.name !== 'archive')
           .map(entry => entry.name)
       : [];

     // Get archived changes if requested
     let archivedDirs: string[] = [];
     if (showArchived) {
-      const archiveDir = path.join(changesDir, 'archive');
       try {
         await fs.access(archiveDir);
         // ... rest of code

And remove the second declaration on line 83:

     // Collect information about each archived change
     const archivedChanges: ChangeInfo[] = [];
-    const archiveDir = path.join(changesDir, 'archive');

     for (const changeDir of archivedDirs) {

Also applies to: 81-93

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c2599b and 5476768.

📒 Files selected for processing (3)
  • src/cli/index.ts
  • src/core/list.ts
  • src/core/view.ts
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED|MODIFIED|REMOVED|RENAMED Requirements` headers in spec delta files
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Check `openspec/project.md` for project conventions before creating specs

Applied to files:

  • src/core/view.ts
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Move completed changes from `changes/[name]/` to `changes/archive/YYYY-MM-DD-[name]/` after deployment

Applied to files:

  • src/core/list.ts
🧬 Code graph analysis (2)
src/cli/index.ts (1)
src/core/list.ts (1)
  • ListCommand (20-168)
src/core/list.ts (1)
src/utils/task-progress.ts (2)
  • getTaskProgressForChange (27-35)
  • formatTaskStatus (37-41)
🔇 Additional comments (5)
src/core/view.ts (1)

52-59: LGTM!

The archived changes section follows the established pattern for other sections, with appropriate visual differentiation using gray styling and a distinct bullet character.

src/cli/index.ts (1)

98-104: LGTM!

The new CLI options are well-integrated. The combination of --archived with --all is technically redundant but handled gracefully in list.ts where showArchived = options.archived || options.all ensures correct behavior regardless.

src/core/list.ts (3)

15-18: LGTM!

The ListOptions interface is well-designed and properly exported for use by CLI and potentially other consumers.


58-67: LGTM!

The context-sensitive empty state messages provide clear feedback to users based on which filter flags they used.


99-124: LGTM!

The display logic is clean with proper section separation and consistent formatting between active and archived changes.

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