diff --git a/.agent/project.md b/.agent/project.md index 595b419..cd3282e 100644 --- a/.agent/project.md +++ b/.agent/project.md @@ -9,7 +9,7 @@ ### Generated Backend Invariants -- Generated applications use Java 17, Spring Boot 3.5.7, the repository Gradle Wrapper, and `com.kri.common:starter:beta.1.6.3`. +- Generated applications use Java 17, Spring Boot 3.5.7, the repository Gradle Wrapper, and `com.kri.common:starter:beta.1.6.4`. - Keep the approved KriCommon version exact. Do not restore `latest.release` or another dynamic version. - Preserve the selected MySQL or MSSQL driver, profile configuration, JPA/QueryDSL structure, and optional MyBatis template behavior. - Generate `.agent/profile.yml`, `.agent/project.md`, and harness line-ending policy for every project. Never copy a stale precomposed `AGENTS.md` into the template. @@ -18,7 +18,7 @@ - Generated projects default to `requested-project`; allow the supported explicit project-type override without changing the fixed `backend` layer. - Include the selected database in the generated profile and declare consumption of the KriCommon contract. -- 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 6263738..dff0df1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -271,7 +271,7 @@ When implementation is complete, report in Korean: ### Generated Backend Invariants -- Generated applications use Java 17, Spring Boot 3.5.7, the repository Gradle Wrapper, and `com.kri.common:starter:beta.1.6.3`. +- Generated applications use Java 17, Spring Boot 3.5.7, the repository Gradle Wrapper, and `com.kri.common:starter:beta.1.6.4`. - Keep the approved KriCommon version exact. Do not restore `latest.release` or another dynamic version. - Preserve the selected MySQL or MSSQL driver, profile configuration, JPA/QueryDSL structure, and optional MyBatis template behavior. - Generate `.agent/profile.yml`, `.agent/project.md`, and harness line-ending policy for every project. Never copy a stale precomposed `AGENTS.md` into the template. @@ -280,7 +280,7 @@ When implementation is complete, report in Korean: - Generated projects default to `requested-project`; allow the supported explicit project-type override without changing the fixed `backend` layer. - Include the selected database in the generated profile and declare consumption of the KriCommon contract. -- 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 cc9bcea..635f368 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ KRI 표준 Spring Boot 프로젝트 생성 CLI입니다. - Java 17 - Spring Boot 3.5.7 - Gradle Groovy DSL / Gradle Wrapper 8.14.3 -- `com.kri.common:starter:beta.1.6.3` +- `com.kri.common:starter:beta.1.6.4` - JPA + QueryDSL + JdbcTemplate 벌크 처리 예제 - EmbeddedId 복합키 예제 - MyBatis 선택 설치 @@ -50,6 +50,8 @@ npx @kri/create-spring-app sample-server --project-type requested-project|internal-service|shared-service --agent-project-id 하네스 프로젝트 ID (기본: 프로젝트명 slug) --harness-root 중앙 Agent Harness 저장소 경로 +--agent-registration + 중앙 등록 범위 (기본 shared) --port 서버 포트 (기본 8080) --database mysql|mssql DB 종류 (기본 mysql) --mybatis MyBatis 예제 포함 @@ -80,7 +82,7 @@ npx @kri/create-spring-app sample-server 2. `KRI_AGENT_HARNESS_ROOT` 환경변수 3. 생성 경로의 상위 디렉터리 -하네스를 발견하면 프로젝트를 `workspace.local.yml`에 등록하고 `compose`, `verify`를 실행합니다. 하네스를 찾지 못해도 프로젝트 생성은 완료되며, 이 경우 `.agent` 원본을 중앙 하네스에서 나중에 등록·합성해야 합니다. +하네스를 발견하면 기본적으로 프로젝트를 공유 `workspace.yml`에 등록하고 `compose`, `verify`를 실행합니다. 일회성 로컬 등록은 `--agent-registration local`로 선택할 수 있습니다. 하네스를 찾지 못해도 프로젝트 생성은 완료되며, 이 경우 `.agent` 원본을 중앙 하네스에서 나중에 등록·합성해야 합니다. 중앙 저장소와 생성 프로젝트의 Git 커밋은 자동으로 수행하지 않습니다. ## Gitea Maven 인증 diff --git a/package-lock.json b/package-lock.json index 8b50fc2..0bfa528 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@kri/create-spring-app", - "version": "0.1.3", + "version": "0.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@kri/create-spring-app", - "version": "0.1.3", + "version": "0.1.4", "license": "UNLICENSED", "bin": { "kri-create-spring-app": "dist/cli.js" diff --git a/package.json b/package.json index 41c55cf..597b2bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kri/create-spring-app", - "version": "0.1.3", + "version": "0.1.4", "description": "Create a KRI standard Spring Boot 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 7a5ddb7..e37a210 100644 --- a/src/args.ts +++ b/src/args.ts @@ -1,5 +1,10 @@ import path from "node:path"; -import type { DatabaseType, ParsedArguments, ProjectType } from "./types.js"; +import type { + AgentRegistration, + DatabaseType, + ParsedArguments, + ProjectType, +} from "./types.js"; const requireValue = (args: string[], index: number, option: string): string => { const value = args[index + 1]; @@ -23,12 +28,18 @@ 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, build: true, jenkins: true, mybatis: false, + agentRegistration: "shared", skipAgentCompose: false, force: false, help: false, @@ -79,6 +90,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; @@ -147,6 +162,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 서버 포트 (기본 8080) --database mysql|mssql DB 종류 (기본 mysql) --mybatis MyBatis 예제 포함 diff --git a/src/cli.ts b/src/cli.ts index b866a2f..d9aa590 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -147,6 +147,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-server", + 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-server", "--path", "sample-server", "--shared"], + ["compose", "--project", "sample-server"], + ["verify", "--project", "sample-server"], + ]); +});