LikeC4 Project Config Workflow
Project ownership and exclusion rules are subtle. Preserve the distinction between "which project owns this document" and "is this document included for this project".
Ground rules
- Start in
packages/language-server/src/workspace/ProjectsManager.ts. - Check callers in
WorkspaceManager.ts,LangiumDocuments.ts, and model parsing before changing semantics. - Prefer focused
ProjectsManager.spec.tscoverage before implementation. - Keep Windows path behavior covered when touching path normalization or folder matching.
Concepts to preserve
- A LikeC4 project is defined by config files such as
.likec4rcorlikec4.config.*. - The nearest config normally determines project ownership.
include.pathsadds source roots for a project; paths are resolved relative to the project folder.- Project-level
excludeaffects that project, but another project may still include the same physical file. - Workspace-level excludes take precedence over project-level inclusion.
- Default excludes such as
node_modulesstill apply where no explicit project rule overrides them.
Important distinction:
ownerProjectId(document)answers ownership.isExcluded(projectId, document)answers exclusion for a specific project.isExcluded(document)answers whether the document should be skipped in the effective owner context.
Regression matrix
Add or update tests for the relevant rows:
| Case | What to assert |
|---|---|
| nested projects | nearest config wins |
| sibling projects with similar prefixes | qwe does not own qwe-qwe |
| include path outside project folder | included document participates in the including project |
| document excluded by project A but included by project B | project-specific exclusion differs by project |
| shared include path | deterministic owner and no duplicate document processing |
| include path removed on reload | stale include ownership disappears |
| workspace startup scanning | include-path documents are loaded before project docs use them |
| workspace exclude | excluded even if project config includes it |
| Windows paths | drive and backslash paths match expected project |
Focused commands
pnpm --filter @likec4/language-server test -- ProjectsManager.spec.ts
pnpm --filter @likec4/language-server typecheck
pnpm exec dprint check packages/language-server/src/workspace
git diff --check
If a unit test manually adds the document, also test the workspace-startup path. Manual document injection can pass while real include-path scanning still drops the file.
PR evidence
Report:
- the reproduced project/include/exclude scenario
- the focused test name
- whether Windows path behavior was covered
- any intentionally unchanged behavior