@nolto/cli 0.19.1 → 0.19.2

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/dist/index.js CHANGED
@@ -1077,6 +1077,13 @@ function formatIssueList(rows, meta) {
1077
1077
  const lines = values.map((row) => row.map((value, index) => index < 4 ? value.padEnd(widths[index]) : value).join(" "));
1078
1078
  return [...lines, `${rows.length} / ${meta.total} (page ${meta.page})`].join("\n");
1079
1079
  }
1080
+ function formatDraftList(list) {
1081
+ if (list.drafts.length === 0) return "No drafts.";
1082
+ return [
1083
+ ...list.drafts.map((draft) => [draft.id, singleLine(draft.subject) || "(no subject)", draft.source, draft.updatedAt].join(" ")),
1084
+ `${list.count}/${list.limit} drafts`
1085
+ ].join("\n");
1086
+ }
1080
1087
  function formatIssueView(bundle) {
1081
1088
  const issue = bundle.issue;
1082
1089
  const attributes = formatRecord({
@@ -1111,6 +1118,9 @@ function addIssueToRoadmapTask(roadmapJson, taskId, key, now) {
1111
1118
  function issueUrl(baseUrl, projectId, number) {
1112
1119
  return `${baseUrl.replace(/\/+$/, "")}/projects/${encodeURIComponent(projectId)}/issues/${number}`;
1113
1120
  }
1121
+ function draftUrl(baseUrl, projectId, id) {
1122
+ return `${baseUrl.replace(/\/+$/, "")}/projects/${encodeURIComponent(projectId)}/issues/drafts/${id}`;
1123
+ }
1114
1124
 
1115
1125
  // src/commands/issue.ts
1116
1126
  var emptySettings = { types: [], statuses: [], categories: [] };
@@ -1220,7 +1230,7 @@ function writeOptions(command, create) {
1220
1230
  if (create) command.requiredOption("--subject <text>", "Issue subject");
1221
1231
  else command.option("--subject <text>", "Issue subject");
1222
1232
  command.option("--body <text>", "Issue body").option("--body-file <path>", "Read body from file (- for stdin)").option("--type <name-or-id>", "Issue type").option("--status <name-or-id>", "Issue status").option("--priority <priority>", "high, normal or low").option("--assignee <assignee>", "me, none or UUID").option("--due <YYYY-MM-DD>", "Due date").option("--category <names...>", "Category names or UUIDs").option("--parent <ref>", "Parent issue key or number");
1223
- if (create) command.option("--phase <task-id>", "Attach the created key to a local roadmap task").option("--roadmap <slug>", "Roadmap filename slug (with --phase)");
1233
+ if (create) command.option("--draft", "Create a draft visible only to you instead of an issue").option("--phase <task-id>", "Attach the created key to a local roadmap task").option("--roadmap <slug>", "Roadmap filename slug (with --phase)");
1224
1234
  else command.option("--no-due", "Clear due date").option("--no-parent", "Clear parent").option("-m, --comment <text>", "Comment in the same update");
1225
1235
  return command;
1226
1236
  }
@@ -1229,6 +1239,10 @@ function register(program, deps) {
1229
1239
  All commands accept global \`--project <id>\`, \`--json\`, \`--token <value>\` and \`--base-url <url>\`.
1230
1240
  Project priority: flag \u2192 NOLTO_PROJECT \u2192 nearest ancestor nolto.json \u2192 config defaultProjectId. Git is not required. An invalid nolto.json remains an error.
1231
1241
 
1242
+ nolto issue create --draft --subject "\u2026"
1243
+ nolto issue drafts
1244
+ nolto issue publish <draft-id>
1245
+
1232
1246
  | Exit | Meaning |
1233
1247
  |---|---|
1234
1248
  | 0 | Success |
@@ -1251,12 +1265,31 @@ Project priority: flag \u2192 NOLTO_PROJECT \u2192 nearest ancestor nolto.json \
1251
1265
  });
1252
1266
  writeOptions(group.command("create").description("Create an issue."), true).action(async (flags, command) => {
1253
1267
  const ctx = context(deps, command);
1268
+ if (flags.draft && (flags.phase !== void 0 || flags.roadmap !== void 0)) throw new CliError("--phase and --roadmap cannot be used with --draft. Publish the draft first.", 2);
1254
1269
  if (flags.roadmap !== void 0 && flags.phase === void 0) throw new CliError("--roadmap requires --phase.", 2);
1255
1270
  const { input, fromTemplate } = await writeInput(deps, ctx.root, flags, true);
1271
+ if (flags.draft) {
1272
+ const result2 = await deps.http.post(`${ctx.root}/issue-drafts`, input);
1273
+ printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created
1274
+ ${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}`, ctx.mode);
1275
+ return;
1276
+ }
1256
1277
  const result = await deps.http.post(`${ctx.root}/issues`, input);
1257
1278
  const roadmap = flags.phase === void 0 ? void 0 : await attachRoadmap(deps, flags.phase, flags.roadmap, result.issue.key);
1258
1279
  printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created
1259
1280
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}`, ctx.mode);
1281
+ });
1282
+ group.command("drafts").description("List your issue drafts (visible only to you).").action(async (_flags, command) => {
1283
+ const ctx = context(deps, command);
1284
+ const result = await deps.http.get(`${ctx.root}/issue-drafts`);
1285
+ printResult(ctx.mode === "json" ? result : formatDraftList(result), ctx.mode);
1286
+ });
1287
+ group.command("publish <draft-id>").description("Publish a draft as an issue.").action(async (id, _flags, command) => {
1288
+ const ctx = context(deps, command);
1289
+ if (!isUuid(id)) throw new CliError("<draft-id> must be a UUID. Run `nolto issue drafts` to list drafts.", 2);
1290
+ const result = await deps.http.post(`${ctx.root}/issue-drafts/${id}/publish`, void 0);
1291
+ printResult(ctx.mode === "json" ? result : `${result.issue.key} published
1292
+ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}`, ctx.mode);
1260
1293
  });
1261
1294
  writeOptions(group.command("update <ref>").description("Update issue fields."), false).action(async (ref, flags, command) => {
1262
1295
  const ctx = context(deps, command);
@@ -1662,9 +1695,12 @@ async function mergedMemoryBranches(branches, context3, root, git, mine = /* @__
1662
1695
  }
1663
1696
 
1664
1697
  // src/memory-import.ts
1665
- function aiHeading(response) {
1698
+ function aiHeading(response, requestedName) {
1666
1699
  const { entry, ai } = response;
1667
1700
  if (!ai || ai.action !== "merge" && ai.action !== "replace") return null;
1701
+ if (requestedName !== void 0 && requestedName !== entry.name) {
1702
+ return `\u65B0\u898F\u306E ${requestedName} \u306F\u4F5C\u3089\u305A\u3001AI \u304C ${entry.scope}/${entry.name} ${ai.action === "merge" ? "\u306B\u7D71\u5408\u3057\u307E\u3057\u305F" : "\u306E\u77DB\u76FE\u3092\u89E3\u6D88\u3057\u307E\u3057\u305F"} (r${entry.revision}) \u2014 ${oneLine(ai.reason ?? "")}`;
1703
+ }
1668
1704
  return `AI \u304C\u6574\u7406: ${entry.scope}/${entry.name} ${ai.action === "merge" ? "\u306B\u7D71\u5408" : "\u306E\u77DB\u76FE\u3092\u89E3\u6D88"} (r${entry.revision}) \u2014 ${oneLine(ai.reason ?? "")}`;
1669
1705
  }
1670
1706
  async function createMemoryContext(opts, recover = false) {
@@ -5069,13 +5105,15 @@ async function apiCall(deps, ctx, call, op = "read", name = "<name>") {
5069
5105
  throw new CliError(error.message, error.exitCode, hint, error.status, code, body, detail);
5070
5106
  }
5071
5107
  }
5072
- function printWrite(deps, ctx, action, response, isNew = false) {
5108
+ function printWrite(deps, ctx, action, response, isNew = false, put) {
5073
5109
  if (deps.output.mode === "json") {
5074
5110
  printResult(response, "json");
5075
5111
  return;
5076
5112
  }
5077
5113
  const { entry } = response;
5078
- const lines = [aiHeading(response) ?? `${action} ${entry.scope}/${entry.name} r${entry.revision}${isNew ? " (\u65B0\u898F)" : ""}`];
5114
+ const heading = aiHeading(response, put?.name);
5115
+ const lines = [heading ?? `${action} ${entry.scope}/${entry.name} r${entry.revision}${isNew ? " (\u65B0\u898F)" : ""}`];
5116
+ if (heading && put && put.name !== entry.name && !put.allowNew) lines.push(`\u65B0\u898F\u306B\u4F5C\u308B\u306A\u3089: nolto memory put --new ${shellArg(put.file)}`);
5079
5117
  if (response.aiSkipped) lines.push(aiSkippedLine(response.aiSkipped));
5080
5118
  const affected = response.affected ?? [];
5081
5119
  for (const a of affected) lines.push(`- ${a.scope}/${a.name} r${a.fromRevision} \u2192 ${a.deleted ? `\u524A\u9664 (r${a.toRevision})` : `r${a.toRevision}`}`);
@@ -5194,7 +5232,7 @@ function register13(program, deps) {
5194
5232
  ...scope === "branch" ? { repoIdentity: ctx.git.repoIdentity, branch: ctx.git.branch } : {}
5195
5233
  }, headers()), "put", draft.name);
5196
5234
  await updateCache(ctx, deps, writtenEntries(ctx, response));
5197
- printWrite(deps, ctx, "put", response, draft.revision === void 0);
5235
+ printWrite(deps, ctx, "put", response, draft.revision === void 0, { name: draft.name, file, allowNew: opts.new });
5198
5236
  });
5199
5237
  memory.command("rm <name>").option("--scope <scope>").option("--branch <branch>", "branch entry of the current repo").action(async (name, opts) => {
5200
5238
  const ctx = await context2(deps);
@@ -58,10 +58,10 @@ Use this reference when creating or structurally editing the cache JSON returned
58
58
  - `summary`: One or two current sentences; do not use as a changelog.
59
59
  - `phases`: Ordered delivery phases.
60
60
  - `phase.status`: `todo`, `in-progress`, `done`, or `blocked`.
61
- - `phase.plan`: Optional repository-relative path (`/`-separated) to a Markdown plan document, for example `docs/plans/auth.md`. Absolute paths, backslashes, and `.`/`..` segments are rejected.
61
+ - `phase.plan`: Optional repository-relative path (`/`-separated) to a Markdown plan document, for example `docs/plans/auth.md`. Absolute paths, backslashes, and `.`/`..` segments are rejected. Attach a shared plan spanning multiple tasks once here, rather than repeating its path on tasks.
62
62
  - `tasks`: Ordered work items. Each must be small enough to verify clearly.
63
63
  - `task.status`: `todo`, `in-progress`, `done`, or `blocked`.
64
- - `task.plan`: Optional repository-relative path (`/`-separated) to a Markdown plan document, for example `docs/plans/auth.md`. Absolute paths, backslashes, and `.`/`..` segments are rejected.
64
+ - `task.plan`: Optional repository-relative path (`/`-separated) to a Markdown plan document, for example `docs/plans/auth.md`. Absolute paths, backslashes, and `.`/`..` segments are rejected. Attach only a task-specific implementation plan; do not repeat the phase plan path. When omitted, the UI shows the phase plan.
65
65
  - `startedAt`: Set by the server for `in-progress` tasks; do not edit manually. Uses the same RFC 3339 date-time format as `updatedAt`.
66
66
  - `completedAt`: Set by the server for `done` tasks; do not edit manually. Uses the same RFC 3339 date-time format as `updatedAt`.
67
67
  - `note`: Current implementation detail or blocker. Omit when it adds no value.
@@ -17,7 +17,7 @@ Use `nolto roadmap --help` and `nolto roadmap <cmd> --help` for commands and opt
17
17
  - Block: run `nolto roadmap block <task-id> [--slug slug] --note text`; describe the blocker and what will unblock it.
18
18
  - Replan: read `nolto roadmap schema` before structural changes. Edit the JSON from `path`, preserve IDs, then run `nolto roadmap validate [slug]` and `nolto roadmap sync [slug]`.
19
19
  On 409, save unsynced edits, `nolto roadmap pull [slug]`, review and reapply changes. Use `--force` only after saving needed edits.
20
- - Plan / summary: use `nolto roadmap plan <task-id> [--slug slug] --path <repo-relative-md>` and `nolto roadmap summary [slug] --text text`; do not edit state, notes, plan links, or summary directly.
20
+ - Plan / summary: use `nolto roadmap plan <task-id> [--slug slug] --path <repo-relative-md>` and `nolto roadmap summary [slug] --text text`; do not edit state, notes, plan links, or summary directly. Attach shared plans once to the phase; task plans are for task-specific implementation plans and must not repeat the phase path. Tasks without a plan show the phase plan in the UI.
21
21
 
22
22
  ## Issues
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",