Derive a subject URI from a vault path and entry type.
(path: &str, entry_type: VaultEntryType)
| 518 | |
| 519 | /// Derive a subject URI from a vault path and entry type. |
| 520 | fn entry_subject(path: &str, entry_type: VaultEntryType) -> String { |
| 521 | match entry_type { |
| 522 | VaultEntryType::Session => { |
| 523 | // goals/swift-meadow-a3f2/_goal.md -> goal:swift-meadow-a3f2 |
| 524 | let name = path |
| 525 | .strip_prefix("goals/") |
| 526 | .and_then(|s| s.strip_suffix("/_goal.md")) |
| 527 | .unwrap_or(path); |
| 528 | format!("goal:{}", name) |
| 529 | } |
| 530 | VaultEntryType::Intent => { |
| 531 | // intents/pimo-1/intent.md -> intent:PIMO-1 |
| 532 | let id = path |
| 533 | .strip_prefix("intents/") |
| 534 | .and_then(|s| s.strip_suffix("/intent.md")) |
| 535 | .unwrap_or(path) |
| 536 | .to_uppercase(); |
| 537 | format!("intent:{}", id) |
| 538 | } |
| 539 | VaultEntryType::Memory => { |
| 540 | // memory/architecture.md -> memory:architecture |
| 541 | let name = path |
| 542 | .strip_prefix("memory/") |
| 543 | .and_then(|s| s.strip_suffix(".md")) |
| 544 | .unwrap_or(path); |
| 545 | format!("memory:{}", name) |
| 546 | } |
| 547 | VaultEntryType::Skill => { |
| 548 | let name = path |
| 549 | .strip_prefix("skills/") |
| 550 | .and_then(|s| s.strip_suffix(".md")) |
| 551 | .unwrap_or(path); |
| 552 | format!("skill:{}", name) |
| 553 | } |
| 554 | VaultEntryType::ToolResult => { |
| 555 | format!("tool:{}", path.replace('/', ":")) |
| 556 | } |
| 557 | VaultEntryType::Scratch => { |
| 558 | format!("scratch:{}", path.replace('/', ":")) |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | /// Convert a vault path to a subject URI (simplified). |
| 564 | fn path_to_subject(path: &str) -> String { |
no outgoing calls
no test coverage detected