@lovelybunch/api 1.0.33 → 1.0.35
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.
|
@@ -2,25 +2,13 @@ import { Hono } from 'hono';
|
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import matter from 'gray-matter';
|
|
5
|
-
import {
|
|
5
|
+
import { findGaitDirectory } from '../../../../../lib/gait-path.js';
|
|
6
6
|
const app = new Hono();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Dev mode: use project root .gait directory
|
|
13
|
-
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
|
-
basePath = path.resolve(process.env.GAIT_DATA_PATH, '.gait');
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
// Fallback: use current directory .gait
|
|
21
|
-
basePath = path.resolve(process.cwd(), '.gait');
|
|
22
|
-
}
|
|
23
|
-
return path.join(basePath, 'context');
|
|
7
|
+
async function getArchitecturePath() {
|
|
8
|
+
const gaitDir = await findGaitDirectory();
|
|
9
|
+
if (!gaitDir)
|
|
10
|
+
return null;
|
|
11
|
+
return path.join(gaitDir, 'context');
|
|
24
12
|
}
|
|
25
13
|
/**
|
|
26
14
|
* GET /api/v1/context/architecture
|
|
@@ -28,7 +16,13 @@ function getArchitecturePath() {
|
|
|
28
16
|
*/
|
|
29
17
|
app.get('/', async (c) => {
|
|
30
18
|
try {
|
|
31
|
-
const architecturePath = getArchitecturePath();
|
|
19
|
+
const architecturePath = await getArchitecturePath();
|
|
20
|
+
if (!architecturePath) {
|
|
21
|
+
return c.json({
|
|
22
|
+
success: false,
|
|
23
|
+
error: 'GAIT directory not found'
|
|
24
|
+
}, 404);
|
|
25
|
+
}
|
|
32
26
|
// Ensure directory exists
|
|
33
27
|
await fs.mkdir(architecturePath, { recursive: true });
|
|
34
28
|
// Look for architecture.md file
|
|
@@ -164,7 +158,10 @@ app.put('/', async (c) => {
|
|
|
164
158
|
if (!body.content) {
|
|
165
159
|
return c.json({ success: false, error: 'Content is required' }, 400);
|
|
166
160
|
}
|
|
167
|
-
const architecturePath = getArchitecturePath();
|
|
161
|
+
const architecturePath = await getArchitecturePath();
|
|
162
|
+
if (!architecturePath) {
|
|
163
|
+
return c.json({ success: false, error: 'GAIT directory not found' }, 404);
|
|
164
|
+
}
|
|
168
165
|
await fs.mkdir(architecturePath, { recursive: true });
|
|
169
166
|
const filePath = path.join(architecturePath, 'architecture.md');
|
|
170
167
|
// Read current content if it exists
|
|
@@ -2,25 +2,13 @@ import { Hono } from 'hono';
|
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import matter from 'gray-matter';
|
|
5
|
-
import {
|
|
5
|
+
import { findGaitDirectory } from '../../../../../lib/gait-path.js';
|
|
6
6
|
const app = new Hono();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Dev mode: use project root .gait directory
|
|
13
|
-
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
|
-
basePath = path.resolve(process.env.GAIT_DATA_PATH, '.gait');
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
// Fallback: use current directory .gait
|
|
21
|
-
basePath = path.resolve(process.cwd(), '.gait');
|
|
22
|
-
}
|
|
23
|
-
return path.join(basePath, 'context');
|
|
7
|
+
async function getProjectPath() {
|
|
8
|
+
const gaitDir = await findGaitDirectory();
|
|
9
|
+
if (!gaitDir)
|
|
10
|
+
return null;
|
|
11
|
+
return path.join(gaitDir, 'context');
|
|
24
12
|
}
|
|
25
13
|
/**
|
|
26
14
|
* GET /api/v1/context/project
|
|
@@ -28,7 +16,13 @@ function getProjectPath() {
|
|
|
28
16
|
*/
|
|
29
17
|
app.get('/', async (c) => {
|
|
30
18
|
try {
|
|
31
|
-
const projectPath = getProjectPath();
|
|
19
|
+
const projectPath = await getProjectPath();
|
|
20
|
+
if (!projectPath) {
|
|
21
|
+
return c.json({
|
|
22
|
+
success: false,
|
|
23
|
+
error: 'GAIT directory not found'
|
|
24
|
+
}, 404);
|
|
25
|
+
}
|
|
32
26
|
// Ensure directory exists
|
|
33
27
|
await fs.mkdir(projectPath, { recursive: true });
|
|
34
28
|
// Look for project.md file
|
|
@@ -119,7 +113,10 @@ app.put('/', async (c) => {
|
|
|
119
113
|
if (!body.content) {
|
|
120
114
|
return c.json({ success: false, error: 'Content is required' }, 400);
|
|
121
115
|
}
|
|
122
|
-
const projectPath = getProjectPath();
|
|
116
|
+
const projectPath = await getProjectPath();
|
|
117
|
+
if (!projectPath) {
|
|
118
|
+
return c.json({ success: false, error: 'GAIT directory not found' }, 404);
|
|
119
|
+
}
|
|
123
120
|
await fs.mkdir(projectPath, { recursive: true });
|
|
124
121
|
const filePath = path.join(projectPath, 'project.md');
|
|
125
122
|
// Read current content if it exists
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.35",
|
|
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.35",
|
|
36
|
+
"@lovelybunch/types": "^1.0.35",
|
|
37
37
|
"dotenv": "^17.2.1",
|
|
38
38
|
"fuse.js": "^7.0.0",
|
|
39
39
|
"gray-matter": "^4.0.3",
|