@orbit-build/cli 0.8.1 → 0.8.2

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 +273 -93
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -259667,7 +259667,13 @@ function canonicalizeProjectPath(projectPath) {
259667
259667
  }
259668
259668
  if (!isDirectory(requested))
259669
259669
  throw new Error("Project path must be an existing directory.");
259670
- return realpathSync2.native(requested);
259670
+ const canonical = realpathSync2.native(requested);
259671
+ if (canonical === parse2(canonical).root) {
259672
+ throw new Error(
259673
+ "A filesystem root cannot be registered as an Orbit project."
259674
+ );
259675
+ }
259676
+ return canonical;
259671
259677
  }
259672
259678
  function projectIdentity(projectPath) {
259673
259679
  const normalized = projectPath.replace(/\\/g, "/");
@@ -276723,28 +276729,93 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276723
276729
  closeContextPicker({ skipRestore: true });
276724
276730
  void updateSession({ action: 'new' });
276725
276731
  });
276726
- const closeProjectDialog = (restoreFocus = true) => {
276732
+ const closeProjectDialog = (restoreFocus = true, force = false) => {
276727
276733
  if (elements.projectDialog.hidden) return;
276734
+ if (state.projectLaunchPending && !force) return;
276728
276735
  elements.projectDialog.hidden = true;
276729
276736
  elements.projectDialog.setAttribute('aria-hidden', 'true');
276730
276737
  if (restoreFocus && state.projectDialogReturnFocus) state.projectDialogReturnFocus.focus();
276731
276738
  state.projectDialogReturnFocus = null;
276732
276739
  };
276733
276740
  const openProjectDialog = () => {
276734
- if (state.busy) return;
276741
+ if (state.busy || state.projectLaunchPending) return;
276735
276742
  state.projectDialogReturnFocus = document.activeElement;
276736
276743
  elements.projectDialog.hidden = false;
276737
276744
  elements.projectDialog.setAttribute('aria-hidden', 'false');
276738
276745
  elements.projectPathInput.focus();
276739
276746
  elements.projectPathInput.select();
276740
276747
  };
276741
- const reserveProjectTab = () => {
276748
+ const showReservedProjectStatus = (projectTab, label, failed = false) => {
276749
+ if (!projectTab || projectTab.closed) return;
276750
+ try {
276751
+ const projectDocument = projectTab.document;
276752
+ const sourceStyle = getComputedStyle(document.documentElement);
276753
+ const themeValue = (name, fallback) =>
276754
+ sourceStyle.getPropertyValue(name).trim() || fallback;
276755
+ projectDocument.title = 'Orbit · ' + label;
276756
+ projectDocument.documentElement.lang = document.documentElement.lang;
276757
+ projectDocument.documentElement.style.colorScheme = sourceStyle.colorScheme;
276758
+ projectDocument.body.replaceChildren();
276759
+ Object.assign(projectDocument.body.style, {
276760
+ minHeight: '100vh',
276761
+ margin: '0',
276762
+ display: 'grid',
276763
+ placeItems: 'center',
276764
+ color: themeValue('--ink', '#2c3834'),
276765
+ background: themeValue('--canvas', '#f4f6f3'),
276766
+ fontFamily: themeValue('--font-sans', 'Inter, ui-sans-serif, system-ui, sans-serif'),
276767
+ });
276768
+ const status = projectDocument.createElement('main');
276769
+ status.setAttribute('role', 'status');
276770
+ status.dataset.orbitProjectHandoff = failed ? 'failed' : 'pending';
276771
+ Object.assign(status.style, {
276772
+ display: 'grid',
276773
+ gap: '10px',
276774
+ justifyItems: 'center',
276775
+ minWidth: 'min(360px, calc(100vw - 40px))',
276776
+ padding: '28px',
276777
+ textAlign: 'center',
276778
+ background: themeValue('--surface-raised', '#ffffff'),
276779
+ border: '1px solid ' + themeValue('--border', 'rgba(28, 49, 42, 0.105)'),
276780
+ borderRadius: themeValue('--radius-lg', '18px'),
276781
+ boxShadow: themeValue('--shadow-md', '0 18px 48px rgba(10, 24, 20, 0.14)'),
276782
+ });
276783
+ const brand = projectDocument.createElement('strong');
276784
+ brand.textContent = 'Orbit';
276785
+ Object.assign(brand.style, {
276786
+ color: themeValue('--accent-strong', '#276a5f'),
276787
+ fontSize: '24px',
276788
+ letterSpacing: '-0.02em',
276789
+ });
276790
+ const message = projectDocument.createElement('span');
276791
+ message.textContent = label;
276792
+ Object.assign(message.style, {
276793
+ maxWidth: '42ch',
276794
+ color: failed
276795
+ ? themeValue('--danger', '#bb5755')
276796
+ : themeValue('--muted', '#596761'),
276797
+ fontSize: '14px',
276798
+ lineHeight: '1.55',
276799
+ });
276800
+ status.append(brand, message);
276801
+ projectDocument.body.append(status);
276802
+ } catch {
276803
+ // A browser may isolate the placeholder before Orbit can decorate it.
276804
+ }
276805
+ };
276806
+ const reserveProjectTab = (label) => {
276742
276807
  const projectTab = window.open('about:blank', '_blank');
276743
- if (projectTab) projectTab.opener = null;
276808
+ showReservedProjectStatus(projectTab, label);
276744
276809
  return projectTab;
276745
276810
  };
276746
- const closeReservedProjectTab = (projectTab) => {
276747
- if (projectTab && !projectTab.closed) projectTab.close();
276811
+ const closeReservedProjectTab = (projectTab, message = copy.projectSwitchFailed) => {
276812
+ if (!projectTab || projectTab.closed) return;
276813
+ showReservedProjectStatus(projectTab, message, true);
276814
+ try {
276815
+ projectTab.close();
276816
+ } catch {
276817
+ // The visible failure state remains if the browser refuses window.close().
276818
+ }
276748
276819
  };
276749
276820
  const switchToProject = (result, projectTab) => {
276750
276821
  if (!result || typeof result.url !== 'string') {
@@ -276765,6 +276836,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276765
276836
  throw new Error(copy.projectSwitchFailed);
276766
276837
  }
276767
276838
  if (projectTab && !projectTab.closed) {
276839
+ projectTab.opener = null;
276768
276840
  projectTab.location.replace(projectUrl.href);
276769
276841
  projectTab.focus();
276770
276842
  showToast(copy.projectOpened, 'success');
@@ -276772,41 +276844,48 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276772
276844
  }
276773
276845
  window.location.assign(projectUrl.href);
276774
276846
  };
276775
- const launchProject = async (action, selectedPath) => {
276847
+ const launchProject = async (selectedPath) => {
276776
276848
  const path = String(selectedPath || elements.projectPathInput.value).trim();
276777
276849
  if (!path) {
276778
276850
  showToast(copy.projectPathRequired, 'error');
276779
276851
  elements.projectPathInput.focus();
276780
276852
  return;
276781
276853
  }
276782
- if (elements.projectDialogOpen.disabled) return;
276783
- const projectTab = reserveProjectTab();
276784
- const pendingButton = action === 'create' ? elements.projectDialogCreate : elements.projectDialogOpen;
276785
- const pendingLabel = action === 'create' ? copy.projectCreating : copy.projectOpening;
276854
+ if (elements.projectDialogCreate.disabled) return;
276855
+ const pendingButton = elements.projectDialogCreate;
276856
+ const pendingLabel = copy.projectCreating;
276857
+ const projectTab = reserveProjectTab(pendingLabel);
276786
276858
  const originalLabel = pendingButton.textContent;
276859
+ state.projectLaunchPending = true;
276860
+ elements.projectDialog.setAttribute('aria-busy', 'true');
276861
+ elements.projectDialogBackdrop.disabled = true;
276862
+ elements.projectDialogCancel.disabled = true;
276787
276863
  elements.projectDialogBrowse.disabled = true;
276788
- elements.projectDialogOpen.disabled = true;
276789
276864
  elements.projectDialogCreate.disabled = true;
276790
276865
  pendingButton.textContent = pendingLabel;
276791
276866
  pendingButton.setAttribute('aria-busy', 'true');
276792
- showToast(pendingLabel);
276793
276867
  try {
276794
276868
  const result = await api('/api/project', {
276795
276869
  method: 'POST',
276796
276870
  headers: { 'Content-Type': 'application/json' },
276797
- body: JSON.stringify({ action, path }),
276871
+ body: JSON.stringify({ action: 'create', path }),
276798
276872
  });
276799
- closeProjectDialog(false);
276873
+ await loadStatus().catch(() => {});
276874
+ closeProjectDialog(false, true);
276800
276875
  elements.projectPathInput.value = '';
276801
276876
  switchToProject(result, projectTab);
276802
276877
  } catch (error) {
276803
- closeReservedProjectTab(projectTab);
276804
- showToast(error.message || String(error), 'error');
276878
+ const message = projectErrorMessage(error);
276879
+ closeReservedProjectTab(projectTab, message);
276880
+ showToast(message, 'error');
276805
276881
  } finally {
276882
+ state.projectLaunchPending = false;
276883
+ elements.projectDialog.removeAttribute('aria-busy');
276884
+ elements.projectDialogBackdrop.disabled = false;
276885
+ elements.projectDialogCancel.disabled = false;
276806
276886
  pendingButton.textContent = originalLabel;
276807
276887
  pendingButton.removeAttribute('aria-busy');
276808
276888
  elements.projectDialogBrowse.disabled = false;
276809
- elements.projectDialogOpen.disabled = false;
276810
276889
  elements.projectDialogCreate.disabled = false;
276811
276890
  }
276812
276891
  };
@@ -276815,7 +276894,6 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276815
276894
  state.projectPickerPending = true;
276816
276895
  elements.projectDialogBrowse.disabled = true;
276817
276896
  elements.projectDialogBrowse.setAttribute('aria-busy', 'true');
276818
- elements.projectDialogOpen.disabled = true;
276819
276897
  elements.projectDialogCreate.disabled = true;
276820
276898
  elements.newProjectButton.disabled = true;
276821
276899
  try {
@@ -276834,7 +276912,6 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276834
276912
  state.projectPickerPending = false;
276835
276913
  elements.projectDialogBrowse.disabled = false;
276836
276914
  elements.projectDialogBrowse.removeAttribute('aria-busy');
276837
- elements.projectDialogOpen.disabled = false;
276838
276915
  elements.projectDialogCreate.disabled = false;
276839
276916
  elements.newProjectButton.disabled = false;
276840
276917
  }
@@ -276843,8 +276920,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276843
276920
  elements.projectDialogBackdrop.addEventListener('click', () => closeProjectDialog());
276844
276921
  elements.projectDialogCancel.addEventListener('click', () => closeProjectDialog());
276845
276922
  elements.projectDialogBrowse.addEventListener('click', () => void pickProjectFolder());
276846
- elements.projectDialogOpen.addEventListener('click', () => void launchProject('open'));
276847
- elements.projectDialogCreate.addEventListener('click', () => void launchProject('create'));
276923
+ elements.projectDialogCreate.addEventListener('click', () => void launchProject());
276848
276924
  elements.projectList.addEventListener('click', (event) => {
276849
276925
  const remove = event.target.closest('[data-project-action="remove"]');
276850
276926
  if (remove && !state.busy) {
@@ -276874,7 +276950,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276874
276950
  const button = event.target.closest('[data-project-path]');
276875
276951
  if (!button || button.disabled || state.busy) return;
276876
276952
  state.busy = true;
276877
- const projectTab = reserveProjectTab();
276953
+ const projectTab = reserveProjectTab(copy.projectOpening);
276878
276954
  button.classList.add('is-switching');
276879
276955
  button.setAttribute('aria-busy', 'true');
276880
276956
  showToast(copy.projectOpening);
@@ -276884,7 +276960,7 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276884
276960
  body: JSON.stringify({ action: 'open', path: button.dataset.projectPath || '' }),
276885
276961
  }).then((result) => switchToProject(result, projectTab))
276886
276962
  .catch((error) => {
276887
- closeReservedProjectTab(projectTab);
276963
+ closeReservedProjectTab(projectTab, error.message || String(error));
276888
276964
  showToast(error.message || String(error), 'error');
276889
276965
  })
276890
276966
  .finally(() => {
@@ -276896,12 +276972,14 @@ var WEB_UI_CLIENT_BINDINGS_SCRIPT = String.raw` elements.composer.addEventListe
276896
276972
  elements.projectPathInput.addEventListener('keydown', (event) => {
276897
276973
  if (event.key === 'Enter') {
276898
276974
  event.preventDefault();
276899
- void launchProject('open');
276975
+ void launchProject();
276900
276976
  }
276901
276977
  });
276902
276978
  elements.projectDialog.addEventListener('keydown', (event) => {
276903
276979
  if (event.key !== 'Tab') return;
276904
- const focusable = [elements.projectPathInput, elements.projectDialogBrowse, elements.projectDialogCancel, elements.projectDialogOpen, elements.projectDialogCreate];
276980
+ const focusable = [elements.projectPathInput, elements.projectDialogBrowse, elements.projectDialogCancel, elements.projectDialogCreate]
276981
+ .filter((control) => !control.disabled);
276982
+ if (!focusable.length) return;
276905
276983
  const first = focusable[0];
276906
276984
  const last = focusable[focusable.length - 1];
276907
276985
  if (event.shiftKey && document.activeElement === first) {
@@ -278148,13 +278226,13 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278148
278226
  sessionRestored: '对话已恢复',
278149
278227
  sessionDeleted: '对话已删除',
278150
278228
  projectOpening: '正在新标签页打开项目…',
278151
- projectCreating: '正在创建项目并打开新标签页…',
278229
+ projectCreating: '正在准备项目并打开新标签页…',
278152
278230
  projectOpened: '项目已在新标签页中打开',
278153
278231
  projectSwitchFailed: '项目已启动,但无法安全打开页面',
278154
278232
  projectRemoved: '项目已从 Orbit 移除,磁盘文件未删除',
278155
278233
  removeProject: '从 Orbit 移除项目',
278156
278234
  confirmRemoveProject: '再次点击确认移除',
278157
- projectPathRequired: '请输入完整的项目文件夹路径',
278235
+ projectPathRequired: '请输入项目文件夹的绝对路径',
278158
278236
  archiveSession: '归档',
278159
278237
  restoreSession: '恢复',
278160
278238
  deleteSession: '删除',
@@ -278300,13 +278378,13 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278300
278378
  sessionRestored: 'Chat restored',
278301
278379
  sessionDeleted: 'Chat deleted',
278302
278380
  projectOpening: 'Opening project in a new tab…',
278303
- projectCreating: 'Creating project and opening a new tab…',
278381
+ projectCreating: 'Preparing project in a new tab…',
278304
278382
  projectOpened: 'Project opened in a new tab',
278305
278383
  projectSwitchFailed: 'The project started, but Orbit could not open it safely',
278306
278384
  projectRemoved: 'Project removed from Orbit; files were not deleted',
278307
278385
  removeProject: 'Remove project from Orbit',
278308
278386
  confirmRemoveProject: 'Click again to confirm removal',
278309
- projectPathRequired: 'Enter the full project folder path',
278387
+ projectPathRequired: 'Enter an absolute project folder path',
278310
278388
  archiveSession: 'Archive',
278311
278389
  restoreSession: 'Restore',
278312
278390
  deleteSession: 'Delete',
@@ -278416,11 +278494,12 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278416
278494
  sessionRestored: '對話已復原',
278417
278495
  sessionDeleted: '對話已刪除',
278418
278496
  projectOpening: '正在新分頁開啟專案…',
278419
- projectCreating: '正在建立專案並開啟新分頁…',
278497
+ projectCreating: '正在準備專案並開啟新分頁…',
278420
278498
  projectOpened: '專案已在新分頁中開啟',
278421
278499
  projectSwitchFailed: '專案已啟動,但無法安全開啟頁面',
278422
278500
  projectRemoved: '專案已從 Orbit 移除,磁碟檔案未刪除',
278423
278501
  removeProject: '從 Orbit 移除專案',
278502
+ projectPathRequired: '請輸入專案資料夾的絕對路徑',
278424
278503
  archiveSession: '封存',
278425
278504
  restoreSession: '復原',
278426
278505
  deleteSession: '刪除',
@@ -278468,6 +278547,38 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278468
278547
  });
278469
278548
  }
278470
278549
 
278550
+ const projectErrorMessages = isChinese
278551
+ ? {
278552
+ absolute_path_required: chinese('请输入项目文件夹的绝对路径。', '請輸入專案資料夾的絕對路徑。'),
278553
+ filesystem_root: chinese('为保护系统,不能把磁盘根目录作为 Orbit 项目。', '為保護系統,不能把磁碟根目錄作為 Orbit 專案。'),
278554
+ entrypoint_unavailable: chinese('Orbit CLI 启动入口不可用,请重启 Orbit 后再试。', 'Orbit CLI 啟動入口無法使用,請重新啟動 Orbit 後再試。'),
278555
+ project_missing: chinese('项目文件夹不存在。', '專案資料夾不存在。'),
278556
+ project_not_directory: chinese('选择的路径不是文件夹。', '選擇的路徑不是資料夾。'),
278557
+ parent_missing: chinese('上级文件夹不存在,请先选择一个已有位置。', '上層資料夾不存在,請先選擇一個現有位置。'),
278558
+ parent_not_directory: chinese('项目的上级路径不是文件夹。', '專案的上層路徑不是資料夾。'),
278559
+ create_failed: chinese('无法创建项目文件夹,请检查路径和权限。', '無法建立專案資料夾,請檢查路徑與權限。'),
278560
+ launch_failed: chinese('无法启动此项目的 Orbit 实例。', '無法啟動此專案的 Orbit 執行個體。'),
278561
+ startup_failed: chinese('项目实例在 WebUI 就绪前退出。', '專案執行個體在 WebUI 就緒前結束。'),
278562
+ startup_timeout: chinese('启动项目超时,请重试或检查运行诊断。', '啟動專案逾時,請重試或檢查執行診斷。'),
278563
+ }
278564
+ : {
278565
+ absolute_path_required: 'Enter an absolute project folder path.',
278566
+ filesystem_root: 'A filesystem root cannot be used as an Orbit project.',
278567
+ entrypoint_unavailable: 'The Orbit CLI entry point is unavailable. Restart Orbit and try again.',
278568
+ project_missing: 'The project folder does not exist.',
278569
+ project_not_directory: 'The selected path is not a folder.',
278570
+ parent_missing: 'The parent folder does not exist. Choose an existing location first.',
278571
+ parent_not_directory: 'The project parent path is not a folder.',
278572
+ create_failed: 'Orbit could not create the project folder. Check the path and permissions.',
278573
+ launch_failed: 'Orbit could not start this project.',
278574
+ startup_failed: 'The project exited before its Web UI was ready.',
278575
+ startup_timeout: 'The project took too long to start. Retry or open Diagnostics.',
278576
+ };
278577
+ const projectErrorMessage = (error) =>
278578
+ projectErrorMessages[error && error.projectErrorCode] ||
278579
+ error && error.message ||
278580
+ String(error);
278581
+
278471
278582
  const suggestionPrompts = isChinese
278472
278583
  ? [
278473
278584
  '全面审查这个项目,找出影响最大的问题并直接修复,最后运行完整验证。',
@@ -278517,7 +278628,6 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278517
278628
  projectDialog: byId('projectDialog'),
278518
278629
  projectDialogBackdrop: byId('projectDialogBackdrop'),
278519
278630
  projectDialogCancel: byId('projectDialogCancel'),
278520
- projectDialogOpen: byId('projectDialogOpen'),
278521
278631
  projectDialogCreate: byId('projectDialogCreate'),
278522
278632
  projectDialogBrowse: byId('projectDialogBrowse'),
278523
278633
  projectPathInput: byId('projectPathInput'),
@@ -278709,6 +278819,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278709
278819
  sessionDeleteReturnFocus: null,
278710
278820
  projectDialogReturnFocus: null,
278711
278821
  projectPickerPending: false,
278822
+ projectLaunchPending: false,
278712
278823
  promptQueue: [],
278713
278824
  queueEditingId: null,
278714
278825
  queueEditDraft: '',
@@ -278859,6 +278970,7 @@ var WEB_UI_CLIENT_FOUNDATION_SCRIPT = String.raw` const byId = (id) => document
278859
278970
  : data.message || data.error || response.statusText || 'Request failed';
278860
278971
  const error = new Error(message);
278861
278972
  error.status = response.status;
278973
+ error.projectErrorCode = typeof data.errorCode === 'string' ? data.errorCode : '';
278862
278974
  throw error;
278863
278975
  }
278864
278976
  return data;
@@ -280355,7 +280467,7 @@ var WEB_UI_CLIENT_PALETTE_SCRIPT = String.raw` let paletteActions = [];
280355
280467
  function buildPaletteActions() {
280356
280468
  const actions = [
280357
280469
  { icon: '+', label: language !== 'en' ? chinese('新建任务', '新增任務') : 'New task', detail: 'Ctrl N', keywords: 'new session task', idle: true, run: () => updateSession({ action: 'new' }) },
280358
- { icon: '▣', label: language !== 'en' ? chinese('新建或打开项目', '新增或開啟專案') : 'New or open project', detail: language !== 'en' ? chinese('选择项目文件夹', '選擇專案資料夾') : 'Choose a project folder', keywords: 'new open create project workspace folder', idle: true, run: openProjectDialog },
280470
+ { icon: '▣', label: language !== 'en' ? chinese('添加或创建项目', '加入或建立專案') : 'Add or create project', detail: language !== 'en' ? chinese('选择项目文件夹', '選擇專案資料夾') : 'Choose a project folder', keywords: 'add new open create project workspace folder', idle: true, run: openProjectDialog },
280359
280471
  { icon: '›', label: copy.focusComposer, detail: language !== 'en' ? chinese('发送消息', '傳送訊息') : 'Message Orbit', keywords: 'focus prompt message composer', run: () => elements.prompt.focus() },
280360
280472
  { icon: '◫', label: copy.openActivity, detail: language !== 'en' ? chinese('运行状态与工具', '執行狀態與工具') : 'Runtime and tools', keywords: 'activity details runtime tools', run: () => setInspector(true, 'activity') },
280361
280473
  { icon: '⚙', label: copy.openSettings, detail: 'Ctrl ,', keywords: 'settings preferences configuration', run: () => setInspector(true, 'settings') },
@@ -282356,7 +282468,25 @@ var WebUiRequestError = class extends Error {
282356
282468
  name = "WebUiRequestError";
282357
282469
  };
282358
282470
 
282471
+ // src/runtime/webui/WebUiContracts.ts
282472
+ var WEB_UI_PROJECT_ERROR_CODES = [
282473
+ "absolute_path_required",
282474
+ "filesystem_root",
282475
+ "entrypoint_unavailable",
282476
+ "project_missing",
282477
+ "project_not_directory",
282478
+ "parent_missing",
282479
+ "parent_not_directory",
282480
+ "create_failed",
282481
+ "launch_failed",
282482
+ "startup_failed",
282483
+ "startup_timeout"
282484
+ ];
282485
+
282359
282486
  // src/runtime/webui/WebUiSecurity.ts
282487
+ var WEB_UI_PROJECT_ERROR_CODE_SET = new Set(
282488
+ WEB_UI_PROJECT_ERROR_CODES
282489
+ );
282360
282490
  function sanitizeWebEventPayload(type, payload) {
282361
282491
  if (!isRecord4(payload)) return void 0;
282362
282492
  switch (type) {
@@ -282624,13 +282754,15 @@ function sanitizeActionResult(result) {
282624
282754
  return result.message ? { ok: result.ok, message: safeWebMessage(result.message) } : { ok: result.ok };
282625
282755
  }
282626
282756
  function sanitizeProjectActionResult(result) {
282627
- const url = sanitizeLocalWebUiUrl(result.url);
282757
+ const url = result.ok ? sanitizeLocalWebUiUrl(result.url) : void 0;
282758
+ const errorCode = !result.ok && WEB_UI_PROJECT_ERROR_CODE_SET.has(result.errorCode) ? result.errorCode : void 0;
282628
282759
  return {
282629
282760
  ok: result.ok,
282630
282761
  ...result.message ? { message: safeWebMessage(result.message) } : {},
282631
- ...result.path ? { path: safeWebText(result.path, 4096) } : {},
282762
+ ...errorCode ? { errorCode } : {},
282763
+ ...result.ok && result.path ? { path: safeWebText(result.path, 4096) } : {},
282632
282764
  ...url ? { url } : {},
282633
- ...result.cancelled ? { cancelled: true } : {}
282765
+ ...result.ok && result.cancelled ? { cancelled: true } : {}
282634
282766
  };
282635
282767
  }
282636
282768
  function sanitizeLocalWebUiUrl(value) {
@@ -283709,14 +283841,13 @@ var BASE_COPY = {
283709
283841
  navigation: "Tools",
283710
283842
  projects: "Projects",
283711
283843
  recentProjects: "Recent projects",
283712
- newProject: "New project",
283844
+ newProject: "Add project",
283713
283845
  projectDialogTitle: "Open or create a project",
283714
- projectDialogBody: "Choose an existing folder, or enter the absolute path of a new folder whose parent already exists. Orbit opens it in a separate local browser tab with its own chats and context.",
283846
+ projectDialogBody: "Choose an existing folder to add it to Orbit, or enter the absolute path of a new folder whose parent already exists. Orbit opens it in a separate local browser tab with its own chats and context.",
283715
283847
  projectPath: "Project folder path",
283716
283848
  projectPathPlaceholder: "C:\\path\\to\\project",
283717
283849
  browseProject: "Browse folders",
283718
- openProject: "Open folder",
283719
- createProject: "Create & open",
283850
+ createProject: "Open or create",
283720
283851
  recentTasks: "Chats",
283721
283852
  searchChats: "Search chats",
283722
283853
  showMoreChats: "Show more",
@@ -283890,14 +284021,13 @@ var BASE_COPY = {
283890
284021
  navigation: "\u5DE5\u5177",
283891
284022
  projects: "\u9879\u76EE",
283892
284023
  recentProjects: "\u6700\u8FD1\u9879\u76EE",
283893
- newProject: "\u65B0\u5EFA\u9879\u76EE",
284024
+ newProject: "\u6DFB\u52A0\u9879\u76EE",
283894
284025
  projectDialogTitle: "\u6253\u5F00\u6216\u521B\u5EFA\u9879\u76EE",
283895
- projectDialogBody: "\u6D4F\u89C8\u9009\u62E9\u5DF2\u6709\u6587\u4EF6\u5939\uFF0C\u6216\u8F93\u5165\u7236\u76EE\u5F55\u5DF2\u5B58\u5728\u7684\u65B0\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\u3002Orbit \u4F1A\u5728\u72EC\u7ACB\u7684\u672C\u5730\u6D4F\u89C8\u5668\u6807\u7B7E\u9875\u4E2D\u6253\u5F00\uFF0C\u5E76\u4FDD\u7559\u81EA\u5DF1\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
284026
+ projectDialogBody: "\u9009\u62E9\u5DF2\u6709\u6587\u4EF6\u5939\u53EF\u76F4\u63A5\u52A0\u5165 Orbit\uFF1B\u4E5F\u53EF\u4EE5\u8F93\u5165\u7236\u76EE\u5F55\u5DF2\u5B58\u5728\u7684\u65B0\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\u3002Orbit \u4F1A\u5728\u72EC\u7ACB\u7684\u672C\u5730\u6D4F\u89C8\u5668\u6807\u7B7E\u9875\u4E2D\u6253\u5F00\uFF0C\u5E76\u4FDD\u7559\u81EA\u5DF1\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
283896
284027
  projectPath: "\u9879\u76EE\u6587\u4EF6\u5939\u8DEF\u5F84",
283897
284028
  projectPathPlaceholder: "C:\\\u8DEF\u5F84\\\u9879\u76EE\u540D\u79F0",
283898
284029
  browseProject: "\u6D4F\u89C8\u6587\u4EF6\u5939",
283899
- openProject: "\u6253\u5F00\u6587\u4EF6\u5939",
283900
- createProject: "\u521B\u5EFA\u5E76\u6253\u5F00",
284030
+ createProject: "\u6253\u5F00\u6216\u521B\u5EFA",
283901
284031
  recentTasks: "\u5BF9\u8BDD",
283902
284032
  searchChats: "\u641C\u7D22\u5BF9\u8BDD",
283903
284033
  showMoreChats: "\u663E\u793A\u66F4\u591A",
@@ -284075,13 +284205,12 @@ var COPY = {
284075
284205
  navigation: "\u5DE5\u5177",
284076
284206
  projects: "\u5C08\u6848",
284077
284207
  recentProjects: "\u6700\u8FD1\u5C08\u6848",
284078
- newProject: "\u65B0\u589E\u5C08\u6848",
284208
+ newProject: "\u52A0\u5165\u5C08\u6848",
284079
284209
  projectDialogTitle: "\u958B\u555F\u6216\u5EFA\u7ACB\u5C08\u6848",
284080
- projectDialogBody: "\u700F\u89BD\u9078\u64C7\u73FE\u6709\u8CC7\u6599\u593E\uFF0C\u6216\u8F38\u5165\u7236\u8CC7\u6599\u593E\u5DF2\u5B58\u5728\u7684\u65B0\u8CC7\u6599\u593E\u7D55\u5C0D\u8DEF\u5F91\u3002Orbit \u6703\u5728\u7368\u7ACB\u7684\u672C\u6A5F\u700F\u89BD\u5668\u5206\u9801\u958B\u555F\uFF0C\u4E26\u4FDD\u7559\u81EA\u5DF1\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
284210
+ projectDialogBody: "\u9078\u64C7\u73FE\u6709\u8CC7\u6599\u593E\u53EF\u76F4\u63A5\u52A0\u5165 Orbit\uFF1B\u4E5F\u53EF\u4EE5\u8F38\u5165\u7236\u8CC7\u6599\u593E\u5DF2\u5B58\u5728\u7684\u65B0\u8CC7\u6599\u593E\u7D55\u5C0D\u8DEF\u5F91\u3002Orbit \u6703\u5728\u7368\u7ACB\u7684\u672C\u6A5F\u700F\u89BD\u5668\u5206\u9801\u958B\u555F\uFF0C\u4E26\u4FDD\u7559\u81EA\u5DF1\u7684\u804A\u5929\u548C\u4E0A\u4E0B\u6587\u3002",
284081
284211
  projectPath: "\u5C08\u6848\u8CC7\u6599\u593E\u8DEF\u5F91",
284082
284212
  browseProject: "\u700F\u89BD\u8CC7\u6599\u593E",
284083
- openProject: "\u958B\u555F\u8CC7\u6599\u593E",
284084
- createProject: "\u5EFA\u7ACB\u4E26\u958B\u555F",
284213
+ createProject: "\u958B\u555F\u6216\u5EFA\u7ACB",
284085
284214
  recentTasks: "\u5C0D\u8A71",
284086
284215
  searchChats: "\u641C\u5C0B\u5C0D\u8A71",
284087
284216
  showMoreChats: "\u986F\u793A\u66F4\u591A",
@@ -284807,7 +284936,6 @@ function renderWebUiPage(language) {
284807
284936
  </div>
284808
284937
  <div class="project-dialog-actions">
284809
284938
  <button class="project-dialog-cancel" id="projectDialogCancel" type="button">${copy.cancel}</button>
284810
- <button class="project-dialog-open" id="projectDialogOpen" type="button">${copy.openProject}</button>
284811
284939
  <button class="project-dialog-create" id="projectDialogCreate" type="button">${copy.createProject}</button>
284812
284940
  </div>
284813
284941
  </section>
@@ -287195,8 +287323,7 @@ var WEB_UI_FEEDBACK_STYLES = String.raw`
287195
287323
  font-weight: 620;
287196
287324
  }
287197
287325
 
287198
- .project-dialog-cancel,
287199
- .project-dialog-open {
287326
+ .project-dialog-cancel {
287200
287327
  color: var(--muted);
287201
287328
  background: var(--surface-subtle);
287202
287329
  border: 1px solid var(--border);
@@ -289546,11 +289673,6 @@ var WEB_UI_RESPONSIVE_STYLES = String.raw`
289546
289673
  width: 100%;
289547
289674
  }
289548
289675
 
289549
- .project-dialog-cancel {
289550
- grid-column: 1 / -1;
289551
- grid-row: 2;
289552
- }
289553
-
289554
289676
  .workspace-view {
289555
289677
  grid-template-rows: 54px auto minmax(0, 1fr);
289556
289678
  }
@@ -291493,11 +291615,14 @@ var SessionActionSchema = z58.discriminatedUnion("action", [
291493
291615
  }).strict()
291494
291616
  )
291495
291617
  ]);
291618
+ var ProjectPathSchema = z58.string().trim().min(1).max(4096).refine((value) => !/[\u0000-\u001f\u007f]/.test(value), {
291619
+ message: "Project paths cannot contain control characters."
291620
+ });
291496
291621
  var ProjectActionSchema = z58.discriminatedUnion("action", [
291497
291622
  z58.object({ action: z58.literal("pick") }).strict(),
291498
291623
  z58.object({
291499
291624
  action: z58.enum(["open", "create"]),
291500
- path: z58.string().trim().min(1).max(4096)
291625
+ path: ProjectPathSchema
291501
291626
  }).strict(),
291502
291627
  z58.object({
291503
291628
  action: z58.literal("remove"),
@@ -294400,33 +294525,57 @@ import { spawn as spawn4 } from "child_process";
294400
294525
  import { existsSync as existsSync20, mkdirSync as mkdirSync7, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
294401
294526
  import { dirname as dirname13, isAbsolute as isAbsolute7, parse as parse4, resolve as resolve13 } from "path";
294402
294527
  var PROJECT_WEB_UI_READY_MESSAGE = "orbit-webui-ready";
294528
+ var ProjectLaunchError = class extends Error {
294529
+ constructor(code, message2, options) {
294530
+ super(message2, options);
294531
+ this.code = code;
294532
+ }
294533
+ code;
294534
+ name = "ProjectLaunchError";
294535
+ };
294403
294536
  async function launchOrbitProject(request, options = {}) {
294404
294537
  if (!isAbsolute7(request.path)) {
294405
- throw new Error("Enter an absolute project folder path.");
294538
+ throw new ProjectLaunchError(
294539
+ "absolute_path_required",
294540
+ "Enter an absolute project folder path."
294541
+ );
294406
294542
  }
294407
294543
  const requestedPath = resolve13(request.path);
294408
- if (requestedPath === parse4(requestedPath).root) {
294409
- throw new Error("A filesystem root cannot be opened as an Orbit project.");
294410
- }
294544
+ rejectFilesystemRoot(requestedPath);
294411
294545
  const entryPoint = options.entryPoint || process.argv[1];
294412
- if (!entryPoint) throw new Error("Orbit CLI entry point is unavailable.");
294546
+ if (!entryPoint) {
294547
+ throw new ProjectLaunchError(
294548
+ "entrypoint_unavailable",
294549
+ "Orbit CLI entry point is unavailable."
294550
+ );
294551
+ }
294413
294552
  if (request.action === "create") {
294414
- createProjectDirectory(requestedPath);
294553
+ ensureProjectDirectory(requestedPath);
294415
294554
  } else {
294416
294555
  requireProjectDirectory(requestedPath);
294417
294556
  }
294418
- const projectPath = realpathSync3(requestedPath);
294557
+ const projectPath = realpathSync3.native(requestedPath);
294558
+ rejectFilesystemRoot(projectPath);
294419
294559
  const launch = options.launch || spawn4;
294420
- const child = launch(
294421
- options.executable || process.execPath,
294422
- [entryPoint, "webui", "--cwd", projectPath],
294423
- {
294424
- ...HIDDEN_CHILD_PROCESS_OPTIONS,
294425
- cwd: projectPath,
294426
- detached: true,
294427
- stdio: ["ignore", "ignore", "ignore", "ipc"]
294428
- }
294429
- );
294560
+ let child;
294561
+ try {
294562
+ child = launch(
294563
+ options.executable || process.execPath,
294564
+ [entryPoint, "webui", "--cwd", projectPath],
294565
+ {
294566
+ ...HIDDEN_CHILD_PROCESS_OPTIONS,
294567
+ cwd: projectPath,
294568
+ detached: true,
294569
+ stdio: ["ignore", "ignore", "ignore", "ipc"]
294570
+ }
294571
+ );
294572
+ } catch (error) {
294573
+ throw new ProjectLaunchError(
294574
+ "launch_failed",
294575
+ "Orbit project could not be started.",
294576
+ { cause: error }
294577
+ );
294578
+ }
294430
294579
  return await new Promise(
294431
294580
  (resolveLaunch, rejectLaunch) => {
294432
294581
  let settled = false;
@@ -294456,11 +294605,16 @@ async function launchOrbitProject(request, options = {}) {
294456
294605
  };
294457
294606
  const onError = (error) => finish(
294458
294607
  void 0,
294459
- new Error(`Orbit project could not be opened: ${error.message}`)
294608
+ new ProjectLaunchError(
294609
+ "launch_failed",
294610
+ `Orbit project could not be opened: ${error.message}`,
294611
+ { cause: error }
294612
+ )
294460
294613
  );
294461
294614
  const onExit2 = (code) => finish(
294462
294615
  void 0,
294463
- new Error(
294616
+ new ProjectLaunchError(
294617
+ "startup_failed",
294464
294618
  `Orbit project exited before its Web UI was ready${code === null ? "." : ` (code ${code}).`}`
294465
294619
  )
294466
294620
  );
@@ -294469,7 +294623,10 @@ async function launchOrbitProject(request, options = {}) {
294469
294623
  child.kill();
294470
294624
  finish(
294471
294625
  void 0,
294472
- new Error("Timed out while starting the Orbit project.")
294626
+ new ProjectLaunchError(
294627
+ "startup_timeout",
294628
+ "Timed out while starting the Orbit project."
294629
+ )
294473
294630
  );
294474
294631
  },
294475
294632
  Math.max(1e3, options.startupTimeoutMs ?? 15e3)
@@ -294487,38 +294644,59 @@ function parseReadyUrl(message2) {
294487
294644
  }
294488
294645
  return sanitizeLocalWebUiUrl(message2.url);
294489
294646
  }
294490
- function createProjectDirectory(projectPath) {
294647
+ function ensureProjectDirectory(projectPath) {
294491
294648
  if (existsSync20(projectPath)) {
294492
- throw new Error("Project folder already exists. Use Open folder instead.");
294649
+ requireProjectDirectory(projectPath);
294650
+ return;
294493
294651
  }
294494
294652
  const parentPath = dirname13(projectPath);
294495
294653
  if (!existsSync20(parentPath)) {
294496
- throw new Error(
294654
+ throw new ProjectLaunchError(
294655
+ "parent_missing",
294497
294656
  "The parent folder does not exist. Choose an existing location first."
294498
294657
  );
294499
294658
  }
294500
294659
  if (!statSync5(parentPath).isDirectory()) {
294501
- throw new Error("The project parent path must be a directory.");
294660
+ throw new ProjectLaunchError(
294661
+ "parent_not_directory",
294662
+ "The project parent path must be a directory."
294663
+ );
294502
294664
  }
294503
294665
  try {
294504
294666
  mkdirSync7(projectPath);
294505
294667
  } catch (error) {
294506
294668
  if (isNodeError4(error) && error.code === "EEXIST") {
294507
- throw new Error(
294508
- "Project folder already exists. Use Open folder instead."
294509
- );
294669
+ requireProjectDirectory(projectPath);
294670
+ return;
294510
294671
  }
294511
- throw new Error("Orbit could not create the project folder.", {
294512
- cause: error
294513
- });
294672
+ throw new ProjectLaunchError(
294673
+ "create_failed",
294674
+ "Orbit could not create the project folder.",
294675
+ { cause: error }
294676
+ );
294514
294677
  }
294515
294678
  }
294516
294679
  function requireProjectDirectory(projectPath) {
294517
294680
  if (!existsSync20(projectPath)) {
294518
- throw new Error("Project folder does not exist.");
294681
+ throw new ProjectLaunchError(
294682
+ "project_missing",
294683
+ "Project folder does not exist."
294684
+ );
294519
294685
  }
294520
294686
  if (!statSync5(projectPath).isDirectory()) {
294521
- throw new Error("Project path must point to a directory.");
294687
+ throw new ProjectLaunchError(
294688
+ "project_not_directory",
294689
+ "Project path must point to a directory."
294690
+ );
294691
+ }
294692
+ }
294693
+ function rejectFilesystemRoot(projectPath) {
294694
+ const normalized = resolve13(projectPath);
294695
+ if (normalized === parse4(normalized).root) {
294696
+ throw new ProjectLaunchError(
294697
+ "filesystem_root",
294698
+ "A filesystem root cannot be opened as an Orbit project."
294699
+ );
294522
294700
  }
294523
294701
  }
294524
294702
  function isNodeError4(error) {
@@ -294693,7 +294871,7 @@ async function selectOrbitProjectFolder(options = {}) {
294693
294871
  const result = await run(command.executable, command.args);
294694
294872
  return result.stdout.trim() || null;
294695
294873
  } catch (error) {
294696
- if (isPickerCancellation(error)) return null;
294874
+ if (isPickerCancellation(error, platform)) return null;
294697
294875
  throw new Error(
294698
294876
  platform === "linux" ? "The system folder picker is unavailable. Install zenity or enter the path manually." : "The system folder picker could not be opened. Enter the path manually.",
294699
294877
  { cause: error }
@@ -294731,10 +294909,11 @@ function projectPickerCommand(platform) {
294731
294909
  ]
294732
294910
  };
294733
294911
  }
294734
- function isPickerCancellation(error) {
294912
+ function isPickerCancellation(error, platform) {
294735
294913
  if (!error || typeof error !== "object") return false;
294736
294914
  const candidate = error;
294737
- return candidate.code === 1 || typeof candidate.stderr === "string" && candidate.stderr.includes("User canceled");
294915
+ const stderr = typeof candidate.stderr === "string" ? candidate.stderr.trim() : "";
294916
+ return stderr.includes("User canceled") || platform === "linux" && candidate.code === 1 && stderr.length === 0;
294738
294917
  }
294739
294918
 
294740
294919
  // src/runtime/commands/SessionMetadataCommandHandler.ts
@@ -295654,6 +295833,7 @@ var CommandRouter = class {
295654
295833
  } catch (error) {
295655
295834
  return {
295656
295835
  ok: false,
295836
+ ...error instanceof ProjectLaunchError ? { errorCode: error.code } : {},
295657
295837
  message: error instanceof Error ? error.message : "Orbit could not open the selected project."
295658
295838
  };
295659
295839
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbit-build/cli",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Local-first AI coding agent CLI, TUI, Web UI, diagnostics, and LSP runtime",
6
6
  "keywords": [