Skip to content

jogelin/dot-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

169 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

dot-ai β€” Universal AI Workspace Convention

License: MIT Version OpenClaw Claude Code Pi

A standardized .ai/ workspace structure for AI assistants β€” with an extension-only architecture for Claude Code, OpenClaw, Pi, Cursor, and Copilot.

The dot-ai convention provides a universal workspace structure that helps AI assistants understand your project context, manage tasks, route between projects, and maintain consistency across sessions. v7 replaces the provider system with a unified extension-only architecture where everything β€” identity, memory, skills, routing, tools β€” is an extension.


✨ Features

  • πŸ—οΈ Workspace Structure β€” Standardized .ai/ directory with boot sequence and project routing
  • 🧩 Extension-Only Architecture β€” Everything is an extension: identity, memory, skills, routing, tools
  • 🎯 Section-Based Context β€” Extensions return Section objects assembled by priority with token-budget trimming
  • πŸ“Š Token Budget β€” formatSections() auto-trims sections to fit context window with BudgetWarning diagnostics
  • πŸ”§ Extension-Registered Tools β€” Tools defined in extensions, exposed as native agent capabilities
  • πŸ” Deterministic Labels β€” Regex-based label extraction from vocabulary (no LLM in pipeline)
  • πŸš€ DotAiRuntime β€” Single class encapsulating boot, processPrompt, fireToolCall, fire, shutdown
  • πŸ”„ 5 Emission Patterns β€” fire, fireCollectSections, fireFirstResult, fireChainTransform, fireUntilBlocked
  • πŸ“‘ Boot Caching β€” Extensions discovered once per session, vocabulary built at boot

πŸ“¦ Installation

Claude Code

# Install the plugin
claude plugin add dot-ai

npm Packages

For programmatic use or custom adapters:

npm install @dot-ai/core @dot-ai/adapter-claude

Available packages:

Package Description
@dot-ai/core Runtime engine, extension runner, section formatting
@dot-ai/adapter-claude Claude Code adapter
@dot-ai/adapter-pi Pi adapter (full event support)
@dot-ai/adapter-sync Cursor / Copilot / Windsurf sync adapter
@dot-ai/adapter-openclaw OpenClaw adapter
@dot-ai/ext-sqlite-memory SQLite-backed memory extension
@dot-ai/ext-file-memory File-backed memory extension
@dot-ai/ext-file-skills File-based skills extension
@dot-ai/ext-file-identity File-based identity extension
@dot-ai/ext-file-tools File-based tools extension
@dot-ai/ext-file-tasks File-based tasks extension
@dot-ai/ext-file-prompts File-based prompts extension
@dot-ai/ext-rules-routing Rules-based routing extension
@dot-ai/cli CLI for workspace management

OpenClaw

openclaw plugins install dot-ai
openclaw gateway restart

Other AI Tools (Windsurf, Cursor, Copilot, Continue.dev)

Use the adapter-sync package to generate agent-specific configuration:

npx @dot-ai/adapter-sync

This generates:

  • Windsurf: .windsurf/rules/dot-ai.md
  • Cursor: .cursor/rules/dot-ai.md
  • Codex: Injects into root AGENTS.md
  • Continue.dev: Manual reference in .continuerc.json

πŸš€ Quick Start

1. Create Workspace Structure

mkdir -p my-project/.ai/memory/tasks
cd my-project/.ai

2. Create Minimum Required File

Create .ai/AGENTS.md:

# AGENTS.md

This workspace follows the dot-ai convention.

## Project

{Brief description of your project}

## Conventions

- Read `.ai/skills/dot-ai/BOOTSTRAP.md` for workspace rules
- Use `dot-ai-tasks` for task management (not built-in todos)
- Follow model routing guidelines

3. Plugin Auto-Detection

The plugin automatically detects any workspace with .ai/AGENTS.md and:

  • βœ… Loads workspace context at session start
  • βœ… Discovers and activates extensions from .ai/extensions/ and installed packages
  • βœ… Enforces task management conventions
  • βœ… Optimizes model selection for sub-agents
  • βœ… Provides access to all skills and capabilities

No local installation needed β€” the plugin provides skills globally!


🧩 Extension System

Extensions are the only mechanism for contributing content in v7. Place TypeScript files in .ai/extensions/ or install extension packages β€” they are loaded automatically at boot.

Writing an Extension

// .ai/extensions/security-gate.ts
import type { ExtensionAPI } from '@dot-ai/core';

export default function(api: ExtensionAPI) {
  // Gate tool calls
  api.on('tool_call', async (event) => {
    if (event.tool === 'Write' && event.input.file_path?.toString().endsWith('.env')) {
      return { decision: 'block', reason: 'Cannot write to .env files' };
    }
  });

  // Enrich context with sections
  api.on('context_enrich', async (event) => {
    return {
      sections: [{
        title: 'Security Rules',
        content: '> Always write tests for new features.',
        priority: 70,
        source: 'security-gate',
      }],
    };
  });

  // Register skills, identities, labels
  api.registerSkill({ name: 'security', description: 'Security rules', labels: ['security'] });
  api.contributeLabels(['security', 'auth', 'secrets']);
}

Extension Events

Event Emission Pattern Description
context_enrich fireCollectSections Extensions return { sections } for context injection
label_extract fireChainTransform Extensions modify the labels array
route fireFirstResult First extension to return a routing result wins
tool_call fireUntilBlocked Gate or block tool calls before execution
tool_result fireChainTransform Observe or transform tool results
agent_end fire React when an agent completes
input fireChainTransform Rewrite user input before processing
session_start fire Session lifecycle
session_end fire Session lifecycle
session_compact fire Context compaction event

Extension API

Extensions receive an ExtensionAPI object with:

Method Purpose
api.on(event, handler) Subscribe to events
api.registerTool(tool) Register a tool the agent can invoke
api.registerCommand(cmd) Register a slash command
api.registerSkill(skill) Register a skill for context enrichment
api.registerIdentity(identity) Register an identity document
api.contributeLabels(labels) Add labels to the global vocabulary
api.events Inter-extension event bus
api.config Extension-specific configuration
api.workspaceRoot Workspace root directory

Adapter Capability Matrix

Not all adapters support every event. The matrix below shows what each adapter can fire:

Adapter context_enrich tool_call agent_end tool_result input
Pi βœ… βœ… βœ… βœ… βœ…
Claude Code βœ… βœ… βœ… β€” β€”
OpenClaw βœ… β€” βœ… β€” β€”
Cursor/Copilot (sync) βœ… β€” β€” β€” β€”

See docs/extensions.md for the full extension authoring guide.


πŸ“š Complete Skill Reference

Core Skills (4)

Skill Purpose Triggers
dot-ai Main workspace convention manual
dot-ai-tasks Task management (use instead of todos) always
model-selection Smart model routing (Haiku/Sonnet/Opus) always
context-strategy Context budget management (<50%, >70%, >85%) always

Project & Workspace (3)

Skill Purpose Triggers
dot-ai-workspace-scan Scan .ai/ directories, build project index boot, manual
dot-ai-project-init Create new project with proper structure manual
dot-ai-migrate Migrate from older convention versions manual, auto-detect

Validation & Sync (6)

Skill Purpose Triggers
dot-ai-audit Weekly workspace coherence validation heartbeat, manual
dot-ai-agent-sync Generate/maintain AGENT.md sections manual, audit
dot-ai-skill-sync Validate SKILL.md frontmatter audit
dot-ai-backlog-sync Validate task structure audit
dot-ai-memory-sync Validate memory/ directory structure audit
dot-ai-tools-sync Validate TOOLS.md structure audit

Utilities (4)

Skill Purpose Triggers
dot-ai-export Export workspace as JSON/YAML/Markdown manual
dot-ai-doctor Health checks and troubleshooting manual, on errors
dot-ai-security Security rules and verification always
dot-ai-self-improve Learning loop and pattern extraction manual

πŸ—οΈ Workspace Structure

my-project/
β”œβ”€β”€ .ai/                        # Root workspace context
β”‚   β”œβ”€β”€ AGENTS.md               # Required β€” AI operating rules
β”‚   β”œβ”€β”€ SOUL.md                 # Optional β€” Workspace personality
β”‚   β”œβ”€β”€ USER.md                 # Optional β€” User preferences
β”‚   β”œβ”€β”€ IDENTITY.md             # Optional β€” Project identity
β”‚   β”œβ”€β”€ TOOLS.md                # Optional β€” Tool configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ extensions/             # User-authored extensions (v7)
β”‚   β”‚   └── *.ts                # Loaded automatically at boot
β”‚   β”‚
β”‚   β”œβ”€β”€ memory/                 # Session memory and tasks
β”‚   β”‚   β”œβ”€β”€ YYYY-MM-DD.md       # Daily session notes
β”‚   β”‚   β”œβ”€β”€ tasks/              # Task details (on-demand)
β”‚   β”‚   β”‚   └── {slug}.md
β”‚   β”‚   └── research/           # Research notes
β”‚   β”‚
β”‚   β”œβ”€β”€ data/                   # Structured data ONLY (no drafts!)
β”‚   β”‚   β”œβ”€β”€ exports/            # Generated exports (CSV, JSON)
β”‚   β”‚   └── imports/            # External data imports
β”‚   β”‚
β”‚   └── skills/
β”‚       └── dot-ai/             # Symlink to plugin skills (auto-created)
β”‚           β”œβ”€β”€ BOOTSTRAP.md    # Lightweight startup context
β”‚           β”œβ”€β”€ SKILL.md        # Full documentation
β”‚           β”œβ”€β”€ CONVENTIONS.md  # Shared conventions
β”‚           └── templates/      # Reusable templates
β”‚
└── projects/                   # Sub-projects (optional)
    └── {project-name}/
        └── .ai/                # Per-project AI context
            β”œβ”€β”€ AGENT.md        # Project-specific docs
            └── memory/
                └── tasks/

Key Principles

  • Root .ai/ β€” Workspace-wide context
  • Project .ai/ β€” Project-specific context
  • Extensions β€” .ai/extensions/ and installed packages loaded at boot
  • Data Separation β€” .ai/data/ = structured only, no research/drafts
  • Memory Organization β€” Daily notes, tasks, research separated

🎯 Usage Examples

Task Management

Always use dot-ai-tasks instead of built-in todos.

Tasks are managed through the task extension. The extension can be backed by:

  • File-based (@dot-ai/ext-file-tasks) β€” JSON files in .ai/memory/tasks/
  • Custom β€” Any extension implementing the task pattern

Configure in .ai/settings.json:

{
  "packages": [
    "@dot-ai/ext-file-tasks"
  ]
}

Tasks support standard fields: id, text, status, priority, project, tags.

Model Selection

The plugin automatically injects model routing rules:

Task Type                  β†’  Model to Use
─────────────────────────────────────────────────
OCR, extraction, formatting  β†’  Haiku (cheap)
Development, refactoring     β†’  Sonnet (standard)
Architecture, planning       β†’  Opus (strategic only)

Anti-patterns:

  • ❌ Never spawn sub-agent without specifying model
  • ❌ Never use Opus for execution tasks
  • ❌ Never do multiple web_fetch in Opus

Context Management

The plugin monitors context usage and suggests delegation:

Context Usage  β†’  Action
───────────────────────────────────────
< 50%          β†’  Normal operation
50-70%         β†’  Delegate reads to sub-agents
> 70%          β†’  Switch to Sonnet if on Opus
> 85%          β†’  Stop reading, work from memory

Health Checks

Run workspace diagnostics:

"doctor" or "health check"

Output:

πŸ₯ dot-ai Health Check

Overall Health: 85/100 (Good)

βœ… Passed (5):
  - Structure validation
  - Required files
  - Extension loading
  - Cache fresh (<7 days)

⚠️ Warnings (2):
  - 3 orphan tasks without backlog refs
  - 1 extension failed to load (syntax error)

πŸ’Š Suggested Fixes:
  1. Run backlog-sync to add orphan tasks
  2. Check .ai/extensions/ for syntax errors

πŸ›οΈ Architecture

Engine Architecture (v7)

Agent (Claude Code / OpenClaw / Pi / Cursor / Copilot)
  └── Adapter (hooks into native events)
        └── DotAiRuntime (@dot-ai/core)
              β”œβ”€β”€ boot()           β†’ discover extensions, register resources, build vocabulary
              β”œβ”€β”€ processPrompt()  β†’ label_extract, context_enrich, route β†’ { sections, labels, routing }
              β”œβ”€β”€ fireToolCall()   β†’ extension-based tool gating
              β”œβ”€β”€ fire('agent_end', { response })  β†’ notify extensions
              β”œβ”€β”€ shutdown()       β†’ session_end + flush
              └── diagnostics      β†’ extension status

  Extensions (everything is an extension):
  β”œβ”€β”€ ext-file-identity     β†’ registerIdentity(), context_enrich
  β”œβ”€β”€ ext-file-memory       β†’ context_enrich, agent_end
  β”œβ”€β”€ ext-file-skills       β†’ registerSkill(), context_enrich
  β”œβ”€β”€ ext-rules-routing     β†’ route event handler
  β”œβ”€β”€ ext-file-tasks        β†’ registerTool(), context_enrich
  β”œβ”€β”€ ext-file-tools        β†’ registerTool(), context_enrich
  β”œβ”€β”€ ext-file-prompts      β†’ context_enrich
  β”œβ”€β”€ ext-sqlite-memory     β†’ context_enrich, agent_end
  └── .ai/extensions/*.ts   β†’ user-authored extensions

See ARCHITECTURE.md for the full technical reference.

INDEX/SKILL Pattern

All large skills (>100 lines) use INDEX/SKILL separation:

  • INDEX.md (~30-40 lines) β€” Quick reference at startup

    • Purpose and triggers
    • Quick commands
    • Key concepts
    • Use cases
    • Pointer to SKILL.md
  • SKILL.md (full docs) β€” Loaded on-demand

    • Detailed procedures
    • Examples and edge cases
    • Templates and validation rules
    • Integration points

Benefits:

  • βœ… Fast startup (agent sees overview)
  • βœ… Complete awareness (knows what exists)
  • βœ… Progressive loading (details when needed)

Shared Infrastructure

  • CONVENTIONS.md β€” Single source of truth for:

    • Marker patterns
    • Frontmatter schema
    • Output formats
    • Validation workflows
    • Directory structure
  • templates/ β€” Reusable templates:

    • BACKLOG.template.md
    • AGENT.template.md
    • SKILL.template.md
    • task-details.template.md
    • validation-output.template.md

πŸ”§ Configuration

settings.json

The central configuration file at .ai/settings.json:

{
  "packages": [
    "@dot-ai/ext-file-identity",
    "@dot-ai/ext-file-memory",
    "@dot-ai/ext-file-skills",
    "@dot-ai/ext-rules-routing",
    "@dot-ai/ext-file-tasks",
    "@dot-ai/ext-file-tools"
  ],
  "extensions": [
    ".ai/extensions/custom.ts"
  ],
  "debug": {
    "logPath": ".ai/debug.log"
  }
}

Global Configuration

User-level defaults can be set in ~/.ai/settings.json. These are merged with project-level settings (arrays deduplicated, project scalars win):

{
  "packages": [
    "@dot-ai/ext-file-identity",
    "@dot-ai/ext-file-memory"
  ]
}

Auto-Install

Packages listed in settings.json are automatically installed into .ai/packages/ at boot if not already present. No manual npm install needed.

Workspace Resolution

Each adapter resolves the workspace root (the directory containing .ai/) and passes it to DotAiRuntime. The resolution priority varies by adapter:

OpenClaw adapter:

Priority Source Use Case
1 process.cwd() CLI / local usage where cwd is the project
2 pluginConfig.workspace Gateway / Discord / TUI where cwd is not the project
3 ctx.workspaceDir OpenClaw fallback

Claude Code adapter: Uses the hook's cwd (always the project directory).

Pi adapter: Uses the configured workspaceRoot option.

OpenClaw Configuration

In openclaw.json, configure the workspace path for gateway/Discord/TUI environments under plugins.entries.dot-ai.config:

{
  "plugins": {
    "entries": {
      "dot-ai": {
        "enabled": true,
        "config": {
          "workspace": "/Users/you/dev/my-project"
        }
      }
    }
  }
}

Claude Code Configuration

Uses .claude-plugin/plugin.json for metadata and skill registration.


πŸ“– Documentation

  • ARCHITECTURE.md β€” Full v7 architecture (runtime, extensions, events, formatting)
  • docs/extensions.md β€” Extension authoring guide (events, custom tools, best practices)
  • BOOTSTRAP.md β€” Lightweight startup context (what agent sees at boot)
  • SKILL.md β€” Full dot-ai convention documentation
  • CONVENTIONS.md β€” Shared conventions across all skills

🀝 Contributing

Adding New Skills

  1. Create skill directory: skills/my-skill/
  2. Create INDEX.md (~30 lines) with overview
  3. Create SKILL.md with full documentation
  4. Add skill to manifests:
    • openclaw.plugin.json β†’ skills array
    • .claude-plugin/plugin.json β†’ skills array
  5. Update plugin injection in index.ts if needed

Writing Extensions

  1. Create a .ts file in .ai/extensions/ or a new ext-* package
  2. Export a default function that receives ExtensionAPI
  3. Register resources (registerSkill, registerIdentity, contributeLabels)
  4. Subscribe to events (context_enrich, tool_call, agent_end, etc.)
  5. Extensions are loaded automatically at boot β€” no registration needed

Release Process

Releases are CI-only β€” never run the release script locally.

  • Trigger: Manual workflow_dispatch on GitHub Actions (.github/workflows/release.yml)
  • Versioning: All packages use fixed versioning (same version). Current version is resolved from git tags, not package.json.
  • Bump detection: Automatic via conventional commits (feat: β†’ minor, fix: β†’ patch)
  • What happens:
    1. Bumps all packages/*/package.json
    2. Syncs plugin manifests (openclaw.plugin.json, .claude-plugin/plugin.json, etc.)
    3. Generates CHANGELOG.md, creates git commit & tag
    4. Publishes all packages to npm

Skill Development Guidelines

  • Follow INDEX/SKILL pattern for skills >100 lines
  • Reference CONVENTIONS.md for shared patterns
  • Use templates from templates/ directory
  • Include frontmatter with name, description, triggers
  • Add cross-references to related skills
  • Write clear examples and use cases

πŸ› Troubleshooting

Plugin Not Loading

# OpenClaw
openclaw plugins list
openclaw gateway restart

# Claude Code
claude plugin list
claude plugin enable dot-ai

Workspace Not Detected

Check that .ai/AGENTS.md exists:

ls -la .ai/

If missing, create it or run:

"init project {name}"

Extension Not Loading

Check the diagnostics output:

"doctor" or "health check"

Common issues:

  • Syntax error in .ts file
  • Missing default export
  • Listening to events not supported by current adapter

Health Check Failed

Run diagnostics and follow suggested fixes from the output.

Skills Not Available

The plugin provides skills globally. If skills aren't working:

  1. Verify plugin is enabled
  2. Restart agent/gateway
  3. Check workspace has .ai/AGENTS.md

πŸ“Š Performance

Token Optimization

Startup injection:

  • Before optimization: 1582 lines
  • After optimization: 620 lines
  • Reduction: 61% (962 lines saved)

Strategy:

  • INDEX.md files provide overview (520 lines)
  • SKILL.md files loaded on-demand (1600+ lines)
  • Agent maintains 100% awareness with 61% fewer tokens

Impact:

  • βœ… Faster startup across all adapters
  • βœ… More context budget for actual work
  • βœ… Same functionality, better performance

πŸ“„ License

MIT License β€” See LICENSE for details.


πŸ”— Links


🎯 Summary

dot-ai provides a universal workspace convention for AI assistants:

  • βœ… Standardized .ai/ structure with multi-project support
  • βœ… Extension-only architecture β€” everything (identity, memory, skills, routing, tools) is an extension
  • βœ… Section-based context enrichment via context_enrich event
  • βœ… DotAiRuntime with boot, processPrompt, fireToolCall, fire, shutdown
  • βœ… 5 emission patterns (fire, fireCollectSections, fireFirstResult, fireChainTransform, fireUntilBlocked)
  • βœ… Token budget with section-aware trimming (formatSections, trimSections)
  • βœ… Deterministic label-based matching (no LLM in pipeline)
  • βœ… Boot caching for fast per-prompt enrichment
  • βœ… Works with Claude Code, OpenClaw, Pi, Cursor, Copilot

Get started: Create .ai/AGENTS.md in your project root and let the plugin handle the rest!


Made with ❀️ by the dot-ai community

Last updated: 2026-03-07

About

Portable AI skill that defines the .ai/ workspace convention with metadata caching and orchestration

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors