@firefunc-agent/runner 0.7.1 → 0.9.3
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 +7 -3
- package/README.md +296 -4
- package/dist/activity.d.ts +32 -0
- package/dist/activity.js +295 -0
- package/dist/api.d.ts +69 -1
- package/dist/api.js +114 -3
- package/dist/brief.d.ts +11 -0
- package/dist/brief.js +278 -0
- package/dist/build-info.json +4 -0
- package/dist/cli.js +59 -2
- package/dist/config.d.ts +7 -0
- package/dist/config.js +3 -0
- package/dist/cut.d.ts +45 -0
- package/dist/cut.js +105 -0
- package/dist/daemon.d.ts +16 -0
- package/dist/daemon.js +196 -7
- package/dist/declined.d.ts +11 -0
- package/dist/declined.js +27 -0
- package/dist/engines/antigravity.d.ts +2 -0
- package/dist/engines/antigravity.js +102 -0
- package/dist/engines/claude-budget.d.ts +1 -1
- package/dist/engines/claude-budget.js +2 -72
- package/dist/engines/claude.js +139 -2
- package/dist/engines/codex.js +10 -3
- package/dist/engines/copilot.d.ts +2 -0
- package/dist/engines/copilot.js +117 -0
- package/dist/engines/cursor.js +4 -0
- package/dist/engines/gemini.js +6 -1
- package/dist/engines/index.d.ts +2 -0
- package/dist/engines/index.js +22 -4
- package/dist/engines/types.d.ts +12 -1
- package/dist/exec.d.ts +3 -0
- package/dist/exec.js +48 -5
- package/dist/firefunc/agents.d.ts +2 -0
- package/dist/firefunc/agents.js +343 -0
- package/dist/firefunc/args.d.ts +18 -0
- package/dist/firefunc/args.js +82 -0
- package/dist/firefunc/auth.d.ts +21 -0
- package/dist/firefunc/auth.js +129 -0
- package/dist/firefunc/catalog.d.ts +10 -0
- package/dist/firefunc/catalog.js +201 -0
- package/dist/firefunc/cli.d.ts +2 -0
- package/dist/firefunc/cli.js +24 -0
- package/dist/firefunc/client.d.ts +36 -0
- package/dist/firefunc/client.js +177 -0
- package/dist/firefunc/command.d.ts +28 -0
- package/dist/firefunc/command.js +35 -0
- package/dist/firefunc/config.d.ts +29 -0
- package/dist/firefunc/config.js +111 -0
- package/dist/firefunc/configure.d.ts +6 -0
- package/dist/firefunc/configure.js +409 -0
- package/dist/firefunc/io.d.ts +25 -0
- package/dist/firefunc/io.js +14 -0
- package/dist/firefunc/main.d.ts +4 -0
- package/dist/firefunc/main.js +259 -0
- package/dist/firefunc/output.d.ts +29 -0
- package/dist/firefunc/output.js +131 -0
- package/dist/firefunc/prompt.d.ts +14 -0
- package/dist/firefunc/prompt.js +58 -0
- package/dist/firefunc/skill.d.ts +3 -0
- package/dist/firefunc/skill.js +80 -0
- package/dist/firefunc/tasks.d.ts +2 -0
- package/dist/firefunc/tasks.js +279 -0
- package/dist/firefunc/version.d.ts +2 -0
- package/dist/firefunc/version.js +8 -0
- package/dist/git-auth.d.ts +4 -1
- package/dist/git-auth.js +6 -2
- package/dist/held.d.ts +18 -0
- package/dist/held.js +95 -0
- package/dist/job.d.ts +3 -0
- package/dist/job.js +818 -102
- package/dist/keep-local.d.ts +12 -0
- package/dist/keep-local.js +651 -0
- package/dist/limit.d.ts +30 -0
- package/dist/limit.js +258 -0
- package/dist/locks.d.ts +14 -0
- package/dist/locks.js +164 -0
- package/dist/machine-logins.d.ts +19 -0
- package/dist/machine-logins.js +187 -0
- package/dist/mcp-login.d.ts +24 -0
- package/dist/mcp-login.js +993 -0
- package/dist/mcp-proxy.d.ts +21 -0
- package/dist/mcp-proxy.js +180 -0
- package/dist/mcp.d.ts +62 -0
- package/dist/mcp.js +611 -0
- package/dist/network.d.ts +20 -0
- package/dist/network.js +76 -0
- package/dist/orphans.d.ts +40 -0
- package/dist/orphans.js +235 -0
- package/dist/pending.d.ts +14 -0
- package/dist/pending.js +56 -0
- package/dist/pool.d.ts +7 -0
- package/dist/pool.js +57 -9
- package/dist/pr-title.d.ts +11 -0
- package/dist/pr-title.js +63 -0
- package/dist/recover.d.ts +10 -0
- package/dist/recover.js +104 -0
- package/dist/secret-scan.d.ts +19 -0
- package/dist/secret-scan.js +161 -0
- package/dist/session-stream.d.ts +9 -1
- package/dist/session-stream.js +20 -2
- package/dist/skills.d.ts +11 -0
- package/dist/skills.js +164 -0
- package/dist/stopped.d.ts +3 -0
- package/dist/stopped.js +10 -0
- package/dist/usage.d.ts +49 -0
- package/dist/usage.js +389 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +17 -0
- package/dist/viewer.js +7 -1
- package/dist/worktrees.d.ts +15 -0
- package/dist/worktrees.js +96 -0
- package/package.json +8 -5
- package/skill/firefunc/SKILL.md +222 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { str, UsageError } from './args.js';
|
|
2
|
+
import { listIn, pick, resolveProject } from './catalog.js';
|
|
3
|
+
import { enc, readInputFile } from './command.js';
|
|
4
|
+
import { Refusal } from './io.js';
|
|
5
|
+
import { printJson, table, text } from './output.js';
|
|
6
|
+
function parseJsonFile(raw, path, want) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(raw);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
throw new Refusal(`--file ${path} is not valid JSON (${err.message}).`, `Write ${want} as JSON.`, 'bad_file');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function requireFile(ctx) {
|
|
15
|
+
const path = str(ctx.args, 'file');
|
|
16
|
+
if (path === undefined) {
|
|
17
|
+
throw new UsageError('Pass --file <path> ("-" for stdin).', ctx.command);
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
export function frontmatterOf(md) {
|
|
22
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(md);
|
|
23
|
+
if (!m)
|
|
24
|
+
return { fields: {}, hasFrontmatter: false };
|
|
25
|
+
const fields = {};
|
|
26
|
+
for (const line of m[1].split(/\r?\n/)) {
|
|
27
|
+
const kv = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line);
|
|
28
|
+
if (!kv)
|
|
29
|
+
continue;
|
|
30
|
+
fields[kv[1]] = kv[2].trim().replace(/^(['"])(.*)\1$/, '$2');
|
|
31
|
+
}
|
|
32
|
+
return { fields, hasFrontmatter: true };
|
|
33
|
+
}
|
|
34
|
+
const slugOf = (name) => name
|
|
35
|
+
.toLowerCase()
|
|
36
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
37
|
+
.replace(/^-+|-+$/g, '')
|
|
38
|
+
.slice(0, 64);
|
|
39
|
+
const looksLikeJson = (path, raw) => path.toLowerCase().endsWith('.json') || raw.trimStart().startsWith('{');
|
|
40
|
+
async function skillFromFile(ctx, path, forCreate) {
|
|
41
|
+
const raw = await readInputFile(ctx.io, path, 'file');
|
|
42
|
+
const name = str(ctx.args, 'name');
|
|
43
|
+
const description = str(ctx.args, 'description');
|
|
44
|
+
const slug = str(ctx.args, 'slug');
|
|
45
|
+
let body;
|
|
46
|
+
if (looksLikeJson(path, raw)) {
|
|
47
|
+
const parsed = parseJsonFile(raw, path, 'the skill');
|
|
48
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
49
|
+
throw new Refusal(`--file ${path} must hold one JSON object.`, 'Write the skill as { "slug", "name", "description", "content" }, or pass a SKILL.md.', 'bad_file');
|
|
50
|
+
}
|
|
51
|
+
body = { ...parsed };
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const { fields, hasFrontmatter } = frontmatterOf(raw);
|
|
55
|
+
const n = name ?? fields.name;
|
|
56
|
+
const d = description ?? fields.description;
|
|
57
|
+
if (!n && (forCreate || !hasFrontmatter)) {
|
|
58
|
+
throw new Refusal(`--file ${path} is a SKILL.md with no name in its frontmatter.`, 'Add "name:" to its frontmatter, or pass --name.', 'skill_needs_name');
|
|
59
|
+
}
|
|
60
|
+
body = {
|
|
61
|
+
...(n ? { name: n } : {}),
|
|
62
|
+
...(d !== undefined || forCreate ? { description: d ?? '' } : {}),
|
|
63
|
+
content: hasFrontmatter
|
|
64
|
+
? raw
|
|
65
|
+
: `---\nname: ${n}\ndescription: ${d ?? ''}\n---\n\n${raw.trim()}\n`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (name !== undefined)
|
|
69
|
+
body.name = name;
|
|
70
|
+
if (description !== undefined)
|
|
71
|
+
body.description = description;
|
|
72
|
+
if (forCreate) {
|
|
73
|
+
if (slug !== undefined)
|
|
74
|
+
body.slug = slug;
|
|
75
|
+
if (body.slug === undefined && typeof body.name === 'string')
|
|
76
|
+
body.slug = slugOf(body.name);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
delete body.slug;
|
|
80
|
+
}
|
|
81
|
+
return body;
|
|
82
|
+
}
|
|
83
|
+
const skillName = (s) => `“${text(s.name)}” (${text(s.slug)})`;
|
|
84
|
+
const INSTRUCTION_LABELS = {
|
|
85
|
+
agent: 'Agent instructions',
|
|
86
|
+
gather: 'What to gather before starting',
|
|
87
|
+
pr_title: 'Pull request titles',
|
|
88
|
+
pr_body: 'Pull request descriptions',
|
|
89
|
+
commit: 'Commit messages',
|
|
90
|
+
};
|
|
91
|
+
function printInstructions(ctx, body, verb) {
|
|
92
|
+
const project = (body.project ?? {});
|
|
93
|
+
const instructions = (body.instructions ?? {});
|
|
94
|
+
const set = Object.entries(instructions).filter(([, v]) => typeof v === 'string' && v);
|
|
95
|
+
const lines = [
|
|
96
|
+
`${verb ? `${verb} the` : 'The'} standing instructions of ${text(project.name)} (${text(project.id)}).`,
|
|
97
|
+
];
|
|
98
|
+
if (!set.length) {
|
|
99
|
+
lines.push('None are set: runs in this project read the workspace’s instructions and the agent’s own.');
|
|
100
|
+
}
|
|
101
|
+
for (const [k, v] of set) {
|
|
102
|
+
lines.push('', `${INSTRUCTION_LABELS[k] ?? k} (${k}):`);
|
|
103
|
+
for (const l of String(v).split('\n'))
|
|
104
|
+
lines.push(` ${l}`);
|
|
105
|
+
}
|
|
106
|
+
if (verb) {
|
|
107
|
+
lines.push('', 'Every run in the project reads them, after the workspace’s instructions and before the agent’s own.');
|
|
108
|
+
}
|
|
109
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
110
|
+
}
|
|
111
|
+
const KIND_LABELS = {
|
|
112
|
+
jira: 'Jira project keys',
|
|
113
|
+
linear: 'Linear teams / projects',
|
|
114
|
+
sentry: 'Sentry projects',
|
|
115
|
+
slack: 'Slack channels',
|
|
116
|
+
figma: 'Figma files',
|
|
117
|
+
};
|
|
118
|
+
function printSources(ctx, body, verb) {
|
|
119
|
+
const project = (body.project ?? {});
|
|
120
|
+
const sources = (body.sources ?? {});
|
|
121
|
+
const bound = Array.isArray(body.claimedThroughBinding)
|
|
122
|
+
? body.claimedThroughBinding.map(String)
|
|
123
|
+
: [];
|
|
124
|
+
const w = Math.max(...Object.values(KIND_LABELS).map((l) => l.length)) + 2;
|
|
125
|
+
const lines = [
|
|
126
|
+
`${verb ? `${verb}. ` : ''}What ${text(project.name)} (${text(project.id)}) claims — work with these keys is routed to it:`,
|
|
127
|
+
];
|
|
128
|
+
for (const [k, label] of Object.entries(KIND_LABELS)) {
|
|
129
|
+
const keys = Array.isArray(sources[k]) ? sources[k].map(String) : [];
|
|
130
|
+
lines.push(` ${label.padEnd(w)}${keys.length ? keys.join(', ') : '—'}${bound.includes(k) ? ' (through its bound account; changed there)' : ''}`);
|
|
131
|
+
}
|
|
132
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
133
|
+
}
|
|
134
|
+
function printRepos(ctx, body, verb) {
|
|
135
|
+
const project = (body.project ?? {});
|
|
136
|
+
const repos = Array.isArray(body.repos) ? body.repos.map(String) : [];
|
|
137
|
+
const lines = [
|
|
138
|
+
`${verb ? `${verb}. ` : ''}${text(project.name)} (${text(project.id)}) lists ${repos.length ? repos.join(', ') : 'no repository'}.`,
|
|
139
|
+
` primary: ${text(body.primaryRepo)}`,
|
|
140
|
+
` updatedAt: ${text(body.updatedAt)} (send it as expectedUpdatedAt to refuse a write over a newer change)`,
|
|
141
|
+
];
|
|
142
|
+
const av = body.available;
|
|
143
|
+
if (av) {
|
|
144
|
+
lines.push('');
|
|
145
|
+
if (av.supported === false) {
|
|
146
|
+
lines.push('This API cannot list the repositories the project’s GitHub account can see.');
|
|
147
|
+
}
|
|
148
|
+
else if (av.connected === false) {
|
|
149
|
+
lines.push('The project has no GitHub account, so no repository can be added to it.');
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
const seen = (av.repos ?? []).map(String);
|
|
153
|
+
lines.push(`Its GitHub account can see ${seen.length} ${seen.length === 1 ? 'repository' : 'repositories'}${av.complete === false ? ' (an account did not answer, so the list may be short)' : ''} — only these can be added:`, ...seen.map((r) => ` ${r}`));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
157
|
+
}
|
|
158
|
+
const NEEDS_CONFIGURE = 'Needs a key granted workspace:configure (off unless ticked in Settings → API keys).';
|
|
159
|
+
function projectCommand(kind, action, spec) {
|
|
160
|
+
return {
|
|
161
|
+
path: ['projects', kind, action],
|
|
162
|
+
summary: spec.summary,
|
|
163
|
+
usage: `projects ${kind} ${action} <project id or name>${action === 'set' ? ' --file <file.json>' : ''}`,
|
|
164
|
+
details: spec.details,
|
|
165
|
+
positional: { min: 1, max: 1 },
|
|
166
|
+
...(action === 'set'
|
|
167
|
+
? {
|
|
168
|
+
flags: { file: 'string' },
|
|
169
|
+
flagHelp: [['--file <path>', `${spec.want} as JSON ("-" for stdin)`]],
|
|
170
|
+
}
|
|
171
|
+
: {}),
|
|
172
|
+
async run(ctx) {
|
|
173
|
+
const project = await resolveProject(ctx, ctx.args.positional[0]);
|
|
174
|
+
const url = `/api/v1/projects/${enc(project.id)}/${kind}`;
|
|
175
|
+
let body;
|
|
176
|
+
if (action === 'get') {
|
|
177
|
+
body = await ctx.api().get(url);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
const path = requireFile(ctx);
|
|
181
|
+
const raw = await readInputFile(ctx.io, path, 'file');
|
|
182
|
+
const parsed = parseJsonFile(raw, path, spec.want);
|
|
183
|
+
const send = spec.body
|
|
184
|
+
? spec.body(parsed, path)
|
|
185
|
+
: (() => {
|
|
186
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
187
|
+
throw new Refusal(`--file ${path} must hold one JSON object.`, `Write ${spec.want} as one JSON object.`, 'bad_file');
|
|
188
|
+
}
|
|
189
|
+
return parsed;
|
|
190
|
+
})();
|
|
191
|
+
body = await ctx.api().put(url, send);
|
|
192
|
+
}
|
|
193
|
+
if (ctx.json)
|
|
194
|
+
return printJson(ctx.io, body);
|
|
195
|
+
spec.print(ctx, body ?? {}, action === 'set' ? spec.verb : undefined);
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export const configureCommands = [
|
|
200
|
+
{
|
|
201
|
+
path: ['skills', 'directory'],
|
|
202
|
+
summary: "FireFunc's curated skills, and which are installed here",
|
|
203
|
+
usage: 'skills directory',
|
|
204
|
+
details: 'Install one with: firefunc skills install <slug> (a key granted workspace:configure).\n' +
|
|
205
|
+
"Each entry's SKILL.md: add --json.",
|
|
206
|
+
async run(ctx) {
|
|
207
|
+
const body = await ctx.api().get('/api/v1/skills/directory');
|
|
208
|
+
if (ctx.json)
|
|
209
|
+
return printJson(ctx.io, body);
|
|
210
|
+
const rows = listIn(body, 'entries');
|
|
211
|
+
if (!rows.length) {
|
|
212
|
+
ctx.io.stdout.write('The directory is empty.\n');
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
table(ctx.io, rows, [
|
|
216
|
+
{ head: 'SLUG', get: pick('slug') },
|
|
217
|
+
{ head: 'CATEGORY', get: pick('category') },
|
|
218
|
+
{ head: 'INSTALLED', get: (r) => (r.installed === true ? 'yes' : 'no') },
|
|
219
|
+
{ head: 'NAME', get: pick('name'), max: 40 },
|
|
220
|
+
{ head: 'DESCRIPTION', get: pick('description'), max: 70 },
|
|
221
|
+
]);
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
path: ['skills', 'install'],
|
|
226
|
+
summary: 'Install a skill from the directory, so agents may carry it',
|
|
227
|
+
usage: 'skills install <slug>',
|
|
228
|
+
details: `${NEEDS_CONFIGURE}\n` +
|
|
229
|
+
'A skill goes into every run of every agent that carries it. Installing one that is\n' +
|
|
230
|
+
'already installed changes nothing. An agent carries it once its "skills" list names\n' +
|
|
231
|
+
'the slug (firefunc agents update <agent> --spec …).',
|
|
232
|
+
positional: { min: 1, max: 1 },
|
|
233
|
+
async run(ctx) {
|
|
234
|
+
const slug = ctx.args.positional[0];
|
|
235
|
+
const body = await ctx
|
|
236
|
+
.api()
|
|
237
|
+
.post('/api/v1/skills/install', { slug });
|
|
238
|
+
if (ctx.json)
|
|
239
|
+
return printJson(ctx.io, body);
|
|
240
|
+
const s = body?.skill ?? { slug };
|
|
241
|
+
ctx.io.stdout.write(body?.installed === false
|
|
242
|
+
? `${skillName(s)} was already installed; nothing changed.\n`
|
|
243
|
+
: `Installed ${skillName(s)}. An agent carries it once its skills list names "${text(s.slug)}".\n`);
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
path: ['skills', 'create'],
|
|
248
|
+
summary: "Write a skill of the workspace's own from a SKILL.md or JSON",
|
|
249
|
+
usage: 'skills create --file <SKILL.md | skill.json> [--slug <slug>] [--name <name>] [--description <text>]',
|
|
250
|
+
details: `${NEEDS_CONFIGURE}\n` +
|
|
251
|
+
'From a SKILL.md: the whole file is the content, and its frontmatter gives the name and\n' +
|
|
252
|
+
'the description (the flags win). A file without frontmatter gets it from --name and\n' +
|
|
253
|
+
'--description. From JSON: { "slug", "name", "description", "content" }.\n' +
|
|
254
|
+
'The slug is --slug, else the name made into one (lower-case, hyphens) — it is how an\n' +
|
|
255
|
+
'agent names the skill. A slug already installed is refused: change that one with\n' +
|
|
256
|
+
'"firefunc skills update".',
|
|
257
|
+
flags: { file: 'string', slug: 'string', name: 'string', description: 'string' },
|
|
258
|
+
flagHelp: [
|
|
259
|
+
['--file <path>', 'a SKILL.md or a JSON skill ("-" for stdin)'],
|
|
260
|
+
['--slug <slug>', 'how agents name it (2-64 lower-case letters, digits, hyphens)'],
|
|
261
|
+
['--name <name>', 'what people call it'],
|
|
262
|
+
['--description <text>', 'the one line the engine reads to decide when it applies'],
|
|
263
|
+
],
|
|
264
|
+
async run(ctx) {
|
|
265
|
+
const send = await skillFromFile(ctx, requireFile(ctx), true);
|
|
266
|
+
const body = await ctx.api().post('/api/v1/skills', send);
|
|
267
|
+
if (ctx.json)
|
|
268
|
+
return printJson(ctx.io, body);
|
|
269
|
+
const s = body?.skill ?? {};
|
|
270
|
+
ctx.io.stdout.write(`Wrote the skill ${skillName(s)} (id ${text(s.id)}). An agent carries it once its skills list names "${text(s.slug)}".\n`);
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
path: ['skills', 'update'],
|
|
275
|
+
summary: 'Change an installed skill (name, description or content)',
|
|
276
|
+
usage: 'skills update <slug or id> [--file <SKILL.md | changes.json>] [--name <name>] [--description <text>]',
|
|
277
|
+
details: `${NEEDS_CONFIGURE}\n` +
|
|
278
|
+
'Sends only what you pass. From a SKILL.md, the content is the whole file and its\n' +
|
|
279
|
+
'frontmatter name and description go with it; from JSON, the fields in it. Every agent\n' +
|
|
280
|
+
'that carries the skill gets the change in its next run.',
|
|
281
|
+
flags: { file: 'string', name: 'string', description: 'string' },
|
|
282
|
+
flagHelp: [
|
|
283
|
+
['--file <path>', 'a SKILL.md or JSON with the fields to change ("-" for stdin)'],
|
|
284
|
+
['--name <name>', 'a new name'],
|
|
285
|
+
['--description <text>', 'a new one-line description'],
|
|
286
|
+
],
|
|
287
|
+
positional: { min: 1, max: 1 },
|
|
288
|
+
async run(ctx) {
|
|
289
|
+
const ref = ctx.args.positional[0];
|
|
290
|
+
const path = str(ctx.args, 'file');
|
|
291
|
+
const send = path ? await skillFromFile(ctx, path, false) : {};
|
|
292
|
+
const name = str(ctx.args, 'name');
|
|
293
|
+
const description = str(ctx.args, 'description');
|
|
294
|
+
if (name !== undefined)
|
|
295
|
+
send.name = name;
|
|
296
|
+
if (description !== undefined)
|
|
297
|
+
send.description = description;
|
|
298
|
+
if (!Object.keys(send).length) {
|
|
299
|
+
throw new UsageError('Nothing to change. Pass --file <SKILL.md | changes.json>, --name or --description.', ctx.command);
|
|
300
|
+
}
|
|
301
|
+
const body = await ctx.api().patch(`/api/v1/skills/${enc(ref)}`, send);
|
|
302
|
+
if (ctx.json)
|
|
303
|
+
return printJson(ctx.io, body);
|
|
304
|
+
ctx.io.stdout.write(`Changed the skill ${skillName(body?.skill ?? { slug: ref })}. Every agent that carries it gets the change in its next run.\n`);
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
projectCommand('instructions', 'get', {
|
|
308
|
+
summary: "A project's standing instructions",
|
|
309
|
+
details: 'What every run in the project is told, after the workspace’s instructions and before\n' +
|
|
310
|
+
'the agent’s own. Needs agents:read.',
|
|
311
|
+
want: 'the instructions',
|
|
312
|
+
print: printInstructions,
|
|
313
|
+
verb: 'Saved',
|
|
314
|
+
}),
|
|
315
|
+
projectCommand('instructions', 'set', {
|
|
316
|
+
summary: "Replace a project's standing instructions",
|
|
317
|
+
details: `${NEEDS_CONFIGURE}\n` +
|
|
318
|
+
'Replaced WHOLE: a field left out (or null, or blank) is cleared — start from\n' +
|
|
319
|
+
'"firefunc projects instructions get <project> --json" and change what you mean to.\n' +
|
|
320
|
+
'The file is { "agent", "gather", "pr_title", "pr_body", "commit" } (each up to 4000\n' +
|
|
321
|
+
'characters), or the answer of "instructions get --json", whose "instructions" is used.',
|
|
322
|
+
want: 'the instructions',
|
|
323
|
+
body: (parsed, path) => {
|
|
324
|
+
const obj = parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
|
|
325
|
+
if (!obj) {
|
|
326
|
+
throw new Refusal(`--file ${path} must hold one JSON object.`, 'Write the instructions as { "agent", "gather", "pr_title", "pr_body", "commit" }.', 'bad_file');
|
|
327
|
+
}
|
|
328
|
+
const inner = obj.instructions;
|
|
329
|
+
return inner && typeof inner === 'object' && !Array.isArray(inner) ? inner : obj;
|
|
330
|
+
},
|
|
331
|
+
print: printInstructions,
|
|
332
|
+
verb: 'Saved',
|
|
333
|
+
}),
|
|
334
|
+
projectCommand('sources', 'get', {
|
|
335
|
+
summary: 'What work a project claims (Jira, Linear, Sentry, Slack, Figma keys)',
|
|
336
|
+
details: 'Work whose key is listed here is routed to this project. Slack and Figma claims marked\n' +
|
|
337
|
+
'"through its bound account" are changed on that account in FireFunc. Needs agents:read.',
|
|
338
|
+
want: 'the sources',
|
|
339
|
+
print: printSources,
|
|
340
|
+
verb: 'Saved',
|
|
341
|
+
}),
|
|
342
|
+
projectCommand('sources', 'set', {
|
|
343
|
+
summary: 'Set what work a project claims',
|
|
344
|
+
details: `${NEEDS_CONFIGURE}\n` +
|
|
345
|
+
'Merged kind by kind: a kind left out is kept, an empty list clears it. The file is\n' +
|
|
346
|
+
'{ "jira": [...], "linear": [...], "sentry": [...] } — Linear keys are a team key\n' +
|
|
347
|
+
'("ENG") or "<TEAM>/<Linear project id>". "slack" and "figma" only remove a leftover\n' +
|
|
348
|
+
'claim. A key another project claims is refused with the project to take it from.\n' +
|
|
349
|
+
'The answer of "sources get --json" round-trips (its "sources" is used).',
|
|
350
|
+
want: 'the sources',
|
|
351
|
+
body: (parsed, path) => {
|
|
352
|
+
const obj = parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : null;
|
|
353
|
+
if (!obj) {
|
|
354
|
+
throw new Refusal(`--file ${path} must hold one JSON object.`, 'Write the sources as { "jira": [...], "linear": [...], "sentry": [...] }.', 'bad_file');
|
|
355
|
+
}
|
|
356
|
+
const inner = obj.sources;
|
|
357
|
+
if (!inner || typeof inner !== 'object' || Array.isArray(inner))
|
|
358
|
+
return obj;
|
|
359
|
+
const send = { ...inner };
|
|
360
|
+
if (Array.isArray(obj.claimedThroughBinding)) {
|
|
361
|
+
for (const k of obj.claimedThroughBinding)
|
|
362
|
+
delete send[String(k)];
|
|
363
|
+
}
|
|
364
|
+
return send;
|
|
365
|
+
},
|
|
366
|
+
print: printSources,
|
|
367
|
+
verb: 'Saved',
|
|
368
|
+
}),
|
|
369
|
+
projectCommand('repos', 'get', {
|
|
370
|
+
summary: "A project's repositories, and the ones its GitHub account can see",
|
|
371
|
+
details: 'The repositories its agents may work in and its GitHub work is routed by, its primary\n' +
|
|
372
|
+
'one, the updatedAt to send back as expectedUpdatedAt, and the repositories the\n' +
|
|
373
|
+
'project’s GitHub account can see (only those can be added). Needs agents:read.',
|
|
374
|
+
want: 'the repositories',
|
|
375
|
+
print: printRepos,
|
|
376
|
+
verb: 'Saved',
|
|
377
|
+
}),
|
|
378
|
+
projectCommand('repos', 'set', {
|
|
379
|
+
summary: "Replace a project's repositories",
|
|
380
|
+
details: `${NEEDS_CONFIGURE}\n` +
|
|
381
|
+
'Replaced WHOLE, with the primary repository: the file is\n' +
|
|
382
|
+
'{ "repos": ["owner/name", ...], "primaryRepo": "owner/name", "expectedUpdatedAt": "…" }\n' +
|
|
383
|
+
'(or just the list, as a JSON array). primaryRepo left out is cleared. A repository\n' +
|
|
384
|
+
'belongs to one project only, and one the project does not list yet must be one its\n' +
|
|
385
|
+
'GitHub account can see ("repos get"). The answer of "repos get --json" round-trips:\n' +
|
|
386
|
+
'its updatedAt is sent as expectedUpdatedAt, so a change made since is not overwritten.',
|
|
387
|
+
want: 'the repositories',
|
|
388
|
+
body: (parsed, path) => {
|
|
389
|
+
if (Array.isArray(parsed))
|
|
390
|
+
return { repos: parsed };
|
|
391
|
+
const obj = parsed && typeof parsed === 'object' ? parsed : null;
|
|
392
|
+
if (!obj) {
|
|
393
|
+
throw new Refusal(`--file ${path} must hold a JSON object or a list of repositories.`, 'Write { "repos": ["owner/name"], "primaryRepo": "owner/name" }, or ["owner/name"].', 'bad_file');
|
|
394
|
+
}
|
|
395
|
+
const send = {};
|
|
396
|
+
if (obj.repos !== undefined)
|
|
397
|
+
send.repos = obj.repos;
|
|
398
|
+
if (obj.primaryRepo !== undefined)
|
|
399
|
+
send.primaryRepo = obj.primaryRepo;
|
|
400
|
+
const expected = obj.expectedUpdatedAt ?? obj.updatedAt;
|
|
401
|
+
if (expected !== undefined)
|
|
402
|
+
send.expectedUpdatedAt = expected;
|
|
403
|
+
return send;
|
|
404
|
+
},
|
|
405
|
+
print: printRepos,
|
|
406
|
+
verb: 'Saved',
|
|
407
|
+
}),
|
|
408
|
+
];
|
|
409
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type Io = {
|
|
2
|
+
stdout: {
|
|
3
|
+
write(s: string): unknown;
|
|
4
|
+
};
|
|
5
|
+
stderr: {
|
|
6
|
+
write(s: string): unknown;
|
|
7
|
+
};
|
|
8
|
+
env: Record<string, string | undefined>;
|
|
9
|
+
home: string;
|
|
10
|
+
cwd: string;
|
|
11
|
+
readSecret(prompt: string): Promise<string>;
|
|
12
|
+
readStdin(): Promise<string>;
|
|
13
|
+
stdinIsTty: boolean;
|
|
14
|
+
fetch: typeof fetch;
|
|
15
|
+
sleep(ms: number): Promise<void>;
|
|
16
|
+
now(): number;
|
|
17
|
+
platform: NodeJS.Platform;
|
|
18
|
+
};
|
|
19
|
+
export declare class Refusal extends Error {
|
|
20
|
+
readonly fix: string | undefined;
|
|
21
|
+
readonly code: string;
|
|
22
|
+
constructor(message: string, fix: string | undefined, code: string);
|
|
23
|
+
}
|
|
24
|
+
export declare const looksLikeSecret: (s: string) => boolean;
|
|
25
|
+
export declare const hideSecrets: (s: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class Refusal extends Error {
|
|
2
|
+
fix;
|
|
3
|
+
code;
|
|
4
|
+
constructor(message, fix, code) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.fix = fix;
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.name = 'Refusal';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const SECRET_SHAPE = /(?<![A-Za-z0-9])ff[a-z0-9]{0,4}_[A-Za-z0-9_-]{8,}/g;
|
|
12
|
+
export const looksLikeSecret = (s) => new RegExp(`^${SECRET_SHAPE.source}`).test(s);
|
|
13
|
+
export const hideSecrets = (s) => s.replace(SECRET_SHAPE, '[a key, not shown]');
|
|
14
|
+
//# sourceMappingURL=io.js.map
|