@townco/cli 0.1.1 → 0.1.3

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.
@@ -105,8 +105,12 @@ export async function runCommand(options) {
105
105
  }
106
106
  // Default: Start TUI interface with the agent
107
107
  console.log(`Starting interactive terminal for agent "${name}"...\n`);
108
- // Get path to TUI app
109
- const tuiPath = join(process.cwd(), "apps", "tui", "src", "index.tsx");
108
+ // Get path to TUI app from CLI package
109
+ const { fileURLToPath } = await import("node:url");
110
+ const { dirname } = await import("node:path");
111
+ const currentFile = fileURLToPath(import.meta.url);
112
+ const cliRoot = join(dirname(currentFile), "..", "..");
113
+ const tuiPath = join(cliRoot, "tui", "index.js");
110
114
  // Run TUI with the agent
111
115
  const tuiProcess = spawn("bun", [tuiPath, "--agent", binPath], {
112
116
  cwd: agentPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@townco/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "dist",
12
+ "tui",
12
13
  "README.md"
13
14
  ],
14
15
  "repository": {
package/tui/App.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { CliConfig } from "./cli.js";
2
+ export interface AppProps {
3
+ config: CliConfig;
4
+ }
5
+ export declare function App({ config }: AppProps): import("react/jsx-runtime").JSX.Element;
package/tui/App.js ADDED
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AcpClient } from "@townco/ui";
3
+ import { ChatView } from "@townco/ui/tui";
4
+ import { Box, Text } from "ink";
5
+ import { useMemo } from "react";
6
+ export function App({ config }) {
7
+ // Create ACP client
8
+ const client = useMemo(() => {
9
+ try {
10
+ const newClient = new AcpClient({
11
+ type: "stdio",
12
+ options: {
13
+ agentPath: config.agentPath,
14
+ workingDirectory: config.workingDir ?? process.cwd(),
15
+ },
16
+ });
17
+ return newClient;
18
+ }
19
+ catch (error) {
20
+ console.error("Failed to create client:", error);
21
+ return null;
22
+ }
23
+ }, [config.agentPath, config.workingDir]);
24
+ if (!client) {
25
+ return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Text, { color: "red", bold: true, children: "Error: Failed to create ACP client" }), _jsx(Text, { color: "gray", children: "Please check your agent path and try again." })] }));
26
+ }
27
+ return _jsx(ChatView, { client: client });
28
+ }
package/tui/cli.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { InferValue } from "@optique/core/parser";
2
+ /**
3
+ * CLI configuration using Optique
4
+ */
5
+ export declare const cliParser: import("@optique/core/parser").Parser<{
6
+ readonly agentPath: string;
7
+ readonly workingDir: string | undefined;
8
+ }, {
9
+ readonly agentPath: import("@optique/core/valueparser").ValueParserResult<string> | undefined;
10
+ readonly workingDir: [[import("@optique/core/valueparser").ValueParserResult<string> | undefined] | undefined] | undefined;
11
+ }>;
12
+ export type CliConfig = InferValue<typeof cliParser>;
package/tui/cli.js ADDED
@@ -0,0 +1,14 @@
1
+ import { text } from "@optique/core/message";
2
+ import { object, option, optional, withDefault } from "@optique/core/parser";
3
+ import { string } from "@optique/core/valueparser";
4
+ /**
5
+ * CLI configuration using Optique
6
+ */
7
+ export const cliParser = object({
8
+ agentPath: option("-a", "--agent", string(), {
9
+ description: [text("Path to the ACP agent executable")],
10
+ }),
11
+ workingDir: withDefault(optional(option("-d", "--dir", string(), {
12
+ description: [text("Working directory for the agent")],
13
+ })), process.cwd()),
14
+ });
package/tui/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/tui/index.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { run } from "@optique/run";
4
+ import { render } from "ink";
5
+ import { App } from "./App.js";
6
+ import { cliParser } from "./cli.js";
7
+ /**
8
+ * Agent Hub TUI
9
+ * Terminal chat interface for ACP agents
10
+ */
11
+ async function main() {
12
+ // Parse CLI arguments
13
+ const config = run(cliParser, {
14
+ help: "both", // Show help for both commands and the program
15
+ programName: "agent-tui",
16
+ description: [
17
+ {
18
+ type: "text",
19
+ text: "Terminal chat interface for Agent Client Protocol (ACP) agents",
20
+ },
21
+ ],
22
+ version: "0.0.1",
23
+ });
24
+ // Render the app
25
+ render(_jsx(App, { config: config }));
26
+ }
27
+ main().catch((error) => {
28
+ console.error("Fatal error:", error);
29
+ process.exit(1);
30
+ });