# All files / lib constants.js

100% Statements 19/19
100% Branches 0/0
100% Functions 0/0
100% Lines 19/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300

    6x
    6x

    6x

    6x

    6x
    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

    6x

     import path from 'path';
    import os from 'os';
    import { fileURLToPath } from 'url';

    const __filename = fileURLToPath(import.meta.url);
    const __dirname = path.dirname(__filename);

    /**
     * Rosetta target IDEs with their configuration files and templates.
     */
    export const TARGETS = [
      { label: 'VSCode / Claude Code', path: 'CLAUDE.md', template: 'anthropic-claude.md', skillsDir: '.claude/skills', generator: 'claude' },
      { label: 'Cursor', path: '.cursorrules', template: 'cursorrules.md', skillsDir: '.cursor/rules', generator: 'cursor' },
      { label: 'Antigravity', path: '.agent/skills/project-skill.md', template: 'antigravity-skill.md', skillsDir: '.agent/skills' },
      { label: 'GitHub Copilot', path: '.github/copilot-instructions.md', template: 'copilot-instructions.md', skillsDir: '.github/skills' },
      { label: 'Windsurf', path: '.windsurf/rules/rosetta-rules.md', template: 'windsurf-rules.md', skillsDir: '.windsurf/skills', generator: 'windsurf' },
      { label: 'GSD / generic', path: 'skills/gsd-skill.md', template: 'gsd-skill.md', skillsDir: 'skills' },
      { label: 'Codex CLI', path: '.codex/rules.md', template: 'codex-cli.md', skillsDir: '.agent/skills' },
      { label: 'Kilo Code', path: '.kilo/rules.md', template: 'kilo-code.md', skillsDir: '.kilo/rules' },
      { label: 'Continue.dev', path: '.continue/config.md', template: 'continue-dev.md', skillsDir: '.continue/rules' }
    ];

    /**
     * Directory paths for loading skills from multiple sources.
     */
    export const SKILLS_SOURCES = [
      path.join(__dirname, '../templates/skills'),
      path.join(os.homedir(), '.rosetta/skills'),
      path.join(process.cwd(), '.rosetta/skills'),
      path.join(process.cwd(), 'skills'),
      path.join(process.cwd(), 'company-skills')
    ];

    /**
     * Rosetta configuration directory and registry paths.
     */
    export const ROSETTA_DIR = path.join(os.homedir(), '.rosetta');
    export const REGISTRY_PATH = path.join(ROSETTA_DIR, 'registry.json');

    /**
     * Default registry content with sample presets and skills.
     */
    export const DEFAULT_REGISTRY = {
      presets: [
        {
          name: "@acme/fintech-agentic",
          domain: "financial",
          description: "A preset for fintech agents with strict compliance rules.",
          url: "https://raw.githubusercontent.com/RajanChavada/Rosetta/main/templates/presets/skill-creator.md"
        }
      ],
      skills: [
        {
          name: "@acme/k8s-manifests",
          domain: "devops",
          description: "Skills for Kubernetes manifest generation and validation.",
          url: "https://raw.githubusercontent.com/RajanChavada/Rosetta/main/templates/skills/node-express-postgres.skill.md"
        }
      ]
    };

    /**
     * Memory and logging templates.
     */
    export const PROJECT_MEMORY_TEMPLATE = `# Project Memory

    This file stores **long-lived knowledge** about the project: decisions, conventions, domain facts, and architectural context that should remain true across tasks and over time.

    ## What belongs here

    - Key architectural decisions and why they were made.
    - Important domain concepts and invariants (e.g., "a workspace always has at least one owner").
    - Naming conventions, folder structure conventions, and patterns that should be reused.
    - Changelogs for major shifts in architecture or tech stack.

    ## What does NOT belong here

    - Step-by-step task logs or debugging notes (use \`.ai/logs/daily/YYYY-MM-DD.md\`).
    - Speculative ideas that haven't been agreed on yet (put them in issues or task.md first).
    - Very low-level details that will quickly go out of date (prefer code comments).

    ## How the agent should update this file

    - Propose updates only when a decision is truly project-wide or long term.
    - When updating, include:
      - **Date**
      - **Context** (why this came up)
      - **Decision** (what is now true)
      - **Implications** (where it matters)

    Example entry:

    - **2026-03-13 – API Versioning**
      - Context: Added v2 endpoints for the payments API.
      - Decision: All new public APIs must be versioned under \`/v2/\` with explicit deprecation strategy for \`/v1/\`.
      - Implications: Update API docs, client SDKs, and test coverage to reflect versioning.
    `;

    export const AUTO_MEMORY_TEMPLATE = `# Auto Memory

    This file is for **agent-maintained notes and heuristics** that are useful across sessions but not "hard" project decisions.

    ## What belongs here

    - Reusable troubleshooting steps ("When tests fail with X, check Y first").
    - Observed patterns in the codebase ("Most services use helper Z for logging").
    - Short reminders about gotchas ("Do not modify table A directly; use migration scripts").

    ## What does NOT belong here

    - Long narratives or full task logs (those go in \`.ai/logs/daily/YYYY-MM-DD.md\`).
    - Major architectural or product decisions (those belong in \`PROJECT_MEMORY.md\`).
    - Sensitive data like access tokens or raw secrets.

    ## How the agent should update this file

    - Append **short, bulleted notes**, not essays.
    - Prefer patterns over one-off events.
    - If a note starts to feel like a project-wide rule, propose moving it to \`PROJECT_MEMORY.md\`.

    Example entries:

    - When updating DB schema, always run \`npm test db\` before committing.
    - Frontend components usually live under \`src/ui/\` and follow the \`Feature/Component\` pattern.
    - Integration tests use a seeded Postgres test database defined in \`docker-compose.test.yml\`.
    `;

    export const DAILY_LOG_TEMPLATE = `# {{DATE}}

    Daily log for this date. Each entry should capture **what was attempted, what changed, and what was learned**.

    ## How to use this file

    - Start your day by appending a new section with your name/agent label.
    - For each task, record:
      - The goal
      - Key steps or commands
      - Outcomes (success/failure)
      - Any follow-ups or questions

    ## Entries

    ### [Your Name or Agent Label]

    **Task:** Short description of what you're doing
    **Context:** Link to issue/ticket if relevant

    **Actions:**
    - Step 1 …
    - Step 2 …

    **Outcome:**
    - What worked / what failed
    - Links to PRs, commits, or files touched

    **Learnings / Notes:**
    - Anything worth moving later to \`AUTO_MEMORY.md\` or \`PROJECT_MEMORY.md\`.
    `;

    export const UNIVERSAL_MEMORY_WORKFLOW = `## Agent Memory & Logging Workflow
    This project uses a centralized memory and logging system located in the \`.ai/\` directory. You MUST follow these conventions:

    1. **Context Gathering:** Before starting a task, read \`.ai/memory/PROJECT_MEMORY.md\` to understand architectural constraints.
    2. **Learning:** If you discover a project-specific quirk, bug pattern, or undocumented preference, append a brief note to \`.ai/memory/AUTO_MEMORY.md\`.
    3. **Task Logging:** Document your progress, tools used, and commands run in \`.ai/logs/daily/YYYY-MM-DD.md\`. Create the file if today's log doesn't exist.
    4. **Current Task:** Track your immediate active task in \`.ai/task.md\`.`;

    /**
     * Memory hierarchy levels in strict order.
     * Agents should read and update memory files in this order.
     */
    export const MEMORY_HIERARCHY = [
      {
        level: 1,
        name: 'PROJECT_MEMORY.md',
        path: '.ai/memory/PROJECT_MEMORY.md',
        purpose: 'Architectural decisions, domain rules, "Why"',
        updateRule: 'Propose to user before modifying'
      },
      {
        level: 2,
        name: 'AUTO_MEMORY.md',
        path: '.ai/memory/AUTO_MEMORY.md',
        purpose: 'Heuristics, patterns, gotchas, shortcuts',
        updateRule: 'Append freely, promote to PROJECT_MEMORY.md when appropriate'
      },
      {
        level: 3,
        name: 'Daily Logs',
        path: '.ai/logs/daily/YYYY-MM-DD.md',
        purpose: 'Session activity, what was attempted',
        updateRule: 'Auto-log for significant work'
      },
      {
        level: 4,
        name: 'Tribal Knowledge Archive',
        path: '.ai/archive/tribal-knowledge.md',
        purpose: 'Append-only tribal wisdom',
        updateRule: 'User approval required, append-only'
      },
      {
        level: 5,
        name: 'Current Task',
        path: '.ai/task.md',
        purpose: 'Current active objective',
        updateRule: 'Update as needed'
      }
    ];

    /**
     * Archive retention policy in days.
     * Daily logs older than this are rotated to archive.
     */
    export const ARCHIVE_RETENTION_DAYS = 90;

    /**
     * Tribal knowledge indicators.
     * Signals that suggest undocumented tribal knowledge.
     */
    export const TRIBAL_KNOWLEDGE_INDICATORS = [
      'We always do it this way',
      'undocumented',
      'workaround',
      'implicit',
      'convention',
      'dont touch',
      "don't touch",
      'historical',
      'learned the hard way',
      'team convention',
      'undocumented pattern'
    ];

    /**
     * Auto-log triggers.
     * Activities that should always be logged to daily logs.
     */
    export const AUTO_LOG_TRIGGERS = [
      'multi-step problem solving',
      'root cause discovery',
      'feature implementation',
      'complex debugging',
      'configuration change',
      'schema change',
      'PRD creation',
      'performance optimization',
      'library change',
      'technical debt reduction'
    ];

    /**
     * Archive entry template for tribal knowledge.
     */
    export const ARCHIVE_ENTRY_TEMPLATE = `## [{{DATE}}] {{TITLE}}

    **Category:** {{CATEGORY}}

    **Context:** {{CONTEXT}}

    **The Knowledge:** {{KNOWLEDGE}}

    **Source:** {{SOURCE}}

    **Archived by:** {{AGENT}}, {{DATE}}

    ---
    `;

    /**
     * Memory template file paths.
     */
    export const MEMORY_TEMPLATES = {
      PROJECT_MEMORY: path.join(__dirname, '../templates/memory/PROJECT_MEMORY.md'),
      AUTO_MEMORY: path.join(__dirname, '../templates/memory/AUTO_MEMORY.md'),
      DAILY_LOG: path.join(__dirname, '../templates/memory/daily-log.md'),
      TRIBAL_KNOWLEDGE: path.join(__dirname, '../templates/memory/tribal-knowledge-archive.md'),
      RETIRED_PATTERNS: path.join(__dirname, '../templates/memory/retired-patterns.md'),
      LOG_ARCHIVE_MONTH: path.join(__dirname, '../templates/memory/log-archive-month.md')
    };

    /**
     * YAML-first architecture constants.
     */
    export const YAML_CONSTANTS = {
      DEFAULT_YAML_PATH: 'rosetta.yaml',
      SCHEMA_PATH: path.join(__dirname, '../schemas/rosetta-schema.json'),
      YAML_TEMPLATES_DIR: path.join(__dirname, '../templates/yaml'),
      VERSION: '1.0.0'
    };

    /**
     * IDE generator mapping.
     */
    export const GENERATORS = {
      claude: { classRef: null, path: 'CLAUDE.md' },
      cursor: { classRef: null, path: '.cursorrules' },
      windsurf: { classRef: null, path: '.windsurfrules' }
      // Future: codex, copilot, kilo, continue
    };