Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"apps/*"
],
"scripts": {
"build": "npm run build --workspaces --if-present",
"build": "node scripts/build-workspaces.mjs",
"test": "npm run test --workspaces --if-present",
"trace": "node apps/cli/dist/index.js trace"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/explainer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"outDir": "dist"
},
"include": ["src"],
"exclude": ["dist", "node_modules"]
"exclude": ["dist", "node_modules", "src/__tests__", "src/benchmark"]
}
4 changes: 2 additions & 2 deletions packages/go-parser/src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function isGinProject(root: string): boolean {
/**
* Walks the project for every `*.go` file (excluding `_test.go` — test
* files aren't part of the routing surface and only add noise), skipping
* vendor/build/VCS directories. Returns paths relative to `root`.
* vendor/build/VCS directories. Returns paths relative to `root`, with `/` separators on every OS.
*/
export function findGoFiles(root: string, opts: ScanOptions = {}): string[] {
const out: string[] = []
Expand Down Expand Up @@ -63,7 +63,7 @@ function walk(root: string, dir: string, out: string[], depth: number, includeTe
if (isDir) {
walk(root, abs, out, depth + 1, includeTests)
} else if (entry.endsWith(".go") && (includeTests || !entry.endsWith("_test.go"))) {
out.push(relative(root, abs))
out.push(relative(root, abs).replace(/\\/g, "/"))
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/lsp/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ await build({
platform: "node",
format: "cjs",
outfile: join(__dirname, "dist/lsp.cjs"),
external: ["tree-sitter", "tree-sitter-php", "tree-sitter-java", "ts-morph"],
// analysis is loaded at runtime from its own install: it pulls in go-parser,
// which needs tree-sitter 0.25 and tree-sitter-go (a native module esbuild
// cannot bundle), while lsp itself runs tree-sitter 0.21.
external: ["tree-sitter", "tree-sitter-php", "tree-sitter-java", "ts-morph", "@kidkender/archmind-analysis"],
banner: { js: "#!/usr/bin/env node" },
minify: false,
})
Expand Down
4 changes: 4 additions & 0 deletions packages/mcp-server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
export default {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
// The server's caches load the Laravel and Go parsers, whose module-level
// tree-sitter Parser intermittently fails when Jest reuses one worker process
// across test files (see packages/laravel-parser/jest.config.js).
maxWorkers: 50,
extensionsToTreatAsEsm: [".ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
moduleNameMapper: {
Expand Down
4 changes: 2 additions & 2 deletions packages/mcp-server/src/__tests__/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ describe("getGraphs() Go/Gin (integration)", () => {
test("re-parses after a tracked file's mtime changes", () => {
const { tmp, mainFile } = makeGinTmp()
getGraphs(tmp)
const before = _getGoTrackedFiles(tmp)!.get(join("cmd", "server", "main.go"))!
const before = _getGoTrackedFiles(tmp)!.get("cmd/server/main.go")!

bumpMtime(mainFile)
getGraphs(tmp)

const after = _getGoTrackedFiles(tmp)!.get(join("cmd", "server", "main.go"))!
const after = _getGoTrackedFiles(tmp)!.get("cmd/server/main.go")!
expect(after).toBeGreaterThan(before)
})

Expand Down
4 changes: 4 additions & 0 deletions packages/nestjs-parser/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
export default {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
// The cross-framework tests load the Laravel and Spring Boot parsers, whose
// module-level tree-sitter Parser intermittently fails when Jest reuses one
// worker process across test files (see packages/laravel-parser/jest.config.js).
maxWorkers: 50,
extensionsToTreatAsEsm: [".ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/", "/fixtures/"],
moduleNameMapper: {
Expand Down
2 changes: 2 additions & 0 deletions packages/nestjs-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"ts-morph": "^23.0.0"
},
"devDependencies": {
"@kidkender/archmind-laravel-parser": "*",
"@kidkender/archmind-springboot-parser": "*",
"@types/jest": "^29.5.0",
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.0.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/retrieval/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
export default {
preset: "ts-jest/presets/default-esm",
testEnvironment: "node",
// These tests load the Laravel / NestJS parsers, whose module-level tree-sitter
// Parser intermittently fails when Jest reuses one worker process across test
// files (see packages/laravel-parser/jest.config.js). One process per file.
maxWorkers: 50,
extensionsToTreatAsEsm: [".ts"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
moduleNameMapper: {
Expand Down
65 changes: 65 additions & 0 deletions scripts/build-workspaces.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env node
// Builds every workspace in dependency order.
//
// `npm run build --workspaces` builds in alphabetical order, so on a clean
// checkout (no dist/ yet) a package is compiled before the packages it imports
// — `aql` before `protocol` — and the build fails. This script orders the
// workspaces so each one is built after the workspaces it depends on.
//
// `dependencies` / `peerDependencies` are hard edges. `devDependencies` are soft:
// honored when possible, dropped only to get past a cycle (explainer's tests use
// scorer, and scorer → llm-client → prompt-builder → explainer).

import { readFileSync, readdirSync, existsSync } from "fs"
import { join } from "path"
import { spawnSync } from "child_process"
import { fileURLToPath } from "url"

const root = fileURLToPath(new URL("..", import.meta.url))
const rootPkg = JSON.parse(readFileSync(join(root, "package.json"), "utf-8"))

const workspaces = []
for (const pattern of rootPkg.workspaces) {
const base = pattern.replace(/\/\*$/, "")
for (const name of readdirSync(join(root, base)).sort()) {
const dir = `${base}/${name}`
const pkgPath = join(root, dir, "package.json")
if (!existsSync(pkgPath)) continue
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"))
workspaces.push({ dir, pkg })
}
}

const byName = new Map(workspaces.map((w) => [w.pkg.name, w]))
const internal = (deps) => Object.keys(deps ?? {}).filter((d) => byName.has(d))
for (const w of workspaces) {
w.hard = new Set([...internal(w.pkg.dependencies), ...internal(w.pkg.peerDependencies)])
w.soft = new Set(internal(w.pkg.devDependencies).filter((d) => !w.hard.has(d)))
}

const order = []
const done = new Set()
while (order.length < workspaces.length) {
const pending = workspaces.filter((w) => !done.has(w.pkg.name))
const ready = (w, useSoft) =>
[...w.hard].every((d) => done.has(d)) && (!useSoft || [...w.soft].every((d) => done.has(d)))
const next = pending.find((w) => ready(w, true)) ?? pending.find((w) => ready(w, false))
if (!next) {
console.error(`Dependency cycle among: ${pending.map((w) => w.pkg.name).join(", ")}`)
process.exit(1)
}
order.push(next)
done.add(next.pkg.name)
}

const npm = process.platform === "win32" ? "npm.cmd" : "npm"
for (const w of order) {
if (!w.pkg.scripts?.build) continue
console.log(`\n▶ ${w.pkg.name} (${w.dir})`)
const result = spawnSync(npm, ["run", "build", "-w", w.dir], { cwd: root, stdio: "inherit", shell: process.platform === "win32" })
if (result.status !== 0) {
console.error(`\n✘ build failed in ${w.dir}`)
process.exit(result.status ?? 1)
}
}
console.log(`\n✔ built ${order.filter((w) => w.pkg.scripts?.build).length} workspaces`)
Loading