Show HN: CodeAlmanac – 基于你对话内容的 Karpathy 风格代码库维基
Show HN: CodeAlmanac – Karpathy-style codebase wiki from your conversations

原始链接: https://github.com/AlmanacCode/codealmanac/

**CodeAlmanac** 是一个本地的、由 AI 维护的 Wiki 系统,它能为您提供代码库中无法体现的核心背景信息,例如系统架构、历史修复记录和工作流程等。 主要功能包括: * **原生于仓库:** Wiki 由标准的 Markdown 文件组成,直接存储在您代码库的 `almanac/` 目录下,确保文档与代码同步进行版本控制。 * **AI 驱动维护:** 通过本地编码代理(Codex 或 Claude),CodeAlmanac 可自动从 Git diff、PR 和代理脚本中获取文档。它还能执行“清理”任务,以剔除过时或冗余的信息。 * **完全本地化:** 该系统完全在您的机器上通过 macOS 的 `launchd` 任务运行。任何敏感数据、脚本或代码都不会上传到外部服务器。 * **工具支持:** 提供强大的命令行界面(CLI)用于搜索、查看和管理 Wiki 自动化。您可以在本地网页浏览器中直观查看 Wiki,也可以直接在终端中进行查询。 **入门指南:** 需要 Python 3.12+。请通过 `uv tool install codealmanac@latest` 进行安装,然后运行 `codealmanac setup` 来初始化代理和自动化配置。使用 `ca init` 创建 Wiki,并使用 `ca ingest` 将相关的项目知识录入系统。

**CodeAlmanac** 是一个开源工具,旨在为编程智能体(Coding Agents)打造一个自动化且持续演进的百科全书。该工具由 Almanac (YC S26) 团队开发,旨在捕捉那些常在与 Claude 或 Cursor 等 AI 编程助手对话中流失的隐性知识。 该工具通过在代码仓库中维护一个包含相互关联的 Markdown 文件的文件夹,记录技术决策和架构原理。每隔五小时,智能体会自动分析近期的对话并更新这些文档。这确保了开发人员在开启新的编程会话时,智能体已预先了解项目历史,从而有效地填补了不同会话及团队成员之间的上下文缺口。 主要功能包括: * **自动化维护:** 定期进行更新,避免了手动维护文档的繁琐。 * **智能体集成:** 通过 SQLite 进行索引并支持 CLI 查询,使编程智能体在执行任务前能够参考这些“年鉴”信息。 * **协作上下文:** 通过确保所有智能体都能访问相同的项目历史,帮助团队在架构决策上达成一致。 CodeAlmanac 目前支持 macOS 系统,Linux 和 Windows 版本的支持正在开发中。该工具开源且免费使用。
相关文章

原文

CodeAlmanac - A living wiki for your codebase

PyPI version PyPI downloads GitHub stars Discord LinkedIn Y Combinator S26 License: Apache-2.0

A living wiki for your codebase, maintained by AI coding agents.

CodeAlmanac gives AI agents the context code alone cannot hold: why a system is shaped the way it is, what broke before, which invariants matter, and how workflows cross files and services. The wiki is plain markdown in your repo, indexed locally, and reviewed in Git like any other code change.

Supported today: macOS with Codex or Claude Code. Requires Python 3.12+.

uv tool install codealmanac@latest
codealmanac setup

See Setup for configuration options.

Once CodeAlmanac is set up:

cd your-repo
codealmanac init                     # Makes your wiki, if you don't have one
codealmanac search "getting started" # Shows matching wiki pages.
codealmanac show getting-started     # Opens one page in the terminal
codealmanac serve                    # Shows the wiki in local web viewer.

Install global agent instructions for the local tools you use:

# Interactive setup
codealmanac setup

# Quick install with recommended defaults; uses Codex as the AI runner
codealmanac setup --yes

# Quick install using Claude as the AI runner
codealmanac setup --yes --runner claude

Setup installs agent instructions for your chosen tools and three local macOS launchd jobs. The jobs and all wiki work run locally.

Job Default schedule What it does
Sync Every 5 hours Scans recent Codex and Claude conversations and queues useful knowledge for the relevant registered wiki.
Garden Every 24 hours Reviews every registered wiki for stale, duplicated, or poorly connected knowledge.
Update Every 24 hours Checks for and installs CodeAlmanac CLI updates when it is safe to do so.

These schedules run locally in the background. Use codealmanac automation status to see what is installed.

The final setup step asks about anonymous telemetry and recommends Yes so we can see which commands work and where the CLI breaks. It sends controlled command and lifecycle outcomes plus sanitized unhandled crashes under a random install UUID. It never sends code, paths, arguments, queries, prompts, transcripts, repository/run IDs, locals, or credentials; GeoIP is disabled. Choose No in setup, pass setup --no-telemetry, set telemetry.enabled to false, or use DO_NOT_TRACK=1 at any time. Without a future login, the UUID profile has no name or email.

If you don't have Codex or prefer Claude, use --runner claude.

--target only chooses which global agent instruction files to install; it does not choose the AI runner:

codealmanac setup --yes --target codex
codealmanac setup --yes --target claude

Customize automatic work during setup:

# Change how often recent agent conversations are scanned
codealmanac setup --yes --sync-every 5h

# Do not install automatic transcript sync
codealmanac setup --yes --sync-off

# Do not install automatic wiki cleanup
codealmanac setup --yes --garden-off

# Do not install automatic CodeAlmanac updates
codealmanac setup --yes --no-auto-update

To uninstall CodeAlmanac-owned local artifacts:

codealmanac uninstall --yes

Agents and humans use the same local read commands:

codealmanac search "checkout timeout"
codealmanac search --mentions src/checkout/
codealmanac show checkout-flow
codealmanac topics
codealmanac health
codealmanac validate

Use --wiki <name> to read another registered local wiki. By default, commands target the exact current directory when it is a registered repository root.

Lifecycle commands run one of three explicit agents—build, ingest, or garden— through the public Yoke SDK. The existing packaged prompt files remain the complete task instructions and direct agents to edit the wiki under almanac/.

Lifecycle agents are trusted local coding agents. They run with the same broad, non-interactive filesystem permissions CodeAlmanac historically provided, so the almanac/ boundary is an instruction and commit policy, not an OS sandbox. Run lifecycle commands only in repositories where you accept that trust model, and review the resulting Git diff when automatic commits are disabled.

codealmanac ingest README.md --using codex
codealmanac ingest github:pr:123 --using claude
codealmanac garden --using codex

ingest folds selected local material into the wiki. Inputs can include files, directories, Git diffs, commit ranges, GitHub PRs or issues, URLs, and local agent transcripts.

garden improves the existing wiki graph: stale pages, links, topics, weak leads, duplicate pages, and unsupported claims.

No-op is valid. If the material adds no durable wiki knowledge, the harness should leave the wiki unchanged.

init, ingest, and garden create queued runs and start a local worker. To follow them visually, run codealmanac serve and select Jobs in the sidebar. To stay in the terminal, use codealmanac jobs attach <run-id>.

CodeAlmanac can keep registered wikis current without requiring you to remember maintenance commands.

Sync scans local Codex and Claude transcript stores for conversations active since the previous completed sync. Conversations associated with registered repositories are queued as ordinary ingest jobs. Sync may decide that a conversation contains no durable knowledge and leave the wiki unchanged.

Garden periodically queues a maintenance job for each registered wiki. It improves stale pages, weak links, topics, duplicated knowledge, and graph structure.

Update keeps the locally installed CodeAlmanac CLI current. Scheduled updates are skipped when an update would be unsafe, such as while lifecycle work is active.

Automation is implemented with local macOS launchd jobs, not a hosted service or cloud sync. Logs are stored under ~/.codealmanac/logs/.

# See installed schedules
codealmanac automation status

# Change a schedule
codealmanac config set automation.sync.every 5h
codealmanac config set automation.garden.every 24h
codealmanac config set automation.update.every 24h

# Disable or re-enable a schedule
codealmanac config set automation.sync.enabled false
codealmanac config set automation.sync.enabled true

config set updates the user TOML and immediately makes launchd match. If you edit the TOML directly, run codealmanac config apply afterward.

Automation creates individual background runs. Inspect those runs separately with codealmanac jobs.

Lifecycle runs are recorded under ~/.codealmanac/. Use these commands to inspect and control them:

# List recent jobs with their IDs, kinds, statuses, and elapsed times
codealmanac jobs

# Show one job's status, summary, page changes, timestamps, and error details
codealmanac jobs show <run-id>

# Print the events recorded so far, including progress, tool activity, and errors
codealmanac jobs logs <run-id>

# Follow new events live until the job finishes, fails, or is marked cancelled
codealmanac jobs attach <run-id>

# Prevent a queued job from starting, or stop a running job and its agent
codealmanac jobs cancel <run-id>

show is a summary of the job; logs is a snapshot of its event history; attach keeps watching and prints events as they arrive. All of these commands read the same durable local job record, so they still work after the terminal that started the job has closed. Add --json when consuming their output from a script.

CodeAlmanac uses almanac-yoke as its single provider boundary. Codex runs through app-server; Claude uses Yoke's default Claude surface (currently the Python Agent SDK). Existing Codex or Claude Code OAuth sessions are reused, and API credentials can be supplied through Yoke when embedding the SDK.

Build, ingest, and garden are packaged as a Yoke agent collection under src/codealmanac/agents/. Each agent uses Yoke's native folder contract: agent.yaml describes tools and permissions, while instructions.md contains the durable agent instructions. A lifecycle run passes only its typed runtime context as the task prompt. Optional Yoke skills/, subagents/, and workflows/ folders can be added to an agent when the product needs them; native Claude or Codex execution still decides how and when to use them.

codex login
claude auth login
codealmanac doctor

Read commands do not need provider credentials. Write-capable lifecycle commands need the selected harness to be available and authenticated.

What Gets Created By Init

With the default root:

your-repo/
|-- almanac/
|   |-- README.md
|   |-- topics.yaml
|   |-- architecture/
|   |   |-- README.md
|   |   `-- indexer.md
|   |-- decisions/
|   |   `-- local-first.md
|   `-- guides/
|       `-- setup.md
|-- src/
`-- ...

Markdown pages live directly under almanac/ in meaningful folders. topics.yaml organizes pages across folders. README.md files act as landing pages for their folder routes.

For auto-detection, a repository counts as a CodeAlmanac wiki when almanac/topics.yaml and almanac/README.md exist.

Derived local state lives under ~/.codealmanac/:

~/.codealmanac/codealmanac.db
~/.codealmanac/repos/<repo-id>/index.db

The local database records repositories, runs, run events, worker locks, and sync state. Per-repository runtime files contain derived indexes. They do not belong in the committed almanac/ tree.

User config lives at:

~/.codealmanac/config.toml

The supported defaults are:

auto_commit = true

[harness]
default = "codex"
model = "gpt-5.5"

[automation.sync]
enabled = true
every = "5h"

[automation.garden]
enabled = true
every = "24h"

[automation.update]
enabled = true
every = "24h"

CLI flags still win over config.

Use codealmanac config set <key> <value> for normal changes. It applies automation changes to launchd immediately. Direct file edits are supported but must be followed by:

auto_commit means lifecycle prompts may tell the selected agent to use normal Git commands for wiki source changes. CodeAlmanac does not stage files, split diffs, or commit internally.

codealmanac setup --no-auto-commit
codealmanac config set auto_commit false
codealmanac config set auto_commit true

The viewer is read-only. It renders pages, search, topics, backlinks, and file-reference navigation from local wiki data. serve opens it in your default browser once the server is ready; use codealmanac serve --no-open for headless or scripted use. By default the viewer can switch across available registered local wikis. Use codealmanac serve --wiki <name> to narrow it to one wiki.

Migrating From The npm CLI

The legacy codealmanac npm package is retired. PyPI is the only supported distribution. If you used the npm CLI, your machine may still carry the old global install plus the hooks and agent instructions it set up. Remove those before installing from PyPI.

Remove the old global package and any CodeAlmanac hooks or agent-instruction sections it installed, then install and set up the Python CLI:

npm uninstall -g codealmanac
uv tool install codealmanac@latest
codealmanac setup --yes
codealmanac doctor

Also remove old bun, pnpm, or yarn installs and any stray legacy binaries from PATH. Leave repo-local almanac/ trees alone; they are committed wiki content, not part of the CLI install.

harness codex failed with status failed: Error: spawn ... codex ENOENT

The Codex CLI on this machine is broken or missing: the @openai/codex package is installed but its native binary is gone (a common result of an interrupted install or a Node version switch under nvm/volta/fnm). Verify with:

If that fails with the same spawn ... ENOENT, reinstall the Codex CLI:

npm install -g @openai/codex
codex --version       # confirm the binary runs
codex login status    # confirm you are still signed in

Reinstalling does not sign you out: codex keeps its login under ~/.codex, outside the npm package.

Or switch CodeAlmanac to the Claude harness instead:

codealmanac config set harness.default claude

The same applies to harness claude failed errors: check claude --version, reinstall the Claude Code CLI if broken, or switch the default harness. codealmanac doctor reports harness availability.

This rewrite is local-only for now.

  • Public command: codealmanac
  • Short alias: ca
  • Repo wiki root: almanac/ only
  • Alternate repo wiki roots: none
  • User state root: ~/.codealmanac/
  • Runtime: Python 3.12+
  • Storage: local markdown plus derived state under ~/.codealmanac/
  • No hosted login/connect/upload commands.
  • No public SDK or MCP package.
  • No legacy compatibility aliases beyond the supported ca shorthand.
  • No alternate wiki roots.
  • Optional anonymous usage and sanitized crash telemetry; disable it with codealmanac config set telemetry.enabled false or --no-telemetry in setup.
  • No wiki, source, prompt, transcript, path, or command-argument upload path.
  • No second canonical product name.

This is the Python/PyPI product surface. Hosted integration can be added later around the same repo-owned wiki artifact, but it is not part of this release surface.

联系我们 contact @ memedata.com