@lonca/baron-recipes 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/dist/index.d.ts +4 -1
- package/dist/index.js +12 -1
- package/package.json +5 -5
- package/recipes/task-finish.yaml +7 -6
- package/recipes/task-new.yaml +15 -0
- package/recipes/task-start.yaml +11 -10
package/dist/index.d.ts
CHANGED
|
@@ -7,14 +7,17 @@ import { KnowledgeLoop } from '@lonca/baron-knowledge-loop';
|
|
|
7
7
|
*/
|
|
8
8
|
declare const RECIPE_OPS: {
|
|
9
9
|
readonly issueCreate: "issue.create";
|
|
10
|
+
readonly issueGet: "issue.get";
|
|
10
11
|
readonly issueTransition: "issue.transition";
|
|
11
12
|
readonly issueComment: "issue.comment";
|
|
12
13
|
readonly issueLink: "issue.link";
|
|
14
|
+
readonly issueAssign: "issue.assign";
|
|
13
15
|
readonly issueQuery: "issue.query";
|
|
14
16
|
readonly scmBranchCreate: "scm.branch.create";
|
|
15
17
|
readonly scmPrCreate: "scm.pr.create";
|
|
16
18
|
readonly scmPrThread: "scm.pr.thread";
|
|
17
19
|
readonly scmPrStatus: "scm.pr.status";
|
|
20
|
+
readonly scmPrFind: "scm.pr.find";
|
|
18
21
|
readonly ciRunTrigger: "ci.run.trigger";
|
|
19
22
|
readonly ciRunCancel: "ci.run.cancel";
|
|
20
23
|
readonly deployDeployments: "deploy.deployments";
|
|
@@ -130,7 +133,7 @@ interface RunRecipeResult {
|
|
|
130
133
|
declare function runRecipe(recipe: Recipe, options: RunRecipeOptions): Promise<RunRecipeResult>;
|
|
131
134
|
|
|
132
135
|
/** The recipes Baron ships out of the box, runnable by name (no file path). */
|
|
133
|
-
declare const BUILTIN_RECIPE_NAMES: readonly ["task-start", "task-finish", "ship"];
|
|
136
|
+
declare const BUILTIN_RECIPE_NAMES: readonly ["task-new", "task-start", "task-finish", "ship"];
|
|
134
137
|
type BuiltinRecipeName = (typeof BUILTIN_RECIPE_NAMES)[number];
|
|
135
138
|
declare function isBuiltinRecipe(name: string): name is BuiltinRecipeName;
|
|
136
139
|
/** Raw YAML of a built-in recipe (the canonical file — no inlined copy, so it can never drift). */
|
package/dist/index.js
CHANGED
|
@@ -3,14 +3,17 @@ import { BaronError } from "@lonca/baron-core";
|
|
|
3
3
|
import { parse as parseYaml } from "yaml";
|
|
4
4
|
var RECIPE_OPS = {
|
|
5
5
|
issueCreate: "issue.create",
|
|
6
|
+
issueGet: "issue.get",
|
|
6
7
|
issueTransition: "issue.transition",
|
|
7
8
|
issueComment: "issue.comment",
|
|
8
9
|
issueLink: "issue.link",
|
|
10
|
+
issueAssign: "issue.assign",
|
|
9
11
|
issueQuery: "issue.query",
|
|
10
12
|
scmBranchCreate: "scm.branch.create",
|
|
11
13
|
scmPrCreate: "scm.pr.create",
|
|
12
14
|
scmPrThread: "scm.pr.thread",
|
|
13
15
|
scmPrStatus: "scm.pr.status",
|
|
16
|
+
scmPrFind: "scm.pr.find",
|
|
14
17
|
ciRunTrigger: "ci.run.trigger",
|
|
15
18
|
ciRunCancel: "ci.run.cancel",
|
|
16
19
|
deployDeployments: "deploy.deployments",
|
|
@@ -336,10 +339,14 @@ async function dispatchOp(ports, op, params) {
|
|
|
336
339
|
...optStrArray(params, "labels", op) !== void 0 ? { labels: optStrArray(params, "labels", op) } : {},
|
|
337
340
|
...optStr(params, "initialRole", op) !== void 0 ? { initialRole: reqRole(params, "initialRole", op) } : {}
|
|
338
341
|
});
|
|
342
|
+
case RECIPE_OPS.issueGet:
|
|
343
|
+
return issues(ports, op).get(reqStr(params, "id", op));
|
|
339
344
|
case RECIPE_OPS.issueTransition:
|
|
340
345
|
return issues(ports, op).transition(reqStr(params, "id", op), reqRole(params, "role", op));
|
|
341
346
|
case RECIPE_OPS.issueComment:
|
|
342
347
|
return issues(ports, op).comment(reqStr(params, "id", op), reqStr(params, "body", op));
|
|
348
|
+
case RECIPE_OPS.issueAssign:
|
|
349
|
+
return issues(ports, op).assign(reqStr(params, "id", op), reqStr(params, "assignee", op));
|
|
343
350
|
case RECIPE_OPS.issueLink:
|
|
344
351
|
return issues(ports, op).link(
|
|
345
352
|
reqStr(params, "fromId", op),
|
|
@@ -375,6 +382,10 @@ async function dispatchOp(ports, op, params) {
|
|
|
375
382
|
);
|
|
376
383
|
case RECIPE_OPS.scmPrStatus:
|
|
377
384
|
return scm(ports, op).prStatus(reqStr(params, "pullRequestId", op));
|
|
385
|
+
case RECIPE_OPS.scmPrFind: {
|
|
386
|
+
const found = await scm(ports, op).prForBranch(reqStr(params, "sourceBranch", op));
|
|
387
|
+
return found ?? null;
|
|
388
|
+
}
|
|
378
389
|
case RECIPE_OPS.ciRunTrigger: {
|
|
379
390
|
const ref = optStr(params, "ref", op);
|
|
380
391
|
const variables = optStrRecord(params, "variables", op);
|
|
@@ -478,7 +489,7 @@ async function runRecipe(recipe, options) {
|
|
|
478
489
|
import { readFileSync } from "fs";
|
|
479
490
|
import { fileURLToPath } from "url";
|
|
480
491
|
var RECIPES_DIR = fileURLToPath(new URL("../recipes/", import.meta.url));
|
|
481
|
-
var BUILTIN_RECIPE_NAMES = ["task-start", "task-finish", "ship"];
|
|
492
|
+
var BUILTIN_RECIPE_NAMES = ["task-new", "task-start", "task-finish", "ship"];
|
|
482
493
|
function isBuiltinRecipe(name) {
|
|
483
494
|
return BUILTIN_RECIPE_NAMES.includes(name);
|
|
484
495
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lonca/baron-recipes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"yaml": "^2.6.0",
|
|
20
|
-
"@lonca/baron-core": "0.
|
|
21
|
-
"@lonca/baron-knowledge-loop": "0.
|
|
20
|
+
"@lonca/baron-core": "0.2.0",
|
|
21
|
+
"@lonca/baron-knowledge-loop": "0.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^22.0.0",
|
|
25
|
-
"@lonca/baron-
|
|
26
|
-
"@lonca/baron-
|
|
25
|
+
"@lonca/baron-adapter-github": "0.2.0",
|
|
26
|
+
"@lonca/baron-conformance": "0.2.0"
|
|
27
27
|
},
|
|
28
28
|
"description": "Baron recipe engine: run declarative YAML workflows over Baron primitives, deterministically.",
|
|
29
29
|
"keywords": [
|
package/recipes/task-finish.yaml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
name: task-finish
|
|
2
|
-
description: Open a pull request for a branch and move
|
|
2
|
+
description: Open a draft pull request for a work-item branch and post the PR link back on the item. Deliberately does NOT move the item's role — review/testing state changes when the PR actually merges, not when it opens.
|
|
3
3
|
steps:
|
|
4
4
|
- ask: { as: issueId, type: text, message: "Issue id?" }
|
|
5
5
|
- ask: { as: branch, type: text, message: "Source branch?" }
|
|
@@ -11,12 +11,13 @@ steps:
|
|
|
11
11
|
title: ${title}
|
|
12
12
|
sourceBranch: ${branch}
|
|
13
13
|
draft: true
|
|
14
|
-
- do: issue.transition
|
|
15
|
-
with:
|
|
16
|
-
id: ${issueId}
|
|
17
|
-
role: in_review
|
|
18
14
|
- do: scm.pr.thread
|
|
19
15
|
with:
|
|
20
16
|
pullRequestId: ${pr.id}
|
|
21
17
|
body: "Opened for issue ${issueId}."
|
|
22
|
-
|
|
18
|
+
# Give the card full context: reviewers/QA opening the work item see the PR without digging.
|
|
19
|
+
- do: issue.comment
|
|
20
|
+
with:
|
|
21
|
+
id: ${issueId}
|
|
22
|
+
body: "PR opened: ${pr.url} (from ${branch}). Role unchanged — moves to in_review on merge."
|
|
23
|
+
- message: "Opened PR ${pr.url} for ${issueId}. Role unchanged; transition on merge (task-move)."
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: task-new
|
|
2
|
+
description: Create a NEW work item (type + optional parent + optional starting role). Starting work on it afterwards is `task-start`.
|
|
3
|
+
steps:
|
|
4
|
+
- ask: { as: title, type: text, message: "Work item title?" }
|
|
5
|
+
- ask: { as: typeRole, type: choice, message: "Type role?", choices: [task, bug, story] }
|
|
6
|
+
- ask: { as: parentId, type: text, message: "Parent id (empty for none)?", optional: true }
|
|
7
|
+
- do: issue.create
|
|
8
|
+
as: issue
|
|
9
|
+
with:
|
|
10
|
+
title: ${title}
|
|
11
|
+
typeRole: ${typeRole}
|
|
12
|
+
# Exactly-one-reference interpolation: an unanswered optional ask stays truly unset,
|
|
13
|
+
# so hierarchy/gap negotiation only runs when a parent was actually given.
|
|
14
|
+
parentId: ${parentId}
|
|
15
|
+
- message: "Created ${issue.key} (${issue.nativeType}): ${issue.title}"
|
package/recipes/task-start.yaml
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
name: task-start
|
|
2
|
-
description:
|
|
2
|
+
description: Start work on an EXISTING work item — load it, cut its canonical branch, move it to in_progress, and note the branch on the item. (Creating a new item is `task-new`.)
|
|
3
3
|
steps:
|
|
4
|
-
- ask: { as:
|
|
5
|
-
- do: issue.
|
|
4
|
+
- ask: { as: issueId, type: text, message: "Work item id?" }
|
|
5
|
+
- do: issue.get
|
|
6
6
|
as: issue
|
|
7
7
|
with:
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
id: ${issueId}
|
|
9
|
+
# ${issue.branchName} is the core-derived canonical name (<prefix>/<id>-<slug>) — every agent and
|
|
10
|
+
# recipe derives the SAME name for the same item. It is unset for container types (epic/initiative),
|
|
11
|
+
# which makes this step fail loudly rather than branch on an epic.
|
|
10
12
|
- do: scm.branch.create
|
|
11
13
|
as: branch
|
|
12
14
|
with:
|
|
13
|
-
# fromBranch omitted on purpose — defaults to the repo's default branch (main/release/master)
|
|
14
|
-
|
|
15
|
-
name: feature/${issue.id}
|
|
15
|
+
# fromBranch omitted on purpose — defaults to the repo's default branch (main/release/master).
|
|
16
|
+
name: ${issue.branchName}
|
|
16
17
|
- do: issue.transition
|
|
17
18
|
as: issue
|
|
18
19
|
with:
|
|
@@ -21,5 +22,5 @@ steps:
|
|
|
21
22
|
- do: issue.comment
|
|
22
23
|
with:
|
|
23
24
|
id: ${issue.id}
|
|
24
|
-
body: "
|
|
25
|
-
- message: "
|
|
25
|
+
body: "Branch created: ${branch.name}."
|
|
26
|
+
- message: "${issue.key} is in progress on ${branch.name}."
|