@lovelybunch/api 1.0.32 → 1.0.34
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/routes/api/v1/config/route.js +5 -15
- package/dist/routes/api/v1/context/architecture/route.js +20 -17
- package/dist/routes/api/v1/context/project/route.js +20 -17
- package/dist/server-with-static.js +3 -0
- package/dist/server.js +3 -0
- package/package.json +3 -3
- package/static/assets/index-MoUp6Yr-.js +640 -0
- package/static/assets/index-rgrbZPlg.js +640 -0
- package/static/index.html +1 -1
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { findGaitDirectory } from '../../../../lib/gait-path.js';
|
|
3
4
|
async function getConfigPath() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
basePath = process.env.GAIT_DEV_ROOT;
|
|
9
|
-
}
|
|
10
|
-
else if (process.env.GAIT_DATA_PATH) {
|
|
11
|
-
// Production mode: use GAIT_DATA_PATH (set by CLI)
|
|
12
|
-
basePath = path.resolve(process.env.GAIT_DATA_PATH, '.gait');
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
// Fallback: use current directory .gait
|
|
16
|
-
basePath = path.resolve(process.cwd(), '.gait');
|
|
17
|
-
}
|
|
18
|
-
return path.join(basePath, 'config.json');
|
|
5
|
+
const gaitDir = await findGaitDirectory();
|
|
6
|
+
if (!gaitDir)
|
|
7
|
+
return null;
|
|
8
|
+
return path.join(gaitDir, 'config.json');
|
|
19
9
|
}
|
|
20
10
|
export async function GET(c) {
|
|
21
11
|
try {
|
|
@@ -2,22 +2,16 @@ 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 { trimTrailingSlash } from 'hono/trailing-slash';
|
|
6
|
+
import { findGaitDirectory } from '../../../../../lib/gait-path.js';
|
|
5
7
|
const app = new Hono();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Production mode: use GAIT_DATA_PATH (set by CLI)
|
|
14
|
-
basePath = path.resolve(process.env.GAIT_DATA_PATH, '.gait');
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// Fallback: use current directory .gait
|
|
18
|
-
basePath = path.resolve(process.cwd(), '.gait');
|
|
19
|
-
}
|
|
20
|
-
return path.join(basePath, 'context');
|
|
8
|
+
// Handle trailing slashes consistently
|
|
9
|
+
app.use('*', trimTrailingSlash());
|
|
10
|
+
async function getArchitecturePath() {
|
|
11
|
+
const gaitDir = await findGaitDirectory();
|
|
12
|
+
if (!gaitDir)
|
|
13
|
+
return null;
|
|
14
|
+
return path.join(gaitDir, 'context');
|
|
21
15
|
}
|
|
22
16
|
/**
|
|
23
17
|
* GET /api/v1/context/architecture
|
|
@@ -25,7 +19,13 @@ function getArchitecturePath() {
|
|
|
25
19
|
*/
|
|
26
20
|
app.get('/', async (c) => {
|
|
27
21
|
try {
|
|
28
|
-
const architecturePath = getArchitecturePath();
|
|
22
|
+
const architecturePath = await getArchitecturePath();
|
|
23
|
+
if (!architecturePath) {
|
|
24
|
+
return c.json({
|
|
25
|
+
success: false,
|
|
26
|
+
error: 'GAIT directory not found'
|
|
27
|
+
}, 404);
|
|
28
|
+
}
|
|
29
29
|
// Ensure directory exists
|
|
30
30
|
await fs.mkdir(architecturePath, { recursive: true });
|
|
31
31
|
// Look for architecture.md file
|
|
@@ -161,7 +161,10 @@ app.put('/', async (c) => {
|
|
|
161
161
|
if (!body.content) {
|
|
162
162
|
return c.json({ success: false, error: 'Content is required' }, 400);
|
|
163
163
|
}
|
|
164
|
-
const architecturePath = getArchitecturePath();
|
|
164
|
+
const architecturePath = await getArchitecturePath();
|
|
165
|
+
if (!architecturePath) {
|
|
166
|
+
return c.json({ success: false, error: 'GAIT directory not found' }, 404);
|
|
167
|
+
}
|
|
165
168
|
await fs.mkdir(architecturePath, { recursive: true });
|
|
166
169
|
const filePath = path.join(architecturePath, 'architecture.md');
|
|
167
170
|
// Read current content if it exists
|
|
@@ -2,22 +2,16 @@ 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 { trimTrailingSlash } from 'hono/trailing-slash';
|
|
6
|
+
import { findGaitDirectory } from '../../../../../lib/gait-path.js';
|
|
5
7
|
const app = new Hono();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// Production mode: use GAIT_DATA_PATH (set by CLI)
|
|
14
|
-
basePath = path.resolve(process.env.GAIT_DATA_PATH, '.gait');
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// Fallback: use current directory .gait
|
|
18
|
-
basePath = path.resolve(process.cwd(), '.gait');
|
|
19
|
-
}
|
|
20
|
-
return path.join(basePath, 'context');
|
|
8
|
+
// Handle trailing slashes consistently
|
|
9
|
+
app.use('*', trimTrailingSlash());
|
|
10
|
+
async function getProjectPath() {
|
|
11
|
+
const gaitDir = await findGaitDirectory();
|
|
12
|
+
if (!gaitDir)
|
|
13
|
+
return null;
|
|
14
|
+
return path.join(gaitDir, 'context');
|
|
21
15
|
}
|
|
22
16
|
/**
|
|
23
17
|
* GET /api/v1/context/project
|
|
@@ -25,7 +19,13 @@ function getProjectPath() {
|
|
|
25
19
|
*/
|
|
26
20
|
app.get('/', async (c) => {
|
|
27
21
|
try {
|
|
28
|
-
const projectPath = getProjectPath();
|
|
22
|
+
const projectPath = await getProjectPath();
|
|
23
|
+
if (!projectPath) {
|
|
24
|
+
return c.json({
|
|
25
|
+
success: false,
|
|
26
|
+
error: 'GAIT directory not found'
|
|
27
|
+
}, 404);
|
|
28
|
+
}
|
|
29
29
|
// Ensure directory exists
|
|
30
30
|
await fs.mkdir(projectPath, { recursive: true });
|
|
31
31
|
// Look for project.md file
|
|
@@ -116,7 +116,10 @@ app.put('/', async (c) => {
|
|
|
116
116
|
if (!body.content) {
|
|
117
117
|
return c.json({ success: false, error: 'Content is required' }, 400);
|
|
118
118
|
}
|
|
119
|
-
const projectPath = getProjectPath();
|
|
119
|
+
const projectPath = await getProjectPath();
|
|
120
|
+
if (!projectPath) {
|
|
121
|
+
return c.json({ success: false, error: 'GAIT directory not found' }, 404);
|
|
122
|
+
}
|
|
120
123
|
await fs.mkdir(projectPath, { recursive: true });
|
|
121
124
|
const filePath = path.join(projectPath, 'project.md');
|
|
122
125
|
// Read current content if it exists
|
|
@@ -4,6 +4,7 @@ import { createNodeWebSocket } from '@hono/node-ws';
|
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
6
6
|
import { serveStatic } from '@hono/node-server/serve-static';
|
|
7
|
+
import { trimTrailingSlash } from 'hono/trailing-slash';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import fs from 'fs';
|
|
9
10
|
import { getGlobalTerminalManager } from './lib/terminal/global-manager.js';
|
|
@@ -18,6 +19,8 @@ app.use('/api/*', cors({
|
|
|
18
19
|
origin: '*',
|
|
19
20
|
credentials: true,
|
|
20
21
|
}));
|
|
22
|
+
// Handle trailing slashes consistently for API routes
|
|
23
|
+
app.use('/api/*', trimTrailingSlash());
|
|
21
24
|
// Create WebSocket support
|
|
22
25
|
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
|
|
23
26
|
// WebSocket route for terminal sessions
|
package/dist/server.js
CHANGED
|
@@ -3,6 +3,7 @@ import { serve } from '@hono/node-server';
|
|
|
3
3
|
import { createNodeWebSocket } from '@hono/node-ws';
|
|
4
4
|
import { Hono } from 'hono';
|
|
5
5
|
import { cors } from 'hono/cors';
|
|
6
|
+
import { trimTrailingSlash } from 'hono/trailing-slash';
|
|
6
7
|
import { getGlobalTerminalManager } from './lib/terminal/global-manager.js';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
import { fileURLToPath } from 'url';
|
|
@@ -16,6 +17,8 @@ app.use('*', cors({
|
|
|
16
17
|
origin: ['http://localhost:5173', 'http://localhost:5174', 'http://localhost:3000'], // Vite and Next.js dev servers
|
|
17
18
|
credentials: true,
|
|
18
19
|
}));
|
|
20
|
+
// Handle trailing slashes consistently for API routes
|
|
21
|
+
app.use('/api/*', trimTrailingSlash());
|
|
19
22
|
// Create WebSocket support
|
|
20
23
|
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
|
|
21
24
|
// WebSocket route for terminal sessions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.34",
|
|
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.34",
|
|
36
|
+
"@lovelybunch/types": "^1.0.34",
|
|
37
37
|
"dotenv": "^17.2.1",
|
|
38
38
|
"fuse.js": "^7.0.0",
|
|
39
39
|
"gray-matter": "^4.0.3",
|