leerness 1.9.351 → 1.9.353
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 +26 -0
- package/README.md +5 -5
- package/bin/harness.js +36 -23
- package/lib/pure-utils.js +9 -4
- package/package.json +1 -1
- package/scripts/e2e.js +56 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.353 — 2026-06-05 — 외부리뷰 P2 마무리 3종 (UR-0067/0070/0071) · P2 전량 완료
|
|
4
|
+
|
|
5
|
+
**🧩 외부 리뷰 남은 P2 3건 — 인코딩 정책/CP949 · shell-guard 셸 명시 · init non-TTY ANSI. 외부리뷰 P0/P1/P2 전량 해소.**
|
|
6
|
+
|
|
7
|
+
### 구현
|
|
8
|
+
1. **UR-0067 — 인코딩 정합** (Opus P2-1/Codex#4): (a) `encoding check` 의 UTF-8 BOM 경고를 `.ps1`/`.bat` 예외 — PS5.1 호환 위해 BOM 이 의도적일 수 있어 `env encoding`(BOM 권장)과의 모순 해소. (b) 한글(`[가-힣]`) 게이트 제거 → **CP949/Latin-1 등 invalid UTF-8 을 round-trip 불일치로 감지**(이전: 한글 없으면 통과 = false negative). 유효 UTF-8 은 byte-exact round-trip 이라 오탐 0.
|
|
9
|
+
2. **UR-0070 — shell-guard 셸 명시** (Opus P2-4): `--shell powershell|cmd|bash` (+ `--ps-version`) 옵션 — 자동 감지(git-bash 경유 등)가 실제 실행 셸과 달라 PS5.1 `&&` 가드가 무력화되던 문제. AI 에이전트가 대상 셸 지정 가능.
|
|
10
|
+
3. **UR-0071 — init non-TTY ANSI** (Sonnet F-05): init 완료 안내 5개 raw ANSI(`\x1b[36m/33m/2m`)에 isTTY 가드 — 파이프 출력에 raw escape 누출 방지.
|
|
11
|
+
|
|
12
|
+
### 검증
|
|
13
|
+
- **selftest 100/100 PASS** · **E2E 297→298 PASS** (회귀 0).
|
|
14
|
+
- 실측: cp949.txt(한글 utf8 미매치) invalid 감지 + script.ps1 BOM 예외 · `shell-guard "a && b" --shell powershell` → ps5-chain 감지 · init 파이프 출력 raw ANSI 0.
|
|
15
|
+
|
|
16
|
+
## 1.9.352 — 2026-06-05 — 외부리뷰 P2 정리 3종 (UR-0066/0068/0069)
|
|
17
|
+
|
|
18
|
+
**🧩 외부 리뷰 P2 3건 — shell:true 주입 가드 + milestone 파서 누출 + usage subcommand 미집계.** (selftest 100 달성)
|
|
19
|
+
|
|
20
|
+
### 구현
|
|
21
|
+
1. **UR-0066 — shell:true 주입 가드** (Opus P2-3/Sonnet F-12): `agents bench|multi --execute` 가 raw task 를 `shell:true` spawn 에 전달 → 셸 메타문자(`& | $()` 백틱) 주입 위험. task 를 `_shellQuoteArg`(크로스플랫폼)로 단일 토큰화(안전 경로 `_cliChat` 와 일관). `fetchNpmLatest` 의 `shell:true` → win `npm.cmd` 직접 호출로 셸 표면 제거.
|
|
22
|
+
2. **UR-0068 — milestone 파서 누출** (Codex#5): `_roadmapParseMilestones` 가 `slice(m.index)` 로 다음 milestone 의 Status/Progress 를 이전에 적용하던 버그. **다음 milestone 직전까지 block 한정**.
|
|
23
|
+
3. **UR-0069 — usage subcommand 미집계** (Codex#6): usage 루트가 `args[1]` 을 path 로 가정 → `decision add`/`scan secrets` 등 subcommand 명령에서 `root=cwd/add` 가 되어 .harness 못 찾아 미집계. 루트를 `arg('--path', cwd)` 로 수정(전 명령 집계).
|
|
24
|
+
|
|
25
|
+
### 검증
|
|
26
|
+
- **selftest 100/100 PASS** · **E2E 296→297 PASS** (회귀 0).
|
|
27
|
+
- 실측: milestone M-0001 status=planned(누출 없음)/M-0002 done · `_shellQuoteArg('a & b')` 단일 토큰화 · decision/lesson/scan 각 usage 1 집계(이전 0) · 기존 UR-0040 fetchNpmLatest selftest 케이스 새 npm.cmd 형태로 갱신.
|
|
28
|
+
|
|
3
29
|
## 1.9.351 — 2026-06-05 — 외부리뷰 UR-0064/0065: 제목 오염 차단 + 문서 정합
|
|
4
30
|
|
|
5
31
|
**🧩 외부 리뷰 남은 P1 2건 — decision/lesson 제목 오염 차단 + 문서 정합(AGENTS.md/--help). 외부리뷰 P0/P1 전량 해소.**
|
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.353 하네스를 사용합니다. 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.353는 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.351는 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.353)** · 매 라운드 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.353: 2026-06-05
|
|
588
588
|
<!-- leerness:project-readme:end -->
|
|
589
589
|
|
package/bin/harness.js
CHANGED
|
@@ -27,7 +27,7 @@ const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInG
|
|
|
27
27
|
// 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
|
|
28
28
|
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 분리
|
|
29
29
|
|
|
30
|
-
const VERSION = '1.9.
|
|
30
|
+
const VERSION = '1.9.353';
|
|
31
31
|
|
|
32
32
|
// 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
|
|
33
33
|
// 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
|
|
@@ -235,7 +235,7 @@ function arg(name, def = null) { const i = process.argv.indexOf(name); return i
|
|
|
235
235
|
function has(name) { return process.argv.includes(name); }
|
|
236
236
|
function nonFlagArgs() {
|
|
237
237
|
const out = [];
|
|
238
|
-
const withValue = new Set(['--language','--skills','--path','--status','--progress','--goal','--reason','--next','--target','--token-env','--package','--out','--from','--repo','--id','--note','--evidence','--query','--limit','--action','--agent','--tool','--doc','--command','--capability','--before','--after','--display','--threshold','--trigger','--check','--set','--min-score','--include','--days','--gh-pages-src','--roadmap','--since','--agents','--model','--timeout','--retry-on-fail','--label','--score','--tokens','--alternatives','--impact','--tag','--surface','--depends-on','--affects','--co-changes-with','--files','--branch','--remote','--task-add','--next-action','--role','--provider','--env-var','--deploy','--token-lifetime-hours','--port','--secret','--keep']);
|
|
238
|
+
const withValue = new Set(['--language','--skills','--path','--status','--progress','--goal','--reason','--next','--target','--token-env','--package','--out','--from','--repo','--id','--note','--evidence','--query','--limit','--action','--agent','--tool','--doc','--command','--capability','--before','--after','--display','--threshold','--trigger','--check','--set','--min-score','--include','--days','--gh-pages-src','--roadmap','--since','--agents','--model','--timeout','--retry-on-fail','--label','--score','--tokens','--alternatives','--impact','--tag','--surface','--depends-on','--affects','--co-changes-with','--files','--branch','--remote','--task-add','--next-action','--role','--provider','--env-var','--deploy','--token-lifetime-hours','--port','--secret','--keep','--shell','--ps-version']);
|
|
239
239
|
const a = process.argv.slice(2);
|
|
240
240
|
for (let i = 0; i < a.length; i++) {
|
|
241
241
|
const x = a[i];
|
|
@@ -1169,14 +1169,16 @@ async function install(root, opts = {}) {
|
|
|
1169
1169
|
}
|
|
1170
1170
|
// 1.9.251 (UR-0018 3단계): init 완료 시 터미널 인코딩 점검 안내 — 사용자 명시 ("leerness init 시 터미널 인코딩 점검 안내")
|
|
1171
1171
|
// Windows CP949 / POSIX non-UTF-8 환경에서 leerness 한국어 출력 깨짐을 설치 직후 사용자에게 즉시 고지.
|
|
1172
|
+
// 1.9.353 (UR-0071 외부리뷰): non-TTY(파이프) 출력에 raw ANSI 누출 방지 — isTTY 일 때만 색상.
|
|
1173
|
+
const _c = (n, s) => (process.stdout && process.stdout.isTTY) ? `\x1b[${n}m${s}\x1b[0m` : s;
|
|
1172
1174
|
if (!opts.migration) {
|
|
1173
1175
|
try {
|
|
1174
1176
|
const enc = _terminalEncodingNotice();
|
|
1175
1177
|
if (enc.lines.length > 0) {
|
|
1176
1178
|
log('');
|
|
1177
|
-
log(
|
|
1179
|
+
log(_c(36, '🌐 터미널 인코딩 점검 (1.9.251, UR-0018)'));
|
|
1178
1180
|
enc.lines.forEach(l => log(l));
|
|
1179
|
-
if (!enc.ok) log(
|
|
1181
|
+
if (!enc.ok) log(_c(2, ' 상세: leerness env · 셸 스크립트 검사: leerness env encoding'));
|
|
1180
1182
|
}
|
|
1181
1183
|
} catch {}
|
|
1182
1184
|
}
|
|
@@ -1187,9 +1189,9 @@ async function install(root, opts = {}) {
|
|
|
1187
1189
|
const diag = _pathDiagnose();
|
|
1188
1190
|
if (!diag.resolvable && !diag.inPath && diag.globalBin) {
|
|
1189
1191
|
log('');
|
|
1190
|
-
log(
|
|
1191
|
-
log(
|
|
1192
|
-
log(
|
|
1192
|
+
log(_c(33, '🔗 leerness CLI PATH 미등록 (1.9.254, UR-0019)'));
|
|
1193
|
+
log(_c(2, ` npm global bin (${diag.globalBin}) 이 PATH 에 없어 'leerness' 명령이 안 먹힐 수 있음`));
|
|
1194
|
+
log(_c(36, ' → 자동 등록: leerness path-setup --apply'));
|
|
1193
1195
|
}
|
|
1194
1196
|
} catch {}
|
|
1195
1197
|
}
|
|
@@ -3002,7 +3004,7 @@ function _selfTestCases() {
|
|
|
3002
3004
|
{ 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)); } },
|
|
3003
3005
|
{ name: 'writeUtf8: 원자적 쓰기(temp→rename) 손상방지 (UR-0038 외부리뷰 3중수렴 1.9.298)', run: () => { const src = read(__filename); return /function writeUtf8\(p, s\)/.test(src) && /fs\.writeFileSync\(tmp,/.test(src) && /fs\.renameSync\(tmp, p\)/.test(src) && /\.tmp-\$\{process\.pid\}/.test(src) && /fs\.unlinkSync\(tmp\)/.test(src); } },
|
|
3004
3006
|
{ 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; } },
|
|
3005
|
-
{ name: 'shell 주입 표면 제거: fetchNpmLatest execFile+pkg검증 + runCommandSafe argList 인용 (UR-0040 외부리뷰 1.9.300)', run: () => { const src = read(__filename); const npmFix = /cp\.execFile\('npm', \['view', pkg, 'version'\]/.test(src) && !/cp\.exec\(.npm view \$\{pkg\}/.test(src) && /패키지명 charset/.test(src); const argFix = /argList\.map\(_shellQuoteArg\)\.join/.test(src); return npmFix && argFix && typeof _shellQuoteArg === 'function'; } },
|
|
3007
|
+
{ name: 'shell 주입 표면 제거: fetchNpmLatest execFile+pkg검증 + runCommandSafe argList 인용 (UR-0040 외부리뷰 1.9.300)', run: () => { const src = read(__filename); const npmFix = /cp\.execFile\([^,]*'npm[^']*', \['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'; } },
|
|
3006
3008
|
{ 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; } },
|
|
3007
3009
|
{ name: 'verify-claim git diff 시맨틱 교차검증: _gitChangedFiles/_claimFileInGit + strict FAIL 통합 (UR-0042 외부리뷰 1.9.302)', run: () => { const fnOk = typeof _gitChangedFiles === 'function' && typeof _claimFileInGit === 'function'; const matchOk = _claimFileInGit('src/api.js', new Set(['src/api.js'])) === true && _claimFileInGit('./src/api.js', new Set(['src/api.js'])) === true && _claimFileInGit('other.js', new Set(['src/api.js'])) === false && _claimFileInGit('x', null) === null; const src = read(__filename); const wired = /git diff 교차검증/.test(src) && /\|\| !gitClaimOk/.test(src) && /_gitChangedFiles\(root\)/.test(src); return fnOk && matchOk && wired; } },
|
|
3008
3010
|
{ 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; } },
|
|
@@ -3053,6 +3055,8 @@ function _selfTestCases() {
|
|
|
3053
3055
|
{ name: 'UR-0059(외부리뷰 P0): --path 라우팅 일관화 — bare args[N]||cwd 제거 + arg(--path) wrap', run: () => { const src = read(__filename); const bare1 = '(args[1] ' + '|| process.cwd())'; const bare2 = '(args[2] ' + '|| process.cwd())'; const noBare = !src.includes(bare1) && !src.includes(bare2); const wrapped = src.includes('arg(' + "'--path', args[1] || process.cwd())") && src.includes('arg(' + "'--path', args[2] || process.cwd())"); const argDefault = arg('--definitely-not-real-xyz', 'SENT') === 'SENT'; return noBare && wrapped && argDefault; } },
|
|
3054
3056
|
{ name: 'UR-0061(외부리뷰 P1): roadmap CSS 값 살균 — :root/</style> breakout 차단', run: () => { const m = require('../lib/pure-utils'); const css = m._roadmapTokenStyles({ 'color.primary': 'red;}' + '</style><script>alert(1)</script>' }, {}); const blocked = !css.includes('<') && !css.includes('>'); const primaryLine = (css.split('\n').find(l => l.includes('--lr-primary')) || ''); const noBreakout = !primaryLine.replace(/;$/, '').includes('}'); const preserved = m._roadmapTokenStyles({ 'color.primary': '#2563eb' }, {}).includes('--lr-primary: #2563eb'); return blocked && noBreakout && preserved; } },
|
|
3055
3057
|
{ name: 'UR-0060(외부리뷰 P1): SECRET_PATTERNS 19종 — GitLab/JWT/DB-URI/SendGrid/AWS-secret/Bearer 보강 + 오탐 가드', run: () => { const c = require('../lib/catalogs'); const hit = s => c.SECRET_PATTERNS.some(p => { p.re.lastIndex = 0; return p.re.test(s); }); const det = hit('glpat-' + 'x'.repeat(20)) && hit('eyJ' + 'x'.repeat(15) + '.eyJ' + 'y'.repeat(15) + '.' + 'z'.repeat(15)) && hit('postgres://u:p@host:5432/db') && hit('SG.' + 'x'.repeat(22) + '.' + 'y'.repeat(43)) && hit('aws_secret_access_key = "' + 'x'.repeat(40) + '"') && hit('Bearer ' + 'x'.repeat(25)); const clean = !hit('const u = "john' + '_doe_2024";') && !hit('https://example.com/path/to/page'); return c.SECRET_PATTERNS.length === 19 && det && clean; } },
|
|
3058
|
+
{ name: 'UR-0068(외부리뷰 P2): _roadmapParseMilestones 블록 경계 — 다음 milestone status 누출 차단', run: () => { const m = require('../lib/pure-utils'); const r = m._roadmapParseMilestones('### M-0001. A\n\n### M-0002. B\nStatus: done\nProgress: 80%\n'); return r.length === 2 && r[0].status === 'planned' && r[0].progress === 0 && r[1].status === 'done' && r[1].progress === 80; } },
|
|
3059
|
+
{ name: 'UR-0066(외부리뷰 P2): shell:true 주입 가드 — agents bench task _shellQuoteArg + fetchNpmLatest npm.cmd', run: () => { const m = require('../lib/pure-utils'); const src = read(__filename); const benchQuoted = src.includes('const qTask = ' + '_shellQuoteArg(task)'); const npmCmd = /'win32' \? 'npm\.cmd' : 'npm'/.test(src); const q = m._shellQuoteArg('a & b'); const safe = (process.platform === 'win32' ? q === '"a & b"' : q === "'a & b'"); return benchQuoted && npmCmd && safe; } },
|
|
3056
3060
|
{ name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
|
|
3057
3061
|
];
|
|
3058
3062
|
}
|
|
@@ -3148,7 +3152,8 @@ function shellGuardCmd(root, cmd, opts = {}) {
|
|
|
3148
3152
|
const yl = s => isTty ? `\x1b[33m${s}\x1b[0m` : s;
|
|
3149
3153
|
const rd = s => isTty ? `\x1b[31m${s}\x1b[0m` : s;
|
|
3150
3154
|
const dm = s => isTty ? `\x1b[2m${s}\x1b[0m` : s;
|
|
3151
|
-
|
|
3155
|
+
// 1.9.353 (UR-0070 외부리뷰): --shell 로 대상 셸 명시 — 자동 감지(git-bash 경유 등)가 실제 실행 셸과 달라 PS5.1 && 가드가 무력화되는 것 방지
|
|
3156
|
+
const ctx = opts.shell ? { shell: opts.shell, psVersion: opts.shell === 'powershell' ? (opts.psVersion || '5') : null } : _detectShellCtx();
|
|
3152
3157
|
// record 모드: 실패한 명령 기록
|
|
3153
3158
|
if (opts.record) {
|
|
3154
3159
|
if (!cmd) { fail('shell-guard --record 에는 --cmd "<명령>" 필요'); return; }
|
|
@@ -7137,7 +7142,7 @@ function encodingCheck(root) {
|
|
|
7137
7142
|
if (buf.length === 0) continue;
|
|
7138
7143
|
if (buf.length > 5 * 1024 * 1024) continue;
|
|
7139
7144
|
const fileRel = rel(root, file);
|
|
7140
|
-
if (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF) { warnings++; findings.push({ file: fileRel, issue: 'UTF-8 BOM' }); }
|
|
7145
|
+
if (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF) { if (ext !== '.ps1' && ext !== '.bat') { warnings++; findings.push({ file: fileRel, issue: 'UTF-8 BOM' }); } } // 1.9.353 (UR-0067 외부리뷰): .ps1/.bat 는 PS5.1 호환 위해 BOM 의도적일 수 있어 예외 (env encoding 정책과 모순 해소)
|
|
7141
7146
|
else if ((buf[0] === 0xFF && buf[1] === 0xFE) || (buf[0] === 0xFE && buf[1] === 0xFF)) { warnings++; findings.push({ file: fileRel, issue: 'UTF-16 BOM' }); }
|
|
7142
7147
|
let nul = false; for (let i = 0; i < Math.min(buf.length, 4096); i++) if (buf[i] === 0) { nul = true; break; }
|
|
7143
7148
|
if (nul) { warnings++; findings.push({ file: fileRel, issue: 'NUL byte (binary in text path)' }); }
|
|
@@ -7145,13 +7150,13 @@ function encodingCheck(root) {
|
|
|
7145
7150
|
const text = buf.toString('utf8').replace(/^/, '');
|
|
7146
7151
|
if (!/^@?chcp\s+65001/i.test(text.split(/\r?\n/, 1)[0] || '')) { warnings++; findings.push({ file: fileRel, issue: '.bat missing chcp 65001' }); }
|
|
7147
7152
|
}
|
|
7153
|
+
// 1.9.353 (UR-0067 외부리뷰): 가-힣 게이트 제거 — CP949/Latin-1 등 invalid UTF-8 은 한글 포함 여부와 무관하게 round-trip 불일치로 감지(이전: 한글 없으면 통과 = false negative). 유효 UTF-8 은 byte-exact round-trip 이라 오탐 없음.
|
|
7148
7154
|
try {
|
|
7149
7155
|
const text = buf.toString('utf8');
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
}
|
|
7156
|
+
const reBuf = Buffer.from(text, 'utf8');
|
|
7157
|
+
const hasBOM = buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF;
|
|
7158
|
+
if (!reBuf.equals(buf) && !hasBOM) {
|
|
7159
|
+
warnings++; findings.push({ file: fileRel, issue: 'invalid UTF-8 roundtrip (CP949/mojibake 의심)' });
|
|
7155
7160
|
}
|
|
7156
7161
|
} catch {}
|
|
7157
7162
|
}
|
|
@@ -11467,19 +11472,21 @@ function agentsCmd(root, sub, ...args) {
|
|
|
11467
11472
|
const promises = ready.map(({ agent, status }) => new Promise((resolve) => {
|
|
11468
11473
|
const t0 = Date.now();
|
|
11469
11474
|
let cmd, cmdArgs;
|
|
11475
|
+
// 1.9.352 (UR-0066 외부리뷰): shell:true 경로에 raw task 전달 시 셸 메타문자(& | $() 백틱) 주입 위험 → _shellQuoteArg 로 단일 토큰화 (안전 경로 _cliChat 와 일관)
|
|
11476
|
+
const qTask = _shellQuoteArg(task);
|
|
11470
11477
|
if (agent.id === 'claude') {
|
|
11471
|
-
cmdArgs = writeMode ? ['--print', '--dangerously-skip-permissions',
|
|
11478
|
+
cmdArgs = writeMode ? ['--print', '--dangerously-skip-permissions', qTask] : ['--print', qTask];
|
|
11472
11479
|
cmd = 'claude';
|
|
11473
11480
|
} else if (agent.id === 'codex') {
|
|
11474
11481
|
cmdArgs = writeMode
|
|
11475
|
-
? ['exec', '--skip-git-repo-check', '--dangerously-bypass-approvals-and-sandbox',
|
|
11476
|
-
: ['exec', '--skip-git-repo-check',
|
|
11482
|
+
? ['exec', '--skip-git-repo-check', '--dangerously-bypass-approvals-and-sandbox', qTask]
|
|
11483
|
+
: ['exec', '--skip-git-repo-check', qTask];
|
|
11477
11484
|
cmd = 'codex';
|
|
11478
11485
|
} else if (agent.id === 'agy') {
|
|
11479
|
-
cmdArgs = writeMode ? ['-p',
|
|
11486
|
+
cmdArgs = writeMode ? ['-p', qTask, '--yolo'] : ['-p', qTask];
|
|
11480
11487
|
cmd = 'agy';
|
|
11481
11488
|
} else if (agent.id === 'copilot') {
|
|
11482
|
-
cmdArgs = ['copilot', 'suggest',
|
|
11489
|
+
cmdArgs = ['copilot', 'suggest', qTask];
|
|
11483
11490
|
cmd = 'gh';
|
|
11484
11491
|
}
|
|
11485
11492
|
const r = cp.spawn(cmd, cmdArgs, { shell: true });
|
|
@@ -14975,7 +14982,8 @@ function fetchNpmLatest(pkg) {
|
|
|
14975
14982
|
// 1.9.300 (UR-0040, 외부리뷰 Sonnet): cp.exec 템플릿리터럴 → execFile(args 배열) + pkg charset 검증 = 셸 주입 이중 차단.
|
|
14976
14983
|
// 이전: `npm view ${pkg} version` 가 셸 문자열이라 pkg 에 메타문자(; && $() 공백)면 주입 가능.
|
|
14977
14984
|
if (!/^@?[a-z0-9][a-z0-9._/-]*$/i.test(String(pkg || ''))) return resolve(null); // 패키지명 charset (메타문자 0)
|
|
14978
|
-
|
|
14985
|
+
// 1.9.352 (UR-0066 외부리뷰): shell:true 대신 win 에서 npm.cmd 직접 호출 (shell 해석 표면 제거 — pkg 가 charset 검증돼 있어도 방어심층)
|
|
14986
|
+
cp.execFile(process.platform === 'win32' ? 'npm.cmd' : 'npm', ['view', pkg, 'version'], { timeout: 12000 }, (err, stdout) => {
|
|
14979
14987
|
if (err) return resolve(null);
|
|
14980
14988
|
const v = String(stdout || '').trim();
|
|
14981
14989
|
resolve(/^\d+\.\d+\.\d+/.test(v) ? v : null);
|
|
@@ -20960,7 +20968,12 @@ async function main() {
|
|
|
20960
20968
|
// 1.9.317 (UR-0051, 설치리뷰): 내부 auto-call(LEERNESS_INTERNAL=1) 은 usage 집계 제외 — 텔레메트리 오염(거짓 skill 추천) 방지.
|
|
20961
20969
|
if (process.env.LEERNESS_INTERNAL !== '1' && cmd !== 'usage' && cmd !== 'init' && cmd !== 'migrate' && cmd !== '--version' && cmd !== '--help') {
|
|
20962
20970
|
try {
|
|
20963
|
-
|
|
20971
|
+
// 1.9.352 (UR-0069 외부리뷰): usage 루트 — --path 우선, 없으면 args[1] 이 .harness 보유 디렉토리일 때만 path(positional 보존), 아니면 cwd. (이전: args[1] 무조건 path 가정 → subcommand[decision add 등] root=cwd/add → .harness 못 찾아 미집계)
|
|
20972
|
+
const _pathArg = arg('--path', null);
|
|
20973
|
+
let root;
|
|
20974
|
+
if (_pathArg) root = absRoot(_pathArg);
|
|
20975
|
+
else if (args[1] && !args[1].startsWith('-') && exists(path.join(absRoot(args[1]), '.harness'))) root = absRoot(args[1]);
|
|
20976
|
+
else root = absRoot(process.cwd());
|
|
20964
20977
|
if (exists(path.join(root, '.harness'))) _bumpUsage(root, cmd);
|
|
20965
20978
|
} catch {}
|
|
20966
20979
|
}
|
|
@@ -21148,7 +21161,7 @@ async function main() {
|
|
|
21148
21161
|
if (cmd === 'shell-guard' || cmd === 'shellguard') {
|
|
21149
21162
|
const cmdArg = arg('--cmd', args[1] && !args[1].startsWith('-') ? args[1] : '');
|
|
21150
21163
|
const exitRaw = arg('--exit', null);
|
|
21151
|
-
return shellGuardCmd(arg('--path', process.cwd()), cmdArg, { record: has('--record'), exit: exitRaw != null ? parseInt(exitRaw, 10) : null, json: has('--json') });
|
|
21164
|
+
return shellGuardCmd(arg('--path', process.cwd()), cmdArg, { record: has('--record'), exit: exitRaw != null ? parseInt(exitRaw, 10) : null, json: has('--json'), shell: arg('--shell', null), psVersion: arg('--ps-version', null) });
|
|
21152
21165
|
}
|
|
21153
21166
|
// 1.9.265: leerness slash-commands [agent] — CLI 에이전트별 슬래시 명령어 레지스트리 (사용자 명시 UR-0021)
|
|
21154
21167
|
if (cmd === 'slash-commands' || cmd === 'slash' || cmd === 'agent-slash') {
|
package/lib/pure-utils.js
CHANGED
|
@@ -296,11 +296,16 @@ function _roadmapMapStatus(s) {
|
|
|
296
296
|
return 'planned';
|
|
297
297
|
}
|
|
298
298
|
function _roadmapParseMilestones(text) {
|
|
299
|
+
const s = String(text || '');
|
|
299
300
|
const out = [];
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
301
|
+
// 1.9.352 (UR-0068 외부리뷰): 다음 milestone 직전까지 block 한정 — 이전 구현은 slice(m.index) 로 다음 milestone 의 Status/Progress 를 누출했음
|
|
302
|
+
const matches = [...s.matchAll(/^### (M-\d{4})\.\s*(.+?)$/gm)];
|
|
303
|
+
for (let i = 0; i < matches.length; i++) {
|
|
304
|
+
const m = matches[i];
|
|
305
|
+
const end = i + 1 < matches.length ? matches[i + 1].index : s.length;
|
|
306
|
+
const block = s.slice(m.index, end);
|
|
307
|
+
const sm = block.match(/^Status:\s*(\S+)/m);
|
|
308
|
+
const pm = block.match(/^Progress:\s*(\d+)%/m);
|
|
304
309
|
out.push({ id: m[1], title: m[2].trim(), status: sm ? sm[1] : 'planned', progress: pm ? parseInt(pm[1], 10) : 0 });
|
|
305
310
|
}
|
|
306
311
|
return out;
|
package/package.json
CHANGED
package/scripts/e2e.js
CHANGED
|
@@ -3330,7 +3330,7 @@ total++;
|
|
|
3330
3330
|
try {
|
|
3331
3331
|
const harnessSrc = fs.readFileSync(path.resolve(__dirname, '..', 'bin', 'harness.js'), 'utf8');
|
|
3332
3332
|
// (1) 소스: cp.exec 템플릿 제거 + execFile args 배열 + argList 인용
|
|
3333
|
-
const srcOk = /cp\.execFile\('npm', \['view', pkg, 'version'\]/.test(harnessSrc) &&
|
|
3333
|
+
const srcOk = /cp\.execFile\([^,]*'npm[^']*', \['view', pkg, 'version'\]/.test(harnessSrc) && // 1.9.352(UR-0066): npm.cmd(win) 형태 허용
|
|
3334
3334
|
!/cp\.exec\(.npm view \$\{pkg\}/.test(harnessSrc) &&
|
|
3335
3335
|
/argList\.map\(_shellQuoteArg\)\.join/.test(harnessSrc);
|
|
3336
3336
|
// (2) 기능 회귀: update --check 가 오프라인(네트워크 무)에서도 crash 없이 종료
|
|
@@ -4668,5 +4668,60 @@ total++;
|
|
|
4668
4668
|
if (!ok) failed++;
|
|
4669
4669
|
}
|
|
4670
4670
|
|
|
4671
|
+
// 1.9.352 회귀 (외부리뷰 P2): UR-0069 usage subcommand 집계 + UR-0068 milestone 파서 블록 경계
|
|
4672
|
+
total++;
|
|
4673
|
+
{
|
|
4674
|
+
let ok = false;
|
|
4675
|
+
try {
|
|
4676
|
+
const m = require(path.resolve(__dirname, '..', 'lib', 'pure-utils.js'));
|
|
4677
|
+
// UR-0068: milestone 누출 차단 (pure)
|
|
4678
|
+
const mil = m._roadmapParseMilestones('### M-0001. A\n\n### M-0002. B\nStatus: done\nProgress: 80%\n');
|
|
4679
|
+
const milOk = mil.length === 2 && mil[0].status === 'planned' && mil[0].progress === 0 && mil[1].status === 'done';
|
|
4680
|
+
// UR-0069: subcommand 명령(decision add/lesson save/scan secrets) usage 집계 (이전엔 args[1]=subcommand 를 path 로 오인 → 미집계)
|
|
4681
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-usg-'));
|
|
4682
|
+
cp.spawnSync(process.execPath, [CLI, 'init', d, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
|
|
4683
|
+
cp.spawnSync(process.execPath, [CLI, 'decision', 'add', 'T1', '--reason', 'r'], { cwd: d, encoding: 'utf8', timeout: 20000 });
|
|
4684
|
+
cp.spawnSync(process.execPath, [CLI, 'lesson', 'save', 'L1'], { cwd: d, encoding: 'utf8', timeout: 20000 });
|
|
4685
|
+
cp.spawnSync(process.execPath, [CLI, 'scan', 'secrets', '.'], { cwd: d, encoding: 'utf8', timeout: 20000 });
|
|
4686
|
+
const ur = cp.spawnSync(process.execPath, [CLI, 'usage', 'stats', d, '--json'], { encoding: 'utf8', timeout: 20000 });
|
|
4687
|
+
let usageOk = false;
|
|
4688
|
+
try { const j = JSON.parse(ur.stdout); const c = j.commands || {}; usageOk = (c.decision || 0) >= 1 && (c.lesson || 0) >= 1 && (c.scan || 0) >= 1; } catch {}
|
|
4689
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
4690
|
+
ok = milOk && usageOk;
|
|
4691
|
+
} catch {}
|
|
4692
|
+
console.log(ok ? '✓ B(1.9.352) 외부리뷰 P2: milestone 파서 블록경계 + usage subcommand 집계 (UR-0068/0069)' : '✗ P2 milestone/usage 실패');
|
|
4693
|
+
if (!ok) failed++;
|
|
4694
|
+
}
|
|
4695
|
+
|
|
4696
|
+
// 1.9.353 회귀 (외부리뷰 P2): UR-0067 encoding(CP949 감지/.ps1 BOM 예외) + UR-0070 shell-guard --shell + UR-0071 init non-TTY ANSI
|
|
4697
|
+
total++;
|
|
4698
|
+
{
|
|
4699
|
+
let ok = false;
|
|
4700
|
+
try {
|
|
4701
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-enc-'));
|
|
4702
|
+
cp.spawnSync(process.execPath, [CLI, 'init', d, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
|
|
4703
|
+
// UR-0067: CP949 bytes(한글 utf8 미매치) → invalid 감지 / .ps1 BOM → 예외
|
|
4704
|
+
fs.writeFileSync(path.join(d, 'cp949.txt'), Buffer.from([0xC7, 0xD1, 0xB1, 0xDB]));
|
|
4705
|
+
fs.writeFileSync(path.join(d, 'script.ps1'), Buffer.concat([Buffer.from([0xEF, 0xBB, 0xBF]), Buffer.from('Write-Host hi', 'utf8')]));
|
|
4706
|
+
const er = cp.spawnSync(process.execPath, [CLI, 'encoding', 'check', d], { encoding: 'utf8', timeout: 20000 });
|
|
4707
|
+
const eout = (er.stdout || '') + (er.stderr || '');
|
|
4708
|
+
const encOk = /cp949\.txt/.test(eout) && /CP949|invalid UTF-8/.test(eout) && !/script\.ps1/.test(eout);
|
|
4709
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
4710
|
+
// UR-0070: shell-guard --shell powershell → ps5-chain 감지(자동감지로는 bash 라 놓쳤을 것)
|
|
4711
|
+
const sr = cp.spawnSync(process.execPath, [CLI, 'shell-guard', 'a && b', '--shell', 'powershell', '--json'], { encoding: 'utf8', timeout: 20000 });
|
|
4712
|
+
let shellOk = false;
|
|
4713
|
+
try { const j = JSON.parse(sr.stdout); shellOk = j.shell === 'powershell' && (j.issues || []).some(i => i.rule === 'ps5-chain'); } catch {}
|
|
4714
|
+
// UR-0071: init non-TTY 출력에 fixed raw ANSI 없음
|
|
4715
|
+
const e2 = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-ansi-'));
|
|
4716
|
+
const ir = cp.spawnSync(process.execPath, [CLI, 'init', e2, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
|
|
4717
|
+
const iout = (ir.stdout || '') + (ir.stderr || '');
|
|
4718
|
+
const ansiOk = !/\x1b\[36m🌐/.test(iout) && !/\x1b\[33m🔗/.test(iout);
|
|
4719
|
+
fs.rmSync(e2, { recursive: true, force: true });
|
|
4720
|
+
ok = encOk && shellOk && ansiOk;
|
|
4721
|
+
} catch {}
|
|
4722
|
+
console.log(ok ? '✓ B(1.9.353) 외부리뷰 P2: encoding CP949/.ps1 BOM + shell-guard --shell + init non-TTY ANSI (UR-0067/0070/0071)' : '✗ P2 마무리 실패');
|
|
4723
|
+
if (!ok) failed++;
|
|
4724
|
+
}
|
|
4725
|
+
|
|
4671
4726
|
console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
|
|
4672
4727
|
if (failed > 0) process.exit(1);
|