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

@airalogy/aimd-core

v2.7.0

Published

AIMD (Airalogy Markdown) core parser and syntax definitions

Readme

@airalogy/aimd-core

npm version License

AIMD(Airalogy Markdown)的核心解析器与规范化字段提取能力。

它也会把 fenced assigner runtime=client 代码块提取为 fields.client_assigner 前端元数据。 普通 var 的 id 仍然保留在 fields.var;其解析出的类型、默认值和 kwargs 元数据也会通过 fields.var_definitions 暴露。

协议级 AIMD 语法、assigner 语义与校验规则以 Airalogy 文档为准;@airalogy/aimd-* 文档只描述前端 parser、renderer、recorder 如何实现这些规范。

安装

pnpm add @airalogy/aimd-core

快速开始

import { unified } from "unified"
import remarkParse from "remark-parse"
import { remarkAimd } from "@airalogy/aimd-core/parser"

const content = "{{var|sample_name: str}}"
const processor = unified().use(remarkParse).use(remarkAimd)
const tree = processor.parse(content)
const file = { data: {} } as any
processor.runSync(tree, file)

console.log(file.data.aimdFields)

示例 client assigner:

```assigner runtime=client
assigner(
  {
    mode: "auto",
    dependent_fields: ["a", "b"],
    assigned_fields: ["total"],
  },
  function calculate_total({ a, b }) {
    return {
      total: a + b,
    };
  }
);
```

如果 AIMD 行内模板出现在 Markdown 表格单元格中,需要在 parse() 之前先保护模板,避免 GFM 把模板里的 | 当成列表格分隔符:

import { protectAimdInlineTemplates, remarkAimd } from "@airalogy/aimd-core/parser"

const { content: protectedContent, templates } = protectAimdInlineTemplates(content)
const file = { data: { aimdInlineTemplates: templates } } as any
const tree = processor.parse(protectedContent)
processor.runSync(tree, file)

Choice 后续字段

选择题选项可以在 followups 下声明条件触发的结构化字段。解析结果会保存在 options[].followups,字段类型只支持 strintfloatbool;这里有意不接受 number

```quiz
id: sample_storage
type: choice
mode: single
stem: "样本当前如何保存?"
options:
  - key: A
    text: "冷藏保存"
    followups:
      - key: temperature_c
        type: float
        title: "温度"
        unit: "°C"
      - key: duration_hours
        type: float
        title: "时长"
        unit: "小时"
  - key: B
    text: "冷冻保存"
  - key: C
    text: "常温放置"
```

判断题

判断题使用 type: true_falseanswerdefault 会被规范化为布尔值;如果省略 options,默认选项为 true. Truefalse. False

```quiz
id: sample_kept_cold
type: true_false
stem: "样本转移过程中是否一直保持低温?"
answer: true
```

校验辅助函数

import {
  parseVarDefinition,
  validateClientAssignerFunctionSource,
  validateVarDefinition,
  validateVarDefaultType,
  validateVarKwargs,
} from "@airalogy/aimd-core/parser"

如果宿主工具需要在保存或执行前预检 fenced assigner runtime=client 函数,可使用 validateClientAssignerFunctionSource()。如果你想在作者填写 AIMD var 默认值时提示类型不匹配警告,可使用 validateVarDefaultType()。如果工具还需要提示 gtgeltlemultiple_of 这类 Pydantic 风格数值约束被用在非数值类型上,可使用 validateVarKwargs()validateVarDefinition()

文档