@defai.digital/automatosx 12.6.3 → 12.7.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/dist/index.js CHANGED
@@ -10417,7 +10417,7 @@ var PRECOMPILED_CONFIG = {
10417
10417
  "enableFreeTierPrioritization": true,
10418
10418
  "enableWorkloadAwareRouting": true
10419
10419
  },
10420
- "version": "12.6.3"
10420
+ "version": "12.7.0"
10421
10421
  };
10422
10422
 
10423
10423
  // src/core/config/schemas.ts
@@ -10850,10 +10850,11 @@ async function loadConfigFile(path9) {
10850
10850
  if (error instanceof ConfigError) {
10851
10851
  throw error;
10852
10852
  }
10853
- if (error.code === "ENOENT") {
10853
+ const nodeError = error;
10854
+ if (nodeError.code === "ENOENT") {
10854
10855
  throw ConfigError.notFound(path9);
10855
10856
  }
10856
- if (error.code === "EACCES") {
10857
+ if (nodeError.code === "EACCES") {
10857
10858
  throw new ConfigError(
10858
10859
  `Permission denied reading config: ${path9}`,
10859
10860
  "E1002" /* CONFIG_PARSE_ERROR */,
@@ -11306,7 +11307,8 @@ async function saveConfigFile(path9, config) {
11306
11307
  if (error instanceof ConfigError) {
11307
11308
  throw error;
11308
11309
  }
11309
- if (error.code === "EACCES") {
11310
+ const nodeError = error;
11311
+ if (nodeError.code === "EACCES") {
11310
11312
  throw new ConfigError(
11311
11313
  `Permission denied writing config: ${path9}`,
11312
11314
  "E1002" /* CONFIG_PARSE_ERROR */,
@@ -11315,7 +11317,7 @@ async function saveConfigFile(path9, config) {
11315
11317
  "Run with appropriate user privileges",
11316
11318
  "Verify the directory is writable"
11317
11319
  ],
11318
- { path: path9, error: error.message }
11320
+ { path: path9, error: nodeError.message }
11319
11321
  );
11320
11322
  }
11321
11323
  throw new ConfigError(
@@ -13318,6 +13320,1374 @@ function safeValidateAgentProfile(profile) {
13318
13320
  }
13319
13321
  agentProfileSchema.partial();
13320
13322
 
13323
+ // src/agents/cognitive/prompt-composer.ts
13324
+ init_esm_shims();
13325
+
13326
+ // src/agents/cognitive/reasoning-scaffolds.ts
13327
+ init_esm_shims();
13328
+ var PROVER_STEPS = [
13329
+ {
13330
+ id: "1_intake",
13331
+ name: "INTAKE",
13332
+ description: "Understand before acting",
13333
+ requiredActions: [
13334
+ "Restate the goal, constraints, and success criteria in your own words",
13335
+ "Read relevant files and cite them (path:line) - do NOT hypothesize without evidence",
13336
+ "List your assumptions and unknowns explicitly",
13337
+ "If blockers exist that prevent progress, ask 1-3 focused clarifying questions"
13338
+ ],
13339
+ skipWhen: ["Task is trivial and self-explanatory"]
13340
+ },
13341
+ {
13342
+ id: "2_risk_scan",
13343
+ name: "RISK SCAN",
13344
+ description: "Anticipate failure modes before they occur",
13345
+ requiredActions: [
13346
+ "Run through your domain-specific checklist (see DOMAIN CHECKLIST section)",
13347
+ "Flag any high-risk items explicitly with [RISK] tag",
13348
+ "Propose mitigations for critical risks before proceeding",
13349
+ "If risks are unacceptable, STOP and discuss with user"
13350
+ ]
13351
+ },
13352
+ {
13353
+ id: "3_options",
13354
+ name: "OPTIONS",
13355
+ description: "Consider alternatives before committing",
13356
+ requiredActions: [
13357
+ "Generate 2-3 viable approaches (skip only if truly trivial)",
13358
+ "Compare each against: complexity, performance, risk, maintainability",
13359
+ "Choose one approach with explicit rationale",
13360
+ "Document what was rejected and why (prevents revisiting)"
13361
+ ],
13362
+ skipWhen: ["Single obvious solution exists", "Task is a simple bug fix"]
13363
+ },
13364
+ {
13365
+ id: "4_plan",
13366
+ name: "PLAN",
13367
+ description: "Decompose before executing",
13368
+ requiredActions: [
13369
+ "Break work into ordered steps (even if small)",
13370
+ "Identify dependencies between steps",
13371
+ "Note which steps are reversible vs. irreversible",
13372
+ 'For trivial tasks: "Plan: Single-step execution"'
13373
+ ]
13374
+ },
13375
+ {
13376
+ id: "5_execute",
13377
+ name: "EXECUTE",
13378
+ description: "Implement with discipline",
13379
+ requiredActions: [
13380
+ "Follow the plan step-by-step",
13381
+ "Cite existing patterns in codebase when applicable",
13382
+ "Keep changes minimal and focused - resist scope creep",
13383
+ "Document non-obvious decisions with brief inline comments",
13384
+ "If blocked during execution, update plan rather than improvising"
13385
+ ]
13386
+ },
13387
+ {
13388
+ id: "6_validate",
13389
+ name: "VALIDATE",
13390
+ description: "Verify before delivering - never ship unvalidated work",
13391
+ requiredActions: [
13392
+ "Run verification commands (typecheck, tests, lint)",
13393
+ "State explicitly what WAS validated",
13394
+ "State explicitly what was NOT validated (gaps)",
13395
+ "Note residual risks that remain after validation",
13396
+ "If validation fails, diagnose and fix before reporting"
13397
+ ]
13398
+ },
13399
+ {
13400
+ id: "7_report",
13401
+ name: "REPORT",
13402
+ description: "Structured delivery with full transparency",
13403
+ requiredActions: [
13404
+ "Use the OUTPUT FORMAT structure (see OUTPUT FORMAT section)",
13405
+ "Be concise but complete - no hand-waving",
13406
+ "Include file references with paths for all changes",
13407
+ "Specify concrete follow-up actions if any"
13408
+ ]
13409
+ }
13410
+ ];
13411
+ var PROVER_TEMPLATE = `## MANDATORY REASONING LOOP (PROVER)
13412
+
13413
+ For EVERY task, follow this sequence. Skipping steps leads to mistakes.
13414
+
13415
+ ### 1. INTAKE (before touching code)
13416
+ **Purpose**: Understand before acting
13417
+
13418
+ - **Restate**: Goal, constraints, success criteria in your own words
13419
+ - **Recon**: Read relevant files (cite \`path:line\`) - do NOT hypothesize without evidence
13420
+ - **Unknowns**: List assumptions explicitly
13421
+ - **Blockers**: If blockers exist, ask 1-3 focused clarifying questions
13422
+
13423
+ ### 2. RISK SCAN
13424
+ **Purpose**: Anticipate failure modes
13425
+
13426
+ - Run through your DOMAIN CHECKLIST (see below)
13427
+ - Flag high-risk items with [RISK] tag
13428
+ - Propose mitigations for critical risks
13429
+ - If risks are unacceptable, STOP and discuss
13430
+
13431
+ ### 3. OPTIONS (skip if truly trivial)
13432
+ **Purpose**: Consider alternatives before committing
13433
+
13434
+ - Generate 2-3 viable approaches
13435
+ - Compare: complexity, performance, risk, maintainability
13436
+ - Choose one with explicit rationale
13437
+ - Note what was rejected and why
13438
+
13439
+ ### 4. PLAN
13440
+ **Purpose**: Decompose before executing
13441
+
13442
+ - Break work into ordered steps
13443
+ - Identify dependencies between steps
13444
+ - Note reversible vs. irreversible steps
13445
+ - For trivial tasks: "Plan: Single-step execution"
13446
+
13447
+ ### 5. EXECUTE
13448
+ **Purpose**: Implement with discipline
13449
+
13450
+ - Follow plan step-by-step
13451
+ - Cite existing patterns in codebase
13452
+ - Keep changes minimal - resist scope creep
13453
+ - If blocked, update plan rather than improvising
13454
+
13455
+ ### 6. VALIDATE
13456
+ **Purpose**: Never ship unvalidated work
13457
+
13458
+ - Run: typecheck, tests, lint (as applicable)
13459
+ - State what WAS validated
13460
+ - State what was NOT validated (gaps)
13461
+ - If validation fails, fix before reporting
13462
+
13463
+ ### 7. REPORT
13464
+ **Purpose**: Structured delivery
13465
+
13466
+ - Use the OUTPUT FORMAT structure
13467
+ - Include file paths for all changes
13468
+ - Specify follow-up actions
13469
+
13470
+ ---
13471
+
13472
+ **CRITICAL**: If uncertain at any step, ASK rather than assume.
13473
+ If proceeding with assumptions, LIST THEM EXPLICITLY.
13474
+ `;
13475
+ var LITE_STEPS = [
13476
+ {
13477
+ id: "1_understand",
13478
+ name: "UNDERSTAND",
13479
+ description: "Quick comprehension",
13480
+ requiredActions: [
13481
+ "Confirm what needs to be done",
13482
+ "Check relevant file if needed"
13483
+ ]
13484
+ },
13485
+ {
13486
+ id: "2_do",
13487
+ name: "DO",
13488
+ description: "Execute the task",
13489
+ requiredActions: [
13490
+ "Make the change",
13491
+ "Follow existing patterns"
13492
+ ]
13493
+ },
13494
+ {
13495
+ id: "3_verify",
13496
+ name: "VERIFY",
13497
+ description: "Quick validation",
13498
+ requiredActions: [
13499
+ "Run typecheck/tests if applicable",
13500
+ "Note if verification was skipped and why"
13501
+ ]
13502
+ },
13503
+ {
13504
+ id: "4_report",
13505
+ name: "REPORT",
13506
+ description: "Brief summary",
13507
+ requiredActions: [
13508
+ "State what was done",
13509
+ "Note any caveats or follow-ups"
13510
+ ]
13511
+ }
13512
+ ];
13513
+ var LITE_TEMPLATE = `## REASONING LOOP (LITE)
13514
+
13515
+ For simple tasks, follow this streamlined process:
13516
+
13517
+ ### 1. UNDERSTAND
13518
+ - Confirm what needs to be done
13519
+ - Check relevant file if needed
13520
+
13521
+ ### 2. DO
13522
+ - Make the change
13523
+ - Follow existing patterns
13524
+
13525
+ ### 3. VERIFY
13526
+ - Run typecheck/tests if applicable
13527
+ - Note if skipped and why
13528
+
13529
+ ### 4. REPORT
13530
+ - State what was done
13531
+ - Note any caveats
13532
+
13533
+ ---
13534
+
13535
+ **Escalate to PROVER scaffold if task is more complex than expected.**
13536
+ `;
13537
+ var SCAFFOLDS = {
13538
+ prover: {
13539
+ id: "prover",
13540
+ name: "PROVER",
13541
+ description: "Full reasoning loop: Plan-Risk-Options-Validate-Execute-Report",
13542
+ steps: PROVER_STEPS,
13543
+ template: PROVER_TEMPLATE
13544
+ },
13545
+ lite: {
13546
+ id: "lite",
13547
+ name: "LITE",
13548
+ description: "Lightweight reasoning: Understand-Do-Verify-Report",
13549
+ steps: LITE_STEPS,
13550
+ template: LITE_TEMPLATE
13551
+ }
13552
+ };
13553
+ function getReasoningScaffold(type) {
13554
+ const scaffold = SCAFFOLDS[type];
13555
+ if (!scaffold) {
13556
+ throw new Error(`Unknown reasoning scaffold: ${type}`);
13557
+ }
13558
+ return scaffold;
13559
+ }
13560
+ function getScaffoldTemplate(type) {
13561
+ return getReasoningScaffold(type).template;
13562
+ }
13563
+
13564
+ // src/agents/cognitive/role-checklists.ts
13565
+ init_esm_shims();
13566
+ var BACKEND_CHECKLIST = {
13567
+ id: "backend",
13568
+ name: "Backend Checklist",
13569
+ role: "Backend Developer",
13570
+ categories: {
13571
+ security: [
13572
+ { id: "be-sec-1", category: "security", text: "Authentication: Are endpoints properly protected?", severity: "critical", triggers: ["api", "endpoint", "route"] },
13573
+ { id: "be-sec-2", category: "security", text: "Authorization: Is access control enforced (who can do what)?", severity: "critical", triggers: ["user", "role", "permission"] },
13574
+ { id: "be-sec-3", category: "security", text: "Input validation: Are all inputs validated and sanitized?", severity: "critical", triggers: ["input", "request", "body", "params"] },
13575
+ { id: "be-sec-4", category: "security", text: "Secrets: No hardcoded credentials, tokens, or keys?", severity: "critical", triggers: ["config", "env", "secret", "key"] }
13576
+ ],
13577
+ data_integrity: [
13578
+ { id: "be-data-1", category: "data_integrity", text: "Migrations: Are database migrations reversible and safe?", severity: "high", triggers: ["migration", "schema", "database", "table"] },
13579
+ { id: "be-data-2", category: "data_integrity", text: "Transactions: Are operations atomic where needed?", severity: "high", triggers: ["transaction", "update", "insert", "delete"] },
13580
+ { id: "be-data-3", category: "data_integrity", text: "Idempotency: Can operations be safely retried?", severity: "medium", triggers: ["retry", "idempotent", "duplicate"] },
13581
+ { id: "be-data-4", category: "data_integrity", text: "Data validation: Are data constraints enforced at DB level?", severity: "medium", triggers: ["constraint", "schema", "validate"] }
13582
+ ],
13583
+ performance: [
13584
+ { id: "be-perf-1", category: "performance", text: "N+1 queries: Are database calls optimized (no loops of queries)?", severity: "high", triggers: ["query", "loop", "database", "fetch"] },
13585
+ { id: "be-perf-2", category: "performance", text: "Caching: Is caching strategy appropriate for this data?", severity: "medium", triggers: ["cache", "redis", "memory"] },
13586
+ { id: "be-perf-3", category: "performance", text: "Indexing: Are queries using appropriate indexes?", severity: "medium", triggers: ["query", "search", "filter", "where"] },
13587
+ { id: "be-perf-4", category: "performance", text: "Connection pooling: Are database connections managed properly?", severity: "medium", triggers: ["connection", "pool", "database"] }
13588
+ ],
13589
+ reliability: [
13590
+ { id: "be-rel-1", category: "reliability", text: "Error handling: Are errors caught, logged, and handled gracefully?", severity: "high", triggers: ["error", "catch", "exception"] },
13591
+ { id: "be-rel-2", category: "reliability", text: "Retry logic: Is there backoff for transient failures?", severity: "medium", triggers: ["retry", "backoff", "timeout"] },
13592
+ { id: "be-rel-3", category: "reliability", text: "Circuit breakers: Are external service calls protected?", severity: "medium", triggers: ["external", "api", "service", "http"] },
13593
+ { id: "be-rel-4", category: "reliability", text: "Observability: Are metrics, logs, and traces in place?", severity: "medium", triggers: ["log", "metric", "trace", "monitor"] }
13594
+ ]
13595
+ },
13596
+ template: `## DOMAIN CHECKLIST: Backend
13597
+
13598
+ Before finalizing, verify each applicable item:
13599
+
13600
+ **Security** (CRITICAL)
13601
+ - [ ] Authentication: Are endpoints properly protected?
13602
+ - [ ] Authorization: Is access control enforced?
13603
+ - [ ] Input validation: Are all inputs sanitized?
13604
+ - [ ] Secrets: No hardcoded credentials?
13605
+
13606
+ **Data Integrity** (HIGH)
13607
+ - [ ] Migrations: Reversible and safe?
13608
+ - [ ] Transactions: Atomic where needed?
13609
+ - [ ] Idempotency: Safe to retry?
13610
+ - [ ] Data validation: Constraints enforced?
13611
+
13612
+ **Performance** (MEDIUM-HIGH)
13613
+ - [ ] N+1 queries: Optimized database calls?
13614
+ - [ ] Caching: Appropriate strategy?
13615
+ - [ ] Indexing: Queries using indexes?
13616
+ - [ ] Connection pooling: Managed properly?
13617
+
13618
+ **Reliability** (HIGH)
13619
+ - [ ] Error handling: Graceful failures?
13620
+ - [ ] Retry logic: Backoff for transient failures?
13621
+ - [ ] Circuit breakers: External calls protected?
13622
+ - [ ] Observability: Logs, metrics, traces?
13623
+
13624
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13625
+ Flag any concerns with [RISK].
13626
+ `
13627
+ };
13628
+ var FRONTEND_CHECKLIST = {
13629
+ id: "frontend",
13630
+ name: "Frontend Checklist",
13631
+ role: "Frontend Developer",
13632
+ categories: {
13633
+ accessibility: [
13634
+ { id: "fe-a11y-1", category: "accessibility", text: "Semantic HTML: Are elements properly labeled (headings, landmarks)?", severity: "high", triggers: ["html", "element", "component"] },
13635
+ { id: "fe-a11y-2", category: "accessibility", text: "Keyboard navigation: Is everything navigable without mouse?", severity: "high", triggers: ["button", "link", "interactive", "focus"] },
13636
+ { id: "fe-a11y-3", category: "accessibility", text: "Screen reader: Are ARIA labels and roles correct?", severity: "high", triggers: ["aria", "label", "role"] },
13637
+ { id: "fe-a11y-4", category: "accessibility", text: "Color contrast: Does it meet WCAG AA standards?", severity: "medium", triggers: ["color", "text", "background", "style"] }
13638
+ ],
13639
+ user_experience: [
13640
+ { id: "fe-ux-1", category: "user_experience", text: "Loading states: Are async operations indicated to user?", severity: "high", triggers: ["async", "fetch", "load", "api"] },
13641
+ { id: "fe-ux-2", category: "user_experience", text: "Error states: Are failures communicated clearly?", severity: "high", triggers: ["error", "fail", "catch"] },
13642
+ { id: "fe-ux-3", category: "user_experience", text: "Empty states: Is there guidance when no data exists?", severity: "medium", triggers: ["empty", "no data", "list", "table"] },
13643
+ { id: "fe-ux-4", category: "user_experience", text: "Responsive: Does it work on all screen sizes?", severity: "high", triggers: ["layout", "grid", "flex", "responsive"] }
13644
+ ],
13645
+ performance: [
13646
+ { id: "fe-perf-1", category: "performance", text: "Bundle size: Are imports optimized (no full library imports)?", severity: "medium", triggers: ["import", "library", "package"] },
13647
+ { id: "fe-perf-2", category: "performance", text: "Lazy loading: Are heavy components/routes deferred?", severity: "medium", triggers: ["route", "component", "heavy", "large"] },
13648
+ { id: "fe-perf-3", category: "performance", text: "Memoization: Are expensive renders cached (useMemo, React.memo)?", severity: "medium", triggers: ["render", "memo", "expensive", "computation"] },
13649
+ { id: "fe-perf-4", category: "performance", text: "Images: Are they optimized and lazy-loaded?", severity: "medium", triggers: ["image", "img", "picture", "media"] }
13650
+ ],
13651
+ security: [
13652
+ { id: "fe-sec-1", category: "security", text: "XSS: Is user-generated content sanitized before rendering?", severity: "critical", triggers: ["user", "content", "html", "dangerously"] },
13653
+ { id: "fe-sec-2", category: "security", text: "CSRF: Are forms and state-changing requests protected?", severity: "high", triggers: ["form", "submit", "post", "put", "delete"] },
13654
+ { id: "fe-sec-3", category: "security", text: "Sensitive data: Is PII handled correctly (not logged, masked)?", severity: "high", triggers: ["password", "email", "personal", "sensitive"] },
13655
+ { id: "fe-sec-4", category: "security", text: "Dependencies: No known vulnerable packages?", severity: "medium", triggers: ["dependency", "package", "npm"] }
13656
+ ]
13657
+ },
13658
+ template: `## DOMAIN CHECKLIST: Frontend
13659
+
13660
+ Before finalizing, verify each applicable item:
13661
+
13662
+ **Accessibility** (HIGH)
13663
+ - [ ] Semantic HTML: Proper labels and landmarks?
13664
+ - [ ] Keyboard navigation: Works without mouse?
13665
+ - [ ] Screen reader: ARIA labels correct?
13666
+ - [ ] Color contrast: Meets WCAG AA?
13667
+
13668
+ **User Experience** (HIGH)
13669
+ - [ ] Loading states: Async operations indicated?
13670
+ - [ ] Error states: Failures communicated clearly?
13671
+ - [ ] Empty states: Guidance when no data?
13672
+ - [ ] Responsive: Works on all screen sizes?
13673
+
13674
+ **Performance** (MEDIUM)
13675
+ - [ ] Bundle size: Imports optimized?
13676
+ - [ ] Lazy loading: Heavy components deferred?
13677
+ - [ ] Memoization: Expensive renders cached?
13678
+ - [ ] Images: Optimized and lazy-loaded?
13679
+
13680
+ **Security** (CRITICAL-HIGH)
13681
+ - [ ] XSS: User content sanitized?
13682
+ - [ ] CSRF: Forms protected?
13683
+ - [ ] Sensitive data: PII handled correctly?
13684
+ - [ ] Dependencies: No known vulnerabilities?
13685
+
13686
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13687
+ Flag any concerns with [RISK].
13688
+ `
13689
+ };
13690
+ var SECURITY_CHECKLIST = {
13691
+ id: "security",
13692
+ name: "Security Checklist",
13693
+ role: "Security Engineer",
13694
+ categories: {
13695
+ threat_model: [
13696
+ { id: "sec-tm-1", category: "threat_model", text: "Attack surface: What can be attacked? (inputs, APIs, data stores)", severity: "critical", triggers: ["api", "input", "endpoint"] },
13697
+ { id: "sec-tm-2", category: "threat_model", text: "Threat actors: Who would attack this? (script kiddies, insiders, nation states)", severity: "high", triggers: ["user", "access", "public"] },
13698
+ { id: "sec-tm-3", category: "threat_model", text: "Assets: What valuable data/access is at risk?", severity: "critical", triggers: ["data", "pii", "credential", "secret"] },
13699
+ { id: "sec-tm-4", category: "threat_model", text: "STRIDE: Spoofing, Tampering, Repudiation, Info Disclosure, DoS, Elevation?", severity: "high", triggers: ["security", "threat", "vulnerability"] }
13700
+ ],
13701
+ owasp_top_10: [
13702
+ { id: "sec-owasp-1", category: "owasp_top_10", text: "Injection: SQL, NoSQL, OS, LDAP injection possible?", severity: "critical", triggers: ["query", "sql", "database", "command"] },
13703
+ { id: "sec-owasp-2", category: "owasp_top_10", text: "Broken Auth: Session management, credential handling secure?", severity: "critical", triggers: ["auth", "login", "session", "token"] },
13704
+ { id: "sec-owasp-3", category: "owasp_top_10", text: "Sensitive Data: Encryption at rest and in transit?", severity: "critical", triggers: ["encrypt", "https", "data", "store"] },
13705
+ { id: "sec-owasp-4", category: "owasp_top_10", text: "XXE: External entity processing disabled?", severity: "high", triggers: ["xml", "parse", "entity"] },
13706
+ { id: "sec-owasp-5", category: "owasp_top_10", text: "Broken Access Control: Privilege escalation possible?", severity: "critical", triggers: ["role", "permission", "admin", "access"] },
13707
+ { id: "sec-owasp-6", category: "owasp_top_10", text: "Misconfiguration: Default settings, errors exposed?", severity: "high", triggers: ["config", "default", "error", "debug"] },
13708
+ { id: "sec-owasp-7", category: "owasp_top_10", text: "XSS: Reflected, stored, DOM-based XSS possible?", severity: "critical", triggers: ["html", "script", "render", "output"] },
13709
+ { id: "sec-owasp-8", category: "owasp_top_10", text: "Deserialization: Untrusted data deserialized safely?", severity: "high", triggers: ["json", "deserialize", "parse", "object"] },
13710
+ { id: "sec-owasp-9", category: "owasp_top_10", text: "Components: Using components with known vulnerabilities?", severity: "high", triggers: ["dependency", "package", "library", "npm"] },
13711
+ { id: "sec-owasp-10", category: "owasp_top_10", text: "Logging: Insufficient monitoring and logging?", severity: "medium", triggers: ["log", "audit", "monitor", "alert"] }
13712
+ ],
13713
+ secrets: [
13714
+ { id: "sec-secret-1", category: "secrets", text: "No hardcoded secrets in code or config files?", severity: "critical", triggers: ["key", "token", "password", "secret"] },
13715
+ { id: "sec-secret-2", category: "secrets", text: "Environment variables for sensitive config?", severity: "high", triggers: ["env", "config", "setting"] },
13716
+ { id: "sec-secret-3", category: "secrets", text: "Secrets rotation policy in place?", severity: "medium", triggers: ["rotate", "expire", "refresh"] },
13717
+ { id: "sec-secret-4", category: "secrets", text: "Audit logging for secret access?", severity: "medium", triggers: ["audit", "access", "log"] }
13718
+ ]
13719
+ },
13720
+ template: `## DOMAIN CHECKLIST: Security
13721
+
13722
+ Before finalizing, verify each applicable item:
13723
+
13724
+ **Threat Model** (CRITICAL)
13725
+ - [ ] Attack surface: What can be attacked?
13726
+ - [ ] Threat actors: Who would attack this?
13727
+ - [ ] Assets: What valuable data is at risk?
13728
+ - [ ] STRIDE: Spoofing, Tampering, Repudiation, Info Disclosure, DoS, Elevation?
13729
+
13730
+ **OWASP Top 10** (CRITICAL)
13731
+ - [ ] Injection: SQL/NoSQL/OS/LDAP injection possible?
13732
+ - [ ] Broken Auth: Session/credential handling secure?
13733
+ - [ ] Sensitive Data: Encrypted at rest and in transit?
13734
+ - [ ] XXE: External entity processing disabled?
13735
+ - [ ] Broken Access Control: Privilege escalation possible?
13736
+ - [ ] Misconfiguration: Defaults secured, errors hidden?
13737
+ - [ ] XSS: Reflected/stored/DOM XSS prevented?
13738
+ - [ ] Deserialization: Untrusted data handled safely?
13739
+ - [ ] Components: No known vulnerable dependencies?
13740
+ - [ ] Logging: Sufficient monitoring and alerting?
13741
+
13742
+ **Secrets Management** (CRITICAL)
13743
+ - [ ] No hardcoded secrets in code?
13744
+ - [ ] Env vars for sensitive config?
13745
+ - [ ] Rotation policy exists?
13746
+ - [ ] Audit logging for access?
13747
+
13748
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13749
+ Flag any concerns with [RISK].
13750
+ `
13751
+ };
13752
+ var QUALITY_CHECKLIST = {
13753
+ id: "quality",
13754
+ name: "Quality Checklist",
13755
+ role: "QA Engineer",
13756
+ categories: {
13757
+ test_scope: [
13758
+ { id: "qa-scope-1", category: "test_scope", text: "Requirements: Are all requirements covered by tests?", severity: "high", triggers: ["requirement", "spec", "feature"] },
13759
+ { id: "qa-scope-2", category: "test_scope", text: "Edge cases: Are boundary conditions tested?", severity: "high", triggers: ["edge", "boundary", "limit", "max", "min"] },
13760
+ { id: "qa-scope-3", category: "test_scope", text: "Error paths: Are failure scenarios tested?", severity: "high", triggers: ["error", "fail", "exception", "invalid"] },
13761
+ { id: "qa-scope-4", category: "test_scope", text: "Integration points: Are interfaces tested?", severity: "medium", triggers: ["api", "interface", "integration", "external"] }
13762
+ ],
13763
+ test_quality: [
13764
+ { id: "qa-qual-1", category: "test_quality", text: "Isolation: Are tests independent (no shared state)?", severity: "high", triggers: ["test", "describe", "it"] },
13765
+ { id: "qa-qual-2", category: "test_quality", text: "Determinism: Do tests pass consistently (no flakiness)?", severity: "high", triggers: ["flaky", "random", "timeout", "intermittent"] },
13766
+ { id: "qa-qual-3", category: "test_quality", text: "Speed: Are tests fast enough for CI feedback loop?", severity: "medium", triggers: ["slow", "timeout", "performance"] },
13767
+ { id: "qa-qual-4", category: "test_quality", text: "Readability: Can failures be diagnosed quickly?", severity: "medium", triggers: ["message", "assert", "expect"] }
13768
+ ],
13769
+ regression: [
13770
+ { id: "qa-reg-1", category: "regression", text: "Existing tests: Do all existing tests still pass?", severity: "critical", triggers: ["change", "modify", "update"] },
13771
+ { id: "qa-reg-2", category: "regression", text: "Coverage: Has test coverage decreased?", severity: "high", triggers: ["coverage", "uncovered", "gap"] },
13772
+ { id: "qa-reg-3", category: "regression", text: "Breaking changes: Are APIs backward compatible?", severity: "high", triggers: ["api", "interface", "contract", "public"] },
13773
+ { id: "qa-reg-4", category: "regression", text: "Performance: Has latency/memory regressed?", severity: "medium", triggers: ["performance", "latency", "memory", "slow"] }
13774
+ ],
13775
+ validation: [
13776
+ { id: "qa-val-1", category: "validation", text: "Reproducibility: Can the bug/behavior be reproduced?", severity: "high", triggers: ["bug", "issue", "reproduce"] },
13777
+ { id: "qa-val-2", category: "validation", text: "Root cause: Is the fix addressing the root cause?", severity: "high", triggers: ["fix", "patch", "resolve"] },
13778
+ { id: "qa-val-3", category: "validation", text: "Side effects: Are there unintended changes?", severity: "medium", triggers: ["change", "affect", "impact"] },
13779
+ { id: "qa-val-4", category: "validation", text: "Documentation: Are test changes documented?", severity: "low", triggers: ["doc", "comment", "readme"] }
13780
+ ]
13781
+ },
13782
+ template: `## DOMAIN CHECKLIST: Quality
13783
+
13784
+ Before finalizing, verify each applicable item:
13785
+
13786
+ **Test Scope** (HIGH)
13787
+ - [ ] Requirements: All requirements covered?
13788
+ - [ ] Edge cases: Boundary conditions tested?
13789
+ - [ ] Error paths: Failure scenarios tested?
13790
+ - [ ] Integration points: Interfaces tested?
13791
+
13792
+ **Test Quality** (HIGH)
13793
+ - [ ] Isolation: Tests independent (no shared state)?
13794
+ - [ ] Determinism: Tests pass consistently?
13795
+ - [ ] Speed: Fast enough for CI?
13796
+ - [ ] Readability: Failures diagnosable?
13797
+
13798
+ **Regression** (CRITICAL)
13799
+ - [ ] Existing tests: All still pass?
13800
+ - [ ] Coverage: Not decreased?
13801
+ - [ ] Breaking changes: APIs compatible?
13802
+ - [ ] Performance: No regression?
13803
+
13804
+ **Validation** (HIGH)
13805
+ - [ ] Reproducibility: Bug reproducible?
13806
+ - [ ] Root cause: Fix addresses cause?
13807
+ - [ ] Side effects: No unintended changes?
13808
+ - [ ] Documentation: Changes documented?
13809
+
13810
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13811
+ Flag any concerns with [RISK].
13812
+ `
13813
+ };
13814
+ var ARCHITECTURE_CHECKLIST = {
13815
+ id: "architecture",
13816
+ name: "Architecture Checklist",
13817
+ role: "Software Architect",
13818
+ categories: {
13819
+ design: [
13820
+ { id: "arch-des-1", category: "design", text: "Requirements alignment: Does it solve the right problem?", severity: "critical", triggers: ["design", "architecture", "system"] },
13821
+ { id: "arch-des-2", category: "design", text: "Simplicity: Is this the simplest viable solution?", severity: "high", triggers: ["complex", "simple", "pattern"] },
13822
+ { id: "arch-des-3", category: "design", text: "Extensibility: Can it evolve with future needs?", severity: "medium", triggers: ["future", "extend", "scale"] },
13823
+ { id: "arch-des-4", category: "design", text: "Consistency: Does it follow existing patterns?", severity: "high", triggers: ["pattern", "convention", "style"] }
13824
+ ],
13825
+ trade_offs: [
13826
+ { id: "arch-trade-1", category: "trade_offs", text: "Performance vs. complexity trade-off documented?", severity: "high", triggers: ["performance", "complexity", "trade"] },
13827
+ { id: "arch-trade-2", category: "trade_offs", text: "Build vs. buy decision documented?", severity: "medium", triggers: ["build", "buy", "library", "vendor"] },
13828
+ { id: "arch-trade-3", category: "trade_offs", text: "Technology choices justified?", severity: "high", triggers: ["technology", "framework", "language"] },
13829
+ { id: "arch-trade-4", category: "trade_offs", text: "Rejected alternatives documented?", severity: "medium", triggers: ["alternative", "option", "consider"] }
13830
+ ],
13831
+ risk: [
13832
+ { id: "arch-risk-1", category: "risk", text: "Single points of failure identified?", severity: "critical", triggers: ["single", "failure", "dependency"] },
13833
+ { id: "arch-risk-2", category: "risk", text: "Scalability bottlenecks identified?", severity: "high", triggers: ["scale", "bottleneck", "limit"] },
13834
+ { id: "arch-risk-3", category: "risk", text: "Security implications considered?", severity: "critical", triggers: ["security", "auth", "data"] },
13835
+ { id: "arch-risk-4", category: "risk", text: "Operational complexity acceptable?", severity: "medium", triggers: ["ops", "deploy", "maintain"] }
13836
+ ],
13837
+ governance: [
13838
+ { id: "arch-gov-1", category: "governance", text: "ADR created for significant decisions?", severity: "high", triggers: ["decision", "adr", "architecture"] },
13839
+ { id: "arch-gov-2", category: "governance", text: "Stakeholders consulted?", severity: "medium", triggers: ["stakeholder", "team", "review"] },
13840
+ { id: "arch-gov-3", category: "governance", text: "Migration path defined?", severity: "high", triggers: ["migrate", "transition", "phase"] },
13841
+ { id: "arch-gov-4", category: "governance", text: "Rollback strategy exists?", severity: "high", triggers: ["rollback", "revert", "undo"] }
13842
+ ]
13843
+ },
13844
+ template: `## DOMAIN CHECKLIST: Architecture
13845
+
13846
+ Before finalizing, verify each applicable item:
13847
+
13848
+ **Design** (CRITICAL-HIGH)
13849
+ - [ ] Requirements alignment: Solves the right problem?
13850
+ - [ ] Simplicity: Simplest viable solution?
13851
+ - [ ] Extensibility: Can evolve with future needs?
13852
+ - [ ] Consistency: Follows existing patterns?
13853
+
13854
+ **Trade-offs** (HIGH)
13855
+ - [ ] Performance vs. complexity documented?
13856
+ - [ ] Build vs. buy decision documented?
13857
+ - [ ] Technology choices justified?
13858
+ - [ ] Rejected alternatives documented?
13859
+
13860
+ **Risk** (CRITICAL)
13861
+ - [ ] Single points of failure identified?
13862
+ - [ ] Scalability bottlenecks identified?
13863
+ - [ ] Security implications considered?
13864
+ - [ ] Operational complexity acceptable?
13865
+
13866
+ **Governance** (HIGH)
13867
+ - [ ] ADR created for significant decisions?
13868
+ - [ ] Stakeholders consulted?
13869
+ - [ ] Migration path defined?
13870
+ - [ ] Rollback strategy exists?
13871
+
13872
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13873
+ Flag any concerns with [RISK].
13874
+ `
13875
+ };
13876
+ var DEVOPS_CHECKLIST = {
13877
+ id: "devops",
13878
+ name: "DevOps Checklist",
13879
+ role: "DevOps Engineer",
13880
+ categories: {
13881
+ deployment: [
13882
+ { id: "devops-dep-1", category: "deployment", text: "Zero-downtime: Can deploy without service interruption?", severity: "high", triggers: ["deploy", "release", "rollout"] },
13883
+ { id: "devops-dep-2", category: "deployment", text: "Rollback: Can quickly revert if issues arise?", severity: "critical", triggers: ["rollback", "revert", "fail"] },
13884
+ { id: "devops-dep-3", category: "deployment", text: "Configuration: Env-specific configs separated from code?", severity: "high", triggers: ["config", "env", "environment"] },
13885
+ { id: "devops-dep-4", category: "deployment", text: "Secrets: Managed securely (not in code/config)?", severity: "critical", triggers: ["secret", "key", "credential"] }
13886
+ ],
13887
+ infrastructure: [
13888
+ { id: "devops-infra-1", category: "infrastructure", text: "IaC: Infrastructure defined as code?", severity: "high", triggers: ["infrastructure", "terraform", "kubernetes"] },
13889
+ { id: "devops-infra-2", category: "infrastructure", text: "Scaling: Auto-scaling configured correctly?", severity: "high", triggers: ["scale", "auto", "capacity"] },
13890
+ { id: "devops-infra-3", category: "infrastructure", text: "Resources: CPU/memory limits appropriate?", severity: "medium", triggers: ["resource", "memory", "cpu", "limit"] },
13891
+ { id: "devops-infra-4", category: "infrastructure", text: "Networking: Security groups and firewalls configured?", severity: "high", triggers: ["network", "firewall", "security group"] }
13892
+ ],
13893
+ observability: [
13894
+ { id: "devops-obs-1", category: "observability", text: "Logging: Structured logs with correlation IDs?", severity: "high", triggers: ["log", "logging", "trace"] },
13895
+ { id: "devops-obs-2", category: "observability", text: "Metrics: Key metrics exposed and collected?", severity: "high", triggers: ["metric", "prometheus", "grafana"] },
13896
+ { id: "devops-obs-3", category: "observability", text: "Alerting: Alerts configured for critical conditions?", severity: "high", triggers: ["alert", "notify", "oncall"] },
13897
+ { id: "devops-obs-4", category: "observability", text: "Dashboards: Visibility into system health?", severity: "medium", triggers: ["dashboard", "monitor", "visualize"] }
13898
+ ],
13899
+ reliability: [
13900
+ { id: "devops-rel-1", category: "reliability", text: "Health checks: Liveness and readiness probes configured?", severity: "high", triggers: ["health", "probe", "check"] },
13901
+ { id: "devops-rel-2", category: "reliability", text: "Disaster recovery: Backup and restore tested?", severity: "critical", triggers: ["backup", "restore", "disaster"] },
13902
+ { id: "devops-rel-3", category: "reliability", text: "Failover: Multi-region/AZ redundancy?", severity: "high", triggers: ["failover", "redundancy", "region", "availability"] },
13903
+ { id: "devops-rel-4", category: "reliability", text: "Runbooks: Incident response procedures documented?", severity: "medium", triggers: ["runbook", "incident", "procedure"] }
13904
+ ]
13905
+ },
13906
+ template: `## DOMAIN CHECKLIST: DevOps
13907
+
13908
+ Before finalizing, verify each applicable item:
13909
+
13910
+ **Deployment** (CRITICAL-HIGH)
13911
+ - [ ] Zero-downtime: Deploy without interruption?
13912
+ - [ ] Rollback: Can quickly revert?
13913
+ - [ ] Configuration: Env-specific configs separated?
13914
+ - [ ] Secrets: Managed securely?
13915
+
13916
+ **Infrastructure** (HIGH)
13917
+ - [ ] IaC: Infrastructure as code?
13918
+ - [ ] Scaling: Auto-scaling configured?
13919
+ - [ ] Resources: CPU/memory limits appropriate?
13920
+ - [ ] Networking: Security groups configured?
13921
+
13922
+ **Observability** (HIGH)
13923
+ - [ ] Logging: Structured with correlation IDs?
13924
+ - [ ] Metrics: Key metrics collected?
13925
+ - [ ] Alerting: Critical alerts configured?
13926
+ - [ ] Dashboards: System health visible?
13927
+
13928
+ **Reliability** (CRITICAL-HIGH)
13929
+ - [ ] Health checks: Probes configured?
13930
+ - [ ] Disaster recovery: Backup/restore tested?
13931
+ - [ ] Failover: Multi-region redundancy?
13932
+ - [ ] Runbooks: Incident procedures documented?
13933
+
13934
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13935
+ Flag any concerns with [RISK].
13936
+ `
13937
+ };
13938
+ var DATA_CHECKLIST = {
13939
+ id: "data",
13940
+ name: "Data Checklist",
13941
+ role: "Data Engineer",
13942
+ categories: {
13943
+ data_quality: [
13944
+ { id: "data-qual-1", category: "data_quality", text: "Schema validation: Data conforms to expected schema?", severity: "high", triggers: ["schema", "type", "validate"] },
13945
+ { id: "data-qual-2", category: "data_quality", text: "Null handling: Missing values handled appropriately?", severity: "high", triggers: ["null", "missing", "empty"] },
13946
+ { id: "data-qual-3", category: "data_quality", text: "Duplicates: Deduplication strategy in place?", severity: "medium", triggers: ["duplicate", "unique", "distinct"] },
13947
+ { id: "data-qual-4", category: "data_quality", text: "Freshness: Data SLAs defined and monitored?", severity: "medium", triggers: ["fresh", "stale", "latency", "sla"] }
13948
+ ],
13949
+ pipeline: [
13950
+ { id: "data-pipe-1", category: "pipeline", text: "Idempotency: Pipeline can be safely re-run?", severity: "high", triggers: ["pipeline", "etl", "process"] },
13951
+ { id: "data-pipe-2", category: "pipeline", text: "Error handling: Failed records captured for review?", severity: "high", triggers: ["error", "fail", "dead letter"] },
13952
+ { id: "data-pipe-3", category: "pipeline", text: "Backfill: Historical data can be reprocessed?", severity: "medium", triggers: ["backfill", "historical", "reprocess"] },
13953
+ { id: "data-pipe-4", category: "pipeline", text: "Monitoring: Pipeline health and progress visible?", severity: "high", triggers: ["monitor", "alert", "status"] }
13954
+ ],
13955
+ governance: [
13956
+ { id: "data-gov-1", category: "governance", text: "Lineage: Data origin and transformations documented?", severity: "medium", triggers: ["lineage", "origin", "source"] },
13957
+ { id: "data-gov-2", category: "governance", text: "Privacy: PII identified and protected?", severity: "critical", triggers: ["pii", "privacy", "gdpr", "personal"] },
13958
+ { id: "data-gov-3", category: "governance", text: "Retention: Data lifecycle and deletion policies?", severity: "high", triggers: ["retention", "delete", "archive"] },
13959
+ { id: "data-gov-4", category: "governance", text: "Access control: Data access properly restricted?", severity: "high", triggers: ["access", "permission", "role"] }
13960
+ ],
13961
+ performance: [
13962
+ { id: "data-perf-1", category: "performance", text: "Partitioning: Data partitioned for query efficiency?", severity: "high", triggers: ["partition", "query", "large"] },
13963
+ { id: "data-perf-2", category: "performance", text: "Indexing: Appropriate indexes for access patterns?", severity: "high", triggers: ["index", "search", "filter"] },
13964
+ { id: "data-perf-3", category: "performance", text: "Compression: Storage optimized with compression?", severity: "medium", triggers: ["compress", "storage", "size"] },
13965
+ { id: "data-perf-4", category: "performance", text: "Caching: Frequently accessed data cached?", severity: "medium", triggers: ["cache", "frequent", "hot"] }
13966
+ ]
13967
+ },
13968
+ template: `## DOMAIN CHECKLIST: Data
13969
+
13970
+ Before finalizing, verify each applicable item:
13971
+
13972
+ **Data Quality** (HIGH)
13973
+ - [ ] Schema validation: Conforms to expected schema?
13974
+ - [ ] Null handling: Missing values handled?
13975
+ - [ ] Duplicates: Deduplication in place?
13976
+ - [ ] Freshness: Data SLAs defined?
13977
+
13978
+ **Pipeline** (HIGH)
13979
+ - [ ] Idempotency: Safe to re-run?
13980
+ - [ ] Error handling: Failed records captured?
13981
+ - [ ] Backfill: Historical reprocessing possible?
13982
+ - [ ] Monitoring: Pipeline health visible?
13983
+
13984
+ **Governance** (CRITICAL-HIGH)
13985
+ - [ ] Lineage: Origin and transforms documented?
13986
+ - [ ] Privacy: PII identified and protected?
13987
+ - [ ] Retention: Lifecycle policies defined?
13988
+ - [ ] Access control: Properly restricted?
13989
+
13990
+ **Performance** (HIGH)
13991
+ - [ ] Partitioning: Query-efficient partitions?
13992
+ - [ ] Indexing: Appropriate indexes?
13993
+ - [ ] Compression: Storage optimized?
13994
+ - [ ] Caching: Hot data cached?
13995
+
13996
+ Mark items as [x] when verified, or note [N/A] if not applicable.
13997
+ Flag any concerns with [RISK].
13998
+ `
13999
+ };
14000
+ var PRODUCT_CHECKLIST = {
14001
+ id: "product",
14002
+ name: "Product Checklist",
14003
+ role: "Product Manager",
14004
+ categories: {
14005
+ requirements: [
14006
+ { id: "prod-req-1", category: "requirements", text: "User problem: Is the problem clearly defined?", severity: "critical", triggers: ["user", "problem", "pain"] },
14007
+ { id: "prod-req-2", category: "requirements", text: "Success criteria: How will we measure success?", severity: "high", triggers: ["success", "metric", "kpi"] },
14008
+ { id: "prod-req-3", category: "requirements", text: "Scope: Is scope clearly bounded?", severity: "high", triggers: ["scope", "feature", "requirement"] },
14009
+ { id: "prod-req-4", category: "requirements", text: 'Acceptance criteria: What defines "done"?', severity: "high", triggers: ["done", "accept", "criteria"] }
14010
+ ],
14011
+ stakeholders: [
14012
+ { id: "prod-stake-1", category: "stakeholders", text: "Alignment: Key stakeholders aligned on approach?", severity: "high", triggers: ["stakeholder", "team", "align"] },
14013
+ { id: "prod-stake-2", category: "stakeholders", text: "Dependencies: Cross-team dependencies identified?", severity: "medium", triggers: ["dependency", "team", "coordinate"] },
14014
+ { id: "prod-stake-3", category: "stakeholders", text: "Communication: Rollout communication planned?", severity: "medium", triggers: ["communicate", "announce", "rollout"] },
14015
+ { id: "prod-stake-4", category: "stakeholders", text: "Feedback: User feedback collection planned?", severity: "medium", triggers: ["feedback", "user", "research"] }
14016
+ ],
14017
+ delivery: [
14018
+ { id: "prod-del-1", category: "delivery", text: "Timeline: Realistic timeline established?", severity: "high", triggers: ["timeline", "deadline", "schedule"] },
14019
+ { id: "prod-del-2", category: "delivery", text: "Risks: Key risks identified and mitigated?", severity: "high", triggers: ["risk", "blocker", "issue"] },
14020
+ { id: "prod-del-3", category: "delivery", text: "MVP: Minimum viable scope defined?", severity: "high", triggers: ["mvp", "minimum", "viable"] },
14021
+ { id: "prod-del-4", category: "delivery", text: "Rollback: Can we undo if issues arise?", severity: "medium", triggers: ["rollback", "undo", "revert"] }
14022
+ ]
14023
+ },
14024
+ template: `## DOMAIN CHECKLIST: Product
14025
+
14026
+ Before finalizing, verify each applicable item:
14027
+
14028
+ **Requirements** (CRITICAL-HIGH)
14029
+ - [ ] User problem: Problem clearly defined?
14030
+ - [ ] Success criteria: How measured?
14031
+ - [ ] Scope: Clearly bounded?
14032
+ - [ ] Acceptance criteria: What defines "done"?
14033
+
14034
+ **Stakeholders** (HIGH-MEDIUM)
14035
+ - [ ] Alignment: Key stakeholders aligned?
14036
+ - [ ] Dependencies: Cross-team deps identified?
14037
+ - [ ] Communication: Rollout planned?
14038
+ - [ ] Feedback: Collection planned?
14039
+
14040
+ **Delivery** (HIGH)
14041
+ - [ ] Timeline: Realistic?
14042
+ - [ ] Risks: Identified and mitigated?
14043
+ - [ ] MVP: Minimum scope defined?
14044
+ - [ ] Rollback: Can undo if needed?
14045
+
14046
+ Mark items as [x] when verified, or note [N/A] if not applicable.
14047
+ Flag any concerns with [RISK].
14048
+ `
14049
+ };
14050
+ var NONE_CHECKLIST = {
14051
+ id: "none",
14052
+ name: "No Checklist",
14053
+ role: "General",
14054
+ categories: {},
14055
+ template: ""
14056
+ };
14057
+ var CHECKLISTS = {
14058
+ backend: BACKEND_CHECKLIST,
14059
+ frontend: FRONTEND_CHECKLIST,
14060
+ security: SECURITY_CHECKLIST,
14061
+ quality: QUALITY_CHECKLIST,
14062
+ architecture: ARCHITECTURE_CHECKLIST,
14063
+ devops: DEVOPS_CHECKLIST,
14064
+ data: DATA_CHECKLIST,
14065
+ product: PRODUCT_CHECKLIST,
14066
+ none: NONE_CHECKLIST
14067
+ };
14068
+ function getRoleChecklist(type) {
14069
+ const checklist = CHECKLISTS[type];
14070
+ if (!checklist) {
14071
+ throw new Error(`Unknown checklist type: ${type}`);
14072
+ }
14073
+ return checklist;
14074
+ }
14075
+ function getChecklistTemplate(type) {
14076
+ return getRoleChecklist(type).template;
14077
+ }
14078
+ function applyChecklistOverrides(type, overrides) {
14079
+ let template = getChecklistTemplate(type);
14080
+ if (overrides.remove && overrides.remove.length > 0) {
14081
+ for (const item of overrides.remove) {
14082
+ const regex = new RegExp(`^- \\[ \\] .*${item}.*$`, "gm");
14083
+ template = template.replace(regex, "");
14084
+ }
14085
+ template = template.replace(/\n\n+/g, "\n\n");
14086
+ }
14087
+ if (overrides.add && overrides.add.length > 0) {
14088
+ const customSection = `
14089
+ **Custom Checks**
14090
+ ${overrides.add.map((item) => `- [ ] ${item}`).join("\n")}
14091
+ `;
14092
+ template = template.replace(/Mark items as \[x\]/, customSection + "\nMark items as [x]");
14093
+ }
14094
+ return template;
14095
+ }
14096
+
14097
+ // src/agents/cognitive/output-contracts.ts
14098
+ init_esm_shims();
14099
+ var STANDARD_SECTIONS = [
14100
+ {
14101
+ name: "Context",
14102
+ required: true,
14103
+ description: "What was understood about the task",
14104
+ format: `**Context**
14105
+ - Goal: [restated objective in your own words]
14106
+ - Constraints: [key limitations or requirements]
14107
+ - Assumptions: [what was assumed - be explicit]`
14108
+ },
14109
+ {
14110
+ name: "Plan",
14111
+ required: true,
14112
+ description: "What will be/was done",
14113
+ format: `**Plan**
14114
+ 1. [Step 1]
14115
+ 2. [Step 2]
14116
+ 3. [Step 3]
14117
+ ...
14118
+ (For trivial tasks: "Plan: Single-step execution")`
14119
+ },
14120
+ {
14121
+ name: "Actions",
14122
+ required: true,
14123
+ description: "What was actually done",
14124
+ format: `**Actions**
14125
+ - [Action 1]: \`path/to/file.ts:line\` - [brief description]
14126
+ - [Action 2]: \`path/to/file.ts:line\` - [brief description]
14127
+ - [Command run]: \`pnpm test\` - [result summary]
14128
+ ...`
14129
+ },
14130
+ {
14131
+ name: "Verification",
14132
+ required: true,
14133
+ description: "How the work was validated",
14134
+ format: `**Verification**
14135
+ - Validated:
14136
+ - [x] [What was tested/checked]
14137
+ - [x] [Another validation]
14138
+ - Commands run:
14139
+ - \`pnpm typecheck\` - [result]
14140
+ - \`pnpm test path/to/test\` - [result]
14141
+ - Gaps (not validated):
14142
+ - [ ] [What was NOT tested and why]`
14143
+ },
14144
+ {
14145
+ name: "Risks",
14146
+ required: true,
14147
+ description: "What could go wrong or needs attention",
14148
+ format: `**Risks**
14149
+ - [Risk 1]: [SEVERITY: LOW/MEDIUM/HIGH/CRITICAL] - [mitigation or note]
14150
+ - [Risk 2]: [SEVERITY] - [mitigation or note]
14151
+ (If none: "Risks: None identified for this change")`
14152
+ },
14153
+ {
14154
+ name: "Next Steps",
14155
+ required: true,
14156
+ description: "What should happen after this",
14157
+ format: `**Next Steps**
14158
+ - [ ] [Recommended action 1]
14159
+ - [ ] [Recommended action 2]
14160
+ (If complete: "Next Steps: Ready for review/merge")`
14161
+ }
14162
+ ];
14163
+ var FAILURE_SECTIONS = [
14164
+ {
14165
+ name: "Failure",
14166
+ required: true,
14167
+ description: "What failed and why",
14168
+ format: `**Failure**
14169
+ - What failed: [description of the failure]
14170
+ - Root cause: [analysis of why it failed]
14171
+ - Attempted recovery: [what was tried to fix it]
14172
+ - Blocked: [yes/no] - [what's needed to proceed]`
14173
+ }
14174
+ ];
14175
+ var STANDARD_CONTRACT = {
14176
+ id: "standard",
14177
+ name: "Standard Output",
14178
+ description: "Full structured output with all sections for complete transparency",
14179
+ sections: STANDARD_SECTIONS,
14180
+ failureSections: FAILURE_SECTIONS,
14181
+ template: `## OUTPUT FORMAT
14182
+
14183
+ Structure your response with these sections:
14184
+
14185
+ **Context**
14186
+ - Goal: [restated objective]
14187
+ - Constraints: [key limitations]
14188
+ - Assumptions: [what was assumed]
14189
+
14190
+ **Plan**
14191
+ 1. [Step 1]
14192
+ 2. [Step 2]
14193
+ (For trivial tasks: "Plan: Single-step execution")
14194
+
14195
+ **Actions**
14196
+ - [Action]: \`path/to/file.ts:line\` - [description]
14197
+ - [Command]: \`command\` - [result]
14198
+
14199
+ **Verification**
14200
+ - Validated:
14201
+ - [x] [What was tested]
14202
+ - Commands: \`pnpm typecheck\`, \`pnpm test\`
14203
+ - Gaps: [What was NOT tested]
14204
+
14205
+ **Risks**
14206
+ - [Risk]: [SEVERITY] - [mitigation]
14207
+ (If none: "Risks: None identified")
14208
+
14209
+ **Next Steps**
14210
+ - [ ] [Action item]
14211
+ (If complete: "Ready for review")
14212
+
14213
+ ---
14214
+
14215
+ **If something fails, add:**
14216
+
14217
+ **Failure**
14218
+ - What failed: [description]
14219
+ - Root cause: [analysis]
14220
+ - Attempted recovery: [what was tried]
14221
+ - Blocked: [yes/no, what's needed]
14222
+ `
14223
+ };
14224
+ var MINIMAL_SECTIONS = [
14225
+ {
14226
+ name: "Done",
14227
+ required: true,
14228
+ description: "What was done",
14229
+ format: `**Done**
14230
+ - [Action]: \`file:line\``
14231
+ },
14232
+ {
14233
+ name: "Verified",
14234
+ required: true,
14235
+ description: "How it was verified",
14236
+ format: `**Verified**: [command or check]`
14237
+ },
14238
+ {
14239
+ name: "Note",
14240
+ required: false,
14241
+ description: "Any important notes",
14242
+ format: `**Note**: [anything important]`
14243
+ }
14244
+ ];
14245
+ var MINIMAL_CONTRACT = {
14246
+ id: "minimal",
14247
+ name: "Minimal Output",
14248
+ description: "Condensed output for simple tasks",
14249
+ sections: MINIMAL_SECTIONS,
14250
+ template: `## OUTPUT FORMAT (MINIMAL)
14251
+
14252
+ For simple tasks, use this condensed format:
14253
+
14254
+ **Done**
14255
+ - [Action]: \`file:line\`
14256
+
14257
+ **Verified**: [command or "visual check"]
14258
+
14259
+ **Note**: [anything important, or omit if none]
14260
+ `
14261
+ };
14262
+ var DETAILED_SECTIONS = [
14263
+ ...STANDARD_SECTIONS,
14264
+ {
14265
+ name: "Options Considered",
14266
+ required: false,
14267
+ description: "Alternatives that were evaluated",
14268
+ format: `**Options Considered**
14269
+ | Option | Pros | Cons | Why Chosen/Rejected |
14270
+ |--------|------|------|---------------------|
14271
+ | [Option 1] | [pros] | [cons] | [rationale] |
14272
+ | [Option 2] | [pros] | [cons] | [rationale] |`
14273
+ },
14274
+ {
14275
+ name: "Dependencies",
14276
+ required: false,
14277
+ description: "Dependencies and related changes",
14278
+ format: `**Dependencies**
14279
+ - Upstream: [what this depends on]
14280
+ - Downstream: [what depends on this]
14281
+ - Related: [related tickets/PRs]`
14282
+ },
14283
+ {
14284
+ name: "Rollback Plan",
14285
+ required: false,
14286
+ description: "How to undo if needed",
14287
+ format: `**Rollback Plan**
14288
+ 1. [Step to revert]
14289
+ 2. [Step to verify revert]`
14290
+ }
14291
+ ];
14292
+ var DETAILED_CONTRACT = {
14293
+ id: "detailed",
14294
+ name: "Detailed Output",
14295
+ description: "Extended output for complex tasks requiring more documentation",
14296
+ sections: DETAILED_SECTIONS,
14297
+ failureSections: FAILURE_SECTIONS,
14298
+ template: `## OUTPUT FORMAT (DETAILED)
14299
+
14300
+ For complex tasks, use this extended format:
14301
+
14302
+ **Context**
14303
+ - Goal: [restated objective]
14304
+ - Constraints: [key limitations]
14305
+ - Assumptions: [what was assumed]
14306
+
14307
+ **Options Considered** (if applicable)
14308
+ | Option | Pros | Cons | Decision |
14309
+ |--------|------|------|----------|
14310
+ | [Option 1] | [pros] | [cons] | [Chosen/Rejected: why] |
14311
+
14312
+ **Plan**
14313
+ 1. [Step 1]
14314
+ 2. [Step 2]
14315
+
14316
+ **Actions**
14317
+ - [Action]: \`path/to/file.ts:line\` - [description]
14318
+ - [Command]: \`command\` - [result]
14319
+
14320
+ **Verification**
14321
+ - Validated:
14322
+ - [x] [What was tested]
14323
+ - Commands: \`pnpm typecheck\`, \`pnpm test\`
14324
+ - Gaps: [What was NOT tested]
14325
+
14326
+ **Dependencies** (if applicable)
14327
+ - Upstream: [what this depends on]
14328
+ - Downstream: [what depends on this]
14329
+
14330
+ **Risks**
14331
+ - [Risk]: [SEVERITY] - [mitigation]
14332
+
14333
+ **Rollback Plan** (if applicable)
14334
+ 1. [How to undo]
14335
+
14336
+ **Next Steps**
14337
+ - [ ] [Action item]
14338
+ `
14339
+ };
14340
+ var CONTRACTS = {
14341
+ standard: STANDARD_CONTRACT,
14342
+ minimal: MINIMAL_CONTRACT,
14343
+ detailed: DETAILED_CONTRACT
14344
+ };
14345
+ function getOutputContract(type) {
14346
+ const contract = CONTRACTS[type];
14347
+ if (!contract) {
14348
+ throw new Error(`Unknown output contract: ${type}`);
14349
+ }
14350
+ return contract;
14351
+ }
14352
+ function getContractTemplate(type) {
14353
+ return getOutputContract(type).template;
14354
+ }
14355
+
14356
+ // src/agents/cognitive/uncertainty-protocol.ts
14357
+ init_esm_shims();
14358
+ var ASK_FIRST_PROTOCOL = {
14359
+ id: "ask_first",
14360
+ name: "Ask First",
14361
+ askWhen: [
14362
+ "Requirements are ambiguous or could be interpreted multiple ways",
14363
+ "Security or data implications require explicit authorization",
14364
+ "Change scope significantly exceeds the original request",
14365
+ "Irreversible actions are required (delete, migrate, deploy to production)",
14366
+ "You need access to resources, credentials, or information not available",
14367
+ "Multiple valid approaches exist and user preference is unknown",
14368
+ "The task involves user-facing changes where UX matters",
14369
+ "You are making assumptions about business logic"
14370
+ ],
14371
+ proceedWhen: [
14372
+ "The request is completely unambiguous",
14373
+ "You are applying a well-documented standard or best practice",
14374
+ "The change is trivial and easily reversible"
14375
+ ],
14376
+ assumptionFormat: `**Clarification Needed**
14377
+
14378
+ Before proceeding, I need to clarify:
14379
+
14380
+ 1. [Question 1 - be specific about what you need to know]
14381
+ 2. [Question 2 - if applicable]
14382
+
14383
+ This will help ensure I deliver exactly what you need.`,
14384
+ template: `## UNCERTAINTY HANDLING (ASK FIRST)
14385
+
14386
+ **Default behavior**: Ask for clarification when uncertain.
14387
+
14388
+ **Ask when** (any of these apply):
14389
+ - Requirements could be interpreted multiple ways
14390
+ - Security or data implications exist
14391
+ - Change scope exceeds original request
14392
+ - Irreversible actions required
14393
+ - Multiple valid approaches exist
14394
+ - Business logic assumptions needed
14395
+
14396
+ **Only proceed without asking when**:
14397
+ - Request is completely unambiguous
14398
+ - Applying documented standard/best practice
14399
+ - Change is trivial and reversible
14400
+
14401
+ **When asking, use this format:**
14402
+
14403
+ **Clarification Needed**
14404
+
14405
+ Before proceeding, I need to clarify:
14406
+
14407
+ 1. [Specific question]
14408
+ 2. [Specific question if needed]
14409
+
14410
+ This ensures I deliver exactly what you need.
14411
+
14412
+ ---
14413
+
14414
+ **Confidence Tagging**: Tag recommendations with confidence level.
14415
+ - **[HIGH]**: Well-established pattern, verified approach
14416
+ - **[MEDIUM]**: Reasonable approach, some assumptions
14417
+ - **[LOW]**: Exploratory, needs validation
14418
+ `
14419
+ };
14420
+ var PROCEED_PROTOCOL = {
14421
+ id: "proceed_with_assumptions",
14422
+ name: "Proceed With Assumptions",
14423
+ askWhen: [
14424
+ "Security-critical decisions require explicit authorization",
14425
+ "Irreversible actions that cannot be undone (data deletion, production deploy)",
14426
+ "Change would break existing functionality or APIs",
14427
+ "You are completely blocked and cannot make progress"
14428
+ ],
14429
+ proceedWhen: [
14430
+ "Best practice clearly applies to the situation",
14431
+ "Change is safely reversible (can be undone easily)",
14432
+ "Scope is well-defined and bounded",
14433
+ "Similar patterns exist in the codebase",
14434
+ "You can make reasonable assumptions based on context",
14435
+ "The risk of proceeding is low"
14436
+ ],
14437
+ assumptionFormat: `**Assumptions Made**
14438
+
14439
+ I proceeded with these assumptions:
14440
+ - [Assumption 1]: [rationale for this assumption]
14441
+ - [Assumption 2]: [rationale]
14442
+
14443
+ If any are incorrect, let me know and I'll adjust.`,
14444
+ template: `## UNCERTAINTY HANDLING (PROCEED WITH ASSUMPTIONS)
14445
+
14446
+ **Default behavior**: Proceed and document assumptions.
14447
+
14448
+ **Only stop and ask when**:
14449
+ - Security-critical decisions need authorization
14450
+ - Irreversible actions that cannot be undone
14451
+ - Change would break existing functionality
14452
+ - Completely blocked with no path forward
14453
+
14454
+ **Proceed (with documented assumptions) when**:
14455
+ - Best practice clearly applies
14456
+ - Change is safely reversible
14457
+ - Similar patterns exist in codebase
14458
+ - Reasonable assumptions can be made
14459
+ - Risk of proceeding is low
14460
+
14461
+ **When proceeding with assumptions:**
14462
+
14463
+ **Assumptions Made**
14464
+
14465
+ I proceeded with these assumptions:
14466
+ - [Assumption 1]: [rationale]
14467
+ - [Assumption 2]: [rationale]
14468
+
14469
+ If any are incorrect, let me know and I'll adjust.
14470
+
14471
+ ---
14472
+
14473
+ **Confidence Tagging**: Tag recommendations with confidence level.
14474
+ - **[HIGH]**: Well-established pattern, verified approach
14475
+ - **[MEDIUM]**: Reasonable approach, some assumptions
14476
+ - **[LOW]**: Exploratory, needs validation
14477
+ `
14478
+ };
14479
+ var BALANCED_PROTOCOL = {
14480
+ id: "balanced",
14481
+ name: "Balanced",
14482
+ askWhen: [
14483
+ "Security implications exist (auth, data access, secrets)",
14484
+ "Data integrity could be affected (migrations, deletions, updates)",
14485
+ "Irreversible actions are involved",
14486
+ "User explicitly requested confirmation before changes",
14487
+ "Multiple fundamentally different approaches exist",
14488
+ "You are unsure which of several options the user would prefer",
14489
+ "The scope is larger than expected (> 2x original estimate)"
14490
+ ],
14491
+ proceedWhen: [
14492
+ "Clear best practice applies",
14493
+ "Change is low-risk and reversible",
14494
+ "You have high confidence in the approach",
14495
+ "Similar pattern exists in codebase",
14496
+ "Scope is well-defined and matches expectations",
14497
+ "Edge cases are handled or documented"
14498
+ ],
14499
+ assumptionFormat: `**Assumptions**
14500
+ - [Assumption]: [brief rationale]
14501
+
14502
+ Proceeding with the above assumptions. Correct me if any are wrong.`,
14503
+ template: `## UNCERTAINTY HANDLING (BALANCED)
14504
+
14505
+ **Default behavior**: Use risk-based judgment.
14506
+
14507
+ **Stop and ask when** (HIGH RISK):
14508
+ - Security implications (auth, data, secrets)
14509
+ - Data integrity at risk (migrations, deletions)
14510
+ - Irreversible actions involved
14511
+ - User requested confirmation
14512
+ - Scope significantly larger than expected
14513
+ - Multiple fundamentally different approaches
14514
+
14515
+ **Proceed with documented assumptions when** (LOW RISK):
14516
+ - Clear best practice applies
14517
+ - Change is low-risk and reversible
14518
+ - High confidence in approach
14519
+ - Similar pattern in codebase
14520
+ - Scope matches expectations
14521
+
14522
+ **When proceeding with assumptions:**
14523
+
14524
+ **Assumptions**
14525
+ - [Assumption]: [brief rationale]
14526
+
14527
+ Proceeding with the above. Correct me if any are wrong.
14528
+
14529
+ ---
14530
+
14531
+ **Risk Assessment Quick Check**:
14532
+ Before deciding to ask vs proceed, consider:
14533
+ 1. What's the worst case if I'm wrong? (severity)
14534
+ 2. How likely is it that I'm wrong? (probability)
14535
+ 3. Can it be easily undone? (reversibility)
14536
+
14537
+ If severity HIGH or probability HIGH and reversibility LOW \u2192 ASK
14538
+ Otherwise \u2192 PROCEED with documented assumptions
14539
+
14540
+ ---
14541
+
14542
+ **Confidence Tagging**: Tag recommendations with confidence level.
14543
+ - **[HIGH]**: Well-established pattern, verified approach
14544
+ - **[MEDIUM]**: Reasonable approach, some assumptions
14545
+ - **[LOW]**: Exploratory, needs validation
14546
+ `
14547
+ };
14548
+ var PROTOCOLS = {
14549
+ ask_first: ASK_FIRST_PROTOCOL,
14550
+ proceed_with_assumptions: PROCEED_PROTOCOL,
14551
+ balanced: BALANCED_PROTOCOL
14552
+ };
14553
+ function getUncertaintyProtocol(mode) {
14554
+ const protocol = PROTOCOLS[mode];
14555
+ if (!protocol) {
14556
+ throw new Error(`Unknown uncertainty mode: ${mode}`);
14557
+ }
14558
+ return protocol;
14559
+ }
14560
+ function getProtocolTemplate(mode) {
14561
+ return getUncertaintyProtocol(mode).template;
14562
+ }
14563
+
14564
+ // src/agents/cognitive/prompt-composer.ts
14565
+ function estimateTokens(text) {
14566
+ return Math.ceil(text.length / 4);
14567
+ }
14568
+ function cleanPersonaSection(basePrompt) {
14569
+ let cleaned = basePrompt;
14570
+ cleaned = cleaned.replace(
14571
+ /Your thinking patterns:[\s\S]*?(?=\n\n|\n##|\n\*\*[A-Z]|$)/gi,
14572
+ ""
14573
+ );
14574
+ cleaned = cleaned.replace(
14575
+ /Thinking patterns:[\s\S]*?(?=\n\n|\n##|\n\*\*[A-Z]|$)/gi,
14576
+ ""
14577
+ );
14578
+ cleaned = cleaned.replace(
14579
+ /## Thinking Patterns[\s\S]*?(?=\n##|$)/gi,
14580
+ ""
14581
+ );
14582
+ const lines = cleaned.split("\n");
14583
+ const seenCommunicationStyle = /* @__PURE__ */ new Set();
14584
+ const dedupedLines = lines.filter((line) => {
14585
+ if (line.trim().startsWith("Communication style:")) {
14586
+ const key = line.trim();
14587
+ if (seenCommunicationStyle.has(key)) {
14588
+ return false;
14589
+ }
14590
+ seenCommunicationStyle.add(key);
14591
+ }
14592
+ return true;
14593
+ });
14594
+ cleaned = dedupedLines.join("\n");
14595
+ cleaned = cleaned.replace(/\n{3,}/g, "\n\n");
14596
+ return cleaned.trim();
14597
+ }
14598
+ function formatRepoContext(context) {
14599
+ const lines = ["**Repository Context**"];
14600
+ if (context.packageManager) {
14601
+ lines.push(`- Package manager: ${context.packageManager}`);
14602
+ }
14603
+ if (context.moduleSystem) {
14604
+ lines.push(`- Module system: ${context.moduleSystem}`);
14605
+ }
14606
+ if (context.testFramework) {
14607
+ lines.push(`- Test framework: ${context.testFramework}`);
14608
+ }
14609
+ if (context.tempDir) {
14610
+ lines.push(`- Temp directory: ${context.tempDir}`);
14611
+ }
14612
+ if (context.rules && context.rules.length > 0) {
14613
+ lines.push("- Additional rules:");
14614
+ for (const rule of context.rules) {
14615
+ lines.push(` - ${rule}`);
14616
+ }
14617
+ }
14618
+ return lines.join("\n");
14619
+ }
14620
+ function composePrompt(options) {
14621
+ const { basePrompt, config, additionalContext, repoContext } = options;
14622
+ const sections = [];
14623
+ const personaSection = cleanPersonaSection(basePrompt);
14624
+ if (personaSection) {
14625
+ sections.push(personaSection);
14626
+ }
14627
+ if (repoContext) {
14628
+ sections.push(formatRepoContext(repoContext));
14629
+ }
14630
+ if (additionalContext) {
14631
+ sections.push(additionalContext);
14632
+ }
14633
+ const scaffoldTemplate = getScaffoldTemplate(config.scaffold);
14634
+ sections.push(scaffoldTemplate);
14635
+ if (config.checklist !== "none") {
14636
+ let checklistTemplate = getChecklistTemplate(config.checklist);
14637
+ if (config.checklistOverrides) {
14638
+ checklistTemplate = applyChecklistOverrides(config.checklist, config.checklistOverrides);
14639
+ }
14640
+ if (config.customChecklist && config.customChecklist.length > 0) {
14641
+ const customSection = `
14642
+ **Custom Checks**
14643
+ ${config.customChecklist.map((item) => `- [ ] ${item}`).join("\n")}
14644
+ `;
14645
+ checklistTemplate = checklistTemplate.replace(
14646
+ /Mark items as \[x\]/,
14647
+ customSection + "\nMark items as [x]"
14648
+ );
14649
+ }
14650
+ sections.push(checklistTemplate);
14651
+ }
14652
+ const contractTemplate = getContractTemplate(config.outputContract);
14653
+ sections.push(contractTemplate);
14654
+ const protocolTemplate = getProtocolTemplate(config.uncertaintyMode);
14655
+ sections.push(protocolTemplate);
14656
+ const fullText = sections.join("\n\n---\n\n");
14657
+ return {
14658
+ text: fullText,
14659
+ components: {
14660
+ persona: !!personaSection,
14661
+ scaffold: config.scaffold,
14662
+ checklist: config.checklist,
14663
+ outputContract: config.outputContract,
14664
+ uncertainty: config.uncertaintyMode
14665
+ },
14666
+ estimatedTokens: estimateTokens(fullText)
14667
+ };
14668
+ }
14669
+ var AUTOMATOSX_REPO_CONTEXT = {
14670
+ packageManager: "pnpm",
14671
+ moduleSystem: "ESM (strict, with .js extensions)",
14672
+ testFramework: "Vitest",
14673
+ tempDir: "automatosx/tmp/",
14674
+ rules: [
14675
+ "Use explicit .js extensions in imports",
14676
+ "Store temporary files in automatosx/tmp/",
14677
+ "Store PRD files in automatosx/PRD/",
14678
+ "Follow existing patterns in codebase"
14679
+ ]
14680
+ };
14681
+
14682
+ // src/types/cognitive.ts
14683
+ init_esm_shims();
14684
+ var DEFAULT_COGNITIVE_CONFIG = {
14685
+ scaffold: "prover",
14686
+ checklist: "none",
14687
+ outputContract: "standard",
14688
+ uncertaintyMode: "balanced"
14689
+ };
14690
+
13321
14691
  // src/agents/profile-loader.ts
13322
14692
  var ProfileLoader = class {
13323
14693
  profilesDir;
@@ -14007,6 +15377,75 @@ var ProfileLoader = class {
14007
15377
  }
14008
15378
  return void 0;
14009
15379
  }
15380
+ /**
15381
+ * Compose cognitive prompt for an agent
15382
+ * v13.0.0+: Assembles the full prompt with reasoning scaffold, checklist, etc.
15383
+ *
15384
+ * @param agentName - Agent name or displayName
15385
+ * @param overrideConfig - Optional config overrides
15386
+ * @returns Composed prompt with all cognitive framework components
15387
+ */
15388
+ async composeAgentPrompt(agentName, overrideConfig) {
15389
+ const profile = await this.loadProfile(agentName);
15390
+ let config = profile.cognitiveFramework ? { ...profile.cognitiveFramework } : this.inferCognitiveConfig(profile);
15391
+ if (overrideConfig) {
15392
+ config = { ...config, ...overrideConfig };
15393
+ }
15394
+ const composed = composePrompt({
15395
+ basePrompt: profile.systemPrompt,
15396
+ config,
15397
+ repoContext: AUTOMATOSX_REPO_CONTEXT
15398
+ });
15399
+ logger.debug("Composed cognitive prompt", {
15400
+ agent: agentName,
15401
+ scaffold: config.scaffold,
15402
+ checklist: config.checklist,
15403
+ outputContract: config.outputContract,
15404
+ estimatedTokens: composed.estimatedTokens
15405
+ });
15406
+ return composed;
15407
+ }
15408
+ /**
15409
+ * Infer cognitive config from agent profile when not explicitly specified
15410
+ * v13.0.0+: Smart defaults based on agent role and abilities
15411
+ */
15412
+ inferCognitiveConfig(profile) {
15413
+ const role = profile.role.toLowerCase();
15414
+ const name = profile.name.toLowerCase();
15415
+ let checklist = "none";
15416
+ if (role.includes("backend") || name === "backend" || role.includes("api")) {
15417
+ checklist = "backend";
15418
+ } else if (role.includes("frontend") || name === "frontend" || role.includes("ui")) {
15419
+ checklist = "frontend";
15420
+ } else if (role.includes("security") || name === "security") {
15421
+ checklist = "security";
15422
+ } else if (role.includes("qa") || role.includes("quality") || name === "quality" || role.includes("test")) {
15423
+ checklist = "quality";
15424
+ } else if (role.includes("architect") || name === "architecture") {
15425
+ checklist = "architecture";
15426
+ } else if (role.includes("devops") || name === "devops" || role.includes("infrastructure")) {
15427
+ checklist = "devops";
15428
+ } else if (role.includes("data") || name === "data" || role.includes("pipeline")) {
15429
+ checklist = "data";
15430
+ } else if (role.includes("product") || name === "product") {
15431
+ checklist = "product";
15432
+ }
15433
+ return {
15434
+ ...DEFAULT_COGNITIVE_CONFIG,
15435
+ checklist
15436
+ };
15437
+ }
15438
+ /**
15439
+ * Get the composed system prompt for an agent
15440
+ * v13.0.0+: Convenience method that returns just the prompt text
15441
+ *
15442
+ * @param agentName - Agent name or displayName
15443
+ * @returns Full composed prompt text
15444
+ */
15445
+ async getComposedPrompt(agentName) {
15446
+ const composed = await this.composeAgentPrompt(agentName);
15447
+ return composed.text;
15448
+ }
14010
15449
  };
14011
15450
 
14012
15451
  // src/core/team-manager.ts