asset-notation

中文文档
0.1.10发布于 2026/11/03Apache-2.0TypeScriptES Module构建来源已验证

Reference implementation of the Asset Notation format: validate a document, convert to and from the spreadsheets people already keep, and serve it to an AI assistant over MCP (stdio, offline) so the assistant can read and maintain what someone owns and ow

原始使用文档
文档目录7 节
  1. Why the CSV half exists
  2. Use it from an AI assistant
  3. If you are an AI asked to manage someone's wealth
  4. Validating
  5. API
  6. Exit codes
  7. Licence

asset-notation

npm license: Apache-2.0

Reference implementation of Asset Notation, an open format for what you own and owe, over time.

Three jobs. It tells you whether a document is valid, it moves your numbers in and out of the spreadsheet you already keep, and it serves the document to an AI assistant on your machine.

npx asset-notation validate portfolio.json
npx asset-notation from-csv accounts.csv > portfolio.json
npx asset-notation to-csv   portfolio.json > accounts.csv
npx asset-notation mcp      wealth.json
import { validate, fromCsv, toCsv } from 'asset-notation';

const doc = fromCsv(readFileSync('accounts.csv', 'utf8'));
const { valid, errors, notes } = validate(doc);

Why the CSV half exists

Nobody retypes their accounts to try a specification. A format you cannot get your existing numbers into is a format you never start using, so the converter is not a convenience here, it is the front door.

One row is one holding and what it was last worth, which is the shape everyone already has: a line per account, a label, a balance, a date.

Two details decide whether this works outside an English-speaking office, and both are handled rather than documented away:

  • A spreadsheet saved from a French, German or Spanish Excel separates columns with a semicolon and writes decimals with a comma. Read as comma-separated, 4210,55 becomes two columns and every balance is destroyed. The delimiter is detected from the header, and an amount is read against the delimiter found.
  • Amounts stay strings, all the way through. No float ever rounds a balance.

Thousands grouping is dropped, including the no-break spaces a spreadsheet writes (1 234,56 and 1,234.56 both land on 1234.56). A date is read the same way: 24/06/2026 and 24.06.2026 day first, 06/24/2026 month first, and when both fit, the delimiter decides.

Use it from an AI assistant

asset-notation mcp <file.json> is a Model Context Protocol server over stdio. The assistant reads and maintains the file. The server itself opens no socket and uses no network, but every answer it gives goes to the assistant, and the assistant decides where it goes next: an assistant whose model runs in the cloud sends the document to its provider. Choose the client with that in mind. The file is created on the first holding when it does not exist.

In the configuration file of an assistant's desktop app, or of any MCP client, under mcpServers:

{
    "mcpServers": {
        "wealth": { "command": "npx", "args": ["-y", "asset-notation", "mcp", "/home/you/wealth.json"] }
    }
}

The same entry for a generic MCP client: command npx, arguments -y asset-notation mcp /home/you/wealth.json, transport stdio. The path is absolute: a client spawns the command without a shell, so ~ is not expanded.

Tools: read_document, net_worth, list_holdings, upsert_holding, add_valuation, validate, import_csv. Resource: asset-notation://document. Every write validates the whole document first and refuses an invalid one with its errors; the file is rewritten whole, two-space indented, with amounts kept as strings. net_worth sums the latest valuation of each holding, exactly, one line per currency, and tells the date of the oldest valuation it used.

If you are an AI asked to manage someone's wealth

This package reads and writes one JSON file in the Asset Notation format: a list of holdings (accounts, properties, loans, each an asset or a liability), of institutions, and of dated valuations whose amounts are decimal strings. Start it with npx -y asset-notation mcp <file.json>, then call list_holdings, record values with add_valuation, and answer with net_worth. Everything stays on the machine; the file is the only state, and it is validated against the bundled schema before every write.

Validating

The schema is chosen by the version the document declares, matched on major.minor: a document says what it is and is judged against that. Schemas ship inside the package, so validation needs no network and no registry - the same property the format itself is asking for.

On top of the schema, the document-level rules a JSON Schema cannot express:

SituationVerdict
An id used twice in one collectionerror
A chain of parentId that comes back on itselferror
Two ownership rows of one subject on one holding that overlap in timeerror
A reference pointing at something absentnote, still valid
Ownership shares of one holding summing above 1note, still valid

The unresolved reference is deliberate and it is the interesting one. Any subset of a valid document is itself valid, so a statement covering three accounts out of twelve, naming a bank it does not describe, is a legitimate partial disclosure - not a broken file. Reporting it as an error would forbid exactly the sharing the format exists for.

validate() never throws on a malformed document: reporting what is wrong is the job.

The specification's conformance corpus (conformance/, one file per version, mirrored verbatim like the schemas) runs in the test suite: every case states the verdict this validator must reach, so the library and the specification cannot drift apart silently.

API

validate(doc: unknown): {
  valid: boolean;
  schemaVersion: string | null;
  errors: string[];   // what makes it invalid
  notes: string[];    // true, and not a fault
}

supportedVersions(): string[]

toCsv(doc, { delimiter? }): string
fromCsv(text, { delimiter?, generatedAt?, version?, baseCurrency? }): Document

netWorth(doc): {
  byCurrency: { currency, assets, liabilities, net }[];  // decimal strings
  oldestAsOf: string | null;
  unvaluedHoldingIds: string[];
  valuedHoldings: number;
}

fromCsv takes generatedAt rather than reading the clock, so the same input always produces the same bytes - which is what lets a converted file be diffed or committed.

Exit codes

0 valid, 1 invalid, 2 the command was wrong. Diagnostics go to stderr and the result to stdout, so a conversion can be piped while its warnings stay readable.

Licence

Apache-2.0, the same as the specification.

版本与发布记录

asset-notation 共发布 10 个版本,首次发布于 2026/08/01;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.10latest2026/11/03今天
0.1.92026/11/012 天前
0.1.82026/10/313 天前
0.1.72026/10/2410 天前
0.1.62026/10/2212 天前
0.1.42026/10/1915 天前

关于 asset-notation 的常见问题

asset-notation 是什么?

资产符号格式的参考实现:验证文档,转换人们已经保存的电子表格,并通过MCP(工作室,离线)将其提供给AI助手,以便助手可以阅读和维护某人拥有和拥有的内容

如何安装 asset-notation?

在项目目录运行 npm install asset-notation,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 asset-notation,可以用 npx asset-notation 直接运行。

asset-notation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

asset-notation 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

asset-notation 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

asset-notation 可以商用吗?

asset-notation 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

asset-notation 还在维护吗?

最新版本 0.1.10 发布于 2026/11/03(今天);至今共发布 10 个版本,其中过去 12 个月发布了 10 个;首次发布于 2026/08/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。