@mytechtoday/augment-extensions 0.2.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +614 -39
- package/augment-extensions/coding-standards/bash/README.md +196 -0
- package/augment-extensions/coding-standards/bash/module.json +163 -0
- package/augment-extensions/coding-standards/bash/rules/naming-conventions.md +336 -0
- package/augment-extensions/coding-standards/bash/rules/universal-standards.md +289 -0
- package/augment-extensions/coding-standards/css/README.md +40 -0
- package/augment-extensions/coding-standards/css/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/css/module.json +44 -0
- package/augment-extensions/coding-standards/css/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/css/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html/README.md +40 -0
- package/augment-extensions/coding-standards/html/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html/module.json +44 -0
- package/augment-extensions/coding-standards/html/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/README.md +194 -0
- package/augment-extensions/coding-standards/html-css-js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/html-css-js/examples/css-examples.css +550 -0
- package/augment-extensions/coding-standards/html-css-js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/html-css-js/examples/html-examples.html +267 -0
- package/augment-extensions/coding-standards/html-css-js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/html-css-js/examples/responsive-layout.html +505 -0
- package/augment-extensions/coding-standards/html-css-js/module.json +48 -0
- package/augment-extensions/coding-standards/html-css-js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-modern-features.md +448 -0
- package/augment-extensions/coding-standards/html-css-js/rules/css-standards.md +492 -0
- package/augment-extensions/coding-standards/html-css-js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/html-css-js/rules/html-standards.md +349 -0
- package/augment-extensions/coding-standards/html-css-js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/html-css-js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/html-css-js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/js/README.md +46 -0
- package/augment-extensions/coding-standards/js/examples/async-examples.js +487 -0
- package/augment-extensions/coding-standards/js/examples/dom-examples.js +667 -0
- package/augment-extensions/coding-standards/js/examples/javascript-examples.js +612 -0
- package/augment-extensions/coding-standards/js/module.json +49 -0
- package/augment-extensions/coding-standards/js/rules/async-patterns.md +515 -0
- package/augment-extensions/coding-standards/js/rules/dom-manipulation.md +439 -0
- package/augment-extensions/coding-standards/js/rules/javascript-standards.md +486 -0
- package/augment-extensions/coding-standards/js/rules/performance.md +463 -0
- package/augment-extensions/coding-standards/js/rules/tooling.md +543 -0
- package/augment-extensions/coding-standards/php/README.md +248 -0
- package/augment-extensions/coding-standards/php/examples/api-endpoint-example.php +204 -0
- package/augment-extensions/coding-standards/php/examples/cli-command-example.php +206 -0
- package/augment-extensions/coding-standards/php/examples/legacy-refactoring-example.php +234 -0
- package/augment-extensions/coding-standards/php/examples/web-application-example.php +211 -0
- package/augment-extensions/coding-standards/php/examples/woocommerce-extension-example.php +215 -0
- package/augment-extensions/coding-standards/php/examples/wordpress-plugin-example.php +189 -0
- package/augment-extensions/coding-standards/php/module.json +166 -0
- package/augment-extensions/coding-standards/php/rules/api-development.md +480 -0
- package/augment-extensions/coding-standards/php/rules/category-configuration.md +332 -0
- package/augment-extensions/coding-standards/php/rules/cli-tools.md +472 -0
- package/augment-extensions/coding-standards/php/rules/cms-integration.md +561 -0
- package/augment-extensions/coding-standards/php/rules/code-quality.md +402 -0
- package/augment-extensions/coding-standards/php/rules/documentation.md +425 -0
- package/augment-extensions/coding-standards/php/rules/ecommerce.md +627 -0
- package/augment-extensions/coding-standards/php/rules/error-handling.md +336 -0
- package/augment-extensions/coding-standards/php/rules/legacy-migration.md +677 -0
- package/augment-extensions/coding-standards/php/rules/naming-conventions.md +279 -0
- package/augment-extensions/coding-standards/php/rules/performance.md +392 -0
- package/augment-extensions/coding-standards/php/rules/psr-standards.md +186 -0
- package/augment-extensions/coding-standards/php/rules/security.md +358 -0
- package/augment-extensions/coding-standards/php/rules/testing.md +403 -0
- package/augment-extensions/coding-standards/php/rules/type-declarations.md +331 -0
- package/augment-extensions/coding-standards/php/rules/web-applications.md +426 -0
- package/augment-extensions/coding-standards/powershell/README.md +154 -0
- package/augment-extensions/coding-standards/powershell/examples/admin-example.ps1 +272 -0
- package/augment-extensions/coding-standards/powershell/examples/automation-example.ps1 +173 -0
- package/augment-extensions/coding-standards/powershell/examples/cloud-example.ps1 +243 -0
- package/augment-extensions/coding-standards/powershell/examples/cross-platform-example.ps1 +297 -0
- package/augment-extensions/coding-standards/powershell/examples/dsc-example.ps1 +224 -0
- package/augment-extensions/coding-standards/powershell/examples/legacy-migration-example.ps1 +340 -0
- package/augment-extensions/coding-standards/powershell/examples/module-example.psm1 +255 -0
- package/augment-extensions/coding-standards/powershell/module.json +165 -0
- package/augment-extensions/coding-standards/powershell/rules/administrative-tools.md +439 -0
- package/augment-extensions/coding-standards/powershell/rules/automation-scripts.md +240 -0
- package/augment-extensions/coding-standards/powershell/rules/cloud-orchestration.md +384 -0
- package/augment-extensions/coding-standards/powershell/rules/configuration-schema.md +383 -0
- package/augment-extensions/coding-standards/powershell/rules/cross-platform-scripts.md +482 -0
- package/augment-extensions/coding-standards/powershell/rules/dsc-configurations.md +296 -0
- package/augment-extensions/coding-standards/powershell/rules/error-handling.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/legacy-migrations.md +466 -0
- package/augment-extensions/coding-standards/powershell/rules/modules-functions.md +244 -0
- package/augment-extensions/coding-standards/powershell/rules/naming-conventions.md +266 -0
- package/augment-extensions/coding-standards/powershell/rules/performance-optimization.md +209 -0
- package/augment-extensions/coding-standards/powershell/rules/security-practices.md +314 -0
- package/augment-extensions/coding-standards/powershell/rules/testing-guidelines.md +268 -0
- package/augment-extensions/coding-standards/powershell/rules/universal-standards.md +197 -0
- package/augment-extensions/coding-standards/python/README.md +12 -8
- package/augment-extensions/coding-standards/python/examples/best-practices.py +373 -0
- package/augment-extensions/coding-standards/python/module.json +8 -4
- package/augment-extensions/coding-standards/python/rules/async-patterns.md +884 -0
- package/augment-extensions/coding-standards/python/rules/documentation.md +831 -0
- package/augment-extensions/coding-standards/python/rules/error-handling.md +855 -68
- package/augment-extensions/coding-standards/python/rules/testing.md +409 -0
- package/augment-extensions/coding-standards/python/rules/tooling.md +446 -0
- package/augment-extensions/coding-standards/python/rules/type-hints.md +115 -50
- package/augment-extensions/collections/html-css-js/README.md +82 -0
- package/augment-extensions/collections/html-css-js/collection.json +41 -0
- package/augment-extensions/domain-rules/database/README.md +161 -0
- package/augment-extensions/domain-rules/database/examples/flat-database-example.md +793 -0
- package/augment-extensions/domain-rules/database/examples/hybrid-database-example.md +1132 -0
- package/augment-extensions/domain-rules/database/examples/nosql-document-example.md +868 -0
- package/augment-extensions/domain-rules/database/examples/nosql-graph-example.md +805 -0
- package/augment-extensions/domain-rules/database/examples/relational-schema-example.md +621 -0
- package/augment-extensions/domain-rules/database/examples/vector-database-example.md +965 -0
- package/augment-extensions/domain-rules/database/module.json +28 -0
- package/augment-extensions/domain-rules/database/rules/flat-databases.md +624 -0
- package/augment-extensions/domain-rules/database/rules/nosql-databases.md +588 -0
- package/augment-extensions/domain-rules/database/rules/nosql-document-stores.md +856 -0
- package/augment-extensions/domain-rules/database/rules/nosql-graph-databases.md +778 -0
- package/augment-extensions/domain-rules/database/rules/nosql-key-value-stores.md +963 -0
- package/augment-extensions/domain-rules/database/rules/performance-optimization.md +1076 -0
- package/augment-extensions/domain-rules/database/rules/relational-databases.md +697 -0
- package/augment-extensions/domain-rules/database/rules/relational-indexing.md +671 -0
- package/augment-extensions/domain-rules/database/rules/relational-query-optimization.md +607 -0
- package/augment-extensions/domain-rules/database/rules/relational-schema-design.md +907 -0
- package/augment-extensions/domain-rules/database/rules/relational-transactions.md +783 -0
- package/augment-extensions/domain-rules/database/rules/security-standards.md +980 -0
- package/augment-extensions/domain-rules/database/rules/universal-best-practices.md +485 -0
- package/augment-extensions/domain-rules/database/rules/vector-databases.md +521 -0
- package/augment-extensions/domain-rules/database/rules/vector-embeddings.md +858 -0
- package/augment-extensions/domain-rules/database/rules/vector-indexing.md +934 -0
- package/augment-extensions/domain-rules/design/color/themes/catppuccin-latte/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/catppuccin-latte/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/catppuccin-mocha/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/catppuccin-mocha/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/dracula/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/dracula/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/gruvbox-dark/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/gruvbox-dark/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/gruvbox-light/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/gruvbox-light/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/high-contrast/README.md +27 -0
- package/augment-extensions/domain-rules/design/color/themes/high-contrast/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/monokai/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/monokai/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/nord/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/nord/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/one-dark/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/one-dark/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/one-light/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/one-light/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/solarized-dark/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/solarized-dark/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/solarized-light/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/solarized-light/module.json +26 -0
- package/augment-extensions/domain-rules/design/color/themes/tokyo-night/README.md +23 -0
- package/augment-extensions/domain-rules/design/color/themes/tokyo-night/module.json +26 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/README.md +136 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/SCHEMA-VALIDATION-REPORT.md +216 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/brand-kit-example.yaml +292 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/campaign-brief-example.yaml +389 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/content-calendar-example.yaml +643 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/email-newsletter-example.md +376 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/landing-page-example.md +934 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/ppc-ad-copy-example.md +301 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/seo-blog-post-example.md +347 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/examples/social-media-campaign-example.md +606 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/module.json +50 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/affiliate-influencer-marketing.md +593 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/asset-management.md +418 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/brand-consistency.md +210 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/content-marketing.md +337 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/conversion-optimization.md +455 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/direct-sales.md +499 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/email-marketing.md +439 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/legal-compliance.md +227 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/ppc-advertising.md +569 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/seo-optimization.md +470 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/social-media-marketing.md +414 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/rules/universal-marketing.md +177 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/schemas/asset-inventory.schema.json +247 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/schemas/brand-kit.schema.json +326 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/schemas/campaign-brief.schema.json +342 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/schemas/color-palette.schema.json +223 -0
- package/augment-extensions/domain-rules/marketing-standards/seo-sales-marketing/schemas/content-template.schema.json +383 -0
- package/augment-extensions/domain-rules/mcp/README.md +150 -0
- package/augment-extensions/domain-rules/mcp/examples/compressed-example.md +522 -0
- package/augment-extensions/domain-rules/mcp/examples/graph-augmented-example.md +520 -0
- package/augment-extensions/domain-rules/mcp/examples/hybrid-example.md +570 -0
- package/augment-extensions/domain-rules/mcp/examples/state-based-example.md +427 -0
- package/augment-extensions/domain-rules/mcp/examples/token-based-example.md +435 -0
- package/augment-extensions/domain-rules/mcp/examples/vector-based-example.md +502 -0
- package/augment-extensions/domain-rules/mcp/module.json +49 -0
- package/augment-extensions/domain-rules/mcp/rules/compressed-mcp.md +595 -0
- package/augment-extensions/domain-rules/mcp/rules/configuration.md +345 -0
- package/augment-extensions/domain-rules/mcp/rules/graph-augmented-mcp.md +687 -0
- package/augment-extensions/domain-rules/mcp/rules/hybrid-mcp.md +636 -0
- package/augment-extensions/domain-rules/mcp/rules/state-based-mcp.md +484 -0
- package/augment-extensions/domain-rules/mcp/rules/testing-validation.md +360 -0
- package/augment-extensions/domain-rules/mcp/rules/token-based-mcp.md +393 -0
- package/augment-extensions/domain-rules/mcp/rules/universal-rules.md +194 -0
- package/augment-extensions/domain-rules/mcp/rules/vector-based-mcp.md +625 -0
- package/augment-extensions/workflows/beads/module.json +4 -3
- package/augment-extensions/workflows/beads-integration/IMPLEMENTATION-STATUS.md +145 -0
- package/augment-extensions/workflows/beads-integration/README.md +143 -0
- package/augment-extensions/workflows/beads-integration/config/defaults.json +32 -0
- package/augment-extensions/workflows/beads-integration/config/schema.json +140 -0
- package/augment-extensions/workflows/beads-integration/examples/basic-task-generation.md +293 -0
- package/augment-extensions/workflows/beads-integration/module.json +75 -0
- package/augment-extensions/workflows/beads-integration/rules/core-rules.md +219 -0
- package/augment-extensions/workflows/beads-integration/rules/effectiveness-standards.md +256 -0
- package/augment-extensions/workflows/beads-integration/rules/task-generation.md +607 -0
- package/augment-extensions/workflows/database/README.md +195 -0
- package/augment-extensions/workflows/database/ai-prompt-testing.md +295 -0
- package/augment-extensions/workflows/database/examples/migration-example.md +498 -0
- package/augment-extensions/workflows/database/examples/optimization-example.md +496 -0
- package/augment-extensions/workflows/database/examples/schema-design-example.md +444 -0
- package/augment-extensions/workflows/database/module.json +42 -0
- package/augment-extensions/workflows/database/rules/data-migration.md +249 -0
- package/augment-extensions/workflows/database/rules/documentation-standards.md +339 -0
- package/augment-extensions/workflows/database/rules/migration-workflow.md +352 -0
- package/augment-extensions/workflows/database/rules/optimization-workflow.md +435 -0
- package/augment-extensions/workflows/database/rules/schema-design-workflow.md +535 -0
- package/augment-extensions/workflows/database/rules/testing-patterns.md +305 -0
- package/augment-extensions/workflows/database/rules/workflow.md +458 -0
- package/augment-extensions/workflows/openspec/module.json +4 -3
- package/augment-extensions/writing-standards/screenplay/README.md +300 -0
- package/augment-extensions/writing-standards/screenplay/_templates/README.md +121 -0
- package/augment-extensions/writing-standards/screenplay/_templates/genre-template.md +153 -0
- package/augment-extensions/writing-standards/screenplay/_templates/style-template.md +243 -0
- package/augment-extensions/writing-standards/screenplay/_templates/theme-template.md +213 -0
- package/augment-extensions/writing-standards/screenplay/examples/aaa-hollywood-scene.fountain +164 -0
- package/augment-extensions/writing-standards/screenplay/examples/beat-sheet-example.yaml +95 -0
- package/augment-extensions/writing-standards/screenplay/examples/character-profile-example.yaml +116 -0
- package/augment-extensions/writing-standards/screenplay/examples/commercial-30sec.fountain +151 -0
- package/augment-extensions/writing-standards/screenplay/examples/independent-monologue.fountain +67 -0
- package/augment-extensions/writing-standards/screenplay/examples/news-segment.fountain +142 -0
- package/augment-extensions/writing-standards/screenplay/examples/plot-outline-example.yaml +184 -0
- package/augment-extensions/writing-standards/screenplay/examples/tv-episode-teaser.fountain +204 -0
- package/augment-extensions/writing-standards/screenplay/genres/README.md +181 -0
- package/augment-extensions/writing-standards/screenplay/genres/examples/.gitkeep +2 -0
- package/augment-extensions/writing-standards/screenplay/genres/module.json +70 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/.gitkeep +2 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/action.md +399 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/adventure.md +407 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/animation.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/biographical.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/comedy.md +401 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/documentary.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/drama.md +409 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/fantasy.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/historical.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/horror.md +268 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/musical.md +294 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/mystery.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/noir.md +294 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/romance.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/sci-fi.md +289 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/superhero.md +293 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/thriller.md +294 -0
- package/augment-extensions/writing-standards/screenplay/genres/rules/western.md +293 -0
- package/augment-extensions/writing-standards/screenplay/module.json +124 -0
- package/augment-extensions/writing-standards/screenplay/rules/aaa-hollywood-films.md +339 -0
- package/augment-extensions/writing-standards/screenplay/rules/ai-integration-testing.md +329 -0
- package/augment-extensions/writing-standards/screenplay/rules/character-development.md +169 -0
- package/augment-extensions/writing-standards/screenplay/rules/commercials.md +437 -0
- package/augment-extensions/writing-standards/screenplay/rules/dialogue-writing.md +263 -0
- package/augment-extensions/writing-standards/screenplay/rules/diversity-inclusion.md +261 -0
- package/augment-extensions/writing-standards/screenplay/rules/examples-guide.md +315 -0
- package/augment-extensions/writing-standards/screenplay/rules/formatting-validation.md +413 -0
- package/augment-extensions/writing-standards/screenplay/rules/fountain-format.md +372 -0
- package/augment-extensions/writing-standards/screenplay/rules/independent-films.md +374 -0
- package/augment-extensions/writing-standards/screenplay/rules/live-tv-productions.md +443 -0
- package/augment-extensions/writing-standards/screenplay/rules/narrative-structures.md +207 -0
- package/augment-extensions/writing-standards/screenplay/rules/news-broadcasts.md +444 -0
- package/augment-extensions/writing-standards/screenplay/rules/pacing-timing.md +331 -0
- package/augment-extensions/writing-standards/screenplay/rules/quality-review-checklist.md +334 -0
- package/augment-extensions/writing-standards/screenplay/rules/quick-reference.md +299 -0
- package/augment-extensions/writing-standards/screenplay/rules/screen-continuity.md +263 -0
- package/augment-extensions/writing-standards/screenplay/rules/streaming-content.md +412 -0
- package/augment-extensions/writing-standards/screenplay/rules/trope-management.md +370 -0
- package/augment-extensions/writing-standards/screenplay/rules/tv-series.md +374 -0
- package/augment-extensions/writing-standards/screenplay/rules/universal-formatting.md +339 -0
- package/augment-extensions/writing-standards/screenplay/rules/vscode-integration.md +277 -0
- package/augment-extensions/writing-standards/screenplay/rules/web-content.md +393 -0
- package/augment-extensions/writing-standards/screenplay/schemas/beat-sheet.json +332 -0
- package/augment-extensions/writing-standards/screenplay/schemas/character-profile.json +247 -0
- package/augment-extensions/writing-standards/screenplay/schemas/feature-selection.json +200 -0
- package/augment-extensions/writing-standards/screenplay/schemas/plot-outline.json +233 -0
- package/augment-extensions/writing-standards/screenplay/schemas/screenplay-config.json +245 -0
- package/augment-extensions/writing-standards/screenplay/schemas/trope-inventory.json +221 -0
- package/augment-extensions/writing-standards/screenplay/styles/README.md +159 -0
- package/augment-extensions/writing-standards/screenplay/styles/examples/.gitkeep +2 -0
- package/augment-extensions/writing-standards/screenplay/styles/examples/style-applications.md +1449 -0
- package/augment-extensions/writing-standards/screenplay/styles/module.json +64 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/.gitkeep +2 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/dialogue-centric.md +520 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/ensemble.md +499 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/epic.md +497 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/experimental.md +492 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/flashback.md +509 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/linear.md +490 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/minimalist.md +499 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/non-linear.md +501 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/poetic.md +499 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/realistic.md +498 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/satirical.md +499 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/surreal.md +508 -0
- package/augment-extensions/writing-standards/screenplay/styles/rules/voice-over.md +500 -0
- package/augment-extensions/writing-standards/screenplay/themes/README.md +158 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/.gitkeep +2 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/common-mistakes-and-fixes.md +643 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/complete-scene-example.md +311 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/individual-theme-examples.md +562 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/multi-theme-weaving.md +538 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/theme-application-guide.md +432 -0
- package/augment-extensions/writing-standards/screenplay/themes/examples/theme-integration-across-acts.md +637 -0
- package/augment-extensions/writing-standards/screenplay/themes/module.json +66 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/.gitkeep +2 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/ambition.md +458 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/betrayal.md +490 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/environment.md +458 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/fate.md +459 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/friendship.md +491 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/growth.md +491 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/identity.md +490 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/isolation.md +464 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/justice.md +461 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/love.md +489 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/power.md +494 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/redemption.md +483 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/revenge.md +489 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/survival.md +496 -0
- package/augment-extensions/writing-standards/screenplay/themes/rules/technology.md +463 -0
- package/cli/MODULES.md +302 -0
- package/cli/dist/cli.js +168 -10
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/catalog.d.ts +13 -0
- package/cli/dist/commands/catalog.d.ts.map +1 -0
- package/cli/dist/commands/catalog.js +104 -0
- package/cli/dist/commands/catalog.js.map +1 -0
- package/cli/dist/commands/gui.d.ts +6 -0
- package/cli/dist/commands/gui.d.ts.map +1 -0
- package/cli/dist/commands/gui.js +211 -0
- package/cli/dist/commands/gui.js.map +1 -0
- package/cli/dist/commands/init.d.ts.map +1 -1
- package/cli/dist/commands/init.js +12 -0
- package/cli/dist/commands/init.js.map +1 -1
- package/cli/dist/commands/install-rules.d.ts +14 -0
- package/cli/dist/commands/install-rules.d.ts.map +1 -0
- package/cli/dist/commands/install-rules.js +127 -0
- package/cli/dist/commands/install-rules.js.map +1 -0
- package/cli/dist/commands/link.d.ts.map +1 -1
- package/cli/dist/commands/link.js +9 -11
- package/cli/dist/commands/link.js.map +1 -1
- package/cli/dist/commands/list.d.ts.map +1 -1
- package/cli/dist/commands/list.js +11 -28
- package/cli/dist/commands/list.js.map +1 -1
- package/cli/dist/commands/mcp.d.ts +48 -0
- package/cli/dist/commands/mcp.d.ts.map +1 -0
- package/cli/dist/commands/mcp.js +229 -0
- package/cli/dist/commands/mcp.js.map +1 -0
- package/cli/dist/commands/self-remove.d.ts +7 -0
- package/cli/dist/commands/self-remove.d.ts.map +1 -0
- package/cli/dist/commands/self-remove.js +179 -0
- package/cli/dist/commands/self-remove.js.map +1 -0
- package/cli/dist/commands/show.d.ts +19 -0
- package/cli/dist/commands/show.d.ts.map +1 -1
- package/cli/dist/commands/show.js +478 -63
- package/cli/dist/commands/show.js.map +1 -1
- package/cli/dist/commands/skill.d.ts +67 -0
- package/cli/dist/commands/skill.d.ts.map +1 -0
- package/cli/dist/commands/skill.js +513 -0
- package/cli/dist/commands/skill.js.map +1 -0
- package/cli/dist/commands/unlink.d.ts +6 -0
- package/cli/dist/commands/unlink.d.ts.map +1 -0
- package/cli/dist/commands/unlink.js +115 -0
- package/cli/dist/commands/unlink.js.map +1 -0
- package/cli/dist/commands/validate.d.ts +6 -0
- package/cli/dist/commands/validate.d.ts.map +1 -0
- package/cli/dist/commands/validate.js +159 -0
- package/cli/dist/commands/validate.js.map +1 -0
- package/cli/dist/types/gui.d.ts +62 -0
- package/cli/dist/types/gui.d.ts.map +1 -0
- package/cli/dist/types/gui.js +30 -0
- package/cli/dist/types/gui.js.map +1 -0
- package/cli/dist/utils/catalog-sync.d.ts +22 -0
- package/cli/dist/utils/catalog-sync.d.ts.map +1 -0
- package/cli/dist/utils/catalog-sync.js +157 -0
- package/cli/dist/utils/catalog-sync.js.map +1 -0
- package/cli/dist/utils/character-count.d.ts +56 -0
- package/cli/dist/utils/character-count.d.ts.map +1 -0
- package/cli/dist/utils/character-count.js +190 -0
- package/cli/dist/utils/character-count.js.map +1 -0
- package/cli/dist/utils/documentation-validator.d.ts +18 -0
- package/cli/dist/utils/documentation-validator.d.ts.map +1 -0
- package/cli/dist/utils/documentation-validator.js +233 -0
- package/cli/dist/utils/documentation-validator.js.map +1 -0
- package/cli/dist/utils/gui-helpers.d.ts +23 -0
- package/cli/dist/utils/gui-helpers.d.ts.map +1 -0
- package/cli/dist/utils/gui-helpers.js +159 -0
- package/cli/dist/utils/gui-helpers.js.map +1 -0
- package/cli/dist/utils/install-rules.d.ts +32 -0
- package/cli/dist/utils/install-rules.d.ts.map +1 -0
- package/cli/dist/utils/install-rules.js +375 -0
- package/cli/dist/utils/install-rules.js.map +1 -0
- package/cli/dist/utils/mcp-integration.d.ts +70 -0
- package/cli/dist/utils/mcp-integration.d.ts.map +1 -0
- package/cli/dist/utils/mcp-integration.js +292 -0
- package/cli/dist/utils/mcp-integration.js.map +1 -0
- package/cli/dist/utils/module-system.d.ts +232 -0
- package/cli/dist/utils/module-system.d.ts.map +1 -0
- package/cli/dist/utils/module-system.js +900 -0
- package/cli/dist/utils/module-system.js.map +1 -0
- package/cli/dist/utils/modules-catalog.d.ts +33 -0
- package/cli/dist/utils/modules-catalog.d.ts.map +1 -0
- package/cli/dist/utils/modules-catalog.js +163 -0
- package/cli/dist/utils/modules-catalog.js.map +1 -0
- package/cli/dist/utils/rule-install-hooks.d.ts +19 -0
- package/cli/dist/utils/rule-install-hooks.d.ts.map +1 -0
- package/cli/dist/utils/rule-install-hooks.js +224 -0
- package/cli/dist/utils/rule-install-hooks.js.map +1 -0
- package/cli/dist/utils/skill-system.d.ts +95 -0
- package/cli/dist/utils/skill-system.d.ts.map +1 -0
- package/cli/dist/utils/skill-system.js +313 -0
- package/cli/dist/utils/skill-system.js.map +1 -0
- package/modules.md +559 -105
- package/package.json +17 -6
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# State-Based MCP Guidelines
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
**State-based MCP** focuses on persisting conversation and task state across sessions. This enables multi-turn interactions, workflow continuity, and stateful agent behavior.
|
|
6
|
+
|
|
7
|
+
**Key Challenge**: Maintaining consistent, reliable state across distributed systems with concurrency, serialization, and persistence concerns.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. State Tracking
|
|
12
|
+
|
|
13
|
+
### State Machines
|
|
14
|
+
|
|
15
|
+
Define explicit state transitions:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from enum import Enum
|
|
19
|
+
from typing import Optional
|
|
20
|
+
|
|
21
|
+
class ConversationState(Enum):
|
|
22
|
+
INITIALIZED = "initialized"
|
|
23
|
+
GATHERING_INFO = "gathering_info"
|
|
24
|
+
PROCESSING = "processing"
|
|
25
|
+
AWAITING_CONFIRMATION = "awaiting_confirmation"
|
|
26
|
+
COMPLETED = "completed"
|
|
27
|
+
ERROR = "error"
|
|
28
|
+
|
|
29
|
+
class StateMachine:
|
|
30
|
+
def __init__(self, initial_state: ConversationState):
|
|
31
|
+
self.current_state = initial_state
|
|
32
|
+
self.transitions = {
|
|
33
|
+
ConversationState.INITIALIZED: [ConversationState.GATHERING_INFO],
|
|
34
|
+
ConversationState.GATHERING_INFO: [ConversationState.PROCESSING, ConversationState.ERROR],
|
|
35
|
+
ConversationState.PROCESSING: [ConversationState.AWAITING_CONFIRMATION, ConversationState.ERROR],
|
|
36
|
+
ConversationState.AWAITING_CONFIRMATION: [ConversationState.COMPLETED, ConversationState.GATHERING_INFO],
|
|
37
|
+
ConversationState.COMPLETED: [],
|
|
38
|
+
ConversationState.ERROR: [ConversationState.INITIALIZED]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def transition(self, new_state: ConversationState) -> bool:
|
|
42
|
+
"""Attempt state transition"""
|
|
43
|
+
if new_state in self.transitions[self.current_state]:
|
|
44
|
+
self.current_state = new_state
|
|
45
|
+
return True
|
|
46
|
+
return False
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Best Practices**:
|
|
50
|
+
- Define all valid states explicitly
|
|
51
|
+
- Document state transition rules
|
|
52
|
+
- Validate transitions before applying
|
|
53
|
+
- Log all state changes
|
|
54
|
+
|
|
55
|
+
### State Schema
|
|
56
|
+
|
|
57
|
+
Use typed schemas (Pydantic, TypedDict):
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from pydantic import BaseModel, Field, validator
|
|
61
|
+
from typing import List, Dict, Optional
|
|
62
|
+
from datetime import datetime
|
|
63
|
+
|
|
64
|
+
class Message(BaseModel):
|
|
65
|
+
role: str
|
|
66
|
+
content: str
|
|
67
|
+
timestamp: datetime
|
|
68
|
+
|
|
69
|
+
class AgentState(BaseModel):
|
|
70
|
+
schema_version: str = "1.0"
|
|
71
|
+
session_id: str
|
|
72
|
+
user_id: str
|
|
73
|
+
conversation_state: ConversationState
|
|
74
|
+
conversation_history: List[Message] = []
|
|
75
|
+
context: Dict[str, any] = {}
|
|
76
|
+
metadata: Dict[str, any] = {}
|
|
77
|
+
created_at: datetime
|
|
78
|
+
updated_at: datetime
|
|
79
|
+
etag: Optional[str] = None
|
|
80
|
+
|
|
81
|
+
class Config:
|
|
82
|
+
validate_assignment = True # Validate on mutation
|
|
83
|
+
|
|
84
|
+
@validator('conversation_history')
|
|
85
|
+
def validate_history(cls, v):
|
|
86
|
+
if len(v) > 1000:
|
|
87
|
+
raise ValueError("Conversation history too long")
|
|
88
|
+
return v
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Best Practices**:
|
|
92
|
+
- Use Pydantic for runtime validation
|
|
93
|
+
- Version schemas explicitly
|
|
94
|
+
- Validate on both load and mutation
|
|
95
|
+
- Set reasonable limits (e.g., max history length)
|
|
96
|
+
|
|
97
|
+
### State Validation
|
|
98
|
+
|
|
99
|
+
Validate state on load and mutation:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
def validate_state(state: AgentState) -> bool:
|
|
103
|
+
"""Validate state integrity"""
|
|
104
|
+
# Schema validation (handled by Pydantic)
|
|
105
|
+
|
|
106
|
+
# Business logic validation
|
|
107
|
+
if state.conversation_state == ConversationState.COMPLETED:
|
|
108
|
+
if not state.context.get('result'):
|
|
109
|
+
raise ValueError("Completed state must have result")
|
|
110
|
+
|
|
111
|
+
# Consistency checks
|
|
112
|
+
if len(state.conversation_history) > 0:
|
|
113
|
+
if state.conversation_history[-1].timestamp > state.updated_at:
|
|
114
|
+
raise ValueError("Message timestamp after state update")
|
|
115
|
+
|
|
116
|
+
return True
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### State History
|
|
120
|
+
|
|
121
|
+
Maintain audit trail of state changes:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
class StateHistory(BaseModel):
|
|
125
|
+
state_id: str
|
|
126
|
+
session_id: str
|
|
127
|
+
previous_state: Optional[ConversationState]
|
|
128
|
+
new_state: ConversationState
|
|
129
|
+
changed_fields: List[str]
|
|
130
|
+
changed_by: str
|
|
131
|
+
timestamp: datetime
|
|
132
|
+
reason: Optional[str]
|
|
133
|
+
|
|
134
|
+
def log_state_change(old_state: AgentState, new_state: AgentState, changed_by: str):
|
|
135
|
+
"""Log state change to audit trail"""
|
|
136
|
+
changed_fields = []
|
|
137
|
+
for field in new_state.__fields__:
|
|
138
|
+
if getattr(old_state, field) != getattr(new_state, field):
|
|
139
|
+
changed_fields.append(field)
|
|
140
|
+
|
|
141
|
+
history = StateHistory(
|
|
142
|
+
state_id=generate_id(),
|
|
143
|
+
session_id=new_state.session_id,
|
|
144
|
+
previous_state=old_state.conversation_state,
|
|
145
|
+
new_state=new_state.conversation_state,
|
|
146
|
+
changed_fields=changed_fields,
|
|
147
|
+
changed_by=changed_by,
|
|
148
|
+
timestamp=datetime.utcnow()
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
save_to_audit_log(history)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 2. Serialization and Persistence
|
|
157
|
+
|
|
158
|
+
### Format
|
|
159
|
+
|
|
160
|
+
Use JSON with schema version field:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
def serialize_state(state: AgentState) -> str:
|
|
164
|
+
"""Serialize state to JSON"""
|
|
165
|
+
return state.json(indent=2)
|
|
166
|
+
|
|
167
|
+
def deserialize_state(json_str: str) -> AgentState:
|
|
168
|
+
"""Deserialize state from JSON"""
|
|
169
|
+
try:
|
|
170
|
+
state = AgentState.parse_raw(json_str)
|
|
171
|
+
validate_state(state)
|
|
172
|
+
return state
|
|
173
|
+
except Exception as e:
|
|
174
|
+
logger.error(f"Failed to deserialize state: {e}")
|
|
175
|
+
raise
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Best Practices**:
|
|
179
|
+
- Always include schema version
|
|
180
|
+
- Use ISO 8601 for timestamps
|
|
181
|
+
- Serialize enums as strings
|
|
182
|
+
- Handle timezone-aware datetimes
|
|
183
|
+
|
|
184
|
+
### Compression
|
|
185
|
+
|
|
186
|
+
Apply compression for large states:
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
import gzip
|
|
190
|
+
import json
|
|
191
|
+
|
|
192
|
+
def compress_state(state: AgentState) -> bytes:
|
|
193
|
+
"""Compress state using gzip"""
|
|
194
|
+
json_str = state.json()
|
|
195
|
+
return gzip.compress(json_str.encode('utf-8'))
|
|
196
|
+
|
|
197
|
+
def decompress_state(compressed: bytes) -> AgentState:
|
|
198
|
+
"""Decompress state"""
|
|
199
|
+
json_str = gzip.decompress(compressed).decode('utf-8')
|
|
200
|
+
return AgentState.parse_raw(json_str)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**When to compress**:
|
|
204
|
+
- State > 10KB
|
|
205
|
+
- Long conversation histories
|
|
206
|
+
- Large context dictionaries
|
|
207
|
+
- Network transfer
|
|
208
|
+
|
|
209
|
+
### Encryption
|
|
210
|
+
|
|
211
|
+
Encrypt sensitive state data at rest:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from cryptography.fernet import Fernet
|
|
215
|
+
|
|
216
|
+
class EncryptedStateManager:
|
|
217
|
+
def __init__(self, encryption_key: bytes):
|
|
218
|
+
self.cipher = Fernet(encryption_key)
|
|
219
|
+
|
|
220
|
+
def encrypt_state(self, state: AgentState) -> bytes:
|
|
221
|
+
"""Encrypt state"""
|
|
222
|
+
json_str = state.json()
|
|
223
|
+
return self.cipher.encrypt(json_str.encode('utf-8'))
|
|
224
|
+
|
|
225
|
+
def decrypt_state(self, encrypted: bytes) -> AgentState:
|
|
226
|
+
"""Decrypt state"""
|
|
227
|
+
json_str = self.cipher.decrypt(encrypted).decode('utf-8')
|
|
228
|
+
return AgentState.parse_raw(json_str)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**What to encrypt**:
|
|
232
|
+
- User PII
|
|
233
|
+
- API keys/credentials
|
|
234
|
+
- Sensitive conversation content
|
|
235
|
+
- Business-critical data
|
|
236
|
+
|
|
237
|
+
### Versioning
|
|
238
|
+
|
|
239
|
+
Support schema migration across versions:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
def migrate_state(state_dict: dict) -> AgentState:
|
|
243
|
+
"""Migrate state from old schema to new"""
|
|
244
|
+
version = state_dict.get('schema_version', '0.1')
|
|
245
|
+
|
|
246
|
+
if version == '0.1':
|
|
247
|
+
# Migrate 0.1 -> 1.0
|
|
248
|
+
state_dict['schema_version'] = '1.0'
|
|
249
|
+
state_dict['metadata'] = {} # Add new field
|
|
250
|
+
# ... other migrations
|
|
251
|
+
|
|
252
|
+
return AgentState(**state_dict)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 3. Concurrency Safety
|
|
258
|
+
|
|
259
|
+
### Optimistic Locking
|
|
260
|
+
|
|
261
|
+
Use ETags or version numbers:
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
import hashlib
|
|
265
|
+
|
|
266
|
+
def generate_etag(state: AgentState) -> str:
|
|
267
|
+
"""Generate ETag for state"""
|
|
268
|
+
content = state.json()
|
|
269
|
+
return hashlib.sha256(content.encode()).hexdigest()[:16]
|
|
270
|
+
|
|
271
|
+
class StateManager:
|
|
272
|
+
def save_state(self, state: AgentState) -> bool:
|
|
273
|
+
"""Save state with optimistic locking"""
|
|
274
|
+
# Load current state
|
|
275
|
+
current = self.load_state(state.session_id)
|
|
276
|
+
|
|
277
|
+
# Check ETag
|
|
278
|
+
if current and current.etag != state.etag:
|
|
279
|
+
raise ConcurrencyError(
|
|
280
|
+
f"State was modified by another process. "
|
|
281
|
+
f"Expected ETag: {state.etag}, Actual: {current.etag}"
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
# Update ETag
|
|
285
|
+
state.etag = generate_etag(state)
|
|
286
|
+
state.updated_at = datetime.utcnow()
|
|
287
|
+
|
|
288
|
+
# Save
|
|
289
|
+
self.db.save(state.session_id, state.json())
|
|
290
|
+
return True
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Pessimistic Locking
|
|
294
|
+
|
|
295
|
+
Acquire locks for critical sections:
|
|
296
|
+
|
|
297
|
+
```python
|
|
298
|
+
import redis
|
|
299
|
+
from contextlib import contextmanager
|
|
300
|
+
|
|
301
|
+
class LockManager:
|
|
302
|
+
def __init__(self, redis_client: redis.Redis):
|
|
303
|
+
self.redis = redis_client
|
|
304
|
+
|
|
305
|
+
@contextmanager
|
|
306
|
+
def acquire_lock(self, session_id: str, timeout: int = 10):
|
|
307
|
+
"""Acquire distributed lock"""
|
|
308
|
+
lock_key = f"lock:session:{session_id}"
|
|
309
|
+
lock_acquired = False
|
|
310
|
+
|
|
311
|
+
try:
|
|
312
|
+
# Try to acquire lock
|
|
313
|
+
lock_acquired = self.redis.set(lock_key, "1", nx=True, ex=timeout)
|
|
314
|
+
if not lock_acquired:
|
|
315
|
+
raise LockError(f"Could not acquire lock for {session_id}")
|
|
316
|
+
|
|
317
|
+
yield
|
|
318
|
+
finally:
|
|
319
|
+
# Release lock
|
|
320
|
+
if lock_acquired:
|
|
321
|
+
self.redis.delete(lock_key)
|
|
322
|
+
|
|
323
|
+
# Usage
|
|
324
|
+
with lock_manager.acquire_lock(session_id):
|
|
325
|
+
state = load_state(session_id)
|
|
326
|
+
state.context['key'] = 'value'
|
|
327
|
+
save_state(state)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Conflict Resolution
|
|
331
|
+
|
|
332
|
+
Define merge strategies for conflicts:
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
def resolve_conflict(local_state: AgentState, remote_state: AgentState) -> AgentState:
|
|
336
|
+
"""Resolve state conflict"""
|
|
337
|
+
# Strategy 1: Last-write-wins
|
|
338
|
+
if remote_state.updated_at > local_state.updated_at:
|
|
339
|
+
return remote_state
|
|
340
|
+
|
|
341
|
+
# Strategy 2: Merge conversation histories
|
|
342
|
+
merged = local_state.copy()
|
|
343
|
+
merged.conversation_history = merge_histories(
|
|
344
|
+
local_state.conversation_history,
|
|
345
|
+
remote_state.conversation_history
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
# Strategy 3: Prefer remote for specific fields
|
|
349
|
+
merged.conversation_state = remote_state.conversation_state
|
|
350
|
+
|
|
351
|
+
return merged
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Idempotency
|
|
355
|
+
|
|
356
|
+
Ensure state operations are idempotent:
|
|
357
|
+
|
|
358
|
+
```python
|
|
359
|
+
def add_message_idempotent(state: AgentState, message: Message, message_id: str):
|
|
360
|
+
"""Add message idempotently"""
|
|
361
|
+
# Check if message already exists
|
|
362
|
+
existing_ids = {msg.metadata.get('id') for msg in state.conversation_history}
|
|
363
|
+
|
|
364
|
+
if message_id not in existing_ids:
|
|
365
|
+
message.metadata['id'] = message_id
|
|
366
|
+
state.conversation_history.append(message)
|
|
367
|
+
|
|
368
|
+
return state
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## 4. Integration Patterns
|
|
374
|
+
|
|
375
|
+
### LangGraph
|
|
376
|
+
|
|
377
|
+
State as graph nodes with typed edges:
|
|
378
|
+
|
|
379
|
+
```python
|
|
380
|
+
from langgraph.graph import StateGraph, END
|
|
381
|
+
|
|
382
|
+
# Define state
|
|
383
|
+
class GraphState(TypedDict):
|
|
384
|
+
messages: List[Message]
|
|
385
|
+
context: Dict[str, any]
|
|
386
|
+
next_action: str
|
|
387
|
+
|
|
388
|
+
# Create graph
|
|
389
|
+
workflow = StateGraph(GraphState)
|
|
390
|
+
|
|
391
|
+
# Add nodes
|
|
392
|
+
workflow.add_node("gather_info", gather_info_node)
|
|
393
|
+
workflow.add_node("process", process_node)
|
|
394
|
+
|
|
395
|
+
# Add edges
|
|
396
|
+
workflow.add_edge("gather_info", "process")
|
|
397
|
+
workflow.add_conditional_edges("process", should_continue, {
|
|
398
|
+
"continue": "gather_info",
|
|
399
|
+
"end": END
|
|
400
|
+
})
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### CrewAI
|
|
404
|
+
|
|
405
|
+
Agent state with task context:
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
from crewai import Agent, Task, Crew
|
|
409
|
+
|
|
410
|
+
class StatefulAgent(Agent):
|
|
411
|
+
def __init__(self, *args, **kwargs):
|
|
412
|
+
super().__init__(*args, **kwargs)
|
|
413
|
+
self.state = AgentState(
|
|
414
|
+
session_id=generate_id(),
|
|
415
|
+
user_id=kwargs.get('user_id'),
|
|
416
|
+
conversation_state=ConversationState.INITIALIZED,
|
|
417
|
+
created_at=datetime.utcnow(),
|
|
418
|
+
updated_at=datetime.utcnow()
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
def execute_task(self, task: Task):
|
|
422
|
+
# Load state
|
|
423
|
+
self.state = load_state(self.state.session_id)
|
|
424
|
+
|
|
425
|
+
# Execute task
|
|
426
|
+
result = super().execute_task(task)
|
|
427
|
+
|
|
428
|
+
# Update state
|
|
429
|
+
self.state.context['last_task'] = task.description
|
|
430
|
+
self.state.updated_at = datetime.utcnow()
|
|
431
|
+
save_state(self.state)
|
|
432
|
+
|
|
433
|
+
return result
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### AutoGen
|
|
437
|
+
|
|
438
|
+
Conversation state with message history:
|
|
439
|
+
|
|
440
|
+
```python
|
|
441
|
+
from autogen import ConversableAgent
|
|
442
|
+
|
|
443
|
+
class StatefulConversableAgent(ConversableAgent):
|
|
444
|
+
def __init__(self, *args, **kwargs):
|
|
445
|
+
super().__init__(*args, **kwargs)
|
|
446
|
+
self.session_id = kwargs.get('session_id', generate_id())
|
|
447
|
+
self.state = load_or_create_state(self.session_id)
|
|
448
|
+
|
|
449
|
+
def receive(self, message, sender):
|
|
450
|
+
# Add to state
|
|
451
|
+
self.state.conversation_history.append(Message(
|
|
452
|
+
role=sender.name,
|
|
453
|
+
content=message,
|
|
454
|
+
timestamp=datetime.utcnow()
|
|
455
|
+
))
|
|
456
|
+
save_state(self.state)
|
|
457
|
+
|
|
458
|
+
# Process message
|
|
459
|
+
return super().receive(message, sender)
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Best Practices
|
|
465
|
+
|
|
466
|
+
✅ **DO**:
|
|
467
|
+
- Always validate state schema on deserialization
|
|
468
|
+
- Log state deltas, not full snapshots (unless checkpointing)
|
|
469
|
+
- Implement graceful rollback on corruption
|
|
470
|
+
- Use Redis/Memcached for hot-path state
|
|
471
|
+
- Persist to PostgreSQL/MongoDB for durability
|
|
472
|
+
- Test state serialization round-trips
|
|
473
|
+
- Use optimistic locking for most cases
|
|
474
|
+
- Version state schemas explicitly
|
|
475
|
+
|
|
476
|
+
❌ **DON'T**:
|
|
477
|
+
- Store unencrypted PII in state
|
|
478
|
+
- Skip validation on state load
|
|
479
|
+
- Ignore concurrency conflicts
|
|
480
|
+
- Store unbounded data (e.g., unlimited history)
|
|
481
|
+
- Use pessimistic locking unless necessary
|
|
482
|
+
- Change schema without migration path
|
|
483
|
+
- Log full state on every change (use deltas)
|
|
484
|
+
|