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

secreq-rule

v0.1.0

Published

AssemblyScript helper for authoring secreq programmable auto-rules: RuleCtx / Decision types plus the linear-memory ABI glue and a build wrapper around asc.

Downloads

20

Readme

secreq-rule

AssemblyScript helper for authoring programmable secreq auto-rules: you write one function, compile it to a sandboxed WebAssembly module, and the secreq daemon runs it before the consent prompt.

Writing a rule

A rule is a single AssemblyScript file exporting decide:

import { RuleCtx, Decision, approve, pass, deny } from 'secreq-rule';

export function decide(ctx: RuleCtx): Decision {
  if (ctx.wrap == 'gh' && ctx.joinedArgv.startsWith('gh repo delete')) {
    return deny('repo deletes are never auto-approved');
  }
  if (ctx.wrap == 'gh' && ctx.joinedArgv.startsWith('gh api --get ')) {
    return approve();
  }
  return pass(); // fall through to declarative rules / the prompt
}

RuleCtx mirrors the daemon's evaluation context (EvalCtx in src/rules.rs): wrap, joinedArgv, callers ({name, command}[], nearest-first), cwd, and secrets.

Compiling

npm install         # inside this package (pulls assemblyscript)
npx secreq-rule-build my-rule.ts -o my-rule.wasm

The build wrapper generates the wasm ABI entry around your decide, compiles with AssemblyScript's stub runtime (no GC), and produces a core wasm module whose only import is env.abort. Modules importing anything else (WASI, clocks, fs, network) are rejected by the daemon at load time — a rule can only inspect the ctx it is handed and return a decision.

ABI (host ↔ module contract)

Kept in lock-step with src/wasm_rules.rs:

  • module exports memory, alloc(len: i32) -> usize, and decide(ptr: usize, len: i32) -> u64;
  • host JSON-encodes the ctx (UTF-8), copies it into alloc(len), calls decide, and unpacks the returned (ptr << 32) | len to read UTF-8 decision JSON: "approve", "pass", or {"deny": "reason"}.

You never deal with this directly — secreq-rule-build generates the glue.

Publishing (maintainers)

The package ships AssemblyScript source (assembly/*.ts, the root index.ts) plus the plain-JS build wrapper (bin/build.js) — there is no compile step, so publishing is just:

cd packages/secreq-rule
npm publish            # runs from a clean checkout; needs npm auth

The files allowlist in package.json pins exactly what ships (assembly/, bin/, index.ts, asconfig.json; npm always adds package.json + README.md). tests/sdk_publish.rs guards that the allowlist still covers everything secreq-rule-build reaches for at consume time, so a new imported file can't silently drop out of the tarball. Verify the tarball contents before publishing with npm pack --dry-run.