MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / load_from_directory

Method load_from_directory

crates/opencode-session/src/instruction.rs:467–504  ·  view source on GitHub ↗

Load instruction files from a single directory (original API).

(dir: &Path)

Source from the content-addressed store, hash-verified

465
466 /// Load instruction files from a single directory (original API).
467 pub fn load_from_directory(dir: &Path) -> Vec<InstructionFile> {
468 let mut instructions = Vec::new();
469
470 if let Ok(content) = std::fs::read_to_string(dir.join(AGENTS_MD)) {
471 instructions.push(InstructionFile {
472 path: AGENTS_MD.to_string(),
473 content,
474 source: InstructionSource::AgentsMd,
475 });
476 }
477
478 if let Ok(content) = std::fs::read_to_string(dir.join(CLAUDE_MD)) {
479 instructions.push(InstructionFile {
480 path: CLAUDE_MD.to_string(),
481 content,
482 source: InstructionSource::ClaudeMd,
483 });
484 }
485
486 if let Ok(content) = std::fs::read_to_string(dir.join(CURSOR_MD)) {
487 instructions.push(InstructionFile {
488 path: CURSOR_MD.to_string(),
489 content,
490 source: InstructionSource::CursorRules,
491 });
492 }
493
494 let copilot_path = dir.join(".github").join("copilot-instructions.md");
495 if let Ok(content) = std::fs::read_to_string(&copilot_path) {
496 instructions.push(InstructionFile {
497 path: COPILOT_MD.to_string(),
498 content,
499 source: InstructionSource::CopilotInstructions,
500 });
501 }
502
503 instructions
504 }
505
506 pub fn merge_instructions(instructions: &[InstructionFile]) -> String {
507 instructions

Callers

nothing calls this directly

Calls 1

newFunction · 0.85

Tested by

no test coverage detected