Skip to main content

Create AI prompts with files, directories, and URLs

Project description

ctxkit

PyPI - Status PyPI GitHub PyPI - Python Version

ctxkit is a command line tool for constructing AI prompts containing files, directories, and URLs. For example:

ctxkit -m "Please review the following source code file." -f main.py

The -m argument includes the message text with the generated prompt. The -f argument includes the text of the given file, in this case main.py.

Usage

Using the ctxkit command line application, you can add any number of ordered context items of the following types: configuration files (-c), messages (-m), URLs (-u), files (-f), and directories (-d).

usage: ctxkit [-h] [-g] [-c PATH] [-m TEXT] [-u URL] [-f PATH] [-d PATH]
              [-x EXT] [-l N] [-v VAR EXPR]

options:
  -h, --help          show this help message and exit
  -g, --config-help   display the ctxkit config file format
  -c, --config PATH   include the ctxkit config
  -m, --message TEXT  include the prompt message
  -u, --url URL       include the URL
  -f, --file PATH     include the file
  -d, --dir PATH      include a directory's files
  -x, --ext EXT       include files with the extension
  -l, --depth N       the maximum directory depth, default is 0 (infinite)
  -v, --var VAR EXPR  define a message variable (reference with "{{var}}")

Message Variables

You can specify one or more variable references in a message's text using the syntax, {{var}}. A variable's value is specified using the -v argument. For example:

ctxkit -v package ctxkit -m 'Write a 100 word or less description of the Python "{{package}}"'

Configuration Files

ctxkit JSON configuration files allow you to contruct complex prompts in one or more JSON files.

The ctxkit -g argument outputs the JSON configuration file format defined using the Schema Markdown Language.

# The ctxkit configuration file format
struct CtxKitConfig

    # The list of prompt items
    CtxKitItem[len > 0] items


# A prompt item
union CtxKitItem

    # Config file include
    string config

    # A prompt message
    string message

    # A long prompt message
    string[len > 0] long

    # File include path
    string file

    # Directory include
    CtxKitDir dir

    # URL include
    string url

    # Set a message variable (reference with "{{var}}")
    CtxKitVariable var


# A directory include item
struct CtxKitDir

    # The directory path
    string path

    # The file extensions to include (e.g. ".py")
    string[] exts

    # The directory traversal depth (default is 0, infinite)
    optional int(>= 0) depth


# A variable definition item
struct CtxKitVariable

    # The variable's name
    string name

    # The variable's value
    string value

Development

This package is developed using python-build. It was started using python-template as follows:

template-specialize python-template/template/ ctxkit/ -k package ctxkit -k name 'Craig A. Hobbs' -k email 'craigahobbs@gmail.com' -k github 'craigahobbs' -k noapi 1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctxkit-0.9.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctxkit-0.9.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file ctxkit-0.9.0.tar.gz.

File metadata

  • Download URL: ctxkit-0.9.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ctxkit-0.9.0.tar.gz
Algorithm Hash digest
SHA256 873d6c60fe51658be29382059140e92c0cbe821401bf2445d70840349f6bc56f
MD5 eb3c39e160e2c595f5f380ce372d46b7
BLAKE2b-256 1e1d06dfe67c4deabc6c12aebcab39fc86b09133bb96040428b8695d97b78d8f

See more details on using hashes here.

File details

Details for the file ctxkit-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: ctxkit-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ctxkit-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35a2b30228616d9a9397653aa6d5f6415140cb31cc76668a131d79bd38116fd1
MD5 7b13383bcc7fdc10a800b28cd1e82f1b
BLAKE2b-256 8cd4e975a1f2f9952a78a160ddfd29f7ee5ad739dcc89fcff803e11085ef2634

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page