diff --git a/.agent/project.md b/.agent/project.md index aa4bd5a..f02aacf 100644 --- a/.agent/project.md +++ b/.agent/project.md @@ -18,7 +18,7 @@ ### Harness Integration - Generated projects default to `requested-project`; allow the supported explicit project-type override without changing the fixed `frontend` layer. -- When the central harness is available, register the project locally and run compose followed by verify. Central-harness absence must not prevent project creation. +- When the central harness is available, register the project in shared `workspace.yml` by default and run compose followed by verify. Allow an explicit local-registration override, and do not perform Git commits. Central-harness absence must not prevent project creation. - `AGENTS.md` and `CLAUDE.md` in this repository are harness-generated outputs. Never edit either file directly; edit `.agent` sources and recompose. - Do not commit user-specific absolute harness paths or credentials. Explicit paths are runtime inputs only. diff --git a/AGENTS.md b/AGENTS.md index f7bca2b..3ee9121 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -303,7 +303,7 @@ When implementing or changing frontend UI, use this order: ### Harness Integration - Generated projects default to `requested-project`; allow the supported explicit project-type override without changing the fixed `frontend` layer. -- When the central harness is available, register the project locally and run compose followed by verify. Central-harness absence must not prevent project creation. +- When the central harness is available, register the project in shared `workspace.yml` by default and run compose followed by verify. Allow an explicit local-registration override, and do not perform Git commits. Central-harness absence must not prevent project creation. - `AGENTS.md` and `CLAUDE.md` in this repository are harness-generated outputs. Never edit either file directly; edit `.agent` sources and recompose. - Do not commit user-specific absolute harness paths or credentials. Explicit paths are runtime inputs only. diff --git a/README.md b/README.md index f9925b5..55f7c81 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ Agent Harness 관련 기본값과 옵션: --project-type requested-project|internal-service|shared-service --agent-project-id 하네스 프로젝트 ID (기본: 프로젝트명 slug) --harness-root 중앙 Agent Harness 저장소 경로 +--agent-registration + 중앙 등록 범위 (기본 shared) --skip-agent-compose 하네스 자동 등록·합성·검증 생략 ``` @@ -53,7 +55,7 @@ Agent Harness 관련 기본값과 옵션: 4. KRI UI Registry 9개 항목 설치 5. TypeScript 검사 6. Next.js production build -7. Agent Harness 로컬 등록, `AGENTS.md`/`CLAUDE.md` 합성 및 검증 +7. Agent Harness 공유 등록, `AGENTS.md`/`CLAUDE.md` 합성 및 검증 UI Registry: `https://ui-registry.kric.com/r` @@ -67,7 +69,7 @@ UI Registry: `https://ui-registry.kric.com/r` 2. `KRI_AGENT_HARNESS_ROOT` 환경변수 3. 생성 경로의 상위 디렉터리 -하네스를 발견하면 프로젝트를 `workspace.local.yml`에 등록하고 `compose`, `verify`를 실행합니다. 하네스를 찾지 못해도 프로젝트 생성은 완료되며, 이 경우 `.agent` 원본을 중앙 하네스에서 나중에 등록·합성해야 합니다. +하네스를 발견하면 기본적으로 프로젝트를 공유 `workspace.yml`에 등록하고 `compose`, `verify`를 실행합니다. 일회성 로컬 등록은 `--agent-registration local`로 선택할 수 있습니다. 하네스를 찾지 못해도 프로젝트 생성은 완료되며, 이 경우 `.agent` 원본을 중앙 하네스에서 나중에 등록·합성해야 합니다. 중앙 저장소와 생성 프로젝트의 Git 커밋은 자동으로 수행하지 않습니다. ## 생성되는 환경 파일 diff --git a/package-lock.json b/package-lock.json index 4e25da5..e8c308a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@kri/create-next-app", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@kri/create-next-app", - "version": "0.1.2", + "version": "0.1.3", "license": "UNLICENSED", "bin": { "kri-create-next-app": "dist/cli.js" diff --git a/package.json b/package.json index f834fc7..4feb708 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kri/create-next-app", - "version": "0.1.2", + "version": "0.1.3", "description": "Create a KRI standard Next.js application", "type": "module", "bin": { @@ -15,6 +15,7 @@ "clean": "rimraf dist", "build": "npm run clean && tsc -p tsconfig.json", "typecheck": "tsc -p tsconfig.json --noEmit", + "test": "npm run build && node --test", "prepack": "npm run build" }, "engines": { diff --git a/src/args.ts b/src/args.ts index 128d860..3c440ef 100644 --- a/src/args.ts +++ b/src/args.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import type { ParsedArguments, ProjectType } from "./types.js"; +import type { AgentRegistration, ParsedArguments, ProjectType } from "./types.js"; const requireValue = (args: string[], index: number, option: string): string => { const value = args[index + 1]; @@ -18,6 +18,11 @@ export const parseProjectType = (value: string): ProjectType => { ); }; +export const parseAgentRegistration = (value: string): AgentRegistration => { + if (value === "shared" || value === "local") return value; + throw new Error("--agent-registration은 shared 또는 local이어야 합니다."); +}; + export function parseArguments(argv: string[]): ParsedArguments { const parsed: ParsedArguments = { yes: false, @@ -25,6 +30,7 @@ export function parseArguments(argv: string[]): ParsedArguments { installUi: true, build: true, jenkins: true, + agentRegistration: "shared", skipAgentCompose: false, force: false, help: false, @@ -80,6 +86,10 @@ export function parseArguments(argv: string[]): ParsedArguments { parsed.harnessRoot = path.resolve(requireValue(argv, index, arg)); index += 1; break; + case "--agent-registration": + parsed.agentRegistration = parseAgentRegistration(requireValue(argv, index, arg)); + index += 1; + break; case "--target-dir": parsed.targetDir = path.resolve(requireValue(argv, index, arg)); index += 1; @@ -140,6 +150,8 @@ export function printHelp(): void { --project-type requested-project|internal-service|shared-service --agent-project-id 하네스 프로젝트 ID (기본: 프로젝트명 slug) --harness-root 중앙 Agent Harness 저장소 경로 + --agent-registration + 중앙 등록 범위 (기본 shared) --port 개발/실행 포트 (기본 4000) --repo-url Gitea 저장소 URL --app-root Ubuntu 배포 경로 diff --git a/src/cli.ts b/src/cli.ts index 0b5fbe0..95b911b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -101,6 +101,7 @@ async function resolveOptions(): Promise { build: parsed.build, jenkins, harnessRoot: parsed.harnessRoot, + agentRegistration: parsed.agentRegistration, skipAgentCompose: parsed.skipAgentCompose, force: parsed.force, }; diff --git a/src/harness.ts b/src/harness.ts index e969de4..d0cd4a3 100644 --- a/src/harness.ts +++ b/src/harness.ts @@ -10,6 +10,7 @@ interface HarnessOptions { targetDir: string; agentProjectId: string; harnessRoot?: string; + agentRegistration: "shared" | "local"; skipAgentCompose: boolean; } @@ -102,14 +103,16 @@ export async function composeAgentHarness(options: HarnessOptions): Promise rm(root, { recursive: true, force: true })); + return { harnessRoot, targetDir, logPath }; +} + +test("defaults to shared registration and accepts an explicit local override", () => { + assert.equal(parseArguments([]).agentRegistration, "shared"); + assert.equal( + parseArguments(["--agent-registration", "local"]).agentRegistration, + "local", + ); + assert.throws( + () => parseArguments(["--agent-registration", "invalid"]), + /shared 또는 local/, + ); +}); + +test("registers shared, composes, and verifies in deterministic order", async (t) => { + const { harnessRoot, targetDir, logPath } = await createFixture(t); + + await composeAgentHarness({ + targetDir, + agentProjectId: "sample-front", + harnessRoot, + agentRegistration: "shared", + skipAgentCompose: false, + }); + + const calls = (await readFile(logPath, "utf8")) + .trim() + .split("\n") + .map((line) => JSON.parse(line)); + assert.deepEqual(calls, [ + ["register", "--project", "sample-front", "--path", "sample-front", "--shared"], + ["compose", "--project", "sample-front"], + ["verify", "--project", "sample-front"], + ]); +});