Answer questions using the brain's knowledge with 3-layer search, synthesis, and citation propagation. Use when the user asks a question, wants a lookup, or nee
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-query-9590280fa6fb ,按照其中的说明把「query」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Answer questions using the brain's knowledge with 3-layer search and synthesis.
Memory verbs (MEMORY_VERBS v1, gbrain ≥ 0.43). When connected to a brain over MCP, prefer the seven frozen memory verbs for memory work — they carry provenance, evidence, and a server-enforced token budget:
recall(query | entity, budget_tokens)— the budget-packed memory read. Use it instead of baresearchfor "what do we know that we SAVED about X".entity(name)— a zero-LLM person/company/project card (aliases, last-touched, open threads, top edges). Use it instead ofget_page+get_backlinkswhen you just need the card.synthesize(question)— the explicitly-expensive cross-page answer; the heavy version ofquery. Reach for it only when the answer must combine evidence across pages. Fall back tosearch/query/get_pagewhen the verbs aren't on the surface (pre-0.43 servers;--surface fullincludes the verbs alongside every other op). Seedocs/protocol/MEMORY_VERBS_v1.md.
This skill guarantees:
Answers should include:
Search returns chunks, not full pages. Read the excerpts first before deciding whether to load a full page.
For a question about saved page evidence with a tight budget, explicitly choose
recall with budget_policy: "query_first". It gives the existing ranked page
results first use of the budget, then packs recent/filtered facts into what remains.
This is an opt-in packing choice, not a new relevance model: an irrelevant page can
displace a useful fact. Keep entity-first, session/event-filtered and fact-focused
questions on their existing facts-first route. Do not change context_pack or
existing third-party calls.
gbrain recall --query 'zebra telescope' --budget-tokens 75 --budget-policy query_first --json
Equivalent MCP request:
{"name":"recall","arguments":{"query":"zebra telescope","budget_tokens":75,"budget_policy":"query_first"}}
Say to your agent: “Recall the saved notes about the zebra telescope using a 75-token estimated budget and query-first packing. Cite the returned evidence; if the first page cannot fit, tell me rather than treating that as missing memory.”
Use the resolved brain and source as usual; the option does not widen permissions.
budget_packing reports the effective policy and per-arm candidate/kept/dropped/used
counts. Costs estimate ceil(fact.length/4) or
ceil(title.length/4) + ceil(chunk.length/4), not exact tokenizer or JSON-envelope
size. Packing never skips an oversized prefix item or truncates it; multiple
required pages may still not fit. With no nonblank query or no positive finite
budget, the operation keeps legacy behavior. An eligible positive budget below one
token returns empty arms. See the protocol for fractional-budget compatibility.
This guidance and advertised tool schemas do not prove native-harness adoption. Confirm an observed query-first call in a fresh harness conversation before claiming activation; otherwise report adoption as unverified.
gbrain search / gbrain query return ranked chunks with context snippets.
These are often enough to answer the question directly.gbrain get <slug> to load the full page when a chunk confirms the
page is relevant and you need more context (e.g., compiled truth, timeline).When multiple sources provide conflicting information, follow this precedence:
When sources conflict, note the contradiction with both citations. Don't silently pick one.
When referencing brain pages in your answer, propagate inline citations:
[Source: ...] citations, propagate them so
the user can trace facts to their originFor relationship questions ("who knows who at X?", "connections between A and B", "who works at Acme?", "who attended the standup?"), use the graph layer instead of full-text search:
gbrain graph-query <slug> --type <link_type> --depth N --direction in|out|bothattended, works_at, invested_in, founded, advises, mentions, source--direction in answers "who points to X?" (e.g., who works at company X)--direction out answers "what does X point to?" (default)--depth N controls multi-hop traversal (default 5)Examples:
gbrain graph-query companies/acme --type works_at --direction ingbrain graph-query meetings/demo-day-w26 --type attended --direction outgbrain graph-query people/emily --type advises --direction outgbrain graph-query people/alice --type attended --depth 2Combine with gbrain query for queries that need BOTH semantic similarity AND
graph structure. Search results are ranked with a small backlink boost so well-
connected entities surface higher.
If search results seem off (wrong results, missing known pages, irrelevant hits):
gbrain doctor --json to check index healthgbrain search) vs hybrid search (gbrain query)
for the same query to isolate whether the issue is embedding-related