ai-engineering-loop 1.0.0 → 1.0.1

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.
@@ -0,0 +1,272 @@
1
+ # AI Engineering Loop
2
+
3
+ <div align="center">
4
+
5
+ [![NPM Version](https://img.shields.io/npm/v/ai-engineering-loop.svg?color=cb3837)](https://www.npmjs.com/package/ai-engineering-loop)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/egagofur/ai-engineering-loop/pulls)
8
+ [![AI Engineering](https://img.shields.io/badge/AI-Engineering%20Loop-orange.svg)](https://github.com/egagofur/ai-engineering-loop)
9
+ [![Release](https://img.shields.io/badge/release-v1.0.0-purple.svg)](https://github.com/egagofur/ai-engineering-loop/releases)
10
+
11
+ **A Reusable, Framework-Agnostic AI Engineering Operating System for Autonomous Coding Agents**
12
+
13
+ *Featuring living project context, post-task impact assessment, contract-driven execution, deterministic machine verification, and independent adversarial review.*
14
+
15
+ [Overview](#overview--philosophy) • [Living Project Context](#living-project-context) • [CLI Commands](#cli-interface--commands) • [Agent Integration](#antigravity-agent-integration) • [Lifecycle](#lifecycle-stages) • [Architecture](#architecture--5-layer-configuration) • [Project Profiles](#project-profiles) • [Repository Structure](#repository-structure) • [Reference Examples](#reference-examples) • [Contributing](#contributing)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## Overview & Philosophy
22
+
23
+ The AI Engineering Loop enforces a clean architectural separation between **Deterministic Living Context Bootstrap** and **Agent Intelligence**:
24
+
25
+ > **"The CLI bootstraps, tracks, and validates living context. The AI Agent reasons over that context to execute the engineering lifecycle."**
26
+
27
+ ```mermaid
28
+ flowchart TD
29
+ Start([User Task in Workspace]) --> PreCheck{Pre-Task Drift Check: metadata.json}
30
+
31
+ PreCheck -->|Context Missing| AutoInit[Stage 0: Bootstrap .ai-engineering-loop/]
32
+ PreCheck -->|Drift Detected| Reconcile[Stage 0: Reconcile Drifted Context]
33
+ PreCheck -->|Context Fresh| GC[Stage 1: Goal Contract: Explicit Acceptance Criteria]
34
+
35
+ AutoInit --> GC
36
+ Reconcile --> GC
37
+
38
+ subgraph CoreEngine [AI ENGINEERING OPERATING SYSTEM]
39
+ GC --> RCA[Stage 2: Root Cause Analysis]
40
+ RCA --> Plan[Stage 3: Implementation Plan]
41
+ Plan --> MA[Stage 4: Maker Agent: Surgical Diff & Tests]
42
+ MA --> DV{Stage 5: Deterministic Verification}
43
+
44
+ DV -->|Fail| MA
45
+ DV -->|Pass| DA[Stage 6: Devil's Advocate: Adversarial Review]
46
+
47
+ DA --> JD[Stage 7: Judge Agent: Impartial Magistrate]
48
+ end
49
+
50
+ JD -->|PASS| ImpactEval{Post-Task Context Impact Assessment}
51
+
52
+ ImpactEval -->|NONE: Typo, UI tweak| Adapter[Stage 8: Delivery Adapter: GitLab / GitHub]
53
+ ImpactEval -->|TARGETED: Dep/route changed| PartialRefresh[Surgical Context Update] --> Adapter
54
+ ImpactEval -->|MAJOR: Framework migration| FullRefresh[Full Context Reconciliation] --> Adapter
55
+
56
+ Adapter --> TargetRepo[(Target Repository)]
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Living Project Context
62
+
63
+ The `.ai-engineering-loop/` directory is **Living Context**, not a static wiki generated once.
64
+
65
+ ### 1. Post-Task Context Impact Assessment
66
+ A task reaching `PASS` does **not** blindly trigger a full project refresh. The agent evaluates the impact level:
67
+ - **`NONE` (80–90% of tasks)**: Typo fixes, CSS tweaks, surgical bugfixes preserving architecture $\rightarrow$ Refresh SKIPPED.
68
+ - **`TARGETED` (10–15% of tasks)**: Manifest script change (`verification.md`), new module (`architecture.md`), new CI config (`adapter.md`) $\rightarrow$ Surgically update affected files only.
69
+ - **`MAJOR` (<5% of tasks)**: Framework migration, monorepo restructuring, auth overhaul $\rightarrow$ Full context reconciliation.
70
+
71
+ ### 2. Context Baseline (`metadata.json`)
72
+ Deterministic drift detection without a database:
73
+ - Tracks `repositoryRevision` (git commit SHA), `manifestChecksums`, and `lastReconciliation`.
74
+ - Enables instant **Level 0 (0ms)** drift verification on subsequent agent invocations.
75
+
76
+ ### 3. Strict Context Isolation
77
+ - **Project Context (`.ai-engineering-loop/`)**: Shared, living ground truth of engineering rules and architecture.
78
+ - **Task Context**: Transient task contracts, acceptance criteria, and active diff scope.
79
+ - **Loop State**: Ephemeral finding signatures, iteration counters, and retry attempts.
80
+
81
+ ---
82
+
83
+ ## CLI Interface & Commands
84
+
85
+ The CLI package is published on NPM as [`ai-engineering-loop`](https://www.npmjs.com/package/ai-engineering-loop) and operates against the current working directory.
86
+
87
+ ```bash
88
+ # Bootstrap .ai-engineering-loop/ context from repository discovery
89
+ npx ai-engineering-loop init
90
+
91
+ # Check the validity, readiness, and baseline freshness of context
92
+ npx ai-engineering-loop status
93
+
94
+ # Reconcile drifted context against repository non-destructively
95
+ npx ai-engineering-loop refresh
96
+
97
+ # Verify context readiness and begin engineering loop
98
+ npx ai-engineering-loop run
99
+ ```
100
+
101
+ ### Command Responsibilities:
102
+
103
+ | Command | Purpose | Expected Writes | Mutates App Code? |
104
+ |---|---|---|:---:|
105
+ | **`init`** | Analyzes repository topology, manifests, and test scripts to generate `.ai-engineering-loop/`. | `.ai-engineering-loop/*` | **NO** |
106
+ | **`status`** | Audits the completeness of context files and checks baseline drift (`CURRENT` / `STALE`). | None | **NO** |
107
+ | **`refresh`** | Re-analyzes manifests and surgically updates drifted sections while preserving human notes. | `.ai-engineering-loop/*` | **NO** |
108
+ | **`run`** | Loads verified context and triggers the AI Agent to execute task engineering. | Governed by Task Scope | By Agent |
109
+
110
+ ---
111
+
112
+ ## Antigravity Agent Integration
113
+
114
+ When working inside the Antigravity IDE or compatible agentic platforms, you can invoke the loop via slash commands:
115
+
116
+ - **`/ai-engineering-loop init`**: Initialize project context only (non-destructive bootstrap).
117
+ - **`/ai-engineering-loop status`**: Check repository context health & baseline freshness.
118
+ - **`/ai-engineering-loop refresh`**: Reconcile drifted context files non-destructively.
119
+ - **`/ai-engineering-loop [task description]`**: Execute the full 8-stage engineering lifecycle with pre-task drift gate and post-task impact assessment.
120
+
121
+ ---
122
+
123
+ ## Lifecycle Stages
124
+
125
+ 1. **Stage 0: Living Context & Drift Gate ([`core/project-initialization.md`](core/project-initialization.md), [`core/context-refresh-policy.md`](core/context-refresh-policy.md))**:
126
+ - Check `metadata.json` baseline. If fresh $\rightarrow$ proceed. If missing or drifted $\rightarrow$ reconcile context.
127
+ 2. **Stage 1: Goal Contract ([`core/goal-contract.md`](core/goal-contract.md))**: Formulate explicit, testable Acceptance Criteria.
128
+ 3. **Stage 2: Root Cause Analysis**: End-to-end data tracing and git commit history examination.
129
+ 4. **Stage 3: Implementation Plan**: Structured diff proposal and test plan.
130
+ 5. **Stage 4: Maker Execution ([`agents/maker.md`](agents/maker.md))**: Surgical implementation and test engineering.
131
+ 6. **Stage 5: Deterministic Verification ([`core/verification-loop.md`](core/verification-loop.md))**: 100% green pass on tests, typechecks, linters, and builds.
132
+ 7. **Stage 6: Devil's Advocate Review ([`agents/devil-advocate.md`](agents/devil-advocate.md))**: Layered adversarial critique with concrete alternative diffs.
133
+ 8. **Stage 7: Judge & Impact Assessment ([`agents/judge.md`](agents/judge.md), [`core/context-impact-assessment.md`](core/context-impact-assessment.md))**: Impartial verdict (`PASS`/`ITERATE`/`ESCALATE`) followed by Context Impact Assessment (`NONE`/`TARGETED`/`MAJOR`).
134
+ 9. **Stage 8: Delivery Pipeline ([`adapters/`](adapters/))**: Automated PR/MR generation, multi-branch propagation, and notification dispatch.
135
+
136
+ ---
137
+
138
+ ## Architecture & 5-Layer Configuration
139
+
140
+ The system dynamically resolves configuration and review rules through a cascading 5-layer hierarchy:
141
+
142
+ $$\text{GLOBAL} \longrightarrow \text{ENGINEERING CORE} \longrightarrow \text{PROJECT TYPE PROFILE} \longrightarrow \text{PROJECT CONFIG (`.ai-engineering-loop/`)} \longrightarrow \text{TASK CONTRACT}$$
143
+
144
+ 1. **GLOBAL**: Host execution safety limits and maximum iteration ceilings (`MAX_ITERATIONS <= 5`).
145
+ 2. **ENGINEERING CORE**: Universal loop invariants ([Goal Contract](core/goal-contract.md), [Verification Loop](core/verification-loop.md), [Definition of Done](core/definition-of-done.md)).
146
+ 3. **PROJECT TYPE PROFILE ([`profiles/`](profiles/README.md))**: Archetype defaults for web applications, backend APIs, mobile apps, libraries, or monorepos.
147
+ 4. **PROJECT CONFIGURATION (`<repo>/.ai-engineering-loop/`)**: Target repository ground truth ([`verification.md`](templates/repo-config/verification.md), [`architecture.md`](templates/repo-config/architecture.md), [`conventions.md`](templates/repo-config/conventions.md)).
148
+ 5. **TASK CONTRACT**: Active task-scoped acceptance criteria and diff constraints.
149
+
150
+ ---
151
+
152
+ ## Project Profiles
153
+
154
+ Profiles define technology-specific characteristics and activate relevant review domains for the Devil's Advocate without modifying the core engine:
155
+
156
+ | Profile | Specification | Target Tech Stack | Active Review Focus |
157
+ |---|---|---|---|
158
+ | **`web-app`** | [web-app.md](profiles/web-app.md) | Next.js, Remix, Vite, React, Vue | DOM rendering, responsiveness (320px–4k), accessibility (a11y/ARIA), client state, Core Web Vitals |
159
+ | **`backend-api`** | [backend-api.md](profiles/backend-api.md) | Go, Node.js, Python, Java, PostgreSQL | Auth/IDOR, database transactions & ACID rollbacks, concurrency locks (`SELECT FOR UPDATE`), N+1 query loops |
160
+ | **`mobile-app`** | [mobile-app.md](profiles/mobile-app.md) | Flutter, React Native, iOS (Swift), Android (Kotlin) | Offline sync queues, OS lifecycle termination & state loss, permission denials, battery/GPS hygiene |
161
+ | **`library`** | [library.md](profiles/library.md) | npm/PyPI packages, SDKs, crates | SemVer public API stability, zero dependency bloat, cross-runtime compatibility, bundle tree-shaking |
162
+ | **`monorepo`** | [monorepo.md](profiles/monorepo.md) | Turborepo, Nx, Cargo/pnpm workspaces | Cross-package boundaries, circular dependencies, affected scope testing, workspace cache invalidation |
163
+
164
+ Profile index: [profiles/README.md](profiles/README.md).
165
+
166
+ ---
167
+
168
+ ## Repository Structure
169
+
170
+ ```text
171
+ ai-engineering-loop/
172
+
173
+ ├── README.md # Operating system overview & architecture
174
+ ├── LICENSE # MIT Open Source License
175
+ ├── package.json # CLI package manifest
176
+
177
+ ├── bin/ # CLI execution entrypoints
178
+ │ └── ai-engineering-loop.js # npx executable CLI (init, status, refresh, run)
179
+
180
+ ├── scripts/ # Shell installers
181
+ │ └── init.sh # Convenience one-liner installer
182
+
183
+ ├── core/ # Generic engineering loop specifications
184
+ │ ├── project-initialization.md # Auto-discovery & initialization lifecycle
185
+ │ ├── context-refresh-policy.md # Progressive drift hierarchy & living baseline
186
+ │ ├── context-impact-assessment.md # Post-task impact assessment (NONE, TARGETED, MAJOR)
187
+ │ ├── goal-contract.md # Task contract schema & acceptance criteria
188
+ │ ├── verification-loop.md # Dual-layer verification lifecycle
189
+ │ ├── definition-of-done.md # 5 pillars of Done & rejection triggers
190
+ │ ├── iteration-policy.md # Bounded autonomous loop (MAX_ITERATIONS = 3)
191
+ │ ├── escalation-policy.md # Deterministic human escalation triggers
192
+ │ ├── judge-policy.md # Evaluation rules, triage audit, & verdicts
193
+ │ ├── configuration-precedence.md # 5-layer precedence & conflict resolution
194
+ │ └── repo-config-schema.md # Schema for target repo .ai-engineering-loop/
195
+
196
+ ├── profiles/ # Project archetype profiles
197
+ │ ├── README.md # Profile catalog & auto-detection rules
198
+ │ ├── web-app.md # Frontend web applications
199
+ │ ├── backend-api.md # Backend APIs & microservices
200
+ │ ├── mobile-app.md # Native & cross-platform mobile apps
201
+ │ ├── library.md # Reusable SDKs & shared packages
202
+ │ └── monorepo.md # Multi-package monorepo workspaces
203
+
204
+ ├── agents/ # Triad agent role specifications
205
+ │ ├── maker.md # Maker agent: surgical diffs & unit tests
206
+ │ ├── devil-advocate.md # Adversarial reviewer: layered review rules & concrete diffs
207
+ │ └── judge.md # Judge agent: neutral magistrate & verdict computation
208
+
209
+ ├── policies/ # Operational schemas & algorithms
210
+ │ ├── discovery-safety-policy.md # Secret protection & non-destructive discovery rules
211
+ │ ├── finding-policy.md # Standardized finding schema & severity matrix
212
+ │ ├── evidence-policy.md # 5-level evidence hierarchy
213
+ │ └── no-progress-policy.md # Finding signature hashing & stagnation detection
214
+
215
+ ├── adapters/ # Pluggable delivery pipelines
216
+ │ └── dot/ # DOT Indonesia delivery adapter
217
+ │ ├── README.md # DOT adapter overview
218
+ │ ├── gitlab.md # glab CLI, issue cards, & MR generation
219
+ │ ├── multi-branch.md # main / staging / develop cherry-pick propagation
220
+ │ ├── coreview.md # @coreview-bot external review triage (Valid vs Halu)
221
+ │ └── mattermost.md # Channel mapping & MCP dispatch (from: "AI Agent")
222
+
223
+ ├── templates/ # Starter templates for target repositories
224
+ │ └── repo-config/ # Ready-to-copy .ai-engineering-loop/ files
225
+ │ ├── config.md # Project identity & profile binding
226
+ │ ├── architecture.md # Layers & boundary invariants
227
+ │ ├── conventions.md # Code standards & forbidden patterns
228
+ │ ├── verification.md # CLI test/lint/build commands
229
+ │ └── adapter.md # Configured release pipeline
230
+
231
+ ├── examples/ # End-to-end multi-archetype reference walkthroughs
232
+ │ ├── initialization/ # Unconfigured Monorepo auto-discovery trace
233
+ │ ├── dot/attendance-confirmation/ # Scenario A: DOT Web Application bugfix & multi-branch MRs
234
+ │ ├── backend-api/payment-idempotency/# Scenario B: Go/PostgreSQL race condition & idempotency fix
235
+ │ └── mobile-app/offline-sync-queue/ # Scenario C: Flutter/SQLite offline sync queue
236
+
237
+ └── docs/ # Meta-documentation & integration guides
238
+ ├── migration-plan.md # 8-phase legacy workflow mapping & rationale
239
+ └── antigravity-feasibility.md # Antigravity runtime evaluation & subagent orchestration
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Reference Examples
245
+
246
+ - **[Auto-Initialization Trace](examples/initialization/README.md)**: Demonstrates the step-by-step discovery of an unconfigured TypeScript/Go monorepo.
247
+ - **[Scenario A: DOT Web Application](examples/dot/attendance-confirmation/README.md)**: Resolves an attendance status bug across `main`, `staging`, and `develop` with `@coreview-bot` triage and Mattermost dispatch.
248
+ - **[Scenario B: Backend API Service](examples/backend-api/payment-idempotency/README.md)**: Eliminates double-spend race conditions in Go/PostgreSQL with `SELECT FOR UPDATE` and automated race test suites.
249
+ - **[Scenario C: Mobile Application](examples/mobile-app/offline-sync-queue/README.md)**: Implements an offline SQLite mutation queue in Flutter with network flapping tolerance and state preservation.
250
+
251
+ ---
252
+
253
+ ## Contributing
254
+
255
+ Contributions, feedback, and new adapter profiles are welcome.
256
+
257
+ 1. Fork the repository (`https://github.com/egagofur/ai-engineering-loop/fork`).
258
+ 2. Create your feature branch (`git checkout -b feature/new-adapter`).
259
+ 3. Ensure all changes adhere to [core/definition-of-done.md](core/definition-of-done.md).
260
+ 4. Open a Pull Request.
261
+
262
+ ---
263
+
264
+ ## License
265
+
266
+ This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
267
+
268
+ ---
269
+
270
+ <div align="center">
271
+ Designed for software engineering teams and autonomous AI coding agents.
272
+ </div>
package/README.md CHANGED
@@ -1,272 +1,63 @@
1
1
  # AI Engineering Loop
2
2
 
3
- <div align="center">
4
-
3
+ [![NPM Version](https://img.shields.io/npm/v/ai-engineering-loop.svg?color=cb3837)](https://www.npmjs.com/package/ai-engineering-loop)
5
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/egagofur/ai-engineering-loop/pulls)
7
- [![AI Engineering](https://img.shields.io/badge/AI-Engineering%20Loop-orange.svg)](https://github.com/egagofur/ai-engineering-loop)
8
- [![Release](https://img.shields.io/badge/release-v1.0.0-purple.svg)](https://github.com/egagofur/ai-engineering-loop/releases)
9
- [![Status](https://img.shields.io/badge/status-production--ready-success.svg)](https://github.com/egagofur/ai-engineering-loop)
5
+ [![GitHub](https://img.shields.io/badge/GitHub-Repository-black.svg)](https://github.com/egagofur/ai-engineering-loop)
10
6
 
11
7
  **A Reusable, Framework-Agnostic AI Engineering Operating System for Autonomous Coding Agents**
12
8
 
13
- *Featuring living project context, post-task impact assessment, contract-driven execution, deterministic machine verification, and independent adversarial review.*
14
-
15
- [Overview](#overview--philosophy) • [Living Project Context](#living-project-context) • [CLI Commands](#cli-interface--commands) • [Agent Integration](#antigravity-agent-integration) • [Lifecycle](#lifecycle-stages) • [Architecture](#architecture--5-layer-configuration) • [Project Profiles](#project-profiles) • [Repository Structure](#repository-structure) • [Reference Examples](#reference-examples) • [Contributing](#contributing)
16
-
17
- </div>
18
-
19
- ---
20
-
21
- ## Overview & Philosophy
22
-
23
- The AI Engineering Loop enforces a clean architectural separation between **Deterministic Living Context Bootstrap** and **Agent Intelligence**:
24
-
25
- > **"The CLI bootstraps, tracks, and validates living context. The AI Agent reasons over that context to execute the engineering lifecycle."**
26
-
27
- ```mermaid
28
- flowchart TD
29
- Start([User Task in Workspace]) --> PreCheck{Pre-Task Drift Check: metadata.json}
30
-
31
- PreCheck -->|Context Missing| AutoInit[Stage 0: Bootstrap .ai-engineering-loop/]
32
- PreCheck -->|Drift Detected| Reconcile[Stage 0: Reconcile Drifted Context]
33
- PreCheck -->|Context Fresh| GC[Stage 1: Goal Contract: Explicit Acceptance Criteria]
34
-
35
- AutoInit --> GC
36
- Reconcile --> GC
37
-
38
- subgraph CoreEngine [AI ENGINEERING OPERATING SYSTEM]
39
- GC --> RCA[Stage 2: Root Cause Analysis]
40
- RCA --> Plan[Stage 3: Implementation Plan]
41
- Plan --> MA[Stage 4: Maker Agent: Surgical Diff & Tests]
42
- MA --> DV{Stage 5: Deterministic Verification}
43
-
44
- DV -->|Fail| MA
45
- DV -->|Pass| DA[Stage 6: Devil's Advocate: Adversarial Review]
46
-
47
- DA --> JD[Stage 7: Judge Agent: Impartial Magistrate]
48
- end
49
-
50
- JD -->|PASS| ImpactEval{Post-Task Context Impact Assessment}
51
-
52
- ImpactEval -->|NONE: Typo, UI tweak| Adapter[Stage 8: Delivery Adapter: GitLab / GitHub]
53
- ImpactEval -->|TARGETED: Dep/route changed| PartialRefresh[Surgical Context Update] --> Adapter
54
- ImpactEval -->|MAJOR: Framework migration| FullRefresh[Full Context Reconciliation] --> Adapter
55
-
56
- Adapter --> TargetRepo[(Target Repository)]
57
- ```
58
-
59
- ---
60
-
61
- ## Living Project Context
62
-
63
- The `.ai-engineering-loop/` directory is **Living Context**, not a static wiki generated once.
64
-
65
- ### 1. Post-Task Context Impact Assessment
66
- A task reaching `PASS` does **not** blindly trigger a full project refresh. The agent evaluates the impact level:
67
- - **`NONE` (80–90% of tasks)**: Typo fixes, CSS tweaks, surgical bugfixes preserving architecture $\rightarrow$ Refresh SKIPPED.
68
- - **`TARGETED` (10–15% of tasks)**: Manifest script change (`verification.md`), new module (`architecture.md`), new CI config (`adapter.md`) $\rightarrow$ Surgically update affected files only.
69
- - **`MAJOR` (<5% of tasks)**: Framework migration, monorepo restructuring, auth overhaul $\rightarrow$ Full context reconciliation.
70
-
71
- ### 2. Context Baseline (`metadata.json`)
72
- Deterministic drift detection without a database:
73
- - Tracks `repositoryRevision` (git commit SHA), `manifestChecksums`, and `lastReconciliation`.
74
- - Enables instant **Level 0 (0ms)** drift verification on subsequent agent invocations.
75
-
76
- ### 3. Strict Context Isolation
77
- - **Project Context (`.ai-engineering-loop/`)**: Shared, living ground truth of engineering rules and architecture.
78
- - **Task Context**: Transient task contracts, acceptance criteria, and active diff scope.
79
- - **Loop State**: Ephemeral finding signatures, iteration counters, and retry attempts.
9
+ Move beyond linear AI pipelines and optimistic self-evaluation toward contract-driven execution, deterministic machine verification, independent adversarial review, and living project context.
80
10
 
81
11
  ---
82
12
 
83
- ## CLI Interface & Commands
13
+ ## Quickstart CLI
84
14
 
85
- The CLI operates against the current working directory without maintaining a centralized project registry.
15
+ Run the CLI in any repository root without global installation:
86
16
 
87
17
  ```bash
88
- # Bootstrap .ai-engineering-loop/ context from repository discovery
18
+ # 1. Bootstrap .ai-engineering-loop/ context from repository discovery
89
19
  npx ai-engineering-loop init
90
20
 
91
- # Check the validity, readiness, and baseline freshness of context
21
+ # 2. Check the validity, readiness, and baseline freshness of context
92
22
  npx ai-engineering-loop status
93
23
 
94
- # Reconcile drifted context against repository non-destructively
24
+ # 3. Reconcile drifted context against repository non-destructively
95
25
  npx ai-engineering-loop refresh
96
26
 
97
- # Verify context readiness and begin engineering loop
27
+ # 4. Verify context readiness and begin engineering loop
98
28
  npx ai-engineering-loop run
99
29
  ```
100
30
 
101
- ### Command Responsibilities:
102
-
103
- | Command | Purpose | Expected Writes | Mutates App Code? |
104
- |---|---|---|:---:|
105
- | **`init`** | Analyzes repository topology, manifests, and test scripts to generate `.ai-engineering-loop/`. | `.ai-engineering-loop/*` | **NO** |
106
- | **`status`** | Audits the completeness of context files and checks baseline drift (`CURRENT` / `STALE`). | None | **NO** |
107
- | **`refresh`** | Re-analyzes manifests and surgically updates drifted sections while preserving human notes. | `.ai-engineering-loop/*` | **NO** |
108
- | **`run`** | Loads verified context and triggers the AI Agent to execute task engineering. | Governed by Task Scope | By Agent |
109
-
110
31
  ---
111
32
 
112
- ## Antigravity Agent Integration
113
-
114
- When working inside the Antigravity IDE or compatible agentic platforms, you can invoke the loop via slash commands:
33
+ ## What It Does
115
34
 
116
- - **`/ai-engineering-loop init`**: Initialize project context only (non-destructive bootstrap).
117
- - **`/ai-engineering-loop status`**: Check repository context health & baseline freshness.
118
- - **`/ai-engineering-loop refresh`**: Reconcile drifted context files non-destructively.
119
- - **`/ai-engineering-loop [task description]`**: Execute the full 8-stage engineering lifecycle with pre-task drift gate and post-task impact assessment.
35
+ 1. **Zero-Config Discovery (`init`)**: Analyzes repository topology (monorepo vs single app), package manifests (`package.json`, `go.mod`, `Cargo.toml`, etc.), frameworks, and test scripts to generate `.ai-engineering-loop/`.
36
+ 2. **Living Project Context**: Tracks repository revisions and manifest checksums in `metadata.json` for instant drift detection.
37
+ 3. **Multi-Agent Triad**: Coordinates **Maker** (surgical diffs & tests), **Devil's Advocate** (independent adversarial review), and **Judge** (impartial evaluation & PASS certification).
38
+ 4. **Context Impact Assessment**: Evaluates completed tasks (`NONE`, `TARGETED`, `MAJOR`) to keep project context fresh without expensive whole-repo re-analysis.
120
39
 
121
40
  ---
122
41
 
123
- ## Lifecycle Stages
42
+ ## Antigravity IDE Integration
124
43
 
125
- 1. **Stage 0: Living Context & Drift Gate ([`core/project-initialization.md`](core/project-initialization.md), [`core/context-refresh-policy.md`](core/context-refresh-policy.md))**:
126
- - Check `metadata.json` baseline. If fresh $\rightarrow$ proceed. If missing or drifted $\rightarrow$ reconcile context.
127
- 2. **Stage 1: Goal Contract ([`core/goal-contract.md`](core/goal-contract.md))**: Formulate explicit, testable Acceptance Criteria.
128
- 3. **Stage 2: Root Cause Analysis**: End-to-end data tracing and git commit history examination.
129
- 4. **Stage 3: Implementation Plan**: Structured diff proposal and test plan.
130
- 5. **Stage 4: Maker Execution ([`agents/maker.md`](agents/maker.md))**: Surgical implementation and test engineering.
131
- 6. **Stage 5: Deterministic Verification ([`core/verification-loop.md`](core/verification-loop.md))**: 100% green pass on tests, typechecks, linters, and builds.
132
- 7. **Stage 6: Devil's Advocate Review ([`agents/devil-advocate.md`](agents/devil-advocate.md))**: Layered adversarial critique with concrete alternative diffs.
133
- 8. **Stage 7: Judge & Impact Assessment ([`agents/judge.md`](agents/judge.md), [`core/context-impact-assessment.md`](core/context-impact-assessment.md))**: Impartial verdict (`PASS`/`ITERATE`/`ESCALATE`) followed by Context Impact Assessment (`NONE`/`TARGETED`/`MAJOR`).
134
- 9. **Stage 8: Delivery Pipeline ([`adapters/`](adapters/))**: Automated PR/MR generation, multi-branch propagation, and notification dispatch.
135
-
136
- ---
44
+ In Antigravity IDE or compatible agentic platforms, invoke the loop directly in chat:
137
45
 
138
- ## Architecture & 5-Layer Configuration
139
-
140
- The system dynamically resolves configuration and review rules through a cascading 5-layer hierarchy:
141
-
142
- $$\text{GLOBAL} \longrightarrow \text{ENGINEERING CORE} \longrightarrow \text{PROJECT TYPE PROFILE} \longrightarrow \text{PROJECT CONFIG (`.ai-engineering-loop/`)} \longrightarrow \text{TASK CONTRACT}$$
143
-
144
- 1. **GLOBAL**: Host execution safety limits and maximum iteration ceilings (`MAX_ITERATIONS <= 5`).
145
- 2. **ENGINEERING CORE**: Universal loop invariants ([Goal Contract](core/goal-contract.md), [Verification Loop](core/verification-loop.md), [Definition of Done](core/definition-of-done.md)).
146
- 3. **PROJECT TYPE PROFILE ([`profiles/`](profiles/README.md))**: Archetype defaults for web applications, backend APIs, mobile apps, libraries, or monorepos.
147
- 4. **PROJECT CONFIGURATION (`<repo>/.ai-engineering-loop/`)**: Target repository ground truth ([`verification.md`](templates/repo-config/verification.md), [`architecture.md`](templates/repo-config/architecture.md), [`conventions.md`](templates/repo-config/conventions.md)).
148
- 5. **TASK CONTRACT**: Active task-scoped acceptance criteria and diff constraints.
46
+ - `/ai-engineering-loop init` Bootstrap project context only.
47
+ - `/ai-engineering-loop status` — Check context health and living freshness.
48
+ - `/ai-engineering-loop refresh` Reconcile drifted context files.
49
+ - `/ai-engineering-loop <task>` — Execute the full 8-stage engineering lifecycle.
149
50
 
150
51
  ---
151
52
 
152
- ## Project Profiles
53
+ ## Complete Documentation & Specifications
153
54
 
154
- Profiles define technology-specific characteristics and activate relevant review domains for the Devil's Advocate without modifying the core engine:
55
+ For the complete architectural specifications, project profiles (`web-app`, `backend-api`, `mobile-app`, `library`, `monorepo`), delivery adapters (GitLab, GitHub, Mattermost), and reference examples:
155
56
 
156
- | Profile | Specification | Target Tech Stack | Active Review Focus |
157
- |---|---|---|---|
158
- | **`web-app`** | [web-app.md](profiles/web-app.md) | Next.js, Remix, Vite, React, Vue | DOM rendering, responsiveness (320px–4k), accessibility (a11y/ARIA), client state, Core Web Vitals |
159
- | **`backend-api`** | [backend-api.md](profiles/backend-api.md) | Go, Node.js, Python, Java, PostgreSQL | Auth/IDOR, database transactions & ACID rollbacks, concurrency locks (`SELECT FOR UPDATE`), N+1 query loops |
160
- | **`mobile-app`** | [mobile-app.md](profiles/mobile-app.md) | Flutter, React Native, iOS (Swift), Android (Kotlin) | Offline sync queues, OS lifecycle termination & state loss, permission denials, battery/GPS hygiene |
161
- | **`library`** | [library.md](profiles/library.md) | npm/PyPI packages, SDKs, crates | SemVer public API stability, zero dependency bloat, cross-runtime compatibility, bundle tree-shaking |
162
- | **`monorepo`** | [monorepo.md](profiles/monorepo.md) | Turborepo, Nx, Cargo/pnpm workspaces | Cross-package boundaries, circular dependencies, affected scope testing, workspace cache invalidation |
163
-
164
- Profile index: [profiles/README.md](profiles/README.md).
165
-
166
- ---
167
-
168
- ## Repository Structure
169
-
170
- ```text
171
- ai-engineering-loop/
172
-
173
- ├── README.md # Operating system overview & architecture
174
- ├── LICENSE # MIT Open Source License
175
- ├── package.json # CLI package manifest
176
-
177
- ├── bin/ # CLI execution entrypoints
178
- │ └── ai-engineering-loop.js # npx executable CLI (init, status, refresh, run)
179
-
180
- ├── scripts/ # Shell installers
181
- │ └── init.sh # Convenience one-liner installer
182
-
183
- ├── core/ # Generic engineering loop specifications
184
- │ ├── project-initialization.md # Auto-discovery & initialization lifecycle
185
- │ ├── context-refresh-policy.md # Progressive drift hierarchy & living baseline
186
- │ ├── context-impact-assessment.md # Post-task impact assessment (NONE, TARGETED, MAJOR)
187
- │ ├── goal-contract.md # Task contract schema & acceptance criteria
188
- │ ├── verification-loop.md # Dual-layer verification lifecycle
189
- │ ├── definition-of-done.md # 5 pillars of Done & rejection triggers
190
- │ ├── iteration-policy.md # Bounded autonomous loop (MAX_ITERATIONS = 3)
191
- │ ├── escalation-policy.md # Deterministic human escalation triggers
192
- │ ├── judge-policy.md # Evaluation rules, triage audit, & verdicts
193
- │ ├── configuration-precedence.md # 5-layer precedence & conflict resolution
194
- │ └── repo-config-schema.md # Schema for target repo .ai-engineering-loop/
195
-
196
- ├── profiles/ # Project archetype profiles
197
- │ ├── README.md # Profile catalog & auto-detection rules
198
- │ ├── web-app.md # Frontend web applications
199
- │ ├── backend-api.md # Backend APIs & microservices
200
- │ ├── mobile-app.md # Native & cross-platform mobile apps
201
- │ ├── library.md # Reusable SDKs & shared packages
202
- │ └── monorepo.md # Multi-package monorepo workspaces
203
-
204
- ├── agents/ # Triad agent role specifications
205
- │ ├── maker.md # Maker agent: surgical diffs & unit tests
206
- │ ├── devil-advocate.md # Adversarial reviewer: layered review rules & concrete diffs
207
- │ └── judge.md # Judge agent: neutral magistrate & verdict computation
208
-
209
- ├── policies/ # Operational schemas & algorithms
210
- │ ├── discovery-safety-policy.md # Secret protection & non-destructive discovery rules
211
- │ ├── finding-policy.md # Standardized finding schema & severity matrix
212
- │ ├── evidence-policy.md # 5-level evidence hierarchy
213
- │ └── no-progress-policy.md # Finding signature hashing & stagnation detection
214
-
215
- ├── adapters/ # Pluggable delivery pipelines
216
- │ └── dot/ # DOT Indonesia delivery adapter
217
- │ ├── README.md # DOT adapter overview
218
- │ ├── gitlab.md # glab CLI, issue cards, & MR generation
219
- │ ├── multi-branch.md # main / staging / develop cherry-pick propagation
220
- │ ├── coreview.md # @coreview-bot external review triage (Valid vs Halu)
221
- │ └── mattermost.md # Channel mapping & MCP dispatch (from: "AI Agent")
222
-
223
- ├── templates/ # Starter templates for target repositories
224
- │ └── repo-config/ # Ready-to-copy .ai-engineering-loop/ files
225
- │ ├── config.md # Project identity & profile binding
226
- │ ├── architecture.md # Layers & boundary invariants
227
- │ ├── conventions.md # Code standards & forbidden patterns
228
- │ ├── verification.md # CLI test/lint/build commands
229
- │ └── adapter.md # Configured release pipeline
230
-
231
- ├── examples/ # End-to-end multi-archetype reference walkthroughs
232
- │ ├── initialization/ # Unconfigured Monorepo auto-discovery trace
233
- │ ├── dot/attendance-confirmation/ # Scenario A: DOT Web Application bugfix & multi-branch MRs
234
- │ ├── backend-api/payment-idempotency/# Scenario B: Go/PostgreSQL race condition & idempotency fix
235
- │ └── mobile-app/offline-sync-queue/ # Scenario C: Flutter/SQLite offline sync queue
236
-
237
- └── docs/ # Meta-documentation & integration guides
238
- ├── migration-plan.md # 8-phase legacy workflow mapping & rationale
239
- └── antigravity-feasibility.md # Antigravity runtime evaluation & subagent orchestration
240
- ```
241
-
242
- ---
243
-
244
- ## Reference Examples
245
-
246
- - **[Auto-Initialization Trace](examples/initialization/README.md)**: Demonstrates the step-by-step discovery of an unconfigured TypeScript/Go monorepo.
247
- - **[Scenario A: DOT Web Application](examples/dot/attendance-confirmation/README.md)**: Resolves an attendance status bug across `main`, `staging`, and `develop` with `@coreview-bot` triage and Mattermost dispatch.
248
- - **[Scenario B: Backend API Service](examples/backend-api/payment-idempotency/README.md)**: Eliminates double-spend race conditions in Go/PostgreSQL with `SELECT FOR UPDATE` and automated race test suites.
249
- - **[Scenario C: Mobile Application](examples/mobile-app/offline-sync-queue/README.md)**: Implements an offline SQLite mutation queue in Flutter with network flapping tolerance and state preservation.
250
-
251
- ---
252
-
253
- ## Contributing
254
-
255
- Contributions, feedback, and new adapter profiles are welcome.
256
-
257
- 1. Fork the repository (`https://github.com/egagofur/ai-engineering-loop/fork`).
258
- 2. Create your feature branch (`git checkout -b feature/new-adapter`).
259
- 3. Ensure all changes adhere to [core/definition-of-done.md](core/definition-of-done.md).
260
- 4. Open a Pull Request.
57
+ 👉 **[Visit the GitHub Repository](https://github.com/egagofur/ai-engineering-loop)**
261
58
 
262
59
  ---
263
60
 
264
61
  ## License
265
62
 
266
- This project is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
267
-
268
- ---
269
-
270
- <div align="center">
271
- Designed for software engineering teams and autonomous AI coding agents.
272
- </div>
63
+ MIT License — see [LICENSE](https://github.com/egagofur/ai-engineering-loop/blob/main/LICENSE) for details.
package/README.npm.md ADDED
@@ -0,0 +1,63 @@
1
+ # AI Engineering Loop
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/ai-engineering-loop.svg?color=cb3837)](https://www.npmjs.com/package/ai-engineering-loop)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![GitHub](https://img.shields.io/badge/GitHub-Repository-black.svg)](https://github.com/egagofur/ai-engineering-loop)
6
+
7
+ **A Reusable, Framework-Agnostic AI Engineering Operating System for Autonomous Coding Agents**
8
+
9
+ Move beyond linear AI pipelines and optimistic self-evaluation toward contract-driven execution, deterministic machine verification, independent adversarial review, and living project context.
10
+
11
+ ---
12
+
13
+ ## Quickstart CLI
14
+
15
+ Run the CLI in any repository root without global installation:
16
+
17
+ ```bash
18
+ # 1. Bootstrap .ai-engineering-loop/ context from repository discovery
19
+ npx ai-engineering-loop init
20
+
21
+ # 2. Check the validity, readiness, and baseline freshness of context
22
+ npx ai-engineering-loop status
23
+
24
+ # 3. Reconcile drifted context against repository non-destructively
25
+ npx ai-engineering-loop refresh
26
+
27
+ # 4. Verify context readiness and begin engineering loop
28
+ npx ai-engineering-loop run
29
+ ```
30
+
31
+ ---
32
+
33
+ ## What It Does
34
+
35
+ 1. **Zero-Config Discovery (`init`)**: Analyzes repository topology (monorepo vs single app), package manifests (`package.json`, `go.mod`, `Cargo.toml`, etc.), frameworks, and test scripts to generate `.ai-engineering-loop/`.
36
+ 2. **Living Project Context**: Tracks repository revisions and manifest checksums in `metadata.json` for instant drift detection.
37
+ 3. **Multi-Agent Triad**: Coordinates **Maker** (surgical diffs & tests), **Devil's Advocate** (independent adversarial review), and **Judge** (impartial evaluation & PASS certification).
38
+ 4. **Context Impact Assessment**: Evaluates completed tasks (`NONE`, `TARGETED`, `MAJOR`) to keep project context fresh without expensive whole-repo re-analysis.
39
+
40
+ ---
41
+
42
+ ## Antigravity IDE Integration
43
+
44
+ In Antigravity IDE or compatible agentic platforms, invoke the loop directly in chat:
45
+
46
+ - `/ai-engineering-loop init` — Bootstrap project context only.
47
+ - `/ai-engineering-loop status` — Check context health and living freshness.
48
+ - `/ai-engineering-loop refresh` — Reconcile drifted context files.
49
+ - `/ai-engineering-loop <task>` — Execute the full 8-stage engineering lifecycle.
50
+
51
+ ---
52
+
53
+ ## Complete Documentation & Specifications
54
+
55
+ For the complete architectural specifications, project profiles (`web-app`, `backend-api`, `mobile-app`, `library`, `monorepo`), delivery adapters (GitLab, GitHub, Mattermost), and reference examples:
56
+
57
+ 👉 **[Visit the GitHub Repository](https://github.com/egagofur/ai-engineering-loop)**
58
+
59
+ ---
60
+
61
+ ## License
62
+
63
+ MIT License — see [LICENSE](https://github.com/egagofur/ai-engineering-loop/blob/main/LICENSE) for details.
@@ -15,7 +15,7 @@ const path = require('path');
15
15
  const crypto = require('crypto');
16
16
  const { execSync } = require('child_process');
17
17
 
18
- const VERSION = '1.0.0';
18
+ const VERSION = '1.0.1';
19
19
  const CWD = process.cwd();
20
20
  const CONTEXT_DIR = path.join(CWD, '.ai-engineering-loop');
21
21
 
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "ai-engineering-loop",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A reusable, framework-agnostic AI Engineering Operating System for autonomous coding agents.",
5
5
  "main": "bin/ai-engineering-loop.js",
6
6
  "bin": {
7
7
  "ai-engineering-loop": "bin/ai-engineering-loop.js"
8
8
  },
9
9
  "scripts": {
10
- "init": "node bin/ai-engineering-loop.js"
10
+ "init": "node bin/ai-engineering-loop.js",
11
+ "prepublishOnly": "node scripts/prepare-npm.js",
12
+ "postpublish": "node scripts/restore-github.js"
11
13
  },
12
14
  "repository": {
13
15
  "type": "git",
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const rootDir = path.resolve(__dirname, '..');
7
+ const readmePath = path.join(rootDir, 'README.md');
8
+ const readmeNpmPath = path.join(rootDir, 'README.npm.md');
9
+ const backupPath = path.join(rootDir, '.README.github.bak.md');
10
+
11
+ if (fs.existsSync(readmeNpmPath)) {
12
+ // Backup full GitHub README
13
+ fs.copyFileSync(readmePath, backupPath);
14
+ // Replace with simplified NPM README for packing
15
+ fs.copyFileSync(readmeNpmPath, readmePath);
16
+ console.log('[prepare-npm] Swapped README.md with simplified README.npm.md for NPM packaging.');
17
+ }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const rootDir = path.resolve(__dirname, '..');
7
+ const readmePath = path.join(rootDir, 'README.md');
8
+ const backupPath = path.join(rootDir, '.README.github.bak.md');
9
+
10
+ if (fs.existsSync(backupPath)) {
11
+ // Restore full GitHub README
12
+ fs.copyFileSync(backupPath, readmePath);
13
+ fs.unlinkSync(backupPath);
14
+ console.log('[restore-github] Restored full GitHub README.md successfully.');
15
+ }