husky-ai 1.0.2 → 1.0.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.
@@ -42,20 +42,30 @@ export async function initCommand() {
42
42
  ]);
43
43
  // Handle Installation
44
44
  if (engine === 'install-opencode') {
45
- const spinner = ora('Installing OpenCode globally...').start();
45
+ const spinner = ora('Installing OpenCode...').start();
46
46
  try {
47
- await execa('npm', ['install', '-g', 'opencode']);
48
- spinner.succeed('OpenCode installed successfully!');
47
+ // Try global install first
48
+ spinner.text = 'Attempting global install...';
49
+ await execa('npm', ['install', '-g', 'opencode-ai']);
50
+ spinner.succeed('OpenCode installed globally!');
49
51
  engine = 'opencode';
50
52
  }
51
53
  catch (e) {
52
- spinner.fail('Installation failed.');
53
- console.log(chalk.yellow('⚠️ We could not install OpenCode automatically (permission error?).'));
54
- console.log(chalk.yellow('Please run this command manually:'));
55
- console.log(chalk.bold('npm install -g opencode'));
56
- console.log(chalk.yellow('\nOr use the official install script:'));
57
- console.log(chalk.bold('curl -fsSL https://opencode.ai/install | bash'));
58
- return;
54
+ // Fallback to local install
55
+ spinner.text = 'Global install failed. Attempting local install...';
56
+ try {
57
+ await execa('npm', ['install', '--save-dev', 'opencode-ai']);
58
+ spinner.succeed('OpenCode installed locally (devDependencies).');
59
+ engine = 'opencode';
60
+ }
61
+ catch (innerError) {
62
+ spinner.fail('Installation failed.');
63
+ console.log(chalk.yellow('⚠️ We could not install OpenCode automatically.'));
64
+ console.log(chalk.yellow('Please run one of these commands manually:'));
65
+ console.log(chalk.bold(' npm install -g opencode-ai'));
66
+ console.log(chalk.bold(' npm install --save-dev opencode-ai'));
67
+ return;
68
+ }
59
69
  }
60
70
  }
61
71
  // 3. Verify Auth (Stub for now)
@@ -62,6 +62,7 @@ export async function reviewCommand() {
62
62
  // console.log("Sending prompt to OpenCode...");
63
63
  const { stdout } = await execa('opencode', ['run', prompt], {
64
64
  input: '',
65
+ preferLocal: true,
65
66
  env: { ...process.env, CI: 'true', NO_COLOR: 'true' }
66
67
  });
67
68
  // console.log("Got response length:", stdout.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "husky-ai",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Zero-config AI code review hook for git commits",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",