foldrun 0.3.0 → 0.4.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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # foldrun
2
2
 
3
+ [![ci](https://github.com/foldrun-io/foldrun-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/foldrun-io/foldrun-cli/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/foldrun)](https://www.npmjs.com/package/foldrun)
5
+ [![licence](https://img.shields.io/badge/licence-Apache--2.0-blue)](LICENSE)
6
+
3
7
  **Agents are just folders.** An agent is a folder with a markdown file in it. A flow is
4
8
  a numbered list naming agents. You write them, read them, diff them in a pull
5
9
  request, and run them from this CLI.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldrun",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Agents are just folders. Write them, check them, run them — on your machine.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "node": ">=22"
12
12
  },
13
13
  "dependencies": {
14
- "@foldrun/core": "^0.2.0"
14
+ "@foldrun/core": "^0.3.0"
15
15
  },
16
16
  "files": [
17
17
  "bin",
@@ -20,7 +20,8 @@
20
20
  ],
21
21
  "scripts": {
22
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"
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
+ "release": "node scripts/release.mjs"
24
25
  },
25
26
  "repository": {
26
27
  "type": "git",
package/src/commands.mjs CHANGED
@@ -4,6 +4,7 @@
4
4
  import fs from "node:fs";
5
5
  import os from "node:os";
6
6
  import path from "node:path";
7
+ import { fileURLToPath } from "node:url";
7
8
  import { credentialFor, defaultPlatform, saveCredential, removeCredential, readCredentials, normaliseUrl } from "./credentials.mjs";
8
9
 
9
10
  const c = {
@@ -47,6 +48,22 @@ function templateFilesFrom(dir) {
47
48
  return out;
48
49
  }
49
50
 
51
+ /** The root of the installed @foldrun/core package — dist/index.js is two levels down. */
52
+ function coreRoot() {
53
+ const entry = fileURLToPath(import.meta.resolve("@foldrun/core"));
54
+ return path.resolve(path.dirname(entry), "..");
55
+ }
56
+ function shippedTemplate(rel) {
57
+ if (path.isAbsolute(rel)) return null;
58
+ const abs = path.join(coreRoot(), rel);
59
+ return fs.existsSync(abs) && fs.statSync(abs).isDirectory() ? abs : null;
60
+ }
61
+ function shippedTemplates() {
62
+ const dir = path.join(coreRoot(), "templates");
63
+ if (!fs.existsSync(dir)) return [];
64
+ return fs.readdirSync(dir).filter((n) => fs.statSync(path.join(dir, n)).isDirectory()).map((n) => `templates/${n}`);
65
+ }
66
+
50
67
  async function init(workspace, from) {
51
68
  // The same definition the dashboard's "+ New workspace" uses — see
52
69
  // core/src/starter.ts for why it is not two lists.
@@ -55,11 +72,16 @@ async function init(workspace, from) {
55
72
  // A template is a source, a workspace is a destination. Keeping the two
56
73
  // words apart is the whole reason `templates/` is not called `examples/`:
57
74
  // there is one place a workspace lives, and it is wherever you make one.
58
- if (from && !fs.existsSync(from)) {
59
- throw new Error(`no template at ${from} pass a directory, e.g. --from templates/hello`);
60
- }
61
- const files = from
62
- ? templateFilesFrom(from)
75
+ // A relative --from is first a directory here, then the same path inside
76
+ // the installed @foldrun/core package, which is where the shipped
77
+ // templates/ live — `--from templates/hello` must work from any directory
78
+ // after `npm i foldrun`, not only from a checkout of the repo.
79
+ const source = from && !fs.existsSync(from) ? shippedTemplate(from) : from;
80
+ if (from && !source) {
81
+ throw new Error(`no template at ${from} — pass a directory, or one that ships with foldrun: ${shippedTemplates().join(", ") || "none found"}`);
82
+ }
83
+ const files = source
84
+ ? templateFilesFrom(source)
63
85
  : starterFiles(path.basename(path.resolve(workspace)));
64
86
 
65
87
  // Whatever the source, the new workspace must ignore the key that decrypts