@aisdlc/core 1.2.0 → 1.3.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
@@ -120,17 +120,31 @@ function calculateLocAndHalstead(fullText, cyclomatic) {
120
120
  const normalizedMI = Math.max(0, Math.min(100, rawMI * 100 / 171));
121
121
  return { loc, mi: Math.round(normalizedMI * 10) / 10 };
122
122
  }
123
- function detectAstCodeSmells(node, loc, nodeText) {
123
+ var TEST_FILE_PATTERN = /(?:^|\/)(?:tests|__tests__|fixtures)\/|\.(?:spec|test)\.[cm]?[jt]sx?$/i;
124
+ var EMPTY_UI_HANDLER_PATTERN = /\bon[A-Z]\w*\s*=\s*\{\s*(?:\([^)]*\)\s*=>\s*\{\s*\}|function\s*\([^)]*\)\s*\{\s*\})\s*\}/;
125
+ var FAKE_WIRING_STUB_PATTERN = /(?:\/\/\s*T[O]DO:\s*(?:connect|wire|integrate)\b|\b(?:m[o]ckData|F[A]KE_DATA)\b)/i;
126
+ function isProductionFile(filePath) {
127
+ return !TEST_FILE_PATTERN.test(filePath.replace(/\\/g, "/"));
128
+ }
129
+ function detectAstCodeSmells(node, loc, fullText, filePath) {
124
130
  const smells = [];
125
131
  if (node.getDescendantsOfKind(SyntaxKind.AnyKeyword).length > 0) {
126
132
  smells.push('Uso prohibido de "any"');
127
133
  }
128
- if (/\/\/\s*@ts-ignore|\/\/\s*eslint-disable/.test(nodeText)) {
134
+ if (/\/\/\s*@ts-ignore|\/\/\s*eslint-disable/.test(fullText)) {
129
135
  smells.push("Supresi\xF3n no autorizada de linter");
130
136
  }
131
137
  if (loc > 40) {
132
138
  smells.push(`Funci\xF3n extensa (${loc} l\xEDneas > l\xEDmite 40)`);
133
139
  }
140
+ if (isProductionFile(filePath)) {
141
+ if (EMPTY_UI_HANDLER_PATTERN.test(fullText)) {
142
+ smells.push("Handler de UI vac\xEDo (fake-wiring detectado)");
143
+ }
144
+ if (FAKE_WIRING_STUB_PATTERN.test(fullText)) {
145
+ smells.push("Datos simulados o conexi\xF3n pendiente en producci\xF3n (fake-wiring)");
146
+ }
147
+ }
134
148
  return smells;
135
149
  }
136
150
  function isDeclarationFunction(node) {
@@ -154,9 +168,8 @@ function buildNodeMetrics(node, filePath) {
154
168
  const cyclomatic = computeCyclomaticFromAst(node);
155
169
  const cognitive = computeCognitiveFromAst(node);
156
170
  const fullText = node.getFullText();
157
- const nodeText = node.getText();
158
171
  const { loc, mi } = calculateLocAndHalstead(fullText, cyclomatic);
159
- const codeSmells = detectAstCodeSmells(node, loc, nodeText);
172
+ const codeSmells = detectAstCodeSmells(node, loc, fullText, filePath);
160
173
  return { functionName, filePath, loc, cyclomatic, cognitive, maintainability: mi, codeSmells };
161
174
  }
162
175
  function buildModuleFallback(content, filePath) {
@@ -9285,6 +9298,7 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9285
9298
 
9286
9299
  ## Operational Directives & Guardrails
9287
9300
  - Decompose the system into building blocks \`CMP-*\` ensuring each component declares which use cases \`UC-*\` it implements and which requirements (\`FR-*\`, \`QR-*\`, \`SEC-REQ-*\`) it fulfills under \`satisfies-requirements\`.
9301
+ - **Contract-First Full-Stack Integration**: Whenever a feature or change spans Frontend (UI) and Backend (API/services), define an explicit shared typed contract (Zod schemas, shared TypeScript DTOs, or OpenAPI specification) in \`design.md\` before implementation so both layers compile against a single source of truth.
9288
9302
  - Generate interaction and sequence diagrams in native Mermaid syntax.
9289
9303
  - Document critical technological decisions using immutable \`ADR-*\` records conforming to \`schemas/architecture/adr.schema.json\`.
9290
9304
  - Validate that architectural choices comply with legal constraints in \`license-policy.yaml\`.
@@ -9307,6 +9321,7 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9307
9321
  2. **Boundary Cases** (\`Scenario Outline\` + \`Examples\` table): values at the extremes of the accepted range.
9308
9322
  3. **Out-of-Range / Invalid Cases** (\`Scenario Outline\` + \`Examples\` table): null, empty, wrong types, values exceeding bounds.
9309
9323
  - Apply conditional categories when applicable: Security (\`@security @mitigation\`), Performance (\`@performance\`), Idempotency (\`@idempotence\`), Postconditions, and Interface Contracts.
9324
+ - **Zero-Mock Integration Rule**: When an \`FR-*\` spans UI and Backend, unit tests mocking \`fetch\`/HTTP in isolation are insufficient; include integration/contract or E2E test scenarios verifying real request/response wiring and UI state transitions (\`Loading\`, \`Empty\`, \`Error\`, \`Nominal\`).
9310
9325
  - Tag all scenarios with \`@<FR-ID> @automated @regression\`.
9311
9326
  - **STRICTLY FORBIDDEN**: Including production code, suggesting implementation, or anticipating technical solutions.
9312
9327
  - Run \`pnpm run verify:testing\` before emitting handoff.
@@ -9325,6 +9340,9 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9325
9340
  - Respect the autonomy mode assigned to each task in \`tasks.md\` (\`AUTONOMOUS\`, \`HUMAN_REVIEW_PLAN\`, \`AMBIGUOUS\`, \`HIGH_RISK_MANUAL\`).
9326
9341
  - Apply Test-Driven Development (TDD): make failing tests delivered by \`agent-qa-engineer\` pass green without altering tests to accommodate buggy code.
9327
9342
  - Cite implemented \`FR-*\` or \`SEC-REQ-*\` IDs in test header comments to maintain 360\xB0 reverse traceability.
9343
+ - **Zero Fake-Wiring Guardrail**: Strictly forbidden from marking a task \`COMPLETED\` with hardcoded \`mockData\` arrays in production views, \`setTimeout\` simulating network calls, or empty UI event handlers (\`onClick={() => {}}\`, \`onSubmit={() => {}}\`). Frontend components must wire directly to the shared contract and real Backend endpoints.
9344
+ - **Mandatory 4 UI States Matrix**: Every data-driven UI component or screen must explicitly implement all 4 usability states: \`Loading\` (spinner/skeleton + disabled submit), \`Empty\` (clear message + CTA), \`Error\` (visible error recovery banner, never silent failure), and \`Nominal/Success\` (accessible semantic DOM + keyboard navigation).
9345
+ - **Live Runtime Smoke Verification**: For tasks touching UI or UI-to-Backend integration, unit tests alone are insufficient. Before emitting handoff, boot the real Backend and Frontend servers and verify (via Playwright E2E or Chrome DevTools MCP) that browser \`console.error\` and \`pageerror\` counts are \`0\` and API calls return real \`2xx\` responses without CORS or schema mismatches.
9328
9346
  - Before adding any external dependency, verify its SPDX license is permitted in \`license-policy.yaml\`.
9329
9347
  - Respect non-negotiable \`quality-policy.yaml\` thresholds: Cyclomatic Complexity $\\le 10$, Cognitive Complexity $\\le 15$, Maintainability Index $\\ge 50$, Function Length $\\le 40$ lines.
9330
9348
  - Run unified pre-flight with auto-fix (\`pnpm run check:fix\`) and full verification (\`pnpm run verify:all\`).
@@ -9373,9 +9391,9 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9373
9391
  ## Operational Directives & Guardrails
9374
9392
  - Operate under bimodal discipline depending on the lifecycle phase:
9375
9393
  1. **Design Mode (Upstream)**: Adopt the primary actor persona under real-world field conditions (stress, latency, constrained viewports). Separate strict Minimum Viable Product (MVP) core from future roadmap ideas using \`templates/product/user-design-feedback.template.md\`.
9376
- 2. **Functional Validation Mode (Downstream / Pre-PR / Post-Development Functional Validation)**: Inspect \`agent-developer\` deliverables once unit tests pass green. Contrast actual UI, CLI, and API behavior against approved \`UC-*\` and \`FR-*\` criteria.
9394
+ 2. **Functional Validation Mode (Downstream / Pre-PR / Post-Development Functional Validation)**: Inspect \`agent-developer\` deliverables once unit tests pass green by executing the real application (via Playwright or Chrome DevTools MCP when UI is present). Contrast actual UI, CLI, and API behavior against approved \`UC-*\` and \`FR-*\` criteria, verifying real Backend connectivity, the 4 UI usability states (\`Loading\`, \`Empty\`, \`Error\`, \`Nominal\`), keyboard/ARIA accessibility, and \`0\` browser \`console.error\` / network failures.
9377
9395
  - Formulate decisive questions under \`open-questions\` for the human Product Owner.
9378
- - Emit handoff block suggesting the Pre-Merge Audit Triad (\`agent-code-reviewer\`, \`agent-security-auditor\`, \`agent-compliance-checker\`) if compliant, or return to \`agent-developer\` on functional drift.`
9396
+ - Emit handoff block suggesting the Pre-Merge Audit Triad (\`agent-code-reviewer\`, \`agent-security-auditor\`, \`agent-compliance-checker\`) if compliant, or return to \`agent-developer\` on functional drift or fake-wiring.`
9379
9397
  },
9380
9398
  {
9381
9399
  id: "agent-code-reviewer",
@@ -9390,6 +9408,7 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9390
9408
  - Analyze code diffs against \`quality-policy.yaml\` standards: Cyclomatic Complexity $\\le 10$, Cognitive Complexity $\\le 15$, Maintainability Index $\\ge 50$, Lines per Function $\\le 40$.
9391
9409
  - Detect improper coupling, code smells, magic numbers, ambiguous identifiers, and encapsulation breaches.
9392
9410
  - Flag premature abstractions and speculative code violating YAGNI.
9411
+ - **Block Fake-Wiring & Disconnected UI**: Flag as \`[BLOCKING]\` any production UI component containing hardcoded mock data (\`mockData\`), empty event handlers (\`onClick={() => {}}\`), missing error/loading state handling, or API calls bypassing shared contracts.
9393
9412
  - Coordinate Pre-Merge Audit Triad with \`agent-security-auditor\` and \`agent-compliance-checker\`.
9394
9413
  - Categorize findings into: \`[BLOCKING]\` (quality violation or broken pattern), \`[CLEAN_CODE_SUGGESTION]\` (non-blocking improvement), and \`[COMPLIANT]\`.
9395
9414
  - If autonomy is $\\ge$ \`HUMAN_REVIEW_PLAN\`, conclude by emitting the Workflow Handoff block (\`templates/workflow/agent-handoff.template.md\`) to the human Tech Lead for final approval and merge, opening the Human Action Window. In \`AUTONOMOUS\` mode, omit interactive handoff.`