leerness 1.9.389 → 1.9.391
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.
- package/CHANGELOG.md +37 -0
- package/README.md +5 -5
- package/bin/harness.js +14 -202
- package/lib/feature.js +118 -0
- package/lib/pure-utils.js +105 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.391 — 2026-06-06 — UR-0025 큰 핸들러 모듈화 3번째: feature → lib/feature.js (DI)
|
|
4
|
+
|
|
5
|
+
**🧩 세 번째 핸들러 모듈 — feature add/link/impact/list/show 를 lib/feature.js 로 분리. 1.9.390 순수 코어 토대 위에 완성.**
|
|
6
|
+
|
|
7
|
+
### 배경 (UR-0025, 사용자 승인 모듈화)
|
|
8
|
+
migrate(1.9.388)/team(1.9.389) 에 이어 세 번째. 1.9.390 에서 feature-graph 순수 코어를 pure-utils 로 뺀 덕에 이제 핸들러를 깨끗이 분리 가능.
|
|
9
|
+
|
|
10
|
+
### 구현
|
|
11
|
+
1. **lib/feature.js 신규**: 5 핸들러(add/link/impact/list/show) 이전.
|
|
12
|
+
- 직접 require: `./io`(absRoot/log/ok/warn/fail) · `./pure-utils`(_nextFeatureId/_featureImpactBfs).
|
|
13
|
+
- **DI 주입**: _ensureFeatureGraph · _readFeatureGraph · _writeFeatureGraph(feature-graph I/O 헬퍼) · arg · has.
|
|
14
|
+
2. **_featureImpactBfs → pure-utils**: 영향 BFS(affects/co-changes transitive + depends-on 역방향)는 순수 + handoff(8613)/audit(19302)도 공유 → pure-utils 로 이동, harness+lib 양쪽 import.
|
|
15
|
+
3. **I/O 헬퍼는 harness 유지**: _readFeatureGraph(7+곳 공유) 등은 그대로, deps 로 주입.
|
|
16
|
+
4. **harness thin wrapper**: _featureDeps() 구성 후 5 wrapper 위임. dispatch·MCP·동작·출력 무변경.
|
|
17
|
+
|
|
18
|
+
### 검증 (회귀 0)
|
|
19
|
+
- **selftest 136→137 PASS** (lib/feature 5 exports + _featureImpactBfs reference-equality + BFS 동작 + 위임 와이어 + lib 본문 이동 교차참조 + behavioral list --json).
|
|
20
|
+
- **E2E 332 유지 PASS** (feature add/link/impact/list/show + 공유 _featureImpactBfs(handoff/audit) 회귀). 락 flake 시 재실행.
|
|
21
|
+
- 실측: add(depends-on)·link(affects)·impact(transitive)·list·show(--json)·에러(BADID exit1)·handoff(공유 BFS) 보존.
|
|
22
|
+
|
|
23
|
+
## 1.9.390 — 2026-06-06 — UR-0025 모듈화: feature-graph 순수 코어 → pure-utils (feature 핸들러 분리 토대)
|
|
24
|
+
|
|
25
|
+
**🧩 feature-graph 의 순수 로직(템플릿/파서/ID/블록 렌더)을 lib/pure-utils.js 로 분리 — 가장 많이 공유되는 서브시스템의 핵심을 단일출처·테스트 가능화.**
|
|
26
|
+
|
|
27
|
+
### 배경 (UR-0025, 사용자 승인 모듈화)
|
|
28
|
+
migrate(1.9.388)/team(1.9.389) 핸들러를 lib 모듈로 뺐다. feature 서브시스템도 후보지만, `_readFeatureGraph` 가 audit/health/handoff 등 **7+곳에서 공유**돼 핸들러를 통째로 옮기기 전에 순수 코어부터 분리하는 게 안전(lib/io.js 토대를 먼저 만든 것과 동일 순서).
|
|
29
|
+
|
|
30
|
+
### 구현
|
|
31
|
+
1. **pure-utils 로 순수 4종 이전**: `_featureGraphTemplate`(템플릿) · `_parseFeatureGraph`(MD→nodes) · `_nextFeatureId`(다음 F-id) · `_featureBlock`(node→MD). 모두 I/O 없음.
|
|
32
|
+
2. **I/O 헬퍼는 harness 유지**: `_readFeatureGraph`(7+곳 공유) · `_writeFeatureGraph` · `_ensureFeatureGraph` · `featureGraphPath` — 이제 pure-utils 의 순수 함수를 import 해 사용.
|
|
33
|
+
3. harness 인라인 정의 제거 + import. 호출부·동작·출력 무변경.
|
|
34
|
+
|
|
35
|
+
### 검증 (회귀 0)
|
|
36
|
+
- **selftest 135→136 PASS** (reference-equality 4종 + 템플릿/파서/nextId 동작 + `_featureBlock`→`_parseFeatureGraph` round-trip + 인라인 제거 확인).
|
|
37
|
+
- **E2E 332 유지 PASS** (feature add/link/impact/list/show + 공유 _readFeatureGraph(audit/health/handoff) 회귀). 락 flake 시 재실행.
|
|
38
|
+
- 실측: add(F-0001/F-0002)·link(affects)·impact(transitive)·list(--json)·health(featureGraph) 보존.
|
|
39
|
+
|
|
3
40
|
## 1.9.389 — 2026-06-06 — UR-0025 큰 핸들러 모듈화 2번째: teamCmd → lib/team.js (DI)
|
|
4
41
|
|
|
5
42
|
**🧩 두 번째 핸들러 모듈 추출 — team 서브시스템(list/add/show/remove/preview/deploy)을 lib/team.js 로 분리. migrate(1.9.388)에서 확립한 DI 패턴 재사용.**
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **AI 코딩 에이전트의 거짓 완료·중복·망각·충돌을 막아주는 검수·기억·협업 CLI 하네스.**
|
|
4
4
|
> **A CLI harness that stops AI coding agents from faking completion, duplicating work, forgetting context, and colliding.**
|
|
5
5
|
|
|
6
|
-
[](https://www.npmjs.com/package/leerness) [](https://www.npmjs.com/package/leerness) []() []() []() []() []() []()
|
|
7
7
|
|
|
8
8
|
```
|
|
9
9
|
╔══════════════════════════════════════════════════════════════╗
|
|
@@ -471,7 +471,7 @@ MIT — © leerness contributors
|
|
|
471
471
|
<!-- leerness:project-readme:start -->
|
|
472
472
|
## Leerness Project Harness
|
|
473
473
|
|
|
474
|
-
이 프로젝트는 Leerness v1.9.
|
|
474
|
+
이 프로젝트는 Leerness v1.9.391 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
|
|
475
475
|
|
|
476
476
|
### 정체성 — AI 에이전트 운영 레이어 (UR-0030)
|
|
477
477
|
|
|
@@ -525,7 +525,7 @@ leerness memory restore decision <date|title>
|
|
|
525
525
|
|
|
526
526
|
### MCP server (외부 AI 통합)
|
|
527
527
|
|
|
528
|
-
Leerness v1.9.
|
|
528
|
+
Leerness v1.9.391는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **85개 도구**를 노출:
|
|
529
529
|
|
|
530
530
|
```jsonc
|
|
531
531
|
// 카테고리별
|
|
@@ -546,7 +546,7 @@ Leerness v1.9.389는 stdio JSON-RPC MCP server를 내장합니다 — Claude Cod
|
|
|
546
546
|
`<<autonomous-loop-dynamic>>` 신호만 보내면 AI가:
|
|
547
547
|
1) 다음 라운드 후보 선정 → 2) 코드 변경 → 3) stress-v* 신규 작성 + 누적 회귀 → 4) e2e 219/219 → 5) npm pack + git tag + GitHub release → 6) main 자동 push (1.9.140+) → 7) session close → 8) 다음 라운드 예약.
|
|
548
548
|
|
|
549
|
-
현재 누적: **70 라운드 (1.9.40 → 1.9.
|
|
549
|
+
현재 누적: **70 라운드 (1.9.40 → 1.9.391)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
|
|
550
550
|
|
|
551
551
|
### 성능 가이드 (1.9.140 측정)
|
|
552
552
|
|
|
@@ -584,6 +584,6 @@ leerness release pack --close --auto-main-push
|
|
|
584
584
|
- `.harness/session-handoff.md`: 다음 세션 인수인계 (자동 작성)
|
|
585
585
|
- `.harness/lessons.md` / `decisions.md` / `rules.md`: 영구 메모리 (5 surface)
|
|
586
586
|
|
|
587
|
-
Last synced by Leerness v1.9.
|
|
587
|
+
Last synced by Leerness v1.9.391: 2026-06-06
|
|
588
588
|
<!-- leerness:project-readme:end -->
|
|
589
589
|
|
package/bin/harness.js
CHANGED
|
@@ -23,13 +23,14 @@ const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _merg
|
|
|
23
23
|
_personaSummaries, _translate,
|
|
24
24
|
_decisionsFromMd, _renderDecisionsMd, _renderLessonsMd,
|
|
25
25
|
_withBuiltinSource, _esc, _roadmapTokenStyles, _parseSkillMd,
|
|
26
|
-
_migrationGuideText, _parseContractSpec, _gitignoreMatch
|
|
26
|
+
_migrationGuideText, _parseContractSpec, _gitignoreMatch,
|
|
27
|
+
_featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock, _featureImpactBfs } = require('../lib/pure-utils'); // 1.9.318~391 (UR-0025/0053/0075/0086/0087): 순수 유틸 모듈 분리
|
|
27
28
|
// 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
|
|
28
29
|
const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
|
|
29
30
|
// 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
|
|
30
31
|
const { CAPABILITY_SURFACE, POWERFUL_COMMANDS, ADAPTERS, REUSE_CATEGORIES, REUSE_CHECKLIST, _DEFAULT_PLATFORM_CONSTRAINTS, _DEFAULT_DOMAIN_CATALOG, _LSP_LANG_PATTERNS, OPTIMISM_PATTERNS, BUILT_IN_PERSONAS, STRINGS, BUILTIN_CATALOG, ROADMAP_STATUS_LABEL, ROADMAP_STATUS_COLOR, SECRET_PATTERNS, MERGE_OVERWRITE_FILES, MINIMAL_SKIP_KEYS, REQUIRED_WORKSPACE_FILES, KEYWORD_STOPWORDS, SKILL_CATALOG_PRESETS } = require('../lib/catalogs'); // 1.9.344/368/369 (UR-0025): catalog 분리 (MERGE_OVERWRITE_FILES/MINIMAL_SKIP_KEYS 포함)
|
|
31
32
|
|
|
32
|
-
const VERSION = '1.9.
|
|
33
|
+
const VERSION = '1.9.391';
|
|
33
34
|
|
|
34
35
|
// 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
|
|
35
36
|
// 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
|
|
@@ -2992,6 +2993,8 @@ function _selfTestCases() {
|
|
|
2992
2993
|
{ name: 'UR-0088 5th외부평가 일관성: incident/runs list 빈 케이스 --json 구조화 (1.9.387)', run: () => { if (typeof incidentListCmd !== 'function' || typeof runsListCmd !== 'function') return false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_lj_')); const save = process.argv; const _w = process.stdout.write; let io = '', ro = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'incident', 'list', '--json']; process.stdout.write = s => { io += s; return true; }; incidentListCmd(tmp); process.stdout.write = _w; process.argv = ['node', 'h', 'runs', 'list', '--json']; process.stdout.write = s => { ro += s; return true; }; runsListCmd(tmp); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } let ij, rj; try { ij = JSON.parse(io); rj = JSON.parse(ro); } catch {} return !!ij && ij.total === 0 && Array.isArray(ij.items) && !!rj && rj.total === 0 && Array.isArray(rj.items); } },
|
|
2993
2994
|
{ name: 'UR-0025 큰핸들러 모듈화: migrate audit/apply/plan → lib/migrate.js + DI 위임 + 동작 (1.9.388)', run: () => { const m = require('../lib/migrate'); const expOk = typeof m.migrateAuditCmd === 'function' && typeof m.migrateApplyCmd === 'function' && typeof m.migratePlanCmd === 'function'; const src = read(__filename); const delegated = src.includes("require('../lib/migrate')") && src.includes('_migrate.migrateAuditCmd(root, opts, _migrateDeps())') && src.includes('_migrate.migratePlanCmd(root, opts, _migrateDeps())'); const movedToLib = read(path.join(path.dirname(__filename), '..', 'lib', 'migrate.js')).includes('leerness-plan-'); let behavOk = false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_mig_')); const save = process.argv; const _w = process.stdout.write; let out = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); fs.writeFileSync(path.join(tmp, '.harness', 'HARNESS_VERSION'), VERSION); process.argv = ['node', 'h', 'migrate', 'audit', tmp, '--json']; process.stdout.write = s => { out += s; return true; }; migrateAuditCmd(tmp, { json: true }); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } try { const j = JSON.parse(out); behavOk = j.version === VERSION && typeof j.willChange === 'number' && Array.isArray(j.findings); } catch {} return expOk && delegated && movedToLib && behavOk; } },
|
|
2994
2995
|
{ name: 'UR-0025 큰핸들러 모듈화: teamCmd → lib/team.js + DI 위임 + 동작 (1.9.389)', run: () => { const m = require('../lib/team'); const expOk = typeof m.teamCmd === 'function'; const src = read(__filename); const delegated = src.includes("require('../lib/team')") && src.includes('_team.teamCmd(root, sub, id, opts,'); const teamSrc = read(path.join(path.dirname(__filename), '..', 'lib', 'team.js')); const movedToLib = teamSrc.includes("require('./pure-utils')") && teamSrc.includes('_teamDeployGate') && teamSrc.includes('알 수 없는 team 하위명령'); let behavOk = false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_tm_')); const save = process.argv; const _w = process.stdout.write; let out = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'team', 'list', '--json']; process.stdout.write = s => { out += s; return true; }; teamCmd(tmp, 'list', undefined, { json: true }); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } try { const j = JSON.parse(out); behavOk = j.version === VERSION && j.count === 0 && Array.isArray(j.teams); } catch {} return expOk && delegated && movedToLib && behavOk; } },
|
|
2996
|
+
{ name: 'UR-0025: feature-graph 순수 코어(_featureGraphTemplate/_parseFeatureGraph/_nextFeatureId/_featureBlock) → pure-utils + round-trip (1.9.390)', run: () => { const m = require('../lib/pure-utils'); const refOk = m._parseFeatureGraph === _parseFeatureGraph && m._featureGraphTemplate === _featureGraphTemplate && m._nextFeatureId === _nextFeatureId && m._featureBlock === _featureBlock; const tmpl = m._featureGraphTemplate(); const tmplOk = tmpl.includes('Feature Graph') && tmpl.includes('## Nodes'); const nodes = m._parseFeatureGraph('## F-0001 Auth\n- depends-on: F-0002\n- affects: F-0003\n- files: a.js\n'); const parseOk = nodes.length === 1 && nodes[0].id === 'F-0001' && nodes[0].title === 'Auth' && nodes[0].dependsOn[0] === 'F-0002' && nodes[0].affects[0] === 'F-0003' && nodes[0].files[0] === 'a.js'; const idOk = m._nextFeatureId(nodes) === 'F-0002'; const rt = m._parseFeatureGraph(m._featureBlock(nodes[0])); const rtOk = rt.length === 1 && rt[0].id === 'F-0001' && rt[0].dependsOn[0] === 'F-0002'; const src = read(__filename); const moved = src.includes("require('../lib/pure-utils')") && !/^function _parseFeatureGraph\(text\) \{/m.test(src) && !/^function _featureBlock\(node\) \{/m.test(src); return refOk && tmplOk && parseOk && idOk && rtOk && moved; } },
|
|
2997
|
+
{ name: 'UR-0025 큰핸들러 모듈화: feature add/link/impact/list/show → lib/feature.js + DI + _featureImpactBfs pure 공유 (1.9.391)', run: () => { const m = require('../lib/feature'); const p = require('../lib/pure-utils'); const expOk = ['featureAddCmd', 'featureLinkCmd', 'featureImpactCmd', 'featureListCmd', 'featureShowCmd'].every(k => typeof m[k] === 'function'); const bfsRefOk = p._featureImpactBfs === _featureImpactBfs; const nodes = [{ id: 'F-0001', title: 'A', affects: ['F-0002'], dependsOn: [], coChangesWith: [] }, { id: 'F-0002', title: 'B', affects: [], dependsOn: [], coChangesWith: [] }]; const r = p._featureImpactBfs(nodes, 'F-0001'); const bfsWork = r.length === 1 && r[0].id === 'F-0002' && r[0].via === 'affects'; const src = read(__filename); const delegated = src.includes("require('../lib/feature')") && src.includes('_feature.featureImpactCmd(root, fromId, _featureDeps())'); const featSrc = read(path.join(path.dirname(__filename), '..', 'lib', 'feature.js')); const movedToLib = featSrc.includes("require('./pure-utils')") && featSrc.includes('feature added:'); let behavOk = false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_ft_')); const save = process.argv; const _w = process.stdout.write; let out = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'feature', 'list', '--json']; process.stdout.write = s => { out += s; return true; }; featureListCmd(tmp); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } try { const j = JSON.parse(out); behavOk = j.total === 0 && Array.isArray(j.features); } catch {} return expOk && bfsRefOk && bfsWork && delegated && movedToLib && behavOk; } },
|
|
2995
2998
|
{ name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
|
|
2996
2999
|
];
|
|
2997
3000
|
}
|
|
@@ -14505,61 +14508,6 @@ function lessonsCmd(root) {
|
|
|
14505
14508
|
// - tests: tests/foo.test.ts
|
|
14506
14509
|
// - notes: 자유 메모
|
|
14507
14510
|
function featureGraphPath(root) { return path.join(absRoot(root), '.harness', 'feature-graph.md'); }
|
|
14508
|
-
function _featureGraphTemplate() {
|
|
14509
|
-
return `# Feature Graph (1.9.141)\n\n` +
|
|
14510
|
-
`> **목적**: 각 기능의 인과관계를 정확히 정리해서 코드 작성 전 영향 범위를 자동 추적.\n` +
|
|
14511
|
-
`> 신규 기능 추가, 데이터 형식 변경, 외부 API 매칭 작업 전 \`leerness feature impact <id>\`로 확인.\n` +
|
|
14512
|
-
`> handoff가 현재 task 키워드로 자동 매칭해서 영향받는 feature 목록을 회수.\n\n` +
|
|
14513
|
-
`## How to use\n\n` +
|
|
14514
|
-
`\`\`\`bash\n` +
|
|
14515
|
-
`leerness feature add "User Auth" # F-0001 자동 부여\n` +
|
|
14516
|
-
`leerness feature link F-0002 --depends-on F-0001 # 의존 관계\n` +
|
|
14517
|
-
`leerness feature link F-0001 --affects F-0002,F-0005 # 영향 관계 (다수)\n` +
|
|
14518
|
-
`leerness feature link F-0001 --co-changes-with F-0011 # 함께 변해야 하는 기능\n` +
|
|
14519
|
-
`leerness feature impact F-0001 # 영향받는 전체 (transitive)\n` +
|
|
14520
|
-
`leerness feature list --json # 그래프 JSON\n` +
|
|
14521
|
-
`leerness feature show F-0001 # 단일 상세\n` +
|
|
14522
|
-
`\`\`\`\n\n` +
|
|
14523
|
-
`## Nodes\n\n`;
|
|
14524
|
-
}
|
|
14525
|
-
function _parseFeatureGraph(text) {
|
|
14526
|
-
if (!text) return [];
|
|
14527
|
-
const nodes = [];
|
|
14528
|
-
const re = /^## (F-\d{4})\s+(.+?)\s*$/gm;
|
|
14529
|
-
const positions = [];
|
|
14530
|
-
let m;
|
|
14531
|
-
while ((m = re.exec(text)) !== null) positions.push({ id: m[1], title: m[2], start: m.index });
|
|
14532
|
-
for (let i = 0; i < positions.length; i++) {
|
|
14533
|
-
const start = positions[i].start;
|
|
14534
|
-
const end = i + 1 < positions.length ? positions[i + 1].start : text.length;
|
|
14535
|
-
const block = text.slice(start, end);
|
|
14536
|
-
const parseField = (key) => {
|
|
14537
|
-
// 1.9.141 fix: \s 은 \n 도 포함하므로 [ \t]* 로 newline 비포함 horizontal whitespace 만 매칭
|
|
14538
|
-
const r = new RegExp(`^- ${key}:[ \\t]*(.*?)$`, 'mi');
|
|
14539
|
-
const mm = block.match(r);
|
|
14540
|
-
return mm ? mm[1].trim() : '';
|
|
14541
|
-
};
|
|
14542
|
-
const parseList = (key) => {
|
|
14543
|
-
const v = parseField(key);
|
|
14544
|
-
if (!v) return [];
|
|
14545
|
-
return v.split(/[,\s]+/).map(s => s.trim()).filter(Boolean);
|
|
14546
|
-
};
|
|
14547
|
-
nodes.push({
|
|
14548
|
-
id: positions[i].id,
|
|
14549
|
-
title: positions[i].title,
|
|
14550
|
-
dependsOn: parseList('depends-on'),
|
|
14551
|
-
affects: parseList('affects'),
|
|
14552
|
-
coChangesWith: parseList('co-changes-with'),
|
|
14553
|
-
files: parseList('files'),
|
|
14554
|
-
input: parseField('input'),
|
|
14555
|
-
output: parseField('output'),
|
|
14556
|
-
errorModes: parseList('error-modes'),
|
|
14557
|
-
tests: parseList('tests'),
|
|
14558
|
-
notes: parseField('notes')
|
|
14559
|
-
});
|
|
14560
|
-
}
|
|
14561
|
-
return nodes;
|
|
14562
|
-
}
|
|
14563
14511
|
function _readFeatureGraph(root) {
|
|
14564
14512
|
const p = featureGraphPath(root);
|
|
14565
14513
|
if (!exists(p)) return { nodes: [], text: '' };
|
|
@@ -14571,157 +14519,21 @@ function _ensureFeatureGraph(root) {
|
|
|
14571
14519
|
if (!exists(p)) writeUtf8(p, _featureGraphTemplate());
|
|
14572
14520
|
return p;
|
|
14573
14521
|
}
|
|
14574
|
-
function _nextFeatureId(nodes) {
|
|
14575
|
-
const used = new Set(nodes.map(n => parseInt(n.id.slice(2), 10)));
|
|
14576
|
-
let n = 1; while (used.has(n)) n++;
|
|
14577
|
-
return 'F-' + String(n).padStart(4, '0');
|
|
14578
|
-
}
|
|
14579
|
-
function _featureBlock(node) {
|
|
14580
|
-
return `## ${node.id} ${node.title}\n` +
|
|
14581
|
-
`- depends-on: ${(node.dependsOn || []).join(', ')}\n` +
|
|
14582
|
-
`- affects: ${(node.affects || []).join(', ')}\n` +
|
|
14583
|
-
`- co-changes-with: ${(node.coChangesWith || []).join(', ')}\n` +
|
|
14584
|
-
`- files: ${(node.files || []).join(', ')}\n` +
|
|
14585
|
-
`- input: ${node.input || ''}\n` +
|
|
14586
|
-
`- output: ${node.output || ''}\n` +
|
|
14587
|
-
`- error-modes: ${(node.errorModes || []).join(', ')}\n` +
|
|
14588
|
-
`- tests: ${(node.tests || []).join(', ')}\n` +
|
|
14589
|
-
`- notes: ${node.notes || ''}\n\n`;
|
|
14590
|
-
}
|
|
14591
14522
|
function _writeFeatureGraph(root, nodes) {
|
|
14592
14523
|
const p = _ensureFeatureGraph(root);
|
|
14593
14524
|
const header = _featureGraphTemplate();
|
|
14594
14525
|
const body = nodes.map(_featureBlock).join('');
|
|
14595
14526
|
writeUtf8(p, header + body);
|
|
14596
14527
|
}
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
const node = {
|
|
14607
|
-
id, title,
|
|
14608
|
-
dependsOn: [], affects: [], coChangesWith: [],
|
|
14609
|
-
files: [], input: '', output: '', errorModes: [], tests: [], notes: ''
|
|
14610
|
-
};
|
|
14611
|
-
// 옵션 인자 — 한 번에 의존/영향 등록 가능
|
|
14612
|
-
const depends = arg('--depends-on', '');
|
|
14613
|
-
const affects = arg('--affects', '');
|
|
14614
|
-
const coChanges = arg('--co-changes-with', '');
|
|
14615
|
-
const files = arg('--files', '');
|
|
14616
|
-
if (depends) node.dependsOn = depends.split(/[,\s]+/).filter(Boolean);
|
|
14617
|
-
if (affects) node.affects = affects.split(/[,\s]+/).filter(Boolean);
|
|
14618
|
-
if (coChanges) node.coChangesWith = coChanges.split(/[,\s]+/).filter(Boolean);
|
|
14619
|
-
if (files) node.files = files.split(/[,\s]+/).filter(Boolean);
|
|
14620
|
-
nodes.push(node);
|
|
14621
|
-
_writeFeatureGraph(root, nodes);
|
|
14622
|
-
ok(`feature added: ${id} · ${title}`);
|
|
14623
|
-
}
|
|
14624
|
-
function featureLinkCmd(root, fromId) {
|
|
14625
|
-
root = absRoot(root);
|
|
14626
|
-
if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature link: 첫 인자는 F-XXXX 형식 ID');
|
|
14627
|
-
const { nodes } = _readFeatureGraph(root);
|
|
14628
|
-
const node = nodes.find(n => n.id === fromId);
|
|
14629
|
-
if (!node) return fail(`feature ${fromId} 없음 — feature add 먼저`);
|
|
14630
|
-
const dep = arg('--depends-on', '');
|
|
14631
|
-
const aff = arg('--affects', '');
|
|
14632
|
-
const co = arg('--co-changes-with', '');
|
|
14633
|
-
let changes = 0;
|
|
14634
|
-
if (dep) { const ids = dep.split(/[,\s]+/).filter(Boolean); for (const id of ids) if (!node.dependsOn.includes(id)) { node.dependsOn.push(id); changes++; } }
|
|
14635
|
-
if (aff) { const ids = aff.split(/[,\s]+/).filter(Boolean); for (const id of ids) if (!node.affects.includes(id)) { node.affects.push(id); changes++; } }
|
|
14636
|
-
if (co) { const ids = co.split(/[,\s]+/).filter(Boolean); for (const id of ids) if (!node.coChangesWith.includes(id)) { node.coChangesWith.push(id); changes++; } }
|
|
14637
|
-
if (!changes) return warn('변경 없음 — --depends-on / --affects / --co-changes-with 중 하나 이상 지정');
|
|
14638
|
-
_writeFeatureGraph(root, nodes);
|
|
14639
|
-
ok(`feature ${fromId} 링크 ${changes}건 추가`);
|
|
14640
|
-
}
|
|
14641
|
-
function _featureImpactBfs(nodes, startId) {
|
|
14642
|
-
// affects + co-changes-with 양방향 transitive closure
|
|
14643
|
-
const byId = new Map(nodes.map(n => [n.id, n]));
|
|
14644
|
-
const visited = new Set();
|
|
14645
|
-
const queue = [{ id: startId, depth: 0, via: 'self' }];
|
|
14646
|
-
const result = [];
|
|
14647
|
-
while (queue.length) {
|
|
14648
|
-
const cur = queue.shift();
|
|
14649
|
-
if (visited.has(cur.id)) continue;
|
|
14650
|
-
visited.add(cur.id);
|
|
14651
|
-
const node = byId.get(cur.id);
|
|
14652
|
-
if (!node) continue;
|
|
14653
|
-
if (cur.depth > 0) result.push({ id: cur.id, title: node.title, depth: cur.depth, via: cur.via, files: node.files, errorModes: node.errorModes });
|
|
14654
|
-
for (const next of node.affects || []) queue.push({ id: next, depth: cur.depth + 1, via: 'affects' });
|
|
14655
|
-
for (const next of node.coChangesWith || []) queue.push({ id: next, depth: cur.depth + 1, via: 'co-changes-with' });
|
|
14656
|
-
}
|
|
14657
|
-
// 역방향: 이 feature에 depends-on 하는 노드도 영향받음
|
|
14658
|
-
for (const n of nodes) {
|
|
14659
|
-
if (visited.has(n.id)) continue;
|
|
14660
|
-
if ((n.dependsOn || []).includes(startId)) {
|
|
14661
|
-
result.push({ id: n.id, title: n.title, depth: 1, via: 'depends-on(reverse)', files: n.files, errorModes: n.errorModes });
|
|
14662
|
-
visited.add(n.id);
|
|
14663
|
-
}
|
|
14664
|
-
}
|
|
14665
|
-
return result;
|
|
14666
|
-
}
|
|
14667
|
-
function featureImpactCmd(root, fromId) {
|
|
14668
|
-
root = absRoot(root);
|
|
14669
|
-
if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature impact: F-XXXX ID 필요');
|
|
14670
|
-
const { nodes } = _readFeatureGraph(root);
|
|
14671
|
-
const node = nodes.find(n => n.id === fromId);
|
|
14672
|
-
if (!node) return fail(`feature ${fromId} 없음`);
|
|
14673
|
-
const impacted = _featureImpactBfs(nodes, fromId);
|
|
14674
|
-
if (has('--json')) {
|
|
14675
|
-
log(JSON.stringify({ feature: { id: node.id, title: node.title }, total: impacted.length, impacted }, null, 2));
|
|
14676
|
-
return;
|
|
14677
|
-
}
|
|
14678
|
-
log(`# Feature Impact: ${node.id} · ${node.title}`);
|
|
14679
|
-
if (!impacted.length) { ok('영향받는 다른 feature 없음 (또는 link 미설정)'); return; }
|
|
14680
|
-
log(`\n총 ${impacted.length} feature에 영향:\n`);
|
|
14681
|
-
for (const it of impacted) {
|
|
14682
|
-
log(` ${it.id} · ${it.title} [depth=${it.depth}, via=${it.via}]`);
|
|
14683
|
-
if (it.files && it.files.length) log(` files: ${it.files.join(', ')}`);
|
|
14684
|
-
if (it.errorModes && it.errorModes.length) log(` error-modes: ${it.errorModes.join(', ')}`);
|
|
14685
|
-
}
|
|
14686
|
-
log(`\n💡 코드 변경 전 위 ${impacted.length}개 feature의 테스트/계약 확인 권장`);
|
|
14687
|
-
}
|
|
14688
|
-
function featureListCmd(root) {
|
|
14689
|
-
root = absRoot(root);
|
|
14690
|
-
const { nodes } = _readFeatureGraph(root);
|
|
14691
|
-
if (has('--json')) {
|
|
14692
|
-
log(JSON.stringify({ total: nodes.length, features: nodes }, null, 2));
|
|
14693
|
-
return;
|
|
14694
|
-
}
|
|
14695
|
-
log(`# Features (${nodes.length}개)`);
|
|
14696
|
-
if (!nodes.length) {
|
|
14697
|
-
log(' (없음) — leerness feature add "<title>"');
|
|
14698
|
-
return;
|
|
14699
|
-
}
|
|
14700
|
-
for (const n of nodes) {
|
|
14701
|
-
log(` ${n.id} · ${n.title}`);
|
|
14702
|
-
if (n.dependsOn.length) log(` ↓ depends-on: ${n.dependsOn.join(', ')}`);
|
|
14703
|
-
if (n.affects.length) log(` → affects: ${n.affects.join(', ')}`);
|
|
14704
|
-
if (n.coChangesWith.length) log(` ↔ co-changes-with: ${n.coChangesWith.join(', ')}`);
|
|
14705
|
-
}
|
|
14706
|
-
}
|
|
14707
|
-
function featureShowCmd(root, fromId) {
|
|
14708
|
-
root = absRoot(root);
|
|
14709
|
-
if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature show: F-XXXX ID 필요');
|
|
14710
|
-
const { nodes } = _readFeatureGraph(root);
|
|
14711
|
-
const node = nodes.find(n => n.id === fromId);
|
|
14712
|
-
if (!node) return fail(`feature ${fromId} 없음`);
|
|
14713
|
-
if (has('--json')) { log(JSON.stringify(node, null, 2)); return; }
|
|
14714
|
-
log(`# ${node.id} · ${node.title}`);
|
|
14715
|
-
log(` depends-on: ${node.dependsOn.join(', ') || '(없음)'}`);
|
|
14716
|
-
log(` affects: ${node.affects.join(', ') || '(없음)'}`);
|
|
14717
|
-
log(` co-changes-with: ${node.coChangesWith.join(', ') || '(없음)'}`);
|
|
14718
|
-
log(` files: ${node.files.join(', ') || '(없음)'}`);
|
|
14719
|
-
log(` input: ${node.input || '(없음)'}`);
|
|
14720
|
-
log(` output: ${node.output || '(없음)'}`);
|
|
14721
|
-
log(` error-modes: ${node.errorModes.join(', ') || '(없음)'}`);
|
|
14722
|
-
log(` tests: ${node.tests.join(', ') || '(없음)'}`);
|
|
14723
|
-
log(` notes: ${node.notes || '(없음)'}`);
|
|
14724
|
-
}
|
|
14528
|
+
// 1.9.391 (UR-0025 큰 핸들러 모듈화 3번째): feature add/link/impact/list/show 핸들러를 lib/feature.js 로 분리.
|
|
14529
|
+
// _featureImpactBfs 는 pure-utils 로 이동(handoff/audit 공유). feature-graph I/O 헬퍼(_readFeatureGraph 등)는 공유라 harness 유지+주입.
|
|
14530
|
+
const _feature = require('../lib/feature');
|
|
14531
|
+
function _featureDeps() { return { _ensureFeatureGraph, _readFeatureGraph, _writeFeatureGraph, arg, has }; }
|
|
14532
|
+
function featureAddCmd(root, title) { return _feature.featureAddCmd(root, title, _featureDeps()); }
|
|
14533
|
+
function featureLinkCmd(root, fromId) { return _feature.featureLinkCmd(root, fromId, _featureDeps()); }
|
|
14534
|
+
function featureImpactCmd(root, fromId) { return _feature.featureImpactCmd(root, fromId, _featureDeps()); }
|
|
14535
|
+
function featureListCmd(root) { return _feature.featureListCmd(root, _featureDeps()); }
|
|
14536
|
+
function featureShowCmd(root, fromId) { return _feature.featureShowCmd(root, fromId, _featureDeps()); }
|
|
14725
14537
|
|
|
14726
14538
|
// ===== 1.9.3: Causal / reuse / consistency =====
|
|
14727
14539
|
const CODE_EXT = new Set(['.js','.ts','.jsx','.tsx','.mjs','.cjs','.css','.scss','.sass','.less','.html','.htm','.vue','.svelte','.md','.json','.py','.rb','.go','.rs','.java','.kt','.swift','.cs','.php']);
|
package/lib/feature.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// lib/feature.js — feature-graph 핸들러 (add/link/impact/list/show).
|
|
2
|
+
// 1.9.391 (UR-0025 큰 핸들러 모듈화 3번째): bin/harness.js 에서 feature 핸들러 분리.
|
|
3
|
+
// - I/O 프리미티브: ./io. 순수 로직: ./pure-utils(_nextFeatureId/_featureImpactBfs).
|
|
4
|
+
// - feature-graph I/O 헬퍼(_readFeatureGraph/_writeFeatureGraph/_ensureFeatureGraph)는 audit/health/handoff 등도 쓰는
|
|
5
|
+
// 공유 함수라 harness 에 유지하고 deps 로 주입(DI). argv 파서 arg/has 도 주입.
|
|
6
|
+
'use strict';
|
|
7
|
+
const { absRoot, log, ok, warn, fail } = require('./io');
|
|
8
|
+
const { _nextFeatureId, _featureImpactBfs } = require('./pure-utils');
|
|
9
|
+
|
|
10
|
+
function featureAddCmd(root, title, deps = {}) {
|
|
11
|
+
const { _ensureFeatureGraph, _readFeatureGraph, _writeFeatureGraph, arg } = deps;
|
|
12
|
+
root = absRoot(root);
|
|
13
|
+
if (!title) return fail('feature add: title 필요 — leerness feature add "<title>"');
|
|
14
|
+
_ensureFeatureGraph(root);
|
|
15
|
+
const { nodes } = _readFeatureGraph(root);
|
|
16
|
+
if (nodes.some(n => n.title.toLowerCase() === title.toLowerCase())) {
|
|
17
|
+
return warn(`이미 존재: "${title}"`);
|
|
18
|
+
}
|
|
19
|
+
const id = _nextFeatureId(nodes);
|
|
20
|
+
const node = {
|
|
21
|
+
id, title,
|
|
22
|
+
dependsOn: [], affects: [], coChangesWith: [],
|
|
23
|
+
files: [], input: '', output: '', errorModes: [], tests: [], notes: ''
|
|
24
|
+
};
|
|
25
|
+
// 옵션 인자 — 한 번에 의존/영향 등록 가능
|
|
26
|
+
const depends = arg('--depends-on', '');
|
|
27
|
+
const affects = arg('--affects', '');
|
|
28
|
+
const coChanges = arg('--co-changes-with', '');
|
|
29
|
+
const files = arg('--files', '');
|
|
30
|
+
if (depends) node.dependsOn = depends.split(/[,\s]+/).filter(Boolean);
|
|
31
|
+
if (affects) node.affects = affects.split(/[,\s]+/).filter(Boolean);
|
|
32
|
+
if (coChanges) node.coChangesWith = coChanges.split(/[,\s]+/).filter(Boolean);
|
|
33
|
+
if (files) node.files = files.split(/[,\s]+/).filter(Boolean);
|
|
34
|
+
nodes.push(node);
|
|
35
|
+
_writeFeatureGraph(root, nodes);
|
|
36
|
+
ok(`feature added: ${id} · ${title}`);
|
|
37
|
+
}
|
|
38
|
+
function featureLinkCmd(root, fromId, deps = {}) {
|
|
39
|
+
const { _readFeatureGraph, _writeFeatureGraph, arg } = deps;
|
|
40
|
+
root = absRoot(root);
|
|
41
|
+
if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature link: 첫 인자는 F-XXXX 형식 ID');
|
|
42
|
+
const { nodes } = _readFeatureGraph(root);
|
|
43
|
+
const node = nodes.find(n => n.id === fromId);
|
|
44
|
+
if (!node) return fail(`feature ${fromId} 없음 — feature add 먼저`);
|
|
45
|
+
const dep = arg('--depends-on', '');
|
|
46
|
+
const aff = arg('--affects', '');
|
|
47
|
+
const co = arg('--co-changes-with', '');
|
|
48
|
+
let changes = 0;
|
|
49
|
+
if (dep) { const ids = dep.split(/[,\s]+/).filter(Boolean); for (const id of ids) if (!node.dependsOn.includes(id)) { node.dependsOn.push(id); changes++; } }
|
|
50
|
+
if (aff) { const ids = aff.split(/[,\s]+/).filter(Boolean); for (const id of ids) if (!node.affects.includes(id)) { node.affects.push(id); changes++; } }
|
|
51
|
+
if (co) { const ids = co.split(/[,\s]+/).filter(Boolean); for (const id of ids) if (!node.coChangesWith.includes(id)) { node.coChangesWith.push(id); changes++; } }
|
|
52
|
+
if (!changes) return warn('변경 없음 — --depends-on / --affects / --co-changes-with 중 하나 이상 지정');
|
|
53
|
+
_writeFeatureGraph(root, nodes);
|
|
54
|
+
ok(`feature ${fromId} 링크 ${changes}건 추가`);
|
|
55
|
+
}
|
|
56
|
+
function featureImpactCmd(root, fromId, deps = {}) {
|
|
57
|
+
const { _readFeatureGraph, has } = deps;
|
|
58
|
+
root = absRoot(root);
|
|
59
|
+
if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature impact: F-XXXX ID 필요');
|
|
60
|
+
const { nodes } = _readFeatureGraph(root);
|
|
61
|
+
const node = nodes.find(n => n.id === fromId);
|
|
62
|
+
if (!node) return fail(`feature ${fromId} 없음`);
|
|
63
|
+
const impacted = _featureImpactBfs(nodes, fromId);
|
|
64
|
+
if (has('--json')) {
|
|
65
|
+
log(JSON.stringify({ feature: { id: node.id, title: node.title }, total: impacted.length, impacted }, null, 2));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
log(`# Feature Impact: ${node.id} · ${node.title}`);
|
|
69
|
+
if (!impacted.length) { ok('영향받는 다른 feature 없음 (또는 link 미설정)'); return; }
|
|
70
|
+
log(`\n총 ${impacted.length} feature에 영향:\n`);
|
|
71
|
+
for (const it of impacted) {
|
|
72
|
+
log(` ${it.id} · ${it.title} [depth=${it.depth}, via=${it.via}]`);
|
|
73
|
+
if (it.files && it.files.length) log(` files: ${it.files.join(', ')}`);
|
|
74
|
+
if (it.errorModes && it.errorModes.length) log(` error-modes: ${it.errorModes.join(', ')}`);
|
|
75
|
+
}
|
|
76
|
+
log(`\n💡 코드 변경 전 위 ${impacted.length}개 feature의 테스트/계약 확인 권장`);
|
|
77
|
+
}
|
|
78
|
+
function featureListCmd(root, deps = {}) {
|
|
79
|
+
const { _readFeatureGraph, has } = deps;
|
|
80
|
+
root = absRoot(root);
|
|
81
|
+
const { nodes } = _readFeatureGraph(root);
|
|
82
|
+
if (has('--json')) {
|
|
83
|
+
log(JSON.stringify({ total: nodes.length, features: nodes }, null, 2));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
log(`# Features (${nodes.length}개)`);
|
|
87
|
+
if (!nodes.length) {
|
|
88
|
+
log(' (없음) — leerness feature add "<title>"');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
for (const n of nodes) {
|
|
92
|
+
log(` ${n.id} · ${n.title}`);
|
|
93
|
+
if (n.dependsOn.length) log(` ↓ depends-on: ${n.dependsOn.join(', ')}`);
|
|
94
|
+
if (n.affects.length) log(` → affects: ${n.affects.join(', ')}`);
|
|
95
|
+
if (n.coChangesWith.length) log(` ↔ co-changes-with: ${n.coChangesWith.join(', ')}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function featureShowCmd(root, fromId, deps = {}) {
|
|
99
|
+
const { _readFeatureGraph, has } = deps;
|
|
100
|
+
root = absRoot(root);
|
|
101
|
+
if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature show: F-XXXX ID 필요');
|
|
102
|
+
const { nodes } = _readFeatureGraph(root);
|
|
103
|
+
const node = nodes.find(n => n.id === fromId);
|
|
104
|
+
if (!node) return fail(`feature ${fromId} 없음`);
|
|
105
|
+
if (has('--json')) { log(JSON.stringify(node, null, 2)); return; }
|
|
106
|
+
log(`# ${node.id} · ${node.title}`);
|
|
107
|
+
log(` depends-on: ${node.dependsOn.join(', ') || '(없음)'}`);
|
|
108
|
+
log(` affects: ${node.affects.join(', ') || '(없음)'}`);
|
|
109
|
+
log(` co-changes-with: ${node.coChangesWith.join(', ') || '(없음)'}`);
|
|
110
|
+
log(` files: ${node.files.join(', ') || '(없음)'}`);
|
|
111
|
+
log(` input: ${node.input || '(없음)'}`);
|
|
112
|
+
log(` output: ${node.output || '(없음)'}`);
|
|
113
|
+
log(` error-modes: ${node.errorModes.join(', ') || '(없음)'}`);
|
|
114
|
+
log(` tests: ${node.tests.join(', ') || '(없음)'}`);
|
|
115
|
+
log(` notes: ${node.notes || '(없음)'}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = { featureAddCmd, featureLinkCmd, featureImpactCmd, featureListCmd, featureShowCmd };
|
package/lib/pure-utils.js
CHANGED
|
@@ -929,7 +929,11 @@ module.exports = {
|
|
|
929
929
|
// 1.9.385 (UR-0086, 5th외부평가): contract spec 순수 파서 (markdown bullet 함수 선언 감지)
|
|
930
930
|
_parseContractSpec,
|
|
931
931
|
// 1.9.386 (UR-0087, 5th외부평가): 간이 .gitignore 매칭 + glob (bare .env → .env.* 과잉보호 제거)
|
|
932
|
-
_gitignoreMatch, _globToRe
|
|
932
|
+
_gitignoreMatch, _globToRe,
|
|
933
|
+
// 1.9.390 (UR-0025): feature-graph 순수 코어 (템플릿/파서/ID/블록)
|
|
934
|
+
_featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock,
|
|
935
|
+
// 1.9.391 (UR-0025): feature 영향 BFS (순수, 공유)
|
|
936
|
+
_featureImpactBfs
|
|
933
937
|
};
|
|
934
938
|
|
|
935
939
|
// 1.9.355 (UR-0075 Phase A): AI 에이전트용 크로스버전 마이그레이션 안전 워크플로 가이드 (순수 텍스트). 임시설치 + --path + 백업 + diff 검증.
|
|
@@ -1016,3 +1020,103 @@ function _gitignoreMatch(giText, fileRel) {
|
|
|
1016
1020
|
}
|
|
1017
1021
|
return false;
|
|
1018
1022
|
}
|
|
1023
|
+
|
|
1024
|
+
// 1.9.390 (UR-0025): feature-graph 순수 코어 — 템플릿/파서/ID/블록 렌더 (I/O 없음). harness 의 _readFeatureGraph/_writeFeatureGraph 가 사용.
|
|
1025
|
+
function _featureGraphTemplate() {
|
|
1026
|
+
return `# Feature Graph (1.9.141)\n\n` +
|
|
1027
|
+
`> **목적**: 각 기능의 인과관계를 정확히 정리해서 코드 작성 전 영향 범위를 자동 추적.\n` +
|
|
1028
|
+
`> 신규 기능 추가, 데이터 형식 변경, 외부 API 매칭 작업 전 \`leerness feature impact <id>\`로 확인.\n` +
|
|
1029
|
+
`> handoff가 현재 task 키워드로 자동 매칭해서 영향받는 feature 목록을 회수.\n\n` +
|
|
1030
|
+
`## How to use\n\n` +
|
|
1031
|
+
`\`\`\`bash\n` +
|
|
1032
|
+
`leerness feature add "User Auth" # F-0001 자동 부여\n` +
|
|
1033
|
+
`leerness feature link F-0002 --depends-on F-0001 # 의존 관계\n` +
|
|
1034
|
+
`leerness feature link F-0001 --affects F-0002,F-0005 # 영향 관계 (다수)\n` +
|
|
1035
|
+
`leerness feature link F-0001 --co-changes-with F-0011 # 함께 변해야 하는 기능\n` +
|
|
1036
|
+
`leerness feature impact F-0001 # 영향받는 전체 (transitive)\n` +
|
|
1037
|
+
`leerness feature list --json # 그래프 JSON\n` +
|
|
1038
|
+
`leerness feature show F-0001 # 단일 상세\n` +
|
|
1039
|
+
`\`\`\`\n\n` +
|
|
1040
|
+
`## Nodes\n\n`;
|
|
1041
|
+
}
|
|
1042
|
+
function _parseFeatureGraph(text) {
|
|
1043
|
+
if (!text) return [];
|
|
1044
|
+
const nodes = [];
|
|
1045
|
+
const re = /^## (F-\d{4})\s+(.+?)\s*$/gm;
|
|
1046
|
+
const positions = [];
|
|
1047
|
+
let m;
|
|
1048
|
+
while ((m = re.exec(text)) !== null) positions.push({ id: m[1], title: m[2], start: m.index });
|
|
1049
|
+
for (let i = 0; i < positions.length; i++) {
|
|
1050
|
+
const start = positions[i].start;
|
|
1051
|
+
const end = i + 1 < positions.length ? positions[i + 1].start : text.length;
|
|
1052
|
+
const block = text.slice(start, end);
|
|
1053
|
+
const parseField = (key) => {
|
|
1054
|
+
// 1.9.141 fix: \s 은 \n 도 포함하므로 [ \t]* 로 newline 비포함 horizontal whitespace 만 매칭
|
|
1055
|
+
const r = new RegExp(`^- ${key}:[ \\t]*(.*?)$`, 'mi');
|
|
1056
|
+
const mm = block.match(r);
|
|
1057
|
+
return mm ? mm[1].trim() : '';
|
|
1058
|
+
};
|
|
1059
|
+
const parseList = (key) => {
|
|
1060
|
+
const v = parseField(key);
|
|
1061
|
+
if (!v) return [];
|
|
1062
|
+
return v.split(/[,\s]+/).map(s => s.trim()).filter(Boolean);
|
|
1063
|
+
};
|
|
1064
|
+
nodes.push({
|
|
1065
|
+
id: positions[i].id,
|
|
1066
|
+
title: positions[i].title,
|
|
1067
|
+
dependsOn: parseList('depends-on'),
|
|
1068
|
+
affects: parseList('affects'),
|
|
1069
|
+
coChangesWith: parseList('co-changes-with'),
|
|
1070
|
+
files: parseList('files'),
|
|
1071
|
+
input: parseField('input'),
|
|
1072
|
+
output: parseField('output'),
|
|
1073
|
+
errorModes: parseList('error-modes'),
|
|
1074
|
+
tests: parseList('tests'),
|
|
1075
|
+
notes: parseField('notes')
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
return nodes;
|
|
1079
|
+
}
|
|
1080
|
+
function _nextFeatureId(nodes) {
|
|
1081
|
+
const used = new Set(nodes.map(n => parseInt(n.id.slice(2), 10)));
|
|
1082
|
+
let n = 1; while (used.has(n)) n++;
|
|
1083
|
+
return 'F-' + String(n).padStart(4, '0');
|
|
1084
|
+
}
|
|
1085
|
+
function _featureBlock(node) {
|
|
1086
|
+
return `## ${node.id} ${node.title}\n` +
|
|
1087
|
+
`- depends-on: ${(node.dependsOn || []).join(', ')}\n` +
|
|
1088
|
+
`- affects: ${(node.affects || []).join(', ')}\n` +
|
|
1089
|
+
`- co-changes-with: ${(node.coChangesWith || []).join(', ')}\n` +
|
|
1090
|
+
`- files: ${(node.files || []).join(', ')}\n` +
|
|
1091
|
+
`- input: ${node.input || ''}\n` +
|
|
1092
|
+
`- output: ${node.output || ''}\n` +
|
|
1093
|
+
`- error-modes: ${(node.errorModes || []).join(', ')}\n` +
|
|
1094
|
+
`- tests: ${(node.tests || []).join(', ')}\n` +
|
|
1095
|
+
`- notes: ${node.notes || ''}\n\n`;
|
|
1096
|
+
}
|
|
1097
|
+
// 1.9.391 (UR-0025): feature 영향 BFS — affects + co-changes-with transitive + depends-on 역방향. 순수(nodes,startId→result). harness(handoff/audit)+lib/feature 공유.
|
|
1098
|
+
function _featureImpactBfs(nodes, startId) {
|
|
1099
|
+
const byId = new Map(nodes.map(n => [n.id, n]));
|
|
1100
|
+
const visited = new Set();
|
|
1101
|
+
const queue = [{ id: startId, depth: 0, via: 'self' }];
|
|
1102
|
+
const result = [];
|
|
1103
|
+
while (queue.length) {
|
|
1104
|
+
const cur = queue.shift();
|
|
1105
|
+
if (visited.has(cur.id)) continue;
|
|
1106
|
+
visited.add(cur.id);
|
|
1107
|
+
const node = byId.get(cur.id);
|
|
1108
|
+
if (!node) continue;
|
|
1109
|
+
if (cur.depth > 0) result.push({ id: cur.id, title: node.title, depth: cur.depth, via: cur.via, files: node.files, errorModes: node.errorModes });
|
|
1110
|
+
for (const next of node.affects || []) queue.push({ id: next, depth: cur.depth + 1, via: 'affects' });
|
|
1111
|
+
for (const next of node.coChangesWith || []) queue.push({ id: next, depth: cur.depth + 1, via: 'co-changes-with' });
|
|
1112
|
+
}
|
|
1113
|
+
// 역방향: 이 feature에 depends-on 하는 노드도 영향받음
|
|
1114
|
+
for (const n of nodes) {
|
|
1115
|
+
if (visited.has(n.id)) continue;
|
|
1116
|
+
if ((n.dependsOn || []).includes(startId)) {
|
|
1117
|
+
result.push({ id: n.id, title: n.title, depth: 1, via: 'depends-on(reverse)', files: n.files, errorModes: n.errorModes });
|
|
1118
|
+
visited.add(n.id);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return result;
|
|
1122
|
+
}
|