Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ On first run, LazyShell will guide you through:
```bash
# Open configuration UI
lazyshell config

# Open GitHub page to create a new issue
lazyshell issue
```

### Manual Environment Variables (Optional)
Expand Down
36 changes: 36 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Command } from 'commander';
import { select, text as input, spinner, outro, isCancel, cancel, intro } from '@clack/prompts';
import chalk from 'chalk';
import { execFile } from 'child_process';
import { info, print, runCommand, printWrapped } from './utils';
import { generateCommandStruct, getDefaultModel, getModelFromConfig, type ModelConfig } from './lib/ai';
import { getOrInitializeConfig } from './lib/config';
Expand Down Expand Up @@ -52,6 +53,27 @@ async function refineCommand(currentPrompt: string, command: string): Promise<st
return `former prompt:${currentPrompt} its command is ${command} refining prompt: ${refineText}`;
}

async function openIssuePage(): Promise<void> {
const issueUrl = 'https://github.com/bernoussama/lazyshell/issues/new';
const [command, args] =
process.platform === 'darwin'
? ['open', [issueUrl]]
: process.platform === 'win32'
? ['cmd', ['/c', 'start', '', issueUrl]]
: ['xdg-open', [issueUrl]];
Comment on lines +58 to +63

await new Promise<void>((resolve, reject) => {
execFile(command, args, (error, _stdout, stderr) => {
if (error) {
const details = stderr?.trim() || error.message;
reject(new Error(`Failed to execute browser command: ${details}`));
return;
Comment on lines +66 to +70
}
resolve();
});
});
}

const program = new Command();
program
.version(require('../package.json').version)
Expand Down Expand Up @@ -125,4 +147,18 @@ program
await showConfigUI();
});

program
.command('issue')
.description('Open browser to create a new GitHub issue')
.action(async () => {
try {
await openIssuePage();
await print(chalk.green('Opened issue page in browser.'));
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error(chalk.red(`Failed to open issue page: ${message}`));
process.exit(1);
}
});

program.parse(process.argv);
Loading