-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prompt transformers and operators 🥇
* fix: adding prompt model and transformer logic * fix: the get transformer * fix: make transformer arguments optional completely * fix: context can now run transformer sequence * fix: the split transformer * fix: the run transformer * fix: attempting to resolve nested resolvers * fix: quoted arguments for nested transformers and the echo transformer * fix: lower, snake, title, and upper transformers * fix: transformer docs
- Loading branch information
1 parent
6349046
commit 533c5be
Showing
16 changed files
with
473 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { transformer } from './index' | ||
export const echo: transformer = (_, ...args) => { | ||
return `echo "${args.join(':')}"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { transformer } from './index' | ||
import { ExecuteContext } from '../execute-context' | ||
|
||
function find(context: ExecuteContext, key: string): string | undefined { | ||
if (context.workspace.store.unlocked) { | ||
// is vault unlocked? | ||
// search here first! | ||
const valueMaybe = context.workspace.store.value<string>(key) | ||
if (valueMaybe !== undefined && valueMaybe !== null) { | ||
// value entries can be empty strings | ||
// lets not do a simple falsie here | ||
return valueMaybe | ||
} | ||
} | ||
const valueMaybe = process.env[key] | ||
if (valueMaybe !== undefined) { | ||
return valueMaybe | ||
} | ||
|
||
return undefined | ||
} | ||
export const get: transformer = (context, keyList, fallback = '') => { | ||
const keys = keyList.split(',') | ||
|
||
for (const key of keys) { | ||
const valueMaybe = find(context, key) | ||
if (valueMaybe !== undefined) { | ||
return valueMaybe | ||
} | ||
} | ||
|
||
return fallback | ||
} |
Oops, something went wrong.