tribunal-kit 6.0.1 → 7.0.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/.agent/ARCHITECTURE.md +9 -6
- package/.agent/agents/accessibility-reviewer.md +23 -16
- package/.agent/agents/ai-code-reviewer.md +25 -21
- package/.agent/agents/anti-pattern-reviewer.md +12 -7
- package/.agent/agents/api-architect.md +1 -0
- package/.agent/agents/backend-specialist.md +23 -22
- package/.agent/agents/cloud-engineer.md +1 -0
- package/.agent/agents/code-archaeologist.md +1 -0
- package/.agent/agents/complexity-reviewer.md +10 -7
- package/.agent/agents/database-architect.md +3 -2
- package/.agent/agents/db-latency-auditor.md +6 -2
- package/.agent/agents/debugger.md +3 -2
- package/.agent/agents/dependency-reviewer.md +1 -0
- package/.agent/agents/devops-engineer.md +9 -8
- package/.agent/agents/documentation-writer.md +6 -5
- package/.agent/agents/explorer-agent.md +1 -0
- package/.agent/agents/frontend-reviewer.md +21 -17
- package/.agent/agents/frontend-specialist.md +23 -20
- package/.agent/agents/game-developer.md +1 -0
- package/.agent/agents/interaction-reviewer.md +10 -5
- package/.agent/agents/logic-reviewer.md +3 -0
- package/.agent/agents/minimalist-reviewer.md +6 -0
- package/.agent/agents/mobile-developer.md +7 -6
- package/.agent/agents/mobile-reviewer.md +14 -13
- package/.agent/agents/orchestrator.md +3 -0
- package/.agent/agents/penetration-tester.md +1 -0
- package/.agent/agents/performance-optimizer.md +6 -5
- package/.agent/agents/performance-reviewer.md +6 -6
- package/.agent/agents/pipeline-reviewer.md +144 -0
- package/.agent/agents/precedence-reviewer.md +1 -0
- package/.agent/agents/product-manager.md +1 -0
- package/.agent/agents/product-owner.md +1 -0
- package/.agent/agents/product-reviewer.md +12 -7
- package/.agent/agents/project-planner.md +3 -0
- package/.agent/agents/qa-automation-engineer.md +50 -43
- package/.agent/agents/resilience-reviewer.md +1 -0
- package/.agent/agents/schema-reviewer.md +1 -0
- package/.agent/agents/security-auditor.md +24 -24
- package/.agent/agents/seo-specialist.md +33 -23
- package/.agent/agents/sql-reviewer.md +5 -4
- package/.agent/agents/supervisor-agent.md +12 -2
- package/.agent/agents/swarm-worker-contracts.md +13 -13
- package/.agent/agents/swarm-worker-registry.md +51 -51
- package/.agent/agents/system-architect.md +1 -0
- package/.agent/agents/test-coverage-reviewer.md +25 -22
- package/.agent/agents/test-engineer.md +12 -11
- package/.agent/agents/throughput-optimizer.md +45 -40
- package/.agent/agents/type-safety-reviewer.md +5 -4
- package/.agent/agents/ui-ux-auditor.md +6 -4
- package/.agent/agents/ui-visual-auditor.md +3 -0
- package/.agent/agents/ux-reviewer.md +11 -6
- package/.agent/agents/visual-reviewer.md +11 -6
- package/.agent/agents/vitals-reviewer.md +5 -4
- package/.agent/history/memory/.memory.idx +1532 -1
- package/.agent/history/memory/MEMORY.md +102 -1
- package/.agent/mcp_config.json +1 -6
- package/.agent/routing_index.json +2033 -263
- package/.agent/rules/GEMINI.md +11 -9
- package/.agent/rules/GEMINI_PLANNER.md +19 -21
- package/.agent/scripts/_colors.js +52 -54
- package/.agent/scripts/_utils.js +52 -53
- package/.agent/scripts/auto_preview.js +39 -43
- package/.agent/scripts/bundle_analyzer.js +47 -60
- package/.agent/scripts/case_law_manager.js +200 -294
- package/.agent/scripts/checklist.js +73 -94
- package/.agent/scripts/cicd_validator.js +305 -0
- package/.agent/scripts/compile_router.py +4 -111
- package/.agent/scripts/context_broker.js +317 -412
- package/.agent/scripts/contract_engine.js +402 -0
- package/.agent/scripts/dependency_analyzer.js +112 -124
- package/.agent/scripts/graph_builder.js +75 -103
- package/.agent/scripts/graph_visualizer.js +10 -12
- package/.agent/scripts/graph_zoom.js +38 -55
- package/.agent/scripts/guardrail_engine.js +195 -145
- package/.agent/scripts/impact_classifier.js +55 -30
- package/.agent/scripts/inner_loop_validator.js +108 -159
- package/.agent/scripts/integrity_manifest.js +59 -67
- package/.agent/scripts/lint_runner.js +65 -75
- package/.agent/scripts/marathon_harness.js +131 -208
- package/.agent/scripts/migrate_skills_frontmatter.py +4 -63
- package/.agent/scripts/minify_context.js +29 -33
- package/.agent/scripts/minimal_change_engine.js +95 -87
- package/.agent/scripts/mutation_runner.js +46 -62
- package/.agent/scripts/pipeline_engine.js +320 -209
- package/.agent/scripts/prompt_compiler.js +118 -93
- package/.agent/scripts/schema_validator.js +73 -121
- package/.agent/scripts/security_scan.js +88 -117
- package/.agent/scripts/session_manager.js +52 -69
- package/.agent/scripts/signal_detector.js +24 -22
- package/.agent/scripts/skill_evolution.js +184 -245
- package/.agent/scripts/skill_integrator.js +35 -48
- package/.agent/scripts/socratic_gate_policy.js +15 -12
- package/.agent/scripts/strengthen_skills.js +29 -33
- package/.agent/scripts/swarm_dispatcher.js +120 -151
- package/.agent/scripts/test_runner.js +54 -56
- package/.agent/scripts/token_budget_broker.js +9 -7
- package/.agent/scripts/trace_engine.js +126 -0
- package/.agent/scripts/verify_all.js +76 -93
- package/.agent/scripts/visual_audit.js +16 -21
- package/.agent/skill_topic_map.json +22 -3
- package/.agent/skills/12-principles-of-animation/SKILL.md +7 -0
- package/.agent/skills/60fps-animation/SKILL.md +7 -0
- package/.agent/skills/accessible-animation/SKILL.md +5 -1
- package/.agent/skills/adapt/SKILL.md +7 -1
- package/.agent/skills/advanced-rag-pipelines/SKILL.md +1 -0
- package/.agent/skills/agent-organizer/SKILL.md +1 -0
- package/.agent/skills/agentic-patterns/SKILL.md +33 -25
- package/.agent/skills/agentic-workflows-2026/SKILL.md +6 -2
- package/.agent/skills/ai-app-hardening/SKILL.md +9 -8
- package/.agent/skills/ai-prompt-injection-defense/SKILL.md +7 -6
- package/.agent/skills/animation-on-scroll/SKILL.md +24 -15
- package/.agent/skills/animation-systems/SKILL.md +11 -10
- package/.agent/skills/antfu-conventions/SKILL.md +7 -2
- package/.agent/skills/api-patterns/SKILL.md +14 -10
- package/.agent/skills/api-security-auditor/SKILL.md +15 -14
- package/.agent/skills/app-builder/SKILL.md +1 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +2 -2
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +1 -1
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +12 -12
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +3 -3
- package/.agent/skills/apple-design/SKILL.md +8 -7
- package/.agent/skills/architecture/SKILL.md +3 -2
- package/.agent/skills/audit-and-fix/SKILL.md +8 -5
- package/.agent/skills/authentication-best-practices/SKILL.md +9 -8
- package/.agent/skills/backend-security-expert/SKILL.md +1 -0
- package/.agent/skills/baseline-ui/SKILL.md +8 -7
- package/.agent/skills/bash-linux/SKILL.md +1 -0
- package/.agent/skills/behavioral-modes/SKILL.md +1 -0
- package/.agent/skills/better-colors/SKILL.md +11 -7
- package/.agent/skills/better-typography/SKILL.md +30 -16
- package/.agent/skills/better-ui/SKILL.md +17 -10
- package/.agent/skills/bolder/SKILL.md +6 -0
- package/.agent/skills/brainstorming/SKILL.md +6 -4
- package/.agent/skills/browser-native-ai/SKILL.md +5 -4
- package/.agent/skills/build-primitive/SKILL.md +5 -0
- package/.agent/skills/building-native-ui/SKILL.md +1 -0
- package/.agent/skills/cicd-pro/SKILL.md +2 -1
- package/.agent/skills/clarify/SKILL.md +19 -14
- package/.agent/skills/clean-code/SKILL.md +16 -15
- package/.agent/skills/cloud-architect/SKILL.md +1 -0
- package/.agent/skills/cobejs/SKILL.md +7 -9
- package/.agent/skills/code-review-checklist/SKILL.md +1 -0
- package/.agent/skills/codebase-design/SKILL.md +7 -2
- package/.agent/skills/colorize/SKILL.md +8 -3
- package/.agent/skills/compact-landing/SKILL.md +8 -3
- package/.agent/skills/company-logos/SKILL.md +6 -0
- package/.agent/skills/config-validator/SKILL.md +10 -9
- package/.agent/skills/containerization-pro/SKILL.md +6 -5
- package/.agent/skills/context-engineering-pro/SKILL.md +5 -4
- package/.agent/skills/create-design-md/SKILL.md +13 -5
- package/.agent/skills/critique/SKILL.md +10 -8
- package/.agent/skills/csharp-developer/SKILL.md +1 -0
- package/.agent/skills/data-validation-schemas/SKILL.md +28 -23
- package/.agent/skills/database-design/SKILL.md +2 -1
- package/.agent/skills/delight/SKILL.md +6 -0
- package/.agent/skills/deployment-procedures/SKILL.md +2 -1
- package/.agent/skills/design-lab/SKILL.md +5 -0
- package/.agent/skills/devops-engineer/SKILL.md +3 -2
- package/.agent/skills/devops-incident-responder/SKILL.md +2 -1
- package/.agent/skills/diagnosing-bugs/SKILL.md +12 -2
- package/.agent/skills/distill/SKILL.md +7 -2
- package/.agent/skills/documentation-templates/SKILL.md +3 -2
- package/.agent/skills/domain-modeling/SKILL.md +12 -4
- package/.agent/skills/duckdb-analytical-sql/SKILL.md +7 -3
- package/.agent/skills/edge-ai-mobile/SKILL.md +5 -1
- package/.agent/skills/edge-computing/SKILL.md +9 -8
- package/.agent/skills/emil-design-eng/SKILL.md +43 -27
- package/.agent/skills/error-resilience/SKILL.md +34 -16
- package/.agent/skills/expo-router-v4/SKILL.md +2 -1
- package/.agent/skills/extract-design-system/SKILL.md +12 -11
- package/.agent/skills/fabel-protocol/SKILL.md +24 -17
- package/.agent/skills/fixing-accessibility/SKILL.md +23 -16
- package/.agent/skills/fixing-metadata/SKILL.md +24 -13
- package/.agent/skills/fixing-motion-performance/SKILL.md +7 -5
- package/.agent/skills/framer-motion-expert/SKILL.md +29 -15
- package/.agent/skills/frontend-design/SKILL.md +21 -13
- package/.agent/skills/frontend-security-expert/SKILL.md +1 -0
- package/.agent/skills/game-design-expert/SKILL.md +1 -0
- package/.agent/skills/game-engineering-expert/SKILL.md +1 -0
- package/.agent/skills/generative-ui-expert/SKILL.md +3 -2
- package/.agent/skills/geo-fundamentals/SKILL.md +2 -1
- package/.agent/skills/git-pro/SKILL.md +10 -9
- package/.agent/skills/github-operations/SKILL.md +2 -1
- package/.agent/skills/gpt-taste/SKILL.md +7 -0
- package/.agent/skills/gsap-core/SKILL.md +26 -22
- package/.agent/skills/gsap-frameworks/SKILL.md +6 -5
- package/.agent/skills/gsap-performance/SKILL.md +4 -3
- package/.agent/skills/gsap-plugins/SKILL.md +34 -33
- package/.agent/skills/gsap-react/SKILL.md +9 -8
- package/.agent/skills/gsap-scrolltrigger/SKILL.md +34 -33
- package/.agent/skills/gsap-timeline/SKILL.md +18 -15
- package/.agent/skills/gsap-utils/SKILL.md +25 -24
- package/.agent/skills/harden/SKILL.md +9 -3
- package/.agent/skills/harness-protocol/SKILL.md +1 -0
- package/.agent/skills/i18n-localization/SKILL.md +10 -9
- package/.agent/skills/impeccable/SKILL.md +5 -0
- package/.agent/skills/improve-codebase-architecture/SKILL.md +10 -5
- package/.agent/skills/improve-ui/SKILL.md +12 -5
- package/.agent/skills/intelligent-routing/SKILL.md +7 -6
- package/.agent/skills/knowledge-graph/SKILL.md +1 -0
- package/.agent/skills/landing-page/SKILL.md +1 -0
- package/.agent/skills/lint-and-validate/SKILL.md +9 -4
- package/.agent/skills/llm-engineering/SKILL.md +55 -54
- package/.agent/skills/local-first/SKILL.md +20 -19
- package/.agent/skills/local-first-architecture/SKILL.md +6 -1
- package/.agent/skills/lottie-animation/SKILL.md +7 -3
- package/.agent/skills/marquee-loop/SKILL.md +1 -0
- package/.agent/skills/masked-reveal/SKILL.md +17 -4
- package/.agent/skills/mcp-builder/SKILL.md +13 -10
- package/.agent/skills/micro-interaction/SKILL.md +20 -5
- package/.agent/skills/mobile-design/SKILL.md +26 -15
- package/.agent/skills/monorepo-management/SKILL.md +3 -2
- package/.agent/skills/morphing-icons/SKILL.md +16 -6
- package/.agent/skills/motion-engineering/SKILL.md +19 -15
- package/.agent/skills/nextjs-react-expert/SKILL.md +26 -21
- package/.agent/skills/nodejs-best-practices/SKILL.md +89 -76
- package/.agent/skills/observability/SKILL.md +45 -44
- package/.agent/skills/opentelemetry-observability/SKILL.md +2 -1
- package/.agent/skills/page-transition-animation/SKILL.md +6 -3
- package/.agent/skills/parallel-agents/SKILL.md +7 -2
- package/.agent/skills/performance-profiling/SKILL.md +24 -13
- package/.agent/skills/plan-writing/SKILL.md +1 -0
- package/.agent/skills/platform-engineer/SKILL.md +3 -2
- package/.agent/skills/platform-engineering-opentofu/SKILL.md +1 -0
- package/.agent/skills/playwright-ai-e2e/SKILL.md +3 -2
- package/.agent/skills/playwright-best-practices/SKILL.md +29 -28
- package/.agent/skills/polish/SKILL.md +13 -12
- package/.agent/skills/powershell-windows/SKILL.md +1 -0
- package/.agent/skills/pricing-page/SKILL.md +8 -3
- package/.agent/skills/product-aware-heuristics/SKILL.md +122 -72
- package/.agent/skills/progressive-blur/SKILL.md +9 -4
- package/.agent/skills/project-idioms/SKILL.md +1 -0
- package/.agent/skills/property-based-testing/SKILL.md +10 -12
- package/.agent/skills/python-patterns/SKILL.md +1 -0
- package/.agent/skills/python-pro/SKILL.md +1 -0
- package/.agent/skills/quieter/SKILL.md +6 -0
- package/.agent/skills/react-doctor/SKILL.md +6 -0
- package/.agent/skills/react-specialist/SKILL.md +32 -28
- package/.agent/skills/readme-builder/SKILL.md +1 -0
- package/.agent/skills/realtime-patterns/SKILL.md +34 -33
- package/.agent/skills/red-team-tactics/SKILL.md +1 -0
- package/.agent/skills/redesign-skill/SKILL.md +6 -0
- package/.agent/skills/review-animations/SKILL.md +5 -2
- package/.agent/skills/review-animations/STANDARDS.md +37 -23
- package/.agent/skills/rust-pro/SKILL.md +1 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +4 -3
- package/.agent/skills/server-management/SKILL.md +1 -0
- package/.agent/skills/shadcn-ui-expert/SKILL.md +28 -22
- package/.agent/skills/shape/SKILL.md +9 -2
- package/.agent/skills/skill-creator/SKILL.md +1 -0
- package/.agent/skills/soft-skill/SKILL.md +6 -0
- package/.agent/skills/sounds-on-the-web/SKILL.md +1 -0
- package/.agent/skills/sql-pro/SKILL.md +1 -0
- package/.agent/skills/supabase-postgres-best-practices/SKILL.md +1 -0
- package/.agent/skills/svg-animation/SKILL.md +16 -7
- package/.agent/skills/swiftui-expert/SKILL.md +1 -0
- package/.agent/skills/swiss-design/SKILL.md +5 -0
- package/.agent/skills/system-design-pro/SKILL.md +1 -0
- package/.agent/skills/systematic-debugging/SKILL.md +1 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +25 -11
- package/.agent/skills/taste-skill/SKILL.md +6 -0
- package/.agent/skills/tdd-workflow/SKILL.md +5 -0
- package/.agent/skills/test-result-analyzer/SKILL.md +1 -0
- package/.agent/skills/testing-patterns/SKILL.md +123 -115
- package/.agent/skills/thermo-nuclear-code-quality-review/SKILL.md +5 -0
- package/.agent/skills/thinking-protocol/SKILL.md +3 -0
- package/.agent/skills/to-spring-or-not-to-spring/SKILL.md +9 -8
- package/.agent/skills/transitions-dev/SKILL.md +19 -6
- package/.agent/skills/trend-researcher/SKILL.md +1 -0
- package/.agent/skills/typescript-advanced/SKILL.md +23 -18
- package/.agent/skills/typeset/SKILL.md +10 -1
- package/.agent/skills/ui-reasoning-engine/SKILL.md +67 -48
- package/.agent/skills/ui-skill-packs/SKILL.md +6 -1
- package/.agent/skills/ui-skills-root/SKILL.md +39 -38
- package/.agent/skills/ui-ux-pro-max/SKILL.md +34 -26
- package/.agent/skills/ui-ux-researcher/SKILL.md +1 -0
- package/.agent/skills/vector-search-pgvector/SKILL.md +3 -2
- package/.agent/skills/vue-expert/SKILL.md +22 -19
- package/.agent/skills/vulnerability-scanner/SKILL.md +22 -21
- package/.agent/skills/web-accessibility-auditor/SKILL.md +2 -1
- package/.agent/skills/web-design-guidelines/SKILL.md +16 -10
- package/.agent/skills/web-quality-audit/SKILL.md +5 -0
- package/.agent/skills/webapp-testing/SKILL.md +14 -13
- package/.agent/skills/webgpu-performance/SKILL.md +1 -0
- package/.agent/skills/whimsy-injector/SKILL.md +9 -5
- package/.agent/skills/workflow-optimizer/SKILL.md +1 -0
- package/.agent/skills/zero-trust-passkeys/SKILL.md +11 -6
- package/.agent/templates/DESIGN.md +119 -110
- package/.agent/templates/design-tokens.json +9 -6
- package/.agent/workflows/acf.md +1 -0
- package/.agent/workflows/api-tester.md +1 -0
- package/.agent/workflows/audit.md +1 -0
- package/.agent/workflows/brainstorm.md +1 -0
- package/.agent/workflows/changelog.md +1 -0
- package/.agent/workflows/contract.md +60 -0
- package/.agent/workflows/create.md +1 -0
- package/.agent/workflows/debug.md +1 -0
- package/.agent/workflows/deploy.md +1 -0
- package/.agent/workflows/enhance.md +1 -0
- package/.agent/workflows/fix-ci.md +89 -0
- package/.agent/workflows/fix.md +1 -0
- package/.agent/workflows/generate.md +1 -0
- package/.agent/workflows/marathon.md +1 -0
- package/.agent/workflows/migrate.md +1 -0
- package/.agent/workflows/minimal.md +9 -7
- package/.agent/workflows/orchestrate.md +1 -0
- package/.agent/workflows/performance-benchmarker.md +1 -0
- package/.agent/workflows/pipeline.md +26 -21
- package/.agent/workflows/plan.md +1 -0
- package/.agent/workflows/preview.md +1 -0
- package/.agent/workflows/refactor.md +3 -2
- package/.agent/workflows/review-ai.md +4 -3
- package/.agent/workflows/review.md +1 -0
- package/.agent/workflows/session.md +1 -0
- package/.agent/workflows/status.md +1 -0
- package/.agent/workflows/strengthen-skills.md +1 -0
- package/.agent/workflows/super-prompt.md +1 -0
- package/.agent/workflows/swarm.md +15 -3
- package/.agent/workflows/test.md +8 -7
- package/.agent/workflows/tribunal-backend.md +3 -2
- package/.agent/workflows/tribunal-cicd.md +104 -0
- package/.agent/workflows/tribunal-database.md +1 -0
- package/.agent/workflows/tribunal-frontend.md +8 -6
- package/.agent/workflows/tribunal-full.md +2 -1
- package/.agent/workflows/tribunal-mobile.md +6 -5
- package/.agent/workflows/tribunal-performance.md +1 -0
- package/.agent/workflows/tribunal-speed.md +1 -0
- package/.agent/workflows/tribunal-ui.md +29 -21
- package/.agent/workflows/ui-ux-pro-max.md +19 -15
- package/CONTRIBUTING.md +3 -3
- package/README.md +94 -44
- package/SECURITY.md +10 -10
- package/bin/mcp-server.js +385 -252
- package/bin/tribunal-kit.js +29 -30
- package/bin/wrapper.js +40 -46
- package/dist/cli.js +6 -0
- package/dist/commands/case.js +2 -0
- package/dist/commands/contract.js +440 -0
- package/dist/commands/status.js +6 -0
- package/dist/index.d.ts +8 -1
- package/package.json +13 -12
- package/scripts/benchmark.js +62 -86
- package/scripts/changelog.js +67 -73
- package/scripts/fix-vbc.js +13 -15
- package/scripts/fix-vbc.ps1 +2 -118
- package/scripts/stress_benchmark.js +358 -0
- package/scripts/sync-version.js +71 -41
- package/scripts/validate-payload.js +23 -30
- package/scripts/visual_audit.js +23 -13
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before designing schemas or parsing untrusted data boundaries, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Universal Trust Boundary Rule (Section 25) → Enforce explicit Zod/Pydantic schemas on API bodies, query params, env vars, and webhooks
|
|
24
25
|
2. Server-Side Mandatory Validation (Section 16) → Never rely solely on client-side UX validation; execute schema validation on the server
|
|
25
26
|
3. Environment Startup Parse (Section 173) → Parse `process.env` with Zod at app startup to crash immediately on missing keys
|
|
@@ -60,7 +61,7 @@ Trust Boundaries:
|
|
|
60
61
|
### Basic Schemas
|
|
61
62
|
|
|
62
63
|
```typescript
|
|
63
|
-
import { z } from
|
|
64
|
+
import { z } from 'zod';
|
|
64
65
|
|
|
65
66
|
// Primitives with constraints
|
|
66
67
|
const Email = z.string().email().toLowerCase().trim();
|
|
@@ -70,14 +71,14 @@ const Username = z
|
|
|
70
71
|
.min(3)
|
|
71
72
|
.max(30)
|
|
72
73
|
.regex(/^[a-zA-Z0-9_]+$/);
|
|
73
|
-
const URL = z.string().url().startsWith(
|
|
74
|
+
const URL = z.string().url().startsWith('https://');
|
|
74
75
|
|
|
75
76
|
// Object schema
|
|
76
77
|
const CreateUserSchema = z.object({
|
|
77
78
|
name: z.string().min(2).max(100),
|
|
78
79
|
email: Email,
|
|
79
80
|
age: Age.optional(),
|
|
80
|
-
role: z.enum([
|
|
81
|
+
role: z.enum(['admin', 'editor', 'viewer']).default('viewer'),
|
|
81
82
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
82
83
|
});
|
|
83
84
|
|
|
@@ -98,9 +99,9 @@ const BaseUserSchema = z.object({
|
|
|
98
99
|
const CreateUserSchema = BaseUserSchema.extend({
|
|
99
100
|
password: z.string().min(8),
|
|
100
101
|
confirmPassword: z.string(),
|
|
101
|
-
}).refine(
|
|
102
|
+
}).refine(data => data.password === data.confirmPassword, {
|
|
102
103
|
message: "Passwords don't match",
|
|
103
|
-
path: [
|
|
104
|
+
path: ['confirmPassword'],
|
|
104
105
|
});
|
|
105
106
|
|
|
106
107
|
const UpdateUserSchema = BaseUserSchema.partial(); // all fields optional
|
|
@@ -118,14 +119,14 @@ const FullProfileSchema = BaseUserSchema.merge(AddressSchema);
|
|
|
118
119
|
|
|
119
120
|
```typescript
|
|
120
121
|
// ✅ Server-side: validate at the boundary, type-safe downstream
|
|
121
|
-
import { z } from
|
|
122
|
+
import { z } from 'zod';
|
|
122
123
|
|
|
123
124
|
// Define once, use everywhere
|
|
124
125
|
const QuerySchema = z.object({
|
|
125
126
|
page: z.coerce.number().int().min(1).default(1),
|
|
126
127
|
limit: z.coerce.number().int().min(1).max(100).default(20),
|
|
127
|
-
sort: z.enum([
|
|
128
|
-
order: z.enum([
|
|
128
|
+
sort: z.enum(['created', 'updated', 'name']).default('created'),
|
|
129
|
+
order: z.enum(['asc', 'desc']).default('desc'),
|
|
129
130
|
search: z.string().max(200).optional(),
|
|
130
131
|
});
|
|
131
132
|
|
|
@@ -135,7 +136,7 @@ function validate<T extends z.ZodType>(schema: T) {
|
|
|
135
136
|
const result = schema.safeParse(req.body);
|
|
136
137
|
if (!result.success) {
|
|
137
138
|
return res.status(400).json({
|
|
138
|
-
error:
|
|
139
|
+
error: 'Validation failed',
|
|
139
140
|
issues: result.error.flatten().fieldErrors,
|
|
140
141
|
});
|
|
141
142
|
}
|
|
@@ -144,7 +145,7 @@ function validate<T extends z.ZodType>(schema: T) {
|
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
|
|
147
|
-
app.post(
|
|
148
|
+
app.post('/api/users', validate(CreateUserSchema), async (req, res) => {
|
|
148
149
|
// req.body is now fully typed and validated
|
|
149
150
|
const user = await createUser(req.body);
|
|
150
151
|
res.status(201).json(user);
|
|
@@ -186,13 +187,13 @@ if (!result.success) {
|
|
|
186
187
|
```typescript
|
|
187
188
|
// ✅ Validate ALL env vars at startup — crash immediately if invalid
|
|
188
189
|
const EnvSchema = z.object({
|
|
189
|
-
NODE_ENV: z.enum([
|
|
190
|
+
NODE_ENV: z.enum(['development', 'production', 'test']),
|
|
190
191
|
PORT: z.coerce.number().default(3000),
|
|
191
192
|
DATABASE_URL: z.string().url(),
|
|
192
193
|
REDIS_URL: z.string().url().optional(),
|
|
193
|
-
JWT_SECRET: z.string().min(32,
|
|
194
|
+
JWT_SECRET: z.string().min(32, 'JWT_SECRET must be ≥ 32 characters'),
|
|
194
195
|
API_KEY: z.string().min(1),
|
|
195
|
-
LOG_LEVEL: z.enum([
|
|
196
|
+
LOG_LEVEL: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
|
|
196
197
|
});
|
|
197
198
|
|
|
198
199
|
export const env = EnvSchema.parse(process.env);
|
|
@@ -241,15 +242,19 @@ async def create_user(user: CreateUserRequest):
|
|
|
241
242
|
|
|
242
243
|
```tsx
|
|
243
244
|
// ✅ React Hook Form + Zod = type-safe forms
|
|
244
|
-
import { useForm } from
|
|
245
|
-
import { zodResolver } from
|
|
246
|
-
import { z } from
|
|
245
|
+
import { useForm } from 'react-hook-form';
|
|
246
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
247
|
+
import { z } from 'zod';
|
|
247
248
|
|
|
248
249
|
const SignupSchema = z.object({
|
|
249
|
-
email: z.string().email(
|
|
250
|
-
password: z
|
|
250
|
+
email: z.string().email('Invalid email address'),
|
|
251
|
+
password: z
|
|
252
|
+
.string()
|
|
253
|
+
.min(8, 'Password must be at least 8 characters')
|
|
254
|
+
.regex(/[A-Z]/, 'Must contain uppercase letter')
|
|
255
|
+
.regex(/[0-9]/, 'Must contain a number'),
|
|
251
256
|
terms: z.literal(true, {
|
|
252
|
-
errorMap: () => ({ message:
|
|
257
|
+
errorMap: () => ({ message: 'You must accept the terms' }),
|
|
253
258
|
}),
|
|
254
259
|
});
|
|
255
260
|
|
|
@@ -265,15 +270,15 @@ function SignupForm() {
|
|
|
265
270
|
});
|
|
266
271
|
|
|
267
272
|
return (
|
|
268
|
-
<form onSubmit={handleSubmit(
|
|
269
|
-
<input {...register(
|
|
273
|
+
<form onSubmit={handleSubmit(data => signup(data))}>
|
|
274
|
+
<input {...register('email')} />
|
|
270
275
|
{errors.email && <span>{errors.email.message}</span>}
|
|
271
276
|
|
|
272
|
-
<input type="password" {...register(
|
|
277
|
+
<input type="password" {...register('password')} />
|
|
273
278
|
{errors.password && <span>{errors.password.message}</span>}
|
|
274
279
|
|
|
275
280
|
<label>
|
|
276
|
-
<input type="checkbox" {...register(
|
|
281
|
+
<input type="checkbox" {...register('terms')} />I accept the terms
|
|
277
282
|
</label>
|
|
278
283
|
{errors.terms && <span>{errors.terms.message}</span>}
|
|
279
284
|
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before designing schemas or writing SQL migrations, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Timezone Timestamp Standard (Section 17) → Use `TIMESTAMPTZ` for all timestamp columns; ban bare `TIMESTAMP`
|
|
24
25
|
2. Primary Key Index Performance (Section 18) → Use `BIGINT GENERATED ALWAYS AS IDENTITY` or UUID v7 (time-ordered); ban random UUID v4 as primary key
|
|
25
26
|
3. Foreign Key Indexing (Section 19) → Create explicit indexes on all foreign key columns (`CREATE INDEX idx_... ON table(fk_id)`) to prevent full table scans during cascading deletes
|
|
@@ -137,7 +138,7 @@ CREATE POLICY tenant_isolation ON projects
|
|
|
137
138
|
const result = await db
|
|
138
139
|
.select({ id: users.id, name: users.name })
|
|
139
140
|
.from(users)
|
|
140
|
-
.where(and(eq(users.role,
|
|
141
|
+
.where(and(eq(users.role, 'admin'), eq(users.isActive, true)))
|
|
141
142
|
.orderBy(desc(users.createdAt))
|
|
142
143
|
.limit(20);
|
|
143
144
|
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before implementing micro-delight moments, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Action frequency context → Keep high-frequency delight (performed 50+ times/day) under 100ms and non-intrusive
|
|
24
25
|
2. `prefers-reduced-motion` CSS media query → Provide fallback states for particle bursts and spring animations
|
|
25
26
|
3. Morphing State Checkmark rules (Section 24) → Hold confirmation icon for 1.5s before smoothly morphing back
|
|
@@ -31,18 +32,23 @@ Elevate everyday digital interactions with subtle, memorable details that make s
|
|
|
31
32
|
## 5 Micro-Delight Patterns
|
|
32
33
|
|
|
33
34
|
### 1. The Morphing State Checkmark
|
|
35
|
+
|
|
34
36
|
- When clicking "Copy Link" or "Save", morph the button icon or label smoothly into a checkmark icon with a quick spring bounce (`scale(1.15) -> scale(1)` over `180ms`), holding for 1.5 seconds before morphing back.
|
|
35
37
|
|
|
36
38
|
### 2. Micro-Confetti & Particle Bursts
|
|
39
|
+
|
|
37
40
|
- On completing a key milestone (e.g. completing onboarding, submitting a project), trigger a lightweight 12-particle CSS/canvas burst anchored directly to the submit button.
|
|
38
41
|
|
|
39
42
|
### 3. Tactile Drag & Reorder Haptics
|
|
43
|
+
|
|
40
44
|
- When dragging list items, elevate the item with a slight tilt ($2^\circ$), drop shadow increase, and scale (`scale(1.02)`), giving a physical card feeling.
|
|
41
45
|
|
|
42
46
|
### 4. Playful Empty State Animations
|
|
47
|
+
|
|
43
48
|
- Transform boring zero-data states with subtle floating illustrations, witty microcopy, and a prominent primary action button.
|
|
44
49
|
|
|
45
50
|
### 5. Keyboard Shortcut Badges with Tooltips
|
|
51
|
+
|
|
46
52
|
- Display subtle keyboard shortcut hints (e.g. `⌘K` or `Ctrl+K`) inside inputs or hover tooltips that respond with a subtle keypress press animation when pressed.
|
|
47
53
|
|
|
48
54
|
---
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before deploying application releases or database migrations, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Expand-and-Contract DB Migrations (Section 104) → Migrate schema FIRST (expand/copy data), then deploy code SECOND, contract legacy columns THIRD
|
|
24
25
|
2. Instant Rollback Contingency (Section 116) → Tag every Docker image with Git SHA (`myapp:a1b2c3d`) for split-second image swaps during failure
|
|
25
26
|
3. Zero-Downtime Traffic Switching (Section 29) → Use Blue/Green or Rolling updates with active health check verification before draining old instances
|
|
@@ -71,7 +72,7 @@ name: Production Deploy
|
|
|
71
72
|
|
|
72
73
|
on:
|
|
73
74
|
push:
|
|
74
|
-
branches: [
|
|
75
|
+
branches: ['main']
|
|
75
76
|
|
|
76
77
|
# Concurrency limits prevent race conditions if two commits are pushed rapidly
|
|
77
78
|
concurrency:
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before generating design variants or conducting design experiments, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Structural Variant Difference Rule (Section 39) → Ensure generated layout variants are structurally distinct; ban micro-variations (differing only by 1px or hex color)
|
|
24
25
|
2. Interactive Refinement Protocol (Section 32) → Ask targeted constraint questions before outputting final component implementations
|
|
25
26
|
3. Visual Hierarchy Mapping (Section 26) → Map visual hierarchy explicitly to project design tokens before presenting options
|
|
@@ -33,14 +34,18 @@ Conduct rapid design experiments, explore multiple structural variants, and iter
|
|
|
33
34
|
## 3 Design Lab Phases
|
|
34
35
|
|
|
35
36
|
### Phase 1: Context & Constraint Gathering
|
|
37
|
+
|
|
36
38
|
Ask 2 targeted questions to map out design direction:
|
|
39
|
+
|
|
37
40
|
1. What aesthetic tone fits best? (e.g. Minimalist Editorial vs High-Impact Brutalist vs Clean Corporate SaaS)
|
|
38
41
|
2. What component variants would you like to explore? (e.g. Card layout options A vs B)
|
|
39
42
|
|
|
40
43
|
### Phase 2: Generating Distinct Structural Variants
|
|
44
|
+
|
|
41
45
|
Generate 2 distinct visual variants (e.g. Option A: Centered Minimalist vs Option B: Asymmetrical Card Grid).
|
|
42
46
|
|
|
43
47
|
### Phase 3: Interactive Refinement
|
|
48
|
+
|
|
44
49
|
Synthesize feedback on preferred elements and build the polished final component.
|
|
45
50
|
|
|
46
51
|
---
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before building Dockerfiles, Docker Compose, or GitHub Actions pipelines, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Non-Root Docker Container Rule (Section 47) → Explicitly specify a non-root user (`USER appuser`) in production Dockerfiles
|
|
24
25
|
2. Deterministic Package Installation (Section 28) → Use `npm ci` (or yarn/pnpm equivalent with lockfiles) in Docker and CI; ban `npm install`
|
|
25
26
|
3. CI/CD Concurrency Group Cancellation (Section 142) → Configure `concurrency.cancel-in-progress: true` on PR workflows to cancel stale builds
|
|
@@ -102,7 +103,7 @@ services:
|
|
|
102
103
|
context: .
|
|
103
104
|
target: runner
|
|
104
105
|
ports:
|
|
105
|
-
-
|
|
106
|
+
- '3000:3000'
|
|
106
107
|
environment:
|
|
107
108
|
- DATABASE_URL=postgres://postgres:postgres@db:5432/myapp
|
|
108
109
|
- REDIS_URL=redis://redis:6379
|
|
@@ -122,7 +123,7 @@ services:
|
|
|
122
123
|
volumes:
|
|
123
124
|
- pgdata:/var/lib/postgresql/data
|
|
124
125
|
healthcheck:
|
|
125
|
-
test: [
|
|
126
|
+
test: ['CMD-SHELL', 'pg_isready -U postgres']
|
|
126
127
|
interval: 5s
|
|
127
128
|
timeout: 3s
|
|
128
129
|
retries: 5
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before responding to production outages or performing incident triage, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Stabilization-First Rule (Section 25) → Immediately rollback/mitigate first (revert commit, flip flag, shed load); perform root cause analysis AFTER system is stable
|
|
24
25
|
2. Circuit Breaker Severance (Section 42) → Sever failing downstream dependencies immediately to prevent cascading overload across the system
|
|
25
26
|
3. Triage Hierarchy (Section 73) → Analyze metrics (what) → traces (where) → logs (why) sequentially to pinpoint root causes
|
|
@@ -74,7 +75,7 @@ const breaker = new CircuitBreaker(fetchUser, {
|
|
|
74
75
|
resetTimeout: 30000, // Open the circuit (stop sending requests) for 30s
|
|
75
76
|
});
|
|
76
77
|
|
|
77
|
-
breaker.fallback(() => ({ id:
|
|
78
|
+
breaker.fallback(() => ({ id: 'cached-user', status: 'degraded' }));
|
|
78
79
|
```
|
|
79
80
|
|
|
80
81
|
**Heavy Mitigation Tactics:**
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before attempting bug diagnostics or proposing code fixes, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Red-Capable Feedback Loop Rule (Section 34) → Construct a fast, deterministic, automated feedback loop command that reproduces the bug (goes red) BEFORE making code edits
|
|
24
25
|
2. Falsifiable Hypotheses Formulation (Section 107) → Formulate 3–5 falsifiable hypotheses (`"If X is cause, then Y prediction"`) before testing any single theory
|
|
25
26
|
3. Tagged Debug Logging & Cleanup (Section 123) → Tag debug log instrumentation (`[DEBUG-id]`) and sweep clean before finalizing regression fixes
|
|
@@ -66,6 +67,7 @@ Build the right feedback loop, and the bug is 90% fixed.
|
|
|
66
67
|
### Tighten the Loop
|
|
67
68
|
|
|
68
69
|
Treat the loop as a product. Once you have a loop, tighten it:
|
|
70
|
+
|
|
69
71
|
- **Can I make it faster?** (Cache setup, skip unrelated init, narrow the test scope.)
|
|
70
72
|
- **Can I make the signal sharper?** (Assert on the specific symptom, not "didn't crash".)
|
|
71
73
|
- **Can I make it more deterministic?** (Pin time, seed RNG, isolate filesystem, freeze network.)
|
|
@@ -79,21 +81,23 @@ The goal is not a clean repro but a higher reproduction rate. Loop the trigger 1
|
|
|
79
81
|
### When You Genuinely Cannot Build a Loop
|
|
80
82
|
|
|
81
83
|
Stop and say so explicitly. List what you tried. Ask the user for:
|
|
84
|
+
|
|
82
85
|
1. Access to whatever environment reproduces it.
|
|
83
86
|
2. A captured artifact (HAR file, log dump, core dump, screen recording with timestamps).
|
|
84
87
|
3. Permission to add temporary production instrumentation.
|
|
85
88
|
|
|
86
|
-
|
|
89
|
+
_Do not proceed to hypothesise without a loop._
|
|
87
90
|
|
|
88
91
|
### Phase 1 Completion Criterion — A Tight Loop That Goes Red
|
|
89
92
|
|
|
90
93
|
Phase 1 is done when the loop is tight and red-capable: you can name **one command** — a script path, a test invocation, a curl — that you have already run at least once (paste the invocation and its output), and that is:
|
|
94
|
+
|
|
91
95
|
- ✅ **Red-capable**: Drives the actual bug code path and asserts the user's exact symptom, going red on this bug and green once fixed. Not "runs without erroring" — it must catch this specific bug.
|
|
92
96
|
- ✅ **Deterministic**: Same verdict every run (or high, pinned reproduction rate).
|
|
93
97
|
- ✅ **Fast**: Seconds, not minutes.
|
|
94
98
|
- ✅ **Agent-runnable**: Runnable unattended (HITL only via `scripts/hitl-loop.template.sh`).
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
_If you catch yourself reading code to build a theory before this command exists, stop. No red-capable command, no Phase 2._
|
|
97
101
|
|
|
98
102
|
---
|
|
99
103
|
|
|
@@ -102,11 +106,13 @@ Phase 1 is done when the loop is tight and red-capable: you can name **one comma
|
|
|
102
106
|
Run the loop. Watch it go red — the bug appears.
|
|
103
107
|
|
|
104
108
|
### Confirm
|
|
109
|
+
|
|
105
110
|
1. The loop produces the failure mode the user described — not a different failure nearby. (Wrong bug = wrong fix.)
|
|
106
111
|
2. The failure is reproducible across multiple runs (or at a high enough reproduction rate).
|
|
107
112
|
3. You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix addresses it.
|
|
108
113
|
|
|
109
114
|
### Minimise
|
|
115
|
+
|
|
110
116
|
Once it's red, shrink the repro to the smallest scenario that still goes red. Cut inputs, callers, config, data, and steps one at a time, re-running the loop after each cut — keep only what's load-bearing for the failure.
|
|
111
117
|
|
|
112
118
|
> 🎯 **Why bother**: A minimal repro shrinks the hypothesis space in Phase 3 (fewer moving parts left to suspect) and becomes the clean regression test in Phase 5.
|
|
@@ -134,6 +140,7 @@ Show the ranked list to the user before testing. (Proceed with your ranking if t
|
|
|
134
140
|
Each probe must map to a specific prediction from Phase 3. Change one variable at a time.
|
|
135
141
|
|
|
136
142
|
### Tool Preference
|
|
143
|
+
|
|
137
144
|
1. **Debugger / REPL Inspection**: If the environment supports it. One breakpoint beats ten logs.
|
|
138
145
|
2. **Targeted Logs**: Place logs at boundaries that distinguish hypotheses. Never "log everything and grep".
|
|
139
146
|
3. **Tag Every Debug Log**: Prefix every debug log with a unique tag, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep.
|
|
@@ -150,6 +157,7 @@ A correct seam is one where the test exercises the real bug pattern as it occurs
|
|
|
150
157
|
If no correct seam exists, note it. The codebase architecture is preventing the bug from being locked down. Flag this for Phase 6.
|
|
151
158
|
|
|
152
159
|
### If a Correct Seam Exists:
|
|
160
|
+
|
|
153
161
|
1. Turn the minimised repro into a failing test at that seam.
|
|
154
162
|
2. Watch it fail.
|
|
155
163
|
3. Apply the fix.
|
|
@@ -161,6 +169,7 @@ If no correct seam exists, note it. The codebase architecture is preventing the
|
|
|
161
169
|
## Phase 6 — Cleanup + Post-Mortem
|
|
162
170
|
|
|
163
171
|
### Required Before Declaring Done
|
|
172
|
+
|
|
164
173
|
- [ ] Original repro no longer reproduces (re-run Phase 1 loop)
|
|
165
174
|
- [ ] Regression test passes (or absence of seam is documented)
|
|
166
175
|
- [ ] All `[DEBUG-...]` instrumentation removed (grep the prefix)
|
|
@@ -168,6 +177,7 @@ If no correct seam exists, note it. The codebase architecture is preventing the
|
|
|
168
177
|
- [ ] Correct hypothesis stated in commit / PR message
|
|
169
178
|
|
|
170
179
|
### Post-Mortem Handoff
|
|
180
|
+
|
|
171
181
|
Ask: **What would have prevented this bug?** If the answer involves architectural debt (no good test seam, tangled callers, hidden coupling), hand off to `/improve-codebase-architecture` with specific findings.
|
|
172
182
|
|
|
173
183
|
---
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before decluttering UI layouts, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Active screen components → Identify core primary user task and secondary/tertiary options
|
|
24
25
|
2. Container Reduction rules (Section 25) → Replace nested card containers and redundant borders with whitespace grid gaps
|
|
25
26
|
3. Progressive Disclosure patterns (Section 30) → Move advanced parameters into collapsible accordions or popovers
|
|
@@ -31,18 +32,22 @@ Systematically strip away visual clutter, redundant controls, and cognitive fric
|
|
|
31
32
|
## The 4 Distillation Steps
|
|
32
33
|
|
|
33
34
|
### 1. Identify & Remove Visual Noise
|
|
35
|
+
|
|
34
36
|
- **Container Reduction**: Eliminate unnecessary nested cards, boxes inside boxes, and decorative borders. Use whitespace instead of lines to separate content blocks.
|
|
35
37
|
- **Icon Pruning**: Remove decorative icons that restate obvious text labels (e.g. an envelope icon next to a button that clearly says "Send Email").
|
|
36
38
|
|
|
37
39
|
### 2. Collapse Secondary Actions
|
|
40
|
+
|
|
38
41
|
- **Primary vs Overflow**: Keep only 1 primary action button and max 1 secondary button visible. Hide tertiary actions inside an overflow dropdown (`...` menu).
|
|
39
42
|
- **Progressive Disclosure**: Hide advanced settings or non-essential controls behind an "Advanced Settings" accordion or popover.
|
|
40
43
|
|
|
41
44
|
### 3. Trim Copy & Microcopy
|
|
42
|
-
|
|
43
|
-
- **
|
|
45
|
+
|
|
46
|
+
- **Cut Conversational Filler**: Strip verbose instructions. Change _"Please fill out the form below to register your account"_ to _"Create account"_.
|
|
47
|
+
- **Shorten Button Labels**: Change _"Click here to update your profile settings"_ to _"Save profile"_.
|
|
44
48
|
|
|
45
49
|
### 4. Group Related Fields
|
|
50
|
+
|
|
46
51
|
- **Consolidate Form Inputs**: Merge separate "First Name" and "Last Name" fields into "Full Name" if separate values aren't strictly required. Merge city/state/zip into single address lookup where possible.
|
|
47
52
|
|
|
48
53
|
---
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before creating or editing documentation, API references, or comments, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Target Audience Identification (Section 27) → Match template strictly to audience (README for 10-min quickstart, API docs for payload contracts, Runbook for on-call triage)
|
|
24
25
|
2. Explain "Why", Not "What" in Code Comments (Section 147) → Document non-obvious business rules or bug workarounds; ban restating obvious code syntax
|
|
25
26
|
3. AI-Friendly Documentation Mapping (Section 171) → Maintain `ARCHITECTURE.md` and `@purpose:` annotations for codebase mental models and automated ingestion
|
|
@@ -149,8 +150,8 @@ Creates a new user account.
|
|
|
149
150
|
**Example**
|
|
150
151
|
\`\`\`bash
|
|
151
152
|
curl -X POST /api/users \
|
|
152
|
-
|
|
153
|
-
|
|
153
|
+
-H "Content-Type: application/json" \
|
|
154
|
+
-d '{"email": "user@example.com", "name": "Jane"}'
|
|
154
155
|
\`\`\`
|
|
155
156
|
```
|
|
156
157
|
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before designing domain entities or business modeling, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Ubiquitous Language Uniformity (Section 25) → Standardize 1 explicit term across UI, code, and DB (e.g. Customer vs User); ban interchangeable synonyms
|
|
24
25
|
2. Bounded Context Separation (Section 30) → Isolate models per context (e.g. Inventory Product vs Catalog Product); ban 60-column monolithic entities
|
|
25
26
|
3. Aggregate Root Invariants (Section 34) → Mutate child entities strictly through Aggregate Root methods (`order.addItem(...)`); ban direct child mutations
|
|
@@ -33,30 +34,37 @@ Model business domain concepts cleanly before committing to database schemas or
|
|
|
33
34
|
## 4 Domain Modeling Rules
|
|
34
35
|
|
|
35
36
|
### 1. Establish Ubiquitous Language
|
|
37
|
+
|
|
36
38
|
- Agree on strict, unambiguous terms used identically across domain experts, code variable names, database tables, and UI copy.
|
|
37
|
-
- ❌
|
|
39
|
+
- ❌ _User_, _Account_, _Member_, _Client_ used interchangeably for the same concept.
|
|
38
40
|
- ✅ Define 1 clear term: **Customer** (for billing context) vs **User** (for authentication context).
|
|
39
41
|
|
|
40
42
|
### 2. Define Bounded Contexts
|
|
41
|
-
|
|
43
|
+
|
|
44
|
+
- Separate large systems into distinct bounded contexts. An entity named `Product` in the _Inventory Context_ (stock level, warehouse bin) has different attributes than `Product` in the _Catalog Context_ (hero image, pricing).
|
|
42
45
|
|
|
43
46
|
### 3. Aggregates & Invariants
|
|
47
|
+
|
|
44
48
|
- An **Aggregate Root** (e.g. `Order`) enforces internal business invariants across child entities (`OrderItem`).
|
|
45
49
|
- Never mutate a child entity (`OrderItem`) directly without passing through the aggregate root method (`order.addItem(product, qty)`).
|
|
46
50
|
|
|
47
51
|
### 4. Value Objects Over Primitives
|
|
52
|
+
|
|
48
53
|
- Wrap primitives into type-safe Value Objects to enforce validation logic:
|
|
54
|
+
|
|
49
55
|
```typescript
|
|
50
56
|
// Value Object enforcing domain rule
|
|
51
57
|
export class EmailAddress {
|
|
52
58
|
private readonly value: string;
|
|
53
59
|
|
|
54
60
|
constructor(email: string) {
|
|
55
|
-
if (!email.includes(
|
|
61
|
+
if (!email.includes('@')) throw new Error('Invalid email domain');
|
|
56
62
|
this.value = email.toLowerCase().trim();
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
public toString(): string {
|
|
65
|
+
public toString(): string {
|
|
66
|
+
return this.value;
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
```
|
|
62
70
|
|
|
@@ -18,6 +18,7 @@ skills:
|
|
|
18
18
|
## Mandatory Pre-Flight Context Inspection
|
|
19
19
|
|
|
20
20
|
Before writing analytical queries:
|
|
21
|
+
|
|
21
22
|
1. Direct File Querying → Query Parquet/CSV/JSON directly without importing into a traditional DB
|
|
22
23
|
2. Memory Allocation → Set explicit memory limit (`SET max_memory = '4GB'`) to prevent OOM
|
|
23
24
|
3. Vectorized Engine Usage → Use column-oriented aggregation over line-by-line loops
|
|
@@ -29,11 +30,12 @@ import { Database } from 'duckdb-async';
|
|
|
29
30
|
|
|
30
31
|
export async function runAnalyticalReport(parquetGlobPath: string) {
|
|
31
32
|
const db = await Database.create(':memory:');
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
// Set memory limits for embedded execution
|
|
34
35
|
await db.exec("SET max_memory = '2GB'; SET threads = 4;");
|
|
35
36
|
|
|
36
|
-
const rows = await db.all(
|
|
37
|
+
const rows = await db.all(
|
|
38
|
+
`
|
|
37
39
|
SELECT
|
|
38
40
|
date_trunc('day', timestamp) as event_day,
|
|
39
41
|
event_type,
|
|
@@ -43,7 +45,9 @@ export async function runAnalyticalReport(parquetGlobPath: string) {
|
|
|
43
45
|
GROUP BY 1, 2
|
|
44
46
|
ORDER BY 1 DESC
|
|
45
47
|
LIMIT 100
|
|
46
|
-
`,
|
|
48
|
+
`,
|
|
49
|
+
[parquetGlobPath],
|
|
50
|
+
);
|
|
47
51
|
|
|
48
52
|
return rows;
|
|
49
53
|
}
|
|
@@ -18,6 +18,7 @@ skills:
|
|
|
18
18
|
## Mandatory Pre-Flight Context Inspection
|
|
19
19
|
|
|
20
20
|
Before deploying on-device AI models:
|
|
21
|
+
|
|
21
22
|
1. Model Quantization → Use 4-bit/8-bit quantized models (GGUF/ONNX) to fit mobile RAM budgets (<500MB)
|
|
22
23
|
2. Hardware Acceleration → Bind inference engine to Apple Neural Engine (ANE) or Android NPU
|
|
23
24
|
3. Fallback Mechanism → Fall back gracefully to cloud LLM API if local inference exceeds latency budget (>200ms)
|
|
@@ -32,7 +33,10 @@ export async function runLocalEmbeddings(textTokens: number[]): Promise<Float32A
|
|
|
32
33
|
executionProviders: ['cpu'], // Accelerates via ANE/NNAPI internally
|
|
33
34
|
});
|
|
34
35
|
|
|
35
|
-
const tensor = new ort.Tensor('int64', new BigInt64Array(textTokens.map(BigInt)), [
|
|
36
|
+
const tensor = new ort.Tensor('int64', new BigInt64Array(textTokens.map(BigInt)), [
|
|
37
|
+
1,
|
|
38
|
+
textTokens.length,
|
|
39
|
+
]);
|
|
36
40
|
const feeds = { input_ids: tensor };
|
|
37
41
|
|
|
38
42
|
const results = await session.run(feeds);
|
|
@@ -20,6 +20,7 @@ scripts-binding:
|
|
|
20
20
|
## Mandatory Pre-Flight Context Inspection
|
|
21
21
|
|
|
22
22
|
Before engineering edge computing handlers or Cloudflare Workers, you MUST inspect:
|
|
23
|
+
|
|
23
24
|
1. Edge Runtime Restrictions (Section 25) → Strictly ban Node.js native core modules (`fs`, `child_process`, native `bcrypt`); use Web APIs (`fetch`, `crypto.subtle`)
|
|
24
25
|
2. Stale-While-Revalidate Caching (Section 47) → Use `Cache-Control: s-maxage=60, stale-while-revalidate=86400` and asynchronous `ctx.waitUntil()` cache puts
|
|
25
26
|
3. Edge Database Access (Section 81) → Never open direct raw TCP connections to DBs; use HTTP connection poolers (Prisma Accelerate, LibSQL, Supabase Pooler)
|
|
@@ -48,11 +49,11 @@ Edge functions (Cloudflare Workers, Vercel Edge) run on V8 Isolates, NOT standar
|
|
|
48
49
|
|
|
49
50
|
```typescript
|
|
50
51
|
// ❌ BAD: Attempting to use Node native core modules
|
|
51
|
-
import fs from
|
|
52
|
-
import bcrypt from
|
|
52
|
+
import fs from 'fs';
|
|
53
|
+
import bcrypt from 'bcrypt'; // Has C++ bindings, will instantly crash on V8 edge
|
|
53
54
|
|
|
54
55
|
// ✅ GOOD: Utilizing standard Web APIs (Fetch, CryptoKey)
|
|
55
|
-
const hashBuffer = await crypto.subtle.digest(
|
|
56
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(password));
|
|
56
57
|
```
|
|
57
58
|
|
|
58
59
|
---
|
|
@@ -79,7 +80,7 @@ export default {
|
|
|
79
80
|
// Instructs the Edge CDN: Serve the stale version instantly to the user,
|
|
80
81
|
// but fire an async request in the background to update the cache for the next user.
|
|
81
82
|
response = new Response(response.body, response);
|
|
82
|
-
response.headers.set(
|
|
83
|
+
response.headers.set('Cache-Control', 's-maxage=60, stale-while-revalidate=86400');
|
|
83
84
|
|
|
84
85
|
// 4. Store in Cache asynchronously (do not block the user response)
|
|
85
86
|
ctx.waitUntil(cache.put(request, response.clone()));
|
|
@@ -104,14 +105,14 @@ Running logic globally while querying a monolithic database in `us-east-1` is co
|
|
|
104
105
|
|
|
105
106
|
```typescript
|
|
106
107
|
// ✅ Turso / LibSQL (Distributed Edge DB) usage:
|
|
107
|
-
import { createClient } from
|
|
108
|
+
import { createClient } from '@libsql/client/web';
|
|
108
109
|
|
|
109
110
|
const client = createClient({
|
|
110
111
|
url: env.TURSO_DATABASE_URL,
|
|
111
112
|
authToken: env.TURSO_AUTH_TOKEN,
|
|
112
113
|
});
|
|
113
114
|
|
|
114
|
-
const result = await client.execute(
|
|
115
|
+
const result = await client.execute('SELECT * FROM users WHERE id = ?', [userId]);
|
|
115
116
|
```
|
|
116
117
|
|
|
117
118
|
---
|
|
@@ -137,9 +138,9 @@ export class ChatRoom {
|
|
|
137
138
|
pair.server.accept();
|
|
138
139
|
|
|
139
140
|
// Handle incoming Chat messages
|
|
140
|
-
pair.server.addEventListener(
|
|
141
|
+
pair.server.addEventListener('message', msg => {
|
|
141
142
|
// Broadcast to all other connected edge users
|
|
142
|
-
this.sessions.forEach(
|
|
143
|
+
this.sessions.forEach(session => session.send(msg.data));
|
|
143
144
|
});
|
|
144
145
|
|
|
145
146
|
return new Response(null, { status: 101, webSocket: pair.client });
|