Skip to content

API Reference

Saros Industries edited this page Jun 28, 2025 · 1 revision

📖 API Reference

Complete API reference for the CursorRIPER♦Σ framework functions, operations, and system interfaces.

🎯 API Overview

The framework API consists of:

  • System Functions (Σ) - Core memory and state management
  • File Operations (Φ) - File system interactions
  • Context Operations (Γ) - Context management
  • Protection Functions (Ψ) - Code protection
  • Permission Functions (ℙ) - Access control

📦 System Functions (Σ)

Σ_memory

Core memory system management.

Σ_memory = {
  σ₁: "projectbrief.md",
  σ₂: "systemPatterns.md",
  σ₃: "techContext.md",
  σ₄: "activeContext.md",
  σ₅: "progress.md",
  σ₆: "protection.md"
}

Σ_update(mode)

Updates memory files based on current mode.

Σ_update(mode) = {
  Ω₁: σ₃ += technical_details, σ₄ = current_focus,
  Ω₂: σ₄ += potential_approaches, σ₂ += design_decisions,
  Ω₃: σ₄ += planned_changes, σ₅ += expected_outcomes,
  Ω₄: σ₅ += implementation_progress, σ₄ += step_completion,
  Ω₅: σ₅ += review_findings, σ₄ += review_status
}

Parameters:

  • mode - Current RIPER mode (Ω₁-Ω₅)

Returns: Updated memory state

Σ_backup

Backup system operations.

Σ_backup = {
  create_backup() = copy_files(𝕄, 📦 + timestamp),
  backup_context() = save_context_state(),
  emergency_backup() = full_state_snapshot()
}

create_backup()

Creates timestamped backup of all memory files.

Returns: Backup path

backup_context()

Saves current context state.

backup_context() = {
  ctx_backup = {
    refs: Σ_context.active_references,
    status: Σ_context.status_map
  },
  write_json(path, ctx_backup)
}

emergency_backup()

Creates emergency state snapshot.

emergency_backup() = {
  create_backup(),
  save_state({
    mode: current_mode,
    context: Σ_context.active_references,
    permissions: current_permissions,
    last_operation: last_op,
    error_state: current_error
  })
}

📂 File Operations (Φ)

Φ_file

Basic file system operations.

Φ_file = {
  ensure_directory(path),
  init(),
  check_files()
}

ensure_directory(path)

Creates directory if it doesn't exist.

Parameters:

  • path - Directory path

Returns: Success boolean

init()

Initializes memory bank structure.

init() = {
  ensure_directory(📂),
  ensure_directory(📦)
}

check_files()

Verifies all memory files exist.

Returns: Validation report

Φ_memory

Memory file operations.

Φ_memory = {
  create_template(template, params),
  initialize()
}

create_template(template, params)

Creates file from template.

Parameters:

  • template - Template string
  • params - Replacement parameters

Returns: Formatted content

initialize()

Creates all memory files from templates.

initialize() = {
  ensure_directory(📂),
  create_file(σ₁, template_σ₁),
  create_file(σ₂, template_σ₂),
  // ... all memory files
}

Φ_mode_transition

Mode transition operations.

Φ_mode_transition = {
  transition(mode_a, mode_b),
  verify_completion(mode),
  enforce_permissions(mode)
}

transition(mode_a, mode_b)

Executes mode transition.

transition(mode_a, mode_b) = {
  Σ_backup.create_backup(),
  verify_completion(mode_a),
  set_mode(mode_b),
  enforce_permissions(𝕊(mode_b)),
  update_context([mode_b]),
  log_transition(mode_a, mode_b)
}

Parameters:

  • mode_a - Current mode
  • mode_b - Target mode

Returns: Transition success

📎 Context Operations (Γ)

Σ_context

Context management system.

Σ_context = {
  active_references: [],
  status_map: {},
  add_reference(type, name, status),
  remove_reference(name),
  clear_references(),
  set_status(name, status),
  context_for_mode(mode)
}

add_reference(type, name, status)

Adds item to active context.

Parameters:

  • type - Context type (Γ₁-Γ₈)
  • name - Item identifier
  • status - Optional status (default: "active")

Example:

add_reference(Γ₁, "src/auth.js", "active")

remove_reference(name)

Removes item from context.

Parameters:

  • name - Item to remove

clear_references()

Clears all context references.

clear_references() = {
  backup_context_refs(),
  active_references = [],
  status_map = {},
  update_file(σ₄)
}

set_status(name, status)

Updates context item status.

Parameters:

  • name - Item identifier
  • status - New status ("active"|"partial"|"essential"|"deprecated")

context_for_mode(mode)

Sets mode-appropriate context.

context_for_mode(mode) = {
  clear_references(),
  for context_type in [mode] {
    add_reference(context_type, "auto:" + mode, "essential")
  }
}

Φ_context

Advanced context operations.

Φ_context = {
  expand(Γₙ),
  filter(Γₙ, criteria),
  persist(Γₙ, 📂),
  retrieve(Γₙ, 📂),
  rank(Γₙ, relevance)
}

expand(Γₙ)

Expands context reference to full details.

Parameters:

  • Γₙ - Context type

Returns: Expanded context

filter(Γₙ, criteria)

Filters context by criteria.

Parameters:

  • Γₙ - Context type
  • criteria - Filter criteria

Returns: Filtered context

🛡️ Protection Functions (Ψ)

Protection Behavior

Mode-specific protection behavior.

Ψ_behavior_summary = {
  Ω₁: identify  document(Ψ, Ψ₊),
  Ω₂: respect_boundaries(Ψ, Ψ₊)  propose_alternatives,
  Ω₃: plan_around(Ψ, Ψ₊)  request_permission(Ψ.GUARDED),
  Ω₄: enforce_protection(Ψ, Ψ₊)  follow_guidelines,
  Ω₅: verify_integrity(Ψ, Ψ₊)  report_violations
}

Protection Levels

Ψ = [PROTECTED, GUARDED, INFO, DEBUG, TEST, CRITICAL]
Ψ₊ = [END-P, END-G, END-I, END-D, END-T, END-C]

Protection Commands

Quick protection application.

protection_commands = {
  "!cp": add_protection(Ψ₁),
  "!cg": add_protection(Ψ₂),
  "!ci": add_protection(Ψ₃),
  "!cd": add_protection(Ψ₄),
  "!ct": add_protection(Ψ₅),
  "!cc": add_protection(Ψ₆)
}

🔐 Permission Functions (ℙ)

Σ_permission

Permission management system.

Σ_permission = {
  check_permission(operation, mode),
  enforce_permissions(mode_permissions),
  handle_violation(operation, mode),
  check_operation_allowed(operation),
  calculate_severity(operation, mode)
}

check_permission(operation, mode)

Verifies operation permission.

Parameters:

  • operation - Operation to check
  • mode - Current mode

Returns: Boolean allowed

check_permission(operation, mode) = {
  op_category = get_operation_category(operation),
  return 𝕊(mode)[op_category] === "✓" || 
         𝕊(mode)[op_category] === "~"
}

enforce_permissions(mode_permissions)

Updates active permissions.

Parameters:

  • mode_permissions - Permission set

handle_violation(operation, mode)

Handles permission violation.

handle_violation(operation, mode) = {
  severity = calculate_severity(operation, mode),
  log_violation_to_registry(operation, mode, severity),
  if (severity === "CRITICAL" || severity === "HIGH") {
    Σ_backup.create_backup(),
    safe_transition(mode, Ω₃)
  } else {
    notify_violation(operation, mode, severity)
  }
}

calculate_severity(operation, mode)

Determines violation severity.

Returns: "CRITICAL"|"HIGH"|"MEDIUM"|"LOW"

Permission Check Function

Main permission verification.

Ξ(op, Ω) = op  𝕊(Ω) ? allow(op) : 𝕍(op, Ω)

🔄 Operation Sets

Operation Categories

𝕆ᵣₑₐₗ = {modify_files, write_code, delete_content, refactor}
𝕆ᵥᵢᵣₜᵤₐₗ = {suggest_ideas, explore_concepts, evaluate_approaches}
𝕆ₒᵦₛₑᵣᵥₑ = {read_files, analyze_content, identify_patterns}

Mode Operation Sets

𝕊(Ω) = {
  Ω₁: {𝕆ₒᵦₛₑᵣᵥₑ: , 𝕆ᵥᵢᵣₜᵤₐₗ: ~, 𝕆ᵣₑₐₗ: },
  Ω₂: {𝕆ₒᵦₛₑᵣᵥₑ: , 𝕆ᵥᵢᵣₜᵤₐₗ: , 𝕆ᵣₑₐₗ: },
  Ω₃: {𝕆ₒᵦₛₑᵣᵥₑ: , 𝕆ᵥᵢᵣₜᵤₐₗ: , 𝕆ᵣₑₐₗ: ~},
  Ω₄: {𝕆ₒᵦₛₑᵣᵥₑ: , 𝕆ᵥᵢᵣₜᵤₐₗ: ~, 𝕆ᵣₑₐₗ: },
  Ω₅: {𝕆ₒᵦₛₑᵣᵥₑ: , 𝕆ᵥᵢᵣₜᵤₐₗ: ~, 𝕆ᵣₑₐₗ: }
}

🔄 Safety Protocols (Δ)

Protocol Definitions

Δ = {
  1: destructive_op(x)  warn  confirm  Σ_backup.create_backup(),
  2: phase_transition(x)  verify  Σ_backup.create_backup()  update,
  3: permission_violation(op)  𝕍(op, current_mode),
  4: error(x)  report("Framework issue: " + x)  suggest_recovery(x),
  5: context_change()  Σ_backup.backup_context()  update_context_references()
}

📐 Utility Functions

Cross-Reference Functions

create_reference(file, item) = "[↗️" + file + ":" + item + "]"
create_context_ref(file, item, context) = "[↗️" + file + ":" + item + "|" + context + "]"
validate_reference(ref) = check_target_exists(ref)

Mode Functions

get_current_mode() = current_mode
is_mode_allowed(mode) = mode  [Ω₁, Ω₂, Ω₃, Ω₄, Ω₅]
get_mode_name(mode) = mode_names[mode]

Status Functions

get_framework_status() = {
  version: "1.0.5",
  phase: current_phase,
  mode: current_mode,
  memory_health: check_memory_health(),
  context_size: Σ_context.active_references.length
}

🎮 Command API

Command Registration

register_command(pattern, handler) = {
  commands[pattern] = handler
}

Command Execution

execute_command(input) = {
  command = parse_command(input),
  if (check_permission(command, current_mode)) {
    return commands[command.pattern](command.args)
  } else {
    handle_violation(command, current_mode)
  }
}

🔌 Extension Points

Custom Functions

Add custom functionality:

extend_framework(name, implementation) = {
  if (!framework[name]) {
    framework[name] = implementation
  }
}

Hook System

hooks = {
  before_mode_transition: [],
  after_mode_transition: [],
  before_backup: [],
  after_backup: [],
  on_violation: []
}

add_hook(event, handler) = {
  hooks[event].push(handler)
}

📊 Metrics API

Collection Functions

metrics = {
  track_transition(from, to) = log_metric("transition", {from, to}),
  track_violation(op, mode) = log_metric("violation", {op, mode}),
  track_command(cmd) = log_metric("command", {cmd})
}

Reporting Functions

generate_report() = {
  transitions: count_transitions(),
  violations: count_violations(),
  commands: count_commands(),
  mode_time: calculate_mode_time()
}

🚨 Error Handling

Error Types

FrameworkError = class extends Error {}
PermissionError = class extends FrameworkError {}
TransitionError = class extends FrameworkError {}
ContextError = class extends FrameworkError {}

Error Recovery

recover_from_error(error) = {
  if (error instanceof PermissionError) {
    suggest_mode_switch(error.required_mode)
  } else if (error instanceof TransitionError) {
    rollback_transition()
  } else {
    emergency_backup()  report_error(error)
  }
}

📚 Related Topics


← Permission Matrix | Home | MCP Integration →

🚀 Getting Started


🧠 Core Concepts


⚡ Features


📖 Guides


📋 Reference


🔌 Advanced

MCP Integration

BMAD Enterprise


🔧 Troubleshooting

Quick Navigation

🚨 Emergency Procedures

📋 Common Issues

Installation & Setup

  • Installation Issues
    • Node.js Version Compatibility
    • Package Installation Failures
    • Framework Dependencies Missing
    • Database Connection Issues
    • Port Conflicts
    • Environment Setup Issues
    • Build and Development Issues
    • Framework CLI Issues

Configuration & Runtime

  • Configuration & Runtime Issues
    • Framework Configuration Problems
    • Runtime Performance Issues
    • Module Loading and Plugin Issues
    • Database and Storage Issues
    • Memory Leaks and High Memory Usage
    • High CPU Usage

BMAD Module

  • BMAD Module Issues
    • BMAD Module Initialization Problems
    • Business Model Canvas Issues
    • Stakeholder Management Issues
    • Analytics and Reporting Issues
    • Performance Optimization

Database & API

  • Database & API Issues
    • Database Connection Problems
    • Database Migration Issues
    • API Performance and Reliability Issues
    • Data Consistency Issues
    • Transaction Problems

Performance & Memory

Security & Authentication

  • Security & Authentication Issues
    • Authentication Failures
    • Authorization Problems
    • JWT Token Issues
    • Session Management
    • CORS and Security Headers
    • SSL/TLS Configuration

Deployment & Production

  • Deployment & Production Issues
    • Production Deployment Failures
    • Environment Configuration
    • Load Balancing Issues
    • Monitoring and Logging
    • Backup and Recovery

Information to Gather

When reporting issues, please include:

  • Framework version (npm list @cursoriper/core)
  • Node.js version (node --version)
  • Operating system and version
  • Error messages and stack traces
  • Steps to reproduce the issue
  • Configuration files (sanitized)
  • Recent changes or deployments

Tech Docs & Suport


📞 Support & Community


📋 Release Notes

Last Updated: June 28, 2025
Framework Version: CursorRIPER.sigma v1.0+

For the original verbose framework, see CursorRIPER

← Back to Home

Clone this wiki locally