jitda-agent 0.1.0 → 0.1.2

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitda",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "짓다 해커톤 대회 작업 폴더(.jitda)에서 나눈 에이전트 대화 기록을 짓다로 보냅니다.",
5
5
  "author": {
6
6
  "name": "team-monolith"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitda",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "짓다 해커톤 대회 작업 폴더(.jitda)에서 나눈 에이전트 대화 기록을 짓다로 보냅니다.",
5
5
  "author": {
6
6
  "name": "team-monolith"
package/README.md CHANGED
@@ -8,9 +8,9 @@
8
8
  |---|---|
9
9
  | MCP | 참가자 PC에서 도는 로컬 MCP 서버입니다. 로그인 토큰을 보관하고 로그를 짓다로 보냅니다. |
10
10
  | 스킬 | 로그인 안내와 상태 확인 방법을 알려 줍니다. |
11
- | 훅 (`hooks.json`) | 이벤트마다 `mcp_tool` 훅으로 로컬 MCP에 로그를 넘깁니다. |
11
+ | 훅 (`hooks/claude.json`, `hooks/codex.json`) | 이벤트마다 `mcp_tool` 훅으로 로컬 MCP에 로그를 넘깁니다. |
12
12
 
13
- > 상태: **설계 단계**. 코드는 아직 없습니다.
13
+ > 상태: 개발 서버에서 동작 확인. 운영 배포 전입니다. 테스트 방법은 [docs/DEV_TESTING.md](docs/DEV_TESTING.md), 흐름은 [docs/FLOWS.md](docs/FLOWS.md)를 보세요.
14
14
  > - 지금 단계 계획: [docs/PLAN.md](docs/PLAN.md) (로컬 MCP + 로그 전송)
15
15
  > - 다음 단계 계획: [docs/PLAN_NEXT.md](docs/PLAN_NEXT.md) (팀 pod에 연결해 파일·실행·미리보기까지)
16
16
 
package/dist/install.mjs CHANGED
@@ -1,8 +1,540 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __jitdaCreateRequire } from "node:module"; const require = __jitdaCreateRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
+ }) : x)(function(x) {
12
+ if (typeof require !== "undefined") return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ try {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ } catch (e) {
19
+ throw mod = 0, e;
20
+ }
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") {
24
+ for (let key of __getOwnPropNames(from))
25
+ if (!__hasOwnProp.call(to, key) && key !== except)
26
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
+ }
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
+ // If the importer is in node compatibility mode or this is not an ESM
32
+ // file that has been converted to a CommonJS file using a Babel-
33
+ // compatible transform (i.e. "__esModule" has not been set), then set
34
+ // "default" to the CommonJS "module.exports" for node compatibility.
35
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
+ mod
37
+ ));
38
+
39
+ // node_modules/isexe/windows.js
40
+ var require_windows = __commonJS({
41
+ "node_modules/isexe/windows.js"(exports, module) {
42
+ module.exports = isexe;
43
+ isexe.sync = sync;
44
+ var fs3 = __require("fs");
45
+ function checkPathExt(path3, options) {
46
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
47
+ if (!pathext) {
48
+ return true;
49
+ }
50
+ pathext = pathext.split(";");
51
+ if (pathext.indexOf("") !== -1) {
52
+ return true;
53
+ }
54
+ for (var i = 0; i < pathext.length; i++) {
55
+ var p = pathext[i].toLowerCase();
56
+ if (p && path3.substr(-p.length).toLowerCase() === p) {
57
+ return true;
58
+ }
59
+ }
60
+ return false;
61
+ }
62
+ function checkStat(stat, path3, options) {
63
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
64
+ return false;
65
+ }
66
+ return checkPathExt(path3, options);
67
+ }
68
+ function isexe(path3, options, cb) {
69
+ fs3.stat(path3, function(er, stat) {
70
+ cb(er, er ? false : checkStat(stat, path3, options));
71
+ });
72
+ }
73
+ function sync(path3, options) {
74
+ return checkStat(fs3.statSync(path3), path3, options);
75
+ }
76
+ }
77
+ });
78
+
79
+ // node_modules/isexe/mode.js
80
+ var require_mode = __commonJS({
81
+ "node_modules/isexe/mode.js"(exports, module) {
82
+ module.exports = isexe;
83
+ isexe.sync = sync;
84
+ var fs3 = __require("fs");
85
+ function isexe(path3, options, cb) {
86
+ fs3.stat(path3, function(er, stat) {
87
+ cb(er, er ? false : checkStat(stat, options));
88
+ });
89
+ }
90
+ function sync(path3, options) {
91
+ return checkStat(fs3.statSync(path3), options);
92
+ }
93
+ function checkStat(stat, options) {
94
+ return stat.isFile() && checkMode(stat, options);
95
+ }
96
+ function checkMode(stat, options) {
97
+ var mod = stat.mode;
98
+ var uid = stat.uid;
99
+ var gid = stat.gid;
100
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
101
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
102
+ var u = parseInt("100", 8);
103
+ var g = parseInt("010", 8);
104
+ var o = parseInt("001", 8);
105
+ var ug = u | g;
106
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
107
+ return ret;
108
+ }
109
+ }
110
+ });
111
+
112
+ // node_modules/isexe/index.js
113
+ var require_isexe = __commonJS({
114
+ "node_modules/isexe/index.js"(exports, module) {
115
+ var fs3 = __require("fs");
116
+ var core;
117
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
118
+ core = require_windows();
119
+ } else {
120
+ core = require_mode();
121
+ }
122
+ module.exports = isexe;
123
+ isexe.sync = sync;
124
+ function isexe(path3, options, cb) {
125
+ if (typeof options === "function") {
126
+ cb = options;
127
+ options = {};
128
+ }
129
+ if (!cb) {
130
+ if (typeof Promise !== "function") {
131
+ throw new TypeError("callback not provided");
132
+ }
133
+ return new Promise(function(resolve, reject) {
134
+ isexe(path3, options || {}, function(er, is) {
135
+ if (er) {
136
+ reject(er);
137
+ } else {
138
+ resolve(is);
139
+ }
140
+ });
141
+ });
142
+ }
143
+ core(path3, options || {}, function(er, is) {
144
+ if (er) {
145
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
146
+ er = null;
147
+ is = false;
148
+ }
149
+ }
150
+ cb(er, is);
151
+ });
152
+ }
153
+ function sync(path3, options) {
154
+ try {
155
+ return core.sync(path3, options || {});
156
+ } catch (er) {
157
+ if (options && options.ignoreErrors || er.code === "EACCES") {
158
+ return false;
159
+ } else {
160
+ throw er;
161
+ }
162
+ }
163
+ }
164
+ }
165
+ });
166
+
167
+ // node_modules/which/which.js
168
+ var require_which = __commonJS({
169
+ "node_modules/which/which.js"(exports, module) {
170
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
171
+ var path3 = __require("path");
172
+ var COLON = isWindows ? ";" : ":";
173
+ var isexe = require_isexe();
174
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
175
+ var getPathInfo = (cmd, opt) => {
176
+ const colon = opt.colon || COLON;
177
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
178
+ // windows always checks the cwd first
179
+ ...isWindows ? [process.cwd()] : [],
180
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
181
+ "").split(colon)
182
+ ];
183
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
184
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
185
+ if (isWindows) {
186
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
187
+ pathExt.unshift("");
188
+ }
189
+ return {
190
+ pathEnv,
191
+ pathExt,
192
+ pathExtExe
193
+ };
194
+ };
195
+ var which = (cmd, opt, cb) => {
196
+ if (typeof opt === "function") {
197
+ cb = opt;
198
+ opt = {};
199
+ }
200
+ if (!opt)
201
+ opt = {};
202
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
203
+ const found = [];
204
+ const step = (i) => new Promise((resolve, reject) => {
205
+ if (i === pathEnv.length)
206
+ return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
207
+ const ppRaw = pathEnv[i];
208
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
209
+ const pCmd = path3.join(pathPart, cmd);
210
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
211
+ resolve(subStep(p, i, 0));
212
+ });
213
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
214
+ if (ii === pathExt.length)
215
+ return resolve(step(i + 1));
216
+ const ext = pathExt[ii];
217
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
218
+ if (!er && is) {
219
+ if (opt.all)
220
+ found.push(p + ext);
221
+ else
222
+ return resolve(p + ext);
223
+ }
224
+ return resolve(subStep(p, i, ii + 1));
225
+ });
226
+ });
227
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
228
+ };
229
+ var whichSync = (cmd, opt) => {
230
+ opt = opt || {};
231
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
232
+ const found = [];
233
+ for (let i = 0; i < pathEnv.length; i++) {
234
+ const ppRaw = pathEnv[i];
235
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
236
+ const pCmd = path3.join(pathPart, cmd);
237
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
238
+ for (let j = 0; j < pathExt.length; j++) {
239
+ const cur = p + pathExt[j];
240
+ try {
241
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
242
+ if (is) {
243
+ if (opt.all)
244
+ found.push(cur);
245
+ else
246
+ return cur;
247
+ }
248
+ } catch (ex) {
249
+ }
250
+ }
251
+ }
252
+ if (opt.all && found.length)
253
+ return found;
254
+ if (opt.nothrow)
255
+ return null;
256
+ throw getNotFoundError(cmd);
257
+ };
258
+ module.exports = which;
259
+ which.sync = whichSync;
260
+ }
261
+ });
262
+
263
+ // node_modules/path-key/index.js
264
+ var require_path_key = __commonJS({
265
+ "node_modules/path-key/index.js"(exports, module) {
266
+ "use strict";
267
+ var pathKey = (options = {}) => {
268
+ const environment = options.env || process.env;
269
+ const platform = options.platform || process.platform;
270
+ if (platform !== "win32") {
271
+ return "PATH";
272
+ }
273
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
274
+ };
275
+ module.exports = pathKey;
276
+ module.exports.default = pathKey;
277
+ }
278
+ });
279
+
280
+ // node_modules/cross-spawn/lib/util/resolveCommand.js
281
+ var require_resolveCommand = __commonJS({
282
+ "node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
283
+ "use strict";
284
+ var path3 = __require("path");
285
+ var which = require_which();
286
+ var getPathKey = require_path_key();
287
+ function resolveCommandAttempt(parsed, withoutPathExt) {
288
+ const env = parsed.options.env || process.env;
289
+ const cwd = process.cwd();
290
+ const hasCustomCwd = parsed.options.cwd != null;
291
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
292
+ if (shouldSwitchCwd) {
293
+ try {
294
+ process.chdir(parsed.options.cwd);
295
+ } catch (err) {
296
+ }
297
+ }
298
+ let resolved;
299
+ try {
300
+ resolved = which.sync(parsed.command, {
301
+ path: env[getPathKey({ env })],
302
+ pathExt: withoutPathExt ? path3.delimiter : void 0
303
+ });
304
+ } catch (e) {
305
+ } finally {
306
+ if (shouldSwitchCwd) {
307
+ process.chdir(cwd);
308
+ }
309
+ }
310
+ if (resolved) {
311
+ resolved = path3.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
312
+ }
313
+ return resolved;
314
+ }
315
+ function resolveCommand(parsed) {
316
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
317
+ }
318
+ module.exports = resolveCommand;
319
+ }
320
+ });
321
+
322
+ // node_modules/cross-spawn/lib/util/escape.js
323
+ var require_escape = __commonJS({
324
+ "node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
325
+ "use strict";
326
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
327
+ function escapeCommand(arg) {
328
+ arg = arg.replace(metaCharsRegExp, "^$1");
329
+ return arg;
330
+ }
331
+ function escapeArgument(arg, doubleEscapeMetaChars) {
332
+ arg = `${arg}`;
333
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
334
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
335
+ arg = `"${arg}"`;
336
+ arg = arg.replace(metaCharsRegExp, "^$1");
337
+ if (doubleEscapeMetaChars) {
338
+ arg = arg.replace(metaCharsRegExp, "^$1");
339
+ }
340
+ return arg;
341
+ }
342
+ module.exports.command = escapeCommand;
343
+ module.exports.argument = escapeArgument;
344
+ }
345
+ });
346
+
347
+ // node_modules/shebang-regex/index.js
348
+ var require_shebang_regex = __commonJS({
349
+ "node_modules/shebang-regex/index.js"(exports, module) {
350
+ "use strict";
351
+ module.exports = /^#!(.*)/;
352
+ }
353
+ });
354
+
355
+ // node_modules/shebang-command/index.js
356
+ var require_shebang_command = __commonJS({
357
+ "node_modules/shebang-command/index.js"(exports, module) {
358
+ "use strict";
359
+ var shebangRegex = require_shebang_regex();
360
+ module.exports = (string = "") => {
361
+ const match = string.match(shebangRegex);
362
+ if (!match) {
363
+ return null;
364
+ }
365
+ const [path3, argument] = match[0].replace(/#! ?/, "").split(" ");
366
+ const binary = path3.split("/").pop();
367
+ if (binary === "env") {
368
+ return argument;
369
+ }
370
+ return argument ? `${binary} ${argument}` : binary;
371
+ };
372
+ }
373
+ });
374
+
375
+ // node_modules/cross-spawn/lib/util/readShebang.js
376
+ var require_readShebang = __commonJS({
377
+ "node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
378
+ "use strict";
379
+ var fs3 = __require("fs");
380
+ var shebangCommand = require_shebang_command();
381
+ function readShebang(command) {
382
+ const size = 150;
383
+ const buffer = Buffer.alloc(size);
384
+ let fd;
385
+ try {
386
+ fd = fs3.openSync(command, "r");
387
+ fs3.readSync(fd, buffer, 0, size, 0);
388
+ fs3.closeSync(fd);
389
+ } catch (e) {
390
+ }
391
+ return shebangCommand(buffer.toString());
392
+ }
393
+ module.exports = readShebang;
394
+ }
395
+ });
396
+
397
+ // node_modules/cross-spawn/lib/parse.js
398
+ var require_parse = __commonJS({
399
+ "node_modules/cross-spawn/lib/parse.js"(exports, module) {
400
+ "use strict";
401
+ var path3 = __require("path");
402
+ var resolveCommand = require_resolveCommand();
403
+ var escape = require_escape();
404
+ var readShebang = require_readShebang();
405
+ var isWin = process.platform === "win32";
406
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
407
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
408
+ function detectShebang(parsed) {
409
+ parsed.file = resolveCommand(parsed);
410
+ const shebang = parsed.file && readShebang(parsed.file);
411
+ if (shebang) {
412
+ parsed.args.unshift(parsed.file);
413
+ parsed.command = shebang;
414
+ return resolveCommand(parsed);
415
+ }
416
+ return parsed.file;
417
+ }
418
+ function parseNonShell(parsed) {
419
+ if (!isWin) {
420
+ return parsed;
421
+ }
422
+ const commandFile = detectShebang(parsed);
423
+ const needsShell = !isExecutableRegExp.test(commandFile);
424
+ if (parsed.options.forceShell || needsShell) {
425
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
426
+ parsed.command = path3.normalize(parsed.command);
427
+ parsed.command = escape.command(parsed.command);
428
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
429
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
430
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
431
+ parsed.command = process.env.comspec || "cmd.exe";
432
+ parsed.options.windowsVerbatimArguments = true;
433
+ }
434
+ return parsed;
435
+ }
436
+ function parse(command, args, options) {
437
+ if (args && !Array.isArray(args)) {
438
+ options = args;
439
+ args = null;
440
+ }
441
+ args = args ? args.slice(0) : [];
442
+ options = Object.assign({}, options);
443
+ const parsed = {
444
+ command,
445
+ args,
446
+ options,
447
+ file: void 0,
448
+ original: {
449
+ command,
450
+ args
451
+ }
452
+ };
453
+ return options.shell ? parsed : parseNonShell(parsed);
454
+ }
455
+ module.exports = parse;
456
+ }
457
+ });
458
+
459
+ // node_modules/cross-spawn/lib/enoent.js
460
+ var require_enoent = __commonJS({
461
+ "node_modules/cross-spawn/lib/enoent.js"(exports, module) {
462
+ "use strict";
463
+ var isWin = process.platform === "win32";
464
+ function notFoundError(original, syscall) {
465
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
466
+ code: "ENOENT",
467
+ errno: "ENOENT",
468
+ syscall: `${syscall} ${original.command}`,
469
+ path: original.command,
470
+ spawnargs: original.args
471
+ });
472
+ }
473
+ function hookChildProcess(cp, parsed) {
474
+ if (!isWin) {
475
+ return;
476
+ }
477
+ const originalEmit = cp.emit;
478
+ cp.emit = function(name, arg1) {
479
+ if (name === "exit") {
480
+ const err = verifyENOENT(arg1, parsed);
481
+ if (err) {
482
+ return originalEmit.call(cp, "error", err);
483
+ }
484
+ }
485
+ return originalEmit.apply(cp, arguments);
486
+ };
487
+ }
488
+ function verifyENOENT(status, parsed) {
489
+ if (isWin && status === 1 && !parsed.file) {
490
+ return notFoundError(parsed.original, "spawn");
491
+ }
492
+ return null;
493
+ }
494
+ function verifyENOENTSync(status, parsed) {
495
+ if (isWin && status === 1 && !parsed.file) {
496
+ return notFoundError(parsed.original, "spawnSync");
497
+ }
498
+ return null;
499
+ }
500
+ module.exports = {
501
+ hookChildProcess,
502
+ verifyENOENT,
503
+ verifyENOENTSync,
504
+ notFoundError
505
+ };
506
+ }
507
+ });
508
+
509
+ // node_modules/cross-spawn/index.js
510
+ var require_cross_spawn = __commonJS({
511
+ "node_modules/cross-spawn/index.js"(exports, module) {
512
+ "use strict";
513
+ var cp = __require("child_process");
514
+ var parse = require_parse();
515
+ var enoent = require_enoent();
516
+ function spawn(command, args, options) {
517
+ const parsed = parse(command, args, options);
518
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
519
+ enoent.hookChildProcess(spawned, parsed);
520
+ return spawned;
521
+ }
522
+ function spawnSync(command, args, options) {
523
+ const parsed = parse(command, args, options);
524
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
525
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
526
+ return result;
527
+ }
528
+ module.exports = spawn;
529
+ module.exports.spawn = spawn;
530
+ module.exports.sync = spawnSync;
531
+ module.exports._parse = parse;
532
+ module.exports._enoent = enoent;
533
+ }
534
+ });
3
535
 
4
536
  // src/install.ts
5
- import { spawnSync } from "node:child_process";
537
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
6
538
  import fs2 from "node:fs";
7
539
  import os2 from "node:os";
8
540
  import path2 from "node:path";
@@ -81,7 +613,7 @@ function packageRoot() {
81
613
  return path2.resolve(path2.dirname(fileURLToPath(import.meta.url)), "..");
82
614
  }
83
615
  function run(cmd, args) {
84
- const result = spawnSync(cmd, args, { encoding: "utf8", shell: false, env: process.env });
616
+ const result = import_cross_spawn.default.sync(cmd, args, { encoding: "utf8", env: process.env });
85
617
  if (result.error) return { ok: false, output: result.error.message };
86
618
  return { ok: result.status === 0, output: `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() };
87
619
  }
@@ -106,10 +638,12 @@ function installClaude(dir) {
106
638
  if (!available("claude")) return { agent: "Claude Code", ok: false, message: "claude \uBA85\uB839\uC744 \uCC3E\uC9C0 \uBABB\uD574 \uAC74\uB108\uB701\uB2C8\uB2E4." };
107
639
  const market = run("claude", ["plugin", "marketplace", "add", dir]);
108
640
  if (!market.ok) return { agent: "Claude Code", ok: false, message: `\uB9C8\uCF13\uD50C\uB808\uC774\uC2A4 \uB4F1\uB85D \uC2E4\uD328: ${market.output}` };
109
- run("claude", ["plugin", "marketplace", "update", MARKETPLACE]);
641
+ const refresh = run("claude", ["plugin", "marketplace", "update", MARKETPLACE]);
642
+ if (!refresh.ok) return { agent: "Claude Code", ok: false, message: `\uB9C8\uCF13\uD50C\uB808\uC774\uC2A4 \uAC31\uC2E0 \uC2E4\uD328: ${refresh.output}` };
110
643
  const install = run("claude", ["plugin", "install", PLUGIN]);
111
644
  if (!install.ok) return { agent: "Claude Code", ok: false, message: `\uD50C\uB7EC\uADF8\uC778 \uC124\uCE58 \uC2E4\uD328: ${install.output}` };
112
- run("claude", ["plugin", "update", PLUGIN]);
645
+ const update = run("claude", ["plugin", "update", PLUGIN]);
646
+ if (!update.ok) return { agent: "Claude Code", ok: false, message: `\uD50C\uB7EC\uADF8\uC778 \uC5C5\uB370\uC774\uD2B8 \uC2E4\uD328: ${update.output}` };
113
647
  return { agent: "Claude Code", ok: true, message: "\uC124\uCE58\uD588\uC2B5\uB2C8\uB2E4. \uC774\uBBF8 \uC5F4\uB824 \uC788\uB294 Claude Code \uB294 \uB2E4\uC2DC \uC2DC\uC791\uD574\uC57C \uBC18\uC601\uB429\uB2C8\uB2E4." };
114
648
  }
115
649
  function installCodex(dir) {
package/dist/server.mjs CHANGED
@@ -37400,6 +37400,7 @@ function workspaceFromResponse(body) {
37400
37400
  workspace_id: String(doc?.data?.id ?? ""),
37401
37401
  token: doc?.data?.attributes?.token ?? null,
37402
37402
  profile_name: profile?.attributes?.name ?? null,
37403
+ profile_id: profile?.id ? String(profile.id) : null,
37403
37404
  hackathon_id: hackathon?.id ?? null,
37404
37405
  hackathon_name: hackathon?.attributes?.name ?? null,
37405
37406
  team_name: team && !team.attributes?.is_personal ? team.attributes?.name ?? null : null
@@ -37608,6 +37609,50 @@ function publish(file2, entries) {
37608
37609
  fs6.writeFileSync(tmp, toLines(entries));
37609
37610
  fs6.renameSync(tmp, file2);
37610
37611
  }
37612
+ function readDestinationMeta(dir) {
37613
+ try {
37614
+ return JSON.parse(fs6.readFileSync(path5.join(dir, "destination.json"), "utf8"));
37615
+ } catch {
37616
+ return null;
37617
+ }
37618
+ }
37619
+ function writeDestinationMeta(fp, dest, meta3) {
37620
+ const dir = outboxDir(fp, dest);
37621
+ const current = readDestinationMeta(dir);
37622
+ if (current && (current.profile_id || !meta3.profile_id)) return;
37623
+ fs6.mkdirSync(dir, { recursive: true, mode: 448 });
37624
+ const file2 = path5.join(dir, "destination.json");
37625
+ const tmp = `${file2}.${process.pid}-${crypto4.randomBytes(4).toString("hex")}.tmp`;
37626
+ fs6.writeFileSync(tmp, JSON.stringify(meta3));
37627
+ fs6.renameSync(tmp, file2);
37628
+ }
37629
+ function adoptPending(fp, dest, match) {
37630
+ const root = path5.join(folderDir(fp), "outbox");
37631
+ let moved = 0;
37632
+ for (const other of listDir(root)) {
37633
+ if (other === dest) continue;
37634
+ const dir = path5.join(root, other);
37635
+ const meta3 = readDestinationMeta(dir);
37636
+ if (!meta3 || !match(meta3)) continue;
37637
+ for (const name of listDir(dir)) {
37638
+ const isSending = name.endsWith(".sending");
37639
+ if (!name.endsWith(".jsonl") && !isSending) continue;
37640
+ const file2 = path5.join(dir, name);
37641
+ try {
37642
+ if (isSending && Date.now() - fs6.statSync(file2).mtimeMs < STALE_SENDING_MS) continue;
37643
+ const original = isSending ? `${name.split(".jsonl.")[0]}.jsonl` : name;
37644
+ const count = countEntries(file2);
37645
+ fs6.mkdirSync(outboxDir(fp, dest), { recursive: true, mode: 448 });
37646
+ let target = path5.join(outboxDir(fp, dest), original);
37647
+ if (fs6.existsSync(target)) target = target.replace(/\.jsonl$/, `-${crypto4.randomBytes(4).toString("hex")}.jsonl`);
37648
+ fs6.renameSync(file2, target);
37649
+ moved += count;
37650
+ } catch {
37651
+ }
37652
+ }
37653
+ }
37654
+ return moved;
37655
+ }
37611
37656
  function appendOutbox(fp, dest, entries) {
37612
37657
  if (!entries.length) return;
37613
37658
  const name = `${Date.now().toString().padStart(15, "0")}-${process.pid}-${crypto4.randomBytes(4).toString("hex")}.jsonl`;
@@ -37831,10 +37876,10 @@ var Recorder = class {
37831
37876
  return { status: "login_required", message, notice: late2 ?? message };
37832
37877
  }
37833
37878
  if (!outcome.done) this.scheduleDrain(fp, agent, input2.session_id);
37834
- if (input2.hook_event_name === "SessionEnd") {
37835
- await Promise.race([this.flush(fp), sleep(FINAL_FLUSH_MS)]);
37879
+ if (input2.hook_event_name === "SessionEnd" || input2.hook_event_name === "Stop") {
37880
+ await Promise.race([this.flushFinal(fp), sleep(FINAL_FLUSH_MS)]);
37836
37881
  } else {
37837
- this.scheduleFlush(fp, input2.hook_event_name === "Stop" ? 0 : 1e3);
37882
+ this.scheduleFlush(fp, 1e3);
37838
37883
  }
37839
37884
  return late2 ? { status: "queued", queued: outcome.queued, notice: late2 } : { status: "queued", queued: outcome.queued };
37840
37885
  }
@@ -37856,9 +37901,11 @@ var Recorder = class {
37856
37901
  if (hook) events.push(hook);
37857
37902
  if (events.length) {
37858
37903
  const session = { external_session_id: state.session_id, started_at: state.started_at, cwd: state.cwd };
37904
+ const dest = destinationKey(credential);
37905
+ writeDestinationMeta(fp, dest, destinationMetaOf(credential));
37859
37906
  appendOutbox(
37860
37907
  fp,
37861
- destinationKey(credential),
37908
+ dest,
37862
37909
  events.map((event) => ({ agent: state.agent, session, event: { ...event, seq: ++state.seq } }))
37863
37910
  );
37864
37911
  }
@@ -37945,6 +37992,28 @@ var Recorder = class {
37945
37992
  }, delayMs);
37946
37993
  runtime.timer.unref();
37947
37994
  }
37995
+ /**
37996
+ * 턴 끝에 쓰는 전송. 이미 다른 전송이 돌고 있으면 flush() 는 그 전송(방금 쌓은 이벤트가 빠진)을 돌려주므로,
37997
+ * 끝난 뒤 남은 것이 있으면 다시 보낸다. 실패·인증 문제·다른 프로세스가 보내는 중이면 멈춘다.
37998
+ */
37999
+ async flushFinal(fp) {
38000
+ for (let i = 0; i < 3; i++) {
38001
+ const result = await this.flush(fp);
38002
+ if (!result || result.retryable || result.unauthorized || result.busy || !result.remaining) return;
38003
+ }
38004
+ }
38005
+ /** 같은 사람·해커톤·서버의 이전 등록에 남은 기록을 지금 목적지로 옮긴다. 옮긴 수를 돌려준다. */
38006
+ adoptForCredential(fp, credential) {
38007
+ writeDestinationMeta(fp, destinationKey(credential), destinationMetaOf(credential));
38008
+ const adopted = adoptPending(
38009
+ fp,
38010
+ destinationKey(credential),
38011
+ (meta3) => meta3.api_url === credential.api_url && meta3.hackathon_id === credential.hackathon_id && !!meta3.profile_id && meta3.profile_id === credential.profile_id
38012
+ );
38013
+ if (adopted) process.stderr.write(`[jitda] \uC774\uC804 \uB4F1\uB85D\uC5D0 \uB0A8\uC740 \uAE30\uB85D ${adopted}\uAC74\uC744 \uC774\uC5B4\uBC1B\uC74C
38014
+ `);
38015
+ return adopted;
38016
+ }
37948
38017
  /** 쌓인 이벤트를 보낸다. 같은 폴더에 대해 동시에 한 번만 돈다. */
37949
38018
  flush(fp) {
37950
38019
  const runtime = this.runtime(fp);
@@ -37955,6 +38024,7 @@ var Recorder = class {
37955
38024
  runtime.flushing = (async () => {
37956
38025
  const credential = credentialFor(fp);
37957
38026
  if (!credential) return null;
38027
+ this.adoptForCredential(fp, credential);
37958
38028
  const result = await flushOutbox(fp, destinationKey(credential), this.apiFor(credential), credential.token);
37959
38029
  if (result.sent || result.dropped || result.error) runtime.last = { ...result, at: (/* @__PURE__ */ new Date()).toISOString() };
37960
38030
  if (result.unauthorized) {
@@ -38120,6 +38190,7 @@ var Recorder = class {
38120
38190
  hackathon_name: info.hackathon_name,
38121
38191
  profile_name: info.profile_name,
38122
38192
  team_name: info.team_name,
38193
+ profile_id: info.profile_id,
38123
38194
  root,
38124
38195
  api_url: this.api.baseUrl,
38125
38196
  saved_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -38183,6 +38254,9 @@ ${text}`;
38183
38254
  function unreadableMarkerMessage(root) {
38184
38255
  return `\uC774 \uD3F4\uB354(${root})\uC758 ${MARKER_NAME} \uB97C \uC77D\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4(\uD3F4\uB354\uC774\uAC70\uB098 \uD574\uCEE4\uD1A4 \uAC12\uC774 \uC5C6\uAC70\uB098 \uB2E4\uB978 \uD574\uCEE4\uD1A4\uC6A9). \uC9C0\uC6B0\uAC70\uB098 \uACE0\uCE5C \uB4A4 \uB2E4\uC2DC \uB85C\uADF8\uC778\uD558\uC138\uC694. \uC9C0\uAE08\uC740 \uAE30\uB85D\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`;
38185
38256
  }
38257
+ function destinationMetaOf(credential) {
38258
+ return { api_url: credential.api_url, hackathon_id: credential.hackathon_id, profile_id: credential.profile_id ?? null };
38259
+ }
38186
38260
  function who(hackathon, team, name) {
38187
38261
  return [hackathon, team, name ? `${name} \uB2D8` : "\uCC38\uAC00\uC790"].filter(Boolean).join(" \xB7 ");
38188
38262
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jitda-agent",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "짓다(jitda) 해커톤 대회 작업 폴더의 Claude Code·Codex 대화를 심사용으로 기록하는 플러그인과 설치기",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -29,7 +29,9 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@modelcontextprotocol/sdk": "^1.32.2",
32
+ "@types/cross-spawn": "^6.0.6",
32
33
  "@types/node": "^22.20.5",
34
+ "cross-spawn": "^7.0.6",
33
35
  "esbuild": "^0.28.2",
34
36
  "typescript": "^7.0.2",
35
37
  "vitest": "^5.1.1",