@db-ux/agent-cli 4.0.2 → 4.0.4

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,21 @@
1
1
  # @db-ux/agent-cli
2
2
 
3
+ ## 4.0.4
4
+
5
+ _version bump_
6
+
7
+
8
+ ## 4.0.3
9
+
10
+ ### Patch Changes
11
+
12
+ - chore: generate Amazon Q rule file with @db-ux/agent-cli - [see commit b61c8b1](https://github.com/db-ux-design-system/core-web/commit/b61c8b14992f5a5b3615c6bff74018d5682aa0cc)
13
+
3
14
  ## 4.0.2
4
15
 
5
16
  ### Patch Changes
6
17
 
7
- - chore: update instructions files for better copilot outputs - [see commit 797a114](https://github.com/db-ux-design-system/core-web/commit/797a114d7abc680667276f8ffc2f7f4482d89d3e):
18
+ - chore: update instructions files for better copilot outputs - [see commit e4bc905](https://github.com/db-ux-design-system/core-web/commit/e4bc90508479387371d816d5776f9f568aa5fb82):
8
19
  - fix: add some missing variables
9
20
 
10
21
  ## 4.0.1
package/README.md CHANGED
@@ -38,7 +38,7 @@ This is useful in monorepo setups where your DB UX packages might be installed i
38
38
 
39
39
  ### Best practices
40
40
 
41
- We've had the best experience with GitHub Copilot when using the following settings:
41
+ We've had the best experience with GitHub Copilot and Amazon Q when using the following settings:
42
42
 
43
43
  - Agent mode works best for code generation and may also offer the best developer experience.
44
44
  - Regarding the provided models, GPT-4o seemed to strike the best balance between "used tokens" and performance, although "Claude Sonnet 4" is still better. However, you run out of tokens quite quickly with this model.
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 });
80
94
  }
81
- const copilotInstructionsPath = path.join(
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 });
131
+ }
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
  );
@@ -98,19 +150,37 @@ ${content}
98
150
  copilotFileContent = (copilotFileContent.slice(0, startIndex) + copilotFileContent.slice(endIndex + endMarker.length)).trim();
99
151
  }
100
152
  copilotFileContent += `
101
- ${startMarker}
102
- > **NOTE**: Always use "DB UX" components and variables as project's conventions
103
- ${copilotInstructionsContent}
104
- ${endMarker}
153
+ ${startMarker}
154
+
155
+ > **NOTE**: Always use "DB UX" components and variables as project's conventions
156
+ ${copilotInstructionsContent}
157
+
158
+ ${endMarker}
105
159
  `;
106
- fs.writeFileSync(copilotInstructionsPath, copilotFileContent);
160
+ fs3.writeFileSync(copilotInstructionsPath, copilotFileContent);
107
161
  }
108
162
  };
109
163
 
110
- // src/cli.ts
164
+ // src/index.ts
111
165
  var action = async (rootPath = ".") => {
112
- 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
+ }
113
181
  };
182
+
183
+ // src/cli.ts
114
184
  var startProgram = (name, description, action2) => {
115
185
  program.name(name).description(description);
116
186
  program.argument(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/agent-cli",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
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
  },