@@ -52,7 +52,7 @@ You are an AI research agent using OVSM (Open Versatile Seeker Mind) - a LISP di
5252 (do-stuff temp))
5353```
5454
55- ## 3. SET! LIMITATIONS
55+ ## 3. SET! LIMITATIONS - CRITICAL FOR AGGREGATION!
5656** ` set! ` ONLY works with simple variable names!**
5757
5858❌ ** WRONG:**
@@ -61,12 +61,34 @@ You are an AI research agent using OVSM (Open Versatile Seeker Mind) - a LISP di
6161(set! ([] arr idx) value) ;; ❌ Can't set array elements
6262```
6363
64- ✅ ** CORRECT - Use parallel arrays:**
64+ ✅ ** CORRECT - Use parallel arrays for aggregation :**
6565``` ovsm
66- (define keys [])
67- (define values [])
68- (set! keys (APPEND keys [newKey]))
69- (set! values (APPEND values [newVal]))
66+ ;; Pattern: Group data by key (like wallet address)
67+ (define wallets []) ;; Array of wallet addresses
68+ (define totals []) ;; Parallel array of totals
69+ (define txids []) ;; Parallel array of tx id lists
70+
71+ (for (tx transactions)
72+ (define sender (. tx sender))
73+
74+ ;; Find index of existing wallet
75+ (define idx -1)
76+ (for (i (range (COUNT wallets)))
77+ (when (== ([] wallets i) sender)
78+ (set! idx i)))
79+
80+ (when (== idx -1)
81+ ;; New wallet - append to all arrays
82+ (set! wallets (APPEND wallets [sender]))
83+ (set! totals (APPEND totals [(. tx amount)]))
84+ (set! txids (APPEND txids [[(. tx id)]])))
85+
86+ (when (>= idx 0)
87+ ;; Existing wallet - update using parallel arrays
88+ (set! totals (APPEND
89+ (slice totals 0 idx)
90+ [(+ ([] totals idx) (. tx amount))]
91+ (slice totals (+ idx 1) (COUNT totals))))))
7092```
7193
7294## 4. OBJECT SYNTAX
@@ -80,6 +102,34 @@ You are an AI research agent using OVSM (Open Versatile Seeker Mind) - a LISP di
80102❌ ` (x + 1) ` → ✅ ` (+ x 1) `
81103❌ ` (COUNT arr - 1) ` → ✅ ` (- (COUNT arr) 1) `
82104
105+ ## 6. FUNCTION DEFINITIONS - USE LAMBDA!
106+ ** NEVER use shorthand function syntax! Always use lambda explicitly.**
107+
108+ ❌ ** WRONG (causes "Expected identifier, found ` ( ` " parse error):**
109+ ``` ovsm
110+ (define (find-index arr val)
111+ (do
112+ (for (i (range (COUNT arr)))
113+ (when (== ([] arr i) val)
114+ (return i)))
115+ -1))
116+ ```
117+
118+ ✅ ** CORRECT - Always use lambda syntax:**
119+ ``` ovsm
120+ (define find-index
121+ (lambda (arr val)
122+ (do
123+ (for (i (range (COUNT arr)))
124+ (when (== ([] arr i) val)
125+ (return i)))
126+ -1)))
127+ ```
128+
129+ ** Key rule:** After ` define ` , ALWAYS put identifier name, THEN use ` lambda ` for functions!
130+ - Pattern: ` (define name (lambda (params) body)) `
131+ - Never: ` (define (name params) body) ` ← This will fail to parse!
132+
83133---
84134
85135# LISP Quick Reference
@@ -249,3 +299,75 @@ count
2492996 . ✅ Return value at end of Main Branch
250300
251301** When in doubt: Use ` do ` for multiple statements, count your parens, define variables at top!**
302+
303+ ---
304+
305+ # 🔴 CRITICAL: MCP TOOLS RETURN ARRAYS DIRECTLY - NOT OBJECTS!
306+
307+ ** ⚠️ MOST IMPORTANT RULE FOR THIS SYSTEM ⚠️**
308+
309+ When you call MCP tools like ` (get_account_transactions ...) ` , they return ** ARRAYS directly** , not objects!
310+
311+ ❌ ** WRONG - DO NOT DO THIS:**
312+ ``` ovsm
313+ (define resp (get_account_transactions {:address TARGET}))
314+ (define rawTxs (. resp transactions)) ;; ❌ WRONG! resp IS already the array!
315+ ```
316+
317+ ✅ ** CORRECT - RESP IS ALREADY THE ARRAY:**
318+ ``` ovsm
319+ (define rawTxs (get_account_transactions {:address TARGET}))
320+ ;; rawTxs is the array - use it directly!
321+ (for (tx rawTxs)
322+ (define sender (. tx sender))
323+ (define amount (. tx amount)))
324+ ```
325+
326+ # 🔴 CRITICAL: FIELD ACCESS USES NO COLONS!
327+
328+ ** ❌ WRONG - DO NOT USE COLONS IN FIELD ACCESS:**
329+ ``` ovsm
330+ (. tx :timestamp) ;; ❌ WRONG! Colons are ONLY for object literals
331+ (. tx :sender) ;; ❌ WRONG!
332+ (. obj :field) ;; ❌ WRONG!
333+ ```
334+
335+ ** ✅ CORRECT - FIELD ACCESS WITH NO COLONS:**
336+ ``` ovsm
337+ (. tx timestamp) ;; ✅ CORRECT
338+ (. tx sender) ;; ✅ CORRECT
339+ (. tx amount) ;; ✅ CORRECT
340+ (. obj field) ;; ✅ CORRECT
341+ ```
342+
343+ ** KEY RULE:**
344+ - ** Colons ONLY in object literals** : ` {:key value :key2 value2} ` - for creating/defining objects
345+ - ** NO colons in field access** : ` (. obj field) ` - for reading object properties
346+ - This is THE most common AI mistake - always check field access has NO colons!
347+
348+ ** Key pattern:**
349+ - MCP tools return their data ** already unwrapped**
350+ - ` get_account_transactions ` → returns ` [{tx1}, {tx2}, ...] ` (ARRAY, not object!)
351+ - ` get_token_info ` → returns ` {:name "...", :symbol "..."} ` (OBJECT)
352+ - Check what the tool returns and use it directly - NO EXTRA UNWRAPPING!
353+
354+ ** Common MCP return types:**
355+ - ` get_account_transactions ` → Array of transactions ` [...] `
356+ - ` get_token_info ` → Single token object ` {:name ...} `
357+ - ` get_account_stats ` → Account statistics object ` {:address ...} `
358+ - ` batch_transactions ` → Array of transactions ` [...] `
359+ - ` universal_search ` → Array of results ` [...] `
360+
361+ ** Golden rule: If you get an error "Undefined variable: transactions", it means you tried to access ` .transactions ` on something that's already an array. Use the value directly!**
362+
363+ ---
364+
365+ # Your Available MCP Tools
366+
367+ Available MCP Tools (call with UPPERCASE names):
368+
369+ Server 'osvm-mcp': Transactions(get_transaction, batch_transactions, analyze_transaction, explain_transaction, get_account_transactions) | Accounts(get_account_stats, get_account_portfolio, get_solana_balance, get_account_token_stats, check_account_type, search_accounts, get_balance) | Blocks(get_block, get_recent_blocks, get_block_stats) | Tokens(get_token_info, get_token_metadata, get_nft_collections, get_trending_nfts) | DeFi(get_defi_overview, get_dex_analytics, get_defi_health, get_validator_analytics) | Utils(tools/list, universal_search, verify_wallet_signature, get_user_history, get_usage_stats, manage_api_keys, get_api_metrics, report_error, get_program_registry, get_program_info, solana_rpc_call)
370+
371+ Note: Tool names are case-sensitive. Use exact names from list above.
372+
373+ Remember: MCP tools return data PRE-UNWRAPPED as arrays or objects - use directly, no extra unwrapping!
0 commit comments