archondev 2.18.7 → 2.18.8

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.
@@ -1110,7 +1110,8 @@ async function promptForDeliverableTarget(prompt, requirements, references) {
1110
1110
  async function resolveProfileId(authId, accessToken) {
1111
1111
  try {
1112
1112
  const supabase = createAuthedSupabaseClient(SUPABASE_URL, SUPABASE_ANON_KEY, accessToken);
1113
- const { data, error } = await supabase.from("user_profiles").select("id").eq("auth_id", authId).single();
1113
+ const { data: rawData, error } = await supabase.from("user_profiles").select("id").eq("auth_id", authId).single();
1114
+ const data = rawData;
1114
1115
  if (error || !data?.id) return null;
1115
1116
  return data.id;
1116
1117
  } catch {
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  listLocalAtoms,
8
8
  loadAtom
9
- } from "./chunk-ESSNYHC7.js";
9
+ } from "./chunk-AFC2XMZS.js";
10
10
  import {
11
11
  loadConfig
12
12
  } from "./chunk-SVU7MLG6.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  listLocalAtoms
3
- } from "./chunk-ESSNYHC7.js";
3
+ } from "./chunk-AFC2XMZS.js";
4
4
 
5
5
  // src/cli/list.ts
6
6
  import chalk from "chalk";
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  UsageRecorder,
8
8
  loadAtom
9
- } from "./chunk-ESSNYHC7.js";
9
+ } from "./chunk-AFC2XMZS.js";
10
10
  import {
11
11
  transitionAtom
12
12
  } from "./chunk-5CFGPXQ3.js";
@@ -4793,7 +4793,7 @@ function createPrompt() {
4793
4793
  }
4794
4794
  async function execute(atomId, options) {
4795
4795
  if (options.parallel && options.parallel.length > 0) {
4796
- const { parallelExecute } = await import("./parallel-U3COBCHB.js");
4796
+ const { parallelExecute } = await import("./parallel-NXSICGS5.js");
4797
4797
  const allAtomIds = [atomId, ...options.parallel];
4798
4798
  await parallelExecute(allAtomIds, { skipGates: options.skipGates === true });
4799
4799
  return;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  execute
3
- } from "./chunk-MRRA3QDP.js";
3
+ } from "./chunk-SLUOXPMX.js";
4
4
  import "./chunk-EBHHIUCB.js";
5
- import "./chunk-ESSNYHC7.js";
5
+ import "./chunk-AFC2XMZS.js";
6
6
  import "./chunk-5CFGPXQ3.js";
7
7
  import "./chunk-5BYCJAFM.js";
8
8
  import "./chunk-HJARQDQR.js";
package/dist/index.js CHANGED
@@ -46,13 +46,13 @@ import {
46
46
  parallelRunWaves,
47
47
  parallelSchedule,
48
48
  parallelStatus
49
- } from "./chunk-ICSHS6BW.js";
49
+ } from "./chunk-BPYTLJOS.js";
50
50
  import {
51
51
  DependencyParser,
52
52
  EnvironmentConfigLoader,
53
53
  EnvironmentValidator,
54
54
  execute
55
- } from "./chunk-MRRA3QDP.js";
55
+ } from "./chunk-SLUOXPMX.js";
56
56
  import {
57
57
  cloudCancel,
58
58
  cloudLogs,
@@ -60,12 +60,12 @@ import {
60
60
  } from "./chunk-EBHHIUCB.js";
61
61
  import {
62
62
  list
63
- } from "./chunk-YFCC6QEY.js";
63
+ } from "./chunk-HANCO7VL.js";
64
64
  import {
65
65
  listLocalAtoms,
66
66
  loadAtom,
67
67
  plan
68
- } from "./chunk-ESSNYHC7.js";
68
+ } from "./chunk-AFC2XMZS.js";
69
69
  import "./chunk-5CFGPXQ3.js";
70
70
  import "./chunk-5BYCJAFM.js";
71
71
  import "./chunk-HJARQDQR.js";
@@ -1199,8 +1199,12 @@ function extractTechStackHints(message) {
1199
1199
  if (/typescript|\.ts\b/i.test(message)) hints.language = "typescript";
1200
1200
  else if (/javascript|\.js\b/i.test(message)) hints.language = "javascript";
1201
1201
  else if (/python|\.py\b/i.test(message)) hints.language = "python";
1202
- else if (/go(lang)?|\.go\b/i.test(message)) hints.language = "go";
1203
- else if (/rust|\.rs\b/i.test(message)) hints.language = "rust";
1202
+ else if (/\bgolang\b|\.go\b/i.test(message)) hints.language = "go";
1203
+ else if (/\bgo\b/i.test(message)) {
1204
+ if (/\bgo (lang|language|backend|server|api|service|cli)\b/i.test(message) || /\bin go\b/i.test(message)) {
1205
+ hints.language = "go";
1206
+ }
1207
+ } else if (/rust|\.rs\b/i.test(message)) hints.language = "rust";
1204
1208
  if (/next\.?js|next/i.test(message)) hints.framework = "nextjs";
1205
1209
  else if (/react/i.test(message)) hints.framework = "react";
1206
1210
  else if (/vue/i.test(message)) hints.framework = "vue";
@@ -2771,7 +2775,22 @@ async function start(options = {}) {
2771
2775
  }
2772
2776
  if (currentTier === "CREDITS" && config.accessToken) {
2773
2777
  try {
2774
- const usageStats = config.userId ? await fetchCreditsUsageStats(config.accessToken, config.userId) : null;
2778
+ const resolvedAuthId = await resolveAuthIdFromToken(config.accessToken, config.userId);
2779
+ if (resolvedAuthId && !config.userId) {
2780
+ await saveConfig({ ...config, userId: resolvedAuthId });
2781
+ }
2782
+ let usageStats = resolvedAuthId ? await fetchCreditsUsageStats(config.accessToken, resolvedAuthId) : null;
2783
+ const usageStatsUnavailable = !usageStats;
2784
+ if (!usageStats) {
2785
+ usageStats = {
2786
+ balance: 0,
2787
+ usedThisPeriod: 0,
2788
+ byModel: [],
2789
+ periodStart: void 0,
2790
+ periodSource: void 0,
2791
+ lastCreditPurchaseAt: null
2792
+ };
2793
+ }
2775
2794
  if (usageStats) {
2776
2795
  console.log();
2777
2796
  console.log(chalk6.bold("\u{1F4B0} Credits Balance"));
@@ -2789,15 +2808,20 @@ async function start(options = {}) {
2789
2808
  } else {
2790
2809
  console.log(chalk6.dim(" No usage recorded since last top-up."));
2791
2810
  }
2811
+ console.log();
2812
+ console.log(chalk6.dim(" Model Usage:"));
2792
2813
  if (usageStats.byModel && usageStats.byModel.length > 0) {
2793
- console.log();
2794
- console.log(chalk6.dim(" Model Usage:"));
2795
2814
  for (const model of usageStats.byModel) {
2796
2815
  const modelName = model.model.length > 32 ? model.model.slice(0, 29) + "..." : model.model;
2797
2816
  console.log(chalk6.dim(` ${modelName.padEnd(34)} $${model.cost.toFixed(4)}`));
2798
2817
  }
2818
+ } else {
2819
+ console.log(chalk6.dim(` ${"No usage yet".padEnd(34)} $0.0000`));
2799
2820
  }
2800
2821
  console.log(chalk6.dim("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"));
2822
+ if (usageStatsUnavailable) {
2823
+ console.log(chalk6.dim("Usage details may be delayed. Run `archon credits` to refresh."));
2824
+ }
2801
2825
  if (usageStats.balance < 5) {
2802
2826
  console.log(chalk6.yellow(`\u26A0\uFE0F Low balance! Add credits: `) + chalk6.bold(`archon credits add`));
2803
2827
  } else {
@@ -2819,7 +2843,7 @@ async function start(options = {}) {
2819
2843
  console.log(` ${chalk6.cyan("2")}) Switch to Managed Plan (no keys needed)`);
2820
2844
  console.log(` ${chalk6.cyan("3")}) Continue on Free tier`);
2821
2845
  console.log();
2822
- const choice = await promptWithCommands("What would you like to do?");
2846
+ const choice = await promptWithCommands("What would you like to do?", { allowMultiline: true });
2823
2847
  switch (choice) {
2824
2848
  case "1":
2825
2849
  const { handleTierSetup: handleTierSetup2 } = await import("./tier-selection-426HA765.js");
@@ -2915,6 +2939,20 @@ function formatTierName(tier) {
2915
2939
  return tier;
2916
2940
  }
2917
2941
  }
2942
+ async function resolveAuthIdFromToken(accessToken, existingAuthId) {
2943
+ if (existingAuthId) return existingAuthId;
2944
+ try {
2945
+ const { SUPABASE_URL: SUPABASE_URL2, SUPABASE_ANON_KEY: SUPABASE_ANON_KEY2 } = await import("./constants-XDIWFFPN.js");
2946
+ const { createClient: createClient2 } = await import("@supabase/supabase-js");
2947
+ const client = createClient2(SUPABASE_URL2, SUPABASE_ANON_KEY2, {
2948
+ global: { headers: { Authorization: `Bearer ${accessToken}` } }
2949
+ });
2950
+ const { data: { user } } = await client.auth.getUser();
2951
+ return user?.id ?? null;
2952
+ } catch {
2953
+ return null;
2954
+ }
2955
+ }
2918
2956
  async function fetchCreditsUsageStats(accessToken, authId) {
2919
2957
  try {
2920
2958
  const { API_URL: API_URL3 } = await import("./constants-XDIWFFPN.js");
@@ -2943,16 +2981,19 @@ async function fetchCreditsUsageStatsFromSupabase(accessToken, authId) {
2943
2981
  const { SUPABASE_URL: SUPABASE_URL2, SUPABASE_ANON_KEY: SUPABASE_ANON_KEY2 } = await import("./constants-XDIWFFPN.js");
2944
2982
  const { createAuthedSupabaseClient: createAuthedSupabaseClient2 } = await import("./client-PHW2C2HB.js");
2945
2983
  const supabase = createAuthedSupabaseClient2(SUPABASE_URL2, SUPABASE_ANON_KEY2, accessToken);
2946
- const { data: profile, error: profileError } = await supabase.from("user_profiles").select("id, credit_balance_cents").eq("auth_id", authId).single();
2984
+ const { data: rawProfile, error: profileError } = await supabase.from("user_profiles").select("id, credit_balance_cents").eq("auth_id", authId).single();
2985
+ const profile = rawProfile;
2947
2986
  if (profileError || !profile?.id) {
2948
2987
  return null;
2949
2988
  }
2950
- const { data: lastPurchase } = await supabase.from("credit_purchases").select("created_at").eq("user_id", profile.id).eq("status", "completed").order("created_at", { ascending: false }).limit(1).maybeSingle();
2989
+ const { data: rawLastPurchase } = await supabase.from("credit_purchases").select("created_at").eq("user_id", profile.id).eq("status", "completed").order("created_at", { ascending: false }).limit(1).maybeSingle();
2990
+ const lastPurchase = rawLastPurchase;
2951
2991
  const now = /* @__PURE__ */ new Date();
2952
2992
  const defaultStart = new Date(now.getFullYear(), now.getMonth(), 1).toISOString();
2953
2993
  const periodStart = lastPurchase?.created_at ?? defaultStart;
2954
2994
  const periodSource = lastPurchase?.created_at ? "credit_purchase" : "month";
2955
- const { data: usageRows } = await supabase.from("token_usage").select("model, marked_up_cost, total_cents, created_at").eq("user_id", profile.id).gte("created_at", periodStart);
2995
+ const { data: rawUsageRows } = await supabase.from("token_usage").select("model, marked_up_cost, total_cents, created_at").eq("user_id", profile.id).gte("created_at", periodStart);
2996
+ const usageRows = rawUsageRows;
2956
2997
  const byModelMap = /* @__PURE__ */ new Map();
2957
2998
  let usedThisPeriod = 0;
2958
2999
  for (const row of usageRows ?? []) {
@@ -3108,7 +3149,7 @@ async function handleNewProject(cwd, _state) {
3108
3149
  console.log(chalk6.bold("\u{1F389} Starting a new project? Great!\n"));
3109
3150
  console.log(chalk6.dim("Answer as much or as little as you want \u2014 you can always refine later."));
3110
3151
  console.log(chalk6.dim('Type "just start" or "skip" to use defaults.\n'));
3111
- const initialResponse = await promptWithCommands("What do you want to do?");
3152
+ const initialResponse = await promptWithCommands("What do you want to do?", { allowMultiline: true });
3112
3153
  if (!initialResponse.trim()) {
3113
3154
  console.log(chalk6.yellow("\nNo response provided. Showing options...\n"));
3114
3155
  await showNewProjectMenu(cwd);
@@ -3127,7 +3168,7 @@ async function handleNewProject(cwd, _state) {
3127
3168
  }
3128
3169
  if (intent.mode === "ad_hoc" && intent.confidence >= 0.7) {
3129
3170
  console.log(chalk6.dim("\n> Got it! Creating a task for this...\n"));
3130
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3171
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3131
3172
  await plan2(initialResponse, {});
3132
3173
  return;
3133
3174
  }
@@ -3151,7 +3192,7 @@ async function handleNewProject(cwd, _state) {
3151
3192
  break;
3152
3193
  case "2":
3153
3194
  console.log(chalk6.dim("\n> Creating a task for this...\n"));
3154
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3195
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3155
3196
  await plan2(initialResponse, {});
3156
3197
  break;
3157
3198
  case "3":
@@ -3181,7 +3222,7 @@ async function showNewProjectMenu(cwd) {
3181
3222
  case "3": {
3182
3223
  const description = await prompt("Describe what you want to do");
3183
3224
  if (description.trim()) {
3184
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3225
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3185
3226
  await plan2(description, {});
3186
3227
  }
3187
3228
  break;
@@ -3247,7 +3288,7 @@ async function runExploreFlow(cwd) {
3247
3288
  case "1": {
3248
3289
  const description = await prompt("Describe what you want to do");
3249
3290
  if (description.trim()) {
3250
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3291
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3251
3292
  await plan2(description, {});
3252
3293
  }
3253
3294
  break;
@@ -3506,7 +3547,7 @@ ${state.forbiddenPatterns?.length ? `- **Forbidden patterns:** ${state.forbidden
3506
3547
  if (continueChoice) {
3507
3548
  const description = await prompt("Describe what you want to build first");
3508
3549
  if (description.trim()) {
3509
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3550
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3510
3551
  await plan2(description, {});
3511
3552
  }
3512
3553
  }
@@ -3544,7 +3585,7 @@ async function handleAdaptExisting(cwd, state) {
3544
3585
  console.log(chalk6.dim("I can analyze your codebase and adapt the governance files to match your structure."));
3545
3586
  console.log(chalk6.dim("This helps me understand your architecture without changing any code.\n"));
3546
3587
  }
3547
- const response = await promptWithCommands("What would you like to do?");
3588
+ const response = await promptWithCommands("What would you like to do?", { allowMultiline: true });
3548
3589
  if (response.toLowerCase() === "q" || response.toLowerCase() === "quit") {
3549
3590
  process.exit(0);
3550
3591
  }
@@ -3560,7 +3601,7 @@ async function handleAdaptExisting(cwd, state) {
3560
3601
  }
3561
3602
  if (intent.mode === "ad_hoc" && intent.confidence >= 0.7) {
3562
3603
  console.log(chalk6.dim("\n> Got it! Creating a task for this...\n"));
3563
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3604
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3564
3605
  await plan2(response, {});
3565
3606
  return;
3566
3607
  }
@@ -3591,7 +3632,7 @@ async function showAdaptExistingMenu(cwd, state) {
3591
3632
  case "2": {
3592
3633
  const description = await prompt("Describe what you want to do");
3593
3634
  if (description.trim()) {
3594
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3635
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3595
3636
  await plan2(description, {});
3596
3637
  }
3597
3638
  break;
@@ -3759,18 +3800,18 @@ async function showReviewProgress(cwd) {
3759
3800
  }
3760
3801
  }
3761
3802
  async function planTask() {
3762
- const { plan: plan2 } = await import("./plan-4RIHWWZG.js");
3803
+ const { plan: plan2 } = await import("./plan-6AZ3U2DA.js");
3763
3804
  const description = await prompt("Describe what you want to build");
3764
3805
  if (description.trim()) {
3765
3806
  await plan2(description, {});
3766
3807
  }
3767
3808
  }
3768
3809
  async function listAtoms() {
3769
- const { list: list2 } = await import("./list-BJCKDRG4.js");
3810
+ const { list: list2 } = await import("./list-QWQ4QBKM.js");
3770
3811
  await list2({});
3771
3812
  }
3772
3813
  async function executeNext() {
3773
- const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-4RIHWWZG.js");
3814
+ const { listLocalAtoms: listLocalAtoms2 } = await import("./plan-6AZ3U2DA.js");
3774
3815
  const { analyzeProject, getComplexityDescription, getModeDescription } = await import("./orchestration-HIF3KP25.js");
3775
3816
  const { loadExecutionPreferences } = await import("./preferences-I6WETXOI.js");
3776
3817
  const cwd = process.cwd();
@@ -3841,11 +3882,11 @@ async function executeNext() {
3841
3882
  }
3842
3883
  }
3843
3884
  if (selectedMode === "parallel-cloud") {
3844
- const { parallelExecuteCloud: parallelExecuteCloud2 } = await import("./parallel-U3COBCHB.js");
3885
+ const { parallelExecuteCloud: parallelExecuteCloud2 } = await import("./parallel-NXSICGS5.js");
3845
3886
  await parallelExecuteCloud2(runIds);
3846
3887
  return;
3847
3888
  }
3848
- const { parallelExecute } = await import("./parallel-U3COBCHB.js");
3889
+ const { parallelExecute } = await import("./parallel-NXSICGS5.js");
3849
3890
  await parallelExecute(runIds);
3850
3891
  return;
3851
3892
  }
@@ -3853,7 +3894,7 @@ async function executeNext() {
3853
3894
  const atomId = await prompt("Enter atom ID to execute (or press Enter for first pending)");
3854
3895
  const targetId = atomId.trim() || pendingAtoms[0]?.id;
3855
3896
  if (targetId) {
3856
- const { execute: execute2 } = await import("./execute-OTW55P2Q.js");
3897
+ const { execute: execute2 } = await import("./execute-VGBCOD5W.js");
3857
3898
  await execute2(targetId, {});
3858
3899
  } else {
3859
3900
  console.log(chalk6.yellow("No atom to execute."));
@@ -3973,9 +4014,41 @@ function prompt(question) {
3973
4014
  });
3974
4015
  });
3975
4016
  }
3976
- async function promptWithCommands(question) {
4017
+ function promptMultiline(question, idleMs = 250) {
4018
+ return new Promise((resolve) => {
4019
+ const rl = readline.createInterface({
4020
+ input: process.stdin,
4021
+ output: process.stdout
4022
+ });
4023
+ const lines = [];
4024
+ let timer = null;
4025
+ const finish = () => {
4026
+ if (timer) clearTimeout(timer);
4027
+ rl.close();
4028
+ resolve(lines.join("\n").trimEnd());
4029
+ };
4030
+ const scheduleFinish = () => {
4031
+ if (timer) clearTimeout(timer);
4032
+ timer = setTimeout(finish, idleMs);
4033
+ };
4034
+ rl.on("line", (line) => {
4035
+ lines.push(line);
4036
+ scheduleFinish();
4037
+ });
4038
+ rl.on("SIGINT", () => {
4039
+ rl.close();
4040
+ process.exit(0);
4041
+ });
4042
+ rl.setPrompt(`${chalk6.cyan("?")} ${question}: `);
4043
+ rl.prompt();
4044
+ });
4045
+ }
4046
+ async function promptWithCommands(question, options = {}) {
3977
4047
  while (true) {
3978
- const answer = await prompt(question);
4048
+ const answer = options.allowMultiline ? await promptMultiline(question) : await prompt(question);
4049
+ if (options.allowMultiline && answer.includes("\n")) {
4050
+ return answer;
4051
+ }
3979
4052
  const handled = await handleInSessionCommand(answer);
3980
4053
  if (!handled) {
3981
4054
  return answer;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  list
3
- } from "./chunk-YFCC6QEY.js";
4
- import "./chunk-ESSNYHC7.js";
3
+ } from "./chunk-HANCO7VL.js";
4
+ import "./chunk-AFC2XMZS.js";
5
5
  import "./chunk-5CFGPXQ3.js";
6
6
  import "./chunk-5BYCJAFM.js";
7
7
  import "./chunk-HJARQDQR.js";
@@ -6,9 +6,9 @@ import {
6
6
  parallelRunWaves,
7
7
  parallelSchedule,
8
8
  parallelStatus
9
- } from "./chunk-ICSHS6BW.js";
9
+ } from "./chunk-BPYTLJOS.js";
10
10
  import "./chunk-EBHHIUCB.js";
11
- import "./chunk-ESSNYHC7.js";
11
+ import "./chunk-AFC2XMZS.js";
12
12
  import "./chunk-5CFGPXQ3.js";
13
13
  import "./chunk-5BYCJAFM.js";
14
14
  import "./chunk-HJARQDQR.js";
@@ -3,7 +3,7 @@ import {
3
3
  loadAtom,
4
4
  parseAtomDescription,
5
5
  plan
6
- } from "./chunk-ESSNYHC7.js";
6
+ } from "./chunk-AFC2XMZS.js";
7
7
  import "./chunk-5CFGPXQ3.js";
8
8
  import "./chunk-5BYCJAFM.js";
9
9
  import "./chunk-HJARQDQR.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archondev",
3
- "version": "2.18.7",
3
+ "version": "2.18.8",
4
4
  "description": "Local-first AI-powered development governance system",
5
5
  "main": "dist/index.js",
6
6
  "bin": {