9148c358d0
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
4.9 KiB
4.9 KiB
id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
| id | title | category | status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | verification_status | tags | raw_sources | last_reinforced | github_commit | tech_stack | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| wiki-2026-0508-automated-refactoring-tools | Automated Refactoring Tools | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Automated Refactoring Tools
매 한 줄
"매 AST-level 의 transform — 매 sed 의 X, 매 syntax-aware 의 mass-edit". 매 IDE refactor (Rename · Extract) 의 80년대 Smalltalk 의 root, 2026 의 LLM-augmented codemod (Claude Opus 4.7 + ast-grep) 의 mainstream.
매 핵심
매 3 tier 의 tool
- IDE-builtin: IntelliJ · VS Code · Rider — 매 single-file 의 dominant.
- Codemod: jscodeshift · ts-morph · comby · ast-grep — 매 cross-cutting mass change.
- LLM-driven: Claude Code · Cursor · GitHub Copilot Workspace — 매 semantic-aware 의 modernization.
매 refactor 종류
- Rename (symbol-aware).
- Extract function/variable/component.
- Inline.
- Move (file/module).
- Change signature.
- Convert (e.g.
var → const,function → arrow).
매 응용
- 매 framework migration (Vue 2 → Vue 3, React class → hook).
- API breaking change 의 fan-out fix.
- Code style 의 mechanical enforcement.
💻 패턴
ts-morph: rename + add property
import { Project } from "ts-morph";
const project = new Project({ tsConfigFilePath: "tsconfig.json" });
for (const sf of project.getSourceFiles()) {
for (const cls of sf.getClasses()) {
if (cls.getName()?.endsWith("Service")) {
cls.rename(cls.getName()!.replace(/Service$/, "Manager"));
cls.addProperty({ name: "createdAt", type: "Date", initializer: "new Date()" });
}
}
}
await project.save();
ast-grep: pattern → rewrite (yaml rule)
id: useEffect-cleanup
language: tsx
rule:
pattern: useEffect(() => { $$$BODY }, $DEPS)
fix: |
useEffect(() => {
$$$BODY
return () => { /* cleanup */ };
}, $DEPS)
ast-grep scan -r useEffect-cleanup.yml --update-all
jscodeshift: Vue Options → Composition API
export default function transformer(file, api) {
const j = api.jscodeshift;
const root = j(file.source);
root.find(j.ObjectExpression)
.filter(p => p.node.properties.some(pr => pr.key?.name === "data"))
.forEach(path => {
// emit setup() function with refs
// ...
});
return root.toSource();
}
jscodeshift -t vue-comp-api.js src/
comby (language-agnostic structural search)
comby 'console.log(:[args])' 'logger.debug(:[args])' .ts -i
LLM codemod (Claude Opus 4.7) — semantic-aware
import anthropic
client = anthropic.Anthropic()
SYSTEM = "You convert React class components to functional + hooks. Preserve behavior."
with open("UserCard.tsx") as f:
src = f.read()
resp = client.messages.create(
model="claude-opus-4-7",
max_tokens=4096,
system=SYSTEM,
messages=[{"role": "user", "content": src}],
)
print(resp.content[0].text)
IDE script: IntelliJ structural search
$method$($args$) { $body$ }
→ Constraints: method matches ".*Async$"
→ Replace with: async $method$($args$) { $body$ }
매 결정 기준
| 상황 | Tool |
|---|---|
| 매 single-file rename in IDE | IDE builtin |
| TS-only · type-aware | ts-morph |
| TS/JS · less type-aware · faster | jscodeshift |
| Multi-language · structural | comby · ast-grep |
| 매 semantic refactor · framework migration | LLM codemod |
| Mass mechanical regex-safe | sed/perl (드물게) |
기본값: TypeScript 의 ts-morph, polyglot 의 ast-grep, 매 semantic 의 LLM.
🔗 Graph
- 부모: Refactoring_Best_Practices · AST_Traversal
- 응용: Architecture_Refactor
- Adjacent: AI-Assisted Refactoring (AI 기반 리팩토링) · AST_Traversal
🤖 LLM 활용
언제: 매 semantic refactor (class→hook, callback→async/await), 매 deterministic rule 의 hard 의 case. 언제 X: 매 mechanical rename 의 case — IDE 가 cheaper · safer. LLM 의 hallucination risk 의 require code review.
❌ 안티패턴
- Regex-only refactor: 매 string match 의 false positive (comment · string literal).
- Test 없음 refactor: 매 mass codemod 의 test suite 의 gate 의 require.
- PR 의 single huge codemod: 매 review 의 X — file-by-file commit 의 split.
- LLM output 의 blind merge: 매 type-check + test 의 gate 의 mandatory.
🧪 검증 / 중복
- Verified (ts-morph docs, Meta jscodeshift, comby.dev, ast-grep.github.io, Anthropic Claude API docs).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — 3-tier taxonomy + ts-morph/ast-grep/comby/LLM examples |