Skip to content

Conversation

@processtrader
Copy link

@processtrader processtrader commented Jan 18, 2026

Summary

Adds a global architecture.md document to OpenSpec for documenting system architecture, components, data flows, and architectural decisions.

Changes

New Files

  • src/core/templates/architecture-template.ts - Template with ASCII diagrams, structured sections
  • src/core/architecture-apply.ts - Auto-merge decisions from design.md to architecture.md on archive

Modified Files

  • src/core/templates/index.ts - Export architecture template
  • src/core/templates/agents-template.ts - Architecture documentation section + post-implementation checklist
  • src/core/archive.ts - Auto-merge architectural decisions
  • src/core/update.ts - Create missing templates for existing projects + user tip
  • src/core/init.ts - Add "Document your system architecture" step
  • src/core/templates/skill-templates.ts - Reference architecture.md in skills
  • schemas/spec-driven/schema.yaml - Clarify design.md/architecture.md relationship
  • openspec/AGENTS.md - Updated via openspec update
  • openspec/architecture.md - New file created for project itself

Features

  1. Created on init/update: architecture.md is generated during openspec init (new projects) or openspec update (existing projects)

  2. Auto-merge on archive: Architectural decisions from per-change design.md are automatically extracted and appended to the global architecture.md decisions table

  3. LLM guidance: AGENTS.md now includes:

    • When to read/update architecture.md
    • Diagram standards (ASCII)
    • Post-implementation checklist for architecture currency
  4. User prompts: Both init and update display helpful prompts for populating architecture.md

Template Structure

# System Architecture
## Overview           (ASCII system diagram)
## Components         (major components/services)
## Data Flows         (how data moves)
## Integration Points (external systems table)
## Architectural Decisions (auto-populated on archive)
## Constraints        (technical/business constraints)
## Diagram Reference  (ASCII building blocks)

Testing

  • ✅ Build passes
  • ✅ 903 tests pass
  • ⚠️ 18 pre-existing failures in zsh-installer.test.ts (unrelated to this PR)

Checklist

  • pnpm install
  • pnpm run build
  • pnpm test (pre-existing failures only)
  • Conventional commit format

Summary by CodeRabbit

  • New Features

    • Design decisions are auto-merged into the central architecture document during archiving.
    • Added a reusable architecture template for documenting components, flows, integrations, decisions, constraints, and diagrams.
  • Documentation

    • Expanded architecture guidance: reading, when/how to update, proposing changes, diagram standards, and a post-implementation checklist.
    • Proposal templates note that decisions are merged to the architecture doc when archived.
  • Workflow Updates

    • Archiving now includes an architecture update step; onboarding emphasizes documenting system architecture.
  • UX

    • Newly created template files are reported in update summaries.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

Adds an architecture documentation template and openspec/architecture.md, implements extraction and merging of architectural decisions from a change's design.md into architecture.md during archival, and integrates template generation and init/update flows to surface and create architecture.md.

Changes

Cohort / File(s) Summary
Documentation & Templates
openspec/AGENTS.md, openspec/architecture.md, src/core/templates/agents-template.ts, src/core/templates/architecture-template.ts
Adds a new architecture.md doc and a large architecture template; expands guidance (when to update, proposing changes, diagram standards, post-implementation checklist) and references across AGENTS and template content.
Core Architecture Decision Logic
src/core/architecture-apply.ts
New module exporting ArchitecturalDecision and functions: hasArchitecturalImpact, extractArchitecturalDecision, appendArchitecturalDecision, applyArchitecturalDecisions; handles detection, extraction, table insertion, truncation/escaping, and file writes.
Archive Workflow Integration
src/core/archive.ts
Calls applyArchitecturalDecisions during archive flow (uses cached archiveDate); logs when architecture.md is updated.
Template Manager & Index
src/core/templates/index.ts
Exposes TemplateManager.getArchitectureTemplate() and includes architecture.md in template list.
Init & UX Prompts
src/core/init.ts
Adjusts wizard prompts and step labels to surface architecture documentation; cosmetic formatting changes.
Template Generation & Update Flow
src/core/update.ts, src/core/templates/skill-templates.ts
Creates missing template files (now tracks created templates), surfaces created templates in final summary, adds tip about populating architecture.md; skill templates reformatted and content updated.
Schema/Proposal Note
schemas/spec-driven/schema.yaml
Adds editorial note that decisions in design.md are auto-merged into openspec/architecture.md when archived.

Sequence Diagram(s)

sequenceDiagram
    participant Archive as Archive Workflow
    participant Design as design.md
    participant Apply as architecture-apply
    participant Arch as architecture.md

    Archive->>Design: Read design.md
    Design-->>Archive: design content
    Archive->>Apply: hasArchitecturalImpact(content)?
    Apply-->>Archive: yes / no

    alt Architectural impact detected
        Archive->>Apply: extractArchitecturalDecision(content, changeName, date)
        Apply-->>Archive: ArchitecturalDecision
        Archive->>Arch: Read architecture.md
        Arch-->>Archive: current architecture content
        Archive->>Apply: appendArchitecturalDecision(currentContent, decision)
        Apply-->>Archive: updated architecture content
        Archive->>Arch: Write updated architecture.md
        Arch-->>Archive: Write confirmed
        Archive->>Archive: Log architecture update
    else No architectural impact
        Archive->>Archive: Skip architecture update
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 I hop through docs and fold a plan,
Lines of decisions tucked by hand—
When changes sleep and archives close,
I stitch the map where structure grows.
A tidy burrow of system prose.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main feature being added: a new architecture.md template and automation to merge architectural decisions upon archiving, which are the core objectives of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 95.65% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/core/archive.ts (1)

231-262: Avoid updating architecture.md before the archive succeeds.

If archiving fails (existing archive or rename error), the decision is still appended, which can record a change that was never archived. Move the merge after a successful rename and read design.md from the archived location.

🛠️ Proposed fix
-    // Apply architectural decisions to architecture.md if design.md has architectural impact
-    const archiveDate = this.getArchiveDate();
-    const architectureUpdated = await applyArchitecturalDecisions(
-      targetPath,
-      changeName!,
-      changeDir,
-      archiveDate
-    );
-    if (architectureUpdated) {
-      console.log('Updated architecture.md with architectural decisions.');
-    }
-
-    // Create archive directory with date prefix
-    const archiveName = `${archiveDate}-${changeName}`;
+    // Create archive directory with date prefix
+    const archiveDate = this.getArchiveDate();
+    const archiveName = `${archiveDate}-${changeName}`;
     const archivePath = path.join(archiveDir, archiveName);
@@
-    await fs.rename(changeDir, archivePath);
+    await fs.rename(changeDir, archivePath);
+
+    // Apply architectural decisions after successful archive
+    const architectureUpdated = await applyArchitecturalDecisions(
+      targetPath,
+      changeName!,
+      archivePath,
+      archiveDate
+    );
+    if (architectureUpdated) {
+      console.log('Updated architecture.md with architectural decisions.');
+    }
🤖 Fix all issues with AI agents
In `@openspec/architecture.md`:
- Around line 55-57: The table row placeholder is malformed because the header
"| Date | Decision | Rationale | Status |" expects four cells but the row
contains only the comment "<!-- Decisions are appended here during archive -->";
fix by either replacing that single-cell row with an empty four-cell row like "|
|  |  |  |" or moving the comment outside the table (e.g., place "<!-- Decisions
are appended here during archive -->" below the table) so the Markdown table
renders correctly in openspec/architecture.md.

In `@src/core/architecture-apply.ts`:
- Around line 28-45: The pattern checking for "API" in hasArchitecturalImpact is
case-sensitive; update the architecturalPatterns array (in the
hasArchitecturalImpact function) to use a case-insensitive regex for API (e.g.,
change /\bAPI\b/ to /\bAPI\b/i or /\bapi\b/i) so occurrences like "api" or "Api"
are detected; keep the rest of the patterns unchanged.
🧹 Nitpick comments (1)
src/core/templates/architecture-template.ts (1)

62-65: Use a valid placeholder for the decisions table.

The single-cell placeholder row can render as a malformed table. Consider removing it (the surrounding comments already explain auto-append behavior).

🛠️ Suggested tweak
 | Date | Decision | Rationale | Status |
 |------|----------|-----------|--------|
-| <!-- Decisions are appended here during archive --> |

Resolved conflicts in skill-templates.ts:
- Combined indentation changes from both branches
- Merged guardrail sections for archive-related skills
- Kept upstream's improvement about delta specs sync assessment
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