Logo Nimonyplugins

Nimonyplugins

Cộng đồng
planetis-m
nimonyplugins

Build and debug Nimony compile-time plugins for code generation and DSL rewrites. Use when replacing Nim macros with Nimony plugins, writing or reviewing template, for-loop, module, type, or import plugins, or diagnosing NIF traversal and generated output.

Tổng quan

Nhà phát hànhplanetis-m
Kho mãskills
Tên kỹ năngnimonyplugins
Sao
66
Bản fork
7
Tệp đi kèm
6
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 6 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được planetis-m công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Nimonyplugins trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/planetis-m/skills/tree/master/nimonyplugins
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/planetis-m/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/nimonyplugins .claude/skills/nimonyplugins
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Nimonyplugins trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Nimonyplugins ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Nimonyplugins không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Nimony Plugins

Rules

Resolve the actual API

  • Resolve nimony with readlink -f "$(command -v nimony)".
  • If the resolved path ends in /bin/nimony, open ../src/nimony/lib/plugins.nim relative to the executable directory. Otherwise open src/nimony/lib/plugins.nim under the executable directory. Treat that file as the source of truth.
  • Plugin modules are compiled with Nimony itself. Each unique plugin path gets a separate nimony c invocation and cached executable, even when two paths contain identical source. Warm builds reuse those executables.
  • A {.plugin: "path".} path is relative to the source file containing the pragma, not the call site.

Choose the plugin contract

There are five plugin kinds:

  • Template: template f(...) {.plugin: "p".} receives (stmts <template-name> <args...>). Use callArgs(root) to read the arguments. Its output is semantically checked again.
  • For-loop: iterator f(...) {.plugin: "p".} receives (forcall <iterator-name> (callargs ...) (unpackflat|unpacktup ...) <body>). Use forLoopCallArgs, forLoopVars, and forLoopBody. The body is already typed; transformed output is semantically checked again.
  • Module: {.plugin: "p".} receives the semantically checked full module and must return the full module. Output is not checked again.
  • Type: type T {.plugin: "p".} = ... receives the full module through loadPluginInput() and triggering definitions through loadTypeDefinitions(). It must return the full module; output is not checked again.
  • Import: import (path/foo) {.plugin: "p".} transforms an imported module.

When multiple templates or iterators name the same plugin path, use pluginName(root) to dispatch them inside that one executable.

Use the named protocol helpers to access template and for-loop inputs.

Ownership and identity

  • NifBuilder is the move-only nifcore.TokenBuf.
  • NifCursor is a copyable, reference-counted, bounded read cursor.
  • snapshot(tree) borrows a non-empty builder. The cursor keeps its observed storage alive; later builder mutation detaches storage as needed.
  • addTree borrows its child builder, so the child remains usable afterward. saveTree accepts its completed output as a sink parameter.
  • SymId and TagId are numeric handles local to shared plugin pools. Resolve their names with symText and tagText.
  • Plugin inputs and builders use shared preseeded pools, so handles obtained from plugin cursors can be reused by builder helpers.

Build NIF

  • Start a builder with createTree().
  • Add known Nimony enum tags with withTree SomeEnum, info:.
  • Add textual or dynamic tags with balanced openTree(tag, info) / closeTree().
  • Preserve n.info when deriving output from an input node. Use NoLineInfo for synthetic output.
  • Use addTree(dest, child) to append an entire child builder.
  • Use addSubtree(dest, cursor) to copy without advancing and takeTree(dest, cursor) to copy and advance.
  • Use copyInto(dest, cursor): to copy a node head while transforming all bounded children.
  • Use bindSym for hygienic definition-scope symbol references.
  • For each local introduced by a plugin, call genSym() once and pass that SymId to addSymDef and every corresponding addSymUse.

Traverse bounded cursors

  • Compound nodes have kind TagLit; strings have kind StrLit.
  • Cursors are bounded by a remaining-token count.
  • firstChild(n) returns a cursor bounded to the current node's children.
  • skip(n) advances over one atom or complete subtree.
  • into n: and loopInto n: require their bodies to consume all children.
  • balancedTokens n: visits descendant TagLit nodes, excludes the root, and leaves n advanced past the root.
  • Copy a cursor for lookahead and use hasMore to test its bounds.

Prefer Replacer for selective rewrites

  • keep, drop, and replace each consume one input child.
  • Their kind argument asserts the current child's kind.
  • keepTag and replaceHead bodies must consume every child.
  • loopKeepTag preserves a node while iterating its children.
  • peek restores the source cursor; writes to r.dest persist.
  • Template replacers start at (stmts <name> <args...>); consume or preserve the leading name deliberately before processing arguments.

Report errors and write output

  • Return errorTree(message, at) when user input violates the plugin's contract.
  • Reserve assertions for plugin implementation contract violations.
  • renderNode(cursor) and renderTree(builder) are debugging helpers that omit line information.
  • saveTree consumes a builder. saveReplacer writes the replacer output.

Workflow

  1. Resolve and inspect the exact plugins.nim used by the selected Nimony.
  2. Select the plugin kind and write down its input/output contract.
  3. Expose the pragma from a small user-facing module and keep transformation logic in a separate plugin module.
  4. Load input with loadPluginInput, loadTypeDefinitions, or loadReplacer.
  5. Use protocol helpers before traversing arguments, variables, or bodies.
  6. Preserve correct subtrees; synthesize only what changes.
  7. Build one complete output. Return errorTree for invalid input, then write the result with saveTree or saveReplacer.
  8. Compile plugin integration tests with Nimony. A host-Nim test harness can launch nimony when needed.

Common Mistakes

MistakeCorrection
Compiling the plugin module with NimCompile plugin modules and integration tests with Nimony
Traversing a template root as though every child were an argumentUse callArgs(root); the root also contains the invoked template name
Confusing addSubtree with takeTreeUse addSubtree to preserve the cursor position and takeTree to advance it
Leaving children unconsumed in into, keepTag, or replaceHeadConsume every bounded child in the body
Returning a transformed fragment from a module or type pluginReturn the complete module
Reusing a textual name for a generated localCall genSym() once and use its SymId for the definition and every use
Writing output during peek while treating it as a dry runKeep peek read-only; it restores the source cursor but not r.dest

References

  • references/template_plugin.md — A template plugin that generates an expression from literal arguments.
  • references/replacer_api.md — A selective call rewrite that preserves most input children.
  • references/for_loop_plugin.md — A for-loop plugin that expands an already typed body.
  • references/module_plugin.md — A module plugin that rewrites an already typed module.
  • references/type_plugin.md — A type plugin for validation or rewrites driven by selected types.
  • references/generated_symbols.md — genSym definition and use for collision-free locals.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Nimonyplugins làm được gì?

Build and debug Nimony compile-time plugins for code generation and DSL rewrites. Use when replacing Nim macros with Nimony plugins, writing or reviewing template, for-loop, module, type, or import plugins, or diagnosing NIF traversal and generated output.

Vì sao nên dùng Nimonyplugins trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Nimonyplugins là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Nimonyplugins trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/planetis-m/skills/tree/master/nimonyplugins. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Nimonyplugins?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Nimonyplugins với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Nimonyplugins với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Nimonyplugins có miễn phí không?

Kỹ năng này được planetis-m phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇