@lovelybunch/api 1.0.24 → 1.0.26
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/lib/gait-path.d.ts +7 -19
- package/dist/lib/gait-path.js +46 -34
- package/dist/lib/storage/file-storage.js +15 -2
- package/package.json +3 -3
- package/static/assets/index-CQ_uAUTe.js +631 -0
- package/static/assets/index-DdxjO25U.js +631 -0
- package/static/index.html +1 -1
package/dist/lib/gait-path.d.ts
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Priority order:
|
|
5
|
-
* 1. Explicit basePath parameter
|
|
6
|
-
* 2. Dev mode: GAIT_DEV_ROOT environment variable
|
|
7
|
-
* 3. Production mode: GAIT_DATA_PATH environment variable
|
|
8
|
-
* 4. Fallback: current working directory
|
|
2
|
+
* Find the .gait directory by traversing up from the current working directory
|
|
3
|
+
* If GAIT_DATA_PATH is set (from CLI), use that instead
|
|
9
4
|
*/
|
|
10
|
-
export declare function
|
|
5
|
+
export declare function findGaitDirectory(startDir?: string): Promise<string | null>;
|
|
11
6
|
/**
|
|
12
|
-
* Get the
|
|
7
|
+
* Get the path to a context file, automatically finding the .gait directory
|
|
13
8
|
*/
|
|
14
|
-
export declare function
|
|
9
|
+
export declare function getContextFilePath(fileName: string): Promise<string | null>;
|
|
15
10
|
/**
|
|
16
|
-
*
|
|
11
|
+
* Get the .gait config to read storage path settings
|
|
17
12
|
*/
|
|
18
|
-
export declare
|
|
19
|
-
readonly proposals: () => string;
|
|
20
|
-
readonly context: () => string;
|
|
21
|
-
readonly agents: () => string;
|
|
22
|
-
readonly resources: () => string;
|
|
23
|
-
readonly chats: () => string;
|
|
24
|
-
readonly config: () => string;
|
|
25
|
-
};
|
|
13
|
+
export declare function getGaitConfig(): Promise<any | null>;
|
package/dist/lib/gait-path.js
CHANGED
|
@@ -1,45 +1,57 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
1
2
|
import path from 'path';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Priority order:
|
|
6
|
-
* 1. Explicit basePath parameter
|
|
7
|
-
* 2. Dev mode: GAIT_DEV_ROOT environment variable
|
|
8
|
-
* 3. Production mode: GAIT_DATA_PATH environment variable
|
|
9
|
-
* 4. Fallback: current working directory
|
|
4
|
+
* Find the .gait directory by traversing up from the current working directory
|
|
5
|
+
* If GAIT_DATA_PATH is set (from CLI), use that instead
|
|
10
6
|
*/
|
|
11
|
-
export function
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
export async function findGaitDirectory(startDir) {
|
|
8
|
+
// If running from CLI (gait serve), use the directory where command was run
|
|
9
|
+
if (process.env.GAIT_DATA_PATH) {
|
|
10
|
+
const gaitPath = path.join(process.env.GAIT_DATA_PATH, '.gait');
|
|
11
|
+
try {
|
|
12
|
+
await fs.access(gaitPath);
|
|
13
|
+
return gaitPath;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// Fall through to directory traversal
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
// Otherwise traverse up from start directory
|
|
20
|
+
let currentDir = startDir || process.cwd();
|
|
21
|
+
while (currentDir !== path.parse(currentDir).root) {
|
|
22
|
+
const gaitPath = path.join(currentDir, '.gait');
|
|
23
|
+
try {
|
|
24
|
+
await fs.access(gaitPath);
|
|
25
|
+
return gaitPath;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
currentDir = path.dirname(currentDir);
|
|
29
|
+
}
|
|
26
30
|
}
|
|
31
|
+
return null;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
|
-
* Get the
|
|
34
|
+
* Get the path to a context file, automatically finding the .gait directory
|
|
30
35
|
*/
|
|
31
|
-
export function
|
|
32
|
-
const
|
|
33
|
-
|
|
36
|
+
export async function getContextFilePath(fileName) {
|
|
37
|
+
const gaitDir = await findGaitDirectory();
|
|
38
|
+
if (!gaitDir)
|
|
39
|
+
return null;
|
|
40
|
+
return path.join(gaitDir, 'context', fileName);
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
36
|
-
*
|
|
43
|
+
* Get the .gait config to read storage path settings
|
|
37
44
|
*/
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
export async function getGaitConfig() {
|
|
46
|
+
const gaitDir = await findGaitDirectory();
|
|
47
|
+
if (!gaitDir)
|
|
48
|
+
return null;
|
|
49
|
+
const configPath = path.join(gaitDir, 'config.json');
|
|
50
|
+
try {
|
|
51
|
+
const config = await fs.readFile(configPath, 'utf-8');
|
|
52
|
+
return JSON.parse(config);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -2,11 +2,24 @@ import { promises as fs } from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import matter from 'gray-matter';
|
|
4
4
|
import Fuse from 'fuse.js';
|
|
5
|
-
import { getGaitPath } from '../gait-path.js';
|
|
6
5
|
export class FileStorageAdapter {
|
|
7
6
|
basePath;
|
|
8
7
|
constructor(basePath) {
|
|
9
|
-
|
|
8
|
+
if (basePath) {
|
|
9
|
+
this.basePath = basePath;
|
|
10
|
+
}
|
|
11
|
+
else if (process.env.NODE_ENV === 'development' && process.env.GAIT_DEV_ROOT) {
|
|
12
|
+
// Dev mode: use project root .gait directory
|
|
13
|
+
this.basePath = process.env.GAIT_DEV_ROOT;
|
|
14
|
+
}
|
|
15
|
+
else if (process.env.GAIT_DATA_PATH) {
|
|
16
|
+
// Production mode: use GAIT_DATA_PATH (set by CLI)
|
|
17
|
+
this.basePath = path.join(process.env.GAIT_DATA_PATH, '.gait');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// Fallback: use current directory .gait
|
|
21
|
+
this.basePath = '.gait';
|
|
22
|
+
}
|
|
10
23
|
}
|
|
11
24
|
async ensureDirectories() {
|
|
12
25
|
const dirs = ['proposals', 'specs', 'flags', 'experiments', 'templates'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/server-with-static.js",
|
|
6
6
|
"exports": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@hono/node-server": "^1.13.7",
|
|
34
34
|
"@hono/node-ws": "^1.0.6",
|
|
35
|
-
"@lovelybunch/core": "^1.0.
|
|
36
|
-
"@lovelybunch/types": "^1.0.
|
|
35
|
+
"@lovelybunch/core": "^1.0.25",
|
|
36
|
+
"@lovelybunch/types": "^1.0.25",
|
|
37
37
|
"dotenv": "^17.2.1",
|
|
38
38
|
"fuse.js": "^7.0.0",
|
|
39
39
|
"gray-matter": "^4.0.3",
|