diff --git a/AGENTS.md b/AGENTS.md index 47d49c3..0b8528f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,26 +21,27 @@ Users ask questions like: *"How does the if statement work?"* or *"Which functio ``` ask262/ -├── agent.ts # Main ReAct agent - answers user queries -├── agent-tools/ # Tool implementations (spec retriever, graph explorer) -│ ├── index.ts # Tool exports -│ ├── specRetriever.ts # Vector search tool -│ ├── sectionRetriever.ts # Section chunk retrieval tool -│ ├── graphExplorer.ts # Knowledge graph navigation tool -│ └── reranker.ts # Document reranking utility -├── constants.ts # Directory paths and model configs +├── src/ +│ ├── agent.ts # Main ReAct agent - answers user queries +│ ├── constants.ts # Directory paths and model configs +│ ├── agent-tools/ # Tool implementations (spec retriever, graph explorer) +│ │ ├── index.ts # Tool exports +│ │ ├── specRetriever.ts # Vector search tool +│ │ ├── sectionRetriever.ts # Section chunk retrieval tool +│ │ ├── graphExplorer.ts # Knowledge graph navigation tool +│ │ └── reranker.ts # Document reranking utility +│ └── setup/ # Data ingestion and graph building +│ ├── ingest.ts # Ingests spec HTML into vector index +│ ├── buildGraph.ts # Builds knowledge graph +│ ├── stripSpecContainer.ts # Cleans spec HTML files +│ ├── htmlAddInternalMethodLink.ts # Adds internal method links +│ ├── text-splitters/ # Text chunking utilities +│ └── utils/ # Formatting utilities +│ └── test/ # Manual verification tests +│ └── manual/ +│ ├── verify-db.ts # Verify database contents +│ └── test-spec-retriever.ts ├── config.json # API keys and endpoints (user-created) -├── setup/ # Data ingestion and graph building -│ ├── ingest.ts # Ingests spec HTML into vector index -│ ├── buildGraph.ts # Builds knowledge graph -│ ├── stripSpecContainer.ts # Cleans spec HTML files -│ ├── htmlAddInternalMethodLink.ts # Adds internal method links -│ ├── text-splitters/ # Text chunking utilities -│ └── utils/ # Formatting utilities -├── test/ # Manual verification tests -│ ├── manual/ -│ │ ├── verify-db.ts # Verify database contents -│ │ └── test-spec-retriever.ts ├── spec-built/multipage/ # ECMAScript spec HTML files ├── engine262/src/ # JavaScript engine implementation ├── storage/ # Vector index persistence (LanceDB) diff --git a/package.json b/package.json index 7ef3447..45c1108 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "lint:fix": "biome check . --write", "lint:fix:unsafe": "biome check . --write --unsafe", "format:fix": "biome format . --write", - "ingest": "bun run setup/ingest.ts", - "verify-db": "bun run test/manual/verify-db.ts", - "agent": "bun run agent.ts", - "build": "bun run setup/buildGraph.ts", + "ingest": "bun run src/setup/ingest.ts", + "verify-db": "bun run src/test/manual/verify-db.ts", + "agent": "bun run src/agent.ts", + "build": "bun run src/setup/buildGraph.ts", "test": "bun test" }, "keywords": [], diff --git a/agent-tools/graphExplorer.ts b/src/agent-tools/graphExplorer.ts similarity index 100% rename from agent-tools/graphExplorer.ts rename to src/agent-tools/graphExplorer.ts diff --git a/agent-tools/index.ts b/src/agent-tools/index.ts similarity index 100% rename from agent-tools/index.ts rename to src/agent-tools/index.ts diff --git a/agent-tools/reranker.ts b/src/agent-tools/reranker.ts similarity index 100% rename from agent-tools/reranker.ts rename to src/agent-tools/reranker.ts diff --git a/agent-tools/sectionRetriever.ts b/src/agent-tools/sectionRetriever.ts similarity index 100% rename from agent-tools/sectionRetriever.ts rename to src/agent-tools/sectionRetriever.ts diff --git a/agent-tools/specRetriever.ts b/src/agent-tools/specRetriever.ts similarity index 100% rename from agent-tools/specRetriever.ts rename to src/agent-tools/specRetriever.ts diff --git a/agent.ts b/src/agent.ts similarity index 95% rename from agent.ts rename to src/agent.ts index e9430d7..766896e 100644 --- a/agent.ts +++ b/src/agent.ts @@ -11,13 +11,18 @@ import { createSectionRetrieverTool, createSpecRetrieverTool, } from "./agent-tools"; -import { EMBEDDING_MODEL, GRAPH_FILE, STORAGE_DIR } from "./constants"; +import { + CONFIG_FILE, + EMBEDDING_MODEL, + GRAPH_FILE, + STORAGE_DIR, +} from "./constants"; const embeddings = new OllamaEmbeddings({ model: EMBEDDING_MODEL, }); -const config = JSON.parse(fs.readFileSync("./config.json", "utf-8")); +const config = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8")); const apiKey = config.NVIDIA_API_KEY; const baseURL = config.NVIDIA_API_BASE; diff --git a/constants.ts b/src/constants.ts similarity index 88% rename from constants.ts rename to src/constants.ts index 124407e..597dbd8 100644 --- a/constants.ts +++ b/src/constants.ts @@ -2,6 +2,7 @@ export const STORAGE_DIR = "./storage"; export const SPEC_DIR = "./spec-built/multipage"; export const CODE_DIR = "./engine262/src"; export const GRAPH_FILE = "./graphology/graph.json"; +export const CONFIG_FILE = "./config.json"; // Model configurations export const EMBEDDING_MODEL = "qwen3-embedding:0.6b"; diff --git a/setup/buildGraph.ts b/src/setup/buildGraph.ts similarity index 100% rename from setup/buildGraph.ts rename to src/setup/buildGraph.ts diff --git a/setup/htmlAddInternalMethodLink.ts b/src/setup/htmlAddInternalMethodLink.ts similarity index 100% rename from setup/htmlAddInternalMethodLink.ts rename to src/setup/htmlAddInternalMethodLink.ts diff --git a/setup/ingest.ts b/src/setup/ingest.ts similarity index 100% rename from setup/ingest.ts rename to src/setup/ingest.ts diff --git a/setup/initEngine262.sh b/src/setup/initEngine262.sh similarity index 100% rename from setup/initEngine262.sh rename to src/setup/initEngine262.sh diff --git a/setup/stripSpecContainer.ts b/src/setup/stripSpecContainer.ts similarity index 100% rename from setup/stripSpecContainer.ts rename to src/setup/stripSpecContainer.ts diff --git a/setup/text-splitters/HtmlTextSplitter.test.ts b/src/setup/text-splitters/HtmlTextSplitter.test.ts similarity index 100% rename from setup/text-splitters/HtmlTextSplitter.test.ts rename to src/setup/text-splitters/HtmlTextSplitter.test.ts diff --git a/setup/text-splitters/HtmlTextSplitter.ts b/src/setup/text-splitters/HtmlTextSplitter.ts similarity index 100% rename from setup/text-splitters/HtmlTextSplitter.ts rename to src/setup/text-splitters/HtmlTextSplitter.ts diff --git a/setup/text-splitters/index.ts b/src/setup/text-splitters/index.ts similarity index 100% rename from setup/text-splitters/index.ts rename to src/setup/text-splitters/index.ts diff --git a/setup/utils/formatHTMLForIngestion.test.ts b/src/setup/utils/formatHTMLForIngestion.test.ts similarity index 100% rename from setup/utils/formatHTMLForIngestion.test.ts rename to src/setup/utils/formatHTMLForIngestion.test.ts diff --git a/setup/utils/formatHTMLForIngestion.ts b/src/setup/utils/formatHTMLForIngestion.ts similarity index 100% rename from setup/utils/formatHTMLForIngestion.ts rename to src/setup/utils/formatHTMLForIngestion.ts diff --git a/test/manual/test-spec-retriever.ts b/src/test/manual/test-spec-retriever.ts similarity index 93% rename from test/manual/test-spec-retriever.ts rename to src/test/manual/test-spec-retriever.ts index 0a54ea1..c221e40 100644 --- a/test/manual/test-spec-retriever.ts +++ b/src/test/manual/test-spec-retriever.ts @@ -1,6 +1,6 @@ /** * Manual test script for spec_retriever agent tool - * Usage: bun run test/manual/test-spec-retriever.ts "your search query" + * Usage: bun run src/test/manual/test-spec-retriever.ts "your search query" */ import * as lancedbSdk from "@lancedb/lancedb"; diff --git a/test/manual/verify-db.ts b/src/test/manual/verify-db.ts similarity index 93% rename from test/manual/verify-db.ts rename to src/test/manual/verify-db.ts index a90b820..ab52558 100644 --- a/test/manual/verify-db.ts +++ b/src/test/manual/verify-db.ts @@ -3,17 +3,17 @@ * Manual verification script for inspecting LanceDB documents/chunks. * * Usage: - * bun run test/manual/verify-db.ts # Show summary (default command) - * bun run test/manual/verify-db.ts summary # Show database summary - * bun run test/manual/verify-db.ts list # List all sections - * bun run test/manual/verify-db.ts section # Show chunks for a section - * bun run test/manual/verify-db.ts search "query" # Search by vector similarity (semantic search) - * bun run test/manual/verify-db.ts tree # Show full section hierarchy - * bun run test/manual/verify-db.ts tree sec-ecmascript-language-source-code # Show subtree from section - * bun run test/manual/verify-db.ts sample # Show random samples - * bun run test/manual/verify-db.ts large # Show large documents - * bun run test/manual/verify-db.ts --help # Show help - * bun run test/manual/verify-db.ts --help # Show help for specific command + * bun run src/test/manual/verify-db.ts # Show summary (default command) + * bun run src/test/manual/verify-db.ts summary # Show database summary + * bun run src/test/manual/verify-db.ts list # List all sections + * bun run src/test/manual/verify-db.ts section # Show chunks for a section + * bun run src/test/manual/verify-db.ts search "query" # Search by vector similarity (semantic search) + * bun run src/test/manual/verify-db.ts tree # Show full section hierarchy + * bun run src/test/manual/verify-db.ts tree sec-ecmascript-language-source-code # Show subtree from section + * bun run src/test/manual/verify-db.ts sample # Show random samples + * bun run src/test/manual/verify-db.ts large # Show large documents + * bun run src/test/manual/verify-db.ts --help # Show help + * bun run src/test/manual/verify-db.ts --help # Show help for specific command */ import fs from "node:fs";