All hardcoded 'clawdie' references in production code now derive from AGENT_NAME (default: 'clawdie'). This makes the mevy canary strategy reliable — changing AGENT_NAME is all that's needed. Changes: - Hardcoded paths: CMS_WEBROOT, ASTRO_SITE_PATH, verify checks, controlplane dashboard dir, sessions dir, output dir, chown user - Prometheus metrics: prefixed with AGENT_NAME for multi-install dashboards - hostd log strings: use AGENT_NAME instead of 'clawdie-hostd' - MCP server name: derived from AGENT_NAME - Skill modify patches: container image and mount allowlist use AGENT_NAME - SQL migration file renamed: clawdie-brain-hybrid-upgrade → brain-hybrid-upgrade - Temp dir prefixes: all use AGENT_NAME Kept as-is (correct pattern): - 'clawdie' as default fallback when AGENT_NAME is unset - .pi/extensions/clawdie-harness/ directory (pi package identity) - html/docs-clawdie-si/ (public docs site URL) --- Build: pass | Tests: pass — 1527 passed, 3 failed (2 files, pre-existing)
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import os from 'os';
|
|
|
|
const agentId = process.argv[2] ?? '';
|
|
const agentName = (process.env.AGENT_NAME || 'clawdie').toLowerCase();
|
|
const SESSIONS_DIR = path.join(os.homedir(), '.config', agentName, 'sessions');
|
|
|
|
function findSessionFiles(): string[] {
|
|
if (!fs.existsSync(SESSIONS_DIR)) return [];
|
|
const files: string[] = [];
|
|
for (const entry of fs.readdirSync(SESSIONS_DIR, { withFileTypes: true })) {
|
|
if (entry.name.endsWith('.jsonl')) {
|
|
files.push(path.join(SESSIONS_DIR, entry.name));
|
|
}
|
|
}
|
|
return files.sort().reverse();
|
|
}
|
|
|
|
function tailFile(filePath: string, n: number): string[] {
|
|
const content = fs.readFileSync(filePath, 'utf-8');
|
|
const lines = content.split('\n').filter(Boolean);
|
|
return lines.slice(-n);
|
|
}
|
|
|
|
const files = findSessionFiles();
|
|
|
|
if (files.length === 0) {
|
|
console.log('No session logs found.');
|
|
process.exit(0);
|
|
}
|
|
|
|
const filtered = agentId
|
|
? files.filter((f) => path.basename(f).includes(agentId))
|
|
: files;
|
|
|
|
if (filtered.length === 0) {
|
|
console.log(`No sessions matching: ${agentId}`);
|
|
process.exit(0);
|
|
}
|
|
|
|
for (const file of filtered.slice(0, 5)) {
|
|
const name = path.basename(file);
|
|
console.log(`\n=== ${name} ===`);
|
|
const lines = tailFile(file, 10);
|
|
for (const line of lines) {
|
|
try {
|
|
const entry = JSON.parse(line) as Record<string, unknown>;
|
|
const role = entry.role ?? '?';
|
|
const content =
|
|
typeof entry.content === 'string'
|
|
? entry.content.slice(0, 120)
|
|
: JSON.stringify(entry.content).slice(0, 120);
|
|
console.log(` [${role}] ${content}`);
|
|
} catch {
|
|
console.log(` ${line.slice(0, 120)}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log(`\n${filtered.length} session(s) found`);
|