danielmiessler / fabric

fabric is an open-source framework for augmenting humans using AI. It provides a modular framework for solving specific problems using a crowdsourced set of AI prompts that can be used anywhere.
https://danielmiessler.com/p/fabric-origin-story
MIT License
25.6k stars 2.72k forks source link

feat: add file-based pattern support #1142

Closed mattjoyce closed 1 week ago

mattjoyce commented 1 week ago

What this Pull Request (PR) does

Add file-based pattern support

This PR adds the ability to load patterns directly from files using explicit path prefixes, making it easier to test and iterate on patterns without requiring installation into the fabric config structure.

Why

Currently, to test a pattern it needs to be instantiated in the fabric config file structure. This change allows for quicker testing and iteration of patterns directly from files.

What

How

Use explicit path prefixes to distinguish file paths from pattern names:


# From files
fabric --pattern ./draft-pattern.txt
fabric --pattern ~/patterns/my-pattern.txt
fabric --pattern ../../shared-patterns/test.txt

# Existing pattern behavior remains unchanged
fabric --pattern patternname
eugeis commented 1 week ago

Hi, thank you for the PR.

Please 1) move the impl. from chatter to in Patterns struct 2) implement variable replacement

mattjoyce commented 1 week ago

@eugeis , you want me to move the new code, and the existing pattern code in chatter.go to pattern.go?

I did implement variable substitution in the new code, line 93 in the pattern.go commit. I think I understand though, we can do variable substitution once. yes?

mattjoyce commented 1 week ago

@eugeis , I have refactored as you asked, but you merged too quickly! :) I have added the new changed to new PR. #1147