@fusengine/harness 0.1.1 → 0.1.3

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 (67) hide show
  1. package/dist/adapters/claude/index.d.mts +1 -35
  2. package/dist/adapters/claude/index.mjs +1 -65
  3. package/dist/adapters/cline/index.mjs +1 -24
  4. package/dist/adapters/codex/index.d.mts +2 -0
  5. package/dist/adapters/codex/index.mjs +2 -0
  6. package/dist/adapters/cursor/index.mjs +1 -36
  7. package/dist/adapters/gemini/index.mjs +1 -24
  8. package/dist/cache/index.d.mts +1 -29
  9. package/dist/cache/index.mjs +1 -109
  10. package/dist/cache-DbPSJ9bC.mjs +110 -0
  11. package/dist/claude-DbzjbxmO.mjs +66 -0
  12. package/dist/cli/bin.mjs +84 -10
  13. package/dist/cline-BxslHtBG.mjs +25 -0
  14. package/dist/config/index.d.mts +1 -36
  15. package/dist/config/index.mjs +1 -18
  16. package/dist/config-BG55s6HZ.mjs +20 -0
  17. package/dist/cursor-Bh7eh9y_.mjs +37 -0
  18. package/dist/detect/index.d.mts +1 -30
  19. package/dist/detect/index.mjs +2 -81
  20. package/dist/detect-la_KkjCS.mjs +1 -0
  21. package/dist/doc-helpers-Dd_x1-tZ.mjs +42 -0
  22. package/dist/freshness/index.d.mts +1 -12
  23. package/dist/freshness/index.mjs +2 -63
  24. package/dist/freshness-BK9Xg6oG.mjs +23 -0
  25. package/dist/gemini-SrK_fFAr.mjs +25 -0
  26. package/dist/harness-C8Nxxyn_.mjs +83 -0
  27. package/dist/harness-DwJskkz_.d.mts +31 -0
  28. package/dist/index-B-z0CCiU.d.mts +37 -0
  29. package/dist/index-B3Ve_bBu.d.mts +30 -0
  30. package/dist/index-BEM-mQMC.d.mts +30 -0
  31. package/dist/index-BKZ67WMa.d.mts +1 -0
  32. package/dist/index-BOBXQ91y.d.mts +12 -0
  33. package/dist/index-BVVgDSdq.d.mts +1 -0
  34. package/dist/index-BWK8slRi.d.mts +84 -0
  35. package/dist/index-BXBWKbL8.d.mts +114 -0
  36. package/dist/index-C1vLIMwN.d.mts +20 -0
  37. package/dist/index-C2Lz-cwJ.d.mts +21 -0
  38. package/dist/index-CPoF_hLP.d.mts +59 -0
  39. package/dist/index-FrWgmkbP.d.mts +36 -0
  40. package/dist/index.d.mts +12 -11
  41. package/dist/index.mjs +11 -12
  42. package/dist/init/index.d.mts +34 -0
  43. package/dist/init/index.mjs +2 -0
  44. package/dist/memory/index.d.mts +1 -29
  45. package/dist/memory/index.mjs +1 -93
  46. package/dist/memory-BVNt4Ary.mjs +94 -0
  47. package/dist/policy/index.d.mts +2 -80
  48. package/dist/policy/index.mjs +2 -33
  49. package/dist/policy-DMpyaPZ_.mjs +68 -0
  50. package/dist/prompt/index.mjs +1 -0
  51. package/dist/prompt-la_KkjCS.mjs +1 -0
  52. package/dist/refs/index.d.mts +2 -43
  53. package/dist/refs/index.mjs +2 -69
  54. package/dist/refs-la_KkjCS.mjs +1 -0
  55. package/dist/router-Dj3AfgBE.mjs +70 -0
  56. package/dist/run-Cc98348q.mjs +94 -0
  57. package/dist/state/index.d.mts +1 -58
  58. package/dist/state/index.mjs +1 -103
  59. package/dist/state-Bc4wdnCG.mjs +104 -0
  60. package/dist/statusline/index.d.mts +1 -83
  61. package/dist/statusline/index.mjs +1 -147
  62. package/dist/statusline-D87eUNXl.mjs +148 -0
  63. package/dist/types-CY5qT2X1.d.mts +26 -0
  64. package/dist/util/index.d.mts +1 -19
  65. package/dist/util/index.mjs +1 -0
  66. package/dist/util-la_KkjCS.mjs +1 -0
  67. package/package.json +5 -3
@@ -1,104 +1,2 @@
1
- import { n as readJsonFile, r as writeJsonFile, t as ensureDir } from "../json-io-RH82El2J.mjs";
2
- import { mkdir, rmdir } from "node:fs/promises";
3
- //#region src/state/lock.ts
4
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5
- /**
6
- * Acquire a directory-based lock (atomic `mkdir`, EEXIST = already held) with a timeout.
7
- * @returns a release function, or null if the lock could not be acquired in time.
8
- */
9
- async function acquireLock(lockDir, timeoutMs = 5e3) {
10
- const start = Date.now();
11
- while (Date.now() - start < timeoutMs) try {
12
- await mkdir(lockDir, { recursive: false });
13
- return async () => {
14
- try {
15
- await rmdir(lockDir);
16
- } catch {}
17
- };
18
- } catch {
19
- await sleep(100);
20
- }
21
- return null;
22
- }
23
- //#endregion
24
- //#region src/state/apex-state.ts
25
- const DEFAULT_STATE = {
26
- $schema: "apex-state-v1",
27
- description: "APEX/SOLID state - sessions[] + 2min expiry",
28
- target: {},
29
- authorizations: {}
30
- };
31
- /** APEX state directory under a home dir. */
32
- function apexStateDir(home = process.env.HOME ?? "") {
33
- return `${home}/.claude/logs/00-apex`;
34
- }
35
- /** Daily state file path: `<home>/.claude/logs/00-apex/<YYYY-MM-DD>-state.json`. */
36
- function stateFilePath(home = process.env.HOME ?? "", today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)) {
37
- return `${apexStateDir(home)}/${today}-state.json`;
38
- }
39
- /** Ensure the state directory exists and return its path. */
40
- async function ensureStateDir(home) {
41
- const dir = apexStateDir(home);
42
- await ensureDir(dir);
43
- return dir;
44
- }
45
- /** Load APEX state, or a fresh default. */
46
- async function loadState(path) {
47
- return await readJsonFile(path) ?? { ...DEFAULT_STATE };
48
- }
49
- /** Save APEX state. */
50
- async function saveState(path, state) {
51
- await writeJsonFile(path, state);
52
- }
53
- //#endregion
54
- //#region src/state/task-helpers.ts
55
- /** Add a new pending task. */
56
- async function taskCreate(file, id, subject, desc) {
57
- const data = await readJsonFile(file);
58
- if (!data) return;
59
- data.tasks[id] = {
60
- subject,
61
- description: desc,
62
- status: "pending",
63
- phase: "pending",
64
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
65
- doc_consulted: {},
66
- files_modified: [],
67
- blockedBy: []
68
- };
69
- await writeJsonFile(file, data);
70
- }
71
- /** Mark a task in_progress (creating a stub if absent). */
72
- async function taskStart(file, id, subject, desc, blocked) {
73
- const data = await readJsonFile(file);
74
- if (!data) return;
75
- const task = data.tasks[id] ?? {
76
- subject: "",
77
- description: "",
78
- status: "in_progress",
79
- phase: "analyze",
80
- doc_consulted: {},
81
- files_modified: []
82
- };
83
- data.tasks[id] = task;
84
- data.current_task = id;
85
- task.status = "in_progress";
86
- task.phase = "analyze";
87
- task.started_at = (/* @__PURE__ */ new Date()).toISOString();
88
- if (subject) task.subject = subject;
89
- if (desc) task.description = desc;
90
- if (blocked) task.blockedBy = blocked.split(",");
91
- await writeJsonFile(file, data);
92
- }
93
- /** Mark a task completed. */
94
- async function taskComplete(file, id) {
95
- const data = await readJsonFile(file);
96
- const task = data?.tasks[id];
97
- if (!data || !task) return;
98
- task.status = "completed";
99
- task.phase = "completed";
100
- task.completed_at = (/* @__PURE__ */ new Date()).toISOString();
101
- await writeJsonFile(file, data);
102
- }
103
- //#endregion
1
+ import { a as ensureStateDir, c as stateFilePath, i as apexStateDir, l as acquireLock, n as taskCreate, o as loadState, r as taskStart, s as saveState, t as taskComplete } from "../state-Bc4wdnCG.mjs";
104
2
  export { acquireLock, apexStateDir, ensureStateDir, loadState, saveState, stateFilePath, taskComplete, taskCreate, taskStart };
@@ -0,0 +1,104 @@
1
+ import { n as readJsonFile, r as writeJsonFile, t as ensureDir } from "./json-io-RH82El2J.mjs";
2
+ import { mkdir, rmdir } from "node:fs/promises";
3
+ //#region src/state/lock.ts
4
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5
+ /**
6
+ * Acquire a directory-based lock (atomic `mkdir`, EEXIST = already held) with a timeout.
7
+ * @returns a release function, or null if the lock could not be acquired in time.
8
+ */
9
+ async function acquireLock(lockDir, timeoutMs = 5e3) {
10
+ const start = Date.now();
11
+ while (Date.now() - start < timeoutMs) try {
12
+ await mkdir(lockDir, { recursive: false });
13
+ return async () => {
14
+ try {
15
+ await rmdir(lockDir);
16
+ } catch {}
17
+ };
18
+ } catch {
19
+ await sleep(100);
20
+ }
21
+ return null;
22
+ }
23
+ //#endregion
24
+ //#region src/state/apex-state.ts
25
+ const DEFAULT_STATE = {
26
+ $schema: "apex-state-v1",
27
+ description: "APEX/SOLID state - sessions[] + 2min expiry",
28
+ target: {},
29
+ authorizations: {}
30
+ };
31
+ /** APEX state directory under a home dir. */
32
+ function apexStateDir(home = process.env.HOME ?? "") {
33
+ return `${home}/.claude/logs/00-apex`;
34
+ }
35
+ /** Daily state file path: `<home>/.claude/logs/00-apex/<YYYY-MM-DD>-state.json`. */
36
+ function stateFilePath(home = process.env.HOME ?? "", today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)) {
37
+ return `${apexStateDir(home)}/${today}-state.json`;
38
+ }
39
+ /** Ensure the state directory exists and return its path. */
40
+ async function ensureStateDir(home) {
41
+ const dir = apexStateDir(home);
42
+ await ensureDir(dir);
43
+ return dir;
44
+ }
45
+ /** Load APEX state, or a fresh default. */
46
+ async function loadState(path) {
47
+ return await readJsonFile(path) ?? { ...DEFAULT_STATE };
48
+ }
49
+ /** Save APEX state. */
50
+ async function saveState(path, state) {
51
+ await writeJsonFile(path, state);
52
+ }
53
+ //#endregion
54
+ //#region src/state/task-helpers.ts
55
+ /** Add a new pending task. */
56
+ async function taskCreate(file, id, subject, desc) {
57
+ const data = await readJsonFile(file);
58
+ if (!data) return;
59
+ data.tasks[id] = {
60
+ subject,
61
+ description: desc,
62
+ status: "pending",
63
+ phase: "pending",
64
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
65
+ doc_consulted: {},
66
+ files_modified: [],
67
+ blockedBy: []
68
+ };
69
+ await writeJsonFile(file, data);
70
+ }
71
+ /** Mark a task in_progress (creating a stub if absent). */
72
+ async function taskStart(file, id, subject, desc, blocked) {
73
+ const data = await readJsonFile(file);
74
+ if (!data) return;
75
+ const task = data.tasks[id] ?? {
76
+ subject: "",
77
+ description: "",
78
+ status: "in_progress",
79
+ phase: "analyze",
80
+ doc_consulted: {},
81
+ files_modified: []
82
+ };
83
+ data.tasks[id] = task;
84
+ data.current_task = id;
85
+ task.status = "in_progress";
86
+ task.phase = "analyze";
87
+ task.started_at = (/* @__PURE__ */ new Date()).toISOString();
88
+ if (subject) task.subject = subject;
89
+ if (desc) task.description = desc;
90
+ if (blocked) task.blockedBy = blocked.split(",");
91
+ await writeJsonFile(file, data);
92
+ }
93
+ /** Mark a task completed. */
94
+ async function taskComplete(file, id) {
95
+ const data = await readJsonFile(file);
96
+ const task = data?.tasks[id];
97
+ if (!data || !task) return;
98
+ task.status = "completed";
99
+ task.phase = "completed";
100
+ task.completed_at = (/* @__PURE__ */ new Date()).toISOString();
101
+ await writeJsonFile(file, data);
102
+ }
103
+ //#endregion
104
+ export { ensureStateDir as a, stateFilePath as c, apexStateDir as i, acquireLock as l, taskCreate as n, loadState as o, taskStart as r, saveState as s, taskComplete as t };
@@ -1,84 +1,2 @@
1
- //#region src/statusline/constants.d.ts
2
- /** Time interval constants (ms). */
3
- declare const TIME_INTERVALS: {
4
- readonly MINUTE_MS: 60_000;
5
- readonly HOUR_MS: 3_600_000;
6
- };
7
- /** Percentage thresholds for progressive coloring. */
8
- declare const COLOR_THRESHOLDS: {
9
- readonly WARNING: 70;
10
- readonly CRITICAL: 90;
11
- };
12
- /** Fill/empty glyphs per progress-bar style. */
13
- declare const PROGRESS_CHARS: {
14
- readonly blocks: {
15
- readonly fill: "█";
16
- readonly empty: "░";
17
- };
18
- readonly bars: {
19
- readonly fill: "▰";
20
- readonly empty: "▱";
21
- };
22
- };
23
- /** Defaults for {@link generateProgressBar}. */
24
- declare const PROGRESS_BAR_DEFAULTS: {
25
- readonly STYLE: "blocks";
26
- readonly LENGTH: 10;
27
- };
28
- /** 9 gradient blocks from empty to full. */
29
- declare const GRADIENT_BLOCKS: readonly [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"];
30
- //#endregion
31
- //#region src/statusline/colors.d.ts
32
- /** A text-decorating function. */
33
- type ColorFn = (text: string) => string;
34
- /** Forced ANSI palette (every entry is a colorizer, plus reset + support flag). */
35
- interface Palette {
36
- blue: ColorFn;
37
- cyan: ColorFn;
38
- green: ColorFn;
39
- yellow: ColorFn;
40
- red: ColorFn;
41
- magenta: ColorFn;
42
- white: ColorFn;
43
- gray: ColorFn;
44
- purple: ColorFn;
45
- orange: ColorFn;
46
- brightRed: ColorFn;
47
- brightYellow: ColorFn;
48
- brightGreen: ColorFn;
49
- bold: ColorFn;
50
- dim: ColorFn;
51
- reset: string;
52
- isSupported: boolean;
53
- }
54
- /** Forced ANSI color helpers (ignore TTY detection). */
55
- declare const colors: Palette;
56
- /** Color `text` by threshold: green < WARNING <= yellow < CRITICAL <= red. */
57
- declare function progressiveColor(value: number, text: string): string;
58
- //#endregion
59
- //#region src/statusline/formatters.d.ts
60
- /** Format a path: truncated (default), full, relative (~), or basename. */
61
- declare function formatPath(path: string, style?: "truncated" | "full" | "relative" | "basename"): string;
62
- /** Basename of a path. */
63
- declare function formatBasename(path: string): string;
64
- /** Humanize a remaining duration in ms (e.g. "2h - 5m"). */
65
- declare function formatTimeLeft(ms: number): string;
66
- /** Format a token count as "12K" (or "12.3K" with decimals). */
67
- declare function formatTokens(tokens: number, showDecimals?: boolean): string;
68
- /** Format a cost as "$1.23". */
69
- declare function formatCost(cost: number, decimals?: number): string;
70
- //#endregion
71
- //#region src/statusline/progress-bar.d.ts
72
- /** Options for {@link generateProgressBar}. */
73
- interface ProgressBarOptions {
74
- style?: keyof typeof PROGRESS_CHARS;
75
- length?: number;
76
- useProgressiveColor?: boolean;
77
- showPercentage?: boolean;
78
- }
79
- /** Render a fill/empty progress bar. */
80
- declare function generateProgressBar(percentage: number, options?: ProgressBarOptions): string;
81
- /** Render a fine-grained gradient bar (sub-block resolution). */
82
- declare function generateGradientBar(percentage: number, length?: number): string;
83
- //#endregion
1
+ import { _ as TIME_INTERVALS, a as formatCost, c as formatTokens, d as colors, f as progressiveColor, g as PROGRESS_CHARS, h as PROGRESS_BAR_DEFAULTS, i as formatBasename, l as ColorFn, m as GRADIENT_BLOCKS, n as generateGradientBar, o as formatPath, p as COLOR_THRESHOLDS, r as generateProgressBar, s as formatTimeLeft, t as ProgressBarOptions, u as Palette } from "../index-BWK8slRi.mjs";
84
2
  export { COLOR_THRESHOLDS, ColorFn, GRADIENT_BLOCKS, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, Palette, ProgressBarOptions, TIME_INTERVALS, colors, formatBasename, formatCost, formatPath, formatTimeLeft, formatTokens, generateGradientBar, generateProgressBar, progressiveColor };
@@ -1,148 +1,2 @@
1
- import { basename } from "node:path";
2
- //#region src/statusline/constants.ts
3
- /** Time interval constants (ms). */
4
- const TIME_INTERVALS = {
5
- MINUTE_MS: 6e4,
6
- HOUR_MS: 36e5
7
- };
8
- /** Percentage thresholds for progressive coloring. */
9
- const COLOR_THRESHOLDS = {
10
- WARNING: 70,
11
- CRITICAL: 90
12
- };
13
- /** Fill/empty glyphs per progress-bar style. */
14
- const PROGRESS_CHARS = {
15
- blocks: {
16
- fill: "█",
17
- empty: "░"
18
- },
19
- bars: {
20
- fill: "▰",
21
- empty: "▱"
22
- }
23
- };
24
- /** Defaults for {@link generateProgressBar}. */
25
- const PROGRESS_BAR_DEFAULTS = {
26
- STYLE: "blocks",
27
- LENGTH: 10
28
- };
29
- /** 9 gradient blocks from empty to full. */
30
- const GRADIENT_BLOCKS = [
31
- " ",
32
- "▏",
33
- "▎",
34
- "▍",
35
- "▌",
36
- "▋",
37
- "▊",
38
- "▉",
39
- "█"
40
- ];
41
- //#endregion
42
- //#region src/statusline/colors.ts
43
- const ansi = (code) => (text) => `\x1b[${code}m${text}\x1b[0m`;
44
- const ansi256 = (code) => (text) => `\x1b[38;5;${code}m${text}\x1b[0m`;
45
- /** Forced ANSI color helpers (ignore TTY detection). */
46
- const colors = {
47
- blue: ansi("0;34"),
48
- cyan: ansi("0;36"),
49
- green: ansi("0;32"),
50
- yellow: ansi("0;33"),
51
- red: ansi("0;31"),
52
- magenta: ansi("0;35"),
53
- white: ansi("0;37"),
54
- gray: ansi256(240),
55
- purple: ansi256(135),
56
- orange: ansi256(208),
57
- brightRed: ansi("1;91"),
58
- brightYellow: ansi("1;93"),
59
- brightGreen: ansi("1;92"),
60
- bold: ansi("1"),
61
- dim: ansi("2"),
62
- reset: "\x1B[0m",
63
- isSupported: true
64
- };
65
- /** Color `text` by threshold: green < WARNING <= yellow < CRITICAL <= red. */
66
- function progressiveColor(value, text) {
67
- if (value >= COLOR_THRESHOLDS.CRITICAL) return colors.brightRed(text);
68
- if (value >= COLOR_THRESHOLDS.WARNING) return colors.brightYellow(text);
69
- return colors.green(text);
70
- }
71
- //#endregion
72
- //#region src/statusline/formatters.ts
73
- /** Format a path: truncated (default), full, relative (~), or basename. */
74
- function formatPath(path, style = "truncated") {
75
- const home = process.env.HOME || "";
76
- const isUnderHome = home !== "" && path.startsWith(home);
77
- const withTilde = isUnderHome ? path.replace(home, "~") : path;
78
- const parts = withTilde.split("/").filter(Boolean);
79
- const name = parts[parts.length - 1] || withTilde;
80
- switch (style) {
81
- case "full": return path;
82
- case "basename": return name;
83
- case "relative": return withTilde;
84
- default:
85
- if (isUnderHome && parts.length > 2) return `~/../${name}`;
86
- if (isUnderHome) return withTilde;
87
- if (parts.length > 3) return `/../${name}`;
88
- return withTilde;
89
- }
90
- }
91
- /** Basename of a path. */
92
- function formatBasename(path) {
93
- return basename(path);
94
- }
95
- /** Humanize a remaining duration in ms (e.g. "2h - 5m"). */
96
- function formatTimeLeft(ms) {
97
- if (ms <= 0) return "0m";
98
- const dayMs = TIME_INTERVALS.HOUR_MS * 24;
99
- const days = Math.floor(ms / dayMs);
100
- const hours = Math.floor(ms % dayMs / TIME_INTERVALS.HOUR_MS);
101
- const minutes = Math.floor(ms % TIME_INTERVALS.HOUR_MS / TIME_INTERVALS.MINUTE_MS);
102
- if (days > 0 && hours > 0) return `${days}d - ${hours}h`;
103
- if (days > 0) return `${days}d`;
104
- if (hours > 0 && minutes > 0) return `${hours}h - ${minutes}m`;
105
- if (hours > 0) return `${hours}h`;
106
- return `${minutes}m`;
107
- }
108
- /** Format a token count as "12K" (or "12.3K" with decimals). */
109
- function formatTokens(tokens, showDecimals = false) {
110
- const k = tokens / 1e3;
111
- return showDecimals ? `${k.toFixed(1)}K` : `${Math.round(k)}K`;
112
- }
113
- /** Format a cost as "$1.23". */
114
- function formatCost(cost, decimals = 2) {
115
- return `$${cost.toFixed(decimals)}`;
116
- }
117
- //#endregion
118
- //#region src/statusline/progress-bar.ts
119
- const clampPct = (p) => Math.max(0, Math.min(100, Number.isNaN(p) ? 0 : p));
120
- /** Render a fill/empty progress bar. */
121
- function generateProgressBar(percentage, options = {}) {
122
- const { style = PROGRESS_BAR_DEFAULTS.STYLE, length = PROGRESS_BAR_DEFAULTS.LENGTH, useProgressiveColor = false, showPercentage = false } = options;
123
- const pct = clampPct(percentage);
124
- const filled = Math.round(pct / 100 * length);
125
- const empty = Math.max(0, length - filled);
126
- const chars = PROGRESS_CHARS[style];
127
- let bar = chars.fill.repeat(filled) + chars.empty.repeat(empty);
128
- if (useProgressiveColor) bar = progressiveColor(pct, bar);
129
- if (showPercentage) {
130
- const pctText = `${Math.round(pct)}%`;
131
- bar += ` ${useProgressiveColor ? progressiveColor(pct, pctText) : pctText}`;
132
- }
133
- return bar;
134
- }
135
- /** Render a fine-grained gradient bar (sub-block resolution). */
136
- function generateGradientBar(percentage, length = 10) {
137
- const pct = clampPct(percentage);
138
- const exact = pct / 100 * length;
139
- const full = Math.floor(exact);
140
- const remainder = exact - full;
141
- let bar = GRADIENT_BLOCKS[8].repeat(full);
142
- if (full < length && remainder > 0) bar += GRADIENT_BLOCKS[Math.floor(remainder * 8)] ?? "";
143
- const remaining = length - bar.length;
144
- if (remaining > 0) bar += " ".repeat(remaining);
145
- return progressiveColor(pct, bar);
146
- }
147
- //#endregion
1
+ import { a as formatPath, c as colors, d as GRADIENT_BLOCKS, f as PROGRESS_BAR_DEFAULTS, i as formatCost, l as progressiveColor, m as TIME_INTERVALS, n as generateProgressBar, o as formatTimeLeft, p as PROGRESS_CHARS, r as formatBasename, s as formatTokens, t as generateGradientBar, u as COLOR_THRESHOLDS } from "../statusline-D87eUNXl.mjs";
148
2
  export { COLOR_THRESHOLDS, GRADIENT_BLOCKS, PROGRESS_BAR_DEFAULTS, PROGRESS_CHARS, TIME_INTERVALS, colors, formatBasename, formatCost, formatPath, formatTimeLeft, formatTokens, generateGradientBar, generateProgressBar, progressiveColor };
@@ -0,0 +1,148 @@
1
+ import { basename } from "node:path";
2
+ //#region src/statusline/constants.ts
3
+ /** Time interval constants (ms). */
4
+ const TIME_INTERVALS = {
5
+ MINUTE_MS: 6e4,
6
+ HOUR_MS: 36e5
7
+ };
8
+ /** Percentage thresholds for progressive coloring. */
9
+ const COLOR_THRESHOLDS = {
10
+ WARNING: 70,
11
+ CRITICAL: 90
12
+ };
13
+ /** Fill/empty glyphs per progress-bar style. */
14
+ const PROGRESS_CHARS = {
15
+ blocks: {
16
+ fill: "█",
17
+ empty: "░"
18
+ },
19
+ bars: {
20
+ fill: "▰",
21
+ empty: "▱"
22
+ }
23
+ };
24
+ /** Defaults for {@link generateProgressBar}. */
25
+ const PROGRESS_BAR_DEFAULTS = {
26
+ STYLE: "blocks",
27
+ LENGTH: 10
28
+ };
29
+ /** 9 gradient blocks from empty to full. */
30
+ const GRADIENT_BLOCKS = [
31
+ " ",
32
+ "▏",
33
+ "▎",
34
+ "▍",
35
+ "▌",
36
+ "▋",
37
+ "▊",
38
+ "▉",
39
+ "█"
40
+ ];
41
+ //#endregion
42
+ //#region src/statusline/colors.ts
43
+ const ansi = (code) => (text) => `\x1b[${code}m${text}\x1b[0m`;
44
+ const ansi256 = (code) => (text) => `\x1b[38;5;${code}m${text}\x1b[0m`;
45
+ /** Forced ANSI color helpers (ignore TTY detection). */
46
+ const colors = {
47
+ blue: ansi("0;34"),
48
+ cyan: ansi("0;36"),
49
+ green: ansi("0;32"),
50
+ yellow: ansi("0;33"),
51
+ red: ansi("0;31"),
52
+ magenta: ansi("0;35"),
53
+ white: ansi("0;37"),
54
+ gray: ansi256(240),
55
+ purple: ansi256(135),
56
+ orange: ansi256(208),
57
+ brightRed: ansi("1;91"),
58
+ brightYellow: ansi("1;93"),
59
+ brightGreen: ansi("1;92"),
60
+ bold: ansi("1"),
61
+ dim: ansi("2"),
62
+ reset: "\x1B[0m",
63
+ isSupported: true
64
+ };
65
+ /** Color `text` by threshold: green < WARNING <= yellow < CRITICAL <= red. */
66
+ function progressiveColor(value, text) {
67
+ if (value >= COLOR_THRESHOLDS.CRITICAL) return colors.brightRed(text);
68
+ if (value >= COLOR_THRESHOLDS.WARNING) return colors.brightYellow(text);
69
+ return colors.green(text);
70
+ }
71
+ //#endregion
72
+ //#region src/statusline/formatters.ts
73
+ /** Format a path: truncated (default), full, relative (~), or basename. */
74
+ function formatPath(path, style = "truncated") {
75
+ const home = process.env.HOME || "";
76
+ const isUnderHome = home !== "" && path.startsWith(home);
77
+ const withTilde = isUnderHome ? path.replace(home, "~") : path;
78
+ const parts = withTilde.split("/").filter(Boolean);
79
+ const name = parts[parts.length - 1] || withTilde;
80
+ switch (style) {
81
+ case "full": return path;
82
+ case "basename": return name;
83
+ case "relative": return withTilde;
84
+ default:
85
+ if (isUnderHome && parts.length > 2) return `~/../${name}`;
86
+ if (isUnderHome) return withTilde;
87
+ if (parts.length > 3) return `/../${name}`;
88
+ return withTilde;
89
+ }
90
+ }
91
+ /** Basename of a path. */
92
+ function formatBasename(path) {
93
+ return basename(path);
94
+ }
95
+ /** Humanize a remaining duration in ms (e.g. "2h - 5m"). */
96
+ function formatTimeLeft(ms) {
97
+ if (ms <= 0) return "0m";
98
+ const dayMs = TIME_INTERVALS.HOUR_MS * 24;
99
+ const days = Math.floor(ms / dayMs);
100
+ const hours = Math.floor(ms % dayMs / TIME_INTERVALS.HOUR_MS);
101
+ const minutes = Math.floor(ms % TIME_INTERVALS.HOUR_MS / TIME_INTERVALS.MINUTE_MS);
102
+ if (days > 0 && hours > 0) return `${days}d - ${hours}h`;
103
+ if (days > 0) return `${days}d`;
104
+ if (hours > 0 && minutes > 0) return `${hours}h - ${minutes}m`;
105
+ if (hours > 0) return `${hours}h`;
106
+ return `${minutes}m`;
107
+ }
108
+ /** Format a token count as "12K" (or "12.3K" with decimals). */
109
+ function formatTokens(tokens, showDecimals = false) {
110
+ const k = tokens / 1e3;
111
+ return showDecimals ? `${k.toFixed(1)}K` : `${Math.round(k)}K`;
112
+ }
113
+ /** Format a cost as "$1.23". */
114
+ function formatCost(cost, decimals = 2) {
115
+ return `$${cost.toFixed(decimals)}`;
116
+ }
117
+ //#endregion
118
+ //#region src/statusline/progress-bar.ts
119
+ const clampPct = (p) => Math.max(0, Math.min(100, Number.isNaN(p) ? 0 : p));
120
+ /** Render a fill/empty progress bar. */
121
+ function generateProgressBar(percentage, options = {}) {
122
+ const { style = PROGRESS_BAR_DEFAULTS.STYLE, length = PROGRESS_BAR_DEFAULTS.LENGTH, useProgressiveColor = false, showPercentage = false } = options;
123
+ const pct = clampPct(percentage);
124
+ const filled = Math.round(pct / 100 * length);
125
+ const empty = Math.max(0, length - filled);
126
+ const chars = PROGRESS_CHARS[style];
127
+ let bar = chars.fill.repeat(filled) + chars.empty.repeat(empty);
128
+ if (useProgressiveColor) bar = progressiveColor(pct, bar);
129
+ if (showPercentage) {
130
+ const pctText = `${Math.round(pct)}%`;
131
+ bar += ` ${useProgressiveColor ? progressiveColor(pct, pctText) : pctText}`;
132
+ }
133
+ return bar;
134
+ }
135
+ /** Render a fine-grained gradient bar (sub-block resolution). */
136
+ function generateGradientBar(percentage, length = 10) {
137
+ const pct = clampPct(percentage);
138
+ const exact = pct / 100 * length;
139
+ const full = Math.floor(exact);
140
+ const remainder = exact - full;
141
+ let bar = GRADIENT_BLOCKS[8].repeat(full);
142
+ if (full < length && remainder > 0) bar += GRADIENT_BLOCKS[Math.floor(remainder * 8)] ?? "";
143
+ const remaining = length - bar.length;
144
+ if (remaining > 0) bar += " ".repeat(remaining);
145
+ return progressiveColor(pct, bar);
146
+ }
147
+ //#endregion
148
+ export { formatPath as a, colors as c, GRADIENT_BLOCKS as d, PROGRESS_BAR_DEFAULTS as f, formatCost as i, progressiveColor as l, TIME_INTERVALS as m, generateProgressBar as n, formatTimeLeft as o, PROGRESS_CHARS as p, formatBasename as r, formatTokens as s, generateGradientBar as t, COLOR_THRESHOLDS as u };
@@ -0,0 +1,26 @@
1
+ //#region src/refs/types.d.ts
2
+ /** Parsed frontmatter metadata from a reference .md file. */
3
+ interface RefMeta {
4
+ name: string;
5
+ description: string;
6
+ keywords: string;
7
+ priority: string;
8
+ related: string;
9
+ appliesTo: string;
10
+ triggerOnEdit: string;
11
+ level: string;
12
+ filePath: string;
13
+ }
14
+ /** A reference with its computed routing score. */
15
+ interface ScoredRef {
16
+ meta: RefMeta;
17
+ score: number;
18
+ }
19
+ /** Routing result with categorized references. */
20
+ interface RouteResult {
21
+ required: ScoredRef[];
22
+ optional: ScoredRef[];
23
+ skillPath: string;
24
+ }
25
+ //#endregion
26
+ export { RouteResult as n, ScoredRef as r, RefMeta as t };
@@ -1,20 +1,2 @@
1
- //#region src/util/compact-json.d.ts
2
- /**
3
- * Compact JSON serializer for cache/state files.
4
- * Top-level keys are indented one per line; nested objects/arrays render inline.
5
- * Behaviour preserved from the fusengine hooks.
6
- */
7
- declare function compactJson(data: unknown): string;
8
- //#endregion
9
- //#region src/util/project-root.d.ts
10
- /** True for a source-code file outside generated/vendored directories. */
11
- declare function isCodeFile(p: string): boolean;
12
- /**
13
- * Resolve the project root, preferring the repo boundary (`.git`) over a
14
- * nested `package.json` — avoids false roots in monorepos. Null if none found.
15
- */
16
- declare function projectRootOrNull(dir: string): string | null;
17
- /** Like {@link projectRootOrNull} but falls back to `process.cwd()`. */
18
- declare function projectRoot(dir: string): string;
19
- //#endregion
1
+ import { i as compactJson, n as projectRoot, r as projectRootOrNull, t as isCodeFile } from "../index-C1vLIMwN.mjs";
20
2
  export { compactJson, isCodeFile, projectRoot, projectRootOrNull };
@@ -1,3 +1,4 @@
1
1
  import { t as compactJson } from "../compact-json-DK2nX-MK.mjs";
2
2
  import { n as projectRoot, r as projectRootOrNull, t as isCodeFile } from "../project-root-C4ks_q1G.mjs";
3
+ import "../util-la_KkjCS.mjs";
3
4
  export { compactJson, isCodeFile, projectRoot, projectRootOrNull };
@@ -0,0 +1 @@
1
+ export {};