kontexta 5.2.0 → 6.1.0
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/bundle/standalone/CHANGELOG.md +52 -0
- package/bundle/standalone/apps/web/.next/BUILD_ID +1 -1
- package/bundle/standalone/apps/web/.next/app-build-manifest.json +42 -42
- package/bundle/standalone/apps/web/.next/app-path-routes-manifest.json +10 -10
- package/bundle/standalone/apps/web/.next/build-manifest.json +2 -2
- package/bundle/standalone/apps/web/.next/prerender-manifest.json +16 -16
- package/bundle/standalone/apps/web/.next/required-server-files.json +1 -0
- package/bundle/standalone/apps/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found.html +1 -1
- package/bundle/standalone/apps/web/.next/server/app/_not-found.rsc +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/about/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/about/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/hooks/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/mcp/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/agents/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/setup/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/auth/token/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/conflicts/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/entities/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/events/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/ics/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/links/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/calendar/settings/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/clip/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/clip/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/docker-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/export/zip/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/backlinks/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/download/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-html/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/export-pdf/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/restore/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/history/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/move/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/files/upload/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/folders/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/remote/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/git/sync-all/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/test-pattern/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/hands/validate/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/health/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/health/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/install-snippets/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/mcp-tools/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/profile/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/profile/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/hands-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/journal-status/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/onboard/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/refresh/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/[id]/sync/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/onboard/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/projects/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/html/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/publish/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/refresh/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/refresh/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reindex/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reindex/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/reports/resources/[name]/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/search/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/search/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/tags/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/tags/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/version-check/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/version-check/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/welcome/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/welcome/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/api/ws-config/route_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/apple-icon.png/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/calendar/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/icon.png/route.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/page.js +4 -4
- package/bundle/standalone/apps/web/.next/server/app/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs/page_client-reference-manifest.js +1 -1
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs.html +2 -2
- package/bundle/standalone/apps/web/.next/server/app/preview/motifs.rsc +1 -1
- package/bundle/standalone/apps/web/.next/server/app-paths-manifest.json +10 -10
- package/bundle/standalone/apps/web/.next/server/pages/404.html +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/500.html +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/_app.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/_document.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/pages/_error.js.nft.json +1 -1
- package/bundle/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
- package/bundle/standalone/apps/web/.next/static/chunks/app/page-86e385abedf10ccd.js +1 -0
- package/bundle/standalone/apps/web/package.json +6 -5
- package/bundle/standalone/apps/web/server.js +1 -1
- package/bundle/standalone/apps/web/src/lib/mcp-tools.json +103 -95
- package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-block.md +28 -185
- package/bundle/standalone/node_modules/kontexta-mcp/dist/agent-rules/rules-reference.md +207 -0
- package/bundle/standalone/node_modules/kontexta-mcp/dist/calendar-tools.js +12 -12
- package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/formatter.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/hands/schema-doc.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js +196 -68
- package/bundle/standalone/node_modules/kontexta-mcp/dist/index.js.map +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-capture.js +3 -3
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-commit-upgrades-tool.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-housekeep-tool.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/dist/journal-tools.js +2 -2
- package/bundle/standalone/node_modules/kontexta-mcp/dist/repo-write-guard.js +1 -1
- package/bundle/standalone/node_modules/kontexta-mcp/package.json +4 -2
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.d.ts +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js +84 -25
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-block.md +28 -185
- package/bundle/standalone/node_modules/kxta-core/dist/agent-rules/rules-reference.md +207 -0
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.d.ts +25 -1
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.js +159 -32
- package/bundle/standalone/node_modules/kxta-core/dist/bundle/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.d.ts +71 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.js +192 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/engine.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.d.ts +9 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.js +10 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/index.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.d.ts +20 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.js +124 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/intent-router.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.d.ts +20 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.js +28 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/pruning.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.d.ts +30 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.js +57 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/sufficiency.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.d.ts +42 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.js +7 -0
- package/bundle/standalone/node_modules/kxta-core/dist/decision/types.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.d.ts +3 -1
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.js +10 -1
- package/bundle/standalone/node_modules/kxta-core/dist/files/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/hooks/alerts.js +2 -2
- package/bundle/standalone/node_modules/kxta-core/dist/index.d.ts +4 -1
- package/bundle/standalone/node_modules/kxta-core/dist/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/index.js +4 -1
- package/bundle/standalone/node_modules/kxta-core/dist/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.d.ts +3 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.js +27 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/bundled.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.d.ts +41 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.js +140 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/cache-manager.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.d.ts +7 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.js +39 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/embeddings.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.d.ts +16 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.js +17 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/index.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.d.ts +132 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.js +312 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/runtime.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.d.ts +55 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.js +6 -0
- package/bundle/standalone/node_modules/kxta-core/dist/inference/types.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.d.ts +6 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.js +50 -7
- package/bundle/standalone/node_modules/kxta-core/dist/journal/distill.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.d.ts +12 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.js +190 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/event-triage.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/high-water.d.ts +2 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/high-water.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/high-water.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.d.ts +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.js +3 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.d.ts +10 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.js +22 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/intelligence-config.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js +2 -2
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/refactor.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tagging-pass.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.js +30 -5
- package/bundle/standalone/node_modules/kxta-core/dist/journal/patterns/tool-classes.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.d.ts +21 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.js +90 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/pivot.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.d.ts +2 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.js +17 -5
- package/bundle/standalone/node_modules/kxta-core/dist/journal/renderer.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/strict-mode.js +2 -2
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.d.ts +17 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.js +77 -9
- package/bundle/standalone/node_modules/kxta-core/dist/journal/topic-detector.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/journal/types.d.ts +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/journal/types.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/mcp-install/tools.generated.js +58 -58
- package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.js +10 -1
- package/bundle/standalone/node_modules/kxta-core/dist/metadata/index.js.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/project-map/index.js +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.d.ts +29 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.js +68 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/arbitrator.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.d.ts +57 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.js +199 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/engine.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.d.ts +7 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.js +8 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/index.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.d.ts +50 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.d.ts.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.js +2 -0
- package/bundle/standalone/node_modules/kxta-core/dist/rerank/types.js.map +1 -0
- package/bundle/standalone/node_modules/kxta-core/dist/types.d.ts +5 -0
- package/bundle/standalone/node_modules/kxta-core/dist/types.d.ts.map +1 -1
- package/bundle/standalone/node_modules/kxta-core/dist/util/paths.js +1 -1
- package/bundle/standalone/node_modules/kxta-core/package.json +4 -2
- package/bundle/standalone/node_modules/kxta-publish/package.json +3 -3
- package/bundle/standalone/package.json +3 -2
- package/package.json +5 -3
- package/bundle/standalone/apps/web/.next/static/chunks/app/page-df34c386b7c150bb.js +0 -1
- /package/bundle/standalone/apps/web/.next/static/{yyj-uK2RH8Rffeq9wVzjU → 0ZL7PJwYf_7ZTTXE_AM0S}/_buildManifest.js +0 -0
- /package/bundle/standalone/apps/web/.next/static/{yyj-uK2RH8Rffeq9wVzjU → 0ZL7PJwYf_7ZTTXE_AM0S}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Full kontexta rules reference — written to KONTEXTA.md at the project root.
|
|
3
|
+
|
|
4
|
+
This file is the single source of truth for all kontexta workflow rules,
|
|
5
|
+
tool routing guidance, Knowledge Items (KI) policies, and content class
|
|
6
|
+
definitions. Agent context files (CLAUDE.md, GEMINI.md, AGENTS.md, etc.)
|
|
7
|
+
contain a compact stub that links here.
|
|
8
|
+
|
|
9
|
+
Authoring rules:
|
|
10
|
+
1. One clause per cell. <= 80 chars. Verbs, no fluff.
|
|
11
|
+
2. "When NOT" is the documented failure mode, not a hypothetical edge case.
|
|
12
|
+
3. "Use instead" is the BETTER sibling tool. Empty if no sibling.
|
|
13
|
+
4. Every row stands alone — no cross-references.
|
|
14
|
+
5. Every new server.tool() in apps/mcp/src/index.ts MUST add a row in the
|
|
15
|
+
relevant bucket below AND bump rulesVersion in packages/core/package.json.
|
|
16
|
+
Tests enforce this.
|
|
17
|
+
|
|
18
|
+
The placeholder {{VERSION}} is substituted at runtime with RULE_BLOCK_VERSION.
|
|
19
|
+
-->
|
|
20
|
+
# Kontexta Rules Reference v{{VERSION}}
|
|
21
|
+
|
|
22
|
+
This project is registered with kontexta. Honor these rules to keep the index, history, and journal coherent — and to avoid burning tokens on workflows kontexta already solves. Tools live under the `kxta` MCP server.
|
|
23
|
+
|
|
24
|
+
## Core rules
|
|
25
|
+
|
|
26
|
+
**Print the session welcome as your first message.** On the very first turn of any new session, call `admin_refresh_session_context` and print a brief greeting to the user based on what it returns — today's date, their name from the profile, upcoming events / conflicts if any, a nudge if the profile is empty or stale. 1–3 lines, not a report. Two reasons: (1) if the client lazy-loads MCP servers, this is what actually triggers `initialize`; (2) the user sees kontexta is connected and knows what context you have. Skip if the user's first message is already a work request — do the work.
|
|
27
|
+
|
|
28
|
+
**Search before reading.** Use `files_search` (ranked matches with excerpts; add `include_bodies: true` only when you need several files at once, with a small `max_tokens`) or `files_regex_search` to find context first, then `files_read` the top hit. Skipping straight to `files_read` on a guessed path wastes tokens and often misses the right file.
|
|
29
|
+
|
|
30
|
+
**All KB writes go through kontexta.** Use `files_create` / `files_update` (pass `section` for a surgical single-heading edit) / `journal_write`. **Never** edit a KB file with raw filesystem tools (Edit/Write/cat) — the watcher and FTS index will diverge until `projects_refresh_index` runs, and subsequent searches will return stale results. **Never write context artifacts directly into the project repository.** All diagrams, event/timeline charts, specs, mockups, and notes belong in the KB via `files_create` (`destination: "knowledge"`). Never use agent filesystem tools (`write_to_file`, `create_file`, bash redirects) to create context or `.mmd` files in the project workspace — doing so pollutes the project repo and triggers unexpected git commits.
|
|
31
|
+
|
|
32
|
+
**Batch reads. Don't loop `files_read`.** Need ≥2 files? Call `files_read` with `ids: [...]` (one round-trip, up to 200 IDs) or `files_search` with `include_bodies: true` and a modest `max_tokens` (default 12000). Looping single-ID `files_read` calls wastes round-trips and inflates response overhead.
|
|
33
|
+
|
|
34
|
+
**Address `journal.suggested_action` before the next tool call.** Many tool responses include a `journal` envelope. If `journal.suggested_action` is set (e.g., `"journal_distill"`), call that tool before issuing your next tool. To dismiss for the rest of the session, pass `journal_acknowledge: true` on your next tool call.
|
|
35
|
+
|
|
36
|
+
**Relay `hooks` prompts once per session.** If a tool response carries a `hooks.prompt` (or the session welcome mentions hooks), tell the user once that kontexta can capture their conversation and shell commands for the agents they enabled. Only call `admin_onboard_agent` with `hooks: true` after they agree.
|
|
37
|
+
|
|
38
|
+
**Use `journal_write({kind: "note", text, tags})` for decisions and abandonments.** When you make a non-obvious call, try something that doesn't work, or capture a workaround, log it. Hands runs are auto-captured now.
|
|
39
|
+
|
|
40
|
+
**Use `journal_write({kind: "intent", summary})` when the user pivots.** One short sentence so the distillation step knows the topic shifted.
|
|
41
|
+
|
|
42
|
+
**Strict mode awareness.** If a project sets `journal.mode = "strict"` in its `kontexta.json`, the MCP server returns a `JOURNAL_BACKLOG` error on read tools (search/read_*/list_*) when undistilled events exist. The error includes `next_action: "journal_distill"`. Either run `journal_distill` first, OR pass `journal_bypass: true` on the read call to override (logged for audit).
|
|
43
|
+
|
|
44
|
+
**Confirm Hands tokens within 60 seconds.** When a Hands tool returns an approval token, do NOT chain a long question or another tool call before `hands_confirm`. Tokens expire; the user will have to re-issue the whole flow.
|
|
45
|
+
|
|
46
|
+
**Save specs to a canonical location.** When generating a spec, plan, or design doc, write it to the KB at `specs/<project-name>/<spec-name>.md` (use `files_create` with `destination: "knowledge"`, `folder: "specs/<project-name>"`). One folder per project keeps specs queryable.
|
|
47
|
+
|
|
48
|
+
**Tag new KB files at creation time.** Pass `tags` on `files_create`, or call `tags_add` immediately after. Untagged files are recoverable but invisible to `files_find_related`.
|
|
49
|
+
|
|
50
|
+
**`admin_overview({mode: "whats_new"})` early. `admin_commit_backup` late.** Run it at session start if you've been away — it returns files added/changed since a cutoff. End the session with `admin_commit_backup` if you mutated KB files and the project has a remote.
|
|
51
|
+
|
|
52
|
+
**Use `.mmd` for diagrams, not fenced code in `.md`.** When creating an architecture / flow / sequence diagram, or visualizing calendar events/timelines, call `files_create` with `format: "mmd"` and `destination: "knowledge"`, putting the raw mermaid source as the body (no ```` ```mermaid ```` fence). Never write `.mmd` files directly into the project repo. The web UI renders `.mmd` files as live diagrams with SVG/PNG export; mermaid embedded in markdown is just text. Default folder: `mermaid/` (or `<project>/mermaid/` for project-scoped diagrams).
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Knowledge Items (KI)
|
|
56
|
+
|
|
57
|
+
KIs are curated, distilled KB files — the highest-signal context in the vault.
|
|
58
|
+
They save tokens and prevent redundant research when used correctly.
|
|
59
|
+
|
|
60
|
+
**Check KIs before independent research.** At the start of any task, run
|
|
61
|
+
`files_search` over the KB for the task topic (no bodies first; `files_read` the best hit). If a matching KI
|
|
62
|
+
exists, read it before writing code, designing architecture, or forming a plan.
|
|
63
|
+
Skipping this step is the single most common source of duplicated work.
|
|
64
|
+
|
|
65
|
+
**KIs are starting points, not ground truth.** KIs are snapshots. Always
|
|
66
|
+
cross-reference a KI's API patterns, file paths, and config values against the
|
|
67
|
+
*current* source on disk before acting on them. KIs can lag behind code.
|
|
68
|
+
|
|
69
|
+
**Close the loop: update the KI after significant changes.** When you ship a
|
|
70
|
+
meaningful change (new API, config schema change, architecture shift), update
|
|
71
|
+
the relevant KI via `files_update` (whole file or, with `section`, one heading). If no KI exists
|
|
72
|
+
yet, create one with `files_create` under `knowledge/` with appropriate tags.
|
|
73
|
+
A KI that isn't maintained becomes noise — which is worse than no KI.
|
|
74
|
+
|
|
75
|
+
**Use `admin_overview({mode: "whats_new"})` at session start after a gap.** If you haven't touched the
|
|
76
|
+
project in a while, run it with `since: "7d"` to surface recently changed
|
|
77
|
+
files — including KIs updated by other agents or the user.
|
|
78
|
+
|
|
79
|
+
## Content class
|
|
80
|
+
|
|
81
|
+
`files_create` requires `kind` for KB writes (single file or `files` array, both):
|
|
82
|
+
- **`dictionary`** = source of truth (mappings, glossaries, runbooks, PR templates, architecture docs)
|
|
83
|
+
- **`note`** = snapshot (meeting notes, PR findings, sprint reviews, post-mortems, working thoughts)
|
|
84
|
+
|
|
85
|
+
Test: *if this file disagreed with the code, who wins?* File wins → dictionary; file loses → note. Search ranks dictionary hits above everything else; filter with `kind` on any read tool for one class. `journal`/`project` are auto-assigned — don't pass them to `files_create`.
|
|
86
|
+
|
|
87
|
+
## Folder structure
|
|
88
|
+
|
|
89
|
+
All files and context artifacts created through kontexta must strictly follow this folder hierarchy inside the Knowledge Base (`destination: "knowledge"`):
|
|
90
|
+
- **HTML reports:** `html/` (use `files_create` with `format: "html"`, `destination: "knowledge"`)
|
|
91
|
+
- **Mermaid diagrams (`.mmd`):** `mermaid/` (use `files_create` with `format: "mmd"`, `destination: "knowledge"`)
|
|
92
|
+
- **Journals:** `journal/` (managed via `journal_write` / `journal_distill`)
|
|
93
|
+
- **Knowledge Base files:** `knowledge/dictionary/` (`kind: "dictionary"` for authoritative sources of truth) or `knowledge/notes/` (`kind: "note"` for working notes, meeting notes, and snapshots)
|
|
94
|
+
|
|
95
|
+
Never create context or diagram files directly in the project workspace or outside these designated folders.
|
|
96
|
+
|
|
97
|
+
## Tool reference
|
|
98
|
+
|
|
99
|
+
The matrix below is grouped by intent. For each tool: when to reach for it, the most common wrong context, and the better sibling tool when wrong.
|
|
100
|
+
|
|
101
|
+
### Find
|
|
102
|
+
|
|
103
|
+
| Tool | When | Not when | Use instead |
|
|
104
|
+
|---|---|---|---|
|
|
105
|
+
| `files_search` | Natural-language keyword across KB (FTS); `include_bodies: true` returns a bundle of hits + bodies capped at `max_tokens` (default 12000); use it sparingly | Substrings, URLs, code idents | `files_regex_search` |
|
|
106
|
+
| `files_regex_search` | Substrings, URLs, code identifiers across files; pass `file_id` to scan just one known file | Natural-language queries | `files_search` |
|
|
107
|
+
| `files_find_related` | Discover siblings via tag overlap | Text content matching | `files_search` |
|
|
108
|
+
| `tags_suggest` | Propose tags for an existing file | Finding files by tag | `files_find_related` |
|
|
109
|
+
|
|
110
|
+
### Read
|
|
111
|
+
|
|
112
|
+
| Tool | When | Not when | Use instead |
|
|
113
|
+
|---|---|---|---|
|
|
114
|
+
| `files_read` | One file (`id` or `path`), a batch (`ids`), or a partial read (`section` or `lines`) | Only metadata needed | `files_describe` |
|
|
115
|
+
| `files_read_outline` | Triaging an unfamiliar file's structure | Structure already known | `files_describe` |
|
|
116
|
+
| `files_describe` | Metadata only (size, tags, mtime) | Need content | `files_read` |
|
|
117
|
+
| `admin_get_profile` | Read user profile/context at session start | Reading normal files | `files_read` |
|
|
118
|
+
|
|
119
|
+
### Write
|
|
120
|
+
|
|
121
|
+
| Tool | When | Not when | Use instead |
|
|
122
|
+
|---|---|---|---|
|
|
123
|
+
| `files_create` | One new file, or a `files` array for bulk-creating ≥2 (md, mmd, or html via `format`) | File already exists | `files_update` |
|
|
124
|
+
| `files_update` | Replacing the whole body, or a surgical edit at a known heading via `section` | File doesn't exist yet | `files_create` |
|
|
125
|
+
| `files_delete` | One file, or an `ids` array for bulk delete | Want to keep the file but hide it | `tags_remove` / `tags_set_favorite` |
|
|
126
|
+
| `files_move` | Rename or relocate a file | File content needs changing | `files_update` |
|
|
127
|
+
|
|
128
|
+
### Organize
|
|
129
|
+
|
|
130
|
+
| Tool | When | Not when | Use instead |
|
|
131
|
+
|---|---|---|---|
|
|
132
|
+
| `tags_add` | Tag an existing file | Tagging at creation time | `files_create` (with `tags` param) |
|
|
133
|
+
| `tags_remove` | Untag a file | Want to delete the file | `files_delete` |
|
|
134
|
+
| `tags_list` | Enumerate all tags in the vault | Want files for a given tag | `files_find_related` |
|
|
135
|
+
| `tags_set_favorite` | Pin / unpin a file | Semantic categorization | `tags_add` |
|
|
136
|
+
| `tags_search` | Bulk-tag every hit from a search | Tagging a single file | `tags_add` |
|
|
137
|
+
| `journal_write` | Log an event: `kind: "note"` (decision/workaround), `kind: "intent"` (topic pivot), or `kind: "append"` (timestamped daily journal entry) | Summarizing accumulated events | `journal_distill` |
|
|
138
|
+
| `journal_distill` | Summarize accumulated journal events | Individual events | `journal_write` |
|
|
139
|
+
| `journal_status` | Check backlog size and high-water mark before distilling | Need the raw events themselves | `journal_distill` |
|
|
140
|
+
| `journal_commit_upgrades` | Mark journal entries upgraded after a subagent rewrites them | Running the initial distillation | `journal_distill` |
|
|
141
|
+
| `journal_housekeep` | Prune old raw journal files and archive cold tasks | Need to distill new events first | `journal_distill` |
|
|
142
|
+
| `resources_clip_url` | Capture a web URL into the KB | Saving a local file | `files_create` |
|
|
143
|
+
| `folders_list` | Enumerate folders in the project | Finding files | `files_list` |
|
|
144
|
+
| `folders_create` | Create a new (possibly nested) folder | Files don't need explicit folders | |
|
|
145
|
+
| `folders_delete` | Remove an empty folder | Folder still has files | `files_delete` (bulk) first |
|
|
146
|
+
|
|
147
|
+
### Reports
|
|
148
|
+
|
|
149
|
+
| Tool | When | Not when | Use instead |
|
|
150
|
+
|---|---|---|---|
|
|
151
|
+
| `resources_add_report` | Add an image to the shared `reports/resources/` pool | Embedding data URIs | |
|
|
152
|
+
| `resources_list_reports` | List all shared report resources | Need full file list | `files_list` |
|
|
153
|
+
| `resources_delete_report` | Delete a shared resource by name | Deleting a report file | `files_delete` |
|
|
154
|
+
| `resources_export_report` | Export an HTML report as PDF or PNG | Exporting markdown | |
|
|
155
|
+
|
|
156
|
+
### History & recovery
|
|
157
|
+
|
|
158
|
+
| Tool | When | Not when | Use instead |
|
|
159
|
+
|---|---|---|---|
|
|
160
|
+
| `files_get_history` | List a file's revisions | Want a diff between two revisions | `files_get_diff` |
|
|
161
|
+
| `files_get_diff` | Compare two specific revisions | Want full content of one | `files_restore` |
|
|
162
|
+
| `files_restore` | Roll back a KB file to an earlier revision | Want to use raw `git` | |
|
|
163
|
+
| `files_diff_against_disk` | Find drift after raw filesystem edits | Normal search staleness | `projects_refresh_index` |
|
|
164
|
+
| `projects_refresh_index` | Rescan after out-of-band changes | Normal in-app edits | |
|
|
165
|
+
| `admin_commit_backup` | Push KB changes to remote git | Local-only work | |
|
|
166
|
+
|
|
167
|
+
### Discover
|
|
168
|
+
|
|
169
|
+
| Tool | When | Not when | Use instead |
|
|
170
|
+
|---|---|---|---|
|
|
171
|
+
| `projects_list` | Enumerate registered projects | Files within one project | `files_list` |
|
|
172
|
+
| `files_list` | Files in a project (filterable) | Full-text content matters | `files_search` |
|
|
173
|
+
| `projects_map` | Folder/file tree for a project | Flat file list | `files_list` |
|
|
174
|
+
| `admin_overview` | `mode: "stats"` for counts/health, `mode: "whats_new"` for files changed since a cutoff | Per-file detail or full-text search | `files_describe` / `files_search` |
|
|
175
|
+
| `admin_refresh_session_context` | Re-fetch profile + upcoming events after mid-session edits | Reading a single profile field | `admin_get_profile` |
|
|
176
|
+
|
|
177
|
+
### Calendar
|
|
178
|
+
|
|
179
|
+
| Tool | When | Not when | Use instead |
|
|
180
|
+
|---|---|---|---|
|
|
181
|
+
| `calendar_entities_add` | Register a new thing to track (server, vehicle, location, etc.) | Entity already exists | `calendar_entities_update` |
|
|
182
|
+
| `calendar_entities_update` | Rename, retag, or retire (`active:false`) an entity | Entity doesn't exist yet | `calendar_entities_add` |
|
|
183
|
+
| `calendar_entities_delete` | Permanently remove an entity, cascading its events/links | Just want to stop scheduling against it | `calendar_entities_update` |
|
|
184
|
+
| `calendar_entities_list` | Enumerate entities with their dependency links | Need conflict or event data | `calendar_events_conflicts` |
|
|
185
|
+
| `calendar_entities_link` | Record or remove a dependency edge for conflict detection | Want to see existing links | `calendar_entities_list` |
|
|
186
|
+
| `calendar_events_add` | Schedule a one-off event (downtime, maintenance, delivery, etc.) | Editing an existing event | `calendar_events_update` |
|
|
187
|
+
| `calendar_events_update` | Move, retitle, or re-home an existing event | Event doesn't exist yet | `calendar_events_add` |
|
|
188
|
+
| `calendar_events_delete` | Remove one event permanently | Want to just move it | `calendar_events_update` |
|
|
189
|
+
| `calendar_events_list` | List/filter events in a time window | Only need the conflict report | `calendar_events_conflicts` |
|
|
190
|
+
| `calendar_events_conflicts` | Find overlapping or too-close-together events in a window | Just need the raw event list | `calendar_events_list` |
|
|
191
|
+
| `calendar_export_ics` | Export a window as an ICS file for calendar apps | Need machine-readable event data | `calendar_events_list` |
|
|
192
|
+
|
|
193
|
+
### Hands (project tools)
|
|
194
|
+
|
|
195
|
+
| Tool | When | Not when | Use instead |
|
|
196
|
+
|---|---|---|---|
|
|
197
|
+
| `hands_list` | Enumerate Hands tools; pass `schema: true` for the `kontexta.json` authoring reference | Neither list nor schema needed | |
|
|
198
|
+
| `hands_confirm` | Approve a Hands token within 60s of issue | Normal MCP tool calls | |
|
|
199
|
+
| `hands_reload` | Re-read `hands.yaml` after editing it | First-time use (auto-loads) | |
|
|
200
|
+
|
|
201
|
+
### Onboarding
|
|
202
|
+
|
|
203
|
+
| Tool | When | Not when | Use instead |
|
|
204
|
+
|---|---|---|---|
|
|
205
|
+
| `projects_register` | Register a new project root with kontexta | Already registered | `projects_list` |
|
|
206
|
+
| `admin_onboard_agent` | Write/update the rules block in CLAUDE.md / AGENTS.md / etc. | Editing regular project content | `files_update` |
|
|
207
|
+
| `admin_transfer_agent_context` | Copy CLAUDE.md / AGENTS.md / `.cursor/rules/*.mdc` etc. from the project repo into Kontexta's KB. Originals are NEVER deleted by this tool. | User wants files to stay in the repo (default) | `projects_register` (which keeps files in place) |
|
|
@@ -3,14 +3,32 @@ export type BundleFormat = "xml" | "markdown";
|
|
|
3
3
|
export interface BundleOptions {
|
|
4
4
|
format?: BundleFormat;
|
|
5
5
|
max_tokens?: number;
|
|
6
|
+
/** When true, rerank BM25 candidates with cross-encoder before packing */
|
|
7
|
+
rerank?: boolean;
|
|
8
|
+
/** Override candidate pool limit (default 30) */
|
|
9
|
+
candidate_limit?: number;
|
|
10
|
+
/** Override dictionary_boost for cross-encoder arbitration */
|
|
11
|
+
dictionary_boost?: number;
|
|
12
|
+
/** When true, evaluate retrieval sufficiency */
|
|
13
|
+
check_sufficiency?: boolean;
|
|
14
|
+
/** Minimum normalized score for a candidate to be packed (default 0.15). */
|
|
15
|
+
relevance_floor?: number;
|
|
16
|
+
/** When false, skip the pre-retrieval intent routing pass. */
|
|
17
|
+
intent_routing?: boolean;
|
|
18
|
+
/** Override the cross-encoder model identifier. */
|
|
19
|
+
model?: string;
|
|
20
|
+
/** Override the reranker hard timeout (ms). */
|
|
21
|
+
timeout_ms?: number;
|
|
6
22
|
}
|
|
7
23
|
export interface BundleIncludedItem {
|
|
8
24
|
id: number;
|
|
9
25
|
path: string;
|
|
10
26
|
est_tokens: number;
|
|
27
|
+
/** Final reranked score, if reranking was applied */
|
|
28
|
+
rerank_score?: number;
|
|
11
29
|
}
|
|
12
30
|
export interface BundleSkippedItem extends BundleIncludedItem {
|
|
13
|
-
reason: "would_exceed_budget";
|
|
31
|
+
reason: "would_exceed_budget" | "below_relevance_threshold";
|
|
14
32
|
}
|
|
15
33
|
export interface BundleResult {
|
|
16
34
|
bundle: string;
|
|
@@ -18,6 +36,12 @@ export interface BundleResult {
|
|
|
18
36
|
query: string;
|
|
19
37
|
format: BundleFormat;
|
|
20
38
|
total_est_tokens: number;
|
|
39
|
+
intent?: string;
|
|
40
|
+
sufficiency?: {
|
|
41
|
+
satisfied: boolean;
|
|
42
|
+
confidence: number;
|
|
43
|
+
};
|
|
44
|
+
warning?: string;
|
|
21
45
|
included: BundleIncludedItem[];
|
|
22
46
|
skipped: BundleSkippedItem[];
|
|
23
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,UAAU,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,MAAM,EAAE,qBAAqB,GAAG,2BAA2B,CAAC;CAC7D;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE;YACZ,SAAS,EAAE,OAAO,CAAC;YACnB,UAAU,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,kBAAkB,EAAE,CAAC;QAC/B,OAAO,EAAE,iBAAiB,EAAE,CAAC;KAC9B,CAAC;CACH;AAsED,wBAAsB,YAAY,CAChC,OAAO,EAAE,aAAa,EACtB,IAAI,GAAE,aAAkB,GACvB,OAAO,CAAC,YAAY,CAAC,CA0LvB"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// packages/core/src/bundle/index.ts
|
|
2
|
-
import { statSync } from "node:fs";
|
|
3
2
|
import { getDatabase } from "../db/index.js";
|
|
4
3
|
import { search } from "../metadata/index.js";
|
|
5
4
|
import { readFile } from "../files/index.js";
|
|
6
5
|
import { estimateTokensFromString } from "../util/tokens.js";
|
|
6
|
+
import { arbitrateCandidates, rerankCandidates } from "../rerank/index.js";
|
|
7
|
+
import { pruneLowRelevanceCandidates } from "../decision/pruning.js";
|
|
8
|
+
import { routeQueryIntent } from "../decision/intent-router.js";
|
|
9
|
+
import { evaluateSufficiency } from "../decision/sufficiency.js";
|
|
7
10
|
function getProjectName(projectId) {
|
|
8
11
|
if (projectId == null)
|
|
9
12
|
return "";
|
|
@@ -62,54 +65,178 @@ function renderMarkdown(docs) {
|
|
|
62
65
|
}
|
|
63
66
|
export async function bundleSearch(filters, opts = {}) {
|
|
64
67
|
const format = opts.format ?? "xml";
|
|
65
|
-
const max_tokens = opts.max_tokens ??
|
|
66
|
-
// Pass through a generous limit so a large token budget isn't silently
|
|
67
|
-
// capped at search()'s default of 50. Cap at 1000 (search()'s hard ceiling)
|
|
68
|
-
// — beyond that, a single bundle is unlikely to fit any usable budget.
|
|
69
|
-
const hits = search({ ...filters, limit: filters.limit ?? 1000 });
|
|
70
|
-
const included = [];
|
|
68
|
+
const max_tokens = opts.max_tokens ?? 12000;
|
|
71
69
|
const skipped = [];
|
|
70
|
+
let queryIntent;
|
|
71
|
+
let dictionaryBoost = opts.dictionary_boost;
|
|
72
|
+
// Step 1: Pre-retrieval Query Intent Routing (if reranking is enabled and intent routing not disabled)
|
|
73
|
+
if (opts.rerank && opts.intent_routing !== false) {
|
|
74
|
+
try {
|
|
75
|
+
const intentResult = await routeQueryIntent(filters.query);
|
|
76
|
+
queryIntent = intentResult.intent;
|
|
77
|
+
if (dictionaryBoost === undefined) {
|
|
78
|
+
dictionaryBoost = intentResult.dictionary_boost;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Ignore intent routing failure
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Step 2: Fetch candidate pool (unbiased BM25 if reranking)
|
|
86
|
+
const candidateLimit = opts.candidate_limit ?? (opts.rerank ? Math.max(filters.limit ?? 30, 30) : (filters.limit ?? 1000));
|
|
87
|
+
let hits;
|
|
88
|
+
if (opts.rerank) {
|
|
89
|
+
hits = search({ ...filters, limit: candidateLimit, raw_bm25_order: true });
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
hits = search({ ...filters, limit: filters.limit ?? 1000 });
|
|
93
|
+
}
|
|
94
|
+
// Step 3: Neural reranking pipeline (only when enabled and hits exist)
|
|
95
|
+
let rankedCandidates = hits.map((h) => ({
|
|
96
|
+
id: h.id,
|
|
97
|
+
title: h.title,
|
|
98
|
+
path: h.path,
|
|
99
|
+
content: "",
|
|
100
|
+
content_class: h.content_class ?? null,
|
|
101
|
+
project_id: h.project_id ?? null,
|
|
102
|
+
bm25_rank: h.rank,
|
|
103
|
+
}));
|
|
104
|
+
const contentMap = new Map();
|
|
105
|
+
if (opts.rerank && hits.length > 0) {
|
|
106
|
+
// Read content for candidates so cross-encoder can evaluate passages
|
|
107
|
+
const candidatesWithContent = [];
|
|
108
|
+
for (const h of hits) {
|
|
109
|
+
let content = "";
|
|
110
|
+
try {
|
|
111
|
+
const file = readFile(h.id);
|
|
112
|
+
content = file.content;
|
|
113
|
+
contentMap.set(h.id, file.content);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// Ignored
|
|
117
|
+
}
|
|
118
|
+
candidatesWithContent.push({
|
|
119
|
+
id: h.id,
|
|
120
|
+
title: h.title,
|
|
121
|
+
path: h.path,
|
|
122
|
+
content,
|
|
123
|
+
content_class: h.content_class ?? null,
|
|
124
|
+
project_id: h.project_id ?? null,
|
|
125
|
+
bm25_rank: h.rank,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (hits.length > 1) {
|
|
129
|
+
// Run cross-encoder reranking
|
|
130
|
+
const scored = await rerankCandidates(filters.query, candidatesWithContent, {
|
|
131
|
+
model: opts.model,
|
|
132
|
+
timeout_ms: opts.timeout_ms,
|
|
133
|
+
candidate_limit: candidateLimit,
|
|
134
|
+
dictionary_boost: dictionaryBoost,
|
|
135
|
+
});
|
|
136
|
+
if (scored && scored.length > 0) {
|
|
137
|
+
// Apply soft content-class arbitration
|
|
138
|
+
const arbitrated = arbitrateCandidates(scored, {
|
|
139
|
+
dictionary_boost: dictionaryBoost,
|
|
140
|
+
});
|
|
141
|
+
// Prune low-relevance candidates
|
|
142
|
+
const pruned = pruneLowRelevanceCandidates(arbitrated, opts.relevance_floor ?? 0.15);
|
|
143
|
+
const prunedIds = new Set(pruned.map((p) => p.id));
|
|
144
|
+
for (const c of arbitrated) {
|
|
145
|
+
if (!prunedIds.has(c.id)) {
|
|
146
|
+
const content = contentMap.get(c.id) ?? "";
|
|
147
|
+
const est = estimateTokensFromString(content);
|
|
148
|
+
skipped.push({
|
|
149
|
+
id: c.id,
|
|
150
|
+
path: c.path,
|
|
151
|
+
est_tokens: est,
|
|
152
|
+
rerank_score: c.final_score,
|
|
153
|
+
reason: "below_relevance_threshold",
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
rankedCandidates = pruned;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
rankedCandidates = candidatesWithContent;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
rankedCandidates = candidatesWithContent;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Step 4: Sufficiency check (if enabled and candidates available)
|
|
168
|
+
let sufficiencyVerdict;
|
|
169
|
+
let sufficiencyWarning;
|
|
170
|
+
if (opts.rerank && opts.check_sufficiency !== false && rankedCandidates.length > 0) {
|
|
171
|
+
try {
|
|
172
|
+
const excerpts = rankedCandidates.slice(0, 3).map((c) => {
|
|
173
|
+
const text = contentMap.get(c.id) ?? c.content ?? "";
|
|
174
|
+
return `${c.title}\n${text.slice(0, 500)}`;
|
|
175
|
+
});
|
|
176
|
+
sufficiencyVerdict = await evaluateSufficiency(filters.query, excerpts);
|
|
177
|
+
if (!sufficiencyVerdict.satisfied) {
|
|
178
|
+
sufficiencyWarning = "Context may be insufficient or tangential";
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
// Ignore sufficiency evaluation error
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Step 5: Greedy token packing from ranked candidates
|
|
186
|
+
const included = [];
|
|
72
187
|
const docs = [];
|
|
73
188
|
let total_est_tokens = 0;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
// Avoid reading the file just to estimate; use file size as a proxy
|
|
78
|
-
// (~4 bytes/token, the same heuristic as estimateTokensFromString).
|
|
79
|
-
let est_tokens = 0;
|
|
189
|
+
for (const candidate of rankedCandidates) {
|
|
190
|
+
let content = contentMap.get(candidate.id);
|
|
191
|
+
if (content === undefined) {
|
|
80
192
|
try {
|
|
81
|
-
|
|
193
|
+
const file = readFile(candidate.id);
|
|
194
|
+
content = file.content;
|
|
195
|
+
contentMap.set(candidate.id, content);
|
|
82
196
|
}
|
|
83
|
-
catch {
|
|
197
|
+
catch {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const est = estimateTokensFromString(content);
|
|
202
|
+
if (total_est_tokens + est > max_tokens) {
|
|
84
203
|
skipped.push({
|
|
85
|
-
id:
|
|
86
|
-
path:
|
|
87
|
-
est_tokens,
|
|
204
|
+
id: candidate.id,
|
|
205
|
+
path: candidate.path,
|
|
206
|
+
est_tokens: est,
|
|
207
|
+
rerank_score: "final_score" in candidate ? candidate.final_score : undefined,
|
|
88
208
|
reason: "would_exceed_budget",
|
|
89
209
|
});
|
|
90
210
|
continue;
|
|
91
211
|
}
|
|
92
|
-
const file = readFile(hit.id);
|
|
93
|
-
const est = estimateTokensFromString(file.content);
|
|
94
|
-
if (total_est_tokens + est > max_tokens) {
|
|
95
|
-
skipped.push({ id: hit.id, path: hit.path, est_tokens: est, reason: "would_exceed_budget" });
|
|
96
|
-
stopped = true;
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
212
|
docs.push({
|
|
100
|
-
id:
|
|
101
|
-
path:
|
|
102
|
-
project: getProjectName(
|
|
103
|
-
tags: getTagNames(
|
|
104
|
-
content
|
|
213
|
+
id: candidate.id,
|
|
214
|
+
path: candidate.path,
|
|
215
|
+
project: getProjectName(candidate.project_id ?? null),
|
|
216
|
+
tags: getTagNames(candidate.id),
|
|
217
|
+
content,
|
|
218
|
+
});
|
|
219
|
+
included.push({
|
|
220
|
+
id: candidate.id,
|
|
221
|
+
path: candidate.path,
|
|
222
|
+
est_tokens: est,
|
|
223
|
+
rerank_score: "final_score" in candidate ? candidate.final_score : undefined,
|
|
105
224
|
});
|
|
106
|
-
included.push({ id: hit.id, path: hit.path, est_tokens: est });
|
|
107
225
|
total_est_tokens += est;
|
|
108
226
|
}
|
|
109
227
|
const bundle = docs.length === 0 ? "" : (format === "xml" ? renderXml(docs) : renderMarkdown(docs));
|
|
110
228
|
return {
|
|
111
229
|
bundle,
|
|
112
|
-
meta: {
|
|
230
|
+
meta: {
|
|
231
|
+
query: filters.query,
|
|
232
|
+
format,
|
|
233
|
+
total_est_tokens,
|
|
234
|
+
intent: queryIntent,
|
|
235
|
+
sufficiency: sufficiencyVerdict,
|
|
236
|
+
warning: sufficiencyWarning,
|
|
237
|
+
included,
|
|
238
|
+
skipped,
|
|
239
|
+
},
|
|
113
240
|
};
|
|
114
241
|
}
|
|
115
242
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oB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CAAC,IAAI,CAAC;YACZ,EAAE,EAAE,SAAS,CAAC,EAAE;YAChB,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;SAC7E,CAAC,CAAC;QACH,gBAAgB,IAAI,GAAG,CAAC;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAEpG,OAAO;QACL,MAAM;QACN,IAAI,EAAE;YACJ,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM;YACN,gBAAgB;YAChB,MAAM,EAAE,WAAW;YACnB,WAAW,EAAE,kBAAkB;YAC/B,OAAO,EAAE,kBAAkB;YAC3B,QAAQ;YACR,OAAO;SACR;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision engine for classification, verdict evaluation, and scoring.
|
|
3
|
+
*
|
|
4
|
+
* Uses the inference runtime to load decision models on demand.
|
|
5
|
+
* All methods return deterministic fallback values on failure.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChoiceDecision, BinaryVerdict, ScoreRating } from "./types.js";
|
|
8
|
+
declare class DecisionEngine {
|
|
9
|
+
/**
|
|
10
|
+
* Check if a decision model is available and ready for inference.
|
|
11
|
+
*/
|
|
12
|
+
isAvailable(): Promise<boolean>;
|
|
13
|
+
private hasInferenceImplementation;
|
|
14
|
+
/**
|
|
15
|
+
* Cheap, I/O-free readiness check: true only when a concrete inference
|
|
16
|
+
* implementation exists. Callers use this to avoid triggering model
|
|
17
|
+
* downloads when there is nothing to run them against.
|
|
18
|
+
*/
|
|
19
|
+
private isReady;
|
|
20
|
+
/**
|
|
21
|
+
* Lazily obtain the decision model session (loads on first use).
|
|
22
|
+
*/
|
|
23
|
+
private session;
|
|
24
|
+
/**
|
|
25
|
+
* Classify context among multiple options.
|
|
26
|
+
*
|
|
27
|
+
* Constructs a prompt asking the model to choose the best option
|
|
28
|
+
* given the context, then returns the selected option with confidence
|
|
29
|
+
* and distribution.
|
|
30
|
+
*
|
|
31
|
+
* @param context - The context to classify
|
|
32
|
+
* @param options - Available options to choose from
|
|
33
|
+
* @returns ChoiceDecision with selected option, confidence, and distribution
|
|
34
|
+
*/
|
|
35
|
+
classifyChoice<T extends string = string>(context: string, options: T[]): Promise<ChoiceDecision<T>>;
|
|
36
|
+
/**
|
|
37
|
+
* Evaluate a binary verdict on whether context satisfies a question.
|
|
38
|
+
*
|
|
39
|
+
* @param context - The context to evaluate
|
|
40
|
+
* @param question - The question to answer (yes/no)
|
|
41
|
+
* @returns BinaryVerdict with verdict, confidence, and raw logit
|
|
42
|
+
*/
|
|
43
|
+
evaluateVerdict(context: string, question: string): Promise<BinaryVerdict>;
|
|
44
|
+
/**
|
|
45
|
+
* Rate context against criteria on a 0–4 scale.
|
|
46
|
+
*
|
|
47
|
+
* @param context - The context to rate
|
|
48
|
+
* @param criteria - The criteria to rate against
|
|
49
|
+
* @returns ScoreRating with discrete score and continuous calibrated value
|
|
50
|
+
*/
|
|
51
|
+
rateScore(context: string, criteria: string): Promise<ScoreRating>;
|
|
52
|
+
/**
|
|
53
|
+
* Run classification inference.
|
|
54
|
+
*/
|
|
55
|
+
private runClassification;
|
|
56
|
+
/**
|
|
57
|
+
* Run binary verdict inference.
|
|
58
|
+
*/
|
|
59
|
+
private runVerdict;
|
|
60
|
+
/**
|
|
61
|
+
* Run rating inference.
|
|
62
|
+
*/
|
|
63
|
+
private runRating;
|
|
64
|
+
/**
|
|
65
|
+
* Wrap a promise with a hard timeout.
|
|
66
|
+
*/
|
|
67
|
+
private withTimeout;
|
|
68
|
+
}
|
|
69
|
+
export declare const decisionEngine: DecisionEngine;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/decision/engine.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAC;AAcpB,cAAM,cAAc;IAClB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAgBrC,OAAO,CAAC,0BAA0B;IAIlC;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAIf;;OAEG;IACH,OAAO,CAAC,OAAO;IAIf;;;;;;;;;;OAUG;IACG,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC5C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,EAAE,GACX,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IA2C7B;;;;;;OAMG;IACG,eAAe,CACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,aAAa,CAAC;IAyBzB;;;;;;OAMG;IACG,SAAS,CACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;IAyBvB;;OAEG;YACW,iBAAiB;IAS/B;;OAEG;YACW,UAAU;IAQxB;;OAEG;YACW,SAAS;IAQvB;;OAEG;YACW,WAAW;CAgB1B;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|