@ravshansbox/pi-next-issue 1.0.6 → 1.0.8

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
@@ -16,7 +16,7 @@ Run these in pi, inside a git repository:
16
16
  - `/next-issue stop` stops the run. The issue keeps its saved state, and the next run resumes it.
17
17
  - `/next-issue status` shows where the run is.
18
18
 
19
- The footer shows the issue, the stage, the number of tool calls and the time spent on the issue, for example `next-issue #12 · review 1/3 · 37 tools · 4m12s`. A line above the editor shows the last tool call. A note appears when an issue is merged or needs a human.
19
+ The footer shows the issue, the stage, the number of tool calls and the time spent on the issue, for example `next-issue #12 · review 1/3 · 37 tools · 4m12s`. A line above the editor shows the last tool call. In the terminal, both use the dim colour of the theme, like the rest of the footer. A note appears when an issue is merged or needs a human.
20
20
 
21
21
  The run does not belong to a session: it goes on after `/new`, `/resume`, a fork or a reload, and the new session shows it. It stops when you quit pi.
22
22
 
package/index.ts CHANGED
@@ -68,6 +68,7 @@ const launchFromRepo: Launch = async (cwd) => {
68
68
  export function createExtension(launch: Launch) {
69
69
  return (pi: ExtensionAPI) => {
70
70
  let ui: ExtensionContext['ui'] | undefined;
71
+ let coloured = false;
71
72
  let timer: ReturnType<typeof setInterval> | undefined;
72
73
  let unsubscribe: (() => void) | undefined;
73
74
  let handled = 0;
@@ -79,9 +80,11 @@ export function createExtension(launch: Launch) {
79
80
  return;
80
81
  }
81
82
  const progress = runner.progress;
82
- ui.setStatus(STATUS_KEY, formatStatus(progress, Date.now()));
83
+ const theme = ui.theme;
84
+ const dim = (text: string) => (coloured ? theme.fg('dim', text) : text);
85
+ ui.setStatus(STATUS_KEY, dim(formatStatus(progress, Date.now())));
83
86
  const active = progress.status === 'running' && progress.lastTool !== undefined;
84
- ui.setWidget(STATUS_KEY, active ? [`↳ ${progress.lastTool}`] : undefined);
87
+ ui.setWidget(STATUS_KEY, active ? [dim(`↳ ${progress.lastTool}`)] : undefined);
85
88
  };
86
89
 
87
90
  const onChange = (progress: Progress) => {
@@ -128,6 +131,7 @@ export function createExtension(launch: Launch) {
128
131
  return;
129
132
  }
130
133
  ui = ctx.ui;
134
+ coloured = ctx.mode === 'tui';
131
135
  timer ??= setInterval(render, 1000);
132
136
  timer.unref?.();
133
137
  const runner = holder().runner;
@@ -174,6 +178,7 @@ export function createExtension(launch: Launch) {
174
178
  holder().runner = runner;
175
179
  if (ctx.hasUI) {
176
180
  ui = ctx.ui;
181
+ coloured = ctx.mode === 'tui';
177
182
  follow(runner);
178
183
  }
179
184
  void runner.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravshansbox/pi-next-issue",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Pi extension that works through GitHub issues in the background",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/git.ts CHANGED
@@ -81,8 +81,8 @@ export async function push(cwd: string, remote: string, branch: string): Promise
81
81
  await must('git', ['push', '-u', remote, `HEAD:refs/heads/${branch}`], { cwd });
82
82
  }
83
83
 
84
- export async function discard(cwd: string): Promise<void> {
85
- await must('git', ['reset', '--hard', '@{upstream}'], { cwd });
84
+ export async function discard(cwd: string, remote: string, branch: string): Promise<void> {
85
+ await must('git', ['reset', '--hard', `${remote}/${branch}`], { cwd });
86
86
  await must('git', ['clean', '-fd'], { cwd });
87
87
  }
88
88
 
package/src/ports.ts CHANGED
@@ -17,7 +17,7 @@ export async function createPorts(root: string, config: Config): Promise<Ports>
17
17
  worktree: (issue, branch) => git.worktree(root, config.remote, base, issue, branch),
18
18
  commit: (cwd, message) => git.commit(cwd, message),
19
19
  push: (cwd, branch) => git.push(cwd, config.remote, branch),
20
- discard: (cwd) => git.discard(cwd),
20
+ discard: (cwd, branch) => git.discard(cwd, config.remote, branch),
21
21
  diff: (cwd) => git.diff(cwd, config.remote, base),
22
22
  openPr: (branch, title, body) => github.openPr(repo, branch, base, title, body),
23
23
  checks: async (pr, cwd, signal) =>
package/src/runner.ts CHANGED
@@ -46,7 +46,7 @@ export type Ports = {
46
46
  worktree(issue: number, branch: string): Promise<string>;
47
47
  commit(cwd: string, message: string): Promise<boolean>;
48
48
  push(cwd: string, branch: string): Promise<void>;
49
- discard(cwd: string): Promise<void>;
49
+ discard(cwd: string, branch: string): Promise<void>;
50
50
  diff(cwd: string): Promise<string>;
51
51
  openPr(branch: string, title: string, body: string): Promise<number>;
52
52
  checks(pr: number, cwd: string, signal: AbortSignal): Promise<ChecksResult>;
@@ -294,7 +294,7 @@ export class Runner {
294
294
  cwd,
295
295
  reviewPrompt(issue, comments, diff, state.earlier),
296
296
  );
297
- await ports.discard(cwd);
297
+ await ports.discard(cwd, state.branch);
298
298
  if (verdict === undefined) {
299
299
  return needsHuman('the reviewer gave no verdict');
300
300
  }