|
- # Loads the Foundry Knowledge Engine commands for this project. Generated by the C64/C128 Dev Foundry.
- # Use: . ./tools/knowledge.ps1 (dot-source it, then see skills/knowledge-management/SKILL.md)
- # The knowledge system is shared across projects and lives in the Foundry that generated this repo.
- # Locations tried, in order: $env:FOUNDRY_HOME, then generated.foundryRoot in project.json.
- # This script never changes the project's build; it only imports the module and sets the project key.
- $repoRoot = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot '..')).Path
- $project = Get-Content -LiteralPath (Join-Path $repoRoot 'project.json') -Raw | ConvertFrom-Json -Depth 64
- $tried = [System.Collections.Generic.List[string]]::new()
- $module = $null
- foreach ($root in @($env:FOUNDRY_HOME, $project.generated.foundryRoot)) {
- if (-not $root) { continue }
- $candidate = Join-Path $root 'powershell/Foundry.Knowledge/Foundry.Knowledge.psd1'
- $tried.Add($candidate)
- if (Test-Path -LiteralPath $candidate) { $module = $candidate; break }
- }
- if (-not $module) {
- Write-Warning ("Foundry Knowledge module not found. Tried: " + ($tried -join '; ') + ". Set FOUNDRY_HOME to the Foundry folder, then run again. Continue without stored knowledge and tell the user.")
- return
- }
- Import-Module $module -Force -Global
- Set-FoundryProjectContext -Project $project.project.slug
- $status = Test-FoundryKnowledge
- Write-Host ("Foundry knowledge: project '{0}', ready={1}, embeddings={2}" -f $project.project.slug, $status.Ready, $status.EmbeddingsReady)
- if (-not $status.Ready) {
- $status.Checks | Where-Object { -not $_.ok } | ForEach-Object { Write-Warning "$($_.check): $($_.detail)" }
- }
|