mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
chore: fix biome issues
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { DynamicStructuredTool } from "@langchain/core/tools";
|
import { DynamicStructuredTool } from "@langchain/core/tools";
|
||||||
// @ts-ignore - graphology type issue
|
|
||||||
import type Graph from "graphology";
|
import type Graph from "graphology";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ const graphExplorerSchema = z.object({
|
|||||||
* Creates the graph explorer tool.
|
* Creates the graph explorer tool.
|
||||||
* @param graph - Graphology graph instance
|
* @param graph - Graphology graph instance
|
||||||
*/
|
*/
|
||||||
// @ts-ignore - Graph type issue
|
// @ts-expect-error - Graph type issue
|
||||||
export function createGraphExplorerTool(graph: Graph) {
|
export function createGraphExplorerTool(graph: Graph) {
|
||||||
return new DynamicStructuredTool({
|
return new DynamicStructuredTool({
|
||||||
name: "ask262_graph_explorer",
|
name: "ask262_graph_explorer",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { GRAPH_FILE } from "../constants.js";
|
|||||||
*/
|
*/
|
||||||
async function buildGraph() {
|
async function buildGraph() {
|
||||||
// Initialize a multi-graph (allows multiple edges between same nodes)
|
// Initialize a multi-graph (allows multiple edges between same nodes)
|
||||||
// @ts-ignore - graphology constructor type issue
|
// @ts-expect-error - graphology constructor type issue
|
||||||
const graph = new Graph({
|
const graph = new Graph({
|
||||||
multi: true,
|
multi: true,
|
||||||
type: "directed",
|
type: "directed",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bun
|
#!/usr/bin/env bun
|
||||||
|
import { readFileSync, writeFileSync } from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
import type { CheerioAPI } from "cheerio";
|
import type { CheerioAPI } from "cheerio";
|
||||||
import * as cheerio from "cheerio";
|
import * as cheerio from "cheerio";
|
||||||
import { readFileSync, writeFileSync } from "fs";
|
|
||||||
import { fileURLToPath } from "url";
|
|
||||||
|
|
||||||
// Resolve the path to the HTML file (relative to repo root)
|
// Resolve the path to the HTML file (relative to repo root)
|
||||||
const htmlUrl = new URL(
|
const htmlUrl = new URL(
|
||||||
|
|||||||
@@ -266,17 +266,17 @@ export function convertTablesToMarkdown($: cheerio.CheerioAPI): void {
|
|||||||
// Header row
|
// Header row
|
||||||
if (rows.length > 0) {
|
if (rows.length > 0) {
|
||||||
const header = rows[0].concat(Array(maxCols - rows[0].length).fill(""));
|
const header = rows[0].concat(Array(maxCols - rows[0].length).fill(""));
|
||||||
mdLines.push("| " + header.join(" | ") + " |");
|
mdLines.push(`| ${header.join(" | ")} |`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
mdLines.push("|" + Array(maxCols).fill(" --- ").join("|") + "|");
|
mdLines.push(`|${Array(maxCols).fill(" --- ").join("|")}|`);
|
||||||
|
|
||||||
// Data rows (skip header if we have more rows)
|
// Data rows (skip header if we have more rows)
|
||||||
const dataRows = rows.length > 1 ? rows.slice(1) : [];
|
const dataRows = rows.length > 1 ? rows.slice(1) : [];
|
||||||
for (const row of dataRows) {
|
for (const row of dataRows) {
|
||||||
const padded = row.concat(Array(maxCols - row.length).fill(""));
|
const padded = row.concat(Array(maxCols - row.length).fill(""));
|
||||||
mdLines.push("| " + padded.join(" | ") + " |");
|
mdLines.push(`| ${padded.join(" | ")} |`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace table with markdown
|
// Replace table with markdown
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ async function getTable(): Promise<Table> {
|
|||||||
// Check if table exists
|
// Check if table exists
|
||||||
try {
|
try {
|
||||||
return await db.openTable("spec_vectors");
|
return await db.openTable("spec_vectors");
|
||||||
} catch (error) {
|
} catch (_error) {
|
||||||
console.error("❌ Table 'spec_vectors' not found in database");
|
console.error("❌ Table 'spec_vectors' not found in database");
|
||||||
console.log("\nRun 'bun run ingest' first to populate the database.");
|
console.log("\nRun 'bun run ingest' first to populate the database.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -97,7 +97,7 @@ program
|
|||||||
.option("-l, --limit <number>", "Number of results to show", "5")
|
.option("-l, --limit <number>", "Number of results to show", "5")
|
||||||
.action(async (query: string, options: { limit: string }) => {
|
.action(async (query: string, options: { limit: string }) => {
|
||||||
const table = await getTable();
|
const table = await getTable();
|
||||||
await vectorSearch(table, query, parseInt(options.limit));
|
await vectorSearch(table, query, parseInt(options.limit, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
@@ -114,7 +114,7 @@ program
|
|||||||
.option("-n, --count <number>", "Number of samples to show", "3")
|
.option("-n, --count <number>", "Number of samples to show", "3")
|
||||||
.action(async (options: { count: string }) => {
|
.action(async (options: { count: string }) => {
|
||||||
const table = await getTable();
|
const table = await getTable();
|
||||||
await showSamples(table, parseInt(options.count));
|
await showSamples(table, parseInt(options.count, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
@@ -123,7 +123,7 @@ program
|
|||||||
.option("-m, --min <number>", "Minimum size in characters", "5000")
|
.option("-m, --min <number>", "Minimum size in characters", "5000")
|
||||||
.action(async (options: { min: string }) => {
|
.action(async (options: { min: string }) => {
|
||||||
const table = await getTable();
|
const table = await getTable();
|
||||||
await showLargeDocs(table, parseInt(options.min));
|
await showLargeDocs(table, parseInt(options.min, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
async function showSummary(table: Table) {
|
async function showSummary(table: Table) {
|
||||||
@@ -223,7 +223,7 @@ async function listSections(table: Table) {
|
|||||||
|
|
||||||
for (const [id, info] of sorted) {
|
for (const [id, info] of sorted) {
|
||||||
const title =
|
const title =
|
||||||
info.title.length > 50 ? info.title.slice(0, 47) + "..." : info.title;
|
info.title.length > 50 ? `${info.title.slice(0, 47)}...` : info.title;
|
||||||
console.log(
|
console.log(
|
||||||
`${id.padEnd(30)} | ${title.padEnd(50)} | ${info.chunks.toString().padStart(3)}`,
|
`${id.padEnd(30)} | ${title.padEnd(50)} | ${info.chunks.toString().padStart(3)}`,
|
||||||
);
|
);
|
||||||
@@ -365,7 +365,7 @@ function printTreeNode(
|
|||||||
const connector = isLast ? "└── " : "├── ";
|
const connector = isLast ? "└── " : "├── ";
|
||||||
const title =
|
const title =
|
||||||
node.sectiontitle.length > 50
|
node.sectiontitle.length > 50
|
||||||
? node.sectiontitle.slice(0, 47) + "..."
|
? `${node.sectiontitle.slice(0, 47)}...`
|
||||||
: node.sectiontitle;
|
: node.sectiontitle;
|
||||||
console.log(`${prefix}${connector}${node.sectionid}`);
|
console.log(`${prefix}${connector}${node.sectionid}`);
|
||||||
console.log(`${prefix}${isLast ? " " : "│ "} ${title}`);
|
console.log(`${prefix}${isLast ? " " : "│ "} ${title}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user