opencode-miniterm 1.0.14 → 1.0.15

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/bun.lock CHANGED
@@ -47,7 +47,7 @@
47
47
 
48
48
  "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
49
49
 
50
- "@opencode-ai/sdk": ["@opencode-ai/sdk@1.2.24", "", {}, "sha512-MQamFkRl4B/3d6oIRLNpkYR2fcwet1V/ffKyOKJXWjtP/CT9PDJMtLpu6olVHjXKQi8zMNltwuMhv1QsNtRlZg=="],
50
+ "@opencode-ai/sdk": ["@opencode-ai/sdk@1.2.25", "", {}, "sha512-ikuGWob48OM7LTgfXFqGOZKVOqh50FEjvtIBhXGhGowJhifmjZ+xuq/ypP8nPjTwUX73pbu1C3X9ZBWVkCN9mA=="],
51
51
 
52
52
  "@trivago/prettier-plugin-sort-imports": ["@trivago/prettier-plugin-sort-imports@6.0.2", "", { "dependencies": { "@babel/generator": "^7.28.0", "@babel/parser": "^7.28.0", "@babel/traverse": "^7.28.0", "@babel/types": "^7.28.0", "javascript-natural-sort": "^0.7.1", "lodash-es": "^4.17.21", "minimatch": "^9.0.0", "parse-imports-exports": "^0.2.4" }, "peerDependencies": { "@vue/compiler-sfc": "3.x", "prettier": "2.x - 3.x", "prettier-plugin-ember-template-tag": ">= 2.0.0", "prettier-plugin-svelte": "3.x", "svelte": "4.x || 5.x" }, "optionalPeers": ["@vue/compiler-sfc", "prettier-plugin-ember-template-tag", "prettier-plugin-svelte", "svelte"] }, "sha512-3DgfkukFyC/sE/VuYjaUUWoFfuVjPK55vOFDsxD56XXynFMCZDYFogH2l/hDfOsQAm1myoU/1xByJ3tWqtulXA=="],
53
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-miniterm",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "A small front-end terminal UI for OpenCode",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
@@ -29,7 +29,7 @@
29
29
  "typescript": "^5"
30
30
  },
31
31
  "dependencies": {
32
- "@opencode-ai/sdk": "^1.2.24",
32
+ "@opencode-ai/sdk": "^1.2.25",
33
33
  "allmark": "^1.0.2"
34
34
  }
35
35
  }
package/src/ansi.ts CHANGED
@@ -5,6 +5,7 @@ export const CLEAR_SCREEN_UP = "\x1b[2A";
5
5
  export const CURSOR_HOME = "\x1b[0G";
6
6
  export const CURSOR_HIDE = "\x1b[?25l";
7
7
  export const CURSOR_SHOW = "\x1b[?25h";
8
+ export const CURSOR_UP = (lines: number) => `\x1b[${lines}A`;
8
9
  export const DISABLE_LINE_WRAP = "\x1b[?7l";
9
10
  export const ENABLE_LINE_WRAP = "\x1b[?7h";
10
11
  export const RESET = "\x1b[0m";
@@ -2,7 +2,7 @@ import type { Agent, OpencodeClient } from "@opencode-ai/sdk";
2
2
  import readline, { type Key } from "node:readline";
3
3
  import { config, saveConfig } from "../config";
4
4
  import { getActiveDisplay, writePrompt } from "../render";
5
- import type { Command } from "../types";
5
+ import type { Command, State } from "../types";
6
6
 
7
7
  interface AgentInfo {
8
8
  id: string;
@@ -25,8 +25,8 @@ let command: Command = {
25
25
 
26
26
  export default command;
27
27
 
28
- async function run(client: OpencodeClient): Promise<void> {
29
- const result = await client.app.agents();
28
+ async function run(state: State): Promise<void> {
29
+ const result = await state.client.app.agents();
30
30
 
31
31
  if (result.error) {
32
32
  throw new Error(
@@ -47,7 +47,7 @@ async function run(client: OpencodeClient): Promise<void> {
47
47
  renderAgentList();
48
48
  }
49
49
 
50
- async function handleKey(client: OpencodeClient, key: Key, str?: string) {
50
+ async function handleKey(state: State, key: Key, str?: string) {
51
51
  switch (key.name) {
52
52
  case "up": {
53
53
  if (selectedAgentIndex === 0) {
@@ -98,7 +98,7 @@ async function handleKey(client: OpencodeClient, key: Key, str?: string) {
98
98
  if (selected) {
99
99
  config.agentID = selected.id;
100
100
  saveConfig();
101
- const activeDisplay = await getActiveDisplay(client);
101
+ const activeDisplay = await getActiveDisplay(state.client);
102
102
  console.log(activeDisplay);
103
103
  console.log();
104
104
  }
@@ -1,8 +1,7 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import { mkdirSync, writeFileSync } from "fs";
3
2
  import { join } from "path";
4
- import { type State, getLogDir } from "../index";
5
- import type { Command } from "../types";
3
+ import { getLogDir } from "../logs";
4
+ import type { Command, State } from "../types";
6
5
 
7
6
  let command: Command = {
8
7
  name: "/debug",
@@ -13,7 +12,7 @@ let command: Command = {
13
12
 
14
13
  export default command;
15
14
 
16
- function run(_client: OpencodeClient, state: State): void {
15
+ function run(state: State): void {
17
16
  if (state.allEvents.length === 0) {
18
17
  console.log("No parts stored yet. Send a message first.");
19
18
  return;
@@ -1,7 +1,5 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
- import type { State } from "../index";
3
1
  import { render } from "../render";
4
- import type { Command } from "../types";
2
+ import type { Command, State } from "../types";
5
3
 
6
4
  let command: Command = {
7
5
  name: "/details",
@@ -12,6 +10,6 @@ let command: Command = {
12
10
 
13
11
  export default command;
14
12
 
15
- function run(_client: OpencodeClient, state: State): void {
13
+ function run(state: State): void {
16
14
  render(state, true);
17
15
  }
@@ -1,7 +1,5 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import { config } from "../config";
3
- import type { State } from "../index";
4
- import type { Command } from "../types";
2
+ import type { Command, State } from "../types";
5
3
 
6
4
  let command: Command = {
7
5
  name: "/diff",
@@ -19,7 +17,7 @@ interface DiffLine {
19
17
  newIndex?: number;
20
18
  }
21
19
 
22
- async function run(client: OpencodeClient, state: State): Promise<void> {
20
+ async function run(state: State): Promise<void> {
23
21
  const cwd = process.cwd();
24
22
  if (!config.sessionIDs[cwd]) {
25
23
  console.log("No active session.\n");
@@ -28,7 +26,7 @@ async function run(client: OpencodeClient, state: State): Promise<void> {
28
26
 
29
27
  console.log("Fetching file changes...");
30
28
 
31
- const result = await client.session.diff({
29
+ const result = await state.client.session.diff({
32
30
  path: { id: config.sessionIDs[cwd] },
33
31
  });
34
32
 
@@ -1,6 +1,4 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
- import type { State } from "../index";
3
- import type { Command } from "../types";
1
+ import type { Command, State } from "../types";
4
2
 
5
3
  let command: Command = {
6
4
  name: "/exit",
@@ -11,7 +9,6 @@ let command: Command = {
11
9
 
12
10
  export default command;
13
11
 
14
- async function run(_client: OpencodeClient, _state: State): Promise<void> {
15
- console.log(`\x1b[90mGoodbye!\x1b[0m`);
16
- process.exit(0);
12
+ async function run(state: State): Promise<void> {
13
+ state.shutdown();
17
14
  }
@@ -1,8 +1,5 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
- import { config, saveConfig } from "../config";
3
- import type { State } from "../index";
4
- import { writePrompt } from "../render";
5
- import type { Command } from "../types";
1
+ import { config } from "../config";
2
+ import type { Command, State } from "../types";
6
3
 
7
4
  let command: Command = {
8
5
  name: "/init",
@@ -13,12 +10,12 @@ let command: Command = {
13
10
 
14
11
  export default command;
15
12
 
16
- async function run(_client: OpencodeClient, _state: State): Promise<void> {
13
+ async function run(state: State): Promise<void> {
17
14
  const cwd = process.cwd();
18
15
  if (!config.sessionIDs[cwd]) return;
19
16
 
20
17
  console.log("Running /init command (analyzing project and creating AGENTS.md)...");
21
- const result = await _client.session.init({
18
+ const result = await state.client.session.init({
22
19
  path: { id: config.sessionIDs[cwd] },
23
20
  });
24
21
 
@@ -1,7 +1,5 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import { config, saveConfig } from "../config";
3
- import type { State } from "../index";
4
- import type { Command } from "../types";
2
+ import type { Command, State } from "../types";
5
3
 
6
4
  let command: Command = {
7
5
  name: "/log",
@@ -12,11 +10,7 @@ let command: Command = {
12
10
 
13
11
  export default command;
14
12
 
15
- export function isLoggingEnabled(): boolean {
16
- return config.loggingEnabled;
17
- }
18
-
19
- function run(_client: OpencodeClient, _state: State): void {
13
+ function run(_state: State): void {
20
14
  config.loggingEnabled = !config.loggingEnabled;
21
15
  saveConfig();
22
16
  const status = config.loggingEnabled ? "enabled" : "disabled";
@@ -1,8 +1,7 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import readline, { type Key } from "node:readline";
3
2
  import { config, saveConfig } from "../config";
4
3
  import { getActiveDisplay, writePrompt } from "../render";
5
- import type { Command } from "../types";
4
+ import type { Command, State } from "../types";
6
5
 
7
6
  let command: Command = {
8
7
  name: "/models",
@@ -27,8 +26,8 @@ let modelListLineCount = 0;
27
26
  let modelSearchString = "";
28
27
  let modelFilteredIndices: number[] = [];
29
28
 
30
- async function run(client: OpencodeClient): Promise<void> {
31
- const result = await client.config.providers();
29
+ async function run(state: State): Promise<void> {
30
+ const result = await state.client.config.providers();
32
31
 
33
32
  if (result.error) {
34
33
  throw new Error(
@@ -64,7 +63,7 @@ async function run(client: OpencodeClient): Promise<void> {
64
63
  renderModelList();
65
64
  }
66
65
 
67
- async function handleKey(client: OpencodeClient, key: Key, str?: string) {
66
+ async function handleKey(state: State, key: Key, str?: string) {
68
67
  switch (key.name) {
69
68
  case "up": {
70
69
  if (selectedModelIndex === 0) {
@@ -116,7 +115,7 @@ async function handleKey(client: OpencodeClient, key: Key, str?: string) {
116
115
  config.providerID = selected.providerID;
117
116
  config.modelID = selected.modelID;
118
117
  saveConfig();
119
- const activeDisplay = await getActiveDisplay(client);
118
+ const activeDisplay = await getActiveDisplay(state.client);
120
119
  console.log(activeDisplay);
121
120
  console.log();
122
121
  }
@@ -1,9 +1,6 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import { config, saveConfig } from "../config";
3
- import type { State } from "../index";
4
- import { updateSessionTitle } from "../index";
5
- import { getActiveDisplay } from "../render";
6
- import type { Command } from "../types";
2
+ import { getActiveDisplay, updateSessionTitle } from "../render";
3
+ import type { Command, State } from "../types";
7
4
 
8
5
  let command: Command = {
9
6
  name: "/new",
@@ -14,21 +11,21 @@ let command: Command = {
14
11
 
15
12
  export default command;
16
13
 
17
- async function run(client: OpencodeClient, state: State): Promise<void> {
18
- state.sessionID = await createSession(client);
14
+ async function run(state: State): Promise<void> {
15
+ state.sessionID = await createSession(state);
19
16
  config.sessionIDs[process.cwd()] = state.sessionID;
20
17
  saveConfig();
21
18
 
22
- await updateSessionTitle();
19
+ await updateSessionTitle(state);
23
20
 
24
- const activeDisplay = await getActiveDisplay(client);
21
+ const activeDisplay = await getActiveDisplay(state.client);
25
22
  console.log(activeDisplay);
26
23
  console.log(`Created new session`);
27
24
  console.log();
28
25
  }
29
26
 
30
- async function createSession(client: OpencodeClient): Promise<string> {
31
- const result = await client.session.create({
27
+ async function createSession(state: State): Promise<string> {
28
+ const result = await state.client.session.create({
32
29
  body: {},
33
30
  });
34
31
 
@@ -1,9 +1,7 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import type { Key } from "node:readline";
3
2
  import * as ansi from "../ansi";
4
- import type { State } from "../index";
5
3
  import { wrapText } from "../render";
6
- import type { Command } from "../types";
4
+ import type { Command, State } from "../types";
7
5
 
8
6
  let currentPageIndex = 0;
9
7
  let pages: string[] = [];
@@ -18,7 +16,7 @@ let command: Command = {
18
16
 
19
17
  export default command;
20
18
 
21
- function run(client: OpencodeClient, state: State): void {
19
+ function run(state: State): void {
22
20
  pages = [];
23
21
 
24
22
  for (const part of state.accumulatedResponse) {
@@ -44,7 +42,7 @@ function run(client: OpencodeClient, state: State): void {
44
42
  displayPage();
45
43
  }
46
44
 
47
- function handleKey(client: OpencodeClient, key: Key, _input?: string): void {
45
+ function handleKey(state: State, key: Key, _input?: string): void {
48
46
  if (key.name === "space") {
49
47
  currentPageIndex++;
50
48
  if (currentPageIndex >= pages.length) {
@@ -1,8 +1,4 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
- import * as ansi from "../ansi";
3
- import { saveConfig } from "../config";
4
- import type { State } from "../index";
5
- import type { Command } from "../types";
1
+ import type { Command, State } from "../types";
6
2
 
7
3
  let command: Command = {
8
4
  name: "/quit",
@@ -13,14 +9,6 @@ let command: Command = {
13
9
 
14
10
  export default command;
15
11
 
16
- async function run(_client: OpencodeClient, _state: State): Promise<void> {
17
- if (process.stdin.setRawMode) {
18
- process.stdin.setRawMode(false);
19
- }
20
- process.stdin.destroy();
21
- process.stdout.write(ansi.ENABLE_LINE_WRAP);
22
- saveConfig();
23
- // TODO: server?.close();
24
- console.log(`${ansi.BRIGHT_BLACK}Goodbye!${ansi.RESET}`);
25
- process.exit(0);
12
+ async function run(state: State): Promise<void> {
13
+ state.shutdown();
26
14
  }
@@ -1,7 +1,5 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import { spawn } from "node:child_process";
3
- import type { State } from "../index";
4
- import type { Command } from "../types";
2
+ import type { Command, State } from "../types";
5
3
 
6
4
  let command: Command = {
7
5
  name: "/run",
@@ -12,7 +10,7 @@ let command: Command = {
12
10
 
13
11
  export default command;
14
12
 
15
- async function run(_client: OpencodeClient, _state: State, input?: string): Promise<void> {
13
+ async function run(_state: State, input?: string): Promise<void> {
16
14
  if (!input) return;
17
15
 
18
16
  const child = spawn(input, [], { shell: true });
@@ -1,10 +1,8 @@
1
- import type { OpencodeClient, Session } from "@opencode-ai/sdk";
1
+ import type { Session } from "@opencode-ai/sdk";
2
2
  import readline, { type Key } from "node:readline";
3
3
  import { config, saveConfig } from "../config";
4
- import type { State } from "../index";
5
- import { updateSessionTitle } from "../index";
6
- import { writePrompt } from "../render";
7
- import type { Command } from "../types";
4
+ import { updateSessionTitle, writePrompt } from "../render";
5
+ import type { Command, State } from "../types";
8
6
 
9
7
  let command: Command = {
10
8
  name: "/sessions",
@@ -30,8 +28,8 @@ let sessionListOffset = 0;
30
28
  let sessionSearchString = "";
31
29
  let sessionFilteredIndices: number[] = [];
32
30
 
33
- async function run(client: OpencodeClient, state: State): Promise<void> {
34
- const result = await client.session.list();
31
+ async function run(state: State): Promise<void> {
32
+ const result = await state.client.session.list();
35
33
 
36
34
  if (result.error) {
37
35
  throw new Error(
@@ -43,11 +41,11 @@ async function run(client: OpencodeClient, state: State): Promise<void> {
43
41
 
44
42
  if (sessions.length === 0) {
45
43
  console.log("No sessions found. Creating a new session...");
46
- state.sessionID = await createSession(client);
44
+ state.sessionID = await createSession(state);
47
45
  config.sessionIDs[process.cwd()] = state.sessionID;
48
46
  saveConfig();
49
47
  console.log(`Created new session: ${state.sessionID}...\n`);
50
- await updateSessionTitle();
48
+ await updateSessionTitle(state);
51
49
  return;
52
50
  }
53
51
 
@@ -71,7 +69,7 @@ async function run(client: OpencodeClient, state: State): Promise<void> {
71
69
  renderSessionList();
72
70
  }
73
71
 
74
- async function handleKey(_client: OpencodeClient, key: Key, str?: string) {
72
+ async function handleKey(state: State, key: Key, str?: string) {
75
73
  switch (key.name) {
76
74
  case "up": {
77
75
  if (selectedSessionIndex === 0) {
@@ -142,7 +140,7 @@ async function handleKey(_client: OpencodeClient, key: Key, str?: string) {
142
140
  console.log(` Title: ${selected.title}`);
143
141
  }
144
142
  console.log();
145
- await updateSessionTitle();
143
+ await updateSessionTitle(state);
146
144
  }
147
145
  writePrompt();
148
146
  return;
@@ -165,8 +163,8 @@ async function handleKey(_client: OpencodeClient, key: Key, str?: string) {
165
163
  }
166
164
  }
167
165
 
168
- async function createSession(client: OpencodeClient): Promise<string> {
169
- const result = await client.session.create({
166
+ async function createSession(state: State): Promise<string> {
167
+ const result = await state.client.session.create({
170
168
  body: {},
171
169
  });
172
170
 
@@ -1,7 +1,5 @@
1
- import type { OpencodeClient } from "@opencode-ai/sdk";
2
1
  import { config } from "../config";
3
- import type { State } from "../index";
4
- import type { Command } from "../types";
2
+ import type { Command, State } from "../types";
5
3
 
6
4
  let command: Command = {
7
5
  name: "/undo",
@@ -12,13 +10,13 @@ let command: Command = {
12
10
 
13
11
  export default command;
14
12
 
15
- async function run(client: OpencodeClient, _state: State): Promise<void> {
13
+ async function run(state: State): Promise<void> {
16
14
  const cwd = process.cwd();
17
15
  if (!config.sessionIDs[cwd]) return;
18
16
 
19
17
  console.log("Fetching session messages...");
20
18
 
21
- const messagesRes = await client.session.messages({
19
+ const messagesRes = await state.client.session.messages({
22
20
  path: { id: config.sessionIDs[cwd] },
23
21
  });
24
22
 
@@ -49,8 +47,8 @@ async function run(client: OpencodeClient, _state: State): Promise<void> {
49
47
 
50
48
  console.log(`Reverting last assistant message (${lastMessage.info.id})...`);
51
49
 
52
- const revertRes = await client.session.revert({
53
- path: { id: config.sessionIDs[process.cwd()] },
50
+ const revertRes = await state.client.session.revert({
51
+ path: { id: config.sessionIDs[process.cwd()]! },
54
52
  body: {
55
53
  messageID: lastMessage.info.id,
56
54
  },