yats-toolkit 0.2.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +14 -2
  2. package/benchmark/questions/go/chi/01-routing.md +1 -0
  3. package/benchmark/questions/go/chi/02-middleware.md +1 -0
  4. package/benchmark/questions/php/slim/01-routing.md +1 -0
  5. package/benchmark/questions/php/slim/02-container.md +1 -0
  6. package/benchmark/questions/python/flask/01-routing.md +1 -0
  7. package/benchmark/questions/python/flask/02-context.md +1 -0
  8. package/benchmark/questions/typescript/express/01-middleware.md +1 -0
  9. package/benchmark/questions/typescript/express/02-router.md +1 -0
  10. package/benchmark/questions/typescript/koa/01-middleware.md +1 -0
  11. package/benchmark/questions/typescript/koa/02-context.md +1 -0
  12. package/benchmark/targets/repos.json +5 -6
  13. package/package.json +1 -1
  14. package/src/benchmark.js +1352 -334
  15. package/src/bridge.js +8 -6
  16. package/src/setup.js +18 -10
  17. package/benchmark/questions/go/terraform/01-providers.md +0 -1
  18. package/benchmark/questions/go/terraform/02-graph.md +0 -1
  19. package/benchmark/questions/php/laravel/01-container.md +0 -1
  20. package/benchmark/questions/php/laravel/02-routing.md +0 -1
  21. package/benchmark/questions/php/symfony/01-dependency-injection.md +0 -1
  22. package/benchmark/questions/php/symfony/02-event-dispatcher.md +0 -1
  23. package/benchmark/questions/python/01-middleware.md +0 -8
  24. package/benchmark/questions/python/02-routing.md +0 -9
  25. package/benchmark/questions/python/django/01-middleware.md +0 -1
  26. package/benchmark/questions/python/django/01-orm.md +0 -1
  27. package/benchmark/questions/typescript/nestjs/01-decorators.md +0 -1
  28. package/benchmark/questions/typescript/nestjs/02-modules.md +0 -1
  29. package/benchmark/questions/typescript/nextjs/01-rendering.md +0 -1
  30. package/benchmark/questions/typescript/nextjs/02-routing.md +0 -1
  31. /package/benchmark/questions/go/{lab_hub → hub-lab}/01-protocol-translation.md +0 -0
  32. /package/benchmark/questions/go/{lab_hub → hub-lab}/02-bidirectional-flow.md +0 -0
package/src/bridge.js CHANGED
@@ -20,7 +20,7 @@
20
20
  import http from "node:http";
21
21
  import https from "node:https";
22
22
  import { createInterface } from "node:readline";
23
- import { basename } from "node:path";
23
+ import { basename, resolve } from "node:path";
24
24
 
25
25
  // ── Config ──────────────────────────────────────────────
26
26
  let yatsUrl = process.env.YATS_URL || "http://localhost:5555";
@@ -37,8 +37,9 @@ for (let i = 0; i < args.length; i++) {
37
37
 
38
38
  const YATS_MCP_URL = yatsUrl.endsWith("/mcp") ? yatsUrl : yatsUrl + "/mcp";
39
39
 
40
- // Default repo: env var > cwd basename
41
- const DEFAULT_REPO = process.env.YATS_DEFAULT_REPO || basename(process.cwd());
40
+ // Default repo: env var (full path) > cwd (full path). Resolved to absolute.
41
+ const DEFAULT_REPO_PATH = resolve(process.env.YATS_DEFAULT_REPO || process.cwd());
42
+ const DEFAULT_REPO_NAME = basename(DEFAULT_REPO_PATH);
42
43
 
43
44
  // Tools that require a repository parameter
44
45
  const REPO_TOOLS = new Set([
@@ -95,7 +96,7 @@ async function callTool(name, args) {
95
96
  async function start() {
96
97
  log(`Connecting to ${YATS_MCP_URL}...`);
97
98
  const tools = await fetchTools();
98
- log(`Fetched ${tools.length} tools — default repo: "${DEFAULT_REPO}"`);
99
+ log(`Fetched ${tools.length} tools — default repo: "${DEFAULT_REPO_NAME}" (${DEFAULT_REPO_PATH})`);
99
100
 
100
101
  const rl = createInterface({ input: process.stdin, terminal: false });
101
102
  let pending = 0;
@@ -141,9 +142,10 @@ async function start() {
141
142
  const toolName = params?.name;
142
143
  const toolArgs = params?.arguments || {};
143
144
 
144
- // Auto-inject repository if missing
145
+ // Auto-inject repo (full path) + name if missing
145
146
  if (REPO_TOOLS.has(toolName) && !toolArgs.repository && !toolArgs.path) {
146
- toolArgs.repository = DEFAULT_REPO;
147
+ toolArgs.path = DEFAULT_REPO_PATH;
148
+ toolArgs.repository = DEFAULT_REPO_NAME;
147
149
  }
148
150
 
149
151
  log(`call: ${toolName}(${JSON.stringify(toolArgs).slice(0, 200)})`);
package/src/setup.js CHANGED
@@ -30,6 +30,7 @@ const REPOS_DIR = join(YATS_DIR, "repos");
30
30
  const COMPOSE_FILE = join(YATS_DIR, "docker-compose.yml");
31
31
  const MCP_CONFIG_FILE = join(YATS_DIR, "mcp-config.json");
32
32
  const YATS_BIN_DIR = join(YATS_DIR, "bin");
33
+ const ENV_FILE = join(YATS_DIR, ".env");
33
34
 
34
35
  const GITHUB_COMPOSE_URL =
35
36
  "https://raw.githubusercontent.com/fvinciarelli/yats.ai/main/docker/docker-compose.yml";
@@ -89,12 +90,12 @@ const EMBEDDED_COMPOSE = `services:
89
90
  - NEO4J_USER=neo4j
90
91
  - NEO4J_PASSWORD=\${NEO4J_PASSWORD:-password}
91
92
  - QDRANT_URL=http://qdrant:6333
92
- - EMBEDDING_PROVIDER=__PROVIDER__
93
+ - EMBEDDING_PROVIDER=\${EMBEDDING_PROVIDER:-ollama}
93
94
  - OLLAMA_URL=http://ollama:11434
94
95
  - OLLAMA_MODEL=__OLLAMA_MODEL__
95
- - OPENAI_API_KEY=__OPENAI_KEY__
96
- - MISTRAL_API_KEY=__MISTRAL_KEY__
97
- - VOYAGE_API_KEY=__VOYAGE_KEY__
96
+ - OPENAI_API_KEY=\${EMBEDDING_OPENAI_API_KEY:-}
97
+ - MISTRAL_API_KEY=\${EMBEDDING_MISTRAL_API_KEY:-}
98
+ - VOYAGE_API_KEY=\${EMBEDDING_VOYAGE_API_KEY:-}
98
99
  - REPOSITORIES_PATH=/repos
99
100
  - YATS_PORT=__MCP_PORT__
100
101
  - EMBEDDING_BATCH_SIZE=__BATCH_SIZE__
@@ -331,11 +332,7 @@ function generateCompose(provider, ollamaModel, apiKey, mcpPort, batchSize, inde
331
332
  }
332
333
 
333
334
  compose = compose
334
- .replace(/__PROVIDER__/g, provider)
335
335
  .replace(/__OLLAMA_MODEL__/g, ollamaModel)
336
- .replace(/__OPENAI_KEY__/g, provider === "openai" ? apiKey : "")
337
- .replace(/__MISTRAL_KEY__/g, provider === "mistral" ? apiKey : "")
338
- .replace(/__VOYAGE_KEY__/g, provider === "voyage" ? apiKey : "")
339
336
  .replace(/__MCP_PORT__/g, String(mcpPort))
340
337
  .replace(/__BATCH_SIZE__/g, String(batchSize))
341
338
  .replace(/__INDEX_DOCS__/g, indexDocs ? "true" : "false")
@@ -418,8 +415,8 @@ async function main(options = {}) {
418
415
  const env = loadEnv();
419
416
  const nonInteractive = options.nonInteractive || false;
420
417
  const prefill = {
421
- provider: options.provider || env.YATS_PROVIDER || null,
422
- apiKey: options.apiKey || env.OPENAI_API_KEY || env.MISTRAL_API_KEY || env.VOYAGE_API_KEY || null,
418
+ provider: options.provider || env.YATS_PROVIDER || env.EMBEDDING_PROVIDER || null,
419
+ apiKey: options.apiKey || env.EMBEDDING_OPENAI_API_KEY || env.EMBEDDING_MISTRAL_API_KEY || env.EMBEDDING_VOYAGE_API_KEY || null,
423
420
  port: options.port ? parseInt(options.port, 10) : null,
424
421
  batch: options.batch ? parseInt(options.batch, 10) : null,
425
422
  noDocs: options.noDocs || false,
@@ -713,6 +710,16 @@ async function main(options = {}) {
713
710
  const mcpConfig = { mcpServers: { yats: { url: `http://localhost:${mcpPort}/mcp/sse` } } };
714
711
  writeFileSync(MCP_CONFIG_FILE, JSON.stringify(mcpConfig, null, 2));
715
712
 
713
+ // Persist keys to ~/.yats/.env — canonical source (embedding + benchmark keys).
714
+ // Merge with any keys the user already added (e.g. ANTHROPIC_API_KEY, GEMINI_API_KEY).
715
+ const envMap = loadEnv();
716
+ envMap.EMBEDDING_PROVIDER = provider;
717
+ envMap.YATS_PROVIDER = provider;
718
+ if (provider === "openai" && apiKey) envMap.EMBEDDING_OPENAI_API_KEY = apiKey;
719
+ if (provider === "mistral" && apiKey) envMap.EMBEDDING_MISTRAL_API_KEY = apiKey;
720
+ if (provider === "voyage" && apiKey) envMap.EMBEDDING_VOYAGE_API_KEY = apiKey;
721
+ writeFileSync(ENV_FILE, Object.entries(envMap).map(([k, v]) => `${k}=${v}`).join("\n") + "\n");
722
+
716
723
  // Pull the YATS Docker image from GitHub Container Registry
717
724
  const sPull = spinner("Pulling YATS image from registry...");
718
725
  try {
@@ -827,6 +834,7 @@ async function main(options = {}) {
827
834
  console.log(` ✅ ${G}YATS is ready!${R} → ${C}http://localhost:${mcpPort}/mcp/sse${R}`);
828
835
  console.log("");
829
836
  console.log(` Config saved to ${C}~/.yats/.env${R}`);
837
+ console.log(` ${D}Benchmark agent keys (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY) go there too.${R}`);
830
838
  console.log("");
831
839
  box([
832
840
  `${B}Copy this URL into your AI agent:${R}`,
@@ -1 +0,0 @@
1
- How does Terraform's provider system work? Find how providers are registered, configured, and how the plugin system operates.
@@ -1 +0,0 @@
1
- How does Terraform build and walk the dependency graph? Find the graph construction and traversal algorithms.
@@ -1 +0,0 @@
1
- How does Laravel's service container work? Find the binding resolution, contextual binding, and automatic injection.
@@ -1 +0,0 @@
1
- How does Laravel handle HTTP routing? Find the route registration, middleware pipeline, and controller dispatch.
@@ -1 +0,0 @@
1
- How does Symfony's dependency injection container work? Find the compiled container, service definitions, and autowiring.
@@ -1 +0,0 @@
1
- How does Symfony's event dispatcher work? Find how events are registered, dispatched, and how listeners/subscribers are resolved.
@@ -1,8 +0,0 @@
1
- ## Question: How does middleware work in FastAPI?
2
-
3
- Find and explain the middleware stack: how middleware is registered, in what order it executes, and what built-in middleware FastAPI provides.
4
-
5
- ### Expected answer should cover:
6
- - The `build_middleware_stack` method in `fastapi/applications.py`
7
- - Order: ServerErrorMiddleware → user middleware → ExceptionMiddleware → AsyncExitStackMiddleware
8
- - How `@app.middleware("http")` registers custom middleware
@@ -1,9 +0,0 @@
1
- ## Question: How is routing implemented in FastAPI?
2
-
3
- Trace how HTTP routes are registered, stored, and dispatched. Find the key classes and methods involved.
4
-
5
- ### Expected answer should cover:
6
- - `APIRouter` class and its `add_api_route` method
7
- - How decorators like `@app.get("/path")` register routes
8
- - The relationship between `Route`, `APIRoute`, and path operations
9
- - How dependencies are injected into route handlers
@@ -1 +0,0 @@
1
- How does Django's middleware system work? Find the middleware chain and how request/response processing flows through it.
@@ -1 +0,0 @@
1
- How does Django's ORM work? Trace how a model query like `User.objects.filter(name="John")` gets translated to SQL and executed.
@@ -1 +0,0 @@
1
- How does NestJS use decorators for dependency injection and route registration? Find the key decorator implementations.
@@ -1 +0,0 @@
1
- How does NestJS module system work? Trace how modules are defined, imported, and how providers are resolved across module boundaries.
@@ -1 +0,0 @@
1
- How does Next.js handle server-side rendering vs static generation? Find the key functions and components involved.
@@ -1 +0,0 @@
1
- How does Next.js file-based routing work? Find the routing implementation and how dynamic routes are resolved.