chore: Lint fixes

This commit is contained in:
2026-03-27 17:47:12 +05:30
parent b6dbcfe91a
commit 0f5a31137f
6 changed files with 41 additions and 32 deletions
+9 -9
View File
@@ -1,16 +1,16 @@
import fs from "node:fs"; import fs from "node:fs";
import {
VectorStoreIndex,
storageContextFromDefaults,
Settings,
QueryEngineTool,
ReActAgent,
} from "llamaindex";
import { OllamaEmbedding } from "@llamaindex/ollama"; import { OllamaEmbedding } from "@llamaindex/ollama";
import { OpenAI } from "@llamaindex/openai"; import { OpenAI } from "@llamaindex/openai";
import { Graph } from "graphology"; import { Graph } from "graphology";
import {
QueryEngineTool,
ReActAgent,
Settings,
storageContextFromDefaults,
VectorStoreIndex,
} from "llamaindex";
import { STORAGE_DIR, GRAPH_FILE } from "./constants.ts"; import { GRAPH_FILE, STORAGE_DIR } from "./constants.ts";
// Configure Settings // Configure Settings
Settings.embedModel = new OllamaEmbedding({ Settings.embedModel = new OllamaEmbedding({
@@ -94,7 +94,7 @@ async function main() {
const attr = graph.getNodeAttributes(neighbor); const attr = graph.getNodeAttributes(neighbor);
const edges = graph.edges(nodeId, neighbor); const edges = graph.edges(nodeId, neighbor);
const edgeAttr = graph.getEdgeAttributes(edges[0]); const edgeAttr = graph.getEdgeAttributes(edges[0]);
result += `- ${neighbor} (${attr.type}) via ${edgeAttr.type}${attr.title ? ": " + attr.title : ""}\n`; result += `- ${neighbor} (${attr.type}) via ${edgeAttr.type}${attr.title ? `: ${attr.title}` : ""}\n`;
}); });
return result; return result;
} }
+1 -1
View File
@@ -5,5 +5,5 @@
"lineWidth": 80, "lineWidth": 80,
"lineEnding": "lf" "lineEnding": "lf"
}, },
"files": { "includes": ["**", "!!spec-built/**", "!!engine262/**"] } "files": { "includes": ["**", "!!spec-built", "!!engine262", "!!graphology"] }
} }
+3
View File
@@ -18,6 +18,7 @@
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^2.4.9", "@biomejs/biome": "^2.4.9",
"typescript": "^5.5.2",
}, },
}, },
}, },
@@ -172,6 +173,8 @@
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
"undici": ["undici@7.24.6", "", {}, "sha512-Xi4agocCbRzt0yYMZGMA6ApD7gvtUFaxm4ZmeacWI4cZxaF6C+8I8QfofC20NAePiB/IcvZmzkJ7XPa471AEtA=="], "undici": ["undici@7.24.6", "", {}, "sha512-Xi4agocCbRzt0yYMZGMA6ApD7gvtUFaxm4ZmeacWI4cZxaF6C+8I8QfofC20NAePiB/IcvZmzkJ7XPa471AEtA=="],
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
+5 -1
View File
@@ -3,8 +3,11 @@
"version": "1.0.0", "version": "1.0.0",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"type-check": "tsc --noEmit",
"lint": "biome check .", "lint": "biome check .",
"format": "biome format .", "lint:fix": "biome check . --write",
"lint:fix:unsafe": "biome check . --write --unsafe",
"format:fix": "biome format . --write",
"ingest": "bun run setup/ingest.ts", "ingest": "bun run setup/ingest.ts",
"agent": "bun run agent.ts", "agent": "bun run agent.ts",
"build": "bun run setup/build_graph.ts", "build": "bun run setup/build_graph.ts",
@@ -28,6 +31,7 @@
"llamaindex": "^0.12.1" "llamaindex": "^0.12.1"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5.5.2",
"@biomejs/biome": "^2.4.9" "@biomejs/biome": "^2.4.9"
} }
} }
+12 -11
View File
@@ -1,11 +1,12 @@
import fs from "fs"; import fs from "node:fs";
import path from "path"; import path from "node:path";
import { glob } from "glob";
import * as cheerio from "cheerio"; import * as cheerio from "cheerio";
import { glob } from "glob";
import { Graph } from "graphology"; import { Graph } from "graphology";
const SPEC_DIR = "./spec-built/multipage"; const SPEC_DIR = "./spec-built/multipage";
const CODE_DIR = "./engine262/src"; const CODE_DIR = "./engine262/src";
import { GRAPH_FILE } from "../constants.ts"; import { GRAPH_FILE } from "../constants.ts";
async function buildGraph() { async function buildGraph() {
@@ -24,7 +25,7 @@ async function buildGraph() {
const content = fs.readFileSync(file, "utf-8"); const content = fs.readFileSync(file, "utf-8");
const $ = cheerio.load(content); const $ = cheerio.load(content);
$("emu-clause").each((i, elem) => { $("emu-clause").each((_i, elem) => {
const id = $(elem).attr("id"); const id = $(elem).attr("id");
const title = $(elem).find("h1").first().text().trim(); const title = $(elem).find("h1").first().text().trim();
@@ -36,12 +37,12 @@ async function buildGraph() {
// Extract internal links // Extract internal links
$(elem) $(elem)
.find("a[href]") .find("a[href]")
.each((j, link) => { .each((_j, link) => {
const href = $(link).attr("href"); const href = $(link).attr("href");
if (href && href.includes("#")) { if (href?.includes("#")) {
const [targetFile, targetId] = href.split("#"); const [_targetFile, targetId] = href.split("#");
// We only care about links to other sections for now // We only care about links to other sections for now
if (targetId && targetId.startsWith("sec-")) { if (targetId?.startsWith("sec-")) {
// Add relationship later if nodes exist // Add relationship later if nodes exist
} }
} }
@@ -54,14 +55,14 @@ async function buildGraph() {
for (const file of htmlFiles) { for (const file of htmlFiles) {
const content = fs.readFileSync(file, "utf-8"); const content = fs.readFileSync(file, "utf-8");
const $ = cheerio.load(content); const $ = cheerio.load(content);
$("emu-clause").each((i, elem) => { $("emu-clause").each((_i, elem) => {
const sourceId = $(elem).attr("id"); const sourceId = $(elem).attr("id");
if (sourceId && graph.hasNode(sourceId)) { if (sourceId && graph.hasNode(sourceId)) {
$(elem) $(elem)
.find("a[href]") .find("a[href]")
.each((j, link) => { .each((_j, link) => {
const href = $(link).attr("href"); const href = $(link).attr("href");
if (href && href.includes("#")) { if (href?.includes("#")) {
const [, targetId] = href.split("#"); const [, targetId] = href.split("#");
if ( if (
targetId && targetId &&
+10 -9
View File
@@ -1,15 +1,15 @@
import fs from "fs"; import fs from "node:fs";
import path from "path"; import path from "node:path";
import { glob } from "glob"; import { OllamaEmbedding } from "@llamaindex/ollama";
import * as cheerio from "cheerio"; import * as cheerio from "cheerio";
import { glob } from "glob";
import { import {
Document, Document,
VectorStoreIndex, SentenceSplitter,
Settings, Settings,
storageContextFromDefaults, storageContextFromDefaults,
SentenceSplitter, VectorStoreIndex,
} from "llamaindex"; } from "llamaindex";
import { OllamaEmbedding } from "@llamaindex/ollama";
// Configure Settings // Configure Settings
Settings.embedModel = new OllamaEmbedding({ Settings.embedModel = new OllamaEmbedding({
@@ -17,7 +17,8 @@ Settings.embedModel = new OllamaEmbedding({
}); });
const SPEC_DIR = "./spec-built/multipage"; const SPEC_DIR = "./spec-built/multipage";
const CODE_DIR = "./engine262/src"; const _CODE_DIR = "./engine262/src";
import { STORAGE_DIR } from "../constants.ts"; import { STORAGE_DIR } from "../constants.ts";
// Initialize a SentenceSplitter with even smaller chunk size // Initialize a SentenceSplitter with even smaller chunk size
@@ -34,7 +35,7 @@ async function ingestSpec() {
const content = fs.readFileSync(file, "utf-8"); const content = fs.readFileSync(file, "utf-8");
const $ = cheerio.load(content); const $ = cheerio.load(content);
$("emu-clause").each((i, elem) => { $("emu-clause").each((_i, elem) => {
const id = $(elem).attr("id"); const id = $(elem).attr("id");
const title = $(elem).find("h1").first().text().trim(); const title = $(elem).find("h1").first().text().trim();
// Only extract immediate text to avoid excessive chunking of child sections // Only extract immediate text to avoid excessive chunking of child sections
@@ -104,7 +105,7 @@ async function main() {
storageContext, storageContext,
}); });
console.log("Existing index found, continuing ingestion..."); console.log("Existing index found, continuing ingestion...");
} catch (e) { } catch (_e) {
console.log("No existing index found, starting fresh."); console.log("No existing index found, starting fresh.");
} }