Sudocode

repository·main·Indexed 43 days ago

https://github.com/sudocode-ai/sudocode

A lightweight agent orchestration system and Git-native spec and issue management tool for AI-assisted software development. It uses a versioned memory system to track requirements (specs) and implementation plans (issues), supporting collaborative long-horizon work for AI coding agents. Features include a CLI for managing entities, Obsidian-style cross-referencing, anchored feedback, and remote deployment to GitHub Codespaces.

Tokens
104.8K
Snippets
355
Records
472
Agent score
54%

What's inside Sudocode

  1. Overview of @sudocode-ai/types

    main

    The @sudocode-ai/types package provides the shared TypeScript type definitions used across the entire sudocode ecosystem. It serves as the single source of truth for data structures used in Git-native spec and issue management.

    Key type definitions included in this package:

    • Specs: Definitions for software specifications.
    • Issues: Definitions for issue management.
    • Relationships: Types defining connections between different entities.
    • Feedback: Types for capturing feedback loops.
    • Events: Definitions for system events.
    • JSONL Interchange Formats: Schema definitions for data exchanged via JSONL (JSON Lines) files.
  2. Overview of Sudocode Feedback Mechanisms

    main
    Sudocode's feedback mechanisms establish a bidirectional flow between design documents (specifications), implementation tracking, and actual code artifacts. This system allows AI agents to provide feedback on specifications, which then links back to issues, ensuring that code implementations remain aligned with the original design intent.
  3. Understand the Sudocode SQLite Schema

    main

    Sudocode uses a SQLite database to manage project state, including specifications, issues, and their relationships. The schema is designed to support a graph-like structure for entities and an audit trail for changes.

    Core Entities

    • Specs: Represents technical specifications (e.g., architecture, api, feature).
    • Issues: Represents actionable items (e.g., bug, task, epic).
    • Relationships: A polymorphic table that links any two entities (spec-to-spec, spec-to-issue, etc.) using types like blocks, related, or implements.
    • Tags: A shared table for categorizing both specs and issues.
    • Events: An audit trail recording changes to entities, including snapshots of old and new values.
    -- Example of the core relationship structure
    CREATE TABLE relationships (
        from_id TEXT NOT NULL,
        from_type TEXT NOT NULL,               -- spec|issue
        to_id TEXT NOT NULL,
        to_type TEXT NOT NULL,                 -- spec|issue
        relationship_type TEXT NOT NULL,       -- blocks|related|parent-child|discovered-from|implements
        created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
        created_by TEXT NOT NULL,
        metadata TEXT,                          -- Optional JSON metadata
        PRIMARY KEY (from_id, from_type, to_id, to_type, relationship_type)
    );
  4. How Sudocode manages data and synchronization

    main

    Sudocode uses a Distributed Git Database model to provide database semantics without external services. It maintains two representations of every entity:

    1. Human-editable format: Markdown and YAML files stored in .sudocode/specs/ and .sudocode/issues/. These are the primary source of truth and are committed to Git.
    2. Machine-optimized format: JSONL files (specs.jsonl, issues.jsonl) and a local SQLite cache (.sudocode/cache.db).

    Synchronization Logic:

    • Auto-Export: Changes made to Markdown/YAML are exported to JSONL after a 5-second debounce.
    • Auto-Import: When JSONL files are newer (e.g., after a git pull), they are imported into the local SQLite cache.
    • Conflict Resolution: Git handles the distribution of files; AI agents handle merge conflicts within the content.
  5. Understand the sudocode context structure

    main

    sudocode uses a 4-tiered abstraction structure to represent context in your repository, moving from high-level intent to low-level implementation:

    1. Spec (Specification): Captures WHAT you want (requirements, RFCs, design decisions). Stored as Markdown with YAML frontmatter in .sudocode/specs/.
    2. Issue: Captures agent intent (tasks derived from specs). Supports relationships like blocks, related, parent-child, and discovered-from. Stored in .sudocode/issues/.
    3. Agent: The execution abstraction. Represents the trajectory of an agentic loop (e.g., Claude Code, Codex) against an issue. Configuration is stored in .sudocode/agents/.
    4. Artifact: Represents state changes from agent execution, such as code diffs, research reports, or documentation updates.
  6. Understand the sudocode Data Model principles

    main

    The sudocode system uses a dual-representation data model to balance human readability with machine efficiency.

    Key principles include:

    • Dual Representation: Entities exist as both human-editable Markdown (with YAML frontmatter) and machine-optimized JSONL/SQLite formats.
    • Bidirectional Links: Relationships are tracked in both directions to enable efficient querying.
    • Immutable IDs: IDs (e.g., spec-001, issue-001) are assigned at creation and never change, even if the entity is renamed.
    • Git-Friendly: Primary storage (JSONL and Markdown) is optimized for version control.
    • Flexible Content: While metadata is structured, the core Markdown content is free-form to allow users and agents to organize information as needed.
  7. Understand the Sudocode Three-Way Sync Flow

    main

    Sudocode uses a three-way synchronization mechanism to keep Markdown files, JSONL snapshots, and the SQLite database in sync. This allows users to edit Markdown files manually while the CLI and background processes manage the structured data in SQLite and JSONL.

    The Sync Flow:

    • Markdown File $\leftrightarrow$ JSONL File $\leftrightarrow$ SQLite DB
    • User Edits trigger the flow starting from the Markdown file.

    This architecture ensures that human-readable documentation (Markdown) remains the source of truth for users, while the JSONL and SQLite layers provide the high-performance querying and structured data required by agents and the CLI.

    Markdown File <──┐
                     │
                     ├──> JSONL File <──> SQLite DB
                     │
    User Edit ───────┘
  8. Understand the sudocode Git-Native Data Model

    main

    Sudocode uses a git-native approach where project management data lives alongside your code in the .sudocode/ directory. This allows you to branch, merge, and version your requirements and issues just like your source code.

    File Structure

    • .sudocode/meta.json: Configuration and ID counters (tracked in git).
    • .sudocode/specs.jsonl: All specifications (tracked in git). Each line is a complete entity.
    • .sudocode/issues.jsonl: All issues (tracked in git). Each line is a complete entity.
    • .sudocode/cache.db: SQLite cache (gitignored).
    • .sudocode/specs/: Generated markdown files for editing (gitignored).
    • .sudocode/issues/: Generated markdown files for editing (gitignored).

    Key Benefits

    • Branching: Create specs/issues for specific feature branches.
    • Merging: Merge requirements and task updates via standard git workflows.
    • Reverting: Revert task changes alongside code changes.
    • Review: Review specifications and issue updates directly in Pull Requests.
  9. Define and structure an Issue

    main

    An Issue captures actionable work items derived from specs, assigned to agents or humans.

    Storage Locations:

    • Markdown: .sudocode/issues/{id}.md
    • JSONL: .sudocode/issues/issues.jsonl

    Status Lifecycle:

    • open → in_progress → closed
    • open → blocked → in_progress → closed
    • closed can be reopened to open.

    Frontmatter Schema:

    id: string                    # Unique identifier (issue-NNN)
    title: string                 # Short description (max 500 chars)
    description: string           # Detailed problem statement
    status: enum                  # open | in_progress | blocked | needs_review | closed
    priority: int                 # 0-4 (0=highest, 2=default)
    issue_type: enum              # bug | feature | task | epic | chore
    assignee: string?            # Agent ID or username
    estimated_minutes: int?       # Estimated effort
    created_at: timestamp         # ISO 8601 format
    updated_at: timestamp         # ISO 8601 format
    closed_at: timestamp?        # When closed (null if open)
    created_by: string            # Who created (user or agent)
    spec_refs: [string]           # Specs this issue relates to
    parent: string?               # Parent issue (for epics)
    blocks: [string]              # Issues this blocks
    blocked_by: [string]          # Issues blocking this (computed)
    related: [string]             # Related issues
    tags: [string]                # Free-form labels for organization
    ---
    id: issue-001
    title: Implement OAuth 2.0 token endpoint
    description: Create REST endpoint for OAuth token exchange
    status: open
    priority: 1
    issue_type: task
    assignee: agent-backend-dev
    estimated_minutes: 120
    created_at: 2025-10-16T10:00:00Z
    updated_at: 2025-10-16T15:30:00Z
    closed_at: null
    created_by: agent-planner
    spec_refs: [spec-001]
    parent: null
    blocks: [issue-002]
    blocked_by: []
    related: [issue-010]
    tags: [auth, backend, api]
    ---
    
    # Implement OAuth 2.0 token endpoint
    
    ## Description
    Create REST endpoint for OAuth token exchange following RFC 6749.
  10. Understand ID assignment and collision handling

    main

    Sudocode uses sequential numbering for IDs, which are stored in .sudocode/meta.json.

    Formats:

    • Specs: spec-NNN (e.g., spec-001)
    • Issues: issue-NNN (e.g., issue-001)

    Collision Handling Strategy: If an ID collision is detected during import or merge:

    1. Detect the collision (same ID, different content).
    2. Score entities by reference count (how many places reference this ID).
    3. Renumber the entity with fewer references.
    4. Update all references in text fields and relationships.
    5. Record the mapping in a conflict log.
  11. How bidirectional linking works

    main

    Sudocode uses a bracket-based syntax to create relationships between specs and issues. These links are tracked bidirectionally in a relationship graph.

    • Syntax: Use [[ID]] to reference an entity (e.g., [[ISSUE-001]] or [[SPEC-010]]).
    • Issue references in Specs: Use [[@ISSUE-001]] to embed an issue reference within a spec.
    • Automatic Backlinks: When you link an issue to a spec, the relationship is automatically tracked in both directions, allowing for easy navigation of dependencies and hierarchies.
    ## Requirements
    1. Support OAuth 2.0 [[ISSUE-001]]
    2. Multi-factor authentication [[ISSUE-002]]
    
    See also [[SPEC-010]] for API design patterns.
  12. Understand the Markdown Source of Truth architecture

    main

    Sudocode supports two primary architectural modes for managing entity data. This allows teams to choose between a machine-first or human-first workflow:

    1. JSONL Mode (Current Default): The JSONL files (e.g., specs.jsonl, issues.jsonl) act as the authoritative source of truth. Markdown files in .sudocode/specs/*.md are synchronized with these files via a watcher using timestamp-based conflict resolution. This mode is optimized for machine-driven data management.

    2. Markdown Mode (Proposed/New): Markdown files become the authoritative source of truth. In this mode, JSONL files are treated as derived artifacts used for caching or exporting. This is ideal for teams that prefer managing data through human-readable, wiki-style documentation.

    In both modes, a SQLite Cache (cache.db) is used as the underlying query engine, but it is typically gitignored and treated as a transient layer.

    Current Architecture (JSONL-first):
    Markdown Files (.sudocode/specs/*.md) <-> JSONL Files (specs.jsonl, issues.jsonl) <-> SQLite Cache (cache.db)
    
    Proposed Architecture (Markdown-first):
    Markdown Files (Source of Truth) -> JSONL Files (derived) -> SQLite Cache