agents-md-gen 0.3.0 → 0.4.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.
- package/README.md +2 -0
- package/package.json +4 -1
- package/src/detect.js +45 -0
- package/src/render.js +13 -0
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@ on immediately.
|
|
|
21
21
|
- **Go** — go.mod, golangci-lint
|
|
22
22
|
- **Ruby** — Bundler, RSpec
|
|
23
23
|
- **Java/Kotlin** — Maven, Gradle (with wrapper detection)
|
|
24
|
+
- **Monorepos** — Turborepo, Nx, Lerna, npm/yarn/pnpm workspaces, listing
|
|
25
|
+
each detected sub-package
|
|
24
26
|
- CI (GitHub Actions), license, and top-level project structure
|
|
25
27
|
|
|
26
28
|
## GitHub Action
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agents-md-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Generate a solid AGENTS.md / CLAUDE.md for any repo by detecting its stack, commands, and structure",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"java",
|
|
30
30
|
"maven",
|
|
31
31
|
"gradle",
|
|
32
|
+
"monorepo",
|
|
33
|
+
"turborepo",
|
|
34
|
+
"nx",
|
|
32
35
|
"cli",
|
|
33
36
|
"codegen",
|
|
34
37
|
"developer-tools"
|
package/src/detect.js
CHANGED
|
@@ -272,6 +272,50 @@ function detectLicense(root) {
|
|
|
272
272
|
return null;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
function detectMonorepo(root) {
|
|
276
|
+
const pkg = readJson(root, 'package.json');
|
|
277
|
+
const patterns = [];
|
|
278
|
+
|
|
279
|
+
if (pkg && Array.isArray(pkg.workspaces)) {
|
|
280
|
+
patterns.push(...pkg.workspaces);
|
|
281
|
+
} else if (pkg && pkg.workspaces && Array.isArray(pkg.workspaces.packages)) {
|
|
282
|
+
patterns.push(...pkg.workspaces.packages);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const pnpmWorkspace = readText(root, 'pnpm-workspace.yaml');
|
|
286
|
+
if (pnpmWorkspace) {
|
|
287
|
+
for (const m of pnpmWorkspace.matchAll(/^\s*-\s*['"]?([^'"\n]+)['"]?\s*$/gm)) {
|
|
288
|
+
patterns.push(m[1].trim());
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const tool = exists(root, 'turbo.json') ? 'Turborepo'
|
|
293
|
+
: exists(root, 'nx.json') ? 'Nx'
|
|
294
|
+
: exists(root, 'lerna.json') ? 'Lerna'
|
|
295
|
+
: patterns.length ? 'workspaces'
|
|
296
|
+
: null;
|
|
297
|
+
|
|
298
|
+
if (!tool) return null;
|
|
299
|
+
|
|
300
|
+
const packages = new Set();
|
|
301
|
+
for (const pattern of patterns) {
|
|
302
|
+
const dirPath = path.join(root, pattern.replace(/\/\*+$/, ''));
|
|
303
|
+
let entries;
|
|
304
|
+
try {
|
|
305
|
+
entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
306
|
+
} catch {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
for (const e of entries) {
|
|
310
|
+
if (!e.isDirectory()) continue;
|
|
311
|
+
const subPkg = readJson(dirPath, e.name, 'package.json');
|
|
312
|
+
if (subPkg) packages.add(subPkg.name || e.name);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return { tool, packages: [...packages].sort() };
|
|
317
|
+
}
|
|
318
|
+
|
|
275
319
|
function detectProject(root) {
|
|
276
320
|
const detectors = [detectNode, detectPython, detectRust, detectGo, detectRuby, detectJava];
|
|
277
321
|
const stacks = detectors.map((fn) => fn(root)).filter(Boolean);
|
|
@@ -279,6 +323,7 @@ function detectProject(root) {
|
|
|
279
323
|
return {
|
|
280
324
|
root,
|
|
281
325
|
stacks,
|
|
326
|
+
monorepo: detectMonorepo(root),
|
|
282
327
|
structure: listStructure(root),
|
|
283
328
|
ci: detectCI(root),
|
|
284
329
|
license: detectLicense(root),
|
package/src/render.js
CHANGED
|
@@ -51,6 +51,16 @@ function renderStack(stack) {
|
|
|
51
51
|
return parts.join('\n');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
function renderMonorepo(monorepo) {
|
|
55
|
+
if (!monorepo) return null;
|
|
56
|
+
const lines = [`This is a monorepo (${monorepo.tool}).`];
|
|
57
|
+
if (monorepo.packages.length) {
|
|
58
|
+
lines.push('', 'Packages:', '');
|
|
59
|
+
lines.push(...monorepo.packages.map((p) => `- \`${p}\``));
|
|
60
|
+
}
|
|
61
|
+
return ['## Monorepo', '', ...lines].join('\n');
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
function renderStructure(structure) {
|
|
55
65
|
if (!structure.length) return null;
|
|
56
66
|
const lines = structure.map((entry) => {
|
|
@@ -87,6 +97,9 @@ function renderAgentsMd(project) {
|
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
const monorepo = renderMonorepo(project.monorepo);
|
|
101
|
+
if (monorepo) sections.push('', monorepo);
|
|
102
|
+
|
|
90
103
|
const structure = renderStructure(project.structure);
|
|
91
104
|
if (structure) sections.push('', structure);
|
|
92
105
|
|