leerness 1.36.21 → 1.36.22

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,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.36.22 — 2026-07-14 — SessionStart 컨텍스트 주입(compaction 후 컨텍스트 유실 차단) + README 를 소개·사용법·효과로 재구성
4
+
5
+ **① SessionStart 컨텍스트 주입** (obra/superpowers 구조 검토 → 배선). 실측 결함: compaction/resume 후 에이전트가 "세션 시작 handoff" 의례를 건너뛰어 컨텍스트를 잃는다. superpowers 는 hook matcher 를 `startup|clear|compact` 로 걸어 하네스가 컨텍스트를 강제 적재한다(에이전트 자발성에 안 기댐) — leerness 는 hook 플럼빙과 compact 신호를 **이미 둘 다 갖고 있었고 배선만 없었다**.
6
+
7
+ - **`leerness hook session-start [path]` 신설** — hook 전용 표면. Claude Code 규약(`{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"…"}}`)으로 진행상황 2~3줄 주입.
8
+ - ★ **handoff 를 호출하지 않는다**: handoff 는 `last-handoff` stamp 를 찍어 detector 3종(핸드오프 넛지·abnormal shutdown·R-0001 interval)을 오염시킨다. 동일 파일 로더만 재사용 — **subprocess 0 · 쓰기 0 · last-handoff.json 미접촉**(실측 불변 확인).
9
+ - **어떤 예외에서도 stdout 무출력 + exit 0** — 세션 시작을 절대 깨지 않는다. 미초기화/없는 경로도 무음.
10
+ - **자기 라벨링**(1.9.272 투명성): "위는 요약 — 전체 컨텍스트는 `leerness handoff .` 실행" + 끄는 법 동봉.
11
+ - opt-out: `--no-context-inject` / `LEERNESS_NO_CONTEXT_INJECT=1`.
12
+ - **`handoff --no-record` / `LEERNESS_HOOK=1` 가드 신설** — 읽기전용/hook 호출이 stamp 를 찍어 detector 를 오염시키던 경로 차단(기본 동작 불변, 실측 무회귀).
13
+ - **hook 설치 배선** — `auto-update install` 이 2번째 SessionStart hook(`matcher: 'startup|clear|compact'`)을 멱등 push. 기존 설치도 자동 취득. 투명성 문구로 무엇을/언제/왜/끄는법 명시.
14
+ - 채택하지 않음: superpowers 의 SKILL.md 전문 주입(leerness 의 값어치는 정적 문서가 아니라 동적 상태) · bash 래퍼 hook(leerness 는 이미 PATH 실행파일).
15
+
16
+ **② README 재구성** — 소개 / 사용법 / 사용효과만 담도록 정리. 자기평가·성숙도 서술은 README 의 일이 아니다.
17
+ - 제거: "자체 수행 클린룸 평가로 검증됨" **주장과 그 한정어를 함께**(주장이 없으면 한정어도 불필요 — 방법론·결과·한계는 원래부터 `docs/clean-room-evaluations.md` 가 보유, Links 에서 링크) · "성숙도" 섹션(초기 단계/단독 유지보수/자율 AI 개발/외부 채택) · ko 의 문서 출처 메타 노트.
18
+ - 이전(삭제 아님): 기여자 테스트 티어(`test:fast`/`test:core`/`npm test`) → **신규 `CONTRIBUTING.md`**(불변식·판별케이스·릴리스 절차 포함).
19
+ - 재구성: "Guidance vs enforcement (be honest about this)" → **"Make it enforced, not optional"**(ci init + branch protection 사용법). gitleaks 병행은 사과가 아니라 사용 권장으로.
20
+ - 정직성 회귀 가드로 전수 재검 → ko 에 남아있던 **"지속적 외부 검증 — 다중 모델 클린룸 리뷰"** 적발·제거(한정어를 뺀 자리에 제3자 검증 함의가 남아있었음). 최종 확인: 감사/인증/보장 함의 문구 0.
21
+ - **검증**: selftest 292/292(신규 hook 소스가드 — 쓰기0 불변식·JSON 규약·matcher compact·opt-out·자기라벨링), hook 실측 5종(JSON 규약 / last-handoff 불변 / 미초기화 무음 exit0 / opt-out 2종 / `--no-record` + 기본 stamp 무회귀), 게이트 e2e, 게시본 클린룸.
22
+
3
23
  ## 1.36.21 — 2026-07-14 — 경로/EOL/형태 견고성 4종 — 없는 경로에 트리 생성·CRLF plan tasks 증발·오타 하위명령 전체설치·user-requests 원본 덮어쓰기 (22 에이전트 전수 sweep, 전부 재현확정)
4
24
 
5
25
  codex 이연분(#8/#6) 재현에 그치지 않고 **동일 버그 클래스를 전수 조사**(CRLF 파서 / `--json` 실패경로 / 로더 스키마 / mutation-order 잔여) — 22 에이전트가 실행 기반으로 확정하고 후보마다 독립 재검증. 확정 P2 중 **현실성 있는 4건**만 채택(P3/contrived 는 기각·이연).
@@ -0,0 +1,34 @@
1
+ # Contributing to leerness
2
+
3
+ ## Invariants (non-negotiable)
4
+
5
+ - **0 runtime dependencies** and **0 install scripts** (`preinstall` / `install` / `postinstall`). `leerness install-safety` asserts both; the release gate fails if either is violated.
6
+ - **UTF-8, no BOM** for every source file.
7
+ - Korean-first comments in `bin/` and `lib/` (the codebase's existing convention).
8
+ - Protected harness files are never deleted — merge, archive, or mark deprecated instead.
9
+
10
+ ## Test tiers
11
+
12
+ Three tiers, fastest to slowest:
13
+
14
+ | Command | What it runs | Time | Use it for |
15
+ |---|---|---|---|
16
+ | `npm run test:fast` | `selftest` + smoke (commands run without crashing) | < 1 min | the dev loop |
17
+ | `npm run test:core` | `selftest` + a flagship behavioral suite — `verify-claim` / `gate` / `contract` / `scan` actually reject bad input and pass honest input | ~20 s | pre-commit, quick CI |
18
+ | `npm test` | `--version` + `selftest` + the entire e2e suite | **10+ minutes by design** | the release gate |
19
+
20
+ `npm test` is the gate that must pass before publishing. It is deliberately slow: the e2e suite drives the published CLI surface end-to-end rather than mocking it.
21
+
22
+ ## Adding a check
23
+
24
+ Prefer **behavioral** tests over source-grep guards. A source-grep guard asserts that a string exists, not that the behavior holds — and it can match its own literal in the file it greps (use split literals like `'function ' + 'name'` to anchor past your own line if you must grep).
25
+
26
+ When you add a guard, construct the **discriminating case**: an input where the old code passes and only the new check catches it. If you cannot construct one, the check may not be measuring what you think.
27
+
28
+ ## Release
29
+
30
+ `npm test` (gate) → bump `VERSION` in `bin/leerness.js` **and** `version` in `package.json` (selftest asserts they match) → CHANGELOG entry → commit → publish → push.
31
+
32
+ ## How releases get tested
33
+
34
+ Methodology, results, and limitations of the clean-room evaluations: [docs/clean-room-evaluations.md](./docs/clean-room-evaluations.md).
package/README.ko.md CHANGED
@@ -11,12 +11,10 @@
11
11
  ╚══════╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝
12
12
  ```
13
13
 
14
- > **어떤 언어, 어떤 AI 에이전트로 작업하든 — "증거 없이는 끝났다고 말할 수 없게" 만드는 AI 코딩 운영 레이어.** 코드를 대신 쓰는 도구가 아니라, AI 에이전트의 **기억·인수인계·검증·감사·보안 가드**를 프로젝트에 영속화하는 CLI + MCP 서버입니다. (이 포지셔닝은 **자체 수행 AI 클린룸 평가** — AI 에이전트가 빈 임시폴더에 fresh 설치 후 행위만으로 검증, 검증기 적대공격 포함 — 로 점검했습니다. *제3자 인간 감사·동료심사가 아닙니다.* 방법론·결과·정직한 한계: [docs/clean-room-evaluations.md](./docs/clean-room-evaluations.md))
14
+ > **어떤 언어, 어떤 AI 에이전트로 작업하든 — "증거 없이는 끝났다고 말할 수 없게" 만드는 AI 코딩 운영 레이어.** 코드를 대신 쓰는 도구가 아니라, AI 에이전트의 **기억·인수인계·검증·감사·보안 가드**를 프로젝트에 영속화하는 CLI + MCP 서버입니다.
15
15
 
16
16
  [![npm](https://img.shields.io/npm/v/leerness)](https://www.npmjs.com/package/leerness) · ![MCP tools](https://img.shields.io/badge/MCP--tools-86-blue) · **런타임 의존성 0** · **install-script 0** · offline-first · Node ≥ 18 · MIT
17
17
 
18
- > 이 문서는 **AI 다중 모델(Codex / Claude Sonnet / Claude Opus)이 README 없이 leerness 를 직접 설치·실행·분석한 클린룸 리뷰**(행위 기반 — 제3자 인간 객관 감사는 아님)를 바탕으로 재구성됐습니다. 매 릴리스마다 자동 갱신됩니다.
19
-
20
18
  ---
21
19
 
22
20
  ## leerness가 뭔가요?
@@ -45,11 +43,9 @@ leerness는 이 문제들을 해결하는 **외부 운영 substrate**입니다.
45
43
 
46
44
  ---
47
45
 
48
- ## 성숙도 그래도 시도 비용은 싸다 (정직)
49
-
50
- 의존하기 전에 솔직히: leerness 는 **초기 단계이고 사실상 단독 유지보수**이며, 대부분 **자율 AI 라운드**로 개발됐습니다 — 따라서 자체 `selftest` + e2e 스위트가 1차 품질 신호이고, 외부 채택은 아직 미미합니다. 신뢰만으로 load-bearing 으로 만들지 마세요: **버전을 핀**하고, 차별화된 슬라이스 — `verify-claim` + CI `gate`(필수 체크) — 만 의존할 부분으로 삼으세요.
46
+ ## 도입 부담이 낮은 설계
51
47
 
52
- 그럼에도 시도가 합리적인 이유는 비대칭입니다: MIT, **런타임 의존성 0**, offline-first, 모든 상태가 *당신의* 저장소 안 평문 파일입니다. lock-in 이 거의 없어 — 값을 못 하면 도구만 빼도 `task`/`decision`/`lesson` 파일은 그대로 남습니다. (시크릿 스캔이 필요하면 gitleaks/trufflehog 같은 검증된 전용 도구를 쓰세요leerness `scan secrets` 는 편의 가드지 대체재가 아닙니다.)
48
+ MIT, **런타임 의존성 0**, offline-first, 모든 상태가 *당신의* 저장소 안 평문 파일입니다. lock-in 이 거의 없어 — 값을 못 하면 도구만 빼도 `task`/`decision`/`lesson` 파일은 그대로 남습니다. CI 에서는 **버전을 핀**하세요 — 조용한 업그레이드로 게이트 판정이 바뀌지 않습니다. (시크릿은 gitleaks/trufflehog 같은 전용 스캐너와 병행하세요 — `scan secrets` 는 에이전트가 로컬에서 보는 것과 같은 신호를 주는 편의 레이어입니다.)
53
49
 
54
50
  ---
55
51
 
@@ -170,7 +166,6 @@ leerness mcp serve # JSON-RPC over stdio, 85 도구
170
166
  - **통합 게이트** — 보안·인코딩·드리프트·검증을 `gate` 하나로.
171
167
  - **한국어 우선 + Windows/인코딩 1급 시민** — CP949/BOM 가드, 한국어 출력 기본(`--language en` 지원).
172
168
  - **자기기술(self-describing)** — `about`/`commands`/`capabilities`/`doctor` 로 도구가 스스로 설명.
173
- - **지속적 외부 검증** — 다중 모델 클린룸 리뷰로 회귀 0 을 유지하며 진화.
174
169
 
175
170
  ---
176
171
 
package/README.md CHANGED
@@ -65,13 +65,11 @@ Built-in harnesses remember what the AI **said**. leerness verifies what the AI
65
65
  | Secrets · encoding · drift guards | none | `scan secrets` · `encoding check` · `drift check --auto-fix` — CI-ready |
66
66
  | Lock-in | one vendor | any agent, any language, 0 runtime dependencies |
67
67
 
68
- This positioning is checked by **self-administered clean-room evaluations** — AI agents do a fresh `npm install` into temp dirs and drive it by behavior only, including adversarial attacks against the verifier itself (fake tests, comment-only stubs, inflated test counts — all rejected). To be clear: these are *AI* clean-room runs, **not third-party human audits or peer review** — they make the claim *checkable* rather than a marketing line. Methodology, results, and honest limitations: **[docs/clean-room-evaluations.md](./docs/clean-room-evaluations.md)**.
69
-
70
68
  ---
71
69
 
72
- ## Guidance vs enforcement (be honest about this)
70
+ ## Make it enforced, not optional
73
71
 
74
- By default leerness is **cooperative**: your AI agent runs the commands because CLAUDE.md / AGENTS.md tell it to. A determined agent could skip them. To make verification **enforced**, not optional:
72
+ By default leerness is **cooperative**: your AI agent runs the commands because CLAUDE.md / AGENTS.md tell it to. A determined agent could skip them. To turn the guideline into a guardrail:
75
73
 
76
74
  ```bash
77
75
  leerness ci init # writes .github/workflows/leerness-gate.yml — runs `leerness gate` on every PR
@@ -81,23 +79,19 @@ The generated workflow is production-grade: it **pins the leerness version** (re
81
79
 
82
80
  Then make that check **required** in GitHub branch protection. Now a PR that skips verification (or whose claims fail) **cannot merge** — the gate runs independently of the agent, returns a non-zero exit code, and blocks. That is the difference between a guideline and a guardrail. For exact per-claim enforcement, run `leerness gate --claims` — it adds a 6th check that runs `verify-claim` on **every** completed task and fails the gate if any "done" task's evidence doesn't match reality (the default 5-check gate already blocks false-done via heuristics; `--claims` makes it precise).
83
81
 
84
- For secrets, pair the gate with a **dedicated scanner** in the same workflow — leerness's `scan secrets` is a convenience guard (the same signal your agent sees locally), not a hard guarantee:
82
+ For secrets, pair the gate with a **dedicated scanner** in the same workflow. `scan secrets` gives your agent the same signal locally; a dedicated scanner is the hard-guarantee layer:
85
83
 
86
84
  ```yaml
87
85
  # add to .github/workflows/leerness-gate.yml (or a separate job)
88
86
  - uses: gitleaks/gitleaks-action@v2 # dedicated scanner — the hard-guarantee layer
89
- - run: npx leerness@<pinned-version> scan secrets . --json # convenience layer — same check your agent runs locally
87
+ - run: npx leerness@<pinned-version> scan secrets . --json # same check your agent runs locally
90
88
  ```
91
89
 
92
90
  ---
93
91
 
94
- ## Maturity and why trying it is still cheap
95
-
96
- Be honest with yourself before you depend on this: leerness is **early and largely solo-maintained**, developed mostly through autonomous AI rounds — so its own `selftest` + e2e suites are the primary quality signal, and external adoption is still small. Don't make it load-bearing on faith: **pin a version**, and treat the differentiated slice — `verify-claim` + the CI `gate` as a required check — as the part worth relying on.
97
-
98
- (Contributor note — three test tiers, fastest to slowest: `npm run test:fast` = selftest + smoke (commands run without crashing, <1 min, dev loop); `npm run test:core` = selftest + a flagship behavioral suite (verify-claim / gate / contract / scan actually reject bad input and pass honest input, ~20 s, pre-commit / quick CI); `npm test` = selftest + the entire e2e suite (**10+ minutes by design**, the release gate).)
92
+ ## Low-risk by design
99
93
 
100
- The asymmetry is what makes a trial reasonable anyway: MIT, **0 runtime dependencies**, offline-first, and all state is plain files in *your* repo. Lock-in is near zero — if it doesn't earn its place, remove the tool and your `task`/`decision`/`lesson` files stay. (For secret scanning specifically, mature dedicated tools like gitleaks/trufflehog exist use those if you need a hard guarantee; leerness's `scan secrets` is a convenience guard, not a replacement.)
94
+ **MIT · 0 runtime dependencies · offline-first**, and all state is plain files in *your* repo. Lock-in is near zero — if it doesn't earn its place, remove the tool and your `task` / `decision` / `lesson` files stay exactly where they are. **Pin a version** in CI so the gate's verdict can't change from a silent upgrade.
101
95
 
102
96
  ---
103
97
 
@@ -117,6 +111,8 @@ Full command reference, workflows, and architecture: **[README.ko.md](./README.k
117
111
  - npm: https://www.npmjs.com/package/leerness
118
112
  - Site & release videos: https://leerness.pages.dev
119
113
  - Changelog: [CHANGELOG.md](./CHANGELOG.md)
114
+ - How this gets tested — methodology, results, and limitations: [docs/clean-room-evaluations.md](./docs/clean-room-evaluations.md)
115
+ - Contributing & test tiers (`test:fast` / `test:core` / `npm test`): [CONTRIBUTING.md](./CONTRIBUTING.md)
120
116
 
121
117
  ## License
122
118
 
@@ -125,7 +121,7 @@ MIT
125
121
  <!-- leerness:project-readme:start -->
126
122
  ## Leerness Project Harness
127
123
 
128
- 이 프로젝트는 Leerness v1.36.21 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
124
+ 이 프로젝트는 Leerness v1.36.22 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
129
125
 
130
126
  ### 정체성 — AI 에이전트 운영 레이어 (UR-0030)
131
127
 
@@ -179,7 +175,7 @@ leerness memory restore decision <date|title>
179
175
 
180
176
  ### MCP server (외부 AI 통합)
181
177
 
182
- Leerness v1.36.21는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **86개 도구**를 노출:
178
+ Leerness v1.36.22는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **86개 도구**를 노출:
183
179
 
184
180
  ```jsonc
185
181
  // 카테고리별
@@ -200,7 +196,7 @@ Leerness v1.36.21는 stdio JSON-RPC MCP server를 내장합니다 — Claude Cod
200
196
  `<<autonomous-loop-dynamic>>` 신호만 보내면 AI가:
201
197
  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) 다음 라운드 예약.
202
198
 
203
- 현재 누적: **70 라운드 (1.9.40 → 1.36.21)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
199
+ 현재 누적: **70 라운드 (1.9.40 → 1.36.22)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
204
200
 
205
201
  ### 성능 가이드 (1.9.140 측정)
206
202
 
@@ -238,6 +234,6 @@ leerness release pack --close --auto-main-push
238
234
  - `.harness/session-handoff.md`: 다음 세션 인수인계 (자동 작성)
239
235
  - `.harness/lessons.md` / `decisions.md` / `rules.md`: 영구 메모리 (5 surface)
240
236
 
241
- Last synced by Leerness v1.36.21: 2026-07-15
237
+ Last synced by Leerness v1.36.22: 2026-07-15
242
238
  <!-- leerness:project-readme:end -->
243
239
 
package/bin/leerness.js CHANGED
@@ -33,7 +33,7 @@ const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInG
33
33
  const { CAPABILITY_SURFACE, POWERFUL_COMMANDS, ADAPTERS, REUSE_CATEGORIES, REUSE_CHECKLIST, _DEFAULT_PLATFORM_CONSTRAINTS, _DEFAULT_DOMAIN_CATALOG, _TOOL_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 분리 · 1.11.4 (UR-0007): _TOOL_CATALOG
34
34
  const { findCorruptedStateJson: _findCorruptedStateJson } = require('../lib/state-integrity'); // 1.36.1 (클린룸 리뷰 FN): .harness/*.json 상태 무결성 (audit/health/check 공유)
35
35
 
36
- const VERSION = '1.36.21';
36
+ const VERSION = '1.36.22';
37
37
 
38
38
  // 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
39
39
  // 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
@@ -2982,6 +2982,21 @@ function _selfTestCases() {
2982
2982
  const encOk = s.includes("(result.applied || []).some(a => a.action === 'failed')) process.exitCode = 1"); // encoding: 실패 exit1
2983
2983
  return reuseOk && releaseOk && encOk;
2984
2984
  } },
2985
+ { name: 'SessionStart 컨텍스트 주입 (1.36.22, obra/superpowers 구조 검토): hook 전용 표면 + 쓰기0 가드 + matcher 에 compact 포함 + opt-out — 소스가드', run: () => {
2986
+ const s = read(__filename);
2987
+ const surface = typeof hookSessionStartCmd === 'function' && s.includes("cmd === 'hook' && args[1] === 'session-start'");
2988
+ // ★ 핵심 불변식: hook 은 handoff 를 부르지 않는다(부르면 last-handoff stamp 로 detector 3종 오염) + record 는 가드 뒤에만
2989
+ const zeroWrite = s.includes("if (!has('--no-record') && process.env.LEERNESS_HOOK !== '1') { try { _recordLastHandoff(root); } catch {} }");
2990
+ // split-literal: 앵커를 통짜 문자열로 두면 이 selftest 줄 자신이 먼저 매칭돼 43자짜리 자기 슬라이스를 잡는다(자기참조 트랩, UR-0009 계열).
2991
+ const hookBody = s.slice(s.indexOf('function ' + 'hookSessionStartCmd'), s.indexOf('function ' + 'handoffCmd'));
2992
+ const noHandoffCall = hookBody.length > 100 && !/handoffCmd\(|_recordLastHandoff\(|writeUtf8\(|mkdirp\(/.test(hookBody); // 쓰기/handoff 호출 0
2993
+ const jsonContract = hookBody.includes("hookEventName: 'SessionStart'") && hookBody.includes('additionalContext');
2994
+ const optOut = hookBody.includes("has('--no-context-inject')") && hookBody.includes("LEERNESS_NO_CONTEXT_INJECT");
2995
+ const selfLabel = hookBody.includes('위는 요약'); // 1.9.272 투명성: 요약임을 자기 라벨링
2996
+ const matcherCompact = s.includes("{ matcher: 'startup|clear|compact', command: 'leerness hook session-start' }"); // 실측 결함(compaction) 커버
2997
+ const idempotent = s.includes("some(h => h.command && h.command.includes('leerness hook session-start'))");
2998
+ return surface && zeroWrite && noHandoffCall && jsonContract && optOut && selfLabel && matcherCompact && idempotent;
2999
+ } },
2985
3000
  { name: '경로/EOL/형태 견고성 4종 (1.36.21, 전수 sweep P2): handoff·env detect 없는경로 가드 + CRLF plan tasks + migrate 오타설치 차단 + user-requests 미인식 쓰기차단 — 소스가드 + 순수 행위', run: () => {
2986
3001
  const s = read(__filename);
2987
3002
  // B: 없는 경로에 트리/.harness 를 만들고 빈 프로젝트로 보고하던 것 차단 (UR-0136 관례 정렬)
@@ -9075,7 +9090,9 @@ function handoff(root) {
9075
9090
  // detector 가 prior gap 을 정확히 측정 (overwrite 전 값 필요). 함수 최상단에 선언.
9076
9091
  let _priorHandoffGap = { hasLast: false };
9077
9092
  try { _priorHandoffGap = _getLastHandoffGap(root); } catch {}
9078
- try { _recordLastHandoff(root); } catch {}
9093
+ // 1.36.22: 읽기전용/hook 호출이 last-handoff stamp 를 찍으면 detector 3종(핸드오프 넛지·abnormal shutdown·R-0001 interval)이
9094
+ // "방금 handoff 했다"고 오판해 오염된다. --no-record / LEERNESS_HOOK=1 로 stamp 생략(기본 동작 불변).
9095
+ if (!has('--no-record') && process.env.LEERNESS_HOOK !== '1') { try { _recordLastHandoff(root); } catch {} }
9079
9096
  // 1.9.203: auto-resume-plan 자동 로드 (사용자 명시 — 자동 모드 알람 트리거)
9080
9097
  let _autoResumePlan = null;
9081
9098
  try { _autoResumePlan = _loadAutoResumePlan(root); } catch {}
@@ -10701,6 +10718,35 @@ function _handoffWorkspace(rootBase) {
10701
10718
  log(` - 새 패턴 추가 시 \`leerness reuse-map --all-apps\`로 중복 감지${sinceCutoff ? '' : ' / `--since 24h`로 최근 변경 추적'}`);
10702
10719
  }
10703
10720
 
10721
+ // 1.36.22 (obra/superpowers 구조 검토 → 배선): SessionStart 컨텍스트 주입 전용 표면.
10722
+ // 문제(실측): compaction/resume 후 에이전트가 "세션 시작 handoff" 의례를 건너뛰어 컨텍스트를 잃는다.
10723
+ // superpowers 는 hook matcher 를 startup|clear|compact 로 걸어 하네스가 컨텍스트를 강제 적재한다(에이전트 자발성에 안 기댐).
10724
+ // leerness 는 hook 플럼빙(autoUpdateInstall)과 compact 신호(handoff --compact)를 이미 둘 다 갖고 있었고 배선만 없었음 → 그 배선.
10725
+ // ★ 여기서 handoff 를 호출하지 않는다: handoff 는 last-handoff stamp 를 찍어 detector 3종을 오염시킴. 동일 파일 로더만 재사용
10726
+ // (subprocess 0 · 쓰기 0 · last-handoff.json 미접촉). 어떤 예외에서도 stdout 무출력 + exit 0 — 세션 시작을 절대 깨지 않는다.
10727
+ function hookSessionStartCmd(root) {
10728
+ if (has('--no-context-inject') || process.env.LEERNESS_NO_CONTEXT_INJECT === '1') return; // opt-out → 무출력 exit 0
10729
+ try {
10730
+ root = absRoot(root || process.cwd());
10731
+ if (!exists(root) || !exists(path.join(root, '.harness'))) return; // 미초기화/없는 경로 → 조용히 무출력(hook 은 어디서나 실행됨)
10732
+ const rows = readProgressRows(root);
10733
+ const byStatus = {};
10734
+ for (const r of rows) byStatus[r.status] = (byStatus[r.status] || 0) + 1;
10735
+ const done = byStatus['done'] || 0, wip = byStatus['in-progress'] || 0, blocked = byStatus['blocked'] || 0;
10736
+ const pct = rows.length ? Math.round(done / rows.length * 100) : 0;
10737
+ const openReq = (_loadUserRequests(root).requests || []).filter(r => r && (r.status === 'open' || r.status === 'in-progress')).length;
10738
+ const nx = rows.find(r => r.status === 'in-progress') || rows.find(r => r.status === 'planned') || null;
10739
+ const flags = [];
10740
+ if (openReq) flags.push(`📥 미답 요청 ${openReq}`);
10741
+ if (blocked) flags.push(`🚫 blocked ${blocked}`);
10742
+ const lines = [_lineSafe(`[leerness] ${detectProjectName(root)} · ${done}/${rows.length}(${pct}%) done · WIP ${wip}${flags.length ? ' · ' + flags.join(' · ') : ''}`)];
10743
+ if (nx) lines.push(_lineSafe(`다음: ${nx.id} [${nx.status}] ${nx.nextAction || nx.request || ''}`).slice(0, 200));
10744
+ // 자기 라벨링(1.9.272 투명성 불변식): 요약임을 밝히고 전체 컨텍스트 경로와 끄는 법을 함께 준다.
10745
+ lines.push('⚠ 위는 요약 — 전체 컨텍스트는 `leerness handoff .` 실행. (이 주입 끄기: LEERNESS_NO_CONTEXT_INJECT=1)');
10746
+ // Claude Code SessionStart hook 규약. JSON.stringify 가 이스케이프 담당(수동 백슬래시/따옴표 처리 불필요).
10747
+ process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext: lines.join('\n') } }) + '\n');
10748
+ } catch { /* 세션 시작을 절대 깨지 않는다 — 무출력 exit 0 */ }
10749
+ }
10704
10750
  function handoffCmd(root) {
10705
10751
  // 1.36.21 (전수 sweep P2/high): 존재하지 않는 경로에 디렉토리 트리 + .harness 를 "생성"하고 깨끗한 빈 프로젝트로 보고하던 것 차단.
10706
10752
  // 오타 경로에 handoff 하면 쓰레기 트리가 생기고, --json 은 ok/error 없는 정상 JSON + exit 0 이라 기계 소비자가 오타를 감지 못 했음.
@@ -16012,6 +16058,11 @@ function autoUpdateInstall(root) {
16012
16058
  if (!settings.hooks.SessionStart.some(h => h.command && h.command.includes('leerness update'))) {
16013
16059
  settings.hooks.SessionStart.push({ matcher: '*', command: 'leerness update --check --quiet' });
16014
16060
  }
16061
+ // 1.36.22: 2번째 SessionStart hook — 컨텍스트 주입. matcher 에 compact 를 포함하는 게 핵심(실측 결함: compaction/resume 후
16062
+ // 에이전트가 세션시작 handoff 의례를 건너뜀). 기존 설치는 이 멱등 push 로 자동 취득(1.9.364 업그레이드 패턴 재사용).
16063
+ if (!settings.hooks.SessionStart.some(h => h.command && h.command.includes('leerness hook session-start'))) {
16064
+ settings.hooks.SessionStart.push({ matcher: 'startup|clear|compact', command: 'leerness hook session-start' });
16065
+ }
16015
16066
  writeUtf8(settingsFile, JSON.stringify(settings, null, 2) + '\n');
16016
16067
  writeUtf8(path.join(root, '.claude/commands/update.md'),
16017
16068
  `# /update\n\nleerness 자동 업데이트 (감지 → 마이그레이션 → 검증).\n\n\`\`\`\n!leerness update --yes\n\`\`\`\n\n체크만:\n\n\`\`\`\n!leerness update --check\n\`\`\`\n`);
@@ -16022,6 +16073,8 @@ function autoUpdateInstall(root) {
16022
16073
  // 1.9.272 (GPT-5.5 외부 리뷰 반영): hook 설치 투명성 — 무엇을/왜/어떻게 끄는지 명시.
16023
16074
  // 1.9.364 (4번째 외부평가 9.3): 비침투 — 세션 시작 시 --quiet 로 up-to-date 면 아무 출력 없음, 업데이트 가능 시에만 1줄.
16024
16075
  log(` ⓘ 이 hook 은 Claude Code 세션 시작 시 \`leerness update --check --quiet\` 를 1회 실행합니다 (최신이면 무음, 업데이트 가능 시에만 1줄 통지 · 자동 설치는 안 함).`);
16076
+ // 1.36.22: 2번째 hook 투명성 — 무엇을(요약 주입)/언제(startup·clear·compact)/왜(compaction 후 컨텍스트 유실)/어떻게 끄는지.
16077
+ log(` ⓘ 2번째 hook \`leerness hook session-start\` 는 세션 시작·clear·compaction 시 진행상황 요약 2~3줄을 컨텍스트에 주입합니다 (쓰기 0 · 미초기화 프로젝트면 무음 · 끄기: LEERNESS_NO_CONTEXT_INJECT=1).`);
16025
16078
  log(` ⓘ 제거: ${rel(root, settingsFile)} 의 hooks.SessionStart 항목 삭제 · 설치 시 끄기: leerness init . --no-auto-update`);
16026
16079
  }
16027
16080
 
@@ -21097,6 +21150,7 @@ async function main() {
21097
21150
  if (cmd === 'encoding' && args[1] === 'check') return encodingCheck(arg('--path', args[2] || process.cwd()));
21098
21151
  if (cmd === 'lazy' && args[1] === 'detect') return lazyDetect(_resolveRoot(args[2]), { json: has('--json') });
21099
21152
  if (cmd === 'memory' && args[1] === 'search') return memorySearch(arg('--path', process.cwd()), args.slice(2).join(' '));
21153
+ if (cmd === 'hook' && args[1] === 'session-start') return hookSessionStartCmd(arg('--path', args[2] || process.cwd())); // 1.36.22: SessionStart 컨텍스트 주입(쓰기 0)
21100
21154
  if (cmd === 'handoff') { const _hp = arg('--path', args[1] || process.cwd()); const _hr = handoffCmd(_hp); _maybeAutoGraph(_hp); return _hr; }
21101
21155
  if (cmd === 'reuse-map') return reuseMapCmd(arg('--path', args[1] || process.cwd()));
21102
21156
  if (cmd === 'verify-claim') { const _p = arg('--path', process.cwd()); if (args[1] === '--all' || has('--all')) return verifyClaimAllCmd(_p); return verifyClaimCmd(_p, args[1]); } // 1.33.2: --all → 모든 done 주장 일괄 검증
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leerness",
3
- "version": "1.36.21",
3
+ "version": "1.36.22",
4
4
  "description": "Leerness: 비파괴 마이그레이션, 자동 버전 감지·업데이트, 계획/진행/핸드오프 자동화, 게으름·시크릿·인코딩 자동 가드, Claude Code 슬래시 통합을 갖춘 한국어 우선 AI 개발 하네스.",
5
5
  "keywords": [
6
6
  "leerness",
@@ -43,6 +43,7 @@
43
43
  "docs",
44
44
  "README.md",
45
45
  "CHANGELOG.md",
46
+ "CONTRIBUTING.md",
46
47
  "SECURITY.md",
47
48
  "LICENSE"
48
49
  ],