@nolto/cli 0.25.1 → 0.27.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 +9 -2
- package/dist/index.js +141 -45
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,6 +56,8 @@ expires (HTTP 401), run `nolto login` again. `nolto whoami` shows the expiry dat
|
|
|
56
56
|
and, within 7 days of it, a reminder. The memory hook (`nolto memory pull --hook`)
|
|
57
57
|
also tells you to run `nolto login` on a 401.
|
|
58
58
|
|
|
59
|
+
A token has the `share` scope when it is created by `nolto login` (or issued with "共有" allowed in the settings). The `share` scope is needed to switch what customers see: `--shared` writes and `--audience`. A token created by `nolto login` before the `share` scope was added does not have it; if `nolto whoami` shows no `share` in its scopes, run `nolto login` again to switch sharing. The API answers 403 `token_scope` (`requiredScope: "share"`), and the CLI exits 3 with a hint to log in again.
|
|
60
|
+
|
|
59
61
|
`nolto logout` asks the server to revoke the saved token (`POST /api/me/token/revoke`),
|
|
60
62
|
then removes only `token` from the config file (`baseUrl` stays) and clears the
|
|
61
63
|
memory caches. If the server cannot be reached, does not have the route yet (404),
|
|
@@ -268,8 +270,13 @@ References accept a key (NOLTO-12) or number (12). Only the number is sent. With
|
|
|
268
270
|
| `issue comment <ref>` | `-m/--comment <text>` or `--body-file <path-or-dash>` |
|
|
269
271
|
| `issue close <ref>` | `--status <closed-name-or-UUID>`, `-m/--comment <text>` |
|
|
270
272
|
|
|
271
|
-
- `--
|
|
272
|
-
- `--
|
|
273
|
+
- `--no-customer-notify` on update or close sends `skipCustomerNotification: true`: this one status change of a shared issue is not notified to the customers watching it (they still see it in the issue's history). Without it, the project's setting (all / only when a closed status is reached / none) decides. It is for the internal write only: combined with `--shared` it exits 2 before any request (the API answers 400 too). It has no effect when the status does not change.
|
|
274
|
+
- `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The token needs the `share` scope (see Setup and Authentication; tokens from `nolto login` made before the `share` scope was added do not have it; if `nolto whoami` shows no `share`, run `nolto login` again). 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.
|
|
275
|
+
- `--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>`.
|
|
276
|
+
- 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.
|
|
277
|
+
- 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.
|
|
278
|
+
- 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).
|
|
279
|
+
- `--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
280
|
|
|
274
281
|
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
282
|
|
package/dist/index.js
CHANGED
|
@@ -140,6 +140,16 @@ function mapHttpStatusToCliError(status, opts = {}) {
|
|
|
140
140
|
const details = Array.isArray(opts.details) ? opts.details.map((detail) => typeof detail === "string" ? detail : JSON.stringify(detail)).join("\n") : "";
|
|
141
141
|
return new CliError([opts.serverError ?? opts.serverMessage ?? "Validation failed", details].filter(Boolean).join("\n"), 2, void 0, status, opts.serverError, opts.body);
|
|
142
142
|
}
|
|
143
|
+
if (status === 403 && opts.serverError === "token_scope" && opts.body?.requiredScope === "share") {
|
|
144
|
+
return new CliError(
|
|
145
|
+
opts.serverMessage ?? opts.serverError,
|
|
146
|
+
3,
|
|
147
|
+
"\u5171\u6709\u3092\u5207\u308A\u66FF\u3048\u308B\u306B\u306F\u3001\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u3066\u304B\u3089 `nolto login` \u3067\u30ED\u30B0\u30A4\u30F3\u3057\u76F4\u3059\u304B\u3001\u8A2D\u5B9A\u3067\u300C\u5171\u6709\u300D\u3092\u8A31\u53EF\u3057\u305F token \u3092\u767A\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
148
|
+
status,
|
|
149
|
+
opts.serverError,
|
|
150
|
+
opts.body
|
|
151
|
+
);
|
|
152
|
+
}
|
|
143
153
|
if (status === 403 && (opts.serverError === "token_scope" || opts.serverError === "token_project")) {
|
|
144
154
|
return new CliError(
|
|
145
155
|
opts.serverMessage ?? opts.serverError,
|
|
@@ -203,13 +213,13 @@ import path from "path";
|
|
|
203
213
|
import { fileURLToPath } from "url";
|
|
204
214
|
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
205
215
|
function resolveSkillSourceDir(name = "roadmap-progress") {
|
|
206
|
-
const
|
|
216
|
+
const candidates2 = [
|
|
207
217
|
path.resolve(__dirname, `skill/${name}`),
|
|
208
218
|
// bundled: dist/skill/...
|
|
209
219
|
path.resolve(__dirname, `../../../skills/${name}`)
|
|
210
220
|
// source: <repo>/skills/...
|
|
211
221
|
];
|
|
212
|
-
for (const candidate of
|
|
222
|
+
for (const candidate of candidates2) {
|
|
213
223
|
if (existsSync(path.join(candidate, "SKILL.md"))) return candidate;
|
|
214
224
|
}
|
|
215
225
|
throw new Error(`Bundled ${name} skill not found. Reinstall @nolto/cli.`);
|
|
@@ -2900,11 +2910,21 @@ async function roadmapMigrate(deps, yes = false) {
|
|
|
2900
2910
|
// src/commands/issue.ts
|
|
2901
2911
|
var emptySettings = { types: [], statuses: [], categories: [] };
|
|
2902
2912
|
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.";
|
|
2913
|
+
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
2914
|
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
2915
|
function sharedOptions(command) {
|
|
2905
|
-
return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only.").option("--confirm-references", confirmHelp);
|
|
2916
|
+
return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only. The token needs the share scope.").option("--audience <name-or-id>", "Share audience for --shared (name or UUID). Required on create when the project has several audiences. Like --shared, it needs the share scope.").option("--confirm-references", confirmHelp);
|
|
2917
|
+
}
|
|
2918
|
+
function noCustomerNotifyOption(command) {
|
|
2919
|
+
return command.option("--no-customer-notify", "Do not notify watching customers of this status change of a shared issue (this one time only). Not for --shared.");
|
|
2920
|
+
}
|
|
2921
|
+
function checkNoCustomerNotify(flags) {
|
|
2922
|
+
if (flags.customerNotify !== false) return {};
|
|
2923
|
+
if (flags.shared) throw new CliError("--no-customer-notify \u306F --shared \u3068\u4E00\u7DD2\u306B\u4F7F\u3048\u307E\u305B\u3093(\u5171\u6709\u30E2\u30FC\u30C9\u306E\u66F8\u304D\u8FBC\u307F\u306F\u3001\u304A\u5BA2\u3055\u307E\u306B\u901A\u77E5\u3055\u308C\u307E\u3059)\u3002", 2);
|
|
2924
|
+
return { skipCustomerNotification: true };
|
|
2906
2925
|
}
|
|
2907
2926
|
async function checkShared(deps, root, flags, ref) {
|
|
2927
|
+
if (flags.audience !== void 0 && !flags.shared) throw new CliError("--audience \u306F --shared \u3068\u4E00\u7DD2\u306B\u4F7F\u3044\u307E\u3059\u3002", 2);
|
|
2908
2928
|
if (!flags.shared) return;
|
|
2909
2929
|
if (flags.priority !== void 0 || flags.category !== void 0) {
|
|
2910
2930
|
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 +2939,65 @@ async function checkShared(deps, root, flags, ref) {
|
|
|
2919
2939
|
}
|
|
2920
2940
|
return context4.project?.name;
|
|
2921
2941
|
}
|
|
2922
|
-
function
|
|
2923
|
-
|
|
2924
|
-
|
|
2942
|
+
async function audienceList(deps, root) {
|
|
2943
|
+
try {
|
|
2944
|
+
const result = await deps.http.get(`${root}/audiences`);
|
|
2945
|
+
return (result.audiences ?? []).filter((row) => typeof row?.id === "string" && isUuid(row.id) && typeof row.name === "string");
|
|
2946
|
+
} catch (error) {
|
|
2947
|
+
if (error instanceof CliError && error.status === 403 && error.serverError === "token_scope") {
|
|
2948
|
+
throw new CliError(
|
|
2949
|
+
"\u5171\u6709\u5148\u306E\u4E00\u89A7\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
|
|
2950
|
+
error.exitCode,
|
|
2951
|
+
"API \u304C\u53E4\u3044\u304B\u3001token \u306B issues:read \u306E scope \u304C\u3042\u308A\u307E\u305B\u3093\u3002",
|
|
2952
|
+
error.status,
|
|
2953
|
+
error.serverError,
|
|
2954
|
+
error.body
|
|
2955
|
+
);
|
|
2956
|
+
}
|
|
2957
|
+
throw error;
|
|
2958
|
+
}
|
|
2925
2959
|
}
|
|
2926
|
-
|
|
2960
|
+
var candidates = (audiences) => audiences.map((row) => terminalLine(row.name)).join("\u3001");
|
|
2961
|
+
function pickAudience(audiences, input) {
|
|
2962
|
+
const wanted = input.trim();
|
|
2963
|
+
const uuid = isUuid(wanted);
|
|
2964
|
+
const matches = audiences.filter((row) => uuid ? row.id.toLowerCase() === wanted.toLowerCase() : row.name.trim() === wanted);
|
|
2965
|
+
const named = uuid && matches.length === 1 ? audiences.find((row) => row !== matches[0] && row.name.trim().toLowerCase() === wanted.toLowerCase()) : void 0;
|
|
2966
|
+
if (named) {
|
|
2967
|
+
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);
|
|
2968
|
+
}
|
|
2969
|
+
if (matches.length === 1) return matches[0];
|
|
2970
|
+
if (matches.length > 1) {
|
|
2971
|
+
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);
|
|
2972
|
+
}
|
|
2973
|
+
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);
|
|
2974
|
+
throw new CliError(`\u5171\u6709\u5148 ${terminalLine(wanted)} \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093(\u5019\u88DC: ${candidates(audiences)})\u3002`, 2, audienceHint);
|
|
2975
|
+
}
|
|
2976
|
+
async function sharedView(deps, root, mode2, flags, number) {
|
|
2977
|
+
if (!flags.shared) return {};
|
|
2978
|
+
if (flags.audience !== void 0) return { view: pickAudience(await audienceList(deps, root), flags.audience) };
|
|
2979
|
+
if (number === void 0) return { view: {} };
|
|
2980
|
+
const { issue } = await deps.http.get(`${root}/issues/${number}`);
|
|
2981
|
+
if (issue.shared === false) {
|
|
2982
|
+
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);
|
|
2983
|
+
}
|
|
2984
|
+
const id = typeof issue.audienceId === "string" && isUuid(issue.audienceId) ? issue.audienceId.toLowerCase() : void 0;
|
|
2985
|
+
const name = id && mode2 === "human" ? (await audienceList(deps, root).catch(() => [])).find((row) => row.id.toLowerCase() === id)?.name : void 0;
|
|
2986
|
+
return { view: { id, name }, issue };
|
|
2987
|
+
}
|
|
2988
|
+
var viewHeaders = (id) => ({ "X-Nolto-View": id !== void 0 && isUuid(id) ? `shared; audience=${id.toLowerCase()}` : "shared" });
|
|
2989
|
+
function writeSuffix(flags, view) {
|
|
2990
|
+
const label = view?.name ? terminalLine(view.name) : "";
|
|
2991
|
+
const shared = label ? `shared: ${label}` : "shared";
|
|
2992
|
+
if (flags.shared && flags.confirmReferences) return ` (${shared}, references confirmed)`;
|
|
2993
|
+
return flags.shared ? ` (${shared})` : flags.confirmReferences ? " (references confirmed)" : "";
|
|
2994
|
+
}
|
|
2995
|
+
async function writeRequest(deps, mode2, flags, root, method, path24, body, view) {
|
|
2927
2996
|
try {
|
|
2928
2997
|
return await deps.http[method](
|
|
2929
2998
|
path24,
|
|
2930
2999
|
flags.confirmReferences ? { ...body, confirmReferences: true } : body,
|
|
2931
|
-
flags.shared ?
|
|
3000
|
+
flags.shared ? viewHeaders(view?.id) : void 0
|
|
2932
3001
|
);
|
|
2933
3002
|
} catch (error) {
|
|
2934
3003
|
if (!(error instanceof CliError)) throw error;
|
|
@@ -2944,11 +3013,32 @@ async function writeRequest(deps, mode2, flags, method, path24, body) {
|
|
|
2944
3013
|
detail
|
|
2945
3014
|
);
|
|
2946
3015
|
}
|
|
3016
|
+
if (flags.shared && error.status === 400 && error.serverError === "view_audience_required" && view?.id === void 0) {
|
|
3017
|
+
const audiences = await audienceList(deps, root).catch(() => void 0);
|
|
3018
|
+
throw new CliError(
|
|
3019
|
+
`\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`,
|
|
3020
|
+
2,
|
|
3021
|
+
audienceHint,
|
|
3022
|
+
error.status,
|
|
3023
|
+
error.serverError,
|
|
3024
|
+
error.body
|
|
3025
|
+
);
|
|
3026
|
+
}
|
|
3027
|
+
if (flags.shared && error.status === 400 && error.serverError === "view_audience_invalid") {
|
|
3028
|
+
throw new CliError(
|
|
3029
|
+
"\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",
|
|
3030
|
+
2,
|
|
3031
|
+
"--audience <\u540D\u524D> \u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
3032
|
+
error.status,
|
|
3033
|
+
error.serverError,
|
|
3034
|
+
error.body
|
|
3035
|
+
);
|
|
3036
|
+
}
|
|
2947
3037
|
if (flags.shared && error.status === 404 && (method === "patch" || path24.endsWith("/comments"))) {
|
|
2948
3038
|
throw new CliError(
|
|
2949
3039
|
error.message,
|
|
2950
3040
|
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",
|
|
3041
|
+
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
3042
|
error.status,
|
|
2953
3043
|
error.serverError,
|
|
2954
3044
|
error.body,
|
|
@@ -3071,15 +3161,16 @@ nolto issue publish <draft-id>
|
|
|
3071
3161
|
const { input, fromTemplate } = await writeInput(deps, ctx.root, flags, true);
|
|
3072
3162
|
if (flags.draft) {
|
|
3073
3163
|
const project2 = await projectLine(deps, ctx);
|
|
3074
|
-
const result2 = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts`, input);
|
|
3164
|
+
const result2 = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issue-drafts`, input);
|
|
3075
3165
|
printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created${writeSuffix(flags)}${project2}
|
|
3076
3166
|
${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}${warningLines(result2.warnings)}`, ctx.mode);
|
|
3077
3167
|
return;
|
|
3078
3168
|
}
|
|
3169
|
+
const { view } = await sharedView(deps, ctx.root, ctx.mode, flags);
|
|
3079
3170
|
const project = await projectLine(deps, ctx);
|
|
3080
|
-
const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues`, input);
|
|
3171
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issues`, input, view);
|
|
3081
3172
|
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}
|
|
3173
|
+
printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags, view)}${project}
|
|
3083
3174
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}${warningLines(result.warnings)}`, ctx.mode);
|
|
3084
3175
|
});
|
|
3085
3176
|
group.command("drafts").description("List your issue drafts (visible only to you).").action(async (_flags, command) => {
|
|
@@ -3091,18 +3182,20 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemp
|
|
|
3091
3182
|
const ctx = context(deps, command);
|
|
3092
3183
|
if (!isUuid(id)) throw new CliError("<draft-id> must be a UUID. Run `nolto issue drafts` to list drafts.", 2);
|
|
3093
3184
|
const project = await projectLine(deps, ctx);
|
|
3094
|
-
const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
|
|
3185
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
|
|
3095
3186
|
printResult(ctx.mode === "json" ? result : `${result.issue.key} published${project}
|
|
3096
3187
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
3097
3188
|
});
|
|
3098
|
-
writeOptions(group.command("update <ref>").description("Update issue fields."), false).action(async (ref, flags, command) => {
|
|
3189
|
+
noCustomerNotifyOption(writeOptions(group.command("update <ref>").description("Update issue fields."), false)).action(async (ref, flags, command) => {
|
|
3099
3190
|
const ctx = context(deps, command);
|
|
3100
3191
|
const number = parseIssueRef(ref);
|
|
3192
|
+
const skip = checkNoCustomerNotify(flags);
|
|
3101
3193
|
ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
|
|
3102
3194
|
const { input } = await writeInput(deps, ctx.root, flags, false);
|
|
3195
|
+
const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
|
|
3103
3196
|
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}
|
|
3197
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, { ...input, ...skip }, view);
|
|
3198
|
+
printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags, view)}${project}
|
|
3106
3199
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
3107
3200
|
});
|
|
3108
3201
|
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,21 +3204,24 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
|
|
|
3111
3204
|
ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
|
|
3112
3205
|
const body = await bodyText(flags.comment, flags.bodyFile);
|
|
3113
3206
|
if (!body?.trim()) throw new CliError("A comment is required. Use -m or --body-file.", 2);
|
|
3114
|
-
const
|
|
3207
|
+
const { view, issue: read } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
|
|
3208
|
+
const issue = read ?? (ctx.mode === "human" ? (await deps.http.get(`${ctx.root}/issues/${number}`)).issue : void 0);
|
|
3115
3209
|
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}
|
|
3210
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issues/${number}/comments`, { body }, view);
|
|
3211
|
+
printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags, view)}${project}
|
|
3118
3212
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
3119
3213
|
});
|
|
3120
|
-
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) => {
|
|
3214
|
+
noCustomerNotifyOption(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) => {
|
|
3121
3215
|
const ctx = context(deps, command);
|
|
3122
3216
|
const number = parseIssueRef(ref);
|
|
3217
|
+
const skip = checkNoCustomerNotify(flags);
|
|
3123
3218
|
ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
|
|
3124
3219
|
const settings = await deps.http.get(`${ctx.root}/issue-settings`);
|
|
3125
3220
|
const status = pickClosedStatus(settings, flags.status);
|
|
3221
|
+
const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
|
|
3126
3222
|
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}
|
|
3223
|
+
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 } : {}, ...skip }, view);
|
|
3224
|
+
printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags, view)}${project}
|
|
3129
3225
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
3130
3226
|
});
|
|
3131
3227
|
}
|
|
@@ -3650,23 +3746,23 @@ function currentCleanupCandidates(state, context4) {
|
|
|
3650
3746
|
function hasSharedMemoryName(entry, entries, context4) {
|
|
3651
3747
|
return currentMemoryEntries(entries, context4).some((e) => e.name === entry.name && e.scope !== entry.scope);
|
|
3652
3748
|
}
|
|
3653
|
-
function cleanupSection(
|
|
3654
|
-
if (!
|
|
3749
|
+
function cleanupSection(candidates2, entries, context4, limit = 10) {
|
|
3750
|
+
if (!candidates2.length) return [];
|
|
3655
3751
|
return [
|
|
3656
3752
|
"## \u6574\u7406\u5019\u88DC(\u78BA\u304B\u3081\u3066\u6D88\u3059\u306A\u3089 nolto memory rm <name>)",
|
|
3657
|
-
...
|
|
3753
|
+
...candidates2.slice(0, limit).map((c) => {
|
|
3658
3754
|
const shared = hasSharedMemoryName(c, entries, context4);
|
|
3659
3755
|
return `- ${shared ? `${c.scope}/` : ""}${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`;
|
|
3660
3756
|
}),
|
|
3661
|
-
...
|
|
3757
|
+
...candidates2.length > limit ? [`\u307B\u304B ${candidates2.length - limit} \u4EF6: nolto memory candidates`] : []
|
|
3662
3758
|
];
|
|
3663
3759
|
}
|
|
3664
3760
|
function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
|
|
3665
3761
|
const branch = context4.branch && context4.branch !== context4.defaultBranch ? context4.branch : null;
|
|
3666
|
-
const
|
|
3667
|
-
const candidateIds = new Set(
|
|
3762
|
+
const candidates2 = currentCleanupCandidates(cache.state, context4);
|
|
3763
|
+
const candidateIds = new Set(candidates2.map((c) => c.entryId));
|
|
3668
3764
|
const entries = sortMemoryEntries(currentMemoryEntries(cache.state.entries, context4).filter((e) => !candidateIds.has(e.id)));
|
|
3669
|
-
let candidateLimit = Math.min(10,
|
|
3765
|
+
let candidateLimit = Math.min(10, candidates2.length);
|
|
3670
3766
|
const groups = ["project", "user", ...branch ? ["branch"] : []];
|
|
3671
3767
|
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
3768
|
let omitted = 0;
|
|
@@ -3679,7 +3775,7 @@ function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
|
|
|
3679
3775
|
const lines2 = entries.filter((e) => e.scope === scope).map((e) => `- ${terminalLine(e.name)} \u2014 ${terminalLine(e.description)}`);
|
|
3680
3776
|
return lines2.length ? [`## ${scope === "branch" ? `branch ${terminalLine(branch)}` : scope}`, ...lines2] : [];
|
|
3681
3777
|
}),
|
|
3682
|
-
...cleanupSection(
|
|
3778
|
+
...cleanupSection(candidates2, cache.state.entries, context4, candidateLimit),
|
|
3683
3779
|
...mergedLines,
|
|
3684
3780
|
...omitted ? [`\u6B8B\u308A ${omitted} \u4EF6: nolto memory list`] : []
|
|
3685
3781
|
];
|
|
@@ -3928,13 +4024,13 @@ function suggestProjectKey(name) {
|
|
|
3928
4024
|
var __dirname2 = path17.dirname(fileURLToPath2(import.meta.url));
|
|
3929
4025
|
var _require = createRequire(import.meta.url);
|
|
3930
4026
|
function getCliVersion() {
|
|
3931
|
-
const
|
|
4027
|
+
const candidates2 = [
|
|
3932
4028
|
path17.resolve(__dirname2, "../package.json"),
|
|
3933
4029
|
// bundled: dist/../package.json
|
|
3934
4030
|
path17.resolve(__dirname2, "../../package.json")
|
|
3935
4031
|
// source: src/commands/../../package.json
|
|
3936
4032
|
];
|
|
3937
|
-
for (const pkgPath of
|
|
4033
|
+
for (const pkgPath of candidates2) {
|
|
3938
4034
|
if (fs2.existsSync(pkgPath)) {
|
|
3939
4035
|
try {
|
|
3940
4036
|
const pkg = _require(pkgPath);
|
|
@@ -5683,12 +5779,12 @@ function chooseStatus(base, ours, theirs) {
|
|
|
5683
5779
|
if (!oursChanged) return theirs.status;
|
|
5684
5780
|
if (!theirsChanged) return ours.status;
|
|
5685
5781
|
}
|
|
5686
|
-
const
|
|
5687
|
-
if (
|
|
5782
|
+
const candidates2 = [ours, theirs];
|
|
5783
|
+
if (candidates2.some((task) => task.status === "done" && task.completedAt != null)) {
|
|
5688
5784
|
return "done";
|
|
5689
5785
|
}
|
|
5690
5786
|
for (const status of ["blocked", "in-progress", "todo"]) {
|
|
5691
|
-
if (
|
|
5787
|
+
if (candidates2.some((task) => task.status === status)) return status;
|
|
5692
5788
|
}
|
|
5693
5789
|
return base?.status !== "done" ? base?.status ?? "todo" : "todo";
|
|
5694
5790
|
}
|
|
@@ -5969,9 +6065,9 @@ function resolveEntry(ctx, name, target, deleted = false) {
|
|
|
5969
6065
|
const branch = target.branch ?? ctx.git.branch;
|
|
5970
6066
|
const named = ctx.cache.state.entries.filter((e) => e.name === name && (!scope || e.scope === scope));
|
|
5971
6067
|
const inRepo = (e) => e.scope !== "branch" || e.repoIdentity === ctx.git.repoIdentity;
|
|
5972
|
-
const
|
|
5973
|
-
if (
|
|
5974
|
-
if (
|
|
6068
|
+
const candidates2 = named.filter((e) => inRepo(e) && (e.scope !== "branch" || e.branch === branch) && (deleted || !e.deleted));
|
|
6069
|
+
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");
|
|
6070
|
+
if (candidates2.length) return candidates2[0];
|
|
5975
6071
|
const others = [...new Set(named.filter((e) => e.scope === "branch" && inRepo(e) && e.branch !== branch && !e.deleted).map((e) => e.branch))];
|
|
5976
6072
|
if (others.length) {
|
|
5977
6073
|
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 +6278,9 @@ function register15(program, deps) {
|
|
|
6182
6278
|
ctx.cache.state.cleanupCandidates = fetched;
|
|
6183
6279
|
await updateCache(ctx, deps, [], true);
|
|
6184
6280
|
}
|
|
6185
|
-
const
|
|
6186
|
-
printResult(deps.output.mode === "json" ? { candidates } : [
|
|
6187
|
-
...
|
|
6281
|
+
const candidates2 = currentCleanupCandidates(ctx.cache.state, ctx.git);
|
|
6282
|
+
printResult(deps.output.mode === "json" ? { candidates: candidates2 } : [
|
|
6283
|
+
...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
6284
|
...fetched === null ? ["(\u6700\u7D42\u540C\u671F\u306E\u6642\u70B9\u306E\u5019\u88DC)"] : []
|
|
6189
6285
|
].join("\n"), deps.output.mode);
|
|
6190
6286
|
});
|
|
@@ -6208,10 +6304,10 @@ function register15(program, deps) {
|
|
|
6208
6304
|
...opts.ai === false ? { aiSkip: true } : {},
|
|
6209
6305
|
...scope === "branch" ? { repoIdentity: ctx.git.repoIdentity, branch: ctx.git.branch } : {}
|
|
6210
6306
|
}, headers()), "put", draft.name);
|
|
6211
|
-
const
|
|
6212
|
-
if (
|
|
6213
|
-
ctx.cache.state.cleanupCandidates =
|
|
6214
|
-
response.cleanupCandidates =
|
|
6307
|
+
const candidates2 = await fetchCandidates(deps, ctx, AbortSignal.timeout(3e3));
|
|
6308
|
+
if (candidates2 !== null) {
|
|
6309
|
+
ctx.cache.state.cleanupCandidates = candidates2;
|
|
6310
|
+
response.cleanupCandidates = candidates2;
|
|
6215
6311
|
} else {
|
|
6216
6312
|
const changed = /* @__PURE__ */ new Set([response.entry.id, ...(response.affected ?? []).map((a) => a.entryId)]);
|
|
6217
6313
|
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.
|
|
3
|
+
"version": "0.27.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": ">=
|
|
15
|
+
"node": ">=22"
|
|
16
16
|
},
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|