Skip to content

Commit f845e62

Browse files
authored
Add AI setup. (#93) (#102)
1 parent 607a2a9 commit f845e62

File tree

9 files changed

+143
-45
lines changed

9 files changed

+143
-45
lines changed

docs/ai-setup.md renamed to docs/ai.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ Storm's design principles align naturally with how AI coding tools operate:
128128
| Design Choice | Why it helps AI |
129129
|---------------|-----------------|
130130
| **Immutable entities** | No hidden state transitions for the AI to track or miss |
131-
| **Explicit SQL** | The generated SQL is visible and predictable; the AI can reason about queries directly |
132131
| **No proxies** | The entity class *is* the entity; no invisible bytecode transformations to account for |
133132
| **No persistence context** | No session scope, flush ordering, or detachment rules that require deep framework knowledge |
134133
| **Convention over configuration** | Fewer annotations and config files for the AI to keep consistent |

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import TabItem from '@theme/TabItem';
88

99
# ST/ORM
1010

11-
:::info Built for the AI Era
12-
Storm's immutable design, skills, and secure MCP schema access make it the ORM that AI coding tools get right consistently. Install with `npm install -g @storm-orm/cli`, then run `storm init` in your project. See [AI-Assisted Development](ai-setup.md).
11+
:::info Built for AI
12+
Storm's concise API, strict conventions, and absence of hidden complexity make it optimized for AI-assisted development. Combined with AI skills and secure schema access via MCP, AI coding tools generate correct Storm code consistently. Install with `npm install -g @storm-orm/cli` and run `storm init` in your project. See [AI-Assisted Development](ai.md).
1313
:::
1414

1515
**Storm** is a modern, high-performance ORM for Kotlin 2.0+ and Java 21+, built around a powerful SQL template engine. It focuses on simplicity, type safety, and predictable performance through immutable models and compile-time metadata.

storm-cli/storm.mjs

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ async function checkbox({ message, choices }) {
316316
const label = atCursor ? boltYellow(choices[i].name) : choices[i].name;
317317
out += `\x1b[2K ${prefix} ${check} ${label}\n`;
318318
}
319-
out += `\x1b[2K${dimText(' Space to toggle, Enter to confirm')}`;
319+
out += `\x1b[2K${dimText(' Space to toggle, Enter to confirm')}\n`;
320320
linesWritten = choices.length + 2;
321321
stdout.write(out);
322322
}
@@ -558,19 +558,10 @@ async function fetchRules() {
558558
}
559559
}
560560

561-
async function fetchSchemaRules() {
562-
try {
563-
const res = await fetch(`${SKILLS_BASE_URL}/storm-schema-rules.md`);
564-
if (!res.ok) throw new Error(`${res.status}`);
565-
return await res.text();
566-
} catch {
567-
return null;
568-
}
569-
}
570561

571-
async function fetchSkillIndex() {
562+
async function fetchSkillIndex(language) {
572563
try {
573-
const res = await fetch(`${SKILLS_BASE_URL}/index.json`);
564+
const res = await fetch(`${SKILLS_BASE_URL}/index-${language}.json`);
574565
if (!res.ok) throw new Error(`${res.status}`);
575566
return await res.json();
576567
} catch {
@@ -1107,16 +1098,6 @@ function registerMcp(toolConfig, stormDir, created, appended) {
11071098
(isNew ? created : appended).push(toolConfig.mcpFile);
11081099
}
11091100

1110-
async function installSchemaRules(toolConfig, created, appended) {
1111-
const schemaRules = await fetchSchemaRules();
1112-
if (!schemaRules) return;
1113-
1114-
// Install as a skill file so all tools learn about the MCP tools.
1115-
if (toolConfig.skillPath) {
1116-
const content = `${STORM_SKILL_MARKER} storm-schema-rules -->\n${schemaRules}`;
1117-
installSkill('storm-schema-rules', content, toolConfig, created);
1118-
}
1119-
}
11201101

11211102
// ─── Database setup ──────────────────────────────────────────────────────────
11221103

@@ -1225,8 +1206,11 @@ async function setup() {
12251206
await printWelcome();
12261207

12271208
// Step 1: Select AI tools.
1209+
console.log(' Storm installs rules and skills for your AI coding tools.');
1210+
console.log(' Select the tools you use in this project.');
1211+
console.log();
12281212
const tools = await checkbox({
1229-
message: 'Select AI tools to configure',
1213+
message: 'Which AI tools do you use?',
12301214
choices: [
12311215
{ name: 'Claude Code', value: 'claude', checked: true },
12321216
{ name: 'Cursor', value: 'cursor' },
@@ -1241,6 +1225,24 @@ async function setup() {
12411225
return;
12421226
}
12431227

1228+
// Step 1b: Select language(s).
1229+
console.log();
1230+
console.log(' Storm provides language-specific skills for entity creation,');
1231+
console.log(' repositories, queries, and SQL templates.');
1232+
console.log();
1233+
const languages = await checkbox({
1234+
message: 'Which language(s) does this project use?',
1235+
choices: [
1236+
{ name: 'Kotlin', value: 'kotlin', checked: true },
1237+
{ name: 'Java (requires --enable-preview on JDK 21)', value: 'java' },
1238+
],
1239+
});
1240+
1241+
if (languages.length === 0) {
1242+
console.log(boltYellow('\nNo language selected. Run again when ready.'));
1243+
return;
1244+
}
1245+
12441246
console.log();
12451247

12461248
// Step 2: Fetch and install rules.
@@ -1249,13 +1251,16 @@ async function setup() {
12491251
const skipped = [];
12501252

12511253
console.log(dimText(' Fetching content from https://orm.st...'));
1252-
const [stormRules, skillIndex] = await Promise.all([fetchRules(), fetchSkillIndex()]);
1254+
const fetchPromises = [fetchRules(), ...languages.map(l => fetchSkillIndex(l))];
1255+
const [stormRules, ...skillIndexes] = await Promise.all(fetchPromises);
12531256
if (!stormRules) {
12541257
console.log(boltYellow('\n Could not fetch Storm rules from https://orm.st. Check your connection.'));
12551258
return;
12561259
}
1257-
const skillNames = skillIndex?.skills ?? [];
1258-
const schemaSkillNames = skillIndex?.schemaSkills ?? [];
1260+
1261+
// Merge skill lists from all selected languages (deduplicated).
1262+
const skillNames = [...new Set(skillIndexes.flatMap(idx => idx?.skills ?? []))];
1263+
const schemaSkillNames = [...new Set(skillIndexes.flatMap(idx => idx?.schemaSkills ?? []))];
12591264

12601265
for (const toolId of tools) {
12611266
const config = TOOL_CONFIGS[toolId];
@@ -1291,10 +1296,15 @@ async function setup() {
12911296
let stormDir = null;
12921297

12931298
if (mcpTools.length > 0) {
1299+
console.log();
1300+
console.log(' Storm can connect to your local development database so AI tools');
1301+
console.log(' can read your schema (tables, columns, foreign keys) and generate');
1302+
console.log(' entities automatically. Credentials are stored locally and never');
1303+
console.log(' exposed to the AI.');
12941304
console.log();
12951305
const connectDb = await confirm({
1296-
message: 'Connect to a local database for schema-aware assistance?',
1297-
defaultValue: false,
1306+
message: 'Connect to a local database?',
1307+
defaultValue: true,
12981308
});
12991309

13001310
if (connectDb) {
@@ -1304,12 +1314,28 @@ async function setup() {
13041314
}
13051315
}
13061316

1307-
// Step 5: Register MCP and install schema skills for each tool.
1317+
// Step 5: Register MCP, append schema rules, and install schema skills.
13081318
if (dbConfigured) {
1319+
// Fetch schema rules and append to each tool's rules block.
1320+
const schemaRules = await fetchSkill('storm-schema-rules');
13091321
for (const toolId of tools) {
13101322
const config = TOOL_CONFIGS[toolId];
13111323
registerMcp(config, stormDir, created, appended);
1312-
await installSchemaRules(config, created, appended);
1324+
if (config.rulesFile && schemaRules) {
1325+
const rulesPath = join(process.cwd(), config.rulesFile);
1326+
if (existsSync(rulesPath)) {
1327+
const existing = readFileSync(rulesPath, 'utf-8');
1328+
// Insert schema rules inside the STORM block if not already present.
1329+
if (!existing.includes('Database Schema Access')) {
1330+
const endMarker = existing.indexOf(MARKER_END);
1331+
if (endMarker !== -1) {
1332+
const updated = existing.substring(0, endMarker) + '\n' + schemaRules.replace(/^<!-- storm-managed: \S+ -->\n/, '') + '\n' + existing.substring(endMarker);
1333+
writeFileSync(rulesPath, updated);
1334+
appended.push(config.rulesFile);
1335+
}
1336+
}
1337+
}
1338+
}
13131339
}
13141340

13151341
// Fetch and install schema-dependent skills.
@@ -1359,7 +1385,7 @@ async function setup() {
13591385
} else {
13601386
console.log(` ${boltYellow('Quick start:')} Your AI tools now know Storm's patterns and conventions.`);
13611387
}
1362-
console.log(` ${dimText('Learn more:')} https://orm.st/ai-setup`);
1388+
console.log(` ${dimText('Learn more:')} https://orm.st/ai`);
13631389
console.log();
13641390
}
13651391

@@ -1381,7 +1407,7 @@ async function run() {
13811407
--help, -h Show this help message
13821408
--version, -v Show version
13831409
1384-
${dimText('Learn more:')} https://orm.st/ai-setup
1410+
${dimText('Learn more:')} https://orm.st/ai
13851411
`);
13861412
return;
13871413
}

website/scripts/generate-llms-full.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ DOCS=(
6464
faq.md
6565
migration-from-jpa.md
6666
glossary.md
67-
ai-setup.md
67+
ai.md
6868
# API Reference
6969
api-kotlin.md
7070
api-java.md

website/static/llms-full.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
> GitHub: https://github.com/storm-orm/storm-framework
1515
> License: Apache 2.0
1616

17-
# Generated: 2026-03-22T21:20:08Z
17+
# Generated: 2026-03-23T08:27:40Z
1818

1919
========================================
2020
## Source: index.md
@@ -23,7 +23,7 @@
2323
# ST/ORM
2424

2525
> **Info:**
26-
Storm's immutable design, skills, and secure MCP schema access make it the ORM that AI coding tools get right consistently. Install with `npm install -g @storm-orm/cli`, then run `storm init` in your project. See [AI-Assisted Development](ai-setup.md).
26+
Storm's concise API, strict conventions, and absence of hidden complexity make it optimized for AI-assisted development. Combined with AI skills and secure schema access via MCP, AI coding tools generate correct Storm code consistently. Install with `npm install -g @storm-orm/cli` and run `storm init` in your project. See [AI-Assisted Development](ai.md).
2727

2828
**Storm** is a modern, high-performance ORM for Kotlin 2.0+ and Java 21+, built around a powerful SQL template engine. It focuses on simplicity, type safety, and predictable performance through immutable models and compile-time metadata.
2929

@@ -18449,7 +18449,7 @@ A window of query results from a scrolling operation. A `Window<R>` contains the
1844918449

1845018450

1845118451
========================================
18452-
## Source: ai-setup.md
18452+
## Source: ai.md
1845318453
========================================
1845418454

1845518455
# AI-Assisted Development
@@ -18571,7 +18571,6 @@ Storm's design principles align naturally with how AI coding tools operate:
1857118571
| Design Choice | Why it helps AI |
1857218572
|---------------|-----------------|
1857318573
| **Immutable entities** | No hidden state transitions for the AI to track or miss |
18574-
| **Explicit SQL** | The generated SQL is visible and predictable; the AI can reason about queries directly |
1857518574
| **No proxies** | The entity class *is* the entity; no invisible bytecode transformations to account for |
1857618575
| **No persistence context** | No session scope, flush ordering, or detachment rules that require deep framework knowledge |
1857718576
| **Convention over configuration** | Fewer annotations and config files for the AI to keep consistent |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"skills": [
3+
"storm-setup",
4+
"storm-docs",
5+
"storm-entity-java",
6+
"storm-repository-java",
7+
"storm-query-java",
8+
"storm-sql-java",
9+
"storm-migration"
10+
],
11+
"schemaSkills": [
12+
"storm-schema",
13+
"storm-validate",
14+
"storm-entity-from-schema"
15+
]
16+
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
{
22
"skills": [
3+
"storm-setup",
34
"storm-docs",
45
"storm-entity-kotlin",
5-
"storm-entity-java",
66
"storm-repository-kotlin",
7-
"storm-repository-java",
87
"storm-query-kotlin",
9-
"storm-query-java",
108
"storm-sql-kotlin",
11-
"storm-sql-java",
129
"storm-migration"
1310
],
1411
"schemaSkills": [

website/static/skills/storm-rules.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ This project uses the [Storm ORM framework](https://orm.st) for database access.
44
Storm is a modern SQL Template and ORM for Kotlin 2.0+ and Java 21+, built around
55
immutable data classes and records instead of proxied entities.
66

7-
Use the Storm skills for detailed guidance on entities, repositories, queries, and more.
7+
If the project does not yet have Storm dependencies in its build file (pom.xml,
8+
build.gradle.kts), use /storm-setup to help the user configure their project.
9+
Detect the project's Kotlin or Java version from the build file to recommend the
10+
correct dependencies and compiler plugin version.
11+
12+
Available Storm skills:
13+
- /storm-setup - Help configure Maven/Gradle dependencies
14+
- /storm-docs - Load full Storm documentation
15+
- /storm-entity-kotlin or /storm-entity-java - Create entities
16+
- /storm-repository-kotlin or /storm-repository-java - Write repositories
17+
- /storm-query-kotlin or /storm-query-java - Write queries with the QueryBuilder
18+
- /storm-sql-kotlin or /storm-sql-java - Write SQL Templates
19+
- /storm-migration - Write Flyway/Liquibase migration SQL
20+
21+
When the user asks about Storm topics, suggest the relevant skill if they need detailed guidance.
822

923
Quick reference: https://orm.st/llms.txt
1024
Full documentation: https://orm.st/llms-full.txt
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Help the user set up Storm ORM in their project.
2+
3+
Fetch https://orm.st/llms-full.txt for complete reference (see the Installation section).
4+
5+
Before suggesting dependencies, read the project's build file (pom.xml, build.gradle.kts, or build.gradle) to detect:
6+
- Build tool (Maven or Gradle)
7+
- Language and version (Kotlin version from kotlin plugin, Java version from sourceCompatibility/release)
8+
- Existing dependencies (Spring Boot, database driver, etc.)
9+
- Fetch the latest Storm version from https://repo1.maven.org/maven2/st/orm/storm-bom/maven-metadata.xml
10+
11+
Core dependencies:
12+
13+
Kotlin (Gradle):
14+
- `implementation(platform("st.orm:storm-bom:<version>"))`
15+
- `implementation("st.orm:storm-kotlin")`
16+
- `runtimeOnly("st.orm:storm-core")`
17+
- `ksp("st.orm:storm-metamodel-ksp")`
18+
- `kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-<kotlin-major.minor>")`
19+
Match the suffix to the project's Kotlin version: 2.0.x uses storm-compiler-plugin-2.0, 2.1.x uses storm-compiler-plugin-2.1, etc.
20+
21+
Java (Maven):
22+
- Import `st.orm:storm-bom` in dependencyManagement
23+
- `st.orm:storm-java21`
24+
- `st.orm:storm-core` (runtime scope)
25+
- `st.orm:storm-metamodel-processor` (provided scope)
26+
- Requires `--enable-preview` in maven-compiler-plugin and maven-surefire-plugin
27+
28+
Spring Boot:
29+
- Kotlin: `st.orm:storm-kotlin-spring-boot-starter`
30+
- Java: `st.orm:storm-spring-boot-starter`
31+
- These replace the core module and include auto-configuration
32+
33+
Serialization (pick one if needed):
34+
- `st.orm:storm-kotlinx-serialization` for kotlinx-serialization
35+
- `st.orm:storm-jackson2` for Jackson 2 (Spring Boot 3.x)
36+
- `st.orm:storm-jackson3` for Jackson 3 (Spring Boot 4+)
37+
38+
Database dialects (add as runtime dependency):
39+
- `st.orm:storm-postgresql`
40+
- `st.orm:storm-mysql`
41+
- `st.orm:storm-mariadb`
42+
- `st.orm:storm-oracle`
43+
- `st.orm:storm-mssqlserver`
44+
45+
After configuring dependencies, remind the user to rebuild so the metamodel classes are generated.
46+
47+
Do not hardcode versions. Always fetch the latest from Maven Central or use the version already in the project's BOM.

0 commit comments

Comments
 (0)