@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.cjs CHANGED
@@ -148,17 +148,31 @@ function calculateLocAndHalstead(fullText, cyclomatic) {
148
148
  const normalizedMI = Math.max(0, Math.min(100, rawMI * 100 / 171));
149
149
  return { loc, mi: Math.round(normalizedMI * 10) / 10 };
150
150
  }
151
- function detectAstCodeSmells(node, loc, nodeText) {
151
+ var TEST_FILE_PATTERN = /(?:^|\/)(?:tests|__tests__|fixtures)\/|\.(?:spec|test)\.[cm]?[jt]sx?$/i;
152
+ var EMPTY_UI_HANDLER_PATTERN = /\bon[A-Z]\w*\s*=\s*\{\s*(?:\([^)]*\)\s*=>\s*\{\s*\}|function\s*\([^)]*\)\s*\{\s*\})\s*\}/;
153
+ var FAKE_WIRING_STUB_PATTERN = /(?:\/\/\s*T[O]DO:\s*(?:connect|wire|integrate)\b|\b(?:m[o]ckData|F[A]KE_DATA)\b)/i;
154
+ function isProductionFile(filePath) {
155
+ return !TEST_FILE_PATTERN.test(filePath.replace(/\\/g, "/"));
156
+ }
157
+ function detectAstCodeSmells(node, loc, fullText, filePath) {
152
158
  const smells = [];
153
159
  if (node.getDescendantsOfKind(tsMorph.SyntaxKind.AnyKeyword).length > 0) {
154
160
  smells.push('Uso prohibido de "any"');
155
161
  }
156
- if (/\/\/\s*@ts-ignore|\/\/\s*eslint-disable/.test(nodeText)) {
162
+ if (/\/\/\s*@ts-ignore|\/\/\s*eslint-disable/.test(fullText)) {
157
163
  smells.push("Supresi\xF3n no autorizada de linter");
158
164
  }
159
165
  if (loc > 40) {
160
166
  smells.push(`Funci\xF3n extensa (${loc} l\xEDneas > l\xEDmite 40)`);
161
167
  }
168
+ if (isProductionFile(filePath)) {
169
+ if (EMPTY_UI_HANDLER_PATTERN.test(fullText)) {
170
+ smells.push("Handler de UI vac\xEDo (fake-wiring detectado)");
171
+ }
172
+ if (FAKE_WIRING_STUB_PATTERN.test(fullText)) {
173
+ smells.push("Datos simulados o conexi\xF3n pendiente en producci\xF3n (fake-wiring)");
174
+ }
175
+ }
162
176
  return smells;
163
177
  }
164
178
  function isDeclarationFunction(node) {
@@ -182,9 +196,8 @@ function buildNodeMetrics(node, filePath) {
182
196
  const cyclomatic = computeCyclomaticFromAst(node);
183
197
  const cognitive = computeCognitiveFromAst(node);
184
198
  const fullText = node.getFullText();
185
- const nodeText = node.getText();
186
199
  const { loc, mi } = calculateLocAndHalstead(fullText, cyclomatic);
187
- const codeSmells = detectAstCodeSmells(node, loc, nodeText);
200
+ const codeSmells = detectAstCodeSmells(node, loc, fullText, filePath);
188
201
  return { functionName, filePath, loc, cyclomatic, cognitive, maintainability: mi, codeSmells };
189
202
  }
190
203
  function buildModuleFallback(content, filePath) {
@@ -9313,6 +9326,7 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9313
9326
 
9314
9327
  ## Operational Directives & Guardrails
9315
9328
  - 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\`.
9329
+ - **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.
9316
9330
  - Generate interaction and sequence diagrams in native Mermaid syntax.
9317
9331
  - Document critical technological decisions using immutable \`ADR-*\` records conforming to \`schemas/architecture/adr.schema.json\`.
9318
9332
  - Validate that architectural choices comply with legal constraints in \`license-policy.yaml\`.
@@ -9335,6 +9349,7 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9335
9349
  2. **Boundary Cases** (\`Scenario Outline\` + \`Examples\` table): values at the extremes of the accepted range.
9336
9350
  3. **Out-of-Range / Invalid Cases** (\`Scenario Outline\` + \`Examples\` table): null, empty, wrong types, values exceeding bounds.
9337
9351
  - Apply conditional categories when applicable: Security (\`@security @mitigation\`), Performance (\`@performance\`), Idempotency (\`@idempotence\`), Postconditions, and Interface Contracts.
9352
+ - **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\`).
9338
9353
  - Tag all scenarios with \`@<FR-ID> @automated @regression\`.
9339
9354
  - **STRICTLY FORBIDDEN**: Including production code, suggesting implementation, or anticipating technical solutions.
9340
9355
  - Run \`pnpm run verify:testing\` before emitting handoff.
@@ -9353,6 +9368,9 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9353
9368
  - Respect the autonomy mode assigned to each task in \`tasks.md\` (\`AUTONOMOUS\`, \`HUMAN_REVIEW_PLAN\`, \`AMBIGUOUS\`, \`HIGH_RISK_MANUAL\`).
9354
9369
  - Apply Test-Driven Development (TDD): make failing tests delivered by \`agent-qa-engineer\` pass green without altering tests to accommodate buggy code.
9355
9370
  - Cite implemented \`FR-*\` or \`SEC-REQ-*\` IDs in test header comments to maintain 360\xB0 reverse traceability.
9371
+ - **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.
9372
+ - **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).
9373
+ - **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.
9356
9374
  - Before adding any external dependency, verify its SPDX license is permitted in \`license-policy.yaml\`.
9357
9375
  - Respect non-negotiable \`quality-policy.yaml\` thresholds: Cyclomatic Complexity $\\le 10$, Cognitive Complexity $\\le 15$, Maintainability Index $\\ge 50$, Function Length $\\le 40$ lines.
9358
9376
  - Run unified pre-flight with auto-fix (\`pnpm run check:fix\`) and full verification (\`pnpm run verify:all\`).
@@ -9401,9 +9419,9 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9401
9419
  ## Operational Directives & Guardrails
9402
9420
  - Operate under bimodal discipline depending on the lifecycle phase:
9403
9421
  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\`.
9404
- 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.
9422
+ 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.
9405
9423
  - Formulate decisive questions under \`open-questions\` for the human Product Owner.
9406
- - 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.`
9424
+ - 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.`
9407
9425
  },
9408
9426
  {
9409
9427
  id: "agent-code-reviewer",
@@ -9418,6 +9436,7 @@ var SPECIALIZED_AGENT_TEMPLATES = [
9418
9436
  - 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$.
9419
9437
  - Detect improper coupling, code smells, magic numbers, ambiguous identifiers, and encapsulation breaches.
9420
9438
  - Flag premature abstractions and speculative code violating YAGNI.
9439
+ - **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.
9421
9440
  - Coordinate Pre-Merge Audit Triad with \`agent-security-auditor\` and \`agent-compliance-checker\`.
9422
9441
  - Categorize findings into: \`[BLOCKING]\` (quality violation or broken pattern), \`[CLEAN_CODE_SUGGESTION]\` (non-blocking improvement), and \`[COMPLIANT]\`.
9423
9442
  - 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.`