mirror of
https://github.com/samsonjs/Peekaboo.git
synced 2026-04-27 15:07:41 +00:00
Fix ESLint violations for release preparation
- Remove unused imports and variables - Fix quote consistency and trailing commas - Remove non-null assertions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
020621582a
commit
57c277f4da
5 changed files with 22 additions and 23 deletions
|
|
@ -44,7 +44,7 @@ export const analyzeToolSchema = z.object({
|
||||||
{
|
{
|
||||||
message: "image_path is required",
|
message: "image_path is required",
|
||||||
path: ["image_path"],
|
path: ["image_path"],
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
export type AnalyzeToolInput = z.infer<typeof analyzeToolSchema>;
|
export type AnalyzeToolInput = z.infer<typeof analyzeToolSchema>;
|
||||||
|
|
@ -57,8 +57,8 @@ export async function analyzeToolHandler(
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Determine the effective image path (prioritize image_path, fallback to path)
|
// Determine the effective image path (prioritize image_path, fallback to path)
|
||||||
const effectiveImagePath = input.image_path || input.path!;
|
const effectiveImagePath = input.image_path || input.path || "";
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
{ input: { ...input, effectiveImagePath: effectiveImagePath.split("/").pop() } },
|
{ input: { ...input, effectiveImagePath: effectiveImagePath.split("/").pop() } },
|
||||||
"Processing peekaboo.analyze tool call",
|
"Processing peekaboo.analyze tool call",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import { performAutomaticAnalysis } from "../utils/image-analysis.js";
|
||||||
import { buildImageSummary } from "../utils/image-summary.js";
|
import { buildImageSummary } from "../utils/image-summary.js";
|
||||||
import { buildSwiftCliArgs, resolveImagePath } from "../utils/image-cli-args.js";
|
import { buildSwiftCliArgs, resolveImagePath } from "../utils/image-cli-args.js";
|
||||||
import { parseAIProviders } from "../utils/ai-providers.js";
|
import { parseAIProviders } from "../utils/ai-providers.js";
|
||||||
import * as fs from "fs/promises";
|
|
||||||
|
|
||||||
export { imageToolSchema } from "../types/index.js";
|
export { imageToolSchema } from "../types/index.js";
|
||||||
|
|
||||||
|
|
@ -19,7 +18,7 @@ export async function imageToolHandler(
|
||||||
context: ToolContext,
|
context: ToolContext,
|
||||||
): Promise<ToolResponse> {
|
): Promise<ToolResponse> {
|
||||||
const { logger } = context;
|
const { logger } = context;
|
||||||
let tempDirUsed: string | undefined = undefined;
|
let _tempDirUsed: string | undefined = undefined;
|
||||||
let finalSavedFiles: SavedFile[] = [];
|
let finalSavedFiles: SavedFile[] = [];
|
||||||
let analysisAttempted = false;
|
let analysisAttempted = false;
|
||||||
let analysisSucceeded = false;
|
let analysisSucceeded = false;
|
||||||
|
|
@ -34,7 +33,7 @@ export async function imageToolHandler(
|
||||||
|
|
||||||
// Resolve the effective path using the centralized logic
|
// Resolve the effective path using the centralized logic
|
||||||
const { effectivePath, tempDirUsed: tempDir } = await resolveImagePath(input, logger);
|
const { effectivePath, tempDirUsed: tempDir } = await resolveImagePath(input, logger);
|
||||||
tempDirUsed = tempDir;
|
_tempDirUsed = tempDir;
|
||||||
|
|
||||||
const args = buildSwiftCliArgs(input, effectivePath, swiftFormat, logger);
|
const args = buildSwiftCliArgs(input, effectivePath, swiftFormat, logger);
|
||||||
|
|
||||||
|
|
@ -92,7 +91,7 @@ export async function imageToolHandler(
|
||||||
if (input.question) {
|
if (input.question) {
|
||||||
analysisAttempted = true;
|
analysisAttempted = true;
|
||||||
const analysisResults: Array<{ label: string; text: string }> = [];
|
const analysisResults: Array<{ label: string; text: string }> = [];
|
||||||
|
|
||||||
const configuredProviders = parseAIProviders(
|
const configuredProviders = parseAIProviders(
|
||||||
process.env.PEEKABOO_AI_PROVIDERS || "",
|
process.env.PEEKABOO_AI_PROVIDERS || "",
|
||||||
);
|
);
|
||||||
|
|
@ -106,7 +105,7 @@ export async function imageToolHandler(
|
||||||
try {
|
try {
|
||||||
const imageBase64 = await readImageAsBase64(savedFile.path);
|
const imageBase64 = await readImageAsBase64(savedFile.path);
|
||||||
logger.debug({ path: savedFile.path }, "Image read successfully for analysis.");
|
logger.debug({ path: savedFile.path }, "Image read successfully for analysis.");
|
||||||
|
|
||||||
const analysisResult = await performAutomaticAnalysis(
|
const analysisResult = await performAutomaticAnalysis(
|
||||||
imageBase64,
|
imageBase64,
|
||||||
input.question,
|
input.question,
|
||||||
|
|
@ -139,7 +138,7 @@ export async function imageToolHandler(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format the analysis results
|
// Format the analysis results
|
||||||
if (analysisResults.length === 1) {
|
if (analysisResults.length === 1) {
|
||||||
analysisText = analysisResults[0].text;
|
analysisText = analysisResults[0].text;
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ export const listToolSchema = z
|
||||||
.refine(
|
.refine(
|
||||||
(data) =>
|
(data) =>
|
||||||
data.item_type !== "server_status" ||
|
data.item_type !== "server_status" ||
|
||||||
(data.app === undefined &&
|
(data.app === undefined &&
|
||||||
(data.include_window_details === undefined || data.include_window_details.length === 0)),
|
(data.include_window_details === undefined || data.include_window_details.length === 0)),
|
||||||
{
|
{
|
||||||
message:
|
message:
|
||||||
|
|
|
||||||
|
|
@ -151,8 +151,8 @@ export const imageToolSchema = z.object({
|
||||||
.describe(
|
.describe(
|
||||||
"Optional. Focus behavior. 'auto' (default): bring target to front only if not already active. " +
|
"Optional. Focus behavior. 'auto' (default): bring target to front only if not already active. " +
|
||||||
"'background': capture without altering window focus. " +
|
"'background': capture without altering window focus. " +
|
||||||
"'foreground': always bring target to front before capture."
|
"'foreground': always bring target to front before capture.",
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.describe(
|
.describe(
|
||||||
|
|
|
||||||
|
|
@ -58,22 +58,22 @@ function getInitializedSwiftCliPath(logger: Logger): string {
|
||||||
function mapExitCodeToErrorMessage(
|
function mapExitCodeToErrorMessage(
|
||||||
exitCode: number,
|
exitCode: number,
|
||||||
stderr: string,
|
stderr: string,
|
||||||
command: 'image' | 'list',
|
command: "image" | "list",
|
||||||
appTarget?: string,
|
appTarget?: string,
|
||||||
): { message: string, code: string } {
|
): { message: string; code: string } {
|
||||||
const defaultMessage = stderr.trim()
|
const defaultMessage = stderr.trim()
|
||||||
? `Peekaboo CLI Error: ${stderr.trim()}`
|
? "Peekaboo CLI Error: " + stderr.trim()
|
||||||
: `Swift CLI execution failed (exit code: ${exitCode})`;
|
: "Swift CLI execution failed (exit code: " + exitCode + ")";
|
||||||
|
|
||||||
// Handle exit code 18 specially with command context
|
// Handle exit code 18 specially with command context
|
||||||
if (exitCode === 18) {
|
if (exitCode === 18) {
|
||||||
return {
|
return {
|
||||||
message: `The specified application ('${appTarget || 'unknown'}') is not running or could not be found.`,
|
message: "The specified application ('" + (appTarget || "unknown") + "') is not running or could not be found.",
|
||||||
code: "SWIFT_CLI_APP_NOT_FOUND",
|
code: "SWIFT_CLI_APP_NOT_FOUND",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const errorCodeMap: { [key: number]: { message: string, code: string } } = {
|
const errorCodeMap: { [key: number]: { message: string; code: string } } = {
|
||||||
1: { message: "An unknown error occurred in the Swift CLI.", code: "SWIFT_CLI_UNKNOWN_ERROR" },
|
1: { message: "An unknown error occurred in the Swift CLI.", code: "SWIFT_CLI_UNKNOWN_ERROR" },
|
||||||
7: { message: "The specified application is running but has no capturable windows. Try setting 'capture_focus' to 'foreground' to un-hide application windows.", code: "SWIFT_CLI_NO_WINDOWS_FOUND" },
|
7: { message: "The specified application is running but has no capturable windows. Try setting 'capture_focus' to 'foreground' to un-hide application windows.", code: "SWIFT_CLI_NO_WINDOWS_FOUND" },
|
||||||
10: { message: "No displays available for capture.", code: "SWIFT_CLI_NO_DISPLAYS" },
|
10: { message: "No displays available for capture.", code: "SWIFT_CLI_NO_DISPLAYS" },
|
||||||
|
|
@ -153,11 +153,11 @@ export async function executeSwiftCli(
|
||||||
);
|
);
|
||||||
|
|
||||||
// Determine command and app target from args
|
// Determine command and app target from args
|
||||||
const command = args[0] as 'image' | 'list';
|
const command = args[0] as "image" | "list";
|
||||||
let appTarget: string | undefined;
|
let appTarget: string | undefined;
|
||||||
|
|
||||||
// Find app target in args
|
// Find app target in args
|
||||||
const appIndex = args.indexOf('--app');
|
const appIndex = args.indexOf("--app");
|
||||||
if (appIndex !== -1 && appIndex < args.length - 1) {
|
if (appIndex !== -1 && appIndex < args.length - 1) {
|
||||||
appTarget = args[appIndex + 1];
|
appTarget = args[appIndex + 1];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue