Skip to content

Commit b678686

Browse files
committed
Add browser Wiki viewer
1 parent e7179ca commit b678686

49 files changed

Lines changed: 8798 additions & 126 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ccg.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ exclude:
1818
- ".*\\.pb\\.go$"
1919
- "bin/.*"
2020
- "docs/.*"
21+
- "web/wiki/dist/.*"
22+
- "web/wiki/node_modules/.*"
2123
- "testdata/.*"
2224
- ".*\\.gen\\.go$"
2325
- "scripts/.*"
@@ -48,6 +50,9 @@ rules:
4850
- pattern: "docs/.*"
4951
category: orphan
5052
action: ignore
53+
- pattern: "web/wiki/dist/.*"
54+
category: orphan
55+
action: ignore
5156
- pattern: "testdata/.*"
5257
category: orphan
5358
action: ignore

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
.git
22
*.db
33
ccg
4+
ccg-server
45
docs/
56
workspaces/
67
archive/
78
superpowers/
89
node_modules/
10+
**/node_modules/
11+
web/wiki/dist/
912
*.md
1013
!go.mod
1114
!go.sum

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ jobs:
2121
with:
2222
go-version: '1.25'
2323

24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: '22'
27+
cache: npm
28+
cache-dependency-path: web/wiki/package-lock.json
29+
2430
- name: Run go vet
2531
run: make vet
2632

2733
- name: Build release binaries
2834
run: make build
2935

36+
- name: Build Wiki UI
37+
run: make wiki-build
38+
3039
- name: Capture go build JSON
3140
run: make build-json
3241

.github/workflows/release.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,37 @@ jobs:
103103
*.tar.gz
104104
*.zip
105105
106+
wiki-dist:
107+
runs-on: ubuntu-latest
108+
109+
steps:
110+
- uses: actions/checkout@v4
111+
112+
- uses: actions/setup-node@v4
113+
with:
114+
node-version: '22'
115+
cache: npm
116+
cache-dependency-path: web/wiki/package-lock.json
117+
118+
- name: Build Wiki UI
119+
working-directory: web/wiki
120+
run: |
121+
npm ci
122+
npm run build
123+
124+
- name: Package Wiki UI
125+
run: tar czf ccg-wiki-dist.tar.gz -C web/wiki/dist .
126+
127+
- name: Upload Wiki artifact
128+
uses: actions/upload-artifact@v4
129+
with:
130+
name: ccg-wiki-dist
131+
path: ccg-wiki-dist.tar.gz
132+
106133
release:
107-
needs: build
134+
needs:
135+
- build
136+
- wiki-dist
108137
runs-on: ubuntu-latest
109138

110139
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Binaries
22
/ccg
3+
/ccg-server
34
/dogfood
45
*.exe
56

@@ -23,3 +24,5 @@ pyproject.toml
2324
/go-refactoring-design.md
2425
*.db-shm
2526
*.db-wal
27+
/web/wiki/dist/
28+
/web/wiki/node_modules/

Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Wiki UI build stage
2+
FROM node:22-alpine AS wiki-builder
3+
4+
WORKDIR /src/web/wiki
5+
COPY web/wiki/package.json web/wiki/package-lock.json ./
6+
RUN npm ci
7+
COPY web/wiki/ ./
8+
RUN npm run build
9+
110
# Build stage
211
FROM golang:1.25-alpine AS builder
312

@@ -22,6 +31,7 @@ RUN apk add --no-cache ca-certificates git \
2231

2332
COPY --from=builder /usr/local/bin/ccg /usr/local/bin/ccg
2433
COPY --from=builder /usr/local/bin/ccg-server /usr/local/bin/ccg-server
34+
COPY --from=wiki-builder /src/web/wiki/dist /usr/share/ccg/wiki
2535

2636
WORKDIR /workspace
2737
USER ccg
@@ -31,4 +41,4 @@ ENV HOME=/home/ccg \
3141
EXPOSE 8080
3242

3343
ENTRYPOINT ["ccg-server"]
34-
CMD ["--http-addr", ":8080"]
44+
CMD ["--http-addr", ":8080", "--wiki-dir", "/usr/share/ccg/wiki"]

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
33
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
44
BASE_LDFLAGS = -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
55
LDFLAGS = -s -w $(BASE_LDFLAGS)
6+
WIKI_ADDR ?= 127.0.0.1:8080
7+
WIKI_DB ?= ccg.db
8+
WIKI_TOKEN ?=
69

7-
.PHONY: build release build-debug build-json install vet test test-integration-helpers clean
10+
.PHONY: build release build-debug build-json install vet test test-integration-helpers wiki-build wiki-run clean
811

912
build: release
1013

@@ -32,5 +35,12 @@ test: test-integration-helpers
3235
test-integration-helpers:
3336
bash ./scripts/integration-test-helpers_test.sh
3437

38+
wiki-build:
39+
cd web/wiki && npm ci && npm run build
40+
41+
wiki-run: wiki-build
42+
CGO_ENABLED=1 go run -tags "fts5" ./cmd/ccg --db-driver sqlite --db-dsn '$(WIKI_DB)' migrate
43+
CGO_ENABLED=1 go run -tags "fts5" ./cmd/ccg-server --db-driver sqlite --db-dsn '$(WIKI_DB)' --http-addr '$(WIKI_ADDR)' --http-bearer-token '$(WIKI_TOKEN)' --wiki-dir web/wiki/dist
44+
3545
clean:
3646
rm -f ccg ccg-server

README.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Inspired by [code-review-graph](https://github.com/tirth8205/code-review-graph)
1313
- **12 languages**: Go, Python, TypeScript, Java, Ruby, JavaScript, C, C++, Rust, Kotlin, PHP, Lua/Luau
1414
- **35 MCP tools**: parse, search, impact analysis, flow tracing, dead code detection, postprocess operations, namespace file management, and more
1515
- **RAG-first code exploration**: generated docs + community structure let LLM agents answer natural-language questions before drilling into exact graph nodes
16+
- **Browser Wiki UI**: `ccg-server` can serve generated docs, tree search, PageIndex-style retrieval, Context Tray copying, and an Obsidian-style graph viewer
1617
- **Custom annotations**: `@intent`, `@domainRule`, `@sideEffect`, `@mutates`, `@index` — search code by business context ([details](guide/annotations.md))
1718
- **Webhook sync**: GitHub / Gitea push events → auto clone + build with per-repo branch filtering and `.ccg.yaml` `include_paths` auto-loading ([details](guide/webhook.md))
1819
- **Eval**: Golden corpus-based parser accuracy (P/R/F1) and search quality (P@K, MRR, nDCG) evaluation ([details](guide/eval.md))
@@ -68,6 +69,9 @@ ccg search "payment" # finds functions with @intent/@domainRule about payment
6869
# Build docs and the default vectorless RAG index for agent-oriented exploration
6970
ccg docs --out docs
7071

72+
# Serve the browser Wiki UI from built assets
73+
make wiki-run
74+
7175
# Graph statistics
7276
ccg status
7377

@@ -85,10 +89,12 @@ ccg eval --suite parser
8589
ccg eval --suite parser --update
8690
```
8791

88-
`ccg docs` refreshes community structure and writes `.ccg/doc-index.json` by
89-
default. Use `--rag=false` when you only want Markdown, or
90-
`--rag-refresh=false` when you want to rebuild the index from existing community
91-
rows without recalculating communities.
92+
`ccg docs` writes generated Markdown plus `.ccg/wiki-index.json` for the browser
93+
Wiki. By default it also refreshes community structure and writes
94+
`.ccg/doc-index.json` for vectorless RAG retrieval. Use `--rag=false` when you
95+
only want Markdown and the Wiki index, or `--rag-refresh=false` when you want to
96+
rebuild the RAG index from existing community rows without recalculating
97+
communities.
9298

9399
For LLM agents, treat generated docs and the RAG index as the primary entrypoint
94100
for natural-language questions such as "how does webhook sync work?" or "where
@@ -103,6 +109,37 @@ also applies when upgrading CCG against an existing default `ccg.db` created by
103109
an older version. See the [CLI Reference](guide/cli-reference.md) for the full
104110
migration contract.
105111

112+
## Browser Wiki
113+
114+
`ccg-server` can serve a React-based Wiki UI at `/wiki` when `--wiki-dir` points
115+
at a built `web/wiki/dist` directory. Docker images include that built UI at
116+
`/usr/share/ccg/wiki`; standalone binaries keep the assets separate so binary
117+
size stays small.
118+
119+
The Wiki is meant for developers and agents inspecting a generated codebase:
120+
121+
- Tree navigation over folders, packages, files, and annotated symbols
122+
- Keyword search and PageIndex-style `retrieve_docs` over `doc-index.json`
123+
- Rich symbol detail cards from CCG annotations even when a symbol has no
124+
generated Markdown file
125+
- Context Tray for collecting files and doc-less symbols into one Markdown
126+
bundle that can be copied into another LLM tool
127+
- Graph tab backed by `/wiki/api/graph`, showing namespace nodes and edges with
128+
filters for structure, calls, imports, types, and symbols
129+
130+
Local development shortcut:
131+
132+
```bash
133+
ccg build .
134+
ccg docs --out docs
135+
make wiki-run
136+
```
137+
138+
For self-hosted deployments, run `ccg-server --wiki-dir <dist-dir>` and protect
139+
`/wiki/api/*` with the same bearer token policy used for `/mcp`. See
140+
[Docker](guide/docker.md#wiki-ui) and [Runtime Layout](guide/runtime-layout.md)
141+
for deployment details.
142+
106143
## Demo
107144

108145
Actual output from CCG parsing its own codebase.
@@ -201,7 +238,8 @@ Add `.mcp.json` to your project:
201238

202239
For remote HTTP mode:
203240

204-
Run the self-hosted server with `ccg-server` and connect to `/mcp`:
241+
Run the self-hosted server with `ccg-server` and connect to `/mcp`. The same
242+
server can also expose `/wiki` when `--wiki-dir` is configured:
205243

206244
```json
207245
{
@@ -226,11 +264,11 @@ Source Code → Tree-sitter Parser → Nodes + Edges + Annotations
226264
227265
FTS Search
228266
229-
ccg serve ccg-server
230-
stdio MCP Streamable HTTP
231-
↓ ↓ ↑
232-
Coding Agents Remote Clients GitHub / Gitea Webhook
233-
push → clone → build → DB
267+
ccg serve ccg-server
268+
stdio MCP Streamable HTTP + Wiki UI
269+
↓ ↑
270+
Coding Agents Remote Clients Browser GitHub / Gitea Webhook
271+
Wiki push → clone → build → DB
234272
```
235273

236274
See [Architecture Details](guide/architecture.md) for component breakdown and DB schema.
@@ -246,10 +284,10 @@ See [Architecture Details](guide/architecture.md) for component breakdown and DB
246284
| [MCP Tools](guide/mcp-tools.md) | 35 MCP tools, agent skills, AI-Driven Annotation |
247285
| [Annotations](guide/annotations.md) | Annotation system — tags, examples, search |
248286
| [Webhook](guide/webhook.md) | Webhook sync, branch filtering, HMAC, graceful shutdown |
249-
| [Docker](guide/docker.md) | Docker build, MCP server, PostgreSQL deployment |
287+
| [Docker](guide/docker.md) | Docker build, MCP server, Wiki UI, PostgreSQL deployment |
250288
| [Operations](guide/operations.md) | Deployment profiles, database choice, readiness, webhook operations |
251289
| [Postprocess Failure Policy](guide/postprocess-failure-policy.md) | Status rules, failure causes, and automatic degraded/fail_closed policy for build and postprocess tools |
252-
| [Runtime Layout](guide/runtime-layout.md) | `ccg`, `ccg-server`, and shared `ccg-core` ownership boundaries |
290+
| [Runtime Layout](guide/runtime-layout.md) | `ccg`, `ccg-server`, Wiki serving, and shared `ccg-core` ownership boundaries |
253291
| [Development](guide/development.md) | Dev guide, integration test, project structure |
254292
| [Namespace Migration](guide/namespace-migration.md) | Default namespace change and migration guide |
255293
| [Architecture](guide/architecture.md) | Data flow, components, DB schema |

cmd/ccg-server/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func newRootCmd(rt *core.Runtime, serviceVersion string) *cobra.Command {
133133
cmd.Flags().StringVar(&cfg.OTELEndpoint, "otel-endpoint", cfg.OTELEndpoint, "OTLP HTTP trace endpoint (optional; enables span export when set)")
134134
cmd.Flags().BoolVar(&cfg.InsecureHTTP, "insecure-http", false, "Allow externally bound HTTP transport without bearer token (unsafe; testing only)")
135135
cmd.Flags().BoolVar(&cfg.Stateless, "stateless", false, "Stateless session management (for multi-instance deployments)")
136+
cmd.Flags().StringVar(&cfg.WikiDir, "wiki-dir", cfg.WikiDir, "Directory containing built Wiki UI assets; enables /wiki when set")
136137
cmd.Flags().StringVar(&cfg.NamespaceRoot, "namespace-root", cfg.NamespaceRoot, "Root directory for file namespaces")
137138
cmd.Flags().StringVar(&cfg.WorkspaceRoot, "workspace-root", "", "Deprecated alias for --namespace-root")
138139

docker-compose.integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ services:
6060
- CCG_LOG_FORMAT=text
6161
command:
6262
- --http-addr=:8080
63+
- --wiki-dir=/usr/share/ccg/wiki
6364
- --http-bearer-token=test-mcp-token
6465
- --db-driver=postgres
6566
- --db-dsn=host=postgres user=ccg password=ccg dbname=ccg_integration port=5432 sslmode=disable

0 commit comments

Comments
 (0)