paseo-terminal-integration 0.4.0 → 0.5.0

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/README.md CHANGED
@@ -29,6 +29,22 @@ Terminal runs in one workspace are queued so a command never types into another
29
29
  Each block runs as a script in the agent's working directory, so `cd` and `export` do not persist
30
30
  between runs. **Settings → Plugins → Terminal integration** sets the checkbox's default.
31
31
 
32
+ **Command guidance for agents.** The same settings screen can add command-formatting and execution
33
+ guidance to the system prompt of newly created agents. Turn on **Inject command instructions** and
34
+ choose one topology:
35
+
36
+ - **Local daemon** tells the agent that Run already executes on the local Paseo daemon host, so it
37
+ should not add SSH merely to reach that machine.
38
+ - **Client–server** tells the agent that the UI and daemon may be on different devices. Commands for
39
+ the daemon need no prefix; commands for another machine must include an explicit transport such
40
+ as SSH, using a destination supplied by the user rather than an invented host.
41
+
42
+ Both templates are editable and stored per host. The shipped defaults are also available as
43
+ [`local-daemon.md`](instructions/local-daemon.md) and
44
+ [`client-server.md`](instructions/client-server.md), and each editor has a restore-default action.
45
+ Changing or enabling the setting affects only agents created afterward; it does not rewrite the
46
+ system prompt of an existing agent.
47
+
32
48
  **Terminal → agent.** In the composer's attachment menu, **Terminal output** attaches the latest
33
49
  lines of any terminal on the daemon. Type part of a name or path to filter, and a number to choose
34
50
  the line count (`build 500`; default 200).
@@ -1,13 +1,22 @@
1
- import { useSettings, type PluginSurfaceProps } from "@getpaseo/plugin/client";
1
+ import { useSettings, type PluginSurfaceProps, type SettingsState } from "@getpaseo/plugin/client";
2
2
  import {
3
+ ExternalLink,
4
+ SettingsAction,
3
5
  SettingsCard,
4
6
  SettingsRow,
5
7
  SettingsSection,
8
+ SettingsSelect,
6
9
  SettingsSwitch,
7
10
  } from "@getpaseo/plugin/client/ui";
8
- import { Text } from "react-native";
11
+ import { useMemo, useState } from "react";
12
+ import { Text, TextInput, View } from "react-native";
9
13
  import { TERMINAL_NAME } from "../shared/contracts";
10
- import { preferences } from "../shared/settings";
14
+ import { CLIENT_SERVER_INSTRUCTIONS, LOCAL_DAEMON_INSTRUCTIONS } from "../shared/instructions";
15
+ import { preferences, type InstructionTopology } from "../shared/settings";
16
+
17
+ const REPOSITORY = "https://github.com/keefeere/paseo-terminal-integration/blob/main";
18
+
19
+ type ReadySettings = Extract<SettingsState<typeof preferences.schema>, { status: "ready" }>;
11
20
 
12
21
  export function SettingsScreen({ theme }: PluginSurfaceProps) {
13
22
  const settings = useSettings(preferences);
@@ -17,24 +26,178 @@ export function SettingsScreen({ theme }: PluginSurfaceProps) {
17
26
  settings.status === "loading" ? "Loading…" : `Settings are unavailable: ${settings.error}`;
18
27
  return <Text style={{ color: theme.colors.foregroundMuted }}>{message}</Text>;
19
28
  }
29
+
30
+ return <ReadySettingsScreen key={settings.revision} settings={settings} theme={theme} />;
31
+ }
32
+
33
+ function ReadySettingsScreen({
34
+ settings,
35
+ theme,
36
+ }: {
37
+ settings: ReadySettings;
38
+ theme: PluginSurfaceProps["theme"];
39
+ }) {
20
40
  const { values, revision } = settings;
41
+ const [draft, setDraft] = useState(values);
42
+ const dirty = useMemo(() => JSON.stringify(draft) !== JSON.stringify(values), [draft, values]);
43
+ const editorStyle = useMemo(
44
+ () => ({
45
+ minHeight: 220,
46
+ paddingHorizontal: 12,
47
+ paddingVertical: 10,
48
+ borderWidth: 1,
49
+ borderColor: theme.colors.border,
50
+ borderRadius: 8,
51
+ color: theme.colors.foreground,
52
+ backgroundColor: theme.colors.surface0,
53
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
54
+ fontSize: 12,
55
+ lineHeight: 18,
56
+ textAlignVertical: "top" as const,
57
+ }),
58
+ [theme],
59
+ );
60
+ const linkStyle = useMemo(() => ({ color: theme.colors.accent, fontSize: 12 }), [theme]);
61
+
62
+ const updateTopology = (instructionTopology: InstructionTopology) =>
63
+ setDraft((current) => ({ ...current, instructionTopology }));
21
64
 
22
65
  return (
23
- <SettingsSection title="Code block actions">
24
- <SettingsCard>
25
- <SettingsSwitch
26
- label="Send output to the agent by default"
27
- hint={`Initial state of the "Send output to agent" checkbox on each code block.`}
28
- value={values.sendToAgent}
29
- disabled={settings.saving}
30
- error={settings.saveError}
31
- onValueChange={(sendToAgent) => void settings.save({ ...values, sendToAgent }, revision)}
32
- />
33
- <SettingsRow
34
- label="Where the terminal appears"
35
- hint={`Commands run in the "${TERMINAL_NAME}" terminal tab. Choose Main panel or On the side in Settings → Layout → Open location → Terminals. Manually moved tabs keep their location.`}
36
- />
37
- </SettingsCard>
38
- </SettingsSection>
66
+ <>
67
+ <SettingsSection title="Code block actions">
68
+ <SettingsCard>
69
+ <SettingsSwitch
70
+ label="Send output to the agent by default"
71
+ hint={`Initial state of the "Send output to agent" checkbox on each code block.`}
72
+ value={values.sendToAgent}
73
+ disabled={settings.saving}
74
+ error={settings.saveError}
75
+ onValueChange={(sendToAgent) =>
76
+ void settings.save({ ...values, sendToAgent }, revision)
77
+ }
78
+ />
79
+ <SettingsRow
80
+ label="Where the terminal appears"
81
+ hint={`Commands run in the "${TERMINAL_NAME}" terminal tab. Choose Main panel or On the side in Settings → Layout → Open location → Terminals. Manually moved tabs keep their location.`}
82
+ />
83
+ </SettingsCard>
84
+ </SettingsSection>
85
+
86
+ <SettingsSection title="Agent command instructions">
87
+ <SettingsCard>
88
+ <SettingsSwitch
89
+ label="Inject command instructions"
90
+ hint="Add the selected guidance to the system prompt of newly created agents. Existing agents are unchanged."
91
+ value={draft.injectCommandInstructions}
92
+ disabled={settings.saving}
93
+ onValueChange={(injectCommandInstructions) =>
94
+ setDraft((current) => ({ ...current, injectCommandInstructions }))
95
+ }
96
+ />
97
+ <SettingsSelect
98
+ label="Execution topology"
99
+ hint="Choose where clicking Run actually executes a command."
100
+ value={draft.instructionTopology}
101
+ options={[
102
+ { label: "Local daemon", value: "local-daemon" },
103
+ { label: "Client–server", value: "client-server" },
104
+ ]}
105
+ disabled={settings.saving}
106
+ onValueChange={updateTopology}
107
+ />
108
+ </SettingsCard>
109
+ </SettingsSection>
110
+
111
+ <SettingsSection title="Local daemon instructions">
112
+ <SettingsCard>
113
+ <SettingsRow
114
+ label="Instruction text"
115
+ hint="Used when Execution topology is Local daemon. Edit the host-scoped copy below."
116
+ >
117
+ <View style={{ gap: 8, width: "100%" }}>
118
+ <ExternalLink href={`${REPOSITORY}/instructions/local-daemon.md`}>
119
+ <Text style={linkStyle}>View shipped local-daemon.md</Text>
120
+ </ExternalLink>
121
+ <TextInput
122
+ multiline
123
+ accessibilityLabel="Local daemon command instructions"
124
+ value={draft.localDaemonInstructions}
125
+ editable={!settings.saving}
126
+ onChangeText={(localDaemonInstructions) =>
127
+ setDraft((current) => ({ ...current, localDaemonInstructions }))
128
+ }
129
+ style={editorStyle}
130
+ />
131
+ </View>
132
+ </SettingsRow>
133
+ <SettingsAction
134
+ label="Restore local template"
135
+ hint="Replace the draft with the version shipped by the plugin."
136
+ actionLabel="Restore default"
137
+ disabled={
138
+ settings.saving || draft.localDaemonInstructions === LOCAL_DAEMON_INSTRUCTIONS
139
+ }
140
+ onPress={() =>
141
+ setDraft((current) => ({
142
+ ...current,
143
+ localDaemonInstructions: LOCAL_DAEMON_INSTRUCTIONS,
144
+ }))
145
+ }
146
+ />
147
+ </SettingsCard>
148
+ </SettingsSection>
149
+
150
+ <SettingsSection title="Client–server instructions">
151
+ <SettingsCard>
152
+ <SettingsRow
153
+ label="Instruction text"
154
+ hint="Used when Execution topology is Client–server. Edit the host-scoped copy below."
155
+ >
156
+ <View style={{ gap: 8, width: "100%" }}>
157
+ <ExternalLink href={`${REPOSITORY}/instructions/client-server.md`}>
158
+ <Text style={linkStyle}>View shipped client-server.md</Text>
159
+ </ExternalLink>
160
+ <TextInput
161
+ multiline
162
+ accessibilityLabel="Client-server command instructions"
163
+ value={draft.clientServerInstructions}
164
+ editable={!settings.saving}
165
+ onChangeText={(clientServerInstructions) =>
166
+ setDraft((current) => ({ ...current, clientServerInstructions }))
167
+ }
168
+ style={editorStyle}
169
+ />
170
+ </View>
171
+ </SettingsRow>
172
+ <SettingsAction
173
+ label="Restore client–server template"
174
+ hint="Replace the draft with the version shipped by the plugin."
175
+ actionLabel="Restore default"
176
+ disabled={
177
+ settings.saving || draft.clientServerInstructions === CLIENT_SERVER_INSTRUCTIONS
178
+ }
179
+ onPress={() =>
180
+ setDraft((current) => ({
181
+ ...current,
182
+ clientServerInstructions: CLIENT_SERVER_INSTRUCTIONS,
183
+ }))
184
+ }
185
+ />
186
+ </SettingsCard>
187
+ </SettingsSection>
188
+
189
+ <SettingsSection title="Save instruction settings">
190
+ <SettingsCard>
191
+ <SettingsAction
192
+ label="Apply to newly created agents"
193
+ hint="Saving does not modify agents that already exist."
194
+ error={settings.saveError}
195
+ actionLabel={settings.saving ? "Saving…" : "Save changes"}
196
+ disabled={settings.saving || !dirty}
197
+ onPress={() => void settings.save(draft, revision)}
198
+ />
199
+ </SettingsCard>
200
+ </SettingsSection>
201
+ </>
39
202
  );
40
203
  }
package/index.server.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PluginServerContext } from "@getpaseo/plugin/server";
2
2
  import { searchTerminals } from "./server/attachments";
3
3
  import { appendCardForTurn, appendRunCard, scanLatestReply } from "./server/cards";
4
+ import { injectCommandInstructions, selectedCommandInstructions } from "./server/instructions";
4
5
  import { cleanupScripts, TerminalRunner } from "./server/runner";
5
6
  import { preferences } from "./shared/settings";
6
7
  import {
@@ -16,11 +17,25 @@ import {
16
17
  } from "./shared/contracts";
17
18
 
18
19
  export default function contribute(server: PluginServerContext) {
19
- server.registerSettings(preferences);
20
+ const settings = server.registerSettings(preferences);
20
21
  let runner: TerminalRunner | null = null;
21
22
  const runnerFor = (paseo: ConstructorParameters<typeof TerminalRunner>[0]) =>
22
23
  (runner ??= new TerminalRunner(paseo));
23
24
 
25
+ server.before("agent.create", async ({ request }) => {
26
+ const state = await settings.read();
27
+ if (state.status !== "ready") return;
28
+ const instructions = selectedCommandInstructions(state.values);
29
+ if (!instructions) return;
30
+ return {
31
+ ...request,
32
+ config: {
33
+ ...request.config,
34
+ systemPrompt: injectCommandInstructions(request.config.systemPrompt, instructions),
35
+ },
36
+ };
37
+ });
38
+
24
39
  // COMPAT(legacyRunCards): only old clients opt into scanning; remove after 2027-04-01.
25
40
  let legacyCardsRequested = false;
26
41
  server.handle(enableLegacyCards, async () => {
@@ -0,0 +1,13 @@
1
+ Paseo Terminal Integration is installed in a client-server setup. The chat UI may be on a different device, but clicking Run never executes on that client device. It executes on this agent's Paseo daemon host, in this agent's working directory, under the daemon user's account.
2
+
3
+ When you offer commands that the user may want to run:
4
+
5
+ - Put each directly executable command in a fenced code block tagged with its interpreter, such as bash, sh, python, or node.
6
+ - Keep explanations, alternatives, warnings, and expected output outside executable code blocks.
7
+ - Make each executable block self-contained. Do not include a shell prompt such as "$ ", prose, or sample output in it.
8
+ - State clearly which machine a command targets whenever that may be ambiguous. Never describe Run as executing on the user's phone, browser, or desktop client.
9
+ - A command for the daemon host needs no transport prefix: clicking Run already executes it there.
10
+ - A command for another machine must include the transport explicitly, normally SSH from the daemon host. Use an SSH destination already provided by the user; do not invent a hostname, username, path, or credential. If the destination is unknown, explain what is needed instead of presenting a falsely runnable command.
11
+ - Quote remote commands so that expansion happens on the intended machine. Account for differences between the agent working directory and the remote working directory.
12
+ - Distinguish commands the user may run from commands you already ran. Do not claim that a suggested command has executed.
13
+ - Use Run in the terminal for commands that may need a password, confirmation, or other input. Background runs have no stdin.
@@ -0,0 +1,11 @@
1
+ Paseo Terminal Integration is installed on this agent's daemon host.
2
+
3
+ When you offer commands that the user may want to run:
4
+
5
+ - Put each directly executable command in a fenced code block tagged with its interpreter, such as bash, sh, python, or node.
6
+ - Keep explanations, alternatives, warnings, and expected output outside executable code blocks.
7
+ - Make each executable block self-contained. Do not include a shell prompt such as "$ ", prose, or sample output in it.
8
+ - Assume that clicking Run executes the block on the same machine as the Paseo daemon, in this agent's working directory, under the daemon user's account.
9
+ - Distinguish commands the user may run from commands you already ran. Do not claim that a suggested command has executed.
10
+ - Use Run in the terminal for commands that may need a password, confirmation, or other input. Background runs have no stdin.
11
+ - Do not add SSH merely to reach the daemon host: the command already runs there.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-terminal-integration",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Run agent code blocks in a Paseo terminal and send the output back to the agent; attach terminal output to prompts",
5
5
  "keywords": [
6
6
  "agents",
@@ -23,6 +23,7 @@
23
23
  "index.client.tsx",
24
24
  "index.server.ts",
25
25
  "client/",
26
+ "instructions/",
26
27
  "server/",
27
28
  "shared/",
28
29
  "!**/*.test.ts"
@@ -0,0 +1,28 @@
1
+ import { INSTRUCTION_PROMPT_MARKER } from "../shared/instructions";
2
+ import type { InstructionTopology } from "../shared/settings";
3
+
4
+ export interface CommandInstructionPreferences {
5
+ injectCommandInstructions: boolean;
6
+ instructionTopology: InstructionTopology;
7
+ localDaemonInstructions: string;
8
+ clientServerInstructions: string;
9
+ }
10
+
11
+ export function selectedCommandInstructions(values: CommandInstructionPreferences): string | null {
12
+ if (!values.injectCommandInstructions) return null;
13
+ const text =
14
+ values.instructionTopology === "local-daemon"
15
+ ? values.localDaemonInstructions
16
+ : values.clientServerInstructions;
17
+ return text.trim() || null;
18
+ }
19
+
20
+ export function injectCommandInstructions(
21
+ systemPrompt: string | undefined,
22
+ instructions: string,
23
+ ): string {
24
+ const existing = systemPrompt?.trim() ?? "";
25
+ if (existing.includes(INSTRUCTION_PROMPT_MARKER)) return existing;
26
+ const addition = `<${INSTRUCTION_PROMPT_MARKER}>\n${instructions.trim()}\n</${INSTRUCTION_PROMPT_MARKER}>`;
27
+ return existing ? `${existing}\n\n${addition}` : addition;
28
+ }
@@ -0,0 +1,31 @@
1
+ export const LOCAL_DAEMON_INSTRUCTIONS = `
2
+ Paseo Terminal Integration is installed on this agent's daemon host.
3
+
4
+ When you offer commands that the user may want to run:
5
+
6
+ - Put each directly executable command in a fenced code block tagged with its interpreter, such as bash, sh, python, or node.
7
+ - Keep explanations, alternatives, warnings, and expected output outside executable code blocks.
8
+ - Make each executable block self-contained. Do not include a shell prompt such as "$ ", prose, or sample output in it.
9
+ - Assume that clicking Run executes the block on the same machine as the Paseo daemon, in this agent's working directory, under the daemon user's account.
10
+ - Distinguish commands the user may run from commands you already ran. Do not claim that a suggested command has executed.
11
+ - Use Run in the terminal for commands that may need a password, confirmation, or other input. Background runs have no stdin.
12
+ - Do not add SSH merely to reach the daemon host: the command already runs there.
13
+ `.trim();
14
+
15
+ export const CLIENT_SERVER_INSTRUCTIONS = `
16
+ Paseo Terminal Integration is installed in a client-server setup. The chat UI may be on a different device, but clicking Run never executes on that client device. It executes on this agent's Paseo daemon host, in this agent's working directory, under the daemon user's account.
17
+
18
+ When you offer commands that the user may want to run:
19
+
20
+ - Put each directly executable command in a fenced code block tagged with its interpreter, such as bash, sh, python, or node.
21
+ - Keep explanations, alternatives, warnings, and expected output outside executable code blocks.
22
+ - Make each executable block self-contained. Do not include a shell prompt such as "$ ", prose, or sample output in it.
23
+ - State clearly which machine a command targets whenever that may be ambiguous. Never describe Run as executing on the user's phone, browser, or desktop client.
24
+ - A command for the daemon host needs no transport prefix: clicking Run already executes it there.
25
+ - A command for another machine must include the transport explicitly, normally SSH from the daemon host. Use an SSH destination already provided by the user; do not invent a hostname, username, path, or credential. If the destination is unknown, explain what is needed instead of presenting a falsely runnable command.
26
+ - Quote remote commands so that expansion happens on the intended machine. Account for differences between the agent working directory and the remote working directory.
27
+ - Distinguish commands the user may run from commands you already ran. Do not claim that a suggested command has executed.
28
+ - Use Run in the terminal for commands that may need a password, confirmation, or other input. Background runs have no stdin.
29
+ `.trim();
30
+
31
+ export const INSTRUCTION_PROMPT_MARKER = "paseo-terminal-integration-command-guidance";
@@ -1,12 +1,24 @@
1
1
  import { defineSettings } from "@getpaseo/plugin";
2
2
  import { z } from "zod";
3
+ import { CLIENT_SERVER_INSTRUCTIONS, LOCAL_DAEMON_INSTRUCTIONS } from "./instructions";
4
+
5
+ export const instructionTopologies = ["local-daemon", "client-server"] as const;
6
+ export type InstructionTopology = (typeof instructionTopologies)[number];
3
7
 
4
8
  export const preferences = defineSettings({
5
9
  id: "preferences",
6
10
  scope: "host",
7
- version: 1,
11
+ version: 2,
8
12
  schema: z.object({
9
13
  /** Initial state of a code block's "Send output to agent" checkbox. */
10
14
  sendToAgent: z.boolean().default(true),
15
+ /** Add command-formatting and execution-topology guidance to newly created agents. */
16
+ injectCommandInstructions: z.boolean().default(false),
17
+ instructionTopology: z.enum(instructionTopologies).default("client-server"),
18
+ localDaemonInstructions: z.string().default(LOCAL_DAEMON_INSTRUCTIONS),
19
+ clientServerInstructions: z.string().default(CLIENT_SERVER_INSTRUCTIONS),
11
20
  }),
21
+ migrate(values) {
22
+ return values;
23
+ },
12
24
  });