(projectRoot)
| 679 | return total; |
| 680 | } |
| 681 | |
| 682 | function readHealth(projectRoot) { |
| 683 | const today = new Date().toISOString().slice(0, 10); |
| 684 | const auditPath = path.join(projectRoot, '.planning', 'telemetry', 'audit.jsonl'); |
| 685 | const audit = tailJsonl(auditPath, 500); |
| 686 | const hookConfig = readJson(path.join(projectRoot, 'hooks', 'hooks.json')) || |
| 687 | readJson(path.join(projectRoot, '.claude', 'hooks.json')) || |
| 688 | readJson(path.join(projectRoot, '.claude', 'settings.json')); |
| 689 | const runtime = configControl.detectRuntimeContract(projectRoot); |
| 690 | const effective = configControl.loadActivationContext(projectRoot, { runtime }); |
| 691 | const loaded = configControl.readConfigFile(projectRoot); |
| 692 | const harness = effective.usable |
| 693 | && effective.receipt?.authority.valid |
| 694 | && loaded.raw |
| 695 | && typeof loaded.raw === 'object' |
| 696 | ? loaded.raw |
| 697 | : {}; |
| 698 | const trust = harness.trust || {}; |
| 699 | const sessions = Number(trust.sessionsCompleted ?? trust.sessions_completed ?? 0); |
| 700 | const campaigns = Number(trust.campaignsCompleted ?? trust.campaigns_completed ?? 0); |
| 701 | |
| 702 | let level = 'novice'; |
| 703 | if (sessions >= 20 && campaigns >= 2) level = 'trusted'; |
| 704 | else if (sessions >= 5) level = 'familiar'; |
| 705 | if (trust.override) level = `${trust.override} (override)`; |
| 706 | |
| 707 | return { |
| 708 | auditEntriesToday: audit.filter((entry) => String(eventTimestamp(entry) || '').startsWith(today)).length, |
| 709 | hooksInstalled: countHooksInConfig(hookConfig), |
| 710 | trustLevel: level, |
no test coverage detected