@nolto/cli 0.22.2 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -3
  2. package/dist/index.js +97 -82
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -231,7 +231,7 @@ Git commands.
231
231
  ### Issues
232
232
 
233
233
  All commands accept global `--project <id>`, `--json`, `--token <value>` and `--base-url <url>`.
234
- Project priority: flag → NOLTO_PROJECT → nearest ancestor nolto.json → config defaultProjectId. Git is not required. An invalid nolto.json remains an error.
234
+ Project priority: flag → NOLTO_PROJECT → nearest ancestor nolto.json. Git is not required. An invalid nolto.json remains an error.
235
235
  References accept a key (NOLTO-12) or number (12). Only the number is sent. With `--shared`, a key prefix must match the selected project's key when the project has one; without `--shared`, a different prefix does not protect against acting on the same number in the selected project.
236
236
 
237
237
  | Command | Options |
@@ -281,8 +281,7 @@ A non-empty `NOLTO_HOME` selects the directory as-is; otherwise use
281
281
  ```json
282
282
  {
283
283
  "token": "nolto_user_...",
284
- "baseUrl": "https://nolto.app",
285
- "defaultProjectId": "00000000-0000-0000-0000-000000000001"
284
+ "baseUrl": "https://nolto.app"
286
285
  }
287
286
  ```
288
287
 
package/dist/index.js CHANGED
@@ -26,6 +26,13 @@ var CliError = class extends Error {
26
26
  detail;
27
27
  retryAfter;
28
28
  };
29
+ function projectRequiredError() {
30
+ return new CliError(
31
+ "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304C\u6C7A\u307E\u308A\u307E\u305B\u3093\u3002nolto.json \u306E\u3042\u308B\u30EA\u30DD\u30B8\u30C8\u30EA(\u304B\u3001\u305D\u306E\u4E0B)\u3067\u5B9F\u884C\u3059\u308B\u304B\u3001--project <id> / NOLTO_PROJECT \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
32
+ 2,
33
+ "nolto init \u307E\u305F\u306F nolto link <projectId> \u3067 nolto.json \u3092\u4F5C\u308B"
34
+ );
35
+ }
29
36
  function mapHttpStatusToCliError(status, opts = {}) {
30
37
  if (opts.serverError?.startsWith("memory_") || status === 400 && opts.serverError === "invalid_input") {
31
38
  return new CliError(opts.serverMessage ?? opts.serverError, 2, void 0, status, opts.serverError, opts.body);
@@ -416,6 +423,7 @@ var CLI_USER_AGENT_NAME = "nolto-cli";
416
423
  var configSchema = z.object({
417
424
  token: z.string().min(1).optional(),
418
425
  baseUrl: z.string().url().optional(),
426
+ // NF-165 で廃止。読まない。
419
427
  defaultProjectId: z.string().uuid().optional()
420
428
  }).strict();
421
429
  var repoBindingSchema = z.object({
@@ -551,20 +559,17 @@ async function saveConfigFile(filePath, value) {
551
559
  await writeFile3(filePath, JSON.stringify(value, null, 2) + "\n", { mode: 384 });
552
560
  }
553
561
  function resolveProjectId(args) {
554
- const { flagProject, envProject, repoBinding, fileProjectId } = args;
562
+ const { flagProject, envProject, repoBinding } = args;
555
563
  if (flagProject != null && flagProject.length > 0) {
556
- return { defaultProjectId: flagProject, projectSource: "flag" };
564
+ return { projectId: flagProject, projectSource: "flag" };
557
565
  }
558
566
  if (envProject != null && envProject.length > 0) {
559
- return { defaultProjectId: envProject, projectSource: "env" };
567
+ return { projectId: envProject, projectSource: "env" };
560
568
  }
561
569
  if (repoBinding != null && repoBinding.projectId.length > 0) {
562
- return { defaultProjectId: repoBinding.projectId, projectSource: "repo" };
570
+ return { projectId: repoBinding.projectId, projectSource: "repo" };
563
571
  }
564
- if (fileProjectId != null && fileProjectId.length > 0) {
565
- return { defaultProjectId: fileProjectId, projectSource: "file" };
566
- }
567
- return { defaultProjectId: void 0, projectSource: "none" };
572
+ return { projectId: void 0, projectSource: "none" };
568
573
  }
569
574
  function resolveSettings(args) {
570
575
  const { flags, env, file, repoBinding } = args;
@@ -594,16 +599,15 @@ function resolveSettings(args) {
594
599
  } else {
595
600
  baseUrl = DEFAULT_BASE_URL;
596
601
  }
597
- const { defaultProjectId, projectSource } = resolveProjectId({
602
+ const { projectId, projectSource } = resolveProjectId({
598
603
  flagProject: flags.project,
599
604
  envProject: env["NOLTO_PROJECT"],
600
- repoBinding,
601
- fileProjectId: file?.defaultProjectId
605
+ repoBinding
602
606
  });
603
607
  return {
604
608
  token,
605
609
  baseUrl,
606
- defaultProjectId,
610
+ projectId,
607
611
  source: { token: tokenSource, baseUrl: baseUrlSource, project: projectSource }
608
612
  };
609
613
  }
@@ -2308,13 +2312,13 @@ async function resolveRoadmapReadContext(deps) {
2308
2312
  }
2309
2313
  const startDir = resolveStartDir(process.env, process.cwd());
2310
2314
  const { root, foundGit } = findRepoRoot(startDir);
2311
- if (!foundGit) {
2312
- throw new CliError("No git repository found. Run inside a repo set up with `nolto init`.", 2);
2313
- }
2314
2315
  const binding = await loadRepoBinding(path12.join(root, "nolto.json"));
2315
- const projectId = binding?.projectId ?? deps.settings.defaultProjectId;
2316
+ const projectId = binding?.projectId ?? deps.settings.projectId;
2316
2317
  if (projectId == null) {
2317
- throw new CliError("No project binding. Run `nolto init` or `nolto link <projectId>`.", 2);
2318
+ throw projectRequiredError();
2319
+ }
2320
+ if (!foundGit) {
2321
+ throw new CliError("No git repository found. Run inside a repo set up with `nolto init`.", 2);
2318
2322
  }
2319
2323
  return { root, projectId };
2320
2324
  }
@@ -2855,6 +2859,7 @@ async function checkShared(deps, root, flags, ref) {
2855
2859
  if (ref?.includes("-") && key && ref.slice(0, ref.lastIndexOf("-")).toUpperCase() !== key.toUpperCase()) {
2856
2860
  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);
2857
2861
  }
2862
+ return context3.project?.name;
2858
2863
  }
2859
2864
  function warningLines(warnings) {
2860
2865
  return Array.isArray(warnings) ? warnings.filter((text) => typeof text === "string").map((text) => `
@@ -2902,14 +2907,25 @@ async function writeRequest(deps, mode2, flags, method, path24, body) {
2902
2907
  function context(deps, command) {
2903
2908
  if (!deps.settings.token) throw new CliError("Not authenticated. Run `nolto login` or set NOLTO_TOKEN.", 3);
2904
2909
  const globals = command.optsWithGlobals();
2905
- const projectId = globals.project ?? deps.settings.defaultProjectId;
2906
- if (!projectId) throw new CliError("No project. Pass --project <id> or run nolto link.", 2);
2910
+ const projectId = globals.project ?? deps.settings.projectId;
2911
+ if (!projectId) throw projectRequiredError();
2907
2912
  return {
2908
2913
  projectId,
2909
2914
  root: `/api/projects/${encodeURIComponent(projectId)}`,
2910
- mode: globals.json ? "json" : deps.output.mode
2915
+ mode: globals.json ? "json" : deps.output.mode,
2916
+ projectName: void 0
2911
2917
  };
2912
2918
  }
2919
+ async function projectLine(deps, ctx) {
2920
+ if (ctx.mode === "json") return "";
2921
+ let name = ctx.projectName;
2922
+ if (!name) {
2923
+ const result = await deps.http.get(ctx.root).catch(() => null);
2924
+ name = result?.project?.name;
2925
+ }
2926
+ return `
2927
+ \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: ${oneLine(name || ctx.projectId)}`;
2928
+ }
2913
2929
  async function bodyText(body, file) {
2914
2930
  if (body !== void 0 && file !== void 0) throw new CliError("Use either --body/-m or --body-file, not both.", 2);
2915
2931
  if (file === void 0) return body;
@@ -2978,7 +2994,7 @@ function writeOptions(command, create) {
2978
2994
  function register4(program, deps) {
2979
2995
  const group = program.command("issue").description("List, view and manage project issues.").addHelpText("after", `
2980
2996
  All commands accept global \`--project <id>\`, \`--json\`, \`--token <value>\` and \`--base-url <url>\`.
2981
- 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.
2997
+ Project priority: flag \u2192 NOLTO_PROJECT \u2192 nearest ancestor nolto.json. Git is not required. An invalid nolto.json remains an error.
2982
2998
 
2983
2999
  nolto issue create --draft --subject "\u2026"
2984
3000
  nolto issue drafts
@@ -3009,17 +3025,19 @@ nolto issue publish <draft-id>
3009
3025
  if (flags.draft && flags.shared) throw new CliError("--shared cannot be combined with --draft.", 2);
3010
3026
  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);
3011
3027
  if (flags.roadmap !== void 0 && flags.phase === void 0) throw new CliError("--roadmap requires --phase.", 2);
3012
- await checkShared(deps, ctx.root, flags);
3028
+ ctx.projectName = await checkShared(deps, ctx.root, flags);
3013
3029
  const { input, fromTemplate } = await writeInput(deps, ctx.root, flags, true);
3014
3030
  if (flags.draft) {
3031
+ const project2 = await projectLine(deps, ctx);
3015
3032
  const result2 = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts`, input);
3016
- printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created${writeSuffix(flags)}
3033
+ printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created${writeSuffix(flags)}${project2}
3017
3034
  ${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}${warningLines(result2.warnings)}`, ctx.mode);
3018
3035
  return;
3019
3036
  }
3037
+ const project = await projectLine(deps, ctx);
3020
3038
  const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues`, input);
3021
3039
  const roadmap = flags.phase === void 0 ? void 0 : await attachRoadmap(deps, flags.phase, flags.roadmap, result.issue.key);
3022
- printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags)}
3040
+ printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags)}${project}
3023
3041
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}${warningLines(result.warnings)}`, ctx.mode);
3024
3042
  });
3025
3043
  group.command("drafts").description("List your issue drafts (visible only to you).").action(async (_flags, command) => {
@@ -3030,38 +3048,42 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemp
3030
3048
  group.command("publish <draft-id>").description("Publish a draft as an issue.").action(async (id, flags, command) => {
3031
3049
  const ctx = context(deps, command);
3032
3050
  if (!isUuid(id)) throw new CliError("<draft-id> must be a UUID. Run `nolto issue drafts` to list drafts.", 2);
3051
+ const project = await projectLine(deps, ctx);
3033
3052
  const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
3034
- printResult(ctx.mode === "json" ? result : `${result.issue.key} published
3053
+ printResult(ctx.mode === "json" ? result : `${result.issue.key} published${project}
3035
3054
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningLines(result.warnings)}`, ctx.mode);
3036
3055
  });
3037
3056
  writeOptions(group.command("update <ref>").description("Update issue fields."), false).action(async (ref, flags, command) => {
3038
3057
  const ctx = context(deps, command);
3039
3058
  const number = parseIssueRef(ref);
3040
- await checkShared(deps, ctx.root, flags, ref);
3059
+ ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3041
3060
  const { input } = await writeInput(deps, ctx.root, flags, false);
3061
+ const project = await projectLine(deps, ctx);
3042
3062
  const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, input);
3043
- printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags)}
3063
+ printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags)}${project}
3044
3064
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3045
3065
  });
3046
3066
  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) => {
3047
3067
  const ctx = context(deps, command);
3048
3068
  const number = parseIssueRef(ref);
3049
- await checkShared(deps, ctx.root, flags, ref);
3069
+ ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3050
3070
  const body = await bodyText(flags.comment, flags.bodyFile);
3051
3071
  if (!body?.trim()) throw new CliError("A comment is required. Use -m or --body-file.", 2);
3052
3072
  const issue = ctx.mode === "human" ? (await deps.http.get(`${ctx.root}/issues/${number}`)).issue : void 0;
3073
+ const project = await projectLine(deps, ctx);
3053
3074
  const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues/${number}/comments`, { body });
3054
- printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags)}
3075
+ printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags)}${project}
3055
3076
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3056
3077
  });
3057
3078
  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) => {
3058
3079
  const ctx = context(deps, command);
3059
3080
  const number = parseIssueRef(ref);
3060
- await checkShared(deps, ctx.root, flags, ref);
3081
+ ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
3061
3082
  const settings = await deps.http.get(`${ctx.root}/issue-settings`);
3062
3083
  const status = pickClosedStatus(settings, flags.status);
3084
+ const project = await projectLine(deps, ctx);
3063
3085
  const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} });
3064
- printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags)}
3086
+ printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags)}${project}
3065
3087
  ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
3066
3088
  });
3067
3089
  }
@@ -3331,6 +3353,19 @@ async function createMemoryContext(opts, recover = false) {
3331
3353
  const cache = owned ? read : { state: { entries: [], scope: "", projectName: project.slice(0, 8), ...fingerprint ? { tokenFingerprint: fingerprint } : {} }, meta: { cursor: 0, pulledAt: "" } };
3332
3354
  return { project, dir, root, git, cache, api: `/api/projects/${project}/memory`, stale: !owned };
3333
3355
  }
3356
+ async function resolveMemoryProjectName(ctx, http, human) {
3357
+ const name = ctx.cache.state.projectName;
3358
+ if (!human || ctx.projectNameRequested || name && name !== ctx.project.slice(0, 8)) return;
3359
+ ctx.projectNameRequested = true;
3360
+ const result = await http.get(`/api/projects/${encodeURIComponent(ctx.project)}`).catch(() => null);
3361
+ if (typeof result?.project?.name === "string" && result.project.name.trim()) {
3362
+ ctx.cache.state.projectName = result.project.name;
3363
+ }
3364
+ }
3365
+ function memoryProjectSuffix(ctx) {
3366
+ const name = ctx.cache.state.projectName;
3367
+ return ` \u2192 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u300C${oneLine(name && name !== ctx.project.slice(0, 8) ? name : ctx.project)}\u300D`;
3368
+ }
3334
3369
  async function memoryIndexText(ctx, deps) {
3335
3370
  const entries = ctx.cache.state.entries.filter((e) => !e.deleted && e.scope === "branch" && e.repoIdentity === ctx.git.repoIdentity);
3336
3371
  const branches = [...new Set(entries.map((e) => e.branch))];
@@ -3399,6 +3434,7 @@ async function importMemoryFiles(opts) {
3399
3434
  allowNew: true,
3400
3435
  ...opts.ai ? {} : { aiSkip: true }
3401
3436
  }, { "X-Nolto-Client": detectMemoryClient(process.env) });
3437
+ await resolveMemoryProjectName(ctx, opts.http, opts.human !== false);
3402
3438
  cached = await updateCache(ctx, opts, writtenEntries(ctx, response), true) && cached;
3403
3439
  heading = aiHeading(response);
3404
3440
  imported++;
@@ -3416,7 +3452,7 @@ async function importMemoryFiles(opts) {
3416
3452
  }
3417
3453
  const result = { file, name, original, status, ...message ? { message } : {} };
3418
3454
  results.push(result);
3419
- opts.write(heading ? `${heading} (\u5143: ${oneLine(file)})` : importResultLine(opts.scope, result));
3455
+ opts.write((heading ? `${heading} (\u5143: ${oneLine(file)})` : importResultLine(opts.scope, result)) + memoryProjectSuffix(ctx));
3420
3456
  }
3421
3457
  return { imported, skipped, failed, results, cached };
3422
3458
  }
@@ -3529,16 +3565,7 @@ async function pickProject(rl, http, projects, promptText, baseUrl) {
3529
3565
  }
3530
3566
  return void 0;
3531
3567
  }
3532
- async function selectRepoProject(rl, http, projects, defaultProjectId, baseUrl) {
3533
- const defaultProject = defaultProjectId == null ? void 0 : projects.find((project) => project.id === defaultProjectId);
3534
- if (defaultProject != null) {
3535
- const useDefault = await rl.question(
3536
- `Use "${stripTerminal(defaultProject.name)}" (${defaultProject.id}) for this repository? [Y/n] `
3537
- );
3538
- if (useDefault.trim().toLowerCase() !== "n") {
3539
- return defaultProject;
3540
- }
3541
- }
3568
+ async function selectRepoProject(rl, http, projects, baseUrl) {
3542
3569
  return pickProject(
3543
3570
  rl,
3544
3571
  http,
@@ -3594,6 +3621,7 @@ async function setupMemory(opts) {
3594
3621
  git,
3595
3622
  memoryGit: deps.memoryGit,
3596
3623
  token,
3624
+ human: deps.output.mode !== "json",
3597
3625
  write: (line2) => {
3598
3626
  process.stdout.write(line2 + "\n");
3599
3627
  }
@@ -3632,7 +3660,7 @@ async function setupMemory(opts) {
3632
3660
  `);
3633
3661
  }
3634
3662
  function register5(program, deps) {
3635
- program.command("init").description("Interactive setup: configure token, base URL, and default project.").option("--force", "Overwrite existing config without prompting").option("--memory", "Set up Nolto memory without the initial confirmation").option("--no-memory", "Skip memory setup").action(async (opts) => {
3663
+ program.command("init").description("Interactive setup: configure token, base URL, and repository project.").option("--force", "Overwrite existing config without prompting").option("--memory", "Set up Nolto memory without the initial confirmation").option("--no-memory", "Skip memory setup").action(async (opts) => {
3636
3664
  const configPath = deps.configPath;
3637
3665
  const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
3638
3666
  try {
@@ -3654,8 +3682,6 @@ function register5(program, deps) {
3654
3682
  }
3655
3683
  let token = deps.settings.token ?? "";
3656
3684
  let baseUrl = deps.settings.baseUrl;
3657
- let defaultProjectId = deps.settings.defaultProjectId;
3658
- let defaultProjectName;
3659
3685
  let http;
3660
3686
  let projects;
3661
3687
  if (configureGlobal) {
@@ -3682,45 +3708,28 @@ function register5(program, deps) {
3682
3708
  }
3683
3709
  throw err;
3684
3710
  }
3685
- const selected = await pickProject(
3686
- rl,
3687
- http,
3688
- projects,
3689
- "Default project number, 'c' to create new (or Enter to skip): ",
3690
- baseUrl
3691
- );
3692
- defaultProjectId = selected?.id;
3693
- defaultProjectName = selected?.name;
3694
- if (selected != null && !projects.some((project) => project.id === selected.id)) {
3695
- projects = [...projects, selected];
3696
- }
3697
3711
  await clearMemoryCaches(configPath);
3698
3712
  await saveConfigFile(configPath, {
3699
3713
  token,
3700
- baseUrl: baseUrl !== DEFAULT_BASE_URL ? baseUrl : void 0,
3701
- defaultProjectId
3714
+ baseUrl: baseUrl !== DEFAULT_BASE_URL ? baseUrl : void 0
3702
3715
  });
3703
- const projectDisplay = defaultProjectId != null ? `${stripTerminal(defaultProjectName)} (${defaultProjectId})` : "not set";
3704
3716
  process.stdout.write(`
3705
3717
  Saved ${configPath}
3706
3718
  `);
3707
3719
  process.stdout.write(`baseUrl: ${baseUrl}
3708
3720
  `);
3709
3721
  process.stdout.write(`token: ${maskToken(token)} (verified)
3710
- `);
3711
- process.stdout.write(`defaultProject: ${projectDisplay}
3712
3722
  `);
3713
3723
  } else {
3714
- const projectDisplay = defaultProjectId ?? "not set";
3715
3724
  process.stdout.write(
3716
- `Using existing config: baseUrl=${baseUrl}, token=${maskToken(token)}, defaultProject=${projectDisplay}
3725
+ `Using existing config: baseUrl=${baseUrl}, token=${maskToken(token)}
3717
3726
  `
3718
3727
  );
3719
3728
  }
3720
3729
  const startDir = resolveStartDir(process.env, process.cwd());
3721
3730
  const { root, foundGit } = findRepoRoot(startDir);
3722
3731
  if (!foundGit) {
3723
- process.stdout.write("\nNo git repository found here \u2014 skipped repo setup. Run `nolto init` inside a repo to set up roadmap sync.\n");
3732
+ process.stdout.write("\nNo git repository found here \u2014 skipped repo setup. Run `nolto init` inside a repo to set up roadmap sync. Project commands require nolto.json in this directory or an ancestor, or --project / NOLTO_PROJECT.\n");
3724
3733
  return;
3725
3734
  }
3726
3735
  if (isHomeDirectory(root)) {
@@ -3757,9 +3766,9 @@ Saved ${configPath}
3757
3766
  boundProject != null ? "Keep this binding? [Y/n] " : "Keep this binding? [y/N] "
3758
3767
  );
3759
3768
  keepExistingBinding = boundProject != null ? keep.trim().toLowerCase() !== "n" : keep.trim().toLowerCase() === "y";
3760
- repoProject = keepExistingBinding ? boundProject ?? { id: existingBinding.projectId, name: path17.basename(root) } : await selectRepoProject(rl, repoHttp, projects, defaultProjectId, baseUrl);
3769
+ repoProject = keepExistingBinding ? boundProject ?? { id: existingBinding.projectId, name: path17.basename(root) } : await selectRepoProject(rl, repoHttp, projects, baseUrl);
3761
3770
  } else {
3762
- repoProject = await selectRepoProject(rl, repoHttp, projects, defaultProjectId, baseUrl);
3771
+ repoProject = await selectRepoProject(rl, repoHttp, projects, baseUrl);
3763
3772
  }
3764
3773
  if (repoProject == null) {
3765
3774
  process.stdout.write("Skipped repo setup (no project selected).\n");
@@ -3991,7 +4000,7 @@ function register6(program, deps) {
3991
4000
  });
3992
4001
  const existingConfig = await loadConfigFile(configPath).catch(() => null);
3993
4002
  const newConfig = {
3994
- ...existingConfig,
4003
+ baseUrl: existingConfig?.baseUrl,
3995
4004
  token
3996
4005
  };
3997
4006
  await clearMemoryCaches(configPath);
@@ -4046,8 +4055,8 @@ function register7(program, deps) {
4046
4055
  configPath,
4047
4056
  tokenLast4: settings.token != null ? settings.token.slice(-4) : null,
4048
4057
  tokenSource: settings.source.token,
4049
- defaultProject: settings.defaultProjectId ?? null,
4050
- defaultProjectSource: settings.source.project,
4058
+ project: settings.projectId ?? null,
4059
+ projectSource: settings.source.project,
4051
4060
  projectBindingPath: projectBindingPath ?? null,
4052
4061
  projects: projectCount ?? null,
4053
4062
  ...tokenInfo ? { tokenScopes: tokenInfo.scopes, tokenProject: tokenInfo.projectId } : {}
@@ -4056,22 +4065,26 @@ function register7(program, deps) {
4056
4065
  );
4057
4066
  } else {
4058
4067
  const tokenDisplay = settings.token != null ? `${maskToken(settings.token)} (source: ${settings.source.token})` : "(not configured)";
4059
- const bindingDisplay = settings.source.project === "repo" && projectBindingPath != null ? `${settings.defaultProjectId ?? "none"} (source: repo, binding: ${projectBindingPath})` : `${settings.defaultProjectId ?? "none"} (source: ${settings.source.project})`;
4068
+ const bindingDisplay = settings.source.project === "repo" && projectBindingPath != null ? `${settings.projectId ?? "none"} (source: repo, binding: ${projectBindingPath})` : `${settings.projectId ?? "none"} (source: ${settings.source.project})`;
4060
4069
  const lines = [
4061
4070
  ["baseUrl", `${settings.baseUrl} (source: ${settings.source.baseUrl})`],
4062
4071
  ["configPath", configPath],
4063
4072
  ["token", tokenDisplay],
4064
- ["defaultProject", bindingDisplay],
4073
+ ["project", bindingDisplay],
4065
4074
  ["projects", projectCount != null ? String(projectCount) : settings.token != null ? "(unavailable)" : "(no token)"]
4066
4075
  ];
4067
4076
  if (tokenInfo) {
4068
- lines.push(["scopes", tokenInfo.scopes === null ? "full" : tokenInfo.scopes.join(", ")], ["project", tokenInfo.projectId ?? "all"]);
4077
+ lines.push(["scopes", tokenInfo.scopes === null ? "full" : tokenInfo.scopes.join(", ")], ["tokenProject", tokenInfo.projectId ?? "all"]);
4069
4078
  }
4079
+ const legacyConfig = await loadConfigFile(configPath).catch(() => null);
4070
4080
  const maxKey = lines.reduce((m, [k]) => Math.max(m, k.length), 0);
4071
4081
  for (const [key, val] of lines) {
4072
4082
  process.stdout.write(`${key.padEnd(maxKey)}: ${val}
4073
4083
  `);
4074
4084
  }
4085
+ if (legacyConfig?.defaultProjectId) {
4086
+ process.stdout.write("(config \u306E defaultProjectId \u306F\u4F7F\u308F\u308C\u307E\u305B\u3093\u3002nolto init \u304B nolto login \u3067\u8A2D\u5B9A\u3092\u4FDD\u5B58\u3057\u76F4\u3059\u3068\u6D88\u3048\u307E\u3059)\n");
4087
+ }
4075
4088
  }
4076
4089
  });
4077
4090
  }
@@ -5434,10 +5447,8 @@ var aiSkippedLine = (reason) => `AI \u6574\u7406\u306A\u3057(${aiSkipReasons[rea
5434
5447
  var pullHint = "nolto memory pull \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044";
5435
5448
  var scopeHint = "--scope project|user|branch";
5436
5449
  async function context2(deps, recover = false) {
5437
- const bindingPath = deps.repoBinding?.path ?? deps.projectBindingPath;
5438
- const binding = deps.repoBinding?.binding ?? (bindingPath ? await loadRepoBinding(bindingPath) : null);
5439
- const project = deps.settings.defaultProjectId ?? binding?.projectId;
5440
- if (!project) throw new CliError("\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304C\u672A\u8A2D\u5B9A\u3067\u3059\u3002", 2, "nolto link \u307E\u305F\u306F --project <id>");
5450
+ const project = deps.settings.projectId;
5451
+ if (!project) throw projectRequiredError();
5441
5452
  const root = findRepoRoot(resolveStartDir(process.env, process.cwd())).root;
5442
5453
  return createMemoryContext({ projectId: project, configPath: deps.configPath, root, git: await memoryGitContext(root, deps), token: deps.settings.token }, recover);
5443
5454
  }
@@ -5522,7 +5533,7 @@ function printWrite(deps, ctx, action, response, isNew = false, put) {
5522
5533
  const { entry } = response;
5523
5534
  const heading = aiHeading(response, put?.name);
5524
5535
  const lifetime = action === "put" ? [entry.expiresOn ? `expires ${oneLine(entry.expiresOn)}` : "", entry.until ? `until ${oneLine(entry.until)}` : ""].filter(Boolean) : [];
5525
- const lines = [heading ?? `${action} ${entry.scope}/${entry.name} r${entry.revision}${isNew ? " (\u65B0\u898F)" : ""}${lifetime.length ? ` (${lifetime.join("\u3001")})` : ""}`];
5536
+ const lines = [(heading ?? `${action} ${entry.scope}/${entry.name} r${entry.revision}${isNew ? " (\u65B0\u898F)" : ""}${lifetime.length ? ` (${lifetime.join("\u3001")})` : ""}`) + memoryProjectSuffix(ctx)];
5526
5537
  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)}`);
5527
5538
  if (response.aiSkipped) lines.push(aiSkippedLine(response.aiSkipped));
5528
5539
  const affected = response.affected ?? [];
@@ -5544,7 +5555,6 @@ async function pull2(deps, opts) {
5544
5555
  try {
5545
5556
  const explicitProject = deps.settings.source?.project === "flag" || deps.settings.source?.project === "env";
5546
5557
  if (opts.hook && !explicitProject && !(deps.repoBinding?.path ?? deps.projectBindingPath)) {
5547
- process.stdout.write(hookOutput(opts.hook, "nolto link \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044"));
5548
5558
  return;
5549
5559
  }
5550
5560
  if (opts.hook && !deps.settings.token) {
@@ -5706,6 +5716,7 @@ function register13(program, deps) {
5706
5716
  const changed = /* @__PURE__ */ new Set([response.entry.id, ...(response.affected ?? []).map((a) => a.entryId)]);
5707
5717
  ctx.cache.state.cleanupCandidates = (ctx.cache.state.cleanupCandidates ?? []).filter((c) => !changed.has(c.entryId));
5708
5718
  }
5719
+ await resolveMemoryProjectName(ctx, deps.http, deps.output.mode !== "json");
5709
5720
  await updateCache(ctx, deps, writtenEntries(ctx, response));
5710
5721
  printWrite(deps, ctx, "put", response, draft.revision === void 0, { name: draft.name, file, allowNew: opts.new });
5711
5722
  });
@@ -5716,6 +5727,7 @@ function register13(program, deps) {
5716
5727
  try {
5717
5728
  const entry = resolveEntry(ctx, name, opts);
5718
5729
  const response = await apiCall(deps, ctx, () => deps.http.delete(`${ctx.api}/${encodeURIComponent(entry.id)}?baseRevision=${entry.revision}`, headers()), "rm", name);
5730
+ await resolveMemoryProjectName(ctx, deps.http, deps.output.mode !== "json");
5719
5731
  await updateCache(ctx, deps, writtenEntries(ctx, response));
5720
5732
  results.push(response);
5721
5733
  if (names.length === 1 || deps.output.mode !== "json") printWrite(deps, ctx, "rm", response);
@@ -5734,6 +5746,7 @@ function register13(program, deps) {
5734
5746
  const ctx = await context2(deps);
5735
5747
  const entry = resolveEntry(ctx, name, opts, true);
5736
5748
  const response = await apiCall(deps, ctx, () => deps.http.post(`${ctx.api}/${encodeURIComponent(entry.id)}/revert`, { revision: parseRevision(revision), baseRevision: entry.revision }, headers()), "revert", name);
5749
+ await resolveMemoryProjectName(ctx, deps.http, deps.output.mode !== "json");
5737
5750
  await updateCache(ctx, deps, writtenEntries(ctx, response));
5738
5751
  printWrite(deps, ctx, "revert", response);
5739
5752
  });
@@ -5755,8 +5768,9 @@ function register13(program, deps) {
5755
5768
  }
5756
5769
  const response = await apiCall(deps, ctx, () => deps.http.post(`${ctx.api}/promote`, { repoIdentity: ctx.git.repoIdentity, branch: opts.branch, ...names.length ? { names } : {}, ...opts.discard ? { discard: true } : {} }, headers()), "promote");
5757
5770
  const retired = selected.map((e) => ({ ...e, deleted: true }));
5771
+ await resolveMemoryProjectName(ctx, deps.http, deps.output.mode !== "json");
5758
5772
  await updateCache(ctx, deps, [...retired, ...response.promoted, ...response.discarded]);
5759
- printResult(deps.output.mode === "json" ? response : [...response.promoted.map((e) => `promote ${line(e)}`), ...response.discarded.map((e) => `discard ${line(e)}`)].join("\n"), deps.output.mode);
5773
+ printResult(deps.output.mode === "json" ? response : [...response.promoted.map((e) => `promote ${line(e)}${memoryProjectSuffix(ctx)}`), ...response.discarded.map((e) => `discard ${line(e)}${memoryProjectSuffix(ctx)}`)].join("\n"), deps.output.mode);
5760
5774
  });
5761
5775
  memory.command("hook").command("install").option("--agent <agent>").option("--write-agents-md").action(async (opts) => {
5762
5776
  const { root } = findRepoRoot(resolveStartDir(process.env, process.cwd()));
@@ -5778,6 +5792,7 @@ function register13(program, deps) {
5778
5792
  token: deps.settings.token,
5779
5793
  scope,
5780
5794
  targets: scan.ok,
5795
+ human: deps.output.mode !== "json",
5781
5796
  ai: opts.ai,
5782
5797
  git: ctx.git,
5783
5798
  memoryGit: deps.memoryGit,
@@ -5789,7 +5804,7 @@ function register13(program, deps) {
5789
5804
  const failed = result.failed + scan.invalid.length;
5790
5805
  const results = [...result.results, ...scan.invalid].sort((a, b) => a.file.localeCompare(b.file));
5791
5806
  if (deps.output.mode !== "json") {
5792
- for (const item of results) process.stdout.write((lines.get(item.file) ?? importResultLine(scope, item)) + "\n");
5807
+ for (const item of results) process.stdout.write((lines.get(item.file) ?? importResultLine(scope, item) + memoryProjectSuffix(ctx)) + "\n");
5793
5808
  }
5794
5809
  const skippedNames = results.filter((r) => r.status === "skipped").map((r) => `${scope}/${String(r.name)}`);
5795
5810
  if (deps.output.mode !== "json" && skippedNames.length) process.stdout.write(`skipped (\u540C\u540D\u3042\u308A\u3002\u7D71\u5408\u3059\u308B\u306A\u3089 nolto memory show <name> --fresh): ${skippedNames.join(", ")}
@@ -5807,7 +5822,7 @@ function stripCommanderErrorPrefix(msg) {
5807
5822
  function buildProgram(deps) {
5808
5823
  const writeErr = (_msg) => {
5809
5824
  };
5810
- const program = new Command("nolto").version(deps.version, "-V, --version", "Print version number").exitOverride().configureOutput({ writeErr }).description("Nolto CLI \u2014 sync repository roadmaps with Nolto.").option("--token <value>", "API token (overrides env/file)").option("--base-url <url>", "Nolto base URL (default: https://nolto.app)").option("--project <projectId>", "Default project ID").option("--json", "Output as JSON");
5825
+ const program = new Command("nolto").version(deps.version, "-V, --version", "Print version number").exitOverride().configureOutput({ writeErr }).description("Nolto CLI \u2014 sync repository roadmaps with Nolto.").option("--token <value>", "API token (overrides env/file)").option("--base-url <url>", "Nolto base URL (default: https://nolto.app)").option("--project <projectId>", "Project ID (overrides env/repo)").option("--json", "Output as JSON");
5811
5826
  register13(program, deps);
5812
5827
  register4(program, deps);
5813
5828
  register5(program, deps);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.22.2",
3
+ "version": "0.23.0",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",