@rollrook-ai/cookbooks 0.0.0-stage → 0.6.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 +24 -2
- package/dist/bin.js +16 -0
- package/dist/checker.js +201 -0
- package/dist/cli.js +792 -0
- package/dist/cookbook_skills.js +158 -0
- package/dist/errors.js +97 -0
- package/dist/git.js +270 -0
- package/dist/github.js +445 -0
- package/dist/installer.js +668 -0
- package/dist/lock.js +179 -0
- package/dist/manifest.js +213 -0
- package/dist/process_runner.js +45 -0
- package/dist/scaffold.js +111 -0
- package/dist/scope.js +40 -0
- package/dist/skills_runner.js +111 -0
- package/dist/source.js +169 -0
- package/dist/template.js +342 -0
- package/docs/commands.md +295 -0
- package/docs/development.md +48 -0
- package/docs/installing.md +114 -0
- package/package.json +48 -4
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cookbooks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`cookbooks` installs Runa cookbooks on a machine, the way `npx skills` installs agent skills. It fetches a cookbook from GitHub, any git URL or a local directory (a repository is installed as a git clone you can edit, commit and push in place), puts its dependencies beside it, installs the skills it brings for Claude Code and Codex, and records all of it in a lock file that rook and RollRook read. It also starts new cookbooks, from scratch or from a template, pins their skills as git submodules, compile-checks them with runa-cc and publishes them to GitHub.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
npx @rollrook-ai/cookbooks add rollrook-ai/gwatch-cookbook # into ./.cookbooks
|
|
8
|
+
npx @rollrook-ai/cookbooks add rollrook-ai/gwatch-cookbook -g # into ~/.cookbooks
|
|
9
|
+
npx @rollrook-ai/cookbooks ls
|
|
10
|
+
npx @rollrook-ai/cookbooks update
|
|
11
|
+
npx @rollrook-ai/cookbooks rm gwatch-cuda-auto-optimization
|
|
12
|
+
|
|
13
|
+
To write a cookbook:
|
|
14
|
+
|
|
15
|
+
npx @rollrook-ai/cookbooks init my-cookbook && cd my-cookbook && git init
|
|
16
|
+
npx @rollrook-ai/cookbooks skill add rollrook-ai/G-Watch@v1.0 --path skills/gwatch-cuda-pc-sampling
|
|
17
|
+
npx @rollrook-ai/cookbooks check
|
|
18
|
+
npx @rollrook-ai/cookbooks add . --link # use this checkout in place, edits and all
|
|
19
|
+
|
|
20
|
+
Or start from a template, a cookbook whose files and pinned skills are copied, and publish it:
|
|
21
|
+
|
|
22
|
+
npx @rollrook-ai/cookbooks init tidy-issues --template bye-world --description "Triage a repository's open issues."
|
|
23
|
+
npx @rollrook-ai/cookbooks publish tidy-issues --owner my-org --private
|
|
24
|
+
|
|
25
|
+
Every command takes `--json`. See [docs/commands.md](docs/commands.md) for every command, flag and JSON shape, [docs/installing.md](docs/installing.md) for how installs, dependencies, skills and the lock file work, and [docs/development.md](docs/development.md) for building and testing.
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import { Cli } from "./cli.js";
|
|
4
|
+
/** Run the command line for this process and exit with its code. */
|
|
5
|
+
async function main() {
|
|
6
|
+
const cli = new Cli({
|
|
7
|
+
list_argv: process.argv.slice(2),
|
|
8
|
+
cwd: process.cwd(),
|
|
9
|
+
home: os.homedir(),
|
|
10
|
+
env: process.env,
|
|
11
|
+
stdout: process.stdout,
|
|
12
|
+
stderr: process.stderr,
|
|
13
|
+
});
|
|
14
|
+
process.exitCode = await cli.run();
|
|
15
|
+
}
|
|
16
|
+
await main();
|
package/dist/checker.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ProcessRunner, ProcessStartError } from "./process_runner.js";
|
|
4
|
+
/** Runs `runa-cc check --format json <dir>` and `runa-cc outline <dir>` from PATH. */
|
|
5
|
+
export class RunaCcCliChecker {
|
|
6
|
+
/** The compiler's command name. */
|
|
7
|
+
static COMMAND = "runa-cc";
|
|
8
|
+
static _DIAGNOSTICS_FORMAT = "runa-cc-diagnostics";
|
|
9
|
+
static _OUTLINE_FORMAT = "runa-cc-outline";
|
|
10
|
+
/** The outline version of a cookbook, whose top-level `skills` lists the folders its modules declare. */
|
|
11
|
+
static _OUTLINE_VERSION_COOKBOOK = 4;
|
|
12
|
+
static _EXIT_OK = 0;
|
|
13
|
+
static _EXIT_REFUSED = 1;
|
|
14
|
+
_env;
|
|
15
|
+
/** @param env - the environment whose PATH is searched and in which runa-cc runs */
|
|
16
|
+
constructor(env) {
|
|
17
|
+
this._env = env;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The runa-cc executable on PATH.
|
|
21
|
+
*
|
|
22
|
+
* @returns its absolute path, or undefined when PATH holds none
|
|
23
|
+
*/
|
|
24
|
+
find() {
|
|
25
|
+
const list_dirs = (this._env["PATH"] ?? "").split(path.delimiter).filter((dir) => dir !== "");
|
|
26
|
+
for (const dir of list_dirs) {
|
|
27
|
+
const candidate = path.join(dir, RunaCcCliChecker.COMMAND);
|
|
28
|
+
if (RunaCcCliChecker._is_executable(candidate)) {
|
|
29
|
+
return candidate;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
/** @inheritDoc */
|
|
35
|
+
async check(dir) {
|
|
36
|
+
const run = await this._run({ dir, list_args: ["check", "--format", "json", dir] });
|
|
37
|
+
if (run.status === "unavailable") {
|
|
38
|
+
return run;
|
|
39
|
+
}
|
|
40
|
+
const list_diagnostics = RunaCcCliChecker._parse(run.stdout);
|
|
41
|
+
if (list_diagnostics === undefined
|
|
42
|
+
|| (run.exit_code !== RunaCcCliChecker._EXIT_OK && run.exit_code !== RunaCcCliChecker._EXIT_REFUSED)) {
|
|
43
|
+
return {
|
|
44
|
+
status: "unavailable",
|
|
45
|
+
checker: run.checker,
|
|
46
|
+
reason: `this runa-cc cannot check a cookbook directory yet (${run.detail})`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
status: run.exit_code === RunaCcCliChecker._EXIT_OK ? "ok" : "refused",
|
|
51
|
+
checker: run.checker,
|
|
52
|
+
list_diagnostics,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** @inheritDoc */
|
|
56
|
+
async skills(dir) {
|
|
57
|
+
const run = await this._run({ dir, list_args: ["outline", dir] });
|
|
58
|
+
if (run.status === "unavailable") {
|
|
59
|
+
return run;
|
|
60
|
+
}
|
|
61
|
+
const document = RunaCcCliChecker._json(run.stdout);
|
|
62
|
+
const is_outline = document?.["format"] === RunaCcCliChecker._OUTLINE_FORMAT;
|
|
63
|
+
const version = document?.["version"];
|
|
64
|
+
if (is_outline && version !== RunaCcCliChecker._OUTLINE_VERSION_COOKBOOK) {
|
|
65
|
+
return {
|
|
66
|
+
status: "unavailable",
|
|
67
|
+
checker: run.checker,
|
|
68
|
+
reason: `this runa-cc writes outline version ${JSON.stringify(version) ?? "none"}, `
|
|
69
|
+
+ `and cookbooks reads version ${RunaCcCliChecker._OUTLINE_VERSION_COOKBOOK}`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (is_outline && run.exit_code === RunaCcCliChecker._EXIT_REFUSED) {
|
|
73
|
+
return {
|
|
74
|
+
status: "unavailable",
|
|
75
|
+
checker: run.checker,
|
|
76
|
+
reason: "runa-cc refused the cookbook; run cookbooks check for its faults",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const list_skills = document === undefined || run.exit_code !== RunaCcCliChecker._EXIT_OK
|
|
80
|
+
? undefined
|
|
81
|
+
: RunaCcCliChecker._parse_skills(document);
|
|
82
|
+
if (list_skills === undefined) {
|
|
83
|
+
return {
|
|
84
|
+
status: "unavailable",
|
|
85
|
+
checker: run.checker,
|
|
86
|
+
reason: `this runa-cc does not list a cookbook's skills (${run.detail})`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
status: "ok",
|
|
91
|
+
checker: run.checker,
|
|
92
|
+
list_skills,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async _run(options) {
|
|
96
|
+
const executable = this.find();
|
|
97
|
+
if (executable === undefined) {
|
|
98
|
+
return {
|
|
99
|
+
status: "unavailable",
|
|
100
|
+
checker: RunaCcCliChecker.COMMAND,
|
|
101
|
+
reason: "runa-cc is not on PATH",
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
let result = { exit_code: 0, stdout: "", stderr: "" };
|
|
105
|
+
try {
|
|
106
|
+
result = await ProcessRunner.run({
|
|
107
|
+
command: executable,
|
|
108
|
+
list_args: options.list_args,
|
|
109
|
+
cwd: options.dir,
|
|
110
|
+
env: this._env,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (err instanceof ProcessStartError) {
|
|
115
|
+
return { status: "unavailable", checker: executable, reason: err.message };
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
const detail = (result.stderr.trim() || result.stdout.trim()).split("\n")[0] ?? "";
|
|
120
|
+
return {
|
|
121
|
+
status: "ran",
|
|
122
|
+
checker: executable,
|
|
123
|
+
exit_code: result.exit_code,
|
|
124
|
+
stdout: result.stdout,
|
|
125
|
+
detail: detail || `exit ${result.exit_code}`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
static _is_executable(file) {
|
|
129
|
+
try {
|
|
130
|
+
fs.accessSync(file, fs.constants.X_OK);
|
|
131
|
+
return fs.statSync(file).isFile();
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
if (err instanceof Error && "code" in err) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
static _parse(stdout) {
|
|
141
|
+
const document = RunaCcCliChecker._json(stdout);
|
|
142
|
+
const list_values = document?.["diagnostics"];
|
|
143
|
+
if (document === undefined
|
|
144
|
+
|| document["format"] !== RunaCcCliChecker._DIAGNOSTICS_FORMAT
|
|
145
|
+
|| !Array.isArray(list_values)) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
const default_file = typeof document["file"] === "string" ? document["file"] : undefined;
|
|
149
|
+
return list_values.map((value) => RunaCcCliChecker._diagnostic({ value, default_file }));
|
|
150
|
+
}
|
|
151
|
+
/** The skills of a cookbook's outline, or undefined when it is not one that lists them. */
|
|
152
|
+
static _parse_skills(document) {
|
|
153
|
+
const list_values = document["skills"];
|
|
154
|
+
if (document["format"] !== RunaCcCliChecker._OUTLINE_FORMAT
|
|
155
|
+
|| !Array.isArray(list_values)) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
const map_skills = new Map();
|
|
159
|
+
for (const value of list_values) {
|
|
160
|
+
const map_skill = typeof value === "object" && value !== null ? value : {};
|
|
161
|
+
const folder = map_skill["path"];
|
|
162
|
+
const name = map_skill["name"];
|
|
163
|
+
if (typeof folder === "string" && typeof name === "string" && !map_skills.has(folder)) {
|
|
164
|
+
map_skills.set(folder, { folder, name });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return [...map_skills.values()];
|
|
168
|
+
}
|
|
169
|
+
static _json(stdout) {
|
|
170
|
+
try {
|
|
171
|
+
const document = JSON.parse(stdout);
|
|
172
|
+
return typeof document === "object" && document !== null && !Array.isArray(document)
|
|
173
|
+
? document
|
|
174
|
+
: undefined;
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
if (err instanceof SyntaxError) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
static _diagnostic(options) {
|
|
184
|
+
const map_record = typeof options.value === "object" && options.value !== null
|
|
185
|
+
? options.value
|
|
186
|
+
: {};
|
|
187
|
+
const span = map_record["span"];
|
|
188
|
+
const start = typeof span === "object" && span !== null && "start" in span ? span.start : undefined;
|
|
189
|
+
const map_start = typeof start === "object" && start !== null ? start : {};
|
|
190
|
+
const text = (value) => (typeof value === "string" ? value : "");
|
|
191
|
+
const number = (value) => (typeof value === "number" ? value : undefined);
|
|
192
|
+
return {
|
|
193
|
+
code: text(map_record["code"]),
|
|
194
|
+
severity: text(map_record["severity"]),
|
|
195
|
+
message: text(map_record["message"]),
|
|
196
|
+
file: typeof map_record["file"] === "string" ? map_record["file"] : options.default_file,
|
|
197
|
+
line: number(map_start["line"]),
|
|
198
|
+
column: number(map_start["column"]),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|