leerness 1.9.365 → 1.9.367
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 +48 -0
- package/README.md +5 -5
- package/bin/harness.js +9 -27
- package/lib/pure-utils.js +21 -0
- package/package.json +1 -1
- package/scripts/e2e.js +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.367 — 2026-06-06 — UR-0025 모듈화: env/line 머지 순수 코어 분리
|
|
4
|
+
|
|
5
|
+
**🧩 안정화 마일스톤 이후 모듈화(UR-0025) 재개 — `.env`/라인 머지 순수 코어를 lib/pure-utils 로 분리, harness 는 얇은 I/O 래퍼.**
|
|
6
|
+
|
|
7
|
+
### 배경
|
|
8
|
+
외부 리뷰가 지목한 코드 품질(5.8) 개선 방향 = 21k줄 단일 harness.js 모듈화. 비파괴 추출 패턴(데이터→catalogs, 순수 로직→pure-utils, harness 얇은 래퍼) 지속.
|
|
9
|
+
|
|
10
|
+
### 구현
|
|
11
|
+
1. **`_mergeLines(currentText, lines)`**(pure-utils): 기존 텍스트에 없는 라인만 append (substring 중복 방지).
|
|
12
|
+
2. **`_mergeEnvLines(currentText, lines)`**(pure-utils): `.env` key-aware 머지 — 기존 KEY 값 보존(덮어쓰기 X), 신규 KEY/주석만 append. 사용자가 편집한 토큰을 절대 덮어쓰지 않는 핵심 로직.
|
|
13
|
+
3. **harness `mergeLinesFile`/`mergeEnvFile`**: 순수 코어 + `read`/`writeUtf8` 만 남긴 얇은 I/O 래퍼.
|
|
14
|
+
|
|
15
|
+
### 검증 (회귀 0)
|
|
16
|
+
- **selftest 112→113 PASS** (행위: `_mergeLines('a\n',['a','b'])==='a\nb\n'` / `_mergeEnvLines('FOO=keep\n',['FOO=new'])==='FOO=keep\n'`(보존) / 신규 KEY append + 모듈 reference equality).
|
|
17
|
+
- **E2E 312→313 PASS** (행위: init → `.env` 토큰 편집 → migrate → 사용자 값 key-aware 보존).
|
|
18
|
+
- 실측: init→토큰편집→migrate→`LEERNESS_NPM_TOKEN` 사용자 값 보존.
|
|
19
|
+
|
|
20
|
+
## 1.9.366 — 2026-06-06 — 안정화⑥(완결) 외부리뷰 CV-5: selftest 행위화 + 외부리뷰 7 finding 전량 해소 🎉
|
|
21
|
+
|
|
22
|
+
**🛠 외부 멀티모델 리뷰 안정화 시리즈 최종 6탄 — selftest 동어반복 source-grep 핵심 케이스를 행위 검증으로 전환. CV-1~7 + 4번째 외부평가 전량 해소로 안정화 마일스톤.**
|
|
23
|
+
|
|
24
|
+
### 배경 — 외부 리뷰 CV-5 (3개 모델 합의)
|
|
25
|
+
selftest ~13/106 케이스가 소스 문자열 grep(`src.includes`)이라 동작이 깨져도 통과(EINVAL 버그가 selftest 106/106 통과한 근본 원인). 권고: 구조 무결성(selftest) vs 행위(e2e) 분리 + 핵심 source-grep 을 행위 검증으로.
|
|
26
|
+
|
|
27
|
+
### 구현
|
|
28
|
+
1. **핵심 동어반복 케이스 행위 전환**:
|
|
29
|
+
- `writeUtf8`: 소스 grep → **실제 호출**(중첩 dir 에 한글 UTF-8 쓰기 → round-trip 내용 일치 + `.tmp-` 잔존 0 검증).
|
|
30
|
+
- `exit code(fail)`: 소스 grep → **실제 호출**(stdout 억제 + exitCode save/restore 로 `fail()` → `process.exitCode===1` 단언).
|
|
31
|
+
2. **구조 vs 행위 분리 원칙 확립**: 구조 케이스(dispatch 와이어/등록 존재 — 빠른 sync)는 selftest 유지, 행위 케이스(로직 출력 정확성)는 함수 직접 호출. **안정화 시리즈(1.9.360~366) 신규 케이스는 전부 행위 기반**(argv 주입/prune/placeholder/secret-like/quiet 등).
|
|
32
|
+
3. **selftest 무결성 e2e 가드**: 설치 패키지 관점 `selftest --json` 전부 통과(pass===total, fail===0) 단언.
|
|
33
|
+
|
|
34
|
+
### 검증 (회귀 0)
|
|
35
|
+
- **selftest 112/112 PASS**(2건 행위 전환, 카운트 유지). **E2E 311→312 PASS**(selftest --json 무결성 가드).
|
|
36
|
+
|
|
37
|
+
### 🎉 외부 리뷰 안정화 마일스톤
|
|
38
|
+
3개 모델 클린룸 리뷰(1.9.359) 교차검증 7 finding + 4번째 외부평가(web) 9.3 **전량 해소**:
|
|
39
|
+
| finding | 버전 |
|
|
40
|
+
|---|---|
|
|
41
|
+
| CV-2 EINVAL | 1.9.360 |
|
|
42
|
+
| CV-1 --path · CV-3 audit | 1.9.361 |
|
|
43
|
+
| CV-4 archive retention | 1.9.362 |
|
|
44
|
+
| CV-7 commands/help drift | 1.9.363 |
|
|
45
|
+
| 4th평가 9.3 auto-update 비침투 | 1.9.364 |
|
|
46
|
+
| CV-6 스캐너 FP/FN | 1.9.365 |
|
|
47
|
+
| CV-5 selftest 행위화 | 1.9.366 |
|
|
48
|
+
|
|
49
|
+
다음: 모듈화(UR-0025) → 에이전트 팀(UR-0073) → 릴리스 케이던스(UR-0074).
|
|
50
|
+
|
|
3
51
|
## 1.9.365 — 2026-06-06 — 안정화⑤ 외부리뷰 CV-6: 시크릿 스캐너 FP/FN 정밀도 (UR-0081)
|
|
4
52
|
|
|
5
53
|
**🛠 외부 멀티모델 리뷰 안정화 시리즈 5탄 — 시크릿 스캐너 오탐(placeholder/자기 .env) 억제 + 미탐(unquoted) 보강.**
|
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.367 하네스를 사용합니다. 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.367는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **83개 도구**를 노출:
|
|
529
529
|
|
|
530
530
|
```jsonc
|
|
531
531
|
// 카테고리별
|
|
@@ -546,7 +546,7 @@ Leerness v1.9.365는 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.367)** · 매 라운드 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.367: 2026-06-06
|
|
588
588
|
<!-- leerness:project-readme:end -->
|
|
589
589
|
|
package/bin/harness.js
CHANGED
|
@@ -7,7 +7,7 @@ const cp = require('child_process');
|
|
|
7
7
|
const os = require('os'); // 1.9.178: _publishToNpm 에서 os.tmpdir() 사용 (전역 import)
|
|
8
8
|
const readline = require('readline');
|
|
9
9
|
// 1.9.274 (UR-0025 1단계): 순수 유틸 함수 모듈 분리 (require-based, 비파괴). selftest 7종이 동작 검증.
|
|
10
|
-
const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, compareVer, parseHarnessVersion, _classifyCJK, _riskLabel, _detectSystemLang, _parseSlashFromHelp,
|
|
10
|
+
const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _mergeEnvLines, compareVer, parseHarnessVersion, _classifyCJK, _riskLabel, _detectSystemLang, _parseSlashFromHelp,
|
|
11
11
|
PERMISSION_TIERS, _tierRank, _requiredTier, _policyAllows, _resolveNpmTag, _mcpJsonContent, _newRunRecord,
|
|
12
12
|
_htmlToText, _extractTitle, _extractLinks,
|
|
13
13
|
_countDatedBlocks, _extractDecisionBlocks, _classifyIntent,
|
|
@@ -28,7 +28,7 @@ const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInG
|
|
|
28
28
|
// 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
|
|
29
29
|
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, SKILL_CATALOG_PRESETS } = require('../lib/catalogs'); // 1.9.344 (UR-0025): SKILL_CATALOG_PRESETS 분리
|
|
30
30
|
|
|
31
|
-
const VERSION = '1.9.
|
|
31
|
+
const VERSION = '1.9.367';
|
|
32
32
|
|
|
33
33
|
// 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
|
|
34
34
|
// 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
|
|
@@ -768,36 +768,17 @@ function writeIfSafe(root, file, content, opts = {}) {
|
|
|
768
768
|
return { action: already ? 'updated' : 'created', file };
|
|
769
769
|
}
|
|
770
770
|
|
|
771
|
+
// 1.9.367 (UR-0025): 순수 코어 _mergeLines (lib/pure-utils) + 얇은 I/O 래퍼.
|
|
771
772
|
function mergeLinesFile(p, lines) {
|
|
772
773
|
const current = exists(p) ? read(p) : '';
|
|
773
|
-
|
|
774
|
-
for (const line of lines) if (!next.includes(line)) next += (next.endsWith('\n') || !next ? '' : '\n') + line + '\n';
|
|
775
|
-
writeUtf8(p, next);
|
|
774
|
+
writeUtf8(p, _mergeLines(current, lines));
|
|
776
775
|
}
|
|
777
776
|
|
|
778
|
-
// 1.9.153: env 파일 전용 key-aware merge —
|
|
777
|
+
// 1.9.153/1.9.367: env 파일 전용 key-aware merge — 기존 값 보존(덮어쓰기 X). 순수 코어 _mergeEnvLines (lib/pure-utils) + 얇은 I/O 래퍼.
|
|
779
778
|
// 사용자가 .env 의 LEERNESS_NPM_TOKEN=abc123 처럼 직접 편집한 값을 절대 덮어쓰지 않음.
|
|
780
|
-
// 주석 / 빈 줄은 substring includes 로 중복 방지 (mergeLinesFile 와 동일).
|
|
781
779
|
function mergeEnvFile(p, lines) {
|
|
782
780
|
const current = exists(p) ? read(p) : '';
|
|
783
|
-
|
|
784
|
-
for (const ln of current.split(/\r?\n/)) {
|
|
785
|
-
const m = ln.match(/^\s*([A-Z][A-Z0-9_]+)\s*=/);
|
|
786
|
-
if (m) existingKeys.add(m[1]);
|
|
787
|
-
}
|
|
788
|
-
let next = current;
|
|
789
|
-
for (const line of lines) {
|
|
790
|
-
const km = line.match(/^\s*([A-Z][A-Z0-9_]+)\s*=/);
|
|
791
|
-
if (km) {
|
|
792
|
-
if (existingKeys.has(km[1])) continue; // 기존 키 값 보존 (덮어쓰기 X)
|
|
793
|
-
next += (next.endsWith('\n') || !next ? '' : '\n') + line + '\n';
|
|
794
|
-
existingKeys.add(km[1]);
|
|
795
|
-
} else {
|
|
796
|
-
// 주석 또는 빈 줄 — substring 미포함 시만 append
|
|
797
|
-
if (!next.includes(line)) next += (next.endsWith('\n') || !next ? '' : '\n') + line + '\n';
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
writeUtf8(p, next);
|
|
781
|
+
writeUtf8(p, _mergeEnvLines(current, lines));
|
|
801
782
|
}
|
|
802
783
|
|
|
803
784
|
function writeMigrationReport(root, backup, actions, opts = {}) {
|
|
@@ -3032,7 +3013,7 @@ function _selfTestCases() {
|
|
|
3032
3013
|
{ name: 'lib/catalogs: CAPABILITY/ADAPTERS/REUSE 모듈 단일출처 분리 (UR-0025 1.9.295)', run: () => { const m = require('../lib/catalogs'); return m.CAPABILITY_SURFACE === CAPABILITY_SURFACE && m.ADAPTERS === ADAPTERS && m.REUSE_CATEGORIES === REUSE_CATEGORIES && m.REUSE_CHECKLIST === REUSE_CHECKLIST && m.POWERFUL_COMMANDS === POWERFUL_COMMANDS && Object.keys(m.CAPABILITY_SURFACE).length === 6 && !/const CAPABILITY_SURFACE = \{/.test(read(__filename)); } },
|
|
3033
3014
|
{ name: 'about: 정체성 verb(AI 운영 레이어) + MCP leerness_about 등록 (UR-0030 1.9.296)', run: () => { const id = _leernessIdentity(); const src = read(__filename); return typeof aboutCmd === 'function' && /운영 레이어/.test(id.identity) && id.layers.length === 5 && id.surface.mcpTools >= 81 && require('../lib/mcp-tools').some(t => t.name === 'leerness_about') && /case 'leerness_about':/.test(src) && /cmd === 'about' \|\| cmd === 'identity'/.test(src); } },
|
|
3034
3015
|
{ name: 'lib/mcp-tools: MCP 도구 정의 모듈 단일출처 (_mcpToolCount=모듈 length, Codex #5 영구해소) (UR-0025 1.9.297)', run: () => { const T = require('../lib/mcp-tools'); return Array.isArray(T) && T.length >= 81 && T.every(t => t.name && t.description && t.inputSchema) && T[0].name === 'leerness_handoff' && _mcpToolCount() === T.length && !/const TOOLS = \[/.test(read(__filename)); } },
|
|
3035
|
-
{ name: 'writeUtf8: 원자적 쓰기(temp→rename) 손상방지 (UR-0038 외부리뷰
|
|
3016
|
+
{ name: 'writeUtf8: 원자적 쓰기(temp→rename) 손상방지 행위 (UR-0038 외부리뷰 / CV-5 행위화 1.9.366)', run: () => { if (typeof writeUtf8 !== 'function') return false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_wu_')); try { const f = path.join(tmp, 'sub', 'a.txt'); writeUtf8(f, '한글 UTF-8 내용'); const okContent = read(f) === '한글 UTF-8 내용'; const noTmpLeft = fs.readdirSync(path.dirname(f)).every(n => !n.includes('.tmp-')); return okContent && noTmpLeft; } finally { try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } } },
|
|
3036
3017
|
{ name: '_scrubTestEnv: npm test 시크릿 차단(_scrubEnv는 release 토큰 유지) (UR-0039 외부리뷰 1.9.299)', run: () => { const o = { N: process.env.NPM_TOKEN, L: process.env.LEERNESS_NPM_TOKEN }; process.env.NPM_TOKEN = 'sec1'; process.env.LEERNESS_NPM_TOKEN = 'sec2'; const base = _scrubEnv(); const test = _scrubTestEnv(); const r = base.NPM_TOKEN === 'sec1' && base.LEERNESS_NPM_TOKEN === 'sec2' && !test.NPM_TOKEN && !test.LEERNESS_NPM_TOKEN && !!test.PATH; if (o.N === undefined) delete process.env.NPM_TOKEN; else process.env.NPM_TOKEN = o.N; if (o.L === undefined) delete process.env.LEERNESS_NPM_TOKEN; else process.env.LEERNESS_NPM_TOKEN = o.L; return r; } },
|
|
3037
3018
|
{ name: 'shell 주입 표면 제거: fetchNpmLatest execFile+pkg검증 + runCommandSafe argList 인용 (UR-0040 외부리뷰 1.9.300)', run: () => { const src = read(__filename); const npmFix = /'view', pkg, 'version'/.test(src) && !/cp\.exec\(.npm view \$\{pkg\}/.test(src) && /패키지명 charset/.test(src) && !/cp\.execFile\('npm', \[[^\]]*\], \{ timeout: 12000, shell:/.test(src); const argFix = /argList\.map\(_shellQuoteArg\)\.join/.test(src); return npmFix && argFix && typeof _shellQuoteArg === 'function'; } },
|
|
3038
3019
|
{ name: 'MCP requiredTier 메타데이터 + 정책 minTier 게이트 (UR-0041 외부리뷰 1.9.301)', run: () => { const T = require('../lib/mcp-tools'); const allValid = T.length >= 81 && T.every(t => PERMISSION_TIERS.includes(t.requiredTier)); const get = n => (T.find(t => t.name === n) || {}).requiredTier; const classOk = get('leerness_state_record') === 'safe-write' && get('leerness_provider_add') === 'safe-write' && get('leerness_web') === 'network' && get('leerness_handoff') === 'read-only' && get('leerness_audit') === 'read-only'; const src = read(__filename); const gateOk = /_tierRank\(minTier\) > _tierRank\(required\)/.test(src) && /_policyEnforce\(targetPath, cliArgs\.join\(' '\), _toolDef/.test(src); return allValid && classOk && gateOk; } },
|
|
@@ -3040,7 +3021,7 @@ function _selfTestCases() {
|
|
|
3040
3021
|
{ name: '_withLock/_updateRun: lost-update 락(O_EXCL+재진입) + 적용 (UR-0043 외부리뷰 1.9.303)', run: () => { const src = read(__filename); const fnOk = typeof _withLock === 'function' && typeof _sleepSyncMs === 'function' && typeof _updateRun === 'function'; const reentrant = /if \(_heldLocks\.has\(lockPath\)\) return fn\(\)/.test(src); const excl = /fs\.openSync\(lockPath, 'wx'\)/.test(src); const applied = /const id = _withLock\(progressPath\(root\)/.test(src) && /_updateRun\(root, curId/.test(src); return fnOk && reentrant && excl && applied; } },
|
|
3041
3022
|
{ name: 'lib/analyzers: 분석/검증 함수 4종 모듈 단일출처 분리 (UR-0025 1.9.304)', run: () => { const m = require('../lib/analyzers'); return m._evidenceQuality === _evidenceQuality && m._shellGuardAnalyze === _shellGuardAnalyze && m._parseEvidenceStats === _parseEvidenceStats && m._claimFileInGit === _claimFileInGit && !/function _evidenceQuality\(evidence\) \{/.test(read(__filename)) && !/function _shellGuardAnalyze\(cmd, ctx\) \{/.test(read(__filename)); } },
|
|
3042
3023
|
{ name: 'honesty-check: AI 인식론적 정직성 3차원 + MCP/CLI/strict 통합 (사용자명시 1.9.305)', run: () => { const h = _epistemicHonestyCheck; const d1 = h('이 기능은 항상 정상 동작합니다').findings.some(f => f.dim === 'pretend-knowledge'); const d2 = h('아마 될 것 같습니다. 구현 완료했습니다').findings.some(f => f.dim === 'premature-judgment'); const d3 = h('이 API 의 rate limit 은 초당 5회입니다').findings.some(f => f.dim === 'no-info-gathering'); const clean = h('src/api.js 수정, 12/12 통과 (Exit: 0)').ok === true; const src = read(__filename); const wired = require('../lib/mcp-tools').some(t => t.name === 'leerness_honesty_check') && /if \(cmd === 'honesty-check'\)/.test(src) && /honestyFindings = _epistemicHonestyCheck/.test(src); return d1 && d2 && d3 && clean && wired; } },
|
|
3043
|
-
{ name: 'exit code 일관성: fail()→exitCode 1 + unknown 명령 안내 (UR-0045
|
|
3024
|
+
{ name: 'exit code 일관성: fail()→exitCode 1 행위 + unknown 명령 안내 (UR-0045 / CV-5 행위화 1.9.366)', run: () => { if (typeof fail !== 'function') return false; const saved = process.exitCode; const _w = process.stdout.write; let setOk = false; try { process.stdout.write = () => true; process.exitCode = 0; fail('selftest probe'); setOk = process.exitCode === 1; } finally { process.stdout.write = _w; process.exitCode = saved; } const src = read(__filename); const dispatchOk = /알 수 없는 명령: \$\{cmd\}/.test(src); return setOk && dispatchOk; } },
|
|
3044
3025
|
{ name: 'brief: 프로젝트 청사진 set/show/export + README 개요 섹션 (UR-0055 사용자명시 1.9.307)', run: () => { const src = read(__filename); const fnOk = typeof briefCmd === 'function' && typeof _loadBrief === 'function' && typeof _briefBlueprint === 'function' && _BRIEF_FIELDS.length === 10; const b = { project: 'X', intro: 'i', purpose: 'p', problem: '', features: ['f1', 'f2'], stack: ['s'], architecture: '', users: [], success: [], nonGoals: [], currentState: '' }; const bp = _briefBlueprint(b, VERSION); const bpOk = /Blueprint/.test(bp) && /소개 \(Intro\)/.test(bp) && /f1/.test(bp) && /신규 프로젝트 시작 가이드/.test(bp); const rb = _briefReadmeBlock(b); const rbOk = rb.includes(BRIEF_START) && rb.includes(BRIEF_END) && /프로젝트 개요/.test(rb) && /\*\*목적\*\*/.test(rb); return fnOk && bpOk && rbOk && /if \(cmd === 'brief'\)/.test(src); } },
|
|
3045
3026
|
{ name: 'brief 2단계: update --direction 이력 + MCP leerness_brief + context 통합 (UR-0055 1.9.308)', run: () => { const src = read(__filename); const b = { project: 'X', intro: '', purpose: '', problem: '', features: [], stack: [], architecture: '', users: [], success: [], nonGoals: [], currentState: '', directionHistory: ['2026-06-04: 확대'] }; const bpOk = /개발 방향 이력/.test(_briefBlueprint(b, VERSION)) && /최근 개발 방향 변경/.test(_briefReadmeBlock(b)); const histWired = /sub === 'update'/.test(src) && /brief\.directionHistory \|\| \[\]\), `\$\{today\(\)\}/.test(src); const mcpOk = require('../lib/mcp-tools').some(t => t.name === 'leerness_brief'); const ctxOk = /brief: \{ intro:/.test(src); return bpOk && histWired && mcpOk && ctxOk; } },
|
|
3046
3027
|
{ name: 'verify-claim: done 주장 evidence 기본강제 + --lenient + MCP/json 도달 (UR-0048 설치리뷰 critical 1.9.309)', run: () => { const src = read(__filename); const def = /const mustHaveEvidence = !has\('--lenient'\) && \(isDoneClaim \|\| has\('--require-evidence'\)\)/.test(src); const threshold = /has\('--require-evidence'\) \? evq\.ok : \(evq\.hasFile \|\| evq\.hasTest \|\| evq\.hasLog\)/.test(src); const jsonWired = /evidenceComplete:/.test(src) && /!evidenceQualityOk\) return process\.exit\(1\)/.test(src); const mcpLenient = !!require('../lib/mcp-tools').find(t => t.name === 'leerness_verify_claim').inputSchema.properties.lenient; return def && threshold && jsonWired && mcpLenient; } },
|
|
@@ -3099,6 +3080,7 @@ function _selfTestCases() {
|
|
|
3099
3080
|
{ name: 'CV-7/UR-0082: commands 카탈로그 + help 에 누락 명령군 등재 (표면 drift 가드)', run: () => { const src = read(__filename); const ci = src.indexOf('function commandsCmd'); const hi = src.indexOf('function help('); if (ci < 0 || hi < 0) return false; const cbody = src.slice(ci, ci + 8000); const hbody = src.slice(hi, hi + 7000); const must = ['install-safety', 'feature add', 'creds list', 'incident list', 'webhook serve', 'deploy auto', 'runs list', 'permissions list', 'whats-new', 'migrate audit']; return must.every(c => cbody.includes(c)) && hbody.includes('install-safety') && hbody.includes('feature add'); } },
|
|
3100
3081
|
{ name: 'UR-0083(4th외부평가 9.3): auto-update hook 비침투 (update --quiet 모드 + hook --check --quiet + 업그레이드)', run: () => { const src = read(__filename); const quietMode = /const quiet = !!opts\.quiet \|\| has\('--quiet'\)/.test(src); const hookQuiet = src.includes("command: 'leerness update --check --quiet'"); const upgrade = /includes\('leerness update --check'\) && !h\.command\.includes\('--quiet'\)/.test(src); return quietMode && hookQuiet && upgrade; } },
|
|
3101
3082
|
{ name: 'CV-6/UR-0081: 시크릿 스캐너 FP/FN — _isPlaceholderSecret + _looksSecretLike 행위', run: () => { if (typeof _isPlaceholderSecret !== 'function' || typeof _looksSecretLike !== 'function') return false; const fp = _isPlaceholderSecret('change-me') && _isPlaceholderSecret('your-api-key-here') && _isPlaceholderSecret('<token>') && _isPlaceholderSecret('') && !_isPlaceholderSecret('hunter2realpass'); const fn = _looksSecretLike('secret123') && _looksSecretLike('a'.repeat(24)) && !_looksSecretLike('processEnv') && !_looksSecretLike('reqBodyPassword'); return fp && fn; } },
|
|
3083
|
+
{ name: 'UR-0025: _mergeLines/_mergeEnvLines 순수 코어 모듈 분리 + 행위 (1.9.367)', run: () => { if (typeof _mergeLines !== 'function' || typeof _mergeEnvLines !== 'function') return false; const m = require('../lib/pure-utils'); const moved = m._mergeLines === _mergeLines && m._mergeEnvLines === _mergeEnvLines; const ml = _mergeLines('a\n', ['a', 'b']) === 'a\nb\n'; const meKeep = _mergeEnvLines('FOO=keep\n', ['FOO=new']) === 'FOO=keep\n'; const meAdd = _mergeEnvLines('FOO=keep\n', ['BAR=add']).includes('BAR=add'); return moved && ml && meKeep && meAdd; } },
|
|
3102
3084
|
{ name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
|
|
3103
3085
|
];
|
|
3104
3086
|
}
|
package/lib/pure-utils.js
CHANGED
|
@@ -635,9 +635,30 @@ function _looksSecretLike(value) {
|
|
|
635
635
|
return (/\d/.test(v) && v.length >= 8) || v.length >= 24;
|
|
636
636
|
}
|
|
637
637
|
|
|
638
|
+
// 1.9.367 (UR-0025): 라인 머지 순수 코어 — 기존 텍스트에 없는 라인만 append (substring 중복 방지). mergeLinesFile 의 I/O 분리.
|
|
639
|
+
function _mergeLines(currentText, lines) {
|
|
640
|
+
let next = currentText || '';
|
|
641
|
+
for (const line of (lines || [])) if (!next.includes(line)) next += (next.endsWith('\n') || !next ? '' : '\n') + line + '\n';
|
|
642
|
+
return next;
|
|
643
|
+
}
|
|
644
|
+
// 1.9.367 (UR-0025): .env key-aware 머지 순수 코어 — 기존 KEY 값 보존(덮어쓰기 X), 신규 KEY/주석만 append. mergeEnvFile 의 I/O 분리.
|
|
645
|
+
function _mergeEnvLines(currentText, lines) {
|
|
646
|
+
const current = currentText || '';
|
|
647
|
+
const existingKeys = new Set();
|
|
648
|
+
for (const ln of current.split(/\r?\n/)) { const m = ln.match(/^\s*([A-Z][A-Z0-9_]+)\s*=/); if (m) existingKeys.add(m[1]); }
|
|
649
|
+
let next = current;
|
|
650
|
+
for (const line of (lines || [])) {
|
|
651
|
+
const km = line.match(/^\s*([A-Z][A-Z0-9_]+)\s*=/);
|
|
652
|
+
if (km) { if (existingKeys.has(km[1])) continue; next += (next.endsWith('\n') || !next ? '' : '\n') + line + '\n'; existingKeys.add(km[1]); }
|
|
653
|
+
else { if (!next.includes(line)) next += (next.endsWith('\n') || !next ? '' : '\n') + line + '\n'; }
|
|
654
|
+
}
|
|
655
|
+
return next;
|
|
656
|
+
}
|
|
657
|
+
|
|
638
658
|
module.exports = {
|
|
639
659
|
_isSecretKey, compareVer, parseHarnessVersion,
|
|
640
660
|
_isPlaceholderSecret, _looksSecretLike,
|
|
661
|
+
_mergeLines, _mergeEnvLines,
|
|
641
662
|
_classifyCJK, _riskLabel, _detectSystemLang, _parseSlashFromHelp,
|
|
642
663
|
// 1.9.283 (UR-0025 2단계)
|
|
643
664
|
PERMISSION_TIERS, _tierRank, _requiredTier, _policyAllows, _resolveNpmTag, _mcpJsonContent, _newRunRecord,
|
package/package.json
CHANGED
package/scripts/e2e.js
CHANGED
|
@@ -5004,5 +5004,36 @@ total++;
|
|
|
5004
5004
|
if (!ok) failed++;
|
|
5005
5005
|
}
|
|
5006
5006
|
|
|
5007
|
+
// 1.9.366 회귀 (외부리뷰 CV-5/UR-0080): selftest 무결성 — 설치 패키지 관점에서 --json 전부 통과 (행위 케이스 포함)
|
|
5008
|
+
total++;
|
|
5009
|
+
{
|
|
5010
|
+
let ok = false;
|
|
5011
|
+
try {
|
|
5012
|
+
const r = cp.spawnSync(process.execPath, [CLI, 'selftest', '--json'], { encoding: 'utf8', timeout: 30000 });
|
|
5013
|
+
const j = JSON.parse(r.stdout);
|
|
5014
|
+
ok = j.ok === true && j.pass === j.total && j.fail === 0 && j.total >= 112 && r.status === 0;
|
|
5015
|
+
} catch {}
|
|
5016
|
+
console.log(ok ? '✓ B(1.9.366) CV-5: selftest 무결성 (--json pass===total, 행위 전환 writeUtf8/fail 포함) (UR-0080)' : '✗ selftest 무결성 실패');
|
|
5017
|
+
if (!ok) failed++;
|
|
5018
|
+
}
|
|
5019
|
+
|
|
5020
|
+
// 1.9.367 회귀 (UR-0025): _mergeEnvLines 모듈 분리 — migrate 가 사용자 .env 값을 key-aware 로 보존 (덮어쓰기 X)
|
|
5021
|
+
total++;
|
|
5022
|
+
{
|
|
5023
|
+
let ok = false;
|
|
5024
|
+
try {
|
|
5025
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-envm-'));
|
|
5026
|
+
cp.spawnSync(process.execPath, [CLI, 'init', d, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
|
|
5027
|
+
const envPath = path.join(d, '.env');
|
|
5028
|
+
fs.writeFileSync(envPath, fs.readFileSync(envPath, 'utf8').replace('LEERNESS_NPM_TOKEN=', 'LEERNESS_NPM_TOKEN=user_kept_value_777'));
|
|
5029
|
+
cp.spawnSync(process.execPath, [CLI, 'migrate', d], { encoding: 'utf8', timeout: 30000 });
|
|
5030
|
+
const after = fs.readFileSync(envPath, 'utf8');
|
|
5031
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
5032
|
+
ok = after.includes('LEERNESS_NPM_TOKEN=user_kept_value_777');
|
|
5033
|
+
} catch {}
|
|
5034
|
+
console.log(ok ? '✓ B(1.9.367) UR-0025: _mergeEnvLines 분리 — migrate 가 사용자 .env 값 key-aware 보존' : '✗ env merge 보존 실패');
|
|
5035
|
+
if (!ok) failed++;
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5007
5038
|
console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
|
|
5008
5039
|
if (failed > 0) process.exit(1);
|