Files
gstack/lib/code-intelligence/index.ts
T
3aba218303 feat(code-intelligence): provider contract Phase 1 — GBrain, Sourcebot, Graphify behind one ask-once offer
Open a large repo (1,000+ tracked files) and gstack can offer code
intelligence ONCE, with the trade-offs stated: GBrain (semantic memory +
code, sends content to YOUR gbrain DB, per-repo consent), Sourcebot
(self-hosted whole-repo search, local on localhost), Graphify (local
tree-sitter graph, nothing leaves the machine, user-installed), or No
indexing — a decline persists machine-wide so no skill ever asks again.
Small repos never see the question; grep stays the always-working default
and provider-OFF degrades silently (PROVIDER_UNAVAILABLE -> file-only).

Ported: lib/code-intelligence/ (contract + 3 verified adapters + picker +
selection + suggest, MIT headers), the gstack-code-intelligence CLI
(suggest/select/consent/index/search/status), 31 offline tests (fake CLI
shims + injected fetch), and the provider-contract design doc. Verified
live on this repo: suggest fires at 1,233 files with real availability
detail per provider.

Hardened per review: the per-remote trust store is the SINGLE consent
authority — a gstack-gbrain-repo-policy deny tier vetoes any recorded
code-intelligence consent (fail-closed on an unreadable store, pinned by
three tests); both send-capable adapters are registered as fail-closed
MODULE_SINKS in the egress tripwire so a refactor can't drop their
receipts; and local-compute vs remote-send consents are never bundled.
setup-gbrain gains the provider-choice Step 0. The fork's Phases 2-4
glue-collapse is explicitly NOT ported.

Ported from time-attack/gstack (GStack 2); consent unification ours.

Co-authored-by: Sina Matian <sina@time-attack.dev>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 13:15:03 -07:00

34 lines
865 B
TypeScript

/**
* code-intelligence — the OPTIONAL, repo-oriented provider contract.
* See docs/designs/CODE_INTELLIGENCE_PROVIDER_CONTRACT.md.
*/
export * from "./contract";
export { GbrainProvider, parseGbrainSearch } from "./gbrain-adapter";
export { GraphifyProvider, parseGraphifyQuery, type GraphifyOptions } from "./graphify-adapter";
export { SourcebotProvider, parseSourcebotSearch, type SourcebotOptions } from "./sourcebot-adapter";
export {
readSelection,
setProvider,
setConsent,
hasConsent,
setRoot,
getRoot,
type Selection,
} from "./selection";
export {
LARGE_REPO_FILE_THRESHOLD,
shouldOfferIndexing,
trackedFileCount,
type Suggestion,
type SuggestReason,
} from "./suggest";
export {
RECOMMENDED_ORDER,
providerById,
resolveSelectedProvider,
detectAvailable,
type PickerOptions,
type Availability,
} from "./picker";