@heyamiko/amiko-cli 0.4.8 → 0.4.9

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.
Files changed (3) hide show
  1. package/dist/cli.js +32 -7
  2. package/package.json +1 -1
  3. package/src/cli.tsx +32 -5
package/dist/cli.js CHANGED
@@ -61,14 +61,39 @@ function parseArgs(argv) {
61
61
  return overrides;
62
62
  }
63
63
  async function main() {
64
- // Ensure safe terminal dimensions for non-TTY environments (e.g. openclaw exec)
65
- // Prevents Ink RangeError from negative layout calculations
66
- if (!process.stdout.columns)
67
- process.stdout.columns = 80;
68
- if (!process.stdout.rows)
69
- process.stdout.rows = 24;
64
+ const argv = process.argv.slice(2);
65
+ // Non-TTY: Ink cannot render without a real terminal.
66
+ // Print version/help as plain text and exit.
67
+ if (!process.stdout.isTTY) {
68
+ const flag = argv[0];
69
+ if (flag === "-h" || flag === "--help") {
70
+ console.log("amiko-cli — interactive AI agent (requires a terminal)");
71
+ console.log("Usage: amiko [options]");
72
+ console.log(" --workspace, -w <path> Workspace directory");
73
+ console.log(" --model <provider/model> Model override");
74
+ console.log(" --session <id> Resume session");
75
+ console.log(" --thinking <level> off|minimal|low|medium|high|xhigh");
76
+ process.exit(0);
77
+ }
78
+ if (flag === "-v" || flag === "--version") {
79
+ const { readFileSync } = await import("node:fs");
80
+ const { fileURLToPath } = await import("node:url");
81
+ const { dirname, join } = await import("node:path");
82
+ try {
83
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
84
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
85
+ console.log(pkg.version);
86
+ }
87
+ catch {
88
+ console.log("unknown");
89
+ }
90
+ process.exit(0);
91
+ }
92
+ console.error("amiko-cli requires an interactive terminal (TTY). Cannot render UI in piped/non-TTY mode.");
93
+ process.exit(1);
94
+ }
70
95
  const config = loadConfig();
71
- const overrides = parseArgs(process.argv.slice(2));
96
+ const overrides = parseArgs(argv);
72
97
  const finalConfig = { ...config, ...overrides };
73
98
  const workspace = await initWorkspace(finalConfig.workspacePath);
74
99
  const persisted = await loadConfigFile(workspace.root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyamiko/amiko-cli",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "amiko": "dist/cli.js"
package/src/cli.tsx CHANGED
@@ -77,13 +77,40 @@ function parseArgs(argv: string[]): ArgOverrides {
77
77
  }
78
78
 
79
79
  async function main() {
80
- // Ensure safe terminal dimensions for non-TTY environments (e.g. openclaw exec)
81
- // Prevents Ink RangeError from negative layout calculations
82
- if (!process.stdout.columns) process.stdout.columns = 80;
83
- if (!process.stdout.rows) process.stdout.rows = 24;
80
+ const argv = process.argv.slice(2);
81
+
82
+ // Non-TTY: Ink cannot render without a real terminal.
83
+ // Print version/help as plain text and exit.
84
+ if (!process.stdout.isTTY) {
85
+ const flag = argv[0];
86
+ if (flag === "-h" || flag === "--help") {
87
+ console.log("amiko-cli — interactive AI agent (requires a terminal)");
88
+ console.log("Usage: amiko [options]");
89
+ console.log(" --workspace, -w <path> Workspace directory");
90
+ console.log(" --model <provider/model> Model override");
91
+ console.log(" --session <id> Resume session");
92
+ console.log(" --thinking <level> off|minimal|low|medium|high|xhigh");
93
+ process.exit(0);
94
+ }
95
+ if (flag === "-v" || flag === "--version") {
96
+ const { readFileSync } = await import("node:fs");
97
+ const { fileURLToPath } = await import("node:url");
98
+ const { dirname, join } = await import("node:path");
99
+ try {
100
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
101
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
102
+ console.log(pkg.version);
103
+ } catch {
104
+ console.log("unknown");
105
+ }
106
+ process.exit(0);
107
+ }
108
+ console.error("amiko-cli requires an interactive terminal (TTY). Cannot render UI in piped/non-TTY mode.");
109
+ process.exit(1);
110
+ }
84
111
 
85
112
  const config = loadConfig();
86
- const overrides = parseArgs(process.argv.slice(2));
113
+ const overrides = parseArgs(argv);
87
114
  const finalConfig = { ...config, ...overrides };
88
115
  const workspace = await initWorkspace(finalConfig.workspacePath);
89
116
  const persisted = await loadConfigFile(workspace.root);