openclaw-node-harness 2.0.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 +21 -0
- package/README.md +184 -0
- package/bin/discord-read.js +228 -0
- package/bin/fleet-deploy.js +365 -0
- package/bin/lane-watchdog.js +232 -0
- package/bin/mesh-agent.js +714 -0
- package/bin/mesh-bridge.js +535 -0
- package/bin/mesh-deploy-listener.js +322 -0
- package/bin/mesh-deploy.js +1048 -0
- package/bin/mesh-health-publisher.js +247 -0
- package/bin/mesh-task-daemon.js +451 -0
- package/bin/mesh-tool-discord.js +293 -0
- package/bin/mesh.js +649 -0
- package/boot/manifest.yaml +187 -0
- package/cli.js +35 -0
- package/config/daemon.json.template +16 -0
- package/config/obsidian-sync.json.template +39 -0
- package/config/openclaw.json.template +124 -0
- package/config/transcript-sources.json.template +22 -0
- package/identity/AGENTS.md +201 -0
- package/identity/CLAUDE.md +64 -0
- package/identity/DELEGATION.md +304 -0
- package/identity/HEARTBEAT.md +163 -0
- package/identity/MEMORY_SPEC.md +368 -0
- package/identity/PRINCIPLES.md +81 -0
- package/identity/SOUL.md +48 -0
- package/identity/TOOLS.md +47 -0
- package/install.sh +895 -0
- package/lib/agent-activity.js +390 -0
- package/lib/kanban-io.js +352 -0
- package/lib/mesh-registry.js +194 -0
- package/lib/mesh-roles.js +13 -0
- package/lib/mesh-tasks.js +306 -0
- package/lib/nats-resolve.js +108 -0
- package/mission-control/README.md +36 -0
- package/mission-control/drizzle/0000_simple_silhouette.sql +62 -0
- package/mission-control/drizzle/meta/0000_snapshot.json +413 -0
- package/mission-control/drizzle/meta/_journal.json +13 -0
- package/mission-control/drizzle.config.ts +13 -0
- package/mission-control/eslint.config.mjs +18 -0
- package/mission-control/next.config.ts +7 -0
- package/mission-control/package-lock.json +10518 -0
- package/mission-control/package.json +49 -0
- package/mission-control/postcss.config.mjs +7 -0
- package/mission-control/public/file.svg +1 -0
- package/mission-control/public/globe.svg +1 -0
- package/mission-control/public/next.svg +1 -0
- package/mission-control/public/vercel.svg +1 -0
- package/mission-control/public/window.svg +1 -0
- package/mission-control/scripts/enrich-descriptions.js +193 -0
- package/mission-control/scripts/gen-chronology.js +102 -0
- package/mission-control/scripts/import-pipeline-v2.js +523 -0
- package/mission-control/scripts/import-pipeline.js +295 -0
- package/mission-control/src/app/api/activity/live/route.ts +27 -0
- package/mission-control/src/app/api/activity/route.ts +47 -0
- package/mission-control/src/app/api/burndown/route.ts +112 -0
- package/mission-control/src/app/api/critical-path/route.ts +159 -0
- package/mission-control/src/app/api/dependencies/route.ts +176 -0
- package/mission-control/src/app/api/memory/categories/route.ts +93 -0
- package/mission-control/src/app/api/memory/consolidate/route.ts +107 -0
- package/mission-control/src/app/api/memory/doc/route.ts +89 -0
- package/mission-control/src/app/api/memory/flush/route.ts +129 -0
- package/mission-control/src/app/api/memory/graph/route.ts +105 -0
- package/mission-control/src/app/api/memory/items/route.ts +86 -0
- package/mission-control/src/app/api/memory/list/route.ts +48 -0
- package/mission-control/src/app/api/memory/retrieve/route.ts +51 -0
- package/mission-control/src/app/api/memory/search/route.ts +143 -0
- package/mission-control/src/app/api/memory/sync/route.ts +23 -0
- package/mission-control/src/app/api/memory/wikilinks/route.ts +75 -0
- package/mission-control/src/app/api/mesh/events/route.ts +67 -0
- package/mission-control/src/app/api/mesh/nodes/route.ts +221 -0
- package/mission-control/src/app/api/mesh/tokens/route.ts +133 -0
- package/mission-control/src/app/api/projects/route.ts +102 -0
- package/mission-control/src/app/api/resolve-path/route.ts +92 -0
- package/mission-control/src/app/api/scheduler/tick/route.ts +38 -0
- package/mission-control/src/app/api/scheduler/waves/route.ts +54 -0
- package/mission-control/src/app/api/screenshot/route.ts +127 -0
- package/mission-control/src/app/api/settings/gateway/route.ts +92 -0
- package/mission-control/src/app/api/skills/[id]/health/route.ts +57 -0
- package/mission-control/src/app/api/skills/list/route.ts +41 -0
- package/mission-control/src/app/api/souls/[id]/evolution/route.ts +253 -0
- package/mission-control/src/app/api/souls/[id]/prompt/route.ts +205 -0
- package/mission-control/src/app/api/souls/[id]/propagate/route.ts +146 -0
- package/mission-control/src/app/api/souls/route.ts +174 -0
- package/mission-control/src/app/api/tasks/[id]/handoff/route.ts +115 -0
- package/mission-control/src/app/api/tasks/[id]/route.ts +266 -0
- package/mission-control/src/app/api/tasks/[id]/tree/route.ts +94 -0
- package/mission-control/src/app/api/tasks/route.ts +253 -0
- package/mission-control/src/app/api/tts/route.ts +47 -0
- package/mission-control/src/app/api/workspace/files/route.ts +88 -0
- package/mission-control/src/app/api/workspace/read/route.ts +73 -0
- package/mission-control/src/app/burndown/page.tsx +309 -0
- package/mission-control/src/app/calendar/page.tsx +839 -0
- package/mission-control/src/app/favicon.ico +0 -0
- package/mission-control/src/app/globals.css +67 -0
- package/mission-control/src/app/graph/page.tsx +352 -0
- package/mission-control/src/app/layout.tsx +35 -0
- package/mission-control/src/app/live/page.tsx +232 -0
- package/mission-control/src/app/memory/page.tsx +154 -0
- package/mission-control/src/app/mesh/page.tsx +457 -0
- package/mission-control/src/app/obsidian/page.tsx +252 -0
- package/mission-control/src/app/page.tsx +70 -0
- package/mission-control/src/app/roadmap/page.tsx +1757 -0
- package/mission-control/src/app/settings/page.tsx +260 -0
- package/mission-control/src/app/souls/page.tsx +573 -0
- package/mission-control/src/components/board/activity-timeline.tsx +96 -0
- package/mission-control/src/components/board/daily-board.tsx +373 -0
- package/mission-control/src/components/board/kanban-board.tsx +364 -0
- package/mission-control/src/components/board/kanban-column.tsx +105 -0
- package/mission-control/src/components/board/live-stream.tsx +116 -0
- package/mission-control/src/components/board/skill-health-card.tsx +128 -0
- package/mission-control/src/components/board/status-banner.tsx +124 -0
- package/mission-control/src/components/board/task-card.tsx +454 -0
- package/mission-control/src/components/board/unified-task-dialog.tsx +1043 -0
- package/mission-control/src/components/layout/resizable-layout.tsx +68 -0
- package/mission-control/src/components/layout/sidebar.tsx +90 -0
- package/mission-control/src/components/live/audio-spectrum.tsx +106 -0
- package/mission-control/src/components/live/chat-bubble.tsx +52 -0
- package/mission-control/src/components/live/chat-input.tsx +92 -0
- package/mission-control/src/components/memory/doc-reader.tsx +172 -0
- package/mission-control/src/components/memory/memory-list.tsx +169 -0
- package/mission-control/src/components/memory/search-bar.tsx +67 -0
- package/mission-control/src/components/memory/search-results.tsx +149 -0
- package/mission-control/src/components/obsidian/backlinks-panel.tsx +52 -0
- package/mission-control/src/components/obsidian/file-tree.tsx +186 -0
- package/mission-control/src/components/obsidian/local-graph.tsx +107 -0
- package/mission-control/src/components/obsidian/obsidian-graph.tsx +192 -0
- package/mission-control/src/components/obsidian/obsidian-reader.tsx +246 -0
- package/mission-control/src/lib/activity.ts +29 -0
- package/mission-control/src/lib/config.ts +21 -0
- package/mission-control/src/lib/db/index.ts +429 -0
- package/mission-control/src/lib/db/schema.ts +218 -0
- package/mission-control/src/lib/gateway-notify.ts +113 -0
- package/mission-control/src/lib/hooks.ts +536 -0
- package/mission-control/src/lib/memory/categories.ts +125 -0
- package/mission-control/src/lib/memory/entities.ts +482 -0
- package/mission-control/src/lib/memory/extract.ts +369 -0
- package/mission-control/src/lib/memory/retrieval.ts +281 -0
- package/mission-control/src/lib/memory/wikilinks.ts +147 -0
- package/mission-control/src/lib/nats.ts +126 -0
- package/mission-control/src/lib/parsers/clawvault-doc.ts +98 -0
- package/mission-control/src/lib/parsers/daily-log.ts +73 -0
- package/mission-control/src/lib/parsers/memory-md.ts +81 -0
- package/mission-control/src/lib/parsers/task-markdown.ts +459 -0
- package/mission-control/src/lib/parsers/transcript.ts +209 -0
- package/mission-control/src/lib/scheduler.ts +394 -0
- package/mission-control/src/lib/speech/use-speech-pipeline.ts +176 -0
- package/mission-control/src/lib/sync/memory.ts +224 -0
- package/mission-control/src/lib/sync/tasks.ts +271 -0
- package/mission-control/src/lib/tts/edge.ts +31 -0
- package/mission-control/src/lib/tts/google.ts +78 -0
- package/mission-control/src/lib/tts/index.ts +39 -0
- package/mission-control/src/lib/tts/types.ts +18 -0
- package/mission-control/tsconfig.json +42 -0
- package/obsidian-vault/.obsidian/app.json +10 -0
- package/obsidian-vault/.obsidian/community-plugins.json +8 -0
- package/obsidian-vault/.obsidian/graph.json +40 -0
- package/obsidian-vault/.obsidian/plugins/obsidian-local-rest-api/main.js +58769 -0
- package/obsidian-vault/.obsidian/plugins/obsidian-local-rest-api/manifest.json +10 -0
- package/obsidian-vault/.obsidian/plugins/obsidian-local-rest-api/styles.css +47 -0
- package/obsidian-vault/00-meta/.gitkeep +0 -0
- package/obsidian-vault/01-architecture/.gitkeep +0 -0
- package/obsidian-vault/02-smart-contracts/.gitkeep +0 -0
- package/obsidian-vault/03-backend/.gitkeep +0 -0
- package/obsidian-vault/04-mobile/.gitkeep +0 -0
- package/obsidian-vault/05-ar-mapping/.gitkeep +0 -0
- package/obsidian-vault/06-3d-assets/.gitkeep +0 -0
- package/obsidian-vault/07-sound-music/.gitkeep +0 -0
- package/obsidian-vault/08-lore/.gitkeep +0 -0
- package/obsidian-vault/09-quests-playthrough/.gitkeep +0 -0
- package/obsidian-vault/10-economy/.gitkeep +0 -0
- package/obsidian-vault/11-nft-assets/.gitkeep +0 -0
- package/obsidian-vault/12-nft-mechanics/.gitkeep +0 -0
- package/obsidian-vault/13-dao-guild-social/.gitkeep +0 -0
- package/obsidian-vault/14-game-progression/.gitkeep +0 -0
- package/obsidian-vault/15-analytics/.gitkeep +0 -0
- package/obsidian-vault/16-security/.gitkeep +0 -0
- package/obsidian-vault/17-devops/.gitkeep +0 -0
- package/obsidian-vault/18-marketplace/.gitkeep +0 -0
- package/obsidian-vault/19-decisions/.gitkeep +0 -0
- package/obsidian-vault/20-business-strategy/.gitkeep +0 -0
- package/obsidian-vault/21-legal-regulatory/.gitkeep +0 -0
- package/obsidian-vault/nodes/.gitkeep +0 -0
- package/openclaw.env.example +17 -0
- package/package.json +45 -0
- package/services/launchd/ai.openclaw.gateway.plist +59 -0
- package/services/launchd/ai.openclaw.lane-watchdog.plist +32 -0
- package/services/launchd/ai.openclaw.log-rotate.plist +28 -0
- package/services/launchd/ai.openclaw.memory-daemon.plist +36 -0
- package/services/launchd/ai.openclaw.mesh-agent.plist +38 -0
- package/services/launchd/ai.openclaw.mesh-bridge.plist +36 -0
- package/services/launchd/ai.openclaw.mesh-deploy-listener.plist +33 -0
- package/services/launchd/ai.openclaw.mesh-health-publisher.plist +29 -0
- package/services/launchd/ai.openclaw.mesh-task-daemon.plist +36 -0
- package/services/launchd/ai.openclaw.mesh-tool-discord.plist +36 -0
- package/services/launchd/ai.openclaw.mission-control.plist +41 -0
- package/services/service-manifest.json +13 -0
- package/services/systemd/openclaw-gateway.service +21 -0
- package/services/systemd/openclaw-lane-watchdog.service +21 -0
- package/services/systemd/openclaw-log-rotate.service +13 -0
- package/services/systemd/openclaw-log-rotate.timer +9 -0
- package/services/systemd/openclaw-memory-daemon.service +21 -0
- package/services/systemd/openclaw-mesh-agent.service +19 -0
- package/services/systemd/openclaw-mesh-bridge.service +21 -0
- package/services/systemd/openclaw-mesh-deploy-listener.service +23 -0
- package/services/systemd/openclaw-mesh-health-publisher.service +21 -0
- package/services/systemd/openclaw-mesh-task-daemon.service +21 -0
- package/services/systemd/openclaw-mesh-tool-discord.service +21 -0
- package/services/systemd/openclaw-mission-control.service +22 -0
- package/skills/1password/.clawhub/origin.json +7 -0
- package/skills/1password/SKILL.md +63 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/acquisition-channel-advisor/SKILL.md +643 -0
- package/skills/acquisition-channel-advisor/examples/conversation-flow.md +531 -0
- package/skills/agent-browser/.clawhub/origin.json +7 -0
- package/skills/agent-browser/CONTRIBUTING.md +63 -0
- package/skills/agent-browser/SKILL.md +338 -0
- package/skills/agentic-compass/.clawhub/origin.json +7 -0
- package/skills/agentic-compass/README.md +96 -0
- package/skills/agentic-compass/SKILL.md +112 -0
- package/skills/agentic-compass/references/README.md +5 -0
- package/skills/agentic-compass/scripts/agentic-compass.py +196 -0
- package/skills/arcane-dev-ops/SKILL.md +61 -0
- package/skills/arcane-dev-ops/references/checklist.md +22 -0
- package/skills/arcane-dev-ops/references/validation-cases.md +11 -0
- package/skills/arcane-dev-ops/scripts/prepush_check.sh +41 -0
- package/skills/auto-updater/.clawhub/origin.json +7 -0
- package/skills/auto-updater/SKILL.md +158 -0
- package/skills/auto-updater/references/agent-guide.md +152 -0
- package/skills/auto-updater/references/summary-examples.md +109 -0
- package/skills/business-health-diagnostic/SKILL.md +782 -0
- package/skills/byterover/.clawhub/origin.json +7 -0
- package/skills/byterover/SKILL.md +105 -0
- package/skills/byterover/TROUBLESHOOTING.md +50 -0
- package/skills/byterover/WORKFLOWS.md +229 -0
- package/skills/capability-evolver/.clawhub/origin.json +7 -0
- package/skills/capability-evolver/CONTRIBUTING.md +11 -0
- package/skills/capability-evolver/README.md +157 -0
- package/skills/capability-evolver/README.zh-CN.md +112 -0
- package/skills/capability-evolver/SKILL.md +93 -0
- package/skills/capability-evolver/assets/gep/capsules.json +5 -0
- package/skills/capability-evolver/assets/gep/genes.json +104 -0
- package/skills/capability-evolver/index.js +59 -0
- package/skills/capability-evolver/package.json +22 -0
- package/skills/capability-evolver/scripts/analyze_by_skill.js +121 -0
- package/skills/capability-evolver/scripts/build_public.js +350 -0
- package/skills/capability-evolver/scripts/export_history.js +98 -0
- package/skills/capability-evolver/scripts/extract_log.js +85 -0
- package/skills/capability-evolver/scripts/generate_history.js +75 -0
- package/skills/capability-evolver/scripts/human_report.js +147 -0
- package/skills/capability-evolver/scripts/publish_public.js +516 -0
- package/skills/capability-evolver/scripts/suggest_version.js +89 -0
- package/skills/capability-evolver/src/evolve.js +594 -0
- package/skills/capability-evolver/src/gep/assetStore.js +204 -0
- package/skills/capability-evolver/src/gep/candidates.js +134 -0
- package/skills/capability-evolver/src/gep/paths.js +23 -0
- package/skills/capability-evolver/src/gep/prompt.js +254 -0
- package/skills/capability-evolver/src/gep/selector.js +89 -0
- package/skills/capability-evolver/src/gep/signals.js +27 -0
- package/skills/cc-godmode/.clawhub/origin.json +7 -0
- package/skills/cc-godmode/CHANGELOG.md +66 -0
- package/skills/cc-godmode/README.md +293 -0
- package/skills/cc-godmode/SKILL.md +242 -0
- package/skills/cc-godmode/docs/AGENTS.md +332 -0
- package/skills/cc-godmode/docs/MIGRATION.md +206 -0
- package/skills/cc-godmode/docs/TROUBLESHOOTING.md +357 -0
- package/skills/cc-godmode/docs/WORKFLOWS.md +329 -0
- package/skills/cc-godmode/references/agents.md +433 -0
- package/skills/cc-godmode/scripts/build-skill.js +232 -0
- package/skills/clawdbot-filesystem/.clawhub/origin.json +7 -0
- package/skills/clawdbot-filesystem/LICENSE.md +21 -0
- package/skills/clawdbot-filesystem/README.md +322 -0
- package/skills/clawdbot-filesystem/SKILL.md +219 -0
- package/skills/clawdbot-filesystem/config.json +41 -0
- package/skills/clawdbot-filesystem/package.json +69 -0
- package/skills/clawdbot-security-check/.clawhub/origin.json +7 -0
- package/skills/clawdbot-security-check/README.md +168 -0
- package/skills/clawdbot-security-check/SKILL.md +145 -0
- package/skills/clawdbot-security-check/references/audit-checks.md +521 -0
- package/skills/clawdbot-security-check/skill.json +42 -0
- package/skills/clawddocs/.clawhub/origin.json +7 -0
- package/skills/clawddocs/SKILL.md +176 -0
- package/skills/clawddocs/package.json +9 -0
- package/skills/clawddocs/scripts/build-index.sh +17 -0
- package/skills/clawddocs/scripts/cache.sh +13 -0
- package/skills/clawddocs/scripts/fetch-doc.sh +7 -0
- package/skills/clawddocs/scripts/recent.sh +5 -0
- package/skills/clawddocs/scripts/search.sh +8 -0
- package/skills/clawddocs/scripts/sitemap.sh +23 -0
- package/skills/clawddocs/scripts/track-changes.sh +16 -0
- package/skills/clawddocs/snippets/common-configs.md +69 -0
- package/skills/clawguard/.clawhub/origin.json +7 -0
- package/skills/clawguard/SKILL.md +137 -0
- package/skills/company-research/SKILL.md +393 -0
- package/skills/company-research/examples/sample.md +164 -0
- package/skills/company-research/template.md +60 -0
- package/skills/crypto-price/.clawhub/origin.json +7 -0
- package/skills/crypto-price/ARCHITECTURE.md +437 -0
- package/skills/crypto-price/README.md +194 -0
- package/skills/crypto-price/SKILL.md +61 -0
- package/skills/crypto-price/requirements.txt +1 -0
- package/skills/crypto-price/scripts/get_price_chart.py +988 -0
- package/skills/customer-journey-map/SKILL.md +343 -0
- package/skills/customer-journey-map/examples/sample.md +33 -0
- package/skills/customer-journey-map/template.md +28 -0
- package/skills/customer-journey-mapping-workshop/SKILL.md +522 -0
- package/skills/deep-research/.clawhub/origin.json +7 -0
- package/skills/deep-research/SKILL.md +93 -0
- package/skills/deep-research/rules/logic.md +32 -0
- package/skills/discord-telegram-triage/SKILL.md +59 -0
- package/skills/discord-telegram-triage/references/discord-runbook.md +28 -0
- package/skills/discord-telegram-triage/references/validation-cases.md +11 -0
- package/skills/discord-telegram-triage/scripts/triage_snapshot.sh +23 -0
- package/skills/discovery-interview-prep/SKILL.md +408 -0
- package/skills/discovery-process/SKILL.md +503 -0
- package/skills/discovery-process/examples/sample.md +60 -0
- package/skills/discovery-process/template.md +39 -0
- package/skills/dist/arcane-dev-ops.skill +0 -0
- package/skills/dist/discord-telegram-triage.skill +0 -0
- package/skills/dist/founder-brief-summarizer.skill +0 -0
- package/skills/epic-breakdown-advisor/SKILL.md +664 -0
- package/skills/epic-hypothesis/SKILL.md +285 -0
- package/skills/epic-hypothesis/examples/sample.md +104 -0
- package/skills/epic-hypothesis/template.md +30 -0
- package/skills/excel/.clawhub/origin.json +7 -0
- package/skills/excel/SKILL.md +332 -0
- package/skills/excel/scripts/excel.py +1120 -0
- package/skills/fast-browser-use/.clawhub/origin.json +7 -0
- package/skills/fast-browser-use/CODEBUDDY.md +142 -0
- package/skills/fast-browser-use/Cargo.toml +77 -0
- package/skills/fast-browser-use/README.md +62 -0
- package/skills/fast-browser-use/SKILL.md +217 -0
- package/skills/fast-browser-use/package-lock.json +28 -0
- package/skills/fast-browser-use/package.json +8 -0
- package/skills/fast-browser-use/rustfmt.toml +10 -0
- package/skills/fast-browser-use/src/bin/cli.rs +373 -0
- package/skills/fast-browser-use/src/bin/mcp_server.rs +203 -0
- package/skills/fast-browser-use/src/browser/config.rs +136 -0
- package/skills/fast-browser-use/src/browser/debug.rs +16 -0
- package/skills/fast-browser-use/src/browser/mod.rs +61 -0
- package/skills/fast-browser-use/src/browser/session.rs +478 -0
- package/skills/fast-browser-use/src/dom/element.rs +442 -0
- package/skills/fast-browser-use/src/dom/extract_dom.js +849 -0
- package/skills/fast-browser-use/src/dom/mod.rs +14 -0
- package/skills/fast-browser-use/src/dom/tree.rs +296 -0
- package/skills/fast-browser-use/src/dom/yaml.rs +149 -0
- package/skills/fast-browser-use/src/error.rs +115 -0
- package/skills/fast-browser-use/src/lib.rs +17 -0
- package/skills/fast-browser-use/src/mcp/handler.rs +63 -0
- package/skills/fast-browser-use/src/mcp/mod.rs +81 -0
- package/skills/fast-browser-use/src/tools/Readability.min.js +1480 -0
- package/skills/fast-browser-use/src/tools/annotate.rs +165 -0
- package/skills/fast-browser-use/src/tools/click.rs +84 -0
- package/skills/fast-browser-use/src/tools/close.rs +35 -0
- package/skills/fast-browser-use/src/tools/close_tab.rs +45 -0
- package/skills/fast-browser-use/src/tools/convert_to_markdown.js +117 -0
- package/skills/fast-browser-use/src/tools/cookies.rs +58 -0
- package/skills/fast-browser-use/src/tools/debug.rs +44 -0
- package/skills/fast-browser-use/src/tools/evaluate.rs +40 -0
- package/skills/fast-browser-use/src/tools/extract.rs +66 -0
- package/skills/fast-browser-use/src/tools/go_back.rs +35 -0
- package/skills/fast-browser-use/src/tools/go_forward.rs +35 -0
- package/skills/fast-browser-use/src/tools/hover.js +33 -0
- package/skills/fast-browser-use/src/tools/hover.rs +97 -0
- package/skills/fast-browser-use/src/tools/html_to_markdown.rs +99 -0
- package/skills/fast-browser-use/src/tools/input.rs +93 -0
- package/skills/fast-browser-use/src/tools/local_storage.rs +159 -0
- package/skills/fast-browser-use/src/tools/markdown.rs +181 -0
- package/skills/fast-browser-use/src/tools/mod.rs +326 -0
- package/skills/fast-browser-use/src/tools/navigate.rs +55 -0
- package/skills/fast-browser-use/src/tools/new_tab.rs +60 -0
- package/skills/fast-browser-use/src/tools/press_key.rs +78 -0
- package/skills/fast-browser-use/src/tools/read_links.rs +59 -0
- package/skills/fast-browser-use/src/tools/readability_script.rs +8 -0
- package/skills/fast-browser-use/src/tools/screenshot.rs +47 -0
- package/skills/fast-browser-use/src/tools/scroll.js +22 -0
- package/skills/fast-browser-use/src/tools/scroll.rs +95 -0
- package/skills/fast-browser-use/src/tools/select.js +23 -0
- package/skills/fast-browser-use/src/tools/select.rs +129 -0
- package/skills/fast-browser-use/src/tools/sitemap.rs +426 -0
- package/skills/fast-browser-use/src/tools/snapshot.rs +324 -0
- package/skills/fast-browser-use/src/tools/switch_tab.rs +69 -0
- package/skills/fast-browser-use/src/tools/tab_list.rs +76 -0
- package/skills/fast-browser-use/src/tools/utils.rs +92 -0
- package/skills/fast-browser-use/src/tools/wait.rs +53 -0
- package/skills/fast-browser-use/test_auth.json +3 -0
- package/skills/fast-browser-use/test_state.json +6 -0
- package/skills/fast-browser-use/tests/browser_tools_integration.rs +233 -0
- package/skills/fast-browser-use/tests/cli_recipes_integration.rs +112 -0
- package/skills/fast-browser-use/tests/cookies_integration.rs +56 -0
- package/skills/fast-browser-use/tests/debug_integration.rs +83 -0
- package/skills/fast-browser-use/tests/dom_integration.rs +170 -0
- package/skills/fast-browser-use/tests/local_storage_integration.rs +75 -0
- package/skills/fast-browser-use/tests/markdown_integration.rs +448 -0
- package/skills/fast-browser-use/tests/navigation_integration.rs +241 -0
- package/skills/fast-browser-use/tests/sitemap_integration.rs +326 -0
- package/skills/fast-browser-use/tests/tab_management_integration.rs +300 -0
- package/skills/feature-investment-advisor/SKILL.md +639 -0
- package/skills/feature-investment-advisor/examples/conversation-flow.md +538 -0
- package/skills/finance-based-pricing-advisor/SKILL.md +763 -0
- package/skills/finance-metrics-quickref/SKILL.md +309 -0
- package/skills/find-skills/.clawhub/origin.json +7 -0
- package/skills/find-skills/SKILL.md +143 -0
- package/skills/flavor-text-writer/SKILL.md +27 -0
- package/skills/founder-brief-summarizer/SKILL.md +52 -0
- package/skills/founder-brief-summarizer/references/response-templates.md +15 -0
- package/skills/founder-brief-summarizer/references/validation-cases.md +11 -0
- package/skills/founder-brief-summarizer/scripts/brief_template.sh +28 -0
- package/skills/frontend-design/.clawhub/origin.json +7 -0
- package/skills/frontend-design/LICENSE.txt +190 -0
- package/skills/frontend-design/SKILL.md +53 -0
- package/skills/gemini/.clawhub/origin.json +7 -0
- package/skills/gemini/SKILL.md +33 -0
- package/skills/gemini-deep-research/.clawhub/origin.json +7 -0
- package/skills/gemini-deep-research/SKILL.md +78 -0
- package/skills/gemini-deep-research/scripts/deep_research.py +176 -0
- package/skills/git-essentials/.clawhub/origin.json +7 -0
- package/skills/git-essentials/SKILL.md +239 -0
- package/skills/git-essentials/references/advanced.md +211 -0
- package/skills/github/.clawhub/origin.json +7 -0
- package/skills/github/SKILL.md +57 -0
- package/skills/google-drive/.clawhub/origin.json +7 -0
- package/skills/google-drive/LICENSE.txt +21 -0
- package/skills/google-drive/SKILL.md +320 -0
- package/skills/growth-loop/SKILL.md +270 -0
- package/skills/growth-loop/_meta.json +9 -0
- package/skills/growth-loop/references/diagnosis-framework.md +84 -0
- package/skills/growth-loop/references/platform-benchmarks.md +79 -0
- package/skills/growth-loop/scripts/init-campaign.sh +274 -0
- package/skills/humanize-ai-text/.clawhub/origin.json +7 -0
- package/skills/humanize-ai-text/SKILL.md +192 -0
- package/skills/humanize-ai-text/scripts/compare.py +58 -0
- package/skills/humanize-ai-text/scripts/detect.py +160 -0
- package/skills/humanize-ai-text/scripts/patterns.json +191 -0
- package/skills/humanize-ai-text/scripts/transform.py +127 -0
- package/skills/humanizer/.clawhub/origin.json +7 -0
- package/skills/humanizer/README.md +82 -0
- package/skills/humanizer/SKILL.md +443 -0
- package/skills/jobs-to-be-done/SKILL.md +378 -0
- package/skills/jobs-to-be-done/examples/sample.md +80 -0
- package/skills/jobs-to-be-done/template.md +65 -0
- package/skills/lean-ux-canvas/SKILL.md +561 -0
- package/skills/lean-ux-canvas/examples/sample.md +88 -0
- package/skills/lean-ux-canvas/template.md +32 -0
- package/skills/markdown-formatter/.clawhub/origin.json +7 -0
- package/skills/markdown-formatter/README.md +137 -0
- package/skills/markdown-formatter/SKILL.md +369 -0
- package/skills/markdown-formatter/config.json +20 -0
- package/skills/markdown-formatter/index.js +439 -0
- package/skills/markdown-formatter/package.json +23 -0
- package/skills/markdown-formatter/test.js +23 -0
- package/skills/marketing-mode/.clawhub/origin.json +7 -0
- package/skills/marketing-mode/README.md +49 -0
- package/skills/marketing-mode/SKILL.md +703 -0
- package/skills/marketing-mode/mode-prompt.md +39 -0
- package/skills/marketing-mode/skill.json +51 -0
- package/skills/memory-hygiene/.clawhub/origin.json +7 -0
- package/skills/memory-hygiene/SKILL.md +91 -0
- package/skills/memory-setup/.clawhub/origin.json +7 -0
- package/skills/memory-setup/SKILL.md +180 -0
- package/skills/memorylayer/.clawhub/origin.json +7 -0
- package/skills/memorylayer/README.md +197 -0
- package/skills/memorylayer/SKILL.md +227 -0
- package/skills/memorylayer/examples/agent-integration.js +145 -0
- package/skills/memorylayer/examples/basic-usage.js +87 -0
- package/skills/memorylayer/examples/token-savings-demo.js +183 -0
- package/skills/memorylayer/index.js +115 -0
- package/skills/memorylayer/package-lock.json +295 -0
- package/skills/memorylayer/package.json +27 -0
- package/skills/memorylayer/python/memorylayer_skill.py +230 -0
- package/skills/memorylayer/python/requirements.txt +7 -0
- package/skills/mesh/SKILL.md +184 -0
- package/skills/model-usage/.clawhub/origin.json +7 -0
- package/skills/model-usage/SKILL.md +54 -0
- package/skills/model-usage/references/codexbar-cli.md +28 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/moltbook-interact/.clawhub/origin.json +7 -0
- package/skills/moltbook-interact/INSTALL.md +139 -0
- package/skills/moltbook-interact/README.md +198 -0
- package/skills/moltbook-interact/SKILL.md +72 -0
- package/skills/moltbook-interact/references/api.md +106 -0
- package/skills/moltbook-interact/scripts/moltbook.sh +142 -0
- package/skills/moltbook-registry/.clawhub/origin.json +7 -0
- package/skills/moltbook-registry/README.md +26 -0
- package/skills/moltbook-registry/SKILL.md +82 -0
- package/skills/moltbook-registry/index.js +180 -0
- package/skills/moltbook-registry/package.json +11 -0
- package/skills/mythril-scanner/SKILL.md +27 -0
- package/skills/n8n/.clawhub/origin.json +7 -0
- package/skills/n8n/SKILL.md +141 -0
- package/skills/n8n/references/api.md +156 -0
- package/skills/n8n/scripts/n8n_api.py +158 -0
- package/skills/n8n-workflow-automation/.clawhub/origin.json +7 -0
- package/skills/n8n-workflow-automation/SKILL.md +103 -0
- package/skills/n8n-workflow-automation/assets/runbook-template.md +32 -0
- package/skills/narrative-designer/SKILL.md +27 -0
- package/skills/ontology/.clawhub/origin.json +7 -0
- package/skills/ontology/SKILL.md +236 -0
- package/skills/ontology/references/queries.md +211 -0
- package/skills/ontology/references/schema.md +322 -0
- package/skills/ontology/scripts/ontology.py +374 -0
- package/skills/openai-image-gen/.clawhub/origin.json +7 -0
- package/skills/openai-image-gen/SKILL.md +45 -0
- package/skills/openai-image-gen/scripts/gen.py +227 -0
- package/skills/openclaw-agent-optimize/.clawhub/origin.json +7 -0
- package/skills/openclaw-agent-optimize/SKILL.md +33 -0
- package/skills/openclaw-agent-optimize/references/agent-orchestration.md +20 -0
- package/skills/openclaw-agent-optimize/references/context-management.md +15 -0
- package/skills/openclaw-agent-optimize/references/continuous-learning.md +14 -0
- package/skills/openclaw-agent-optimize/references/cron-optimization.md +16 -0
- package/skills/openclaw-agent-optimize/references/memory-patterns.md +14 -0
- package/skills/openclaw-agent-optimize/references/model-selection.md +18 -0
- package/skills/openclaw-skill-scanner/.clawhub/origin.json +7 -0
- package/skills/openclaw-skill-scanner/SKILL.md +88 -0
- package/skills/openclaw-skill-scanner/install-hook.sh +294 -0
- package/skills/openclaw-skill-scanner/report-template.md +53 -0
- package/skills/openclaw-skill-scanner/scanner.py +929 -0
- package/skills/openclaw-skill-scanner/whitelist.json +18 -0
- package/skills/opportunity-solution-tree/SKILL.md +428 -0
- package/skills/opportunity-solution-tree/examples/sample.md +104 -0
- package/skills/opportunity-solution-tree/template.md +33 -0
- package/skills/pdf/.clawhub/origin.json +7 -0
- package/skills/pdf/SKILL.md +304 -0
- package/skills/pestel-analysis/SKILL.md +384 -0
- package/skills/pestel-analysis/examples/sample.md +143 -0
- package/skills/pestel-analysis/template.md +53 -0
- package/skills/pol-probe/SKILL.md +217 -0
- package/skills/pol-probe/examples/sample.md +136 -0
- package/skills/pol-probe/template.md +59 -0
- package/skills/pol-probe-advisor/SKILL.md +492 -0
- package/skills/positioning-statement/SKILL.md +229 -0
- package/skills/positioning-statement/examples/sample.md +51 -0
- package/skills/positioning-statement/template.md +25 -0
- package/skills/positioning-workshop/SKILL.md +424 -0
- package/skills/prd-development/SKILL.md +654 -0
- package/skills/prd-development/examples/sample.md +43 -0
- package/skills/prd-development/template.md +55 -0
- package/skills/press-release/SKILL.md +277 -0
- package/skills/press-release/examples/sample.md +73 -0
- package/skills/press-release/template.md +39 -0
- package/skills/prioritization-advisor/SKILL.md +451 -0
- package/skills/proactive-messages/.clawhub/origin.json +7 -0
- package/skills/proactive-messages/SKILL.md +91 -0
- package/skills/problem-framing-canvas/SKILL.md +466 -0
- package/skills/problem-framing-canvas/examples/sample.md +58 -0
- package/skills/problem-framing-canvas/template.md +22 -0
- package/skills/problem-statement/SKILL.md +255 -0
- package/skills/problem-statement/examples/sample.md +82 -0
- package/skills/problem-statement/template.md +37 -0
- package/skills/product-strategy-session/SKILL.md +434 -0
- package/skills/product-strategy-session/examples/sample.md +67 -0
- package/skills/product-strategy-session/template.md +38 -0
- package/skills/prompt-guard/.clawhub/origin.json +7 -0
- package/skills/prompt-guard/ARCHITECTURE.md +364 -0
- package/skills/prompt-guard/CHANGELOG.md +200 -0
- package/skills/prompt-guard/README.md +215 -0
- package/skills/prompt-guard/SECURITY.md +66 -0
- package/skills/prompt-guard/SKILL.md +174 -0
- package/skills/prompt-guard/blog/how-i-secured-my-ai-agent.md +185 -0
- package/skills/prompt-guard/config.example.yaml +56 -0
- package/skills/prompt-guard/references/detection-patterns.md +298 -0
- package/skills/prompt-guard/requirements.txt +1 -0
- package/skills/prompt-guard/scripts/analyze_log.py +224 -0
- package/skills/prompt-guard/scripts/audit.py +344 -0
- package/skills/prompt-guard/scripts/detect.py +1587 -0
- package/skills/prompt-guard/scripts/hivefence.py +345 -0
- package/skills/proto-persona/SKILL.md +336 -0
- package/skills/proto-persona/examples/sample.md +97 -0
- package/skills/proto-persona/template.md +45 -0
- package/skills/recommendation-canvas/SKILL.md +382 -0
- package/skills/recommendation-canvas/examples/sample.md +94 -0
- package/skills/recommendation-canvas/template.md +86 -0
- package/skills/refactor-suggest/.clawhub/origin.json +7 -0
- package/skills/refactor-suggest/SKILL.md +94 -0
- package/skills/roadmap-planning/SKILL.md +506 -0
- package/skills/roadmap-planning/examples/sample.md +62 -0
- package/skills/roadmap-planning/template.md +30 -0
- package/skills/saas-economics-efficiency-metrics/SKILL.md +694 -0
- package/skills/saas-economics-efficiency-metrics/examples/cash-trap.md +365 -0
- package/skills/saas-economics-efficiency-metrics/examples/healthy-unit-economics.md +279 -0
- package/skills/saas-economics-efficiency-metrics/template.md +263 -0
- package/skills/saas-revenue-growth-metrics/SKILL.md +629 -0
- package/skills/saas-revenue-growth-metrics/examples/healthy-saas.md +131 -0
- package/skills/saas-revenue-growth-metrics/examples/warning-signs.md +229 -0
- package/skills/saas-revenue-growth-metrics/template.md +192 -0
- package/skills/save-money/.clawhub/origin.json +7 -0
- package/skills/save-money/SKILL.md +173 -0
- package/skills/scripts/golden_skills_v3.sh +32 -0
- package/skills/search/.clawhub/origin.json +7 -0
- package/skills/search/SKILL.md +18 -0
- package/skills/search/skill.json +1 -0
- package/skills/second-brain/.clawhub/origin.json +7 -0
- package/skills/second-brain/SKILL.md +278 -0
- package/skills/second-brain/scripts/ensue-api.sh +37 -0
- package/skills/self-improving-agent/.clawhub/origin.json +7 -0
- package/skills/self-improving-agent/.learnings/ERRORS.md +5 -0
- package/skills/self-improving-agent/.learnings/FEATURE_REQUESTS.md +5 -0
- package/skills/self-improving-agent/.learnings/LEARNINGS.md +5 -0
- package/skills/self-improving-agent/SKILL.md +130 -0
- package/skills/self-improving-agent/assets/LEARNINGS.md +45 -0
- package/skills/self-improving-agent/assets/SKILL-TEMPLATE.md +177 -0
- package/skills/self-improving-agent/hooks/openclaw/HOOK.md +23 -0
- package/skills/self-improving-agent/hooks/openclaw/handler.js +56 -0
- package/skills/self-improving-agent/hooks/openclaw/handler.ts +62 -0
- package/skills/self-improving-agent/references/examples.md +374 -0
- package/skills/self-improving-agent/references/hooks-setup.md +223 -0
- package/skills/self-improving-agent/references/openclaw-integration.md +248 -0
- package/skills/self-improving-agent/references/templates.md +480 -0
- package/skills/self-improving-agent/scripts/activator.sh +20 -0
- package/skills/self-improving-agent/scripts/error-detector.sh +55 -0
- package/skills/self-improving-agent/scripts/extract-skill.sh +203 -0
- package/skills/self-improving-agent-1-0-2/.clawhub/origin.json +7 -0
- package/skills/self-improving-agent-1-0-2/SKILL.md +562 -0
- package/skills/self-improving-agent-1-0-2/assets/LEARNINGS.md +45 -0
- package/skills/self-improving-agent-1-0-2/assets/SKILL-TEMPLATE.md +182 -0
- package/skills/self-improving-agent-1-0-2/references/clawdbot-integration.md +311 -0
- package/skills/self-improving-agent-1-0-2/references/examples.md +374 -0
- package/skills/self-improving-agent-1-0-2/references/hooks-setup.md +223 -0
- package/skills/self-improving-agent-1-0-2/scripts/activator.sh +20 -0
- package/skills/self-improving-agent-1-0-2/scripts/error-detector.sh +55 -0
- package/skills/self-improving-agent-1-0-2/scripts/extract-skill.sh +203 -0
- package/skills/self-love-confidence/.clawhub/origin.json +7 -0
- package/skills/self-love-confidence/SKILL.md +79 -0
- package/skills/self-reflection/.clawhub/origin.json +7 -0
- package/skills/self-reflection/README.md +292 -0
- package/skills/self-reflection/SKILL.md +110 -0
- package/skills/self-reflection/self-reflection.example.json +6 -0
- package/skills/slither-analyzer/SKILL.md +27 -0
- package/skills/solidity-audit/SKILL.md +27 -0
- package/skills/soulcraft/.clawhub/origin.json +7 -0
- package/skills/soulcraft/README.md +123 -0
- package/skills/soulcraft/SKILL.md +340 -0
- package/skills/soulcraft/references/question-bank.md +154 -0
- package/skills/soulcraft/references/soul-examples.md +207 -0
- package/skills/soulcraft/research/RESEARCH_REPORT.md +317 -0
- package/skills/spotify-player/.clawhub/origin.json +7 -0
- package/skills/spotify-player/SKILL.md +44 -0
- package/skills/storyboard/SKILL.md +259 -0
- package/skills/storyboard/examples/sample.md +71 -0
- package/skills/storyboard/template.md +41 -0
- package/skills/summarize/.clawhub/origin.json +7 -0
- package/skills/summarize/SKILL.md +59 -0
- package/skills/superdesign/.clawhub/origin.json +7 -0
- package/skills/superdesign/SKILL.md +224 -0
- package/skills/tam-sam-som-calculator/SKILL.md +399 -0
- package/skills/tam-sam-som-calculator/examples/sample.md +142 -0
- package/skills/tam-sam-som-calculator/scripts/market-sizing.py +95 -0
- package/skills/tam-sam-som-calculator/template.md +35 -0
- package/skills/tavily-search/.clawhub/origin.json +7 -0
- package/skills/tavily-search/SKILL.md +49 -0
- package/skills/tavily-search/scripts/extract.mjs +59 -0
- package/skills/tavily-search/scripts/search.mjs +101 -0
- package/skills/twitter/SKILL.md +74 -0
- package/skills/twitter/_meta.json +9 -0
- package/skills/twitter/references/validation-cases.md +53 -0
- package/skills/twitter/scripts/twitter.sh +421 -0
- package/skills/ui-ux-pro-max/.clawhub/origin.json +7 -0
- package/skills/ui-ux-pro-max/SKILL.md +54 -0
- package/skills/ui-ux-pro-max/assets/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/assets/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/assets/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/assets/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/assets/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/assets/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/assets/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/assets/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/assets/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/assets/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/assets/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/assets/data/web-interface.csv +31 -0
- package/skills/ui-ux-pro-max/references/upstream-README.md +488 -0
- package/skills/ui-ux-pro-max/references/upstream-skill-content.md +288 -0
- package/skills/ui-ux-pro-max/scripts/__init__.py +0 -0
- package/skills/ui-ux-pro-max/scripts/core.py +253 -0
- package/skills/ui-ux-pro-max/scripts/design_system.py +1071 -0
- package/skills/ui-ux-pro-max/scripts/search.py +111 -0
- package/skills/user-story/SKILL.md +272 -0
- package/skills/user-story/examples/sample.md +110 -0
- package/skills/user-story/scripts/user-story-template.py +65 -0
- package/skills/user-story/template.md +32 -0
- package/skills/user-story-mapping/SKILL.md +296 -0
- package/skills/user-story-mapping/examples/sample.md +77 -0
- package/skills/user-story-mapping/template.md +41 -0
- package/skills/user-story-mapping-workshop/SKILL.md +485 -0
- package/skills/user-story-mapping-workshop/template.md +28 -0
- package/skills/user-story-splitting/SKILL.md +313 -0
- package/skills/user-story-splitting/examples/sample.md +147 -0
- package/skills/user-story-splitting/template.md +37 -0
- package/skills/wacli/.clawhub/origin.json +7 -0
- package/skills/wacli/SKILL.md +53 -0
- package/skills/web-search/.clawhub/origin.json +7 -0
- package/skills/web-search/SKILL.md +151 -0
- package/skills/web-search/references/api-details.md +207 -0
- package/skills/web-search/scripts/search.py +576 -0
- package/skills/workshop-facilitation/SKILL.md +88 -0
- package/skills/world-builder/SKILL.md +27 -0
- package/souls/blockchain-auditor/PRINCIPLES.md +75 -0
- package/souls/blockchain-auditor/SOUL.md +56 -0
- package/souls/blockchain-auditor/capabilities.json +33 -0
- package/souls/blockchain-auditor/evolution/capsules.json +4 -0
- package/souls/blockchain-auditor/evolution/events.jsonl +1 -0
- package/souls/blockchain-auditor/evolution/genes.json +62 -0
- package/souls/daedalus/PRINCIPLES.md +78 -0
- package/souls/daedalus/SOUL.md +48 -0
- package/souls/daedalus/capabilities.json +46 -0
- package/souls/identity-architect/PRINCIPLES.md +83 -0
- package/souls/identity-architect/SOUL.md +66 -0
- package/souls/identity-architect/capabilities.json +38 -0
- package/souls/identity-architect/evolution/capsules.json +4 -0
- package/souls/identity-architect/evolution/events.jsonl +0 -0
- package/souls/identity-architect/evolution/genes.json +4 -0
- package/souls/infra-ops/PRINCIPLES.md +77 -0
- package/souls/infra-ops/SOUL.md +56 -0
- package/souls/infra-ops/capabilities.json +33 -0
- package/souls/infra-ops/evolution/capsules.json +4 -0
- package/souls/infra-ops/evolution/events.jsonl +0 -0
- package/souls/infra-ops/evolution/genes.json +4 -0
- package/souls/lore-writer/PRINCIPLES.md +74 -0
- package/souls/lore-writer/SOUL.md +54 -0
- package/souls/lore-writer/capabilities.json +37 -0
- package/souls/lore-writer/evolution/capsules.json +4 -0
- package/souls/lore-writer/evolution/events.jsonl +0 -0
- package/souls/lore-writer/evolution/genes.json +4 -0
- package/souls/qa-evidence/PRINCIPLES.md +97 -0
- package/souls/qa-evidence/SOUL.md +66 -0
- package/souls/qa-evidence/capabilities.json +32 -0
- package/souls/qa-evidence/evolution/capsules.json +4 -0
- package/souls/qa-evidence/evolution/events.jsonl +0 -0
- package/souls/qa-evidence/evolution/genes.json +4 -0
- package/souls/registry.json +211 -0
- package/souls/sync-registry.js +65 -0
- package/uninstall.sh +102 -0
- package/workspace-bin/auto-checkpoint +60 -0
- package/workspace-bin/clawvault-access-control +65 -0
- package/workspace-bin/clawvault-local +28 -0
- package/workspace-bin/compile-boot +494 -0
- package/workspace-bin/daily-log-writer.mjs +251 -0
- package/workspace-bin/evolve +540 -0
- package/workspace-bin/fitness_score.py +395 -0
- package/workspace-bin/hooks/pre-commit +80 -0
- package/workspace-bin/install-daemon +299 -0
- package/workspace-bin/lane-watchdog.js +232 -0
- package/workspace-bin/lib/__init__.py +0 -0
- package/workspace-bin/lib/frontmatter.py +114 -0
- package/workspace-bin/memory-daemon.mjs +879 -0
- package/workspace-bin/memory-maintenance.mjs +531 -0
- package/workspace-bin/mesh-bridge.mjs +154 -0
- package/workspace-bin/multi-review +130 -0
- package/workspace-bin/obsidian +125 -0
- package/workspace-bin/obsidian-sync.mjs +888 -0
- package/workspace-bin/openclaw-register-source +102 -0
- package/workspace-bin/proactive-scan +147 -0
- package/workspace-bin/quality-gate +175 -0
- package/workspace-bin/screenshot +96 -0
- package/workspace-bin/session-recap +453 -0
- package/workspace-bin/skill-audit +494 -0
- package/workspace-bin/skill-quality-check +134 -0
- package/workspace-bin/skill-routing-eval +599 -0
- package/workspace-bin/soul-prompt +251 -0
- package/workspace-bin/subagent-audit.mjs +267 -0
- package/workspace-bin/test-multi-soul-workflow +130 -0
- package/workspace-bin/trust-registry +465 -0
- package/workspace-docs/AGENTS.md +201 -0
- package/workspace-docs/CLAUDE.md +64 -0
- package/workspace-docs/PRINCIPLES.md +81 -0
- package/workspace-docs/SOUL.md +48 -0
|
@@ -0,0 +1,988 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
import json
|
|
3
|
+
import math
|
|
4
|
+
import re
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
import urllib.error
|
|
9
|
+
import urllib.parse
|
|
10
|
+
import urllib.request
|
|
11
|
+
from datetime import datetime, timezone
|
|
12
|
+
|
|
13
|
+
DEFAULT_HOURS = 24
|
|
14
|
+
CANDLE_MINUTES = 15
|
|
15
|
+
CACHE_TTL_SEC = 300
|
|
16
|
+
COINGECKO_PRICE_URL = "https://api.coingecko.com/api/v3/simple/price?ids={id}&vs_currencies={currency}"
|
|
17
|
+
COINGECKO_OHLC_URL = "https://api.coingecko.com/api/v3/coins/{id}/ohlc?vs_currency={currency}&days=1"
|
|
18
|
+
COINGECKO_SEARCH_URL = "https://api.coingecko.com/api/v3/search?query={query}"
|
|
19
|
+
COINGECKO_MARKET_CHART_URL = "https://api.coingecko.com/api/v3/coins/{id}/market_chart?vs_currency={currency}&days=1"
|
|
20
|
+
COINGECKO_MARKET_CHART_DAYS_URL = "https://api.coingecko.com/api/v3/coins/{id}/market_chart?vs_currency={currency}&days={days}"
|
|
21
|
+
HYPERLIQUID_INFO_URL = "https://api.hyperliquid.xyz/info"
|
|
22
|
+
|
|
23
|
+
TOKEN_ID_MAP = {
|
|
24
|
+
"HYPE": "hyperliquid",
|
|
25
|
+
"HYPERLIQUID": "hyperliquid",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _json_error(message, details=None):
|
|
30
|
+
payload = {"error": message}
|
|
31
|
+
if details:
|
|
32
|
+
payload["details"] = details
|
|
33
|
+
print(json.dumps(payload))
|
|
34
|
+
return 0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _cache_path(prefix, token_id):
|
|
38
|
+
safe = token_id.replace("/", "-")
|
|
39
|
+
return f"/tmp/crypto_price_{prefix}_{safe}.json"
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _read_cache(path, max_age_sec):
|
|
43
|
+
try:
|
|
44
|
+
stat = os.stat(path)
|
|
45
|
+
except FileNotFoundError:
|
|
46
|
+
return None
|
|
47
|
+
age = time.time() - stat.st_mtime
|
|
48
|
+
if age > max_age_sec:
|
|
49
|
+
return None
|
|
50
|
+
try:
|
|
51
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
52
|
+
return json.load(handle)
|
|
53
|
+
except (OSError, json.JSONDecodeError):
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _write_cache(path, payload):
|
|
58
|
+
try:
|
|
59
|
+
with open(path, "w", encoding="utf-8") as handle:
|
|
60
|
+
json.dump(payload, handle)
|
|
61
|
+
except OSError:
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _fetch_json(url):
|
|
66
|
+
req = urllib.request.Request(
|
|
67
|
+
url,
|
|
68
|
+
headers={"User-Agent": "clawdbot-crypto-price/1.0"},
|
|
69
|
+
)
|
|
70
|
+
retry_codes = {429, 502, 503, 504}
|
|
71
|
+
last_error = None
|
|
72
|
+
for attempt in range(3):
|
|
73
|
+
try:
|
|
74
|
+
with urllib.request.urlopen(req, timeout=15) as resp:
|
|
75
|
+
raw = resp.read().decode("utf-8")
|
|
76
|
+
try:
|
|
77
|
+
return json.loads(raw)
|
|
78
|
+
except json.JSONDecodeError as exc:
|
|
79
|
+
raise RuntimeError("invalid JSON") from exc
|
|
80
|
+
except urllib.error.HTTPError as exc:
|
|
81
|
+
last_error = exc
|
|
82
|
+
if exc.code in retry_codes and attempt < 2:
|
|
83
|
+
time.sleep(2 * (attempt + 1))
|
|
84
|
+
continue
|
|
85
|
+
raise RuntimeError(str(exc)) from exc
|
|
86
|
+
except urllib.error.URLError as exc:
|
|
87
|
+
last_error = exc
|
|
88
|
+
if attempt < 2:
|
|
89
|
+
time.sleep(2 * (attempt + 1))
|
|
90
|
+
continue
|
|
91
|
+
raise RuntimeError(str(exc)) from exc
|
|
92
|
+
raise RuntimeError(str(last_error))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _post_json(url, payload):
|
|
96
|
+
req = urllib.request.Request(
|
|
97
|
+
url,
|
|
98
|
+
data=json.dumps(payload).encode("utf-8"),
|
|
99
|
+
headers={"Content-Type": "application/json", "User-Agent": "clawdbot-crypto-price/1.0"},
|
|
100
|
+
)
|
|
101
|
+
retry_codes = {429, 502, 503, 504}
|
|
102
|
+
last_error = None
|
|
103
|
+
for attempt in range(3):
|
|
104
|
+
try:
|
|
105
|
+
with urllib.request.urlopen(req, timeout=15) as resp:
|
|
106
|
+
raw = resp.read().decode("utf-8")
|
|
107
|
+
try:
|
|
108
|
+
return json.loads(raw)
|
|
109
|
+
except json.JSONDecodeError as exc:
|
|
110
|
+
raise RuntimeError("invalid JSON") from exc
|
|
111
|
+
except urllib.error.HTTPError as exc:
|
|
112
|
+
last_error = exc
|
|
113
|
+
if exc.code in retry_codes and attempt < 2:
|
|
114
|
+
time.sleep(2 * (attempt + 1))
|
|
115
|
+
continue
|
|
116
|
+
raise RuntimeError(str(exc)) from exc
|
|
117
|
+
except urllib.error.URLError as exc:
|
|
118
|
+
last_error = exc
|
|
119
|
+
if attempt < 2:
|
|
120
|
+
time.sleep(2 * (attempt + 1))
|
|
121
|
+
continue
|
|
122
|
+
raise RuntimeError(str(exc)) from exc
|
|
123
|
+
raise RuntimeError(str(last_error))
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _post_json(url, payload):
|
|
127
|
+
req = urllib.request.Request(
|
|
128
|
+
url,
|
|
129
|
+
data=json.dumps(payload).encode("utf-8"),
|
|
130
|
+
headers={"Content-Type": "application/json", "User-Agent": "clawdbot-crypto-price/1.0"},
|
|
131
|
+
)
|
|
132
|
+
retry_codes = {429, 502, 503, 504}
|
|
133
|
+
last_error = None
|
|
134
|
+
for attempt in range(3):
|
|
135
|
+
try:
|
|
136
|
+
with urllib.request.urlopen(req, timeout=15) as resp:
|
|
137
|
+
raw = resp.read().decode("utf-8")
|
|
138
|
+
try:
|
|
139
|
+
return json.loads(raw)
|
|
140
|
+
except json.JSONDecodeError as exc:
|
|
141
|
+
raise RuntimeError("invalid JSON") from exc
|
|
142
|
+
except urllib.error.HTTPError as exc:
|
|
143
|
+
last_error = exc
|
|
144
|
+
if exc.code in retry_codes and attempt < 2:
|
|
145
|
+
time.sleep(2 * (attempt + 1))
|
|
146
|
+
continue
|
|
147
|
+
raise RuntimeError(str(exc)) from exc
|
|
148
|
+
except urllib.error.URLError as exc:
|
|
149
|
+
last_error = exc
|
|
150
|
+
if attempt < 2:
|
|
151
|
+
time.sleep(2 * (attempt + 1))
|
|
152
|
+
continue
|
|
153
|
+
raise RuntimeError(str(exc)) from exc
|
|
154
|
+
raise RuntimeError(str(last_error))
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _get_price(token_id, currency):
|
|
158
|
+
cache_path = _cache_path(f"price_{currency}", token_id)
|
|
159
|
+
cached = _read_cache(cache_path, CACHE_TTL_SEC)
|
|
160
|
+
if cached is not None:
|
|
161
|
+
return cached
|
|
162
|
+
data = _fetch_json(COINGECKO_PRICE_URL.format(id=token_id, currency=currency))
|
|
163
|
+
_write_cache(cache_path, data)
|
|
164
|
+
return data
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _get_ohlc(token_id, currency):
|
|
168
|
+
cache_path = _cache_path(f"ohlc_{currency}", token_id)
|
|
169
|
+
cached = _read_cache(cache_path, CACHE_TTL_SEC)
|
|
170
|
+
if cached is not None:
|
|
171
|
+
return cached
|
|
172
|
+
data = _fetch_json(COINGECKO_OHLC_URL.format(id=token_id, currency=currency))
|
|
173
|
+
_write_cache(cache_path, data)
|
|
174
|
+
return data
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _get_market_chart(token_id, currency, days):
|
|
178
|
+
cache_path = _cache_path(f"market_{currency}_{days}", token_id)
|
|
179
|
+
cached = _read_cache(cache_path, CACHE_TTL_SEC)
|
|
180
|
+
if cached is not None:
|
|
181
|
+
return cached
|
|
182
|
+
if days == 1:
|
|
183
|
+
url = COINGECKO_MARKET_CHART_URL.format(id=token_id, currency=currency)
|
|
184
|
+
else:
|
|
185
|
+
url = COINGECKO_MARKET_CHART_DAYS_URL.format(id=token_id, currency=currency, days=days)
|
|
186
|
+
data = _fetch_json(url)
|
|
187
|
+
_write_cache(cache_path, data)
|
|
188
|
+
return data
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _get_hyperliquid_meta():
|
|
192
|
+
cache_path = _cache_path("hyperliquid_meta", "meta")
|
|
193
|
+
cached = _read_cache(cache_path, CACHE_TTL_SEC)
|
|
194
|
+
if cached is not None:
|
|
195
|
+
return cached
|
|
196
|
+
data = _post_json(HYPERLIQUID_INFO_URL, {"type": "metaAndAssetCtxs"})
|
|
197
|
+
_write_cache(cache_path, data)
|
|
198
|
+
return data
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _hyperliquid_lookup(symbol):
|
|
202
|
+
try:
|
|
203
|
+
meta, ctxs = _get_hyperliquid_meta()
|
|
204
|
+
except RuntimeError:
|
|
205
|
+
return None, None
|
|
206
|
+
universe = meta.get("universe", [])
|
|
207
|
+
mapping = {}
|
|
208
|
+
for idx, entry in enumerate(universe):
|
|
209
|
+
name = str(entry.get("name", "")).upper()
|
|
210
|
+
if name:
|
|
211
|
+
mapping[name] = idx
|
|
212
|
+
idx = mapping.get(symbol.upper())
|
|
213
|
+
if idx is None or idx >= len(ctxs):
|
|
214
|
+
return None, None
|
|
215
|
+
return universe[idx], ctxs[idx]
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _pick_hyperliquid_interval_minutes(total_minutes):
|
|
219
|
+
if total_minutes <= 180:
|
|
220
|
+
return 1
|
|
221
|
+
if total_minutes <= 360:
|
|
222
|
+
return 3
|
|
223
|
+
if total_minutes <= 720:
|
|
224
|
+
return 5
|
|
225
|
+
if total_minutes <= 1440:
|
|
226
|
+
return 15
|
|
227
|
+
if total_minutes <= 4320:
|
|
228
|
+
return 30
|
|
229
|
+
if total_minutes <= 10080:
|
|
230
|
+
return 60
|
|
231
|
+
if total_minutes <= 20160:
|
|
232
|
+
return 120
|
|
233
|
+
if total_minutes <= 40320:
|
|
234
|
+
return 240
|
|
235
|
+
if total_minutes <= 80640:
|
|
236
|
+
return 480
|
|
237
|
+
return 1440
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def _interval_minutes_to_str(minutes):
|
|
241
|
+
if minutes < 60:
|
|
242
|
+
return f"{int(minutes)}m"
|
|
243
|
+
hours = int(minutes / 60)
|
|
244
|
+
if hours < 24:
|
|
245
|
+
return f"{hours}h"
|
|
246
|
+
days = int(hours / 24)
|
|
247
|
+
return f"{days}d"
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _get_hyperliquid_candles(symbol, total_minutes, interval_minutes):
|
|
251
|
+
now_ms = int(time.time() * 1000)
|
|
252
|
+
start_ms = now_ms - int(total_minutes * 60 * 1000)
|
|
253
|
+
payload = {
|
|
254
|
+
"type": "candleSnapshot",
|
|
255
|
+
"req": {
|
|
256
|
+
"coin": symbol.upper(),
|
|
257
|
+
"interval": _interval_minutes_to_str(interval_minutes),
|
|
258
|
+
"startTime": start_ms,
|
|
259
|
+
"endTime": now_ms,
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
data = _post_json(HYPERLIQUID_INFO_URL, payload)
|
|
263
|
+
candles = []
|
|
264
|
+
for row in data:
|
|
265
|
+
try:
|
|
266
|
+
ts_ms = int(row["t"])
|
|
267
|
+
open_price = float(row["o"])
|
|
268
|
+
high_price = float(row["h"])
|
|
269
|
+
low_price = float(row["l"])
|
|
270
|
+
close_price = float(row["c"])
|
|
271
|
+
except (KeyError, TypeError, ValueError):
|
|
272
|
+
continue
|
|
273
|
+
candles.append((ts_ms, open_price, high_price, low_price, close_price))
|
|
274
|
+
return candles
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _get_hyperliquid_meta():
|
|
278
|
+
cache_path = _cache_path("hyperliquid_meta", "meta")
|
|
279
|
+
cached = _read_cache(cache_path, CACHE_TTL_SEC)
|
|
280
|
+
if cached is not None:
|
|
281
|
+
return cached
|
|
282
|
+
data = _post_json(HYPERLIQUID_INFO_URL, {"type": "metaAndAssetCtxs"})
|
|
283
|
+
_write_cache(cache_path, data)
|
|
284
|
+
return data
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def _hyperliquid_lookup(symbol):
|
|
288
|
+
try:
|
|
289
|
+
meta, ctxs = _get_hyperliquid_meta()
|
|
290
|
+
except RuntimeError:
|
|
291
|
+
return None, None
|
|
292
|
+
universe = meta.get("universe", [])
|
|
293
|
+
mapping = {}
|
|
294
|
+
for idx, entry in enumerate(universe):
|
|
295
|
+
name = str(entry.get("name", "")).upper()
|
|
296
|
+
if name:
|
|
297
|
+
mapping[name] = idx
|
|
298
|
+
idx = mapping.get(symbol.upper())
|
|
299
|
+
if idx is None or idx >= len(ctxs):
|
|
300
|
+
return None, None
|
|
301
|
+
return universe[idx], ctxs[idx]
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def _pick_hyperliquid_interval_minutes(total_minutes):
|
|
305
|
+
if total_minutes <= 180:
|
|
306
|
+
return 1
|
|
307
|
+
if total_minutes <= 360:
|
|
308
|
+
return 3
|
|
309
|
+
if total_minutes <= 720:
|
|
310
|
+
return 5
|
|
311
|
+
if total_minutes <= 1440:
|
|
312
|
+
return 15
|
|
313
|
+
if total_minutes <= 4320:
|
|
314
|
+
return 30
|
|
315
|
+
if total_minutes <= 10080:
|
|
316
|
+
return 60
|
|
317
|
+
if total_minutes <= 20160:
|
|
318
|
+
return 120
|
|
319
|
+
if total_minutes <= 40320:
|
|
320
|
+
return 240
|
|
321
|
+
if total_minutes <= 80640:
|
|
322
|
+
return 480
|
|
323
|
+
return 1440
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def _interval_minutes_to_str(minutes):
|
|
327
|
+
if minutes < 60:
|
|
328
|
+
return f"{int(minutes)}m"
|
|
329
|
+
hours = int(minutes / 60)
|
|
330
|
+
if hours < 24:
|
|
331
|
+
return f"{hours}h"
|
|
332
|
+
days = int(hours / 24)
|
|
333
|
+
return f"{days}d"
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def _get_hyperliquid_candles(symbol, total_minutes, interval_minutes):
|
|
337
|
+
now_ms = int(time.time() * 1000)
|
|
338
|
+
start_ms = now_ms - int(total_minutes * 60 * 1000)
|
|
339
|
+
payload = {
|
|
340
|
+
"type": "candleSnapshot",
|
|
341
|
+
"req": {
|
|
342
|
+
"coin": symbol.upper(),
|
|
343
|
+
"interval": _interval_minutes_to_str(interval_minutes),
|
|
344
|
+
"startTime": start_ms,
|
|
345
|
+
"endTime": now_ms,
|
|
346
|
+
},
|
|
347
|
+
}
|
|
348
|
+
data = _post_json(HYPERLIQUID_INFO_URL, payload)
|
|
349
|
+
candles = []
|
|
350
|
+
for row in data:
|
|
351
|
+
try:
|
|
352
|
+
ts_ms = int(row["t"])
|
|
353
|
+
open_price = float(row["o"])
|
|
354
|
+
high_price = float(row["h"])
|
|
355
|
+
low_price = float(row["l"])
|
|
356
|
+
close_price = float(row["c"])
|
|
357
|
+
volume = float(row.get("v", 0))
|
|
358
|
+
except (KeyError, TypeError, ValueError):
|
|
359
|
+
continue
|
|
360
|
+
candles.append((ts_ms, open_price, high_price, low_price, close_price, volume))
|
|
361
|
+
return candles
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def _find_fractals(ohlc_rows, window=10, max_fractals=3):
|
|
365
|
+
"""Find true swing highs and lows.
|
|
366
|
+
Swing high: highest high within window candles on both sides.
|
|
367
|
+
Swing low: lowest low within window candles on both sides.
|
|
368
|
+
Returns list of (index, type, price) where type is 'up' or 'down'.
|
|
369
|
+
"""
|
|
370
|
+
if len(ohlc_rows) < window * 2 + 1:
|
|
371
|
+
return []
|
|
372
|
+
|
|
373
|
+
swing_highs = []
|
|
374
|
+
swing_lows = []
|
|
375
|
+
|
|
376
|
+
for i in range(window, len(ohlc_rows) - window):
|
|
377
|
+
current_high = ohlc_rows[i][2]
|
|
378
|
+
current_low = ohlc_rows[i][3]
|
|
379
|
+
|
|
380
|
+
# Check if this is a swing high (highest high in the window)
|
|
381
|
+
is_swing_high = True
|
|
382
|
+
for j in range(i - window, i + window + 1):
|
|
383
|
+
if j != i and ohlc_rows[j][2] >= current_high:
|
|
384
|
+
is_swing_high = False
|
|
385
|
+
break
|
|
386
|
+
|
|
387
|
+
if is_swing_high:
|
|
388
|
+
swing_highs.append((i, current_high))
|
|
389
|
+
|
|
390
|
+
# Check if this is a swing low (lowest low in the window)
|
|
391
|
+
is_swing_low = True
|
|
392
|
+
for j in range(i - window, i + window + 1):
|
|
393
|
+
if j != i and ohlc_rows[j][3] <= current_low:
|
|
394
|
+
is_swing_low = False
|
|
395
|
+
break
|
|
396
|
+
|
|
397
|
+
if is_swing_low:
|
|
398
|
+
swing_lows.append((i, current_low))
|
|
399
|
+
|
|
400
|
+
# Sort by price extremity and take top N
|
|
401
|
+
# For highs: sort by price descending (highest first)
|
|
402
|
+
swing_highs.sort(key=lambda x: -x[1])
|
|
403
|
+
# For lows: sort by price ascending (lowest first)
|
|
404
|
+
swing_lows.sort(key=lambda x: x[1])
|
|
405
|
+
|
|
406
|
+
result = []
|
|
407
|
+
for idx, price in swing_highs[:max_fractals]:
|
|
408
|
+
result.append((idx, 'down', price)) # down arrow for resistance/high
|
|
409
|
+
for idx, price in swing_lows[:max_fractals]:
|
|
410
|
+
result.append((idx, 'up', price)) # up arrow for support/low
|
|
411
|
+
|
|
412
|
+
return sorted(result, key=lambda x: x[0])
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def _search_token_id(symbol):
|
|
416
|
+
cache_path = _cache_path("search", symbol.upper())
|
|
417
|
+
cached = _read_cache(cache_path, CACHE_TTL_SEC)
|
|
418
|
+
if cached is None:
|
|
419
|
+
data = _fetch_json(COINGECKO_SEARCH_URL.format(query=urllib.parse.quote(symbol)))
|
|
420
|
+
_write_cache(cache_path, data)
|
|
421
|
+
else:
|
|
422
|
+
data = cached
|
|
423
|
+
|
|
424
|
+
coins = data.get("coins", [])
|
|
425
|
+
symbol_upper = symbol.upper()
|
|
426
|
+
matches = [coin for coin in coins if coin.get("symbol", "").upper() == symbol_upper]
|
|
427
|
+
if not matches:
|
|
428
|
+
return None
|
|
429
|
+
|
|
430
|
+
def _rank_key(coin):
|
|
431
|
+
rank = coin.get("market_cap_rank")
|
|
432
|
+
return rank if isinstance(rank, int) else 10**9
|
|
433
|
+
|
|
434
|
+
matches.sort(key=_rank_key)
|
|
435
|
+
return matches[0].get("id")
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
def _format_price(value):
|
|
439
|
+
if value is None:
|
|
440
|
+
return "n/a"
|
|
441
|
+
if value >= 1:
|
|
442
|
+
return f"{value:.2f}"
|
|
443
|
+
return f"{value:.6f}"
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def _build_candles_from_prices(price_points, hours, candle_minutes):
|
|
447
|
+
if not price_points:
|
|
448
|
+
return []
|
|
449
|
+
price_points.sort(key=lambda row: row[0])
|
|
450
|
+
last_ts = price_points[-1][0]
|
|
451
|
+
start_ts = last_ts - (hours * 3600 * 1000)
|
|
452
|
+
bucket_ms = candle_minutes * 60 * 1000
|
|
453
|
+
candles = []
|
|
454
|
+
bucket = None
|
|
455
|
+
for ts, price in price_points:
|
|
456
|
+
if ts < start_ts:
|
|
457
|
+
continue
|
|
458
|
+
bucket_start = (int(ts) // bucket_ms) * bucket_ms
|
|
459
|
+
if bucket is None or bucket["bucket_start"] != bucket_start:
|
|
460
|
+
if bucket is not None:
|
|
461
|
+
candles.append((
|
|
462
|
+
bucket["bucket_start"],
|
|
463
|
+
bucket["open"],
|
|
464
|
+
bucket["high"],
|
|
465
|
+
bucket["low"],
|
|
466
|
+
bucket["close"],
|
|
467
|
+
))
|
|
468
|
+
bucket = {
|
|
469
|
+
"bucket_start": bucket_start,
|
|
470
|
+
"open": price,
|
|
471
|
+
"high": price,
|
|
472
|
+
"low": price,
|
|
473
|
+
"close": price,
|
|
474
|
+
}
|
|
475
|
+
else:
|
|
476
|
+
bucket["high"] = max(bucket["high"], price)
|
|
477
|
+
bucket["low"] = min(bucket["low"], price)
|
|
478
|
+
bucket["close"] = price
|
|
479
|
+
if bucket is not None:
|
|
480
|
+
candles.append((
|
|
481
|
+
bucket["bucket_start"],
|
|
482
|
+
bucket["open"],
|
|
483
|
+
bucket["high"],
|
|
484
|
+
bucket["low"],
|
|
485
|
+
bucket["close"],
|
|
486
|
+
))
|
|
487
|
+
return candles
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
def _parse_duration(args):
|
|
491
|
+
for arg in args:
|
|
492
|
+
cleaned = arg.strip().lower()
|
|
493
|
+
match = re.match(r"^(\d+(?:\.\d+)?)([mhd])?$", cleaned)
|
|
494
|
+
if not match:
|
|
495
|
+
continue
|
|
496
|
+
value = float(match.group(1))
|
|
497
|
+
unit = match.group(2) or "h"
|
|
498
|
+
if unit == "m":
|
|
499
|
+
total_minutes = max(1.0, value)
|
|
500
|
+
label = f"{int(value)}m" if value.is_integer() else f"{value}m"
|
|
501
|
+
elif unit == "d":
|
|
502
|
+
total_minutes = max(1.0, value * 24 * 60)
|
|
503
|
+
label = f"{int(value)}d" if value.is_integer() else f"{value}d"
|
|
504
|
+
else:
|
|
505
|
+
total_minutes = max(1.0, value * 60)
|
|
506
|
+
label = f"{int(value)}h" if value.is_integer() else f"{value}h"
|
|
507
|
+
return total_minutes, label
|
|
508
|
+
return float(DEFAULT_HOURS * 60), f"{DEFAULT_HOURS}h"
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
def _pick_candle_minutes(total_minutes):
|
|
512
|
+
if total_minutes <= 360:
|
|
513
|
+
return 5
|
|
514
|
+
if total_minutes <= 1440:
|
|
515
|
+
return 15
|
|
516
|
+
if total_minutes <= 4320:
|
|
517
|
+
return 30
|
|
518
|
+
return 60
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def _timestamp_to_datetime(ts_value):
|
|
522
|
+
ts = float(ts_value)
|
|
523
|
+
if ts >= 1e12:
|
|
524
|
+
ts = ts / 1000.0
|
|
525
|
+
return datetime.fromtimestamp(ts, tz=timezone.utc)
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def _build_chart(symbol, ohlc_rows, currency, label, use_gradient=False):
|
|
529
|
+
try:
|
|
530
|
+
import matplotlib
|
|
531
|
+
matplotlib.use("Agg")
|
|
532
|
+
import matplotlib.pyplot as plt
|
|
533
|
+
import matplotlib.dates as mdates
|
|
534
|
+
from matplotlib.lines import Line2D
|
|
535
|
+
from matplotlib.patches import Rectangle
|
|
536
|
+
import matplotlib.font_manager as fm
|
|
537
|
+
|
|
538
|
+
# Load custom font
|
|
539
|
+
font_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'fonts', 'Tomorrow.ttf')
|
|
540
|
+
if os.path.exists(font_path):
|
|
541
|
+
fm.fontManager.addfont(font_path)
|
|
542
|
+
custom_font = fm.FontProperties(fname=font_path).get_name()
|
|
543
|
+
plt.rcParams['font.family'] = custom_font
|
|
544
|
+
except Exception:
|
|
545
|
+
return None
|
|
546
|
+
|
|
547
|
+
if not ohlc_rows:
|
|
548
|
+
return None
|
|
549
|
+
|
|
550
|
+
# Check if we have volume data (6-element tuples)
|
|
551
|
+
has_volume = len(ohlc_rows[0]) >= 6 if ohlc_rows else False
|
|
552
|
+
|
|
553
|
+
if has_volume:
|
|
554
|
+
fig, (ax, ax_vol) = plt.subplots(2, 1, figsize=(8, 9), facecolor="#121212",
|
|
555
|
+
gridspec_kw={'height_ratios': [3, 1], 'hspace': 0.05})
|
|
556
|
+
ax_vol.set_facecolor("#121212")
|
|
557
|
+
else:
|
|
558
|
+
fig, ax = plt.subplots(figsize=(8, 8), facecolor="#121212")
|
|
559
|
+
ax_vol = None
|
|
560
|
+
|
|
561
|
+
ax.set_facecolor("#121212")
|
|
562
|
+
|
|
563
|
+
times = [_timestamp_to_datetime(row[0]) for row in ohlc_rows]
|
|
564
|
+
x_vals = mdates.date2num(times)
|
|
565
|
+
widths = []
|
|
566
|
+
if len(x_vals) > 1:
|
|
567
|
+
delta = min(x_vals[i + 1] - x_vals[i] for i in range(len(x_vals) - 1))
|
|
568
|
+
widths = [delta * 0.7] * len(x_vals)
|
|
569
|
+
else:
|
|
570
|
+
widths = [0.02] * len(x_vals)
|
|
571
|
+
delta = 0.02
|
|
572
|
+
|
|
573
|
+
lows = []
|
|
574
|
+
highs = []
|
|
575
|
+
volumes = []
|
|
576
|
+
colors = []
|
|
577
|
+
|
|
578
|
+
# Pre-calculate fractals
|
|
579
|
+
fractals = _find_fractals(ohlc_rows)
|
|
580
|
+
|
|
581
|
+
# Build sets of indices for swing coloring (only used in default mode)
|
|
582
|
+
bullish_reversal_indices = set()
|
|
583
|
+
bearish_reversal_indices = set()
|
|
584
|
+
|
|
585
|
+
# Always include absolute high/low candles in coloring
|
|
586
|
+
abs_high_idx = None
|
|
587
|
+
abs_low_idx = None
|
|
588
|
+
if ohlc_rows:
|
|
589
|
+
abs_high_idx = max(range(len(ohlc_rows)), key=lambda i: ohlc_rows[i][2])
|
|
590
|
+
abs_low_idx = min(range(len(ohlc_rows)), key=lambda i: ohlc_rows[i][3])
|
|
591
|
+
|
|
592
|
+
if not use_gradient:
|
|
593
|
+
for frac_idx, frac_type, frac_price in fractals:
|
|
594
|
+
if frac_type == 'up': # swing low = bullish reversal
|
|
595
|
+
for off in range(0, 3): # swing candle + 2 after = 3 total
|
|
596
|
+
if frac_idx + off < len(ohlc_rows):
|
|
597
|
+
bullish_reversal_indices.add(frac_idx + off)
|
|
598
|
+
else: # swing high = bearish reversal
|
|
599
|
+
for off in range(0, 3): # swing candle + 2 after = 3 total
|
|
600
|
+
if frac_idx + off < len(ohlc_rows):
|
|
601
|
+
bearish_reversal_indices.add(frac_idx + off)
|
|
602
|
+
|
|
603
|
+
if abs_low_idx is not None:
|
|
604
|
+
for off in range(0, 3):
|
|
605
|
+
if abs_low_idx + off < len(ohlc_rows):
|
|
606
|
+
bullish_reversal_indices.add(abs_low_idx + off)
|
|
607
|
+
if abs_high_idx is not None:
|
|
608
|
+
for off in range(0, 3):
|
|
609
|
+
if abs_high_idx + off < len(ohlc_rows):
|
|
610
|
+
bearish_reversal_indices.add(abs_high_idx + off)
|
|
611
|
+
|
|
612
|
+
for idx, row in enumerate(ohlc_rows):
|
|
613
|
+
if has_volume:
|
|
614
|
+
_ts, open_price, high_price, low_price, close_price, volume = row
|
|
615
|
+
volumes.append(volume)
|
|
616
|
+
else:
|
|
617
|
+
_ts, open_price, high_price, low_price, close_price = row[:5]
|
|
618
|
+
|
|
619
|
+
is_bullish = close_price >= open_price
|
|
620
|
+
x = x_vals[idx]
|
|
621
|
+
width = widths[idx]
|
|
622
|
+
lower = min(open_price, close_price)
|
|
623
|
+
height = max(abs(close_price - open_price), 1e-9)
|
|
624
|
+
|
|
625
|
+
if use_gradient:
|
|
626
|
+
# Gradient mode: green gradient up, blue-purple gradient down
|
|
627
|
+
wick_color = "#888888"
|
|
628
|
+
border_color = "#000000"
|
|
629
|
+
if is_bullish:
|
|
630
|
+
color_top = "#84dc58" # Bright green
|
|
631
|
+
color_bottom = "#336d16" # Dark green
|
|
632
|
+
else:
|
|
633
|
+
color_top = "#6c7ce4" # Blue
|
|
634
|
+
color_bottom = "#544996" # Purple
|
|
635
|
+
|
|
636
|
+
colors.append(color_top)
|
|
637
|
+
wick = Line2D([x, x], [low_price, high_price], color=wick_color, linewidth=1.0, zorder=3)
|
|
638
|
+
ax.add_line(wick)
|
|
639
|
+
|
|
640
|
+
# Draw gradient candle body
|
|
641
|
+
n_segments = 10
|
|
642
|
+
segment_height = height / n_segments
|
|
643
|
+
for seg in range(n_segments):
|
|
644
|
+
t = seg / (n_segments - 1) if n_segments > 1 else 0
|
|
645
|
+
r1, g1, b1 = int(color_bottom[1:3], 16), int(color_bottom[3:5], 16), int(color_bottom[5:7], 16)
|
|
646
|
+
r2, g2, b2 = int(color_top[1:3], 16), int(color_top[3:5], 16), int(color_top[5:7], 16)
|
|
647
|
+
r = int(r1 + (r2 - r1) * t)
|
|
648
|
+
g = int(g1 + (g2 - g1) * t)
|
|
649
|
+
b = int(b1 + (b2 - b1) * t)
|
|
650
|
+
seg_color = f'#{r:02x}{g:02x}{b:02x}'
|
|
651
|
+
seg_y = lower + seg * segment_height
|
|
652
|
+
rect = Rectangle((x - width / 2, seg_y), width, segment_height,
|
|
653
|
+
facecolor=seg_color, edgecolor='none', zorder=4)
|
|
654
|
+
ax.add_patch(rect)
|
|
655
|
+
border_rect = Rectangle((x - width / 2, lower), width, height,
|
|
656
|
+
facecolor='none', edgecolor=border_color, linewidth=0.5, zorder=5)
|
|
657
|
+
ax.add_patch(border_rect)
|
|
658
|
+
else:
|
|
659
|
+
# Default mode: Grey + Cyan/Magenta for swings
|
|
660
|
+
wick_color = "#808080"
|
|
661
|
+
border_color = "#000000"
|
|
662
|
+
up_normal = "#B0B0B0"
|
|
663
|
+
down_normal = "#606060"
|
|
664
|
+
up_reversal = "#00FFFF"
|
|
665
|
+
down_reversal = "#FF00FF"
|
|
666
|
+
|
|
667
|
+
if idx in bullish_reversal_indices:
|
|
668
|
+
color = up_reversal
|
|
669
|
+
elif idx in bearish_reversal_indices:
|
|
670
|
+
color = down_reversal
|
|
671
|
+
else:
|
|
672
|
+
color = up_normal if is_bullish else down_normal
|
|
673
|
+
|
|
674
|
+
colors.append(color)
|
|
675
|
+
wick = Line2D([x, x], [low_price, high_price], color=wick_color, linewidth=1.0, zorder=3)
|
|
676
|
+
ax.add_line(wick)
|
|
677
|
+
rect = Rectangle((x - width / 2, lower), width, height, facecolor=color, edgecolor=border_color, linewidth=0.5, zorder=4)
|
|
678
|
+
ax.add_patch(rect)
|
|
679
|
+
|
|
680
|
+
lows.append(low_price)
|
|
681
|
+
highs.append(high_price)
|
|
682
|
+
|
|
683
|
+
# Draw fractals (already calculated above)
|
|
684
|
+
price_range = max(highs) - min(lows) if highs and lows else 1
|
|
685
|
+
offset = price_range * 0.02
|
|
686
|
+
|
|
687
|
+
# Fractal colors based on mode
|
|
688
|
+
frac_up_color = "#84dc58" if use_gradient else "#00FFFF"
|
|
689
|
+
frac_down_color = "#6c7ce4" if use_gradient else "#FF00FF"
|
|
690
|
+
|
|
691
|
+
for frac_idx, frac_type, frac_price in fractals:
|
|
692
|
+
x = x_vals[frac_idx]
|
|
693
|
+
if frac_type == 'down': # bearish fractal - arrow down above high
|
|
694
|
+
ax.plot(x, frac_price + offset * 0.5, marker='v', color=frac_down_color, markersize=6, zorder=5)
|
|
695
|
+
ax.annotate(f'{frac_price:.2f}', xy=(x, frac_price + offset * 1.5),
|
|
696
|
+
fontsize=8, color='white', ha='center', va='bottom', zorder=6)
|
|
697
|
+
else: # bullish fractal - arrow up below low
|
|
698
|
+
ax.plot(x, frac_price - offset * 0.5, marker='^', color=frac_up_color, markersize=6, zorder=5)
|
|
699
|
+
ax.annotate(f'{frac_price:.2f}', xy=(x, frac_price - offset * 1.5),
|
|
700
|
+
fontsize=8, color='white', ha='center', va='top', zorder=6)
|
|
701
|
+
|
|
702
|
+
# Always mark absolute high/low so at least one swing high/low is visible
|
|
703
|
+
if highs and lows:
|
|
704
|
+
abs_high_price = max(highs)
|
|
705
|
+
abs_low_price = min(lows)
|
|
706
|
+
abs_high_idx = highs.index(abs_high_price)
|
|
707
|
+
abs_low_idx = lows.index(abs_low_price)
|
|
708
|
+
|
|
709
|
+
abs_high_color = "#FFD54F" # gold
|
|
710
|
+
abs_low_color = "#90CAF9" # light blue
|
|
711
|
+
|
|
712
|
+
xh = x_vals[abs_high_idx]
|
|
713
|
+
xl = x_vals[abs_low_idx]
|
|
714
|
+
|
|
715
|
+
ax.plot(xh, abs_high_price + offset * 0.5, marker='v', color=abs_high_color, markersize=7, zorder=6)
|
|
716
|
+
ax.annotate(f'{abs_high_price:.2f}', xy=(xh, abs_high_price + offset * 1.7),
|
|
717
|
+
fontsize=8, color='white', ha='center', va='bottom', zorder=7)
|
|
718
|
+
|
|
719
|
+
ax.plot(xl, abs_low_price - offset * 0.5, marker='^', color=abs_low_color, markersize=7, zorder=6)
|
|
720
|
+
ax.annotate(f'{abs_low_price:.2f}', xy=(xl, abs_low_price - offset * 1.7),
|
|
721
|
+
fontsize=8, color='white', ha='center', va='top', zorder=7)
|
|
722
|
+
|
|
723
|
+
# Draw volume bars
|
|
724
|
+
if has_volume and ax_vol and volumes:
|
|
725
|
+
for idx, vol in enumerate(volumes):
|
|
726
|
+
x = x_vals[idx]
|
|
727
|
+
width = widths[idx]
|
|
728
|
+
rect = Rectangle((x - width / 2, 0), width, vol,
|
|
729
|
+
facecolor=colors[idx], edgecolor=colors[idx], alpha=0.7, zorder=3)
|
|
730
|
+
ax_vol.add_patch(rect)
|
|
731
|
+
|
|
732
|
+
ax_vol.set_xlim(min(x_vals) - delta, max(x_vals) + delta)
|
|
733
|
+
ax_vol.set_ylim(0, max(volumes) * 1.1 if volumes else 1)
|
|
734
|
+
ax_vol.set_ylabel("Volume", color="#8b949e", fontsize=9)
|
|
735
|
+
ax_vol.tick_params(axis="x", colors="#8b949e")
|
|
736
|
+
ax_vol.tick_params(axis="y", colors="#8b949e")
|
|
737
|
+
for spine in ax_vol.spines.values():
|
|
738
|
+
spine.set_color("#2a2f38")
|
|
739
|
+
ax_vol.grid(True, linestyle="-", linewidth=0.6, color="#1f2630", alpha=0.8, zorder=1)
|
|
740
|
+
|
|
741
|
+
# Format volume axis
|
|
742
|
+
locator = mdates.AutoDateLocator(minticks=4, maxticks=8)
|
|
743
|
+
formatter = mdates.ConciseDateFormatter(locator)
|
|
744
|
+
ax_vol.xaxis.set_major_locator(locator)
|
|
745
|
+
ax_vol.xaxis.set_major_formatter(formatter)
|
|
746
|
+
ax.set_xticklabels([]) # Hide x labels on price chart
|
|
747
|
+
|
|
748
|
+
ax.set_title(f"{symbol} last {label}", loc="center", fontsize=14, color="white", fontweight="bold", pad=12)
|
|
749
|
+
if not has_volume:
|
|
750
|
+
ax.set_xlabel("Time (UTC)", color="#8b949e")
|
|
751
|
+
ax.set_ylabel(currency.upper(), color="#8b949e")
|
|
752
|
+
|
|
753
|
+
ax.tick_params(axis="x", colors="#8b949e")
|
|
754
|
+
ax.tick_params(axis="y", colors="#8b949e")
|
|
755
|
+
for spine in ax.spines.values():
|
|
756
|
+
spine.set_color("#2a2f38")
|
|
757
|
+
|
|
758
|
+
ax.grid(True, linestyle="-", linewidth=0.6, color="#1f2630", alpha=0.8, zorder=1)
|
|
759
|
+
|
|
760
|
+
if len(x_vals) > 1:
|
|
761
|
+
ax.set_xlim(min(x_vals) - delta, max(x_vals) + delta)
|
|
762
|
+
if lows and highs:
|
|
763
|
+
min_y = min(lows)
|
|
764
|
+
max_y = max(highs)
|
|
765
|
+
pad = (max_y - min_y) * 0.08 if max_y > min_y else max_y * 0.01 # More padding for fractals
|
|
766
|
+
ax.set_ylim(min_y - pad, max_y + pad)
|
|
767
|
+
|
|
768
|
+
if not has_volume:
|
|
769
|
+
locator = mdates.AutoDateLocator(minticks=4, maxticks=8)
|
|
770
|
+
formatter = mdates.ConciseDateFormatter(locator)
|
|
771
|
+
ax.xaxis.set_major_locator(locator)
|
|
772
|
+
ax.xaxis.set_major_formatter(formatter)
|
|
773
|
+
ax.tick_params(axis="x", labelrotation=0)
|
|
774
|
+
|
|
775
|
+
# Highlight last price on Y-axis
|
|
776
|
+
if ohlc_rows:
|
|
777
|
+
last_close = ohlc_rows[-1][4]
|
|
778
|
+
# Draw horizontal dashed line at last price
|
|
779
|
+
ax.axhline(y=last_close, color='white', linestyle='--', linewidth=0.8, alpha=0.6)
|
|
780
|
+
# Add price label on left side
|
|
781
|
+
ax.annotate(f'{last_close:.2f}', xy=(ax.get_xlim()[0], last_close),
|
|
782
|
+
fontsize=9, color='white', fontweight='bold',
|
|
783
|
+
ha='right', va='center',
|
|
784
|
+
bbox=dict(boxstyle='round,pad=0.3', facecolor='#0f141c', edgecolor='white', linewidth=1))
|
|
785
|
+
|
|
786
|
+
ts = int(time.time())
|
|
787
|
+
chart_path = f"/tmp/crypto_chart_{symbol}_{ts}.png"
|
|
788
|
+
fig.tight_layout()
|
|
789
|
+
fig.savefig(chart_path, dpi=150)
|
|
790
|
+
plt.close(fig)
|
|
791
|
+
return chart_path
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
def _normalize_hl_symbol(symbol):
|
|
795
|
+
sym = str(symbol or "").upper()
|
|
796
|
+
# Strip common separators (e.g., BTC-USD, BTC/USDC)
|
|
797
|
+
for sep in ("-", "/", "_"):
|
|
798
|
+
if sep in sym:
|
|
799
|
+
sym = sym.split(sep)[0]
|
|
800
|
+
break
|
|
801
|
+
# Strip common stablecoin suffixes (e.g., BTCUSDC)
|
|
802
|
+
stable_suffixes = ("USDC", "USDH", "USDE", "USD", "USDT")
|
|
803
|
+
for suf in stable_suffixes:
|
|
804
|
+
if sym.endswith(suf) and len(sym) > len(suf):
|
|
805
|
+
sym = sym[: -len(suf)]
|
|
806
|
+
break
|
|
807
|
+
return sym
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
def _hyperliquid_lookup(symbol):
|
|
811
|
+
try:
|
|
812
|
+
meta, ctxs = _get_hyperliquid_meta()
|
|
813
|
+
except RuntimeError:
|
|
814
|
+
return None, None
|
|
815
|
+
universe = meta.get("universe", [])
|
|
816
|
+
mapping = {}
|
|
817
|
+
for idx, entry in enumerate(universe):
|
|
818
|
+
name = str(entry.get("name", "")).upper()
|
|
819
|
+
if name:
|
|
820
|
+
mapping[name] = idx
|
|
821
|
+
norm = _normalize_hl_symbol(symbol)
|
|
822
|
+
idx = mapping.get(norm)
|
|
823
|
+
if idx is None or idx >= len(ctxs):
|
|
824
|
+
return None, None
|
|
825
|
+
return universe[idx], ctxs[idx]
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
def main():
|
|
829
|
+
if len(sys.argv) < 2:
|
|
830
|
+
return _json_error("missing symbol", "Usage: get_price_chart.py <symbol>")
|
|
831
|
+
|
|
832
|
+
raw_symbol = sys.argv[1].strip()
|
|
833
|
+
if not raw_symbol:
|
|
834
|
+
return _json_error("missing symbol", "Usage: get_price_chart.py <symbol>")
|
|
835
|
+
|
|
836
|
+
symbol_upper = raw_symbol.upper()
|
|
837
|
+
token_id = TOKEN_ID_MAP.get(symbol_upper)
|
|
838
|
+
if token_id is None:
|
|
839
|
+
token_id = raw_symbol.lower()
|
|
840
|
+
|
|
841
|
+
total_minutes, label = _parse_duration(sys.argv[2:])
|
|
842
|
+
# Check for gradient mode flag
|
|
843
|
+
use_gradient = any(arg.lower() in ('gradient', 'grad', '-g', '--gradient') for arg in sys.argv[2:])
|
|
844
|
+
hours = total_minutes / 60.0
|
|
845
|
+
source = "coingecko"
|
|
846
|
+
currency = "usdt"
|
|
847
|
+
price_usdt = None
|
|
848
|
+
hl_symbol = _normalize_hl_symbol(symbol_upper)
|
|
849
|
+
hl_meta, hl_ctx = _hyperliquid_lookup(hl_symbol)
|
|
850
|
+
if hl_ctx:
|
|
851
|
+
source = "hyperliquid"
|
|
852
|
+
currency = "usd"
|
|
853
|
+
try:
|
|
854
|
+
price_usdt = float(hl_ctx.get("markPx") or hl_ctx.get("midPx"))
|
|
855
|
+
except (TypeError, ValueError):
|
|
856
|
+
price_usdt = None
|
|
857
|
+
if price_usdt is None:
|
|
858
|
+
try:
|
|
859
|
+
price_payload = _get_price(token_id, currency)
|
|
860
|
+
except RuntimeError as exc:
|
|
861
|
+
return _json_error("price lookup failed", str(exc))
|
|
862
|
+
|
|
863
|
+
price_entry = price_payload.get(token_id, {})
|
|
864
|
+
price_usdt = price_entry.get(currency)
|
|
865
|
+
if price_usdt is None:
|
|
866
|
+
currency = "usd"
|
|
867
|
+
try:
|
|
868
|
+
price_payload = _get_price(token_id, currency)
|
|
869
|
+
except RuntimeError as exc:
|
|
870
|
+
return _json_error("price lookup failed", str(exc))
|
|
871
|
+
price_entry = price_payload.get(token_id, {})
|
|
872
|
+
price_usdt = price_entry.get(currency)
|
|
873
|
+
|
|
874
|
+
if price_usdt is None and token_id == raw_symbol.lower():
|
|
875
|
+
try:
|
|
876
|
+
searched_id = _search_token_id(symbol_upper)
|
|
877
|
+
except RuntimeError as exc:
|
|
878
|
+
return _json_error("token search failed", str(exc))
|
|
879
|
+
if searched_id:
|
|
880
|
+
token_id = searched_id
|
|
881
|
+
currency = "usdt"
|
|
882
|
+
try:
|
|
883
|
+
price_payload = _get_price(token_id, currency)
|
|
884
|
+
except RuntimeError as exc:
|
|
885
|
+
return _json_error("price lookup failed", str(exc))
|
|
886
|
+
price_entry = price_payload.get(token_id, {})
|
|
887
|
+
price_usdt = price_entry.get(currency)
|
|
888
|
+
if price_usdt is None:
|
|
889
|
+
currency = "usd"
|
|
890
|
+
try:
|
|
891
|
+
price_payload = _get_price(token_id, currency)
|
|
892
|
+
except RuntimeError as exc:
|
|
893
|
+
return _json_error("price lookup failed", str(exc))
|
|
894
|
+
price_entry = price_payload.get(token_id, {})
|
|
895
|
+
price_usdt = price_entry.get(currency)
|
|
896
|
+
|
|
897
|
+
if price_usdt is None:
|
|
898
|
+
return _json_error("token not found", f"CoinGecko id: {token_id}")
|
|
899
|
+
|
|
900
|
+
candles = []
|
|
901
|
+
candle_minutes = _pick_candle_minutes(total_minutes)
|
|
902
|
+
if source == "hyperliquid":
|
|
903
|
+
interval_minutes = _pick_hyperliquid_interval_minutes(total_minutes)
|
|
904
|
+
candle_minutes = interval_minutes
|
|
905
|
+
try:
|
|
906
|
+
candles = _get_hyperliquid_candles(hl_symbol, total_minutes, interval_minutes)
|
|
907
|
+
except RuntimeError:
|
|
908
|
+
candles = []
|
|
909
|
+
|
|
910
|
+
if not candles:
|
|
911
|
+
try:
|
|
912
|
+
days = max(1, int(math.ceil(total_minutes / 1440.0)))
|
|
913
|
+
if days > 365:
|
|
914
|
+
days = 365
|
|
915
|
+
chart_payload = _get_market_chart(token_id, currency, days)
|
|
916
|
+
price_points = chart_payload.get("prices", [])
|
|
917
|
+
candles = _build_candles_from_prices(price_points, hours, candle_minutes)
|
|
918
|
+
except RuntimeError:
|
|
919
|
+
candles = []
|
|
920
|
+
|
|
921
|
+
if not candles:
|
|
922
|
+
candle_minutes = 30
|
|
923
|
+
try:
|
|
924
|
+
ohlc_payload = _get_ohlc(token_id, currency)
|
|
925
|
+
except RuntimeError:
|
|
926
|
+
ohlc_payload = []
|
|
927
|
+
for row in ohlc_payload:
|
|
928
|
+
if len(row) < 5:
|
|
929
|
+
continue
|
|
930
|
+
ts_ms, open_price, high_price, low_price, close_price = row
|
|
931
|
+
candles.append((ts_ms, open_price, high_price, low_price, close_price))
|
|
932
|
+
|
|
933
|
+
candles.sort(key=lambda item: item[0])
|
|
934
|
+
if candles:
|
|
935
|
+
target = max(2, int((hours * 60) / candle_minutes))
|
|
936
|
+
target = int(target * 0.8) # 20% fewer candles for breathing room
|
|
937
|
+
last_points = candles[-target:]
|
|
938
|
+
else:
|
|
939
|
+
last_points = []
|
|
940
|
+
|
|
941
|
+
change_period = None
|
|
942
|
+
change_period_percent = None
|
|
943
|
+
price_period_ago = None
|
|
944
|
+
|
|
945
|
+
if len(last_points) >= 2:
|
|
946
|
+
price_period_ago = last_points[0][4]
|
|
947
|
+
if price_period_ago:
|
|
948
|
+
change_period = price_usdt - price_period_ago
|
|
949
|
+
change_period_percent = (change_period / price_period_ago) * 100
|
|
950
|
+
chart_path = _build_chart(symbol_upper, last_points, currency, label, use_gradient)
|
|
951
|
+
|
|
952
|
+
if change_period_percent is None:
|
|
953
|
+
change_text = f"{label} n/a"
|
|
954
|
+
else:
|
|
955
|
+
if change_period_percent >= 0:
|
|
956
|
+
emoji = "⬆️"
|
|
957
|
+
sign = "+"
|
|
958
|
+
else:
|
|
959
|
+
emoji = "🔻"
|
|
960
|
+
sign = ""
|
|
961
|
+
change_text = f"{emoji} {sign}{change_period_percent:.2f}% over {label}"
|
|
962
|
+
|
|
963
|
+
text = f"{symbol_upper}: ${_format_price(price_usdt)} {currency.upper()} {change_text}"
|
|
964
|
+
text = text.replace("*", "")
|
|
965
|
+
result = {
|
|
966
|
+
"symbol": symbol_upper,
|
|
967
|
+
"token_id": token_id,
|
|
968
|
+
"source": source,
|
|
969
|
+
"currency": currency.upper(),
|
|
970
|
+
"hours": hours,
|
|
971
|
+
"duration_label": label,
|
|
972
|
+
"candle_minutes": candle_minutes,
|
|
973
|
+
"price": price_usdt,
|
|
974
|
+
"price_usdt": price_usdt,
|
|
975
|
+
"change_12h": change_period,
|
|
976
|
+
"change_12h_percent": change_period_percent,
|
|
977
|
+
"change_period": change_period,
|
|
978
|
+
"change_period_percent": change_period_percent,
|
|
979
|
+
"chart_path": chart_path,
|
|
980
|
+
"text": text,
|
|
981
|
+
"text_plain": text,
|
|
982
|
+
}
|
|
983
|
+
print(json.dumps(result, ensure_ascii=True))
|
|
984
|
+
return 0
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
if __name__ == "__main__":
|
|
988
|
+
sys.exit(main())
|