@nolto/cli 0.23.1 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -7
- package/dist/index.js +481 -114
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -26,6 +26,13 @@ var CliError = class extends Error {
|
|
|
26
26
|
detail;
|
|
27
27
|
retryAfter;
|
|
28
28
|
};
|
|
29
|
+
var TOKEN_EXPIRED_MESSAGE = "token \u306E\u671F\u9650\u304C\u5207\u308C\u305F\u304B\u3001\u5931\u52B9\u3057\u3066\u3044\u307E\u3059\u3002`nolto login` \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044";
|
|
30
|
+
function tokenOriginMismatchMessage(m) {
|
|
31
|
+
return `\u8A2D\u5B9A\u306E token \u306F ${m.issuedBy} \u3067\u767A\u884C\u3055\u308C\u305F\u3082\u306E\u3067\u3059\u3002${m.sentTo} \u306B\u306F\u9001\u308A\u307E\u305B\u3093\u3002\`nolto login --base-url ${m.sentTo}\` \u3067\u53D6\u308A\u76F4\u3059\u304B\u3001\`NOLTO_TOKEN\` \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`;
|
|
32
|
+
}
|
|
33
|
+
function tokenOriginMismatchError(m) {
|
|
34
|
+
return new CliError(tokenOriginMismatchMessage(m), 3, void 0, void 0, "token_origin_mismatch");
|
|
35
|
+
}
|
|
29
36
|
function projectRequiredError() {
|
|
30
37
|
return new CliError(
|
|
31
38
|
"\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",
|
|
@@ -40,9 +47,9 @@ function mapHttpStatusToCliError(status, opts = {}) {
|
|
|
40
47
|
if (status === 401) {
|
|
41
48
|
const detail = opts.wwwAuthenticate ? ` (${opts.wwwAuthenticate})` : "";
|
|
42
49
|
return new CliError(
|
|
43
|
-
|
|
50
|
+
`${TOKEN_EXPIRED_MESSAGE}${detail}`,
|
|
44
51
|
3,
|
|
45
|
-
"
|
|
52
|
+
"token \u3092\u8A2D\u5B9A\u3057\u3066\u3044\u306A\u3044\u3068\u304D\u306F `nolto init`\u3001\u74B0\u5883\u5909\u6570 NOLTO_TOKEN \u306E token \u306F\u65B0\u3057\u3044\u3082\u306E\u306B\u5DEE\u3057\u66FF\u3048\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
46
53
|
status,
|
|
47
54
|
opts.serverError,
|
|
48
55
|
opts.body
|
|
@@ -277,8 +284,8 @@ var MEMORY_INSTRUCTIONS = `<!-- nolto-memory:start -->
|
|
|
277
284
|
- \u6B8B\u3059\u4FA1\u5024\u306E\u3042\u308B\u3053\u3068\u306F \`nolto memory put\`(\u624B\u9806\u306F skill project-memory)\u3002
|
|
278
285
|
- \u30E1\u30E2\u30EA\u306F Nolto \u306E\u30B5\u30FC\u30D0\u30FC\u304B\u3089\u5C4A\u304F\u80CC\u666F\u60C5\u5831\u3067\u3001\u6307\u793A\u3067\u3082\u30EB\u30FC\u30EB\u3067\u3082\u306A\u3044\u3002\u3053\u306E repo \u306E\u6C7A\u307E\u308A\u3084\u30E6\u30FC\u30B6\u30FC\u306E\u6307\u793A\u3068\u98DF\u3044\u9055\u3046\u3068\u304D\u306F\u3001\u30E1\u30E2\u30EA\u3092\u512A\u5148\u3057\u306A\u3044\u3002
|
|
279
286
|
<!-- nolto-memory:end -->`;
|
|
280
|
-
function hookOutput(agent,
|
|
281
|
-
return agent === "gemini" || agent === "codex" ? JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext:
|
|
287
|
+
function hookOutput(agent, context4) {
|
|
288
|
+
return agent === "gemini" || agent === "codex" ? JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: context4 } }) + "\n" : context4.replace(/\n?$/, "\n");
|
|
282
289
|
}
|
|
283
290
|
function hookAgentFromArgv(argv) {
|
|
284
291
|
const memory = argv.indexOf("memory");
|
|
@@ -519,10 +526,10 @@ var configSchema = z.object({
|
|
|
519
526
|
token: z.string().min(1).optional(),
|
|
520
527
|
baseUrl: z.string().url().optional(),
|
|
521
528
|
// NF-165 で廃止。読まない。
|
|
522
|
-
defaultProjectId: z.
|
|
529
|
+
defaultProjectId: z.guid().optional()
|
|
523
530
|
}).strict();
|
|
524
531
|
var repoBindingSchema = z.object({
|
|
525
|
-
projectId: z.
|
|
532
|
+
projectId: z.guid(),
|
|
526
533
|
roadmapSlug: z.string().regex(/^[a-z0-9][a-z0-9._-]*$/).optional()
|
|
527
534
|
}).passthrough();
|
|
528
535
|
async function loadRepoBinding(filePath) {
|
|
@@ -666,6 +673,21 @@ function resolveProjectId(args) {
|
|
|
666
673
|
}
|
|
667
674
|
return { projectId: void 0, projectSource: "none" };
|
|
668
675
|
}
|
|
676
|
+
function originOf(url) {
|
|
677
|
+
return new URL(url).origin;
|
|
678
|
+
}
|
|
679
|
+
function validateBaseUrl(url) {
|
|
680
|
+
let parsed;
|
|
681
|
+
try {
|
|
682
|
+
parsed = new URL(url);
|
|
683
|
+
} catch {
|
|
684
|
+
throw new CliError(`Invalid base URL: ${url}`, 2);
|
|
685
|
+
}
|
|
686
|
+
const localhost = parsed.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(parsed.hostname);
|
|
687
|
+
if (parsed.protocol !== "https:" && !localhost) {
|
|
688
|
+
throw new CliError(`Base URL must use https:// (http:// is allowed only for localhost): ${url}`, 2);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
669
691
|
function resolveSettings(args) {
|
|
670
692
|
const { flags, env, file, repoBinding } = args;
|
|
671
693
|
let token;
|
|
@@ -694,6 +716,17 @@ function resolveSettings(args) {
|
|
|
694
716
|
} else {
|
|
695
717
|
baseUrl = DEFAULT_BASE_URL;
|
|
696
718
|
}
|
|
719
|
+
validateBaseUrl(baseUrl);
|
|
720
|
+
let tokenOriginMismatch;
|
|
721
|
+
if (tokenSource === "file") {
|
|
722
|
+
const issuedBy = originOf(file?.baseUrl ?? DEFAULT_BASE_URL);
|
|
723
|
+
const sentTo = originOf(baseUrl);
|
|
724
|
+
if (issuedBy !== sentTo) {
|
|
725
|
+
tokenOriginMismatch = { issuedBy, sentTo };
|
|
726
|
+
token = void 0;
|
|
727
|
+
tokenSource = "none";
|
|
728
|
+
}
|
|
729
|
+
}
|
|
697
730
|
const { projectId, projectSource } = resolveProjectId({
|
|
698
731
|
flagProject: flags.project,
|
|
699
732
|
envProject: env["NOLTO_PROJECT"],
|
|
@@ -703,6 +736,7 @@ function resolveSettings(args) {
|
|
|
703
736
|
token,
|
|
704
737
|
baseUrl,
|
|
705
738
|
projectId,
|
|
739
|
+
...tokenOriginMismatch ? { tokenOriginMismatch } : {},
|
|
706
740
|
source: { token: tokenSource, baseUrl: baseUrlSource, project: projectSource }
|
|
707
741
|
};
|
|
708
742
|
}
|
|
@@ -790,8 +824,24 @@ function createHttpClient(opts) {
|
|
|
790
824
|
// src/program.ts
|
|
791
825
|
import { Command } from "commander";
|
|
792
826
|
|
|
793
|
-
// src/
|
|
794
|
-
import { readFile as
|
|
827
|
+
// src/body-input.ts
|
|
828
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
829
|
+
function warningLines(warnings) {
|
|
830
|
+
return Array.isArray(warnings) ? warnings.filter((text) => typeof text === "string").map((text) => `
|
|
831
|
+
\u6CE8\u610F: ${terminalLine(text)}`).join("") : "";
|
|
832
|
+
}
|
|
833
|
+
async function bodyText(body, file) {
|
|
834
|
+
if (body !== void 0 && file !== void 0) throw new CliError("Use either --body/-m or --body-file, not both.", 2);
|
|
835
|
+
if (file === void 0) return body;
|
|
836
|
+
try {
|
|
837
|
+
if (file !== "-") return await readFile4(file, "utf8");
|
|
838
|
+
const chunks = [];
|
|
839
|
+
for await (const chunk of process.stdin) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
840
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
841
|
+
} catch (error) {
|
|
842
|
+
throw new CliError(`Cannot read body from ${file}: ${String(error)}`, 2);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
795
845
|
|
|
796
846
|
// src/watch-state.ts
|
|
797
847
|
import * as fs from "fs/promises";
|
|
@@ -849,7 +899,7 @@ async function staleWatchWarning(env, currentVersion, kill = process.kill) {
|
|
|
849
899
|
// src/roadmap-commands.ts
|
|
850
900
|
import path14 from "path";
|
|
851
901
|
import { existsSync as existsSync5 } from "fs";
|
|
852
|
-
import { readFile as
|
|
902
|
+
import { readFile as readFile10, readdir as readdir4, writeFile as writeFile7, rename as rename3, unlink as unlink3, realpath as realpath3 } from "fs/promises";
|
|
853
903
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
854
904
|
import readline2 from "readline/promises";
|
|
855
905
|
|
|
@@ -1258,7 +1308,7 @@ function draftUrl(baseUrl, projectId, id) {
|
|
|
1258
1308
|
}
|
|
1259
1309
|
|
|
1260
1310
|
// src/roadmap-cache.ts
|
|
1261
|
-
import { mkdir as mkdir4, readdir as readdir2, readFile as
|
|
1311
|
+
import { mkdir as mkdir4, readdir as readdir2, readFile as readFile5, writeFile as writeFile4, rename, unlink } from "fs/promises";
|
|
1262
1312
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
1263
1313
|
import path6 from "path";
|
|
1264
1314
|
|
|
@@ -1437,7 +1487,7 @@ async function readCache(env, projectId, slug) {
|
|
|
1437
1487
|
const paths = cachePaths(env, projectId, slug);
|
|
1438
1488
|
let raw;
|
|
1439
1489
|
try {
|
|
1440
|
-
raw = await
|
|
1490
|
+
raw = await readFile5(paths.json, "utf8");
|
|
1441
1491
|
} catch (err) {
|
|
1442
1492
|
if (err.code === "ENOENT") return null;
|
|
1443
1493
|
throw err;
|
|
@@ -1452,7 +1502,7 @@ async function readCache(env, projectId, slug) {
|
|
|
1452
1502
|
if (errors.length) throw new CliError(`${paths.json} failed validation: ${errors.join("; ")}`, 2);
|
|
1453
1503
|
let meta = null;
|
|
1454
1504
|
try {
|
|
1455
|
-
const parsed = JSON.parse(await
|
|
1505
|
+
const parsed = JSON.parse(await readFile5(paths.meta, "utf8"));
|
|
1456
1506
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed) || !("revision" in parsed) || !Number.isSafeInteger(parsed.revision) || Number(parsed.revision) < 0 || !("pulledAt" in parsed) || typeof parsed.pulledAt !== "string" || !("contentHash" in parsed) || typeof parsed.contentHash !== "string") {
|
|
1457
1507
|
throw new Error("Invalid cache metadata");
|
|
1458
1508
|
}
|
|
@@ -1491,7 +1541,7 @@ function isDirty(entry) {
|
|
|
1491
1541
|
|
|
1492
1542
|
// src/roadmap-bootstrap.ts
|
|
1493
1543
|
import { existsSync as existsSync3 } from "fs";
|
|
1494
|
-
import { readFile as
|
|
1544
|
+
import { readFile as readFile6, realpath } from "fs/promises";
|
|
1495
1545
|
import path7 from "path";
|
|
1496
1546
|
|
|
1497
1547
|
// src/roadmap-scaffold.ts
|
|
@@ -1587,7 +1637,7 @@ async function ensureRoadmapCache(args) {
|
|
|
1587
1637
|
await writeCache(env, projectId, slug, roadmap, { repoIdentity: identity, revision: 0, pulledAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
1588
1638
|
const response = await runSync({ ...args, slug, roadmap, baseRevision: 0 }, {
|
|
1589
1639
|
http: args.http,
|
|
1590
|
-
readFile: (p) =>
|
|
1640
|
+
readFile: (p) => readFile6(p, "utf8"),
|
|
1591
1641
|
realpath,
|
|
1592
1642
|
fileExists: existsSync3,
|
|
1593
1643
|
log: () => void 0,
|
|
@@ -1641,13 +1691,13 @@ import path11 from "path";
|
|
|
1641
1691
|
import { statSync as statSync3 } from "fs";
|
|
1642
1692
|
|
|
1643
1693
|
// src/registry.ts
|
|
1644
|
-
import { readFile as
|
|
1694
|
+
import { readFile as readFile7, writeFile as writeFile5, mkdir as mkdir5, rename as rename2, unlink as unlink2 } from "fs/promises";
|
|
1645
1695
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
1646
1696
|
import path8 from "path";
|
|
1647
1697
|
import { z as z3 } from "zod";
|
|
1648
1698
|
var registrySchema = z3.object({
|
|
1649
1699
|
schemaVersion: z3.literal(1),
|
|
1650
|
-
repos: z3.array(z3.object({ root: z3.string().min(1), projectId: z3.
|
|
1700
|
+
repos: z3.array(z3.object({ root: z3.string().min(1), projectId: z3.guid().optional() }).passthrough())
|
|
1651
1701
|
}).passthrough();
|
|
1652
1702
|
function getRegistryPath(env) {
|
|
1653
1703
|
return path8.join(getConfigDir(env), "registry.json");
|
|
@@ -1655,7 +1705,7 @@ function getRegistryPath(env) {
|
|
|
1655
1705
|
async function loadRegistry(filePath) {
|
|
1656
1706
|
let raw;
|
|
1657
1707
|
try {
|
|
1658
|
-
raw = await
|
|
1708
|
+
raw = await readFile7(filePath, "utf8");
|
|
1659
1709
|
} catch (err) {
|
|
1660
1710
|
const code = err != null && typeof err === "object" && "code" in err ? err.code : "";
|
|
1661
1711
|
if (code === "ENOENT") {
|
|
@@ -1719,7 +1769,7 @@ import { realpathSync } from "fs";
|
|
|
1719
1769
|
import path10 from "path";
|
|
1720
1770
|
|
|
1721
1771
|
// src/machine-id.ts
|
|
1722
|
-
import { chmod, mkdir as mkdir6, readFile as
|
|
1772
|
+
import { chmod, mkdir as mkdir6, readFile as readFile8, writeFile as writeFile6 } from "fs/promises";
|
|
1723
1773
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
1724
1774
|
import path9 from "path";
|
|
1725
1775
|
var inFlightByConfigDir = /* @__PURE__ */ new Map();
|
|
@@ -1740,7 +1790,7 @@ async function loadOrCreate(configDir) {
|
|
|
1740
1790
|
const file = path9.join(configDir, "machine.json");
|
|
1741
1791
|
let raw = null;
|
|
1742
1792
|
try {
|
|
1743
|
-
raw = await
|
|
1793
|
+
raw = await readFile8(file, "utf8");
|
|
1744
1794
|
} catch (err) {
|
|
1745
1795
|
const code = err.code;
|
|
1746
1796
|
if (code !== "ENOENT") {
|
|
@@ -1760,7 +1810,7 @@ async function loadOrCreate(configDir) {
|
|
|
1760
1810
|
});
|
|
1761
1811
|
} catch (err) {
|
|
1762
1812
|
if (err.code === "EEXIST") {
|
|
1763
|
-
return parseMachineId(await
|
|
1813
|
+
return parseMachineId(await readFile8(file, "utf8"), file);
|
|
1764
1814
|
}
|
|
1765
1815
|
throw new CliError(`Cannot write ${file}: ${String(err)}`, 2);
|
|
1766
1816
|
}
|
|
@@ -1939,7 +1989,7 @@ async function handleRebind(deps, projectId, root, mode2, yes) {
|
|
|
1939
1989
|
}
|
|
1940
1990
|
}
|
|
1941
1991
|
async function handleUnlink(projectBindingPath, mode2) {
|
|
1942
|
-
const { readFile: readFile19, writeFile:
|
|
1992
|
+
const { readFile: readFile19, writeFile: writeFile12, chmod: chmod2 } = await import("fs/promises");
|
|
1943
1993
|
let existing = {};
|
|
1944
1994
|
try {
|
|
1945
1995
|
const raw = await readFile19(projectBindingPath, "utf8");
|
|
@@ -1957,7 +2007,7 @@ async function handleUnlink(projectBindingPath, mode2) {
|
|
|
1957
2007
|
}
|
|
1958
2008
|
const { projectId: _removed, ...rest } = existing;
|
|
1959
2009
|
void _removed;
|
|
1960
|
-
await
|
|
2010
|
+
await writeFile12(projectBindingPath, JSON.stringify(rest, null, 2) + "\n", { mode: 420 });
|
|
1961
2011
|
await chmod2(projectBindingPath, 420);
|
|
1962
2012
|
if (mode2 === "json") {
|
|
1963
2013
|
printResult({ unlinked: true, projectBindingPath }, mode2);
|
|
@@ -2260,7 +2310,7 @@ async function runPull(deps, opts = {}) {
|
|
|
2260
2310
|
// src/commands/sync.ts
|
|
2261
2311
|
import { execFile as execFile2 } from "child_process";
|
|
2262
2312
|
import { promisify } from "util";
|
|
2263
|
-
import { readFile as
|
|
2313
|
+
import { readFile as readFile9, realpath as realpath2 } from "fs/promises";
|
|
2264
2314
|
import { existsSync as existsSync4 } from "fs";
|
|
2265
2315
|
|
|
2266
2316
|
// src/git-links.ts
|
|
@@ -2448,7 +2498,7 @@ async function runSyncCommand(deps, opts = {}) {
|
|
|
2448
2498
|
{ root, projectId, slugs: opts.slug === void 0 ? void 0 : [opts.slug] },
|
|
2449
2499
|
{
|
|
2450
2500
|
env: process.env,
|
|
2451
|
-
readFile: (p) =>
|
|
2501
|
+
readFile: (p) => readFile9(p, "utf8"),
|
|
2452
2502
|
realpath: (p) => realpath2(p),
|
|
2453
2503
|
fileExists: (p) => existsSync4(p),
|
|
2454
2504
|
repoIdentity: makeRepoIdentityResolver(deps),
|
|
@@ -2503,22 +2553,22 @@ async function pull(deps, projectId, slug) {
|
|
|
2503
2553
|
}
|
|
2504
2554
|
}
|
|
2505
2555
|
async function selectRoadmap(deps, requestedSlug) {
|
|
2506
|
-
const
|
|
2556
|
+
const context4 = await resolveRoadmapReadContext(deps);
|
|
2507
2557
|
let slug = requestedSlug;
|
|
2508
2558
|
if (slug === void 0) {
|
|
2509
|
-
let slugs = await listCachedSlugs(process.env,
|
|
2559
|
+
let slugs = await listCachedSlugs(process.env, context4.projectId);
|
|
2510
2560
|
if (slugs.length === 0) {
|
|
2511
2561
|
await runPull(deps, { quiet: true });
|
|
2512
|
-
slugs = await listCachedSlugs(process.env,
|
|
2562
|
+
slugs = await listCachedSlugs(process.env, context4.projectId);
|
|
2513
2563
|
}
|
|
2514
2564
|
if (slugs.length !== 1) {
|
|
2515
2565
|
throw new CliError(slugs.length === 0 ? "No roadmap found. Run `nolto init`." : `Multiple roadmaps found (${slugs.join(", ")}); specify a slug (task commands: --slug <slug>).`, 2);
|
|
2516
2566
|
}
|
|
2517
2567
|
slug = slugs[0];
|
|
2518
2568
|
}
|
|
2519
|
-
const paths = cachePaths(process.env,
|
|
2520
|
-
if (!existsSync5(paths.json)) await pull(deps,
|
|
2521
|
-
return { ...
|
|
2569
|
+
const paths = cachePaths(process.env, context4.projectId, slug);
|
|
2570
|
+
if (!existsSync5(paths.json)) await pull(deps, context4.projectId, slug);
|
|
2571
|
+
return { ...context4, slug, paths };
|
|
2522
2572
|
}
|
|
2523
2573
|
async function roadmapPath(deps, slug) {
|
|
2524
2574
|
const { paths } = await selectRoadmap(deps, slug);
|
|
@@ -2551,7 +2601,7 @@ async function roadmapValidate(deps, slug) {
|
|
|
2551
2601
|
const { paths } = await selectRoadmap(deps, slug);
|
|
2552
2602
|
let parsed;
|
|
2553
2603
|
try {
|
|
2554
|
-
parsed = JSON.parse(await
|
|
2604
|
+
parsed = JSON.parse(await readFile10(paths.json, "utf8"));
|
|
2555
2605
|
} catch {
|
|
2556
2606
|
throw new CliError(`ERROR Malformed JSON in ${paths.json}.`, 1);
|
|
2557
2607
|
}
|
|
@@ -2666,7 +2716,7 @@ async function roadmapMigrate(deps, yes = false) {
|
|
|
2666
2716
|
for (const file of files) {
|
|
2667
2717
|
const slug = file.slice(0, -5);
|
|
2668
2718
|
cachePaths(process.env, projectId, slug);
|
|
2669
|
-
const roadmap = await loadValidRoadmap(path14.join(dir, file), (p) =>
|
|
2719
|
+
const roadmap = await loadValidRoadmap(path14.join(dir, file), (p) => readFile10(p, "utf8"));
|
|
2670
2720
|
roadmap.schemaVersion = 3;
|
|
2671
2721
|
delete roadmap.updatedAt;
|
|
2672
2722
|
delete roadmap.currentTaskId;
|
|
@@ -2701,7 +2751,7 @@ async function roadmapMigrate(deps, yes = false) {
|
|
|
2701
2751
|
if (!unchanged) {
|
|
2702
2752
|
const response = await runSync({ repoRoot: root, projectId, slug, roadmap, baseRevision: revision, repoIdentity: await makeRepoIdentityResolver(deps)(root) }, {
|
|
2703
2753
|
http: deps.http,
|
|
2704
|
-
readFile: (p) =>
|
|
2754
|
+
readFile: (p) => readFile10(p, "utf8"),
|
|
2705
2755
|
realpath: realpath3,
|
|
2706
2756
|
fileExists: existsSync5,
|
|
2707
2757
|
log: () => void 0,
|
|
@@ -2719,7 +2769,7 @@ async function roadmapMigrate(deps, yes = false) {
|
|
|
2719
2769
|
const nextSteps = ["Next steps (run yourself):", " git rm -r .nolto/roadmaps"];
|
|
2720
2770
|
let attributes = "";
|
|
2721
2771
|
try {
|
|
2722
|
-
attributes = await
|
|
2772
|
+
attributes = await readFile10(path14.join(root, ".gitattributes"), "utf8");
|
|
2723
2773
|
} catch (error) {
|
|
2724
2774
|
if (error.code !== "ENOENT") throw error;
|
|
2725
2775
|
}
|
|
@@ -2747,19 +2797,15 @@ async function checkShared(deps, root, flags, ref) {
|
|
|
2747
2797
|
if (flags.priority !== void 0 || flags.category !== void 0) {
|
|
2748
2798
|
throw new CliError("--shared \u3067\u306F --priority \u3068 --category \u306F\u4F7F\u3048\u307E\u305B\u3093(\u5171\u6709\u30E2\u30FC\u30C9\u3067\u306F\u53CD\u6620\u3055\u308C\u307E\u305B\u3093)\u3002", 2);
|
|
2749
2799
|
}
|
|
2750
|
-
const
|
|
2751
|
-
if (
|
|
2800
|
+
const context4 = await deps.http.get(root);
|
|
2801
|
+
if (context4.shareMode?.available !== true) {
|
|
2752
2802
|
throw new CliError("\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u5171\u6709\u30E2\u30FC\u30C9\u3092\u4F7F\u3048\u307E\u305B\u3093(Pro+ \u3067\u3001\u304A\u5BA2\u3055\u307E\u306E\u3044\u308B\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3060\u3051)\u3002--shared \u3092\u5916\u3059\u3068\u793E\u5185\u306E\u66F8\u304D\u8FBC\u307F\u306B\u306A\u308A\u307E\u3059\u3002", 2);
|
|
2753
2803
|
}
|
|
2754
|
-
const key =
|
|
2804
|
+
const key = context4.project?.key;
|
|
2755
2805
|
if (ref?.includes("-") && key && ref.slice(0, ref.lastIndexOf("-")).toUpperCase() !== key.toUpperCase()) {
|
|
2756
2806
|
throw new CliError(`${terminalLine(ref)} \u306F\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8(${terminalLine(key)})\u306E\u8AB2\u984C\u30AD\u30FC\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002`, 2);
|
|
2757
2807
|
}
|
|
2758
|
-
return
|
|
2759
|
-
}
|
|
2760
|
-
function warningLines(warnings) {
|
|
2761
|
-
return Array.isArray(warnings) ? warnings.filter((text) => typeof text === "string").map((text) => `
|
|
2762
|
-
\u6CE8\u610F: ${terminalLine(text)}`).join("") : "";
|
|
2808
|
+
return context4.project?.name;
|
|
2763
2809
|
}
|
|
2764
2810
|
function writeSuffix(flags) {
|
|
2765
2811
|
if (flags.shared && flags.confirmReferences) return " (shared, references confirmed)";
|
|
@@ -2822,18 +2868,6 @@ async function projectLine(deps, ctx) {
|
|
|
2822
2868
|
return `
|
|
2823
2869
|
\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: ${terminalLine(name || ctx.projectId)}`;
|
|
2824
2870
|
}
|
|
2825
|
-
async function bodyText(body, file) {
|
|
2826
|
-
if (body !== void 0 && file !== void 0) throw new CliError("Use either --body/-m or --body-file, not both.", 2);
|
|
2827
|
-
if (file === void 0) return body;
|
|
2828
|
-
try {
|
|
2829
|
-
if (file !== "-") return await readFile10(file, "utf8");
|
|
2830
|
-
const chunks = [];
|
|
2831
|
-
for await (const chunk of process.stdin) chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
2832
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
2833
|
-
} catch (error) {
|
|
2834
|
-
throw new CliError(`Cannot read body from ${file}: ${String(error)}`, 2);
|
|
2835
|
-
}
|
|
2836
|
-
}
|
|
2837
2871
|
async function writeInput(deps, root, flags, create) {
|
|
2838
2872
|
const body = await bodyText(flags.body, flags.bodyFile);
|
|
2839
2873
|
const settings = flags.type || flags.status || flags.category ? await deps.http.get(`${root}/issue-settings`) : emptySettings;
|
|
@@ -2984,6 +3018,277 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
|
|
|
2984
3018
|
});
|
|
2985
3019
|
}
|
|
2986
3020
|
|
|
3021
|
+
// src/commands/wiki.ts
|
|
3022
|
+
import { writeFile as writeFile8 } from "fs/promises";
|
|
3023
|
+
|
|
3024
|
+
// src/wiki-core.ts
|
|
3025
|
+
var wikiSearchMaxLength = 100;
|
|
3026
|
+
var secretFence = "```secret";
|
|
3027
|
+
var secretMark = /^```secret id=/m;
|
|
3028
|
+
var secretNote = `\u30B7\u30FC\u30AF\u30EC\u30C3\u30C8\u306E\u5024\u306F\u8868\u793A\u3055\u308C\u307E\u305B\u3093\u3002\u66F4\u65B0\u3059\u308B\u3068\u304D\u306F ${secretFence} id=\u2026 \u306E\u884C\u3092\u6D88\u3055\u305A\u306B\u6B8B\u3057\u3066\u304F\u3060\u3055\u3044`;
|
|
3029
|
+
var warningNote = `
|
|
3030
|
+
\u30D1\u30B9\u30EF\u30FC\u30C9\u306A\u3069\u306F ${secretFence} \u8868\u793A\u540D \u306E fence \u306B\u66F8\u304F\u3068\u6697\u53F7\u5316\u3057\u3066\u4FDD\u5B58\u3055\u308C\u307E\u3059`;
|
|
3031
|
+
var notFound = () => new CliError("\u30DA\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002", 2, "nolto wiki list \u3067\u30DA\u30FC\u30B8\u3092\u78BA\u304B\u3081\u308B");
|
|
3032
|
+
var wrongProject = () => new CliError("\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30DA\u30FC\u30B8\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002", 2, "--project \u304B nolto.json \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3068\u3001\u30DA\u30FC\u30B8\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u5408\u308F\u305B\u308B");
|
|
3033
|
+
function parsePageRef(input) {
|
|
3034
|
+
const value = input.trim();
|
|
3035
|
+
if (isUuid(value)) return { pageId: value.toLowerCase() };
|
|
3036
|
+
if (/^[0-9A-Za-z]{6}$/.test(value)) return { shortId: value };
|
|
3037
|
+
if (/^https?:\/\//i.test(value)) {
|
|
3038
|
+
let url;
|
|
3039
|
+
try {
|
|
3040
|
+
url = new URL(value);
|
|
3041
|
+
} catch {
|
|
3042
|
+
}
|
|
3043
|
+
const page = url?.pathname.match(/^\/projects\/([^/]+)\/wiki\/([^/]+)\/?$/);
|
|
3044
|
+
if (page && isUuid(page[2])) {
|
|
3045
|
+
try {
|
|
3046
|
+
return { pageId: page[2].toLowerCase(), projectId: decodeURIComponent(page[1]) };
|
|
3047
|
+
} catch {
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
const short = url?.pathname.match(/^(\/s)?\/w\/([0-9A-Za-z]{6})\/?$/);
|
|
3051
|
+
if (short && (short[1] || url?.hostname === "nol.to")) return { shortId: short[2] };
|
|
3052
|
+
}
|
|
3053
|
+
throw new CliError(
|
|
3054
|
+
`<page> \u304C\u8AAD\u3081\u307E\u305B\u3093: ${terminalLine(input)}`,
|
|
3055
|
+
2,
|
|
3056
|
+
"UUID\u30016 \u6587\u5B57\u306E shortId\u3001\u753B\u9762\u306E URL(\u2026/projects/<id>/wiki/<page-id>)\u3001\u77ED\u3044 URL(https://nol.to/w/<shortId>)\u306E\u3069\u308C\u304B\u3067\u6307\u5B9A\u3059\u308B"
|
|
3057
|
+
);
|
|
3058
|
+
}
|
|
3059
|
+
function checkedId(value) {
|
|
3060
|
+
if (typeof value !== "string" || !isUuid(value)) throw new CliError("\u30B5\u30FC\u30D0\u30FC\u306E\u5FDC\u7B54\u304C\u4E0D\u6B63\u3067\u3059(\u30DA\u30FC\u30B8\u306E id \u304C UUID \u3067\u306F\u3042\u308A\u307E\u305B\u3093)\u3002", 5);
|
|
3061
|
+
return value;
|
|
3062
|
+
}
|
|
3063
|
+
async function resolvePageId(http, projectId, ref) {
|
|
3064
|
+
const sameProject = (other) => other.toLowerCase() === projectId.toLowerCase();
|
|
3065
|
+
if ("pageId" in ref) {
|
|
3066
|
+
if (ref.projectId !== void 0 && !sameProject(ref.projectId)) throw wrongProject();
|
|
3067
|
+
return ref.pageId;
|
|
3068
|
+
}
|
|
3069
|
+
let targets;
|
|
3070
|
+
try {
|
|
3071
|
+
targets = (await http.get(`/api/links/resolve?path=w/${ref.shortId}`)).targets ?? [];
|
|
3072
|
+
} catch (error) {
|
|
3073
|
+
if (error instanceof CliError && error.status === 404) throw notFound();
|
|
3074
|
+
throw error;
|
|
3075
|
+
}
|
|
3076
|
+
const pages = targets.filter((target) => target.kind === "wiki" && typeof target.pageId === "string" && typeof target.projectId === "string");
|
|
3077
|
+
if (pages.length === 0) throw notFound();
|
|
3078
|
+
const page = pages.find((target) => sameProject(target.projectId));
|
|
3079
|
+
if (!page) throw wrongProject();
|
|
3080
|
+
return checkedId(page.pageId);
|
|
3081
|
+
}
|
|
3082
|
+
function mapWikiError(error) {
|
|
3083
|
+
const body = error.body ?? {};
|
|
3084
|
+
const keep = [error.status, error.serverError, error.body];
|
|
3085
|
+
if (error.status === 409 && error.serverError === "wiki_revision_conflict") {
|
|
3086
|
+
const latest2 = body.latestRevision;
|
|
3087
|
+
return new CliError(
|
|
3088
|
+
typeof latest2 === "number" ? `\u30DA\u30FC\u30B8\u306F\u7248 ${latest2} \u306B\u66F4\u65B0\u3055\u308C\u3066\u3044\u307E\u3059\u3002` : "\u30DA\u30FC\u30B8\u306F\u3001\u8AAD\u3093\u3060\u5F8C\u306B\u66F4\u65B0\u3055\u308C\u3066\u3044\u307E\u3059\u3002",
|
|
3089
|
+
2,
|
|
3090
|
+
`nolto wiki view \u3067\u6700\u65B0\u306E\u5185\u5BB9\u3092\u78BA\u304B\u3081\u3066\u304B\u3089\u3001--base-revision ${typeof latest2 === "number" ? latest2 : "<\u7248>"} \u3067\u66F4\u65B0\u3057\u3066\u304F\u3060\u3055\u3044`,
|
|
3091
|
+
...keep
|
|
3092
|
+
);
|
|
3093
|
+
}
|
|
3094
|
+
if (error.status === 400 && error.serverError?.includes("\u4E0D\u660E\u306A\u9805\u76EE\u304C\u3042\u308A\u307E\u3059") && error.serverError.includes("baseRevision")) {
|
|
3095
|
+
return new CliError(
|
|
3096
|
+
"\u63A5\u7D9A\u5148\u306E Nolto \u304C\u307E\u3060 --base-revision \u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002",
|
|
3097
|
+
2,
|
|
3098
|
+
"--base-revision \u3092\u5916\u3059\u3068\u3001\u5F8C\u304B\u3089\u4FDD\u5B58\u3057\u305F\u65B9\u304C\u6B8B\u308A\u307E\u3059",
|
|
3099
|
+
...keep
|
|
3100
|
+
);
|
|
3101
|
+
}
|
|
3102
|
+
if (error.status === 409 && error.serverError === "share_visibility_change") {
|
|
3103
|
+
const direction = body.direction === "in" ? "\u793E\u5185\u306E\u307F \u2192 \u304A\u5BA2\u3055\u307E\u306B\u516C\u958B" : "\u304A\u5BA2\u3055\u307E\u306B\u516C\u958B \u2192 \u793E\u5185\u306E\u307F";
|
|
3104
|
+
const count2 = typeof body.count === "number" ? body.count : "\u8907\u6570";
|
|
3105
|
+
return new CliError(
|
|
3106
|
+
`\u3053\u306E\u79FB\u52D5\u3067 ${count2} \u30DA\u30FC\u30B8\u306E\u516C\u958B\u7BC4\u56F2\u304C\u5909\u308F\u308A\u307E\u3059(${direction})\u3002`,
|
|
3107
|
+
2,
|
|
3108
|
+
"\u78BA\u304B\u3081\u3066\u304B\u3089 --confirm-share \u3092\u4ED8\u3051\u3066\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
3109
|
+
...keep
|
|
3110
|
+
);
|
|
3111
|
+
}
|
|
3112
|
+
if (error.status === 404 && error.serverError === "\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002") {
|
|
3113
|
+
return new CliError(error.message, error.exitCode, "Wiki \u304C OFF \u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304B\u3001Wiki \u3092\u4F7F\u3048\u306A\u3044\u30E1\u30F3\u30D0\u30FC\u306E\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059", ...keep);
|
|
3114
|
+
}
|
|
3115
|
+
return error;
|
|
3116
|
+
}
|
|
3117
|
+
function wikiUrl(baseUrl, projectId, pageId2) {
|
|
3118
|
+
return `${baseUrl.replace(/\/+$/, "")}/projects/${encodeURIComponent(projectId)}/wiki/${pageId2}`;
|
|
3119
|
+
}
|
|
3120
|
+
function formatWikiList(pages) {
|
|
3121
|
+
if (pages.length === 0) return "\u30DA\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093";
|
|
3122
|
+
const ids = new Set(pages.map((page) => page.id));
|
|
3123
|
+
const children = /* @__PURE__ */ new Map();
|
|
3124
|
+
for (const page of pages) {
|
|
3125
|
+
const key = page.parentId !== null && ids.has(page.parentId) ? page.parentId : null;
|
|
3126
|
+
children.set(key, [...children.get(key) ?? [], page]);
|
|
3127
|
+
}
|
|
3128
|
+
const lines = [];
|
|
3129
|
+
const walk = (parentId, depth) => {
|
|
3130
|
+
const siblings = [...children.get(parentId) ?? []].sort((a, b) => a.position - b.position || (a.title < b.title ? -1 : a.title > b.title ? 1 : 0));
|
|
3131
|
+
for (const page of siblings) {
|
|
3132
|
+
const mark = page.shareRoot ? " [\u5171\u6709\u30EB\u30FC\u30C8]" : page.shared ? " [\u5171\u6709\u4E2D]" : "";
|
|
3133
|
+
lines.push(`${" ".repeat(depth)}${terminalLine(page.title)} (${terminalLine(page.shortId)})${mark}`);
|
|
3134
|
+
walk(page.id, depth + 1);
|
|
3135
|
+
}
|
|
3136
|
+
};
|
|
3137
|
+
walk(null, 0);
|
|
3138
|
+
return lines.join("\n");
|
|
3139
|
+
}
|
|
3140
|
+
function hasSecretMark(body) {
|
|
3141
|
+
return secretMark.test(body);
|
|
3142
|
+
}
|
|
3143
|
+
function formatWikiView(bundle, url) {
|
|
3144
|
+
const page = bundle.page;
|
|
3145
|
+
const attributes = formatRecord({
|
|
3146
|
+
title: terminalLine(page.title),
|
|
3147
|
+
shortId: terminalLine(page.shortId),
|
|
3148
|
+
revision: bundle.latestRevision === null ? "-" : String(bundle.latestRevision),
|
|
3149
|
+
updatedBy: terminalLine(page.updatedBy?.displayName ?? "\u2014"),
|
|
3150
|
+
updatedAt: terminalLine(formatTimestamp(page.updatedAt)),
|
|
3151
|
+
url: terminalLine(url)
|
|
3152
|
+
});
|
|
3153
|
+
return [attributes, terminalText(page.body), ...hasSecretMark(page.body) ? [secretNote] : []].join("\n\n");
|
|
3154
|
+
}
|
|
3155
|
+
function formatWikiSearch(results) {
|
|
3156
|
+
if (results.length === 0) return "\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F";
|
|
3157
|
+
return results.map((result) => [
|
|
3158
|
+
[result.id, result.title, formatTimestamp(result.updatedAt)].filter(Boolean).map(terminalLine).join(" "),
|
|
3159
|
+
` ${terminalLine(result.snippet)}`
|
|
3160
|
+
].join("\n")).join("\n");
|
|
3161
|
+
}
|
|
3162
|
+
function formatWikiWrite(verb, page, project, url, warnings) {
|
|
3163
|
+
const notes = warningLines(warnings);
|
|
3164
|
+
return `\u300C${terminalLine(page.title)}\u300D\u3092${verb}\u3057\u307E\u3057\u305F
|
|
3165
|
+
shortId: ${terminalLine(page.shortId)}${project}
|
|
3166
|
+
${url}${notes}${notes ? warningNote : ""}`;
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3169
|
+
// src/commands/wiki.ts
|
|
3170
|
+
function context2(deps, command) {
|
|
3171
|
+
if (!deps.settings.token) throw new CliError("Not authenticated. Run `nolto login` or set NOLTO_TOKEN.", 3);
|
|
3172
|
+
const globals = command.optsWithGlobals();
|
|
3173
|
+
const projectId = globals.project ?? deps.settings.projectId;
|
|
3174
|
+
if (!projectId) throw projectRequiredError();
|
|
3175
|
+
return { projectId, root: `/api/projects/${encodeURIComponent(projectId)}`, mode: globals.json ? "json" : deps.output.mode };
|
|
3176
|
+
}
|
|
3177
|
+
async function projectLine2(deps, ctx) {
|
|
3178
|
+
if (ctx.mode === "json") return "";
|
|
3179
|
+
const result = await deps.http.get(ctx.root).catch(() => null);
|
|
3180
|
+
return `
|
|
3181
|
+
\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: ${terminalLine(result?.project?.name || ctx.projectId)}`;
|
|
3182
|
+
}
|
|
3183
|
+
async function wikiCall(call) {
|
|
3184
|
+
try {
|
|
3185
|
+
return await call();
|
|
3186
|
+
} catch (error) {
|
|
3187
|
+
throw error instanceof CliError ? mapWikiError(error) : error;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
function integer(value, flag, min) {
|
|
3191
|
+
if (value === void 0) return void 0;
|
|
3192
|
+
const parsed = Number(value);
|
|
3193
|
+
if (!/^\d+$/.test(value) || !Number.isSafeInteger(parsed) || parsed < min) throw new CliError(`${flag} must be an integer of ${min} or more.`, 2);
|
|
3194
|
+
return parsed;
|
|
3195
|
+
}
|
|
3196
|
+
var pageId = (deps, ctx, input) => resolvePageId(deps.http, ctx.projectId, parsePageRef(input));
|
|
3197
|
+
function register5(program, deps) {
|
|
3198
|
+
const group = program.command("wiki").description("List, view and manage project wiki pages.").addHelpText("after", `
|
|
3199
|
+
<page> is a UUID, a 6-character shortId, a page URL (\u2026/projects/<id>/wiki/<page-id>) or a short URL (https://nol.to/w/<shortId>).
|
|
3200
|
+
All commands accept global \`--project <id>\`, \`--json\`, \`--token <value>\` and \`--base-url <url>\`.
|
|
3201
|
+
Project priority: flag \u2192 NOLTO_PROJECT \u2192 nearest ancestor nolto.json. Git is not required. An invalid nolto.json remains an error.
|
|
3202
|
+
Delete, revision history/restore and attachments are not available here; use the web app.
|
|
3203
|
+
|
|
3204
|
+
Round trip (use --base-revision so a page saved by someone else in between is not overwritten):
|
|
3205
|
+
nolto wiki view <page> # note "revision"
|
|
3206
|
+
nolto wiki view <page> --output page.md # writes the body exactly as stored
|
|
3207
|
+
nolto wiki update <page> --body-file page.md --base-revision <revision>
|
|
3208
|
+
--body-only is for reading in a terminal (control characters are replaced); do not use it for the round trip.
|
|
3209
|
+
|
|
3210
|
+
Secrets: view shows a \`\`\`secret id=\u2026 line instead of the value. Keep that line when you send the body back.
|
|
3211
|
+
To store a new secret, write a \`\`\`secret <name> fence; it is encrypted when saved.
|
|
3212
|
+
|
|
3213
|
+
| Exit | Meaning |
|
|
3214
|
+
|---|---|
|
|
3215
|
+
| 0 | Success |
|
|
3216
|
+
| 2 | Invalid input, unreadable or other-project <page>, recognized API 404, HTTP 422 (details shown), 409 wiki_revision_conflict (view again), 409 share_visibility_change (confirm, then --confirm-share) |
|
|
3217
|
+
| 3 | HTTP 401/403; token_scope/token_project includes a token settings hint |
|
|
3218
|
+
| 4 | HTTP 402/429 (quota/rate limit). API token writes: 60/minute. On 429, wait Retry-After seconds before retrying. |
|
|
3219
|
+
| 5 | Network/generic HTTP errors, including a 404 without an API error string |
|
|
3220
|
+
`);
|
|
3221
|
+
group.command("list").description("List pages as a tree.").action(async (_flags, command) => {
|
|
3222
|
+
const ctx = context2(deps, command);
|
|
3223
|
+
const result = await wikiCall(() => deps.http.get(`${ctx.root}/wiki/pages`));
|
|
3224
|
+
printResult(ctx.mode === "json" ? result : formatWikiList(result.pages), ctx.mode);
|
|
3225
|
+
});
|
|
3226
|
+
group.command("view <page>").description("Show a page.").option("--body-only", "Print only the body for reading (control characters are replaced; not for sending back with update)").option("--output <path>", "Write the body to a file exactly as stored (for editing and sending back with update)").action(async (page, flags, command) => {
|
|
3227
|
+
const ctx = context2(deps, command);
|
|
3228
|
+
if (flags.output !== void 0 && flags.bodyOnly) throw new CliError("--output and --body-only cannot be used together.", 2);
|
|
3229
|
+
const id = await pageId(deps, ctx, page);
|
|
3230
|
+
const result = await wikiCall(() => deps.http.get(`${ctx.root}/wiki/pages/${id}`));
|
|
3231
|
+
if (flags.output !== void 0) {
|
|
3232
|
+
try {
|
|
3233
|
+
await writeFile8(flags.output, result.page.body, "utf8");
|
|
3234
|
+
} catch (error) {
|
|
3235
|
+
throw new CliError(`Cannot write body to ${flags.output}: ${String(error)}`, 2);
|
|
3236
|
+
}
|
|
3237
|
+
printResult(ctx.mode === "json" ? result : `${terminalLine(flags.output)} \u306B\u672C\u6587\u3092\u66F8\u304D\u307E\u3057\u305F(\u7248 ${result.latestRevision ?? "-"})`, ctx.mode);
|
|
3238
|
+
return;
|
|
3239
|
+
}
|
|
3240
|
+
const human = flags.bodyOnly ? result.page.body.replace(/\n+$/, "") : formatWikiView(result, wikiUrl(deps.settings.baseUrl, ctx.projectId, checkedId(result.page.id)));
|
|
3241
|
+
printResult(ctx.mode === "json" ? result : human, ctx.mode);
|
|
3242
|
+
});
|
|
3243
|
+
group.command("search <query>").description("Search pages by text.").action(async (query, _flags, command) => {
|
|
3244
|
+
const ctx = context2(deps, command);
|
|
3245
|
+
if (query.trim() === "") throw new CliError("<query> must not be empty.", 2);
|
|
3246
|
+
if (Array.from(query).length > wikiSearchMaxLength) throw new CliError(`<query> must be ${wikiSearchMaxLength} characters or fewer.`, 2);
|
|
3247
|
+
const result = await wikiCall(() => deps.http.get(`${ctx.root}/wiki/search?q=${encodeURIComponent(query)}`));
|
|
3248
|
+
printResult(ctx.mode === "json" ? result : formatWikiSearch(result.results), ctx.mode);
|
|
3249
|
+
});
|
|
3250
|
+
async function write(ctx, verb, send) {
|
|
3251
|
+
const result = await wikiCall(send);
|
|
3252
|
+
const url = wikiUrl(deps.settings.baseUrl, ctx.projectId, checkedId(result.page?.id));
|
|
3253
|
+
const project = await projectLine2(deps, ctx);
|
|
3254
|
+
printResult(ctx.mode === "json" ? result : formatWikiWrite(verb, result.page, project, url, result.warnings), ctx.mode);
|
|
3255
|
+
}
|
|
3256
|
+
group.command("create").description("Create a page.").requiredOption("--title <text>", "Page title").option("--body <text>", "Page body (Markdown)").option("--body-file <path>", "Read body from file (- for stdin)").option("--parent <page>", "Parent page (default: top level)").action(async (flags, command) => {
|
|
3257
|
+
const ctx = context2(deps, command);
|
|
3258
|
+
const body = await bodyText(flags.body, flags.bodyFile);
|
|
3259
|
+
const parentId = flags.parent === void 0 ? void 0 : await pageId(deps, ctx, flags.parent);
|
|
3260
|
+
await write(ctx, "\u4F5C\u6210", () => deps.http.post(
|
|
3261
|
+
`${ctx.root}/wiki/pages`,
|
|
3262
|
+
{ title: flags.title, ...body !== void 0 ? { body } : {}, ...parentId !== void 0 ? { parentId } : {} }
|
|
3263
|
+
));
|
|
3264
|
+
});
|
|
3265
|
+
group.command("update <page>").description("Update a page title and/or body.").option("--title <text>", "Page title").option("--body <text>", "Page body (Markdown)").option("--body-file <path>", "Read body from file (- for stdin)").option("--base-revision <n>", "Fail with a conflict if the page was saved after this revision (see `view`)").action(async (page, flags, command) => {
|
|
3266
|
+
const ctx = context2(deps, command);
|
|
3267
|
+
const body = await bodyText(flags.body, flags.bodyFile);
|
|
3268
|
+
if (flags.title === void 0 && body === void 0) throw new CliError("No changes. Pass --title, --body or --body-file.", 2);
|
|
3269
|
+
const baseRevision = integer(flags.baseRevision, "--base-revision", 1);
|
|
3270
|
+
const id = await pageId(deps, ctx, page);
|
|
3271
|
+
await write(ctx, "\u66F4\u65B0", () => deps.http.patch(
|
|
3272
|
+
`${ctx.root}/wiki/pages/${id}`,
|
|
3273
|
+
{
|
|
3274
|
+
...flags.title !== void 0 ? { title: flags.title } : {},
|
|
3275
|
+
...body !== void 0 ? { body } : {},
|
|
3276
|
+
...baseRevision !== void 0 ? { baseRevision } : {}
|
|
3277
|
+
}
|
|
3278
|
+
));
|
|
3279
|
+
});
|
|
3280
|
+
group.command("move <page>").description("Move a page under another page (or to the top level).").requiredOption("--parent <page|none>", "New parent page, or none for the top level").requiredOption("--position <n>", "Position among the siblings, from 0").option("--confirm-share", "Move even if it changes which pages customers can see. Use only after a 409 share_visibility_change and the user's go-ahead.").action(async (page, flags, command) => {
|
|
3281
|
+
const ctx = context2(deps, command);
|
|
3282
|
+
const position = integer(flags.position, "--position", 0);
|
|
3283
|
+
const id = await pageId(deps, ctx, page);
|
|
3284
|
+
const parentId = flags.parent === "none" ? null : await pageId(deps, ctx, flags.parent);
|
|
3285
|
+
await write(ctx, "\u79FB\u52D5", () => deps.http.patch(
|
|
3286
|
+
`${ctx.root}/wiki/pages/${id}/move`,
|
|
3287
|
+
{ parentId, position, ...flags.confirmShare ? { confirmShare: true } : {} }
|
|
3288
|
+
));
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
|
|
2987
3292
|
// src/memory-import.ts
|
|
2988
3293
|
import { readFile as readFile12, readdir as readdir6, rm as rm3 } from "fs/promises";
|
|
2989
3294
|
import path16 from "path";
|
|
@@ -3115,7 +3420,7 @@ function detectMemoryClient(env) {
|
|
|
3115
3420
|
}
|
|
3116
3421
|
|
|
3117
3422
|
// src/memory-cache.ts
|
|
3118
|
-
import { mkdir as mkdir7, readFile as readFile11, readdir as readdir5, rename as rename4, rm as rm2, unlink as unlink4, writeFile as
|
|
3423
|
+
import { mkdir as mkdir7, readFile as readFile11, readdir as readdir5, rename as rename4, rm as rm2, unlink as unlink4, writeFile as writeFile9 } from "fs/promises";
|
|
3119
3424
|
import { createHash as createHash3, randomUUID as randomUUID6 } from "crypto";
|
|
3120
3425
|
import path15 from "path";
|
|
3121
3426
|
function memoryDir(configPath, project) {
|
|
@@ -3156,7 +3461,7 @@ async function atomicMemoryFile(file, content) {
|
|
|
3156
3461
|
await mkdir7(path15.dirname(file), { recursive: true, mode: 448 });
|
|
3157
3462
|
const temp = `${file}.tmp-${randomUUID6()}`;
|
|
3158
3463
|
try {
|
|
3159
|
-
await
|
|
3464
|
+
await writeFile9(temp, content, { mode: 292 });
|
|
3160
3465
|
await unlink4(file).catch((error) => {
|
|
3161
3466
|
if (error.code !== "ENOENT") throw error;
|
|
3162
3467
|
});
|
|
@@ -3210,16 +3515,16 @@ async function saveMemoryCache(dir, cache, previous, index, reset = false) {
|
|
|
3210
3515
|
await atomicMemoryFile(path15.join(dir, ".meta.json"), JSON.stringify(cache.meta) + "\n");
|
|
3211
3516
|
return unsafe;
|
|
3212
3517
|
}
|
|
3213
|
-
function currentMemoryEntries(entries,
|
|
3214
|
-
return entries.filter((e) => !e.deleted && storableMemoryEntry(e) && (e.scope !== "branch" || allBranches ||
|
|
3518
|
+
function currentMemoryEntries(entries, context4, allBranches = false) {
|
|
3519
|
+
return entries.filter((e) => !e.deleted && storableMemoryEntry(e) && (e.scope !== "branch" || allBranches || context4.branch !== context4.defaultBranch && e.repoIdentity === context4.repoIdentity && e.branch === context4.branch));
|
|
3215
3520
|
}
|
|
3216
3521
|
var scopeOrder = ["project", "user", "branch"];
|
|
3217
3522
|
function sortMemoryEntries(entries) {
|
|
3218
3523
|
return entries.sort((a, b) => scopeOrder.indexOf(a.scope) - scopeOrder.indexOf(b.scope) || b.updatedAt.localeCompare(a.updatedAt) || a.name.localeCompare(b.name));
|
|
3219
3524
|
}
|
|
3220
3525
|
var MEMORY_INDEX_MAX_CHARS = 9500;
|
|
3221
|
-
function currentCleanupCandidates(state,
|
|
3222
|
-
const entries = currentMemoryEntries(state.entries,
|
|
3526
|
+
function currentCleanupCandidates(state, context4) {
|
|
3527
|
+
const entries = currentMemoryEntries(state.entries, context4);
|
|
3223
3528
|
const live = new Map(entries.map((e) => [e.id, e]));
|
|
3224
3529
|
return (state.cleanupCandidates ?? []).flatMap((candidate) => {
|
|
3225
3530
|
const entry = live.get(candidate.entryId);
|
|
@@ -3228,28 +3533,28 @@ function currentCleanupCandidates(state, context3) {
|
|
|
3228
3533
|
return [{ ...candidate, scope: entry.scope, name: entry.name, repoIdentity: entry.repoIdentity, branch: entry.branch }];
|
|
3229
3534
|
});
|
|
3230
3535
|
}
|
|
3231
|
-
function hasSharedMemoryName(entry, entries,
|
|
3232
|
-
return currentMemoryEntries(entries,
|
|
3536
|
+
function hasSharedMemoryName(entry, entries, context4) {
|
|
3537
|
+
return currentMemoryEntries(entries, context4).some((e) => e.name === entry.name && e.scope !== entry.scope);
|
|
3233
3538
|
}
|
|
3234
|
-
function cleanupSection(candidates, entries,
|
|
3539
|
+
function cleanupSection(candidates, entries, context4, limit = 10) {
|
|
3235
3540
|
if (!candidates.length) return [];
|
|
3236
3541
|
return [
|
|
3237
3542
|
"## \u6574\u7406\u5019\u88DC(\u78BA\u304B\u3081\u3066\u6D88\u3059\u306A\u3089 nolto memory rm <name>)",
|
|
3238
3543
|
...candidates.slice(0, limit).map((c) => {
|
|
3239
|
-
const shared = hasSharedMemoryName(c, entries,
|
|
3544
|
+
const shared = hasSharedMemoryName(c, entries, context4);
|
|
3240
3545
|
return `- ${shared ? `${c.scope}/` : ""}${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`;
|
|
3241
3546
|
}),
|
|
3242
3547
|
...candidates.length > limit ? [`\u307B\u304B ${candidates.length - limit} \u4EF6: nolto memory candidates`] : []
|
|
3243
3548
|
];
|
|
3244
3549
|
}
|
|
3245
|
-
function memoryIndex(cache,
|
|
3246
|
-
const branch =
|
|
3247
|
-
const candidates = currentCleanupCandidates(cache.state,
|
|
3550
|
+
function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
|
|
3551
|
+
const branch = context4.branch && context4.branch !== context4.defaultBranch ? context4.branch : null;
|
|
3552
|
+
const candidates = currentCleanupCandidates(cache.state, context4);
|
|
3248
3553
|
const candidateIds = new Set(candidates.map((c) => c.entryId));
|
|
3249
|
-
const entries = sortMemoryEntries(currentMemoryEntries(cache.state.entries,
|
|
3554
|
+
const entries = sortMemoryEntries(currentMemoryEntries(cache.state.entries, context4).filter((e) => !candidateIds.has(e.id)));
|
|
3250
3555
|
let candidateLimit = Math.min(10, candidates.length);
|
|
3251
3556
|
const groups = ["project", "user", ...branch ? ["branch"] : []];
|
|
3252
|
-
const mergedLines = [...merged].sort().map((b) => `merge \u6E08\u307F\u306E ${terminalLine(b)} \u306B ${cache.state.entries.filter((e) => !e.deleted && e.scope === "branch" && e.repoIdentity ===
|
|
3557
|
+
const mergedLines = [...merged].sort().map((b) => `merge \u6E08\u307F\u306E ${terminalLine(b)} \u306B ${cache.state.entries.filter((e) => !e.deleted && e.scope === "branch" && e.repoIdentity === context4.repoIdentity && e.branch === b).length} \u4EF6: nolto memory promote --branch ${commandArg(b, "<branch>")}`);
|
|
3253
3558
|
let omitted = 0;
|
|
3254
3559
|
const build = () => [
|
|
3255
3560
|
`# Nolto memory \u2014 ${terminalLine(cache.state.projectName)}(\u540C\u671F ${cache.meta.pulledAt ? new Date(cache.meta.pulledAt).toTimeString().slice(0, 5) : "\u672A\u540C\u671F"}${branch ? `\u3001branch ${terminalLine(branch)}` : ""})`,
|
|
@@ -3260,7 +3565,7 @@ function memoryIndex(cache, context3, merged = /* @__PURE__ */ new Set(), dir) {
|
|
|
3260
3565
|
const lines2 = entries.filter((e) => e.scope === scope).map((e) => `- ${terminalLine(e.name)} \u2014 ${terminalLine(e.description)}`);
|
|
3261
3566
|
return lines2.length ? [`## ${scope === "branch" ? `branch ${terminalLine(branch)}` : scope}`, ...lines2] : [];
|
|
3262
3567
|
}),
|
|
3263
|
-
...cleanupSection(candidates, cache.state.entries,
|
|
3568
|
+
...cleanupSection(candidates, cache.state.entries, context4, candidateLimit),
|
|
3264
3569
|
...mergedLines,
|
|
3265
3570
|
...omitted ? [`\u6B8B\u308A ${omitted} \u4EF6: nolto memory list`] : []
|
|
3266
3571
|
];
|
|
@@ -3318,9 +3623,9 @@ async function memoryGitContext(root, deps) {
|
|
|
3318
3623
|
}
|
|
3319
3624
|
return result;
|
|
3320
3625
|
}
|
|
3321
|
-
async function mergedMemoryBranches(branches,
|
|
3626
|
+
async function mergedMemoryBranches(branches, context4, root, git, mine = /* @__PURE__ */ new Set()) {
|
|
3322
3627
|
const merged = /* @__PURE__ */ new Set();
|
|
3323
|
-
if (!
|
|
3628
|
+
if (!context4.defaultBranch || !context4.repoIdentity) return merged;
|
|
3324
3629
|
const hasRef = async (ref) => {
|
|
3325
3630
|
try {
|
|
3326
3631
|
await git(["show-ref", "--verify", "--quiet", ref], root);
|
|
@@ -3333,13 +3638,13 @@ async function mergedMemoryBranches(branches, context3, root, git, mine = /* @__
|
|
|
3333
3638
|
let checkedOut, target, targetTip;
|
|
3334
3639
|
try {
|
|
3335
3640
|
checkedOut = new Set((await git(["worktree", "list", "--porcelain"], root)).split("\n").filter((l) => l.startsWith("branch refs/heads/")).map((l) => l.slice("branch refs/heads/".length)));
|
|
3336
|
-
target = await hasRef(`refs/heads/${
|
|
3641
|
+
target = await hasRef(`refs/heads/${context4.defaultBranch}`) ? `refs/heads/${context4.defaultBranch}` : `refs/remotes/origin/${context4.defaultBranch}`;
|
|
3337
3642
|
targetTip = await git(["rev-parse", target], root);
|
|
3338
3643
|
} catch {
|
|
3339
3644
|
return merged;
|
|
3340
3645
|
}
|
|
3341
3646
|
for (const branch of branches) {
|
|
3342
|
-
if (branch ===
|
|
3647
|
+
if (branch === context4.defaultBranch || branch === context4.branch || checkedOut.has(branch)) continue;
|
|
3343
3648
|
try {
|
|
3344
3649
|
const local = `refs/heads/${branch}`;
|
|
3345
3650
|
if (await hasRef(local)) {
|
|
@@ -3681,7 +3986,7 @@ async function setupMemory(opts) {
|
|
|
3681
3986
|
else writeOut(`memory: Claude Code \u306E\u81EA\u52D5\u30E1\u30E2\u30EA\u505C\u6B62${result === "already" ? "\u306F\u8A2D\u5B9A\u6E08\u307F" : "\u3092\u8A2D\u5B9A\u3057\u307E\u3057\u305F"}
|
|
3682
3987
|
`);
|
|
3683
3988
|
}
|
|
3684
|
-
function
|
|
3989
|
+
function register6(program, deps) {
|
|
3685
3990
|
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) => {
|
|
3686
3991
|
const configPath = deps.configPath;
|
|
3687
3992
|
const rl = readline3.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -3709,7 +4014,9 @@ function register5(program, deps) {
|
|
|
3709
4014
|
if (configureGlobal) {
|
|
3710
4015
|
const rawUrl = await rl.question(`Base URL [${DEFAULT_BASE_URL}]: `);
|
|
3711
4016
|
baseUrl = rawUrl.trim() || DEFAULT_BASE_URL;
|
|
3712
|
-
|
|
4017
|
+
validateBaseUrl(baseUrl);
|
|
4018
|
+
const issuedElsewhere = deps.settings.source.token === "file" && originOf(baseUrl) !== originOf(deps.settings.baseUrl);
|
|
4019
|
+
const currentToken = issuedElsewhere ? void 0 : deps.settings.token;
|
|
3713
4020
|
const tokenPrompt = currentToken != null ? "API token [press Enter to keep current token]: " : "API token: ";
|
|
3714
4021
|
const enteredToken = await promptHidden(rl, tokenPrompt);
|
|
3715
4022
|
token = enteredToken.length > 0 ? enteredToken : currentToken ?? "";
|
|
@@ -3960,7 +4267,7 @@ function sleep(ms) {
|
|
|
3960
4267
|
}
|
|
3961
4268
|
|
|
3962
4269
|
// src/commands/login.ts
|
|
3963
|
-
function
|
|
4270
|
+
function register7(program, deps) {
|
|
3964
4271
|
program.command("login").description("Authenticate via browser and save an API token to the config file.").option("--force", "Overwrite existing token without prompting").action(
|
|
3965
4272
|
async (opts) => {
|
|
3966
4273
|
const { configPath, settings, output } = deps;
|
|
@@ -4005,11 +4312,11 @@ function register6(program, deps) {
|
|
|
4005
4312
|
throw err;
|
|
4006
4313
|
}
|
|
4007
4314
|
writeOut("\n");
|
|
4008
|
-
writeOut("Open the following URL in your browser
|
|
4315
|
+
writeOut("Open the following URL in your browser and enter the confirmation code shown below:\n\n");
|
|
4009
4316
|
writeOut(` ${startResp.verification_url}
|
|
4010
4317
|
|
|
4011
4318
|
`);
|
|
4012
|
-
writeOut(`
|
|
4319
|
+
writeOut(` Confirmation code: ${startResp.user_code}
|
|
4013
4320
|
|
|
4014
4321
|
`);
|
|
4015
4322
|
writeOut("Waiting for browser confirmation...\n");
|
|
@@ -4020,9 +4327,8 @@ function register6(program, deps) {
|
|
|
4020
4327
|
expiresIn: startResp.expires_in,
|
|
4021
4328
|
baseUrl: settings.baseUrl
|
|
4022
4329
|
});
|
|
4023
|
-
const existingConfig = await loadConfigFile(configPath).catch(() => null);
|
|
4024
4330
|
const newConfig = {
|
|
4025
|
-
baseUrl:
|
|
4331
|
+
baseUrl: settings.baseUrl,
|
|
4026
4332
|
token
|
|
4027
4333
|
};
|
|
4028
4334
|
await clearMemoryCaches(configPath);
|
|
@@ -4042,8 +4348,50 @@ function register6(program, deps) {
|
|
|
4042
4348
|
);
|
|
4043
4349
|
}
|
|
4044
4350
|
|
|
4351
|
+
// src/commands/logout.ts
|
|
4352
|
+
function register8(program, deps) {
|
|
4353
|
+
program.command("logout").description("Revoke the saved API token and remove it from the config file.").action(async () => {
|
|
4354
|
+
const { configPath, settings, output } = deps;
|
|
4355
|
+
const existing = await loadConfigFile(configPath).catch(() => null);
|
|
4356
|
+
const fileToken = existing?.token;
|
|
4357
|
+
const envToken = settings.source.token === "env";
|
|
4358
|
+
let revoked = false;
|
|
4359
|
+
if (fileToken) {
|
|
4360
|
+
try {
|
|
4361
|
+
const issuedBy = existing?.baseUrl ?? DEFAULT_BASE_URL;
|
|
4362
|
+
validateBaseUrl(issuedBy);
|
|
4363
|
+
const http = createHttpClient({ baseUrl: issuedBy, version: deps.version, token: fileToken });
|
|
4364
|
+
await http.post("/api/me/token/revoke", {});
|
|
4365
|
+
revoked = true;
|
|
4366
|
+
} catch {
|
|
4367
|
+
}
|
|
4368
|
+
await clearMemoryCaches(configPath);
|
|
4369
|
+
await saveConfigFile(configPath, { baseUrl: existing?.baseUrl });
|
|
4370
|
+
}
|
|
4371
|
+
if (output.mode === "json") {
|
|
4372
|
+
printResult({ ok: true, revoked, removed: fileToken != null, envToken }, "json");
|
|
4373
|
+
return;
|
|
4374
|
+
}
|
|
4375
|
+
if (fileToken == null) writeOut("\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306B\u4FDD\u5B58\u3055\u308C\u305F token \u306F\u3042\u308A\u307E\u305B\u3093\u3002\n");
|
|
4376
|
+
else if (revoked) writeOut("token \u3092\u5931\u52B9\u3057\u3001\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u6D88\u3057\u307E\u3057\u305F\u3002\n");
|
|
4377
|
+
else writeErr("Warning: \u624B\u5143\u306E token \u306F\u6D88\u3057\u307E\u3057\u305F\u3002\u30B5\u30FC\u30D0\u30FC\u3067\u306E\u5931\u52B9\u3092\u78BA\u304B\u3081\u308B\u306B\u306F\u3001\u753B\u9762\u306E\u300EAPI \u30C8\u30FC\u30AF\u30F3\u300F\u3092\u958B\u3044\u3066\u304F\u3060\u3055\u3044\n");
|
|
4378
|
+
if (envToken) writeOut("\u74B0\u5883\u5909\u6570 NOLTO_TOKEN \u306E token \u306F\u6D88\u305B\u307E\u305B\u3093\u3002\u74B0\u5883\u5909\u6570\u3092\u5916\u3057\u3001\u753B\u9762\u306E\u300EAPI \u30C8\u30FC\u30AF\u30F3\u300F\u3067\u5931\u52B9\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n");
|
|
4379
|
+
});
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4045
4382
|
// src/commands/whoami.ts
|
|
4046
|
-
|
|
4383
|
+
var EXPIRY_WARNING_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
4384
|
+
function tokenExpiry(expiresAt) {
|
|
4385
|
+
if (!expiresAt) return void 0;
|
|
4386
|
+
const at = new Date(expiresAt);
|
|
4387
|
+
if (Number.isNaN(at.getTime())) return void 0;
|
|
4388
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
4389
|
+
return {
|
|
4390
|
+
date: `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`,
|
|
4391
|
+
soon: at.getTime() - Date.now() <= EXPIRY_WARNING_MS
|
|
4392
|
+
};
|
|
4393
|
+
}
|
|
4394
|
+
function register9(program, deps) {
|
|
4047
4395
|
program.command("whoami").description("Show the current authentication and configuration state.").action(async () => {
|
|
4048
4396
|
const { settings, output, configPath } = deps;
|
|
4049
4397
|
const mode2 = output.mode;
|
|
@@ -4068,6 +4416,7 @@ function register7(program, deps) {
|
|
|
4068
4416
|
} catch {
|
|
4069
4417
|
}
|
|
4070
4418
|
}
|
|
4419
|
+
const expiry = tokenExpiry(tokenInfo?.expiresAt);
|
|
4071
4420
|
const projectBindingPath = deps.repoBinding?.path ?? deps.projectBindingPath ?? null;
|
|
4072
4421
|
if (mode2 === "json") {
|
|
4073
4422
|
printResult(
|
|
@@ -4081,7 +4430,8 @@ function register7(program, deps) {
|
|
|
4081
4430
|
projectSource: settings.source.project,
|
|
4082
4431
|
projectBindingPath: projectBindingPath ?? null,
|
|
4083
4432
|
projects: projectCount ?? null,
|
|
4084
|
-
...tokenInfo ? { tokenScopes: tokenInfo.scopes, tokenProject: tokenInfo.projectId } : {}
|
|
4433
|
+
...tokenInfo ? { tokenScopes: tokenInfo.scopes, tokenProject: tokenInfo.projectId } : {},
|
|
4434
|
+
...tokenInfo?.expiresAt !== void 0 ? { tokenExpiresAt: tokenInfo.expiresAt } : {}
|
|
4085
4435
|
},
|
|
4086
4436
|
mode2
|
|
4087
4437
|
);
|
|
@@ -4097,11 +4447,16 @@ function register7(program, deps) {
|
|
|
4097
4447
|
];
|
|
4098
4448
|
if (tokenInfo) {
|
|
4099
4449
|
lines.push(["scopes", tokenInfo.scopes === null ? "full" : tokenInfo.scopes.join(", ")], ["tokenProject", tokenInfo.projectId ?? "all"]);
|
|
4450
|
+
if (tokenInfo.expiresAt !== void 0) lines.push(["expires", expiry?.date ?? "none"]);
|
|
4100
4451
|
}
|
|
4101
4452
|
const legacyConfig = await loadConfigFile(configPath).catch(() => null);
|
|
4102
4453
|
const maxKey = lines.reduce((m, [k]) => Math.max(m, k.length), 0);
|
|
4103
4454
|
for (const [key, val] of lines) {
|
|
4104
4455
|
writeOut(`${key.padEnd(maxKey)}: ${val}
|
|
4456
|
+
`);
|
|
4457
|
+
}
|
|
4458
|
+
if (expiry?.soon) {
|
|
4459
|
+
writeOut(`token \u306E\u671F\u9650\u306F ${expiry.date} \u3067\u3059\u3002\`nolto login\` \u3067\u53D6\u308A\u76F4\u305B\u307E\u3059
|
|
4105
4460
|
`);
|
|
4106
4461
|
}
|
|
4107
4462
|
if (legacyConfig?.defaultProjectId) {
|
|
@@ -4213,7 +4568,7 @@ function formatRoadmapDiff(slug, entries) {
|
|
|
4213
4568
|
}
|
|
4214
4569
|
|
|
4215
4570
|
// src/commands/diff.ts
|
|
4216
|
-
function
|
|
4571
|
+
function register10(program, deps) {
|
|
4217
4572
|
program.command("diff [slug]").description("Compare local roadmaps with the server without changing either side.").action(async (requestedSlug) => {
|
|
4218
4573
|
const { projectId } = await resolveRoadmapReadContext(deps);
|
|
4219
4574
|
const list = await deps.http.get(
|
|
@@ -4280,7 +4635,7 @@ function register8(program, deps) {
|
|
|
4280
4635
|
// src/commands/roadmap.ts
|
|
4281
4636
|
import { readFile as readFile14 } from "fs/promises";
|
|
4282
4637
|
import { existsSync as existsSync6 } from "fs";
|
|
4283
|
-
function
|
|
4638
|
+
function register11(program, deps) {
|
|
4284
4639
|
const roadmap = program.command("roadmap").description("Read and update server roadmaps through the local cache.");
|
|
4285
4640
|
roadmap.command("schema").description("Print the roadmap schema reference").action(async () => {
|
|
4286
4641
|
const bundled = new URL("./roadmap-schema-reference.md", import.meta.url);
|
|
@@ -4562,7 +4917,7 @@ async function installServiceWith(deps) {
|
|
|
4562
4917
|
deps.log("Service nolto-watch enabled and started. Logs: journalctl --user -u nolto-watch -f");
|
|
4563
4918
|
}
|
|
4564
4919
|
async function installService() {
|
|
4565
|
-
const { writeFile:
|
|
4920
|
+
const { writeFile: writeFile12, mkdir: mkdir9 } = await import("fs/promises");
|
|
4566
4921
|
const { execFile: execFile6 } = await import("child_process");
|
|
4567
4922
|
const { promisify: promisify5 } = await import("util");
|
|
4568
4923
|
const execFileAsync = promisify5(execFile6);
|
|
@@ -4572,7 +4927,7 @@ async function installService() {
|
|
|
4572
4927
|
env: process.env,
|
|
4573
4928
|
nodePath: process.execPath,
|
|
4574
4929
|
scriptPath: path19.resolve(process.argv[1] ?? ""),
|
|
4575
|
-
writeFile: (p, content, mode2) =>
|
|
4930
|
+
writeFile: (p, content, mode2) => writeFile12(p, content, mode2 === void 0 ? "utf8" : { encoding: "utf8", mode: mode2 }),
|
|
4576
4931
|
mkdir: async (p, mode2) => {
|
|
4577
4932
|
await mkdir9(p, mode2 === void 0 ? { recursive: true } : { recursive: true, mode: mode2 });
|
|
4578
4933
|
},
|
|
@@ -4705,7 +5060,7 @@ async function stopServiceWith(deps) {
|
|
|
4705
5060
|
}
|
|
4706
5061
|
|
|
4707
5062
|
// src/commands/watch.ts
|
|
4708
|
-
function
|
|
5063
|
+
function register12(program, deps) {
|
|
4709
5064
|
const watch = program.command("watch").description("Watch every registered repository's roadmap + plan files and sync on change.").option("--debounce <ms>", "Debounce window in milliseconds", "2000").option("--install-service", "Install and start a background service (systemd user unit on Linux, launchd agent on macOS) instead of watching").option("--uninstall-service", "Stop and remove the background service instead of watching").action(async (opts) => {
|
|
4710
5065
|
if (opts.installService && opts.uninstallService) {
|
|
4711
5066
|
throw new CliError("--install-service and --uninstall-service cannot be used together.", 2);
|
|
@@ -4923,7 +5278,7 @@ import { fileURLToPath as fileURLToPath3 } from "url";
|
|
|
4923
5278
|
import { promisify as promisify4 } from "util";
|
|
4924
5279
|
|
|
4925
5280
|
// src/update-notifier.ts
|
|
4926
|
-
import { readFile as readFile16, writeFile as
|
|
5281
|
+
import { readFile as readFile16, writeFile as writeFile10, mkdir as mkdir8 } from "fs/promises";
|
|
4927
5282
|
import https from "https";
|
|
4928
5283
|
import path21 from "path";
|
|
4929
5284
|
var VERSION_PATTERN = /^\d+\.\d+\.\d+$(?![\s\S])/;
|
|
@@ -4986,7 +5341,7 @@ function fetchLatestFromRegistry(timeoutMs = REQUEST_TIMEOUT_MS, opts = {}) {
|
|
|
4986
5341
|
async function writeUpdateCache(cachePath, now, latest2) {
|
|
4987
5342
|
await mkdir8(path21.dirname(cachePath), { recursive: true });
|
|
4988
5343
|
const payload = { checkedAt: now, latest: latest2 };
|
|
4989
|
-
await
|
|
5344
|
+
await writeFile10(cachePath, JSON.stringify(payload), { mode: 384 });
|
|
4990
5345
|
}
|
|
4991
5346
|
async function refreshCache(cachePath, now, fetchLatest) {
|
|
4992
5347
|
const latest2 = await fetchLatest();
|
|
@@ -5176,7 +5531,7 @@ async function updateCli(opts = {}) {
|
|
|
5176
5531
|
}
|
|
5177
5532
|
|
|
5178
5533
|
// src/commands/update.ts
|
|
5179
|
-
function
|
|
5534
|
+
function register13(program, deps) {
|
|
5180
5535
|
program.command("update").description("Update @nolto/cli to the latest version and restart the watch service if installed").action(async () => {
|
|
5181
5536
|
const mode2 = deps.output.mode;
|
|
5182
5537
|
const result = await updateCli({ quiet: mode2 === "json" });
|
|
@@ -5187,7 +5542,7 @@ function register11(program, deps) {
|
|
|
5187
5542
|
}
|
|
5188
5543
|
|
|
5189
5544
|
// src/commands/merge-file.ts
|
|
5190
|
-
import { readFile as readFile17, writeFile as
|
|
5545
|
+
import { readFile as readFile17, writeFile as writeFile11 } from "fs/promises";
|
|
5191
5546
|
|
|
5192
5547
|
// src/roadmap-merge.ts
|
|
5193
5548
|
import { isDeepStrictEqual } from "util";
|
|
@@ -5442,7 +5797,7 @@ async function readRoadmap(filePath) {
|
|
|
5442
5797
|
}
|
|
5443
5798
|
return parsed;
|
|
5444
5799
|
}
|
|
5445
|
-
function
|
|
5800
|
+
function register14(program) {
|
|
5446
5801
|
program.command("merge-file <ours> <theirs>").description(
|
|
5447
5802
|
'Structurally merge roadmap files for Git.\ngit config merge.nolto-roadmap.driver "nolto merge-file %A %B --base %O"'
|
|
5448
5803
|
).option("--base <path>", "Common ancestor roadmap file").option("--output <path>", "Write the result here (defaults to <ours>)").action(async (oursPath, theirsPath, opts) => {
|
|
@@ -5451,7 +5806,7 @@ function register12(program) {
|
|
|
5451
5806
|
const theirs = await readRoadmap(theirsPath);
|
|
5452
5807
|
const base = opts.base == null ? null : await readRoadmap(opts.base);
|
|
5453
5808
|
const merged = mergeRoadmaps({ base, ours, theirs });
|
|
5454
|
-
await
|
|
5809
|
+
await writeFile11(
|
|
5455
5810
|
opts.output ?? oursPath,
|
|
5456
5811
|
JSON.stringify(merged, null, 2) + "\n",
|
|
5457
5812
|
"utf8"
|
|
@@ -5469,7 +5824,7 @@ var aiSkipReasons = { timeout: "\u6642\u9593\u5207\u308C", limit: "\u4ECA\u65E5\
|
|
|
5469
5824
|
var aiSkippedLine = (reason) => `AI \u6574\u7406\u306A\u3057(${aiSkipReasons[reason] ?? terminalLine(reason)})`;
|
|
5470
5825
|
var pullHint = "nolto memory pull \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044";
|
|
5471
5826
|
var scopeHint = "--scope project|user|branch";
|
|
5472
|
-
async function
|
|
5827
|
+
async function context3(deps, recover = false) {
|
|
5473
5828
|
const project = deps.settings.projectId;
|
|
5474
5829
|
if (!project) throw projectRequiredError();
|
|
5475
5830
|
const root = findRepoRoot(resolveStartDir(process.env, process.cwd())).root;
|
|
@@ -5580,6 +5935,10 @@ async function pull2(deps, opts) {
|
|
|
5580
5935
|
if (opts.hook && !explicitProject && !(deps.repoBinding?.path ?? deps.projectBindingPath)) {
|
|
5581
5936
|
return;
|
|
5582
5937
|
}
|
|
5938
|
+
if (opts.hook && deps.settings.tokenOriginMismatch) {
|
|
5939
|
+
process.stdout.write(hookOutput(opts.hook, terminalLine(tokenOriginMismatchMessage(deps.settings.tokenOriginMismatch))));
|
|
5940
|
+
return;
|
|
5941
|
+
}
|
|
5583
5942
|
if (opts.hook && !deps.settings.token) {
|
|
5584
5943
|
process.stdout.write(hookOutput(opts.hook, "nolto login \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044"));
|
|
5585
5944
|
return;
|
|
@@ -5602,7 +5961,7 @@ async function pull2(deps, opts) {
|
|
|
5602
5961
|
}).then((latest2) => latest2 ? `nolto CLI ${latest2} \u304C\u516C\u958B\u3055\u308C\u3066\u3044\u307E\u3059(\u4ECA\u306F ${deps.version})\u3002\`nolto update\` \u3067\u66F4\u65B0\u3067\u304D\u307E\u3059\u3002
|
|
5603
5962
|
` : "").catch(() => "");
|
|
5604
5963
|
}
|
|
5605
|
-
ctx = await
|
|
5964
|
+
ctx = await context3(deps, true);
|
|
5606
5965
|
if (opts.hook && typeof opts.hook === "string" && !["claude", "codex", "gemini"].includes(opts.hook)) throw new CliError("Unknown hook agent", 2);
|
|
5607
5966
|
const scope = opts.scope ? [...new Set(opts.scope.split(",").map((s) => parseScope(s.trim(), scopeHint)))].sort().join(",") : "";
|
|
5608
5967
|
const previous = ctx.cache.state.entries;
|
|
@@ -5640,7 +5999,8 @@ async function pull2(deps, opts) {
|
|
|
5640
5999
|
} catch (error) {
|
|
5641
6000
|
if (!opts.hook) throw error;
|
|
5642
6001
|
let text = pullHint;
|
|
5643
|
-
if (
|
|
6002
|
+
if (error instanceof CliError && error.status === 401) text = TOKEN_EXPIRED_MESSAGE;
|
|
6003
|
+
else if (ctx?.cache.meta.pulledAt) {
|
|
5644
6004
|
try {
|
|
5645
6005
|
const age = Math.max(0, Math.floor((Date.now() - Date.parse(ctx.cache.meta.pulledAt)) / 6e4));
|
|
5646
6006
|
text = `(\u6700\u7D42\u540C\u671F ${Number.isFinite(age) ? age : "\u4E0D\u660E"} \u5206\u524D\u3002\u4ECA\u56DE\u306F\u540C\u671F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F)
|
|
@@ -5661,18 +6021,18 @@ async function inputText(file) {
|
|
|
5661
6021
|
for await (const chunk of process.stdin) text += chunk;
|
|
5662
6022
|
return text;
|
|
5663
6023
|
}
|
|
5664
|
-
function
|
|
6024
|
+
function register15(program, deps) {
|
|
5665
6025
|
const memory = program.command("memory").description("Read and write project memory.");
|
|
5666
6026
|
memory.command("pull").option("--hook [agent]", "SessionStart output; always exit 0").option("--scope <csv>").action((opts) => pull2(deps, opts));
|
|
5667
6027
|
memory.command("context").action(async () => {
|
|
5668
|
-
const ctx = await
|
|
6028
|
+
const ctx = await context3(deps);
|
|
5669
6029
|
writeOut(ctx.cache.meta.pulledAt || ctx.cache.state.entries.length ? await memoryIndexText(ctx, deps) : pullHint + "\n");
|
|
5670
6030
|
});
|
|
5671
6031
|
memory.command("instructions").action(() => {
|
|
5672
6032
|
writeOut(MEMORY_INSTRUCTIONS + "\n");
|
|
5673
6033
|
});
|
|
5674
6034
|
memory.command("list").option("--scope <scope>").option("--all-branches").option("--deleted").action(async (opts) => {
|
|
5675
|
-
const ctx = await
|
|
6035
|
+
const ctx = await context3(deps);
|
|
5676
6036
|
if (opts.scope) parseScope(opts.scope, scopeHint);
|
|
5677
6037
|
if (opts.deleted) {
|
|
5678
6038
|
const entries2 = sortMemoryEntries(ctx.cache.state.entries.filter((e) => e.deleted && storableMemoryEntry(e) && (!opts.scope || e.scope === opts.scope)));
|
|
@@ -5683,7 +6043,7 @@ function register13(program, deps) {
|
|
|
5683
6043
|
printResult(deps.output.mode === "json" ? entries : entries.map((e) => line(e) + (opts.allBranches && e.scope === "branch" ? ` [${terminalLine(e.repoIdentity ?? "")} ${terminalLine(e.branch ?? "")}]` : "")).join("\n"), deps.output.mode);
|
|
5684
6044
|
});
|
|
5685
6045
|
memory.command("show <name>").option("--scope <scope>").option("--branch <branch>", "branch entry of the current repo").option("--fresh").action(async (name, opts) => {
|
|
5686
|
-
const ctx = await
|
|
6046
|
+
const ctx = await context3(deps);
|
|
5687
6047
|
let entry = resolveEntry(ctx, name, opts);
|
|
5688
6048
|
if (opts.fresh) {
|
|
5689
6049
|
entry = await apiCall(deps, ctx, () => deps.http.get(`${ctx.api}/${encodeURIComponent(entry.id)}`));
|
|
@@ -5695,7 +6055,7 @@ function register13(program, deps) {
|
|
|
5695
6055
|
else writeOut(formatMemory(entry, cleanup, scoped));
|
|
5696
6056
|
});
|
|
5697
6057
|
memory.command("candidates").action(async () => {
|
|
5698
|
-
const ctx = await
|
|
6058
|
+
const ctx = await context3(deps);
|
|
5699
6059
|
if (!ctx.cache.meta.pulledAt) {
|
|
5700
6060
|
writeOut(pullHint + "\n");
|
|
5701
6061
|
return;
|
|
@@ -5715,7 +6075,7 @@ function register13(program, deps) {
|
|
|
5715
6075
|
const draft = parseMemory(await inputText(file));
|
|
5716
6076
|
const scope = parseScope(draft.scope);
|
|
5717
6077
|
validateDraft(draft);
|
|
5718
|
-
const ctx = await
|
|
6078
|
+
const ctx = await context3(deps, true);
|
|
5719
6079
|
if (scope === "branch" && (!ctx.git.branch || !ctx.git.repoIdentity || ctx.git.branch === ctx.git.defaultBranch || ["main", "master"].includes(ctx.git.branch) && !ctx.git.defaultBranch)) throw new CliError("branch \u30B9\u30B3\u30FC\u30D7\u306F\u4F5C\u696D\u30D6\u30E9\u30F3\u30C1\u3067\u3060\u3051\u4F7F\u3048\u307E\u3059\u3002", 2, "\u4F5C\u696D\u30D6\u30E9\u30F3\u30C1\u306B\u5207\u308A\u66FF\u3048\u308B(git switch -c <branch>)\u304B\u3001scope \u3092 project / user \u306B\u3059\u308B");
|
|
5720
6080
|
if (scope === "branch" && draft.branch !== void 0 && draft.branch !== ctx.git.branch) throw new CliError(`branch ${terminalLine(draft.branch)} \u304C\u4ECA\u306E\u30D6\u30E9\u30F3\u30C1 ${terminalLine(ctx.git.branch)} \u3068\u7570\u306A\u308A\u307E\u3059\u3002`, 2, `frontmatter \u306E branch \u3092\u6D88\u3059\u304B ${terminalLine(ctx.git.branch)} \u306B\u3059\u308B`);
|
|
5721
6081
|
const response = await apiCall(deps, ctx, () => deps.http.put(ctx.api, {
|
|
@@ -5744,7 +6104,7 @@ function register13(program, deps) {
|
|
|
5744
6104
|
printWrite(deps, ctx, "put", response, draft.revision === void 0, { name: draft.name, file, allowNew: opts.new });
|
|
5745
6105
|
});
|
|
5746
6106
|
memory.command("rm <names...>").option("--scope <scope>").option("--branch <branch>", "branch entry of the current repo").action(async (names, opts) => {
|
|
5747
|
-
const ctx = await
|
|
6107
|
+
const ctx = await context3(deps);
|
|
5748
6108
|
const results = [];
|
|
5749
6109
|
for (const name of names) {
|
|
5750
6110
|
try {
|
|
@@ -5766,7 +6126,7 @@ function register13(program, deps) {
|
|
|
5766
6126
|
if (names.length > 1 && deps.output.mode === "json") printResult({ results }, "json");
|
|
5767
6127
|
});
|
|
5768
6128
|
memory.command("revert <name> <revision>").option("--scope <scope>").option("--branch <branch>", "branch entry of the current repo").action(async (name, revision, opts) => {
|
|
5769
|
-
const ctx = await
|
|
6129
|
+
const ctx = await context3(deps);
|
|
5770
6130
|
const entry = resolveEntry(ctx, name, opts, true);
|
|
5771
6131
|
const response = await apiCall(deps, ctx, () => deps.http.post(`${ctx.api}/${encodeURIComponent(entry.id)}/revert`, { revision: parseRevision(revision), baseRevision: entry.revision }, headers()), "revert", name);
|
|
5772
6132
|
await resolveMemoryProjectName(ctx, deps.http, deps.output.mode !== "json");
|
|
@@ -5774,7 +6134,7 @@ function register13(program, deps) {
|
|
|
5774
6134
|
printWrite(deps, ctx, "revert", response);
|
|
5775
6135
|
});
|
|
5776
6136
|
memory.command("log <name>").option("--scope <scope>").option("--branch <branch>", "branch entry of the current repo").action(async (name, opts) => {
|
|
5777
|
-
const ctx = await
|
|
6137
|
+
const ctx = await context3(deps);
|
|
5778
6138
|
const entry = resolveEntry(ctx, name, opts, true);
|
|
5779
6139
|
const names = new Map(ctx.cache.state.entries.flatMap((e) => e.updatedBy?.name ? [[e.updatedBy.id, e.updatedBy.name]] : []));
|
|
5780
6140
|
const response = await apiCall(deps, ctx, () => deps.http.get(`${ctx.api}/${encodeURIComponent(entry.id)}/revisions`));
|
|
@@ -5782,7 +6142,7 @@ function register13(program, deps) {
|
|
|
5782
6142
|
});
|
|
5783
6143
|
memory.command("promote [names...]").requiredOption("--branch <branch>").option("--all").option("--discard").action(async (names, opts) => {
|
|
5784
6144
|
if (opts.all && names.length) throw new CliError("--all \u3068 name \u306F\u540C\u6642\u306B\u6307\u5B9A\u3067\u304D\u307E\u305B\u3093\u3002", 2);
|
|
5785
|
-
const ctx = await
|
|
6145
|
+
const ctx = await context3(deps);
|
|
5786
6146
|
if (!ctx.git.repoIdentity) throw new CliError("repo \u3092\u8B58\u5225\u3067\u304D\u307E\u305B\u3093\u3002", 2);
|
|
5787
6147
|
const selected = ctx.cache.state.entries.filter((e) => !e.deleted && e.scope === "branch" && e.repoIdentity === ctx.git.repoIdentity && e.branch === opts.branch && (!names.length || names.includes(e.name)));
|
|
5788
6148
|
if (!opts.all && !names.length) {
|
|
@@ -5803,7 +6163,7 @@ function register13(program, deps) {
|
|
|
5803
6163
|
memory.command("import <dir>").description("Import memory files. AI cleanup is off by default (--ai to use it).").requiredOption("--scope <scope>").option("--ai", "use AI cleanup (Pro+)").action(async (dir, opts) => {
|
|
5804
6164
|
const scope = parseScope(opts.scope, "--scope project|user");
|
|
5805
6165
|
if (scope === "branch") throw new CliError("branch \u30B9\u30B3\u30FC\u30D7\u3078\u306E import \u306F\u3067\u304D\u307E\u305B\u3093\u3002", 2, "--scope project|user");
|
|
5806
|
-
const ctx = await
|
|
6166
|
+
const ctx = await context3(deps, true);
|
|
5807
6167
|
const scan = await scanMemoryDir(dir);
|
|
5808
6168
|
const lines = /* @__PURE__ */ new Map();
|
|
5809
6169
|
let position = 0;
|
|
@@ -5846,29 +6206,36 @@ function buildProgram(deps) {
|
|
|
5846
6206
|
const writeErr2 = (_msg) => {
|
|
5847
6207
|
};
|
|
5848
6208
|
const program = new Command("nolto").version(deps.version, "-V, --version", "Print version number").exitOverride().configureOutput({ writeErr: writeErr2 }).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");
|
|
5849
|
-
|
|
6209
|
+
register15(program, deps);
|
|
5850
6210
|
register4(program, deps);
|
|
5851
6211
|
register5(program, deps);
|
|
5852
6212
|
register6(program, deps);
|
|
5853
6213
|
register7(program, deps);
|
|
5854
|
-
register(program, deps);
|
|
5855
|
-
register3(program, deps);
|
|
5856
6214
|
register8(program, deps);
|
|
5857
|
-
register2(program, deps);
|
|
5858
6215
|
register9(program, deps);
|
|
6216
|
+
register(program, deps);
|
|
6217
|
+
register3(program, deps);
|
|
5859
6218
|
register10(program, deps);
|
|
6219
|
+
register2(program, deps);
|
|
5860
6220
|
register11(program, deps);
|
|
5861
|
-
register12(program);
|
|
6221
|
+
register12(program, deps);
|
|
6222
|
+
register13(program, deps);
|
|
6223
|
+
register14(program);
|
|
5862
6224
|
program.action(() => {
|
|
5863
6225
|
program.help();
|
|
5864
6226
|
});
|
|
5865
6227
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
5866
6228
|
if (actionCommand.parent?.name() === "memory" && actionCommand.name() === "pull" && actionCommand.opts().hook) return;
|
|
5867
6229
|
const bindingError = deps.repoBinding?.error;
|
|
5868
|
-
const bindingExemptCommands = ["init", "link", "update", "merge-file"];
|
|
6230
|
+
const bindingExemptCommands = ["init", "link", "update", "merge-file", "logout"];
|
|
5869
6231
|
if (bindingError != null && !(actionCommand.parent === program && bindingExemptCommands.includes(actionCommand.name()))) {
|
|
5870
6232
|
throw bindingError;
|
|
5871
6233
|
}
|
|
6234
|
+
const tokenOriginExemptCommands = ["login", "logout", "update", "merge-file"];
|
|
6235
|
+
const mismatch = deps.settings.tokenOriginMismatch;
|
|
6236
|
+
if (mismatch != null && !(actionCommand.parent === program && tokenOriginExemptCommands.includes(actionCommand.name()))) {
|
|
6237
|
+
throw tokenOriginMismatchError(mismatch);
|
|
6238
|
+
}
|
|
5872
6239
|
});
|
|
5873
6240
|
return program;
|
|
5874
6241
|
}
|