oneie 2.0.2 → 2.0.5
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/AGENTS.md +245 -0
- package/CLAUDE.md +725 -0
- package/LICENSE.md +84 -0
- package/README.md +489 -931
- package/folders.yaml +78 -17
- package/one/.obsidian/app.json +1 -0
- package/one/.obsidian/appearance.json +1 -0
- package/one/.obsidian/core-plugins.json +33 -0
- package/one/.obsidian/workspace.json +211 -0
- package/one/connections/a2a.md +551 -0
- package/one/connections/acp.md +761 -0
- package/one/connections/acps.md +731 -0
- package/one/connections/agentkit.md +349 -0
- package/one/connections/agui.md +767 -0
- package/one/connections/any-backend.md +1702 -0
- package/one/connections/ap2.md +998 -0
- package/one/connections/api-docs.md +1891 -0
- package/one/connections/api.md +2190 -0
- package/one/connections/architecture-diagram.md +94 -0
- package/one/connections/communications.md +449 -0
- package/one/connections/connections.md +339 -0
- package/one/connections/copilotkit.md +1559 -0
- package/one/connections/cryptonetworks.md +781 -0
- package/one/connections/documentation.md +1120 -0
- package/one/connections/effect.md +279 -0
- package/one/connections/elizaos.md +1290 -0
- package/one/connections/inference.md +58 -0
- package/one/connections/kyc.md +632 -0
- package/one/connections/mcp.md +842 -0
- package/one/connections/membership.md +1152 -0
- package/one/connections/middleware.md +1067 -0
- package/one/connections/multitenant.md +1341 -0
- package/one/connections/n8n.md +1015 -0
- package/one/connections/patterns.md +89 -0
- package/one/connections/protocols.md +279 -0
- package/one/connections/relationships.md +107 -0
- package/one/connections/schema.md +587 -0
- package/one/connections/service-layer.md +550 -0
- package/one/connections/structure.md +0 -0
- package/one/connections/vectors.md +207 -0
- package/one/connections/wordpress.md +1302 -0
- package/one/connections/workflow-copy.md +905 -0
- package/one/connections/workflow-examples.md +741 -0
- package/one/connections/workflow.md +905 -0
- package/one/connections/workflows/delegation.md +885 -0
- package/one/connections/workflows/frontend.md +1037 -0
- package/one/connections/workflows/strategy.md +903 -0
- package/one/connections/workflows/tasks.md +698 -0
- package/one/connections/x402.md +1249 -0
- package/one/events/CASCADE-2-BACKEND-AGNOSTIC.md +412 -0
- package/one/events/FEATURE-2-4-COMPLETE.md +302 -0
- package/one/events/FEATURE_2_3_COMPLETE.md +575 -0
- package/one/events/GROUPS-MIGRATION.md +625 -0
- package/one/events/INSTALL-TESTS.md +293 -0
- package/one/events/INTEGRATION-ARCHITECTURE.md +561 -0
- package/one/events/INTEGRATION-CHECKLIST.md +1234 -0
- package/one/events/INTEGRATION-ORCHESTRATION.md +2623 -0
- package/one/events/INTEGRATION-SUMMARY.md +653 -0
- package/one/events/MIGRATION-REPORT.md +435 -0
- package/one/events/MIGRATION.md +69 -0
- package/one/events/README-archived.md +519 -0
- package/one/events/TEST-SUMMARY.md +393 -0
- package/one/events/TESTS-QUICK-REF.md +262 -0
- package/one/events/events.md +545 -0
- package/one/groups/groups.md +543 -0
- package/one/groups/one.md +599 -0
- package/one/groups/revenue.md +673 -0
- package/one/groups/strategy.md +869 -0
- package/one/groups/vision.md +98 -0
- package/one/knowledge/CLOUDFLARE_ENV_SETUP.md +49 -0
- package/one/knowledge/ai-platform.md +305 -0
- package/one/knowledge/architecture-any-backend.md +1366 -0
- package/one/knowledge/architecture-diagram.md +94 -0
- package/one/knowledge/architecture-frontend.md +930 -0
- package/one/knowledge/architecture.md +2077 -0
- package/one/knowledge/crypto.md +960 -0
- package/one/knowledge/docs/flow.md +0 -0
- package/one/knowledge/dsl.md +1660 -0
- package/one/knowledge/files.md +2471 -0
- package/one/knowledge/frontend.md +1038 -0
- package/one/knowledge/hono.md +2109 -0
- package/one/knowledge/implementation-examples.md +2536 -0
- package/one/knowledge/inference-score.md +159 -0
- package/one/knowledge/knowledge.md +642 -0
- package/one/knowledge/language.md +980 -0
- package/one/knowledge/lessons-learned.md +70 -0
- package/one/knowledge/ontology-6-dimensions.md +0 -0
- package/one/knowledge/ontology-documentation.md +356 -0
- package/one/knowledge/ontology-engineering-specification.md +1292 -0
- package/one/knowledge/ontology-engineering.md +1652 -0
- package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
- package/one/knowledge/ontology-frontend-copy.md +753 -0
- package/one/knowledge/ontology-frontend-specifications.md +2188 -0
- package/one/knowledge/ontology-frontend.md +2427 -0
- package/one/knowledge/ontology-minimal.yaml +299 -0
- package/one/knowledge/ontology.md +2830 -0
- package/one/knowledge/ontology.md.backup +2822 -0
- package/one/knowledge/ontology.yaml +1165 -0
- package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
- package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
- package/one/knowledge/patterns/backend/mutation-template.md +231 -0
- package/one/knowledge/patterns/backend/query-template.md +267 -0
- package/one/knowledge/patterns/backend/service-template.md +237 -0
- package/one/knowledge/patterns/design/component-architecture.md +399 -0
- package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
- package/one/knowledge/patterns/design/wireframe-template.md +216 -0
- package/one/knowledge/patterns/frontend/component-template.md +195 -0
- package/one/knowledge/patterns/frontend/form-template.md +276 -0
- package/one/knowledge/patterns/frontend/page-template.md +178 -0
- package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
- package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
- package/one/knowledge/patterns/test/technical-test-template.md +544 -0
- package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
- package/one/knowledge/patterns/test/user-flow-template.md +254 -0
- package/one/knowledge/provider-creation-guide.md +1064 -0
- package/one/knowledge/quality-loop.md +401 -0
- package/one/knowledge/readme.md +131 -0
- package/one/knowledge/rules.md +626 -0
- package/one/knowledge/score.md +67 -0
- package/one/knowledge/specifications.md +855 -0
- package/one/knowledge/tags.md +130 -0
- package/one/knowledge/todo.md +251 -0
- package/one/license.md +84 -0
- package/one/people/anthony-o-connell.md +440 -0
- package/one/people/people.md +567 -0
- package/one/things/CHECKLIST.md +356 -0
- package/one/things/ONE.md +510 -0
- package/one/things/agents/agent-backend.md +1401 -0
- package/one/things/agents/agent-builder.md +955 -0
- package/one/things/agents/agent-clean.md +709 -0
- package/one/things/agents/agent-clone.md +1341 -0
- package/one/things/agents/agent-designer.md +2177 -0
- package/one/things/agents/agent-director.md +1508 -0
- package/one/things/agents/agent-documenter.md +1049 -0
- package/one/things/agents/agent-frontend.md +1119 -0
- package/one/things/agents/agent-integrator.md +1192 -0
- package/one/things/agents/agent-problem-solver.md +1379 -0
- package/one/things/agents/agent-quality.md +1353 -0
- package/one/things/agents/agent-sales.md +986 -0
- package/one/things/cascade/cascade.yaml +464 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
- package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
- package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
- package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
- package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
- package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
- package/one/things/cascade/docs/examples/readme.md +222 -0
- package/one/things/cascade/docs/getting-started.md +515 -0
- package/one/things/cascade/docs/workflow.md +1372 -0
- package/one/things/cascade/readme.md +336 -0
- package/one/things/cascade/templates/feature-template.md +267 -0
- package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
- package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
- package/one/things/claude/agents/analyst.md +483 -0
- package/one/things/claude/agents/architect.md +480 -0
- package/one/things/claude/agents/brand-identity-specialist.md +513 -0
- package/one/things/claude/agents/bstp-token-strategist.md +667 -0
- package/one/things/claude/agents/builder-repo.md +489 -0
- package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
- package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
- package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
- package/one/things/claude/agents/company-bullstamp-character.md +587 -0
- package/one/things/claude/agents/company-bullstamp-community.md +292 -0
- package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
- package/one/things/claude/agents/company-bullstamp-token.md +292 -0
- package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
- package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
- package/one/things/claude/agents/content-calendar-planner.md +448 -0
- package/one/things/claude/agents/content-chapter-formatter.md +488 -0
- package/one/things/claude/agents/content-formatter.md +546 -0
- package/one/things/claude/agents/content-hook-specialist.md +462 -0
- package/one/things/claude/agents/content-image-formatter.md +535 -0
- package/one/things/claude/agents/content-introduction-formatter.md +485 -0
- package/one/things/claude/agents/content-multiplication-engine.md +556 -0
- package/one/things/claude/agents/content-playbook-writer.md +448 -0
- package/one/things/claude/agents/content-team-manager.md +622 -0
- package/one/things/claude/agents/content-toc-formatter.md +522 -0
- package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
- package/one/things/claude/agents/core-manager.md +582 -0
- package/one/things/claude/agents/core-master.md +403 -0
- package/one/things/claude/agents/cross-functional-manager.md +471 -0
- package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
- package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
- package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
- package/one/things/claude/agents/crypto-community-analyst.md +298 -0
- package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
- package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
- package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
- package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
- package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
- package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
- package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
- package/one/things/claude/agents/crypto-market-researcher.md +292 -0
- package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
- package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
- package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
- package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
- package/one/things/claude/agents/crypto-team-manager.md +387 -0
- package/one/things/claude/agents/crypto-token-analyst.md +278 -0
- package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
- package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
- package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
- package/one/things/claude/agents/customer-journey-designer.md +481 -0
- package/one/things/claude/agents/customer-success-manager.md +581 -0
- package/one/things/claude/agents/dev.md +413 -0
- package/one/things/claude/agents/documenter.md +546 -0
- package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
- package/one/things/claude/agents/engagement-specialist.md +509 -0
- package/one/things/claude/agents/engineering-architect.md +387 -0
- package/one/things/claude/agents/engineering-business-analyst.md +537 -0
- package/one/things/claude/agents/engineering-developer.md +387 -0
- package/one/things/claude/agents/engineering-director.md +282 -0
- package/one/things/claude/agents/engineering-ingestor.md +649 -0
- package/one/things/claude/agents/engineering-product-manager.md +537 -0
- package/one/things/claude/agents/engineering-product-owner.md +537 -0
- package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
- package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
- package/one/things/claude/agents/engineering-team-manager.md +512 -0
- package/one/things/claude/agents/engineering-user-experience.md +387 -0
- package/one/things/claude/agents/framework-elevate-manager.md +294 -0
- package/one/things/claude/agents/improver.md +763 -0
- package/one/things/claude/agents/intelligence-team-manager.md +385 -0
- package/one/things/claude/agents/lead-capture-expert.md +466 -0
- package/one/things/claude/agents/lead-magnet-creator.md +453 -0
- package/one/things/claude/agents/market-research-analyst.md +412 -0
- package/one/things/claude/agents/marketing-brand-identity.md +314 -0
- package/one/things/claude/agents/marketing-content-hooks.md +450 -0
- package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
- package/one/things/claude/agents/marketing-content-poster.md +361 -0
- package/one/things/claude/agents/marketing-customer-journey.md +326 -0
- package/one/things/claude/agents/marketing-director.md +397 -0
- package/one/things/claude/agents/marketing-engagement.md +326 -0
- package/one/things/claude/agents/marketing-lead-capture.md +326 -0
- package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
- package/one/things/claude/agents/marketing-network-effects.md +326 -0
- package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
- package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
- package/one/things/claude/agents/marketing-team-manager.md +446 -0
- package/one/things/claude/agents/marketing-viral-growth.md +201 -0
- package/one/things/claude/agents/mission-commander.md +373 -0
- package/one/things/claude/agents/network-effect-analyst.md +587 -0
- package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
- package/one/things/claude/agents/npx.md +890 -0
- package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
- package/one/things/claude/agents/one-master.md +355 -0
- package/one/things/claude/agents/one-orchestrator.md +315 -0
- package/one/things/claude/agents/one.md +601 -0
- package/one/things/claude/agents/playbook-generator.md +503 -0
- package/one/things/claude/agents/pm.md +326 -0
- package/one/things/claude/agents/po.md +345 -0
- package/one/things/claude/agents/qa.md +336 -0
- package/one/things/claude/agents/research-foundation-analyst.md +307 -0
- package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
- package/one/things/claude/agents/research-market-analyst.md +307 -0
- package/one/things/claude/agents/research-team-manager.md +482 -0
- package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
- package/one/things/claude/agents/sales-team-manager.md +400 -0
- package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
- package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
- package/one/things/claude/agents/service-advocacy-manager.md +307 -0
- package/one/things/claude/agents/service-success-manager.md +307 -0
- package/one/things/claude/agents/service-team-manager.md +400 -0
- package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
- package/one/things/claude/agents/share-optimization-specialist.md +551 -0
- package/one/things/claude/agents/sm.md +327 -0
- package/one/things/claude/agents/story-teller.md +473 -0
- package/one/things/claude/agents/task-master.md +596 -0
- package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
- package/one/things/claude/agents/tester.md +556 -0
- package/one/things/claude/agents/the-bull-character-manager.md +580 -0
- package/one/things/claude/agents/tools-playbook-generator.md +489 -0
- package/one/things/claude/agents/turbo-repo-builder.md +316 -0
- package/one/things/claude/agents/upsell-strategist.md +480 -0
- package/one/things/claude/agents/ux-expert.md +335 -0
- package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
- package/one/things/claude/claude-code-hooks-development.json +21 -0
- package/one/things/claude/claude-code-hooks-production.json +21 -0
- package/one/things/claude/claude-code-hooks.json +25 -0
- package/one/things/claude/commands/agent.md +104 -0
- package/one/things/claude/commands/cascade-status.md +128 -0
- package/one/things/claude/commands/ingest.md +290 -0
- package/one/things/claude/commands/ingestor.md +136 -0
- package/one/things/claude/commands/mission.md +83 -0
- package/one/things/claude/commands/npx.md +133 -0
- package/one/things/claude/commands/one.md +440 -0
- package/one/things/claude/commands/quality-check.md +204 -0
- package/one/things/claude/commands/smart-route.md +220 -0
- package/one/things/claude/commands/start.md +121 -0
- package/one/things/claude/commands/story.md +83 -0
- package/one/things/claude/commands/task.md +173 -0
- package/one/things/claude/hook-bypass.json +32 -0
- package/one/things/claude/hooks/agent-hook-config.json +427 -0
- package/one/things/claude/hooks/agent-hook-manager.js +525 -0
- package/one/things/claude/hooks/agent-load-balancer.js +271 -0
- package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
- package/one/things/claude/hooks/build-hook.sh +156 -0
- package/one/things/claude/hooks/cascade-feedback.js +297 -0
- package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
- package/one/things/claude/hooks/cleanup-hook.sh +201 -0
- package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
- package/one/things/claude/hooks/file-organization-engine.js +427 -0
- package/one/things/claude/hooks/file-organization-hook.sh +80 -0
- package/one/things/claude/hooks/file-organization-monitor.js +269 -0
- package/one/things/claude/hooks/format-hook.sh +43 -0
- package/one/things/claude/hooks/hook-bypass.sh +293 -0
- package/one/things/claude/hooks/hook-config-manager.js +202 -0
- package/one/things/claude/hooks/hook-debouncer.sh +62 -0
- package/one/things/claude/hooks/hook-logger.sh +89 -0
- package/one/things/claude/hooks/hook-orchestrator.js +662 -0
- package/one/things/claude/hooks/hook-performance-report.js +120 -0
- package/one/things/claude/hooks/lint-hook.sh +140 -0
- package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
- package/one/things/claude/hooks/memory-optimizer.js +510 -0
- package/one/things/claude/hooks/notification-hook.sh +204 -0
- package/one/things/claude/hooks/ontology-compliance.js +394 -0
- package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
- package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
- package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
- package/one/things/claude/hooks/performance-metrics.json +25 -0
- package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
- package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
- package/one/things/claude/hooks/security-hook.sh +256 -0
- package/one/things/claude/hooks/simple-load-balancer.js +238 -0
- package/one/things/claude/hooks/startup-optimizer.js +625 -0
- package/one/things/claude/hooks/story-scoring-system.js +445 -0
- package/one/things/claude/hooks/story-validation-engine.js +473 -0
- package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
- package/one/things/claude/hooks/story-validation-hook.sh +145 -0
- package/one/things/claude/hooks/structure-synchronizer.js +194 -0
- package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
- package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
- package/one/things/claude/hooks/test-hook.sh +145 -0
- package/one/things/claude/hooks/test-story-validation.sh +170 -0
- package/one/things/claude/hooks/trinity-validation-system.js +392 -0
- package/one/things/claude/settings-local.json +86 -0
- package/one/things/cli/cli-code.md +652 -0
- package/one/things/cli/cli-compiler-code.md +652 -0
- package/one/things/cli/cli.md +1068 -0
- package/one/things/components/card-shadcn.md +929 -0
- package/one/things/components/card.md +1050 -0
- package/one/things/components.md +1669 -0
- package/one/things/componets.md +4 -0
- package/one/things/creator-diagram.md +166 -0
- package/one/things/examples/children/lemonade-stand.md +366 -0
- package/one/things/examples/enterprise/crm-saas.md +1429 -0
- package/one/things/features/1-1-agent-prompts/design.md +470 -0
- package/one/things/features/1-1-agent-prompts/tests.md +264 -0
- package/one/things/features/1-1-agent-prompts.md +486 -0
- package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
- package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
- package/one/things/features/1-2-yaml-orchestrator.md +516 -0
- package/one/things/features/1-3-event-coordination/design.md +544 -0
- package/one/things/features/1-3-event-coordination/tests.md +223 -0
- package/one/things/features/1-3-event-coordination.md +508 -0
- package/one/things/features/1-4-knowledge-management/design.md +609 -0
- package/one/things/features/1-4-knowledge-management/tests.md +195 -0
- package/one/things/features/1-4-knowledge-management.md +577 -0
- package/one/things/features/1-5-quality-loops/design.md +797 -0
- package/one/things/features/1-5-quality-loops/tests.md +212 -0
- package/one/things/features/1-5-quality-loops.md +641 -0
- package/one/things/features/1-6-numbering-structure/design.md +610 -0
- package/one/things/features/1-6-numbering-structure/tests.md +213 -0
- package/one/things/features/1-6-numbering-structure.md +575 -0
- package/one/things/features/2-1-dataprovider-interface.md +2358 -0
- package/one/things/features/2-2-config-system.md +3075 -0
- package/one/things/features/2-3-effectts-services.md +1498 -0
- package/one/things/features/2-4-react-hooks.md +2120 -0
- package/one/things/features/2-5-auth-migration.md +2046 -0
- package/one/things/features/2-6-dashboard-migration.md +1985 -0
- package/one/things/features/2-7-alternative-providers.md +2505 -0
- package/one/things/features/2-7-implementation-report.md +680 -0
- package/one/things/features/2-cli.md +1235 -0
- package/one/things/features/2-design.md +1738 -0
- package/one/things/features/2-tests.md +520 -0
- package/one/things/features/AUTH_HOOKS_IMPLEMENTATION.md +521 -0
- package/one/things/features/DECOUPLING.md +272 -0
- package/one/things/features/DEPLOYMENT.md +452 -0
- package/one/things/features/IMPLEMENTATION_SUMMARY.md +316 -0
- package/one/things/features/dataprovider-interface/1-tests.md +1522 -0
- package/one/things/features/improve.md +843 -0
- package/one/things/features/remove-convex-deps.md +45 -0
- package/one/things/features/top-features.md +79 -0
- package/one/things/features/use-one-backend.md +1180 -0
- package/one/things/ideas/1-create-workflow.md +189 -0
- package/one/things/ideas/2-backend-agnostic-frontend.md +384 -0
- package/one/things/plans/1-create-workflow-status.md +555 -0
- package/one/things/plans/1-create-workflow.md +713 -0
- package/one/things/plans/2-backend-agnostic-frontend.md +543 -0
- package/one/things/plans/3-groups.md +502 -0
- package/one/things/plans/app.md +761 -0
- package/one/things/plans/backend-agnostic-frontend.md +323 -0
- package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
- package/one/things/plans/better-auth-any-backend.md +1852 -0
- package/one/things/plans/better-auth-available-features.md +235 -0
- package/one/things/plans/big-plan.md +38 -0
- package/one/things/plans/convex-better-auth.md +1109 -0
- package/one/things/plans/convex-on-off.md +389 -0
- package/one/things/plans/deploy-to-cloudflare.md +581 -0
- package/one/things/plans/desktop.md +1121 -0
- package/one/things/plans/effect-components.md +1669 -0
- package/one/things/plans/effect.md +973 -0
- package/one/things/plans/email.md +953 -0
- package/one/things/plans/enhance-auth.md +1669 -0
- package/one/things/plans/install-components.md +198 -0
- package/one/things/plans/landing.md +728 -0
- package/one/things/plans/layout.md +205 -0
- package/one/things/plans/mail-backend.md +1308 -0
- package/one/things/plans/mail.md +2624 -0
- package/one/things/plans/next-features.md +83 -0
- package/one/things/plans/one.md +658 -0
- package/one/things/plans/ontology-6-dimensions.md +2216 -0
- package/one/things/plans/ontology-driven-strategy.md +866 -0
- package/one/things/plans/ontology-ui-approach.md +357 -0
- package/one/things/plans/open-agent.md +785 -0
- package/one/things/plans/organizations-to-groups.md +705 -0
- package/one/things/plans/performace.md +90 -0
- package/one/things/plans/release.md +432 -0
- package/one/things/plans/releases.md +809 -0
- package/one/things/plans/repos.md +76 -0
- package/one/things/plans/separate-copy-2.md +1293 -0
- package/one/things/plans/separate-copy-3.md +2458 -0
- package/one/things/plans/separate-copy.md +1293 -0
- package/one/things/plans/separate.md +1983 -0
- package/one/things/plans/shadcn-integration-summary.md +450 -0
- package/one/things/plans/sidebar.md +172 -0
- package/one/things/plans/small-fixes.md +5 -0
- package/one/things/plans/test-backend-connection.md +476 -0
- package/one/things/plans/workflow-files.md +1196 -0
- package/one/things/plans/workflow.md +1372 -0
- package/one/things/products/cascade-landing-page.md +737 -0
- package/one/things/products/cascade.md +1518 -0
- package/one/things/products/context-engineering.md +1427 -0
- package/one/things/products/onthology.md +0 -0
- package/one/things/products/ontology-ui-shadcn.md +1280 -0
- package/one/things/products/ontology-ui.md +1387 -0
- package/one/things/products/ontology.md +717 -0
- package/one/things/products/sdk.md +557 -0
- package/one/things/promptkit.md +903 -0
- package/one/things/service-providers-new.md +982 -0
- package/one/things/service-providers.md +1092 -0
- package/one/things/system.md +600 -0
- package/one/things/tests/2-1-dataprovider-interface.md +1144 -0
- package/one/things/tests/2-1-test-analysis.md +496 -0
- package/one/things/things.md +349 -0
- package/one/things/todo.md +1248 -0
- package/one/things/vision/elegant-interface.md +214 -0
- package/package.json +5 -2
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Memory Optimizer Hook
|
|
5
|
+
*
|
|
6
|
+
* Reduces 500MB+ peak usage to <150MB through intelligent memory management
|
|
7
|
+
* Implements real-time memory monitoring and optimization strategies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'fs/promises';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import zlib from 'zlib';
|
|
13
|
+
|
|
14
|
+
class MemoryOptimizer {
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.options = {
|
|
17
|
+
maxMemoryMB: 150,
|
|
18
|
+
warningThresholdMB: 120,
|
|
19
|
+
gcIntervalMs: 30000,
|
|
20
|
+
cacheMaxItems: 1000,
|
|
21
|
+
cacheMaxSizeMB: 50,
|
|
22
|
+
enableStreaming: true,
|
|
23
|
+
compressionLevel: 6,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
this.memoryCache = new Map();
|
|
28
|
+
this.cacheStats = {
|
|
29
|
+
hits: 0,
|
|
30
|
+
misses: 0,
|
|
31
|
+
evictions: 0,
|
|
32
|
+
totalSize: 0
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.gcTimer = null;
|
|
36
|
+
this.memoryMonitorTimer = null;
|
|
37
|
+
this.isOptimizing = false;
|
|
38
|
+
|
|
39
|
+
this.init();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Initialize memory optimizer
|
|
44
|
+
*/
|
|
45
|
+
init() {
|
|
46
|
+
// Start periodic garbage collection
|
|
47
|
+
this.startGarbageCollection();
|
|
48
|
+
|
|
49
|
+
// Start memory monitoring
|
|
50
|
+
this.startMemoryMonitoring();
|
|
51
|
+
|
|
52
|
+
// Handle process events
|
|
53
|
+
process.on('exit', () => this.cleanup());
|
|
54
|
+
process.on('SIGINT', () => this.cleanup());
|
|
55
|
+
process.on('SIGTERM', () => this.cleanup());
|
|
56
|
+
|
|
57
|
+
console.log('🧠 Memory Optimizer initialized');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get current memory usage
|
|
62
|
+
*/
|
|
63
|
+
getMemoryUsage() {
|
|
64
|
+
const usage = process.memoryUsage();
|
|
65
|
+
return {
|
|
66
|
+
rss: Math.round(usage.rss / 1024 / 1024), // MB
|
|
67
|
+
heapUsed: Math.round(usage.heapUsed / 1024 / 1024), // MB
|
|
68
|
+
heapTotal: Math.round(usage.heapTotal / 1024 / 1024), // MB
|
|
69
|
+
external: Math.round(usage.external / 1024 / 1024), // MB
|
|
70
|
+
arrayBuffers: Math.round(usage.arrayBuffers / 1024 / 1024) // MB
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Check if memory optimization is needed
|
|
76
|
+
*/
|
|
77
|
+
needsOptimization() {
|
|
78
|
+
const usage = this.getMemoryUsage();
|
|
79
|
+
return usage.heapUsed > this.options.warningThresholdMB;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Start periodic memory monitoring
|
|
84
|
+
*/
|
|
85
|
+
startMemoryMonitoring() {
|
|
86
|
+
this.memoryMonitorTimer = setInterval(() => {
|
|
87
|
+
const usage = this.getMemoryUsage();
|
|
88
|
+
|
|
89
|
+
if (usage.heapUsed > this.options.maxMemoryMB) {
|
|
90
|
+
console.warn(`🚨 Memory limit exceeded: ${usage.heapUsed}MB > ${this.options.maxMemoryMB}MB`);
|
|
91
|
+
this.emergencyOptimization();
|
|
92
|
+
} else if (usage.heapUsed > this.options.warningThresholdMB) {
|
|
93
|
+
console.warn(`⚠️ Memory warning: ${usage.heapUsed}MB (threshold: ${this.options.warningThresholdMB}MB)`);
|
|
94
|
+
this.optimizeMemory();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Log memory stats periodically
|
|
98
|
+
if (Math.random() < 0.1) { // 10% chance
|
|
99
|
+
this.logMemoryStats();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}, 10000); // Check every 10 seconds
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Start periodic garbage collection
|
|
107
|
+
*/
|
|
108
|
+
startGarbageCollection() {
|
|
109
|
+
this.gcTimer = setInterval(() => {
|
|
110
|
+
if (global.gc && this.needsOptimization()) {
|
|
111
|
+
const before = this.getMemoryUsage();
|
|
112
|
+
global.gc();
|
|
113
|
+
const after = this.getMemoryUsage();
|
|
114
|
+
|
|
115
|
+
const freed = before.heapUsed - after.heapUsed;
|
|
116
|
+
if (freed > 10) {
|
|
117
|
+
console.log(`🗑️ Garbage collection freed ${freed}MB`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}, this.options.gcIntervalMs);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Emergency memory optimization when limits are exceeded
|
|
125
|
+
*/
|
|
126
|
+
async emergencyOptimization() {
|
|
127
|
+
if (this.isOptimizing) return;
|
|
128
|
+
|
|
129
|
+
this.isOptimizing = true;
|
|
130
|
+
console.log('🚨 Starting emergency memory optimization...');
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
// Clear all caches immediately
|
|
134
|
+
await this.clearAllCaches();
|
|
135
|
+
|
|
136
|
+
// Force garbage collection
|
|
137
|
+
if (global.gc) {
|
|
138
|
+
global.gc();
|
|
139
|
+
global.gc(); // Run twice for better cleanup
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Clear large variables if possible
|
|
143
|
+
this.clearLargeVariables();
|
|
144
|
+
|
|
145
|
+
console.log('✅ Emergency optimization completed');
|
|
146
|
+
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error('❌ Emergency optimization failed:', error);
|
|
149
|
+
} finally {
|
|
150
|
+
this.isOptimizing = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Regular memory optimization
|
|
156
|
+
*/
|
|
157
|
+
async optimizeMemory() {
|
|
158
|
+
if (this.isOptimizing) return;
|
|
159
|
+
|
|
160
|
+
this.isOptimizing = true;
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
// Clean expired cache entries
|
|
164
|
+
await this.cleanExpiredCache();
|
|
165
|
+
|
|
166
|
+
// Compress large objects in memory
|
|
167
|
+
await this.compressLargeObjects();
|
|
168
|
+
|
|
169
|
+
// Trigger garbage collection if available
|
|
170
|
+
if (global.gc && Math.random() < 0.3) {
|
|
171
|
+
global.gc();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.warn('⚠️ Memory optimization error:', error.message);
|
|
176
|
+
} finally {
|
|
177
|
+
this.isOptimizing = false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Intelligent caching with size limits
|
|
183
|
+
*/
|
|
184
|
+
async cacheContent(key, content, options = {}) {
|
|
185
|
+
const {
|
|
186
|
+
ttl = 300000, // 5 minutes default
|
|
187
|
+
compress = true,
|
|
188
|
+
priority = 'normal'
|
|
189
|
+
} = options;
|
|
190
|
+
|
|
191
|
+
// Check cache size limits
|
|
192
|
+
if (this.cacheStats.totalSize > this.options.cacheMaxSizeMB * 1024 * 1024) {
|
|
193
|
+
await this.evictLeastRecentlyUsed();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (this.memoryCache.size >= this.options.cacheMaxItems) {
|
|
197
|
+
await this.evictLeastRecentlyUsed();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const entry = {
|
|
201
|
+
content: compress ? this.compressString(content) : content,
|
|
202
|
+
timestamp: Date.now(),
|
|
203
|
+
ttl,
|
|
204
|
+
priority,
|
|
205
|
+
compressed: compress,
|
|
206
|
+
size: Buffer.byteLength(content, 'utf8'),
|
|
207
|
+
accessCount: 0,
|
|
208
|
+
lastAccessed: Date.now()
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
this.memoryCache.set(key, entry);
|
|
212
|
+
this.cacheStats.totalSize += entry.size;
|
|
213
|
+
|
|
214
|
+
return entry;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Retrieve from cache with optimization
|
|
219
|
+
*/
|
|
220
|
+
async getCachedContent(key) {
|
|
221
|
+
const entry = this.memoryCache.get(key);
|
|
222
|
+
|
|
223
|
+
if (!entry) {
|
|
224
|
+
this.cacheStats.misses++;
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Check TTL
|
|
229
|
+
if (Date.now() - entry.timestamp > entry.ttl) {
|
|
230
|
+
this.memoryCache.delete(key);
|
|
231
|
+
this.cacheStats.totalSize -= entry.size;
|
|
232
|
+
this.cacheStats.misses++;
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Update access stats
|
|
237
|
+
entry.accessCount++;
|
|
238
|
+
entry.lastAccessed = Date.now();
|
|
239
|
+
this.cacheStats.hits++;
|
|
240
|
+
|
|
241
|
+
// Decompress if needed
|
|
242
|
+
const content = entry.compressed ?
|
|
243
|
+
this.decompressString(entry.content) :
|
|
244
|
+
entry.content;
|
|
245
|
+
|
|
246
|
+
return content;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Evict least recently used cache entries
|
|
251
|
+
*/
|
|
252
|
+
async evictLeastRecentlyUsed() {
|
|
253
|
+
const entries = Array.from(this.memoryCache.entries())
|
|
254
|
+
.map(([key, value]) => ({ key, ...value }))
|
|
255
|
+
.sort((a, b) => {
|
|
256
|
+
// Sort by priority first, then by last accessed
|
|
257
|
+
if (a.priority !== b.priority) {
|
|
258
|
+
const priorities = { low: 0, normal: 1, high: 2 };
|
|
259
|
+
return priorities[a.priority] - priorities[b.priority];
|
|
260
|
+
}
|
|
261
|
+
return a.lastAccessed - b.lastAccessed;
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// Remove bottom 20% of entries
|
|
265
|
+
const toRemove = Math.max(1, Math.floor(entries.length * 0.2));
|
|
266
|
+
|
|
267
|
+
for (let i = 0; i < toRemove && entries.length > 0; i++) {
|
|
268
|
+
const entry = entries[i];
|
|
269
|
+
this.memoryCache.delete(entry.key);
|
|
270
|
+
this.cacheStats.totalSize -= entry.size;
|
|
271
|
+
this.cacheStats.evictions++;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
console.log(`🧹 Evicted ${toRemove} cache entries`);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Clear expired cache entries
|
|
279
|
+
*/
|
|
280
|
+
async cleanExpiredCache() {
|
|
281
|
+
const now = Date.now();
|
|
282
|
+
const expired = [];
|
|
283
|
+
|
|
284
|
+
for (const [key, entry] of this.memoryCache) {
|
|
285
|
+
if (now - entry.timestamp > entry.ttl) {
|
|
286
|
+
expired.push(key);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
for (const key of expired) {
|
|
291
|
+
const entry = this.memoryCache.get(key);
|
|
292
|
+
this.memoryCache.delete(key);
|
|
293
|
+
this.cacheStats.totalSize -= entry.size;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (expired.length > 0) {
|
|
297
|
+
console.log(`🧹 Cleaned ${expired.length} expired cache entries`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Clear all caches for emergency optimization
|
|
303
|
+
*/
|
|
304
|
+
async clearAllCaches() {
|
|
305
|
+
const size = this.memoryCache.size;
|
|
306
|
+
this.memoryCache.clear();
|
|
307
|
+
this.cacheStats.totalSize = 0;
|
|
308
|
+
this.cacheStats.evictions += size;
|
|
309
|
+
|
|
310
|
+
console.log(`🧹 Cleared all ${size} cache entries`);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Compress large objects in memory
|
|
315
|
+
*/
|
|
316
|
+
async compressLargeObjects() {
|
|
317
|
+
let compressed = 0;
|
|
318
|
+
|
|
319
|
+
for (const [key, entry] of this.memoryCache) {
|
|
320
|
+
if (!entry.compressed && entry.size > 10000) { // 10KB threshold
|
|
321
|
+
try {
|
|
322
|
+
const compressedContent = this.compressString(entry.content);
|
|
323
|
+
const originalSize = entry.size;
|
|
324
|
+
const newSize = Buffer.byteLength(compressedContent, 'utf8');
|
|
325
|
+
|
|
326
|
+
if (newSize < originalSize * 0.8) { // Only if 20%+ compression
|
|
327
|
+
entry.content = compressedContent;
|
|
328
|
+
entry.compressed = true;
|
|
329
|
+
entry.size = newSize;
|
|
330
|
+
|
|
331
|
+
this.cacheStats.totalSize -= (originalSize - newSize);
|
|
332
|
+
compressed++;
|
|
333
|
+
}
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.warn(`⚠️ Cannot compress cache entry ${key}:`, error.message);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (compressed > 0) {
|
|
341
|
+
console.log(`🗜️ Compressed ${compressed} large cache objects`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Clear large variables (placeholder for app-specific cleanup)
|
|
347
|
+
*/
|
|
348
|
+
clearLargeVariables() {
|
|
349
|
+
// Clear any global variables that might be holding large amounts of data
|
|
350
|
+
if (global.ONE_LARGE_DATA) {
|
|
351
|
+
global.ONE_LARGE_DATA = null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Clear any module-level caches
|
|
355
|
+
if (require.cache) {
|
|
356
|
+
const largeModules = Object.keys(require.cache).filter(key =>
|
|
357
|
+
key.includes('large-') || key.includes('cache-')
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
largeModules.forEach(key => {
|
|
361
|
+
delete require.cache[key];
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
if (largeModules.length > 0) {
|
|
365
|
+
console.log(`🧹 Cleared ${largeModules.length} large modules from require cache`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Simple string compression using gzip
|
|
372
|
+
*/
|
|
373
|
+
compressString(str) {
|
|
374
|
+
return zlib.gzipSync(str, { level: this.options.compressionLevel }).toString('base64');
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* String decompression
|
|
379
|
+
*/
|
|
380
|
+
decompressString(compressed) {
|
|
381
|
+
const buffer = Buffer.from(compressed, 'base64');
|
|
382
|
+
return zlib.gunzipSync(buffer).toString('utf8');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Log memory statistics
|
|
387
|
+
*/
|
|
388
|
+
logMemoryStats() {
|
|
389
|
+
const usage = this.getMemoryUsage();
|
|
390
|
+
const cacheEfficiency = this.cacheStats.hits / (this.cacheStats.hits + this.cacheStats.misses) * 100;
|
|
391
|
+
|
|
392
|
+
console.log(`📊 Memory Stats:`);
|
|
393
|
+
console.log(` Heap: ${usage.heapUsed}MB / ${usage.heapTotal}MB`);
|
|
394
|
+
console.log(` RSS: ${usage.rss}MB`);
|
|
395
|
+
console.log(` Cache: ${this.memoryCache.size} items, ${Math.round(this.cacheStats.totalSize / 1024 / 1024)}MB`);
|
|
396
|
+
console.log(` Cache Efficiency: ${cacheEfficiency.toFixed(1)}%`);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Stream large files instead of loading into memory
|
|
401
|
+
*/
|
|
402
|
+
async streamLargeFile(filePath, processor) {
|
|
403
|
+
const { createReadStream } = await import('fs');
|
|
404
|
+
const readline = await import('readline');
|
|
405
|
+
|
|
406
|
+
const stream = createReadStream(filePath, { encoding: 'utf8' });
|
|
407
|
+
const rl = readline.createInterface({
|
|
408
|
+
input: stream,
|
|
409
|
+
crlfDelay: Infinity
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
let lineCount = 0;
|
|
413
|
+
for await (const line of rl) {
|
|
414
|
+
await processor(line, lineCount++);
|
|
415
|
+
|
|
416
|
+
// Check memory periodically during streaming
|
|
417
|
+
if (lineCount % 1000 === 0 && this.needsOptimization()) {
|
|
418
|
+
await this.optimizeMemory();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return lineCount;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Memory-efficient file processing
|
|
427
|
+
*/
|
|
428
|
+
async processFileMemoryEfficient(filePath, chunkSize = 64 * 1024) {
|
|
429
|
+
const chunks = [];
|
|
430
|
+
const fsModule = await import('fs');
|
|
431
|
+
const stream = fsModule.createReadStream(filePath, {
|
|
432
|
+
encoding: 'utf8',
|
|
433
|
+
highWaterMark: chunkSize
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
return new Promise((resolve, reject) => {
|
|
437
|
+
stream.on('data', (chunk) => {
|
|
438
|
+
chunks.push(chunk);
|
|
439
|
+
|
|
440
|
+
// Check memory usage during processing
|
|
441
|
+
if (chunks.length % 10 === 0 && this.needsOptimization()) {
|
|
442
|
+
this.optimizeMemory();
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
stream.on('end', () => {
|
|
447
|
+
resolve(chunks.join(''));
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
stream.on('error', reject);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Hook integration for Claude Code
|
|
456
|
+
*/
|
|
457
|
+
async onFileChange(event, filePath) {
|
|
458
|
+
// Optimize memory when large files are processed
|
|
459
|
+
const stats = await fs.stat(filePath).catch(() => null);
|
|
460
|
+
|
|
461
|
+
if (stats && stats.size > 1024 * 1024) { // 1MB+
|
|
462
|
+
console.log(`🧠 Large file detected (${Math.round(stats.size / 1024 / 1024)}MB): ${filePath}`);
|
|
463
|
+
|
|
464
|
+
if (this.needsOptimization()) {
|
|
465
|
+
await this.optimizeMemory();
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Hook integration for before command execution
|
|
472
|
+
*/
|
|
473
|
+
async beforeCommand(command) {
|
|
474
|
+
const usage = this.getMemoryUsage();
|
|
475
|
+
|
|
476
|
+
if (usage.heapUsed > this.options.warningThresholdMB) {
|
|
477
|
+
console.log(`🧠 Pre-command memory optimization (${usage.heapUsed}MB)`);
|
|
478
|
+
await this.optimizeMemory();
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Cleanup method
|
|
484
|
+
*/
|
|
485
|
+
cleanup() {
|
|
486
|
+
if (this.gcTimer) {
|
|
487
|
+
clearInterval(this.gcTimer);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (this.memoryMonitorTimer) {
|
|
491
|
+
clearInterval(this.memoryMonitorTimer);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
console.log('🧠 Memory Optimizer cleaned up');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// Export for Claude Code hook integration
|
|
499
|
+
export default MemoryOptimizer;
|
|
500
|
+
|
|
501
|
+
// CLI execution
|
|
502
|
+
if (process.argv[1] === new URL(import.meta.url).pathname) {
|
|
503
|
+
const optimizer = new MemoryOptimizer();
|
|
504
|
+
|
|
505
|
+
console.log('🧠 Memory Optimizer running...');
|
|
506
|
+
console.log('Press Ctrl+C to exit');
|
|
507
|
+
|
|
508
|
+
// Keep process alive for monitoring
|
|
509
|
+
process.stdin.resume();
|
|
510
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Claude Code notification hook script
|
|
4
|
+
# Handles custom notifications for development feedback
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Source the logger
|
|
9
|
+
source .claude/hooks/hook-logger.sh
|
|
10
|
+
|
|
11
|
+
# Configuration
|
|
12
|
+
EVENT="${1:-}"
|
|
13
|
+
MESSAGE="${2:-}"
|
|
14
|
+
TYPE="${3:-info}" # info, success, warning, error
|
|
15
|
+
CHANNEL="${4:-console}" # console, system, file, webhook
|
|
16
|
+
|
|
17
|
+
# Log start
|
|
18
|
+
log_message "INFO" "Starting notification-hook for event: $EVENT, type: $TYPE, channel: $CHANNEL"
|
|
19
|
+
START_TIME=$(get_time_ms)
|
|
20
|
+
|
|
21
|
+
# Function to send console notification
|
|
22
|
+
send_console_notification() {
|
|
23
|
+
local msg="$1"
|
|
24
|
+
local type="$2"
|
|
25
|
+
|
|
26
|
+
case "$type" in
|
|
27
|
+
"success")
|
|
28
|
+
echo "✅ $msg"
|
|
29
|
+
;;
|
|
30
|
+
"warning")
|
|
31
|
+
echo "⚠️ $msg"
|
|
32
|
+
;;
|
|
33
|
+
"error")
|
|
34
|
+
echo "❌ $msg"
|
|
35
|
+
;;
|
|
36
|
+
"info"|*)
|
|
37
|
+
echo "ℹ️ $msg"
|
|
38
|
+
;;
|
|
39
|
+
esac
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Function to send system notification (macOS/Linux)
|
|
43
|
+
send_system_notification() {
|
|
44
|
+
local title="$1"
|
|
45
|
+
local msg="$2"
|
|
46
|
+
local type="$3"
|
|
47
|
+
|
|
48
|
+
if command -v osascript &> /dev/null; then
|
|
49
|
+
# macOS
|
|
50
|
+
osascript -e "display notification \"$msg\" with title \"Claude Code - $title\""
|
|
51
|
+
elif command -v notify-send &> /dev/null; then
|
|
52
|
+
# Linux
|
|
53
|
+
local icon=""
|
|
54
|
+
case "$type" in
|
|
55
|
+
"success") icon="dialog-information" ;;
|
|
56
|
+
"warning") icon="dialog-warning" ;;
|
|
57
|
+
"error") icon="dialog-error" ;;
|
|
58
|
+
*) icon="dialog-information" ;;
|
|
59
|
+
esac
|
|
60
|
+
notify-send --icon="$icon" "Claude Code - $title" "$msg"
|
|
61
|
+
else
|
|
62
|
+
# Fallback to console
|
|
63
|
+
send_console_notification "$title: $msg" "$type"
|
|
64
|
+
fi
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# Function to save notification to file
|
|
68
|
+
save_notification_to_file() {
|
|
69
|
+
local msg="$1"
|
|
70
|
+
local type="$2"
|
|
71
|
+
local event="$3"
|
|
72
|
+
|
|
73
|
+
local notification_file=".claude/notifications.log"
|
|
74
|
+
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
|
75
|
+
|
|
76
|
+
echo "[$timestamp] [$type] [$event] $msg" >> "$notification_file"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Function to send webhook notification
|
|
80
|
+
send_webhook_notification() {
|
|
81
|
+
local msg="$1"
|
|
82
|
+
local type="$2"
|
|
83
|
+
local event="$3"
|
|
84
|
+
local webhook_url="$4"
|
|
85
|
+
|
|
86
|
+
if [ -n "$webhook_url" ] && command -v curl &> /dev/null; then
|
|
87
|
+
local payload="{\"event\":\"$event\",\"type\":\"$type\",\"message\":\"$msg\",\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}"
|
|
88
|
+
|
|
89
|
+
curl -s -X POST \
|
|
90
|
+
-H "Content-Type: application/json" \
|
|
91
|
+
-d "$payload" \
|
|
92
|
+
"$webhook_url" >/dev/null 2>&1 || true
|
|
93
|
+
|
|
94
|
+
log_message "INFO" "Webhook notification sent to $webhook_url"
|
|
95
|
+
else
|
|
96
|
+
log_message "WARN" "Webhook notification failed - curl not available or no URL configured"
|
|
97
|
+
fi
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# Predefined notification templates
|
|
101
|
+
get_notification_template() {
|
|
102
|
+
local event="$1"
|
|
103
|
+
|
|
104
|
+
case "$event" in
|
|
105
|
+
"build-start")
|
|
106
|
+
echo "Build process started"
|
|
107
|
+
;;
|
|
108
|
+
"build-success")
|
|
109
|
+
echo "Build completed successfully"
|
|
110
|
+
;;
|
|
111
|
+
"build-failure")
|
|
112
|
+
echo "Build failed - check logs for details"
|
|
113
|
+
;;
|
|
114
|
+
"test-start")
|
|
115
|
+
echo "Running tests..."
|
|
116
|
+
;;
|
|
117
|
+
"test-success")
|
|
118
|
+
echo "All tests passed"
|
|
119
|
+
;;
|
|
120
|
+
"test-failure")
|
|
121
|
+
echo "Some tests failed"
|
|
122
|
+
;;
|
|
123
|
+
"lint-success")
|
|
124
|
+
echo "Code linting passed"
|
|
125
|
+
;;
|
|
126
|
+
"lint-failure")
|
|
127
|
+
echo "Linting issues found"
|
|
128
|
+
;;
|
|
129
|
+
"security-warning")
|
|
130
|
+
echo "Security warning - sensitive file modification detected"
|
|
131
|
+
;;
|
|
132
|
+
"security-block")
|
|
133
|
+
echo "Security block - sensitive file modification prevented"
|
|
134
|
+
;;
|
|
135
|
+
"session-start")
|
|
136
|
+
echo "Claude Code session started"
|
|
137
|
+
;;
|
|
138
|
+
"session-end")
|
|
139
|
+
echo "Claude Code session ended"
|
|
140
|
+
;;
|
|
141
|
+
*)
|
|
142
|
+
echo "$MESSAGE"
|
|
143
|
+
;;
|
|
144
|
+
esac
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
EXIT_CODE=0
|
|
148
|
+
|
|
149
|
+
# Determine notification message
|
|
150
|
+
NOTIFICATION_MESSAGE="${MESSAGE:-$(get_notification_template "$EVENT")}"
|
|
151
|
+
|
|
152
|
+
# Send notification based on channel
|
|
153
|
+
case "$CHANNEL" in
|
|
154
|
+
"console")
|
|
155
|
+
send_console_notification "$NOTIFICATION_MESSAGE" "$TYPE"
|
|
156
|
+
;;
|
|
157
|
+
|
|
158
|
+
"system")
|
|
159
|
+
send_system_notification "$EVENT" "$NOTIFICATION_MESSAGE" "$TYPE"
|
|
160
|
+
;;
|
|
161
|
+
|
|
162
|
+
"file")
|
|
163
|
+
save_notification_to_file "$NOTIFICATION_MESSAGE" "$TYPE" "$EVENT"
|
|
164
|
+
;;
|
|
165
|
+
|
|
166
|
+
"webhook")
|
|
167
|
+
# Check for webhook URL in environment or config
|
|
168
|
+
WEBHOOK_URL="${CLAUDE_HOOKS_WEBHOOK_URL:-}"
|
|
169
|
+
if [ -z "$WEBHOOK_URL" ]; then
|
|
170
|
+
# Try to get from config file
|
|
171
|
+
CONFIG_FILE=".claude/claude-code-hooks.json"
|
|
172
|
+
if [ -f "$CONFIG_FILE" ] && command -v jq &> /dev/null; then
|
|
173
|
+
WEBHOOK_URL=$(jq -r '.config.webhookUrl // empty' "$CONFIG_FILE" 2>/dev/null || echo "")
|
|
174
|
+
fi
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
send_webhook_notification "$NOTIFICATION_MESSAGE" "$TYPE" "$EVENT" "$WEBHOOK_URL"
|
|
178
|
+
;;
|
|
179
|
+
|
|
180
|
+
"all")
|
|
181
|
+
send_console_notification "$NOTIFICATION_MESSAGE" "$TYPE"
|
|
182
|
+
save_notification_to_file "$NOTIFICATION_MESSAGE" "$TYPE" "$EVENT"
|
|
183
|
+
send_system_notification "$EVENT" "$NOTIFICATION_MESSAGE" "$TYPE"
|
|
184
|
+
;;
|
|
185
|
+
|
|
186
|
+
*)
|
|
187
|
+
echo "❌ Unknown notification channel: $CHANNEL"
|
|
188
|
+
log_message "ERROR" "Unknown notification channel: $CHANNEL"
|
|
189
|
+
EXIT_CODE=1
|
|
190
|
+
;;
|
|
191
|
+
esac
|
|
192
|
+
|
|
193
|
+
# Always log the notification
|
|
194
|
+
if [ $EXIT_CODE -eq 0 ]; then
|
|
195
|
+
log_message "INFO" "Notification sent: $EVENT - $NOTIFICATION_MESSAGE"
|
|
196
|
+
else
|
|
197
|
+
log_message "ERROR" "Notification failed: $EVENT - $NOTIFICATION_MESSAGE"
|
|
198
|
+
fi
|
|
199
|
+
|
|
200
|
+
# Log completion
|
|
201
|
+
END_TIME=$(get_time_ms)
|
|
202
|
+
log_hook_execution "notification-hook" "$0 $*" "$START_TIME" "$END_TIME" "$EXIT_CODE"
|
|
203
|
+
|
|
204
|
+
exit $EXIT_CODE
|