leerness 1.9.396 → 1.9.398

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,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.398 — 2026-06-07 — --json 에러 경로 구조화 (6번째 외부평가 P1-C, UR-0099)
4
+
5
+ **🔌 `--json` 모드에서 에러도 구조화 JSON(`{ok:false,error,code}`) — AI 에이전트가 에러 경로에서 JSON.parse 실패하지 않도록.**
6
+
7
+ ### 배경 (6번째 외부평가 codex P1-C · UR-0085/0088 의 에러판)
8
+ codex: `contract verify --json`(인자 누락) / `feature show F-9999 --json`(없는 ID) 등이 에러 시 사람용 텍스트(`✗ ...`)를 출력 → 자동화가 JSON.parse 크래시. UR-0085/0088 이 성공/빈 경로를 구조화했으나 **에러 경로**가 남아 있었음.
9
+
10
+ ### 구현
11
+ - `failJson(jsonMode, code, msg)` 헬퍼 신규(lib/io.js): jsonMode 면 `{ok:false,error,code}` + exit1, 아니면 사람용 `fail()`. 양쪽 exit 1.
12
+ - 적용: `contract verify`(missing_args/spec_not_found/impl_not_found), `feature show`/`feature impact`(bad_id/not_found). 사람용 출력 무변경.
13
+
14
+ ### 검증 (회귀 0)
15
+ - **selftest 143→144 PASS** (failJson reference-equality + json/human 분기 + exit1 + 와이어).
16
+ - **E2E 336→337 PASS** (contract verify --json → code:missing_args / feature show --json → code:not_found, 둘 다 exit1 + 사람용 텍스트 보존).
17
+
18
+ ## 1.9.397 — 2026-06-06 — install-safety 레시피 셸-무관화 (6번째 외부평가 P1-A, UR-0098)
19
+
20
+ **🪟 install-safety 안전설치 레시피를 셸-무관으로 — Windows PowerShell(주환경)에서 깨지던 POSIX env-prefix 제거.**
21
+
22
+ ### 배경 (6번째 외부평가 codex P1-A · 비판검토 후 채택)
23
+ codex 가 레시피의 `npm_config_ignore_scripts=true npx ...`(bash env-prefix)가 PowerShell 에서 실패한다고 지적. **직접 검토**: PowerShell 비호환은 실문제(Windows 주환경)이나 "update 단계 ignore-scripts 누락"은 저가치(leerness 는 0 deps/0 install-script 라 실행될 스크립트 없음). → **셸 호환만 핵심 수정**.
24
+
25
+ ### 구현
26
+ - safeInstall 레시피: `npm_config_x=true npx ...`(POSIX) → `npx --yes leerness@latest ...`(셸 무관). PowerShell/cmd/bash 모두 동작.
27
+ - `hardeningNote` 신규: leerness 자체 0-script 명시 + 일반 npx 하드닝(타 패키지 대비)을 셸별로 안내(bash/PowerShell/cmd). 사람용 출력에도 노출.
28
+
29
+ ### 검증 (회귀 0)
30
+ - **selftest 142→143 PASS** (safeInstall 에 POSIX env-prefix 부재 + npx --yes 2건 + hardeningNote PowerShell 언급).
31
+ - **E2E 335→336 PASS** (install-safety --json 셸-무관 + hardeningNote).
32
+
3
33
  ## 1.9.396 — 2026-06-06 — 6번째 외부 멀티모델 리뷰 + task drop 데이터 손상 수정 (UR-0097)
4
34
 
5
35
  **🔬 6번째 외부 클린룸 리뷰(codex GPT-5.5 + Opus) — findings 7건 등록 + 최우선 데이터 손상(task drop) 즉시 수정.**
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.396-green)]() [![tests](https://img.shields.io/badge/e2e-335%2F335-success)]() [![selftest](https://img.shields.io/badge/selftest-142-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.398-green)]() [![tests](https://img.shields.io/badge/e2e-337%2F337-success)]() [![selftest](https://img.shields.io/badge/selftest-144-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.396 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
474
+ 이 프로젝트는 Leerness v1.9.398 하네스를 사용합니다. 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.396는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **85개 도구**를 노출:
528
+ Leerness v1.9.398는 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.396는 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.396)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
549
+ 현재 누적: **70 라운드 (1.9.40 → 1.9.398)** · 매 라운드 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.396: 2026-06-06
587
+ Last synced by Leerness v1.9.398: 2026-06-06
588
588
  <!-- leerness:project-readme:end -->
589
589
 
package/bin/harness.js CHANGED
@@ -4,7 +4,7 @@
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const cp = require('child_process');
7
- const { log, ok, warn, fail, today, now, absRoot, exists, read, readBuf, mkdirp, writeUtf8, append, rel } = require('../lib/io'); // 1.9.382/383 (UR-0025): 출력/시간/파일 프리미티브 공유 모듈
7
+ const { log, ok, warn, fail, failJson, today, now, absRoot, exists, read, readBuf, mkdirp, writeUtf8, append, rel } = require('../lib/io'); // 1.9.382/383 (UR-0025): 출력/시간/파일 프리미티브 공유 모듈
8
8
  const os = require('os'); // 1.9.178: _publishToNpm 에서 os.tmpdir() 사용 (전역 import)
9
9
  const readline = require('readline');
10
10
  // 1.9.274 (UR-0025 1단계): 순수 유틸 함수 모듈 분리 (require-based, 비파괴). selftest 7종이 동작 검증.
@@ -31,7 +31,7 @@ const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInG
31
31
  // 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
32
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 포함)
33
33
 
34
- const VERSION = '1.9.396';
34
+ const VERSION = '1.9.398';
35
35
 
36
36
  // 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
37
37
  // 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
@@ -3001,6 +3001,8 @@ function _selfTestCases() {
3001
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; } },
3002
3002
  { name: '회귀가드: decisions/lessons canonical round-trip 엣지문자(pipe/dash/colon) 무손상 + idempotent (1.9.395)', run: () => { const m = require('../lib/pure-utils'); const d = [{ date: '2026-06-06', title: 'A | pipe', decision: 'use X | Y', reason: 'r—dash', alternatives: 'alt: colon', impact: 'i' }]; const dback = m._decisionsFromMd(m._renderDecisionsMd(d)); const dOk = dback.length === 1 && dback[0].title === 'A | pipe' && dback[0].decision === 'use X | Y' && dback[0].reason === 'r—dash'; const dIdem = JSON.stringify(dback) === JSON.stringify(m._decisionsFromMd(m._renderDecisionsMd(dback))); const l = [{ date: '2026-06-06', text: 'lesson | with — chars: ok', tag: 't' }]; const lback = m._parseLessonEntries(m._renderLessonsMd(l)); const lOk = lback.length === 1 && lback[0].text === 'lesson | with — chars: ok'; const lIdem = JSON.stringify(lback) === JSON.stringify(m._parseLessonEntries(m._renderLessonsMd(lback))); return dOk && dIdem && lOk && lIdem; } },
3003
3003
  { name: '6번째 외부평가/codex P1-B: task drop 존재확인 가드 — 없는 ID 가짜 row 방지 (1.9.396)', run: () => { const src = read(__filename); const i = src.indexOf('function taskDrop(root, id)'); if (i < 0) return false; const body = src.slice(i, i + 700); return body.includes('not found in progress-tracker.md') && body.includes('rows.find(r => r.id === id)') && body.includes('_requireInit'); } },
3004
+ { name: '6번째 외부평가/codex P1-A (UR-0098): install-safety 레시피 셸-무관 + hardeningNote (1.9.397)', run: () => { if (typeof installSafetyCmd !== 'function') return false; const save = process.argv; const _w = process.stdout.write; let out = ''; try { process.argv = ['node', 'h', 'install-safety', '--json']; process.stdout.write = s => { out += s; return true; }; installSafetyCmd({ json: true }); } catch {} finally { process.stdout.write = _w; process.argv = save; } let j; try { j = JSON.parse(out); } catch {} const noPosixPrefix = !!j && Array.isArray(j.safeInstall) && !j.safeInstall.some(x => /^npm_config_\w+=/.test(String(x).trim())); const crossShell = !!j && j.safeInstall.filter(x => String(x).includes('npx --yes')).length >= 2; const noteOk = !!j && typeof j.hardeningNote === 'string' && j.hardeningNote.includes('PowerShell'); return noPosixPrefix && crossShell && noteOk; } },
3005
+ { name: '6번째 외부평가/codex P1-C (UR-0099): --json 에러 경로 구조화 failJson + 와이어 (1.9.398)', run: () => { const io = require('../lib/io'); if (io.failJson !== failJson) return false; const _w = process.stdout.write; const saved = process.exitCode; let jOut = '', hOut = ''; let jExit = 0; try { process.stdout.write = s => { jOut += s; return true; }; process.exitCode = 0; failJson(true, 'tc', 'm'); jExit = process.exitCode; process.stdout.write = s => { hOut += s; return true; }; process.exitCode = 0; failJson(false, 'c', 'humanmsg'); } catch {} finally { process.stdout.write = _w; process.exitCode = saved; } let pj; try { pj = JSON.parse(jOut); } catch {} const jsonOk = !!pj && pj.ok === false && pj.code === 'tc' && pj.error === 'm' && jExit === 1; const humanOk = hOut.includes('✗') && hOut.includes('humanmsg') && !hOut.includes('{'); const src = read(__filename); const wired = src.includes("failJson(_j, 'missing_args'") && src.includes("failJson(_j, 'spec_not_found'"); return jsonOk && humanOk && wired; } },
3004
3006
  { name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
3005
3007
  ];
3006
3008
  }
@@ -6710,12 +6712,16 @@ function installSafetyCmd(opts = {}) {
6710
6712
  hasInstallScripts: installHooks.length > 0,
6711
6713
  node: (pkg.engines && pkg.engines.node) || null,
6712
6714
  offlineFirst: true,
6715
+ // 1.9.397 (6번째 외부평가/codex P1-A, UR-0098): 레시피를 셸-무관으로 — 종전 'npm_config_x=true npx'(POSIX env-prefix)는
6716
+ // PowerShell(Windows 주환경)에서 실패. leerness 는 0 deps/0 install-script 라 npx 시 실행될 스크립트 자체가 없어 prefix 불필요.
6717
+ // 타 패키지 대비 일반 하드닝은 셸별로 hardeningNote 참조.
6713
6718
  safeInstall: [
6714
6719
  'git checkout -b chore/leerness-update',
6715
- 'npm_config_ignore_scripts=true npx leerness@latest migrate plan --path . # 임시폴더 비교(읽기 전용)',
6716
- 'npx leerness@latest update --yes --path .',
6720
+ 'npx --yes leerness@latest migrate plan --path . # 임시폴더 비교(읽기 전용, 셸 무관)',
6721
+ 'npx --yes leerness@latest update --yes --path .',
6717
6722
  'git diff # 변경 검토 후 커밋 또는 롤백',
6718
6723
  ],
6724
+ hardeningNote: 'leerness 자체는 0 deps / 0 install-script 라 설치/업데이트 시 임의코드 실행 없음. 일반 npx 하드닝(타 패키지 대비)은 셸별 — bash: npm_config_ignore_scripts=true npx ... · PowerShell: $env:npm_config_ignore_scripts=1; npx ... · cmd: set npm_config_ignore_scripts=1 && npx ...',
6719
6725
  };
6720
6726
  if (opts.json) { log(JSON.stringify(profile, null, 2)); return; }
6721
6727
  log(`# leerness install-safety (1.9.359) — 설치 안전 프로필`);
@@ -6725,6 +6731,7 @@ function installSafetyCmd(opts = {}) {
6725
6731
  log(` 동작 방식: offline-first (설치 시 네트워크/빌드 불필요, 단일 bin + lib)`);
6726
6732
  log(`\n 안전 설치 워크플로 (검토 후 적용):`);
6727
6733
  profile.safeInstall.forEach((s, i) => log(` ${i + 1}. ${s}`));
6734
+ log(`\n ⓘ ${profile.hardeningNote}`); // 1.9.397 (UR-0098): 셸별 하드닝 노트
6728
6735
  if (installHooks.length > 0) warn('install-time 스크립트 존재 — 위 ignore-scripts safe-install 권장');
6729
6736
  }
6730
6737
  function debug(root) {
@@ -19687,12 +19694,14 @@ function taskSyncCmd(root) {
19687
19694
  // 사양 문서(spec.md)에 명시된 함수 이름이 실제 module.exports에 모두 있는지 검사.
19688
19695
  // 사용 예: leerness contract verify TICK_SPEC.md src/format.js
19689
19696
  function contractVerifyCmd(specPath, implPath) {
19690
- if (!specPath || !implPath) { fail('사용법: leerness contract verify <spec.md> <impl.js>'); return process.exit(1); }
19697
+ // 1.9.398 (6번째 외부평가/codex P1-C, UR-0099): --json 모드 에러는 구조화 출력(텍스트 대신) AI 에이전트 JSON.parse 보호.
19698
+ const _j = has('--json');
19699
+ if (!specPath || !implPath) { failJson(_j, 'missing_args', '사용법: leerness contract verify <spec.md> <impl.js>'); return process.exit(process.exitCode || 1); }
19691
19700
  const spec = absRoot('.') + path.sep; // dummy to avoid abs
19692
19701
  const specFile = path.resolve(specPath);
19693
19702
  const implFile = path.resolve(implPath);
19694
- if (!exists(specFile)) { fail(`spec 파일 없음: ${specFile}`); return process.exit(1); }
19695
- if (!exists(implFile)) { fail(`impl 파일 없음: ${implFile}`); return process.exit(1); }
19703
+ if (!exists(specFile)) { failJson(_j, 'spec_not_found', `spec 파일 없음: ${specFile}`); return process.exit(process.exitCode || 1); }
19704
+ if (!exists(implFile)) { failJson(_j, 'impl_not_found', `impl 파일 없음: ${implFile}`); return process.exit(process.exitCode || 1); }
19696
19705
  const specText = read(specFile);
19697
19706
  // 1.9.385 (UR-0086, 5th외부평가): spec 함수/필드 추출을 순수 파서 _parseContractSpec 로 위임.
19698
19707
  // declared(강선언): function 시그니처 + markdown bullet "- name(args)" — 누락검사 대상.
package/lib/feature.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // - feature-graph I/O 헬퍼(_readFeatureGraph/_writeFeatureGraph/_ensureFeatureGraph)는 audit/health/handoff 등도 쓰는
5
5
  // 공유 함수라 harness 에 유지하고 deps 로 주입(DI). argv 파서 arg/has 도 주입.
6
6
  'use strict';
7
- const { absRoot, log, ok, warn, fail } = require('./io');
7
+ const { absRoot, log, ok, warn, fail, failJson } = require('./io');
8
8
  const { _nextFeatureId, _featureImpactBfs } = require('./pure-utils');
9
9
 
10
10
  function featureAddCmd(root, title, deps = {}) {
@@ -56,10 +56,11 @@ function featureLinkCmd(root, fromId, deps = {}) {
56
56
  function featureImpactCmd(root, fromId, deps = {}) {
57
57
  const { _readFeatureGraph, has } = deps;
58
58
  root = absRoot(root);
59
- if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature impact: F-XXXX ID 필요');
59
+ const _j = has('--json'); // 1.9.398 (UR-0099): --json 에러 구조화
60
+ if (!fromId || !/^F-\d{4}$/.test(fromId)) return failJson(_j, 'bad_id', 'feature impact: F-XXXX ID 필요');
60
61
  const { nodes } = _readFeatureGraph(root);
61
62
  const node = nodes.find(n => n.id === fromId);
62
- if (!node) return fail(`feature ${fromId} 없음`);
63
+ if (!node) return failJson(_j, 'not_found', `feature ${fromId} 없음`);
63
64
  const impacted = _featureImpactBfs(nodes, fromId);
64
65
  if (has('--json')) {
65
66
  log(JSON.stringify({ feature: { id: node.id, title: node.title }, total: impacted.length, impacted }, null, 2));
@@ -98,10 +99,11 @@ function featureListCmd(root, deps = {}) {
98
99
  function featureShowCmd(root, fromId, deps = {}) {
99
100
  const { _readFeatureGraph, has } = deps;
100
101
  root = absRoot(root);
101
- if (!fromId || !/^F-\d{4}$/.test(fromId)) return fail('feature show: F-XXXX ID 필요');
102
+ const _j = has('--json'); // 1.9.398 (UR-0099): --json 에러 구조화
103
+ if (!fromId || !/^F-\d{4}$/.test(fromId)) return failJson(_j, 'bad_id', 'feature show: F-XXXX ID 필요');
102
104
  const { nodes } = _readFeatureGraph(root);
103
105
  const node = nodes.find(n => n.id === fromId);
104
- if (!node) return fail(`feature ${fromId} 없음`);
106
+ if (!node) return failJson(_j, 'not_found', `feature ${fromId} 없음`);
105
107
  if (has('--json')) { log(JSON.stringify(node, null, 2)); return; }
106
108
  log(`# ${node.id} · ${node.title}`);
107
109
  log(` depends-on: ${node.dependsOn.join(', ') || '(없음)'}`);
package/lib/io.js CHANGED
@@ -11,6 +11,12 @@ function ok(s) { log('✓ ' + s); }
11
11
  function warn(s) { log('⚠ ' + s); }
12
12
  // fail() 은 오류 신호 → exit code 1 설정 (CI/MCP/에이전트가 실패를 성공으로 오판 방지, UR-0045).
13
13
  function fail(s) { log('✗ ' + s); process.exitCode = 1; }
14
+ // 1.9.398 (6번째 외부평가/codex P1-C, UR-0099): --json 모드 에러는 구조화 출력 — AI 에이전트가 에러 경로에서 JSON.parse 실패하지 않도록.
15
+ // jsonMode 면 {ok:false,error,code} + exit1, 아니면 사람용 fail(). 양쪽 exit code 1 일관.
16
+ function failJson(jsonMode, code, msg) {
17
+ if (jsonMode) { log(JSON.stringify({ ok: false, error: msg, code }, null, 2)); process.exitCode = 1; }
18
+ else fail(msg);
19
+ }
14
20
  function today() { return new Date().toISOString().slice(0, 10); }
15
21
  function now() { return new Date().toISOString(); }
16
22
 
@@ -40,4 +46,4 @@ function writeUtf8(p, s) {
40
46
  function append(p, s) { mkdirp(path.dirname(p)); fs.appendFileSync(p, s, 'utf8'); }
41
47
  function rel(root, p) { return path.relative(root, p).replace(/\\/g, '/') || '.'; }
42
48
 
43
- module.exports = { log, ok, warn, fail, today, now, absRoot, exists, read, readBuf, mkdirp, writeUtf8, append, rel };
49
+ module.exports = { log, ok, warn, fail, failJson, today, now, absRoot, exists, read, readBuf, mkdirp, writeUtf8, append, rel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leerness",
3
- "version": "1.9.396",
3
+ "version": "1.9.398",
4
4
  "description": "Leerness: 비파괴 마이그레이션, 자동 버전 감지·업데이트, 계획/진행/핸드오프 자동화, 게으름·시크릿·인코딩 자동 가드, Claude Code 슬래시 통합을 갖춘 한국어 우선 AI 개발 하네스.",
5
5
  "keywords": [
6
6
  "leerness",
package/scripts/e2e.js CHANGED
@@ -5521,5 +5521,42 @@ total++;
5521
5521
  if (!ok) failed++;
5522
5522
  }
5523
5523
 
5524
+ // 1.9.397 회귀 (6번째 외부평가/codex P1-A, UR-0098): install-safety 레시피 셸-무관(POSIX env-prefix 제거) + hardeningNote
5525
+ total++;
5526
+ {
5527
+ let ok = false;
5528
+ try {
5529
+ const r = cp.spawnSync(process.execPath, [CLI, 'install-safety', '--json'], { encoding: 'utf8', timeout: 10000 });
5530
+ const j = JSON.parse(r.stdout);
5531
+ const noPosix = Array.isArray(j.safeInstall) && !j.safeInstall.some(x => /^npm_config_\w+=/.test(String(x).trim())); // PowerShell 비호환 prefix 부재
5532
+ const crossShell = j.safeInstall.filter(x => String(x).includes('npx --yes')).length >= 2;
5533
+ const note = typeof j.hardeningNote === 'string' && j.hardeningNote.includes('PowerShell');
5534
+ ok = noPosix && crossShell && note;
5535
+ } catch {}
5536
+ console.log(ok ? '✓ B(1.9.397) 6th외부평가 codex P1-A: install-safety 레시피 셸-무관 + hardeningNote (UR-0098)' : '✗ install-safety 셸호환 실패');
5537
+ if (!ok) failed++;
5538
+ }
5539
+
5540
+ // 1.9.398 회귀 (6번째 외부평가/codex P1-C, UR-0099): --json 에러 경로가 구조화 JSON(텍스트 아님) + 사람용 보존
5541
+ total++;
5542
+ {
5543
+ let ok = false;
5544
+ try {
5545
+ const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-jsonerr-'));
5546
+ cp.spawnSync(process.execPath, [CLI, 'init', d, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
5547
+ const cv = cp.spawnSync(process.execPath, [CLI, 'contract', 'verify', '--json'], { encoding: 'utf8', timeout: 10000 });
5548
+ const cj = JSON.parse(cv.stdout); const cvOk = cj.ok === false && cj.code === 'missing_args' && cv.status === 1;
5549
+ const fsr = cp.spawnSync(process.execPath, [CLI, 'feature', 'show', 'F-9999', '--path', d, '--json'], { encoding: 'utf8', timeout: 10000 });
5550
+ const fj = JSON.parse(fsr.stdout); const fsOk = fj.ok === false && fj.code === 'not_found' && fsr.status === 1;
5551
+ // 사람용 보존: --json 없이 텍스트(JSON 아님) + exit1
5552
+ const fh = cp.spawnSync(process.execPath, [CLI, 'feature', 'show', 'F-9999', '--path', d], { encoding: 'utf8', timeout: 10000 });
5553
+ const humanOk = fh.status === 1 && /✗/.test(fh.stdout || '') && !/^\s*\{/.test(fh.stdout || '');
5554
+ fs.rmSync(d, { recursive: true, force: true });
5555
+ ok = cvOk && fsOk && humanOk;
5556
+ } catch {}
5557
+ console.log(ok ? '✓ B(1.9.398) 6th외부평가 codex P1-C: --json 에러 경로 구조화(contract verify/feature show) + 사람용 보존 (UR-0099)' : '✗ --json 에러 경로 실패');
5558
+ if (!ok) failed++;
5559
+ }
5560
+
5524
5561
  console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
5525
5562
  if (failed > 0) process.exit(1);