engineering-intelligence 0.8.1 → 1.1.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 (60) hide show
  1. package/README.md +23 -2
  2. package/dist/adapters/index.d.ts.map +1 -1
  3. package/dist/adapters/index.js +55 -11
  4. package/dist/adapters/index.js.map +1 -1
  5. package/dist/cli/index.js +20 -2
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/installer/index.d.ts.map +1 -1
  8. package/dist/installer/index.js +2 -10
  9. package/dist/installer/index.js.map +1 -1
  10. package/dist/manifest/index.d.ts +1 -1
  11. package/dist/manifest/index.js +1 -1
  12. package/dist/templates.d.ts +4 -3
  13. package/dist/templates.d.ts.map +1 -1
  14. package/dist/templates.js +59 -1
  15. package/dist/templates.js.map +1 -1
  16. package/dist/validation/index.d.ts.map +1 -1
  17. package/dist/validation/index.js +4 -12
  18. package/dist/validation/index.js.map +1 -1
  19. package/dist/visualizer/index.d.ts.map +1 -1
  20. package/dist/visualizer/index.js +100 -5
  21. package/dist/visualizer/index.js.map +1 -1
  22. package/package.json +1 -1
  23. package/templates/canonical/agents/adversary.md +19 -0
  24. package/templates/canonical/agents/compliance-auditor.md +20 -0
  25. package/templates/canonical/agents/database-administrator.md +21 -0
  26. package/templates/canonical/agents/documentation-writer.md +19 -0
  27. package/templates/canonical/agents/engineering-orchestrator.md +49 -8
  28. package/templates/canonical/agents/performance-analyst.md +19 -0
  29. package/templates/canonical/agents/product-analyst.md +5 -1
  30. package/templates/canonical/agents/release-engineer.md +20 -0
  31. package/templates/canonical/agents/security-officer.md +21 -0
  32. package/templates/canonical/agents/site-reliability-engineer.md +19 -0
  33. package/templates/canonical/agents/system-architect.md +27 -0
  34. package/templates/canonical/agents/test-engineer.md +20 -0
  35. package/templates/canonical/rules/engineering-intelligence.md +45 -4
  36. package/templates/canonical/skills/aidlc-lifecycle-engine/SKILL.md +141 -0
  37. package/templates/canonical/skills/codebase-discovery-engine/SKILL.md +428 -0
  38. package/templates/canonical/skills/convention-detector/SKILL.md +199 -0
  39. package/templates/canonical/skills/debugging-engine/SKILL.md +189 -0
  40. package/templates/canonical/skills/engineering-intelligence-skill/SKILL.md +30 -1
  41. package/templates/canonical/skills/environmental-backpressure-engine/SKILL.md +50 -0
  42. package/templates/canonical/skills/git-intelligence-engine/SKILL.md +146 -0
  43. package/templates/canonical/skills/graph-engine/SKILL.md +30 -5
  44. package/templates/canonical/skills/greenfield-architect/SKILL.md +287 -0
  45. package/templates/canonical/skills/impact-analysis-engine/SKILL.md +12 -4
  46. package/templates/canonical/skills/incremental-sync-engine/SKILL.md +17 -0
  47. package/templates/canonical/skills/mcp-security-governor/SKILL.md +51 -0
  48. package/templates/canonical/skills/nfr-adr-governor/SKILL.md +83 -0
  49. package/templates/canonical/skills/ongoing-learning-engine/SKILL.md +175 -0
  50. package/templates/canonical/skills/operations-readiness-engine/SKILL.md +54 -0
  51. package/templates/canonical/skills/performance-analysis-engine/SKILL.md +156 -0
  52. package/templates/canonical/skills/pr-intelligence-engine/SKILL.md +127 -0
  53. package/templates/canonical/skills/requirement-scoper/SKILL.md +17 -3
  54. package/templates/canonical/skills/security-audit-engine/SKILL.md +165 -0
  55. package/templates/canonical/skills/staleness-detector/SKILL.md +185 -0
  56. package/templates/canonical/workflows/create-project.md +63 -0
  57. package/templates/canonical/workflows/discover-codebase.md +60 -0
  58. package/templates/canonical/workflows/engineering-intelligence.md +12 -8
  59. package/templates/canonical/workflows/initialize-engineering-intelligence.md +3 -1
  60. package/templates/canonical/workflows/scope-requirement.md +5 -4
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: aidlc-lifecycle-engine
3
+ description: Runs the adaptive AI-DLC lifecycle with Discovery, Inception, Construction, Operations, durable artifacts, hatted agents, and objective completion gates.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # AI-DLC Lifecycle Engine
8
+
9
+ Use this skill inside the existing Engineering Intelligence workflows. It is not a separate command family. It turns Agile intent into an adaptive, artifact-driven delivery path while preserving familiar Agile concepts: vision, backlog, user stories, acceptance criteria, sprint planning, implementation, review, release readiness, and retrospective learning.
10
+
11
+ ## Runtime Artifacts
12
+
13
+ Use `.engineering-intelligence/aidlc/` as the canonical AI-DLC root:
14
+
15
+ | Path | Purpose |
16
+ |---|---|
17
+ | `.engineering-intelligence/aidlc/aidlc-state.md` | Active phase, stage, workflow, hat, unit, and completion status |
18
+ | `.engineering-intelligence/aidlc/audit.md` | Append-only chronological log of decisions, user answers, tool checks, and transitions |
19
+ | `.engineering-intelligence/aidlc/open-questions.md` | Unresolved ambiguities and owner/status |
20
+ | `.engineering-intelligence/aidlc/execution-plan.md` | Adaptive stage plan with mandatory/conditional/skipped stages |
21
+ | `.engineering-intelligence/aidlc/discovery/vision.md` | Business objectives, personas, value, success metrics |
22
+ | `.engineering-intelligence/aidlc/discovery/technical-environment.md` | Runtime, deployment, integrations, data stores, auth, constraints |
23
+ | `.engineering-intelligence/aidlc/agile/product-backlog.md` | Epics, stories, priorities, dependencies, and status |
24
+ | `.engineering-intelligence/aidlc/agile/sprint-plan.md` | Active sprint goal, selected stories, capacity, risks, and commitments |
25
+ | `.engineering-intelligence/aidlc/agile/acceptance-criteria.md` | Story-level acceptance criteria expressed as executable validation targets |
26
+ | `.engineering-intelligence/aidlc/agile/definition-of-ready.md` | Readiness checklist before construction |
27
+ | `.engineering-intelligence/aidlc/agile/definition-of-done.md` | Completion checklist after validation and sync |
28
+ | `.engineering-intelligence/aidlc/agile/retrospective.md` | Lessons, process improvements, recurring risks, and follow-ups |
29
+ | `.engineering-intelligence/aidlc/inception/requirements.md` | Validated functional requirements and edge cases |
30
+ | `.engineering-intelligence/aidlc/inception/reverse-engineering/` | Brownfield architecture, API, code structure, component inventory, technology stack |
31
+ | `.engineering-intelligence/aidlc/construction/cross-unit-discoveries.md` | Shared discoveries from parallel or sequential units |
32
+ | `.engineering-intelligence/aidlc/construction/<unit>/` | Unit functional design, NFR design, ADRs, code plan, build/test evidence |
33
+ | `.engineering-intelligence/aidlc/operations/` | Deployment readiness, observability, runbooks, rollback notes |
34
+
35
+ These AI-DLC files complement `knowledge-base/`, `.engineering-intelligence/memory/`, `.engineering-intelligence/context/`, `.engineering-intelligence/graph/`, `.engineering-intelligence/reports/`, and `.changes/`.
36
+
37
+ ## Embedded Agile + AI-DLC Model
38
+
39
+ Map Agile to AI-DLC this way:
40
+
41
+ | Agile Concept | AI-DLC Phase | Artifact |
42
+ |---|---|---|
43
+ | Product vision | Discovery | `discovery/vision.md` |
44
+ | Product backlog | Discovery / Inception | `agile/product-backlog.md` |
45
+ | User stories | Inception | `inception/requirements.md`, `agile/product-backlog.md` |
46
+ | Acceptance criteria | Inception / Construction | `agile/acceptance-criteria.md`, tests |
47
+ | Sprint planning | Inception | `agile/sprint-plan.md`, `execution-plan.md` |
48
+ | Development | Construction | `construction/<unit>/` |
49
+ | Daily inspection | Construction | `aidlc-state.md`, `audit.md`, `cross-unit-discoveries.md` |
50
+ | Sprint review | Construction / Operations | validation summary, review report |
51
+ | Release | Operations | `operations/operations-readiness.md` |
52
+ | Retrospective | Operations | `agile/retrospective.md` |
53
+
54
+ ## Adaptive Phase Model
55
+
56
+ ### 0. Discovery
57
+
58
+ Use when project intent, deployment environment, ownership, or constraints are unclear.
59
+
60
+ Outputs:
61
+ - `discovery/vision.md`
62
+ - `discovery/technical-environment.md`
63
+ - `open-questions.md`
64
+
65
+ Ask role-aware questions. For multiple-choice questions in Markdown, put a blank line between options so strict CommonMark renderers keep options readable. Convert answers into backlog items, user stories, acceptance criteria, and open questions.
66
+
67
+ ### 1. Inception
68
+
69
+ Always run workspace detection. Classify the repository as `greenfield` or `brownfield`.
70
+
71
+ For brownfield systems, run reverse engineering and write:
72
+ - `business-overview.md`
73
+ - `architecture.md`
74
+ - `code-structure.md`
75
+ - `api-documentation.md`
76
+ - `component-inventory.md`
77
+ - `technology-stack.md`
78
+
79
+ Then compile validated requirements, backlog updates, acceptance criteria, sprint plan, and an adaptive `execution-plan.md`.
80
+
81
+ ### 2. Construction
82
+
83
+ Execute per unit of work. Each unit may include:
84
+ - Functional design
85
+ - NFR requirements
86
+ - NFR design
87
+ - Infrastructure design
88
+ - Code generation plan
89
+ - Build and test summary
90
+
91
+ Before starting each unit, read `cross-unit-discoveries.md`. If new constraints appear, append finding, impact, and action taken.
92
+
93
+ ### 3. Operations
94
+
95
+ Use when deployment, infrastructure, observability, or production readiness is in scope. Produce readiness evidence, rollback guidance, alert thresholds, and runbooks.
96
+
97
+ ## Delivery Mode Selection
98
+
99
+ Within `/engineering-intelligence`, choose a delivery mode:
100
+
101
+ | Mode | Use When | Required Hats |
102
+ |---|---|---|
103
+ | Standard Agile Delivery | General feature, bugfix, refactor, or update | Product Analyst, System Architect, Component Builder, Test Engineer, Documentation Writer |
104
+ | Adversarial Delivery | Auth, payment, public API, data exposure, critical business rules | Security Officer, Adversary, Compliance Auditor, Test Engineer |
105
+ | TDD Delivery | High-reliability business logic or service contracts | Product Analyst, Test Engineer, Component Builder |
106
+ | Design-First Delivery | Major migrations, new architecture, data model redesign | System Architect, Database Administrator, Security Officer, Compliance Auditor |
107
+ | Hypothesis Debugging | Production bugs, regressions, memory leaks, trace failures | Orchestration Lead, Performance Analyst, SRE, Component Builder |
108
+
109
+ ## Objective Completion Criteria
110
+
111
+ Each stage must end with binary evidence:
112
+ - Artifact exists at the expected path
113
+ - Story is Ready before implementation and Done before completion
114
+ - Unknowns are recorded or resolved
115
+ - Required tests, type checks, linters, scans, or build commands ran, failed, or were explicitly unavailable
116
+ - Human approval is recorded before irreversible actions
117
+ - Breadcrumb is updated in `aidlc-state.md`
118
+
119
+ ## Environmental Backpressure
120
+
121
+ Use compilers, strict linters, type systems, test suites, security scanners, architecture checks, and local reproducer scripts as direct feedback. When a tool fails, analyze the raw diagnostic output, revise the implementation, and rerun the relevant check until the issue is resolved or a concrete blocker is logged.
122
+
123
+ ## Progress Breadcrumb
124
+
125
+ End AI-DLC-enabled workflow responses with one compact status line:
126
+
127
+ ```text
128
+ AI-DLC: <phase> -> <stage> -> <status>
129
+ ```
130
+
131
+ ## Quality Gates
132
+
133
+ - [ ] Discovery artifacts exist when initial intent or environment was ambiguous
134
+ - [ ] Backlog, stories, acceptance criteria, Definition of Ready, and Definition of Done are updated for product work
135
+ - [ ] Workspace is classified as greenfield or brownfield
136
+ - [ ] Brownfield reverse engineering exists before broad changes
137
+ - [ ] Requirements and execution plan are durable files
138
+ - [ ] Construction is split into explicit units
139
+ - [ ] Cross-unit discoveries are loaded and updated
140
+ - [ ] Validation uses environmental backpressure
141
+ - [ ] Operations readiness is addressed when deployment or production behavior changes
@@ -0,0 +1,428 @@
1
+ ---
2
+ name: codebase-discovery-engine
3
+ description: Autonomously explores and deeply understands a codebase before asking any questions. Scans repo structure, identifies tech stack with confidence scores, builds architecture hypotheses, maps entry points, detects conventions, analyzes git history, and produces a structured discovery report. Invoke when onboarding to a new repository or when deep understanding is required.
4
+ version: 3.0.0
5
+ ---
6
+
7
+ # Codebase Discovery Engine
8
+
9
+ Autonomously explore and understand a codebase with minimal human interaction. The engine operates in four phases: automated discovery, hypothesis verification, targeted clarification, and confidence reporting. The goal is to build a comprehensive mental model of the project before asking any questions.
10
+
11
+ This capability does not modify product code.
12
+
13
+ ## Inputs
14
+
15
+ - Repository root path (current working directory by default)
16
+ - Optional: scope constraints (specific package, service, directory, or monorepo workspace)
17
+ - Optional: depth limit (shallow = top-level only, deep = full recursive analysis)
18
+
19
+ ## Outputs
20
+
21
+ - `.engineering-intelligence/reports/DISCOVERY-report.md` — structured discovery findings with per-area confidence scores
22
+ - Feeds directly into `initialize-intelligence-skill` for knowledge base generation
23
+
24
+ ---
25
+
26
+ ## Phase 1: Automated Discovery (No User Interaction)
27
+
28
+ Execute ALL of the following scans silently. Do not prompt the user during this phase.
29
+
30
+ ### 1.1 Repository Structure Scan
31
+
32
+ 1. **File tree analysis** — Generate annotated directory tree (top 3 levels). Identify:
33
+ - Source code directories vs configuration vs documentation vs generated output
34
+ - Monorepo workspace boundaries
35
+ - Hidden directories with significance (`.github`, `.gitlab`, `.circleci`, `.husky`, `.changeset`)
36
+ 2. **File count distribution** — Count files by extension to determine primary and secondary languages
37
+ 3. **Gitignore analysis** — Read `.gitignore` to understand build outputs, generated files, and secrets patterns
38
+ 4. **Workspace root markers** — Identify the true project root vs nested project roots
39
+
40
+ ### 1.2 Package Management Detection
41
+
42
+ Scan for ALL of the following package manifests and extract dependency information:
43
+
44
+ | Ecosystem | Manifest Files | Lock Files | What to Extract |
45
+ |---|---|---|---|
46
+ | **Node.js** | `package.json` | `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `bun.lockb` | dependencies, devDependencies, scripts, workspaces, engines |
47
+ | **Go** | `go.mod`, `go.sum` | — | module path, Go version, require directives |
48
+ | **Rust** | `Cargo.toml` | `Cargo.lock` | dependencies, features, workspace members, edition |
49
+ | **Python** | `pyproject.toml`, `setup.py`, `setup.cfg`, `requirements.txt`, `Pipfile`, `poetry.lock` | `poetry.lock`, `Pipfile.lock` | dependencies, python version, build system |
50
+ | **Java/Kotlin** | `pom.xml`, `build.gradle`, `build.gradle.kts`, `settings.gradle` | — | dependencies, plugins, modules, Java version |
51
+ | **Ruby** | `Gemfile`, `*.gemspec` | `Gemfile.lock` | gems, ruby version, groups |
52
+ | **PHP** | `composer.json` | `composer.lock` | require, autoload, scripts |
53
+ | **.NET** | `*.csproj`, `*.sln`, `Directory.Build.props` | — | PackageReference, TargetFramework |
54
+ | **Elixir** | `mix.exs` | `mix.lock` | deps, elixir version |
55
+ | **Swift** | `Package.swift` | `Package.resolved` | dependencies, targets |
56
+
57
+ ### 1.3 Build System Identification
58
+
59
+ | Build Tool | Detection Files | What to Extract |
60
+ |---|---|---|
61
+ | **Webpack** | `webpack.config.*` | entry points, output config, loaders, plugins |
62
+ | **Vite** | `vite.config.*` | plugins, build target, SSR config |
63
+ | **Turbopack** | `turbo.json` (with Next.js) | — |
64
+ | **Turborepo** | `turbo.json` | pipeline tasks, cache config, workspace dependencies |
65
+ | **Nx** | `nx.json`, `project.json` | targets, executors, affected config |
66
+ | **Lerna** | `lerna.json` | versioning strategy, packages |
67
+ | **Bazel** | `WORKSPACE`, `BUILD`, `*.bzl` | targets, rules, dependencies |
68
+ | **Make** | `Makefile`, `GNUmakefile` | targets, phony targets, key variables |
69
+ | **Cargo** | `Cargo.toml` (already scanned) | build scripts, features |
70
+ | **Gradle** | `build.gradle*`, `gradlew` | tasks, plugins, subprojects |
71
+ | **Maven** | `pom.xml` (already scanned) | phases, plugins, profiles |
72
+ | **CMake** | `CMakeLists.txt` | targets, find_package calls |
73
+ | **pnpm workspaces** | `pnpm-workspace.yaml` | workspace packages |
74
+
75
+ ### 1.4 Framework Detection
76
+
77
+ Identify frameworks with **confidence scores** by cross-referencing dependencies, file patterns, and configuration:
78
+
79
+ | Category | Frameworks to Detect | Key Signals |
80
+ |---|---|---|
81
+ | **Frontend** | Next.js, Nuxt, Remix, SvelteKit, Astro, Gatsby, Create React App, Vite+React, Vite+Vue, Vite+Svelte, Angular, Solid.js, Qwik | `next.config.*`, `nuxt.config.*`, `remix.config.*`, `svelte.config.*`, `astro.config.*`, `angular.json`, framework deps in package.json |
82
+ | **Backend** | Express, Fastify, Koa, Hono, NestJS, Django, Flask, FastAPI, Spring Boot, Rails, Phoenix, Gin, Fiber, Echo, ASP.NET | Framework imports in entry files, decorator patterns, config files |
83
+ | **Mobile** | React Native, Flutter, Swift UI, Jetpack Compose, Expo | `app.json`, `pubspec.yaml`, `*.swift`, `build.gradle` with Android plugins |
84
+ | **Desktop** | Electron, Tauri | `electron-builder.*`, `tauri.conf.json` |
85
+ | **Full-stack** | T3 Stack, Blitz.js, RedwoodJS, Wasp | Meta-framework config patterns |
86
+
87
+ ### 1.5 Database & ORM Detection
88
+
89
+ | ORM / DB Tool | Detection Signals |
90
+ |---|---|
91
+ | **Prisma** | `prisma/schema.prisma`, `@prisma/client` in deps |
92
+ | **TypeORM** | `typeorm` in deps, `ormconfig.*`, entity decorators |
93
+ | **Drizzle** | `drizzle-orm` in deps, `drizzle.config.*` |
94
+ | **Sequelize** | `sequelize` in deps, `.sequelizerc`, migration dirs |
95
+ | **Mongoose** | `mongoose` in deps, schema definitions |
96
+ | **SQLAlchemy** | `sqlalchemy` in deps, `alembic/` dir, model files |
97
+ | **Django ORM** | `models.py` in Django apps, `DATABASES` in settings |
98
+ | **Hibernate** | `hibernate.cfg.xml`, JPA annotations |
99
+ | **ActiveRecord** | `db/migrate/`, `app/models/`, Rails conventions |
100
+ | **Knex** | `knex` in deps, `knexfile.*`, migration dirs |
101
+ | **MikroORM** | `@mikro-orm/*` in deps, `mikro-orm.config.*` |
102
+ | **Diesel** | `diesel` in Cargo.toml, `diesel.toml`, migrations dir |
103
+ | **GORM** | `gorm.io/gorm` in go.mod |
104
+ | **Ent** | `entgo.io/ent` in go.mod, `ent/schema/` dir |
105
+ | **Raw SQL** | `.sql` files, query builder usage without ORM |
106
+ | **Database engines** | Connection strings, Docker services: PostgreSQL, MySQL, MongoDB, Redis, SQLite, DynamoDB, Cassandra, CockroachDB |
107
+
108
+ ### 1.6 Authentication Detection
109
+
110
+ | Auth Solution | Detection Signals |
111
+ |---|---|
112
+ | **NextAuth / Auth.js** | `next-auth` in deps, `[...nextauth].ts`, `auth.config.*` |
113
+ | **Passport.js** | `passport` in deps, strategy configurations |
114
+ | **JWT patterns** | `jsonwebtoken` / `jose` in deps, token signing/verification code |
115
+ | **OAuth / OpenID** | OAuth client configs, redirect URIs, provider setup |
116
+ | **SAML** | `passport-saml`, SAML metadata files |
117
+ | **Clerk** | `@clerk/*` in deps, Clerk middleware |
118
+ | **Auth0** | `@auth0/*` in deps, Auth0 config |
119
+ | **Supabase Auth** | `@supabase/supabase-js` with auth usage |
120
+ | **Firebase Auth** | `firebase/auth` imports |
121
+ | **Keycloak** | Keycloak adapter configs |
122
+ | **Custom auth** | Hand-rolled middleware with session/token logic |
123
+ | **RBAC/ABAC** | Role definitions, permission matrices, guard patterns |
124
+
125
+ ### 1.7 CI/CD Detection
126
+
127
+ | CI/CD Platform | Detection Files | What to Extract |
128
+ |---|---|---|
129
+ | **GitHub Actions** | `.github/workflows/*.yml` | Jobs, triggers, matrix strategies, secrets refs |
130
+ | **GitLab CI** | `.gitlab-ci.yml` | Stages, jobs, rules, includes |
131
+ | **Jenkins** | `Jenkinsfile` | Pipeline stages, agents, post actions |
132
+ | **CircleCI** | `.circleci/config.yml` | Jobs, workflows, orbs |
133
+ | **Travis CI** | `.travis.yml` | Language, stages, deploy |
134
+ | **Azure Pipelines** | `azure-pipelines.yml` | Stages, pools, templates |
135
+ | **Bitbucket Pipelines** | `bitbucket-pipelines.yml` | Steps, caches, deployments |
136
+ | **Drone CI** | `.drone.yml` | Steps, triggers, volumes |
137
+ | **Vercel** | `vercel.json` | Build config, rewrites, functions |
138
+ | **Netlify** | `netlify.toml` | Build command, plugins, redirects |
139
+ | **Railway** | `railway.json`, `Procfile` | Start commands, services |
140
+ | **Render** | `render.yaml` | Services, build/start commands |
141
+
142
+ ### 1.8 Infrastructure Detection
143
+
144
+ | Infrastructure | Detection Signals |
145
+ |---|---|
146
+ | **Docker** | `Dockerfile`, `.dockerignore`, `docker-compose.yml`, `docker-compose.*.yml` |
147
+ | **Kubernetes** | `k8s/`, `kubernetes/`, `*.yaml` with `apiVersion: apps/v1`, Helm charts (`Chart.yaml`) |
148
+ | **Terraform** | `*.tf`, `.terraform/`, `terraform.tfstate` |
149
+ | **Pulumi** | `Pulumi.yaml`, `Pulumi.*.yaml` |
150
+ | **CDK** | `cdk.json`, `lib/*-stack.ts` |
151
+ | **CloudFormation** | `template.yaml` with `AWSTemplateFormatVersion` |
152
+ | **Ansible** | `ansible.cfg`, `playbooks/`, `roles/` |
153
+ | **Serverless** | `serverless.yml`, `serverless.ts` |
154
+ | **SST** | `sst.config.ts` |
155
+
156
+ ### 1.9 Testing Detection
157
+
158
+ | Testing Tool | Detection Signals | What to Extract |
159
+ |---|---|---|
160
+ | **Jest** | `jest.config.*`, `jest` in deps | Test file patterns, coverage config, transforms |
161
+ | **Vitest** | `vitest.config.*`, `vitest` in deps | Test file patterns, coverage |
162
+ | **Mocha** | `.mocharc.*`, `mocha` in deps | Reporter, timeout, spec patterns |
163
+ | **pytest** | `pytest.ini`, `pyproject.toml [tool.pytest]`, `conftest.py` | Markers, fixtures, plugins |
164
+ | **JUnit** | `@Test` annotations, JUnit deps in build files | Test runners, assertion libs |
165
+ | **RSpec** | `.rspec`, `spec/`, `spec_helper.rb` | Configuration, shared contexts |
166
+ | **Go test** | `*_test.go` files | Test functions, benchmarks, table-driven tests |
167
+ | **Rust test** | `#[test]`, `#[cfg(test)]` | Unit vs integration test organization |
168
+ | **Cypress** | `cypress.config.*`, `cypress/` | E2E specs, component tests, fixtures |
169
+ | **Playwright** | `playwright.config.*` | Test projects, browsers, base URL |
170
+ | **Testing Library** | `@testing-library/*` in deps | Which framework variant (React, Vue, etc.) |
171
+ | **Storybook** | `.storybook/`, `*.stories.*` | Addons, framework, static dirs |
172
+ | **Supertest** | `supertest` in deps | API integration test patterns |
173
+
174
+ ### 1.10 Documentation & Existing Knowledge
175
+
176
+ 1. Read `README.md` — extract project description, setup instructions, architecture notes
177
+ 2. Scan `docs/` directory — identify existing architecture docs, API docs, guides
178
+ 3. Read `CONTRIBUTING.md` — extract development workflow, code standards, PR process
179
+ 4. Read `CHANGELOG.md` — understand release cadence, versioning strategy
180
+ 5. Read `ADR/` or `adr/` or `docs/decisions/` — existing architectural decision records
181
+ 6. Scan inline comments — look for `TODO`, `FIXME`, `HACK`, `XXX`, `NOTE` patterns
182
+ 7. Read `LICENSE` — identify license type
183
+
184
+ ### 1.11 Git History Analysis
185
+
186
+ 1. **Hotspot analysis** — Identify the 20 most-changed files via `git log --pretty=format: --name-only | sort | uniq -c | sort -rn | head -20`
187
+ 2. **Change velocity** — Commits per week/month over the last 6 months
188
+ 3. **Primary contributors per module** — `git shortlog -sn -- <path>` for major directories
189
+ 4. **Recent activity** — Files changed in the last 30 days (indicates active development areas)
190
+ 5. **Large commits** — Identify bulk refactors or migrations from git history
191
+ 6. **Branch patterns** — `git branch -r` to understand branching strategy (feature branches, release branches, trunk-based)
192
+ 7. **Tag/release pattern** — `git tag --sort=-creatordate | head -10` to understand versioning cadence
193
+
194
+ ### 1.12 Monorepo Detection
195
+
196
+ | Tool | Detection Signal |
197
+ |---|---|
198
+ | **Nx** | `nx.json`, `project.json` in subdirectories |
199
+ | **Turborepo** | `turbo.json` with `pipeline` |
200
+ | **Lerna** | `lerna.json` |
201
+ | **pnpm workspaces** | `pnpm-workspace.yaml` |
202
+ | **Yarn workspaces** | `workspaces` field in root `package.json` |
203
+ | **npm workspaces** | `workspaces` field in root `package.json` + npm lock |
204
+ | **Cargo workspaces** | `[workspace]` section in root `Cargo.toml` |
205
+ | **Go workspaces** | `go.work` file |
206
+ | **Bazel** | `WORKSPACE` + multiple `BUILD` files |
207
+
208
+ When a monorepo is detected:
209
+ - Enumerate all workspace packages/apps
210
+ - Identify shared libraries vs applications
211
+ - Map inter-package dependency graph
212
+ - Identify independent vs coupled packages
213
+
214
+ ---
215
+
216
+ ## Phase 2: Hypothesis Verification
217
+
218
+ After automated discovery, classify every finding by confidence level:
219
+
220
+ ### Confidence Classification Rules
221
+
222
+ | Level | Score | Action | Example |
223
+ |---|---|---|---|
224
+ | **HIGH** | >85% | State as fact with evidence | "The project uses Next.js 14 with App Router (evidence: `next.config.mjs`, `app/` directory structure, `next` v14.2.3 in package.json)" |
225
+ | **MEDIUM** | 50–85% | Present as belief with reasoning | "I believe the project uses a modular monolith pattern because modules communicate via direct imports rather than HTTP/events, and there are clear directory boundaries — correct?" |
226
+ | **LOW** | <50% | Ask a direct question | "I see Redis in docker-compose but no Redis client in dependencies. Is Redis used in production, or is it only for development?" |
227
+
228
+ ### Confidence Scoring Heuristic
229
+
230
+ - **Config file explicitly declares it** → 95% confidence
231
+ - **Dependency present + matching file patterns** → 85% confidence
232
+ - **Dependency present but no matching usage found** → 60% confidence
233
+ - **File patterns suggest it but no dependency** → 50% confidence
234
+ - **Inferred from indirect evidence only** → 30% confidence
235
+ - **Single ambiguous signal** → 15% confidence
236
+
237
+ ---
238
+
239
+ ## Phase 3: Targeted Clarification (Maximum 5–10 Questions)
240
+
241
+ After Phases 1 and 2, ask ONLY questions that cannot be answered from code evidence. Group them into these categories:
242
+
243
+ ### 3.1 Business Domain
244
+ - What is the core business domain? What problem does this solve for users?
245
+ - Are there domain-specific terms or jargon the team uses?
246
+
247
+ ### 3.2 Deployment & Environments
248
+ - Where is this deployed? (cloud provider, region, multi-region?)
249
+ - What environments exist? (dev, staging, preview, production)
250
+ - What is the deployment process? (manual, CD, blue-green, canary)
251
+
252
+ ### 3.3 Team Conventions
253
+ - What is the code review process? (required approvals, automated checks)
254
+ - What is the release cadence? (continuous, weekly, sprints)
255
+ - Are there unwritten rules not captured in linters or configs?
256
+
257
+ ### 3.4 Pain Points & Tech Debt
258
+ - What areas of the codebase cause the most friction?
259
+ - Is there an active migration or refactoring effort?
260
+ - Are there known reliability or performance issues?
261
+
262
+ ### 3.5 Future Direction
263
+ - What major changes are planned for the architecture?
264
+ - Are there technology migrations in progress or planned?
265
+
266
+ **Rules for clarification questions:**
267
+ - Never ask about something discoverable from code
268
+ - Never ask more than 10 questions total
269
+ - Group related questions together
270
+ - Provide your best guess alongside each question so the user can simply confirm or correct
271
+
272
+ ---
273
+
274
+ ## Phase 4: Confidence Report
275
+
276
+ Generate `.engineering-intelligence/reports/DISCOVERY-report.md` with this structure:
277
+
278
+ ```markdown
279
+ # Codebase Discovery Report
280
+
281
+ Generated: <timestamp>
282
+ Repository: <repo path>
283
+ Scope: <full repo | specific scope>
284
+
285
+ ## Executive Summary
286
+
287
+ <2-3 paragraph overview of the project, its purpose, tech stack, and architecture>
288
+
289
+ ## Tech Stack (Confidence Scores)
290
+
291
+ | Category | Detection | Confidence | Evidence |
292
+ |---|---|---|---|
293
+ | Primary Language | TypeScript | 95% | `tsconfig.json`, 847 `.ts` files |
294
+ | Framework | Next.js 14 (App Router) | 95% | `next.config.mjs`, `app/` dir |
295
+ | Database | PostgreSQL via Prisma | 90% | `prisma/schema.prisma`, `@prisma/client` |
296
+ | Auth | NextAuth v5 | 85% | `auth.config.ts`, `next-auth` dep |
297
+ | CI/CD | GitHub Actions | 95% | `.github/workflows/ci.yml` |
298
+ | ... | ... | ... | ... |
299
+
300
+ ## Architecture Hypothesis
301
+
302
+ <architecture pattern, layer definitions, module boundaries, communication patterns>
303
+
304
+ ### Architecture Confidence: <overall score>%
305
+
306
+ ## Entry Points
307
+
308
+ | Entry Point | Type | Path | Purpose |
309
+ |---|---|---|---|
310
+ | ... | ... | ... | ... |
311
+
312
+ ## Module Map
313
+
314
+ | Module | Path | Responsibility | Confidence |
315
+ |---|---|---|---|
316
+ | ... | ... | ... | ... |
317
+
318
+ ## Git Insights
319
+
320
+ ### Hotspots (Most Changed Files)
321
+ | File | Changes | Last Modified | Primary Contributor |
322
+ |---|---|---|---|
323
+ | ... | ... | ... | ... |
324
+
325
+ ### Change Velocity
326
+ <commits per week trend>
327
+
328
+ ### Active Areas (Last 30 Days)
329
+ <list of recently active directories/modules>
330
+
331
+ ## Detected Patterns
332
+
333
+ ### Naming Conventions
334
+ <observed patterns>
335
+
336
+ ### Code Organization
337
+ <folder structure patterns>
338
+
339
+ ### Import Patterns
340
+ <import style and organization>
341
+
342
+ ### Test Patterns
343
+ <test file placement, naming, assertion style>
344
+
345
+ ## Unknowns & Uncertainties
346
+
347
+ | Area | What's Unknown | Why It Matters | Suggested Resolution |
348
+ |---|---|---|---|
349
+ | ... | ... | ... | ... |
350
+
351
+ ## Clarification Questions
352
+
353
+ <numbered list of 5-10 targeted questions from Phase 3>
354
+
355
+ ## Per-Area Confidence Summary
356
+
357
+ | Area | Confidence | Status |
358
+ |---|---|---|
359
+ | Tech Stack | 92% | ✅ High |
360
+ | Architecture | 75% | ⚠️ Medium |
361
+ | Data Model | 88% | ✅ High |
362
+ | Auth & Security | 60% | ⚠️ Medium |
363
+ | Infrastructure | 45% | ❌ Low |
364
+ | Business Domain | 20% | ❌ Low — needs human input |
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Procedure
370
+
371
+ 1. **Scan repository structure** — Execute file tree analysis, file count distribution, and gitignore analysis from §1.1.
372
+
373
+ 2. **Detect package management** — Scan for all manifest files from §1.2. Record ecosystem, versions, and dependency counts.
374
+
375
+ 3. **Identify build system** — Check for all build tool indicators from §1.3. Note build commands from package scripts.
376
+
377
+ 4. **Detect frameworks** — Cross-reference dependencies, config files, and file patterns from §1.4. Assign initial confidence scores.
378
+
379
+ 5. **Detect data layer** — Scan for ORM configs, schema files, migration directories, and database connection patterns from §1.5.
380
+
381
+ 6. **Detect authentication** — Look for auth libraries, middleware, token patterns, and role definitions from §1.6.
382
+
383
+ 7. **Scan CI/CD** — Read all CI/CD configuration files from §1.7. Extract pipeline stages, triggers, and deployment targets.
384
+
385
+ 8. **Scan infrastructure** — Identify containerization, orchestration, and IaC tools from §1.8.
386
+
387
+ 9. **Detect testing setup** — Find test configs, test files, and coverage settings from §1.9. Identify testing strategy (unit, integration, e2e).
388
+
389
+ 10. **Read existing documentation** — Extract knowledge from README, docs, ADRs, and changelogs from §1.10.
390
+
391
+ 11. **Analyze git history** — Run hotspot analysis, contributor mapping, and change velocity calculations from §1.11.
392
+
393
+ 12. **Check for monorepo** — Detect workspace tools and map package dependencies from §1.12.
394
+
395
+ 13. **Map entry points** — Trace application entry points, routing, and middleware chains from discovered framework and config evidence.
396
+
397
+ 14. **Build architecture hypothesis** — Synthesize findings into an architecture hypothesis: monolith vs microservices, layer boundaries, communication patterns.
398
+
399
+ 15. **Classify confidence** — Apply confidence scoring from Phase 2 to every finding.
400
+
401
+ 16. **Generate clarification questions** — Formulate 5-10 targeted questions from Phase 3 for areas with <50% confidence.
402
+
403
+ 17. **Write DISCOVERY-report.md** — Generate the full report following the Phase 4 template.
404
+
405
+ 18. **Present findings** — Share high-confidence facts, medium-confidence hypotheses (seeking confirmation), and low-confidence questions with the user.
406
+
407
+ ## Quality Gates
408
+
409
+ - [ ] All 12 discovery scans (§1.1–§1.12) were executed
410
+ - [ ] Every tech stack detection has a confidence score with evidence
411
+ - [ ] Architecture hypothesis is stated with supporting evidence
412
+ - [ ] No findings are stated without evidence citations
413
+ - [ ] Clarification questions number between 5 and 10
414
+ - [ ] No question asks about something discoverable from code
415
+ - [ ] DISCOVERY-report.md exists at `.engineering-intelligence/reports/DISCOVERY-report.md`
416
+ - [ ] Per-area confidence summary covers all major areas
417
+ - [ ] Git history analysis includes hotspots and change velocity
418
+ - [ ] Monorepo detection was performed (even if result is "not a monorepo")
419
+ - [ ] Unknowns and uncertainties are explicitly listed
420
+
421
+ ## Cross-References
422
+
423
+ - Used by: `initialize-intelligence-skill`, `engineering-orchestrator`
424
+ - Consumed by: all sync engines, `convention-detector`, `ongoing-learning-engine`
425
+ - Depends on: git history access, file system read access
426
+ - Feeds into: `knowledge-base/00-project-overview.md`, `.engineering-intelligence/memory/technology-decisions.md`
427
+
428
+ This capability does not modify product code.