mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
refactor: simplify yolo mode implementation by removing env vars
Remove HAPPY_GEMINI_ARGS and HAPPY_GEMINI_COMMAND environment variables. Refactor gemini.ts to export registerGeminiAgent(yolo) function that directly configures args instead of reading from environment.
This commit is contained in:
@@ -81,11 +81,6 @@ See `src/configuration.ts` for all options.
|
||||
- `HAPI_DAEMON_HEARTBEAT_INTERVAL` - Heartbeat interval in ms (default: 60000).
|
||||
- `HAPI_DAEMON_HTTP_TIMEOUT` - HTTP timeout for daemon control in ms (default: 10000).
|
||||
|
||||
### Gemini/Agent
|
||||
|
||||
- `HAPPY_GEMINI_COMMAND` - Gemini executable command (default: gemini).
|
||||
- `HAPPY_GEMINI_ARGS` - Gemini arguments (default: --experimental-acp).
|
||||
|
||||
## Storage
|
||||
|
||||
Data is stored in `~/.hapi/` (or `$HAPI_HOME`):
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import { AgentRegistry } from '@/agent/AgentRegistry';
|
||||
import { AcpSdkBackend } from '@/agent/backends/acp';
|
||||
|
||||
function parseArgs(value?: string): string[] | null {
|
||||
if (!value) return null;
|
||||
const parts = value.split(' ').map((part) => part.trim()).filter(Boolean);
|
||||
return parts.length > 0 ? parts : null;
|
||||
}
|
||||
|
||||
function buildEnv(): Record<string, string> {
|
||||
return Object.keys(process.env).reduce((acc, key) => {
|
||||
const value = process.env[key];
|
||||
@@ -17,16 +11,13 @@ function buildEnv(): Record<string, string> {
|
||||
}, {} as Record<string, string>);
|
||||
}
|
||||
|
||||
const command = process.env.HAPPY_GEMINI_COMMAND
|
||||
|| process.env.GEMINI_ACP_COMMAND
|
||||
|| 'gemini';
|
||||
export function registerGeminiAgent(yolo: boolean): void {
|
||||
const args = ['--experimental-acp'];
|
||||
if (yolo) args.push('--yolo');
|
||||
|
||||
const args = parseArgs(process.env.HAPPY_GEMINI_ARGS)
|
||||
?? parseArgs(process.env.GEMINI_ACP_ARGS)
|
||||
?? ['--experimental-acp'];
|
||||
|
||||
AgentRegistry.register('gemini', () => new AcpSdkBackend({
|
||||
command,
|
||||
args,
|
||||
env: buildEnv()
|
||||
}));
|
||||
AgentRegistry.register('gemini', () => new AcpSdkBackend({
|
||||
command: 'gemini',
|
||||
args,
|
||||
env: buildEnv()
|
||||
}));
|
||||
}
|
||||
|
||||
+2
-11
@@ -157,18 +157,9 @@ import { getCliArgs } from './utils/cliArgs'
|
||||
}
|
||||
}
|
||||
|
||||
if (yolo) {
|
||||
const existingArgs = process.env.HAPPY_GEMINI_ARGS ?? process.env.GEMINI_ACP_ARGS ?? '';
|
||||
if (!existingArgs.includes('--yolo')) {
|
||||
const nextArgs = existingArgs.trim().length > 0
|
||||
? `${existingArgs} --yolo`
|
||||
: '--yolo';
|
||||
process.env.HAPPY_GEMINI_ARGS = nextArgs;
|
||||
}
|
||||
}
|
||||
|
||||
await import('./agent/runners/gemini');
|
||||
const { registerGeminiAgent } = await import('./agent/runners/gemini');
|
||||
const { runAgentSession } = await import('./agent/runners/runAgentSession');
|
||||
registerGeminiAgent(yolo);
|
||||
|
||||
await initializeToken();
|
||||
await authAndSetupMachineIfNeeded();
|
||||
|
||||
Reference in New Issue
Block a user