@heyamiko/amiko-cli 0.4.9 → 0.4.10

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 +9 -32
  2. package/package.json +1 -1
  3. package/src/cli.tsx +9 -32
package/dist/cli.js CHANGED
@@ -61,39 +61,16 @@ function parseArgs(argv) {
61
61
  return overrides;
62
62
  }
63
63
  async function main() {
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
- }
64
+ // Ink's render-border.js calls box.top.repeat(contentWidth) where
65
+ // contentWidth = width - 2. When yoga computes a zero-width node (common
66
+ // in non-TTY / piped environments), contentWidth goes negative and
67
+ // String.repeat() throws. Patch String.repeat to clamp to 0.
68
+ const origRepeat = String.prototype.repeat;
69
+ String.prototype.repeat = function (count) {
70
+ return origRepeat.call(this, Math.max(0, Math.floor(count)));
71
+ };
95
72
  const config = loadConfig();
96
- const overrides = parseArgs(argv);
73
+ const overrides = parseArgs(process.argv.slice(2));
97
74
  const finalConfig = { ...config, ...overrides };
98
75
  const workspace = await initWorkspace(finalConfig.workspacePath);
99
76
  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.9",
3
+ "version": "0.4.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "amiko": "dist/cli.js"
package/src/cli.tsx CHANGED
@@ -77,40 +77,17 @@ function parseArgs(argv: string[]): ArgOverrides {
77
77
  }
78
78
 
79
79
  async function main() {
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
- }
80
+ // Ink's render-border.js calls box.top.repeat(contentWidth) where
81
+ // contentWidth = width - 2. When yoga computes a zero-width node (common
82
+ // in non-TTY / piped environments), contentWidth goes negative and
83
+ // String.repeat() throws. Patch String.repeat to clamp to 0.
84
+ const origRepeat = String.prototype.repeat;
85
+ String.prototype.repeat = function (count: number) {
86
+ return origRepeat.call(this, Math.max(0, Math.floor(count)));
87
+ };
111
88
 
112
89
  const config = loadConfig();
113
- const overrides = parseArgs(argv);
90
+ const overrides = parseArgs(process.argv.slice(2));
114
91
  const finalConfig = { ...config, ...overrides };
115
92
  const workspace = await initWorkspace(finalConfig.workspacePath);
116
93
  const persisted = await loadConfigFile(workspace.root);