@aragon-agent/cli 0.6.44 → 0.6.45
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 +69 -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/plan-prompt.d.ts +7 -0
- package/dist/agent/plan-prompt.js +2 -1
- package/dist/agent/reducer.d.ts +33 -1
- package/dist/agent/reducer.js +45 -9
- 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 +10 -4
- package/dist/commands/governance-command.d.ts +35 -0
- package/dist/commands/governance-command.js +292 -0
- package/dist/commands/governance-runs-table.d.ts +40 -0
- package/dist/commands/governance-runs-table.js +130 -0
- package/dist/commands/registry.d.ts +12 -0
- 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/validate-session.js +32 -1
- 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 +145 -25
- 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 +3 -0
- package/dist/ui/entries/GovernanceCard.d.ts +30 -0
- package/dist/ui/entries/GovernanceCard.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/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 +11 -0
- 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 +9 -0
- package/dist/ui/use-wheel-routing.js +3 -1
- package/package.json +2 -2
|
@@ -105,6 +105,14 @@ export interface UiState {
|
|
|
105
105
|
* and a boolean could only ever say "shown", never "shown WHAT".
|
|
106
106
|
*/
|
|
107
107
|
promptKeyNoticeVersion: number;
|
|
108
|
+
/**
|
|
109
|
+
* Whether the one-time GOVERN explainer has been shown (governance-mode 4.3). A boolean is
|
|
110
|
+
* enough here, unlike the notices above: the sentence has never been reworded, so there is
|
|
111
|
+
* no audience of "already shown the OLD text" to reach. Like them it is a new scalar rather
|
|
112
|
+
* than a schema bump (which would reset every user's `submitCount`), and an older file reads
|
|
113
|
+
* it as `false`, which is exactly the first-run behaviour wanted.
|
|
114
|
+
*/
|
|
115
|
+
governanceIntroSeen: boolean;
|
|
108
116
|
}
|
|
109
117
|
/** Read the state, caching it for the life of the process. Never throws. */
|
|
110
118
|
export declare function loadUiState(): UiState;
|
|
@@ -125,6 +133,9 @@ export declare function setScrollModeNoticeVersion(version: number): void;
|
|
|
125
133
|
/** `0` on a file written before the field existed; see the field's comment. */
|
|
126
134
|
export declare function getPromptKeyNoticeVersion(): number;
|
|
127
135
|
export declare function setPromptKeyNoticeVersion(version: number): void;
|
|
136
|
+
/** `false` until the one-time GOVERN explainer has been shown; persisted across launches. */
|
|
137
|
+
export declare function getGovernanceIntroSeen(): boolean;
|
|
138
|
+
export declare function setGovernanceIntroSeen(seen: boolean): void;
|
|
128
139
|
/**
|
|
129
140
|
* Migration-only: fill in fields that are still at their default, and never
|
|
130
141
|
* overwrite a value already here. A second import — after a half-finished
|
package/dist/config/ui-state.js
CHANGED
|
@@ -39,6 +39,7 @@ const DEFAULT_UI_STATE = {
|
|
|
39
39
|
vtInputNoticeVersion: 0,
|
|
40
40
|
scrollModeNoticeVersion: 0,
|
|
41
41
|
promptKeyNoticeVersion: 0,
|
|
42
|
+
governanceIntroSeen: false,
|
|
42
43
|
};
|
|
43
44
|
let memory = null;
|
|
44
45
|
/** Non-negative integer or `fallback`; shared by both numeric fields. */
|
|
@@ -73,6 +74,9 @@ function readFromDisk() {
|
|
|
73
74
|
vtInputNoticeVersion: coerceCount(parsed.vtInputNoticeVersion, DEFAULT_UI_STATE.vtInputNoticeVersion),
|
|
74
75
|
scrollModeNoticeVersion: coerceCount(parsed.scrollModeNoticeVersion, DEFAULT_UI_STATE.scrollModeNoticeVersion),
|
|
75
76
|
promptKeyNoticeVersion: coerceCount(parsed.promptKeyNoticeVersion, DEFAULT_UI_STATE.promptKeyNoticeVersion),
|
|
77
|
+
governanceIntroSeen: typeof parsed.governanceIntroSeen === 'boolean'
|
|
78
|
+
? parsed.governanceIntroSeen
|
|
79
|
+
: DEFAULT_UI_STATE.governanceIntroSeen,
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
82
|
catch {
|
|
@@ -160,6 +164,13 @@ export function getPromptKeyNoticeVersion() {
|
|
|
160
164
|
export function setPromptKeyNoticeVersion(version) {
|
|
161
165
|
update({ promptKeyNoticeVersion: version });
|
|
162
166
|
}
|
|
167
|
+
/** `false` until the one-time GOVERN explainer has been shown; persisted across launches. */
|
|
168
|
+
export function getGovernanceIntroSeen() {
|
|
169
|
+
return loadUiState().governanceIntroSeen;
|
|
170
|
+
}
|
|
171
|
+
export function setGovernanceIntroSeen(seen) {
|
|
172
|
+
update({ governanceIntroSeen: seen });
|
|
173
|
+
}
|
|
163
174
|
/**
|
|
164
175
|
* Migration-only: fill in fields that are still at their default, and never
|
|
165
176
|
* overwrite a value already here. A second import — after a half-finished
|
|
@@ -16,6 +16,8 @@ import process from 'node:process';
|
|
|
16
16
|
import { initProviders, ModelRegistry } from '@aragon-agent/core';
|
|
17
17
|
import { getHomeResolutionWarning, getSessionsDir, getUserDataDir } from '../config/app-paths.js';
|
|
18
18
|
import { readConfigFile } from '../config/store.js';
|
|
19
|
+
import { describeGovernanceConfigAvailability, } from '../config/governance-config.js';
|
|
20
|
+
import { unavailableReasonText } from '../governance/copy.js';
|
|
19
21
|
import { loadConfig, makeGetApiKey } from '../config/load.js';
|
|
20
22
|
import { isAdapterProvider, toRetryPolicy } from '../config/schema.js';
|
|
21
23
|
import { MODE_TOGGLE_KEYS } from '../agent/agent-mode.js';
|
|
@@ -28,6 +30,7 @@ export async function runDoctorChecks(flags, opts = {}) {
|
|
|
28
30
|
checks.push(checkModel(config));
|
|
29
31
|
checks.push(checkSessionsDir());
|
|
30
32
|
checks.push(checkValidationStrength());
|
|
33
|
+
checks.push(checkGovernance(config));
|
|
31
34
|
if (opts.probe)
|
|
32
35
|
checks.push(await probeProvider(config));
|
|
33
36
|
return { ok: checks.every((c) => c.verdict !== 'fail'), checks };
|
|
@@ -64,6 +67,23 @@ function checkValidationStrength() {
|
|
|
64
67
|
return pass('ajv', 'absent: required/properties/items/additionalProperties are still enforced by the ' +
|
|
65
68
|
'built-in validator; pattern/format/multipleOf are not');
|
|
66
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* `governance: ready | unavailable (<reason>)` (governance-mode 13.2) - a `pass` either way.
|
|
72
|
+
*
|
|
73
|
+
* An unavailable feature is a CHOICE (a config key, `ARAGON_GOVERNANCE=0`, team mode off),
|
|
74
|
+
* not a defect, so it must not warn or move the exit code; the row exists so "why does
|
|
75
|
+
* Shift+Tab not reach GOVERN" has an answer next to the other install facts. Config-level
|
|
76
|
+
* reasons only: a missing API key is already reported by the `api-key` row, and the runtime
|
|
77
|
+
* reasons (`headless`, `restart_required`) are not properties of an installation.
|
|
78
|
+
* The sentences come from `governance/copy.ts`, the one definition `/gov` and the settings
|
|
79
|
+
* screen share.
|
|
80
|
+
*/
|
|
81
|
+
function checkGovernance(config) {
|
|
82
|
+
const availability = describeGovernanceConfigAvailability(config, process.env);
|
|
83
|
+
if (availability.ok)
|
|
84
|
+
return pass('governance', 'ready');
|
|
85
|
+
return pass('governance', `unavailable (${unavailableReasonText(availability.reason)})`);
|
|
86
|
+
}
|
|
67
87
|
function pass(name, detail) {
|
|
68
88
|
return { name, verdict: 'pass', detail, remedy: '' };
|
|
69
89
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `normalizeGovernanceCard` - turn an untrusted value (a session file, a hand-edited
|
|
3
|
+
* `entries` array) into a renderable `GovernanceCardData`, or `null` (section 10.4).
|
|
4
|
+
*
|
|
5
|
+
* Pure: no React, no I/O. ASCII ONLY.
|
|
6
|
+
*
|
|
7
|
+
* LENIENT BY DESIGN. A governance card is HISTORY: a resume that refuses because one row
|
|
8
|
+
* carried a string where a number belongs would throw away a conversation to protect a
|
|
9
|
+
* footnote (`validate-session.ts` makes the same argument for the todo card). So:
|
|
10
|
+
* unknown fields are dropped, a malformed ROW is dropped, a missing text field degrades
|
|
11
|
+
* to an empty string, and only a value that is not a card at all (not an object, no
|
|
12
|
+
* recognisable variant, nothing left to draw) returns `null` - which the caller turns into
|
|
13
|
+
* a one-line text entry.
|
|
14
|
+
*/
|
|
15
|
+
import type { GovernanceCardData } from './types.js';
|
|
16
|
+
/** The one line a card degrades to when nothing of it can be drawn. */
|
|
17
|
+
export declare const GOVERNANCE_CARD_FALLBACK_TEXT = "Governance card unavailable";
|
|
18
|
+
/** Bounds so a corrupt file cannot make a card taller than the transcript can hold. */
|
|
19
|
+
export declare const CARD_LIMITS: {
|
|
20
|
+
readonly rows: 24;
|
|
21
|
+
readonly notes: 12;
|
|
22
|
+
readonly textChars: 400;
|
|
23
|
+
};
|
|
24
|
+
export declare function normalizeGovernanceCard(value: unknown): GovernanceCardData | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `normalizeGovernanceCard` - turn an untrusted value (a session file, a hand-edited
|
|
3
|
+
* `entries` array) into a renderable `GovernanceCardData`, or `null` (section 10.4).
|
|
4
|
+
*
|
|
5
|
+
* Pure: no React, no I/O. ASCII ONLY.
|
|
6
|
+
*
|
|
7
|
+
* LENIENT BY DESIGN. A governance card is HISTORY: a resume that refuses because one row
|
|
8
|
+
* carried a string where a number belongs would throw away a conversation to protect a
|
|
9
|
+
* footnote (`validate-session.ts` makes the same argument for the todo card). So:
|
|
10
|
+
* unknown fields are dropped, a malformed ROW is dropped, a missing text field degrades
|
|
11
|
+
* to an empty string, and only a value that is not a card at all (not an object, no
|
|
12
|
+
* recognisable variant, nothing left to draw) returns `null` - which the caller turns into
|
|
13
|
+
* a one-line text entry.
|
|
14
|
+
*/
|
|
15
|
+
const VARIANTS = [
|
|
16
|
+
'charter',
|
|
17
|
+
'phase',
|
|
18
|
+
'escalation',
|
|
19
|
+
'final',
|
|
20
|
+
];
|
|
21
|
+
const TONES = ['ok', 'warn', 'error', 'info'];
|
|
22
|
+
const ROLES = ['DEV', 'REV', 'TEST', 'INSP'];
|
|
23
|
+
/** The one line a card degrades to when nothing of it can be drawn. */
|
|
24
|
+
export const GOVERNANCE_CARD_FALLBACK_TEXT = 'Governance card unavailable';
|
|
25
|
+
/** Bounds so a corrupt file cannot make a card taller than the transcript can hold. */
|
|
26
|
+
export const CARD_LIMITS = { rows: 24, notes: 12, textChars: 400 };
|
|
27
|
+
function asRecord(value) {
|
|
28
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
29
|
+
? value
|
|
30
|
+
: null;
|
|
31
|
+
}
|
|
32
|
+
function text(value) {
|
|
33
|
+
return typeof value === 'string' ? value.slice(0, CARD_LIMITS.textChars) : '';
|
|
34
|
+
}
|
|
35
|
+
function oneOf(value, allowed, fallback) {
|
|
36
|
+
return typeof value === 'string' && allowed.includes(value)
|
|
37
|
+
? value
|
|
38
|
+
: fallback;
|
|
39
|
+
}
|
|
40
|
+
function normalizeRow(value) {
|
|
41
|
+
const source = asRecord(value);
|
|
42
|
+
if (source === null || typeof source.id !== 'string' || source.id === '')
|
|
43
|
+
return null;
|
|
44
|
+
const role = oneOf(source.role, ROLES, 'DEV');
|
|
45
|
+
const confirmed = typeof source.confirmed === 'number' && Number.isFinite(source.confirmed)
|
|
46
|
+
? source.confirmed
|
|
47
|
+
: null;
|
|
48
|
+
return { id: text(source.id), role, confirmed, deltaText: text(source.deltaText) };
|
|
49
|
+
}
|
|
50
|
+
export function normalizeGovernanceCard(value) {
|
|
51
|
+
const source = asRecord(value);
|
|
52
|
+
if (source === null)
|
|
53
|
+
return null;
|
|
54
|
+
const rows = (Array.isArray(source.rows) ? source.rows : [])
|
|
55
|
+
.slice(0, CARD_LIMITS.rows)
|
|
56
|
+
.map(normalizeRow)
|
|
57
|
+
.filter((row) => row !== null);
|
|
58
|
+
const notes = (Array.isArray(source.notes) ? source.notes : [])
|
|
59
|
+
.slice(0, CARD_LIMITS.notes)
|
|
60
|
+
.filter((note) => typeof note === 'string')
|
|
61
|
+
.map((note) => note.slice(0, CARD_LIMITS.textChars));
|
|
62
|
+
const title = text(source.title);
|
|
63
|
+
const headline = text(source.headline);
|
|
64
|
+
// Nothing to draw: the caller degrades to a one-line text entry.
|
|
65
|
+
if (title === '' && headline === '' && rows.length === 0 && notes.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
return {
|
|
68
|
+
variant: oneOf(source.variant, VARIANTS, 'phase'),
|
|
69
|
+
runId: text(source.runId),
|
|
70
|
+
title,
|
|
71
|
+
headline,
|
|
72
|
+
tone: oneOf(source.tone, TONES, 'info'),
|
|
73
|
+
rows,
|
|
74
|
+
notes,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every user-visible governance sentence (governance-mode 10.6, 14.2).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY (`governance/` is glyph-scanned). UI components, the `/gov` command, `doctor`
|
|
5
|
+
* and the settings screen import their words from here and never inline a sentence: one
|
|
6
|
+
* place to review the wording, one place to change it, and one definition of what each
|
|
7
|
+
* "unavailable" reason means (`/gov`, `doctor` and settings share it).
|
|
8
|
+
*
|
|
9
|
+
* Nothing here reaches a model. Prompts live in `prompts/`; these strings are for the
|
|
10
|
+
* person at the keyboard, which is why they may be friendlier and less formal.
|
|
11
|
+
*/
|
|
12
|
+
import type { DispatchEstimate } from './engine/estimate.js';
|
|
13
|
+
import { type Posture } from './posture.js';
|
|
14
|
+
/** Why governance cannot be used right now. Spelled as in `config/governance-config.ts`. */
|
|
15
|
+
export type GovernanceUnavailableReason = 'disabled_config' | 'disabled_env' | 'no_team' | 'team_off' | 'no_api_key' | 'headless' | 'restart_required';
|
|
16
|
+
/** Shown for `restart_required`: the tool array is fixed at construction (RV-14). */
|
|
17
|
+
export declare const RESTART_REQUIRED_TEXT = "Governance was disabled when this session started. Restart to enable it.";
|
|
18
|
+
/** The one sentence for an unavailable reason (`/gov`, `doctor`, settings). */
|
|
19
|
+
export declare function unavailableReasonText(reason: GovernanceUnavailableReason): string;
|
|
20
|
+
export type GovernanceAvailability = {
|
|
21
|
+
ok: true;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
reason: GovernanceUnavailableReason;
|
|
25
|
+
};
|
|
26
|
+
/** `doctor` line: `governance: ready` or `governance: unavailable (<reason>)`. */
|
|
27
|
+
export declare function doctorGovernanceLine(availability: GovernanceAvailability): string;
|
|
28
|
+
/** One-time notice on the first entry into GOVERN (shown once across launches). */
|
|
29
|
+
export declare const GOVERN_INTRO_NOTICE: string;
|
|
30
|
+
/** One-time notice on the first entry into PLAN+GOVERN. */
|
|
31
|
+
export declare const PLAN_GOVERN_INTRO_NOTICE: string;
|
|
32
|
+
/** `<LABEL> mode.` after a posture change took effect. */
|
|
33
|
+
export declare function postureAppliedToast(posture: Posture): string;
|
|
34
|
+
/** The change was deferred to the end of the current run. */
|
|
35
|
+
export declare function posturePendingToast(posture: Posture): string;
|
|
36
|
+
/** D-23: a governed stage is in flight, so every posture change waits for it. */
|
|
37
|
+
export declare function stageRunningToast(target: Posture): string;
|
|
38
|
+
/** Toast when a PLAN+GOVERN plan is approved and the posture flips to GOVERN. */
|
|
39
|
+
export declare const PLAN_APPROVED_TOAST = "Plan approved - GOVERN mode: the team takes over.";
|
|
40
|
+
/** Hint rows (interaction-hints). */
|
|
41
|
+
export declare const GOV_IDLE_HINT = "type a task - the Orchestrator will assemble the team";
|
|
42
|
+
export declare const GOV_RUNNING_HINT = "esc x2 interrupt (run is resumable)";
|
|
43
|
+
/** Shortcut-panel descriptions (`ui/shortcuts.ts`). */
|
|
44
|
+
export declare const SHIFT_TAB_DESCRIPTION = "Cycle BUILD / PLAN / GOVERN / PLAN+GOVERN";
|
|
45
|
+
export declare const GOV_COMMAND_SUMMARY = "Governed multi-agent team: /gov help";
|
|
46
|
+
/**
|
|
47
|
+
* Chip on the question overlay during the PLAN+GOVERN interview. While rounds are still
|
|
48
|
+
* needed it shows the round being asked; once enough were ANSWERED the `+` becomes `OK`.
|
|
49
|
+
* `''` when no minimum is enforced.
|
|
50
|
+
*/
|
|
51
|
+
export declare function interviewChipText(answered: number, need: number): string;
|
|
52
|
+
export declare const GOV_STAGE_BUSY_NOTICE: string;
|
|
53
|
+
export declare const GOV_OFF_WITH_RUN_NOTICE: string;
|
|
54
|
+
export declare const GOV_OFF_NOTICE = "Governance is off.";
|
|
55
|
+
export declare const GOV_NO_STAGE_NOTICE = "No governed stage is running.";
|
|
56
|
+
export declare const GOV_ABORTED_NOTICE = "The stage was stopped and the run is paused. /gov resume continues it.";
|
|
57
|
+
export declare const GOV_NO_RUN_NOTICE = "There is no governed run to resume in this directory.";
|
|
58
|
+
export declare const GOV_NO_RUNS_NOTICE = "No governed runs yet in this directory.";
|
|
59
|
+
export declare const GOV_PAUSE_NO_RUN_NOTICE = "No governed run to pause.";
|
|
60
|
+
export declare const GOV_PAUSE_ALREADY_NOTICE = "Already paused. /gov resume continues it.";
|
|
61
|
+
export declare const GOV_PAUSE_ESCALATED_NOTICE: string;
|
|
62
|
+
export declare const GOV_PAUSE_CANCELLED_TOAST = "Pause cancelled; the run continues.";
|
|
63
|
+
export declare const GOV_PAUSE_NONE_PENDING_NOTICE = "No pause is pending.";
|
|
64
|
+
/** Toast: the request is accepted and the stage keeps running. */
|
|
65
|
+
export declare function govPausePendingToast(stage: string | null): string;
|
|
66
|
+
/** Toast: no stage was running, so the run paused at once. */
|
|
67
|
+
export declare function govPausedNowToast(runId: string): string;
|
|
68
|
+
export declare const GOV_REPORT_USAGE = "Usage: /gov report [runId]";
|
|
69
|
+
export declare function govReportBadIdNotice(raw: string): string;
|
|
70
|
+
export declare function govReportMissingNotice(runId: string): string;
|
|
71
|
+
export declare const GOV_REPORT_NO_RUN_NOTICE = "There is no governed run to report on in this directory.";
|
|
72
|
+
export declare const GOV_REPORT_MAX_LINES = 120;
|
|
73
|
+
/** `/gov on` and friends when governance cannot be used. */
|
|
74
|
+
export declare function govUnavailableNotice(reason: GovernanceUnavailableReason): string;
|
|
75
|
+
export declare function govBudgetSetNotice(tokens: number): string;
|
|
76
|
+
export declare const GOV_BUDGET_OFF_NOTICE = "Team token budget removed (unlimited).";
|
|
77
|
+
export declare const GOV_BUDGET_USAGE = "Usage: /gov budget <tokens>|off";
|
|
78
|
+
export interface GovStatusRun {
|
|
79
|
+
runId: string;
|
|
80
|
+
/** 1-based. */
|
|
81
|
+
phase: number;
|
|
82
|
+
phaseCount: number;
|
|
83
|
+
stage: string | null;
|
|
84
|
+
status: string;
|
|
85
|
+
health: number | null;
|
|
86
|
+
/** A cooperative `/gov pause` is waiting for the running stage to finish. */
|
|
87
|
+
pauseRequested?: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface GovStatusInput {
|
|
90
|
+
posture: Posture;
|
|
91
|
+
availability: GovernanceAvailability;
|
|
92
|
+
run: GovStatusRun | null;
|
|
93
|
+
/** The `formatDispatchEstimate` line for the live run, when there is one. */
|
|
94
|
+
dispatchPlan?: string | null;
|
|
95
|
+
}
|
|
96
|
+
/** The `/gov` and `/gov status` notice. */
|
|
97
|
+
export declare function formatGovStatus(input: GovStatusInput): string;
|
|
98
|
+
/** `/gov help`: the three powers, GT, stages, keys, and how this differs from team fan-out. */
|
|
99
|
+
export declare function buildGovHelpText(minAskRounds?: number): string;
|
|
100
|
+
/**
|
|
101
|
+
* THE DISCIPLINE OF THIS WORDING. The three numbers are the only ones that can be proven
|
|
102
|
+
* true (see `engine/estimate.ts`), so the sentence says exactly what each one is: a CLEAN
|
|
103
|
+
* run, what ONE round "adds up to", and the cap. It never says "at most", "upper bound" or
|
|
104
|
+
* "worst case" - the rework cap is per work package and grants raise it, so any total
|
|
105
|
+
* would be a promise the engine does not keep. `governance-estimate.test.ts` asserts that.
|
|
106
|
+
*/
|
|
107
|
+
export declare function formatDispatchEstimate(estimate: DispatchEstimate): string;
|
|
108
|
+
/** The same figures for the Orchestrator's `gov_run start` result (agent-facing, ASCII). */
|
|
109
|
+
export declare function formatDispatchPlanForAgent(estimate: DispatchEstimate): string;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every user-visible governance sentence (governance-mode 10.6, 14.2).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY (`governance/` is glyph-scanned). UI components, the `/gov` command, `doctor`
|
|
5
|
+
* and the settings screen import their words from here and never inline a sentence: one
|
|
6
|
+
* place to review the wording, one place to change it, and one definition of what each
|
|
7
|
+
* "unavailable" reason means (`/gov`, `doctor` and settings share it).
|
|
8
|
+
*
|
|
9
|
+
* Nothing here reaches a model. Prompts live in `prompts/`; these strings are for the
|
|
10
|
+
* person at the keyboard, which is why they may be friendlier and less formal.
|
|
11
|
+
*/
|
|
12
|
+
import { GOV_LIMITS } from './limits.js';
|
|
13
|
+
import { POSTURE_LABEL } from './posture.js';
|
|
14
|
+
/** Shown for `restart_required`: the tool array is fixed at construction (RV-14). */
|
|
15
|
+
export const RESTART_REQUIRED_TEXT = 'Governance was disabled when this session started. Restart to enable it.';
|
|
16
|
+
const UNAVAILABLE_TEXT = {
|
|
17
|
+
disabled_config: 'Governance is switched off in settings (governance.enabled is false).',
|
|
18
|
+
disabled_env: 'Governance is switched off by the ARAGON_GOVERNANCE=0 environment variable.',
|
|
19
|
+
no_team: 'Governance needs team mode, which this session started without (--no-team).',
|
|
20
|
+
team_off: 'Governance needs team mode, which is switched off. Turn it on with /team on.',
|
|
21
|
+
no_api_key: 'Governance needs an API key for the active provider. Set one first.',
|
|
22
|
+
headless: 'Governance mode needs an interactive terminal.',
|
|
23
|
+
restart_required: RESTART_REQUIRED_TEXT,
|
|
24
|
+
};
|
|
25
|
+
/** The one sentence for an unavailable reason (`/gov`, `doctor`, settings). */
|
|
26
|
+
export function unavailableReasonText(reason) {
|
|
27
|
+
return UNAVAILABLE_TEXT[reason];
|
|
28
|
+
}
|
|
29
|
+
/** `doctor` line: `governance: ready` or `governance: unavailable (<reason>)`. */
|
|
30
|
+
export function doctorGovernanceLine(availability) {
|
|
31
|
+
if (availability.ok)
|
|
32
|
+
return 'governance: ready';
|
|
33
|
+
return `governance: unavailable (${unavailableReasonText(availability.reason)})`;
|
|
34
|
+
}
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Posture notices and toasts
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
/** One-time notice on the first entry into GOVERN (shown once across launches). */
|
|
39
|
+
export const GOVERN_INTRO_NOTICE = 'GOVERN: your next message goes to an Orchestrator that runs a governed team ' +
|
|
40
|
+
'(dev / review / test / inspector). Esc interrupts. /gov for status, /gov off to leave.';
|
|
41
|
+
/** One-time notice on the first entry into PLAN+GOVERN. */
|
|
42
|
+
export const PLAN_GOVERN_INTRO_NOTICE = 'PLAN+GOVERN: the Orchestrator interviews you first, then a governed team executes the ' +
|
|
43
|
+
'approved plan. Esc interrupts. /gov for status, /gov off to leave.';
|
|
44
|
+
/** `<LABEL> mode.` after a posture change took effect. */
|
|
45
|
+
export function postureAppliedToast(posture) {
|
|
46
|
+
return `${POSTURE_LABEL[posture]} mode.`;
|
|
47
|
+
}
|
|
48
|
+
/** The change was deferred to the end of the current run. */
|
|
49
|
+
export function posturePendingToast(posture) {
|
|
50
|
+
return `${POSTURE_LABEL[posture]} mode applies after this run.`;
|
|
51
|
+
}
|
|
52
|
+
/** D-23: a governed stage is in flight, so every posture change waits for it. */
|
|
53
|
+
export function stageRunningToast(target) {
|
|
54
|
+
return (`GOVERN stage is running: ${POSTURE_LABEL[target]} applies after it ends. ` +
|
|
55
|
+
'Esc stops the stage now.');
|
|
56
|
+
}
|
|
57
|
+
/** Toast when a PLAN+GOVERN plan is approved and the posture flips to GOVERN. */
|
|
58
|
+
export const PLAN_APPROVED_TOAST = 'Plan approved - GOVERN mode: the team takes over.';
|
|
59
|
+
/** Hint rows (interaction-hints). */
|
|
60
|
+
export const GOV_IDLE_HINT = 'type a task - the Orchestrator will assemble the team';
|
|
61
|
+
export const GOV_RUNNING_HINT = 'esc x2 interrupt (run is resumable)';
|
|
62
|
+
/** Shortcut-panel descriptions (`ui/shortcuts.ts`). */
|
|
63
|
+
export const SHIFT_TAB_DESCRIPTION = 'Cycle BUILD / PLAN / GOVERN / PLAN+GOVERN';
|
|
64
|
+
export const GOV_COMMAND_SUMMARY = 'Governed multi-agent team: /gov help';
|
|
65
|
+
/**
|
|
66
|
+
* Chip on the question overlay during the PLAN+GOVERN interview. While rounds are still
|
|
67
|
+
* needed it shows the round being asked; once enough were ANSWERED the `+` becomes `OK`.
|
|
68
|
+
* `''` when no minimum is enforced.
|
|
69
|
+
*/
|
|
70
|
+
export function interviewChipText(answered, need) {
|
|
71
|
+
if (need <= 0)
|
|
72
|
+
return '';
|
|
73
|
+
if (answered >= need)
|
|
74
|
+
return `PLAN+GOVERN interview round ${answered}/${need} OK`;
|
|
75
|
+
return `PLAN+GOVERN interview round ${answered + 1}/${need}+`;
|
|
76
|
+
}
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
// /gov command
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
export const GOV_STAGE_BUSY_NOTICE = 'A governed stage is running. Wait for it to finish, or press Esc / use /gov abort to ' +
|
|
81
|
+
'stop it first.';
|
|
82
|
+
export const GOV_OFF_WITH_RUN_NOTICE = 'Governance is off. The run is paused, not ended: /gov resume continues it. ' +
|
|
83
|
+
'Use /gov pause first to stop at a clean boundary.';
|
|
84
|
+
export const GOV_OFF_NOTICE = 'Governance is off.';
|
|
85
|
+
export const GOV_NO_STAGE_NOTICE = 'No governed stage is running.';
|
|
86
|
+
export const GOV_ABORTED_NOTICE = 'The stage was stopped and the run is paused. /gov resume continues it.';
|
|
87
|
+
export const GOV_NO_RUN_NOTICE = 'There is no governed run to resume in this directory.';
|
|
88
|
+
export const GOV_NO_RUNS_NOTICE = 'No governed runs yet in this directory.';
|
|
89
|
+
// --- /gov pause (governance-mode-v1-1 6.1) ---------------------------------------------
|
|
90
|
+
export const GOV_PAUSE_NO_RUN_NOTICE = 'No governed run to pause.';
|
|
91
|
+
export const GOV_PAUSE_ALREADY_NOTICE = 'Already paused. /gov resume continues it.';
|
|
92
|
+
export const GOV_PAUSE_ESCALATED_NOTICE = 'The run is waiting on your ruling (escalated); there is nothing to pause. ' +
|
|
93
|
+
'/gov board shows the open item.';
|
|
94
|
+
export const GOV_PAUSE_CANCELLED_TOAST = 'Pause cancelled; the run continues.';
|
|
95
|
+
export const GOV_PAUSE_NONE_PENDING_NOTICE = 'No pause is pending.';
|
|
96
|
+
/** Toast: the request is accepted and the stage keeps running. */
|
|
97
|
+
export function govPausePendingToast(stage) {
|
|
98
|
+
const where = stage === null ? 'the current stage' : `the current stage (${stage.toUpperCase()})`;
|
|
99
|
+
return `Pausing after ${where}. Nothing is stopped; /gov pause cancel undoes this.`;
|
|
100
|
+
}
|
|
101
|
+
/** Toast: no stage was running, so the run paused at once. */
|
|
102
|
+
export function govPausedNowToast(runId) {
|
|
103
|
+
return `Run ${runId} paused. /gov resume continues it.`;
|
|
104
|
+
}
|
|
105
|
+
// --- /gov report (governance-mode-v1-1 7.2) ---------------------------------------------
|
|
106
|
+
export const GOV_REPORT_USAGE = 'Usage: /gov report [runId]';
|
|
107
|
+
export function govReportBadIdNotice(raw) {
|
|
108
|
+
return `"${raw.slice(0, 24)}" is not a run id. ${GOV_REPORT_USAGE}`;
|
|
109
|
+
}
|
|
110
|
+
export function govReportMissingNotice(runId) {
|
|
111
|
+
return (`No report is available for run ${runId} yet ` +
|
|
112
|
+
'(reports are written when a phase is integrated).');
|
|
113
|
+
}
|
|
114
|
+
export const GOV_REPORT_NO_RUN_NOTICE = 'There is no governed run to report on in this directory.';
|
|
115
|
+
export const GOV_REPORT_MAX_LINES = 120;
|
|
116
|
+
/** `/gov on` and friends when governance cannot be used. */
|
|
117
|
+
export function govUnavailableNotice(reason) {
|
|
118
|
+
return `Governance is unavailable: ${unavailableReasonText(reason)}`;
|
|
119
|
+
}
|
|
120
|
+
export function govBudgetSetNotice(tokens) {
|
|
121
|
+
return `Team token budget set to ${tokens}. It limits team spend only.`;
|
|
122
|
+
}
|
|
123
|
+
export const GOV_BUDGET_OFF_NOTICE = 'Team token budget removed (unlimited).';
|
|
124
|
+
export const GOV_BUDGET_USAGE = 'Usage: /gov budget <tokens>|off';
|
|
125
|
+
/** The `/gov` and `/gov status` notice. */
|
|
126
|
+
export function formatGovStatus(input) {
|
|
127
|
+
const lines = [`Posture: ${POSTURE_LABEL[input.posture]}`];
|
|
128
|
+
lines.push(input.availability.ok
|
|
129
|
+
? 'Governance: available'
|
|
130
|
+
: `Governance: unavailable - ${unavailableReasonText(input.availability.reason)}`);
|
|
131
|
+
const run = input.run;
|
|
132
|
+
if (!run) {
|
|
133
|
+
lines.push('Run: none');
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const stage = run.stage ? ` ${run.stage.toUpperCase()}` : '';
|
|
137
|
+
const health = run.health === null ? '' : ` health ${Math.round(run.health)}`;
|
|
138
|
+
const pausing = run.pauseRequested === true ? ' (pausing after this stage)' : '';
|
|
139
|
+
lines.push(`Run: ${run.runId} phase ${run.phase}/${run.phaseCount}${stage} ` +
|
|
140
|
+
`${run.status}${pausing}${health}`);
|
|
141
|
+
if (input.dispatchPlan)
|
|
142
|
+
lines.push(input.dispatchPlan);
|
|
143
|
+
}
|
|
144
|
+
return lines.join('\n');
|
|
145
|
+
}
|
|
146
|
+
function planGovernHelpLine(rounds) {
|
|
147
|
+
if (rounds <= 0)
|
|
148
|
+
return ' PLAN+GOVERN: an interview, then the approved plan is the spec.';
|
|
149
|
+
const noun = rounds === 1 ? 'round' : 'rounds';
|
|
150
|
+
return ` PLAN+GOVERN: an interview of >= ${rounds} answered ${noun}, then the plan is the spec.`;
|
|
151
|
+
}
|
|
152
|
+
/** `/gov help`: the three powers, GT, stages, keys, and how this differs from team fan-out. */
|
|
153
|
+
export function buildGovHelpText(minAskRounds = 2) {
|
|
154
|
+
const rounds = Math.max(0, Math.floor(minAskRounds));
|
|
155
|
+
return [
|
|
156
|
+
'GOVERNANCE - a governed engineering team',
|
|
157
|
+
'',
|
|
158
|
+
'Three powers and an inspector',
|
|
159
|
+
' DEV writes the code, one work package each.',
|
|
160
|
+
' REV reviews independently; can veto, or fix small things directly.',
|
|
161
|
+
' TEST verifies behavior and traces every requirement to evidence.',
|
|
162
|
+
' INSP the fourth power: rules on disputes, checks integration and books judgment',
|
|
163
|
+
' events. It is not scored.',
|
|
164
|
+
'The Orchestrator (this session) plans and drives the run. It cannot edit files itself:',
|
|
165
|
+
'all implementation goes through the dispatched agents.',
|
|
166
|
+
'',
|
|
167
|
+
'GT (governance tokens)',
|
|
168
|
+
` Each DEV / REV / TEST starts with ${GOV_LIMITS.initialTokens} GT. Good work earns GT;`,
|
|
169
|
+
' rejections and incomplete work cost GT. Positive GT waits in ESCROW (P) until the phase',
|
|
170
|
+
' integration check passes, and is clawed back if integration fails because of that',
|
|
171
|
+
` agent. At zero confirmed GT an agent is replaced (${GOV_LIMITS.respawnTokens} GT, briefed).`,
|
|
172
|
+
' GT is a score for this run, unrelated to LLM context tokens.',
|
|
173
|
+
'',
|
|
174
|
+
'Stages, per phase',
|
|
175
|
+
' dev -> review -> test -> settle -> integrate. A failed integration adds fix and',
|
|
176
|
+
' integrate again. Rework loops are automatic; disputes escalate to you.',
|
|
177
|
+
'',
|
|
178
|
+
'Postures and keys',
|
|
179
|
+
' Shift+Tab (or Ctrl+N) cycles BUILD / PLAN / GOVERN / PLAN+GOVERN.',
|
|
180
|
+
' GOVERN: your next message goes to the Orchestrator.',
|
|
181
|
+
planGovernHelpLine(rounds),
|
|
182
|
+
' Esc interrupts; an interrupted run is paused and resumable.',
|
|
183
|
+
' /gov pause stops at the end of the current stage: nothing is killed, no work is lost.',
|
|
184
|
+
'',
|
|
185
|
+
'Commands',
|
|
186
|
+
' /gov status | on | plan | off | board | runs | resume [id] | abort | budget <n|off> | help',
|
|
187
|
+
' /gov pause [cancel] | report [id]',
|
|
188
|
+
'',
|
|
189
|
+
'Team fan-out versus governance',
|
|
190
|
+
' /team and the task tool fan out independent subtasks in parallel and the lead',
|
|
191
|
+
' summarizes them: fast, with no independent check. Governance adds separated roles,',
|
|
192
|
+
' structured submissions, independent review, testing and integration, and a score that',
|
|
193
|
+
' makes skipping quality expensive. It is slower and costs more: use it where quality',
|
|
194
|
+
' matters more than speed.',
|
|
195
|
+
].join('\n');
|
|
196
|
+
}
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// Dispatch plan (governance-mode-v1-1 7.3, V-5)
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
/**
|
|
201
|
+
* THE DISCIPLINE OF THIS WORDING. The three numbers are the only ones that can be proven
|
|
202
|
+
* true (see `engine/estimate.ts`), so the sentence says exactly what each one is: a CLEAN
|
|
203
|
+
* run, what ONE round "adds up to", and the cap. It never says "at most", "upper bound" or
|
|
204
|
+
* "worst case" - the rework cap is per work package and grants raise it, so any total
|
|
205
|
+
* would be a promise the engine does not keep. `governance-estimate.test.ts` asserts that.
|
|
206
|
+
*/
|
|
207
|
+
export function formatDispatchEstimate(estimate) {
|
|
208
|
+
if (estimate.cleanRun === 0)
|
|
209
|
+
return '';
|
|
210
|
+
const chunked = estimate.chunked ? ' Wide stages are split into several calls.' : '';
|
|
211
|
+
return (`Dispatch plan: ${estimate.cleanRun} for a clean run; a rework round adds up to ` +
|
|
212
|
+
`${estimate.perReworkRound}, a fix cycle up to ${estimate.perFixCycle}; the run is ` +
|
|
213
|
+
`capped at ${estimate.hardCap}.${chunked} Counts only - tokens depend on the model ` +
|
|
214
|
+
'and the task.');
|
|
215
|
+
}
|
|
216
|
+
/** The same figures for the Orchestrator's `gov_run start` result (agent-facing, ASCII). */
|
|
217
|
+
export function formatDispatchPlanForAgent(estimate) {
|
|
218
|
+
if (estimate.cleanRun === 0)
|
|
219
|
+
return '';
|
|
220
|
+
return (`DISPATCH PLAN: a clean run needs ${estimate.cleanRun} gov_dispatch calls; a rework ` +
|
|
221
|
+
`round adds up to ${estimate.perReworkRound} and a fix cycle up to ` +
|
|
222
|
+
`${estimate.perFixCycle}; the run is capped at ${estimate.hardCap}.`);
|
|
223
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What follows a ledger change (governance-mode 5.8): elimination is already decided by the
|
|
3
|
+
* pure ledger (`confirmed <= 0` removes the agent inside `apply`), but a removed agent is
|
|
4
|
+
* only half the story - the roster needs a replacement and the work needs an owner.
|
|
5
|
+
*
|
|
6
|
+
* ASCII ONLY (`governance/` is glyph-scanned).
|
|
7
|
+
*
|
|
8
|
+
* RESPAWN IS A SEPARATE LOGGED OP, NOT A SIDE EFFECT OF `apply`. The ledger is rebuilt by
|
|
9
|
+
* replaying `ledger` events; a respawn that happened implicitly in the live path would have
|
|
10
|
+
* no event to replay and the rebuilt ledger would silently lack the successor (I-G2). So
|
|
11
|
+
* the engine issues `{op:'respawn'}` through `core.ledgerOp` like any other mutation.
|
|
12
|
+
*
|
|
13
|
+
* Neither the orchestrator nor any model can trigger a respawn: it is a roster property,
|
|
14
|
+
* not an orchestration action (5.8), and this is the only caller.
|
|
15
|
+
*/
|
|
16
|
+
import type { LedgerEvent } from '../rules/ledger.js';
|
|
17
|
+
import type { BookedEntry, EngineCore } from './engine-core.js';
|
|
18
|
+
export interface AfterLedgerOptions {
|
|
19
|
+
/** 0-based phase the change belongs to (stamped on the respawn entry). */
|
|
20
|
+
phase: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AfterLedgerResult {
|
|
23
|
+
eliminated: string[];
|
|
24
|
+
respawned: Array<{
|
|
25
|
+
predecessor: string;
|
|
26
|
+
successor: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Replace every eliminated-but-unreplaced agent. Idempotent: an agent with `replacedBy`
|
|
31
|
+
* set is skipped, so calling this after every ledger change is safe and cheap.
|
|
32
|
+
*/
|
|
33
|
+
export declare function afterLedgerChange(core: EngineCore, options: AfterLedgerOptions): AfterLedgerResult;
|
|
34
|
+
/**
|
|
35
|
+
* Apply a list of engine / inspector events one op each (each gets its own seq so the log
|
|
36
|
+
* reads as the sequence of decisions it was), then settle the roster. Returns every entry
|
|
37
|
+
* booked, in order.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyEvents(core: EngineCore, events: readonly LedgerEvent[], options: {
|
|
40
|
+
actor?: string;
|
|
41
|
+
phase: number;
|
|
42
|
+
}): BookedEntry[];
|
|
43
|
+
export declare function emitLedger(core: EngineCore): void;
|
|
44
|
+
/**
|
|
45
|
+
* Phase-end tail check (5.8): warn on the first strike, eliminate on the second, skip ties.
|
|
46
|
+
* The preview is computed on the current ledger first because `core.ledgerOp` returns only
|
|
47
|
+
* booked entries, and the warnings / tie notes are exactly what the digest should print.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runTailCheck(core: EngineCore, phase: number): string[];
|