@oal-sarl/code 6.0.1 → 6.0.3

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 (2) hide show
  1. package/dist/index.js +1220 -1067
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -97,6 +97,44 @@ var init_settings = __esm(() => {
97
97
  };
98
98
  });
99
99
 
100
+ // src/config/codeMd.ts
101
+ import fs from "fs/promises";
102
+ import path from "path";
103
+ async function loadCodeConfig() {
104
+ const codeMdPath = path.join(process.cwd(), "CODE.md");
105
+ try {
106
+ const rawContent = await fs.readFile(codeMdPath, "utf-8");
107
+ return { rawContent };
108
+ } catch {
109
+ return { rawContent: "" };
110
+ }
111
+ }
112
+ async function createCodeConfig() {
113
+ const codeMdPath = path.join(process.cwd(), "CODE.md");
114
+ await fs.writeFile(codeMdPath, DEFAULT_CODE_MD, "utf-8");
115
+ }
116
+ var DEFAULT_CODE_MD = `# CODE.md - Configuration du projet
117
+
118
+ ## Stack technique
119
+ <!-- Ex: TypeScript, Next.js 14, PostgreSQL, Vitest -->
120
+
121
+ ## Commandes
122
+ - dev: \`npm run dev\`
123
+ - test: \`npm test\`
124
+ - build: \`npm run build\`
125
+ - lint: \`npm run lint\`
126
+
127
+ ## Standards de code
128
+ <!-- Ex: 2 espaces, single quotes, camelCase, pas de any TypeScript -->
129
+
130
+ ## Architecture des dossiers
131
+ <!-- Decris la structure et le role de chaque dossier principal -->
132
+
133
+ ## A eviter
134
+ <!-- Actions que Code ne doit PAS faire automatiquement -->
135
+ `;
136
+ var init_codeMd = () => {};
137
+
100
138
  // src/logging/logger.ts
101
139
  function shouldWriteToStderr() {
102
140
  if (IS_CI)
@@ -1999,17 +2037,44 @@ function isMissingQuantizedArtifactError(error) {
1999
2037
  const message = error instanceof Error ? error.message : String(error ?? "");
2000
2038
  return /could not locate file/i.test(message) && /_q4|q4\.onnx|decoder_model_merged_q4/i.test(message);
2001
2039
  }
2002
- async function loadEmbeddedVisionPipeline(pipeline) {
2040
+ function isRetryableLocalModelCacheError(error, modelId) {
2041
+ const message = error instanceof Error ? error.message : String(error ?? "");
2042
+ const normalizedModel = modelId.replace("/", "\\");
2043
+ return /load model from/i.test(message) && (/system error number 13/i.test(message) || /permission denied/i.test(message) || /access is denied/i.test(message)) && (message.includes(MODELS_DIR) || message.includes(normalizedModel));
2044
+ }
2045
+ function getLocalModelCacheDir(modelId) {
2046
+ return path7.join(MODELS_DIR, ...modelId.split("/"));
2047
+ }
2048
+ async function purgeLocalModelCache(modelId) {
2049
+ const localCacheDir = getLocalModelCacheDir(modelId);
2050
+ await fs9.rm(localCacheDir, { recursive: true, force: true }).catch(() => {});
2051
+ }
2052
+ async function loadEmbeddedVisionPipeline(pipeline, purgeCache = purgeLocalModelCache) {
2003
2053
  try {
2004
2054
  return await pipeline("image-to-text", VISION_MODEL_ID, {
2005
2055
  dtype: "q4",
2006
2056
  device: "cpu"
2007
2057
  });
2008
2058
  } catch (error) {
2009
- if (!isMissingQuantizedArtifactError(error)) {
2059
+ if (isRetryableLocalModelCacheError(error, VISION_MODEL_ID)) {
2060
+ logger.warn("vision_pipeline_cache_retry", { modelId: VISION_MODEL_ID, phase: "quantized" });
2061
+ await purgeCache(VISION_MODEL_ID);
2062
+ } else if (!isMissingQuantizedArtifactError(error)) {
2063
+ throw error;
2064
+ } else {
2065
+ logger.warn("vision_pipeline_q4_unavailable", { modelId: VISION_MODEL_ID });
2066
+ }
2067
+ }
2068
+ try {
2069
+ return await pipeline("image-to-text", VISION_MODEL_ID, {
2070
+ device: "cpu"
2071
+ });
2072
+ } catch (error) {
2073
+ if (!isRetryableLocalModelCacheError(error, VISION_MODEL_ID)) {
2010
2074
  throw error;
2011
2075
  }
2012
- logger.warn("vision_pipeline_q4_unavailable", { modelId: VISION_MODEL_ID });
2076
+ logger.warn("vision_pipeline_cache_retry", { modelId: VISION_MODEL_ID });
2077
+ await purgeCache(VISION_MODEL_ID);
2013
2078
  return pipeline("image-to-text", VISION_MODEL_ID, {
2014
2079
  device: "cpu"
2015
2080
  });
@@ -2043,12 +2108,12 @@ function configureLocalModelRuntime(env) {
2043
2108
  env.localModelPath = MODELS_DIR;
2044
2109
  env.allowRemoteModels = true;
2045
2110
  }
2046
- async function downloadModel(modelId, onProgress) {
2111
+ async function downloadModel(modelId, onProgress, loadRuntime = () => import("@huggingface/transformers")) {
2047
2112
  logger.info("model_download_start", { modelId });
2048
2113
  let pipeline;
2049
2114
  let env;
2050
2115
  try {
2051
- ({ pipeline, env } = await import("@huggingface/transformers"));
2116
+ ({ pipeline, env } = await loadRuntime());
2052
2117
  } catch {
2053
2118
  throw new Error("Le runtime local @huggingface/transformers n'est pas disponible. Installe-le pour telecharger les modeles embarques.");
2054
2119
  }
@@ -2063,7 +2128,16 @@ async function downloadModel(modelId, onProgress) {
2063
2128
  };
2064
2129
  }
2065
2130
  if (modelId === EMBED_MODEL_ID) {
2066
- await pipeline("feature-extraction", modelId, { dtype: "q4", device: "cpu" });
2131
+ try {
2132
+ await pipeline("feature-extraction", modelId, { dtype: "q4", device: "cpu" });
2133
+ } catch (error) {
2134
+ if (!isRetryableLocalModelCacheError(error, modelId)) {
2135
+ throw error;
2136
+ }
2137
+ logger.warn("embedding_pipeline_cache_retry", { modelId });
2138
+ await purgeLocalModelCache(modelId);
2139
+ await pipeline("feature-extraction", modelId, { dtype: "q4", device: "cpu" });
2140
+ }
2067
2141
  } else {
2068
2142
  await loadEmbeddedVisionPipeline(pipeline);
2069
2143
  }
@@ -7492,6 +7566,25 @@ var init_skillLoader = __esm(() => {
7492
7566
  MODULE_DIR = path17.dirname(fileURLToPath(import.meta.url));
7493
7567
  });
7494
7568
 
7569
+ // src/productMeta.ts
7570
+ import fs16 from "fs";
7571
+ function readPackageVersion() {
7572
+ try {
7573
+ const raw = fs16.readFileSync(new URL("../package.json", import.meta.url), "utf-8");
7574
+ const parsed = JSON.parse(raw);
7575
+ if (typeof parsed.version === "string" && parsed.version.trim()) {
7576
+ return parsed.version.trim();
7577
+ }
7578
+ } catch {}
7579
+ return "0.0.0";
7580
+ }
7581
+ var PRODUCT_NAME = "Code", PRODUCT_VERSION, PRODUCT_MAJOR_LABEL, PRODUCT_SHELL_LABEL;
7582
+ var init_productMeta = __esm(() => {
7583
+ PRODUCT_VERSION = readPackageVersion();
7584
+ PRODUCT_MAJOR_LABEL = `v${PRODUCT_VERSION.split(".")[0] ?? "0"}`;
7585
+ PRODUCT_SHELL_LABEL = `${PRODUCT_NAME} ${PRODUCT_MAJOR_LABEL}`;
7586
+ });
7587
+
7495
7588
  // src/ui/theme.ts
7496
7589
  function getPhaseColor(phase) {
7497
7590
  switch (phase) {
@@ -7535,255 +7628,31 @@ var init_theme = __esm(() => {
7535
7628
  };
7536
7629
  });
7537
7630
 
7538
- // src/ui/wizard/WizardStep1Welcome.tsx
7539
- import { Box, Text, useInput } from "ink";
7540
- import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
7541
- function WizardStep1Welcome({ diagnostics, onNext }) {
7542
- useInput((_, key) => {
7543
- if (key.return)
7544
- onNext();
7545
- });
7546
- return /* @__PURE__ */ jsxDEV(Box, {
7547
- flexDirection: "column",
7548
- gap: 1,
7549
- children: [
7550
- /* @__PURE__ */ jsxDEV(Text, {
7551
- color: codeTheme.text,
7552
- children: "Code is OAL SARL's terminal-native coding shell with multi-session runs, guided execution, visual artifacts and guarded approvals."
7553
- }, undefined, false, undefined, this),
7554
- /* @__PURE__ */ jsxDEV(Box, {
7555
- flexDirection: "column",
7556
- marginTop: 1,
7557
- children: [
7558
- /* @__PURE__ */ jsxDEV(OnboardingMetric, {
7559
- label: "Sessions",
7560
- value: "multi-context shell"
7561
- }, undefined, false, undefined, this),
7562
- /* @__PURE__ */ jsxDEV(OnboardingMetric, {
7563
- label: "Validation",
7564
- value: "judge + transactions"
7565
- }, undefined, false, undefined, this),
7566
- /* @__PURE__ */ jsxDEV(OnboardingMetric, {
7567
- label: "Local features",
7568
- value: "vision + semantic index"
7569
- }, undefined, false, undefined, this),
7570
- /* @__PURE__ */ jsxDEV(OnboardingMetric, {
7571
- label: "Workflow",
7572
- value: "skills + approvals + history"
7573
- }, undefined, false, undefined, this)
7574
- ]
7575
- }, undefined, true, undefined, this),
7576
- /* @__PURE__ */ jsxDEV(Box, {
7577
- marginTop: 1,
7578
- flexDirection: "column",
7579
- children: [
7580
- /* @__PURE__ */ jsxDEV(Text, {
7581
- color: codeTheme.brandStrong,
7582
- children: "What changes in v6"
7583
- }, undefined, false, undefined, this),
7584
- /* @__PURE__ */ jsxDEV(Text, {
7585
- color: codeTheme.muted,
7586
- children: "Cleaner chat UI, stronger runtime visibility, safer approvals and model-backed planning."
7587
- }, undefined, false, undefined, this)
7588
- ]
7589
- }, undefined, true, undefined, this),
7590
- /* @__PURE__ */ jsxDEV(Box, {
7591
- marginTop: 1,
7592
- flexDirection: "column",
7593
- children: [
7594
- /* @__PURE__ */ jsxDEV(Text, {
7595
- color: codeTheme.brandStrong,
7596
- children: "Platform diagnostics"
7597
- }, undefined, false, undefined, this),
7598
- diagnostics ? /* @__PURE__ */ jsxDEV(Fragment, {
7599
- children: [
7600
- /* @__PURE__ */ jsxDEV(OnboardingMetric, {
7601
- label: "Shell",
7602
- value: diagnostics.shellLabel,
7603
- tone: diagnostics.shellSupportsPosix ? "success" : "warning"
7604
- }, undefined, false, undefined, this),
7605
- /* @__PURE__ */ jsxDEV(OnboardingMetric, {
7606
- label: "Warnings",
7607
- value: diagnostics.warnings.length === 0 ? "none" : `${diagnostics.warnings.length} attention point(s)`,
7608
- tone: diagnostics.warnings.length === 0 ? "success" : "warning"
7609
- }, undefined, false, undefined, this)
7610
- ]
7611
- }, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV(Text, {
7612
- color: codeTheme.muted,
7613
- children: "Scanning local shell, sandbox and optional capabilities..."
7614
- }, undefined, false, undefined, this)
7615
- ]
7616
- }, undefined, true, undefined, this),
7617
- /* @__PURE__ */ jsxDEV(OnboardingHint, {
7618
- children: "Press Enter to continue."
7619
- }, undefined, false, undefined, this)
7620
- ]
7621
- }, undefined, true, undefined, this);
7622
- }
7623
- var init_WizardStep1Welcome = __esm(() => {
7624
- init_theme();
7625
- init_wizardHelper();
7626
- });
7627
-
7628
- // src/ui/clipboard.ts
7629
- import { spawnSync as spawnSync2 } from "child_process";
7630
- function tryCommand(command, args) {
7631
- try {
7632
- const result = spawnSync2(command, args, { encoding: "utf-8", windowsHide: true });
7633
- if (result.status === 0 && typeof result.stdout === "string" && result.stdout.length > 0) {
7634
- return result.stdout;
7635
- }
7636
- } catch {}
7637
- return null;
7631
+ // src/ui/glyphs.ts
7632
+ function isUnicodeCapableTerminal() {
7633
+ const mode = process.env.CODE_GLYPHS?.toLowerCase() ?? "auto";
7634
+ if (mode === "ascii")
7635
+ return false;
7636
+ if (mode === "unicode")
7637
+ return true;
7638
+ if (process.platform !== "win32")
7639
+ return true;
7640
+ const term = (process.env.TERM ?? "").toLowerCase();
7641
+ const lang = (process.env.LC_ALL ?? process.env.LC_CTYPE ?? process.env.LANG ?? "").toLowerCase();
7642
+ if (process.env.WT_SESSION)
7643
+ return true;
7644
+ if (process.env.TERM_PROGRAM)
7645
+ return true;
7646
+ if ((process.env.ConEmuANSI ?? "").toUpperCase() === "ON")
7647
+ return true;
7648
+ if (term.includes("xterm") || term.includes("utf") || term.includes("256color"))
7649
+ return true;
7650
+ if (lang.includes("utf-8"))
7651
+ return true;
7652
+ return false;
7638
7653
  }
7639
- function readClipboardText() {
7640
- if (process.platform === "win32") {
7641
- return tryCommand("powershell", ["-NoProfile", "-Command", "Get-Clipboard -Raw"]) ?? tryCommand("pwsh", ["-NoProfile", "-Command", "Get-Clipboard -Raw"]) ?? "";
7642
- }
7643
- if (process.platform === "darwin") {
7644
- return tryCommand("pbpaste", []) ?? "";
7645
- }
7646
- return tryCommand("wl-paste", ["-n"]) ?? tryCommand("xclip", ["-selection", "clipboard", "-o"]) ?? "";
7647
- }
7648
- var init_clipboard = () => {};
7649
-
7650
- // src/ui/wizard/WizardStep2ApiKey.tsx
7651
- import { useState } from "react";
7652
- import { Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
7653
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
7654
- function WizardStep2ApiKey({ onNext }) {
7655
- const [value, setValue] = useState("");
7656
- const [error, setError] = useState("");
7657
- const [checking, setChecking] = useState(false);
7658
- useInput2(async (input, key) => {
7659
- if (key.return) {
7660
- if (!/^(pk_|sk_)/.test(value)) {
7661
- setError("La cle doit commencer par pk_ ou sk_.");
7662
- return;
7663
- }
7664
- setChecking(true);
7665
- setError("");
7666
- try {
7667
- const res = await fetch("https://gen.pollinations.ai/v1/chat/completions", {
7668
- method: "POST",
7669
- headers: {
7670
- "Content-Type": "application/json",
7671
- Authorization: `Bearer ${value}`
7672
- },
7673
- body: JSON.stringify({
7674
- model: "mistral",
7675
- messages: [{ role: "user", content: "hi" }],
7676
- max_tokens: 5
7677
- }),
7678
- signal: AbortSignal.timeout(8000)
7679
- });
7680
- if (res.status === 401) {
7681
- setError("Cle invalide.");
7682
- setChecking(false);
7683
- return;
7684
- }
7685
- } catch {
7686
- setError("Impossible de verifier maintenant. La cle reste acceptee.");
7687
- }
7688
- setChecking(false);
7689
- onNext(value);
7690
- return;
7691
- }
7692
- if (key.backspace || key.delete) {
7693
- setValue((prev) => prev.slice(0, -1));
7694
- return;
7695
- }
7696
- if (key.ctrl && (input === "v" || input === "\x16")) {
7697
- const pasted = readClipboardText().replace(/\r\n/g, `
7698
- `);
7699
- if (pasted)
7700
- setValue((prev) => prev + pasted.trim());
7701
- return;
7702
- }
7703
- if (!key.ctrl && !key.meta && input.length > 0) {
7704
- setValue((prev) => prev + input);
7705
- }
7706
- });
7707
- return /* @__PURE__ */ jsxDEV2(Box2, {
7708
- flexDirection: "column",
7709
- gap: 1,
7710
- children: [
7711
- /* @__PURE__ */ jsxDEV2(Text2, {
7712
- color: codeTheme.text,
7713
- children: "This key powers preflight, planning, execution and the judge. The shell keeps it local in your Code settings."
7714
- }, undefined, false, undefined, this),
7715
- /* @__PURE__ */ jsxDEV2(Text2, {
7716
- color: codeTheme.muted,
7717
- children: "Expected format: `pk_...` or `sk_...`"
7718
- }, undefined, false, undefined, this),
7719
- /* @__PURE__ */ jsxDEV2(Box2, {
7720
- marginTop: 1,
7721
- borderStyle: "round",
7722
- borderColor: error ? codeTheme.danger : codeTheme.brand,
7723
- paddingX: 1,
7724
- children: [
7725
- /* @__PURE__ */ jsxDEV2(Text2, {
7726
- color: codeTheme.brandStrong,
7727
- children: "key "
7728
- }, undefined, false, undefined, this),
7729
- /* @__PURE__ */ jsxDEV2(Text2, {
7730
- color: codeTheme.text,
7731
- children: [
7732
- "*".repeat(Math.max(0, value.length - 6)),
7733
- value.slice(-6)
7734
- ]
7735
- }, undefined, true, undefined, this),
7736
- /* @__PURE__ */ jsxDEV2(Text2, {
7737
- color: codeTheme.brand,
7738
- children: "|"
7739
- }, undefined, false, undefined, this)
7740
- ]
7741
- }, undefined, true, undefined, this),
7742
- checking ? /* @__PURE__ */ jsxDEV2(Text2, {
7743
- color: codeTheme.warning,
7744
- children: "Verification in progress..."
7745
- }, undefined, false, undefined, this) : null,
7746
- error ? /* @__PURE__ */ jsxDEV2(Text2, {
7747
- color: codeTheme.danger,
7748
- children: error
7749
- }, undefined, false, undefined, this) : null,
7750
- /* @__PURE__ */ jsxDEV2(OnboardingHint, {
7751
- children: "Ctrl+V to paste. Press Enter to validate and continue."
7752
- }, undefined, false, undefined, this)
7753
- ]
7754
- }, undefined, true, undefined, this);
7755
- }
7756
- var init_WizardStep2ApiKey = __esm(() => {
7757
- init_clipboard();
7758
- init_theme();
7759
- init_wizardHelper();
7760
- });
7761
-
7762
- // src/ui/glyphs.ts
7763
- function isUnicodeCapableTerminal() {
7764
- const mode = process.env.CODE_GLYPHS?.toLowerCase() ?? "auto";
7765
- if (mode === "ascii")
7766
- return false;
7767
- if (mode === "unicode")
7768
- return true;
7769
- if (process.platform !== "win32")
7770
- return true;
7771
- const term = (process.env.TERM ?? "").toLowerCase();
7772
- const lang = (process.env.LC_ALL ?? process.env.LC_CTYPE ?? process.env.LANG ?? "").toLowerCase();
7773
- if (process.env.WT_SESSION)
7774
- return true;
7775
- if (process.env.TERM_PROGRAM)
7776
- return true;
7777
- if ((process.env.ConEmuANSI ?? "").toUpperCase() === "ON")
7778
- return true;
7779
- if (term.includes("xterm") || term.includes("utf") || term.includes("256color"))
7780
- return true;
7781
- if (lang.includes("utf-8"))
7782
- return true;
7783
- return false;
7784
- }
7785
- function pickGlyph(unicode, ascii) {
7786
- return isUnicodeCapableTerminal() ? unicode : ascii;
7654
+ function pickGlyph(unicode, ascii) {
7655
+ return isUnicodeCapableTerminal() ? unicode : ascii;
7787
7656
  }
7788
7657
  var ASCII_GLYPHS, UNICODE_GLYPHS, uiGlyphs;
7789
7658
  var init_glyphs = __esm(() => {
@@ -7967,9 +7836,9 @@ var init_glyphs = __esm(() => {
7967
7836
  });
7968
7837
 
7969
7838
  // src/ui/ProgressBar.tsx
7970
- import React2 from "react";
7971
- import { Box as Box3, Text as Text3 } from "ink";
7972
- import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
7839
+ import React from "react";
7840
+ import { Box, Text } from "ink";
7841
+ import { jsxDEV } from "react/jsx-dev-runtime";
7973
7842
  function ProgressBar({
7974
7843
  progress,
7975
7844
  width = 30,
@@ -7981,10 +7850,10 @@ function ProgressBar({
7981
7850
  const filled = Math.round(clampedProgress / 100 * width);
7982
7851
  const empty = width - filled;
7983
7852
  const bar = uiGlyphs.progressStart + uiGlyphs.progressFull.repeat(filled) + uiGlyphs.progressEmpty.repeat(empty) + uiGlyphs.progressEnd;
7984
- return /* @__PURE__ */ jsxDEV3(Box3, {
7853
+ return /* @__PURE__ */ jsxDEV(Box, {
7985
7854
  flexDirection: "column",
7986
7855
  children: [
7987
- label && /* @__PURE__ */ jsxDEV3(Text3, {
7856
+ label && /* @__PURE__ */ jsxDEV(Text, {
7988
7857
  dimColor: true,
7989
7858
  children: [
7990
7859
  uiGlyphs.bullet,
@@ -7992,13 +7861,13 @@ function ProgressBar({
7992
7861
  label
7993
7862
  ]
7994
7863
  }, undefined, true, undefined, this),
7995
- /* @__PURE__ */ jsxDEV3(Box3, {
7864
+ /* @__PURE__ */ jsxDEV(Box, {
7996
7865
  children: [
7997
- /* @__PURE__ */ jsxDEV3(Text3, {
7866
+ /* @__PURE__ */ jsxDEV(Text, {
7998
7867
  color,
7999
7868
  children: bar
8000
7869
  }, undefined, false, undefined, this),
8001
- showPercentage && /* @__PURE__ */ jsxDEV3(Text3, {
7870
+ showPercentage && /* @__PURE__ */ jsxDEV(Text, {
8002
7871
  dimColor: true,
8003
7872
  children: [
8004
7873
  " ",
@@ -8012,20 +7881,20 @@ function ProgressBar({
8012
7881
  }, undefined, true, undefined, this);
8013
7882
  }
8014
7883
  function Spinner({ message, color = codeTheme.brand }) {
8015
- const [frame, setFrame] = React2.useState(0);
8016
- React2.useEffect(() => {
7884
+ const [frame, setFrame] = React.useState(0);
7885
+ React.useEffect(() => {
8017
7886
  const interval = setInterval(() => {
8018
7887
  setFrame((prev) => (prev + 1) % uiGlyphs.spinner.length);
8019
7888
  }, 100);
8020
7889
  return () => clearInterval(interval);
8021
7890
  }, []);
8022
- return /* @__PURE__ */ jsxDEV3(Box3, {
7891
+ return /* @__PURE__ */ jsxDEV(Box, {
8023
7892
  children: [
8024
- /* @__PURE__ */ jsxDEV3(Text3, {
7893
+ /* @__PURE__ */ jsxDEV(Text, {
8025
7894
  color,
8026
7895
  children: uiGlyphs.spinner[frame]
8027
7896
  }, undefined, false, undefined, this),
8028
- message && /* @__PURE__ */ jsxDEV3(Text3, {
7897
+ message && /* @__PURE__ */ jsxDEV(Text, {
8029
7898
  children: [
8030
7899
  " ",
8031
7900
  message
@@ -8040,19 +7909,19 @@ function LoadingState({
8040
7909
  progress,
8041
7910
  showSpinner = true
8042
7911
  }) {
8043
- return /* @__PURE__ */ jsxDEV3(Box3, {
7912
+ return /* @__PURE__ */ jsxDEV(Box, {
8044
7913
  flexDirection: "column",
8045
7914
  marginY: 1,
8046
7915
  children: [
8047
- /* @__PURE__ */ jsxDEV3(Box3, {
7916
+ /* @__PURE__ */ jsxDEV(Box, {
8048
7917
  children: [
8049
- showSpinner && /* @__PURE__ */ jsxDEV3(Box3, {
7918
+ showSpinner && /* @__PURE__ */ jsxDEV(Box, {
8050
7919
  marginRight: 1,
8051
- children: /* @__PURE__ */ jsxDEV3(Spinner, {
7920
+ children: /* @__PURE__ */ jsxDEV(Spinner, {
8052
7921
  color: "cyan"
8053
7922
  }, undefined, false, undefined, this)
8054
7923
  }, undefined, false, undefined, this),
8055
- /* @__PURE__ */ jsxDEV3(Text3, {
7924
+ /* @__PURE__ */ jsxDEV(Text, {
8056
7925
  bold: true,
8057
7926
  color: "cyan",
8058
7927
  children: [
@@ -8063,9 +7932,9 @@ function LoadingState({
8063
7932
  }, undefined, true, undefined, this)
8064
7933
  ]
8065
7934
  }, undefined, true, undefined, this),
8066
- subMessage && /* @__PURE__ */ jsxDEV3(Box3, {
7935
+ subMessage && /* @__PURE__ */ jsxDEV(Box, {
8067
7936
  marginLeft: 2,
8068
- children: /* @__PURE__ */ jsxDEV3(Text3, {
7937
+ children: /* @__PURE__ */ jsxDEV(Text, {
8069
7938
  dimColor: true,
8070
7939
  children: [
8071
7940
  uiGlyphs.arrowRight,
@@ -8074,10 +7943,10 @@ function LoadingState({
8074
7943
  ]
8075
7944
  }, undefined, true, undefined, this)
8076
7945
  }, undefined, false, undefined, this),
8077
- progress !== undefined && /* @__PURE__ */ jsxDEV3(Box3, {
7946
+ progress !== undefined && /* @__PURE__ */ jsxDEV(Box, {
8078
7947
  marginLeft: 2,
8079
7948
  marginTop: 1,
8080
- children: /* @__PURE__ */ jsxDEV3(ProgressBar, {
7949
+ children: /* @__PURE__ */ jsxDEV(ProgressBar, {
8081
7950
  progress,
8082
7951
  width: 25,
8083
7952
  showPercentage: true
@@ -8091,794 +7960,1000 @@ var init_ProgressBar = __esm(() => {
8091
7960
  init_theme();
8092
7961
  });
8093
7962
 
8094
- // src/ui/wizard/WizardStep3Test.tsx
8095
- import { useEffect, useState as useState2 } from "react";
8096
- import { Box as Box4, Text as Text4, useInput as useInput3 } from "ink";
8097
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
8098
- function WizardStep3Test({ apiKey, onNext }) {
8099
- const [status, setStatus] = useState2("idle");
8100
- useEffect(() => {
8101
- setStatus("testing");
8102
- (async () => {
8103
- try {
8104
- const res = await fetch("https://gen.pollinations.ai/v1/chat/completions", {
8105
- method: "POST",
8106
- headers: {
8107
- "Content-Type": "application/json",
8108
- Authorization: `Bearer ${apiKey}`
8109
- },
8110
- body: JSON.stringify({
8111
- model: "mistral",
8112
- messages: [{ role: "user", content: "ping" }],
8113
- max_tokens: 4
8114
- }),
8115
- signal: AbortSignal.timeout(8000)
8116
- });
8117
- setStatus(res.ok ? "ok" : "warn");
8118
- } catch {
8119
- setStatus("warn");
8120
- }
8121
- })();
8122
- }, [apiKey]);
8123
- useInput3((_, key) => {
8124
- if (key.return)
8125
- onNext();
8126
- });
8127
- return /* @__PURE__ */ jsxDEV4(Box4, {
8128
- flexDirection: "column",
8129
- gap: 1,
8130
- children: [
8131
- /* @__PURE__ */ jsxDEV4(Text4, {
8132
- color: codeTheme.text,
8133
- children: "Before entering the shell, Code probes the configured endpoint to avoid a dead setup on first use."
8134
- }, undefined, false, undefined, this),
8135
- status === "testing" ? /* @__PURE__ */ jsxDEV4(LoadingState, {
8136
- message: "Testing model access",
8137
- subMessage: "Polling the API with a minimal request."
8138
- }, undefined, false, undefined, this) : null,
8139
- status === "ok" ? /* @__PURE__ */ jsxDEV4(Text4, {
8140
- color: codeTheme.success,
8141
- children: "API check passed."
8142
- }, undefined, false, undefined, this) : null,
8143
- status === "warn" ? /* @__PURE__ */ jsxDEV4(Text4, {
8144
- color: codeTheme.warning,
8145
- children: "Could not fully validate. You can still continue."
8146
- }, undefined, false, undefined, this) : null,
8147
- /* @__PURE__ */ jsxDEV4(OnboardingHint, {
8148
- children: "Press Enter to continue."
8149
- }, undefined, false, undefined, this)
8150
- ]
8151
- }, undefined, true, undefined, this);
8152
- }
8153
- var init_WizardStep3Test = __esm(() => {
8154
- init_ProgressBar();
8155
- init_theme();
8156
- init_wizardHelper();
8157
- });
8158
-
8159
- // src/ui/wizard/WizardStep4Model.tsx
8160
- import { useState as useState3 } from "react";
8161
- import { Box as Box5, Text as Text5, useInput as useInput4 } from "ink";
8162
- import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
8163
- function WizardStep4Model({ onNext }) {
8164
- const [modelIndex, setModelIndex] = useState3(0);
8165
- const [langIndex, setLangIndex] = useState3(0);
8166
- const [editing, setEditing] = useState3("model");
8167
- useInput4((_, key) => {
8168
- if (key.upArrow) {
8169
- if (editing === "model")
8170
- setModelIndex((i) => Math.max(0, i - 1));
8171
- else
8172
- setLangIndex((i) => Math.max(0, i - 1));
8173
- return;
8174
- }
8175
- if (key.downArrow) {
8176
- if (editing === "model")
8177
- setModelIndex((i) => Math.min(MODELS.length - 1, i + 1));
8178
- else
8179
- setLangIndex((i) => Math.min(LANGUAGES.length - 1, i + 1));
8180
- return;
8181
- }
8182
- if (key.tab) {
8183
- setEditing((e) => e === "model" ? "lang" : "model");
8184
- return;
8185
- }
8186
- if (key.return) {
8187
- onNext(MODELS[modelIndex], LANGUAGES[langIndex]);
8188
- }
8189
- });
8190
- return /* @__PURE__ */ jsxDEV5(Box5, {
7963
+ // src/ui/wizard/wizardHelper.tsx
7964
+ import { Box as Box2, Text as Text2, render } from "ink";
7965
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
7966
+ function OnboardingShell({ step, total, steps, children }) {
7967
+ const active = steps[Math.max(0, step - 1)];
7968
+ const progress = step / Math.max(total, 1) * 100;
7969
+ return /* @__PURE__ */ jsxDEV2(Box2, {
8191
7970
  flexDirection: "column",
8192
- gap: 1,
7971
+ paddingX: 1,
8193
7972
  children: [
8194
- /* @__PURE__ */ jsxDEV5(Text5, {
8195
- color: codeTheme.text,
8196
- children: "Pick the default routing posture for the shell. You can still override it later with `/model`."
8197
- }, undefined, false, undefined, this),
8198
- /* @__PURE__ */ jsxDEV5(Box5, {
8199
- marginTop: 1,
8200
- flexDirection: "column",
7973
+ /* @__PURE__ */ jsxDEV2(Box2, {
7974
+ justifyContent: "space-between",
7975
+ marginBottom: 1,
8201
7976
  children: [
8202
- /* @__PURE__ */ jsxDEV5(Text5, {
7977
+ /* @__PURE__ */ jsxDEV2(Box2, {
7978
+ gap: 1,
7979
+ children: [
7980
+ /* @__PURE__ */ jsxDEV2(Text2, {
7981
+ bold: true,
7982
+ color: codeTheme.brandStrong,
7983
+ children: "Code"
7984
+ }, undefined, false, undefined, this),
7985
+ /* @__PURE__ */ jsxDEV2(Text2, {
7986
+ color: codeTheme.muted,
7987
+ children: "OAL SARL | v6 onboarding"
7988
+ }, undefined, false, undefined, this)
7989
+ ]
7990
+ }, undefined, true, undefined, this),
7991
+ /* @__PURE__ */ jsxDEV2(Text2, {
8203
7992
  color: codeTheme.muted,
8204
- children: "Model"
8205
- }, undefined, false, undefined, this),
8206
- MODELS.map((model, index) => /* @__PURE__ */ jsxDEV5(OnboardingChoice, {
8207
- active: editing === "model" && modelIndex === index,
8208
- label: model,
8209
- detail: model === "mistral" ? "Balanced default for day-to-day execution." : model === "gemini-fast" ? "Fast response profile for lightweight tasks." : "Bigger-context profile for heavier planning."
8210
- }, model, false, undefined, this))
7993
+ children: [
7994
+ "Step ",
7995
+ step,
7996
+ "/",
7997
+ total
7998
+ ]
7999
+ }, undefined, true, undefined, this)
8211
8000
  ]
8212
8001
  }, undefined, true, undefined, this),
8213
- /* @__PURE__ */ jsxDEV5(Box5, {
8214
- flexDirection: "column",
8002
+ /* @__PURE__ */ jsxDEV2(Box2, {
8003
+ marginBottom: 1,
8004
+ children: /* @__PURE__ */ jsxDEV2(ProgressBar, {
8005
+ progress,
8006
+ width: 34,
8007
+ color: codeTheme.brand,
8008
+ showPercentage: false
8009
+ }, undefined, false, undefined, this)
8010
+ }, undefined, false, undefined, this),
8011
+ /* @__PURE__ */ jsxDEV2(Box2, {
8012
+ borderStyle: "round",
8013
+ borderColor: codeTheme.line,
8014
+ paddingX: 1,
8015
+ paddingY: 1,
8215
8016
  children: [
8216
- /* @__PURE__ */ jsxDEV5(Text5, {
8217
- color: codeTheme.muted,
8218
- children: "Language"
8219
- }, undefined, false, undefined, this),
8220
- LANGUAGES.map((language, index) => /* @__PURE__ */ jsxDEV5(OnboardingChoice, {
8221
- active: editing === "lang" && langIndex === index,
8222
- label: language,
8223
- detail: language === "auto" ? "Infer from the environment." : `Force ${language.toUpperCase()} responses.`
8224
- }, language, false, undefined, this))
8225
- ]
8226
- }, undefined, true, undefined, this),
8227
- /* @__PURE__ */ jsxDEV5(OnboardingHint, {
8228
- children: "Use Up/Down to change the active field, Tab to switch field, Enter to continue."
8229
- }, undefined, false, undefined, this)
8230
- ]
8231
- }, undefined, true, undefined, this);
8232
- }
8233
- var MODELS, LANGUAGES;
8234
- var init_WizardStep4Model = __esm(() => {
8235
- init_theme();
8236
- init_wizardHelper();
8237
- MODELS = ["mistral", "gemini-fast", "kimi"];
8238
- LANGUAGES = ["auto", "fr", "en"];
8239
- });
8240
-
8241
- // src/ui/wizard/WizardStep5Features.tsx
8242
- import { useEffect as useEffect2, useState as useState4 } from "react";
8243
- import { Box as Box6, Text as Text6, useInput as useInput5 } from "ink";
8244
- import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
8245
- function WizardStep5Features({ diagnostics, onNext }) {
8246
- const [detecting, setDetecting] = useState4(true);
8247
- const [dockerAvailable, setDockerAvailable] = useState4(false);
8248
- const [visionCached, setVisionCached] = useState4(false);
8249
- const [embedCached, setEmbedCached] = useState4(false);
8250
- const [downloading, setDownloading] = useState4(false);
8251
- const [downloadChoice, setDownloadChoice] = useState4(null);
8252
- const [downloadLabel, setDownloadLabel] = useState4("Preparation...");
8253
- const [downloadError, setDownloadError] = useState4("");
8254
- const runtimeReady = diagnostics?.capabilities.find((item) => item.key === "transformers")?.status === "ready";
8255
- useEffect2(() => {
8256
- (async () => {
8257
- const [hasDocker, visionReady, embedReady] = await Promise.all([
8258
- detectDockerAvailability(),
8259
- isModelCached(VISION_MODEL_ID),
8260
- isModelCached(EMBED_MODEL_ID)
8261
- ]);
8262
- setDockerAvailable(hasDocker);
8263
- setVisionCached(visionReady);
8264
- setEmbedCached(embedReady);
8265
- setDetecting(false);
8266
- })();
8267
- }, []);
8268
- useInput5(async (input, key) => {
8269
- if (detecting || downloading)
8270
- return;
8271
- if (visionCached && embedCached && key.return) {
8272
- onNext({
8273
- enableVision: true,
8274
- visionSource: "embedded",
8275
- enableSandbox: dockerAvailable,
8276
- sandboxMode: dockerAvailable ? "docker" : "safe",
8277
- modelPreloadStatus: "already_cached",
8278
- modelPreloadError: undefined
8279
- });
8280
- return;
8281
- }
8282
- if (!runtimeReady && key.return) {
8283
- onNext({
8284
- enableVision: true,
8285
- visionSource: "embedded",
8286
- enableSandbox: dockerAvailable,
8287
- sandboxMode: dockerAvailable ? "docker" : "safe",
8288
- modelPreloadStatus: "runtime_missing",
8289
- modelPreloadError: "Local runtime missing. Install project dependencies first, then rerun setup."
8290
- });
8291
- return;
8017
+ /* @__PURE__ */ jsxDEV2(Box2, {
8018
+ width: 26,
8019
+ marginRight: 2,
8020
+ flexDirection: "column",
8021
+ children: [
8022
+ /* @__PURE__ */ jsxDEV2(Text2, {
8023
+ color: codeTheme.muted,
8024
+ children: "Setup flow"
8025
+ }, undefined, false, undefined, this),
8026
+ /* @__PURE__ */ jsxDEV2(Box2, {
8027
+ marginTop: 1,
8028
+ flexDirection: "column",
8029
+ children: steps.map((item, index) => {
8030
+ const current = index + 1;
8031
+ const done = current < step;
8032
+ const activeStep = current === step;
8033
+ return /* @__PURE__ */ jsxDEV2(Box2, {
8034
+ marginBottom: 1,
8035
+ flexDirection: "column",
8036
+ children: [
8037
+ /* @__PURE__ */ jsxDEV2(Text2, {
8038
+ color: done ? codeTheme.success : activeStep ? codeTheme.brandStrong : codeTheme.muted,
8039
+ children: [
8040
+ done ? "OK" : activeStep ? ">" : "-",
8041
+ " ",
8042
+ item.title
8043
+ ]
8044
+ }, undefined, true, undefined, this),
8045
+ /* @__PURE__ */ jsxDEV2(Text2, {
8046
+ color: activeStep ? codeTheme.text : codeTheme.muted,
8047
+ children: item.description
8048
+ }, undefined, false, undefined, this)
8049
+ ]
8050
+ }, item.title, true, undefined, this);
8051
+ })
8052
+ }, undefined, false, undefined, this)
8053
+ ]
8054
+ }, undefined, true, undefined, this),
8055
+ /* @__PURE__ */ jsxDEV2(Box2, {
8056
+ flexGrow: 1,
8057
+ flexDirection: "column",
8058
+ borderStyle: "round",
8059
+ borderColor: codeTheme.line,
8060
+ paddingX: 1,
8061
+ paddingY: 1,
8062
+ children: [
8063
+ /* @__PURE__ */ jsxDEV2(Text2, {
8064
+ color: codeTheme.accent,
8065
+ children: active.eyebrow
8066
+ }, undefined, false, undefined, this),
8067
+ /* @__PURE__ */ jsxDEV2(Text2, {
8068
+ bold: true,
8069
+ color: codeTheme.brandStrong,
8070
+ children: active.title
8071
+ }, undefined, false, undefined, this),
8072
+ /* @__PURE__ */ jsxDEV2(Text2, {
8073
+ color: codeTheme.muted,
8074
+ children: active.description
8075
+ }, undefined, false, undefined, this),
8076
+ /* @__PURE__ */ jsxDEV2(Box2, {
8077
+ marginTop: 1,
8078
+ flexDirection: "column",
8079
+ children
8080
+ }, undefined, false, undefined, this)
8081
+ ]
8082
+ }, undefined, true, undefined, this)
8083
+ ]
8084
+ }, undefined, true, undefined, this)
8085
+ ]
8086
+ }, undefined, true, undefined, this);
8087
+ }
8088
+ function OnboardingHint({ children }) {
8089
+ return /* @__PURE__ */ jsxDEV2(Text2, {
8090
+ color: codeTheme.muted,
8091
+ children
8092
+ }, undefined, false, undefined, this);
8093
+ }
8094
+ function OnboardingMetric({
8095
+ label,
8096
+ value,
8097
+ tone = "text"
8098
+ }) {
8099
+ const color = tone === "success" ? codeTheme.success : tone === "warning" ? codeTheme.warning : codeTheme.text;
8100
+ return /* @__PURE__ */ jsxDEV2(Box2, {
8101
+ flexDirection: "row",
8102
+ gap: 2,
8103
+ children: [
8104
+ /* @__PURE__ */ jsxDEV2(Box2, {
8105
+ width: 20,
8106
+ flexShrink: 0,
8107
+ children: /* @__PURE__ */ jsxDEV2(Text2, {
8108
+ color: codeTheme.muted,
8109
+ children: label
8110
+ }, undefined, false, undefined, this)
8111
+ }, undefined, false, undefined, this),
8112
+ /* @__PURE__ */ jsxDEV2(Box2, {
8113
+ flexGrow: 1,
8114
+ children: /* @__PURE__ */ jsxDEV2(Text2, {
8115
+ color,
8116
+ wrap: "wrap",
8117
+ children: value
8118
+ }, undefined, false, undefined, this)
8119
+ }, undefined, false, undefined, this)
8120
+ ]
8121
+ }, undefined, true, undefined, this);
8122
+ }
8123
+ function OnboardingChoice({
8124
+ active,
8125
+ label,
8126
+ detail
8127
+ }) {
8128
+ return /* @__PURE__ */ jsxDEV2(Box2, {
8129
+ borderStyle: "round",
8130
+ borderColor: active ? codeTheme.brand : codeTheme.line,
8131
+ paddingX: 1,
8132
+ marginBottom: 1,
8133
+ children: /* @__PURE__ */ jsxDEV2(Box2, {
8134
+ flexDirection: "column",
8135
+ children: [
8136
+ /* @__PURE__ */ jsxDEV2(Text2, {
8137
+ color: active ? codeTheme.brandStrong : codeTheme.text,
8138
+ children: [
8139
+ active ? ">" : " ",
8140
+ " ",
8141
+ label
8142
+ ]
8143
+ }, undefined, true, undefined, this),
8144
+ /* @__PURE__ */ jsxDEV2(Text2, {
8145
+ color: codeTheme.muted,
8146
+ children: detail
8147
+ }, undefined, false, undefined, this)
8148
+ ]
8149
+ }, undefined, true, undefined, this)
8150
+ }, undefined, false, undefined, this);
8151
+ }
8152
+ var init_wizardHelper = __esm(() => {
8153
+ init_WizardContainer();
8154
+ init_theme();
8155
+ init_ProgressBar();
8156
+ });
8157
+
8158
+ // src/ui/wizard/WizardStep1Welcome.tsx
8159
+ import { Box as Box3, Text as Text3, useInput } from "ink";
8160
+ import { jsxDEV as jsxDEV3, Fragment } from "react/jsx-dev-runtime";
8161
+ function WizardStep1Welcome({ diagnostics, onNext }) {
8162
+ useInput((_, key) => {
8163
+ if (key.return)
8164
+ onNext();
8165
+ });
8166
+ return /* @__PURE__ */ jsxDEV3(Box3, {
8167
+ flexDirection: "column",
8168
+ gap: 1,
8169
+ children: [
8170
+ /* @__PURE__ */ jsxDEV3(Text3, {
8171
+ color: codeTheme.text,
8172
+ children: "Code is OAL SARL's terminal-native coding shell with multi-session runs, guided execution, visual artifacts and guarded approvals."
8173
+ }, undefined, false, undefined, this),
8174
+ /* @__PURE__ */ jsxDEV3(Box3, {
8175
+ flexDirection: "column",
8176
+ marginTop: 1,
8177
+ children: [
8178
+ /* @__PURE__ */ jsxDEV3(OnboardingMetric, {
8179
+ label: "Sessions",
8180
+ value: "multi-context shell"
8181
+ }, undefined, false, undefined, this),
8182
+ /* @__PURE__ */ jsxDEV3(OnboardingMetric, {
8183
+ label: "Validation",
8184
+ value: "judge + transactions"
8185
+ }, undefined, false, undefined, this),
8186
+ /* @__PURE__ */ jsxDEV3(OnboardingMetric, {
8187
+ label: "Local features",
8188
+ value: "vision + semantic index"
8189
+ }, undefined, false, undefined, this),
8190
+ /* @__PURE__ */ jsxDEV3(OnboardingMetric, {
8191
+ label: "Workflow",
8192
+ value: "skills + approvals + history"
8193
+ }, undefined, false, undefined, this)
8194
+ ]
8195
+ }, undefined, true, undefined, this),
8196
+ /* @__PURE__ */ jsxDEV3(Box3, {
8197
+ marginTop: 1,
8198
+ flexDirection: "column",
8199
+ children: [
8200
+ /* @__PURE__ */ jsxDEV3(Text3, {
8201
+ color: codeTheme.brandStrong,
8202
+ children: "What changes in v6"
8203
+ }, undefined, false, undefined, this),
8204
+ /* @__PURE__ */ jsxDEV3(Text3, {
8205
+ color: codeTheme.muted,
8206
+ children: "Cleaner chat UI, stronger runtime visibility, safer approvals and model-backed planning."
8207
+ }, undefined, false, undefined, this)
8208
+ ]
8209
+ }, undefined, true, undefined, this),
8210
+ /* @__PURE__ */ jsxDEV3(Box3, {
8211
+ marginTop: 1,
8212
+ flexDirection: "column",
8213
+ children: [
8214
+ /* @__PURE__ */ jsxDEV3(Text3, {
8215
+ color: codeTheme.brandStrong,
8216
+ children: "Platform diagnostics"
8217
+ }, undefined, false, undefined, this),
8218
+ diagnostics ? /* @__PURE__ */ jsxDEV3(Fragment, {
8219
+ children: [
8220
+ /* @__PURE__ */ jsxDEV3(OnboardingMetric, {
8221
+ label: "Shell",
8222
+ value: diagnostics.shellLabel,
8223
+ tone: diagnostics.shellSupportsPosix ? "success" : "warning"
8224
+ }, undefined, false, undefined, this),
8225
+ /* @__PURE__ */ jsxDEV3(OnboardingMetric, {
8226
+ label: "Warnings",
8227
+ value: diagnostics.warnings.length === 0 ? "none" : `${diagnostics.warnings.length} attention point(s)`,
8228
+ tone: diagnostics.warnings.length === 0 ? "success" : "warning"
8229
+ }, undefined, false, undefined, this)
8230
+ ]
8231
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV3(Text3, {
8232
+ color: codeTheme.muted,
8233
+ children: "Scanning local shell, sandbox and optional capabilities..."
8234
+ }, undefined, false, undefined, this)
8235
+ ]
8236
+ }, undefined, true, undefined, this),
8237
+ /* @__PURE__ */ jsxDEV3(OnboardingHint, {
8238
+ children: "Press Enter to continue."
8239
+ }, undefined, false, undefined, this)
8240
+ ]
8241
+ }, undefined, true, undefined, this);
8242
+ }
8243
+ var init_WizardStep1Welcome = __esm(() => {
8244
+ init_theme();
8245
+ init_wizardHelper();
8246
+ });
8247
+
8248
+ // src/ui/clipboard.ts
8249
+ import { spawnSync as spawnSync2 } from "child_process";
8250
+ function tryCommand(command, args) {
8251
+ try {
8252
+ const result = spawnSync2(command, args, { encoding: "utf-8", windowsHide: true });
8253
+ if (result.status === 0 && typeof result.stdout === "string" && result.stdout.length > 0) {
8254
+ return result.stdout;
8292
8255
  }
8293
- if (downloadChoice !== null)
8294
- return;
8295
- if (input === "y" || input === "Y") {
8296
- if (!runtimeReady) {
8297
- setDownloadError("Local runtime missing. Install project dependencies first, then rerun setup.");
8256
+ } catch {}
8257
+ return null;
8258
+ }
8259
+ function readClipboardText() {
8260
+ if (process.platform === "win32") {
8261
+ return tryCommand("powershell", ["-NoProfile", "-Command", "Get-Clipboard -Raw"]) ?? tryCommand("pwsh", ["-NoProfile", "-Command", "Get-Clipboard -Raw"]) ?? "";
8262
+ }
8263
+ if (process.platform === "darwin") {
8264
+ return tryCommand("pbpaste", []) ?? "";
8265
+ }
8266
+ return tryCommand("wl-paste", ["-n"]) ?? tryCommand("xclip", ["-selection", "clipboard", "-o"]) ?? "";
8267
+ }
8268
+ var init_clipboard = () => {};
8269
+
8270
+ // src/ui/wizard/WizardStep2ApiKey.tsx
8271
+ import { useState } from "react";
8272
+ import { Box as Box4, Text as Text4, useInput as useInput2 } from "ink";
8273
+ import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
8274
+ function WizardStep2ApiKey({ onNext }) {
8275
+ const [value, setValue] = useState("");
8276
+ const [error, setError] = useState("");
8277
+ const [checking, setChecking] = useState(false);
8278
+ useInput2(async (input, key) => {
8279
+ if (key.return) {
8280
+ if (!/^(pk_|sk_)/.test(value)) {
8281
+ setError("La cle doit commencer par pk_ ou sk_.");
8298
8282
  return;
8299
8283
  }
8300
- setDownloadChoice("y");
8301
- setDownloading(true);
8302
- setDownloadError("");
8284
+ setChecking(true);
8285
+ setError("");
8303
8286
  try {
8304
- setDownloadLabel("Vision locale (~230MB)...");
8305
- await downloadModel(VISION_MODEL_ID);
8306
- setDownloadLabel("Embeddings semantiques (~22MB)...");
8307
- await downloadModel(EMBED_MODEL_ID);
8308
- const [visionReady, embedReady] = await Promise.all([
8309
- isModelCached(VISION_MODEL_ID),
8310
- isModelCached(EMBED_MODEL_ID)
8311
- ]);
8312
- setVisionCached(visionReady);
8313
- setEmbedCached(embedReady);
8314
- if (!visionReady || !embedReady) {
8315
- throw new Error("Local preload completed without a persistent cache. Code will retry the missing models on first use.");
8316
- }
8317
- } catch (error) {
8318
- const message = error instanceof Error ? error.message : "Model download failed.";
8319
- setDownloading(false);
8320
- setDownloadChoice(null);
8321
- setDownloadError(message);
8322
- onNext({
8323
- enableVision: true,
8324
- visionSource: "embedded",
8325
- enableSandbox: dockerAvailable,
8326
- sandboxMode: dockerAvailable ? "docker" : "safe",
8327
- modelPreloadStatus: "failed",
8328
- modelPreloadError: message
8287
+ const res = await fetch("https://gen.pollinations.ai/v1/chat/completions", {
8288
+ method: "POST",
8289
+ headers: {
8290
+ "Content-Type": "application/json",
8291
+ Authorization: `Bearer ${value}`
8292
+ },
8293
+ body: JSON.stringify({
8294
+ model: "mistral",
8295
+ messages: [{ role: "user", content: "hi" }],
8296
+ max_tokens: 5
8297
+ }),
8298
+ signal: AbortSignal.timeout(8000)
8329
8299
  });
8330
- return;
8331
- }
8332
- setDownloading(false);
8333
- onNext({
8334
- enableVision: true,
8335
- visionSource: "embedded",
8336
- enableSandbox: dockerAvailable,
8337
- sandboxMode: dockerAvailable ? "docker" : "safe",
8338
- modelPreloadStatus: "downloaded",
8339
- modelPreloadError: undefined
8340
- });
8300
+ if (res.status === 401) {
8301
+ setError("Cle invalide.");
8302
+ setChecking(false);
8303
+ return;
8304
+ }
8305
+ } catch {
8306
+ setError("Impossible de verifier maintenant. La cle reste acceptee.");
8307
+ }
8308
+ setChecking(false);
8309
+ onNext(value);
8341
8310
  return;
8342
8311
  }
8343
- if (input === "n" || input === "N") {
8344
- setDownloadChoice("n");
8345
- onNext({
8346
- enableVision: true,
8347
- visionSource: "embedded",
8348
- enableSandbox: dockerAvailable,
8349
- sandboxMode: dockerAvailable ? "docker" : "safe",
8350
- modelPreloadStatus: runtimeReady ? "lazy" : "runtime_missing",
8351
- modelPreloadError: runtimeReady ? undefined : "Local runtime missing. Install project dependencies first, then rerun setup."
8352
- });
8312
+ if (key.backspace || key.delete) {
8313
+ setValue((prev) => prev.slice(0, -1));
8314
+ return;
8315
+ }
8316
+ if (key.ctrl && (input === "v" || input === "\x16")) {
8317
+ const pasted = readClipboardText().replace(/\r\n/g, `
8318
+ `);
8319
+ if (pasted)
8320
+ setValue((prev) => prev + pasted.trim());
8321
+ return;
8322
+ }
8323
+ if (!key.ctrl && !key.meta && input.length > 0) {
8324
+ setValue((prev) => prev + input);
8353
8325
  }
8354
8326
  });
8355
- if (detecting) {
8356
- return /* @__PURE__ */ jsxDEV6(LoadingState, {
8357
- message: "Scanning local capabilities",
8358
- subMessage: "Inspecting Docker and local model cache."
8359
- }, undefined, false, undefined, this);
8360
- }
8361
- if (downloading) {
8362
- return /* @__PURE__ */ jsxDEV6(LoadingState, {
8363
- message: "Downloading local models",
8364
- subMessage: `${downloadLabel} Downloading sequentially to keep the setup stable.`
8365
- }, undefined, false, undefined, this);
8366
- }
8367
- return /* @__PURE__ */ jsxDEV6(Box6, {
8327
+ return /* @__PURE__ */ jsxDEV4(Box4, {
8368
8328
  flexDirection: "column",
8369
8329
  gap: 1,
8370
8330
  children: [
8371
- /* @__PURE__ */ jsxDEV6(Text6, {
8331
+ /* @__PURE__ */ jsxDEV4(Text4, {
8372
8332
  color: codeTheme.text,
8373
- children: "Code can preload local models now or keep them lazy-loaded for the first real use."
8333
+ children: "This key powers preflight, planning, execution and the judge. The shell keeps it local in your Code settings."
8374
8334
  }, undefined, false, undefined, this),
8375
- /* @__PURE__ */ jsxDEV6(Box6, {
8376
- flexDirection: "column",
8335
+ /* @__PURE__ */ jsxDEV4(Text4, {
8336
+ color: codeTheme.muted,
8337
+ children: "Expected format: `pk_...` or `sk_...`"
8338
+ }, undefined, false, undefined, this),
8339
+ /* @__PURE__ */ jsxDEV4(Box4, {
8377
8340
  marginTop: 1,
8341
+ borderStyle: "round",
8342
+ borderColor: error ? codeTheme.danger : codeTheme.brand,
8343
+ paddingX: 1,
8378
8344
  children: [
8379
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8380
- label: "Shell runtime",
8381
- value: diagnostics?.shellLabel ?? "detecting...",
8382
- tone: diagnostics ? diagnostics.shellSupportsPosix ? "success" : "warning" : "text"
8383
- }, undefined, false, undefined, this),
8384
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8385
- label: "Vision",
8386
- value: "embedded local pipeline",
8387
- tone: "success"
8388
- }, undefined, false, undefined, this),
8389
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8390
- label: "Embeddings",
8391
- value: "semantic index ready",
8392
- tone: "success"
8393
- }, undefined, false, undefined, this),
8394
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8395
- label: "Sandbox",
8396
- value: dockerAvailable ? "docker available" : "safe mode only",
8397
- tone: dockerAvailable ? "success" : "warning"
8398
- }, undefined, false, undefined, this),
8399
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8400
- label: "Vision cache",
8401
- value: visionCached ? "already cached" : "download required",
8402
- tone: visionCached ? "success" : "warning"
8403
- }, undefined, false, undefined, this),
8404
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8405
- label: "Embedding cache",
8406
- value: embedCached ? "already cached" : "download required",
8407
- tone: embedCached ? "success" : "warning"
8408
- }, undefined, false, undefined, this),
8409
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8410
- label: "Image preprocessing",
8411
- value: diagnostics?.capabilities.find((item) => item.key === "sharp")?.detail ?? "detecting...",
8412
- tone: diagnostics?.capabilities.find((item) => item.key === "sharp")?.status === "ready" ? "success" : "warning"
8413
- }, undefined, false, undefined, this),
8414
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8415
- label: "Screenshots",
8416
- value: diagnostics?.capabilities.find((item) => item.key === "playwright")?.detail ?? "detecting...",
8417
- tone: diagnostics?.capabilities.find((item) => item.key === "playwright")?.status === "ready" ? "success" : "warning"
8345
+ /* @__PURE__ */ jsxDEV4(Text4, {
8346
+ color: codeTheme.brandStrong,
8347
+ children: "key "
8418
8348
  }, undefined, false, undefined, this),
8419
- /* @__PURE__ */ jsxDEV6(OnboardingMetric, {
8420
- label: "Validation",
8421
- value: "judge + transactions enabled",
8422
- tone: "success"
8349
+ /* @__PURE__ */ jsxDEV4(Text4, {
8350
+ color: codeTheme.text,
8351
+ children: [
8352
+ "*".repeat(Math.max(0, value.length - 6)),
8353
+ value.slice(-6)
8354
+ ]
8355
+ }, undefined, true, undefined, this),
8356
+ /* @__PURE__ */ jsxDEV4(Text4, {
8357
+ color: codeTheme.brand,
8358
+ children: "|"
8423
8359
  }, undefined, false, undefined, this)
8424
8360
  ]
8425
8361
  }, undefined, true, undefined, this),
8426
- !visionCached || !embedCached ? /* @__PURE__ */ jsxDEV6(Box6, {
8427
- marginTop: 1,
8428
- flexDirection: "column",
8429
- children: [
8430
- /* @__PURE__ */ jsxDEV6(Text6, {
8431
- bold: true,
8432
- color: runtimeReady ? codeTheme.warning : codeTheme.danger,
8433
- children: runtimeReady ? "Download local models now? [y/n]" : "Local runtime missing - preload unavailable"
8434
- }, undefined, false, undefined, this),
8435
- /* @__PURE__ */ jsxDEV6(Text6, {
8436
- color: codeTheme.muted,
8437
- children: runtimeReady ? "Vision + embeddings. Download size varies by model version and runtime." : "Install dependencies so @huggingface/transformers is available, then rerun setup."
8438
- }, undefined, false, undefined, this)
8439
- ]
8440
- }, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV6(OnboardingHint, {
8441
- children: "Press Enter to continue."
8442
- }, undefined, false, undefined, this),
8443
- downloadError ? /* @__PURE__ */ jsxDEV6(Text6, {
8362
+ checking ? /* @__PURE__ */ jsxDEV4(Text4, {
8363
+ color: codeTheme.warning,
8364
+ children: "Verification in progress..."
8365
+ }, undefined, false, undefined, this) : null,
8366
+ error ? /* @__PURE__ */ jsxDEV4(Text4, {
8444
8367
  color: codeTheme.danger,
8445
- children: downloadError
8368
+ children: error
8446
8369
  }, undefined, false, undefined, this) : null,
8447
- !visionCached && !embedCached && !runtimeReady ? /* @__PURE__ */ jsxDEV6(OnboardingHint, {
8448
- children: "Press Enter to continue without local preload."
8449
- }, undefined, false, undefined, this) : null
8370
+ /* @__PURE__ */ jsxDEV4(OnboardingHint, {
8371
+ children: "Ctrl+V to paste. Press Enter to validate and continue."
8372
+ }, undefined, false, undefined, this)
8450
8373
  ]
8451
8374
  }, undefined, true, undefined, this);
8452
8375
  }
8453
- var init_WizardStep5Features = __esm(() => {
8454
- init_sandbox();
8455
- init_modelManager();
8376
+ var init_WizardStep2ApiKey = __esm(() => {
8377
+ init_clipboard();
8456
8378
  init_theme();
8457
- init_ProgressBar();
8458
8379
  init_wizardHelper();
8459
8380
  });
8460
8381
 
8461
- // src/ui/wizard/WizardStep6Ready.tsx
8462
- import { Box as Box7, Text as Text7, useInput as useInput6 } from "ink";
8463
- import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
8464
- function WizardStep6Ready({ data, diagnostics, onNext }) {
8465
- useInput6((_, key) => {
8382
+ // src/ui/wizard/WizardStep3Test.tsx
8383
+ import { useEffect, useState as useState2 } from "react";
8384
+ import { Box as Box5, Text as Text5, useInput as useInput3 } from "ink";
8385
+ import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
8386
+ function WizardStep3Test({ apiKey, onNext }) {
8387
+ const [status, setStatus] = useState2("idle");
8388
+ useEffect(() => {
8389
+ setStatus("testing");
8390
+ (async () => {
8391
+ try {
8392
+ const res = await fetch("https://gen.pollinations.ai/v1/chat/completions", {
8393
+ method: "POST",
8394
+ headers: {
8395
+ "Content-Type": "application/json",
8396
+ Authorization: `Bearer ${apiKey}`
8397
+ },
8398
+ body: JSON.stringify({
8399
+ model: "mistral",
8400
+ messages: [{ role: "user", content: "ping" }],
8401
+ max_tokens: 4
8402
+ }),
8403
+ signal: AbortSignal.timeout(8000)
8404
+ });
8405
+ setStatus(res.ok ? "ok" : "warn");
8406
+ } catch {
8407
+ setStatus("warn");
8408
+ }
8409
+ })();
8410
+ }, [apiKey]);
8411
+ useInput3((_, key) => {
8466
8412
  if (key.return)
8467
8413
  onNext();
8468
8414
  });
8469
- const preloadLabel = data.modelPreloadStatus === "already_cached" ? "already cached" : data.modelPreloadStatus === "downloaded" ? "downloaded now" : data.modelPreloadStatus === "runtime_missing" ? "unavailable (runtime missing)" : data.modelPreloadStatus === "failed" ? "download failed" : "lazy on first use";
8470
- return /* @__PURE__ */ jsxDEV7(Box7, {
8415
+ return /* @__PURE__ */ jsxDEV5(Box5, {
8471
8416
  flexDirection: "column",
8472
8417
  gap: 1,
8473
8418
  children: [
8474
- /* @__PURE__ */ jsxDEV7(Text7, {
8419
+ /* @__PURE__ */ jsxDEV5(Text5, {
8475
8420
  color: codeTheme.text,
8476
- children: "The shell is configured. This is the runtime profile Code will start with."
8421
+ children: "Before entering the shell, Code probes the configured endpoint to avoid a dead setup on first use."
8477
8422
  }, undefined, false, undefined, this),
8478
- /* @__PURE__ */ jsxDEV7(Box7, {
8479
- marginTop: 1,
8480
- flexDirection: "column",
8481
- children: [
8482
- /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8483
- label: "Default model",
8484
- value: data.model
8485
- }, undefined, false, undefined, this),
8486
- /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8487
- label: "Language",
8488
- value: data.language
8489
- }, undefined, false, undefined, this),
8490
- /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8491
- label: "Vision",
8492
- value: data.visionSource
8493
- }, undefined, false, undefined, this),
8494
- /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8495
- label: "Sandbox",
8496
- value: data.sandboxMode
8497
- }, undefined, false, undefined, this),
8498
- /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8499
- label: "Model preload",
8500
- value: preloadLabel,
8501
- tone: data.modelPreloadStatus === "downloaded" || data.modelPreloadStatus === "already_cached" ? "success" : data.modelPreloadStatus === "runtime_missing" || data.modelPreloadStatus === "failed" ? "warning" : "text"
8502
- }, undefined, false, undefined, this)
8503
- ]
8504
- }, undefined, true, undefined, this),
8505
- /* @__PURE__ */ jsxDEV7(Box7, {
8423
+ status === "testing" ? /* @__PURE__ */ jsxDEV5(LoadingState, {
8424
+ message: "Testing model access",
8425
+ subMessage: "Polling the API with a minimal request."
8426
+ }, undefined, false, undefined, this) : null,
8427
+ status === "ok" ? /* @__PURE__ */ jsxDEV5(Text5, {
8428
+ color: codeTheme.success,
8429
+ children: "API check passed."
8430
+ }, undefined, false, undefined, this) : null,
8431
+ status === "warn" ? /* @__PURE__ */ jsxDEV5(Text5, {
8432
+ color: codeTheme.warning,
8433
+ children: "Could not fully validate. You can still continue."
8434
+ }, undefined, false, undefined, this) : null,
8435
+ /* @__PURE__ */ jsxDEV5(OnboardingHint, {
8436
+ children: "Press Enter to continue."
8437
+ }, undefined, false, undefined, this)
8438
+ ]
8439
+ }, undefined, true, undefined, this);
8440
+ }
8441
+ var init_WizardStep3Test = __esm(() => {
8442
+ init_ProgressBar();
8443
+ init_theme();
8444
+ init_wizardHelper();
8445
+ });
8446
+
8447
+ // src/ui/wizard/WizardStep4Model.tsx
8448
+ import { useState as useState3 } from "react";
8449
+ import { Box as Box6, Text as Text6, useInput as useInput4 } from "ink";
8450
+ import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
8451
+ function WizardStep4Model({ onNext }) {
8452
+ const [modelIndex, setModelIndex] = useState3(0);
8453
+ const [langIndex, setLangIndex] = useState3(0);
8454
+ const [editing, setEditing] = useState3("model");
8455
+ useInput4((_, key) => {
8456
+ if (key.upArrow) {
8457
+ if (editing === "model")
8458
+ setModelIndex((i) => Math.max(0, i - 1));
8459
+ else
8460
+ setLangIndex((i) => Math.max(0, i - 1));
8461
+ return;
8462
+ }
8463
+ if (key.downArrow) {
8464
+ if (editing === "model")
8465
+ setModelIndex((i) => Math.min(MODELS.length - 1, i + 1));
8466
+ else
8467
+ setLangIndex((i) => Math.min(LANGUAGES.length - 1, i + 1));
8468
+ return;
8469
+ }
8470
+ if (key.tab) {
8471
+ setEditing((e) => e === "model" ? "lang" : "model");
8472
+ return;
8473
+ }
8474
+ if (key.return) {
8475
+ onNext(MODELS[modelIndex], LANGUAGES[langIndex]);
8476
+ }
8477
+ });
8478
+ return /* @__PURE__ */ jsxDEV6(Box6, {
8479
+ flexDirection: "column",
8480
+ gap: 1,
8481
+ children: [
8482
+ /* @__PURE__ */ jsxDEV6(Text6, {
8483
+ color: codeTheme.text,
8484
+ children: "Pick the default routing posture for the shell. You can still override it later with `/model`."
8485
+ }, undefined, false, undefined, this),
8486
+ /* @__PURE__ */ jsxDEV6(Box6, {
8506
8487
  marginTop: 1,
8507
8488
  flexDirection: "column",
8508
8489
  children: [
8509
- /* @__PURE__ */ jsxDEV7(Text7, {
8510
- color: codeTheme.brandStrong,
8511
- children: "Ready for first task"
8512
- }, undefined, false, undefined, this),
8513
- /* @__PURE__ */ jsxDEV7(Text7, {
8490
+ /* @__PURE__ */ jsxDEV6(Text6, {
8514
8491
  color: codeTheme.muted,
8515
- children: "Chat opens as the OAL SARL Code shell with the UI language and model defaults you picked here."
8516
- }, undefined, false, undefined, this)
8492
+ children: "Model"
8493
+ }, undefined, false, undefined, this),
8494
+ MODELS.map((model, index) => /* @__PURE__ */ jsxDEV6(OnboardingChoice, {
8495
+ active: editing === "model" && modelIndex === index,
8496
+ label: model,
8497
+ detail: model === "mistral" ? "Balanced default for day-to-day execution." : model === "gemini-fast" ? "Fast response profile for lightweight tasks." : "Bigger-context profile for heavier planning."
8498
+ }, model, false, undefined, this))
8517
8499
  ]
8518
8500
  }, undefined, true, undefined, this),
8519
- data.modelPreloadStatus === "failed" || data.modelPreloadStatus === "runtime_missing" ? /* @__PURE__ */ jsxDEV7(Box7, {
8520
- marginTop: 1,
8501
+ /* @__PURE__ */ jsxDEV6(Box6, {
8521
8502
  flexDirection: "column",
8522
8503
  children: [
8523
- /* @__PURE__ */ jsxDEV7(Text7, {
8524
- color: codeTheme.warning,
8525
- children: "Local model preload issue"
8526
- }, undefined, false, undefined, this),
8527
- /* @__PURE__ */ jsxDEV7(Text7, {
8504
+ /* @__PURE__ */ jsxDEV6(Text6, {
8528
8505
  color: codeTheme.muted,
8529
- children: data.modelPreloadError ?? "Local models were not preloaded. Code can still start, and local capabilities can be retried later."
8530
- }, undefined, false, undefined, this)
8531
- ]
8532
- }, undefined, true, undefined, this) : null,
8533
- diagnostics && diagnostics.warnings.length > 0 ? /* @__PURE__ */ jsxDEV7(Box7, {
8534
- marginTop: 1,
8535
- flexDirection: "column",
8536
- children: [
8537
- /* @__PURE__ */ jsxDEV7(Text7, {
8538
- color: codeTheme.warning,
8539
- children: "Attention before launch"
8506
+ children: "Language"
8540
8507
  }, undefined, false, undefined, this),
8541
- diagnostics.warnings.slice(0, 3).map((warning) => /* @__PURE__ */ jsxDEV7(Text7, {
8542
- color: codeTheme.muted,
8543
- children: warning
8544
- }, warning, false, undefined, this))
8508
+ LANGUAGES.map((language, index) => /* @__PURE__ */ jsxDEV6(OnboardingChoice, {
8509
+ active: editing === "lang" && langIndex === index,
8510
+ label: language,
8511
+ detail: language === "auto" ? "Infer from the environment." : `Force ${language.toUpperCase()} responses.`
8512
+ }, language, false, undefined, this))
8545
8513
  ]
8546
- }, undefined, true, undefined, this) : null,
8547
- /* @__PURE__ */ jsxDEV7(OnboardingHint, {
8548
- children: "Press Enter to start Code."
8514
+ }, undefined, true, undefined, this),
8515
+ /* @__PURE__ */ jsxDEV6(OnboardingHint, {
8516
+ children: "Use Up/Down to change the active field, Tab to switch field, Enter to continue."
8549
8517
  }, undefined, false, undefined, this)
8550
8518
  ]
8551
8519
  }, undefined, true, undefined, this);
8552
8520
  }
8553
- var init_WizardStep6Ready = __esm(() => {
8521
+ var MODELS, LANGUAGES;
8522
+ var init_WizardStep4Model = __esm(() => {
8554
8523
  init_theme();
8555
8524
  init_wizardHelper();
8525
+ MODELS = ["mistral", "gemini-fast", "kimi"];
8526
+ LANGUAGES = ["auto", "fr", "en"];
8556
8527
  });
8557
8528
 
8558
- // src/ui/wizard/WizardContainer.tsx
8559
- import { useEffect as useEffect3, useState as useState5 } from "react";
8560
- import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
8561
- function WizardContainer({ onComplete }) {
8562
- const [step, setStep] = useState5(1);
8563
- const [data, setData] = useState5({});
8564
- const [diagnostics, setDiagnostics] = useState5(null);
8565
- const total = 6;
8566
- useEffect3(() => {
8529
+ // src/ui/wizard/WizardStep5Features.tsx
8530
+ import { useEffect as useEffect2, useState as useState4 } from "react";
8531
+ import { Box as Box7, Text as Text7, useInput as useInput5 } from "ink";
8532
+ import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
8533
+ function WizardStep5Features({ diagnostics, onNext }) {
8534
+ const [detecting, setDetecting] = useState4(true);
8535
+ const [dockerAvailable, setDockerAvailable] = useState4(false);
8536
+ const [visionCached, setVisionCached] = useState4(false);
8537
+ const [embedCached, setEmbedCached] = useState4(false);
8538
+ const [downloading, setDownloading] = useState4(false);
8539
+ const [downloadChoice, setDownloadChoice] = useState4(null);
8540
+ const [downloadLabel, setDownloadLabel] = useState4("Preparation...");
8541
+ const [downloadError, setDownloadError] = useState4("");
8542
+ const runtimeReady = diagnostics?.capabilities.find((item) => item.key === "transformers")?.status === "ready";
8543
+ useEffect2(() => {
8567
8544
  (async () => {
8568
- const nextDiagnostics = await detectPlatformDiagnostics().catch(() => null);
8569
- setDiagnostics(nextDiagnostics);
8545
+ const [hasDocker, visionReady, embedReady] = await Promise.all([
8546
+ detectDockerAvailability(),
8547
+ isModelCached(VISION_MODEL_ID),
8548
+ isModelCached(EMBED_MODEL_ID)
8549
+ ]);
8550
+ setDockerAvailable(hasDocker);
8551
+ setVisionCached(visionReady);
8552
+ setEmbedCached(embedReady);
8553
+ setDetecting(false);
8570
8554
  })();
8571
8555
  }, []);
8572
- const next = async (partial) => {
8573
- const merged = { ...data, ...partial };
8574
- setData(merged);
8575
- if (step < total) {
8576
- if (step === 5) {
8577
- const nextDiagnostics = await detectPlatformDiagnostics().catch(() => null);
8578
- setDiagnostics(nextDiagnostics);
8579
- }
8580
- setStep(step + 1);
8556
+ useInput5(async (input, key) => {
8557
+ if (detecting || downloading)
8558
+ return;
8559
+ if (visionCached && embedCached && key.return) {
8560
+ onNext({
8561
+ enableVision: true,
8562
+ visionSource: "embedded",
8563
+ enableSandbox: dockerAvailable,
8564
+ sandboxMode: dockerAvailable ? "docker" : "safe",
8565
+ modelPreloadStatus: "already_cached",
8566
+ modelPreloadError: undefined
8567
+ });
8581
8568
  return;
8582
8569
  }
8583
- settings.setApiKey(merged.apiKey ?? "");
8584
- settings.set("defaultModel", merged.model ?? "mistral");
8585
- settings.set("language", merged.language ?? "auto");
8586
- settings.set("visionModel", merged.visionSource ?? "embedded");
8587
- settings.set("sandboxMode", merged.sandboxMode ?? "safe");
8588
- settings.set("visionModelCached", await isModelCached(VISION_MODEL_ID));
8589
- settings.set("embeddingModelCached", await isModelCached(EMBED_MODEL_ID));
8590
- settings.set("setupCompleted", true);
8591
- settings.set("setupVersion", CURRENT_SETUP_VERSION);
8592
- onComplete(merged);
8593
- };
8594
- const steps = [
8595
- /* @__PURE__ */ jsxDEV8(WizardStep1Welcome, {
8596
- diagnostics,
8597
- onNext: () => void next({})
8598
- }, 1, false, undefined, this),
8599
- /* @__PURE__ */ jsxDEV8(WizardStep2ApiKey, {
8600
- onNext: (apiKey) => void next({ apiKey })
8601
- }, 2, false, undefined, this),
8602
- /* @__PURE__ */ jsxDEV8(WizardStep3Test, {
8603
- apiKey: data.apiKey ?? "",
8604
- onNext: () => void next({})
8605
- }, 3, false, undefined, this),
8606
- /* @__PURE__ */ jsxDEV8(WizardStep4Model, {
8607
- onNext: (model, language) => void next({ model, language })
8608
- }, 4, false, undefined, this),
8609
- /* @__PURE__ */ jsxDEV8(WizardStep5Features, {
8610
- diagnostics,
8611
- onNext: (opts) => void next(opts)
8612
- }, 5, false, undefined, this),
8613
- /* @__PURE__ */ jsxDEV8(WizardStep6Ready, {
8614
- data,
8615
- diagnostics,
8616
- onNext: () => void next({})
8617
- }, 6, false, undefined, this)
8618
- ];
8619
- const stepMeta = [
8620
- {
8621
- eyebrow: "Orientation",
8622
- title: "Start with the shell",
8623
- description: "Get the product shape, capabilities and operating mode before configuration."
8624
- },
8625
- {
8626
- eyebrow: "Security",
8627
- title: "Connect the model",
8628
- description: "Register the API key and validate the trust boundary early."
8629
- },
8630
- {
8631
- eyebrow: "Connectivity",
8632
- title: "Probe the runtime",
8633
- description: "Check that Code can actually reach the configured model endpoint."
8634
- },
8635
- {
8636
- eyebrow: "Defaults",
8637
- title: "Choose your working style",
8638
- description: "Select default model and language for the shell and non-TTY runs."
8639
- },
8640
- {
8641
- eyebrow: "Local capabilities",
8642
- title: "Enable embedded features",
8643
- description: "Inspect sandbox and local model cache before the first real task."
8644
- },
8645
- {
8646
- eyebrow: "Ready",
8647
- title: "Review and launch",
8648
- description: "Confirm the final setup and enter the product with a clear runtime profile."
8570
+ if (!runtimeReady && key.return) {
8571
+ onNext({
8572
+ enableVision: true,
8573
+ visionSource: "embedded",
8574
+ enableSandbox: dockerAvailable,
8575
+ sandboxMode: dockerAvailable ? "docker" : "safe",
8576
+ modelPreloadStatus: "runtime_missing",
8577
+ modelPreloadError: "Local runtime missing. Install project dependencies first, then rerun setup."
8578
+ });
8579
+ return;
8649
8580
  }
8650
- ];
8651
- return /* @__PURE__ */ jsxDEV8(OnboardingShell, {
8652
- step,
8653
- total,
8654
- steps: stepMeta,
8655
- children: steps[step - 1]
8656
- }, undefined, false, undefined, this);
8657
- }
8658
- var init_WizardContainer = __esm(() => {
8659
- init_settings();
8660
- init_modelManager();
8661
- init_platformDiagnostics();
8662
- init_WizardStep1Welcome();
8663
- init_WizardStep2ApiKey();
8664
- init_WizardStep3Test();
8665
- init_WizardStep4Model();
8666
- init_WizardStep5Features();
8667
- init_WizardStep6Ready();
8668
- init_wizardHelper();
8669
- });
8670
-
8671
- // src/ui/wizard/wizardHelper.tsx
8672
- var exports_wizardHelper = {};
8673
- __export(exports_wizardHelper, {
8674
- waitForWizard: () => waitForWizard,
8675
- OnboardingShell: () => OnboardingShell,
8676
- OnboardingMetric: () => OnboardingMetric,
8677
- OnboardingHint: () => OnboardingHint,
8678
- OnboardingChoice: () => OnboardingChoice
8679
- });
8680
- import { Box as Box8, Text as Text8, render } from "ink";
8681
- import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
8682
- function waitForWizard() {
8683
- return new Promise((resolve) => {
8684
- const instance = render(/* @__PURE__ */ jsxDEV9(WizardContainer, {
8685
- onComplete: (data) => {
8686
- instance.unmount();
8687
- instance.waitUntilExit().then(() => resolve(data));
8581
+ if (downloadChoice !== null)
8582
+ return;
8583
+ if (input === "y" || input === "Y") {
8584
+ if (!runtimeReady) {
8585
+ setDownloadError("Local runtime missing. Install project dependencies first, then rerun setup.");
8586
+ return;
8587
+ }
8588
+ setDownloadChoice("y");
8589
+ setDownloading(true);
8590
+ setDownloadError("");
8591
+ try {
8592
+ setDownloadLabel("Vision locale (~230MB)...");
8593
+ await downloadModel(VISION_MODEL_ID);
8594
+ setDownloadLabel("Embeddings semantiques (~22MB)...");
8595
+ await downloadModel(EMBED_MODEL_ID);
8596
+ const [visionReady, embedReady] = await Promise.all([
8597
+ isModelCached(VISION_MODEL_ID),
8598
+ isModelCached(EMBED_MODEL_ID)
8599
+ ]);
8600
+ setVisionCached(visionReady);
8601
+ setEmbedCached(embedReady);
8602
+ if (!visionReady || !embedReady) {
8603
+ throw new Error("Local preload completed without a persistent cache. Code will retry the missing models on first use.");
8604
+ }
8605
+ } catch (error) {
8606
+ const message = error instanceof Error ? error.message : "Model download failed.";
8607
+ setDownloading(false);
8608
+ setDownloadChoice(null);
8609
+ setDownloadError(message);
8610
+ onNext({
8611
+ enableVision: true,
8612
+ visionSource: "embedded",
8613
+ enableSandbox: dockerAvailable,
8614
+ sandboxMode: dockerAvailable ? "docker" : "safe",
8615
+ modelPreloadStatus: "failed",
8616
+ modelPreloadError: message
8617
+ });
8618
+ return;
8688
8619
  }
8689
- }, undefined, false, undefined, this));
8620
+ setDownloading(false);
8621
+ onNext({
8622
+ enableVision: true,
8623
+ visionSource: "embedded",
8624
+ enableSandbox: dockerAvailable,
8625
+ sandboxMode: dockerAvailable ? "docker" : "safe",
8626
+ modelPreloadStatus: "downloaded",
8627
+ modelPreloadError: undefined
8628
+ });
8629
+ return;
8630
+ }
8631
+ if (input === "n" || input === "N") {
8632
+ setDownloadChoice("n");
8633
+ onNext({
8634
+ enableVision: true,
8635
+ visionSource: "embedded",
8636
+ enableSandbox: dockerAvailable,
8637
+ sandboxMode: dockerAvailable ? "docker" : "safe",
8638
+ modelPreloadStatus: runtimeReady ? "lazy" : "runtime_missing",
8639
+ modelPreloadError: runtimeReady ? undefined : "Local runtime missing. Install project dependencies first, then rerun setup."
8640
+ });
8641
+ }
8690
8642
  });
8691
- }
8692
- function OnboardingShell({ step, total, steps, children }) {
8693
- const active = steps[Math.max(0, step - 1)];
8694
- const progress = step / Math.max(total, 1) * 100;
8695
- return /* @__PURE__ */ jsxDEV9(Box8, {
8643
+ if (detecting) {
8644
+ return /* @__PURE__ */ jsxDEV7(LoadingState, {
8645
+ message: "Scanning local capabilities",
8646
+ subMessage: "Inspecting Docker and local model cache."
8647
+ }, undefined, false, undefined, this);
8648
+ }
8649
+ if (downloading) {
8650
+ return /* @__PURE__ */ jsxDEV7(LoadingState, {
8651
+ message: "Downloading local models",
8652
+ subMessage: `${downloadLabel} Downloading sequentially to keep the setup stable.`
8653
+ }, undefined, false, undefined, this);
8654
+ }
8655
+ return /* @__PURE__ */ jsxDEV7(Box7, {
8696
8656
  flexDirection: "column",
8697
- paddingX: 1,
8657
+ gap: 1,
8698
8658
  children: [
8699
- /* @__PURE__ */ jsxDEV9(Box8, {
8700
- justifyContent: "space-between",
8701
- marginBottom: 1,
8659
+ /* @__PURE__ */ jsxDEV7(Text7, {
8660
+ color: codeTheme.text,
8661
+ children: "Code can preload local models now or keep them lazy-loaded for the first real use."
8662
+ }, undefined, false, undefined, this),
8663
+ /* @__PURE__ */ jsxDEV7(Box7, {
8664
+ flexDirection: "column",
8665
+ marginTop: 1,
8702
8666
  children: [
8703
- /* @__PURE__ */ jsxDEV9(Box8, {
8704
- gap: 1,
8705
- children: [
8706
- /* @__PURE__ */ jsxDEV9(Text8, {
8707
- bold: true,
8708
- color: codeTheme.brandStrong,
8709
- children: "Code"
8710
- }, undefined, false, undefined, this),
8711
- /* @__PURE__ */ jsxDEV9(Text8, {
8712
- color: codeTheme.muted,
8713
- children: "OAL SARL | v6 onboarding"
8714
- }, undefined, false, undefined, this)
8715
- ]
8716
- }, undefined, true, undefined, this),
8717
- /* @__PURE__ */ jsxDEV9(Text8, {
8718
- color: codeTheme.muted,
8719
- children: [
8720
- "Step ",
8721
- step,
8722
- "/",
8723
- total
8724
- ]
8725
- }, undefined, true, undefined, this)
8667
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8668
+ label: "Shell runtime",
8669
+ value: diagnostics?.shellLabel ?? "detecting...",
8670
+ tone: diagnostics ? diagnostics.shellSupportsPosix ? "success" : "warning" : "text"
8671
+ }, undefined, false, undefined, this),
8672
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8673
+ label: "Vision",
8674
+ value: "embedded local pipeline",
8675
+ tone: "success"
8676
+ }, undefined, false, undefined, this),
8677
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8678
+ label: "Embeddings",
8679
+ value: "semantic index ready",
8680
+ tone: "success"
8681
+ }, undefined, false, undefined, this),
8682
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8683
+ label: "Sandbox",
8684
+ value: dockerAvailable ? "docker available" : "safe mode only",
8685
+ tone: dockerAvailable ? "success" : "warning"
8686
+ }, undefined, false, undefined, this),
8687
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8688
+ label: "Vision cache",
8689
+ value: visionCached ? "already cached" : "download required",
8690
+ tone: visionCached ? "success" : "warning"
8691
+ }, undefined, false, undefined, this),
8692
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8693
+ label: "Embedding cache",
8694
+ value: embedCached ? "already cached" : "download required",
8695
+ tone: embedCached ? "success" : "warning"
8696
+ }, undefined, false, undefined, this),
8697
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8698
+ label: "Image preprocessing",
8699
+ value: diagnostics?.capabilities.find((item) => item.key === "sharp")?.detail ?? "detecting...",
8700
+ tone: diagnostics?.capabilities.find((item) => item.key === "sharp")?.status === "ready" ? "success" : "warning"
8701
+ }, undefined, false, undefined, this),
8702
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8703
+ label: "Screenshots",
8704
+ value: diagnostics?.capabilities.find((item) => item.key === "playwright")?.detail ?? "detecting...",
8705
+ tone: diagnostics?.capabilities.find((item) => item.key === "playwright")?.status === "ready" ? "success" : "warning"
8706
+ }, undefined, false, undefined, this),
8707
+ /* @__PURE__ */ jsxDEV7(OnboardingMetric, {
8708
+ label: "Validation",
8709
+ value: "judge + transactions enabled",
8710
+ tone: "success"
8711
+ }, undefined, false, undefined, this)
8726
8712
  ]
8727
8713
  }, undefined, true, undefined, this),
8728
- /* @__PURE__ */ jsxDEV9(Box8, {
8729
- marginBottom: 1,
8730
- children: /* @__PURE__ */ jsxDEV9(ProgressBar, {
8731
- progress,
8732
- width: 34,
8733
- color: codeTheme.brand,
8734
- showPercentage: false
8735
- }, undefined, false, undefined, this)
8736
- }, undefined, false, undefined, this),
8737
- /* @__PURE__ */ jsxDEV9(Box8, {
8738
- borderStyle: "round",
8739
- borderColor: codeTheme.line,
8740
- paddingX: 1,
8741
- paddingY: 1,
8714
+ !visionCached || !embedCached ? /* @__PURE__ */ jsxDEV7(Box7, {
8715
+ marginTop: 1,
8716
+ flexDirection: "column",
8742
8717
  children: [
8743
- /* @__PURE__ */ jsxDEV9(Box8, {
8744
- width: 26,
8745
- marginRight: 2,
8746
- flexDirection: "column",
8747
- children: [
8748
- /* @__PURE__ */ jsxDEV9(Text8, {
8749
- color: codeTheme.muted,
8750
- children: "Setup flow"
8751
- }, undefined, false, undefined, this),
8752
- /* @__PURE__ */ jsxDEV9(Box8, {
8753
- marginTop: 1,
8754
- flexDirection: "column",
8755
- children: steps.map((item, index) => {
8756
- const current = index + 1;
8757
- const done = current < step;
8758
- const activeStep = current === step;
8759
- return /* @__PURE__ */ jsxDEV9(Box8, {
8760
- marginBottom: 1,
8761
- flexDirection: "column",
8762
- children: [
8763
- /* @__PURE__ */ jsxDEV9(Text8, {
8764
- color: done ? codeTheme.success : activeStep ? codeTheme.brandStrong : codeTheme.muted,
8765
- children: [
8766
- done ? "OK" : activeStep ? ">" : "-",
8767
- " ",
8768
- item.title
8769
- ]
8770
- }, undefined, true, undefined, this),
8771
- /* @__PURE__ */ jsxDEV9(Text8, {
8772
- color: activeStep ? codeTheme.text : codeTheme.muted,
8773
- children: item.description
8774
- }, undefined, false, undefined, this)
8775
- ]
8776
- }, item.title, true, undefined, this);
8777
- })
8778
- }, undefined, false, undefined, this)
8779
- ]
8780
- }, undefined, true, undefined, this),
8781
- /* @__PURE__ */ jsxDEV9(Box8, {
8782
- flexGrow: 1,
8783
- flexDirection: "column",
8784
- borderStyle: "round",
8785
- borderColor: codeTheme.line,
8786
- paddingX: 1,
8787
- paddingY: 1,
8788
- children: [
8789
- /* @__PURE__ */ jsxDEV9(Text8, {
8790
- color: codeTheme.accent,
8791
- children: active.eyebrow
8792
- }, undefined, false, undefined, this),
8793
- /* @__PURE__ */ jsxDEV9(Text8, {
8794
- bold: true,
8795
- color: codeTheme.brandStrong,
8796
- children: active.title
8797
- }, undefined, false, undefined, this),
8798
- /* @__PURE__ */ jsxDEV9(Text8, {
8799
- color: codeTheme.muted,
8800
- children: active.description
8801
- }, undefined, false, undefined, this),
8802
- /* @__PURE__ */ jsxDEV9(Box8, {
8803
- marginTop: 1,
8804
- flexDirection: "column",
8805
- children
8806
- }, undefined, false, undefined, this)
8807
- ]
8808
- }, undefined, true, undefined, this)
8718
+ /* @__PURE__ */ jsxDEV7(Text7, {
8719
+ bold: true,
8720
+ color: runtimeReady ? codeTheme.warning : codeTheme.danger,
8721
+ children: runtimeReady ? "Download local models now? [y/n]" : "Local runtime missing - preload unavailable"
8722
+ }, undefined, false, undefined, this),
8723
+ /* @__PURE__ */ jsxDEV7(Text7, {
8724
+ color: codeTheme.muted,
8725
+ children: runtimeReady ? "Vision + embeddings. Download size varies by model version and runtime." : "Install dependencies so @huggingface/transformers is available, then rerun setup."
8726
+ }, undefined, false, undefined, this)
8809
8727
  ]
8810
- }, undefined, true, undefined, this)
8728
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsxDEV7(OnboardingHint, {
8729
+ children: "Press Enter to continue."
8730
+ }, undefined, false, undefined, this),
8731
+ downloadError ? /* @__PURE__ */ jsxDEV7(Text7, {
8732
+ color: codeTheme.danger,
8733
+ children: downloadError
8734
+ }, undefined, false, undefined, this) : null,
8735
+ !visionCached && !embedCached && !runtimeReady ? /* @__PURE__ */ jsxDEV7(OnboardingHint, {
8736
+ children: "Press Enter to continue without local preload."
8737
+ }, undefined, false, undefined, this) : null
8811
8738
  ]
8812
8739
  }, undefined, true, undefined, this);
8813
8740
  }
8814
- function OnboardingHint({ children }) {
8815
- return /* @__PURE__ */ jsxDEV9(Text8, {
8816
- color: codeTheme.muted,
8817
- children
8818
- }, undefined, false, undefined, this);
8819
- }
8820
- function OnboardingMetric({
8821
- label,
8822
- value,
8823
- tone = "text"
8824
- }) {
8825
- const color = tone === "success" ? codeTheme.success : tone === "warning" ? codeTheme.warning : codeTheme.text;
8826
- return /* @__PURE__ */ jsxDEV9(Box8, {
8827
- flexDirection: "row",
8828
- gap: 2,
8741
+ var init_WizardStep5Features = __esm(() => {
8742
+ init_sandbox();
8743
+ init_modelManager();
8744
+ init_theme();
8745
+ init_ProgressBar();
8746
+ init_wizardHelper();
8747
+ });
8748
+
8749
+ // src/ui/wizard/WizardStep6Ready.tsx
8750
+ import { Box as Box8, Text as Text8, useInput as useInput6 } from "ink";
8751
+ import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
8752
+ function WizardStep6Ready({ data, diagnostics, onNext }) {
8753
+ useInput6((_, key) => {
8754
+ if (key.return)
8755
+ onNext();
8756
+ });
8757
+ const preloadLabel = data.modelPreloadStatus === "already_cached" ? "already cached" : data.modelPreloadStatus === "downloaded" ? "downloaded now" : data.modelPreloadStatus === "runtime_missing" ? "unavailable (runtime missing)" : data.modelPreloadStatus === "failed" ? "download failed" : "lazy on first use";
8758
+ return /* @__PURE__ */ jsxDEV8(Box8, {
8759
+ flexDirection: "column",
8760
+ gap: 1,
8829
8761
  children: [
8830
- /* @__PURE__ */ jsxDEV9(Box8, {
8831
- width: 20,
8832
- flexShrink: 0,
8833
- children: /* @__PURE__ */ jsxDEV9(Text8, {
8834
- color: codeTheme.muted,
8835
- children: label
8836
- }, undefined, false, undefined, this)
8762
+ /* @__PURE__ */ jsxDEV8(Text8, {
8763
+ color: codeTheme.text,
8764
+ children: "The shell is configured. This is the runtime profile Code will start with."
8837
8765
  }, undefined, false, undefined, this),
8838
- /* @__PURE__ */ jsxDEV9(Box8, {
8839
- flexGrow: 1,
8840
- children: /* @__PURE__ */ jsxDEV9(Text8, {
8841
- color,
8842
- wrap: "wrap",
8843
- children: value
8844
- }, undefined, false, undefined, this)
8766
+ /* @__PURE__ */ jsxDEV8(Box8, {
8767
+ marginTop: 1,
8768
+ flexDirection: "column",
8769
+ children: [
8770
+ /* @__PURE__ */ jsxDEV8(OnboardingMetric, {
8771
+ label: "Default model",
8772
+ value: data.model
8773
+ }, undefined, false, undefined, this),
8774
+ /* @__PURE__ */ jsxDEV8(OnboardingMetric, {
8775
+ label: "Language",
8776
+ value: data.language
8777
+ }, undefined, false, undefined, this),
8778
+ /* @__PURE__ */ jsxDEV8(OnboardingMetric, {
8779
+ label: "Vision",
8780
+ value: data.visionSource
8781
+ }, undefined, false, undefined, this),
8782
+ /* @__PURE__ */ jsxDEV8(OnboardingMetric, {
8783
+ label: "Sandbox",
8784
+ value: data.sandboxMode
8785
+ }, undefined, false, undefined, this),
8786
+ /* @__PURE__ */ jsxDEV8(OnboardingMetric, {
8787
+ label: "Model preload",
8788
+ value: preloadLabel,
8789
+ tone: data.modelPreloadStatus === "downloaded" || data.modelPreloadStatus === "already_cached" ? "success" : data.modelPreloadStatus === "runtime_missing" || data.modelPreloadStatus === "failed" ? "warning" : "text"
8790
+ }, undefined, false, undefined, this)
8791
+ ]
8792
+ }, undefined, true, undefined, this),
8793
+ /* @__PURE__ */ jsxDEV8(Box8, {
8794
+ marginTop: 1,
8795
+ flexDirection: "column",
8796
+ children: [
8797
+ /* @__PURE__ */ jsxDEV8(Text8, {
8798
+ color: codeTheme.brandStrong,
8799
+ children: "Ready for first task"
8800
+ }, undefined, false, undefined, this),
8801
+ /* @__PURE__ */ jsxDEV8(Text8, {
8802
+ color: codeTheme.muted,
8803
+ children: "Chat opens as the OAL SARL Code shell with the UI language and model defaults you picked here."
8804
+ }, undefined, false, undefined, this)
8805
+ ]
8806
+ }, undefined, true, undefined, this),
8807
+ data.modelPreloadStatus === "failed" || data.modelPreloadStatus === "runtime_missing" ? /* @__PURE__ */ jsxDEV8(Box8, {
8808
+ marginTop: 1,
8809
+ flexDirection: "column",
8810
+ children: [
8811
+ /* @__PURE__ */ jsxDEV8(Text8, {
8812
+ color: codeTheme.warning,
8813
+ children: "Local model preload issue"
8814
+ }, undefined, false, undefined, this),
8815
+ /* @__PURE__ */ jsxDEV8(Text8, {
8816
+ color: codeTheme.muted,
8817
+ children: data.modelPreloadError ?? "Local models were not preloaded. Code can still start, and local capabilities can be retried later."
8818
+ }, undefined, false, undefined, this)
8819
+ ]
8820
+ }, undefined, true, undefined, this) : null,
8821
+ diagnostics && diagnostics.warnings.length > 0 ? /* @__PURE__ */ jsxDEV8(Box8, {
8822
+ marginTop: 1,
8823
+ flexDirection: "column",
8824
+ children: [
8825
+ /* @__PURE__ */ jsxDEV8(Text8, {
8826
+ color: codeTheme.warning,
8827
+ children: "Attention before launch"
8828
+ }, undefined, false, undefined, this),
8829
+ diagnostics.warnings.slice(0, 3).map((warning) => /* @__PURE__ */ jsxDEV8(Text8, {
8830
+ color: codeTheme.muted,
8831
+ children: warning
8832
+ }, warning, false, undefined, this))
8833
+ ]
8834
+ }, undefined, true, undefined, this) : null,
8835
+ /* @__PURE__ */ jsxDEV8(OnboardingHint, {
8836
+ children: "Press Enter to start Code."
8845
8837
  }, undefined, false, undefined, this)
8846
8838
  ]
8847
8839
  }, undefined, true, undefined, this);
8848
8840
  }
8849
- function OnboardingChoice({
8850
- active,
8851
- label,
8852
- detail
8853
- }) {
8854
- return /* @__PURE__ */ jsxDEV9(Box8, {
8855
- borderStyle: "round",
8856
- borderColor: active ? codeTheme.brand : codeTheme.line,
8857
- paddingX: 1,
8858
- marginBottom: 1,
8859
- children: /* @__PURE__ */ jsxDEV9(Box8, {
8860
- flexDirection: "column",
8861
- children: [
8862
- /* @__PURE__ */ jsxDEV9(Text8, {
8863
- color: active ? codeTheme.brandStrong : codeTheme.text,
8864
- children: [
8865
- active ? ">" : " ",
8866
- " ",
8867
- label
8868
- ]
8869
- }, undefined, true, undefined, this),
8870
- /* @__PURE__ */ jsxDEV9(Text8, {
8871
- color: codeTheme.muted,
8872
- children: detail
8873
- }, undefined, false, undefined, this)
8874
- ]
8875
- }, undefined, true, undefined, this)
8841
+ var init_WizardStep6Ready = __esm(() => {
8842
+ init_theme();
8843
+ init_wizardHelper();
8844
+ });
8845
+
8846
+ // src/ui/wizard/WizardContainer.tsx
8847
+ import { useEffect as useEffect3, useState as useState5 } from "react";
8848
+ import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
8849
+ function WizardContainer({ onComplete }) {
8850
+ const [step, setStep] = useState5(1);
8851
+ const [data, setData] = useState5({});
8852
+ const [diagnostics, setDiagnostics] = useState5(null);
8853
+ const total = 6;
8854
+ useEffect3(() => {
8855
+ (async () => {
8856
+ const nextDiagnostics = await detectPlatformDiagnostics().catch(() => null);
8857
+ setDiagnostics(nextDiagnostics);
8858
+ })();
8859
+ }, []);
8860
+ const next = async (partial) => {
8861
+ const merged = { ...data, ...partial };
8862
+ setData(merged);
8863
+ if (step < total) {
8864
+ if (step === 5) {
8865
+ const nextDiagnostics = await detectPlatformDiagnostics().catch(() => null);
8866
+ setDiagnostics(nextDiagnostics);
8867
+ }
8868
+ setStep(step + 1);
8869
+ return;
8870
+ }
8871
+ settings.setApiKey(merged.apiKey ?? "");
8872
+ settings.set("defaultModel", merged.model ?? "mistral");
8873
+ settings.set("language", merged.language ?? "auto");
8874
+ settings.set("visionModel", merged.visionSource ?? "embedded");
8875
+ settings.set("sandboxMode", merged.sandboxMode ?? "safe");
8876
+ settings.set("visionModelCached", await isModelCached(VISION_MODEL_ID));
8877
+ settings.set("embeddingModelCached", await isModelCached(EMBED_MODEL_ID));
8878
+ settings.set("setupCompleted", true);
8879
+ settings.set("setupVersion", CURRENT_SETUP_VERSION);
8880
+ onComplete(merged);
8881
+ };
8882
+ const steps = [
8883
+ /* @__PURE__ */ jsxDEV9(WizardStep1Welcome, {
8884
+ diagnostics,
8885
+ onNext: () => void next({})
8886
+ }, 1, false, undefined, this),
8887
+ /* @__PURE__ */ jsxDEV9(WizardStep2ApiKey, {
8888
+ onNext: (apiKey) => void next({ apiKey })
8889
+ }, 2, false, undefined, this),
8890
+ /* @__PURE__ */ jsxDEV9(WizardStep3Test, {
8891
+ apiKey: data.apiKey ?? "",
8892
+ onNext: () => void next({})
8893
+ }, 3, false, undefined, this),
8894
+ /* @__PURE__ */ jsxDEV9(WizardStep4Model, {
8895
+ onNext: (model, language) => void next({ model, language })
8896
+ }, 4, false, undefined, this),
8897
+ /* @__PURE__ */ jsxDEV9(WizardStep5Features, {
8898
+ diagnostics,
8899
+ onNext: (opts) => void next(opts)
8900
+ }, 5, false, undefined, this),
8901
+ /* @__PURE__ */ jsxDEV9(WizardStep6Ready, {
8902
+ data,
8903
+ diagnostics,
8904
+ onNext: () => void next({})
8905
+ }, 6, false, undefined, this)
8906
+ ];
8907
+ const stepMeta = [
8908
+ {
8909
+ eyebrow: "Orientation",
8910
+ title: "Start with the shell",
8911
+ description: "Get the product shape, capabilities and operating mode before configuration."
8912
+ },
8913
+ {
8914
+ eyebrow: "Security",
8915
+ title: "Connect the model",
8916
+ description: "Register the API key and validate the trust boundary early."
8917
+ },
8918
+ {
8919
+ eyebrow: "Connectivity",
8920
+ title: "Probe the runtime",
8921
+ description: "Check that Code can actually reach the configured model endpoint."
8922
+ },
8923
+ {
8924
+ eyebrow: "Defaults",
8925
+ title: "Choose your working style",
8926
+ description: "Select default model and language for the shell and non-TTY runs."
8927
+ },
8928
+ {
8929
+ eyebrow: "Local capabilities",
8930
+ title: "Enable embedded features",
8931
+ description: "Inspect sandbox and local model cache before the first real task."
8932
+ },
8933
+ {
8934
+ eyebrow: "Ready",
8935
+ title: "Review and launch",
8936
+ description: "Confirm the final setup and enter the product with a clear runtime profile."
8937
+ }
8938
+ ];
8939
+ return /* @__PURE__ */ jsxDEV9(OnboardingShell, {
8940
+ step,
8941
+ total,
8942
+ steps: stepMeta,
8943
+ children: steps[step - 1]
8876
8944
  }, undefined, false, undefined, this);
8877
8945
  }
8878
- var init_wizardHelper = __esm(() => {
8879
- init_WizardContainer();
8880
- init_theme();
8881
- init_ProgressBar();
8946
+ var init_WizardContainer = __esm(() => {
8947
+ init_settings();
8948
+ init_modelManager();
8949
+ init_platformDiagnostics();
8950
+ init_WizardStep1Welcome();
8951
+ init_WizardStep2ApiKey();
8952
+ init_WizardStep3Test();
8953
+ init_WizardStep4Model();
8954
+ init_WizardStep5Features();
8955
+ init_WizardStep6Ready();
8956
+ init_wizardHelper();
8882
8957
  });
8883
8958
 
8884
8959
  // src/ui/Header.tsx
@@ -8895,11 +8970,11 @@ function Header({ model, env, sessionCount, skillCount }) {
8895
8970
  /* @__PURE__ */ jsxDEV10(Text9, {
8896
8971
  bold: true,
8897
8972
  color: codeTheme.brandStrong,
8898
- children: "Code"
8973
+ children: PRODUCT_NAME
8899
8974
  }, undefined, false, undefined, this),
8900
8975
  /* @__PURE__ */ jsxDEV10(Text9, {
8901
8976
  color: codeTheme.muted,
8902
- children: "v6"
8977
+ children: PRODUCT_MAJOR_LABEL
8903
8978
  }, undefined, false, undefined, this),
8904
8979
  /* @__PURE__ */ jsxDEV10(Text9, {
8905
8980
  color: codeTheme.line,
@@ -8958,6 +9033,7 @@ function Header({ model, env, sessionCount, skillCount }) {
8958
9033
  }
8959
9034
  var init_Header = __esm(() => {
8960
9035
  init_theme();
9036
+ init_productMeta();
8961
9037
  });
8962
9038
 
8963
9039
  // src/ui/HistoryBrowser.tsx
@@ -12209,14 +12285,14 @@ var init_sessionManager = __esm(() => {
12209
12285
  });
12210
12286
 
12211
12287
  // src/platform/multiAgent.ts
12212
- import fs16 from "fs/promises";
12288
+ import fs17 from "fs/promises";
12213
12289
  import os8 from "os";
12214
12290
  import path18 from "path";
12215
12291
  import lockfile from "proper-lockfile";
12216
12292
  async function withProjectLock(projectDir, fn) {
12217
- await fs16.mkdir(LOCK_DIR, { recursive: true });
12293
+ await fs17.mkdir(LOCK_DIR, { recursive: true });
12218
12294
  const lockTarget = path18.join(LOCK_DIR, Buffer.from(projectDir).toString("hex") + ".lock");
12219
- await fs16.writeFile(lockTarget, "", { flag: "a" });
12295
+ await fs17.writeFile(lockTarget, "", { flag: "a" });
12220
12296
  const release = await lockfile.lock(lockTarget, { retries: { retries: 3, factor: 1.2, minTimeout: 50 } });
12221
12297
  try {
12222
12298
  return await fn();
@@ -12255,7 +12331,7 @@ var init_multiAgent = __esm(() => {
12255
12331
  });
12256
12332
 
12257
12333
  // src/platform/historyManager.ts
12258
- import fs17 from "fs/promises";
12334
+ import fs18 from "fs/promises";
12259
12335
  import os9 from "os";
12260
12336
  import path19 from "path";
12261
12337
  function projectHistoryDir(projectHash2) {
@@ -12266,7 +12342,7 @@ function sessionFile(projectHash2, sessionId) {
12266
12342
  }
12267
12343
  async function appendToHistory(projectHash2, sessionId, sessionName, message) {
12268
12344
  const dir2 = projectHistoryDir(projectHash2);
12269
- await fs17.mkdir(dir2, { recursive: true });
12345
+ await fs18.mkdir(dir2, { recursive: true });
12270
12346
  const entry = {
12271
12347
  timestamp: Date.now(),
12272
12348
  role: message.role,
@@ -12274,13 +12350,13 @@ async function appendToHistory(projectHash2, sessionId, sessionName, message) {
12274
12350
  sessionId,
12275
12351
  sessionName
12276
12352
  };
12277
- await fs17.appendFile(sessionFile(projectHash2, sessionId), JSON.stringify(entry) + `
12353
+ await fs18.appendFile(sessionFile(projectHash2, sessionId), JSON.stringify(entry) + `
12278
12354
  `, "utf-8");
12279
12355
  }
12280
12356
  async function readSessionHistory(projectHash2, sessionId) {
12281
12357
  const file = sessionFile(projectHash2, sessionId);
12282
12358
  try {
12283
- const raw = await fs17.readFile(file, "utf-8");
12359
+ const raw = await fs18.readFile(file, "utf-8");
12284
12360
  return raw.split(`
12285
12361
  `).filter(Boolean).map((line) => JSON.parse(line));
12286
12362
  } catch {
@@ -12290,7 +12366,7 @@ async function readSessionHistory(projectHash2, sessionId) {
12290
12366
  async function listProjectSessions(projectHash2) {
12291
12367
  const dir2 = projectHistoryDir(projectHash2);
12292
12368
  try {
12293
- const files = await fs17.readdir(dir2);
12369
+ const files = await fs18.readdir(dir2);
12294
12370
  const sessions = [];
12295
12371
  for (const file of files.filter((f) => f.endsWith(".jsonl"))) {
12296
12372
  const sessionId = file.replace(/\.jsonl$/, "");
@@ -12336,7 +12412,7 @@ var init_historyManager = __esm(() => {
12336
12412
  });
12337
12413
 
12338
12414
  // src/eval/evals/basic.ts
12339
- import fs18 from "fs/promises";
12415
+ import fs19 from "fs/promises";
12340
12416
  import path20 from "path";
12341
12417
  var BASIC_EVAL_TASKS;
12342
12418
  var init_basic = __esm(() => {
@@ -12348,7 +12424,7 @@ var init_basic = __esm(() => {
12348
12424
  prompt: "Lis le fichier package.json et dis-moi le nom du projet",
12349
12425
  expectedOutcome: "Nom du projet lu depuis package.json",
12350
12426
  verifier: async (dir2) => {
12351
- const pkg = JSON.parse(await fs18.readFile(path20.join(dir2, "package.json"), "utf-8"));
12427
+ const pkg = JSON.parse(await fs19.readFile(path20.join(dir2, "package.json"), "utf-8"));
12352
12428
  return Boolean(pkg.name);
12353
12429
  }
12354
12430
  },
@@ -12360,7 +12436,7 @@ var init_basic = __esm(() => {
12360
12436
  expectedOutcome: "HELLO.md cree avec le bon contenu",
12361
12437
  verifier: async (dir2) => {
12362
12438
  try {
12363
- const content = await fs18.readFile(path20.join(dir2, "HELLO.md"), "utf-8");
12439
+ const content = await fs19.readFile(path20.join(dir2, "HELLO.md"), "utf-8");
12364
12440
  return content.includes("# Hello from Code");
12365
12441
  } catch {
12366
12442
  return false;
@@ -12376,7 +12452,7 @@ var init_basic = __esm(() => {
12376
12452
  expectedOutcome: "src/index.ts contient 'Hello Code'",
12377
12453
  verifier: async (dir2) => {
12378
12454
  try {
12379
- const content = await fs18.readFile(path20.join(dir2, "src/index.ts"), "utf-8");
12455
+ const content = await fs19.readFile(path20.join(dir2, "src/index.ts"), "utf-8");
12380
12456
  return content.includes("Hello Code");
12381
12457
  } catch {
12382
12458
  return false;
@@ -12387,7 +12463,7 @@ var init_basic = __esm(() => {
12387
12463
  });
12388
12464
 
12389
12465
  // src/eval/evals/refactor.ts
12390
- import fs19 from "fs/promises";
12466
+ import fs20 from "fs/promises";
12391
12467
  import path21 from "path";
12392
12468
  var REFACTOR_EVAL_TASKS;
12393
12469
  var init_refactor = __esm(() => {
@@ -12404,8 +12480,8 @@ var init_refactor = __esm(() => {
12404
12480
  ].join(" && "),
12405
12481
  expectedOutcome: "legacyCompute n'existe plus, computeV2 existe et est utilisee",
12406
12482
  verifier: async (dir2) => {
12407
- const a = await fs19.readFile(path21.join(dir2, "src/lib/math.ts"), "utf-8");
12408
- const b = await fs19.readFile(path21.join(dir2, "src/app/main.ts"), "utf-8");
12483
+ const a = await fs20.readFile(path21.join(dir2, "src/lib/math.ts"), "utf-8");
12484
+ const b = await fs20.readFile(path21.join(dir2, "src/app/main.ts"), "utf-8");
12409
12485
  return !a.includes("legacyCompute") && a.includes("computeV2") && b.includes("computeV2");
12410
12486
  }
12411
12487
  }
@@ -12413,7 +12489,7 @@ var init_refactor = __esm(() => {
12413
12489
  });
12414
12490
 
12415
12491
  // src/eval/evals/vision.ts
12416
- import fs20 from "fs/promises";
12492
+ import fs21 from "fs/promises";
12417
12493
  import path22 from "path";
12418
12494
  var VISION_EVAL_TASKS;
12419
12495
  var init_vision2 = __esm(() => {
@@ -12425,7 +12501,7 @@ var init_vision2 = __esm(() => {
12425
12501
  prompt: "Analyse l'image fixtures/ui-button-shifted.png et decris le probleme d'alignement.",
12426
12502
  setup: 'mkdir -p fixtures && echo "placeholder" > fixtures/ui-button-shifted.png',
12427
12503
  expectedOutcome: "Le pipeline vision est appele sans erreur",
12428
- verifier: async (dir2) => fs20.access(path22.join(dir2, "fixtures/ui-button-shifted.png")).then(() => true).catch(() => false)
12504
+ verifier: async (dir2) => fs21.access(path22.join(dir2, "fixtures/ui-button-shifted.png")).then(() => true).catch(() => false)
12429
12505
  }
12430
12506
  ];
12431
12507
  });
@@ -12462,7 +12538,7 @@ __export(exports_benchmarkRunner, {
12462
12538
  generateEvalReport: () => generateEvalReport,
12463
12539
  ALL_EVAL_TASKS: () => ALL_EVAL_TASKS
12464
12540
  });
12465
- import fs21 from "fs/promises";
12541
+ import fs22 from "fs/promises";
12466
12542
  import path23 from "path";
12467
12543
  import os10 from "os";
12468
12544
  async function applySetupSegment(segment, cwd) {
@@ -12472,7 +12548,7 @@ async function applySetupSegment(segment, cwd) {
12472
12548
  const mkdirMatch = trimmed.match(/^mkdir\s+-p\s+(.+)$/i);
12473
12549
  if (mkdirMatch) {
12474
12550
  const dirs = mkdirMatch[1].split(/\s+/).map((part) => part.trim().replace(/^["']|["']$/g, "")).filter(Boolean);
12475
- await Promise.all(dirs.map((dir2) => fs21.mkdir(path23.resolve(cwd, dir2), { recursive: true })));
12551
+ await Promise.all(dirs.map((dir2) => fs22.mkdir(path23.resolve(cwd, dir2), { recursive: true })));
12476
12552
  return;
12477
12553
  }
12478
12554
  const echoMatch = trimmed.match(/^echo\s+["']([\s\S]*)["']\s*>\s*(.+)$/i);
@@ -12480,8 +12556,8 @@ async function applySetupSegment(segment, cwd) {
12480
12556
  const [, rawContent, rawTarget] = echoMatch;
12481
12557
  const target = rawTarget.trim().replace(/^["']|["']$/g, "");
12482
12558
  const resolved = path23.resolve(cwd, target);
12483
- await fs21.mkdir(path23.dirname(resolved), { recursive: true });
12484
- await fs21.writeFile(resolved, rawContent.replace(/\\"/g, '"'), "utf-8");
12559
+ await fs22.mkdir(path23.dirname(resolved), { recursive: true });
12560
+ await fs22.writeFile(resolved, rawContent.replace(/\\"/g, '"'), "utf-8");
12485
12561
  return;
12486
12562
  }
12487
12563
  const { bash: bash2 } = await Promise.resolve().then(() => (init_shell(), exports_shell));
@@ -12494,7 +12570,7 @@ async function runEvalSetup(setup, cwd) {
12494
12570
  }
12495
12571
  }
12496
12572
  async function runEvalTask(task, runAgentFn) {
12497
- const tempDir = await fs21.mkdtemp(path23.join(os10.tmpdir(), "code-eval-"));
12573
+ const tempDir = await fs22.mkdtemp(path23.join(os10.tmpdir(), "code-eval-"));
12498
12574
  const start = Date.now();
12499
12575
  try {
12500
12576
  if (task.setup) {
@@ -12525,7 +12601,7 @@ async function runEvalTask(task, runAgentFn) {
12525
12601
  error: error instanceof Error ? error.message : String(error)
12526
12602
  };
12527
12603
  } finally {
12528
- await fs21.rm(tempDir, { recursive: true, force: true });
12604
+ await fs22.rm(tempDir, { recursive: true, force: true });
12529
12605
  }
12530
12606
  }
12531
12607
  async function generateEvalReport(results) {
@@ -12533,7 +12609,7 @@ async function generateEvalReport(results) {
12533
12609
  const metrics = computeEvalMetrics(results);
12534
12610
  let baseline;
12535
12611
  try {
12536
- const prevReport = JSON.parse(await fs21.readFile(path23.join(EVALS_DIR, "latest.json"), "utf-8"));
12612
+ const prevReport = JSON.parse(await fs22.readFile(path23.join(EVALS_DIR, "latest.json"), "utf-8"));
12537
12613
  baseline = prevReport.totalScore;
12538
12614
  } catch {}
12539
12615
  const report = {
@@ -12545,9 +12621,9 @@ async function generateEvalReport(results) {
12545
12621
  metrics,
12546
12622
  baseline
12547
12623
  };
12548
- await fs21.mkdir(EVALS_DIR, { recursive: true });
12549
- await fs21.writeFile(path23.join(EVALS_DIR, `eval-${Date.now()}.json`), JSON.stringify(report, null, 2));
12550
- await fs21.writeFile(path23.join(EVALS_DIR, "latest.json"), JSON.stringify(report, null, 2));
12624
+ await fs22.mkdir(EVALS_DIR, { recursive: true });
12625
+ await fs22.writeFile(path23.join(EVALS_DIR, `eval-${Date.now()}.json`), JSON.stringify(report, null, 2));
12626
+ await fs22.writeFile(path23.join(EVALS_DIR, "latest.json"), JSON.stringify(report, null, 2));
12551
12627
  return report;
12552
12628
  }
12553
12629
  var EVALS_DIR, ALL_EVAL_TASKS;
@@ -12566,7 +12642,7 @@ __export(exports_App, {
12566
12642
  });
12567
12643
  import { useCallback, useEffect as useEffect4, useRef, useState as useState10 } from "react";
12568
12644
  import { Box as Box30, Text as Text30, useApp, useInput as useInput16, useStdin as useStdin6 } from "ink";
12569
- import fs22 from "fs/promises";
12645
+ import fs23 from "fs/promises";
12570
12646
  import path24 from "path";
12571
12647
  import { jsxDEV as jsxDEV31 } from "react/jsx-dev-runtime";
12572
12648
  function createId(prefix) {
@@ -13411,10 +13487,10 @@ ${mem.modifiedFiles.slice(-10).join(`
13411
13487
  const exportSessionId = result.slice("EXPORT_SESSION:".length).trim() || activeSessionId;
13412
13488
  const markdown = await exportSessionMarkdown(projectHash2, exportSessionId);
13413
13489
  const exportDir = path24.join(process.cwd(), ".code");
13414
- await fs22.mkdir(exportDir, { recursive: true });
13490
+ await fs23.mkdir(exportDir, { recursive: true });
13415
13491
  const fileName = `session-${exportSessionId}-${shortId()}.md`;
13416
13492
  const outputPath = path24.join(exportDir, fileName);
13417
- await fs22.writeFile(outputPath, markdown, "utf-8");
13493
+ await fs23.writeFile(outputPath, markdown, "utf-8");
13418
13494
  setMessages((prev) => [...prev, `[SYS] Session exportee: ${outputPath}`]);
13419
13495
  return;
13420
13496
  }
@@ -14126,54 +14202,124 @@ var init_App = __esm(() => {
14126
14202
  init_benchmarkRunner();
14127
14203
  });
14128
14204
 
14129
- // src/index.ts
14130
- init_settings();
14131
- import { Command } from "commander";
14132
- import { createInterface } from "readline";
14133
- import { spawnSync as spawnSync3 } from "child_process";
14134
- import fs23 from "fs/promises";
14135
- import path25 from "path";
14136
-
14137
- // src/config/codeMd.ts
14138
- import fs from "fs/promises";
14139
- import path from "path";
14140
- var DEFAULT_CODE_MD = `# CODE.md - Configuration du projet
14141
-
14142
- ## Stack technique
14143
- <!-- Ex: TypeScript, Next.js 14, PostgreSQL, Vitest -->
14144
-
14145
- ## Commandes
14146
- - dev: \`npm run dev\`
14147
- - test: \`npm test\`
14148
- - build: \`npm run build\`
14149
- - lint: \`npm run lint\`
14150
-
14151
- ## Standards de code
14152
- <!-- Ex: 2 espaces, single quotes, camelCase, pas de any TypeScript -->
14153
-
14154
- ## Architecture des dossiers
14155
- <!-- Decris la structure et le role de chaque dossier principal -->
14205
+ // src/ui/BootstrapShell.tsx
14206
+ var exports_BootstrapShell = {};
14207
+ __export(exports_BootstrapShell, {
14208
+ BootstrapShell: () => BootstrapShell
14209
+ });
14210
+ import { useEffect as useEffect5, useState as useState11 } from "react";
14211
+ import { Box as Box31, Text as Text31 } from "ink";
14212
+ import { jsxDEV as jsxDEV32 } from "react/jsx-dev-runtime";
14213
+ function ensureVisionSource() {
14214
+ const current = settings.get("visionModel");
14215
+ if (current === "embedded" || current === "pollinations" || current === "ollama")
14216
+ return;
14217
+ settings.set("visionModel", "embedded");
14218
+ }
14219
+ function BootstrapShell({ forceIndex = false }) {
14220
+ const [bootstrapDone, setBootstrapDone] = useState11(false);
14221
+ const [appProps, setAppProps] = useState11(null);
14222
+ const [error, setError] = useState11(null);
14223
+ useEffect5(() => {
14224
+ if (!bootstrapDone)
14225
+ return;
14226
+ let cancelled = false;
14227
+ (async () => {
14228
+ try {
14229
+ ensureVisionSource();
14230
+ const apiKey = settings.getApiKey();
14231
+ const [config, env, memory, projectFiles, allSkills, platformDiagnostics] = await Promise.all([
14232
+ loadCodeConfig(),
14233
+ detectEnvironment(),
14234
+ settings.get("enableMemory") ? loadMemory() : Promise.resolve(null),
14235
+ discoverProjectFiles(),
14236
+ settings.get("enableSkills") ? loadSkills() : Promise.resolve([]),
14237
+ detectPlatformDiagnostics()
14238
+ ]);
14239
+ if (forceIndex && memory) {
14240
+ const sem = new SemanticMemory(memory.projectHash);
14241
+ await sem.indexProjectFiles(env.cwd ?? process.cwd()).catch(() => 0);
14242
+ }
14243
+ const projectContext = config.rawContent ? `Projet: ${env.projectName} (${env.fileCount} fichiers)
14156
14244
 
14157
- ## A eviter
14158
- <!-- Actions que Code ne doit PAS faire automatiquement -->
14159
- `;
14160
- async function loadCodeConfig() {
14161
- const codeMdPath = path.join(process.cwd(), "CODE.md");
14162
- try {
14163
- const rawContent = await fs.readFile(codeMdPath, "utf-8");
14164
- return { rawContent };
14165
- } catch {
14166
- return { rawContent: "" };
14245
+ ${config.rawContent}` : `Projet: ${env.projectName} (${env.fileCount} fichiers, ${env.language}, ${env.framework ?? "framework non detecte"})`;
14246
+ const startupNotice = buildStartupDiagnosticsNotice(platformDiagnostics);
14247
+ if (cancelled)
14248
+ return;
14249
+ setAppProps({
14250
+ apiKey,
14251
+ projectContext,
14252
+ env,
14253
+ memory,
14254
+ projectFiles,
14255
+ allSkills,
14256
+ startupMessages: startupNotice ? [startupNotice] : []
14257
+ });
14258
+ } catch (nextError) {
14259
+ if (!cancelled) {
14260
+ setError(nextError instanceof Error ? nextError.message : String(nextError));
14261
+ }
14262
+ }
14263
+ })();
14264
+ return () => {
14265
+ cancelled = true;
14266
+ };
14267
+ }, [bootstrapDone, forceIndex]);
14268
+ if (appProps) {
14269
+ return /* @__PURE__ */ jsxDEV32(App, {
14270
+ ...appProps
14271
+ }, undefined, false, undefined, this);
14167
14272
  }
14273
+ if (bootstrapDone) {
14274
+ if (error) {
14275
+ return /* @__PURE__ */ jsxDEV32(Box31, {
14276
+ flexDirection: "column",
14277
+ paddingX: 1,
14278
+ children: [
14279
+ /* @__PURE__ */ jsxDEV32(Text31, {
14280
+ color: codeTheme.danger,
14281
+ children: "Unable to launch Code after setup."
14282
+ }, undefined, false, undefined, this),
14283
+ /* @__PURE__ */ jsxDEV32(Text31, {
14284
+ color: codeTheme.muted,
14285
+ children: error
14286
+ }, undefined, false, undefined, this)
14287
+ ]
14288
+ }, undefined, true, undefined, this);
14289
+ }
14290
+ return /* @__PURE__ */ jsxDEV32(LoadingState, {
14291
+ message: "Launching Code",
14292
+ subMessage: "Finalizing setup and preparing the shell."
14293
+ }, undefined, false, undefined, this);
14294
+ }
14295
+ return /* @__PURE__ */ jsxDEV32(WizardContainer, {
14296
+ onComplete: () => setBootstrapDone(true)
14297
+ }, undefined, false, undefined, this);
14168
14298
  }
14169
- async function createCodeConfig() {
14170
- const codeMdPath = path.join(process.cwd(), "CODE.md");
14171
- await fs.writeFile(codeMdPath, DEFAULT_CODE_MD, "utf-8");
14172
- }
14299
+ var init_BootstrapShell = __esm(() => {
14300
+ init_settings();
14301
+ init_codeMd();
14302
+ init_context();
14303
+ init_envDetector();
14304
+ init_platformDiagnostics();
14305
+ init_skillLoader();
14306
+ init_semanticMemory();
14307
+ init_WizardContainer();
14308
+ init_ProgressBar();
14309
+ init_App();
14310
+ init_theme();
14311
+ });
14173
14312
 
14174
14313
  // src/index.ts
14314
+ init_settings();
14315
+ init_codeMd();
14175
14316
  init_context();
14176
14317
  init_agent();
14318
+ import { Command } from "commander";
14319
+ import { createInterface } from "readline";
14320
+ import { spawnSync as spawnSync3 } from "child_process";
14321
+ import fs24 from "fs/promises";
14322
+ import path25 from "path";
14177
14323
 
14178
14324
  // src/core/run-output.ts
14179
14325
  function cleanRunOutput(text) {
@@ -14214,6 +14360,7 @@ init_logger();
14214
14360
  // src/core/ciRunner.ts
14215
14361
  init_agent();
14216
14362
  init_logger();
14363
+ init_productMeta();
14217
14364
  import readline from "readline";
14218
14365
  async function runCI(task, context, opts = {}) {
14219
14366
  const { failOnJudgeBelow = 80 } = opts;
@@ -14302,7 +14449,7 @@ async function runCI(task, context, opts = {}) {
14302
14449
  }
14303
14450
  async function runInteractive(context) {
14304
14451
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
14305
- console.log("Code v6 - Mode non-TTY (Ctrl+D pour quitter)");
14452
+ console.log(`${PRODUCT_SHELL_LABEL} - Mode non-TTY (Ctrl+D pour quitter)`);
14306
14453
  const ask = () => {
14307
14454
  rl.question(`
14308
14455
  > `, async (input) => {
@@ -14344,13 +14491,14 @@ Au revoir !`);
14344
14491
  }
14345
14492
 
14346
14493
  // src/index.ts
14494
+ init_productMeta();
14347
14495
  var program = new Command;
14348
14496
  var VALID_MODELS = ["kimi", "mistral", "gemini-fast"];
14349
14497
  function ensureApiKey() {
14350
14498
  const apiKey = settings.getApiKey();
14351
14499
  if (!apiKey || !apiKey.startsWith("pk_") && !apiKey.startsWith("sk_")) {
14352
14500
  console.log([
14353
- "Code v6 | OAL SARL",
14501
+ `${PRODUCT_SHELL_LABEL} | OAL SARL`,
14354
14502
  "",
14355
14503
  "Cle API Pollinations manquante ou invalide.",
14356
14504
  "1. https://enter.pollinations.ai",
@@ -14400,7 +14548,7 @@ async function tryOfflineTask(task, cwd) {
14400
14548
  if (!requested)
14401
14549
  return null;
14402
14550
  const resolved = path25.resolve(cwd, requested);
14403
- return fs23.readFile(resolved, "utf-8");
14551
+ return fs24.readFile(resolved, "utf-8");
14404
14552
  }
14405
14553
  async function resolveVisionSource() {
14406
14554
  const current = settings.get("visionModel");
@@ -14424,14 +14572,19 @@ async function bootstrapContext(apiKey, taskForSkills = "") {
14424
14572
  ctx.activeSkills = activeSkills;
14425
14573
  return { config, env, memory, projectFiles, allSkills, ctx, platformDiagnostics };
14426
14574
  }
14427
- program.name("oal-code").description("Code v6 Augmented | OAL SARL | Vision embarquee | Transactions | Judge").version("6.0.0");
14575
+ program.name("oal-code").description(`${PRODUCT_SHELL_LABEL} Augmented | OAL SARL | Vision embarquee | Transactions | Judge`).version(PRODUCT_VERSION);
14428
14576
  async function startChat(opts) {
14429
14577
  const useInkUi = shouldUseInkUi();
14430
14578
  const setupRequired = opts.setup || opts.config || !settings.isSetupCurrent() || !hasValidApiKey();
14431
14579
  if (setupRequired) {
14432
14580
  if (useInkUi) {
14433
- const { waitForWizard: waitForWizard2 } = await Promise.resolve().then(() => (init_wizardHelper(), exports_wizardHelper));
14434
- await waitForWizard2();
14581
+ const [{ render: render2 }, React13, { BootstrapShell: BootstrapShell2 }] = await Promise.all([
14582
+ import("ink"),
14583
+ import("react"),
14584
+ Promise.resolve().then(() => (init_BootstrapShell(), exports_BootstrapShell))
14585
+ ]);
14586
+ render2(React13.createElement(BootstrapShell2, { forceIndex: opts.index }));
14587
+ return;
14435
14588
  } else {
14436
14589
  console.log("Mode non-TTY : entrez votre cle API Pollinations (pk_... ou sk_...):");
14437
14590
  const rl = createInterface({ input: process.stdin, output: process.stdout });
@@ -14471,18 +14624,18 @@ async function startChat(opts) {
14471
14624
  ${loaded.rawContent}` : `Projet: ${env.projectName} (${env.fileCount} fichiers, ${env.language}, ${env.framework ?? "framework non detecte"})`;
14472
14625
  const startupNotice = buildStartupDiagnosticsNotice(platformDiagnostics);
14473
14626
  if (!useInkUi) {
14474
- console.log(`Code v6 | OAL SARL | model:${settings.getDefaultModel()} | files:${env.fileCount} | skills:${allSkills.length}${memory ? " | memoire" : ""}`);
14627
+ console.log(`${PRODUCT_SHELL_LABEL} | OAL SARL | model:${settings.getDefaultModel()} | files:${env.fileCount} | skills:${allSkills.length}${memory ? " | memoire" : ""}`);
14475
14628
  if (startupNotice) {
14476
14629
  console.log(startupNotice);
14477
14630
  }
14478
14631
  }
14479
14632
  if (useInkUi) {
14480
- const [{ render: render2 }, React12, { App: App2 }] = await Promise.all([
14633
+ const [{ render: render2 }, React13, { App: App2 }] = await Promise.all([
14481
14634
  import("ink"),
14482
14635
  import("react"),
14483
14636
  Promise.resolve().then(() => (init_App(), exports_App))
14484
14637
  ]);
14485
- render2(React12.createElement(App2, {
14638
+ render2(React13.createElement(App2, {
14486
14639
  apiKey,
14487
14640
  projectContext,
14488
14641
  env,
@@ -14675,7 +14828,7 @@ program.command("run <task>").description("Executer une tache unique et quitter
14675
14828
  });
14676
14829
  program.command("eval").description("Gerer les benchmarks").command("run").option("--tasks <ids>", "IDs de taches separes par des virgules").action(async (opts) => {
14677
14830
  const { ALL_EVAL_TASKS: ALL_EVAL_TASKS2, runEvalTask: runEvalTask2, generateEvalReport: generateEvalReport2 } = await Promise.resolve().then(() => (init_benchmarkRunner(), exports_benchmarkRunner));
14678
- const fs24 = await import("fs/promises");
14831
+ const fs25 = await import("fs/promises");
14679
14832
  const path26 = await import("path");
14680
14833
  const selectedIds = opts.tasks?.split(",").map((item) => item.trim()).filter(Boolean) ?? [];
14681
14834
  const tasks = selectedIds.length > 0 ? ALL_EVAL_TASKS2.filter((task) => selectedIds.includes(task.id)) : ALL_EVAL_TASKS2;
@@ -14690,25 +14843,25 @@ program.command("eval").description("Gerer les benchmarks").command("run").optio
14690
14843
  const pkgPath = path26.join(projectDir, "package.json");
14691
14844
  let pkg;
14692
14845
  try {
14693
- pkg = JSON.parse(await fs24.readFile(pkgPath, "utf-8"));
14846
+ pkg = JSON.parse(await fs25.readFile(pkgPath, "utf-8"));
14694
14847
  } catch {
14695
14848
  pkg = { name: "code-eval-project", version: "1.0.0" };
14696
- await fs24.writeFile(pkgPath, JSON.stringify(pkg, null, 2), "utf-8");
14849
+ await fs25.writeFile(pkgPath, JSON.stringify(pkg, null, 2), "utf-8");
14697
14850
  toolCount += 1;
14698
14851
  }
14699
14852
  response = `Project name: ${String(pkg.name ?? "unknown")}`;
14700
14853
  toolCount += 1;
14701
14854
  }
14702
14855
  if (/HELLO\.md/i.test(prompt)) {
14703
- await fs24.writeFile(path26.join(projectDir, "HELLO.md"), `# Hello from Code
14856
+ await fs25.writeFile(path26.join(projectDir, "HELLO.md"), `# Hello from Code
14704
14857
  `, "utf-8");
14705
14858
  response = "HELLO.md created";
14706
14859
  toolCount += 1;
14707
14860
  }
14708
14861
  if (/Hello World/i.test(prompt) && /Hello Code/i.test(prompt)) {
14709
14862
  const indexPath = path26.join(projectDir, "src", "index.ts");
14710
- const content = await fs24.readFile(indexPath, "utf-8");
14711
- await fs24.writeFile(indexPath, content.replace(/Hello World/g, "Hello Code"), "utf-8");
14863
+ const content = await fs25.readFile(indexPath, "utf-8");
14864
+ await fs25.writeFile(indexPath, content.replace(/Hello World/g, "Hello Code"), "utf-8");
14712
14865
  response = "src/index.ts updated";
14713
14866
  toolCount += 2;
14714
14867
  }
@@ -14716,12 +14869,12 @@ program.command("eval").description("Gerer les benchmarks").command("run").optio
14716
14869
  const mathPath = path26.join(projectDir, "src", "lib", "math.ts");
14717
14870
  const mainPath = path26.join(projectDir, "src", "app", "main.ts");
14718
14871
  const [mathContent, mainContent] = await Promise.all([
14719
- fs24.readFile(mathPath, "utf-8"),
14720
- fs24.readFile(mainPath, "utf-8")
14872
+ fs25.readFile(mathPath, "utf-8"),
14873
+ fs25.readFile(mainPath, "utf-8")
14721
14874
  ]);
14722
14875
  await Promise.all([
14723
- fs24.writeFile(mathPath, mathContent.replace(/legacyCompute/g, "computeV2"), "utf-8"),
14724
- fs24.writeFile(mainPath, mainContent.replace(/legacyCompute/g, "computeV2"), "utf-8")
14876
+ fs25.writeFile(mathPath, mathContent.replace(/legacyCompute/g, "computeV2"), "utf-8"),
14877
+ fs25.writeFile(mainPath, mainContent.replace(/legacyCompute/g, "computeV2"), "utf-8")
14725
14878
  ]);
14726
14879
  response = "Symbol renamed in math.ts and main.ts";
14727
14880
  toolCount += 2;