feat: register generated apps with agent harness
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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 <type> requested-project|internal-service|shared-service
|
||||
--agent-project-id <id> 하네스 프로젝트 ID (기본: 프로젝트명 slug)
|
||||
--harness-root <path> 중앙 Agent Harness 저장소 경로
|
||||
--agent-registration <shared|local>
|
||||
중앙 등록 범위 (기본 shared)
|
||||
--port <number> 서버 포트 (기본 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 인증
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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"
|
||||
|
||||
@@ -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": {
|
||||
|
||||
19
src/args.ts
19
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 <type> requested-project|internal-service|shared-service
|
||||
--agent-project-id <id> 하네스 프로젝트 ID (기본: 프로젝트명 slug)
|
||||
--harness-root <path> 중앙 Agent Harness 저장소 경로
|
||||
--agent-registration <shared|local>
|
||||
중앙 등록 범위 (기본 shared)
|
||||
--port <number> 서버 포트 (기본 8080)
|
||||
--database mysql|mssql DB 종류 (기본 mysql)
|
||||
--mybatis MyBatis 예제 포함
|
||||
|
||||
@@ -147,6 +147,7 @@ async function resolveOptions(): Promise<CliOptions> {
|
||||
build: parsed.build,
|
||||
jenkins,
|
||||
harnessRoot: parsed.harnessRoot,
|
||||
agentRegistration: parsed.agentRegistration,
|
||||
skipAgentCompose: parsed.skipAgentCompose,
|
||||
force: parsed.force,
|
||||
};
|
||||
|
||||
@@ -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<void
|
||||
}
|
||||
|
||||
const projectPath = workspaceRelativePath(harnessRoot, options.targetDir);
|
||||
console.log("\n[Agent Harness] 로컬 등록·합성·검증");
|
||||
await runHarness(harnessRoot, [
|
||||
console.log(`\n[Agent Harness] ${options.agentRegistration} 등록·합성·검증`);
|
||||
const registerArgs = [
|
||||
"register",
|
||||
"--project",
|
||||
options.agentProjectId,
|
||||
"--path",
|
||||
projectPath,
|
||||
]);
|
||||
];
|
||||
if (options.agentRegistration === "shared") registerArgs.push("--shared");
|
||||
await runHarness(harnessRoot, registerArgs);
|
||||
await runHarness(harnessRoot, ["compose", "--project", options.agentProjectId]);
|
||||
await runHarness(harnessRoot, ["verify", "--project", options.agentProjectId]);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export type DatabaseType = "mysql" | "mssql";
|
||||
export type ProjectType = "requested-project" | "internal-service" | "shared-service";
|
||||
export type AgentRegistration = "shared" | "local";
|
||||
|
||||
export interface CliOptions {
|
||||
projectName: string;
|
||||
@@ -22,6 +23,7 @@ export interface CliOptions {
|
||||
build: boolean;
|
||||
jenkins: boolean;
|
||||
harnessRoot?: string;
|
||||
agentRegistration: AgentRegistration;
|
||||
skipAgentCompose: boolean;
|
||||
force: boolean;
|
||||
}
|
||||
@@ -46,6 +48,7 @@ export interface ParsedArguments {
|
||||
build: boolean;
|
||||
jenkins: boolean;
|
||||
harnessRoot?: string;
|
||||
agentRegistration: AgentRegistration;
|
||||
skipAgentCompose: boolean;
|
||||
force: boolean;
|
||||
help: boolean;
|
||||
|
||||
@@ -6,7 +6,7 @@ __DESCRIPTION__
|
||||
|
||||
- Java 17
|
||||
- Spring Boot 3.5.7
|
||||
- `com.kri.common:starter:beta.1.6.3`
|
||||
- `com.kri.common:starter:beta.1.6.4`
|
||||
- JPA + QueryDSL + JdbcTemplate
|
||||
- EmbeddedId 예제
|
||||
- MyBatis는 생성 옵션에 따라 포함
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
## Generated Spring Boot Repository Rules
|
||||
|
||||
- This backend application was generated by `@kri/create-spring-app` with Java 17 and Spring Boot 3.5.7.
|
||||
- Consume KriCommon through `com.kri.common:starter:beta.1.6.3`; do not change that approved version or duplicate shared behavior without explicit approval.
|
||||
- Consume KriCommon through `com.kri.common:starter:beta.1.6.4`; do not change that approved version or duplicate shared behavior without explicit approval.
|
||||
- The selected primary database is `__DATABASE__`. Preserve its configured dialect, driver, transaction, schema, and migration conventions.
|
||||
- Keep controllers thin and preserve the generated service, DTO, persistence, configuration, QueryDSL, JDBC, and optional MyBatis boundaries.
|
||||
- `AGENTS.md` and `CLAUDE.md` are central-harness generated outputs. Never edit them directly; update `.agent/profile.yml` or `.agent/project.md` and recompose.
|
||||
|
||||
@@ -45,7 +45,7 @@ configurations.configureEach {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.kri.common:starter:beta.1.6.3'
|
||||
implementation 'com.kri.common:starter:beta.1.6.4'
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
|
||||
59
tests/harness.test.mjs
Normal file
59
tests/harness.test.mjs
Normal file
@@ -0,0 +1,59 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
import { parseArguments } from "../dist/args.js";
|
||||
import { composeAgentHarness } from "../dist/harness.js";
|
||||
|
||||
async function createFixture(t) {
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), "kri-create-spring-harness-"));
|
||||
const harnessRoot = path.join(root, "_________AgentHarnessBase");
|
||||
const targetDir = path.join(root, "sample-server");
|
||||
const logPath = path.join(root, "calls.jsonl");
|
||||
await mkdir(path.join(harnessRoot, "dist"), { recursive: true });
|
||||
await mkdir(targetDir, { recursive: true });
|
||||
await writeFile(path.join(harnessRoot, "workspace.yml"), "schema_version: 1\nprojects: {}\n", "utf8");
|
||||
await writeFile(
|
||||
path.join(harnessRoot, "dist", "cli.cjs"),
|
||||
`const { appendFileSync } = require("node:fs");\nappendFileSync(${JSON.stringify(logPath)}, JSON.stringify(process.argv.slice(2)) + "\\n");\n`,
|
||||
"utf8",
|
||||
);
|
||||
t.after(() => 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"],
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user