kedovi 0.103.0 → 0.104.0

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
@@ -2,6 +2,18 @@
2
2
 
3
3
  `kedovi upgrade` 가 올린 버전 사이의 항목을 표로 보여 준다. 배포할 때 이번 버전 항목을 맨 위에 더한다 (`## 버전` 아래 `| 구분 | 내용 |` 표, 한 줄씩 짧게).
4
4
 
5
+ ## 0.104.0
6
+
7
+ | 구분 | 내용 |
8
+ |---|---|
9
+ | 기능 | `kedovi init`: repo 가 3개 이상이면 「repo 폴더 묶기」 질문 (주소 경로 기준 · 이름 앞부분 기준 · 묶지 않음) |
10
+ | 기능 | `kedovi repo group [--apply]`: 기존 워크스페이스의 repo 를 그룹 폴더로 한 번에 옮김. 작업 폴더 연결도 다시 이음 |
11
+ | 기능 | `kedovi worktree clean`: 끝난 작업 폴더(squash 머지 포함) 정리, 킷 밖에서 진행 중인 것은 `.worktrees/` 로 옮김 |
12
+ | 기능 | `kedovi worktree list` 가 모든 작업 폴더(직접 · Claude 것 포함)와 상태를 보여 줌. `add --branch` · `--base` |
13
+ | 검사 | `.worktrees/` 밖에 `git worktree add` 하면 훅이 막음 (메인 · 리더 · 팀원 모두) |
14
+ | 알림 | 하루 넘게 손대지 않았거나 킷 밖에 있는 작업 폴더를 6시간마다 한 줄 알림 |
15
+ | 변경 | `git.cleanupMerged` 는 브랜치 삭제만 뜻함. 작업 폴더 정리는 늘 제안 |
16
+
5
17
  ## 0.103.0
6
18
 
7
19
  | 구분 | 내용 |
package/bin/kedovi.js CHANGED
@@ -15,6 +15,7 @@
15
15
  * kedovi rules ondemand|always <ID…|repo-tasks> 상시 규칙을 필요할 때만 읽게 (AGENTS.md 를 줄인다) · 되돌리기
16
16
  * kedovi repo add [주소|폴더|이름] [--kind …] [--group <그룹>] repo 를 더한다 (이름만 주면 repos/<이름> 에 원격 없이 새로 만든다, legacy 제외. --group 이면 repos/<그룹>/<이름>)
17
17
  * kedovi repo move <이름> --group <그룹>|--no-group repo 를 그룹 폴더로 옮긴다: 폴더 · workspace.json · 문서의 경로를 고치고 sync
18
+ * kedovi repo group [--apply] [--by remote|name] 주소 경로(또는 이름 앞부분) 기준 그룹 폴더 추천을 보이고, --apply 면 모두 옮긴다
18
19
  * kedovi repo remove <이름> [--delete] repo 를 뺀다: workspace.json · 리뷰 대상에서 지우고 sync, 이름이 남은 문서를 알린다. 폴더는 --delete 일 때만 (커밋 안 한 변경 · push 안 한 커밋이 있으면 거부)
19
20
  * kedovi repo guides [<이름> follow|kit|ignore] [--rescan [<이름>]] repo 안에 원래 있던 AI 지침(CLAUDE.md · AGENTS.md · 룰 · 스킬 등) 보기 · 따르는 방식 정하기 (follow = repo 지침 우선, 기본 · kit = 킷 규칙 우선 · ignore = 무시) · 다시 훑기
20
21
  * kedovi team [id] [--take 1,2|all] 팀 현황 (모두의 핸드오프) · 한 사람 자세히 · 그 사람 TODO 항목을 내 TODO 로 인수
@@ -47,7 +48,7 @@
47
48
  * kedovi suggest [list] · set <id> yes|no [--all] · reset [<id>] · off|on [--all] 기능 추천: 대화 주제 · 상태에 맞는 킷 기능을 에이전트가 가끔 답 끝에 한 줄로 묻는다. 정한 것(씀 · 안 씀)은 다시 묻지 않는다 (--all = 이 PC 의 모든 프로젝트)
48
49
  * kedovi tips 출력이 많아 읽기 힘들 때 쓰는 Claude Code 화면 기능 (/tui fullscreen · /focus · Ctrl+O). kedovi start 가 이 PC 에서 처음 한 번 보여 준다
49
50
  * kedovi agents watch [--once] [--all] [--json] [--tmux] 에이전트 진행 보기 (Claude Code): 메인이 부른 작업 리더 · 역할 에이전트 · 그 아래 팀원이 지금 무엇을 하는지 나무 모양으로 (이름 없는 서브에이전트도). 읽기만
50
- * kedovi worktree add|merge|remove <repo> <단위> · list 작업 리더 worktree: 같은 repo 를 여러 작업 리더가 동시에 고칠 때 리더마다 .worktrees/<repo>/<단위> (merge = 본 작업 트리에 커밋하지 않은 변경으로 옮김)
51
+ * kedovi worktree add|merge|remove <repo> <단위> · list · clean 작업 폴더(worktree): 같은 repo 를 여러 작업 리더가 동시에 고칠 때 리더마다 .worktrees/<repo>/<단위> (merge = 본 작업 트리에 커밋하지 않은 변경으로 옮김, clean = 끝난 작업 폴더 정리 · 킷 밖에 만든 것은 .worktrees/ 로)
51
52
  * kedovi docs build [repo|폴더] [--out docs-site] [--force] [--no-source] [--write-config] · check [repo|폴더] 문서 사이트: 기획 repo 의 md · 화면설계서 장 → docs-site/ (가이드와 같은 화면 틀 · 근거 색인 ids.json · 묶음은 docs-site.json) · 어긋남 검사 · 문서 점검 경고
52
53
  * kedovi docs show <ID> [--in <파일 조각>] [--all] · refs <ID> [--docs] 기획 문서를 ID 단위로: 정의 부분만 출력 · 그 ID 가 나오는 곳(기획 · 코드 · 이슈 repo, 파일:줄)
53
54
  * kedovi docs trace [--ids FN] [--all] [--strict] [--md] [--new] 기획 ID 와 코드의 @spec 주석 대조: 코드에 없는 ID · 테스트에 없는 수용 기준 · 기획에 정의 없는 ID. --md 추적표 · --new 새 진입 파일 중 ID 없는 것 (커밋 전)
@@ -1103,6 +1104,8 @@ const validateOne = (taken, required, allowNew) => (v) => {
1103
1104
 
1104
1105
  /** ~ 로 시작하는 경로를 홈 폴더로 */
1105
1106
  const expandHome = (x) => (/^~(?=$|[\\/])/.test(x) ? path.join(require('os').homedir(), x.slice(1)) : x);
1107
+ /** 로컬 repo 폴더의 origin 주소 (없으면 '') */
1108
+ const originOf = (dir) => { try { return execFileSync('git', ['-C', dir, 'remote', 'get-url', 'origin'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim(); } catch { return ''; } };
1106
1109
  const isFolder = (x) => { try { return fs.statSync(path.resolve(expandHome(x))).isDirectory(); } catch { return false; } };
1107
1110
 
1108
1111
  /** repo 를 넣는 방식 — clone(git 주소) · 기존 로컬 폴더(링크) · 새로 만들기(git init). 원격 없이 로컬에만 둔 repo 는 기존 폴더로 넣는다 */
@@ -1235,7 +1238,7 @@ async function cmdInit(argv) {
1235
1238
  if (given && !/^[a-z][a-z0-9-]*$/.test(given)) fail(`프로젝트명은 영문 소문자·숫자·'-' 로 쓰고 문자로 시작합니다: ${given}`);
1236
1239
  const here = ['empty', 'fresh-repo'].includes(kit.folderState(cwd)) && path.basename(cwd) !== '' ? cwd : null;
1237
1240
  const targetOf = (name) => (here && (kit.folderState(cwd) === 'fresh-repo' || path.basename(cwd) === name) ? cwd : path.resolve(cwd, name));
1238
- const a = { title: given, type: undefined, approach: undefined, from: '', code: [], docs: [], issues: [], legacy: [], hosts: {}, pages: false };
1241
+ const a = { title: given, type: undefined, approach: undefined, from: '', code: [], docs: [], issues: [], legacy: [], hosts: {}, pages: false, grouping: undefined };
1239
1242
  const flow = () => TYPE_FLOW[a.type || 'new'];
1240
1243
  // 다른 목록에 이미 넣은 값 (같은 repo 를 두 종류로 넣지 않게)
1241
1244
  const othersOf = (kind) => ['code', 'docs', 'issues', 'legacy'].filter((k) => k !== kind).flatMap((k) => a[k]);
@@ -1311,6 +1314,18 @@ async function cmdInit(argv) {
1311
1314
  }
1312
1315
  return a.hosts;
1313
1316
  }, set: () => {} },
1317
+ // repo 가 여럿이면 주소 경로 · 이름으로 그룹 폴더(repos/<그룹>/<이름>)를 추천한다
1318
+ { when: () => !!groupChoices(), run: async () => {
1319
+ const c = groupChoices();
1320
+ const preview = (m) => { const by = {}; for (const [n, g] of Object.entries(m)) (by[g] = by[g] || []).push(n); return Object.entries(by).map(([g, ns]) => `${g}/ ${ns.length}개`).join(' · '); };
1321
+ const options = [
1322
+ ...(c.remote ? [{ value: 'remote', label: '주소 경로 기준 (권장)', hint: preview(c.remote) }] : []),
1323
+ ...(c.name ? [{ value: 'name', label: c.remote ? '이름 앞부분 기준' : '이름 앞부분 기준 (권장)', hint: preview(c.name) }] : []),
1324
+ { value: 'none', label: '묶지 않음', hint: 'repos/<이름> 한 단계' },
1325
+ ];
1326
+ return choose({ message: 'repo 폴더 묶기', hint: 'repo 를 repos/<그룹>/<이름> 으로 나눠 받습니다. 그룹에 들지 않는 repo 는 repos/<이름>. 나중에 kedovi repo group 으로 바꿉니다.',
1327
+ initialValue: options.some((o) => o.value === a.grouping) ? a.grouping : options[0].value, options });
1328
+ }, set: (v) => { a.grouping = v; } },
1314
1329
  { run: async () => {
1315
1330
  p.note(summary().join('\n'), '만들 내용');
1316
1331
  return yesNo({ message: '이대로 만들까요?', hint: '예를 누르면 워크스페이스를 만들고 repo 를 clone 합니다.' });
@@ -1333,8 +1348,17 @@ async function cmdInit(argv) {
1333
1348
  if (kind === 'code' || kind === 'issues') { const h = hostFor(list[i]); if (h) r.host = h; }
1334
1349
  return r;
1335
1350
  });
1336
- return [...(flow().code ? withHost(a.code, 'code') : []), ...withHost(a.docs, 'docs'), ...withHost(a.issues, 'issues'),
1351
+ const list = [...(flow().code ? withHost(a.code, 'code') : []), ...withHost(a.docs, 'docs'), ...withHost(a.issues, 'issues'),
1337
1352
  ...(flow().legacy ? withHost(a.legacy, 'legacy') : [])];
1353
+ const pick = a.grouping && a.grouping !== 'none' ? (groupChoices(list) || {})[a.grouping] : null;
1354
+ if (pick) for (const r of list) if (pick[r.name]) r.group = pick[r.name];
1355
+ return list;
1356
+ };
1357
+ // 그룹 추천 (repo 3개 이상): 로컬 폴더는 그 origin 주소로 본다
1358
+ const groupChoices = (list = repos()) => {
1359
+ if (list.length < 3) return null;
1360
+ const c = kit.suggestGroups(list.map((r) => ({ name: r.name, remote: r.remote || (r.path ? originOf(path.resolve(root(), r.path)) : '') })));
1361
+ return c.remote || c.name ? c : null;
1338
1362
  };
1339
1363
  const summary = () => {
1340
1364
  const typePack = kit.TYPE_RULES[a.type].pack;
@@ -1344,7 +1368,7 @@ async function cmdInit(argv) {
1344
1368
  `유형 ${kit.PROJECT_TYPES[a.type]}${['enhancement', 'new'].includes(a.type) && a.approach ? ` · 진행 방식 ${kit.APPROACHES[a.approach].split(' (')[0]}` : ''}`,
1345
1369
  ...(a.from ? [`이어 받음 ${a.from}`] : []),
1346
1370
  `규칙 core${typePack ? `, ${typePack} (유형)` : ''} + repo 마다 스택·협업 도구 규칙`,
1347
- ...(rs.length ? rs.map((r) => `repos/${r.name.padEnd(16)} ${padTo(kit.REPO_KINDS[r.kind], 14)} ${padTo(r.host ? kit.HOSTS[r.host] : '', 7)} ← ${r.remote || r.path || '새로 만듦 (원격 없음, git init)'}`) : ['repo (없음: 나중에 workspace.json 에 추가)']),
1371
+ ...(rs.length ? rs.map((r) => `${kit.repoRel(r).padEnd(23)} ${padTo(kit.REPO_KINDS[r.kind], 14)} ${padTo(r.host ? kit.HOSTS[r.host] : '', 7)} ← ${r.remote || r.path || '새로 만듦 (원격 없음, git init)'}`) : ['repo (없음: 나중에 workspace.json 에 추가)']),
1348
1372
  ...(a.docs.length ? [`Pages ${a.pages ? '켬: 기획 repo 에 원격에 맞는 CI 파일을 두고 docs-site/ 를 커밋한다' : '끔 (나중에 kedovi docs pages on)'}`] : []),
1349
1373
  '스택은 repo 를 받은 뒤 감지한다. 역할·브랜치는 workspace.json 에서 고친다',
1350
1374
  ];
@@ -2072,7 +2096,7 @@ async function cmdRules(argv = []) {
2072
2096
 
2073
2097
  // ───────────────────────── repo add ─────────────────────────
2074
2098
 
2075
- const REPO_USAGE = 'kedovi repo add [<git 주소 | 폴더 | 새로 만들 이름>] [--kind code|docs|issues|legacy] [--group <그룹>] · kedovi repo move <이름> --group <그룹>|--no-group · kedovi repo remove <이름> [--delete] · kedovi repo guides [<이름> follow|kit|ignore] [--rescan]';
2099
+ const REPO_USAGE = 'kedovi repo add [<git 주소 | 폴더 | 새로 만들 이름>] [--kind code|docs|issues|legacy] [--group <그룹>] · kedovi repo move <이름> --group <그룹>|--no-group · kedovi repo group [--apply] [--by remote|name] · kedovi repo remove <이름> [--delete] · kedovi repo guides [<이름> follow|kit|ignore] [--rescan]';
2076
2100
 
2077
2101
  /** 워크스페이스에 repo 를 더한다 — clone · 링크 · (이름만 주면) repos/<이름> 에 새로 만들기 → 스택 확인 → sync */
2078
2102
  /** repo 빼기: workspace.json repos(와 리뷰 대상 목록)에서 지우고 sync. 폴더는 --delete 일 때만, 커밋 안 한 변경 · push 안 한 커밋이 없을 때 지운다 */
@@ -2179,22 +2203,8 @@ function requireGroups(root) {
2179
2203
  if (!ok) fail('이 워크스페이스의 킷은 그룹 폴더(--group)를 모릅니다. kedovi upgrade 후 다시 하세요');
2180
2204
  }
2181
2205
 
2182
- /** repo 를 그룹 폴더로 옮긴다: 폴더 이동 → workspace.json group → 사람이 쓴 문서의 경로 → sync */
2183
- function cmdRepoMove(rest) {
2184
- const name = rest.find((x, i) => !x.startsWith('--') && rest[i - 1] !== '--group');
2185
- const gi = rest.indexOf('--group');
2186
- const group = rest.includes('--no-group') ? '' : gi >= 0 ? rest[gi + 1] : undefined;
2187
- if (!name || group === undefined || (gi >= 0 && (!group || group.startsWith('--')))) fail(`사용법: ${REPO_USAGE}`);
2188
- const root = locateWorkspace();
2189
- requireAdmin(root, 'repo 옮기기');
2190
- const wsFile = path.join(root, 'workspace.json');
2191
- const raw = JSON.parse(read(wsFile));
2192
- const repo = (raw.repos || []).find((r) => r.name === name);
2193
- if (!repo) fail(`workspace.json 에 없는 repo 입니다: ${name} (있는 것: ${(raw.repos || []).map((r) => r.name).join(', ') || '없음'})`);
2194
- if (group && !GROUP_NAME.test(group)) fail(`그룹 이름은 영문·숫자·._- 만 (한 단계): ${group}`);
2195
- if (group && raw.repos.some((r) => !r.group && r.name === group)) fail(`그룹 '${group}' 이 그룹 없는 repo 이름과 같아 폴더가 겹칩니다`);
2196
- if ((repo.group || '') === group) { console.log(`이미 ${kit.repoRel(repo)} 입니다`); return; }
2197
- if (group) requireGroups(root);
2206
+ /** repo 하나를 그룹 폴더로 옮긴다 (폴더 · worktree 연결 · workspace.json 항목 · 사람이 쓴 문서 경로). sync 는 부르는 쪽이. 반환: { from, to, folder, isLink, fixed } */
2207
+ function moveRepoFolder(root, raw, repo, group) {
2198
2208
  const from = kit.repoRel(repo);
2199
2209
  const to = kit.repoRel({ ...repo, group });
2200
2210
  const src = path.join(root, from), dst = path.join(root, to);
@@ -2207,12 +2217,13 @@ function cmdRepoMove(rest) {
2207
2217
  fs.mkdirSync(path.dirname(dst), { recursive: true });
2208
2218
  fs.renameSync(src, dst);
2209
2219
  folder = '옮김';
2220
+ // 이 repo 의 worktree 가 옛 경로를 가리키지 않게 다시 잇는다
2221
+ if (fs.existsSync(path.join(dst, '.git'))) spawnSync('git', ['-C', dst, 'worktree', 'repair'], { stdio: 'ignore' });
2210
2222
  }
2211
2223
  // 빈 그룹 폴더는 지운다
2212
2224
  const oldParent = path.dirname(src);
2213
2225
  if (repo.group && oldParent !== path.join(root, kit.REPOS_DIR)) { try { fs.rmdirSync(oldParent); } catch { /* 비어 있지 않음 */ } }
2214
2226
  if (group) repo.group = group; else delete repo.group;
2215
- fs.writeFileSync(wsFile, JSON.stringify(raw, null, 2) + '\n');
2216
2227
  // 사람이 쓴 문서 (워크스페이스 git 의 md · 생성물 · handoffs 제외) 의 옛 경로를 바꾼다
2217
2228
  const re = new RegExp(`(?<![\\w.-])${from.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![\\w.-])`, 'g');
2218
2229
  const listed = (spawnSync('git', ['-C', root, 'grep', '-l', '-F', '-e', from, '--', '*.md', ':!repos', ':!AGENTS.md', ':!CLAUDE.md', ':!.agents', ':!.claude', ':!.codex', ':!handoffs'], { encoding: 'utf8' }).stdout || '').trim().split('\n').filter(Boolean);
@@ -2223,19 +2234,75 @@ function cmdRepoMove(rest) {
2223
2234
  const next = cur.replace(re, to);
2224
2235
  if (next !== cur) { fs.writeFileSync(file, next); fixed.push(f); }
2225
2236
  }
2226
- const ok = runWorkspaceKit(root, isLink ? ['install'] : ['sync', '--quiet']);
2227
- console.log(`✔ repo 옮김: ${from} → ${to} · 폴더 ${folder}`);
2228
- if (fixed.length) console.log(` 문서 경로 고침: ${fixed.join(', ')}`);
2237
+ return { from, to, folder, isLink, fixed };
2238
+ }
2239
+
2240
+ /** repo 를 그룹 폴더로 옮긴다: 폴더 이동 → workspace.json group → 사람이 쓴 문서의 경로 → sync */
2241
+ function cmdRepoMove(rest) {
2242
+ const name = rest.find((x, i) => !x.startsWith('--') && rest[i - 1] !== '--group');
2243
+ const gi = rest.indexOf('--group');
2244
+ const group = rest.includes('--no-group') ? '' : gi >= 0 ? rest[gi + 1] : undefined;
2245
+ if (!name || group === undefined || (gi >= 0 && (!group || group.startsWith('--')))) fail(`사용법: ${REPO_USAGE}`);
2246
+ const root = locateWorkspace();
2247
+ requireAdmin(root, 'repo 옮기기');
2248
+ const wsFile = path.join(root, 'workspace.json');
2249
+ const raw = JSON.parse(read(wsFile));
2250
+ const repo = (raw.repos || []).find((r) => r.name === name);
2251
+ if (!repo) fail(`workspace.json 에 없는 repo 입니다: ${name} (있는 것: ${(raw.repos || []).map((r) => r.name).join(', ') || '없음'})`);
2252
+ if (group && !GROUP_NAME.test(group)) fail(`그룹 이름은 영문·숫자·._- 만 (한 단계): ${group}`);
2253
+ if (group && raw.repos.some((r) => !r.group && r.name === group)) fail(`그룹 '${group}' 이 그룹 없는 repo 이름과 같아 폴더가 겹칩니다`);
2254
+ if ((repo.group || '') === group) { console.log(`이미 ${kit.repoRel(repo)} 입니다`); return; }
2255
+ if (group) requireGroups(root);
2256
+ const m = moveRepoFolder(root, raw, repo, group);
2257
+ fs.writeFileSync(wsFile, JSON.stringify(raw, null, 2) + '\n');
2258
+ const ok = runWorkspaceKit(root, m.isLink ? ['install'] : ['sync', '--quiet']);
2259
+ console.log(`✔ repo 옮김: ${m.from} → ${m.to} · 폴더 ${m.folder}`);
2260
+ if (m.fixed.length) console.log(` 문서 경로 고침: ${m.fixed.join(', ')}`);
2229
2261
  console.log(' workspace.json 이 바뀌었습니다. commit · push 하면 팀에 적용됩니다 (팀원 PC 는 kedovi repo move 를 같이 하거나, 옛 폴더를 지우고 kedovi install)');
2230
2262
  console.log(' 열려 있는 IDE · 터미널은 새 경로로 다시 엽니다');
2231
2263
  if (!ok) process.exit(1);
2232
2264
  }
2233
2265
 
2266
+ /** 주소 경로 · 이름 기준 그룹 폴더 추천을 보이고, --apply [--by remote|name] 면 그대로 옮긴다 */
2267
+ function cmdRepoGroup(rest) {
2268
+ const root = locateWorkspace();
2269
+ const wsFile = path.join(root, 'workspace.json');
2270
+ const raw = JSON.parse(read(wsFile));
2271
+ const repos = raw.repos || [];
2272
+ const bi = rest.indexOf('--by');
2273
+ const by = bi >= 0 ? rest[bi + 1] : undefined;
2274
+ if (by !== undefined && !['remote', 'name'].includes(by)) fail('--by 는 remote | name');
2275
+ const remoteOf = (r) => r.remote || originOf(path.join(root, kit.repoRel(r)));
2276
+ const c = kit.suggestGroups(repos.map((r) => ({ name: r.name, remote: remoteOf(r) })));
2277
+ const pickBy = by || (c.remote ? 'remote' : c.name ? 'name' : null);
2278
+ const plan = pickBy ? c[pickBy] : null;
2279
+ if (!plan) { console.log('그룹 추천 없음: 주소 경로 · 이름 앞부분이 두 repo 이상 겹치는 묶음이 없습니다. 손으로 옮기려면 kedovi repo move <이름> --group <그룹>'); return; }
2280
+ const moves = repos.filter((r) => (plan[r.name] || '') !== (r.group || '') && (plan[r.name] || !r.group));
2281
+ const label = { remote: '주소 경로 기준', name: '이름 앞부분 기준' };
2282
+ console.log(`그룹 추천 (${label[pickBy]}${c.remote && c.name && !by ? ' · 다른 기준: --by ' + (pickBy === 'remote' ? 'name' : 'remote') : ''})\n`);
2283
+ console.log('| repo | 지금 | 옮길 곳 |\n|---|---|---|');
2284
+ for (const r of repos) console.log(`| ${r.name} | ${kit.repoRel(r)} | ${moves.includes(r) ? kit.repoRel({ ...r, group: plan[r.name] }) : '그대로'} |`);
2285
+ if (!moves.length) { console.log('\n이미 추천대로입니다'); return; }
2286
+ if (!rest.includes('--apply')) { console.log(`\n옮기기: kedovi repo group --apply${by ? ` --by ${by}` : ''} (폴더 · worktree 연결 · 문서 경로를 고치고 sync)`); return; }
2287
+ requireAdmin(root, 'repo 옮기기');
2288
+ requireGroups(root);
2289
+ const done = [];
2290
+ for (const r of moves) done.push(moveRepoFolder(root, raw, r, plan[r.name] || ''));
2291
+ fs.writeFileSync(wsFile, JSON.stringify(raw, null, 2) + '\n');
2292
+ const ok = runWorkspaceKit(root, done.some((m) => m.isLink) ? ['install'] : ['sync', '--quiet']);
2293
+ console.log(`\n✔ ${done.length}개 옮김`);
2294
+ for (const m of done) console.log(` ${m.from} → ${m.to} · 폴더 ${m.folder}${m.fixed.length ? ` · 문서 경로 고침 ${m.fixed.join(', ')}` : ''}`);
2295
+ console.log(' workspace.json 이 바뀌었습니다. commit · push 하면 팀에 적용됩니다 (팀원 PC 는 kedovi repo group --apply 를 같이 하거나, 옛 폴더를 지우고 kedovi install)');
2296
+ console.log(' 열려 있는 IDE · 터미널은 새 경로로 다시 엽니다');
2297
+ if (!ok) process.exit(1);
2298
+ }
2299
+
2234
2300
  async function cmdRepo(argv = []) {
2235
2301
  const [sub, ...rest] = argv;
2236
2302
  if (sub === 'remove' || sub === 'rm') return cmdRepoRemove(rest);
2237
2303
  if (sub === 'guides') return cmdRepoGuides(rest);
2238
2304
  if (sub === 'move' || sub === 'mv') return cmdRepoMove(rest);
2305
+ if (sub === 'group') return cmdRepoGroup(rest);
2239
2306
  if (sub !== 'add') fail(`사용법: ${REPO_USAGE}`);
2240
2307
  const root = locateWorkspace();
2241
2308
  requireAdmin(root, 'repo 추가');
@@ -2271,7 +2338,9 @@ async function cmdRepo(argv = []) {
2271
2338
  // 그룹 폴더 repos/<그룹>/<이름>: 이미 그룹을 쓰는 워크스페이스면 대화형에서 고른다
2272
2339
  const groups = [...new Set((raw.repos || []).map((r) => r.group).filter(Boolean))];
2273
2340
  if (group === undefined && tty && groups.length) {
2274
- const v = ask(await choose({ message: '그룹 폴더', hint: `repos/<그룹>/${repo.name} 에 받습니다. 그룹 없음 = repos/${repo.name}`, initialValue: groups[0],
2341
+ const c = kit.suggestGroups([...(raw.repos || []).map((r) => ({ name: r.name, remote: r.remote || originOf(path.join(root, kit.repoRel(r))) })), { name: repo.name, remote: repo.remote || (repo.path ? originOf(path.resolve(root, repo.path)) : '') }]);
2342
+ const guess = ((c.remote || {})[repo.name]) || ((c.name || {})[repo.name]);
2343
+ const v = ask(await choose({ message: '그룹 폴더', hint: `repos/<그룹>/${repo.name} 에 받습니다. 그룹 없음 = repos/${repo.name}`, initialValue: groups.includes(guess) ? guess : groups[0],
2275
2344
  options: [...groups.map((g) => ({ value: g, label: g })), { value: '', label: '그룹 없음' }, { value: NEW_GROUP, label: '새 그룹' }] }));
2276
2345
  group = v === NEW_GROUP ? ask(await input({ message: '새 그룹 이름', hint: '영문·숫자·._- (예: server · client · plans)', validate: (x) => (GROUP_NAME.test(String(x || '').trim()) ? undefined : '영문·숫자·._- 만') })).trim() : v;
2277
2346
  }
package/bin/kit.js CHANGED
@@ -39,6 +39,54 @@ const REPO_SEG = /^(?!\.{1,2}$)[A-Za-z0-9._][A-Za-z0-9._-]*$/;
39
39
  const safeRemote = (v) => typeof v === 'string' && !!v && !v.startsWith('-') && !/^[A-Za-z][A-Za-z0-9+.-]*::/.test(v);
40
40
  /** workspace.json 의 repo 항목을 디스크에 써도 되는지 (이름 · 그룹 · 주소). 팀원이 고친 workspace.json 도 이걸 거친 뒤에만 clone · 링크한다 */
41
41
  const repoSafe = (r) => REPO_SEG.test(r.name || '') && (r.group === undefined || (typeof r.group === 'string' && REPO_SEG.test(r.group))) && (!r.remote || safeRemote(r.remote));
42
+
43
+ /** clone 주소에서 호스트와 repo 이름을 뺀 경로 단계. 예: https://h/a/b/c.git → ['a', 'b'] · git@h:a/c.git → ['a']. 주소가 아니면 null */
44
+ function remoteNamespace(url) {
45
+ const s = String(url || '').trim().replace(/\/+$/, '').replace(/\.git$/, '');
46
+ const m = s.match(/^[a-z][a-z0-9+.-]*:\/\/[^/]+\/(.+)$/i) || s.match(/^[^@\s/:]+@[^:\s]+:(.+)$/);
47
+ return m ? m[1].split('/').filter(Boolean).slice(0, -1) : null;
48
+ }
49
+
50
+ /**
51
+ * repo 그룹 폴더 추천: { remote: { 이름: 그룹 } | null, name: { 이름: 그룹 } | null }
52
+ * remote = 주소 경로에서 모든 repo 가 같은 앞부분을 뺀 첫 단계 (예: …/team/dcim/api · …/team/fms/ui → dcim · fms)
53
+ * name = 이름의 첫 낱말이 절반 넘게 같으면 둘째 낱말, 아니면 첫 낱말 (예: shop-order-api · shop-order-ui → order). 마지막 낱말은 그룹으로 쓰지 않는다
54
+ * 두 repo 이상이 모인 그룹만 남긴다. 모두 한 그룹이거나 그룹 없는 repo 이름과 겹치면 쓰지 않는다. repos: [{ name, remote? }]
55
+ */
56
+ function suggestGroups(repos) {
57
+ const list = (repos || []).filter((r) => r && REPO_SEG.test(r.name || ''));
58
+ const finish = (pairs) => {
59
+ const count = {};
60
+ for (const [, g] of pairs) if (g) count[g] = (count[g] || 0) + 1;
61
+ const out = {};
62
+ for (const [n, g] of pairs) if (g && count[g] >= 2 && REPO_SEG.test(g)) out[n] = g;
63
+ const used = new Set(Object.values(out));
64
+ for (const g of used) if (list.some((r) => !out[r.name] && r.name === g)) for (const n of Object.keys(out)) if (out[n] === g) delete out[n];
65
+ const groups = new Set(Object.values(out));
66
+ if (!groups.size || (groups.size === 1 && Object.keys(out).length === list.length)) return null;
67
+ return out;
68
+ };
69
+ const seg = (x) => String(x || '').replace(/[^A-Za-z0-9._-]/g, '-').replace(/^[-.]+/, '');
70
+ // 주소 기준
71
+ const withNs = list.map((r) => [r.name, remoteNamespace(r.remote)]).filter(([, ns]) => ns);
72
+ let remote = null;
73
+ if (withNs.length >= 2) {
74
+ let common = 0;
75
+ const first = withNs[0][1];
76
+ while (common < first.length && withNs.every(([, ns]) => ns[common] === first[common])) common++;
77
+ remote = finish(withNs.map(([n, ns]) => [n, seg(ns[common])]));
78
+ }
79
+ // 이름 기준
80
+ const words = list.map((r) => [r.name, r.name.split(/[-_.]+/).filter(Boolean)]);
81
+ const head = {};
82
+ for (const [, w] of words) head[w[0]] = (head[w[0]] || 0) + 1;
83
+ const name = list.length >= 3 ? finish(words.map(([n, w]) => {
84
+ const i = head[w[0]] * 2 > list.length ? 1 : 0;
85
+ return [n, w.length > i + 1 ? seg(w[i]) : ''];
86
+ })) : null;
87
+ return { remote, name };
88
+ }
89
+
42
90
  const LOCAL_CONFIG = '.agents/local.json'; // 이 PC·이 워크스페이스 전용 설정 (메인 에이전트 등)
43
91
  // 시작 유형 (SI 분류) — 유형마다 자동으로 들어가는 팩과, 필수·경고 대상 자료 종류
44
92
  const PROJECT_TYPES = {
@@ -1097,7 +1145,7 @@ const GITIGNORE_END = '# <<< kit <<<';
1097
1145
 
1098
1146
  function buildGitignore(current, ws) {
1099
1147
  const block = [GITIGNORE_BEGIN, '# 개인 지침: 공유하지 않는다',
1100
- '.agents/local.md', LOCAL_CONFIG, 'CLAUDE.local.md', 'AGENTS.override.md', '.claude/settings.local.json', '.handoff-snooze', '.agents/bin/', '.agents/board/', '.agents/board.serve.json', '.agents/reports/', '.agents/traces/', '.agents/history/', '.agents/status/', '.agents/heavy/', '.agents/verify/', '.worktrees/',
1148
+ '.agents/local.md', LOCAL_CONFIG, 'CLAUDE.local.md', 'AGENTS.override.md', '.claude/settings.local.json', '.handoff-snooze', '.agents/bin/', '.agents/board/', '.agents/board.serve.json', '.agents/reports/', '.agents/traces/', '.agents/history/', '.agents/status/', '.agents/heavy/', '.agents/verify/', '.worktrees/', '.claude/worktrees/',
1101
1149
  '# 팀 에이전트: 모델이 사람마다 다를 수 있어 각자 sync 가 만든다', '.claude/agents/', '.codex/agents/', LOCAL_MANIFEST,
1102
1150
  '# repo: 각자 kedovi install 로 clone 한다', `/${REPOS_DIR}/`, GITIGNORE_END].join('\n');
1103
1151
  const re = new RegExp(`${GITIGNORE_BEGIN.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?${GITIGNORE_END}`);
@@ -2833,4 +2881,4 @@ function main() {
2833
2881
 
2834
2882
  main();
2835
2883
 
2836
- module.exports = { LIMIT_KEYS, LIMIT_DEFAULTS, claudeRoom, claudeModelEnv, hasFamily, gatewayAliasFix, gatewayAliasCheck, gatewayAliasHint, gatewayFetchNotices, scanGuides, fillGuides, guideChanges, GUIDE_MODES, isGuideMode, hintedCatalog, parseRepos, repoLanguages, labelLanguages, ruleRepos, projectRulesPinning, fillLanguages, loadLanguages, claudeKey, window1m, claudeWindow, SECRET_PATTERNS, secretHits, repoRel, repoSafe, ENFORCE_LEVELS, ENFORCE_DEFAULTS, APPROACHES, missingTypePacks, ensurePlan, roleGrades, teamOptions, teamSection, loadCatalogFor, loginPlanValues, detectPlans, vendorRooms, profileRank, profileLabel, profileNotice, countPicks, applyAccess, normalizeAccess, gatewayVendors, gatewayId, startToolOf, migrateTypes, lockState, generate, buildAgentFiles, splitModel, fillLocalRemotes, installRepos, effortOf, profileModels, fillStackPaths, setStackPaths, detectLine, addStackHint, HINT_HELP, auditModels, resolveModels, stacksLabel, stackLabel, loadLayers, LAYER_PACKS, folderState, HOSTS, inferHost, hostOf, detectRepos, loadCatalog, repoPacks, PROJECT_NAME, PROJECT_NAME_RULE, PROJECT_TYPES, TYPE_RULES, REPO_KINDS, REPOS_DIR, LOCAL_CONFIG, initWorkspace, cmdInstall, cmdSync, cmdCheck, loadWorkspace, findRoot, kitRoot, isGitUrl };
2884
+ module.exports = { suggestGroups, remoteNamespace, LIMIT_KEYS, LIMIT_DEFAULTS, claudeRoom, claudeModelEnv, hasFamily, gatewayAliasFix, gatewayAliasCheck, gatewayAliasHint, gatewayFetchNotices, scanGuides, fillGuides, guideChanges, GUIDE_MODES, isGuideMode, hintedCatalog, parseRepos, repoLanguages, labelLanguages, ruleRepos, projectRulesPinning, fillLanguages, loadLanguages, claudeKey, window1m, claudeWindow, SECRET_PATTERNS, secretHits, repoRel, repoSafe, ENFORCE_LEVELS, ENFORCE_DEFAULTS, APPROACHES, missingTypePacks, ensurePlan, roleGrades, teamOptions, teamSection, loadCatalogFor, loginPlanValues, detectPlans, vendorRooms, profileRank, profileLabel, profileNotice, countPicks, applyAccess, normalizeAccess, gatewayVendors, gatewayId, startToolOf, migrateTypes, lockState, generate, buildAgentFiles, splitModel, fillLocalRemotes, installRepos, effortOf, profileModels, fillStackPaths, setStackPaths, detectLine, addStackHint, HINT_HELP, auditModels, resolveModels, stacksLabel, stackLabel, loadLayers, LAYER_PACKS, folderState, HOSTS, inferHost, hostOf, detectRepos, loadCatalog, repoPacks, PROJECT_NAME, PROJECT_NAME_RULE, PROJECT_TYPES, TYPE_RULES, REPO_KINDS, REPOS_DIR, LOCAL_CONFIG, initWorkspace, cmdInstall, cmdSync, cmdCheck, loadWorkspace, findRoot, kitRoot, isGitUrl };
package/docs/commands.md CHANGED
@@ -65,7 +65,8 @@
65
65
  | `kedovi suggest` | 추천받은 킷 기능 · 내 결정 보기, 그만 묻기 · 다시 묻기 | 대화 주제 · 워크스페이스 상태에 맞는 기능(팩 · 명령 · 설정)을 에이전트가 한 세션에 2개까지 답 끝에 한 줄로 묻는다. `set <id> yes\|no` 로 정하면 다시 묻지 않는다 (`--all` = 이 PC 의 모든 프로젝트). `reset [<id>]` 다시 묻기 · `off\|on [--all]` 끄기 |
66
66
  | `kedovi agents watch` `[--once] [--all] [--json] [--tmux]` | 작업 리더 · 역할 에이전트가 지금 무엇을 하는지 볼 때 (Claude Code) | 메인 → 리더 → 팀원 나무로 상태와 마지막 행동을 2초마다 다시 그린다. 상태: ● 도는 중 · ⏳ 도구 실행 중(긴 시험 등) · ⏲ sleep 명령 · ⏸ 도구 대기(권한 질문일 수 있음: 결과 없는 바로 끝나는 도구가 1분 넘음 · 권한 훅이 질문을 적음) · ◌ 기록 없이 5분 넘음 · ⏹ 끊김(메인 · 사용자가 멈춤) · ✔ 끝남. 이름 없는 서브에이전트(리더 · 리더 아래 팀원)는 tmux 창이 없어 이것으로 본다. `--tmux` 는 tmux 안이면 오른쪽 창으로. 읽기만 |
67
67
  | `kedovi handoff after-push` `[ask\|auto\|off] [--bundle 시간]` | push 할 때마다 「핸드오프 할까요?」 가 번거로울 때 | 작업 repo 로 push 한 뒤 핸드오프가 없을 때: `ask` 묻기(기본) · `auto` 묻지 않고 기록(이 설정이 기록 커밋 · push 승인, 오늘 섹션이 있으면 덧붙임) · `off` 보지 않기. `--bundle` 은 오늘 핸드오프 뒤 그 시간 안의 push 를 묶어서 시간이 지난 뒤 한 번에 기록(기본 3, 0 = push 마다). 값 없이 실행하면 지금 값. workspace.json `vars.handoff` (팀 값) |
68
- | `kedovi worktree add <repo> <단위>` · `merge <repo> <단위>` · `remove <repo> <단위> [--force]` · `list [--json]` | 독립 단위를 작업 리더 여럿이 나눠 맡는데 같은 repo 를 함께 고칠 때 (메인이 한다) | `add` = `.worktrees/<repo>/<단위>/` 에 지금 브랜치 HEAD 로 작업 폴더 (로컬 임시 브랜치 `kedovi/<단위>`, 원격에 안 올림. 통합 브랜치 직접 운영이어도 된다). `merge` = 변경을 repo 본 작업 트리에 **커밋하지 않은 변경**으로 옮기고(3-way) 작업 폴더 · 임시 브랜치를 지운다. 겹쳐서 못 옮기면 아무것도 지우지 않고 겹친 파일을 알린다. 커밋은 평소처럼 |
68
+ | `kedovi worktree add <repo> <단위>` · `merge <repo> <단위>` · `remove <repo> <단위> [--force]` · `list [--json]` | 같은 repo 를 작업 리더 여럿이 함께 고칠 때 (메인이 한다) | `add` = `.worktrees/<repo>/<단위>/` 에 작업 폴더 (로컬 임시 브랜치 `kedovi/<단위>`, 원격에 안 올림). 있는 브랜치는 `--branch`, 기준 바꾸기는 `--base`. `merge` = 본 작업 트리에 **커밋하지 않은 변경**으로 옮기고 작업 폴더를 지운다. 겹치면 아무것도 지우지 않는다. `list` = 모든 repo 의 작업 폴더와 상태 |
69
+ | `kedovi worktree clean [--dry-run] [--branches] [--now]` | 작업 폴더가 쌓였을 때 (세션이 6시간마다 알린다) | 바뀐 파일이 없고 브랜치 내용이 기준 브랜치에 있는(squash 머지 포함) 것을 지운다. 진행 중인데 킷 밖에 있는 것은 `.worktrees/<repo>/` 로 옮긴다. 다른 브랜치는 `--branches` 일 때만 지운다 |
69
70
  | `kedovi debate list` · `watch [id] [--once]` · `status [id]` · `models [--task code\|design\|docs]` | 토론 모드(여러 모델이 따로 보고 서로 반박)를 볼 때. 시작은 채팅에서 "토론해줘" | `watch` = 다른 터미널에서 모델별 주장 · 판정 · 회차 정리를 실시간으로 (끝나면 닫힘). `--once` = 지금까지만 보여 주고 끝 (채팅에서 물을 때). `models` = 이 PC 에서 쓸 수 있는 모델과 강점 점수, 작업에 맞춘 패널 예시. `status` = 지금 회차 · 모델별 상태 |
70
71
  | `kedovi docs serve [repo]` | Pages 없이 이 PC 에서 문서 사이트를 볼 때 | `docs-site/` 를 `http://127.0.0.1:8000/` 로 연다 (`--port` · `--open`). `file://` 로 열면 쪽 이동이 새로고침이 되고 전체 인쇄가 안 된다 |
71
72
  | `kedovi docs pages [on\|off] [repo]` | 문서 사이트를 Pages 로 올릴지 정할 때 | on = 원격에 맞는 CI 파일 · `docs-site/` 커밋 대상, off = `.gitignore` 에 `/docs-site/`. 인자 없이 = repo 마다 상태 |
@@ -108,7 +109,8 @@
108
109
  | `kedovi rules ondemand\|always <ID…\|repo-tasks>` | AGENTS.md 가 Codex 한도를 넘을 때 | 상시 규칙을 필요할 때만 읽게 한다 (`rules.onDemand`). `repo-tasks` 는 「repo 별 작업 규칙」의 작업별 표를 `.agents/rules/repo-tasks.md` 로 뺀다. sync 경고가 큰 절을 알려 준다 |
109
110
  | `kedovi repo add [주소·폴더·이름]` | repo 를 더할 때 | clone · 링크(원격 없는 로컬 repo 도), 또는 이름만 주면 `repos/<이름>` 에 원격 없이 새로 만든다. 인자 없이 = 화면에서 방식(clone · 기존 로컬 폴더 · 새로 만들기)을 먼저 고른다 (레거시 제외. 기획 repo 면 뼈대는 `kedovi init-docs`) → 스택 확인 → sync |
110
111
  | `kedovi repo add … --group <그룹>` | repo 가 많아 폴더를 나눌 때 | `repos/<그룹>/<이름>` 에 받는다. 이미 그룹을 쓰는 워크스페이스면 화면에서 고른다 ([그룹 폴더](workspace.md#repo-그룹-폴더)) |
111
- | `kedovi repo move <이름> --group <그룹>` · `--no-group` | 있는 repo 를 그룹 폴더로 옮길 때 | 폴더 · `workspace.json` · 사람이 쓴 md 의 옛 경로를 고치고 sync (팀장) |
112
+ | `kedovi repo move <이름> --group <그룹>` · `--no-group` | 있는 repo 를 그룹 폴더로 옮길 때 | 폴더 · worktree 연결 · `workspace.json` · 사람이 쓴 md 의 옛 경로를 고치고 sync (팀장) |
113
+ | `kedovi repo group [--apply] [--by remote\|name]` | repo 가 `repos/` 한 단계에 섞여 있을 때 | 주소 경로 기준 그룹 추천 표를 보인다 (겹침이 없으면 이름 앞부분 기준). `--apply` 면 모두 옮긴다 (팀장) |
112
114
  | `kedovi repo guides` · `<이름> follow\|kit\|ignore` · `--rescan [<이름>]` | 받은 repo 에 원래 CLAUDE.md · AGENTS.md · 룰 · 스킬이 있을 때 | 목록과 따르는 방식을 보여 주고 바꾼다. follow = repo 지침 우선(기본), kit = 킷 규칙 우선, ignore = 무시. 자세히는 [repo 자체 지침](workspace.md#repo-자체-지침) (팀장) |
113
115
  | `kedovi repo remove <이름> [--delete]` | repo 를 뺄 때 | `workspace.json` · 리뷰 대상에서 지우고 sync, 이름이 남은 문서(README 등)를 알린다. 폴더는 `--delete` 일 때만 지운다 (커밋 안 한 변경 · push 안 한 커밋이 있으면 거부) |
114
116
  | `kedovi detect` | repo 스택이 바뀌었을 때 | 코드 repo 의 기술 스택을 다시 감지하고 고친다 → repo 별 규칙이 바뀐다 |
package/docs/rules.md CHANGED
@@ -68,7 +68,7 @@ kedovi detect --hint spring --contains 'com\.example\.platform:platform-starter'
68
68
  | 설정 | 값 | 바뀌는 것 |
69
69
  |---|---|---|
70
70
  | `gitlab.branchMode` | `feature`(기본) · `trunk` | feature = 작업 브랜치 → 통합 브랜치 MR. trunk = 작업 브랜치 · worktree 없이 통합 브랜치에 직접 커밋 · push, 운영 배포만 MR (팀원 브랜치 생성은 훅이 막고, 같은 repo 를 두 팀원에게 동시에 맡기지 않는다) |
71
- | `git.cleanupMerged` | `false`(기본) · `true` | true 면 머지가 확인된 로컬 브랜치 · worktree 를 머지 직후 정리 (원격 삭제는 건마다 승인) |
71
+ | `git.cleanupMerged` | `false`(기본) · `true` | true 면 머지가 확인된 로컬 작업 브랜치를 머지 직후 정리 (원격 삭제는 건마다 승인). 작업 폴더는 이 값과 상관없이 `kedovi worktree clean` 이 끝난 것만 지운다 |
72
72
  | `cleanCode.helperMethods` | `few`(기본) · `none` | 역할 클래스의 도우미 메서드(접근 제한자 무관) 기준. none 이면 0개, `kedovi archrules` 검사도 켜진다 |
73
73
 
74
74
 
@@ -129,7 +129,7 @@ flowchart TD
129
129
 
130
130
  - **맥락 교체**: 리더 · 팀원의 맥락이 `vars.team.memberContextK`(기본 200K 토큰)를 넘으면 훅이 인계를 알린다. 큰 맥락은 호출마다 다시 읽혀 주간 한도를 빠르게 쓴다.
131
131
  - **상한 확인**: `kedovi models limits` 가 실제 적용 값과 정한 곳(프로필 · 팀 직접 값 · 이 PC 직접 값 · 요금제)을 보여 준다. 프로필을 올렸는데 예전에 넣어 둔 `agents.limits` 가 더 낮으면 `kedovi models profile` 이 알리고 화면이면 지울지 묻는다. 지우기: `kedovi models limits clear [--team]`.
132
- - **같은 repo**: 리더마다 `kedovi worktree add <repo> <단위>` 로 작업 폴더(`.worktrees/<repo>/<단위>/`, 로컬 임시 브랜치)를 주고, 끝나면 메인이 `kedovi worktree merge` 로 본 작업 트리에 커밋하지 않은 변경으로 옮긴다. 통합 브랜치 직접 운영이어도 쓸 수 있다 (임시 브랜치는 이 PC 에만 있다).
132
+ - **같은 repo**: 리더마다 `kedovi worktree add <repo> <단위>` 로 작업 폴더(`.worktrees/<repo>/<단위>/`, 로컬 임시 브랜치)를 주고, 끝나면 메인이 `kedovi worktree merge` 로 본 작업 트리에 커밋하지 않은 변경으로 옮긴다. 통합 브랜치 직접 운영이어도 쓸 수 있다 (임시 브랜치는 이 PC 에만 있다). `git worktree add` 로 repo 옆(`repos/<repo>-wt/`)에 만들면 훅이 막고, 남은 작업 폴더는 `kedovi worktree clean` 이 정리한다.
133
133
  - **진행 보기**: `kedovi team` 현황의 「지금 도는 에이전트」 줄 (작업 리더 수 · 리더별 팀원 수).
134
134
 
135
135
  > 근거: Claude Code 서브에이전트 중첩(메인 아래 3층까지 · 동시 20)과 훅 입력의 agent_id 는 공식 문서(code.claude.com/docs/en/sub-agents · /hooks), agent teams 의 중첩 팀 불가는 /agent-teams. 2026-11-11 Claude Code 2.1.322 에서 리더 2명 아래 팀원 4명이 함께 도는 것을 확인. 여러 에이전트는 채팅의 약 15배 토큰을 쓴다 (anthropic.com/engineering/multi-agent-research-system). 그래서 독립 단위가 있을 때만 쓴다.
package/docs/workflow.md CHANGED
@@ -74,8 +74,11 @@ flowchart TD
74
74
  L2 --> H
75
75
  H{"주소만으로 GitHub·GitLab 을<br/>모르는 호스트가 있는가"}
76
76
  H -->|"있음"| H1["&lt;호스트&gt; 의 협업 도구<br/>GitLab · GitHub · 기타·없음"]
77
- H -->|"없음"| OK
78
- H1 --> OK{"이대로 만들까요?"}
77
+ H -->|"없음"| GQ
78
+ H1 --> GQ{"repo 3개 이상이고 주소 경로 · 이름 앞부분이<br/>두 repo 이상 겹치는가"}
79
+ GQ -->|"예"| GP["repo 폴더 묶기<br/>주소 경로 기준 · 이름 앞부분 기준 · 묶지 않음<br/>→ repos/&lt;그룹&gt;/&lt;이름&gt;"]
80
+ GQ -->|"아니오"| OK
81
+ GP --> OK{"이대로 만들까요?"}
79
82
  OK -->|"아니오"| X(["만들지 않고 끝"])
80
83
  OK -->|"예"| MK["워크스페이스 생성 · repo clone<br/>스택 자동 감지"]
81
84
  MK --> RF{"clone 하지 못한 repo 가 있는가"}
@@ -366,7 +369,8 @@ flowchart TD
366
369
  RI --> RG["그룹 폴더 (이미 그룹을 쓰는 워크스페이스만)<br/>기존 그룹 · 그룹 없음 · 새 그룹 → 새 그룹 이름<br/>→ repos/&lt;그룹&gt;/&lt;이름&gt;"]
367
370
  RG --> RH["이 repo 의 협업 도구<br/>(주소로 GitHub·GitLab 을 모를 때만)"]
368
371
  RH --> RX["clone · 링크 · 새로 만들기 → 스택 확인 → sync"]
369
- Q -->|"repo 를 그룹 폴더로"| RMV["kedovi repo move &lt;이름&gt; --group &lt;그룹&gt; · --no-group (팀장)<br/>폴더 옮김 · workspace.json group · 문서의 옛 경로 → sync"]
372
+ Q -->|"repo 를 그룹 폴더로"| RMV["kedovi repo move &lt;이름&gt; --group &lt;그룹&gt; · --no-group (팀장)<br/>폴더 옮김 · worktree 다시 잇기 · workspace.json group · 문서의 옛 경로 → sync"]
373
+ Q -->|"repo 를 주소별 폴더로 한 번에"| RGP["kedovi repo group: 추천 표 (주소 경로, 없으면 이름 앞부분)<br/>--apply [--by remote · name] 로 모두 옮김 (팀장)"]
370
374
  Q -->|"새로 만든 repo 를 원격에 올림"| RP["git -C repos/&lt;이름&gt; remote add origin &lt;주소&gt; → push"]
371
375
  RP --> RF["sync 가 workspace.json 에 remote 기록 (local 삭제)<br/>→ workspace.json commit · push → 팀원 git pull · kedovi install"]
372
376
  Q -->|"명령 찾기"| HLP["kedovi --help: 자주 쓰는 명령 · 분류 목록<br/>분류를 고르세요 (터미널) → 그 분류의 명령과 설명<br/>kedovi help &lt;번호&gt; · kedovi help --all · kedovi &lt;명령&gt; --help"]
@@ -419,12 +423,12 @@ flowchart TD
419
423
  | `kedovi tips` | 화면 보기 안내: `/tui fullscreen` · `/focus` · `Ctrl+O` (start 가 처음 한 번) |
420
424
  | `kedovi suggest` | 기능 추천 기록: 대화 중 추천받은 기능 · 결정(씀 · 안 씀) 보기 · 다시 묻기 · 끄기 |
421
425
  | `kedovi agents watch` | 에이전트 진행 보기: 메인 → 작업 리더 → 팀원 나무로 상태 · 마지막 행동 (Claude Code, 이름 없는 서브에이전트도). `--once` · `--all` · `--json` · `--tmux` |
422
- | `kedovi worktree add <repo> <단위>` · `merge` · `remove` · `list` | 작업 리더 작업 폴더: 같은 repo 를 여러 작업 리더가 동시에 고칠 때 리더마다 `.worktrees/<repo>/<단위>`, merge 는 본 작업 트리에 커밋하지 않은 변경으로 옮김 |
426
+ | `kedovi worktree add <repo> <단위>` · `merge` · `remove` · `list` · `clean` | 작업 폴더: 같은 repo 를 여러 작업 리더가 동시에 고칠 때 리더마다 `.worktrees/<repo>/<단위>`, merge 는 본 작업 트리에 커밋하지 않은 변경으로 옮김. clean 은 끝난 작업 폴더를 지우고 킷 밖에 만든 것을 `.worktrees/` 로 옮김 |
423
427
  | `kedovi debate list` · `watch [id]` · `status [id]` · `models` | 토론 모드: 목록 · 실시간 보기(모델별 주장 · 판정) · 지금 회차와 모델별 상태 · 쓸 수 있는 모델과 패널 예시 (시작은 채팅에서 "토론해줘") |
424
428
  | `kedovi docs serve [repo]` | `docs-site/` 를 이 PC 에서 웹 주소(`http://127.0.0.1:8000/`)로 보기. 전체 인쇄와 새로고침 없는 이동까지 된다 |
425
429
  | `kedovi docs pages [on\|off] [repo]` | 문서 사이트를 Pages 로 올리기 켜고 끄기 · 상태. on = 원격(GitLab · GitHub)에 맞는 CI 파일(`.gitlab-ci.yml` · `.github/workflows/pages.yml`)을 두고 `docs-site/` 를 커밋 대상으로(원격이 없으면 둘 다), off = `.gitignore` 에 `/docs-site/` (CI 는 두어도 돌지 않는다) |
426
430
  | `kedovi docs trace` | 기획 ID(`vars.docs.traceIds`)와 코드의 `@spec` 주석 대조: 코드에 표시 없는 ID(⚠) · 테스트에 없는 수용 기준(⚠) · 기획에 정의 없는 ID(✖). `--md` 추적표 · `--new` 새 진입 파일 중 ID 없는 것 |
427
- | `kedovi repo add … --group <그룹>` · `kedovi repo move <이름> --group <그룹>` | 그룹 폴더 `repos/<그룹>/<이름>`: 더할 때 그룹을 주거나(이미 그룹을 쓰면 화면에서 고름) 있는 repo 를 옮긴다(폴더 · `workspace.json` · 문서의 옛 경로, `--no-group` 은 빼기) (팀장) |
431
+ | `kedovi repo add … --group <그룹>` · `kedovi repo move <이름> --group <그룹>` · `kedovi repo group [--apply]` | 그룹 폴더 `repos/<그룹>/<이름>`: 더할 때 그룹을 주거나(이미 그룹을 쓰면 화면에서 고름) 있는 repo 를 옮긴다(폴더 · `workspace.json` · 문서의 옛 경로, `--no-group` 은 빼기). `repo group` 은 주소 경로 기준 추천대로 한 번에 (팀장) |
428
432
  | `kedovi repo remove <이름>` | repo 빼기: `workspace.json` · 리뷰 대상에서 지우고 sync, 이름이 남은 문서를 알린다. 폴더는 `--delete` 일 때만 (커밋 안 한 변경 · push 안 한 커밋이 있으면 거부) (팀장) |
429
433
  | `kedovi tidy` | 정리 후보 찾기 (읽기만): 이번 작업 새 파일 · 안 쓰는 자료 · 링크 없는 문서 · 백업 이름. 지우기는 `tidy` 스킬 (표 → 승인 → 지움 → 검증) |
430
434
  | `kedovi import` | 기존 AI 작업 폴더 훑기 (읽기만): 종류별 분류 · 큰 폴더 · 문서 속 절대경로 · 비밀값 의심 줄. 옮기기는 `import` 스킬 (계획 → 승인 → 반영) |
@@ -500,7 +504,7 @@ flowchart TD
500
504
  | `workspace.json` | init · detect · models(팀) · team-mode(팀) · team add · rules · upgrade | git 공유 | 유형 · repo · 스택 · 팀 모델 프로필 · 팀 구성(`agents.mode` · `save` · `prefer`) · 훅 강제 수준 · 리뷰 확인 대상 · 대기 팀원 시간(`agents.enforce`) · 팀원의 높은 프로필 허용(`agents.allowHigherProfile`) · 팀 직접 지정 모델 · 팀 명단 · 팀장 · 설정 수정 권한(`team`) · 끈 규칙(`rules.off`) · 필요할 때만 읽는 규칙(`rules.onDemand`) |
501
505
  | `.agents/local.json` | install · agent · ai · models(내 PC) | 이 PC 만 | 시작 도구 · 인자 · AI 연결 방식(`agents.access`: 게이트웨이 주소·키 환경변수 이름·모델 목록, 키 값은 없음) · 내 프로필(팀과 같거나 낮은 것만) · 내가 직접 고른 모델 · 역할 상한(`agents.limits`, 팀 값 이내) |
502
506
  | `.claude/agents` · `.codex/agents` | sync | 이 PC 만 (사람마다 모델이 달라서) | 역할 에이전트 파일 |
503
- | `.worktrees/<repo>/<단위>/` | kedovi worktree add | 이 PC 만 (gitignore) | 작업 리더 작업 폴더 · 로컬 임시 브랜치 `kedovi/<단위>` (merge · remove 때 지운다) |
507
+ | `.worktrees/<repo>/<단위>/` | kedovi worktree add · clean | 이 PC 만 (gitignore) | 작업 폴더 · 로컬 임시 브랜치 `kedovi/<단위>` (merge · remove · clean 때 지운다). 작업 폴더는 여기에만 만든다 (`git worktree add` 로 repo 옆에 만들면 훅이 막는다) |
504
508
  | `CLAUDE.local.md` · `AGENTS.override.md` · `.claude/settings.local.json` | sync | 이 PC 만 | 개인 지침 · 역할 위임 표 · 설정 잠금 지침과 편집 금지(팀원) |
505
509
  | `AGENTS.md` · `CLAUDE.md` · `.claude/settings.json` · `.codex/config.toml` | sync | git 공유 | 규칙 · 스킬 · 훅 · 팀 메인 모델 |
506
510
  | `handoffs/<id>/` | handoff · 인수(resume <id> · kedovi team --take) | git 공유 (워크스페이스 repo) | 본인 작업별 기록(미완 작업의 정본) · LATEST · 주간 기록 · TODO(사용자가 등록한 것). 각자 자기 폴더만 |
package/docs/workspace.md CHANGED
@@ -78,12 +78,15 @@ repo 가 많으면(MSA · 화면 repo 여럿) `repos/` 아래를 그룹으로
78
78
 
79
79
  | 할 일 | 명령 |
80
80
  |---|---|
81
+ | 새 워크스페이스 | `kedovi init` 이 repo 3개 이상이면 「repo 폴더 묶기」 를 묻는다. 주소 경로에서 공통 앞부분을 뺀 첫 단계가 그룹이다 (예: `…/team/dcim/dcim-api` · `…/team/fms/fms-ui` → `dcim` · `fms`). 주소가 모두 같은 단계면 이름 앞부분 기준을 추천한다 |
82
+ | 한 번에 묶기 | `kedovi repo group` 으로 추천 표를 보고 `--apply` 로 옮긴다 |
81
83
  | 그룹에 더하기 | `kedovi repo add <주소> --group server` (이미 그룹을 쓰면 화면에서 고른다) |
82
84
  | 있는 repo 옮기기 | `kedovi repo move order-api --group server`: 폴더를 옮기고 `workspace.json` 과 사람이 쓴 md 의 옛 경로를 고친 뒤 sync. `--no-group` 은 `repos/<이름>` 으로 되돌린다 |
83
85
  | 팀원 PC | `workspace.json` 을 받은 뒤 같은 `kedovi repo move` 를 하거나, 옛 폴더를 지우고 `kedovi install`. `kedovi doctor` 가 「그룹 폴더와 실제 위치가 다름」 으로 알린다 |
84
86
 
85
87
  - AGENTS.md 의 repo 표에 그룹 칸이 생기고 그룹 순서로 묶인다. 경로는 표의 위치를 쓴다.
86
88
  - 그룹 이름은 그룹 없는 repo 이름과 같으면 안 된다 (`repos/<이름>` 폴더가 겹친다).
89
+ - 작업 폴더(worktree)는 `repos/` 가 아니라 `.worktrees/<repo>/<단위>` 에 둔다 (`kedovi worktree add`). repo 를 옮기면 그 작업 폴더 연결도 다시 잇는다.
87
90
  - 그룹을 안 쓰는 워크스페이스는 생성물이 그대로다.
88
91
 
89
92
  ### repo 자체 지침
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kedovi",
3
- "version": "0.103.0",
3
+ "version": "0.104.0",
4
4
  "private": false,
5
- "description": "Claude Code · Codex 팀 개발 워크스페이스 킷: 메인은 대화만, 작업은 리더 · 팀원 에이전트가 병렬로(3층 · 요금제별 상한 · 자리 비워도 권한 질문에 안 멈춤) · 질문엔 답 먼저 · 채팅은 결론 + 자세히 링크(보고 페이지) · 착수 전 확인 → 검사 → 리뷰를 훅으로 지킴 · 주간 사용량 속도 조절(Max · Ultra) · 사람이 읽는 글의 4대 원칙(두괄식 · 개조식 · 간결성 · 가독성) · 소스 코드 표현 검사 · 설정 파일 주석 검사 · 검증 2단(작업마다 바뀐 영역 시험 · 전체는 릴리스 직전 한 번) · 무거운 시험 순번 · 리더 진행판 · API · 배치 · 화면 실행 흐름 디버깅(Java · Python · React · Next.js · Node, 줄마다 값 · SQL · 요청을 웹으로) · 대화 중 기능 추천(정한 것은 다시 안 물음) · 한 규칙 두 도구 · 사람이 읽는 글 틀 · 형식 검사(이슈 · MR · 댓글 · 기획 문서의 빈칸 · 긴 글머리 · 로컬 링크 막기) · 핸드오프 · 로드맵 · 기획 문서 사이트 · 화면 정본 대조(착수 전 막기 · 배치 대조 · 결정 없는 다름 막기)",
5
+ "description": "Claude Code · Codex 팀 개발 워크스페이스 킷: 메인은 대화만, 작업은 리더 · 팀원 에이전트가 병렬로(3층 · 요금제별 상한 · 자리 비워도 권한 질문에 안 멈춤) · 질문엔 답 먼저 · 채팅은 결론 + 자세히 링크(보고 페이지) · 착수 전 확인 → 검사 → 리뷰를 훅으로 지킴 · 주간 사용량 속도 조절(Max · Ultra) · 사람이 읽는 글의 4대 원칙(두괄식 · 개조식 · 간결성 · 가독성) · 소스 코드 표현 검사 · 설정 파일 주석 검사 · 검증 2단(작업마다 바뀐 영역 시험 · 전체는 릴리스 직전 한 번) · 무거운 시험 순번 · 리더 진행판 · API · 배치 · 화면 실행 흐름 디버깅(Java · Python · React · Next.js · Node, 줄마다 값 · SQL · 요청을 웹으로) · 대화 중 기능 추천(정한 것은 다시 안 물음) · 한 규칙 두 도구 · 사람이 읽는 글 틀 · 형식 검사(이슈 · MR · 댓글 · 기획 문서의 빈칸 · 긴 글머리 · 로컬 링크 막기) · 작업 폴더 위치 강제 · 끝난 작업 폴더 정리 · repo 폴더 묶기 · 핸드오프 · 로드맵 · 기획 문서 사이트 · 화면 정본 대조(착수 전 막기 · 배치 대조 · 결정 없는 다름 막기)",
6
6
  "keywords": [
7
7
  "claude-code",
8
8
  "codex",
@@ -23,7 +23,8 @@
23
23
  "writing-style",
24
24
  "test-queue",
25
25
  "usage-limits",
26
- "developer-tools"
26
+ "developer-tools",
27
+ "git-worktree"
27
28
  ],
28
29
  "license": "MIT",
29
30
  "repository": {
@@ -1,31 +1,30 @@
1
1
  #!/usr/bin/env node
2
- // 작업 리더 worktree: 같은 repo 를 여러 작업 리더가 동시에 고칠 때 리더마다 따로 쓰는 작업 폴더. 실행: kedovi worktree <명령> 또는 node packs/core/bin/worktree.js <명령>
2
+ // 작업 폴더(worktree): 같은 repo 를 여러 작업 리더가 동시에 고칠 때 리더마다 따로 쓰는 폴더. 실행: kedovi worktree <명령> 또는 node packs/core/bin/worktree.js <명령>
3
3
  /*
4
4
  * 명령
5
- * add <repo> <단위> .worktrees/<repo>/<단위>/ 에 지금 브랜치의 HEAD 로 작업 폴더를 만든다 (로컬 임시 브랜치 kedovi/<단위>, 원격에 올리지 않는다)
6
- * list [--json] 작업 폴더 목록: repo · 단위 · 바뀐 파일 수 · 만든 시각
7
- * merge <repo> <단위> 작업 폴더의 변경을 repo 본 작업 트리에 커밋하지 않은 변경으로 옮기고(3-way) 작업 폴더 · 임시 브랜치를 지운다.
8
- * 겹쳐서 못 옮기면 아무것도 지우지 않고 겹친 파일을 알린다 (끝 코드 1)
9
- * remove <repo> <단위> 옮기지 않고 지운다 (변경이 있으면 --force 가 있어야)
5
+ * add <repo> <단위> [--base <ref>] .worktrees/<repo>/<단위>/ 에 지금 HEAD(또는 ref)로 작업 폴더를 만든다 (로컬 임시 브랜치 kedovi/<단위>, 원격에 올리지 않는다)
6
+ * add <repo> <단위> --branch <브랜치> 있는 브랜치를 그대로 받는다 (리뷰 · 그 브랜치에서 커밋할 때. merge 대신 그 폴더에서 커밋 · push 하고 clean 으로 정리)
7
+ * list [--json] 이 워크스페이스 repo 의 모든 작업 폴더: 위치 종류(킷 · Claude · 직접 만듦) · 브랜치 · 바뀐 파일 · 상태
8
+ * merge <repo> <단위> 작업 폴더의 변경을 repo 본 작업 트리에 커밋하지 않은 변경으로 옮기고(3-way) 작업 폴더 · 임시 브랜치를 지운다.
9
+ * 겹쳐서 못 옮기면 아무것도 지우지 않고 겹친 파일을 알린다 (끝 코드 1)
10
+ * remove <repo> <단위> [--force] 옮기지 않고 지운다 (변경이 있으면 --force 가 있어야)
11
+ * clean [--dry-run] [--branches] [--now]
12
+ * 끝난 작업 폴더를 지운다: 바뀐 파일이 없고 브랜치 내용이 기준 브랜치에 이미 있으며(squash 머지 포함) 한 시간 넘게 손대지 않은 것.
13
+ * 킷 임시 브랜치(kedovi/…)도 지운다. 다른 브랜치는 --branches 또는 vars.git.cleanupMerged = true 일 때만.
14
+ * 킷 밖(repos/ 안 등)에 직접 만든 작업 폴더 중 진행 중인 것은 .worktrees/<repo>/ 로 옮긴다. 폴더가 사라진 기록은 정리한다
10
15
  * 커밋 · push 는 하지 않는다. 옮긴 변경은 평소처럼 사용자가 확인하고 커밋한다 (워크스페이스 커밋 규칙 그대로).
11
16
  * 통합 브랜치 직접 운영(branchMode trunk)이어도 쓴다: 임시 브랜치는 이 PC 에만 있고 merge 때 지운다.
12
17
  */
13
18
  'use strict';
14
19
  const fs = require('fs');
15
20
  const path = require('path');
16
- const { execFileSync } = require('child_process');
17
21
  const { load } = require('../lib/workspace');
22
+ const W = require('../lib/worktrees');
18
23
 
19
- const DIR = '.worktrees';
24
+ const DIR = W.KIT_DIR;
20
25
  const UNIT = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
21
26
  const BRANCH = (unit) => `kedovi/${unit}`;
22
-
23
- /** git 실행. ok = false 면 out 에 오류 */
24
- function git(cwd, args, input) {
25
- try {
26
- return { ok: true, out: execFileSync('git', ['-C', cwd, '-c', 'core.quotepath=false', ...args], { encoding: 'utf8', input, stdio: [input === undefined ? 'ignore' : 'pipe', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 }).trim() };
27
- } catch (e) { return { ok: false, out: String((e.stderr || '') + (e.stdout || '') || e.message).trim() }; }
28
- }
27
+ const git = W.git;
29
28
 
30
29
  function fail(msg) { console.error(`✖ ${msg}`); process.exit(1); }
31
30
 
@@ -38,56 +37,61 @@ function repoOf(ws, name) {
38
37
 
39
38
  const metaFile = (ws, repo, unit) => path.join(ws.root, DIR, repo, `${unit}.json`);
40
39
  const wtDir = (ws, repo, unit) => path.join(ws.root, DIR, repo, unit);
40
+ const opt = (argv, k) => { const i = argv.indexOf(`--${k}`); return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[i + 1] : undefined; };
41
41
 
42
- function add(ws, repo, unit) {
42
+ function add(ws, repo, unit, { base, branch: existing } = {}) {
43
43
  if (!UNIT.test(unit || '')) fail('단위 이름은 영문 · 숫자 · . _ - (64자까지). 예: FN-012 · order-list');
44
44
  const r = repoOf(ws, repo);
45
45
  const dir = wtDir(ws, repo, unit);
46
46
  if (fs.existsSync(dir)) fail(`이미 있습니다: ${path.relative(ws.root, dir)} (끝났으면 kedovi worktree merge ${repo} ${unit})`);
47
- const base = git(r.dir, ['rev-parse', 'HEAD']);
48
- if (!base.ok) fail(`${repo} 의 HEAD 를 읽지 못했습니다: ${base.out}`);
49
- const branch = git(r.dir, ['rev-parse', '--abbrev-ref', 'HEAD']).out || '';
50
47
  fs.mkdirSync(path.dirname(dir), { recursive: true });
51
- const made = git(r.dir, ['worktree', 'add', '-b', BRANCH(unit), dir, base.out]);
48
+ if (existing) {
49
+ // 있는 브랜치: 로컬에 없으면 origin/<브랜치> 를 따라가는 로컬 브랜치로
50
+ const local = git(r.dir, ['rev-parse', '--verify', '-q', `refs/heads/${existing}`]).ok;
51
+ const made = local ? git(r.dir, ['worktree', 'add', dir, existing]) : git(r.dir, ['worktree', 'add', '--track', '-b', existing, dir, `origin/${existing}`]);
52
+ if (!made.ok) fail(`worktree 를 만들지 못했습니다: ${made.out}`);
53
+ const head = git(dir, ['rev-parse', 'HEAD']).out;
54
+ fs.writeFileSync(metaFile(ws, repo, unit), `${JSON.stringify({ repo, unit, base: head, branch: existing, own: false, at: new Date().toISOString() }, null, 2)}\n`);
55
+ console.log(`✔ ${path.relative(ws.root, dir)} (${repo} · 브랜치 ${existing} 그대로)`);
56
+ console.log(' 이 폴더에서 커밋 · push 한다 (merge 로 옮기지 않는다). 끝나면: kedovi worktree clean');
57
+ return;
58
+ }
59
+ const from = git(r.dir, ['rev-parse', `${base || 'HEAD'}^{commit}`]);
60
+ if (!from.ok) fail(`${repo} 의 ${base || 'HEAD'} 를 읽지 못했습니다: ${from.out}`);
61
+ const branch = base ? base.replace(/^origin\//, '') : git(r.dir, ['rev-parse', '--abbrev-ref', 'HEAD']).out || '';
62
+ const made = git(r.dir, ['worktree', 'add', '-b', BRANCH(unit), dir, from.out]);
52
63
  if (!made.ok) fail(`worktree 를 만들지 못했습니다: ${made.out}`);
53
- fs.writeFileSync(metaFile(ws, repo, unit), `${JSON.stringify({ repo, unit, base: base.out, branch, at: new Date().toISOString() }, null, 2)}\n`);
64
+ fs.writeFileSync(metaFile(ws, repo, unit), `${JSON.stringify({ repo, unit, base: from.out, branch, at: new Date().toISOString() }, null, 2)}\n`);
54
65
  console.log(`✔ ${path.relative(ws.root, dir)} (${repo} · ${branch || 'HEAD'} 기준, 임시 브랜치 ${BRANCH(unit)})`);
55
66
  console.log(' 팀원은 이 폴더 안의 파일만 고친다 (소유 파일 경로를 이 폴더 기준으로 준다). 의존성 설치가 필요한 repo 면 이 폴더에서 설치 명령을 먼저 돌린다.');
56
67
  console.log(` 끝나면 메인이: kedovi worktree merge ${repo} ${unit}`);
57
68
  }
58
69
 
70
+ const KIND = { kit: '킷', claude: 'Claude', other: '직접 만듦' };
71
+
59
72
  function list(ws, json) {
60
- const root = path.join(ws.root, DIR);
61
- const out = [];
62
- if (fs.existsSync(root)) {
63
- for (const repo of fs.readdirSync(root)) {
64
- const rd = path.join(root, repo);
65
- if (!fs.statSync(rd).isDirectory()) continue;
66
- for (const f of fs.readdirSync(rd).filter((x) => x.endsWith('.json'))) {
67
- let m = {};
68
- try { m = JSON.parse(fs.readFileSync(path.join(rd, f), 'utf8')); } catch { continue; }
69
- const dir = wtDir(ws, repo, m.unit);
70
- const st = fs.existsSync(dir) ? git(dir, ['status', '--porcelain']) : { ok: false, out: '' };
71
- out.push({ repo, unit: m.unit, dir: path.relative(ws.root, dir), branch: m.branch, at: m.at, changed: st.ok ? st.out.split('\n').filter(Boolean).length : null, missing: !fs.existsSync(dir) });
72
- }
73
- }
74
- }
75
- if (json) return console.log(JSON.stringify(out, null, 2));
76
- if (!out.length) return console.log('작업 리더 worktree 없음');
77
- console.log('| repo | 단위 | 기준 브랜치 | 바뀐 파일 | 만든 시각 |\n|---|---|---|---|---|');
78
- for (const x of out) console.log(`| ${x.repo} | ${x.unit} | ${x.branch || '-'} | ${x.missing ? '폴더 없음' : x.changed} | ${String(x.at || '').slice(0, 16).replace('T', ' ')} |`);
73
+ const out = W.scan(ws, { deep: true });
74
+ if (json) return console.log(JSON.stringify(out.map(({ repoDir, ...x }) => x), null, 2));
75
+ if (!out.length) return console.log('작업 폴더(worktree) 없음');
76
+ const age = (t) => { if (!t) return '-'; const m = Math.round((Date.now() - t) / 60000); return m < 60 ? `${m}분 전` : m < 1440 ? `${Math.round(m / 60)}시간 전` : `${Math.round(m / 1440)}일 전`; };
77
+ console.log('| repo | 위치 | 종류 | 브랜치 | 마지막 손댐 | 상태 |\n|---|---|---|---|---|---|');
78
+ for (const x of out) console.log(`| ${x.repo} | ${x.rel} | ${KIND[x.kind]} | ${x.branch || (x.detached ? '(분리된 HEAD)' : '-')} | ${age(x.activity)} | ${x.missing ? '폴더 없음 (clean 이 기록 정리)' : x.done ? '끝남 (clean 이 지움)' : x.why} |`);
79
+ const stray = out.filter((x) => x.kind === 'other' && !x.missing);
80
+ if (out.some((x) => x.done || x.missing) || stray.length) console.log(`\n정리: kedovi worktree clean${stray.length ? ` (직접 만든 ${stray.length}개 중 진행 중인 것은 ${DIR}/<repo>/ 로 옮긴다)` : ''}`);
79
81
  }
80
82
 
81
83
  /** 작업 폴더 · 임시 브랜치 · 기록 지우기 */
82
84
  function drop(ws, r, unit) {
83
85
  const dir = wtDir(ws, r.name, unit);
86
+ const m = readMeta(ws, r.name, unit) || {};
84
87
  if (fs.existsSync(dir)) {
85
88
  const rm = git(r.dir, ['worktree', 'remove', '--force', dir]);
86
89
  if (!rm.ok) fs.rmSync(dir, { recursive: true, force: true });
87
90
  }
88
91
  git(r.dir, ['worktree', 'prune']);
89
- git(r.dir, ['branch', '-D', BRANCH(unit)]);
92
+ if (m.own !== false) git(r.dir, ['branch', '-D', BRANCH(unit)]);
90
93
  try { fs.unlinkSync(metaFile(ws, r.name, unit)); } catch { /* 없음 */ }
94
+ W.removeEmptyParents(dir, path.join(ws.root, DIR));
91
95
  }
92
96
 
93
97
  function readMeta(ws, repo, unit) {
@@ -99,6 +103,7 @@ function merge(ws, repo, unit) {
99
103
  const m = readMeta(ws, repo, unit);
100
104
  const dir = wtDir(ws, repo, unit);
101
105
  if (!m || !fs.existsSync(dir)) fail(`작업 폴더가 없습니다: ${DIR}/${repo}/${unit} (kedovi worktree list)`);
106
+ if (m.own === false) fail(`${DIR}/${repo}/${unit} 은 브랜치 ${m.branch} 를 그대로 쓰는 작업 폴더입니다. 그 폴더에서 커밋 · push 하고 끝나면 kedovi worktree clean`);
102
107
  // 새 파일까지 담으려고 임시 브랜치에 한 번 커밋한다 (이 PC 에만 있고 곧 지운다. repo 의 커밋 훅은 돌리지 않는다)
103
108
  git(dir, ['add', '-A']);
104
109
  const staged = git(dir, ['diff', '--cached', '--quiet']);
@@ -112,19 +117,19 @@ function merge(ws, repo, unit) {
112
117
  const files = git(dir, ['diff', '--name-only', m.base, 'HEAD']).out.split('\n').filter(Boolean);
113
118
  const now = git(r.dir, ['rev-parse', '--abbrev-ref', 'HEAD']).out;
114
119
  if (m.branch && now && m.branch !== 'HEAD' && now !== m.branch) fail(`${repo} 의 지금 브랜치(${now})가 만들 때(${m.branch})와 다릅니다. ${m.branch} 로 돌아간 뒤 다시 하세요`);
115
- const ap = git(r.dir, ['apply', '--3way', '--binary', '--whitespace=nowarn'], `${diff.out}\n`);
116
- if (!ap.ok) {
120
+ const ap = require('child_process').spawnSync('git', ['-C', r.dir, 'apply', '--3way', '--binary', '--whitespace=nowarn'], { input: `${diff.out}\n`, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
121
+ if (ap.status !== 0) {
117
122
  const conflicts = git(r.dir, ['diff', '--name-only', '--diff-filter=U']).out.split('\n').filter(Boolean);
118
123
  console.error(`✖ ${repo} · ${unit}: 본 작업 트리와 겹쳐 옮기지 못했습니다. 작업 폴더는 그대로 둡니다`);
119
124
  if (conflicts.length) console.error(` 충돌 표시가 남은 파일 (본 작업 트리): ${conflicts.join(', ')}. 고친 뒤 git -C ${path.relative(ws.root, r.dir)} add <파일>`);
120
- console.error(` git: ${ap.out.split('\n').slice(0, 6).join(' · ')}`);
125
+ console.error(` git: ${String(ap.stderr || ap.stdout || '').trim().split('\n').slice(0, 6).join(' · ')}`);
121
126
  process.exit(1);
122
127
  }
123
128
  drop(ws, r, unit);
124
129
  console.log(`✔ ${repo} · ${unit}: 변경 ${files.length}개 파일을 ${path.relative(ws.root, r.dir) || r.dir} 작업 트리로 옮겼습니다 (커밋 안 함)`);
125
130
  for (const f of files.slice(0, 20)) console.log(` ${f}`);
126
131
  if (files.length > 20) console.log(` … 외 ${files.length - 20}개`);
127
- console.log(' 다음: 통합 검사(빌드 · 테스트)를 돌리고 평소처럼 커밋');
132
+ console.log(' 다음: 통합 검사(빌드 · 테스트)를 돌리고 평소처럼 커밋. 끝난 작업 폴더가 더 있으면 kedovi worktree clean');
128
133
  }
129
134
 
130
135
  function remove(ws, repo, unit, force) {
@@ -138,14 +143,86 @@ function remove(ws, repo, unit, force) {
138
143
  console.log(`✔ ${repo} · ${unit}: 작업 폴더를 지웠습니다`);
139
144
  }
140
145
 
146
+ /** 킷 밖 작업 폴더를 .worktrees/<repo>/<이름> 으로 옮긴다 (git worktree move). 반환: 새 경로 또는 오류 */
147
+ function adopt(ws, x) {
148
+ const base = path.basename(x.path).replace(/[^A-Za-z0-9._-]/g, '-').replace(/^[-.]+/, '') || 'wt';
149
+ let unit = base;
150
+ for (let n = 2; fs.existsSync(wtDir(ws, x.repo, unit)) || fs.existsSync(metaFile(ws, x.repo, unit)); n++) unit = `${base}-${n}`;
151
+ const dst = wtDir(ws, x.repo, unit);
152
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
153
+ const mv = git(x.repoDir, ['worktree', 'move', x.path, dst]);
154
+ if (!mv.ok) return { error: mv.out.split('\n')[0] };
155
+ fs.writeFileSync(metaFile(ws, x.repo, unit), `${JSON.stringify({ repo: x.repo, unit, base: x.base || x.head, branch: x.branch || 'HEAD', own: false, adopted: x.rel, at: new Date().toISOString() }, null, 2)}\n`);
156
+ W.removeEmptyParents(x.path, ws.root);
157
+ return { to: path.relative(ws.root, dst) };
158
+ }
159
+
160
+ function clean(ws, { dry, branches, now: ignoreIdle }) {
161
+ const cleanupMerged = (((ws.vars || {}).git || {}).cleanupMerged) === true;
162
+ const idleMin = ignoreIdle ? 0 : W.IDLE_MIN;
163
+ const list = W.scan(ws, { deep: true, idleMin });
164
+ if (!list.length) return console.log('작업 폴더(worktree) 없음');
165
+ const rows = [];
166
+ const pruned = new Set();
167
+ for (const x of list) {
168
+ if (x.missing) {
169
+ if (!dry && !pruned.has(x.repoDir)) { git(x.repoDir, ['worktree', 'prune']); pruned.add(x.repoDir); }
170
+ rows.push([x, dry ? '기록 정리 예정 (폴더 없음)' : '기록 정리 (폴더 없음)']);
171
+ continue;
172
+ }
173
+ if (x.done) {
174
+ const kitUnit = x.kind === 'kit' ? path.basename(x.path) : null;
175
+ const temp = x.branch && x.branch.startsWith('kedovi/');
176
+ const delBranch = x.branch && (temp || ((branches || cleanupMerged) && x.landed));
177
+ if (dry) { rows.push([x, `지울 예정${delBranch ? ` (브랜치 ${x.branch} 도)` : ''}`]); continue; }
178
+ const rm = git(x.repoDir, ['worktree', 'remove', x.path]);
179
+ if (!rm.ok) { rows.push([x, `못 지움: ${rm.out.split('\n')[0]}`]); continue; }
180
+ let note = '지움';
181
+ if (delBranch) note += git(x.repoDir, ['branch', '-D', x.branch]).ok ? ` · 브랜치 ${x.branch} 지움` : ` · 브랜치 ${x.branch} 남김`;
182
+ if (kitUnit) { try { fs.unlinkSync(metaFile(ws, x.repo, kitUnit)); } catch { /* 없음 */ } }
183
+ W.removeEmptyParents(x.path, x.kind === 'kit' ? path.join(ws.root, DIR) : ws.root);
184
+ rows.push([x, note]);
185
+ continue;
186
+ }
187
+ // 진행 중: 킷 밖에 직접 만든 것은 손대지 않은 지 한 시간이 지났으면 .worktrees/ 로 옮긴다
188
+ const idle = !x.activity || Date.now() - x.activity >= idleMin * 60000;
189
+ if (x.kind === 'other' && idle && !x.locked) {
190
+ if (dry) { rows.push([x, `남김 (${x.why}) · ${DIR}/${x.repo}/ 로 옮길 예정`]); continue; }
191
+ const a = adopt(ws, x);
192
+ rows.push([x, a.error ? `남김 (${x.why}) · 옮기지 못함: ${a.error}` : `남김 (${x.why}) · ${a.to} 로 옮김`]);
193
+ continue;
194
+ }
195
+ rows.push([x, `남김 (${x.why})`]);
196
+ }
197
+ // 폴더 없는 킷 기록
198
+ const metaRoot = path.join(ws.root, DIR);
199
+ if (!dry && fs.existsSync(metaRoot)) {
200
+ for (const repo of fs.readdirSync(metaRoot)) {
201
+ const rd = path.join(metaRoot, repo);
202
+ if (!fs.statSync(rd).isDirectory()) continue;
203
+ for (const f of fs.readdirSync(rd).filter((n) => n.endsWith('.json'))) if (!fs.existsSync(path.join(rd, f.slice(0, -5)))) { try { fs.unlinkSync(path.join(rd, f)); } catch { /* 없음 */ } }
204
+ try { if (!fs.readdirSync(rd).length) fs.rmdirSync(rd); } catch { /* 비어 있지 않음 */ }
205
+ }
206
+ }
207
+ console.log(`작업 폴더 정리${dry ? ' (미리 보기)' : ''}\n`);
208
+ console.log('| repo | 위치 | 종류 | 브랜치 | 결과 |\n|---|---|---|---|---|');
209
+ for (const [x, note] of rows) console.log(`| ${x.repo} | ${x.rel} | ${KIND[x.kind]} | ${x.branch || '-'} | ${note} |`);
210
+ const kept = rows.filter(([, n]) => n.startsWith('남김'));
211
+ if (kept.length) console.log(`\n남긴 것 ${kept.length}개: 바뀐 파일은 merge(킷 작업 폴더) 또는 그 폴더에서 커밋, 머지 안 된 커밋은 MR 머지 뒤 다시 clean. 방금 손댄 것까지 보려면 --now`);
212
+ if (!branches && !cleanupMerged && rows.some(([x]) => x.done && x.branch && !x.branch.startsWith('kedovi/'))) console.log('머지된 작업 브랜치는 남겼습니다 (vars.git.cleanupMerged = false). 함께 지우려면 --branches');
213
+ }
214
+
141
215
  function main(argv) {
142
- const [cmd, repo, unit] = argv.filter((a) => !a.startsWith('--'));
216
+ const vals = [];
217
+ for (let i = 0; i < argv.length; i++) { if (['--base', '--branch'].includes(argv[i])) { i++; continue; } if (!argv[i].startsWith('--')) vals.push(argv[i]); }
218
+ const [cmd, repo, unit] = vals;
143
219
  const ws = load();
144
- if (cmd === 'add') return add(ws, repo, unit);
220
+ if (cmd === 'add') return add(ws, repo, unit, { base: opt(argv, 'base'), branch: opt(argv, 'branch') });
145
221
  if (cmd === 'merge') return merge(ws, repo, unit);
146
222
  if (cmd === 'remove') return remove(ws, repo, unit, argv.includes('--force'));
223
+ if (cmd === 'clean') return clean(ws, { dry: argv.includes('--dry-run'), branches: argv.includes('--branches'), now: argv.includes('--now') });
147
224
  if (!cmd || cmd === 'list') return list(ws, argv.includes('--json'));
148
- fail('사용법: kedovi worktree add|merge|remove <repo> <단위> · list [--json]');
225
+ fail('사용법: kedovi worktree add <repo> <단위> [--base <ref> | --branch <브랜치>] · merge|remove <repo> <단위> · list [--json] · clean [--dry-run] [--branches] [--now]');
149
226
  }
150
227
 
151
228
  if (require.main === module) main(process.argv.slice(2));
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // 팀원 git 안전장치 (Claude Code · Codex PreToolUse Bash): 팀원 · 서브에이전트 · 위임 세션은 워크스페이스 루트 repo 에 git 쓰기를 하지 않고, push 는 어디서도 하지 않는다 (리더만). 통합 브랜치 직접 운영(vars.gitlab.branchMode = trunk)이면 새 브랜치 · worktree 도 막는다 (리더는 경고).
2
+ // 팀원 git 안전장치 (Claude Code · Codex PreToolUse Bash): 팀원 · 서브에이전트 · 위임 세션은 워크스페이스 루트 repo 에 git 쓰기를 하지 않고, push 는 어디서도 하지 않는다 (리더만). 통합 브랜치 직접 운영(vars.gitlab.branchMode = trunk)이면 새 브랜치 · worktree 도 막는다 (리더는 경고). git worktree add 를 .worktrees/ · .claude/worktrees/ 밖에 하는 것은 누구든 막는다 (kedovi worktree add 로).
3
3
  // 명령을 나눠 cd 를 따라가며 실제로 git 이 도는 위치를 본다. cd 대상이 없으면(실패하면 그 자리에서 다음 명령이 돈다) 위치가 바뀌지 않은 것으로, $변수 · `명령` 이면 위치를 모르는 것으로 본다.
4
4
  // bash x.sh · sh x.sh · ./x.sh 로 부르는 스크립트와 bash -c "…" 의 내용도 같은 방법으로 본다 (python · make 안의 git 은 못 본다).
5
5
  // cd 뒤에 && · || exit · set -e 없이 이어지는 git 쓰기도 막는다 (git -C <절대경로> 로). 리더 세션은 막지 않고 경고(additionalContext)만, push 는 리더 몫이라 조용. 막을 때만 deny JSON, 예외는 삼키고 항상 exit 0
@@ -116,6 +116,16 @@ function findGit(cmd, cwd, root, depth = 0) {
116
116
  if (!sub) continue;
117
117
  if (sub === 'init' || sub === 'clone') { if (where) inited.push(sub === 'init' ? abs(rest.find((x) => !x.startsWith('-')) || '.', where) : abs(rest.filter((x) => !x.startsWith('-'))[1] || path.basename(String(rest.filter((x) => !x.startsWith('-'))[0] || '')).replace(/\.git$/, ''), where)); continue; }
118
118
  if (sub === 'push') { out.push({ kind: 'push', sub, where }); continue; }
119
+ // 작업 폴더 위치: .worktrees/ · .claude/worktrees/ 밖(repos/ 안 등)에 만들지 않는다 (누구든)
120
+ if (sub === 'worktree' && rest[0] === 'add') {
121
+ let target = null;
122
+ for (let q = 1; q < rest.length; q++) { if (/^(-b|-B|--reason)$/.test(rest[q])) { q++; continue; } if (!rest[q].startsWith('-')) { target = rest[q]; break; } }
123
+ if (target && !DYNAMIC.test(target) && (where || path.isAbsolute(target))) {
124
+ const to = abs(target, where || '/');
125
+ const ok = [path.join(root, '.worktrees'), path.join(root, '.claude', 'worktrees')].some((d) => to === d || to.startsWith(d + path.sep) || (real(path.dirname(to)) + path.sep).startsWith(real(d) + path.sep));
126
+ if (!ok) out.push({ kind: 'wtpath', sub, where, target: path.relative(root, to) || to });
127
+ }
128
+ }
119
129
  // 새 브랜치 · worktree (통합 브랜치 직접 운영에서 막는다)
120
130
  if ((sub === 'worktree' && rest[0] === 'add') || (sub === 'switch' && rest.some((x) => /^-[cC]$|^--(create|force-create)/.test(x))) || (sub === 'checkout' && rest.some((x) => /^-[bB]$/.test(x))) || (sub === 'branch' && !READ_FORM.branch(rest) && !rest.some((x) => /^-[dDmMcC]$|^--(delete|move|copy|set-upstream-to|unset-upstream)/.test(x)))) out.push({ kind: 'newbranch', sub, where });
121
131
  if (!ROOT_WRITE.has(sub) || (READ_FORM[sub] && READ_FORM[sub](rest))) continue;
@@ -131,6 +141,7 @@ function message(hit, root) {
131
141
  const via = hit.via ? ` (스크립트 ${hit.via} 안)` : '';
132
142
  if (hit.kind === 'push') return `팀원은 git push 를 하지 않는다${via}. push 는 리더만 한다: 커밋까지 끝났으면 여기서 다시 시도하지 말고 올릴 repo · 브랜치 · 커밋을 리더에게 보고하고 일을 마친다.`;
133
143
  if (hit.kind === 'newbranch') return `이 워크스페이스는 통합 브랜치에서 직접 작업한다 (vars.gitlab.branchMode = trunk)${via}. git ${hit.sub} 로 브랜치 · worktree 를 만들지 않고 지금 브랜치(또는 메인이 준 작업 폴더)에서 고친다. 같은 repo 를 나눠 맡아야 하면 메인이 kedovi worktree add <repo> <단위> 로 만든다. 그 밖에 브랜치가 꼭 필요하면 멈추고 리더에게 알린다.`;
144
+ if (hit.kind === 'wtpath') return `작업 폴더(worktree)를 ${hit.target} 에 만들지 않는다${via}. repo 폴더 사이에 섞여 구분 · 정리가 어려워진다. \`kedovi worktree add <repo> <단위>\` 로 .worktrees/<repo>/<단위> 에 만든다 (있는 브랜치를 받으려면 --branch <브랜치>, 기준을 바꾸려면 --base <ref>). 끝나면 kedovi worktree merge 또는 kedovi worktree clean.`;
134
145
  if (hit.kind === 'unsafe-cd') return `cd 뒤 git ${hit.sub} 이(가) && 연결 · set -e 없이 이어진다${via}. cd 가 실패하면 워크스페이스 루트 repo 에서 돈다. \`git -C <절대경로> ${hit.sub} …\` 로 위치를 명시해 다시 실행한다 (또는 \`cd <경로> && git …\`).`;
135
146
  if (hit.kind === 'unknown') return `git ${hit.sub} 이(가) 어느 repo 에서 도는지 알 수 없다${via} (cd · -C 대상이 변수이거나 위치가 바뀐 뒤). cd 가 실패하면 워크스페이스 루트 repo 에서 돈다. 맡은 repo 를 \`git -C repos/<이름> ${hit.sub} …\` 처럼 실제 경로로 적어 다시 실행한다.`;
136
147
  return `팀원은 워크스페이스 루트 repo(${root}) 에 git ${hit.sub} 을(를) 하지 않는다${via}. 사용자의 미커밋 파일이 사라질 수 있다. 맡은 repo 를 \`git -C repos/<이름> ${hit.sub} …\` 로 부른다. 루트를 바꿔야 하면 멈추고 리더에게 알린다.`;
@@ -146,6 +157,8 @@ function main() {
146
157
  if (!/\bgit\b|\.(?:sh|bash|zsh)\b|\b(?:bash|sh|zsh)\b|\.\//.test(cmd)) return;
147
158
  const trunk = (() => { try { return ((JSON.parse(fs.readFileSync(path.join(R, 'workspace.json'), 'utf8')).vars || {}).gitlab || {}).branchMode === 'trunk'; } catch { return false; } })();
148
159
  const hits = findGit(cmd, input.cwd || R, path.resolve(R)).filter((h) => h.kind !== 'newbranch' || trunk);
160
+ const wt = hits.find((h) => h.kind === 'wtpath');
161
+ if (wt) { deny(`${message(wt, R)} (git 안전장치: packs/core/hooks/git-guard.js)`); return; }
149
162
  if (member) { if (hits[0]) deny(`${message(hits[0], R)} (팀원 git 안전장치: packs/core/hooks/git-guard.js)`); return; }
150
163
  // 리더: push 는 리더 몫이라 그대로, 나머지는 막지 않고 경고만
151
164
  // 루트 커밋은 리더 일(워크스페이스 설정 · 기록)이라 지우는 쪽(reset · clean · checkout · restore · stash · rebase · branch)만
@@ -6,6 +6,7 @@
6
6
  * UserPromptSubmit (30분에 한 번):
7
7
  * 메모리: 이 PC 의 Claude Code 세션 나무(MCP · 셸 · 브라우저 포함) 합계가 vars.session.memoryWarnGB(기본 8)를 넘으면 세션 수 · 큰 세션 · 주인 없이 남은 브라우저 · MCP 를 한 줄로
8
8
  * 오래된 세션: 이 세션(claude 프로세스)이 vars.session.longHours(기본 8) 시간을 넘으면 핸드오프 뒤 새로 시작하라고 (같은 세션에 2시간마다)
9
+ * 작업 폴더: 하루 넘게 손대지 않았거나 킷 밖(.worktrees/ · .claude/worktrees/ 밖)에 만든 worktree 가 있으면 kedovi worktree clean 을 (메인 세션, 6시간에 한 번)
9
10
  * 맥락: 대화 기록의 마지막 응답 사용량(입력 + 캐시)이 맥락 창의 vars.session.renewContextPct(기본 70)% 를 넘으면 같은 제안 (같은 세션에 한 번, 10%p 더 늘면 다시)
10
11
  * 자세히: kedovi doctor 의 「메모리」 항목. 판정은 lib/procmem.js (Windows 는 하지 않는다)
11
12
  */
@@ -118,6 +119,15 @@ run(() => {
118
119
  st.ctxWarned = ctx.pct;
119
120
  out.push(`⚠ 대화 맥락이 약 ${ctx.pct}% 찼습니다 (${Math.round(ctx.tokens / 1000)}K / ${ctx.window / 1000}K 추정, 기준 ${cfg.ctxPct}%). 응답이 느려지고 앞 내용이 요약될 수 있습니다. 이번 요청을 마치면 핸드오프를 남기고 새 세션으로 시작하자고 사용자에게 한 줄 제안한다`);
120
121
  }
122
+ // 남은 작업 폴더 (메인 세션, 6시간에 한 번): 하루 넘게 손대지 않은 것 · 킷 밖에 직접 만든 것 · 폴더 없는 기록
123
+ if (!input.agent_id && (!st.wtWarned || now - st.wtWarned > 6 * 3600000)) {
124
+ let w = null;
125
+ try { w = require('../lib/worktrees').summary(load(ROOT), { now }); } catch { /* 옛 워크스페이스 */ }
126
+ if (w && (w.stale || w.stray || w.missing)) {
127
+ st.wtWarned = now;
128
+ out.push(`⚠ 작업 폴더(worktree) ${w.total}개가 남아 있습니다 (하루 넘게 손대지 않음 ${w.stale}개 · 킷 밖 위치 ${w.stray}개 · 폴더 없는 기록 ${w.missing}개). 사용자에게 한 줄 알리고 kedovi worktree clean 으로 끝난 것을 정리한다 (바뀐 파일 · 머지 안 된 커밋이 있는 것은 남고, 킷 밖의 것은 .worktrees/ 로 옮긴다. 미리 보기 --dry-run)`);
129
+ }
130
+ }
121
131
  try { fs.writeFileSync(file, JSON.stringify(st)); } catch { /* 기록 실패 */ }
122
132
  if (out.length) context(out.join('\n'));
123
133
  });
@@ -0,0 +1,146 @@
1
+ // 워크스페이스 repo 들의 git worktree(작업 폴더)를 훑는다. 쓰는 곳: bin/worktree.js (list · clean) · hooks/session-health.js (남은 작업 폴더 알림)
2
+ /*
3
+ * 종류: kit = 킷 작업 폴더(.worktrees/<repo>/<단위>) · claude = Claude Code 작업 폴더(.claude/worktrees/) · other = 그 밖(git worktree add 로 직접 만든 것)
4
+ * 끝난 작업 폴더 = 바뀐 파일이 없고, 브랜치 내용이 이미 기준 브랜치에 들어갔거나(squash 머지 포함) 기준에서 나아간 커밋이 없고, 최근 손댄 지 idleMin 분이 지난 것
5
+ */
6
+ 'use strict';
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { execFileSync } = require('child_process');
10
+
11
+ const KIT_DIR = '.worktrees';
12
+ const CLAUDE_DIR = path.join('.claude', 'worktrees');
13
+ const IDLE_MIN = 60;
14
+
15
+ function git(cwd, args) {
16
+ try {
17
+ return { ok: true, out: execFileSync('git', ['-C', cwd, '-c', 'core.quotepath=false', ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024, timeout: 20000 }).trim() };
18
+ } catch (e) { return { ok: false, out: String((e.stderr || '') + (e.stdout || '') || e.message).trim() }; }
19
+ }
20
+
21
+ const real = (p) => { try { return fs.realpathSync(p); } catch { return path.resolve(p); } };
22
+ const under = (p, dir) => { const a = real(p); const b = real(dir); return a === b || a.startsWith(b + path.sep); };
23
+
24
+ /** git worktree list --porcelain → [{ path, head, branch, detached, locked, prunable, main }] (첫 항목 = 본 작업 트리) */
25
+ function listRepo(repoDir) {
26
+ const r = git(repoDir, ['worktree', 'list', '--porcelain']);
27
+ if (!r.ok) return [];
28
+ const out = [];
29
+ let cur = null;
30
+ for (const line of r.out.split('\n')) {
31
+ if (line.startsWith('worktree ')) { cur = { path: line.slice(9), branch: null, detached: false, locked: false, prunable: false }; out.push(cur); continue; }
32
+ if (!cur) continue;
33
+ if (line.startsWith('HEAD ')) cur.head = line.slice(5);
34
+ else if (line.startsWith('branch ')) cur.branch = line.slice(7).replace(/^refs\/heads\//, '');
35
+ else if (line === 'detached') cur.detached = true;
36
+ else if (line.startsWith('locked')) cur.locked = true;
37
+ else if (line.startsWith('prunable')) cur.prunable = true;
38
+ else if (line === 'bare') cur.bare = true;
39
+ }
40
+ out.forEach((w, i) => { w.main = i === 0; });
41
+ return out;
42
+ }
43
+
44
+ function kindOf(root, p) {
45
+ if (under(p, path.join(root, KIT_DIR))) return 'kit';
46
+ if (under(p, path.join(root, CLAUDE_DIR))) return 'claude';
47
+ return 'other';
48
+ }
49
+
50
+ /** 작업 폴더를 마지막으로 손댄 시각 (그 worktree 의 git 기록 · 인덱스 · 폴더). git status 를 돌리기 전에 읽는다 */
51
+ function lastActivity(p) {
52
+ const files = [p];
53
+ try {
54
+ const m = fs.readFileSync(path.join(p, '.git'), 'utf8').match(/^gitdir:\s*(.+?)\s*$/m);
55
+ if (m) { const gd = path.resolve(p, m[1]); files.push(path.join(gd, 'index'), path.join(gd, 'HEAD'), path.join(gd, 'logs', 'HEAD')); }
56
+ } catch { /* 없음 */ }
57
+ let t = 0;
58
+ for (const f of files) { try { t = Math.max(t, fs.statSync(f).mtimeMs); } catch { /* 없음 */ } }
59
+ return t || null;
60
+ }
61
+
62
+ /** 기준 커밋들: 본 작업 트리 HEAD · 그 upstream · origin/HEAD (있는 것만) */
63
+ function targets(repoDir) {
64
+ const out = [];
65
+ for (const ref of ['HEAD', '@{upstream}', 'refs/remotes/origin/HEAD']) {
66
+ const r = git(repoDir, ['rev-parse', '--verify', '-q', `${ref}^{commit}`]);
67
+ if (r.ok && r.out && !out.includes(r.out)) out.push(r.out);
68
+ }
69
+ return out;
70
+ }
71
+
72
+ /** 브랜치(또는 커밋) 내용이 기준에 이미 있는가: 조상이거나, 기준과 갈라진 뒤 바꾼 파일이 지금 기준과 모두 같다 (squash 머지) */
73
+ function landed(repoDir, tip, bases) {
74
+ for (const b of bases) {
75
+ if (git(repoDir, ['merge-base', '--is-ancestor', tip, b]).ok) return true;
76
+ const mb = git(repoDir, ['merge-base', tip, b]);
77
+ if (!mb.ok || !mb.out) continue;
78
+ const files = git(repoDir, ['diff', '--name-only', mb.out, tip]);
79
+ if (!files.ok) continue;
80
+ const list = files.out.split('\n').filter(Boolean);
81
+ if (list.length && git(repoDir, ['diff', '--quiet', tip, b, '--', ...list]).ok) return true;
82
+ }
83
+ return false;
84
+ }
85
+
86
+ /**
87
+ * 워크스페이스의 모든 작업 폴더 (본 작업 트리 제외)
88
+ * ws = lib/workspace load() 결과. deep 이면 바뀐 파일 · 기준 반영 여부 · 끝남 판정까지 (repo 마다 git 을 더 돈다)
89
+ * 반환: [{ repo, repoDir, path, rel, kind, branch, head, detached, locked, missing, activity, changed?, ahead?, landed?, done?, why? }]
90
+ */
91
+ function scan(ws, { deep = false, idleMin = IDLE_MIN, now = Date.now() } = {}) {
92
+ const out = [];
93
+ const seen = new Set();
94
+ for (const r of ws.repos || []) {
95
+ if (!r.dir || !fs.existsSync(path.join(r.dir, '.git'))) continue;
96
+ const key = real(r.dir);
97
+ if (seen.has(key)) continue;
98
+ seen.add(key);
99
+ const wts = listRepo(r.dir).filter((w) => !w.main && !w.bare);
100
+ if (!wts.length) continue;
101
+ const bases = deep ? targets(r.dir) : [];
102
+ for (const w of wts) {
103
+ const missing = w.prunable || !fs.existsSync(w.path);
104
+ const x = { repo: r.name, repoDir: r.dir, path: w.path, rel: path.relative(ws.root, w.path) || w.path, kind: kindOf(ws.root, w.path), branch: w.branch, head: w.head, detached: w.detached, locked: w.locked, missing, activity: missing ? null : lastActivity(w.path) };
105
+ if (deep && !missing) {
106
+ const st = git(w.path, ['status', '--porcelain']);
107
+ x.changed = st.ok ? st.out.split('\n').filter(Boolean).length : null;
108
+ const tip = w.head;
109
+ const base = bases.find((b) => git(r.dir, ['merge-base', '--is-ancestor', b, tip]).ok);
110
+ const ahead = bases.length ? git(r.dir, ['rev-list', '--count', tip, ...bases.map((b) => `^${b}`)]) : { ok: false };
111
+ x.ahead = ahead.ok ? Number(ahead.out) : null;
112
+ x.landed = !!tip && (x.ahead === 0 || landed(r.dir, tip, bases));
113
+ const idle = !x.activity || now - x.activity > idleMin * 60000;
114
+ if (w.locked) x.why = '잠김 (git worktree unlock 뒤)';
115
+ else if (x.changed === null) x.why = '상태를 읽지 못함';
116
+ else if (x.changed > 0) x.why = `바뀐 파일 ${x.changed}개`;
117
+ else if (!x.landed) x.why = `기준 브랜치에 없는 커밋 ${x.ahead === null ? '?' : x.ahead}개 (머지 · 옮기기 전)`;
118
+ else if (!idle) x.why = `최근 ${Math.max(1, Math.round((now - x.activity) / 60000))}분 안에 손댐 (작업 중일 수 있음)`;
119
+ else x.done = true;
120
+ x.base = base || bases[0] || null;
121
+ }
122
+ out.push(x);
123
+ }
124
+ }
125
+ return out;
126
+ }
127
+
128
+ /** 빈 상위 폴더를 stop 직전까지 지운다 (repos/<x>-wt/ 처럼 작업 폴더만 담던 폴더) */
129
+ function removeEmptyParents(dir, stop) {
130
+ for (let d = path.dirname(dir); under(d, stop) && real(d) !== real(stop); d = path.dirname(d)) {
131
+ try { if (fs.readdirSync(d).filter((f) => f !== '.DS_Store').length) break; try { fs.unlinkSync(path.join(d, '.DS_Store')); } catch { /* 없음 */ } fs.rmdirSync(d); } catch { break; }
132
+ }
133
+ }
134
+
135
+ /** 하루 넘게 손대지 않은 작업 폴더 · 킷 밖 위치 · 폴더 없는 기록 수 (가벼운 훑기, 알림용) */
136
+ function summary(ws, { now = Date.now(), staleHours = 24 } = {}) {
137
+ const list = scan(ws, { now });
138
+ return {
139
+ total: list.length,
140
+ stray: list.filter((x) => x.kind === 'other' && !x.missing).length,
141
+ stale: list.filter((x) => !x.missing && x.activity && now - x.activity > staleHours * 3600000).length,
142
+ missing: list.filter((x) => x.missing).length,
143
+ };
144
+ }
145
+
146
+ module.exports = { KIT_DIR, CLAUDE_DIR, IDLE_MIN, git, listRepo, kindOf, lastActivity, targets, landed, scan, summary, removeEmptyParents, under };
@@ -135,7 +135,7 @@
135
135
  false,
136
136
  true
137
137
  ],
138
- "desc": "머지가 확인된 로컬 브랜치 · worktree 를 에이전트가 머지 직후 정리할지. false(기본) = 지우지도 제안하지도 않는다. true = git status 와 merge-base 로 잃을 것이 없음을 보인 뒤 지운다 (원격 브랜치 삭제는 건마다 승인)"
138
+ "desc": "머지가 확인된 로컬 작업 브랜치를 에이전트가 머지 직후 정리할지. false(기본) = 지우지도 제안하지도 않는다. true = git status 와 merge-base 로 잃을 것이 없음을 보인 뒤 지운다 (원격 브랜치 삭제는 건마다 승인). 작업 폴더(worktree)는 이 값과 상관없이 kedovi worktree clean 이 끝난 것만 지운다 (true 면 그 브랜치도)"
139
139
  },
140
140
  "session.memoryWarnGB": {
141
141
  "default": "8",
@@ -10,5 +10,6 @@ load: always
10
10
  - **커밋 전에 diff 를 본다** — 의도한 파일만 스테이징하고 비밀값·임시 파일·산출물을 섞지 않는다. 메시지는 repo 관례대로.
11
11
  - **내가 만들지 않은 변경은 되돌리지 않는다** — 작업 트리에 있던 수정은 사용자 것이다. 겹치면 멈추고 묻는다.
12
12
  - **파괴적 명령·히스토리 변경은 요청받았을 때만** — `reset --hard`·`checkout -- `·`clean`·amend·rebase·강제 push 전에 `git status` 로 잃을 것을 보이고 승인을 받는다.
13
- - **브랜치 정리** (`cleanupMerged = {{ws:vars.git.cleanupMerged}}`): `false` 면 로컬 브랜치 · worktree 를 지우지 않고 삭제 · prune 을 제안하지도 않는다. `true` 면 머지가 확인된 것만 머지 직후 지운다: 먼저 `git status` 로 미커밋 변경이 없음을, `git merge-base --is-ancestor <브랜치> origin/<대상>` 으로 머지됨을 보인다. 원격 브랜치 삭제는 건마다 승인받는다.
13
+ - **브랜치 정리** (`cleanupMerged = {{ws:vars.git.cleanupMerged}}`): `false` 면 로컬 브랜치를 지우지 않고 삭제를 제안하지도 않는다. `true` 면 머지가 확인된 것만 머지 직후 지운다: 먼저 `git status` 로 미커밋 변경이 없음을, `git merge-base --is-ancestor <브랜치> origin/<대상>` 으로 머지됨을 보인다. 원격 브랜치 삭제는 건마다 승인받는다.
14
+ - **작업 폴더(worktree)는 `kedovi worktree add <repo> <단위>` 로만** 만든다 (`.worktrees/<repo>/<단위>`, 있는 브랜치는 `--branch`). `git worktree add` 로 repo 옆에 만들지 않는다 (훅이 막는다). 단위가 끝나면 `kedovi worktree merge`, 남은 것은 `kedovi worktree clean` 으로 정리한다 (위 브랜치 정리 설정과 상관없이. 바뀐 파일 · 머지 안 된 커밋이 있는 것은 남는다).
14
15
  - **넓은 패턴으로 프로세스를 죽이지 않는다** — 내가 띄운 PID 만.
@@ -24,7 +24,8 @@ description: 워크스페이스 설정을 바꾸거나 확인하는 요청을 ke
24
24
  | 화면이 너무 많이 올라가 읽기 힘들 때 | `kedovi tips` (Claude Code `/tui fullscreen` · `/focus` · `Ctrl+O` 안내, 사용자가 직접 친다) | 읽기만 |
25
25
  | 기능 추천 보기 · 그만 묻기 · 다시 묻기 · 끄기 (훅의 「기능 추천」 에 사용자가 답했을 때 기록) | `kedovi suggest` · `set <id> yes\|no [--all]` · `reset [<id>]` · `off\|on [--all]` | 이 PC (`--all` = 모든 프로젝트) |
26
26
  | 에이전트 진행 보기 (Claude Code: 작업 리더 · 역할 에이전트 · 리더 아래 팀원, 이름 없는 서브에이전트도) | `kedovi agents watch` (2초마다 새로 그림) · `--once` (채팅에서는 이것) · `--all` (끝난 것까지) · `--json` · `--tmux` (tmux 안이면 오른쪽 창에) | 읽기만 |
27
- | 작업 리더 작업 폴더 | `kedovi worktree add <repo> <단위>` · `merge <repo> <단위>` (본 작업 트리에 커밋하지 않은 변경으로 옮기고 작업 폴더 · 임시 브랜치 삭제, 겹치면 멈춤) · `remove <repo> <단위> [--force]` · `list`. 같은 repo 를 여러 작업 리더가 동시에 고칠 때 (`team` 스킬 「작업 리더」) | 개인 |
27
+ | 작업 폴더 (worktree) | `kedovi worktree add <repo> <단위> [--base <ref> \| --branch <브랜치>]` (`.worktrees/<repo>/<단위>`) · `merge <repo> <단위>` (본 작업 트리에 커밋하지 않은 변경으로 옮기고 작업 폴더 · 임시 브랜치 삭제, 겹치면 멈춤) · `remove <repo> <단위> [--force]` · `list` (모든 repo 의 작업 폴더 · 상태). 같은 repo 를 여러 작업 리더가 동시에 고칠 때 (`team` 스킬 「작업 리더」). `git worktree add` 를 직접 쓰지 않는다 (훅이 막는다) | 개인 |
28
+ | 끝난 작업 폴더 정리 ("worktree 정리해줘") | `kedovi worktree clean [--dry-run] [--branches] [--now]`: 바뀐 파일 없고 브랜치 내용이 기준 브랜치에 있는(squash 머지 포함) 작업 폴더를 지운다. 진행 중인데 킷 밖에 있는 것은 `.worktrees/<repo>/` 로 옮긴다 | 개인 |
28
29
  | 로드맵 보기 · 점검 | `kedovi plan` (흐름도 · 지금 단계 표 · 다음, 이슈형은 이슈 보드) · `kedovi plan --short` (한 줄) · `kedovi plan check` (갱신 누락 ⚠) · `kedovi plan --report [시작 [끝]]` (이슈형 주간 보고) | 보기 |
29
30
  | 일정 정본을 밖에 둘 때 (GitLab 마일스톤 · 외부 일정표) | `kedovi plan external "<위치>"` (workspace.json `vars.plan.external` 에 적고 handoffs/PLAN.md 갱신 경고를 내지 않는다) · `kedovi plan external off` (PLAN.md 를 다시 정본으로) · `kedovi plan external` (지금 값). "일정은 GitLab 마일스톤에서 관리해" 같은 말에 쓴다 | 팀 |
30
31
  | 팀 구성 바꾸기 | `kedovi team-mode auto\|fixed` · `prefer <역할> <claude\|codex>:<모델>` (`--team` 은 팀 기본값, 팀장) | 이 PC · 팀 |
@@ -65,6 +66,7 @@ description: 워크스페이스 설정을 바꾸거나 확인하는 요청을 ke
65
66
  | 설정 수정 권한 | `kedovi team edit allow\|deny` · `kedovi team admins [id…]` | 팀 |
66
67
  | repo 추가 | `kedovi repo add <git 주소\|폴더\|새 이름> [--kind code\|docs\|issues\|legacy] [--group <그룹>]` (그룹이면 `repos/<그룹>/<이름>`. 이름만 주면 원격 없이 새로 만든다, 레거시 제외) | 팀 |
67
68
  | repo 그룹 폴더로 옮기기 | `kedovi repo move <이름> --group <그룹>` · `--no-group` (폴더 · workspace.json · 문서의 옛 경로를 고치고 sync) | 팀 (팀장) |
69
+ | repo 를 주소 · 이름별 폴더로 묶기 ("repo 폴더 정리해줘") | `kedovi repo group` (주소 경로 기준 추천 표, 겹침이 없으면 이름 앞부분 기준) · `--apply [--by remote\|name]` (모두 옮김: 폴더 · worktree 연결 · 문서 경로 · sync) | 팀 (팀장) |
68
70
  | repo 안의 기존 AI 지침 | `kedovi repo guides` (보기) · `kedovi repo guides <이름> follow\|kit\|ignore` (follow = repo 지침 우선, 기본 · kit = 킷 규칙 우선 · ignore = 무시) · `kedovi repo guides --rescan [<이름>]` (다시 훑기). "이 repo 의 CLAUDE.md 는 무시해줘" 같은 요청 | 팀 (팀장) |
69
71
  | repo 빼기 | `kedovi repo remove <이름> [--delete]` (workspace.json · 리뷰 대상에서 지우고 sync, 이름이 남은 문서를 알림. 폴더는 `--delete` 일 때만, 커밋 안 한 변경 · push 안 한 커밋이 있으면 거부) | 팀 (팀장) |
70
72
  | 스택 다시 감지 | `kedovi detect` · 감지 힌트 `kedovi detect --hint <스택> --contains <정규식>` | 팀 |
@@ -140,7 +140,7 @@ AI 게이트웨이를 쓰는 Claude Code 에서는 GPT 역할도 **보통 하위
140
140
  - **작업 리더**: 맡은 단위에서 팀원을 순서대로 부르고 리뷰 반영까지 끝내 20줄 안으로 보고한다. 코드를 쓰지 않는다 (`lead` 역할 정의).
141
141
  - **띄우는 법 (Claude Code)**: 리더는 **팀 모드여도 이름(name) 없이 서브에이전트로** 띄운다 (이름을 주면 팀원이 되어 그 아래 팀원이 병렬로 돌지 않는다. 훅이 막는다). 리더 여럿은 한 메시지에 함께 부르고 `run_in_background` 로 돌린다. 리더는 팀원도 **이름 없이** 서브에이전트로 부르고(이름을 주면 팀원 세션이 되어 보고가 메인으로 가고 리더는 결과 없이 끝난다. 훅이 막는다), 팀원 완료 알림을 받을 때까지 기다린 뒤 보고한다 (중첩 깊이 2, sync 가 `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH` 로 정한다). 리더에게 주는 지시서에 팀원 이름을 적지 않는다. 진행은 `kedovi agents watch` 로 본다.
142
142
  - **상한**: 개인 지침 「역할 에이전트 상한」 의 리더 동시 · 리더당 팀원 동시 · 요청당 모두. 이 PC 의 Claude 요금제 여유도(빠듯 1×2 · Max 2×2 · 넉넉 3×2 · Ultra · 종량 4×3)로 정해지고 팀 값보다 높지 않다. 넘으면 훅이 막는다. **리더 하나에 단위 하나**: 단위가 리더 상한보다 많으면 리더가 끝난 자리에 새 리더를 띄워 다음 단위를 맡긴다. 한 리더에 단위를 얹으면 그 아래 팀원이 쌓여 리더가 늦게 끝나고 보고도 늦게 온다.
143
- - **같은 repo 를 둘 이상의 리더가 고치면** 메인이 리더마다 `kedovi worktree add <repo> <단위>` 로 작업 폴더를 먼저 만들어 지시서에 적는다 (통합 브랜치 직접 운영이어도 된다: 임시 브랜치는 이 PC 에만 있다). 리더가 끝나면 메인이 `kedovi worktree merge <repo> <단위>` 로 본 작업 트리에 커밋하지 않은 변경으로 옮긴 뒤 다음 단위를 옮긴다. 겹치면 멈추고 겹친 파일을 고친 뒤 다시.
143
+ - **같은 repo 를 둘 이상의 리더가 고치면** 메인이 리더마다 `kedovi worktree add <repo> <단위>` 로 작업 폴더를 먼저 만들어 지시서에 적는다 (통합 브랜치 직접 운영이어도 된다: 임시 브랜치는 이 PC 에만 있다). 리더가 끝나면 메인이 `kedovi worktree merge <repo> <단위>` 로 본 작업 트리에 커밋하지 않은 변경으로 옮긴 뒤 다음 단위를 옮긴다. 겹치면 멈추고 겹친 파일을 고친 뒤 다시. 모든 단위를 마치면 `kedovi worktree clean` 으로 남은 작업 폴더를 정리하고 보고에 한 줄 적는다.
144
144
  - **진행 보기**: 사용자에게 「리더 n명 · 단위 목록」 을 한 줄로 알리고, 리더 보고가 올 때마다 한 줄씩 전한다. 리더는 단계마다 · {{ws:vars.team.leadReportMinutes}}분마다 진행판(`kedovi team step`)을 고치고 메인에게 한 줄을 보낸다. 메인 · 사용자는 `kedovi team board` 로 단위마다 단계 · 끝난 것 · 다음 · 예상 종료를 본다 (tmux 창 없이도. 요청 시작 때 훅이 진행 중인 단위를 넣는다). 상태 줄의 예상 종료는 진행판 · `kedovi heavy status` 로 적는다.
145
145
  - **리더는 팀원이 도는 동안 끝내지 않는다**: 끝내면 그 뒤 보고가 끊기고 끝남 알림이 늦게 온다. 훅이 한 번 되돌린다 (`kedovi team-mode enforce hold`).
146
146
  - **리더 보고는 메시지로 온다**: 백그라운드 서브에이전트는 그 아래 팀원 · 백그라운드 명령이 모두 끝나야 끝남 알림이 메인에 간다. 그래서 리더는 이정표 · 최종 보고 · 결정 요청을 먼저 메시지로 보낸다 (`lead` 정의). 메인은 그 메시지를 받으면 끝남 알림을 기다리지 않고 바로 다음 일(합치기 · 결정 묻기 · 다음 리더)로 넘어간다.
@@ -164,7 +164,7 @@ AI 게이트웨이를 쓰는 Claude Code 에서는 GPT 역할도 **보통 하위
164
164
  - 경계 파일(공유 타입·스키마·API 계약)은 한 명이 먼저 만들고 알린 뒤 나머지가 시작한다.
165
165
  - tester 는 테스트 파일만, documenter · spec-writer 는 문서 파일만 소유한다. 제품 코드 결함은 해당 implementer 에게 되돌린다.
166
166
  - 소유 밖 변경이 필요하면 멈추고 리더에게 알린다. 리더가 소유를 다시 나눈다.
167
- - **브랜치 · worktree:** 팀원은 git 으로 브랜치 · worktree 를 직접 만들지 않는다 (통합 브랜치 직접 운영 `vars.gitlab.branchMode` = `trunk` 면 훅이 막는다). 같은 repo 를 동시에 둘 이상에게 맡기려면 메인이 `kedovi worktree add <repo> <단위>` 로 작업 폴더를 나눠 준다 (임시 브랜치는 이 PC 에만, merge 때 지운다). 작업 폴더가 없으면 같은 repo 는 한 명에게만 맡기고 차례로 넘긴다.
167
+ - **브랜치 · worktree:** 팀원은 git 으로 브랜치 · worktree 를 직접 만들지 않는다 (통합 브랜치 직접 운영 `vars.gitlab.branchMode` = `trunk` 면 훅이 막는다). `git worktree add` 로 `.worktrees/` 밖(repo 옆 `<repo>-wt/` 등)에 만드는 것은 누구든 훅이 막는다. 같은 repo 를 동시에 둘 이상에게 맡기려면 메인이 `kedovi worktree add <repo> <단위>` 로 작업 폴더를 나눠 준다 (임시 브랜치는 이 PC 에만, merge 때 지운다). 작업 폴더가 없으면 같은 repo 는 한 명에게만 맡기고 차례로 넘긴다.
168
168
 
169
169
  ## 넘겨주기
170
170
 
@@ -32,4 +32,4 @@ git push
32
32
 
33
33
  ### 예외로 브랜치 · worktree 를 썼을 때
34
34
 
35
- 실험 · 큰 리팩터링처럼 사용자가 브랜치를 쓰라고 한 건만. 머지가 확인되면 바로 정리한다 (core 「git 기본」 의 브랜치 정리 설정과 상관없이): `git status` 로 잃을 것이 없음을, `git merge-base --is-ancestor <브랜치> origin/{{ws:vars.branch.develop}}` 로 머지됨을 보인 뒤 로컬 브랜치 · worktree 를 지운다. 원격 브랜치 삭제는 건마다 승인받는다.
35
+ 실험 · 큰 리팩터링처럼 사용자가 브랜치를 쓰라고 한 건만. 머지가 확인되면 바로 정리한다 (core 「git 기본」 의 브랜치 정리 설정과 상관없이): `git status` 로 잃을 것이 없음을, `git merge-base --is-ancestor <브랜치> origin/{{ws:vars.branch.develop}}` 로 머지됨을 보인 뒤 로컬 브랜치를 지우고, 작업 폴더는 `kedovi worktree clean --branches` 로 함께 정리한다. 원격 브랜치 삭제는 건마다 승인받는다.
@@ -82,7 +82,7 @@ argument-hint: "<source 브랜치> [target 브랜치]"
82
82
  임시파일은 세션 임시 폴더에 둔다. 4xx/5xx 면 응답을 그대로 보고하고 반복 재시도하지 않는다.
83
83
  7. **작업 브랜치를 떠난다** (source 가 작업 브랜치일 때만) — source 가 영구 · 상시 브랜치(`{{ws:vars.branch.develop}}` · `{{ws:vars.branch.release}}` · `vars.gitlab.persistentBranches`)면 이 단계를 건너뛰고 그 브랜치에 남는다 (`{{ws:vars.branch.develop}}` → `{{ws:vars.branch.release}}` MR 뒤 `{{ws:vars.branch.release}}` 로 옮겨 가지 않게).
84
84
  작업 브랜치면: 미커밋 변경이 없을 때 통합 브랜치(`{{ws:vars.branch.develop}}`, hotfix 는 target)로 `git switch` + `git pull --ff-only`. 있으면 옮기지 말고 보고한다(임의 stash 금지). 머지되면 원격 source 가 지워지므로 그 위에서 다음 작업을 시작하지 않기 위함이다.
85
- 브랜치 정리 설정(`vars.git.cleanupMerged`)이 `true` 면 머지가 확인된 뒤 core 「git 기본」 대로 그 작업 브랜치 · worktree 를 지운다.
85
+ 브랜치 정리 설정(`vars.git.cleanupMerged`)이 `true` 면 머지가 확인된 뒤 core 「git 기본」 대로 그 작업 브랜치를 지운다. 그 브랜치의 작업 폴더는 설정과 상관없이 `kedovi worktree clean` 으로 정리한다.
86
86
  8. **팀 배포 안내** — 아래 §배포 안내. MR 을 실제로 만들었을 때만 낸다.
87
87
 
88
88
  ## 배포 안내 (MR 생성 후 마지막에)