intentpatch 0.1.0 → 0.2.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 (45) hide show
  1. package/README.ko.md +488 -0
  2. package/README.md +215 -211
  3. package/dist/application/ports/module-alias-resolver.d.ts +11 -0
  4. package/dist/application/ports/module-alias-resolver.d.ts.map +1 -0
  5. package/dist/application/ports/module-alias-resolver.js +2 -0
  6. package/dist/application/ports/module-alias-resolver.js.map +1 -0
  7. package/dist/application/ports/package-lock-parser.d.ts +20 -0
  8. package/dist/application/ports/package-lock-parser.d.ts.map +1 -0
  9. package/dist/application/ports/package-lock-parser.js +2 -0
  10. package/dist/application/ports/package-lock-parser.js.map +1 -0
  11. package/dist/application/rules/npm-lockfile-rule.d.ts +12 -0
  12. package/dist/application/rules/npm-lockfile-rule.d.ts.map +1 -0
  13. package/dist/application/rules/npm-lockfile-rule.js +109 -0
  14. package/dist/application/rules/npm-lockfile-rule.js.map +1 -0
  15. package/dist/application/rules/npm-workspace-dependency-rule.d.ts +10 -0
  16. package/dist/application/rules/npm-workspace-dependency-rule.d.ts.map +1 -0
  17. package/dist/application/rules/npm-workspace-dependency-rule.js +155 -0
  18. package/dist/application/rules/npm-workspace-dependency-rule.js.map +1 -0
  19. package/dist/application/rules/package-dependency-rule.d.ts +4 -3
  20. package/dist/application/rules/package-dependency-rule.d.ts.map +1 -1
  21. package/dist/application/rules/package-dependency-rule.js +33 -28
  22. package/dist/application/rules/package-dependency-rule.js.map +1 -1
  23. package/dist/application/services/analyze-import-impact.d.ts +3 -1
  24. package/dist/application/services/analyze-import-impact.d.ts.map +1 -1
  25. package/dist/application/services/analyze-import-impact.js +12 -7
  26. package/dist/application/services/analyze-import-impact.js.map +1 -1
  27. package/dist/infrastructure/git/git-file-snapshot-source.d.ts.map +1 -1
  28. package/dist/infrastructure/git/git-file-snapshot-source.js +4 -2
  29. package/dist/infrastructure/git/git-file-snapshot-source.js.map +1 -1
  30. package/dist/infrastructure/npm/npm-package-lock-parser.d.ts +6 -0
  31. package/dist/infrastructure/npm/npm-package-lock-parser.d.ts.map +1 -0
  32. package/dist/infrastructure/npm/npm-package-lock-parser.js +93 -0
  33. package/dist/infrastructure/npm/npm-package-lock-parser.js.map +1 -0
  34. package/dist/infrastructure/typescript/typescript-config-loader.d.ts +17 -0
  35. package/dist/infrastructure/typescript/typescript-config-loader.d.ts.map +1 -0
  36. package/dist/infrastructure/typescript/typescript-config-loader.js +99 -0
  37. package/dist/infrastructure/typescript/typescript-config-loader.js.map +1 -0
  38. package/dist/infrastructure/typescript/typescript-module-alias-resolver.d.ts +10 -0
  39. package/dist/infrastructure/typescript/typescript-module-alias-resolver.d.ts.map +1 -0
  40. package/dist/infrastructure/typescript/typescript-module-alias-resolver.js +78 -0
  41. package/dist/infrastructure/typescript/typescript-module-alias-resolver.js.map +1 -0
  42. package/dist/presentation/analyze-repository.d.ts.map +1 -1
  43. package/dist/presentation/analyze-repository.js +7 -3
  44. package/dist/presentation/analyze-repository.js.map +1 -1
  45. package/package.json +8 -3
package/README.md CHANGED
@@ -1,26 +1,32 @@
1
1
  # IntentPatch
2
2
 
3
+ **English** | [한국어](./README.ko.md)
4
+
3
5
  [![CI](https://github.com/xx2xxjaeil/intent-patch/actions/workflows/ci.yml/badge.svg)](https://github.com/xx2xxjaeil/intent-patch/actions/workflows/ci.yml)
4
6
 
5
- > AI 코딩 에이전트가 만든 변경을 근거 중심으로 분석하는 오픈소스 도구
7
+ > Evidence-based change-scope analysis for code written by AI coding agents
8
+
9
+ AI coding agents such as Codex, Claude Code, and Cursor can change many files from a short request. As the patch grows, it becomes harder to answer a few important questions:
6
10
 
7
- Codex, Claude Code, Cursor 같은 AI 코딩 에이전트는 짧은 요청만으로 여러 파일을 빠르게
8
- 수정합니다. 하지만 변경된 파일이 많아질수록 다음 질문에 답하기 어려워집니다.
11
+ - Did the agent change files outside the requested scope?
12
+ - Did it recreate logic that already existed?
13
+ - Did it add an unnecessary dependency or abstraction?
14
+ - How far can the change affect other modules?
15
+ - Were relevant tests changed with the production code?
9
16
 
10
- - 요청한 범위보다 많은 파일을 수정하지 않았는가?
11
- - 기존 코드를 재사용하지 않고 비슷한 로직을 새로 만들지 않았는가?
12
- - 불필요한 라이브러리나 추상화를 추가하지 않았는가?
13
- - 이번 변경이 다른 모듈에 어디까지 영향을 주는가?
14
- - 중요한 동작에 대한 테스트가 함께 추가되었는가?
17
+ IntentPatch combines **Git diff analysis, static analysis, and dependency analysis** to answer those questions. Its core analysis is deterministic and works without an LLM. Optional AI explanations can be added later without making the core tool dependent on a model provider.
15
18
 
16
- IntentPatch는 이러한 질문에 답하기 위해 **Git diff, 정적 분석, 의존 관계 분석**을 결합합니다.
17
- LLM 없이도 재현 가능한 분석을 제공하고, AI 설명 기능은 선택적으로 결합하는 것을 목표로
18
- 합니다.
19
+ ## Quick start
19
20
 
20
- ## 빠른 시작
21
+ IntentPatch requires Node.js 20 or later and Git. Run the published v0.2.0 CLI without
22
+ installing it globally:
23
+
24
+ ```bash
25
+ npx intentpatch analyze --cwd /path/to/repository
26
+ npx intentpatch analyze --format html --output intentpatch-report.html
27
+ ```
21
28
 
22
- Node.js 20 이상과 Git이 설치되어 있어야 합니다. 현재 npm 공개 전에는 저장소를 빌드해 바로
23
- 실행할 수 있습니다.
29
+ To run the current source version instead, build it from the repository:
24
30
 
25
31
  ```bash
26
32
  git clone https://github.com/xx2xxjaeil/intent-patch.git
@@ -31,20 +37,11 @@ node dist/presentation/cli/main.js --version
31
37
  node dist/presentation/cli/main.js analyze --cwd /path/to/repository
32
38
  ```
33
39
 
34
- npm 릴리스가 공개된 뒤에는 설치 없이 같은 CLI를 실행할 수 있습니다.
35
-
36
- ```bash
37
- npx intentpatch analyze --cwd /path/to/repository
38
- npx intentpatch analyze --format html --output intentpatch-report.html
39
- ```
40
-
41
- 핵심 분석에는 API key, 유료 AI 모델, 서버 또는 데이터베이스가 필요하지 않습니다. 분석할 Git
42
- 저장소의 파일은 로컬에서 처리하며 LLM 연결은 현재 기본 실행 경로에 포함되지 않습니다.
40
+ The core analyzer needs no API key, paid AI model, server, or database. Repository files are processed locally, and no LLM is used in the default execution path.
43
41
 
44
42
  ## GitHub Action
45
43
 
46
- Pull Request에서 요청 범위와 위험 변경을 자동 검사할 수 있습니다. 정확한 base·head commit을
47
- 사용하도록 checkout의 전체 히스토리를 가져와야 합니다.
44
+ Use IntentPatch in pull requests to check scope and risky changes automatically. The checkout must include the full Git history so the action can compare the exact base and head commits.
48
45
 
49
46
  ```yaml
50
47
  name: IntentPatch
@@ -65,7 +62,7 @@ jobs:
65
62
 
66
63
  - name: Analyze pull request
67
64
  id: intentpatch
68
- uses: xx2xxjaeil/intent-patch@main
65
+ uses: xx2xxjaeil/intent-patch@v0.2.0
69
66
  with:
70
67
  fail-on: high
71
68
 
@@ -77,20 +74,20 @@ jobs:
77
74
  path: intentpatch-report
78
75
  ```
79
76
 
80
- 현재 개발 버전은 `@main`으로 실행합니다. 첫 번째 정식 릴리스 후에는 불변 SHA 또는 `@v1`
81
- 태그로 고정하는 방식을 권장합니다. Action은 PR·push 이벤트의 commit 범위를 자동으로
82
- 선택하고 다음 결과를 남깁니다.
77
+ Pin the action to a released version or an immutable commit SHA. The v0.2.0 release includes
78
+ TypeScript path aliases and npm lockfile/workspace analysis; `@main` follows unreleased changes.
79
+
80
+ The action detects the comparison range for pull request and push events and produces:
83
81
 
84
- - GitHub Actions Job Summary의 Markdown 보고서
85
- - 심각도별 workflow annotation
86
- - artifact 업로드에 사용할 JSON·HTML 보고서
87
- - `high`, `medium`, `low` 기준의 품질 게이트
88
- - finding 수와 보고서 경로 Action output
82
+ - a Markdown report in the GitHub Actions Job Summary;
83
+ - workflow annotations grouped by severity;
84
+ - JSON and HTML reports that can be uploaded as artifacts;
85
+ - a quality gate at the `high`, `medium`, or `low` threshold;
86
+ - action outputs containing finding counts and report paths.
89
87
 
90
- 입력·출력과 이벤트별 비교 기준은 [GitHub Action 사용 문서](./docs/github-action.md)에서
91
- 확인할 수 있습니다.
88
+ See the [GitHub Action guide](./docs/github-action.md) for inputs, outputs, and event-specific comparison behavior.
92
89
 
93
- ## 프로젝트가 지향하는 결과
90
+ ## What the report looks like
94
91
 
95
92
  ```text
96
93
  IntentPatch Change Report
@@ -116,80 +113,88 @@ Impacted files
116
113
 
117
114
  Potential issues
118
115
 
119
- HIGH 공개 함수 시그니처 호환성 파괴
120
- MEDIUM 기존 인증 로직과 동일한 구현 발견
121
- MEDIUM 요청과 관련성이 낮아 보이는 파일 4개 변경
122
- LOW 구현체가 하나뿐인 추상화 추가
116
+ HIGH Breaking change to a public function signature
117
+ MEDIUM Implementation duplicates existing authentication logic
118
+ MEDIUM Four files changed outside the expected scope
119
+ LOW New abstraction has only one implementation
123
120
  ```
124
121
 
125
- 분석 결과는 단순한 경고 문구가 아니라 관련 파일, 규칙 ID, 판단 근거와 함께 제공하는 것을
126
- 원칙으로 합니다.
127
-
128
- ## 현재 구현된 기능
129
-
130
- 현재 버전은 Git 변경사항 수집, 루트 `package.json`의 직접 dependency 분석, TypeScript
131
- 최상위 심볼과 공개 API 변경 분석, 기존 구현 중복·단일 구현 추상화 신호, import graph 기반
132
- 영향 범위와 테스트 동반 변경 분석을 제공합니다.
133
-
134
- - `HEAD`와 현재 working tree 비교
135
- - 두 Git reference 또는 브랜치 비교
136
- - 추가, 수정, 삭제, 이름 변경 등 파일 상태 분류
137
- - 파일별 추가·삭제 라인 수 계산
138
- - binary 파일 구분
139
- - working tree 분석 시 untracked 파일 포함
140
- - 터미널용 텍스트 보고서
141
- - 후속 도구 연동을 위한 JSON 보고서
142
- - 요약 카드, finding, 테스트 신호와 영향 그래프를 담은 단일 HTML 보고서
143
- - 외부 CDN이나 JavaScript dependency가 필요 없는 인라인 CSS·SVG 시각화
144
- - production·development dependency 추가 탐지
145
- - dependency 삭제, 버전 변경, 섹션 이동 탐지
146
- - 잘못된 `package.json`을 예외 대신 근거가 포함된 finding으로 보고
147
- - finding 심각도(`high`, `medium`, `low`) 집계
148
- - CI 품질 게이트를 위한 `--fail-on` 종료 코드
149
- - 설치된 패키지 버전을 확인하는 `--version` 명령
150
- - `.ts`·`.tsx` 파일의 최상위 함수·클래스·인터페이스·타입 별칭 추출
151
- - 심볼 추가·수정·삭제 탐지와 소스 위치 표시
152
- - 직접 `export`된 선언, 로컬 export 목록과 외부 re-export를 공개 심볼 근거에 보존
153
- - 공개 심볼 삭제와 `export` 해제를 호환성 위험 `high` finding으로 탐지
154
- - 공개 함수의 기존 호출 시그니처 제거와 공개 인터페이스의 호환성 파괴를 `high` finding으로 탐지
155
- - 구현이 추가된 기존 overload는 제외하고 기존 overload가 사라진 경우만 함수 계약 변경으로 판정
156
- - 공백과 주석을 제외한 구현 토큰이 같은 신규 함수와 기존 함수를 재사용 후보 `medium` finding으로 탐지
157
- - 신규 인터페이스를 명시적으로 구현하는 클래스가 하나뿐이면 추상화 검토 `low` finding으로 탐지
158
- - rename 전후 파일 경로를 사용한 심볼 비교
159
- - 구문 오류가 있는 파일을 누락시키지 않고 분석 불가 근거로 보고
160
- - `.ts`·`.tsx` 파일의 상대 경로 정적 import와 re-export 관계 수집
161
- - `.js`·`.jsx`·`.mjs`·`.cjs` specifier를 대응하는 TypeScript 소스로 해석
162
- - 변경 모듈을 import하는 직접 의존자와 여러 단계를 거친 간접 영향 파일 계산
163
- - 해결하지 못한 상대 import와 읽기·파싱 실패를 분석 근거로 보존
164
- - working tree의 tracked·untracked 파일 또는 지정한 head ref를 동일한 결과점에서 분석
165
- - `.intentpatch.json`에 요청 의도, 예상 경로, 허용 경로와 변경량 예산 선언
166
- - 예상·허용 패턴을 벗어난 변경 파일을 파일별 `medium` finding으로 탐지
167
- - 변경 파일 수와 측정 라인 예산 초과를 수치 근거가 있는 `low` finding으로 탐지
168
- - Contract가 지정한 소스·테스트 경로를 분류하고 파일명 기준으로 관련 변경 연결
169
- - 테스트 변경 수와 추가·삭제 수를 별도의 분석 사실로 집계
170
- - 관련 테스트 변경이 없는 소스 파일을 `medium` finding으로 탐지
171
- - `*`, `**`, `?` 기반의 저장소 상대 경로 패턴 지원
172
- - Pull Request·push commit 범위를 자동 판별하는 GitHub Action
173
- - GitHub Job Summary, workflow annotation, JSON·HTML artifact용 보고서 생성
174
-
175
- 아직 lockfile의 전이 dependency 분석, path alias 해석, JavaScript·메서드 구조 분석과 AI 리뷰
176
- 기능은 구현되지 않았습니다.
177
-
178
- ## 상세 사용법
179
-
180
- 현재 저장소의 working tree를 분석합니다.
122
+ Every finding includes the relevant file, a stable rule ID, and evidence for the decision instead of only presenting an unexplained warning.
123
+
124
+ ## Implemented capabilities
125
+
126
+ The current source tree analyzes Git changes, direct dependencies in the root `package.json`, top-level TypeScript symbols and public API changes, possible duplicate implementations, single-implementation abstractions, import-graph impact, and related test changes.
127
+
128
+ ### Git and reporting
129
+
130
+ - Compare `HEAD` with the current working tree.
131
+ - Compare two Git references or branches from their merge base.
132
+ - Classify added, modified, deleted, and renamed files.
133
+ - Count added and deleted lines per file.
134
+ - Distinguish binary files.
135
+ - Include untracked files in working-tree analysis.
136
+ - Render terminal-friendly text and machine-readable JSON reports.
137
+ - Generate a standalone HTML report containing summary cards, findings, test signals, and an impact graph.
138
+ - Render the visualization with inline CSS and SVG, without a CDN or runtime JavaScript dependency.
139
+ - Aggregate findings by `high`, `medium`, and `low` severity.
140
+ - Return a CI-friendly exit code through `--fail-on`.
141
+ - Print the installed package version through `--version`.
142
+
143
+ ### Dependencies and TypeScript structure
144
+
145
+ - Detect additions to production and development dependencies.
146
+ - Detect dependency removal, version changes, and section moves.
147
+ - Report malformed `package.json` files as evidence-backed findings instead of crashing.
148
+ - Compare resolved package additions, removals, and version changes in npm `package-lock.json` v2/v3.
149
+ - Keep scoped and nested installation paths distinct, and exclude local workspace links.
150
+ - Report malformed or unsupported lockfiles as findings rather than silently skipping them.
151
+ - Attribute direct dependency changes to changed npm workspace manifests selected by the root `workspaces` patterns.
152
+ - Report changes to workspace patterns and manifest moves into or out of a configured workspace.
153
+ - Extract top-level named functions, classes, interfaces, and type aliases from `.ts` and `.tsx` files.
154
+ - Detect symbol additions, modifications, and removals with source locations.
155
+ - Preserve direct exports, local export lists, and external re-exports as public-symbol evidence.
156
+ - Report removed public symbols and removed exports as high-severity compatibility risks.
157
+ - Detect removed public function call signatures and incompatible public interface changes.
158
+ - Exclude overloads that only gain an implementation while reporting previously available overloads that disappear.
159
+ - Find newly added functions whose normalized implementation matches an existing function.
160
+ - Report a newly added interface when exactly one class explicitly implements it.
161
+ - Compare symbols correctly across renamed files.
162
+ - Preserve syntax errors as analysis evidence instead of silently dropping a file.
163
+
164
+ ### Impact, scope, and tests
165
+
166
+ - Build relative static import and re-export relationships for `.ts` and `.tsx` files.
167
+ - Resolve local imports through the nearest `tsconfig.json` or `jsconfig.json` `paths` and
168
+ `baseUrl`, including relative `extends` files.
169
+ - Resolve `.js`, `.jsx`, `.mjs`, and `.cjs` import specifiers to matching TypeScript sources.
170
+ - Calculate direct importers and transitively impacted files for changed modules.
171
+ - Preserve unresolved relative imports and file read or parse failures as evidence.
172
+ - Build the graph at the same result point as the diff: the working tree or the selected head ref.
173
+ - Read intent, expected paths, allowed paths, and change budgets from `.intentpatch.json`.
174
+ - Report each file outside expected and allowed patterns as a medium-severity finding.
175
+ - Report file-count and measurable-line budget overruns with numeric evidence.
176
+ - Classify source and test paths declared by the contract and connect related changes by basename.
177
+ - Report test file counts and added or deleted tests as separate facts.
178
+ - Report source files without a related test change as medium-severity findings.
179
+ - Support repository-relative `*`, `**`, and `?` path patterns.
180
+
181
+ Transitive lockfile dependency provenance, JavaScript and method-level structure analysis, and optional AI review are not implemented yet.
182
+
183
+ ## CLI usage
184
+
185
+ Analyze the current repository's working tree:
181
186
 
182
187
  ```bash
183
188
  node dist/presentation/cli/main.js analyze
184
189
  ```
185
190
 
186
- 다른 Git 저장소를 분석할 수도 있습니다.
191
+ Analyze another Git repository:
187
192
 
188
193
  ```bash
189
194
  node dist/presentation/cli/main.js analyze --cwd /path/to/repository
190
195
  ```
191
196
 
192
- 두 브랜치를 비교합니다. 내부적으로 merge base 기준의 변경사항을 분석합니다.
197
+ Compare two branches. IntentPatch analyzes their changes from the merge base:
193
198
 
194
199
  ```bash
195
200
  node dist/presentation/cli/main.js analyze \
@@ -198,13 +203,13 @@ node dist/presentation/cli/main.js analyze \
198
203
  --head feature/account-deletion
199
204
  ```
200
205
 
201
- JSON으로 출력합니다.
206
+ Write JSON output:
202
207
 
203
208
  ```bash
204
209
  node dist/presentation/cli/main.js analyze --json
205
210
  ```
206
211
 
207
- 브라우저에서 볼 수 있는 HTML 보고서를 파일로 생성합니다.
212
+ Create a standalone HTML report:
208
213
 
209
214
  ```bash
210
215
  node dist/presentation/cli/main.js analyze \
@@ -212,18 +217,15 @@ node dist/presentation/cli/main.js analyze \
212
217
  --output intentpatch-report.html
213
218
  ```
214
219
 
215
- HTML 파일에는 스타일과 dependency 영향 SVG 그래프가 모두 포함되므로 별도 서버나 API key 없이
216
- 바로 열 수 있습니다. `--output`은 텍스트와 JSON 형식에도 사용할 수 있으며 상대 경로는
217
- IntentPatch를 실행한 현재 디렉터리를 기준으로 해석합니다. 기존 `--json`은
218
- `--format json`의 단축 옵션입니다.
220
+ The HTML file contains all styles and the dependency-impact SVG, so it opens directly without a server or API key. `--output` also works with text and JSON formats. Relative output paths are resolved from the directory where IntentPatch is executed. `--json` is an alias for `--format json`.
219
221
 
220
- ### Change Contract로 요청 범위 검사
222
+ ### Check request scope with a Change Contract
221
223
 
222
- 분석할 저장소의 `.intentpatch.json`에 이번 요청의 기대 범위를 선언할 수 있습니다.
224
+ Create `.intentpatch.json` in the repository being analyzed and declare the expected scope of the request:
223
225
 
224
226
  ```json
225
227
  {
226
- "intent": "회원 탈퇴 기능 구현",
228
+ "intent": "Implement account deletion",
227
229
  "scope": {
228
230
  "include": ["src/user/**", "tests/user/**"],
229
231
  "allow": ["package.json", "package-lock.json"],
@@ -238,19 +240,17 @@ IntentPatch를 실행한 현재 디렉터리를 기준으로 해석합니다.
238
240
  }
239
241
  ```
240
242
 
241
- - `include`: 요청 수행 중 변경될 것으로 예상한 경로
242
- - `allow`: 설정이나 lockfile처럼 함께 변경되어도 허용하는 예외 경로
243
- - `maxFiles`: 변경 파일 수의 상한
244
- - `maxLines`: 측정 가능한 추가·삭제 라인 합의 상한
245
- - `tests.requireFor`: 테스트 동반 변경을 확인할 소스 경로
246
- - `tests.include`: 테스트 파일로 분류할 경로
247
- - `tests.exclude`: 생성 파일이나 선언 파일처럼 검사에서 제외할 소스 경로
243
+ - `include`: paths expected to change for the request;
244
+ - `allow`: exceptional paths such as configuration or lockfiles;
245
+ - `maxFiles`: maximum number of changed files;
246
+ - `maxLines`: maximum total of measurable added and deleted lines;
247
+ - `tests.requireFor`: source paths that require a related test change;
248
+ - `tests.include`: paths classified as tests;
249
+ - `tests.exclude`: generated or declaration files excluded from the source check.
248
250
 
249
- 테스트 연결은 결정적인 결과를 위해 파일명을 사용합니다. 예를 들어 `src/user.ts`는
250
- `tests/user.test.ts`, `user.spec.ts`, `user.integration.test.ts` 같은 변경과 연결됩니다.
251
+ Test matching uses basenames for deterministic results. For example, `src/user.ts` can match changed files such as `tests/user.test.ts`, `user.spec.ts`, or `user.integration.test.ts`.
251
252
 
252
- 기본 파일 대신 별도 계약을 사용하려면 `--config`를 지정합니다. 상대 경로는 `--cwd`를 기준으로
253
- 해석합니다.
253
+ Use `--config` to select another contract. Relative paths are resolved from `--cwd`:
254
254
 
255
255
  ```bash
256
256
  node dist/presentation/cli/main.js analyze \
@@ -258,19 +258,19 @@ node dist/presentation/cli/main.js analyze \
258
258
  --config contracts/delete-user.json
259
259
  ```
260
260
 
261
- 복사해서 시작할 수 있는 설정은 [`.intentpatch.example.json`](./.intentpatch.example.json)에
262
- 있습니다. Contract가 없으면 기존 분석은 그대로 실행되고 scope 규칙만 비활성화됩니다.
261
+ Start with [`.intentpatch.example.json`](./.intentpatch.example.json). Without a contract, all existing analysis still runs and only the scope rules are disabled.
262
+
263
+ ### Quality gates
263
264
 
264
- 지정한 심각도 이상의 finding이 있으면 보고서를 출력한 뒤 종료 코드 `1`을 반환합니다.
265
+ Return exit code `1` after rendering the report when a finding meets or exceeds the selected severity:
265
266
 
266
267
  ```bash
267
268
  node dist/presentation/cli/main.js analyze --fail-on medium
268
269
  ```
269
270
 
270
- `medium`은 `medium`과 `high` finding에 반응하며, `low`를 지정하면 모든 finding을 품질
271
- 게이트 대상으로 취급합니다. 잘못된 CLI 사용은 종료 코드 `2`를 반환합니다.
271
+ `medium` reacts to both medium- and high-severity findings. `low` treats every finding as a quality-gate failure. Invalid CLI usage returns exit code `2`.
272
272
 
273
- dependency 변경과 코드 영향 범위를 다음과 같이 근거와 함께 출력합니다.
273
+ An evidence-rich result looks like this:
274
274
 
275
275
  ```text
276
276
  IntentPatch Change Report
@@ -328,16 +328,15 @@ LOW New interface has one implementation
328
328
  The new interface DeletionStrategy is implemented only by DefaultDeletionStrategy.
329
329
  ```
330
330
 
331
- 개발 중에는 빌드 없이 실행할 수 있습니다.
331
+ Run the TypeScript entry point directly during development:
332
332
 
333
333
  ```bash
334
334
  npm run dev -- analyze --cwd /path/to/repository
335
335
  ```
336
336
 
337
- ## 아키텍처
337
+ ## Architecture
338
338
 
339
- 기능이 늘어나도 Git, UI, 분석 규칙이 서로 강하게 결합되지 않도록 클린 아키텍처의 의존성
340
- 방향을 적용했습니다.
339
+ IntentPatch applies Clean Architecture dependency direction so Git, presentation, and analysis rules do not become tightly coupled as the project grows.
341
340
 
342
341
  ```text
343
342
  presentation ───────▶ application ───────▶ domain
@@ -345,109 +344,114 @@ presentation ───────▶ application ───────▶ domai
345
344
  └──▶ infrastructure ──┘
346
345
  ```
347
346
 
348
- | 계층 | 책임 |
347
+ | Layer | Responsibility |
349
348
  | --- | --- |
350
- | `domain` | 변경 파일, Change Contract, finding, 심볼 변경, dependency 영향 등 핵심 모델 |
351
- | `application` | 분석 유스케이스, 규칙 엔진, 심볼·영향 계산과 외부 데이터 포트 |
352
- | `infrastructure` | Git 명령·diff 파싱·프로젝트 파일 공급·TypeScript AST 파싱 |
353
- | `presentation` | CLI 인자 처리, 의존성 조립, 텍스트·JSON·HTML 출력 |
349
+ | `domain` | Core models for changed files, Change Contracts, findings, symbol changes, and dependency impact |
350
+ | `application` | Analysis use cases, rule engine, symbol and impact calculations, and ports for external data |
351
+ | `infrastructure` | Git commands, diff parsing, project-file access, and TypeScript AST parsing |
352
+ | `presentation` | CLI argument handling, dependency composition, and text, JSON, and HTML output |
354
353
 
355
- 하위 계층이 외부 구현을 참조하지 않도록 아키텍처 테스트가 import 방향을 검사합니다.
356
- 구현상의 주요 판단과 확장 지점은 [상세 아키텍처 문서](./docs/architecture.md)에서 설명합니다.
354
+ Architecture tests enforce the import direction so inner layers never depend on external implementations. See the [architecture document](./docs/architecture.md) for design decisions and extension points.
357
355
 
358
- ## 설계 원칙
356
+ ## Design principles
359
357
 
360
- - **Deterministic first:** 핵심 분석은 동일한 입력에 동일한 결과를 반환합니다.
361
- - **Evidence over claims:** 확실하지 않은 판단을 사실처럼 단정하지 않습니다.
362
- - **LLM optional:** AI 연결 없이도 기본 분석 기능을 사용할 수 있어야 합니다.
363
- - **Dependency minimalism:** 편의를 위한 라이브러리를 무분별하게 추가하지 않습니다.
364
- - **Explicit boundaries:** 도메인 로직과 Git·CLI 같은 외부 기술을 분리합니다.
358
+ - **Deterministic first:** the same input produces the same core analysis result.
359
+ - **Evidence over claims:** uncertain signals are not presented as facts.
360
+ - **LLM optional:** useful analysis remains available without an AI provider.
361
+ - **Dependency minimalism:** convenience alone does not justify another library.
362
+ - **Explicit boundaries:** domain logic stays separate from external details such as Git and CLI frameworks.
365
363
 
366
- ## 테스트와 품질 검사
364
+ ## Testing and quality checks
367
365
 
368
366
  ```bash
369
367
  npm run check
370
368
  ```
371
369
 
372
- 위 명령은 다음 검사를 순서대로 실행합니다.
370
+ This command runs:
373
371
 
374
- - 엄격한 TypeScript 타입 검사
375
- - Biome 린트 및 포맷 검사
376
- - 도메인과 유스케이스 단위 테스트
377
- - 실제 임시 Git 저장소를 사용하는 통합 테스트
378
- - 생성한 npm tarball을 임시 프로젝트에 설치하고 실행하는 패키지 통합 테스트
379
- - 계층 간 의존 방향을 검증하는 아키텍처 테스트
372
+ - strict TypeScript type checking;
373
+ - Biome lint and format checks;
374
+ - domain and use-case unit tests;
375
+ - integration tests against real temporary Git repositories;
376
+ - a package integration test that installs the generated npm tarball in a temporary project and executes it;
377
+ - architecture tests that enforce dependency direction;
378
+ - a reproducibility check for the bundled GitHub Action.
380
379
 
381
- 프로덕션 빌드만 확인하려면 다음 명령을 사용합니다.
380
+ Run only the production build with:
382
381
 
383
382
  ```bash
384
383
  npm run build
385
384
  ```
386
385
 
387
- npm에 포함될 파일과 패키지 생성을 확인하려면 실제 공개 없이 dry-run을 실행합니다.
386
+ Inspect the files that would be published without creating a public release:
388
387
 
389
388
  ```bash
390
389
  npm pack --dry-run
391
390
  ```
392
391
 
393
- ## 로드맵
394
-
395
- 1. ✅ `package.json` 직접 dependency 변경 탐지와 규칙 엔진
396
- 2. ✅ TypeScript AST 기반 함수·클래스·인터페이스·타입 변경 분석
397
- 3. ✅ 상대 경로 정적 import graph 기반 변경 영향 범위 계산
398
- 4. ✅ Change Contract 기반 예상 범위 이탈과 변경량 예산 탐지
399
- 5. ✅ Contract 기반 관련 테스트 변경 누락 탐지
400
- 6. lockfile과 workspace를 고려한 package manager adapter
401
- 7. ✅ 직접 export된 공개 심볼 삭제와 export 해제 탐지
402
- 8. ✅ 단일 HTML 대시보드와 SVG 기반 dependency 영향 그래프
403
- 9. ✅ re-export·함수/인터페이스 호환성과 기존 코드 중복 가능성 탐지
404
- 10. ✅ 구현체가 하나뿐인 신규 인터페이스 탐지
405
- 11. ✅ PR·push 비교, Job Summary와 artifact 출력을 제공하는 GitHub Action
406
- 12. Codex·Claude Code·Cursor adapter
407
- 13. 근거 기반 결과에 대한 선택적 LLM 설명
408
-
409
- ## 현재 제한사항
410
-
411
- - 분석 대상은 최소 한 번 이상 커밋된 Git 저장소여야 합니다.
412
- - untracked symbolic link는 안전을 위해 내용을 읽지 않습니다.
413
- - 10 MiB를 초과하는 untracked 파일은 라인 수를 측정하지 않습니다.
414
- - dependency 분석은 저장소 루트의 npm `package.json`에 선언된 `dependencies`와
415
- `devDependencies`를 대상으로 합니다.
416
- - lockfile의 전이 dependency, workspace package, 코드에서의 실제 사용 여부는 아직 분석하지 않습니다.
417
- - 심볼 분석은 `.ts`와 `.tsx`의 이름이 있는 최상위 함수, 클래스, 인터페이스, 타입
418
- 별칭만 지원합니다.
419
- - 공개 API 분석은 이름이 있는 최상위 함수·인터페이스, 로컬 `export { name }`, 외부
420
- `export { name } from`, `export * from`을 지원합니다. package `exports`, 익명 default export,
421
- 클래스·타입 별칭의 세부 계약은 아직 해석하지 않습니다.
422
- - 함수 호환성은 명시된 파라미터·반환 타입 텍스트를 비교합니다. 추론된 반환 타입 변화나
423
- TypeScript의 구조적 타입 할당 가능성까지 판정하지 않습니다.
424
- - 중복 구현 후보는 새로 추가된 최상위 함수와 기존 최상위 함수의 토큰이 공백·주석을 제외하고
425
- 완전히 같으며 본문이 12토큰 이상일 때만 보고합니다. 식별자 이름이 바뀐 유사 코드, 메서드,
426
- 의미적으로만 같은 구현은 탐지하지 않습니다.
427
- - 단일 구현 추상화는 새 인터페이스를 `implements`로 명시한 이름 있는 클래스가 정확히 하나일 때만
428
- 보고합니다. TypeScript의 구조적 구현, factory 반환 타입과 런타임 등록은 계산하지 않습니다.
429
- - 메서드, 변수 선언, enum, 중첩 선언, JavaScript 파일은 아직 심볼 분석 대상이 아닙니다.
430
- - 선언 내부의 포맷이나 주석 변경도 심볼 수정으로 집계될 수 있습니다.
431
- - 영향 분석은 `.ts`·`.tsx` 파일의 상대 경로 정적 `import`, side-effect import,
432
- `export ... from`, `import = require()`를 대상으로 합니다.
433
- - 외부 package import는 그래프에서 제외하며 path alias, dynamic `import()`, 일반 `require()`는
434
- 아직 해석하지 않습니다.
435
- - 영향 그래프는 비교 결과점(working tree 또는 head ref)의 파일을 기준으로 만듭니다. 따라서
436
- 삭제된 모듈을 가리키던 과거 import의 영향은 현재 단계에서 계산할 수 없습니다.
437
- - 영향 분석용 소스 파일은 파일당 1 MiB로 제한하며, symbolic link는 읽지 않습니다.
438
- - IntentPatch는 자연어 intent만으로 예상 경로를 추측하지 않습니다. 범위 판단은 Contract에 명시한
439
- `include`와 `allow`를 기준으로 수행합니다.
440
- - 경로 패턴은 저장소 상대 경로와 `*`, `**`, `?`만 지원합니다. 부정 패턴과 brace 확장은 아직
441
- 지원하지 않습니다.
442
- - `maxLines`는 측정 가능한 텍스트 파일의 추가·삭제 라인만 합산합니다. Binary와 측정 불가 파일을
443
- 0줄이라고 간주하지 않지만, 해당 파일의 크기를 라인 예산에 포함하지도 않습니다.
444
- - 테스트 분석은 실행 결과나 코드 커버리지를 측정하지 않고 Contract에 지정된 변경 파일만
445
- 비교합니다.
446
- - 관련 테스트는 현재 소스와 테스트의 파일명이 같은지로 판단하므로 이름이 다른 통합 테스트나
447
- 하나의 테스트가 여러 소스를 검증하는 관계는 자동으로 연결하지 못합니다.
448
- - HTML 영향 그래프는 변경 모듈과 영향 파일을 결정적인 두 열 레이아웃으로 표시합니다. 노드 이동,
449
- 확대·축소와 필터링을 제공하는 대화형 웹 UI는 아직 구현하지 않았습니다.
450
-
451
- ## 라이선스
392
+ ## Release process
393
+
394
+ Pushing a tag such as `v0.1.0`, matching the version in `package.json`, from a commit contained in the default branch triggers the release workflow:
395
+
396
+ 1. Validate the tag, package version, and default-branch ancestry.
397
+ 2. Run the full quality suite and inspect the npm package with a dry run.
398
+ 3. Publish through npm Trusted Publishing with OpenID Connect.
399
+ 4. Create a GitHub Release with automatically generated notes.
400
+
401
+ No long-lived npm token is stored as a GitHub secret. Public packages published through OIDC receive npm provenance automatically. A package that does not yet exist on npm needs a one-time bootstrap before a Trusted Publisher can be configured. See the [release operations guide](./docs/releasing.md) for bootstrap and subsequent release procedures.
402
+
403
+ ## Roadmap
404
+
405
+ 1. ✅ Direct `package.json` dependency detection and rule engine
406
+ 2. ✅ TypeScript AST analysis for functions, classes, interfaces, and types
407
+ 3. ✅ Relative static import graph and change-impact calculation
408
+ - ✅ TypeScript `paths` and `baseUrl` aliases from the nearest project config
409
+ 4. ✅ Change Contract scope and change-budget analysis
410
+ 5. ✅ Contract-based detection of missing related test changes
411
+ 6. Package-manager adapters for lockfiles and workspaces
412
+ - ✅ npm `package-lock.json` v2/v3 resolved package changes
413
+ - ✅ npm workspace manifest dependency changes
414
+ - pnpm and Yarn adapters
415
+ 7. ✅ Detection of removed public exports
416
+ 8. ✅ Standalone HTML dashboard and SVG dependency-impact graph
417
+ 9. ✅ Re-export and function/interface compatibility checks plus possible code duplication
418
+ 10. ✅ Detection of newly introduced single-implementation interfaces
419
+ 11. ✅ GitHub Action with PR/push comparison, Job Summary, annotations, and artifacts
420
+ 12. Codex, Claude Code, and Cursor adapters
421
+ 13. Optional LLM explanations grounded in deterministic evidence
422
+
423
+ ## Current limitations
424
+
425
+ - The target must be a Git repository with at least one commit.
426
+ - Untracked symbolic links are not read for safety.
427
+ - Line counts are skipped for untracked files larger than 10 MiB.
428
+ - Direct dependency declarations are analyzed from `dependencies` and `devDependencies` in the root npm `package.json` and changed npm workspace manifests.
429
+ - npm `package-lock.json` v2/v3 analysis compares installed package paths and versions, not dependency provenance, integrity hashes, or vulnerability data. It does not attribute transitive packages to their parents.
430
+ - Workspace detection supports the root npm `workspaces` array with explicit paths and `*`, `**`, and `?` globs. Negation, brace, and character-class patterns are reported as unsupported.
431
+ - pnpm and Yarn lockfiles and real dependency usage in source code are not analyzed yet.
432
+ - Working-tree `package-lock.json` files are limited to 10 MiB; other text snapshots retain the 1 MiB limit.
433
+ - Symbol analysis supports named top-level functions, classes, interfaces, and type aliases in `.ts` and `.tsx` files.
434
+ - Public API analysis supports named top-level functions and interfaces, local `export { name }`, external `export { name } from`, and `export * from`. Package `exports`, anonymous default exports, and detailed class or type-alias contracts are not interpreted yet.
435
+ - Function compatibility compares explicitly written parameter and return-type text. It does not evaluate inferred return types or full TypeScript structural assignability.
436
+ - Duplicate candidates require a newly added top-level function and an existing top-level function to have exactly the same normalized tokens after comments and whitespace are removed, with at least 12 body tokens. Renamed identifiers, methods, and semantically equivalent implementations are not detected.
437
+ - A single-implementation abstraction is reported only when exactly one named class explicitly uses `implements` for a new interface. Structural implementation, factory return types, and runtime registration are not calculated.
438
+ - Methods, variable declarations, enums, nested declarations, and JavaScript files are not included in symbol analysis.
439
+ - Formatting or comment changes inside a declaration can be counted as symbol modifications.
440
+ - Impact analysis covers static `import`, side-effect imports, `export ... from`, and
441
+ `import = require()` in `.ts` and `.tsx` files. Local aliases use the nearest `tsconfig.json` or
442
+ `jsconfig.json`, with relative `extends` support.
443
+ - Package-based config `extends`, project references, arbitrary config filenames, package
444
+ `imports`/`exports`, external package imports, dynamic `import()`, and ordinary `require()` are
445
+ not included in the graph.
446
+ - The graph is built from files at the comparison result point: the working tree or head ref. Impact from historical imports that referenced a deleted module cannot be calculated yet.
447
+ - Source files used for impact analysis are limited to 1 MiB per file, and symbolic links are not read.
448
+ - IntentPatch does not infer expected paths from natural-language intent. Scope decisions use the contract's explicit `include` and `allow` patterns.
449
+ - Path patterns support only repository-relative `*`, `**`, and `?`; negation and brace expansion are not supported.
450
+ - `maxLines` sums only measurable added and deleted lines in text files. Binary or unmeasurable files are not treated as zero lines, but their size is not included in the budget.
451
+ - Test analysis compares only the changed paths declared in the contract; it does not execute tests or measure coverage.
452
+ - Related tests are matched by basename. Integration tests with different names or one test covering several source files cannot be linked automatically yet.
453
+ - The HTML impact graph uses a deterministic two-column layout. Interactive node movement, zooming, and filtering are not implemented yet.
454
+
455
+ ## License
452
456
 
453
457
  [MIT](./LICENSE)
@@ -0,0 +1,11 @@
1
+ import type { ImpactAnalysisIssue } from "../../domain/impact.js";
2
+ import type { AnalysisTarget } from "../../domain/report.js";
3
+ /** 분석 결과점에서 해석 가능한 비상대 경로 import를 찾는 언어별 출력 포트다. */
4
+ export interface ModuleAliasResolver {
5
+ prepare(target: AnalysisTarget, repositoryPaths: readonly string[], sourcePaths: ReadonlySet<string>): Promise<PreparedModuleAliasResolver>;
6
+ }
7
+ export interface PreparedModuleAliasResolver {
8
+ readonly issues: readonly ImpactAnalysisIssue[];
9
+ resolve(importer: string, specifier: string): string | undefined;
10
+ }
11
+ //# sourceMappingURL=module-alias-resolver.d.ts.map