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

Function recommendNextScope

src/cli/maintain-stats.ts:62–76  ·  view source on GitHub ↗
(
  runs: MaintainRun[],
  stats: MaintainStats,
  allScopes: readonly string[],
)

Source from the content-addressed store, hash-verified

60/** Auto-recommend the next scope to run, with a reason. Prefers a never-run scope; else the scope
61 * blocking most often (a backlog it can't currently clear); else the least-used. PURE. */
62export function recommendNextScope(
63 runs: MaintainRun[],
64 stats: MaintainStats,
65 allScopes: readonly string[],
66): { scope: string; why: string } | null {
67 const never = suggestNextScopes(stats, allScopes);
68 if (never.length) return { scope: never[0]!, why: 'never run here yet — try it' };
69 // count blocks per scope (a scope that keeps blocking has a backlog worth a look)
70 const blocks = new Map<string, number>();
71 for (const r of runs) if (r.status === 'blocked') blocks.set(r.scope, (blocks.get(r.scope) ?? 0) + 1);
72 const topBlock = [...blocks.entries()].sort((a, b) => b[1] - a[1])[0];
73 if (topBlock && topBlock[1] >= 2) return { scope: topBlock[0], why: `blocked ${topBlock[1]}× recently — review the backlog` };
74 const leastUsed = [...stats.byScope].sort((a, b) => a.runs - b.runs)[0];
75 return leastUsed ? { scope: leastUsed.scope, why: 'least-exercised scope' } : null;
76}
77
78export interface MaintainWeekly {
79 opened: number; blocked: number; filesCleaned: number; minutesSaved: number;

Callers 4

index.tsFile · 0.85
gatherDashboardDataFunction · 0.85

Calls 3

suggestNextScopesFunction · 0.85
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected