xray-code 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -140,6 +140,33 @@ program
140
140
  process.exit(1);
141
141
  }
142
142
  });
143
+ // ─── Install (standalone) ───────────────────────────────────────
144
+ program
145
+ .command("install")
146
+ .description("Install XRay hooks and CLAUDE.md in the current project directory")
147
+ .action(async () => {
148
+ const { existsSync, readFileSync } = await import("node:fs");
149
+ const { join } = await import("node:path");
150
+ const { homedir } = await import("node:os");
151
+ // Load config
152
+ const configPath = join(homedir(), ".xray", "config.json");
153
+ if (!existsSync(configPath)) {
154
+ console.error(" Not activated yet. Run 'npx xray-code activate <invite-code>' first.\n");
155
+ process.exit(1);
156
+ }
157
+ const config = JSON.parse(readFileSync(configPath, "utf-8"));
158
+ const client = new client_js_1.XRayClient(config.server, config.apiKey);
159
+ try {
160
+ const health = await client.health();
161
+ console.log(`\n Installing XRay into ${process.cwd()}...\n`);
162
+ (0, install_js_1.installClaude)(process.cwd(), config.server, config.apiKey, config.space || "default", health.symbols, health.uses);
163
+ console.log(`\n Done! Start a new Claude Code session to get ambient code intelligence.\n`);
164
+ }
165
+ catch (e) {
166
+ console.error(` Install failed: ${e}\n`);
167
+ process.exit(1);
168
+ }
169
+ });
143
170
  // ─── Onboarding ─────────────────────────────────────────────────
144
171
  program
145
172
  .command("init [filter]")
package/dist/onboard.js CHANGED
@@ -164,7 +164,20 @@ async function onboard(repoFilter) {
164
164
  await runCommand(foxrefBin, ["snapshot", "--repo", ".", "--out", ".fox/foxref/snapshot.json"], cloneDir);
165
165
  snapSpin.stop("done");
166
166
  // ─── Step 6: Save project config ──────────────────────────────
167
- const apiKey = (0, node_child_process_1.execSync)("openssl rand -hex 32").toString().trim();
167
+ // Preserve API key from prior `xray activate` — don't generate a new one
168
+ const existingConfig = (() => {
169
+ const p = (0, node_path_1.join)((0, node_os_1.homedir)(), ".xray", "config.json");
170
+ if ((0, node_fs_1.existsSync)(p)) {
171
+ try {
172
+ return JSON.parse((0, node_fs_1.readFileSync)(p, "utf-8"));
173
+ }
174
+ catch {
175
+ return {};
176
+ }
177
+ }
178
+ return {};
179
+ })();
180
+ const apiKey = existingConfig.apiKey || (0, node_child_process_1.execSync)("openssl rand -hex 32").toString().trim();
168
181
  const webhookSecret = (0, node_child_process_1.execSync)("openssl rand -hex 32").toString().trim();
169
182
  const configDir = (0, node_path_1.join)(cloneDir, ".xray");
170
183
  if (!(0, node_fs_1.existsSync)(configDir))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xray-code",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "XRay — code intelligence CLI. X-ray your codebase with instant cross-references.",
5
5
  "bin": {
6
6
  "xray": "dist/cli.js"