@famgia/omnify-laravel 0.0.87 → 0.0.89

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.
Files changed (46) hide show
  1. package/dist/{chunk-YVVAJA3T.js → chunk-V7LWJ6OM.js} +178 -12
  2. package/dist/chunk-V7LWJ6OM.js.map +1 -0
  3. package/dist/index.cjs +180 -11
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +48 -1
  6. package/dist/index.d.ts +48 -1
  7. package/dist/index.js +5 -1
  8. package/dist/plugin.cjs +176 -11
  9. package/dist/plugin.cjs.map +1 -1
  10. package/dist/plugin.js +1 -1
  11. package/package.json +5 -5
  12. package/scripts/postinstall.js +29 -36
  13. package/stubs/ai-guides/claude-agents/architect.md.stub +150 -0
  14. package/stubs/ai-guides/claude-agents/developer.md.stub +190 -0
  15. package/stubs/ai-guides/claude-agents/reviewer.md.stub +134 -0
  16. package/stubs/ai-guides/claude-agents/tester.md.stub +196 -0
  17. package/stubs/ai-guides/claude-checklists/backend.md.stub +112 -0
  18. package/stubs/ai-guides/claude-omnify/antdesign-guide.md.stub +401 -0
  19. package/stubs/ai-guides/claude-omnify/config-guide.md.stub +253 -0
  20. package/stubs/ai-guides/claude-omnify/japan-guide.md.stub +186 -0
  21. package/stubs/ai-guides/claude-omnify/laravel-guide.md.stub +61 -0
  22. package/stubs/ai-guides/claude-omnify/schema-guide.md.stub +115 -0
  23. package/stubs/ai-guides/claude-omnify/typescript-guide.md.stub +310 -0
  24. package/stubs/ai-guides/claude-rules/naming.md.stub +364 -0
  25. package/stubs/ai-guides/claude-rules/performance.md.stub +251 -0
  26. package/stubs/ai-guides/claude-rules/security.md.stub +159 -0
  27. package/stubs/ai-guides/claude-workflows/bug-fix.md.stub +201 -0
  28. package/stubs/ai-guides/claude-workflows/code-review.md.stub +164 -0
  29. package/stubs/ai-guides/claude-workflows/new-feature.md.stub +327 -0
  30. package/stubs/ai-guides/cursor/laravel-controller.mdc.stub +391 -0
  31. package/stubs/ai-guides/cursor/laravel-request.mdc.stub +112 -0
  32. package/stubs/ai-guides/cursor/laravel-resource.mdc.stub +73 -0
  33. package/stubs/ai-guides/cursor/laravel-review.mdc.stub +69 -0
  34. package/stubs/ai-guides/cursor/laravel-testing.mdc.stub +138 -0
  35. package/stubs/ai-guides/cursor/laravel.mdc.stub +82 -0
  36. package/stubs/ai-guides/laravel/README.md.stub +59 -0
  37. package/stubs/ai-guides/laravel/architecture.md.stub +424 -0
  38. package/stubs/ai-guides/laravel/controller.md.stub +484 -0
  39. package/stubs/ai-guides/laravel/datetime.md.stub +334 -0
  40. package/stubs/ai-guides/laravel/openapi.md.stub +369 -0
  41. package/stubs/ai-guides/laravel/request.md.stub +450 -0
  42. package/stubs/ai-guides/laravel/resource.md.stub +516 -0
  43. package/stubs/ai-guides/laravel/service.md.stub +503 -0
  44. package/stubs/ai-guides/laravel/testing.md.stub +1504 -0
  45. package/ai-guides/laravel-guide.md +0 -461
  46. package/dist/chunk-YVVAJA3T.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -24,6 +24,7 @@ __export(index_exports, {
24
24
  formatForeignKey: () => formatForeignKey,
25
25
  formatIndex: () => formatIndex,
26
26
  formatMigrationFile: () => formatMigrationFile,
27
+ generateAIGuides: () => generateAIGuides,
27
28
  generateAlterMigration: () => generateAlterMigration,
28
29
  generateDropMigrationForTable: () => generateDropMigrationForTable,
29
30
  generateDropTableMigration: () => generateDropTableMigration,
@@ -43,6 +44,7 @@ __export(index_exports, {
43
44
  laravelPlugin: () => laravelPlugin,
44
45
  propertyToColumnMethod: () => propertyToColumnMethod,
45
46
  schemaToBlueprint: () => schemaToBlueprint,
47
+ shouldGenerateAIGuides: () => shouldGenerateAIGuides,
46
48
  toColumnName: () => toColumnName,
47
49
  toTableName: () => toTableName
48
50
  });
@@ -2637,8 +2639,8 @@ function getFactoryPath(factory) {
2637
2639
  }
2638
2640
 
2639
2641
  // src/plugin.ts
2640
- var import_node_fs = require("fs");
2641
- var import_node_path = require("path");
2642
+ var import_node_fs2 = require("fs");
2643
+ var import_node_path2 = require("path");
2642
2644
 
2643
2645
  // src/request/generator.ts
2644
2646
  var import_omnify_types3 = require("@famgia/omnify-types");
@@ -3971,6 +3973,152 @@ function getResourcePath(resource) {
3971
3973
  return resource.path;
3972
3974
  }
3973
3975
 
3976
+ // src/ai-guides/generator.ts
3977
+ var import_node_fs = require("fs");
3978
+ var import_node_path = require("path");
3979
+ var import_node_url = require("url");
3980
+ var import_meta = {};
3981
+ var __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
3982
+ var __dirname = (0, import_node_path.dirname)(__filename);
3983
+ function getStubsDir() {
3984
+ const devPath = (0, import_node_path.resolve)(__dirname, "../../stubs/ai-guides");
3985
+ if ((0, import_node_fs.existsSync)(devPath)) {
3986
+ return devPath;
3987
+ }
3988
+ const distPath = (0, import_node_path.resolve)(__dirname, "../stubs/ai-guides");
3989
+ if ((0, import_node_fs.existsSync)(distPath)) {
3990
+ return distPath;
3991
+ }
3992
+ throw new Error("AI guides stubs not found");
3993
+ }
3994
+ function extractLaravelBasePath(modelsPath) {
3995
+ if (!modelsPath) return "app";
3996
+ const normalized = modelsPath.replace(/\\/g, "/");
3997
+ const match = normalized.match(/^(.+?)\/Models(?:\/.*)?$/);
3998
+ if (match && match[1]) {
3999
+ return match[1];
4000
+ }
4001
+ const parts = normalized.split("/").filter(Boolean);
4002
+ if (parts.length > 1) {
4003
+ return parts.slice(0, -1).join("/");
4004
+ }
4005
+ return "app";
4006
+ }
4007
+ function replacePlaceholders(content, basePath) {
4008
+ return content.replace(/\{\{LARAVEL_BASE\}\}/g, basePath);
4009
+ }
4010
+ function copyStubs(srcDir, destDir, transform) {
4011
+ const writtenFiles = [];
4012
+ if (!(0, import_node_fs.existsSync)(srcDir)) {
4013
+ return writtenFiles;
4014
+ }
4015
+ if (!(0, import_node_fs.existsSync)(destDir)) {
4016
+ (0, import_node_fs.mkdirSync)(destDir, { recursive: true });
4017
+ }
4018
+ const entries = (0, import_node_fs.readdirSync)(srcDir, { withFileTypes: true });
4019
+ for (const entry of entries) {
4020
+ const srcPath = (0, import_node_path.join)(srcDir, entry.name);
4021
+ if (entry.isDirectory()) {
4022
+ const subDestDir = (0, import_node_path.join)(destDir, entry.name);
4023
+ const subFiles = copyStubs(srcPath, subDestDir, transform);
4024
+ writtenFiles.push(...subFiles);
4025
+ } else if (entry.isFile() && entry.name.endsWith(".stub")) {
4026
+ const destName = entry.name.slice(0, -5);
4027
+ const destPath = (0, import_node_path.join)(destDir, destName);
4028
+ let content = (0, import_node_fs.readFileSync)(srcPath, "utf-8");
4029
+ if (transform) {
4030
+ content = transform(content);
4031
+ }
4032
+ (0, import_node_fs.writeFileSync)(destPath, content);
4033
+ writtenFiles.push(destPath);
4034
+ }
4035
+ }
4036
+ return writtenFiles;
4037
+ }
4038
+ function generateAIGuides(rootDir, options = {}) {
4039
+ const stubsDir = getStubsDir();
4040
+ const basePath = options.laravelBasePath || extractLaravelBasePath(options.modelsPath);
4041
+ const result = {
4042
+ claudeGuides: 0,
4043
+ claudeRules: 0,
4044
+ claudeChecklists: 0,
4045
+ claudeWorkflows: 0,
4046
+ claudeAgents: 0,
4047
+ claudeOmnify: 0,
4048
+ cursorRules: 0,
4049
+ files: []
4050
+ };
4051
+ const claudeSrcDir = (0, import_node_path.join)(stubsDir, "laravel");
4052
+ const claudeDestDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/guides/laravel");
4053
+ if ((0, import_node_fs.existsSync)(claudeSrcDir)) {
4054
+ const files = copyStubs(claudeSrcDir, claudeDestDir);
4055
+ result.claudeGuides = files.length;
4056
+ result.files.push(...files);
4057
+ }
4058
+ const claudeRulesSrcDir = (0, import_node_path.join)(stubsDir, "claude-rules");
4059
+ const claudeRulesDestDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/rules");
4060
+ if ((0, import_node_fs.existsSync)(claudeRulesSrcDir)) {
4061
+ const files = copyStubs(claudeRulesSrcDir, claudeRulesDestDir);
4062
+ result.claudeRules = files.length;
4063
+ result.files.push(...files);
4064
+ }
4065
+ const claudeChecklistsSrcDir = (0, import_node_path.join)(stubsDir, "claude-checklists");
4066
+ const claudeChecklistsDestDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/checklists");
4067
+ if ((0, import_node_fs.existsSync)(claudeChecklistsSrcDir)) {
4068
+ const files = copyStubs(claudeChecklistsSrcDir, claudeChecklistsDestDir);
4069
+ result.claudeChecklists = files.length;
4070
+ result.files.push(...files);
4071
+ }
4072
+ const claudeWorkflowsSrcDir = (0, import_node_path.join)(stubsDir, "claude-workflows");
4073
+ const claudeWorkflowsDestDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/workflows");
4074
+ if ((0, import_node_fs.existsSync)(claudeWorkflowsSrcDir)) {
4075
+ const files = copyStubs(claudeWorkflowsSrcDir, claudeWorkflowsDestDir);
4076
+ result.claudeWorkflows = files.length;
4077
+ result.files.push(...files);
4078
+ }
4079
+ const claudeAgentsSrcDir = (0, import_node_path.join)(stubsDir, "claude-agents");
4080
+ const claudeAgentsDestDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/agents");
4081
+ if ((0, import_node_fs.existsSync)(claudeAgentsSrcDir)) {
4082
+ const files = copyStubs(claudeAgentsSrcDir, claudeAgentsDestDir);
4083
+ result.claudeAgents = files.length;
4084
+ result.files.push(...files);
4085
+ }
4086
+ const claudeOmnifySrcDir = (0, import_node_path.join)(stubsDir, "claude-omnify");
4087
+ const claudeOmnifyDestDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/guides/omnify");
4088
+ if ((0, import_node_fs.existsSync)(claudeOmnifySrcDir)) {
4089
+ const files = copyStubs(claudeOmnifySrcDir, claudeOmnifyDestDir);
4090
+ result.claudeOmnify = files.length;
4091
+ result.files.push(...files);
4092
+ }
4093
+ const cursorSrcDir = (0, import_node_path.join)(stubsDir, "cursor");
4094
+ const cursorDestDir = (0, import_node_path.resolve)(rootDir, ".cursor/rules/omnify");
4095
+ if ((0, import_node_fs.existsSync)(cursorSrcDir)) {
4096
+ const files = copyStubs(
4097
+ cursorSrcDir,
4098
+ cursorDestDir,
4099
+ (content) => replacePlaceholders(content, basePath)
4100
+ );
4101
+ result.cursorRules = files.length;
4102
+ result.files.push(...files);
4103
+ }
4104
+ return result;
4105
+ }
4106
+ function shouldGenerateAIGuides(rootDir) {
4107
+ const claudeDir = (0, import_node_path.resolve)(rootDir, ".claude/omnify/guides/laravel");
4108
+ const cursorDir = (0, import_node_path.resolve)(rootDir, ".cursor/rules/omnify");
4109
+ if (!(0, import_node_fs.existsSync)(claudeDir) || !(0, import_node_fs.existsSync)(cursorDir)) {
4110
+ return true;
4111
+ }
4112
+ try {
4113
+ const claudeFiles = (0, import_node_fs.readdirSync)(claudeDir);
4114
+ const cursorFiles = (0, import_node_fs.readdirSync)(cursorDir);
4115
+ const hasLaravelRules = cursorFiles.some((f) => f.startsWith("laravel"));
4116
+ return claudeFiles.length === 0 || !hasLaravelRules;
4117
+ } catch {
4118
+ return true;
4119
+ }
4120
+ }
4121
+
3974
4122
  // src/plugin.ts
3975
4123
  function inferLaravelRoot(providersPath) {
3976
4124
  const normalized = providersPath.replace(/\\/g, "/");
@@ -3986,11 +4134,11 @@ function inferLaravelRoot(providersPath) {
3986
4134
  }
3987
4135
  function getExistingMigrationTables(migrationsDir) {
3988
4136
  const existingTables = /* @__PURE__ */ new Set();
3989
- if (!(0, import_node_fs.existsSync)(migrationsDir)) {
4137
+ if (!(0, import_node_fs2.existsSync)(migrationsDir)) {
3990
4138
  return existingTables;
3991
4139
  }
3992
4140
  try {
3993
- const files = (0, import_node_fs.readdirSync)(migrationsDir);
4141
+ const files = (0, import_node_fs2.readdirSync)(migrationsDir);
3994
4142
  const createMigrationPattern = /^\d{4}_\d{2}_\d{2}_\d{6}_create_(.+)_table\.php$/;
3995
4143
  for (const file of files) {
3996
4144
  const match = file.match(createMigrationPattern);
@@ -4156,7 +4304,7 @@ function laravelPlugin(options) {
4156
4304
  customTypes: ctx.customTypes
4157
4305
  };
4158
4306
  const outputs = [];
4159
- const migrationsDir = (0, import_node_path.join)(ctx.cwd, resolved.migrationsPath);
4307
+ const migrationsDir = (0, import_node_path2.join)(ctx.cwd, resolved.migrationsPath);
4160
4308
  const existingTables = getExistingMigrationTables(migrationsDir);
4161
4309
  if (ctx.changes !== void 0) {
4162
4310
  if (ctx.changes.length === 0) {
@@ -4256,20 +4404,20 @@ function laravelPlugin(options) {
4256
4404
  const laravelRoot = inferLaravelRoot(resolved.providersPath);
4257
4405
  const bootstrapProvidersRelPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
4258
4406
  const configAppRelPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
4259
- const bootstrapProvidersPath = (0, import_node_path.join)(ctx.cwd, bootstrapProvidersRelPath);
4260
- const configAppPath = (0, import_node_path.join)(ctx.cwd, configAppRelPath);
4407
+ const bootstrapProvidersPath = (0, import_node_path2.join)(ctx.cwd, bootstrapProvidersRelPath);
4408
+ const configAppPath = (0, import_node_path2.join)(ctx.cwd, configAppRelPath);
4261
4409
  let existingContent = null;
4262
4410
  let laravelVersion;
4263
- if ((0, import_node_fs.existsSync)(bootstrapProvidersPath)) {
4411
+ if ((0, import_node_fs2.existsSync)(bootstrapProvidersPath)) {
4264
4412
  laravelVersion = "laravel11+";
4265
4413
  try {
4266
- existingContent = (0, import_node_fs.readFileSync)(bootstrapProvidersPath, "utf-8");
4414
+ existingContent = (0, import_node_fs2.readFileSync)(bootstrapProvidersPath, "utf-8");
4267
4415
  } catch {
4268
4416
  existingContent = null;
4269
4417
  }
4270
- } else if ((0, import_node_fs.existsSync)(configAppPath)) {
4418
+ } else if ((0, import_node_fs2.existsSync)(configAppPath)) {
4271
4419
  try {
4272
- const configContent = (0, import_node_fs.readFileSync)(configAppPath, "utf-8");
4420
+ const configContent = (0, import_node_fs2.readFileSync)(configAppPath, "utf-8");
4273
4421
  if (/'providers'\s*=>\s*\[/.test(configContent)) {
4274
4422
  laravelVersion = "laravel10-";
4275
4423
  existingContent = configContent;
@@ -4382,6 +4530,24 @@ function laravelPlugin(options) {
4382
4530
  }));
4383
4531
  }
4384
4532
  };
4533
+ const aiGuidesGenerator = {
4534
+ name: "laravel-ai-guides",
4535
+ description: "Generate AI assistant guides (Claude, Cursor) for Laravel development",
4536
+ generate: async (ctx) => {
4537
+ if (!shouldGenerateAIGuides(ctx.cwd)) {
4538
+ ctx.logger.debug("AI guides already exist, skipping");
4539
+ return [];
4540
+ }
4541
+ const result = generateAIGuides(ctx.cwd, {
4542
+ modelsPath: resolved.modelsPath,
4543
+ migrationsPath: resolved.migrationsPath,
4544
+ laravelBasePath: "app"
4545
+ });
4546
+ const claudeTotal = result.claudeGuides + result.claudeRules + result.claudeChecklists + result.claudeWorkflows + result.claudeAgents + result.claudeOmnify;
4547
+ ctx.logger.info(`Generated ${claudeTotal} Claude files, ${result.cursorRules} Cursor rules`);
4548
+ return [];
4549
+ }
4550
+ };
4385
4551
  const generators = [migrationGenerator];
4386
4552
  if (resolved.generateModels) {
4387
4553
  generators.push(modelGenerator);
@@ -4395,6 +4561,7 @@ function laravelPlugin(options) {
4395
4561
  if (resolved.generateResources) {
4396
4562
  generators.push(resourceGenerator);
4397
4563
  }
4564
+ generators.push(aiGuidesGenerator);
4398
4565
  return {
4399
4566
  name: "@famgia/omnify-laravel",
4400
4567
  version: "0.0.14",
@@ -4408,6 +4575,7 @@ function laravelPlugin(options) {
4408
4575
  formatForeignKey,
4409
4576
  formatIndex,
4410
4577
  formatMigrationFile,
4578
+ generateAIGuides,
4411
4579
  generateAlterMigration,
4412
4580
  generateDropMigrationForTable,
4413
4581
  generateDropTableMigration,
@@ -4427,6 +4595,7 @@ function laravelPlugin(options) {
4427
4595
  laravelPlugin,
4428
4596
  propertyToColumnMethod,
4429
4597
  schemaToBlueprint,
4598
+ shouldGenerateAIGuides,
4430
4599
  toColumnName,
4431
4600
  toTableName
4432
4601
  });