mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Remove unnecessary type assertions across codebase
Add oxlint-tsgolint and configure typescript/no-unnecessary-type-assertion to flag redundant `!` and `as Foo` casts. Type-aware mode is left off by default to keep `npm run lint` fast; the rule sits configured for when we turn type-aware on intentionally. Auto-fix removed ~283 redundant casts; two manual touch-ups: a real tsgolint false positive in split-container.tsx and a stale ChildProcess import after a double-cast collapsed.
This commit is contained in:
@@ -44,7 +44,7 @@ export async function runArchiveCommand(
|
||||
options: AgentArchiveOptions,
|
||||
_command: Command,
|
||||
): Promise<AgentArchiveCommandResult> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
// Validate arguments
|
||||
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
||||
@@ -58,7 +58,7 @@ export async function runArchiveCommand(
|
||||
|
||||
let client: DaemonClient;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const error: CommandError = {
|
||||
|
||||
@@ -105,7 +105,7 @@ export async function runAttachCommand(
|
||||
options: AgentAttachOptions,
|
||||
_command: Command,
|
||||
): Promise<void> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
if (!id) {
|
||||
console.error("Error: Agent ID required");
|
||||
@@ -115,7 +115,7 @@ export async function runAttachCommand(
|
||||
|
||||
let client: DaemonClient;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
console.error(`Error: Cannot connect to daemon at ${host}: ${message}`);
|
||||
|
||||
@@ -113,7 +113,7 @@ export async function runImportCommand(
|
||||
options: AgentImportOptions,
|
||||
_command: Command,
|
||||
): Promise<AgentImportCommandResult> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
const sessionId = sessionIdArg.trim();
|
||||
if (!sessionId) {
|
||||
throw {
|
||||
@@ -134,7 +134,7 @@ export async function runImportCommand(
|
||||
}
|
||||
|
||||
const labels = parseImportLabels(options.label);
|
||||
const client = await connectToDaemonOrThrow(options.host as string | undefined, host);
|
||||
const client = await connectToDaemonOrThrow(options.host, host);
|
||||
|
||||
try {
|
||||
const agent = await client.importAgent({
|
||||
|
||||
@@ -216,7 +216,7 @@ export async function runInspectCommand(
|
||||
options: AgentInspectOptions,
|
||||
_command: Command,
|
||||
): Promise<AgentInspectResult> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
// Validate arguments
|
||||
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
||||
@@ -230,7 +230,7 @@ export async function runInspectCommand(
|
||||
|
||||
let client;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const error: CommandError = {
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function runReloadCommand(
|
||||
options: AgentReloadOptions,
|
||||
_command: Command,
|
||||
): Promise<AgentReloadCommandResult> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
||||
const error: CommandError = {
|
||||
@@ -53,7 +53,7 @@ export async function runReloadCommand(
|
||||
|
||||
let client: DaemonClient;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const error: CommandError = {
|
||||
|
||||
@@ -86,7 +86,7 @@ export async function runUpdateCommand(
|
||||
options: AgentUpdateOptions,
|
||||
_command: Command,
|
||||
): Promise<AgentUpdateCommandResult> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
// Validate arguments
|
||||
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
||||
@@ -120,7 +120,7 @@ export async function runUpdateCommand(
|
||||
|
||||
let client;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const error: CommandError = {
|
||||
|
||||
@@ -139,7 +139,7 @@ export async function runWaitCommand(
|
||||
options: AgentWaitOptions,
|
||||
_command: Command,
|
||||
): Promise<SingleResult<AgentWaitResult>> {
|
||||
const host = getDaemonHost({ host: options.host as string | undefined });
|
||||
const host = getDaemonHost({ host: options.host });
|
||||
|
||||
if (!agentIdArg || agentIdArg.trim().length === 0) {
|
||||
throw {
|
||||
@@ -153,7 +153,7 @@ export async function runWaitCommand(
|
||||
|
||||
let client;
|
||||
try {
|
||||
client = await connectToDaemon({ host: options.host as string | undefined });
|
||||
client = await connectToDaemon({ host: options.host });
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
const error: CommandError = {
|
||||
|
||||
@@ -32,7 +32,7 @@ export async function runPostCommand(
|
||||
]);
|
||||
return {
|
||||
type: "single",
|
||||
data: message!,
|
||||
data: message,
|
||||
schema: chatMessageSchema,
|
||||
};
|
||||
} catch (err) {
|
||||
|
||||
@@ -12,7 +12,7 @@ export function pairCommand(): Command {
|
||||
return addJsonOption(new Command("pair").description("Print the daemon pairing QR code and link"))
|
||||
.option("--home <path>", "Paseo home directory (default: ~/.paseo)")
|
||||
.action(async (_options: PairOptions, command: Command) => {
|
||||
await runPairCommand(command.optsWithGlobals() as PairOptions);
|
||||
await runPairCommand(command.optsWithGlobals());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ async function resolveNodePathFromPidWindows(pid: number): Promise<NodePathFromP
|
||||
error: errors.join("; ") || "could not resolve executable path from PID",
|
||||
};
|
||||
}
|
||||
const probe = probes[index] as (typeof probes)[number];
|
||||
const probe = probes[index];
|
||||
const result = await runProcessProbe(probe.command, probe.args);
|
||||
if (result.resolved) {
|
||||
const resolved = probe.parseValue ? probe.parseValue(result.resolved) : result.resolved;
|
||||
|
||||
@@ -111,7 +111,7 @@ export async function runAllowCommand(
|
||||
permissionsToAllow = pendingPermissions;
|
||||
} else {
|
||||
// Find permission by ID prefix
|
||||
const permission = pendingPermissions.find((p) => p.id === reqId || p.id.startsWith(reqId!));
|
||||
const permission = pendingPermissions.find((p) => p.id === reqId || p.id.startsWith(reqId));
|
||||
if (!permission) {
|
||||
await client.close();
|
||||
const error: CommandError = {
|
||||
|
||||
@@ -76,7 +76,7 @@ export async function runLsCommand(
|
||||
provider: entry.provider,
|
||||
label: entry.label ?? entry.provider,
|
||||
status: entry.status === "ready" ? "available" : entry.status,
|
||||
enabled: entry.enabled === false ? "Disabled" : "Enabled",
|
||||
enabled: !entry.enabled ? "Disabled" : "Enabled",
|
||||
defaultMode: entry.defaultModeId ?? "default",
|
||||
modes: (entry.modes ?? []).map((mode) => mode.label).join(", "),
|
||||
})),
|
||||
|
||||
@@ -137,7 +137,7 @@ export function renderTable<T>(result: AnyCommandResult<T>, options: OutputOptio
|
||||
return "";
|
||||
}
|
||||
|
||||
const columns = schema.columns as ColumnDef<T>[];
|
||||
const columns = schema.columns;
|
||||
const includeHeaders = !options.noHeaders;
|
||||
const widths = calculateWidths(data, columns, includeHeaders);
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ export async function connectToDaemon(options?: ConnectOptions): Promise<DaemonC
|
||||
if (lastError instanceof Error) throw lastError;
|
||||
throw new Error(`Unable to connect to Paseo daemon via ${hosts.join(", ")}`);
|
||||
}
|
||||
const host = hosts[index] as string;
|
||||
const host = hosts[index];
|
||||
const password = resolveDaemonPassword(host);
|
||||
const result = await tryConnectHost(host, password, clientId, timeout, nodeWebSocketFactory);
|
||||
if ("client" in result) {
|
||||
|
||||
Reference in New Issue
Block a user