@odyssey365/cli 0.2.4 → 0.3.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/dist/watch.js CHANGED
@@ -40,6 +40,7 @@
40
40
  */
41
41
  import { UsageError } from './config.js';
42
42
  import { OdysseyClient, resolveTarget } from './session.js';
43
+ import { connectFirestore } from './firebase-connect.js';
43
44
  import { activeFollowedRooms, activeTaggedRooms, commentAuthor, commentEvent, InChunks, isLiveComment, isTaggedRoom, TAG_SOURCES, tagThreadEvent, threadEvent, todoEvent, } from './watch-events.js';
44
45
  export const WATCH_HELP = `odyssey watch [--tag 태그 ...] [--no-tag-threads] [--no-comments] [--no-threads] [--include-agent] [--since ISO]
45
46
  내 계정의 변화를 실시간으로 받아 한 줄에 JSON 하나씩(NDJSON) stdout 으로 낸다. 끄려면 Ctrl+C.
@@ -50,6 +51,8 @@ export const WATCH_HELP = `odyssey watch [--tag 태그 ...] [--no-tag-threads] [
50
51
  --no-threads 관심 스레드(에이전트가 댓글을 남긴 방 · odyssey threads follow)를 보지 않는다
51
52
  --include-agent AI(MCP·컴패니언)가 단 댓글도 낸다(기본은 사람이 쓴 것만)
52
53
  --since <ISO> 이 시각 뒤의 댓글부터(기본: 지금). 밀린 댓글을 다시 받을 때
54
+ --bridge-turns <브리지 id> 에이전트 브리지 턴(주인 bridge:<id> · running)을 {"type":"turn",…} 으로 낸다(host = 세션의
55
+ external.host — 데스크톱 듣는 세션이 desktop 턴을 넘겨받는다 · odyssey agent status 의 bridgeId)
53
56
  이벤트: {"type":"ready"} · {"type":"todo",...} · {"type":"comment",...} · {"type":"thread",...} · {"type":"error",...}
54
57
  comment 의 followed:true = 관심 스레드의 댓글 · tagged:true = 태그 항목 스레드의 댓글(둘 다 남이 쓴 것은 author "other")
55
58
  replyTo = 답글이면 원 댓글과 그 작성자 · thread 의 source "tag" = 태그 항목의 방(태그를 떼면 reason "untagged" 로 빠진다)
@@ -79,6 +82,9 @@ export function parseWatchArgs(args, now = new Date()) {
79
82
  case '--no-threads':
80
83
  o.threads = false;
81
84
  break;
85
+ case '--bridge-turns':
86
+ o.bridgeTurns = value();
87
+ break;
82
88
  case '--include-agent':
83
89
  o.includeAgent = true;
84
90
  break;
@@ -96,7 +102,7 @@ export function parseWatchArgs(args, now = new Date()) {
96
102
  }
97
103
  if (o.tags.length > 30)
98
104
  throw new UsageError('--tag 는 30개까지입니다(Firestore array-contains-any 한도).');
99
- if (!o.tags.length && !o.comments && !o.threads) {
105
+ if (!o.tags.length && !o.comments && !o.threads && !o.bridgeTurns) {
100
106
  throw new UsageError('볼 것이 없습니다 — --tag 를 주거나 --no-comments·--no-threads 를 빼세요.');
101
107
  }
102
108
  return o;
@@ -108,32 +114,7 @@ export async function cmdWatch(g, args, version) {
108
114
  const opts = parseWatchArgs(args);
109
115
  const target = resolveTarget(g);
110
116
  const client = new OdysseyClient(target, version);
111
- let session = await client.firebaseSession();
112
- let sessionAt = Date.now();
113
- const { initializeApp } = await import('firebase/app');
114
- const { initializeAppCheck, CustomProvider } = await import('firebase/app-check');
115
- const { getAuth, signInWithCustomToken } = await import('firebase/auth');
116
- const fs = await import('firebase/firestore');
117
- const app = initializeApp(session.firebase, `odyssey-cli-${target.profileName ?? 'env'}`);
118
- initializeAppCheck(app, {
119
- provider: new CustomProvider({
120
- // SDK 는 토큰이 다 됐을 때만 다시 부른다. 처음 한 번은 교환에서 받은 것을 쓰고, 그 뒤는 다시 교환한다.
121
- getToken: async () => {
122
- if (Date.now() - sessionAt > 60_000) {
123
- session = await client.firebaseSession();
124
- sessionAt = Date.now();
125
- }
126
- return { token: session.appCheck.token, expireTimeMillis: sessionAt + session.appCheck.ttlMillis };
127
- },
128
- }),
129
- isTokenAutoRefreshEnabled: false,
130
- });
131
- const signedIn = await signInWithCustomToken(getAuth(app), session.customToken);
132
- if (signedIn.user.uid !== session.firebaseUid) {
133
- throw new UsageError('Firebase 신원이 CLI 전용 세션과 일치하지 않습니다. 서버의 감시 보안 업데이트가 필요합니다.');
134
- }
135
- const db = fs.getFirestore(app);
136
- const uid = session.uid;
117
+ const { fs, db, uid } = await connectFirestore(client, `odyssey-cli-${target.profileName ?? 'env'}`);
137
118
  const unsubs = [];
138
119
  const streams = [];
139
120
  const pending = new Set();
@@ -420,6 +401,63 @@ export async function cmdWatch(g, args, version) {
420
401
  }));
421
402
  }
422
403
  }
404
+ if (opts.bridgeTurns) {
405
+ // 에이전트 브리지 턴(설계 §6.3) — 주인이 이 브리지인 running 턴. 세션 host 를 함께 실어 듣기가 desktop 만 고른다.
406
+ // 세션 문서를 못 읽는 서버 규칙이면 host 는 null(듣기가 bridge 데몬 몫으로 본다).
407
+ streams.push('turns');
408
+ pending.add('turns');
409
+ let first = true;
410
+ const hosts = new Map();
411
+ const hostOf = async (sessionUid) => {
412
+ try {
413
+ const snap = await fs.getDoc(fs.doc(db, 'user', uid, 'companion_session', sessionUid));
414
+ const ext = snap.data()?.external ?? {};
415
+ const host = typeof ext.host === 'string' ? ext.host : null;
416
+ hosts.set(sessionUid, host);
417
+ return {
418
+ host,
419
+ workspaceName: typeof ext.workspaceName === 'string' ? ext.workspaceName : null,
420
+ externalSessionId: typeof ext.externalSessionId === 'string' ? ext.externalSessionId : null,
421
+ };
422
+ }
423
+ catch {
424
+ return { host: hosts.get(sessionUid) ?? null, workspaceName: null, externalSessionId: null };
425
+ }
426
+ };
427
+ const seenTurns = new Set();
428
+ const q = fs.query(fs.collection(db, 'user', uid, 'companion_turn'), fs.where('leaseOwner', '==', `bridge:${opts.bridgeTurns}`), fs.where('status', '==', 'running'));
429
+ unsubs.push(fs.onSnapshot(q, async (snap) => {
430
+ const initial = first;
431
+ first = false;
432
+ for (const ch of snap.docChanges()) {
433
+ if (ch.type !== 'added' || seenTurns.has(ch.doc.id))
434
+ continue;
435
+ seenTurns.add(ch.doc.id);
436
+ const d = ch.doc.data();
437
+ const sessionUid = String(d.sessionUid ?? '');
438
+ const meta = await hostOf(sessionUid);
439
+ const createdAt = d.createdAt;
440
+ emit({
441
+ type: 'turn',
442
+ turnUid: ch.doc.id,
443
+ sessionUid,
444
+ bridgeId: opts.bridgeTurns,
445
+ host: meta.host,
446
+ workspaceName: meta.workspaceName,
447
+ externalSessionId: meta.externalSessionId,
448
+ text: typeof d.text === 'string' ? d.text : '',
449
+ approval: d.approval ?? null,
450
+ imageStoragePaths: Array.isArray(d.imageStoragePaths) ? d.imageStoragePaths : [],
451
+ createdAt: typeof createdAt === 'string' ? createdAt : createdAt?.toDate?.().toISOString() ?? null,
452
+ initial,
453
+ });
454
+ }
455
+ if (initial) {
456
+ pending.delete('turns');
457
+ ready();
458
+ }
459
+ }, (e) => emit({ type: 'error', stream: 'turns', code: e.code ?? null, message: e.message })));
460
+ }
423
461
  if (opts.comments) {
424
462
  streams.push('comments');
425
463
  pending.add('comments');
@@ -68,6 +68,7 @@ node ../odyssey-listen/listen.mjs --dry-run # 밀린 태그 할일 중 무엇
68
68
  | `mention` | 아무 항목에 단 **내** 댓글의 `@클로드코드`(공백·대소문자 무시) — 그 항목은 맡은 스레드가 된다 |
69
69
  | `tagged` | 태그가 걸린 할일·메모·프로젝트·리포트 스레드의 내 댓글 |
70
70
  | `reply` | 맡은 스레드의 내 댓글(멘션 없어도) |
71
+ | `turn` | 앱 컴패니언 대화에서 이 컴퓨터의 **데스크톱** 에이전트 세션에 보낸 말(`bridgeId` 를 넣었을 때만 — 아래) |
71
72
 
72
73
  AI 댓글(세션 자신의 답글)·다른 사람 댓글·할일 수정은 깨우지 않습니다 — 메아리와 남의 지시를 막습니다.
73
74
  상태 줄: `ended`(2) · `error`(3) · `busy`(4, 다른 듣기가 돎 — 이어받으려면 `--replace`) · `stopped`(5).
@@ -81,7 +82,12 @@ AI 댓글(세션 자신의 답글)·다른 사람 댓글·할일 수정은 깨
81
82
  | `odysseyProfile` | init 때 프로필 | `odyssey login` 프로필 |
82
83
  | `expectedUid` | 빈 값 | `--check`의 uid — 넣으면 다른 계정이면 오류로 끝난다 |
83
84
  | `followedThreads` | `false` | 관심 스레드(남의 답까지)도 들을지 — 지시는 내 댓글뿐이라 보통 끈다 |
84
- | `statePath` | `./state/listen.json` | 상태(since·seen·tagged·threads). 세션을 비우거나 바꿔도 이어 듣는다 |
85
+ | `bridgeId` | 빈 값 | 에이전트 브리지(`odyssey agent status` 의 bridgeId). 넣으면 데스크톱 세션 턴(`turn`)도 깨운다 — 데몬은 그 턴을 실행하지 않는다(`odyssey agent setup --desktop-relay`) |
86
+ | `statePath` | `./state/listen.json` | 상태(since·seen·tagged·threads·turns). 세션을 비우거나 바꿔도 이어 듣는다 |
87
+
88
+ `turn` 을 받은 세션은 그 대화의 데스크톱 세션(`externalSessionId` — 없으면 새로)에 `text` 를 넘긴다(`send_message` · `start_session`).
89
+ 훅 미러링이 그 글을 알아보고 그 세션의 답을 앱 대화의 답으로 쓰고 턴을 닫는다. 넘기지 못하면
90
+ `odyssey agent_turn_update --turnUid <턴> --settle failed --error noDesktopListener` 로 닫는다.
85
91
 
86
92
  ## 끄기·비우기
87
93
 
@@ -5,6 +5,7 @@
5
5
  "watchTag": "클로드 코드",
6
6
  "mentions": ["@클로드코드"],
7
7
  "followedThreads": false,
8
+ "bridgeId": "",
8
9
  "readyTimeoutMs": 120000,
9
10
  "statePath": "./state/listen.json"
10
11
  }
@@ -36,6 +36,9 @@ export const DEFAULT_CONFIG = Object.freeze({
36
36
  expectedUid: '',
37
37
  // 관심 스레드(남의 답까지 오는 방)도 들을지 — 지시는 내 댓글뿐이라 기본은 끈다(--no-threads)
38
38
  followedThreads: false,
39
+ // 에이전트 브리지(odyssey agent) 의 브리지 id — 넣으면 앱이 데스크톱 세션(host desktop)에 보낸 턴도 깨운다(listen: turn).
40
+ // 이 컴퓨터의 데몬은 그 턴을 실행하지 않고 이 세션에 맡긴다 — `odyssey agent setup --desktop-relay` · `odyssey agent status` 의 bridgeId
41
+ bridgeId: '',
39
42
  // 감시가 첫 스냅샷(ready)까지 이 안에 못 오면 오류(3)로 끝낸다 — 세션이 한 번 다시 띄운다
40
43
  readyTimeoutMs: 120_000,
41
44
  statePath: path.join(HERE, 'state', 'listen.json'),
@@ -72,6 +75,7 @@ export function validateConfig(cfg) {
72
75
  if (!cfg.mentions.some((m) => normalizeMention(m))) throw new Error('설정 mentions 가 비었어요');
73
76
  if (typeof cfg.expectedUid !== 'string') throw new Error('설정 expectedUid 는 문자열이어야 해요');
74
77
  if (typeof cfg.followedThreads !== 'boolean') throw new Error('설정 followedThreads 는 true/false 여야 해요');
78
+ if (typeof cfg.bridgeId !== 'string') throw new Error('설정 bridgeId 는 문자열이어야 해요');
75
79
  if (!(Number.isFinite(cfg.readyTimeoutMs) && cfg.readyTimeoutMs > 0)) throw new Error('설정 readyTimeoutMs 는 유한한 양수여야 해요');
76
80
  }
77
81
 
@@ -79,8 +83,9 @@ export function validateConfig(cfg) {
79
83
 
80
84
  const SEEN_KEEP = 500; // 기억하는 댓글 uid 수(파일이 끝없이 커지지 않게)
81
85
  const TAGGED_KEEP = 2000;
86
+ const TURNS_KEEP = 500;
82
87
 
83
- /** 세션이 답글을 달 수 있는 항목 종류 — comment_on_item 의 itemType + 보드 전체(comment_on_project). */
88
+ /** 세션이 답글을 달 수 있는 항목 종류 — comment_on_item 의 itemType(보드 전체 project 포함 — 옛 comment_on_project). */
84
89
  export const COMMENT_ITEM_TYPES = Object.freeze([
85
90
  'todo', 'memo', 'asset', 'event', 'routine', 'routineInstance', 'locationMap', 'record', 'companionReport', 'projectComponent', 'project',
86
91
  ]);
@@ -98,7 +103,7 @@ export function hasMention(text, mentions) {
98
103
  }
99
104
 
100
105
  export function emptyState(now = nowIso()) {
101
- return { since: now, seen: [], tagged: [], threads: {} };
106
+ return { since: now, seen: [], tagged: [], threads: {}, turns: [] };
102
107
  }
103
108
 
104
109
  export function normalizeState(raw, now = nowIso()) {
@@ -108,6 +113,7 @@ export function normalizeState(raw, now = nowIso()) {
108
113
  if (Array.isArray(raw.seen)) s.seen = raw.seen.filter((x) => typeof x === 'string');
109
114
  if (Array.isArray(raw.tagged)) s.tagged = raw.tagged.filter((x) => typeof x === 'string');
110
115
  if (raw.threads && typeof raw.threads === 'object') s.threads = { ...raw.threads };
116
+ if (Array.isArray(raw.turns)) s.turns = raw.turns.filter((x) => typeof x === 'string');
111
117
  }
112
118
  return s;
113
119
  }
@@ -118,9 +124,23 @@ export function normalizeState(raw, now = nowIso()) {
118
124
  * mention 아무 항목에 단 내 댓글의 멘션. 그 항목은 맡은 스레드(threads)에 오른다
119
125
  * tagged 태그 항목 스레드의 내 댓글 — 멘션 없어도 대화창이다
120
126
  * reply 맡은 스레드의 내 댓글
127
+ * turn 앱이 이 컴퓨터의 **데스크톱** 에이전트 세션에 보낸 말(브리지 턴 · host desktop) — bridgeId 를 넣었을 때만
121
128
  * 깨우지 않는 것: 에이전트 댓글(세션 자신의 답글 — 메아리) · 남의 댓글(author "other" — 지시가 아니다) · 할일 수정(세션이 바꾼 상태의 메아리).
122
129
  */
123
130
  export function classify(evt, state, cfg) {
131
+ if (evt?.type === 'turn') {
132
+ // 데스크톱 갈래(설계 §6.3) — cli 턴은 브리지 데몬이 직접 돌린다. host 를 모르면(세션 문서를 못 읽음) 데몬 몫으로 둔다.
133
+ if (!cfg.bridgeId || evt.bridgeId !== cfg.bridgeId || evt.host !== 'desktop') return null;
134
+ if (!evt.turnUid || state.turns.includes(evt.turnUid)) return null;
135
+ state.turns = [...state.turns, evt.turnUid].slice(-TURNS_KEEP);
136
+ return {
137
+ listen: 'turn', turnUid: evt.turnUid, sessionUid: evt.sessionUid ?? null, bridgeId: evt.bridgeId,
138
+ externalSessionId: evt.externalSessionId ?? null, workspaceName: evt.workspaceName ?? null,
139
+ text: typeof evt.text === 'string' ? evt.text.slice(0, 4000) : '', approval: evt.approval ?? null,
140
+ imageStoragePaths: Array.isArray(evt.imageStoragePaths) ? evt.imageStoragePaths : [],
141
+ createdAt: evt.createdAt ?? null, initial: Boolean(evt.initial),
142
+ };
143
+ }
124
144
  if (evt?.type === 'todo') {
125
145
  if (evt.change !== 'added' || evt.status !== 'notStarted') return null;
126
146
  if (!evt.uid || state.tagged.includes(evt.uid)) return null;
@@ -230,7 +250,8 @@ export function commandOf(bin, args) {
230
250
  }
231
251
 
232
252
  export function buildWatchArgs(cfg, since) {
233
- return ['-p', cfg.odysseyProfile, 'watch', '--tag', cfg.watchTag, ...(cfg.followedThreads ? [] : ['--no-threads']), '--since', since];
253
+ return ['-p', cfg.odysseyProfile, 'watch', '--tag', cfg.watchTag, ...(cfg.followedThreads ? [] : ['--no-threads']),
254
+ ...(cfg.bridgeId ? ['--bridge-turns', cfg.bridgeId] : []), '--since', since];
234
255
  }
235
256
 
236
257
  /** 감시를 띄우지 않고 CLI 로그인·계정만 확인한다. */
@@ -173,3 +173,18 @@ test('설정 — 모르는 키는 거절, 상대 경로는 설정 파일 기준'
173
173
  writeFileSync(config, JSON.stringify({ workDir: '.' }));
174
174
  assert.throws(() => loadConfig(config), /모르는 키/);
175
175
  });
176
+
177
+ test('브리지 턴(turn) — bridgeId 를 넣었을 때 데스크톱 턴만 한 번 깨운다', () => {
178
+ const s = emptyState('2026-11-22T00:00:00.000Z');
179
+ const turn = { type: 'turn', turnUid: 'T1', sessionUid: 'S', bridgeId: 'br_1', host: 'desktop', text: '화면 봐 줘', initial: true };
180
+ assert.equal(classify(turn, s, cfg), null); // bridgeId 없으면 듣지 않는다
181
+ const c = { ...cfg, bridgeId: 'br_1' };
182
+ assert.equal(classify({ ...turn, host: 'cli' }, s, c), null); // cli 턴은 데몬 몫
183
+ assert.equal(classify({ ...turn, host: null }, s, c), null);
184
+ assert.equal(classify({ ...turn, bridgeId: 'br_2' }, s, c), null);
185
+ const o = classify(turn, s, c);
186
+ assert.equal(o.listen, 'turn');
187
+ assert.equal(o.text, '화면 봐 줘');
188
+ assert.equal(classify(turn, s, c), null); // 두 번 내지 않는다
189
+ assert.deepEqual(buildWatchArgs(c, 'S').slice(-4), ['--bridge-turns', 'br_1', '--since', 'S']);
190
+ });
@@ -54,7 +54,7 @@
54
54
  - `odyssey -p <프로필> watch --tag "<감시 태그>" --since <상태 파일의 커서>` 를 자식 프로세스로 띄우고 **stdout 을 줄 단위로** JSON 파싱한다. stderr 는 로그로만.
55
55
  에이전트 댓글(일꾼 답글의 메아리)은 기본으로 오지 않는다. 내 댓글이 일꾼 댓글에 단 「답글」인지는 감시가 `replyTo.author` 로 알려 준다
56
56
  (예전엔 `--include-agent` 로 에이전트 댓글 uid 를 적어 두고 대조했다 — CLI 0.2.2+ 에선 필요 없다).
57
- - **관심 스레드**: 일꾼이 `comment_on_item`·`comment_on_project` 로 답글을 단 스레드(받았다 표시 포함)는 서버가 자동으로 관심 스레드에 올리고,
57
+ - **관심 스레드**: 일꾼이 `comment_on_item`(보드 전체 포함 — 디스패처의 받았다 표시도 `itemType project`) 으로 답글을 단 스레드(받았다 표시 포함)는 서버가 자동으로 관심 스레드에 올리고,
58
58
  감시는 그 방의 새 댓글을 누가 썼든 `followed:true` 로 낸다. 마지막 에이전트 활동 뒤 기간(기본 14일 · `follow_thread` 의 `days` 로 1~365일,
59
59
  뒤의 자동 등록도 그 기간으로 다시 센다) 조용하면 빠진다. 일꾼은 일이 끝나 더 받을 필요가
60
60
  없으면 `follow_thread(follow:false)` 로 뺄 수 있다(할일 완료만으로는 빼지 않는다).
@@ -84,7 +84,7 @@
84
84
 
85
85
  **멘션** = 댓글 본문에서 공백을 지우고 소문자로 바꾼 글에 설정의 멘션(같은 방식으로 바꾼 것)이 들어 있다. `@클로드 코드`·`@클로드코드님` 도 걸린다.
86
86
 
87
- **댓글 도구가 받는 종류** = `comment_on_item` 의 itemType(todo · memo · asset · event · routine · routineInstance · locationMap · record · companionReport · projectComponent) + 보드 전체 `project`(`comment_on_project`).
87
+ **댓글 도구가 받는 종류** = `comment_on_item` 의 itemType(todo · memo · asset · event · routine · routineInstance · locationMap · record · companionReport · projectComponent) + 보드 전체 `project`(일꾼은 `comment_on_item(itemType "project")`, 디스패처 CLI 는 옛 이름 `comment_on_project` — 서버가 같은 도구로 옮긴다).
88
88
  페이지·컬렉션 같은 그 밖의 종류는 일꾼이 답글을 달 수 없으니 받지 않는다.
89
89
 
90
90
  | 이벤트 | 조건 | 배달 |
@@ -165,7 +165,8 @@
165
165
  ### 6. 디스패처가 쓰는 것 — 받았다 표시와 실패 알림뿐
166
166
 
167
167
  - **답글 자리**(받았다 표시·실패 알림 공통) — 항목 종류로 고른다:
168
- - 보드 전체(`project`): `comment_on_project --projectId <uid>` — 이 도구엔 `notifyMe` 가 없다. `--notify false` 로 단다(알림 없이 스레드에만).
168
+ - 보드 전체(`project`): `comment_on_item --itemType project --itemUid <uid>` — 보드 전체 스레드엔 `notifyMe` 가 없다. `--notify false` 로 단다(알림 없이 스레드에만).
169
+ 옛 이름이다(지금 이름은 `comment_on_item --itemType project --itemUid <uid>`) — 서버가 옛 이름도 받아 옛 서버 · 새 서버 어디서나 돈다.
169
170
  - 보드 카드(`projectComponent`): `comment_on_item --itemType projectComponent --itemUid <카드 id> --projectId <보드 uid>`
170
171
  - 그 밖: `comment_on_item --itemType <종류> --itemUid <uid>`
171
172
  - **받았다 표시**(멘션으로 배달할 때만, 설정이 비어 있지 않으면): 큐에 넣는 그 자리에서 바로 단다 — `--notify false`(알림 없음).
@@ -205,8 +206,8 @@ Odyssey 는 MCP 도구(mcp__{Odyssey 손}__*)로 읽고 쓴다. 너는 디스패
205
206
  **7-2. 멘션으로 맡은 항목**(`origin:"mention"`)
206
207
 
207
208
  `{스레드 인자}` = 2절 항목(보드 카드면 `itemType "projectComponent", itemUid {카드 id}, projectId {보드 uid}`, 보드 전체면 `itemType "project"`) ·
208
- `{답글 도구}` = 6절 답글 자리 · `{읽기 도구}` = 종류에 맞는 것(할일 get_todo · 메모 get_memo · 일정 get_event · 기록 get_record · 루틴 get_routine ·
209
- 에셋 get_asset · 리포트 get_report · 보드 get_project · 카드 get_project_components · 그 밖은 스레드만) · `{질문 알림}` = `notifyMe true`(보드 전체는 `notify false` — 나만 알림이 없다).
209
+ `{답글 도구}` = 6절 답글 자리(일꾼에겐 지금 이름 — 보드 전체도 `comment_on_item(itemType "project", itemUid {보드 uid}, …)`) · `{읽기 도구}` = 종류에 맞는 것(할일 get_todo · 메모 get_memo · 일정 get_event ·
210
+ 기록 fetch("record:<uid>") · 루틴 fetch("routine:<uid>") · 에셋 fetch("asset:<uid>") · 리포트 get_report · 보드 get_project · 카드 get_project_components · 그 밖은 스레드만) · `{질문 알림}` = `notifyMe true`(보드 전체는 `notify false` — 나만 알림이 없다).
210
211
 
211
212
  ```
212
213
  너는 Odyssey {항목}의 댓글 스레드에서 「{멘션}」으로 불려 온 일꾼이다. 작업 폴더({작업 폴더}) 밖은 건드리지 않는다.
@@ -119,7 +119,7 @@ export const PHASES = ['running', 'idle', 'done', 'blocked', 'cancelled'];
119
119
  const DELIVERED_KEEP = 1000; // 항목당 기억하는 배달 댓글 수(파일이 끝없이 커지지 않게)
120
120
  const AGENT_KEEP = 300; // 항목당 기억하는 에이전트 댓글 uid 수 — 옛 감시(--include-agent)용. 이제 답글 대상은 감시가 replyTo 로 알려 준다
121
121
 
122
- /** 일꾼이 답글을 달 수 있는 항목 종류 — comment_on_item 의 itemType + 보드 전체(comment_on_project). */
122
+ /** 일꾼이 답글을 달 수 있는 항목 종류 — comment_on_item 의 itemType(보드 전체 project 포함 — 옛 comment_on_project). */
123
123
  export const COMMENT_ITEM_TYPES = Object.freeze([
124
124
  'todo', 'memo', 'asset', 'event', 'routine', 'routineInstance', 'locationMap', 'record', 'companionReport', 'projectComponent', 'project',
125
125
  ]);
@@ -320,9 +320,10 @@ function tagWorkerRules(cfg, { title, todoUid, ref, myUid }) {
320
320
  ].join('\n');
321
321
  }
322
322
 
323
+ // 루틴 · 기록 · 에셋 상세는 fetch("타입:uid") — get_routine · get_record · get_asset 은 MCP 목록에서 숨었다(부르면 돌지만 일꾼의 도구 목록엔 없다).
323
324
  const READ_TOOL = {
324
- todo: 'get_todo', memo: 'get_memo', event: 'get_event', record: 'get_record', routine: 'get_routine',
325
- asset: 'get_asset', companionReport: 'get_report', project: 'get_project', projectComponent: 'get_project_components',
325
+ todo: 'get_todo', memo: 'get_memo', event: 'get_event', record: 'fetch("record:<uid>")', routine: 'fetch("routine:<uid>")',
326
+ asset: 'fetch("asset:<uid>")', companionReport: 'get_report', project: 'get_project', projectComponent: 'get_project_components',
326
327
  };
327
328
 
328
329
  /** list_item_comments·comment_on_item 에 넘길 대상 인자(사람이 읽는 글로). */
@@ -338,7 +339,8 @@ function mentionWorkerRules(cfg, { ref }) {
338
339
  const read = READ_TOOL[r.itemType];
339
340
  const board = r.itemType === 'project';
340
341
  const who = `authorName "${cfg.authorName}", authorEmoji "${cfg.authorEmoji}", notify false`;
341
- const reply = board ? `comment_on_project(projectId "${r.itemUid}", ${who})` : `comment_on_item(${threadArgsText(r)}, ${who})`;
342
+ // 보드 전체도 comment_on_item(itemType "project") — 옛 comment_on_project 는 MCP 목록에서 빠졌다(서버가 옛 이름도 받는다).
343
+ const reply = board ? `comment_on_item(itemType "project", itemUid "${r.itemUid}", ${who})` : `comment_on_item(${threadArgsText(r)}, ${who})`;
342
344
  const ask = board ? 'notify false 그대로 — 보드 전체 댓글엔 나만 알림이 없다' : 'notifyMe true — 나한테만 알림';
343
345
  const mention = cfg.mentions[0];
344
346
  return [
@@ -398,10 +400,14 @@ export function ackContent(cfg, busy) {
398
400
  return busy ? `${base.replace(/[.。\s]+$/u, '')} — 앞의 일을 마치면 이어서 볼게요.` : base;
399
401
  }
400
402
 
401
- /** 6절 답글 자리 — 보드 전체는 comment_on_project(나만 알림 없음), 카드는 보드(projectId)까지, 그 밖은 comment_on_item. */
403
+ /**
404
+ * 6절 답글 자리 — 보드 전체는 comment_on_item(itemType "project" · 나만 알림 없음), 카드는 보드(projectId)까지, 그 밖도 comment_on_item.
405
+ * 디스패처가 CLI 로 직접 다는 댓글(받았다 표시 · 실패 알림)도 지금 이름을 쓴다 — CLI 는 목록에 없는 옛 이름(comment_on_project)을
406
+ * 서버에 보내기 전에 막는다(261110 MCP 100개 판 배포 뒤).
407
+ */
402
408
  export function replyTarget(ref) {
403
409
  const r = asRef(ref);
404
- if (r.itemType === 'project') return { tool: 'comment_on_project', params: { projectId: r.itemUid }, canNotifyMe: false };
410
+ if (r.itemType === 'project') return { tool: 'comment_on_item', params: { itemType: 'project', itemUid: r.itemUid }, canNotifyMe: false };
405
411
  if (r.itemType === 'projectComponent') {
406
412
  return { tool: 'comment_on_item', params: { itemType: 'projectComponent', itemUid: r.itemUid, projectId: r.projectId }, canNotifyMe: true };
407
413
  }
@@ -578,7 +584,7 @@ export function createWorkerRunner(cfg, log) {
578
584
  };
579
585
  }
580
586
 
581
- /** 실제 댓글(받았다 표시·실패 알림) — odyssey comment_on_item / comment_on_project. */
587
+ /** 실제 댓글(받았다 표시·실패 알림) — odyssey comment_on_item(보드 전체는 itemType project). */
582
588
  export function createCommentPoster(cfg, log) {
583
589
  return async ({ ref, todoUid, content, notifyMe = true }) => {
584
590
  const args = buildCommentArgs(cfg, ref ?? todoUid, content, { notifyMe });
@@ -680,14 +680,16 @@ test('보드 카드 멘션 — 키와 답글 자리에 보드(projectId)까지
680
680
  assert.deepEqual(h.comments[0].ref, { itemType: 'projectComponent', itemUid: 'K1', projectId: 'B1' });
681
681
  });
682
682
 
683
- test('보드 전체 멘션 — comment_on_project · 나만 알림이 없어 notify false 로만', async () => {
683
+ test('보드 전체 멘션 — comment_on_item(itemType project) · 나만 알림이 없어 notify false 로만', async () => {
684
684
  const h = harness();
685
685
  await h.send(ready(), comment('C1', 'B1', { itemType: 'project', text: MENTION_TEXT }));
686
- assert.match(h.calls[0].systemPrompt, /comment_on_project\(projectId "B1", authorName "Claude", authorEmoji "✨", notify false\)/);
686
+ // 일꾼(MCP)에겐 지금 이름 — 옛 comment_on_project 는 MCP 목록에 없다. 디스패처 자신의 CLI 호출(받았다 표시)도 지금 이름(CLI 가 옛 이름을 막는다).
687
+ assert.match(h.calls[0].systemPrompt, /comment_on_item\(itemType "project", itemUid "B1", authorName "Claude", authorEmoji "✨", notify false\)/);
688
+ assert.doesNotMatch(h.calls[0].systemPrompt, /comment_on_project/);
687
689
  assert.match(h.calls[0].systemPrompt, /보드 전체 댓글엔 나만 알림이 없다/);
688
690
  const ack = buildCommentArgs(DEFAULT_CONFIG, { itemType: 'project', itemUid: 'B1' }, '👀 받았어요.', { notifyMe: true });
689
- assert.deepEqual(ack.slice(0, 4), ['-p', 'default', 'comment_on_project', '--json']);
690
- assert.deepEqual(JSON.parse(ack[4]), { projectId: 'B1', content: '👀 받았어요.', authorName: 'Claude', authorEmoji: '✨', notify: false });
691
+ assert.deepEqual(ack.slice(0, 4), ['-p', 'default', 'comment_on_item', '--json']);
692
+ assert.deepEqual(JSON.parse(ack[4]), { itemType: 'project', itemUid: 'B1', content: '👀 받았어요.', authorName: 'Claude', authorEmoji: '✨', notify: false });
691
693
  });
692
694
 
693
695
  test('받지 않는 종류(스냅샷 등)의 멘션 · 멘션 없는 남의 항목 댓글 → 무시', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odyssey365/cli",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Odyssey365 / Odyssey60 / Odyssey30 CLI — 터미널·AI 에이전트에서 할일·메모·루틴·기록·보드·페이지를 다룬다 (OdysseyCLI)",
5
5
  "type": "module",
6
6
  "engines": {
@@ -57,5 +57,8 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "firebase": "^12.19.0"
60
+ },
61
+ "optionalDependencies": {
62
+ "@anthropic-ai/claude-agent-sdk": "^0.3.330"
60
63
  }
61
64
  }
@@ -66,7 +66,7 @@
66
66
  | 갈래 | 오는 댓글 | 어떻게 붙나 | 언제 빠지나 |
67
67
  |---|---|---|---|
68
68
  | **내 댓글** | 모든 스레드의 내 계정 댓글 | 늘 온다(등록 불필요) | 빠지지 않는다(`--no-comments` 로만 끔) |
69
- | **관심 스레드** (`followed:true`) | 그 방의 **남의** 댓글까지(공유 보드 멤버 · 앱 「답글」) | 자동 — 에이전트가 `comment_on_item`·`comment_on_project` 로 댓글을 남기면(`source:"auto"`) · 수동 — `odyssey threads follow`(`source:"manual"`) | 마지막 **에이전트 활동**(댓글·follow) 뒤 `ttlDays`(기본 14일, 1~365) 조용하면. 사람 댓글로는 늘지 않는다 · `odyssey threads unfollow` |
69
+ | **관심 스레드** (`followed:true`) | 그 방의 **남의** 댓글까지(공유 보드 멤버 · 앱 「답글」) | 자동 — 에이전트가 `comment_on_item`(보드 전체는 `itemType "project"`) 로 댓글을 남기면(`source:"auto"`) · 수동 — `odyssey threads follow`(`source:"manual"`) | 마지막 **에이전트 활동**(댓글·follow) 뒤 `ttlDays`(기본 14일, 1~365) 조용하면. 사람 댓글로는 늘지 않는다 · `odyssey threads unfollow` |
70
70
  | **태그 항목 스레드** (`tagged:true`) | `--tag` 가 걸린 내 할일·메모·프로젝트(+그 보드의 카드)·리포트의 방 | 태그가 곧 등록 | 태그를 떼면 바로(`reason:"untagged"`) — 만료 없음 |
71
71
 
72
72
  감시에서 갈래째 끄기: `--no-comments`(내 댓글) · `--no-threads`(관심 스레드) · `--no-tag-threads`(태그 항목 스레드).
@@ -139,7 +139,7 @@ odyssey threads unfollow --roomUid <방> # 또는 --it
139
139
 
140
140
  ### D. 활동 기록기 — 모델이 아예 없는 일
141
141
 
142
- - **입구**: 게임·앱 프로세스의 시작·끝. **일**: `create_record` 한 번 → 세션마다 `add_record_trace`(time·endTime·`dedupeKey`).
142
+ - **입구**: 게임·앱 프로세스의 시작·끝. **일**: `save_record`(기록 만들기) 한 번 → 세션마다 `add_record_trace`(time·endTime·`dedupeKey`).
143
143
  - **멱등**: `dedupeKey` = 같은 키는 한 번만. 종료 코드 `4`(네트워크)만 같은 키로 재전송, `1`(도구 오류)은 고치기 전엔 다시 보내지 않는다.
144
144
  - 자세한 호출법(Windows·Python): README 「프로그램에서 쓰기」.
145
145
 
@@ -102,7 +102,7 @@
102
102
  - **mention** — 오래 걸릴 일이면 받았다 표시부터 단다 → `list_item_comments` 로 스레드를, 필요하면 종류에 맞는 읽기 도구(`get_memo`·`get_event`·`get_project` …)로 항목을 읽는다 → 요청한 일 → 결과 답글.
103
103
  작업 기록용 할일을 새로 만들지 않는다 — 그 스레드가 기록이다(내가 할일을 만들어 달라고 하면 그건 일이니 만든다).
104
104
  - **tagged · reply** — 스레드를 읽고 이어 처리한다. 깨운 댓글이 너에게 한 말이 아니면(같은 보드 사람에게 단 답 · 혼잣말 메모) **답글 없이** 넘긴다.
105
- 4. **답글 자리**: `comment_on_item(itemType, itemUid, authorName, authorEmoji, notify false)` · 보드 카드는 `itemType "projectComponent"` + `projectId`(보드 uid = `parentItemUid`) · 보드 전체는 `comment_on_project`.
105
+ 4. **답글 자리**: `comment_on_item(itemType, itemUid, authorName, authorEmoji, notify false)` · 보드 카드는 `itemType "projectComponent"` + `projectId`(보드 uid = `parentItemUid`) · 보드 전체는 `itemType "project"` + `itemUid`(보드 uid — `notifyMe` 없이).
106
106
  - 판단이 필요하거나 막히면 추측하지 말고 질문을 답글로 남기고 `notifyMe true`(나한테만 알림 · 보드 전체는 `notify false`) — 끝에 "답글로 답해 주시면 이어서 할게요." 를 붙인다. 내 답이 이 세션을 다시 깨운다.
107
107
  - 끝났으면 결과 답글은 알림 없이. `notify true` 는 공유 보드 참여자 전원에게 간다 — 쓰지 않는다.
108
108
  - 권한에 막혔으면 무엇이 막혔는지 답글로 말한다.
@@ -110,7 +110,7 @@
110
110
  6. **큰 일은 하위 에이전트로** — 코딩이 길면 서브에이전트에 맡겨 이 세션의 맥락을 지킨다. 깨어난 턴은 사람이 없는 자동 턴이다 — 사람의 승인이 필요한 일(배포·게시·삭제)은 하지 말고 답글로 묻는다.
111
111
  7. 끝나면 **같은 명령으로 다시 띄운다**(백그라운드 종료). Monitor 는 걸어 둔 채 다음 줄을 기다린다.
112
112
 
113
- 관심 스레드: 네가 `comment_on_item`·`comment_on_project` 로 답글을 단 스레드는 서버가 자동으로 관심 스레드에 올린다(기본 14일). 이 듣기는 기본으로 그 방을 듣지 않으니 손댈 것 없다 —
113
+ 관심 스레드: 네가 `comment_on_item` 으로 답글을 단 스레드(보드 전체 포함)는 서버가 자동으로 관심 스레드에 올린다(기본 14일). 이 듣기는 기본으로 그 방을 듣지 않으니 손댈 것 없다 —
114
114
  남의 답까지 받아야 하는 설계일 때만 켠다(`odyssey agent-guide --design` 2절).
115
115
 
116
116
  ---