leerness 1.9.388 → 1.9.390

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,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.9.390 — 2026-06-06 — UR-0025 모듈화: feature-graph 순수 코어 → pure-utils (feature 핸들러 분리 토대)
4
+
5
+ **🧩 feature-graph 의 순수 로직(템플릿/파서/ID/블록 렌더)을 lib/pure-utils.js 로 분리 — 가장 많이 공유되는 서브시스템의 핵심을 단일출처·테스트 가능화.**
6
+
7
+ ### 배경 (UR-0025, 사용자 승인 모듈화)
8
+ migrate(1.9.388)/team(1.9.389) 핸들러를 lib 모듈로 뺐다. feature 서브시스템도 후보지만, `_readFeatureGraph` 가 audit/health/handoff 등 **7+곳에서 공유**돼 핸들러를 통째로 옮기기 전에 순수 코어부터 분리하는 게 안전(lib/io.js 토대를 먼저 만든 것과 동일 순서).
9
+
10
+ ### 구현
11
+ 1. **pure-utils 로 순수 4종 이전**: `_featureGraphTemplate`(템플릿) · `_parseFeatureGraph`(MD→nodes) · `_nextFeatureId`(다음 F-id) · `_featureBlock`(node→MD). 모두 I/O 없음.
12
+ 2. **I/O 헬퍼는 harness 유지**: `_readFeatureGraph`(7+곳 공유) · `_writeFeatureGraph` · `_ensureFeatureGraph` · `featureGraphPath` — 이제 pure-utils 의 순수 함수를 import 해 사용.
13
+ 3. harness 인라인 정의 제거 + import. 호출부·동작·출력 무변경.
14
+
15
+ ### 검증 (회귀 0)
16
+ - **selftest 135→136 PASS** (reference-equality 4종 + 템플릿/파서/nextId 동작 + `_featureBlock`→`_parseFeatureGraph` round-trip + 인라인 제거 확인).
17
+ - **E2E 332 유지 PASS** (feature add/link/impact/list/show + 공유 _readFeatureGraph(audit/health/handoff) 회귀). 락 flake 시 재실행.
18
+ - 실측: add(F-0001/F-0002)·link(affects)·impact(transitive)·list(--json)·health(featureGraph) 보존.
19
+
20
+ ## 1.9.389 — 2026-06-06 — UR-0025 큰 핸들러 모듈화 2번째: teamCmd → lib/team.js (DI)
21
+
22
+ **🧩 두 번째 핸들러 모듈 추출 — team 서브시스템(list/add/show/remove/preview/deploy)을 lib/team.js 로 분리. migrate(1.9.388)에서 확립한 DI 패턴 재사용.**
23
+
24
+ ### 배경 (UR-0025 큰 핸들러 모듈화, 사용자 승인)
25
+ 1.9.388 migrate 추출로 DI 패턴(io import + deps 주입)을 확립. 동일 패턴으로 두 번째 응집 핸들러 teamCmd(UR-0073, ~111줄, e2e 5건 보유)를 분리.
26
+
27
+ ### 구현
28
+ 1. **lib/team.js 신규**: teamCmd(6 서브명령) 이전.
29
+ - 직접 require: `./io`(absRoot/log/ok/warn/fail/now) · `./pure-utils`(_composeTeamPlan/_teamDeployGate) · `./analyzers`(_shellGuardAnalyze) · node child_process.
30
+ - **DI 주입**: VERSION · _loadTeams · _saveTeams · _detectShellCtx · arg · has(argv 파서).
31
+ 2. **_loadTeams/_saveTeams 는 harness 유지**: handoff team reminders(_teamHandoffReminders)도 쓰는 공유 함수 → harness 에 두고 주입만. (teamsJsonPath/teamsPath/_renderTeamsMd 도 harness 유지.)
32
+ 3. **harness thin wrapper**: deps 구성 후 위임. dispatch · 동작 · 출력 무변경.
33
+
34
+ ### 검증 (회귀 0)
35
+ - **selftest 134→135 PASS** (lib/team export + 위임 와이어 + lib 본문 이동(pure-utils require/_teamDeployGate/하위명령) 교차참조 + behavioral list --json). 기존 1.9.371 케이스(_saveTeams/_loadTeams/_renderTeamsMd harness 유지)도 통과.
36
+ - **E2E 332 유지 PASS** (team B(1.9.371/372/373/376/378) list/add/preview/deploy-gate/MCP 회귀가 CLI→wrapper→lib 경로 검증). 락 flake 시 재실행.
37
+ - 실측: list/add/show/preview/deploy(dry-run·gated 이중게이트) + handoff team reminders(daily 팀 노출) 보존.
38
+
3
39
  ## 1.9.388 — 2026-06-06 — UR-0025 큰 핸들러 모듈화: migrate audit/apply/plan → lib/migrate.js (DI)
4
40
 
5
41
  **🧩 첫 실제 핸들러 모듈 추출 — migrate 서브시스템(audit/apply/plan)을 lib/migrate.js 로 분리(의존성 주입 ctx). lib/io.js 토대(1.9.382/383)의 첫 활용.**
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.388-green)]() [![tests](https://img.shields.io/badge/e2e-332%2F332-success)]() [![selftest](https://img.shields.io/badge/selftest-134-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.390-green)]() [![tests](https://img.shields.io/badge/e2e-332%2F332-success)]() [![selftest](https://img.shields.io/badge/selftest-136-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.388 하네스를 사용합니다. AI 에이전트는 작업 전 `leerness handoff`로 컨텍스트를 적재하고, 작업 후 `leerness check`/`leerness audit`/`leerness session close`를 수행해야 합니다.
474
+ 이 프로젝트는 Leerness v1.9.390 하네스를 사용합니다. 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.388는 stdio JSON-RPC MCP server를 내장합니다 — Claude Code · Cursor · Codex CLI 등 외부 AI에 **85개 도구**를 노출:
528
+ Leerness v1.9.390는 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.388는 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.388)** · 매 라운드 GitHub release/태그 생성 · _reports/는 비공개 보존.
549
+ 현재 누적: **70 라운드 (1.9.40 → 1.9.390)** · 매 라운드 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.388: 2026-06-06
587
+ Last synced by Leerness v1.9.390: 2026-06-06
588
588
  <!-- leerness:project-readme:end -->
589
589
 
package/bin/harness.js CHANGED
@@ -23,13 +23,14 @@ const { _isSecretKey, _isPlaceholderSecret, _looksSecretLike, _mergeLines, _merg
23
23
  _personaSummaries, _translate,
24
24
  _decisionsFromMd, _renderDecisionsMd, _renderLessonsMd,
25
25
  _withBuiltinSource, _esc, _roadmapTokenStyles, _parseSkillMd,
26
- _migrationGuideText, _parseContractSpec, _gitignoreMatch } = require('../lib/pure-utils'); // 1.9.318~386 (UR-0025/0053/0075/0086/0087): 순수 유틸 모듈 분리
26
+ _migrationGuideText, _parseContractSpec, _gitignoreMatch,
27
+ _featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock } = require('../lib/pure-utils'); // 1.9.318~390 (UR-0025/0053/0075/0086/0087): 순수 유틸 모듈 분리
27
28
  // 1.9.304 (UR-0025): 순수 분석/검증 함수 모듈 분리.
28
29
  const { _evidenceQuality, _parseEvidenceStats, _shellGuardAnalyze, _claimFileInGit, _epistemicHonestyCheck } = require('../lib/analyzers');
29
30
  // 1.9.295 (UR-0025 4단계): 정적 데이터 카탈로그 모듈 분리 (비파괴, require-based).
30
31
  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 포함)
31
32
 
32
- const VERSION = '1.9.388';
33
+ const VERSION = '1.9.390';
33
34
 
34
35
  // 1.9.290 (UR-0037, Codex gpt-5.5 #4 수렴): CLI 전용 부작용은 require 시 실행하지 않는다.
35
36
  // 이전: warning listener 제거 / NODE_OPTIONS 변경 / chcp IIFE 가 top-level 즉시 실행 → require('harness') 시 호스트 프로세스 오염.
@@ -2991,6 +2992,8 @@ function _selfTestCases() {
2991
2992
  { name: '5th외부평가/UR-0087: _gitignoreMatch git 일치(.env↛.env.bad) + env-family 스캔 (1.9.386)', run: () => { const m = require('../lib/pure-utils'); if (m._gitignoreMatch !== _gitignoreMatch) return false; const gm = _gitignoreMatch; const semOk = gm('.env', '.env') === true && gm('.env', '.env.bad') === false && gm('.env', '.env.local') === false && gm('.env.*', '.env.bad') === true && gm('.env*', '.env') === true && gm('*.pem', 'k.pem') === true && gm('src/', 'src/a.txt') === true; const src = read(__filename); const envFamilyScan = src.includes('const isEnvFamily =') && src.includes('!SCAN_TEXT_EXT.has(ext) && !isEnvFamily'); const delegated = src.includes('return _gitignoreMatch(gi, fileRel)'); return semOk && envFamilyScan && delegated; } },
2992
2993
  { name: 'UR-0088 5th외부평가 일관성: incident/runs list 빈 케이스 --json 구조화 (1.9.387)', run: () => { if (typeof incidentListCmd !== 'function' || typeof runsListCmd !== 'function') return false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_lj_')); const save = process.argv; const _w = process.stdout.write; let io = '', ro = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'incident', 'list', '--json']; process.stdout.write = s => { io += s; return true; }; incidentListCmd(tmp); process.stdout.write = _w; process.argv = ['node', 'h', 'runs', 'list', '--json']; process.stdout.write = s => { ro += s; return true; }; runsListCmd(tmp); } catch {} finally { process.stdout.write = _w; process.argv = save; try { fs.rmSync(tmp, { recursive: true, force: true }); } catch {} } let ij, rj; try { ij = JSON.parse(io); rj = JSON.parse(ro); } catch {} return !!ij && ij.total === 0 && Array.isArray(ij.items) && !!rj && rj.total === 0 && Array.isArray(rj.items); } },
2993
2994
  { name: 'UR-0025 큰핸들러 모듈화: migrate audit/apply/plan → lib/migrate.js + DI 위임 + 동작 (1.9.388)', run: () => { const m = require('../lib/migrate'); const expOk = typeof m.migrateAuditCmd === 'function' && typeof m.migrateApplyCmd === 'function' && typeof m.migratePlanCmd === 'function'; const src = read(__filename); const delegated = src.includes("require('../lib/migrate')") && src.includes('_migrate.migrateAuditCmd(root, opts, _migrateDeps())') && src.includes('_migrate.migratePlanCmd(root, opts, _migrateDeps())'); const movedToLib = read(path.join(path.dirname(__filename), '..', 'lib', 'migrate.js')).includes('leerness-plan-'); let behavOk = false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_mig_')); 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, '.harness', 'HARNESS_VERSION'), VERSION); process.argv = ['node', 'h', 'migrate', 'audit', tmp, '--json']; process.stdout.write = s => { out += s; return true; }; migrateAuditCmd(tmp, { json: true }); } 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.version === VERSION && typeof j.willChange === 'number' && Array.isArray(j.findings); } catch {} return expOk && delegated && movedToLib && behavOk; } },
2995
+ { name: 'UR-0025 큰핸들러 모듈화: teamCmd → lib/team.js + DI 위임 + 동작 (1.9.389)', run: () => { const m = require('../lib/team'); const expOk = typeof m.teamCmd === 'function'; const src = read(__filename); const delegated = src.includes("require('../lib/team')") && src.includes('_team.teamCmd(root, sub, id, opts,'); const teamSrc = read(path.join(path.dirname(__filename), '..', 'lib', 'team.js')); const movedToLib = teamSrc.includes("require('./pure-utils')") && teamSrc.includes('_teamDeployGate') && teamSrc.includes('알 수 없는 team 하위명령'); let behavOk = false; const tmp = fs.mkdtempSync(path.join(os.tmpdir(), '__leerness_tm_')); const save = process.argv; const _w = process.stdout.write; let out = ''; try { fs.mkdirSync(path.join(tmp, '.harness'), { recursive: true }); process.argv = ['node', 'h', 'team', 'list', '--json']; process.stdout.write = s => { out += s; return true; }; teamCmd(tmp, 'list', undefined, { json: true }); } 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.version === VERSION && j.count === 0 && Array.isArray(j.teams); } catch {} return expOk && delegated && movedToLib && behavOk; } },
2996
+ { name: 'UR-0025: feature-graph 순수 코어(_featureGraphTemplate/_parseFeatureGraph/_nextFeatureId/_featureBlock) → pure-utils + round-trip (1.9.390)', run: () => { const m = require('../lib/pure-utils'); const refOk = m._parseFeatureGraph === _parseFeatureGraph && m._featureGraphTemplate === _featureGraphTemplate && m._nextFeatureId === _nextFeatureId && m._featureBlock === _featureBlock; const tmpl = m._featureGraphTemplate(); const tmplOk = tmpl.includes('Feature Graph') && tmpl.includes('## Nodes'); const nodes = m._parseFeatureGraph('## F-0001 Auth\n- depends-on: F-0002\n- affects: F-0003\n- files: a.js\n'); const parseOk = nodes.length === 1 && nodes[0].id === 'F-0001' && nodes[0].title === 'Auth' && nodes[0].dependsOn[0] === 'F-0002' && nodes[0].affects[0] === 'F-0003' && nodes[0].files[0] === 'a.js'; const idOk = m._nextFeatureId(nodes) === 'F-0002'; const rt = m._parseFeatureGraph(m._featureBlock(nodes[0])); const rtOk = rt.length === 1 && rt[0].id === 'F-0001' && rt[0].dependsOn[0] === 'F-0002'; const src = read(__filename); const moved = src.includes("require('../lib/pure-utils')") && !/^function _parseFeatureGraph\(text\) \{/m.test(src) && !/^function _featureBlock\(node\) \{/m.test(src); return refOk && tmplOk && parseOk && idOk && rtOk && moved; } },
2994
2997
  { name: 'VERSION 형식 (x.y.z)', run: () => /^\d+\.\d+\.\d+$/.test(VERSION) }
2995
2998
  ];
2996
2999
  }
@@ -5785,114 +5788,10 @@ function _saveTeams(root, teams) {
5785
5788
  writeUtf8(teamsJsonPath(root), JSON.stringify(arr, null, 2) + '\n');
5786
5789
  writeUtf8(teamsPath(root), _renderTeamsMd(arr));
5787
5790
  }
5788
- function teamCmd(root, sub, id, opts = {}) {
5789
- root = absRoot(root);
5790
- const json = opts.json || has('--json');
5791
- const teams = _loadTeams(root);
5792
- sub = sub || 'list';
5793
- if (sub === 'list') {
5794
- if (json) { log(JSON.stringify({ version: VERSION, root, count: teams.length, teams }, null, 2)); return; }
5795
- log(`# leerness team (1.9.371, UR-0073 Phase A) — 에이전트 팀 정의 (opt-in · 정의 전용)`);
5796
- if (!teams.length) { log(' (정의된 팀 없음) — leerness team add <id> --name "..." --purpose "..." --personas a,b --members claude,codex'); return; }
5797
- for (const t of teams) log(` • ${t.id}${t.name ? ' — ' + t.name : ''} [${t.status || 'active'}/${t.schedule || 'manual'}] personas:${(t.personas || []).join('|') || '-'} members:${(t.members || []).join('|') || '-'}`);
5798
- log(`\n ⓘ 정의 전용 — 자동 실행 없음. 실행(리뷰/배포/블로그)은 향후 opt-in 단계.`);
5799
- return;
5800
- }
5801
- if (sub === 'add') {
5802
- const teamId = String(id || '').toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[.\-]+|[.\-]+$/g, '');
5803
- if (!teamId || teamId.includes('..')) { fail(`무효한 team id: "${id}" (영숫자/._- 만)`); return; }
5804
- if (teams.some(t => t.id === teamId)) { warn(`이미 존재: ${teamId} (제거 후 재정의: leerness team remove ${teamId})`); return; }
5805
- const splitCsv = v => (v && v !== true) ? String(v).split(',').map(s => s.trim()).filter(Boolean) : [];
5806
- const sched = arg('--schedule', 'manual');
5807
- const validSched = new Set(['manual', 'every-session', 'daily', 'weekly']);
5808
- const team = {
5809
- id: teamId,
5810
- name: arg('--name', '') === true ? '' : arg('--name', ''),
5811
- purpose: arg('--purpose', '') === true ? '' : arg('--purpose', ''),
5812
- personas: splitCsv(arg('--personas', null)),
5813
- members: splitCsv(arg('--members', null)),
5814
- schedule: validSched.has(sched) ? sched : 'manual',
5815
- deployCommand: arg('--deploy', '') === true ? '' : arg('--deploy', ''), // 1.9.376 (Phase D): 사용자 설정 배포 명령 (실행은 게이트)
5816
- status: 'active',
5817
- createdAt: now()
5818
- };
5819
- teams.push(team);
5820
- _saveTeams(root, teams);
5821
- ok(`team 정의: ${teamId} (personas:${team.personas.length} members:${team.members.length} schedule:${team.schedule})`);
5822
- log(` ⓘ 정의 전용 — 자동 실행 없음. 목록: leerness team list`);
5823
- return;
5824
- }
5825
- if (sub === 'show') {
5826
- const t = teams.find(x => x.id === id);
5827
- if (!t) { fail(`team 없음: ${id}`); return; }
5828
- if (json) { log(JSON.stringify(t, null, 2)); return; }
5829
- log(`# team ${t.id}`);
5830
- log(` name: ${t.name || ''}`);
5831
- log(` purpose: ${t.purpose || ''}`);
5832
- log(` personas: ${(t.personas || []).join(', ') || '-'}`);
5833
- log(` members: ${(t.members || []).join(', ') || '-'}`);
5834
- log(` schedule: ${t.schedule || 'manual'} · status: ${t.status || 'active'}`);
5835
- log(` deploy: ${t.deployCommand || '-'}`);
5836
- return;
5837
- }
5838
- if (sub === 'remove') {
5839
- const before = teams.length;
5840
- const next = teams.filter(x => x.id !== id);
5841
- if (next.length === before) { warn(`team 없음: ${id}`); return; }
5842
- _saveTeams(root, next);
5843
- ok(`team 제거: ${id}`);
5844
- return;
5845
- }
5846
- // 1.9.372 (UR-0073 Phase B): team preview — dry-run 실행 계획 미리보기 (실제 dispatch/spawn/배포 없음).
5847
- if (sub === 'preview') {
5848
- const t = teams.find(x => x.id === id);
5849
- if (!t) { fail(`team 없음: ${id}`); return; }
5850
- const plan = _composeTeamPlan(t, arg('--task', null));
5851
- if (json) { log(JSON.stringify({ version: VERSION, dryRun: true, ...plan }, null, 2)); return; }
5852
- log(`# team preview ${t.id} (1.9.372, UR-0073 Phase B) — dry-run (실제 실행 없음)`);
5853
- log(` task: ${plan.task}`);
5854
- log(` schedule: ${plan.schedule} · members: ${plan.memberCount}`);
5855
- if (!plan.steps.length) { warn('members 없음 — leerness team add <id> --members claude,codex 로 지정'); return; }
5856
- log(` 실행 계획 (미리보기 · 자동 실행 안 함):`);
5857
- for (const s of plan.steps) {
5858
- log(` • ${s.member}${s.personas.length ? ' [' + s.personas.join(',') + ']' : ''}`);
5859
- log(` ↳ ${s.suggestedCommand}`);
5860
- }
5861
- log(`\n ⓘ dry-run — 실제 dispatch/배포 없음. 위 명령을 검토 후 직접 실행하거나, 향후 Phase C(스케줄)/D(배포)에서 게이트 적용.`);
5862
- return;
5863
- }
5864
- // 1.9.376 (UR-0073 Phase D): team deploy — 사용자 설정 deployCommand 실행. 안전: dry-run 기본 + --yes + LEERNESS_TEAM_DEPLOY=1 이중 게이트 + shell-guard.
5865
- if (sub === 'deploy') {
5866
- const t = teams.find(x => x.id === id);
5867
- if (!t) { fail(`team 없음: ${id}`); return; }
5868
- const gate = _teamDeployGate(t, { yes: has('--yes'), envOn: process.env.LEERNESS_TEAM_DEPLOY === '1' });
5869
- if (json) { log(JSON.stringify({ version: VERSION, teamId: t.id, ...gate }, null, 2)); if (gate.mode !== 'execute') return; }
5870
- if (gate.mode === 'no-command') { fail(`team '${t.id}' deployCommand 미설정 — leerness team add ${t.id} --deploy "<배포 명령>"`); return; }
5871
- if (gate.mode === 'dry-run') {
5872
- log(`# team deploy ${t.id} (1.9.376, UR-0073 Phase D) — dry-run (실행 없음)`);
5873
- log(` 배포 명령: ${gate.command}`);
5874
- log(` ⓘ ${gate.message}`);
5875
- log(` 실행: LEERNESS_TEAM_DEPLOY=1 leerness team deploy ${t.id} --yes (셸 호환성 점검 후 실행)`);
5876
- return;
5877
- }
5878
- if (gate.mode === 'gated') { fail(`${gate.message} — dry-run 으로 먼저 검토: leerness team deploy ${t.id}`); return; }
5879
- // execute: shell-guard 정적 점검(advisory) 후 spawn
5880
- try {
5881
- const ctx = _detectShellCtx();
5882
- const guard = _shellGuardAnalyze ? _shellGuardAnalyze(gate.command, ctx) : null;
5883
- if (guard && guard.findings && guard.findings.length) {
5884
- warn(`shell-guard 경고 ${guard.findings.length}건 (배포 명령): ${guard.findings.map(f => f.rule || f.kind || f).join(', ')}`);
5885
- }
5886
- } catch {}
5887
- log(`# team deploy ${t.id} — 실행 (LEERNESS_TEAM_DEPLOY=1 + --yes)`);
5888
- log(` $ ${gate.command}`);
5889
- const r = cp.spawnSync(gate.command, { cwd: root, shell: true, stdio: 'inherit', timeout: 600000 });
5890
- if (r.status === 0) ok(`team deploy 완료: ${t.id} (exit 0)`);
5891
- else { fail(`team deploy 실패: ${t.id} (exit ${r.status})`); }
5892
- return;
5893
- }
5894
- fail(`알 수 없는 team 하위명령: ${sub} (list|add|show|remove|preview|deploy)`);
5895
- }
5791
+ // 1.9.389 (UR-0025 핸들러 모듈화 2번째): teamCmd 핸들러를 lib/team.js 로 분리.
5792
+ // harness deps(VERSION · 공유 저장 _loadTeams/_saveTeams · _detectShellCtx · argv 파서 arg/has)를 구성해 위임(thin wrapper). 호출부/동작 무변경.
5793
+ const _team = require('../lib/team');
5794
+ function teamCmd(root, sub, id, opts = {}) { return _team.teamCmd(root, sub, id, opts, { VERSION, _loadTeams, _saveTeams, _detectShellCtx, arg, has }); }
5896
5795
 
5897
5796
  // 1.9.112: 전용 lessons.md (Memory Write Surface 5번째)
5898
5797
  const lessonsPath = root => path.join(root, '.harness/lessons.md');
@@ -14608,61 +14507,6 @@ function lessonsCmd(root) {
14608
14507
  // - tests: tests/foo.test.ts
14609
14508
  // - notes: 자유 메모
14610
14509
  function featureGraphPath(root) { return path.join(absRoot(root), '.harness', 'feature-graph.md'); }
14611
- function _featureGraphTemplate() {
14612
- return `# Feature Graph (1.9.141)\n\n` +
14613
- `> **목적**: 각 기능의 인과관계를 정확히 정리해서 코드 작성 전 영향 범위를 자동 추적.\n` +
14614
- `> 신규 기능 추가, 데이터 형식 변경, 외부 API 매칭 작업 전 \`leerness feature impact <id>\`로 확인.\n` +
14615
- `> handoff가 현재 task 키워드로 자동 매칭해서 영향받는 feature 목록을 회수.\n\n` +
14616
- `## How to use\n\n` +
14617
- `\`\`\`bash\n` +
14618
- `leerness feature add "User Auth" # F-0001 자동 부여\n` +
14619
- `leerness feature link F-0002 --depends-on F-0001 # 의존 관계\n` +
14620
- `leerness feature link F-0001 --affects F-0002,F-0005 # 영향 관계 (다수)\n` +
14621
- `leerness feature link F-0001 --co-changes-with F-0011 # 함께 변해야 하는 기능\n` +
14622
- `leerness feature impact F-0001 # 영향받는 전체 (transitive)\n` +
14623
- `leerness feature list --json # 그래프 JSON\n` +
14624
- `leerness feature show F-0001 # 단일 상세\n` +
14625
- `\`\`\`\n\n` +
14626
- `## Nodes\n\n`;
14627
- }
14628
- function _parseFeatureGraph(text) {
14629
- if (!text) return [];
14630
- const nodes = [];
14631
- const re = /^## (F-\d{4})\s+(.+?)\s*$/gm;
14632
- const positions = [];
14633
- let m;
14634
- while ((m = re.exec(text)) !== null) positions.push({ id: m[1], title: m[2], start: m.index });
14635
- for (let i = 0; i < positions.length; i++) {
14636
- const start = positions[i].start;
14637
- const end = i + 1 < positions.length ? positions[i + 1].start : text.length;
14638
- const block = text.slice(start, end);
14639
- const parseField = (key) => {
14640
- // 1.9.141 fix: \s 은 \n 도 포함하므로 [ \t]* 로 newline 비포함 horizontal whitespace 만 매칭
14641
- const r = new RegExp(`^- ${key}:[ \\t]*(.*?)$`, 'mi');
14642
- const mm = block.match(r);
14643
- return mm ? mm[1].trim() : '';
14644
- };
14645
- const parseList = (key) => {
14646
- const v = parseField(key);
14647
- if (!v) return [];
14648
- return v.split(/[,\s]+/).map(s => s.trim()).filter(Boolean);
14649
- };
14650
- nodes.push({
14651
- id: positions[i].id,
14652
- title: positions[i].title,
14653
- dependsOn: parseList('depends-on'),
14654
- affects: parseList('affects'),
14655
- coChangesWith: parseList('co-changes-with'),
14656
- files: parseList('files'),
14657
- input: parseField('input'),
14658
- output: parseField('output'),
14659
- errorModes: parseList('error-modes'),
14660
- tests: parseList('tests'),
14661
- notes: parseField('notes')
14662
- });
14663
- }
14664
- return nodes;
14665
- }
14666
14510
  function _readFeatureGraph(root) {
14667
14511
  const p = featureGraphPath(root);
14668
14512
  if (!exists(p)) return { nodes: [], text: '' };
@@ -14674,23 +14518,6 @@ function _ensureFeatureGraph(root) {
14674
14518
  if (!exists(p)) writeUtf8(p, _featureGraphTemplate());
14675
14519
  return p;
14676
14520
  }
14677
- function _nextFeatureId(nodes) {
14678
- const used = new Set(nodes.map(n => parseInt(n.id.slice(2), 10)));
14679
- let n = 1; while (used.has(n)) n++;
14680
- return 'F-' + String(n).padStart(4, '0');
14681
- }
14682
- function _featureBlock(node) {
14683
- return `## ${node.id} ${node.title}\n` +
14684
- `- depends-on: ${(node.dependsOn || []).join(', ')}\n` +
14685
- `- affects: ${(node.affects || []).join(', ')}\n` +
14686
- `- co-changes-with: ${(node.coChangesWith || []).join(', ')}\n` +
14687
- `- files: ${(node.files || []).join(', ')}\n` +
14688
- `- input: ${node.input || ''}\n` +
14689
- `- output: ${node.output || ''}\n` +
14690
- `- error-modes: ${(node.errorModes || []).join(', ')}\n` +
14691
- `- tests: ${(node.tests || []).join(', ')}\n` +
14692
- `- notes: ${node.notes || ''}\n\n`;
14693
- }
14694
14521
  function _writeFeatureGraph(root, nodes) {
14695
14522
  const p = _ensureFeatureGraph(root);
14696
14523
  const header = _featureGraphTemplate();
package/lib/pure-utils.js CHANGED
@@ -929,7 +929,9 @@ module.exports = {
929
929
  // 1.9.385 (UR-0086, 5th외부평가): contract spec 순수 파서 (markdown bullet 함수 선언 감지)
930
930
  _parseContractSpec,
931
931
  // 1.9.386 (UR-0087, 5th외부평가): 간이 .gitignore 매칭 + glob (bare .env → .env.* 과잉보호 제거)
932
- _gitignoreMatch, _globToRe
932
+ _gitignoreMatch, _globToRe,
933
+ // 1.9.390 (UR-0025): feature-graph 순수 코어 (템플릿/파서/ID/블록)
934
+ _featureGraphTemplate, _parseFeatureGraph, _nextFeatureId, _featureBlock
933
935
  };
934
936
 
935
937
  // 1.9.355 (UR-0075 Phase A): AI 에이전트용 크로스버전 마이그레이션 안전 워크플로 가이드 (순수 텍스트). 임시설치 + --path + 백업 + diff 검증.
@@ -1016,3 +1018,77 @@ function _gitignoreMatch(giText, fileRel) {
1016
1018
  }
1017
1019
  return false;
1018
1020
  }
1021
+
1022
+ // 1.9.390 (UR-0025): feature-graph 순수 코어 — 템플릿/파서/ID/블록 렌더 (I/O 없음). harness 의 _readFeatureGraph/_writeFeatureGraph 가 사용.
1023
+ function _featureGraphTemplate() {
1024
+ return `# Feature Graph (1.9.141)\n\n` +
1025
+ `> **목적**: 각 기능의 인과관계를 정확히 정리해서 코드 작성 전 영향 범위를 자동 추적.\n` +
1026
+ `> 신규 기능 추가, 데이터 형식 변경, 외부 API 매칭 작업 전 \`leerness feature impact <id>\`로 확인.\n` +
1027
+ `> handoff가 현재 task 키워드로 자동 매칭해서 영향받는 feature 목록을 회수.\n\n` +
1028
+ `## How to use\n\n` +
1029
+ `\`\`\`bash\n` +
1030
+ `leerness feature add "User Auth" # F-0001 자동 부여\n` +
1031
+ `leerness feature link F-0002 --depends-on F-0001 # 의존 관계\n` +
1032
+ `leerness feature link F-0001 --affects F-0002,F-0005 # 영향 관계 (다수)\n` +
1033
+ `leerness feature link F-0001 --co-changes-with F-0011 # 함께 변해야 하는 기능\n` +
1034
+ `leerness feature impact F-0001 # 영향받는 전체 (transitive)\n` +
1035
+ `leerness feature list --json # 그래프 JSON\n` +
1036
+ `leerness feature show F-0001 # 단일 상세\n` +
1037
+ `\`\`\`\n\n` +
1038
+ `## Nodes\n\n`;
1039
+ }
1040
+ function _parseFeatureGraph(text) {
1041
+ if (!text) return [];
1042
+ const nodes = [];
1043
+ const re = /^## (F-\d{4})\s+(.+?)\s*$/gm;
1044
+ const positions = [];
1045
+ let m;
1046
+ while ((m = re.exec(text)) !== null) positions.push({ id: m[1], title: m[2], start: m.index });
1047
+ for (let i = 0; i < positions.length; i++) {
1048
+ const start = positions[i].start;
1049
+ const end = i + 1 < positions.length ? positions[i + 1].start : text.length;
1050
+ const block = text.slice(start, end);
1051
+ const parseField = (key) => {
1052
+ // 1.9.141 fix: \s 은 \n 도 포함하므로 [ \t]* 로 newline 비포함 horizontal whitespace 만 매칭
1053
+ const r = new RegExp(`^- ${key}:[ \\t]*(.*?)$`, 'mi');
1054
+ const mm = block.match(r);
1055
+ return mm ? mm[1].trim() : '';
1056
+ };
1057
+ const parseList = (key) => {
1058
+ const v = parseField(key);
1059
+ if (!v) return [];
1060
+ return v.split(/[,\s]+/).map(s => s.trim()).filter(Boolean);
1061
+ };
1062
+ nodes.push({
1063
+ id: positions[i].id,
1064
+ title: positions[i].title,
1065
+ dependsOn: parseList('depends-on'),
1066
+ affects: parseList('affects'),
1067
+ coChangesWith: parseList('co-changes-with'),
1068
+ files: parseList('files'),
1069
+ input: parseField('input'),
1070
+ output: parseField('output'),
1071
+ errorModes: parseList('error-modes'),
1072
+ tests: parseList('tests'),
1073
+ notes: parseField('notes')
1074
+ });
1075
+ }
1076
+ return nodes;
1077
+ }
1078
+ function _nextFeatureId(nodes) {
1079
+ const used = new Set(nodes.map(n => parseInt(n.id.slice(2), 10)));
1080
+ let n = 1; while (used.has(n)) n++;
1081
+ return 'F-' + String(n).padStart(4, '0');
1082
+ }
1083
+ function _featureBlock(node) {
1084
+ return `## ${node.id} ${node.title}\n` +
1085
+ `- depends-on: ${(node.dependsOn || []).join(', ')}\n` +
1086
+ `- affects: ${(node.affects || []).join(', ')}\n` +
1087
+ `- co-changes-with: ${(node.coChangesWith || []).join(', ')}\n` +
1088
+ `- files: ${(node.files || []).join(', ')}\n` +
1089
+ `- input: ${node.input || ''}\n` +
1090
+ `- output: ${node.output || ''}\n` +
1091
+ `- error-modes: ${(node.errorModes || []).join(', ')}\n` +
1092
+ `- tests: ${(node.tests || []).join(', ')}\n` +
1093
+ `- notes: ${node.notes || ''}\n\n`;
1094
+ }
package/lib/team.js ADDED
@@ -0,0 +1,122 @@
1
+ // lib/team.js — 에이전트 팀 정의 핸들러 (UR-0073: list/add/show/remove/preview/deploy).
2
+ // 1.9.389 (UR-0025 큰 핸들러 모듈화 2번째): bin/harness.js 에서 teamCmd 분리.
3
+ // - I/O 프리미티브: ./io. 순수 로직: ./pure-utils(_composeTeamPlan/_teamDeployGate). 정적분석: ./analyzers(_shellGuardAnalyze).
4
+ // - harness 고유 의존(VERSION · 공유 저장 함수 _loadTeams/_saveTeams · _detectShellCtx · argv 파서 arg/has)은 deps 로 주입(DI).
5
+ // - _loadTeams/_saveTeams 는 handoff(team reminders)도 쓰는 공유 함수라 harness 에 유지하고 주입만 받음.
6
+ 'use strict';
7
+ const cp = require('child_process');
8
+ const { absRoot, log, ok, warn, fail, now } = require('./io');
9
+ const { _composeTeamPlan, _teamDeployGate } = require('./pure-utils');
10
+ const { _shellGuardAnalyze } = require('./analyzers');
11
+
12
+ function teamCmd(root, sub, id, opts = {}, deps = {}) {
13
+ const { VERSION, _loadTeams, _saveTeams, _detectShellCtx, arg, has } = deps;
14
+ root = absRoot(root);
15
+ const json = opts.json || has('--json');
16
+ const teams = _loadTeams(root);
17
+ sub = sub || 'list';
18
+ if (sub === 'list') {
19
+ if (json) { log(JSON.stringify({ version: VERSION, root, count: teams.length, teams }, null, 2)); return; }
20
+ log(`# leerness team (1.9.371, UR-0073 Phase A) — 에이전트 팀 정의 (opt-in · 정의 전용)`);
21
+ if (!teams.length) { log(' (정의된 팀 없음) — leerness team add <id> --name "..." --purpose "..." --personas a,b --members claude,codex'); return; }
22
+ for (const t of teams) log(` • ${t.id}${t.name ? ' — ' + t.name : ''} [${t.status || 'active'}/${t.schedule || 'manual'}] personas:${(t.personas || []).join('|') || '-'} members:${(t.members || []).join('|') || '-'}`);
23
+ log(`\n ⓘ 정의 전용 — 자동 실행 없음. 실행(리뷰/배포/블로그)은 향후 opt-in 단계.`);
24
+ return;
25
+ }
26
+ if (sub === 'add') {
27
+ const teamId = String(id || '').toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[.\-]+|[.\-]+$/g, '');
28
+ if (!teamId || teamId.includes('..')) { fail(`무효한 team id: "${id}" (영숫자/._- 만)`); return; }
29
+ if (teams.some(t => t.id === teamId)) { warn(`이미 존재: ${teamId} (제거 후 재정의: leerness team remove ${teamId})`); return; }
30
+ const splitCsv = v => (v && v !== true) ? String(v).split(',').map(s => s.trim()).filter(Boolean) : [];
31
+ const sched = arg('--schedule', 'manual');
32
+ const validSched = new Set(['manual', 'every-session', 'daily', 'weekly']);
33
+ const team = {
34
+ id: teamId,
35
+ name: arg('--name', '') === true ? '' : arg('--name', ''),
36
+ purpose: arg('--purpose', '') === true ? '' : arg('--purpose', ''),
37
+ personas: splitCsv(arg('--personas', null)),
38
+ members: splitCsv(arg('--members', null)),
39
+ schedule: validSched.has(sched) ? sched : 'manual',
40
+ deployCommand: arg('--deploy', '') === true ? '' : arg('--deploy', ''), // 1.9.376 (Phase D): 사용자 설정 배포 명령 (실행은 게이트)
41
+ status: 'active',
42
+ createdAt: now()
43
+ };
44
+ teams.push(team);
45
+ _saveTeams(root, teams);
46
+ ok(`team 정의: ${teamId} (personas:${team.personas.length} members:${team.members.length} schedule:${team.schedule})`);
47
+ log(` ⓘ 정의 전용 — 자동 실행 없음. 목록: leerness team list`);
48
+ return;
49
+ }
50
+ if (sub === 'show') {
51
+ const t = teams.find(x => x.id === id);
52
+ if (!t) { fail(`team 없음: ${id}`); return; }
53
+ if (json) { log(JSON.stringify(t, null, 2)); return; }
54
+ log(`# team ${t.id}`);
55
+ log(` name: ${t.name || ''}`);
56
+ log(` purpose: ${t.purpose || ''}`);
57
+ log(` personas: ${(t.personas || []).join(', ') || '-'}`);
58
+ log(` members: ${(t.members || []).join(', ') || '-'}`);
59
+ log(` schedule: ${t.schedule || 'manual'} · status: ${t.status || 'active'}`);
60
+ log(` deploy: ${t.deployCommand || '-'}`);
61
+ return;
62
+ }
63
+ if (sub === 'remove') {
64
+ const before = teams.length;
65
+ const next = teams.filter(x => x.id !== id);
66
+ if (next.length === before) { warn(`team 없음: ${id}`); return; }
67
+ _saveTeams(root, next);
68
+ ok(`team 제거: ${id}`);
69
+ return;
70
+ }
71
+ // 1.9.372 (UR-0073 Phase B): team preview — dry-run 실행 계획 미리보기 (실제 dispatch/spawn/배포 없음).
72
+ if (sub === 'preview') {
73
+ const t = teams.find(x => x.id === id);
74
+ if (!t) { fail(`team 없음: ${id}`); return; }
75
+ const plan = _composeTeamPlan(t, arg('--task', null));
76
+ if (json) { log(JSON.stringify({ version: VERSION, dryRun: true, ...plan }, null, 2)); return; }
77
+ log(`# team preview ${t.id} (1.9.372, UR-0073 Phase B) — dry-run (실제 실행 없음)`);
78
+ log(` task: ${plan.task}`);
79
+ log(` schedule: ${plan.schedule} · members: ${plan.memberCount}`);
80
+ if (!plan.steps.length) { warn('members 없음 — leerness team add <id> --members claude,codex 로 지정'); return; }
81
+ log(` 실행 계획 (미리보기 · 자동 실행 안 함):`);
82
+ for (const s of plan.steps) {
83
+ log(` • ${s.member}${s.personas.length ? ' [' + s.personas.join(',') + ']' : ''}`);
84
+ log(` ↳ ${s.suggestedCommand}`);
85
+ }
86
+ log(`\n ⓘ dry-run — 실제 dispatch/배포 없음. 위 명령을 검토 후 직접 실행하거나, 향후 Phase C(스케줄)/D(배포)에서 게이트 적용.`);
87
+ return;
88
+ }
89
+ // 1.9.376 (UR-0073 Phase D): team deploy — 사용자 설정 deployCommand 실행. 안전: dry-run 기본 + --yes + LEERNESS_TEAM_DEPLOY=1 이중 게이트 + shell-guard.
90
+ if (sub === 'deploy') {
91
+ const t = teams.find(x => x.id === id);
92
+ if (!t) { fail(`team 없음: ${id}`); return; }
93
+ const gate = _teamDeployGate(t, { yes: has('--yes'), envOn: process.env.LEERNESS_TEAM_DEPLOY === '1' });
94
+ if (json) { log(JSON.stringify({ version: VERSION, teamId: t.id, ...gate }, null, 2)); if (gate.mode !== 'execute') return; }
95
+ if (gate.mode === 'no-command') { fail(`team '${t.id}' deployCommand 미설정 — leerness team add ${t.id} --deploy "<배포 명령>"`); return; }
96
+ if (gate.mode === 'dry-run') {
97
+ log(`# team deploy ${t.id} (1.9.376, UR-0073 Phase D) — dry-run (실행 없음)`);
98
+ log(` 배포 명령: ${gate.command}`);
99
+ log(` ⓘ ${gate.message}`);
100
+ log(` 실행: LEERNESS_TEAM_DEPLOY=1 leerness team deploy ${t.id} --yes (셸 호환성 점검 후 실행)`);
101
+ return;
102
+ }
103
+ if (gate.mode === 'gated') { fail(`${gate.message} — dry-run 으로 먼저 검토: leerness team deploy ${t.id}`); return; }
104
+ // execute: shell-guard 정적 점검(advisory) 후 spawn
105
+ try {
106
+ const ctx = _detectShellCtx();
107
+ const guard = _shellGuardAnalyze ? _shellGuardAnalyze(gate.command, ctx) : null;
108
+ if (guard && guard.findings && guard.findings.length) {
109
+ warn(`shell-guard 경고 ${guard.findings.length}건 (배포 명령): ${guard.findings.map(f => f.rule || f.kind || f).join(', ')}`);
110
+ }
111
+ } catch {}
112
+ log(`# team deploy ${t.id} — 실행 (LEERNESS_TEAM_DEPLOY=1 + --yes)`);
113
+ log(` $ ${gate.command}`);
114
+ const r = cp.spawnSync(gate.command, { cwd: root, shell: true, stdio: 'inherit', timeout: 600000 });
115
+ if (r.status === 0) ok(`team deploy 완료: ${t.id} (exit 0)`);
116
+ else { fail(`team deploy 실패: ${t.id} (exit ${r.status})`); }
117
+ return;
118
+ }
119
+ fail(`알 수 없는 team 하위명령: ${sub} (list|add|show|remove|preview|deploy)`);
120
+ }
121
+
122
+ module.exports = { teamCmd };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leerness",
3
- "version": "1.9.388",
3
+ "version": "1.9.390",
4
4
  "description": "Leerness: 비파괴 마이그레이션, 자동 버전 감지·업데이트, 계획/진행/핸드오프 자동화, 게으름·시크릿·인코딩 자동 가드, Claude Code 슬래시 통합을 갖춘 한국어 우선 AI 개발 하네스.",
5
5
  "keywords": [
6
6
  "leerness",