@db-ux/agent-cli 4.0.1 → 4.0.3

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/CHANGELOG.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # @db-ux/agent-cli
2
2
 
3
+ ## 4.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: generate AmazonQ rule file with @db-ux/agent-cli - [see commit b61c8b1](https://github.com/db-ux-design-system/core-web/commit/b61c8b14992f5a5b3615c6bff74018d5682aa0cc)
8
+
9
+ ## 4.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - chore: update instructions files for better copilot outputs - [see commit 797a114](https://github.com/db-ux-design-system/core-web/commit/797a114d7abc680667276f8ffc2f7f4482d89d3e):
14
+ - fix: add some missing variables
15
+
3
16
  ## 4.0.1
4
17
 
5
18
  _version bump_
6
19
 
7
-
8
20
  ## 4.0.0
9
21
 
10
22
  _version bump_
package/build/index.js CHANGED
@@ -3,7 +3,15 @@
3
3
  // src/cli.ts
4
4
  import { program } from "commander";
5
5
 
6
- // src/copilot/index.ts
6
+ // src/index.ts
7
+ import fs4 from "node:fs";
8
+ import path4 from "node:path";
9
+
10
+ // src/amazonq/index.ts
11
+ import fs2 from "node:fs";
12
+ import path2 from "node:path";
13
+
14
+ // src/utils/index.ts
7
15
  import fs from "node:fs";
8
16
  import path from "node:path";
9
17
  function findAllNodeModulesDirectories(directory, found = []) {
@@ -25,14 +33,13 @@ function findAllNodeModulesDirectories(directory, found = []) {
25
33
  }
26
34
  return found;
27
35
  }
28
- var generateCopilot = (rootPath) => {
29
- const outputFolder = path.resolve(rootPath, ".github");
36
+ var getInstructions = (rootPath) => {
37
+ let copilotInstructionsContent = "";
30
38
  const nodeModulesDirectories = findAllNodeModulesDirectories(rootPath);
31
39
  if (nodeModulesDirectories.length === 0) {
32
40
  console.error("No node_modules folders found.");
33
- return;
41
+ return "";
34
42
  }
35
- let copilotInstructionsContent = "";
36
43
  for (const nodeModulesPath of nodeModulesDirectories) {
37
44
  const databaseUxPaths = [
38
45
  path.join(nodeModulesPath, "@db-ux/"),
@@ -75,18 +82,63 @@ ${content}
75
82
  }
76
83
  }
77
84
  }
78
- if (!fs.existsSync(outputFolder)) {
79
- fs.mkdirSync(outputFolder);
85
+ copilotInstructionsContent = copilotInstructionsContent.trim();
86
+ return copilotInstructionsContent;
87
+ };
88
+
89
+ // src/amazonq/index.ts
90
+ var generateAmazonQ = (rootPath) => {
91
+ const outputFolder = path2.resolve(rootPath, ".amazonq", "rules");
92
+ if (!fs2.existsSync(outputFolder)) {
93
+ fs2.mkdirSync(outputFolder, { recursive: true });
94
+ }
95
+ const amazonqInstructionsPath = path2.join(outputFolder, "db-ux.md");
96
+ if (!fs2.existsSync(amazonqInstructionsPath)) {
97
+ fs2.writeFileSync(amazonqInstructionsPath, "");
98
+ }
99
+ const amazonqInstructionsContent = getInstructions(rootPath);
100
+ if (amazonqInstructionsContent) {
101
+ let amazonqFileContent = fs2.readFileSync(
102
+ amazonqInstructionsPath,
103
+ "utf8"
104
+ );
105
+ const startMarker = "--- START: DB UX Amazon Q Instructions \u2013 do not edit below ---";
106
+ const endMarker = "--- END: DB UX Amazon Q Instructions \u2013 do not edit above ---";
107
+ const startIndex = amazonqFileContent.indexOf(startMarker);
108
+ const endIndex = amazonqFileContent.indexOf(endMarker);
109
+ if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
110
+ amazonqFileContent = (amazonqFileContent.slice(0, startIndex) + amazonqFileContent.slice(endIndex + endMarker.length)).trim();
111
+ }
112
+ amazonqFileContent += `
113
+ ${startMarker}
114
+
115
+ > **NOTE**: Always use "DB UX" components and variables as project's conventions
116
+ ${amazonqInstructionsContent}
117
+
118
+ ${endMarker}
119
+ `;
120
+ fs2.writeFileSync(amazonqInstructionsPath, amazonqFileContent);
121
+ }
122
+ };
123
+
124
+ // src/copilot/index.ts
125
+ import fs3 from "node:fs";
126
+ import path3 from "node:path";
127
+ var generateCopilot = (rootPath) => {
128
+ const outputFolder = path3.resolve(rootPath, ".github");
129
+ if (!fs3.existsSync(outputFolder)) {
130
+ fs3.mkdirSync(outputFolder, { recursive: true });
80
131
  }
81
- const copilotInstructionsPath = path.join(
132
+ const copilotInstructionsPath = path3.join(
82
133
  outputFolder,
83
134
  "copilot-instructions.md"
84
135
  );
85
- if (!fs.existsSync(copilotInstructionsPath)) {
86
- fs.writeFileSync(copilotInstructionsPath, "");
136
+ if (!fs3.existsSync(copilotInstructionsPath)) {
137
+ fs3.writeFileSync(copilotInstructionsPath, "");
87
138
  }
88
- if (copilotInstructionsContent.trim()) {
89
- let copilotFileContent = fs.readFileSync(
139
+ const copilotInstructionsContent = getInstructions(rootPath);
140
+ if (copilotInstructionsContent) {
141
+ let copilotFileContent = fs3.readFileSync(
90
142
  copilotInstructionsPath,
91
143
  "utf8"
92
144
  );
@@ -99,17 +151,36 @@ ${content}
99
151
  }
100
152
  copilotFileContent += `
101
153
  ${startMarker}
154
+
155
+ > **NOTE**: Always use "DB UX" components and variables as project's conventions
102
156
  ${copilotInstructionsContent}
157
+
103
158
  ${endMarker}
104
- `;
105
- fs.writeFileSync(copilotInstructionsPath, copilotFileContent);
159
+ `;
160
+ fs3.writeFileSync(copilotInstructionsPath, copilotFileContent);
106
161
  }
107
162
  };
108
163
 
109
- // src/cli.ts
164
+ // src/index.ts
110
165
  var action = async (rootPath = ".") => {
111
- generateCopilot(rootPath);
166
+ const hasCopilot = fs4.existsSync(
167
+ path4.join(rootPath, ".github", "copilot-instructions.md")
168
+ );
169
+ const hasAmazonQ = fs4.existsSync(path4.join(rootPath, ".amazonq", "rules"));
170
+ if (!hasCopilot && !hasAmazonQ) {
171
+ generateCopilot(rootPath);
172
+ generateAmazonQ(rootPath);
173
+ } else if (hasCopilot && hasAmazonQ) {
174
+ generateCopilot(rootPath);
175
+ generateAmazonQ(rootPath);
176
+ } else if (hasCopilot) {
177
+ generateCopilot(rootPath);
178
+ } else {
179
+ generateAmazonQ(rootPath);
180
+ }
112
181
  };
182
+
183
+ // src/cli.ts
113
184
  var startProgram = (name, description, action2) => {
114
185
  program.name(name).description(description);
115
186
  program.argument(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/agent-cli",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "type": "module",
5
5
  "description": "CLI for DB UX Design System generate AI agent instructions",
6
6
  "repository": {
@@ -24,14 +24,15 @@
24
24
  "copy-build:package.json": "cpr package.json ../../build-outputs/agent-cli/package.json --overwrite",
25
25
  "copy-build:readme": "cpr README.md ../../build-outputs/agent-cli/README.md --overwrite",
26
26
  "test": "vitest run --config vitest.config.ts",
27
- "test:cli": "tsx src/cli.ts --help"
27
+ "test:cli": "tsx src/cli.ts --help",
28
+ "test:update": "vitest run --config vitest.config.ts --update"
28
29
  },
29
30
  "dependencies": {
30
31
  "commander": "14.0.1"
31
32
  },
32
33
  "devDependencies": {
33
34
  "cpr": "3.0.1",
34
- "esbuild": "0.25.10",
35
+ "esbuild": "0.25.11",
35
36
  "tsx": "4.20.6",
36
37
  "vitest": "3.2.4"
37
38
  },