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

@aiwayds/pi-kimi-cron

v1.0.0

Published

Cron scheduling extension for Pi coding agent, inspired by Kimi Code's cron feature

Readme

@aiwayds/pi-kimi-cron

Cron scheduling extension for the Pi coding agent. Schedule prompts to be injected into the conversation on a recurring schedule using standard 5-field cron expressions.

Acknowledgments

This extension is inspired by and based on the cron scheduling feature from Kimi Code by MoonshotAI.

We thank the Kimi Code team for open-sourcing their implementation, which made this Pi adaptation possible. The original architecture, including the tick-loop scheduler, deterministic jitter, and prompt injection mechanism, was ported from Kimi Code's packages/agent-core/src/tools/cron/ module.

Usage

For Agents (Primary Use Case)

This extension is designed for agent-first usage. The LLM calls the tools directly:

  • CronCreate — Schedule a task with a cron expression
  • CronDelete — Remove a scheduled task
  • CronList — List all scheduled tasks

For Humans (Natural Language)

Human users interact via natural language. The LLM translates your intent into cron expressions:

  • "每周一早上9点生成周报" → CronCreate({cron: "0 9 * * 1", prompt: "生成周报"})
  • "every day at 6pm check build status" → CronCreate({cron: "0 18 * * *", prompt: "check build status"})
  • "list my scheduled tasks" → CronList({})

Installation

npm install @aiwayds/pi-kimi-cron

Then register the extension with Pi (add to your Pi extension configuration):

import cronSchedulerExtension from '@aiwayds/pi-kimi-cron';

export default cronSchedulerExtension;

@earendil-works/pi-coding-agent and typebox are peer dependencies — Pi provides both at runtime.

Tools

| Tool | Description | | ------ | ------------- | | CronCreate | Create a scheduled task with a cron expression and prompt | | CronDelete | Delete a task by its 8-char hex id | | CronList | List all tasks with next fire times |

CronCreate parameters

| Parameter | Type | Description | | ----------- | ------ | ------------- | | cron | string | 5-field cron expression, e.g. "*/5 * * * *" | | prompt | string | Prompt text injected when the task fires | | recurring | boolean (optional) | Repeat after firing (default true); false = one-shot |

Cron Syntax

Standard 5-field cron: minute hour day-of-month month day-of-week

*/5 * * * *     every 5 minutes
0 * * * *       every hour
0 9 * * 1-5     weekdays at 9:00 AM
0 18 * * *      daily at 6:00 PM
0 0 1 * *       monthly on the 1st

Supported field syntax: *, lists (1,3,5), ranges (1-5), steps (*/2), and month/day names (jan, mon).

Examples

CronCreate({ cron: "*/5 * * * *", prompt: "check the build status" })
CronCreate({ cron: "0 9 * * 1", prompt: "生成周报" })
CronCreate({ cron: "0 0 1 * *", prompt: "summarize last month", recurring: false })
CronList({})
CronDelete({ id: "a1b2c3d4" })

Configuration (Environment Variables)

| Variable | Description | | ---------- | ------------- | | PI_CRON_DEBUG=1 | Enable verbose scheduler logging to stderr | | PI_CRON_NO_JITTER=1 | Disable deterministic per-task jitter | | PI_CRON_CLOCK=fixed | Use fixed clock (testing, requires PI_CRON_CLOCK_FIXED_MS) | | PI_CRON_CLOCK=offset | Use offset clock (testing, requires PI_CRON_CLOCK_OFFSET_MS) |

Persistence

Tasks are stored as JSON files at:

~/.pi/agent/cron/<session-id>/<8-hex-id>.json

Limitations

Tasks only fire while Pi is running. The scheduler uses an in-process setInterval tick loop (15s interval). When Pi exits, no tasks fire. On restart, tasks are rehydrated from disk and resume from their last fire time — missed fires are coalesced, not replayed.

Architecture

src/
  index.ts               Extension entry point (tools + lifecycle hooks)
  types.ts               CronTask interface
  cron-expr.ts           5-field cron parser + next-fire calculator
  jitter.ts              Deterministic per-task jitter
  cron-fire-xml.ts       XML envelope renderer for fire injection
  session-store.ts       In-memory task map
  clock.ts               Clock sources (system / fixed / offset)
  per-id-json-store.ts   Generic per-id JSON file store with atomic writes
  persist.ts             Cron task persistence wrapper
  scheduler.ts           Tick-loop engine (15s interval)

License

MIT