repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | /** |
| #2 | * UltraThink Blockchain — TUI Reference Panel |
| #3 | * |
| #4 | * Interactive browser for the Ultrathink Blockchain Formula: |
| #5 | * depth ladder · 8-phase protocol · antipatterns · templates |
| #6 | * |
| #7 | * Source: agents/skills/ultrathink-blockchain/SKILL.md |
| #8 | */ |
| #9 | |
| #10 | import chalk from 'chalk'; |
| #11 | |
| #12 | // ─── Sections ───────────────────────────────────────────────────────────────── |
| #13 | |
| #14 | interface Section { |
| #15 | key: string; |
| #16 | icon: string; |
| #17 | label: string; |
| #18 | lines: string[][]; // pages of lines |
| #19 | } |
| #20 | |
| #21 | const FORMULA_SECTION: Section = { |
| #22 | key: '1', |
| #23 | icon: '🧠', |
| #24 | label: 'Formula', |
| #25 | lines: [[ |
| #26 | chalk.bold.cyanBright(' CONTEXT → INTENT → INTERVIEW → ULTRATHINK → PLAN → EXECUTE → ITERATE'), |
| #27 | '', |
| #28 | chalk.bold.white(' Phase 1 CONTEXT DUMP'), |
| #29 | chalk.gray(' Prime every session with chain-native defaults. Prevents web2 patterns leaking in.'), |
| #30 | '', |
| #31 | chalk.green(' Context: Solana mainnet-beta production environment.'), |
| #32 | chalk.green(' Stack: TypeScript, Helius RPC + websockets, Birdeye data, Jito execution.'), |
| #33 | chalk.green(' Constraints:'), |
| #34 | chalk.green(' - All RPC calls through retry wrapper with exponential backoff'), |
| #35 | chalk.green(' - All transactions simulated before sending'), |
| #36 | chalk.green(' - Dynamic priority fees via Helius priority fee API'), |
| #37 | chalk.green(' - Value transactions through Jito bundles'), |
| #38 | chalk.green(' - Explicit timeouts on all network operations'), |
| #39 | '', |
| #40 | chalk.bold.white(' Phase 2 INTENT DECLARATION'), |
| #41 | chalk.gray(' Extract dimensional goals, not flat descriptions.'), |
| #42 | '', |
| #43 | chalk.red(' BAD: "build me a sniper"'), |
| #44 | chalk.green(' GOOD: "sub-200ms execution via Jito with trailing stops and terminal UI"'), |
| #45 | chalk.red(' BAD: "make a swap"'), |
| #46 | chalk.green(' GOOD: "atomic multi-hop swap with slippage protection and MEV shielding"'), |
| #47 | '', |
| #48 | chalk.yellow(' Goal formula: "I want [WHAT] that [HOW] with [CONSTRAINTS] targeting [METRICS]"'), |
| #49 | '', |
| #50 | chalk.bold.white(' Phase 3 EXTRACTION INTERVIEW'), |
| #51 | chalk.gray(' Ask 3-5 questions at a time. Cover:'), |
| #52 | chalk.cyan(' Architecture') + chalk.gray(' — program (Rust) or client (TS)? which programs/accounts?'), |
| #53 | chalk.cyan(' Execution') + chalk.gray(' — latency? batch or single? confirmation strategy?'), |
| #54 | chalk.cyan(' Data') + chalk.gray(' — on-chain state? real-time? historical depth?'), |
| #55 | chalk.cyan(' Risk') + chalk.gray(' — max value per tx? MEV concerns? 3am failure?'), |
| #56 | chalk.cyan(' Existing') + chalk.gray(' — greenfield or integrating? what\'s already built?'), |
| #57 | chalk.gray(' Reflect requirements back for confirmation before proceeding.'), |
| #58 | ]], |
| #59 | }; |
| #60 | |
| #61 | const DEPTH_SECTION: Section = { |
| #62 | key: '2', |
| #63 | icon: '⚡', |
| #64 | label: 'Depth Ladder', |
| #65 | lines: [[ |
| #66 | chalk.bold.cyanBright(' ULTRATHINK DEPTH LADDER'), |
| #67 | '', |
| #68 | chalk.gray(' Invocation Budget Best For'), |
| #69 | chalk.gray(' ' + '─'.repeat(60)), |
| #70 | chalk.white(' think') + chalk.gray(' ~500 tok simple decisions, quick fixes'), |
| #71 | chalk.white(' think step by step') + chalk.gray(' ~1000 tok multi-step, debugging'), |
| #72 | chalk.white(' think hard') + chalk.gray(' ~2000 tok architecture, complex logic'), |
| #73 | chalk.white(' think harder') + chalk.gray(' ~4000 tok system design, security analysis'), |
| #74 | chalk.cyanBright.bold(' ultrathink') + chalk.gray(' ~8000 tok production systems, critical code'), |
| #75 | chalk.magenta.bold(' megathink') + chalk.gray(' maximum novel problems, research-grade'), |
| #76 | '', |
| #77 | chalk.bold.white(' Activation patterns that reliably trigger deep reasoning:'), |
| #78 | '', |
| #79 | chalk.green(' ultrathink about...'), |
| #80 | chalk.green(' think very carefully about...'), |
| #81 | chalk.green(' before answering, deeply consider...'), |
| #82 | chalk.green(' explore multiple approaches before deciding...'), |
| #83 | chalk.green(' reason through this step by step, considering edge cases...'), |
| #84 | chalk.green(' think like a senior blockchain engineer would...'), |
| #85 | '', |
| #86 | chalk.bold.white(' Stacking for maximum depth:'), |
| #87 | '', |
| #88 | chalk.green(' ultrathink. Consider from multiple angles:'), |
| #89 | chalk.green(' - Performance implications on-chain'), |
| #90 | chalk.green(' - Security attack vectors'), |
| #91 | chalk.green(' - MEV exposure'), |
| #92 | chalk.green(' - Failure modes under load'), |
| #93 | chalk.green(' - Compute unit optimization'), |
| #94 | chalk.green(' Then give me your recommended approach with justification.'), |
| #95 | '', |
| #96 | chalk.bold.white(' Focused ultrathink (don\'t waste tokens on obvious parts):'), |
| #97 | '', |
| #98 | chalk.red(' BAD: "Build me a swap aggregator. ultrathink."'), |
| #99 | '', |
| #100 | chalk.green(' GOOD: "Build a Solana swap aggregator.'), |
| #101 | chalk.green(' ultrathink specifically about:'), |
| #102 | chalk.green(' - Route optimization across Jupiter, Raydium, Orca'), |
| #103 | chalk.green(' - Slippage calculation with real-time liquidity depth'), |
| #104 | chalk.green(' - Transaction assembly for atomic multi-hop swaps'), |
| #105 | chalk.green(' - Priority fee estimation using recent block data"'), |
| #106 | ]], |
| #107 | }; |
| #108 | |
| #109 | const BLOCKCHAIN_SECTION: Section = { |
| #110 | key: '3', |
| #111 | icon: '🔗', |
| #112 | label: 'Blockchain Focus', |
| #113 | lines: [[ |
| #114 | chalk.bold.cyanBright(' ULTRATHINK FOCUS AREAS FOR BLOCKCHAIN'), |
| #115 | chalk.gray(' Always ultrathink about these 5 areas. Focus, don\'t spray.'), |
| #116 | '', |
| #117 | chalk.bold.yellow(' 1. TRANSACTION ATOMICITY'), |
| #118 | chalk.gray(' • Instruction ordering and dependencies'), |
| #119 | chalk.gray(' • Account validation (signer, writable, PDA derivation)'), |
| #120 | chalk.gray(' • Compute unit estimation with buffer'), |
| #121 | chalk.gray(' • Lookup tables for address compression'), |
| #122 | chalk.gray(' • Blockhash freshness and retry strategy'), |
| #123 | '', |
| #124 | chalk.bold.yellow(' 2. MEV EXPOSURE'), |
| #125 | chalk.gray(' • What can a searcher extract from this transaction?'), |
| #126 | chalk.gray(' • Should this go through Jito bundles?'), |
| #127 | chalk.gray(' • Is there a backrun opportunity we\'re creating?'), |
| #128 | chalk.gray(' • Can the transaction be sandwiched? How do we prevent it?'), |
| #129 | chalk.gray(' • What\'s worst-case slippage if frontrun?'), |
| #130 | '', |
| #131 | chalk.bold.yellow(' 3. STATE RACE CONDITIONS'), |
| #132 | chalk.gray(' • What if the account state changes between read and write?'), |
| #133 | chalk.gray(' • How do we handle stale blockhash?'), |
| #134 | chalk.gray(' • What if another transaction touches this account first?'), |
| #135 | chalk.gray(' • Should we use durable nonces?'), |
| #136 | chalk.gray(' • Retry strategy that doesn\'t double-spend?'), |
| #137 | '', |
| #138 | chalk.bold.yellow(' 4. SECURITY'), |
| #139 | chalk.gray(' • Can instruction data be manipulated to drain funds?'), |
| #140 | chalk.gray(' • Are all account constraints validated on-chain?'), |
| #141 | chalk.gray(' • Is there a reentrancy path?'), |
| #142 | chalk.gray(' • Can authority checks be bypassed?'), |
| #143 | chalk.gray(' • What happens if accounts are passed in wrong order?'), |
| #144 | '', |
| #145 | chalk.bold.yellow(' 5. FAILURE MODES'), |
| #146 | chalk.gray(' • What breaks at 3am with no one watching?'), |
| #147 | chalk.gray(' • RPC provider outages'), |
| #148 | chalk.gray(' • Cascading failures'), |
| #149 | chalk.gray(' • Orphaned state / open positions'), |
| #150 | ]], |
| #151 | }; |
| #152 | |
| #153 | const ANTIPATTERNS_SECTION: Section = { |
| #154 | key: '4', |
| #155 | icon: '🚫', |
| #156 | label: 'Antipatterns', |
| #157 | lines: [[ |
| #158 | chalk.bold.cyanBright(' TOP 5 BLOCKCHAIN ANTIPATTERNS — WHAT CLAUDE GETS WRONG BY DEFAULT'), |
| #159 | '', |
| #160 | chalk.bold.red(' 1. NO RETRY LOGIC ON RPC CALLS'), |
| #161 | chalk.gray(' Claude\'s default — direct RPC call, no error handling.'), |
| #162 | chalk.red(' BAD: const balance = await connection.getBalance(pubkey);'), |
| #163 | chalk.green(' GOOD: const balance = await withRetry('), |
| #164 | chalk.green(' () => connection.getBalance(pubkey),'), |
| #165 | chalk.green(' { maxRetries: 3, backoffMs: 200 }'), |
| #166 | chalk.green(' );'), |
| #167 | chalk.yellow(' Fix prompt: "All RPC calls through retry wrapper with exponential backoff."'), |
| #168 | '', |
| #169 | chalk.bold.red(' 2. NO TRANSACTION SIMULATION'), |
| #170 | chalk.gray(' Sending transactions without simulating costs money on failures.'), |
| #171 | chalk.red(' BAD: await sendAndConfirmTransaction(connection, tx, [signer]);'), |
| #172 | chalk.green(' GOOD: const sim = await connection.simulateTransaction(tx);'), |
| #173 | chalk.green(' if (sim.value.err) throw new SimulationError(sim.value.err, sim.value.logs);'), |
| #174 | chalk.green(' // then send with CU from simulation'), |
| #175 | chalk.yellow(' Fix prompt: "Simulate every transaction before sending."'), |
| #176 | '', |
| #177 | chalk.bold.red(' 3. BLOCKING ON CONFIRMATION'), |
| #178 | chalk.gray(' sendAndConfirmTransaction() can hang for 60s+ during congestion.'), |
| #179 | chalk.red(' BAD: await sendAndConfirmTransaction(...); // blocks forever'), |
| #180 | chalk.green(' GOOD: const sig = await sendWithTimeout(tx, { timeoutMs: 5000 });'), |
| #181 | chalk.green(' const ok = await pollConfirmation(sig, { maxAttempts: 10 });'), |
| #182 | chalk.yellow(' Fix prompt: "Explicit timeouts on all network operations."'), |
| #183 | '', |
| #184 | chalk.bold.red(' 4. HARDCODED PRIORITY FEES'), |
| #185 | chalk.gray(' Network conditions change. Hardcoded fees get txs stuck or overpay.'), |
| #186 | chalk.red(' BAD: setComputeUnitPrice({ microLamports: 1000 }) // stale number'), |
| #187 | chalk.green(' GOOD: const fee = await helius.getPriorityFeeEstimate(tx);'), |
| #188 | chalk.green(' setComputeUnitPrice({ microLamports: fee.high })'), |
| #189 | chalk.yellow(' Fix prompt: "Dynamic priority fees via Helius API."'), |
| #190 | '', |
| #191 | chalk.bold.red(' 5. NO MEV PROTECTION FOR SWAPS'), |
| #192 | chalk.gray(' Public mempool = sandwichable. Any swap over $500 needs Jito.'), |
| #193 | chalk.red(' BAD: await sendTransaction(swapTx); // public mempool'), |
| #194 | chalk.green(' GOOD: await jito.sendBundle([swapTx], { tip: 10000 });'), |
| #195 | chalk.yellow(' Fix prompt: "Value transactions through Jito bundles."'), |
| #196 | ]], |
| #197 | }; |
| #198 | |
| #199 | const CONSTRAINTS_SECTION: Section = { |
| #200 | key: '5', |
| #201 | icon: '✅', |
| #202 | label: 'Never Ship Without', |
| #203 | lines: [[ |
| #204 | chalk.bold.cyanBright(' NEVER SHIP WITHOUT — THE PRODUCTION CHECKLIST'), |
| #205 | '', |
| #206 | chalk.green(' ✓') + chalk.white(' Retry logic on all RPC calls') + |
| #207 | chalk.gray(' — exponential backoff, 3+ retries, classify transient vs permanent errors'), |
| #208 | '', |
| #209 | chalk.green(' ✓') + chalk.white(' Transaction simulation before send') + |
| #210 | chalk.gray(' — use simulation CU to set ComputeUnitLimit accurately'), |
| #211 | '', |
| #212 | chalk.green(' ✓') + chalk.white(' Dynamic priority fees') + |
| #213 | chalk.gray(' — Helius getPriorityFeeEstimate(), pick medium/high based on urgency'), |
| #214 | '', |
| #215 | chalk.green(' ✓') + chalk.white(' Jito bundles for value transactions') + |
| #216 | chalk.gray(' — any swap, liquidation, or arb > $100 goes through Jito'), |
| #217 | '', |
| #218 | chalk.green(' ✓') + chalk.white(' Explicit timeouts on network ops') + |
| #219 | chalk.gray(' — no indefinite blocking, poll confirmation with maxAttempts'), |
| #220 | '', |
| #221 | chalk.green(' ✓') + chalk.white(' Graceful shutdown / position cleanup') + |
| #222 | chalk.gray(' — SIGINT handler, cancel open orders, close positions, exit cleanly'), |
| #223 | '', |
| #224 | chalk.green(' ✓') + chalk.white(' Comprehensive error types') + |
| #225 | chalk.gray(' — no generic throws. SimulationError, RpcError, InsufficientFunds, etc.'), |
| #226 | '', |
| #227 | chalk.green(' ✓') + chalk.white(' Structured logging with correlation IDs') + |
| #228 | chalk.gray(' — every operation has a traceId, logs are parseable JSON'), |
| #229 | '', |
| #230 | chalk.bold.white(' The complete one-shot prompt:'), |
| #231 | '', |
| #232 | chalk.green(' Context: Solana mainnet-beta.'), |
| #233 | chalk.green(' Stack: TypeScript, Helius RPC + websockets, Birdeye, Jito.'), |
| #234 | chalk.green(' I want [GOAL].'), |
| #235 | '', |
| #236 | chalk.green(' Interview me about requirements (3-5 questions at a time).'), |
| #237 | chalk.green(' ultrathink about: TX structure, MEV, state races, security, failure modes.'), |
| #238 | chalk.green(' Present plan. Wait for approval. Then implement.'), |
| #239 | '', |
| #240 | chalk.green(' Constraints:'), |
| #241 | chalk.green(' - All RPC calls through retry wrapper'), |
| #242 | chalk.green(' - All transactions simulated before sending'), |
| #243 | chalk.green(' - Dynamic priority fees via Helius'), |
| #244 | chalk.green(' - Value transactions through Jito'), |
| #245 | chalk.green(' - Explicit timeout on all network ops'), |
| #246 | chalk.green(' - Full files, no stubs. Ship this to mainnet.'), |
| #247 | ]], |
| #248 | }; |
| #249 | |
| #250 | const TEMPLATES_SECTION: Section = { |
| #251 | key: '6', |
| #252 | icon: '📋', |
| #253 | label: 'Templates', |
| #254 | lines: [ |
| #255 | [ |
| #256 | chalk.bold.cyanBright(' TEMPLATE 1 OF 4 — Token Sniper / Trading Bot'), |
| #257 | '', |
| #258 | chalk.green(' I want a production Solana token sniper that:'), |
| #259 | chalk.green(' - Monitors [Raydium/Pump.fun] for new pools via websocket'), |
| #260 | chalk.green(' - Evaluates tokens against [criteria: liquidity, holder distribution]'), |
| #261 | chalk.green(' - Executes buys within [X]ms of detection using Jito bundles'), |
| #262 | chalk.green(' - Implements [trailing stop / take profit / time-based exit]'), |
| #263 | chalk.green(' - Exposes a terminal UI with real-time PnL'), |
| #264 | '', |
| #265 | chalk.green(' Interview me about:'), |
| #266 | chalk.green(' - RPC setup (Helius tier, dedicated nodes?)'), |
| #267 | chalk.green(' - Risk parameters (max position size, daily loss limit)'), |
| #268 | chalk.green(' - Specific signals to filter on'), |
| #269 | chalk.green(' - Existing infra this needs to integrate with'), |
| #270 | '', |
| #271 | chalk.green(' ultrathink about:'), |
| #272 | chalk.green(' - Latency budget from detection → execution'), |
| #273 | chalk.green(' - Race conditions between monitor and executor'), |
| #274 | chalk.green(' - State management for open positions'), |
| #275 | chalk.green(' - Failure modes when RPC lags or Jito rejects bundles'), |
| #276 | chalk.green(' - How to avoid rugs and honeypots'), |
| #277 | '', |
| #278 | chalk.green(' plan mode: on — see architecture before code.'), |
| #279 | '', |
| #280 | chalk.gray(' [Page 1/4] — press → for next template'), |
| #281 | ], |
| #282 | [ |
| #283 | chalk.bold.cyanBright(' TEMPLATE 2 OF 4 — DeFi Protocol Integration'), |
| #284 | '', |
| #285 | chalk.green(' I want to integrate with [Protocol] to [action: swap/stake/lend].'), |
| #286 | '', |
| #287 | chalk.green(' Context:'), |
| #288 | chalk.green(' - Protocol address: [address]'), |
| #289 | chalk.green(' - IDL available: [yes/no, location]'), |
| #290 | chalk.green(' - Documentation: [link]'), |
| #291 | '', |
| #292 | chalk.green(' Interview me about:'), |
| #293 | chalk.green(' - The specific user flow I\'m building'), |
| #294 | chalk.green(' - Whether I need to handle [ATAs, wrapping SOL]'), |
| #295 | chalk.green(' - Expected transaction frequency'), |
| #296 | chalk.green(' - Error handling requirements'), |
| #297 | '', |
| #298 | chalk.green(' ultrathink about:'), |
| #299 | chalk.green(' - The exact instruction sequence this protocol expects'), |
| #300 | chalk.green(' - Account validation — what PDAs need derivation?'), |
| #301 | chalk.green(' - Edge cases: no ATA? insufficient balance?'), |
| #302 | chalk.green(' - How to simulate this transaction before sending'), |
| #303 | '', |
| #304 | chalk.green(' Before writing code, show me:'), |
| #305 | chalk.green(' 1. Account schema for each instruction'), |
| #306 | chalk.green(' 2. Instruction data layout'), |
| #307 | chalk.green(' 3. Example transaction structure'), |
| #308 | '', |
| #309 | chalk.gray(' [Page 2/4] — press → for next template'), |
| #310 | ], |
| #311 | [ |
| #312 | chalk.bold.cyanBright(' TEMPLATE 3 OF 4 — Anchor Program (Rust)'), |
| #313 | '', |
| #314 | chalk.green(' I want an Anchor program that [functionality].'), |
| #315 | '', |
| #316 | chalk.green(' Interview me about:'), |
| #317 | chalk.green(' - The accounts this program will manage'), |
| #318 | chalk.green(' - Who can call which instructions (authority model)'), |
| #319 | chalk.green(' - Fee structure if any'), |
| #320 | chalk.green(' - Upgrade authority plan'), |
| #321 | '', |
| #322 | chalk.green(' ultrathink about:'), |
| #323 | chalk.green(' - Account sizing and rent implications'), |
| #324 | chalk.green(' - PDA derivation strategy (seeds, bump handling)'), |
| #325 | chalk.green(' - Access control vulnerabilities'), |
| #326 | chalk.green(' - Integer overflow/underflow risks'), |
| #327 | chalk.green(' - Reentrancy potential'), |
| #328 | chalk.green(' - Wrong account ordering'), |
| #329 | '', |
| #330 | chalk.green(' plan mode: on — show me:'), |
| #331 | chalk.green(' 1. Account struct definitions'), |
| #332 | chalk.green(' 2. Instruction signatures'), |
| #333 | chalk.green(' 3. Error enum'), |
| #334 | chalk.green(' 4. Events emitted'), |
| #335 | chalk.green(' 5. Key security invariants'), |
| #336 | '', |
| #337 | chalk.green(' Constraints: Anchor 0.29+, checked math, events on all state changes.'), |
| #338 | '', |
| #339 | chalk.gray(' [Page 3/4] — press → for next template'), |
| #340 | ], |
| #341 | [ |
| #342 | chalk.bold.cyanBright(' TEMPLATE 4 OF 4 — Multi-Agent Trading System'), |
| #343 | '', |
| #344 | chalk.green(' I want a multi-agent system where:'), |
| #345 | chalk.green(' - Agent A monitors [data source] for signals'), |
| #346 | chalk.green(' - Agent B evaluates signals against [strategy]'), |
| #347 | chalk.green(' - Agent C executes approved trades via [venue]'), |
| #348 | chalk.green(' - Agent D manages risk and position limits'), |
| #349 | chalk.green(' - All agents coordinate via [message bus / shared state]'), |
| #350 | '', |
| #351 | chalk.green(' Interview me about:'), |
| #352 | chalk.green(' - Signal sources and their data format'), |
| #353 | chalk.green(' - Strategy parameters (what makes a "good" signal?)'), |
| #354 | chalk.green(' - Execution requirements (speed, MEV protection)'), |
| #355 | chalk.green(' - Risk limits (position size, correlation, drawdown)'), |
| #356 | chalk.green(' - How to monitor and intervene'), |
| #357 | '', |
| #358 | chalk.green(' ultrathink about:'), |
| #359 | chalk.green(' - Agent coordination — avoiding race conditions'), |
| #360 | chalk.green(' - State consistency across agents'), |
| #361 | chalk.green(' - Failure isolation — one crash shouldn\'t kill the system'), |
| #362 | chalk.green(' - Human override mechanisms'), |
| #363 | chalk.green(' - Backtest vs live mode switching'), |
| #364 | '', |
| #365 | chalk.green(' plan mode: on — show message schemas, state machines,'), |
| #366 | chalk.green(' and coordination protocol before implementation.'), |
| #367 | '', |
| #368 | chalk.gray(' [Page 4/4] — press ← to go back'), |
| #369 | ], |
| #370 | ], |
| #371 | }; |
| #372 | |
| #373 | const INSTALL_SECTION: Section = { |
| #374 | key: '7', |
| #375 | icon: '📦', |
| #376 | label: 'Install / Use', |
| #377 | lines: [[ |
| #378 | chalk.bold.cyanBright(' ULTRATHINK SKILL — INSTALL & USAGE'), |
| #379 | '', |
| #380 | chalk.bold.white(' Skill location:'), |
| #381 | chalk.green(' agents/skills/ultrathink-blockchain/SKILL.md'), |
| #382 | chalk.gray(' agents/skills/ultrathink-blockchain/references/antipatterns.md'), |
| #383 | chalk.gray(' agents/skills/ultrathink-blockchain/references/templates.md'), |
| #384 | '', |
| #385 | chalk.bold.white(' Install via install.sh:'), |
| #386 | chalk.green(' bash UltraThink-SKill/install.sh'), |
| #387 | '', |
| #388 | chalk.bold.white(' Install via ClawdHub:'), |
| #389 | chalk.green(' clawdhub install ultrathink-blockchain'), |
| #390 | '', |
| #391 | chalk.bold.white(' Use in Claude Code session:'), |
| #392 | chalk.green(' /ultrathink-blockchain'), |
| #393 | chalk.gray(' (loads the skill, primes context for Solana dev)'), |
| #394 | '', |
| #395 | chalk.bold.white(' Use formula directly in any prompt:'), |
| #396 | chalk.green(' Context: Solana mainnet-beta.'), |
| #397 | chalk.green(' Stack: TypeScript, Helius, Birdeye, Jito.'), |
| #398 | chalk.green(' [describe goal]'), |
| #399 | chalk.green(' Interview me → ultrathink → plan → execute.'), |
| #400 | '', |
| #401 | chalk.bold.white(' Catalog entry (agents/skills/catalog.json):'), |
| #402 | chalk.green(' {'), |
| #403 | chalk.green(' "slug": "ultrathink-blockchain",'), |
| #404 | chalk.green(' "name": "ultrathink-blockchain",'), |
| #405 | chalk.green(' "category": "Solana / Blockchain"'), |
| #406 | chalk.green(' }'), |
| #407 | '', |
| #408 | chalk.bold.white(' Full formula doc:'), |
| #409 | chalk.green(' agents/skills/ultrathink-blockchain/ultrathink-blockchain-formula.md'), |
| #410 | '', |
| #411 | chalk.bold.white(' Quick reference card (one-liner):'), |
| #412 | chalk.yellow(' CONTEXT → INTENT → INTERVIEW → ULTRATHINK → PLAN → EXECUTE → ITERATE'), |
| #413 | ]], |
| #414 | }; |
| #415 | |
| #416 | const SECTIONS: Section[] = [ |
| #417 | FORMULA_SECTION, |
| #418 | DEPTH_SECTION, |
| #419 | BLOCKCHAIN_SECTION, |
| #420 | ANTIPATTERNS_SECTION, |
| #421 | CONSTRAINTS_SECTION, |
| #422 | TEMPLATES_SECTION, |
| #423 | INSTALL_SECTION, |
| #424 | ]; |
| #425 | |
| #426 | // ─── Render ─────────────────────────────────────────────────────────────────── |
| #427 | |
| #428 | function visible(s: string): number { |
| #429 | // eslint-disable-next-line no-control-regex |
| #430 | return s.replace(/\x1b\[[0-9;]*m/g, '').length; |
| #431 | } |
| #432 | |
| #433 | function pad(s: string, width: number): string { |
| #434 | return s + ' '.repeat(Math.max(0, width - visible(s))); |
| #435 | } |
| #436 | |
| #437 | function render(secIdx: number, pageIdx: number): void { |
| #438 | process.stdout.write('\x1b[2J\x1b[H'); |
| #439 | const cols = Math.max(100, Math.min(process.stdout.columns || 130, 148)); |
| #440 | const border = chalk.magenta('═'.repeat(cols - 2)); |
| #441 | const box = (txt: string) => chalk.magenta('║') + pad(' ' + txt, cols - 2) + chalk.magenta('║'); |
| #442 | const sec = SECTIONS[secIdx]!; |
| #443 | const page = sec.lines[pageIdx] ?? sec.lines[0]!; |
| #444 | |
| #445 | // Header |
| #446 | process.stdout.write(chalk.magenta('╔') + border + chalk.magenta('╗\n')); |
| #447 | process.stdout.write( |
| #448 | box(chalk.bold.magenta('🧠 ULTRATHINK BLOCKCHAIN') + |
| #449 | chalk.gray(' — production methodology for shipping Solana code that survives mainnet')), |
| #450 | ); |
| #451 | process.stdout.write('\n'); |
| #452 | process.stdout.write( |
| #453 | box(chalk.gray('CONTEXT → INTENT → INTERVIEW → ') + |
| #454 | chalk.bold.cyanBright('ULTRATHINK') + |
| #455 | chalk.gray(' → PLAN → EXECUTE → ITERATE')), |
| #456 | ); |
| #457 | process.stdout.write('\n'); |
| #458 | process.stdout.write(chalk.magenta('╠') + border + chalk.magenta('╣\n')); |
| #459 | |
| #460 | // Section tabs |
| #461 | const tabLine = SECTIONS.map((s, i) => { |
| #462 | const active = i === secIdx; |
| #463 | const label = `${s.key}. ${s.icon} ${s.label}`; |
| #464 | return active |
| #465 | ? chalk.bold.magenta('[' + label + ']') |
| #466 | : chalk.gray(' ' + label + ' '); |
| #467 | }).join(chalk.gray(' │ ')); |
| #468 | process.stdout.write(box(' ' + tabLine)); |
| #469 | process.stdout.write('\n'); |
| #470 | process.stdout.write(chalk.magenta('╠') + border + chalk.magenta('╣\n')); |
| #471 | |
| #472 | // Content |
| #473 | const contentHeight = 24; |
| #474 | for (let i = 0; i < contentHeight; i++) { |
| #475 | const line = page[i] ?? ''; |
| #476 | process.stdout.write( |
| #477 | chalk.magenta('║') + pad(line || '', cols - 2) + chalk.magenta('║\n'), |
| #478 | ); |
| #479 | } |
| #480 | |
| #481 | // Footer |
| #482 | const pageInfo = sec.lines.length > 1 |
| #483 | ? chalk.cyan(` Page ${pageIdx + 1}/${sec.lines.length} [←→ pages] `) |
| #484 | : ' '; |
| #485 | process.stdout.write(chalk.magenta('╠') + border + chalk.magenta('╣\n')); |
| #486 | process.stdout.write( |
| #487 | box(chalk.gray('[1-7] section [←→] page [↑↓] section [b/Esc] back') + pageInfo), |
| #488 | ); |
| #489 | process.stdout.write('\n'); |
| #490 | process.stdout.write(chalk.magenta('╚') + border + chalk.magenta('╝\n')); |
| #491 | } |
| #492 | |
| #493 | // ─── Main export ────────────────────────────────────────────────────────────── |
| #494 | |
| #495 | export async function runUltraThink(): Promise<void> { |
| #496 | let secIdx = 0; |
| #497 | let pageIdx = 0; |
| #498 | |
| #499 | render(secIdx, pageIdx); |
| #500 | |
| #501 | return new Promise<void>(resolve => { |
| #502 | const enableRaw = () => { |
| #503 | if (process.stdin.setRawMode) process.stdin.setRawMode(true); |
| #504 | process.stdin.resume(); |
| #505 | process.stdin.setEncoding('utf8'); |
| #506 | }; |
| #507 | const disableRaw = () => { |
| #508 | if (process.stdin.setRawMode) process.stdin.setRawMode(false); |
| #509 | }; |
| #510 | |
| #511 | enableRaw(); |
| #512 | |
| #513 | const onData = (chunk: string): void => { |
| #514 | if (chunk === 'b' || chunk === 'B' || chunk === '\x1b') { |
| #515 | process.stdin.off('data', onData); |
| #516 | disableRaw(); |
| #517 | resolve(); |
| #518 | return; |
| #519 | } |
| #520 | if (chunk === '\x03') { |
| #521 | process.stdin.off('data', onData); |
| #522 | disableRaw(); |
| #523 | process.exit(0); |
| #524 | } |
| #525 | |
| #526 | const sec = SECTIONS[secIdx]!; |
| #527 | |
| #528 | // Arrow up — previous section |
| #529 | if (chunk === '\x1b[A') { |
| #530 | secIdx = (secIdx - 1 + SECTIONS.length) % SECTIONS.length; |
| #531 | pageIdx = 0; |
| #532 | render(secIdx, pageIdx); |
| #533 | return; |
| #534 | } |
| #535 | // Arrow down — next section |
| #536 | if (chunk === '\x1b[B') { |
| #537 | secIdx = (secIdx + 1) % SECTIONS.length; |
| #538 | pageIdx = 0; |
| #539 | render(secIdx, pageIdx); |
| #540 | return; |
| #541 | } |
| #542 | // Arrow left — previous page |
| #543 | if (chunk === '\x1b[D') { |
| #544 | pageIdx = Math.max(0, pageIdx - 1); |
| #545 | render(secIdx, pageIdx); |
| #546 | return; |
| #547 | } |
| #548 | // Arrow right — next page |
| #549 | if (chunk === '\x1b[C') { |
| #550 | pageIdx = Math.min(sec.lines.length - 1, pageIdx + 1); |
| #551 | render(secIdx, pageIdx); |
| #552 | return; |
| #553 | } |
| #554 | |
| #555 | // Number keys 1-7 jump to section |
| #556 | const numMatch = chunk.match(/^[1-7]$/); |
| #557 | if (numMatch) { |
| #558 | secIdx = parseInt(chunk, 10) - 1; |
| #559 | pageIdx = 0; |
| #560 | render(secIdx, pageIdx); |
| #561 | } |
| #562 | }; |
| #563 | |
| #564 | process.stdin.on('data', onData); |
| #565 | }); |
| #566 | } |
| #567 |