foldrun 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +149 -0
- package/bin/foldrun.mjs +165 -0
- package/package.json +43 -0
- package/src/commands.mjs +1780 -0
- package/src/credentials.mjs +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 foldrun contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# foldrun
|
|
2
|
+
|
|
3
|
+
**Agents are just folders.** An agent is a folder with a markdown file in it. A flow is
|
|
4
|
+
a numbered list naming agents. You write them, read them, diff them in a pull
|
|
5
|
+
request, and run them from this CLI.
|
|
6
|
+
|
|
7
|
+
Everything here works on a plain folder — no account, no server, no network
|
|
8
|
+
beyond the model call itself.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm install -g foldrun
|
|
12
|
+
export ANTHROPIC_API_KEY=sk-ant-…
|
|
13
|
+
|
|
14
|
+
foldrun init competitor-watch
|
|
15
|
+
cd competitor-watch
|
|
16
|
+
foldrun check # free — no model calls
|
|
17
|
+
foldrun run publish
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Requires Node 22 or newer. `init` and `check` need no API key.
|
|
21
|
+
|
|
22
|
+
## What `init` gives you
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
competitor-watch/
|
|
26
|
+
├── AGENTS.md what every agent here shares
|
|
27
|
+
├── agents/
|
|
28
|
+
│ ├── researcher/agent.md
|
|
29
|
+
│ └── writer/agent.md
|
|
30
|
+
├── flows/publish.md the steps, in order
|
|
31
|
+
├── knowledge/house-style.md given to them; they may read, never write
|
|
32
|
+
├── memory/what-worked.md what they learned; they write here
|
|
33
|
+
└── evals/writer-quality.md what "good" means, as a test
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
An agent is frontmatter for the machine and prose for the model:
|
|
37
|
+
|
|
38
|
+
```markdown
|
|
39
|
+
---
|
|
40
|
+
name: researcher
|
|
41
|
+
description: Finds one thing worth writing about, and says why.
|
|
42
|
+
model: fast
|
|
43
|
+
effort: high
|
|
44
|
+
tools:
|
|
45
|
+
- web
|
|
46
|
+
- read
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Pick exactly one topic, in a short paragraph, and say who it helps and why now.
|
|
50
|
+
Do not write the article.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A flow is the numbers, not the order of the lines — same number runs at the
|
|
54
|
+
same time, different numbers run one after another:
|
|
55
|
+
|
|
56
|
+
```markdown
|
|
57
|
+
---
|
|
58
|
+
name: publish
|
|
59
|
+
trigger: manual
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
1. [[researcher]] — find one topic worth writing about
|
|
63
|
+
2. [[writer]] — draft it
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`model:` takes a tier — `fast`, `default`, `max` — rather than a model id, so a
|
|
67
|
+
workspace doesn't rot when models are renamed. `effort:` is the other half: not
|
|
68
|
+
which brain, but how long it thinks.
|
|
69
|
+
|
|
70
|
+
## Giving an agent real capabilities
|
|
71
|
+
|
|
72
|
+
A **script tool** is a folder holding its definition and the program it runs:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
tools/wordcount/
|
|
76
|
+
├── tool.md transport: script · run: run.py · args: {text: …}
|
|
77
|
+
└── run.py a real file — lint it, test it, run it by hand
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The agent calls it by name with typed arguments and never composes a shell
|
|
81
|
+
command. Arguments arrive as `--flags`, stdout comes back, a non-zero exit is a
|
|
82
|
+
failure. An agent grants it with `tools: [wordcount]`.
|
|
83
|
+
|
|
84
|
+
An **HTTP tool** is one markdown file declaring a base URL, allowed methods and
|
|
85
|
+
headers, with `${SECRET}` placeholders the platform resolves at call time — so
|
|
86
|
+
the model gets the capability and never sees the key. An **MCP server** is
|
|
87
|
+
declared the same way.
|
|
88
|
+
|
|
89
|
+
## Commands
|
|
90
|
+
|
|
91
|
+
| | |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `foldrun init [dir]` | create a workspace you can run immediately |
|
|
94
|
+
| `foldrun check [dir]` | validate agents, flows, tools, evals and knowledge |
|
|
95
|
+
| `foldrun run <target>` | run an agent or a flow |
|
|
96
|
+
| `foldrun eval [name]` | run one eval, or all of them |
|
|
97
|
+
| `foldrun extract [dir]` | move single-file script tools into folders |
|
|
98
|
+
| `foldrun probe <model>` | live check: can this model hold a tool loop here? |
|
|
99
|
+
| `foldrun logs [run-id]` | recent runs, or one run's full event trail |
|
|
100
|
+
| `foldrun secrets set NAME` | store a secret, prompted and never echoed |
|
|
101
|
+
| `foldrun deploy [dir]` | push a workspace into an installation |
|
|
102
|
+
| `foldrun invoke <flow>` | start a flow on a running platform (`--watch` streams its trace) |
|
|
103
|
+
| `foldrun open [page]` | the dashboard for this workspace, in the browser |
|
|
104
|
+
| `foldrun login` | sign this machine in from the browser — no key to copy |
|
|
105
|
+
| `foldrun whoami` | who you are on the platform: account, role, workspaces |
|
|
106
|
+
| `foldrun keys ls` | the account's API keys — also `create <label>`, `revoke <id>` |
|
|
107
|
+
|
|
108
|
+
`foldrun --help` lists every flag.
|
|
109
|
+
|
|
110
|
+
**`check` is the one to run in CI.** It costs nothing and catches what
|
|
111
|
+
otherwise surfaces as a confidently wrong answer at 3am: a step naming an agent
|
|
112
|
+
that doesn't exist, a tool whose program isn't on disk, an eval pointing at a
|
|
113
|
+
flow that was renamed, a knowledge bundle whose index disagrees with its own
|
|
114
|
+
files.
|
|
115
|
+
|
|
116
|
+
## Secrets
|
|
117
|
+
|
|
118
|
+
Declared by name in an agent's frontmatter, never by value:
|
|
119
|
+
|
|
120
|
+
```yaml
|
|
121
|
+
secrets:
|
|
122
|
+
- SLACK_WEBHOOK_TOKEN
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`foldrun secrets set SLACK_WEBHOOK_TOKEN` prompts for it and stores it
|
|
126
|
+
encrypted. Declared secrets are injected as environment variables into the
|
|
127
|
+
agent's scripts and substituted into HTTP headers. They are never returned by
|
|
128
|
+
an API and never reach the model.
|
|
129
|
+
|
|
130
|
+
## Running it somewhere else
|
|
131
|
+
|
|
132
|
+
`foldrun deploy` pushes a workspace into an installation — your own, or a
|
|
133
|
+
hosted one — and `foldrun invoke <flow> --wait` starts a flow there and prints
|
|
134
|
+
the result. A deploy never touches run history, state, secrets, or memory an
|
|
135
|
+
agent wrote: those belong to the installation, not to your git repo.
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
foldrun login # approve it in the browser, once per machine
|
|
139
|
+
foldrun deploy
|
|
140
|
+
foldrun invoke publish --wait
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`foldrun login --url https://your-platform` signs in to your own installation.
|
|
144
|
+
In CI, set `FOLDRUN_URL` and `FOLDRUN_TOKEN` instead — the environment always
|
|
145
|
+
wins over the credentials file, so a job never reads one from disk.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
Apache-2.0.
|
package/bin/foldrun.mjs
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// foldrun — the open-source CLI.
|
|
3
|
+
//
|
|
4
|
+
// Local-first by design: every command here works on a plain folder with no
|
|
5
|
+
// account, no server and no network beyond the model call itself. That is the
|
|
6
|
+
// point. A framework whose free version is a crippled demo gets no adoption,
|
|
7
|
+
// and adoption is the only reason a hosted version has customers.
|
|
8
|
+
//
|
|
9
|
+
// foldrun init [dir] scaffold a working workspace
|
|
10
|
+
// foldrun check [dir] validate it — no model calls, no cost
|
|
11
|
+
// foldrun run <target> run an agent or a flow
|
|
12
|
+
// foldrun eval [name] run evals
|
|
13
|
+
// foldrun probe <model> can this model hold a tool loop? (live check)
|
|
14
|
+
// foldrun logs [run-id] recent runs, or one run's full event trail
|
|
15
|
+
// foldrun secrets <verb> set / ls / rm — the vault, from the terminal
|
|
16
|
+
// foldrun deploy [dir] push a workspace into an installation
|
|
17
|
+
// foldrun invoke <flow> start a flow on a running platform
|
|
18
|
+
// foldrun open [page] the dashboard for this workspace
|
|
19
|
+
// foldrun login sign this machine in from the browser
|
|
20
|
+
// foldrun whoami who the platform thinks this terminal is
|
|
21
|
+
// foldrun keys <verb> ls / create / revoke — the account's API keys
|
|
22
|
+
//
|
|
23
|
+
// `check` is the one to run in CI: it catches the mistakes that otherwise only
|
|
24
|
+
// show up as a confidently wrong answer at 3am.
|
|
25
|
+
|
|
26
|
+
import { fileURLToPath } from "node:url";
|
|
27
|
+
import path from "node:path";
|
|
28
|
+
import process from "node:process";
|
|
29
|
+
|
|
30
|
+
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
31
|
+
|
|
32
|
+
// Node warns about stripping types from a package without "type": "module".
|
|
33
|
+
// True, and not the user's problem — they asked to run an agent.
|
|
34
|
+
process.removeAllListeners("warning");
|
|
35
|
+
process.on("warning", () => {});
|
|
36
|
+
|
|
37
|
+
const [, , command, ...rest] = process.argv;
|
|
38
|
+
|
|
39
|
+
const HELP = `foldrun — agents are just folders
|
|
40
|
+
|
|
41
|
+
foldrun init [dir] create a workspace you can run immediately
|
|
42
|
+
foldrun check [dir] validate agents, flows, tools, evals and knowledge
|
|
43
|
+
foldrun extract [dir] move single-file script tools into folders (tool.md + run.*)
|
|
44
|
+
foldrun run <target> run an agent or flow (target: name, or flow:name)
|
|
45
|
+
foldrun eval [name] run one eval, or all of them
|
|
46
|
+
foldrun probe <model> live check: can this model hold a tool loop here?
|
|
47
|
+
foldrun logs [run-id] recent runs, or one run's full event trail
|
|
48
|
+
foldrun secrets set NAME store a secret (prompted, never echoed) — also ls, rm
|
|
49
|
+
foldrun connect NAME OAuth sign-in from the terminal, stored as an auto-refreshing secret
|
|
50
|
+
foldrun deploy [dir] push a workspace into an installation
|
|
51
|
+
foldrun invoke <flow> start a flow on a running platform (--to <workspace>)
|
|
52
|
+
foldrun open [page] the dashboard for this workspace, in the browser
|
|
53
|
+
|
|
54
|
+
Signing in
|
|
55
|
+
foldrun login sign this machine in from the browser (--token <key> to skip it)
|
|
56
|
+
foldrun logout forget this machine's key, and revoke it where allowed
|
|
57
|
+
foldrun whoami who you are on the platform: account, role, workspaces
|
|
58
|
+
foldrun keys ls the account's API keys — also create <label>, revoke <id>
|
|
59
|
+
foldrun --help
|
|
60
|
+
|
|
61
|
+
Options
|
|
62
|
+
--workspace <dir> the workspace folder (default: .)
|
|
63
|
+
--from <template> start from a shipped template, e.g. templates/hello
|
|
64
|
+
--task "<text>" the instruction for a manual run
|
|
65
|
+
--follow logs: keep tailing a live run (with --url: on the platform)
|
|
66
|
+
--value "<text>" secrets set: skip the prompt (careful with shell history)
|
|
67
|
+
--account secrets: account scope instead of the workspace's
|
|
68
|
+
--wait invoke: hold on and print the result
|
|
69
|
+
--watch invoke: follow the run's trace here as it happens
|
|
70
|
+
--print open: print the URL only
|
|
71
|
+
--from <n> invoke: start at step n; earlier steps are skipped
|
|
72
|
+
--no-browser login, connect: print the address instead of opening it
|
|
73
|
+
--provider <name> connect: google, github, microsoft or linkedin (fills the URLs)
|
|
74
|
+
--scopes "<a b c>" connect: space-separated scopes (default: the provider's example)
|
|
75
|
+
--client-id / --client-secret connect: the OAuth app (prompted if omitted; secret never echoed)
|
|
76
|
+
--port <n> connect: loopback port for the redirect (default 8642 — register http://localhost:8642/callback on the app)
|
|
77
|
+
--authorize-url / --token-url connect: a provider with no preset
|
|
78
|
+
--role <r> keys create: viewer, editor (default) or admin
|
|
79
|
+
--for <workspace> keys create: a deploy key for one workspace (--access read|write)
|
|
80
|
+
|
|
81
|
+
Platform options (deploy, invoke, secrets, logs, keys)
|
|
82
|
+
--to <workspace> workspace on the platform (deploy default: folder name)
|
|
83
|
+
--tenant <name> account to deploy into (default: default, local only)
|
|
84
|
+
--data <dir> the installation's data directory
|
|
85
|
+
--url <url> a running platform (or FOLDRUN_URL, or where you last signed in)
|
|
86
|
+
--token <key> API key for --url (or FOLDRUN_TOKEN, or the one from foldrun login)
|
|
87
|
+
--local deploy: into the installation on this machine, even when signed in
|
|
88
|
+
--commit <sha> deploy: record which commit this is
|
|
89
|
+
--dry-run deploy: check and report, change nothing
|
|
90
|
+
--force deploy: deploy even while runs are in flight
|
|
91
|
+
|
|
92
|
+
Nothing here needs an account. Set ANTHROPIC_API_KEY to run; init and check
|
|
93
|
+
work without one. \`foldrun login\` is for the hosted platform, or your own.`;
|
|
94
|
+
|
|
95
|
+
if (!command || command === "--help" || command === "-h") {
|
|
96
|
+
console.log(HELP);
|
|
97
|
+
process.exit(0);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Flags first, so the workspace is known before anything loads the core:
|
|
101
|
+
// single-workspace mode is an environment decision, read at import time.
|
|
102
|
+
// Flags that take no value. Without the list, `--account --value X` read
|
|
103
|
+
// `--value` as the account's argument and stored an empty secret; `--force
|
|
104
|
+
// ./dir` swallowed the directory. A flag followed by another flag is also
|
|
105
|
+
// boolean, so an unlisted switch at least does not eat its neighbour.
|
|
106
|
+
const BOOLEAN_FLAGS = new Set(["account", "follow", "force", "oauth2", "wait", "watch", "print", "dry-run", "help", "no-browser", "local"]);
|
|
107
|
+
const flags = {};
|
|
108
|
+
const positional = [];
|
|
109
|
+
for (let i = 0; i < rest.length; i++) {
|
|
110
|
+
if (!rest[i].startsWith("--")) {
|
|
111
|
+
positional.push(rest[i]);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const name = rest[i].slice(2);
|
|
115
|
+
const next = rest[i + 1];
|
|
116
|
+
if (BOOLEAN_FLAGS.has(name) || next === undefined || next.startsWith("--")) flags[name] = true;
|
|
117
|
+
else flags[name] = rest[++i];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// `deploy` is the one command that is not about a single folder: it reads a
|
|
121
|
+
// source directory and writes into an installation, which has accounts and
|
|
122
|
+
// many workspaces. Pinning FOLDRUN_WORKSPACE would collapse that layout to one
|
|
123
|
+
// folder and send every deploy to the same place.
|
|
124
|
+
const isDeploy = command === "deploy";
|
|
125
|
+
|
|
126
|
+
// `init` and `check` take a directory; `run` and `eval` take the name of a
|
|
127
|
+
// thing to run, so a directory there would be ambiguous — use --workspace.
|
|
128
|
+
const takesDir = command === "init" || command === "check" || command === "extract";
|
|
129
|
+
const workspace = path.resolve(
|
|
130
|
+
flags.workspace ?? (takesDir ? positional.shift() ?? "." : "."),
|
|
131
|
+
);
|
|
132
|
+
if (!isDeploy) process.env.FOLDRUN_WORKSPACE = workspace;
|
|
133
|
+
|
|
134
|
+
// Where the secrets, keys and run store live.
|
|
135
|
+
//
|
|
136
|
+
// A workspace on a laptop keeps them inside itself, in `.foldrun/`. But a
|
|
137
|
+
// workspace that belongs to an installation sits at
|
|
138
|
+
// `<data>/<tenant>/workspaces/<name>`, and its secrets belong to the tenant,
|
|
139
|
+
// two levels up — so pointing --workspace at one and defaulting to `.foldrun/`
|
|
140
|
+
// opened an empty store beside it. Every declared secret came back missing,
|
|
141
|
+
// and the error told you to add secrets that were already there.
|
|
142
|
+
//
|
|
143
|
+
// The layout says which case this is: a parent directory named `workspaces`
|
|
144
|
+
// only happens in an installation.
|
|
145
|
+
const parent = path.basename(path.dirname(workspace));
|
|
146
|
+
const installationRoot =
|
|
147
|
+
parent === "workspaces" ? path.resolve(workspace, "..", "..", "..") : null;
|
|
148
|
+
|
|
149
|
+
if (isDeploy) {
|
|
150
|
+
// The destination is an installation, so --data names it outright. Without
|
|
151
|
+
// one, dataRoot()'s own default applies: data/ at the project root.
|
|
152
|
+
if (flags.data) process.env.FOLDRUN_DATA = path.resolve(flags.data);
|
|
153
|
+
} else {
|
|
154
|
+
process.env.FOLDRUN_DATA ??= installationRoot ?? path.join(workspace, ".foldrun");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const { run } = await import(path.join(HERE, "../src/commands.mjs"));
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
const code = await run(command, positional, flags, workspace);
|
|
161
|
+
process.exit(code ?? 0);
|
|
162
|
+
} catch (err) {
|
|
163
|
+
console.error(`\n ${err instanceof Error ? err.message : String(err)}\n`);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "foldrun",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Agents are just folders. Write them, check them, run them — on your machine.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"foldrun": "bin/foldrun.mjs"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=22"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@foldrun/core": "^0.2.0"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin",
|
|
18
|
+
"src",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"e2e": "FOLDRUN_E2E=1 FOLDRUN_DATA=$(mktemp -d /tmp/foldrun-e2e-XXXXXX) node --test --test-timeout=300000 tests/e2e.test.ts",
|
|
23
|
+
"test": "FOLDRUN_DATA=$(mktemp -d /tmp/foldrun-test-XXXXXX) node --test tests/cli-secrets.test.ts tests/cli-check-library.test.ts tests/cli-connect.test.ts"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/foldrun-io/foldrun-cli.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://foldrun.io",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/foldrun-io/foldrun-cli/issues"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"agents",
|
|
35
|
+
"llm",
|
|
36
|
+
"markdown",
|
|
37
|
+
"workflows",
|
|
38
|
+
"claude"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|