@datasynx/agentic-ai-cartography 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Datasynx AI
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/README.md ADDED
@@ -0,0 +1,201 @@
1
+ # @datasynx-ai/agentic-ai-cartography
2
+
3
+ **AI-powered Infrastructure Cartography & SOP Generation**
4
+
5
+ Cartography uses the **Claude Agent SDK** to automatically discover your infrastructure, map dependencies, and generate Standard Operating Procedures from observed workflows — all from your terminal.
6
+
7
+ ```
8
+ $ cartography discover
9
+ 🔍 Scanning localhost...
10
+ ├── postgres:5432 (3 databases, 47 tables)
11
+ ├── redis:6379 (standalone, 12 keys)
12
+ ├── nginx:80 → upstream:3000 (express)
13
+ │ └── GET /api/users, POST /api/auth, ...
14
+ ├── rabbitmq:5672 (3 queues)
15
+ └── grafana:3000 → prometheus:9090
16
+ ✓ 8 nodes, 11 edges discovered
17
+ ✓ Exported: catalog.json, topology.mermaid, catalog-info.yaml
18
+
19
+ $ cartography shadow start
20
+ 👁 Shadow daemon started (PID 48291)
21
+ Observing network + processes every 30s...
22
+
23
+ $ cartography shadow stop
24
+ ✓ Shadow stopped. 142 events, 3 tasks, 2 workflows detected.
25
+ ✓ Generated: sops/deploy-check.md, sops/db-migration.md
26
+ ```
27
+
28
+ 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.
29
+
30
+ ---
31
+
32
+ ## Requirements
33
+
34
+ - **Node.js ≥ 18**
35
+ - **Claude CLI** (runtime dependency — the Agent SDK starts it as a child process)
36
+
37
+ ```bash
38
+ npm install -g @anthropic-ai/claude-code
39
+ claude login
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ npm install -g @datasynx-ai/agentic-ai-cartography
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ # Discover your infrastructure (one-shot, Claude Sonnet)
56
+ cartography discover
57
+
58
+ # Start background observer (Claude Haiku, every 30s)
59
+ cartography shadow start
60
+
61
+ # Attach to see live events
62
+ cartography shadow attach
63
+
64
+ # After observing: generate SOPs from workflows
65
+ cartography sops
66
+
67
+ # Stop daemon
68
+ cartography shadow stop
69
+
70
+ # Full feature overview
71
+ cartography docs
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Commands
77
+
78
+ ### Discovery
79
+
80
+ ```
81
+ cartography discover [options]
82
+
83
+ --entry <hosts...> Start hosts (default: localhost)
84
+ --depth <n> Max crawl depth (default: 8)
85
+ --max-turns <n> Max agent turns (default: 50)
86
+ --model <m> Claude model (default: claude-sonnet-4-5-...)
87
+ --org <name> Org name for Backstage YAML
88
+ -o, --output <dir> Output directory (default: ./cartography-output)
89
+ -v, --verbose Show agent reasoning
90
+ ```
91
+
92
+ ### Shadow Daemon
93
+
94
+ ```
95
+ cartography shadow start [options]
96
+
97
+ --interval <ms> Poll interval (default: 30000, min: 15000)
98
+ --inactivity <ms> Task boundary gap (default: 300000)
99
+ --model <m> Claude model (default: claude-haiku-4-5-...)
100
+ --track-windows Track window focus (requires xdotool)
101
+ --auto-save Save nodes without prompting
102
+ --foreground Run in foreground (no fork)
103
+
104
+ cartography shadow stop
105
+ cartography shadow status
106
+ cartography shadow attach # hotkeys: [T] new task [S] status [D] detach [Q] stop
107
+ ```
108
+
109
+ ### Analysis & Export
110
+
111
+ ```
112
+ cartography sops [session-id] Generate SOPs from observed workflows
113
+ cartography export [session-id] [options] Export all formats
114
+ --format <fmt...> mermaid, json, yaml, html, sops (default: all)
115
+ -o, --output <dir> Output directory
116
+ cartography show [session-id] Session details + node list
117
+ cartography sessions List all sessions
118
+ cartography docs Full feature reference
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Output Files
124
+
125
+ ```
126
+ cartography-output/
127
+ ├── catalog.json Full machine-readable dump
128
+ ├── catalog-info.yaml Backstage service catalog
129
+ ├── topology.mermaid Infrastructure topology (graph TB)
130
+ ├── dependencies.mermaid Service dependencies (graph LR)
131
+ ├── topology.html Interactive D3.js force graph
132
+ ├── sops/
133
+ │ ├── deploy-check.md
134
+ │ └── db-migration.md
135
+ └── workflows/
136
+ └── workflow-001.mermaid
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Costs
142
+
143
+ | Mode | Model | Interval | per Hour | per 8h Day |
144
+ |------|-------|----------|----------|------------|
145
+ | Discovery | Sonnet | one-shot | $0.15–0.50 | one-shot |
146
+ | Shadow | Haiku | 30s | $0.12–0.36 | $0.96–2.88 |
147
+ | Shadow | Haiku | 60s | $0.06–0.18 | $0.48–1.44 |
148
+ | Shadow (quiet)* | Haiku | 30s | ~$0.02 | ~$0.16 |
149
+ | SOP generation | Sonnet | one-shot | $0.01–0.03 | one-shot |
150
+
151
+ \* *quiet = diff-check skips ~90% of cycles when the system is idle*
152
+
153
+ ---
154
+
155
+ ## Architecture
156
+
157
+ ```
158
+ CLI (Commander)
159
+ └── Preflight: Claude CLI check + API key + interval validation
160
+ └── Agent Orchestrator
161
+ ├── runDiscovery() Claude Sonnet + Bash + MCP Tools
162
+ ├── runShadowCycle() Claude Haiku + MCP Tools only (no Bash!)
163
+ └── generateSOPs() Anthropic Messages API (no agent loop)
164
+ └── Custom MCP Tools: save_node, save_edge, save_event,
165
+ get_catalog, manage_task, save_sop
166
+ └── CartographyDB (SQLite WAL, ~/.cartography/cartography.db)
167
+
168
+ Shadow Daemon
169
+ ├── takeSnapshot() → ss + ps (no Claude!)
170
+ ├── Diff-check → only calls Claude when something changed
171
+ ├── IPC Server → Unix socket ~/.cartography/daemon.sock
172
+ └── Notifications → desktop alerts when no client attached
173
+ ```
174
+
175
+ ### Safety
176
+
177
+ Every Bash call is guarded by a `PreToolUse` hook that blocks any destructive command:
178
+ `rm`, `mv`, `dd`, `chmod`, `kill`, `docker rm/run/exec`, `kubectl delete/apply/exec`, redirects (`>`), and more.
179
+ Claude only reads — never writes, never deletes.
180
+
181
+ ---
182
+
183
+ ## Public API
184
+
185
+ ```typescript
186
+ import {
187
+ CartographyDB,
188
+ runDiscovery,
189
+ runShadowCycle,
190
+ generateSOPs,
191
+ exportAll,
192
+ safetyHook,
193
+ defaultConfig,
194
+ } from '@datasynx-ai/agentic-ai-cartography';
195
+ ```
196
+
197
+ ---
198
+
199
+ ## License
200
+
201
+ MIT — © Datasynx AI