arkaos 2.0.0-alpha.1
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/CONSTITUTION.md +81 -0
- package/LICENSE +21 -0
- package/README.md +154 -0
- package/VERSION +1 -0
- package/arka/SKILL.md +134 -0
- package/bin/arkaos +107 -0
- package/config/constitution.yaml +168 -0
- package/config/hooks/post-tool-use-v2.sh +116 -0
- package/config/hooks/post-tool-use.sh +188 -0
- package/config/hooks/pre-compact-v2.sh +43 -0
- package/config/hooks/pre-compact.sh +99 -0
- package/config/hooks/user-prompt-submit-v2.sh +119 -0
- package/config/hooks/user-prompt-submit.sh +312 -0
- package/core/__init__.py +3 -0
- package/core/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/agents/__init__.py +14 -0
- package/core/agents/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/agents/__pycache__/loader.cpython-313.pyc +0 -0
- package/core/agents/__pycache__/registry_gen.cpython-313.pyc +0 -0
- package/core/agents/__pycache__/schema.cpython-313.pyc +0 -0
- package/core/agents/__pycache__/validator.cpython-313.pyc +0 -0
- package/core/agents/loader.py +88 -0
- package/core/agents/registry_gen.py +118 -0
- package/core/agents/schema.py +265 -0
- package/core/agents/validator.py +141 -0
- package/core/conclave/__init__.py +12 -0
- package/core/conclave/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/advisor_db.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/display.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/matcher.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/persistence.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/profiler.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/prompts.cpython-313.pyc +0 -0
- package/core/conclave/__pycache__/schema.cpython-313.pyc +0 -0
- package/core/conclave/advisor_db.py +373 -0
- package/core/conclave/display.py +104 -0
- package/core/conclave/matcher.py +104 -0
- package/core/conclave/persistence.py +61 -0
- package/core/conclave/profiler.py +298 -0
- package/core/conclave/prompts.py +77 -0
- package/core/conclave/schema.py +132 -0
- package/core/governance/__init__.py +5 -0
- package/core/governance/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/governance/__pycache__/constitution.cpython-313.pyc +0 -0
- package/core/governance/constitution.py +152 -0
- package/core/registry/__init__.py +1 -0
- package/core/registry/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/registry/__pycache__/generator.cpython-313.pyc +0 -0
- package/core/registry/generator.py +199 -0
- package/core/runtime/__init__.py +6 -0
- package/core/runtime/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/base.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/claude_code.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/codex_cli.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/cursor.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/gemini_cli.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/registry.cpython-313.pyc +0 -0
- package/core/runtime/__pycache__/subagent.cpython-313.pyc +0 -0
- package/core/runtime/base.py +143 -0
- package/core/runtime/claude_code.py +104 -0
- package/core/runtime/codex_cli.py +71 -0
- package/core/runtime/cursor.py +71 -0
- package/core/runtime/gemini_cli.py +68 -0
- package/core/runtime/registry.py +86 -0
- package/core/runtime/subagent.py +201 -0
- package/core/specs/__init__.py +10 -0
- package/core/specs/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/specs/__pycache__/manager.cpython-313.pyc +0 -0
- package/core/specs/__pycache__/schema.cpython-313.pyc +0 -0
- package/core/specs/manager.py +164 -0
- package/core/specs/schema.py +199 -0
- package/core/squads/__init__.py +7 -0
- package/core/squads/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/squads/__pycache__/loader.cpython-313.pyc +0 -0
- package/core/squads/__pycache__/registry.cpython-313.pyc +0 -0
- package/core/squads/__pycache__/schema.cpython-313.pyc +0 -0
- package/core/squads/loader.py +40 -0
- package/core/squads/registry.py +145 -0
- package/core/squads/schema.py +93 -0
- package/core/synapse/__init__.py +11 -0
- package/core/synapse/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/synapse/__pycache__/cache.cpython-313.pyc +0 -0
- package/core/synapse/__pycache__/engine.cpython-313.pyc +0 -0
- package/core/synapse/__pycache__/layers.cpython-313.pyc +0 -0
- package/core/synapse/cache.py +82 -0
- package/core/synapse/engine.py +184 -0
- package/core/synapse/layers.py +441 -0
- package/core/tasks/__init__.py +6 -0
- package/core/tasks/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/tasks/__pycache__/manager.cpython-313.pyc +0 -0
- package/core/tasks/__pycache__/schema.cpython-313.pyc +0 -0
- package/core/tasks/manager.py +150 -0
- package/core/tasks/schema.py +108 -0
- package/core/workflow/__init__.py +10 -0
- package/core/workflow/__pycache__/__init__.cpython-313.pyc +0 -0
- package/core/workflow/__pycache__/engine.cpython-313.pyc +0 -0
- package/core/workflow/__pycache__/loader.cpython-313.pyc +0 -0
- package/core/workflow/__pycache__/schema.cpython-313.pyc +0 -0
- package/core/workflow/engine.py +216 -0
- package/core/workflow/loader.py +28 -0
- package/core/workflow/schema.py +129 -0
- package/departments/brand/SKILL.md +85 -0
- package/departments/brand/agents/brand-director.yaml +77 -0
- package/departments/brand/agents/brand-strategist.md +182 -0
- package/departments/brand/agents/brand-strategist.yaml +58 -0
- package/departments/brand/agents/creative-director.md +149 -0
- package/departments/brand/agents/motion-designer.md +113 -0
- package/departments/brand/agents/ux-designer.yaml +60 -0
- package/departments/brand/agents/visual-designer.md +187 -0
- package/departments/brand/agents/visual-designer.yaml +58 -0
- package/departments/brand/references/brand-creation-guide.md +559 -0
- package/departments/brand/scripts/provider-call.sh +262 -0
- package/departments/brand/skills/archetype-finder/SKILL.md +18 -0
- package/departments/brand/skills/colors/SKILL.md +18 -0
- package/departments/brand/skills/design-system/SKILL.md +18 -0
- package/departments/brand/skills/identity-system/SKILL.md +18 -0
- package/departments/brand/skills/logo-brief/SKILL.md +18 -0
- package/departments/brand/skills/mockup-generate/SKILL.md +18 -0
- package/departments/brand/skills/naming-evaluate/SKILL.md +50 -0
- package/departments/brand/skills/positioning-statement/SKILL.md +18 -0
- package/departments/brand/skills/primal-audit/SKILL.md +43 -0
- package/departments/brand/skills/ux-audit/SKILL.md +18 -0
- package/departments/brand/skills/voice-guide/SKILL.md +18 -0
- package/departments/brand/skills/wireframe/SKILL.md +18 -0
- package/departments/brand/squad.yaml +39 -0
- package/departments/brand/workflows/identity.yaml +113 -0
- package/departments/brand/workflows/naming.yaml +58 -0
- package/departments/community/SKILL.md +62 -0
- package/departments/community/agents/community-manager.yaml +57 -0
- package/departments/community/agents/community-strategist.yaml +74 -0
- package/departments/community/agents/engagement-designer.yaml +56 -0
- package/departments/community/skills/ai-community/SKILL.md +18 -0
- package/departments/community/skills/betting-setup/SKILL.md +18 -0
- package/departments/community/skills/business-model/SKILL.md +53 -0
- package/departments/community/skills/content-calendar/SKILL.md +18 -0
- package/departments/community/skills/events-plan/SKILL.md +18 -0
- package/departments/community/skills/gamification-design/SKILL.md +18 -0
- package/departments/community/skills/growth-plan/SKILL.md +18 -0
- package/departments/community/skills/metrics-track/SKILL.md +18 -0
- package/departments/community/skills/moderation/SKILL.md +18 -0
- package/departments/community/skills/monetize-plan/SKILL.md +18 -0
- package/departments/community/skills/niche-setup/SKILL.md +18 -0
- package/departments/community/skills/onboarding-flow/SKILL.md +18 -0
- package/departments/community/skills/platform-select/SKILL.md +18 -0
- package/departments/community/skills/retention-system/SKILL.md +48 -0
- package/departments/community/squad.yaml +32 -0
- package/departments/community/workflows/setup.yaml +62 -0
- package/departments/content/SKILL.md +65 -0
- package/departments/content/agents/content-strategist.yaml +74 -0
- package/departments/content/agents/repurpose-distributor.yaml +57 -0
- package/departments/content/agents/scriptwriter.yaml +56 -0
- package/departments/content/agents/viral-engineer.yaml +56 -0
- package/departments/content/skills/ai-workflow/SKILL.md +18 -0
- package/departments/content/skills/analytics/SKILL.md +18 -0
- package/departments/content/skills/calendar/SKILL.md +18 -0
- package/departments/content/skills/content-system/SKILL.md +75 -0
- package/departments/content/skills/hook-write/SKILL.md +43 -0
- package/departments/content/skills/monetization-plan/SKILL.md +18 -0
- package/departments/content/skills/newsletter-write/SKILL.md +18 -0
- package/departments/content/skills/platform-optimize/SKILL.md +18 -0
- package/departments/content/skills/repurpose-plan/SKILL.md +18 -0
- package/departments/content/skills/script-structure/SKILL.md +18 -0
- package/departments/content/skills/short-form/SKILL.md +18 -0
- package/departments/content/skills/thumbnail-package/SKILL.md +18 -0
- package/departments/content/skills/viral-design/SKILL.md +45 -0
- package/departments/content/skills/youtube-strategy/SKILL.md +18 -0
- package/departments/content/squad.yaml +39 -0
- package/departments/content/workflows/viral.yaml +99 -0
- package/departments/dev/SKILL.md +135 -0
- package/departments/dev/agents/analyst.md +184 -0
- package/departments/dev/agents/architect.md +184 -0
- package/departments/dev/agents/architect.yaml +74 -0
- package/departments/dev/agents/backend-dev.yaml +70 -0
- package/departments/dev/agents/cto.md +140 -0
- package/departments/dev/agents/cto.yaml +77 -0
- package/departments/dev/agents/dba.yaml +72 -0
- package/departments/dev/agents/devops-eng.yaml +72 -0
- package/departments/dev/agents/devops.md +204 -0
- package/departments/dev/agents/frontend-dev.md +213 -0
- package/departments/dev/agents/frontend-dev.yaml +71 -0
- package/departments/dev/agents/qa-eng.yaml +72 -0
- package/departments/dev/agents/qa.md +231 -0
- package/departments/dev/agents/security-eng.yaml +72 -0
- package/departments/dev/agents/security.md +174 -0
- package/departments/dev/agents/senior-dev.md +177 -0
- package/departments/dev/agents/tech-lead.md +188 -0
- package/departments/dev/agents/tech-lead.yaml +72 -0
- package/departments/dev/skills/adversarial-review/SKILL.md +117 -0
- package/departments/dev/skills/agent-design/SKILL.md +127 -0
- package/departments/dev/skills/agent-workflow/SKILL.md +116 -0
- package/departments/dev/skills/ai-assisted-dev/SKILL.md +18 -0
- package/departments/dev/skills/ai-security/SKILL.md +112 -0
- package/departments/dev/skills/api-design/SKILL.md +59 -0
- package/departments/dev/skills/architecture-design/SKILL.md +89 -0
- package/departments/dev/skills/changelog/SKILL.md +110 -0
- package/departments/dev/skills/ci-cd-pipeline/SKILL.md +130 -0
- package/departments/dev/skills/clean-code-review/SKILL.md +65 -0
- package/departments/dev/skills/code-review/SKILL.md +18 -0
- package/departments/dev/skills/codebase-onboard/SKILL.md +109 -0
- package/departments/dev/skills/db-design/SKILL.md +18 -0
- package/departments/dev/skills/db-schema/SKILL.md +130 -0
- package/departments/dev/skills/ddd-model/SKILL.md +18 -0
- package/departments/dev/skills/dependency-audit/SKILL.md +118 -0
- package/departments/dev/skills/deploy/SKILL.md +18 -0
- package/departments/dev/skills/devops-pipeline/SKILL.md +18 -0
- package/departments/dev/skills/docs/SKILL.md +18 -0
- package/departments/dev/skills/env-secrets/SKILL.md +89 -0
- package/departments/dev/skills/incident/SKILL.md +125 -0
- package/departments/dev/skills/mcp/SKILL.md +106 -0
- package/departments/dev/skills/mcp-builder/SKILL.md +121 -0
- package/departments/dev/skills/observability/SKILL.md +119 -0
- package/departments/dev/skills/onboard/SKILL.md +389 -0
- package/departments/dev/skills/onboard/scripts/detect-stack.py +472 -0
- package/departments/dev/skills/performance-audit/SKILL.md +49 -0
- package/departments/dev/skills/performance-profiler/SKILL.md +128 -0
- package/departments/dev/skills/rag-architect/SKILL.md +125 -0
- package/departments/dev/skills/red-team/SKILL.md +112 -0
- package/departments/dev/skills/refactor-plan/SKILL.md +18 -0
- package/departments/dev/skills/release/SKILL.md +130 -0
- package/departments/dev/skills/research/SKILL.md +18 -0
- package/departments/dev/skills/runbook/SKILL.md +103 -0
- package/departments/dev/skills/scaffold/SKILL.md +249 -0
- package/departments/dev/skills/security-audit/SKILL.md +68 -0
- package/departments/dev/skills/skill-audit/SKILL.md +96 -0
- package/departments/dev/skills/spec/SKILL.md +218 -0
- package/departments/dev/skills/stack-check/SKILL.md +18 -0
- package/departments/dev/skills/tdd-cycle/SKILL.md +56 -0
- package/departments/dev/skills/tech-debt/SKILL.md +100 -0
- package/departments/dev/squad.yaml +62 -0
- package/departments/dev/workflows/debug.yaml +63 -0
- package/departments/dev/workflows/feature.yaml +129 -0
- package/departments/dev/workflows/refactor.yaml +64 -0
- package/departments/ecom/SKILL.md +39 -0
- package/departments/ecom/agents/commerce-engineer.yaml +58 -0
- package/departments/ecom/agents/cro-specialist.yaml +56 -0
- package/departments/ecom/agents/ecom-director.yaml +73 -0
- package/departments/ecom/agents/retention-manager.yaml +59 -0
- package/departments/ecom/skills/analytics/SKILL.md +18 -0
- package/departments/ecom/skills/cart-recovery/SKILL.md +18 -0
- package/departments/ecom/skills/cro-optimize/SKILL.md +58 -0
- package/departments/ecom/skills/customer-journey/SKILL.md +18 -0
- package/departments/ecom/skills/fulfillment-plan/SKILL.md +18 -0
- package/departments/ecom/skills/marketplace-manage/SKILL.md +18 -0
- package/departments/ecom/skills/pricing-strategy/SKILL.md +18 -0
- package/departments/ecom/skills/product-launch/SKILL.md +18 -0
- package/departments/ecom/skills/rfm-segment/SKILL.md +44 -0
- package/departments/ecom/skills/social-commerce/SKILL.md +18 -0
- package/departments/ecom/skills/store-audit/SKILL.md +18 -0
- package/departments/ecom/skills/subscription-model/SKILL.md +18 -0
- package/departments/ecom/squad.yaml +39 -0
- package/departments/ecom/workflows/product-page.yaml +62 -0
- package/departments/ecommerce/SKILL.md +363 -0
- package/departments/ecommerce/agents/ecommerce-manager.md +91 -0
- package/departments/finance/SKILL.md +37 -0
- package/departments/finance/agents/cfo.md +85 -0
- package/departments/finance/agents/cfo.yaml +77 -0
- package/departments/finance/agents/financial-analyst.yaml +57 -0
- package/departments/finance/agents/investment-strategist.yaml +58 -0
- package/departments/finance/skills/budget-plan/SKILL.md +18 -0
- package/departments/finance/skills/cashflow-forecast/SKILL.md +18 -0
- package/departments/finance/skills/ciso-advisor/SKILL.md +113 -0
- package/departments/finance/skills/financial-model/SKILL.md +70 -0
- package/departments/finance/skills/pitch-deck/SKILL.md +18 -0
- package/departments/finance/skills/scenario-analysis/SKILL.md +18 -0
- package/departments/finance/skills/unit-economics/SKILL.md +44 -0
- package/departments/finance/skills/valuation-model/SKILL.md +18 -0
- package/departments/finance/squad.yaml +37 -0
- package/departments/finance/workflows/cashflow.yaml +47 -0
- package/departments/finance/workflows/model.yaml +83 -0
- package/departments/kb/SKILL.md +38 -0
- package/departments/kb/agents/knowledge-curator.yaml +60 -0
- package/departments/kb/agents/knowledge-director.yaml +72 -0
- package/departments/kb/agents/research-analyst.yaml +58 -0
- package/departments/kb/skills/ai-research/SKILL.md +18 -0
- package/departments/kb/skills/competitive-intel/SKILL.md +18 -0
- package/departments/kb/skills/knowledge-review/SKILL.md +18 -0
- package/departments/kb/skills/learn-content/SKILL.md +18 -0
- package/departments/kb/skills/moc-create/SKILL.md +18 -0
- package/departments/kb/skills/persona-build/SKILL.md +18 -0
- package/departments/kb/skills/research-plan/SKILL.md +51 -0
- package/departments/kb/skills/search-kb/SKILL.md +18 -0
- package/departments/kb/skills/source-evaluate/SKILL.md +18 -0
- package/departments/kb/skills/taxonomy-manage/SKILL.md +18 -0
- package/departments/kb/skills/write-as-persona/SKILL.md +18 -0
- package/departments/kb/skills/zettelkasten-process/SKILL.md +56 -0
- package/departments/kb/squad.yaml +34 -0
- package/departments/kb/workflows/learn.yaml +63 -0
- package/departments/knowledge/SKILL.md +474 -0
- package/departments/knowledge/agents/knowledge-curator.md +89 -0
- package/departments/knowledge/scripts/kb-check-capabilities.sh +143 -0
- package/departments/knowledge/scripts/kb-cleanup.sh +135 -0
- package/departments/knowledge/scripts/kb-queue.sh +156 -0
- package/departments/knowledge/scripts/kb-status.sh +195 -0
- package/departments/knowledge/scripts/kb-worker.sh +217 -0
- package/departments/landing/SKILL.md +65 -0
- package/departments/landing/agents/affiliate-manager.yaml +57 -0
- package/departments/landing/agents/conversion-strategist.yaml +74 -0
- package/departments/landing/agents/cro-specialist.yaml +58 -0
- package/departments/landing/agents/sales-copywriter.yaml +61 -0
- package/departments/landing/skills/ab-test/SKILL.md +18 -0
- package/departments/landing/skills/affiliate-bridge/SKILL.md +18 -0
- package/departments/landing/skills/awareness-diagnose/SKILL.md +18 -0
- package/departments/landing/skills/copy-framework/SKILL.md +55 -0
- package/departments/landing/skills/email-sequence/SKILL.md +18 -0
- package/departments/landing/skills/funnel-design/SKILL.md +49 -0
- package/departments/landing/skills/funnel-metrics/SKILL.md +18 -0
- package/departments/landing/skills/headline-write/SKILL.md +18 -0
- package/departments/landing/skills/landing-gen/SKILL.md +124 -0
- package/departments/landing/skills/launch-sequence/SKILL.md +18 -0
- package/departments/landing/skills/offer-create/SKILL.md +62 -0
- package/departments/landing/skills/optimize-page/SKILL.md +18 -0
- package/departments/landing/skills/page-architect/SKILL.md +18 -0
- package/departments/landing/skills/persuasion-apply/SKILL.md +18 -0
- package/departments/landing/skills/webinar-funnel/SKILL.md +18 -0
- package/departments/landing/squad.yaml +39 -0
- package/departments/landing/workflows/launch.yaml +72 -0
- package/departments/landing/workflows/offer.yaml +99 -0
- package/departments/leadership/SKILL.md +35 -0
- package/departments/leadership/agents/culture-coach.yaml +59 -0
- package/departments/leadership/agents/hr-specialist.yaml +57 -0
- package/departments/leadership/agents/leadership-director.yaml +72 -0
- package/departments/leadership/skills/change-manage/SKILL.md +18 -0
- package/departments/leadership/skills/conflict-resolve/SKILL.md +18 -0
- package/departments/leadership/skills/culture-audit/SKILL.md +18 -0
- package/departments/leadership/skills/delegation-matrix/SKILL.md +18 -0
- package/departments/leadership/skills/disc-assess/SKILL.md +18 -0
- package/departments/leadership/skills/feedback-give/SKILL.md +18 -0
- package/departments/leadership/skills/hiring-plan/SKILL.md +18 -0
- package/departments/leadership/skills/okr-define/SKILL.md +69 -0
- package/departments/leadership/skills/performance-review/SKILL.md +18 -0
- package/departments/leadership/skills/team-health/SKILL.md +56 -0
- package/departments/leadership/squad.yaml +35 -0
- package/departments/leadership/workflows/team-build.yaml +55 -0
- package/departments/marketing/SKILL.md +61 -0
- package/departments/marketing/agents/content-creator.md +85 -0
- package/departments/marketing/agents/content-marketer.yaml +58 -0
- package/departments/marketing/agents/marketing-director.yaml +75 -0
- package/departments/marketing/agents/paid-specialist.yaml +58 -0
- package/departments/marketing/agents/seo-specialist.yaml +57 -0
- package/departments/marketing/skills/ab-test/SKILL.md +18 -0
- package/departments/marketing/skills/analytics-report/SKILL.md +18 -0
- package/departments/marketing/skills/audience-segment/SKILL.md +18 -0
- package/departments/marketing/skills/calendar-plan/SKILL.md +18 -0
- package/departments/marketing/skills/cold-email/SKILL.md +128 -0
- package/departments/marketing/skills/competitor-analysis/SKILL.md +18 -0
- package/departments/marketing/skills/content-audit/SKILL.md +18 -0
- package/departments/marketing/skills/email-sequence/SKILL.md +18 -0
- package/departments/marketing/skills/growth-loop/SKILL.md +50 -0
- package/departments/marketing/skills/marketing-automation/SKILL.md +18 -0
- package/departments/marketing/skills/paid-campaign/SKILL.md +18 -0
- package/departments/marketing/skills/programmatic-seo/SKILL.md +123 -0
- package/departments/marketing/skills/seo-audit/SKILL.md +48 -0
- package/departments/marketing/skills/social-strategy/SKILL.md +18 -0
- package/departments/marketing/squad.yaml +39 -0
- package/departments/marketing/workflows/campaign.yaml +112 -0
- package/departments/marketing/workflows/social.yaml +56 -0
- package/departments/operations/SKILL.md +422 -0
- package/departments/operations/agents/coo.md +88 -0
- package/departments/ops/SKILL.md +37 -0
- package/departments/ops/agents/automation-engineer.yaml +58 -0
- package/departments/ops/agents/ops-lead.yaml +71 -0
- package/departments/ops/skills/bottleneck-find/SKILL.md +49 -0
- package/departments/ops/skills/dashboard-build/SKILL.md +18 -0
- package/departments/ops/skills/gtd-setup/SKILL.md +18 -0
- package/departments/ops/skills/integration-design/SKILL.md +18 -0
- package/departments/ops/skills/lean-audit/SKILL.md +18 -0
- package/departments/ops/skills/metrics-dashboard/SKILL.md +18 -0
- package/departments/ops/skills/n8n-flow/SKILL.md +18 -0
- package/departments/ops/skills/sop-create/SKILL.md +18 -0
- package/departments/ops/skills/workflow-automate/SKILL.md +39 -0
- package/departments/ops/skills/zapier-flow/SKILL.md +18 -0
- package/departments/ops/squad.yaml +35 -0
- package/departments/ops/workflows/lean-audit.yaml +69 -0
- package/departments/org/SKILL.md +34 -0
- package/departments/org/agents/coo.yaml +80 -0
- package/departments/org/agents/org-designer.yaml +56 -0
- package/departments/org/agents/people-ops.yaml +56 -0
- package/departments/org/skills/compensation-plan/SKILL.md +18 -0
- package/departments/org/skills/culture-define/SKILL.md +18 -0
- package/departments/org/skills/decision-framework/SKILL.md +18 -0
- package/departments/org/skills/hiring-plan/SKILL.md +18 -0
- package/departments/org/skills/meeting-optimize/SKILL.md +18 -0
- package/departments/org/skills/onboarding-design/SKILL.md +18 -0
- package/departments/org/skills/org-design/SKILL.md +18 -0
- package/departments/org/skills/remote-setup/SKILL.md +18 -0
- package/departments/org/skills/sop-process/SKILL.md +18 -0
- package/departments/org/skills/team-assess/SKILL.md +18 -0
- package/departments/org/squad.yaml +33 -0
- package/departments/org/workflows/design.yaml +55 -0
- package/departments/pm/SKILL.md +39 -0
- package/departments/pm/agents/pm-director.yaml +75 -0
- package/departments/pm/agents/product-owner.yaml +59 -0
- package/departments/pm/agents/scrum-master.yaml +59 -0
- package/departments/pm/skills/agile-po/SKILL.md +118 -0
- package/departments/pm/skills/backlog-groom/SKILL.md +18 -0
- package/departments/pm/skills/discovery-plan/SKILL.md +48 -0
- package/departments/pm/skills/estimate-forecast/SKILL.md +18 -0
- package/departments/pm/skills/impact-map/SKILL.md +18 -0
- package/departments/pm/skills/kanban-setup/SKILL.md +18 -0
- package/departments/pm/skills/risk-register/SKILL.md +18 -0
- package/departments/pm/skills/roadmap-build/SKILL.md +18 -0
- package/departments/pm/skills/shape-pitch/SKILL.md +55 -0
- package/departments/pm/skills/sprint-plan/SKILL.md +18 -0
- package/departments/pm/skills/stakeholder-map/SKILL.md +18 -0
- package/departments/pm/skills/standup-run/SKILL.md +18 -0
- package/departments/pm/skills/story-write/SKILL.md +18 -0
- package/departments/pm/squad.yaml +37 -0
- package/departments/pm/workflows/retro.yaml +33 -0
- package/departments/quality/SKILL.md +66 -0
- package/departments/quality/agents/copy-director.md +134 -0
- package/departments/quality/agents/copy-director.yaml +73 -0
- package/departments/quality/agents/cqo.md +134 -0
- package/departments/quality/agents/cqo.yaml +76 -0
- package/departments/quality/agents/tech-director.yaml +79 -0
- package/departments/quality/agents/tech-ux-director.md +193 -0
- package/departments/quality/squad.yaml +25 -0
- package/departments/saas/SKILL.md +64 -0
- package/departments/saas/agents/cs-manager.yaml +57 -0
- package/departments/saas/agents/growth-engineer.yaml +57 -0
- package/departments/saas/agents/metrics-analyst.yaml +57 -0
- package/departments/saas/agents/saas-strategist.yaml +74 -0
- package/departments/saas/skills/benchmark-compare/SKILL.md +18 -0
- package/departments/saas/skills/churn-analysis/SKILL.md +18 -0
- package/departments/saas/skills/customer-success/SKILL.md +18 -0
- package/departments/saas/skills/growth-plan/SKILL.md +18 -0
- package/departments/saas/skills/gtm-strategy/SKILL.md +18 -0
- package/departments/saas/skills/launch-execute/SKILL.md +18 -0
- package/departments/saas/skills/metrics-dashboard/SKILL.md +18 -0
- package/departments/saas/skills/micro-saas-stack/SKILL.md +18 -0
- package/departments/saas/skills/mvp-build/SKILL.md +18 -0
- package/departments/saas/skills/niche-evaluate/SKILL.md +18 -0
- package/departments/saas/skills/onboarding-optimize/SKILL.md +18 -0
- package/departments/saas/skills/plg-setup/SKILL.md +53 -0
- package/departments/saas/skills/pricing-strategy/SKILL.md +48 -0
- package/departments/saas/skills/saas-scaffold/SKILL.md +127 -0
- package/departments/saas/skills/validate-idea/SKILL.md +55 -0
- package/departments/saas/squad.yaml +37 -0
- package/departments/saas/workflows/metrics.yaml +58 -0
- package/departments/saas/workflows/validate.yaml +103 -0
- package/departments/sales/SKILL.md +35 -0
- package/departments/sales/agents/sales-closer.yaml +58 -0
- package/departments/sales/agents/sales-director.yaml +72 -0
- package/departments/sales/agents/sales-ops.yaml +55 -0
- package/departments/sales/skills/challenger-sell/SKILL.md +18 -0
- package/departments/sales/skills/deal-qualify/SKILL.md +18 -0
- package/departments/sales/skills/discovery-call/SKILL.md +18 -0
- package/departments/sales/skills/forecast-revenue/SKILL.md +18 -0
- package/departments/sales/skills/negotiate-plan/SKILL.md +18 -0
- package/departments/sales/skills/objection-handle/SKILL.md +18 -0
- package/departments/sales/skills/pipeline-manage/SKILL.md +18 -0
- package/departments/sales/skills/pricing-negotiate/SKILL.md +18 -0
- package/departments/sales/skills/proposal-write/SKILL.md +54 -0
- package/departments/sales/skills/spin-sell/SKILL.md +50 -0
- package/departments/sales/squad.yaml +35 -0
- package/departments/sales/workflows/pipeline.yaml +49 -0
- package/departments/strategy/SKILL.md +37 -0
- package/departments/strategy/agents/business-model-designer.yaml +58 -0
- package/departments/strategy/agents/market-analyst.yaml +58 -0
- package/departments/strategy/agents/strategist.md +79 -0
- package/departments/strategy/agents/strategy-director.yaml +75 -0
- package/departments/strategy/skills/blue-ocean/SKILL.md +56 -0
- package/departments/strategy/skills/bmc/SKILL.md +18 -0
- package/departments/strategy/skills/board-advisor/SKILL.md +121 -0
- package/departments/strategy/skills/cto-advisor/SKILL.md +113 -0
- package/departments/strategy/skills/five-forces/SKILL.md +74 -0
- package/departments/strategy/skills/growth-strategy/SKILL.md +18 -0
- package/departments/strategy/skills/moat-analysis/SKILL.md +18 -0
- package/departments/strategy/skills/position/SKILL.md +18 -0
- package/departments/strategy/skills/scenario-plan/SKILL.md +18 -0
- package/departments/strategy/squad.yaml +37 -0
- package/departments/strategy/workflows/analysis.yaml +90 -0
- package/departments/strategy/workflows/swot.yaml +47 -0
- package/installer/adapters/claude-code.js +73 -0
- package/installer/adapters/codex-cli.js +34 -0
- package/installer/adapters/cursor.js +34 -0
- package/installer/adapters/gemini-cli.js +37 -0
- package/installer/cli.js +91 -0
- package/installer/detect-runtime.js +122 -0
- package/installer/doctor.js +105 -0
- package/installer/index.js +199 -0
- package/installer/uninstall.js +46 -0
- package/installer/update.js +39 -0
- package/knowledge/agents-registry-v2.json +2702 -0
- package/knowledge/commands-registry-v2.json +3827 -0
- package/package.json +58 -0
- package/pyproject.toml +64 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""Synapse v2 engine — orchestrates all 8 layers with caching and filtering.
|
|
2
|
+
|
|
3
|
+
Design goals:
|
|
4
|
+
- <100ms total latency for all layers
|
|
5
|
+
- 65% context reduction vs injecting everything
|
|
6
|
+
- Pluggable layers (add/remove/reorder)
|
|
7
|
+
- TTL-based caching per layer
|
|
8
|
+
- Relevance filtering (skip irrelevant layers)
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
|
|
14
|
+
from core.synapse.layers import Layer, LayerResult, PromptContext
|
|
15
|
+
from core.synapse.cache import LayerCache
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class SynapseResult:
|
|
20
|
+
"""Complete result of Synapse context injection."""
|
|
21
|
+
context_string: str # The combined context to inject
|
|
22
|
+
layers: list[LayerResult] # Individual layer results
|
|
23
|
+
total_ms: int # Total computation time
|
|
24
|
+
total_tokens_est: int # Estimated total tokens injected
|
|
25
|
+
cache_stats: dict # Cache hit/miss statistics
|
|
26
|
+
layers_skipped: int # Layers that returned empty results
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SynapseEngine:
|
|
30
|
+
"""8-layer context injection engine.
|
|
31
|
+
|
|
32
|
+
Computes all registered layers, caches results per TTL,
|
|
33
|
+
filters empty results, and combines into a compact context string.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self) -> None:
|
|
37
|
+
self._layers: list[Layer] = []
|
|
38
|
+
self._cache = LayerCache()
|
|
39
|
+
self._metrics: list[dict] = []
|
|
40
|
+
|
|
41
|
+
def register_layer(self, layer: Layer) -> None:
|
|
42
|
+
"""Register a context layer. Layers execute in priority order."""
|
|
43
|
+
self._layers.append(layer)
|
|
44
|
+
self._layers.sort(key=lambda l: l.priority)
|
|
45
|
+
|
|
46
|
+
def remove_layer(self, layer_id: str) -> None:
|
|
47
|
+
"""Remove a layer by ID."""
|
|
48
|
+
self._layers = [l for l in self._layers if l.id != layer_id]
|
|
49
|
+
|
|
50
|
+
def get_layer(self, layer_id: str) -> Layer | None:
|
|
51
|
+
"""Get a layer by ID."""
|
|
52
|
+
for layer in self._layers:
|
|
53
|
+
if layer.id == layer_id:
|
|
54
|
+
return layer
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
def inject(self, ctx: PromptContext) -> SynapseResult:
|
|
58
|
+
"""Compute all layers and return combined context.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
ctx: The prompt context (user input, environment).
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
SynapseResult with the combined context string.
|
|
65
|
+
"""
|
|
66
|
+
start = time.time()
|
|
67
|
+
results: list[LayerResult] = []
|
|
68
|
+
skipped = 0
|
|
69
|
+
|
|
70
|
+
for layer in self._layers:
|
|
71
|
+
result = self._compute_layer(layer, ctx)
|
|
72
|
+
if result.tag or result.content:
|
|
73
|
+
results.append(result)
|
|
74
|
+
else:
|
|
75
|
+
skipped += 1
|
|
76
|
+
|
|
77
|
+
# Combine all layer tags into a single context string
|
|
78
|
+
tags = [r.tag for r in results if r.tag]
|
|
79
|
+
context_string = " ".join(tags)
|
|
80
|
+
|
|
81
|
+
total_tokens = sum(r.tokens_est for r in results)
|
|
82
|
+
total_ms = int((time.time() - start) * 1000)
|
|
83
|
+
|
|
84
|
+
# Record metrics
|
|
85
|
+
self._metrics.append({
|
|
86
|
+
"timestamp": time.time(),
|
|
87
|
+
"total_ms": total_ms,
|
|
88
|
+
"layers_computed": len(results),
|
|
89
|
+
"layers_skipped": skipped,
|
|
90
|
+
"tokens_injected": total_tokens,
|
|
91
|
+
})
|
|
92
|
+
# Keep only last 500 metrics
|
|
93
|
+
if len(self._metrics) > 500:
|
|
94
|
+
self._metrics = self._metrics[-500:]
|
|
95
|
+
|
|
96
|
+
return SynapseResult(
|
|
97
|
+
context_string=context_string,
|
|
98
|
+
layers=results,
|
|
99
|
+
total_ms=total_ms,
|
|
100
|
+
total_tokens_est=total_tokens,
|
|
101
|
+
cache_stats=self._cache.stats,
|
|
102
|
+
layers_skipped=skipped,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def _compute_layer(self, layer: Layer, ctx: PromptContext) -> LayerResult:
|
|
106
|
+
"""Compute a single layer with caching."""
|
|
107
|
+
cache_key = f"{layer.id}:{ctx.cwd}:{ctx.active_agent}"
|
|
108
|
+
|
|
109
|
+
# Check cache
|
|
110
|
+
if layer.cache_ttl > 0:
|
|
111
|
+
cached = self._cache.get(cache_key)
|
|
112
|
+
if cached is not None:
|
|
113
|
+
return LayerResult(
|
|
114
|
+
layer_id=layer.id,
|
|
115
|
+
tag=cached,
|
|
116
|
+
content=cached,
|
|
117
|
+
tokens_est=len(cached.split()),
|
|
118
|
+
compute_ms=0,
|
|
119
|
+
cached=True,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Compute fresh
|
|
123
|
+
result = layer.compute(ctx)
|
|
124
|
+
|
|
125
|
+
# Cache if TTL > 0 and result is non-empty
|
|
126
|
+
if layer.cache_ttl > 0 and result.tag:
|
|
127
|
+
self._cache.set(cache_key, result.tag, layer.cache_ttl)
|
|
128
|
+
|
|
129
|
+
return result
|
|
130
|
+
|
|
131
|
+
def clear_cache(self) -> None:
|
|
132
|
+
"""Clear all cached layer results."""
|
|
133
|
+
self._cache.clear()
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def metrics(self) -> list[dict]:
|
|
137
|
+
"""Get computation metrics history."""
|
|
138
|
+
return self._metrics
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def layer_count(self) -> int:
|
|
142
|
+
"""Number of registered layers."""
|
|
143
|
+
return len(self._layers)
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def cache_stats(self) -> dict:
|
|
147
|
+
"""Cache hit/miss statistics."""
|
|
148
|
+
return self._cache.stats
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def create_default_engine(
|
|
152
|
+
constitution_compressed: str = "",
|
|
153
|
+
commands: list[dict] | None = None,
|
|
154
|
+
agents_registry: dict[str, dict] | None = None,
|
|
155
|
+
) -> SynapseEngine:
|
|
156
|
+
"""Create a SynapseEngine with all 8 default layers.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
constitution_compressed: Compressed Constitution string for L0.
|
|
160
|
+
commands: Command registry for L5 hints.
|
|
161
|
+
agents_registry: Agent registry for L2 context.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Configured SynapseEngine ready to use.
|
|
165
|
+
"""
|
|
166
|
+
from core.synapse.layers import (
|
|
167
|
+
ConstitutionLayer, DepartmentLayer, AgentLayer,
|
|
168
|
+
ProjectLayer, BranchLayer, CommandHintsLayer,
|
|
169
|
+
QualityGateLayer, TimeLayer,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
engine = SynapseEngine()
|
|
173
|
+
|
|
174
|
+
l0 = ConstitutionLayer(compressed=constitution_compressed)
|
|
175
|
+
engine.register_layer(l0)
|
|
176
|
+
engine.register_layer(DepartmentLayer())
|
|
177
|
+
engine.register_layer(AgentLayer(agents_registry=agents_registry))
|
|
178
|
+
engine.register_layer(ProjectLayer())
|
|
179
|
+
engine.register_layer(BranchLayer())
|
|
180
|
+
engine.register_layer(CommandHintsLayer(commands=commands))
|
|
181
|
+
engine.register_layer(QualityGateLayer())
|
|
182
|
+
engine.register_layer(TimeLayer())
|
|
183
|
+
|
|
184
|
+
return engine
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"""Synapse layer definitions — the 8 context layers.
|
|
2
|
+
|
|
3
|
+
Each layer extracts a specific type of context and compresses it
|
|
4
|
+
for injection into the prompt. Layers are pluggable and ordered.
|
|
5
|
+
|
|
6
|
+
Layer Architecture:
|
|
7
|
+
L0: Constitution — Compressed governance rules (TTL: 300s)
|
|
8
|
+
L1: Department — Detected department from input (no cache)
|
|
9
|
+
L2: Agent — Agent profile + last gotchas (TTL: 30s)
|
|
10
|
+
L3: Project — Active project context (TTL: 30s)
|
|
11
|
+
L4: Branch — Current git branch (no cache)
|
|
12
|
+
L5: Command Hints — Matching commands from registry (TTL: 30s)
|
|
13
|
+
L6: Quality Gate — QG status and last verdicts (TTL: 60s)
|
|
14
|
+
L7: Time — Time-of-day signal (no cache)
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import re
|
|
18
|
+
import time
|
|
19
|
+
from abc import ABC, abstractmethod
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from typing import Optional, Any
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class LayerResult:
|
|
26
|
+
"""Result from computing a single layer."""
|
|
27
|
+
layer_id: str
|
|
28
|
+
tag: str # e.g., "[dept:dev]"
|
|
29
|
+
content: str # Full content for this layer
|
|
30
|
+
tokens_est: int # Estimated token count
|
|
31
|
+
compute_ms: int # Time to compute in milliseconds
|
|
32
|
+
cached: bool # Whether this was served from cache
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class PromptContext:
|
|
37
|
+
"""Input context for layer computation."""
|
|
38
|
+
user_input: str = ""
|
|
39
|
+
cwd: str = ""
|
|
40
|
+
git_branch: str = ""
|
|
41
|
+
project_name: str = ""
|
|
42
|
+
project_stack: str = ""
|
|
43
|
+
active_agent: str = ""
|
|
44
|
+
runtime_id: str = "claude-code"
|
|
45
|
+
extra: dict[str, Any] = None
|
|
46
|
+
|
|
47
|
+
def __post_init__(self) -> None:
|
|
48
|
+
if self.extra is None:
|
|
49
|
+
self.extra = {}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Layer(ABC):
|
|
53
|
+
"""Abstract base class for a Synapse context layer."""
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
@abstractmethod
|
|
57
|
+
def id(self) -> str:
|
|
58
|
+
"""Unique layer identifier (e.g., 'L0', 'L1')."""
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
@abstractmethod
|
|
62
|
+
def name(self) -> str:
|
|
63
|
+
"""Human-readable name."""
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def cache_ttl(self) -> int:
|
|
67
|
+
"""Cache TTL in seconds. 0 = no caching."""
|
|
68
|
+
return 0
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def priority(self) -> int:
|
|
72
|
+
"""Layer priority (lower = computed first)."""
|
|
73
|
+
return 50
|
|
74
|
+
|
|
75
|
+
@abstractmethod
|
|
76
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
77
|
+
"""Compute this layer's context.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
ctx: The prompt context with user input and environment.
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
LayerResult with the computed context.
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# --- L0: Constitution ---
|
|
88
|
+
|
|
89
|
+
class ConstitutionLayer(Layer):
|
|
90
|
+
"""L0: Compressed Constitution rules. Highest priority, longest cache."""
|
|
91
|
+
|
|
92
|
+
def __init__(self, compressed: str = "") -> None:
|
|
93
|
+
self._compressed = compressed
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def id(self) -> str:
|
|
97
|
+
return "L0"
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def name(self) -> str:
|
|
101
|
+
return "Constitution"
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def cache_ttl(self) -> int:
|
|
105
|
+
return 300
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def priority(self) -> int:
|
|
109
|
+
return 0
|
|
110
|
+
|
|
111
|
+
def set_compressed(self, compressed: str) -> None:
|
|
112
|
+
self._compressed = compressed
|
|
113
|
+
|
|
114
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
115
|
+
start = time.time()
|
|
116
|
+
content = self._compressed
|
|
117
|
+
ms = int((time.time() - start) * 1000)
|
|
118
|
+
return LayerResult(
|
|
119
|
+
layer_id=self.id,
|
|
120
|
+
tag="[Constitution]",
|
|
121
|
+
content=content,
|
|
122
|
+
tokens_est=len(content.split()),
|
|
123
|
+
compute_ms=ms,
|
|
124
|
+
cached=False,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# --- L1: Department Detection ---
|
|
129
|
+
|
|
130
|
+
DEPARTMENT_PATTERNS: dict[str, str] = {
|
|
131
|
+
"dev": r"\b(build|code|feature|deploy|test|review|scaffold|debug|refactor|api|migration|stack|implement|fix|bug)\b",
|
|
132
|
+
"marketing": r"\b(social|content|campaign|post|instagram|linkedin|twitter|tiktok|seo|marketing|ads|email.?campaign|growth|viral)\b",
|
|
133
|
+
"finance": r"\b(budget|invoice|revenue|forecast|profit|loss|roi|margin|cash.?flow|financial|invest|valuation|pricing)\b",
|
|
134
|
+
"ecom": r"\b(store|product|shop|shopify|ecommerce|catalog|inventory|cart|checkout|pricing|marketplace)\b",
|
|
135
|
+
"strategy": r"\b(strategy|brainstorm|market|swot|competitor|roadmap|pivot|growth|porter|blue.?ocean|positioning)\b",
|
|
136
|
+
"ops": r"\b(task|automate|meeting|workflow|process|schedule|sop|integration|zapier|n8n)\b",
|
|
137
|
+
"kb": r"\b(learn|persona|knowledge|youtube|transcribe|article|research|zettelkasten|note)\b",
|
|
138
|
+
"brand": r"\b(brand|logo|colors|palette|mockup|photoshoot|brand.?identity|brand.?guide|mood.?board|naming|visual.?design|motion|ux|ui|wireframe)\b",
|
|
139
|
+
"saas": r"\b(saas|micro.?saas|plg|freemium|churn|mrr|arr|subscription|onboarding|metrics)\b",
|
|
140
|
+
"landing": r"\b(landing|funnel|copy|headline|offer|launch|affiliate|webinar|conversion|sales.?page)\b",
|
|
141
|
+
"community": r"\b(community|group|membership|discord|telegram|skool|circle|gamification|engagement)\b",
|
|
142
|
+
"content": r"\b(viral|hook|script|repurpose|youtube|tiktok|reels|shorts|newsletter|creator)\b",
|
|
143
|
+
"pm": r"\b(sprint|backlog|standup|retro|scrum|kanban|story|estimate|roadmap|agile)\b",
|
|
144
|
+
"lead": r"\b(leadership|delegation|1on1|feedback|culture|hiring|performance.?review|team.?build)\b",
|
|
145
|
+
"sales": r"\b(pipeline|proposal|discovery.?call|objection|negotiate|deal|close|prospect|spin|challenger)\b",
|
|
146
|
+
"org": r"\b(org.?design|hiring.?plan|onboarding|remote|meeting.?optimize|compensation|decision.?framework)\b",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class DepartmentLayer(Layer):
|
|
151
|
+
"""L1: Detect department from user input via keyword matching."""
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def id(self) -> str:
|
|
155
|
+
return "L1"
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def name(self) -> str:
|
|
159
|
+
return "Department"
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
def priority(self) -> int:
|
|
163
|
+
return 10
|
|
164
|
+
|
|
165
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
166
|
+
start = time.time()
|
|
167
|
+
text = ctx.user_input.lower()
|
|
168
|
+
|
|
169
|
+
# Check for explicit command prefix first
|
|
170
|
+
prefix_match = re.match(r"^/(\w+)\s", text)
|
|
171
|
+
if prefix_match:
|
|
172
|
+
prefix = prefix_match.group(1)
|
|
173
|
+
dept_map = {
|
|
174
|
+
"dev": "dev", "mkt": "marketing", "fin": "finance",
|
|
175
|
+
"strat": "strategy", "ops": "ops", "ecom": "ecom",
|
|
176
|
+
"kb": "kb", "brand": "brand", "saas": "saas",
|
|
177
|
+
"landing": "landing", "community": "community",
|
|
178
|
+
"content": "content", "pm": "pm", "lead": "lead",
|
|
179
|
+
"sales": "sales", "org": "org",
|
|
180
|
+
}
|
|
181
|
+
if prefix in dept_map:
|
|
182
|
+
dept = dept_map[prefix]
|
|
183
|
+
ms = int((time.time() - start) * 1000)
|
|
184
|
+
return LayerResult(
|
|
185
|
+
layer_id=self.id, tag=f"[dept:{dept}]",
|
|
186
|
+
content=dept, tokens_est=1, compute_ms=ms, cached=False,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
# Pattern matching on input text
|
|
190
|
+
scores: dict[str, int] = {}
|
|
191
|
+
for dept, pattern in DEPARTMENT_PATTERNS.items():
|
|
192
|
+
matches = re.findall(pattern, text, re.IGNORECASE)
|
|
193
|
+
if matches:
|
|
194
|
+
scores[dept] = len(matches)
|
|
195
|
+
|
|
196
|
+
dept = max(scores, key=scores.get) if scores else ""
|
|
197
|
+
tag = f"[dept:{dept}]" if dept else ""
|
|
198
|
+
|
|
199
|
+
ms = int((time.time() - start) * 1000)
|
|
200
|
+
return LayerResult(
|
|
201
|
+
layer_id=self.id, tag=tag, content=dept,
|
|
202
|
+
tokens_est=1, compute_ms=ms, cached=False,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
# --- L2: Agent Context ---
|
|
207
|
+
|
|
208
|
+
class AgentLayer(Layer):
|
|
209
|
+
"""L2: Active agent profile and recent gotchas."""
|
|
210
|
+
|
|
211
|
+
def __init__(self, agents_registry: dict[str, dict] | None = None) -> None:
|
|
212
|
+
self._registry = agents_registry or {}
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def id(self) -> str:
|
|
216
|
+
return "L2"
|
|
217
|
+
|
|
218
|
+
@property
|
|
219
|
+
def name(self) -> str:
|
|
220
|
+
return "Agent"
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def cache_ttl(self) -> int:
|
|
224
|
+
return 30
|
|
225
|
+
|
|
226
|
+
@property
|
|
227
|
+
def priority(self) -> int:
|
|
228
|
+
return 20
|
|
229
|
+
|
|
230
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
231
|
+
start = time.time()
|
|
232
|
+
agent_id = ctx.active_agent
|
|
233
|
+
if not agent_id:
|
|
234
|
+
ms = int((time.time() - start) * 1000)
|
|
235
|
+
return LayerResult(
|
|
236
|
+
layer_id=self.id, tag="", content="",
|
|
237
|
+
tokens_est=0, compute_ms=ms, cached=False,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
agent = self._registry.get(agent_id, {})
|
|
241
|
+
disc = agent.get("disc", "")
|
|
242
|
+
tag = f"[agent:{agent_id} disc:{disc}]"
|
|
243
|
+
|
|
244
|
+
ms = int((time.time() - start) * 1000)
|
|
245
|
+
return LayerResult(
|
|
246
|
+
layer_id=self.id, tag=tag, content=agent_id,
|
|
247
|
+
tokens_est=3, compute_ms=ms, cached=False,
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
# --- L3: Project Context ---
|
|
252
|
+
|
|
253
|
+
class ProjectLayer(Layer):
|
|
254
|
+
"""L3: Active project name and stack."""
|
|
255
|
+
|
|
256
|
+
@property
|
|
257
|
+
def id(self) -> str:
|
|
258
|
+
return "L3"
|
|
259
|
+
|
|
260
|
+
@property
|
|
261
|
+
def name(self) -> str:
|
|
262
|
+
return "Project"
|
|
263
|
+
|
|
264
|
+
@property
|
|
265
|
+
def cache_ttl(self) -> int:
|
|
266
|
+
return 30
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def priority(self) -> int:
|
|
270
|
+
return 30
|
|
271
|
+
|
|
272
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
273
|
+
start = time.time()
|
|
274
|
+
parts = []
|
|
275
|
+
if ctx.project_name:
|
|
276
|
+
parts.append(f"project:{ctx.project_name}")
|
|
277
|
+
if ctx.project_stack:
|
|
278
|
+
parts.append(f"stack:{ctx.project_stack}")
|
|
279
|
+
|
|
280
|
+
tag = f"[{' '.join(parts)}]" if parts else ""
|
|
281
|
+
ms = int((time.time() - start) * 1000)
|
|
282
|
+
return LayerResult(
|
|
283
|
+
layer_id=self.id, tag=tag, content=ctx.project_name or "",
|
|
284
|
+
tokens_est=len(parts), compute_ms=ms, cached=False,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
# --- L4: Git Branch ---
|
|
289
|
+
|
|
290
|
+
class BranchLayer(Layer):
|
|
291
|
+
"""L4: Current git branch (hidden for main/master/dev)."""
|
|
292
|
+
|
|
293
|
+
@property
|
|
294
|
+
def id(self) -> str:
|
|
295
|
+
return "L4"
|
|
296
|
+
|
|
297
|
+
@property
|
|
298
|
+
def name(self) -> str:
|
|
299
|
+
return "Branch"
|
|
300
|
+
|
|
301
|
+
@property
|
|
302
|
+
def priority(self) -> int:
|
|
303
|
+
return 40
|
|
304
|
+
|
|
305
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
306
|
+
start = time.time()
|
|
307
|
+
branch = ctx.git_branch
|
|
308
|
+
# Hide main/master/dev branches
|
|
309
|
+
if branch in ("main", "master", "dev", ""):
|
|
310
|
+
tag = ""
|
|
311
|
+
else:
|
|
312
|
+
tag = f"[branch:{branch}]"
|
|
313
|
+
|
|
314
|
+
ms = int((time.time() - start) * 1000)
|
|
315
|
+
return LayerResult(
|
|
316
|
+
layer_id=self.id, tag=tag, content=branch,
|
|
317
|
+
tokens_est=1 if tag else 0, compute_ms=ms, cached=False,
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
# --- L5: Command Hints ---
|
|
322
|
+
|
|
323
|
+
class CommandHintsLayer(Layer):
|
|
324
|
+
"""L5: Matching commands from the registry for non-explicit requests."""
|
|
325
|
+
|
|
326
|
+
def __init__(self, commands: list[dict] | None = None) -> None:
|
|
327
|
+
self._commands = commands or []
|
|
328
|
+
|
|
329
|
+
@property
|
|
330
|
+
def id(self) -> str:
|
|
331
|
+
return "L5"
|
|
332
|
+
|
|
333
|
+
@property
|
|
334
|
+
def name(self) -> str:
|
|
335
|
+
return "CommandHints"
|
|
336
|
+
|
|
337
|
+
@property
|
|
338
|
+
def cache_ttl(self) -> int:
|
|
339
|
+
return 30
|
|
340
|
+
|
|
341
|
+
@property
|
|
342
|
+
def priority(self) -> int:
|
|
343
|
+
return 50
|
|
344
|
+
|
|
345
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
346
|
+
start = time.time()
|
|
347
|
+
text = ctx.user_input.lower()
|
|
348
|
+
|
|
349
|
+
# Skip if already an explicit command
|
|
350
|
+
if text.startswith("/"):
|
|
351
|
+
ms = int((time.time() - start) * 1000)
|
|
352
|
+
return LayerResult(
|
|
353
|
+
layer_id=self.id, tag="", content="",
|
|
354
|
+
tokens_est=0, compute_ms=ms, cached=False,
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
# Score commands by keyword match
|
|
358
|
+
scored = []
|
|
359
|
+
for cmd in self._commands:
|
|
360
|
+
keywords = cmd.get("keywords", [])
|
|
361
|
+
score = sum(1 for kw in keywords if kw.lower() in text)
|
|
362
|
+
if score > 0:
|
|
363
|
+
scored.append((score, cmd.get("command", "")))
|
|
364
|
+
|
|
365
|
+
scored.sort(reverse=True)
|
|
366
|
+
hints = [cmd for _, cmd in scored[:2]]
|
|
367
|
+
|
|
368
|
+
tags = " ".join(f"[hint:{h}]" for h in hints)
|
|
369
|
+
ms = int((time.time() - start) * 1000)
|
|
370
|
+
return LayerResult(
|
|
371
|
+
layer_id=self.id, tag=tags, content=" ".join(hints),
|
|
372
|
+
tokens_est=len(hints) * 2, compute_ms=ms, cached=False,
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
# --- L6: Quality Gate Status ---
|
|
377
|
+
|
|
378
|
+
class QualityGateLayer(Layer):
|
|
379
|
+
"""L6: Current quality gate status and recent verdicts."""
|
|
380
|
+
|
|
381
|
+
@property
|
|
382
|
+
def id(self) -> str:
|
|
383
|
+
return "L6"
|
|
384
|
+
|
|
385
|
+
@property
|
|
386
|
+
def name(self) -> str:
|
|
387
|
+
return "QualityGate"
|
|
388
|
+
|
|
389
|
+
@property
|
|
390
|
+
def cache_ttl(self) -> int:
|
|
391
|
+
return 60
|
|
392
|
+
|
|
393
|
+
@property
|
|
394
|
+
def priority(self) -> int:
|
|
395
|
+
return 60
|
|
396
|
+
|
|
397
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
398
|
+
start = time.time()
|
|
399
|
+
# Quality Gate status is contextual — loaded from governance engine
|
|
400
|
+
tag = "[qg:active]"
|
|
401
|
+
ms = int((time.time() - start) * 1000)
|
|
402
|
+
return LayerResult(
|
|
403
|
+
layer_id=self.id, tag=tag, content="active",
|
|
404
|
+
tokens_est=1, compute_ms=ms, cached=False,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
# --- L7: Time Signal ---
|
|
409
|
+
|
|
410
|
+
class TimeLayer(Layer):
|
|
411
|
+
"""L7: Time-of-day signal for context-aware behavior."""
|
|
412
|
+
|
|
413
|
+
@property
|
|
414
|
+
def id(self) -> str:
|
|
415
|
+
return "L7"
|
|
416
|
+
|
|
417
|
+
@property
|
|
418
|
+
def name(self) -> str:
|
|
419
|
+
return "Time"
|
|
420
|
+
|
|
421
|
+
@property
|
|
422
|
+
def priority(self) -> int:
|
|
423
|
+
return 70
|
|
424
|
+
|
|
425
|
+
def compute(self, ctx: PromptContext) -> LayerResult:
|
|
426
|
+
start = time.time()
|
|
427
|
+
import datetime
|
|
428
|
+
hour = datetime.datetime.now().hour
|
|
429
|
+
if 5 <= hour < 12:
|
|
430
|
+
period = "morning"
|
|
431
|
+
elif 12 <= hour < 18:
|
|
432
|
+
period = "afternoon"
|
|
433
|
+
else:
|
|
434
|
+
period = "evening"
|
|
435
|
+
|
|
436
|
+
tag = f"[time:{period}]"
|
|
437
|
+
ms = int((time.time() - start) * 1000)
|
|
438
|
+
return LayerResult(
|
|
439
|
+
layer_id=self.id, tag=tag, content=period,
|
|
440
|
+
tokens_est=1, compute_ms=ms, cached=False,
|
|
441
|
+
)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|