gcyphrq 0.12.6
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/README.md +179 -0
- package/dist/engine/cypher-engine.d.ts +39 -0
- package/dist/engine/cypher-engine.d.ts.map +1 -0
- package/dist/engine/cypher-parser.d.ts +3 -0
- package/dist/engine/cypher-parser.d.ts.map +1 -0
- package/dist/graph.d.ts +24 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/index.js +5816 -0
- package/dist/indexes.d.ts +38 -0
- package/dist/indexes.d.ts.map +1 -0
- package/dist/lib.d.ts +189 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +1455 -0
- package/dist/types/cypher.d.ts +139 -0
- package/dist/types/cypher.d.ts.map +1 -0
- package/docs/404.md +11 -0
- package/docs/_config.yml +42 -0
- package/docs/_includes/footer.html +6 -0
- package/docs/_includes/head.html +13 -0
- package/docs/_includes/nav.html +23 -0
- package/docs/_layouts/default.html +20 -0
- package/docs/assets/cypher-highlight.js +171 -0
- package/docs/assets/favicon.svg +4 -0
- package/docs/assets/main.css +416 -0
- package/docs/cli.md +115 -0
- package/docs/examples.md +223 -0
- package/docs/getting-started.md +158 -0
- package/docs/index.md +89 -0
- package/docs/library-api.md +618 -0
- package/docs/query-guide.md +302 -0
- package/docs/skill.md +219 -0
- package/examples/README.md +187 -0
- package/examples/cloud-infra.json +199 -0
- package/examples/social-graph.json +11 -0
- package/package.json +71 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Query Guide
|
|
4
|
+
description: Full Cypher syntax reference, supported features, and query patterns for gcyphrq.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<div class="breadcrumb">
|
|
8
|
+
<a href="{{ '/' | relative_url }}">Home</a> <span>›</span> Query Guide
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
# Query Guide
|
|
12
|
+
|
|
13
|
+
This guide covers all supported Cypher syntax and query patterns available in the `gcyphrq` engine.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Supported Features
|
|
18
|
+
|
|
19
|
+
See the [Home page](/) for the full feature support table.
|
|
20
|
+
|
|
21
|
+
<div class="callout">
|
|
22
|
+
<p><strong>Single MATCH per stage:</strong> The engine processes one MATCH clause at a time. Chained MATCHes within the same stage are not supported — use multiple stages separated by <code>WITH</code> instead.</p>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## MATCH
|
|
28
|
+
|
|
29
|
+
### Basic node match
|
|
30
|
+
|
|
31
|
+
```cypher
|
|
32
|
+
MATCH (u:User) RETURN u
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Match with property filter
|
|
36
|
+
|
|
37
|
+
```cypher
|
|
38
|
+
MATCH (u:User {name: 'Alice'}) RETURN u
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Match with relationships
|
|
42
|
+
|
|
43
|
+
```cypher
|
|
44
|
+
MATCH (u:User)-[:FRIEND]->(f:User) RETURN u, f
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Variable-length paths
|
|
48
|
+
|
|
49
|
+
```cypher
|
|
50
|
+
MATCH (u:User)-[r:FRIEND*1..3]-(f:User) RETURN u, r, f
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The `*min..max` syntax specifies the minimum and maximum path length. Use `*1..3` for 1 to 3 hops, `*2..2` for exactly 2 hops, etc.
|
|
54
|
+
|
|
55
|
+
### Directional edges
|
|
56
|
+
|
|
57
|
+
| Syntax | Meaning |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `-[:TYPE]->` | Outbound only (from source to target) |
|
|
60
|
+
| `<-[:TYPE]-` | Inbound only (from target to source) |
|
|
61
|
+
| `-[:TYPE]-` | Undirected (either direction) |
|
|
62
|
+
|
|
63
|
+
```cypher
|
|
64
|
+
// Outbound only
|
|
65
|
+
MATCH (u:User {name: 'Alice'})-[r:FRIEND]->(f:User) RETURN f
|
|
66
|
+
|
|
67
|
+
// Inbound only
|
|
68
|
+
MATCH (u:User {name: 'Alice'})<-[r:FRIEND]-(f:User) RETURN f
|
|
69
|
+
|
|
70
|
+
// Any direction
|
|
71
|
+
MATCH (u:User {name: 'Alice'})-[r:FRIEND]-(f:User) RETURN f
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## OPTIONAL MATCH
|
|
77
|
+
|
|
78
|
+
Performs a left outer join — returns results even when no matching path exists (with nulls for unmatched variables):
|
|
79
|
+
|
|
80
|
+
```cypher
|
|
81
|
+
MATCH (u:User)
|
|
82
|
+
OPTIONAL MATCH (u)-[r:HAS_CARD]->(c:Card)
|
|
83
|
+
RETURN u, c
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## RETURN
|
|
89
|
+
|
|
90
|
+
### Return full nodes
|
|
91
|
+
|
|
92
|
+
```cypher
|
|
93
|
+
MATCH (u:User) RETURN u
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Return specific properties
|
|
97
|
+
|
|
98
|
+
```cypher
|
|
99
|
+
MATCH (u:User) RETURN u.name, u.age
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Return with aliases
|
|
103
|
+
|
|
104
|
+
```cypher
|
|
105
|
+
MATCH (u:User) RETURN u.name AS userName, u.age AS userAge
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## WITH + Implicit Grouping
|
|
111
|
+
|
|
112
|
+
Use `WITH` to pipe results through intermediate stages. When you include both aggregated and non-aggregated variables, implicit grouping occurs:
|
|
113
|
+
|
|
114
|
+
```cypher
|
|
115
|
+
MATCH (u:User)-[:FRIEND]->(f)
|
|
116
|
+
WITH u, count(f) AS friendCount
|
|
117
|
+
WHERE friendCount > 1
|
|
118
|
+
RETURN u.name, friendCount
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Supported aggregations
|
|
122
|
+
|
|
123
|
+
| Function | Description |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `count(x)` | Count non-null values |
|
|
126
|
+
| `sum(x.prop)` | Sum numeric values |
|
|
127
|
+
| `avg(x.prop)` | Average of numeric values (null if no values) |
|
|
128
|
+
| `min(x.prop)` | Minimum numeric value (null if no values) |
|
|
129
|
+
| `max(x.prop)` | Maximum numeric value (null if no values) |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## WHERE (on WITH)
|
|
134
|
+
|
|
135
|
+
Filter results after a `WITH` clause:
|
|
136
|
+
|
|
137
|
+
```cypher
|
|
138
|
+
MATCH (s:Service)-[]->(t)
|
|
139
|
+
WITH s, count(t) AS outDegree
|
|
140
|
+
WHERE outDegree > 2
|
|
141
|
+
RETURN s.name, outDegree
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Supported operators
|
|
145
|
+
|
|
146
|
+
| Operator | Example |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `=` | `WHERE count = 5` |
|
|
149
|
+
| `>` | `WHERE count > 5` |
|
|
150
|
+
| `<` | `WHERE count < 5` |
|
|
151
|
+
| `CONTAINS` | `WHERE name CONTAINS "api"` |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## ORDER BY
|
|
156
|
+
|
|
157
|
+
Sort results by one or more properties. Default direction is `ASC` (ascending).
|
|
158
|
+
|
|
159
|
+
```cypher
|
|
160
|
+
// Single column, ascending (default)
|
|
161
|
+
MATCH (u:User) RETURN u.name ORDER BY u.name
|
|
162
|
+
|
|
163
|
+
// Single column, descending
|
|
164
|
+
MATCH (u:User) RETURN u.name, u.age ORDER BY u.age DESC
|
|
165
|
+
|
|
166
|
+
// Multiple columns
|
|
167
|
+
MATCH (u:User) RETURN u.name, u.age ORDER BY u.age ASC, u.name DESC
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## LIMIT
|
|
173
|
+
|
|
174
|
+
Return only the first N results:
|
|
175
|
+
|
|
176
|
+
```cypher
|
|
177
|
+
MATCH (u:User) RETURN u.name LIMIT 5
|
|
178
|
+
|
|
179
|
+
// Combined with ORDER BY for top-N
|
|
180
|
+
MATCH (u:User) RETURN u.name, u.age ORDER BY u.age DESC LIMIT 3
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## SKIP
|
|
186
|
+
|
|
187
|
+
Skip the first N results:
|
|
188
|
+
|
|
189
|
+
```cypher
|
|
190
|
+
MATCH (u:User) RETURN u.name SKIP 5
|
|
191
|
+
|
|
192
|
+
// Pagination: page 2 with 10 results per page
|
|
193
|
+
MATCH (u:User) RETURN u.name ORDER BY u.name ASC SKIP 10 LIMIT 10
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Mutations
|
|
199
|
+
|
|
200
|
+
### CREATE
|
|
201
|
+
|
|
202
|
+
Create a new node:
|
|
203
|
+
|
|
204
|
+
```cypher
|
|
205
|
+
CREATE (l:Log {timestamp: 12345})
|
|
206
|
+
RETURN l
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### SET
|
|
210
|
+
|
|
211
|
+
Update a node property:
|
|
212
|
+
|
|
213
|
+
```cypher
|
|
214
|
+
MATCH (u:User {name: 'Alice'})
|
|
215
|
+
SET u.age = 31
|
|
216
|
+
RETURN u
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### DELETE
|
|
220
|
+
|
|
221
|
+
Remove a node from the graph:
|
|
222
|
+
|
|
223
|
+
```cypher
|
|
224
|
+
MATCH (f:User {name: 'Bob'})
|
|
225
|
+
DELETE f
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Query Patterns
|
|
231
|
+
|
|
232
|
+
### Blast radius analysis
|
|
233
|
+
|
|
234
|
+
Find all nodes affected by a failure (up to N hops):
|
|
235
|
+
|
|
236
|
+
```cypher
|
|
237
|
+
MATCH (kafka:Infrastructure {name: "Kafka Cluster"})-[r*1..2]-(affected)
|
|
238
|
+
RETURN kafka, r, affected
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Dependency chain
|
|
242
|
+
|
|
243
|
+
Trace the full request path from entry point to databases:
|
|
244
|
+
|
|
245
|
+
```cypher
|
|
246
|
+
MATCH (api:Service {name: "API Gateway"})-[r*2..4]->(db:Database)
|
|
247
|
+
RETURN api, r, db
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Collaborative filtering
|
|
251
|
+
|
|
252
|
+
Find items recommended based on what "friends of friends" bought:
|
|
253
|
+
|
|
254
|
+
```cypher
|
|
255
|
+
MATCH (u:User {id: 'usr_abc'})-[:FRIEND*2..2]-(peer:User)-[:BOUGHT]->(item:Product)
|
|
256
|
+
OPTIONAL MATCH (u)-[already_owns:BOUGHT]->(item)
|
|
257
|
+
WITH item, already_owns
|
|
258
|
+
WHERE already_owns IS NULL
|
|
259
|
+
RETURN item
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### What-if impact simulation
|
|
263
|
+
|
|
264
|
+
Inject speculative properties mid-pipeline:
|
|
265
|
+
|
|
266
|
+
```cypher
|
|
267
|
+
MATCH (s:Server {id: 'srv_A'})-[:DEPENDS_ON*1..3]->(downstream:Application)
|
|
268
|
+
SET s.capacity = 90
|
|
269
|
+
WITH downstream, s
|
|
270
|
+
WHERE downstream.min_required_capacity > s.capacity
|
|
271
|
+
RETURN downstream.name AS at_risk_application, s.capacity AS simulated_capacity
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Top-N by degree
|
|
275
|
+
|
|
276
|
+
Find the N nodes with the most connections:
|
|
277
|
+
|
|
278
|
+
```cypher
|
|
279
|
+
MATCH (s:Service)-[]->(target)
|
|
280
|
+
WITH s, count(target) AS outDegree
|
|
281
|
+
ORDER BY outDegree DESC
|
|
282
|
+
LIMIT 3
|
|
283
|
+
RETURN s.name, outDegree
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Unsupported Features
|
|
289
|
+
|
|
290
|
+
The following Cypher features are **not** supported by the engine:
|
|
291
|
+
|
|
292
|
+
- **Subqueries** — `CALL {}` syntax
|
|
293
|
+
- **APOC procedures** — `CALL apoc.*`
|
|
294
|
+
- **Multiple MATCH in same stage** — use `WITH` to chain stages
|
|
295
|
+
- **MERGE** — use `CREATE` or `MATCH` + `CREATE` instead
|
|
296
|
+
- **FOREACH** — not implemented
|
|
297
|
+
- **UNION** — not implemented
|
|
298
|
+
|
|
299
|
+
## Next Steps
|
|
300
|
+
|
|
301
|
+
- **[Library API](library-api)** — Use gcyphrq programmatically in your code
|
|
302
|
+
- **[Examples](examples)** — 18 ready-to-run queries against the bundled cloud infrastructure graph
|
package/docs/skill.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: default
|
|
3
|
+
title: Skill Guide
|
|
4
|
+
description: Install the gcyphrq skill on AI coding agents and use it to query graphs with natural language.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<div class="breadcrumb">
|
|
8
|
+
<a href="{{ '/' | relative_url }}">Home</a> <span>›</span> Skill Guide
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
# Skill Guide
|
|
12
|
+
|
|
13
|
+
The **gcyphrq skill** lets AI coding agents execute Cypher queries against JSON graph files using natural language prompts. Install it once, then ask questions like *"What services depend on the API Gateway?"* and get structured JSON results.
|
|
14
|
+
|
|
15
|
+
## What the Skill Does
|
|
16
|
+
|
|
17
|
+
When installed, the skill teaches an AI agent to:
|
|
18
|
+
|
|
19
|
+
- **Translate natural language** into Cypher queries automatically
|
|
20
|
+
- **Run queries** against your JSON graph files using the `gcyphrq` CLI
|
|
21
|
+
- **Interpret results** and present them in a readable format
|
|
22
|
+
- **Chain multiple queries** for complex analysis (blast radius, path tracing, degree analysis)
|
|
23
|
+
|
|
24
|
+
The skill includes a curated library of query patterns for common infrastructure questions — service dependencies, replication topology, monitoring coverage, and more.
|
|
25
|
+
|
|
26
|
+
## Installation by Platform
|
|
27
|
+
|
|
28
|
+
### Pi
|
|
29
|
+
|
|
30
|
+
Pi auto-discovers skills placed in its skill directories.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Copy the skill globally
|
|
34
|
+
mkdir -p ~/.pi/agent/skills/gcyphrq/references
|
|
35
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/SKILL.md \
|
|
36
|
+
-o ~/.pi/agent/skills/gcyphrq/SKILL.md
|
|
37
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/references/queries.md \
|
|
38
|
+
-o ~/.pi/agent/skills/gcyphrq/references/queries.md
|
|
39
|
+
|
|
40
|
+
# Or project-level (available only in this project)
|
|
41
|
+
mkdir -p .pi/skills/gcyphrq/references
|
|
42
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/SKILL.md \
|
|
43
|
+
-o .pi/skills/gcyphrq/SKILL.md
|
|
44
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/references/queries.md \
|
|
45
|
+
-o .pi/skills/gcyphrq/references/queries.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Pi will recognize the skill automatically. You can invoke it with `/skill:gcyphrq` or simply describe what you want in natural language — Pi will match the skill to your request.
|
|
49
|
+
|
|
50
|
+
### Claude (Claude Code / MCP)
|
|
51
|
+
|
|
52
|
+
Claude Code auto-discovers skills placed in its skill directories.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Copy the skill globally
|
|
56
|
+
mkdir -p ~/.claude/skills/gcyphrq/references
|
|
57
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/SKILL.md \
|
|
58
|
+
-o ~/.claude/skills/gcyphrq/SKILL.md
|
|
59
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/references/queries.md \
|
|
60
|
+
-o ~/.claude/skills/gcyphrq/references/queries.md
|
|
61
|
+
|
|
62
|
+
# Or project-level (available only in this project)
|
|
63
|
+
mkdir -p .claude/skills/gcyphrq/references
|
|
64
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/SKILL.md \
|
|
65
|
+
-o .claude/skills/gcyphrq/SKILL.md
|
|
66
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/references/queries.md \
|
|
67
|
+
-o .claude/skills/gcyphrq/references/queries.md
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Claude Code will recognize the skill automatically when you ask graph-related questions.
|
|
71
|
+
|
|
72
|
+
### OpenCode
|
|
73
|
+
|
|
74
|
+
OpenCode supports skill files in its configuration directory:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Install gcyphrq CLI globally
|
|
78
|
+
npm install -g gcyphrq
|
|
79
|
+
|
|
80
|
+
# Copy the skill to OpenCode's skill directory
|
|
81
|
+
mkdir -p ~/.opencode/skills/gcyphrq/references
|
|
82
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/SKILL.md \
|
|
83
|
+
-o ~/.opencode/skills/gcyphrq/SKILL.md
|
|
84
|
+
curl -sL https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/references/queries.md \
|
|
85
|
+
-o ~/.opencode/skills/gcyphrq/references/queries.md
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
OpenCode will load the skill and use it when your prompts match the skill's description (graph queries, infrastructure topology, service dependencies, etc.).
|
|
89
|
+
|
|
90
|
+
### Other Agents
|
|
91
|
+
|
|
92
|
+
For any AI coding agent that supports custom instructions or system prompts:
|
|
93
|
+
|
|
94
|
+
1. **Install the CLI**: `npm install -g gcyphrq`
|
|
95
|
+
2. **Copy the SKILL.md** from `https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/SKILL.md` into your agent's custom instructions
|
|
96
|
+
3. **Copy the reference file** from `https://raw.githubusercontent.com/plelevier/gcyphrq/main/skills/gcyphrq/references/queries.md` into a `references/` subdirectory alongside SKILL.md
|
|
97
|
+
4. **Point to your graph files** — replace `<graph.json>` in skill examples with paths to your actual graph files
|
|
98
|
+
|
|
99
|
+
## Prerequisites
|
|
100
|
+
|
|
101
|
+
- **gcyphrq CLI** installed and on PATH — see [Getting Started](getting-started) for install instructions
|
|
102
|
+
- **A JSON graph file** to query (use the bundled `examples/cloud-infra.json` to get started)
|
|
103
|
+
|
|
104
|
+
## Example Prompts
|
|
105
|
+
|
|
106
|
+
Once the skill is installed, you can use natural language prompts. Here are examples that the skill should resolve:
|
|
107
|
+
|
|
108
|
+
### Service Dependencies
|
|
109
|
+
|
|
110
|
+
> **Prompt:** "What services does the API Gateway depend on?"
|
|
111
|
+
|
|
112
|
+
The skill translates this to a Cypher query tracing outgoing connections from the API Gateway node.
|
|
113
|
+
|
|
114
|
+
> **Prompt:** "Show me all services connected to PostgreSQL."
|
|
115
|
+
|
|
116
|
+
Returns all services with TCP connections to the PostgreSQL Primary database.
|
|
117
|
+
|
|
118
|
+
### Blast Radius Analysis
|
|
119
|
+
|
|
120
|
+
> **Prompt:** "If Kafka goes down, what breaks?"
|
|
121
|
+
|
|
122
|
+
Traces all nodes reachable from the Kafka Cluster within 2 hops to show the impact radius.
|
|
123
|
+
|
|
124
|
+
> **Prompt:** "What's the blast radius if the API Gateway fails?"
|
|
125
|
+
|
|
126
|
+
Maps all downstream services and infrastructure affected by the API Gateway being unavailable.
|
|
127
|
+
|
|
128
|
+
### Path Tracing
|
|
129
|
+
|
|
130
|
+
> **Prompt:** "Show me the path from the CDN to the database."
|
|
131
|
+
|
|
132
|
+
Finds the connection path between the CDN and database nodes, showing intermediate services.
|
|
133
|
+
|
|
134
|
+
> **Prompt:** "How does a request flow from the API Gateway to the user database?"
|
|
135
|
+
|
|
136
|
+
Traces the request path through authentication, RPC services, and database connections.
|
|
137
|
+
|
|
138
|
+
### Infrastructure Topology
|
|
139
|
+
|
|
140
|
+
> **Prompt:** "How are the message queues connected?"
|
|
141
|
+
|
|
142
|
+
Lists all message queue infrastructure and their producer/consumer relationships.
|
|
143
|
+
|
|
144
|
+
> **Prompt:** "What's the replication setup for the databases?"
|
|
145
|
+
|
|
146
|
+
Shows primary-replica relationships and replication edge types.
|
|
147
|
+
|
|
148
|
+
### Degree Analysis
|
|
149
|
+
|
|
150
|
+
> **Prompt:** "Which service has the most outgoing connections?"
|
|
151
|
+
|
|
152
|
+
Computes out-degree for all services and returns the most connected one.
|
|
153
|
+
|
|
154
|
+
> **Prompt:** "Find services with more than 2 outgoing connections."
|
|
155
|
+
|
|
156
|
+
Filters services by out-degree threshold using aggregation and WHERE.
|
|
157
|
+
|
|
158
|
+
### Monitoring Coverage
|
|
159
|
+
|
|
160
|
+
> **Prompt:** "What services are being monitored?"
|
|
161
|
+
|
|
162
|
+
Finds all services connected to monitoring infrastructure (Prometheus, Grafana, etc.).
|
|
163
|
+
|
|
164
|
+
> **Prompt:** "Which services don't have monitoring?"
|
|
165
|
+
|
|
166
|
+
Uses OPTIONAL MATCH to find services without monitoring connections.
|
|
167
|
+
|
|
168
|
+
### External Dependencies
|
|
169
|
+
|
|
170
|
+
> **Prompt:** "Which services call external APIs?"
|
|
171
|
+
|
|
172
|
+
Traces RPC services through 1-3 hops to find external API dependencies.
|
|
173
|
+
|
|
174
|
+
> **Prompt:** "List all external integrations."
|
|
175
|
+
|
|
176
|
+
Returns all nodes with the External label and their upstream callers.
|
|
177
|
+
|
|
178
|
+
### Pagination
|
|
179
|
+
|
|
180
|
+
> **Prompt:** "Show me page 2 of services, 10 per page, sorted alphabetically."
|
|
181
|
+
|
|
182
|
+
Uses ORDER BY, SKIP, and LIMIT to paginate through service results.
|
|
183
|
+
|
|
184
|
+
### Graph Mutations
|
|
185
|
+
|
|
186
|
+
> **Prompt:** "Add a new monitoring service called 'Datadog'."
|
|
187
|
+
|
|
188
|
+
Uses CREATE to add a new node to the graph.
|
|
189
|
+
|
|
190
|
+
> **Prompt:** "Set the status of the API Gateway to 'deprecated'."
|
|
191
|
+
|
|
192
|
+
Uses SET to update a node property.
|
|
193
|
+
|
|
194
|
+
## Skill Reference
|
|
195
|
+
|
|
196
|
+
The skill file (`SKILL.md`) includes:
|
|
197
|
+
|
|
198
|
+
- **CLI usage** — command syntax, options, stdin piping
|
|
199
|
+
- **Graph file format** — node and edge structure
|
|
200
|
+
- **Supported Cypher features** — full feature matrix with status
|
|
201
|
+
- **Query patterns** — pre-built queries for the cloud-infra example graph
|
|
202
|
+
- **Output format** — raw JSON output specification
|
|
203
|
+
- **Limitations** — known constraints (single MATCH per stage, no subqueries, etc.)
|
|
204
|
+
|
|
205
|
+
## Troubleshooting
|
|
206
|
+
|
|
207
|
+
| Issue | Solution |
|
|
208
|
+
|---|---|
|
|
209
|
+
| `gcyphrq: command not found` | Run `npm install -g gcyphrq` or `npm link` |
|
|
210
|
+
| Skill not detected by agent | Verify the `SKILL.md` is in the correct skill directory for your platform |
|
|
211
|
+
| Query returns empty results | Check that node labels and property names match your graph file exactly |
|
|
212
|
+
| "Single MATCH per stage" error | Split chained MATCHes into separate queries or use WITH pipelining |
|
|
213
|
+
|
|
214
|
+
## Next Steps
|
|
215
|
+
|
|
216
|
+
- **[Getting Started](getting-started)** — Install gcyphrq and run your first query
|
|
217
|
+
- **[Query Guide](query-guide)** — Full Cypher syntax reference
|
|
218
|
+
- **[Examples](examples)** — 18 ready-to-run queries against the cloud infrastructure graph
|
|
219
|
+
- **[Library API](library-api)** — Use gcyphrq programmatically in Node.js / TypeScript
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Example Graphs
|
|
2
|
+
|
|
3
|
+
This directory contains example graph files you can use with `gcyphrq`.
|
|
4
|
+
|
|
5
|
+
Each file uses a simple JSON format:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"nodes": [
|
|
10
|
+
{ "id": "<node-id>", "label": "<label>", "<property>": "<value>", ... }
|
|
11
|
+
],
|
|
12
|
+
"edges": [
|
|
13
|
+
{ "source": "<source-id>", "target": "<target-id>", "type": "<edge-type>", ... }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Available examples
|
|
19
|
+
|
|
20
|
+
| File | Description |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `social-graph.json` | A small social network with three users connected by `FRIEND` relationships |
|
|
23
|
+
| `cloud-infra.json` | A full startup cloud infrastructure — 52 nodes, 110 edges — with RPC services, message queues, databases, workers, monitoring, and external APIs |
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Load a graph from file
|
|
29
|
+
gcyphrq -g examples/social-graph.json -e 'MATCH (u:User) RETURN u'
|
|
30
|
+
|
|
31
|
+
# Pipe a graph from stdin
|
|
32
|
+
cat examples/social-graph.json | gcyphrq -g - -e 'MATCH (u:User) RETURN u'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## `cloud-infra.json` — Query Examples
|
|
38
|
+
|
|
39
|
+
This graph models an entire startup's cloud service infrastructure. Use it to explore real-world queries like impact analysis, dependency chains, and service topology.
|
|
40
|
+
|
|
41
|
+
### 1. List all RPC services
|
|
42
|
+
|
|
43
|
+
Find every service of type `RPC` running in the infrastructure:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service {type: "RPC"}) RETURN s'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### 2. Trace the full request path from the public API to databases
|
|
50
|
+
|
|
51
|
+
Follow the call chain from the API Gateway, 2–4 hops deep, to see which databases a request can reach:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (api:Service {name: "API Gateway"})-[r*2..4]->(db:Database) RETURN api, r, db'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 3. Find all services that depend on a specific database
|
|
58
|
+
|
|
59
|
+
Discover every service that has a direct connection to the PostgreSQL primary:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service)-[:TCP]->(db:Database {name: "PostgreSQL Primary"}) RETURN s'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 4. Count how many services each message queue feeds into
|
|
66
|
+
|
|
67
|
+
Group by message queue and count the downstream consumers:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (mq:Infrastructure {type: "MessageQueue"})-[:TCP]->(w:Service) WITH mq, count(w) AS consumerCount RETURN mq, consumerCount'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 5. Find the blast radius of a service failure
|
|
74
|
+
|
|
75
|
+
If the Kafka cluster goes down, which services are directly or indirectly affected (up to 2 hops)?
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (kafka:Infrastructure {name: "Kafka Cluster"})-[r*1..2]-(affected) RETURN kafka, r, affected'
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 6. List all external dependencies per service
|
|
82
|
+
|
|
83
|
+
For each RPC service, find which external APIs it calls (directly or through intermediaries, up to 3 hops):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service {type: "RPC"})-[r*1..3]->(ext:External) RETURN s, ext'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 7. Find which services call Stripe
|
|
90
|
+
|
|
91
|
+
Trace from any service through up to 3 hops to find which ones reach the Stripe API:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service)-[r*1..3]->(stripe:External {name: "Stripe API"}) RETURN s, stripe'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 8. Map the replication topology
|
|
98
|
+
|
|
99
|
+
Find all replication relationships between databases:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (primary:Database)-[r:Replication]->(replica:Database) RETURN primary, r, replica'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 9. Find the longest dependency chain
|
|
106
|
+
|
|
107
|
+
Trace paths from the CDN (edge) down through the infrastructure to storage or databases (up to 6 hops):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (cdn:Service {name: "CloudFront CDN"})-[r*1..6]->(leaf:Database) RETURN cdn, r, leaf'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 10. List all services hosted on the primary EKS cluster
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (eks:Infrastructure {name: "EKS Cluster"})-[:Hosts]->(s:Service) RETURN s'
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 11. Find which services talk to Vault for secrets
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service)-[:HTTPS]->(v:Security {name: "Vault"}) RETURN s'
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 12. Count outgoing connections per service
|
|
126
|
+
|
|
127
|
+
Rank services by how many direct dependencies they have:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service)-[]->(target) WITH s, count(target) AS outDegree WHERE outDegree > 2 RETURN s, outDegree'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 13. Sort services by name (ORDER BY)
|
|
134
|
+
|
|
135
|
+
Return all services sorted alphabetically by name:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service) RETURN s.name ORDER BY s.name ASC'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 14. Top-N services by connection count (ORDER BY + LIMIT)
|
|
142
|
+
|
|
143
|
+
Find the 3 services with the most outgoing connections:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service)-[]->(target) WITH s, count(target) AS outDegree ORDER BY outDegree DESC LIMIT 3 RETURN s.name, outDegree'
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 15. Limit results to first N (LIMIT)
|
|
150
|
+
|
|
151
|
+
Return only the first 5 databases in the infrastructure:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (d:Database) RETURN d.name LIMIT 5'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 16. Sort by multiple columns
|
|
158
|
+
|
|
159
|
+
Sort services first by type (ascending), then by name (descending):
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service) RETURN s.type, s.name ORDER BY s.type ASC, s.name DESC'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 17. Skip first N results (SKIP)
|
|
166
|
+
|
|
167
|
+
Skip the first 5 services when listing all services:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service) RETURN s.name SKIP 5'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 18. Pagination with ORDER BY + SKIP + LIMIT
|
|
174
|
+
|
|
175
|
+
Get page 2 of services sorted by name (10 per page):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
gcyphrq -g examples/cloud-infra.json -e 'MATCH (s:Service) RETURN s.name ORDER BY s.name ASC SKIP 10 LIMIT 10'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 19. Average, min, max aggregations
|
|
182
|
+
|
|
183
|
+
Compute average, minimum, and maximum across all users:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
gcyphrq -g examples/social-graph.json -e 'MATCH (u:User) RETURN avg(u.age) AS avgAge, min(u.age) AS minAge, max(u.age) AS maxAge'
|
|
187
|
+
```
|