leerness 1.9.289 → 1.9.290

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,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.290 — 2026-06-03 — UR-0037 (Codex #4): require 시 top-level side effect 격리 — Codex 5건 완전 수렴 🎉
4
+
5
+ **🧩 `require('leerness/bin/harness.js')` 가 호스트 프로세스를 오염시키던 마지막 갭 수정 (Codex gpt-5.5 #4). 이로써 Codex 코드 리뷰 5건 전부 수렴 완료.**
6
+
7
+ ### 배경
8
+ 1.9.184/249 에서 (1) `process.removeAllListeners('warning')` + warning 핸들러 재등록, (2) `process.env.NODE_OPTIONS += ' --no-deprecation'`, (3) chcp 65001 IIFE 가 **파일 최상단에서 즉시 실행**됐음. CLI 로는 정상이나, leerness 를 라이브러리로 `require()` 하거나 단위 테스트(`require.main` 가드로 노출한 14종 순수 함수)에서 불러오면 호스트 프로세스의 warning 리스너가 통째로 제거되고 NODE_OPTIONS 가 변형됨 → side-effect-free import 원칙 위반.
9
+
10
+ ### 구현 (Codex #4 → 수렴)
11
+ 1. **`_cliBootstrap()` 로 CLI 전용 부작용 격리** — warning listener 제거/재등록 + NODE_OPTIONS 변형 + `_ensureStdoutEncoding()` 호출을 한 함수로 묶고, 파일 끝의 기존 `if (require.main === module)` 가드(1.9.255)와 동일하게 **상단에서도 `if (require.main === module) _cliBootstrap();`** 로만 호출.
12
+ 2. **`_ensureStdoutEncoding()` IIFE → named 함수** — 즉시실행 제거, `_cliBootstrap` 내부에서만 호출 (chcp/encoding 부작용도 CLI 한정).
13
+ 3. selftest 37→38 (소스 가드 정합 + named 함수 존재 검증) · e2e 234→235 (깨끗한 자식에서 require 후 warning listener 보존 + NODE_OPTIONS 미오염 실측).
14
+
15
+ ### 검증
16
+ - **selftest 38/38 PASS** · **E2E 235/235 PASS** (회귀 0).
17
+ - 실측: `node -e "process.on('warning',L); require('harness'); ..."` → listener 보존 `true` · NODE_OPTIONS 오염 `false`. CLI(`selftest`/`--version`)는 부트스트랩 정상 실행.
18
+ - **🎉 Codex gpt-5.5 코드 리뷰 5건(#1 MCP policy / #2 release dry-run / #3 셸 주입 / #4 side effect / #5 도구수) 전부 수렴 완료.**
19
+
3
20
  ## 1.9.289 — 2026-06-03 — UR-0036 (Codex #3): REPL agy/copilot 프롬프트 셸 주입 차단
4
21
 
5
22
  **🔒 REPL 스트리밍에서 agy/copilot 프롬프트가 `shell:true` 인자로 raw 전달돼 셸 분리/주입되던 보안 갭 수정 (Codex gpt-5.5 #3).**
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.289-green)]() [![tests](https://img.shields.io/badge/e2e-234%2F234-success)]() [![selftest](https://img.shields.io/badge/selftest-37-success)]() [![mcp](https://img.shields.io/badge/MCP--tools-79-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.290-green)]() [![tests](https://img.shields.io/badge/e2e-235%2F235-success)]() [![selftest](https://img.shields.io/badge/selftest-38-success)]() [![mcp](https://img.shields.io/badge/MCP--tools-79-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.289 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
474
+ 이 프로젝트는 Leerness v1.9.290 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
475
475
 
476
476
  ### Core Commands
477
477
 
@@ -513,7 +513,7 @@ leerness memory restore decision <date|title>
513
513
 
514
514
  ### MCP server (외부 AI 통합)
515
515
 
516
- Leerness v1.9.289는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **79개 도구**를 노출:
516
+ Leerness v1.9.290는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **79개 도구**를 노출:
517
517
 
518
518
  ```jsonc
519
519
  // 카테고리별
@@ -534,7 +534,7 @@ Leerness v1.9.289는 stdio JSON-RPC MCP server를 내장합니다 — Claude Cod
534
534
  `<<autonomous-loop-dynamic>>` 신호만 보내면 AI가:
535
535
  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) 다음 라운드 예약.
536
536
 
537
- 현재 누적: **70 라운드 (1.9.40 → 1.9.289)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
537
+ 현재 누적: **70 라운드 (1.9.40 → 1.9.290)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
538
538
 
539
539
  ### 성능 가이드 (1.9.140 측정)
540
540
 
@@ -572,6 +572,6 @@ leerness release pack --close --auto-main-push
572
572
  - `.harness/session-handoff.md`: 다음 세션 인수인계 (자동 작성)
573
573
  - `.harness/lessons.md` / `decisions.md` / `rules.md`: 영구 메모리 (5 surface)
574
574
 
575
- Last synced by Leerness v1.9.289: 2026-06-03
575
+ Last synced by Leerness v1.9.290: 2026-06-03
576
576
  <!-- leerness:project-readme:end -->
577
577
 
package/bin/harness.js CHANGED
@@ -10,33 +10,17 @@ const readline = require('readline');
10
10
  const { _isSecretKey, compareVer, parseHarnessVersion, _classifyCJK, _riskLabel, _detectSystemLang, _parseSlashFromHelp,
11
11
  PERMISSION_TIERS, _tierRank, _requiredTier, _policyAllows, _resolveNpmTag, _mcpJsonContent, _newRunRecord } = require('../lib/pure-utils');
12
12
 
13
- const VERSION = '1.9.289';
14
-
15
- // 1.9.184: DEP0190 (child_process shell: true) deprecation warning 억제 (사용자 명시).
16
- // leerness cross-platform PATH resolution 위해 shell: true 의도적으로 사용 (claude.cmd / ollama.cmd Windows .cmd 처리).
17
- // 인자 escape 필요한 위치는 검증된 입력만 spawnSync 전달. REPL agent 진입 시 _checkAgent 가 발산하는 노이즈 제거.
18
- process.removeAllListeners('warning');
19
- process.on('warning', (w) => {
20
- if (w && (w.code === 'DEP0190' || /DEP0190/.test(String(w.message || '')))) return;
21
- process.stderr.write(`(node:${process.pid}) ${w.name || 'Warning'}: ${w.message || w}\n`);
22
- });
23
- // 1.9.185 (사용자 명시): REPL 진입 후 user input 시점에도 DEP0190 발생 (claude/ollama CLI 가 Node 자식 spawn 시 자식의 노이즈).
24
- // 부모 핸들러는 자식에 상속 X → NODE_OPTIONS=--no-deprecation 으로 모든 Node child 까지 전파.
25
- // process.env 변경은 자식 spawn 시 상속 (이미 시작된 부모에는 영향 X, 부모는 위의 'warning' 핸들러로 처리).
26
- if (!/--no-deprecation/.test(process.env.NODE_OPTIONS || '')) {
27
- process.env.NODE_OPTIONS = ((process.env.NODE_OPTIONS || '') + ' --no-deprecation').trim();
28
- }
29
-
30
- // 1.9.249 (사용자 명시 UR-0018): 터미널 출력 한국어 깨짐 사전 방지
31
- // 사용자 보고: protected-files.md 같은 한국어 텍스트가 ? / 한자 조각으로 깨짐 (UTF-8 → CP949 오인식)
32
- // 조치: (1) stdout/stderr UTF-8 명시 (2) Windows + 한국어 OS + 비-65001 코드페이지 시 chcp 65001 자동 시도
33
- // 안전: 1회만 시도 (LEERNESS_NO_AUTOCHCP=1 로 opt-out), 실패 시 무시
34
- (function _ensureStdoutEncoding() {
13
+ const VERSION = '1.9.290';
14
+
15
+ // 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
16
+ // 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE top-level 즉시 실행 require('harness') 호스트 프로세스 오염.
17
+ // 해결: 부작용을 _cliBootstrap() 으로 묶고 파일 require.main 가드에서만 호출. import/단위테스트는 부작용 0.
18
+ // 1.9.249 (UR-0018): 터미널 출력 한국어 깨짐 사전 방지 (stdout UTF-8 + Windows 비-65001 시 chcp 65001 자동, opt-out LEERNESS_NO_AUTOCHCP=1).
19
+ function _ensureStdoutEncoding() {
35
20
  try {
36
21
  if (process.stdout && process.stdout.setEncoding) process.stdout.setEncoding('utf8');
37
22
  if (process.stderr && process.stderr.setEncoding) process.stderr.setEncoding('utf8');
38
23
  } catch {}
39
- // Windows + 한국어 사용자 환경 (chcp 949 = CP949) → 한국어 콘솔 자동 65001 (UTF-8)
40
24
  if (process.platform !== 'win32') return;
41
25
  if (process.env.LEERNESS_NO_AUTOCHCP === '1') return;
42
26
  if (process.env._LEERNESS_CHCP_DONE === '1') return; // 자식 spawn 무한 재호출 방지
@@ -47,7 +31,6 @@ if (!/--no-deprecation/.test(process.env.NODE_OPTIONS || '')) {
47
31
  const code = m ? parseInt(m[1], 10) : null;
48
32
  // 65001 = UTF-8, 949 = CP949 (한국), 932 = CP932 (일본), 936 = CP936 (중국)
49
33
  if (code && code !== 65001) {
50
- // 자동 chcp 65001 시도 (실패해도 무시 — 출력 방향 X 인 비-TTY 등)
51
34
  try {
52
35
  cp.spawnSync('chcp.com', ['65001'], { encoding: 'utf8', timeout: 2000, shell: true, stdio: 'ignore' });
53
36
  process.env._LEERNESS_AUTOCHCP_APPLIED = String(code); // 진단용 — handoff body 에서 노출
@@ -55,7 +38,21 @@ if (!/--no-deprecation/.test(process.env.NODE_OPTIONS || '')) {
55
38
  }
56
39
  process.env._LEERNESS_CHCP_DONE = '1';
57
40
  } catch {}
58
- })();
41
+ }
42
+ // 1.9.184/185: DEP0190 (shell:true) 경고 억제 — cross-platform .cmd resolution 위해 shell:true 의도 사용.
43
+ // warning listener 제거 + NODE_OPTIONS=--no-deprecation (자식 spawn 까지 전파). CLI 전용 → _cliBootstrap 내부.
44
+ function _cliBootstrap() {
45
+ process.removeAllListeners('warning');
46
+ process.on('warning', (w) => {
47
+ if (w && (w.code === 'DEP0190' || /DEP0190/.test(String(w.message || '')))) return;
48
+ process.stderr.write(`(node:${process.pid}) ${w.name || 'Warning'}: ${w.message || w}\n`);
49
+ });
50
+ if (!/--no-deprecation/.test(process.env.NODE_OPTIONS || '')) {
51
+ process.env.NODE_OPTIONS = ((process.env.NODE_OPTIONS || '') + ' --no-deprecation').trim();
52
+ }
53
+ _ensureStdoutEncoding();
54
+ }
55
+ if (require.main === module) _cliBootstrap();
59
56
 
60
57
  const MARK = '<!-- leerness:managed -->';
61
58
  const README_START = '<!-- leerness:project-readme:start -->';
@@ -2999,6 +2996,7 @@ function _selfTestCases() {
2999
2996
  { name: 'ADAPTERS + _mcpJsonContent: 도구 매핑 + .mcp.json 등록 (1.9.280)', run: () => { const ids = Object.keys(ADAPTERS); const okMap = ['claude','cursor','codex','goose','opencode'].every(id => ADAPTERS[id] && Array.isArray(ADAPTERS[id].keys) && ADAPTERS[id].keys.length); const m = JSON.parse(_mcpJsonContent()); return ids.length >= 9 && okMap && ADAPTERS.claude.mcp === true && ADAPTERS.copilot.mcp === false && m.mcpServers.leerness.command === 'npx' && m.mcpServers.leerness.args.join(' ') === 'leerness mcp serve'; } },
3000
2997
  { name: '_newRunRecord: GPT-5.5 권고 스키마 14필드 + 기본값 (1.9.278)', run: () => { const r = _newRunRecord({ run_id: 'run-0001', goal: 'g', started_at: '2026-06-03T00:00:00Z' }); return r.schemaVersion === 1 && r.run_id === 'run-0001' && r.started_at === '2026-06-03T00:00:00Z' && Array.isArray(r.files_changed) && Array.isArray(r.commands_run) && Array.isArray(r.tests_run) && Array.isArray(r.decisions) && r.verification_result === null && r.status === 'in-progress' && 'handoff_summary' in r && 'model_name' in r && 'task_id' in r; } },
3001
2998
  { name: 'coreFiles --minimal: 핵심 유지 + 비핵심 제외 + verify 필수 보존 (1.9.276)', run: () => { const full = coreFiles('.', 'ko', []); const min = coreFiles('.', 'ko', [], { minimal: true }); const keep = ['.harness/plan.md','.harness/progress-tracker.md','.harness/session-handoff.md','AGENTS.md','CLAUDE.md','.harness/consistency-policy.md','.harness/reuse-map.md','.harness/encoding-policy.md','.harness/secret-policy.md']; const drop = ['.cursor/rules/leerness.mdc','.harness/skill-index.md','.harness/architecture.md']; const verifyReq = ['.harness/design-system.md','.harness/protected-files.md','.harness/current-state.md']; if (!verifyReq.every(k => min[k])) return false; return Object.keys(min).length < Object.keys(full).length && keep.every(k => min[k]) && drop.every(k => !min[k]); } },
2999
+ { name: '_cliBootstrap: CLI 부작용 require.main 가드 격리 (Codex #4 UR-0037 1.9.290)', run: () => { if (typeof _cliBootstrap !== 'function' || typeof _ensureStdoutEncoding !== 'function') return false; const src = read(__filename); const guarded = /if \(require\.main === module\) _cliBootstrap\(\);/.test(src); const inFn = /function _cliBootstrap\(\)\s*\{[\s\S]*?removeAllListeners\('warning'\)[\s\S]*?NODE_OPTIONS[\s\S]*?_ensureStdoutEncoding\(\);[\s\S]*?\n\}/.test(src); const noTopIife = !/\}\)\(\);\s*\n\n\/\/ 1\.9\.184/.test(src); return guarded && inFn && noTopIife; } },
3002
3000
  { name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
3003
3001
  ];
3004
3002
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leerness",
3
- "version": "1.9.289",
3
+ "version": "1.9.290",
4
4
  "description": "Leerness: 비파괴 마이그레이션, 자동 버전 감지·업데이트, 계획/진행/핸드오프 자동화, 게으름·시크릿·인코딩 자동 가드, Claude Code 슬래시 통합을 갖춘 한국어 우선 AI 개발 하네스.",
5
5
  "keywords": [
6
6
  "leerness",
package/scripts/e2e.js CHANGED
@@ -3096,5 +3096,24 @@ total++;
3096
3096
  if (!ok) failed++;
3097
3097
  }
3098
3098
 
3099
+ // 1.9.290 회귀 (Codex #4 UR-0037): require('harness') 가 호스트 프로세스 오염 X (top-level side effect 격리)
3100
+ total++;
3101
+ {
3102
+ let ok = false;
3103
+ try {
3104
+ // 깨끗한 자식에서: 내 warning listener 등록 → require → 보존 확인 + NODE_OPTIONS 미변경
3105
+ const probe = "const L=()=>{};process.on('warning',L);const o=process.env.NODE_OPTIONS||'';" +
3106
+ "require(process.argv[1]);" +
3107
+ "const survived=process.listeners('warning').includes(L);" +
3108
+ "const polluted=(process.env.NODE_OPTIONS||'')!==o;" +
3109
+ "process.exit(survived&&!polluted?0:1);";
3110
+ const harnessPath = path.resolve(__dirname, '..', 'bin', 'harness.js');
3111
+ const r = cp.spawnSync(process.execPath, ['-e', probe, harnessPath], { encoding: 'utf8', timeout: 20000 });
3112
+ ok = r.status === 0;
3113
+ } catch {}
3114
+ console.log(ok ? '✓ B(1.9.290) require 부작용 격리: warning listener 보존 + NODE_OPTIONS 미오염 (Codex #4)' : '✗ require 부작용 격리 실패');
3115
+ if (!ok) failed++;
3116
+ }
3117
+
3099
3118
  console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
3100
3119
  if (failed > 0) process.exit(1);