@aragon-agent/cli 0.6.55 → 0.6.57
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 +2935 -2864
- package/README.md +160 -45
- package/dist/agent/controller.d.ts +47 -0
- package/dist/agent/controller.js +153 -2
- package/dist/agent/governance-wiring.js +8 -1
- package/dist/agent/system-prompt.d.ts +26 -0
- package/dist/agent/system-prompt.js +11 -0
- package/dist/app/App.js +101 -3
- package/dist/cli.js +29 -1
- package/dist/commands/builtins.js +4 -0
- package/dist/commands/catalog.js +1 -0
- package/dist/commands/registry.d.ts +8 -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 +29 -0
- package/dist/config/cli-commands.js +76 -1
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +12 -1
- package/dist/config/load.d.ts +10 -0
- package/dist/config/load.js +13 -2
- package/dist/config/store.js +11 -1
- package/dist/exec/bridge/server.d.ts +7 -0
- package/dist/exec/bridge/server.js +6 -2
- package/dist/exec/cli-commands.js +4 -0
- package/dist/exec/index.js +2 -0
- package/dist/exec/options.d.ts +11 -0
- package/dist/exec/options.js +21 -1
- package/dist/gene/block.d.ts +33 -0
- package/dist/gene/block.js +51 -0
- package/dist/gene/capacity.d.ts +74 -0
- package/dist/gene/capacity.js +169 -0
- package/dist/gene/catalog-reconcile.d.ts +13 -0
- package/dist/gene/catalog-reconcile.js +105 -0
- package/dist/gene/catalog-stats.d.ts +27 -0
- package/dist/gene/catalog-stats.js +89 -0
- package/dist/gene/catalog-sync.d.ts +82 -0
- package/dist/gene/catalog-sync.js +324 -0
- package/dist/gene/catalog.d.ts +160 -0
- package/dist/gene/catalog.js +433 -0
- package/dist/gene/cli-commands.d.ts +50 -0
- package/dist/gene/cli-commands.js +500 -0
- package/dist/gene/command-report.d.ts +40 -0
- package/dist/gene/command-report.js +246 -0
- package/dist/gene/command.d.ts +29 -0
- package/dist/gene/command.js +561 -0
- package/dist/gene/commit-apply-types.d.ts +13 -0
- package/dist/gene/commit-apply-types.js +1 -0
- package/dist/gene/commit-compound.d.ts +34 -0
- package/dist/gene/commit-compound.js +212 -0
- package/dist/gene/commit-counts.d.ts +41 -0
- package/dist/gene/commit-counts.js +70 -0
- package/dist/gene/commit-exec.d.ts +42 -0
- package/dist/gene/commit-exec.js +134 -0
- package/dist/gene/commit-head.d.ts +52 -0
- package/dist/gene/commit-head.js +97 -0
- package/dist/gene/commit-plan.d.ts +95 -0
- package/dist/gene/commit-plan.js +68 -0
- package/dist/gene/commit-prepare.d.ts +63 -0
- package/dist/gene/commit-prepare.js +159 -0
- package/dist/gene/commit-types.d.ts +234 -0
- package/dist/gene/commit-types.js +3 -0
- package/dist/gene/curator/agent.d.ts +137 -0
- package/dist/gene/curator/agent.js +203 -0
- package/dist/gene/curator/budget.d.ts +69 -0
- package/dist/gene/curator/budget.js +131 -0
- package/dist/gene/curator/conflicts.d.ts +54 -0
- package/dist/gene/curator/conflicts.js +143 -0
- package/dist/gene/curator/curator.d.ts +170 -0
- package/dist/gene/curator/curator.js +617 -0
- package/dist/gene/curator/deps.d.ts +34 -0
- package/dist/gene/curator/deps.js +48 -0
- package/dist/gene/curator/deterministic.d.ts +62 -0
- package/dist/gene/curator/deterministic.js +287 -0
- package/dist/gene/curator/executors.d.ts +36 -0
- package/dist/gene/curator/executors.js +379 -0
- package/dist/gene/curator/lanes.d.ts +52 -0
- package/dist/gene/curator/lanes.js +99 -0
- package/dist/gene/curator/lease.d.ts +76 -0
- package/dist/gene/curator/lease.js +171 -0
- package/dist/gene/curator/library.d.ts +36 -0
- package/dist/gene/curator/library.js +169 -0
- package/dist/gene/curator/lifecycle.d.ts +52 -0
- package/dist/gene/curator/lifecycle.js +109 -0
- package/dist/gene/curator/maintenance.d.ts +71 -0
- package/dist/gene/curator/maintenance.js +213 -0
- package/dist/gene/curator/probation.d.ts +51 -0
- package/dist/gene/curator/probation.js +71 -0
- package/dist/gene/curator/probe.d.ts +131 -0
- package/dist/gene/curator/probe.js +534 -0
- package/dist/gene/curator/prompt.d.ts +18 -0
- package/dist/gene/curator/prompt.js +128 -0
- package/dist/gene/curator/publish.d.ts +64 -0
- package/dist/gene/curator/publish.js +113 -0
- package/dist/gene/curator/recheck.d.ts +55 -0
- package/dist/gene/curator/recheck.js +104 -0
- package/dist/gene/curator/run-events.d.ts +63 -0
- package/dist/gene/curator/run-events.js +55 -0
- package/dist/gene/curator/similarity.d.ts +13 -0
- package/dist/gene/curator/similarity.js +46 -0
- package/dist/gene/curator/switches.d.ts +78 -0
- package/dist/gene/curator/switches.js +146 -0
- package/dist/gene/curator/task-context.d.ts +93 -0
- package/dist/gene/curator/task-context.js +63 -0
- package/dist/gene/curator/task-runner.d.ts +56 -0
- package/dist/gene/curator/task-runner.js +257 -0
- package/dist/gene/curator/tool-support.d.ts +112 -0
- package/dist/gene/curator/tool-support.js +206 -0
- package/dist/gene/curator/toolkit.d.ts +49 -0
- package/dist/gene/curator/toolkit.js +104 -0
- package/dist/gene/curator/tools-read.d.ts +4 -0
- package/dist/gene/curator/tools-read.js +177 -0
- package/dist/gene/curator/tools-release.d.ts +73 -0
- package/dist/gene/curator/tools-release.js +287 -0
- package/dist/gene/curator/tools-verify.d.ts +47 -0
- package/dist/gene/curator/tools-verify.js +243 -0
- package/dist/gene/curator/tools-write.d.ts +26 -0
- package/dist/gene/curator/tools-write.js +434 -0
- package/dist/gene/curator/tools.d.ts +23 -0
- package/dist/gene/curator/tools.js +21 -0
- package/dist/gene/curator/validate/common.d.ts +87 -0
- package/dist/gene/curator/validate/common.js +132 -0
- package/dist/gene/curator/validate/evidence-tokens.d.ts +24 -0
- package/dist/gene/curator/validate/evidence-tokens.js +217 -0
- package/dist/gene/curator/validate/index.d.ts +23 -0
- package/dist/gene/curator/validate/index.js +62 -0
- package/dist/gene/curator/validate/knowledge.d.ts +41 -0
- package/dist/gene/curator/validate/knowledge.js +255 -0
- package/dist/gene/curator/validate/live-check.d.ts +14 -0
- package/dist/gene/curator/validate/live-check.js +150 -0
- package/dist/gene/curator/validate/ports.d.ts +67 -0
- package/dist/gene/curator/validate/ports.js +1 -0
- package/dist/gene/curator/validate/prompts.d.ts +41 -0
- package/dist/gene/curator/validate/prompts.js +165 -0
- package/dist/gene/curator/validate/skill.d.ts +15 -0
- package/dist/gene/curator/validate/skill.js +251 -0
- package/dist/gene/curator/validate/tool.d.ts +6 -0
- package/dist/gene/curator/validate/tool.js +217 -0
- package/dist/gene/curator/validate/types.d.ts +90 -0
- package/dist/gene/curator/validate/types.js +1 -0
- package/dist/gene/curator/validator-ports.d.ts +38 -0
- package/dist/gene/curator/validator-ports.js +29 -0
- package/dist/gene/diag.d.ts +209 -0
- package/dist/gene/diag.js +549 -0
- package/dist/gene/env.d.ts +10 -0
- package/dist/gene/env.js +214 -0
- package/dist/gene/eval-recorder.d.ts +84 -0
- package/dist/gene/eval-recorder.js +222 -0
- package/dist/gene/explain-transport.d.ts +3 -0
- package/dist/gene/explain-transport.js +39 -0
- package/dist/gene/explain.d.ts +96 -0
- package/dist/gene/explain.js +293 -0
- package/dist/gene/fs.d.ts +39 -0
- package/dist/gene/fs.js +139 -0
- package/dist/gene/fsck.d.ts +68 -0
- package/dist/gene/fsck.js +134 -0
- package/dist/gene/gc-library-sweeps.d.ts +9 -0
- package/dist/gene/gc-library-sweeps.js +220 -0
- package/dist/gene/gc-rejected-set.d.ts +15 -0
- package/dist/gene/gc-rejected-set.js +63 -0
- package/dist/gene/gc-safe.d.ts +12 -0
- package/dist/gene/gc-safe.js +74 -0
- package/dist/gene/gc-scope-sweeps.d.ts +18 -0
- package/dist/gene/gc-scope-sweeps.js +297 -0
- package/dist/gene/gc-types.d.ts +55 -0
- package/dist/gene/gc-types.js +26 -0
- package/dist/gene/gc.d.ts +42 -0
- package/dist/gene/gc.js +129 -0
- package/dist/gene/gene-errors.d.ts +23 -0
- package/dist/gene/gene-errors.js +29 -0
- package/dist/gene/hints.d.ts +91 -0
- package/dist/gene/hints.js +394 -0
- package/dist/gene/hub.d.ts +149 -0
- package/dist/gene/hub.js +371 -0
- package/dist/gene/import-plan.d.ts +80 -0
- package/dist/gene/import-plan.js +294 -0
- package/dist/gene/import-proposal.d.ts +23 -0
- package/dist/gene/import-proposal.js +101 -0
- package/dist/gene/import-skill-port.d.ts +6 -0
- package/dist/gene/import-skill-port.js +53 -0
- package/dist/gene/import-sources.d.ts +48 -0
- package/dist/gene/import-sources.js +140 -0
- package/dist/gene/index-writer.d.ts +36 -0
- package/dist/gene/index-writer.js +101 -0
- package/dist/gene/learn/learn-call.d.ts +116 -0
- package/dist/gene/learn/learn-call.js +165 -0
- package/dist/gene/learn/learn-prompt.d.ts +58 -0
- package/dist/gene/learn/learn-prompt.js +254 -0
- package/dist/gene/learn/learner.d.ts +187 -0
- package/dist/gene/learn/learner.js +448 -0
- package/dist/gene/learn/ledger.d.ts +220 -0
- package/dist/gene/learn/ledger.js +394 -0
- package/dist/gene/learn/proposal-build.d.ts +83 -0
- package/dist/gene/learn/proposal-build.js +207 -0
- package/dist/gene/learn/proposal-guard.d.ts +43 -0
- package/dist/gene/learn/proposal-guard.js +37 -0
- package/dist/gene/learn/signals-port.d.ts +47 -0
- package/dist/gene/learn/signals-port.js +86 -0
- package/dist/gene/maintenance-paths.d.ts +7 -0
- package/dist/gene/maintenance-paths.js +20 -0
- package/dist/gene/maintenance-probation.d.ts +33 -0
- package/dist/gene/maintenance-probation.js +127 -0
- package/dist/gene/maintenance-proposals.d.ts +24 -0
- package/dist/gene/maintenance-proposals.js +68 -0
- package/dist/gene/maintenance-runner.d.ts +92 -0
- package/dist/gene/maintenance-runner.js +262 -0
- package/dist/gene/maintenance-tasks.d.ts +37 -0
- package/dist/gene/maintenance-tasks.js +95 -0
- package/dist/gene/manager-actions.d.ts +12 -0
- package/dist/gene/manager-actions.js +279 -0
- package/dist/gene/manager-approve.d.ts +29 -0
- package/dist/gene/manager-approve.js +84 -0
- package/dist/gene/manager-context.d.ts +90 -0
- package/dist/gene/manager-context.js +201 -0
- package/dist/gene/manager-detail.d.ts +17 -0
- package/dist/gene/manager-detail.js +313 -0
- package/dist/gene/manager-gc.d.ts +13 -0
- package/dist/gene/manager-gc.js +81 -0
- package/dist/gene/manager-library.d.ts +39 -0
- package/dist/gene/manager-library.js +90 -0
- package/dist/gene/manager-list.d.ts +27 -0
- package/dist/gene/manager-list.js +170 -0
- package/dist/gene/manager-queue.d.ts +16 -0
- package/dist/gene/manager-queue.js +124 -0
- package/dist/gene/manager-stats.d.ts +28 -0
- package/dist/gene/manager-stats.js +53 -0
- package/dist/gene/manager-view.d.ts +27 -0
- package/dist/gene/manager-view.js +124 -0
- package/dist/gene/manager.d.ts +56 -0
- package/dist/gene/manager.js +179 -0
- package/dist/gene/orphan-scopes.d.ts +37 -0
- package/dist/gene/orphan-scopes.js +150 -0
- package/dist/gene/paths.d.ts +73 -0
- package/dist/gene/paths.js +239 -0
- package/dist/gene/plan-content.d.ts +73 -0
- package/dist/gene/plan-content.js +522 -0
- package/dist/gene/plan-lifecycle.d.ts +29 -0
- package/dist/gene/plan-lifecycle.js +310 -0
- package/dist/gene/policy.d.ts +71 -0
- package/dist/gene/policy.js +313 -0
- package/dist/gene/project-learning.d.ts +25 -0
- package/dist/gene/project-learning.js +54 -0
- package/dist/gene/propagation.d.ts +48 -0
- package/dist/gene/propagation.js +45 -0
- package/dist/gene/queue-lock.d.ts +22 -0
- package/dist/gene/queue-lock.js +99 -0
- package/dist/gene/queue-record.d.ts +57 -0
- package/dist/gene/queue-record.js +145 -0
- package/dist/gene/queue.d.ts +235 -0
- package/dist/gene/queue.js +764 -0
- package/dist/gene/read.d.ts +61 -0
- package/dist/gene/read.js +252 -0
- package/dist/gene/runlog.d.ts +101 -0
- package/dist/gene/runlog.js +404 -0
- package/dist/gene/schema-lite.d.ts +24 -0
- package/dist/gene/schema-lite.js +159 -0
- package/dist/gene/scope-guard.d.ts +23 -0
- package/dist/gene/scope-guard.js +9 -0
- package/dist/gene/scope-lock.d.ts +48 -0
- package/dist/gene/scope-lock.js +222 -0
- package/dist/gene/scope-verify.d.ts +63 -0
- package/dist/gene/scope-verify.js +123 -0
- package/dist/gene/secrets.d.ts +43 -0
- package/dist/gene/secrets.js +161 -0
- package/dist/gene/service-context.d.ts +43 -0
- package/dist/gene/service-context.js +79 -0
- package/dist/gene/service-prepare.d.ts +25 -0
- package/dist/gene/service-prepare.js +219 -0
- package/dist/gene/service-types.d.ts +196 -0
- package/dist/gene/service-types.js +1 -0
- package/dist/gene/service-view.d.ts +41 -0
- package/dist/gene/service-view.js +69 -0
- package/dist/gene/service.d.ts +114 -0
- package/dist/gene/service.js +761 -0
- package/dist/gene/session-start.d.ts +36 -0
- package/dist/gene/session-start.js +212 -0
- package/dist/gene/store-port.d.ts +88 -0
- package/dist/gene/store-port.js +10 -0
- package/dist/gene/store-rows.d.ts +36 -0
- package/dist/gene/store-rows.js +72 -0
- package/dist/gene/store.d.ts +125 -0
- package/dist/gene/store.js +622 -0
- package/dist/gene/tombstones.d.ts +47 -0
- package/dist/gene/tombstones.js +61 -0
- package/dist/gene/tool-runner.d.ts +47 -0
- package/dist/gene/tool-runner.js +154 -0
- package/dist/gene/tool-screen.d.ts +41 -0
- package/dist/gene/tool-screen.js +227 -0
- package/dist/gene/tools.d.ts +112 -0
- package/dist/gene/tools.js +539 -0
- package/dist/gene/transfer.d.ts +85 -0
- package/dist/gene/transfer.js +433 -0
- package/dist/gene/ui-hints.d.ts +15 -0
- package/dist/gene/ui-hints.js +67 -0
- package/dist/gene/usage-fold-cursor.d.ts +24 -0
- package/dist/gene/usage-fold-cursor.js +115 -0
- package/dist/gene/usage-fold.d.ts +49 -0
- package/dist/gene/usage-fold.js +397 -0
- package/dist/gene/usage.d.ts +67 -0
- package/dist/gene/usage.js +231 -0
- package/dist/gene/version-service.d.ts +118 -0
- package/dist/gene/version-service.js +453 -0
- package/dist/gene/wiring-events.d.ts +43 -0
- package/dist/gene/wiring-events.js +113 -0
- package/dist/gene/wiring-models.d.ts +46 -0
- package/dist/gene/wiring-models.js +84 -0
- package/dist/gene/wiring.d.ts +200 -0
- package/dist/gene/wiring.js +764 -0
- package/dist/governance/prompts/orchestrator-block.js +3 -2
- package/dist/host/gene.d.ts +26 -0
- package/dist/host/gene.js +24 -0
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/team/runtime.d.ts +5 -0
- package/dist/team/runtime.js +23 -0
- package/dist/team/subagent.d.ts +34 -0
- package/dist/team/subagent.js +39 -2
- package/dist/tools/index.d.ts +36 -2
- package/dist/tools/index.js +48 -7
- package/package.json +3 -3
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words `/gene` and `aragon gene show` print (gene-bank spec 16.3, 16.4).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`. PURE: facts in, lines out,
|
|
5
|
+
* no manager, no clock, no I/O, so each report is one function a test can call with a literal.
|
|
6
|
+
*
|
|
7
|
+
* A GENE'S TEXT IS SHOWN WITH HIDDEN CONTROL CHARACTERS STRIPPED AND NOTHING ELSE CHANGED
|
|
8
|
+
* (`clean`). This is the person's own library on their own terminal, not the Agent's fenced view,
|
|
9
|
+
* so the entity escaping the prompt block applies would only make the text harder to read; what
|
|
10
|
+
* must not reach a terminal is an escape sequence, and `stripHiddenControls` removes exactly that.
|
|
11
|
+
*/
|
|
12
|
+
import { describeGeneError, pausedReasonCopy, runEventLabel } from '@aragon-agent/tui/model/gene/copy';
|
|
13
|
+
import { stripHiddenControls } from '@aragon-agent/tui/model/gene/escape';
|
|
14
|
+
export function clean(text) {
|
|
15
|
+
return stripHiddenControls(text);
|
|
16
|
+
}
|
|
17
|
+
const onOff = (value) => (value ? 'on' : 'off');
|
|
18
|
+
function libraryLines(view) {
|
|
19
|
+
const lib = view.library;
|
|
20
|
+
const counts = `${lib.knowledge} knowledge, ${lib.tool} tools, ${lib.skill} skills`;
|
|
21
|
+
const lines = [`Library: ${counts}; ${lib.candidates} candidates; ${lib.pinned} pinned`];
|
|
22
|
+
const over = Object.entries(lib.overCap).filter(([, count]) => (count ?? 0) > 0);
|
|
23
|
+
if (over.length > 0) {
|
|
24
|
+
const what = over.map(([type, count]) => `${type} +${count}`).join(', ');
|
|
25
|
+
lines.push(`Over the cap: ${what} (/gene gc archives the overflow)`);
|
|
26
|
+
}
|
|
27
|
+
return lines;
|
|
28
|
+
}
|
|
29
|
+
function contextLine(view) {
|
|
30
|
+
const ctx = view.context;
|
|
31
|
+
if (ctx.stopReason === 'off') {
|
|
32
|
+
return 'This session: genes are not loaded (use is off or the library is empty).';
|
|
33
|
+
}
|
|
34
|
+
const stop = ctx.stopReason === 'exhausted'
|
|
35
|
+
? 'everything relevant fit'
|
|
36
|
+
: `stopped by the ${ctx.stopReason} cap`;
|
|
37
|
+
const items = `${ctx.loadedItems} of ${ctx.budgetItems} genes loaded`;
|
|
38
|
+
const tokens = `${ctx.loadedTokens} of ${ctx.budgetTokens} tokens`;
|
|
39
|
+
return `This session: ${items}, ${tokens} (${stop}).`;
|
|
40
|
+
}
|
|
41
|
+
const HOLDERS = { self: 'this process', other: 'another process', none: 'nobody' };
|
|
42
|
+
function workerLines(view) {
|
|
43
|
+
const { learner, curator } = view;
|
|
44
|
+
const learnerNote = learner.pausedReason ? ` - ${pausedReasonCopy(learner.pausedReason)}` : '';
|
|
45
|
+
const curatorNote = curator.pausedReason ? ` - ${pausedReasonCopy(curator.pausedReason)}` : '';
|
|
46
|
+
const gene = curator.geneName ? ` ${clean(curator.geneName)}` : '';
|
|
47
|
+
const stage = curator.stage === undefined ? '' : `, ${curator.stage}${gene}`;
|
|
48
|
+
return [
|
|
49
|
+
`Learner: ${learner.state}${learnerNote}`,
|
|
50
|
+
`Curator: ${curator.state} (lease held by ${HOLDERS[curator.holder]})${stage}${curatorNote}`,
|
|
51
|
+
`Queue: ${curator.queued} pending, ${curator.claimed} in progress, ${curator.dead} failed`,
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
/** The switch line alone, for a session whose library is not running. */
|
|
55
|
+
export function switchLine(view) {
|
|
56
|
+
return `Gene Bank: use ${onOff(view.use)}, learning ${onOff(view.autoLearn)}`;
|
|
57
|
+
}
|
|
58
|
+
/** One screen of facts: switches, library, this session, learner, curator, queue, budget. */
|
|
59
|
+
/** One line for the current project's learning switch (I3-5); `null` state = no project. */
|
|
60
|
+
export function projectLearningLine(state) {
|
|
61
|
+
if (state === null)
|
|
62
|
+
return null;
|
|
63
|
+
const label = clean(state.label);
|
|
64
|
+
switch (state.source) {
|
|
65
|
+
case 'none':
|
|
66
|
+
return `Project ${label}: learning on`;
|
|
67
|
+
case 'user':
|
|
68
|
+
return `Project ${label}: learning off (your setting; /gene learn on --project to undo)`;
|
|
69
|
+
case 'repo':
|
|
70
|
+
return `Project ${label}: learning off (.aragon/gene.json; edit that file to change it)`;
|
|
71
|
+
case 'unreadable':
|
|
72
|
+
return `Project ${label}: learning off (a policy file is unreadable; fix or remove it, see aragon gene fsck)`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function statusLines(view, facts) {
|
|
76
|
+
const lines = [switchLine(view), ...libraryLines(view), contextLine(view), ...workerLines(view)];
|
|
77
|
+
if (facts.config !== undefined) {
|
|
78
|
+
const budget = facts.config.dailyTokens;
|
|
79
|
+
lines.push(`Tokens: ${facts.tokensToday} of ${budget} used in the last 24 hours.`);
|
|
80
|
+
lines.push(`Holdout: ${facts.config.holdoutPercent}% of runs deliberately skip the library.`);
|
|
81
|
+
}
|
|
82
|
+
if (view.last !== undefined) {
|
|
83
|
+
const detail = view.last.detail ? ` (${clean(view.last.detail)})` : '';
|
|
84
|
+
lines.push(`Last: ${runEventLabel(view.last.ev)}${detail}`);
|
|
85
|
+
}
|
|
86
|
+
lines.push(...(facts.orphanLines ?? []));
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// one gene
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
function toolLines(payload) {
|
|
93
|
+
const exec = payload.exec;
|
|
94
|
+
if (exec === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
const run = exec.kind === 'command'
|
|
97
|
+
? exec.argv.join(' ')
|
|
98
|
+
: exec.kind === 'script'
|
|
99
|
+
? `${exec.interpreter} script`
|
|
100
|
+
: 'composite of built-in tools';
|
|
101
|
+
const permissions = (payload.requiredPermissions ?? []).join(', ') || 'none';
|
|
102
|
+
return [`Runs: ${clean(run)}`, `Risk: ${payload.risk ?? 'unknown'}; permissions: ${permissions}`];
|
|
103
|
+
}
|
|
104
|
+
/** A gene as the transcript and `aragon gene show` print it: tier 2, controls stripped. */
|
|
105
|
+
export function renderGeneDetail(view) {
|
|
106
|
+
const { row, content } = view;
|
|
107
|
+
const facts = [
|
|
108
|
+
`Type: ${row.type}`,
|
|
109
|
+
`scope: ${row.scope.kind}`,
|
|
110
|
+
`status: ${row.status}`,
|
|
111
|
+
`health: ${row.health}`,
|
|
112
|
+
`trust: ${row.trust}`,
|
|
113
|
+
`v${row.version}`,
|
|
114
|
+
];
|
|
115
|
+
const applies = view.applicable.here
|
|
116
|
+
? 'Applies here: yes'
|
|
117
|
+
: `Applies here: no (${view.applicable.reasons.join(' ')})`;
|
|
118
|
+
const lines = [row.line, facts.join('; '), applies];
|
|
119
|
+
if (content.tags.length > 0)
|
|
120
|
+
lines.push(`Tags: ${content.tags.map(clean).join(', ')}`);
|
|
121
|
+
if (row.type === 'tool')
|
|
122
|
+
lines.push(...toolLines(content.payload));
|
|
123
|
+
lines.push('', clean(content.body));
|
|
124
|
+
return lines;
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// stats, packs, gc
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
const pct = (value) => value === null ? 'n/a' : `${Math.round(value * 100)}%`;
|
|
130
|
+
/** The evaluation report: descriptive until there are enough finished runs to compare. */
|
|
131
|
+
export function statsLines(window, s) {
|
|
132
|
+
const kinds = `${s.completed} completed, ${s.errored} errored, ${s.aborted} aborted`;
|
|
133
|
+
const lines = [`Gene Bank evaluation, ${window}: ${s.runs} runs (${kinds})`];
|
|
134
|
+
if (!s.enoughRuns) {
|
|
135
|
+
lines.push('Not enough finished runs yet (20 needed) to compare anything; the figures are descriptive.');
|
|
136
|
+
}
|
|
137
|
+
const ci = s.successCi === null ? '' : ` (${pct(s.successCi[0])} to ${pct(s.successCi[1])})`;
|
|
138
|
+
lines.push(`Success rate: ${pct(s.successRate)}${ci}`);
|
|
139
|
+
const covered = `covered by a gene ${pct(s.coveredRecurrenceRate)}`;
|
|
140
|
+
const uncovered = `not covered ${pct(s.uncoveredRecurrenceRate)}`;
|
|
141
|
+
lines.push(`User corrections: ${pct(s.correctionRate)}`);
|
|
142
|
+
lines.push(`Repeated errors: ${pct(s.recurrenceRate)}`);
|
|
143
|
+
lines.push(`Repeated errors, ${covered}, ${uncovered}`);
|
|
144
|
+
lines.push(`Harmed adoptions: ${pct(s.harmedAdoptionRate)}`);
|
|
145
|
+
const unpriced = s.costHasUnpriced ? ' (some models unpriced)' : '';
|
|
146
|
+
const cost = s.costUsd === null ? 'n/a' : `$${s.costUsd.toFixed(2)}${unpriced}`;
|
|
147
|
+
lines.push(`Cost: ${cost}; learning overhead ${pct(s.learningOverheadShare)}`);
|
|
148
|
+
return lines;
|
|
149
|
+
}
|
|
150
|
+
export function exportSummary(count, file) {
|
|
151
|
+
const zipped = file.toLowerCase().endsWith('.gz') ? ' (gzip)' : '';
|
|
152
|
+
return `Exported ${count} gene(s) to ${file}. The file is plain text${zipped}.`;
|
|
153
|
+
}
|
|
154
|
+
/** What an import did, in the words both `/gene import` and `aragon gene import` use. */
|
|
155
|
+
export function importSummary(r) {
|
|
156
|
+
const skipped = r.skippedExisting + r.skippedForgotten + r.skippedScope;
|
|
157
|
+
const reasons = [
|
|
158
|
+
`${r.skippedExisting} already present`,
|
|
159
|
+
`${r.skippedForgotten} forgotten`,
|
|
160
|
+
`${r.skippedScope} not importable`,
|
|
161
|
+
].join(', ');
|
|
162
|
+
const demoted = r.demoted > 0 ? `; ${r.demoted} oversight gene(s) demoted to standard` : '';
|
|
163
|
+
const head = `Imported ${r.imported} of ${r.total} gene(s) as candidates`;
|
|
164
|
+
return `${head} (skipped ${skipped}: ${reasons})${demoted}.`;
|
|
165
|
+
}
|
|
166
|
+
export function gcSummary(r) {
|
|
167
|
+
const entries = r.trashPurged === 1 ? 'entry' : 'entries';
|
|
168
|
+
const aged = `${r.queuePruned} queue file(s), ${r.runsPruned} run log(s) and ` +
|
|
169
|
+
`${r.evalPruned} eval file(s)`;
|
|
170
|
+
return (`Reclaimed: ${r.archived} gene(s) archived to meet the cap; ` +
|
|
171
|
+
`${r.trashPurged} trash ${entries}, ${aged} aged out.`);
|
|
172
|
+
}
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
// cold-start import
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
const SKIP_WORDS = {
|
|
177
|
+
secret: 'looks like it holds a secret',
|
|
178
|
+
injection: 'reads like instructions to an Agent',
|
|
179
|
+
too_long: 'too long to carry as evidence',
|
|
180
|
+
disabled: 'switched off',
|
|
181
|
+
empty: 'empty',
|
|
182
|
+
unreadable: 'unreadable',
|
|
183
|
+
already_imported: 'already imported',
|
|
184
|
+
forgotten: 'you chose never to learn it',
|
|
185
|
+
project_excluded: 'learning is switched off for this project',
|
|
186
|
+
};
|
|
187
|
+
function skipLines(skipped) {
|
|
188
|
+
return Object.keys(SKIP_WORDS)
|
|
189
|
+
.filter((reason) => (skipped[reason] ?? 0) > 0)
|
|
190
|
+
.map((reason) => ` skipped ${skipped[reason]}: ${SKIP_WORDS[reason]}`);
|
|
191
|
+
}
|
|
192
|
+
const WHAT = { memory: 'memory notes', skills: 'installed skills' };
|
|
193
|
+
/** The dry run: what a commit would queue, what it would leave out, and where the text goes. */
|
|
194
|
+
export function importPreviewLines(preview, command) {
|
|
195
|
+
const lines = [`Import preview: ${WHAT[preview.source]}`];
|
|
196
|
+
const found = `${preview.eligible} eligible, ${preview.willQueue} would be queued`;
|
|
197
|
+
lines.push(` ${found} (about ${preview.estimatedTokens} tokens of drafting and checking)`);
|
|
198
|
+
if (preview.leftForLater > 0) {
|
|
199
|
+
lines.push(` left for next time: ${preview.leftForLater} (count, queue room or token allowance)`);
|
|
200
|
+
}
|
|
201
|
+
lines.push(...skipLines(preview.skipped));
|
|
202
|
+
if (preview.budget.exceeded) {
|
|
203
|
+
const share = `${preview.budget.allowed} of ${preview.budget.remaining} remaining tokens today`;
|
|
204
|
+
lines.push(` token allowance reached: an import may use half of what is left (${share})`);
|
|
205
|
+
}
|
|
206
|
+
for (const title of preview.titles)
|
|
207
|
+
lines.push(` - ${clean(title)}`);
|
|
208
|
+
if (preview.willQueue === 0) {
|
|
209
|
+
lines.push('Nothing to queue.');
|
|
210
|
+
return lines;
|
|
211
|
+
}
|
|
212
|
+
const where = preview.provider === null
|
|
213
|
+
? 'No fast model is configured, so nothing is drafted until one is.'
|
|
214
|
+
: `The selected text will be sent to your fast model (${clean(preview.provider)}) to draft English genes.`;
|
|
215
|
+
lines.push(where);
|
|
216
|
+
lines.push('Imports are candidates: they are checked first and no Agent sees them until published.');
|
|
217
|
+
lines.push(`Run \`${command} --yes\` to queue them.`);
|
|
218
|
+
return lines;
|
|
219
|
+
}
|
|
220
|
+
export function importOutcomeLine(outcome) {
|
|
221
|
+
const parts = [`Queued ${outcome.queued} item(s) for drafting`];
|
|
222
|
+
if (outcome.merged > 0)
|
|
223
|
+
parts.push(`${outcome.merged} folded into pending requests`);
|
|
224
|
+
if (outcome.changed > 0)
|
|
225
|
+
parts.push(`${outcome.changed} changed since the preview and skipped`);
|
|
226
|
+
if (outcome.leftForLater > 0)
|
|
227
|
+
parts.push(`${outcome.leftForLater} left for next time`);
|
|
228
|
+
if (outcome.failed > 0)
|
|
229
|
+
parts.push(`${outcome.failed} could not be queued`);
|
|
230
|
+
return `${parts.join('; ')}. Follow progress with /gene queue or Ctrl+Q.`;
|
|
231
|
+
}
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
// explain
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
const EXPLAIN_DETAIL_COPY = {
|
|
236
|
+
explain_no_fast_model: 'No fast model is configured, so there is nothing to translate with. Set one with /fast model <id>.',
|
|
237
|
+
explain_timeout: 'The fast model did not answer in time. Try again.',
|
|
238
|
+
explain_unfaithful: 'The translation did not keep the original file names, codes or numbers, so it was discarded. Try again.',
|
|
239
|
+
explain_failed: 'The fast model could not translate this gene. Try again.',
|
|
240
|
+
lang_unsupported: 'Only Chinese (zh) and the original English (en) are available.',
|
|
241
|
+
};
|
|
242
|
+
/** One line for a refused explanation: the specific reason when the engine gave one. */
|
|
243
|
+
export function explainFailureLine(failure) {
|
|
244
|
+
const specific = failure.detail === undefined ? undefined : EXPLAIN_DETAIL_COPY[failure.detail];
|
|
245
|
+
return specific ?? describeGeneError(failure.code, failure.detail);
|
|
246
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GeneControlPort } from '@aragon-agent/tui/model/gene/port';
|
|
2
|
+
import type { CommandContext, CommandRegistry } from '../commands/registry.js';
|
|
3
|
+
import { renderGeneDetail } from './command-report.js';
|
|
4
|
+
import type { GeneManager } from './manager.js';
|
|
5
|
+
export { renderGeneDetail };
|
|
6
|
+
/** Where the overlay can open. */
|
|
7
|
+
export type GeneManagerPage = 'list' | 'candidates' | 'queue' | 'activity' | 'stats';
|
|
8
|
+
/** What `/gene` needs from the app (supplied on `CommandContext.gene`). */
|
|
9
|
+
export interface GeneCommandHost {
|
|
10
|
+
/** The manager over this session's library. */
|
|
11
|
+
manager: GeneManager;
|
|
12
|
+
/** The live status and the curator switch. */
|
|
13
|
+
control: Pick<GeneControlPort, 'getView' | 'curator'>;
|
|
14
|
+
/** Persist `gene.use` and apply it to this session at once (spec 16.8 `setGeneConfig`). */
|
|
15
|
+
setUse(value: boolean): void;
|
|
16
|
+
/** Persist `gene.autoLearn` and apply it to this session at once. */
|
|
17
|
+
setAutoLearn(value: boolean): void;
|
|
18
|
+
/** Open the manager overlay on a page. */
|
|
19
|
+
openManager(page?: GeneManagerPage): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const GENE_DISABLED_COPY: string;
|
|
22
|
+
export declare const GENE_UNAVAILABLE_COPY = "The gene library is not available in this session (headless, print mode or a sub-agent).";
|
|
23
|
+
export declare function registerGeneCommands(registry: CommandRegistry): void;
|
|
24
|
+
/** The text of `/gene help`: generated from the table, so it cannot drift from the handlers. */
|
|
25
|
+
export declare const GENE_HELP: string;
|
|
26
|
+
/** Every word the dispatcher answers (tests assert the help names each one). */
|
|
27
|
+
export declare const GENE_SUBCOMMAND_WORDS: readonly string[];
|
|
28
|
+
/** The dispatcher: `enabled=false` is answered BEFORE any subcommand, `help` before the host. */
|
|
29
|
+
export declare function runGeneCommand(ctx: CommandContext): Promise<void>;
|