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

intentspec

v0.1.2

Published

CLI for IntentSpec

Downloads

20

Readme

intentspec CLI

Command-line tool for Intent Spec: extract agent-readable metadata from Solidity contracts using custom NatSpec tags and emit schema-compliant JSON.


Requirements

  • Node.js ≥ 18
  • Solidity contracts that use @custom:agent-* NatSpec tags (see NatSpec tags)

Installation

Option 1: Run with npx (no install)

From any directory:

npx intentspec compile
npx intentspec extract-natspec --file path/to/Contract.sol

Option 2: Install globally

npm install -g intentspec

Then run from anywhere:

intentspec compile
intentspec extract-natspec -f contracts/MyContract.sol

Option 3: Install as a dev dependency in your project

npm install --save-dev intentspec

Use via npx in scripts or locally:

npx intentspec compile

Option 4: Build from source

git clone <repo-url>
cd intent-spec/cli
npm install
npm run build

Run the built CLI:

node dist/index.js compile
# or link globally: npm link && intentspec compile

Commands

compile

Scans a directory for all .sol files (recursively, excluding node_modules and .git), extracts Intent Spec metadata from each file that contains a contract with valid NatSpec, and writes one JSON file per contract into an intentspec/ folder.

Usage:

intentspec compile
intentspec compile --dir /path/to/contracts
intentspec compile -d ./src

| Option | Description | Default | |--------|-------------|---------| | -d, --dir <path> | Root directory to search for .sol files | Current directory (.)

Behavior:

  • Creates intentspec/ in the root directory you specify.
  • For each .sol file that has a contract and at least one function with @custom:agent-intent, writes intentspec/<ContractName>.json.
  • Skips files that do not declare a contract or have no valid agent NatSpec.

Example:

cd my-project
intentspec compile
# → Creates  intentspec/Token.json, etc.

extract-natspec

Reads a single Solidity file, extracts Intent Spec from it, and prints the JSON to stdout (no file written).

Usage:

intentspec extract-natspec
intentspec extract-natspec --file contracts/MyContract.sol
intentspec extract-natspec -f ./src/Proxy.sol

| Option | Description | Default | |--------|-------------|---------| | -f, --file <path> | Path to the Solidity file | Built-in default path (for development) |

Paths are resolved relative to the current working directory. Use this for quick inspection or piping into other tools.

Example:

intentspec extract-natspec -f contracts/UserProxy.sol | jq .

NatSpec tags

The CLI only includes in the spec what you declare with these tags. Put them in block comments (/** ... */) directly above the contract or function.

Contract-level (block above contract Name {)

| Tag | Purpose | Example | |-----|---------|--------| | @custom:agent-version | Contract version | @custom:agent-version 1.0 | | @custom:agent-description | Short description | @custom:agent-description Proxy for user ops. | | @custom:agent-invariant | Invariant (can repeat) | @custom:agent-invariant owner is immutable. | | @custom:agent-event | Event name + description | @custom:agent-event Transfer Token balance change. |

Function-level (block above each function)

| Tag | Purpose | Example | |-----|---------|--------| | @custom:agent-intent | Required. One-line intent | @custom:agent-intent Withdraws ERC20 to an address. | | @custom:agent-precondition | Precondition (can repeat) | @custom:agent-precondition Caller is owner or user. | | @custom:agent-effect | Effect (can repeat) | @custom:agent-effect Balance decreases; emits Transfer. | | @custom:agent-risk | Risk (can repeat) | @custom:agent-risk Irreversible transfer. | | @custom:agent-guidance | Guidance for agents | @custom:agent-guidance Check balance before calling. |

Only functions that have @custom:agent-intent are included in the generated spec. Preconditions, effects, risks, and guidance are optional and can appear multiple times (they become arrays in JSON).


Output schema

Generated JSON follows the Intent Spec schema. Each file under intentspec/ looks like:

{
  "contract": {
    "name": "UserProxy",
    "version": "1.0",
    "description": "Proxy for user operations."
  },
  "functions": [
    {
      "name": "withdrawERC20",
      "signature": "0x44004cc1",
      "intent": "Withdraw a specific amount of ERC20 tokens to an address.",
      "preconditions": ["Caller is owner or user.", "token and to are non-zero."],
      "effects": ["Balance decreases; to receives tokens. Emits TokensWithdrawn."],
      "risks": ["Irreversible transfer."],
      "agentGuidance": "Check balance first."
    }
  ],
  "events": [
    { "name": "TokensWithdrawn", "description": "Emitted when tokens are withdrawn." }
  ],
  "invariants": ["owner and user are set at construction and immutable."]
}
  • signature is the EVM function selector in hex (first 4 bytes of keccak256(functionSignature)).
  • contract and functions are required; events and invariants are optional.

Example workflow

  1. Annotate your Solidity contract with @custom:agent-* tags (see NatSpec tags).
  2. Generate specs:
    npx intentspec compile
  3. Inspect intentspec/<ContractName>.json and use it for agents, docs, or publishing (e.g. IPFS + onchain pointer).

Re-run intentspec compile after changing NatSpec to refresh the JSON.


Scripts (from source)

| Script | Description | |--------|-------------| | npm run build | Compile TypeScript and emit to dist/ | | npm run dev | Watch and recompile on change | | npm run start | Run node dist/index.js | | npm run clean | Remove dist/ |


License

MIT. See LICENSE in this folder.