@lovelybunch/api 1.0.33 → 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.
@@ -3,24 +3,15 @@ import { promises as fs } from 'fs';
3
3
  import path from 'path';
4
4
  import matter from 'gray-matter';
5
5
  import { trimTrailingSlash } from 'hono/trailing-slash';
6
+ import { findGaitDirectory } from '../../../../../lib/gait-path.js';
6
7
  const app = new Hono();
7
8
  // Handle trailing slashes consistently
8
9
  app.use('*', trimTrailingSlash());
9
- function getArchitecturePath() {
10
- let basePath;
11
- if (process.env.NODE_ENV === 'development' && process.env.GAIT_DEV_ROOT) {
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');
10
+ async function getArchitecturePath() {
11
+ const gaitDir = await findGaitDirectory();
12
+ if (!gaitDir)
13
+ return null;
14
+ return path.join(gaitDir, 'context');
24
15
  }
25
16
  /**
26
17
  * GET /api/v1/context/architecture
@@ -28,7 +19,13 @@ function getArchitecturePath() {
28
19
  */
29
20
  app.get('/', async (c) => {
30
21
  try {
31
- 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
+ }
32
29
  // Ensure directory exists
33
30
  await fs.mkdir(architecturePath, { recursive: true });
34
31
  // Look for architecture.md file
@@ -164,7 +161,10 @@ app.put('/', async (c) => {
164
161
  if (!body.content) {
165
162
  return c.json({ success: false, error: 'Content is required' }, 400);
166
163
  }
167
- const architecturePath = getArchitecturePath();
164
+ const architecturePath = await getArchitecturePath();
165
+ if (!architecturePath) {
166
+ return c.json({ success: false, error: 'GAIT directory not found' }, 404);
167
+ }
168
168
  await fs.mkdir(architecturePath, { recursive: true });
169
169
  const filePath = path.join(architecturePath, 'architecture.md');
170
170
  // Read current content if it exists
@@ -3,24 +3,15 @@ import { promises as fs } from 'fs';
3
3
  import path from 'path';
4
4
  import matter from 'gray-matter';
5
5
  import { trimTrailingSlash } from 'hono/trailing-slash';
6
+ import { findGaitDirectory } from '../../../../../lib/gait-path.js';
6
7
  const app = new Hono();
7
8
  // Handle trailing slashes consistently
8
9
  app.use('*', trimTrailingSlash());
9
- function getProjectPath() {
10
- let basePath;
11
- if (process.env.NODE_ENV === 'development' && process.env.GAIT_DEV_ROOT) {
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');
10
+ async function getProjectPath() {
11
+ const gaitDir = await findGaitDirectory();
12
+ if (!gaitDir)
13
+ return null;
14
+ return path.join(gaitDir, 'context');
24
15
  }
25
16
  /**
26
17
  * GET /api/v1/context/project
@@ -28,7 +19,13 @@ function getProjectPath() {
28
19
  */
29
20
  app.get('/', async (c) => {
30
21
  try {
31
- 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
+ }
32
29
  // Ensure directory exists
33
30
  await fs.mkdir(projectPath, { recursive: true });
34
31
  // Look for project.md file
@@ -119,7 +116,10 @@ app.put('/', async (c) => {
119
116
  if (!body.content) {
120
117
  return c.json({ success: false, error: 'Content is required' }, 400);
121
118
  }
122
- const projectPath = getProjectPath();
119
+ const projectPath = await getProjectPath();
120
+ if (!projectPath) {
121
+ return c.json({ success: false, error: 'GAIT directory not found' }, 404);
122
+ }
123
123
  await fs.mkdir(projectPath, { recursive: true });
124
124
  const filePath = path.join(projectPath, 'project.md');
125
125
  // 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.33",
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.33",
36
- "@lovelybunch/types": "^1.0.33",
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",