@hivehub/rulebook 5.4.0 → 5.4.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/.claude/commands/analysis.md +35 -35
- package/.claude/commands/continue.md +33 -33
- package/.claude/commands/ralph-config.md +112 -112
- package/.claude/commands/ralph-history.md +110 -110
- package/.claude/commands/ralph-init.md +72 -72
- package/.claude/commands/ralph-pause-resume.md +105 -105
- package/.claude/commands/ralph-run.md +101 -101
- package/.claude/commands/ralph-status.md +76 -76
- package/.claude/commands/rulebook-decision-create.md +55 -55
- package/.claude/commands/rulebook-decision-list.md +15 -15
- package/.claude/commands/rulebook-knowledge-add.md +41 -41
- package/.claude/commands/rulebook-knowledge-list.md +15 -15
- package/.claude/commands/rulebook-learn-capture.md +48 -48
- package/.claude/commands/rulebook-learn-list.md +13 -13
- package/.claude/commands/rulebook-memory-save.md +48 -48
- package/.claude/commands/rulebook-memory-search.md +47 -47
- package/.claude/commands/rulebook-task-apply.md +67 -67
- package/.claude/commands/rulebook-task-archive.md +94 -94
- package/.claude/commands/rulebook-task-create.md +93 -93
- package/.claude/commands/rulebook-task-list.md +42 -42
- package/.claude/commands/rulebook-task-show.md +52 -52
- package/.claude/commands/rulebook-task-validate.md +53 -53
- package/.claude-plugin/marketplace.json +28 -28
- package/.claude-plugin/plugin.json +8 -8
- package/LICENSE +191 -191
- package/README.md +393 -393
- package/dist/index.js +0 -0
- package/dist/mcp/rulebook-server.js +0 -0
- package/package.json +22 -21
- package/templates/agents/accessibility-reviewer.md +43 -43
- package/templates/agents/api-designer.md +42 -42
- package/templates/agents/architect.md +51 -51
- package/templates/agents/build-engineer.md +36 -36
- package/templates/agents/code-reviewer.md +47 -47
- package/templates/agents/compiler/codegen-debugger.md +34 -34
- package/templates/agents/compiler/stdlib-engineer.md +28 -28
- package/templates/agents/compiler/test-coverage-guardian.md +31 -31
- package/templates/agents/context-intelligence.md +52 -52
- package/templates/agents/database-architect.md +41 -41
- package/templates/agents/devops-engineer.md +42 -42
- package/templates/agents/docs-writer.md +38 -38
- package/templates/agents/game-engine/cpp-core-expert.md +35 -35
- package/templates/agents/game-engine/render-engineer.md +22 -22
- package/templates/agents/game-engine/shader-engineer.md +38 -38
- package/templates/agents/game-engine/systems-integration.md +43 -43
- package/templates/agents/generic/code-reviewer.md +41 -41
- package/templates/agents/generic/docs-writer.md +25 -25
- package/templates/agents/generic/project-manager.md +36 -36
- package/templates/agents/generic/researcher.md +34 -34
- package/templates/agents/generic/test-engineer.md +41 -41
- package/templates/agents/i18n-engineer.md +42 -42
- package/templates/agents/implementer.md +42 -42
- package/templates/agents/migration-engineer.md +42 -42
- package/templates/agents/mobile/platform-specialist.md +22 -22
- package/templates/agents/mobile/ui-engineer.md +22 -22
- package/templates/agents/performance-engineer.md +49 -49
- package/templates/agents/refactoring-agent.md +41 -41
- package/templates/agents/researcher.md +38 -38
- package/templates/agents/security-reviewer.md +40 -40
- package/templates/agents/team-lead.md +37 -37
- package/templates/agents/tester.md +48 -48
- package/templates/agents/ux-reviewer.md +43 -43
- package/templates/agents/web-app/api-designer.md +22 -22
- package/templates/agents/web-app/backend-engineer.md +30 -30
- package/templates/agents/web-app/database-engineer.md +22 -22
- package/templates/agents/web-app/frontend-engineer.md +29 -29
- package/templates/agents/web-app/security-reviewer.md +32 -32
- package/templates/ci/rulebook-review.yml +26 -26
- package/templates/cli/AIDER.md +49 -49
- package/templates/cli/AMAZON_Q.md +25 -25
- package/templates/cli/AUGGIE.md +32 -32
- package/templates/cli/CLAUDE.md +117 -117
- package/templates/cli/CLINE.md +99 -99
- package/templates/cli/CODEBUDDY.md +20 -20
- package/templates/cli/CODEIUM.md +20 -20
- package/templates/cli/CODEX.md +21 -21
- package/templates/cli/CONTINUE.md +34 -34
- package/templates/cli/CURSOR_CLI.md +62 -62
- package/templates/cli/FACTORY.md +18 -18
- package/templates/cli/GEMINI.md +35 -35
- package/templates/cli/KILOCODE.md +18 -18
- package/templates/cli/OPENCODE.md +18 -18
- package/templates/cli/_GENERIC_TEMPLATE.md +29 -29
- package/templates/cli/gemini-extension.json +77 -77
- package/templates/commands/rulebook-decision-create.md +55 -55
- package/templates/commands/rulebook-decision-list.md +15 -15
- package/templates/commands/rulebook-knowledge-add.md +41 -41
- package/templates/commands/rulebook-knowledge-list.md +15 -15
- package/templates/commands/rulebook-learn-capture.md +48 -48
- package/templates/commands/rulebook-learn-list.md +13 -13
- package/templates/commands/rulebook-memory-save.md +48 -48
- package/templates/commands/rulebook-memory-search.md +47 -47
- package/templates/commands/rulebook-task-apply.md +67 -67
- package/templates/commands/rulebook-task-archive.md +94 -94
- package/templates/commands/rulebook-task-create.md +93 -93
- package/templates/commands/rulebook-task-list.md +42 -42
- package/templates/commands/rulebook-task-show.md +52 -52
- package/templates/commands/rulebook-task-validate.md +53 -53
- package/templates/compact-context/_default.md +23 -23
- package/templates/compact-context/cpp.md +26 -26
- package/templates/compact-context/go.md +26 -26
- package/templates/compact-context/python.md +26 -26
- package/templates/compact-context/rust.md +28 -28
- package/templates/compact-context/typescript.md +29 -29
- package/templates/core/AGENTS_OVERRIDE.md +16 -16
- package/templates/core/AGENT_AUTOMATION.md +296 -296
- package/templates/core/CLAUDE_MD_v2.md +71 -71
- package/templates/core/DAG.md +304 -304
- package/templates/core/DECISIONS.md +38 -38
- package/templates/core/DOCUMENTATION_RULES.md +36 -36
- package/templates/core/KNOWLEDGE.md +49 -49
- package/templates/core/MULTI_AGENT.md +74 -74
- package/templates/core/PLANS.md +28 -28
- package/templates/core/QUALITY_ENFORCEMENT.md +68 -68
- package/templates/core/RALPH.md +471 -471
- package/templates/core/RULEBOOK.md +1947 -1947
- package/templates/core/TIER1_PROHIBITIONS.md +154 -154
- package/templates/core/TOKEN_OPTIMIZATION.md +49 -49
- package/templates/core/WORKSPACE.md +69 -69
- package/templates/frameworks/ANGULAR.md +36 -36
- package/templates/frameworks/DJANGO.md +83 -83
- package/templates/frameworks/ELECTRON.md +147 -147
- package/templates/frameworks/FLASK.md +38 -38
- package/templates/frameworks/FLUTTER.md +55 -55
- package/templates/frameworks/JQUERY.md +32 -32
- package/templates/frameworks/LARAVEL.md +38 -38
- package/templates/frameworks/NESTJS.md +43 -43
- package/templates/frameworks/NEXTJS.md +127 -127
- package/templates/frameworks/NUXT.md +40 -40
- package/templates/frameworks/RAILS.md +66 -66
- package/templates/frameworks/REACT.md +38 -38
- package/templates/frameworks/REACT_NATIVE.md +47 -47
- package/templates/frameworks/SPRING.md +39 -39
- package/templates/frameworks/SYMFONY.md +36 -36
- package/templates/frameworks/VUE.md +36 -36
- package/templates/frameworks/ZEND.md +35 -35
- package/templates/git/CI_CD_PATTERNS.md +661 -661
- package/templates/git/GITHUB_ACTIONS.md +728 -728
- package/templates/git/GITLAB_CI.md +730 -730
- package/templates/git/GIT_WORKFLOW.md +1192 -1192
- package/templates/git/SECRETS_MANAGEMENT.md +585 -585
- package/templates/hooks/COMMIT_MSG.md +530 -530
- package/templates/hooks/POST_CHECKOUT.md +546 -546
- package/templates/hooks/PREPARE_COMMIT_MSG.md +619 -619
- package/templates/hooks/PRE_COMMIT.md +414 -414
- package/templates/hooks/PRE_PUSH.md +601 -601
- package/templates/hooks/check-context-and-handoff.ps1 +58 -58
- package/templates/hooks/check-context-and-handoff.sh +76 -76
- package/templates/hooks/enforce-team-for-background-agents.ps1 +63 -63
- package/templates/hooks/enforce-team-for-background-agents.sh +55 -55
- package/templates/hooks/on-compact-reinject.sh +34 -34
- package/templates/hooks/resume-from-handoff.ps1 +40 -40
- package/templates/hooks/resume-from-handoff.sh +61 -61
- package/templates/hooks/terse-activate.ps1 +143 -143
- package/templates/hooks/terse-activate.sh +197 -197
- package/templates/hooks/terse-mode-tracker.ps1 +153 -153
- package/templates/hooks/terse-mode-tracker.sh +187 -187
- package/templates/ides/CONTINUE_RULES.md +16 -16
- package/templates/ides/COPILOT.md +37 -37
- package/templates/ides/COPILOT_INSTRUCTIONS.md +23 -23
- package/templates/ides/CURSOR.md +43 -43
- package/templates/ides/GEMINI_RULES.md +17 -17
- package/templates/ides/JETBRAINS_AI.md +35 -35
- package/templates/ides/REPLIT.md +36 -36
- package/templates/ides/TABNINE.md +29 -29
- package/templates/ides/VSCODE.md +40 -40
- package/templates/ides/WINDSURF.md +36 -36
- package/templates/ides/WINDSURF_RULES.md +14 -14
- package/templates/ides/ZED.md +32 -32
- package/templates/ides/cursor-mdc/go.mdc +24 -24
- package/templates/ides/cursor-mdc/python.mdc +24 -24
- package/templates/ides/cursor-mdc/quality.mdc +25 -25
- package/templates/ides/cursor-mdc/ralph.mdc +39 -39
- package/templates/ides/cursor-mdc/rulebook.mdc +38 -38
- package/templates/ides/cursor-mdc/rust.mdc +24 -24
- package/templates/ides/cursor-mdc/typescript.mdc +25 -25
- package/templates/languages/C.md +333 -333
- package/templates/languages/CPP.md +743 -743
- package/templates/languages/CSHARP.md +417 -417
- package/templates/languages/ELIXIR.md +454 -454
- package/templates/languages/ERLANG.md +361 -361
- package/templates/languages/GO.md +645 -645
- package/templates/languages/HASKELL.md +177 -177
- package/templates/languages/JAVA.md +607 -607
- package/templates/languages/JAVASCRIPT.md +631 -631
- package/templates/languages/JULIA.md +97 -97
- package/templates/languages/KOTLIN.md +511 -511
- package/templates/languages/LISP.md +100 -100
- package/templates/languages/LUA.md +74 -74
- package/templates/languages/OBJECTIVEC.md +90 -90
- package/templates/languages/PHP.md +416 -416
- package/templates/languages/PYTHON.md +682 -682
- package/templates/languages/RUBY.md +421 -421
- package/templates/languages/RUST.md +477 -477
- package/templates/languages/SAS.md +73 -73
- package/templates/languages/SCALA.md +348 -348
- package/templates/languages/SOLIDITY.md +580 -580
- package/templates/languages/SQL.md +137 -137
- package/templates/languages/SWIFT.md +466 -466
- package/templates/languages/TYPESCRIPT.md +591 -591
- package/templates/languages/ZIG.md +265 -265
- package/templates/modules/ATLASSIAN.md +255 -255
- package/templates/modules/CONTEXT7.md +54 -54
- package/templates/modules/FIGMA.md +267 -267
- package/templates/modules/GITHUB_MCP.md +64 -64
- package/templates/modules/GRAFANA.md +328 -328
- package/templates/modules/MEMORY.md +126 -126
- package/templates/modules/NOTION.md +247 -247
- package/templates/modules/PLAYWRIGHT.md +90 -90
- package/templates/modules/RULEBOOK_MCP.md +208 -208
- package/templates/modules/SERENA.md +337 -337
- package/templates/modules/SUPABASE.md +223 -223
- package/templates/modules/SYNAP.md +69 -69
- package/templates/modules/VECTORIZER.md +63 -63
- package/templates/modules/sequential-thinking.md +42 -42
- package/templates/ralph/ralph-history.bat +4 -4
- package/templates/ralph/ralph-history.sh +5 -5
- package/templates/ralph/ralph-init.bat +5 -5
- package/templates/ralph/ralph-init.sh +5 -5
- package/templates/ralph/ralph-pause.bat +5 -5
- package/templates/ralph/ralph-pause.sh +5 -5
- package/templates/ralph/ralph-run.bat +5 -5
- package/templates/ralph/ralph-run.sh +5 -5
- package/templates/ralph/ralph-status.bat +4 -4
- package/templates/ralph/ralph-status.sh +5 -5
- package/templates/rules/consult-analysis-before-implementing.md +23 -23
- package/templates/rules/cpp.md +46 -46
- package/templates/rules/csharp.md +44 -44
- package/templates/rules/diagnostic-first.md +39 -39
- package/templates/rules/fail-twice-escalate.md +46 -46
- package/templates/rules/follow-task-sequence.md +36 -36
- package/templates/rules/git-safety.md +29 -29
- package/templates/rules/go.md +40 -40
- package/templates/rules/incremental-implementation.md +56 -56
- package/templates/rules/incremental-tests.md +29 -29
- package/templates/rules/java.md +43 -43
- package/templates/rules/javascript.md +39 -39
- package/templates/rules/knowledge-base-usage.md +41 -41
- package/templates/rules/multi-agent-teams.md +75 -75
- package/templates/rules/no-deferred.md +31 -31
- package/templates/rules/no-shortcuts.md +30 -30
- package/templates/rules/python.md +43 -43
- package/templates/rules/research-first.md +30 -30
- package/templates/rules/respect-handoff-trigger.md +41 -41
- package/templates/rules/rust.md +40 -40
- package/templates/rules/sequential-editing.md +21 -21
- package/templates/rules/session-workflow.md +24 -24
- package/templates/rules/task-decomposition.md +32 -32
- package/templates/rules/typescript.md +40 -40
- package/templates/services/AZURE_BLOB.md +184 -184
- package/templates/services/CASSANDRA.md +239 -239
- package/templates/services/DATADOG.md +26 -26
- package/templates/services/DOCKER.md +124 -124
- package/templates/services/DOCKER_COMPOSE.md +168 -168
- package/templates/services/DYNAMODB.md +308 -308
- package/templates/services/ELASTICSEARCH.md +347 -347
- package/templates/services/GCS.md +178 -178
- package/templates/services/HELM.md +194 -194
- package/templates/services/INFLUXDB.md +265 -265
- package/templates/services/KAFKA.md +341 -341
- package/templates/services/KUBERNETES.md +208 -208
- package/templates/services/MARIADB.md +183 -183
- package/templates/services/MEMCACHED.md +242 -242
- package/templates/services/MINIO.md +201 -201
- package/templates/services/MONGODB.md +268 -268
- package/templates/services/MYSQL.md +358 -358
- package/templates/services/NEO4J.md +247 -247
- package/templates/services/OPENTELEMETRY.md +25 -25
- package/templates/services/ORACLE.md +290 -290
- package/templates/services/PINO.md +24 -24
- package/templates/services/POSTGRESQL.md +326 -326
- package/templates/services/PROMETHEUS.md +33 -33
- package/templates/services/RABBITMQ.md +286 -286
- package/templates/services/REDIS.md +292 -292
- package/templates/services/S3.md +298 -298
- package/templates/services/SENTRY.md +23 -23
- package/templates/services/SQLITE.md +294 -294
- package/templates/services/SQLSERVER.md +294 -294
- package/templates/services/WINSTON.md +30 -30
- package/templates/skills/cli/aider/SKILL.md +59 -59
- package/templates/skills/cli/amazon-q/SKILL.md +35 -35
- package/templates/skills/cli/auggie/SKILL.md +42 -42
- package/templates/skills/cli/claude/SKILL.md +42 -42
- package/templates/skills/cli/cline/SKILL.md +42 -42
- package/templates/skills/cli/codebuddy/SKILL.md +30 -30
- package/templates/skills/cli/codeium/SKILL.md +30 -30
- package/templates/skills/cli/codex/SKILL.md +31 -31
- package/templates/skills/cli/continue/SKILL.md +44 -44
- package/templates/skills/cli/cursor-cli/SKILL.md +38 -38
- package/templates/skills/cli/factory/SKILL.md +28 -28
- package/templates/skills/cli/gemini/SKILL.md +45 -45
- package/templates/skills/cli/kilocode/SKILL.md +28 -28
- package/templates/skills/cli/opencode/SKILL.md +28 -28
- package/templates/skills/core/agent-automation/SKILL.md +194 -194
- package/templates/skills/core/dag/SKILL.md +314 -314
- package/templates/skills/core/documentation-rules/SKILL.md +46 -46
- package/templates/skills/core/quality-enforcement/SKILL.md +78 -78
- package/templates/skills/core/rulebook/SKILL.md +176 -176
- package/templates/skills/core/rulebook-terse/SKILL.md +116 -116
- package/templates/skills/core/rulebook-terse-commit/SKILL.md +96 -96
- package/templates/skills/core/rulebook-terse-review/SKILL.md +112 -112
- package/templates/skills/dev/accessibility/SKILL.md +17 -17
- package/templates/skills/dev/analysis/SKILL.md +19 -19
- package/templates/skills/dev/api-design/SKILL.md +15 -15
- package/templates/skills/dev/architect/SKILL.md +17 -17
- package/templates/skills/dev/build-fix/SKILL.md +17 -17
- package/templates/skills/dev/db-design/SKILL.md +15 -15
- package/templates/skills/dev/debug/SKILL.md +16 -16
- package/templates/skills/dev/deploy/SKILL.md +17 -17
- package/templates/skills/dev/docs/SKILL.md +17 -17
- package/templates/skills/dev/handoff/SKILL.md +27 -27
- package/templates/skills/dev/migrate/SKILL.md +15 -15
- package/templates/skills/dev/perf/SKILL.md +17 -17
- package/templates/skills/dev/refactor/SKILL.md +17 -17
- package/templates/skills/dev/research/SKILL.md +14 -14
- package/templates/skills/dev/review/SKILL.md +18 -18
- package/templates/skills/dev/security-audit/SKILL.md +17 -17
- package/templates/skills/frameworks/angular/SKILL.md +46 -46
- package/templates/skills/frameworks/django/SKILL.md +93 -93
- package/templates/skills/frameworks/electron/SKILL.md +157 -157
- package/templates/skills/frameworks/flask/SKILL.md +48 -48
- package/templates/skills/frameworks/flutter/SKILL.md +65 -65
- package/templates/skills/frameworks/jquery/SKILL.md +42 -42
- package/templates/skills/frameworks/laravel/SKILL.md +48 -48
- package/templates/skills/frameworks/nestjs/SKILL.md +53 -53
- package/templates/skills/frameworks/nextjs/SKILL.md +137 -137
- package/templates/skills/frameworks/nuxt/SKILL.md +50 -50
- package/templates/skills/frameworks/rails/SKILL.md +76 -76
- package/templates/skills/frameworks/react/SKILL.md +48 -48
- package/templates/skills/frameworks/react-native/SKILL.md +57 -57
- package/templates/skills/frameworks/spring/SKILL.md +49 -49
- package/templates/skills/frameworks/symfony/SKILL.md +46 -46
- package/templates/skills/frameworks/vue/SKILL.md +46 -46
- package/templates/skills/frameworks/zend/SKILL.md +45 -45
- package/templates/skills/ides/copilot/SKILL.md +47 -47
- package/templates/skills/ides/cursor/SKILL.md +53 -53
- package/templates/skills/ides/jetbrains-ai/SKILL.md +45 -45
- package/templates/skills/ides/replit/SKILL.md +46 -46
- package/templates/skills/ides/tabnine/SKILL.md +39 -39
- package/templates/skills/ides/vscode/SKILL.md +50 -50
- package/templates/skills/ides/windsurf/SKILL.md +46 -46
- package/templates/skills/ides/zed/SKILL.md +42 -42
- package/templates/skills/languages/c/SKILL.md +343 -343
- package/templates/skills/languages/cpp/SKILL.md +753 -753
- package/templates/skills/languages/csharp/SKILL.md +427 -427
- package/templates/skills/languages/elixir/SKILL.md +464 -464
- package/templates/skills/languages/erlang/SKILL.md +371 -371
- package/templates/skills/languages/go/SKILL.md +655 -655
- package/templates/skills/languages/haskell/SKILL.md +187 -187
- package/templates/skills/languages/java/SKILL.md +617 -617
- package/templates/skills/languages/javascript/SKILL.md +641 -641
- package/templates/skills/languages/julia/SKILL.md +107 -107
- package/templates/skills/languages/kotlin/SKILL.md +521 -521
- package/templates/skills/languages/lisp/SKILL.md +110 -110
- package/templates/skills/languages/lua/SKILL.md +84 -84
- package/templates/skills/languages/objectivec/SKILL.md +100 -100
- package/templates/skills/languages/php/SKILL.md +426 -426
- package/templates/skills/languages/python/SKILL.md +692 -692
- package/templates/skills/languages/ruby/SKILL.md +431 -431
- package/templates/skills/languages/rust/SKILL.md +487 -487
- package/templates/skills/languages/sas/SKILL.md +83 -83
- package/templates/skills/languages/scala/SKILL.md +358 -358
- package/templates/skills/languages/solidity/SKILL.md +590 -590
- package/templates/skills/languages/sql/SKILL.md +147 -147
- package/templates/skills/languages/swift/SKILL.md +476 -476
- package/templates/skills/languages/typescript/SKILL.md +302 -302
- package/templates/skills/languages/zig/SKILL.md +275 -275
- package/templates/skills/modules/atlassian/SKILL.md +265 -265
- package/templates/skills/modules/context7/SKILL.md +64 -64
- package/templates/skills/modules/figma/SKILL.md +277 -277
- package/templates/skills/modules/github-mcp/SKILL.md +74 -74
- package/templates/skills/modules/grafana/SKILL.md +338 -338
- package/templates/skills/modules/memory/SKILL.md +73 -73
- package/templates/skills/modules/notion/SKILL.md +257 -257
- package/templates/skills/modules/playwright/SKILL.md +100 -100
- package/templates/skills/modules/rulebook-mcp/SKILL.md +166 -166
- package/templates/skills/modules/serena/SKILL.md +347 -347
- package/templates/skills/modules/supabase/SKILL.md +233 -233
- package/templates/skills/modules/synap/SKILL.md +79 -79
- package/templates/skills/modules/vectorizer/SKILL.md +73 -73
- package/templates/skills/services/azure-blob/SKILL.md +194 -194
- package/templates/skills/services/cassandra/SKILL.md +249 -249
- package/templates/skills/services/dynamodb/SKILL.md +318 -318
- package/templates/skills/services/elasticsearch/SKILL.md +357 -357
- package/templates/skills/services/gcs/SKILL.md +188 -188
- package/templates/skills/services/influxdb/SKILL.md +275 -275
- package/templates/skills/services/kafka/SKILL.md +351 -351
- package/templates/skills/services/mariadb/SKILL.md +193 -193
- package/templates/skills/services/memcached/SKILL.md +252 -252
- package/templates/skills/services/minio/SKILL.md +211 -211
- package/templates/skills/services/mongodb/SKILL.md +278 -278
- package/templates/skills/services/mysql/SKILL.md +368 -368
- package/templates/skills/services/neo4j/SKILL.md +257 -257
- package/templates/skills/services/oracle/SKILL.md +300 -300
- package/templates/skills/services/postgresql/SKILL.md +336 -336
- package/templates/skills/services/rabbitmq/SKILL.md +296 -296
- package/templates/skills/services/redis/SKILL.md +302 -302
- package/templates/skills/services/s3/SKILL.md +308 -308
- package/templates/skills/services/sqlite/SKILL.md +304 -304
- package/templates/skills/services/sqlserver/SKILL.md +304 -304
- package/templates/skills/workflows/ralph/SKILL.md +309 -309
- package/templates/skills/workflows/ralph/install.sh +87 -87
- package/templates/skills/workflows/ralph/manifest.json +158 -158
- package/templates/workflows/codespell.yml +31 -31
- package/templates/workflows/cpp-lint.yml +47 -47
- package/templates/workflows/cpp-publish.yml +119 -119
- package/templates/workflows/cpp-test.yml +77 -77
- package/templates/workflows/dotnet-lint.yml +29 -29
- package/templates/workflows/dotnet-publish.yml +40 -40
- package/templates/workflows/dotnet-test.yml +41 -41
- package/templates/workflows/elixir-lint.yml +45 -45
- package/templates/workflows/elixir-publish.yml +49 -49
- package/templates/workflows/elixir-test.yml +54 -54
- package/templates/workflows/erlang-lint.yml +47 -47
- package/templates/workflows/erlang-test.yml +62 -62
- package/templates/workflows/go-lint.yml +39 -39
- package/templates/workflows/go-publish.yml +95 -95
- package/templates/workflows/go-test.yml +59 -59
- package/templates/workflows/java-lint.yml +60 -60
- package/templates/workflows/java-publish.yml +120 -120
- package/templates/workflows/java-test.yml +85 -85
- package/templates/workflows/kotlin-lint.yml +34 -34
- package/templates/workflows/kotlin-publish.yml +56 -56
- package/templates/workflows/kotlin-test.yml +48 -48
- package/templates/workflows/php-lint.yml +39 -39
- package/templates/workflows/php-publish.yml +50 -50
- package/templates/workflows/php-test.yml +54 -54
- package/templates/workflows/python-lint.yml +47 -47
- package/templates/workflows/python-publish.yml +91 -91
- package/templates/workflows/python-test.yml +59 -59
- package/templates/workflows/rust-lint.yml +54 -54
- package/templates/workflows/rust-publish.yml +66 -66
- package/templates/workflows/rust-test.yml +75 -75
- package/templates/workflows/solidity-lint.yml +41 -41
- package/templates/workflows/solidity-test.yml +47 -47
- package/templates/workflows/swift-lint.yml +32 -32
- package/templates/workflows/swift-publish.yml +58 -58
- package/templates/workflows/swift-test.yml +44 -44
- package/templates/workflows/typescript-publish.yml +60 -60
- package/templates/workflows/typescript-test.yml +73 -73
- package/templates/workflows/zig-lint.yml +27 -27
- package/templates/workflows/zig-test.yml +40 -40
- package/dist/hooks/terse-activate.d.ts +0 -59
- package/dist/hooks/terse-activate.d.ts.map +0 -1
- package/dist/hooks/terse-activate.js +0 -149
- package/dist/hooks/terse-activate.js.map +0 -1
- package/dist/hooks/terse-config.d.ts +0 -51
- package/dist/hooks/terse-config.d.ts.map +0 -1
- package/dist/hooks/terse-config.js +0 -130
- package/dist/hooks/terse-config.js.map +0 -1
- package/dist/hooks/terse-mode-tracker.d.ts +0 -78
- package/dist/hooks/terse-mode-tracker.d.ts.map +0 -1
- package/dist/hooks/terse-mode-tracker.js +0 -213
- package/dist/hooks/terse-mode-tracker.js.map +0 -1
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code SessionStart hook for rulebook-terse.
|
|
3
|
-
*
|
|
4
|
-
* Runs once per session. Responsibilities:
|
|
5
|
-
*
|
|
6
|
-
* 1. Resolve the active intensity mode (env → project config →
|
|
7
|
-
* user-global config → tier default → `brief`).
|
|
8
|
-
* 2. Write the mode to `<project>/.rulebook/.terse-mode` using
|
|
9
|
-
* `safeWriteFlag`.
|
|
10
|
-
* 3. Read the invocable `rulebook-terse` SKILL.md, filter the
|
|
11
|
-
* intensity table + examples down to only the active level's
|
|
12
|
-
* rows, and emit the filtered body to stdout.
|
|
13
|
-
*
|
|
14
|
-
* Claude Code treats SessionStart stdout as hidden `additionalContext`
|
|
15
|
-
* — the user never sees the injection in their transcript, but the
|
|
16
|
-
* model's system context now carries the compression rules.
|
|
17
|
-
*
|
|
18
|
-
* Silent-fails on every filesystem error. A broken hook must NEVER
|
|
19
|
-
* prevent session start.
|
|
20
|
-
*/
|
|
21
|
-
import { existsSync, readFileSync, unlinkSync } from 'node:fs';
|
|
22
|
-
import { join } from 'node:path';
|
|
23
|
-
import { fileURLToPath } from 'node:url';
|
|
24
|
-
import { safeWriteFlag } from './safe-flag-io.js';
|
|
25
|
-
import { getDefaultMode, getFlagPath, } from './terse-config.js';
|
|
26
|
-
/**
|
|
27
|
-
* Minimal fallback ruleset emitted when SKILL.md cannot be found on
|
|
28
|
-
* disk — e.g. a standalone installer that did not copy the templates
|
|
29
|
-
* directory. Matches the Caveman precedent (see analysis report 06).
|
|
30
|
-
*/
|
|
31
|
-
const FALLBACK_RULES = `Respond tersely. All technical substance stays. Only fluff dies.
|
|
32
|
-
|
|
33
|
-
## Persistence
|
|
34
|
-
ACTIVE EVERY RESPONSE once set. Off only via "/rulebook-terse off", "normal mode", or session end.
|
|
35
|
-
|
|
36
|
-
## Rules
|
|
37
|
-
Drop filler (just, really, basically), pleasantries, hedging. Keep technical terms exact. Code blocks byte-for-byte unchanged.
|
|
38
|
-
|
|
39
|
-
## Auto-Clarity
|
|
40
|
-
Full prose for: security warnings, destructive-op confirmations, quality-gate failures, multi-step sequences, user confusion.
|
|
41
|
-
|
|
42
|
-
## Boundaries
|
|
43
|
-
Code/tests/commits/specs: unchanged.`;
|
|
44
|
-
/**
|
|
45
|
-
* Strip YAML frontmatter from a SKILL.md body. Returns the body as-is
|
|
46
|
-
* if no frontmatter is present.
|
|
47
|
-
*/
|
|
48
|
-
export function stripFrontmatter(content) {
|
|
49
|
-
const match = content.match(/^---\s*\n[\s\S]*?\n---\s*\n([\s\S]*)$/);
|
|
50
|
-
return match ? match[1] : content;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Filter the intensity table + worked-example rows to keep only the
|
|
54
|
-
* active level's row. The SKILL.md has six intensity-level rows but
|
|
55
|
-
* the model only needs the one it will use this session; keeping all
|
|
56
|
-
* six wastes context and invites cross-level confusion.
|
|
57
|
-
*
|
|
58
|
-
* Rows start with `| **<level>** |` for the table and `- **<level>**:`
|
|
59
|
-
* for the examples. The table header + separator rows pass through
|
|
60
|
-
* unchanged because they don't match the level-row pattern.
|
|
61
|
-
*/
|
|
62
|
-
export function filterSkillForLevel(body, level) {
|
|
63
|
-
const out = [];
|
|
64
|
-
const tableRow = /^\|\s*\*\*(\S+?)\*\*\s*\|/;
|
|
65
|
-
const exampleLine = /^-\s*\*\*(\S+?)\*\*\s*:/;
|
|
66
|
-
for (const line of body.split('\n')) {
|
|
67
|
-
const tMatch = line.match(tableRow);
|
|
68
|
-
if (tMatch) {
|
|
69
|
-
if (tMatch[1] === level)
|
|
70
|
-
out.push(line);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const eMatch = line.match(exampleLine);
|
|
74
|
-
if (eMatch) {
|
|
75
|
-
if (eMatch[1] === level)
|
|
76
|
-
out.push(line);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
out.push(line);
|
|
80
|
-
}
|
|
81
|
-
return out.join('\n');
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Build the full SessionStart stdout payload.
|
|
85
|
-
*/
|
|
86
|
-
export function buildSessionStartOutput(args) {
|
|
87
|
-
const header = `RULEBOOK-TERSE MODE ACTIVE — level: ${args.mode}`;
|
|
88
|
-
if (args.skillBody === null) {
|
|
89
|
-
return `${header}\n\n${FALLBACK_RULES}`;
|
|
90
|
-
}
|
|
91
|
-
const filtered = filterSkillForLevel(args.skillBody, args.mode);
|
|
92
|
-
return `${header}\n\n${filtered}`.trimEnd() + '\n';
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Read the installed `rulebook-terse` SKILL.md. Returns the raw content
|
|
96
|
-
* on success, or null if no candidate path resolves.
|
|
97
|
-
*/
|
|
98
|
-
export function loadSkillBody(projectRoot) {
|
|
99
|
-
const candidates = [
|
|
100
|
-
join(projectRoot, '.claude', 'skills', 'rulebook-terse', 'SKILL.md'),
|
|
101
|
-
join(projectRoot, 'templates', 'skills', 'core', 'rulebook-terse', 'SKILL.md'),
|
|
102
|
-
];
|
|
103
|
-
for (const path of candidates) {
|
|
104
|
-
try {
|
|
105
|
-
if (existsSync(path)) {
|
|
106
|
-
return stripFrontmatter(readFileSync(path, 'utf8'));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
/* try next candidate */
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* CLI entry for the SessionStart hook. Always exits 0 — any failure
|
|
117
|
-
* silently falls back to a no-op so session start is never blocked.
|
|
118
|
-
*/
|
|
119
|
-
export function main(options = {}) {
|
|
120
|
-
try {
|
|
121
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
122
|
-
const env = options.env ?? process.env;
|
|
123
|
-
const stdout = options.stdout ?? process.stdout;
|
|
124
|
-
const mode = getDefaultMode({ env, projectRoot, tier: env.RULEBOOK_AGENT_TIER });
|
|
125
|
-
const flagPath = getFlagPath(projectRoot);
|
|
126
|
-
if (mode === 'off') {
|
|
127
|
-
try {
|
|
128
|
-
unlinkSync(flagPath);
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
/* flag already absent — fine */
|
|
132
|
-
}
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
safeWriteFlag(flagPath, mode);
|
|
136
|
-
const skillBody = loadSkillBody(projectRoot);
|
|
137
|
-
const output = buildSessionStartOutput({ mode, skillBody });
|
|
138
|
-
stdout.write(output);
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
/* silent fail — never block session start */
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// CLI guard — only auto-run when invoked as the entry script.
|
|
145
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
146
|
-
if (process.argv[1] === __filename) {
|
|
147
|
-
main();
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=terse-activate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terse-activate.js","sourceRoot":"","sources":["../../src/hooks/terse-activate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,E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G,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;QAEhD,MAAM,IAAI,GAAG,cAAc,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,CAAC,mBAAmB,EAAE,CAAC,CAAC;QACjF,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;QAE1C,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC;gBACH,UAAU,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,gCAAgC;YAClC,CAAC;YACD,OAAO;QACT,CAAC;QAED,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE9B,MAAM,SAAS,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,uBAAuB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC5D,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,6CAA6C;IAC/C,CAAC;AACH,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;IACnC,IAAI,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default-mode resolution for rulebook-terse.
|
|
3
|
-
*
|
|
4
|
-
* Resolution order (first match wins):
|
|
5
|
-
*
|
|
6
|
-
* 1. `RULEBOOK_TERSE_MODE` environment variable.
|
|
7
|
-
* 2. Project-local config at `<projectRoot>/.rulebook/rulebook.json`,
|
|
8
|
-
* field `terse.defaultMode`. Project config dominates user-global
|
|
9
|
-
* because a project's team standard should not be overridden by
|
|
10
|
-
* an individual contributor's personal preference.
|
|
11
|
-
* 3. User-global config at `$XDG_CONFIG_HOME/rulebook/config.json`,
|
|
12
|
-
* `~/.config/rulebook/config.json`, or `%APPDATA%/rulebook/config.json`.
|
|
13
|
-
* 4. The fallback literal `brief`.
|
|
14
|
-
*
|
|
15
|
-
* The active agent-tier can also override — see `resolveTierDefault`.
|
|
16
|
-
*
|
|
17
|
-
* Every read silent-fails on filesystem errors. A missing or corrupt
|
|
18
|
-
* config file never prevents the hook from proceeding; we fall through
|
|
19
|
-
* to the next tier.
|
|
20
|
-
*/
|
|
21
|
-
import { type TerseMode } from './safe-flag-io.js';
|
|
22
|
-
/**
|
|
23
|
-
* Compute the user-global rulebook config path in OS-appropriate order:
|
|
24
|
-
* - `$XDG_CONFIG_HOME/rulebook/config.json` if XDG_CONFIG_HOME is set.
|
|
25
|
-
* - `%APPDATA%/rulebook/config.json` on Windows.
|
|
26
|
-
* - `~/.config/rulebook/config.json` otherwise.
|
|
27
|
-
*/
|
|
28
|
-
export declare function getUserGlobalConfigPath(env?: NodeJS.ProcessEnv): string;
|
|
29
|
-
/**
|
|
30
|
-
* Read the project-local config if present.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getProjectConfigPath(projectRoot: string): string;
|
|
33
|
-
/**
|
|
34
|
-
* Translate an agent-tier name into the default intensity level, or
|
|
35
|
-
* null if the tier is unknown.
|
|
36
|
-
*/
|
|
37
|
-
export declare function resolveTierDefault(tier: string | undefined): TerseMode | null;
|
|
38
|
-
/**
|
|
39
|
-
* Resolve the default intensity mode. Options allow tests to inject
|
|
40
|
-
* env + project root deterministically.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getDefaultMode(options?: {
|
|
43
|
-
env?: NodeJS.ProcessEnv;
|
|
44
|
-
projectRoot?: string;
|
|
45
|
-
tier?: string;
|
|
46
|
-
}): TerseMode;
|
|
47
|
-
/**
|
|
48
|
-
* Path to the mode flag file (project-local).
|
|
49
|
-
*/
|
|
50
|
-
export declare function getFlagPath(projectRoot?: string): string;
|
|
51
|
-
//# sourceMappingURL=terse-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terse-config.d.ts","sourceRoot":"","sources":["../../src/hooks/terse-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAmChE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAOpF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAI7E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACV,GACL,SAAS,CAgCX;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,GAAE,MAAsB,GAAG,MAAM,CAEvE"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default-mode resolution for rulebook-terse.
|
|
3
|
-
*
|
|
4
|
-
* Resolution order (first match wins):
|
|
5
|
-
*
|
|
6
|
-
* 1. `RULEBOOK_TERSE_MODE` environment variable.
|
|
7
|
-
* 2. Project-local config at `<projectRoot>/.rulebook/rulebook.json`,
|
|
8
|
-
* field `terse.defaultMode`. Project config dominates user-global
|
|
9
|
-
* because a project's team standard should not be overridden by
|
|
10
|
-
* an individual contributor's personal preference.
|
|
11
|
-
* 3. User-global config at `$XDG_CONFIG_HOME/rulebook/config.json`,
|
|
12
|
-
* `~/.config/rulebook/config.json`, or `%APPDATA%/rulebook/config.json`.
|
|
13
|
-
* 4. The fallback literal `brief`.
|
|
14
|
-
*
|
|
15
|
-
* The active agent-tier can also override — see `resolveTierDefault`.
|
|
16
|
-
*
|
|
17
|
-
* Every read silent-fails on filesystem errors. A missing or corrupt
|
|
18
|
-
* config file never prevents the hook from proceeding; we fall through
|
|
19
|
-
* to the next tier.
|
|
20
|
-
*/
|
|
21
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
22
|
-
import { homedir, platform } from 'node:os';
|
|
23
|
-
import { join } from 'node:path';
|
|
24
|
-
import { VALID_MODES } from './safe-flag-io.js';
|
|
25
|
-
const FALLBACK_MODE = 'brief';
|
|
26
|
-
/**
|
|
27
|
-
* Tier → default-intensity map. Per
|
|
28
|
-
* `.rulebook/specs/RULEBOOK_TERSE.md` §Tier-aware defaults.
|
|
29
|
-
*/
|
|
30
|
-
const TIER_DEFAULTS = {
|
|
31
|
-
research: 'terse',
|
|
32
|
-
haiku: 'terse',
|
|
33
|
-
standard: 'brief',
|
|
34
|
-
sonnet: 'brief',
|
|
35
|
-
'team-lead': 'brief',
|
|
36
|
-
core: 'off',
|
|
37
|
-
opus: 'off',
|
|
38
|
-
};
|
|
39
|
-
function readJsonSilently(path) {
|
|
40
|
-
try {
|
|
41
|
-
if (!existsSync(path))
|
|
42
|
-
return null;
|
|
43
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function asTerseMode(v) {
|
|
50
|
-
if (typeof v !== 'string')
|
|
51
|
-
return null;
|
|
52
|
-
const lower = v.trim().toLowerCase();
|
|
53
|
-
return VALID_MODES.includes(lower)
|
|
54
|
-
? lower
|
|
55
|
-
: null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Compute the user-global rulebook config path in OS-appropriate order:
|
|
59
|
-
* - `$XDG_CONFIG_HOME/rulebook/config.json` if XDG_CONFIG_HOME is set.
|
|
60
|
-
* - `%APPDATA%/rulebook/config.json` on Windows.
|
|
61
|
-
* - `~/.config/rulebook/config.json` otherwise.
|
|
62
|
-
*/
|
|
63
|
-
export function getUserGlobalConfigPath(env = process.env) {
|
|
64
|
-
if (env.XDG_CONFIG_HOME)
|
|
65
|
-
return join(env.XDG_CONFIG_HOME, 'rulebook', 'config.json');
|
|
66
|
-
if (platform() === 'win32') {
|
|
67
|
-
const appData = env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
|
|
68
|
-
return join(appData, 'rulebook', 'config.json');
|
|
69
|
-
}
|
|
70
|
-
return join(homedir(), '.config', 'rulebook', 'config.json');
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Read the project-local config if present.
|
|
74
|
-
*/
|
|
75
|
-
export function getProjectConfigPath(projectRoot) {
|
|
76
|
-
return join(projectRoot, '.rulebook', 'rulebook.json');
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Translate an agent-tier name into the default intensity level, or
|
|
80
|
-
* null if the tier is unknown.
|
|
81
|
-
*/
|
|
82
|
-
export function resolveTierDefault(tier) {
|
|
83
|
-
if (!tier)
|
|
84
|
-
return null;
|
|
85
|
-
const key = tier.trim().toLowerCase();
|
|
86
|
-
return TIER_DEFAULTS[key] ?? null;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Resolve the default intensity mode. Options allow tests to inject
|
|
90
|
-
* env + project root deterministically.
|
|
91
|
-
*/
|
|
92
|
-
export function getDefaultMode(options = {}) {
|
|
93
|
-
const env = options.env ?? process.env;
|
|
94
|
-
const projectRoot = options.projectRoot ?? process.cwd();
|
|
95
|
-
// 1. Env var override.
|
|
96
|
-
const fromEnv = asTerseMode(env.RULEBOOK_TERSE_MODE);
|
|
97
|
-
if (fromEnv)
|
|
98
|
-
return fromEnv;
|
|
99
|
-
// 2. Project-local .rulebook/rulebook.json → terse.defaultMode.
|
|
100
|
-
const projectConfig = readJsonSilently(getProjectConfigPath(projectRoot));
|
|
101
|
-
const projectTerse = projectConfig?.['terse'];
|
|
102
|
-
if (projectTerse && typeof projectTerse === 'object') {
|
|
103
|
-
const m = asTerseMode(projectTerse.defaultMode);
|
|
104
|
-
if (m)
|
|
105
|
-
return m;
|
|
106
|
-
}
|
|
107
|
-
// 3. User-global config.
|
|
108
|
-
const userConfig = readJsonSilently(getUserGlobalConfigPath(env));
|
|
109
|
-
const userTerse = userConfig?.['terse'];
|
|
110
|
-
if (userTerse && typeof userTerse === 'object') {
|
|
111
|
-
const m = asTerseMode(userTerse.defaultMode);
|
|
112
|
-
if (m)
|
|
113
|
-
return m;
|
|
114
|
-
}
|
|
115
|
-
// 4. Agent-tier default (only if explicitly provided).
|
|
116
|
-
if (options.tier) {
|
|
117
|
-
const tierMode = resolveTierDefault(options.tier);
|
|
118
|
-
if (tierMode)
|
|
119
|
-
return tierMode;
|
|
120
|
-
}
|
|
121
|
-
// 5. Literal fallback.
|
|
122
|
-
return FALLBACK_MODE;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Path to the mode flag file (project-local).
|
|
126
|
-
*/
|
|
127
|
-
export function getFlagPath(projectRoot = process.cwd()) {
|
|
128
|
-
return join(projectRoot, '.rulebook', '.terse-mode');
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=terse-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terse-config.js","sourceRoot":"","sources":["../../src/hooks/terse-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,MAAM,aAAa,GAAc,OAAO,CAAC;AAEzC;;;GAGG;A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IACxC,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAC/C,MAAM,CAAC,GAAG,WAAW,CAAE,SAAuC,CAAC,WAAW,CAAC,CAAC;QAC5E,IAAI,CAAC;YAAE,OAAO,CAAC,CAAC;IAClB,CAAC;IAED,uDAAuD;IACvD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;IAChC,CAAC;IAED,uBAAuB;IACvB,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,cAAsB,OAAO,CAAC,GAAG,EAAE;IAC7D,OAAO,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code UserPromptSubmit hook for rulebook-terse.
|
|
3
|
-
*
|
|
4
|
-
* Runs on every user message. Three responsibilities:
|
|
5
|
-
*
|
|
6
|
-
* 1. **Mode switching.** Parses slash commands (`/rulebook-terse`,
|
|
7
|
-
* `/rulebook-terse brief|terse|ultra|off`, `/rulebook-terse-commit`,
|
|
8
|
-
* `/rulebook-terse-review`) and natural-language activation
|
|
9
|
-
* phrases ("be terse", "less tokens please", "terse mode",
|
|
10
|
-
* "activate rulebook-terse"). Writes the resolved mode to the
|
|
11
|
-
* flag file via `safeWriteFlag`.
|
|
12
|
-
*
|
|
13
|
-
* 2. **Mode deactivation.** Recognizes "normal mode", "stop terse",
|
|
14
|
-
* "disable terse", etc. Deletes the flag file.
|
|
15
|
-
*
|
|
16
|
-
* 3. **Per-turn reinforcement.** When the flag is set to a persistent
|
|
17
|
-
* mode (brief / terse / ultra), emits a short ~45 token attention
|
|
18
|
-
* anchor as `hookSpecificOutput.additionalContext` JSON. The
|
|
19
|
-
* SessionStart hook supplied the full rules once; this reminder
|
|
20
|
-
* keeps the register in the model's attention when other plugins
|
|
21
|
-
* inject competing instructions mid-conversation.
|
|
22
|
-
*
|
|
23
|
-
* Independent modes (commit / review) do not get the anchor —
|
|
24
|
-
* they have their own skill files that fully own the behavior
|
|
25
|
-
* during the single turn they're invoked.
|
|
26
|
-
*
|
|
27
|
-
* Silent-fails on every filesystem error. A broken hook must NEVER
|
|
28
|
-
* prevent a user message from reaching the model.
|
|
29
|
-
*/
|
|
30
|
-
import { type TerseMode } from './safe-flag-io.js';
|
|
31
|
-
/**
|
|
32
|
-
* Result of parsing a user prompt. `null` means no mode change is
|
|
33
|
-
* implied by the prompt.
|
|
34
|
-
*/
|
|
35
|
-
export type ParsedIntent = {
|
|
36
|
-
kind: 'set';
|
|
37
|
-
mode: TerseMode;
|
|
38
|
-
} | {
|
|
39
|
-
kind: 'off';
|
|
40
|
-
} | null;
|
|
41
|
-
/**
|
|
42
|
-
* Parse a user prompt for an intent to activate, switch, or disable
|
|
43
|
-
* rulebook-terse. Slash commands take priority over natural language;
|
|
44
|
-
* natural-language deactivation takes priority over activation when
|
|
45
|
-
* both appear in the same prompt.
|
|
46
|
-
*
|
|
47
|
-
* `defaultMode` is used for plain `/rulebook-terse` (no argument).
|
|
48
|
-
*/
|
|
49
|
-
export declare function parseIntent(prompt: string, defaultMode: TerseMode): ParsedIntent;
|
|
50
|
-
/**
|
|
51
|
-
* Build the per-turn attention-anchor JSON emitted when a persistent
|
|
52
|
-
* mode is active. Format matches Claude Code's `hookSpecificOutput`
|
|
53
|
-
* contract for UserPromptSubmit hooks.
|
|
54
|
-
*/
|
|
55
|
-
export declare function buildAttentionAnchor(mode: TerseMode): string;
|
|
56
|
-
/**
|
|
57
|
-
* Core hook logic, pure and testable. Given an input object and
|
|
58
|
-
* options, returns the string (if any) that should be emitted to
|
|
59
|
-
* stdout, and performs the flag-file side effects.
|
|
60
|
-
*/
|
|
61
|
-
export declare function runHook(input: {
|
|
62
|
-
prompt?: string;
|
|
63
|
-
cwd?: string;
|
|
64
|
-
}, options?: {
|
|
65
|
-
projectRoot?: string;
|
|
66
|
-
env?: NodeJS.ProcessEnv;
|
|
67
|
-
}): string | null;
|
|
68
|
-
/**
|
|
69
|
-
* CLI entry. Reads JSON from stdin, invokes `runHook`, emits any
|
|
70
|
-
* returned string to stdout. Always exits 0.
|
|
71
|
-
*/
|
|
72
|
-
export declare function main(options?: {
|
|
73
|
-
stdin?: NodeJS.ReadableStream;
|
|
74
|
-
stdout?: NodeJS.WriteStream;
|
|
75
|
-
projectRoot?: string;
|
|
76
|
-
env?: NodeJS.ProcessEnv;
|
|
77
|
-
}): Promise<void>;
|
|
78
|
-
//# sourceMappingURL=terse-mode-tracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terse-mode-tracker.d.ts","sourceRoot":"","sources":["../../src/hooks/terse-mode-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA+B5E;;;GAGG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf,IAAI,CAAC;AAET;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,GAAG,YAAY,CA6ChF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAa5D;AAcD;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACxC,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACpB,GACL,MAAM,GAAG,IAAI,CA6Cf;AAED;;;GAGG;AACH,wBAAsB,IAAI,CACxB,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACpB,GACL,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Claude Code UserPromptSubmit hook for rulebook-terse.
|
|
3
|
-
*
|
|
4
|
-
* Runs on every user message. Three responsibilities:
|
|
5
|
-
*
|
|
6
|
-
* 1. **Mode switching.** Parses slash commands (`/rulebook-terse`,
|
|
7
|
-
* `/rulebook-terse brief|terse|ultra|off`, `/rulebook-terse-commit`,
|
|
8
|
-
* `/rulebook-terse-review`) and natural-language activation
|
|
9
|
-
* phrases ("be terse", "less tokens please", "terse mode",
|
|
10
|
-
* "activate rulebook-terse"). Writes the resolved mode to the
|
|
11
|
-
* flag file via `safeWriteFlag`.
|
|
12
|
-
*
|
|
13
|
-
* 2. **Mode deactivation.** Recognizes "normal mode", "stop terse",
|
|
14
|
-
* "disable terse", etc. Deletes the flag file.
|
|
15
|
-
*
|
|
16
|
-
* 3. **Per-turn reinforcement.** When the flag is set to a persistent
|
|
17
|
-
* mode (brief / terse / ultra), emits a short ~45 token attention
|
|
18
|
-
* anchor as `hookSpecificOutput.additionalContext` JSON. The
|
|
19
|
-
* SessionStart hook supplied the full rules once; this reminder
|
|
20
|
-
* keeps the register in the model's attention when other plugins
|
|
21
|
-
* inject competing instructions mid-conversation.
|
|
22
|
-
*
|
|
23
|
-
* Independent modes (commit / review) do not get the anchor —
|
|
24
|
-
* they have their own skill files that fully own the behavior
|
|
25
|
-
* during the single turn they're invoked.
|
|
26
|
-
*
|
|
27
|
-
* Silent-fails on every filesystem error. A broken hook must NEVER
|
|
28
|
-
* prevent a user message from reaching the model.
|
|
29
|
-
*/
|
|
30
|
-
import { unlinkSync } from 'node:fs';
|
|
31
|
-
import { fileURLToPath } from 'node:url';
|
|
32
|
-
import { readFlag, safeWriteFlag } from './safe-flag-io.js';
|
|
33
|
-
import { getDefaultMode, getFlagPath } from './terse-config.js';
|
|
34
|
-
/**
|
|
35
|
-
* Modes whose behavior is fully handled by their own sub-skill file
|
|
36
|
-
* and do NOT get a per-turn attention anchor.
|
|
37
|
-
*/
|
|
38
|
-
const INDEPENDENT_MODES = new Set(['commit', 'review']);
|
|
39
|
-
/**
|
|
40
|
-
* Natural-language activation patterns. Matched case-insensitively.
|
|
41
|
-
* Both orderings are accepted ("activate caveman" and "caveman mode").
|
|
42
|
-
*/
|
|
43
|
-
const ACTIVATION_PATTERNS = [
|
|
44
|
-
/\b(activate|enable|turn\s+on|start)\b.*\brulebook[-\s]?terse\b/i,
|
|
45
|
-
/\brulebook[-\s]?terse\b.*\b(mode|activate|enable|turn\s+on|start)\b/i,
|
|
46
|
-
/\bbe\s+terse\b/i,
|
|
47
|
-
/\bterse\s+mode\b/i,
|
|
48
|
-
/\bless\s+tokens?\s*(please)?\b/i,
|
|
49
|
-
];
|
|
50
|
-
/**
|
|
51
|
-
* Natural-language deactivation patterns.
|
|
52
|
-
*/
|
|
53
|
-
const DEACTIVATION_PATTERNS = [
|
|
54
|
-
/\b(stop|disable|turn\s+off|deactivate)\b.*\brulebook[-\s]?terse\b/i,
|
|
55
|
-
/\brulebook[-\s]?terse\b.*\b(stop|disable|turn\s+off|deactivate)\b/i,
|
|
56
|
-
/\b(stop|disable)\s+terse\b/i,
|
|
57
|
-
/\bnormal\s+mode\b/i,
|
|
58
|
-
];
|
|
59
|
-
/**
|
|
60
|
-
* Parse a user prompt for an intent to activate, switch, or disable
|
|
61
|
-
* rulebook-terse. Slash commands take priority over natural language;
|
|
62
|
-
* natural-language deactivation takes priority over activation when
|
|
63
|
-
* both appear in the same prompt.
|
|
64
|
-
*
|
|
65
|
-
* `defaultMode` is used for plain `/rulebook-terse` (no argument).
|
|
66
|
-
*/
|
|
67
|
-
export function parseIntent(prompt, defaultMode) {
|
|
68
|
-
const trimmed = prompt.trim();
|
|
69
|
-
const lower = trimmed.toLowerCase();
|
|
70
|
-
// Slash commands — highest priority, exact surface.
|
|
71
|
-
if (lower.startsWith('/rulebook-terse')) {
|
|
72
|
-
const parts = lower.split(/\s+/);
|
|
73
|
-
const cmd = parts[0];
|
|
74
|
-
const arg = parts[1] ?? '';
|
|
75
|
-
if (cmd === '/rulebook-terse-commit') {
|
|
76
|
-
return { kind: 'set', mode: 'commit' };
|
|
77
|
-
}
|
|
78
|
-
if (cmd === '/rulebook-terse-review') {
|
|
79
|
-
return { kind: 'set', mode: 'review' };
|
|
80
|
-
}
|
|
81
|
-
if (cmd === '/rulebook-terse') {
|
|
82
|
-
switch (arg) {
|
|
83
|
-
case 'off':
|
|
84
|
-
return { kind: 'off' };
|
|
85
|
-
case 'brief':
|
|
86
|
-
case 'terse':
|
|
87
|
-
case 'ultra':
|
|
88
|
-
case 'commit':
|
|
89
|
-
case 'review':
|
|
90
|
-
return { kind: 'set', mode: arg };
|
|
91
|
-
case '':
|
|
92
|
-
return { kind: 'set', mode: defaultMode };
|
|
93
|
-
default:
|
|
94
|
-
return null; // Unknown subcommand — leave mode unchanged.
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Natural-language deactivation first — "stop terse" should win over
|
|
99
|
-
// a stray "terse" that happens to also match activation.
|
|
100
|
-
if (DEACTIVATION_PATTERNS.some((re) => re.test(trimmed))) {
|
|
101
|
-
return { kind: 'off' };
|
|
102
|
-
}
|
|
103
|
-
if (ACTIVATION_PATTERNS.some((re) => re.test(trimmed))) {
|
|
104
|
-
return { kind: 'set', mode: defaultMode };
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Build the per-turn attention-anchor JSON emitted when a persistent
|
|
110
|
-
* mode is active. Format matches Claude Code's `hookSpecificOutput`
|
|
111
|
-
* contract for UserPromptSubmit hooks.
|
|
112
|
-
*/
|
|
113
|
-
export function buildAttentionAnchor(mode) {
|
|
114
|
-
const text = `RULEBOOK-TERSE ACTIVE (${mode}). ` +
|
|
115
|
-
`Drop filler/hedging/pleasantries. ` +
|
|
116
|
-
(mode === 'brief' ? 'Keep articles and full sentences.' : 'Fragments OK.') +
|
|
117
|
-
` Code/tests/commits/security: write full. Quality-gate failures + destructive ops: write full.`;
|
|
118
|
-
return JSON.stringify({
|
|
119
|
-
hookSpecificOutput: {
|
|
120
|
-
hookEventName: 'UserPromptSubmit',
|
|
121
|
-
additionalContext: text,
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Read an entire JSON object from a readable stream. Claude Code
|
|
127
|
-
* passes hook input as `{ prompt, cwd, ... }` on stdin.
|
|
128
|
-
*/
|
|
129
|
-
async function readAllStdin(stream) {
|
|
130
|
-
const chunks = [];
|
|
131
|
-
for await (const chunk of stream) {
|
|
132
|
-
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
|
|
133
|
-
}
|
|
134
|
-
return Buffer.concat(chunks).toString('utf8');
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Core hook logic, pure and testable. Given an input object and
|
|
138
|
-
* options, returns the string (if any) that should be emitted to
|
|
139
|
-
* stdout, and performs the flag-file side effects.
|
|
140
|
-
*/
|
|
141
|
-
export function runHook(input, options = {}) {
|
|
142
|
-
try {
|
|
143
|
-
const prompt = input.prompt ?? '';
|
|
144
|
-
const projectRoot = options.projectRoot ?? input.cwd ?? process.cwd();
|
|
145
|
-
const env = options.env ?? process.env;
|
|
146
|
-
const flagPath = getFlagPath(projectRoot);
|
|
147
|
-
// Resolve default-mode fresh each turn so env changes take effect.
|
|
148
|
-
const defaultMode = getDefaultMode({ env, projectRoot, tier: env.RULEBOOK_AGENT_TIER });
|
|
149
|
-
const intent = parseIntent(prompt, defaultMode);
|
|
150
|
-
if (intent?.kind === 'off') {
|
|
151
|
-
try {
|
|
152
|
-
unlinkSync(flagPath);
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
/* flag already absent — fine */
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
if (intent?.kind === 'set') {
|
|
160
|
-
if (intent.mode === 'off') {
|
|
161
|
-
try {
|
|
162
|
-
unlinkSync(flagPath);
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
/* fine */
|
|
166
|
-
}
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
safeWriteFlag(flagPath, intent.mode);
|
|
170
|
-
}
|
|
171
|
-
// Read whatever mode is now persisted (may be set by this turn or
|
|
172
|
-
// a previous one) and emit the attention anchor for persistent
|
|
173
|
-
// modes only.
|
|
174
|
-
const currentMode = readFlag(flagPath);
|
|
175
|
-
if (currentMode && currentMode !== 'off' && !INDEPENDENT_MODES.has(currentMode)) {
|
|
176
|
-
return buildAttentionAnchor(currentMode);
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
catch {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* CLI entry. Reads JSON from stdin, invokes `runHook`, emits any
|
|
186
|
-
* returned string to stdout. Always exits 0.
|
|
187
|
-
*/
|
|
188
|
-
export async function main(options = {}) {
|
|
189
|
-
try {
|
|
190
|
-
const stdin = options.stdin ?? process.stdin;
|
|
191
|
-
const stdout = options.stdout ?? process.stdout;
|
|
192
|
-
const raw = await readAllStdin(stdin);
|
|
193
|
-
let input = {};
|
|
194
|
-
try {
|
|
195
|
-
input = JSON.parse(raw);
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
/* Non-JSON input — treat as empty. Hook still no-ops gracefully. */
|
|
199
|
-
}
|
|
200
|
-
const out = runHook(input, { projectRoot: options.projectRoot, env: options.env });
|
|
201
|
-
if (out !== null)
|
|
202
|
-
stdout.write(out);
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
/* silent fail */
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
// CLI guard — only auto-run when invoked as the entry script.
|
|
209
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
210
|
-
if (process.argv[1] === __filename) {
|
|
211
|
-
void main();
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=terse-mode-tracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terse-mode-tracker.js","sourceRoot":"","sources":["../../src/hooks/terse-mode-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;GAGG;AACH,MAAM,iBAAiB,GAA2B,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEhF;;;GAGG;AACH,MAAM,mBAAmB,GAAsB;IAC7C,iEAAiE;IACjE,sEAAsE;IACtE,iBAAiB;IACjB,mBAAmB;IACnB,iCAAiC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,qBAAqB,GAAsB;IAC/C,oEAAoE;IACpE,oEAAoE;IACpE,6BAA6B;IAC7B,oBAAoB;CACrB,CAAC;AAWF;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,WAAsB;IAChE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