nimai-core 0.1.0 → 0.1.2
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.
- package/LICENSE +21 -0
- package/dist/context.js +23 -5
- package/dist/context.js.map +1 -1
- package/package.json +21 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Balagopalaji
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/context.js
CHANGED
|
@@ -38,7 +38,7 @@ const fs = __importStar(require("fs"));
|
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const MAX_FILES = 20;
|
|
40
40
|
const INCLUDE_EXTENSIONS = new Set(['.ts', '.js', '.md', '.json', '.yaml', '.yml']);
|
|
41
|
-
const EXCLUDE_DIRS = new Set(['node_modules', '.git', 'dist', '.next', '__pycache__']);
|
|
41
|
+
const EXCLUDE_DIRS = new Set(['node_modules', '.git', 'dist', '.next', '__pycache__', 'tmp', '.tmp', 'coverage', '.cache', 'build', 'out']);
|
|
42
42
|
const MAX_SNIPPET_CHARS = 2000;
|
|
43
43
|
function extractContext(repoPath, request) {
|
|
44
44
|
const keywords = tokenize(request);
|
|
@@ -74,9 +74,9 @@ function walkDir(rootPath, currentPath, results, keywords) {
|
|
|
74
74
|
catch {
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const relPath = path.relative(rootPath, fullPath);
|
|
78
|
+
const relevance = scoreRelevance(entry.name, content, keywords, relPath);
|
|
78
79
|
if (relevance > 0) {
|
|
79
|
-
const relPath = path.relative(rootPath, fullPath);
|
|
80
80
|
results.push({
|
|
81
81
|
file: relPath,
|
|
82
82
|
snippet: content.slice(0, MAX_SNIPPET_CHARS),
|
|
@@ -86,11 +86,29 @@ function walkDir(rootPath, currentPath, results, keywords) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
// Source dirs score higher than docs/examples/schemas
|
|
90
|
+
const SOURCE_DIR_PATTERNS = ['src/', 'lib/', 'app/', 'server/', 'api/'];
|
|
91
|
+
const DOCS_DIR_PATTERNS = ['docs/', 'examples/', 'schemas/'];
|
|
92
|
+
function scoreRelevance(filename, content, keywords, relPath) {
|
|
90
93
|
if (keywords.length === 0)
|
|
91
94
|
return 1;
|
|
92
95
|
const lower = (filename + ' ' + content).toLowerCase();
|
|
93
|
-
|
|
96
|
+
const keywordScore = keywords.filter(k => lower.includes(k)).length;
|
|
97
|
+
if (keywordScore === 0)
|
|
98
|
+
return 0;
|
|
99
|
+
// Filename boost: if the filename itself matches a keyword, it's likely the most relevant file
|
|
100
|
+
const filenameLower = filename.toLowerCase().replace(/\.[^.]+$/, '');
|
|
101
|
+
const filenameBoost = keywords.some(k => filenameLower.includes(k)) ? 2 : 0;
|
|
102
|
+
// Path boost: source files score higher than docs/examples
|
|
103
|
+
let pathBoost = 0;
|
|
104
|
+
if (relPath) {
|
|
105
|
+
const rel = relPath.toLowerCase();
|
|
106
|
+
if (SOURCE_DIR_PATTERNS.some(p => rel.startsWith(p)))
|
|
107
|
+
pathBoost = 1;
|
|
108
|
+
if (DOCS_DIR_PATTERNS.some(p => rel.startsWith(p)))
|
|
109
|
+
pathBoost = -1;
|
|
110
|
+
}
|
|
111
|
+
return keywordScore + filenameBoost + pathBoost;
|
|
94
112
|
}
|
|
95
113
|
function tokenize(request) {
|
|
96
114
|
return request
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wCASC;AAlBD,uCAAyB;AACzB,2CAA6B;AAG7B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACpF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,wCASC;AAlBD,uCAAyB;AACzB,2CAA6B;AAG7B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,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AAC,CAAC;AAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nimai-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Nimai core library — template loading, lint engine, context extraction. No LLM dependencies.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nimai",
|
|
7
|
+
"forge",
|
|
8
|
+
"spec",
|
|
9
|
+
"lint",
|
|
10
|
+
"ai",
|
|
11
|
+
"llm",
|
|
12
|
+
"specification",
|
|
13
|
+
"template"
|
|
14
|
+
],
|
|
6
15
|
"license": "MIT",
|
|
7
16
|
"repository": {
|
|
8
17
|
"type": "git",
|
|
9
18
|
"url": "https://github.com/Balagopalaji/nimai.git",
|
|
10
19
|
"directory": "packages/core"
|
|
11
20
|
},
|
|
12
|
-
"files": [
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/"
|
|
23
|
+
],
|
|
13
24
|
"main": "dist/index.js",
|
|
14
25
|
"types": "dist/index.d.ts",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "tsc",
|
|
17
|
-
"test": "vitest run",
|
|
18
|
-
"dev": "tsc --watch",
|
|
19
|
-
"clean": "rm -rf dist"
|
|
20
|
-
},
|
|
21
26
|
"devDependencies": {
|
|
22
27
|
"@types/node": "^22.0.0",
|
|
23
28
|
"typescript": "^5.4.5",
|
|
@@ -25,5 +30,11 @@
|
|
|
25
30
|
},
|
|
26
31
|
"dependencies": {
|
|
27
32
|
"zod": "^3.23.8"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"dev": "tsc --watch",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
28
39
|
}
|
|
29
|
-
}
|
|
40
|
+
}
|