context-mcp-server 1.0.5 → 1.0.7
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/README.md +99 -359
- package/codegraph/server.py +37 -46
- package/package.json +3 -2
- package/pyproject.toml +1 -1
- package/src/assests/main.png +0 -0
- package/src/cli.js +35 -8
- package/src/db.js +28 -9
- package/src/hooks/autoContext.js +1 -1
- package/src/templates/CLAUDE.md +8 -3
- package/src/templates/commands/context-resume.md +3 -1
- package/src/templates/skills/SKILL.md +9 -7
- package/src/tools/codegraph.js +12 -78
- package/src/tools/context.js +29 -9
- package/src/tools/gitTools.js +3 -4
- package/uv.lock +1 -1
- package/codegraph/extractors/audio_extractor.py +0 -8
- package/codegraph/extractors/doc_extractor.py +0 -34
- package/codegraph/extractors/image_extractor.py +0 -26
package/src/tools/gitTools.js
CHANGED
|
@@ -29,11 +29,10 @@ function resolveCwd(args, state) {
|
|
|
29
29
|
// Auto-detect project root on first use if not already configured.
|
|
30
30
|
if (!state.projectRootPath) {
|
|
31
31
|
const detected = autoDetectRoot(args.cwd ? pathResolve(args.cwd) : process.cwd());
|
|
32
|
-
|
|
32
|
+
state.projectRootPath = detected || process.cwd();
|
|
33
33
|
}
|
|
34
|
-
const raw = args.cwd ? pathResolve(args.cwd) :
|
|
35
|
-
|
|
36
|
-
return raw;
|
|
34
|
+
const raw = args.cwd ? pathResolve(args.cwd) : state.projectRootPath;
|
|
35
|
+
return guardPath(raw, state.projectRootPath);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
const ROOT_NOTE = ' All paths must be within the project root (sandboxed — access outside root is denied).';
|
package/uv.lock
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
doc_extractor.py — extract plain text from doc and PDF files.
|
|
3
|
-
PDF extraction uses pymupdf if installed; falls back to label-only otherwise.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def extract_text(path: str) -> str:
|
|
10
|
-
"""Return text content of a doc/PDF file. Truncated at DOC_MAX_CHARS."""
|
|
11
|
-
from ..config import DOC_MAX_CHARS
|
|
12
|
-
if path.lower().endswith(".pdf"):
|
|
13
|
-
return _extract_pdf(path, DOC_MAX_CHARS)
|
|
14
|
-
try:
|
|
15
|
-
return Path(path).read_text(encoding="utf-8", errors="replace")[:DOC_MAX_CHARS]
|
|
16
|
-
except OSError:
|
|
17
|
-
return ""
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _extract_pdf(path: str, max_chars: int) -> str:
|
|
21
|
-
try:
|
|
22
|
-
import pymupdf # optional dep
|
|
23
|
-
doc = pymupdf.open(path)
|
|
24
|
-
parts = []
|
|
25
|
-
for page in doc:
|
|
26
|
-
parts.append(page.get_text())
|
|
27
|
-
if sum(len(p) for p in parts) >= max_chars:
|
|
28
|
-
break
|
|
29
|
-
doc.close()
|
|
30
|
-
return "".join(parts)[:max_chars]
|
|
31
|
-
except ImportError:
|
|
32
|
-
return f"[PDF: {Path(path).name} — install pymupdf to extract text]"
|
|
33
|
-
except Exception:
|
|
34
|
-
return ""
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
image_extractor.py — encode images as base64 for AI vision.
|
|
3
|
-
No external deps — stdlib only.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import base64
|
|
7
|
-
import mimetypes
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def extract_image_b64(path: str) -> dict | None:
|
|
12
|
-
"""Return {"data": base64_str, "media_type": "image/png"} or None on failure."""
|
|
13
|
-
try:
|
|
14
|
-
data = Path(path).read_bytes()
|
|
15
|
-
media_type = mimetypes.guess_type(path)[0] or "image/png"
|
|
16
|
-
return {"data": base64.b64encode(data).decode(), "media_type": media_type}
|
|
17
|
-
except OSError:
|
|
18
|
-
return None
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def extract_svg_text(path: str) -> str:
|
|
22
|
-
"""Return SVG file as plain text (SVGs are XML — readable as-is)."""
|
|
23
|
-
try:
|
|
24
|
-
return Path(path).read_text(encoding="utf-8", errors="replace")[:4000]
|
|
25
|
-
except OSError:
|
|
26
|
-
return ""
|