Skip to content

Commit 77e8afa

Browse files
committed
dist v0.1.0
1 parent b92ba89 commit 77e8afa

File tree

14 files changed

+424
-401
lines changed

14 files changed

+424
-401
lines changed

README.md

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,62 @@
1313
```rust
1414
import "@weave";
1515

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-
4616
Weave workflow: {
17+
str out: ""
18+
4719
jobs: [
48-
new First {},
49-
new Second {},
20+
() => {
21+
let out = &self.out;
22+
out.push("first");
23+
},
24+
{
25+
#[run]
26+
fn fourth() {
27+
self.async_handle(async {
28+
sleep(5ms);
29+
let out = &self.weave().out;
30+
out.push("\nfourth");
31+
});
32+
}
33+
},
34+
{
35+
#[run(0)]
36+
fn second() {
37+
let out = &self.weave().out;
38+
out.push("\nsecond");
39+
}
40+
41+
#[run(1)]
42+
fn third() {
43+
let out = &self.weave().out;
44+
out.push("\nthird");
45+
}
46+
},
5047
]
48+
49+
finalize: () => {
50+
let out = &self.out;
51+
out.push("\nfinal");
52+
}
5153
}
5254

5355
#[main]
5456
fn run_workflow() {
55-
self.workflow.set("start", Time.now());
5657
self.workflow.run();
57-
58-
assert(self.workflow.delete("start"));
59-
pln(stringify('toml', self.workflow.background));
58+
pln(self.workflow.out);
6059
}
6160
```
6261
```bash
63-
stof test examples/simple
64-
first = 10.0
65-
second_0 = 0.0
66-
second_1 = 2.0
62+
stof run example.stof
63+
first
64+
second
65+
third
66+
fourth
67+
final
6768
```
6869

6970
## Differentiators
70-
- Single File Simplicity
71+
- Simplicity
7172
- Built-in Validation & Healing
7273
- No Glue Code
7374
- Composability
@@ -76,6 +77,19 @@ second_1 = 2.0
7677
## License
7778
Apache 2.0. See LICENSE for details.
7879

80+
## Package Stof CLI Command
81+
Run this Stof CLI command to create a pkg file for use.
82+
```
83+
stof pkg . dist/weave.pkg
84+
```
85+
86+
## Install (unpackage) StofWeave
87+
Run this Stof CLI command to unpack the weave.pkg file into you "stof" folder.
88+
After execution, StofWeave will be available as `import '@weave';` in your Stof code.
89+
```
90+
stof unpkg dist/weave.pkg
91+
```
92+
7993
## Feedback & Community
8094
- Open issues or discussions on [GitHub](https://github.com/dev-formata-io/stof)
8195
- Chat with us on [Discord](https://discord.gg/Up5kxdeXZt)

dist/weave.pkg

63.5 KB
Binary file not shown.

examples/async/mod.stof

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
#[type]
19+
#[extends('Job')]
20+
First: {
21+
#[run]
22+
fn first() {
23+
self.async_handle(async {
24+
sleep(10ms);
25+
const diff = Time.diff(self.get('start'));
26+
self.set('first', diff);
27+
});
28+
}
29+
}
30+
31+
#[type]
32+
#[extends('Job')]
33+
Second: {
34+
#[run(0)]
35+
fn second_0() {
36+
const diff = Time.diff(self.get('start'));
37+
self.set('second_0', diff);
38+
sleep(2ms);
39+
}
40+
41+
#[run(1)]
42+
fn second_1() {
43+
const diff = Time.diff(self.get('start'));
44+
self.set('second_1', diff);
45+
}
46+
}
47+
48+
#[test]
49+
fn run_workflow() {
50+
const workflow = <Weave>.new([
51+
new First {},
52+
new Second {},
53+
]);
54+
workflow.set('start', Time.now());
55+
workflow.run();
56+
57+
assert(workflow.delete('start'));
58+
//pln(stringify('toml', workflow.data));
59+
60+
assert(workflow.data.first >= 10ms);
61+
assert(workflow.data.second_0 < workflow.data.second_1);
62+
assert(workflow.data.second_1 >= 2ms);
63+
}

examples/async/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+
]

examples/pkg.stof

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ import: [
2929
},
3030
{
3131
path: 'simple/mod'
32-
as: 'SimpleTests'
32+
as: 'SimpleFlow'
33+
},
34+
{
35+
path: 'async/mod'
36+
as: 'AsyncFlow'
37+
},
38+
{
39+
path: 'readme/mod'
40+
as: 'ReadmeFlow'
3341
},
3442
{
3543
path: 'prompts/mod'
36-
as: 'PromptTests'
44+
as: 'Prompting'
3745
},
3846
]

examples/readme/mod.stof

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
Weave workflow: {
19+
str out: ""
20+
21+
jobs: [
22+
() => {
23+
let out = &self.out;
24+
out.push("first");
25+
},
26+
{
27+
#[run]
28+
fn fourth() {
29+
self.async_handle(async {
30+
sleep(5ms);
31+
let out = &self.weave().out;
32+
out.push("\nfourth");
33+
});
34+
}
35+
},
36+
{
37+
#[run(0)]
38+
fn second() {
39+
let out = &self.weave().out;
40+
out.push("\nsecond");
41+
}
42+
43+
#[run(1)]
44+
fn third() {
45+
let out = &self.weave().out;
46+
out.push("\nthird");
47+
}
48+
},
49+
]
50+
51+
finalize: () => {
52+
let out = &self.out;
53+
out.push("\nfinal");
54+
}
55+
}
56+
57+
#[test]
58+
fn run_workflow() {
59+
self.workflow.run();
60+
assert_eq(self.workflow.out, "first\nsecond\nthird\nfourth\nfinal");
61+
}

examples/readme/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)