mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-18 16:13:29 +08:00
fix(ck): address Greptile + CodeRabbit review bugs
- Fix read-after-write in session-start.mjs: read prevSession BEFORE
overwriting current-session.json so unsaved-session detection fires
- Fix shell injection in resume.mjs: replace execSync shell string with
fs.existsSync for directory existence check
- Fix shell injection in shared.mjs gitSummary: replace nested \$(git ...)
subshell with a separate runGit() call to get rev count
- Fix displayName never shown: render functions now use ctx.displayName
?? ctx.name so user-supplied names show instead of the slug
- Fix renderListTable: uses context.displayName ?? entry.name
- Fix init.mjs: use path.basename() instead of cwd.split('/').pop()
- Fix save.mjs confirmation: show original name, not contextDir slug
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -165,9 +165,10 @@ export function gitSummary(projectPath, sinceDate) {
|
||||
const commits = log.split('\n').filter(Boolean).length;
|
||||
if (commits === 0) return null;
|
||||
|
||||
// Count unique files changed across those commits
|
||||
const diff = runGit(`diff --shortstat HEAD@{$(git -C "${projectPath}" rev-list --count HEAD --since="${sinceDate}")}..HEAD 2>/dev/null`, projectPath)
|
||||
|| runGit(`diff --shortstat HEAD~${Math.min(commits, 50)}..HEAD`, projectPath);
|
||||
// Count unique files changed: use a separate runGit call to avoid nested shell substitution
|
||||
const countStr = runGit(`rev-list --count HEAD --since="${sinceDate}"`, projectPath);
|
||||
const revCount = countStr ? parseInt(countStr, 10) : commits;
|
||||
const diff = runGit(`diff --shortstat HEAD~${Math.min(revCount, 50)}..HEAD`, projectPath);
|
||||
|
||||
if (diff) {
|
||||
const filesMatch = diff.match(/(\d+) file/);
|
||||
@@ -196,7 +197,7 @@ export function renderContextMd(ctx) {
|
||||
const latest = ctx.sessions?.[ctx.sessions.length - 1] || null;
|
||||
const lines = [
|
||||
`<!-- Generated by ck v2 — edit context.json instead -->`,
|
||||
`# Project: ${ctx.name}`,
|
||||
`# Project: ${ctx.displayName ?? ctx.name}`,
|
||||
`> Path: ${ctx.path}`,
|
||||
];
|
||||
if (ctx.repo) lines.push(`> Repo: ${ctx.repo}`);
|
||||
@@ -282,7 +283,7 @@ export function renderBriefingBox(ctx, meta = {}) {
|
||||
|
||||
const lines = [
|
||||
`┌${'─'.repeat(W)}┐`,
|
||||
`│ RESUMING: ${pad(ctx.name, W - 12)}│`,
|
||||
`│ RESUMING: ${pad(ctx.displayName ?? ctx.name, W - 12)}│`,
|
||||
`│ Last session: ${pad(`${when} | Sessions: ${sessions}`, W - 16)}│`,
|
||||
];
|
||||
if (shortSessId) lines.push(`│ Session ID: ${pad(shortSessId, W - 14)}│`);
|
||||
@@ -318,7 +319,7 @@ export function renderInfoBlock(ctx) {
|
||||
const latest = ctx.sessions?.[ctx.sessions.length - 1] || {};
|
||||
const sep = '─'.repeat(44);
|
||||
const lines = [
|
||||
`ck: ${ctx.name}`,
|
||||
`ck: ${ctx.displayName ?? ctx.name}`,
|
||||
sep,
|
||||
];
|
||||
lines.push(`PATH ${ctx.path}`);
|
||||
@@ -352,7 +353,7 @@ export function renderListTable(entries, cwd, todayStr) {
|
||||
const statusLabel = icon === '●' ? '● Active' : icon === '◐' ? '◐ Warm' : '○ Stale';
|
||||
const sessId = latest.id ? latest.id.slice(0, 8) : '—';
|
||||
const summary = (latest.summary || '—').slice(0, 34);
|
||||
const displayName = (e.name + (isHere ? ' <-' : '')).slice(0, 18);
|
||||
const displayName = ((e.context?.displayName ?? e.name) + (isHere ? ' <-' : '')).slice(0, 18);
|
||||
return {
|
||||
num: String(i + 1),
|
||||
name: displayName,
|
||||
|
||||
Reference in New Issue
Block a user