@agentskillkit/agent-skills 1.0.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/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +292 -0
- package/.agent/GEMINI.md +374 -0
- package/.agent/agents/backend-specialist.md +263 -0
- package/.agent/agents/code-archaeologist.md +106 -0
- package/.agent/agents/database-architect.md +226 -0
- package/.agent/agents/debugger.md +225 -0
- package/.agent/agents/devops-engineer.md +242 -0
- package/.agent/agents/documentation-writer.md +104 -0
- package/.agent/agents/explorer-agent.md +73 -0
- package/.agent/agents/frontend-specialist.md +556 -0
- package/.agent/agents/game-developer.md +162 -0
- package/.agent/agents/mobile-developer.md +377 -0
- package/.agent/agents/orchestrator.md +416 -0
- package/.agent/agents/penetration-tester.md +188 -0
- package/.agent/agents/performance-optimizer.md +187 -0
- package/.agent/agents/product-manager.md +112 -0
- package/.agent/agents/product-owner.md +95 -0
- package/.agent/agents/project-planner.md +406 -0
- package/.agent/agents/qa-automation-engineer.md +103 -0
- package/.agent/agents/security-auditor.md +170 -0
- package/.agent/agents/seo-specialist.md +111 -0
- package/.agent/agents/test-engineer.md +158 -0
- package/.agent/knowledge/lessons-learned.yaml +17 -0
- package/.agent/rules/GEMINI.md +253 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/aesthetic/SKILL.md +121 -0
- package/.agent/skills/aesthetic/assets/design-guideline-template.md +163 -0
- package/.agent/skills/aesthetic/assets/design-story-template.md +135 -0
- package/.agent/skills/aesthetic/references/design-principles.md +62 -0
- package/.agent/skills/aesthetic/references/design-resources.md +75 -0
- package/.agent/skills/aesthetic/references/micro-interactions.md +53 -0
- package/.agent/skills/aesthetic/references/storytelling-design.md +50 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/rules/api-style.md +42 -0
- package/.agent/skills/api-patterns/rules/auth.md +24 -0
- package/.agent/skills/api-patterns/rules/documentation.md +26 -0
- package/.agent/skills/api-patterns/rules/graphql.md +41 -0
- package/.agent/skills/api-patterns/rules/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/rules/response.md +37 -0
- package/.agent/skills/api-patterns/rules/rest.md +40 -0
- package/.agent/skills/api-patterns/rules/security-testing.md +122 -0
- package/.agent/skills/api-patterns/rules/trpc.md +41 -0
- package/.agent/skills/api-patterns/rules/versioning.md +22 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/bash-linux/SKILL.md +199 -0
- package/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/.agent/skills/brainstorming/SKILL.md +163 -0
- package/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/.agent/skills/code-reviewer/.skill-source.json +8 -0
- package/.agent/skills/code-reviewer/SKILL.md +32 -0
- package/.agent/skills/code-reviewer/enforcement/checklists/backend-api-review-checklist.md +5 -0
- package/.agent/skills/code-reviewer/examples/approved-pr/review-output.md +76 -0
- package/.agent/skills/code-reviewer/examples/rejected-pr/review-output.md +99 -0
- package/.agent/skills/code-reviewer/examples/scenarios.md +3 -0
- package/.agent/skills/code-reviewer/metadata/doctrine-mapping.yaml +167 -0
- package/.agent/skills/code-reviewer/metadata/intent-triggers.yaml +41 -0
- package/.agent/skills/code-reviewer/resources/links.md +59 -0
- package/.agent/skills/code-reviewer/scripts/audit_pr.js +8 -0
- package/.agent/skills/code-reviewer/scripts/audit_pr.v2.js +417 -0
- package/.agent/skills/code-reviewer/scripts/validate_doctrine.js +307 -0
- package/.agent/skills/context-engineering/SKILL.md +86 -0
- package/.agent/skills/context-engineering/references/context-compression.md +84 -0
- package/.agent/skills/context-engineering/references/context-degradation.md +93 -0
- package/.agent/skills/context-engineering/references/context-fundamentals.md +75 -0
- package/.agent/skills/context-engineering/references/context-optimization.md +82 -0
- package/.agent/skills/context-engineering/references/evaluation.md +89 -0
- package/.agent/skills/context-engineering/references/memory-systems.md +88 -0
- package/.agent/skills/context-engineering/references/multi-agent-patterns.md +90 -0
- package/.agent/skills/context-engineering/references/project-development.md +97 -0
- package/.agent/skills/context-engineering/references/tool-design.md +86 -0
- package/.agent/skills/context-engineering/scripts/compression_evaluator.py +329 -0
- package/.agent/skills/context-engineering/scripts/context_analyzer.py +294 -0
- package/.agent/skills/database-design/SKILL.md +52 -0
- package/.agent/skills/database-design/database-selection.md +43 -0
- package/.agent/skills/database-design/indexing.md +39 -0
- package/.agent/skills/database-design/migrations.md +48 -0
- package/.agent/skills/database-design/optimization.md +36 -0
- package/.agent/skills/database-design/orm-selection.md +30 -0
- package/.agent/skills/database-design/schema-design.md +56 -0
- package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/.agent/skills/debugging/SKILL.md +42 -0
- package/.agent/skills/debugging/defense-in-depth/SKILL.md +130 -0
- package/.agent/skills/debugging/root-cause-tracing/SKILL.md +177 -0
- package/.agent/skills/debugging/root-cause-tracing/find-polluter.sh +63 -0
- package/.agent/skills/debugging/verification-before-completion/SKILL.md +142 -0
- package/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/document-skills/SKILL.md +49 -0
- package/.agent/skills/document-skills/docx/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/docx/SKILL.md +197 -0
- package/.agent/skills/document-skills/docx/docx-js.md +350 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/pack.py +159 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/unpack.py +29 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validate.py +69 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/.agent/skills/document-skills/docx/ooxml.md +610 -0
- package/.agent/skills/document-skills/docx/scripts/__init__.py +1 -0
- package/.agent/skills/document-skills/docx/scripts/document.py +1276 -0
- package/.agent/skills/document-skills/docx/scripts/templates/comments.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/people.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/utilities.py +374 -0
- package/.agent/skills/document-skills/pdf/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/pdf/SKILL.md +294 -0
- package/.agent/skills/document-skills/pdf/forms.md +205 -0
- package/.agent/skills/document-skills/pdf/reference.md +612 -0
- package/.agent/skills/document-skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/.agent/skills/document-skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/.agent/skills/document-skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/.agent/skills/document-skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/.agent/skills/document-skills/pdf/scripts/create_validation_image.py +41 -0
- package/.agent/skills/document-skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/.agent/skills/document-skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/.agent/skills/document-skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/.agent/skills/document-skills/pptx/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/pptx/SKILL.md +484 -0
- package/.agent/skills/document-skills/pptx/html2pptx.md +625 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/pack.py +159 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validate.py +69 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/.agent/skills/document-skills/pptx/ooxml.md +427 -0
- package/.agent/skills/document-skills/pptx/scripts/html2pptx.js +979 -0
- package/.agent/skills/document-skills/pptx/scripts/inventory.py +1020 -0
- package/.agent/skills/document-skills/pptx/scripts/rearrange.py +231 -0
- package/.agent/skills/document-skills/pptx/scripts/replace.py +385 -0
- package/.agent/skills/document-skills/pptx/scripts/thumbnail.py +450 -0
- package/.agent/skills/document-skills/xlsx/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/xlsx/SKILL.md +289 -0
- package/.agent/skills/document-skills/xlsx/recalc.py +178 -0
- package/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/.agent/skills/frontend/SKILL.md +38 -0
- package/.agent/skills/frontend/rules/_sections.md +46 -0
- package/.agent/skills/frontend/rules/_template.md +28 -0
- package/.agent/skills/frontend/rules/advanced-event-handler-refs.md +55 -0
- package/.agent/skills/frontend/rules/advanced-init-once.md +42 -0
- package/.agent/skills/frontend/rules/advanced-use-latest.md +39 -0
- package/.agent/skills/frontend/rules/async-api-routes.md +38 -0
- package/.agent/skills/frontend/rules/async-defer-await.md +80 -0
- package/.agent/skills/frontend/rules/async-dependencies.md +51 -0
- package/.agent/skills/frontend/rules/async-parallel.md +28 -0
- package/.agent/skills/frontend/rules/async-suspense-boundaries.md +99 -0
- package/.agent/skills/frontend/rules/bundle-barrel-imports.md +59 -0
- package/.agent/skills/frontend/rules/bundle-conditional.md +31 -0
- package/.agent/skills/frontend/rules/bundle-defer-third-party.md +49 -0
- package/.agent/skills/frontend/rules/bundle-dynamic-imports.md +35 -0
- package/.agent/skills/frontend/rules/bundle-preload.md +50 -0
- package/.agent/skills/frontend/rules/client-event-listeners.md +74 -0
- package/.agent/skills/frontend/rules/client-localstorage-schema.md +71 -0
- package/.agent/skills/frontend/rules/client-passive-event-listeners.md +48 -0
- package/.agent/skills/frontend/rules/client-swr-dedup.md +56 -0
- package/.agent/skills/frontend/rules/js-batch-dom-css.md +107 -0
- package/.agent/skills/frontend/rules/js-cache-function-results.md +80 -0
- package/.agent/skills/frontend/rules/js-cache-property-access.md +28 -0
- package/.agent/skills/frontend/rules/js-cache-storage.md +70 -0
- package/.agent/skills/frontend/rules/js-combine-iterations.md +32 -0
- package/.agent/skills/frontend/rules/js-early-exit.md +50 -0
- package/.agent/skills/frontend/rules/js-hoist-regexp.md +45 -0
- package/.agent/skills/frontend/rules/js-index-maps.md +37 -0
- package/.agent/skills/frontend/rules/js-length-check-first.md +49 -0
- package/.agent/skills/frontend/rules/js-min-max-loop.md +82 -0
- package/.agent/skills/frontend/rules/js-set-map-lookups.md +24 -0
- package/.agent/skills/frontend/rules/js-tosorted-immutable.md +57 -0
- package/.agent/skills/frontend/rules/rendering-activity.md +26 -0
- package/.agent/skills/frontend/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agent/skills/frontend/rules/rendering-conditional-render.md +40 -0
- package/.agent/skills/frontend/rules/rendering-content-visibility.md +38 -0
- package/.agent/skills/frontend/rules/rendering-hoist-jsx.md +46 -0
- package/.agent/skills/frontend/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agent/skills/frontend/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agent/skills/frontend/rules/rendering-svg-precision.md +28 -0
- package/.agent/skills/frontend/rules/rendering-usetransition-loading.md +75 -0
- package/.agent/skills/frontend/rules/rerender-defer-reads.md +39 -0
- package/.agent/skills/frontend/rules/rerender-dependencies.md +45 -0
- package/.agent/skills/frontend/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agent/skills/frontend/rules/rerender-derived-state.md +29 -0
- package/.agent/skills/frontend/rules/rerender-functional-setstate.md +74 -0
- package/.agent/skills/frontend/rules/rerender-lazy-state-init.md +58 -0
- package/.agent/skills/frontend/rules/rerender-memo-with-default-value.md +38 -0
- package/.agent/skills/frontend/rules/rerender-memo.md +44 -0
- package/.agent/skills/frontend/rules/rerender-move-effect-to-event.md +45 -0
- package/.agent/skills/frontend/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agent/skills/frontend/rules/rerender-transitions.md +40 -0
- package/.agent/skills/frontend/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agent/skills/frontend/rules/schema.json +34 -0
- package/.agent/skills/frontend/rules/server-after-nonblocking.md +73 -0
- package/.agent/skills/frontend/rules/server-auth-actions.md +96 -0
- package/.agent/skills/frontend/rules/server-cache-lru.md +41 -0
- package/.agent/skills/frontend/rules/server-cache-react.md +76 -0
- package/.agent/skills/frontend/rules/server-dedup-props.md +65 -0
- package/.agent/skills/frontend/rules/server-parallel-fetching.md +83 -0
- package/.agent/skills/frontend/rules/server-serialization.md +38 -0
- package/.agent/skills/frontend-design/SKILL.md +33 -0
- package/.agent/skills/frontend-design/rules/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/rules/color-system.md +311 -0
- package/.agent/skills/frontend-design/rules/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/rules/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/rules/typography-system.md +345 -0
- package/.agent/skills/frontend-design/rules/ux-psychology.md +541 -0
- package/.agent/skills/frontend-design/rules/visual-effects.md +383 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/.agent/skills/git-conventions/.skill-source.json +8 -0
- package/.agent/skills/git-conventions/SKILL.md +28 -0
- package/.agent/skills/git-conventions/enforcement/commit-validation-rules.md +55 -0
- package/.agent/skills/git-conventions/examples/bad-commits.md +201 -0
- package/.agent/skills/git-conventions/examples/good-commits.md +135 -0
- package/.agent/skills/git-conventions/metadata/commit-config.yaml +79 -0
- package/.agent/skills/git-conventions/metadata/intent-triggers.yaml +25 -0
- package/.agent/skills/git-conventions/metadata/scope-mapping.yaml +83 -0
- package/.agent/skills/git-conventions/resources/BEST_PRACTICES.md +121 -0
- package/.agent/skills/git-conventions/resources/references.md +53 -0
- package/.agent/skills/git-conventions/scripts/format-commit.js +393 -0
- package/.agent/skills/git-conventions/scripts/validate-commit-msg.sh +27 -0
- package/.agent/skills/governance/.skill-source.json +8 -0
- package/.agent/skills/governance/CHANGELOG.md +222 -0
- package/.agent/skills/governance/README.md +250 -0
- package/.agent/skills/governance/SKILL.md +199 -0
- package/.agent/skills/governance/VERSION +4 -0
- package/.agent/skills/governance/examples/violation-backend-mutation/after.tsx +59 -0
- package/.agent/skills/governance/examples/violation-backend-mutation/before.tsx +42 -0
- package/.agent/skills/governance/examples/violation-backend-mutation/explanation.md +87 -0
- package/.agent/skills/governance/examples/violation-chart-injection/after.tsx +99 -0
- package/.agent/skills/governance/examples/violation-chart-injection/before.tsx +57 -0
- package/.agent/skills/governance/examples/violation-chart-injection/explanation.md +116 -0
- package/.agent/skills/governance/knowledge/lessons-learned.yaml +3 -0
- package/.agent/skills/governance/metadata/precedence.yaml +117 -0
- package/.agent/skills/governance/metadata/scope-map.yaml +156 -0
- package/.agent/skills/governance/proposals/v1.1-change-proposal-template.md +197 -0
- package/.agent/skills/governance/resources/AUTHORITY_MODEL.md +111 -0
- package/.agent/skills/governance/resources/ENFORCEMENT_GUIDE.md +242 -0
- package/.agent/skills/governance/resources/LOAD_ORDER.md +82 -0
- package/.agent/skills/governance/rules/constitution/coinpika-master-constitution.md +206 -0
- package/.agent/skills/governance/rules/doctrines/architecture/coinpika-architecture-doctrine.md +184 -0
- package/.agent/skills/governance/rules/doctrines/backend/coinpika-backend-data-engine-doctrine.md +214 -0
- package/.agent/skills/governance/rules/doctrines/commercial/coinpika-commercial-guardrails-doctrine.md +192 -0
- package/.agent/skills/governance/rules/doctrines/data/coinpika-chart-data-doctrine.md +198 -0
- package/.agent/skills/governance/rules/doctrines/frontend/coinpika-frontend-mobile-doctrine.md +165 -0
- package/.agent/skills/governance/rules/doctrines/frontend/coinpika-swipe-tabs-doctrine.md +172 -0
- package/.agent/skills/governance/rules/doctrines/learning/coinpika-learning-engine-doctrine.md +188 -0
- package/.agent/skills/governance/rules/doctrines/performance/coinpika-performance-doctrine.md +176 -0
- package/.agent/skills/governance/rules/doctrines/review/coinpika-code-review-doctrine.md +170 -0
- package/.agent/skills/governance/rules/enforcement/agents/coinpika-agent-enforcement-protocol.md +214 -0
- package/.agent/skills/governance/rules/enforcement/agents/coinpika-agent-system-prompt.md +192 -0
- package/.agent/skills/governance/rules/enforcement/checklists/backend-api-review-checklist.md +127 -0
- package/.agent/skills/governance/rules/enforcement/checklists/chart-component-review-checklist.md +143 -0
- package/.agent/skills/governance/rules/enforcement/checklists/coinpika-frontend-gesture-review-checklist.md +190 -0
- package/.agent/skills/governance/rules/enforcement/playbooks/doctrine-violation-playbook.md +232 -0
- package/.agent/skills/governance/scripts/audit_pr.js +218 -0
- package/.agent/skills/governance/scripts/learn.js +161 -0
- package/.agent/skills/governance/scripts/validate_doctrine.js +286 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/.agent/skills/lint-and-validate/scripts/lint_runner.py +172 -0
- package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/mermaidjs-v11/SKILL.md +115 -0
- package/.agent/skills/mermaidjs-v11/references/cli-usage.md +228 -0
- package/.agent/skills/mermaidjs-v11/references/configuration.md +232 -0
- package/.agent/skills/mermaidjs-v11/references/diagram-types.md +315 -0
- package/.agent/skills/mermaidjs-v11/references/examples.md +344 -0
- package/.agent/skills/mermaidjs-v11/references/integration.md +310 -0
- package/.agent/skills/mobile-design/SKILL.md +76 -0
- package/.agent/skills/mobile-design/references/anti-patterns.md +46 -0
- package/.agent/skills/mobile-design/references/decision-trees.md +516 -0
- package/.agent/skills/mobile-design/references/mobile-backend.md +491 -0
- package/.agent/skills/mobile-design/references/mobile-color-system.md +420 -0
- package/.agent/skills/mobile-design/references/mobile-debugging.md +122 -0
- package/.agent/skills/mobile-design/references/mobile-design-thinking.md +357 -0
- package/.agent/skills/mobile-design/references/mobile-navigation.md +458 -0
- package/.agent/skills/mobile-design/references/mobile-performance.md +767 -0
- package/.agent/skills/mobile-design/references/mobile-testing.md +356 -0
- package/.agent/skills/mobile-design/references/mobile-typography.md +433 -0
- package/.agent/skills/mobile-design/references/platform-android.md +666 -0
- package/.agent/skills/mobile-design/references/platform-ios.md +561 -0
- package/.agent/skills/mobile-design/references/touch-psychology.md +537 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/.agent/skills/nextjs-best-practices/SKILL.md +203 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +76 -0
- package/.agent/skills/nodejs-best-practices/references/architecture-patterns.md +34 -0
- package/.agent/skills/nodejs-best-practices/references/async-patterns.md +32 -0
- package/.agent/skills/nodejs-best-practices/references/error-handling.md +39 -0
- package/.agent/skills/nodejs-best-practices/references/framework-selection.md +39 -0
- package/.agent/skills/nodejs-best-practices/references/runtime-modules.md +33 -0
- package/.agent/skills/nodejs-best-practices/references/testing-strategy.md +25 -0
- package/.agent/skills/nodejs-best-practices/references/validation-security.md +45 -0
- package/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/.agent/skills/plan-writing/SKILL.md +152 -0
- package/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/.agent/skills/problem-solving/ABOUT.md +40 -0
- package/.agent/skills/problem-solving/SKILL.md +69 -0
- package/.agent/skills/problem-solving/collision-zone-thinking/SKILL.md +62 -0
- package/.agent/skills/problem-solving/inversion-exercise/SKILL.md +58 -0
- package/.agent/skills/problem-solving/meta-pattern-recognition/SKILL.md +54 -0
- package/.agent/skills/problem-solving/scale-game/SKILL.md +63 -0
- package/.agent/skills/problem-solving/simplification-cascades/SKILL.md +76 -0
- package/.agent/skills/problem-solving/when-stuck/SKILL.md +88 -0
- package/.agent/skills/python-patterns/SKILL.md +80 -0
- package/.agent/skills/python-patterns/references/async-patterns.md +57 -0
- package/.agent/skills/python-patterns/references/django-patterns.md +41 -0
- package/.agent/skills/python-patterns/references/fastapi-patterns.md +54 -0
- package/.agent/skills/python-patterns/references/framework-selection.md +39 -0
- package/.agent/skills/python-patterns/references/project-structure.md +80 -0
- package/.agent/skills/python-patterns/references/testing-patterns.md +34 -0
- package/.agent/skills/python-patterns/references/type-hints.md +51 -0
- package/.agent/skills/react-patterns/SKILL.md +198 -0
- package/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/.agent/skills/registry.json +367 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/.agent/skills/sequential-thinking/README.md +118 -0
- package/.agent/skills/sequential-thinking/SKILL.md +93 -0
- package/.agent/skills/sequential-thinking/references/advanced.md +122 -0
- package/.agent/skills/sequential-thinking/references/examples.md +274 -0
- package/.agent/skills/server-management/SKILL.md +161 -0
- package/.agent/skills/skill-creator/LICENSE.txt +202 -0
- package/.agent/skills/skill-creator/SKILL.md +237 -0
- package/.agent/skills/skill-creator/scripts/init_skill.py +303 -0
- package/.agent/skills/skill-creator/scripts/package_skill.py +110 -0
- package/.agent/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/.agent/workflows/architect.md +200 -0
- package/.agent/workflows/autopilot.md +254 -0
- package/.agent/workflows/boost.md +163 -0
- package/.agent/workflows/build.md +192 -0
- package/.agent/workflows/chronicle.md +172 -0
- package/.agent/workflows/diagnose.md +207 -0
- package/.agent/workflows/forge.md +123 -0
- package/.agent/workflows/inspect.md +187 -0
- package/.agent/workflows/launch.md +208 -0
- package/.agent/workflows/pulse.md +115 -0
- package/.agent/workflows/stage.md +117 -0
- package/.agent/workflows/studio.md +319 -0
- package/.agent/workflows/think.md +173 -0
- package/.agent/workflows/validate.md +226 -0
- package/.editorconfig +21 -0
- package/.github/workflows/release.yml +39 -0
- package/CHANGELOG.md +38 -0
- package/LICENSE +16 -0
- package/README.md +294 -0
- package/VERSIONING.md +45 -0
- package/docs/PATTERNS_REFERENCE.md +93 -0
- package/docs/PLAN-consolidation-final.md +14 -0
- package/docs/PLAN-integration.md +28 -0
- package/docs/PLAN-rebrand-agent-skills-kit.md +104 -0
- package/docs/PLAN-refactor.md +48 -0
- package/docs/PYTHON_SCRIPTS.md +55 -0
- package/docs/awf-user-guide.md +436 -0
- package/docs/context-engineering-guide.md +99 -0
- package/package.json +38 -0
- package/packages/cli/.agent/knowledge/lessons-learned.yaml +32 -0
- package/packages/cli/bin/ag-smart.js +155 -0
- package/packages/cli/bin/ag-smart.v1.js +78 -0
- package/packages/cli/lib/audit.js +69 -0
- package/packages/cli/lib/audit.v2.js +151 -0
- package/packages/cli/lib/auto-learn.js +319 -0
- package/packages/cli/lib/auto_preview.py +148 -0
- package/packages/cli/lib/checklist.py +222 -0
- package/packages/cli/lib/config.js +29 -0
- package/packages/cli/lib/eslint-fix.js +238 -0
- package/packages/cli/lib/fix.js +278 -0
- package/packages/cli/lib/generate-registry.js +42 -0
- package/packages/cli/lib/hooks/install-hooks.js +176 -0
- package/packages/cli/lib/hooks/lint-learn.js +172 -0
- package/packages/cli/lib/learn.js +173 -0
- package/packages/cli/lib/learn.test.js +70 -0
- package/packages/cli/lib/learn.v2.js +255 -0
- package/packages/cli/lib/recall.js +75 -0
- package/packages/cli/lib/recall.v2.js +252 -0
- package/packages/cli/lib/session_manager.py +120 -0
- package/packages/cli/lib/skill-learn.js +296 -0
- package/packages/cli/lib/stats.js +143 -0
- package/packages/cli/lib/types.js +33 -0
- package/packages/cli/lib/verify_all.py +327 -0
- package/packages/cli/lib/watcher.js +181 -0
- package/packages/cli/package-lock.json +1837 -0
- package/packages/cli/package.json +23 -0
- package/packages/cli/vitest.config.js +9 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Compression Evaluator - Evaluate compression quality with probe-based testing.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python compression_evaluator.py evaluate <original_file> <compressed_file>
|
|
7
|
+
python compression_evaluator.py generate-probes <context_file>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import re
|
|
13
|
+
from dataclasses import dataclass, field
|
|
14
|
+
from enum import Enum
|
|
15
|
+
from typing import Optional
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ProbeType(Enum):
|
|
19
|
+
RECALL = "recall" # Factual retention
|
|
20
|
+
ARTIFACT = "artifact" # File tracking
|
|
21
|
+
CONTINUATION = "continuation" # Task planning
|
|
22
|
+
DECISION = "decision" # Reasoning chains
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class Probe:
|
|
27
|
+
type: ProbeType
|
|
28
|
+
question: str
|
|
29
|
+
ground_truth: str
|
|
30
|
+
context_reference: Optional[str] = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class ProbeResult:
|
|
35
|
+
probe: Probe
|
|
36
|
+
response: str
|
|
37
|
+
scores: dict
|
|
38
|
+
overall_score: float
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class EvaluationReport:
|
|
43
|
+
compression_ratio: float
|
|
44
|
+
quality_score: float
|
|
45
|
+
dimension_scores: dict
|
|
46
|
+
probe_results: list
|
|
47
|
+
recommendations: list = field(default_factory=list)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# Six evaluation dimensions with weights
|
|
51
|
+
DIMENSIONS = {
|
|
52
|
+
"accuracy": {"weight": 0.20, "description": "Technical correctness"},
|
|
53
|
+
"context_awareness": {"weight": 0.15, "description": "Conversation state"},
|
|
54
|
+
"artifact_trail": {"weight": 0.20, "description": "File tracking"},
|
|
55
|
+
"completeness": {"weight": 0.20, "description": "Coverage and depth"},
|
|
56
|
+
"continuity": {"weight": 0.15, "description": "Work continuation"},
|
|
57
|
+
"instruction_following": {"weight": 0.10, "description": "Constraint adherence"}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def estimate_tokens(text: str) -> int:
|
|
62
|
+
"""Estimate token count."""
|
|
63
|
+
return len(text) // 4
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def extract_facts(messages: list) -> list:
|
|
67
|
+
"""Extract factual statements that can be probed."""
|
|
68
|
+
facts = []
|
|
69
|
+
patterns = [
|
|
70
|
+
(r"error[:\s]+([^.]+)", "error"),
|
|
71
|
+
(r"next step[s]?[:\s]+([^.]+)", "next_step"),
|
|
72
|
+
(r"decided to\s+([^.]+)", "decision"),
|
|
73
|
+
(r"implemented\s+([^.]+)", "implementation"),
|
|
74
|
+
(r"found that\s+([^.]+)", "finding")
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
for msg in messages:
|
|
78
|
+
content = str(msg.get("content", "") if isinstance(msg, dict) else msg)
|
|
79
|
+
for pattern, fact_type in patterns:
|
|
80
|
+
matches = re.findall(pattern, content, re.IGNORECASE)
|
|
81
|
+
for match in matches:
|
|
82
|
+
facts.append({"type": fact_type, "content": match.strip()})
|
|
83
|
+
return facts
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def extract_files(messages: list) -> list:
|
|
87
|
+
"""Extract file references."""
|
|
88
|
+
files = []
|
|
89
|
+
patterns = [
|
|
90
|
+
r"(?:created|modified|updated|edited|read)\s+[`'\"]?([a-zA-Z0-9_/.-]+\.[a-zA-Z]+)[`'\"]?",
|
|
91
|
+
r"file[:\s]+[`'\"]?([a-zA-Z0-9_/.-]+\.[a-zA-Z]+)[`'\"]?"
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
for msg in messages:
|
|
95
|
+
content = str(msg.get("content", "") if isinstance(msg, dict) else msg)
|
|
96
|
+
for pattern in patterns:
|
|
97
|
+
matches = re.findall(pattern, content)
|
|
98
|
+
files.extend(matches)
|
|
99
|
+
return list(set(files))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def extract_decisions(messages: list) -> list:
|
|
103
|
+
"""Extract decision points."""
|
|
104
|
+
decisions = []
|
|
105
|
+
patterns = [
|
|
106
|
+
r"chose\s+([^.]+)\s+(?:because|since|over)",
|
|
107
|
+
r"decided\s+(?:to\s+)?([^.]+)",
|
|
108
|
+
r"went with\s+([^.]+)"
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
for msg in messages:
|
|
112
|
+
content = str(msg.get("content", "") if isinstance(msg, dict) else msg)
|
|
113
|
+
for pattern in patterns:
|
|
114
|
+
matches = re.findall(pattern, content, re.IGNORECASE)
|
|
115
|
+
decisions.extend(matches)
|
|
116
|
+
return decisions
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def generate_probes(messages: list) -> list:
|
|
120
|
+
"""Generate probe set for evaluation."""
|
|
121
|
+
probes = []
|
|
122
|
+
|
|
123
|
+
# Recall probes from facts
|
|
124
|
+
facts = extract_facts(messages)
|
|
125
|
+
for fact in facts[:3]: # Limit to 3 recall probes
|
|
126
|
+
probes.append(Probe(
|
|
127
|
+
type=ProbeType.RECALL,
|
|
128
|
+
question=f"What was the {fact['type'].replace('_', ' ')}?",
|
|
129
|
+
ground_truth=fact["content"]
|
|
130
|
+
))
|
|
131
|
+
|
|
132
|
+
# Artifact probes from files
|
|
133
|
+
files = extract_files(messages)
|
|
134
|
+
if files:
|
|
135
|
+
probes.append(Probe(
|
|
136
|
+
type=ProbeType.ARTIFACT,
|
|
137
|
+
question="Which files have been modified or created?",
|
|
138
|
+
ground_truth=", ".join(files)
|
|
139
|
+
))
|
|
140
|
+
|
|
141
|
+
# Continuation probe
|
|
142
|
+
probes.append(Probe(
|
|
143
|
+
type=ProbeType.CONTINUATION,
|
|
144
|
+
question="What should be done next?",
|
|
145
|
+
ground_truth="[Extracted from context]" # Would need LLM to generate
|
|
146
|
+
))
|
|
147
|
+
|
|
148
|
+
# Decision probes
|
|
149
|
+
decisions = extract_decisions(messages)
|
|
150
|
+
for decision in decisions[:2]: # Limit to 2 decision probes
|
|
151
|
+
probes.append(Probe(
|
|
152
|
+
type=ProbeType.DECISION,
|
|
153
|
+
question=f"Why was the decision made to {decision[:50]}...?",
|
|
154
|
+
ground_truth=decision
|
|
155
|
+
))
|
|
156
|
+
|
|
157
|
+
return probes
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def evaluate_response(probe: Probe, response: str) -> dict:
|
|
161
|
+
"""
|
|
162
|
+
Evaluate response against probe.
|
|
163
|
+
Note: Production should use LLM-as-Judge.
|
|
164
|
+
"""
|
|
165
|
+
scores = {}
|
|
166
|
+
response_lower = response.lower()
|
|
167
|
+
ground_truth_lower = probe.ground_truth.lower()
|
|
168
|
+
|
|
169
|
+
# Heuristic scoring (replace with LLM evaluation in production)
|
|
170
|
+
# Check for ground truth presence
|
|
171
|
+
if ground_truth_lower in response_lower:
|
|
172
|
+
base_score = 1.0
|
|
173
|
+
elif any(word in response_lower for word in ground_truth_lower.split()[:3]):
|
|
174
|
+
base_score = 0.6
|
|
175
|
+
else:
|
|
176
|
+
base_score = 0.3
|
|
177
|
+
|
|
178
|
+
# Adjust based on probe type
|
|
179
|
+
if probe.type == ProbeType.ARTIFACT:
|
|
180
|
+
# Check file mentions
|
|
181
|
+
files_mentioned = len(re.findall(r'\.[a-z]+', response_lower))
|
|
182
|
+
scores["artifact_trail"] = min(1.0, base_score + files_mentioned * 0.1)
|
|
183
|
+
scores["accuracy"] = base_score
|
|
184
|
+
elif probe.type == ProbeType.RECALL:
|
|
185
|
+
scores["accuracy"] = base_score
|
|
186
|
+
scores["completeness"] = base_score
|
|
187
|
+
elif probe.type == ProbeType.CONTINUATION:
|
|
188
|
+
scores["continuity"] = base_score
|
|
189
|
+
scores["context_awareness"] = base_score
|
|
190
|
+
elif probe.type == ProbeType.DECISION:
|
|
191
|
+
scores["accuracy"] = base_score
|
|
192
|
+
scores["context_awareness"] = base_score
|
|
193
|
+
|
|
194
|
+
return scores
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def calculate_compression_ratio(original: str, compressed: str) -> float:
|
|
198
|
+
"""Calculate compression ratio."""
|
|
199
|
+
original_tokens = estimate_tokens(original)
|
|
200
|
+
compressed_tokens = estimate_tokens(compressed)
|
|
201
|
+
if original_tokens == 0:
|
|
202
|
+
return 0.0
|
|
203
|
+
return 1.0 - (compressed_tokens / original_tokens)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def evaluate_compression(original_messages: list, compressed_text: str,
|
|
207
|
+
probes: Optional[list] = None) -> EvaluationReport:
|
|
208
|
+
"""
|
|
209
|
+
Evaluate compression quality.
|
|
210
|
+
|
|
211
|
+
Args:
|
|
212
|
+
original_messages: Original context messages
|
|
213
|
+
compressed_text: Compressed summary
|
|
214
|
+
probes: Optional pre-generated probes
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
EvaluationReport with scores and recommendations
|
|
218
|
+
"""
|
|
219
|
+
# Generate probes if not provided
|
|
220
|
+
if probes is None:
|
|
221
|
+
probes = generate_probes(original_messages)
|
|
222
|
+
|
|
223
|
+
# Calculate compression ratio
|
|
224
|
+
original_text = json.dumps(original_messages)
|
|
225
|
+
compression_ratio = calculate_compression_ratio(original_text, compressed_text)
|
|
226
|
+
|
|
227
|
+
# Evaluate each probe (simulated - production uses LLM)
|
|
228
|
+
probe_results = []
|
|
229
|
+
dimension_scores = {dim: [] for dim in DIMENSIONS}
|
|
230
|
+
|
|
231
|
+
for probe in probes:
|
|
232
|
+
# In production, send compressed_text + probe.question to LLM
|
|
233
|
+
# Here we simulate with heuristic check
|
|
234
|
+
scores = evaluate_response(probe, compressed_text)
|
|
235
|
+
|
|
236
|
+
overall = sum(scores.values()) / len(scores) if scores else 0
|
|
237
|
+
probe_results.append(ProbeResult(
|
|
238
|
+
probe=probe,
|
|
239
|
+
response="[Would be LLM response]",
|
|
240
|
+
scores=scores,
|
|
241
|
+
overall_score=overall
|
|
242
|
+
))
|
|
243
|
+
|
|
244
|
+
# Aggregate by dimension
|
|
245
|
+
for dim, score in scores.items():
|
|
246
|
+
if dim in dimension_scores:
|
|
247
|
+
dimension_scores[dim].append(score)
|
|
248
|
+
|
|
249
|
+
# Calculate dimension averages
|
|
250
|
+
avg_dimensions = {}
|
|
251
|
+
for dim, scores in dimension_scores.items():
|
|
252
|
+
avg_dimensions[dim] = sum(scores) / len(scores) if scores else 0.5
|
|
253
|
+
|
|
254
|
+
# Calculate weighted quality score
|
|
255
|
+
quality_score = sum(
|
|
256
|
+
avg_dimensions.get(dim, 0.5) * info["weight"]
|
|
257
|
+
for dim, info in DIMENSIONS.items()
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
# Generate recommendations
|
|
261
|
+
recommendations = []
|
|
262
|
+
if compression_ratio > 0.99:
|
|
263
|
+
recommendations.append("Very high compression. Risk of information loss.")
|
|
264
|
+
if avg_dimensions.get("artifact_trail", 1) < 0.5:
|
|
265
|
+
recommendations.append("Artifact tracking weak. Add explicit file section to summary.")
|
|
266
|
+
if avg_dimensions.get("continuity", 1) < 0.5:
|
|
267
|
+
recommendations.append("Continuity low. Add 'Next Steps' section to summary.")
|
|
268
|
+
if quality_score < 0.6:
|
|
269
|
+
recommendations.append("Quality below threshold. Consider less aggressive compression.")
|
|
270
|
+
|
|
271
|
+
return EvaluationReport(
|
|
272
|
+
compression_ratio=compression_ratio,
|
|
273
|
+
quality_score=quality_score,
|
|
274
|
+
dimension_scores=avg_dimensions,
|
|
275
|
+
probe_results=probe_results,
|
|
276
|
+
recommendations=recommendations
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def main():
|
|
281
|
+
parser = argparse.ArgumentParser(description="Compression quality evaluator")
|
|
282
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
283
|
+
|
|
284
|
+
# Evaluate command
|
|
285
|
+
eval_parser = subparsers.add_parser("evaluate", help="Evaluate compression quality")
|
|
286
|
+
eval_parser.add_argument("original_file", help="JSON file with original messages")
|
|
287
|
+
eval_parser.add_argument("compressed_file", help="Text file with compressed summary")
|
|
288
|
+
|
|
289
|
+
# Generate probes command
|
|
290
|
+
probe_parser = subparsers.add_parser("generate-probes", help="Generate evaluation probes")
|
|
291
|
+
probe_parser.add_argument("context_file", help="JSON file with context messages")
|
|
292
|
+
|
|
293
|
+
args = parser.parse_args()
|
|
294
|
+
|
|
295
|
+
if args.command == "evaluate":
|
|
296
|
+
with open(args.original_file) as f:
|
|
297
|
+
original = json.load(f)
|
|
298
|
+
messages = original if isinstance(original, list) else original.get("messages", [])
|
|
299
|
+
|
|
300
|
+
with open(args.compressed_file) as f:
|
|
301
|
+
compressed = f.read()
|
|
302
|
+
|
|
303
|
+
report = evaluate_compression(messages, compressed)
|
|
304
|
+
print(json.dumps({
|
|
305
|
+
"compression_ratio": f"{report.compression_ratio:.1%}",
|
|
306
|
+
"quality_score": f"{report.quality_score:.2f}",
|
|
307
|
+
"dimension_scores": {k: f"{v:.2f}" for k, v in report.dimension_scores.items()},
|
|
308
|
+
"probe_count": len(report.probe_results),
|
|
309
|
+
"recommendations": report.recommendations
|
|
310
|
+
}, indent=2))
|
|
311
|
+
|
|
312
|
+
elif args.command == "generate-probes":
|
|
313
|
+
with open(args.context_file) as f:
|
|
314
|
+
data = json.load(f)
|
|
315
|
+
messages = data if isinstance(data, list) else data.get("messages", [])
|
|
316
|
+
|
|
317
|
+
probes = generate_probes(messages)
|
|
318
|
+
output = []
|
|
319
|
+
for probe in probes:
|
|
320
|
+
output.append({
|
|
321
|
+
"type": probe.type.value,
|
|
322
|
+
"question": probe.question,
|
|
323
|
+
"ground_truth": probe.ground_truth
|
|
324
|
+
})
|
|
325
|
+
print(json.dumps(output, indent=2))
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
if __name__ == "__main__":
|
|
329
|
+
main()
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Context Analyzer - Health analysis and degradation detection for agent contexts.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python context_analyzer.py analyze <context_file>
|
|
7
|
+
python context_analyzer.py budget --system 2000 --tools 1500 --docs 3000 --history 5000
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import math
|
|
13
|
+
import re
|
|
14
|
+
from dataclasses import dataclass, field
|
|
15
|
+
from enum import Enum
|
|
16
|
+
from typing import Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class HealthStatus(Enum):
|
|
20
|
+
HEALTHY = "healthy"
|
|
21
|
+
WARNING = "warning"
|
|
22
|
+
DEGRADED = "degraded"
|
|
23
|
+
CRITICAL = "critical"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class ContextAnalysis:
|
|
28
|
+
total_tokens: int
|
|
29
|
+
token_limit: int
|
|
30
|
+
utilization: float
|
|
31
|
+
health_status: HealthStatus
|
|
32
|
+
health_score: float
|
|
33
|
+
degradation_risk: float
|
|
34
|
+
poisoning_risk: float
|
|
35
|
+
recommendations: list = field(default_factory=list)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def estimate_tokens(text: str) -> int:
|
|
39
|
+
"""Estimate token count (~4 chars per token for English)."""
|
|
40
|
+
return len(text) // 4
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def estimate_message_tokens(messages: list) -> int:
|
|
44
|
+
"""Estimate tokens in message list."""
|
|
45
|
+
total = 0
|
|
46
|
+
for msg in messages:
|
|
47
|
+
if isinstance(msg, dict):
|
|
48
|
+
content = msg.get("content", "")
|
|
49
|
+
total += estimate_tokens(str(content))
|
|
50
|
+
# Add overhead for role, metadata
|
|
51
|
+
total += 10
|
|
52
|
+
else:
|
|
53
|
+
total += estimate_tokens(str(msg))
|
|
54
|
+
return total
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def measure_attention_distribution(context_length: int, sample_size: int = 100) -> list:
|
|
58
|
+
"""
|
|
59
|
+
Simulate U-shaped attention distribution.
|
|
60
|
+
Real implementation would extract from model attention weights.
|
|
61
|
+
"""
|
|
62
|
+
attention = []
|
|
63
|
+
for i in range(sample_size):
|
|
64
|
+
position = i / sample_size
|
|
65
|
+
# U-shaped curve: high at start/end, low in middle
|
|
66
|
+
if position < 0.1:
|
|
67
|
+
score = 0.9 - position * 2
|
|
68
|
+
elif position > 0.9:
|
|
69
|
+
score = 0.7 + (position - 0.9) * 2
|
|
70
|
+
else:
|
|
71
|
+
score = 0.3 + 0.1 * math.sin(position * math.pi)
|
|
72
|
+
attention.append(score)
|
|
73
|
+
return attention
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def detect_lost_in_middle(messages: list, critical_keywords: list) -> list:
|
|
77
|
+
"""Identify critical items in attention-degraded regions."""
|
|
78
|
+
if not messages:
|
|
79
|
+
return []
|
|
80
|
+
|
|
81
|
+
total = len(messages)
|
|
82
|
+
warnings = []
|
|
83
|
+
|
|
84
|
+
for i, msg in enumerate(messages):
|
|
85
|
+
position = i / total
|
|
86
|
+
content = str(msg.get("content", "") if isinstance(msg, dict) else msg)
|
|
87
|
+
|
|
88
|
+
# Middle region (10%-90%)
|
|
89
|
+
if 0.1 < position < 0.9:
|
|
90
|
+
for keyword in critical_keywords:
|
|
91
|
+
if keyword.lower() in content.lower():
|
|
92
|
+
warnings.append({
|
|
93
|
+
"position": i,
|
|
94
|
+
"position_pct": f"{position:.1%}",
|
|
95
|
+
"keyword": keyword,
|
|
96
|
+
"risk": "high" if 0.3 < position < 0.7 else "medium"
|
|
97
|
+
})
|
|
98
|
+
return warnings
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def detect_poisoning_patterns(messages: list) -> dict:
|
|
102
|
+
"""Detect potential context poisoning indicators."""
|
|
103
|
+
error_patterns = [
|
|
104
|
+
r"error", r"failed", r"exception", r"cannot", r"unable",
|
|
105
|
+
r"invalid", r"not found", r"undefined", r"null"
|
|
106
|
+
]
|
|
107
|
+
# Simple contradiction check - look for both positive and negative statements
|
|
108
|
+
contradiction_keywords = [
|
|
109
|
+
("is correct", "is not correct"),
|
|
110
|
+
("should work", "should not work"),
|
|
111
|
+
("will succeed", "will fail"),
|
|
112
|
+
("is valid", "is invalid"),
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
errors_found = []
|
|
116
|
+
contradictions = []
|
|
117
|
+
|
|
118
|
+
for i, msg in enumerate(messages):
|
|
119
|
+
content = str(msg.get("content", "") if isinstance(msg, dict) else msg).lower()
|
|
120
|
+
|
|
121
|
+
# Check error patterns
|
|
122
|
+
for pattern in error_patterns:
|
|
123
|
+
if re.search(pattern, content):
|
|
124
|
+
errors_found.append({"position": i, "pattern": pattern})
|
|
125
|
+
|
|
126
|
+
# Check for contradiction keywords (simplified)
|
|
127
|
+
for pos_phrase, neg_phrase in contradiction_keywords:
|
|
128
|
+
if pos_phrase in content and neg_phrase in content:
|
|
129
|
+
contradictions.append({"position": i, "type": "self-contradiction"})
|
|
130
|
+
|
|
131
|
+
total = max(len(messages), 1)
|
|
132
|
+
return {
|
|
133
|
+
"error_density": len(errors_found) / total,
|
|
134
|
+
"contradiction_count": len(contradictions),
|
|
135
|
+
"poisoning_risk": min(1.0, (len(errors_found) * 0.1 + len(contradictions) * 0.3))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def calculate_health_score(utilization: float, degradation_risk: float, poisoning_risk: float) -> float:
|
|
140
|
+
"""
|
|
141
|
+
Calculate composite health score.
|
|
142
|
+
1.0 = healthy, 0.0 = critical
|
|
143
|
+
"""
|
|
144
|
+
score = 1.0
|
|
145
|
+
# Utilization penalty (kicks in after 70%)
|
|
146
|
+
if utilization > 0.7:
|
|
147
|
+
score -= (utilization - 0.7) * 1.5
|
|
148
|
+
# Degradation penalty
|
|
149
|
+
score -= degradation_risk * 0.3
|
|
150
|
+
# Poisoning penalty
|
|
151
|
+
score -= poisoning_risk * 0.2
|
|
152
|
+
return max(0.0, min(1.0, score))
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def get_health_status(score: float) -> HealthStatus:
|
|
156
|
+
"""Map health score to status."""
|
|
157
|
+
if score > 0.8:
|
|
158
|
+
return HealthStatus.HEALTHY
|
|
159
|
+
elif score > 0.6:
|
|
160
|
+
return HealthStatus.WARNING
|
|
161
|
+
elif score > 0.4:
|
|
162
|
+
return HealthStatus.DEGRADED
|
|
163
|
+
return HealthStatus.CRITICAL
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def analyze_context(messages: list, token_limit: int = 128000,
|
|
167
|
+
critical_keywords: Optional[list] = None) -> ContextAnalysis:
|
|
168
|
+
"""
|
|
169
|
+
Comprehensive context health analysis.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
messages: List of context messages
|
|
173
|
+
token_limit: Model's context window size
|
|
174
|
+
critical_keywords: Keywords that should be at attention-favored positions
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
ContextAnalysis with health metrics and recommendations
|
|
178
|
+
"""
|
|
179
|
+
critical_keywords = critical_keywords or ["goal", "task", "important", "critical", "must"]
|
|
180
|
+
|
|
181
|
+
# Calculate token utilization
|
|
182
|
+
total_tokens = estimate_message_tokens(messages)
|
|
183
|
+
utilization = total_tokens / token_limit
|
|
184
|
+
|
|
185
|
+
# Check for lost-in-middle issues
|
|
186
|
+
middle_warnings = detect_lost_in_middle(messages, critical_keywords)
|
|
187
|
+
degradation_risk = min(1.0, len(middle_warnings) * 0.2)
|
|
188
|
+
|
|
189
|
+
# Check for poisoning
|
|
190
|
+
poisoning = detect_poisoning_patterns(messages)
|
|
191
|
+
poisoning_risk = poisoning["poisoning_risk"]
|
|
192
|
+
|
|
193
|
+
# Calculate health
|
|
194
|
+
health_score = calculate_health_score(utilization, degradation_risk, poisoning_risk)
|
|
195
|
+
health_status = get_health_status(health_score)
|
|
196
|
+
|
|
197
|
+
# Generate recommendations
|
|
198
|
+
recommendations = []
|
|
199
|
+
if utilization > 0.8:
|
|
200
|
+
recommendations.append("URGENT: Context utilization >80%. Trigger compaction immediately.")
|
|
201
|
+
elif utilization > 0.7:
|
|
202
|
+
recommendations.append("WARNING: Context utilization >70%. Plan for compaction.")
|
|
203
|
+
|
|
204
|
+
if middle_warnings:
|
|
205
|
+
recommendations.append(f"Found {len(middle_warnings)} critical items in middle region. "
|
|
206
|
+
"Consider moving to beginning/end.")
|
|
207
|
+
|
|
208
|
+
if poisoning_risk > 0.3:
|
|
209
|
+
recommendations.append("High poisoning risk detected. Review recent tool outputs for errors.")
|
|
210
|
+
|
|
211
|
+
if health_status == HealthStatus.CRITICAL:
|
|
212
|
+
recommendations.append("CRITICAL: Consider context reset with clean state.")
|
|
213
|
+
|
|
214
|
+
return ContextAnalysis(
|
|
215
|
+
total_tokens=total_tokens,
|
|
216
|
+
token_limit=token_limit,
|
|
217
|
+
utilization=utilization,
|
|
218
|
+
health_status=health_status,
|
|
219
|
+
health_score=health_score,
|
|
220
|
+
degradation_risk=degradation_risk,
|
|
221
|
+
poisoning_risk=poisoning_risk,
|
|
222
|
+
recommendations=recommendations
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def calculate_budget(system: int, tools: int, docs: int, history: int,
|
|
227
|
+
buffer_pct: float = 0.15) -> dict:
|
|
228
|
+
"""Calculate context budget allocation."""
|
|
229
|
+
subtotal = system + tools + docs + history
|
|
230
|
+
buffer = int(subtotal * buffer_pct)
|
|
231
|
+
total = subtotal + buffer
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
"allocation": {
|
|
235
|
+
"system_prompt": system,
|
|
236
|
+
"tool_definitions": tools,
|
|
237
|
+
"retrieved_docs": docs,
|
|
238
|
+
"message_history": history,
|
|
239
|
+
"reserved_buffer": buffer
|
|
240
|
+
},
|
|
241
|
+
"total_budget": total,
|
|
242
|
+
"warning_threshold": int(total * 0.7),
|
|
243
|
+
"critical_threshold": int(total * 0.8),
|
|
244
|
+
"recommendations": [
|
|
245
|
+
f"Trigger compaction at {int(total * 0.7):,} tokens",
|
|
246
|
+
f"Aggressive optimization at {int(total * 0.8):,} tokens",
|
|
247
|
+
f"Reserved {buffer:,} tokens ({buffer_pct:.0%}) for responses"
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def main():
|
|
253
|
+
parser = argparse.ArgumentParser(description="Context health analyzer")
|
|
254
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
255
|
+
|
|
256
|
+
# Analyze command
|
|
257
|
+
analyze_parser = subparsers.add_parser("analyze", help="Analyze context health")
|
|
258
|
+
analyze_parser.add_argument("context_file", help="JSON file with messages array")
|
|
259
|
+
analyze_parser.add_argument("--limit", type=int, default=128000, help="Token limit")
|
|
260
|
+
analyze_parser.add_argument("--keywords", nargs="+", help="Critical keywords to track")
|
|
261
|
+
|
|
262
|
+
# Budget command
|
|
263
|
+
budget_parser = subparsers.add_parser("budget", help="Calculate context budget")
|
|
264
|
+
budget_parser.add_argument("--system", type=int, default=2000, help="System prompt tokens")
|
|
265
|
+
budget_parser.add_argument("--tools", type=int, default=1500, help="Tool definitions tokens")
|
|
266
|
+
budget_parser.add_argument("--docs", type=int, default=3000, help="Retrieved docs tokens")
|
|
267
|
+
budget_parser.add_argument("--history", type=int, default=5000, help="Message history tokens")
|
|
268
|
+
budget_parser.add_argument("--buffer", type=float, default=0.15, help="Buffer percentage")
|
|
269
|
+
|
|
270
|
+
args = parser.parse_args()
|
|
271
|
+
|
|
272
|
+
if args.command == "analyze":
|
|
273
|
+
with open(args.context_file) as f:
|
|
274
|
+
data = json.load(f)
|
|
275
|
+
messages = data if isinstance(data, list) else data.get("messages", [])
|
|
276
|
+
result = analyze_context(messages, args.limit, args.keywords)
|
|
277
|
+
print(json.dumps({
|
|
278
|
+
"total_tokens": result.total_tokens,
|
|
279
|
+
"token_limit": result.token_limit,
|
|
280
|
+
"utilization": f"{result.utilization:.1%}",
|
|
281
|
+
"health_status": result.health_status.value,
|
|
282
|
+
"health_score": f"{result.health_score:.2f}",
|
|
283
|
+
"degradation_risk": f"{result.degradation_risk:.2f}",
|
|
284
|
+
"poisoning_risk": f"{result.poisoning_risk:.2f}",
|
|
285
|
+
"recommendations": result.recommendations
|
|
286
|
+
}, indent=2))
|
|
287
|
+
|
|
288
|
+
elif args.command == "budget":
|
|
289
|
+
result = calculate_budget(args.system, args.tools, args.docs, args.history, args.buffer)
|
|
290
|
+
print(json.dumps(result, indent=2))
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
if __name__ == "__main__":
|
|
294
|
+
main()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: database-design
|
|
3
|
+
description: Database design principles and decision-making. Schema design, indexing strategy, ORM selection, serverless databases.
|
|
4
|
+
allowed-tools: Read, Write, Edit, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Database Design
|
|
8
|
+
|
|
9
|
+
> **Learn to THINK, not copy SQL patterns.**
|
|
10
|
+
|
|
11
|
+
## 🎯 Selective Reading Rule
|
|
12
|
+
|
|
13
|
+
**Read ONLY files relevant to the request!** Check the content map, find what you need.
|
|
14
|
+
|
|
15
|
+
| File | Description | When to Read |
|
|
16
|
+
|------|-------------|--------------|
|
|
17
|
+
| `database-selection.md` | PostgreSQL vs Neon vs Turso vs SQLite | Choosing database |
|
|
18
|
+
| `orm-selection.md` | Drizzle vs Prisma vs Kysely | Choosing ORM |
|
|
19
|
+
| `schema-design.md` | Normalization, PKs, relationships | Designing schema |
|
|
20
|
+
| `indexing.md` | Index types, composite indexes | Performance tuning |
|
|
21
|
+
| `optimization.md` | N+1, EXPLAIN ANALYZE | Query optimization |
|
|
22
|
+
| `migrations.md` | Safe migrations, serverless DBs | Schema changes |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## ⚠️ Core Principle
|
|
27
|
+
|
|
28
|
+
- ASK user for database preferences when unclear
|
|
29
|
+
- Choose database/ORM based on CONTEXT
|
|
30
|
+
- Don't default to PostgreSQL for everything
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Decision Checklist
|
|
35
|
+
|
|
36
|
+
Before designing schema:
|
|
37
|
+
|
|
38
|
+
- [ ] Asked user about database preference?
|
|
39
|
+
- [ ] Chosen database for THIS context?
|
|
40
|
+
- [ ] Considered deployment environment?
|
|
41
|
+
- [ ] Planned index strategy?
|
|
42
|
+
- [ ] Defined relationship types?
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Anti-Patterns
|
|
47
|
+
|
|
48
|
+
❌ Default to PostgreSQL for simple apps (SQLite may suffice)
|
|
49
|
+
❌ Skip indexing
|
|
50
|
+
❌ Use SELECT * in production
|
|
51
|
+
❌ Store JSON when structured data is better
|
|
52
|
+
❌ Ignore N+1 queries
|