sovkora 0.0.0-stage → 1.1.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.
- package/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +67 -2
- package/dist/commands/agent.command.js +267 -0
- package/dist/commands/chat.command.js +214 -0
- package/dist/commands/chat.handlers.js +150 -0
- package/dist/commands/chat.types.js +44 -0
- package/dist/commands/cinema.command.js +643 -0
- package/dist/commands/config.command.js +228 -0
- package/dist/commands/db.command.js +114 -0
- package/dist/commands/demo.command.js +55 -0
- package/dist/commands/dev.command.js +462 -0
- package/dist/commands/docs.command.js +135 -0
- package/dist/commands/doctor.command.js +119 -0
- package/dist/commands/forgot.command.js +57 -0
- package/dist/commands/generate.command.js +376 -0
- package/dist/commands/graph.command.js +54 -0
- package/dist/commands/init.command.js +380 -0
- package/dist/commands/init.steps.js +115 -0
- package/dist/commands/install.command.js +459 -0
- package/dist/commands/login.command.js +110 -0
- package/dist/commands/logs.command.js +215 -0
- package/dist/commands/logs.steps.js +130 -0
- package/dist/commands/mcp.command.js +104 -0
- package/dist/commands/models.command.js +164 -0
- package/dist/commands/onboard.command.js +236 -0
- package/dist/commands/pack.command.js +255 -0
- package/dist/commands/profile.command.js +51 -0
- package/dist/commands/recover.command.js +489 -0
- package/dist/commands/register.command.js +94 -0
- package/dist/commands/release.command.js +99 -0
- package/dist/commands/reset.command.js +79 -0
- package/dist/commands/runs.command.js +201 -0
- package/dist/commands/settings.command.js +85 -0
- package/dist/commands/start.command.js +590 -0
- package/dist/commands/status.command.js +167 -0
- package/dist/commands/stop.command.js +313 -0
- package/dist/commands/studio.command.js +266 -0
- package/dist/commands/test.command.js +134 -0
- package/dist/commands/verify.command.js +52 -0
- package/dist/commands/video.command.js +73 -0
- package/dist/commands/workspace-guard.js +72 -0
- package/dist/index.js +207 -0
- package/dist/renderers.js +250 -0
- package/dist/services/api-client.js +150 -0
- package/dist/services/auth.api.js +87 -0
- package/dist/services/chat.api.js +117 -0
- package/dist/services/cinema-estimate.json +42 -0
- package/dist/services/cinema.childsafe.js +52 -0
- package/dist/services/cinema.director.js +285 -0
- package/dist/services/cinema.production.js +417 -0
- package/dist/services/cinema.staging.js +323 -0
- package/dist/services/cinema.story.js +758 -0
- package/dist/services/cinema.treatment.js +393 -0
- package/dist/services/composer.run.js +94 -0
- package/dist/services/demo/demo.documents.js +108 -0
- package/dist/services/demo/demo.guard.js +49 -0
- package/dist/services/demo/demo.persona.js +114 -0
- package/dist/services/demo/demo.seed.js +281 -0
- package/dist/services/diagnostics.js +327 -0
- package/dist/services/image-model-recipes.json +93 -0
- package/dist/services/image-models.js +152 -0
- package/dist/services/local-store.js +145 -0
- package/dist/services/mcp.api.js +38 -0
- package/dist/services/model-catalog.js +70 -0
- package/dist/services/notify.js +55 -0
- package/dist/services/pack.api.js +23 -0
- package/dist/services/pack.bundle.js +241 -0
- package/dist/services/pack.sources.js +101 -0
- package/dist/services/release-manifest.js +266 -0
- package/dist/services/runs.view.js +80 -0
- package/dist/services/runs.wait.js +38 -0
- package/dist/services/semver.js +55 -0
- package/dist/services/settings.api.js +108 -0
- package/dist/services/string-utils.js +70 -0
- package/dist/services/studio.api.js +120 -0
- package/dist/services/templates.js +893 -0
- package/dist/services/tool-installer.js +353 -0
- package/dist/services/tool-path.js +72 -0
- package/dist/services/version-manager.js +253 -0
- package/dist/services/workspace-bootstrap.js +68 -0
- package/dist/threads.js +202 -0
- package/dist/types/api.types.js +6 -0
- package/dist/types/local.types.js +6 -0
- package/dist/ui/box.js +46 -0
- package/dist/ui/logger.js +28 -0
- package/dist/ui/platform.js +32 -0
- package/dist/ui/prompts.js +130 -0
- package/dist/ui/table.js +33 -0
- package/dist/utils/config.js +150 -0
- package/dist/utils/development-status.js +22 -0
- package/dist/utils/endpoints.js +41 -0
- package/dist/utils/health.js +94 -0
- package/dist/utils/pid.js +83 -0
- package/dist/utils/platform.js +358 -0
- package/dist/utils/process.js +139 -0
- package/dist/utils/state-dir.js +105 -0
- package/package.json +95 -4
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file templates.ts
|
|
4
|
+
* @description Template engine for generating service skeletons, interceptors,
|
|
5
|
+
* business features, technical features, API connectors, and configurations.
|
|
6
|
+
* Scans the workspace to auto-detect correct placement directories.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.scanWorkspaceStructure = scanWorkspaceStructure;
|
|
43
|
+
exports.generateInterceptor = generateInterceptor;
|
|
44
|
+
exports.generateBusinessFeature = generateBusinessFeature;
|
|
45
|
+
exports.generateTechnicalFeature = generateTechnicalFeature;
|
|
46
|
+
exports.generateApiConnector = generateApiConnector;
|
|
47
|
+
exports.generateConfiguration = generateConfiguration;
|
|
48
|
+
exports.generateJavaService = generateJavaService;
|
|
49
|
+
exports.generateJavaController = generateJavaController;
|
|
50
|
+
exports.generateTypeScriptHook = generateTypeScriptHook;
|
|
51
|
+
exports.generateSqlMigration = generateSqlMigration;
|
|
52
|
+
exports.generateDockerComposeService = generateDockerComposeService;
|
|
53
|
+
const fs = __importStar(require("node:fs"));
|
|
54
|
+
const path = __importStar(require("node:path"));
|
|
55
|
+
const string_utils_1 = require("./string-utils");
|
|
56
|
+
// ═══════════════════════════════════════════════════════════════
|
|
57
|
+
// Workspace Scanner
|
|
58
|
+
// ═══════════════════════════════════════════════════════════════
|
|
59
|
+
/**
|
|
60
|
+
* Scans the workspace to find standard directories for file placement.
|
|
61
|
+
*/
|
|
62
|
+
function scanWorkspaceStructure(workspaceRoot) {
|
|
63
|
+
const tryResolve = (...parts) => {
|
|
64
|
+
const resolved = path.join(workspaceRoot, ...parts);
|
|
65
|
+
return fs.existsSync(resolved) ? resolved : null;
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
interceptorsDir: tryResolve("engine", "sovkora-engine-interceptors"),
|
|
69
|
+
coreDir: tryResolve("engine", "sovkora-engine-core"),
|
|
70
|
+
conversationDir: tryResolve("services", "conversation", "sovkora-conversation-service"),
|
|
71
|
+
uiDir: tryResolve("apps"),
|
|
72
|
+
infraDir: tryResolve("infra"),
|
|
73
|
+
businessDir: tryResolve("engine", "sovkora-engine-business"),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Safely writes a file, creating directories as needed.
|
|
78
|
+
* Returns a GeneratedFile descriptor.
|
|
79
|
+
*/
|
|
80
|
+
function writeFile(filePath, content, workspaceRoot, description) {
|
|
81
|
+
const dir = path.dirname(filePath);
|
|
82
|
+
if (!fs.existsSync(dir)) {
|
|
83
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
const existed = fs.existsSync(filePath);
|
|
86
|
+
if (existed) {
|
|
87
|
+
return {
|
|
88
|
+
path: filePath,
|
|
89
|
+
relativePath: path.relative(workspaceRoot, filePath),
|
|
90
|
+
action: "skipped",
|
|
91
|
+
description: `${description} (already exists)`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
95
|
+
return {
|
|
96
|
+
path: filePath,
|
|
97
|
+
relativePath: path.relative(workspaceRoot, filePath),
|
|
98
|
+
action: "created",
|
|
99
|
+
description,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
// ═══════════════════════════════════════════════════════════════
|
|
103
|
+
// 1. Interceptor Template
|
|
104
|
+
// ═══════════════════════════════════════════════════════════════
|
|
105
|
+
function generateInterceptor(ctx, workspaceRoot) {
|
|
106
|
+
const name = (0, string_utils_1.pascalCase)(ctx.moduleName);
|
|
107
|
+
const kebab = (0, string_utils_1.kebabCase)(ctx.moduleName);
|
|
108
|
+
const pkg = kebab.replaceAll("-", "");
|
|
109
|
+
const files = [];
|
|
110
|
+
const struct = scanWorkspaceStructure(workspaceRoot);
|
|
111
|
+
const interceptorsBase = struct.interceptorsDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-interceptors");
|
|
112
|
+
const moduleDir = path.join(interceptorsBase, `orazaka-interceptor-${kebab}`);
|
|
113
|
+
const srcMain = path.join(moduleDir, "src", "main", "java", "com", "orazaka", "interceptor", pkg);
|
|
114
|
+
const srcTest = path.join(moduleDir, "src", "test", "java", "com", "orazaka", "interceptor", pkg);
|
|
115
|
+
// pom.xml
|
|
116
|
+
files.push(writeFile(path.join(moduleDir, "pom.xml"), `<?xml version="1.0" encoding="UTF-8"?>
|
|
117
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
118
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
119
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
120
|
+
<modelVersion>4.0.0</modelVersion>
|
|
121
|
+
|
|
122
|
+
<parent>
|
|
123
|
+
<groupId>com.krizaka.orazaka</groupId>
|
|
124
|
+
<artifactId>orazaka-interceptors</artifactId>
|
|
125
|
+
<version>1.0.0-SNAPSHOT</version>
|
|
126
|
+
<relativePath>../pom.xml</relativePath>
|
|
127
|
+
</parent>
|
|
128
|
+
|
|
129
|
+
<artifactId>orazaka-interceptor-${kebab}</artifactId>
|
|
130
|
+
<name>orazaka-interceptor-${kebab}</name>
|
|
131
|
+
<description>${ctx.description}</description>
|
|
132
|
+
|
|
133
|
+
<dependencies>
|
|
134
|
+
<dependency>
|
|
135
|
+
<groupId>com.krizaka.orazaka</groupId>
|
|
136
|
+
<artifactId>orazaka-core</artifactId>
|
|
137
|
+
</dependency>
|
|
138
|
+
<dependency>
|
|
139
|
+
<groupId>org.slf4j</groupId>
|
|
140
|
+
<artifactId>slf4j-api</artifactId>
|
|
141
|
+
</dependency>
|
|
142
|
+
<dependency>
|
|
143
|
+
<groupId>org.springframework.boot</groupId>
|
|
144
|
+
<artifactId>spring-boot-autoconfigure</artifactId>
|
|
145
|
+
</dependency>
|
|
146
|
+
<dependency>
|
|
147
|
+
<groupId>org.springframework</groupId>
|
|
148
|
+
<artifactId>spring-context</artifactId>
|
|
149
|
+
</dependency>
|
|
150
|
+
<dependency>
|
|
151
|
+
<groupId>org.springframework.ai</groupId>
|
|
152
|
+
<artifactId>spring-ai-model</artifactId>
|
|
153
|
+
</dependency>
|
|
154
|
+
<dependency>
|
|
155
|
+
<groupId>org.junit.jupiter</groupId>
|
|
156
|
+
<artifactId>junit-jupiter-api</artifactId>
|
|
157
|
+
<scope>test</scope>
|
|
158
|
+
</dependency>
|
|
159
|
+
<dependency>
|
|
160
|
+
<groupId>org.assertj</groupId>
|
|
161
|
+
<artifactId>assertj-core</artifactId>
|
|
162
|
+
<scope>test</scope>
|
|
163
|
+
</dependency>
|
|
164
|
+
<dependency>
|
|
165
|
+
<groupId>org.mockito</groupId>
|
|
166
|
+
<artifactId>mockito-core</artifactId>
|
|
167
|
+
<scope>test</scope>
|
|
168
|
+
</dependency>
|
|
169
|
+
</dependencies>
|
|
170
|
+
|
|
171
|
+
</project>
|
|
172
|
+
`, workspaceRoot, "Maven module definition"), // Interceptor implementation
|
|
173
|
+
writeFile(path.join(srcMain, `${name}Interceptor.java`), String.raw `package com.krizaka.orazaka.interceptor.${pkg};
|
|
174
|
+
|
|
175
|
+
import com.krizaka.orazaka.core.application.interceptor.PromptContextInterceptor;
|
|
176
|
+
import org.slf4j.Logger;
|
|
177
|
+
import org.slf4j.LoggerFactory;
|
|
178
|
+
import org.springframework.ai.chat.client.advisor.api.AdvisedRequest;
|
|
179
|
+
import org.springframework.ai.chat.client.advisor.api.AdvisedResponse;
|
|
180
|
+
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisorChain;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* ${name}Interceptor: ${ctx.description}
|
|
184
|
+
*
|
|
185
|
+
* <p>Implements the PromptContextInterceptor SPI to participate in the
|
|
186
|
+
* context-matrix pipeline. Registered via {@link ${name}AutoConfiguration}.
|
|
187
|
+
*
|
|
188
|
+
* @since ${ctx.year}
|
|
189
|
+
*/
|
|
190
|
+
public final class ${name}Interceptor implements PromptContextInterceptor {
|
|
191
|
+
|
|
192
|
+
private static final Logger log = LoggerFactory.getLogger(${name}Interceptor.class);
|
|
193
|
+
|
|
194
|
+
@Override
|
|
195
|
+
public AdvisedResponse aroundCall(final AdvisedRequest request, final CallAroundAdvisorChain chain) {
|
|
196
|
+
log.debug("${name}Interceptor: processing request");
|
|
197
|
+
|
|
198
|
+
// TODO: Implement interception logic
|
|
199
|
+
// Example: modify the request before passing to the next interceptor
|
|
200
|
+
// AdvisedRequest enriched = AdvisedRequest.from(request)
|
|
201
|
+
// .withSystemText(request.systemText() + "\n[${name} context]")
|
|
202
|
+
// .build();
|
|
203
|
+
|
|
204
|
+
return chain.nextAroundCall(request);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@Override
|
|
208
|
+
public String getName() {
|
|
209
|
+
return "${name}Interceptor";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@Override
|
|
213
|
+
public int getOrder() {
|
|
214
|
+
return 50; // TODO: Adjust ordering per context-matrix table
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
`, workspaceRoot, "Interceptor implementation (PromptContextInterceptor SPI)"), // Auto-configuration
|
|
218
|
+
writeFile(path.join(srcMain, `${name}AutoConfiguration.java`), `package com.krizaka.orazaka.interceptor.${pkg};
|
|
219
|
+
|
|
220
|
+
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
221
|
+
import org.springframework.context.annotation.Bean;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Spring Boot auto-configuration for the ${kebab} interceptor module.
|
|
225
|
+
*
|
|
226
|
+
* <p>Registers {@link ${name}Interceptor} into the application context
|
|
227
|
+
* for dynamic pipeline discovery via SPI.
|
|
228
|
+
*
|
|
229
|
+
* @since ${ctx.year}
|
|
230
|
+
*/
|
|
231
|
+
@AutoConfiguration
|
|
232
|
+
public class ${name}AutoConfiguration {
|
|
233
|
+
|
|
234
|
+
@Bean
|
|
235
|
+
${name}Interceptor ${(0, string_utils_1.camelCase)(ctx.moduleName)}Interceptor() {
|
|
236
|
+
return new ${name}Interceptor();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
`, workspaceRoot, "Spring Boot auto-configuration (SPI registration)"));
|
|
240
|
+
// META-INF/spring.factories or spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
|
|
241
|
+
const importsDir = path.join(moduleDir, "src", "main", "resources", "META-INF", "spring");
|
|
242
|
+
files.push(writeFile(path.join(importsDir, "org.springframework.boot.autoconfigure.AutoConfiguration.imports"), `com.krizaka.orazaka.interceptor.${pkg}.${name}AutoConfiguration\n`, workspaceRoot, "Spring Boot auto-configuration SPI import"), // Test
|
|
243
|
+
writeFile(path.join(srcTest, `${name}InterceptorTest.java`), `package com.krizaka.orazaka.interceptor.${pkg};
|
|
244
|
+
|
|
245
|
+
import org.junit.jupiter.api.Test;
|
|
246
|
+
|
|
247
|
+
import static org.assertj.core.api.Assertions.assertThat;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Unit tests for {@link ${name}Interceptor}.
|
|
251
|
+
*/
|
|
252
|
+
class ${name}InterceptorTest {
|
|
253
|
+
|
|
254
|
+
private final ${name}Interceptor interceptor = new ${name}Interceptor();
|
|
255
|
+
|
|
256
|
+
@Test
|
|
257
|
+
void shouldReturnCorrectName() {
|
|
258
|
+
assertThat(interceptor.getName()).isEqualTo("${name}Interceptor");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@Test
|
|
262
|
+
void shouldHavePositiveOrder() {
|
|
263
|
+
assertThat(interceptor.getOrder()).isGreaterThan(0);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
`, workspaceRoot, "Unit test for interceptor"));
|
|
267
|
+
return {
|
|
268
|
+
files,
|
|
269
|
+
nextSteps: [
|
|
270
|
+
`Add <module>orazaka-interceptor-${kebab}</module> to orazaka-interceptors/pom.xml`,
|
|
271
|
+
`Add dependency to orazaka-conversation-service/pom.xml: <artifactId>orazaka-interceptor-${kebab}</artifactId>`,
|
|
272
|
+
`Set the correct order in getOrder() per the context-matrix table in AGENTS.md`,
|
|
273
|
+
`Run: mvn clean install -pl engine/sovkora-engine-interceptors`,
|
|
274
|
+
],
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// ═══════════════════════════════════════════════════════════════
|
|
278
|
+
// 2. Business Feature (full-stack: service + controller + hook)
|
|
279
|
+
// ═══════════════════════════════════════════════════════════════
|
|
280
|
+
function generateBusinessFeature(ctx, workspaceRoot) {
|
|
281
|
+
const name = (0, string_utils_1.pascalCase)(ctx.moduleName);
|
|
282
|
+
const camel = (0, string_utils_1.camelCase)(ctx.moduleName);
|
|
283
|
+
const kebab = (0, string_utils_1.kebabCase)(ctx.moduleName);
|
|
284
|
+
const files = [];
|
|
285
|
+
const struct = scanWorkspaceStructure(workspaceRoot);
|
|
286
|
+
const coreSrc = path.join(struct.coreDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-core"), "src", "main", "java", "com", "orazaka", "core");
|
|
287
|
+
const conversationSrc = path.join(struct.conversationDir ?? path.join(workspaceRoot, "services", "conversation", "sovkora-conversation-service"), "src", "main", "java", "com", "orazaka", "router");
|
|
288
|
+
const uiDir = struct.uiDir ?? path.join(workspaceRoot, "apps");
|
|
289
|
+
// Service interface (core)
|
|
290
|
+
files.push(writeFile(path.join(coreSrc, "application", "service", `${name}Service.java`), `package com.krizaka.orazaka.core.application.service;
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* ${name}Service: ${ctx.description}
|
|
294
|
+
*
|
|
295
|
+
* @since ${ctx.year}
|
|
296
|
+
*/
|
|
297
|
+
public interface ${name}Service {
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Execute the primary business operation.
|
|
301
|
+
*
|
|
302
|
+
* @param userId the authenticated user ID
|
|
303
|
+
* @param input the request payload
|
|
304
|
+
* @return the result
|
|
305
|
+
*/
|
|
306
|
+
String execute(String userId, String input);
|
|
307
|
+
}
|
|
308
|
+
`, workspaceRoot, "Service interface (orazaka-core)"), // Service implementation (core)
|
|
309
|
+
writeFile(path.join(coreSrc, "application", "service", `${name}ServiceImpl.java`), `package com.krizaka.orazaka.core.application.service;
|
|
310
|
+
|
|
311
|
+
import org.slf4j.Logger;
|
|
312
|
+
import org.slf4j.LoggerFactory;
|
|
313
|
+
import org.springframework.stereotype.Service;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* ${name}ServiceImpl: Implementation of {@link ${name}Service}.
|
|
317
|
+
*
|
|
318
|
+
* @since ${ctx.year}
|
|
319
|
+
*/
|
|
320
|
+
@Service
|
|
321
|
+
final class ${name}ServiceImpl implements ${name}Service {
|
|
322
|
+
|
|
323
|
+
private static final Logger log = LoggerFactory.getLogger(${name}ServiceImpl.class);
|
|
324
|
+
|
|
325
|
+
@Override
|
|
326
|
+
public String execute(final String userId, final String input) {
|
|
327
|
+
log.info("[${name}] User {} executing with input: {}", userId, input);
|
|
328
|
+
|
|
329
|
+
// TODO: Implement business logic
|
|
330
|
+
return "Result: " + input;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
`, workspaceRoot, "Service implementation (package-private, orazaka-core)"), // REST controller (gateway)
|
|
334
|
+
writeFile(path.join(conversationSrc, "infrastructure", "adapter", "rest", `${name}Controller.java`), `package com.krizaka.orazaka.conversationservice.infrastructure.adapter.rest;
|
|
335
|
+
|
|
336
|
+
import com.krizaka.orazaka.core.application.service.${name}Service;
|
|
337
|
+
import org.springframework.web.bind.annotation.*;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* ${name}Controller: REST adapter for ${ctx.description}.
|
|
341
|
+
*
|
|
342
|
+
* @since ${ctx.year}
|
|
343
|
+
*/
|
|
344
|
+
@RestController
|
|
345
|
+
@RequestMapping("/api/v1/${kebab}")
|
|
346
|
+
public final class ${name}Controller {
|
|
347
|
+
|
|
348
|
+
private final ${name}Service ${camel}Service;
|
|
349
|
+
|
|
350
|
+
${name}Controller(final ${name}Service ${camel}Service) {
|
|
351
|
+
this.${camel}Service = ${camel}Service;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
@PostMapping("/execute")
|
|
355
|
+
public String execute(
|
|
356
|
+
@RequestHeader("X-User-Id") final String userId,
|
|
357
|
+
@RequestBody final String request) {
|
|
358
|
+
return ${camel}Service.execute(userId, request);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@GetMapping("/health")
|
|
362
|
+
public String health() {
|
|
363
|
+
return "OK";
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
`, workspaceRoot, "REST controller (orazaka-conversation-service/adapter/rest/)"));
|
|
367
|
+
// React hook (UI)
|
|
368
|
+
const hookName = `use${name}`;
|
|
369
|
+
files.push(writeFile(path.join(uiDir, "src", "hooks", `${hookName}.ts`), `import { useState, useCallback } from "react";
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* ${hookName}: Client hook for ${ctx.description}
|
|
373
|
+
*/
|
|
374
|
+
export function ${hookName}() {
|
|
375
|
+
const [loading, setLoading] = useState(false);
|
|
376
|
+
const [error, setError] = useState<string | null>(null);
|
|
377
|
+
const [data, setData] = useState<unknown>(null);
|
|
378
|
+
|
|
379
|
+
const execute = useCallback(async (input: string) => {
|
|
380
|
+
setLoading(true);
|
|
381
|
+
setError(null);
|
|
382
|
+
|
|
383
|
+
try {
|
|
384
|
+
const response = await fetch("/api/${kebab}/execute", {
|
|
385
|
+
method: "POST",
|
|
386
|
+
headers: { "Content-Type": "application/json" },
|
|
387
|
+
body: JSON.stringify({ input }),
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
if (!response.ok) {
|
|
391
|
+
throw new Error(\`HTTP Error: \${response.status}\`);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
const result = await response.json();
|
|
395
|
+
setData(result);
|
|
396
|
+
return result;
|
|
397
|
+
} catch (err) {
|
|
398
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
399
|
+
setError(message);
|
|
400
|
+
throw err;
|
|
401
|
+
} finally {
|
|
402
|
+
setLoading(false);
|
|
403
|
+
}
|
|
404
|
+
}, []);
|
|
405
|
+
|
|
406
|
+
return { execute, loading, error, data };
|
|
407
|
+
}
|
|
408
|
+
`, workspaceRoot, `React hook (orazaka-ui/src/hooks/${hookName}.ts)`), // Next.js server action (BFF proxy)
|
|
409
|
+
writeFile(path.join(uiDir, "src", "app", "api", kebab, "execute", "route.ts"), `import { NextRequest, NextResponse } from "next/server";
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* BFF proxy for ${ctx.description}.
|
|
413
|
+
* Browser never hits Gateway directly (AGENTS.md §6).
|
|
414
|
+
*/
|
|
415
|
+
export async function POST(request: NextRequest) {
|
|
416
|
+
try {
|
|
417
|
+
const body = await request.text();
|
|
418
|
+
const userId = request.headers.get("x-user-id") ?? "anonymous";
|
|
419
|
+
|
|
420
|
+
const response = await fetch(\`http://localhost:8080/api/v1/${kebab}/execute\`, {
|
|
421
|
+
method: "POST",
|
|
422
|
+
headers: {
|
|
423
|
+
"Content-Type": "application/json",
|
|
424
|
+
"X-User-Id": userId,
|
|
425
|
+
},
|
|
426
|
+
body,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
if (!response.ok) {
|
|
430
|
+
return NextResponse.json(
|
|
431
|
+
{ error: \`Gateway error: \${response.statusText}\` },
|
|
432
|
+
{ status: response.status },
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const result = await response.json();
|
|
437
|
+
return NextResponse.json(result);
|
|
438
|
+
} catch (error) {
|
|
439
|
+
return NextResponse.json(
|
|
440
|
+
{ error: "Internal server error" },
|
|
441
|
+
{ status: 500 },
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
`, workspaceRoot, "Next.js API route (BFF proxy — browser never hits Gateway directly)"));
|
|
446
|
+
return {
|
|
447
|
+
files,
|
|
448
|
+
nextSteps: [
|
|
449
|
+
`Implement business logic in ${name}ServiceImpl.java`,
|
|
450
|
+
`Add request/response DTOs as Java records in orazaka-core`,
|
|
451
|
+
`Write unit tests: ${name}ServiceImplTest.java and ${name}ControllerTest.java`,
|
|
452
|
+
`Start Gateway from IntelliJ, then test: curl -X POST http://localhost:3000/api/${kebab}/execute`,
|
|
453
|
+
],
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
// ═══════════════════════════════════════════════════════════════
|
|
457
|
+
// 3. Technical Feature (infra-level: config + properties)
|
|
458
|
+
// ═══════════════════════════════════════════════════════════════
|
|
459
|
+
function generateTechnicalFeature(ctx, workspaceRoot) {
|
|
460
|
+
const name = (0, string_utils_1.pascalCase)(ctx.moduleName);
|
|
461
|
+
const kebab = (0, string_utils_1.kebabCase)(ctx.moduleName);
|
|
462
|
+
const files = [];
|
|
463
|
+
const struct = scanWorkspaceStructure(workspaceRoot);
|
|
464
|
+
const coreSrc = path.join(struct.coreDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-core"), "src", "main", "java", "com", "orazaka", "core");
|
|
465
|
+
// Properties record
|
|
466
|
+
files.push(writeFile(path.join(coreSrc, "infrastructure", "config", `${name}Properties.java`), `package com.krizaka.orazaka.core.infrastructure.config;
|
|
467
|
+
|
|
468
|
+
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* ${name}Properties: Configuration binding for orazaka.${kebab}.* properties.
|
|
472
|
+
*
|
|
473
|
+
* @since ${ctx.year}
|
|
474
|
+
*/
|
|
475
|
+
@ConfigurationProperties(prefix = "orazaka.${kebab}")
|
|
476
|
+
public record ${name}Properties(
|
|
477
|
+
boolean enabled,
|
|
478
|
+
String endpoint,
|
|
479
|
+
int timeoutMs
|
|
480
|
+
) {
|
|
481
|
+
|
|
482
|
+
public ${name}Properties {
|
|
483
|
+
if (timeoutMs < 0) {
|
|
484
|
+
throw new IllegalArgumentException("timeoutMs must be non-negative");
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** Defaults. */
|
|
489
|
+
public ${name}Properties() {
|
|
490
|
+
this(true, "http://localhost:8080", 30000);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
`, workspaceRoot, "Configuration properties record (self-validating)"), // Configuration class
|
|
494
|
+
writeFile(path.join(coreSrc, "infrastructure", "config", `${name}Configuration.java`), `package com.krizaka.orazaka.core.infrastructure.config;
|
|
495
|
+
|
|
496
|
+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
497
|
+
import org.springframework.context.annotation.Configuration;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* ${name}Configuration: Enables ${name}Properties binding.
|
|
501
|
+
*
|
|
502
|
+
* @since ${ctx.year}
|
|
503
|
+
*/
|
|
504
|
+
@Configuration
|
|
505
|
+
@EnableConfigurationProperties(${name}Properties.class)
|
|
506
|
+
public class ${name}Configuration {
|
|
507
|
+
}
|
|
508
|
+
`, workspaceRoot, "Spring configuration class"), // Test
|
|
509
|
+
writeFile(path.join(struct.coreDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-core"), "src", "test", "java", "com", "orazaka", "core", "infrastructure", "config", `${name}PropertiesTest.java`), `package com.krizaka.orazaka.core.infrastructure.config;
|
|
510
|
+
|
|
511
|
+
import org.junit.jupiter.api.Test;
|
|
512
|
+
import static org.assertj.core.api.Assertions.assertThat;
|
|
513
|
+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
514
|
+
|
|
515
|
+
class ${name}PropertiesTest {
|
|
516
|
+
|
|
517
|
+
@Test
|
|
518
|
+
void shouldCreateWithDefaults() {
|
|
519
|
+
var props = new ${name}Properties();
|
|
520
|
+
assertThat(props.enabled()).isTrue();
|
|
521
|
+
assertThat(props.endpoint()).isNotBlank();
|
|
522
|
+
assertThat(props.timeoutMs()).isPositive();
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
@Test
|
|
526
|
+
void shouldRejectNegativeTimeout() {
|
|
527
|
+
assertThatThrownBy(() -> new ${name}Properties(true, "http://localhost", -1))
|
|
528
|
+
.isInstanceOf(IllegalArgumentException.class);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
`, workspaceRoot, "Properties validation test"));
|
|
532
|
+
return {
|
|
533
|
+
files,
|
|
534
|
+
nextSteps: [
|
|
535
|
+
`Add to application.yml: orazaka.${kebab}.enabled=true`,
|
|
536
|
+
`Inject ${name}Properties into services that need this configuration`,
|
|
537
|
+
`Add orazaka.${kebab}.* to docs/GLOSSARY.md environment reference`,
|
|
538
|
+
],
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
// ═══════════════════════════════════════════════════════════════
|
|
542
|
+
// 4. External API Connector
|
|
543
|
+
// ═══════════════════════════════════════════════════════════════
|
|
544
|
+
function generateApiConnector(ctx, workspaceRoot) {
|
|
545
|
+
const name = (0, string_utils_1.pascalCase)(ctx.moduleName);
|
|
546
|
+
const kebab = (0, string_utils_1.kebabCase)(ctx.moduleName);
|
|
547
|
+
const files = [];
|
|
548
|
+
const struct = scanWorkspaceStructure(workspaceRoot);
|
|
549
|
+
const coreSrc = path.join(struct.coreDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-core"), "src", "main", "java", "com", "orazaka", "core");
|
|
550
|
+
// Client interface (port)
|
|
551
|
+
files.push(writeFile(path.join(coreSrc, "domain", "port", `${name}Client.java`), `package com.krizaka.orazaka.core.domain.port;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* ${name}Client: Outbound port for ${ctx.description}.
|
|
555
|
+
*
|
|
556
|
+
* <p>Implementations must use Spring RestClient or @HttpExchange proxies
|
|
557
|
+
* (ERR-120: manual HTTP clients are banned).
|
|
558
|
+
*
|
|
559
|
+
* @since ${ctx.year}
|
|
560
|
+
*/
|
|
561
|
+
public interface ${name}Client {
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Call the external API.
|
|
565
|
+
*
|
|
566
|
+
* @param request the request payload
|
|
567
|
+
* @return the response
|
|
568
|
+
*/
|
|
569
|
+
String call(String request);
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Check if the external service is reachable.
|
|
573
|
+
*
|
|
574
|
+
* @return true if healthy
|
|
575
|
+
*/
|
|
576
|
+
boolean isHealthy();
|
|
577
|
+
}
|
|
578
|
+
`, workspaceRoot, "Client interface (outbound port)"), // RestClient implementation
|
|
579
|
+
writeFile(path.join(coreSrc, "infrastructure", "adapter", "client", `${name}RestClient.java`), `package com.krizaka.orazaka.core.infrastructure.adapter.client;
|
|
580
|
+
|
|
581
|
+
import com.krizaka.orazaka.core.domain.port.${name}Client;
|
|
582
|
+
import com.krizaka.orazaka.core.infrastructure.config.${name}ConnectorProperties;
|
|
583
|
+
import org.slf4j.Logger;
|
|
584
|
+
import org.slf4j.LoggerFactory;
|
|
585
|
+
import org.springframework.stereotype.Component;
|
|
586
|
+
import org.springframework.web.client.RestClient;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* ${name}RestClient: Spring RestClient adapter for ${ctx.description}.
|
|
590
|
+
*
|
|
591
|
+
* <p>Enforces ERR-120: uses Spring RestClient, no manual HTTP clients.
|
|
592
|
+
*
|
|
593
|
+
* @since ${ctx.year}
|
|
594
|
+
*/
|
|
595
|
+
@Component
|
|
596
|
+
final class ${name}RestClient implements ${name}Client {
|
|
597
|
+
|
|
598
|
+
private static final Logger log = LoggerFactory.getLogger(${name}RestClient.class);
|
|
599
|
+
private final RestClient restClient;
|
|
600
|
+
|
|
601
|
+
${name}RestClient(final ${name}ConnectorProperties properties) {
|
|
602
|
+
this.restClient = RestClient.builder()
|
|
603
|
+
.baseUrl(properties.baseUrl())
|
|
604
|
+
.build();
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
@Override
|
|
608
|
+
public String call(final String request) {
|
|
609
|
+
log.debug("[${name}] Calling external API");
|
|
610
|
+
return restClient.post()
|
|
611
|
+
.uri("/api/execute")
|
|
612
|
+
.body(request)
|
|
613
|
+
.retrieve()
|
|
614
|
+
.body(String.class);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
@Override
|
|
618
|
+
public boolean isHealthy() {
|
|
619
|
+
try {
|
|
620
|
+
restClient.get()
|
|
621
|
+
.uri("/health")
|
|
622
|
+
.retrieve()
|
|
623
|
+
.toBodilessEntity();
|
|
624
|
+
return true;
|
|
625
|
+
} catch (Exception e) {
|
|
626
|
+
log.warn("[${name}] Health check failed: {}", e.getMessage());
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
`, workspaceRoot, "RestClient adapter (ERR-120 compliant)"), // Properties
|
|
632
|
+
writeFile(path.join(coreSrc, "infrastructure", "config", `${name}ConnectorProperties.java`), `package com.krizaka.orazaka.core.infrastructure.config;
|
|
633
|
+
|
|
634
|
+
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* ${name}ConnectorProperties: Connection settings for ${ctx.description}.
|
|
638
|
+
*
|
|
639
|
+
* @since ${ctx.year}
|
|
640
|
+
*/
|
|
641
|
+
@ConfigurationProperties(prefix = "orazaka.connector.${kebab}")
|
|
642
|
+
public record ${name}ConnectorProperties(
|
|
643
|
+
String baseUrl,
|
|
644
|
+
int timeoutMs,
|
|
645
|
+
int maxRetries
|
|
646
|
+
) {
|
|
647
|
+
|
|
648
|
+
public ${name}ConnectorProperties {
|
|
649
|
+
if (baseUrl == null || baseUrl.isBlank()) {
|
|
650
|
+
throw new IllegalArgumentException("baseUrl must not be blank");
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
`, workspaceRoot, "Connector configuration properties"), // Test
|
|
655
|
+
writeFile(path.join(struct.coreDir ?? path.join(workspaceRoot, "engine", "sovkora-engine-core"), "src", "test", "java", "com", "orazaka", "core", "infrastructure", "adapter", "client", `${name}RestClientTest.java`), `package com.krizaka.orazaka.core.infrastructure.adapter.client;
|
|
656
|
+
|
|
657
|
+
import com.krizaka.orazaka.core.infrastructure.config.${name}ConnectorProperties;
|
|
658
|
+
import org.junit.jupiter.api.Test;
|
|
659
|
+
import static org.assertj.core.api.Assertions.assertThat;
|
|
660
|
+
|
|
661
|
+
class ${name}RestClientTest {
|
|
662
|
+
|
|
663
|
+
@Test
|
|
664
|
+
void shouldCreateWithValidProperties() {
|
|
665
|
+
var props = new ${name}ConnectorProperties("http://localhost:9090", 5000, 3);
|
|
666
|
+
var client = new ${name}RestClient(props);
|
|
667
|
+
assertThat(client).isNotNull();
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
`, workspaceRoot, "RestClient unit test"));
|
|
671
|
+
return {
|
|
672
|
+
files,
|
|
673
|
+
nextSteps: [
|
|
674
|
+
`Add to application.yml: orazaka.connector.${kebab}.base-url=https://api.example.com`,
|
|
675
|
+
`Add env vars to .env: ${kebab.toUpperCase().replaceAll("-", "_")}_BASE_URL, ${kebab.toUpperCase().replaceAll("-", "_")}_API_KEY`,
|
|
676
|
+
`Wire ${name}Client into your service layer`,
|
|
677
|
+
`Run: npx orazaka config to add the new env vars interactively`,
|
|
678
|
+
],
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
// ═══════════════════════════════════════════════════════════════
|
|
682
|
+
// 5. Configuration / Env Var Module
|
|
683
|
+
// ═══════════════════════════════════════════════════════════════
|
|
684
|
+
function generateConfiguration(ctx, workspaceRoot) {
|
|
685
|
+
const name = (0, string_utils_1.pascalCase)(ctx.moduleName);
|
|
686
|
+
const kebab = (0, string_utils_1.kebabCase)(ctx.moduleName);
|
|
687
|
+
const envPrefix = kebab.toUpperCase().replaceAll("-", "_");
|
|
688
|
+
const files = [];
|
|
689
|
+
// Add to .env
|
|
690
|
+
const envFile = path.join(workspaceRoot, ".env");
|
|
691
|
+
if (fs.existsSync(envFile)) {
|
|
692
|
+
let content = fs.readFileSync(envFile, "utf-8");
|
|
693
|
+
const newVars = [
|
|
694
|
+
"",
|
|
695
|
+
`# ─── ${name} Configuration ────────────────────────────`,
|
|
696
|
+
`${envPrefix}_ENABLED=true`,
|
|
697
|
+
`${envPrefix}_ENDPOINT=http://localhost:8080`,
|
|
698
|
+
`${envPrefix}_TIMEOUT_MS=30000`,
|
|
699
|
+
].join("\n");
|
|
700
|
+
if (!content.includes(`${envPrefix}_ENABLED`)) {
|
|
701
|
+
content += "\n" + newVars + "\n";
|
|
702
|
+
fs.writeFileSync(envFile, content, "utf-8");
|
|
703
|
+
files.push({
|
|
704
|
+
path: envFile,
|
|
705
|
+
relativePath: ".env",
|
|
706
|
+
action: "updated",
|
|
707
|
+
description: `Added ${envPrefix}_* environment variables`,
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
files.push({
|
|
712
|
+
path: envFile,
|
|
713
|
+
relativePath: ".env",
|
|
714
|
+
action: "skipped",
|
|
715
|
+
description: `${envPrefix}_* already exists in .env`,
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
// Add to example env
|
|
720
|
+
const exampleEnv = path.join(workspaceRoot, "exemple.env.txt");
|
|
721
|
+
if (fs.existsSync(exampleEnv)) {
|
|
722
|
+
let content = fs.readFileSync(exampleEnv, "utf-8");
|
|
723
|
+
if (!content.includes(`${envPrefix}_ENABLED`)) {
|
|
724
|
+
content += `\n# ${name}\n${envPrefix}_ENABLED=true\n${envPrefix}_ENDPOINT=http://localhost:8080\n${envPrefix}_TIMEOUT_MS=30000\n`;
|
|
725
|
+
fs.writeFileSync(exampleEnv, content, "utf-8");
|
|
726
|
+
files.push({
|
|
727
|
+
path: exampleEnv,
|
|
728
|
+
relativePath: "exemple.env.txt",
|
|
729
|
+
action: "updated",
|
|
730
|
+
description: "Added variables to env template",
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
// Generate Properties class
|
|
735
|
+
const techResult = generateTechnicalFeature(ctx, workspaceRoot);
|
|
736
|
+
files.push(...techResult.files);
|
|
737
|
+
return {
|
|
738
|
+
files,
|
|
739
|
+
nextSteps: [
|
|
740
|
+
`Review and customize the values in .env`,
|
|
741
|
+
`Add to config.command.ts CONFIG_CATEGORIES for interactive editing`,
|
|
742
|
+
...techResult.nextSteps,
|
|
743
|
+
],
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
// ═══════════════════════════════════════════════════════════════
|
|
747
|
+
// Existing Templates (preserved)
|
|
748
|
+
// ═══════════════════════════════════════════════════════════════
|
|
749
|
+
function generateJavaService(ctx) {
|
|
750
|
+
const className = `${(0, string_utils_1.pascalCase)(ctx.moduleName)}Service`;
|
|
751
|
+
const implClassName = `${className}Impl`;
|
|
752
|
+
return {
|
|
753
|
+
interface: `package com.krizaka.orazaka.core.application.service;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* ${className}: ${ctx.description}
|
|
757
|
+
*
|
|
758
|
+
* @since ${ctx.year}
|
|
759
|
+
*/
|
|
760
|
+
public interface ${className} {
|
|
761
|
+
|
|
762
|
+
String execute(String input);
|
|
763
|
+
}
|
|
764
|
+
`,
|
|
765
|
+
implementation: `package com.krizaka.orazaka.core.application.service;
|
|
766
|
+
|
|
767
|
+
import org.slf4j.Logger;
|
|
768
|
+
import org.slf4j.LoggerFactory;
|
|
769
|
+
import org.springframework.stereotype.Service;
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* ${implClassName}: Implementation of ${className}.
|
|
773
|
+
*
|
|
774
|
+
* @since ${ctx.year}
|
|
775
|
+
*/
|
|
776
|
+
@Service
|
|
777
|
+
final class ${implClassName} implements ${className} {
|
|
778
|
+
|
|
779
|
+
private static final Logger log = LoggerFactory.getLogger(${implClassName}.class);
|
|
780
|
+
|
|
781
|
+
@Override
|
|
782
|
+
public String execute(final String input) {
|
|
783
|
+
log.info("Executing {} with input: {}", "${className}", input);
|
|
784
|
+
|
|
785
|
+
// TODO: Implement business logic
|
|
786
|
+
return "Result: " + input;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
`,
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function generateJavaController(ctx) {
|
|
793
|
+
const controllerName = `${(0, string_utils_1.pascalCase)(ctx.moduleName)}Controller`;
|
|
794
|
+
const serviceName = `${(0, string_utils_1.pascalCase)(ctx.moduleName)}Service`;
|
|
795
|
+
const serviceVarName = (0, string_utils_1.camelCase)(ctx.moduleName);
|
|
796
|
+
const endpoint = `/${(0, string_utils_1.kebabCase)(ctx.moduleName)}`;
|
|
797
|
+
return `package com.krizaka.orazaka.conversationservice.infrastructure.adapter.rest;
|
|
798
|
+
|
|
799
|
+
import com.krizaka.orazaka.core.application.service.${serviceName};
|
|
800
|
+
import org.springframework.web.bind.annotation.*;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* ${controllerName}: REST API for ${ctx.description}.
|
|
804
|
+
*
|
|
805
|
+
* @since ${ctx.year}
|
|
806
|
+
*/
|
|
807
|
+
@RestController
|
|
808
|
+
@RequestMapping("${endpoint}")
|
|
809
|
+
public final class ${controllerName} {
|
|
810
|
+
|
|
811
|
+
private final ${serviceName} ${serviceVarName}Service;
|
|
812
|
+
|
|
813
|
+
${controllerName}(final ${serviceName} ${serviceVarName}Service) {
|
|
814
|
+
this.${serviceVarName}Service = ${serviceVarName}Service;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
@PostMapping("/execute")
|
|
818
|
+
public String execute(@RequestBody final String request) {
|
|
819
|
+
return ${serviceVarName}Service.execute(request);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
@GetMapping("/health")
|
|
823
|
+
public String health() {
|
|
824
|
+
return "OK";
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
`;
|
|
828
|
+
}
|
|
829
|
+
function generateTypeScriptHook(ctx) {
|
|
830
|
+
const hookName = `use${(0, string_utils_1.pascalCase)(ctx.moduleName)}`;
|
|
831
|
+
const endpoint = `/${(0, string_utils_1.kebabCase)(ctx.moduleName)}`;
|
|
832
|
+
return `import { useState, useCallback } from "react";
|
|
833
|
+
|
|
834
|
+
export function ${hookName}() {
|
|
835
|
+
const [loading, setLoading] = useState(false);
|
|
836
|
+
const [error, setError] = useState<string | null>(null);
|
|
837
|
+
const [data, setData] = useState<unknown>(null);
|
|
838
|
+
|
|
839
|
+
const execute = useCallback(async (input: string) => {
|
|
840
|
+
setLoading(true);
|
|
841
|
+
setError(null);
|
|
842
|
+
try {
|
|
843
|
+
const response = await fetch("${endpoint}/execute", {
|
|
844
|
+
method: "POST",
|
|
845
|
+
headers: { "Content-Type": "application/json" },
|
|
846
|
+
body: JSON.stringify({ input }),
|
|
847
|
+
});
|
|
848
|
+
if (!response.ok) throw new Error(\`HTTP Error: \${response.status}\`);
|
|
849
|
+
const result = await response.json();
|
|
850
|
+
setData(result);
|
|
851
|
+
} catch (err) {
|
|
852
|
+
setError(err instanceof Error ? err.message : "Unknown error");
|
|
853
|
+
} finally {
|
|
854
|
+
setLoading(false);
|
|
855
|
+
}
|
|
856
|
+
}, []);
|
|
857
|
+
|
|
858
|
+
return { execute, loading, error, data };
|
|
859
|
+
}
|
|
860
|
+
`;
|
|
861
|
+
}
|
|
862
|
+
function generateSqlMigration(ctx) {
|
|
863
|
+
const tableName = (0, string_utils_1.kebabCase)(ctx.moduleName).replaceAll("-", "_");
|
|
864
|
+
return `-- Migration: Create ${tableName} table
|
|
865
|
+
-- Author: Orazaka | Date: ${new Date().toISOString()}
|
|
866
|
+
|
|
867
|
+
CREATE TABLE IF NOT EXISTS ${tableName} (
|
|
868
|
+
id SERIAL PRIMARY KEY,
|
|
869
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
870
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
871
|
+
name VARCHAR(255) NOT NULL,
|
|
872
|
+
CONSTRAINT ${tableName}_unique_name UNIQUE (name)
|
|
873
|
+
);
|
|
874
|
+
|
|
875
|
+
CREATE INDEX idx_${tableName}_created_at ON ${tableName}(created_at DESC);
|
|
876
|
+
`;
|
|
877
|
+
}
|
|
878
|
+
function generateDockerComposeService(ctx) {
|
|
879
|
+
const serviceName = (0, string_utils_1.kebabCase)(ctx.moduleName);
|
|
880
|
+
return ` ${serviceName}:
|
|
881
|
+
image: node:24-slim
|
|
882
|
+
container_name: orazaka-${serviceName}
|
|
883
|
+
working_dir: /app
|
|
884
|
+
ports:
|
|
885
|
+
- "3000:3000"
|
|
886
|
+
volumes:
|
|
887
|
+
- ./${serviceName}:/app
|
|
888
|
+
command: npm run start
|
|
889
|
+
restart: unless-stopped
|
|
890
|
+
networks:
|
|
891
|
+
- orazaka-network
|
|
892
|
+
`;
|
|
893
|
+
}
|