auigrid-mcp-server 0.1.1 → 0.2.0

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.
@@ -1,52 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
- const indexPath = path.resolve(__dirname, "../../data/samples-index.json");
6
- let entries = [];
7
- try {
8
- entries = JSON.parse(fs.readFileSync(indexPath, "utf-8"));
9
- }
10
- catch (err) {
11
- console.error(`Failed to load samples index at ${indexPath}. Run "npm run build:samples-index" first.`, err);
12
- }
13
- function snippetAround(content, query, contextLines = 3) {
14
- const lines = content.split("\n");
15
- const q = query.toLowerCase();
16
- const hitIdx = lines.findIndex((l) => l.toLowerCase().includes(q));
17
- if (hitIdx === -1)
18
- return lines.slice(0, contextLines * 2).join("\n");
19
- const start = Math.max(0, hitIdx - contextLines);
20
- const end = Math.min(lines.length, hitIdx + contextLines + 1);
21
- return lines.slice(start, end).join("\n");
22
- }
23
- export function searchSamples(query, limit = 10) {
24
- const q = query.toLowerCase();
25
- const matches = entries.filter((e) => e.name.toLowerCase().includes(q) ||
26
- e.category.toLowerCase().includes(q) ||
27
- e.content.toLowerCase().includes(q));
28
- matches.sort((a, b) => {
29
- const aNameHit = a.name.toLowerCase().includes(q) ? 0 : 1;
30
- const bNameHit = b.name.toLowerCase().includes(q) ? 0 : 1;
31
- return aNameHit - bNameHit;
32
- });
33
- return matches.slice(0, limit).map((e) => ({
34
- name: e.name,
35
- framework: e.framework,
36
- category: e.category,
37
- relPath: e.relPath,
38
- snippet: snippetAround(e.content, query),
39
- }));
40
- }
41
- export function getSample(name) {
42
- const lower = name.toLowerCase();
43
- return entries.filter((e) => e.name.toLowerCase() === lower);
44
- }
45
- export function listSamples() {
46
- return entries.map(({ name, framework, category, relPath }) => ({
47
- name,
48
- framework,
49
- category,
50
- relPath,
51
- }));
52
- }
@@ -1,29 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
- const indexPath = path.resolve(__dirname, "../../data/static-utils-index.json");
6
- let entries = [];
7
- try {
8
- entries = JSON.parse(fs.readFileSync(indexPath, "utf-8"));
9
- }
10
- catch (err) {
11
- console.error(`Failed to load static utils index at ${indexPath}. Run "npm run build:static-utils-index" first.`, err);
12
- }
13
- export function searchStaticUtils(query, limit = 15) {
14
- const q = query.toLowerCase();
15
- const results = entries.filter((e) => e.name.toLowerCase().includes(q) || e.description.toLowerCase().includes(q));
16
- results.sort((a, b) => {
17
- const aExact = a.name.toLowerCase() === q ? 0 : 1;
18
- const bExact = b.name.toLowerCase() === q ? 0 : 1;
19
- return aExact - bExact;
20
- });
21
- return results.slice(0, limit);
22
- }
23
- export function getStaticUtil(name) {
24
- const lower = name.toLowerCase();
25
- return entries.find((e) => e.name.toLowerCase() === lower);
26
- }
27
- export function listStaticUtils() {
28
- return entries;
29
- }