@datasynx/agentic-ai-cartography 1.1.1 → 2.0.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.
Files changed (50) hide show
  1. package/README.md +197 -33
  2. package/dist/bookmarks-VS56KVCO.js +25 -0
  3. package/dist/chunk-CJ2PITFA.js +785 -0
  4. package/dist/chunk-CJ2PITFA.js.map +1 -0
  5. package/dist/chunk-D6SRSLBF.js +48 -0
  6. package/dist/{chunk-WJR63RWY.js → chunk-J6FDZ6HZ.js} +11 -2
  7. package/dist/chunk-J6FDZ6HZ.js.map +1 -0
  8. package/dist/chunk-UGSNG3QJ.js +49 -0
  9. package/dist/chunk-UGSNG3QJ.js.map +1 -0
  10. package/dist/chunk-W7YE6AAH.js +1516 -0
  11. package/dist/chunk-W7YE6AAH.js.map +1 -0
  12. package/dist/cli.js +133 -664
  13. package/dist/cli.js.map +1 -1
  14. package/dist/index.cjs +60115 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +734 -0
  17. package/dist/index.d.ts +363 -7
  18. package/dist/index.js +1462 -161
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp-bin.js +33 -0
  21. package/dist/mcp-bin.js.map +1 -0
  22. package/dist/onnxruntime_binding-6Q6HXASN.node +0 -0
  23. package/dist/onnxruntime_binding-EKZT2NRK.node +0 -0
  24. package/dist/onnxruntime_binding-P6S7V3CI.node +0 -0
  25. package/dist/onnxruntime_binding-PJNNIIUO.node +0 -0
  26. package/dist/onnxruntime_binding-UN6SPTQK.node +0 -0
  27. package/dist/sdk-A6NLO3DJ.js +12294 -0
  28. package/dist/sdk-A6NLO3DJ.js.map +1 -0
  29. package/dist/sdk-G5D4WQZ4.js +12293 -0
  30. package/dist/sdk-G5D4WQZ4.js.map +1 -0
  31. package/dist/sdk-QSTAREST.js +4869 -0
  32. package/dist/sdk-QSTAREST.js.map +1 -0
  33. package/dist/sqlite-vec-EZN67B2V.js +40 -0
  34. package/dist/sqlite-vec-EZN67B2V.js.map +1 -0
  35. package/dist/sqlite-vec-UK5YYE5T.js +39 -0
  36. package/dist/sqlite-vec-UK5YYE5T.js.map +1 -0
  37. package/dist/transformers.node-BTYUTJK5.js +42884 -0
  38. package/dist/transformers.node-BTYUTJK5.js.map +1 -0
  39. package/dist/transformers.node-J6PRTTOX.js +42883 -0
  40. package/dist/transformers.node-J6PRTTOX.js.map +1 -0
  41. package/dist/{types-54623ALF.js → types-JG27FR3E.js} +5 -2
  42. package/dist/types-JG27FR3E.js.map +1 -0
  43. package/package.json +51 -16
  44. package/server.json +28 -0
  45. package/dist/bookmarks-BWNVQGPG.js +0 -14
  46. package/dist/chunk-QKNYI3SU.js +0 -459
  47. package/dist/chunk-QKNYI3SU.js.map +0 -1
  48. package/dist/chunk-WJR63RWY.js.map +0 -1
  49. /package/dist/{bookmarks-BWNVQGPG.js.map → bookmarks-VS56KVCO.js.map} +0 -0
  50. /package/dist/{types-54623ALF.js.map → chunk-D6SRSLBF.js.map} +0 -0
package/README.md CHANGED
@@ -9,13 +9,17 @@
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
10
10
  [![Node.js >=20](https://img.shields.io/badge/Node.js-%E2%89%A520-339933?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org)
11
11
  [![CI](https://github.com/datasynx/agentic-ai-cartography/actions/workflows/ci.yml/badge.svg)](https://github.com/datasynx/agentic-ai-cartography/actions/workflows/ci.yml)
12
- [![Built with Claude](https://img.shields.io/badge/Built_with-Claude_Agent_SDK-D4A017?style=flat-square&logo=anthropic&logoColor=white)](https://github.com/anthropics/claude-code)
12
+ [![Release](https://github.com/datasynx/agentic-ai-cartography/actions/workflows/release.yml/badge.svg)](https://github.com/datasynx/agentic-ai-cartography/actions/workflows/release.yml)
13
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
14
+ [![MCP](https://img.shields.io/badge/MCP-server-6E56CF?style=flat-square)](https://modelcontextprotocol.io)
15
+ [![Provenance](https://img.shields.io/badge/npm-provenance_signed-3B7DBD?style=flat-square&logo=npm&logoColor=white)](https://docs.npmjs.com/generating-provenance-statements)
16
+ [![Agentic AI](https://img.shields.io/badge/Agentic_AI-Provider_Agnostic-D4A017?style=flat-square)](https://github.com/datasynx/agentic-ai-cartography)
13
17
  [![LinkedIn](https://img.shields.io/badge/LinkedIn-Datasynx_AI-0077B5?style=flat-square&logo=linkedin&logoColor=white)](https://www.linkedin.com/company/datasynx-ai/)
14
18
  [![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-blue?style=flat-square)](https://github.com/datasynx/agentic-ai-cartography)
15
19
 
16
20
  <br/>
17
21
 
18
- *Claude IS the agent it decides which read-only commands to run, analyses the output, and stores results via custom MCP tools into SQLite. No hand-written parsers, diff logic, or decision trees.*
22
+ *A **Model Context Protocol server** that gives any AI agent read-only awareness of your complete system landscape — local services, databases, SaaS tools, installed apps and their dependencies with progressive disclosure, recursive dependency traversal and semantic search. Discovery runs deterministically (no LLM required) or via an optional Claude-driven loop. Provider-agnostic: works with Claude, OpenAI, Ollama, or any MCP-compatible host.*
19
23
 
20
24
  <br/>
21
25
 
@@ -25,6 +29,107 @@
25
29
 
26
30
  ---
27
31
 
32
+ ## Contents
33
+
34
+ [MCP-first quick start](#-mcp-first--install-once-every-agent-knows-your-landscape) ·
35
+ [Connect your client](#connect-your-client-copy-paste) ·
36
+ [Embed in your app](#embed-in-your-own-app) ·
37
+ [What it does](#what-it-does) ·
38
+ [Cross-platform](#cross-platform-support) ·
39
+ [Features](#features) ·
40
+ [CLI commands](#commands) ·
41
+ [Architecture](#architecture) ·
42
+ [Safety](#safety) ·
43
+ [Public API](#public-api) ·
44
+ [Releasing](#releasing)
45
+
46
+ ---
47
+
48
+ ## 🤖 MCP-first — install once, every agent knows your landscape
49
+
50
+ > **v2.0** inverts the architecture: the package's primary interface is now a
51
+ > production **Model Context Protocol (MCP) server**. Any MCP host — Claude Code,
52
+ > Cursor, Cline, Windsurf, VS Code Copilot, the Vercel AI SDK, LangGraph — connects
53
+ > to it and gains read-only awareness of your complete system landscape. The bundled
54
+ > Claude-driven discovery loop is now one optional turnkey adapter; the server needs
55
+ > **no LLM dependency of its own**.
56
+
57
+ The topology is exposed with **progressive disclosure** so agents never blow their
58
+ context window:
59
+
60
+ - **Resources** (read-only context): `cartography://graph/summary` (low-token index — read first), `cartography://nodes/{id}`, `cartography://services`, `cartography://databases`, `cartography://dependencies/{id}`.
61
+ - **Tools** (parameterized queries): `query_infrastructure`, `search_topology` (semantic), `get_dependencies` (recursive graph traversal), `list_services`, `get_node`, `get_summary`, `run_discovery`.
62
+ - **Prompts**: `audit-attack-surface`, `map-service-dependencies`, `onboard-to-system`.
63
+
64
+ ### Quick start
65
+
66
+ ```bash
67
+ # 1. Discover your system (read-only, deterministic — no LLM required)
68
+ npx -p @datasynx/agentic-ai-cartography cartography-mcp --help
69
+ datasynx-cartography discover # or the richer Claude-driven loop
70
+
71
+ # 2. Run the MCP server (stdio by default)
72
+ npx -p @datasynx/agentic-ai-cartography cartography-mcp
73
+ ```
74
+
75
+ ### Connect your client (copy-paste)
76
+
77
+ **Claude Code**
78
+ ```bash
79
+ claude mcp add cartography -- npx -p @datasynx/agentic-ai-cartography cartography-mcp
80
+ ```
81
+
82
+ **Cursor / Windsurf / Cline** — `mcp.json` (or `~/.codeium/windsurf/mcp_config.json`):
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "cartography": {
87
+ "command": "npx",
88
+ "args": ["-p", "@datasynx/agentic-ai-cartography", "cartography-mcp"]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ **VS Code (Copilot)** — `.vscode/mcp.json` (note: `servers`, not `mcpServers`):
95
+ ```json
96
+ {
97
+ "servers": {
98
+ "cartography": { "command": "npx", "args": ["-p", "@datasynx/agentic-ai-cartography", "cartography-mcp"] }
99
+ }
100
+ }
101
+ ```
102
+
103
+ **Remote / team use** — Streamable HTTP (localhost-bound, DNS-rebind protected):
104
+ ```bash
105
+ cartography-mcp --http --port 3737 # → http://127.0.0.1:3737/mcp
106
+ ```
107
+
108
+ **Vercel AI SDK** (provider-agnostic):
109
+ ```ts
110
+ import { experimental_createMCPClient } from 'ai';
111
+ const mcp = await experimental_createMCPClient({
112
+ transport: { type: 'sse', url: 'http://127.0.0.1:3737/mcp' },
113
+ });
114
+ const tools = await mcp.tools(); // MCP tools → AI SDK tools, any model
115
+ ```
116
+
117
+ ### Embed in your own app
118
+
119
+ ```ts
120
+ import { createMcpServer, runStdio, createSemanticSearch, localDiscoveryFn, CartographyDB } from '@datasynx/agentic-ai-cartography';
121
+
122
+ const db = new CartographyDB('/path/to/cartography.db');
123
+ const server = createMcpServer({
124
+ db,
125
+ search: await createSemanticSearch(db), // semantic (sqlite-vec) + lexical fallback
126
+ discovery: localDiscoveryFn(), // deterministic, LLM-free scanners
127
+ });
128
+ await runStdio(server);
129
+ ```
130
+
131
+ ---
132
+
28
133
  ## What it does
29
134
 
30
135
  ```
@@ -68,7 +173,7 @@ Cartography runs natively on **Linux**, **macOS**, and **Windows** — no WSL re
68
173
  | **DB service detection** | CLI probes (psql, mysql, etc.) | CLI probes | `Get-Service` + CLI probes |
69
174
  | **Browser bookmarks** | `~/.config/google-chrome` + Snap/Flatpak | `~/Library/Application Support/...` | `%LOCALAPPDATA%\Google\Chrome\User Data` |
70
175
  | **Firefox profiles** | `~/.mozilla/firefox` + Snap/Flatpak | `~/Library/.../Firefox/Profiles` | `%APPDATA%\Mozilla\Firefox\Profiles` |
71
- | **Safety hook** | Blocks `rm`, `mv`, `kill`, etc. | Blocks `rm`, `mv`, `kill`, etc. | Blocks `Remove-Item`, `Stop-Process`, etc. |
176
+ | **Safety policy** | Read-only **allowlist** (POSIX parser) | Read-only **allowlist** (POSIX parser) | Read-only allowlist (PowerShell mutating-cmdlet denylist) |
72
177
 
73
178
  ---
74
179
 
@@ -82,19 +187,20 @@ Cartography runs natively on **Linux**, **macOS**, and **Windows** — no WSL re
82
187
  | **Cloud Scanning** | AWS (EC2/RDS/EKS/S3), GCP (Compute/GKE/Cloud Run), Azure (AKS/WebApps), Kubernetes |
83
188
  | **Human-in-the-Loop** | Chat with the agent mid-discovery: type `"hubspot windsurf"` to search for specific tools |
84
189
  | **Export Formats** | Mermaid topology, D3.js interactive graph, Backstage YAML, JSON |
85
- | **Safety First** | `PreToolUse` hook blocks all destructive commands — Unix AND PowerShell. 100% read-only |
190
+ | **Safety First** | Strict read-only **allowlist** (not a denylist): only known-safe commands run shell-aware for POSIX *and* PowerShell, enforced at the command runner as defense-in-depth. 100% read-only |
86
191
 
87
192
  ---
88
193
 
89
194
  ## Requirements
90
195
 
91
- - **Node.js >= 20** (Linux, macOS, or Windows)
92
- - **Claude CLI** the Agent SDK starts it as a subprocess
93
-
94
- ```bash
95
- npm install -g @anthropic-ai/claude-code
96
- claude login
97
- ```
196
+ - **Node.js >= 20** (Linux, macOS, or Windows) — that's it for the MCP server and the
197
+ deterministic, read-only discovery. **No LLM and no API key required.**
198
+ - **Optional — Claude CLI**, only for the richer Claude-driven discovery loop
199
+ (`datasynx-cartography discover`): `npm install -g @anthropic-ai/claude-code && claude login`.
200
+ - **Optional — semantic search** auto-upgrades when `sqlite-vec` and a local embedder
201
+ (`@huggingface/transformers`) are present; otherwise it falls back to lexical search.
202
+ These ship as `optionalDependencies` and are lazy-loaded, so installs that skip them
203
+ pay no cost.
98
204
 
99
205
  ---
100
206
 
@@ -114,7 +220,7 @@ npm install -g @datasynx/agentic-ai-cartography
114
220
  # Check all requirements (platform-aware)
115
221
  datasynx-cartography doctor
116
222
 
117
- # Discover your full infrastructure (one-shot, Claude Sonnet)
223
+ # Discover your full infrastructure (autonomous agent scan)
118
224
  # → scans bookmarks, installed apps, local services, cloud, config files
119
225
  # → then interactive follow-up: type tool names to search further
120
226
  datasynx-cartography discover
@@ -142,7 +248,7 @@ datasynx-cartography discover [options]
142
248
  --entry <hosts...> Start hosts (default: localhost)
143
249
  --depth <n> Max crawl depth (default: 8)
144
250
  --max-turns <n> Max agent turns (default: 50)
145
- --model <m> Claude model (default: claude-sonnet-4-5-...)
251
+ --model <m> LLM model (default: claude-sonnet-4-5-...)
146
252
  --org <name> Org name for Backstage YAML
147
253
  -o, --output <dir> Output directory (default: ./datasynx-output)
148
254
  -v, --verbose Show agent reasoning
@@ -196,33 +302,49 @@ datasynx-output/
196
302
 
197
303
  ## Architecture
198
304
 
305
+ The **MCP server is the headline interface** — LLM-agnostic and the same SQLite graph
306
+ underneath every entry point. Discovery (deterministic scanners or the optional Claude
307
+ loop) writes the graph; any MCP host reads it.
308
+
199
309
  ```
200
- CLI (Commander.js)
201
- └── Preflight: Claude CLI + API key check
202
- └── Platform Detection (src/platform.ts)
203
- ├── Shell: /bin/sh (Unix) | PowerShell (Windows)
204
- ├── Commands: which (Unix) | Get-Command (Windows)
205
- └── Agent Orchestrator (src/agent.ts)
206
- └── runDiscovery() Claude Sonnet + Bash + MCP Tools
207
- ├── scan_bookmarks() browser bookmark extraction (all platforms)
208
- ├── scan_browser_history() anonymized hostname extraction
209
- ├── scan_installed_apps() platform-native app detection
210
- ├── scan_local_databases() DB service + file scanning
211
- ├── scan_k8s_resources() kubectl (readonly)
212
- ├── scan_aws/gcp/azure() cloud CLI scans (readonly)
213
- ├── ask_user() human-in-the-loop questions
214
- └── Custom MCP Tools CartographyDB (SQLite WAL)
310
+ ┌──────────────────────────────────────────┐
311
+ MCP hosts ───────────►│ MCP server (src/mcp) primary interface
312
+ (Claude Code, │ Resources · Tools · Prompts │
313
+ Cursor, Cline, │ stdio + Streamable HTTP transports │
314
+ Windsurf, VS Code, └───────────────────┬──────────────────────┘
315
+ Vercel AI SDK, )
316
+
317
+ CartographyDB (SQLite WAL, src/db)
318
+ recursive-CTE traversal · search · summary
319
+
320
+ ┌────────────────────────────┴────────────────────────────┐
321
+ │ │
322
+ Deterministic discovery (src/discovery, src/scanners) Optional Claude loop (src/agent)
323
+ bookmarks · installed-apps · local ports · DBs runDiscovery()human-in-the-loop
324
+ LLM-free, registry-driven LLM + Bash + custom MCP tools
325
+ │ │
326
+ └──────────────────────────┬───────────────────────────────┘
327
+
328
+ Platform layer (src/platform) + read-only allowlist (src/allowlist)
329
+ Shell/commands resolved per-OS · every command vetted before it runs
215
330
  ```
216
331
 
217
332
  ### Safety
218
333
 
219
- Every Bash call is guarded by a `PreToolUse` hook that blocks destructive commands:
220
-
221
- **Unix:** `rm`, `mv`, `dd`, `chmod`, `kill`, `docker rm/run/exec`, `kubectl delete/apply/exec`, redirects (`>`), and more.
334
+ v2.0 replaces the old "block bad commands" denylist with a **strict read-only allowlist**
335
+ (`src/allowlist.ts`): a command runs only if it is explicitly known to be safe. The check
336
+ is shell-aware and enforced in two places the command runner itself (defense-in-depth)
337
+ and the Claude loop's `PreToolUse` hook.
222
338
 
223
- **Windows/PowerShell:** `Remove-Item`, `Move-Item`, `Stop-Process`, `Stop-Service`, `Restart-Computer`, `Format-Volume`, `Out-File`, `Set-Content`, and more.
339
+ - **POSIX:** parses the command line, resolves `sudo`/`env`/command-runners and brace
340
+ groups, and allows only read-only tools (`ss`, `lsof`, `ps`, `which`, `find`, DB
341
+ probes, cloud `describe/list/get`, `kubectl get/describe`, …). Redirections, pipes to
342
+ writers, and anything unrecognized are rejected.
343
+ - **Windows/PowerShell:** allows read-only cmdlets and rejects mutating ones
344
+ (`Remove-Item`, `Move-Item`, `Stop-Process`, `Stop-Service`, `Restart-Computer`,
345
+ `Format-Volume`, `Out-File`, `Set-Content`, …).
224
346
 
225
- **Claude only reads — never writes, never deletes.**
347
+ **Cartography only reads — never writes, never deletes.**
226
348
 
227
349
  ---
228
350
 
@@ -243,6 +365,42 @@ await runDiscovery(config, db, sessionId, onEvent, onAskUser, 'hubspot windsurf'
243
365
 
244
366
  ---
245
367
 
368
+ ## Releasing
369
+
370
+ [`release.yml`](.github/workflows/release.yml) publishes to npm automatically on every push
371
+ to `main`, in one of **two modes** — auto-selected by which secrets are present:
372
+
373
+ - **`RELEASE_TOKEN` present → full [semantic-release](https://github.com/semantic-release/semantic-release).**
374
+ Version, `CHANGELOG.md`, git tag `v<version>`, GitHub Release and the provenance-signed npm
375
+ publish are all derived from [Conventional Commits](https://www.conventionalcommits.org/)
376
+ since the last tag (`fix:` → patch, `feat:` → minor, `feat!:`/`BREAKING CHANGE:` → major;
377
+ `docs/chore/refactor/test/ci` → no release). No manual version bumps. PR titles are linted
378
+ by [`pr-title.yml`](.github/workflows/pr-title.yml) so the squash-merge commit stays analyzable.
379
+ - **`RELEASE_TOKEN` absent → idempotent npm publish.** The `package.json` version is published
380
+ (provenance-signed) only when it isn't already on npm — so doc/refactor merges are no-ops.
381
+ Bump the version + merge to release.
382
+
383
+ > **Why two modes:** every commit here carries `.github/workflows/` files, and the Actions
384
+ > `GITHUB_TOKEN` may not push a git ref that touches workflow files (it can't hold the
385
+ > `workflow` scope). semantic-release pushes a tag, so it needs a workflow-scoped
386
+ > `RELEASE_TOKEN`. Until one exists, the idempotent publish keeps releases flowing with only
387
+ > `NPM_TOKEN`; adding `RELEASE_TOKEN` later upgrades to the full flow with no other changes.
388
+
389
+ Quality is gated independently by [`ci.yml`](.github/workflows/ci.yml) on every PR and push:
390
+ **lint/typecheck → test matrix (Node 20/22) + coverage → audit + license check → build &
391
+ validate (publint, [are-the-types-wrong](https://github.com/arethetypeswrong/arethetypeswrong.github.io),
392
+ ESM/CJS consumer smoke tests)**.
393
+
394
+ **Repository secrets** (*Settings → Secrets and variables → Actions*):
395
+
396
+ | Secret | Required | Purpose |
397
+ |---|---|---|
398
+ | `NPM_TOKEN` | **yes** | npm *Automation*/granular token with publish rights for the `@datasynx` scope. Provenance signing itself needs no secret (OIDC). |
399
+ | `RELEASE_TOKEN` | optional | PAT (classic: `repo` + `workflow`) or deploy key. Unlocks full semantic-release (auto-versioning, changelog, tags, GitHub Releases). Without it, the idempotent npm publish is used. |
400
+ | `CODECOV_TOKEN` | optional | Upload coverage to Codecov (non-blocking if absent). |
401
+
402
+ ---
403
+
246
404
  ## Built by
247
405
 
248
406
  <div align="center">
@@ -256,3 +414,9 @@ await runDiscovery(config, db, sessionId, onEvent, onAskUser, 'hubspot windsurf'
256
414
  ## License
257
415
 
258
416
  MIT — © [Datasynx AI](https://www.linkedin.com/company/datasynx-ai/)
417
+
418
+ ---
419
+
420
+ ## Related Projects
421
+
422
+ - [**agentic-ai-shadowing**](https://github.com/datasynx/agentic-ai-shadowing) — AI-powered agent session shadowing & replay
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ chromeLikeHistoryPaths,
4
+ chromeLikePaths,
5
+ cleanupTempFiles,
6
+ extractHost,
7
+ readChromeLike,
8
+ readFirefoxHistory,
9
+ scanAllBookmarks,
10
+ scanAllHistory,
11
+ walkChrome
12
+ } from "./chunk-CJ2PITFA.js";
13
+ import "./chunk-UGSNG3QJ.js";
14
+ export {
15
+ chromeLikeHistoryPaths,
16
+ chromeLikePaths,
17
+ cleanupTempFiles,
18
+ extractHost,
19
+ readChromeLike,
20
+ readFirefoxHistory,
21
+ scanAllBookmarks,
22
+ scanAllHistory,
23
+ walkChrome
24
+ };
25
+ //# sourceMappingURL=bookmarks-VS56KVCO.js.map