@nolto/cli 0.25.1 → 0.26.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.
Files changed (3) hide show
  1. package/README.md +6 -2
  2. package/dist/index.js +119 -43
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -268,8 +268,12 @@ References accept a key (NOLTO-12) or number (12). Only the number is sent. With
268
268
  | `issue comment <ref>` | `-m/--comment <text>` or `--body-file <path-or-dash>` |
269
269
  | `issue close <ref>` | `--status <closed-name-or-UUID>`, `-m/--comment <text>` |
270
270
 
271
- - `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The default is internal. Shared mode is available only in Pro+ projects with customers; other projects fail before any write. It cannot be combined with `create --draft`, `--priority` or `--category`. Human success output adds ` (shared)` to the first line; JSON responses stay unchanged.
272
- - `--confirm-references` on create, update, comment or close sends `confirmReferences: true`. Do not add it on the first attempt. After a 409 `internal_references`, check the references customers cannot open (the API lists at most five and reports only the count for the rest). Remove or rewrite those references first. To send the text as written, get the user's go-ahead before retrying with this flag; the references will remain inaccessible to customers. This 409 can also occur without `--shared` when updating the subject or body of a shared issue. Human success output adds ` (references confirmed)`, or ` (shared, references confirmed)` with both flags; JSON success responses stay unchanged. Agents (LLMs) must use `--shared` and `--confirm-references` only with the user's instruction or approval.
271
+ - `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The default is internal. Shared mode is available only in Pro+ projects with customers; other projects fail before any write. It cannot be combined with `create --draft`, `--priority` or `--category`. Human success output adds ` (shared: <audience name>)` to the first line (` (shared)` when the name is not known); JSON responses stay unchanged.
272
+ - `--audience <name-or-UUID>` (with `--shared` only; otherwise exit 2) picks the share audience. The CLI reads `GET /api/projects/<id>/audiences` (token scope `issues:read`; exit 3 `共有先の一覧を読めませんでした。` on an old API or a token without it) and matches the name exactly after trimming, or the UUID. No match exits 2 and lists the audiences. Several audiences with the same name (spaces aside), or a UUID that is one audience's id and another's name, exit 2 instead of picking one. It sends `X-Nolto-View: shared; audience=<uuid>`.
273
+ - Omitted on update, comment or close: the CLI reads the issue in the internal view and uses its audience. An issue that is not shared exits 2 without writing; an issue without an audience id sends `shared` only.
274
+ - Omitted on create: sends `shared` only. A project with several audiences answers 400 `view_audience_required`; the CLI exits 2 with `共有先が 2 つ以上あります。--audience <名前> で指定してください(候補: …)。` (without the candidates when the audience list cannot be read or has no valid audiences) and nothing is written. The choice is the user's: the error hint says not to guess it from the candidates.
275
+ - 400 `view_audience_invalid` (for example the audience was deleted) exits 2. With `--audience`, a 404 on update, comment or close means the issue is not visible in that audience (another audience, or not shared).
276
+ - `--confirm-references` on create, update, comment or close sends `confirmReferences: true`. Do not add it on the first attempt. After a 409 `internal_references`, check the references customers cannot open (the API lists at most five and reports only the count for the rest). Remove or rewrite those references first. To send the text as written, get the user's go-ahead before retrying with this flag; the references will remain inaccessible to customers. This 409 can also occur without `--shared` when updating the subject or body of a shared issue. Human success output adds ` (references confirmed)`, or ` (shared, references confirmed)` with both flags (` (shared: <audience name>, references confirmed)` when the audience name is known); JSON success responses stay unchanged. Agents (LLMs) must use `--shared` and `--confirm-references` only with the user's instruction or approval. Take `--audience` from the user's instruction; do not guess it from the candidates.
273
277
 
274
278
  Status/type/category accept case-insensitive exact names or UUIDs from the project's settings. Unknown or ambiguous names list candidates. Create with `--type` and no body uses that type's body template. Update never inserts a template automatically. Close chooses the first closed status by sortOrder unless overridden; it fails if no matching closed status exists. `--assignee me` on writes resolves /api/me/profile; none clears the assignee.
275
279
 
package/dist/index.js CHANGED
@@ -203,13 +203,13 @@ import path from "path";
203
203
  import { fileURLToPath } from "url";
204
204
  var __dirname = path.dirname(fileURLToPath(import.meta.url));
205
205
  function resolveSkillSourceDir(name = "roadmap-progress") {
206
- const candidates = [
206
+ const candidates2 = [
207
207
  path.resolve(__dirname, `skill/${name}`),
208
208
  // bundled: dist/skill/...
209
209
  path.resolve(__dirname, `../../../skills/${name}`)
210
210
  // source: <repo>/skills/...
211
211
  ];
212
- for (const candidate of candidates) {
212
+ for (const candidate of candidates2) {
213
213
  if (existsSync(path.join(candidate, "SKILL.md"))) return candidate;
214
214
  }
215
215
  throw new Error(`Bundled ${name} skill not found. Reinstall @nolto/cli.`);
@@ -2900,11 +2900,13 @@ async function roadmapMigrate(deps, yes = false) {
2900
2900
  // src/commands/issue.ts
2901
2901
  var emptySettings = { types: [], statuses: [], categories: [] };
2902
2902
  var confirmHelp = "Send even if the text has references customers cannot open. Use only after a 409 internal_references and the user's go-ahead.";
2903
+ var audienceHint = "\u3069\u306E\u5171\u6709\u5148\u306B\u66F8\u304F\u304B\u306F\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u308B\u3002\u5019\u88DC\u304B\u3089\u63A8\u6E2C\u3057\u3066 --audience \u3092\u4ED8\u3051\u306A\u3044\u3002";
2903
2904
  var confirmHint = "\u53C2\u7167\u3092\u5916\u3059\u304B\u66F8\u304D\u63DB\u3048\u308B\u306E\u304C\u5148\u3002\u3053\u306E\u307E\u307E\u9001\u308B\u3068\u3001\u3053\u306E\u6587\u9762\u306F\u304A\u5BA2\u3055\u307E\u306B\u305D\u306E\u307E\u307E\u898B\u3048\u3001\u53C2\u7167\u306F\u958B\u3051\u306A\u3044\u307E\u307E\u6B8B\u308B\u3002\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u3066\u304B\u3089 --confirm-references \u3092\u4ED8\u3051\u3066\u518D\u5B9F\u884C\u3059\u308B";
2904
2905
  function sharedOptions(command) {
2905
- return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only.").option("--confirm-references", confirmHelp);
2906
+ return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only.").option("--audience <name-or-id>", "Share audience for --shared (name or UUID). Required on create when the project has several audiences.").option("--confirm-references", confirmHelp);
2906
2907
  }
2907
2908
  async function checkShared(deps, root, flags, ref) {
2909
+ if (flags.audience !== void 0 && !flags.shared) throw new CliError("--audience \u306F --shared \u3068\u4E00\u7DD2\u306B\u4F7F\u3044\u307E\u3059\u3002", 2);
2908
2910
  if (!flags.shared) return;
2909
2911
  if (flags.priority !== void 0 || flags.category !== void 0) {
2910
2912
  throw new CliError("--shared \u3067\u306F --priority \u3068 --category \u306F\u4F7F\u3048\u307E\u305B\u3093(\u5171\u6709\u30E2\u30FC\u30C9\u3067\u306F\u53CD\u6620\u3055\u308C\u307E\u305B\u3093)\u3002", 2);
@@ -2919,16 +2921,65 @@ async function checkShared(deps, root, flags, ref) {
2919
2921
  }
2920
2922
  return context4.project?.name;
2921
2923
  }
2922
- function writeSuffix(flags) {
2923
- if (flags.shared && flags.confirmReferences) return " (shared, references confirmed)";
2924
- return flags.shared ? " (shared)" : flags.confirmReferences ? " (references confirmed)" : "";
2924
+ async function audienceList(deps, root) {
2925
+ try {
2926
+ const result = await deps.http.get(`${root}/audiences`);
2927
+ return (result.audiences ?? []).filter((row) => typeof row?.id === "string" && isUuid(row.id) && typeof row.name === "string");
2928
+ } catch (error) {
2929
+ if (error instanceof CliError && error.status === 403 && error.serverError === "token_scope") {
2930
+ throw new CliError(
2931
+ "\u5171\u6709\u5148\u306E\u4E00\u89A7\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
2932
+ error.exitCode,
2933
+ "API \u304C\u53E4\u3044\u304B\u3001token \u306B issues:read \u306E scope \u304C\u3042\u308A\u307E\u305B\u3093\u3002",
2934
+ error.status,
2935
+ error.serverError,
2936
+ error.body
2937
+ );
2938
+ }
2939
+ throw error;
2940
+ }
2925
2941
  }
2926
- async function writeRequest(deps, mode2, flags, method, path24, body) {
2942
+ var candidates = (audiences) => audiences.map((row) => terminalLine(row.name)).join("\u3001");
2943
+ function pickAudience(audiences, input) {
2944
+ const wanted = input.trim();
2945
+ const uuid = isUuid(wanted);
2946
+ const matches = audiences.filter((row) => uuid ? row.id.toLowerCase() === wanted.toLowerCase() : row.name.trim() === wanted);
2947
+ const named = uuid && matches.length === 1 ? audiences.find((row) => row !== matches[0] && row.name.trim().toLowerCase() === wanted.toLowerCase()) : void 0;
2948
+ if (named) {
2949
+ throw new CliError(`${terminalLine(wanted)} \u306F\u3001\u3042\u308B\u5171\u6709\u5148\u306E id \u3068\u3001\u5225\u306E\u5171\u6709\u5148\u306E\u540D\u524D(${terminalLine(named.name)})\u306E\u4E21\u65B9\u306B\u4E00\u81F4\u3057\u307E\u3059\u3002\u3069\u3061\u3089\u304B\u6C7A\u3081\u3089\u308C\u307E\u305B\u3093\u3002`, 2, audienceHint);
2950
+ }
2951
+ if (matches.length === 1) return matches[0];
2952
+ if (matches.length > 1) {
2953
+ throw new CliError(`\u540C\u3058\u540D\u524D(\u524D\u5F8C\u306E\u7A7A\u767D\u3060\u3051\u304C\u9055\u3046\u540D\u524D\u3092\u542B\u3080)\u306E\u5171\u6709\u5148\u304C\u8907\u6570\u3042\u308A\u307E\u3059\u3002id \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044(${matches.map((row) => `${terminalLine(row.name)}: ${terminalLine(row.id)}`).join("\u3001")})\u3002`, 2, audienceHint);
2954
+ }
2955
+ if (audiences.length === 0) throw new CliError("\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u306F\u5171\u6709\u5148\u304C\u3042\u308A\u307E\u305B\u3093\u3002--audience \u306F\u4F7F\u3048\u307E\u305B\u3093\u3002", 2);
2956
+ throw new CliError(`\u5171\u6709\u5148 ${terminalLine(wanted)} \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093(\u5019\u88DC: ${candidates(audiences)})\u3002`, 2, audienceHint);
2957
+ }
2958
+ async function sharedView(deps, root, mode2, flags, number) {
2959
+ if (!flags.shared) return {};
2960
+ if (flags.audience !== void 0) return { view: pickAudience(await audienceList(deps, root), flags.audience) };
2961
+ if (number === void 0) return { view: {} };
2962
+ const { issue } = await deps.http.get(`${root}/issues/${number}`);
2963
+ if (issue.shared === false) {
2964
+ throw new CliError("\u3053\u306E\u8AB2\u984C\u306F\u304A\u5BA2\u3055\u307E\u3068\u5171\u6709\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u8AB2\u984C\u3092\u5171\u6709\u3059\u308B\u304B\u3001--shared \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002", 2);
2965
+ }
2966
+ const id = typeof issue.audienceId === "string" && isUuid(issue.audienceId) ? issue.audienceId.toLowerCase() : void 0;
2967
+ const name = id && mode2 === "human" ? (await audienceList(deps, root).catch(() => [])).find((row) => row.id.toLowerCase() === id)?.name : void 0;
2968
+ return { view: { id, name }, issue };
2969
+ }
2970
+ var viewHeaders = (id) => ({ "X-Nolto-View": id !== void 0 && isUuid(id) ? `shared; audience=${id.toLowerCase()}` : "shared" });
2971
+ function writeSuffix(flags, view) {
2972
+ const label = view?.name ? terminalLine(view.name) : "";
2973
+ const shared = label ? `shared: ${label}` : "shared";
2974
+ if (flags.shared && flags.confirmReferences) return ` (${shared}, references confirmed)`;
2975
+ return flags.shared ? ` (${shared})` : flags.confirmReferences ? " (references confirmed)" : "";
2976
+ }
2977
+ async function writeRequest(deps, mode2, flags, root, method, path24, body, view) {
2927
2978
  try {
2928
2979
  return await deps.http[method](
2929
2980
  path24,
2930
2981
  flags.confirmReferences ? { ...body, confirmReferences: true } : body,
2931
- flags.shared ? { "X-Nolto-View": "shared" } : void 0
2982
+ flags.shared ? viewHeaders(view?.id) : void 0
2932
2983
  );
2933
2984
  } catch (error) {
2934
2985
  if (!(error instanceof CliError)) throw error;
@@ -2944,11 +2995,32 @@ async function writeRequest(deps, mode2, flags, method, path24, body) {
2944
2995
  detail
2945
2996
  );
2946
2997
  }
2998
+ if (flags.shared && error.status === 400 && error.serverError === "view_audience_required" && view?.id === void 0) {
2999
+ const audiences = await audienceList(deps, root).catch(() => void 0);
3000
+ throw new CliError(
3001
+ `\u5171\u6709\u5148\u304C 2 \u3064\u4EE5\u4E0A\u3042\u308A\u307E\u3059\u3002--audience <\u540D\u524D> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044${audiences?.length ? `(\u5019\u88DC: ${candidates(audiences)})` : ""}\u3002`,
3002
+ 2,
3003
+ audienceHint,
3004
+ error.status,
3005
+ error.serverError,
3006
+ error.body
3007
+ );
3008
+ }
3009
+ if (flags.shared && error.status === 400 && error.serverError === "view_audience_invalid") {
3010
+ throw new CliError(
3011
+ "\u5171\u6709\u5148\u306E\u6307\u5B9A\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093(\u5171\u6709\u5148\u304C\u524A\u9664\u3055\u308C\u305F\u304B\u3001\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u5171\u6709\u5148\u3067\u306F\u3042\u308A\u307E\u305B\u3093)\u3002",
3012
+ 2,
3013
+ "--audience <\u540D\u524D> \u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
3014
+ error.status,
3015
+ error.serverError,
3016
+ error.body
3017
+ );
3018
+ }
2947
3019
  if (flags.shared && error.status === 404 && (method === "patch" || path24.endsWith("/comments"))) {
2948
3020
  throw new CliError(
2949
3021
  error.message,
2950
3022
  error.exitCode,
2951
- "\u5171\u6709\u30E2\u30FC\u30C9\u3067\u306F\u3001\u304A\u5BA2\u3055\u307E\u3068\u5171\u6709\u3057\u3066\u3044\u306A\u3044\u8AB2\u984C\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\u8AB2\u984C\u3092\u5171\u6709\u3059\u308B\u304B\u3001--shared \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
3023
+ view?.name ? `\u5171\u6709\u5148 ${terminalLine(view.name)} \u3067\u306F\u3001\u3053\u306E\u8AB2\u984C\u306F\u898B\u3048\u307E\u305B\u3093(\u8AB2\u984C\u306E\u5171\u6709\u5148\u304C\u9055\u3046\u304B\u3001\u5171\u6709\u3057\u3066\u3044\u307E\u305B\u3093)\u3002` : "\u5171\u6709\u30E2\u30FC\u30C9\u3067\u306F\u3001\u304A\u5BA2\u3055\u307E\u3068\u5171\u6709\u3057\u3066\u3044\u306A\u3044\u8AB2\u984C\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\u8AB2\u984C\u3092\u5171\u6709\u3059\u308B\u304B\u3001--shared \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
2952
3024
  error.status,
2953
3025
  error.serverError,
2954
3026
  error.body,
@@ -3071,15 +3143,16 @@ nolto issue publish <draft-id>
3071
3143
  const { input, fromTemplate } = await writeInput(deps, ctx.root, flags, true);
3072
3144
  if (flags.draft) {
3073
3145
  const project2 = await projectLine(deps, ctx);
3074
- const result2 = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts`, input);
3146
+ const result2 = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issue-drafts`, input);
3075
3147
  printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created${writeSuffix(flags)}${project2}
3076
3148
  ${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}${warningLines(result2.warnings)}`, ctx.mode);
3077
3149
  return;
3078
3150
  }
3151
+ const { view } = await sharedView(deps, ctx.root, ctx.mode, flags);
3079
3152
  const project = await projectLine(deps, ctx);
3080
- const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues`, input);
3153
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issues`, input, view);
3081
3154
  const roadmap = flags.phase === void 0 ? void 0 : await attachRoadmap(deps, flags.phase, flags.roadmap, result.issue.key);
3082
- printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags)}${project}
3155
+ printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags, view)}${project}
3083
3156
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}${warningLines(result.warnings)}`, ctx.mode);
3084
3157
  });
3085
3158
  group.command("drafts").description("List your issue drafts (visible only to you).").action(async (_flags, command) => {
@@ -3091,7 +3164,7 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemp
3091
3164
  const ctx = context(deps, command);
3092
3165
  if (!isUuid(id)) throw new CliError("<draft-id> must be a UUID. Run `nolto issue drafts` to list drafts.", 2);
3093
3166
  const project = await projectLine(deps, ctx);
3094
- const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
3167
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
3095
3168
  printResult(ctx.mode === "json" ? result : `${result.issue.key} published${project}
3096
3169
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningLines(result.warnings)}`, ctx.mode);
3097
3170
  });
@@ -3100,9 +3173,10 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningL
3100
3173
  const number = parseIssueRef(ref);
3101
3174
  ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3102
3175
  const { input } = await writeInput(deps, ctx.root, flags, false);
3176
+ const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
3103
3177
  const project = await projectLine(deps, ctx);
3104
- const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, input);
3105
- printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags)}${project}
3178
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, input, view);
3179
+ printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags, view)}${project}
3106
3180
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3107
3181
  });
3108
3182
  sharedOptions(group.command("comment <ref>").description("Post a comment.").option("-m, --comment <text>", "Comment text").option("--body-file <path>", "Read comment from file (- for stdin)")).action(async (ref, flags, command) => {
@@ -3111,10 +3185,11 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
3111
3185
  ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3112
3186
  const body = await bodyText(flags.comment, flags.bodyFile);
3113
3187
  if (!body?.trim()) throw new CliError("A comment is required. Use -m or --body-file.", 2);
3114
- const issue = ctx.mode === "human" ? (await deps.http.get(`${ctx.root}/issues/${number}`)).issue : void 0;
3188
+ const { view, issue: read } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
3189
+ const issue = read ?? (ctx.mode === "human" ? (await deps.http.get(`${ctx.root}/issues/${number}`)).issue : void 0);
3115
3190
  const project = await projectLine(deps, ctx);
3116
- const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues/${number}/comments`, { body });
3117
- printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags)}${project}
3191
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issues/${number}/comments`, { body }, view);
3192
+ printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags, view)}${project}
3118
3193
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3119
3194
  });
3120
3195
  sharedOptions(group.command("close <ref>").description("Move an issue to a closed status.").option("--status <name-or-id>", "Closed status (defaults to first by sort order)").option("-m, --comment <text>", "Comment in the same update")).action(async (ref, flags, command) => {
@@ -3123,9 +3198,10 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
3123
3198
  ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3124
3199
  const settings = await deps.http.get(`${ctx.root}/issue-settings`);
3125
3200
  const status = pickClosedStatus(settings, flags.status);
3201
+ const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
3126
3202
  const project = await projectLine(deps, ctx);
3127
- const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} });
3128
- printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags)}${project}
3203
+ const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} }, view);
3204
+ printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags, view)}${project}
3129
3205
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3130
3206
  });
3131
3207
  }
@@ -3650,23 +3726,23 @@ function currentCleanupCandidates(state, context4) {
3650
3726
  function hasSharedMemoryName(entry, entries, context4) {
3651
3727
  return currentMemoryEntries(entries, context4).some((e) => e.name === entry.name && e.scope !== entry.scope);
3652
3728
  }
3653
- function cleanupSection(candidates, entries, context4, limit = 10) {
3654
- if (!candidates.length) return [];
3729
+ function cleanupSection(candidates2, entries, context4, limit = 10) {
3730
+ if (!candidates2.length) return [];
3655
3731
  return [
3656
3732
  "## \u6574\u7406\u5019\u88DC(\u78BA\u304B\u3081\u3066\u6D88\u3059\u306A\u3089 nolto memory rm <name>)",
3657
- ...candidates.slice(0, limit).map((c) => {
3733
+ ...candidates2.slice(0, limit).map((c) => {
3658
3734
  const shared = hasSharedMemoryName(c, entries, context4);
3659
3735
  return `- ${shared ? `${c.scope}/` : ""}${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`;
3660
3736
  }),
3661
- ...candidates.length > limit ? [`\u307B\u304B ${candidates.length - limit} \u4EF6: nolto memory candidates`] : []
3737
+ ...candidates2.length > limit ? [`\u307B\u304B ${candidates2.length - limit} \u4EF6: nolto memory candidates`] : []
3662
3738
  ];
3663
3739
  }
3664
3740
  function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
3665
3741
  const branch = context4.branch && context4.branch !== context4.defaultBranch ? context4.branch : null;
3666
- const candidates = currentCleanupCandidates(cache.state, context4);
3667
- const candidateIds = new Set(candidates.map((c) => c.entryId));
3742
+ const candidates2 = currentCleanupCandidates(cache.state, context4);
3743
+ const candidateIds = new Set(candidates2.map((c) => c.entryId));
3668
3744
  const entries = sortMemoryEntries(currentMemoryEntries(cache.state.entries, context4).filter((e) => !candidateIds.has(e.id)));
3669
- let candidateLimit = Math.min(10, candidates.length);
3745
+ let candidateLimit = Math.min(10, candidates2.length);
3670
3746
  const groups = ["project", "user", ...branch ? ["branch"] : []];
3671
3747
  const mergedLines = [...merged].sort().map((b) => `merge \u6E08\u307F\u306E ${terminalLine(b)} \u306B ${cache.state.entries.filter((e) => !e.deleted && e.scope === "branch" && e.repoIdentity === context4.repoIdentity && e.branch === b).length} \u4EF6: nolto memory promote --branch ${commandArg(b, "<branch>")}`);
3672
3748
  let omitted = 0;
@@ -3679,7 +3755,7 @@ function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
3679
3755
  const lines2 = entries.filter((e) => e.scope === scope).map((e) => `- ${terminalLine(e.name)} \u2014 ${terminalLine(e.description)}`);
3680
3756
  return lines2.length ? [`## ${scope === "branch" ? `branch ${terminalLine(branch)}` : scope}`, ...lines2] : [];
3681
3757
  }),
3682
- ...cleanupSection(candidates, cache.state.entries, context4, candidateLimit),
3758
+ ...cleanupSection(candidates2, cache.state.entries, context4, candidateLimit),
3683
3759
  ...mergedLines,
3684
3760
  ...omitted ? [`\u6B8B\u308A ${omitted} \u4EF6: nolto memory list`] : []
3685
3761
  ];
@@ -3928,13 +4004,13 @@ function suggestProjectKey(name) {
3928
4004
  var __dirname2 = path17.dirname(fileURLToPath2(import.meta.url));
3929
4005
  var _require = createRequire(import.meta.url);
3930
4006
  function getCliVersion() {
3931
- const candidates = [
4007
+ const candidates2 = [
3932
4008
  path17.resolve(__dirname2, "../package.json"),
3933
4009
  // bundled: dist/../package.json
3934
4010
  path17.resolve(__dirname2, "../../package.json")
3935
4011
  // source: src/commands/../../package.json
3936
4012
  ];
3937
- for (const pkgPath of candidates) {
4013
+ for (const pkgPath of candidates2) {
3938
4014
  if (fs2.existsSync(pkgPath)) {
3939
4015
  try {
3940
4016
  const pkg = _require(pkgPath);
@@ -5683,12 +5759,12 @@ function chooseStatus(base, ours, theirs) {
5683
5759
  if (!oursChanged) return theirs.status;
5684
5760
  if (!theirsChanged) return ours.status;
5685
5761
  }
5686
- const candidates = [ours, theirs];
5687
- if (candidates.some((task) => task.status === "done" && task.completedAt != null)) {
5762
+ const candidates2 = [ours, theirs];
5763
+ if (candidates2.some((task) => task.status === "done" && task.completedAt != null)) {
5688
5764
  return "done";
5689
5765
  }
5690
5766
  for (const status of ["blocked", "in-progress", "todo"]) {
5691
- if (candidates.some((task) => task.status === status)) return status;
5767
+ if (candidates2.some((task) => task.status === status)) return status;
5692
5768
  }
5693
5769
  return base?.status !== "done" ? base?.status ?? "todo" : "todo";
5694
5770
  }
@@ -5969,9 +6045,9 @@ function resolveEntry(ctx, name, target, deleted = false) {
5969
6045
  const branch = target.branch ?? ctx.git.branch;
5970
6046
  const named = ctx.cache.state.entries.filter((e) => e.name === name && (!scope || e.scope === scope));
5971
6047
  const inRepo = (e) => e.scope !== "branch" || e.repoIdentity === ctx.git.repoIdentity;
5972
- const candidates = named.filter((e) => inRepo(e) && (e.scope !== "branch" || e.branch === branch) && (deleted || !e.deleted));
5973
- if (candidates.length > 1) throw new CliError(`\u30E1\u30E2\u30EA ${terminalLine(name)} \u306F\u66D6\u6627\u3067\u3059: ${candidates.map((e) => `${e.scope}/${terminalLine(e.name)}`).join(", ")}`, 2, "--scope \u3092\u4ED8\u3051\u308B");
5974
- if (candidates.length) return candidates[0];
6048
+ const candidates2 = named.filter((e) => inRepo(e) && (e.scope !== "branch" || e.branch === branch) && (deleted || !e.deleted));
6049
+ if (candidates2.length > 1) throw new CliError(`\u30E1\u30E2\u30EA ${terminalLine(name)} \u306F\u66D6\u6627\u3067\u3059: ${candidates2.map((e) => `${e.scope}/${terminalLine(e.name)}`).join(", ")}`, 2, "--scope \u3092\u4ED8\u3051\u308B");
6050
+ if (candidates2.length) return candidates2[0];
5975
6051
  const others = [...new Set(named.filter((e) => e.scope === "branch" && inRepo(e) && e.branch !== branch && !e.deleted).map((e) => e.branch))];
5976
6052
  if (others.length) {
5977
6053
  throw new CliError(`\u30E1\u30E2\u30EA ${terminalLine(name)} \u306F\u4ECA\u306E\u30D6\u30E9\u30F3\u30C1\u306B\u3042\u308A\u307E\u305B\u3093\u3002\u307B\u304B\u306E\u30D6\u30E9\u30F3\u30C1: ${others.map(terminalLine).join(", ")}`, 2, `--branch ${commandArg(others[0], "<branch>")} \u3092\u4ED8\u3051\u308B`);
@@ -6182,9 +6258,9 @@ function register15(program, deps) {
6182
6258
  ctx.cache.state.cleanupCandidates = fetched;
6183
6259
  await updateCache(ctx, deps, [], true);
6184
6260
  }
6185
- const candidates = currentCleanupCandidates(ctx.cache.state, ctx.git);
6186
- printResult(deps.output.mode === "json" ? { candidates } : [
6187
- ...candidates.length ? candidates.map((c) => `${c.scope}/${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`) : ["\u6574\u7406\u5019\u88DC\u306F\u3042\u308A\u307E\u305B\u3093"],
6261
+ const candidates2 = currentCleanupCandidates(ctx.cache.state, ctx.git);
6262
+ printResult(deps.output.mode === "json" ? { candidates: candidates2 } : [
6263
+ ...candidates2.length ? candidates2.map((c) => `${c.scope}/${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`) : ["\u6574\u7406\u5019\u88DC\u306F\u3042\u308A\u307E\u305B\u3093"],
6188
6264
  ...fetched === null ? ["(\u6700\u7D42\u540C\u671F\u306E\u6642\u70B9\u306E\u5019\u88DC)"] : []
6189
6265
  ].join("\n"), deps.output.mode);
6190
6266
  });
@@ -6208,10 +6284,10 @@ function register15(program, deps) {
6208
6284
  ...opts.ai === false ? { aiSkip: true } : {},
6209
6285
  ...scope === "branch" ? { repoIdentity: ctx.git.repoIdentity, branch: ctx.git.branch } : {}
6210
6286
  }, headers()), "put", draft.name);
6211
- const candidates = await fetchCandidates(deps, ctx, AbortSignal.timeout(3e3));
6212
- if (candidates !== null) {
6213
- ctx.cache.state.cleanupCandidates = candidates;
6214
- response.cleanupCandidates = candidates;
6287
+ const candidates2 = await fetchCandidates(deps, ctx, AbortSignal.timeout(3e3));
6288
+ if (candidates2 !== null) {
6289
+ ctx.cache.state.cleanupCandidates = candidates2;
6290
+ response.cleanupCandidates = candidates2;
6215
6291
  } else {
6216
6292
  const changed = /* @__PURE__ */ new Set([response.entry.id, ...(response.affected ?? []).map((a) => a.entryId)]);
6217
6293
  ctx.cache.state.cleanupCandidates = (ctx.cache.state.cleanupCandidates ?? []).filter((c) => !changed.has(c.entryId));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.25.1",
3
+ "version": "0.26.0",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "README.md"
13
13
  ],
14
14
  "engines": {
15
- "node": ">=20.11.0"
15
+ "node": ">=22"
16
16
  },
17
17
  "publishConfig": {
18
18
  "access": "public"