# veryfront/knowledge

## Import

```ts
import {
  createSearchKnowledgeTool,
  formatKnowledgeContext,
  inspectOkfDocument,
  normalizedProjectKnowledgeScopeGrantsAnyPath,
  normalizeKnowledgeQuery,
  normalizeProjectKnowledgeScopeSelector,
} from "veryfront/knowledge";
```

## Examples

```ts
import { projectKnowledge } from "veryfront/knowledge";

const knowledge = projectKnowledge();
await knowledge.index();
const result = await knowledge.retrieve("SSO login failure");
```

## Exports

### Components

| Name                | Description                                                                        | Source                                                                                        |
| ------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `OKF_SPEC_REVISION` | Immutable upstream revision used by this reader's conformance checks.              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/okf-document.ts) |
| `OKF_SPEC_VERSION`  | Supported canonical OKF version. Existing documents are never migrated implicitly. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/okf-document.ts) |

### Functions

| Name                                           | Description                                                                                                                                                                                                                                                                                               | Source                                                                                        |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `createSearchKnowledgeTool`                    | Create a project-authored knowledge tool with a configurable ID and hosted-compatible response shape.                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `formatKnowledgeContext`                       | Format search results into a deterministic prompt context block.                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `inspectOkfDocument`                           | Inspect the basic OKF document contract at the pinned revision.                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/okf-document.ts) |
| `normalizedProjectKnowledgeScopeGrantsAnyPath` |                                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `normalizeKnowledgeQuery`                      | Normalize a knowledge query before retrieval.                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `normalizeProjectKnowledgeScopeSelector`       |                                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `projectKnowledge`                             | Create a project knowledge helper backed by the configured RAG store.                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `projectKnowledgeScopeSelectorGrantsAnyPath`   |                                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `searchProjectKnowledge`                       | Search the local OKF knowledge manifest with the response shape of Veryfront Cloud's `veryfront__search_knowledge` operation. Two inputs differ from the hosted operation: `lookup_target` names one knowledge file (a path or `{ path }`) rather than a source, and `limit` defaults to 8 rather than 6. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |

### Types

| Name                                      | Description                                                                        | Source                                                                                        |
| ----------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `CreateSearchKnowledgeToolOptions`        |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `NormalizedProjectKnowledgeScopeSelector` |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `OkfDocumentDiagnostic`                   | An actionable source defect, rather than a reason to discard document content.     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/okf-document.ts) |
| `OkfDocumentInspection`                   | Lossless source plus decoded metadata; inspection does not serialize or edit YAML. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/okf-document.ts) |
| `ProjectKnowledge`                        | Helper for indexing and retrieving project knowledge.                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeConfig`                  | Configuration for project knowledge indexing and retrieval.                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeLookupFrontmatterField`  |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeLookupInput`             |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeLookupItem`              |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeLookupOutput`            |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeLookupPageInfo`          |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeLookupShard`             |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeResult`                  | Result returned from project knowledge retrieval.                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeRetrieveOptions`         | Per-call options for project knowledge retrieval.                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `ProjectKnowledgeScopeSelector`           |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
| `SearchKnowledgeTool`                     |                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/knowledge/index.ts)        |
