oleander-cli 0.27.0 → 0.28.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 +5 -1
- package/dist/index.cjs +229 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -313,7 +313,9 @@ Notebooks round-trip as YAML files, so you (or a coding agent) can edit one in
|
|
|
313
313
|
your editor and review it in a pull request like any other code.
|
|
314
314
|
|
|
315
315
|
```bash
|
|
316
|
+
oleander notebooks list # every notebook you can see
|
|
316
317
|
oleander notebooks pull bluehouse-morning # writes bluehouse-morning.notebook.yaml
|
|
318
|
+
oleander notebooks pull --all # one file per notebook
|
|
317
319
|
oleander notebooks plan bluehouse-morning.notebook.yaml # what saving would change
|
|
318
320
|
oleander notebooks push bluehouse-morning.notebook.yaml --run
|
|
319
321
|
```
|
|
@@ -371,7 +373,9 @@ oleander notebooks sync notebooks/ --approve --publish # save and publish
|
|
|
371
373
|
|
|
372
374
|
`--approve` applies changes that add outputs, a schedule, destinations or a
|
|
373
375
|
budget. `--publish` publishes live notebooks' drafts. `--summary <file>` writes
|
|
374
|
-
a Markdown report.
|
|
376
|
+
a Markdown report. A removed file leaves its notebook in oleander;
|
|
377
|
+
`--removed-since <git-ref> --delete` deletes it. Start a repository with
|
|
378
|
+
`oleander notebooks pull --all`.
|
|
375
379
|
|
|
376
380
|
In GitHub Actions, use
|
|
377
381
|
[OleanderHQ/sync-oleander-notebooks](https://github.com/OleanderHQ/sync-oleander-notebooks):
|
package/dist/index.cjs
CHANGED
|
@@ -45775,7 +45775,7 @@ var import_fs7 = require("fs");
|
|
|
45775
45775
|
// package.json
|
|
45776
45776
|
var package_default = {
|
|
45777
45777
|
name: "oleander-cli",
|
|
45778
|
-
version: "0.
|
|
45778
|
+
version: "0.28.0",
|
|
45779
45779
|
description: "oleander CLI",
|
|
45780
45780
|
keywords: [
|
|
45781
45781
|
"cli",
|
|
@@ -46706,6 +46706,30 @@ var NotebooksClient = class {
|
|
|
46706
46706
|
if (!response.ok) throw await failure(response, fallback2);
|
|
46707
46707
|
return await readBody(response);
|
|
46708
46708
|
}
|
|
46709
|
+
/** The notebooks the key's user can see. */
|
|
46710
|
+
async listNotebooks() {
|
|
46711
|
+
const body = await this.json(
|
|
46712
|
+
"GET",
|
|
46713
|
+
`${getEndpoint()}/api/v1/notebooks`,
|
|
46714
|
+
"Failed to list notebooks"
|
|
46715
|
+
);
|
|
46716
|
+
return body?.notebooks ?? [];
|
|
46717
|
+
}
|
|
46718
|
+
/**
|
|
46719
|
+
* Delete a notebook with its schedule, run history and result tables.
|
|
46720
|
+
* Resolves false when there was no such notebook.
|
|
46721
|
+
*/
|
|
46722
|
+
async deleteNotebook(slug) {
|
|
46723
|
+
const response = await fetch(notebookUrl(slug), {
|
|
46724
|
+
method: "DELETE",
|
|
46725
|
+
headers: this.headers()
|
|
46726
|
+
});
|
|
46727
|
+
if (response.status === 404) return false;
|
|
46728
|
+
if (!response.ok) {
|
|
46729
|
+
throw await failure(response, "Failed to delete notebook");
|
|
46730
|
+
}
|
|
46731
|
+
return true;
|
|
46732
|
+
}
|
|
46709
46733
|
/** The YAML exactly as saved, and the version it is. */
|
|
46710
46734
|
async getYaml(slug) {
|
|
46711
46735
|
const response = await fetch(notebookUrl(slug), {
|
|
@@ -47243,6 +47267,26 @@ function formatParams(params) {
|
|
|
47243
47267
|
([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`
|
|
47244
47268
|
).join(" ");
|
|
47245
47269
|
}
|
|
47270
|
+
var NOTEBOOK_COLUMNS = [
|
|
47271
|
+
"slug",
|
|
47272
|
+
"title",
|
|
47273
|
+
"version",
|
|
47274
|
+
"state",
|
|
47275
|
+
"schedule",
|
|
47276
|
+
"last run",
|
|
47277
|
+
"updated"
|
|
47278
|
+
];
|
|
47279
|
+
function notebookRows(notebooks) {
|
|
47280
|
+
return notebooks.map((notebook) => [
|
|
47281
|
+
notebook.slug,
|
|
47282
|
+
notebook.title,
|
|
47283
|
+
notebook.version,
|
|
47284
|
+
notebook.draft_version !== null ? `${notebook.live ? "live" : "not live"}, draft ${notebook.draft_version}` : notebook.live ? "live" : "not live",
|
|
47285
|
+
notebook.schedule ? formatSchedule(notebook.schedule) : "",
|
|
47286
|
+
notebook.latest_run ? `${notebook.latest_run.status} ${notebook.latest_run.created_at}` : "",
|
|
47287
|
+
notebook.updated_at
|
|
47288
|
+
]);
|
|
47289
|
+
}
|
|
47246
47290
|
var RUN_COLUMNS = [
|
|
47247
47291
|
"id",
|
|
47248
47292
|
"trigger",
|
|
@@ -47315,8 +47359,10 @@ function publishGuidance(slug, planId) {
|
|
|
47315
47359
|
}
|
|
47316
47360
|
|
|
47317
47361
|
// src/commands/notebooks/sync.ts
|
|
47362
|
+
var import_node_child_process3 = require("child_process");
|
|
47318
47363
|
var import_node_fs7 = require("fs");
|
|
47319
47364
|
var import_node_path7 = require("path");
|
|
47365
|
+
var import_node_util2 = require("util");
|
|
47320
47366
|
var NOTEBOOK_FILE_SUFFIX = ".notebook.yaml";
|
|
47321
47367
|
var SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules"]);
|
|
47322
47368
|
async function findNotebookFiles(paths) {
|
|
@@ -47473,6 +47519,90 @@ async function recordIfTracked(cwd, slug, version) {
|
|
|
47473
47519
|
const versions = await readNotebookVersions(cwd);
|
|
47474
47520
|
if (slug in versions) await recordNotebookVersion(cwd, slug, version);
|
|
47475
47521
|
}
|
|
47522
|
+
var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process3.execFile);
|
|
47523
|
+
async function git(cwd, args2) {
|
|
47524
|
+
try {
|
|
47525
|
+
const { stdout } = await execFileAsync("git", args2, {
|
|
47526
|
+
cwd,
|
|
47527
|
+
maxBuffer: 64 * 1024 * 1024
|
|
47528
|
+
});
|
|
47529
|
+
return stdout;
|
|
47530
|
+
} catch (error) {
|
|
47531
|
+
const stderr = error.stderr?.trim();
|
|
47532
|
+
const command = args2.find(
|
|
47533
|
+
(arg) => !arg.startsWith("-") && !arg.includes("=")
|
|
47534
|
+
);
|
|
47535
|
+
throw new Error(`git ${command} failed${stderr ? `: ${stderr}` : ""}`);
|
|
47536
|
+
}
|
|
47537
|
+
}
|
|
47538
|
+
async function findRemovedNotebooks(cwd, ref, paths, currentSlugs) {
|
|
47539
|
+
const out = await git(cwd, [
|
|
47540
|
+
"-c",
|
|
47541
|
+
"core.quotepath=off",
|
|
47542
|
+
"diff",
|
|
47543
|
+
"--name-only",
|
|
47544
|
+
"-z",
|
|
47545
|
+
"--diff-filter=D",
|
|
47546
|
+
"--find-renames",
|
|
47547
|
+
"--relative",
|
|
47548
|
+
ref,
|
|
47549
|
+
"--",
|
|
47550
|
+
...paths
|
|
47551
|
+
]);
|
|
47552
|
+
const removed = [];
|
|
47553
|
+
for (const path2 of out.split("\0")) {
|
|
47554
|
+
if (!path2.endsWith(NOTEBOOK_FILE_SUFFIX)) continue;
|
|
47555
|
+
const yaml = await git(cwd, ["show", `${ref}:./${path2}`]);
|
|
47556
|
+
const slug = readSlugFromYaml(yaml);
|
|
47557
|
+
if (!slug || currentSlugs.has(slug)) continue;
|
|
47558
|
+
if (removed.some((entry) => entry.slug === slug)) continue;
|
|
47559
|
+
removed.push({ path: path2, slug });
|
|
47560
|
+
}
|
|
47561
|
+
return removed.sort((a, b3) => a.path.localeCompare(b3.path));
|
|
47562
|
+
}
|
|
47563
|
+
function removedResult(removed, status, message) {
|
|
47564
|
+
return {
|
|
47565
|
+
file: removed.path,
|
|
47566
|
+
slug: removed.slug,
|
|
47567
|
+
status,
|
|
47568
|
+
plan: null,
|
|
47569
|
+
publish_plan: null,
|
|
47570
|
+
version: null,
|
|
47571
|
+
url: null,
|
|
47572
|
+
message,
|
|
47573
|
+
errors: []
|
|
47574
|
+
};
|
|
47575
|
+
}
|
|
47576
|
+
async function syncRemovedNotebook(client, removed, options) {
|
|
47577
|
+
if (!options.delete) {
|
|
47578
|
+
return removedResult(
|
|
47579
|
+
removed,
|
|
47580
|
+
"kept",
|
|
47581
|
+
"The notebook stays in oleander. Pass --delete to delete it."
|
|
47582
|
+
);
|
|
47583
|
+
}
|
|
47584
|
+
if (options.dryRun) {
|
|
47585
|
+
return removedResult(
|
|
47586
|
+
removed,
|
|
47587
|
+
"would_delete",
|
|
47588
|
+
"Deletes the notebook, its schedule, run history and result tables."
|
|
47589
|
+
);
|
|
47590
|
+
}
|
|
47591
|
+
try {
|
|
47592
|
+
const existed = await client.deleteNotebook(removed.slug);
|
|
47593
|
+
return removedResult(
|
|
47594
|
+
removed,
|
|
47595
|
+
"deleted",
|
|
47596
|
+
existed ? null : "It was already gone."
|
|
47597
|
+
);
|
|
47598
|
+
} catch (error) {
|
|
47599
|
+
return removedResult(
|
|
47600
|
+
removed,
|
|
47601
|
+
"error",
|
|
47602
|
+
error instanceof Error ? error.message : String(error)
|
|
47603
|
+
);
|
|
47604
|
+
}
|
|
47605
|
+
}
|
|
47476
47606
|
var STATUS_TEXT = {
|
|
47477
47607
|
unchanged: "unchanged",
|
|
47478
47608
|
planned: "would change",
|
|
@@ -47480,6 +47610,9 @@ var STATUS_TEXT = {
|
|
|
47480
47610
|
updated: "updated",
|
|
47481
47611
|
draft_saved: "draft saved",
|
|
47482
47612
|
published: "published",
|
|
47613
|
+
kept: "file removed",
|
|
47614
|
+
would_delete: "would delete",
|
|
47615
|
+
deleted: "deleted",
|
|
47483
47616
|
needs_approval: "needs approval",
|
|
47484
47617
|
invalid: "invalid",
|
|
47485
47618
|
conflict: "conflict",
|
|
@@ -47580,27 +47713,67 @@ function displayPath(path2) {
|
|
|
47580
47713
|
const rel = (0, import_node_path8.relative)(process.cwd(), path2);
|
|
47581
47714
|
return rel && !rel.startsWith("..") ? rel : path2;
|
|
47582
47715
|
}
|
|
47583
|
-
async function
|
|
47716
|
+
async function listNotebooksCommand(options = {}) {
|
|
47584
47717
|
const json = isJsonOutput(options.output);
|
|
47585
47718
|
const client = await loadClient();
|
|
47586
|
-
const spinner = startSpinner(json,
|
|
47719
|
+
const spinner = startSpinner(json, "Loading notebooks...");
|
|
47587
47720
|
try {
|
|
47588
|
-
const
|
|
47721
|
+
const notebooks = await client.listNotebooks();
|
|
47589
47722
|
if (json) {
|
|
47590
|
-
printJson2({
|
|
47723
|
+
printJson2({ notebooks });
|
|
47591
47724
|
return;
|
|
47592
47725
|
}
|
|
47593
|
-
spinner?.
|
|
47594
|
-
|
|
47595
|
-
|
|
47596
|
-
|
|
47726
|
+
spinner?.stop();
|
|
47727
|
+
printTable(
|
|
47728
|
+
{ columns: NOTEBOOK_COLUMNS, rows: notebookRows(notebooks) },
|
|
47729
|
+
{ emptyMessage: "No notebooks yet" }
|
|
47597
47730
|
);
|
|
47598
|
-
|
|
47599
|
-
|
|
47600
|
-
|
|
47601
|
-
|
|
47731
|
+
} catch (error) {
|
|
47732
|
+
exitWithError(spinner, error, "Failed to list notebooks");
|
|
47733
|
+
}
|
|
47734
|
+
}
|
|
47735
|
+
async function pullNotebookCommand(slugs, options = {}) {
|
|
47736
|
+
const json = isJsonOutput(options.output);
|
|
47737
|
+
if (options.all ? slugs.length > 0 : slugs.length === 0) {
|
|
47738
|
+
console.error(
|
|
47739
|
+
options.all ? "Pass slugs or --all, not both." : "Pass one or more slugs, or --all."
|
|
47740
|
+
);
|
|
47741
|
+
process.exit(1);
|
|
47742
|
+
}
|
|
47743
|
+
const client = await loadClient();
|
|
47744
|
+
let spinner = null;
|
|
47745
|
+
try {
|
|
47746
|
+
let targets = slugs;
|
|
47747
|
+
if (options.all) {
|
|
47748
|
+
spinner = startSpinner(json, "Loading notebooks...");
|
|
47749
|
+
targets = (await client.listNotebooks()).map((notebook) => notebook.slug);
|
|
47750
|
+
spinner?.stop();
|
|
47751
|
+
}
|
|
47752
|
+
const results = [];
|
|
47753
|
+
for (const slug of targets) {
|
|
47754
|
+
spinner = startSpinner(json, `Pulling ${slug}...`);
|
|
47755
|
+
const result = await pullNotebook(client, slug, process.cwd());
|
|
47756
|
+
results.push({ ...result, file: displayPath(result.file) });
|
|
47757
|
+
spinner?.succeed(
|
|
47758
|
+
source_default.green(
|
|
47759
|
+
`Wrote ${displayPath(result.file)}${result.version !== null ? ` (version ${result.version})` : ""}`
|
|
47602
47760
|
)
|
|
47603
47761
|
);
|
|
47762
|
+
if (!json && result.version === null) {
|
|
47763
|
+
console.log(
|
|
47764
|
+
source_default.yellow(
|
|
47765
|
+
"The server sent no version, so the next push will not check for concurrent edits."
|
|
47766
|
+
)
|
|
47767
|
+
);
|
|
47768
|
+
}
|
|
47769
|
+
}
|
|
47770
|
+
spinner = null;
|
|
47771
|
+
if (json) {
|
|
47772
|
+
printJson2(
|
|
47773
|
+
!options.all && results.length === 1 ? results[0] : { pulled: results }
|
|
47774
|
+
);
|
|
47775
|
+
} else if (options.all && !results.length) {
|
|
47776
|
+
console.log(source_default.dim("No notebooks to pull"));
|
|
47604
47777
|
}
|
|
47605
47778
|
} catch (error) {
|
|
47606
47779
|
exitWithError(spinner, error, "Failed to pull notebook");
|
|
@@ -47962,8 +48135,19 @@ async function syncNotebooksCommand(paths, options = {}) {
|
|
|
47962
48135
|
${duplicates.join("\n")}`
|
|
47963
48136
|
);
|
|
47964
48137
|
}
|
|
48138
|
+
if (options.delete && !options.removedSince) {
|
|
48139
|
+
throw new Error(
|
|
48140
|
+
"--delete needs --removed-since <ref> to know which files were removed."
|
|
48141
|
+
);
|
|
48142
|
+
}
|
|
48143
|
+
const removed = options.removedSince ? await findRemovedNotebooks(
|
|
48144
|
+
cwd,
|
|
48145
|
+
options.removedSince,
|
|
48146
|
+
searchPaths,
|
|
48147
|
+
new Set(files.map((file) => file.slug))
|
|
48148
|
+
) : [];
|
|
47965
48149
|
const results = [];
|
|
47966
|
-
if (files.length) {
|
|
48150
|
+
if (files.length || removed.length) {
|
|
47967
48151
|
const client = await loadClient();
|
|
47968
48152
|
for (const file of files) {
|
|
47969
48153
|
spinner = startSpinner(
|
|
@@ -47984,6 +48168,20 @@ ${duplicates.join("\n")}`
|
|
|
47984
48168
|
console.log();
|
|
47985
48169
|
}
|
|
47986
48170
|
}
|
|
48171
|
+
for (const entry of removed) {
|
|
48172
|
+
spinner = startSpinner(
|
|
48173
|
+
json,
|
|
48174
|
+
`${options.delete && !options.dryRun ? "Deleting" : "Checking"} ${entry.slug}...`
|
|
48175
|
+
);
|
|
48176
|
+
results.push(
|
|
48177
|
+
await syncRemovedNotebook(client, entry, {
|
|
48178
|
+
dryRun: options.dryRun,
|
|
48179
|
+
delete: options.delete
|
|
48180
|
+
})
|
|
48181
|
+
);
|
|
48182
|
+
spinner?.stop();
|
|
48183
|
+
spinner = null;
|
|
48184
|
+
}
|
|
47987
48185
|
}
|
|
47988
48186
|
if (options.summary) {
|
|
47989
48187
|
await import_node_fs8.promises.appendFile(
|
|
@@ -48043,6 +48241,7 @@ overwrites someone else's edit. On a live notebook push saves a draft; publish
|
|
|
48043
48241
|
it with the plan id push prints.
|
|
48044
48242
|
|
|
48045
48243
|
Examples:
|
|
48244
|
+
oleander notebooks list
|
|
48046
48245
|
oleander notebooks pull bluehouse-morning
|
|
48047
48246
|
oleander notebooks plan bluehouse-morning.notebook.yaml
|
|
48048
48247
|
oleander notebooks push bluehouse-morning.notebook.yaml --run
|
|
@@ -48050,7 +48249,9 @@ Examples:
|
|
|
48050
48249
|
oleander notebooks logs bluehouse-morning <run_id> --cell posts_by_hour
|
|
48051
48250
|
`
|
|
48052
48251
|
);
|
|
48053
|
-
const
|
|
48252
|
+
const list = notebooks.command("list").description("List the organization's notebooks").action(listNotebooksCommand);
|
|
48253
|
+
addOutputOption(list);
|
|
48254
|
+
const pull = notebooks.command("pull").description("Write <slug>.notebook.yaml exactly as saved").argument("[slugs...]", "Notebook slugs").option("--all", "Pull every notebook").action(pullNotebookCommand);
|
|
48054
48255
|
addOutputOption(pull);
|
|
48055
48256
|
const push = notebooks.command("push").description(
|
|
48056
48257
|
"Plan and save a notebook YAML file (a draft, on a live notebook)"
|
|
@@ -48067,18 +48268,26 @@ Examples:
|
|
|
48067
48268
|
).option("--publish", "Publish the draft a save leaves on a live notebook").option(
|
|
48068
48269
|
"--summary <file>",
|
|
48069
48270
|
"Append a Markdown report, like $GITHUB_STEP_SUMMARY"
|
|
48271
|
+
).option(
|
|
48272
|
+
"--removed-since <ref>",
|
|
48273
|
+
"Also report notebook files deleted since this git ref"
|
|
48274
|
+
).option(
|
|
48275
|
+
"--delete",
|
|
48276
|
+
"Delete the notebooks of files removed since --removed-since, with their run history and result tables"
|
|
48070
48277
|
).addHelpText(
|
|
48071
48278
|
"after",
|
|
48072
48279
|
`
|
|
48073
48280
|
The files are the source of truth: sync saves each changed file over what is on
|
|
48074
48281
|
the server (a concurrent edit made between its plan and save fails with a
|
|
48075
|
-
conflict instead). Unchanged files are skipped.
|
|
48076
|
-
|
|
48077
|
-
fails to save
|
|
48282
|
+
conflict instead). Unchanged files are skipped. A notebook whose file is
|
|
48283
|
+
removed stays in oleander unless --removed-since finds the removal and --delete
|
|
48284
|
+
is passed. Exits 1 if any file is invalid, needs --approve, or fails to save or
|
|
48285
|
+
delete.
|
|
48078
48286
|
|
|
48079
48287
|
Examples:
|
|
48080
48288
|
oleander notebooks sync notebooks/ --dry-run --summary "$GITHUB_STEP_SUMMARY"
|
|
48081
48289
|
oleander notebooks sync notebooks/ --approve --publish
|
|
48290
|
+
oleander notebooks sync notebooks/ --removed-since HEAD~1 --delete
|
|
48082
48291
|
`
|
|
48083
48292
|
).action(syncNotebooksCommand);
|
|
48084
48293
|
addOutputOption(sync);
|
|
@@ -48101,7 +48310,7 @@ Examples:
|
|
|
48101
48310
|
}
|
|
48102
48311
|
|
|
48103
48312
|
// src/utils/skills.ts
|
|
48104
|
-
var
|
|
48313
|
+
var import_node_child_process4 = require("child_process");
|
|
48105
48314
|
var import_node_os5 = require("os");
|
|
48106
48315
|
var import_node_fs9 = require("fs");
|
|
48107
48316
|
var import_node_path9 = require("path");
|
|
@@ -48287,7 +48496,7 @@ function getSkillsStatus(options = {}) {
|
|
|
48287
48496
|
};
|
|
48288
48497
|
}
|
|
48289
48498
|
function installSkills(options = {}) {
|
|
48290
|
-
const spawn3 = options.spawn ?? ((command, args2, spawnOptions) => (0,
|
|
48499
|
+
const spawn3 = options.spawn ?? ((command, args2, spawnOptions) => (0, import_node_child_process4.spawnSync)(command, args2, spawnOptions));
|
|
48291
48500
|
const home = options.homeDir ?? (0, import_node_os5.homedir)();
|
|
48292
48501
|
const agentRoots = options.agentRoots ?? AGENT_SKILL_ROOTS;
|
|
48293
48502
|
const env2 = options.homeDir ? { ...process.env, HOME: options.homeDir } : process.env;
|