npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@khanglvm/affine-cli

v0.1.1

Published

Agent-optimized CLI for AFFiNE, powered on demand by affine-mcp-server

Readme

@khanglvm/affine-cli

Agent-optimized command-line access to AFFiNE. It exposes the full AFFiNE tool surface on demand without permanently loading a large MCP schema into every agent session.

Provenance and license

This CLI is a port/adaptor of DAWNCR0W/affine-mcp-server. The original project provides the AFFiNE GraphQL/WebSocket implementation and MCP tool catalog. affine-cli depends on that package at runtime and adds a compact CLI, secure profiles, deterministic JSON output, mutation gates, large-result offloading, and an agent skill.

Both projects use the MIT License. Upstream copyright and attribution are preserved in NOTICE. This project is independent and is not affiliated with AFFiNE or the upstream maintainers.

Install

npm install -g @khanglvm/affine-cli
affine-cli --version

Migrate from an existing AFFiNE MCP connection

Import the existing ~/.config/affine-mcp/config and Codex MCP environment. The token moves into the OS keychain; the CLI config contains only non-secret profile metadata.

affine-cli profile import-mcp --pretty
affine-cli profile test --pretty

After successful verification, remove the legacy credential file explicitly:

affine-cli profile import-mcp --remove-source --perform-action --pretty

Removing a Codex registration remains a separate, visible step:

codex mcp remove affine

Agent-first usage

JSON is the default output. Logs and errors go to stderr. Large results are written to mode-0600 temporary files and returned as a compact preview.

affine-cli workspace list
affine-cli doc search --workspace <id> --query "meeting notes"
affine-cli doc read --workspace <id> --doc <id> --markdown
affine-cli tools list --query markdown
affine-cli tools describe append_markdown
affine-cli invoke export_doc_markdown \
  --args '{"workspaceId":"<id>","docId":"<id>"}'

Mutating tools require an explicit gate. Tools annotated destructive require a second gate, while profile-disabled tools remain blocked:

affine-cli invoke append_markdown \
  --args '{"workspaceId":"<id>","docId":"<id>","markdown":"Update"}' \
  --perform-action

For multi-step automation, avoid repeated server startup:

affine-cli batch --stdin <<'JSON'
[
  {"tool":"list_workspaces","args":{}},
  {"tool":"list_docs","args":{"workspaceId":"<id>","limit":10}}
]
JSON

Agent skill

The repository and npm package include skills/affine-cli/SKILL.md:

npx skills add https://github.com/khanglvm/affine-cli --skill affine-cli -y
affine-cli skill path

Security

  • Tokens are stored in the OS keychain, not the JSON config.
  • Token input uses stdin to avoid shell history and process-list leakage.
  • Tool annotations determine mutation gates; unknown annotations fail closed.
  • Disabled tools imported from Codex stay disabled in the CLI runtime.
  • Output files use mode 0600.
  • Errors omit stacks and redact secret-like detail keys.