Skip to main content

scaf_code

scaf_code is an innovative command-line tool designed to streamline the process of generating code. By leveraging the capabilities of Large Language Models, scaf_code can transform your reference and specification files into working code that meets your project's requirements.

Features

  • Code Generation: Generate code that adheres to your specifications using reference files.
  • Support for Images: Include images as references for visual specifications.
  • Customizable: Use command-line options to tailor the code generation process to your needs.
  • Easy to Install: Get started quickly with a simple pip command.
  • Refinement: Refine existing code by providing additional context or corrections.

Installation

To install scaf_code, run the following command in your terminal:

pip install scaf_code

Configuration

Before using scaf_code, you need to set your OpenAI API key as an environment variable:

export OPENAI_API_KEY=<your_openai_api_key>

Usage

To use scaf_code, you'll need to provide reference files, a specification, and an output path. Here's the basic syntax:

scaf_code --ref <ref_file>... --spec "<spec_text>" --out <output_path>

You can also specify a specification file instead of inline text:

scaf_code --ref <ref_file>... --spec-file <spec_file> --out <output_path>

To refine existing code, provide the file to be refined along with the reference files and specification:

scaf_code --refine <refine_file> --ref <ref_file>... --spec "<spec_text>"

The --refine option allows you to improve or modify existing code. When using this option, scaf_code will take the provided file and apply the changes specified in the specification text. This is particularly useful for optimizing code, fixing bugs, or adding new features.

When refining code, you can use the --no-backup option to prevent scaf_code from creating a backup of the original file. This is useful if you are confident in the changes being made and do not require a backup.

Options

  • --ref: One or more reference files. Images are supported with .jpg, .png, .gif, and .webp extensions.
  • --spec: The specification text describing what code to generate.
  • --spec-file: A file containing the specification text.
  • --out: The path to the output file where the generated code will be saved.
  • --refine: The file to be refined. This option is used to refine existing code.
  • --no-backup: Do not create a backup of the original file when using the --refine option.

Examples

Generating Code from Text Specifications

To generate a Python test file based on existing code files and a text specification:

scaf_code --out tests/test_scaffold_code.py --ref scaf_code/cli.py scaf_code/scaffold_code.py --spec "write pytest to scaf_code.scaffold_code.py"

Using Images as References

To generate code that processes an image according to an algorithm specified in a reference image:

scaf_code --out tests/test_image_processing.py --ref image_processing_algorithm.jpg --spec "write a function to process an image according to the algorithm specified in the reference image"

Refining Existing Code

To refine an existing Python script with additional specifications:

scaf_code --refine existing_script.py --ref additional_context.py --spec "optimize the existing function for better performance"

To refine the script without creating a backup file:

scaf_code --refine existing_script.py --ref additional_context.py --spec "optimize the existing function for better performance" --no-backup

Contributing

Contributions are welcome! If you have ideas for improvements or have found a bug, please open an issue or submit a pull request on our GitHub repository.

License

scaf_code is released under the MIT License.

Support

If you need help or have any questions, please open an issue on the GitHub repository, and we'll do our best to assist you.

Happy coding!

Release files for scaf-code 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scaf-code 0.3.3
File Size Uploaded
scaf_code-0.3.3.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scaf-code 0.3.3
File Interpreter ABI Platform
scaf_code-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size:13.9 kB

Release files / scaf_code-0.3.3.tar.gz

Download URL scaf_code-0.3.3.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ae119ac10f6b5d02a6d947395ab881de77446c3ca299cee5b9d7f92ff5a4436a
BLAKE2b-256 checksum
How to use checksums
57cb6897c4dcd0910d2f5133eb6e8d4d30a7c46ce94a871ee900122c34e32fe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.2 Darwin/23.2.0

Release files / scaf_code-0.3.3-py3-none-any.whl

Download URL scaf_code-0.3.3-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dac485ccec82a28fa0707dfcc05b32e459d4bddb3bb942ef060dfd2bf8f40a45
BLAKE2b-256 checksum
How to use checksums
900369fc051fa4ee02d342349f1ca299ce515f77b427ebff3e41301f6685dc76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.2 Darwin/23.2.0

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page