@hassangameryt/freeflow 0.4.0 → 0.6.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +2 -1
- package/.codex-plugin/plugin.json +2 -1
- package/README.md +150 -155
- package/capabilities/cognitive-routing/SKILL.md +229 -0
- package/capabilities/context-virtualization/SKILL.md +103 -0
- package/capabilities/conversation-history/SKILL.md +53 -0
- package/command-surface.json +17 -13
- package/hooks/freeflow-runtime-context.mjs +393 -159
- package/hooks/hooks.json +26 -1
- package/hooks/tests/check-runtime-context-hook.sh +223 -54
- package/package.json +25 -16
- package/pi-extension/dist/cognitive-routing/commands.js +96 -0
- package/pi-extension/dist/cognitive-routing/config.js +236 -0
- package/pi-extension/dist/cognitive-routing/controller.js +862 -0
- package/pi-extension/dist/cognitive-routing/history.js +439 -0
- package/pi-extension/dist/cognitive-routing/host.js +126 -0
- package/pi-extension/dist/cognitive-routing/runtime.js +43 -0
- package/pi-extension/dist/cognitive-routing/tool.js +211 -0
- package/pi-extension/dist/cognitive-routing/types.js +6 -0
- package/pi-extension/dist/context-virtualization/commands.js +89 -0
- package/pi-extension/dist/context-virtualization/projector.js +42 -0
- package/pi-extension/dist/context-virtualization/runtime.js +356 -0
- package/pi-extension/dist/context-virtualization/state.js +57 -0
- package/pi-extension/dist/context-virtualization/types.js +10 -0
- package/pi-extension/dist/conversation-history/passages.js +66 -0
- package/pi-extension/dist/conversation-history/ranking.js +105 -0
- package/pi-extension/dist/conversation-history/runtime.js +226 -0
- package/pi-extension/dist/conversation-history/search.js +56 -0
- package/pi-extension/dist/conversation-history/types.js +1 -0
- package/pi-extension/dist/freeflow-context/resolver.js +120 -0
- package/pi-extension/dist/freeflow-context/runtime.js +80 -0
- package/pi-extension/dist/freeflow-context/source-projector.js +95 -0
- package/pi-extension/dist/freeflow-context/tool.js +308 -0
- package/pi-extension/dist/freeflow-context/types.js +12 -0
- package/pi-extension/dist/freeflow-context/visibility.js +28 -0
- package/pi-extension/dist/index.js +516 -98
- package/pi-extension/dist/runtime/runtime-context.js +318 -271
- package/pi-extension/dist/runtime/runtime-identity.js +5 -0
- package/pi-extension/dist/settings/settings-tui.js +78 -0
- package/pi-extension/dist/settings/settings-ui.js +593 -563
- package/pi-extension/dist/ui/text-component.js +57 -0
- package/pi-extension/src/cognitive-routing/commands.ts +119 -0
- package/pi-extension/src/cognitive-routing/config.ts +307 -0
- package/pi-extension/src/cognitive-routing/controller.ts +1118 -0
- package/pi-extension/src/cognitive-routing/history.ts +638 -0
- package/pi-extension/src/cognitive-routing/host.ts +172 -0
- package/pi-extension/src/cognitive-routing/runtime.ts +57 -0
- package/pi-extension/src/cognitive-routing/tool.ts +272 -0
- package/pi-extension/src/cognitive-routing/types.ts +89 -0
- package/pi-extension/src/context-virtualization/commands.ts +111 -0
- package/pi-extension/src/context-virtualization/projector.ts +62 -0
- package/pi-extension/src/context-virtualization/runtime.ts +406 -0
- package/pi-extension/src/context-virtualization/state.ts +79 -0
- package/pi-extension/src/context-virtualization/types.ts +92 -0
- package/pi-extension/src/conversation-history/passages.ts +81 -0
- package/pi-extension/src/conversation-history/ranking.ts +155 -0
- package/pi-extension/src/conversation-history/runtime.ts +250 -0
- package/pi-extension/src/conversation-history/search.ts +79 -0
- package/pi-extension/src/conversation-history/types.ts +31 -0
- package/pi-extension/src/freeflow-context/resolver.ts +139 -0
- package/pi-extension/src/freeflow-context/runtime.ts +100 -0
- package/pi-extension/src/freeflow-context/source-projector.ts +106 -0
- package/pi-extension/src/freeflow-context/tool.ts +360 -0
- package/pi-extension/src/freeflow-context/types.ts +70 -0
- package/pi-extension/src/freeflow-context/visibility.ts +53 -0
- package/pi-extension/src/index.ts +553 -101
- package/pi-extension/src/runtime/runtime-context.ts +339 -281
- package/pi-extension/src/runtime/runtime-identity.ts +8 -0
- package/pi-extension/src/settings/settings-tui.ts +93 -0
- package/pi-extension/src/settings/settings-ui.ts +700 -613
- package/pi-extension/src/ui/text-component.ts +66 -0
- package/pi-extension/tests/cognitive-routing/commands.test.js +134 -0
- package/pi-extension/tests/cognitive-routing/controller.test.js +1099 -0
- package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +1071 -0
- package/pi-extension/tests/cognitive-routing/history.test.js +274 -0
- package/pi-extension/tests/cognitive-routing/host-fixture.js +4 -0
- package/pi-extension/tests/cognitive-routing/host-identity.test.js +63 -0
- package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +236 -0
- package/pi-extension/tests/cognitive-routing/tool.test.js +230 -0
- package/pi-extension/tests/context-virtualization/extension.test.js +749 -0
- package/pi-extension/tests/context-virtualization/projector.test.js +110 -0
- package/pi-extension/tests/context-virtualization/runtime.test.js +216 -0
- package/pi-extension/tests/conversation-history/runtime.test.js +98 -0
- package/pi-extension/tests/conversation-history/search.test.js +97 -0
- package/pi-extension/tests/integration/pi-extension.test.js +928 -2047
- package/pi-extension/tests/integration/prompt-architecture.test.js +305 -0
- package/runtime/prompts/cognitive-routing.md +9 -0
- package/runtime/prompts/context-virtualization.md +3 -0
- package/runtime/prompts/conversation-history.md +3 -0
- package/runtime/prompts/core.md +13 -0
- package/runtime/prompts/interaction-contract.md +7 -0
- package/runtime/prompts/skills.md +65 -0
- package/skills/action-selection/SKILL.md +91 -0
- package/skills/bypass/SKILL.md +3 -2
- package/skills/commit-work/SKILL.md +1 -1
- package/skills/commit-work/references/staging-decisions.md +1 -1
- package/skills/decision-gate/SKILL.md +1 -1
- package/skills/design-for-depth/SKILL.md +14 -33
- package/skills/design-for-depth/references/design-pressure-signals.md +1 -1
- package/skills/design-for-depth/references/interface-design-loop.md +1 -1
- package/skills/design-for-depth/references/software-design-philosophy.md +1 -1
- package/skills/diagnose-failure/SKILL.md +20 -14
- package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +1 -3
- package/skills/diagnose-failure/references/{flaky-and-performance.md → flaky-and-performance-diagnosis.md} +1 -1
- package/skills/discuss/SKILL.md +34 -22
- package/skills/discuss/references/discussion-continuity.md +71 -0
- package/skills/evaluate-skill/SKILL.md +5 -5
- package/skills/evaluate-skill/references/{definition-schema.md → evaluation-definition-schema.md} +42 -2
- package/skills/evaluate-skill/references/execution-and-evidence.md +8 -3
- package/skills/evaluate-skill/scripts/lib/definitions.mjs +114 -3
- package/skills/evaluate-skill/scripts/lib/grade-interaction.mjs +156 -1
- package/skills/evaluate-skill/scripts/lib/grade.mjs +9 -1
- package/skills/evaluate-skill/scripts/lib/pi.mjs +147 -32
- package/skills/evaluate-skill/scripts/lib/rpc.mjs +4 -4
- package/skills/evaluate-skill/scripts/lib/runner.mjs +36 -14
- package/skills/evaluate-skill/scripts/lib/sandbox.mjs +92 -0
- package/skills/evaluate-skill/scripts/pi-guard.mjs +1 -1
- package/skills/evaluate-skill/scripts/pi-observer.mjs +66 -0
- package/skills/evaluate-skill/scripts/skill-eval.mjs +6 -5
- package/skills/execute-work/SKILL.md +18 -15
- package/skills/execute-work/references/code-practices.md +1 -1
- package/skills/execute-work/references/execute-work-edges.md +42 -0
- package/skills/finish-branch/SKILL.md +2 -2
- package/skills/finish-branch/references/integration-options.md +1 -1
- package/skills/handoff/SKILL.md +3 -3
- package/skills/launch-work/SKILL.md +1 -1
- package/skills/launch-work/references/launch-readiness.md +2 -2
- package/skills/migration-work/SKILL.md +2 -2
- package/skills/migration-work/references/migration-lifecycle.md +1 -1
- package/skills/mode-contract/SKILL.md +32 -10
- package/skills/release-work/SKILL.md +1 -1
- package/skills/release-work/references/release-evidence.md +1 -1
- package/skills/review-artifact/SKILL.md +28 -26
- package/skills/review-work/SKILL.md +28 -26
- package/skills/review-work/references/{reviewer-prompt.md → independent-work-reviewer-contract.md} +1 -1
- package/skills/review-work/references/security-risk-lens.md +1 -1
- package/skills/setup-freeflow/SKILL.md +6 -10
- package/skills/setup-freeflow/references/activation-contract.md +5 -10
- package/skills/setup-freeflow/references/host-setup.md +3 -7
- package/skills/simplify-code/SKILL.md +1 -1
- package/skills/simplify-code/references/simplification-patterns.md +1 -1
- package/skills/tdd/SKILL.md +18 -38
- package/skills/tdd/references/test-design.md +2 -2
- package/skills/track-work/SKILL.md +362 -58
- package/skills/track-work/scripts/lib/codec.mjs +570 -0
- package/skills/track-work/scripts/lib/commands.mjs +568 -0
- package/skills/track-work/scripts/lib/contract.mjs +303 -0
- package/skills/track-work/scripts/lib/model.mjs +506 -0
- package/skills/track-work/scripts/lib/operations.mjs +965 -0
- package/skills/track-work/scripts/lib/record-store.mjs +264 -0
- package/skills/track-work/scripts/lib/result.mjs +37 -0
- package/skills/track-work/scripts/lib/rewrites.mjs +740 -0
- package/skills/track-work/scripts/lib/schema.mjs +277 -0
- package/skills/track-work/scripts/lib/source-inventory.mjs +162 -0
- package/skills/track-work/scripts/lib/views.mjs +443 -0
- package/skills/track-work/scripts/lib/workspace.mjs +134 -0
- package/skills/track-work/scripts/working-record.mjs +122 -0
- package/skills/verify-work/SKILL.md +14 -2
- package/skills/verify-work/references/browser-runtime-evidence.md +1 -1
- package/skills/verify-work/references/integration-evidence.md +1 -1
- package/skills/verify-work/references/performance-evidence.md +1 -1
- package/skills/workflow/SKILL.md +105 -53
- package/skills/workflow/references/domain-skill-composition.md +22 -42
- package/skills/write-plan/SKILL.md +1 -1
- package/skills/write-skill/SKILL.md +3 -2
- package/skills/write-skill/references/progressive-disclosure.md +17 -3
- package/pi-extension/dist/output-router/host-producer-identification.js +0 -232
- package/pi-extension/dist/output-router/native-safety-net.js +0 -216
- package/pi-extension/dist/output-router/observed-tool-routing.js +0 -122
- package/pi-extension/dist/output-router/renderers.js +0 -1023
- package/pi-extension/dist/output-router/router-tools.js +0 -554
- package/pi-extension/dist/output-router/schemas.js +0 -383
- package/pi-extension/dist/output-router/status.js +0 -744
- package/pi-extension/dist/output-router/utils.js +0 -502
- package/pi-extension/src/output-router/host-producer-identification.ts +0 -256
- package/pi-extension/src/output-router/native-safety-net.ts +0 -248
- package/pi-extension/src/output-router/observed-tool-routing.ts +0 -134
- package/pi-extension/src/output-router/renderers.ts +0 -1108
- package/pi-extension/src/output-router/router-tools.ts +0 -579
- package/pi-extension/src/output-router/schemas.ts +0 -387
- package/pi-extension/src/output-router/status.ts +0 -791
- package/pi-extension/src/output-router/utils.ts +0 -554
- package/pi-extension/tests/output-router/observed-producers.test.js +0 -132
- package/pi-extension/tests/output-router/search.test.js +0 -722
- package/router/dist/benchmarks/benchmark-harness.d.ts +0 -35
- package/router/dist/benchmarks/benchmark-harness.js +0 -92
- package/router/dist/benchmarks/benchmarks.d.ts +0 -109
- package/router/dist/benchmarks/benchmarks.js +0 -979
- package/router/dist/benchmarks/codex-qa-benchmarks.d.ts +0 -95
- package/router/dist/benchmarks/codex-qa-benchmarks.js +0 -500
- package/router/dist/benchmarks/command-benchmarks.d.ts +0 -143
- package/router/dist/benchmarks/command-benchmarks.js +0 -698
- package/router/dist/benchmarks/context-mode-normalized-benchmarks.d.ts +0 -82
- package/router/dist/benchmarks/context-mode-normalized-benchmarks.js +0 -773
- package/router/dist/benchmarks/context-mode-real-deep-benchmark.d.ts +0 -132
- package/router/dist/benchmarks/context-mode-real-deep-benchmark.js +0 -1380
- package/router/dist/benchmarks/context-saving-baseline.d.ts +0 -60
- package/router/dist/benchmarks/context-saving-baseline.js +0 -470
- package/router/dist/benchmarks/index-benchmarks.d.ts +0 -103
- package/router/dist/benchmarks/index-benchmarks.js +0 -862
- package/router/dist/benchmarks/storage-policy-benchmarks.d.ts +0 -101
- package/router/dist/benchmarks/storage-policy-benchmarks.js +0 -618
- package/router/dist/benchmarks/vault-index-benchmarks.d.ts +0 -56
- package/router/dist/benchmarks/vault-index-benchmarks.js +0 -322
- package/router/dist/config/config.d.ts +0 -103
- package/router/dist/config/config.js +0 -632
- package/router/dist/config/router-contract.d.ts +0 -10
- package/router/dist/config/router-contract.js +0 -54
- package/router/dist/config/schema.d.ts +0 -27
- package/router/dist/config/schema.js +0 -648
- package/router/dist/config/types.d.ts +0 -573
- package/router/dist/config/types.js +0 -41
- package/router/dist/evidence/bounded-evidence.d.ts +0 -40
- package/router/dist/evidence/bounded-evidence.js +0 -323
- package/router/dist/evidence/evidence-range-selector.d.ts +0 -24
- package/router/dist/evidence/evidence-range-selector.js +0 -232
- package/router/dist/evidence/evidence-search.d.ts +0 -27
- package/router/dist/evidence/evidence-search.js +0 -490
- package/router/dist/evidence/evidence.d.ts +0 -38
- package/router/dist/evidence/evidence.js +0 -200
- package/router/dist/evidence/failure-contracts.d.ts +0 -37
- package/router/dist/evidence/failure-contracts.js +0 -166
- package/router/dist/evidence/line-ranges.d.ts +0 -24
- package/router/dist/evidence/line-ranges.js +0 -22
- package/router/dist/experiments/local-index.d.ts +0 -64
- package/router/dist/experiments/local-index.js +0 -581
- package/router/dist/index.d.ts +0 -30
- package/router/dist/index.js +0 -32
- package/router/dist/local/local-traversal.d.ts +0 -18
- package/router/dist/local/local-traversal.js +0 -334
- package/router/dist/processing/engine.d.ts +0 -132
- package/router/dist/processing/engine.js +0 -533
- package/router/dist/processing/reducers.d.ts +0 -280
- package/router/dist/processing/reducers.js +0 -1673
- package/router/dist/processing/renderers.d.ts +0 -31
- package/router/dist/processing/renderers.js +0 -195
- package/router/dist/processing/scripts.d.ts +0 -91
- package/router/dist/processing/scripts.js +0 -386
- package/router/dist/repo/repo-traversal.d.ts +0 -18
- package/router/dist/repo/repo-traversal.js +0 -245
- package/router/dist/routing/observed-reducers.d.ts +0 -41
- package/router/dist/routing/observed-reducers.js +0 -661
- package/router/dist/routing/observed-routing.d.ts +0 -26
- package/router/dist/routing/observed-routing.js +0 -378
- package/router/dist/routing/parsers.d.ts +0 -16
- package/router/dist/routing/parsers.js +0 -521
- package/router/dist/routing/run-filters.d.ts +0 -60
- package/router/dist/routing/run-filters.js +0 -238
- package/router/dist/routing/run-reducers.d.ts +0 -49
- package/router/dist/routing/run-reducers.js +0 -122
- package/router/dist/sandbox/adapter-roots.d.ts +0 -46
- package/router/dist/sandbox/adapter-roots.js +0 -66
- package/router/dist/sandbox/eryx-python-adapter.d.ts +0 -13
- package/router/dist/sandbox/eryx-python-adapter.js +0 -868
- package/router/dist/sandbox/jq-wasm-adapter.d.ts +0 -9
- package/router/dist/sandbox/jq-wasm-adapter.js +0 -429
- package/router/dist/sandbox/quickjs-wasi-adapter.d.ts +0 -13
- package/router/dist/sandbox/quickjs-wasi-adapter.js +0 -384
- package/router/dist/sandbox/script-sandbox.d.ts +0 -134
- package/router/dist/sandbox/script-sandbox.js +0 -337
- package/router/dist/setup/script-transform-adapters.d.ts +0 -32
- package/router/dist/setup/script-transform-adapters.js +0 -278
- package/router/dist/tools/batch.d.ts +0 -33
- package/router/dist/tools/batch.js +0 -586
- package/router/dist/tools/run.d.ts +0 -62
- package/router/dist/tools/run.js +0 -1304
- package/router/dist/tools/search.d.ts +0 -66
- package/router/dist/tools/search.js +0 -1364
- package/router/dist/transform/engine.d.ts +0 -168
- package/router/dist/transform/engine.js +0 -2072
- package/router/dist/vault/vault-index.d.ts +0 -125
- package/router/dist/vault/vault-index.js +0 -416
- package/router/dist/vault/vault.d.ts +0 -138
- package/router/dist/vault/vault.js +0 -630
- package/runtime/interaction-contract.md +0 -16
- package/skills/discuss/references/checkpoints.md +0 -66
- package/skills/execute-work/references/execution-loop.md +0 -77
- package/skills/output-router/SKILL.md +0 -206
- package/skills/output-router/references/safety-policy.md +0 -40
- package/skills/setup-freeflow/references/output-router-setup.md +0 -110
- package/skills/track-work/references/working-record-schema.md +0 -378
- package/skills/workflow/references/workflow-loop.md +0 -92
- /package/skills/handoff/references/{templates.md → handoff-templates.md} +0 -0
- /package/skills/review-artifact/references/{reviewer-prompt.md → independent-artifact-reviewer-contract.md} +0 -0
|
@@ -1,1023 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
extractTextContent,
|
|
3
|
-
formatStatus,
|
|
4
|
-
oneLine,
|
|
5
|
-
shortenMiddle,
|
|
6
|
-
splitLines,
|
|
7
|
-
statusIcon,
|
|
8
|
-
textComponent,
|
|
9
|
-
themeBold,
|
|
10
|
-
themeFg,
|
|
11
|
-
truncateText,
|
|
12
|
-
} from "./utils.js";
|
|
13
|
-
export function commandLabel(command) {
|
|
14
|
-
if (Array.isArray(command)) {
|
|
15
|
-
return truncateText(command.join(" "), 120);
|
|
16
|
-
}
|
|
17
|
-
return truncateText(command ?? "...", 120);
|
|
18
|
-
}
|
|
19
|
-
function runProducerLabel(args) {
|
|
20
|
-
if (args?.script?.language) {
|
|
21
|
-
const label = args.script.label ? ` ${args.script.label}` : "";
|
|
22
|
-
return `script:${args.script.language}${label}`;
|
|
23
|
-
}
|
|
24
|
-
return `$ ${commandLabel(args?.command)}`;
|
|
25
|
-
}
|
|
26
|
-
function retrieveSourceLabel(source) {
|
|
27
|
-
if (!source || source.kind === "repo") {
|
|
28
|
-
return `repo ${shortenMiddle(source?.path ?? ".", 80)}`;
|
|
29
|
-
}
|
|
30
|
-
if (source.kind === "local") {
|
|
31
|
-
const path = source.path ? `:${source.path}` : "";
|
|
32
|
-
return `local ${shortenMiddle(source.root ?? ".", 60)}${shortenMiddle(path, 50)}`;
|
|
33
|
-
}
|
|
34
|
-
if (source.kind === "vault") {
|
|
35
|
-
const stream = source.stream ? `:${source.stream}` : "";
|
|
36
|
-
return `vault ${shortenMiddle(source.outputId ?? "...", 48)}${stream}`;
|
|
37
|
-
}
|
|
38
|
-
return oneLine(source.kind ?? "source");
|
|
39
|
-
}
|
|
40
|
-
function evidenceLabel(evidence) {
|
|
41
|
-
if (!evidence) {
|
|
42
|
-
return "no evidence";
|
|
43
|
-
}
|
|
44
|
-
const source = evidence.source;
|
|
45
|
-
const path =
|
|
46
|
-
evidence.path ??
|
|
47
|
-
(source?.kind === "repo"
|
|
48
|
-
? source.path
|
|
49
|
-
: source?.kind === "local"
|
|
50
|
-
? source.path
|
|
51
|
-
: source?.kind === "vault"
|
|
52
|
-
? source.outputId
|
|
53
|
-
: "evidence");
|
|
54
|
-
const lines = evidence.lines ? `:${evidence.lines}` : "";
|
|
55
|
-
return `${shortenMiddle(path, 90)}${lines}`;
|
|
56
|
-
}
|
|
57
|
-
function excerptLines(theme, excerpt, indent = " ", maxLines = 8) {
|
|
58
|
-
const lines = splitLines(String(excerpt ?? ""));
|
|
59
|
-
const shown = lines
|
|
60
|
-
.slice(0, maxLines)
|
|
61
|
-
.map((line) => `${indent}${themeFg(theme, "toolOutput", truncateText(line, 140))}`);
|
|
62
|
-
const omitted = lines.length - shown.length;
|
|
63
|
-
if (omitted > 0) {
|
|
64
|
-
shown.push(`${indent}${themeFg(theme, "dim", `… ${omitted} more line(s)`)}`);
|
|
65
|
-
}
|
|
66
|
-
return shown;
|
|
67
|
-
}
|
|
68
|
-
function routeSummaryLine(theme, result) {
|
|
69
|
-
const route = result?.routing?.status ?? "unknown";
|
|
70
|
-
const preserve = result?.preserve ? ` • preserve: ${result.preserve}` : "";
|
|
71
|
-
return `${themeFg(theme, "muted", "routing:")} ${formatStatus(theme, route)}${themeFg(theme, "dim", preserve)}`;
|
|
72
|
-
}
|
|
73
|
-
function evidenceSourceSummary(source) {
|
|
74
|
-
if (!source || typeof source !== "object") {
|
|
75
|
-
return "unknown";
|
|
76
|
-
}
|
|
77
|
-
if (source.kind === "repo") {
|
|
78
|
-
return `repo ${source.path ?? "."}`;
|
|
79
|
-
}
|
|
80
|
-
if (source.kind === "local") {
|
|
81
|
-
const path = source.path ? `:${source.path}` : "";
|
|
82
|
-
return `local ${source.root ?? "."}${path}`;
|
|
83
|
-
}
|
|
84
|
-
if (source.kind === "vault") {
|
|
85
|
-
const stream = source.stream ? `:${source.stream}` : "";
|
|
86
|
-
return `vault ${source.outputId ?? "..."}${stream}`;
|
|
87
|
-
}
|
|
88
|
-
return oneLine(source.kind ?? "source");
|
|
89
|
-
}
|
|
90
|
-
function runFilterLabel(filters) {
|
|
91
|
-
if (!filters || typeof filters !== "object") {
|
|
92
|
-
return "";
|
|
93
|
-
}
|
|
94
|
-
const parts = [`stream=${filters.stream ?? "selected"}`];
|
|
95
|
-
if (Array.isArray(filters.include) && filters.include.length > 0) {
|
|
96
|
-
parts.push(`include=${filters.include.join("|")}`);
|
|
97
|
-
}
|
|
98
|
-
if (Array.isArray(filters.exclude) && filters.exclude.length > 0) {
|
|
99
|
-
parts.push(`exclude=${filters.exclude.join("|")}`);
|
|
100
|
-
}
|
|
101
|
-
if (filters.flags) {
|
|
102
|
-
parts.push(`flags=${filters.flags}`);
|
|
103
|
-
}
|
|
104
|
-
for (const key of ["head", "tail", "maxLines", "maxBytes"]) {
|
|
105
|
-
if (filters[key] !== undefined) {
|
|
106
|
-
parts.push(`${key}=${filters[key]}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (filters.selectedLines !== undefined && filters.sourceLines !== undefined) {
|
|
110
|
-
parts.push(`selected=${filters.selectedLines}/${filters.sourceLines}`);
|
|
111
|
-
}
|
|
112
|
-
if (filters.fallbackPreservedFailureEvidence) {
|
|
113
|
-
parts.push("fallback=failure-evidence");
|
|
114
|
-
}
|
|
115
|
-
return parts.join(" ");
|
|
116
|
-
}
|
|
117
|
-
function runScriptProducerLabel(scriptProducer) {
|
|
118
|
-
if (!scriptProducer || typeof scriptProducer !== "object") {
|
|
119
|
-
return "";
|
|
120
|
-
}
|
|
121
|
-
const parts = [
|
|
122
|
-
`${scriptProducer.language ?? "script"}:${scriptProducer.status ?? "unknown"}`,
|
|
123
|
-
`policy=${scriptProducer.policy ?? "sandboxed"}`,
|
|
124
|
-
];
|
|
125
|
-
if (scriptProducer.label) {
|
|
126
|
-
parts.push(`label=${scriptProducer.label}`);
|
|
127
|
-
}
|
|
128
|
-
if (scriptProducer.adapterId) {
|
|
129
|
-
parts.push(`adapter=${scriptProducer.adapterId}`);
|
|
130
|
-
}
|
|
131
|
-
if (scriptProducer.codeSha256) {
|
|
132
|
-
parts.push(`code=${scriptProducer.codeSha256}`);
|
|
133
|
-
}
|
|
134
|
-
if (scriptProducer.stdoutBytes !== undefined || scriptProducer.stderrBytes !== undefined) {
|
|
135
|
-
parts.push(`bytes=${scriptProducer.stdoutBytes ?? 0}/${scriptProducer.stderrBytes ?? 0}`);
|
|
136
|
-
}
|
|
137
|
-
if (scriptProducer.failure?.kind) {
|
|
138
|
-
parts.push(`failure=${scriptProducer.failure.kind}`);
|
|
139
|
-
}
|
|
140
|
-
return parts.join(" ");
|
|
141
|
-
}
|
|
142
|
-
function runScriptFilterLabel(scriptFilter) {
|
|
143
|
-
if (!scriptFilter || typeof scriptFilter !== "object") {
|
|
144
|
-
return "";
|
|
145
|
-
}
|
|
146
|
-
const parts = [`${scriptFilter.language ?? "script"}:${scriptFilter.status ?? "unknown"}`];
|
|
147
|
-
if (scriptFilter.label) {
|
|
148
|
-
parts.push(`label=${scriptFilter.label}`);
|
|
149
|
-
}
|
|
150
|
-
if (scriptFilter.outputId) {
|
|
151
|
-
parts.push(`transformed=${scriptFilter.outputId}`);
|
|
152
|
-
}
|
|
153
|
-
if (scriptFilter.failure?.kind) {
|
|
154
|
-
parts.push(`failure=${scriptFilter.failure.kind}`);
|
|
155
|
-
}
|
|
156
|
-
return parts.join(" ");
|
|
157
|
-
}
|
|
158
|
-
function appendStorageSection(lines, theme, routed, outputId, title = "Storage") {
|
|
159
|
-
const persistence = routed?.persistence;
|
|
160
|
-
const recoveryOutputId = persistence?.recoveryOutputId ?? persistence?.outputId ?? routed?.recovery?.outputId;
|
|
161
|
-
const hasStorage = routed?.decisionId || outputId || routed?.recordId || persistence?.status || recoveryOutputId;
|
|
162
|
-
if (!hasStorage) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
lines.push("", themeFg(theme, "toolTitle", title));
|
|
166
|
-
if (routed?.decisionId) {
|
|
167
|
-
lines.push(` ${themeFg(theme, "muted", "decisionId:")} ${themeFg(theme, "accent", routed.decisionId)}`);
|
|
168
|
-
}
|
|
169
|
-
if (outputId) {
|
|
170
|
-
lines.push(` ${themeFg(theme, "muted", "outputId:")} ${themeFg(theme, "accent", outputId)}`);
|
|
171
|
-
}
|
|
172
|
-
if (routed?.recordId) {
|
|
173
|
-
lines.push(` ${themeFg(theme, "muted", "recordId:")} ${themeFg(theme, "accent", routed.recordId)}`);
|
|
174
|
-
}
|
|
175
|
-
if (persistence?.status) {
|
|
176
|
-
lines.push(
|
|
177
|
-
` ${themeFg(theme, "muted", "persistence:")} ${persistence.status} / ${persistence.recoverability ?? "unknown"}`,
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
if (recoveryOutputId && recoveryOutputId !== outputId) {
|
|
181
|
-
lines.push(` ${themeFg(theme, "muted", "recoveryOutputId:")} ${themeFg(theme, "accent", recoveryOutputId)}`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function exactRetrieveHintFromEvidence(packet) {
|
|
185
|
-
if (!packet?.lines) {
|
|
186
|
-
return "";
|
|
187
|
-
}
|
|
188
|
-
const source = packet.source;
|
|
189
|
-
if (source?.kind === "vault" && source.outputId) {
|
|
190
|
-
return `action=retrieve source.kind=vault lineRange=${packet.lines} stream=${source.stream ?? "raw"} outputId=${source.outputId}`;
|
|
191
|
-
}
|
|
192
|
-
if (source?.kind === "local") {
|
|
193
|
-
const path = packet.path ?? source.path;
|
|
194
|
-
return path ? `action=retrieve source.kind=local lineRange=${packet.lines} root=${source.root} path=${path}` : "";
|
|
195
|
-
}
|
|
196
|
-
const path = packet.path ?? (source?.kind === "repo" ? source.path : undefined);
|
|
197
|
-
if (path && source?.kind !== "vault") {
|
|
198
|
-
return `action=retrieve source.kind=repo lineRange=${packet.lines} path=${path}`;
|
|
199
|
-
}
|
|
200
|
-
return "";
|
|
201
|
-
}
|
|
202
|
-
function firstExactRetrieveHintFromEvidence(evidence) {
|
|
203
|
-
if (!Array.isArray(evidence)) {
|
|
204
|
-
return "";
|
|
205
|
-
}
|
|
206
|
-
for (const packet of evidence) {
|
|
207
|
-
const hint = exactRetrieveHintFromEvidence(packet);
|
|
208
|
-
if (hint) {
|
|
209
|
-
return hint;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return "";
|
|
213
|
-
}
|
|
214
|
-
function exactRetrieveHintFromImportantLines(outputId, importantLines) {
|
|
215
|
-
if (!outputId || !Array.isArray(importantLines)) {
|
|
216
|
-
return "";
|
|
217
|
-
}
|
|
218
|
-
const firstSpan = importantLines.find((line) => line?.lines);
|
|
219
|
-
if (!firstSpan) {
|
|
220
|
-
return "";
|
|
221
|
-
}
|
|
222
|
-
return `action=retrieve source.kind=vault lineRange=${firstSpan.lines} stream=${firstSpan.stream ?? "combined"} outputId=${outputId}`;
|
|
223
|
-
}
|
|
224
|
-
function recoveryStartingPoint(outputId) {
|
|
225
|
-
return outputId
|
|
226
|
-
? `freeflow_search source.kind=vault outputId=${outputId} (choose stream + lineRange, or query/expand)`
|
|
227
|
-
: "";
|
|
228
|
-
}
|
|
229
|
-
function routerResultFromToolResult(result) {
|
|
230
|
-
return result?.details?.result;
|
|
231
|
-
}
|
|
232
|
-
function fallbackResultText(result) {
|
|
233
|
-
const text = extractTextContent(result?.content);
|
|
234
|
-
return text ? truncateText(text, 200) : "No Freeflow result details available.";
|
|
235
|
-
}
|
|
236
|
-
export function renderFreeflowSearchCall(args, theme) {
|
|
237
|
-
const title = themeFg(theme, "toolTitle", themeBold(theme, "freeflow_search"));
|
|
238
|
-
const action = themeFg(theme, "muted", args?.action ?? "query");
|
|
239
|
-
const source = themeFg(theme, "accent", retrieveSourceLabel(args?.source));
|
|
240
|
-
const query = args?.query ? ` ${themeFg(theme, "dim", `\"${truncateText(args.query, 70)}\"`)}` : "";
|
|
241
|
-
return textComponent(`${title} ${action} ${source}${query}`);
|
|
242
|
-
}
|
|
243
|
-
export function renderFreeflowRetrieveCall(args, theme) {
|
|
244
|
-
const title = themeFg(theme, "toolTitle", themeBold(theme, "freeflow_search"));
|
|
245
|
-
const action = themeFg(theme, "muted", args?.action ?? "query");
|
|
246
|
-
const source = themeFg(theme, "accent", retrieveSourceLabel(args?.source));
|
|
247
|
-
const query = args?.query ? ` ${themeFg(theme, "dim", `\"${truncateText(args.query, 70)}\"`)}` : "";
|
|
248
|
-
return textComponent(`${title} ${action} ${source}${query}`);
|
|
249
|
-
}
|
|
250
|
-
export function renderFreeflowRunCall(args, theme) {
|
|
251
|
-
const title = themeFg(theme, "toolTitle", themeBold(theme, "freeflow_run"));
|
|
252
|
-
const command = themeFg(theme, "accent", runProducerLabel(args));
|
|
253
|
-
const extras = [];
|
|
254
|
-
if (args?.preserve) {
|
|
255
|
-
extras.push(`preserve=${args.preserve}`);
|
|
256
|
-
}
|
|
257
|
-
if (args?.timeoutMs !== undefined) {
|
|
258
|
-
extras.push(`timeout=${args.timeoutMs}ms`);
|
|
259
|
-
}
|
|
260
|
-
if (args?.script?.language) {
|
|
261
|
-
extras.push(`producer=${args.script.language}`);
|
|
262
|
-
}
|
|
263
|
-
if (args?.scriptFilter?.language) {
|
|
264
|
-
extras.push(`scriptFilter=${args.scriptFilter.language}`);
|
|
265
|
-
}
|
|
266
|
-
const suffix = extras.length > 0 ? ` ${themeFg(theme, "dim", `(${extras.join(", ")})`)}` : "";
|
|
267
|
-
return textComponent(`${title} ${command}${suffix}`);
|
|
268
|
-
}
|
|
269
|
-
function transformOperationLabel(operation) {
|
|
270
|
-
if (!operation || typeof operation !== "object") {
|
|
271
|
-
return "operation";
|
|
272
|
-
}
|
|
273
|
-
return String(operation.kind ?? "operation");
|
|
274
|
-
}
|
|
275
|
-
export function renderFreeflowTransformCall(args, theme) {
|
|
276
|
-
const title = themeFg(theme, "toolTitle", themeBold(theme, "freeflow_search action=transform"));
|
|
277
|
-
const operation = themeFg(theme, "accent", transformOperationLabel(args?.operation));
|
|
278
|
-
const source = themeFg(theme, "muted", retrieveSourceLabel(args?.source));
|
|
279
|
-
const preserve = args?.preserve ? ` ${themeFg(theme, "dim", `(preserve=${args.preserve})`)}` : "";
|
|
280
|
-
return textComponent(`${title} ${operation} ${source}${preserve}`);
|
|
281
|
-
}
|
|
282
|
-
export function renderFreeflowBatchCall(args, theme) {
|
|
283
|
-
const title = themeFg(theme, "toolTitle", themeBold(theme, "freeflow_batch"));
|
|
284
|
-
const steps = Array.isArray(args?.steps) ? args.steps : [];
|
|
285
|
-
const kinds = steps
|
|
286
|
-
.slice(0, 4)
|
|
287
|
-
.map((step) => step?.kind ?? "step")
|
|
288
|
-
.join(", ");
|
|
289
|
-
const more = steps.length > 4 ? ` +${steps.length - 4}` : "";
|
|
290
|
-
const concurrency = args?.concurrency ? ` ${themeFg(theme, "dim", `(concurrency=${args.concurrency})`)}` : "";
|
|
291
|
-
return textComponent(
|
|
292
|
-
`${title} ${themeFg(theme, "accent", `${steps.length} step(s)`)} ${themeFg(theme, "muted", kinds + more)}${concurrency}`,
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
export function renderFreeflowBatchResult(result, { expanded } = {}, theme) {
|
|
296
|
-
const routed = routerResultFromToolResult(result);
|
|
297
|
-
if (!routed) {
|
|
298
|
-
return textComponent(fallbackResultText(result));
|
|
299
|
-
}
|
|
300
|
-
const failed = routed.failedCount ?? 0;
|
|
301
|
-
const icon = failed > 0 || routed.toolStatus === "error" ? "✗" : statusIcon(routed.toolStatus);
|
|
302
|
-
const steps = Array.isArray(routed.steps) ? routed.steps : [];
|
|
303
|
-
const lines = [
|
|
304
|
-
`${themeFg(theme, failed > 0 ? "warning" : "success", icon)} ${themeFg(theme, "toolTitle", "freeflow_batch")} ${themeFg(theme, "muted", `${routed.okCount ?? 0}/${routed.stepCount ?? steps.length} ok`)} • ${routeSummaryLine(theme, routed)}`,
|
|
305
|
-
];
|
|
306
|
-
if (routed.summary) {
|
|
307
|
-
lines.push(themeFg(theme, "muted", truncateText(routed.summary, 160)));
|
|
308
|
-
}
|
|
309
|
-
const queryAnswers = Array.isArray(routed.queries) ? routed.queries : [];
|
|
310
|
-
if (queryAnswers.length > 0) {
|
|
311
|
-
lines.push(
|
|
312
|
-
themeFg(
|
|
313
|
-
theme,
|
|
314
|
-
"dim",
|
|
315
|
-
`${queryAnswers.filter((answer) => answer?.status === "answered").length}/${queryAnswers.length} query answer(s) from child evidence handles`,
|
|
316
|
-
),
|
|
317
|
-
);
|
|
318
|
-
for (const answer of queryAnswers.slice(0, 3)) {
|
|
319
|
-
lines.push(themeFg(theme, "muted", truncateText(answer?.summary ?? answer?.query ?? "query", 180)));
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
lines.push(
|
|
323
|
-
themeFg(
|
|
324
|
-
theme,
|
|
325
|
-
"dim",
|
|
326
|
-
`concurrency=${routed.concurrency ?? "?"} • child outputs suppressed; full child results in details.result.steps`,
|
|
327
|
-
),
|
|
328
|
-
);
|
|
329
|
-
if (!expanded) {
|
|
330
|
-
lines.push(themeFg(theme, "dim", "ctrl+o to expand child step statuses and recovery pointers"));
|
|
331
|
-
return textComponent(lines.join("\n"));
|
|
332
|
-
}
|
|
333
|
-
if (queryAnswers.length > 0) {
|
|
334
|
-
lines.push("", themeFg(theme, "toolTitle", "Query answers"));
|
|
335
|
-
queryAnswers.forEach((answer, index) => {
|
|
336
|
-
lines.push(
|
|
337
|
-
` ${themeFg(theme, answer?.status === "answered" ? "accent" : "warning", `#${index + 1} ${answer?.status ?? "unknown"}`)} ${truncateText(answer?.query ?? "query", 120)}`,
|
|
338
|
-
);
|
|
339
|
-
if (answer?.summary) {
|
|
340
|
-
lines.push(` ${truncateText(answer.summary, 220)}`);
|
|
341
|
-
}
|
|
342
|
-
const matches = Array.isArray(answer?.matches) ? answer.matches : [];
|
|
343
|
-
matches.slice(0, 3).forEach((match) => {
|
|
344
|
-
lines.push(
|
|
345
|
-
` ${themeFg(theme, "muted", `${match.stepId ?? "step"}:`)} ${truncateText(match.excerpt ?? "", 180)}`,
|
|
346
|
-
);
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
lines.push("", themeFg(theme, "toolTitle", "Steps"));
|
|
351
|
-
if (steps.length === 0) {
|
|
352
|
-
lines.push(` ${themeFg(theme, "dim", "No steps returned.")}`);
|
|
353
|
-
} else {
|
|
354
|
-
steps.forEach((step) => {
|
|
355
|
-
const child = step.result;
|
|
356
|
-
const outputId = child?.outputId ?? child?.recovery?.outputId;
|
|
357
|
-
const status = step.status ?? child?.toolStatus ?? "unknown";
|
|
358
|
-
const pieces = [`${step.kind}`, `status=${status}`, `${step.durationMs ?? 0}ms`];
|
|
359
|
-
if (child?.routing?.status) {
|
|
360
|
-
pieces.push(`routing=${child.routing.status}`);
|
|
361
|
-
}
|
|
362
|
-
if (child?.execution?.status) {
|
|
363
|
-
pieces.push(`execution=${child.execution.status}`);
|
|
364
|
-
}
|
|
365
|
-
if (outputId) {
|
|
366
|
-
pieces.push(`outputId=${outputId}`);
|
|
367
|
-
}
|
|
368
|
-
if (Array.isArray(child?.evidence)) {
|
|
369
|
-
pieces.push(`evidence=${child.evidence.length}`);
|
|
370
|
-
}
|
|
371
|
-
if (Array.isArray(child?.importantLines)) {
|
|
372
|
-
pieces.push(`spans=${child.importantLines.length}`);
|
|
373
|
-
}
|
|
374
|
-
lines.push(
|
|
375
|
-
` ${themeFg(theme, status === "failed" ? "warning" : "accent", `#${step.index + 1} ${step.id}`)} ${themeFg(theme, "muted", pieces.join(" • "))}`,
|
|
376
|
-
);
|
|
377
|
-
const message = step.error ?? child?.failure?.message ?? child?.summary ?? child?.routing?.reason;
|
|
378
|
-
if (message) {
|
|
379
|
-
lines.push(` ${truncateText(message, 180)}`);
|
|
380
|
-
}
|
|
381
|
-
if (outputId) {
|
|
382
|
-
lines.push(` ${themeFg(theme, "muted", "recovery starting point:")} ${recoveryStartingPoint(outputId)}`);
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
lines.push("", themeFg(theme, "toolTitle", "Batch recovery"));
|
|
387
|
-
if (routed.recovery?.how) {
|
|
388
|
-
lines.push(` ${truncateText(routed.recovery.how, 220)}`);
|
|
389
|
-
}
|
|
390
|
-
lines.push(
|
|
391
|
-
` ${themeFg(theme, "dim", "Use details.result.steps for complete child routed results; model-visible output intentionally omits child excerpts.")}`,
|
|
392
|
-
);
|
|
393
|
-
return textComponent(lines.join("\n"));
|
|
394
|
-
}
|
|
395
|
-
export function renderFreeflowStatusCall(args, theme) {
|
|
396
|
-
const title = themeFg(theme, "toolTitle", themeBold(theme, "freeflow_status"));
|
|
397
|
-
const action = themeFg(theme, "accent", args?.action ?? "status");
|
|
398
|
-
return textComponent(`${title} ${action}`);
|
|
399
|
-
}
|
|
400
|
-
export function renderFreeflowStatusResult(result, { expanded } = {}, theme) {
|
|
401
|
-
const report = routerResultFromToolResult(result);
|
|
402
|
-
if (!report) {
|
|
403
|
-
return textComponent(fallbackResultText(result));
|
|
404
|
-
}
|
|
405
|
-
const warnings = Array.isArray(report.configWarnings) ? report.configWarnings : [];
|
|
406
|
-
const localWarnings = Array.isArray(report.localConfigWarnings) ? report.localConfigWarnings : [];
|
|
407
|
-
const allWarnings = [...warnings, ...localWarnings];
|
|
408
|
-
const recommendations = Array.isArray(report.migration?.recommendations) ? report.migration.recommendations : [];
|
|
409
|
-
const core = report.effectiveConfig ?? {};
|
|
410
|
-
const sources = report.configuration?.sources ?? core.sources ?? {};
|
|
411
|
-
const router = core.outputRouter ?? {};
|
|
412
|
-
const observedRouting = report.observedRouting ?? core.observedRouting ?? {};
|
|
413
|
-
const unsafeProcessing = report.processing?.unsafeUnsandboxed?.enabled === true;
|
|
414
|
-
const modeActive = report.mode?.active === true;
|
|
415
|
-
const resolvedMode = report.mode?.resolvedMode ?? report.mode?.effectiveMode ?? "workflow";
|
|
416
|
-
const displayedMode = modeActive ? resolvedMode : `dormant (${resolvedMode})`;
|
|
417
|
-
const icon = statusIcon(report.toolStatus);
|
|
418
|
-
const lines = [
|
|
419
|
-
`${themeFg(theme, "success", icon)} ${themeFg(theme, "toolTitle", "freeflow_status")} ${themeFg(theme, "muted", report.action ?? "status")} • freeflow ${formatStatus(theme, core.enabled ? "ok" : "off")} • mode ${themeFg(theme, modeActive ? "accent" : "dim", displayedMode)} • router ${formatStatus(theme, router.enabled === false ? "off" : "ok")}`,
|
|
420
|
-
`${themeFg(theme, "muted", "vault:")} ${themeFg(theme, "accent", shortenMiddle(report.vault?.root ?? "unknown", 80))} ${themeFg(theme, "dim", report.vault?.writability?.status ?? "unknown")}`,
|
|
421
|
-
`${themeFg(theme, "muted", "routing:")} observed=${observedRouting.enabled ? "on" : "off"} • processing=${unsafeProcessing ? "unsafe/unsandboxed" : "safe-default"} • warnings=${allWarnings.length} • migrations=${recommendations.length}`,
|
|
422
|
-
];
|
|
423
|
-
if (!expanded) {
|
|
424
|
-
lines.push(
|
|
425
|
-
themeFg(
|
|
426
|
-
theme,
|
|
427
|
-
"dim",
|
|
428
|
-
"ctrl+o to expand configuration sources, effective state, routing, warnings, and migrations",
|
|
429
|
-
),
|
|
430
|
-
);
|
|
431
|
-
return textComponent(lines.join("\n"));
|
|
432
|
-
}
|
|
433
|
-
const repository = report.configuration?.repository ?? {};
|
|
434
|
-
const personal = report.configuration?.personal ?? {};
|
|
435
|
-
lines.push("", themeFg(theme, "toolTitle", "Configuration"));
|
|
436
|
-
lines.push(
|
|
437
|
-
` ${themeFg(theme, "muted", "repository:")} ${repository.exists ? (repository.valid ? "valid" : themeFg(theme, "warning", "invalid")) : "missing"} ${themeFg(theme, "dim", shortenMiddle(repository.path ?? report.configPath ?? ".freeflow/config.json", 90))}`,
|
|
438
|
-
);
|
|
439
|
-
lines.push(
|
|
440
|
-
` ${themeFg(theme, "muted", "personal:")} ${personal.exists ? (personal.valid ? "valid" : themeFg(theme, "warning", "invalid")) : "not set"} ${themeFg(theme, "dim", shortenMiddle(personal.path ?? report.localConfigPath ?? ".freeflow/local.json", 90))}`,
|
|
441
|
-
);
|
|
442
|
-
lines.push(
|
|
443
|
-
` ${themeFg(theme, "muted", "enabled:")} ${String(Boolean(core.enabled))} ${themeFg(theme, "dim", `(${sources.enabled ?? "builtin"})`)}`,
|
|
444
|
-
);
|
|
445
|
-
lines.push(
|
|
446
|
-
` ${themeFg(theme, "muted", "interactionContract:")} ${String(Boolean(core.interactionContract?.enabled))} ${themeFg(theme, "dim", `(${sources.interactionContract ?? "builtin"})`)}`,
|
|
447
|
-
);
|
|
448
|
-
lines.push(
|
|
449
|
-
` ${themeFg(theme, "muted", "skills:")} ${String(Boolean(core.skills?.enabled))} ${themeFg(theme, "dim", `(${sources.skillsEnabled ?? "builtin"})`)}`,
|
|
450
|
-
);
|
|
451
|
-
lines.push("", themeFg(theme, "toolTitle", "Mode"));
|
|
452
|
-
lines.push(` ${themeFg(theme, "muted", "active:")} ${String(modeActive)}`);
|
|
453
|
-
lines.push(` ${themeFg(theme, "muted", "effective:")} ${report.mode?.effectiveMode ?? "none"}`);
|
|
454
|
-
lines.push(` ${themeFg(theme, "muted", "resolved:")} ${resolvedMode}`);
|
|
455
|
-
lines.push(
|
|
456
|
-
` ${themeFg(theme, "muted", "repository default:")} ${report.mode?.repositoryDefaultMode ?? "workflow"} ${themeFg(theme, "dim", `(${report.mode?.repositoryDefaultModeSource ?? "builtin"})`)}`,
|
|
457
|
-
);
|
|
458
|
-
lines.push(
|
|
459
|
-
` ${themeFg(theme, "muted", "personal default override:")} ${report.mode?.personalDefaultMode ?? "none"}`,
|
|
460
|
-
);
|
|
461
|
-
lines.push(
|
|
462
|
-
` ${themeFg(theme, "muted", "configured default:")} ${report.mode?.defaultMode ?? "workflow"} ${themeFg(theme, "dim", `(${report.mode?.defaultModeSource ?? sources.defaultMode ?? "builtin"})`)}`,
|
|
463
|
-
);
|
|
464
|
-
lines.push(
|
|
465
|
-
` ${themeFg(theme, "muted", "session override:")} ${report.mode?.sessionMode ?? report.mode?.currentMode ?? "none"}`,
|
|
466
|
-
);
|
|
467
|
-
lines.push("", themeFg(theme, "toolTitle", "Router"));
|
|
468
|
-
lines.push(` ${themeFg(theme, "muted", "enabled:")} ${String(router.enabled !== false)}`);
|
|
469
|
-
lines.push(` ${themeFg(theme, "muted", "profile:")} ${router.profile ?? "standard"}`);
|
|
470
|
-
lines.push(` ${themeFg(theme, "muted", "postToolRouting:")} ${router.postToolRouting ?? "off"}`);
|
|
471
|
-
lines.push(` ${themeFg(theme, "muted", "storagePolicy:")} ${router.storagePolicy ?? "hybrid-dedupe"}`);
|
|
472
|
-
if (router.thresholds) {
|
|
473
|
-
lines.push(` ${themeFg(theme, "muted", "thresholds:")} ${JSON.stringify(router.thresholds)}`);
|
|
474
|
-
}
|
|
475
|
-
const vaultIndex = report.vaultIndex;
|
|
476
|
-
if (vaultIndex) {
|
|
477
|
-
lines.push("", themeFg(theme, "toolTitle", "Vault index"));
|
|
478
|
-
lines.push(` ${themeFg(theme, "muted", "engine:")} ${vaultIndex.engine ?? "local-json-sidecar"}`);
|
|
479
|
-
lines.push(
|
|
480
|
-
` ${themeFg(theme, "muted", "available:")} ${String(Boolean(vaultIndex.available))} degraded=${String(Boolean(vaultIndex.degraded))} stale=${String(Boolean(vaultIndex.stale))} rebuildRecommended=${String(Boolean(vaultIndex.rebuildRecommended))}`,
|
|
481
|
-
);
|
|
482
|
-
lines.push(
|
|
483
|
-
` ${themeFg(theme, "muted", "entries:")} ${vaultIndex.entryCount ?? 0} text=${vaultIndex.textEntryCount ?? 0} metadata=${vaultIndex.metadataOnlyEntryCount ?? 0}`,
|
|
484
|
-
);
|
|
485
|
-
if (vaultIndex.lastError) {
|
|
486
|
-
lines.push(` ${themeFg(theme, "warning", `lastError: ${truncateText(vaultIndex.lastError, 160)}`)}`);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
const scriptTransform = report.scriptTransform;
|
|
490
|
-
if (scriptTransform) {
|
|
491
|
-
lines.push("", themeFg(theme, "toolTitle", "Script transform"));
|
|
492
|
-
lines.push(` ${themeFg(theme, "muted", "enabled:")} ${String(Boolean(scriptTransform.enabled))}`);
|
|
493
|
-
lines.push(` ${themeFg(theme, "muted", "adapter:")} ${scriptTransform.adapterStatus ?? "unavailable"}`);
|
|
494
|
-
lines.push(
|
|
495
|
-
` ${themeFg(theme, "muted", "languages:")} ${(scriptTransform.configuredLanguages ?? []).join(", ") || "none"}`,
|
|
496
|
-
);
|
|
497
|
-
lines.push(` ${themeFg(theme, "muted", "network:")} ${scriptTransform.network ?? "off"}`);
|
|
498
|
-
lines.push(
|
|
499
|
-
` ${themeFg(theme, "muted", "rawScriptPersistence:")} ${scriptTransform.rawScriptPersistence ?? "disabled"}`,
|
|
500
|
-
);
|
|
501
|
-
if (scriptTransform.adapterHome) {
|
|
502
|
-
lines.push(` ${themeFg(theme, "muted", "adapterHome:")} ${shortenMiddle(scriptTransform.adapterHome, 90)}`);
|
|
503
|
-
}
|
|
504
|
-
if (scriptTransform.setupCommand && scriptTransform.adapterStatus !== "available") {
|
|
505
|
-
lines.push(` ${themeFg(theme, "muted", "setup:")} ${truncateText(scriptTransform.setupCommand, 140)}`);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
const processing = report.processing?.unsafeUnsandboxed;
|
|
509
|
-
if (processing) {
|
|
510
|
-
lines.push("", themeFg(theme, "toolTitle", "Processing"));
|
|
511
|
-
lines.push(
|
|
512
|
-
` ${themeFg(theme, "muted", "unsafeUnsandboxed:")} ${processing.enabled ? themeFg(theme, "warning", "enabled unsafe/unsandboxed") : "disabled"}`,
|
|
513
|
-
);
|
|
514
|
-
lines.push(` ${themeFg(theme, "muted", "source:")} ${processing.source ?? ".freeflow/local.json"}`);
|
|
515
|
-
const notes = Array.isArray(processing.notes) ? processing.notes : [];
|
|
516
|
-
notes
|
|
517
|
-
.slice(0, 2)
|
|
518
|
-
.forEach((note) =>
|
|
519
|
-
lines.push(` ${themeFg(theme, processing.enabled ? "warning" : "dim", truncateText(note, 180))}`),
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
|
-
lines.push("", themeFg(theme, "toolTitle", "Observed routing"));
|
|
523
|
-
lines.push(` ${themeFg(theme, "muted", "enabled:")} ${String(Boolean(observedRouting.enabled))}`);
|
|
524
|
-
lines.push(` ${themeFg(theme, "muted", "onRoutingFailure:")} ${observedRouting.onRoutingFailure ?? "fail-open"}`);
|
|
525
|
-
lines.push(
|
|
526
|
-
` ${themeFg(theme, "muted", "host:")} ${observedRouting.host?.name ?? "pi"} outputReplacement=${observedRouting.host?.outputReplacement ?? "available"}`,
|
|
527
|
-
);
|
|
528
|
-
lines.push(` ${themeFg(theme, "muted", "mcp servers:")} ${observedRouting.mcp?.configuredServerCount ?? 0}`);
|
|
529
|
-
if (observedRouting.web || observedRouting.fetch || observedRouting.codeSearch) {
|
|
530
|
-
lines.push(
|
|
531
|
-
` ${themeFg(theme, "muted", "web/fetch/codeSearch:")} web=${observedRouting.web?.enabled ? "on" : "off"} fetch=${observedRouting.fetch?.enabled ? "on" : "off"} codeSearch=${observedRouting.codeSearch?.enabled ? "on" : "off"}`,
|
|
532
|
-
);
|
|
533
|
-
}
|
|
534
|
-
if (allWarnings.length > 0) {
|
|
535
|
-
lines.push("", themeFg(theme, "toolTitle", "Warnings"));
|
|
536
|
-
allWarnings
|
|
537
|
-
.slice(0, 8)
|
|
538
|
-
.forEach((warning) => lines.push(` ${themeFg(theme, "warning", truncateText(warning, 180))}`));
|
|
539
|
-
}
|
|
540
|
-
if (recommendations.length > 0) {
|
|
541
|
-
lines.push("", themeFg(theme, "toolTitle", "Migration recommendations"));
|
|
542
|
-
recommendations
|
|
543
|
-
.slice(0, 8)
|
|
544
|
-
.forEach((item) =>
|
|
545
|
-
lines.push(
|
|
546
|
-
` ${themeFg(theme, "accent", item.path)} ${themeFg(theme, "muted", item.action)} — ${truncateText(item.message, 160)}`,
|
|
547
|
-
),
|
|
548
|
-
);
|
|
549
|
-
lines.push(
|
|
550
|
-
` ${themeFg(theme, "dim", "No config was rewritten; confirmation is required before applying recommendations.")}`,
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
return textComponent(lines.join("\n"));
|
|
554
|
-
}
|
|
555
|
-
export function renderFreeflowSearchResult(result, options = {}, theme) {
|
|
556
|
-
const routed = routerResultFromToolResult(result);
|
|
557
|
-
if (routed?.implementation === "processing-engine-skeleton-v1") {
|
|
558
|
-
return renderFreeflowProcessingResult(result, options, theme);
|
|
559
|
-
}
|
|
560
|
-
if (routed?.routing?.route === "transform") {
|
|
561
|
-
return renderFreeflowTransformResult(result, options, theme, "freeflow_search");
|
|
562
|
-
}
|
|
563
|
-
return renderFreeflowRetrieveResult(result, options, theme, "freeflow_search");
|
|
564
|
-
}
|
|
565
|
-
function renderFreeflowProcessingResult(result, { expanded } = {}, theme) {
|
|
566
|
-
const routed = routerResultFromToolResult(result);
|
|
567
|
-
if (!routed) {
|
|
568
|
-
return textComponent(fallbackResultText(result));
|
|
569
|
-
}
|
|
570
|
-
const icon = routed.status === "ok" ? "✓" : routed.status === "blocked" ? "✗" : "!";
|
|
571
|
-
const unsafe = routed.script && "policy" in routed.script && routed.script.policy === "unsafe-unsandboxed";
|
|
572
|
-
const lines = [
|
|
573
|
-
`${themeFg(theme, unsafe ? "warning" : routed.status === "ok" ? "success" : "warning", icon)} ${themeFg(theme, "toolTitle", "freeflow_search")} ${themeFg(theme, "muted", "transform")} • ${formatStatus(theme, routed.status ?? "unknown")}${unsafe ? themeFg(theme, "warning", " • unsafe/unsandboxed") : ""}`,
|
|
574
|
-
];
|
|
575
|
-
const visibleLines = splitLines(String(routed.visibleText ?? ""));
|
|
576
|
-
visibleLines
|
|
577
|
-
.slice(0, expanded ? 20 : 4)
|
|
578
|
-
.forEach((line) =>
|
|
579
|
-
lines.push(
|
|
580
|
-
themeFg(
|
|
581
|
-
theme,
|
|
582
|
-
unsafe && line.includes("unsafe/unsandboxed") ? "warning" : "toolOutput",
|
|
583
|
-
truncateText(line, 160),
|
|
584
|
-
),
|
|
585
|
-
),
|
|
586
|
-
);
|
|
587
|
-
if (visibleLines.length > (expanded ? 20 : 4)) {
|
|
588
|
-
lines.push(themeFg(theme, "dim", `… ${visibleLines.length - (expanded ? 20 : 4)} more line(s)`));
|
|
589
|
-
}
|
|
590
|
-
if (!expanded) {
|
|
591
|
-
lines.push(themeFg(theme, "dim", "ctrl+o to expand transform details and recovery"));
|
|
592
|
-
return textComponent(lines.join("\n"));
|
|
593
|
-
}
|
|
594
|
-
lines.push("", themeFg(theme, "toolTitle", "Source"));
|
|
595
|
-
lines.push(` ${themeFg(theme, "accent", routed.source?.displayPath ?? "source")}`);
|
|
596
|
-
if (routed.stats) {
|
|
597
|
-
lines.push(` ${themeFg(theme, "muted", "stats:")} ${routed.stats.bytes} bytes • ${routed.stats.lines} lines`);
|
|
598
|
-
}
|
|
599
|
-
if (routed.reducer?.status) {
|
|
600
|
-
lines.push("", themeFg(theme, "toolTitle", "Reducer"));
|
|
601
|
-
lines.push(` ${routed.reducer.status}${routed.reducer.selected?.name ? ` ${routed.reducer.selected.name}` : ""}`);
|
|
602
|
-
}
|
|
603
|
-
if (routed.script?.status) {
|
|
604
|
-
lines.push("", themeFg(theme, "toolTitle", "Script"));
|
|
605
|
-
lines.push(` ${themeFg(theme, "muted", "status:")} ${routed.script.status}`);
|
|
606
|
-
if (routed.script.policy) lines.push(` ${themeFg(theme, "muted", "policy:")} ${routed.script.policy}`);
|
|
607
|
-
if (routed.script.unsafeUnsandboxed) lines.push(` ${themeFg(theme, "warning", "unsafe/unsandboxed local-yolo")}`);
|
|
608
|
-
}
|
|
609
|
-
if (routed.recovery?.how) {
|
|
610
|
-
lines.push("", themeFg(theme, "toolTitle", "Recovery"));
|
|
611
|
-
lines.push(` ${truncateText(routed.recovery.how, 180)}`);
|
|
612
|
-
if (routed.recovery.outputId)
|
|
613
|
-
lines.push(` ${themeFg(theme, "muted", "outputId:")} ${themeFg(theme, "accent", routed.recovery.outputId)}`);
|
|
614
|
-
}
|
|
615
|
-
return textComponent(lines.join("\n"));
|
|
616
|
-
}
|
|
617
|
-
export function renderFreeflowRetrieveResult(result, { expanded } = {}, theme, toolTitle = "freeflow_search") {
|
|
618
|
-
const routed = routerResultFromToolResult(result);
|
|
619
|
-
if (!routed) {
|
|
620
|
-
return textComponent(fallbackResultText(result));
|
|
621
|
-
}
|
|
622
|
-
const evidence = Array.isArray(routed.evidence) ? routed.evidence : [];
|
|
623
|
-
const firstEvidence = evidence[0];
|
|
624
|
-
const icon = statusIcon(routed.toolStatus);
|
|
625
|
-
const lines = [
|
|
626
|
-
`${themeFg(theme, "success", icon)} ${themeFg(theme, "toolTitle", toolTitle)} ${themeFg(theme, "muted", `${evidence.length} evidence packet(s)`)} • ${routeSummaryLine(theme, routed)}`,
|
|
627
|
-
];
|
|
628
|
-
if (firstEvidence) {
|
|
629
|
-
lines.push(
|
|
630
|
-
`${themeFg(theme, "accent", evidenceLabel(firstEvidence))}${firstEvidence.expandable ? themeFg(theme, "dim", " • expandable") : ""}`,
|
|
631
|
-
);
|
|
632
|
-
} else {
|
|
633
|
-
lines.push(
|
|
634
|
-
themeFg(theme, "warning", truncateText(routed.routing?.reason ?? "No matching evidence returned.", 140)),
|
|
635
|
-
);
|
|
636
|
-
}
|
|
637
|
-
if (!expanded) {
|
|
638
|
-
lines.push(themeFg(theme, "dim", "ctrl+o to expand evidence and recovery details"));
|
|
639
|
-
return textComponent(lines.join("\n"));
|
|
640
|
-
}
|
|
641
|
-
lines.push("", themeFg(theme, "toolTitle", "Source"));
|
|
642
|
-
lines.push(` ${themeFg(theme, "accent", retrieveSourceLabel(routed.source))}`);
|
|
643
|
-
if (routed.preserve) {
|
|
644
|
-
lines.push(` ${themeFg(theme, "muted", "preserve:")} ${routed.preserve}`);
|
|
645
|
-
}
|
|
646
|
-
appendStorageSection(lines, theme, routed, routed.outputId || routed.recovery?.outputId);
|
|
647
|
-
lines.push("", themeFg(theme, "toolTitle", "Routing"));
|
|
648
|
-
lines.push(` ${themeFg(theme, "muted", "toolStatus:")} ${formatStatus(theme, routed.toolStatus)}`);
|
|
649
|
-
lines.push(` ${themeFg(theme, "muted", "routing.status:")} ${formatStatus(theme, routed.routing?.status)}`);
|
|
650
|
-
lines.push(` ${themeFg(theme, "muted", "route:")} ${routed.routing?.route ?? "retrieve"}`);
|
|
651
|
-
if (routed.routing?.reason) {
|
|
652
|
-
lines.push(` ${themeFg(theme, "muted", "reason:")} ${truncateText(routed.routing.reason, 160)}`);
|
|
653
|
-
}
|
|
654
|
-
lines.push("", themeFg(theme, "toolTitle", "Evidence"));
|
|
655
|
-
if (evidence.length === 0) {
|
|
656
|
-
lines.push(` ${themeFg(theme, "dim", "No evidence packets returned.")}`);
|
|
657
|
-
} else {
|
|
658
|
-
evidence.forEach((packet, index) => {
|
|
659
|
-
lines.push(
|
|
660
|
-
` ${themeFg(theme, "accent", `#${index + 1} ${evidenceLabel(packet)}`)} ${themeFg(theme, "dim", `window=${packet.window}`)}`,
|
|
661
|
-
);
|
|
662
|
-
if (packet.id) {
|
|
663
|
-
lines.push(` ${themeFg(theme, "muted", "evidenceId:")} ${themeFg(theme, "accent", packet.id)}`);
|
|
664
|
-
}
|
|
665
|
-
if (packet.source) {
|
|
666
|
-
lines.push(` ${themeFg(theme, "muted", "source:")} ${evidenceSourceSummary(packet.source)}`);
|
|
667
|
-
}
|
|
668
|
-
if (packet.expandable !== undefined) {
|
|
669
|
-
lines.push(` ${themeFg(theme, "muted", "expandable:")} ${String(Boolean(packet.expandable))}`);
|
|
670
|
-
}
|
|
671
|
-
const exactHint = exactRetrieveHintFromEvidence(packet);
|
|
672
|
-
if (exactHint) {
|
|
673
|
-
lines.push(` ${themeFg(theme, "muted", "exact search:")} ${exactHint}`);
|
|
674
|
-
}
|
|
675
|
-
if (packet.why) {
|
|
676
|
-
lines.push(` ${themeFg(theme, "muted", "why:")} ${truncateText(packet.why, 160)}`);
|
|
677
|
-
}
|
|
678
|
-
lines.push(...excerptLines(theme, packet.excerpt, " ", 8));
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
if (routed.recovery?.how) {
|
|
682
|
-
lines.push("", themeFg(theme, "toolTitle", "Recovery"));
|
|
683
|
-
lines.push(` ${truncateText(routed.recovery.how, 180)}`);
|
|
684
|
-
if (routed.recovery.outputId) {
|
|
685
|
-
lines.push(` ${themeFg(theme, "muted", "outputId:")} ${themeFg(theme, "accent", routed.recovery.outputId)}`);
|
|
686
|
-
}
|
|
687
|
-
const exactHint = firstExactRetrieveHintFromEvidence(evidence);
|
|
688
|
-
if (exactHint) {
|
|
689
|
-
lines.push(` ${themeFg(theme, "muted", "exact search:")} ${exactHint}`);
|
|
690
|
-
} else if (routed.recovery.outputId) {
|
|
691
|
-
lines.push(
|
|
692
|
-
` ${themeFg(theme, "muted", "recovery starting point:")} ${recoveryStartingPoint(routed.recovery.outputId)}`,
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
if (routed.recovery.evidenceId) {
|
|
696
|
-
lines.push(` ${themeFg(theme, "muted", "evidenceId:")} ${themeFg(theme, "accent", routed.recovery.evidenceId)}`);
|
|
697
|
-
lines.push(
|
|
698
|
-
` ${themeFg(theme, "muted", "expand hint:")} freeflow_search action=expand evidenceId=${routed.recovery.evidenceId}`,
|
|
699
|
-
);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
return textComponent(lines.join("\n"));
|
|
703
|
-
}
|
|
704
|
-
export function renderFreeflowRunResult(result, { expanded } = {}, theme, context = {}) {
|
|
705
|
-
const routed = routerResultFromToolResult(result);
|
|
706
|
-
if (!routed) {
|
|
707
|
-
return textComponent(fallbackResultText(result));
|
|
708
|
-
}
|
|
709
|
-
const executionStatus = routed.execution?.status ?? routed.toolStatus;
|
|
710
|
-
const outputId = routed.outputId;
|
|
711
|
-
const exactRecoveryOutputId = routed.persistence?.recoverability === "exact" ? outputId : routed.recovery?.outputId;
|
|
712
|
-
const icon = statusIcon(executionStatus);
|
|
713
|
-
const importantLines = Array.isArray(routed.importantLines) ? routed.importantLines : [];
|
|
714
|
-
const lines = [
|
|
715
|
-
`${themeFg(theme, executionStatus === "failed" ? "error" : "success", icon)} ${themeFg(theme, "toolTitle", "freeflow_run")} ${themeFg(theme, "muted", "execution:")} ${formatStatus(theme, executionStatus)} • ${routeSummaryLine(theme, routed)}`,
|
|
716
|
-
];
|
|
717
|
-
const statusParts = [];
|
|
718
|
-
if (routed.execution?.exitCode !== undefined && routed.execution?.exitCode !== null) {
|
|
719
|
-
statusParts.push(`exit ${routed.execution.exitCode}`);
|
|
720
|
-
}
|
|
721
|
-
if (routed.execution?.durationMs !== undefined) {
|
|
722
|
-
statusParts.push(`${routed.execution.durationMs}ms`);
|
|
723
|
-
}
|
|
724
|
-
if (outputId) {
|
|
725
|
-
statusParts.push(
|
|
726
|
-
`${routed.persistence?.recoverability === "metadata_only" ? "metadataId" : "outputId"} ${outputId}`,
|
|
727
|
-
);
|
|
728
|
-
}
|
|
729
|
-
if (exactRecoveryOutputId && exactRecoveryOutputId !== outputId) {
|
|
730
|
-
statusParts.push(`exact ${exactRecoveryOutputId}`);
|
|
731
|
-
}
|
|
732
|
-
if (routed.scriptFilter?.outputId) {
|
|
733
|
-
statusParts.push(`transformed ${routed.scriptFilter.outputId}`);
|
|
734
|
-
}
|
|
735
|
-
if (routed.reducer?.outputId) {
|
|
736
|
-
statusParts.push(`reduced ${routed.reducer.outputId}`);
|
|
737
|
-
}
|
|
738
|
-
if (routed.parser?.name) {
|
|
739
|
-
statusParts.push(`parser ${routed.parser.name} ${Number(routed.parser.confidence ?? 0).toFixed(2)}`);
|
|
740
|
-
}
|
|
741
|
-
if (statusParts.length > 0) {
|
|
742
|
-
lines.push(themeFg(theme, "accent", statusParts.join(" • ")));
|
|
743
|
-
}
|
|
744
|
-
if (routed.summary) {
|
|
745
|
-
lines.push(themeFg(theme, "muted", truncateText(routed.summary, 140)));
|
|
746
|
-
}
|
|
747
|
-
lines.push(
|
|
748
|
-
themeFg(
|
|
749
|
-
theme,
|
|
750
|
-
"dim",
|
|
751
|
-
`${importantLines.length} important span(s) • ${exactRecoveryOutputId ? (routed.scriptFilter?.outputId ? "raw and script output recoverable from vault" : routed.reducer?.outputId ? "raw and reducer output recoverable from vault" : "raw output recoverable from vault") : "metadata-only record; exact raw output not vaulted"}`,
|
|
752
|
-
),
|
|
753
|
-
);
|
|
754
|
-
if (!expanded) {
|
|
755
|
-
lines.push(themeFg(theme, "dim", "ctrl+o to expand status, evidence, and vault recovery"));
|
|
756
|
-
return textComponent(lines.join("\n"));
|
|
757
|
-
}
|
|
758
|
-
lines.push("", themeFg(theme, "toolTitle", context.args?.script ? "Producer script" : "Command"));
|
|
759
|
-
lines.push(` ${themeFg(theme, "accent", runProducerLabel(context.args))}`);
|
|
760
|
-
lines.push("", themeFg(theme, "toolTitle", "Status"));
|
|
761
|
-
lines.push(` ${themeFg(theme, "muted", "toolStatus:")} ${formatStatus(theme, routed.toolStatus)}`);
|
|
762
|
-
lines.push(` ${themeFg(theme, "muted", "execution.status:")} ${formatStatus(theme, routed.execution?.status)}`);
|
|
763
|
-
lines.push(` ${themeFg(theme, "muted", "routing.status:")} ${formatStatus(theme, routed.routing?.status)}`);
|
|
764
|
-
if (routed.execution?.exitCode !== undefined) {
|
|
765
|
-
lines.push(` ${themeFg(theme, "muted", "exitCode:")} ${routed.execution.exitCode}`);
|
|
766
|
-
}
|
|
767
|
-
if (routed.execution?.durationMs !== undefined) {
|
|
768
|
-
lines.push(` ${themeFg(theme, "muted", "durationMs:")} ${routed.execution.durationMs}`);
|
|
769
|
-
}
|
|
770
|
-
appendStorageSection(lines, theme, routed, outputId);
|
|
771
|
-
if (routed.routing?.reason || routed.summary) {
|
|
772
|
-
lines.push("", themeFg(theme, "toolTitle", "Routing"));
|
|
773
|
-
if (routed.summary) {
|
|
774
|
-
lines.push(` ${themeFg(theme, "muted", "summary:")} ${truncateText(routed.summary, 160)}`);
|
|
775
|
-
}
|
|
776
|
-
if (routed.routing?.reason) {
|
|
777
|
-
lines.push(` ${themeFg(theme, "muted", "reason:")} ${truncateText(routed.routing.reason, 180)}`);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
if (routed.filters) {
|
|
781
|
-
lines.push("", themeFg(theme, "toolTitle", "Filters"));
|
|
782
|
-
lines.push(` ${truncateText(runFilterLabel(routed.filters), 220)}`);
|
|
783
|
-
}
|
|
784
|
-
if (routed.scriptProducer) {
|
|
785
|
-
lines.push("", themeFg(theme, "toolTitle", "Script producer"));
|
|
786
|
-
lines.push(` ${truncateText(runScriptProducerLabel(routed.scriptProducer), 220)}`);
|
|
787
|
-
if (routed.scriptProducer.operation) {
|
|
788
|
-
lines.push(
|
|
789
|
-
` ${themeFg(theme, "muted", "operation:")} ${truncateText(JSON.stringify(routed.scriptProducer.operation), 180)}`,
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
if (routed.scriptProducer.failure?.message) {
|
|
793
|
-
lines.push(` ${themeFg(theme, "warning", truncateText(routed.scriptProducer.failure.message, 180))}`);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
if (routed.reducer) {
|
|
797
|
-
lines.push("", themeFg(theme, "toolTitle", "Reducer"));
|
|
798
|
-
lines.push(
|
|
799
|
-
` ${routed.reducer.name}@${routed.reducer.version} confidence=${Number(routed.reducer.confidence ?? 0).toFixed(2)} status=${routed.reducer.status}`,
|
|
800
|
-
);
|
|
801
|
-
if (routed.reducer.rawOutputId) {
|
|
802
|
-
lines.push(
|
|
803
|
-
` ${themeFg(theme, "muted", "rawOutputId:")} ${themeFg(theme, "accent", routed.reducer.rawOutputId)}`,
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
if (routed.reducer.outputId) {
|
|
807
|
-
lines.push(` ${themeFg(theme, "muted", "outputId:")} ${themeFg(theme, "accent", routed.reducer.outputId)}`);
|
|
808
|
-
}
|
|
809
|
-
if (Array.isArray(routed.reducer.facts) && routed.reducer.facts.length > 0) {
|
|
810
|
-
lines.push(` ${themeFg(theme, "muted", "facts:")} ${truncateText(JSON.stringify(routed.reducer.facts), 220)}`);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
if (routed.scriptFilter) {
|
|
814
|
-
lines.push("", themeFg(theme, "toolTitle", "Script filter"));
|
|
815
|
-
lines.push(` ${truncateText(runScriptFilterLabel(routed.scriptFilter), 220)}`);
|
|
816
|
-
if (routed.scriptFilter.rawOutputId) {
|
|
817
|
-
lines.push(
|
|
818
|
-
` ${themeFg(theme, "muted", "rawOutputId:")} ${themeFg(theme, "accent", routed.scriptFilter.rawOutputId)}`,
|
|
819
|
-
);
|
|
820
|
-
}
|
|
821
|
-
if (Array.isArray(routed.scriptFilter.sourceAliases)) {
|
|
822
|
-
lines.push(` ${themeFg(theme, "muted", "sources:")} ${routed.scriptFilter.sourceAliases.join(", ")}`);
|
|
823
|
-
}
|
|
824
|
-
if (routed.scriptFilter.operation) {
|
|
825
|
-
lines.push(
|
|
826
|
-
` ${themeFg(theme, "muted", "operation:")} ${truncateText(JSON.stringify(routed.scriptFilter.operation), 180)}`,
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
if (routed.scriptFilter.failure?.message) {
|
|
830
|
-
lines.push(` ${themeFg(theme, "warning", truncateText(routed.scriptFilter.failure.message, 180))}`);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
if (routed.parser?.name) {
|
|
834
|
-
lines.push("", themeFg(theme, "toolTitle", "Parser"));
|
|
835
|
-
lines.push(` ${themeFg(theme, "muted", "name:")} ${routed.parser.name}`);
|
|
836
|
-
lines.push(` ${themeFg(theme, "muted", "confidence:")} ${Number(routed.parser.confidence ?? 0).toFixed(2)}`);
|
|
837
|
-
lines.push(` ${themeFg(theme, "muted", "fidelity:")} ${routed.parser.fidelity ?? "exact"}`);
|
|
838
|
-
lines.push(` ${themeFg(theme, "muted", "compressed:")} ${String(Boolean(routed.parser.compressed))}`);
|
|
839
|
-
if (routed.parser.counts && Object.keys(routed.parser.counts).length > 0) {
|
|
840
|
-
lines.push(` ${themeFg(theme, "muted", "counts:")} ${truncateText(JSON.stringify(routed.parser.counts), 160)}`);
|
|
841
|
-
}
|
|
842
|
-
if (Array.isArray(routed.parser.references) && routed.parser.references.length > 0) {
|
|
843
|
-
const refs = routed.parser.references
|
|
844
|
-
.slice(0, 3)
|
|
845
|
-
.map(
|
|
846
|
-
(ref) =>
|
|
847
|
-
`${ref.path}${ref.line ? `:${ref.line}${ref.column ? `:${ref.column}` : ""}` : ""}${ref.code ? ` ${ref.code}` : ""}`,
|
|
848
|
-
);
|
|
849
|
-
lines.push(` ${themeFg(theme, "muted", "references:")} ${truncateText(refs.join(", "), 180)}`);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
lines.push("", themeFg(theme, "toolTitle", "Evidence"));
|
|
853
|
-
if (importantLines.length === 0) {
|
|
854
|
-
lines.push(` ${themeFg(theme, "dim", "No important lines selected.")}`);
|
|
855
|
-
} else {
|
|
856
|
-
importantLines.forEach((line, index) => {
|
|
857
|
-
lines.push(` ${themeFg(theme, "accent", `#${index + 1} ${line.stream} lines ${line.lines}`)}`);
|
|
858
|
-
lines.push(...excerptLines(theme, line.excerpt, " ", 8));
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
if (routed.recovery?.how || outputId) {
|
|
862
|
-
lines.push("", themeFg(theme, "toolTitle", "Vault recovery"));
|
|
863
|
-
if (outputId) {
|
|
864
|
-
lines.push(` ${themeFg(theme, "muted", "outputId:")} ${themeFg(theme, "accent", outputId)}`);
|
|
865
|
-
}
|
|
866
|
-
if (routed.recovery?.how) {
|
|
867
|
-
lines.push(` ${truncateText(routed.recovery.how, 180)}`);
|
|
868
|
-
}
|
|
869
|
-
const evidenceOutputId = routed.scriptFilter?.outputId ?? routed.reducer?.outputId ?? exactRecoveryOutputId;
|
|
870
|
-
const exactHint = exactRetrieveHintFromImportantLines(evidenceOutputId, importantLines);
|
|
871
|
-
if (exactHint) {
|
|
872
|
-
const hint =
|
|
873
|
-
routed.scriptFilter?.outputId || routed.reducer?.outputId
|
|
874
|
-
? exactHint.replace(/stream=(stdout|stderr|combined)/, "stream=raw")
|
|
875
|
-
: exactHint;
|
|
876
|
-
lines.push(` ${themeFg(theme, "muted", "exact search:")} ${hint}`);
|
|
877
|
-
if ((routed.scriptFilter?.outputId || routed.reducer?.outputId) && outputId) {
|
|
878
|
-
lines.push(` ${themeFg(theme, "muted", "raw command starting point:")} ${recoveryStartingPoint(outputId)}`);
|
|
879
|
-
}
|
|
880
|
-
} else if (exactRecoveryOutputId) {
|
|
881
|
-
lines.push(
|
|
882
|
-
` ${themeFg(theme, "muted", "recovery starting point:")} ${recoveryStartingPoint(exactRecoveryOutputId)}`,
|
|
883
|
-
);
|
|
884
|
-
}
|
|
885
|
-
lines.push(` ${themeFg(theme, "dim", "Full structured result remains available in details.result.")}`);
|
|
886
|
-
}
|
|
887
|
-
return textComponent(lines.join("\n"));
|
|
888
|
-
}
|
|
889
|
-
export function renderFreeflowTransformResult(
|
|
890
|
-
result,
|
|
891
|
-
{ expanded } = {},
|
|
892
|
-
theme,
|
|
893
|
-
toolTitle = "freeflow_search action=transform",
|
|
894
|
-
) {
|
|
895
|
-
const routed = routerResultFromToolResult(result);
|
|
896
|
-
if (!routed) {
|
|
897
|
-
return textComponent(fallbackResultText(result));
|
|
898
|
-
}
|
|
899
|
-
const outputId = routed.outputId || routed.recovery?.outputId;
|
|
900
|
-
const operation = transformOperationLabel(routed.operation ?? { kind: routed.producer?.name });
|
|
901
|
-
const failed = routed.failure || routed.toolStatus === "error" || routed.routing?.status === "failed";
|
|
902
|
-
const icon = failed ? "✗" : statusIcon(routed.toolStatus);
|
|
903
|
-
const evidence = Array.isArray(routed.evidence) ? routed.evidence : [];
|
|
904
|
-
const sourceLabel = retrieveSourceLabel(routed.source);
|
|
905
|
-
const lines = [
|
|
906
|
-
`${themeFg(theme, failed ? "error" : "success", icon)} ${themeFg(theme, "toolTitle", toolTitle)} ${themeFg(theme, "accent", operation)} • ${routeSummaryLine(theme, routed)}`,
|
|
907
|
-
];
|
|
908
|
-
const statusParts = [];
|
|
909
|
-
if (outputId) {
|
|
910
|
-
statusParts.push(`outputId ${outputId}`);
|
|
911
|
-
}
|
|
912
|
-
if (routed.recordId) {
|
|
913
|
-
statusParts.push(`recordId ${routed.recordId}`);
|
|
914
|
-
}
|
|
915
|
-
if (routed.persistence?.status) {
|
|
916
|
-
statusParts.push(`persistence ${routed.persistence.status}/${routed.persistence.recoverability}`);
|
|
917
|
-
}
|
|
918
|
-
if (routed.source?.outputId) {
|
|
919
|
-
statusParts.push(`source ${routed.source.outputId}${routed.source.stream ? `:${routed.source.stream}` : ""}`);
|
|
920
|
-
}
|
|
921
|
-
if (statusParts.length > 0) {
|
|
922
|
-
lines.push(themeFg(theme, "accent", statusParts.join(" • ")));
|
|
923
|
-
}
|
|
924
|
-
if (routed.failure?.message) {
|
|
925
|
-
lines.push(themeFg(theme, "warning", `${routed.failure.kind}: ${truncateText(routed.failure.message, 140)}`));
|
|
926
|
-
} else if (routed.summary) {
|
|
927
|
-
lines.push(themeFg(theme, "muted", truncateText(routed.summary, 140)));
|
|
928
|
-
}
|
|
929
|
-
lines.push(
|
|
930
|
-
themeFg(
|
|
931
|
-
theme,
|
|
932
|
-
"dim",
|
|
933
|
-
`${evidence.length} evidence packet(s)${outputId ? " • transformed output recoverable from vault" : ""}`,
|
|
934
|
-
),
|
|
935
|
-
);
|
|
936
|
-
if (!expanded) {
|
|
937
|
-
lines.push(themeFg(theme, "dim", "ctrl+o to expand source, operation, lineage, evidence, and recovery details"));
|
|
938
|
-
return textComponent(lines.join("\n"));
|
|
939
|
-
}
|
|
940
|
-
lines.push("", themeFg(theme, "toolTitle", "Status"));
|
|
941
|
-
lines.push(` ${themeFg(theme, "muted", "toolStatus:")} ${formatStatus(theme, routed.toolStatus)}`);
|
|
942
|
-
if (routed.transformExecution?.status) {
|
|
943
|
-
lines.push(
|
|
944
|
-
` ${themeFg(theme, "muted", "transformExecution.status:")} ${formatStatus(theme, routed.transformExecution.status)}`,
|
|
945
|
-
);
|
|
946
|
-
}
|
|
947
|
-
lines.push(` ${themeFg(theme, "muted", "routing.status:")} ${formatStatus(theme, routed.routing?.status)}`);
|
|
948
|
-
if (routed.persistence?.status) {
|
|
949
|
-
lines.push(
|
|
950
|
-
` ${themeFg(theme, "muted", "persistence:")} ${routed.persistence.status} / ${routed.persistence.recoverability}`,
|
|
951
|
-
);
|
|
952
|
-
}
|
|
953
|
-
if (routed.routing?.reason) {
|
|
954
|
-
lines.push(` ${themeFg(theme, "muted", "reason:")} ${truncateText(routed.routing.reason, 180)}`);
|
|
955
|
-
}
|
|
956
|
-
appendStorageSection(lines, theme, routed, outputId);
|
|
957
|
-
lines.push("", themeFg(theme, "toolTitle", "Source"));
|
|
958
|
-
lines.push(` ${themeFg(theme, "accent", sourceLabel)}`);
|
|
959
|
-
lines.push("", themeFg(theme, "toolTitle", "Operation"));
|
|
960
|
-
if (routed.operation) {
|
|
961
|
-
lines.push(` ${truncateText(JSON.stringify(routed.operation), 220)}`);
|
|
962
|
-
} else {
|
|
963
|
-
lines.push(` ${themeFg(theme, "dim", operation)}`);
|
|
964
|
-
}
|
|
965
|
-
if (routed.lineage) {
|
|
966
|
-
lines.push("", themeFg(theme, "toolTitle", "Lineage"));
|
|
967
|
-
if (Array.isArray(routed.lineage.sourceOutputIds)) {
|
|
968
|
-
lines.push(` ${themeFg(theme, "muted", "sourceOutputIds:")} ${routed.lineage.sourceOutputIds.join(", ")}`);
|
|
969
|
-
}
|
|
970
|
-
if (Array.isArray(routed.lineage.sourceRecordIds)) {
|
|
971
|
-
lines.push(` ${themeFg(theme, "muted", "sourceRecordIds:")} ${routed.lineage.sourceRecordIds.join(", ")}`);
|
|
972
|
-
}
|
|
973
|
-
if (routed.lineage.operation) {
|
|
974
|
-
lines.push(` ${themeFg(theme, "muted", "operation:")} ${routed.lineage.operation}`);
|
|
975
|
-
}
|
|
976
|
-
if (routed.lineage.operationHash) {
|
|
977
|
-
lines.push(` ${themeFg(theme, "muted", "operationHash:")} ${shortenMiddle(routed.lineage.operationHash, 80)}`);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
lines.push("", themeFg(theme, "toolTitle", "Evidence"));
|
|
981
|
-
if (evidence.length === 0) {
|
|
982
|
-
lines.push(` ${themeFg(theme, "dim", "No evidence packets returned.")}`);
|
|
983
|
-
} else {
|
|
984
|
-
evidence.forEach((packet, index) => {
|
|
985
|
-
lines.push(
|
|
986
|
-
` ${themeFg(theme, "accent", `#${index + 1} ${evidenceLabel(packet)}`)} ${themeFg(theme, "dim", `window=${packet.window}`)}`,
|
|
987
|
-
);
|
|
988
|
-
if (packet.id) {
|
|
989
|
-
lines.push(` ${themeFg(theme, "muted", "evidenceId:")} ${themeFg(theme, "accent", packet.id)}`);
|
|
990
|
-
}
|
|
991
|
-
if (packet.source) {
|
|
992
|
-
lines.push(` ${themeFg(theme, "muted", "source:")} ${evidenceSourceSummary(packet.source)}`);
|
|
993
|
-
}
|
|
994
|
-
if (packet.expandable !== undefined) {
|
|
995
|
-
lines.push(` ${themeFg(theme, "muted", "expandable:")} ${String(Boolean(packet.expandable))}`);
|
|
996
|
-
}
|
|
997
|
-
const exactHint = exactRetrieveHintFromEvidence(packet);
|
|
998
|
-
if (exactHint) {
|
|
999
|
-
lines.push(` ${themeFg(theme, "muted", "exact search:")} ${exactHint}`);
|
|
1000
|
-
}
|
|
1001
|
-
if (packet.why) {
|
|
1002
|
-
lines.push(` ${themeFg(theme, "muted", "why:")} ${truncateText(packet.why, 160)}`);
|
|
1003
|
-
}
|
|
1004
|
-
lines.push(...excerptLines(theme, packet.excerpt, " ", 8));
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
if (routed.recovery?.how || outputId) {
|
|
1008
|
-
lines.push("", themeFg(theme, "toolTitle", "Recovery"));
|
|
1009
|
-
if (outputId) {
|
|
1010
|
-
lines.push(` ${themeFg(theme, "muted", "outputId:")} ${themeFg(theme, "accent", outputId)}`);
|
|
1011
|
-
}
|
|
1012
|
-
if (routed.recovery?.how) {
|
|
1013
|
-
lines.push(` ${truncateText(routed.recovery.how, 180)}`);
|
|
1014
|
-
}
|
|
1015
|
-
const exactHint = firstExactRetrieveHintFromEvidence(evidence);
|
|
1016
|
-
if (exactHint) {
|
|
1017
|
-
lines.push(` ${themeFg(theme, "muted", "exact search:")} ${exactHint}`);
|
|
1018
|
-
} else if (outputId) {
|
|
1019
|
-
lines.push(` ${themeFg(theme, "muted", "recovery starting point:")} ${recoveryStartingPoint(outputId)}`);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
return textComponent(lines.join("\n"));
|
|
1023
|
-
}
|