Files
reverse-engineering-anything/src/contracts/cliCommandNames.ts
T
8d6552e928 feat(config): persist provider settings in a user config file (#3023)
* feat(config): persist provider settings in a user config file

Providers currently rediscover install paths from scratch in every
process, so a path set once (for example GHIDRA_INSTALL_DIR) silently
reverts on the next run. Introduce ~/.config/rea/rea.json as the
user-owned persistence layer and merge it into the environment
snapshot before configuration parsing, keeping env > config file >
auto-detect precedence on both the CLI and MCP entry points.

Add a rea config command (list/get/set/unset) as the write surface,
reporting the effective value and where it came from.

* fix(config): address review findings on persistence safety and CLI surface

- stage config writes beside the file and rename into place so an
  interrupted write cannot leave partial JSON (greptile #4, codex #11)
- convert unreadable config files into configuration errors on the CLI
  seam instead of escaping raw filesystem errors (greptile #5, codex #15)
- keep injected runtimes without a config root isolated from the host
  account's rea.json (codex #18)
- surface the config file error on stderr when doctor falls back to the
  raw environment (greptile #3, codex #16)
- route the config command through logCliCommand and return documents so
  --json stays parseable and failures exit non-zero (greptile #2,
  codex #10)
- reject empty --set values, unknown --set/--unset/--get names, and --get
  combined with mutations (greptile #1/#7, codex #9/#12/#13/#17)
- cover the new behavior in the boundary tests and stop leaking one
  temporary home per run (greptile #8)

* fix(config): validate and back up persisted provider settings

* fix(config): keep saved provider defaults out of client registrations

* fix(config): preserve provider discovery and budgets for saved settings

* fix(config): check only settings needed by the IDA deadline lookup

* fix(config): share effective provider settings and verify config file reads

* fix(doctor): share selected settings with Hopper and ILSpy probes

* fix(config): resolve the destination of first-time saves

* fix(doctor): preserve unresolved provider location inputs

* fix(doctor): honor inherited IDA deadline overrides

* fix(config): show empty environment overrides

* fix(setup): preserve client-selected saved configuration roots

---------

Co-authored-by: Jackzigen <zigenhan@gmail.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-11-21 22:02:35 +00:00

61 lines
2.1 KiB
TypeScript

/** The kebab-case spelling of a contract name, which names its CLI command. */
export type CliCommandName<Name extends string> =
Name extends `${infer Head}_${infer Tail}`
? `${Head}-${CliCommandName<Tail>}`
: Name;
/**
* The CLI command of a contract that declares `cli: true`. The contract
* registry owns these names; `CLI_COMMANDS` holds only the commands no
* contract names.
*/
export const cliCommandFor = <Name extends string>(
name: Name,
): CliCommandName<Name> => name.replaceAll("_", "-") as CliCommandName<Name>;
/** Names of the CLI commands that no contract names. */
export const CLI_COMMANDS = Object.freeze({
analyze: "analyze",
inspect: "inspect",
decompile: "decompile",
setup: "setup",
config: "config",
doctor: "doctor",
uninstall: "uninstall",
update: "update",
trace: "trace",
capabilities: "capabilities",
providers: "providers",
guidance: "guidance",
function: "function",
instructions: "instructions",
search: "search",
importReferenceSource: "import-reference-source",
listObjdumpArchitectures: "list-objdump-architectures",
debugWithGdb: "debug-with-gdb",
debugWithRizin: "debug-with-rizin",
inspectEvidenceBundle: "inspect-evidence-bundle",
evidenceImport: "evidence-import",
evidenceExport: "evidence-export",
environmentServe: "environment-serve",
environmentExport: "environment-export",
environmentCompare: "environment-compare",
environmentBuild: "environment-build",
compare: "compare",
captureProcess: "capture-process",
captureDesktopApplication: "capture-desktop-application",
inspectDesktopApplicationState: "inspect-desktop-application-state",
exportDesktopApplication: "export-desktop-application",
describeDesktopApplicationTask: "describe-desktop-application-task",
validateBrowserScenario: "validate-browser-scenario",
});
/**
* Commands that announce their progress at info level when REA_LOG_LEVEL is
* unset, like `rea mcp --http`. Their logger writes to stderr directly.
*/
export const DEFAULT_INFO_LOGGING_COMMANDS: ReadonlySet<string> = new Set([
CLI_COMMANDS.environmentServe,
CLI_COMMANDS.environmentBuild,
]);