@db-ux/agent-cli 4.12.0 → 4.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @db-ux/agent-cli
2
2
 
3
+ ## 4.13.0
4
+
5
+ _version bump_
6
+
7
+ ## 4.12.1
8
+
9
+ _version bump_
10
+
3
11
  ## 4.12.0
4
12
 
5
13
  _version bump_
package/build/index.js CHANGED
@@ -4,33 +4,41 @@
4
4
  import { program } from "commander";
5
5
 
6
6
  // src/index.ts
7
- import fs4 from "node:fs";
8
- import path4 from "node:path";
7
+ import { existsSync as existsSync4 } from "node:fs";
8
+ import { join as join4 } from "node:path";
9
9
 
10
10
  // src/amazonq/index.ts
11
- import fs2 from "node:fs";
12
- import path2 from "node:path";
11
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
12
+ import { join as join2, resolve as resolve2 } from "node:path";
13
13
 
14
14
  // src/utils/index.ts
15
- import fs from "node:fs";
16
- import path from "node:path";
15
+ import {
16
+ existsSync,
17
+ readdirSync,
18
+ readFileSync,
19
+ realpathSync,
20
+ statSync
21
+ } from "node:fs";
22
+ import { basename, dirname, join, relative, resolve } from "node:path";
17
23
  function findAllNodeModulesDirectories(directory, found = /* @__PURE__ */ new Set()) {
18
- if (!fs.existsSync(directory)) {
24
+ if (!existsSync(directory)) {
19
25
  return found;
20
26
  }
21
- const entries = fs.readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name, "en"));
27
+ const entries = readdirSync(directory, { withFileTypes: true }).sort(
28
+ (a, b) => a.name.localeCompare(b.name, "en")
29
+ );
22
30
  for (const entry of entries) {
23
- const fullPath = path.resolve(directory, entry.name);
31
+ const fullPath = resolve(directory, entry.name);
24
32
  let isDirectory = false;
25
33
  try {
26
- const stats = fs.statSync(fullPath);
34
+ const stats = statSync(fullPath);
27
35
  isDirectory = stats.isDirectory();
28
36
  } catch {
29
37
  continue;
30
38
  }
31
39
  if (isDirectory) {
32
40
  if (entry.name === "node_modules") {
33
- found.add(fs.realpathSync(fullPath));
41
+ found.add(realpathSync(fullPath));
34
42
  } else if (!entry.name.startsWith(".")) {
35
43
  findAllNodeModulesDirectories(fullPath, found);
36
44
  }
@@ -46,24 +54,28 @@ var getInstructions = (rootPath) => {
46
54
  }
47
55
  let powersPath = "";
48
56
  for (const nodeModulesPath of nodeModulesDirectories) {
49
- const agentCliPowersPath = path.join(
57
+ const agentCliPowersPath = join(
50
58
  nodeModulesPath,
51
59
  "@db-ux",
52
60
  "agent-cli",
53
61
  "db-ux-consumer-powers"
54
62
  );
55
- if (fs.existsSync(agentCliPowersPath)) {
56
- powersPath = path.relative(rootPath, agentCliPowersPath).replaceAll("\\", "/");
63
+ if (existsSync(agentCliPowersPath)) {
64
+ powersPath = relative(rootPath, agentCliPowersPath).replaceAll(
65
+ "\\",
66
+ "/"
67
+ );
57
68
  break;
58
69
  }
59
70
  }
60
71
  if (!powersPath) {
61
- const packageDir = path.dirname(
62
- path.dirname(new URL(import.meta.url).pathname)
63
- );
64
- const localPowersPath = path.join(packageDir, "db-ux-consumer-powers");
65
- if (fs.existsSync(localPowersPath)) {
66
- powersPath = path.relative(rootPath, localPowersPath).replaceAll("\\", "/");
72
+ const packageDir = dirname(dirname(new URL(import.meta.url).pathname));
73
+ const localPowersPath = join(packageDir, "db-ux-consumer-powers");
74
+ if (existsSync(localPowersPath)) {
75
+ powersPath = relative(rootPath, localPowersPath).replaceAll(
76
+ "\\",
77
+ "/"
78
+ );
67
79
  }
68
80
  }
69
81
  let copilotInstructionsContent = `# DB UX Design System Automation Core
@@ -78,30 +90,33 @@ ${powersPath ? `
78
90
  `;
79
91
  for (const nodeModulesPath of nodeModulesDirectories) {
80
92
  const databaseUxPaths = [
81
- path.join(nodeModulesPath, "@db-ux/"),
82
- path.join(nodeModulesPath, "@db-ux-inner-source/")
93
+ join(nodeModulesPath, "@db-ux/"),
94
+ join(nodeModulesPath, "@db-ux-inner-source/")
83
95
  ];
84
96
  for (const databaseUxPath of databaseUxPaths) {
85
- if (!fs.existsSync(databaseUxPath)) {
97
+ if (!existsSync(databaseUxPath)) {
86
98
  continue;
87
99
  }
88
- const packages = fs.readdirSync(databaseUxPath, {
100
+ const packages = readdirSync(databaseUxPath, {
89
101
  withFileTypes: true
90
102
  });
91
103
  for (const package_ of packages) {
92
- let packagePath = path.resolve(databaseUxPath, package_.name);
104
+ let packagePath = resolve(databaseUxPath, package_.name);
93
105
  let isDirectory = false;
94
106
  try {
95
- const stats = fs.statSync(packagePath);
107
+ const stats = statSync(packagePath);
96
108
  isDirectory = stats.isDirectory();
97
109
  if (!isDirectory && stats.isFile()) {
98
- const content = fs.readFileSync(packagePath, "utf8").trim();
110
+ const content = readFileSync(
111
+ packagePath,
112
+ "utf8"
113
+ ).trim();
99
114
  if (!content.includes("\n")) {
100
- const targetPath = path.resolve(
101
- path.dirname(packagePath),
115
+ const targetPath = resolve(
116
+ dirname(packagePath),
102
117
  content
103
118
  );
104
- if (fs.existsSync(targetPath) && fs.statSync(targetPath).isDirectory()) {
119
+ if (existsSync(targetPath) && statSync(targetPath).isDirectory()) {
105
120
  isDirectory = true;
106
121
  packagePath = targetPath;
107
122
  }
@@ -111,17 +126,14 @@ ${powersPath ? `
111
126
  continue;
112
127
  }
113
128
  if (isDirectory) {
114
- const instructionsPath = path.join(
129
+ const instructionsPath = join(
115
130
  packagePath,
116
131
  "agent",
117
132
  "_instructions.md"
118
133
  );
119
- if (fs.existsSync(instructionsPath)) {
120
- let content = fs.readFileSync(instructionsPath, "utf8");
121
- const relativePath = path.relative(
122
- rootPath,
123
- packagePath
124
- );
134
+ if (existsSync(instructionsPath)) {
135
+ let content = readFileSync(instructionsPath, "utf8");
136
+ const relativePath = relative(rootPath, packagePath);
125
137
  content = content.replaceAll(
126
138
  "__agent-path__",
127
139
  relativePath.replaceAll("\\", "/")
@@ -130,7 +142,7 @@ ${powersPath ? `
130
142
  relativePath.replaceAll("\\", "/")
131
143
  );
132
144
  copilotInstructionsContent += `
133
- # ${path.basename(databaseUxPath)}/${package_.name}
145
+ # ${basename(databaseUxPath)}/${package_.name}
134
146
  ${content}
135
147
  `;
136
148
  }
@@ -144,20 +156,17 @@ ${content}
144
156
 
145
157
  // src/amazonq/index.ts
146
158
  var generateAmazonQ = (rootPath) => {
147
- const outputFolder = path2.resolve(rootPath, ".amazonq", "rules");
148
- if (!fs2.existsSync(outputFolder)) {
149
- fs2.mkdirSync(outputFolder, { recursive: true });
159
+ const outputFolder = resolve2(rootPath, ".amazonq", "rules");
160
+ if (!existsSync2(outputFolder)) {
161
+ mkdirSync(outputFolder, { recursive: true });
150
162
  }
151
- const amazonqInstructionsPath = path2.join(outputFolder, "db-ux.md");
152
- if (!fs2.existsSync(amazonqInstructionsPath)) {
153
- fs2.writeFileSync(amazonqInstructionsPath, "");
163
+ const amazonqInstructionsPath = join2(outputFolder, "db-ux.md");
164
+ if (!existsSync2(amazonqInstructionsPath)) {
165
+ writeFileSync(amazonqInstructionsPath, "");
154
166
  }
155
167
  const amazonqInstructionsContent = getInstructions(rootPath);
156
- if (amazonqInstructionsContent) {
157
- let amazonqFileContent = fs2.readFileSync(
158
- amazonqInstructionsPath,
159
- "utf8"
160
- );
168
+ if (amazonqInstructionsContent !== "") {
169
+ let amazonqFileContent = readFileSync2(amazonqInstructionsPath, "utf8");
161
170
  const startMarker = "--- START: DB UX Amazon Q Instructions \u2013 do not edit below ---";
162
171
  const endMarker = "--- END: DB UX Amazon Q Instructions \u2013 do not edit above ---";
163
172
  const startIndex = amazonqFileContent.indexOf(startMarker);
@@ -173,31 +182,28 @@ ${amazonqInstructionsContent}
173
182
 
174
183
  ${endMarker}
175
184
  `;
176
- fs2.writeFileSync(amazonqInstructionsPath, amazonqFileContent);
185
+ writeFileSync(amazonqInstructionsPath, amazonqFileContent);
177
186
  }
178
187
  };
179
188
 
180
189
  // src/copilot/index.ts
181
- import fs3 from "node:fs";
182
- import path3 from "node:path";
190
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
191
+ import { join as join3, resolve as resolve3 } from "node:path";
183
192
  var generateCopilot = (rootPath) => {
184
- const outputFolder = path3.resolve(rootPath, ".github");
185
- if (!fs3.existsSync(outputFolder)) {
186
- fs3.mkdirSync(outputFolder, { recursive: true });
193
+ const outputFolder = resolve3(rootPath, ".github");
194
+ if (!existsSync3(outputFolder)) {
195
+ mkdirSync2(outputFolder, { recursive: true });
187
196
  }
188
- const copilotInstructionsPath = path3.join(
197
+ const copilotInstructionsPath = join3(
189
198
  outputFolder,
190
199
  "copilot-instructions.md"
191
200
  );
192
- if (!fs3.existsSync(copilotInstructionsPath)) {
193
- fs3.writeFileSync(copilotInstructionsPath, "");
201
+ if (!existsSync3(copilotInstructionsPath)) {
202
+ writeFileSync2(copilotInstructionsPath, "");
194
203
  }
195
204
  const copilotInstructionsContent = getInstructions(rootPath);
196
- if (copilotInstructionsContent) {
197
- let copilotFileContent = fs3.readFileSync(
198
- copilotInstructionsPath,
199
- "utf8"
200
- );
205
+ if (copilotInstructionsContent !== "") {
206
+ let copilotFileContent = readFileSync3(copilotInstructionsPath, "utf8");
201
207
  const startMarker = "--- START: DB UX Copilot Instructions \u2013 do not edit below ---";
202
208
  const endMarker = "--- END: DB UX Copilot Instructions \u2013 do not edit above ---";
203
209
  const startIndex = copilotFileContent.indexOf(startMarker);
@@ -213,16 +219,16 @@ ${copilotInstructionsContent}
213
219
 
214
220
  ${endMarker}
215
221
  `;
216
- fs3.writeFileSync(copilotInstructionsPath, copilotFileContent);
222
+ writeFileSync2(copilotInstructionsPath, copilotFileContent);
217
223
  }
218
224
  };
219
225
 
220
226
  // src/index.ts
221
227
  var action = async (rootPath = ".") => {
222
- const hasCopilot = fs4.existsSync(
223
- path4.join(rootPath, ".github", "copilot-instructions.md")
228
+ const hasCopilot = existsSync4(
229
+ join4(rootPath, ".github", "copilot-instructions.md")
224
230
  );
225
- const hasAmazonQ = fs4.existsSync(path4.join(rootPath, ".amazonq", "rules"));
231
+ const hasAmazonQ = existsSync4(join4(rootPath, ".amazonq", "rules"));
226
232
  if (!hasCopilot && !hasAmazonQ) {
227
233
  generateCopilot(rootPath);
228
234
  generateAmazonQ(rootPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@db-ux/agent-cli",
3
- "version": "4.12.0",
3
+ "version": "4.13.0",
4
4
  "type": "module",
5
5
  "description": "CLI for DB UX Design System generate AI agent instructions",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "esbuild": "0.28.1",
26
26
  "npm-run-all2": "9.0.2",
27
27
  "tsx": "4.22.4",
28
- "vitest": "4.1.8"
28
+ "vitest": "4.1.9"
29
29
  },
30
30
  "publishConfig": {
31
31
  "registry": "https://registry.npmjs.org/",