@famgia/omnify-laravel 0.0.88 → 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
@@ -1,6 +1,6 @@
1
1
  // src/plugin.ts
2
- import { readFileSync, existsSync, readdirSync } from "fs";
3
- import { join } from "path";
2
+ import { readFileSync as readFileSync2, existsSync as existsSync2, readdirSync as readdirSync2 } from "fs";
3
+ import { join as join2 } from "path";
4
4
 
5
5
  // src/migration/schema-builder.ts
6
6
  import { resolveLocalizedString } from "@famgia/omnify-types";
@@ -3921,6 +3921,151 @@ function getResourcePath(resource) {
3921
3921
  return resource.path;
3922
3922
  }
3923
3923
 
3924
+ // src/ai-guides/generator.ts
3925
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
3926
+ import { resolve, dirname, join } from "path";
3927
+ import { fileURLToPath } from "url";
3928
+ var __filename = fileURLToPath(import.meta.url);
3929
+ var __dirname = dirname(__filename);
3930
+ function getStubsDir() {
3931
+ const devPath = resolve(__dirname, "../../stubs/ai-guides");
3932
+ if (existsSync(devPath)) {
3933
+ return devPath;
3934
+ }
3935
+ const distPath = resolve(__dirname, "../stubs/ai-guides");
3936
+ if (existsSync(distPath)) {
3937
+ return distPath;
3938
+ }
3939
+ throw new Error("AI guides stubs not found");
3940
+ }
3941
+ function extractLaravelBasePath(modelsPath) {
3942
+ if (!modelsPath) return "app";
3943
+ const normalized = modelsPath.replace(/\\/g, "/");
3944
+ const match = normalized.match(/^(.+?)\/Models(?:\/.*)?$/);
3945
+ if (match && match[1]) {
3946
+ return match[1];
3947
+ }
3948
+ const parts = normalized.split("/").filter(Boolean);
3949
+ if (parts.length > 1) {
3950
+ return parts.slice(0, -1).join("/");
3951
+ }
3952
+ return "app";
3953
+ }
3954
+ function replacePlaceholders(content, basePath) {
3955
+ return content.replace(/\{\{LARAVEL_BASE\}\}/g, basePath);
3956
+ }
3957
+ function copyStubs(srcDir, destDir, transform) {
3958
+ const writtenFiles = [];
3959
+ if (!existsSync(srcDir)) {
3960
+ return writtenFiles;
3961
+ }
3962
+ if (!existsSync(destDir)) {
3963
+ mkdirSync(destDir, { recursive: true });
3964
+ }
3965
+ const entries = readdirSync(srcDir, { withFileTypes: true });
3966
+ for (const entry of entries) {
3967
+ const srcPath = join(srcDir, entry.name);
3968
+ if (entry.isDirectory()) {
3969
+ const subDestDir = join(destDir, entry.name);
3970
+ const subFiles = copyStubs(srcPath, subDestDir, transform);
3971
+ writtenFiles.push(...subFiles);
3972
+ } else if (entry.isFile() && entry.name.endsWith(".stub")) {
3973
+ const destName = entry.name.slice(0, -5);
3974
+ const destPath = join(destDir, destName);
3975
+ let content = readFileSync(srcPath, "utf-8");
3976
+ if (transform) {
3977
+ content = transform(content);
3978
+ }
3979
+ writeFileSync(destPath, content);
3980
+ writtenFiles.push(destPath);
3981
+ }
3982
+ }
3983
+ return writtenFiles;
3984
+ }
3985
+ function generateAIGuides(rootDir, options = {}) {
3986
+ const stubsDir = getStubsDir();
3987
+ const basePath = options.laravelBasePath || extractLaravelBasePath(options.modelsPath);
3988
+ const result = {
3989
+ claudeGuides: 0,
3990
+ claudeRules: 0,
3991
+ claudeChecklists: 0,
3992
+ claudeWorkflows: 0,
3993
+ claudeAgents: 0,
3994
+ claudeOmnify: 0,
3995
+ cursorRules: 0,
3996
+ files: []
3997
+ };
3998
+ const claudeSrcDir = join(stubsDir, "laravel");
3999
+ const claudeDestDir = resolve(rootDir, ".claude/omnify/guides/laravel");
4000
+ if (existsSync(claudeSrcDir)) {
4001
+ const files = copyStubs(claudeSrcDir, claudeDestDir);
4002
+ result.claudeGuides = files.length;
4003
+ result.files.push(...files);
4004
+ }
4005
+ const claudeRulesSrcDir = join(stubsDir, "claude-rules");
4006
+ const claudeRulesDestDir = resolve(rootDir, ".claude/omnify/rules");
4007
+ if (existsSync(claudeRulesSrcDir)) {
4008
+ const files = copyStubs(claudeRulesSrcDir, claudeRulesDestDir);
4009
+ result.claudeRules = files.length;
4010
+ result.files.push(...files);
4011
+ }
4012
+ const claudeChecklistsSrcDir = join(stubsDir, "claude-checklists");
4013
+ const claudeChecklistsDestDir = resolve(rootDir, ".claude/omnify/checklists");
4014
+ if (existsSync(claudeChecklistsSrcDir)) {
4015
+ const files = copyStubs(claudeChecklistsSrcDir, claudeChecklistsDestDir);
4016
+ result.claudeChecklists = files.length;
4017
+ result.files.push(...files);
4018
+ }
4019
+ const claudeWorkflowsSrcDir = join(stubsDir, "claude-workflows");
4020
+ const claudeWorkflowsDestDir = resolve(rootDir, ".claude/omnify/workflows");
4021
+ if (existsSync(claudeWorkflowsSrcDir)) {
4022
+ const files = copyStubs(claudeWorkflowsSrcDir, claudeWorkflowsDestDir);
4023
+ result.claudeWorkflows = files.length;
4024
+ result.files.push(...files);
4025
+ }
4026
+ const claudeAgentsSrcDir = join(stubsDir, "claude-agents");
4027
+ const claudeAgentsDestDir = resolve(rootDir, ".claude/omnify/agents");
4028
+ if (existsSync(claudeAgentsSrcDir)) {
4029
+ const files = copyStubs(claudeAgentsSrcDir, claudeAgentsDestDir);
4030
+ result.claudeAgents = files.length;
4031
+ result.files.push(...files);
4032
+ }
4033
+ const claudeOmnifySrcDir = join(stubsDir, "claude-omnify");
4034
+ const claudeOmnifyDestDir = resolve(rootDir, ".claude/omnify/guides/omnify");
4035
+ if (existsSync(claudeOmnifySrcDir)) {
4036
+ const files = copyStubs(claudeOmnifySrcDir, claudeOmnifyDestDir);
4037
+ result.claudeOmnify = files.length;
4038
+ result.files.push(...files);
4039
+ }
4040
+ const cursorSrcDir = join(stubsDir, "cursor");
4041
+ const cursorDestDir = resolve(rootDir, ".cursor/rules/omnify");
4042
+ if (existsSync(cursorSrcDir)) {
4043
+ const files = copyStubs(
4044
+ cursorSrcDir,
4045
+ cursorDestDir,
4046
+ (content) => replacePlaceholders(content, basePath)
4047
+ );
4048
+ result.cursorRules = files.length;
4049
+ result.files.push(...files);
4050
+ }
4051
+ return result;
4052
+ }
4053
+ function shouldGenerateAIGuides(rootDir) {
4054
+ const claudeDir = resolve(rootDir, ".claude/omnify/guides/laravel");
4055
+ const cursorDir = resolve(rootDir, ".cursor/rules/omnify");
4056
+ if (!existsSync(claudeDir) || !existsSync(cursorDir)) {
4057
+ return true;
4058
+ }
4059
+ try {
4060
+ const claudeFiles = readdirSync(claudeDir);
4061
+ const cursorFiles = readdirSync(cursorDir);
4062
+ const hasLaravelRules = cursorFiles.some((f) => f.startsWith("laravel"));
4063
+ return claudeFiles.length === 0 || !hasLaravelRules;
4064
+ } catch {
4065
+ return true;
4066
+ }
4067
+ }
4068
+
3924
4069
  // src/plugin.ts
3925
4070
  function inferLaravelRoot(providersPath) {
3926
4071
  const normalized = providersPath.replace(/\\/g, "/");
@@ -3936,11 +4081,11 @@ function inferLaravelRoot(providersPath) {
3936
4081
  }
3937
4082
  function getExistingMigrationTables(migrationsDir) {
3938
4083
  const existingTables = /* @__PURE__ */ new Set();
3939
- if (!existsSync(migrationsDir)) {
4084
+ if (!existsSync2(migrationsDir)) {
3940
4085
  return existingTables;
3941
4086
  }
3942
4087
  try {
3943
- const files = readdirSync(migrationsDir);
4088
+ const files = readdirSync2(migrationsDir);
3944
4089
  const createMigrationPattern = /^\d{4}_\d{2}_\d{2}_\d{6}_create_(.+)_table\.php$/;
3945
4090
  for (const file of files) {
3946
4091
  const match = file.match(createMigrationPattern);
@@ -4106,7 +4251,7 @@ function laravelPlugin(options) {
4106
4251
  customTypes: ctx.customTypes
4107
4252
  };
4108
4253
  const outputs = [];
4109
- const migrationsDir = join(ctx.cwd, resolved.migrationsPath);
4254
+ const migrationsDir = join2(ctx.cwd, resolved.migrationsPath);
4110
4255
  const existingTables = getExistingMigrationTables(migrationsDir);
4111
4256
  if (ctx.changes !== void 0) {
4112
4257
  if (ctx.changes.length === 0) {
@@ -4206,20 +4351,20 @@ function laravelPlugin(options) {
4206
4351
  const laravelRoot = inferLaravelRoot(resolved.providersPath);
4207
4352
  const bootstrapProvidersRelPath = laravelRoot ? `${laravelRoot}/bootstrap/providers.php` : "bootstrap/providers.php";
4208
4353
  const configAppRelPath = laravelRoot ? `${laravelRoot}/config/app.php` : "config/app.php";
4209
- const bootstrapProvidersPath = join(ctx.cwd, bootstrapProvidersRelPath);
4210
- const configAppPath = join(ctx.cwd, configAppRelPath);
4354
+ const bootstrapProvidersPath = join2(ctx.cwd, bootstrapProvidersRelPath);
4355
+ const configAppPath = join2(ctx.cwd, configAppRelPath);
4211
4356
  let existingContent = null;
4212
4357
  let laravelVersion;
4213
- if (existsSync(bootstrapProvidersPath)) {
4358
+ if (existsSync2(bootstrapProvidersPath)) {
4214
4359
  laravelVersion = "laravel11+";
4215
4360
  try {
4216
- existingContent = readFileSync(bootstrapProvidersPath, "utf-8");
4361
+ existingContent = readFileSync2(bootstrapProvidersPath, "utf-8");
4217
4362
  } catch {
4218
4363
  existingContent = null;
4219
4364
  }
4220
- } else if (existsSync(configAppPath)) {
4365
+ } else if (existsSync2(configAppPath)) {
4221
4366
  try {
4222
- const configContent = readFileSync(configAppPath, "utf-8");
4367
+ const configContent = readFileSync2(configAppPath, "utf-8");
4223
4368
  if (/'providers'\s*=>\s*\[/.test(configContent)) {
4224
4369
  laravelVersion = "laravel10-";
4225
4370
  existingContent = configContent;
@@ -4332,6 +4477,24 @@ function laravelPlugin(options) {
4332
4477
  }));
4333
4478
  }
4334
4479
  };
4480
+ const aiGuidesGenerator = {
4481
+ name: "laravel-ai-guides",
4482
+ description: "Generate AI assistant guides (Claude, Cursor) for Laravel development",
4483
+ generate: async (ctx) => {
4484
+ if (!shouldGenerateAIGuides(ctx.cwd)) {
4485
+ ctx.logger.debug("AI guides already exist, skipping");
4486
+ return [];
4487
+ }
4488
+ const result = generateAIGuides(ctx.cwd, {
4489
+ modelsPath: resolved.modelsPath,
4490
+ migrationsPath: resolved.migrationsPath,
4491
+ laravelBasePath: "app"
4492
+ });
4493
+ const claudeTotal = result.claudeGuides + result.claudeRules + result.claudeChecklists + result.claudeWorkflows + result.claudeAgents + result.claudeOmnify;
4494
+ ctx.logger.info(`Generated ${claudeTotal} Claude files, ${result.cursorRules} Cursor rules`);
4495
+ return [];
4496
+ }
4497
+ };
4335
4498
  const generators = [migrationGenerator];
4336
4499
  if (resolved.generateModels) {
4337
4500
  generators.push(modelGenerator);
@@ -4345,6 +4508,7 @@ function laravelPlugin(options) {
4345
4508
  if (resolved.generateResources) {
4346
4509
  generators.push(resourceGenerator);
4347
4510
  }
4511
+ generators.push(aiGuidesGenerator);
4348
4512
  return {
4349
4513
  name: "@famgia/omnify-laravel",
4350
4514
  version: "0.0.14",
@@ -4378,6 +4542,8 @@ export {
4378
4542
  generateProviderRegistration,
4379
4543
  generateFactories,
4380
4544
  getFactoryPath,
4545
+ generateAIGuides,
4546
+ shouldGenerateAIGuides,
4381
4547
  laravelPlugin
4382
4548
  };
4383
- //# sourceMappingURL=chunk-YVVAJA3T.js.map
4549
+ //# sourceMappingURL=chunk-V7LWJ6OM.js.map