MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / getFactsForCwd

Method getFactsForCwd

src/session/store.ts:315–331  ·  view source on GitHub ↗

* Facts to inject for a session in `cwd`: this project's facts PLUS all global * user facts. User facts come first so personal preferences lead. Deduped.

(cwd: string, limit = 50)

Source from the content-addressed store, hash-verified

313 * facts are stored with a '*' sentinel cwd so they never collide with a real path.
314 */
315 addFact(sessionId: string, cwd: string, fact: string, scope: 'project' | 'user' = 'project'): void {
316 this.db.prepare(`INSERT INTO session_facts (session_id, cwd, fact, scope) VALUES (?, ?, ?, ?)`).run(
317 sessionId,
318 scope === 'user' ? '*' : cwd,
319 fact,
320 scope,
321 );
322 }
323
324 /**
325 * Facts to inject for a session in `cwd`: this project's facts PLUS all global
326 * user facts. User facts come first so personal preferences lead. Deduped.
327 */
328 getFactsForCwd(cwd: string, limit = 50): string[] {
329 const userRows = this.db.prepare(
330 `SELECT DISTINCT fact FROM session_facts WHERE scope = 'user' ORDER BY id DESC LIMIT ?`,
331 ).all(limit) as { fact: string }[];
332 const projectRows = this.db.prepare(
333 `SELECT DISTINCT fact FROM session_facts WHERE cwd = ? AND scope = 'project' ORDER BY id DESC LIMIT ?`,
334 ).all(cwd, limit) as { fact: string }[];

Callers 7

index.tsFile · 0.80
executeMethod · 0.80
handleSlashCommandFunction · 0.80
gatherDashboardDataFunction · 0.80
dispatchActionFunction · 0.80
buildInitialMessagesMethod · 0.80

Calls 3

addMethod · 0.80
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected