fix: fixed prompt parsing, startup tracing, and help-command behavior

- Fixed help rendering so `--help` no longer triggers unrelated command loaders.
- Fixed startup span logging to emit markers only with PI_DEBUG_STARTUP set.
- Fixed logger startup trace behavior for `:start`, `:done`, and `:fail` phases.
- Fixed prompt template processing with cached raw-template compilation and safer formatting.
- Optimized symbol and tag parsing in prompt templates via manual parsers.
This commit is contained in:
can1357
2026-06-10 02:17:35 +02:00
parent 9615418ca9
commit f2137becb8
23 changed files with 966 additions and 138 deletions
@@ -355,6 +355,33 @@ export async function getHostInfoForHost(host: SSHConnectionTarget): Promise<SSH
return await loadHostInfoFromDisk(host);
}
/**
* Synchronous, probe-free host info lookup for startup paths.
*
* Checks the in-memory cache, then falls back to a synchronous read of the
* persisted host-info cache file. Never opens a connection or probes the
* remote host — callers get `undefined` when nothing is cached yet.
*/
export function getCachedHostInfoSync(host: SSHConnectionTarget): SSHHostInfo | undefined {
const cached = hostInfoCache.get(host.name);
if (cached) {
const resolved = applyCompatOverride(host, cached);
if (resolved !== cached) hostInfoCache.set(host.name, resolved);
return resolved;
}
try {
const parsed = parseHostInfo(JSON.parse(fs.readFileSync(getHostInfoPath(host.name), "utf-8")));
if (!parsed) return undefined;
const resolved = applyCompatOverride(host, parsed);
hostInfoCache.set(host.name, resolved);
return resolved;
} catch (err) {
if (isEnoent(err)) return undefined;
logger.warn("Failed to load SSH host info", { host: host.name, error: String(err) });
return undefined;
}
}
export async function ensureHostInfo(host: SSHConnectionTarget): Promise<SSHHostInfo> {
const cached = hostInfoCache.get(host.name);
if (cached) {