@nolto/cli 0.22.0 → 0.22.1

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 +3 -3
  2. package/dist/index.js +200 -170
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -248,14 +248,14 @@ References accept a key (NOLTO-12) or number (12). Only the number is sent. With
248
248
 
249
249
  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.
250
250
 
251
- List output is one line per issue plus `n / total (page p)`. View includes body and comments with API-token provenance. Writes print the issue key and URL. `--json` preserves API responses: list `{ issues, total, page, pageSize }`, view the full bundle, create `{ issue }`, update/close `{ issue, comment }`, comment `{ comment }`. Successful create with phase additionally returns `roadmap: { file, taskId }`. Human template creation adds `body: from template`. `whoami` adds scopes (null displayed as full) and project binding; JSON uses tokenScopes/tokenProject when introspection succeeds. Introspection failure is non-fatal and retains the old output.
251
+ List output is one line per issue plus `n / total (page p)`. View includes body and comments with API-token provenance. Writes print the issue key and URL. `--json` preserves API responses: list `{ issues, total, page, pageSize }`, view the full bundle, create `{ issue }`, update/close `{ issue, comment }`, comment `{ comment }`. Successful create with phase additionally returns `roadmap: { file, taskId }`. Human template creation adds `body: from template`. Successful issue create (including `--draft`), update, comment, publish and close append API warnings as `注意: <message>` lines. JSON keeps the response `warnings` unchanged. `whoami` adds scopes (null displayed as full) and project binding; JSON uses tokenScopes/tokenProject when introspection succeeds. Introspection failure is non-fatal and retains the old output.
252
252
 
253
253
  `--phase` refers to a **task ID**, not a phase ID. After creation it adds the issue key to task.issues in the cached roadmap (`nolto roadmap path`), avoids duplicates, keeps schemaVersion and updatedAt unchanged, and runs `nolto roadmap sync` for that slug. If the key is already attached, nothing is written or synced. If multiple roadmaps are cached, use `--roadmap <slug>`. A failure after issue creation (missing task, roadmap selection, or sync) exits 2 and the error includes the created key; add it to task.issues in the cache and run `nolto roadmap sync` instead of repeating create.
254
254
 
255
255
  | Exit | Meaning |
256
256
  |---|---|
257
257
  | 0 | Success |
258
- | 2 | Invalid input, recognized API 404, HTTP 422 (details shown), internal_references (confirmation required), or roadmap cache/sync failure after creation |
258
+ | 2 | Invalid input, recognized API 404, HTTP 422 (details shown), secret_detected (possible secret; message shown), internal_references (confirmation required), or roadmap cache/sync failure after creation |
259
259
  | 3 | HTTP 401/403; token_scope/token_project includes a token settings hint |
260
260
  | 4 | Plan / quota limit (HTTP 402) or rate limit (HTTP 429); resolve or wait before retrying. Token writes: 60/minute; wait Retry-After seconds before retrying. |
261
261
  | 5 | Network/generic HTTP errors, including a 404 without an API error string |
@@ -333,7 +333,7 @@ Errors are written to stderr:
333
333
 
334
334
  ## Exit Codes
335
335
 
336
- Issue validation and API 404 with an error string exit 2; 422 includes details. Token scope/project denial exits 3 with a token-settings URL and whoami hint. A create/phase failure explicitly reports the already-created key.
336
+ Issue validation and API 404 with an error string exit 2; 422 includes details. `secret_detected` exits 2 and displays the server message (possible secret; message shown), without a details line. JSON errors also include `code` and `findings` (field/rule/line only). Token scope/project denial exits 3 with a token-settings URL and whoami hint. A create/phase failure explicitly reports the already-created key.
337
337
 
338
338
  | Code | Meaning |
339
339
  |---|---|
package/dist/index.js CHANGED
@@ -117,6 +117,9 @@ function mapHttpStatusToCliError(status, opts = {}) {
117
117
  if (status === 404 && opts.serverError) {
118
118
  return new CliError(opts.serverError, 2, void 0, status, opts.serverError, opts.body);
119
119
  }
120
+ if (status === 422 && opts.serverError === "secret_detected") {
121
+ return new CliError(opts.serverMessage ?? opts.serverError, 2, void 0, status, opts.serverError, opts.body);
122
+ }
120
123
  if (status === 422) {
121
124
  const details = Array.isArray(opts.details) ? opts.details.map((detail) => typeof detail === "string" ? detail : JSON.stringify(detail)).join("\n") : "";
122
125
  return new CliError([opts.serverError ?? opts.serverMessage ?? "Validation failed", details].filter(Boolean).join("\n"), 2, void 0, status, opts.serverError, opts.body);
@@ -686,6 +689,133 @@ function createHttpClient(opts) {
686
689
  // src/program.ts
687
690
  import { Command } from "commander";
688
691
 
692
+ // src/memory-format.ts
693
+ var oneLine = (value) => value.replace(new RegExp("\\p{Cs}", "gu"), "\uFFFD").replace(/[\x00-\x1f\x7f-\x9f\u2028\u2029]/gu, " ").replace(new RegExp("(?![\\u200c\\u200d])\\p{Cf}|[\\u{e0100}-\\u{e01ef}\\u3164\\u115f\\u1160\\uffa0]", "gu"), "");
694
+ var commandArg = (value, placeholder) => {
695
+ const safe = oneLine(value);
696
+ return /^[A-Za-z0-9._/][A-Za-z0-9._/-]*$/.test(safe) ? safe : placeholder;
697
+ };
698
+ var shellArg = (value) => {
699
+ const safe = oneLine(value);
700
+ return /^[A-Za-z0-9._/][A-Za-z0-9._/-]*$/.test(safe) ? safe : "'" + safe.replace(/'/g, "'\\''") + "'";
701
+ };
702
+ var memoryClient = (via) => via?.client || via?.tokenName || "Web";
703
+ function parseMemory(text, importing = false) {
704
+ const lines = text.replace(/\r\n/g, "\n").split("\n");
705
+ if (/^<!--.*-->$/.test(lines[0] ?? "")) lines.shift();
706
+ if (lines.shift() !== "---") throw new CliError("frontmatter \u306E --- \u304C\u3042\u308A\u307E\u305B\u3093\u3002", 2);
707
+ const end = lines.indexOf("---");
708
+ if (end < 0) throw new CliError("frontmatter \u3092 --- \u3067\u9589\u3058\u3066\u304F\u3060\u3055\u3044\u3002", 2);
709
+ const fields = {};
710
+ let metadata = false;
711
+ for (const line2 of lines.slice(0, end)) {
712
+ const match = /^(\s*)([a-zA-Z]+):\s*(.*)$/.exec(line2);
713
+ if (!match) continue;
714
+ const indent = match[1], key = match[2], raw = match[3];
715
+ if (!indent) metadata = key === "metadata";
716
+ if (indent && !(importing && metadata && key === "type")) continue;
717
+ if (importing && ["expires", "ttl", "until"].includes(key)) continue;
718
+ let value = raw.trim();
719
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
720
+ if (["name", "description", "type", "scope", "branch", "revision", "expires", "ttl", "until"].includes(key)) fields[key] = value;
721
+ }
722
+ const body = lines.slice(end + 1);
723
+ if (body[0] === "") body.shift();
724
+ return { ...fields, name: fields.name ?? "", description: fields.description ?? "", body: body.join("\n") };
725
+ }
726
+ function cleanupReason(reason) {
727
+ let text;
728
+ switch (reason.code) {
729
+ case "expired":
730
+ text = `\u671F\u9650\u5207\u308C(${reason.expiresOn ?? ""} \u307E\u3067)`;
731
+ break;
732
+ case "issue_closed":
733
+ text = `${reason.until ?? ""} \u304C\u5B8C\u4E86`;
734
+ break;
735
+ case "task_done":
736
+ text = `task ${reason.until ?? ""} \u304C\u5B8C\u4E86`;
737
+ break;
738
+ case "ref_missing":
739
+ text = `${reason.until ?? ""} \u304C\u898B\u3064\u304B\u3089\u306A\u3044`;
740
+ break;
741
+ case "superseded":
742
+ text = `\u65B0\u3057\u3044\u518D\u958B\u30DD\u30A4\u30F3\u30C8\u3042\u308A(${reason.newer ?? ""})`;
743
+ break;
744
+ default:
745
+ text = reason.code;
746
+ }
747
+ const chars = Array.from(oneLine(text));
748
+ return chars.length > 200 ? chars.slice(0, 199).join("") + "\u2026" : chars.join("");
749
+ }
750
+ function ttlExpires(ttl, today) {
751
+ const date = new Date(today.getTime());
752
+ date.setDate(date.getDate() + Number(ttl.slice(0, -1)));
753
+ return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
754
+ }
755
+ function formatMemory(entry, cleanup, scoped = false) {
756
+ const value = (s) => {
757
+ const safe = oneLine(s);
758
+ return /^['"]|['"]$|^\s|\s$/.test(safe) ? `"${safe}"` : safe;
759
+ };
760
+ return [
761
+ `<!-- ${cleanup ? `\u6574\u7406\u5019\u88DC: ${cleanupReason(cleanup)}\u3002\u6D88\u3059\u306A\u3089 nolto memory rm ${commandArg(entry.name, "<name>")}${scoped && ["project", "user", "branch"].includes(entry.scope) ? ` --scope ${entry.scope}` : ""}\u3002` : ""}nolto memory \u306E\u30AD\u30E3\u30C3\u30B7\u30E5\u3002\u7DE8\u96C6\u3057\u306A\u3044\u3002\u5909\u66F4\u306F\u4E0B\u66F8\u304D\u306B\u30B3\u30D4\u30FC\u3057\u3066 nolto memory put -->`,
762
+ "---",
763
+ `name: ${oneLine(entry.name)}`,
764
+ `description: ${value(entry.description)}`,
765
+ ...entry.type == null ? [] : [`type: ${entry.type}`],
766
+ `scope: ${entry.scope}`,
767
+ ...entry.scope === "branch" ? [`branch: ${value(entry.branch ?? "")}`] : [],
768
+ ...entry.expiresOn ? [`expires: ${value(entry.expiresOn)}`] : [],
769
+ ...entry.until ? [`until: ${value(entry.until)}`] : [],
770
+ `revision: ${entry.revision}`,
771
+ `updated: ${oneLine(entry.updatedAt)}${entry.updatedBy?.name ? ` by ${oneLine(entry.updatedBy.name)}` : ""} (${oneLine(memoryClient(entry.updatedVia))})`,
772
+ "---",
773
+ "",
774
+ entry.body
775
+ ].join("\n");
776
+ }
777
+ function parseScope(scope, hint = "scope: project|user|branch \u3092 frontmatter \u306B\u66F8\u304F") {
778
+ if (scope !== "project" && scope !== "user" && scope !== "branch") {
779
+ throw new CliError(scope ? `scope \u304C\u4E0D\u6B63\u3067\u3059: ${scope}` : "scope \u304C\u5FC5\u8981\u3067\u3059\u3002", 2, hint);
780
+ }
781
+ return scope;
782
+ }
783
+ var count = (n) => n.toLocaleString("en-US");
784
+ var invalidInput = (message, hint) => new CliError(message, 2, hint, void 0, "invalid_input");
785
+ function validateDraft(draft) {
786
+ if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(draft.name)) {
787
+ throw invalidInput(draft.name ? `name \u306E\u5F62\u304C\u4E0D\u6B63\u3067\u3059(${oneLine(draft.name)})\u3002` : "name \u304C\u3042\u308A\u307E\u305B\u3093\u3002", "name \u306F\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3\u3067 64 \u5B57\u307E\u3067\u3001\u5148\u982D\u306F\u82F1\u6570\u5B57");
788
+ }
789
+ const description = draft.description.trim();
790
+ if (/[\r\n\u0085\u2028\u2029]/.test(draft.description)) throw invalidInput("description \u306B\u6539\u884C\u304C\u3042\u308A\u307E\u3059\u3002", "description \u306F 1 \u884C\u306B\u3059\u308B");
791
+ if (!description) throw invalidInput("description \u304C\u3042\u308A\u307E\u305B\u3093\u3002", "\u7D22\u5F15\u3067\u8AAD\u3080\u304B\u3069\u3046\u304B\u3092\u6C7A\u3081\u3089\u308C\u308B 1 \u884C\u3092\u66F8\u304F");
792
+ if (description.length > 200) throw invalidInput(`description \u304C 200 \u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059(${count(description.length)} \u5B57)\u3002`, "\u7D22\u5F15\u3067\u8AAD\u3080\u304B\u3069\u3046\u304B\u3092\u6C7A\u3081\u3089\u308C\u308B 1 \u884C\u306B\u7E2E\u3081\u308B");
793
+ if (draft.body.length > 1e4) throw invalidInput(`\u672C\u6587\u304C 10,000 \u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059(${count(draft.body.length)} \u5B57)\u3002`, "\u30A8\u30F3\u30C8\u30EA\u3092\u5206\u3051\u308B\u304B\u3001\u8981\u70B9\u306B\u7D5E\u308B");
794
+ if (draft.type && !["user", "feedback", "project", "reference"].includes(draft.type)) {
795
+ throw invalidInput(`type \u304C\u4E0D\u6B63\u3067\u3059(${oneLine(draft.type)})\u3002`, "type \u306F user / feedback / project / reference \u306E\u3069\u308C\u304B\u3002\u4E0D\u8981\u306A\u3089\u884C\u3054\u3068\u6D88\u3059");
796
+ }
797
+ if (draft.expires !== void 0 && draft.ttl !== void 0) throw invalidInput("expires \u3068 ttl \u306F\u4E21\u65B9\u66F8\u3051\u307E\u305B\u3093\u3002", "expires \u304B ttl \u306E\u3069\u3061\u3089\u304B\u3092\u66F8\u304F");
798
+ if (draft.expires !== void 0) {
799
+ const parsed = /* @__PURE__ */ new Date(`${draft.expires}T00:00:00Z`);
800
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(draft.expires) || !Number.isFinite(parsed.getTime()) || parsed.toISOString().slice(0, 10) !== draft.expires) throw invalidInput("expires \u304C\u4E0D\u6B63\u3067\u3059\u3002", "expires \u306F YYYY-MM-DD \u306E\u5B9F\u5728\u3059\u308B\u65E5\u4ED8\u3067\u66F8\u304F");
801
+ }
802
+ if (draft.ttl !== void 0 && (!/^([1-9][0-9]{0,2})d$/.test(draft.ttl) || Number(draft.ttl.slice(0, -1)) > 365)) throw invalidInput("ttl \u304C\u4E0D\u6B63\u3067\u3059\u3002", "ttl \u306F 7d \u306E\u3088\u3046\u306B\u65E5\u6570\u3067\u66F8\u304F(1\u301C365)");
803
+ if (draft.until !== void 0 && draft.until.length > 200) throw invalidInput("until \u304C 200 \u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002", "until \u306F 200 \u5B57\u307E\u3067");
804
+ }
805
+ function parseRevision(value) {
806
+ const revision = Number(value);
807
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(revision) || revision < 1) throw new CliError("revision \u306F\u6B63\u306E\u6574\u6570\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002", 2);
808
+ return revision;
809
+ }
810
+ function detectMemoryClient(env) {
811
+ const agent = env.NOLTO_AGENT?.trim();
812
+ if (agent && /^[\x20-\x7e]+$/.test(agent)) return agent;
813
+ if (env.CLAUDECODE === "1") return "Claude Code";
814
+ if (env.GEMINI_CLI === "1") return "Gemini CLI";
815
+ if (env.CODEX_THREAD_ID) return "Codex";
816
+ return "CLI";
817
+ }
818
+
689
819
  // src/commands/issue.ts
690
820
  import { readFile as readFile10 } from "fs/promises";
691
821
 
@@ -708,6 +838,12 @@ function printError(err, mode2) {
708
838
  ...err.body?.["candidates"] ? { candidates: err.body["candidates"] } : {},
709
839
  ...err.body?.["conflicts"] ? { conflicts: err.body["conflicts"] } : {},
710
840
  ...err.body && "aiSkipped" in err.body ? { aiSkipped: err.body["aiSkipped"] } : {},
841
+ ...Array.isArray(err.body?.["findings"]) ? { findings: err.body["findings"].flatMap((item) => {
842
+ if (!item || typeof item !== "object") return [];
843
+ const { field, rule, line: line2 } = item;
844
+ if (typeof field !== "string" || typeof rule !== "string") return [];
845
+ return [{ field, rule, ...typeof line2 === "number" ? { line: line2 } : {} }];
846
+ }) } : {},
711
847
  ...err.body && "references" in err.body ? { references: err.body["references"] } : {},
712
848
  ...err.body && "total" in err.body ? { total: err.body["total"] } : {},
713
849
  exitCode: err.exitCode,
@@ -1145,12 +1281,13 @@ var personLabel = (person) => person?.name ?? person?.email ?? "\u2014";
1145
1281
  var singleLine = (value) => (value ?? "").replace(/[\r\n\t\u2028\u2029]/g, " ");
1146
1282
  var stripControl = (value, multiline = false) => multiline ? (value ?? "").replace(new RegExp("\\p{Cc}", "gu"), (c) => c === "\n" || c === " " ? c : "") : singleLine(value).replace(new RegExp("\\p{Cc}", "gu"), "");
1147
1283
  var stripFormatControl = (value) => value.replace(new RegExp("\\p{Cf}", "gu"), (c) => c === "\u200C" || c === "\u200D" ? c : "");
1284
+ var stripTerminal = (value) => stripFormatControl(stripControl(value));
1148
1285
  function formatInternalReferences(body) {
1149
1286
  const references = Array.isArray(body.references) ? body.references : [];
1150
1287
  const rows = [];
1151
1288
  for (const ref of references) {
1152
1289
  if (!ref || typeof ref !== "object" || Array.isArray(ref) || typeof ref.label !== "string") continue;
1153
- const label = Array.from(stripFormatControl(stripControl(ref.label)));
1290
+ const label = Array.from(stripTerminal(ref.label));
1154
1291
  rows.push(`- ${label.length > 200 ? `${label.slice(0, 199).join("")}\u2026` : label.join("")}`);
1155
1292
  }
1156
1293
  const total = typeof body.total === "number" && Number.isSafeInteger(body.total) && body.total >= 0 ? body.total : references.length;
@@ -1333,7 +1470,7 @@ async function runSync(args, deps) {
1333
1470
  deps
1334
1471
  });
1335
1472
  const response = await deps.http.put(
1336
- `/api/projects/${args.projectId}/roadmaps/${args.slug}`,
1473
+ `/api/projects/${args.projectId}/roadmaps/${encodeURIComponent(args.slug)}`,
1337
1474
  { ...body, baseRevision: args.baseRevision }
1338
1475
  );
1339
1476
  for (const warning of response.warnings ?? []) deps.warn(warning);
@@ -1351,8 +1488,14 @@ function cacheDir(env, projectId) {
1351
1488
  if (!UUID_RE.test(projectId)) throw new CliError(`Invalid project id "${projectId}".`, 2);
1352
1489
  return path6.join(getConfigDir(env), "projects", projectId, "roadmaps");
1353
1490
  }
1491
+ function isCacheableSlug(slug) {
1492
+ return ROADMAP_SLUG_PATTERN.test(slug) && !slug.endsWith(".meta");
1493
+ }
1494
+ function assertCacheableSlug(slug) {
1495
+ if (!isCacheableSlug(slug)) throw new CliError(`Invalid roadmap slug "${stripTerminal(slug)}".`, 2);
1496
+ }
1354
1497
  function cachePaths(env, projectId, slug) {
1355
- if (!ROADMAP_SLUG_PATTERN.test(slug)) throw new CliError(`Invalid roadmap slug "${slug}".`, 2);
1498
+ assertCacheableSlug(slug);
1356
1499
  const dir = cacheDir(env, projectId);
1357
1500
  return { json: path6.join(dir, `${slug}.json`), meta: path6.join(dir, `${slug}.meta.json`) };
1358
1501
  }
@@ -1428,7 +1571,7 @@ import path7 from "path";
1428
1571
 
1429
1572
  // src/roadmap-scaffold.ts
1430
1573
  function slugifyProjectId(name) {
1431
- const slug = name.toLowerCase().replace(/[^a-z0-9.-]+/g, "-").replace(/^[^a-z0-9]+/, "").replace(/[-_.]+$/, "");
1574
+ const slug = name.toLowerCase().replace(/[^a-z0-9.-]+/g, "-").replace(/^[^a-z0-9]+/, "").replace(/[-_.]+$/, "").replace(/\.meta$/, "-meta");
1432
1575
  return slug.length > 0 ? slug : "project";
1433
1576
  }
1434
1577
  function buildScaffold(projectName, repoBasename) {
@@ -1441,12 +1584,14 @@ function buildScaffold(projectName, repoBasename) {
1441
1584
  }
1442
1585
 
1443
1586
  // src/roadmap-bootstrap.ts
1587
+ var uncacheableSlugWarning = (slug) => `Warning: skipped roadmap "${stripTerminal(slug)}" \u2014 its slug cannot be cached locally.`;
1444
1588
  async function pullRoadmapCache(args) {
1445
1589
  const { env, projectId, slug } = args;
1590
+ assertCacheableSlug(slug);
1446
1591
  const response = await args.http.get(`/api/projects/${projectId}/roadmaps/${encodeURIComponent(slug)}`);
1447
1592
  const validation = validateRoadmap(response.roadmap);
1448
1593
  if (validation.errors.length > 0) {
1449
- throw new CliError(`Server roadmap "${slug}" failed validation: ${validation.errors.join("; ")}`, 5);
1594
+ throw new CliError(`Server roadmap "${slug}" failed validation: ${stripTerminal(validation.errors.join("; "))}`, 5);
1450
1595
  }
1451
1596
  let existing;
1452
1597
  try {
@@ -1471,38 +1616,40 @@ async function pullRoadmapCache(args) {
1471
1616
  }
1472
1617
  async function ensureRoadmapCache(args) {
1473
1618
  const { env, projectId } = args;
1474
- if (args.slug?.endsWith(".meta")) throw new CliError(`Roadmap slug cannot end with ".meta".`, 2);
1619
+ const basename = path7.basename(args.repoRoot);
1620
+ const slug = args.slug ?? slugifyProjectId(basename);
1621
+ assertCacheableSlug(slug);
1475
1622
  const identity = repoIdentityToString(args.repoIdentity);
1476
1623
  const list = await args.http.get(`/api/projects/${projectId}/roadmaps`);
1477
1624
  const warn2 = (line2) => {
1478
1625
  process.stderr.write(line2 + "\n");
1479
1626
  };
1480
1627
  const log = (line2) => args.log(`roadmap: ${line2}`);
1481
- const mine = list.roadmaps.filter((row) => row.repoIdentity == null || row.repoIdentity === identity);
1482
- if (list.roadmaps.length > 0) {
1628
+ const roadmaps = list.roadmaps.filter((row) => {
1629
+ if (isCacheableSlug(row.slug)) return true;
1630
+ warn2(uncacheableSlugWarning(row.slug));
1631
+ return false;
1632
+ });
1633
+ const mine = roadmaps.filter((row) => row.repoIdentity == null || row.repoIdentity === identity);
1634
+ if (roadmaps.length > 0) {
1483
1635
  let skipped = false;
1484
- for (const { slug: slug2 } of list.roadmaps) {
1485
- if (!await pullRoadmapCache({ ...args, slug: slug2, warn: warn2, log, recoverInvalid: true })) skipped = true;
1636
+ for (const row of roadmaps) {
1637
+ if (!await pullRoadmapCache({ ...args, slug: row.slug, warn: warn2, log, recoverInvalid: true })) skipped = true;
1486
1638
  }
1487
1639
  if (skipped) throw new CliError("Some roadmaps have local changes that are not synced.", 4);
1488
1640
  if (args.slug === void 0 ? mine.length > 0 : mine.some((row) => row.slug === args.slug)) return;
1489
1641
  }
1490
- const basename = path7.basename(args.repoRoot);
1491
- const slug = args.slug ?? slugifyProjectId(basename);
1492
- const collision = list.roadmaps.find((row) => row.slug === slug);
1642
+ const collision = roadmaps.find((row) => row.slug === slug);
1493
1643
  if (collision) {
1494
1644
  if (args.slug === void 0) {
1495
- log(`skipped \u2014 "${slug}" is another repository's roadmap (${collision.repoIdentity ?? "unknown"}). Run \`nolto link --slug <name>\` to create one for this repository.`);
1645
+ log(`skipped \u2014 "${slug}" is another repository's roadmap (${stripTerminal(collision.repoIdentity ?? "unknown")}). Run \`nolto link --slug <name>\` to create one for this repository.`);
1496
1646
  return;
1497
1647
  }
1498
- throw new CliError(`Roadmap slug "${slug}" already exists in this project (repo: ${collision.repoIdentity ?? "unknown"}). Run \`nolto link --slug <other-slug>\` to name this repository's roadmap.`, 2);
1648
+ throw new CliError(`Roadmap slug "${slug}" already exists in this project (repo: ${stripTerminal(collision.repoIdentity ?? "unknown")}). Run \`nolto link --slug <other-slug>\` to name this repository's roadmap.`, 2);
1499
1649
  }
1500
- let existing;
1501
- try {
1502
- existing = await readCache(env, projectId, slug);
1503
- } catch (err) {
1504
- if (!(err instanceof CliError)) throw err;
1505
- existing = null;
1650
+ const existing = await readCache(env, projectId, slug);
1651
+ if (existing?.meta && (existing.meta.revision > 0 || existing.meta.repoIdentity != null && existing.meta.repoIdentity !== identity)) {
1652
+ throw new CliError(`Local cache for "${slug}" belongs to a roadmap that is no longer on the server (${cachePaths(env, projectId, slug).json}). Remove it or choose another slug with \`nolto link --slug\`.`, 2);
1506
1653
  }
1507
1654
  if (existing && isDirty(existing)) {
1508
1655
  warn2(`Warning: ${slug} has local changes that are not synced; use --force to overwrite or run nolto sync first`);
@@ -1538,7 +1685,7 @@ async function ensureProjectRepo(args) {
1538
1685
  if (repos.length === 0) return "unbound";
1539
1686
  const identity = repoIdentityToString(args.repoIdentity);
1540
1687
  if (repos.some((repo) => repo.identity === identity)) return "bound";
1541
- if (!await args.confirm(`Project is bound to ${repos.map((repo) => repo.identity).join(", ")}. Add this repository (${identity}) to the project? [Y/n] `)) return "declined";
1688
+ if (!await args.confirm(`Project is bound to ${repos.map((repo) => stripTerminal(repo.identity)).join(", ")}. Add this repository (${identity}) to the project? [Y/n] `)) return "declined";
1542
1689
  try {
1543
1690
  await args.http.post(`/api/projects/${args.projectId}/repos`, { repoIdentity: args.repoIdentity });
1544
1691
  } catch (error) {
@@ -1831,9 +1978,9 @@ async function handleRebind(deps, projectId, root, mode2, yes) {
1831
1978
  }
1832
1979
  const repoIdentity = await makeRepoIdentityResolver(deps)(root);
1833
1980
  if (mode2 !== "json") {
1834
- process.stdout.write(`Project : ${project.name} (${project.id})
1981
+ process.stdout.write(`Project : ${stripTerminal(project.name)} (${project.id})
1835
1982
  `);
1836
- process.stdout.write(`Bound to : ${project.repoIdentity ?? "not bound"}
1983
+ process.stdout.write(`Bound to : ${stripTerminal(project.repoIdentity ?? "not bound")}
1837
1984
  `);
1838
1985
  process.stdout.write(`Rebind to : ${repoIdentity.kind}:${repoIdentity.value}
1839
1986
  `);
@@ -1848,7 +1995,7 @@ async function handleRebind(deps, projectId, root, mode2, yes) {
1848
1995
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
1849
1996
  let confirmed = false;
1850
1997
  try {
1851
- const answer = await rl.question(`Rebind "${project.name}" to this repository? [y/N] `);
1998
+ const answer = await rl.question(`Rebind "${stripTerminal(project.name)}" to this repository? [y/N] `);
1852
1999
  confirmed = answer.trim().toLowerCase() === "y";
1853
2000
  } finally {
1854
2001
  rl.close();
@@ -2046,6 +2193,7 @@ function register(program, deps) {
2046
2193
  return;
2047
2194
  }
2048
2195
  const opts = cmd.opts();
2196
+ if (opts["slug"] !== void 0) assertCacheableSlug(opts["slug"]);
2049
2197
  if (opts["list"] || opts["add"] || opts["remove"] !== void 0 || opts["slug"] !== void 0) {
2050
2198
  if (projectId == null) {
2051
2199
  if (bindingError != null) throw invalidBindingError(projectBindingPath, bindingError);
@@ -2068,7 +2216,7 @@ function register(program, deps) {
2068
2216
  const { repos } = await deps.http.get(`/api/projects/${projectId}`);
2069
2217
  if (opts["list"]) {
2070
2218
  if (mode2 === "json") printResult({ repos }, mode2);
2071
- else for (const repo2 of repos) printResult(`${repo2.identity}${repo2.label ? ` (${repo2.label})` : ""} ${repo2.boundAt} ${repo2.id}`, mode2);
2219
+ else for (const repo2 of repos) printResult(`${stripTerminal(repo2.identity)}${repo2.label ? ` (${stripTerminal(repo2.label)})` : ""} ${stripTerminal(repo2.boundAt)} ${stripTerminal(repo2.id)}`, mode2);
2072
2220
  return;
2073
2221
  }
2074
2222
  const input = opts["remove"];
@@ -2080,7 +2228,7 @@ function register(program, deps) {
2080
2228
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
2081
2229
  let confirmed = false;
2082
2230
  try {
2083
- const answer = await rl.question(`Remove "${repo.identity}" from project ${projectId}? [y/N] `);
2231
+ const answer = await rl.question(`Remove "${stripTerminal(repo.identity)}" from project ${projectId}? [y/N] `);
2084
2232
  confirmed = answer.trim().toLowerCase() === "y";
2085
2233
  } finally {
2086
2234
  rl.close();
@@ -2091,7 +2239,7 @@ function register(program, deps) {
2091
2239
  }
2092
2240
  }
2093
2241
  await deps.http.delete(`/api/projects/${projectId}/repos/${repo.id}`);
2094
- printResult(mode2 === "json" ? { removed: true, projectId, repoId: repo.id } : `Removed ${repo.identity} from project ${projectId}.`, mode2);
2242
+ printResult(mode2 === "json" ? { removed: true, projectId, repoId: repo.id } : `Removed ${stripTerminal(repo.identity)} from project ${projectId}.`, mode2);
2095
2243
  return;
2096
2244
  }
2097
2245
  }
@@ -2151,13 +2299,18 @@ function register2(program, deps) {
2151
2299
  }
2152
2300
  async function runPull(deps, opts = {}) {
2153
2301
  const messages = [];
2302
+ if (opts.slug != null) assertCacheableSlug(opts.slug);
2154
2303
  const { projectId } = await resolveRoadmapReadContext(deps);
2155
2304
  const list = await deps.http.get(`/api/projects/${projectId}/roadmaps`);
2156
2305
  const serverBySlug = new Map(list.roadmaps.map((roadmap) => [roadmap.slug, roadmap]));
2157
2306
  if (opts.slug != null && !serverBySlug.has(opts.slug)) {
2158
2307
  throw new CliError(`Roadmap "${opts.slug}" was not found on the server.`, 2);
2159
2308
  }
2160
- const slugs = opts.slug == null ? [...serverBySlug.keys()] : [opts.slug];
2309
+ const slugs = opts.slug == null ? [...serverBySlug.keys()].filter((slug) => {
2310
+ if (isCacheableSlug(slug)) return true;
2311
+ process.stderr.write(uncacheableSlugWarning(slug) + "\n");
2312
+ return false;
2313
+ }) : [opts.slug];
2161
2314
  let skipped = false;
2162
2315
  for (const slug of slugs) {
2163
2316
  if (!await pullRoadmapCache({
@@ -2276,7 +2429,7 @@ async function syncRepo(args, io) {
2276
2429
  const entry = await readCache(io.env, projectId, slug);
2277
2430
  if (!entry) throw new CliError(`No cached roadmap "${slug}". Run \`nolto roadmap pull ${slug}\`.`, 2);
2278
2431
  if (args.slugs === void 0 && entry.meta?.repoIdentity != null && entry.meta.repoIdentity !== identity) {
2279
- io.log(`skipped ${slug} (belongs to ${entry.meta.repoIdentity})`);
2432
+ io.log(`skipped ${slug} (belongs to ${stripTerminal(entry.meta.repoIdentity)})`);
2280
2433
  continue;
2281
2434
  }
2282
2435
  roadmaps.push({ slug, ...entry });
@@ -2674,6 +2827,10 @@ async function checkShared(deps, root, flags, ref) {
2674
2827
  throw new CliError(`${stripControl(ref)} \u306F\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8(${stripControl(key)})\u306E\u8AB2\u984C\u30AD\u30FC\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`, 2);
2675
2828
  }
2676
2829
  }
2830
+ function warningLines(warnings) {
2831
+ return Array.isArray(warnings) ? warnings.filter((text) => typeof text === "string").map((text) => `
2832
+ \u6CE8\u610F: ${oneLine(text)}`).join("") : "";
2833
+ }
2677
2834
  function writeSuffix(flags) {
2678
2835
  if (flags.shared && flags.confirmReferences) return " (shared, references confirmed)";
2679
2836
  return flags.shared ? " (shared)" : flags.confirmReferences ? " (references confirmed)" : "";
@@ -2801,7 +2958,7 @@ nolto issue publish <draft-id>
2801
2958
  | Exit | Meaning |
2802
2959
  |---|---|
2803
2960
  | 0 | Success |
2804
- | 2 | Invalid input, recognized API 404, HTTP 422 (details shown), internal_references (confirmation required), or roadmap cache/sync failure after creation |
2961
+ | 2 | Invalid input, recognized API 404, HTTP 422 (details shown), secret_detected (possible secret; message shown), internal_references (confirmation required), or roadmap cache/sync failure after creation |
2805
2962
  | 3 | HTTP 401/403; token_scope/token_project includes a token settings hint |
2806
2963
  | 4 | HTTP 402/429 (quota/rate limit). API token writes: 60/minute. On 429, wait Retry-After seconds before retrying. |
2807
2964
  | 5 | Network/generic HTTP errors, including a 404 without an API error string |
@@ -2828,13 +2985,13 @@ nolto issue publish <draft-id>
2828
2985
  if (flags.draft) {
2829
2986
  const result2 = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts`, input);
2830
2987
  printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created${writeSuffix(flags)}
2831
- ${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}`, ctx.mode);
2988
+ ${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}${warningLines(result2.warnings)}`, ctx.mode);
2832
2989
  return;
2833
2990
  }
2834
2991
  const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues`, input);
2835
2992
  const roadmap = flags.phase === void 0 ? void 0 : await attachRoadmap(deps, flags.phase, flags.roadmap, result.issue.key);
2836
2993
  printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags)}
2837
- ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}`, ctx.mode);
2994
+ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}${warningLines(result.warnings)}`, ctx.mode);
2838
2995
  });
2839
2996
  group.command("drafts").description("List your issue drafts (visible only to you).").action(async (_flags, command) => {
2840
2997
  const ctx = context(deps, command);
@@ -2846,7 +3003,7 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemp
2846
3003
  if (!isUuid(id)) throw new CliError("<draft-id> must be a UUID. Run `nolto issue drafts` to list drafts.", 2);
2847
3004
  const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
2848
3005
  printResult(ctx.mode === "json" ? result : `${result.issue.key} published
2849
- ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}`, ctx.mode);
3006
+ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningLines(result.warnings)}`, ctx.mode);
2850
3007
  });
2851
3008
  writeOptions(group.command("update <ref>").description("Update issue fields."), false).action(async (ref, flags, command) => {
2852
3009
  const ctx = context(deps, command);
@@ -2855,7 +3012,7 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}`, ctx.mod
2855
3012
  const { input } = await writeInput(deps, ctx.root, flags, false);
2856
3013
  const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, input);
2857
3014
  printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags)}
2858
- ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}`, ctx.mode);
3015
+ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
2859
3016
  });
2860
3017
  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) => {
2861
3018
  const ctx = context(deps, command);
@@ -2866,7 +3023,7 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}`, ctx.mode);
2866
3023
  const issue = ctx.mode === "human" ? (await deps.http.get(`${ctx.root}/issues/${number}`)).issue : void 0;
2867
3024
  const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues/${number}/comments`, { body });
2868
3025
  printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags)}
2869
- ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}`, ctx.mode);
3026
+ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
2870
3027
  });
2871
3028
  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) => {
2872
3029
  const ctx = context(deps, command);
@@ -2876,7 +3033,7 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}`, ctx.mode);
2876
3033
  const status = pickClosedStatus(settings, flags.status);
2877
3034
  const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} });
2878
3035
  printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags)}
2879
- ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}`, ctx.mode);
3036
+ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
2880
3037
  });
2881
3038
  }
2882
3039
 
@@ -2884,133 +3041,6 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}`, ctx.mode);
2884
3041
  import { readFile as readFile12, readdir as readdir6, rm as rm3 } from "fs/promises";
2885
3042
  import path16 from "path";
2886
3043
 
2887
- // src/memory-format.ts
2888
- var oneLine = (value) => value.replace(new RegExp("\\p{Cs}", "gu"), "\uFFFD").replace(/[\x00-\x1f\x7f-\x9f\u2028\u2029]/gu, " ").replace(new RegExp("(?![\\u200c\\u200d])\\p{Cf}|[\\u{e0100}-\\u{e01ef}\\u3164\\u115f\\u1160\\uffa0]", "gu"), "");
2889
- var commandArg = (value, placeholder) => {
2890
- const safe = oneLine(value);
2891
- return /^[A-Za-z0-9._/][A-Za-z0-9._/-]*$/.test(safe) ? safe : placeholder;
2892
- };
2893
- var shellArg = (value) => {
2894
- const safe = oneLine(value);
2895
- return /^[A-Za-z0-9._/][A-Za-z0-9._/-]*$/.test(safe) ? safe : "'" + safe.replace(/'/g, "'\\''") + "'";
2896
- };
2897
- var memoryClient = (via) => via?.client || via?.tokenName || "Web";
2898
- function parseMemory(text, importing = false) {
2899
- const lines = text.replace(/\r\n/g, "\n").split("\n");
2900
- if (/^<!--.*-->$/.test(lines[0] ?? "")) lines.shift();
2901
- if (lines.shift() !== "---") throw new CliError("frontmatter \u306E --- \u304C\u3042\u308A\u307E\u305B\u3093\u3002", 2);
2902
- const end = lines.indexOf("---");
2903
- if (end < 0) throw new CliError("frontmatter \u3092 --- \u3067\u9589\u3058\u3066\u304F\u3060\u3055\u3044\u3002", 2);
2904
- const fields = {};
2905
- let metadata = false;
2906
- for (const line2 of lines.slice(0, end)) {
2907
- const match = /^(\s*)([a-zA-Z]+):\s*(.*)$/.exec(line2);
2908
- if (!match) continue;
2909
- const indent = match[1], key = match[2], raw = match[3];
2910
- if (!indent) metadata = key === "metadata";
2911
- if (indent && !(importing && metadata && key === "type")) continue;
2912
- if (importing && ["expires", "ttl", "until"].includes(key)) continue;
2913
- let value = raw.trim();
2914
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
2915
- if (["name", "description", "type", "scope", "branch", "revision", "expires", "ttl", "until"].includes(key)) fields[key] = value;
2916
- }
2917
- const body = lines.slice(end + 1);
2918
- if (body[0] === "") body.shift();
2919
- return { ...fields, name: fields.name ?? "", description: fields.description ?? "", body: body.join("\n") };
2920
- }
2921
- function cleanupReason(reason) {
2922
- let text;
2923
- switch (reason.code) {
2924
- case "expired":
2925
- text = `\u671F\u9650\u5207\u308C(${reason.expiresOn ?? ""} \u307E\u3067)`;
2926
- break;
2927
- case "issue_closed":
2928
- text = `${reason.until ?? ""} \u304C\u5B8C\u4E86`;
2929
- break;
2930
- case "task_done":
2931
- text = `task ${reason.until ?? ""} \u304C\u5B8C\u4E86`;
2932
- break;
2933
- case "ref_missing":
2934
- text = `${reason.until ?? ""} \u304C\u898B\u3064\u304B\u3089\u306A\u3044`;
2935
- break;
2936
- case "superseded":
2937
- text = `\u65B0\u3057\u3044\u518D\u958B\u30DD\u30A4\u30F3\u30C8\u3042\u308A(${reason.newer ?? ""})`;
2938
- break;
2939
- default:
2940
- text = reason.code;
2941
- }
2942
- const chars = Array.from(oneLine(text));
2943
- return chars.length > 200 ? chars.slice(0, 199).join("") + "\u2026" : chars.join("");
2944
- }
2945
- function ttlExpires(ttl, today) {
2946
- const date = new Date(today.getTime());
2947
- date.setDate(date.getDate() + Number(ttl.slice(0, -1)));
2948
- return `${String(date.getFullYear()).padStart(4, "0")}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
2949
- }
2950
- function formatMemory(entry, cleanup, scoped = false) {
2951
- const value = (s) => {
2952
- const safe = oneLine(s);
2953
- return /^['"]|['"]$|^\s|\s$/.test(safe) ? `"${safe}"` : safe;
2954
- };
2955
- return [
2956
- `<!-- ${cleanup ? `\u6574\u7406\u5019\u88DC: ${cleanupReason(cleanup)}\u3002\u6D88\u3059\u306A\u3089 nolto memory rm ${commandArg(entry.name, "<name>")}${scoped && ["project", "user", "branch"].includes(entry.scope) ? ` --scope ${entry.scope}` : ""}\u3002` : ""}nolto memory \u306E\u30AD\u30E3\u30C3\u30B7\u30E5\u3002\u7DE8\u96C6\u3057\u306A\u3044\u3002\u5909\u66F4\u306F\u4E0B\u66F8\u304D\u306B\u30B3\u30D4\u30FC\u3057\u3066 nolto memory put -->`,
2957
- "---",
2958
- `name: ${oneLine(entry.name)}`,
2959
- `description: ${value(entry.description)}`,
2960
- ...entry.type == null ? [] : [`type: ${entry.type}`],
2961
- `scope: ${entry.scope}`,
2962
- ...entry.scope === "branch" ? [`branch: ${value(entry.branch ?? "")}`] : [],
2963
- ...entry.expiresOn ? [`expires: ${value(entry.expiresOn)}`] : [],
2964
- ...entry.until ? [`until: ${value(entry.until)}`] : [],
2965
- `revision: ${entry.revision}`,
2966
- `updated: ${oneLine(entry.updatedAt)}${entry.updatedBy?.name ? ` by ${oneLine(entry.updatedBy.name)}` : ""} (${oneLine(memoryClient(entry.updatedVia))})`,
2967
- "---",
2968
- "",
2969
- entry.body
2970
- ].join("\n");
2971
- }
2972
- function parseScope(scope, hint = "scope: project|user|branch \u3092 frontmatter \u306B\u66F8\u304F") {
2973
- if (scope !== "project" && scope !== "user" && scope !== "branch") {
2974
- throw new CliError(scope ? `scope \u304C\u4E0D\u6B63\u3067\u3059: ${scope}` : "scope \u304C\u5FC5\u8981\u3067\u3059\u3002", 2, hint);
2975
- }
2976
- return scope;
2977
- }
2978
- var count = (n) => n.toLocaleString("en-US");
2979
- var invalidInput = (message, hint) => new CliError(message, 2, hint, void 0, "invalid_input");
2980
- function validateDraft(draft) {
2981
- if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(draft.name)) {
2982
- throw invalidInput(draft.name ? `name \u306E\u5F62\u304C\u4E0D\u6B63\u3067\u3059(${oneLine(draft.name)})\u3002` : "name \u304C\u3042\u308A\u307E\u305B\u3093\u3002", "name \u306F\u82F1\u5C0F\u6587\u5B57\u30FB\u6570\u5B57\u30FB\u30CF\u30A4\u30D5\u30F3\u3067 64 \u5B57\u307E\u3067\u3001\u5148\u982D\u306F\u82F1\u6570\u5B57");
2983
- }
2984
- const description = draft.description.trim();
2985
- if (/[\r\n\u0085\u2028\u2029]/.test(draft.description)) throw invalidInput("description \u306B\u6539\u884C\u304C\u3042\u308A\u307E\u3059\u3002", "description \u306F 1 \u884C\u306B\u3059\u308B");
2986
- if (!description) throw invalidInput("description \u304C\u3042\u308A\u307E\u305B\u3093\u3002", "\u7D22\u5F15\u3067\u8AAD\u3080\u304B\u3069\u3046\u304B\u3092\u6C7A\u3081\u3089\u308C\u308B 1 \u884C\u3092\u66F8\u304F");
2987
- if (description.length > 200) throw invalidInput(`description \u304C 200 \u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059(${count(description.length)} \u5B57)\u3002`, "\u7D22\u5F15\u3067\u8AAD\u3080\u304B\u3069\u3046\u304B\u3092\u6C7A\u3081\u3089\u308C\u308B 1 \u884C\u306B\u7E2E\u3081\u308B");
2988
- if (draft.body.length > 1e4) throw invalidInput(`\u672C\u6587\u304C 10,000 \u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059(${count(draft.body.length)} \u5B57)\u3002`, "\u30A8\u30F3\u30C8\u30EA\u3092\u5206\u3051\u308B\u304B\u3001\u8981\u70B9\u306B\u7D5E\u308B");
2989
- if (draft.type && !["user", "feedback", "project", "reference"].includes(draft.type)) {
2990
- throw invalidInput(`type \u304C\u4E0D\u6B63\u3067\u3059(${oneLine(draft.type)})\u3002`, "type \u306F user / feedback / project / reference \u306E\u3069\u308C\u304B\u3002\u4E0D\u8981\u306A\u3089\u884C\u3054\u3068\u6D88\u3059");
2991
- }
2992
- if (draft.expires !== void 0 && draft.ttl !== void 0) throw invalidInput("expires \u3068 ttl \u306F\u4E21\u65B9\u66F8\u3051\u307E\u305B\u3093\u3002", "expires \u304B ttl \u306E\u3069\u3061\u3089\u304B\u3092\u66F8\u304F");
2993
- if (draft.expires !== void 0) {
2994
- const parsed = /* @__PURE__ */ new Date(`${draft.expires}T00:00:00Z`);
2995
- if (!/^\d{4}-\d{2}-\d{2}$/.test(draft.expires) || !Number.isFinite(parsed.getTime()) || parsed.toISOString().slice(0, 10) !== draft.expires) throw invalidInput("expires \u304C\u4E0D\u6B63\u3067\u3059\u3002", "expires \u306F YYYY-MM-DD \u306E\u5B9F\u5728\u3059\u308B\u65E5\u4ED8\u3067\u66F8\u304F");
2996
- }
2997
- if (draft.ttl !== void 0 && (!/^([1-9][0-9]{0,2})d$/.test(draft.ttl) || Number(draft.ttl.slice(0, -1)) > 365)) throw invalidInput("ttl \u304C\u4E0D\u6B63\u3067\u3059\u3002", "ttl \u306F 7d \u306E\u3088\u3046\u306B\u65E5\u6570\u3067\u66F8\u304F(1\u301C365)");
2998
- if (draft.until !== void 0 && draft.until.length > 200) throw invalidInput("until \u304C 200 \u5B57\u3092\u8D85\u3048\u3066\u3044\u307E\u3059\u3002", "until \u306F 200 \u5B57\u307E\u3067");
2999
- }
3000
- function parseRevision(value) {
3001
- const revision = Number(value);
3002
- if (!/^\d+$/.test(value) || !Number.isSafeInteger(revision) || revision < 1) throw new CliError("revision \u306F\u6B63\u306E\u6574\u6570\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002", 2);
3003
- return revision;
3004
- }
3005
- function detectMemoryClient(env) {
3006
- const agent = env.NOLTO_AGENT?.trim();
3007
- if (agent && /^[\x20-\x7e]+$/.test(agent)) return agent;
3008
- if (env.CLAUDECODE === "1") return "Claude Code";
3009
- if (env.GEMINI_CLI === "1") return "Gemini CLI";
3010
- if (env.CODEX_THREAD_ID) return "Codex";
3011
- return "CLI";
3012
- }
3013
-
3014
3044
  // src/memory-cache.ts
3015
3045
  import { mkdir as mkdir7, readFile as readFile11, readdir as readdir5, rename as rename4, rm as rm2, unlink as unlink4, writeFile as writeFile8 } from "fs/promises";
3016
3046
  import { createHash as createHash3, randomUUID as randomUUID6 } from "crypto";
@@ -3413,7 +3443,7 @@ async function pickProject(rl, http, projects, promptText, baseUrl) {
3413
3443
  if (projects.length > 0) {
3414
3444
  process.stdout.write("\nProjects:\n");
3415
3445
  projects.forEach((project, index) => {
3416
- process.stdout.write(` (${index + 1}) ${project.name} \u2014 ${project.id}
3446
+ process.stdout.write(` (${index + 1}) ${stripTerminal(project.name)} \u2014 ${project.id}
3417
3447
  `);
3418
3448
  });
3419
3449
  } else {
@@ -3439,7 +3469,7 @@ async function pickProject(rl, http, projects, promptText, baseUrl) {
3439
3469
  if (orgs.length > 1) {
3440
3470
  process.stdout.write("\nOrganizations:\n");
3441
3471
  orgs.forEach((org, index2) => {
3442
- process.stdout.write(` (${index2 + 1}) ${org.name} \u2014 ${org.id}
3472
+ process.stdout.write(` (${index2 + 1}) ${stripTerminal(org.name)} \u2014 ${org.id}
3443
3473
  `);
3444
3474
  });
3445
3475
  const choice = (await rl.question("Organization number: ")).trim();
@@ -3460,7 +3490,7 @@ async function pickProject(rl, http, projects, promptText, baseUrl) {
3460
3490
  id: created.project.id,
3461
3491
  name: created.project.name ?? name.trim()
3462
3492
  };
3463
- process.stdout.write(`Created project ${project.name} [${key}] (${project.id}) in ${organization.name}
3493
+ process.stdout.write(`Created project ${stripTerminal(project.name)} [${key}] (${project.id}) in ${stripTerminal(organization.name)}
3464
3494
  `);
3465
3495
  return project;
3466
3496
  }
@@ -3474,7 +3504,7 @@ async function selectRepoProject(rl, http, projects, defaultProjectId, baseUrl)
3474
3504
  const defaultProject = defaultProjectId == null ? void 0 : projects.find((project) => project.id === defaultProjectId);
3475
3505
  if (defaultProject != null) {
3476
3506
  const useDefault = await rl.question(
3477
- `Use "${defaultProject.name}" (${defaultProject.id}) for this repository? [Y/n] `
3507
+ `Use "${stripTerminal(defaultProject.name)}" (${defaultProject.id}) for this repository? [Y/n] `
3478
3508
  );
3479
3509
  if (useDefault.trim().toLowerCase() !== "n") {
3480
3510
  return defaultProject;
@@ -3641,7 +3671,7 @@ function register5(program, deps) {
3641
3671
  baseUrl: baseUrl !== DEFAULT_BASE_URL ? baseUrl : void 0,
3642
3672
  defaultProjectId
3643
3673
  });
3644
- const projectDisplay = defaultProjectId != null ? `${defaultProjectName ?? ""} (${defaultProjectId})` : "not set";
3674
+ const projectDisplay = defaultProjectId != null ? `${stripTerminal(defaultProjectName)} (${defaultProjectId})` : "not set";
3645
3675
  process.stdout.write(`
3646
3676
  Saved ${configPath}
3647
3677
  `);
@@ -3685,7 +3715,7 @@ Saved ${configPath}
3685
3715
  );
3686
3716
  if (boundProject != null) {
3687
3717
  process.stdout.write(
3688
- `Existing binding: nolto.json \u2192 "${boundProject.name}" (${boundProject.id})
3718
+ `Existing binding: nolto.json \u2192 "${stripTerminal(boundProject.name)}" (${boundProject.id})
3689
3719
  `
3690
3720
  );
3691
3721
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",