@itarrshia/bati 0.0.0-stage → 0.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 (67) hide show
  1. package/README.md +164 -2
  2. package/assets/bati-mark.svg +26 -0
  3. package/dist/api.ts +0 -0
  4. package/dist/bati-db.png +0 -0
  5. package/dist/bati-openapi.json +8 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +174 -0
  8. package/dist/core/api-generate.d.ts +9 -0
  9. package/dist/core/api-generate.js +74 -0
  10. package/dist/core/api.d.ts +44 -0
  11. package/dist/core/api.js +292 -0
  12. package/dist/core/config.d.ts +40 -0
  13. package/dist/core/config.js +53 -0
  14. package/dist/core/dashboard.d.ts +37 -0
  15. package/dist/core/dashboard.js +95 -0
  16. package/dist/core/db.d.ts +31 -0
  17. package/dist/core/db.js +392 -0
  18. package/dist/core/deps.d.ts +35 -0
  19. package/dist/core/deps.js +242 -0
  20. package/dist/core/diagram.d.ts +4 -0
  21. package/dist/core/diagram.js +151 -0
  22. package/dist/core/doctor.d.ts +23 -0
  23. package/dist/core/doctor.js +148 -0
  24. package/dist/core/files.d.ts +5 -0
  25. package/dist/core/files.js +69 -0
  26. package/dist/core/format.d.ts +13 -0
  27. package/dist/core/format.js +54 -0
  28. package/dist/core/graph-view.d.ts +2 -0
  29. package/dist/core/graph-view.js +65 -0
  30. package/dist/core/mcp-install.d.ts +19 -0
  31. package/dist/core/mcp-install.js +105 -0
  32. package/dist/core/mcp.d.ts +12 -0
  33. package/dist/core/mcp.js +244 -0
  34. package/dist/core/openapi.d.ts +16 -0
  35. package/dist/core/openapi.js +270 -0
  36. package/dist/core/pack.d.ts +8 -0
  37. package/dist/core/pack.js +101 -0
  38. package/dist/core/php.d.ts +6 -0
  39. package/dist/core/php.js +50 -0
  40. package/dist/core/preview.d.ts +9 -0
  41. package/dist/core/preview.js +89 -0
  42. package/dist/core/probe.d.ts +21 -0
  43. package/dist/core/probe.js +119 -0
  44. package/dist/core/routes.d.ts +37 -0
  45. package/dist/core/routes.js +343 -0
  46. package/dist/core/scan.d.ts +13 -0
  47. package/dist/core/scan.js +395 -0
  48. package/dist/core/tasks.d.ts +34 -0
  49. package/dist/core/tasks.js +88 -0
  50. package/dist/core/types.d.ts +46 -0
  51. package/dist/core/types.js +1 -0
  52. package/dist/openapi.json +8 -0
  53. package/dist/theme.d.ts +12 -0
  54. package/dist/theme.js +32 -0
  55. package/dist/ui/App.d.ts +5 -0
  56. package/dist/ui/App.js +247 -0
  57. package/dist/ui/Banner.d.ts +5 -0
  58. package/dist/ui/Banner.js +9 -0
  59. package/dist/ui/Dashboard.d.ts +26 -0
  60. package/dist/ui/Dashboard.js +52 -0
  61. package/dist/ui/MapView.d.ts +5 -0
  62. package/dist/ui/MapView.js +47 -0
  63. package/dist/ui/Wizard.d.ts +17 -0
  64. package/dist/ui/Wizard.js +112 -0
  65. package/dist/ui/presentation.d.ts +24 -0
  66. package/dist/ui/presentation.js +15 -0
  67. package/package.json +80 -4
@@ -0,0 +1,395 @@
1
+ import { listFiles } from './files.js';
2
+ import { readFileSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { Project } from 'ts-morph';
5
+ import PhpParser from 'php-parser';
6
+ import { loadConfig } from './config.js';
7
+ export const IGNORE = [
8
+ '**/node_modules/**',
9
+ '**/vendor/**',
10
+ '**/dist/**',
11
+ '**/build/**',
12
+ '**/.git/**',
13
+ '**/.next/**',
14
+ '**/storage/**',
15
+ '**/coverage/**',
16
+ '**/bootstrap/cache/**',
17
+ '**/*.d.ts',
18
+ '**/*.min.js'
19
+ ];
20
+ const CODE = '**/*.{ts,tsx,js,jsx,mjs,cjs,php,vue}';
21
+ const langOf = (file) => {
22
+ const ext = path.extname(file);
23
+ if (ext === '.php')
24
+ return 'php';
25
+ if (ext === '.ts' || ext === '.tsx')
26
+ return 'ts';
27
+ return 'js';
28
+ };
29
+ const nameOf = (n) => {
30
+ if (!n)
31
+ return '';
32
+ if (typeof n === 'string')
33
+ return n;
34
+ return nameOf(n.name);
35
+ };
36
+ const lastSegment = (s) => s.split('\\').filter(Boolean).pop() ?? s;
37
+ const phpType = (t) => {
38
+ if (!t)
39
+ return '';
40
+ const prefix = t.nullable ? '?' : '';
41
+ if (t.kind === 'uniontype' || t.kind === 'intersectiontype') {
42
+ return (t.types || []).map(phpType).join(t.kind === 'uniontype' ? '|' : '&');
43
+ }
44
+ return prefix + lastSegment(nameOf(t));
45
+ };
46
+ const parsePhp = (code, file, rel) => {
47
+ const engine = new PhpParser({
48
+ parser: { extractDoc: false, php8: true, suppressErrors: true },
49
+ ast: { withPositions: false }
50
+ });
51
+ const out = [];
52
+ const handle = (n) => {
53
+ if (!['class', 'interface', 'trait', 'enum'].includes(n.kind))
54
+ return;
55
+ const name = nameOf(n.name);
56
+ if (!name)
57
+ return;
58
+ const info = {
59
+ id: `${rel}::${name}`,
60
+ name,
61
+ kind: n.kind,
62
+ file: rel,
63
+ lang: 'php',
64
+ implements: [],
65
+ traits: [],
66
+ props: [],
67
+ methods: []
68
+ };
69
+ if (n.kind === 'interface') {
70
+ const parents = (Array.isArray(n.extends) ? n.extends : n.extends ? [n.extends] : []).map((x) => lastSegment(nameOf(x)));
71
+ info.implements = parents;
72
+ }
73
+ else {
74
+ if (n.extends)
75
+ info.extends = lastSegment(nameOf(n.extends));
76
+ info.implements = (n.implements || []).map((x) => lastSegment(nameOf(x)));
77
+ }
78
+ for (const b of n.body || []) {
79
+ if (b.kind === 'propertystatement') {
80
+ for (const p of b.properties || []) {
81
+ info.props.push({
82
+ name: nameOf(p.name),
83
+ visibility: b.visibility || 'public',
84
+ static: !!b.isStatic,
85
+ type: phpType(p.type)
86
+ });
87
+ }
88
+ }
89
+ else if (b.kind === 'method') {
90
+ info.methods.push({
91
+ name: nameOf(b.name),
92
+ visibility: b.visibility || 'public',
93
+ static: !!b.isStatic,
94
+ params: (b.arguments || [])
95
+ .map((a) => `${a.type ? phpType(a.type) + ' ' : ''}$${nameOf(a.name)}`)
96
+ .join(', '),
97
+ returns: phpType(b.type)
98
+ });
99
+ if (nameOf(b.name) === '__construct') {
100
+ for (const a of b.arguments || []) {
101
+ if (a.flags || a.promote) {
102
+ info.props.push({
103
+ name: nameOf(a.name),
104
+ visibility: 'private',
105
+ static: false,
106
+ type: phpType(a.type)
107
+ });
108
+ }
109
+ }
110
+ }
111
+ }
112
+ else if (b.kind === 'traituse') {
113
+ info.traits.push(...(b.traits || []).map((t) => lastSegment(nameOf(t))));
114
+ }
115
+ else if (b.kind === 'classconstant') {
116
+ for (const c of b.constants || []) {
117
+ info.props.push({ name: nameOf(c.name), visibility: b.visibility || 'public', static: true });
118
+ }
119
+ }
120
+ }
121
+ out.push(info);
122
+ };
123
+ const walk = (nodes) => {
124
+ for (const n of nodes || []) {
125
+ if (n.kind === 'namespace')
126
+ walk(n.children);
127
+ else
128
+ handle(n);
129
+ }
130
+ };
131
+ const ast = engine.parseCode(code, file);
132
+ walk(ast.children);
133
+ return out;
134
+ };
135
+ const parseTs = (project, abs, rel, lang) => {
136
+ const sf = project.addSourceFileAtPath(abs);
137
+ const out = [];
138
+ const vis = (m) => {
139
+ const s = typeof m.getScope === 'function' ? m.getScope() : 'public';
140
+ return String(s);
141
+ };
142
+ for (const c of sf.getClasses()) {
143
+ const name = c.getName();
144
+ if (!name)
145
+ continue;
146
+ const props = c.getProperties().map((p) => ({
147
+ name: p.getName(),
148
+ visibility: vis(p),
149
+ static: p.isStatic(),
150
+ type: p.getTypeNode()?.getText()
151
+ }));
152
+ for (const ctor of c.getConstructors()) {
153
+ for (const p of ctor.getParameters()) {
154
+ if (p.isParameterProperty()) {
155
+ props.push({
156
+ name: p.getName(),
157
+ visibility: String(p.getScope() ?? 'public'),
158
+ static: false,
159
+ type: p.getTypeNode()?.getText()
160
+ });
161
+ }
162
+ }
163
+ }
164
+ const methods = c.getMethods().map((m) => ({
165
+ name: m.getName(),
166
+ visibility: vis(m),
167
+ static: m.isStatic(),
168
+ params: m
169
+ .getParameters()
170
+ .map((p) => p.getName() + (p.getTypeNode() ? `: ${p.getTypeNode().getText()}` : ''))
171
+ .join(', '),
172
+ returns: m.getReturnTypeNode()?.getText()
173
+ }));
174
+ out.push({
175
+ id: `${rel}::${name}`,
176
+ name,
177
+ kind: 'class',
178
+ file: rel,
179
+ lang,
180
+ extends: c.getExtends()?.getExpression().getText().split('.').pop(),
181
+ implements: c.getImplements().map((i) => i.getExpression().getText().split('.').pop() ?? ''),
182
+ traits: [],
183
+ props,
184
+ methods
185
+ });
186
+ }
187
+ for (const i of sf.getInterfaces()) {
188
+ out.push({
189
+ id: `${rel}::${i.getName()}`,
190
+ name: i.getName(),
191
+ kind: 'interface',
192
+ file: rel,
193
+ lang,
194
+ implements: i.getExtends().map((e) => e.getExpression().getText().split('.').pop() ?? ''),
195
+ traits: [],
196
+ props: i.getProperties().map((p) => ({
197
+ name: p.getName(),
198
+ visibility: 'public',
199
+ static: false,
200
+ type: p.getTypeNode()?.getText()
201
+ })),
202
+ methods: i.getMethods().map((m) => ({
203
+ name: m.getName(),
204
+ visibility: 'public',
205
+ static: false,
206
+ params: m
207
+ .getParameters()
208
+ .map((p) => p.getName() + (p.getTypeNode() ? `: ${p.getTypeNode().getText()}` : ''))
209
+ .join(', '),
210
+ returns: m.getReturnTypeNode()?.getText()
211
+ }))
212
+ });
213
+ }
214
+ for (const e of sf.getEnums()) {
215
+ out.push({
216
+ id: `${rel}::${e.getName()}`,
217
+ name: e.getName(),
218
+ kind: 'enum',
219
+ file: rel,
220
+ lang,
221
+ implements: [],
222
+ traits: [],
223
+ props: e.getMembers().map((m) => ({ name: m.getName(), visibility: 'public', static: true })),
224
+ methods: []
225
+ });
226
+ }
227
+ return out;
228
+ };
229
+ const ROLE_RULES = [
230
+ [/(^|\/)(tests?|__tests__|spec)(\/|$)|\.(test|spec)\.[a-z]+$/i, 'test'],
231
+ [/migrations?\//i, 'migration'],
232
+ [/controllers?(\/|\.|[A-Z])/i, 'controller'],
233
+ [/middleware/i, 'middleware'],
234
+ [/(models?|entit(y|ies))\//i, 'model'],
235
+ [/repositor/i, 'repository'],
236
+ [/services?(\/|\.|[A-Z])/i, 'service'],
237
+ [/(requests?|dto|schemas?)\//i, 'dto'],
238
+ [/providers?\//i, 'provider'],
239
+ [/(jobs?|listeners?|events?|observers?)\//i, 'job'],
240
+ [/(console|commands?)\//i, 'command'],
241
+ [/(^|\/)use[A-Z]\w*\.[jt]sx?$/, 'hook'],
242
+ [/\.(tsx|jsx|vue)$/, 'component'],
243
+ [/routes?(\/|\.)/i, 'route'],
244
+ [/config/i, 'config'],
245
+ [/(types?|interfaces?|contracts?)\//i, 'contract'],
246
+ [/(utils?|helpers?|lib)\//i, 'util']
247
+ ];
248
+ const roleOf = (rel, classes) => {
249
+ for (const c of classes) {
250
+ const e = c.extends ?? '';
251
+ if (/Controller$/.test(e))
252
+ return 'controller';
253
+ if (/Model$/.test(e))
254
+ return 'model';
255
+ if (/Middleware$/.test(e))
256
+ return 'middleware';
257
+ if (/Command$/.test(e))
258
+ return 'command';
259
+ if (/Migration$/.test(e))
260
+ return 'migration';
261
+ if (/ServiceProvider$/.test(e))
262
+ return 'provider';
263
+ if (/(TestCase|Test)$/.test(e))
264
+ return 'test';
265
+ }
266
+ for (const [re, role] of ROLE_RULES)
267
+ if (re.test(rel))
268
+ return role;
269
+ return classes.length ? 'class' : 'module';
270
+ };
271
+ const typeRefs = (s) => (s ? s.match(/[A-Z][A-Za-z0-9_]*/g) ?? [] : []);
272
+ export const scanProject = async (dir) => {
273
+ const root = path.resolve(dir);
274
+ const config = await loadConfig(root);
275
+ const entries = (await listFiles(root, CODE)).filter((file) => !/\.d\.ts$|\.min\.js$|^bootstrap\/cache\//.test(file));
276
+ entries.sort();
277
+ const tsProject = new Project({
278
+ skipAddingFilesFromTsConfig: true,
279
+ skipFileDependencyResolution: true,
280
+ compilerOptions: { allowJs: true }
281
+ });
282
+ const files = [];
283
+ const classes = [];
284
+ for (const rel of entries) {
285
+ const abs = path.join(root, rel);
286
+ const lang = langOf(rel);
287
+ let found = [];
288
+ let lines = 0;
289
+ try {
290
+ const code = readFileSync(abs, 'utf8');
291
+ lines = code.split('\n').length;
292
+ if (lang === 'php')
293
+ found = parsePhp(code, abs, rel);
294
+ else if (!rel.endsWith('.vue'))
295
+ found = parseTs(tsProject, abs, rel, lang);
296
+ }
297
+ catch {
298
+ found = [];
299
+ }
300
+ classes.push(...found);
301
+ const file = { path: rel, lang, role: roleOf(rel, found), lines, classes: found.map((c) => c.name) };
302
+ for (const scanner of config.plugins.flatMap((plugin) => plugin.scanners ?? [])) {
303
+ Object.assign(file, await scanner({ root }, file));
304
+ }
305
+ files.push(file);
306
+ }
307
+ const byName = new Map();
308
+ for (const c of classes)
309
+ if (!byName.has(c.name))
310
+ byName.set(c.name, c);
311
+ const seen = new Set();
312
+ const edges = [];
313
+ const add = (from, toName, kind) => {
314
+ if (!toName)
315
+ return;
316
+ const target = byName.get(toName);
317
+ if (!target || target.id === from.id)
318
+ return;
319
+ const key = `${from.id}>${target.id}>${kind}`;
320
+ if (seen.has(key))
321
+ return;
322
+ seen.add(key);
323
+ edges.push({ from: from.id, to: target.id, kind });
324
+ };
325
+ for (const c of classes) {
326
+ add(c, c.extends, 'extends');
327
+ c.implements.forEach((i) => add(c, i, 'implements'));
328
+ c.traits.forEach((t) => add(c, t, 'uses'));
329
+ const refs = new Set();
330
+ c.props.forEach((p) => typeRefs(p.type).forEach((r) => refs.add(r)));
331
+ c.methods
332
+ .filter((m) => m.name === 'constructor' || m.name === '__construct')
333
+ .forEach((m) => typeRefs(m.params).forEach((r) => refs.add(r)));
334
+ refs.forEach((r) => add(c, r, 'uses'));
335
+ }
336
+ return { root, files, classes, edges };
337
+ };
338
+ export const filterModel = (model, query) => {
339
+ if (!query)
340
+ return model;
341
+ const q = query.toLowerCase();
342
+ const hit = new Set(model.classes.filter((c) => c.name.toLowerCase().includes(q) || c.file.toLowerCase().includes(q)).map((c) => c.id));
343
+ const keep = new Set(hit);
344
+ for (const e of model.edges) {
345
+ if (hit.has(e.from))
346
+ keep.add(e.to);
347
+ if (hit.has(e.to))
348
+ keep.add(e.from);
349
+ }
350
+ return {
351
+ ...model,
352
+ classes: model.classes.filter((c) => keep.has(c.id)),
353
+ edges: model.edges.filter((e) => keep.has(e.from) && keep.has(e.to))
354
+ };
355
+ };
356
+ export const treeRows = (model) => {
357
+ const rootNode = { name: '', children: new Map() };
358
+ for (const f of model.files) {
359
+ let cur = rootNode;
360
+ for (const part of f.path.split('/')) {
361
+ if (!cur.children.has(part))
362
+ cur.children.set(part, { name: part, children: new Map() });
363
+ cur = cur.children.get(part);
364
+ }
365
+ cur.file = f;
366
+ }
367
+ const rows = [];
368
+ const walk = (node, indent) => {
369
+ const kids = [...node.children.values()].sort((a, b) => {
370
+ const ad = a.file ? 1 : 0;
371
+ const bd = b.file ? 1 : 0;
372
+ return ad - bd || a.name.localeCompare(b.name);
373
+ });
374
+ kids.forEach((k, i) => {
375
+ const last = i === kids.length - 1;
376
+ const prefix = indent + (last ? '└─ ' : '├─ ');
377
+ if (k.file) {
378
+ const cls = k.file.classes.length ? k.file.classes.slice(0, 3).join(', ') : '';
379
+ rows.push({ prefix, name: k.name, dir: false, role: k.file.role, meta: cls });
380
+ }
381
+ else {
382
+ rows.push({ prefix, name: k.name + '/', dir: true });
383
+ walk(k, indent + (last ? ' ' : '│ '));
384
+ }
385
+ });
386
+ };
387
+ walk(rootNode, '');
388
+ return rows;
389
+ };
390
+ export const roleStats = (model) => {
391
+ const m = new Map();
392
+ for (const f of model.files)
393
+ m.set(f.role, (m.get(f.role) ?? 0) + 1);
394
+ return [...m.entries()].sort((a, b) => b[1] - a[1]);
395
+ };
@@ -0,0 +1,34 @@
1
+ import type { TaskResult } from './types.js';
2
+ export declare const apiGen: (o: {
3
+ spec: string;
4
+ root?: string;
5
+ out?: string;
6
+ typesOnly?: boolean;
7
+ baseUrl?: string;
8
+ zod?: boolean;
9
+ query?: boolean;
10
+ split?: boolean;
11
+ }) => Promise<TaskResult>;
12
+ export declare const apiProbe: (o: {
13
+ base: string;
14
+ routes: string;
15
+ root?: string;
16
+ out?: string;
17
+ headers?: string[];
18
+ offline?: boolean;
19
+ typesOnly?: boolean;
20
+ }) => Promise<TaskResult>;
21
+ export declare const fmt: (o: {
22
+ paths: string[];
23
+ check?: boolean;
24
+ }) => Promise<TaskResult>;
25
+ export declare const classes: (o: {
26
+ dir: string;
27
+ format: string;
28
+ out?: string;
29
+ filter?: string;
30
+ }) => Promise<TaskResult>;
31
+ export declare const projectSummary: (dir: string) => Promise<{
32
+ model: import("./types.js").ProjectModel;
33
+ roles: [string, number][];
34
+ }>;
@@ -0,0 +1,88 @@
1
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { configuredOutput, loadConfig } from './config.js';
4
+ import { writeOutput } from './files.js';
5
+ const write = (file, data) => {
6
+ const abs = path.resolve(file);
7
+ mkdirSync(path.dirname(abs), { recursive: true });
8
+ writeFileSync(abs, data);
9
+ return abs;
10
+ };
11
+ export const apiGen = async (o) => {
12
+ const { generate, loadSpec } = await import('./openapi.js');
13
+ const spec = await loadSpec(o.spec);
14
+ const r = await generate(spec, { ...o, baseUrl: o.baseUrl || undefined });
15
+ const target = configuredOutput(o.root ?? '.', await loadConfig(o.root), 'api', o.split ? 'api' : 'api.ts', o.out);
16
+ if (o.split && /\.[cm]?tsx?$/.test(target))
17
+ throw new Error('Split output requires a directory');
18
+ const files = o.split
19
+ ? await Promise.all(Object.entries(r.parts).filter(([name]) => name !== 'index.ts')
20
+ .map(([name, code]) => writeOutput(path.join(target, name), code)))
21
+ : [];
22
+ const file = o.split
23
+ ? await writeOutput(path.join(target, 'index.ts'), r.parts['index.ts'])
24
+ : await writeOutput(target, r.code);
25
+ files.push(file);
26
+ return {
27
+ title: 'API generated',
28
+ output: file,
29
+ data: { files, schemas: r.schemas, operations: r.operations },
30
+ lines: [`${r.schemas} schemas`, `${r.operations} operations`, `${(r.code.length / 1024).toFixed(1)} KB`, `→ ${file}`]
31
+ };
32
+ };
33
+ export const apiProbe = async (o) => {
34
+ const [{ probe }, { generate }] = await Promise.all([import('./probe.js'), import('./openapi.js')]);
35
+ const { spec, results } = await probe({ base: o.base, routes: o.routes, headers: o.headers, offline: o.offline });
36
+ const r = await generate(spec, { typesOnly: o.typesOnly, baseUrl: o.base });
37
+ const file = write(configuredOutput(o.root ?? '.', await loadConfig(o.root), 'api', 'api.ts', o.out), r.code);
38
+ return {
39
+ title: 'API probed',
40
+ output: file,
41
+ lines: [...results.map((x) => `${x.status.padEnd(8)}${x.route}`), `→ ${file}`]
42
+ };
43
+ };
44
+ export const fmt = async (o) => {
45
+ const { formatPaths } = await import('./format.js');
46
+ const r = await formatPaths(o.paths, { check: o.check });
47
+ const rel = (f) => path.relative(process.cwd(), f);
48
+ return {
49
+ exitCode: r.failed.length || (o.check && r.changed.length) ? 1 : 0,
50
+ data: r,
51
+ title: o.check ? 'Format check' : 'Formatted',
52
+ lines: [
53
+ `${r.changed.length} ${o.check ? 'need formatting' : 'rewritten'} · ${r.unchanged} already clean · ${r.failed.length} failed`,
54
+ ...r.changed.slice(0, 40).map((f) => `✎ ${rel(f)}`),
55
+ ...r.failed.slice(0, 10).map((f) => `✗ ${rel(f.file)} — ${f.error}`)
56
+ ]
57
+ };
58
+ };
59
+ export const classes = async (o) => {
60
+ const [{ filterModel, scanProject }, { renderSvg, toMermaid, toPng }] = await Promise.all([import('./scan.js'), import('./diagram.js')]);
61
+ const model = filterModel(await scanProject(o.dir), o.filter);
62
+ const fmtName = o.format.toLowerCase();
63
+ if (!['png', 'svg', 'mermaid', 'json'].includes(fmtName))
64
+ throw new Error(`Unknown diagram format: ${fmtName}`);
65
+ if (!model.classes.length)
66
+ return { title: 'Classes', lines: ['No classes found'], data: { classes: [], edges: [] } };
67
+ const out = configuredOutput(o.dir, await loadConfig(o.dir), 'classes', `bati-classes.${fmtName === 'mermaid' ? 'mmd' : fmtName}`, o.out);
68
+ let file;
69
+ if (fmtName === 'mermaid')
70
+ file = write(out, toMermaid(model));
71
+ else if (fmtName === 'json')
72
+ file = write(out, JSON.stringify({ classes: model.classes, edges: model.edges }, null, 2));
73
+ else {
74
+ const svg = renderSvg(model);
75
+ file = write(out, fmtName === 'png' ? toPng(svg) : svg);
76
+ }
77
+ return {
78
+ title: 'Class map',
79
+ output: file,
80
+ data: { classes: model.classes, edges: model.edges },
81
+ lines: [`${model.classes.length} types · ${model.edges.length} relations`, `→ ${file}`]
82
+ };
83
+ };
84
+ export const projectSummary = async (dir) => {
85
+ const { scanProject, roleStats } = await import('./scan.js');
86
+ const model = await scanProject(dir);
87
+ return { model, roles: roleStats(model) };
88
+ };
@@ -0,0 +1,46 @@
1
+ export type Lang = 'ts' | 'js' | 'php';
2
+ export interface Member {
3
+ name: string;
4
+ visibility: string;
5
+ static: boolean;
6
+ type?: string;
7
+ params?: string;
8
+ returns?: string;
9
+ }
10
+ export interface ClassInfo {
11
+ id: string;
12
+ name: string;
13
+ kind: 'class' | 'interface' | 'trait' | 'enum';
14
+ file: string;
15
+ lang: Lang;
16
+ extends?: string;
17
+ implements: string[];
18
+ traits: string[];
19
+ props: Member[];
20
+ methods: Member[];
21
+ }
22
+ export interface FileInfo {
23
+ path: string;
24
+ lang: Lang;
25
+ role: string;
26
+ lines: number;
27
+ classes: string[];
28
+ }
29
+ export interface Edge {
30
+ from: string;
31
+ to: string;
32
+ kind: 'extends' | 'implements' | 'uses';
33
+ }
34
+ export interface ProjectModel {
35
+ root: string;
36
+ files: FileInfo[];
37
+ classes: ClassInfo[];
38
+ edges: Edge[];
39
+ }
40
+ export interface TaskResult {
41
+ title: string;
42
+ lines: string[];
43
+ output?: string;
44
+ data?: unknown;
45
+ exitCode?: number;
46
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ {
2
+ "openapi": "3.1.0",
3
+ "info": {
4
+ "title": "dist",
5
+ "version": "1.0.0"
6
+ },
7
+ "paths": {}
8
+ }
@@ -0,0 +1,12 @@
1
+ export declare const theme: {
2
+ primary: string;
3
+ accent: string;
4
+ pink: string;
5
+ amber: string;
6
+ green: string;
7
+ red: string;
8
+ dim: string;
9
+ text: string;
10
+ };
11
+ export declare const gradient: string[];
12
+ export declare const roleColors: Record<string, string>;
package/dist/theme.js ADDED
@@ -0,0 +1,32 @@
1
+ export const theme = {
2
+ primary: '#7C5CFF',
3
+ accent: '#00E5C7',
4
+ pink: '#FF5CAA',
5
+ amber: '#FFB547',
6
+ green: '#4ADE80',
7
+ red: '#FF6B6B',
8
+ dim: '#6B7280',
9
+ text: '#E5E7EB'
10
+ };
11
+ export const gradient = ['#7C5CFF', '#FF5CAA', '#00E5C7'];
12
+ export const roleColors = {
13
+ controller: '#FF5CAA',
14
+ model: '#7C5CFF',
15
+ service: '#00E5C7',
16
+ repository: '#38BDF8',
17
+ middleware: '#FFB547',
18
+ dto: '#A3E635',
19
+ component: '#F472B6',
20
+ hook: '#C084FC',
21
+ route: '#FB923C',
22
+ config: '#94A3B8',
23
+ migration: '#FACC15',
24
+ test: '#4ADE80',
25
+ provider: '#22D3EE',
26
+ job: '#F87171',
27
+ command: '#E879F9',
28
+ contract: '#2DD4BF',
29
+ util: '#A1A1AA',
30
+ class: '#CBD5E1',
31
+ module: '#9CA3AF'
32
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { type BatiConfig } from '../core/config.js';
3
+ export declare const App: ({ config: initialConfig }: {
4
+ config: BatiConfig;
5
+ }) => React.JSX.Element;