@db-ux/agent-cli 3.0.2-copilot-66b0168 → 3.0.2-copilot3-1616965
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 +1 -4
- package/build/index.js +54 -39
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -14,10 +14,7 @@ Use this command in your repository:
|
|
|
14
14
|
npx @db-ux/agent-cli
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
A new folder will be created named `_db-ux-docs`.
|
|
19
|
-
|
|
20
|
-
You might want to add this folder to your `.gitignore` file.
|
|
17
|
+
The DB UX Design System docs will get appended (or replaced in subsequent runs, e.g. after a DB UX Design System update) within the file `.github/copilot-instructions.md` (if the file doesn't exist in your codebase so far, it gets created).
|
|
21
18
|
|
|
22
19
|
You can also change the root path where the tool should check for `node_modules`:
|
|
23
20
|
|
package/build/index.js
CHANGED
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
import { program } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/copilot/index.ts
|
|
7
|
-
import fs from "fs";
|
|
8
|
-
import path from "path";
|
|
9
|
-
function
|
|
10
|
-
if (!fs.existsSync(
|
|
11
|
-
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
function findAllNodeModulesDirectories(directory, found = []) {
|
|
10
|
+
if (!fs.existsSync(directory)) {
|
|
11
|
+
return found;
|
|
12
|
+
}
|
|
13
|
+
const entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
12
14
|
for (const entry of entries) {
|
|
13
15
|
if (entry.isDirectory()) {
|
|
14
16
|
if (entry.name === "node_modules") {
|
|
15
|
-
found.push(path.join(
|
|
17
|
+
found.push(path.join(directory, entry.name));
|
|
16
18
|
} else if (!entry.name.startsWith(".")) {
|
|
17
|
-
|
|
19
|
+
findAllNodeModulesDirectories(
|
|
20
|
+
path.join(directory, entry.name),
|
|
21
|
+
found
|
|
22
|
+
);
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
}
|
|
@@ -22,40 +27,50 @@ function findAllNodeModulesDirs(dir, found = []) {
|
|
|
22
27
|
}
|
|
23
28
|
var generateCopilot = (rootPath) => {
|
|
24
29
|
const outputFolder = path.resolve(rootPath, ".github");
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
30
|
+
const nodeModulesDirectories = findAllNodeModulesDirectories(rootPath);
|
|
31
|
+
if (nodeModulesDirectories.length === 0) {
|
|
27
32
|
console.error("No node_modules folders found.");
|
|
28
33
|
return;
|
|
29
34
|
}
|
|
30
35
|
let copilotInstructionsContent = "";
|
|
31
|
-
for (const nodeModulesPath of
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
content = content.replace(
|
|
52
|
-
/__agent-path__/g,
|
|
53
|
-
relPath.replace(/\\/g, "/")
|
|
36
|
+
for (const nodeModulesPath of nodeModulesDirectories) {
|
|
37
|
+
const databaseUxPaths = [
|
|
38
|
+
path.join(nodeModulesPath, "@db-ux"),
|
|
39
|
+
path.join(nodeModulesPath, "@db-ux-inner-source")
|
|
40
|
+
];
|
|
41
|
+
for (const databaseUxPath of databaseUxPaths) {
|
|
42
|
+
if (!fs.existsSync(databaseUxPath)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const packages = fs.readdirSync(databaseUxPath, {
|
|
46
|
+
withFileTypes: true
|
|
47
|
+
});
|
|
48
|
+
for (const package_ of packages) {
|
|
49
|
+
if (package_.isDirectory()) {
|
|
50
|
+
const instructionsPath = path.join(
|
|
51
|
+
databaseUxPath,
|
|
52
|
+
package_.name,
|
|
53
|
+
"agent",
|
|
54
|
+
"_instructions.md"
|
|
54
55
|
);
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
if (fs.existsSync(instructionsPath)) {
|
|
57
|
+
let content = fs.readFileSync(instructionsPath, "utf8");
|
|
58
|
+
const relativePath = path.relative(
|
|
59
|
+
rootPath,
|
|
60
|
+
path.join(databaseUxPath, package_.name)
|
|
61
|
+
);
|
|
62
|
+
content = content.replaceAll(
|
|
63
|
+
"__agent-path__",
|
|
64
|
+
relativePath.replaceAll("\\", "/")
|
|
65
|
+
).replaceAll(
|
|
66
|
+
"**agent-path**",
|
|
67
|
+
relativePath.replaceAll("\\", "/")
|
|
68
|
+
);
|
|
69
|
+
copilotInstructionsContent += `
|
|
70
|
+
# ${path.basename(databaseUxPath)}/${package_.name}
|
|
57
71
|
${content}
|
|
58
72
|
`;
|
|
73
|
+
}
|
|
59
74
|
}
|
|
60
75
|
}
|
|
61
76
|
}
|
|
@@ -73,14 +88,14 @@ ${content}
|
|
|
73
88
|
if (copilotInstructionsContent.trim()) {
|
|
74
89
|
let copilotFileContent = fs.readFileSync(
|
|
75
90
|
copilotInstructionsPath,
|
|
76
|
-
"
|
|
91
|
+
"utf8"
|
|
77
92
|
);
|
|
78
93
|
const startMarker = "--- START: DB UX Copilot Instructions ---";
|
|
79
94
|
const endMarker = "--- END: DB UX Copilot Instructions ---";
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
copilotFileContent = (copilotFileContent.slice(0,
|
|
95
|
+
const startIndex = copilotFileContent.indexOf(startMarker);
|
|
96
|
+
const endIndex = copilotFileContent.indexOf(endMarker);
|
|
97
|
+
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
|
|
98
|
+
copilotFileContent = (copilotFileContent.slice(0, startIndex) + copilotFileContent.slice(endIndex + endMarker.length)).trim();
|
|
84
99
|
}
|
|
85
100
|
copilotFileContent += `
|
|
86
101
|
${startMarker}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@db-ux/agent-cli",
|
|
3
|
-
"version": "3.0.2-
|
|
3
|
+
"version": "3.0.2-copilot3-1616965",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for DB UX Design System generate AI agent instructions",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"bin": {
|
|
12
|
-
"@db-
|
|
12
|
+
"@db-ux/agent-cli": "build/index.js"
|
|
13
13
|
},
|
|
14
14
|
"main": "build.js",
|
|
15
15
|
"files": [
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"test:cli": "tsx src/cli.ts --help"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"commander": "
|
|
29
|
-
"glob": "
|
|
28
|
+
"commander": "14.0.0",
|
|
29
|
+
"glob": "11.0.3"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"cpr": "3.0.1",
|
|
33
33
|
"esbuild": "0.25.5",
|
|
34
|
-
"tsx": "
|
|
35
|
-
"vitest": "
|
|
34
|
+
"tsx": "4.19.4",
|
|
35
|
+
"vitest": "3.2.4"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"registry": "https://registry.npmjs.org/",
|