adula 0.0.0 → 2.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.
Files changed (210) hide show
  1. package/LICENSE.md +10 -0
  2. package/README.md +38 -2
  3. package/build/agent/AGENTS.template.md +28 -0
  4. package/build/agent/capabilities.md +60 -0
  5. package/build/agent/skills/adula-frontend-design/SKILL.md +59 -0
  6. package/build/agent/skills/idea-review/SKILL.md +31 -0
  7. package/build/agent/skills/module-review/SKILL.md +22 -0
  8. package/build/agent/skills/perf-review/SKILL.md +24 -0
  9. package/build/agent/skills/schema-review/SKILL.md +22 -0
  10. package/build/agent/skills/security-review/SKILL.md +24 -0
  11. package/build/agent/skills/ui-review/SKILL.md +22 -0
  12. package/build/commands/capabilities.d.ts +10 -0
  13. package/build/commands/capabilities.js +40 -0
  14. package/build/commands/doctor.d.ts +9 -0
  15. package/build/commands/doctor.js +72 -0
  16. package/build/commands/gaps.d.ts +12 -0
  17. package/build/commands/gaps.js +62 -0
  18. package/build/commands/install.d.ts +9 -0
  19. package/build/commands/install.js +105 -0
  20. package/build/commands/main.d.ts +8 -0
  21. package/build/commands/main.js +33 -0
  22. package/build/commands/module_add.d.ts +8 -0
  23. package/build/commands/module_add.js +57 -0
  24. package/build/commands/module_remove.d.ts +10 -0
  25. package/build/commands/module_remove.js +94 -0
  26. package/build/commands/resource.d.ts +8 -0
  27. package/build/commands/resource.js +29 -0
  28. package/build/commands/resource_snapshot.d.ts +15 -0
  29. package/build/commands/resource_snapshot.js +61 -0
  30. package/build/commands/storage_migrate.d.ts +12 -0
  31. package/build/commands/storage_migrate.js +39 -0
  32. package/build/commands/ui.d.ts +11 -0
  33. package/build/commands/ui.js +210 -0
  34. package/build/commands/upgrade.d.ts +15 -0
  35. package/build/commands/upgrade.js +34 -0
  36. package/build/configure.d.ts +2 -0
  37. package/build/configure.js +79 -0
  38. package/build/database/migrations/1770000000000_core.d.ts +5 -0
  39. package/build/database/migrations/1770000000000_core.js +10 -0
  40. package/build/database/migrations/1770000000001_attachments.d.ts +5 -0
  41. package/build/database/migrations/1770000000001_attachments.js +10 -0
  42. package/build/database/migrations/1770000000002_saved_views.d.ts +5 -0
  43. package/build/database/migrations/1770000000002_saved_views.js +10 -0
  44. package/build/database/migrations/1770000000003_user_invitations.d.ts +5 -0
  45. package/build/database/migrations/1770000000003_user_invitations.js +18 -0
  46. package/build/database/migrations/1770000000004_collaboration.d.ts +5 -0
  47. package/build/database/migrations/1770000000004_collaboration.js +10 -0
  48. package/build/database/migrations/1770000000005_assignments.d.ts +5 -0
  49. package/build/database/migrations/1770000000005_assignments.js +10 -0
  50. package/build/database/migrations/1770000000006_messaging.d.ts +5 -0
  51. package/build/database/migrations/1770000000006_messaging.js +10 -0
  52. package/build/database/migrations/1770000000007_webhooks.d.ts +5 -0
  53. package/build/database/migrations/1770000000007_webhooks.js +10 -0
  54. package/build/database/migrations/1770000000008_imports.d.ts +5 -0
  55. package/build/database/migrations/1770000000008_imports.js +10 -0
  56. package/build/database/migrations/1770000000010_workflows.d.ts +5 -0
  57. package/build/database/migrations/1770000000010_workflows.js +10 -0
  58. package/build/database/migrations/1770000000011_managed_assignments.d.ts +5 -0
  59. package/build/database/migrations/1770000000011_managed_assignments.js +10 -0
  60. package/build/database/migrations/1770000000012_role_keys.d.ts +5 -0
  61. package/build/database/migrations/1770000000012_role_keys.js +10 -0
  62. package/build/database/migrations/1770000000013_notification_targets.d.ts +5 -0
  63. package/build/database/migrations/1770000000013_notification_targets.js +10 -0
  64. package/build/database/migrations/1770000000014_upload_grants.d.ts +5 -0
  65. package/build/database/migrations/1770000000014_upload_grants.js +10 -0
  66. package/build/database/migrations/1770000000015_inbound_webhooks.d.ts +5 -0
  67. package/build/database/migrations/1770000000015_inbound_webhooks.js +10 -0
  68. package/build/database/migrations/1770000000016_adulajs_names.d.ts +6 -0
  69. package/build/database/migrations/1770000000016_adulajs_names.js +11 -0
  70. package/build/index.d.ts +80 -0
  71. package/build/index.js +49 -0
  72. package/build/providers/adula_provider.d.ts +6 -0
  73. package/build/providers/adula_provider.js +10 -0
  74. package/build/src/admin/contracts.d.ts +19 -0
  75. package/build/src/admin/contracts.js +115 -0
  76. package/build/src/admin/controller.d.ts +32 -0
  77. package/build/src/admin/controller.js +167 -0
  78. package/build/src/admin/errors.d.ts +5 -0
  79. package/build/src/admin/errors.js +9 -0
  80. package/build/src/admin/presentation.d.ts +28 -0
  81. package/build/src/admin/presentation.js +1 -0
  82. package/build/src/admin/record_title.d.ts +14 -0
  83. package/build/src/admin/record_title.js +50 -0
  84. package/build/src/admin/resource_service.d.ts +376 -0
  85. package/build/src/admin/resource_service.js +1448 -0
  86. package/build/src/attachments/attachment_service.d.ts +100 -0
  87. package/build/src/attachments/attachment_service.js +270 -0
  88. package/build/src/attachments/doctor.d.ts +4 -0
  89. package/build/src/attachments/doctor.js +28 -0
  90. package/build/src/attachments/storage_migrate.d.ts +39 -0
  91. package/build/src/attachments/storage_migrate.js +64 -0
  92. package/build/src/attachments/upload_grants.d.ts +44 -0
  93. package/build/src/attachments/upload_grants.js +105 -0
  94. package/build/src/auth/ability.d.ts +24 -0
  95. package/build/src/auth/ability.js +34 -0
  96. package/build/src/auth/actor_store.d.ts +14 -0
  97. package/build/src/auth/actor_store.js +70 -0
  98. package/build/src/auth/conditions.d.ts +26 -0
  99. package/build/src/auth/conditions.js +117 -0
  100. package/build/src/auth/packed_rules.d.ts +4 -0
  101. package/build/src/auth/packed_rules.js +13 -0
  102. package/build/src/auth/sql.d.ts +11 -0
  103. package/build/src/auth/sql.js +118 -0
  104. package/build/src/collaboration/assignments.d.ts +129 -0
  105. package/build/src/collaboration/assignments.js +333 -0
  106. package/build/src/collaboration/record_collaboration.d.ts +86 -0
  107. package/build/src/collaboration/record_collaboration.js +348 -0
  108. package/build/src/commands/agent_assets.d.ts +7 -0
  109. package/build/src/commands/agent_assets.js +66 -0
  110. package/build/src/commands/capabilities.d.ts +19 -0
  111. package/build/src/commands/capabilities.js +179 -0
  112. package/build/src/commands/doctor.d.ts +42 -0
  113. package/build/src/commands/doctor.js +375 -0
  114. package/build/src/commands/gap_report.d.ts +56 -0
  115. package/build/src/commands/gap_report.js +110 -0
  116. package/build/src/commands/generator.d.ts +1 -0
  117. package/build/src/commands/generator.js +70 -0
  118. package/build/src/commands/snapshot.d.ts +28 -0
  119. package/build/src/commands/snapshot.js +48 -0
  120. package/build/src/commands/source_markers.d.ts +11 -0
  121. package/build/src/commands/source_markers.js +41 -0
  122. package/build/src/core/activity.d.ts +43 -0
  123. package/build/src/core/activity.js +77 -0
  124. package/build/src/core/administration_guard.d.ts +3 -0
  125. package/build/src/core/administration_guard.js +39 -0
  126. package/build/src/core/health.d.ts +42 -0
  127. package/build/src/core/health.js +44 -0
  128. package/build/src/core/mail_test.d.ts +18 -0
  129. package/build/src/core/mail_test.js +88 -0
  130. package/build/src/core/message_templates.d.ts +83 -0
  131. package/build/src/core/message_templates.js +293 -0
  132. package/build/src/core/module_seed.d.ts +15 -0
  133. package/build/src/core/module_seed.js +31 -0
  134. package/build/src/core/notifications.d.ts +42 -0
  135. package/build/src/core/notifications.js +91 -0
  136. package/build/src/core/org_units.d.ts +30 -0
  137. package/build/src/core/org_units.js +123 -0
  138. package/build/src/core/roles.d.ts +98 -0
  139. package/build/src/core/roles.js +447 -0
  140. package/build/src/core/saved_views.d.ts +37 -0
  141. package/build/src/core/saved_views.js +164 -0
  142. package/build/src/core/settings.d.ts +29 -0
  143. package/build/src/core/settings.js +113 -0
  144. package/build/src/core/setup.d.ts +14 -0
  145. package/build/src/core/setup.js +89 -0
  146. package/build/src/core/ui_preferences.d.ts +12 -0
  147. package/build/src/core/ui_preferences.js +30 -0
  148. package/build/src/core/user_invitations.d.ts +23 -0
  149. package/build/src/core/user_invitations.js +144 -0
  150. package/build/src/core/users.d.ts +44 -0
  151. package/build/src/core/users.js +182 -0
  152. package/build/src/database/configure.d.ts +3 -0
  153. package/build/src/database/configure.js +41 -0
  154. package/build/src/database/schema.d.ts +52 -0
  155. package/build/src/database/schema.js +538 -0
  156. package/build/src/eslint/index.d.ts +3 -0
  157. package/build/src/eslint/index.js +90 -0
  158. package/build/src/events/adonis_jobs.d.ts +9 -0
  159. package/build/src/events/adonis_jobs.js +13 -0
  160. package/build/src/events/outbox.d.ts +19 -0
  161. package/build/src/events/outbox.js +33 -0
  162. package/build/src/events/record_mutation.d.ts +24 -0
  163. package/build/src/events/record_mutation.js +62 -0
  164. package/build/src/integrations/imports.d.ts +74 -0
  165. package/build/src/integrations/imports.js +333 -0
  166. package/build/src/integrations/inbound_webhooks.d.ts +94 -0
  167. package/build/src/integrations/inbound_webhooks.js +276 -0
  168. package/build/src/integrations/openapi.d.ts +39 -0
  169. package/build/src/integrations/openapi.js +323 -0
  170. package/build/src/integrations/print.d.ts +37 -0
  171. package/build/src/integrations/print.js +124 -0
  172. package/build/src/integrations/webhooks.d.ts +98 -0
  173. package/build/src/integrations/webhooks.js +298 -0
  174. package/build/src/mcp/tools.d.ts +8 -0
  175. package/build/src/mcp/tools.js +156 -0
  176. package/build/src/org/org_service.d.ts +2 -0
  177. package/build/src/org/org_service.js +16 -0
  178. package/build/src/resource/define_resource.d.ts +5 -0
  179. package/build/src/resource/define_resource.js +68 -0
  180. package/build/src/resource/registry.d.ts +12 -0
  181. package/build/src/resource/registry.js +101 -0
  182. package/build/src/resource/types.d.ts +155 -0
  183. package/build/src/resource/types.js +1 -0
  184. package/build/src/resource/values.d.ts +5 -0
  185. package/build/src/resource/values.js +88 -0
  186. package/build/src/services/backup.d.ts +14 -0
  187. package/build/src/services/backup.js +59 -0
  188. package/build/src/services/settings.d.ts +21 -0
  189. package/build/src/services/settings.js +30 -0
  190. package/build/src/upgrade/legacy.d.ts +27 -0
  191. package/build/src/upgrade/legacy.js +58 -0
  192. package/build/src/upgrade/rename.d.ts +17 -0
  193. package/build/src/upgrade/rename.js +94 -0
  194. package/build/src/version.d.ts +1 -0
  195. package/build/src/version.js +2 -0
  196. package/build/src/workflows/define_workflow.d.ts +124 -0
  197. package/build/src/workflows/define_workflow.js +123 -0
  198. package/build/src/workflows/engine.d.ts +141 -0
  199. package/build/src/workflows/engine.js +752 -0
  200. package/build/stubs/README.md +6 -0
  201. package/build/stubs/controller.stub +8 -0
  202. package/build/stubs/main.d.ts +5 -0
  203. package/build/stubs/main.js +5 -0
  204. package/build/stubs/main.ts +5 -0
  205. package/build/stubs/modules.stub +6 -0
  206. package/build/stubs/resource_contract.stub +1 -0
  207. package/build/stubs/resource_contract.txt +452 -0
  208. package/build/stubs/routes.stub +16 -0
  209. package/build/stubs/service.stub +9 -0
  210. package/package.json +95 -6
@@ -0,0 +1,210 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseCommand, args, flags } from '@adonisjs/core/ace';
8
+ import { createRequire } from 'node:module';
9
+ import { readFile, writeFile, mkdir, access } from 'node:fs/promises';
10
+ import { dirname, join, resolve, relative, isAbsolute } from 'node:path';
11
+ import { spawn } from 'node:child_process';
12
+ import { digest } from '../src/commands/agent_assets.js';
13
+ export default class Ui extends BaseCommand {
14
+ static commandName = 'adula:ui';
15
+ static description = 'Install reviewed RTL components through the project-owned shadcn registry';
16
+ async run() {
17
+ if (this.action !== 'add')
18
+ throw new Error('Usage: adula:ui add <component|all> [--preview|--accept]');
19
+ if (this.preview && this.accept)
20
+ throw new Error('Use either --preview or --accept, not both');
21
+ if (this.app.inProduction)
22
+ throw new Error('Install UI components in the source checkout');
23
+ const root = this.app.makePath();
24
+ const require = createRequire(this.app.makeURL('package.json'));
25
+ const uiRoot = dirname(require.resolve('@adula/ui/package.json'));
26
+ const manifest = JSON.parse(await readFile(join(uiRoot, 'build/manifest.json'), 'utf8'));
27
+ const available = new Set(manifest.items.map((item) => item.name));
28
+ if (this.component !== 'all' && !available.has(this.component))
29
+ throw new Error(`Unknown UI component: ${this.component}`);
30
+ const collected = new Map();
31
+ const load = async (name) => {
32
+ if (collected.has(name))
33
+ return;
34
+ if (!available.has(name))
35
+ throw new Error(`Unreviewed registry dependency: ${name}`);
36
+ const item = JSON.parse(await readFile(join(uiRoot, 'build', `${name}.json`), 'utf8'));
37
+ collected.set(name, item);
38
+ for (const dependency of item.registryDependencies ?? [])
39
+ await load(dependency);
40
+ };
41
+ for (const name of this.component === 'all' ? available : [this.component])
42
+ await load(name);
43
+ let lock = {
44
+ version: manifest.version,
45
+ adulaCompatibility: manifest.adulaCompatibility,
46
+ files: {},
47
+ };
48
+ try {
49
+ lock = JSON.parse(await readFile(this.app.makePath('ui.lock.json'), 'utf8'));
50
+ }
51
+ catch (error) {
52
+ if (error.code !== 'ENOENT')
53
+ throw error;
54
+ }
55
+ const customized = new Map();
56
+ for (const item of collected.values())
57
+ for (const file of item.files) {
58
+ const path = resolve(root, file.target);
59
+ const local = relative(root, path);
60
+ if (local.startsWith('..') ||
61
+ isAbsolute(local) ||
62
+ !file.target.startsWith('inertia/components/ui/'))
63
+ throw new Error('Registry files must stay in inertia/components/ui');
64
+ try {
65
+ const current = await readFile(path, 'utf8');
66
+ if (digest(current) !== lock.files[file.target]?.hash) {
67
+ // --accept is the documented end of a review: the developer merged by hand,
68
+ // so the file stays exactly as it is and only its recorded hash moves.
69
+ if (this.accept)
70
+ customized.set(file.target, current);
71
+ else if (!this.preview)
72
+ throw new Error(`Project customized ${file.target}; review it with --preview, merge the changes, then re-run with --accept`);
73
+ }
74
+ }
75
+ catch (error) {
76
+ if (error.code !== 'ENOENT')
77
+ throw error;
78
+ }
79
+ }
80
+ if (!this.preview)
81
+ await this.initialize(uiRoot);
82
+ else
83
+ await access(this.app.makePath('components.json'));
84
+ const bundle = {
85
+ $schema: 'https://ui.shadcn.com/schema/registry-item.json',
86
+ name: 'adula-ui',
87
+ type: 'registry:ui',
88
+ dependencies: [
89
+ ...new Set([
90
+ ...[...collected.values()].flatMap((item) => item.dependencies ?? []),
91
+ ...['tw-animate-css', '@fontsource/ibm-plex-sans-arabic'].map((name) => `${name}@${manifest.dependencies[name]}`),
92
+ ]),
93
+ ],
94
+ files: [...collected.values()].flatMap((item) => item.files),
95
+ };
96
+ const bundlePath = this.app.tmpPath('adula-ui.json');
97
+ await mkdir(dirname(bundlePath), { recursive: true });
98
+ await writeFile(bundlePath, JSON.stringify(bundle, null, 2));
99
+ const command = require.resolve('shadcn');
100
+ const bundleArgument = `./${relative(root, bundlePath).replaceAll('\\', '/')}`;
101
+ await new Promise((done, reject) => {
102
+ const child = spawn(process.execPath, [
103
+ command,
104
+ 'add',
105
+ bundleArgument,
106
+ '--yes',
107
+ ...(this.preview ? ['--dry-run'] : ['--overwrite']),
108
+ ], { cwd: root, stdio: 'inherit', shell: false });
109
+ child.once('error', reject);
110
+ child.once('exit', (code) => code === 0 ? done() : reject(new Error(`shadcn exited with ${code}`)));
111
+ });
112
+ if (this.preview)
113
+ return;
114
+ // shadcn overwrites unconditionally; reviewed customizations are put back untouched.
115
+ for (const [target, content] of customized)
116
+ await writeFile(this.app.makePath(target), content);
117
+ for (const item of collected.values())
118
+ for (const file of item.files)
119
+ lock.files[file.target] = {
120
+ hash: digest(await readFile(this.app.makePath(file.target), 'utf8')),
121
+ component: item.name,
122
+ };
123
+ lock.version = manifest.version;
124
+ lock.adulaCompatibility = manifest.adulaCompatibility;
125
+ await writeFile(this.app.makePath('ui.lock.json'), JSON.stringify(lock, null, 2) + '\n');
126
+ this.logger.success(`Installed ${collected.size} registry items; project file hashes recorded in ui.lock.json`);
127
+ if (customized.size)
128
+ this.logger.info(`Preserved ${customized.size} reviewed customization(s): ${[...customized.keys()].join(', ')}`);
129
+ }
130
+ async initialize(uiRoot) {
131
+ const root = this.app.makePath();
132
+ const create = async (path, content) => {
133
+ await mkdir(dirname(path), { recursive: true });
134
+ try {
135
+ await writeFile(path, content, { flag: 'wx' });
136
+ }
137
+ catch (error) {
138
+ if (error.code !== 'EEXIST')
139
+ throw error;
140
+ }
141
+ };
142
+ await create(join(root, 'components.json'), JSON.stringify({
143
+ $schema: 'https://ui.shadcn.com/schema.json',
144
+ style: 'new-york',
145
+ rsc: false,
146
+ tsx: true,
147
+ rtl: true,
148
+ tailwind: {
149
+ config: '',
150
+ css: 'inertia/css/adula.css',
151
+ baseColor: 'neutral',
152
+ cssVariables: true,
153
+ },
154
+ aliases: {
155
+ components: '~/components',
156
+ ui: '~/components/ui',
157
+ utils: '~/lib/utils',
158
+ lib: '~/lib',
159
+ hooks: '~/hooks',
160
+ },
161
+ iconLibrary: 'lucide',
162
+ }, null, 2) + '\n');
163
+ await create(join(root, 'inertia/css/adula.css'), await readFile(join(uiRoot, 'build/theme.css'), 'utf8'));
164
+ await create(join(root, 'inertia/lib/utils.ts'), "export { cn } from 'cn'\n");
165
+ const tsPath = join(root, 'tsconfig.json');
166
+ const ts = JSON.parse(await readFile(tsPath, 'utf8'));
167
+ ts.compilerOptions ??= {};
168
+ ts.compilerOptions.paths = { ...ts.compilerOptions.paths, '~/*': ['./inertia/*'] };
169
+ await writeFile(tsPath, JSON.stringify(ts, null, 2) + '\n');
170
+ const cssPath = join(root, 'inertia/css/app.css');
171
+ const css = await readFile(cssPath, 'utf8');
172
+ if (!css.includes('/* adula:legacy-layer */'))
173
+ await writeFile(cssPath, `/* adula:legacy-layer */\n@layer theme, base, legacy, components, utilities;\n@layer legacy {\n${css}\n}\n`);
174
+ const codemods = await this.createCodemods();
175
+ // The framework codemod only supports an object config. A configured host
176
+ // may use a callback (for test aliases, for example); do not rewrite it.
177
+ const vite = await readFile(join(root, 'vite.config.ts'), 'utf8');
178
+ if (!vite.includes("from '@tailwindcss/vite'") && !vite.includes('from "@tailwindcss/vite"'))
179
+ await codemods.registerVitePlugin('tailwindcss()', [
180
+ { module: '@tailwindcss/vite', identifier: 'tailwindcss', isNamed: false },
181
+ ]);
182
+ const project = await codemods.getTsMorphProject();
183
+ if (!project)
184
+ throw new Error('UI installation requires @adonisjs/assembler');
185
+ const entry = project.addSourceFileAtPathIfExists(join(root, 'inertia/app.tsx'));
186
+ // One CSS entry fixes layer ordering in development and production bundlers.
187
+ const adulaCssPath = join(root, 'inertia/css/adula.css');
188
+ const adulaCss = await readFile(adulaCssPath, 'utf8');
189
+ if (!adulaCss.includes('@import "./app.css"'))
190
+ await writeFile(adulaCssPath, `@layer theme, base, legacy, components, utilities;\n@import "./app.css";\n${adulaCss}`);
191
+ entry.getImportDeclaration('./css/app.css')?.remove();
192
+ if (!entry.getImportDeclaration('./css/adula.css'))
193
+ entry.addImportDeclaration({ moduleSpecifier: './css/adula.css' });
194
+ await entry.save();
195
+ }
196
+ }
197
+ __decorate([
198
+ args.string()
199
+ ], Ui.prototype, "action", void 0);
200
+ __decorate([
201
+ args.string()
202
+ ], Ui.prototype, "component", void 0);
203
+ __decorate([
204
+ flags.boolean({ description: 'Show shadcn changes without modifying UI files' })
205
+ ], Ui.prototype, "preview", void 0);
206
+ __decorate([
207
+ flags.boolean({
208
+ description: 'Keep already reviewed customizations, re-record their hashes and update others',
209
+ })
210
+ ], Ui.prototype, "accept", void 0);
@@ -0,0 +1,15 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ /**
3
+ * Second step of the 2.0 upgrade, after `npx create-adula-app@latest upgrade` has
4
+ * moved the application to the `adula` package. Renames the migration history,
5
+ * the gap log and the managed AGENTS.md block that 1.x wrote, then runs the
6
+ * pending migrations. Safe to repeat.
7
+ */
8
+ export default class Upgrade extends BaseCommand {
9
+ static commandName: string;
10
+ static description: string;
11
+ static options: {
12
+ startApp: boolean;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,34 @@
1
+ import { BaseCommand } from '@adonisjs/core/ace';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { syncAgentAssets } from '../src/commands/agent_assets.js';
4
+ import { renameLegacyFiles, renameRecordedMigrations } from '../src/upgrade/rename.js';
5
+ /**
6
+ * Second step of the 2.0 upgrade, after `npx create-adula-app@latest upgrade` has
7
+ * moved the application to the `adula` package. Renames the migration history,
8
+ * the gap log and the managed AGENTS.md block that 1.x wrote, then runs the
9
+ * pending migrations. Safe to repeat.
10
+ */
11
+ export default class Upgrade extends BaseCommand {
12
+ static commandName = 'adula:upgrade';
13
+ static description = 'Rename 1.x migration history and managed files to AdulaJS, then run pending migrations';
14
+ static options = { startApp: true };
15
+ async run() {
16
+ const { default: db } = await import('@adonisjs/lucid/services/db');
17
+ const config = db.getRawConnection(db.primaryConnectionName)?.config;
18
+ const table = config?.migrations?.tableName ?? 'adonis_schema';
19
+ const renamed = await renameRecordedMigrations(db.connection().getWriteClient(), table);
20
+ this.logger.info(`Migration history: ${renamed} recorded 1.x migrations renamed`);
21
+ const root = fileURLToPath(this.app.appRoot);
22
+ for (const change of await renameLegacyFiles(root))
23
+ this.logger.info(`Renamed ${change}`);
24
+ await syncAgentAssets(root);
25
+ this.logger.info('Managed AGENTS.md block and skills synchronized');
26
+ const migrate = await this.kernel.exec('migration:run', ['--force']);
27
+ if (migrate.exitCode) {
28
+ this.exitCode = migrate.exitCode;
29
+ this.logger.error('migration:run failed; the history rename is kept and can be repeated');
30
+ return;
31
+ }
32
+ this.logger.success('Upgrade finished. Next: ADULA_ADMIN_EMAIL=<email> node ace adula:install, then node ace adula:doctor');
33
+ }
34
+ }
@@ -0,0 +1,2 @@
1
+ import type Configure from '@adonisjs/core/commands/configure';
2
+ export declare function configure(command: Configure): Promise<void>;
@@ -0,0 +1,79 @@
1
+ /*
2
+ |--------------------------------------------------------------------------
3
+ | Configure hook
4
+ |--------------------------------------------------------------------------
5
+ |
6
+ | The configure hook is called when someone runs "node ace configure <package>"
7
+ | command. You are free to perform any operations inside this function to
8
+ | configure the package.
9
+ |
10
+ | To make things easier, you have access to the underlying "Configure"
11
+ | instance and you can use codemods to modify the source files.
12
+ |
13
+ */
14
+ import { readFile, writeFile } from 'node:fs/promises';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { stubsRoot } from './stubs/main.js';
17
+ export async function configure(command) {
18
+ const pkgPath = command.app.makePath('package.json');
19
+ const pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
20
+ for (const dependency of ['@adonisjs/lucid', '@adonisjs/auth', '@adonisjs/session', '@adonisjs/shield', 'pg']) {
21
+ if (!pkg.dependencies?.[dependency])
22
+ throw new Error(`Install and configure ${dependency} before adula`);
23
+ }
24
+ const aliases = { '#modules/*': './app/modules/*.js', '#tests/*': './tests/*.js' };
25
+ for (const [key, target] of Object.entries(aliases)) {
26
+ if (pkg.imports?.[key] && pkg.imports[key] !== target)
27
+ throw new Error(`Conflicting package import ${key}`);
28
+ }
29
+ const dbPath = command.app.configPath('database.ts');
30
+ const databaseSource = await readFile(dbPath, 'utf8');
31
+ if (!/client:\s*['"]pg['"]/.test(databaseSource.replace(/\/\/[^\n]*/g, '')))
32
+ throw new Error('Configure PostgreSQL with node ace configure @adonisjs/lucid --db=postgres before adula');
33
+ const codemods = await command.createCodemods();
34
+ const project = await codemods.getTsMorphProject();
35
+ if (!project)
36
+ throw new Error('The host must have @adonisjs/assembler installed to configure AdulaJS');
37
+ const dbFile = project.addSourceFileAtPathIfExists(dbPath);
38
+ const dbExport = dbFile.getExportAssignments()[0];
39
+ if (!dbExport)
40
+ throw new Error('config/database.ts must have a default export');
41
+ if (!dbExport.getExpression().getText().startsWith('withAdulaDatabase(')) {
42
+ const adulaImport = dbFile.getImportDeclaration('adula');
43
+ if (adulaImport)
44
+ adulaImport.addNamedImport('withAdulaDatabase');
45
+ else
46
+ dbFile.addImportDeclaration({ moduleSpecifier: 'adula', namedImports: ['withAdulaDatabase'] });
47
+ const urlImport = dbFile.getImportDeclaration('node:url');
48
+ if (!urlImport?.getNamedImports().some((entry) => entry.getName() === 'fileURLToPath')) {
49
+ if (urlImport)
50
+ urlImport.addNamedImport('fileURLToPath');
51
+ else
52
+ dbFile.addImportDeclaration({ moduleSpecifier: 'node:url', namedImports: ['fileURLToPath'] });
53
+ }
54
+ dbExport.setExpression(`withAdulaDatabase(${dbExport.getExpression().getText()}, fileURLToPath(new URL('../', import.meta.url)))`);
55
+ await dbFile.save();
56
+ }
57
+ pkg.imports = { ...pkg.imports, ...aliases };
58
+ await writeFile(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
59
+ codemods.overwriteExisting = false;
60
+ for (const stub of ['modules', 'service', 'controller', 'routes', 'resource_contract'])
61
+ await codemods.makeUsingStub(stubsRoot, `${stub}.stub`, {}, stub === 'resource_contract'
62
+ ? { contentsFromFile: fileURLToPath(new URL('./stubs/resource_contract.txt', import.meta.url)) } : undefined);
63
+ await codemods.updateRcFile((rc) => {
64
+ rc.addProvider('adula/provider').addCommand('adula/commands').addPreloadFile('#start/adula_routes');
65
+ });
66
+ if (!pkg.devDependencies?.['@japa/api-client'] && !pkg.dependencies?.['@japa/api-client']) {
67
+ const installed = await codemods.installPackages([{ name: '@japa/api-client@3.2.1', isDevDependency: true }]);
68
+ if (!installed)
69
+ throw new Error('Install @japa/api-client@3.2.1, then rerun configure');
70
+ }
71
+ for (const [name, path, args] of [
72
+ ['apiClient', '@japa/api-client', ''],
73
+ ['sessionApiClient', '@adonisjs/session/plugins/api_client', 'app'],
74
+ ['authApiClient', '@adonisjs/auth/plugins/api_client', 'app'],
75
+ ['shieldApiClient', '@adonisjs/shield/plugins/api_client', ''],
76
+ ])
77
+ await codemods.registerJapaPlugin(`${name}(${args})`, [{ module: path, isNamed: true, identifier: name }]);
78
+ command.logger.success('AdulaJS configured. Run migration:run, create your user using the official auth flow, then ADULA_ADMIN_EMAIL=<email> node ace adula:install.');
79
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Core extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createCoreSchema } from '../../src/database/schema.js';
3
+ export default class Core extends BaseSchema {
4
+ async up() {
5
+ await createCoreSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Attachments extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createAttachmentsSchema } from '../../src/database/schema.js';
3
+ export default class Attachments extends BaseSchema {
4
+ async up() {
5
+ await createAttachmentsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class SavedViews extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createSavedViewsSchema } from '../../src/database/schema.js';
3
+ export default class SavedViews extends BaseSchema {
4
+ async up() {
5
+ await createSavedViewsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class extends BaseSchema {
3
+ async up() {
4
+ this.schema.createTable('user_invitations', (table) => {
5
+ table.increments('id');
6
+ table.string('email', 254).notNullable().unique();
7
+ table.string('full_name', 120).notNullable();
8
+ table.string('token_hash', 64).notNullable().unique();
9
+ table.integer('invited_by').unsigned().references('id').inTable('users').onDelete('RESTRICT');
10
+ table.timestamp('expires_at', { useTz: true }).notNullable();
11
+ table.timestamp('accepted_at', { useTz: true }).nullable();
12
+ table.timestamp('created_at', { useTz: true }).notNullable().defaultTo(this.now());
13
+ });
14
+ }
15
+ async down() {
16
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Collaboration extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createCollaborationSchema } from '../../src/database/schema.js';
3
+ export default class Collaboration extends BaseSchema {
4
+ async up() {
5
+ await createCollaborationSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Assignments extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createAssignmentsSchema } from '../../src/database/schema.js';
3
+ export default class Assignments extends BaseSchema {
4
+ async up() {
5
+ await createAssignmentsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Messaging extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createMessagingSchema } from '../../src/database/schema.js';
3
+ export default class Messaging extends BaseSchema {
4
+ async up() {
5
+ await createMessagingSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Webhooks extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createWebhooksSchema } from '../../src/database/schema.js';
3
+ export default class Webhooks extends BaseSchema {
4
+ async up() {
5
+ await createWebhooksSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Imports extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createImportsSchema } from '../../src/database/schema.js';
3
+ export default class Imports extends BaseSchema {
4
+ async up() {
5
+ await createImportsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class Workflows extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createWorkflowSchema } from '../../src/database/schema.js';
3
+ export default class Workflows extends BaseSchema {
4
+ async up() {
5
+ await createWorkflowSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class ManagedAssignments extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createManagedAssignmentsSchema } from '../../src/database/schema.js';
3
+ export default class ManagedAssignments extends BaseSchema {
4
+ async up() {
5
+ await createManagedAssignmentsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class RoleKeys extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createRoleKeysSchema } from '../../src/database/schema.js';
3
+ export default class RoleKeys extends BaseSchema {
4
+ async up() {
5
+ await createRoleKeysSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class NotificationTargets extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createNotificationTargetsSchema } from '../../src/database/schema.js';
3
+ export default class NotificationTargets extends BaseSchema {
4
+ async up() {
5
+ await createNotificationTargetsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class UploadGrants extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createUploadGrantsSchema } from '../../src/database/schema.js';
3
+ export default class UploadGrants extends BaseSchema {
4
+ async up() {
5
+ await createUploadGrantsSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }
@@ -0,0 +1,5 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ export default class InboundWebhooks extends BaseSchema {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
@@ -0,0 +1,10 @@
1
+ import { BaseSchema } from '@adonisjs/lucid/schema';
2
+ import { createInboundWebhooksSchema } from '../../src/database/schema.js';
3
+ export default class InboundWebhooks extends BaseSchema {
4
+ async up() {
5
+ await createInboundWebhooksSchema(this.db.getWriteClient());
6
+ }
7
+ async down() {
8
+ throw new Error('AdulaJS migrations are additive. Restore a tested backup instead of rolling back.');
9
+ }
10
+ }