oh-my-opencode 4.16.0 → 4.16.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.
- package/.agents/skills/codex-qa/SKILL.md +9 -7
- package/.agents/skills/codex-qa/references/logging-debug.md +6 -4
- package/.agents/skills/opencode-qa/SKILL.md +9 -9
- package/.agents/skills/opencode-qa/references/tui-tmux.md +10 -8
- package/dist/cli/codex-ulw-loop.d.ts +8 -0
- package/dist/cli/get-local-version/types.d.ts +1 -1
- package/dist/cli/index.js +260 -207
- package/dist/cli-node/index.js +260 -207
- package/dist/features/background-agent/parent-wake-dedupe.d.ts +1 -0
- package/dist/features/background-agent/parent-wake-flush-runner.d.ts +2 -0
- package/dist/features/background-agent/parent-wake-prompt-dispatch.d.ts +1 -0
- package/dist/features/builtin-commands/templates/refactor-sections/intro-and-analysis.d.ts +1 -1
- package/dist/features/builtin-commands/templates/remove-ai-slops.d.ts +1 -1
- package/dist/features/builtin-commands/templates/start-work.d.ts +1 -1
- package/dist/features/monitor/process.d.ts +17 -1
- package/dist/index.js +1098 -1020
- package/dist/skills/frontend/SKILL.md +9 -9
- package/dist/skills/frontend/references/design/README.md +7 -3
- package/dist/skills/frontend/references/design/_INDEX.md +1 -1
- package/dist/skills/frontend/references/design/design-system-architecture.md +24 -2
- package/dist/skills/frontend/references/designpowers/README.md +2 -2
- package/dist/skills/frontend/references/designpowers/lane-b-execution.md +1 -1
- package/dist/skills/review-work/SKILL.md +3 -1
- package/dist/skills/start-work/SKILL.md +4 -2
- package/dist/skills/ulw-research/SKILL.md +3 -1
- package/dist/skills/visual-qa/SKILL.md +13 -17
- package/docs/reference/web-terminal-visual-qa.md +39 -45
- package/package.json +31 -25
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/codegraph/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/bundled-rules/hephaestus.md +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/directive.md +3 -3
- package/packages/omo-codex/plugin/components/start-work-continuation/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/start-work-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/start-work-continuation/test/codex-hook.test.ts +1 -1
- package/packages/omo-codex/plugin/components/teammode/AGENTS.md +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/skills/teammode/SKILL.md +3 -3
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/directive.md +19 -10
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/skills/ultrawork/SKILL.md +19 -10
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/SKILL.md +13 -0
- package/packages/omo-codex/plugin/components/ultrawork/skills/ulw-plan/references/full-workflow.md +2 -0
- package/packages/omo-codex/plugin/components/ultrawork/test/codex-hook.test.ts +22 -1
- package/packages/omo-codex/plugin/components/ulw-loop/CHANGELOG.md +4 -0
- package/packages/omo-codex/plugin/components/ulw-loop/directive.md +19 -10
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-commands.js +15 -2
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli-steering.js +2 -1
- package/packages/omo-codex/plugin/components/ulw-loop/dist/cli.js +89 -27
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.d.ts +6 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/plan-io.js +55 -9
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-snapshot.d.ts +15 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-snapshot.js +33 -0
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering-types.d.ts +10 -3
- package/packages/omo-codex/plugin/components/ulw-loop/dist/steering.js +15 -11
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +3 -1
- package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +7 -7
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-commands.ts +17 -2
- package/packages/omo-codex/plugin/components/ulw-loop/src/cli-steering.ts +2 -1
- package/packages/omo-codex/plugin/components/ulw-loop/src/plan-io.ts +59 -11
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering-snapshot.ts +38 -0
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering-types.ts +11 -3
- package/packages/omo-codex/plugin/components/ulw-loop/src/steering.ts +15 -7
- package/packages/omo-codex/plugin/components/ulw-loop/test/cli-create-goals.test.ts +16 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/plan-io.test.ts +260 -2
- package/packages/omo-codex/plugin/components/ulw-loop/test/skill-contract.test.ts +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/test/steering-snapshot.test.ts +124 -0
- package/packages/omo-codex/plugin/components/ulw-loop/test/steering.test.ts +101 -2
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-codegraph-init-guidance.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-codegraph-bootstrap.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-start-work-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-checking-start-work-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +13 -13
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/scripts/auto-update.mjs +64 -17
- package/packages/omo-codex/plugin/scripts/hook-status-message.mjs +10 -6
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/multi-agent-v2-guard.mjs +186 -20
- package/packages/omo-codex/plugin/scripts/migrate-codex-config/subagent-limit-guard.mjs +51 -3
- package/packages/omo-codex/plugin/scripts/migrate-codex-config.mjs +33 -5
- package/packages/omo-codex/plugin/scripts/sync-skills.mjs +1 -1
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +9 -9
- package/packages/omo-codex/plugin/skills/frontend/references/design/README.md +7 -3
- package/packages/omo-codex/plugin/skills/frontend/references/design/_INDEX.md +1 -1
- package/packages/omo-codex/plugin/skills/frontend/references/design/design-system-architecture.md +24 -2
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/README.md +2 -2
- package/packages/omo-codex/plugin/skills/frontend/references/designpowers/lane-b-execution.md +1 -1
- package/packages/omo-codex/plugin/skills/init-deep/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/refactor/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/remove-ai-slops/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/review-work/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/start-work/SKILL.md +3 -3
- package/packages/omo-codex/plugin/skills/teammode/SKILL.md +3 -3
- package/packages/omo-codex/plugin/skills/ultrawork/SKILL.md +19 -10
- package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +3 -1
- package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +7 -7
- package/packages/omo-codex/plugin/skills/ulw-plan/SKILL.md +13 -0
- package/packages/omo-codex/plugin/skills/ulw-plan/references/full-workflow.md +2 -0
- package/packages/omo-codex/plugin/skills/ulw-research/SKILL.md +1 -1
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +14 -18
- package/packages/omo-codex/plugin/test/aggregate-hooks.test.mjs +4 -4
- package/packages/omo-codex/plugin/test/aggregate-plugin-fixture.mjs +1 -1
- package/packages/omo-codex/plugin/test/auto-update.test.mjs +35 -1
- package/packages/omo-codex/plugin/test/bootstrap-hooks.test.mjs +1 -1
- package/packages/omo-codex/plugin/test/hook-status-message.test.mjs +22 -9
- package/packages/omo-codex/plugin/test/migrate-codex-config.test.mjs +275 -19
- package/packages/omo-codex/plugin/test/subagent-limit-migration.test.mjs +33 -0
- package/packages/omo-codex/plugin/test/sync-hook-status-messages.test.mjs +6 -6
- package/packages/omo-codex/plugin/test/sync-skills-orchestration.test.mjs +4 -2
- package/packages/omo-codex/plugin/test/ulw-plan-skill-contract.test.mjs +52 -0
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +65 -39
- package/packages/omo-codex/scripts/install-lazycodex-version-stamp.test.mjs +2 -2
- package/packages/shared-skills/skills/frontend/SKILL.md +9 -9
- package/packages/shared-skills/skills/frontend/references/design/README.md +7 -3
- package/packages/shared-skills/skills/frontend/references/design/_INDEX.md +1 -1
- package/packages/shared-skills/skills/frontend/references/design/design-system-architecture.md +24 -2
- package/packages/shared-skills/skills/frontend/references/designpowers/README.md +2 -2
- package/packages/shared-skills/skills/frontend/references/designpowers/lane-b-execution.md +1 -1
- package/packages/shared-skills/skills/review-work/SKILL.md +3 -1
- package/packages/shared-skills/skills/start-work/SKILL.md +4 -2
- package/packages/shared-skills/skills/ulw-research/SKILL.md +3 -1
- package/packages/shared-skills/skills/visual-qa/SKILL.md +13 -17
- package/script/qa/strip-ansi.mjs +10 -0
- package/script/qa/web-terminal-visual-qa.mjs +112 -195
- package/script/qa/xterm-live-terminal.mjs +180 -0
- package/script/qa/web-terminal-renderer.mjs +0 -218
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
const ANSI_PATTERN = /\u001b\[[0-?]*[ -/]*[@-~]/g;
|
|
2
|
-
const OSC_PATTERN = /\u001b\][\s\S]*?(?:\u0007|\u001b\\|\u009c)/g;
|
|
3
|
-
const SGR_PATTERN = /\u001b\[([0-9;:]*)m/g;
|
|
4
|
-
|
|
5
|
-
const COLOR_NAMES = [
|
|
6
|
-
"black",
|
|
7
|
-
"red",
|
|
8
|
-
"green",
|
|
9
|
-
"yellow",
|
|
10
|
-
"blue",
|
|
11
|
-
"magenta",
|
|
12
|
-
"cyan",
|
|
13
|
-
"white",
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const BASIC_ANSI_COLORS = {
|
|
17
|
-
black: "#0c0d10",
|
|
18
|
-
red: "#ff6b6b",
|
|
19
|
-
green: "#51cf66",
|
|
20
|
-
yellow: "#ffd43b",
|
|
21
|
-
blue: "#4dabf7",
|
|
22
|
-
magenta: "#d0bfff",
|
|
23
|
-
cyan: "#66d9e8",
|
|
24
|
-
white: "#f1f3f5",
|
|
25
|
-
"bright-black": "#868e96",
|
|
26
|
-
"bright-red": "#ff8787",
|
|
27
|
-
"bright-green": "#69db7c",
|
|
28
|
-
"bright-yellow": "#ffe066",
|
|
29
|
-
"bright-blue": "#74c0fc",
|
|
30
|
-
"bright-magenta": "#e599f7",
|
|
31
|
-
"bright-cyan": "#99e9f2",
|
|
32
|
-
"bright-white": "#ffffff",
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const DEFAULT_TERMINAL_FOREGROUND = "#d8dee9";
|
|
36
|
-
export const DEFAULT_TERMINAL_BACKGROUND = "#090b10";
|
|
37
|
-
|
|
38
|
-
export function escapeHtml(value) {
|
|
39
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function stripAnsi(value) {
|
|
43
|
-
return value.replace(OSC_PATTERN, "").replace(ANSI_PATTERN, "");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function createState() {
|
|
47
|
-
return {
|
|
48
|
-
bold: false,
|
|
49
|
-
dim: false,
|
|
50
|
-
italic: false,
|
|
51
|
-
underline: false,
|
|
52
|
-
inverse: false,
|
|
53
|
-
strike: false,
|
|
54
|
-
fg: null,
|
|
55
|
-
bg: null,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function parseCodes(raw) {
|
|
60
|
-
if (raw === "") return { values: [0], separators: [null] };
|
|
61
|
-
const values = [];
|
|
62
|
-
const separators = [];
|
|
63
|
-
let separator = null;
|
|
64
|
-
for (const part of raw.split(/([;:])/)) {
|
|
65
|
-
if (part === ";" || part === ":") {
|
|
66
|
-
separator = part;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
values.push(part === "" ? null : Number.parseInt(part, 10));
|
|
70
|
-
separators.push(separator);
|
|
71
|
-
separator = null;
|
|
72
|
-
}
|
|
73
|
-
return { values, separators };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function basicColor(code, base, brightBase, prefix) {
|
|
77
|
-
if (code >= base && code < base + COLOR_NAMES.length) return `${prefix}-${COLOR_NAMES[code - base]}`;
|
|
78
|
-
if (code >= brightBase && code < brightBase + COLOR_NAMES.length) {
|
|
79
|
-
return `${prefix}-bright-${COLOR_NAMES[code - brightBase]}`;
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function rgbFrom256(index) {
|
|
85
|
-
if (index < 0 || index > 255) return null;
|
|
86
|
-
if (index < 16) {
|
|
87
|
-
const base = [
|
|
88
|
-
"#000000",
|
|
89
|
-
"#800000",
|
|
90
|
-
"#008000",
|
|
91
|
-
"#808000",
|
|
92
|
-
"#000080",
|
|
93
|
-
"#800080",
|
|
94
|
-
"#008080",
|
|
95
|
-
"#c0c0c0",
|
|
96
|
-
"#808080",
|
|
97
|
-
"#ff0000",
|
|
98
|
-
"#00ff00",
|
|
99
|
-
"#ffff00",
|
|
100
|
-
"#0000ff",
|
|
101
|
-
"#ff00ff",
|
|
102
|
-
"#00ffff",
|
|
103
|
-
"#ffffff",
|
|
104
|
-
];
|
|
105
|
-
return base[index] ?? null;
|
|
106
|
-
}
|
|
107
|
-
if (index >= 232) {
|
|
108
|
-
const level = 8 + (index - 232) * 10;
|
|
109
|
-
return `rgb(${level}, ${level}, ${level})`;
|
|
110
|
-
}
|
|
111
|
-
const offset = index - 16;
|
|
112
|
-
const levels = [0, 95, 135, 175, 215, 255];
|
|
113
|
-
const r = levels[Math.floor(offset / 36) % 6] ?? 0;
|
|
114
|
-
const g = levels[Math.floor(offset / 6) % 6] ?? 0;
|
|
115
|
-
const b = levels[offset % 6] ?? 0;
|
|
116
|
-
return `rgb(${r}, ${g}, ${b})`;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function readExtendedColor(codes, separators, index) {
|
|
120
|
-
const mode = codes[index + 1];
|
|
121
|
-
if (mode === 5) return { color: rgbFrom256(codes[index + 2] ?? -1), next: index + 3 };
|
|
122
|
-
if (mode === 2) {
|
|
123
|
-
const offset = separators[index + 1] === ":" && codes[index + 5] !== undefined ? 3 : 2;
|
|
124
|
-
const [r, g, b] = [codes[index + offset], codes[index + offset + 1], codes[index + offset + 2]];
|
|
125
|
-
if ([r, g, b].every((value) => Number.isInteger(value) && value >= 0 && value <= 255)) {
|
|
126
|
-
return { color: `rgb(${r}, ${g}, ${b})`, next: index + offset + 3 };
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return { color: null, next: index + 1 };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function applySgr(state, raw) {
|
|
133
|
-
const { values: codes, separators } = parseCodes(raw);
|
|
134
|
-
let nextState = { ...state };
|
|
135
|
-
for (let i = 0; i < codes.length; i += 1) {
|
|
136
|
-
const code = codes[i] ?? 0;
|
|
137
|
-
if (code === 0) nextState = createState();
|
|
138
|
-
else if (code === 1) nextState.bold = true;
|
|
139
|
-
else if (code === 2) nextState.dim = true;
|
|
140
|
-
else if (code === 3) nextState.italic = true;
|
|
141
|
-
else if (code === 4) nextState.underline = true;
|
|
142
|
-
else if (code === 7) nextState.inverse = true;
|
|
143
|
-
else if (code === 9) nextState.strike = true;
|
|
144
|
-
else if (code === 22) {
|
|
145
|
-
nextState.bold = false;
|
|
146
|
-
nextState.dim = false;
|
|
147
|
-
} else if (code === 23) nextState.italic = false;
|
|
148
|
-
else if (code === 24) nextState.underline = false;
|
|
149
|
-
else if (code === 27) nextState.inverse = false;
|
|
150
|
-
else if (code === 29) nextState.strike = false;
|
|
151
|
-
else if (code === 39) nextState.fg = null;
|
|
152
|
-
else if (code === 49) nextState.bg = null;
|
|
153
|
-
else if (code === 38 || code === 48) {
|
|
154
|
-
const extended = readExtendedColor(codes, separators, i);
|
|
155
|
-
if (code === 38) nextState.fg = extended.color;
|
|
156
|
-
else nextState.bg = extended.color;
|
|
157
|
-
i = extended.next - 1;
|
|
158
|
-
} else {
|
|
159
|
-
const fg = basicColor(code, 30, 90, "fg");
|
|
160
|
-
const bg = basicColor(code, 40, 100, "bg");
|
|
161
|
-
if (fg) nextState.fg = fg;
|
|
162
|
-
if (bg) nextState.bg = bg;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return nextState;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function spanAttributes(state) {
|
|
169
|
-
const classes = [];
|
|
170
|
-
const styles = [];
|
|
171
|
-
if (state.bold) classes.push("ansi-bold");
|
|
172
|
-
if (state.dim) classes.push("ansi-dim");
|
|
173
|
-
if (state.italic) classes.push("ansi-italic");
|
|
174
|
-
if (state.underline) classes.push("ansi-underline");
|
|
175
|
-
if (state.strike) classes.push("ansi-strike");
|
|
176
|
-
const effectiveFg = state.inverse ? state.bg || DEFAULT_TERMINAL_BACKGROUND : state.fg;
|
|
177
|
-
const effectiveBg = state.inverse ? state.fg || DEFAULT_TERMINAL_FOREGROUND : state.bg;
|
|
178
|
-
for (const [value, cssProperty, classPrefix] of [
|
|
179
|
-
[effectiveFg, "color", "fg-"],
|
|
180
|
-
[effectiveBg, "background-color", "bg-"],
|
|
181
|
-
]) {
|
|
182
|
-
if (!value) continue;
|
|
183
|
-
const colorName = value.match(/^(?:fg|bg)-(.+)$/)?.[1];
|
|
184
|
-
if (colorName) classes.push(`ansi-${classPrefix}${colorName}`);
|
|
185
|
-
else styles.push(`${cssProperty}: ${value}`);
|
|
186
|
-
}
|
|
187
|
-
const attrs = [];
|
|
188
|
-
if (classes.length > 0) attrs.push(`class="${classes.join(" ")}"`);
|
|
189
|
-
if (styles.length > 0) attrs.push(`style="${styles.join("; ")}"`);
|
|
190
|
-
return attrs.join(" ");
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function renderSegment(value, state) {
|
|
194
|
-
const escaped = escapeHtml(value);
|
|
195
|
-
const attrs = spanAttributes(state);
|
|
196
|
-
return attrs ? `<span ${attrs}>${escaped}</span>` : escaped;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export function renderAnsiToHtml(value) {
|
|
200
|
-
const cleanValue = value.replace(OSC_PATTERN, "");
|
|
201
|
-
let state = createState();
|
|
202
|
-
let cursor = 0;
|
|
203
|
-
let output = "";
|
|
204
|
-
for (const match of cleanValue.matchAll(SGR_PATTERN)) {
|
|
205
|
-
const index = match.index ?? 0;
|
|
206
|
-
if (index > cursor) output += renderSegment(cleanValue.slice(cursor, index), state);
|
|
207
|
-
state = applySgr(state, match[1] ?? "");
|
|
208
|
-
cursor = index + match[0].length;
|
|
209
|
-
}
|
|
210
|
-
if (cursor < cleanValue.length) output += renderSegment(cleanValue.slice(cursor), state);
|
|
211
|
-
return output.replace(ANSI_PATTERN, "");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function ansiColorCss() {
|
|
215
|
-
return Object.entries(BASIC_ANSI_COLORS)
|
|
216
|
-
.map(([name, value]) => `.ansi-fg-${name} { color: ${value}; }\n.ansi-bg-${name} { background-color: ${value}; }`)
|
|
217
|
-
.join("\n");
|
|
218
|
-
}
|