@agiflowai/aicode-utils 1.0.6 → 1.0.8

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/dist/index.cjs CHANGED
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
15
19
  }
16
20
  return to;
17
21
  };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
- import * as path from "node:path";
3
- import nodePath from "node:path";
2
+ import * as path$1 from "node:path";
3
+ import path from "node:path";
4
4
  import * as fs from "node:fs/promises";
5
5
  import { accessSync, mkdirSync, readFileSync, readFileSync as readFileSync$1, statSync, writeFileSync } from "node:fs";
6
6
  import * as os from "node:os";
@@ -89,7 +89,7 @@ async function copy(src, dest) {
89
89
  * Move a file or directory
90
90
  */
91
91
  async function move(src, dest) {
92
- await ensureDir(nodePath.dirname(dest));
92
+ await ensureDir(path.dirname(dest));
93
93
  await fs.rename(src, dest);
94
94
  }
95
95
  /**
@@ -123,7 +123,7 @@ function writeJsonSync(filePath, data, options) {
123
123
  * Output file - writes content ensuring directory exists
124
124
  */
125
125
  async function outputFile(filePath, content) {
126
- await ensureDir(nodePath.dirname(filePath));
126
+ await ensureDir(path.dirname(filePath));
127
127
  await fs.writeFile(filePath, content, "utf-8");
128
128
  }
129
129
  const readFile = fs.readFile;
@@ -138,12 +138,12 @@ const cp = fs.cp;
138
138
 
139
139
  //#endregion
140
140
  //#region src/utils/logger.ts
141
- const logsDir = path.join(os.tmpdir(), "scaffold-mcp-logs");
141
+ const logsDir = path$1.join(os.tmpdir(), "scaffold-mcp-logs");
142
142
  const logger = pino({
143
143
  level: process.env.LOG_LEVEL || "debug",
144
144
  timestamp: pino.stdTimeFunctions.isoTime
145
145
  }, pino.destination({
146
- dest: path.join(logsDir, "scaffold-mcp.log"),
146
+ dest: path$1.join(logsDir, "scaffold-mcp.log"),
147
147
  mkdir: true,
148
148
  sync: true
149
149
  }));
@@ -200,18 +200,18 @@ var TemplatesManagerService = class TemplatesManagerService {
200
200
  */
201
201
  static async findTemplatesPath(startPath = process.cwd()) {
202
202
  const workspaceRoot = await TemplatesManagerService.findWorkspaceRoot(startPath);
203
- const toolkitConfigPath = nodePath.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
203
+ const toolkitConfigPath = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
204
204
  if (await pathExists(toolkitConfigPath)) {
205
205
  const yaml$1 = await import("js-yaml");
206
206
  const content = await fs.readFile(toolkitConfigPath, "utf-8");
207
207
  const config = yaml$1.load(content);
208
208
  if (config?.templatesPath) {
209
- const templatesPath$1 = nodePath.isAbsolute(config.templatesPath) ? config.templatesPath : nodePath.join(workspaceRoot, config.templatesPath);
209
+ const templatesPath$1 = path.isAbsolute(config.templatesPath) ? config.templatesPath : path.join(workspaceRoot, config.templatesPath);
210
210
  if (await pathExists(templatesPath$1)) return templatesPath$1;
211
211
  else throw new Error(`Templates path specified in toolkit.yaml does not exist: ${templatesPath$1}`);
212
212
  }
213
213
  }
214
- const templatesPath = nodePath.join(workspaceRoot, TemplatesManagerService.TEMPLATES_FOLDER);
214
+ const templatesPath = path.join(workspaceRoot, TemplatesManagerService.TEMPLATES_FOLDER);
215
215
  if (await pathExists(templatesPath)) return templatesPath;
216
216
  throw new Error(`Templates folder not found at ${templatesPath}.\nEither create a 'templates' folder or specify templatesPath in toolkit.yaml`);
217
217
  }
@@ -219,12 +219,12 @@ var TemplatesManagerService = class TemplatesManagerService {
219
219
  * Find the workspace root by searching upwards for .git folder
220
220
  */
221
221
  static async findWorkspaceRoot(startPath) {
222
- let currentPath = nodePath.resolve(startPath);
223
- const rootPath = nodePath.parse(currentPath).root;
222
+ let currentPath = path.resolve(startPath);
223
+ const rootPath = path.parse(currentPath).root;
224
224
  while (true) {
225
- if (await pathExists(nodePath.join(currentPath, ".git"))) return currentPath;
225
+ if (await pathExists(path.join(currentPath, ".git"))) return currentPath;
226
226
  if (currentPath === rootPath) return process.cwd();
227
- currentPath = nodePath.dirname(currentPath);
227
+ currentPath = path.dirname(currentPath);
228
228
  }
229
229
  }
230
230
  /**
@@ -237,18 +237,18 @@ var TemplatesManagerService = class TemplatesManagerService {
237
237
  */
238
238
  static findTemplatesPathSync(startPath = process.cwd()) {
239
239
  const workspaceRoot = TemplatesManagerService.findWorkspaceRootSync(startPath);
240
- const toolkitConfigPath = nodePath.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
240
+ const toolkitConfigPath = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
241
241
  if (pathExistsSync(toolkitConfigPath)) {
242
242
  const yaml$1 = __require("js-yaml");
243
243
  const content = readFileSync$1(toolkitConfigPath, "utf-8");
244
244
  const config = yaml$1.load(content);
245
245
  if (config?.templatesPath) {
246
- const templatesPath$1 = nodePath.isAbsolute(config.templatesPath) ? config.templatesPath : nodePath.join(workspaceRoot, config.templatesPath);
246
+ const templatesPath$1 = path.isAbsolute(config.templatesPath) ? config.templatesPath : path.join(workspaceRoot, config.templatesPath);
247
247
  if (pathExistsSync(templatesPath$1)) return templatesPath$1;
248
248
  else throw new Error(`Templates path specified in toolkit.yaml does not exist: ${templatesPath$1}`);
249
249
  }
250
250
  }
251
- const templatesPath = nodePath.join(workspaceRoot, TemplatesManagerService.TEMPLATES_FOLDER);
251
+ const templatesPath = path.join(workspaceRoot, TemplatesManagerService.TEMPLATES_FOLDER);
252
252
  if (pathExistsSync(templatesPath)) return templatesPath;
253
253
  throw new Error(`Templates folder not found at ${templatesPath}.\nEither create a 'templates' folder or specify templatesPath in toolkit.yaml`);
254
254
  }
@@ -256,12 +256,12 @@ var TemplatesManagerService = class TemplatesManagerService {
256
256
  * Find the workspace root synchronously by searching upwards for .git folder
257
257
  */
258
258
  static findWorkspaceRootSync(startPath) {
259
- let currentPath = nodePath.resolve(startPath);
260
- const rootPath = nodePath.parse(currentPath).root;
259
+ let currentPath = path.resolve(startPath);
260
+ const rootPath = path.parse(currentPath).root;
261
261
  while (true) {
262
- if (pathExistsSync(nodePath.join(currentPath, ".git"))) return currentPath;
262
+ if (pathExistsSync(path.join(currentPath, ".git"))) return currentPath;
263
263
  if (currentPath === rootPath) return process.cwd();
264
- currentPath = nodePath.dirname(currentPath);
264
+ currentPath = path.dirname(currentPath);
265
265
  }
266
266
  }
267
267
  /**
@@ -294,7 +294,7 @@ var TemplatesManagerService = class TemplatesManagerService {
294
294
  */
295
295
  static async readToolkitConfig(startPath = process.cwd()) {
296
296
  const workspaceRoot = await TemplatesManagerService.findWorkspaceRoot(startPath);
297
- const toolkitConfigPath = nodePath.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
297
+ const toolkitConfigPath = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
298
298
  if (!await pathExists(toolkitConfigPath)) return null;
299
299
  const yaml$1 = await import("js-yaml");
300
300
  const content = await fs.readFile(toolkitConfigPath, "utf-8");
@@ -308,7 +308,7 @@ var TemplatesManagerService = class TemplatesManagerService {
308
308
  */
309
309
  static readToolkitConfigSync(startPath = process.cwd()) {
310
310
  const workspaceRoot = TemplatesManagerService.findWorkspaceRootSync(startPath);
311
- const toolkitConfigPath = nodePath.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
311
+ const toolkitConfigPath = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
312
312
  if (!pathExistsSync(toolkitConfigPath)) return null;
313
313
  const yaml$1 = __require("js-yaml");
314
314
  const content = readFileSync$1(toolkitConfigPath, "utf-8");
@@ -322,7 +322,7 @@ var TemplatesManagerService = class TemplatesManagerService {
322
322
  */
323
323
  static async writeToolkitConfig(config, startPath = process.cwd()) {
324
324
  const workspaceRoot = await TemplatesManagerService.findWorkspaceRoot(startPath);
325
- const toolkitConfigPath = nodePath.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
325
+ const toolkitConfigPath = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
326
326
  const content = (await import("js-yaml")).dump(config, { indent: 2 });
327
327
  await fs.writeFile(toolkitConfigPath, content, "utf-8");
328
328
  }
@@ -393,13 +393,13 @@ var ProjectConfigResolver = class ProjectConfigResolver {
393
393
  */
394
394
  static async resolveProjectConfig(projectPath, explicitTemplate) {
395
395
  try {
396
- const absolutePath = nodePath.resolve(projectPath);
396
+ const absolutePath = path.resolve(projectPath);
397
397
  if (explicitTemplate) return {
398
398
  type: ProjectType.MONOLITH,
399
399
  sourceTemplate: explicitTemplate,
400
400
  configSource: ConfigSource.TOOLKIT_YAML
401
401
  };
402
- const projectJsonPath = nodePath.join(absolutePath, "project.json");
402
+ const projectJsonPath = path.join(absolutePath, "project.json");
403
403
  if (await pathExists(projectJsonPath)) {
404
404
  const projectJson = await readJson(projectJsonPath);
405
405
  if (projectJson.sourceTemplate && typeof projectJson.sourceTemplate === "string" && projectJson.sourceTemplate.trim()) return {
@@ -490,12 +490,12 @@ Run 'scaffold-mcp scaffold list --help' for more info.`;
490
490
  * @param sourceTemplate - The template identifier
491
491
  */
492
492
  static async createProjectJson(projectPath, projectName, sourceTemplate) {
493
- const projectJsonPath = nodePath.join(projectPath, "project.json");
493
+ const projectJsonPath = path.join(projectPath, "project.json");
494
494
  try {
495
495
  let projectJson;
496
496
  if (await pathExists(projectJsonPath)) projectJson = await readJson(projectJsonPath);
497
497
  else {
498
- const relativePath = nodePath.relative(projectPath, process.cwd());
498
+ const relativePath = path.relative(projectPath, process.cwd());
499
499
  projectJson = {
500
500
  name: projectName,
501
501
  $schema: relativePath ? `${relativePath}/node_modules/nx/schemas/project-schema.json` : "node_modules/nx/schemas/project-schema.json",
@@ -547,15 +547,15 @@ var ProjectFinderService = class {
547
547
  * @returns Project configuration or null if not found
548
548
  */
549
549
  async findProjectForFile(filePath) {
550
- const normalizedPath = nodePath.isAbsolute(filePath) ? filePath : nodePath.join(this.workspaceRoot, filePath);
551
- let currentDir = nodePath.dirname(normalizedPath);
550
+ const normalizedPath = path.isAbsolute(filePath) ? filePath : path.join(this.workspaceRoot, filePath);
551
+ let currentDir = path.dirname(normalizedPath);
552
552
  while (currentDir !== "/" && currentDir.startsWith(this.workspaceRoot)) {
553
- const projectJsonPath = nodePath.join(currentDir, "project.json");
553
+ const projectJsonPath = path.join(currentDir, "project.json");
554
554
  try {
555
555
  const project = await this.loadProjectConfig(projectJsonPath);
556
556
  if (project) return project;
557
557
  } catch {}
558
- currentDir = nodePath.dirname(currentDir);
558
+ currentDir = path.dirname(currentDir);
559
559
  }
560
560
  return null;
561
561
  }
@@ -566,15 +566,15 @@ var ProjectFinderService = class {
566
566
  * @returns Project configuration or null if not found
567
567
  */
568
568
  findProjectForFileSync(filePath) {
569
- const normalizedPath = nodePath.isAbsolute(filePath) ? filePath : nodePath.join(this.workspaceRoot, filePath);
570
- let currentDir = nodePath.dirname(normalizedPath);
569
+ const normalizedPath = path.isAbsolute(filePath) ? filePath : path.join(this.workspaceRoot, filePath);
570
+ let currentDir = path.dirname(normalizedPath);
571
571
  while (currentDir !== "/" && currentDir.startsWith(this.workspaceRoot)) {
572
- const projectJsonPath = nodePath.join(currentDir, "project.json");
572
+ const projectJsonPath = path.join(currentDir, "project.json");
573
573
  try {
574
574
  const project = this.loadProjectConfigSync(projectJsonPath);
575
575
  if (project) return project;
576
576
  } catch {}
577
- currentDir = nodePath.dirname(currentDir);
577
+ currentDir = path.dirname(currentDir);
578
578
  }
579
579
  return null;
580
580
  }
@@ -587,8 +587,8 @@ var ProjectFinderService = class {
587
587
  const content = await fs.readFile(projectJsonPath, "utf-8");
588
588
  const config = JSON.parse(content);
589
589
  const projectConfig = {
590
- name: config.name || nodePath.basename(nodePath.dirname(projectJsonPath)),
591
- root: nodePath.dirname(projectJsonPath),
590
+ name: config.name || path.basename(path.dirname(projectJsonPath)),
591
+ root: path.dirname(projectJsonPath),
592
592
  sourceTemplate: config.sourceTemplate,
593
593
  projectType: config.projectType
594
594
  };
@@ -607,8 +607,8 @@ var ProjectFinderService = class {
607
607
  const content = readFileSync$1(projectJsonPath, "utf-8");
608
608
  const config = JSON.parse(content);
609
609
  const projectConfig = {
610
- name: config.name || nodePath.basename(nodePath.dirname(projectJsonPath)),
611
- root: nodePath.dirname(projectJsonPath),
610
+ name: config.name || path.basename(path.dirname(projectJsonPath)),
611
+ root: path.dirname(projectJsonPath),
612
612
  sourceTemplate: config.sourceTemplate,
613
613
  projectType: config.projectType
614
614
  };
@@ -668,7 +668,7 @@ var ScaffoldProcessingService = class {
668
668
  * Now supports tracking existing files separately from created files
669
669
  */
670
670
  async copyAndProcess(sourcePath, targetPath, variables, createdFiles, existingFiles) {
671
- await this.fileSystem.ensureDir(nodePath.dirname(targetPath));
671
+ await this.fileSystem.ensureDir(path.dirname(targetPath));
672
672
  if (await this.fileSystem.pathExists(targetPath) && existingFiles) {
673
673
  await this.trackExistingFiles(targetPath, existingFiles);
674
674
  return;
@@ -690,7 +690,7 @@ var ScaffoldProcessingService = class {
690
690
  }
691
691
  for (const item of items) {
692
692
  if (!item) continue;
693
- const itemPath = nodePath.join(dirPath, item);
693
+ const itemPath = path.join(dirPath, item);
694
694
  try {
695
695
  const stat$1 = await this.fileSystem.stat(itemPath);
696
696
  if (stat$1.isDirectory()) await this.trackCreatedFilesRecursive(itemPath, createdFiles);
@@ -713,7 +713,7 @@ var ScaffoldProcessingService = class {
713
713
  }
714
714
  for (const item of items) {
715
715
  if (!item) continue;
716
- const itemPath = nodePath.join(dirPath, item);
716
+ const itemPath = path.join(dirPath, item);
717
717
  try {
718
718
  const stat$1 = await this.fileSystem.stat(itemPath);
719
719
  if (stat$1.isDirectory()) await this.trackExistingFilesRecursive(itemPath, existingFiles);
@@ -927,7 +927,7 @@ const MONOREPO_INDICATOR_FILES = [
927
927
  */
928
928
  async function detectProjectType(workspaceRoot) {
929
929
  const indicators = [];
930
- const toolkitYamlPath = nodePath.join(workspaceRoot, "toolkit.yaml");
930
+ const toolkitYamlPath = path.join(workspaceRoot, "toolkit.yaml");
931
931
  if (await pathExists(toolkitYamlPath)) try {
932
932
  const content = await fs.readFile(toolkitYamlPath, "utf-8");
933
933
  const config = yaml.load(content);
@@ -939,14 +939,14 @@ async function detectProjectType(workspaceRoot) {
939
939
  };
940
940
  }
941
941
  } catch {}
942
- for (const filename of MONOREPO_INDICATOR_FILES) if (await pathExists(nodePath.join(workspaceRoot, filename))) {
942
+ for (const filename of MONOREPO_INDICATOR_FILES) if (await pathExists(path.join(workspaceRoot, filename))) {
943
943
  indicators.push(`${filename} found`);
944
944
  return {
945
945
  projectType: ProjectType.MONOREPO,
946
946
  indicators
947
947
  };
948
948
  }
949
- const packageJsonPath = nodePath.join(workspaceRoot, "package.json");
949
+ const packageJsonPath = path.join(workspaceRoot, "package.json");
950
950
  if (await pathExists(packageJsonPath)) try {
951
951
  if ((await readJson(packageJsonPath)).workspaces) {
952
952
  indicators.push("package.json with workspaces found");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agiflowai/aicode-utils",
3
3
  "description": "Shared utilities and types for AI-powered code generation, scaffolding, and analysis",
4
- "version": "1.0.6",
4
+ "version": "1.0.8",
5
5
  "license": "AGPL-3.0",
6
6
  "author": "AgiflowIO",
7
7
  "repository": {