@timurproko/a1-install 0.2.7-dev.810 → 0.2.7-dev.828

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.
package/bin/a1-install.js CHANGED
@@ -2,10 +2,11 @@
2
2
 
3
3
  import { spawn } from "node:child_process";
4
4
  import { access, lstat, readFile, realpath } from "node:fs/promises";
5
- import { lstatSync, realpathSync } from "node:fs";
5
+ import { lstatSync, realpathSync, readFileSync, statSync } from "node:fs";
6
+ import { homedir } from "node:os";
6
7
  import { delimiter, dirname, isAbsolute, join, resolve } from "node:path";
7
8
  import { fileURLToPath, pathToFileURL } from "node:url";
8
- import { SHARED_PROGRESS_ACCENT_ANSI } from "./progress-palette.js";
9
+ import { SHARED_PROGRESS_ACCENT_ANSI, SHARED_PROGRESS_PALETTE } from "./progress-palette.js";
9
10
 
10
11
  export { SHARED_PROGRESS_ACCENT_ANSI };
11
12
 
@@ -93,12 +94,34 @@ export function installerHelp() {
93
94
  ].join("\n");
94
95
  }
95
96
 
96
- export function renderProgressBar(percent) {
97
+ // Invariant: the bootstrap cannot import the main package's settings manager or its dependencies.
98
+ // Mirror only its bounded, read-only global A1 accent resolution before acquisition.
99
+ export function resolveInstallerAccentColor(environment = process.env, home = homedir) {
100
+ try {
101
+ const selectedHome = environment.A1_PROFILE_HOME ?? home();
102
+ if (!isAbsolute(selectedHome) || selectedHome.includes("\0")) return "blue";
103
+ const file = join(selectedHome, ".a1", "agent", "settings.json");
104
+ if (statSync(file).size > 256 * 1024) return "blue";
105
+ const raw = readFileSync(file, "utf8");
106
+ if (Buffer.byteLength(raw, "utf8") > 256 * 1024) return "blue";
107
+ const root = JSON.parse(raw.replace(/^\uFEFF/u, ""));
108
+ const settings = root && typeof root === "object" && !Array.isArray(root)
109
+ ? Object.getOwnPropertyDescriptor(root, "a1")?.value : undefined;
110
+ const value = settings && typeof settings === "object" && !Array.isArray(settings)
111
+ ? settings.accentColor : undefined;
112
+ if (value === "default") return "purple";
113
+ return typeof value === "string" && Object.hasOwn(SHARED_PROGRESS_PALETTE, value) ? value : "blue";
114
+ } catch {
115
+ return "blue";
116
+ }
117
+ }
118
+
119
+ export function renderProgressBar(percent, accent = SHARED_PROGRESS_ACCENT_ANSI) {
97
120
  const bounded = Math.min(100, Math.max(0, Math.round(percent)));
98
121
  const filled = Math.round((bounded / 100) * PROGRESS_WIDTH);
99
122
  const gray = "\u001b[38;2;128;128;128m";
100
123
  const track = "\u001b[38;2;102;102;102m";
101
- return `${SHARED_PROGRESS_ACCENT_ANSI}${"━".repeat(filled)}${track}${"─".repeat(PROGRESS_WIDTH - filled)}${gray} ${bounded}%\u001b[39m`;
124
+ return `${accent}${"━".repeat(filled)}${track}${"─".repeat(PROGRESS_WIDTH - filled)}${gray} ${bounded}%\u001b[39m`;
102
125
  }
103
126
 
104
127
  export function classifyProgressLine(line, fallback = "Installing") {
@@ -150,6 +173,7 @@ class ProgressDisplay {
150
173
  this.timer = null;
151
174
  this.visible = false;
152
175
  this.maxWidth = PROGRESS_WIDTH + 6;
176
+ this.accent = options.accent ?? SHARED_PROGRESS_ACCENT_ANSI;
153
177
  }
154
178
 
155
179
  set(percent, _label, creepTo = percent) {
@@ -172,7 +196,7 @@ class ProgressDisplay {
172
196
  this.shown = rounded;
173
197
  if (!this.visible) this.output.write("\u001b[?25l");
174
198
  this.visible = true;
175
- this.output.write(`\r${renderProgressBar(rounded)}\u001b[K`);
199
+ this.output.write(`\r${renderProgressBar(rounded, this.accent)}\u001b[K`);
176
200
  }
177
201
 
178
202
  finish() {
@@ -500,7 +524,19 @@ export async function runInstaller(argv, options = {}) {
500
524
  throw new InstallationFailure("Node.js 22.19.0 or newer is required");
501
525
  }
502
526
 
503
- const progress = options.progress ?? new ProgressDisplay(stdout, options.tty ?? stdout.isTTY === true, options.progressOptions);
527
+ const accentColor = resolveInstallerAccentColor(environment);
528
+ const background = Number.parseInt(String(environment.COLORFGBG ?? "").split(";").at(-1) ?? "", 10);
529
+ const appearance = Number.isInteger(background) && (background === 7 || background === 15 || background >= 231) ? "light" : "dark";
530
+ const program = (environment.TERM_PROGRAM ?? "").toLowerCase();
531
+ const known = ["kitty", "ghostty", "wezterm", "rex", "warpterminal", "iterm.app", "alacritty", "vscode", "zed"];
532
+ const trueColor = environment.PI_TRUE_COLOR === "1" || (environment.PI_TRUE_COLOR !== "0" && (
533
+ /^(truecolor|24bit)$/iu.test(environment.COLORTERM ?? "")
534
+ || (environment.TERM ?? "").endsWith("-direct") || process.platform === "win32"
535
+ || environment.WT_SESSION !== undefined || known.includes(program)
536
+ ));
537
+ const mode = trueColor ? "truecolor" : "256color";
538
+ const accent = SHARED_PROGRESS_PALETTE[accentColor][appearance][mode].accent;
539
+ const progress = options.progress ?? new ProgressDisplay(stdout, options.tty ?? stdout.isTTY === true, { ...options.progressOptions, accent });
504
540
  const runner = options.runner ?? createDefaultProcessRunner(environment);
505
541
  let activeChild = null;
506
542
  let killTimer = null;
@@ -1,5 +1,139 @@
1
1
  /**
2
- * Generated by scripts/pi/sync-progress-palette.ts from @earendil-works/pi-coding-agent 1.4.0
3
- * (MIT), commit 4a080252f06caf63a525d7873c5d94d3c23887e0. Do not edit directly.
2
+ * Generated by scripts/pi/sync-progress-palette.ts from A1's named accent projection
3
+ * over pinned Pi 1.4.0 (MIT), commit 4a080252f06caf63a525d7873c5d94d3c23887e0. Do not edit directly.
4
4
  */
5
- export const SHARED_PROGRESS_ACCENT_ANSI = "\u001b[38;2;167;152;215m";
5
+ export const SHARED_PROGRESS_PALETTE = Object.freeze({
6
+ "blue": {
7
+ "dark": {
8
+ "truecolor": {
9
+ "accent": "\u001b[38;2;130;160;241m",
10
+ "border": "\u001b[38;2;116;102;197m"
11
+ },
12
+ "256color": {
13
+ "accent": "\u001b[38;5;111m",
14
+ "border": "\u001b[38;5;98m"
15
+ }
16
+ },
17
+ "light": {
18
+ "truecolor": {
19
+ "accent": "\u001b[38;2;63;96;226m",
20
+ "border": "\u001b[38;2;83;67;154m"
21
+ },
22
+ "256color": {
23
+ "accent": "\u001b[38;5;62m",
24
+ "border": "\u001b[38;5;60m"
25
+ }
26
+ }
27
+ },
28
+ "purple": {
29
+ "dark": {
30
+ "truecolor": {
31
+ "accent": "\u001b[38;2;167;152;215m",
32
+ "border": "\u001b[38;2;105;115;167m"
33
+ },
34
+ "256color": {
35
+ "accent": "\u001b[38;5;140m",
36
+ "border": "\u001b[38;5;61m"
37
+ }
38
+ },
39
+ "light": {
40
+ "truecolor": {
41
+ "accent": "\u001b[38;2;116;89;180m",
42
+ "border": "\u001b[38;2;68;77;130m"
43
+ },
44
+ "256color": {
45
+ "accent": "\u001b[38;5;97m",
46
+ "border": "\u001b[38;5;60m"
47
+ }
48
+ }
49
+ },
50
+ "cyan": {
51
+ "dark": {
52
+ "truecolor": {
53
+ "accent": "\u001b[38;2;93;179;186m",
54
+ "border": "\u001b[38;2;74;128;146m"
55
+ },
56
+ "256color": {
57
+ "accent": "\u001b[38;5;73m",
58
+ "border": "\u001b[38;5;66m"
59
+ }
60
+ },
61
+ "light": {
62
+ "truecolor": {
63
+ "accent": "\u001b[38;2;40;122;129m",
64
+ "border": "\u001b[38;2;40;89;106m"
65
+ },
66
+ "256color": {
67
+ "accent": "\u001b[38;5;30m",
68
+ "border": "\u001b[38;5;23m"
69
+ }
70
+ }
71
+ },
72
+ "green": {
73
+ "dark": {
74
+ "truecolor": {
75
+ "accent": "\u001b[38;2;104;183;141m",
76
+ "border": "\u001b[38;2;75;132;120m"
77
+ },
78
+ "256color": {
79
+ "accent": "\u001b[38;5;72m",
80
+ "border": "\u001b[38;5;66m"
81
+ }
82
+ },
83
+ "light": {
84
+ "truecolor": {
85
+ "accent": "\u001b[38;2;51;126;88m",
86
+ "border": "\u001b[38;2;41;93;82m"
87
+ },
88
+ "256color": {
89
+ "accent": "\u001b[38;5;65m",
90
+ "border": "\u001b[38;5;23m"
91
+ }
92
+ }
93
+ },
94
+ "orange": {
95
+ "dark": {
96
+ "truecolor": {
97
+ "accent": "\u001b[38;2;231;135;83m",
98
+ "border": "\u001b[38;2;178;89;79m"
99
+ },
100
+ "256color": {
101
+ "accent": "\u001b[38;5;173m",
102
+ "border": "\u001b[38;5;131m"
103
+ }
104
+ },
105
+ "light": {
106
+ "truecolor": {
107
+ "accent": "\u001b[38;2;174;80;16m",
108
+ "border": "\u001b[38;2;133;57;49m"
109
+ },
110
+ "256color": {
111
+ "accent": "\u001b[38;5;130m",
112
+ "border": "\u001b[38;5;95m"
113
+ }
114
+ }
115
+ },
116
+ "pink": {
117
+ "dark": {
118
+ "truecolor": {
119
+ "accent": "\u001b[38;2;223;122;199m",
120
+ "border": "\u001b[38;2;150;91;171m"
121
+ },
122
+ "256color": {
123
+ "accent": "\u001b[38;5;176m",
124
+ "border": "\u001b[38;5;97m"
125
+ }
126
+ },
127
+ "light": {
128
+ "truecolor": {
129
+ "accent": "\u001b[38;2;178;56;153m",
130
+ "border": "\u001b[38;2;114;61;131m"
131
+ },
132
+ "256color": {
133
+ "accent": "\u001b[38;5;132m",
134
+ "border": "\u001b[38;5;60m"
135
+ }
136
+ }
137
+ }
138
+ });
139
+ export const SHARED_PROGRESS_ACCENT_ANSI = SHARED_PROGRESS_PALETTE.blue.dark.truecolor.accent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timurproko/a1-install",
3
- "version": "0.2.7-dev.810",
3
+ "version": "0.2.7-dev.828",
4
4
  "description": "Dependency-free installer for a1",
5
5
  "type": "module",
6
6
  "bin": {