leerness 1.9.397 → 1.9.399
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 +36 -0
- package/README.md +5 -5
- package/bin/harness.js +18 -10
- package/lib/feature.js +7 -5
- package/lib/io.js +7 -1
- package/lib/pure-utils.js +8 -1
- package/package.json +1 -1
- package/scripts/e2e.js +47 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.399 — 2026-06-07 — 테이블셀 injection 차단: task/rule 파이프·개행 (7번째 버그헌트 P1-A, UR-0104)
|
|
4
|
+
|
|
5
|
+
**🛡 데이터 무결성 — task/rule 텍스트의 파이프(|)·개행(\\n)이 progress-tracker/rules.md 표를 손상·가짜행 주입·멱등성 무력화하던 것을 차단(셀 이스케이프).**
|
|
6
|
+
|
|
7
|
+
### 배경 (7번째 — 내부 멀티에이전트 버그헌트, 외부리뷰 초월)
|
|
8
|
+
38 에이전트 포괄 버그헌트(31후보→confirmed 30/refuted 1)가 외부 리뷰(codex/Opus)가 못 본 **테이블셀 injection 클래스**를 발견. 직접 재현 검증:
|
|
9
|
+
- `task add 'fix login | bypass'` → progress-tracker 행 컬럼 시프트, update 시 영구 절단(JSON 백업 없음).
|
|
10
|
+
- `task add '...\\n| T-9999 | done | ...'` → 가짜 done 행 주입 + 실제 task 무성 소실.
|
|
11
|
+
- `rule add 'a | b'` → rules.md 컬럼 밀림 + dedup(1.9.212) 무력화로 중복 룰 무한 생성.
|
|
12
|
+
|
|
13
|
+
### 구현
|
|
14
|
+
- **`_cellSafe`/`_cellUnescape`** 순수 헬퍼(lib/pure-utils.js): 쓰기 시 개행→공백 + `|`→`\\|`, 읽기 시 비이스케이프 파이프(`/(?<!\\)\\|/`)에서만 분리 후 `\\|`→`|` 복원.
|
|
15
|
+
- 적용: `writeProgressRows`/`readProgressRows`(task) + `writeRules`/`readRules`(rule). 사용자 텍스트의 파이프는 **보존**(복원), 개행은 공백화(행 주입 차단).
|
|
16
|
+
|
|
17
|
+
### 검증 (회귀 0)
|
|
18
|
+
- **selftest 144→145 PASS** (cellSafe/Unescape reference-equality + 파이프 round-trip + 개행 제거 + 와이어).
|
|
19
|
+
- **E2E 337→338 PASS** (task 파이프 보존/개행 가짜행 차단 + rule 파이프 보존/멱등 회복/status 비오염).
|
|
20
|
+
- 실측: `task add 'fix login | bypass'` 원본 보존, 개행 주입 T-9999 차단, rule 중복 add → skip(멱등).
|
|
21
|
+
|
|
22
|
+
### 다음(같은 클러스터): decisions/lessons MD projection 셀 안전화(UR-0104 잔여, JSON canonical 은 이미 안전).
|
|
23
|
+
|
|
24
|
+
## 1.9.398 — 2026-06-07 — --json 에러 경로 구조화 (6번째 외부평가 P1-C, UR-0099)
|
|
25
|
+
|
|
26
|
+
**🔌 `--json` 모드에서 에러도 구조화 JSON(`{ok:false,error,code}`) — AI 에이전트가 에러 경로에서 JSON.parse 실패하지 않도록.**
|
|
27
|
+
|
|
28
|
+
### 배경 (6번째 외부평가 codex P1-C · UR-0085/0088 의 에러판)
|
|
29
|
+
codex: `contract verify --json`(인자 누락) / `feature show F-9999 --json`(없는 ID) 등이 에러 시 사람용 텍스트(`✗ ...`)를 출력 → 자동화가 JSON.parse 크래시. UR-0085/0088 이 성공/빈 경로를 구조화했으나 **에러 경로**가 남아 있었음.
|
|
30
|
+
|
|
31
|
+
### 구현
|
|
32
|
+
- `failJson(jsonMode, code, msg)` 헬퍼 신규(lib/io.js): jsonMode 면 `{ok:false,error,code}` + exit1, 아니면 사람용 `fail()`. 양쪽 exit 1.
|
|
33
|
+
- 적용: `contract verify`(missing_args/spec_not_found/impl_not_found), `feature show`/`feature impact`(bad_id/not_found). 사람용 출력 무변경.
|
|
34
|
+
|
|
35
|
+
### 검증 (회귀 0)
|
|
36
|
+
- **selftest 143→144 PASS** (failJson reference-equality + json/human 분기 + exit1 + 와이어).
|
|
37
|
+
- **E2E 336→337 PASS** (contract verify --json → code:missing_args / feature show --json → code:not_found, 둘 다 exit1 + 사람용 텍스트 보존).
|
|
38
|
+
|
|
3
39
|
## 1.9.397 — 2026-06-06 — install-safety 레시피 셸-무관화 (6번째 외부평가 P1-A, UR-0098)
|
|
4
40
|
|
|
5
41
|
**🪟 install-safety 안전설치 레시피를 셸-무관으로 — Windows PowerShell(주환경)에서 깨지던 POSIX env-prefix 제거.**
|
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.399 하네스를 사용합니다. 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.399는 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.397는 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.399)** · 매 라운드 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.399: 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종이 동작 검증.
|
|
@@ -25,13 +25,13 @@ const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _merg
|
|
|
25
25
|
_withBuiltinSource, _esc, _roadmapTokenStyles, _parseSkillMd,
|
|
26
26
|
_migrationGuideText, _parseContractSpec, _gitignoreMatch,
|
|
27
27
|
_featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock, _featureImpactBfs,
|
|
28
|
-
_parseChangelogBetween } = require('../lib/pure-utils'); // 1.9.318~
|
|
28
|
+
_parseChangelogBetween, _cellSafe, _cellUnescape } = require('../lib/pure-utils'); // 1.9.318~399 (UR-0025/0053/0075/0086/0087/0104): 순수 유틸 모듈 분리
|
|
29
29
|
// 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
|
|
30
30
|
const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
|
|
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.
|
|
34
|
+
const VERSION = '1.9.399';
|
|
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') 시 호스트 프로세스 오염.
|
|
@@ -3002,6 +3002,8 @@ function _selfTestCases() {
|
|
|
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
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; } },
|
|
3006
|
+
{ name: '7번째 버그헌트 P1-A (UR-0104): 테이블셀 안전화 _cellSafe/_cellUnescape (파이프/개행 injection 차단) (1.9.399)', run: () => { const m = require('../lib/pure-utils'); if (m._cellSafe !== _cellSafe || m._cellUnescape !== _cellUnescape) return false; const safe = _cellSafe('fix | bug\nrow2'); const noRaw = !/(?<!\\)\|/.test(safe) && !/[\r\n]/.test(safe); const pipeRt = _cellUnescape(_cellSafe('a | b | c')) === 'a | b | c'; const nlGone = _cellSafe('a\nb') === 'a b'; const src = read(__filename); const wired = src.includes('_cellSafe(r.request)') && src.includes('_cellSafe(r.rule)'); return noRaw && pipeRt && nlGone && wired; } },
|
|
3005
3007
|
{ name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
|
|
3006
3008
|
];
|
|
3007
3009
|
}
|
|
@@ -5831,7 +5833,8 @@ function readProgressRows(root) {
|
|
|
5831
5833
|
const rows = [];
|
|
5832
5834
|
for (const line of text.split('\n')) {
|
|
5833
5835
|
if (!/^\| (?:T|M|D)-\d{4} \|/.test(line)) continue;
|
|
5834
|
-
|
|
5836
|
+
// 1.9.399 (7번째 버그헌트 P1-A, UR-0104): 비이스케이프 파이프에서만 분리 + 셀 복원 — 사용자 텍스트의 '|'(이스케이프됨)이 컬럼을 깨지 않음.
|
|
5837
|
+
const cells = line.split(/(?<!\\)\|/).slice(1, -1).map(s => _cellUnescape(s).trim());
|
|
5835
5838
|
if (cells.length < 6) continue;
|
|
5836
5839
|
const [id, status, request, evidence, nextAction, updated] = cells;
|
|
5837
5840
|
rows.push({ id, status, request, evidence, nextAction, updated });
|
|
@@ -5852,8 +5855,9 @@ function progressHeader(root) {
|
|
|
5852
5855
|
return text.slice(0, text.indexOf('\n', idx)).trimEnd();
|
|
5853
5856
|
}
|
|
5854
5857
|
function writeProgressRows(root, header, rows) {
|
|
5858
|
+
// 1.9.399 (7번째 버그헌트 P1-A, UR-0104): 셀 콘텐츠 안전화 — 개행→공백, '|'→'\|'. 사용자 텍스트의 파이프/개행이 표 행을 손상/주입 못 함.
|
|
5855
5859
|
const composed = header + '\n' +
|
|
5856
|
-
rows.map(r => `| ${r.id} | ${r.status} | ${r.request} | ${r.evidence} | ${r.nextAction} | ${r.updated} |`).join('\n') +
|
|
5860
|
+
rows.map(r => `| ${_cellSafe(r.id)} | ${_cellSafe(r.status)} | ${_cellSafe(r.request)} | ${_cellSafe(r.evidence)} | ${_cellSafe(r.nextAction)} | ${_cellSafe(r.updated)} |`).join('\n') +
|
|
5857
5861
|
(rows.length ? '\n' : '');
|
|
5858
5862
|
writeUtf8(progressPath(root), composed);
|
|
5859
5863
|
}
|
|
@@ -13564,7 +13568,8 @@ function readRules(root) {
|
|
|
13564
13568
|
const rules = [];
|
|
13565
13569
|
for (const line of read(f).split('\n')) {
|
|
13566
13570
|
if (!/^\| R-\d{4} \|/.test(line)) continue;
|
|
13567
|
-
|
|
13571
|
+
// 1.9.399 (7번째 버그헌트 P1-A, UR-0104): 비이스케이프 파이프 분리 + 복원 — rule 텍스트의 '|'가 컬럼 밀림/멱등성 무력화를 못 일으킴.
|
|
13572
|
+
const cells = line.split(/(?<!\\)\|/).slice(1, -1).map(s => _cellUnescape(s).trim());
|
|
13568
13573
|
if (cells.length < 6) continue;
|
|
13569
13574
|
rules.push({ id: cells[0], trigger: cells[1], rule: cells[2], added: cells[3], status: cells[4], lastVerified: cells[5] });
|
|
13570
13575
|
}
|
|
@@ -13572,7 +13577,8 @@ function readRules(root) {
|
|
|
13572
13577
|
}
|
|
13573
13578
|
|
|
13574
13579
|
function writeRules(root, rules) {
|
|
13575
|
-
|
|
13580
|
+
// 1.9.399 (7번째 버그헌트 P1-A, UR-0104): 셀 안전화 — rule 텍스트의 파이프/개행 차단(컬럼 밀림·중복 룰 무한생성 방지).
|
|
13581
|
+
const body = rules.map(r => `| ${_cellSafe(r.id)} | ${_cellSafe(r.trigger)} | ${_cellSafe(r.rule)} | ${_cellSafe(r.added)} | ${_cellSafe(r.status)} | ${_cellSafe(r.lastVerified || '-')} |`).join('\n');
|
|
13576
13582
|
writeUtf8(rulesPath(root), _rulesHeader() + '\n' + body + (body ? '\n' : ''));
|
|
13577
13583
|
}
|
|
13578
13584
|
|
|
@@ -19693,12 +19699,14 @@ function taskSyncCmd(root) {
|
|
|
19693
19699
|
// 사양 문서(spec.md)에 명시된 함수 이름이 실제 module.exports에 모두 있는지 검사.
|
|
19694
19700
|
// 사용 예: leerness contract verify TICK_SPEC.md src/format.js
|
|
19695
19701
|
function contractVerifyCmd(specPath, implPath) {
|
|
19696
|
-
|
|
19702
|
+
// 1.9.398 (6번째 외부평가/codex P1-C, UR-0099): --json 모드 에러는 구조화 출력(텍스트 대신) — AI 에이전트 JSON.parse 보호.
|
|
19703
|
+
const _j = has('--json');
|
|
19704
|
+
if (!specPath || !implPath) { failJson(_j, 'missing_args', '사용법: leerness contract verify <spec.md> <impl.js>'); return process.exit(process.exitCode || 1); }
|
|
19697
19705
|
const spec = absRoot('.') + path.sep; // dummy to avoid abs
|
|
19698
19706
|
const specFile = path.resolve(specPath);
|
|
19699
19707
|
const implFile = path.resolve(implPath);
|
|
19700
|
-
if (!exists(specFile)) {
|
|
19701
|
-
if (!exists(implFile)) {
|
|
19708
|
+
if (!exists(specFile)) { failJson(_j, 'spec_not_found', `spec 파일 없음: ${specFile}`); return process.exit(process.exitCode || 1); }
|
|
19709
|
+
if (!exists(implFile)) { failJson(_j, 'impl_not_found', `impl 파일 없음: ${implFile}`); return process.exit(process.exitCode || 1); }
|
|
19702
19710
|
const specText = read(specFile);
|
|
19703
19711
|
// 1.9.385 (UR-0086, 5th외부평가): spec 함수/필드 추출을 순수 파서 _parseContractSpec 로 위임.
|
|
19704
19712
|
// 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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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/lib/pure-utils.js
CHANGED
|
@@ -935,7 +935,9 @@ module.exports = {
|
|
|
935
935
|
// 1.9.391 (UR-0025): feature 영향 BFS (순수, 공유)
|
|
936
936
|
_featureImpactBfs,
|
|
937
937
|
// 1.9.393 (UR-0025): CHANGELOG 버전 구간 차분 파서 (순수, 공유)
|
|
938
|
-
_parseChangelogBetween
|
|
938
|
+
_parseChangelogBetween,
|
|
939
|
+
// 1.9.399 (7번째 버그헌트 P1-A, UR-0104): markdown 테이블 셀 안전화(파이프/개행 injection 차단)
|
|
940
|
+
_cellSafe, _cellUnescape
|
|
939
941
|
};
|
|
940
942
|
|
|
941
943
|
// 1.9.355 (UR-0075 Phase A): AI 에이전트용 크로스버전 마이그레이션 안전 워크플로 가이드 (순수 텍스트). 임시설치 + --path + 백업 + diff 검증.
|
|
@@ -1167,3 +1169,8 @@ function _parseChangelogBetween(changelogText, fromV, toV) {
|
|
|
1167
1169
|
}
|
|
1168
1170
|
return ranged;
|
|
1169
1171
|
}
|
|
1172
|
+
// 1.9.399 (7번째 버그헌트 P1-A, UR-0104): markdown 테이블 셀 안전화 — 개행(행 주입)·파이프(컬럼 시프트) 차단.
|
|
1173
|
+
// _cellSafe: 쓰기 시 개행→공백, '|'→'\|'(이스케이프). _cellUnescape: 읽기 시 '\|'→'|' 복원.
|
|
1174
|
+
// table 파서는 split(/(?<!\\)\|/) 로 비이스케이프 파이프에서만 분리 → 사용자 텍스트의 파이프/개행이 데이터 손상·가짜행 주입을 못 일으킴.
|
|
1175
|
+
function _cellSafe(s) { return String(s == null ? '' : s).replace(/\r\n|\r|\n/g, ' ').replace(/\|/g, '\\|'); }
|
|
1176
|
+
function _cellUnescape(s) { return String(s == null ? '' : s).replace(/\\\|/g, '|'); }
|
package/package.json
CHANGED
package/scripts/e2e.js
CHANGED
|
@@ -5537,5 +5537,52 @@ total++;
|
|
|
5537
5537
|
if (!ok) failed++;
|
|
5538
5538
|
}
|
|
5539
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
|
+
|
|
5561
|
+
// 1.9.399 회귀 (7번째 버그헌트 P1-A, UR-0104): 테이블셀 injection 차단 — task/rule 텍스트의 파이프(|) 보존 + 개행 가짜행 주입 차단 + rule 멱등성
|
|
5562
|
+
total++;
|
|
5563
|
+
{
|
|
5564
|
+
let ok = false;
|
|
5565
|
+
try {
|
|
5566
|
+
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'leerness-cellinj-'));
|
|
5567
|
+
cp.spawnSync(process.execPath, [CLI, 'init', d, '--yes', '--language', 'ko'], { encoding: 'utf8', timeout: 30000 });
|
|
5568
|
+
cp.spawnSync(process.execPath, [CLI, 'task', 'add', 'fix login | bypass', '--path', d, '--no-review'], { encoding: 'utf8', timeout: 15000 });
|
|
5569
|
+
cp.spawnSync(process.execPath, [CLI, 'task', 'add', 'real\n| T-9999 | done | x | y | z | w |', '--path', d, '--no-review'], { encoding: 'utf8', timeout: 15000 });
|
|
5570
|
+
const tl = JSON.parse(cp.spawnSync(process.execPath, [CLI, 'task', 'list', '--path', d, '--json'], { encoding: 'utf8', timeout: 15000 }).stdout);
|
|
5571
|
+
const ts = tl.tasks || tl;
|
|
5572
|
+
const pipeOk = ts.some(t => t.request === 'fix login | bypass'); // 파이프 원본 보존
|
|
5573
|
+
const noInject = !ts.some(t => t.id === 'T-9999' || t.status === 'done'); // 개행 가짜행 주입 차단
|
|
5574
|
+
// rule 파이프 + 멱등성(중복 add → skip)
|
|
5575
|
+
cp.spawnSync(process.execPath, [CLI, 'rule', 'add', 'lint | typecheck', '--trigger', 'every-commit', '--path', d], { encoding: 'utf8', timeout: 15000 });
|
|
5576
|
+
cp.spawnSync(process.execPath, [CLI, 'rule', 'add', 'lint | typecheck', '--trigger', 'every-commit', '--path', d], { encoding: 'utf8', timeout: 15000 });
|
|
5577
|
+
const rl = JSON.parse(cp.spawnSync(process.execPath, [CLI, 'rule', 'list', '--path', d, '--json'], { encoding: 'utf8', timeout: 15000 }).stdout);
|
|
5578
|
+
const rs = rl.rules || rl;
|
|
5579
|
+
const ruleOk = rs.length === 1 && rs[0].rule === 'lint | typecheck' && rs[0].status === 'active'; // 파이프 보존 + 멱등 + status 비오염
|
|
5580
|
+
fs.rmSync(d, { recursive: true, force: true });
|
|
5581
|
+
ok = pipeOk && noInject && ruleOk;
|
|
5582
|
+
} catch {}
|
|
5583
|
+
console.log(ok ? '✓ B(1.9.399) 7th버그헌트 P1-A: 테이블셀 injection 차단(task/rule 파이프 보존+개행 가짜행 차단+rule 멱등) (UR-0104)' : '✗ 테이블셀 injection 차단 실패');
|
|
5584
|
+
if (!ok) failed++;
|
|
5585
|
+
}
|
|
5586
|
+
|
|
5540
5587
|
console.log(`\nE2E result: ${total - failed}/${total} passed · ${((Date.now() - _e2eStart) / 1000).toFixed(0)}s`);
|
|
5541
5588
|
if (failed > 0) process.exit(1);
|