Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 8 additions & 404 deletions .gitignore

Large diffs are not rendered by default.

67 changes: 66 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# RagSharp
# RagSharp

RagSharp provides a deterministic, offline-capable code graph indexer and skill installer for C#/.NET repositories. It ships a single NuGet package containing:

- `ragsharp` — installer for Codex skills.
- `ragsharp-codegraph` — code graph indexer/query CLI.

See the Codex skill specification at https://agentskills.io/specification.

## Requirements

- .NET SDK 10 (primary) with multi-targeting to net8.0 for fallback.
- Cross-platform (Windows/macOS/Linux).

## Install .NET 10

Follow the OS-specific steps in [docs/Development/SetupDotNet.md](docs/Development/SetupDotNet.md) and verify:

```bash
dotnet --info
dotnet --list-sdks
```

## Build and test RagSharp

```bash
dotnet build

dotnet test
```

## Package

```bash
dotnet pack src/RagSharp.Packaging/RagSharp.Packaging.csproj -c Release -o dist
```

## Install in another repository

From the target repository root:

```bash
dotnet add package RagSharp --source /path/to/ragsharp/dist

ragsharp install --root . --skill-dir .codex/skills
```

## Index and query

```bash
ragsharp-codegraph doctor --root .

ragsharp-codegraph index --root . --db .codegraph/index.db --state .codegraph/state.json

ragsharp-codegraph query symbols --db .codegraph/index.db --format json --limit 50 --symbol "Greeter"
```

## Output locations

- `.codex/skills/` contains installed skills.
- `.codegraph/` contains the index and state files (not committed).
- Ensure `.codegraph/` and `state.json` remain in `.gitignore`.

## Troubleshooting

See [docs/Development/Troubleshooting.md](docs/Development/Troubleshooting.md).
15 changes: 15 additions & 0 deletions assets/skill-templates/build-code-graph/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: ragsharp-build-code-graph
description: |
Build or update a code graph index for C#/.NET repositories using ragsharp-codegraph.
Triggers: build index, update index, refresh index, code graph, dependency graph, static analysis, Roslyn, line numbers.
---
## Steps
1. Run `ragsharp-codegraph doctor --root .`.
2. Run `ragsharp-codegraph index --root . --db .codegraph/index.db --state .codegraph/state.json`.
3. For incremental updates, run `ragsharp-codegraph update --root . --db .codegraph/index.db --state .codegraph/state.json`.

## Expected Results
- `.codegraph/index.db` exists.
- `.codegraph/state.json` is updated.
- Output goes to stderr, JSON is emitted only for query commands.
6 changes: 6 additions & 0 deletions assets/skill-templates/build-code-graph/references/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Build Code Graph Skill

Use this skill to initialize or refresh the code graph index.
- `ragsharp-codegraph doctor` validates tooling.
- `ragsharp-codegraph index` builds the graph.
- `ragsharp-codegraph update` applies incremental changes.
2 changes: 2 additions & 0 deletions assets/skill-templates/build-code-graph/scripts/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
param([string]$Root = ".")
ragsharp-codegraph index --root $Root --db .codegraph/index.db --state .codegraph/state.json
3 changes: 3 additions & 0 deletions assets/skill-templates/build-code-graph/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
set -euo pipefail
ragsharp-codegraph index --root "${1:-.}" --db .codegraph/index.db --state .codegraph/state.json
9 changes: 9 additions & 0 deletions assets/skill-templates/query-code-graph/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: ragsharp-query-code-graph
description: |
Query the ragsharp code graph for declarations, references, callers, callees, dependencies, and line-number evidence.
Triggers: find usages, where defined, callers, callees, dependency path, project deps, type hierarchy, line numbers, evidence.
---
## Steps
1. Run `ragsharp-codegraph query symbols --db .codegraph/index.db --format json --limit 50 --symbol "SymbolName"`.
2. Use the JSON output to answer questions with file:line-range evidence.
4 changes: 4 additions & 0 deletions assets/skill-templates/query-code-graph/references/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Query Code Graph Skill

Use query contracts defined in docs/Development/QueryContract.md and OutputSchema.md.
Each answer should cite file:line-range evidence from query results.
2 changes: 2 additions & 0 deletions assets/skill-templates/query-code-graph/scripts/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
param([string]$Symbol = "")
ragsharp-codegraph query symbols --db .codegraph/index.db --format json --limit 50 --symbol $Symbol
3 changes: 3 additions & 0 deletions assets/skill-templates/query-code-graph/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
set -euo pipefail
ragsharp-codegraph query symbols --db .codegraph/index.db --format json --limit 50 --symbol "${1:-}"
18 changes: 18 additions & 0 deletions docs/Development/CodeGraph.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Code Graph CLI

## Commands

- `ragsharp-codegraph doctor --root <path>`
- `ragsharp-codegraph index --root <path> --db .codegraph/index.db --state .codegraph/state.json`
- `ragsharp-codegraph update --root <path> --db .codegraph/index.db --state .codegraph/state.json`
- `ragsharp-codegraph query <queryType> --db .codegraph/index.db --format json --limit N --context-lines M`
- `ragsharp-codegraph export --db .codegraph/index.db --format dot|gexf --out .codegraph/graph.dot`

## Files\n\n- `.codegraph/index.db` — SQLite graph database.\n- `.codegraph/state.json` — incremental index state.\n- `.codegraph/schema_version` — schema version guard.\n+
Copy link

Copilot AI Jan 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra newline escape sequence in the middle of the line. The text "## Files\n\n- " should be "## Files" followed by a proper newline and bullet list.

Suggested change
## Files\n\n- `.codegraph/index.db` — SQLite graph database.\n- `.codegraph/state.json` — incremental index state.\n- `.codegraph/schema_version` — schema version guard.\n+
## Files
- `.codegraph/index.db` — SQLite graph database.
- `.codegraph/state.json` — incremental index state.
- `.codegraph/schema_version` — schema version guard.

Copilot uses AI. Check for mistakes.
## Exit codes

- 0: success
- 2: invalid arguments
- 3: environment error
- 4: index missing
- 5: schema mismatch
38 changes: 38 additions & 0 deletions docs/Development/OutputSchema.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Output Schema

```json
{
"schemaVersion": "1",
"nodes": [
{
"id": 1,
"kind": "Type",
"name": "Greeter",
"fullyQualifiedName": "SampleApp.Greeter",
"documentPath": "Program.cs",
"location": {
"filePathRelative": "Program.cs",
"startLine": 5,
"startColumn": 1,
"endLine": 9,
"endColumn": 2
}
}
],
"edges": [
{
"id": 10,
"kind": "DeclaredAt",
"sourceId": 2,
"targetId": 1,
"location": {
"filePathRelative": "Program.cs",
"startLine": 5,
"startColumn": 1,
"endLine": 9,
"endColumn": 2
}
}
]
}
```
5 changes: 5 additions & 0 deletions docs/Development/Performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Performance

- Use `ragsharp-codegraph update` for incremental indexing.
- Store the database on fast local storage.
- Increase `--limit` cautiously for large repositories.
9 changes: 9 additions & 0 deletions docs/Development/QueryContract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Query Contract

All `ragsharp-codegraph query` commands emit JSON to stdout. Logs go to stderr. The JSON schema is defined in [OutputSchema.md](OutputSchema.md).

Query requests support:
- `--symbol` to filter by name or fully-qualified name.
- `--kind` to filter by node kind.
- `--document` to filter by file path.
- `--limit` to cap results.
29 changes: 29 additions & 0 deletions docs/Development/SetupDotNet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Setup .NET 10

## macOS

```bash
brew install --cask dotnet-sdk-preview

dotnet --info
dotnet --list-sdks
```

## Ubuntu/Debian

```bash
sudo apt-get update
sudo apt-get install -y dotnet-sdk-10.0

dotnet --info
dotnet --list-sdks
```

## Windows (PowerShell)

```powershell
winget install Microsoft.DotNet.SDK.Preview
dotnet --info
dotnet --list-sdks
```
5 changes: 5 additions & 0 deletions docs/Development/Troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Troubleshooting

- Ensure .NET SDK 10 is installed and on PATH.
- Run `ragsharp-codegraph doctor` for environment checks.
- Delete `.codegraph/` to rebuild the index from scratch.
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestFeature",
"allowPrerelease": true
}
}
55 changes: 55 additions & 0 deletions ragsharp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.CodeGraph.Core", "src/RagSharp.CodeGraph.Core/RagSharp.CodeGraph.Core.csproj", "{9842C0C2-C914-4AE9-B695-C31285B4FA10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.CodeGraph.Store.LiteGraph", "src/RagSharp.CodeGraph.Store.LiteGraph/RagSharp.CodeGraph.Store.LiteGraph.csproj", "{DB688194-9C0A-40CC-8977-C49F0EF97F7E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.CodeGraph.Cli", "src/RagSharp.CodeGraph.Cli/RagSharp.CodeGraph.Cli.csproj", "{E9442C38-3561-489A-A048-9C39E3989204}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.SkillInstaller", "src/RagSharp.SkillInstaller/RagSharp.SkillInstaller.csproj", "{F88A2153-7673-4CC3-BEB7-93990D10D8E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.Packaging", "src/RagSharp.Packaging/RagSharp.Packaging.csproj", "{329B88F1-A1C4-444F-9BD4-3E5333E587DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.CodeGraph.Tests", "tests/RagSharp.CodeGraph.Tests/RagSharp.CodeGraph.Tests.csproj", "{0EB45C08-B646-40B0-8766-A4790C70FB7C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RagSharp.SkillInstaller.Tests", "tests/RagSharp.SkillInstaller.Tests/RagSharp.SkillInstaller.Tests.csproj", "{763BFEF6-0BD4-423D-9784-CE707EBC3719}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9842C0C2-C914-4AE9-B695-C31285B4FA10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9842C0C2-C914-4AE9-B695-C31285B4FA10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9842C0C2-C914-4AE9-B695-C31285B4FA10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9842C0C2-C914-4AE9-B695-C31285B4FA10}.Release|Any CPU.Build.0 = Release|Any CPU
{DB688194-9C0A-40CC-8977-C49F0EF97F7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB688194-9C0A-40CC-8977-C49F0EF97F7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB688194-9C0A-40CC-8977-C49F0EF97F7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB688194-9C0A-40CC-8977-C49F0EF97F7E}.Release|Any CPU.Build.0 = Release|Any CPU
{E9442C38-3561-489A-A048-9C39E3989204}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9442C38-3561-489A-A048-9C39E3989204}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9442C38-3561-489A-A048-9C39E3989204}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9442C38-3561-489A-A048-9C39E3989204}.Release|Any CPU.Build.0 = Release|Any CPU
{F88A2153-7673-4CC3-BEB7-93990D10D8E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F88A2153-7673-4CC3-BEB7-93990D10D8E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F88A2153-7673-4CC3-BEB7-93990D10D8E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F88A2153-7673-4CC3-BEB7-93990D10D8E0}.Release|Any CPU.Build.0 = Release|Any CPU
{329B88F1-A1C4-444F-9BD4-3E5333E587DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{329B88F1-A1C4-444F-9BD4-3E5333E587DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{329B88F1-A1C4-444F-9BD4-3E5333E587DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{329B88F1-A1C4-444F-9BD4-3E5333E587DA}.Release|Any CPU.Build.0 = Release|Any CPU
{0EB45C08-B646-40B0-8766-A4790C70FB7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0EB45C08-B646-40B0-8766-A4790C70FB7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0EB45C08-B646-40B0-8766-A4790C70FB7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0EB45C08-B646-40B0-8766-A4790C70FB7C}.Release|Any CPU.Build.0 = Release|Any CPU
{763BFEF6-0BD4-423D-9784-CE707EBC3719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{763BFEF6-0BD4-423D-9784-CE707EBC3719}.Debug|Any CPU.Build.0 = Debug|Any CPU
{763BFEF6-0BD4-423D-9784-CE707EBC3719}.Release|Any CPU.ActiveCfg = Release|Any CPU
{763BFEF6-0BD4-423D-9784-CE707EBC3719}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Loading
Loading