@foundation0/api 1.1.8 → 1.1.10
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/mcp/cli.ts +0 -10
- package/mcp/manual.md +161 -161
- package/mcp/server.test.ts +102 -97
- package/mcp/server.ts +267 -288
- package/package.json +1 -1
- package/projects.ts +27 -3
package/package.json
CHANGED
package/projects.ts
CHANGED
|
@@ -314,8 +314,23 @@ export function resolveProjectRoot(projectName: string, processRoot: string = pr
|
|
|
314
314
|
throw new Error('project-name may not include path traversal.')
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
const
|
|
317
|
+
const resolvedProcessRoot = path.resolve(processRoot)
|
|
318
|
+
const projectRoot = path.join(resolveProjectsRoot(resolvedProcessRoot), normalized)
|
|
318
319
|
if (!existsDir(projectRoot)) {
|
|
320
|
+
const identity = resolveProjectRepoIdentity(resolvedProcessRoot)
|
|
321
|
+
const normalizedKey = normalized.replace(/\\/g, '/').toLowerCase()
|
|
322
|
+
const normalizedLeaf = normalized.split(path.sep).filter(Boolean).at(-1)?.toLowerCase() ?? null
|
|
323
|
+
const aliases = [
|
|
324
|
+
identity?.repo?.toLowerCase() ?? null,
|
|
325
|
+
identity?.owner && identity?.repo ? `${identity.owner}/${identity.repo}`.toLowerCase() : null,
|
|
326
|
+
path.basename(resolvedProcessRoot).toLowerCase(),
|
|
327
|
+
].filter((value): value is string => Boolean(value))
|
|
328
|
+
const hasAliasMatch = aliases.some((alias) => alias === normalizedKey || alias === normalizedLeaf)
|
|
329
|
+
|
|
330
|
+
if (hasAliasMatch) {
|
|
331
|
+
return resolvedProcessRoot
|
|
332
|
+
}
|
|
333
|
+
|
|
319
334
|
throw new Error(`Project folder not found: ${projectRoot}`)
|
|
320
335
|
}
|
|
321
336
|
|
|
@@ -323,9 +338,18 @@ export function resolveProjectRoot(projectName: string, processRoot: string = pr
|
|
|
323
338
|
}
|
|
324
339
|
|
|
325
340
|
export function listProjects(processRoot: string = process.cwd()): string[] {
|
|
326
|
-
const
|
|
341
|
+
const resolvedProcessRoot = path.resolve(processRoot)
|
|
342
|
+
const projectsRoot = resolveProjectsRoot(resolvedProcessRoot)
|
|
327
343
|
if (!existsDir(projectsRoot)) {
|
|
328
|
-
|
|
344
|
+
const hasSingleRepoDocs = existsDir(path.join(resolvedProcessRoot, 'docs'))
|
|
345
|
+
const hasSingleRepoSpec = existsDir(path.join(resolvedProcessRoot, 'spec'))
|
|
346
|
+
if (!hasSingleRepoDocs && !hasSingleRepoSpec) {
|
|
347
|
+
return []
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const identity = resolveProjectRepoIdentity(resolvedProcessRoot)
|
|
351
|
+
const singleProjectName = identity?.repo ?? path.basename(resolvedProcessRoot)
|
|
352
|
+
return singleProjectName ? [singleProjectName] : []
|
|
329
353
|
}
|
|
330
354
|
|
|
331
355
|
return fsSync
|