heyeric 1.0.0 → 1.0.1

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 (2) hide show
  1. package/dist/index.js +25 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { execSync } from "child_process";
4
+ import { execSync, spawn } from "child_process";
5
+ import { createInterface } from "readline";
5
6
  import { readFileSync } from "fs";
6
7
  import { platform } from "os";
7
8
  import { basename } from "path";
@@ -113,7 +114,29 @@ async function main() {
113
114
  command = command.replace(/^`+|`+$/g, "");
114
115
  command = command.trim();
115
116
  if (!command) die("API returned empty command");
116
- process.stdout.write(command + "\n");
117
+ process.stderr.write(`\x1B[1;32m\u276F\x1B[0m \x1B[1m${command}\x1B[0m
118
+ `);
119
+ process.stderr.write(`\x1B[2mEnter to run \xB7 Type to refine \xB7 Ctrl+C to cancel\x1B[0m
120
+ `);
121
+ const rl = createInterface({ input: process.stdin, output: process.stderr });
122
+ const answer = await new Promise((resolve) => {
123
+ rl.question("\x1B[2m\u203A \x1B[0m", (input) => {
124
+ rl.close();
125
+ resolve(input.trim());
126
+ });
127
+ });
128
+ if (answer) {
129
+ const child2 = spawn(process.argv[0], [...process.argv.slice(1, 2), answer], {
130
+ stdio: "inherit",
131
+ env: process.env
132
+ });
133
+ child2.on("close", (code) => process.exit(code ?? 0));
134
+ return;
135
+ }
136
+ const child = spawn(command, { shell: true, stdio: "inherit" });
137
+ child.on("close", (code) => {
138
+ process.exit(code ?? 0);
139
+ });
117
140
  }
118
141
  main().catch((err) => {
119
142
  die(err.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heyeric",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Natural language to bash commands via LLM",
5
5
  "type": "module",
6
6
  "bin": {