@rubytech/create-maxy 1.0.629 → 1.0.630

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.
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env bash
2
+ # Task 557 acceptance harness for the graph MCP integration.
3
+ #
4
+ # Spawns the graph shim, drives it as a JSON-RPC client over stdio, runs
5
+ # one query per acceptance class, prints PASS/FAIL per check, and exits
6
+ # non-zero if any check fails. Assumes the brand's Neo4j is running and
7
+ # the fixture in fixture.cypher has been seeded.
8
+ #
9
+ # Usage:
10
+ # PLATFORM_ROOT=~/.maxy/platform bash accept.sh # infers NEO4J_URI from env
11
+ # PLATFORM_ROOT=~/.maxy/platform NEO4J_URI=bolt://localhost:7687 bash accept.sh
12
+ #
13
+ # Dependencies: node, python3 (for JSON-RPC framing), uvx (via the shim).
14
+ #
15
+ # Exit codes:
16
+ # 0 all PASS
17
+ # 1 one or more FAIL
18
+ # 2 setup error (shim missing, uvx missing, etc.)
19
+
20
+ set -euo pipefail
21
+
22
+ PLATFORM_ROOT="${PLATFORM_ROOT:-$(cd "$(dirname "$0")/../../../../.." && pwd)}"
23
+ SHIM="${PLATFORM_ROOT}/lib/graph-mcp/dist/index.js"
24
+
25
+ if [[ ! -f "$SHIM" ]]; then
26
+ echo "FAIL: shim not built at $SHIM — run 'npm run build:lib' in $PLATFORM_ROOT" >&2
27
+ exit 2
28
+ fi
29
+
30
+ if ! command -v uvx >/dev/null 2>&1; then
31
+ echo "FAIL: uvx not on PATH — run: curl -LsSf https://astral.sh/uv/install.sh | sh -s -- -y" >&2
32
+ exit 2
33
+ fi
34
+
35
+ PASS=0
36
+ FAIL=0
37
+ TOTAL=0
38
+
39
+ run_check() {
40
+ local label="$1"
41
+ local query="$2"
42
+ local tool="${3:-maxy-graph_read_neo4j_cypher}"
43
+ TOTAL=$(( TOTAL + 1 ))
44
+
45
+ # Drive the shim via a short Node inline client. Exits 0 with the response
46
+ # body on stdout when the tool call succeeds; exits 1 on any RPC error.
47
+ if out=$(
48
+ node -e "
49
+ const { spawn } = require('node:child_process');
50
+ const shim = process.env.SHIM;
51
+ const tool = process.env.TOOL;
52
+ const query = process.env.QUERY;
53
+ const proc = spawn('node', [shim], { stdio: ['pipe', 'pipe', 'inherit'] });
54
+ let buf = '';
55
+ proc.stdout.on('data', (chunk) => { buf += chunk.toString('utf8'); });
56
+ const send = (obj) => proc.stdin.write(JSON.stringify(obj) + '\n');
57
+ send({ jsonrpc: '2.0', id: 1, method: 'initialize',
58
+ params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'accept.sh', version: '1.0' } } });
59
+ setTimeout(() => {
60
+ send({ jsonrpc: '2.0', method: 'notifications/initialized' });
61
+ const params = tool === 'maxy-graph_get_neo4j_schema' ? {} : { query };
62
+ send({ jsonrpc: '2.0', id: 2, method: 'tools/call', params: { name: tool, arguments: params } });
63
+ }, 1500);
64
+ setTimeout(() => {
65
+ proc.kill('SIGTERM');
66
+ // Look for id:2 response in the buffer
67
+ const lines = buf.split('\n').filter(Boolean);
68
+ for (const line of lines) {
69
+ try { const m = JSON.parse(line); if (m.id === 2) {
70
+ if (m.error) { console.error('RPC_ERROR: ' + JSON.stringify(m.error)); process.exit(1); }
71
+ const text = m.result && m.result.content && m.result.content[0] && m.result.content[0].text || '';
72
+ process.stdout.write(text);
73
+ process.exit(0);
74
+ } } catch (_) {}
75
+ }
76
+ console.error('NO_RESPONSE');
77
+ process.exit(1);
78
+ }, 10000);
79
+ " 2>/dev/null
80
+ ); then
81
+ if [[ -n "$out" ]]; then
82
+ echo "PASS: ${label} (response ${#out}b)"
83
+ PASS=$(( PASS + 1 ))
84
+ else
85
+ echo "FAIL: ${label} (empty response)"
86
+ FAIL=$(( FAIL + 1 ))
87
+ fi
88
+ else
89
+ echo "FAIL: ${label} (RPC error or timeout)"
90
+ FAIL=$(( FAIL + 1 ))
91
+ fi
92
+ }
93
+
94
+ # Exported env used by the inline Node client above.
95
+ export SHIM
96
+ export PLATFORM_ROOT
97
+
98
+ export TOOL="maxy-graph_get_neo4j_schema"
99
+ export QUERY=""
100
+ run_check "get_neo4j_schema returns labels" ""
101
+
102
+ export TOOL="maxy-graph_read_neo4j_cypher"
103
+
104
+ export QUERY="MATCH (n) RETURN labels(n)[0] AS type, count(*) AS n ORDER BY n DESC LIMIT 20"
105
+ run_check "enumerate by label" "$QUERY"
106
+
107
+ export QUERY="MATCH (n:Task) RETURN count(n) AS total"
108
+ run_check "count Tasks" "$QUERY"
109
+
110
+ export QUERY="MATCH (p:Person {email: 'graph-accept@test.maxy.local'}) RETURN elementId(p) AS id, p.givenName, p.email LIMIT 1"
111
+ run_check "find person by email" "$QUERY"
112
+
113
+ export QUERY="MATCH (p:Person {email: 'graph-accept@test.maxy.local'})-[r]-(m) RETURN type(r) AS rel, labels(m)[0] AS neighbourType LIMIT 10"
114
+ run_check "neighbours of fixture person" "$QUERY"
115
+
116
+ export QUERY="MATCH (n) WHERE n.createdAt IS NOT NULL RETURN labels(n)[0] AS type, toString(n.createdAt) AS createdAt ORDER BY n.createdAt DESC LIMIT 5"
117
+ run_check "recent nodes projection" "$QUERY"
118
+
119
+ export QUERY="CALL db.labels() YIELD label RETURN label ORDER BY label"
120
+ run_check "db.labels() schema introspection" "$QUERY"
121
+
122
+ echo ""
123
+ if [[ $FAIL -eq 0 ]]; then
124
+ echo "ALL PASS — ${PASS}/${TOTAL}"
125
+ exit 0
126
+ else
127
+ echo "FAIL — ${PASS}/${TOTAL} passed, ${FAIL} failed"
128
+ exit 1
129
+ fi
@@ -0,0 +1,59 @@
1
+ // Task 557 — acceptance fixture for the graph MCP integration.
2
+ // Seeds one node per primary label so accept.sh can verify enumerate,
3
+ // count, find, neighbours, recent, and schema queries end-to-end.
4
+ // Safe to re-run: MERGE on a synthetic accountId prefix + deterministic ids.
5
+
6
+ MERGE (p:Person {email: 'graph-accept@test.maxy.local'})
7
+ ON CREATE SET p.givenName = 'Graph',
8
+ p.familyName = 'Accept',
9
+ p.telephone = '+440000557001',
10
+ p.status = 'active',
11
+ p.accountId = 'accept-557',
12
+ p.createdAt = datetime()
13
+ MERGE (b:LocalBusiness {accountId: 'accept-557'})
14
+ ON CREATE SET b.name = 'Accept Corp',
15
+ b.businessType = 'test-fixture',
16
+ b.createdAt = datetime()
17
+ MERGE (s:Service {serviceId: 'accept-557-service-1'})
18
+ ON CREATE SET s.name = 'Test Service',
19
+ s.accountId = 'accept-557',
20
+ s.createdAt = datetime()
21
+ MERGE (t:Task {taskId: 'accept-557-task-1'})
22
+ ON CREATE SET t.title = 'Acceptance task',
23
+ t.status = 'open',
24
+ t.priority = 'P2',
25
+ t.accountId = 'accept-557',
26
+ t.createdAt = datetime()
27
+ MERGE (e:Event {eventId: 'accept-557-event-1'})
28
+ ON CREATE SET e.name = 'Acceptance event',
29
+ e.status = 'scheduled',
30
+ e.startDate = datetime(),
31
+ e.accountId = 'accept-557',
32
+ e.createdAt = datetime()
33
+ MERGE (c:Conversation {conversationId: 'accept-557-conv-1'})
34
+ ON CREATE SET c.name = 'Acceptance conversation',
35
+ c.agentType = 'admin',
36
+ c.accountId = 'accept-557',
37
+ c.createdAt = datetime()
38
+ MERGE (m:Message {messageId: 'accept-557-msg-1'})
39
+ ON CREATE SET m.role = 'user',
40
+ m.content = 'Acceptance test message',
41
+ m.accountId = 'accept-557',
42
+ m.createdAt = datetime()
43
+ MERGE (kd:KnowledgeDocument {attachmentId: 'accept-557-doc-1'})
44
+ ON CREATE SET kd.name = 'Acceptance document',
45
+ kd.accountId = 'accept-557',
46
+ kd.createdAt = datetime()
47
+ MERGE (sec:Section {sectionId: 'accept-557-sec-1'})
48
+ ON CREATE SET sec.title = 'Section one',
49
+ sec.accountId = 'accept-557',
50
+ sec.createdAt = datetime()
51
+ MERGE (ch:Chunk {chunkId: 'accept-557-chk-1'})
52
+ ON CREATE SET ch.text = 'Chunk text for acceptance.',
53
+ ch.accountId = 'accept-557',
54
+ ch.createdAt = datetime()
55
+ MERGE (p)-[:WORKS_FOR]->(b)
56
+ MERGE (b)-[:OFFERS]->(s)
57
+ MERGE (kd)-[:HAS_SECTION]->(sec)
58
+ MERGE (sec)-[:HAS_CHUNK]->(ch)
59
+ MERGE (c)-[:HAS_MESSAGE]->(m);
@@ -0,0 +1,195 @@
1
+ <!-- Injected into admin system prompt by claude-agent.ts when agentType === "admin". -->
2
+ <!-- Consumed by the upstream mcp-neo4j-cypher server via `maxy-graph_read_neo4j_cypher`. -->
3
+ <!-- Source of truth for node labels and properties: platform/neo4j/schema.cypher + plugins/memory/references/schema-*.md. -->
4
+
5
+ # Graph interrogation (read-only Cypher cookbook)
6
+
7
+ When a user asks a relational question about their own graph — *"list all my
8
+ people", "how many tasks do I have", "find the person with email X", "what's
9
+ linked to this business", "show me the 20 most recently created nodes" — use
10
+ `maxy-graph_read_neo4j_cypher` or `maxy-graph_get_neo4j_schema`, not
11
+ `memory-search`. Vector search is for "things like this"; Cypher is for "the
12
+ exact set where".
13
+
14
+ The connected Neo4j instance contains only this brand's data (per-brand
15
+ instance architecture — see `.docs/neo4j.md`). You never need an account
16
+ filter in the query.
17
+
18
+ ## Non-negotiable: never return raw nodes
19
+
20
+ `RETURN n` dumps every property, including the 768-dim `embedding` float
21
+ array. This blows the context budget on the first row. **Always enumerate the
22
+ properties you want.**
23
+
24
+ Wrong: `MATCH (n:Person) RETURN n LIMIT 20`
25
+ Right: `MATCH (n:Person) RETURN elementId(n) AS id, n.givenName, n.familyName, n.email, n.telephone LIMIT 20`
26
+
27
+ Apply this convention to every query. Only project the fields you need to
28
+ answer the question. When in doubt, exclude `embedding`, `embeddingText`, and
29
+ any property whose name ends in `_vector`.
30
+
31
+ ## Cookbook
32
+
33
+ Parameterise results with `ORDER BY` and `LIMIT` every time — even an
34
+ "inventory" query should bound itself. Default limit: 50.
35
+
36
+ ### Enumerate
37
+
38
+ All nodes, grouped by label, with a human-readable name:
39
+
40
+ ```cypher
41
+ MATCH (n)
42
+ RETURN labels(n)[0] AS type,
43
+ coalesce(n.name, n.title, n.givenName + ' ' + n.familyName, n.email, '(unnamed)') AS name,
44
+ elementId(n) AS id
45
+ ORDER BY type, name
46
+ LIMIT 200
47
+ ```
48
+
49
+ One label only:
50
+
51
+ ```cypher
52
+ MATCH (n:Person)
53
+ RETURN elementId(n) AS id, n.givenName, n.familyName, n.email, n.telephone
54
+ ORDER BY n.familyName, n.givenName
55
+ LIMIT 100
56
+ ```
57
+
58
+ ### Count
59
+
60
+ Total across the graph:
61
+
62
+ ```cypher
63
+ MATCH (n)
64
+ RETURN count(n) AS total
65
+ ```
66
+
67
+ By label:
68
+
69
+ ```cypher
70
+ MATCH (n)
71
+ RETURN labels(n)[0] AS type, count(*) AS n
72
+ ORDER BY n DESC
73
+ ```
74
+
75
+ ### Find
76
+
77
+ By exact email:
78
+
79
+ ```cypher
80
+ MATCH (p:Person {email: $email})
81
+ RETURN elementId(p) AS id, p.givenName, p.familyName, p.telephone, p.status
82
+ ```
83
+
84
+ Partial name, case-insensitive:
85
+
86
+ ```cypher
87
+ MATCH (p:Person)
88
+ WHERE toLower(p.givenName) CONTAINS toLower($q)
89
+ OR toLower(p.familyName) CONTAINS toLower($q)
90
+ RETURN elementId(p) AS id, p.givenName, p.familyName, p.email
91
+ LIMIT 20
92
+ ```
93
+
94
+ ### Neighbours
95
+
96
+ What is linked to a node (1 hop out, undirected):
97
+
98
+ ```cypher
99
+ MATCH (n)-[r]-(m)
100
+ WHERE elementId(n) = $id
101
+ RETURN type(r) AS rel,
102
+ labels(m)[0] AS neighbourType,
103
+ coalesce(m.name, m.title, m.email, '(unnamed)') AS neighbour,
104
+ elementId(m) AS neighbourId
105
+ LIMIT 50
106
+ ```
107
+
108
+ ### Recent
109
+
110
+ Most recently created nodes (any label):
111
+
112
+ ```cypher
113
+ MATCH (n)
114
+ WHERE n.createdAt IS NOT NULL
115
+ RETURN labels(n)[0] AS type,
116
+ coalesce(n.name, n.title, n.givenName + ' ' + n.familyName, n.email, '(unnamed)') AS name,
117
+ toString(n.createdAt) AS createdAt,
118
+ elementId(n) AS id
119
+ ORDER BY n.createdAt DESC
120
+ LIMIT 20
121
+ ```
122
+
123
+ Most recently updated:
124
+
125
+ ```cypher
126
+ MATCH (n)
127
+ WHERE n.updatedAt IS NOT NULL
128
+ RETURN labels(n)[0] AS type,
129
+ coalesce(n.name, n.title, n.email, '(unnamed)') AS name,
130
+ toString(n.updatedAt) AS updatedAt,
131
+ elementId(n) AS id
132
+ ORDER BY n.updatedAt DESC
133
+ LIMIT 20
134
+ ```
135
+
136
+ ### Schema
137
+
138
+ All labels present in the graph:
139
+
140
+ ```cypher
141
+ CALL db.labels() YIELD label RETURN label ORDER BY label
142
+ ```
143
+
144
+ All relationship types:
145
+
146
+ ```cypher
147
+ CALL db.relationshipTypes() YIELD relationshipType RETURN relationshipType ORDER BY relationshipType
148
+ ```
149
+
150
+ Or use `maxy-graph_get_neo4j_schema` for a richer one-shot structural summary.
151
+
152
+ ### Fulltext
153
+
154
+ Use the `knowledge_fulltext` index for keyword-style search across
155
+ KnowledgeDocument / Section / Chunk content:
156
+
157
+ ```cypher
158
+ CALL db.index.fulltext.queryNodes('knowledge_fulltext', $query)
159
+ YIELD node, score
160
+ WHERE score > 0.5
161
+ RETURN labels(node)[0] AS type,
162
+ coalesce(node.name, node.title, node.heading, '(unnamed)') AS name,
163
+ score,
164
+ elementId(node) AS id
165
+ LIMIT 20
166
+ ```
167
+
168
+ ### Filter by status or category
169
+
170
+ Events that are cancelled:
171
+
172
+ ```cypher
173
+ MATCH (e:Event {status: 'cancelled'})
174
+ RETURN elementId(e) AS id, e.name, toString(e.startDate) AS start
175
+ ORDER BY e.startDate DESC
176
+ LIMIT 50
177
+ ```
178
+
179
+ Tasks by status:
180
+
181
+ ```cypher
182
+ MATCH (t:Task {status: $status})
183
+ RETURN elementId(t) AS id, t.title, toString(t.createdAt) AS created, t.priority
184
+ ORDER BY t.createdAt DESC
185
+ LIMIT 50
186
+ ```
187
+
188
+ ## When to switch back to memory-search
189
+
190
+ - "Things similar to X" → `memory-search` (vector + BM25 hybrid)
191
+ - "Candidates to rank by criterion Y" → `memory-rank`
192
+ - "Conversations where we discussed Z" → `conversation-search`
193
+
194
+ Cypher is for relational certainty. Vector search is for similarity. They
195
+ answer different questions; don't use one to fake the other.