@jcjeon/integration-cli 0.2.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.
Files changed (264) hide show
  1. package/.gitignore +23 -0
  2. package/.npmignore +21 -0
  3. package/.prettierignore +6 -0
  4. package/.prettierrc +26 -0
  5. package/AGENTS.md +10 -0
  6. package/CLAUDE.md +10 -0
  7. package/README.md +384 -0
  8. package/apps/server/README.md +294 -0
  9. package/apps/server/eslint.config.mjs +20 -0
  10. package/apps/server/nest-cli.json +8 -0
  11. package/apps/server/package.json +89 -0
  12. package/apps/server/scripts/postinstall.js +53 -0
  13. package/apps/server/src/__mocks__/glob.js +6 -0
  14. package/apps/server/src/__mocks__/uuid.js +5 -0
  15. package/apps/server/src/app.controller.spec.ts +24 -0
  16. package/apps/server/src/app.controller.ts +13 -0
  17. package/apps/server/src/app.module.ts +18 -0
  18. package/apps/server/src/app.service.ts +8 -0
  19. package/apps/server/src/common/ji-paths.ts +41 -0
  20. package/apps/server/src/database/database.module.ts +27 -0
  21. package/apps/server/src/database/entities/agent-changelog.entity.ts +39 -0
  22. package/apps/server/src/database/entities/agent-session.entity.ts +29 -0
  23. package/apps/server/src/database/entities/conversation.entity.ts +41 -0
  24. package/apps/server/src/database/entities/session.entity.ts +16 -0
  25. package/apps/server/src/database/entities/task-agent-run.entity.ts +40 -0
  26. package/apps/server/src/database/entities/task-agent.entity.ts +42 -0
  27. package/apps/server/src/database/entities/task-requirement.entity.ts +27 -0
  28. package/apps/server/src/database/entities/task-run.entity.ts +41 -0
  29. package/apps/server/src/database/entities/task.entity.ts +44 -0
  30. package/apps/server/src/main.ts +65 -0
  31. package/apps/server/src/modules/agents/agent-model-settings.spec.ts +80 -0
  32. package/apps/server/src/modules/agents/agents.module.ts +11 -0
  33. package/apps/server/src/modules/agents/claude/claude-auth.manager.ts +83 -0
  34. package/apps/server/src/modules/agents/claude/claude-pty.manager.ts +380 -0
  35. package/apps/server/src/modules/agents/claude/claude.controller.ts +85 -0
  36. package/apps/server/src/modules/agents/claude/claude.gateway.ts +158 -0
  37. package/apps/server/src/modules/agents/claude/claude.module.ts +18 -0
  38. package/apps/server/src/modules/agents/claude/claude.service.ts +67 -0
  39. package/apps/server/src/modules/agents/claude/dto/create-session.dto.ts +24 -0
  40. package/apps/server/src/modules/agents/claude/dto/resize-session.dto.ts +13 -0
  41. package/apps/server/src/modules/agents/claude/dto/send-input.dto.ts +9 -0
  42. package/apps/server/src/modules/agents/claude/interfaces/claude-session.interface.ts +26 -0
  43. package/apps/server/src/modules/agents/claude/interfaces/pty-event.interface.ts +10 -0
  44. package/apps/server/src/modules/agents/claude/interfaces/stream-event.interface.ts +61 -0
  45. package/apps/server/src/modules/agents/codex/codex-auth.manager.ts +107 -0
  46. package/apps/server/src/modules/agents/codex/codex-session.manager.ts +357 -0
  47. package/apps/server/src/modules/agents/codex/codex.controller.ts +64 -0
  48. package/apps/server/src/modules/agents/codex/codex.gateway.ts +97 -0
  49. package/apps/server/src/modules/agents/codex/codex.module.ts +17 -0
  50. package/apps/server/src/modules/agents/codex/dto/configure-auth.dto.ts +7 -0
  51. package/apps/server/src/modules/agents/gemini/dto/configure-auth.dto.ts +15 -0
  52. package/apps/server/src/modules/agents/gemini/dto/create-session.dto.ts +9 -0
  53. package/apps/server/src/modules/agents/gemini/dto/send-input.dto.ts +9 -0
  54. package/apps/server/src/modules/agents/gemini/gemini-auth.manager.ts +157 -0
  55. package/apps/server/src/modules/agents/gemini/gemini-session.manager.ts +287 -0
  56. package/apps/server/src/modules/agents/gemini/gemini.controller.ts +93 -0
  57. package/apps/server/src/modules/agents/gemini/gemini.gateway.ts +149 -0
  58. package/apps/server/src/modules/agents/gemini/gemini.module.ts +17 -0
  59. package/apps/server/src/modules/agents/gemini/interfaces/gemini-session.interface.ts +18 -0
  60. package/apps/server/src/modules/agents/gemini/interfaces/stream-event.interface.ts +14 -0
  61. package/apps/server/src/modules/agents/session-termination.spec.ts +103 -0
  62. package/apps/server/src/modules/changelog/changelog.controller.ts +20 -0
  63. package/apps/server/src/modules/changelog/changelog.module.ts +14 -0
  64. package/apps/server/src/modules/changelog/changelog.service.spec.ts +531 -0
  65. package/apps/server/src/modules/changelog/changelog.service.ts +690 -0
  66. package/apps/server/src/modules/conversations/conversation.controller.spec.ts +106 -0
  67. package/apps/server/src/modules/conversations/conversation.controller.ts +60 -0
  68. package/apps/server/src/modules/conversations/conversation.module.ts +14 -0
  69. package/apps/server/src/modules/conversations/conversation.service.spec.ts +176 -0
  70. package/apps/server/src/modules/conversations/conversation.service.ts +54 -0
  71. package/apps/server/src/modules/conversations/dto/create-conversation.dto.ts +37 -0
  72. package/apps/server/src/modules/conversations/enums/conversation.enum.ts +13 -0
  73. package/apps/server/src/modules/fs/fs.controller.ts +29 -0
  74. package/apps/server/src/modules/fs/fs.module.ts +8 -0
  75. package/apps/server/src/modules/harness/dto/save-harness.dto.ts +9 -0
  76. package/apps/server/src/modules/harness/harness.controller.spec.ts +95 -0
  77. package/apps/server/src/modules/harness/harness.controller.ts +35 -0
  78. package/apps/server/src/modules/harness/harness.module.ts +11 -0
  79. package/apps/server/src/modules/harness/harness.service.spec.ts +217 -0
  80. package/apps/server/src/modules/harness/harness.service.ts +112 -0
  81. package/apps/server/src/modules/sessions/session.controller.spec.ts +68 -0
  82. package/apps/server/src/modules/sessions/session.controller.ts +43 -0
  83. package/apps/server/src/modules/sessions/session.module.ts +14 -0
  84. package/apps/server/src/modules/sessions/session.service.spec.ts +106 -0
  85. package/apps/server/src/modules/sessions/session.service.ts +35 -0
  86. package/apps/server/src/modules/tasks/dto/create-task.dto.ts +54 -0
  87. package/apps/server/src/modules/tasks/dto/execute-task.dto.ts +22 -0
  88. package/apps/server/src/modules/tasks/dto/merge-file.dto.ts +7 -0
  89. package/apps/server/src/modules/tasks/dto/rerun-task.dto.ts +14 -0
  90. package/apps/server/src/modules/tasks/dto/update-task.dto.ts +55 -0
  91. package/apps/server/src/modules/tasks/task-execution.service.ts +978 -0
  92. package/apps/server/src/modules/tasks/task.gateway.ts +140 -0
  93. package/apps/server/src/modules/tasks/tasks.controller.spec.ts +210 -0
  94. package/apps/server/src/modules/tasks/tasks.controller.ts +139 -0
  95. package/apps/server/src/modules/tasks/tasks.module.ts +30 -0
  96. package/apps/server/src/modules/tasks/tasks.service.spec.ts +552 -0
  97. package/apps/server/src/modules/tasks/tasks.service.ts +333 -0
  98. package/apps/server/test/app.e2e-spec.ts +28 -0
  99. package/apps/server/test/jest-e2e.json +9 -0
  100. package/apps/server/tsconfig.build.json +4 -0
  101. package/apps/server/tsconfig.json +13 -0
  102. package/apps/web/AGENTS.md +7 -0
  103. package/apps/web/CLAUDE.md +1 -0
  104. package/apps/web/README.md +36 -0
  105. package/apps/web/eslint.config.mjs +21 -0
  106. package/apps/web/next-env.d.ts +6 -0
  107. package/apps/web/next.config.ts +7 -0
  108. package/apps/web/package.json +49 -0
  109. package/apps/web/postcss.config.mjs +7 -0
  110. package/apps/web/public/file.svg +1 -0
  111. package/apps/web/public/globe.svg +1 -0
  112. package/apps/web/public/next.svg +1 -0
  113. package/apps/web/public/vercel.svg +1 -0
  114. package/apps/web/public/window.svg +1 -0
  115. package/apps/web/src/app/claude/page.tsx +5 -0
  116. package/apps/web/src/app/codex/page.tsx +126 -0
  117. package/apps/web/src/app/favicon.ico +0 -0
  118. package/apps/web/src/app/gemini/page.tsx +130 -0
  119. package/apps/web/src/app/globals.css +149 -0
  120. package/apps/web/src/app/layout.tsx +40 -0
  121. package/apps/web/src/app/login/page.tsx +67 -0
  122. package/apps/web/src/app/page.tsx +497 -0
  123. package/apps/web/src/app/task/[id]/page.tsx +11 -0
  124. package/apps/web/src/app/test/page.tsx +298 -0
  125. package/apps/web/src/components/ui/Modal.tsx +78 -0
  126. package/apps/web/src/components/ui/WorkingDirPicker.tsx +195 -0
  127. package/apps/web/src/components/ui/__tests__/Modal.test.tsx +68 -0
  128. package/apps/web/src/features/auth/api/__tests__/auth.api.test.ts +83 -0
  129. package/apps/web/src/features/auth/api/auth.api.ts +81 -0
  130. package/apps/web/src/features/auth/hooks/__tests__/useClaudeAuth.test.ts +166 -0
  131. package/apps/web/src/features/auth/hooks/__tests__/useCodexAuth.test.ts +127 -0
  132. package/apps/web/src/features/auth/hooks/__tests__/useGeminiAuth.test.ts +120 -0
  133. package/apps/web/src/features/auth/hooks/useClaudeAuth.ts +88 -0
  134. package/apps/web/src/features/auth/hooks/useCodexAuth.ts +149 -0
  135. package/apps/web/src/features/auth/hooks/useGeminiAuth.ts +125 -0
  136. package/apps/web/src/features/auth/ui/CodexLoginPanel.tsx +302 -0
  137. package/apps/web/src/features/auth/ui/GeminiLoginPanel.tsx +316 -0
  138. package/apps/web/src/features/auth/ui/LoginForm.tsx +190 -0
  139. package/apps/web/src/features/auth/ui/LoginPanel.tsx +114 -0
  140. package/apps/web/src/features/auth/ui/__tests__/LoginPanel.test.tsx +105 -0
  141. package/apps/web/src/features/chat/api/__tests__/sessions.api.test.ts +187 -0
  142. package/apps/web/src/features/chat/api/sessions.api.ts +161 -0
  143. package/apps/web/src/features/chat/container/ClaudePageContainer.tsx +152 -0
  144. package/apps/web/src/features/chat/hooks/__tests__/useCodexSessions.test.ts +131 -0
  145. package/apps/web/src/features/chat/hooks/__tests__/useGeminiSessions.test.ts +130 -0
  146. package/apps/web/src/features/chat/hooks/useAgentModelSettings.ts +54 -0
  147. package/apps/web/src/features/chat/hooks/useClaudeSessions.ts +323 -0
  148. package/apps/web/src/features/chat/hooks/useCodexSessions.ts +275 -0
  149. package/apps/web/src/features/chat/hooks/useGeminiSessions.ts +255 -0
  150. package/apps/web/src/features/chat/hooks/useSessionCommand.ts +66 -0
  151. package/apps/web/src/features/chat/hooks/useSessionRename.ts +61 -0
  152. package/apps/web/src/features/chat/hooks/useSessionWorkingDirectories.ts +34 -0
  153. package/apps/web/src/features/chat/hooks/useUnifiedSessions.ts +156 -0
  154. package/apps/web/src/features/chat/lib/agentModelOptions.ts +72 -0
  155. package/apps/web/src/features/chat/ui/AgentModelPicker.tsx +134 -0
  156. package/apps/web/src/features/chat/ui/AgentSelectModal.tsx +236 -0
  157. package/apps/web/src/features/chat/ui/ChatInput.tsx +162 -0
  158. package/apps/web/src/features/chat/ui/ChatMessage.tsx +204 -0
  159. package/apps/web/src/features/chat/ui/ChatWorkspace.tsx +207 -0
  160. package/apps/web/src/features/chat/ui/CheckingSkeleton.tsx +44 -0
  161. package/apps/web/src/features/chat/ui/ClaudeLoginView.tsx +44 -0
  162. package/apps/web/src/features/chat/ui/PermissionCard.tsx +37 -0
  163. package/apps/web/src/features/chat/ui/SessionSidebar.tsx +280 -0
  164. package/apps/web/src/features/chat/ui/__tests__/AgentSelectModal.test.tsx +58 -0
  165. package/apps/web/src/features/chat/ui/__tests__/ChatInput.test.tsx +134 -0
  166. package/apps/web/src/features/chat/ui/__tests__/ChatMessage.test.tsx +106 -0
  167. package/apps/web/src/features/chat/ui/__tests__/ChatWorkspace.test.tsx +66 -0
  168. package/apps/web/src/features/diff/ui/DiffFileRow.tsx +73 -0
  169. package/apps/web/src/features/diff/ui/DiffHunk.tsx +61 -0
  170. package/apps/web/src/features/diff/ui/FileChangeBadge.tsx +23 -0
  171. package/apps/web/src/features/diff/ui/__tests__/DiffFileRow.test.tsx +40 -0
  172. package/apps/web/src/features/diff/ui/__tests__/DiffHunk.test.tsx +24 -0
  173. package/apps/web/src/features/diff/ui/__tests__/FileChangeBadge.test.tsx +16 -0
  174. package/apps/web/src/features/fs/api/fs.api.ts +14 -0
  175. package/apps/web/src/features/fs/hooks/useDirBrowser.ts +50 -0
  176. package/apps/web/src/features/harness/api/__tests__/harness.api.test.ts +73 -0
  177. package/apps/web/src/features/harness/api/harness.api.ts +46 -0
  178. package/apps/web/src/features/harness/hooks/__tests__/useHarness.test.ts +65 -0
  179. package/apps/web/src/features/harness/hooks/useHarness.ts +66 -0
  180. package/apps/web/src/features/harness/ui/HarnessModal.tsx +171 -0
  181. package/apps/web/src/features/harness/ui/__tests__/HarnessModal.test.tsx +46 -0
  182. package/apps/web/src/features/status/ui/AgentStatusModal.tsx +267 -0
  183. package/apps/web/src/features/status/ui/__tests__/AgentStatusModal.test.tsx +71 -0
  184. package/apps/web/src/features/tasks/api/__tests__/changelog.api.test.ts +89 -0
  185. package/apps/web/src/features/tasks/api/__tests__/tasks.api.test.ts +282 -0
  186. package/apps/web/src/features/tasks/api/changelog.api.ts +52 -0
  187. package/apps/web/src/features/tasks/api/tasks.api.ts +175 -0
  188. package/apps/web/src/features/tasks/container/TaskDetailPageContainer.tsx +69 -0
  189. package/apps/web/src/features/tasks/hooks/__tests__/useChangelogCodeCopy.test.ts +48 -0
  190. package/apps/web/src/features/tasks/hooks/__tests__/useTaskChangelog.test.ts +48 -0
  191. package/apps/web/src/features/tasks/hooks/__tests__/useTaskCreate.test.ts +217 -0
  192. package/apps/web/src/features/tasks/hooks/__tests__/useTaskEdit.test.ts +152 -0
  193. package/apps/web/src/features/tasks/hooks/__tests__/useTaskExecution.test.ts +143 -0
  194. package/apps/web/src/features/tasks/hooks/__tests__/useTaskList.test.ts +168 -0
  195. package/apps/web/src/features/tasks/hooks/__tests__/useTaskNotification.test.ts +125 -0
  196. package/apps/web/src/features/tasks/hooks/__tests__/useTaskRuns.test.ts +51 -0
  197. package/apps/web/src/features/tasks/hooks/useChangelogCodeCopy.ts +52 -0
  198. package/apps/web/src/features/tasks/hooks/useCopyToClipboard.ts +47 -0
  199. package/apps/web/src/features/tasks/hooks/useTaskChangelog.ts +32 -0
  200. package/apps/web/src/features/tasks/hooks/useTaskCreate.ts +137 -0
  201. package/apps/web/src/features/tasks/hooks/useTaskDetail.ts +217 -0
  202. package/apps/web/src/features/tasks/hooks/useTaskEdit.ts +130 -0
  203. package/apps/web/src/features/tasks/hooks/useTaskExecution.ts +137 -0
  204. package/apps/web/src/features/tasks/hooks/useTaskList.ts +159 -0
  205. package/apps/web/src/features/tasks/hooks/useTaskNotification.ts +80 -0
  206. package/apps/web/src/features/tasks/hooks/useTaskRuns.ts +32 -0
  207. package/apps/web/src/features/tasks/ui/AgentOutputPanel.tsx +203 -0
  208. package/apps/web/src/features/tasks/ui/AgentRoleSelect.tsx +97 -0
  209. package/apps/web/src/features/tasks/ui/ChangelogPanel.tsx +321 -0
  210. package/apps/web/src/features/tasks/ui/RunHistoryPanel.tsx +193 -0
  211. package/apps/web/src/features/tasks/ui/TaskCreateModal.tsx +205 -0
  212. package/apps/web/src/features/tasks/ui/TaskDetailView.tsx +413 -0
  213. package/apps/web/src/features/tasks/ui/TaskEditModal.tsx +165 -0
  214. package/apps/web/src/features/tasks/ui/TaskListModal.tsx +591 -0
  215. package/apps/web/src/features/tasks/ui/__tests__/AgentRoleSelect.test.tsx +91 -0
  216. package/apps/web/src/features/tasks/ui/__tests__/ChangelogPanel.test.tsx +94 -0
  217. package/apps/web/src/features/tasks/ui/__tests__/RunHistoryPanel.test.tsx +71 -0
  218. package/apps/web/src/features/tasks/ui/__tests__/TaskCreateModal.test.tsx +153 -0
  219. package/apps/web/src/features/tasks/ui/__tests__/TaskEditModal.test.tsx +75 -0
  220. package/apps/web/src/features/tasks/ui/__tests__/TaskListModal.test.tsx +243 -0
  221. package/apps/web/src/hooks/useWorkingDir.ts +28 -0
  222. package/apps/web/src/lib/__tests__/ansi.test.ts +88 -0
  223. package/apps/web/src/lib/ansi.ts +105 -0
  224. package/apps/web/src/lib/constants.ts +4 -0
  225. package/apps/web/src/lib/quota.ts +22 -0
  226. package/apps/web/src/lib/theme.tsx +78 -0
  227. package/apps/web/src/lib/toast.tsx +175 -0
  228. package/apps/web/src/store/agentStatusStore.ts +38 -0
  229. package/apps/web/tsconfig.json +18 -0
  230. package/apps/web/vitest.config.ts +25 -0
  231. package/apps/web/vitest.setup.ts +10 -0
  232. package/package.json +85 -0
  233. package/packages/cli/dist/commands/check.d.ts +1 -0
  234. package/packages/cli/dist/commands/check.js +89 -0
  235. package/packages/cli/dist/commands/init.d.ts +5 -0
  236. package/packages/cli/dist/commands/init.js +183 -0
  237. package/packages/cli/dist/commands/start.d.ts +4 -0
  238. package/packages/cli/dist/commands/start.js +188 -0
  239. package/packages/cli/dist/index.d.ts +2 -0
  240. package/packages/cli/dist/index.js +71 -0
  241. package/packages/cli/dist/utils/agent-tools.d.ts +28 -0
  242. package/packages/cli/dist/utils/agent-tools.js +193 -0
  243. package/packages/cli/dist/utils/project-init.d.ts +12 -0
  244. package/packages/cli/dist/utils/project-init.js +258 -0
  245. package/packages/cli/dist/utils/proxy.d.ts +8 -0
  246. package/packages/cli/dist/utils/proxy.js +138 -0
  247. package/packages/cli/package.json +30 -0
  248. package/packages/cli/src/commands/check.ts +77 -0
  249. package/packages/cli/src/commands/init.ts +209 -0
  250. package/packages/cli/src/commands/start.ts +183 -0
  251. package/packages/cli/src/index.ts +91 -0
  252. package/packages/cli/src/utils/agent-tools.ts +201 -0
  253. package/packages/cli/src/utils/project-init.ts +252 -0
  254. package/packages/cli/src/utils/proxy.ts +123 -0
  255. package/packages/cli/tsconfig.json +14 -0
  256. package/packages/eslint-config/base.mjs +31 -0
  257. package/packages/eslint-config/nest.mjs +55 -0
  258. package/packages/eslint-config/next.mjs +23 -0
  259. package/packages/eslint-config/package.json +20 -0
  260. package/packages/typescript-config/base.json +16 -0
  261. package/packages/typescript-config/nestjs.json +17 -0
  262. package/packages/typescript-config/nextjs.json +15 -0
  263. package/packages/typescript-config/package.json +11 -0
  264. package/turbo.json +28 -0
@@ -0,0 +1,29 @@
1
+ import { Column, CreateDateColumn, Entity, PrimaryColumn, UpdateDateColumn } from 'typeorm';
2
+
3
+ /** Claude CLI 프로세스 세션 추적용 엔티티 (내부 사용) */
4
+ @Entity('agent_sessions')
5
+ export class AgentSessionEntity {
6
+ @PrimaryColumn({ type: 'text' })
7
+ id!: string;
8
+
9
+ @Column({ type: 'text', nullable: true })
10
+ claudeSessionId!: string | null;
11
+
12
+ @Column({ type: 'text', default: 'idle' })
13
+ status!: string;
14
+
15
+ @Column({ type: 'text' })
16
+ workingDirectory!: string;
17
+
18
+ @Column({ type: 'text', nullable: true })
19
+ model!: string | null;
20
+
21
+ @Column({ type: 'text', nullable: true })
22
+ reasoning!: string | null;
23
+
24
+ @CreateDateColumn()
25
+ createdAt!: Date;
26
+
27
+ @UpdateDateColumn()
28
+ lastActivity!: Date;
29
+ }
@@ -0,0 +1,41 @@
1
+ import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ import { AgentModel, ConversationType } from '../../modules/conversations/enums/conversation.enum';
4
+
5
+ @Entity('conversations')
6
+ export class ConversationEntity {
7
+ /** 대화 고유 ID (UUID, PK) */
8
+ @PrimaryGeneratedColumn('uuid')
9
+ id!: string;
10
+
11
+ /** 세션 FK (sessions.session_id) */
12
+ @Column({ type: 'text', name: 'session_id' })
13
+ sessionId!: string;
14
+
15
+ /** 프롬프트 ID — user_message / agent_message 1:1 매핑 키 */
16
+ @Column({ type: 'text', name: 'prompt_id' })
17
+ promptId!: string;
18
+
19
+ /** 태스크 에이전트 ID (task_agents.id) — 태스크 실행 시에만 존재 */
20
+ @Column({ type: 'integer', name: 'agent_id', nullable: true })
21
+ agentId!: number | null;
22
+
23
+ /** 실행 버전 ID (task_runs.id) — rerun 버전 구분용 */
24
+ @Column({ type: 'integer', name: 'run_id', nullable: true })
25
+ runId!: number | null;
26
+
27
+ /** 메시지 내용 */
28
+ @Column({ type: 'text' })
29
+ content!: string;
30
+
31
+ /** 에이전트 모델 (claude | chatgpt | gemini | opencode | grok) */
32
+ @Column({ type: 'simple-enum', enum: AgentModel, name: 'agent_model' })
33
+ agentModel!: AgentModel;
34
+
35
+ /** 메시지 타입 (user_message | agent_message) */
36
+ @Column({ type: 'simple-enum', enum: ConversationType })
37
+ type!: ConversationType;
38
+
39
+ @CreateDateColumn({ name: 'created_at' })
40
+ createdAt!: Date;
41
+ }
@@ -0,0 +1,16 @@
1
+ import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ @Entity('sessions')
4
+ export class SessionEntity {
5
+ @PrimaryGeneratedColumn('uuid', { name: 'session_id' })
6
+ sessionId!: string;
7
+
8
+ @Column({ type: 'text' })
9
+ title!: string;
10
+
11
+ @Column({ type: 'text', default: 'claude' })
12
+ agentType!: string;
13
+
14
+ @CreateDateColumn({ name: 'created_at' })
15
+ createdAt!: Date;
16
+ }
@@ -0,0 +1,40 @@
1
+ import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ import { TaskAgentEntity } from './task-agent.entity';
4
+ import { TaskRunEntity } from './task-run.entity';
5
+
6
+ @Entity('task_agent_runs')
7
+ export class TaskAgentRunEntity {
8
+ @PrimaryGeneratedColumn()
9
+ id!: number;
10
+
11
+ @Column('integer')
12
+ runId!: number;
13
+
14
+ @Column('integer')
15
+ agentId!: number;
16
+
17
+ @Column('text', { default: 'pending' })
18
+ status!: string;
19
+
20
+ @Column('text', { nullable: true })
21
+ worktreePath!: string | null;
22
+
23
+ @Column('text', { nullable: true })
24
+ startCommitHash!: string | null;
25
+
26
+ @Column('real', { nullable: true })
27
+ durationMs!: number | null;
28
+
29
+ @Column('real', { nullable: true })
30
+ costUsd!: number | null;
31
+
32
+ @CreateDateColumn()
33
+ createdAt!: Date;
34
+
35
+ @ManyToOne(() => TaskRunEntity, (r) => r.agentRuns, { onDelete: 'CASCADE' })
36
+ run!: TaskRunEntity;
37
+
38
+ @ManyToOne(() => TaskAgentEntity, { onDelete: 'CASCADE' })
39
+ agent!: TaskAgentEntity;
40
+ }
@@ -0,0 +1,42 @@
1
+ import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ import { TaskEntity } from './task.entity';
4
+
5
+ export type AgentRole = 'frontend' | 'backend' | 'doc' | 'operation' | 'other';
6
+ export type AgentType = 'claude' | 'gemini' | 'codex' | 'opencode';
7
+
8
+ @Entity('task_agents')
9
+ export class TaskAgentEntity {
10
+ @PrimaryGeneratedColumn()
11
+ id!: number;
12
+
13
+ @Column('text')
14
+ taskId!: string;
15
+
16
+ @ManyToOne(() => TaskEntity, (t) => t.agents, { onDelete: 'CASCADE' })
17
+ task!: TaskEntity;
18
+
19
+ @Column('text', { default: 'claude' })
20
+ agentType!: AgentType;
21
+
22
+ @Column('text')
23
+ role!: AgentRole;
24
+
25
+ @Column('text', { nullable: true })
26
+ customRole!: string | null;
27
+
28
+ @Column('text', { nullable: true })
29
+ claudeSessionId!: string | null;
30
+
31
+ @Column('text', { nullable: true })
32
+ worktreePath!: string | null;
33
+
34
+ @Column('text', { nullable: true })
35
+ startCommitHash!: string | null;
36
+
37
+ @Column('text', { default: 'pending' })
38
+ status!: string;
39
+
40
+ @CreateDateColumn()
41
+ createdAt!: Date;
42
+ }
@@ -0,0 +1,27 @@
1
+ import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
2
+
3
+ import { TaskEntity } from './task.entity';
4
+
5
+ @Entity('task_requirements')
6
+ export class TaskRequirementEntity {
7
+ @PrimaryGeneratedColumn()
8
+ id!: number;
9
+
10
+ @Column('text')
11
+ taskId!: string;
12
+
13
+ @ManyToOne(() => TaskEntity, (t) => t.requirements, { onDelete: 'CASCADE' })
14
+ task!: TaskEntity;
15
+
16
+ @Column('text')
17
+ content!: string;
18
+
19
+ @Column('text', { default: 'pending' })
20
+ status!: string;
21
+
22
+ @Column('integer', { default: 0 })
23
+ orderIndex!: number;
24
+
25
+ @CreateDateColumn()
26
+ createdAt!: Date;
27
+ }
@@ -0,0 +1,41 @@
1
+ import {
2
+ Column,
3
+ CreateDateColumn,
4
+ Entity,
5
+ ManyToOne,
6
+ OneToMany,
7
+ PrimaryGeneratedColumn,
8
+ } from 'typeorm';
9
+
10
+ import { TaskEntity } from './task.entity';
11
+ import { TaskAgentRunEntity } from './task-agent-run.entity';
12
+
13
+ @Entity('task_runs')
14
+ export class TaskRunEntity {
15
+ @PrimaryGeneratedColumn()
16
+ id!: number;
17
+
18
+ @Column('text')
19
+ taskId!: string;
20
+
21
+ @Column('integer')
22
+ version!: number;
23
+
24
+ @Column('text', { nullable: true })
25
+ supplementNote!: string | null;
26
+
27
+ @Column('text', { default: 'pending' })
28
+ status!: string;
29
+
30
+ @CreateDateColumn()
31
+ startedAt!: Date;
32
+
33
+ @Column({ type: 'datetime', nullable: true })
34
+ completedAt!: Date | null;
35
+
36
+ @ManyToOne(() => TaskEntity, { onDelete: 'CASCADE' })
37
+ task!: TaskEntity;
38
+
39
+ @OneToMany(() => TaskAgentRunEntity, (ar) => ar.run, { cascade: true })
40
+ agentRuns!: TaskAgentRunEntity[];
41
+ }
@@ -0,0 +1,44 @@
1
+ import {
2
+ Column,
3
+ CreateDateColumn,
4
+ Entity,
5
+ OneToMany,
6
+ PrimaryColumn,
7
+ UpdateDateColumn,
8
+ } from 'typeorm';
9
+
10
+ import { TaskAgentEntity } from './task-agent.entity';
11
+ import { TaskRequirementEntity } from './task-requirement.entity';
12
+
13
+ @Entity('tasks')
14
+ export class TaskEntity {
15
+ @PrimaryColumn('text')
16
+ id!: string;
17
+
18
+ @Column('text')
19
+ title!: string;
20
+
21
+ @Column('text', { default: 'pending' })
22
+ status!: string;
23
+
24
+ @Column('text', { nullable: true })
25
+ workingDir!: string | null;
26
+
27
+ @Column('text', { nullable: true })
28
+ claudeSessionId!: string | null;
29
+
30
+ @Column('boolean', { default: false })
31
+ archived!: boolean;
32
+
33
+ @CreateDateColumn()
34
+ createdAt!: Date;
35
+
36
+ @UpdateDateColumn()
37
+ updatedAt!: Date;
38
+
39
+ @OneToMany(() => TaskRequirementEntity, (r) => r.task, { cascade: true })
40
+ requirements!: TaskRequirementEntity[];
41
+
42
+ @OneToMany(() => TaskAgentEntity, (a) => a.task, { cascade: true })
43
+ agents!: TaskAgentEntity[];
44
+ }
@@ -0,0 +1,65 @@
1
+ import * as fs from 'fs';
2
+
3
+ import { ValidationPipe } from '@nestjs/common';
4
+ import { NestFactory } from '@nestjs/core';
5
+ import { IoAdapter } from '@nestjs/platform-socket.io';
6
+ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
7
+ import { apiReference } from '@scalar/nestjs-api-reference';
8
+
9
+ import { AppModule } from './app.module';
10
+ import { ensureJiDirs, JI_PATHS } from './common/ji-paths';
11
+
12
+ async function bootstrap() {
13
+ ensureJiDirs();
14
+
15
+ const app = await NestFactory.create(AppModule, {
16
+ logger: ['log', 'warn', 'error', 'debug'],
17
+ });
18
+
19
+ // 로그를 ~/.ji/logs/server.log 에 추가 기록
20
+ const logStream = fs.createWriteStream(JI_PATHS.serverLog, { flags: 'a' });
21
+ const origWrite = process.stdout.write.bind(process.stdout);
22
+ process.stdout.write = (chunk: string | Uint8Array, ...args: unknown[]) => {
23
+ logStream.write(chunk);
24
+ return (origWrite as (...a: unknown[]) => boolean)(chunk, ...args);
25
+ };
26
+
27
+ app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
28
+ app.useWebSocketAdapter(new IoAdapter(app));
29
+ app.enableCors();
30
+
31
+ // ─── Swagger / OpenAPI ────────────────────────────────────────────────────
32
+ const config = new DocumentBuilder()
33
+ .setTitle('Integration CLI API')
34
+ .setDescription(
35
+ 'Claude Code · Gemini CLI 등 AI 에이전트를 통합 관리하는 REST API.\n\n' +
36
+ '실시간 출력은 `/tasks` WebSocket 네임스페이스를 통해 수신합니다.',
37
+ )
38
+ .setVersion('1.0')
39
+ .addTag('agents/claude', 'Claude Code 인증·세션 관리')
40
+ .addTag('agents/gemini', 'Gemini CLI 인증·세션 관리')
41
+ .addTag('tasks', '비동기 작업 생성·실행·조회')
42
+ .addTag('sessions', 'DB 저장 세션 조회')
43
+ .addTag('conversations', '대화 메시지 저장·조회')
44
+ .build();
45
+
46
+ const document = SwaggerModule.createDocument(app, config);
47
+
48
+ // Scalar UI — /docs
49
+ app.use(
50
+ '/docs',
51
+ apiReference({
52
+ spec: { content: document },
53
+ theme: 'saturn',
54
+ }),
55
+ );
56
+
57
+ // Raw OpenAPI JSON — /docs-json
58
+ SwaggerModule.setup('docs-json', app, document, {
59
+ jsonDocumentUrl: 'docs-json',
60
+ swaggerUiEnabled: false,
61
+ });
62
+
63
+ await app.listen(process.env.PORT ?? 3001);
64
+ }
65
+ void bootstrap();
@@ -0,0 +1,80 @@
1
+ import { EventEmitter } from 'events';
2
+ import { spawn } from 'child_process';
3
+
4
+ import { ClaudePtyManager } from './claude/claude-pty.manager';
5
+ import { CodexSessionManager } from './codex/codex-session.manager';
6
+
7
+ jest.mock('child_process', () => ({
8
+ spawn: jest.fn(),
9
+ execSync: jest.fn(),
10
+ }));
11
+
12
+ const spawnMock = spawn as jest.Mock;
13
+
14
+ function mockRepo() {
15
+ return {
16
+ save: jest.fn().mockResolvedValue({}),
17
+ update: jest.fn().mockResolvedValue({}),
18
+ findOne: jest.fn(),
19
+ };
20
+ }
21
+
22
+ function mockProcess() {
23
+ const proc = new EventEmitter() as EventEmitter & {
24
+ stdout: EventEmitter;
25
+ stderr: EventEmitter;
26
+ killed: boolean;
27
+ kill: jest.Mock;
28
+ };
29
+ proc.stdout = new EventEmitter();
30
+ proc.stderr = new EventEmitter();
31
+ proc.killed = false;
32
+ proc.kill = jest.fn();
33
+ return proc;
34
+ }
35
+
36
+ async function flushPromises() {
37
+ await Promise.resolve();
38
+ await Promise.resolve();
39
+ }
40
+
41
+ describe('agent model settings', () => {
42
+ afterEach(() => jest.clearAllMocks());
43
+
44
+ it('passes Claude model and reasoning to the CLI', async () => {
45
+ const proc = mockProcess();
46
+ spawnMock.mockReturnValueOnce(proc);
47
+ const agentRepo = mockRepo();
48
+ const sessionRepo = mockRepo();
49
+ const manager = new ClaudePtyManager(agentRepo as never, sessionRepo as never);
50
+ const session = manager.createSession('/tmp/project', 'sonnet', 'high');
51
+
52
+ manager.sendMessage(session.id, 'hello');
53
+ await flushPromises();
54
+
55
+ expect(spawnMock).toHaveBeenCalledWith(
56
+ 'claude',
57
+ expect.arrayContaining(['--model', 'sonnet', '--effort', 'high']),
58
+ expect.objectContaining({ cwd: '/tmp/project' }),
59
+ );
60
+ });
61
+
62
+ it('passes Codex model and reasoning to the CLI', async () => {
63
+ const proc = mockProcess();
64
+ spawnMock.mockReturnValueOnce(proc);
65
+ const agentRepo = mockRepo();
66
+ const sessionRepo = mockRepo();
67
+ const authManager = { getEnvForCodex: jest.fn(() => ({})) };
68
+ const manager = new CodexSessionManager(agentRepo as never, sessionRepo as never, authManager as never);
69
+ const session = manager.createSession('/tmp/project', 'gpt-5.5', 'xhigh');
70
+
71
+ manager.sendMessage(session.id, 'hello');
72
+ await flushPromises();
73
+
74
+ expect(spawnMock).toHaveBeenCalledWith(
75
+ 'codex',
76
+ expect.arrayContaining(['exec', '-m', 'gpt-5.5', '-c', 'model_reasoning_effort="xhigh"']),
77
+ expect.objectContaining({ cwd: '/tmp/project' }),
78
+ );
79
+ });
80
+ });
@@ -0,0 +1,11 @@
1
+ import { Module } from '@nestjs/common';
2
+
3
+ import { ClaudeModule } from './claude/claude.module';
4
+ import { CodexModule } from './codex/codex.module';
5
+ import { GeminiModule } from './gemini/gemini.module';
6
+
7
+ @Module({
8
+ imports: [ClaudeModule, GeminiModule, CodexModule],
9
+ exports: [ClaudeModule, GeminiModule, CodexModule],
10
+ })
11
+ export class AgentsModule {}
@@ -0,0 +1,83 @@
1
+ import { spawn } from 'child_process';
2
+ import type { ChildProcess } from 'child_process';
3
+
4
+ import { Injectable, Logger } from '@nestjs/common';
5
+
6
+ export interface AuthStatus {
7
+ loggedIn: boolean;
8
+ authMethod: string;
9
+ apiProvider: string;
10
+ email?: string;
11
+ orgName?: string;
12
+ subscriptionType?: string;
13
+ }
14
+
15
+ @Injectable()
16
+ export class ClaudeAuthManager {
17
+ private readonly logger = new Logger(ClaudeAuthManager.name);
18
+ private readonly loginProcesses = new Map<string, ChildProcess>();
19
+
20
+ async getAuthStatus(): Promise<AuthStatus> {
21
+ return new Promise((resolve) => {
22
+ const proc = spawn('claude', ['auth', 'status'], {
23
+ stdio: ['ignore', 'pipe', 'pipe'],
24
+ env: process.env,
25
+ });
26
+
27
+ let output = '';
28
+ proc.stdout.on('data', (d: Buffer) => (output += d.toString()));
29
+ proc.stderr.on('data', (d: Buffer) => (output += d.toString()));
30
+
31
+ proc.on('close', () => {
32
+ try {
33
+ resolve(JSON.parse(output.trim()) as AuthStatus);
34
+ } catch {
35
+ resolve({ loggedIn: false, authMethod: 'unknown', apiProvider: 'firstParty' });
36
+ }
37
+ });
38
+
39
+ proc.on('error', () => {
40
+ resolve({ loggedIn: false, authMethod: 'unknown', apiProvider: 'firstParty' });
41
+ });
42
+ });
43
+ }
44
+
45
+ startLogin(
46
+ clientId: string,
47
+ onOutput: (text: string) => void,
48
+ onDone: (success: boolean) => void,
49
+ ): void {
50
+ this.cancelLogin(clientId);
51
+
52
+ const proc = spawn('claude', ['auth', 'login'], {
53
+ stdio: ['ignore', 'pipe', 'pipe'],
54
+ env: process.env,
55
+ });
56
+
57
+ this.loginProcesses.set(clientId, proc);
58
+ this.logger.log(`Started login process for client ${clientId} (pid: ${proc.pid})`);
59
+
60
+ proc.stdout.on('data', (chunk: Buffer) => onOutput(chunk.toString()));
61
+ proc.stderr.on('data', (chunk: Buffer) => onOutput(chunk.toString()));
62
+
63
+ proc.on('close', (code) => {
64
+ this.loginProcesses.delete(clientId);
65
+ this.logger.log(`Login process for ${clientId} exited with code ${code}`);
66
+ onDone(code === 0);
67
+ });
68
+
69
+ proc.on('error', (err) => {
70
+ this.loginProcesses.delete(clientId);
71
+ this.logger.error(`Login process error for ${clientId}: ${err.message}`);
72
+ onDone(false);
73
+ });
74
+ }
75
+
76
+ cancelLogin(clientId: string): void {
77
+ const proc = this.loginProcesses.get(clientId);
78
+ if (proc) {
79
+ proc.kill();
80
+ this.loginProcesses.delete(clientId);
81
+ }
82
+ }
83
+ }