architecture-harness 0.27.1 → 0.28.0
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/package.json +1 -1
- package/src/cli/fleet-assign.mjs +12 -0
- package/src/cli/fleet-assign.test.mjs +24 -1
- package/src/cli/fleet-discover.mjs +137 -0
- package/src/cli/fleet-discover.test.mjs +213 -0
- package/src/cli/fleet-github.mjs +6 -0
- package/src/cli/fleet-github.test.mjs +17 -0
- package/src/cli/fleet-load.mjs +18 -0
- package/src/cli/fleet-load.test.mjs +13 -0
- package/src/cli/fleet-node.mjs +51 -9
- package/src/cli/fleet-node.test.mjs +111 -11
- package/src/cli/fleet.mjs +27 -12
- package/src/cli/fleet.test.mjs +77 -11
- package/src/cli/statusline.test.mjs +155 -0
- package/user-config/claude/statusline.js +47 -8
|
@@ -21,6 +21,7 @@ const NAVY = [16, 26, 58];
|
|
|
21
21
|
const GREEN = [30, 120, 60];
|
|
22
22
|
const BLUE = [30, 80, 170];
|
|
23
23
|
const AMBER = [196, 110, 0];
|
|
24
|
+
const TEAL = [25, 110, 115];
|
|
24
25
|
|
|
25
26
|
function fg(rgb) { return `\x1b[38;2;${rgb[0]};${rgb[1]};${rgb[2]}m`; }
|
|
26
27
|
function bg(rgb) { return `\x1b[48;2;${rgb[0]};${rgb[1]};${rgb[2]}m`; }
|
|
@@ -61,7 +62,7 @@ function gitInfo(dir) {
|
|
|
61
62
|
raw = execFileSync(
|
|
62
63
|
'git',
|
|
63
64
|
['-C', dir, '--no-optional-locks', 'status', '--porcelain=v2', '--branch'],
|
|
64
|
-
{ stdio: ['ignore', 'pipe', 'ignore'] }
|
|
65
|
+
{ stdio: ['ignore', 'pipe', 'ignore'], timeout: 500 }
|
|
65
66
|
).toString();
|
|
66
67
|
} catch {
|
|
67
68
|
return null; // Not a repository, or git is missing.
|
|
@@ -71,9 +72,12 @@ function gitInfo(dir) {
|
|
|
71
72
|
let ahead = 0;
|
|
72
73
|
let behind = 0;
|
|
73
74
|
let dirty = false;
|
|
75
|
+
let oid = '';
|
|
74
76
|
for (const line of raw.split('\n')) {
|
|
75
77
|
if (line.startsWith('# branch.head ')) {
|
|
76
78
|
branch = line.slice('# branch.head '.length).trim();
|
|
79
|
+
} else if (line.startsWith('# branch.oid ')) {
|
|
80
|
+
oid = line.slice('# branch.oid '.length).trim();
|
|
77
81
|
} else if (line.startsWith('# branch.ab ')) {
|
|
78
82
|
const m = line.match(/\+(\d+) -(\d+)/);
|
|
79
83
|
if (m) { ahead = Number(m[1]); behind = Number(m[2]); }
|
|
@@ -83,18 +87,52 @@ function gitInfo(dir) {
|
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
if (!branch || branch === '(detached)') {
|
|
86
|
-
|
|
87
|
-
branch = execFileSync(
|
|
88
|
-
'git',
|
|
89
|
-
['-C', dir, '--no-optional-locks', 'rev-parse', '--short', 'HEAD'],
|
|
90
|
-
{ stdio: ['ignore', 'pipe', 'ignore'] }
|
|
91
|
-
).toString().trim();
|
|
92
|
-
} catch { /* leave branch as whatever branch.head reported */ }
|
|
90
|
+
if (/^[a-f0-9]+$/.test(oid)) branch = oid.slice(0, 7);
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
return { branch, ahead, behind, dirty };
|
|
96
94
|
}
|
|
97
95
|
|
|
96
|
+
// Let git resolve symlinks, linked worktrees, and repository environment variables.
|
|
97
|
+
function gitCommonDir(dir) {
|
|
98
|
+
try {
|
|
99
|
+
const output = execFileSync(
|
|
100
|
+
'git',
|
|
101
|
+
['-C', dir, 'rev-parse', '--is-inside-work-tree', '--path-format=absolute', '--git-common-dir'],
|
|
102
|
+
{ stdio: ['ignore', 'pipe', 'ignore'], timeout: 500 }
|
|
103
|
+
).toString();
|
|
104
|
+
const separator = output.indexOf('\n');
|
|
105
|
+
const commonDir = output.slice(separator + 1).replace(/\n$/, '');
|
|
106
|
+
return separator >= 0 && output.slice(0, separator) === 'true' ? commonDir || null : null;
|
|
107
|
+
} catch { return null; }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function fleetSegment(dir) {
|
|
111
|
+
try {
|
|
112
|
+
// Keep in sync with fleetPath in the CLI; this script runs standalone.
|
|
113
|
+
const base = process.platform === 'win32' && process.env.APPDATA
|
|
114
|
+
? process.env.APPDATA : process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config');
|
|
115
|
+
const file = process.env.QC_FLEET_FILE || path.join(base, 'qc', 'fleet.json');
|
|
116
|
+
const self = JSON.parse(fs.readFileSync(file, 'utf8'))?.self;
|
|
117
|
+
if (typeof self !== 'string' || !/^[a-z0-9-]{1,32}$/.test(self)) return null;
|
|
118
|
+
let mark = '';
|
|
119
|
+
const commonDir = gitCommonDir(dir);
|
|
120
|
+
if (commonDir) {
|
|
121
|
+
mark = ' off';
|
|
122
|
+
try {
|
|
123
|
+
const node = JSON.parse(fs.readFileSync(path.join(commonDir, 'qc', 'fleet', 'node.json'), 'utf8'));
|
|
124
|
+
if (Number.isSafeInteger(node?.pid) && node.pid > 0) {
|
|
125
|
+
let alive = false;
|
|
126
|
+
try { process.kill(node.pid, 0); alive = true; }
|
|
127
|
+
catch (error) { alive = error.code === 'EPERM'; }
|
|
128
|
+
if (alive) mark = node.leader === true ? ' leader' : '';
|
|
129
|
+
}
|
|
130
|
+
} catch { /* missing or invalid node state means off */ }
|
|
131
|
+
}
|
|
132
|
+
return { text: `fleet ${self}${mark}`, color: TEAL };
|
|
133
|
+
} catch { return null; }
|
|
134
|
+
}
|
|
135
|
+
|
|
98
136
|
function gitSegmentText(info) {
|
|
99
137
|
let text = `${BRANCH_ICON} ${info.branch}`;
|
|
100
138
|
if (info.ahead > 0) text += ` ↑${info.ahead}`;
|
|
@@ -285,6 +323,7 @@ process.stdin.on('data', (d) => { raw += d; }).on('end', () => {
|
|
|
285
323
|
const line1 = [
|
|
286
324
|
{ text: tildePath(dir), color: ORANGE_BROWN },
|
|
287
325
|
git ? { text: gitSegmentText(git), color: DARK_GREY } : null,
|
|
326
|
+
fleetSegment(dir),
|
|
288
327
|
typeof ctxPct === 'number' ? { text: contextText(ctxPct, j.context_window?.context_window_size), color: SLATE } : null,
|
|
289
328
|
];
|
|
290
329
|
|