@aragon-agent/cli 0.6.44 → 0.6.46
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/CHANGELOG.md +44 -0
- package/README.md +120 -2
- package/dist/agent/controller.d.ts +69 -0
- package/dist/agent/controller.js +224 -11
- package/dist/agent/governance-view.d.ts +40 -0
- package/dist/agent/governance-view.js +40 -0
- package/dist/agent/governance-wiring.d.ts +162 -0
- package/dist/agent/governance-wiring.js +470 -0
- package/dist/agent/invocation-card.d.ts +77 -0
- package/dist/agent/invocation-card.js +169 -0
- package/dist/agent/plan-prompt.d.ts +7 -0
- package/dist/agent/plan-prompt.js +2 -1
- package/dist/agent/prompt-options.d.ts +6 -0
- package/dist/agent/queued-messages.d.ts +3 -0
- package/dist/agent/queued-messages.js +4 -1
- package/dist/agent/reducer.d.ts +38 -1
- package/dist/agent/reducer.js +57 -12
- package/dist/agent/system-prompt.d.ts +19 -0
- package/dist/agent/system-prompt.js +9 -1
- package/dist/cli.js +45 -1
- package/dist/commands/builtins.js +22 -4
- package/dist/commands/governance-command.d.ts +35 -0
- package/dist/commands/governance-command.js +304 -0
- package/dist/commands/governance-runs-table.d.ts +40 -0
- package/dist/commands/governance-runs-table.js +130 -0
- package/dist/commands/index-build.d.ts +8 -0
- package/dist/commands/index-build.js +11 -0
- package/dist/commands/registry.d.ts +35 -0
- package/dist/commands/registry.js +20 -7
- package/dist/commands/skills.js +36 -2
- package/dist/commands/subagent-command.js +3 -1
- package/dist/commands/team-command.d.ts +6 -0
- package/dist/commands/team-command.js +40 -3
- package/dist/config/app-paths.d.ts +10 -0
- package/dist/config/app-paths.js +12 -0
- package/dist/config/cli-commands.d.ts +18 -0
- package/dist/config/cli-commands.js +47 -1
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +10 -1
- package/dist/config/governance-config.d.ts +125 -0
- package/dist/config/governance-config.js +164 -0
- package/dist/config/governance-launch.d.ts +71 -0
- package/dist/config/governance-launch.js +58 -0
- package/dist/config/load.d.ts +15 -0
- package/dist/config/load.js +26 -1
- package/dist/config/model-profile-store.d.ts +4 -2
- package/dist/config/schema.d.ts +22 -0
- package/dist/config/schema.js +6 -0
- package/dist/config/store.js +14 -1
- package/dist/config/ui-state.d.ts +11 -0
- package/dist/config/ui-state.js +11 -0
- package/dist/diagnostics/doctor.js +20 -0
- package/dist/governance/card-normalize.d.ts +24 -0
- package/dist/governance/card-normalize.js +76 -0
- package/dist/governance/copy.d.ts +109 -0
- package/dist/governance/copy.js +223 -0
- package/dist/governance/engine/aftermath.d.ts +49 -0
- package/dist/governance/engine/aftermath.js +134 -0
- package/dist/governance/engine/artifact-persist.d.ts +35 -0
- package/dist/governance/engine/artifact-persist.js +86 -0
- package/dist/governance/engine/budget.d.ts +52 -0
- package/dist/governance/engine/budget.js +112 -0
- package/dist/governance/engine/cards.d.ts +18 -0
- package/dist/governance/engine/cards.js +186 -0
- package/dist/governance/engine/digest.d.ts +32 -0
- package/dist/governance/engine/digest.js +63 -0
- package/dist/governance/engine/engine-core.d.ts +219 -0
- package/dist/governance/engine/engine-core.js +562 -0
- package/dist/governance/engine/engine.d.ts +68 -0
- package/dist/governance/engine/engine.js +314 -0
- package/dist/governance/engine/estimate.d.ts +38 -0
- package/dist/governance/engine/estimate.js +46 -0
- package/dist/governance/engine/inspector.d.ts +16 -0
- package/dist/governance/engine/inspector.js +396 -0
- package/dist/governance/engine/integration.d.ts +35 -0
- package/dist/governance/engine/integration.js +220 -0
- package/dist/governance/engine/lifecycle.d.ts +29 -0
- package/dist/governance/engine/lifecycle.js +656 -0
- package/dist/governance/engine/pause.d.ts +56 -0
- package/dist/governance/engine/pause.js +107 -0
- package/dist/governance/engine/phase-members.d.ts +15 -0
- package/dist/governance/engine/phase-members.js +34 -0
- package/dist/governance/engine/phase-planner.d.ts +53 -0
- package/dist/governance/engine/phase-planner.js +282 -0
- package/dist/governance/engine/rebuild.d.ts +27 -0
- package/dist/governance/engine/rebuild.js +57 -0
- package/dist/governance/engine/report.d.ts +66 -0
- package/dist/governance/engine/report.js +220 -0
- package/dist/governance/engine/run-digest.d.ts +20 -0
- package/dist/governance/engine/run-digest.js +42 -0
- package/dist/governance/engine/spec-builder.d.ts +117 -0
- package/dist/governance/engine/spec-builder.js +321 -0
- package/dist/governance/engine/stage-runner.d.ts +22 -0
- package/dist/governance/engine/stage-runner.js +664 -0
- package/dist/governance/engine/start-input.d.ts +19 -0
- package/dist/governance/engine/start-input.js +111 -0
- package/dist/governance/engine/state-machine.d.ts +101 -0
- package/dist/governance/engine/state-machine.js +586 -0
- package/dist/governance/engine/submission-queries.d.ts +42 -0
- package/dist/governance/engine/submission-queries.js +97 -0
- package/dist/governance/engine/submission-render.d.ts +12 -0
- package/dist/governance/engine/submission-render.js +92 -0
- package/dist/governance/engine/submissions.d.ts +27 -0
- package/dist/governance/engine/submissions.js +455 -0
- package/dist/governance/engine/visibility.d.ts +104 -0
- package/dist/governance/engine/visibility.js +223 -0
- package/dist/governance/governed-dispatch.d.ts +19 -0
- package/dist/governance/governed-dispatch.js +17 -0
- package/dist/governance/limits.d.ts +107 -0
- package/dist/governance/limits.js +131 -0
- package/dist/governance/posture-transition.d.ts +38 -0
- package/dist/governance/posture-transition.js +44 -0
- package/dist/governance/posture.d.ts +35 -0
- package/dist/governance/posture.js +59 -0
- package/dist/governance/profiles.d.ts +48 -0
- package/dist/governance/profiles.js +140 -0
- package/dist/governance/prompts/orchestrator-block.d.ts +40 -0
- package/dist/governance/prompts/orchestrator-block.js +128 -0
- package/dist/governance/prompts/plan-addendum.d.ts +22 -0
- package/dist/governance/prompts/plan-addendum.js +60 -0
- package/dist/governance/prompts/refusals.d.ts +48 -0
- package/dist/governance/prompts/refusals.js +82 -0
- package/dist/governance/prompts/role-blocks.d.ts +40 -0
- package/dist/governance/prompts/role-blocks.js +255 -0
- package/dist/governance/report-reader.d.ts +31 -0
- package/dist/governance/report-reader.js +57 -0
- package/dist/governance/roles.d.ts +83 -0
- package/dist/governance/roles.js +142 -0
- package/dist/governance/rules/claims.d.ts +83 -0
- package/dist/governance/rules/claims.js +250 -0
- package/dist/governance/rules/elimination.d.ts +66 -0
- package/dist/governance/rules/elimination.js +105 -0
- package/dist/governance/rules/events-table.d.ts +46 -0
- package/dist/governance/rules/events-table.js +94 -0
- package/dist/governance/rules/failure-analysis.d.ts +28 -0
- package/dist/governance/rules/failure-analysis.js +93 -0
- package/dist/governance/rules/ledger-replay.d.ts +53 -0
- package/dist/governance/rules/ledger-replay.js +53 -0
- package/dist/governance/rules/ledger-state.d.ts +85 -0
- package/dist/governance/rules/ledger-state.js +175 -0
- package/dist/governance/rules/ledger.d.ts +228 -0
- package/dist/governance/rules/ledger.js +560 -0
- package/dist/governance/rules/rca.d.ts +68 -0
- package/dist/governance/rules/rca.js +220 -0
- package/dist/governance/rules/settlement.d.ts +129 -0
- package/dist/governance/rules/settlement.js +363 -0
- package/dist/governance/rules/suspicion.d.ts +66 -0
- package/dist/governance/rules/suspicion.js +169 -0
- package/dist/governance/store/artifacts.d.ts +81 -0
- package/dist/governance/store/artifacts.js +173 -0
- package/dist/governance/store/atomic.d.ts +79 -0
- package/dist/governance/store/atomic.js +119 -0
- package/dist/governance/store/events-log.d.ts +35 -0
- package/dist/governance/store/events-log.js +86 -0
- package/dist/governance/store/run-lock.d.ts +51 -0
- package/dist/governance/store/run-lock.js +122 -0
- package/dist/governance/store/run-store.d.ts +229 -0
- package/dist/governance/store/run-store.js +644 -0
- package/dist/governance/store/scoreboard-export.d.ts +53 -0
- package/dist/governance/store/scoreboard-export.js +65 -0
- package/dist/governance/tools/child-tools.d.ts +31 -0
- package/dist/governance/tools/child-tools.js +65 -0
- package/dist/governance/tools/guard.d.ts +71 -0
- package/dist/governance/tools/guard.js +194 -0
- package/dist/governance/tools/inspector-tools.d.ts +63 -0
- package/dist/governance/tools/inspector-tools.js +424 -0
- package/dist/governance/tools/lead-tools.d.ts +42 -0
- package/dist/governance/tools/lead-tools.js +226 -0
- package/dist/governance/tools/normalize-util.d.ts +101 -0
- package/dist/governance/tools/normalize-util.js +230 -0
- package/dist/governance/tools/scan-incomplete.d.ts +79 -0
- package/dist/governance/tools/scan-incomplete.js +486 -0
- package/dist/governance/tools/shared-tools.d.ts +44 -0
- package/dist/governance/tools/shared-tools.js +125 -0
- package/dist/governance/tools/submit-normalizers.d.ts +28 -0
- package/dist/governance/tools/submit-normalizers.js +474 -0
- package/dist/governance/tools/submit-tools.d.ts +26 -0
- package/dist/governance/tools/submit-tools.js +171 -0
- package/dist/governance/types.d.ts +661 -0
- package/dist/governance/types.js +27 -0
- package/dist/session/persist.js +10 -0
- package/dist/session/validate-session.js +36 -3
- package/dist/team/forced-mode.d.ts +19 -0
- package/dist/team/forced-mode.js +42 -20
- package/dist/team/runtime.d.ts +8 -0
- package/dist/team/runtime.js +9 -0
- package/dist/team/subagent.d.ts +23 -0
- package/dist/team/subagent.js +14 -3
- package/dist/team/types.d.ts +6 -0
- package/dist/tools/index.d.ts +30 -7
- package/dist/tools/index.js +14 -0
- package/dist/tools/plan-tools.d.ts +14 -2
- package/dist/tools/plan-tools.js +5 -2
- package/dist/ui/App.js +170 -31
- package/dist/ui/BottomStatusRow.js +1 -1
- package/dist/ui/Composer.d.ts +7 -1
- package/dist/ui/Composer.js +9 -6
- package/dist/ui/GovernancePanel.d.ts +50 -0
- package/dist/ui/GovernancePanel.js +77 -0
- package/dist/ui/GovernanceRun.d.ts +18 -0
- package/dist/ui/GovernanceRun.js +11 -0
- package/dist/ui/StatusBar.d.ts +15 -2
- package/dist/ui/StatusBar.js +10 -4
- package/dist/ui/Transcript.js +7 -1
- package/dist/ui/entries/GovernanceCard.d.ts +30 -0
- package/dist/ui/entries/GovernanceCard.js +32 -0
- package/dist/ui/entries/InvocationCard.d.ts +20 -0
- package/dist/ui/entries/InvocationCard.js +32 -0
- package/dist/ui/governance-copy.d.ts +69 -0
- package/dist/ui/governance-copy.js +104 -0
- package/dist/ui/governance-status.d.ts +145 -0
- package/dist/ui/governance-status.js +326 -0
- package/dist/ui/interaction-copy.d.ts +4 -0
- package/dist/ui/interaction-copy.js +5 -0
- package/dist/ui/interaction-hints.d.ts +17 -0
- package/dist/ui/interaction-hints.js +14 -2
- package/dist/ui/layout/governance-board.d.ts +121 -0
- package/dist/ui/layout/governance-board.js +382 -0
- package/dist/ui/layout/governance-card.d.ts +53 -0
- package/dist/ui/layout/governance-card.js +134 -0
- package/dist/ui/layout/governance-chip.d.ts +38 -0
- package/dist/ui/layout/governance-chip.js +64 -0
- package/dist/ui/layout/governance-panel.d.ts +85 -0
- package/dist/ui/layout/governance-panel.js +358 -0
- package/dist/ui/layout/governance-roster.d.ts +65 -0
- package/dist/ui/layout/governance-roster.js +275 -0
- package/dist/ui/layout/invocation-card.d.ts +41 -0
- package/dist/ui/layout/invocation-card.js +91 -0
- package/dist/ui/layout/status-detail-layout.js +3 -3
- package/dist/ui/layout/status-layout.d.ts +5 -2
- package/dist/ui/layout/status-layout.js +10 -6
- package/dist/ui/layout/virtual-window.js +22 -1
- package/dist/ui/overlays/GovernanceBoardOverlay.d.ts +41 -0
- package/dist/ui/overlays/GovernanceBoardOverlay.js +76 -0
- package/dist/ui/overlays/GovernanceSettingsPage.d.ts +48 -0
- package/dist/ui/overlays/GovernanceSettingsPage.js +93 -0
- package/dist/ui/overlays/HelpOverlay.js +4 -3
- package/dist/ui/overlays/QuestionOverlay.d.ts +9 -1
- package/dist/ui/overlays/QuestionOverlay.js +4 -2
- package/dist/ui/overlays/SettingsScreen.d.ts +7 -0
- package/dist/ui/overlays/SettingsScreen.js +21 -1
- package/dist/ui/overlays/governance-settings.d.ts +79 -0
- package/dist/ui/overlays/governance-settings.js +140 -0
- package/dist/ui/overlays/model-profile-state.d.ts +6 -1
- package/dist/ui/overlays/model-profile-state.js +10 -0
- package/dist/ui/palettes.d.ts +17 -0
- package/dist/ui/palettes.js +9 -0
- package/dist/ui/scrollback/live-preview.js +2 -0
- package/dist/ui/scrollback/settled-boundary.js +3 -0
- package/dist/ui/shortcuts.js +2 -2
- package/dist/ui/theme.d.ts +7 -0
- package/dist/ui/theme.js +1 -0
- package/dist/ui/transcript-text.js +13 -1
- package/dist/ui/use-wheel-routing.js +3 -1
- package/package.json +2 -2
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The legion panel's geometry: every decision `GovernancePanel` draws (governance-mode
|
|
3
|
+
* section 10.3), made in pure code so it can be tested without a terminal.
|
|
4
|
+
*
|
|
5
|
+
* Pure and total: no Ink, no clock (`now` is injected), no I/O. ASCII ONLY.
|
|
6
|
+
*
|
|
7
|
+
* THE COMPONENT ONLY COLOURS AND PLACES. Tier, header, step strip, roster columns and
|
|
8
|
+
* cell text, overflow line and ticker are all computed here; a test that wants to know
|
|
9
|
+
* what the panel says at 80 columns asks this module and never renders.
|
|
10
|
+
*
|
|
11
|
+
* FOUR TIERS, chosen from the terminal's size alone (`selectTier`):
|
|
12
|
+
* full >= 100 cols and >= 26 rows header + step strip + roster (with gauge) + ticker
|
|
13
|
+
* standard 80-99 cols (rows >= 26) the same without the activity column
|
|
14
|
+
* compact 60-79 cols, or rows < 26 header with the stage name + a bare roster
|
|
15
|
+
* minimal < 60 cols or rows < 20 ONE line
|
|
16
|
+
* and a tier that does not fit the caller's `availableRows` steps DOWN rather than
|
|
17
|
+
* overflowing - the band clamps the panel's height, and a clipped last row is the one
|
|
18
|
+
* outcome worse than a smaller tier.
|
|
19
|
+
*/
|
|
20
|
+
import type { GovernanceSnapshot } from '../../governance/types.js';
|
|
21
|
+
import type { Glyphs } from '../glyphs.js';
|
|
22
|
+
import { type EliminatedSince, type Segment } from '../governance-status.js';
|
|
23
|
+
import { type PanelTier, type RosterColumn, type RosterLine } from './governance-roster.js';
|
|
24
|
+
export type { PanelTier } from './governance-roster.js';
|
|
25
|
+
export declare const PANEL_TIER_COLS: {
|
|
26
|
+
readonly full: 100;
|
|
27
|
+
readonly standard: 80;
|
|
28
|
+
readonly compact: 60;
|
|
29
|
+
};
|
|
30
|
+
export declare const PANEL_TIER_ROWS: {
|
|
31
|
+
readonly full: 26;
|
|
32
|
+
readonly minimal: 20;
|
|
33
|
+
};
|
|
34
|
+
/** Roster rows shown: `clamp(rows - 16, 2, 10)` (spec 10.3). */
|
|
35
|
+
export declare function maxRosterRows(rows: number): number;
|
|
36
|
+
/** The tier the terminal's size asks for, before any height budget is applied. */
|
|
37
|
+
export declare function selectTier(cols: number, rows: number): PanelTier;
|
|
38
|
+
/** One display line: a flexible left run and an optional right-anchored run. */
|
|
39
|
+
export interface PanelLine {
|
|
40
|
+
left: Segment[];
|
|
41
|
+
right: Segment[];
|
|
42
|
+
/** Cells the right run occupies (0 when there is none). */
|
|
43
|
+
rightCells: number;
|
|
44
|
+
}
|
|
45
|
+
export interface GovernancePanelInput {
|
|
46
|
+
cols: number;
|
|
47
|
+
rows: number;
|
|
48
|
+
snapshot: GovernanceSnapshot | null;
|
|
49
|
+
glyphs: Glyphs;
|
|
50
|
+
reducedMotion: boolean;
|
|
51
|
+
now: number;
|
|
52
|
+
/** `panel` while a stage runs; `run-strip` between stages (header + step strip only). */
|
|
53
|
+
mode?: 'panel' | 'run-strip';
|
|
54
|
+
/** Height budget the caller can spare; tiers step down to fit. Default unlimited. */
|
|
55
|
+
availableRows?: number;
|
|
56
|
+
/** First-seen-eliminated phases, so a replaced member leaves after one phase. */
|
|
57
|
+
eliminatedSince?: EliminatedSince;
|
|
58
|
+
}
|
|
59
|
+
export interface GovernancePanelLayout {
|
|
60
|
+
tier: PanelTier;
|
|
61
|
+
mode: 'panel' | 'run-strip';
|
|
62
|
+
/** Terminal columns this layout was built for. */
|
|
63
|
+
cols: number;
|
|
64
|
+
/** `cols` minus the margin: the budget every line is planned against. */
|
|
65
|
+
innerCols: number;
|
|
66
|
+
height: number;
|
|
67
|
+
header: PanelLine | null;
|
|
68
|
+
pipeline: PanelLine | null;
|
|
69
|
+
/** Width of the horizontal rule above and below the roster; 0 = no rules. */
|
|
70
|
+
ruleCells: number;
|
|
71
|
+
columns: RosterColumn[];
|
|
72
|
+
rosterRows: RosterLine[];
|
|
73
|
+
overflow: string | null;
|
|
74
|
+
ticker: PanelLine[];
|
|
75
|
+
}
|
|
76
|
+
export declare function segmentsCells(segments: readonly Segment[]): number;
|
|
77
|
+
/**
|
|
78
|
+
* Plan the panel for a terminal and a snapshot.
|
|
79
|
+
*
|
|
80
|
+
* `null` snapshot, or a finished run, plans to height 0 (nothing mounts - zero rows and
|
|
81
|
+
* zero layout shift, the `TeamPanel` D-11 rule). The caller's `availableRows` is a
|
|
82
|
+
* ceiling: tiers step down until one fits, and `minimal` is a single row or, with no row to
|
|
83
|
+
* spare, nothing.
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildGovernancePanelLayout(input: GovernancePanelInput): GovernancePanelLayout;
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The legion panel's geometry: every decision `GovernancePanel` draws (governance-mode
|
|
3
|
+
* section 10.3), made in pure code so it can be tested without a terminal.
|
|
4
|
+
*
|
|
5
|
+
* Pure and total: no Ink, no clock (`now` is injected), no I/O. ASCII ONLY.
|
|
6
|
+
*
|
|
7
|
+
* THE COMPONENT ONLY COLOURS AND PLACES. Tier, header, step strip, roster columns and
|
|
8
|
+
* cell text, overflow line and ticker are all computed here; a test that wants to know
|
|
9
|
+
* what the panel says at 80 columns asks this module and never renders.
|
|
10
|
+
*
|
|
11
|
+
* FOUR TIERS, chosen from the terminal's size alone (`selectTier`):
|
|
12
|
+
* full >= 100 cols and >= 26 rows header + step strip + roster (with gauge) + ticker
|
|
13
|
+
* standard 80-99 cols (rows >= 26) the same without the activity column
|
|
14
|
+
* compact 60-79 cols, or rows < 26 header with the stage name + a bare roster
|
|
15
|
+
* minimal < 60 cols or rows < 20 ONE line
|
|
16
|
+
* and a tier that does not fit the caller's `availableRows` steps DOWN rather than
|
|
17
|
+
* overflowing - the band clamps the panel's height, and a clipped last row is the one
|
|
18
|
+
* outcome worse than a smaller tier.
|
|
19
|
+
*/
|
|
20
|
+
import { formatCost, formatDuration, formatTokens } from '../../agent/usage.js';
|
|
21
|
+
import { activeStepKey, isFinishedRun, isPausePending, isRetired, segment, shortRunId, signedDeltaText, sortRoster, teamTokens, workingCount, } from '../governance-status.js';
|
|
22
|
+
import { GOV_TITLE, PANEL_BOARD_HINT, PANEL_HEALTH_LABEL, PANEL_LEDGER_LABEL, PANEL_TOKEN_UNIT, PIPELINE_LABEL, STATUS_WORD, moreText, phaseLongText, pausingText, phaseText, workingCountText, } from '../governance-copy.js';
|
|
23
|
+
import { cellWidth, fitCells } from './cells.js';
|
|
24
|
+
import { PANEL_MARGIN_CELLS, buildRosterLine, columnPlan, markerCells, } from './governance-roster.js';
|
|
25
|
+
export const PANEL_TIER_COLS = { full: 100, standard: 80, compact: 60 };
|
|
26
|
+
export const PANEL_TIER_ROWS = { full: 26, minimal: 20 };
|
|
27
|
+
/** Roster rows shown: `clamp(rows - 16, 2, 10)` (spec 10.3). */
|
|
28
|
+
export function maxRosterRows(rows) {
|
|
29
|
+
const free = Number.isFinite(rows) ? Math.floor(rows) - 16 : 0;
|
|
30
|
+
return Math.min(10, Math.max(2, free));
|
|
31
|
+
}
|
|
32
|
+
/** The tier the terminal's size asks for, before any height budget is applied. */
|
|
33
|
+
export function selectTier(cols, rows) {
|
|
34
|
+
if (cols < PANEL_TIER_COLS.compact || rows < PANEL_TIER_ROWS.minimal)
|
|
35
|
+
return 'minimal';
|
|
36
|
+
if (rows < PANEL_TIER_ROWS.full || cols < PANEL_TIER_COLS.standard)
|
|
37
|
+
return 'compact';
|
|
38
|
+
return cols >= PANEL_TIER_COLS.full ? 'full' : 'standard';
|
|
39
|
+
}
|
|
40
|
+
const NEXT_SMALLER = {
|
|
41
|
+
full: 'standard',
|
|
42
|
+
standard: 'compact',
|
|
43
|
+
compact: 'minimal',
|
|
44
|
+
minimal: null,
|
|
45
|
+
};
|
|
46
|
+
const EMPTY = {
|
|
47
|
+
tier: 'minimal',
|
|
48
|
+
mode: 'panel',
|
|
49
|
+
cols: 0,
|
|
50
|
+
innerCols: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
header: null,
|
|
53
|
+
pipeline: null,
|
|
54
|
+
ruleCells: 0,
|
|
55
|
+
columns: [],
|
|
56
|
+
rosterRows: [],
|
|
57
|
+
overflow: null,
|
|
58
|
+
ticker: [],
|
|
59
|
+
};
|
|
60
|
+
function nonNegativeInt(value) {
|
|
61
|
+
return Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 0;
|
|
62
|
+
}
|
|
63
|
+
export function segmentsCells(segments) {
|
|
64
|
+
return segments.reduce((sum, part) => sum + cellWidth(part.text), 0);
|
|
65
|
+
}
|
|
66
|
+
function line(left, right = []) {
|
|
67
|
+
return { left, right, rightCells: segmentsCells(right) };
|
|
68
|
+
}
|
|
69
|
+
const SEPARATOR = ' ';
|
|
70
|
+
/** The parts joined by the glyph tier's middle dot, the dot itself in `muted`. */
|
|
71
|
+
function joined(parts, glyphs) {
|
|
72
|
+
const out = [];
|
|
73
|
+
parts.forEach((part, index) => {
|
|
74
|
+
if (index > 0)
|
|
75
|
+
out.push(segment(`${SEPARATOR}${glyphs.midDot}${SEPARATOR}`, 'muted'));
|
|
76
|
+
out.push(part);
|
|
77
|
+
});
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
// Header
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
function stageWord(snapshot) {
|
|
84
|
+
const key = activeStepKey(snapshot);
|
|
85
|
+
return key === null ? '' : PIPELINE_LABEL[key];
|
|
86
|
+
}
|
|
87
|
+
function statusSegments(snapshot) {
|
|
88
|
+
// A pending `/gov pause` outranks the plain status: the run is still executing, and the
|
|
89
|
+
// one thing the user needs to see is that the stop is coming and nothing is killed.
|
|
90
|
+
if (isPausePending(snapshot)) {
|
|
91
|
+
return [segment(pausingText(stageWord(snapshot)), 'warn', true)];
|
|
92
|
+
}
|
|
93
|
+
if (snapshot.status === 'paused')
|
|
94
|
+
return [segment(STATUS_WORD.paused, 'warn', true)];
|
|
95
|
+
if (snapshot.status === 'escalated')
|
|
96
|
+
return [segment(STATUS_WORD.escalated, 'warn', true)];
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
/** The right-hand figures, most expendable last: cost, then tokens, then health. */
|
|
100
|
+
function headerFigures(snapshot, withCost) {
|
|
101
|
+
const figures = [];
|
|
102
|
+
if (snapshot.health !== null) {
|
|
103
|
+
figures.push([
|
|
104
|
+
segment(`${PANEL_HEALTH_LABEL} `, 'muted'),
|
|
105
|
+
segment(String(Math.round(snapshot.health)), 'text', true),
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
figures.push([segment(`${formatTokens(teamTokens(snapshot))} ${PANEL_TOKEN_UNIT}`, 'muted')]);
|
|
109
|
+
if (withCost && snapshot.usage.costUsd !== null) {
|
|
110
|
+
figures.push([segment(formatCost(snapshot.usage.costUsd), 'muted')]);
|
|
111
|
+
}
|
|
112
|
+
return figures;
|
|
113
|
+
}
|
|
114
|
+
function spaced(figures) {
|
|
115
|
+
const out = [];
|
|
116
|
+
figures.forEach((figure, index) => {
|
|
117
|
+
if (index > 0)
|
|
118
|
+
out.push(segment(' ', 'muted'));
|
|
119
|
+
out.push(...figure);
|
|
120
|
+
});
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
function buildHeader(snapshot, inner, now, glyphs, withCost) {
|
|
124
|
+
const elapsed = formatDuration(Math.max(0, now - snapshot.startedAt));
|
|
125
|
+
const parts = [
|
|
126
|
+
segment(`run ${shortRunId(snapshot.runId)}`, 'muted'),
|
|
127
|
+
segment(phaseLongText(snapshot.phase, snapshot.phaseCount), 'text'),
|
|
128
|
+
];
|
|
129
|
+
// `pausing after REVIEW` already names the stage; saying it twice is noise on a short row.
|
|
130
|
+
const stage = isPausePending(snapshot) ? '' : stageWord(snapshot);
|
|
131
|
+
if (stage !== '')
|
|
132
|
+
parts.push(segment(stage, 'primary', true));
|
|
133
|
+
parts.push(segment(elapsed, 'muted'));
|
|
134
|
+
const title = [segment(GOV_TITLE, 'govern', true), ...statusSegments(snapshot).flatMap((s) => [
|
|
135
|
+
segment(' ', 'muted'),
|
|
136
|
+
s,
|
|
137
|
+
])];
|
|
138
|
+
const left = [...title, segment(' ', 'muted'), ...joined(parts, glyphs)];
|
|
139
|
+
const figures = headerFigures(snapshot, withCost);
|
|
140
|
+
while (figures.length > 0) {
|
|
141
|
+
const right = spaced(figures);
|
|
142
|
+
if (segmentsCells(left) + segmentsCells(right) + 2 <= inner)
|
|
143
|
+
return line(left, right);
|
|
144
|
+
figures.pop();
|
|
145
|
+
}
|
|
146
|
+
return line(left);
|
|
147
|
+
}
|
|
148
|
+
/** Compact header: the stage name replaces the step strip (spec 10.3). */
|
|
149
|
+
function buildCompactHeader(snapshot, inner, now, glyphs) {
|
|
150
|
+
const parts = [segment(phaseText(snapshot.phase, snapshot.phaseCount), 'text')];
|
|
151
|
+
const stage = isPausePending(snapshot) ? '' : stageWord(snapshot);
|
|
152
|
+
if (stage !== '')
|
|
153
|
+
parts.push(segment(stage, 'primary', true));
|
|
154
|
+
parts.push(segment(formatDuration(Math.max(0, now - snapshot.startedAt)), 'muted'));
|
|
155
|
+
const title = [segment(GOV_TITLE, 'govern', true), ...statusSegments(snapshot).flatMap((s) => [
|
|
156
|
+
segment(' ', 'muted'),
|
|
157
|
+
s,
|
|
158
|
+
])];
|
|
159
|
+
const left = [...title, segment(' ', 'muted'), ...joined(parts, glyphs)];
|
|
160
|
+
if (snapshot.health === null)
|
|
161
|
+
return line(left);
|
|
162
|
+
const right = [
|
|
163
|
+
segment(`${PANEL_HEALTH_LABEL} `, 'muted'),
|
|
164
|
+
segment(String(Math.round(snapshot.health)), 'text', true),
|
|
165
|
+
];
|
|
166
|
+
return segmentsCells(left) + segmentsCells(right) + 2 <= inner ? line(left, right) : line(left);
|
|
167
|
+
}
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
// Step strip
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
function stepSegments(snapshot, glyphs) {
|
|
172
|
+
return snapshot.pipeline.map((step) => {
|
|
173
|
+
const label = PIPELINE_LABEL[step.key];
|
|
174
|
+
if (step.state === 'done') {
|
|
175
|
+
return [segment(label, 'ok'), segment(` ${glyphs.check}`, 'ok')];
|
|
176
|
+
}
|
|
177
|
+
if (step.state === 'active')
|
|
178
|
+
return [segment(`${glyphs.cursor}${label}`, 'govern', true)];
|
|
179
|
+
return [segment(label, 'muted')];
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function flattenSteps(steps, glyphs, leadingGap) {
|
|
183
|
+
const out = leadingGap
|
|
184
|
+
? [segment(`${glyphs.ellipsis} ${glyphs.hrule} `, 'muted')]
|
|
185
|
+
: [];
|
|
186
|
+
steps.forEach((step, index) => {
|
|
187
|
+
if (index > 0)
|
|
188
|
+
out.push(segment(` ${glyphs.hrule} `, 'border'));
|
|
189
|
+
out.push(...step);
|
|
190
|
+
});
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The step strip, with the rework note right-anchored. A strip too wide for the row loses
|
|
195
|
+
* its OLDEST steps first (they are the ones already done), marked with a leading ellipsis,
|
|
196
|
+
* so the current step and what is still to come always stay visible.
|
|
197
|
+
*/
|
|
198
|
+
function buildPipeline(snapshot, inner, glyphs) {
|
|
199
|
+
const steps = stepSegments(snapshot, glyphs);
|
|
200
|
+
if (steps.length === 0)
|
|
201
|
+
return null;
|
|
202
|
+
const note = snapshot.reworkNote === null ? [] : [segment(snapshot.reworkNote, 'warn')];
|
|
203
|
+
const noteCells = segmentsCells(note);
|
|
204
|
+
const activeIndex = Math.max(0, snapshot.pipeline.findIndex((s) => s.state === 'active'));
|
|
205
|
+
for (const withNote of note.length > 0 ? [true, false] : [false]) {
|
|
206
|
+
const budget = inner - (withNote ? noteCells + 2 : 0);
|
|
207
|
+
for (let start = 0; start <= Math.min(activeIndex, steps.length - 1); start += 1) {
|
|
208
|
+
const left = flattenSteps(steps.slice(start), glyphs, start > 0);
|
|
209
|
+
if (segmentsCells(left) <= budget)
|
|
210
|
+
return line(left, withNote ? note : []);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return line(flattenSteps(steps.slice(activeIndex), glyphs, activeIndex > 0));
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// Ticker
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
function tickerEntry(row) {
|
|
219
|
+
const amount = signedDeltaText(row.delta, row.provisional);
|
|
220
|
+
return `${row.agentId} ${amount} ${row.code} ${row.reason}`.replace(/\s+/g, ' ').trim();
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The ledger ticker: the most recent entries, newest first, joined by a middle dot.
|
|
224
|
+
*
|
|
225
|
+
* An ALERT outranks it. A budget warning or an escalation is the one thing the panel
|
|
226
|
+
* cannot afford to scroll past, and the row is already the panel's quiet last line.
|
|
227
|
+
*/
|
|
228
|
+
function buildTicker(snapshot, inner, glyphs) {
|
|
229
|
+
const alert = snapshot.alerts[0];
|
|
230
|
+
if (alert !== undefined) {
|
|
231
|
+
const text = fitCells(`${glyphs.warn} ${alert}`, inner, glyphs.ellipsis);
|
|
232
|
+
return [line([segment(text, 'warn')])];
|
|
233
|
+
}
|
|
234
|
+
if (snapshot.recent.length === 0)
|
|
235
|
+
return [];
|
|
236
|
+
const label = `${PANEL_LEDGER_LABEL} `;
|
|
237
|
+
const separator = ` ${glyphs.midDot} `;
|
|
238
|
+
const budget = Math.max(0, inner - cellWidth(label));
|
|
239
|
+
let body = '';
|
|
240
|
+
// Sorted by time here rather than trusting the producer's order: the ticker's whole
|
|
241
|
+
// meaning is "newest first".
|
|
242
|
+
for (const row of [...snapshot.recent].sort((a, b) => b.at - a.at)) {
|
|
243
|
+
const next = body === '' ? tickerEntry(row) : `${body}${separator}${tickerEntry(row)}`;
|
|
244
|
+
if (body !== '' && cellWidth(next) > budget)
|
|
245
|
+
break;
|
|
246
|
+
body = next;
|
|
247
|
+
}
|
|
248
|
+
const shown = fitCells(body, budget, glyphs.ellipsis);
|
|
249
|
+
return [line([segment(label, 'muted'), segment(shown, 'text')])];
|
|
250
|
+
}
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// Minimal tier
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
function minimalCandidates(snapshot, glyphs) {
|
|
255
|
+
const status = isPausePending(snapshot)
|
|
256
|
+
? ` ${STATUS_WORD.pausing}`
|
|
257
|
+
: snapshot.status === 'paused' || snapshot.status === 'escalated'
|
|
258
|
+
? ` ${STATUS_WORD[snapshot.status]}`
|
|
259
|
+
: '';
|
|
260
|
+
const stage = stageWord(snapshot);
|
|
261
|
+
const base = `${GOV_TITLE}${status} ${phaseText(snapshot.phase, snapshot.phaseCount)}`;
|
|
262
|
+
const staged = stage === '' ? base : `${base} ${stage}`;
|
|
263
|
+
const dot = ` ${glyphs.midDot} `;
|
|
264
|
+
const working = workingCountText(workingCount(snapshot));
|
|
265
|
+
const health = snapshot.health === null
|
|
266
|
+
? ''
|
|
267
|
+
: `${dot}${PANEL_HEALTH_LABEL} ${Math.round(snapshot.health)}`;
|
|
268
|
+
return [
|
|
269
|
+
`${staged}${dot}${working}${health}${dot}${PANEL_BOARD_HINT}`,
|
|
270
|
+
`${staged}${dot}${working}${health}`,
|
|
271
|
+
`${staged}${dot}${working}`,
|
|
272
|
+
staged,
|
|
273
|
+
base,
|
|
274
|
+
GOV_TITLE,
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
function buildMinimal(snapshot, inner, glyphs) {
|
|
278
|
+
const fits = (candidate) => cellWidth(candidate) <= inner;
|
|
279
|
+
const text = minimalCandidates(snapshot, glyphs).find(fits)
|
|
280
|
+
?? fitCells(GOV_TITLE, inner, glyphs.ellipsis);
|
|
281
|
+
const split = text.indexOf(' ');
|
|
282
|
+
const head = split < 0 ? text : text.slice(0, split);
|
|
283
|
+
const rest = split < 0 ? '' : text.slice(split);
|
|
284
|
+
return line([segment(head, 'govern', true), ...(rest === '' ? [] : [segment(rest, 'muted')])]);
|
|
285
|
+
}
|
|
286
|
+
function selectRoster(snapshot, rows, since) {
|
|
287
|
+
const present = sortRoster(snapshot.roster)
|
|
288
|
+
.filter((row) => !isRetired(row, snapshot.phase, since));
|
|
289
|
+
const cap = maxRosterRows(rows);
|
|
290
|
+
if (present.length <= cap)
|
|
291
|
+
return { visible: present, hidden: 0 };
|
|
292
|
+
// One row of the cap is spent on the `+N more` line, so a hidden roster never makes
|
|
293
|
+
// the panel taller than the budget `maxRosterRows` promised.
|
|
294
|
+
const shown = Math.max(1, cap - 1);
|
|
295
|
+
return { visible: present.slice(0, shown), hidden: present.length - shown };
|
|
296
|
+
}
|
|
297
|
+
function buildTier(input, tier) {
|
|
298
|
+
const snapshot = input.snapshot;
|
|
299
|
+
const cols = nonNegativeInt(input.cols);
|
|
300
|
+
const inner = Math.max(0, cols - PANEL_MARGIN_CELLS);
|
|
301
|
+
const mode = input.mode ?? 'panel';
|
|
302
|
+
const base = { ...EMPTY, tier, mode, cols, innerCols: inner };
|
|
303
|
+
if (tier === 'minimal') {
|
|
304
|
+
return { ...base, height: 1, header: buildMinimal(snapshot, inner, input.glyphs) };
|
|
305
|
+
}
|
|
306
|
+
const compact = tier === 'compact';
|
|
307
|
+
const header = compact
|
|
308
|
+
? buildCompactHeader(snapshot, inner, input.now, input.glyphs)
|
|
309
|
+
: buildHeader(snapshot, inner, input.now, input.glyphs, tier === 'full');
|
|
310
|
+
const pipeline = compact ? null : buildPipeline(snapshot, inner, input.glyphs);
|
|
311
|
+
if (mode === 'run-strip') {
|
|
312
|
+
return { ...base, height: 1 + Number(pipeline !== null), header, pipeline };
|
|
313
|
+
}
|
|
314
|
+
const columns = columnPlan(tier, inner, markerCells(input.glyphs));
|
|
315
|
+
const { visible, hidden } = selectRoster(snapshot, input.rows, input.eliminatedSince ?? {});
|
|
316
|
+
const rosterRows = visible.map((row) => buildRosterLine({
|
|
317
|
+
columns, row, glyphs: input.glyphs, now: input.now, reducedMotion: input.reducedMotion,
|
|
318
|
+
}));
|
|
319
|
+
const ticker = compact ? [] : buildTicker(snapshot, inner, input.glyphs);
|
|
320
|
+
const ruled = !compact && rosterRows.length > 0;
|
|
321
|
+
const overflow = hidden > 0 ? fitCells(moreText(hidden), inner, input.glyphs.ellipsis) : null;
|
|
322
|
+
const height = 1 + Number(pipeline !== null) + 2 * Number(ruled) + rosterRows.length
|
|
323
|
+
+ Number(overflow !== null) + ticker.length;
|
|
324
|
+
return {
|
|
325
|
+
...base,
|
|
326
|
+
height,
|
|
327
|
+
header,
|
|
328
|
+
pipeline,
|
|
329
|
+
ruleCells: ruled ? inner : 0,
|
|
330
|
+
columns,
|
|
331
|
+
rosterRows,
|
|
332
|
+
overflow,
|
|
333
|
+
ticker,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Plan the panel for a terminal and a snapshot.
|
|
338
|
+
*
|
|
339
|
+
* `null` snapshot, or a finished run, plans to height 0 (nothing mounts - zero rows and
|
|
340
|
+
* zero layout shift, the `TeamPanel` D-11 rule). The caller's `availableRows` is a
|
|
341
|
+
* ceiling: tiers step down until one fits, and `minimal` is a single row or, with no row to
|
|
342
|
+
* spare, nothing.
|
|
343
|
+
*/
|
|
344
|
+
export function buildGovernancePanelLayout(input) {
|
|
345
|
+
if (input.snapshot === null || isFinishedRun(input.snapshot.status))
|
|
346
|
+
return EMPTY;
|
|
347
|
+
const available = input.availableRows === undefined
|
|
348
|
+
? Infinity
|
|
349
|
+
: nonNegativeInt(input.availableRows);
|
|
350
|
+
let tier = selectTier(nonNegativeInt(input.cols), nonNegativeInt(input.rows));
|
|
351
|
+
while (tier !== null) {
|
|
352
|
+
const layout = buildTier(input, tier);
|
|
353
|
+
if (layout.height <= available)
|
|
354
|
+
return layout;
|
|
355
|
+
tier = NEXT_SMALLER[tier];
|
|
356
|
+
}
|
|
357
|
+
return { ...EMPTY, cols: nonNegativeInt(input.cols) };
|
|
358
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Roster geometry and cell text for the legion panel (governance-mode section 10.3).
|
|
3
|
+
*
|
|
4
|
+
* Pure and total: no Ink, no clock, no terminal. ASCII ONLY.
|
|
5
|
+
*
|
|
6
|
+
* WHY COMPUTED FIXED-WIDTH COLUMNS. Same lesson as `team-row.ts`, whose header records
|
|
7
|
+
* it at length: a fixed-height parent makes Yoga size a flex column to its widest CHILD,
|
|
8
|
+
* so a row placed by `flexGrow` stops short of the terminal and the cells to its right
|
|
9
|
+
* lose their absolute offsets. Every column below therefore has a COMPUTED integer width
|
|
10
|
+
* and exactly ONE column is elastic; it sits between the fixed cluster on its left and
|
|
11
|
+
* the fixed `delta` cell on its right, so the score change always lands in the row's
|
|
12
|
+
* last column whatever the activity text says.
|
|
13
|
+
*
|
|
14
|
+
* `columnPlan` is TOTAL: for any width (including 0 and 400) the widths never sum past
|
|
15
|
+
* the width it was given. `governance-panel-layout.test.ts` runs it for every width.
|
|
16
|
+
*/
|
|
17
|
+
import type { RosterRow } from '../../governance/types.js';
|
|
18
|
+
import type { Glyphs } from '../glyphs.js';
|
|
19
|
+
import { type Segment } from '../governance-status.js';
|
|
20
|
+
export type PanelTier = 'full' | 'standard' | 'compact' | 'minimal';
|
|
21
|
+
export type RosterColumnKey = 'marker' | 'id' | 'role' | 'state' | 'gauge' | 'score' | 'prov' | 'tag' | 'wp' | 'activity' | 'delta' | 'note';
|
|
22
|
+
export interface RosterColumn {
|
|
23
|
+
key: RosterColumnKey;
|
|
24
|
+
/** Final integer width in terminal columns (the elastic column's is what is left). */
|
|
25
|
+
width: number;
|
|
26
|
+
elastic: boolean;
|
|
27
|
+
align: 'left' | 'right';
|
|
28
|
+
}
|
|
29
|
+
/** One leading margin column, drawn by the component. */
|
|
30
|
+
export declare const PANEL_MARGIN_CELLS = 1;
|
|
31
|
+
/**
|
|
32
|
+
* The row's columns for a tier at `inner` columns (the terminal width minus the margin).
|
|
33
|
+
*
|
|
34
|
+
* THE DROP LADDER IS THE SPECIFICATION, in the order the cells give way: the activity
|
|
35
|
+
* text first (the only column whose loss costs nothing structural - the work-package cell
|
|
36
|
+
* becomes the elastic one), then the tag, gauge, provisional, role and delta cells. The
|
|
37
|
+
* elastic column keeps at least its floor; when even the fixed cluster does not fit,
|
|
38
|
+
* `squeeze` trims from the right so the sum stays inside `inner` for any input.
|
|
39
|
+
*/
|
|
40
|
+
export declare function columnPlan(tier: PanelTier, inner: number, markerCells: number): RosterColumn[];
|
|
41
|
+
export declare function columnsWidth(columns: readonly RosterColumn[]): number;
|
|
42
|
+
export interface RosterCell {
|
|
43
|
+
key: RosterColumnKey;
|
|
44
|
+
width: number;
|
|
45
|
+
elastic: boolean;
|
|
46
|
+
align: 'left' | 'right';
|
|
47
|
+
segments: Segment[];
|
|
48
|
+
}
|
|
49
|
+
export interface RosterLine {
|
|
50
|
+
/** `row.id`; stable across snapshots so React keys do not churn. */
|
|
51
|
+
key: string;
|
|
52
|
+
kind: 'agent' | 'eliminated';
|
|
53
|
+
cells: RosterCell[];
|
|
54
|
+
}
|
|
55
|
+
export interface RosterLineInput {
|
|
56
|
+
columns: readonly RosterColumn[];
|
|
57
|
+
row: RosterRow;
|
|
58
|
+
glyphs: Glyphs;
|
|
59
|
+
now: number;
|
|
60
|
+
reducedMotion: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** One roster row's cells, text already clamped to its cell. */
|
|
63
|
+
export declare function buildRosterLine(input: RosterLineInput): RosterLine;
|
|
64
|
+
/** The marker cell's width in the current glyph tier: 1 + widest marker + 1. */
|
|
65
|
+
export declare function markerCells(glyphs: Glyphs): number;
|