fix(adapters/gemini-local): address PR review feedback for skills and formatting

- Isolate skills injection using a temporary directory mapped via
  GEMINI_CLI_HOME, mirroring the claude-local sandbox approach
  instead of polluting the global ~/.gemini/skills directory.
- Update the environment probe to use `--output-format stream-json`
  so the payload matches the downstream parseGeminiJsonl parser.
- Deduplicate `firstNonEmptyLine` helper by extracting it to a
  shared `utils.ts` module.
- Clean up orphaned internal exports and update adapter documentation.
This commit is contained in:
Aditya Sasidhar
2026-03-08 19:20:43 +05:30
committed by Aaron
parent af97259a9c
commit ec445e4cc9
5 changed files with 65 additions and 105 deletions

View File

@@ -16,6 +16,7 @@ import {
} from "@paperclipai/adapter-utils/server-utils";
import { DEFAULT_GEMINI_LOCAL_MODEL } from "../index.js";
import { parseGeminiJsonl } from "./parse.js";
import { firstNonEmptyLine } from "./utils.js";
function summarizeStatus(checks: AdapterEnvironmentCheck[]): AdapterEnvironmentTestResult["status"] {
if (checks.some((check) => check.level === "error")) return "fail";
@@ -27,15 +28,6 @@ function isNonEmpty(value: unknown): value is string {
return typeof value === "string" && value.trim().length > 0;
}
function firstNonEmptyLine(text: string): string {
return (
text
.split(/\r?\n/)
.map((line) => line.trim())
.find(Boolean) ?? ""
);
}
function commandLooksLike(command: string, expected: string): boolean {
const base = path.basename(command).toLowerCase();
return base === expected || base === `${expected}.cmd` || base === `${expected}.exe`;
@@ -146,7 +138,7 @@ export async function testEnvironment(
return asStringArray(config.args);
})();
const args = ["--output-format", "json"];
const args = ["--output-format", "stream-json"];
if (model && model !== DEFAULT_GEMINI_LOCAL_MODEL) args.push("--model", model);
if (yolo) args.push("--approval-mode", "yolo");
if (extraArgs.length > 0) args.push(...extraArgs);
@@ -161,7 +153,7 @@ export async function testEnvironment(
env,
timeoutSec: 45,
graceSec: 5,
onLog: async () => {},
onLog: async () => { },
},
);
const parsed = parseGeminiJsonl(probe.stdout);
@@ -188,8 +180,8 @@ export async function testEnvironment(
...(hasHello
? {}
: {
hint: "Try `gemini --output-format json \"Respond with hello.\"` manually to inspect full output.",
}),
hint: "Try `gemini --output-format json \"Respond with hello.\"` manually to inspect full output.",
}),
});
} else if (GEMINI_AUTH_REQUIRED_RE.test(authEvidence)) {
checks.push({