From b825125616a0620282123f9e79cf70159c9aa97a Mon Sep 17 00:00:00 2001 From: Jiwan SEO Date: Tue, 10 Nov 2026 15:19:06 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20(feat)=20#11=20::=20=ED=8C=80?= =?UTF-8?q?=C2=B7=EB=B3=B8=EB=B6=80=20=EB=B3=B4=EA=B3=A0=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EB=B8=94=EA=B3=BC=20=EC=9D=B8=EA=B3=84=20=EC=9E=90?= =?UTF-8?q?=EB=A3=8C=20=EC=83=9D=EC=84=B1=20=EA=B7=9C=EC=B9=99=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/core.test.ts | 32 + packages/core/src/handoff.ts | 71 ++ packages/core/src/index.ts | 1 + packages/db/drizzle/0002_loving_ricochet.sql | 20 + packages/db/drizzle/meta/0002_snapshot.json | 822 +++++++++++++++++++ packages/db/drizzle/meta/_journal.json | 7 + packages/db/src/schema.ts | 33 + 7 files changed, 986 insertions(+) create mode 100644 packages/core/src/handoff.ts create mode 100644 packages/db/drizzle/0002_loving_ricochet.sql create mode 100644 packages/db/drizzle/meta/0002_snapshot.json diff --git a/packages/core/src/core.test.ts b/packages/core/src/core.test.ts index f6348a5..3041206 100644 --- a/packages/core/src/core.test.ts +++ b/packages/core/src/core.test.ts @@ -3,6 +3,8 @@ import { DEFAULT_ORG, InvalidTransitionError, branchName, + buildHandoff, + nextStep, checkDivisionBudget, evaluateCommand, initialState, @@ -209,3 +211,33 @@ describe("예산", () => { }); }); }); + +describe("인계", () => { + const entry = (summary: string, body = "") => ({ + stage: "plan" as const, + teamName: "기획팀", + divisionName: "기획본부", + outcome: "completed" as const, + summary, + body, + }); + + it("앞 팀 보고를 단계·본부·팀 순서로 묶는다", () => { + const text = buildHandoff([entry("명세 확정", "**변경**\n- 없음")]); + expect(text).toContain("### [기획] 기획본부 기획팀 — 완료"); + expect(text).toContain("명세 확정"); + }); + + it("길면 오래된 보고부터 본문을 뺀다", () => { + const text = buildHandoff([entry("첫 보고", "x".repeat(500)), entry("둘째 보고", "y".repeat(100))], 300); + expect(text).toContain("첫 보고"); + expect(text).not.toContain("xxxx"); + expect(text).toContain("yyyy"); + }); + + it("다음 담당은 팀 또는 사람이다", () => { + expect(nextStep(DEFAULT_ORG, { stage: "implement", status: "queued", reworks: 0, reason: null }, ["⚙️ backend"])).toEqual({ teamId: "backend", human: null }); + expect(nextStep(DEFAULT_ORG, { stage: "verify", status: "awaiting_merge", reworks: 0, reason: null }, []).human).toContain("merge"); + expect(nextStep(DEFAULT_ORG, { stage: "plan", status: "escalated", reworks: 0, reason: "질문" }, []).human).toContain("질문"); + }); +}); diff --git a/packages/core/src/handoff.ts b/packages/core/src/handoff.ts new file mode 100644 index 0000000..71e7ec7 --- /dev/null +++ b/packages/core/src/handoff.ts @@ -0,0 +1,71 @@ +import { STAGE_LABEL, type Org, type Stage } from "./org"; +import type { Report } from "./report"; +import { routeTask } from "./routing"; +import type { TaskState } from "./task"; + +export const OUTCOME_LABEL: Record = { + completed: "완료", + changes_requested: "수정 요청", + blocked: "진행 불가", +}; + +/** 팀 보고 본문 (Markdown). 인계 자료와 화면에 함께 쓴다. */ +export function reportBody(report: Report): string { + const section = (title: string, items: string[]) => (items.length ? `**${title}**\n${items.map((item) => `- ${item}`).join("\n")}` : ""); + return [ + section("변경", report.changes), + section("검증", report.verification), + section("수정 요청", report.findings), + section("질문", report.questions), + section("비고", report.notes), + ] + .filter(Boolean) + .join("\n\n"); +} + +export type HandoffEntry = { + stage: Stage; + teamName: string; + divisionName: string; + outcome: Report["outcome"]; + summary: string; + body: string; +}; + +/** + * 앞 팀들의 보고를 다음 팀 브리프에 넣을 인계 자료로 만든다. + * 길이가 넘치면 오래된 보고부터 본문을 빼고 요약만 남긴다. + */ +export function buildHandoff(entries: readonly HandoffEntry[], maxChars = 6000): string { + if (entries.length === 0) return ""; + const render = (entry: HandoffEntry, withBody: boolean) => + [`### [${STAGE_LABEL[entry.stage]}] ${entry.divisionName} ${entry.teamName} — ${OUTCOME_LABEL[entry.outcome]}`, entry.summary, withBody ? entry.body : ""] + .filter(Boolean) + .join("\n\n"); + + const blocks = entries.map((entry) => render(entry, true)); + for (let i = 0; i < blocks.length && blocks.join("\n\n").length > maxChars; i++) { + blocks[i] = render(entries[i]!, false); + } + let text = blocks.join("\n\n"); + if (text.length > maxChars) text = `…(앞부분 생략)\n\n${text.slice(text.length - maxChars)}`; + return text; +} + +export type NextStep = { teamId: string | null; human: string | null }; + +/** 상태 전이 후 다음 담당 (팀 또는 사람) */ +export function nextStep(org: Org, state: TaskState, labels: readonly string[]): NextStep { + switch (state.status) { + case "queued": + return { teamId: routeTask(org, { stage: state.stage, labels }).team.id, human: null }; + case "awaiting_merge": + return { teamId: null, human: "PR 검토와 merge" }; + case "awaiting_deploy": + return { teamId: null, human: "production 배포" }; + case "escalated": + return { teamId: null, human: `사람 확인${state.reason ? `: ${state.reason}` : ""}` }; + default: + return { teamId: null, human: null }; + } +} diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index ac9638a..38579fe 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -6,3 +6,4 @@ export * from "./policy"; export * from "./git"; export * from "./budget"; export * from "./report"; +export * from "./handoff"; diff --git a/packages/db/drizzle/0002_loving_ricochet.sql b/packages/db/drizzle/0002_loving_ricochet.sql new file mode 100644 index 0000000..509015e --- /dev/null +++ b/packages/db/drizzle/0002_loving_ricochet.sql @@ -0,0 +1,20 @@ +CREATE TABLE "reports" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "task_id" uuid NOT NULL, + "run_id" uuid, + "level" text NOT NULL, + "stage" text NOT NULL, + "division_id" text NOT NULL, + "team_id" text, + "outcome" text NOT NULL, + "summary" text NOT NULL, + "body" text DEFAULT '' NOT NULL, + "next_team_id" text, + "next_human" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "reports" ADD CONSTRAINT "reports_task_id_tasks_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."tasks"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "reports" ADD CONSTRAINT "reports_run_id_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "reports_task_idx" ON "reports" USING btree ("task_id","created_at");--> statement-breakpoint +CREATE INDEX "reports_created_idx" ON "reports" USING btree ("created_at"); \ No newline at end of file diff --git a/packages/db/drizzle/meta/0002_snapshot.json b/packages/db/drizzle/meta/0002_snapshot.json new file mode 100644 index 0000000..36659e7 --- /dev/null +++ b/packages/db/drizzle/meta/0002_snapshot.json @@ -0,0 +1,822 @@ +{ + "id": "6db02269-beed-483c-9d01-9b43a38c0cd1", + "prevId": "ab22c92e-67b3-41db-ac0a-0037df851139", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.agents": { + "name": "agents", + "schema": "", + "columns": { + "role_id": { + "name": "role_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_version": { + "name": "agent_version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "config_hash": { + "name": "config_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.approvals": { + "name": "approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_use_id": { + "name": "tool_use_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "command": { + "name": "command", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decided_by": { + "name": "decided_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "decided_at": { + "name": "decided_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "approvals_tool_use_idx": { + "name": "approvals_tool_use_idx", + "columns": [ + { + "expression": "tool_use_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "approvals_status_idx": { + "name": "approvals_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "approvals_task_id_tasks_id_fk": { + "name": "approvals_task_id_tasks_id_fk", + "tableFrom": "approvals", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "approvals_run_id_runs_id_fk": { + "name": "approvals_run_id_runs_id_fk", + "tableFrom": "approvals", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.org_versions": { + "name": "org_versions", + "schema": "", + "columns": { + "version": { + "name": "version", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "edited_by": { + "name": "edited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reports": { + "name": "reports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "division_id": { + "name": "division_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "outcome": { + "name": "outcome", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "next_team_id": { + "name": "next_team_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_human": { + "name": "next_human", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reports_task_idx": { + "name": "reports_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reports_created_idx": { + "name": "reports_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reports_task_id_tasks_id_fk": { + "name": "reports_task_id_tasks_id_fk", + "tableFrom": "reports", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "reports_run_id_runs_id_fk": { + "name": "reports_run_id_runs_id_fk", + "tableFrom": "reports", + "tableTo": "runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.runs": { + "name": "runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "division_id": { + "name": "division_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "budget_cents": { + "name": "budget_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cost_cents": { + "name": "cost_cents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "report": { + "name": "report", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "runs_task_idx": { + "name": "runs_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runs_division_month_idx": { + "name": "runs_division_month_idx", + "columns": [ + { + "expression": "division_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "runs_task_id_tasks_id_fk": { + "name": "runs_task_id_tasks_id_fk", + "tableFrom": "runs", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.task_events": { + "name": "task_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor": { + "name": "actor", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "task_events_task_idx": { + "name": "task_events_task_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "task_events_task_id_tasks_id_fk": { + "name": "task_events_task_id_tasks_id_fk", + "tableFrom": "task_events", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_number": { + "name": "issue_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "labels": { + "name": "labels", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "stage": { + "name": "stage", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reworks": { + "name": "reworks", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pr_number": { + "name": "pr_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "spec": { + "name": "spec", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "findings": { + "name": "findings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tasks_repo_issue_idx": { + "name": "tasks_repo_issue_idx", + "columns": [ + { + "expression": "repo", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issue_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_status_idx": { + "name": "tasks_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json index 68e825c..4b0052b 100644 --- a/packages/db/drizzle/meta/_journal.json +++ b/packages/db/drizzle/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1794290080583, "tag": "0001_material_robin_chapel", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1794291283513, + "tag": "0002_loving_ricochet", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index b6c76e9..d92fe65 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -124,3 +124,36 @@ export const settings = pgTable("settings", { value: text("value").notNull(), updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(), }); + +export const REPORT_LEVELS = ["team", "division"] as const; +export type ReportLevel = (typeof REPORT_LEVELS)[number]; + +/** + * 팀·본부 보고. 팀 세션이 끝나면 팀 보고, 단계가 끝나면 참여 본부별 종합 보고를 남긴다. + * 다음 단계 팀의 브리프에 인계 자료로 들어간다. + */ +export const reports = pgTable( + "reports", + { + id: uuid("id").primaryKey().defaultRandom(), + taskId: uuid("task_id") + .notNull() + .references(() => tasks.id, { onDelete: "cascade" }), + runId: uuid("run_id").references(() => runs.id, { onDelete: "set null" }), + level: text("level").$type().notNull(), + stage: text("stage").$type().notNull(), + divisionId: text("division_id").notNull(), + /** 본부 보고는 null */ + teamId: text("team_id"), + outcome: text("outcome").$type().notNull(), + summary: text("summary").notNull(), + /** 인계용 상세 (Markdown) */ + body: text("body").notNull().default(""), + /** 다음에 일을 넘겨받는 팀 (없으면 사람 또는 종료) */ + nextTeamId: text("next_team_id"), + /** 다음 담당이 사람일 때 설명 (merge, 배포 등) */ + nextHuman: text("next_human"), + createdAt: createdAt(), + }, + (table) => [index("reports_task_idx").on(table.taskId, table.createdAt), index("reports_created_idx").on(table.createdAt)], +); From af2b9850c2de38f280a8f2f1cdc3dbe2fc618100 Mon Sep 17 00:00:00 2001 From: Jiwan SEO Date: Tue, 10 Nov 2026 15:19:06 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20(feat)=20#11=20::=20=ED=8C=80?= =?UTF-8?q?=20=EC=84=B8=EC=85=98=EB=A7=88=EB=8B=A4=20=ED=8C=80=20=EB=B3=B4?= =?UTF-8?q?=EA=B3=A0,=20=EB=8B=A8=EA=B3=84=EB=A7=88=EB=8B=A4=20=EB=B3=B8?= =?UTF-8?q?=EB=B6=80=20=EB=B3=B4=EA=B3=A0=EB=A5=BC=20=EB=82=A8=EA=B8=B0?= =?UTF-8?q?=EA=B3=A0=20=EB=8B=A4=EC=9D=8C=20=ED=8C=80=20=EB=B8=8C=EB=A6=AC?= =?UTF-8?q?=ED=94=84=EC=97=90=20=EC=9D=B8=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/worker/src/brief.ts | 21 ++++++ apps/worker/src/flow.test.ts | 28 +++++++- apps/worker/src/orchestrator.ts | 109 ++++++++++++++++++++++++++++++-- apps/worker/src/unit.test.ts | 8 +++ 4 files changed, 161 insertions(+), 5 deletions(-) diff --git a/apps/worker/src/brief.ts b/apps/worker/src/brief.ts index 94d6c68..936c839 100644 --- a/apps/worker/src/brief.ts +++ b/apps/worker/src/brief.ts @@ -8,6 +8,8 @@ export type BriefInput = { reviewer?: { teamName: string }; /** 기획 단계에서 확정된 명세 */ spec: string; + /** 앞 팀들의 보고 (인계 자료) */ + handoff: string; repo: string; issueNumber: number | null; title: string; @@ -37,6 +39,15 @@ function issueBlock(input: BriefInput): string { ].join("\n"); } +function handoffBlock(input: BriefInput): string { + if (!input.handoff) return ""; + return [ + "## 이전 팀 보고 (인계)", + "앞서 일한 팀들의 보고다. 이미 확인된 내용은 다시 조사하지 말고 이어서 진행한다. 보고와 실제 코드가 다르면 코드를 기준으로 하고 그 차이를 보고에 적는다.", + quoted(input.handoff), + ].join("\n"); +} + function specBlock(input: BriefInput): string { if (!input.spec) return ""; return ["## 기획 명세", "기획본부가 확정한 명세다. 수용 기준을 기준으로 작업한다.", quoted(input.spec)].join("\n"); @@ -57,6 +68,8 @@ export function buildBrief(input: BriefInput): string { "", issueBlock(input), "", + handoffBlock(input), + "", "## 기획 단계", focus, "1. 레포의 README, CLAUDE.md, 관련 코드를 읽고 현재 동작을 파악한다. 파일을 수정하지 않는다.", @@ -76,6 +89,8 @@ export function buildBrief(input: BriefInput): string { "", issueBlock(input), "", + handoffBlock(input), + "", specBlock(input), "", rework ? `## 검증팀 수정 요청 (재작업 ${input.findings.length}건)\n${input.findings.map((item) => `- ${item}`).join("\n")}` : "", @@ -102,6 +117,8 @@ export function buildBrief(input: BriefInput): string { "", issueBlock(input), "", + handoffBlock(input), + "", specBlock(input), "", `## 검증 대상: PR #${input.prNumber} (브랜치 ${input.branch}, checkout 되어 있음)`, @@ -119,6 +136,8 @@ export function buildBrief(input: BriefInput): string { "", issueBlock(input), "", + handoffBlock(input), + "", specBlock(input), "", `## 배포 준비 참여: PR #${input.prNumber} 가 ${input.baseBranch} 에 merge 되었다.`, @@ -132,6 +151,8 @@ export function buildBrief(input: BriefInput): string { "", issueBlock(input), "", + handoffBlock(input), + "", `## 릴리스 준비: PR #${input.prNumber} 가 ${input.baseBranch} 에 merge 되었다.`, "1. 최신 기본 브랜치에서 install, build, test 를 실행해 merge 결과가 깨지지 않았는지 확인한다.", "2. 레포에 staging 배포 방법이 문서화되어 있으면 그 결과를 확인하는 방법을 정리한다. 배포 명령은 실행하지 않는다.", diff --git a/apps/worker/src/flow.test.ts b/apps/worker/src/flow.test.ts index 21639d7..0e30060 100644 --- a/apps/worker/src/flow.test.ts +++ b/apps/worker/src/flow.test.ts @@ -112,7 +112,7 @@ describe.skipIf(!url)("작업 흐름 (Postgres)", () => { }); beforeEach(async () => { - await db.execute(sql`truncate table task_events, approvals, runs, tasks, agents, settings, org_versions restart identity cascade`); + await db.execute(sql`truncate table reports, task_events, approvals, runs, tasks, agents, settings, org_versions restart identity cascade`); const version = await saveOrg(db, DEFAULT_ORG, "test"); await setSetting(db, SYNCED_ORG_SETTING, String(version)); await setSetting(db, ENVIRONMENT_SETTING, "env_test"); @@ -172,6 +172,9 @@ describe.skipIf(!url)("작업 흐름 (Postgres)", () => { const implement = calls.find((call) => call.stage === "implement")!; expect(implement.input.checkoutBranch).toBe("main"); expect(implement.input.brief).toContain("footer 링크 수정"); + // 기획본부 보고가 구현팀에 인계된다 + expect(implement.input.brief).toContain("## 이전 팀 보고 (인계)"); + expect(implement.input.brief).toContain("[기획] 기획본부 디자인팀 — 완료"); github.changed = ["app/auth/session.ts", "package.json"]; // 보안 경로 → 보안팀, package.json → 법무팀 await step(); // 검증 1회차: 수정 요청 @@ -185,6 +188,8 @@ describe.skipIf(!url)("작업 흐름 (Postgres)", () => { expect(rework.input.brief).toContain("app/footer.tsx:8 테스트 누락"); expect(github.prs).toHaveLength(1); + // 재구현 팀은 검증팀의 수정 요청 보고까지 인계받는다 + expect(rework.input.brief).toContain("[검증] 품질본부 QA팀 — 수정 요청"); await step(); // 검증 2회차: QA + 보안 통과 task = await currentTask(); expect(task).toMatchObject({ stage: "verify", status: "awaiting_merge" }); @@ -207,6 +212,27 @@ describe.skipIf(!url)("작업 흐름 (Postgres)", () => { await orchestrator.applyById(task.id, { type: "deploy_approved" }, "xixn2"); expect((await currentTask()).status).toBe("done"); + // 팀 보고는 세션마다, 본부 보고는 단계·본부마다 남는다 + const allReports = await db.select().from(schema.reports).orderBy(schema.reports.createdAt); + const teamReports = allReports.filter((report) => report.level === "team"); + expect(teamReports).toHaveLength(calls.length); + const divisionReports = allReports.filter((report) => report.level === "division"); + expect(divisionReports.map((report) => `${report.stage}:${report.divisionId}`)).toEqual([ + "plan:planning", + "implement:product", + "verify:quality", + "verify:risk", + "implement:product", + "verify:quality", + "verify:risk", + "release:operations", + "release:business", + ]); + expect(divisionReports[0]).toMatchObject({ nextTeamId: "web", outcome: "completed" }); + expect(divisionReports[2]).toMatchObject({ nextTeamId: "web", outcome: "changes_requested" }); + expect(divisionReports[5]).toMatchObject({ nextTeamId: null, nextHuman: "PR 검토와 merge" }); + expect(divisionReports[7]).toMatchObject({ nextHuman: "production 배포" }); + const runs = await db.select().from(schema.runs); expect(runs.every((run) => run.status === "completed" && run.costCents === 120)).toBe(true); }); diff --git a/apps/worker/src/orchestrator.ts b/apps/worker/src/orchestrator.ts index c9fe3bd..3df2514 100644 --- a/apps/worker/src/orchestrator.ts +++ b/apps/worker/src/orchestrator.ts @@ -1,6 +1,11 @@ import type Anthropic from "@anthropic-ai/sdk"; import { GITMOJI, + OUTCOME_LABEL, + buildHandoff, + findTeam, + nextStep, + reportBody, branchName, branchTypeFor, checkDivisionBudget, @@ -176,7 +181,7 @@ export class Orchestrator { const results: { ref: TeamRef; result: RunResult }[] = []; for (const ref of teams) { - const result = await this.runTeam(task, ref, environmentId, baseBranch); + const result = await this.runTeam(org, task, ref, environmentId, baseBranch); results.push({ ref, result }); if (!result.ok) break; } @@ -184,10 +189,77 @@ export class Orchestrator { const failed = results.find((item) => !item.result.ok); if (failed && !failed.result.ok) { await this.escalate(task.id, `${failed.ref.team.name}: ${failed.result.error}`); + await this.reportDivisions(org, task, results); return; } const reports = results.map((item) => ({ ref: item.ref, report: (item.result as Extract).report })); await this.applyReports(task, reports, baseBranch); + await this.reportDivisions(org, task, results); + } + + /** + * 단계가 끝나면 참여한 본부마다 종합 보고를 남긴다 (본부장 명의). + * 다음 담당(팀 또는 사람)을 함께 적어 본부 사이의 인계를 드러낸다. + */ + private async reportDivisions(org: Org, task: Task, results: { ref: TeamRef; result: RunResult }[]): Promise { + const { db } = this.deps; + const [current] = await db.select().from(schema.tasks).where(eq(schema.tasks.id, task.id)); + if (!current) return; + const next = nextStep(org, { stage: current.stage, status: current.status, reworks: current.reworks, reason: current.reason }, current.labels); + const nextLabel = next.teamId ? (findTeam(org, next.teamId)?.team.name ?? next.teamId) : (next.human ?? "완료"); + + const byDivision = new Map(); + for (const item of results) { + const list = byDivision.get(item.ref.division.id) ?? []; + list.push(item); + byDivision.set(item.ref.division.id, list); + } + + for (const items of byDivision.values()) { + const division = items[0]!.ref.division; + const outcomes = items.map((item) => (item.result.ok ? item.result.report.outcome : "blocked")); + const outcome = outcomes.includes("blocked") ? "blocked" : outcomes.includes("changes_requested") ? "changes_requested" : "completed"; + const lines = items.map((item) => + item.result.ok + ? `- ${item.ref.team.name}: ${OUTCOME_LABEL[item.result.report.outcome]} — ${item.result.report.summary}` + : `- ${item.ref.team.name}: 진행 불가 — ${item.result.error}`, + ); + const summary = `${items.map((item) => item.ref.team.name).join("·")} ${OUTCOME_LABEL[outcome]} → ${nextLabel}`; + await db.insert(schema.reports).values({ + taskId: task.id, + level: "division", + stage: task.stage, + divisionId: division.id, + outcome, + summary, + body: lines.join("\n"), + nextTeamId: next.teamId, + nextHuman: next.human, + }); + await addTaskEvent(db, task.id, `${division.name} ${division.head.name} 본부장`, `본부 보고: ${summary}`); + } + } + + /** 앞 팀들의 보고로 인계 자료를 만든다 */ + private async handoffFor(org: Org, taskId: string): Promise { + const prior = await this.deps.db + .select() + .from(schema.reports) + .where(and(eq(schema.reports.taskId, taskId), eq(schema.reports.level, "team"))) + .orderBy(schema.reports.createdAt); + return buildHandoff( + prior.map((row) => { + const ref = row.teamId ? findTeam(org, row.teamId) : undefined; + return { + stage: row.stage, + teamName: ref?.team.name ?? row.teamId ?? "-", + divisionName: ref?.division.name ?? row.divisionId, + outcome: row.outcome, + summary: row.summary, + body: row.body, + }; + }), + ); } /** 주 담당 팀 + 조건부 팀 (검증 단계는 PR 변경 파일로 판단) */ @@ -196,7 +268,7 @@ export class Orchestrator { return teamsForStage(org, { stage: task.stage, labels: task.labels, changedFiles }); } - private async runTeam(task: Task, ref: TeamRef, environmentId: string, baseBranch: string): Promise { + private async runTeam(org: Org, task: Task, ref: TeamRef, environmentId: string, baseBranch: string): Promise { const { db, anthropic, github, config, log } = this.deps; const spend = await monthlySpendByDivision(db); @@ -205,7 +277,18 @@ export class Orchestrator { spentThisMonthCents: spend.get(ref.division.id) ?? 0, sessionBudgetCents: ref.team.sessionBudgetCents, }); - if (!budget.ok) return { ok: false, sessionId: null, error: budget.reason, costCents: 0 }; + if (!budget.ok) { + await db.insert(schema.reports).values({ + taskId: task.id, + level: "team", + stage: task.stage, + divisionId: ref.division.id, + teamId: ref.team.id, + outcome: "blocked", + summary: budget.reason, + }); + return { ok: false, sessionId: null, error: budget.reason, costCents: 0 }; + } const [run] = await db .insert(schema.runs) @@ -223,6 +306,7 @@ export class Orchestrator { stage: task.stage, ...(ref.team.assignment === "conditional" ? { reviewer: { teamName: ref.team.name } } : {}), spec: task.spec, + handoff: await this.handoffFor(org, task.id), repo: task.repo, issueNumber: task.issueNumber, title: task.title, @@ -271,7 +355,24 @@ export class Orchestrator { finishedAt: new Date(), }) .where(eq(schema.runs.id, run.id)); - await addTaskEvent(db, task.id, ref.team.name, result.ok ? `보고: ${result.report.summary}` : `실패: ${result.error}`); + await db.insert(schema.reports).values({ + taskId: task.id, + runId: run.id, + level: "team", + stage: task.stage, + divisionId: ref.division.id, + teamId: ref.team.id, + outcome: result.ok ? result.report.outcome : "blocked", + summary: result.ok ? result.report.summary : result.error, + body: result.ok ? reportBody(result.report) : "", + }); + const lead = ref.team.roles.find((role) => role.rank === "팀장"); + await addTaskEvent( + db, + task.id, + `${ref.team.name}${lead ? ` ${lead.person.name} 팀장` : ""}`, + result.ok ? `팀 보고(${OUTCOME_LABEL[result.report.outcome]}): ${result.report.summary}` : `팀 보고(진행 불가): ${result.error}`, + ); return result; } diff --git a/apps/worker/src/unit.test.ts b/apps/worker/src/unit.test.ts index 47e8947..8a177cf 100644 --- a/apps/worker/src/unit.test.ts +++ b/apps/worker/src/unit.test.ts @@ -112,6 +112,7 @@ describe("브리프", () => { commitType: "feat", gitmoji: "✨", spec: "", + handoff: "", }; it("Issue 본문은 자료 블록에 가두고 블록을 닫는 문자열을 무력화한다", () => { @@ -142,6 +143,13 @@ describe("브리프", () => { expect(brief).toContain("questions"); }); + it("앞 팀 보고가 있으면 인계 섹션으로 넣는다", () => { + expect(buildBrief(base)).not.toContain("이전 팀 보고"); + const brief = buildBrief({ ...base, stage: "verify", prNumber: 3, handoff: "### [구현] 제품개발본부 Web팀 — 완료\n\nfooter 수정" }); + expect(brief).toContain("## 이전 팀 보고 (인계)"); + expect(brief).toContain("footer 수정"); + }); + it("구현 브리프에 기획 명세를 자료로 넣는다", () => { const brief = buildBrief({ ...base, spec: "- [ ] footer 링크가 /contact 로 이동" }); expect(brief).toContain("## 기획 명세"); From 8ebdc2bc5232b30b04b35fea31aa36330245ea95 Mon Sep 17 00:00:00 2001 From: Jiwan SEO Date: Tue, 10 Nov 2026 15:19:06 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20(feat)=20#11=20::=20=EB=B3=B4?= =?UTF-8?q?=EA=B3=A0=20=ED=99=94=EB=A9=B4(=EB=B3=B8=EB=B6=80=EB=B3=84=207?= =?UTF-8?q?=EC=9D=BC=20=ED=98=84=ED=99=A9=C2=B7=EB=B3=B4=EA=B3=A0=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C)=EA=B3=BC=20=EC=9E=91=EC=97=85=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EB=B3=B4=EA=B3=A0=20=ED=9D=90=EB=A6=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/app/globals.css | 221 +++++++++++++++++++++++++++ apps/web/app/nav.tsx | 1 + apps/web/app/reports/page.tsx | 107 +++++++++++++ apps/web/app/tasks/[taskId]/page.tsx | 24 ++- apps/web/components/report-card.tsx | 55 +++++++ apps/web/lib/data.ts | 109 ++++++++++++- 6 files changed, 514 insertions(+), 3 deletions(-) create mode 100644 apps/web/app/reports/page.tsx create mode 100644 apps/web/components/report-card.tsx diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css index 21dd702..05a8198 100644 --- a/apps/web/app/globals.css +++ b/apps/web/app/globals.css @@ -1552,3 +1552,224 @@ body:has(.bleed) .site-header__inner { grid-column: auto; } } + +/* ───────── reports ───────── */ +.week { + margin-bottom: 32px; +} + +.week__grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); + gap: 12px; +} + +.week__card { + padding: 14px 16px; + border: 1px solid var(--line); + border-radius: var(--radius); + background: var(--surface); + display: flex; + flex-direction: column; + gap: 10px; +} + +.week__head { + display: flex; + align-items: center; + gap: 10px; + font-size: 14px; +} + +.week__stats { + display: grid; + grid-template-columns: repeat(5, minmax(0, 1fr)); + gap: 4px; + margin: 0; +} + +.week__stats dt { + font-size: 11px; + color: var(--muted); +} + +.week__stats dd { + margin: 0; + font-weight: 600; + font-variant-numeric: tabular-nums; + font-size: 15px; +} + +.week__stats .is-bad { + color: #dc2626; +} + +.week__latest { + font-size: 13px; + color: var(--muted); + border-top: 1px solid var(--line); + padding-top: 8px; +} + +.feed__head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + flex-wrap: wrap; +} + +.segmented { + display: inline-flex; + border: 1px solid var(--line-strong); + border-radius: 8px; + padding: 2px; + background: var(--surface); +} + +.segmented a { + padding: 4px 12px; + border-radius: 6px; + font-size: 13px; + text-decoration: none; + color: var(--muted); +} + +.segmented a:hover { + color: var(--text); +} + +.segmented a[aria-current="page"] { + background: var(--text); + color: var(--bg); +} + +.feed__list { + display: flex; + flex-direction: column; + gap: 8px; + max-width: 1100px; +} + +.report { + display: flex; + gap: 12px; + padding: 12px 14px; + border: 1px solid var(--line); + border-left-width: 3px; + border-radius: var(--radius); + background: var(--surface); +} + +.report--division { + background: var(--bg); + border-style: solid; +} + +.report--completed { + border-left-color: var(--working); +} + +.report--changes_requested { + border-left-color: var(--human); +} + +.report--blocked { + border-left-color: #dc2626; +} + +.report__main { + min-width: 0; + flex: 1; + display: flex; + flex-direction: column; + gap: 4px; +} + +.report__head { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 4px 10px; + font-size: 13px; + color: var(--muted); +} + +.report__author strong { + color: var(--text); +} + +.report__kind { + font-size: 11px; + font-weight: 600; + padding: 0 6px; + border: 1px solid var(--line-strong); + border-radius: 4px; +} + +.report__head time { + margin-left: auto; + font-size: 12px; +} + +.outcome { + font-size: 12px; + font-weight: 600; +} + +.outcome--completed { + color: var(--working); +} + +.outcome--changes_requested { + color: var(--human); +} + +.outcome--blocked { + color: #dc2626; +} + +.report__task { + font-size: 13px; + font-weight: 600; + text-decoration: none; +} + +.report__task:hover { + text-decoration: underline; +} + +.report__summary { + font-size: 14px; +} + +.report__body summary { + cursor: pointer; + font-size: 12px; + color: var(--muted); +} + +.report__body pre { + white-space: pre-wrap; + word-break: break-word; + font-family: var(--font); + font-size: 13px; + margin: 6px 0 0; + padding: 10px 12px; + border-radius: 6px; + background: var(--bg); + border: 1px solid var(--line); +} + +.report__next { + font-size: 13px; + color: var(--muted); +} + +.report__next strong { + color: var(--text); +} + +.report-flow { + margin-bottom: 24px; +} diff --git a/apps/web/app/nav.tsx b/apps/web/app/nav.tsx index fff5481..f5f4260 100644 --- a/apps/web/app/nav.tsx +++ b/apps/web/app/nav.tsx @@ -7,6 +7,7 @@ const LINKS = [ { href: "/", label: "조직도" }, { href: "/office", label: "자리 배치도" }, { href: "/tasks", label: "작업" }, + { href: "/reports", label: "보고" }, { href: "/approvals", label: "승인함" }, { href: "/settings", label: "설정" }, ] as const; diff --git a/apps/web/app/reports/page.tsx b/apps/web/app/reports/page.tsx new file mode 100644 index 0000000..00b343c --- /dev/null +++ b/apps/web/app/reports/page.tsx @@ -0,0 +1,107 @@ +import type { Metadata } from "next"; +import { Avatar } from "@/components/avatar"; +import { ReportCard } from "@/components/report-card"; +import { getDivisionWeek, getOrg, getRecentReports, isPreview } from "@/lib/data"; +import { formatUsd } from "@/lib/format"; +import { PreviewBanner } from "../notice"; + +export const metadata: Metadata = { title: "보고" }; +export const dynamic = "force-dynamic"; + +type Props = { searchParams: Promise<{ level?: string }> }; + +export default async function ReportsPage({ searchParams }: Props) { + const [org, week, reports, query] = await Promise.all([getOrg(), getDivisionWeek(), getRecentReports(), searchParams]); + const level = query.level === "division" || query.level === "team" ? query.level : "all"; + const visible = level === "all" ? reports : reports.filter((report) => report.level === level); + + return ( +
+
+
+

보고

+

팀은 세션을 마칠 때마다 팀장이 보고하고, 단계가 끝나면 본부장이 본부 보고와 함께 다음 팀에 일을 넘깁니다.

+
+
+ {isPreview() && } + +
+

+ 본부별 최근 7일 +

+
    + {org.divisions.map((division) => { + const stats = week.get(division.id); + return ( +
  • +
    + +
    + {division.name} + · {division.head.name} 본부장 +
    +
    +
    +
    +
    세션
    +
    {stats?.sessions ?? 0}
    +
    +
    +
    완료
    +
    {stats?.completed ?? 0}
    +
    +
    +
    수정 요청
    +
    {stats?.changesRequested ?? 0}
    +
    +
    +
    진행 불가
    +
    {stats?.blocked ?? 0}
    +
    +
    +
    사용
    +
    {formatUsd(stats?.costCents ?? 0)}
    +
    +
    +

    {stats?.latest ? stats.latest.summary : "최근 본부 보고가 없습니다"}

    +
  • + ); + })} +
+
+ +
+ + {visible.length === 0 ? ( +
+

아직 보고가 없습니다

+

작업이 접수되어 팀 세션이 끝나면 이곳에 보고가 쌓입니다.

+
+ ) : ( +
    + {visible.map((report) => ( +
  1. + +
  2. + ))} +
+ )} +
+
+ ); +} diff --git a/apps/web/app/tasks/[taskId]/page.tsx b/apps/web/app/tasks/[taskId]/page.tsx index a4abd78..1029ca6 100644 --- a/apps/web/app/tasks/[taskId]/page.tsx +++ b/apps/web/app/tasks/[taskId]/page.tsx @@ -2,7 +2,8 @@ import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { STAGE_LABEL, STATUS_LABEL } from "@offai/core"; -import { getOrg, getTask, type RunSummary } from "@/lib/data"; +import { ReportCard } from "@/components/report-card"; +import { getOrg, getTask, getTaskReports, type RunSummary } from "@/lib/data"; import { formatDate, formatUsd } from "@/lib/format"; import { approveDeploy, retryTask } from "../../actions"; import { Notice } from "../../notice"; @@ -22,7 +23,7 @@ const RUN_STATUS = { running: "실행 중", completed: "완료", failed: "실패 export default async function TaskPage({ params, searchParams }: Props) { const [{ taskId }, query] = await Promise.all([params, searchParams]); - const [task, org] = await Promise.all([getTask(taskId), getOrg()]); + const [task, org, reports] = await Promise.all([getTask(taskId), getOrg(), getTaskReports(taskId)]); if (!task) notFound(); const teamName = (id: string | null) => org.divisions.flatMap((division) => division.teams).find((team) => team.id === id)?.name ?? id ?? "-"; const github = `https://github.com/${task.repo}`; @@ -90,6 +91,24 @@ export default async function TaskPage({ params, searchParams }: Props) { )}
+
+
+

+ 보고 흐름 {reports.length} +

+ {reports.length === 0 ? ( +

아직 보고가 없습니다.

+ ) : ( +
    + {reports.map((report) => ( +
  1. + +
  2. + ))} +
+ )} +
+

팀 세션 {task.runs.length} @@ -117,6 +136,7 @@ export default async function TaskPage({ params, searchParams }: Props) { )}

+