@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 +8 -0
- package/build/index.js +73 -67
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/build/index.js
CHANGED
|
@@ -4,33 +4,41 @@
|
|
|
4
4
|
import { program } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
|
|
12
|
-
import
|
|
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
|
|
16
|
-
|
|
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 (!
|
|
24
|
+
if (!existsSync(directory)) {
|
|
19
25
|
return found;
|
|
20
26
|
}
|
|
21
|
-
const entries =
|
|
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 =
|
|
31
|
+
const fullPath = resolve(directory, entry.name);
|
|
24
32
|
let isDirectory = false;
|
|
25
33
|
try {
|
|
26
|
-
const stats =
|
|
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(
|
|
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 =
|
|
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 (
|
|
56
|
-
powersPath =
|
|
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 =
|
|
62
|
-
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
82
|
-
|
|
93
|
+
join(nodeModulesPath, "@db-ux/"),
|
|
94
|
+
join(nodeModulesPath, "@db-ux-inner-source/")
|
|
83
95
|
];
|
|
84
96
|
for (const databaseUxPath of databaseUxPaths) {
|
|
85
|
-
if (!
|
|
97
|
+
if (!existsSync(databaseUxPath)) {
|
|
86
98
|
continue;
|
|
87
99
|
}
|
|
88
|
-
const packages =
|
|
100
|
+
const packages = readdirSync(databaseUxPath, {
|
|
89
101
|
withFileTypes: true
|
|
90
102
|
});
|
|
91
103
|
for (const package_ of packages) {
|
|
92
|
-
let packagePath =
|
|
104
|
+
let packagePath = resolve(databaseUxPath, package_.name);
|
|
93
105
|
let isDirectory = false;
|
|
94
106
|
try {
|
|
95
|
-
const stats =
|
|
107
|
+
const stats = statSync(packagePath);
|
|
96
108
|
isDirectory = stats.isDirectory();
|
|
97
109
|
if (!isDirectory && stats.isFile()) {
|
|
98
|
-
const content =
|
|
110
|
+
const content = readFileSync(
|
|
111
|
+
packagePath,
|
|
112
|
+
"utf8"
|
|
113
|
+
).trim();
|
|
99
114
|
if (!content.includes("\n")) {
|
|
100
|
-
const targetPath =
|
|
101
|
-
|
|
115
|
+
const targetPath = resolve(
|
|
116
|
+
dirname(packagePath),
|
|
102
117
|
content
|
|
103
118
|
);
|
|
104
|
-
if (
|
|
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 =
|
|
129
|
+
const instructionsPath = join(
|
|
115
130
|
packagePath,
|
|
116
131
|
"agent",
|
|
117
132
|
"_instructions.md"
|
|
118
133
|
);
|
|
119
|
-
if (
|
|
120
|
-
let content =
|
|
121
|
-
const relativePath =
|
|
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
|
-
# ${
|
|
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 =
|
|
148
|
-
if (!
|
|
149
|
-
|
|
159
|
+
const outputFolder = resolve2(rootPath, ".amazonq", "rules");
|
|
160
|
+
if (!existsSync2(outputFolder)) {
|
|
161
|
+
mkdirSync(outputFolder, { recursive: true });
|
|
150
162
|
}
|
|
151
|
-
const amazonqInstructionsPath =
|
|
152
|
-
if (!
|
|
153
|
-
|
|
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 =
|
|
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
|
-
|
|
185
|
+
writeFileSync(amazonqInstructionsPath, amazonqFileContent);
|
|
177
186
|
}
|
|
178
187
|
};
|
|
179
188
|
|
|
180
189
|
// src/copilot/index.ts
|
|
181
|
-
import
|
|
182
|
-
import
|
|
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 =
|
|
185
|
-
if (!
|
|
186
|
-
|
|
193
|
+
const outputFolder = resolve3(rootPath, ".github");
|
|
194
|
+
if (!existsSync3(outputFolder)) {
|
|
195
|
+
mkdirSync2(outputFolder, { recursive: true });
|
|
187
196
|
}
|
|
188
|
-
const copilotInstructionsPath =
|
|
197
|
+
const copilotInstructionsPath = join3(
|
|
189
198
|
outputFolder,
|
|
190
199
|
"copilot-instructions.md"
|
|
191
200
|
);
|
|
192
|
-
if (!
|
|
193
|
-
|
|
201
|
+
if (!existsSync3(copilotInstructionsPath)) {
|
|
202
|
+
writeFileSync2(copilotInstructionsPath, "");
|
|
194
203
|
}
|
|
195
204
|
const copilotInstructionsContent = getInstructions(rootPath);
|
|
196
|
-
if (copilotInstructionsContent) {
|
|
197
|
-
let copilotFileContent =
|
|
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
|
-
|
|
222
|
+
writeFileSync2(copilotInstructionsPath, copilotFileContent);
|
|
217
223
|
}
|
|
218
224
|
};
|
|
219
225
|
|
|
220
226
|
// src/index.ts
|
|
221
227
|
var action = async (rootPath = ".") => {
|
|
222
|
-
const hasCopilot =
|
|
223
|
-
|
|
228
|
+
const hasCopilot = existsSync4(
|
|
229
|
+
join4(rootPath, ".github", "copilot-instructions.md")
|
|
224
230
|
);
|
|
225
|
-
const hasAmazonQ =
|
|
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.
|
|
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.
|
|
28
|
+
"vitest": "4.1.9"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"registry": "https://registry.npmjs.org/",
|