@rfany/rf 0.1.0 → 0.2.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/package.json +1 -1
- package/rf.mjs +9 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rfany/rf",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "rollforward's command line for people: what its page does, from a shell or a desktop agent, as you",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": { "type": "git", "url": "git+https://github.com/spoj/rollforward.git", "directory": "cli" },
|
package/rf.mjs
CHANGED
|
@@ -8,11 +8,10 @@ import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
|
8
8
|
const USAGE = `rf login URL TOKEN
|
|
9
9
|
rf ls
|
|
10
10
|
rf pull DIR a read-only mirror of what you can see, in the layout agents see
|
|
11
|
-
rf comment PATH TEXT [--item ID] [--ref REF] [--thread T] [--wait]
|
|
12
|
-
rf answer PATH NOTE CHOICE CHOICE the option's number, from 0
|
|
11
|
+
rf comment PATH TEXT [--item ID] [--ref REF] [--thread T] [--wait] a new thread, or a reply in T, as to an agent's ask
|
|
13
12
|
rf upload PATH FILE [--onto ITEM] [--output]
|
|
14
13
|
rf wake PATH AT REASON [--label LABEL] AT now, +<n>m|h|d or a date; PATH an open instance, or a series with LABEL
|
|
15
|
-
rf
|
|
14
|
+
rf agents [WORKSPACE] [--set FILE|-] the company's AGENTS.md, or a workspace's; setting the company's is for admins
|
|
16
15
|
rf skills
|
|
17
16
|
rf websites
|
|
18
17
|
|
|
@@ -72,9 +71,9 @@ const under = (base , rel ) => resolve(base, rel).startsWith(resol
|
|
|
72
71
|
async function pull(dir ) {
|
|
73
72
|
const manifest = join(dir, '.rf-pull.json'), had = existsSync(manifest) ? JSON.parse(readFileSync(manifest, 'utf8')) : {};
|
|
74
73
|
const now = {}, tree = await get('/api');
|
|
75
|
-
write(join(dir, '
|
|
74
|
+
write(join(dir, 'AGENTS.md'), (await get('/agents')).text);
|
|
76
75
|
for (const w of tree) {
|
|
77
|
-
write(join(dir, w.name, '
|
|
76
|
+
write(join(dir, w.name, 'AGENTS.md'), w.agents);
|
|
78
77
|
for (const s of w.series) for (const i of s.instances) now[i.id] = { path: join(w.name, s.name, i.label), files: {} };
|
|
79
78
|
}
|
|
80
79
|
for (const [id, old] of Object.entries (had)) if (now[id]?.path !== old.path) rmSync(join(dir, old.path), { recursive: true, force: true });
|
|
@@ -117,7 +116,7 @@ if (cmd === 'login' && url && token) {
|
|
|
117
116
|
} else if (cmd === 'ls') {
|
|
118
117
|
for (const w of await get('/api')) for (const s of w.series) {
|
|
119
118
|
console.log(`${w.name}/${s.name}${s.wake ? ` wakes ${s.wake.at} to start ${s.wake.label}: ${s.wake.reason}` : ''}${s.requests.length ? ` ${s.requests.length} asking to start` : ''}`);
|
|
120
|
-
for (const i of s.instances) console.log(`${w.name}/${s.name}/${i.label} ${i.status}${i.running ? ', running' : ''}${i.
|
|
119
|
+
for (const i of s.instances) console.log(`${w.name}/${s.name}/${i.label} ${i.status}${i.running ? ', running' : ''}${i.asks.length ? `, ${i.asks.length} asks waiting` : ''}${i.wake ? `, wakes ${i.wake}` : ''}, runner ${i.runner}`);
|
|
121
120
|
}
|
|
122
121
|
} else if (cmd === 'pull' && args[0]) await pull(args[0]);
|
|
123
122
|
else if (cmd === 'comment' && args.length === 2) {
|
|
@@ -131,13 +130,10 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
131
130
|
const log = (await get(at)).log, done = log.find(e => e.op === 'done' && e.seen >= seq);
|
|
132
131
|
if (!done) continue;
|
|
133
132
|
const from = Math.max(seq, log.find(e => e.op === 'run' && e.run === done.run).seq);
|
|
134
|
-
for (const e of log.filter(e => e.seq > from && e.seq < done.seq && ((e.op === 'comment' && e.by === 'agent') || e.op === 'report'))) console.log(`${e.op === '
|
|
133
|
+
for (const e of log.filter(e => e.seq > from && e.seq < done.seq && ((e.op === 'comment' && e.by === 'agent') || e.op === 'report'))) console.log(`${e.op === 'report' ? 'Report' : `${e.ask ? 'Asks' : 'Says'} in ${e.thread}`}:\n${e.text}\n`);
|
|
135
134
|
if (done.error) console.log(`The run failed: ${done.error}`);
|
|
136
135
|
break;
|
|
137
136
|
}
|
|
138
|
-
} else if (cmd === 'answer' && args.length === 3) {
|
|
139
|
-
await post(`${(await find(args[0])).at}/answer`, { note: args[1], choice: Number(args[2]) });
|
|
140
|
-
console.log('answered');
|
|
141
137
|
} else if (cmd === 'upload' && args.length === 2) {
|
|
142
138
|
const q = new URLSearchParams({ name: basename(args[1]), pane: flags.output ? 'out' : 'in', ...(typeof flags.onto === 'string' && { onto: flags.onto }) });
|
|
143
139
|
await api(`${(await find(args[0])).at}/upload?${q}`, { method: 'POST', body: readFileSync(args[1]) });
|
|
@@ -147,13 +143,13 @@ else if (cmd === 'comment' && args.length === 2) {
|
|
|
147
143
|
const at = args[1] === 'now' ? Date.now() : args[1].startsWith('+') ? Date.now() + Number(args[1].slice(1, -1)) * { m: 60e3, h: 3600e3, d: 86400e3 }[args[1].at(-1) ] : Date.parse(args[1]);
|
|
148
144
|
const w = await (await post(`/api/wakes/${inst?.id ?? series.id}`, { at: new Date(at).toISOString(), reason: args.slice(2).join(' '), label: flags.label }, 'PUT')).json();
|
|
149
145
|
console.log(`wakes at ${w.at}`);
|
|
150
|
-
} else if (cmd === '
|
|
146
|
+
} else if (cmd === 'agents' && args.length <= 1) {
|
|
151
147
|
const ws = args[0] === undefined ? undefined : (await get('/api')).find(w => w.name === args[0]);
|
|
152
148
|
if (args[0] !== undefined && !ws) throw new Error(`no workspace ${args[0]}`);
|
|
153
|
-
if (typeof flags.set !== 'string') console.log(ws ? ws.
|
|
149
|
+
if (typeof flags.set !== 'string') console.log(ws ? ws.agents : (await get('/agents')).text);
|
|
154
150
|
else {
|
|
155
151
|
const text = readFileSync(flags.set === '-' ? 0 : flags.set, 'utf8');
|
|
156
|
-
await (ws ? post(`/api/workspaces/${ws.id}`, {
|
|
152
|
+
await (ws ? post(`/api/workspaces/${ws.id}`, { agents: text }, 'PUT') : api('/agents', { method: 'PUT', body: text }));
|
|
157
153
|
console.log('saved');
|
|
158
154
|
}
|
|
159
155
|
} else if (cmd === 'skill' && args[0] === 'push' && args[1]) {
|