@valni/cli-darwin-x64 0.1.2 → 0.1.4
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/LICENSE +1 -2
- package/package.json +1 -1
- package/runtime/LICENSE +1 -2
- package/runtime/examples/extensions/auto-commit-on-exit.ts +6 -6
- package/runtime/examples/extensions/bash-spawn-hook.ts +3 -3
- package/runtime/examples/extensions/bookmark.ts +5 -5
- package/runtime/examples/extensions/border-status-editor.ts +7 -7
- package/runtime/examples/extensions/built-in-tool-renderer.ts +6 -6
- package/runtime/examples/extensions/claude-rules.ts +4 -4
- package/runtime/examples/extensions/commands.ts +5 -5
- package/runtime/examples/extensions/confirm-destructive.ts +3 -3
- package/runtime/examples/extensions/custom-footer.ts +2 -2
- package/runtime/examples/extensions/custom-header.ts +5 -5
- package/runtime/examples/extensions/custom-provider-anthropic/index.ts +4 -4
- package/runtime/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
- package/runtime/examples/extensions/custom-provider-anthropic/package.json +3 -3
- package/runtime/examples/extensions/dirty-repo-guard.ts +7 -7
- package/runtime/examples/extensions/doom-overlay/doom/build.sh +4 -4
- package/runtime/examples/extensions/doom-overlay/doom/{doomgeneric_pi.c → doomgeneric_valni.c} +1 -1
- package/runtime/examples/extensions/doom-overlay/index.ts +3 -3
- package/runtime/examples/extensions/dynamic-resources/dynamic.json +0 -1
- package/runtime/examples/extensions/dynamic-resources/index.ts +2 -4
- package/runtime/examples/extensions/dynamic-tools.ts +4 -4
- package/runtime/examples/extensions/entry-renderer.ts +6 -6
- package/runtime/examples/extensions/event-bus.ts +8 -8
- package/runtime/examples/extensions/file-trigger.ts +3 -3
- package/runtime/examples/extensions/git-checkpoint.ts +7 -7
- package/runtime/examples/extensions/git-merge-and-resolve.ts +14 -14
- package/runtime/examples/extensions/github-issue-autocomplete.ts +6 -6
- package/runtime/examples/extensions/hello.ts +2 -2
- package/runtime/examples/extensions/hidden-thinking-label.ts +4 -4
- package/runtime/examples/extensions/inline-bash.ts +5 -5
- package/runtime/examples/extensions/input-transform-streaming.ts +5 -5
- package/runtime/examples/extensions/input-transform.ts +5 -5
- package/runtime/examples/extensions/interactive-shell.ts +3 -3
- package/runtime/examples/extensions/mac-system-theme.ts +5 -5
- package/runtime/examples/extensions/message-renderer.ts +4 -4
- package/runtime/examples/extensions/minimal-mode.ts +9 -9
- package/runtime/examples/extensions/modal-editor.ts +3 -3
- package/runtime/examples/extensions/model-status.ts +3 -3
- package/runtime/examples/extensions/notify.ts +5 -5
- package/runtime/examples/extensions/overlay-qa-tests.ts +20 -20
- package/runtime/examples/extensions/overlay-test.ts +3 -3
- package/runtime/examples/extensions/permission-gate.ts +2 -2
- package/runtime/examples/extensions/pirate.ts +4 -4
- package/runtime/examples/extensions/plan-mode/index.ts +21 -21
- package/runtime/examples/extensions/preset.ts +26 -26
- package/runtime/examples/extensions/project-trust.ts +7 -7
- package/runtime/examples/extensions/prompt-customizer.ts +3 -3
- package/runtime/examples/extensions/protected-paths.ts +2 -2
- package/runtime/examples/extensions/provider-payload.ts +3 -3
- package/runtime/examples/extensions/question.ts +2 -2
- package/runtime/examples/extensions/questionnaire.ts +2 -2
- package/runtime/examples/extensions/rainbow-editor.ts +3 -3
- package/runtime/examples/extensions/reload-runtime.ts +4 -4
- package/runtime/examples/extensions/rpc-demo.ts +10 -10
- package/runtime/examples/extensions/sandbox/index.ts +15 -15
- package/runtime/examples/extensions/sandbox/package-lock.json +4 -4
- package/runtime/examples/extensions/sandbox/package.json +3 -3
- package/runtime/examples/extensions/send-user-message.ts +13 -13
- package/runtime/examples/extensions/session-name.ts +4 -4
- package/runtime/examples/extensions/shutdown-command.ts +10 -10
- package/runtime/examples/extensions/snake.ts +3 -3
- package/runtime/examples/extensions/space-invaders.ts +3 -3
- package/runtime/examples/extensions/ssh.ts +12 -12
- package/runtime/examples/extensions/status-line.ts +4 -4
- package/runtime/examples/extensions/structured-output.ts +2 -2
- package/runtime/examples/extensions/subagent/index.ts +5 -5
- package/runtime/examples/extensions/system-prompt-header.ts +3 -3
- package/runtime/examples/extensions/tic-tac-toe.ts +15 -15
- package/runtime/examples/extensions/timed-confirm.ts +4 -4
- package/runtime/examples/extensions/titlebar-spinner.ts +11 -11
- package/runtime/examples/extensions/todo.ts +5 -5
- package/runtime/examples/extensions/tool-override.ts +5 -5
- package/runtime/examples/extensions/tools.ts +10 -10
- package/runtime/examples/extensions/trigger-compact.ts +3 -3
- package/runtime/examples/extensions/truncated-tool.ts +3 -3
- package/runtime/examples/extensions/widget-placement.ts +2 -2
- package/runtime/examples/extensions/with-deps/index.ts +2 -2
- package/runtime/examples/extensions/with-deps/package-lock.json +4 -4
- package/runtime/examples/extensions/with-deps/package.json +3 -3
- package/runtime/examples/extensions/working-indicator.ts +7 -7
- package/runtime/examples/extensions/working-message-test.ts +3 -3
- package/runtime/examples/sdk/01-minimal.ts +1 -1
- package/runtime/examples/sdk/03-custom-prompt.ts +1 -1
- package/runtime/examples/sdk/04-skills.ts +1 -1
- package/runtime/examples/sdk/05-tools.ts +1 -1
- package/runtime/examples/sdk/06-extensions.ts +11 -11
- package/runtime/examples/sdk/08-prompt-templates.ts +1 -1
- package/runtime/export-html/template.js +3 -3
- package/runtime/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/runtime/package.json +8 -14
- package/runtime/theme/dark.json +0 -1
- package/runtime/theme/light.json +0 -1
- package/runtime/theme/theme-schema.json +2 -2
- package/runtime/valni +2 -2
- package/runtime/README.md +0 -674
- package/runtime/docs/extensions.md +0 -2910
- package/runtime/docs/json.md +0 -82
- package/runtime/docs/models.md +0 -540
- package/runtime/docs/packages.md +0 -228
- package/runtime/docs/rpc.md +0 -1480
- package/runtime/docs/sdk.md +0 -1183
- package/runtime/docs/session-format.md +0 -422
- package/runtime/docs/settings.md +0 -315
- package/runtime/docs/shell-aliases.md +0 -13
- package/runtime/docs/terminal-setup.md +0 -142
- package/runtime/docs/termux.md +0 -127
- package/runtime/docs/tmux.md +0 -63
- package/runtime/docs/tui.md +0 -927
- package/runtime/docs/windows.md +0 -17
- package/runtime/examples/README.md +0 -25
- package/runtime/examples/extensions/README.md +0 -212
- package/runtime/examples/extensions/doom-overlay/README.md +0 -46
- package/runtime/examples/extensions/dynamic-resources/SKILL.md +0 -8
- package/runtime/examples/extensions/dynamic-resources/dynamic.md +0 -5
- package/runtime/examples/extensions/gondolin/index.ts +0 -531
- package/runtime/examples/extensions/gondolin/package-lock.json +0 -185
- package/runtime/examples/extensions/gondolin/package.json +0 -19
- package/runtime/examples/extensions/plan-mode/README.md +0 -66
- package/runtime/examples/extensions/subagent/README.md +0 -175
- package/runtime/examples/extensions/subagent/agents/planner.md +0 -37
- package/runtime/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/runtime/examples/extensions/subagent/agents/scout.md +0 -50
- package/runtime/examples/extensions/subagent/agents/worker.md +0 -24
- package/runtime/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/runtime/examples/extensions/subagent/prompts/implement.md +0 -10
- package/runtime/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- package/runtime/examples/sdk/README.md +0 -140
- package/runtime/node_modules/@mariozechner/clipboard/.yarnrc.yml +0 -1
- package/runtime/node_modules/@mariozechner/clipboard/Cargo.toml +0 -45
- package/runtime/node_modules/@mariozechner/clipboard/README.md +0 -60
- package/runtime/node_modules/@mariozechner/clipboard/build.rs +0 -5
- package/runtime/node_modules/@mariozechner/clipboard/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard/exp.ts +0 -12
- package/runtime/node_modules/@mariozechner/clipboard/index.js +0 -606
- package/runtime/node_modules/@mariozechner/clipboard/package.json +0 -56
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/common.rs +0 -307
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/mod.rs +0 -93
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/ios.rs +0 -313
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/macos.rs +0 -471
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/mod.rs +0 -252
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/wayland.rs +0 -431
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/win.rs +0 -712
- package/runtime/node_modules/@mariozechner/clipboard/src/clipboard_rs/platform/x11.rs +0 -916
- package/runtime/node_modules/@mariozechner/clipboard/src/lib.rs +0 -194
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/README.md +0 -3
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/clipboard.darwin-x64.node +0 -0
- package/runtime/node_modules/@mariozechner/clipboard-darwin-x64/package.json +0 -22
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inter-extension event bus example.
|
|
3
3
|
*
|
|
4
|
-
* Shows
|
|
4
|
+
* Shows valni.events for communication between extensions. One extension
|
|
5
5
|
* can emit events that other extensions listen to.
|
|
6
6
|
*
|
|
7
7
|
* Usage: /emit [event-name] [data] - emit an event on the bus
|
|
@@ -9,33 +9,33 @@
|
|
|
9
9
|
|
|
10
10
|
import type { ExtensionAPI, ExtensionContext } from "@valni/cli";
|
|
11
11
|
|
|
12
|
-
export default function (
|
|
12
|
+
export default function (valni: ExtensionAPI) {
|
|
13
13
|
// Store ctx for use in event handler
|
|
14
14
|
let currentCtx: ExtensionContext | undefined;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
17
17
|
currentCtx = ctx;
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
// Listen for events from other extensions
|
|
21
|
-
|
|
21
|
+
valni.events.on("my:notification", (data) => {
|
|
22
22
|
const { message, from } = data as { message: string; from: string };
|
|
23
23
|
currentCtx?.ui.notify(`Event from ${from}: ${message}`, "info");
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// Command to emit events (emits "my:notification" which the listener above receives)
|
|
27
|
-
|
|
27
|
+
valni.registerCommand("emit", {
|
|
28
28
|
description: "Emit my:notification event (usage: /emit message)",
|
|
29
29
|
handler: async (args, _ctx) => {
|
|
30
30
|
const message = args.trim() || "hello";
|
|
31
|
-
|
|
31
|
+
valni.events.emit("my:notification", { message, from: "/emit command" });
|
|
32
32
|
// Listener above will show the notification
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
// Example: emit on session start
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
valni.on("session_start", async () => {
|
|
38
|
+
valni.events.emit("my:notification", {
|
|
39
39
|
message: "Session started",
|
|
40
40
|
from: "event-bus-example",
|
|
41
41
|
});
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
import * as fs from "node:fs";
|
|
12
12
|
import type { ExtensionAPI } from "@valni/cli";
|
|
13
13
|
|
|
14
|
-
export default function (
|
|
15
|
-
|
|
14
|
+
export default function (valni: ExtensionAPI) {
|
|
15
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
16
16
|
const triggerFile = "/tmp/agent-trigger.txt";
|
|
17
17
|
|
|
18
18
|
fs.watch(triggerFile, () => {
|
|
19
19
|
try {
|
|
20
20
|
const content = fs.readFileSync(triggerFile, "utf-8").trim();
|
|
21
21
|
if (content) {
|
|
22
|
-
|
|
22
|
+
valni.sendMessage(
|
|
23
23
|
{
|
|
24
24
|
customType: "file-trigger",
|
|
25
25
|
content: `External trigger: ${content}`,
|
|
@@ -7,26 +7,26 @@
|
|
|
7
7
|
|
|
8
8
|
import type { ExtensionAPI } from "@valni/cli";
|
|
9
9
|
|
|
10
|
-
export default function (
|
|
10
|
+
export default function (valni: ExtensionAPI) {
|
|
11
11
|
const checkpoints = new Map<string, string>();
|
|
12
12
|
let currentEntryId: string | undefined;
|
|
13
13
|
|
|
14
14
|
// Track the current entry ID when user messages are saved
|
|
15
|
-
|
|
15
|
+
valni.on("tool_result", async (_event, ctx) => {
|
|
16
16
|
const leaf = ctx.sessionManager.getLeafEntry();
|
|
17
17
|
if (leaf) currentEntryId = leaf.id;
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
valni.on("turn_start", async () => {
|
|
21
21
|
// Create a git stash entry before LLM makes changes
|
|
22
|
-
const { stdout } = await
|
|
22
|
+
const { stdout } = await valni.exec("git", ["stash", "create"]);
|
|
23
23
|
const ref = stdout.trim();
|
|
24
24
|
if (ref && currentEntryId) {
|
|
25
25
|
checkpoints.set(currentEntryId, ref);
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
valni.on("session_before_fork", async (event, ctx) => {
|
|
30
30
|
const ref = checkpoints.get(event.entryId);
|
|
31
31
|
if (!ref) return;
|
|
32
32
|
|
|
@@ -41,12 +41,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
41
41
|
]);
|
|
42
42
|
|
|
43
43
|
if (choice?.startsWith("Yes")) {
|
|
44
|
-
await
|
|
44
|
+
await valni.exec("git", ["stash", "apply", ref]);
|
|
45
45
|
ctx.ui.notify("Code restored to checkpoint", "info");
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
valni.on("agent_end", async () => {
|
|
50
50
|
// Clear checkpoints after agent completes
|
|
51
51
|
checkpoints.clear();
|
|
52
52
|
});
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* with file, line range, and ours/theirs sections so it can resolve them.
|
|
9
9
|
* Also re-sends unresolved conflicts from a previous incomplete merge.
|
|
10
10
|
*
|
|
11
|
-
* Start
|
|
12
|
-
*
|
|
11
|
+
* Start valni with this extension:
|
|
12
|
+
* valni -e ./examples/extensions/git-merge-and-resolve.ts
|
|
13
13
|
*/
|
|
14
14
|
import { createReadStream } from "node:fs";
|
|
15
15
|
import { join } from "node:path";
|
|
@@ -24,8 +24,8 @@ interface ConflictBlock {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** Parse conflict markers from working tree files with unmerged paths. */
|
|
27
|
-
async function findConflicts(
|
|
28
|
-
const { stdout, code } = await
|
|
27
|
+
async function findConflicts(valni: ExtensionAPI, cwd: string): Promise<ConflictBlock[]> {
|
|
28
|
+
const { stdout, code } = await valni.exec("git", ["diff", "--name-only", "--diff-filter=U"]);
|
|
29
29
|
if (code !== 0 || !stdout.trim()) return [];
|
|
30
30
|
|
|
31
31
|
const blocks: ConflictBlock[] = [];
|
|
@@ -70,21 +70,21 @@ function formatConflicts(ref: string, blocks: ConflictBlock[]): string {
|
|
|
70
70
|
return lines.join("\n");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
export default function (
|
|
74
|
-
|
|
75
|
-
const { code: revParseCode } = await
|
|
73
|
+
export default function (valni: ExtensionAPI) {
|
|
74
|
+
valni.on("agent_end", async (_event, ctx) => {
|
|
75
|
+
const { code: revParseCode } = await valni.exec("git", ["rev-parse", "--git-dir"]);
|
|
76
76
|
if (revParseCode !== 0) return;
|
|
77
77
|
|
|
78
78
|
let ref = "MERGE_HEAD";
|
|
79
79
|
|
|
80
80
|
// If not already in a merge, attempt one
|
|
81
|
-
const { code: mergeHeadCode } = await
|
|
81
|
+
const { code: mergeHeadCode } = await valni.exec("git", ["rev-parse", "MERGE_HEAD"]);
|
|
82
82
|
if (mergeHeadCode !== 0) {
|
|
83
83
|
// Only attempt a new merge if the working tree is clean
|
|
84
|
-
const { stdout: status } = await
|
|
84
|
+
const { stdout: status } = await valni.exec("git", ["status", "--porcelain"]);
|
|
85
85
|
if (status.trim()) return;
|
|
86
86
|
|
|
87
|
-
const { stdout: upstream, code: upstreamCode } = await
|
|
87
|
+
const { stdout: upstream, code: upstreamCode } = await valni.exec("git", [
|
|
88
88
|
"rev-parse",
|
|
89
89
|
"--abbrev-ref",
|
|
90
90
|
"--symbolic-full-name",
|
|
@@ -96,20 +96,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
96
96
|
const remote = ref.split("/")[0];
|
|
97
97
|
ctx.ui.notify(`git-merge-and-resolve: fetching ${remote}, merging ${ref}`, "info");
|
|
98
98
|
|
|
99
|
-
const { code: fetchCode, stderr: fetchErr } = await
|
|
99
|
+
const { code: fetchCode, stderr: fetchErr } = await valni.exec("git", ["fetch", remote]);
|
|
100
100
|
if (fetchCode !== 0) {
|
|
101
101
|
ctx.ui.notify(`git-merge-and-resolve: fetch failed: ${fetchErr.trim()}`, "warning");
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
const { code: mergeCode } = await
|
|
105
|
+
const { code: mergeCode } = await valni.exec("git", ["merge", "--no-ff", ref]);
|
|
106
106
|
if (mergeCode === 0) return;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// Either we just merged with conflicts, or we were already in an unfinished merge
|
|
110
|
-
const conflicts = await findConflicts(
|
|
110
|
+
const conflicts = await findConflicts(valni, ctx.cwd);
|
|
111
111
|
if (conflicts.length === 0) return;
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
valni.sendUserMessage(formatConflicts(ref, conflicts), { deliverAs: "followUp" });
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -39,8 +39,8 @@ function parseGitHubRepo(remoteUrl: string): string | undefined {
|
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async function resolveGitHubRepo(
|
|
43
|
-
const result = await
|
|
42
|
+
async function resolveGitHubRepo(valni: ExtensionAPI, cwd: string): Promise<RepoResolution> {
|
|
43
|
+
const result = await valni.exec("git", ["remote", "-v"], { cwd, timeout: 5_000 });
|
|
44
44
|
if (result.code !== 0) {
|
|
45
45
|
return { ok: false, error: "github-issue-autocomplete: cwd is not a git repository" };
|
|
46
46
|
}
|
|
@@ -127,9 +127,9 @@ function createIssueAutocompleteProvider(
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
export default function (
|
|
131
|
-
|
|
132
|
-
const resolvedRepo = await resolveGitHubRepo(
|
|
130
|
+
export default function (valni: ExtensionAPI): void {
|
|
131
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
132
|
+
const resolvedRepo = await resolveGitHubRepo(valni, ctx.cwd);
|
|
133
133
|
if (!resolvedRepo.ok) {
|
|
134
134
|
ctx.ui.notify(resolvedRepo.error, "error");
|
|
135
135
|
return;
|
|
@@ -141,7 +141,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
141
141
|
|
|
142
142
|
const getIssues = async (): Promise<GitHubIssue[] | undefined> => {
|
|
143
143
|
issuesPromise ||= (async () => {
|
|
144
|
-
const result = await
|
|
144
|
+
const result = await valni.exec(
|
|
145
145
|
"gh",
|
|
146
146
|
[
|
|
147
147
|
"issue",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* when thinking blocks are hidden.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
|
-
*
|
|
8
|
+
* valni --extension examples/extensions/hidden-thinking-label.ts
|
|
9
9
|
*
|
|
10
10
|
* Test:
|
|
11
11
|
* 1. Load this extension
|
|
@@ -22,18 +22,18 @@ import type { ExtensionAPI, ExtensionContext } from "@valni/cli";
|
|
|
22
22
|
|
|
23
23
|
const DEFAULT_LABEL = "Pondering...";
|
|
24
24
|
|
|
25
|
-
export default function (
|
|
25
|
+
export default function (valni: ExtensionAPI) {
|
|
26
26
|
let label = DEFAULT_LABEL;
|
|
27
27
|
|
|
28
28
|
const applyLabel = (ctx: ExtensionContext) => {
|
|
29
29
|
ctx.ui.setHiddenThinkingLabel(label);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
33
33
|
applyLabel(ctx);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
valni.registerCommand("thinking-label", {
|
|
37
37
|
description: "Set the hidden thinking label. Use without args to reset.",
|
|
38
38
|
handler: async (args, ctx) => {
|
|
39
39
|
const nextLabel = args.trim();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Inline Bash Extension - expands inline bash commands in user prompts.
|
|
3
3
|
*
|
|
4
|
-
* Start
|
|
5
|
-
*
|
|
4
|
+
* Start valni with this extension:
|
|
5
|
+
* valni -e ./examples/extensions/inline-bash.ts
|
|
6
6
|
*
|
|
7
7
|
* Then type prompts with inline bash:
|
|
8
8
|
* What's in !{pwd}?
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { ExtensionAPI } from "@valni/cli";
|
|
18
18
|
|
|
19
|
-
export default function (
|
|
19
|
+
export default function (valni: ExtensionAPI) {
|
|
20
20
|
const PATTERN = /!\{([^}]+)\}/g;
|
|
21
21
|
const TIMEOUT_MS = 30000;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
valni.on("input", async (event, ctx) => {
|
|
24
24
|
const text = event.text;
|
|
25
25
|
|
|
26
26
|
// Don't process if it's a whole-line bash command (starts with !)
|
|
@@ -51,7 +51,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
51
51
|
// Execute each command and collect results
|
|
52
52
|
for (const { full, command } of matches) {
|
|
53
53
|
try {
|
|
54
|
-
const bashResult = await
|
|
54
|
+
const bashResult = await valni.exec("bash", ["-c", command], {
|
|
55
55
|
timeout: TIMEOUT_MS,
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
* file changes, giving the model immediate context. During steering the
|
|
9
9
|
* exec call is skipped so the correction reaches the model without delay.
|
|
10
10
|
*
|
|
11
|
-
* Start
|
|
12
|
-
*
|
|
11
|
+
* Start valni with this extension:
|
|
12
|
+
* valni -e ./examples/extensions/input-transform-streaming.ts
|
|
13
13
|
*/
|
|
14
14
|
import type { ExtensionAPI } from "@valni/cli";
|
|
15
15
|
|
|
16
16
|
const TRIGGER = /\b(changes?|diff|modified)\b/i;
|
|
17
17
|
|
|
18
|
-
export default function (
|
|
19
|
-
|
|
18
|
+
export default function (valni: ExtensionAPI) {
|
|
19
|
+
valni.on("input", async (event) => {
|
|
20
20
|
// During steering, skip the exec call — corrections should be fast
|
|
21
21
|
if (event.streamingBehavior === "steer") {
|
|
22
22
|
return { action: "continue" };
|
|
@@ -26,7 +26,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
26
26
|
return { action: "continue" };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const { stdout, code } = await
|
|
29
|
+
const { stdout, code } = await valni.exec("git", ["diff", "--stat"]);
|
|
30
30
|
if (code !== 0 || !stdout.trim()) {
|
|
31
31
|
return { action: "continue" };
|
|
32
32
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Input Transform Example - demonstrates the `input` event for intercepting user input.
|
|
3
3
|
*
|
|
4
|
-
* Start
|
|
5
|
-
*
|
|
4
|
+
* Start valni with this extension:
|
|
5
|
+
* valni -e ./examples/extensions/input-transform.ts
|
|
6
6
|
*
|
|
7
|
-
* Then type these inside
|
|
7
|
+
* Then type these inside valni:
|
|
8
8
|
* ?quick What is TypeScript? → "Respond briefly: What is TypeScript?"
|
|
9
9
|
* ping → "pong" (instant, no LLM)
|
|
10
10
|
* time → current time (instant, no LLM)
|
|
11
11
|
*/
|
|
12
12
|
import type { ExtensionAPI } from "@valni/cli";
|
|
13
13
|
|
|
14
|
-
export default function (
|
|
15
|
-
|
|
14
|
+
export default function (valni: ExtensionAPI) {
|
|
15
|
+
valni.on("input", async (event, ctx) => {
|
|
16
16
|
// Source-based logic: skip processing for extension-injected messages
|
|
17
17
|
if (event.source === "extension") {
|
|
18
18
|
return { action: "continue" };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* with full terminal access. The TUI suspends while they run.
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
|
-
*
|
|
8
|
+
* valni -e examples/extensions/interactive-shell.ts
|
|
9
9
|
*
|
|
10
10
|
* !vim file.txt # Auto-detected as interactive
|
|
11
11
|
* !i any-command # Force interactive mode with !i prefix
|
|
@@ -128,8 +128,8 @@ function isInteractiveCommand(command: string): boolean {
|
|
|
128
128
|
return false;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
export default function (
|
|
132
|
-
|
|
131
|
+
export default function (valni: ExtensionAPI) {
|
|
132
|
+
valni.on("user_bash", async (event, ctx) => {
|
|
133
133
|
let command = event.command;
|
|
134
134
|
let forceInteractive = false;
|
|
135
135
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Syncs
|
|
2
|
+
* Syncs valni theme with macOS system appearance (dark/light mode).
|
|
3
3
|
*
|
|
4
4
|
* Usage:
|
|
5
|
-
*
|
|
5
|
+
* valni -e examples/extensions/mac-system-theme.ts
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { exec } from "node:child_process";
|
|
@@ -22,10 +22,10 @@ async function isDarkMode(): Promise<boolean> {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export default function (
|
|
25
|
+
export default function (valni: ExtensionAPI) {
|
|
26
26
|
let intervalId: ReturnType<typeof setInterval> | null = null;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
valni.on("session_start", async (_event, ctx) => {
|
|
29
29
|
let currentTheme = (await isDarkMode()) ? "dark" : "light";
|
|
30
30
|
ctx.ui.setTheme(currentTheme);
|
|
31
31
|
|
|
@@ -38,7 +38,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
38
38
|
}, 2000);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
valni.on("session_shutdown", () => {
|
|
42
42
|
if (intervalId) {
|
|
43
43
|
clearInterval(intervalId);
|
|
44
44
|
intervalId = null;
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
import type { ExtensionAPI } from "@valni/cli";
|
|
11
11
|
import { Box, Text } from "@valni/tui";
|
|
12
12
|
|
|
13
|
-
export default function (
|
|
13
|
+
export default function (valni: ExtensionAPI) {
|
|
14
14
|
// Register custom renderer for "status-update" messages
|
|
15
|
-
|
|
15
|
+
valni.registerMessageRenderer("status-update", (message, { expanded }, theme) => {
|
|
16
16
|
const details = message.details as { level: string; timestamp: number } | undefined;
|
|
17
17
|
const level = details?.level ?? "info";
|
|
18
18
|
|
|
@@ -35,7 +35,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
// Command to send status messages
|
|
38
|
-
|
|
38
|
+
valni.registerCommand("status", {
|
|
39
39
|
description: "Send a status message (usage: /status [warn|error] message)",
|
|
40
40
|
handler: async (args, _ctx) => {
|
|
41
41
|
const parts = args.trim().split(/\s+/);
|
|
@@ -48,7 +48,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
48
48
|
content = parts.slice(1).join(" ") || "Status update";
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
valni.sendMessage({
|
|
52
52
|
customType: "status-update",
|
|
53
53
|
content,
|
|
54
54
|
display: true,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - Minimal: Shows only tool call, no output (this extension's collapsed mode)
|
|
12
12
|
*
|
|
13
13
|
* Usage:
|
|
14
|
-
*
|
|
14
|
+
* valni -e ./minimal-mode.ts
|
|
15
15
|
*
|
|
16
16
|
* Then use ctrl+o to toggle between minimal (collapsed) and full (expanded) views.
|
|
17
17
|
*/
|
|
@@ -64,11 +64,11 @@ function getBuiltInTools(cwd: string) {
|
|
|
64
64
|
return tools;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export default function (
|
|
67
|
+
export default function (valni: ExtensionAPI) {
|
|
68
68
|
// =========================================================================
|
|
69
69
|
// Read Tool
|
|
70
70
|
// =========================================================================
|
|
71
|
-
|
|
71
|
+
valni.registerTool({
|
|
72
72
|
name: "read",
|
|
73
73
|
label: "read",
|
|
74
74
|
description:
|
|
@@ -115,7 +115,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
115
115
|
// =========================================================================
|
|
116
116
|
// Bash Tool
|
|
117
117
|
// =========================================================================
|
|
118
|
-
|
|
118
|
+
valni.registerTool({
|
|
119
119
|
name: "bash",
|
|
120
120
|
label: "bash",
|
|
121
121
|
description:
|
|
@@ -164,7 +164,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
164
164
|
// =========================================================================
|
|
165
165
|
// Write Tool
|
|
166
166
|
// =========================================================================
|
|
167
|
-
|
|
167
|
+
valni.registerTool({
|
|
168
168
|
name: "write",
|
|
169
169
|
label: "write",
|
|
170
170
|
description:
|
|
@@ -206,7 +206,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
206
206
|
// =========================================================================
|
|
207
207
|
// Edit Tool
|
|
208
208
|
// =========================================================================
|
|
209
|
-
|
|
209
|
+
valni.registerTool({
|
|
210
210
|
name: "edit",
|
|
211
211
|
label: "edit",
|
|
212
212
|
description:
|
|
@@ -251,7 +251,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
251
251
|
// =========================================================================
|
|
252
252
|
// Find Tool
|
|
253
253
|
// =========================================================================
|
|
254
|
-
|
|
254
|
+
valni.registerTool({
|
|
255
255
|
name: "find",
|
|
256
256
|
label: "find",
|
|
257
257
|
description:
|
|
@@ -309,7 +309,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
309
309
|
// =========================================================================
|
|
310
310
|
// Grep Tool
|
|
311
311
|
// =========================================================================
|
|
312
|
-
|
|
312
|
+
valni.registerTool({
|
|
313
313
|
name: "grep",
|
|
314
314
|
label: "grep",
|
|
315
315
|
description:
|
|
@@ -371,7 +371,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
371
371
|
// =========================================================================
|
|
372
372
|
// Ls Tool
|
|
373
373
|
// =========================================================================
|
|
374
|
-
|
|
374
|
+
valni.registerTool({
|
|
375
375
|
name: "ls",
|
|
376
376
|
label: "ls",
|
|
377
377
|
description:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Modal Editor - vim-like modal editing example
|
|
3
3
|
*
|
|
4
|
-
* Usage:
|
|
4
|
+
* Usage: valni --extension ./examples/extensions/modal-editor.ts
|
|
5
5
|
*
|
|
6
6
|
* - Escape: insert → normal mode (in normal mode, aborts agent)
|
|
7
7
|
* - i: normal → insert mode
|
|
@@ -78,8 +78,8 @@ class ModalEditor extends CustomEditor {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export default function (
|
|
82
|
-
|
|
81
|
+
export default function (valni: ExtensionAPI) {
|
|
82
|
+
valni.on("session_start", (_event, ctx) => {
|
|
83
83
|
ctx.ui.setEditorComponent((tui, theme, kb) => new ModalEditor(tui, theme, kb));
|
|
84
84
|
});
|
|
85
85
|
}
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Demonstrates the `model_select` hook which fires when the model changes
|
|
5
5
|
* via /model command, Ctrl+P cycling, or session restore.
|
|
6
6
|
*
|
|
7
|
-
* Usage:
|
|
7
|
+
* Usage: valni -e ./model-status.ts
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ExtensionAPI } from "@valni/cli";
|
|
11
11
|
|
|
12
|
-
export default function (
|
|
13
|
-
|
|
12
|
+
export default function (valni: ExtensionAPI) {
|
|
13
|
+
valni.on("model_select", async (event, ctx) => {
|
|
14
14
|
const { model, previousModel, source } = event;
|
|
15
15
|
|
|
16
16
|
// Format model identifiers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Valni Notify Extension
|
|
3
3
|
*
|
|
4
|
-
* Sends a native terminal notification when
|
|
4
|
+
* Sends a native terminal notification when Valni agent is done and waiting for input.
|
|
5
5
|
* Supports multiple terminal protocols:
|
|
6
6
|
* - OSC 777: Ghostty, iTerm2, WezTerm, rxvt-unicode
|
|
7
7
|
* - OSC 99: Kitty
|
|
@@ -48,8 +48,8 @@ function notify(title: string, body: string): void {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export default function (
|
|
52
|
-
|
|
53
|
-
notify("
|
|
51
|
+
export default function (valni: ExtensionAPI) {
|
|
52
|
+
valni.on("agent_end", async () => {
|
|
53
|
+
notify("Valni", "Ready for input");
|
|
54
54
|
});
|
|
55
55
|
}
|