@nolto/cli 0.25.0 → 0.26.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 +6 -2
- package/dist/index.js +274 -81
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -268,8 +268,12 @@ References accept a key (NOLTO-12) or number (12). Only the number is sent. With
|
|
|
268
268
|
| `issue comment <ref>` | `-m/--comment <text>` or `--body-file <path-or-dash>` |
|
|
269
269
|
| `issue close <ref>` | `--status <closed-name-or-UUID>`, `-m/--comment <text>` |
|
|
270
270
|
|
|
271
|
-
- `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The default is internal. Shared mode is available only in Pro+ projects with customers; other projects fail before any write. It cannot be combined with `create --draft`, `--priority` or `--category`. Human success output adds ` (shared)` to the first line; JSON responses stay unchanged.
|
|
272
|
-
- `--
|
|
271
|
+
- `--shared` on create, update, comment or close writes in shared mode: customers see the text as written. The default is internal. Shared mode is available only in Pro+ projects with customers; other projects fail before any write. It cannot be combined with `create --draft`, `--priority` or `--category`. Human success output adds ` (shared: <audience name>)` to the first line (` (shared)` when the name is not known); JSON responses stay unchanged.
|
|
272
|
+
- `--audience <name-or-UUID>` (with `--shared` only; otherwise exit 2) picks the share audience. The CLI reads `GET /api/projects/<id>/audiences` (token scope `issues:read`; exit 3 `共有先の一覧を読めませんでした。` on an old API or a token without it) and matches the name exactly after trimming, or the UUID. No match exits 2 and lists the audiences. Several audiences with the same name (spaces aside), or a UUID that is one audience's id and another's name, exit 2 instead of picking one. It sends `X-Nolto-View: shared; audience=<uuid>`.
|
|
273
|
+
- Omitted on update, comment or close: the CLI reads the issue in the internal view and uses its audience. An issue that is not shared exits 2 without writing; an issue without an audience id sends `shared` only.
|
|
274
|
+
- Omitted on create: sends `shared` only. A project with several audiences answers 400 `view_audience_required`; the CLI exits 2 with `共有先が 2 つ以上あります。--audience <名前> で指定してください(候補: …)。` (without the candidates when the audience list cannot be read or has no valid audiences) and nothing is written. The choice is the user's: the error hint says not to guess it from the candidates.
|
|
275
|
+
- 400 `view_audience_invalid` (for example the audience was deleted) exits 2. With `--audience`, a 404 on update, comment or close means the issue is not visible in that audience (another audience, or not shared).
|
|
276
|
+
- `--confirm-references` on create, update, comment or close sends `confirmReferences: true`. Do not add it on the first attempt. After a 409 `internal_references`, check the references customers cannot open (the API lists at most five and reports only the count for the rest). Remove or rewrite those references first. To send the text as written, get the user's go-ahead before retrying with this flag; the references will remain inaccessible to customers. This 409 can also occur without `--shared` when updating the subject or body of a shared issue. Human success output adds ` (references confirmed)`, or ` (shared, references confirmed)` with both flags (` (shared: <audience name>, references confirmed)` when the audience name is known); JSON success responses stay unchanged. Agents (LLMs) must use `--shared` and `--confirm-references` only with the user's instruction or approval. Take `--audience` from the user's instruction; do not guess it from the candidates.
|
|
273
277
|
|
|
274
278
|
Status/type/category accept case-insensitive exact names or UUIDs from the project's settings. Unknown or ambiguous names list candidates. Create with `--type` and no body uses that type's body template. Update never inserts a template automatically. Close chooses the first closed status by sortOrder unless overridden; it fails if no matching closed status exists. `--assignee me` on writes resolves /api/me/profile; none clears the assignee.
|
|
275
279
|
|
package/dist/index.js
CHANGED
|
@@ -203,13 +203,13 @@ import path from "path";
|
|
|
203
203
|
import { fileURLToPath } from "url";
|
|
204
204
|
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
205
205
|
function resolveSkillSourceDir(name = "roadmap-progress") {
|
|
206
|
-
const
|
|
206
|
+
const candidates2 = [
|
|
207
207
|
path.resolve(__dirname, `skill/${name}`),
|
|
208
208
|
// bundled: dist/skill/...
|
|
209
209
|
path.resolve(__dirname, `../../../skills/${name}`)
|
|
210
210
|
// source: <repo>/skills/...
|
|
211
211
|
];
|
|
212
|
-
for (const candidate of
|
|
212
|
+
for (const candidate of candidates2) {
|
|
213
213
|
if (existsSync(path.join(candidate, "SKILL.md"))) return candidate;
|
|
214
214
|
}
|
|
215
215
|
throw new Error(`Bundled ${name} skill not found. Reinstall @nolto/cli.`);
|
|
@@ -745,6 +745,9 @@ function maskToken(token) {
|
|
|
745
745
|
}
|
|
746
746
|
|
|
747
747
|
// src/http.ts
|
|
748
|
+
function redirectError(base) {
|
|
749
|
+
return new CliError(`The server at ${base} returned an unexpected redirect; refusing to follow it.`, 5);
|
|
750
|
+
}
|
|
748
751
|
function createHttpClient(opts) {
|
|
749
752
|
const { baseUrl, version, token } = opts;
|
|
750
753
|
const base = baseUrl.replace(/\/+$/, "");
|
|
@@ -767,9 +770,15 @@ function createHttpClient(opts) {
|
|
|
767
770
|
method,
|
|
768
771
|
headers: headers2,
|
|
769
772
|
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
773
|
+
// Never follow a redirect: it would forward the Authorization header to another origin.
|
|
774
|
+
redirect: "error",
|
|
770
775
|
...signal ? { signal } : {}
|
|
771
776
|
});
|
|
772
777
|
} catch (err) {
|
|
778
|
+
if (err instanceof TypeError) {
|
|
779
|
+
const cause = err.cause;
|
|
780
|
+
if (/redirect/i.test(String(cause?.message ?? err.message))) throw redirectError(base);
|
|
781
|
+
}
|
|
773
782
|
if (isNetworkError(err)) {
|
|
774
783
|
throw new CliError(
|
|
775
784
|
`Network error contacting ${base}: ${err instanceof Error ? err.message : String(err)}`,
|
|
@@ -786,6 +795,7 @@ function createHttpClient(opts) {
|
|
|
786
795
|
}
|
|
787
796
|
throw err;
|
|
788
797
|
}
|
|
798
|
+
if (response.status >= 300 && response.status < 400) throw redirectError(base);
|
|
789
799
|
if (!response.ok) {
|
|
790
800
|
const retryAfter = response.headers.get("retry-after") ?? void 0;
|
|
791
801
|
const wwwAuthenticate = response.headers.get("www-authenticate") ?? void 0;
|
|
@@ -1187,6 +1197,40 @@ function serializeRoadmap(roadmap) {
|
|
|
1187
1197
|
return JSON.stringify(ordered, null, 2) + "\n";
|
|
1188
1198
|
}
|
|
1189
1199
|
|
|
1200
|
+
// src/git-ignore.ts
|
|
1201
|
+
import { execFile } from "child_process";
|
|
1202
|
+
import { promisify } from "util";
|
|
1203
|
+
async function probeWorkTree(exec, root) {
|
|
1204
|
+
try {
|
|
1205
|
+
const result = await exec("git", ["rev-parse", "--is-inside-work-tree"], { cwd: root, env: { ...process.env, LC_ALL: "C" } });
|
|
1206
|
+
const stdout2 = result?.stdout;
|
|
1207
|
+
return typeof stdout2 === "string" && stdout2.trim() === "false" ? "outside" : "inside";
|
|
1208
|
+
} catch (err) {
|
|
1209
|
+
const { code, stderr } = err ?? {};
|
|
1210
|
+
if (code === "ENOENT" || typeof stderr === "string" && stderr.includes("not a git repository")) return "outside";
|
|
1211
|
+
return "broken";
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
function makeIgnoreChecker(exec = promisify(execFile)) {
|
|
1215
|
+
const workTrees = /* @__PURE__ */ new Map();
|
|
1216
|
+
return async (root, relPath) => {
|
|
1217
|
+
let probe = workTrees.get(root);
|
|
1218
|
+
if (probe === void 0) {
|
|
1219
|
+
probe = probeWorkTree(exec, root);
|
|
1220
|
+
workTrees.set(root, probe);
|
|
1221
|
+
}
|
|
1222
|
+
const state = await probe;
|
|
1223
|
+
if (state === "outside") return "not-ignored";
|
|
1224
|
+
if (state === "broken") return "unknown";
|
|
1225
|
+
try {
|
|
1226
|
+
await exec("git", ["check-ignore", "-q", "--", relPath], { cwd: root });
|
|
1227
|
+
return "ignored";
|
|
1228
|
+
} catch (err) {
|
|
1229
|
+
return err?.code === 1 ? "not-ignored" : "unknown";
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1190
1234
|
// src/issue-core.ts
|
|
1191
1235
|
var isUuid = (value) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
1192
1236
|
function parseIssueRef(input) {
|
|
@@ -1392,12 +1436,18 @@ async function buildSyncBody(args) {
|
|
|
1392
1436
|
args.deps.warn(`plan path not allowed (markdown only, no dot segments), skipping: ${ref.path}`);
|
|
1393
1437
|
continue;
|
|
1394
1438
|
}
|
|
1395
|
-
|
|
1396
|
-
if (
|
|
1397
|
-
|
|
1398
|
-
|
|
1439
|
+
const check = async (relPath) => {
|
|
1440
|
+
if (args.deps.isIgnored === void 0) return "not-ignored";
|
|
1441
|
+
try {
|
|
1442
|
+
return await args.deps.isIgnored(args.repoRoot, relPath);
|
|
1443
|
+
} catch {
|
|
1444
|
+
return "unknown";
|
|
1399
1445
|
}
|
|
1400
|
-
}
|
|
1446
|
+
};
|
|
1447
|
+
const refVerdict = await check(ref.path);
|
|
1448
|
+
if (refVerdict === "ignored") {
|
|
1449
|
+
args.deps.warn(`plan path is git-ignored, skipping: ${ref.path}`);
|
|
1450
|
+
continue;
|
|
1401
1451
|
}
|
|
1402
1452
|
const root = path5.resolve(args.repoRoot);
|
|
1403
1453
|
const absolute = path5.resolve(root, ref.path);
|
|
@@ -1409,6 +1459,7 @@ async function buildSyncBody(args) {
|
|
|
1409
1459
|
args.deps.warn(`plan file not found, skipping: ${ref.path}`);
|
|
1410
1460
|
continue;
|
|
1411
1461
|
}
|
|
1462
|
+
let readPath = absolute;
|
|
1412
1463
|
if (args.deps.realpath !== void 0) {
|
|
1413
1464
|
let real;
|
|
1414
1465
|
let realRoot;
|
|
@@ -1423,12 +1474,26 @@ async function buildSyncBody(args) {
|
|
|
1423
1474
|
args.deps.warn(`symlink escapes repository root, skipping: ${ref.path}`);
|
|
1424
1475
|
continue;
|
|
1425
1476
|
}
|
|
1426
|
-
|
|
1477
|
+
const realRel = path5.relative(realRoot, real).split(path5.sep).join("/");
|
|
1478
|
+
if (!isValidPlanPath(realRel)) {
|
|
1427
1479
|
args.deps.warn(`plan path not allowed (markdown only, no dot segments), skipping: ${ref.path}`);
|
|
1428
1480
|
continue;
|
|
1429
1481
|
}
|
|
1482
|
+
const verdict = realRel === ref.path ? refVerdict : await check(realRel);
|
|
1483
|
+
if (verdict === "ignored") {
|
|
1484
|
+
args.deps.warn(`plan path is git-ignored, skipping: ${ref.path}`);
|
|
1485
|
+
continue;
|
|
1486
|
+
}
|
|
1487
|
+
if (verdict === "unknown") {
|
|
1488
|
+
args.deps.warn(`cannot determine whether plan path is git-ignored, skipping: ${ref.path}`);
|
|
1489
|
+
continue;
|
|
1490
|
+
}
|
|
1491
|
+
readPath = real;
|
|
1492
|
+
} else if (refVerdict === "unknown") {
|
|
1493
|
+
args.deps.warn(`cannot determine whether plan path is git-ignored, skipping: ${ref.path}`);
|
|
1494
|
+
continue;
|
|
1430
1495
|
}
|
|
1431
|
-
const content = await args.deps.readFile(
|
|
1496
|
+
const content = await args.deps.readFile(readPath);
|
|
1432
1497
|
planDocuments.push({
|
|
1433
1498
|
path: ref.path,
|
|
1434
1499
|
taskId: ref.ownerId,
|
|
@@ -1535,6 +1600,37 @@ async function writeCache(env, projectId, slug, roadmap, meta) {
|
|
|
1535
1600
|
}
|
|
1536
1601
|
}
|
|
1537
1602
|
}
|
|
1603
|
+
function normalizeIdentity(identity) {
|
|
1604
|
+
if (!identity.startsWith("remote:")) return identity;
|
|
1605
|
+
const normalized = normalizeRemote(identity.slice("remote:".length));
|
|
1606
|
+
return normalized === null ? identity : `remote:${normalized}`;
|
|
1607
|
+
}
|
|
1608
|
+
async function rewriteCachedRepoIdentity(env, projectId, from, to) {
|
|
1609
|
+
const fromKey = normalizeIdentity(from);
|
|
1610
|
+
const updated = [];
|
|
1611
|
+
const failed = [];
|
|
1612
|
+
for (const slug of await listCachedSlugs(env, projectId)) {
|
|
1613
|
+
let entry;
|
|
1614
|
+
try {
|
|
1615
|
+
entry = await readCache(env, projectId, slug);
|
|
1616
|
+
} catch {
|
|
1617
|
+
continue;
|
|
1618
|
+
}
|
|
1619
|
+
if (entry?.meta == null || entry.meta.repoIdentity == null || normalizeIdentity(entry.meta.repoIdentity) !== fromKey) continue;
|
|
1620
|
+
const metaPath = cachePaths(env, projectId, slug).meta;
|
|
1621
|
+
const temp = `${metaPath}.tmp-${process.pid}-${randomUUID2()}`;
|
|
1622
|
+
try {
|
|
1623
|
+
await writeFile4(temp, JSON.stringify({ ...entry.meta, repoIdentity: to }, null, 2) + "\n", { mode: 384 });
|
|
1624
|
+
await rename(temp, metaPath);
|
|
1625
|
+
updated.push(slug);
|
|
1626
|
+
} catch {
|
|
1627
|
+
failed.push(slug);
|
|
1628
|
+
} finally {
|
|
1629
|
+
await unlink(temp).catch(() => void 0);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
return { updated, failed };
|
|
1633
|
+
}
|
|
1538
1634
|
function isDirty(entry) {
|
|
1539
1635
|
return entry.meta === null || sha256Hex(entry.raw) !== entry.meta.contentHash;
|
|
1540
1636
|
}
|
|
@@ -1640,6 +1736,7 @@ async function ensureRoadmapCache(args) {
|
|
|
1640
1736
|
readFile: (p) => readFile6(p, "utf8"),
|
|
1641
1737
|
realpath,
|
|
1642
1738
|
fileExists: existsSync3,
|
|
1739
|
+
isIgnored: makeIgnoreChecker(),
|
|
1643
1740
|
log: () => void 0,
|
|
1644
1741
|
warn: warn2
|
|
1645
1742
|
});
|
|
@@ -1764,7 +1861,7 @@ async function removeRepoFromRegistry(filePath, root) {
|
|
|
1764
1861
|
}
|
|
1765
1862
|
|
|
1766
1863
|
// src/repo-identity.ts
|
|
1767
|
-
import { execFile } from "child_process";
|
|
1864
|
+
import { execFile as execFile2 } from "child_process";
|
|
1768
1865
|
import { realpathSync } from "fs";
|
|
1769
1866
|
import path10 from "path";
|
|
1770
1867
|
|
|
@@ -1831,7 +1928,7 @@ function loadOrCreateMachineId(configDir) {
|
|
|
1831
1928
|
// src/repo-identity.ts
|
|
1832
1929
|
function defaultGetRemoteUrl(root) {
|
|
1833
1930
|
return new Promise((resolve) => {
|
|
1834
|
-
|
|
1931
|
+
execFile2(
|
|
1835
1932
|
"git",
|
|
1836
1933
|
["-C", root, "remote", "get-url", "origin"],
|
|
1837
1934
|
{ timeout: 5e3 },
|
|
@@ -1981,10 +2078,32 @@ async function handleRebind(deps, projectId, root, mode2, yes) {
|
|
|
1981
2078
|
}
|
|
1982
2079
|
}
|
|
1983
2080
|
await deps.http.post(`/api/projects/${projectId}/repo-binding`, { repoIdentity });
|
|
2081
|
+
let cacheUpdated = [];
|
|
2082
|
+
if (project.repoIdentity != null) {
|
|
2083
|
+
try {
|
|
2084
|
+
const { updated, failed } = await rewriteCachedRepoIdentity(
|
|
2085
|
+
process.env,
|
|
2086
|
+
projectId,
|
|
2087
|
+
project.repoIdentity,
|
|
2088
|
+
repoIdentityToString(repoIdentity)
|
|
2089
|
+
);
|
|
2090
|
+
cacheUpdated = updated;
|
|
2091
|
+
if (failed.length > 0) {
|
|
2092
|
+
writeErr(`Warning: could not update the local roadmap cache for: ${failed.map(terminalLine).join(", ")}. Run \`nolto roadmap sync <slug>\` to fix it.
|
|
2093
|
+
`);
|
|
2094
|
+
}
|
|
2095
|
+
} catch (err) {
|
|
2096
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2097
|
+
writeErr(`Warning: could not update the local roadmap cache (${message}). Run \`nolto roadmap sync <slug>\` to fix it.
|
|
2098
|
+
`);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
1984
2101
|
if (mode2 === "json") {
|
|
1985
|
-
printResult({ rebound: true, projectId, repoIdentity }, mode2);
|
|
2102
|
+
printResult({ rebound: true, projectId, repoIdentity, cacheUpdated }, mode2);
|
|
1986
2103
|
} else {
|
|
1987
2104
|
writeOut(`Rebound project ${projectId} to ${repoIdentity.kind}:${repoIdentity.value}.
|
|
2105
|
+
`);
|
|
2106
|
+
if (cacheUpdated.length > 0) writeOut(`Updated local roadmap cache: ${cacheUpdated.map(terminalLine).join(", ")}
|
|
1988
2107
|
`);
|
|
1989
2108
|
}
|
|
1990
2109
|
}
|
|
@@ -2308,8 +2427,8 @@ async function runPull(deps, opts = {}) {
|
|
|
2308
2427
|
}
|
|
2309
2428
|
|
|
2310
2429
|
// src/commands/sync.ts
|
|
2311
|
-
import { execFile as
|
|
2312
|
-
import { promisify } from "util";
|
|
2430
|
+
import { execFile as execFile3 } from "child_process";
|
|
2431
|
+
import { promisify as promisify2 } from "util";
|
|
2313
2432
|
import { readFile as readFile9, realpath as realpath2 } from "fs/promises";
|
|
2314
2433
|
import { existsSync as existsSync4 } from "fs";
|
|
2315
2434
|
|
|
@@ -2410,15 +2529,7 @@ async function syncRepo(args, io) {
|
|
|
2410
2529
|
roadmaps.push({ slug, ...entry });
|
|
2411
2530
|
}
|
|
2412
2531
|
if (roadmaps.length === 0) throw new CliError("No cached roadmap belongs to this repository. Run `nolto link --slug <slug>` to create one, or `nolto pull`.", 2);
|
|
2413
|
-
const
|
|
2414
|
-
const isIgnored = exec === void 0 ? void 0 : async (root, relPath) => {
|
|
2415
|
-
try {
|
|
2416
|
-
await exec("git", ["check-ignore", "-q", "--", relPath], { cwd: root });
|
|
2417
|
-
return true;
|
|
2418
|
-
} catch {
|
|
2419
|
-
return false;
|
|
2420
|
-
}
|
|
2421
|
-
};
|
|
2532
|
+
const isIgnored = io.exec === void 0 ? void 0 : makeIgnoreChecker(io.exec);
|
|
2422
2533
|
const results = [];
|
|
2423
2534
|
for (const entry of roadmaps) {
|
|
2424
2535
|
const { slug, roadmap, meta } = entry;
|
|
@@ -2502,7 +2613,7 @@ async function runSyncCommand(deps, opts = {}) {
|
|
|
2502
2613
|
realpath: (p) => realpath2(p),
|
|
2503
2614
|
fileExists: (p) => existsSync4(p),
|
|
2504
2615
|
repoIdentity: makeRepoIdentityResolver(deps),
|
|
2505
|
-
exec:
|
|
2616
|
+
exec: promisify2(execFile3),
|
|
2506
2617
|
gitLinks: (opts.gitLinks ?? true) && process.env.NOLTO_GIT_LINKS !== "0",
|
|
2507
2618
|
http,
|
|
2508
2619
|
log: (line2) => {
|
|
@@ -2754,6 +2865,7 @@ async function roadmapMigrate(deps, yes = false) {
|
|
|
2754
2865
|
readFile: (p) => readFile10(p, "utf8"),
|
|
2755
2866
|
realpath: realpath3,
|
|
2756
2867
|
fileExists: existsSync5,
|
|
2868
|
+
isIgnored: makeIgnoreChecker(),
|
|
2757
2869
|
log: () => void 0,
|
|
2758
2870
|
warn
|
|
2759
2871
|
});
|
|
@@ -2788,11 +2900,13 @@ async function roadmapMigrate(deps, yes = false) {
|
|
|
2788
2900
|
// src/commands/issue.ts
|
|
2789
2901
|
var emptySettings = { types: [], statuses: [], categories: [] };
|
|
2790
2902
|
var confirmHelp = "Send even if the text has references customers cannot open. Use only after a 409 internal_references and the user's go-ahead.";
|
|
2903
|
+
var audienceHint = "\u3069\u306E\u5171\u6709\u5148\u306B\u66F8\u304F\u304B\u306F\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u308B\u3002\u5019\u88DC\u304B\u3089\u63A8\u6E2C\u3057\u3066 --audience \u3092\u4ED8\u3051\u306A\u3044\u3002";
|
|
2791
2904
|
var confirmHint = "\u53C2\u7167\u3092\u5916\u3059\u304B\u66F8\u304D\u63DB\u3048\u308B\u306E\u304C\u5148\u3002\u3053\u306E\u307E\u307E\u9001\u308B\u3068\u3001\u3053\u306E\u6587\u9762\u306F\u304A\u5BA2\u3055\u307E\u306B\u305D\u306E\u307E\u307E\u898B\u3048\u3001\u53C2\u7167\u306F\u958B\u3051\u306A\u3044\u307E\u307E\u6B8B\u308B\u3002\u5229\u7528\u8005\u306B\u78BA\u304B\u3081\u3066\u304B\u3089 --confirm-references \u3092\u4ED8\u3051\u3066\u518D\u5B9F\u884C\u3059\u308B";
|
|
2792
2905
|
function sharedOptions(command) {
|
|
2793
|
-
return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only.").option("--confirm-references", confirmHelp);
|
|
2906
|
+
return command.option("--shared", "Write in shared mode (visible to customers). Pro+ projects with customers only.").option("--audience <name-or-id>", "Share audience for --shared (name or UUID). Required on create when the project has several audiences.").option("--confirm-references", confirmHelp);
|
|
2794
2907
|
}
|
|
2795
2908
|
async function checkShared(deps, root, flags, ref) {
|
|
2909
|
+
if (flags.audience !== void 0 && !flags.shared) throw new CliError("--audience \u306F --shared \u3068\u4E00\u7DD2\u306B\u4F7F\u3044\u307E\u3059\u3002", 2);
|
|
2796
2910
|
if (!flags.shared) return;
|
|
2797
2911
|
if (flags.priority !== void 0 || flags.category !== void 0) {
|
|
2798
2912
|
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);
|
|
@@ -2807,16 +2921,65 @@ async function checkShared(deps, root, flags, ref) {
|
|
|
2807
2921
|
}
|
|
2808
2922
|
return context4.project?.name;
|
|
2809
2923
|
}
|
|
2810
|
-
function
|
|
2811
|
-
|
|
2812
|
-
|
|
2924
|
+
async function audienceList(deps, root) {
|
|
2925
|
+
try {
|
|
2926
|
+
const result = await deps.http.get(`${root}/audiences`);
|
|
2927
|
+
return (result.audiences ?? []).filter((row) => typeof row?.id === "string" && isUuid(row.id) && typeof row.name === "string");
|
|
2928
|
+
} catch (error) {
|
|
2929
|
+
if (error instanceof CliError && error.status === 403 && error.serverError === "token_scope") {
|
|
2930
|
+
throw new CliError(
|
|
2931
|
+
"\u5171\u6709\u5148\u306E\u4E00\u89A7\u3092\u8AAD\u3081\u307E\u305B\u3093\u3067\u3057\u305F\u3002",
|
|
2932
|
+
error.exitCode,
|
|
2933
|
+
"API \u304C\u53E4\u3044\u304B\u3001token \u306B issues:read \u306E scope \u304C\u3042\u308A\u307E\u305B\u3093\u3002",
|
|
2934
|
+
error.status,
|
|
2935
|
+
error.serverError,
|
|
2936
|
+
error.body
|
|
2937
|
+
);
|
|
2938
|
+
}
|
|
2939
|
+
throw error;
|
|
2940
|
+
}
|
|
2813
2941
|
}
|
|
2814
|
-
|
|
2942
|
+
var candidates = (audiences) => audiences.map((row) => terminalLine(row.name)).join("\u3001");
|
|
2943
|
+
function pickAudience(audiences, input) {
|
|
2944
|
+
const wanted = input.trim();
|
|
2945
|
+
const uuid = isUuid(wanted);
|
|
2946
|
+
const matches = audiences.filter((row) => uuid ? row.id.toLowerCase() === wanted.toLowerCase() : row.name.trim() === wanted);
|
|
2947
|
+
const named = uuid && matches.length === 1 ? audiences.find((row) => row !== matches[0] && row.name.trim().toLowerCase() === wanted.toLowerCase()) : void 0;
|
|
2948
|
+
if (named) {
|
|
2949
|
+
throw new CliError(`${terminalLine(wanted)} \u306F\u3001\u3042\u308B\u5171\u6709\u5148\u306E id \u3068\u3001\u5225\u306E\u5171\u6709\u5148\u306E\u540D\u524D(${terminalLine(named.name)})\u306E\u4E21\u65B9\u306B\u4E00\u81F4\u3057\u307E\u3059\u3002\u3069\u3061\u3089\u304B\u6C7A\u3081\u3089\u308C\u307E\u305B\u3093\u3002`, 2, audienceHint);
|
|
2950
|
+
}
|
|
2951
|
+
if (matches.length === 1) return matches[0];
|
|
2952
|
+
if (matches.length > 1) {
|
|
2953
|
+
throw new CliError(`\u540C\u3058\u540D\u524D(\u524D\u5F8C\u306E\u7A7A\u767D\u3060\u3051\u304C\u9055\u3046\u540D\u524D\u3092\u542B\u3080)\u306E\u5171\u6709\u5148\u304C\u8907\u6570\u3042\u308A\u307E\u3059\u3002id \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044(${matches.map((row) => `${terminalLine(row.name)}: ${terminalLine(row.id)}`).join("\u3001")})\u3002`, 2, audienceHint);
|
|
2954
|
+
}
|
|
2955
|
+
if (audiences.length === 0) throw new CliError("\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u306F\u5171\u6709\u5148\u304C\u3042\u308A\u307E\u305B\u3093\u3002--audience \u306F\u4F7F\u3048\u307E\u305B\u3093\u3002", 2);
|
|
2956
|
+
throw new CliError(`\u5171\u6709\u5148 ${terminalLine(wanted)} \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093(\u5019\u88DC: ${candidates(audiences)})\u3002`, 2, audienceHint);
|
|
2957
|
+
}
|
|
2958
|
+
async function sharedView(deps, root, mode2, flags, number) {
|
|
2959
|
+
if (!flags.shared) return {};
|
|
2960
|
+
if (flags.audience !== void 0) return { view: pickAudience(await audienceList(deps, root), flags.audience) };
|
|
2961
|
+
if (number === void 0) return { view: {} };
|
|
2962
|
+
const { issue } = await deps.http.get(`${root}/issues/${number}`);
|
|
2963
|
+
if (issue.shared === false) {
|
|
2964
|
+
throw new CliError("\u3053\u306E\u8AB2\u984C\u306F\u304A\u5BA2\u3055\u307E\u3068\u5171\u6709\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u8AB2\u984C\u3092\u5171\u6709\u3059\u308B\u304B\u3001--shared \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002", 2);
|
|
2965
|
+
}
|
|
2966
|
+
const id = typeof issue.audienceId === "string" && isUuid(issue.audienceId) ? issue.audienceId.toLowerCase() : void 0;
|
|
2967
|
+
const name = id && mode2 === "human" ? (await audienceList(deps, root).catch(() => [])).find((row) => row.id.toLowerCase() === id)?.name : void 0;
|
|
2968
|
+
return { view: { id, name }, issue };
|
|
2969
|
+
}
|
|
2970
|
+
var viewHeaders = (id) => ({ "X-Nolto-View": id !== void 0 && isUuid(id) ? `shared; audience=${id.toLowerCase()}` : "shared" });
|
|
2971
|
+
function writeSuffix(flags, view) {
|
|
2972
|
+
const label = view?.name ? terminalLine(view.name) : "";
|
|
2973
|
+
const shared = label ? `shared: ${label}` : "shared";
|
|
2974
|
+
if (flags.shared && flags.confirmReferences) return ` (${shared}, references confirmed)`;
|
|
2975
|
+
return flags.shared ? ` (${shared})` : flags.confirmReferences ? " (references confirmed)" : "";
|
|
2976
|
+
}
|
|
2977
|
+
async function writeRequest(deps, mode2, flags, root, method, path24, body, view) {
|
|
2815
2978
|
try {
|
|
2816
2979
|
return await deps.http[method](
|
|
2817
2980
|
path24,
|
|
2818
2981
|
flags.confirmReferences ? { ...body, confirmReferences: true } : body,
|
|
2819
|
-
flags.shared ?
|
|
2982
|
+
flags.shared ? viewHeaders(view?.id) : void 0
|
|
2820
2983
|
);
|
|
2821
2984
|
} catch (error) {
|
|
2822
2985
|
if (!(error instanceof CliError)) throw error;
|
|
@@ -2832,11 +2995,32 @@ async function writeRequest(deps, mode2, flags, method, path24, body) {
|
|
|
2832
2995
|
detail
|
|
2833
2996
|
);
|
|
2834
2997
|
}
|
|
2998
|
+
if (flags.shared && error.status === 400 && error.serverError === "view_audience_required" && view?.id === void 0) {
|
|
2999
|
+
const audiences = await audienceList(deps, root).catch(() => void 0);
|
|
3000
|
+
throw new CliError(
|
|
3001
|
+
`\u5171\u6709\u5148\u304C 2 \u3064\u4EE5\u4E0A\u3042\u308A\u307E\u3059\u3002--audience <\u540D\u524D> \u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044${audiences?.length ? `(\u5019\u88DC: ${candidates(audiences)})` : ""}\u3002`,
|
|
3002
|
+
2,
|
|
3003
|
+
audienceHint,
|
|
3004
|
+
error.status,
|
|
3005
|
+
error.serverError,
|
|
3006
|
+
error.body
|
|
3007
|
+
);
|
|
3008
|
+
}
|
|
3009
|
+
if (flags.shared && error.status === 400 && error.serverError === "view_audience_invalid") {
|
|
3010
|
+
throw new CliError(
|
|
3011
|
+
"\u5171\u6709\u5148\u306E\u6307\u5B9A\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093(\u5171\u6709\u5148\u304C\u524A\u9664\u3055\u308C\u305F\u304B\u3001\u3053\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u5171\u6709\u5148\u3067\u306F\u3042\u308A\u307E\u305B\u3093)\u3002",
|
|
3012
|
+
2,
|
|
3013
|
+
"--audience <\u540D\u524D> \u3067\u6307\u5B9A\u3057\u76F4\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
3014
|
+
error.status,
|
|
3015
|
+
error.serverError,
|
|
3016
|
+
error.body
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
2835
3019
|
if (flags.shared && error.status === 404 && (method === "patch" || path24.endsWith("/comments"))) {
|
|
2836
3020
|
throw new CliError(
|
|
2837
3021
|
error.message,
|
|
2838
3022
|
error.exitCode,
|
|
2839
|
-
"\u5171\u6709\u30E2\u30FC\u30C9\u3067\u306F\u3001\u304A\u5BA2\u3055\u307E\u3068\u5171\u6709\u3057\u3066\u3044\u306A\u3044\u8AB2\u984C\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\u8AB2\u984C\u3092\u5171\u6709\u3059\u308B\u304B\u3001--shared \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
3023
|
+
view?.name ? `\u5171\u6709\u5148 ${terminalLine(view.name)} \u3067\u306F\u3001\u3053\u306E\u8AB2\u984C\u306F\u898B\u3048\u307E\u305B\u3093(\u8AB2\u984C\u306E\u5171\u6709\u5148\u304C\u9055\u3046\u304B\u3001\u5171\u6709\u3057\u3066\u3044\u307E\u305B\u3093)\u3002` : "\u5171\u6709\u30E2\u30FC\u30C9\u3067\u306F\u3001\u304A\u5BA2\u3055\u307E\u3068\u5171\u6709\u3057\u3066\u3044\u306A\u3044\u8AB2\u984C\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002\u8AB2\u984C\u3092\u5171\u6709\u3059\u308B\u304B\u3001--shared \u3092\u5916\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
|
|
2840
3024
|
error.status,
|
|
2841
3025
|
error.serverError,
|
|
2842
3026
|
error.body,
|
|
@@ -2959,15 +3143,16 @@ nolto issue publish <draft-id>
|
|
|
2959
3143
|
const { input, fromTemplate } = await writeInput(deps, ctx.root, flags, true);
|
|
2960
3144
|
if (flags.draft) {
|
|
2961
3145
|
const project2 = await projectLine(deps, ctx);
|
|
2962
|
-
const result2 = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts`, input);
|
|
3146
|
+
const result2 = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issue-drafts`, input);
|
|
2963
3147
|
printResult(ctx.mode === "json" ? result2 : `draft ${result2.draft.id} created${writeSuffix(flags)}${project2}
|
|
2964
3148
|
${draftUrl(deps.settings.baseUrl, ctx.projectId, result2.draft.id)}${warningLines(result2.warnings)}`, ctx.mode);
|
|
2965
3149
|
return;
|
|
2966
3150
|
}
|
|
3151
|
+
const { view } = await sharedView(deps, ctx.root, ctx.mode, flags);
|
|
2967
3152
|
const project = await projectLine(deps, ctx);
|
|
2968
|
-
const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues`, input);
|
|
3153
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issues`, input, view);
|
|
2969
3154
|
const roadmap = flags.phase === void 0 ? void 0 : await attachRoadmap(deps, flags.phase, flags.roadmap, result.issue.key);
|
|
2970
|
-
printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags)}${project}
|
|
3155
|
+
printResult(ctx.mode === "json" ? { ...result, ...roadmap ? { roadmap } : {} } : `${result.issue.key} created${writeSuffix(flags, view)}${project}
|
|
2971
3156
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemplate ? "\nbody: from template" : ""}${warningLines(result.warnings)}`, ctx.mode);
|
|
2972
3157
|
});
|
|
2973
3158
|
group.command("drafts").description("List your issue drafts (visible only to you).").action(async (_flags, command) => {
|
|
@@ -2979,7 +3164,7 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${fromTemp
|
|
|
2979
3164
|
const ctx = context(deps, command);
|
|
2980
3165
|
if (!isUuid(id)) throw new CliError("<draft-id> must be a UUID. Run `nolto issue drafts` to list drafts.", 2);
|
|
2981
3166
|
const project = await projectLine(deps, ctx);
|
|
2982
|
-
const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
|
|
3167
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issue-drafts/${id}/publish`, void 0);
|
|
2983
3168
|
printResult(ctx.mode === "json" ? result : `${result.issue.key} published${project}
|
|
2984
3169
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
2985
3170
|
});
|
|
@@ -2988,9 +3173,10 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, result.issue.number)}${warningL
|
|
|
2988
3173
|
const number = parseIssueRef(ref);
|
|
2989
3174
|
ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
|
|
2990
3175
|
const { input } = await writeInput(deps, ctx.root, flags, false);
|
|
3176
|
+
const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
|
|
2991
3177
|
const project = await projectLine(deps, ctx);
|
|
2992
|
-
const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, input);
|
|
2993
|
-
printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags)}${project}
|
|
3178
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, input, view);
|
|
3179
|
+
printResult(ctx.mode === "json" ? result : `${result.issue.key} updated${writeSuffix(flags, view)}${project}
|
|
2994
3180
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
2995
3181
|
});
|
|
2996
3182
|
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) => {
|
|
@@ -2999,10 +3185,11 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
|
|
|
2999
3185
|
ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
|
|
3000
3186
|
const body = await bodyText(flags.comment, flags.bodyFile);
|
|
3001
3187
|
if (!body?.trim()) throw new CliError("A comment is required. Use -m or --body-file.", 2);
|
|
3002
|
-
const
|
|
3188
|
+
const { view, issue: read } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
|
|
3189
|
+
const issue = read ?? (ctx.mode === "human" ? (await deps.http.get(`${ctx.root}/issues/${number}`)).issue : void 0);
|
|
3003
3190
|
const project = await projectLine(deps, ctx);
|
|
3004
|
-
const result = await writeRequest(deps, ctx.mode, flags, "post", `${ctx.root}/issues/${number}/comments`, { body });
|
|
3005
|
-
printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags)}${project}
|
|
3191
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "post", `${ctx.root}/issues/${number}/comments`, { body }, view);
|
|
3192
|
+
printResult(ctx.mode === "json" ? result : `${issue.key} commented${writeSuffix(flags, view)}${project}
|
|
3006
3193
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
3007
3194
|
});
|
|
3008
3195
|
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) => {
|
|
@@ -3011,9 +3198,10 @@ ${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.w
|
|
|
3011
3198
|
ctx.projectName = await checkShared(deps, ctx.root, flags, ref);
|
|
3012
3199
|
const settings = await deps.http.get(`${ctx.root}/issue-settings`);
|
|
3013
3200
|
const status = pickClosedStatus(settings, flags.status);
|
|
3201
|
+
const { view } = await sharedView(deps, ctx.root, ctx.mode, flags, number);
|
|
3014
3202
|
const project = await projectLine(deps, ctx);
|
|
3015
|
-
const result = await writeRequest(deps, ctx.mode, flags, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} });
|
|
3016
|
-
printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags)}${project}
|
|
3203
|
+
const result = await writeRequest(deps, ctx.mode, flags, ctx.root, "patch", `${ctx.root}/issues/${number}`, { statusId: status.id, ...flags.comment !== void 0 ? { comment: flags.comment } : {} }, view);
|
|
3204
|
+
printResult(ctx.mode === "json" ? result : `${result.issue.key} closed${writeSuffix(flags, view)}${project}
|
|
3017
3205
|
${issueUrl(deps.settings.baseUrl, ctx.projectId, number)}${warningLines(result.warnings)}`, ctx.mode);
|
|
3018
3206
|
});
|
|
3019
3207
|
}
|
|
@@ -3209,6 +3397,8 @@ nolto wiki update <page> --body-file page.md --base-revision <revision>
|
|
|
3209
3397
|
|
|
3210
3398
|
Secrets: view shows a \`\`\`secret id=\u2026 line instead of the value. Keep that line when you send the body back.
|
|
3211
3399
|
To store a new secret, write a \`\`\`secret <name> fence; it is encrypted when saved.
|
|
3400
|
+
Only a fence at the start of a line (up to 3 spaces of indent), outside any list or quote, with a closing fence, is recognized;
|
|
3401
|
+
otherwise the value is saved as plain text. After saving, run view and check the line became \`\`\`secret id=\u2026.
|
|
3212
3402
|
|
|
3213
3403
|
| Exit | Meaning |
|
|
3214
3404
|
|---|---|
|
|
@@ -3536,23 +3726,23 @@ function currentCleanupCandidates(state, context4) {
|
|
|
3536
3726
|
function hasSharedMemoryName(entry, entries, context4) {
|
|
3537
3727
|
return currentMemoryEntries(entries, context4).some((e) => e.name === entry.name && e.scope !== entry.scope);
|
|
3538
3728
|
}
|
|
3539
|
-
function cleanupSection(
|
|
3540
|
-
if (!
|
|
3729
|
+
function cleanupSection(candidates2, entries, context4, limit = 10) {
|
|
3730
|
+
if (!candidates2.length) return [];
|
|
3541
3731
|
return [
|
|
3542
3732
|
"## \u6574\u7406\u5019\u88DC(\u78BA\u304B\u3081\u3066\u6D88\u3059\u306A\u3089 nolto memory rm <name>)",
|
|
3543
|
-
...
|
|
3733
|
+
...candidates2.slice(0, limit).map((c) => {
|
|
3544
3734
|
const shared = hasSharedMemoryName(c, entries, context4);
|
|
3545
3735
|
return `- ${shared ? `${c.scope}/` : ""}${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`;
|
|
3546
3736
|
}),
|
|
3547
|
-
...
|
|
3737
|
+
...candidates2.length > limit ? [`\u307B\u304B ${candidates2.length - limit} \u4EF6: nolto memory candidates`] : []
|
|
3548
3738
|
];
|
|
3549
3739
|
}
|
|
3550
3740
|
function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
|
|
3551
3741
|
const branch = context4.branch && context4.branch !== context4.defaultBranch ? context4.branch : null;
|
|
3552
|
-
const
|
|
3553
|
-
const candidateIds = new Set(
|
|
3742
|
+
const candidates2 = currentCleanupCandidates(cache.state, context4);
|
|
3743
|
+
const candidateIds = new Set(candidates2.map((c) => c.entryId));
|
|
3554
3744
|
const entries = sortMemoryEntries(currentMemoryEntries(cache.state.entries, context4).filter((e) => !candidateIds.has(e.id)));
|
|
3555
|
-
let candidateLimit = Math.min(10,
|
|
3745
|
+
let candidateLimit = Math.min(10, candidates2.length);
|
|
3556
3746
|
const groups = ["project", "user", ...branch ? ["branch"] : []];
|
|
3557
3747
|
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>")}`);
|
|
3558
3748
|
let omitted = 0;
|
|
@@ -3565,7 +3755,7 @@ function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
|
|
|
3565
3755
|
const lines2 = entries.filter((e) => e.scope === scope).map((e) => `- ${terminalLine(e.name)} \u2014 ${terminalLine(e.description)}`);
|
|
3566
3756
|
return lines2.length ? [`## ${scope === "branch" ? `branch ${terminalLine(branch)}` : scope}`, ...lines2] : [];
|
|
3567
3757
|
}),
|
|
3568
|
-
...cleanupSection(
|
|
3758
|
+
...cleanupSection(candidates2, cache.state.entries, context4, candidateLimit),
|
|
3569
3759
|
...mergedLines,
|
|
3570
3760
|
...omitted ? [`\u6B8B\u308A ${omitted} \u4EF6: nolto memory list`] : []
|
|
3571
3761
|
];
|
|
@@ -3596,9 +3786,9 @@ function memoryIndex(cache, context4, merged = /* @__PURE__ */ new Set(), dir) {
|
|
|
3596
3786
|
}
|
|
3597
3787
|
|
|
3598
3788
|
// src/memory-git.ts
|
|
3599
|
-
import { execFile as
|
|
3600
|
-
import { promisify as
|
|
3601
|
-
var runMemoryGit = async (args, root) => (await
|
|
3789
|
+
import { execFile as execFile4 } from "child_process";
|
|
3790
|
+
import { promisify as promisify3 } from "util";
|
|
3791
|
+
var runMemoryGit = async (args, root) => (await promisify3(execFile4)("git", args, { cwd: root, timeout: 5e3 })).stdout.trim();
|
|
3602
3792
|
async function memoryGitContext(root, deps) {
|
|
3603
3793
|
const git = deps.memoryGit ?? runMemoryGit;
|
|
3604
3794
|
const result = { repoIdentity: null, branch: null, defaultBranch: null };
|
|
@@ -3814,13 +4004,13 @@ function suggestProjectKey(name) {
|
|
|
3814
4004
|
var __dirname2 = path17.dirname(fileURLToPath2(import.meta.url));
|
|
3815
4005
|
var _require = createRequire(import.meta.url);
|
|
3816
4006
|
function getCliVersion() {
|
|
3817
|
-
const
|
|
4007
|
+
const candidates2 = [
|
|
3818
4008
|
path17.resolve(__dirname2, "../package.json"),
|
|
3819
4009
|
// bundled: dist/../package.json
|
|
3820
4010
|
path17.resolve(__dirname2, "../../package.json")
|
|
3821
4011
|
// source: src/commands/../../package.json
|
|
3822
4012
|
];
|
|
3823
|
-
for (const pkgPath of
|
|
4013
|
+
for (const pkgPath of candidates2) {
|
|
3824
4014
|
if (fs2.existsSync(pkgPath)) {
|
|
3825
4015
|
try {
|
|
3826
4016
|
const pkg = _require(pkgPath);
|
|
@@ -4669,8 +4859,8 @@ function register11(program, deps) {
|
|
|
4669
4859
|
}
|
|
4670
4860
|
|
|
4671
4861
|
// src/commands/watch.ts
|
|
4672
|
-
import { execFile as
|
|
4673
|
-
import { promisify as
|
|
4862
|
+
import { execFile as execFile5 } from "child_process";
|
|
4863
|
+
import { promisify as promisify4 } from "util";
|
|
4674
4864
|
import { readFile as readFile15, realpath as realpath4 } from "fs/promises";
|
|
4675
4865
|
import { existsSync as existsSync7, mkdirSync } from "fs";
|
|
4676
4866
|
import path20 from "path";
|
|
@@ -4918,9 +5108,9 @@ async function installServiceWith(deps) {
|
|
|
4918
5108
|
}
|
|
4919
5109
|
async function installService() {
|
|
4920
5110
|
const { writeFile: writeFile12, mkdir: mkdir9 } = await import("fs/promises");
|
|
4921
|
-
const { execFile:
|
|
4922
|
-
const { promisify:
|
|
4923
|
-
const execFileAsync =
|
|
5111
|
+
const { execFile: execFile7 } = await import("child_process");
|
|
5112
|
+
const { promisify: promisify6 } = await import("util");
|
|
5113
|
+
const execFileAsync = promisify6(execFile7);
|
|
4924
5114
|
await installServiceWith({
|
|
4925
5115
|
platform: process.platform,
|
|
4926
5116
|
uid: process.getuid?.(),
|
|
@@ -5016,9 +5206,9 @@ async function uninstallServiceWith(deps) {
|
|
|
5016
5206
|
}
|
|
5017
5207
|
async function uninstallService() {
|
|
5018
5208
|
const { unlink: unlink5 } = await import("fs/promises");
|
|
5019
|
-
const { execFile:
|
|
5020
|
-
const { promisify:
|
|
5021
|
-
const execFileAsync =
|
|
5209
|
+
const { execFile: execFile7 } = await import("child_process");
|
|
5210
|
+
const { promisify: promisify6 } = await import("util");
|
|
5211
|
+
const execFileAsync = promisify6(execFile7);
|
|
5022
5212
|
await uninstallServiceWith({
|
|
5023
5213
|
platform: process.platform,
|
|
5024
5214
|
uid: process.getuid?.(),
|
|
@@ -5123,7 +5313,7 @@ function register12(program, deps) {
|
|
|
5123
5313
|
realpath: (p) => realpath4(p),
|
|
5124
5314
|
fileExists: (p) => existsSync7(p),
|
|
5125
5315
|
repoIdentity: makeRepoIdentityResolver(deps),
|
|
5126
|
-
exec:
|
|
5316
|
+
exec: promisify4(execFile5),
|
|
5127
5317
|
gitLinks: process.env.NOLTO_GIT_LINKS !== "0",
|
|
5128
5318
|
http,
|
|
5129
5319
|
log: (line2) => writeOut(`[${path20.basename(root)}] ${line2}
|
|
@@ -5226,7 +5416,7 @@ stale: ${result.stale}`, deps.output.mode);
|
|
|
5226
5416
|
uid: process.getuid?.(),
|
|
5227
5417
|
exec: async (cmd) => {
|
|
5228
5418
|
try {
|
|
5229
|
-
await
|
|
5419
|
+
await promisify4(execFile5)(cmd[0], cmd.slice(1));
|
|
5230
5420
|
return { code: 0, stderr: "" };
|
|
5231
5421
|
} catch (error) {
|
|
5232
5422
|
const e = error;
|
|
@@ -5269,13 +5459,13 @@ stale: ${result.stale}`, deps.output.mode);
|
|
|
5269
5459
|
}
|
|
5270
5460
|
|
|
5271
5461
|
// src/update-cli.ts
|
|
5272
|
-
import { execFile as
|
|
5462
|
+
import { execFile as execFile6 } from "child_process";
|
|
5273
5463
|
import { existsSync as existsSync8 } from "fs";
|
|
5274
5464
|
import { realpath as realpath5 } from "fs/promises";
|
|
5275
5465
|
import { createRequire as createRequire2 } from "module";
|
|
5276
5466
|
import path22 from "path";
|
|
5277
5467
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
5278
|
-
import { promisify as
|
|
5468
|
+
import { promisify as promisify5 } from "util";
|
|
5279
5469
|
|
|
5280
5470
|
// src/update-notifier.ts
|
|
5281
5471
|
import { readFile as readFile16, writeFile as writeFile10, mkdir as mkdir8 } from "fs/promises";
|
|
@@ -5434,6 +5624,9 @@ async function updateCliWith(deps) {
|
|
|
5434
5624
|
5
|
|
5435
5625
|
);
|
|
5436
5626
|
}
|
|
5627
|
+
if (!VERSION_PATTERN.test(latest2)) {
|
|
5628
|
+
throw new CliError("The npm registry returned an unexpected version string; not updating.", 5);
|
|
5629
|
+
}
|
|
5437
5630
|
if (!isNewerVersion(latest2, deps.currentVersion)) {
|
|
5438
5631
|
deps.log(`Already up to date (${PACKAGE2} ${deps.currentVersion}).`);
|
|
5439
5632
|
return {
|
|
@@ -5498,7 +5691,7 @@ function getCurrentVersion() {
|
|
|
5498
5691
|
}
|
|
5499
5692
|
}
|
|
5500
5693
|
async function updateCli(opts = {}) {
|
|
5501
|
-
const execFileAsync =
|
|
5694
|
+
const execFileAsync = promisify5(execFile6);
|
|
5502
5695
|
const scriptPath = await realpath5(process.argv[1] ?? "");
|
|
5503
5696
|
return updateCliWith({
|
|
5504
5697
|
currentVersion: getCurrentVersion(),
|
|
@@ -5566,12 +5759,12 @@ function chooseStatus(base, ours, theirs) {
|
|
|
5566
5759
|
if (!oursChanged) return theirs.status;
|
|
5567
5760
|
if (!theirsChanged) return ours.status;
|
|
5568
5761
|
}
|
|
5569
|
-
const
|
|
5570
|
-
if (
|
|
5762
|
+
const candidates2 = [ours, theirs];
|
|
5763
|
+
if (candidates2.some((task) => task.status === "done" && task.completedAt != null)) {
|
|
5571
5764
|
return "done";
|
|
5572
5765
|
}
|
|
5573
5766
|
for (const status of ["blocked", "in-progress", "todo"]) {
|
|
5574
|
-
if (
|
|
5767
|
+
if (candidates2.some((task) => task.status === status)) return status;
|
|
5575
5768
|
}
|
|
5576
5769
|
return base?.status !== "done" ? base?.status ?? "todo" : "todo";
|
|
5577
5770
|
}
|
|
@@ -5852,9 +6045,9 @@ function resolveEntry(ctx, name, target, deleted = false) {
|
|
|
5852
6045
|
const branch = target.branch ?? ctx.git.branch;
|
|
5853
6046
|
const named = ctx.cache.state.entries.filter((e) => e.name === name && (!scope || e.scope === scope));
|
|
5854
6047
|
const inRepo = (e) => e.scope !== "branch" || e.repoIdentity === ctx.git.repoIdentity;
|
|
5855
|
-
const
|
|
5856
|
-
if (
|
|
5857
|
-
if (
|
|
6048
|
+
const candidates2 = named.filter((e) => inRepo(e) && (e.scope !== "branch" || e.branch === branch) && (deleted || !e.deleted));
|
|
6049
|
+
if (candidates2.length > 1) throw new CliError(`\u30E1\u30E2\u30EA ${terminalLine(name)} \u306F\u66D6\u6627\u3067\u3059: ${candidates2.map((e) => `${e.scope}/${terminalLine(e.name)}`).join(", ")}`, 2, "--scope \u3092\u4ED8\u3051\u308B");
|
|
6050
|
+
if (candidates2.length) return candidates2[0];
|
|
5858
6051
|
const others = [...new Set(named.filter((e) => e.scope === "branch" && inRepo(e) && e.branch !== branch && !e.deleted).map((e) => e.branch))];
|
|
5859
6052
|
if (others.length) {
|
|
5860
6053
|
throw new CliError(`\u30E1\u30E2\u30EA ${terminalLine(name)} \u306F\u4ECA\u306E\u30D6\u30E9\u30F3\u30C1\u306B\u3042\u308A\u307E\u305B\u3093\u3002\u307B\u304B\u306E\u30D6\u30E9\u30F3\u30C1: ${others.map(terminalLine).join(", ")}`, 2, `--branch ${commandArg(others[0], "<branch>")} \u3092\u4ED8\u3051\u308B`);
|
|
@@ -6065,9 +6258,9 @@ function register15(program, deps) {
|
|
|
6065
6258
|
ctx.cache.state.cleanupCandidates = fetched;
|
|
6066
6259
|
await updateCache(ctx, deps, [], true);
|
|
6067
6260
|
}
|
|
6068
|
-
const
|
|
6069
|
-
printResult(deps.output.mode === "json" ? { candidates } : [
|
|
6070
|
-
...
|
|
6261
|
+
const candidates2 = currentCleanupCandidates(ctx.cache.state, ctx.git);
|
|
6262
|
+
printResult(deps.output.mode === "json" ? { candidates: candidates2 } : [
|
|
6263
|
+
...candidates2.length ? candidates2.map((c) => `${c.scope}/${terminalLine(c.name)} \u2014 ${cleanupReason(c.reason)}`) : ["\u6574\u7406\u5019\u88DC\u306F\u3042\u308A\u307E\u305B\u3093"],
|
|
6071
6264
|
...fetched === null ? ["(\u6700\u7D42\u540C\u671F\u306E\u6642\u70B9\u306E\u5019\u88DC)"] : []
|
|
6072
6265
|
].join("\n"), deps.output.mode);
|
|
6073
6266
|
});
|
|
@@ -6091,10 +6284,10 @@ function register15(program, deps) {
|
|
|
6091
6284
|
...opts.ai === false ? { aiSkip: true } : {},
|
|
6092
6285
|
...scope === "branch" ? { repoIdentity: ctx.git.repoIdentity, branch: ctx.git.branch } : {}
|
|
6093
6286
|
}, headers()), "put", draft.name);
|
|
6094
|
-
const
|
|
6095
|
-
if (
|
|
6096
|
-
ctx.cache.state.cleanupCandidates =
|
|
6097
|
-
response.cleanupCandidates =
|
|
6287
|
+
const candidates2 = await fetchCandidates(deps, ctx, AbortSignal.timeout(3e3));
|
|
6288
|
+
if (candidates2 !== null) {
|
|
6289
|
+
ctx.cache.state.cleanupCandidates = candidates2;
|
|
6290
|
+
response.cleanupCandidates = candidates2;
|
|
6098
6291
|
} else {
|
|
6099
6292
|
const changed = /* @__PURE__ */ new Set([response.entry.id, ...(response.affected ?? []).map((a) => a.entryId)]);
|
|
6100
6293
|
ctx.cache.state.cleanupCandidates = (ctx.cache.state.cleanupCandidates ?? []).filter((c) => !changed.has(c.entryId));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nolto/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "CLI for syncing repository roadmaps with Nolto.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
15
|
+
"node": ">=22"
|
|
16
16
|
},
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|