11#!/usr/bin/env node
22
3- import { runSetupWizard , runRemove } from "flight-proxy" ;
3+ import { installClaudeHooks , uninstallClaudeHooks } from "flight-proxy" ;
44
55const USAGE = `Usage: npx @flight/claude-code init [options]
66
7- Sets up Flight (agent observability ) for Claude Code: installs hooks,
8- slash commands, and optionally wraps MCP servers .
7+ Sets up Flight (agent verification & trust layer ) for Claude Code:
8+ installs hooks and /flight slash commands .
99
1010Subcommands:
11- init Run the Flight setup wizard
11+ init Install Flight hooks and slash commands
1212
1313Options:
14- --hooks, --no-hooks Install/skip Claude Code hooks
15- --proxy, --no-proxy Wrap/skip MCP server proxying
16- --pd, --no-pd Enable/disable progressive disclosure
17- --slash-commands, --no-slash-commands Install/skip /flight slash commands
18- --banner, --no-banner Show/skip the setup banner
19- --remove Uninstall Flight integration
20- --help, -h Show this help
14+ --remove Uninstall Flight integration
15+ --help, -h Show this help
2116
2217See https://github.com/lewisnsmith/flight for full docs.
2318` ;
2419
25- /**
26- * Parse process.argv into subcommand + overrides object.
27- * Returns { subcommand, overrides, remove, help }.
28- */
2920function parseArgs ( argv ) {
3021 const args = argv . slice ( 2 ) ;
3122 let subcommand = null ;
3223 let remove = false ;
3324 let help = false ;
34- const overrides = { } ;
35-
36- let i = 0 ;
37- while ( i < args . length ) {
38- const arg = args [ i ] ;
3925
26+ for ( const arg of args ) {
4027 if ( arg === "--help" || arg === "-h" ) {
4128 help = true ;
4229 } else if ( arg === "--remove" ) {
4330 remove = true ;
44- } else if ( arg === "--hooks" ) {
45- overrides . hooks = true ;
46- } else if ( arg === "--no-hooks" ) {
47- overrides . hooks = false ;
48- } else if ( arg === "--proxy" ) {
49- overrides . proxy = true ;
50- } else if ( arg === "--no-proxy" ) {
51- overrides . proxy = false ;
52- } else if ( arg === "--pd" ) {
53- overrides . pd = true ;
54- } else if ( arg === "--no-pd" ) {
55- overrides . pd = false ;
56- } else if ( arg === "--slash-commands" ) {
57- overrides . slashCommands = true ;
58- } else if ( arg === "--no-slash-commands" ) {
59- overrides . slashCommands = false ;
60- } else if ( arg === "--banner" ) {
61- overrides . banner = true ;
62- } else if ( arg === "--no-banner" ) {
63- overrides . banner = false ;
6431 } else if ( ! arg . startsWith ( "-" ) ) {
6532 subcommand = arg ;
6633 } else {
6734 process . stderr . write ( `Unknown option: ${ arg } \n\n${ USAGE } ` ) ;
6835 process . exit ( 1 ) ;
6936 }
70- i ++ ;
7137 }
7238
73- return { subcommand, overrides , remove, help } ;
39+ return { subcommand, remove, help } ;
7440}
7541
7642async function main ( ) {
77- const { subcommand, overrides , remove, help } = parseArgs ( process . argv ) ;
43+ const { subcommand, remove, help } = parseArgs ( process . argv ) ;
7844
7945 if ( help ) {
8046 process . stdout . write ( USAGE ) ;
@@ -91,13 +57,20 @@ async function main() {
9157 process . exit ( 1 ) ;
9258 }
9359
94- // subcommand === "init"
9560 if ( remove ) {
96- await runRemove ( ) ;
61+ const result = await uninstallClaudeHooks ( ) ;
62+ process . stdout . write (
63+ `Removed Flight hooks from ${ result . settingsPath } \n` +
64+ `Removed slash commands: ${ result . commandsRemoved . join ( ", " ) || "(none)" } \n` ,
65+ ) ;
9766 return ;
9867 }
9968
100- await runSetupWizard ( overrides ) ;
69+ const result = await installClaudeHooks ( ) ;
70+ process . stdout . write (
71+ `Installed ${ result . hooksInstalled . length } hooks into ${ result . settingsPath } \n` +
72+ `Installed slash commands: ${ result . commandsInstalled . map ( ( c ) => "/" + c ) . join ( ", " ) } \n` ,
73+ ) ;
10174}
10275
10376main ( ) . catch ( ( err ) => {
0 commit comments