Brain knowledge base operations. The core read/write cycle: brain-first lookup, read-enrich-write loop, source attribution, ambient enrichment, back-linking. Re
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-brain-ops-2e01d07aba08 ,按照其中的说明把「brain-ops」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Recall relevant context before responding. Save explicit requests with provenance; automatic capture is off until the user opts in. Reading this skill does not enable capture, delegation, or paid enrichment. A chat-only instruction suppresses writes for that turn, including when standing capture is enabled.
Convention: See
skills/conventions/brain-first.mdfor the 5-step lookup protocol. Convention: Seeskills/conventions/quality.mdfor citation and back-link rules.
Memory verbs (MEMORY_VERBS v1, gbrain ≥ 0.43). Over MCP, prefer the five core memory verbs for the read/write cycle:
remember(fact, provenance, ttl?)to save a single durable fact (mandatory provenance; dedupes + supersedes),recall(query | entity, budget_tokens)to read it back budget-packed,entity(name)for a zero-LLM card,synthesize(question)for the expensive cross-page answer,forget(id)to withdraw active memory (history, source material, and backups may remain).context_packanddeltacomplete the seven-verb surface. Userememberinstead ofextract_factswhen you already have ONE formed fact;put_page/add_link/add_timeline_entrystay the page/graph write path. Fall back to the classic ops when the verbs aren't on the surface. Contract:docs/protocol/MEMORY_VERBS_v1.md.Tight-budget page questions: explicitly use
recall({query: "zebra telescope", budget_tokens: 75, budget_policy: "query_first"})so ranked page evidence packs before recent facts. CLI:gbrain recall --query 'zebra telescope' --budget-tokens 75 --budget-policy query_first --json. Keep entity-first, event/session-filtered and fact-focused questions on their existing facts-first route; do not changecontext_pack. Costs are character-based estimates, and an oversized first item is dropped without skipping or truncation. Readbudget_packingbefore interpreting an empty result as missing memory. Seeskills/query/SKILL.mdfor the MCP request and caller example. Guidance is not native-harness activation: adoption remains unverified until a fresh conversation is observed making the opted-in call.Choose a readback path that can see the intended visibility. Trusted local CLI callers can recall and withdraw private facts. Every MCP caller, including stdio, and a thin CLI connected to MCP currently have world-only fact recall and withdrawal. A request to remember does not authorize making real private information world-visible. Use a trusted local write/readback path for private memory when available. If only remote access is available, a successful private write receipt confirms storage, but private recall remains unverified; explain that limit and the trusted local path needed for private readback or withdrawal. Do not widen visibility or request broader OAuth scopes merely to make verification pass. For an MCP connection test, use only a harmless synthetic
visibility: "world"fixture with the user's test authorization, retain its ID, and withdraw it afterward.Keyless brains: when
extract_factsreturnsskipped: extraction_unavailable, YOU are the extractor — pull the facts from the turn yourself and write each one viarememberwithkindset (event | preference | commitment | belief | fact — those five are the frozen protocol enum; theideakind the extractor and DB carry is NOT one of them) and the visibility the envelope'sagent_actionnames (default private — pin it;rememberdefaults to world), or author a## Factsfence on the entity page. Askipped: extraction_failedenvelope (server-side extractor errored on this turn;reasonnames why) invites the same manualrememberfallback for that turn — automatic extraction stays on for future writes.
This skill guarantees:
[Source: ...] citations)Every mention of a person or company with a brain page MUST create a back-link
FROM that entity's page TO the page mentioning them. An unlinked mention is a
broken brain. See skills/conventions/quality.md for format.
Before using ANY external API to research a person, company, or topic:
gbrain entity "<name>" (v0.43+) — ONE known person/company/project → full card (description, aliases, open threads, recent events, edges, backlink/fact counts). Zero LLM calls, sub-100ms. This one call replaces steps 2–6 for known-entity lookups; near-misses return suggestions.gbrain search "name" — exact-token lookup for existing pages (cheap hybrid, no expansion)gbrain query "natural question about name" — concept/landscape questions go here FIRST (expansion recovers synonym phrasings; a nonzero search count is not proof of completeness)gbrain get <slug> — if you know the slug, read the full pageThe brain almost always has something. External APIs fill gaps, not start from scratch.
⚠️ NEVER scope/count a corpus with shallow ls — query gbrain or find. Federated sources often carry MULTIPLE coexisting directory conventions — a flat legacy layer AND a date-nested meetings/YYYY/MM/ layer. A non-recursive ls dir/*.md sees only one and undercounts massively. Real example: a shallow ls of one source's meetings/ counted 132 files, almost all the user's, and concluded that WAS the corpus — missing thousands of transcripts nested under meetings/YYYY/MM/. To count/scope a brain corpus:
gbrain sources list (shows per-source indexed page counts) + gbrain query. gbrain indexes ALL federated sources correctly; trust its index, not the filesystem.find <dir> -name '*.md' | wc -l, never ls *.md. Then map the layout: find <dir> -name '*.md' | sed -E 's#(.*/)[^/]+$#\1#' | sort | uniq -c.gbrain sources list before believing a low count.For questions that need synthesis, temporal grounding, or analytical answers — not just "find the page" but "answer the question":
gbrain think "<question>" — multi-hop synthesis across pages + takes +
the graph. Temporal questions route through trajectory analysis; everything
else gets an LLM-synthesized, cited answer with conflict + gap analysis.
Returns a grounded answer, not just a list of matching pages.query for
simple page lookups where you just need the slug or a quick context check.For an explicit save request, or a message within the user's opted-in capture scope that has no chat-only restriction:
Attribute the user's direct statements with [Source: User, YYYY-MM-DD].
Without capture authorization, use the information in the current conversation
without persisting it. Explicit remembering does not enable ongoing capture.
"Auto-link" reconciliation extracts entity references from a page and writes
them to the graph (links table) with inferred relationship types; stale
links (refs no longer in the page text) are removed. WHO runs it depends on
the write path:
gbrain put, gbrain capture,
gbrain call put_page) auto-link inline and return
auto_links: { created, removed, errors }.auto_links: { skipped: "remote", hint }
and auto_timeline: { skipped: "remote" }. Body wikilinks are saved as text.
A stdio gbrain serve reconciles the edges asynchronously with its
maintenance sweep (startup + 10-minute idle ticks).
gbrain serve --http does not self-sweep — reconcile on demand with
gbrain sweep --once (delegates to the live serve over IPC) or
gbrain extract links --source db.
Use add_link for relationships you need immediately. Untrusted body text can plant
ranking-boosting edges, which is why the inline path is local-only.attended (meeting -> person), works_at, invested_in,
founded, advises, source (frontmatter), mentions (default).gbrain config set auto_link false. Default is on.gbrain timeline-add
(or batch via gbrain extract timeline --source db).Before answering any question about a person, company, or topic:
Don't answer from general knowledge when a brain page exists.
Enrichment is an additional user choice. Neither a mentioned entity, a shared link, nor capture opt-in authorizes external research, paid calls, or delegation by itself. Follow an explicit ingestion/enrichment request or the user's stored scope and spending policy. Without that authority, recall existing context and save only the supplied information that the user authorized retaining.
Use background agents only when delegation is authorized and supported by the harness. Report observed results without claiming a generated routine ran.
Use retrieved context in the response and cite it. Confirm authorized writes only after readback; if no write was requested or opted in, do not persist the conversation merely to produce a memory update.
When a brain has multiple sources (wiki, gstack, yc-media, etc.), every
citation MUST include the source id: [source-id:slug]. Example:
You told me about the retry budget approach — see [wiki:topics/resilience] and [gstack:plans/retry-policy] for where this came from.
Rules:
sources.id (immutable), never sources.name (mutable display).[default:slug] OR may omit the prefix
for backward compat.search, query, get_page, list_pages
carries source_id — always use it when citing, never guess.If a search result has source_id: "gstack" and slug: "plans/foo",
the citation is [gstack:plans/foo]. That's the whole rule.
[Source: ...] citationsgbrain entity "<name>" (catches aliases + near-misses), then query with name variantssearch — cheap hybrid search (vector + keyword, no expansion)query — hybrid search + LLM multi-query expansion (concept/landscape questions)get_page — read a brain pageput_page — create/update brain pagesadd_link — cross-reference entitiesadd_timeline_entry — record eventsget_backlinks — check who references an entitysync_brain — sync changes to the index