-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathmain.ts
More file actions
34 lines (29 loc) · 1.52 KB
/
Copy pathmain.ts
File metadata and controls
34 lines (29 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Agent, setGlobalDispatcher } from 'undici';
/*
* TODO(#1198): remove when fetch over HTTP/2 is safe on Node 26. Remove when all
* of these are true:
* - nodejs/node no longer creates an orphan ClientHttp2Stream when a client
* session gets HEADERS for a stream id it already reset. Repro: abort a fetch
* before its response headers, then idle 4s on Node 26. Fixed when the
* process survives.
* - modelcontextprotocol/typescript-sdk#2526 is closed.
* - pi-coding-agent's CLI drops `allowH2: false` from its http-dispatcher.
* Same workaround as pi's CLI and typescript-sdk#2526: HTTP/1.1 only.
*/
setGlobalDispatcher(new Agent({ allowH2: false }));
import { runCli } from '@cli';
import { recoverOrphanedSettingsBackups } from '@shared/claude-settings';
// Heal any .claude/settings backup a previous interrupted run left orphaned,
// before anything else reads Claude settings — conflict detection, OAuth, and
// the agent all need to see the user's real settings file. The install dir is
// read directly from argv/env because yargs hasn't parsed yet.
recoverOrphanedSettingsBackups(resolveInstallDir());
function resolveInstallDir(): string {
const args = process.argv.slice(2);
const flagIndex = args.indexOf('--install-dir');
if (flagIndex !== -1 && args[flagIndex + 1]) return args[flagIndex + 1];
const inline = args.find((a) => a.startsWith('--install-dir='));
if (inline) return inline.slice('--install-dir='.length);
return process.env.POSTHOG_WIZARD_INSTALL_DIR ?? process.cwd();
}
runCli();