@db-ux/agent-cli
Advanced tools
+89
-19
@@ -6,3 +6,11 @@ #!/usr/bin/env node | ||
| // src/copilot/index.ts | ||
| // src/index.ts | ||
| import fs4 from "node:fs"; | ||
| import path4 from "node:path"; | ||
| // src/amazonq/index.ts | ||
| import fs2 from "node:fs"; | ||
| import path2 from "node:path"; | ||
| // src/utils/index.ts | ||
| import fs from "node:fs"; | ||
@@ -29,10 +37,9 @@ import path from "node:path"; | ||
| } | ||
| var generateCopilot = (rootPath) => { | ||
| const outputFolder = path.resolve(rootPath, ".github"); | ||
| var getInstructions = (rootPath) => { | ||
| let copilotInstructionsContent = ""; | ||
| const nodeModulesDirectories = findAllNodeModulesDirectories(rootPath); | ||
| if (nodeModulesDirectories.length === 0) { | ||
| console.error("No node_modules folders found."); | ||
| return; | ||
| return ""; | ||
| } | ||
| let copilotInstructionsContent = ""; | ||
| for (const nodeModulesPath of nodeModulesDirectories) { | ||
@@ -80,14 +87,59 @@ const databaseUxPaths = [ | ||
| } | ||
| if (!fs.existsSync(outputFolder)) { | ||
| fs.mkdirSync(outputFolder); | ||
| copilotInstructionsContent = copilotInstructionsContent.trim(); | ||
| return copilotInstructionsContent; | ||
| }; | ||
| // src/amazonq/index.ts | ||
| var generateAmazonQ = (rootPath) => { | ||
| const outputFolder = path2.resolve(rootPath, ".amazonq", "rules"); | ||
| if (!fs2.existsSync(outputFolder)) { | ||
| fs2.mkdirSync(outputFolder, { recursive: true }); | ||
| } | ||
| const copilotInstructionsPath = path.join( | ||
| const amazonqInstructionsPath = path2.join(outputFolder, "db-ux.md"); | ||
| if (!fs2.existsSync(amazonqInstructionsPath)) { | ||
| fs2.writeFileSync(amazonqInstructionsPath, ""); | ||
| } | ||
| const amazonqInstructionsContent = getInstructions(rootPath); | ||
| if (amazonqInstructionsContent) { | ||
| let amazonqFileContent = fs2.readFileSync( | ||
| amazonqInstructionsPath, | ||
| "utf8" | ||
| ); | ||
| const startMarker = "--- START: DB UX Amazon Q Instructions \u2013 do not edit below ---"; | ||
| const endMarker = "--- END: DB UX Amazon Q Instructions \u2013 do not edit above ---"; | ||
| const startIndex = amazonqFileContent.indexOf(startMarker); | ||
| const endIndex = amazonqFileContent.indexOf(endMarker); | ||
| if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) { | ||
| amazonqFileContent = (amazonqFileContent.slice(0, startIndex) + amazonqFileContent.slice(endIndex + endMarker.length)).trim(); | ||
| } | ||
| amazonqFileContent += ` | ||
| ${startMarker} | ||
| > **NOTE**: Always use "DB UX" components and variables as project's conventions | ||
| ${amazonqInstructionsContent} | ||
| ${endMarker} | ||
| `; | ||
| fs2.writeFileSync(amazonqInstructionsPath, amazonqFileContent); | ||
| } | ||
| }; | ||
| // src/copilot/index.ts | ||
| import fs3 from "node:fs"; | ||
| import path3 from "node:path"; | ||
| var generateCopilot = (rootPath) => { | ||
| const outputFolder = path3.resolve(rootPath, ".github"); | ||
| if (!fs3.existsSync(outputFolder)) { | ||
| fs3.mkdirSync(outputFolder, { recursive: true }); | ||
| } | ||
| const copilotInstructionsPath = path3.join( | ||
| outputFolder, | ||
| "copilot-instructions.md" | ||
| ); | ||
| if (!fs.existsSync(copilotInstructionsPath)) { | ||
| fs.writeFileSync(copilotInstructionsPath, ""); | ||
| if (!fs3.existsSync(copilotInstructionsPath)) { | ||
| fs3.writeFileSync(copilotInstructionsPath, ""); | ||
| } | ||
| if (copilotInstructionsContent.trim()) { | ||
| let copilotFileContent = fs.readFileSync( | ||
| const copilotInstructionsContent = getInstructions(rootPath); | ||
| if (copilotInstructionsContent) { | ||
| let copilotFileContent = fs3.readFileSync( | ||
| copilotInstructionsPath, | ||
@@ -104,15 +156,33 @@ "utf8" | ||
| copilotFileContent += ` | ||
| ${startMarker} | ||
| > **NOTE**: Always use "DB UX" components and variables as project's conventions | ||
| ${copilotInstructionsContent} | ||
| ${endMarker} | ||
| ${startMarker} | ||
| > **NOTE**: Always use "DB UX" components and variables as project's conventions | ||
| ${copilotInstructionsContent} | ||
| ${endMarker} | ||
| `; | ||
| fs.writeFileSync(copilotInstructionsPath, copilotFileContent); | ||
| fs3.writeFileSync(copilotInstructionsPath, copilotFileContent); | ||
| } | ||
| }; | ||
| // src/cli.ts | ||
| // src/index.ts | ||
| var action = async (rootPath = ".") => { | ||
| generateCopilot(rootPath); | ||
| const hasCopilot = fs4.existsSync( | ||
| path4.join(rootPath, ".github", "copilot-instructions.md") | ||
| ); | ||
| const hasAmazonQ = fs4.existsSync(path4.join(rootPath, ".amazonq", "rules")); | ||
| if (!hasCopilot && !hasAmazonQ) { | ||
| generateCopilot(rootPath); | ||
| generateAmazonQ(rootPath); | ||
| } else if (hasCopilot && hasAmazonQ) { | ||
| generateCopilot(rootPath); | ||
| generateAmazonQ(rootPath); | ||
| } else if (hasCopilot) { | ||
| generateCopilot(rootPath); | ||
| } else { | ||
| generateAmazonQ(rootPath); | ||
| } | ||
| }; | ||
| // src/cli.ts | ||
| var startProgram = (name, description, action2) => { | ||
@@ -119,0 +189,0 @@ program.name(name).description(description); |
+6
-0
| # @db-ux/agent-cli | ||
| ## 4.0.3 | ||
| ### Patch Changes | ||
| - chore: generate AmazonQ rule file with @db-ux/agent-cli - [see commit b61c8b1](https://github.com/db-ux-design-system/core-web/commit/b61c8b14992f5a5b3615c6bff74018d5682aa0cc) | ||
| ## 4.0.2 | ||
@@ -4,0 +10,0 @@ |
+4
-3
| { | ||
| "name": "@db-ux/agent-cli", | ||
| "version": "4.0.2", | ||
| "version": "4.0.3", | ||
| "type": "module", | ||
@@ -27,3 +27,4 @@ "description": "CLI for DB UX Design System generate AI agent instructions", | ||
| "test": "vitest run --config vitest.config.ts", | ||
| "test:cli": "tsx src/cli.ts --help" | ||
| "test:cli": "tsx src/cli.ts --help", | ||
| "test:update": "vitest run --config vitest.config.ts --update" | ||
| }, | ||
@@ -35,3 +36,3 @@ "dependencies": { | ||
| "cpr": "3.0.1", | ||
| "esbuild": "0.25.10", | ||
| "esbuild": "0.25.11", | ||
| "tsx": "4.20.6", | ||
@@ -38,0 +39,0 @@ "vitest": "3.2.4" |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
12412
26.42%185
49.19%2
100%