anomalyco / anomalyco/opencode
Compiled builds crash on first prompt: undefined layer node from filesystem search import cycle
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Compiled builds of the server crash on the first prompt while booting a location:
TypeError: undefined is not an object (evaluating 'node.name')
The same code works when run from source (bun run).
Cause: packages/core/src/filesystem/search.ts imports the FileSystem self-namespace from ../filesystem to use Entry.make / Match.make (values re-exported from @opencode-ai/schema/filesystem). That creates a runtime import cycle between filesystem.ts and filesystem/search.ts. In bundled output the cycle can leave FileSystemSearch.node undefined when filesystem.ts builds its layer node, so the layer graph walker dereferences an undefined node.
This blocks any self-contained/compiled distribution of the kernel (for example embedding it as a headless engine behind a native desktop shell).
Reproduction
- Build a standalone binary (
bun run --cwd packages/opencode script/build.ts --single). - Run
serve, create a session, sendprompt_async. - The session errors with the TypeError above and the assistant message never completes.
Expected
The compiled binary behaves like the source build: the prompt runs and the assistant message completes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with packages/core/src/filesystem/search.ts and packages/core/src/filesystem.ts, then reproduce the failure with bun run --cwd packages/opencode script/build.ts --single and the serve/prompt_async sequence. Trace the runtime cycle involving FileSystem, Entry.make, and Match.make. Done means the compiled binary completes the prompt like the source build without the undefined node error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, typescript
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100