@vibe-agent-toolkit/utils 0.1.12 → 0.1.14
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/project-utils.d.ts +19 -0
- package/dist/project-utils.d.ts.map +1 -0
- package/dist/project-utils.js +52 -0
- package/dist/project-utils.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './fs-utils.js';
|
|
|
10
10
|
export * from './file-crawler.js';
|
|
11
11
|
export * from './gitignore-checker.js';
|
|
12
12
|
export * from './git-utils.js';
|
|
13
|
+
export * from './project-utils.js';
|
|
13
14
|
export * from './git-tracker.js';
|
|
14
15
|
export * from './test-helpers.js';
|
|
15
16
|
export * from './zod-introspection.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,eAAe,CAAC;AAG9B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,gBAAgB,CAAC;AAG/B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,eAAe,CAAC;AAG9B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ export * from './file-crawler.js';
|
|
|
16
16
|
export * from './gitignore-checker.js';
|
|
17
17
|
// Git utilities (using git commands directly)
|
|
18
18
|
export * from './git-utils.js';
|
|
19
|
+
// Project root discovery (workspace root -> git root -> fallback)
|
|
20
|
+
export * from './project-utils.js';
|
|
19
21
|
// Git tracking cache (for efficient git-ignore checking)
|
|
20
22
|
export * from './git-tracker.js';
|
|
21
23
|
// Test helpers for isolated test output directories
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8DAA8D;AAC9D,cAAc,gBAAgB,CAAC;AAE/B,gCAAgC;AAChC,cAAc,iBAAiB,CAAC;AAEhC,uBAAuB;AACvB,cAAc,eAAe,CAAC;AAE9B,wCAAwC;AACxC,cAAc,mBAAmB,CAAC;AAElC,sBAAsB;AACtB,cAAc,wBAAwB,CAAC;AAEvC,8CAA8C;AAC9C,cAAc,gBAAgB,CAAC;AAE/B,yDAAyD;AACzD,cAAc,kBAAkB,CAAC;AAEjC,oDAAoD;AACpD,cAAc,mBAAmB,CAAC;AAElC,4CAA4C;AAC5C,cAAc,wBAAwB,CAAC;AAEvC,2DAA2D;AAC3D,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8DAA8D;AAC9D,cAAc,gBAAgB,CAAC;AAE/B,gCAAgC;AAChC,cAAc,iBAAiB,CAAC;AAEhC,uBAAuB;AACvB,cAAc,eAAe,CAAC;AAE9B,wCAAwC;AACxC,cAAc,mBAAmB,CAAC;AAElC,sBAAsB;AACtB,cAAc,wBAAwB,CAAC;AAEvC,8CAA8C;AAC9C,cAAc,gBAAgB,CAAC;AAE/B,kEAAkE;AAClE,cAAc,oBAAoB,CAAC;AAEnC,yDAAyD;AACzD,cAAc,kBAAkB,CAAC;AAEjC,oDAAoD;AACpD,cAAc,mBAAmB,CAAC;AAElC,4CAA4C;AAC5C,cAAc,wBAAwB,CAAC;AAEvC,2DAA2D;AAC3D,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project root discovery utilities.
|
|
3
|
+
*
|
|
4
|
+
* Finds the project root directory using a layered detection strategy:
|
|
5
|
+
* workspace root (monorepo) -> git root -> directory fallback.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Find the project root for boundary enforcement.
|
|
9
|
+
*
|
|
10
|
+
* Detection order:
|
|
11
|
+
* 1. Walk up from startDir looking for package.json with "workspaces" (monorepo root)
|
|
12
|
+
* 2. Fall back to git repository root
|
|
13
|
+
* 3. Fall back to startDir itself (tests / standalone)
|
|
14
|
+
*
|
|
15
|
+
* @param startDir - Directory to start searching from (e.g., dirname of SKILL.md)
|
|
16
|
+
* @returns Project root directory
|
|
17
|
+
*/
|
|
18
|
+
export declare function findProjectRoot(startDir: string): string;
|
|
19
|
+
//# sourceMappingURL=project-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-utils.d.ts","sourceRoot":"","sources":["../src/project-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CA+BxD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project root discovery utilities.
|
|
3
|
+
*
|
|
4
|
+
* Finds the project root directory using a layered detection strategy:
|
|
5
|
+
* workspace root (monorepo) -> git root -> directory fallback.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
8
|
+
import { dirname, join, resolve } from 'node:path';
|
|
9
|
+
import { gitFindRoot } from './git-utils.js';
|
|
10
|
+
const PACKAGE_JSON_FILENAME = 'package.json';
|
|
11
|
+
/**
|
|
12
|
+
* Find the project root for boundary enforcement.
|
|
13
|
+
*
|
|
14
|
+
* Detection order:
|
|
15
|
+
* 1. Walk up from startDir looking for package.json with "workspaces" (monorepo root)
|
|
16
|
+
* 2. Fall back to git repository root
|
|
17
|
+
* 3. Fall back to startDir itself (tests / standalone)
|
|
18
|
+
*
|
|
19
|
+
* @param startDir - Directory to start searching from (e.g., dirname of SKILL.md)
|
|
20
|
+
* @returns Project root directory
|
|
21
|
+
*/
|
|
22
|
+
export function findProjectRoot(startDir) {
|
|
23
|
+
let currentDir = resolve(startDir);
|
|
24
|
+
const resolvedStartDir = currentDir;
|
|
25
|
+
// 1. Walk up looking for workspace root (package.json with "workspaces")
|
|
26
|
+
while (currentDir !== dirname(currentDir)) {
|
|
27
|
+
const packageJsonPath = join(currentDir, PACKAGE_JSON_FILENAME);
|
|
28
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Walking up from validated startDir
|
|
29
|
+
if (existsSync(packageJsonPath)) {
|
|
30
|
+
try {
|
|
31
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Walking up from validated startDir
|
|
32
|
+
const content = readFileSync(packageJsonPath, 'utf-8');
|
|
33
|
+
const parsed = JSON.parse(content);
|
|
34
|
+
if (typeof parsed === 'object' && parsed !== null && 'workspaces' in parsed) {
|
|
35
|
+
return currentDir;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Invalid JSON - skip this package.json
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
currentDir = dirname(currentDir);
|
|
43
|
+
}
|
|
44
|
+
// 2. Fall back to git root
|
|
45
|
+
const gitRoot = gitFindRoot(resolvedStartDir);
|
|
46
|
+
if (gitRoot !== null) {
|
|
47
|
+
return gitRoot;
|
|
48
|
+
}
|
|
49
|
+
// 3. Fall back to start directory
|
|
50
|
+
return resolvedStartDir;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=project-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-utils.js","sourceRoot":"","sources":["../src/project-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,gBAAgB,GAAG,UAAU,CAAC;IAEpC,yEAAyE;IACzE,OAAO,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC;QAChE,yGAAyG;QACzG,IAAI,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,yGAAyG;gBACzG,MAAM,OAAO,GAAG,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;gBACvD,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC5C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,YAAY,IAAI,MAAM,EAAE,CAAC;oBAC5E,OAAO,UAAU,CAAC;gBACpB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,wCAAwC;YAC1C,CAAC;QACH,CAAC;QACD,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,2BAA2B;IAC3B,MAAM,OAAO,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAC9C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,kCAAkC;IAClC,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|