@codelia/cli 0.1.90 → 0.1.91

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.
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  NOOP_LAUNCH_UPDATE_SESSION,
3
3
  prepareTuiLaunch
4
- } from "./chunk-QYWLK4HY.js";
5
- import "./chunk-S7OVJIGV.js";
4
+ } from "./chunk-KQTBRN7C.js";
5
+ import "./chunk-BYLYQTEO.js";
6
6
  export {
7
7
  NOOP_LAUNCH_UPDATE_SESSION,
8
8
  prepareTuiLaunch
@@ -0,0 +1,23 @@
1
+ import {
2
+ TUI_LAUNCH_CONTEXT_FLAG,
3
+ buildTuiArgs,
4
+ buildTuiLaunchContext,
5
+ resolveBundledRuntimeLaunch,
6
+ resolveOptionalTuiBinaryPath,
7
+ resolvePlatformTuiPackageName,
8
+ resolveTuiCommand,
9
+ runTui
10
+ } from "./chunk-3NQYB4G5.js";
11
+ import "./chunk-445VMRAL.js";
12
+ import "./chunk-KQTBRN7C.js";
13
+ import "./chunk-BYLYQTEO.js";
14
+ export {
15
+ TUI_LAUNCH_CONTEXT_FLAG,
16
+ buildTuiArgs,
17
+ buildTuiLaunchContext,
18
+ resolveBundledRuntimeLaunch,
19
+ resolveOptionalTuiBinaryPath,
20
+ resolvePlatformTuiPackageName,
21
+ resolveTuiCommand,
22
+ runTui
23
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
- resolveRuntimeEnvForTui
3
- } from "./chunk-BFVVMMRM.js";
4
- import "./chunk-PG452V5E.js";
5
- import "./chunk-QYWLK4HY.js";
6
- import "./chunk-S7OVJIGV.js";
2
+ resolveBundledRuntimeLaunch
3
+ } from "./chunk-3NQYB4G5.js";
4
+ import "./chunk-445VMRAL.js";
5
+ import "./chunk-KQTBRN7C.js";
6
+ import "./chunk-BYLYQTEO.js";
7
7
 
8
8
  // src/prompt-mode.ts
9
9
  import { spawn } from "child_process";
@@ -410,10 +410,11 @@ var runPromptMode = async (options) => {
410
410
  );
411
411
  const atifOut = process.env.CODELIA_ATIF_OUT?.trim();
412
412
  const harborShellRequested = options.harborShellApproval === true && options.sandboxMode === "full-access" && process.env.CODELIA_HARBOR_SHELL_APPROVAL === "1";
413
- const runtimeEnv = resolveRuntimeEnvForTui(process.env);
414
- const runtimeCmd = runtimeEnv.CODELIA_RUNTIME_CMD ?? process.execPath;
415
- const runtimeArgsValue = runtimeEnv.CODELIA_RUNTIME_ARGS ?? "packages/runtime/src/index.ts";
416
- const runtimeArgs = parseShellLikeArgs(runtimeArgsValue);
413
+ const bundledRuntime = resolveBundledRuntimeLaunch(process.env);
414
+ const runtimeCmd = bundledRuntime?.command ?? process.env.CODELIA_RUNTIME_CMD ?? process.execPath;
415
+ const runtimeArgs = bundledRuntime ? [...bundledRuntime.args] : parseShellLikeArgs(
416
+ process.env.CODELIA_RUNTIME_ARGS ?? "packages/runtime/src/index.ts"
417
+ );
417
418
  if (runtimeArgs.length === 0) {
418
419
  runtimeArgs.push("packages/runtime/src/index.ts");
419
420
  }
@@ -424,7 +425,7 @@ var runPromptMode = async (options) => {
424
425
  runtimeArgs.push("--approval-mode", options.approvalMode);
425
426
  }
426
427
  const child = spawn(runtimeCmd, runtimeArgs, {
427
- env: runtimeEnv,
428
+ env: process.env,
428
429
  stdio: ["pipe", "pipe", "pipe"]
429
430
  });
430
431
  let buffer = "";
@@ -1,25 +1,112 @@
1
1
  import {
2
2
  CLI_VERSION,
3
3
  resolveLoadedCliPackageRoot
4
- } from "./chunk-PG452V5E.js";
4
+ } from "./chunk-445VMRAL.js";
5
5
  import {
6
6
  applyUpdate,
7
7
  buildUpdateCommand,
8
8
  commandHint,
9
9
  compareVersions,
10
+ computeRegistryId,
10
11
  detectInstallMethod,
12
+ isMatchingCheckScope,
13
+ isNewerVersion,
14
+ readUpdateState,
15
+ resolveEffectiveChannel,
16
+ resolveRegistryUrl,
11
17
  resolveUpdatePaths,
12
18
  resolveUpdateSettings,
13
19
  runRegistryCheck
14
- } from "./chunk-S7OVJIGV.js";
20
+ } from "./chunk-BYLYQTEO.js";
15
21
 
16
22
  // src/commands/update.ts
17
23
  import { promises as fs } from "fs";
24
+ import { resolveStoragePaths as resolveStoragePaths2 } from "@codelia/storage";
25
+
26
+ // src/update/control.ts
27
+ import { parseUpdateMode, updateConfigValue } from "@codelia/config-loader";
18
28
  import { resolveStoragePaths } from "@codelia/storage";
29
+ var runUpdateControl = async (args, options, out, err) => {
30
+ const save = args[0] === "--tui-set-mode";
31
+ const mode = save && args.length === 2 ? parseUpdateMode(args[1]) : void 0;
32
+ if (!mode && !(args.length === 1 && args[0] === "--tui-status")) {
33
+ err("Invalid update settings request.");
34
+ return 1;
35
+ }
36
+ const storage = resolveStoragePaths();
37
+ const configFile = options.configFile ?? storage.configFile;
38
+ if (mode) {
39
+ try {
40
+ await updateConfigValue(configFile, ["update", "mode"], mode);
41
+ } catch {
42
+ err(
43
+ "Could not save the global update mode. Check the config and its permissions."
44
+ );
45
+ return 1;
46
+ }
47
+ }
48
+ const settings = await resolveUpdateSettings({
49
+ configFile,
50
+ env: options.env,
51
+ interactive: true
52
+ });
53
+ const channel = resolveEffectiveChannel(
54
+ options.currentVersion,
55
+ settings.channel
56
+ );
57
+ const paths = resolveUpdatePaths(options.cacheDir ?? storage.cacheDir);
58
+ const state = await readUpdateState(paths.stateFile);
59
+ let candidate = null;
60
+ try {
61
+ const registryId = computeRegistryId(resolveRegistryUrl(options.env));
62
+ if (isMatchingCheckScope(state, {
63
+ channel,
64
+ configuredChannel: settings.channel,
65
+ registryId
66
+ }) && state.latest_version && isNewerVersion(state.latest_version, options.currentVersion)) {
67
+ candidate = state.latest_version;
68
+ }
69
+ } catch {
70
+ }
71
+ const method = options.packageRoot ? detectInstallMethod({
72
+ packageRoot: options.packageRoot,
73
+ env: options.env,
74
+ resolveNpm: options.resolveNpm
75
+ }) : null;
76
+ out(
77
+ JSON.stringify({
78
+ current_version: options.currentVersion,
79
+ channel,
80
+ candidate,
81
+ saved_mode: settings.savedMode,
82
+ effective_mode: settings.mode,
83
+ mode_source: settings.modeSource,
84
+ auto_apply_supported: method?.autoApply.supported ?? false
85
+ })
86
+ );
87
+ return 0;
88
+ };
89
+
90
+ // src/commands/update.ts
19
91
  var USAGE = "usage: codelia update [--check]";
20
92
  var runUpdateCommand = async (args, deps = {}) => {
21
93
  const out = deps.out ?? ((line) => console.log(line));
22
94
  const err = deps.err ?? ((line) => console.error(line));
95
+ if (args[0] === "--tui-status" || args[0] === "--tui-set-mode") {
96
+ return runUpdateControl(
97
+ args,
98
+ {
99
+ currentVersion: deps.currentVersion ?? CLI_VERSION,
100
+ packageRoot: deps.packageRoot === void 0 ? resolveLoadedCliPackageRoot() : deps.packageRoot,
101
+ configFile: deps.configFile,
102
+ cacheDir: deps.cacheDir,
103
+ env: deps.env ?? process.env,
104
+ resolveNpm: deps.resolveNpm
105
+ },
106
+ out,
107
+ err
108
+ );
109
+ }
23
110
  if (args.length === 1 && ["-h", "--help", "help"].includes(args[0])) {
24
111
  out(USAGE);
25
112
  return 0;
@@ -33,7 +120,7 @@ var runUpdateCommand = async (args, deps = {}) => {
33
120
  const currentVersion = deps.currentVersion ?? CLI_VERSION;
34
121
  const packageRoot = deps.packageRoot === void 0 ? resolveLoadedCliPackageRoot() : deps.packageRoot;
35
122
  const method = packageRoot ? detectInstallMethod({ packageRoot, env, resolveNpm: deps.resolveNpm }) : null;
36
- const storagePaths = resolveStoragePaths();
123
+ const storagePaths = resolveStoragePaths2();
37
124
  const paths = resolveUpdatePaths(deps.cacheDir ?? storagePaths.cacheDir);
38
125
  await fs.mkdir(paths.dir, { recursive: true });
39
126
  const settings = await resolveUpdateSettings({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codelia/cli",
3
- "version": "0.1.90",
3
+ "version": "0.1.91",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -20,19 +20,19 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@codelia/config-loader": "0.1.90",
24
- "@codelia/protocol": "0.1.90",
25
- "@codelia/runtime": "0.1.90",
26
- "@codelia/storage": "0.1.90",
23
+ "@codelia/config-loader": "0.1.91",
24
+ "@codelia/protocol": "0.1.91",
25
+ "@codelia/runtime": "0.1.91",
26
+ "@codelia/storage": "0.1.91",
27
27
  "cac": "^6.7.14",
28
28
  "zod": "^4.3.6"
29
29
  },
30
30
  "optionalDependencies": {
31
- "@codelia/tui-darwin-arm64": "0.1.90",
32
- "@codelia/tui-darwin-x64": "0.1.90",
33
- "@codelia/tui-linux-arm64": "0.1.90",
34
- "@codelia/tui-linux-x64": "0.1.90",
35
- "@codelia/tui-win32-x64": "0.1.90"
31
+ "@codelia/tui-darwin-arm64": "0.1.91",
32
+ "@codelia/tui-darwin-x64": "0.1.91",
33
+ "@codelia/tui-linux-arm64": "0.1.91",
34
+ "@codelia/tui-linux-x64": "0.1.91",
35
+ "@codelia/tui-win32-x64": "0.1.91"
36
36
  },
37
37
  "overrides": {
38
38
  "gaxios": "7.1.4"
@@ -1,19 +0,0 @@
1
- import {
2
- resolveLaunchEnvForTui,
3
- resolveOptionalTuiBinaryPath,
4
- resolvePlatformTuiPackageName,
5
- resolveRuntimeEnvForTui,
6
- resolveTuiCommand,
7
- runTui
8
- } from "./chunk-BFVVMMRM.js";
9
- import "./chunk-PG452V5E.js";
10
- import "./chunk-QYWLK4HY.js";
11
- import "./chunk-S7OVJIGV.js";
12
- export {
13
- resolveLaunchEnvForTui,
14
- resolveOptionalTuiBinaryPath,
15
- resolvePlatformTuiPackageName,
16
- resolveRuntimeEnvForTui,
17
- resolveTuiCommand,
18
- runTui
19
- };