c24165b8bc
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4.7 KiB
4.7 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-concrete-syntax-tree-cst | Concrete Syntax Tree (CST) | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Concrete Syntax Tree (CST)
매 한 줄
"매 source 의 every token (whitespace, comment 포함) 까지 보존하는 lossless tree". AST 가 semantic-only 인 반면 CST 는 매 source 의 round-trip 가능. 매 modern tooling — tree-sitter, rowan (rust-analyzer), Roslyn — 매 CST 위에서 매 IDE feature, refactoring, formatter 를 매 build.
매 핵심
매 vs AST
- AST: semantic node 만 (
if,BinaryOp, etc) — comment, whitespace 버림. - CST: 모든 token + trivia 보존 —
source == reprint(cst). - CST → AST 의 lowering 가능, 역은 매 lossy.
매 핵심 properties
- Lossless: print 시 원본 byte-for-byte 복구.
- Error-tolerant: incomplete/invalid code 도 partial tree.
- Incremental: edit 시 affected subtree 만 reparse (tree-sitter).
- Untyped or weakly-typed: 모든 node 가 동질 — typed wrapper 로 navigate.
매 응용
- IDE: syntax highlight, fold, outline, indent.
- Refactoring: rename, extract method (preserve formatting).
- Formatter: prettier, rustfmt — CST 로 layout 결정.
- Linter: tree-sitter queries.
💻 패턴
tree-sitter parsing
const Parser = require('tree-sitter');
const TS = require('tree-sitter-typescript').typescript;
const parser = new Parser();
parser.setLanguage(TS);
const tree = parser.parse('const x: number = 1;');
// Walk
const cursor = tree.walk();
do { console.log(cursor.nodeType, cursor.startIndex, cursor.endIndex); }
while (cursor.gotoNextSibling() || cursor.gotoFirstChild());
tree-sitter query (S-expression)
; Find all function declarations
(function_declaration
name: (identifier) @func.name
parameters: (formal_parameters) @func.params)
; Find unused imports
(import_statement
source: (string) @import.source) @import
Incremental edit
const oldTree = parser.parse(oldSrc);
const newSrc = oldSrc.slice(0, 10) + 'INSERTED' + oldSrc.slice(10);
oldTree.edit({
startIndex: 10, oldEndIndex: 10, newEndIndex: 18,
startPosition: {row: 0, column: 10},
oldEndPosition: {row: 0, column: 10},
newEndPosition: {row: 0, column: 18},
});
const newTree = parser.parse(newSrc, oldTree); // reuses unchanged subtrees
rowan (rust-analyzer) typed wrapper
// Untyped GreenNode + typed SyntaxNode wrapper
use rowan::{GreenNode, SyntaxNode};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u16)]
enum SyntaxKind { L_PAREN, R_PAREN, IDENT, FN_KW, FN_DEF, ROOT, /* ... */ }
struct FnDef(SyntaxNode<MyLang>);
impl FnDef {
fn name(&self) -> Option<String> {
self.0.children().find(|n| n.kind() == SyntaxKind::IDENT)
.map(|n| n.text().to_string())
}
}
Lossless rewrite (rename)
// Replace token in CST and reprint — preserves comments/whitespace.
fn rename(node: &SyntaxNode, old: &str, new: &str) -> String {
let mut out = String::new();
for tok in node.descendants_with_tokens() {
if let Some(t) = tok.as_token() {
if t.kind() == SyntaxKind::IDENT && t.text() == old { out.push_str(new); }
else { out.push_str(t.text()); }
}
}
out
}
매 결정 기준
| 상황 | Approach |
|---|---|
| Compiler / type checker | AST (semantic 충분) |
| IDE / LSP / formatter | CST (lossless 필수) |
| Refactoring tool | CST + typed wrapper |
| Quick analysis script | tree-sitter query |
| New language design | rowan or tree-sitter base |
기본값: User-facing tool 이면 매 CST. Compiler internal pass 면 매 AST.
🔗 Graph
🤖 LLM 활용
언제: Source-to-source transformation, IDE-grade tooling, codemods. 언제 X: Pure semantic analysis (AST 만 충분).
❌ 안티패턴
- Regex on source: 매 fragile — CST query 사용.
- AST 로 formatter: comment 손실 — CST 필수.
- Hand-rolled parser: error recovery 빠짐 — tree-sitter/lark 사용.
- Full reparse on every keystroke: incremental edit API 사용.
🧪 검증 / 중복
- Verified (tree-sitter docs, rust-analyzer rowan, Roslyn architecture).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — CST vs AST + tree-sitter/rowan patterns |