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

@fnet/io

v0.1.37

Published

## Introduction

Downloads

30

Readme

@fnet/io

Introduction

@fnet/io is a tool designed to facilitate the automation of generating JSON schemas based on source code analysis. It integrates with OpenAI's API to process and interpret source code, specifically focusing on the default exports and their argument structures. The project focuses on creating a YAML-only schema format without additional commentary or explanations. This can be useful for software developers looking to easily generate schemas from their existing codebase.

How It Works

The project operates by taking source code as input and processing it through a series of steps to generate a YAML schema. It utilizes OpenAI's API for analyzing the default export functions or classes within the code. The workflow involves loading configuration, preparing a prompt for OpenAI, executing this prompt, and finally writing the schema to a file.

Key Features

  • Source Code Analysis: Analyzes JavaScript code to focus on the default export and its arguments.
  • OpenAI Integration: Utilizes OpenAI's capabilities to automate the schema creation process.
  • YAML Output: Produces YAML-only JSON schemas for ease of use in various development operations.
  • File Handling: Manages the reading and writing of necessary files during the process.
  • Workflow Automation: Implements a structured workflow to streamline the coding-to-schema transformation.

Conclusion

@fnet/io modestly aids developers by automating the intricate process of schema generation from source code. Its straightforward approach to analyzing code and producing YAML schemas can simplify workflow for developers requiring schema documents without manual intervention.

Developer Guide for @fnet/io

Overview

The @fnet/io library is designed to facilitate workflow automation through orchestration of various tasks primarily involving the OpenAI API. The library provides an engine with a structured workflow for tasks such as reading source files, preparing prompts, executing them via OpenAI's API, and handling the results. Developers can leverage this library to automate complex workflows involving AI prompts and responses.

Installation

To install the @fnet/io library, run one of the following commands in your project directory:

Using npm:

npm install @fnet/io

Using yarn:

yarn add @fnet/io

Usage

The primary usage of the @fnet/io library revolves around its Engine class, which orchestrates a sequence of tasks. Here's a basic usage scenario:

  1. Initialize the Engine.
  2. Run the workflow with parameters defined in the context.

Basic Example

import FnetEngine from '@fnet/io';

async function runWorkflow() {
  const engine = new FnetEngine();

  const params = {
    file: 'path/to/source/file.js',
    title: 'My Document Title'
  };

  try {
    await engine.run(params);
  } catch (error) {
    console.error('An error occurred:', error);
  }
}

runWorkflow();

Examples

Running a Workflow

This example demonstrates how to create and run a workflow using the engine:

import FnetEngine from '@fnet/io';

const params = {
  file: 'myfile.js', // The source file to be read
  title: 'Example Title' // Optional title parameter
};

async function execute() {
  const engine = new FnetEngine();
  
  try {
    const result = await engine.run(params);
    console.log('Workflow result:', result);
  } catch (e) {
    console.error('Error during workflow execution:', e);
  }
}

execute();

Handling Workflow Transitions

Given that the engine processes tasks in a sequence, you can handle transitions between different blocks or steps in the workflow:

import FnetEngine from '@fnet/io';

async function runWithTransitionHandling() {
  const engine = new FnetEngine();
  const params = { file: 'script.js', title: 'Example Script' };

  const result = await engine.run(params);

  // Process the resulting value if needed
  if (result) {
    console.log('Processed result:', result);
  }
}

runWithTransitionHandling();

Acknowledgement

This library makes use of OpenAI's API for certain tasks. Ensure you have valid API credentials set in your environment variables to use the library effectively.

Input Schema

$schema: https://json-schema.org/draft/2020-12/schema
type: object
properties:
  file:
    type: string
    description: The source file path to be set in the workflow.
  title:
    type: string
    description: The title to be set in the workflow.