@yaag/extension 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/run-call-body.ts +47 -0
- package/src/run-tool.ts +3 -11
- package/src/run-tree-component.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaag/extension",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@earendil-works/pi-tui": "^0.84.0",
|
|
27
|
-
"@yaag/cli": "0.5.
|
|
28
|
-
"@yaag/runtime": "0.5.
|
|
29
|
-
"@yaag/tui": "0.5.
|
|
27
|
+
"@yaag/cli": "0.5.2",
|
|
28
|
+
"@yaag/runtime": "0.5.2",
|
|
29
|
+
"@yaag/tui": "0.5.2",
|
|
30
30
|
"nanoid": "^6.0.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text of one `yaag_run` call, as the transcript shows it: the call head,
|
|
3
|
+
* and under it either the Inline Program source or the hint that names the key
|
|
4
|
+
* which shows that source.
|
|
5
|
+
*/
|
|
6
|
+
import { keyText, type Theme } from "@earendil-works/pi-coding-agent";
|
|
7
|
+
import { type ProgramParams, programExpansion, programLabel } from "./run-program-param.ts";
|
|
8
|
+
|
|
9
|
+
/** What the call render needs: the call itself, its styling, and its state. */
|
|
10
|
+
export interface CallBodyOptions {
|
|
11
|
+
readonly params: ProgramParams;
|
|
12
|
+
readonly theme: Theme;
|
|
13
|
+
/** True while pi shows the call expanded, where the source replaces the hint. */
|
|
14
|
+
readonly expanded: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The head alone, the head over the program source, or the head over the expand
|
|
19
|
+
* hint. A call with no source to show gets no hint, because the hint would
|
|
20
|
+
* promise an empty view.
|
|
21
|
+
*/
|
|
22
|
+
export function callBody(options: CallBodyOptions): string {
|
|
23
|
+
const { params, theme } = options;
|
|
24
|
+
const head =
|
|
25
|
+
theme.fg("toolTitle", theme.bold("yaag_run")) + theme.fg("muted", `(${programLabel(params)})`);
|
|
26
|
+
const expansion = programExpansion(params);
|
|
27
|
+
if (expansion === "") return head;
|
|
28
|
+
if (options.expanded) return `${head}\n${theme.fg("muted", expansion)}`;
|
|
29
|
+
const hint = expandHint(theme);
|
|
30
|
+
return hint === "" ? head : `${head}\n${hint}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The muted second line that tells the reader which key shows the program
|
|
35
|
+
* source. It reads the bound key, so a rebound keymap stays correct, and it is
|
|
36
|
+
* empty when the action has no key at all, because a hint that names no key
|
|
37
|
+
* tells the reader nothing.
|
|
38
|
+
*
|
|
39
|
+
* The caller's `Theme` styles the whole line `muted`. pi's own `keyHint` (pi
|
|
40
|
+
* `docs/extensions.md`, keybinding hints) styles the key `dim` and the
|
|
41
|
+
* description `muted` from a module-global theme instead, which a Host Session
|
|
42
|
+
* installs but a test does not.
|
|
43
|
+
*/
|
|
44
|
+
function expandHint(theme: Theme): string {
|
|
45
|
+
const key = keyText("app.tools.expand");
|
|
46
|
+
return key === "" ? "" : theme.fg("muted", `... (${key} to expand)`);
|
|
47
|
+
}
|
package/src/run-tool.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Text } from "@earendil-works/pi-tui";
|
|
|
4
4
|
import { initialSummary } from "@yaag/runtime";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
6
|
import { type BackgroundStatus, createBackgroundStatus } from "./background-status.ts";
|
|
7
|
+
import { callBody } from "./run-call-body.ts";
|
|
7
8
|
import type { RunDetails } from "./run-details.ts";
|
|
8
9
|
import { foregroundInline, foregroundResult, inlineAvailable } from "./run-foreground.ts";
|
|
9
10
|
import { RunTreeComponent } from "./run-tree-component.ts";
|
|
@@ -15,12 +16,7 @@ import { type ProcessIdentity, readProcessStart } from "./process-liveness.ts";
|
|
|
15
16
|
import { resolveProgramParams } from "./resume-source.ts";
|
|
16
17
|
import type { ProgramTarget } from "./run-argv.ts";
|
|
17
18
|
import { mintRunId } from "./run-id.ts";
|
|
18
|
-
import {
|
|
19
|
-
confirmProgramTarget,
|
|
20
|
-
programExpansion,
|
|
21
|
-
programLabel,
|
|
22
|
-
programTarget,
|
|
23
|
-
} from "./run-program-param.ts";
|
|
19
|
+
import { confirmProgramTarget, programTarget } from "./run-program-param.ts";
|
|
24
20
|
import type { RunLaunch } from "./run-record.ts";
|
|
25
21
|
import type { LiveRun, RunRegistry, RunSettlement } from "./run-registry.ts";
|
|
26
22
|
import { errorText, failure, observedSettlement } from "./run-settlement.ts";
|
|
@@ -137,11 +133,7 @@ export function createRunTool(deps: RunToolOptions): ToolDefinition<typeof param
|
|
|
137
133
|
renderCall(params, theme, context) {
|
|
138
134
|
const text =
|
|
139
135
|
context.lastComponent instanceof Text ? context.lastComponent : new Text("", 0, 0);
|
|
140
|
-
|
|
141
|
-
theme.fg("toolTitle", theme.bold("yaag_run")) +
|
|
142
|
-
theme.fg("muted", `(${programLabel(params)})`);
|
|
143
|
-
const body = context.expanded ? programExpansion(params) : "";
|
|
144
|
-
text.setText(body === "" ? head : `${head}\n${theme.fg("muted", body)}`);
|
|
136
|
+
text.setText(callBody({ params, theme, expanded: context.expanded }));
|
|
145
137
|
return text;
|
|
146
138
|
},
|
|
147
139
|
renderResult(result, _options, _theme, context) {
|
|
@@ -37,12 +37,17 @@ export class RunTreeComponent {
|
|
|
37
37
|
this.#state.ingest(details);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Renders the header, the tree and the Result region once the Run settled.
|
|
42
|
+
* It draws no key footer, and no ruled tree band when the Run spawned no
|
|
43
|
+
* Agent, because this surface takes no input.
|
|
44
|
+
*/
|
|
41
45
|
render(width: number): string[] {
|
|
42
46
|
const id = this.#state.runId;
|
|
43
47
|
return renderTree(this.#state, {
|
|
44
48
|
now: this.#now(),
|
|
45
49
|
width,
|
|
50
|
+
interactive: false,
|
|
46
51
|
...(id === undefined ? {} : { label: id }),
|
|
47
52
|
}).map((line) => truncateToWidth(line, width));
|
|
48
53
|
}
|