@db-ux/agent-cli 3.0.2-copilot-66b0168
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 +47 -0
- package/build/index.js +111 -0
- package/package.json +41 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @db-ux/agent-cli
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](https://conventionalcommits.org)
|
|
6
|
+
[](https://makeapullrequest.com)
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
We provide a cli tool to copy `@db-ux` docs to your repository to provide it for AI Agents.
|
|
11
|
+
Use this command in your repository:
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npx @db-ux/agent-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This will search for all `@db-ux` packages inside your `node_modules` and copy the documentation to your repository.
|
|
18
|
+
A new folder will be created named `_db-ux-docs`.
|
|
19
|
+
|
|
20
|
+
You might want to add this folder to your `.gitignore` file.
|
|
21
|
+
|
|
22
|
+
You can also change the root path where the tool should check for `node_modules`:
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
npx @db-ux/agent-cli packages/frontend
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Deutsche Bahn brand
|
|
29
|
+
|
|
30
|
+
As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even if being used with the code that we're providing with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license.
|
|
31
|
+
Please have a look at our brand portal at <https://marketingportal.extranet.deutschebahn.com/> for any further questions and whom to contact on any brand issues.
|
|
32
|
+
|
|
33
|
+
For any usage outside of Deutsche Bahn websites and applications you aren't allowed to use any Deutsche Bahn brand and
|
|
34
|
+
design assets as well as protected characteristics and trademarks, that for not including the DB Theme.
|
|
35
|
+
|
|
36
|
+
## Contributions
|
|
37
|
+
|
|
38
|
+
Contributions are very welcome, please refer to the [contribution guide](https://github.com/db-ux-design-system/core-web/blob/main/CONTRIBUTING.md).
|
|
39
|
+
|
|
40
|
+
## Code of conduct
|
|
41
|
+
|
|
42
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
43
|
+
community a harassment-free experience for everyone – have a look at our [Contributor Covenant Code of Conduct](https://github.com/db-ux-design-system/core-web/blob/main/CODE-OF-CONDUCT.md).
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
This project is licensed under [Apache-2.0](LICENSE).
|
package/build/index.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { program } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/copilot/index.ts
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
function findAllNodeModulesDirs(dir, found = []) {
|
|
10
|
+
if (!fs.existsSync(dir)) return found;
|
|
11
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
if (entry.isDirectory()) {
|
|
14
|
+
if (entry.name === "node_modules") {
|
|
15
|
+
found.push(path.join(dir, entry.name));
|
|
16
|
+
} else if (!entry.name.startsWith(".")) {
|
|
17
|
+
findAllNodeModulesDirs(path.join(dir, entry.name), found);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return found;
|
|
22
|
+
}
|
|
23
|
+
var generateCopilot = (rootPath) => {
|
|
24
|
+
const outputFolder = path.resolve(rootPath, ".github");
|
|
25
|
+
const nodeModulesDirs = findAllNodeModulesDirs(rootPath);
|
|
26
|
+
if (nodeModulesDirs.length === 0) {
|
|
27
|
+
console.error("No node_modules folders found.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let copilotInstructionsContent = "";
|
|
31
|
+
for (const nodeModulesPath of nodeModulesDirs) {
|
|
32
|
+
const dbUxPath = path.join(nodeModulesPath, "@db-ux");
|
|
33
|
+
if (!fs.existsSync(dbUxPath)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const packages = fs.readdirSync(dbUxPath, { withFileTypes: true });
|
|
37
|
+
for (const pkg of packages) {
|
|
38
|
+
if (pkg.isDirectory()) {
|
|
39
|
+
const instructionsPath = path.join(
|
|
40
|
+
dbUxPath,
|
|
41
|
+
pkg.name,
|
|
42
|
+
"agent",
|
|
43
|
+
"_instructions.md"
|
|
44
|
+
);
|
|
45
|
+
if (fs.existsSync(instructionsPath)) {
|
|
46
|
+
let content = fs.readFileSync(instructionsPath, "utf-8");
|
|
47
|
+
const relPath = path.relative(
|
|
48
|
+
rootPath,
|
|
49
|
+
path.join(dbUxPath, pkg.name)
|
|
50
|
+
);
|
|
51
|
+
content = content.replace(
|
|
52
|
+
/__agent-path__/g,
|
|
53
|
+
relPath.replace(/\\/g, "/")
|
|
54
|
+
);
|
|
55
|
+
copilotInstructionsContent += `
|
|
56
|
+
# @db-ux/${pkg.name}
|
|
57
|
+
${content}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!fs.existsSync(outputFolder)) {
|
|
64
|
+
fs.mkdirSync(outputFolder);
|
|
65
|
+
}
|
|
66
|
+
const copilotInstructionsPath = path.join(
|
|
67
|
+
outputFolder,
|
|
68
|
+
"copilot-instructions.md"
|
|
69
|
+
);
|
|
70
|
+
if (!fs.existsSync(copilotInstructionsPath)) {
|
|
71
|
+
fs.writeFileSync(copilotInstructionsPath, "");
|
|
72
|
+
}
|
|
73
|
+
if (copilotInstructionsContent.trim()) {
|
|
74
|
+
let copilotFileContent = fs.readFileSync(
|
|
75
|
+
copilotInstructionsPath,
|
|
76
|
+
"utf-8"
|
|
77
|
+
);
|
|
78
|
+
const startMarker = "--- START: DB UX Copilot Instructions ---";
|
|
79
|
+
const endMarker = "--- END: DB UX Copilot Instructions ---";
|
|
80
|
+
const startIdx = copilotFileContent.indexOf(startMarker);
|
|
81
|
+
const endIdx = copilotFileContent.indexOf(endMarker);
|
|
82
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
83
|
+
copilotFileContent = (copilotFileContent.slice(0, startIdx) + copilotFileContent.slice(endIdx + endMarker.length)).trim();
|
|
84
|
+
}
|
|
85
|
+
copilotFileContent += `
|
|
86
|
+
${startMarker}
|
|
87
|
+
${copilotInstructionsContent}
|
|
88
|
+
${endMarker}
|
|
89
|
+
`;
|
|
90
|
+
fs.writeFileSync(copilotInstructionsPath, copilotFileContent);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/cli.ts
|
|
95
|
+
var action = async (rootPath = ".") => {
|
|
96
|
+
generateCopilot(rootPath);
|
|
97
|
+
};
|
|
98
|
+
var startProgram = (name, description, action2) => {
|
|
99
|
+
program.name(name).description(description);
|
|
100
|
+
program.argument(
|
|
101
|
+
"[root]",
|
|
102
|
+
"Root path to generate AI agent instructions. Default: `.`"
|
|
103
|
+
);
|
|
104
|
+
program.action(action2);
|
|
105
|
+
program.parse();
|
|
106
|
+
};
|
|
107
|
+
startProgram(
|
|
108
|
+
"@db-ux/agent-cli",
|
|
109
|
+
"CLI for DB UX Design System generate AI agent instructions",
|
|
110
|
+
action
|
|
111
|
+
);
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@db-ux/agent-cli",
|
|
3
|
+
"version": "3.0.2-copilot-66b0168",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI for DB UX Design System generate AI agent instructions",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/db-ux-design-system/core-web.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"bin": {
|
|
12
|
+
"@db-uxagent-cli": "build/index.js"
|
|
13
|
+
},
|
|
14
|
+
"main": "build.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"build"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "node esbuild.js",
|
|
20
|
+
"copy-build": "npm-run-all copy-build:*",
|
|
21
|
+
"copy-build:build": "cpr build ../../build-outputs/agent-cli/build -o",
|
|
22
|
+
"copy-build:package.json": "cpr package.json ../../build-outputs/agent-cli/package.json -o",
|
|
23
|
+
"copy-build:readme": "cpr README.md ../../build-outputs/agent-cli/README.md -o",
|
|
24
|
+
"test": "vitest run --config vitest.config.ts",
|
|
25
|
+
"test:cli": "tsx src/cli.ts --help"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"commander": "^14.0.0",
|
|
29
|
+
"glob": "^11.0.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"cpr": "3.0.1",
|
|
33
|
+
"esbuild": "0.25.5",
|
|
34
|
+
"tsx": "^4.19.4",
|
|
35
|
+
"vitest": "^3.2.1"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"registry": "https://registry.npmjs.org/",
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|