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

intelli-buddy

v1.0.0-alpha.4

Published

Your Smart Coding Friend

Downloads

8

Readme

intelli-buddy

This package provides helpers for working with code and documentation.

Overview

To understand why it is needed and what problems it can solve, please see the examples folder.

Files *.input.[ext] - templates that are received as input.

Files *.output.[ext] - corresponding processed files.

Setup

npm i intelli-buddy

Make an .ai-config.json in the root of your project. You can connect the json schema. It should help you to make a valid config:

{
	"$schema": "node_modules/intelli-buddy/ai-config.schema.json"
}

Then you should fill the config. You can look at the ai-config.example.json and at the config structure for more explanations

API

processFile(path: string, showDiff: boolean)

Function accepts a path to the template file as input. Optionally, as a second argument, you can specify whether to display diffs or immediately overwrite the file.

To be able to highlight areas that need processing when working with files, it was decided to support the tag {{#ai}}any content{{/ai}}.

For example, tag without any attrivutes will correct grammar errors in the text:

{{#ai}}Inside the tags is the content that needs processing{{/ai}}

The tag supports attributes for specifying prompts.

lang="ru|en"

Attribute for translating text. E.g. this content will be translated into the Russian language:

{{#ai lang="ru"}}Text for translation{{/ai}}

Custom language support is implemented through the configuration file:

// .ai-config.json
{
	"langs": {
		"pt": "portuguese"
	}
}

The content will be translated into the Portuguese language:

// **/[fileName].[ext]
{{#ai lang="pt"}}Text for improvement{{/ai}}

prompt="Custom prompt"

An attribute in which you can write your own prompt. For example, this content will be translated into the Portuguese language:

{{#ai prompt="translate text to portuguese"}}Text for translation{{/ai}}

customPromptName="true"

Support for fully custom attributes through the configuration file

// .ai-config.json
{
	"prompts": {
		"func": "return js function by description:"
	}
}

Returns a function that adds up numbers in JavaScript:

// **/your-file.ext
{{#ai func="true"}}summarize numbers{{/ai}}

processData(content: string)

The function takes content and returns the parsed response from the specified endpoint in the config without support for tag syntax

.ai-config.json structure

Config provides 4 top-level fields:

{
	"request": {},
	"response": {},
	"prompts": {},
	"langs": {}
}
  • request - contains a request information
  • response - contains information about response parsing
  • prompts? - optional, custom prompts
  • langs? - optional, additional langs

request field structure

Provides 4 fields for a request building

{
	"url": "string",
	"method": "post",
	"headers": {
		"Auth": "token"
	},
	"body": {
		"foo": "{{prompt}}",
	}
}
  • url - contains the endpoint url
  • method - contains the HTTP request method: POST | PUT
  • headers - contains dictionary of the request headers
  • body - contains the request body
    • To indicate the place where the generated prompt will be inserted, use the placeholder {{prompt}}

response field structure

Provides 4 fields with information for response parsing

{
	"contentPath": "path.to.content",
	"errorPath": "path.to.error",
	"statusCodePath": "path.tp.statusCode",
	"successStatus": [200, 201]
}
  • contentPath - string path to response content
  • errorPath - string path to response error text
  • statusCodePath - string path to response statusCode
  • successStatus - list of successful status codes

prompts field structure

Dictionary where both key and value are strings

{
	"func": "Generate js function by description:"
}

After adding entries, you have the ability to use custom attributes in the tag:

{{#ai func="true"}}Summation of numbers{{/ai}}

A function for summing numbers in JavaScript will be generated, as specified in our prompt.

langs field structure

Dictionary where both key and value are strings

{
	"pt": "portuguese"
}

After adding a custom language, you have the ability to specify its key in the lang attribute

{{#ai lang="pt"}}Text for translation{{/ai}}

Text will be translated into portuguese