next-issue 16.10.0 → 16.12.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 CHANGED
@@ -40,7 +40,7 @@ Give an issue the `status:todo` label to have it picked up. See [Issue format](h
40
40
 
41
41
  ### Skills for Claude Code
42
42
 
43
- `init` (see [Configuration](#configuration)) installs the `create-issue` skill, which writes an issue that the harness can claim, and the `answer-hand-over` skill, which helps you answer a hand-over. It asks whether to install them for your user or for the project; `--scope user|project` answers in advance. Run `init` again after an upgrade of next-issue to get the skills of that version. See [Skills](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#skills).
43
+ `init` (see [Configuration](#configuration)) installs the `create-issue` skill, which writes an issue that the harness can claim, and the `answer-hand-over` skill, which helps you answer a hand-over. It asks whether to install them for your user or for the project; `--scope user|project` answers in advance. `start` updates an outdated copy and installs a missing skill for the project. See [Skills](https://github.com/ravshansbox/next-issue/blob/main/packages/next-issue/docs/behaviour.md#skills).
44
44
 
45
45
  ## Configuration
46
46
 
@@ -1,8 +1,10 @@
1
- import { cp, rename, rm } from 'node:fs/promises';
1
+ import { createHash } from 'node:crypto';
2
+ import { cp, readdir, readFile, rename, rm } from 'node:fs/promises';
2
3
  import { homedir } from 'node:os';
3
4
  import { join } from 'node:path';
4
5
  import { createInterface } from 'node:readline/promises';
5
6
  import { OWN_SKILLS } from '../shared/agents.mjs';
7
+ import { hasCode } from '../shared/errors.mjs';
6
8
  import { repoRoot } from '../shared/git.mjs';
7
9
  const SKILLS = join(import.meta.dirname, '..', '..', 'skills');
8
10
  const QUESTION = 'Install the skills for the user, in ~/.claude/skills, or for the project, in .claude/skills of the main worktree? (user/project) ';
@@ -39,23 +41,73 @@ async function skillsFolder(scope) {
39
41
  const base = scope === 'user' ? homedir() : await repoRoot(process.cwd());
40
42
  return join(base, '.claude', 'skills');
41
43
  }
44
+ async function replaceSkill(folder, name) {
45
+ const target = join(folder, name);
46
+ const staging = join(folder, `.${name}.new`);
47
+ await rm(staging, { recursive: true, force: true });
48
+ try {
49
+ await cp(join(SKILLS, name), staging, { recursive: true });
50
+ }
51
+ catch (error) {
52
+ await rm(staging, { recursive: true, force: true });
53
+ throw error;
54
+ }
55
+ await rm(target, { recursive: true, force: true });
56
+ await rename(staging, target);
57
+ return target;
58
+ }
42
59
  export async function installSkills(scope) {
43
60
  const folder = await skillsFolder(scope);
44
61
  const written = [];
45
62
  for (const name of OWN_SKILLS) {
46
- const target = join(folder, name);
47
- const staging = join(folder, `.${name}.new`);
48
- await rm(staging, { recursive: true, force: true });
49
- try {
50
- await cp(join(SKILLS, name), staging, { recursive: true });
63
+ written.push(await replaceSkill(folder, name));
64
+ }
65
+ return written;
66
+ }
67
+ async function skillHash(folder) {
68
+ let entries;
69
+ try {
70
+ entries = await readdir(folder, { recursive: true, withFileTypes: true });
71
+ }
72
+ catch (error) {
73
+ if (hasCode(error, 'ENOENT')) {
74
+ return undefined;
75
+ }
76
+ throw error;
77
+ }
78
+ const files = entries
79
+ .filter((entry) => entry.isFile())
80
+ .map((entry) => join(entry.parentPath, entry.name))
81
+ .sort();
82
+ const hash = createHash('sha256');
83
+ for (const file of files) {
84
+ hash.update(`${file.slice(folder.length)}\0`);
85
+ hash.update(await readFile(file));
86
+ hash.update('\0');
87
+ }
88
+ return hash.digest('hex');
89
+ }
90
+ export async function refreshSkills(root) {
91
+ const folders = [
92
+ ...new Set([join(homedir(), '.claude', 'skills'), join(root, '.claude', 'skills')]),
93
+ ];
94
+ const notes = [];
95
+ for (const name of OWN_SKILLS) {
96
+ const shipped = await skillHash(join(SKILLS, name));
97
+ let installed = false;
98
+ for (const folder of folders) {
99
+ const hash = await skillHash(join(folder, name));
100
+ if (hash === undefined) {
101
+ continue;
102
+ }
103
+ installed = true;
104
+ if (hash !== shipped) {
105
+ notes.push(`updated ${await replaceSkill(folder, name)}`);
106
+ }
51
107
  }
52
- catch (error) {
53
- await rm(staging, { recursive: true, force: true });
54
- throw error;
108
+ if (!installed) {
109
+ notes.push(`wrote ${await replaceSkill(join(root, '.claude', 'skills'), name)}`);
55
110
  }
56
- await rm(target, { recursive: true, force: true });
57
- await rename(staging, target);
58
- written.push(target);
59
111
  }
60
- return written;
112
+ return notes;
61
113
  }
package/dist/cli.mjs CHANGED
@@ -10,7 +10,7 @@ import { serve } from './worker/serve.mjs';
10
10
  import { startInWorker } from './cli/start.mjs';
11
11
  import { STATE_DIR } from './shared/state.mjs';
12
12
  import { statusInWorker, stopInWorker, switchInWorker } from './cli/switch-run.mjs';
13
- import { chooseScope, installSkills } from './cli/skills.mjs';
13
+ import { chooseScope, installSkills, refreshSkills } from './cli/skills.mjs';
14
14
  import { WORKTREE_DIR } from './shared/worktree.mjs';
15
15
  function write(stream, text) {
16
16
  return new Promise((resolve, reject) => {
@@ -52,6 +52,9 @@ async function main() {
52
52
  if (args.command === 'serve') {
53
53
  return serve(root);
54
54
  }
55
+ for (const note of await refreshSkills(root)) {
56
+ await write(process.stderr, `${note}\n`);
57
+ }
55
58
  await write(process.stderr, await startInWorker(root, argv.slice(1)));
56
59
  return 0;
57
60
  }
@@ -1,11 +1,13 @@
1
1
  import { ISSUE_SECTIONS, numbered } from './issue-format.mjs';
2
2
  import { fenceFor, paragraphs } from './text.mjs';
3
+ const README_RULE = 'Keep each README to what a user needs to start and use the tool. Put edge cases and internal behaviour in other docs.';
3
4
  const ENGINEERING_RULES = [
4
5
  'Update the documentation when you change behaviour or add or remove a feature.',
5
6
  'Remove the tests of a feature or behaviour that you remove.',
6
7
  'Test behaviour that a user can observe, not internals. Give each test a description that names the actor, the action and the observable outcome.',
7
8
  'Reuse existing code and patterns, stay consistent with the repository and pick the simpler option.',
8
9
  'Check an API, a command or a url in the repository or its dependencies before you use it. Do not invent one.',
10
+ README_RULE,
9
11
  ].join('\n');
10
12
  const OTHER_RULES = 'The other rules of `CLAUDE.md`, such as code conventions and test style, still apply.';
11
13
  const HARNESS_RULES = [
@@ -109,6 +111,7 @@ function reviewScope(earlier) {
109
111
  'Check that the change updates the documentation when it changes behaviour or adds or removes a feature, and that it removes the tests of a removed feature or behaviour.',
110
112
  'Check that each test checks behaviour that a user can observe, and that its description names the actor, the action and the observable outcome.',
111
113
  'Check that the change reuses existing code and patterns, stays consistent with the repository and picks the simpler option, and that it uses no invented API, command or url.',
114
+ `Check that the change follows this rule: ${README_RULE}`,
112
115
  'A missing documentation update or a test that is not observable is a finding.',
113
116
  ].join('\n')
114
117
  : [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "16.10.0",
3
+ "version": "16.12.0",
4
4
  "description": "Autonomous issue harness driven by the Claude Agent SDK",
5
5
  "keywords": [
6
6
  "github",
@@ -7,6 +7,8 @@ description: Investigate an issue that the next-issue worker handed over to a pe
7
7
 
8
8
  Help the user understand why the worker handed an issue over, then answer the hand-over on GitHub. Do not fix the code of the issue yourself. The worker does the work.
9
9
 
10
+ Run any next-issue command as `npx -y next-issue@latest <command>`. Never run it from the `PATH`, a global install or a local build.
11
+
10
12
  1. Find the repository, `<repo>`, that the worker reads. `<remote>` is the value of `remote` in `.next-issue/config.json` at the root of the repository. When there is no config file or no `remote` field, `<remote>` is `origin`. Run `git remote get-url <remote>` and take `<owner>/<name>` from the url, without `.git`. That is `<repo>`. When the host of the url is not `github.com`, `<repo>` is `<host>/<owner>/<name>`, so gh acts on that host. For an ssh url, such as `git@<host>:<owner>/<name>.git`, run `ssh -G <host>` and take the host from its `hostname` line, since `<host>` may be an alias from the ssh config. The host `ssh.github.com` means `github.com` (GitHub's ssh over port 443), so `<repo>` is then `<owner>/<name>`. Pass `--repo <repo>` to every `gh` command but `gh api`, since gh otherwise may pick another remote, such as `upstream`.
11
13
  2. Find the labels. `<needs-human>` is the value of `labels.needsHuman` in `.next-issue/config.json`, or `status:needs-human` when it is not set or there is no config file. `<skip>` is the value of `labels.skip` in `.next-issue/config.json`, or `status:blocked` when it is not set or there is no config file. `<ready>` is the value of `labels.ready` in `.next-issue/config.json`, or `status:todo` when it is not set or there is no config file. When `labels.ready` is `""`, leave out `--add-label "<ready>"` below, since the worker then claims every open issue.
12
14
  3. List the waiting issues:
@@ -1,12 +1,14 @@
1
1
  ---
2
2
  name: create-issue
3
- description: Turn a problem into a clear GitHub issue that the next-issue worker can claim. Use when the user wants to write, file or create an issue, or asks for a change to the code of a repository that has `.next-issue/config.json`.
3
+ description: Turn a problem into a clear GitHub issue that the next-issue worker can claim. Use when the user wants to write, file or create an issue, or asks for a change to the code of a repository that has `.next-issue/config.json`. In that case, file an issue with this skill instead of editing files.
4
4
  ---
5
5
 
6
6
  # Create an issue
7
7
 
8
8
  Turn the problem of the user into one GitHub issue, or a split of linked issues when the change is too big for one commit, in the format of `template.md`, next to this file.
9
9
 
10
+ Run any next-issue command as `npx -y next-issue@latest <command>`. Never run it from the `PATH`, a global install or a local build.
11
+
10
12
  1. Understand the problem. Restate it in your own words.
11
13
  2. Find the repository, `<repo>`, that the worker reads. `<remote>` is the value of `remote` in `.next-issue/config.json` at the root of the repository. When there is no config file or no `remote` field, `<remote>` is `origin`. Run `git remote get-url <remote>` and take `<owner>/<name>` from the url, without `.git`. That is `<repo>`. When the host of the url is not `github.com`, `<repo>` is `<host>/<owner>/<name>`, so gh acts on that host. For an ssh url, such as `git@<host>:<owner>/<name>.git`, run `ssh -G <host>` and take the host from its `hostname` line, since `<host>` may be an alias from the ssh config. The host `ssh.github.com` means `github.com` (GitHub's ssh over port 443), so `<repo>` is then `<owner>/<name>`. Pass `--repo <repo>` to every `gh` command, since gh otherwise may pick another remote, such as `upstream`.
12
14