Skip to content

Commit e082fcb

Browse files
committed
simple workflows
1 parent 55d6615 commit e082fcb

File tree

15 files changed

+939
-2
lines changed

15 files changed

+939
-2
lines changed

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"titleBar.activeBackground": "#5f2068",
4+
"titleBar.activeForeground": "#fff",
5+
"titleBar.inactiveForeground": "#5f2068",
6+
"titleBar.border": "#5f2068",
7+
"activityBar.activeBackground": "#5f2068",
8+
"activityBar.activeBorder": "#5f2068",
9+
"activityBar.inactiveForeground": "#5f2068",
10+
"activityBar.foreground": "#fff",
11+
}
12+
}

.vscode/snippets.code-snippets

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"copyright": {
3+
"description": "A snippet to insert the copyright notice.",
4+
"prefix": "copyright",
5+
"scope": "typescript,javascript,css,html,md,txt,rust,wat",
6+
"body": [
7+
"//\n// Copyright 2025 Formata, Inc. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//"
8+
]
9+
},
10+
"blocksep": {
11+
"description": "A snippet to insert a separation block.",
12+
"prefix": "blocksep",
13+
"scope": "typescript,javascript,css,html,md,rust",
14+
"body": [
15+
"/*****************************************************************************\n * $1\n *****************************************************************************/\n$2"
16+
]
17+
},
18+
"doccomment": {
19+
"description": "A snippet to insert a doc comment.",
20+
"prefix": "doccomment",
21+
"scope": "typescript,javascript,css,html,md,txt,rust,wat,stof",
22+
"body": [
23+
"/**\n * $1\n */\n$2"
24+
]
25+
},
26+
"docinnercomment": {
27+
"description": "A snippet to insert a doc comment.",
28+
"prefix": "docinnercomment",
29+
"scope": "typescript,javascript,css,html,md,txt,rust,wat,stof",
30+
"body": [
31+
"/*!\n * $1\n */\n$2"
32+
]
33+
}
34+
}

README.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,84 @@
1-
# stof-weave
2-
Smart, composable AI workflows in a single declarative Stof file.
1+
# StofWeave
2+
**Smart, composable AI workflows in a single declarative Stof file.**
3+
4+
- [Docs](https://docs.stof.dev)
5+
- [GitHub](https://github.com/dev-formata-io/stof-weave)
6+
- [Stof](https://github.com/dev-formata-io/stof)
7+
- [Discord](https://discord.gg/Up5kxdeXZt)
8+
9+
## What is StofWeave?
10+
**Simple, modular, and composable Stof workflows** with built-in validation, defaults, units, logic, and more, with no extra glue code required.
11+
12+
## Example
13+
```rust
14+
import "@weave";
15+
16+
#[type]
17+
#[extends("Job")]
18+
First: {
19+
#[run]
20+
fn first() {
21+
self.async_handle(async {
22+
sleep(10ms);
23+
const diff = Time.diff(self.get("start"));
24+
self.set("first", diff);
25+
});
26+
}
27+
}
28+
29+
#[type]
30+
#[extends("Job")]
31+
Second: {
32+
#[run(0)]
33+
fn second_0() {
34+
const diff = Time.diff(self.get("start"));
35+
self.set("second_0", diff);
36+
sleep(2ms);
37+
}
38+
39+
#[run(1)]
40+
fn second_1() {
41+
const diff = Time.diff(self.get("start"));
42+
self.set("second_1", diff);
43+
}
44+
}
45+
46+
Weave workflow: {
47+
jobs: [
48+
new First {},
49+
new Second {},
50+
]
51+
}
52+
53+
#[main]
54+
fn run_workflow() {
55+
self.workflow.set("start", Time.now());
56+
self.workflow.run();
57+
58+
assert(self.workflow.delete("start"));
59+
pln(stringify('toml', self.workflow.background));
60+
}
61+
```
62+
```bash
63+
stof test examples/simple
64+
first = 10.0
65+
second_0 = 0.0
66+
second_1 = 2.0
67+
```
68+
69+
## Differentiators
70+
- Single File Simplicity
71+
- Built-in Validation & Healing
72+
- No Glue Code
73+
- Composability
74+
- Stof units, types, logic, etc.
75+
76+
## License
77+
Apache 2.0. See LICENSE for details.
78+
79+
## Feedback & Community
80+
- Open issues or discussions on [GitHub](https://github.com/dev-formata-io/stof)
81+
- Chat with us on [Discord](https://discord.gg/Up5kxdeXZt)
82+
- Star the project to support future development!
83+
84+
> Reach out to info@stof.dev to contact us directly

examples/pkg.stof

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// Copyright 2025 Formata, Inc. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
/*!
18+
* To run examples, first install the Stof CLI (https://crates.io/crates/stof-cli).
19+
* Next, in the stof-weave dir, execute `stof test examples`.
20+
* This command will use the imports defined in this file and run all #[test] functions.
21+
*
22+
* Alternatively, run `stof test examples/<EXAMPLE DIR>` to only run a single example.
23+
*/
24+
25+
import: [
26+
{
27+
path: '../pkg.stof'
28+
format: 'pkg'
29+
},
30+
{
31+
path: 'simple/mod'
32+
as: 'SimpleTests'
33+
},
34+
{
35+
path: 'prompts/mod'
36+
as: 'PromptTests'
37+
},
38+
]

examples/prompts/mod.stof

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//
2+
// Copyright 2025 Formata, Inc. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
18+
#[test]
19+
fn basic_prompt() {
20+
const prompt = <Prompt>.new('simple text');
21+
assert_eq(prompt.out(), 'simple text');
22+
}
23+
24+
25+
#[test]
26+
fn tagged_prompt() {
27+
const prompt = <Prompt>.new('should be tagged', tag = 'tag');
28+
assert_eq(prompt.out(), '<tag>should be tagged</tag>');
29+
}
30+
31+
32+
#[test]
33+
fn composed_prompts() {
34+
const arena = new {};
35+
const prompt = <Prompt>.new(tag = 'outer', arena = arena);
36+
{
37+
prompt.push(<Prompt>.new(tag = 'person', arena = arena,
38+
prompts = [
39+
<Prompt>.new('CJ', tag = 'first-name', arena = arena),
40+
<Prompt>.new('Cummings', tag = 'last-name', arena = arena),
41+
]
42+
));
43+
}
44+
{
45+
prompt.push(<ListPrompt>.new(tag = 'hobbies', arena = arena,
46+
prompts = [
47+
<Prompt>.new('sailing', arena = arena),
48+
<Prompt>.new('dirt biking', arena = arena),
49+
<Prompt>.new('skiing', arena = arena),
50+
]
51+
));
52+
}
53+
const out = prompt.out();
54+
drop(arena);
55+
assert_eq(out, "<outer><person><first-name>CJ</first-name><last-name>Cummings</last-name></person><hobbies>1. sailing\n2. dirt biking\n3. skiing\n</hobbies></outer>");
56+
}
57+
58+
59+
//#[test]
60+
fn oneshot_test() {
61+
const key = '';
62+
const prompt = <Prompt>.new('how long are dog nails on average?');
63+
const response = await <Anthropic.Model>.oneshot(key, prompt);
64+
pln(response);
65+
}

examples/prompts/pkg.stof

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Copyright 2025 Formata, Inc. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import: [
18+
{
19+
path: '../../pkg.stof'
20+
format: 'pkg'
21+
},
22+
'mod'
23+
]

0 commit comments

Comments
 (0)