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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ai-prompt-coder

v1.2.0

Published

`ai-prompt-coder` uses ChatGPT to write code based on `.prompt` files. It will build a prompt based on a set of rules applied to your directory structure. All rules are defined in `.promptRules`. Please see `/examples` for existing rules you can utilise.

Downloads

4

Readme

Introduction

ai-prompt-coder uses ChatGPT to write code based on .prompt files. It will build a prompt based on a set of rules applied to your directory structure. All rules are defined in .promptRules. Please see /examples for existing rules you can utilise.

Usage

Setting up

  • Install

    yarn add ai-prompt-coder
  • Create a .promptRules in your root directory. A basic rule that will be applied to all generated prompts looks as follows:

    -- src/**/*.prompt
    Project written in TypeScript with: React.
  • To exclude files, add them to an array after the glob pattern:

    -- **/components/**/*.tsx.prompt ["**/*.stories.tsx.prompt"]
    Rule applied to all components, excluding StoryBook examples.

A full example may look as follows:

-- src/**/*.prompt

This project uses: TypeScript, React, MUI, lodash, styled-components.

-- **/components/**/*.tsx.prompt ["**/*.stories.tsx.prompt"]

Follow the approach shown in this example:

```tsx
export interface IMyComponentProps {...}
export const MyComponent: React.FC<IMyComponentProps> = ({ ... }) => { ... }
```

No default export.
Include a class comment explaining the purpose of the component.
Use existing MUI components if necessary.

-- **/components/**/*.stories.tsx.prompt

Storybook example demonstrating all props.
Follow the approach shown in this example:

```ts
import React from "react";
import type { Meta, StoryFn } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import { MyComponent, IMyComponentProps } from "./MyComponent";

const meta: Meta = {
  title: "Example/MyComponent",
  component: MyComponent,
  parameters: {
    layout: "centered"
  },
  argTypes: {
    onClick: { action: "clicked" }
  }
};

export default meta;

const Template: StoryFn<IMyComponentProps> = (args) => <MyComponent {...args} />;

export const Default = Template.bind({});
Default.args = {
  onClick: action("digit-click")
};
```

-- **/helpers/*.ts.prompt

Do not include any examples or tests in the code.
Ensure the function is exported.
Add a comment describing the purpose of the function.

-- **/helpers/**/*.spec.ts.prompt

Use Jest for testing.

Generating files

To generate a file:

  • Create a file called _prompts/OUTPUT_NAME.prompt. For example, create Timer.tsx.prompt with the following:

    Create a component named Timer that displays the ellapsed time since started.
  • Run using npx ai-prompt-coder. This will produce a Timer.tsx file.

  • If you are unhappy with the file, delete and run again.

  • You can embed other files using the markup [[./relative-path/filename]]. For example:

    Create a component that displays an Image [[../types/Image.ts]].