@ramon-sg/issue-flow 0.3.4 → 0.3.5

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 CHANGED
@@ -99,7 +99,7 @@ issue-flow worktree setup --only deps # uno solo
99
99
  issue-flow worktree teardown # sus pasos de limpieza, sus puertos y su Docker
100
100
  issue-flow worktree ports [--next] # el primer puerto de su bloque, o lo pasa al siguiente
101
101
  issue-flow worktree cleanup # el Docker de los worktrees que ya no existen
102
- issue-flow worktree prune # borra los worktrees cuyo PR se mergeó o se cerró
102
+ issue-flow worktree prune # borra los worktrees cuyo PR se mergeó o se cerró, y pone al día la base local
103
103
  ```
104
104
 
105
105
  Lo propio de cada repo (instalar, armar la base, levantar Docker) son **pasos** en `worktrees` de `.agents/flow.json`; `issue-flow` solo los corre:
@@ -72,7 +72,7 @@ export declare function worktreeCleanup(options: WorktreeOptions, out: Output):
72
72
  * closed, after asking: their teardown, the folder, the local branch and the session id.
73
73
  * It never touches one with uncommitted changes, unpushed commits, or a lock (a live
74
74
  * session of `claude --worktree` or `issue start`, or by hand), and checks each again just
75
- * before deleting it.
75
+ * before deleting it. If it deleted one, it moves the local base forward to origin's.
76
76
  * @param options - The options.
77
77
  * @param out - Where to write.
78
78
  * @returns The exit code.
@@ -10,7 +10,7 @@ import { confirm } from "../ask.js";
10
10
  import { existsSync } from "node:fs";
11
11
  import { resolve } from "node:path";
12
12
  import { canonicalPath, dockerCleanup } from "../docker.js";
13
- import { checkoutRoot, git, isClean, locateRepo, safeToDelete, worktrees } from "../git.js";
13
+ import { checkoutRoot, git, isClean, locateRepo, safeToDelete, updateBase, worktrees } from "../git.js";
14
14
  import { forgetSession } from "../launch.js";
15
15
  import { warn } from "../output.js";
16
16
  import { claimPortBase, nextPortBase, portBase } from "../ports.js";
@@ -204,7 +204,7 @@ async function pruneCandidates(options, mainRoot, out) {
204
204
  * closed, after asking: their teardown, the folder, the local branch and the session id.
205
205
  * It never touches one with uncommitted changes, unpushed commits, or a lock (a live
206
206
  * session of `claude --worktree` or `issue start`, or by hand), and checks each again just
207
- * before deleting it.
207
+ * before deleting it. If it deleted one, it moves the local base forward to origin's.
208
208
  * @param options - The options.
209
209
  * @param out - Where to write.
210
210
  * @returns The exit code.
@@ -224,6 +224,7 @@ export async function worktreePrune(options, out) {
224
224
  return 0;
225
225
  }
226
226
  const { commonDir } = locateRepo(mainRoot) ?? { commonDir: "" };
227
+ let deleted = 0;
227
228
  for (const item of doomed) {
228
229
  if (!unchanged(mainRoot, item)) {
229
230
  out.stdout(`changed since the check, not deleted: ${item.path}\n`);
@@ -238,6 +239,10 @@ export async function worktreePrune(options, out) {
238
239
  warn(out, `could not delete the local branch ${item.branch}.`);
239
240
  forgetSession(commonDir, item.branch);
240
241
  out.stdout(`deleted: ${item.path} (${item.branch})\n`);
242
+ deleted += 1;
241
243
  }
244
+ const stale = deleted === 0 ? null : updateBase(mainRoot, place.base);
245
+ if (stale !== null)
246
+ warn(out, stale);
242
247
  return 0;
243
248
  }
package/dist/git.d.ts CHANGED
@@ -144,3 +144,15 @@ export declare function checkoutRoot(cwd: string): string | null;
144
144
  * @example safeToDelete("/repo", "feat/42-x", "")
145
145
  */
146
146
  export declare function safeToDelete(cwd: string, branch: string, head: string): boolean;
147
+ /**
148
+ * Brings `origin/<base>` and moves the local base forward to it, if nothing is lost. A base
149
+ * not checked out anywhere moves as a ref only; one checked out is merged there with
150
+ * `--ff-only`, and only if that checkout has no changes. A base with commits that are not in
151
+ * origin is left alone.
152
+ * @param mainRoot - The main checkout.
153
+ * @param base - The base branch.
154
+ * @returns Null if it is up to date now (or there is no local base); else why it was not
155
+ * moved.
156
+ * @example updateBase("/repo", "main") // null
157
+ */
158
+ export declare function updateBase(mainRoot: string, base: string): string | null;
package/dist/git.js CHANGED
@@ -213,3 +213,34 @@ export function safeToDelete(cwd, branch, head) {
213
213
  return true;
214
214
  return head !== "" && git(cwd, ["merge-base", "--is-ancestor", branch, head]).ok;
215
215
  }
216
+ /**
217
+ * Brings `origin/<base>` and moves the local base forward to it, if nothing is lost. A base
218
+ * not checked out anywhere moves as a ref only; one checked out is merged there with
219
+ * `--ff-only`, and only if that checkout has no changes. A base with commits that are not in
220
+ * origin is left alone.
221
+ * @param mainRoot - The main checkout.
222
+ * @param base - The base branch.
223
+ * @returns Null if it is up to date now (or there is no local base); else why it was not
224
+ * moved.
225
+ * @example updateBase("/repo", "main") // null
226
+ */
227
+ export function updateBase(mainRoot, base) {
228
+ const remote = `refs/remotes/origin/${base}`;
229
+ const local = `refs/heads/${base}`;
230
+ if (!git(mainRoot, ["fetch", "-q", "origin", `+refs/heads/${base}:${remote}`]).ok)
231
+ return `could not fetch ${base} from origin; local ${base} was not updated.`;
232
+ if (!hasRef(mainRoot, local))
233
+ return null;
234
+ const from = git(mainRoot, ["rev-parse", local]).out;
235
+ const to = git(mainRoot, ["rev-parse", remote]).out;
236
+ if (from === to)
237
+ return null;
238
+ if (!git(mainRoot, ["merge-base", "--is-ancestor", local, remote]).ok)
239
+ return `local ${base} has commits that are not in origin/${base}; it was not updated.`;
240
+ const at = checkedOutAt(mainRoot, base);
241
+ if (at === null)
242
+ return git(mainRoot, ["update-ref", local, to, from]).ok ? null : `could not move local ${base} to origin/${base}.`;
243
+ if (!isClean(at, false))
244
+ return `${base} is checked out in ${at} with changes; it was not updated. Run 'git pull --ff-only' there.`;
245
+ return git(at, ["merge", "-q", "--ff-only", remote]).ok ? null : `could not update ${base} in ${at}; run 'git pull --ff-only' there.`;
246
+ }
@@ -52,8 +52,8 @@ export declare function publish(state: StartState): Promise<number>;
52
52
  export declare function copyWorktreeIncludes(from: string, to: string, out: Output): void;
53
53
  /**
54
54
  * After Claude: if the PR was merged and nothing would be lost, offers to delete the
55
- * worktree and the branch (or, in the main checkout, to go back to the base); if not,
56
- * says how to resume.
55
+ * worktree and the branch (or, in the main checkout, to go back to the base), and then
56
+ * moves the local base forward to origin's; if not, says how to resume.
57
57
  * @param state - The start.
58
58
  * @param lock - The worktree lock (shared: another session uses it).
59
59
  * @example await afterSession(state, lock)
@@ -9,7 +9,7 @@ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync } from "node:f
9
9
  import { dirname, join, relative } from "node:path";
10
10
  import { assign, createPr, findPr, getPr, updatePr } from "@ramon-sg/github-rest";
11
11
  import { confirm } from "./ask.js";
12
- import { checkedOutAt, currentBranch, git, gitLines, hasLocal, isClean, onOrigin, safeToDelete, trackOrigin, untracked } from "./git.js";
12
+ import { checkedOutAt, currentBranch, git, gitLines, hasLocal, isClean, onOrigin, safeToDelete, trackOrigin, untracked, updateBase } from "./git.js";
13
13
  import { bodyToPartOf, dirName, fill, prBody } from "./issue-text.js";
14
14
  import { forgetSession } from "./launch.js";
15
15
  import { warn } from "./output.js";
@@ -262,8 +262,8 @@ function keepReason(state, lock, head) {
262
262
  }
263
263
  /**
264
264
  * After Claude: if the PR was merged and nothing would be lost, offers to delete the
265
- * worktree and the branch (or, in the main checkout, to go back to the base); if not,
266
- * says how to resume.
265
+ * worktree and the branch (or, in the main checkout, to go back to the base), and then
266
+ * moves the local base forward to origin's; if not, says how to resume.
267
267
  * @param state - The start.
268
268
  * @param lock - The worktree lock (shared: another session uses it).
269
269
  * @example await afterSession(state, lock)
@@ -296,10 +296,10 @@ export async function afterSession(state, lock) {
296
296
  if (!(await confirm(out, `The PR was merged. Go back to ${base} and delete the local branch ${branch}?`)))
297
297
  return;
298
298
  mustGit(mainRoot, ["checkout", "-q", base], `could not check out ${base}`);
299
- const updated = git(mainRoot, ["fetch", "-q", "origin"]).ok && git(mainRoot, ["merge", "-q", "--ff-only", `origin/${base}`]).ok;
300
- if (!updated)
301
- warn(out, `could not update ${base}; do it by hand.`);
302
299
  }
303
300
  mustGit(mainRoot, ["branch", "-q", "-D", branch], `could not delete ${branch}`);
304
301
  forgetSession(commonDir, branch);
302
+ const stale = updateBase(mainRoot, base);
303
+ if (stale !== null)
304
+ warn(out, stale);
305
305
  }
package/dist/usage.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @file The usage text of the CLI, printed with `--help` and after a usage error.
3
3
  */
4
4
  /** Usage text. */
5
- export declare const USAGE = "Usage:\n issue-flow issue branch <n>... [--namer claude|title] [--json] [-R owner/repo]\n issue-flow issue branch --missing [--limit <n>] [--namer claude|title] [--dry-run | --yes] [--json] [-R owner/repo]\n issue-flow issue start <n> [--branch] [--dry-run | --yes] [--resume <branch> | --new] [--no-launch]\n [--ask-permissions | --free [--no-repo-deny]] [--namer claude|title] [-R owner/repo]\n issue-flow issue start <n> --plan [--ask-permissions | --free] [--namer claude|title] [-R owner/repo]\n issue-flow issue start <n> --cloud | --here | --teleport | --adopt [...]\n issue-flow worktree setup [--only <step>]\n issue-flow worktree teardown [--path <dir>]\n issue-flow worktree ports [--next]\n issue-flow worktree cleanup [--path <dir>]\n issue-flow worktree prune [--only <dir>] [--yes] [-R owner/repo]\n issue-flow pr worktree <n> [--no-setup] [-R owner/repo] [-- [<command>...]]\n issue-flow adapter setup [--only <step>] | issue [<url>] | archive [-R owner/repo]\n issue-flow session\n issue-flow hook worktree-create | worktree-remove\n issue-flow apply [--yes] [--dry-run] [--json] [--recipe <name>,...]\n issue-flow doctor [--json]\n issue-flow labels sync [--update] [--dry-run] [--json] [-R owner/repo]\n\nThe slug comes from the issue's \"Slug de rama\" block, then from Claude, then from the title,\nand the branch from the repo's template (an older \"Rama sugerida\" block is used if it fits).\n--missing adds the slug block to every open issue without a block, after confirming.\n\nissue start makes the branch in a worktree (or, with --branch, in this checkout), the\nstart commit, the push, the draft PR and the assignment, after confirming, and opens\nClaude: in auto mode if the repo has claude-repo-guard, with your settings with\n--ask-permissions, with no sandbox nor questions with --free, and also without the repo's\ndeny rules with --free --no-repo-deny. --plan prints the branch and the prompt as JSON and\nchanges nothing. issue start --help explains each flag.\n\n--cloud confirms here and opens a Claude cloud session that starts the issue there.\n--here, inside a cloud session, starts it in this checkout and opens nothing. --teleport\nbrings the cloud session noted in the PR to the worktree. --adopt starts it in the\nworktree another tool (Orca, Paseo) just made, without asking nor opening Claude.\n\nworktree runs the steps of \"worktrees\" in .agents/flow.json: setup prepares this worktree,\nteardown cleans it before it goes (steps, ports, Docker), ports prints or moves its block\nof ports, cleanup deletes the Docker of deleted worktrees, and prune deletes the worktrees\nwhose PR was merged or closed. session is the SessionStart hook of Claude Code.\n\npr worktree makes (or reuses) a worktree on a PR's own branch, to review and fix it; with\n--, it runs the command there (Claude if none). adapter is what Orca and Paseo run: setup\nwhen they make a worktree (its steps and, if it came from an issue, issue start --adopt),\nissue to start one by hand, and archive before they delete it. hook implements Claude\nCode's WorktreeCreate and WorktreeRemove for claude --worktree.\n\napply leaves the repo as this version needs it: .agents/flow.json (the first time, with\nthe recipes its files suggest), issue-flow at this version and github-rest and the scripts\nif missing in package.json, and the hooks; it changes no other version, and refuses a newer\nissue-flow or a range. doctor checks them. npx agent-kitchen apply runs apply at the version\nit picks, along with the skills, claude-cloud and claude-repo-guard. init and upgrade still\nrun apply, with a warning, until 0.4.0.\n\nlabels sync makes in GitHub the labels the flow wants (\"labels\" in .agents/flow.json: the\nissue types and P1 to P4 by default) that the repo lacks. Names ignore case and are never\nrenamed nor deleted; --update also fixes the color and description of those that differ.";
5
+ export declare const USAGE = "Usage:\n issue-flow issue branch <n>... [--namer claude|title] [--json] [-R owner/repo]\n issue-flow issue branch --missing [--limit <n>] [--namer claude|title] [--dry-run | --yes] [--json] [-R owner/repo]\n issue-flow issue start <n> [--branch] [--dry-run | --yes] [--resume <branch> | --new] [--no-launch]\n [--ask-permissions | --free [--no-repo-deny]] [--namer claude|title] [-R owner/repo]\n issue-flow issue start <n> --plan [--ask-permissions | --free] [--namer claude|title] [-R owner/repo]\n issue-flow issue start <n> --cloud | --here | --teleport | --adopt [...]\n issue-flow worktree setup [--only <step>]\n issue-flow worktree teardown [--path <dir>]\n issue-flow worktree ports [--next]\n issue-flow worktree cleanup [--path <dir>]\n issue-flow worktree prune [--only <dir>] [--yes] [-R owner/repo]\n issue-flow pr worktree <n> [--no-setup] [-R owner/repo] [-- [<command>...]]\n issue-flow adapter setup [--only <step>] | issue [<url>] | archive [-R owner/repo]\n issue-flow session\n issue-flow hook worktree-create | worktree-remove\n issue-flow apply [--yes] [--dry-run] [--json] [--recipe <name>,...]\n issue-flow doctor [--json]\n issue-flow labels sync [--update] [--dry-run] [--json] [-R owner/repo]\n\nThe slug comes from the issue's \"Slug de rama\" block, then from Claude, then from the title,\nand the branch from the repo's template (an older \"Rama sugerida\" block is used if it fits).\n--missing adds the slug block to every open issue without a block, after confirming.\n\nissue start makes the branch in a worktree (or, with --branch, in this checkout), the\nstart commit, the push, the draft PR and the assignment, after confirming, and opens\nClaude: in auto mode if the repo has claude-repo-guard, with your settings with\n--ask-permissions, with no sandbox nor questions with --free, and also without the repo's\ndeny rules with --free --no-repo-deny. --plan prints the branch and the prompt as JSON and\nchanges nothing. issue start --help explains each flag.\n\n--cloud confirms here and opens a Claude cloud session that starts the issue there.\n--here, inside a cloud session, starts it in this checkout and opens nothing. --teleport\nbrings the cloud session noted in the PR to the worktree. --adopt starts it in the\nworktree another tool (Orca, Paseo) just made, without asking nor opening Claude.\n\nworktree runs the steps of \"worktrees\" in .agents/flow.json: setup prepares this worktree,\nteardown cleans it before it goes (steps, ports, Docker), ports prints or moves its block\nof ports, cleanup deletes the Docker of deleted worktrees, and prune deletes the worktrees\nwhose PR was merged or closed, then moves the local base forward to origin's (only if\nnothing is lost: not with changes where it is checked out, nor with commits not in\norigin). session is the SessionStart hook of Claude Code.\n\npr worktree makes (or reuses) a worktree on a PR's own branch, to review and fix it; with\n--, it runs the command there (Claude if none). adapter is what Orca and Paseo run: setup\nwhen they make a worktree (its steps and, if it came from an issue, issue start --adopt),\nissue to start one by hand, and archive before they delete it. hook implements Claude\nCode's WorktreeCreate and WorktreeRemove for claude --worktree.\n\napply leaves the repo as this version needs it: .agents/flow.json (the first time, with\nthe recipes its files suggest), issue-flow at this version and github-rest and the scripts\nif missing in package.json, and the hooks; it changes no other version, and refuses a newer\nissue-flow or a range. doctor checks them. npx agent-kitchen apply runs apply at the version\nit picks, along with the skills, claude-cloud and claude-repo-guard. init and upgrade still\nrun apply, with a warning, until 0.4.0.\n\nlabels sync makes in GitHub the labels the flow wants (\"labels\" in .agents/flow.json: the\nissue types and P1 to P4 by default) that the repo lacks. Names ignore case and are never\nrenamed nor deleted; --update also fixes the color and description of those that differ.";
6
6
  /** Usage text of `issue start`, printed with `issue start --help`. */
7
7
  export declare const START_USAGE = "Usage: issue-flow issue start <n> [flags]\n\nStarts issue <n>: the branch (in a worktree, or in this checkout with --branch), the empty\nstart commit, the push, the draft PR and the assignment, after confirming; then it opens\nClaude there.\n\nFlags:\n --dry-run show what it would do and change nothing\n -y, --yes do it without asking\n --branch in this checkout instead of a worktree\n --resume <branch> take that branch of the issue\n --new make another branch, even if the issue has one\n --no-launch leave everything ready and do not open Claude\n --namer claude|title who names the branch when the issue has no slug block\n -R owner/repo another repo than the checkout's\n --plan print the branch and the prompt as JSON, and change nothing\n --cloud open a Claude cloud session that starts the issue there\n --here inside a cloud session, start it in this checkout\n --teleport bring the cloud session noted in the PR to the worktree\n --adopt start it in the worktree Orca or Paseo just made\n -h, --help this help\n\nPermissions of the Claude it opens (one at most):\n (none) auto mode if the repo has claude-repo-guard, else your settings\n --ask-permissions your settings: Claude asks before what they do not allow\n --free no sandbox and no questions, as claude:free\n --no-repo-deny with --free: also without the deny rules of the repo's settings\n\nWhat each one takes away, and what stays:\n (none), --ask-permissions\n take nothing away: the sandbox, the questions your settings ask\n and every deny rule stay.\n --free takes away the sandbox and the questions. Every deny rule stays:\n yours (~/.claude), the repo's (.claude/settings.json) and the\n local ones (.claude/settings.local.json).\n --free --no-repo-deny\n also takes the deny rules out of the worktree's\n .claude/settings.json while Claude runs, and puts them back when it\n exits; git does not see the change meanwhile. Your deny rules and the\n local ones stay, and so do the repo's hooks, attribution, CLAUDE.md,\n skills, agents and MCP servers. If Claude changes that file, the\n rules go back on top of its change, with a warning to review it. If\n the terminal closes first, the next issue start of the issue puts\n them back.\n\nFrom the repo's scripts (issue:start, and issue:start:free, which adds --free):\n npm run issue:start:free 42 npm passes a number on as it is\n npm run issue:start -- 42 --free but keeps the flags for itself, unless after --\n pnpm issue:start 42 --free pnpm, bun and yarn pass everything on\n bun run issue:start 42 --free\n yarn issue:start 42 --free\nA -- does no harm with any of them: issue-flow drops it.\n\nissue:start:free does not go with --ask-permissions, --cloud, --here nor --adopt: use\nissue:start for those. --no-repo-deny goes after it, as any flag:\n npm run issue:start:free -- 42 --no-repo-deny\n pnpm issue:start:free 42 --no-repo-deny";
8
8
  /**
package/dist/usage.js CHANGED
@@ -41,7 +41,9 @@ worktree another tool (Orca, Paseo) just made, without asking nor opening Claude
41
41
  worktree runs the steps of "worktrees" in .agents/flow.json: setup prepares this worktree,
42
42
  teardown cleans it before it goes (steps, ports, Docker), ports prints or moves its block
43
43
  of ports, cleanup deletes the Docker of deleted worktrees, and prune deletes the worktrees
44
- whose PR was merged or closed. session is the SessionStart hook of Claude Code.
44
+ whose PR was merged or closed, then moves the local base forward to origin's (only if
45
+ nothing is lost: not with changes where it is checked out, nor with commits not in
46
+ origin). session is the SessionStart hook of Claude Code.
45
47
 
46
48
  pr worktree makes (or reuses) a worktree on a PR's own branch, to review and fix it; with
47
49
  --, it runs the command there (Claude if none). adapter is what Orca and Paseo run: setup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramon-sg/issue-flow",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Issue-to-PR workflow for any repo: names each issue's branch, creates its worktree, opens the draft PR and launches Claude Code, locally and in Claude's cloud.",
5
5
  "license": "MIT",
6
6
  "type": "module",