Hacker News new | ask | show | jobs
by pst723 777 days ago
We built an "infinite canvas" style app for exploring codebases. We cut your repo into atomic pieces - functions, data structures etc. and give you an interactively expandable graph of defintions.

Even with the best go-to-definition editor feature you need to keep a whole bunch of mental context when tracking down a deep control flow. The idea of Territory is to give you exactly the relevant cross-section through a large codebase. A code map that you build in this fashion can then provide explanatory value to others.

So far we indexed Linux, LLVM and Godot to prove we can handle repos of that scale and to provide value free of charge to free software contributors. We will be adding more repos and shipping self-service build setup later. Would love to hear your opinion. Are there any projects you think we should cover next? We are doing C/C++ first -- our initial parsing setup is build around libclang.

7 comments

Ideally this would be a standalone app (perhaps ported using electron) that I could run locally, and import codebases directly. Sourcegraph was on the right track, but eventually fizzled out unfortunately.

I would love to use a tool like this to navigate the unknown on rails!

By chance did you mean Sourcetrail [1] instead of Sourcegraph? Old demo video on YouTube: https://youtu.be/Cfu6f0uyzc8?si=oNS9KKlbgEk_Ct0p.

[1] https://github.com/CoatiSoftware/Sourcetrail

Yes you're right, my mistake!
Sourcegraph CEO here. We stopped making a standalone Electron app (which was an experiment) and instead remained focused on our web app and editor extensions. You can use Cody in your editor with no server needed. We didn’t fizzle out. :)
Oh hi there! Love what Sourcegraph is doing.
I confused Sourcetrail and SourceGraph, didn't mean to spread misinformation on your product!
That is definitely an option. However what you get from a hosted service is that we do the indexing for you. That can take a significant amount of time for a huge codebase.
Love the idea, but isn't the "indexing" part of many editors and language servers already? Ctags and stuff? Never got the impression that to be a huge problem on modern hardware.

I doubt, there will be much demand for throwing large non-public code bases into third party services... However, I can totally see how this would be a hit as a FOSS project.

I've built a code search engine in the past so I know how painful debugging long indexing jobs can be and I would certainly be reluctant to support private repos until I know I can index thousands if not tens of thousands of open source repos with no issues.
That's more or less the plan. We want to prove our concept with free software repos first.
I would like editing code in this style. Focus on narrow area but can easily view as bird eye.

Nice work!

Thank you!

Editing is definitely on the roadmap. We would like to have an agent to sync edits with your local workspace at some point.

What about a VS Code extension? Would love to explore like this in my IDE over needing a separate tool / webapp

Something like: https://github.com/pixelkind/p5canvas

I got that request from a couple of people already. Definitely coming soon. For now, we tried to make it easy to hop around manually. Click the node header to copy path, ⌘P, paste. Pasting a path to our search bar also works.
Post to HN when that launches. I’ll take a look then.
Sure. You can follow as on X @territory_dev, I post updates there.
I can imagine a number of really cool ways to explore code with a tight integration to intellisense / LSP

in particular, show all callers and callees of a code snippet

Some first impression UI feedback:

Don't overlap existing boxes when exploring new definition. Instead find the lowest free space in the column (or insert it at appropriate level)

When adding a reference to rather than exploring definition, default to adding box to the opposite side (left)

Ah yes those are definitely on the TODO list.
While we are at it, it would probably also be nice to (optionally) color the background of the explored row(or token) and color the title bar of the result correspondingly (I am thinking similar to Godbolt color coding for matching C->ASM)
Support Unreal Engine and you'd get a lot of interest from game devs!
This might interest you - https://github.com/aappleby/wideboard
It'd be great if this UI could happen inside VS Code, for the current workspace and its dependencies
I have some interesting ideas about this, as I've been thinking about it and have been prototyping ideas for ... a decade at this point?

Do you have a way to contact you?

Any reason you're not using treesitter with LSPs by the way? This would make it really easy to get this working with all major languages at once.

LSP and treesitter are cool and we might use them when adding more languages eventually. From my understanding though treesitter does parsing only and it would take a bunch of work to do the semantic analysis clang already does. Plus clang is an industry tried compiler that we know can handle a lot of the rough edge cases of C and C++. LSP is closer to our use case but I think still not close enough. It took a lot of work to get the right points to cut the code at and when talking to clang directly, at least we can inspect things at a decently low level.

Are you on X? You can DM me at @pst723 or @territory_dev.