@famgia/omnify-core 0.0.138 → 0.0.140
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/dist/index.cjs +459 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +245 -1
- package/dist/index.d.ts +245 -1
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
- package/src/ai-guides/config/rules.yaml +505 -0
- package/src/ai-guides/knowledge/agents/architect.md +150 -0
- package/src/ai-guides/knowledge/agents/developer.md +190 -0
- package/src/ai-guides/knowledge/agents/reviewer.md +134 -0
- package/src/ai-guides/knowledge/agents/tester.md +196 -0
- package/src/ai-guides/knowledge/checklists/backend.md +112 -0
- package/src/ai-guides/knowledge/checklists/react.md +108 -0
- package/src/ai-guides/knowledge/claude-rules/laravel-controllers.md +57 -0
- package/src/ai-guides/knowledge/claude-rules/laravel-migrations.md +47 -0
- package/src/ai-guides/knowledge/claude-rules/laravel-tests.md +52 -0
- package/src/ai-guides/knowledge/claude-rules/naming.md +369 -0
- package/src/ai-guides/knowledge/claude-rules/performance.md +256 -0
- package/src/ai-guides/knowledge/claude-rules/php-standards.md +305 -0
- package/src/ai-guides/knowledge/claude-rules/react-components.md +67 -0
- package/src/ai-guides/knowledge/claude-rules/schema-yaml.md +83 -0
- package/src/ai-guides/knowledge/claude-rules/security.md +164 -0
- package/src/ai-guides/knowledge/cursor-rules/basemodel-readonly.mdc +66 -0
- package/src/ai-guides/knowledge/cursor-rules/baserequest-readonly.mdc +74 -0
- package/src/ai-guides/knowledge/cursor-rules/baseresource-readonly.mdc +78 -0
- package/src/ai-guides/knowledge/cursor-rules/laravel-controller.mdc +421 -0
- package/src/ai-guides/knowledge/cursor-rules/laravel-request.mdc +112 -0
- package/src/ai-guides/knowledge/cursor-rules/laravel-resource.mdc +73 -0
- package/src/ai-guides/knowledge/cursor-rules/laravel-review.mdc +69 -0
- package/src/ai-guides/knowledge/cursor-rules/laravel-testing.mdc +138 -0
- package/src/ai-guides/knowledge/cursor-rules/laravel.mdc +138 -0
- package/src/ai-guides/knowledge/cursor-rules/migrations-workflow.mdc +224 -0
- package/src/ai-guides/knowledge/cursor-rules/model-editable.mdc +120 -0
- package/src/ai-guides/knowledge/cursor-rules/omnify-migrations.mdc +109 -0
- package/src/ai-guides/knowledge/cursor-rules/omnify-schema.mdc +358 -0
- package/src/ai-guides/knowledge/cursor-rules/omnify.mdc +58 -0
- package/src/ai-guides/knowledge/cursor-rules/react-design.mdc +693 -0
- package/src/ai-guides/knowledge/cursor-rules/react-form.mdc +277 -0
- package/src/ai-guides/knowledge/cursor-rules/react-services.mdc +304 -0
- package/src/ai-guides/knowledge/cursor-rules/react.mdc +336 -0
- package/src/ai-guides/knowledge/cursor-rules/request-editable.mdc +111 -0
- package/src/ai-guides/knowledge/cursor-rules/resource-editable.mdc +125 -0
- package/src/ai-guides/knowledge/cursor-rules/schema-create.mdc +446 -0
- package/src/ai-guides/knowledge/cursor-rules/validation-rules.mdc +181 -0
- package/src/ai-guides/knowledge/laravel/README.md +59 -0
- package/src/ai-guides/knowledge/laravel/architecture.md +424 -0
- package/src/ai-guides/knowledge/laravel/authentication.md +588 -0
- package/src/ai-guides/knowledge/laravel/controller.md +484 -0
- package/src/ai-guides/knowledge/laravel/datetime.md +334 -0
- package/src/ai-guides/knowledge/laravel/migrations-team.md +376 -0
- package/src/ai-guides/knowledge/laravel/openapi.md +449 -0
- package/src/ai-guides/knowledge/laravel/request.md +450 -0
- package/src/ai-guides/knowledge/laravel/resource.md +516 -0
- package/src/ai-guides/knowledge/laravel/service.md +503 -0
- package/src/ai-guides/knowledge/laravel/testing.md +1504 -0
- package/src/ai-guides/knowledge/omnify/antdesign-guide.md +401 -0
- package/src/ai-guides/knowledge/omnify/config-guide.md +253 -0
- package/src/ai-guides/knowledge/omnify/japan-guide.md +186 -0
- package/src/ai-guides/knowledge/omnify/laravel-guide.md +61 -0
- package/src/ai-guides/knowledge/omnify/react-form-guide.md +259 -0
- package/src/ai-guides/knowledge/omnify/schema-guide.md +144 -0
- package/src/ai-guides/knowledge/omnify/typescript-guide.md +310 -0
- package/src/ai-guides/knowledge/react/README.md +221 -0
- package/src/ai-guides/knowledge/react/antd-guide.md +457 -0
- package/src/ai-guides/knowledge/react/checklist.md +108 -0
- package/src/ai-guides/knowledge/react/datetime-guide.md +137 -0
- package/src/ai-guides/knowledge/react/design-philosophy.md +363 -0
- package/src/ai-guides/knowledge/react/i18n-guide.md +211 -0
- package/src/ai-guides/knowledge/react/laravel-integration.md +181 -0
- package/src/ai-guides/knowledge/react/service-pattern.md +180 -0
- package/src/ai-guides/knowledge/react/tanstack-query.md +339 -0
- package/src/ai-guides/knowledge/react/types-guide.md +671 -0
- package/src/ai-guides/knowledge/workflows/bug-fix.md +201 -0
- package/src/ai-guides/knowledge/workflows/code-review.md +164 -0
- package/src/ai-guides/knowledge/workflows/new-feature.md +327 -0
package/dist/index.cjs
CHANGED
|
@@ -35,9 +35,12 @@ __export(index_exports, {
|
|
|
35
35
|
OmnifyError: () => OmnifyError,
|
|
36
36
|
PluginManager: () => PluginManager,
|
|
37
37
|
VersionStore: () => VersionStore,
|
|
38
|
+
allAdapters: () => allAdapters,
|
|
39
|
+
antigravityAdapter: () => antigravityAdapter,
|
|
38
40
|
atlasError: () => atlasError,
|
|
39
41
|
atlasNotFoundError: () => atlasNotFoundError,
|
|
40
42
|
circularReferenceError: () => circularReferenceError,
|
|
43
|
+
claudeAdapter: () => claudeAdapter,
|
|
41
44
|
configError: () => configError,
|
|
42
45
|
configNotFoundError: () => configNotFoundError,
|
|
43
46
|
createFileLoadedSchema: () => createFileLoadedSchema,
|
|
@@ -45,6 +48,7 @@ __export(index_exports, {
|
|
|
45
48
|
createOmnify: () => createOmnify,
|
|
46
49
|
createPluginManager: () => createPluginManager,
|
|
47
50
|
createVersionStore: () => createVersionStore,
|
|
51
|
+
cursorAdapter: () => cursorAdapter,
|
|
48
52
|
duplicateSchemaError: () => duplicateSchemaError,
|
|
49
53
|
ensureFileSchema: () => ensureFileSchema,
|
|
50
54
|
err: () => import_omnify_types3.err,
|
|
@@ -58,9 +62,13 @@ __export(index_exports, {
|
|
|
58
62
|
formatError: () => formatError,
|
|
59
63
|
formatErrorPlain: () => formatErrorPlain,
|
|
60
64
|
formatErrorSummary: () => formatErrorSummary,
|
|
65
|
+
generateAIGuides: () => generateAIGuides,
|
|
61
66
|
generateFileSchemaYaml: () => generateFileSchemaYaml,
|
|
62
67
|
generationError: () => generationError,
|
|
68
|
+
getAdapter: () => getAdapter,
|
|
69
|
+
getAdapters: () => getAdapters,
|
|
63
70
|
getAssociationMetadata: () => getAssociationMetadata,
|
|
71
|
+
getAvailableAdapters: () => getAvailableAdapters,
|
|
64
72
|
getCustomTypeNames: () => getCustomTypeNames,
|
|
65
73
|
getEntitySchemas: () => getEntitySchemas,
|
|
66
74
|
getEnumSchemas: () => getEnumSchemas,
|
|
@@ -99,6 +107,7 @@ __export(index_exports, {
|
|
|
99
107
|
schemaNotFoundError: () => schemaNotFoundError,
|
|
100
108
|
schemaParseError: () => schemaParseError,
|
|
101
109
|
schemasHaveFileProperties: () => schemasHaveFileProperties,
|
|
110
|
+
shouldGenerateAIGuides: () => shouldGenerateAIGuides,
|
|
102
111
|
validateAssociations: () => validateAssociations,
|
|
103
112
|
validateDefaultValue: () => validateDefaultValue,
|
|
104
113
|
validateEnumSchema: () => validateEnumSchema,
|
|
@@ -5099,6 +5108,447 @@ var VersionStore = class {
|
|
|
5099
5108
|
function createVersionStore(config) {
|
|
5100
5109
|
return new VersionStore(config);
|
|
5101
5110
|
}
|
|
5111
|
+
|
|
5112
|
+
// src/ai-guides/adapters/cursor.ts
|
|
5113
|
+
function replacePlaceholders(content, placeholders) {
|
|
5114
|
+
let result = content;
|
|
5115
|
+
for (const [key, value] of Object.entries(placeholders)) {
|
|
5116
|
+
result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
5117
|
+
}
|
|
5118
|
+
return result;
|
|
5119
|
+
}
|
|
5120
|
+
var cursorAdapter = {
|
|
5121
|
+
name: "cursor",
|
|
5122
|
+
outputDir: ".cursor/rules/omnify",
|
|
5123
|
+
transform(content, rule, placeholders) {
|
|
5124
|
+
const target = rule.targets.cursor;
|
|
5125
|
+
let transformedContent = replacePlaceholders(content, placeholders);
|
|
5126
|
+
if (transformedContent.startsWith("---")) {
|
|
5127
|
+
return transformedContent;
|
|
5128
|
+
}
|
|
5129
|
+
const description = target?.description || "";
|
|
5130
|
+
const globs = target?.globs || [];
|
|
5131
|
+
const alwaysApply = target?.alwaysApply ?? false;
|
|
5132
|
+
const frontmatter = `---
|
|
5133
|
+
description: "${description}"
|
|
5134
|
+
globs: ${JSON.stringify(globs)}
|
|
5135
|
+
alwaysApply: ${alwaysApply}
|
|
5136
|
+
---
|
|
5137
|
+
|
|
5138
|
+
`;
|
|
5139
|
+
return frontmatter + transformedContent;
|
|
5140
|
+
},
|
|
5141
|
+
getFilename(rule) {
|
|
5142
|
+
const target = rule.targets.cursor;
|
|
5143
|
+
if (target?.filename) {
|
|
5144
|
+
return target.filename;
|
|
5145
|
+
}
|
|
5146
|
+
return `${rule.id}.mdc`;
|
|
5147
|
+
},
|
|
5148
|
+
isEnabled(rule) {
|
|
5149
|
+
const target = rule.targets.cursor;
|
|
5150
|
+
return target?.enabled ?? false;
|
|
5151
|
+
},
|
|
5152
|
+
getOutputPath(rule) {
|
|
5153
|
+
const filename = this.getFilename(rule);
|
|
5154
|
+
return filename;
|
|
5155
|
+
}
|
|
5156
|
+
};
|
|
5157
|
+
|
|
5158
|
+
// src/ai-guides/adapters/claude.ts
|
|
5159
|
+
function replacePlaceholders2(content, placeholders) {
|
|
5160
|
+
let result = content;
|
|
5161
|
+
for (const [key, value] of Object.entries(placeholders)) {
|
|
5162
|
+
result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
5163
|
+
}
|
|
5164
|
+
return result;
|
|
5165
|
+
}
|
|
5166
|
+
var claudeAdapter = {
|
|
5167
|
+
name: "claude",
|
|
5168
|
+
outputDir: ".claude/omnify",
|
|
5169
|
+
transform(content, rule, placeholders) {
|
|
5170
|
+
return replacePlaceholders2(content, placeholders);
|
|
5171
|
+
},
|
|
5172
|
+
getFilename(rule) {
|
|
5173
|
+
const target = rule.targets.claude;
|
|
5174
|
+
if (target?.filename) {
|
|
5175
|
+
return target.filename;
|
|
5176
|
+
}
|
|
5177
|
+
return `${rule.id}.md`;
|
|
5178
|
+
},
|
|
5179
|
+
isEnabled(rule) {
|
|
5180
|
+
const target = rule.targets.claude;
|
|
5181
|
+
return target?.enabled ?? false;
|
|
5182
|
+
},
|
|
5183
|
+
getOutputPath(rule) {
|
|
5184
|
+
const target = rule.targets.claude;
|
|
5185
|
+
const filename = this.getFilename(rule);
|
|
5186
|
+
const subdir = target?.subdir || rule.category;
|
|
5187
|
+
if (subdir) {
|
|
5188
|
+
return `${subdir}/${filename}`;
|
|
5189
|
+
}
|
|
5190
|
+
return filename;
|
|
5191
|
+
}
|
|
5192
|
+
};
|
|
5193
|
+
|
|
5194
|
+
// src/ai-guides/adapters/antigravity.ts
|
|
5195
|
+
function replacePlaceholders3(content, placeholders) {
|
|
5196
|
+
let result = content;
|
|
5197
|
+
for (const [key, value] of Object.entries(placeholders)) {
|
|
5198
|
+
result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
5199
|
+
}
|
|
5200
|
+
return result;
|
|
5201
|
+
}
|
|
5202
|
+
var antigravityAdapter = {
|
|
5203
|
+
name: "antigravity",
|
|
5204
|
+
outputDir: ".agent/rules/omnify",
|
|
5205
|
+
transform(content, rule, placeholders) {
|
|
5206
|
+
const target = rule.targets.antigravity;
|
|
5207
|
+
let transformedContent = replacePlaceholders3(content, placeholders);
|
|
5208
|
+
if (transformedContent.startsWith("---")) {
|
|
5209
|
+
const endIndex = transformedContent.indexOf("---", 3);
|
|
5210
|
+
if (endIndex !== -1) {
|
|
5211
|
+
const existingFrontmatter = transformedContent.substring(3, endIndex).trim();
|
|
5212
|
+
const bodyContent = transformedContent.substring(endIndex + 3).trim();
|
|
5213
|
+
const antigravityFrontmatter = buildAntigravityFrontmatter(rule, target, existingFrontmatter);
|
|
5214
|
+
return `---
|
|
5215
|
+
${antigravityFrontmatter}---
|
|
5216
|
+
|
|
5217
|
+
${bodyContent}`;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
const frontmatter = buildAntigravityFrontmatter(rule, target);
|
|
5221
|
+
return `---
|
|
5222
|
+
${frontmatter}---
|
|
5223
|
+
|
|
5224
|
+
${transformedContent}`;
|
|
5225
|
+
},
|
|
5226
|
+
getFilename(rule) {
|
|
5227
|
+
const target = rule.targets.antigravity;
|
|
5228
|
+
if (target?.filename) {
|
|
5229
|
+
return target.filename;
|
|
5230
|
+
}
|
|
5231
|
+
return `${rule.id}.md`;
|
|
5232
|
+
},
|
|
5233
|
+
isEnabled(rule) {
|
|
5234
|
+
const target = rule.targets.antigravity;
|
|
5235
|
+
return target?.enabled ?? false;
|
|
5236
|
+
},
|
|
5237
|
+
getOutputPath(rule) {
|
|
5238
|
+
const filename = this.getFilename(rule);
|
|
5239
|
+
return filename;
|
|
5240
|
+
}
|
|
5241
|
+
};
|
|
5242
|
+
function buildAntigravityFrontmatter(rule, target, existingFrontmatter) {
|
|
5243
|
+
const lines = [];
|
|
5244
|
+
lines.push(`id: ${rule.id}`);
|
|
5245
|
+
const description = target?.description || extractDescription(existingFrontmatter) || rule.id;
|
|
5246
|
+
lines.push(`description: "${description}"`);
|
|
5247
|
+
lines.push(`category: ${rule.category || "general"}`);
|
|
5248
|
+
const priority = target?.priority || "medium";
|
|
5249
|
+
lines.push(`priority: ${priority}`);
|
|
5250
|
+
const globs = target?.globs || extractGlobs(existingFrontmatter) || [];
|
|
5251
|
+
if (globs.length > 0) {
|
|
5252
|
+
lines.push(`globs:`);
|
|
5253
|
+
for (const glob of globs) {
|
|
5254
|
+
lines.push(` - "${glob}"`);
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
const tags = target?.tags || inferTags(rule);
|
|
5258
|
+
if (tags.length > 0) {
|
|
5259
|
+
lines.push(`tags:`);
|
|
5260
|
+
for (const tag of tags) {
|
|
5261
|
+
lines.push(` - ${tag}`);
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
return lines.join("\n") + "\n";
|
|
5265
|
+
}
|
|
5266
|
+
function extractDescription(frontmatter) {
|
|
5267
|
+
if (!frontmatter) return void 0;
|
|
5268
|
+
const match = frontmatter.match(/description:\s*["']?([^"'\n]+)["']?/);
|
|
5269
|
+
return match?.[1];
|
|
5270
|
+
}
|
|
5271
|
+
function extractGlobs(frontmatter) {
|
|
5272
|
+
if (!frontmatter) return [];
|
|
5273
|
+
const match = frontmatter.match(/globs:\s*\[([^\]]+)\]/);
|
|
5274
|
+
if (match) {
|
|
5275
|
+
return match[1].split(",").map((g) => g.trim().replace(/["']/g, ""));
|
|
5276
|
+
}
|
|
5277
|
+
return [];
|
|
5278
|
+
}
|
|
5279
|
+
function inferTags(rule) {
|
|
5280
|
+
const tags = [];
|
|
5281
|
+
if (rule.category) {
|
|
5282
|
+
const parts = rule.category.split("/");
|
|
5283
|
+
tags.push(...parts.filter((p) => p !== "guides"));
|
|
5284
|
+
}
|
|
5285
|
+
if (rule.id.includes("laravel")) tags.push("laravel");
|
|
5286
|
+
if (rule.id.includes("react")) tags.push("react");
|
|
5287
|
+
if (rule.id.includes("schema")) tags.push("schema");
|
|
5288
|
+
if (rule.id.includes("omnify")) tags.push("omnify");
|
|
5289
|
+
return [...new Set(tags)];
|
|
5290
|
+
}
|
|
5291
|
+
|
|
5292
|
+
// src/ai-guides/adapters/index.ts
|
|
5293
|
+
var allAdapters = [
|
|
5294
|
+
cursorAdapter,
|
|
5295
|
+
claudeAdapter,
|
|
5296
|
+
antigravityAdapter
|
|
5297
|
+
];
|
|
5298
|
+
function getAdapter(name) {
|
|
5299
|
+
return allAdapters.find((a) => a.name === name);
|
|
5300
|
+
}
|
|
5301
|
+
function getAdapters(names) {
|
|
5302
|
+
if (!names || names.length === 0) {
|
|
5303
|
+
return allAdapters;
|
|
5304
|
+
}
|
|
5305
|
+
return allAdapters.filter((a) => names.includes(a.name));
|
|
5306
|
+
}
|
|
5307
|
+
|
|
5308
|
+
// src/ai-guides/generator.ts
|
|
5309
|
+
var import_node_fs = require("fs");
|
|
5310
|
+
var import_node_path2 = require("path");
|
|
5311
|
+
var import_node_url = require("url");
|
|
5312
|
+
var import_yaml = require("yaml");
|
|
5313
|
+
var import_meta = {};
|
|
5314
|
+
var __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
|
|
5315
|
+
var __dirname = (0, import_node_path2.dirname)(__filename);
|
|
5316
|
+
function getKnowledgeDir() {
|
|
5317
|
+
const possiblePaths = [
|
|
5318
|
+
// Dev: src内で実行している場合
|
|
5319
|
+
(0, import_node_path2.resolve)(__dirname, "knowledge"),
|
|
5320
|
+
// Dist: dist/から実行、src/ai-guides/knowledge
|
|
5321
|
+
(0, import_node_path2.resolve)(__dirname, "../src/ai-guides/knowledge"),
|
|
5322
|
+
// Installed package: node_modules内
|
|
5323
|
+
(0, import_node_path2.resolve)(__dirname, "../knowledge")
|
|
5324
|
+
];
|
|
5325
|
+
for (const path2 of possiblePaths) {
|
|
5326
|
+
if ((0, import_node_fs.existsSync)(path2)) {
|
|
5327
|
+
return path2;
|
|
5328
|
+
}
|
|
5329
|
+
}
|
|
5330
|
+
throw new Error(`AI guides knowledge directory not found. Tried: ${possiblePaths.join(", ")}`);
|
|
5331
|
+
}
|
|
5332
|
+
function getConfigDir() {
|
|
5333
|
+
const possiblePaths = [
|
|
5334
|
+
// Dev: src内で実行している場合
|
|
5335
|
+
(0, import_node_path2.resolve)(__dirname, "config"),
|
|
5336
|
+
// Dist: dist/から実行、src/ai-guides/config
|
|
5337
|
+
(0, import_node_path2.resolve)(__dirname, "../src/ai-guides/config"),
|
|
5338
|
+
// Installed package: node_modules内
|
|
5339
|
+
(0, import_node_path2.resolve)(__dirname, "../config")
|
|
5340
|
+
];
|
|
5341
|
+
for (const path2 of possiblePaths) {
|
|
5342
|
+
if ((0, import_node_fs.existsSync)(path2)) {
|
|
5343
|
+
return path2;
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
throw new Error(`AI guides config directory not found. Tried: ${possiblePaths.join(", ")}`);
|
|
5347
|
+
}
|
|
5348
|
+
function loadRulesConfig() {
|
|
5349
|
+
const configDir = getConfigDir();
|
|
5350
|
+
const rulesPath = (0, import_node_path2.join)(configDir, "rules.yaml");
|
|
5351
|
+
if (!(0, import_node_fs.existsSync)(rulesPath)) {
|
|
5352
|
+
throw new Error(`Rules config not found: ${rulesPath}`);
|
|
5353
|
+
}
|
|
5354
|
+
const content = (0, import_node_fs.readFileSync)(rulesPath, "utf-8");
|
|
5355
|
+
return (0, import_yaml.parse)(content);
|
|
5356
|
+
}
|
|
5357
|
+
function loadKnowledgeFile(source) {
|
|
5358
|
+
const knowledgeDir = getKnowledgeDir();
|
|
5359
|
+
const filePath = (0, import_node_path2.join)(knowledgeDir, source);
|
|
5360
|
+
if (!(0, import_node_fs.existsSync)(filePath)) {
|
|
5361
|
+
throw new Error(`Knowledge file not found: ${filePath}`);
|
|
5362
|
+
}
|
|
5363
|
+
return (0, import_node_fs.readFileSync)(filePath, "utf-8");
|
|
5364
|
+
}
|
|
5365
|
+
function replacePlaceholders4(content, placeholders) {
|
|
5366
|
+
let result = content;
|
|
5367
|
+
for (const [key, value] of Object.entries(placeholders)) {
|
|
5368
|
+
result = result.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), value);
|
|
5369
|
+
}
|
|
5370
|
+
return result;
|
|
5371
|
+
}
|
|
5372
|
+
function writeOutputFile(filePath, content, dryRun) {
|
|
5373
|
+
if (dryRun) {
|
|
5374
|
+
console.log(`[DRY RUN] Would write: ${filePath}`);
|
|
5375
|
+
return;
|
|
5376
|
+
}
|
|
5377
|
+
const dir = (0, import_node_path2.dirname)(filePath);
|
|
5378
|
+
if (!(0, import_node_fs.existsSync)(dir)) {
|
|
5379
|
+
(0, import_node_fs.mkdirSync)(dir, { recursive: true });
|
|
5380
|
+
}
|
|
5381
|
+
(0, import_node_fs.writeFileSync)(filePath, content);
|
|
5382
|
+
}
|
|
5383
|
+
function generateAIGuides(rootDir, options = {}) {
|
|
5384
|
+
const config = loadRulesConfig();
|
|
5385
|
+
const knowledgeDir = getKnowledgeDir();
|
|
5386
|
+
const adapters = getAdapters(options.adapters);
|
|
5387
|
+
const dryRun = options.dryRun ?? false;
|
|
5388
|
+
const placeholders = {
|
|
5389
|
+
...config.placeholders,
|
|
5390
|
+
...options.placeholders
|
|
5391
|
+
};
|
|
5392
|
+
const result = {
|
|
5393
|
+
counts: {},
|
|
5394
|
+
files: []
|
|
5395
|
+
};
|
|
5396
|
+
for (const adapter of adapters) {
|
|
5397
|
+
result.counts[adapter.name] = 0;
|
|
5398
|
+
}
|
|
5399
|
+
for (const rule of config.guides) {
|
|
5400
|
+
try {
|
|
5401
|
+
const content = loadKnowledgeFile(rule.source);
|
|
5402
|
+
for (const adapter of adapters) {
|
|
5403
|
+
if (!adapter.isEnabled(rule)) {
|
|
5404
|
+
continue;
|
|
5405
|
+
}
|
|
5406
|
+
const transformed = adapter.transform(content, rule, placeholders);
|
|
5407
|
+
const outputPath = adapter.getOutputPath(rule);
|
|
5408
|
+
const fullPath = (0, import_node_path2.resolve)(rootDir, adapter.outputDir, outputPath);
|
|
5409
|
+
writeOutputFile(fullPath, transformed, dryRun);
|
|
5410
|
+
result.files.push(fullPath);
|
|
5411
|
+
result.counts[adapter.name]++;
|
|
5412
|
+
}
|
|
5413
|
+
} catch (error) {
|
|
5414
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5415
|
+
result.errors = result.errors || [];
|
|
5416
|
+
result.errors.push(`Error processing ${rule.id}: ${message}`);
|
|
5417
|
+
}
|
|
5418
|
+
}
|
|
5419
|
+
const cursorAdapter2 = adapters.find((a) => a.name === "cursor");
|
|
5420
|
+
if (cursorAdapter2 && config.cursorRules) {
|
|
5421
|
+
for (const rule of config.cursorRules) {
|
|
5422
|
+
try {
|
|
5423
|
+
const content = loadKnowledgeFile(rule.source);
|
|
5424
|
+
const transformed = replacePlaceholders4(content, placeholders);
|
|
5425
|
+
const filename = (0, import_node_path2.basename)(rule.source);
|
|
5426
|
+
const fullPath = (0, import_node_path2.resolve)(rootDir, cursorAdapter2.outputDir, filename);
|
|
5427
|
+
writeOutputFile(fullPath, transformed, dryRun);
|
|
5428
|
+
result.files.push(fullPath);
|
|
5429
|
+
result.counts[cursorAdapter2.name]++;
|
|
5430
|
+
} catch (error) {
|
|
5431
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5432
|
+
result.errors = result.errors || [];
|
|
5433
|
+
result.errors.push(`Error processing cursor rule ${rule.source}: ${message}`);
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
}
|
|
5437
|
+
const claudeAdapter2 = adapters.find((a) => a.name === "claude");
|
|
5438
|
+
if (claudeAdapter2 && config.claudeRules) {
|
|
5439
|
+
for (const rule of config.claudeRules) {
|
|
5440
|
+
try {
|
|
5441
|
+
const content = loadKnowledgeFile(rule.source);
|
|
5442
|
+
const strippedContent = stripFrontmatter(content);
|
|
5443
|
+
const transformed = replacePlaceholders4(strippedContent, placeholders);
|
|
5444
|
+
const filename = (0, import_node_path2.basename)(rule.source).replace(".mdc", ".md");
|
|
5445
|
+
const fullPath = (0, import_node_path2.resolve)(rootDir, ".claude/rules/omnify", filename);
|
|
5446
|
+
writeOutputFile(fullPath, transformed, dryRun);
|
|
5447
|
+
result.files.push(fullPath);
|
|
5448
|
+
result.counts[claudeAdapter2.name]++;
|
|
5449
|
+
} catch (error) {
|
|
5450
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5451
|
+
result.errors = result.errors || [];
|
|
5452
|
+
result.errors.push(`Error processing claude rule ${rule.source}: ${message}`);
|
|
5453
|
+
}
|
|
5454
|
+
}
|
|
5455
|
+
}
|
|
5456
|
+
const antigravityAdapterInstance = adapters.find((a) => a.name === "antigravity");
|
|
5457
|
+
if (antigravityAdapterInstance && config.antigravityRules) {
|
|
5458
|
+
for (const rule of config.antigravityRules) {
|
|
5459
|
+
try {
|
|
5460
|
+
const content = loadKnowledgeFile(rule.source);
|
|
5461
|
+
const transformed = transformForAntigravity(content, rule, placeholders);
|
|
5462
|
+
const filename = (0, import_node_path2.basename)(rule.source).replace(".mdc", ".md");
|
|
5463
|
+
const fullPath = (0, import_node_path2.resolve)(rootDir, antigravityAdapterInstance.outputDir, filename);
|
|
5464
|
+
writeOutputFile(fullPath, transformed, dryRun);
|
|
5465
|
+
result.files.push(fullPath);
|
|
5466
|
+
result.counts[antigravityAdapterInstance.name]++;
|
|
5467
|
+
} catch (error) {
|
|
5468
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5469
|
+
result.errors = result.errors || [];
|
|
5470
|
+
result.errors.push(`Error processing antigravity rule ${rule.source}: ${message}`);
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
return result;
|
|
5475
|
+
}
|
|
5476
|
+
function transformForAntigravity(content, rule, placeholders) {
|
|
5477
|
+
let transformed = replacePlaceholders4(content, placeholders);
|
|
5478
|
+
if (transformed.startsWith("---")) {
|
|
5479
|
+
const endIndex = transformed.indexOf("---", 3);
|
|
5480
|
+
if (endIndex !== -1) {
|
|
5481
|
+
const existingFrontmatter = transformed.substring(3, endIndex).trim();
|
|
5482
|
+
const bodyContent = transformed.substring(endIndex + 3).trim();
|
|
5483
|
+
const id = (0, import_node_path2.basename)(rule.source, ".mdc");
|
|
5484
|
+
const description = extractYamlValue(existingFrontmatter, "description") || id;
|
|
5485
|
+
const globs = extractYamlArray(existingFrontmatter, "globs");
|
|
5486
|
+
const priority = rule.priority || "medium";
|
|
5487
|
+
const tags = rule.tags || [];
|
|
5488
|
+
const lines = [
|
|
5489
|
+
`id: ${id}`,
|
|
5490
|
+
`description: "${description}"`,
|
|
5491
|
+
`priority: ${priority}`
|
|
5492
|
+
];
|
|
5493
|
+
if (globs.length > 0) {
|
|
5494
|
+
lines.push("globs:");
|
|
5495
|
+
for (const glob of globs) {
|
|
5496
|
+
lines.push(` - "${glob}"`);
|
|
5497
|
+
}
|
|
5498
|
+
}
|
|
5499
|
+
if (tags.length > 0) {
|
|
5500
|
+
lines.push("tags:");
|
|
5501
|
+
for (const tag of tags) {
|
|
5502
|
+
lines.push(` - ${tag}`);
|
|
5503
|
+
}
|
|
5504
|
+
}
|
|
5505
|
+
return `---
|
|
5506
|
+
${lines.join("\n")}
|
|
5507
|
+
---
|
|
5508
|
+
|
|
5509
|
+
${bodyContent}`;
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
return transformed;
|
|
5513
|
+
}
|
|
5514
|
+
function extractYamlValue(yaml3, key) {
|
|
5515
|
+
const match = yaml3.match(new RegExp(`${key}:\\s*["']?([^"'\\n]+)["']?`));
|
|
5516
|
+
return match?.[1]?.trim();
|
|
5517
|
+
}
|
|
5518
|
+
function extractYamlArray(yaml3, key) {
|
|
5519
|
+
const match = yaml3.match(new RegExp(`${key}:\\s*\\[([^\\]]+)\\]`));
|
|
5520
|
+
if (match) {
|
|
5521
|
+
return match[1].split(",").map((g) => g.trim().replace(/["']/g, ""));
|
|
5522
|
+
}
|
|
5523
|
+
return [];
|
|
5524
|
+
}
|
|
5525
|
+
function stripFrontmatter(content) {
|
|
5526
|
+
if (!content.startsWith("---")) {
|
|
5527
|
+
return content;
|
|
5528
|
+
}
|
|
5529
|
+
const endIndex = content.indexOf("---", 3);
|
|
5530
|
+
if (endIndex === -1) {
|
|
5531
|
+
return content;
|
|
5532
|
+
}
|
|
5533
|
+
return content.substring(endIndex + 3).trim();
|
|
5534
|
+
}
|
|
5535
|
+
function shouldGenerateAIGuides(rootDir) {
|
|
5536
|
+
const claudeDir = (0, import_node_path2.resolve)(rootDir, ".claude/omnify/guides");
|
|
5537
|
+
const cursorDir = (0, import_node_path2.resolve)(rootDir, ".cursor/rules/omnify");
|
|
5538
|
+
if (!(0, import_node_fs.existsSync)(claudeDir) || !(0, import_node_fs.existsSync)(cursorDir)) {
|
|
5539
|
+
return true;
|
|
5540
|
+
}
|
|
5541
|
+
try {
|
|
5542
|
+
const claudeFiles = (0, import_node_fs.readdirSync)(claudeDir, { recursive: true });
|
|
5543
|
+
const cursorFiles = (0, import_node_fs.readdirSync)(cursorDir);
|
|
5544
|
+
return claudeFiles.length === 0 || cursorFiles.length === 0;
|
|
5545
|
+
} catch {
|
|
5546
|
+
return true;
|
|
5547
|
+
}
|
|
5548
|
+
}
|
|
5549
|
+
function getAvailableAdapters() {
|
|
5550
|
+
return getAdapters().map((a) => a.name);
|
|
5551
|
+
}
|
|
5102
5552
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5103
5553
|
0 && (module.exports = {
|
|
5104
5554
|
FILE_SCHEMA_NAME,
|
|
@@ -5106,9 +5556,12 @@ function createVersionStore(config) {
|
|
|
5106
5556
|
OmnifyError,
|
|
5107
5557
|
PluginManager,
|
|
5108
5558
|
VersionStore,
|
|
5559
|
+
allAdapters,
|
|
5560
|
+
antigravityAdapter,
|
|
5109
5561
|
atlasError,
|
|
5110
5562
|
atlasNotFoundError,
|
|
5111
5563
|
circularReferenceError,
|
|
5564
|
+
claudeAdapter,
|
|
5112
5565
|
configError,
|
|
5113
5566
|
configNotFoundError,
|
|
5114
5567
|
createFileLoadedSchema,
|
|
@@ -5116,6 +5569,7 @@ function createVersionStore(config) {
|
|
|
5116
5569
|
createOmnify,
|
|
5117
5570
|
createPluginManager,
|
|
5118
5571
|
createVersionStore,
|
|
5572
|
+
cursorAdapter,
|
|
5119
5573
|
duplicateSchemaError,
|
|
5120
5574
|
ensureFileSchema,
|
|
5121
5575
|
err,
|
|
@@ -5129,9 +5583,13 @@ function createVersionStore(config) {
|
|
|
5129
5583
|
formatError,
|
|
5130
5584
|
formatErrorPlain,
|
|
5131
5585
|
formatErrorSummary,
|
|
5586
|
+
generateAIGuides,
|
|
5132
5587
|
generateFileSchemaYaml,
|
|
5133
5588
|
generationError,
|
|
5589
|
+
getAdapter,
|
|
5590
|
+
getAdapters,
|
|
5134
5591
|
getAssociationMetadata,
|
|
5592
|
+
getAvailableAdapters,
|
|
5135
5593
|
getCustomTypeNames,
|
|
5136
5594
|
getEntitySchemas,
|
|
5137
5595
|
getEnumSchemas,
|
|
@@ -5170,6 +5628,7 @@ function createVersionStore(config) {
|
|
|
5170
5628
|
schemaNotFoundError,
|
|
5171
5629
|
schemaParseError,
|
|
5172
5630
|
schemasHaveFileProperties,
|
|
5631
|
+
shouldGenerateAIGuides,
|
|
5173
5632
|
validateAssociations,
|
|
5174
5633
|
validateDefaultValue,
|
|
5175
5634
|
validateEnumSchema,
|