Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@db-ux/agent-cli

Package Overview
Dependencies
Maintainers
2
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@db-ux/agent-cli - npm Package Compare versions

Comparing version
3.0.2-copilot-66b0168
to
3.0.2-copilot2-e7bf98b
+54
-39
build/index.js

@@ -7,13 +7,18 @@ #!/usr/bin/env node

// src/copilot/index.ts
import fs from "fs";
import path from "path";
function findAllNodeModulesDirs(dir, found = []) {
if (!fs.existsSync(dir)) return found;
const entries = fs.readdirSync(dir, { withFileTypes: true });
import fs from "node:fs";
import path from "node:path";
function findAllNodeModulesDirectories(directory, found = []) {
if (!fs.existsSync(directory)) {
return found;
}
const entries = fs.readdirSync(directory, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory()) {
if (entry.name === "node_modules") {
found.push(path.join(dir, entry.name));
found.push(path.join(directory, entry.name));
} else if (!entry.name.startsWith(".")) {
findAllNodeModulesDirs(path.join(dir, entry.name), found);
findAllNodeModulesDirectories(
path.join(directory, entry.name),
found
);
}

@@ -26,4 +31,4 @@ }

const outputFolder = path.resolve(rootPath, ".github");
const nodeModulesDirs = findAllNodeModulesDirs(rootPath);
if (nodeModulesDirs.length === 0) {
const nodeModulesDirectories = findAllNodeModulesDirectories(rootPath);
if (nodeModulesDirectories.length === 0) {
console.error("No node_modules folders found.");

@@ -33,30 +38,40 @@ return;

let copilotInstructionsContent = "";
for (const nodeModulesPath of nodeModulesDirs) {
const dbUxPath = path.join(nodeModulesPath, "@db-ux");
if (!fs.existsSync(dbUxPath)) {
continue;
}
const packages = fs.readdirSync(dbUxPath, { withFileTypes: true });
for (const pkg of packages) {
if (pkg.isDirectory()) {
const instructionsPath = path.join(
dbUxPath,
pkg.name,
"agent",
"_instructions.md"
);
if (fs.existsSync(instructionsPath)) {
let content = fs.readFileSync(instructionsPath, "utf-8");
const relPath = path.relative(
rootPath,
path.join(dbUxPath, pkg.name)
for (const nodeModulesPath of nodeModulesDirectories) {
const databaseUxPaths = [
path.join(nodeModulesPath, "@db-ux"),
path.join(nodeModulesPath, "@db-ux-inner-source")
];
for (const databaseUxPath of databaseUxPaths) {
if (!fs.existsSync(databaseUxPath)) {
continue;
}
const packages = fs.readdirSync(databaseUxPath, {
withFileTypes: true
});
for (const package_ of packages) {
if (package_.isDirectory()) {
const instructionsPath = path.join(
databaseUxPath,
package_.name,
"agent",
"_instructions.md"
);
content = content.replace(
/__agent-path__/g,
relPath.replace(/\\/g, "/")
);
copilotInstructionsContent += `
# @db-ux/${pkg.name}
if (fs.existsSync(instructionsPath)) {
let content = fs.readFileSync(instructionsPath, "utf8");
const relativePath = path.relative(
rootPath,
path.join(databaseUxPath, package_.name)
);
content = content.replaceAll(
"__agent-path__",
relativePath.replaceAll("\\", "/")
).replaceAll(
"**agent-path**",
relativePath.replaceAll("\\", "/")
);
copilotInstructionsContent += `
# ${path.basename(databaseUxPath)}/${package_.name}
${content}
`;
}
}

@@ -79,10 +94,10 @@ }

copilotInstructionsPath,
"utf-8"
"utf8"
);
const startMarker = "--- START: DB UX Copilot Instructions ---";
const endMarker = "--- END: DB UX Copilot Instructions ---";
const startIdx = copilotFileContent.indexOf(startMarker);
const endIdx = copilotFileContent.indexOf(endMarker);
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
copilotFileContent = (copilotFileContent.slice(0, startIdx) + copilotFileContent.slice(endIdx + endMarker.length)).trim();
const startIndex = copilotFileContent.indexOf(startMarker);
const endIndex = copilotFileContent.indexOf(endMarker);
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
copilotFileContent = (copilotFileContent.slice(0, startIndex) + copilotFileContent.slice(endIndex + endMarker.length)).trim();
}

@@ -89,0 +104,0 @@ copilotFileContent += `

{
"name": "@db-ux/agent-cli",
"version": "3.0.2-copilot-66b0168",
"version": "3.0.2-copilot2-e7bf98b",
"type": "module",

@@ -12,3 +12,3 @@ "description": "CLI for DB UX Design System generate AI agent instructions",

"bin": {
"@db-uxagent-cli": "build/index.js"
"@db-ux/agent-cli": "build/index.js"
},

@@ -15,0 +15,0 @@ "main": "build.js",