cc-dev-template 0.1.2 → 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.
- package/package.json +1 -1
- package/src/scripts/statusline.js +32 -38
package/package.json
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Custom Status Line for Claude Code
|
|
5
5
|
*
|
|
6
|
-
* Displays project status in lines:
|
|
7
|
-
* - Directory name
|
|
8
|
-
* -
|
|
6
|
+
* Displays project status in 3 lines:
|
|
7
|
+
* - Line 0: Directory name
|
|
8
|
+
* - Line 1: Git branch + status
|
|
9
|
+
* - Line 2: Context window usage bar with percentage and tokens
|
|
9
10
|
*
|
|
10
11
|
* Input: JSON on stdin with transcript_path
|
|
11
12
|
* Output: Formatted status to stdout
|
|
@@ -302,58 +303,51 @@ function main() {
|
|
|
302
303
|
const labelWidth = modelName.length + 2; // +2 for brackets
|
|
303
304
|
const topBorder = `${DIM_GREY}╔═[${modelName}]${'═'.repeat(width - labelWidth + 1)}╗${RESET}`;
|
|
304
305
|
|
|
305
|
-
// Line 0: Directory
|
|
306
|
+
// Line 0: Directory only (padded to width)
|
|
306
307
|
const rawDirName = basename(data.workspace.project_dir).toUpperCase();
|
|
307
|
-
|
|
308
|
+
const maxDirLen = width - 5; // "DIR: " = 5 chars
|
|
309
|
+
const dirName =
|
|
310
|
+
rawDirName.length > maxDirLen ? rawDirName.substring(0, maxDirLen - 3) + '...' : rawDirName;
|
|
311
|
+
const line0Content = `DIR: ${dirName}`;
|
|
308
312
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const gitStatusSpace = gitStatusStr ? ` ${gitStatusStr}` : '';
|
|
313
|
+
const plainLine0 = line0Content.replace(/\x1b\[[0-9;]*m/g, '');
|
|
314
|
+
const padding0 = width - plainLine0.length;
|
|
315
|
+
const paddedLine0 = line0Content + ' '.repeat(Math.max(0, padding0));
|
|
316
|
+
const line0 = `${DIM_GREY}║ ${paddedLine0} ║${RESET}`;
|
|
314
317
|
|
|
315
|
-
|
|
318
|
+
// Line 1: Branch + git status (padded to width)
|
|
319
|
+
let line1Content = '';
|
|
320
|
+
if (gitBranch) {
|
|
321
|
+
const branchPrefix = 'BRANCH: ';
|
|
316
322
|
const branchSuffix = ' ⎇';
|
|
317
|
-
const
|
|
318
|
-
dirPrefix.length + separator.length + branchSuffix.length + gitStatusSpace.length;
|
|
319
|
-
const availableSpace = width - reservedSpace;
|
|
320
|
-
|
|
321
|
-
// Split available space between directory and branch (favor branch slightly)
|
|
322
|
-
const maxDirLen = Math.floor(availableSpace * 0.4);
|
|
323
|
-
const maxBranchLen = availableSpace - maxDirLen;
|
|
324
|
-
|
|
325
|
-
const dirName =
|
|
326
|
-
rawDirName.length > maxDirLen ? rawDirName.substring(0, maxDirLen - 3) + '...' : rawDirName;
|
|
323
|
+
const gitStatusSpace = gitStatusStr ? ` ${gitStatusStr}` : '';
|
|
327
324
|
|
|
325
|
+
const availableSpace = width - branchPrefix.length - branchSuffix.length - gitStatusSpace.length;
|
|
328
326
|
const displayBranch =
|
|
329
|
-
gitBranch.length >
|
|
330
|
-
? gitBranch.substring(0,
|
|
327
|
+
gitBranch.length > availableSpace
|
|
328
|
+
? gitBranch.substring(0, availableSpace - 3) + '...'
|
|
331
329
|
: gitBranch;
|
|
332
330
|
|
|
333
|
-
|
|
331
|
+
line1Content = `${branchPrefix}${displayBranch.toUpperCase()}${branchSuffix}${gitStatusSpace}`;
|
|
334
332
|
} else {
|
|
335
|
-
|
|
336
|
-
const maxDirLen = 20;
|
|
337
|
-
const dirName =
|
|
338
|
-
rawDirName.length > maxDirLen ? rawDirName.substring(0, maxDirLen - 3) + '...' : rawDirName;
|
|
339
|
-
line0Content = `DIR: ${dirName}`;
|
|
333
|
+
line1Content = 'BRANCH: (none)';
|
|
340
334
|
}
|
|
341
335
|
|
|
342
|
-
const
|
|
343
|
-
const
|
|
344
|
-
const
|
|
345
|
-
const
|
|
336
|
+
const plainLine1 = line1Content.replace(/\x1b\[[0-9;]*m/g, '');
|
|
337
|
+
const padding1 = width - plainLine1.length;
|
|
338
|
+
const paddedLine1 = line1Content + ' '.repeat(Math.max(0, padding1));
|
|
339
|
+
const line1 = `${DIM_GREY}║ ${paddedLine1} ║${RESET}`;
|
|
346
340
|
|
|
347
|
-
// Line
|
|
341
|
+
// Line 2: Context bar (padded to width)
|
|
348
342
|
const plainCtx = ctxDisplay.replace(/\x1b\[[0-9;]*m/g, '');
|
|
349
|
-
const
|
|
350
|
-
const paddedCtx = ctxDisplay + ' '.repeat(Math.max(0,
|
|
351
|
-
const
|
|
343
|
+
const padding2 = width - plainCtx.length;
|
|
344
|
+
const paddedCtx = ctxDisplay + ' '.repeat(Math.max(0, padding2));
|
|
345
|
+
const line2 = `${DIM_GREY}║ ${paddedCtx} ║${RESET}`;
|
|
352
346
|
|
|
353
347
|
// Bottom border (add 2 to match content line width)
|
|
354
348
|
const bottomBorder = `${DIM_GREY}╚${'═'.repeat(width + 2)}╝${RESET}`;
|
|
355
349
|
|
|
356
|
-
console.log(`${topBorder}\n${line0}\n${line1}\n${bottomBorder}`);
|
|
350
|
+
console.log(`${topBorder}\n${line0}\n${line1}\n${line2}\n${bottomBorder}`);
|
|
357
351
|
} catch (error) {
|
|
358
352
|
// Log error for debugging (goes to stderr, not visible in status line)
|
|
359
353
|
console.error(`Status line error: ${error.message}`);
|