@unerr-ai/unerr 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/cli.js +37236 -35793
- package/package.json +6 -1
- package/dist/behaviors/agent-llm-bridge.js +0 -166
- package/dist/behaviors/architecture-guard.js +0 -256
- package/dist/behaviors/auto-doc.js +0 -247
- package/dist/behaviors/cascade-guard.js +0 -289
- package/dist/behaviors/change-narrative.js +0 -270
- package/dist/behaviors/convention-drift.js +0 -290
- package/dist/behaviors/framework.js +0 -235
- package/dist/behaviors/guard-formatter.js +0 -44
- package/dist/behaviors/incomplete-work.js +0 -270
- package/dist/behaviors/loop-breaker.js +0 -300
- package/dist/behaviors/session-continuity.js +0 -208
- package/dist/commands/branches.js +0 -97
- package/dist/commands/check-commit.js +0 -225
- package/dist/commands/compress-output.js +0 -64
- package/dist/commands/config-verify.js +0 -243
- package/dist/commands/daemon.js +0 -905
- package/dist/commands/dashboard.js +0 -52
- package/dist/commands/debug.js +0 -200
- package/dist/commands/enrich.js +0 -184
- package/dist/commands/exec.js +0 -233
- package/dist/commands/gain.js +0 -156
- package/dist/commands/hook.js +0 -88
- package/dist/commands/index.js +0 -88
- package/dist/commands/init.js +0 -74
- package/dist/commands/install.js +0 -505
- package/dist/commands/learn.js +0 -116
- package/dist/commands/manifest.js +0 -193
- package/dist/commands/rewind.js +0 -103
- package/dist/commands/serve.js +0 -19
- package/dist/commands/setup-wizard.js +0 -414
- package/dist/commands/skills.js +0 -64
- package/dist/commands/stats.js +0 -20
- package/dist/commands/status.js +0 -654
- package/dist/commands/timeline.js +0 -139
- package/dist/commands/uninstall.js +0 -230
- package/dist/components/App.js +0 -109
- package/dist/components/Banner.js +0 -12
- package/dist/components/ConfirmPrompt.js +0 -25
- package/dist/components/DriftSummary.js +0 -23
- package/dist/components/GradeBadge.js +0 -15
- package/dist/components/HealthCard.js +0 -18
- package/dist/components/InkSpinner.js +0 -22
- package/dist/components/InputBox.js +0 -17
- package/dist/components/KeyValue.js +0 -13
- package/dist/components/MessageList.js +0 -14
- package/dist/components/ProgressBar.js +0 -26
- package/dist/components/Section.js +0 -16
- package/dist/components/SessionSummaryCard.js +0 -73
- package/dist/components/StartupDisplay.js +0 -24
- package/dist/components/StatusDashboard.js +0 -57
- package/dist/components/StatusLine.js +0 -8
- package/dist/components/StepLine.js +0 -22
- package/dist/components/Theme.js +0 -20
- package/dist/components/ToolProgress.js +0 -8
- package/dist/components/ViolationList.js +0 -21
- package/dist/components/render.js +0 -13
- package/dist/config/agent-registry.js +0 -237
- package/dist/config/claude-settings-hooks.js +0 -304
- package/dist/config/hook-installer.js +0 -65
- package/dist/config/instruction-writer.js +0 -388
- package/dist/config/mcp-config-writer.js +0 -266
- package/dist/config/settings.js +0 -174
- package/dist/config/tool-detector.js +0 -42
- package/dist/config/value-surfacing.js +0 -119
- package/dist/core/context-assembly.js +0 -108
- package/dist/core/conversation.js +0 -33
- package/dist/core/local-chat-provider.js +0 -475
- package/dist/core/provider-factory.js +0 -55
- package/dist/core/providers.js +0 -90
- package/dist/core/query-engine.js +0 -174
- package/dist/daemon/api.js +0 -312
- package/dist/daemon/autostart.js +0 -119
- package/dist/daemon/bootstrap.js +0 -39
- package/dist/daemon/client.js +0 -164
- package/dist/daemon/detect-ci.js +0 -81
- package/dist/daemon/platform-linux.js +0 -146
- package/dist/daemon/platform-macos.js +0 -134
- package/dist/daemon/platform-windows.js +0 -116
- package/dist/daemon/process-manager.js +0 -299
- package/dist/daemon/protocol.js +0 -23
- package/dist/daemon/registry.js +0 -270
- package/dist/daemon/settings-schema.js +0 -72
- package/dist/daemon/system-health.js +0 -134
- package/dist/daemon/version-checker.js +0 -262
- package/dist/daemon/warm-start.js +0 -223
- package/dist/entrypoints/cli.js +0 -1043
- package/dist/entrypoints/daemon.js +0 -380
- package/dist/entrypoints/repl.js +0 -147
- package/dist/hooks/adapters/claude-code.js +0 -90
- package/dist/hooks/adapters/cline.js +0 -100
- package/dist/hooks/adapters/cursor.js +0 -98
- package/dist/hooks/hook-dedup.js +0 -79
- package/dist/hooks/hook-runner.js +0 -113
- package/dist/hooks/navigation-hooks.js +0 -175
- package/dist/hooks/prompt-hooks.js +0 -63
- package/dist/hooks/shell-hooks.js +0 -47
- package/dist/ignore.js +0 -111
- package/dist/intelligence/approach-suggester.js +0 -61
- package/dist/intelligence/ast-extractor.js +0 -2615
- package/dist/intelligence/ast-worker.js +0 -34
- package/dist/intelligence/background-indexer.js +0 -121
- package/dist/intelligence/blast-radius.js +0 -200
- package/dist/intelligence/community-detection.js +0 -691
- package/dist/intelligence/community-detector.js +0 -184
- package/dist/intelligence/computation-scheduler.js +0 -75
- package/dist/intelligence/confidence-propagation.js +0 -47
- package/dist/intelligence/convention-detector.js +0 -242
- package/dist/intelligence/convention-learner.js +0 -205
- package/dist/intelligence/convention-matcher.js +0 -205
- package/dist/intelligence/cozo-schema.js +0 -376
- package/dist/intelligence/decision-point-detector.js +0 -90
- package/dist/intelligence/deep-dive-tools.js +0 -586
- package/dist/intelligence/durability-scorer.js +0 -84
- package/dist/intelligence/exploration-cost.js +0 -204
- package/dist/intelligence/exploration-pattern-tracker.js +0 -61
- package/dist/intelligence/fact-generator.js +0 -322
- package/dist/intelligence/facts-schema.js +0 -90
- package/dist/intelligence/file-intelligence.js +0 -59
- package/dist/intelligence/graph-holder.js +0 -220
- package/dist/intelligence/graph-temporal-joiner.js +0 -238
- package/dist/intelligence/health-grade.js +0 -423
- package/dist/intelligence/health-grader.js +0 -200
- package/dist/intelligence/health-map-data.js +0 -259
- package/dist/intelligence/import-symbols.js +0 -136
- package/dist/intelligence/incremental-indexer.js +0 -658
- package/dist/intelligence/indexer/centrality.js +0 -62
- package/dist/intelligence/indexer/cfg-context.js +0 -95
- package/dist/intelligence/indexer/confidence.js +0 -34
- package/dist/intelligence/indexer/cross-file-resolver.js +0 -104
- package/dist/intelligence/indexer/edge-repair.js +0 -89
- package/dist/intelligence/indexer/entity-key.js +0 -17
- package/dist/intelligence/indexer/export-map.js +0 -132
- package/dist/intelligence/indexer/git-cochange.js +0 -128
- package/dist/intelligence/indexer/graph-patch.js +0 -147
- package/dist/intelligence/indexer/incremental.js +0 -78
- package/dist/intelligence/indexer/ingest.js +0 -160
- package/dist/intelligence/indexer/language-detect.js +0 -226
- package/dist/intelligence/indexer/metadata.js +0 -63
- package/dist/intelligence/indexer/mutation-tracker.js +0 -79
- package/dist/intelligence/indexer/orchestrator.js +0 -155
- package/dist/intelligence/indexer/plugin-interface.js +0 -31
- package/dist/intelligence/indexer/plugins/csharp.js +0 -440
- package/dist/intelligence/indexer/plugins/go.js +0 -335
- package/dist/intelligence/indexer/plugins/java.js +0 -370
- package/dist/intelligence/indexer/plugins/python.js +0 -358
- package/dist/intelligence/indexer/plugins/regex-fallback.js +0 -82
- package/dist/intelligence/indexer/plugins/ruby.js +0 -290
- package/dist/intelligence/indexer/plugins/rust.js +0 -484
- package/dist/intelligence/indexer/plugins/tier2-generic.js +0 -310
- package/dist/intelligence/indexer/plugins/typescript.js +0 -456
- package/dist/intelligence/indexer/resource-monitor.js +0 -93
- package/dist/intelligence/indexer/scip/decoder.js +0 -253
- package/dist/intelligence/indexer/scip/detector.js +0 -232
- package/dist/intelligence/indexer/scip/downloader.js +0 -427
- package/dist/intelligence/indexer/scip/fallback.js +0 -34
- package/dist/intelligence/indexer/scip/merger.js +0 -109
- package/dist/intelligence/indexer/scip/orchestrator.js +0 -433
- package/dist/intelligence/indexer/scip/runner.js +0 -98
- package/dist/intelligence/indexer/snapshot.js +0 -66
- package/dist/intelligence/indexer/test-detector.js +0 -196
- package/dist/intelligence/indexer/watch-integration.js +0 -61
- package/dist/intelligence/indexer/worker.js +0 -85
- package/dist/intelligence/local-convention-detector.js +0 -437
- package/dist/intelligence/local-embeddings.js +0 -190
- package/dist/intelligence/local-graph.js +0 -1946
- package/dist/intelligence/local-indexer.js +0 -1575
- package/dist/intelligence/local-llm.js +0 -163
- package/dist/intelligence/local-rule-generator.js +0 -154
- package/dist/intelligence/local-snapshot.js +0 -213
- package/dist/intelligence/negative-knowledge.js +0 -103
- package/dist/intelligence/persistent-db.js +0 -85
- package/dist/intelligence/query-router.js +0 -2556
- package/dist/intelligence/risk-classifier.js +0 -116
- package/dist/intelligence/rule-evaluator.js +0 -380
- package/dist/intelligence/rule-generator.js +0 -49
- package/dist/intelligence/search-index.js +0 -173
- package/dist/intelligence/semantic/docstring-extractor.js +0 -67
- package/dist/intelligence/semantic/embedding-store.js +0 -52
- package/dist/intelligence/semantic/enrichment-orchestrator.js +0 -48
- package/dist/intelligence/semantic/git-message-miner.js +0 -114
- package/dist/intelligence/semantic/identifier-tokenizer.js +0 -51
- package/dist/intelligence/semantic/node2vec-embeddings.js +0 -71
- package/dist/intelligence/semantic/node2vec-walks.js +0 -103
- package/dist/intelligence/semantic/path-domain-inference.js +0 -112
- package/dist/intelligence/semantic/similarity-engine.js +0 -60
- package/dist/intelligence/semantic/tfidf-vectors.js +0 -88
- package/dist/intelligence/session-brief-builder.js +0 -159
- package/dist/intelligence/session-context.js +0 -221
- package/dist/intelligence/session-health-monitor.js +0 -211
- package/dist/intelligence/session-narrative.js +0 -197
- package/dist/intelligence/session-pattern-analyzer.js +0 -218
- package/dist/intelligence/signal-scorer.js +0 -390
- package/dist/intelligence/signal-show-store.js +0 -182
- package/dist/intelligence/smart-truncate.js +0 -158
- package/dist/intelligence/subgraph-cache.js +0 -88
- package/dist/intelligence/temporal-facts.js +0 -494
- package/dist/intelligence/token-estimator.js +0 -100
- package/dist/intelligence/tool-injector.js +0 -87
- package/dist/intelligence/tree-sitter-loader.js +0 -71
- package/dist/intelligence/worker-pool.js +0 -116
- package/dist/proxy/arg-validator.js +0 -79
- package/dist/proxy/auto-bootstrap.js +0 -167
- package/dist/proxy/bridge.js +0 -147
- package/dist/proxy/budget-enforcer.js +0 -70
- package/dist/proxy/compression-quality-monitor.js +0 -160
- package/dist/proxy/compression-stats.js +0 -51
- package/dist/proxy/context-rot-detector.js +0 -137
- package/dist/proxy/drift-detector.js +0 -139
- package/dist/proxy/efficiency-tracker.js +0 -79
- package/dist/proxy/fact-ranking.js +0 -154
- package/dist/proxy/format-encoder.js +0 -266
- package/dist/proxy/http-transport.js +0 -90
- package/dist/proxy/lifecycle-actor.js +0 -55
- package/dist/proxy/lifecycle-machine.js +0 -187
- package/dist/proxy/log-tailer.js +0 -265
- package/dist/proxy/model-pricing.js +0 -98
- package/dist/proxy/network-firewall.js +0 -141
- package/dist/proxy/nudge-state.js +0 -93
- package/dist/proxy/output-compressor.js +0 -185
- package/dist/proxy/pid-lock.js +0 -291
- package/dist/proxy/proxy-context.js +0 -11
- package/dist/proxy/proxy.js +0 -2633
- package/dist/proxy/response-enrichment.js +0 -32
- package/dist/proxy/response-envelope.js +0 -313
- package/dist/proxy/session-dedup.js +0 -82
- package/dist/proxy/session-legend.js +0 -30
- package/dist/proxy/session-persistence.js +0 -210
- package/dist/proxy/session-resume.js +0 -94
- package/dist/proxy/session-stats.js +0 -513
- package/dist/proxy/shell-classifier.js +0 -1346
- package/dist/proxy/shell-compression-log.js +0 -93
- package/dist/proxy/shell-compressor.js +0 -390
- package/dist/proxy/shell-graph-boost.js +0 -202
- package/dist/proxy/shell-monitor-map.js +0 -18
- package/dist/proxy/shell-stats.js +0 -54
- package/dist/proxy/shell-strategies/cloud.js +0 -215
- package/dist/proxy/shell-strategies/diff.js +0 -159
- package/dist/proxy/shell-strategies/error-diagnostic.js +0 -796
- package/dist/proxy/shell-strategies/filter-dsl.js +0 -358
- package/dist/proxy/shell-strategies/git-status.js +0 -177
- package/dist/proxy/shell-strategies/key-value.js +0 -193
- package/dist/proxy/shell-strategies/log-text.js +0 -154
- package/dist/proxy/shell-strategies/omni.js +0 -188
- package/dist/proxy/shell-strategies/progress.js +0 -55
- package/dist/proxy/shell-strategies/redact.js +0 -76
- package/dist/proxy/shell-strategies/structured.js +0 -241
- package/dist/proxy/shell-strategies/tabular.js +0 -243
- package/dist/proxy/shell-strategies/test-results-types.js +0 -13
- package/dist/proxy/shell-strategies/test-results.js +0 -784
- package/dist/proxy/shell-strategies/tree-paths.js +0 -144
- package/dist/proxy/shell-strategies/yaml.js +0 -182
- package/dist/proxy/shell-tee.js +0 -111
- package/dist/proxy/signal-dedup.js +0 -171
- package/dist/proxy/startup-renderer.js +0 -158
- package/dist/proxy/task-token-display.js +0 -38
- package/dist/proxy/token-counter.js +0 -61
- package/dist/proxy/tool-clusters.js +0 -273
- package/dist/proxy/tool-definitions.js +0 -525
- package/dist/proxy/transport-mux.js +0 -229
- package/dist/proxy/wire-cap.js +0 -268
- package/dist/rules/developer.mozilla.org.json +0 -9
- package/dist/rules/github.com.json +0 -21
- package/dist/schemas/api/skills.js +0 -19
- package/dist/schemas/common/errors.js +0 -7
- package/dist/schemas/common/headers.js +0 -5
- package/dist/schemas/entities/edge.js +0 -25
- package/dist/schemas/entities/entity.js +0 -22
- package/dist/schemas/entities/rule.js +0 -18
- package/dist/schemas/index.js +0 -14
- package/dist/server/event-bus.js +0 -59
- package/dist/server/http.js +0 -156
- package/dist/server/middleware.js +0 -70
- package/dist/server/routes/drift.js +0 -97
- package/dist/server/routes/intelligence.js +0 -1217
- package/dist/server/routes/reasoning-quality.js +0 -444
- package/dist/server/routes/session.js +0 -86
- package/dist/server/routes/stream.js +0 -120
- package/dist/server/routes/system.js +0 -73
- package/dist/server/routes/temporal.js +0 -170
- package/dist/server/routes/timeline.js +0 -232
- package/dist/server/routes/token-flow.js +0 -403
- package/dist/skills/effectiveness-tracker.js +0 -93
- package/dist/skills/local-pack.js +0 -380
- package/dist/skills/resolver.js +0 -495
- package/dist/state-detector.js +0 -83
- package/dist/timeline/intent-detector.js +0 -263
- package/dist/timeline/loop-miner.js +0 -140
- package/dist/timeline/open-threads.js +0 -49
- package/dist/timeline/signal-reinforcer.js +0 -62
- package/dist/timeline/timeline-bootstrap.js +0 -151
- package/dist/timeline/timeline-store.js +0 -618
- package/dist/tools/coding/bash.js +0 -49
- package/dist/tools/coding/file-edit.js +0 -72
- package/dist/tools/coding/file-outline.js +0 -227
- package/dist/tools/coding/file-read-protocol.js +0 -425
- package/dist/tools/coding/file-read.js +0 -35
- package/dist/tools/coding/file-write.js +0 -43
- package/dist/tools/coding/glob-tool.js +0 -109
- package/dist/tools/coding/grep.js +0 -162
- package/dist/tools/coding/index.js +0 -27
- package/dist/tools/intelligence/index.js +0 -269
- package/dist/tools/intelligence/record-fact.js +0 -48
- package/dist/tools/intelligence/timeline-markers.js +0 -130
- package/dist/tools/registry.js +0 -47
- package/dist/tools/types.js +0 -8
- package/dist/tracking/auto-snapshot-triggers.js +0 -246
- package/dist/tracking/branch-context.js +0 -115
- package/dist/tracking/branch-snapshot.js +0 -217
- package/dist/tracking/causal-bridge.js +0 -317
- package/dist/tracking/circuit-breaker.js +0 -147
- package/dist/tracking/commit-watcher.js +0 -114
- package/dist/tracking/context-ledger.js +0 -119
- package/dist/tracking/correction-detector.js +0 -324
- package/dist/tracking/drift-tracker.js +0 -874
- package/dist/tracking/durability-tracker.js +0 -94
- package/dist/tracking/entity-rewind.js +0 -200
- package/dist/tracking/file-hash-state.js +0 -114
- package/dist/tracking/git-attribution.js +0 -132
- package/dist/tracking/git-trailers.js +0 -171
- package/dist/tracking/intelligence-counter.js +0 -46
- package/dist/tracking/intent-correlator.js +0 -202
- package/dist/tracking/intent-encoder.js +0 -52
- package/dist/tracking/intent-token-tracker.js +0 -159
- package/dist/tracking/ledger-archiver.js +0 -94
- package/dist/tracking/ledger-chains.js +0 -245
- package/dist/tracking/metrics-store.js +0 -361
- package/dist/tracking/native-watcher.js +0 -131
- package/dist/tracking/offline-rewind.js +0 -295
- package/dist/tracking/pending-violations.js +0 -74
- package/dist/tracking/persistence-effectiveness.js +0 -167
- package/dist/tracking/prompt-durability.js +0 -202
- package/dist/tracking/quality-signals.js +0 -213
- package/dist/tracking/redactor.js +0 -73
- package/dist/tracking/rewind-engine.js +0 -161
- package/dist/tracking/session-history.js +0 -128
- package/dist/tracking/session-receipt.js +0 -88
- package/dist/tracking/session-summary-writer.js +0 -157
- package/dist/tracking/shadow-ledger.js +0 -321
- package/dist/tracking/stash-manager.js +0 -258
- package/dist/tracking/timeline-fork.js +0 -213
- package/dist/tracking/timeline.js +0 -69
- package/dist/tracking/token-flow.js +0 -276
- package/dist/tracking/turn-segmenter.js +0 -122
- package/dist/tracking/weekly-accumulator.js +0 -179
- package/dist/tracking/working-snapshots.js +0 -188
- package/dist/tracking/workspace-manifest.js +0 -176
- package/dist/transport/http.js +0 -102
- package/dist/utils/counterfactual.js +0 -65
- package/dist/utils/deep-link.js +0 -34
- package/dist/utils/detect.js +0 -193
- package/dist/utils/exec.js +0 -73
- package/dist/utils/file-logger.js +0 -87
- package/dist/utils/format-error.js +0 -29
- package/dist/utils/git.js +0 -181
- package/dist/utils/log.js +0 -57
- package/dist/utils/logger.js +0 -35
- package/dist/utils/mcp-content-json.js +0 -8
- package/dist/utils/session-logger.js +0 -154
- package/dist/utils/startup-log.js +0 -512
- package/dist/utils/ui.js +0 -56
package/dist/commands/status.js
DELETED
|
@@ -1,654 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* unerr status — check repo/proxy/graph/drift/ledger state.
|
|
3
|
-
*
|
|
4
|
-
* Renders a rich Ink dashboard to stderr with:
|
|
5
|
-
* - Repo info, branch, commits ahead/behind
|
|
6
|
-
* - Proxy state (running/stopped, PID)
|
|
7
|
-
* - Graph stats (entity count, edge count, age)
|
|
8
|
-
* - Health grade with progress bar
|
|
9
|
-
* - Drift summary
|
|
10
|
-
* - Live session latency if proxy is running
|
|
11
|
-
*
|
|
12
|
-
* All output to stderr to protect MCP stdout stream.
|
|
13
|
-
*/
|
|
14
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
15
|
-
import { join } from "node:path";
|
|
16
|
-
import React from "react";
|
|
17
|
-
import { getRemoteUrl } from "../utils/git.js";
|
|
18
|
-
/**
|
|
19
|
-
* Contextual suggestions engine.
|
|
20
|
-
* Surfaces actionable next steps based on current state.
|
|
21
|
-
*/
|
|
22
|
-
function buildSuggestions(data) {
|
|
23
|
-
const suggestions = [];
|
|
24
|
-
if (data.byoLlmStatus === "not_configured") {
|
|
25
|
-
suggestions.push("Configure BYO-LLM for semantic search: edit ~/.unerr/settings.json");
|
|
26
|
-
}
|
|
27
|
-
if (data.byoLlmStatus === "unreachable") {
|
|
28
|
-
suggestions.push("LLM is unreachable. Start Ollama: ollama serve");
|
|
29
|
-
}
|
|
30
|
-
if (!data.lastIndexed) {
|
|
31
|
-
suggestions.push("No index yet. Run 'unerr' to start indexing.");
|
|
32
|
-
}
|
|
33
|
-
if (data.conventionCount === 0 || data.conventionCount == null) {
|
|
34
|
-
suggestions.push("Run 'unerr' to detect conventions and generate rules");
|
|
35
|
-
}
|
|
36
|
-
if (data.byoLlmStatus === "connected") {
|
|
37
|
-
suggestions.push("Run 'unerr enrich' to generate business context with your LLM");
|
|
38
|
-
}
|
|
39
|
-
suggestions.push("Run 'unerr chat' to talk to your codebase interactively");
|
|
40
|
-
if (data.skillCount === 0 || data.skillCount == null) {
|
|
41
|
-
suggestions.push("No skills installed. Run 'unerr' to install agent skills.");
|
|
42
|
-
}
|
|
43
|
-
if (!data.proxyRunning) {
|
|
44
|
-
suggestions.push("Run 'unerr' to start the proxy.");
|
|
45
|
-
}
|
|
46
|
-
return suggestions;
|
|
47
|
-
}
|
|
48
|
-
export function registerStatusCommand(program) {
|
|
49
|
-
program
|
|
50
|
-
.command("status")
|
|
51
|
-
.description("Check repo, proxy, graph, drift, and ledger state")
|
|
52
|
-
.action(async () => {
|
|
53
|
-
const cwd = process.cwd();
|
|
54
|
-
// ── Git Check ──────────────────────────────────────────────
|
|
55
|
-
const { isGitRepo } = await import("../utils/git.js");
|
|
56
|
-
if (!(await isGitRepo(cwd))) {
|
|
57
|
-
process.stderr.write("[unerr] Error: not inside a git repository.\n" +
|
|
58
|
-
" Run unerr from a project directory that has been initialized with git.\n");
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
const unerrDir = join(cwd, ".unerr");
|
|
62
|
-
const localDataDir = join(cwd, ".unerr");
|
|
63
|
-
// ── Repo Info ──────────────────────────────────────────────
|
|
64
|
-
let repoId = "";
|
|
65
|
-
const configPath = join(unerrDir, "config.json");
|
|
66
|
-
if (existsSync(configPath)) {
|
|
67
|
-
try {
|
|
68
|
-
const config = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
69
|
-
repoId = config.repoId ?? "";
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
/* ignore */
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// ── Git Context ────────────────────────────────────────────
|
|
76
|
-
let currentBranch = "unknown";
|
|
77
|
-
let commitsAhead = 0;
|
|
78
|
-
let commitsBehind = null;
|
|
79
|
-
try {
|
|
80
|
-
const { computeBranchContext } = await import("../tracking/branch-context.js");
|
|
81
|
-
const ctx = await computeBranchContext(cwd);
|
|
82
|
-
currentBranch = ctx.currentBranch;
|
|
83
|
-
commitsAhead = ctx.commitsAhead;
|
|
84
|
-
commitsBehind = ctx.commitsBehind;
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
/* ignore */
|
|
88
|
-
}
|
|
89
|
-
const branchDetail = commitsBehind !== null
|
|
90
|
-
? `${currentBranch} (${commitsAhead} ahead, ${commitsBehind} behind)`
|
|
91
|
-
: `${currentBranch} (${commitsAhead} ahead)`;
|
|
92
|
-
// ── Repo Name ──────────────────────────────────────────────
|
|
93
|
-
let repoFullName = repoId;
|
|
94
|
-
const remote = await getRemoteUrl(cwd);
|
|
95
|
-
if (remote) {
|
|
96
|
-
const sshMatch = remote.match(/git@[^:]+:(.+?)(?:\.git)?$/);
|
|
97
|
-
const httpMatch = remote.match(/(?:https?:\/\/)?(?:www\.)?[^/]+\/(.+?)(?:\.git)?$/);
|
|
98
|
-
repoFullName = sshMatch?.[1] ?? httpMatch?.[1] ?? repoId;
|
|
99
|
-
}
|
|
100
|
-
// ── Proxy Status ───────────────────────────────────────────
|
|
101
|
-
let proxyStatus = "Not running";
|
|
102
|
-
let proxyRunning = false;
|
|
103
|
-
const pidPath = join(unerrDir, "state", "proxy.pid");
|
|
104
|
-
if (existsSync(pidPath)) {
|
|
105
|
-
try {
|
|
106
|
-
const pidStr = readFileSync(pidPath, "utf-8").trim();
|
|
107
|
-
const pid = Number.parseInt(pidStr, 10);
|
|
108
|
-
process.kill(pid, 0);
|
|
109
|
-
proxyStatus = `Running (PID ${pid})`;
|
|
110
|
-
proxyRunning = true;
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
113
|
-
proxyStatus = "Not running (stale PID)";
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// ── Graph Stats ────────────────────────────────────────────
|
|
117
|
-
let graphInfo = "No local graph";
|
|
118
|
-
const manifestsDir = join(localDataDir, "manifests");
|
|
119
|
-
if (repoId && existsSync(join(manifestsDir, `${repoId}.json`))) {
|
|
120
|
-
try {
|
|
121
|
-
const manifest = JSON.parse(readFileSync(join(manifestsDir, `${repoId}.json`), "utf-8"));
|
|
122
|
-
const entityCount = manifest.entityCount ?? 0;
|
|
123
|
-
const edgeCount = manifest.edgeCount ?? 0;
|
|
124
|
-
const pulledAt = manifest.pulledAt;
|
|
125
|
-
let ageStr = "";
|
|
126
|
-
if (pulledAt) {
|
|
127
|
-
const ageMs = Date.now() - new Date(pulledAt).getTime();
|
|
128
|
-
const ageHours = Math.floor(ageMs / 3_600_000);
|
|
129
|
-
if (ageHours < 1)
|
|
130
|
-
ageStr = "indexed <1h ago";
|
|
131
|
-
else if (ageHours < 24)
|
|
132
|
-
ageStr = `indexed ${ageHours}h ago`;
|
|
133
|
-
else
|
|
134
|
-
ageStr = `indexed ${Math.floor(ageHours / 24)}d ago`;
|
|
135
|
-
}
|
|
136
|
-
graphInfo = `${entityCount.toLocaleString()} entities, ${edgeCount.toLocaleString()} edges${ageStr ? ` (${ageStr})` : ""}`;
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
/* ignore */
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
// ── Drift Stats ────────────────────────────────────────────
|
|
143
|
-
let drift;
|
|
144
|
-
const driftSummaryPath = join(unerrDir, "drift", "drift_summary.json");
|
|
145
|
-
if (existsSync(driftSummaryPath)) {
|
|
146
|
-
try {
|
|
147
|
-
const summary = JSON.parse(readFileSync(driftSummaryPath, "utf-8"));
|
|
148
|
-
drift = {
|
|
149
|
-
modified: summary.modified ?? 0,
|
|
150
|
-
added: summary.added ?? 0,
|
|
151
|
-
deleted: summary.deleted ?? 0,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
/* ignore */
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// ── Health Grade ───────────────────────────────────────────
|
|
159
|
-
let healthGrade;
|
|
160
|
-
let healthScore;
|
|
161
|
-
const graphVersionPath = join(unerrDir, "state", "graph_version.json");
|
|
162
|
-
if (existsSync(graphVersionPath)) {
|
|
163
|
-
try {
|
|
164
|
-
const gv = JSON.parse(readFileSync(graphVersionPath, "utf-8"));
|
|
165
|
-
healthGrade = gv.health_grade;
|
|
166
|
-
healthScore = gv.health_score;
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
/* ignore */
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
// ── Rule Health ───────────────────────────────────────────
|
|
173
|
-
let ruleHealth;
|
|
174
|
-
if (repoId) {
|
|
175
|
-
try {
|
|
176
|
-
const snapshotsDir = join(localDataDir, "snapshots");
|
|
177
|
-
let snapshotPath = join(snapshotsDir, "graph.msgpack.gz");
|
|
178
|
-
if (!existsSync(snapshotPath)) {
|
|
179
|
-
snapshotPath = join(snapshotsDir, "graph.msgpack");
|
|
180
|
-
}
|
|
181
|
-
if (existsSync(snapshotPath)) {
|
|
182
|
-
const { gunzipSync } = await import("node:zlib");
|
|
183
|
-
const { unpack } = await import("msgpackr");
|
|
184
|
-
const { default: CozoDbConstructor } = await import("cozo-node");
|
|
185
|
-
const { CozoGraphStore } = await import("../intelligence/local-graph.js");
|
|
186
|
-
const raw = readFileSync(snapshotPath);
|
|
187
|
-
let buffer;
|
|
188
|
-
try {
|
|
189
|
-
buffer = gunzipSync(raw);
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
buffer = raw;
|
|
193
|
-
}
|
|
194
|
-
const db = new CozoDbConstructor();
|
|
195
|
-
const graph = await CozoGraphStore.create(db);
|
|
196
|
-
const envelope = unpack(buffer);
|
|
197
|
-
await graph.loadSnapshot(envelope);
|
|
198
|
-
ruleHealth = await graph.getRuleHealthSummary();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
catch {
|
|
202
|
-
/* ignore */
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// ── Live Session Stats + Latency ───────────────────────────
|
|
206
|
-
let liveToolCalls;
|
|
207
|
-
let latency;
|
|
208
|
-
const statsPath = join(unerrDir, "state", "session_stats.json");
|
|
209
|
-
if (existsSync(statsPath) && proxyRunning) {
|
|
210
|
-
try {
|
|
211
|
-
const liveStats = JSON.parse(readFileSync(statsPath, "utf-8"));
|
|
212
|
-
const localCalls = liveStats.toolCallsLocal ?? 0;
|
|
213
|
-
if (localCalls > 0) {
|
|
214
|
-
liveToolCalls = { local: localCalls };
|
|
215
|
-
}
|
|
216
|
-
const localL = liveStats.latency?.local;
|
|
217
|
-
if (localL) {
|
|
218
|
-
latency = {
|
|
219
|
-
localP50: localL.p50,
|
|
220
|
-
localP99: localL.p99,
|
|
221
|
-
localBudgetExceeded: localL.p99 > 5,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
catch {
|
|
226
|
-
/* ignore */
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
// ── Local Mode Status ────────────────────────────────────
|
|
230
|
-
// Firewall status
|
|
231
|
-
let firewallStatus = "Not active (proxy not running)";
|
|
232
|
-
let firewallBlocked;
|
|
233
|
-
if (proxyRunning) {
|
|
234
|
-
firewallStatus = "Sealed (active)";
|
|
235
|
-
}
|
|
236
|
-
try {
|
|
237
|
-
const firewallStatsPath = join(unerrDir, "state", "firewall_stats.json");
|
|
238
|
-
if (existsSync(firewallStatsPath)) {
|
|
239
|
-
const fs = JSON.parse(readFileSync(firewallStatsPath, "utf-8"));
|
|
240
|
-
firewallBlocked = fs.blocked ?? 0;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
catch {
|
|
244
|
-
/* ignore */
|
|
245
|
-
}
|
|
246
|
-
// BYO-LLM
|
|
247
|
-
let byoLlm;
|
|
248
|
-
let byoLlmStatus = "not_configured";
|
|
249
|
-
const { loadSettings } = await import("../config/settings.js");
|
|
250
|
-
const settings = loadSettings();
|
|
251
|
-
if (settings.localLlm) {
|
|
252
|
-
const { resolveEmbeddingEndpoint, resolveInferenceEndpoint } = await import("../config/settings.js");
|
|
253
|
-
const embEp = resolveEmbeddingEndpoint(settings.localLlm);
|
|
254
|
-
const infEp = resolveInferenceEndpoint(settings.localLlm);
|
|
255
|
-
const embDesc = embEp.baseUrl
|
|
256
|
-
? `${embEp.provider} at ${embEp.baseUrl}`
|
|
257
|
-
: embEp.provider;
|
|
258
|
-
byoLlm = `embed: ${embDesc} (${embEp.model})`;
|
|
259
|
-
const infDesc = infEp.baseUrl
|
|
260
|
-
? `${infEp.provider} at ${infEp.baseUrl}`
|
|
261
|
-
: infEp.provider;
|
|
262
|
-
byoLlm += `, chat: ${infDesc} (${infEp.model})`;
|
|
263
|
-
// Health check against the embedding endpoint
|
|
264
|
-
if (embEp.baseUrl) {
|
|
265
|
-
try {
|
|
266
|
-
const stripped = embEp.baseUrl.replace(/\/+$/, "");
|
|
267
|
-
const healthUrl = embEp.provider === "ollama"
|
|
268
|
-
? `${stripped}/api/tags`
|
|
269
|
-
: `${stripped}/v1/models`;
|
|
270
|
-
const headers = {};
|
|
271
|
-
if (embEp.apiKey)
|
|
272
|
-
headers.Authorization = `Bearer ${embEp.apiKey}`;
|
|
273
|
-
const hc = await fetch(healthUrl, {
|
|
274
|
-
headers,
|
|
275
|
-
signal: AbortSignal.timeout(2000),
|
|
276
|
-
});
|
|
277
|
-
byoLlmStatus = hc.ok ? "connected" : "unreachable";
|
|
278
|
-
}
|
|
279
|
-
catch {
|
|
280
|
-
byoLlmStatus = "unreachable";
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
byoLlm = "Not configured";
|
|
286
|
-
}
|
|
287
|
-
// Last indexed
|
|
288
|
-
let lastIndexed;
|
|
289
|
-
const snapshotMetaPath = join(unerrDir, "state", "snapshot_meta.json");
|
|
290
|
-
if (existsSync(snapshotMetaPath)) {
|
|
291
|
-
try {
|
|
292
|
-
const meta = JSON.parse(readFileSync(snapshotMetaPath, "utf-8"));
|
|
293
|
-
if (meta.indexedAt) {
|
|
294
|
-
const ageMs = Date.now() - new Date(meta.indexedAt).getTime();
|
|
295
|
-
const ageHours = Math.floor(ageMs / 3_600_000);
|
|
296
|
-
const ageStr = ageHours < 1
|
|
297
|
-
? "<1h ago"
|
|
298
|
-
: ageHours < 24
|
|
299
|
-
? `${ageHours}h ago`
|
|
300
|
-
: `${Math.floor(ageHours / 24)}d ago`;
|
|
301
|
-
lastIndexed = ageStr;
|
|
302
|
-
if (meta.fileCount)
|
|
303
|
-
lastIndexed += ` (${meta.fileCount} files`;
|
|
304
|
-
if (meta.elapsedMs)
|
|
305
|
-
lastIndexed += ` in ${(meta.elapsedMs / 1000).toFixed(1)}s`;
|
|
306
|
-
if (meta.fileCount)
|
|
307
|
-
lastIndexed += ")";
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
catch {
|
|
311
|
-
/* ignore */
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
// Corrections count
|
|
315
|
-
let corrections;
|
|
316
|
-
try {
|
|
317
|
-
const corrPath = join(unerrDir, "state", "corrections_count.json");
|
|
318
|
-
if (existsSync(corrPath)) {
|
|
319
|
-
const cc = JSON.parse(readFileSync(corrPath, "utf-8"));
|
|
320
|
-
corrections = cc.count;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
catch {
|
|
324
|
-
/* ignore */
|
|
325
|
-
}
|
|
326
|
-
// Community, convention, rule counts from graph_version.json
|
|
327
|
-
let communityCount;
|
|
328
|
-
let conventionCount;
|
|
329
|
-
let ruleCount;
|
|
330
|
-
try {
|
|
331
|
-
if (existsSync(graphVersionPath)) {
|
|
332
|
-
const gv = JSON.parse(readFileSync(graphVersionPath, "utf-8"));
|
|
333
|
-
communityCount = gv.community_count;
|
|
334
|
-
conventionCount = gv.convention_count;
|
|
335
|
-
ruleCount = gv.rule_count;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
catch {
|
|
339
|
-
/* ignore */
|
|
340
|
-
}
|
|
341
|
-
// ── Hook Status (S6.6) ─────────────────────────────────────
|
|
342
|
-
let hookStatus;
|
|
343
|
-
try {
|
|
344
|
-
const { isClaudeHookInstalled } = await import("../config/hook-installer.js");
|
|
345
|
-
const { isConfigured } = await import("../config/mcp-config-writer.js");
|
|
346
|
-
const { detectTools } = await import("../config/tool-detector.js");
|
|
347
|
-
const tools = detectTools(cwd);
|
|
348
|
-
const parts = [];
|
|
349
|
-
if (isClaudeHookInstalled(cwd)) {
|
|
350
|
-
parts.push("Claude hook: installed");
|
|
351
|
-
}
|
|
352
|
-
for (const tool of tools) {
|
|
353
|
-
if (isConfigured(cwd, tool.ide)) {
|
|
354
|
-
const name = tool.ide === "claude-code"
|
|
355
|
-
? "Claude Code"
|
|
356
|
-
: tool.ide === "vscode"
|
|
357
|
-
? "VS Code"
|
|
358
|
-
: tool.ide.charAt(0).toUpperCase() + tool.ide.slice(1);
|
|
359
|
-
parts.push(`${name} MCP: configured`);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
if (parts.length > 0) {
|
|
363
|
-
hookStatus = parts.join(", ");
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
catch {
|
|
367
|
-
/* ignore */
|
|
368
|
-
}
|
|
369
|
-
// Installed skills
|
|
370
|
-
let skillCount;
|
|
371
|
-
let skillNames;
|
|
372
|
-
try {
|
|
373
|
-
const { detectIde } = await import("../utils/detect.js");
|
|
374
|
-
const { listInstalledSkills } = await import("../skills/resolver.js");
|
|
375
|
-
const ide = await detectIde(cwd);
|
|
376
|
-
const skills = listInstalledSkills(ide, cwd);
|
|
377
|
-
skillCount = skills.length;
|
|
378
|
-
skillNames = skills.map((s) => s.name);
|
|
379
|
-
}
|
|
380
|
-
catch {
|
|
381
|
-
/* ignore */
|
|
382
|
-
}
|
|
383
|
-
// Ledger entry count
|
|
384
|
-
let ledgerEntryCount;
|
|
385
|
-
try {
|
|
386
|
-
const ledgerPath = join(unerrDir, "ledger", "shadow.jsonl");
|
|
387
|
-
if (existsSync(ledgerPath)) {
|
|
388
|
-
const content = readFileSync(ledgerPath, "utf-8");
|
|
389
|
-
ledgerEntryCount = content
|
|
390
|
-
.split("\n")
|
|
391
|
-
.filter((l) => l.trim().length > 0).length;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
catch {
|
|
395
|
-
/* ignore */
|
|
396
|
-
}
|
|
397
|
-
// Log file path (latest log)
|
|
398
|
-
let logPath;
|
|
399
|
-
try {
|
|
400
|
-
const logsDir = join(unerrDir, "logs");
|
|
401
|
-
if (existsSync(logsDir)) {
|
|
402
|
-
const { readdirSync, statSync } = await import("node:fs");
|
|
403
|
-
const logs = readdirSync(logsDir)
|
|
404
|
-
.filter((f) => f.startsWith("session-") && f.endsWith(".log"))
|
|
405
|
-
.map((f) => ({
|
|
406
|
-
name: f,
|
|
407
|
-
mtime: statSync(join(logsDir, f)).mtimeMs,
|
|
408
|
-
}))
|
|
409
|
-
.sort((a, b) => b.mtime - a.mtime);
|
|
410
|
-
if (logs[0]) {
|
|
411
|
-
logPath = `.unerr/logs/${logs[0].name}`;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
catch {
|
|
416
|
-
/* ignore */
|
|
417
|
-
}
|
|
418
|
-
// Cumulative local stats
|
|
419
|
-
let cumulative;
|
|
420
|
-
try {
|
|
421
|
-
const { loadCumulativeLocalStats } = await import("../proxy/session-stats.js");
|
|
422
|
-
const cls = loadCumulativeLocalStats();
|
|
423
|
-
if (cls.totalSessions > 0) {
|
|
424
|
-
cumulative = {
|
|
425
|
-
sessions: cls.totalSessions,
|
|
426
|
-
toolCalls: cls.totalToolCalls,
|
|
427
|
-
tokensSaved: cls.totalTokensSaved,
|
|
428
|
-
violations: cls.totalViolationsCaught,
|
|
429
|
-
corrections: cls.totalCorrectionsApplied,
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
catch {
|
|
434
|
-
/* ignore */
|
|
435
|
-
}
|
|
436
|
-
// Last session summary (when proxy is NOT running)
|
|
437
|
-
let lastSession;
|
|
438
|
-
if (!proxyRunning) {
|
|
439
|
-
try {
|
|
440
|
-
const statsPath2 = join(unerrDir, "state", "session_stats.json");
|
|
441
|
-
if (existsSync(statsPath2)) {
|
|
442
|
-
const raw = JSON.parse(readFileSync(statsPath2, "utf-8"));
|
|
443
|
-
const totalCalls = raw.toolCallsLocal ?? 0;
|
|
444
|
-
if (totalCalls > 0) {
|
|
445
|
-
const endTime = raw.updatedAt
|
|
446
|
-
? new Date(raw.updatedAt)
|
|
447
|
-
: new Date();
|
|
448
|
-
const startTime = raw.sessionStartedAt
|
|
449
|
-
? new Date(raw.sessionStartedAt)
|
|
450
|
-
: endTime;
|
|
451
|
-
const durationMin = Math.round((endTime.getTime() - startTime.getTime()) / 60_000);
|
|
452
|
-
const ageMs = Date.now() - endTime.getTime();
|
|
453
|
-
const ageHours = Math.floor(ageMs / 3_600_000);
|
|
454
|
-
const endedAtStr = ageHours < 1
|
|
455
|
-
? "<1h ago"
|
|
456
|
-
: ageHours < 24
|
|
457
|
-
? `${ageHours}h ago`
|
|
458
|
-
: `${Math.floor(ageHours / 24)}d ago`;
|
|
459
|
-
lastSession = {
|
|
460
|
-
endedAt: endedAtStr,
|
|
461
|
-
durationMin: durationMin > 0 ? durationMin : 1,
|
|
462
|
-
toolCalls: totalCalls,
|
|
463
|
-
violationsCaught: raw.violationsCaught ?? 0,
|
|
464
|
-
tokensSaved: totalCalls * 3200,
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
catch {
|
|
470
|
-
/* ignore */
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
// Suggestions engine
|
|
474
|
-
const suggestions = buildSuggestions({
|
|
475
|
-
byoLlmStatus,
|
|
476
|
-
lastIndexed,
|
|
477
|
-
conventionCount,
|
|
478
|
-
skillCount,
|
|
479
|
-
proxyRunning,
|
|
480
|
-
healthGrade,
|
|
481
|
-
});
|
|
482
|
-
let shellCompression;
|
|
483
|
-
let preBashHookConfigured = false;
|
|
484
|
-
try {
|
|
485
|
-
const sp = join(cwd, ".claude", "settings.json");
|
|
486
|
-
if (existsSync(sp)) {
|
|
487
|
-
const raw = readFileSync(sp, "utf8");
|
|
488
|
-
preBashHookConfigured =
|
|
489
|
-
raw.includes("unerr hook pre-bash") ||
|
|
490
|
-
raw.includes('"unerr hook pre-bash"');
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
catch {
|
|
494
|
-
/* ignore */
|
|
495
|
-
}
|
|
496
|
-
const { readShellCompressionAggregate } = await import("../proxy/shell-stats.js");
|
|
497
|
-
const shellAgg = readShellCompressionAggregate(cwd);
|
|
498
|
-
if (shellAgg || preBashHookConfigured) {
|
|
499
|
-
shellCompression = {
|
|
500
|
-
events: shellAgg?.totalEvents ?? 0,
|
|
501
|
-
tokensSavedApprox: shellAgg?.tokensSavedApprox ?? 0,
|
|
502
|
-
preBashHookConfigured,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
// Read recent compression events for detailed display
|
|
506
|
-
const { readRecentCompressionLogs, readRecentFileReadLogs } = await import("../proxy/shell-compression-log.js");
|
|
507
|
-
const recentCompressionEvents = readRecentCompressionLogs(cwd, 10);
|
|
508
|
-
if (shellCompression && recentCompressionEvents.length > 0) {
|
|
509
|
-
shellCompression.recentEvents = recentCompressionEvents;
|
|
510
|
-
}
|
|
511
|
-
// Read recent file-read optimization events
|
|
512
|
-
const recentFileReadEvents = readRecentFileReadLogs(cwd, 10);
|
|
513
|
-
const localModeData = {
|
|
514
|
-
mode: "local",
|
|
515
|
-
firewallStatus,
|
|
516
|
-
firewallBlocked,
|
|
517
|
-
byoLlm,
|
|
518
|
-
byoLlmStatus,
|
|
519
|
-
lastIndexed,
|
|
520
|
-
corrections,
|
|
521
|
-
communityCount,
|
|
522
|
-
conventionCount,
|
|
523
|
-
ruleCount,
|
|
524
|
-
hookStatus,
|
|
525
|
-
shellCompression,
|
|
526
|
-
recentFileReadEvents: recentFileReadEvents.length > 0 ? recentFileReadEvents : undefined,
|
|
527
|
-
skillCount,
|
|
528
|
-
skillNames,
|
|
529
|
-
logPath,
|
|
530
|
-
ledgerEntryCount,
|
|
531
|
-
suggestions,
|
|
532
|
-
cumulative,
|
|
533
|
-
lastSession,
|
|
534
|
-
};
|
|
535
|
-
// ── Render Ink Dashboard ───────────────────────────────────
|
|
536
|
-
// Layer 10: Read token flow data for status display
|
|
537
|
-
let tokenFlowData = undefined;
|
|
538
|
-
try {
|
|
539
|
-
const { readTokenFlowEvents, aggregateSession: aggSession } = await import("../tracking/token-flow.js");
|
|
540
|
-
const events = readTokenFlowEvents(unerrDir);
|
|
541
|
-
if (events.length > 0) {
|
|
542
|
-
const latestSessionId = events[events.length - 1]?.session_id ?? "";
|
|
543
|
-
const summary = aggSession(events, latestSessionId);
|
|
544
|
-
if (summary.total_tokens_saved > 0) {
|
|
545
|
-
tokenFlowData = {
|
|
546
|
-
tokensSaved: summary.total_tokens_saved,
|
|
547
|
-
tokensDelivered: summary.total_tokens_with,
|
|
548
|
-
efficiencyPct: summary.efficiency_pct,
|
|
549
|
-
byMechanism: Object.entries(summary.by_mechanism)
|
|
550
|
-
.sort(([, a], [, b]) => b.tokens_saved - a.tokens_saved)
|
|
551
|
-
.map(([mechanism, data]) => ({
|
|
552
|
-
mechanism,
|
|
553
|
-
tokensSaved: data.tokens_saved,
|
|
554
|
-
pctOfTotal: data.pct_of_total,
|
|
555
|
-
})),
|
|
556
|
-
topTurn: summary.top_turns[0]
|
|
557
|
-
? {
|
|
558
|
-
tool: summary.top_turns[0].tool,
|
|
559
|
-
tokensSaved: summary.top_turns[0].tokens_saved,
|
|
560
|
-
}
|
|
561
|
-
: undefined,
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
catch {
|
|
567
|
-
/* non-critical */
|
|
568
|
-
}
|
|
569
|
-
const statusData = {
|
|
570
|
-
repoName: repoFullName || "(no repo)",
|
|
571
|
-
repoId: repoId || undefined,
|
|
572
|
-
branch: currentBranch,
|
|
573
|
-
branchDetail,
|
|
574
|
-
proxyStatus,
|
|
575
|
-
proxyRunning,
|
|
576
|
-
graphInfo,
|
|
577
|
-
drift,
|
|
578
|
-
healthGrade,
|
|
579
|
-
healthScore,
|
|
580
|
-
latency,
|
|
581
|
-
liveToolCalls,
|
|
582
|
-
ruleHealth,
|
|
583
|
-
localMode: localModeData,
|
|
584
|
-
tokenFlow: tokenFlowData,
|
|
585
|
-
};
|
|
586
|
-
try {
|
|
587
|
-
const { StatusDashboard } = await import("../components/StatusDashboard.js");
|
|
588
|
-
const { ThemeProvider } = await import("../components/Theme.js");
|
|
589
|
-
const { renderToStderr } = await import("../components/render.js");
|
|
590
|
-
const el = React.createElement(ThemeProvider, null, React.createElement(StatusDashboard, { data: statusData }));
|
|
591
|
-
const inst = renderToStderr(el);
|
|
592
|
-
inst.unmount();
|
|
593
|
-
}
|
|
594
|
-
catch {
|
|
595
|
-
// Fallback to plain text
|
|
596
|
-
const lm = statusData.localMode;
|
|
597
|
-
let output = `
|
|
598
|
-
Repo: ${statusData.repoName}${statusData.repoId ? ` (${statusData.repoId})` : ""}
|
|
599
|
-
Branch: ${statusData.branchDetail}
|
|
600
|
-
Mode: Local (offline)
|
|
601
|
-
Proxy: ${statusData.proxyStatus}
|
|
602
|
-
Graph: ${statusData.graphInfo}
|
|
603
|
-
`;
|
|
604
|
-
if (lm) {
|
|
605
|
-
output += ` Firewall: ${lm.firewallStatus}${lm.firewallBlocked != null ? ` (${lm.firewallBlocked} blocked)` : ""}\n`;
|
|
606
|
-
if (lm.byoLlm)
|
|
607
|
-
output += ` BYO-LLM: ${lm.byoLlm}\n`;
|
|
608
|
-
if (lm.lastIndexed)
|
|
609
|
-
output += ` Indexed: ${lm.lastIndexed}\n`;
|
|
610
|
-
if (lm.communityCount)
|
|
611
|
-
output += ` Communities: ${lm.communityCount} clusters\n`;
|
|
612
|
-
if (lm.conventionCount)
|
|
613
|
-
output += ` Conventions: ${lm.conventionCount} detected\n`;
|
|
614
|
-
if (lm.ruleCount)
|
|
615
|
-
output += ` Rules: ${lm.ruleCount} active\n`;
|
|
616
|
-
if (lm.hookStatus)
|
|
617
|
-
output += ` Hooks: ${lm.hookStatus}\n`;
|
|
618
|
-
if (lm.skillCount != null) {
|
|
619
|
-
output += ` Skills: ${lm.skillCount} installed\n`;
|
|
620
|
-
if (lm.skillNames) {
|
|
621
|
-
for (const n of lm.skillNames)
|
|
622
|
-
output += ` ${n}\n`;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
if (lm.ledgerEntryCount)
|
|
626
|
-
output += ` Ledger: ${lm.ledgerEntryCount} entries\n`;
|
|
627
|
-
if (lm.logPath)
|
|
628
|
-
output += ` Logs: ${lm.logPath}\n`;
|
|
629
|
-
if (!statusData.proxyRunning && lm.lastSession) {
|
|
630
|
-
output += `\n Last session (${lm.lastSession.endedAt}, ${lm.lastSession.durationMin} min):\n`;
|
|
631
|
-
output += ` Tool calls: ${lm.lastSession.toolCalls} (all local)\n`;
|
|
632
|
-
if (lm.lastSession.violationsCaught > 0)
|
|
633
|
-
output += ` Violations: ${lm.lastSession.violationsCaught} caught\n`;
|
|
634
|
-
if (lm.lastSession.tokensSaved > 0)
|
|
635
|
-
output += ` Tokens: ~${lm.lastSession.tokensSaved.toLocaleString()} saved\n`;
|
|
636
|
-
}
|
|
637
|
-
if (lm.cumulative && lm.cumulative.sessions > 0) {
|
|
638
|
-
const c = lm.cumulative;
|
|
639
|
-
output += "\n This Week (Local Mode):\n";
|
|
640
|
-
output += ` Sessions: ${c.sessions}\n`;
|
|
641
|
-
output += ` Tool calls: ${c.toolCalls.toLocaleString()}\n`;
|
|
642
|
-
output += ` Tokens saved: ~${c.tokensSaved.toLocaleString()}\n`;
|
|
643
|
-
output += ` Violations: ${c.violations} caught\n`;
|
|
644
|
-
}
|
|
645
|
-
if (lm.suggestions && lm.suggestions.length > 0) {
|
|
646
|
-
output += "\n Suggestions:\n";
|
|
647
|
-
for (const s of lm.suggestions)
|
|
648
|
-
output += ` · ${s}\n`;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
process.stderr.write(output);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
}
|