MCPcopy Create free account
hub / github.com/Eversmile12/sharedcontext / simplifyKey

Function simplifyKey

src/core/engine.ts:94–114  ·  view source on GitHub ↗

* Strip the scope prefix from a fact key to get a short, readable label. * "project:sharedcontext:storage:backend" → "storage backend" * "global:coding_style" → "coding style"

(key: string, scope: string)

Source from the content-addressed store, hash-verified

92 * "global:coding_style""coding style"
93 */
94function simplifyKey(key: string, scope: string): string {
95 let simplified = key;
96
97 // Remove scope prefix: "project:sharedcontext:" or "global:"
98 if (scope.startsWith("project:")) {
99 const prefix = scope.replace("project:", "") + ":";
100 if (simplified.startsWith(prefix)) {
101 simplified = simplified.slice(prefix.length);
102 }
103 }
104 if (simplified.startsWith("global:")) {
105 simplified = simplified.slice("global:".length);
106 }
107 // Also strip a leading project name if the key was "project:name:rest"
108 if (simplified.startsWith("project:")) {
109 simplified = simplified.replace(/^project:[^:]+:/, "");
110 }
111
112 // Replace remaining colons and underscores with spaces
113 return simplified.replace(/[:_]/g, " ").trim();
114}
115
116/**
117 * Format facts as a context string for injection into an LLM prompt.

Callers 1

formatContextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected