azcodr 2.2.0 → 2.4.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.
Files changed (78) hide show
  1. package/.agents/scripts/agent_guard.js +63 -0
  2. package/.agents/skills/lets-build/SKILL.md +1 -1
  3. package/.github/workflows/ci.yml +21 -0
  4. package/.github/workflows/publish.yml +7 -0
  5. package/CODE_OF_CONDUCT.md +122 -0
  6. package/CONTRIBUTING.md +85 -0
  7. package/README.md +73 -3
  8. package/SECURITY.md +32 -0
  9. package/data/memory.template +36 -0
  10. package/docs/rules/clean_code.md +13 -0
  11. package/docs/tipping-points.md +37 -0
  12. package/lib/agent-guard-command.d.ts +28 -0
  13. package/lib/agent-guard-command.d.ts.map +1 -0
  14. package/lib/agent-guard-command.js +103 -0
  15. package/lib/agent-guard-command.js.map +1 -0
  16. package/lib/agent-guard-file.d.ts +32 -0
  17. package/lib/agent-guard-file.d.ts.map +1 -0
  18. package/lib/agent-guard-file.js +77 -0
  19. package/lib/agent-guard-file.js.map +1 -0
  20. package/lib/agent-guard-tdd.d.ts +34 -0
  21. package/lib/agent-guard-tdd.d.ts.map +1 -0
  22. package/lib/agent-guard-tdd.js +77 -0
  23. package/lib/agent-guard-tdd.js.map +1 -0
  24. package/lib/agent-guard.d.ts +38 -0
  25. package/lib/agent-guard.d.ts.map +1 -0
  26. package/lib/agent-guard.js +80 -0
  27. package/lib/agent-guard.js.map +1 -0
  28. package/lib/boundaries.d.ts +41 -0
  29. package/lib/boundaries.d.ts.map +1 -0
  30. package/lib/boundaries.js +158 -0
  31. package/lib/boundaries.js.map +1 -0
  32. package/lib/cli-boundaries.d.ts +18 -0
  33. package/lib/cli-boundaries.d.ts.map +1 -0
  34. package/lib/cli-boundaries.js +46 -0
  35. package/lib/cli-boundaries.js.map +1 -0
  36. package/lib/cli-parse.d.ts +5 -0
  37. package/lib/cli-parse.d.ts.map +1 -1
  38. package/lib/cli-parse.js +35 -5
  39. package/lib/cli-parse.js.map +1 -1
  40. package/lib/cli.d.ts +17 -0
  41. package/lib/cli.d.ts.map +1 -1
  42. package/lib/cli.js +47 -5
  43. package/lib/cli.js.map +1 -1
  44. package/lib/guards.d.ts +6 -0
  45. package/lib/guards.d.ts.map +1 -1
  46. package/lib/guards.js +10 -1
  47. package/lib/guards.js.map +1 -1
  48. package/lib/index.d.ts +15 -0
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +12 -0
  51. package/lib/index.js.map +1 -1
  52. package/lib/repo.js +4 -4
  53. package/lib/repo.js.map +1 -1
  54. package/lib/scaffold.d.ts +2 -7
  55. package/lib/scaffold.d.ts.map +1 -1
  56. package/lib/scaffold.js +7 -10
  57. package/lib/scaffold.js.map +1 -1
  58. package/lib/validate.d.ts +33 -0
  59. package/lib/validate.d.ts.map +1 -0
  60. package/lib/validate.js +24 -0
  61. package/lib/validate.js.map +1 -0
  62. package/memory.md +24 -0
  63. package/package.json +10 -2
  64. package/scripts/validate/links.js +0 -1
  65. package/scripts/validate/root.js +1 -1
  66. package/src/agent-guard-command.ts +118 -0
  67. package/src/agent-guard-file.ts +107 -0
  68. package/src/agent-guard-tdd.ts +96 -0
  69. package/src/agent-guard.ts +123 -0
  70. package/src/boundaries.ts +198 -0
  71. package/src/cli-boundaries.ts +67 -0
  72. package/src/cli-parse.ts +40 -4
  73. package/src/cli.ts +57 -15
  74. package/src/guards.ts +11 -1
  75. package/src/index.ts +40 -0
  76. package/src/repo.ts +4 -4
  77. package/src/scaffold.ts +7 -10
  78. package/src/validate.ts +47 -0
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Cross-platform PreToolUse safety & architectural enforcement hook.
5
+ *
6
+ * Enforces:
7
+ * 1. Command safety (blocks destructive rm, force-push, drop db, etc.)
8
+ * 2. Refactor-Before-Add (blocks adding lines to files over line budget)
9
+ * 3. Test-First / RED-before-GREEN (when enabled)
10
+ */
11
+ import fs from 'node:fs';
12
+ import path from 'node:path';
13
+ import process from 'node:process';
14
+ import { fileURLToPath, pathToFileURL } from 'node:url';
15
+
16
+ const selfDir = path.dirname(fileURLToPath(import.meta.url));
17
+ const guardModulePath = path.resolve(selfDir, '../../lib/agent-guard.js');
18
+
19
+ async function getGuardModule() {
20
+ return import(pathToFileURL(guardModulePath).href);
21
+ }
22
+
23
+ async function readStdin(timeoutMs = 1500) {
24
+ if (process.stdin.isTTY) return '';
25
+ return new Promise((resolve) => {
26
+ let acc = '';
27
+ const timer = setTimeout(() => resolve(acc), timeoutMs);
28
+ process.stdin.setEncoding('utf-8');
29
+ process.stdin.on('data', (chunk) => { acc += chunk; });
30
+ process.stdin.on('end', () => {
31
+ clearTimeout(timer);
32
+ resolve(acc);
33
+ });
34
+ process.stdin.on('error', () => {
35
+ clearTimeout(timer);
36
+ resolve(acc);
37
+ });
38
+ });
39
+ }
40
+
41
+ async function main() {
42
+ const argvInput = process.argv.slice(2).join(' ').trim();
43
+ const stdinInput = (await readStdin()).trim();
44
+ const rawInput = argvInput || stdinInput;
45
+
46
+ if (!rawInput) {
47
+ process.exit(0);
48
+ }
49
+
50
+ const { inspectPreTool } = await getGuardModule();
51
+ const decision = inspectPreTool(rawInput, {
52
+ workspaceRoot: process.cwd()
53
+ });
54
+
55
+ if (!decision.allowed) {
56
+ console.error(`🚨 Architectural Guard: ${decision.reason}`);
57
+ process.exit(1);
58
+ }
59
+
60
+ process.exit(0);
61
+ }
62
+
63
+ main().catch(() => process.exit(0));
@@ -100,7 +100,7 @@ Upon user confirmation:
100
100
  - *Extension:* `manifest.json`, `src/background/index.ts`, `src/content/index.ts`, `src/popup/index.html`.
101
101
  - *Game / Engine:* `src/core/`, `src/ecs/`, asset manifest, frame loop entrypoint.
102
102
  - *CLI:* `src/cmd/`, `src/core/`, CLI entrypoint with exit code handling.
103
- 3. Generate build manifests (`Cargo.toml`, `package.json`, `go.mod`, `pyproject.toml`), linter configurations, and boundary smoke test (`scripts/smoke_test.sh`).
103
+ 3. Generate build manifests (`Cargo.toml`, `package.json`, `go.mod`, `pyproject.toml`), deterministic linter configurations strictly enforcing the [Polyglot Fitness Function Standards](../../../docs/rules/clean_code.md#polyglot-fitness-function-standards), and boundary smoke test (`scripts/smoke_test.sh`).
104
104
  4. **Replace Starter README with Project-Specific README**:
105
105
  Generate a clean, project-specific `README.md` using [references/project_readme_template.md](./references/project_readme_template.md), completely replacing meta-template content with the project's actual name, mission, stack highlights, quickstart commands, and directory tree.
106
106
 
@@ -54,6 +54,13 @@ jobs:
54
54
  node --version
55
55
  npm --version
56
56
 
57
+ - name: Verify TypeScript Compilation & lib/ Parity
58
+ shell: bash
59
+ run: |
60
+ npm run build
61
+ git diff --exit-code lib/
62
+ npm run typecheck
63
+
57
64
  - name: Run Syntax & Lint Checks
58
65
  run: npm run lint
59
66
 
@@ -84,6 +91,20 @@ jobs:
84
91
  - name: Verify Coverage Gates
85
92
  run: npm run test:coverage
86
93
 
94
+ - name: Verify Mutation Score Gate (100% Mutant Kill)
95
+ run: npm run test:mutation
96
+
97
+ - name: Verify Empirical Drift Benchmark
98
+ run: node benchmark/run-benchmark.js
99
+
100
+ - name: Upload Coverage Report
101
+ uses: actions/upload-artifact@v4
102
+ if: always()
103
+ with:
104
+ name: coverage-report
105
+ path: coverage/
106
+ retention-days: 14
107
+
87
108
  shell-syntax:
88
109
  name: Shell Script Syntax (shipped hooks)
89
110
  runs-on: ubuntu-24.04
@@ -43,6 +43,13 @@ jobs:
43
43
  node --version
44
44
  npm --version
45
45
 
46
+ - name: Verify TypeScript Compilation & lib/ Parity
47
+ shell: bash
48
+ run: |
49
+ npm run build
50
+ git diff --exit-code lib/
51
+ npm run typecheck
52
+
46
53
  # Re-run the full gate on the exact release tag. prepublishOnly also runs
47
54
  # on `npm publish`, but failing fast here avoids building a tarball at all.
48
55
  - name: Run Syntax & Lint Checks
@@ -0,0 +1,122 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [prosubodh+conduct@gmail.com](mailto:prosubodh+conduct@gmail.com).
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html).
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
@@ -0,0 +1,85 @@
1
+ # Contributing to azcodr
2
+
3
+ Thank you for contributing to `azcodr`!
4
+
5
+ This repository is governed by strict systemic atomicity, Clean Code fitness functions, and test-driven development.
6
+
7
+ ---
8
+
9
+ ## 🛠️ Development Setup
10
+
11
+ ### Prerequisites
12
+ - Node.js `>=22.8.0` (required for native ESM VM modules)
13
+ - npm `>=10.0.0`
14
+ - Git
15
+
16
+ ### Installation
17
+ Clone the repository and install exact-pinned development tooling:
18
+ ```bash
19
+ git clone https://github.com/prosubodh/azcodr.git
20
+ cd azcodr
21
+ npm ci
22
+ ```
23
+
24
+ ---
25
+
26
+ ## 🧪 Verification & Quality Gates
27
+
28
+ Before submitting any code changes, all 5 quality gates must pass with zero errors:
29
+
30
+ 1. **Type Checking:**
31
+ ```bash
32
+ npm run typecheck
33
+ ```
34
+ 2. **Production Build:**
35
+ ```bash
36
+ npm run build
37
+ ```
38
+ 3. **Clean Code Fitness Functions (ESLint):**
39
+ ```bash
40
+ npm run lint
41
+ ```
42
+ *Enforces:*
43
+ - Maximum 300 lines per file (including comments)
44
+ - Maximum 30 lines per function
45
+ - Cyclomatic complexity $\le 10$
46
+ - Maximum 3 parameters per function
47
+ 4. **Test Suite & Coverage Gate (Jest):**
48
+ ```bash
49
+ npm test
50
+ npm run test:coverage
51
+ ```
52
+ *Coverage gates enforced:*
53
+ - **100% lines coverage**
54
+ - **97% functions coverage**
55
+ - **98% branches coverage**
56
+ 5. **Agentic Architecture Validation:**
57
+ ```bash
58
+ npm run validate
59
+ ```
60
+ Validates root harness parity, progressive disclosure rules, skill formats, markdown links, and ADR ledger consistency.
61
+
62
+ ---
63
+
64
+ ## 🏛️ Architectural Invariants
65
+
66
+ Every contribution must preserve these core invariants:
67
+ - **Zero Runtime Dependencies:** `dependencies` in `package.json` must remain undefined. Runtime features rely strictly on Node.js standard builtins (`node:*`).
68
+ - **Exact-Pinned DevDependencies:** Any tool in `devDependencies` must have an exact version (no `^`, `~`, or floating ranges) and committed `package-lock.json`.
69
+ - **Refactor Before Adding:** When introducing changes, refactor structure first under existing green tests before adding new logic.
70
+ - **Lightweight ADRs:** Significant architectural decisions or boundary changes must be recorded in `memory.md`.
71
+
72
+ ---
73
+
74
+ ## 🔄 Pull Request Guidelines
75
+
76
+ 1. Create a feature branch: `git checkout -b feat/your-feature-name`.
77
+ 2. Follow Conventional Commits: `feat(...)`, `fix(...)`, `docs(...)`, `test(...)`.
78
+ 3. Ensure all tests and validation pass locally (`npm run prepublishOnly`).
79
+ 4. Submit your pull request with a concise summary and verification evidence.
80
+
81
+ ---
82
+
83
+ ## 📜 Code of Conduct
84
+
85
+ All contributors and maintainers are expected to abide by our [Code of Conduct](./CODE_OF_CONDUCT.md). Please report any violations to `prosubodh+conduct@gmail.com`.
package/README.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # azcodr: Enterprise Architecture & Agentic Engineering Starter Template
2
2
 
3
- > **Production-ready, battle-tested software architecture governed by problem-first topology alignment, strict systemic atomicity, evolutionary architecture tipping points, 100% open-source standards, true incremental TDD nano-cycles, and zero speculative bloat.**
3
+ [![npm version](https://img.shields.io/npm/v/azcodr.svg?color=cb3837)](https://www.npmjs.com/package/azcodr)
4
+ [![JSR Package](https://jsr.io/badges/@azcodr/azcodr)](https://jsr.io/@azcodr/azcodr)
5
+ [![CI Status](https://github.com/prosubodh/azcodr/actions/workflows/ci.yml/badge.svg)](https://github.com/prosubodh/azcodr/actions/workflows/ci.yml)
6
+ [![Coverage](https://img.shields.io/badge/coverage-100.00%25-brightgreen.svg)](https://github.com/prosubodh/azcodr)
7
+ [![Mutation Score](https://img.shields.io/badge/mutants%20killed-100%25-brightgreen.svg)](https://github.com/prosubodh/azcodr)
8
+ [![Dependencies](https://img.shields.io/badge/dependencies-0-success.svg)](https://www.npmjs.com/package/azcodr)
9
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
10
+
11
+ > **Production-oriented architecture governance and topology-scoped scaffolding for AI-assisted development (early release).**
12
+ > *AI agents move fast. Architecture drifts. Azcodr turns architectural intent into executable constraints your agent cannot skip.*
4
13
 
5
14
  ---
6
15
 
@@ -8,7 +17,7 @@
8
17
 
9
18
  1. **Problem-First & Topology Alignment**: Architecture emerges strictly from problem constraints and execution targets (Problem-First; zero preemptive tool bias). Architectural styles match the problem topology: Hexagonal for enterprise backends, Platform Scripting for extensions, Data-Oriented Design for game engines, Command Pipeline for CLIs, and Game Loop for canvas games.
10
19
  2. **Systemic Atomicity**: Every rule, skill, database transaction, and code unit adheres to the Single Responsibility Principle (SRP)—indivisible, self-contained, orthogonal, and composable with zero conjunction naming.
11
- 3. **Evolutionary Architecture & Refactor-Before-Add**: To eliminate AI-accelerated architectural drift, code graduates across 5 deterministic tipping points. Refactor structure first under existing green tests before implementing new features. Never append code into rotting files.
20
+ 3. **Evolutionary Architecture & Refactor-Before-Add**: To catch AI-accelerated architectural drift, code graduates across [5 deterministic tipping points](./docs/tipping-points.md). Refactor structure first under existing green tests before implementing new features. Never append code into rotting files.
12
21
  4. **True Incremental TDD & Nano-Cycles**: Prohibit batch-test dumps ("Test-First Waterfall"). Follow Uncle Bob's Three Laws: write one micro-assertion at a time, verify RED failure output, write minimal code to turn GREEN, and refactor under green with Ping-Pong pair programming.
13
22
  5. **100% Open-Source & Open Standards**: Standardized exclusively on open-source solutions and vendor-neutral specifications (OpenTelemetry, OPA, OpenFGA, Protocol Buffers, OpenAPI 3.1, JSON Schema Draft 2020-12, CloudEvents, Semgrep, Trivy, Gitleaks, Cosign).
14
23
  6. **Zero-Assumption Framework**: Ground truth is established solely through workspace configurations, code evidence, or direct user confirmation.
@@ -23,6 +32,67 @@
23
32
 
24
33
  ---
25
34
 
35
+ ## ⚡ 60-Second Demo: See Drift Prevention in Action
36
+
37
+ Azcodr turns architectural philosophy into machine-checked constraints your agent cannot skip.
38
+
39
+ ### 1. Standalone Architectural Check
40
+ Run the validator on any repository without scaffolding:
41
+ ```bash
42
+ npx azcodr check
43
+ ```
44
+ ```text
45
+ 🔍 Validating Architecture & Agent Invariants in: ./
46
+ --------------------------------------------------------------
47
+ 1. Root Config & Symlinks -> PASS
48
+ 2. Progressive Disclosure Rules -> PASS (28 rules verified)
49
+ 3. Specialized Skills (.agents) -> PASS (6 skills active)
50
+ 4. Markdown Cross-References -> PASS (0 broken links)
51
+ 5. Memory & ADR Ledger -> PASS (16 ADRs verified)
52
+ 6. ADR Index Consistency -> PASS
53
+ 🎉 SUCCESS: All architectural invariants are healthy! (0 warnings)
54
+ ```
55
+
56
+ ### 2. Real-Time PreToolUse Guard: Refactor-Before-Add
57
+ When an AI coding agent attempts to dump new logic into a file already exceeding 300 lines, Azcodr's agent hook intercepts the tool call at runtime before it touches the disk:
58
+ ```text
59
+ 🚨 TOOL USE BLOCKED: Refactor-Before-Add Violation
60
+ File 'src/auth.ts' has 315 lines (limit: 300).
61
+ Mutations that add code are blocked.
62
+ Extract strategy classes or helper modules to reduce file size before adding new features.
63
+ ```
64
+
65
+ ### 3. Zero-Dependency Boundary & Cycle Enforcement
66
+ Inspect dependency cycles and layer boundaries on demand without third-party linters:
67
+ ```bash
68
+ npx azcodr boundaries [directory]
69
+ ```
70
+ ```text
71
+ 🔍 Inspecting Architectural Boundaries in: ./src
72
+ --------------------------------------------------------------
73
+ 🚨 ARCHITECTURAL VIOLATIONS DETECTED (2):
74
+ - Circular Dependency: src/billing.ts -> src/tenant.ts -> src/billing.ts
75
+ - Layer Boundary Breach: src/domain/payment.ts illegally imports src/infrastructure/db.ts (domain -> infrastructure)
76
+ Action Required: Invert dependencies via Ports or extract shared modules.
77
+ ```
78
+
79
+ ### 4. Empirical Benchmark Proof (3 Arms, 10 Sequential Tickets)
80
+ In an automated empirical trial across 10 sequential tickets with 3 architectural traps ([`benchmark/RESULTS.md`](https://github.com/prosubodh/azcodr/blob/main/benchmark/RESULTS.md)):
81
+
82
+ | Metric | Arm A (Control) | Arm B (Hooks Only) | Arm C (Full Azcodr) |
83
+ |---|:---:|:---:|:---:|
84
+ | **Files >300 Lines** | 1 (365 lines in `auth.ts`) | **0** (Modularized) | **0** (Modularized) |
85
+ | **Circular Dependency Cycles** | 1 (`billing <-> tenant`) | 1 (`billing <-> tenant`) | **0** (Decoupled Port) |
86
+ | **Layer Boundary Breaches** | 1 (`domain -> infra`) | 1 (`domain -> infra`) | **0** (Hexagonal Port) |
87
+ | **Overall Drift Reduction** | ❌ FAILED | ❌ FAILED | ✅ **100% DRIFT-FREE** |
88
+
89
+ Run the empirical benchmark yourself:
90
+ ```bash
91
+ node benchmark/run-benchmark.js
92
+ ```
93
+
94
+ ---
95
+
26
96
  ## 🗂️ Workspace Architecture
27
97
 
28
98
  ```
@@ -165,4 +235,4 @@ The scaffolder declares two expected capabilities:
165
235
 
166
236
  Failures carry stable machine-readable codes (`E_TARGET_NOT_EMPTY`, `E_GIT_BLOCKED`, `E_PATH_ESCAPE`, ...). Branch on `err.code`, never on message text — see the exported `ERROR_CODES` map and `ScaffoldError` type.
167
237
 
168
- Initial-commit fallback identity is `Subodh Khanal <prosubodh@gmail.com>` via `GIT_AUTHOR_*` / `GIT_COMMITTER_*` env (no `git -c` shell flags).
238
+ Initial-commit fallback identity is `azcodr[bot] <bot@azcodr.internal>` via `GIT_AUTHOR_*` / `GIT_COMMITTER_*` env (no `git -c` shell flags).
package/SECURITY.md ADDED
@@ -0,0 +1,32 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 2.x | :white_check_mark: |
8
+ | 1.x | :x: |
9
+
10
+ ## Reporting a Vulnerability
11
+
12
+ We take the security of `azcodr` and the architectures scaffolded with it seriously. If you discover a security vulnerability, please report it responsibly:
13
+
14
+ 1. **GitHub Private Vulnerability Reporting (Preferred):**
15
+ Submit a private advisory directly through [GitHub Security Advisories](https://github.com/prosubodh/azcodr/security/advisories/new).
16
+ 2. **Email Disclosure:**
17
+ Email `prosubodh+security@gmail.com` with:
18
+ - Detailed description of the vulnerability and potential impact.
19
+ - Minimal, reproducible steps or proof-of-concept payload.
20
+ - Affected subsystem (`src/guards.ts`, `src/scaffold.ts`, `.agents/scripts/`, etc.).
21
+
22
+ ### Response Commitments
23
+ - **Initial Acknowledgment:** Within 48 hours.
24
+ - **Triage & Reproduction:** Within 5 business days.
25
+ - **Coordinated Disclosure:** Security patch release with accompanying advisory disclosure once remediated.
26
+
27
+ ### Scope & Hardening Invariants
28
+ The core supply-chain invariants defended by `azcodr` include:
29
+ - **Zero Runtime Dependencies:** Supply chain attack surface bounded to standard library Node.js builtins.
30
+ - **Strict Process Isolation:** No shell-string execution (`execSync`/`exec` forbidden; `execFileSync` requires `shell: false`).
31
+ - **Filesystem Containment:** Path boundary enforcement (`assertInside`) preventing directory traversal or escape.
32
+ - **Target Protection:** Refusal to write into system root, user home directory, or ancestors (`isProtectedTarget`), even with `--force`.
@@ -0,0 +1,36 @@
1
+ # Workspace Memory, Architecture Decisions & Knowledge Hub
2
+
3
+ > **Core Purpose:** Authoritative persistent memory ledger for the workspace repository (`./`), maintaining Lightweight Architectural Decision Records (ADRs), system topologies, and living domain contracts.
4
+
5
+ ---
6
+
7
+ ## 1. Quick Navigation & Knowledge Repositories
8
+
9
+ - 📖 **[Living Ubiquitous Language Glossary](./docs/knowledge/ubiquitous_language.md)**: Authoritative, single-name domain vocabulary contract.
10
+ - 📜 **[Lightweight ADR Master Index](#adr-master-index)**: Summary of all architectural decisions and direct links to governing rules.
11
+
12
+ ---
13
+
14
+ ## 2. Consolidated Architectural Decision Records (ADRs)
15
+
16
+ ### ADR Master Index
17
+
18
+ | ID | Title | Date | Status | Governing Rule / Skill |
19
+ |---|---|---|---|---|
20
+ | *(No decisions recorded yet)* | *Record initial architecture decisions during Phase 3 of /lets-build.* | *YYYY-MM-DD* | *ACCEPTED* | *e.g. [`clean_code.md`](./docs/rules/clean_code.md)* |
21
+
22
+ ---
23
+
24
+ ### Lightweight Decision Summaries
25
+
26
+ <!--
27
+ Record project Architectural Decision Records (ADRs) below as decisions are finalized.
28
+ Format:
29
+
30
+ #### ADR-001: [Imperative Title]
31
+ - **Date:** YYYY-MM-DD | **Status:** ACCEPTED
32
+ - **Context:** Problem space, constraints, and operational context requiring a decision.
33
+ - **Decision:** Chosen architecture, invariants, and implementation patterns.
34
+ - **Consequences:** Positive benefits and deliberate trade-offs accepted.
35
+ - **Enforced In:** Relevant rule files in docs/rules/ or code paths.
36
+ -->
@@ -60,3 +60,16 @@ Prevent AI-generated code rot using automated fitness functions integrated into
60
60
  - **Dependency Direction Gates**: Enforce unidirectional import rules (e.g. `import/no-restricted-paths`, `dependency-cruiser`, `ArchUnit`) ensuring domain core never imports infrastructure or transport adapters.
61
61
  - **Complexity Budgets**: Enforce cyclomatic complexity limits (maximum 10 per function).
62
62
  If an AI attempt to add code violates any fitness function, the build fails immediately, blocking completion until the architecture is refactored.
63
+
64
+ ### Polyglot Fitness Function Standards
65
+
66
+ When bootstrapping non-TypeScript projects via `/lets-build`, the agent must instantiate deterministic, automated fitness function gates matching these exact rules:
67
+
68
+ | Language | Linter / Static Tool | Max File Lines (300) | Max Function Lines (30) | Max Complexity (10) | Max Arguments (3) |
69
+ |---|---|---|---|---|---|
70
+ | **TypeScript / Node** | `eslint` | `max-lines: [error, 300]` | `max-lines-per-function: [error, 30]` | `complexity: [error, 10]` | `max-params: [error, 3]` |
71
+ | **Python** | `ruff` + `flake8` | `flake8-lines: max-line-count = 300` | `flake8-functions: max-function-length = 30` | `mccabe: max-complexity = 10` | `flake8-functions: max-parameters = 3` |
72
+ | **Rust** | `cargo clippy` | `#![deny(clippy::too_many_lines)]` | `clippy::too_many_lines = 30` | `clippy::cognitive_complexity = 10` | `clippy::too_many_arguments = 3` |
73
+ | **Go** | `golangci-lint` | `maintidx: 300` | `funlen: lines = 30` | `gocyclo: min-complexity = 10` | `funlen: statements = 25` |
74
+ | **Java** | `Checkstyle` + `ArchUnit` | `FileLength: max 300` | `MethodLength: max 30` | `CyclomaticComplexity: max 10` | `ParameterNumber: max 3` |
75
+ | **C# / .NET** | `.editorconfig` + Roslyn | `file_length = 300:error` | `method_length = 30:error` | `CA1502: Avoid excessive complexity <= 10` | `CA1501: max 3 params` |
@@ -0,0 +1,37 @@
1
+ # Deterministic Architectural Tipping Points
2
+
3
+ > **Core Mandate:** Architecture evolves incrementally as complexity grows. AI coding agents naturally take the path of least resistance (local token minimization), repeatedly appending code to simple files until they rot into a Big Ball of Mud. Whenever code crosses one of the 5 Deterministic Tipping Points, the agent must pause and execute an architectural refactor under green tests before adding new features.
4
+
5
+ ---
6
+
7
+ ## The 5 Deterministic Tipping Points
8
+
9
+ | # | Simple Baseline (Day 1) | Tipping Point / Mutation Trigger | Required Architectural Upgrade |
10
+ |---|---|---|---|
11
+ | **1** | **Flat Script / Single File** | File exceeds **250 lines**, coordinates **>2 distinct I/O resources**, or is imported by **>3 distinct callers**. | **Extract Modular Subsystems:** Decouple domain logic from platform I/O; split into dedicated, cohesive submodules. |
12
+ | **2** | **Inline Branching (`if/else` / `switch`)** | **Rule of Three:** The 3rd branching variant, payment provider, or protocol format is introduced. | **Strategy Pattern / Registry:** Replace conditional cascades with a polymorphic Strategy interface or handler registry; update `memory.md`. |
13
+ | **3** | **In-Memory Store / Global State** | State requires **concurrent mutations**, **persistence across restarts**, or **transactional rollback**. | **Repository Pattern & Persistence Port:** Introduce an explicit storage port contract; swap in-memory mock for a persistent database adapter. |
14
+ | **4** | **Direct Platform / Third-Party SDK Calls** | External SDK or platform API is called from **>2 places**, or throws untyped exceptions across boundaries. | **Adapter Pattern (Anti-Corruption Layer):** Wrap external SDK inside an application-owned port interface; mock only the owned interface in tests. |
15
+ | **5** | **Monolithic Domain Model** | The same business noun represents divergent lifecycles or definitions across workflows (e.g. `User` in Auth vs `User` in Billing). | **Bounded Context Split:** Separate into isolated domain contexts with explicit DTO / Anti-Corruption translation between them. |
16
+
17
+ ---
18
+
19
+ ## Refactor-Before-Add Protocol (Kent Beck's Rule)
20
+
21
+ > *"Make the change easy (warning: this may be hard), then make the easy change."* — Kent Beck
22
+
23
+ Before writing production code for any new feature or user story:
24
+
25
+ 1. **Assess Tipping Points**: Will adding this requirement cause any module, function, or data structure to cross an architectural tipping point?
26
+ 2. **Phase A — Structural Refactoring (Under Green)**: If yes, refactor the existing architecture *first* while existing test suites remain 100% green. Zero behavioral changes; purely structural evolution.
27
+ 3. **Phase B — ADR Mutation**: When an architectural tipping point is crossed, log a Lightweight Architectural Decision Record in `memory.md` summarizing the new structural boundary and trade-off.
28
+ 4. **Phase C — Feature Implementation (Inner TDD)**: Only once the architecture cleanly accommodates the new capability, write the failing micro-test and implement the feature.
29
+
30
+ ---
31
+
32
+ ## References
33
+
34
+ - [Clean Code & Pragmatic Directives](./rules/clean_code.md)
35
+ - [Design Patterns & Result Types](./rules/design_patterns.md)
36
+ - [Domain-Driven Design](./rules/domain_driven_design.md)
37
+ - [Test-Driven Development](./rules/test_driven_development.md)
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Command safety guard inspecting shell commands against a destructive denylist.
3
+ */
4
+ export interface CommandViolation {
5
+ blocked: boolean;
6
+ reason?: string;
7
+ command?: string;
8
+ }
9
+ export interface DenylistRule {
10
+ pattern: RegExp;
11
+ reason: string;
12
+ }
13
+ export declare const DESTRUCTIVE_RULES: readonly DenylistRule[];
14
+ export declare function normalizeCommand(raw: string): string;
15
+ /**
16
+ * Checks a command string against the safety denylist.
17
+ *
18
+ * @param command - Raw shell command string.
19
+ * @returns Violation details if blocked, or clean outcome.
20
+ */
21
+ export declare function inspectCommand(command: string): CommandViolation;
22
+ declare const _default: {
23
+ DESTRUCTIVE_RULES: readonly DenylistRule[];
24
+ normalizeCommand: typeof normalizeCommand;
25
+ inspectCommand: typeof inspectCommand;
26
+ };
27
+ export default _default;
28
+ //# sourceMappingURL=agent-guard-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-guard-command.d.ts","sourceRoot":"","sources":["../src/agent-guard-command.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,EAAE,SAAS,YAAY,EAyEpD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAehE;;;;;;AAED,wBAAuE"}