# Code Intelligence

Code-aware indexing, search, symbols, deps, and graph workflows introduced in the v0.18 series

## [Code Intelligence](https://knowns.sh/docs/code-intelligence#code-intelligence)

Knowns includes a code-awareness layer so agents can reason from real files and symbols instead of guessing from task and doc text alone.

### [What It Provides](https://knowns.sh/docs/code-intelligence#what-it-provides)

- AST-based indexing for supported source files
- Dedicated code workflows for ingesting, watching, searching, and inspecting dependencies
- Code-aware graph exploration in the Web UI
- MCP code tools for structured agent retrieval
- Structural knowledge retrieval (v0.20) — relation-aware traversal across entities and graph edges

This feature is opt-in. If you never index code, your existing task/doc/memory workflows keep working normally.

### [Core Flow](https://knowns.sh/docs/code-intelligence#core-flow)

```
# Build the initial code index
knowns code ingest

# Keep code index fresh while you work
knowns code watch

# Discover likely entry points
knowns code search "oauth login"

# Inspect indexed symbols in a scope
knowns code symbols

# Inspect raw code relationships
knowns code deps
```

### [Recommended Retrieval Order](https://knowns.sh/docs/code-intelligence#recommended-retrieval-order)

When you need code context, use this order:

1. `knowns code search` for entry-point discovery
2. `knowns code symbols` to verify what was indexed in a file or scope
3. `knowns code deps` to inspect raw relationships

That order matches the imported learnings for the v0.18 code graph work: search is best for discovery, symbols verify parser/index output, and deps confirm relationships.

### [What Gets Indexed](https://knowns.sh/docs/code-intelligence#what-gets-indexed)

The imported `AST Code Intelligence` spec describes these capabilities:

- Functions, methods, classes, interfaces, and file-level entries can become code chunks
- Relationship edges such as calls, imports, and contains are stored for later graph and dependency exploration
- Supported languages include Go, TypeScript, JavaScript, and Python
- Browser watch mode can keep the UI server and file watching in the same workflow

### [Web UI Support](https://knowns.sh/docs/code-intelligence#web-ui-support)

The v0.18.0 release also introduced a dedicated Code Graph experience in the Web UI:

- Show or hide code nodes separately from tasks, docs, and memories
- Explore code-connected project context visually
- Use graph details and relationships to jump from knowledge to implementation

For the browser workflow, see [Web UI](https://knowns.sh/docs/web-ui).

### [MCP Tools](https://knowns.sh/docs/code-intelligence#mcp-tools)

Agents can use the code-aware MCP tools directly (v0.20 consolidated format):

```
// Search for code symbols
code({ action: "search", query: "oauth login" })

// Inspect symbols in a file or scope
code({ action: "symbols", path: "src/auth/" })

// Inspect dependency edges
code({ action: "deps", type: "imports" })

// Get graph data for exploration
code({ action: "graph" })
```

These are a better fit for machine-readable code exploration than trying to force code results into generic text search.

### [Related](https://knowns.sh/docs/code-intelligence#related)

- [MCP Integration](https://knowns.sh/docs/mcp-integration) - structured tools for code-aware agent workflows
- [Web UI](https://knowns.sh/docs/web-ui) - code graph, workspace switching, and richer chat UI
- [Semantic Search](https://knowns.sh/docs/semantic-search) - search and retrieval behavior across docs, tasks, and memory

[Semantic Search

AI-powered search using vector embeddings for better relevance](https://knowns.sh/docs/semantic-search) [Web UI

Local interface for tasks, docs, memories, code graph, workspace switching, and built-in AI Chat](https://knowns.sh/docs/web-ui)
