@townco/tui-template 0.1.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/dist/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/dist/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/dist/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/dist/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
+ });
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/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
+ });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@townco/tui-template",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "bin": {
8
+ "agent-tui": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "src",
13
+ "README.md"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/federicoweber/agent_hub.git"
18
+ },
19
+ "author": "Federico Weber",
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "dev": "bun src/index.tsx --agent=../../packages/agent/bin.ts",
23
+ "start": "bun dist/index.js",
24
+ "check": "tsc --noEmit"
25
+ },
26
+ "dependencies": {
27
+ "@townco/ui": "^0.1.0",
28
+ "@optique/core": "^0.6.2",
29
+ "@optique/run": "^0.6.2",
30
+ "ink": "^6.4.0",
31
+ "ink-text-input": "^6.0.0",
32
+ "react": "^19.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@townco/tsconfig": "^0.1.0",
36
+ "@types/node": "^24.10.0",
37
+ "@types/react": "^19.2.2",
38
+ "tsx": "^4.20.6",
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }
package/src/App.tsx ADDED
@@ -0,0 +1,41 @@
1
+ import { AcpClient } from "@townco/ui";
2
+ import { ChatView } from "@townco/ui/tui";
3
+ import { Box, Text } from "ink";
4
+ import { useMemo } from "react";
5
+ import type { CliConfig } from "./cli.js";
6
+
7
+ export interface AppProps {
8
+ config: CliConfig;
9
+ }
10
+
11
+ export function App({ config }: AppProps) {
12
+ // Create ACP client
13
+ const client = useMemo(() => {
14
+ try {
15
+ const newClient = new AcpClient({
16
+ type: "stdio",
17
+ options: {
18
+ agentPath: config.agentPath,
19
+ workingDirectory: config.workingDir ?? process.cwd(),
20
+ },
21
+ });
22
+ return newClient;
23
+ } catch (error) {
24
+ console.error("Failed to create client:", error);
25
+ return null;
26
+ }
27
+ }, [config.agentPath, config.workingDir]);
28
+
29
+ if (!client) {
30
+ return (
31
+ <Box flexDirection="column" padding={1}>
32
+ <Text color="red" bold>
33
+ Error: Failed to create ACP client
34
+ </Text>
35
+ <Text color="gray">Please check your agent path and try again.</Text>
36
+ </Box>
37
+ );
38
+ }
39
+
40
+ return <ChatView client={client} />;
41
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { text } from "@optique/core/message";
2
+ import type { InferValue } from "@optique/core/parser";
3
+ import { object, option, optional, withDefault } from "@optique/core/parser";
4
+ import { string } from "@optique/core/valueparser";
5
+
6
+ /**
7
+ * CLI configuration using Optique
8
+ */
9
+
10
+ export const cliParser = object({
11
+ agentPath: option("-a", "--agent", string(), {
12
+ description: [text("Path to the ACP agent executable")],
13
+ }),
14
+ workingDir: withDefault(
15
+ optional(
16
+ option("-d", "--dir", string(), {
17
+ description: [text("Working directory for the agent")],
18
+ }),
19
+ ),
20
+ process.cwd(),
21
+ ),
22
+ });
23
+
24
+ export type CliConfig = InferValue<typeof cliParser>;
package/src/index.tsx ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import { run } from "@optique/run";
3
+ import { render } from "ink";
4
+ import { App } from "./App.js";
5
+ import { cliParser } from "./cli.js";
6
+
7
+ /**
8
+ * Agent Hub TUI
9
+ * Terminal chat interface for ACP agents
10
+ */
11
+
12
+ async function main() {
13
+ // Parse CLI arguments
14
+ const config = run(cliParser, {
15
+ help: "both", // Show help for both commands and the program
16
+ programName: "agent-tui",
17
+ description: [
18
+ {
19
+ type: "text",
20
+ text: "Terminal chat interface for Agent Client Protocol (ACP) agents",
21
+ },
22
+ ],
23
+ version: "0.0.1",
24
+ });
25
+
26
+ // Render the app
27
+ render(<App config={config} />);
28
+ }
29
+
30
+ main().catch((error) => {
31
+ console.error("Fatal error:", error);
32
+ process.exit(1);
33
+ });