Implementation:20000419 Fauxnix tryClaudeCodeAdapter
| Knowledge Sources |
|
|---|---|
| Domains | Adapter, Harness_Scaffolding, Agent_Integration |
| Last Updated | 2026-10-26 00:00 GMT |
Overview
Concrete adapter that detects Claude Code's private Bash-tool scaffolding (export prefix, shopt -u extglob, eval 'PAYLOAD' < /dev/null, pwd -P >| marker), applies the prefix, executes the payload, and writes the cwd marker itself — or falls through to plain translation when the pattern does not match.
Description
The tryClaudeCodeAdapter function (src/facade.ts) inspects the raw -c script for Claude Code's harness scaffolding, captured from a live session (2026-10-05). Two patterns:
- CC_SNAPSHOT_RE: a shell-snapshot bootstrap ending at RIPGREP_FUNC_END. When matched, the adapter writes a stub snapshot file (the facade session holds shell state, not a snapshot script) and returns 0.
- CC_COMMAND_RE: export ... && shopt -u extglob ... && eval 'PAYLOAD' < /dev/null && pwd -P >| marker. When matched, the adapter runs the export prefix, then the payload via runScript, and on success writes the cwd marker (the facade's session.cwd as a POSIX path) to the marker file. A nonzero payload exit stops the && chain and omits the marker, matching bash.
When neither pattern matches, the function returns null so runFacade falls through to plain one-shot translation. toPosixPath/fromPosixPath convert between Windows and POSIX drive-letter paths. Pattern drift fails loud (visible in FAUXNIX_FACADE_TRACE), never silently wrong.
Usage
Called by runFacade for every -c invocation with no trailing positionals (the form Claude Code uses). Returns an exit code when it handled the script, or null to fall through.
Code Reference
Source Location
- Repository: fauxnix
- File: src/facade.ts
- Lines: tryClaudeCodeAdapter L74-106; CC_SNAPSHOT_RE L58; CC_COMMAND_RE L59-60; toPosixPath/fromPosixPath L62-71
Signature
async function tryClaudeCodeAdapter(session: FauxnixSession, script: string): Promise<number | null>;
Import
// Internal — called by runFacade, not exported for external use.
import { runFacade } from './facade.js'; // runFacade calls tryClaudeCodeAdapter internally
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| session | FauxnixSession | Yes | The resident facade session |
| script | string | Yes | The raw bash -c operand (scaffolding + payload) |
Outputs
| Name | Type | Description |
|---|---|---|
| (return) | null | Exit code when handled; null to fall through to plain translation |
Usage Examples
Internal: RunFacade Delegates
// Inside runFacade, when -c is given with no trailing positionals:
const adapted = await tryClaudeCodeAdapter(session, dashC.script);
if (adapted !== null) return adapted; // scaffolding handled
return await runOneShot(session, dashC.script, dashC.positionals); // plain