leerness 1.9.392 → 1.9.394

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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.394 — 2026-06-06 — UR-0025: whatsNewCmd → lib/diagnostics.js (whats-new 완결) + 파서 형제버그 감사
4
+
5
+ **🧩 whats-new 핸들러를 lib/diagnostics.js 로 분리 — whats-new 서브시스템 완전 모듈화. + /m `$` 절단 버그 클래스 전수 감사(클린).**
6
+
7
+ ### 배경
8
+ 1.9.393 에서 whats-new 파서(`_parseChangelogBetween`)를 pure-utils 로 빼고 버그 2건을 고쳤다. 후속으로 (1) **같은 부류의 형제 버그 감사** + (2) whatsNewCmd 핸들러 자체 분리로 서브시스템을 완결.
9
+
10
+ ### 구현
11
+ 1. **파서 형제버그 감사**: `|$)` lookahead + `/m` 조합으로 줄끝 절단되는 정규식을 전수 검색. 다른 5개(`Tasks:` 섹션 / `## Incomplete` / env-family / secret value / lang) 는 모두 `/m` 미사용이거나 `$`=문자열끝으로 **올바름** → 형제 버그 없음(no-op 릴리스 안 만듦).
12
+ 2. **whatsNewCmd → lib/diagnostics.js**: introspection 핸들러(~58줄) 이전. require: `./io`(absRoot/exists/read/log/fail) · `./pure-utils`(parseHarnessVersion/_parseChangelogBetween) · node path. DI: VERSION/arg/has. CHANGELOG 경로 fallback `lib/../CHANGELOG.md`(= pkg 루트, bin/ 과 동일).
13
+ 3. harness thin wrapper. dispatch·동작·출력·exit code 무변경.
14
+
15
+ ### 검증 (회귀 0)
16
+ - **selftest 139→140 PASS** (lib/diagnostics whatsNewCmd export + 위임 와이어 + lib 본문 이동 + behavioral: tmp CHANGELOG `--from 1.9.49 --to 1.9.50 --json` → 1 version).
17
+ - **E2E 333 유지 PASS** (whats-new B(1.9.393) + 회귀). 락 flake 시 재실행.
18
+ - 실측: whats-new --from 1.9.388 --json(5 versions) · 사람용 · --from 누락 exit1 보존.
19
+
20
+ ## 1.9.393 — 2026-06-06 — whats-new 파서 BUG-fix + _parseChangelogBetween → pure-utils (UR-0025/UR-0094)
21
+
22
+ **🐞 `whats-new` 가 현재 CHANGELOG 형식(`## X — DATE — title`)에서 0건 반환하던 버그 수정 + 파서를 lib/pure-utils.js 로 추출.**
23
+
24
+ ### 배경 (UR-0025 모듈화 중 실사용 버그 발견)
25
+ whats-new 의 순수 파서 `_parseChangelogBetween` 를 pure-utils 로 추출하려다 자체 검증에서 **실사용 버그 2건** 발견(추출은 byte-identical 이라 회귀 아님 — 기존부터 깨져 있었음):
26
+ 1. **헤더 미파싱**: 헤더 꼬리 정규식 `\s*\n` 이 `## X — DATE — title` 의 ` — title` 를 소비 못 해 현재 CHANGELOG 형식에서 **0개 섹션** 반환(`whats-new --from 1.9.388` → 0 versions).
27
+ 2. **body 첫줄 절단**: body 캡처 `([\s\S]*?)(?=^##…|$)` 의 `$` 가 `/m` 모드에서 **줄 끝**과 매칭 → body 가 첫 줄로 잘림(①이 헤더를 막아 가려져 있던 잠재 버그).
28
+
29
+ ### 구현
30
+ - `_parseChangelogBetween` 를 `_parseFeatureGraph` 식 **위치 기반 분할**로 재작성: 헤더 정규식으로 위치 수집 → 다음 헤더(또는 끝)까지 body 전체 slice. `## X` / `## X — DATE` / `## X — DATE — title` 모두 매칭, 다중줄 body 보존.
31
+ - pure-utils 로 추출(738 update 경로 + whats-new 공유) + harness 인라인 제거 + import.
32
+
33
+ ### 검증 (회귀 0)
34
+ - **selftest 138→139 PASS** (reference-equality + `## X — DATE — title` 파싱 + 명령/플래그/파일 추출 + 제목없음 헤더 + 인라인 제거).
35
+ - **E2E 332→333 PASS** (실제 CHANGELOG whats-new `--from 1.9.388` ≥1 versions + 제목있음/없음 헤더 + 다중줄 body).
36
+ - 실측: whats-new --from 1.9.388 = **0 → 4 versions**(1.9.389~392), body 17줄 전체 캡처.
37
+
3
38
  ## 1.9.392 — 2026-06-06 — UR-0025 큰 핸들러 모듈화 4번째: doctor/which → lib/diagnostics.js (DI)
4
39
 
5
40
  **🧩 네 번째 핸들러 모듈 — 진단 명령(doctor/which)을 lib/diagnostics.js 로 분리.**
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
- [![npm](https://img.shields.io/badge/npm-leerness-blue)](https://www.npmjs.com/package/leerness) [![version](https://img.shields.io/badge/version-1.9.392-green)]() [![tests](https://img.shields.io/badge/e2e-332%2F332-success)]() [![selftest](https://img.shields.io/badge/selftest-138-success)]() [![mcp](https://img.shields.io/badge/MCP--tools-85-brightgreen)]() [![providers](https://img.shields.io/badge/AI_providers-10-brightgreen)]() [![license](https://img.shields.io/badge/license-MIT-lightgrey)]()
6
+ [![npm](https://img.shields.io/badge/npm-leerness-blue)](https://www.npmjs.com/package/leerness) [![version](https://img.shields.io/badge/version-1.9.394-green)]() [![tests](https://img.shields.io/badge/e2e-333%2F333-success)]() [![selftest](https://img.shields.io/badge/selftest-140-success)]() [![mcp](https://img.shields.io/badge/MCP--tools-85-brightgreen)]() [![providers](https://img.shields.io/badge/AI_providers-10-brightgreen)]() [![license](https://img.shields.io/badge/license-MIT-lightgrey)]()
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.392 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
474
+ 이 프로젝트는 Leerness v1.9.394 하네스를 사용합니다. 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.392는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **85개 도구**를 노출:
528
+ Leerness v1.9.394는 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.392는 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.392)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
549
+ 현재 누적: **70 라운드 (1.9.40 → 1.9.394)** · 매 라운드 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.392: 2026-06-06
587
+ Last synced by Leerness v1.9.394: 2026-06-06
588
588
  <!-- leerness:project-readme:end -->
589
589
 
package/bin/harness.js CHANGED
@@ -24,13 +24,14 @@ const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _merg
24
24
  _decisionsFromMd, _renderDecisionsMd, _renderLessonsMd,
25
25
  _withBuiltinSource, _esc, _roadmapTokenStyles, _parseSkillMd,
26
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
+ _featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock, _featureImpactBfs,
28
+ _parseChangelogBetween } = require('../lib/pure-utils'); // 1.9.318~393 (UR-0025/0053/0075/0086/0087): 순수 유틸 모듈 분리
28
29
  // 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
29
30
  const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
30
31
  // 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
31
32
  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 포함)
32
33
 
33
- const VERSION = '1.9.392';
34
+ const VERSION = '1.9.394';
34
35
 
35
36
  // 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
36
37
  // 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
@@ -2996,6 +2997,8 @@ function _selfTestCases() {
2996
2997
  { 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
2998
  { 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; } },
2998
2999
  { name: 'UR-0025 큰핸들러 모듈화: doctor/which → lib/diagnostics.js + DI 위임 + 동작 (1.9.392)', run: () => { const m = require('../lib/diagnostics'); const expOk = typeof m.doctorCmd === 'function' && typeof m.whichCmd === 'function'; const src = read(__filename); const delegated = src.includes("require('../lib/diagnostics')") && src.includes('_diag.doctorCmd(opts,') && src.includes('_diag.whichCmd('); const diagSrc = read(path.join(path.dirname(__filename), '..', 'lib', 'diagnostics.js')); const movedToLib = diagSrc.includes('leerness doctor') && diagSrc.includes('_selfTestCases'); let behavOk = false; const _w = process.stdout.write; const savedExit = process.exitCode; try { process.stdout.write = () => true; const rep = m.doctorCmd({ json: true }, { VERSION, _selfTestCases: () => [], _detectShellCtx: () => ({ shell: 'test', psVersion: null }), _mcpToolCount: () => 7, has: () => true, harnessPath: 'h.js' }); behavOk = !!rep && rep.version === VERSION && rep.selftest.total === 0 && rep.healthy === true && rep.mcpTools === 7; } catch {} finally { process.stdout.write = _w; process.exitCode = savedExit; } return expOk && delegated && movedToLib && behavOk; } },
3000
+ { name: 'UR-0025/whats-new BUG-fix: _parseChangelogBetween pure 추출 + "## X — DATE — title" 헤더 파싱 (1.9.393)', run: () => { const m = require('../lib/pure-utils'); if (m._parseChangelogBetween !== _parseChangelogBetween) return false; const cl = '## 1.9.393 — 2026-06-06 — Title\n- `leerness foo`\n- `--flagx`\n- `.harness/x.md`\n\n## 1.9.392 — 2026-06-05 — Y\n- y\n\n## 1.9.391 — 2026-06-04 — Z\n- z\n'; const r = m._parseChangelogBetween(cl, '1.9.391', '1.9.393'); const rangeOk = r.length === 2 && r[0].version === '1.9.393' && r[1].version === '1.9.392'; const extractOk = r[0].newCommands.includes('foo') && r[0].newFlags.includes('--flagx') && r[0].newFiles.includes('.harness/x.md'); const titlelessOk = m._parseChangelogBetween('## 1.9.50\n- a\n## 1.9.49\n- b\n', '1.9.49', '1.9.50').length === 1; const src = read(__filename); const moved = src.includes("require('../lib/pure-utils')") && !/function _parseChangelogBetween\(changelogText/.test(src); return rangeOk && extractOk && titlelessOk && moved; } },
3001
+ { name: 'UR-0025 whats-new 완결: whatsNewCmd → lib/diagnostics.js + DI 위임 + 동작 (1.9.394)', run: () => { const m = require('../lib/diagnostics'); const expOk = typeof m.whatsNewCmd === 'function'; const src = read(__filename); const delegated = src.includes('_diag.whatsNewCmd(root,'); const diagSrc = read(path.join(path.dirname(__filename), '..', 'lib', 'diagnostics.js')); const movedToLib = diagSrc.includes('leerness whats-new') && diagSrc.includes('_parseChangelogBetween'); let behavOk = false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_wn_')); 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, 'CHANGELOG.md'), '## 1.9.50 — 2026-06-06 — A\n- `leerness x`\n\n## 1.9.49 — 2026-06-05 — B\n- old\n'); process.argv = ['node', 'h', 'whats-new', tmp, '--from', '1.9.49', '--to', '1.9.50', '--json']; process.stdout.write = s => { out += s; return true; }; whatsNewCmd(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.from === '1.9.49' && j.to === '1.9.50' && Array.isArray(j.versions) && j.versions.length === 1 && j.versions[0].version === '1.9.50'; } catch {} return expOk && delegated && movedToLib && behavOk; } },
2999
3002
  { name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
3000
3003
  ];
3001
3004
  }
@@ -15377,45 +15380,6 @@ function _bumpMcpUsage(root, toolName) {
15377
15380
 
15378
15381
  // 1.9.41: CHANGELOG.md를 파싱하여 from → to 사이 버전 차분 추출
15379
15382
  // 반환: [{ version, date, body, newCommands, newFlags, newFiles }]
15380
- function _parseChangelogBetween(changelogText, fromV, toV) {
15381
- // ## 1.9.X — YYYY-MM-DD 헤더 사이의 텍스트 추출
15382
- const sections = [];
15383
- const re = /^## (\d+\.\d+\.\d+)(?:\s+—\s+(\d{4}-\d{2}-\d{2}))?\s*\n([\s\S]*?)(?=^## \d+\.\d+\.\d+|$)/gm;
15384
- let m;
15385
- while ((m = re.exec(changelogText)) !== null) {
15386
- sections.push({ version: m[1], date: m[2] || null, body: m[3].trim() });
15387
- }
15388
- // from < V <= to 만 (fromV 자체는 이미 적용된 버전이므로 제외)
15389
- const ranged = sections.filter(s => {
15390
- const cmp = (v1, v2) => {
15391
- const a = v1.split('.').map(Number), b = v2.split('.').map(Number);
15392
- for (let i = 0; i < 3; i++) { if (a[i] !== b[i]) return a[i] - b[i]; }
15393
- return 0;
15394
- };
15395
- return cmp(s.version, fromV) > 0 && cmp(s.version, toV) <= 0;
15396
- });
15397
- // 각 섹션에서 신규 명령/플래그/파일 추출
15398
- for (const s of ranged) {
15399
- s.newCommands = [];
15400
- s.newFlags = [];
15401
- s.newFiles = [];
15402
- // `leerness X [...]` 또는 backtick에 싸인 leerness 명령
15403
- for (const cm of s.body.matchAll(/`leerness\s+([a-z][\w-]*(?:\s+[a-z][\w-]*)?)/g)) {
15404
- const cmd = cm[1].trim();
15405
- if (!s.newCommands.includes(cmd)) s.newCommands.push(cmd);
15406
- }
15407
- // `--xxx` 플래그
15408
- for (const fm of s.body.matchAll(/`(--[a-z][\w-]*)`/g)) {
15409
- if (!s.newFlags.includes(fm[1])) s.newFlags.push(fm[1]);
15410
- }
15411
- // .harness/X.md 같은 신규 파일
15412
- for (const ff of s.body.matchAll(/`(\.harness\/[\w./-]+\.(?:md|json|jsonl))`/g)) {
15413
- if (!s.newFiles.includes(ff[1])) s.newFiles.push(ff[1]);
15414
- }
15415
- }
15416
- return ranged;
15417
- }
15418
-
15419
15383
  // 1.9.41: leerness whats-new [--from V] — 현재 워크스페이스 버전 → leerness latest 차분
15420
15384
  // 1.9.48: cross-platform archive 생성 — tar → PowerShell Compress-Archive → 7z 순 fallback
15421
15385
  // outPath의 확장자(tgz/zip)에 따라 tar 또는 zip. tar 실패 시 .zip으로 자동 전환.
@@ -16453,64 +16417,8 @@ function mcpServeCmd(root) {
16453
16417
  process.on('SIGTERM', () => process.exit(0));
16454
16418
  }
16455
16419
 
16456
- function whatsNewCmd(root) {
16457
- root = absRoot(root || process.cwd());
16458
- const fromV = arg('--from', null) || (function () {
16459
- const hv = path.join(root, '.harness', 'HARNESS_VERSION');
16460
- if (exists(hv)) { try { return parseHarnessVersion(read(hv)).base || parseHarnessVersion(read(hv)).plus; } catch { return null; } }
16461
- return null;
16462
- })();
16463
- const toV = arg('--to', null) || VERSION;
16464
- if (!fromV) {
16465
- fail('현재 버전을 파악할 수 없습니다. --from <version> 명시');
16466
- return process.exit(1);
16467
- }
16468
- // CHANGELOG.md — 우선 root, 없으면 leerness-pkg 자체
16469
- let changelogPath = path.join(root, 'CHANGELOG.md');
16470
- if (!exists(changelogPath)) changelogPath = path.join(__dirname, '..', 'CHANGELOG.md');
16471
- if (!exists(changelogPath)) {
16472
- fail('CHANGELOG.md 없음');
16473
- return process.exit(1);
16474
- }
16475
- const diff = _parseChangelogBetween(read(changelogPath), fromV, toV);
16476
- if (has('--json')) { log(JSON.stringify({ from: fromV, to: toV, versions: diff }, null, 2)); return; }
16477
- if (!diff.length) {
16478
- log(`# leerness whats-new (1.9.41)`);
16479
- log(`현재 ${fromV} ↔ 대상 ${toV}: 새 항목 없음 (또는 CHANGELOG에 기록 안 됨)`);
16480
- return;
16481
- }
16482
- log(`# leerness whats-new (1.9.41)`);
16483
- log(`현재 워크스페이스 버전: ${fromV} → 대상: ${toV}`);
16484
- log(`범위: ${diff.length}개 버전 (${diff[0].version} → ${diff[diff.length - 1].version})`);
16485
- log('');
16486
- // AI 가독 요약 — 각 버전당 한 줄 + 신규 명령/플래그/파일
16487
- log(`## 🆕 신규 명령·플래그·파일 (AI 에이전트는 다음 명령을 우선 시도)`);
16488
- const allCommands = new Set();
16489
- const allFlags = new Set();
16490
- const allFiles = new Set();
16491
- for (const v of diff) {
16492
- v.newCommands.forEach(c => allCommands.add(c));
16493
- v.newFlags.forEach(f => allFlags.add(f));
16494
- v.newFiles.forEach(f => allFiles.add(f));
16495
- }
16496
- if (allCommands.size) log(` 📌 신규 명령: ${[...allCommands].join(', ')}`);
16497
- if (allFlags.size) log(` 🚩 신규 플래그: ${[...allFlags].join(', ')}`);
16498
- if (allFiles.size) log(` 📄 신규 파일: ${[...allFiles].join(', ')}`);
16499
- log('');
16500
- log(`## 📜 버전별 헤드라인`);
16501
- for (const v of diff) {
16502
- // body 첫 줄(또는 strong header) 추출
16503
- const firstLine = (v.body.match(/^\*\*([^*]+)\*\*/) || [])[1]
16504
- || (v.body.split('\n').find(l => l.trim() && !l.startsWith('##')) || '').trim().slice(0, 120);
16505
- log(` • ${v.version}${v.date ? ` (${v.date})` : ''} — ${firstLine || '(no headline)'}`);
16506
- }
16507
- log('');
16508
- log(`## 💡 권장 행동`);
16509
- log(` 1. 위 신규 명령들을 시도해 보세요 (예: \`leerness <명령> --help\`)`);
16510
- log(` 2. 신규 파일들을 읽어 보세요 (예: \`cat .harness/session-workflow.md\`)`);
16511
- log(` 3. AGENTS.md/CLAUDE.md 재독 — migrate가 인스트럭션을 업데이트했을 수 있음`);
16512
- log(` 4. 상세: \`cat CHANGELOG.md\` 또는 \`leerness whats-new --json\``);
16513
- }
16420
+ // 1.9.394 (UR-0025): whatsNewCmd 를 lib/diagnostics.js 로 분리 (whats-new 서브시스템 완결 — 파서는 1.9.393 에 pure-utils 로). deps 위임.
16421
+ function whatsNewCmd(root) { return _diag.whatsNewCmd(root, { VERSION, arg, has }); }
16514
16422
 
16515
16423
  // 1.9.71: .env / .env.example 자동 동기화 — 누락 키 감지 + (옵션) 자동 추가
16516
16424
  // 보안 정책: .env의 실제 값은 절대 옮기지 않음. .env.example엔 키만 (빈 값).
@@ -5,7 +5,9 @@
5
5
  // _selfTestCases 의 각 case.run 클로저는 harness 스코프를 유지하므로 함수 참조 주입만으로 정상 동작.
6
6
  'use strict';
7
7
  const cp = require('child_process');
8
- const { log } = require('./io');
8
+ const path = require('path');
9
+ const { log, fail, absRoot, exists, read } = require('./io');
10
+ const { parseHarnessVersion, _parseChangelogBetween } = require('./pure-utils');
9
11
 
10
12
  function doctorCmd(opts = {}, deps = {}) {
11
13
  const { VERSION, _selfTestCases, _detectShellCtx, _mcpToolCount, has, harnessPath } = deps;
@@ -126,4 +128,66 @@ function whichCmd(deps = {}) {
126
128
  log(` 3) npm cache clean --force # npx 캐시 강제 비우기 (의심 시)`);
127
129
  }
128
130
 
129
- module.exports = { doctorCmd, whichCmd };
131
+ // 1.9.394 (UR-0025): whats-new 현재 워크스페이스 버전 → 도구 버전 CHANGELOG 차분(신규 명령/플래그/파일 요약). introspection 핸들러.
132
+ // 순수 파서 _parseChangelogBetween(pure-utils) 사용. deps: VERSION/arg/has. CHANGELOG 경로는 root 우선, 없으면 pkg 자체(lib/../).
133
+ function whatsNewCmd(root, deps = {}) {
134
+ const { VERSION, arg, has } = deps;
135
+ root = absRoot(root || process.cwd());
136
+ const fromV = arg('--from', null) || (function () {
137
+ const hv = path.join(root, '.harness', 'HARNESS_VERSION');
138
+ if (exists(hv)) { try { return parseHarnessVersion(read(hv)).base || parseHarnessVersion(read(hv)).plus; } catch { return null; } }
139
+ return null;
140
+ })();
141
+ const toV = arg('--to', null) || VERSION;
142
+ if (!fromV) {
143
+ fail('현재 버전을 파악할 수 없습니다. --from <version> 명시');
144
+ return process.exit(1);
145
+ }
146
+ // CHANGELOG.md — 우선 root, 없으면 leerness-pkg 자체 (lib/../CHANGELOG.md = pkg 루트)
147
+ let changelogPath = path.join(root, 'CHANGELOG.md');
148
+ if (!exists(changelogPath)) changelogPath = path.join(__dirname, '..', 'CHANGELOG.md');
149
+ if (!exists(changelogPath)) {
150
+ fail('CHANGELOG.md 없음');
151
+ return process.exit(1);
152
+ }
153
+ const diff = _parseChangelogBetween(read(changelogPath), fromV, toV);
154
+ if (has('--json')) { log(JSON.stringify({ from: fromV, to: toV, versions: diff }, null, 2)); return; }
155
+ if (!diff.length) {
156
+ log(`# leerness whats-new (1.9.41)`);
157
+ log(`현재 ${fromV} ↔ 대상 ${toV}: 새 항목 없음 (또는 CHANGELOG에 기록 안 됨)`);
158
+ return;
159
+ }
160
+ log(`# leerness whats-new (1.9.41)`);
161
+ log(`현재 워크스페이스 버전: ${fromV} → 대상: ${toV}`);
162
+ log(`범위: ${diff.length}개 버전 (${diff[0].version} → ${diff[diff.length - 1].version})`);
163
+ log('');
164
+ // AI 가독 요약 — 각 버전당 한 줄 + 신규 명령/플래그/파일
165
+ log(`## 🆕 신규 명령·플래그·파일 (AI 에이전트는 다음 명령을 우선 시도)`);
166
+ const allCommands = new Set();
167
+ const allFlags = new Set();
168
+ const allFiles = new Set();
169
+ for (const v of diff) {
170
+ v.newCommands.forEach(c => allCommands.add(c));
171
+ v.newFlags.forEach(f => allFlags.add(f));
172
+ v.newFiles.forEach(f => allFiles.add(f));
173
+ }
174
+ if (allCommands.size) log(` 📌 신규 명령: ${[...allCommands].join(', ')}`);
175
+ if (allFlags.size) log(` 🚩 신규 플래그: ${[...allFlags].join(', ')}`);
176
+ if (allFiles.size) log(` 📄 신규 파일: ${[...allFiles].join(', ')}`);
177
+ log('');
178
+ log(`## 📜 버전별 헤드라인`);
179
+ for (const v of diff) {
180
+ // body 첫 줄(또는 strong header) 추출
181
+ const firstLine = (v.body.match(/^\*\*([^*]+)\*\*/) || [])[1]
182
+ || (v.body.split('\n').find(l => l.trim() && !l.startsWith('##')) || '').trim().slice(0, 120);
183
+ log(` • ${v.version}${v.date ? ` (${v.date})` : ''} — ${firstLine || '(no headline)'}`);
184
+ }
185
+ log('');
186
+ log(`## 💡 권장 행동`);
187
+ log(` 1. 위 신규 명령들을 시도해 보세요 (예: \`leerness <명령> --help\`)`);
188
+ log(` 2. 신규 파일들을 읽어 보세요 (예: \`cat .harness/session-workflow.md\`)`);
189
+ log(` 3. AGENTS.md/CLAUDE.md 재독 — migrate가 인스트럭션을 업데이트했을 수 있음`);
190
+ log(` 4. 상세: \`cat CHANGELOG.md\` 또는 \`leerness whats-new --json\``);
191
+ }
192
+
193
+ module.exports = { doctorCmd, whichCmd, whatsNewCmd };
package/lib/pure-utils.js CHANGED
@@ -933,7 +933,9 @@ module.exports = {
933
933
  // 1.9.390 (UR-0025): feature-graph 순수 코어 (템플릿/파서/ID/블록)
934
934
  _featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock,
935
935
  // 1.9.391 (UR-0025): feature 영향 BFS (순수, 공유)
936
- _featureImpactBfs
936
+ _featureImpactBfs,
937
+ // 1.9.393 (UR-0025): CHANGELOG 버전 구간 차분 파서 (순수, 공유)
938
+ _parseChangelogBetween
937
939
  };
938
940
 
939
941
  // 1.9.355 (UR-0075 Phase A): AI 에이전트용 크로스버전 마이그레이션 안전 워크플로 가이드 (순수 텍스트). 임시설치 + --path + 백업 + diff 검증.
@@ -1120,3 +1122,48 @@ function _featureImpactBfs(nodes, startId) {
1120
1122
  }
1121
1123
  return result;
1122
1124
  }
1125
+ // 1.9.393 (UR-0025): CHANGELOG 버전 구간 차분 파서 — from < V <= to 섹션 + 신규 명령/플래그/파일 추출. 순수. harness(update/whats-new) 공유.
1126
+ // BUG-fix(1.9.393): (1) 헤더 꼬리가 '## X — DATE — title' 의 ' — title' 를 소비 못 해 0건 반환 → 헤더에 '[^\n]*' 허용.
1127
+ // (2) 기존 본문 캡처 '([\s\S]*?)(?=^##…|$)' 가 /m 모드 '$'(줄 끝) 때문에 본문을 첫 줄로 절단 → _parseFeatureGraph 식 '위치 기반 분할'로 교체.
1128
+ // '## X'(제목 없음) / '## X — DATE' / '## X — DATE — title' 모두 매칭, 본문은 다음 헤더(또는 끝)까지 전체 캡처.
1129
+ function _parseChangelogBetween(changelogText, fromV, toV) {
1130
+ const text = changelogText || '';
1131
+ const headerRe = /^## (\d+\.\d+\.\d+)(?:\s+—\s+(\d{4}-\d{2}-\d{2}))?[^\n]*$/gm;
1132
+ const positions = [];
1133
+ let hm;
1134
+ while ((hm = headerRe.exec(text)) !== null) positions.push({ version: hm[1], date: hm[2] || null, start: hm.index, bodyStart: hm.index + hm[0].length });
1135
+ const sections = [];
1136
+ for (let i = 0; i < positions.length; i++) {
1137
+ const end = i + 1 < positions.length ? positions[i + 1].start : text.length;
1138
+ sections.push({ version: positions[i].version, date: positions[i].date, body: text.slice(positions[i].bodyStart, end).trim() });
1139
+ }
1140
+ // from < V <= to 만 (fromV 자체는 이미 적용된 버전이므로 제외)
1141
+ const ranged = sections.filter(s => {
1142
+ const cmp = (v1, v2) => {
1143
+ const a = v1.split('.').map(Number), b = v2.split('.').map(Number);
1144
+ for (let i = 0; i < 3; i++) { if (a[i] !== b[i]) return a[i] - b[i]; }
1145
+ return 0;
1146
+ };
1147
+ return cmp(s.version, fromV) > 0 && cmp(s.version, toV) <= 0;
1148
+ });
1149
+ // 각 섹션에서 신규 명령/플래그/파일 추출
1150
+ for (const s of ranged) {
1151
+ s.newCommands = [];
1152
+ s.newFlags = [];
1153
+ s.newFiles = [];
1154
+ // `leerness X [...]` 또는 backtick에 싸인 leerness 명령
1155
+ for (const cm of s.body.matchAll(/`leerness\s+([a-z][\w-]*(?:\s+[a-z][\w-]*)?)/g)) {
1156
+ const cmd = cm[1].trim();
1157
+ if (!s.newCommands.includes(cmd)) s.newCommands.push(cmd);
1158
+ }
1159
+ // `--xxx` 플래그
1160
+ for (const fm of s.body.matchAll(/`(--[a-z][\w-]*)`/g)) {
1161
+ if (!s.newFlags.includes(fm[1])) s.newFlags.push(fm[1]);
1162
+ }
1163
+ // .harness/X.md 같은 신규 파일
1164
+ for (const ff of s.body.matchAll(/`(\.harness\/[\w./-]+\.(?:md|json|jsonl))`/g)) {
1165
+ if (!s.newFiles.includes(ff[1])) s.newFiles.push(ff[1]);
1166
+ }
1167
+ }
1168
+ return ranged;
1169
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leerness",
3
- "version": "1.9.392",
3
+ "version": "1.9.394",
4
4
  "description": "Leerness: 비파괴 마이그레이션, 자동 버전 감지·업데이트, 계획/진행/핸드오프 자동화, 게으름·시크릿·인코딩 자동 가드, Claude Code 슬래시 통합을 갖춘 한국어 우선 AI 개발 하네스.",
5
5
  "keywords": [
6
6
  "leerness",
package/scripts/e2e.js CHANGED
@@ -5448,5 +5448,25 @@ total++;
5448
5448
  if (!ok) failed++;
5449
5449
  }
5450
5450
 
5451
+ // 1.9.393 회귀 (UR-0025 + whats-new BUG-fix): _parseChangelogBetween 가 "## X — DATE — title" 헤더를 파싱 (종전 0건 반환 버그)
5452
+ total++;
5453
+ {
5454
+ let ok = false;
5455
+ try {
5456
+ const pkgRoot = path.resolve(__dirname, '..');
5457
+ const r = cp.spawnSync(process.execPath, [CLI, 'whats-new', pkgRoot, '--from', '1.9.388', '--json'], { encoding: 'utf8', timeout: 15000 });
5458
+ const j = JSON.parse(r.stdout);
5459
+ // 실제 CHANGELOG(## X — DATE — title 형식)에서 1.9.388 초과 버전이 1건 이상 파싱돼야 함
5460
+ const versOk = Array.isArray(j.versions) && j.versions.length >= 1 && j.versions.every(v => /^\d+\.\d+\.\d+$/.test(v.version));
5461
+ // 순수 함수 직접: 제목 있는 헤더 + 제목 없는 헤더 모두 매칭
5462
+ const pu = require(path.resolve(pkgRoot, 'lib', 'pure-utils'));
5463
+ const titled = pu._parseChangelogBetween('## 1.9.20 — 2026-01-01 — T\n- a\n## 1.9.19 — 2026-01-01 — U\n- b\n', '1.9.19', '1.9.20').length === 1;
5464
+ const titleless = pu._parseChangelogBetween('## 1.9.20\n- a\n## 1.9.19\n- b\n', '1.9.19', '1.9.20').length === 1;
5465
+ ok = versOk && titled && titleless;
5466
+ } catch {}
5467
+ console.log(ok ? '✓ B(1.9.393) whats-new BUG-fix: "## X — DATE — title" 헤더 파싱 (_parseChangelogBetween pure 추출, UR-0025)' : '✗ whats-new 헤더 파싱 실패');
5468
+ if (!ok) failed++;
5469
+ }
5470
+
5451
5471
  console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
5452
5472
  if (failed > 0) process.exit(1);