testingterm 0.0.0-stage → 0.0.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 (52) hide show
  1. package/AGENT-DOCS.md +77 -0
  2. package/LICENSE +21 -0
  3. package/dist/ai.d.ts +24 -0
  4. package/dist/attach.d.ts +6 -0
  5. package/dist/capabilities.d.ts +6 -0
  6. package/dist/chunks/ai-MISD5ZKB.js +260 -0
  7. package/dist/chunks/args-FJPX5SKE.js +8 -0
  8. package/dist/chunks/attach-STVPRW4U.js +30 -0
  9. package/dist/chunks/chunk-66N3P624.js +44 -0
  10. package/dist/chunks/chunk-IJ5VA4HN.js +41 -0
  11. package/dist/chunks/chunk-INTJPVJZ.js +191 -0
  12. package/dist/chunks/chunk-NM755IGG.js +658 -0
  13. package/dist/chunks/chunk-PA67Y4XN.js +65 -0
  14. package/dist/chunks/chunk-U52LFC23.js +68 -0
  15. package/dist/chunks/chunk-YFGNBX2I.js +229 -0
  16. package/dist/chunks/chunk-YHQYNBAN.js +801 -0
  17. package/dist/chunks/commands-IWTFRW33.js +540 -0
  18. package/dist/chunks/context-QML5TP36.js +14 -0
  19. package/dist/chunks/help-I5WIJHZM.js +359 -0
  20. package/dist/chunks/paths-X3C4P67K.js +18 -0
  21. package/dist/chunks/run-RNFQMMXD.js +95 -0
  22. package/dist/chunks/setup-WIZULKES.js +106 -0
  23. package/dist/chunks/themes.gen-E3CTYIQE.js +8 -0
  24. package/dist/chunks/upgrade-43JWCQ63.js +143 -0
  25. package/dist/chunks/verify-55DFXJOY.js +37 -0
  26. package/dist/cli/args.d.ts +13 -0
  27. package/dist/cli/commands.d.ts +5 -0
  28. package/dist/cli/help.d.ts +2 -0
  29. package/dist/cli/main.d.ts +2 -0
  30. package/dist/cli/main.js +83 -0
  31. package/dist/cli/run.d.ts +2 -0
  32. package/dist/cli/setup.d.ts +6 -0
  33. package/dist/cli/upgrade.d.ts +19 -0
  34. package/dist/cli/verify.d.ts +2 -0
  35. package/dist/context.d.ts +33 -0
  36. package/dist/engine.d.ts +56 -0
  37. package/dist/errors.d.ts +4 -0
  38. package/dist/expect.d.ts +62 -0
  39. package/dist/index.d.ts +27 -0
  40. package/dist/index.js +205 -0
  41. package/dist/install.d.ts +13 -0
  42. package/dist/instances.d.ts +23 -0
  43. package/dist/locator.d.ts +49 -0
  44. package/dist/paths.d.ts +7 -0
  45. package/dist/runner.d.ts +56 -0
  46. package/dist/sync.d.ts +8 -0
  47. package/dist/terminal.d.ts +146 -0
  48. package/dist/themes.gen.d.ts +4 -0
  49. package/dist/types.d.ts +214 -0
  50. package/package.json +41 -4
  51. package/skill/testingterm/SKILL.md +138 -0
  52. package/README.md +0 -3
@@ -0,0 +1,191 @@
1
+ // src/capabilities.ts
2
+ var FULL = {
3
+ colors: "truecolor",
4
+ mouse: true,
5
+ bracketedPaste: true,
6
+ focusEvents: true,
7
+ synchronizedOutput: true,
8
+ alternateScreen: true,
9
+ kittyKeyboard: true,
10
+ kittyGraphics: true,
11
+ clipboard: true,
12
+ hyperlinks: true,
13
+ title: true,
14
+ graphemes: true
15
+ };
16
+ var PRESETS = {
17
+ full: {},
18
+ xterm: { kittyKeyboard: false, kittyGraphics: false, synchronizedOutput: false, graphemes: false },
19
+ "apple-terminal": { colors: 256, kittyKeyboard: false, kittyGraphics: false, synchronizedOutput: false, clipboard: false, hyperlinks: false, graphemes: false },
20
+ tmux: { term: "tmux-256color", kittyKeyboard: false, kittyGraphics: false, graphemes: false },
21
+ basic: { term: "xterm", colors: 16, kittyKeyboard: false, kittyGraphics: false, synchronizedOutput: false, bracketedPaste: false, focusEvents: false, clipboard: false, hyperlinks: false, graphemes: false },
22
+ dumb: {
23
+ term: "dumb",
24
+ colors: "none",
25
+ mouse: false,
26
+ bracketedPaste: false,
27
+ focusEvents: false,
28
+ synchronizedOutput: false,
29
+ alternateScreen: false,
30
+ kittyKeyboard: false,
31
+ kittyGraphics: false,
32
+ clipboard: false,
33
+ hyperlinks: false,
34
+ title: false,
35
+ graphemes: false
36
+ }
37
+ };
38
+ var CAPABILITY_PRESETS = Object.keys(PRESETS);
39
+ function resolveCapabilities(option) {
40
+ if (option === void 0) return { ...FULL };
41
+ const spec = typeof option === "string" ? { preset: option } : option;
42
+ const preset = spec.preset ?? "full";
43
+ if (!(preset in PRESETS)) throw new Error(`unknown capabilities preset "${preset}" (${CAPABILITY_PRESETS.join(", ")})`);
44
+ const { preset: _, ...overrides } = spec;
45
+ const defined = Object.fromEntries(Object.entries(overrides).filter(([, v]) => v !== void 0));
46
+ return { ...FULL, ...PRESETS[preset], ...defined };
47
+ }
48
+
49
+ // src/sync.ts
50
+ import { execFileSync } from "node:child_process";
51
+ import fs from "node:fs";
52
+ import os from "node:os";
53
+ import path from "node:path";
54
+ function appearance() {
55
+ if (process.platform !== "darwin") return "dark";
56
+ try {
57
+ return execFileSync("defaults", ["read", "-g", "AppleInterfaceStyle"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim() === "Dark" ? "dark" : "light";
58
+ } catch {
59
+ return "light";
60
+ }
61
+ }
62
+ function ghosttyDirs() {
63
+ const override = process.env.TESTINGTERM_GHOSTTY_CONFIG_DIRS;
64
+ if (override) return override.split(path.delimiter).filter(Boolean);
65
+ const xdg = process.env.XDG_CONFIG_HOME && path.isAbsolute(process.env.XDG_CONFIG_HOME) ? process.env.XDG_CONFIG_HOME : path.join(os.homedir(), ".config");
66
+ const dirs = [path.join(xdg, "ghostty")];
67
+ if (process.platform === "darwin") dirs.push(path.join(os.homedir(), "Library", "Application Support", "com.mitchellh.ghostty"));
68
+ return dirs;
69
+ }
70
+ function unquote(value) {
71
+ const v = value.trim();
72
+ return v.length >= 2 && v.startsWith('"') && v.endsWith('"') ? v.slice(1, -1) : v;
73
+ }
74
+ function readGhostty(file, values, seen) {
75
+ const real = path.resolve(file);
76
+ if (seen.has(real)) return;
77
+ seen.add(real);
78
+ let text;
79
+ try {
80
+ text = fs.readFileSync(real, "utf8");
81
+ } catch {
82
+ return;
83
+ }
84
+ for (const line of text.split("\n")) {
85
+ const match = /^\s*([a-z0-9-]+)\s*=\s*(.*?)\s*$/.exec(line);
86
+ if (!match) continue;
87
+ const [, key, raw] = match;
88
+ const value = unquote(raw);
89
+ if (key === "config-file") {
90
+ const target = value.replace(/^\?/, "");
91
+ const expanded = target.startsWith("~/") ? path.join(os.homedir(), target.slice(2)) : target;
92
+ readGhostty(path.isAbsolute(expanded) ? expanded : path.join(path.dirname(real), expanded), values, seen);
93
+ continue;
94
+ }
95
+ if (key === "palette") values.set("palette", [...values.get("palette") ?? [], value]);
96
+ else values.set(key, [value]);
97
+ }
98
+ }
99
+ function pick(theme, mode) {
100
+ if (!theme.includes(":") || !/(^|,)\s*(light|dark)\s*:/.test(theme)) return theme;
101
+ const pairs = Object.fromEntries(theme.split(",").map((part) => part.split(":").map((s) => s.trim())));
102
+ return pairs[mode ?? appearance()] ?? pairs.dark ?? pairs.light ?? theme;
103
+ }
104
+ function ghosttyThemeFile(name) {
105
+ if (path.isAbsolute(name)) return fs.existsSync(name) ? name : null;
106
+ for (const dir of ghosttyDirs()) {
107
+ const file = path.join(dir, "themes", name);
108
+ if (fs.existsSync(file)) return file;
109
+ }
110
+ return null;
111
+ }
112
+ function colorsFrom(values) {
113
+ const colors = {};
114
+ const one = (key) => values.get(key)?.at(-1);
115
+ const hex = (value) => value && /^#?[0-9a-f]{6}$/i.test(value) ? `#${value.replace(/^#/, "")}` : void 0;
116
+ colors.background = hex(one("background"));
117
+ colors.foreground = hex(one("foreground"));
118
+ colors.cursor = hex(one("cursor-color"));
119
+ colors.cursorText = hex(one("cursor-text"));
120
+ const palette = {};
121
+ for (const entry of values.get("palette") ?? []) {
122
+ const [index, color] = entry.split("=");
123
+ const value = hex(color?.trim());
124
+ if (value && Number(index) >= 0 && Number(index) < 256) palette[Number(index)] = value;
125
+ }
126
+ if (Object.keys(palette).length) colors.palette = palette;
127
+ for (const key of Object.keys(colors)) if (colors[key] === void 0) delete colors[key];
128
+ return colors;
129
+ }
130
+ function ghostty(mode) {
131
+ const values = /* @__PURE__ */ new Map();
132
+ const seen = /* @__PURE__ */ new Set();
133
+ for (const dir of ghosttyDirs()) {
134
+ for (const name of ["config", "config.ghostty"]) readGhostty(path.join(dir, name), values, seen);
135
+ }
136
+ if (seen.size === 0 || values.size === 0) throw new Error(`no Ghostty config found (looked in ${ghosttyDirs().join(", ")})`);
137
+ const own = colorsFrom(values);
138
+ const themeName = values.get("theme")?.at(-1);
139
+ let base = {};
140
+ let baseName;
141
+ if (themeName) {
142
+ const chosen = pick(themeName, mode);
143
+ const file = ghosttyThemeFile(chosen);
144
+ if (file) {
145
+ const themeValues = /* @__PURE__ */ new Map();
146
+ readGhostty(file, themeValues, /* @__PURE__ */ new Set());
147
+ base = colorsFrom(themeValues);
148
+ } else {
149
+ baseName = chosen;
150
+ }
151
+ }
152
+ const palette = { ...base.palette, ...own.palette };
153
+ const theme = { ...baseName ? { base: baseName } : {}, ...base, ...own, ...Object.keys(palette).length ? { palette } : {} };
154
+ const size = Number(values.get("font-size")?.at(-1));
155
+ return { theme, fontSize: Number.isFinite(size) && size > 0 ? size : void 0 };
156
+ }
157
+ function rexDefault(key) {
158
+ try {
159
+ return execFileSync("defaults", ["read", "com.superlogical.rex", key], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
160
+ } catch {
161
+ return null;
162
+ }
163
+ }
164
+ function rex(mode) {
165
+ if (process.platform !== "darwin") throw new Error("Rex settings are only on macOS");
166
+ const which = mode ?? appearance();
167
+ const id = rexDefault(which === "dark" ? "Workspace.darkThemeID" : "Workspace.lightThemeID") ?? (which === "dark" ? "merino-dark" : "merino-light");
168
+ const custom = rexDefault("Workspace.customThemes");
169
+ if (custom) {
170
+ try {
171
+ const themes = JSON.parse(custom);
172
+ const found = themes.find((theme) => theme.id === id)?.source;
173
+ if (found) return { theme: { background: found.background, foreground: found.foreground, cursor: found.cursor, cursorText: found.cursorText, palette: found.ansi } };
174
+ } catch {
175
+ }
176
+ }
177
+ return { theme: `rex:${id}` };
178
+ }
179
+ function syncTheme(theme) {
180
+ if (typeof theme !== "string") return null;
181
+ const match = /^(ghostty|rex)(?::(light|dark))?$/i.exec(theme.trim());
182
+ if (!match) return null;
183
+ const mode = match[2]?.toLowerCase();
184
+ return match[1].toLowerCase() === "ghostty" ? ghostty(mode) : rex(mode);
185
+ }
186
+
187
+ export {
188
+ CAPABILITY_PRESETS,
189
+ resolveCapabilities,
190
+ syncTheme
191
+ };