Skip to content

Commit e6b725f

Browse files
committed
fix(claude-code): update init.js to use v2 API (installClaudeHooks/uninstallClaudeHooks)
runSetupWizard and runRemove were removed in the Trace v2 refactor. Export the v2 equivalents from index.ts and update init.js to call them. Strip stale v1-only flags (--pd, --proxy, --banner) from the CLI surface.
1 parent b83eca3 commit e6b725f

3 files changed

Lines changed: 21 additions & 47 deletions

File tree

packages/claude-code/bin/init.js

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,46 @@
11
#!/usr/bin/env node
22

3-
import { runSetupWizard, runRemove } from "flight-proxy";
3+
import { installClaudeHooks, uninstallClaudeHooks } from "flight-proxy";
44

55
const 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
1010
Subcommands:
11-
init Run the Flight setup wizard
11+
init Install Flight hooks and slash commands
1212
1313
Options:
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
2217
See 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-
*/
2920
function 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

7642
async 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

10376
main().catch((err) => {

packages/claude-code/test/init.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("@flight/claude-code bin/init.js", () => {
5858
mkdirSync(claudeDir, { recursive: true });
5959
writeFileSync(join(claudeDir, "settings.json"), JSON.stringify({}));
6060

61-
const flags = ["init", "--hooks", "--no-proxy", "--slash-commands", "--no-pd", "--no-banner"];
61+
const flags = ["init"];
6262
const env = { HOME: tmpHome };
6363

6464
// First run

packages/flight-proxy/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
export * from "./schema/trace-v2.js";
33
export { createFlightClient } from "./sdk.js";
44
export type { FlightClient, FlightClientOptions, RecordOptions } from "./sdk.js";
5+
export { installClaudeHooks, uninstallClaudeHooks } from "./init.js";

0 commit comments

Comments
 (0)