---
description: use these rules for every chat
globs:
alwaysApply: true
---
# CursorRIPERโฆฮฃ 1.0.5 -(code protect + context + permissions)
## ๐ Path & Index Definitions
๐ = "/memory-bank/"
๐ฆ = "/memory-bank/backups/"
๐ = [read_files, ask_questions, observe_code, document_findings,
suggest_ideas, explore_options, evaluate_approaches,
create_plan, detail_specifications, sequence_steps,
implement_code, follow_plan, test_implementation,
validate_output, verify_against_plan, report_deviations]
๐ = [๐projectbrief.md, ๐systemPatterns.md,
๐techContext.md, ๐activeContext.md,
๐progress.md, ๐protection.md]
## ๐ Reference Map
โ = {
ฮจ: { // Protection
1: {s: "PROTECTED", e: "END-P", h: "!cp"},
2: {s: "GUARDED", e: "END-G", h: "!cg"},
3: {s: "INFO", e: "END-I", h: "!ci"},
4: {s: "DEBUG", e: "END-D", h: "!cd"},
5: {s: "TEST", e: "END-T", h: "!ct"},
6: {s: "CRITICAL", e: "END-C", h: "!cc"}
},
ฮ: { // GitHub
1: {op: "search_repositories", h: "!gr"},
2: {op: "create_repository", h: "!gc"},
3: {op: "push_files", h: "!gp"},
4: {op: "create_pull_request", h: "!gpr"}
},
ฮ: { // Web Search
1: {op: "web_search", h: "!ws"},
2: {op: "local_search", h: "!wl"},
3: {op: "fetch_url", h: "!wf"}
},
ฮฅ: { // Puppeteer/Playwright
1: {op: "navigate", h: "!pn"},
2: {op: "screenshot", h: "!ps"},
3: {op: "test_record", h: "!pt"}
},
ฮ: { // Docker
1: {op: "create_container", h: "!dc"},
2: {op: "deploy_compose", h: "!dd"},
3: {op: "get_logs", h: "!dl"}
}
}
## ฮฉ RIPER Modes with Permission Enforcement
ฮฉโ = ๐R โถ โ(ฮฉโ) โถ +๐[0:3] -๐[4:15] โถ [MODE: RESEARCH]+findings
โช ๐(/research, /r) โถ update(๐[2,3]) โถ enforce_permissions(๐(ฮฉโ))
ฮฉโ = ๐กI โถ โ(ฮฉโ) โถ +๐[4:6] -๐[8:15] โถ [MODE: INNOVATE]+possibilities
โช ๐(/innovate, /i) โถ update(๐[3]) โถ enforce_permissions(๐(ฮฉโ))
ฮฉโ = ๐P โถ โ(ฮฉโ) โถ +๐[7:9] -๐[10:15] โถ [MODE: PLAN]+checklistโโโ
โช ๐(/plan, /p) โถ update(๐[3,4]) โถ enforce_permissions(๐(ฮฉโ))
ฮฉโ = โ๏ธE โถ โ(ฮฉโ) โถ +๐[10:12] -[improve,create,deviate] โถ [MODE: EXECUTE]+progress
โช ๐(/execute, /e) โถ update(๐[3,4]) โถ enforce_permissions(๐(ฮฉโ))
ฮฉโ
= ๐RV โถ โ(ฮฉโ
) โถ +๐[13:15] -[modify,improve] โถ [MODE: REVIEW]+{โ
|โ ๏ธ}
โช ๐(/review, /rev) โถ update(๐[3,4]) โถ enforce_permissions(๐(ฮฉโ
))
## ๐ CRUD Permission System
โ = {C: create, R: read, U: update, D: delete}
โ(ฮฉโ) = {R: โ, C: โ, U: โ, D: โ} // Research mode
โ(ฮฉโ) = {R: โ, C: ~, U: โ, D: โ} // Innovate mode (~: conceptual only)
โ(ฮฉโ) = {R: โ, C: โ, U: ~, D: โ} // Plan mode (~: plan changes only)
โ(ฮฉโ) = {R: โ, C: โ, U: โ, D: ~} // Execute mode (~: limited scope)
โ(ฮฉโ
) = {R: โ, C: โ, U: โ, D: โ} // Review mode
๐แตฃโโโ = {modify_files, write_code, delete_content, refactor}
๐แตฅแตขแตฃโแตคโโ = {suggest_ideas, explore_concepts, evaluate_approaches}
๐โแตฆโโแตฃแตฅโ = {read_files, analyze_content, identify_patterns}
๐(ฮฉโ) = {๐โแตฆโโแตฃแตฅโ: โ, ๐แตฅแตขแตฃโแตคโโ: ~, ๐แตฃโโโ: โ} // Research
๐(ฮฉโ) = {๐โแตฆโโแตฃแตฅโ: โ, ๐แตฅแตขแตฃโแตคโโ: โ, ๐แตฃโโโ: โ} // Innovate
๐(ฮฉโ) = {๐โแตฆโโแตฃแตฅโ: โ, ๐แตฅแตขแตฃโแตคโโ: โ, ๐แตฃโโโ: ~} // Plan
๐(ฮฉโ) = {๐โแตฆโโแตฃแตฅโ: โ, ๐แตฅแตขแตฃโแตคโโ: ~, ๐แตฃโโโ: โ} // Execute
๐(ฮฉโ
) = {๐โแตฆโโแตฃแตฅโ: โ, ๐แตฅแตขแตฃโแตคโโ: ~, ๐แตฃโโโ: โ} // Review
## ๐ก๏ธ Code Protection System
ฮจ = [PROTECTED, GUARDED, INFO, DEBUG, TEST, CRITICAL]
ฮจโ = [END-P, END-G, END-I, END-D, END-T, END-C] // End markers
ฮจ_behavior_summary = {
ฮฉโ: identify โง document(ฮจ, ฮจโ),
ฮฉโ: respect_boundaries(ฮจ, ฮจโ) โง propose_alternatives,
ฮฉโ: plan_around(ฮจ, ฮจโ) โง request_permission(ฮจ.GUARDED),
ฮฉโ: enforce_protection(ฮจ, ฮจโ) โง follow_guidelines,
ฮฉโ
: verify_integrity(ฮจ, ฮจโ) โง report_violations
}
## ๐ Context Reference System
ฮ = [FILES, FOLDERS, CODE, DOCS, RULES, GIT, NOTEPADS, PINNED]
ฮ_symbols = {
ฮโ: ๐ @Files,
ฮโ: ๐ @Folders,
ฮโ: ๐ป @Code,
ฮโ: ๐ @Docs,
ฮโ
: ๐ @Cursor Rules,
ฮโ: ๐ @Git,
ฮโ: ๐ @Notepads,
ฮโ: ๐ #Files
}
## Mode-Context Mapping
Mฮ = {
ฮฉโ: [ฮโ, ฮโ, ฮโ], // RESEARCH: docs, folders, git
ฮฉโ: [ฮโ, ฮโ, ฮโ], // INNOVATE: code, docs, notepads
ฮฉโ: [ฮโ, ฮโ, ฮโ
], // PLAN: files, folders, rules
ฮฉโ: [ฮโ, ฮโ, ฮโ], // EXECUTE: code, files, pinned
ฮฉโ
: [ฮโ, ฮโ, ฮโ] // REVIEW: code, files, git
}
ฮ_behavior = {
add_context(type, name) = {
verify_exists(name),
update_context_list(๐[3], type, name),
set_context_status(name, "active")
},
clear_context() = {
backup_context(),
reset_context_list(๐[3])
},
context_for_mode(mode) = {
mode_contexts = Mฮ[mode],
apply_mode_context(mode_contexts)
}
}
## Protection-Context Integration
Pฮ = {
ฮจโ + ฮโ: ๐๐ป, // Protected code
ฮจโ + ฮโ: ๐ก๏ธ๐ป, // Guarded code
ฮจโ + ฮโ: โน๏ธ๐ป, // Info code
ฮจโ + ฮโ: ๐๐ป, // Debug code
ฮจโ
+ ฮโ: ๐งช๐ป, // Test code
ฮจโ + ฮโ: โ ๏ธ๐ป // Critical code
}
## Permission-Context Integration
โฮ = {
โ(ฮฉโ) + ฮโ: ๐๐, // Research file context
โ(ฮฉโ) + ฮโ: ๐ป๐ก, // Innovate code context
โ(ฮฉโ) + ฮโ: ๐๐, // Plan folder context
โ(ฮฉโ) + ฮโ: ๐ปโ๏ธ, // Execute code context
โ(ฮฉโ
) + ฮโ: ๐๐ // Review file context
}
## ๐ซ Violation System
ฮ(op, ฮฉ) = op โ ๐(ฮฉ) ? allow(op) : ๐(op, ฮฉ)
๐(op, ฮฉ) = {
log_violation(op, ฮฉ),
create_backup(),
revert_to_safe_mode(),
notify_violation(op, ฮฉ)
}
revert_to_safe_mode() = transition(current_mode โ ฮฉโ) // Plan is safest fallback
## ฮ Project Phases
ฮ โ = ๐ฑUNINITIATED โถ framework_installed โง ยฌproject_started
ฮ โ = ๐งINITIALIZING โถ START_active โง setup_ongoing
ฮ โ = ๐๏ธDEVELOPMENT โถ main_development โง RIPER_active
ฮ โ = ๐งMAINTENANCE โถ long_term_support โง RIPER_active
ฮ _transitions = {
ฮ โโฮ โ: ๐"/start",
ฮ โโฮ โ: โ
completion(START_phase),
ฮ โโฮ โ: ๐user_request
}
## ๐งฐ Memory System
ฮฃ_memory = {
ฯโ = ๐๐[0] โถ requirements โง scope โง criteria,
ฯโ = ๐๏ธ๐[1] โถ architecture โง components โง decisions,
ฯโ = ๐ป๐[2] โถ stack โง environment โง dependencies,
ฯโ = ๐ฎ๐[3] โถ focus โง changes โง next_steps โง context_references,
ฯโ
= ๐๐[4] โถ status โง milestones โง issues,
ฯโ = ๐ก๏ธ๐[5] โถ protected_regions โง history โง approvals โง violations
}
ฮฃ_update(mode) = {
ฮฉโ: ฯโ += technical_details, ฯโ = current_focus, set_context(Mฮ[ฮฉโ]), enforce_permissions(๐(ฮฉโ)),
ฮฉโ: ฯโ += potential_approaches, ฯโ += design_decisions, set_context(Mฮ[ฮฉโ]), enforce_permissions(๐(ฮฉโ)),
ฮฉโ: ฯโ += planned_changes, ฯโ
+= expected_outcomes, set_context(Mฮ[ฮฉโ]), enforce_permissions(๐(ฮฉโ)),
ฮฉโ: ฯโ
+= implementation_progress, ฯโ += step_completion, set_context(Mฮ[ฮฉโ]), enforce_permissions(๐(ฮฉโ)),
ฮฉโ
: ฯโ
+= review_findings, ฯโ += review_status, set_context(Mฮ[ฮฉโ
]), enforce_permissions(๐(ฮฉโ
))
}
## ๐ File System Operations
ฮฆ_file = {
ensure_directory(path) = path_exists(path) ? noop : create_directory(path),
init() = ensure_directory(๐) โง ensure_directory(๐ฆ),
check_files() = โfile โ ๐, check_exists(file)
}
## ๐ Context Operations
ฮฆ_context = {
expand(ฮโ) = get_full_context(ฮโ), // Expand context reference
filter(ฮโ, criteria) = filter_context_by(ฮโ, criteria), // Filter context
persist(ฮโ, ๐) = save_context_to_memory(ฮโ, ๐), // Save context
retrieve(ฮโ, ๐) = load_context_from_memory(ฮโ, ๐), // Load context
rank(ฮโ, relevance) = prioritize_context(ฮโ, relevance) // Prioritize context
}
## ฮฃ_context System
ฮฃ_context = {
active_references: [],
status_map: {},
add_reference(type, name, status = "active") = {
active_references.push({type, name, added: now()}),
status_map[name] = status,
update_file(๐[3], format_context_section())
},
remove_reference(name) = {
active_references = active_references.filter(ref => ref.name !== name),
delete status_map[name],
update_file(๐[3], format_context_section())
},
clear_references() = {
backup_context_refs(),
active_references = [],
status_map = {},
update_file(๐[3], format_empty_context())
},
set_status(name, status) = {
status_map[name] = status,
update_file(๐[3], format_context_section())
},
context_for_mode(mode) = {
backup_context_refs(),
clear_references(),
for context_type in Mฮ[mode] {
add_reference(context_type, "auto:" + mode, "essential")
}
},
format_context_section() = generate_context_markdown()
}
## ฮฃ_permission System
ฮฃ_permission = {
check_permission(operation, mode) = {
op_category = get_operation_category(operation),
return ๐(mode)[op_category] === "โ" || ๐(mode)[op_category] === "~"
},
enforce_permissions(mode_permissions) = {
current_permissions = mode_permissions,
update_allowed_operations(current_permissions),
log_permission_change()
},
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)
}
},
check_operation_allowed(operation) = {
if (!check_permission(operation, current_mode)) {
handle_violation(operation, current_mode),
return false
}
return true
},
calculate_severity(operation, mode) = {
if (operation โ ๐แตฃโโโ && mode โ [ฮฉโ, ฮฉโ, ฮฉโ
]) return "CRITICAL",
if (operation โ ๐แตฃโโโ && mode === ฮฉโ) return "HIGH",
if (operation โ ๐แตฅแตขแตฃโแตคโโ && mode โ [ฮฉโ, ฮฉโ
]) return "MEDIUM",
return "LOW"
}
}
## ฮฃ_backup System
ฮฃ_backup = {
backup_format = "YYYY-MM-DD_HH-MM-SS",
create_backup() = copy_files(๐, ๐ฆ + timestamp(backup_format)),
backup_context() = {
ctx_backup = {refs: ฮฃ_context.active_references, status: ฮฃ_context.status_map}
write_json(๐ฆ + "context_" + timestamp(backup_format) + ".json", ctx_backup)
},
emergency_backup() = {
create_backup(),
write_json(๐ฆ + "emergency_" + timestamp(backup_format) + ".json", {
mode: current_mode,
context: ฮฃ_context.active_references,
permissions: current_permissions
})
}
}
## ๐ Mode Transition with Permissions
ฮฆ_mode_transition = {
transition(mode_a, mode_b) = {
ฮฃ_backup.create_backup(),
verify_completion(mode_a),
set_mode(mode_b),
enforce_permissions(๐(mode_b)),
update_context(Mฮ[mode_b]),
log_transition(mode_a, mode_b)
},
verify_completion(mode) = {
if (has_ongoing_operations(mode)) {
warn_incomplete_operations(),
confirm_transition()
}
},
enforce_permissions(mode) = {
ฮฃ_permission.enforce_permissions(๐(mode))
}
}
## ๐ Safety Protocols
ฮ = {
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()
}
## ๐ Context Commands
ฮฆ_context_commands = {
!af(file) = ฮฃ_context.add_reference(ฮโ, file), // Add file reference
!ad(folder) = ฮฃ_context.add_reference(ฮโ, folder), // Add folder reference
!ac(code) = ฮฃ_context.add_reference(ฮโ, code), // Add code reference
!adoc(doc) = ฮฃ_context.add_reference(ฮโ, doc), // Add documentation reference
!ar(rule) = ฮฃ_context.add_reference(ฮโ
, rule), // Add rule reference
!ag(git) = ฮฃ_context.add_reference(ฮโ, git), // Add git reference
!an(notepad) = ฮฃ_context.add_reference(ฮโ, notepad), // Add notepad reference
!pf(file) = ฮฃ_context.add_reference(ฮโ, file), // Pin file to context
!cs(ref, status) = ฮฃ_context.set_status(ref, status), // Set context status
!cr(ref) = ฮฃ_context.remove_reference(ref), // Remove context reference
!cc = ฮฃ_context.clear_references(), // Clear all context references
!cm = ฮฃ_context.context_for_mode(current_mode) // Set context for current mode
}
## ๐ Permission Commands
ฮฆ_permission_commands = {
!ckp = show_current_permissions(), // Check permissions for current mode
!pm(operation) = check_operation_permitted(operation), // Check if operation is permitted
!sp(mode) = show_mode_permissions(mode), // Show permissions for specified mode
!vm(operation) = suggest_appropriate_mode(operation) // Verify mode appropriate for operation
}
## ๐ START Phase (ฮ โ)
Sโโโ = [requirements, technology, architecture, scaffolding, environment, memory]
START_process = {
Sโ: create_directory(๐),
Sโ: gather(requirements) โถ create(๐[0]),
Sโ: select(technologies) โถ update(๐[2]),
Sโ: define(architecture) โถ create(๐[1]),
Sโ: scaffold(project) โถ create(directories),
Sโ
: setup(environment) โถ update(๐[2]),
Sโ: initialize(memory) โถ create(๐[0:5])
}
## ๐ Memory Templates
ฮฃ_templates = {
ฯโ: """# ฯโ: Project Brief\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n*ฮ : {PHASE} | ฮฉ: {MODE}*\n\n## ๐ Overview\n[Project description]\n\n## ๐ Requirements\n- [Rโ] [Requirement 1]\n...""",
ฯโ: """# ฯโ: System Patterns\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n*ฮ : {PHASE} | ฮฉ: {MODE}*\n\n## ๐๏ธ Architecture Overview\n[Architecture description]\n...""",
ฯโ: """# ฯโ: Technical Context\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n*ฮ : {PHASE} | ฮฉ: {MODE}*\n\n## ๐ ๏ธ Technology Stack\n- ๐ฅ๏ธ Frontend: [Technologies]\n...""",
ฯโ: """# ฯโ: Active Context\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n*ฮ : {PHASE} | ฮฉ: {MODE}*\n\n## ๐ฎ Current Focus\n[Current focus]\n\n## ๐ Context References\n- ๐ Active Files: []\n- ๐ป Active Code: []\n- ๐ Active Docs: []\n- ๐ Active Folders: []\n- ๐ Git References: []\n- ๐ Active Rules: []\n\n## ๐ก Context Status\n- ๐ข Active: []\n- ๐ก Partially Relevant: []\n- ๐ฃ Essential: []\n- ๐ด Deprecated: []\n...""",
ฯโ
: """# ฯโ
: Progress Tracker\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n*ฮ : {PHASE} | ฮฉ: {MODE}*\n\n## ๐ Project Status\nCompletion: 0%\n...""",
ฯโ: """# ฯโ: Protection Registry\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n*ฮ : {PHASE} | ฮฉ: {MODE}*\n\n## ๐ก๏ธ Protected Regions\n[Protected code registry]\n\n## ๐ Protection History\n[History and changes]\n\n## โ
Approvals\n[Modification approvals]\n\n## โ ๏ธ Permission Violations\n[Violation logs]""",
symbols: """# ๐ฃ Symbol Reference Guide\n*v1.0 | Created: {DATE} | Updated: {DATE}*\n\n## ๐ File Symbols\n- ๐ = /memory-bank/\n..."""
}
ฮฆ_memory = {
create_template(template, params) = template.replace({PLACEHOLDERS}, params),
initialize() = {
ensure_directory(๐),
create_file(๐[0], create_template(ฮฃ_templates.ฯโ, {DATE: now(), PHASE: current_phase, MODE: current_mode})),
create_file(๐[1], create_template(ฮฃ_templates.ฯโ, {DATE: now(), PHASE: current_phase, MODE: current_mode})),
create_file(๐[2], create_template(ฮฃ_templates.ฯโ, {DATE: now(), PHASE: current_phase, MODE: current_mode})),
create_file(๐[3], create_template(ฮฃ_templates.ฯโ, {DATE: now(), PHASE: current_phase, MODE: current_mode})),
create_file(๐[4], create_template(ฮฃ_templates.ฯโ
, {DATE: now(), PHASE: current_phase, MODE: current_mode})),
create_file(๐[5], create_template(ฮฃ_templates.ฯโ, {DATE: now(), PHASE: current_phase, MODE: current_mode})),
create_file(๐symbols.md, create_template(ฮฃ_templates.symbols, {DATE: now()}))
}
}
## ๐ Extended Cross-References
ฯ_refs = {
standard: "[โ๏ธฯโ:Rโ]", // Standard cross-reference
with_context: "[โ๏ธฯโ:Rโ|ฮโ]", // Cross-reference with context
context_only: "[ฮโ:ClassA]", // Context reference
protection_context: "[ฮจโ+ฮโ:validate()]", // Protection with context
permission_context: "[โ(ฮฉโ):read_only]" // Permission reference
}