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 automatically 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: when/how to update, proposing changes, diagram standards, and a post-implementation checklist.
  • Workflow Updates

    • Archiving now includes an architecture update step; onboarding prompts emphasize 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 architecture documentation (openspec/architecture.md and template), implements extraction and merging of architectural decisions from design.md into architecture.md during archival, integrates this into the archive workflow, and updates templates, initialization prompts, and template generation to support the architecture lifecycle.

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 document and long-form architecture template; expands architecture guidance, diagram standards, post-implementation checklist, and references in AGENTS and template content.
Core Architecture Decision Logic
src/core/architecture-apply.ts
NEW module exporting ArchitecturalDecision and functions: hasArchitecturalImpact, extractArchitecturalDecision, appendArchitecturalDecision, applyArchitecturalDecisions; handles parsing, table insertion, truncation/escaping, and file updates.
Archive Workflow Integration
src/core/archive.ts
Calls applyArchitecturalDecisions during archive flow using a cached archiveDate; logs updates when architecture.md is modified.
Template Manager & Index
src/core/templates/index.ts
Exposes new TemplateManager.getArchitectureTemplate() and includes architecture.md in template list.
Init & UX Prompts
src/core/init.ts
Adjusts wizard prompts/messages to emphasize documenting system architecture; 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 summary and tips for populating architecture.md; skill templates reformatted and content edited.
Schema/Proposal Note
schemas/spec-driven/schema.yaml
Adds editorial note: decisions from design.md are auto-merged into openspec/architecture.md when archived.

Sequence Diagram

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: Return 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.md 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 nibble notes and sketch a plan,
Decisions hop from mind to land—
In architecture.md they settle and stay,
Auto-merged when changes go on their way.
A tidy burrow for how systems stand.

🚥 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 pull request title 'feat(architecture): add architecture.md template and auto-merge on archive' accurately captures the main changes: introducing an architecture.md template and implementing auto-merge logic for architectural decisions on archive.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 markdownlint-cli2 (0.18.1)
openspec/architecture.md

markdownlint-cli2 v0.18.1 (markdownlint v0.38.0)
Finding: openspec/architecture.md
Linting: 1 file(s)
Summary: 3 error(s)
Error: EACCES: permission denied, open '/markdownlint-cli2-results.json'
at async open (node:internal/fs/promises:640:25)
at async Object.writeFile (node:internal/fs/promises:1214:14)
at async Promise.all (index 0)
at async outputSummary (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:877:5)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:1053:25)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:12:22 {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/markdownlint-cli2-results.json'
}


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

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