flightdesk 0.2.2 → 0.2.4

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.
Files changed (3) hide show
  1. package/main.js +55 -30
  2. package/main.js.map +2 -2
  3. package/package.json +1 -1
package/main.js CHANGED
@@ -3059,9 +3059,6 @@ function loadConfig() {
3059
3059
  if (fs.existsSync(CONFIG_FILE)) {
3060
3060
  const content = fs.readFileSync(CONFIG_FILE, "utf-8");
3061
3061
  const parsed = JSON.parse(content);
3062
- if (parsed.organizations?.[0]?.apiKey) {
3063
- return migrateOldConfig(parsed);
3064
- }
3065
3062
  return {
3066
3063
  organizations: [],
3067
3064
  repoMapping: {},
@@ -3076,22 +3073,6 @@ function loadConfig() {
3076
3073
  repoMapping: {}
3077
3074
  };
3078
3075
  }
3079
- function migrateOldConfig(oldConfig) {
3080
- console.log("\u{1F4E6} Migrating config to new format...");
3081
- const defaultOrg = oldConfig.defaultOrganization ? oldConfig.organizations.find((o) => o.id === oldConfig.defaultOrganization) : oldConfig.organizations[0];
3082
- const newConfig = {
3083
- apiKey: defaultOrg?.apiKey,
3084
- activeOrganization: defaultOrg?.id,
3085
- organizations: oldConfig.organizations.map((o) => ({
3086
- id: o.id,
3087
- name: o.name
3088
- })),
3089
- repoMapping: oldConfig.repoMapping || {}
3090
- };
3091
- saveConfig(newConfig);
3092
- console.log("\u2705 Config migrated successfully");
3093
- return newConfig;
3094
- }
3095
3076
  function saveConfig(config) {
3096
3077
  fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
3097
3078
  }
@@ -3162,6 +3143,9 @@ var readline = __toESM(require("readline"));
3162
3143
  // apps/cli/src/lib/api.ts
3163
3144
  var FlightDeskAPI = class _FlightDeskAPI {
3164
3145
  constructor(config, org2) {
3146
+ if (!config.apiKey) {
3147
+ throw new Error("API key is required. Run: flightdesk login");
3148
+ }
3165
3149
  this.apiUrl = getApiUrl();
3166
3150
  this.apiKey = config.apiKey;
3167
3151
  this.organizationId = org2.id;
@@ -3173,6 +3157,12 @@ var FlightDeskAPI = class _FlightDeskAPI {
3173
3157
  return new _FlightDeskAPI(config, org2);
3174
3158
  }
3175
3159
  async graphql(query, variables) {
3160
+ const verbose = process.env.FLIGHTDESK_DEBUG === "1";
3161
+ if (verbose) {
3162
+ console.log("\n--- GraphQL Request ---");
3163
+ console.log("URL:", `${this.apiUrl}/graphql`);
3164
+ console.log("Variables:", JSON.stringify(variables, null, 2));
3165
+ }
3176
3166
  const response = await fetch(`${this.apiUrl}/graphql`, {
3177
3167
  method: "POST",
3178
3168
  headers: {
@@ -3182,9 +3172,19 @@ var FlightDeskAPI = class _FlightDeskAPI {
3182
3172
  body: JSON.stringify({ query, variables })
3183
3173
  });
3184
3174
  if (!response.ok) {
3185
- throw new Error(`API request failed: ${response.status} ${response.statusText}`);
3175
+ const body = await response.text();
3176
+ if (verbose) {
3177
+ console.log("--- Error Response ---");
3178
+ console.log("Status:", response.status, response.statusText);
3179
+ console.log("Body:", body);
3180
+ }
3181
+ throw new Error(`API request failed: ${response.status} ${response.statusText}${verbose ? "" : " (set FLIGHTDESK_DEBUG=1 for details)"}`);
3186
3182
  }
3187
3183
  const result = await response.json();
3184
+ if (verbose) {
3185
+ console.log("--- Response ---");
3186
+ console.log(JSON.stringify(result, null, 2));
3187
+ }
3188
3188
  if (result.errors && result.errors.length > 0) {
3189
3189
  throw new Error(`GraphQL error: ${result.errors.map((e) => e.message).join(", ")}`);
3190
3190
  }
@@ -3587,12 +3587,21 @@ var PersistentBrowser = class {
3587
3587
  this.page = null;
3588
3588
  this.headless = headless;
3589
3589
  }
3590
+ /**
3591
+ * Get page, throwing if not initialized
3592
+ */
3593
+ get activePage() {
3594
+ if (!this.page) {
3595
+ throw new Error("Browser not initialized. Call init() first.");
3596
+ }
3597
+ return this.page;
3598
+ }
3590
3599
  /**
3591
3600
  * Initialize the browser context (if not already initialized)
3592
3601
  */
3593
3602
  async init() {
3594
3603
  if (this.context) return;
3595
- if (!await isPlaywrightAvailable()) {
3604
+ if (!await isPlaywrightAvailable() || !playwright) {
3596
3605
  throw new Error("Playwright not available");
3597
3606
  }
3598
3607
  ensureUserDataDir();
@@ -3617,9 +3626,9 @@ var PersistentBrowser = class {
3617
3626
  async checkAuth() {
3618
3627
  await this.init();
3619
3628
  try {
3620
- await this.page.goto("https://claude.ai/", { waitUntil: "networkidle", timeout: 3e4 });
3621
- await this.page.waitForTimeout(2e3);
3622
- const url = this.page.url();
3629
+ await this.activePage.goto("https://claude.ai/", { waitUntil: "domcontentloaded", timeout: 3e4 });
3630
+ await this.activePage.waitForTimeout(2e3);
3631
+ const url = this.activePage.url();
3623
3632
  console.log(" Final URL:", url);
3624
3633
  return !url.includes("/login") && !url.includes("/oauth") && !url.includes("accounts.google") && url.includes("claude.ai");
3625
3634
  } catch (error) {
@@ -3713,7 +3722,7 @@ async function checkAuth() {
3713
3722
  try {
3714
3723
  const page = await context.newPage();
3715
3724
  page.setDefaultTimeout(3e4);
3716
- await page.goto("https://claude.ai/", { waitUntil: "networkidle", timeout: 3e4 });
3725
+ await page.goto("https://claude.ai/", { waitUntil: "domcontentloaded", timeout: 3e4 });
3717
3726
  await page.waitForTimeout(2e3);
3718
3727
  const url = page.url();
3719
3728
  console.log(" Final URL:", url);
@@ -3776,7 +3785,7 @@ async function scrapeSession(page, sessionUrl, options = {}) {
3776
3785
  const { timeout = 3e4, autoPr = false } = options;
3777
3786
  try {
3778
3787
  page.setDefaultTimeout(timeout);
3779
- await page.goto(sessionUrl, { waitUntil: "networkidle" });
3788
+ await page.goto(sessionUrl, { waitUntil: "domcontentloaded", timeout });
3780
3789
  await page.waitForSelector('[data-testid="conversation-turn"], .code-spinner-animate, button:has-text("Create PR")', {
3781
3790
  timeout: 1e4
3782
3791
  }).catch(() => {
@@ -4015,6 +4024,7 @@ async function registerCommand(taskId, options) {
4015
4024
  let viewUrl = options.viewUrl;
4016
4025
  let teleportId = options.teleportId;
4017
4026
  if (!process.stdin.isTTY) {
4027
+ console.log("\u23F3 Waiting for Claude session output...");
4018
4028
  const input = await readStdin();
4019
4029
  const parsed = parseClaudeOutput(input);
4020
4030
  viewUrl = viewUrl || parsed.viewUrl;
@@ -4060,14 +4070,29 @@ Task ID: ${actualTaskId}`);
4060
4070
  function readStdin() {
4061
4071
  return new Promise((resolve) => {
4062
4072
  let data = "";
4073
+ let resolved = false;
4063
4074
  process.stdin.setEncoding("utf8");
4064
4075
  process.stdin.on("data", (chunk) => {
4065
4076
  data += chunk;
4066
4077
  });
4067
4078
  process.stdin.on("end", () => {
4068
- resolve(data);
4079
+ if (!resolved) {
4080
+ resolved = true;
4081
+ resolve(data);
4082
+ }
4083
+ });
4084
+ process.stdin.on("close", () => {
4085
+ if (!resolved) {
4086
+ resolved = true;
4087
+ resolve(data);
4088
+ }
4069
4089
  });
4070
- setTimeout(() => resolve(data), 100);
4090
+ setTimeout(() => {
4091
+ if (!resolved) {
4092
+ resolved = true;
4093
+ resolve(data);
4094
+ }
4095
+ }, 3e4);
4071
4096
  });
4072
4097
  }
4073
4098
  function parseClaudeOutput(output) {
@@ -5198,7 +5223,7 @@ async function scanClaudeSessions(options) {
5198
5223
  }
5199
5224
 
5200
5225
  // apps/cli/src/commands/project.ts
5201
- async function projectCommand(action, options) {
5226
+ async function projectCommand(action, _options) {
5202
5227
  const { config, org: org2 } = requireActiveOrg();
5203
5228
  const api = FlightDeskAPI.fromConfig(config, org2);
5204
5229
  switch (action) {
@@ -5498,7 +5523,7 @@ async function handleTeardown(api, options) {
5498
5523
 
5499
5524
  // apps/cli/src/main.ts
5500
5525
  var program2 = new Command();
5501
- program2.name("flightdesk").description("FlightDesk CLI - AI task management for Claude Code sessions").version("0.2.2").option("--dev", "Use local development API (localhost:3000)").option("--api <url>", "Use custom API URL");
5526
+ program2.name("flightdesk").description("FlightDesk CLI - AI task management for Claude Code sessions").version("0.2.4").option("--dev", "Use local development API (localhost:3000)").option("--api <url>", "Use custom API URL");
5502
5527
  program2.hook("preAction", () => {
5503
5528
  const opts = program2.opts();
5504
5529
  if (opts.api) {