@nolto/cli 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +60 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -389,7 +389,7 @@ ${MEMORY_INSTRUCTIONS}
|
|
|
389
389
|
// src/index.ts
|
|
390
390
|
import { createRequire as createRequire3 } from "module";
|
|
391
391
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
392
|
-
import
|
|
392
|
+
import path24 from "path";
|
|
393
393
|
import os5 from "os";
|
|
394
394
|
import { CommanderError } from "commander";
|
|
395
395
|
|
|
@@ -608,11 +608,11 @@ function maskToken(token) {
|
|
|
608
608
|
function createHttpClient(opts) {
|
|
609
609
|
const { baseUrl, version, token } = opts;
|
|
610
610
|
const base = baseUrl.replace(/\/+$/, "");
|
|
611
|
-
async function request(method,
|
|
612
|
-
if (!
|
|
613
|
-
throw new CliError(`HTTP client path must start with /api/, got: ${
|
|
611
|
+
async function request(method, path25, body, extraHeaders, signal) {
|
|
612
|
+
if (!path25.startsWith("/api/")) {
|
|
613
|
+
throw new CliError(`HTTP client path must start with /api/, got: ${path25}`, 2);
|
|
614
614
|
}
|
|
615
|
-
const url = `${base}${
|
|
615
|
+
const url = `${base}${path25}`;
|
|
616
616
|
const headers2 = {
|
|
617
617
|
...extraHeaders,
|
|
618
618
|
"Content-Type": "application/json",
|
|
@@ -829,12 +829,12 @@ function normalizeRemote(raw) {
|
|
|
829
829
|
const firstSlash = s.indexOf("/");
|
|
830
830
|
if (firstSlash <= 0) return null;
|
|
831
831
|
let host = s.slice(0, firstSlash).toLowerCase();
|
|
832
|
-
let
|
|
832
|
+
let path25 = s.slice(firstSlash + 1);
|
|
833
833
|
if (hadScheme) host = host.replace(/:\d+$/, "");
|
|
834
|
-
|
|
835
|
-
if (
|
|
836
|
-
if (HOSTED_LOWERCASE_PATH.has(host))
|
|
837
|
-
return `${host}/${
|
|
834
|
+
path25 = path25.replace(/\/+/g, "/").replace(/^\/+/, "").replace(/\/+$/, "").replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
835
|
+
if (path25.length === 0) return null;
|
|
836
|
+
if (HOSTED_LOWERCASE_PATH.has(host)) path25 = path25.toLowerCase();
|
|
837
|
+
return `${host}/${path25}`;
|
|
838
838
|
}
|
|
839
839
|
function repoIdentityToString(id) {
|
|
840
840
|
return `${id.kind}:${id.value}`;
|
|
@@ -1169,8 +1169,15 @@ function formatIssueView(bundle) {
|
|
|
1169
1169
|
categories: issue.categories.map((row) => row.name).join(", "),
|
|
1170
1170
|
parent: issue.parent?.key ?? "\u2014"
|
|
1171
1171
|
});
|
|
1172
|
-
const comments = bundle.comments.map((comment) =>
|
|
1173
|
-
|
|
1172
|
+
const comments = bundle.comments.map((comment) => {
|
|
1173
|
+
let via = "";
|
|
1174
|
+
if (!comment.deletedAt && comment.via) {
|
|
1175
|
+
const name = comment.via.tokenName.replace(new RegExp("\\p{Cf}", "gu"), "").trim();
|
|
1176
|
+
via = comment.via.kind === "oauth_app" ? name ? ` [${name} \u7D4C\u7531]` : " [\u30A2\u30D7\u30EA\u7D4C\u7531]" : ` [API \u7D4C\u7531: ${comment.via.tokenName}]`;
|
|
1177
|
+
}
|
|
1178
|
+
return `${personLabel(comment.author)} / ${formatTimestamp(comment.createdAt)}${via}
|
|
1179
|
+
${comment.deletedAt ? "\u30B3\u30E1\u30F3\u30C8\u306F\u524A\u9664\u3055\u308C\u3066\u3044\u307E\u3059\u3002" : comment.body}`;
|
|
1180
|
+
});
|
|
1174
1181
|
return [attributes, issue.body, ...comments].join("\n\n");
|
|
1175
1182
|
}
|
|
1176
1183
|
function addIssueToRoadmapTask(roadmapJson, taskId, key) {
|
|
@@ -3610,6 +3617,8 @@ async function promptHidden(rl, prompt) {
|
|
|
3610
3617
|
|
|
3611
3618
|
// src/commands/login.ts
|
|
3612
3619
|
import readline4 from "readline/promises";
|
|
3620
|
+
import { readdir as readdir6, rm as rm3 } from "fs/promises";
|
|
3621
|
+
import path18 from "path";
|
|
3613
3622
|
|
|
3614
3623
|
// src/login-poll.ts
|
|
3615
3624
|
async function pollUntilToken(opts) {
|
|
@@ -3730,6 +3739,13 @@ function register6(program, deps) {
|
|
|
3730
3739
|
token
|
|
3731
3740
|
};
|
|
3732
3741
|
await saveConfigFile(configPath, newConfig);
|
|
3742
|
+
const projects = await readdir6(path18.join(path18.dirname(configPath), "projects")).catch(() => []);
|
|
3743
|
+
for (const project of projects) {
|
|
3744
|
+
try {
|
|
3745
|
+
await rm3(memoryDir(configPath, project), { recursive: true, force: true });
|
|
3746
|
+
} catch {
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3733
3749
|
process.stdout.write("\n");
|
|
3734
3750
|
if (output.mode === "json") {
|
|
3735
3751
|
process.stdout.write(
|
|
@@ -4017,11 +4033,11 @@ import { execFile as execFile4 } from "child_process";
|
|
|
4017
4033
|
import { promisify as promisify3 } from "util";
|
|
4018
4034
|
import { readFile as readFile15, realpath as realpath4 } from "fs/promises";
|
|
4019
4035
|
import { existsSync as existsSync7, mkdirSync } from "fs";
|
|
4020
|
-
import
|
|
4036
|
+
import path21 from "path";
|
|
4021
4037
|
import chokidar from "chokidar";
|
|
4022
4038
|
|
|
4023
4039
|
// src/watch-core.ts
|
|
4024
|
-
import
|
|
4040
|
+
import path19 from "path";
|
|
4025
4041
|
var WatchSet = class {
|
|
4026
4042
|
constructor(deps) {
|
|
4027
4043
|
this.deps = deps;
|
|
@@ -4070,7 +4086,7 @@ async function reloadRoots(deps) {
|
|
|
4070
4086
|
continue;
|
|
4071
4087
|
}
|
|
4072
4088
|
try {
|
|
4073
|
-
const projectId = repo.projectId ?? (await loadRepoBinding(
|
|
4089
|
+
const projectId = repo.projectId ?? (await loadRepoBinding(path19.join(repo.root, "nolto.json")))?.projectId;
|
|
4074
4090
|
if (projectId) repos.push({ root: repo.root, projectId });
|
|
4075
4091
|
else deps.warn(`registered repo has no project binding, skipping: ${repo.root}`);
|
|
4076
4092
|
} catch (err) {
|
|
@@ -4141,7 +4157,7 @@ var RepoWatch = class {
|
|
|
4141
4157
|
};
|
|
4142
4158
|
|
|
4143
4159
|
// src/service-install.ts
|
|
4144
|
-
import
|
|
4160
|
+
import path20 from "path";
|
|
4145
4161
|
import os4 from "os";
|
|
4146
4162
|
function buildUnitFile(args) {
|
|
4147
4163
|
return [
|
|
@@ -4161,8 +4177,8 @@ function buildUnitFile(args) {
|
|
|
4161
4177
|
}
|
|
4162
4178
|
function getUnitPath(env) {
|
|
4163
4179
|
const xdg = env["XDG_CONFIG_HOME"];
|
|
4164
|
-
const base = xdg != null && xdg.length > 0 ? xdg :
|
|
4165
|
-
return
|
|
4180
|
+
const base = xdg != null && xdg.length > 0 ? xdg : path20.join(os4.homedir(), ".config");
|
|
4181
|
+
return path20.join(base, "systemd", "user", "nolto-watch.service");
|
|
4166
4182
|
}
|
|
4167
4183
|
async function installServiceWith(deps) {
|
|
4168
4184
|
if (deps.platform !== "linux") {
|
|
@@ -4173,7 +4189,7 @@ async function installServiceWith(deps) {
|
|
|
4173
4189
|
);
|
|
4174
4190
|
}
|
|
4175
4191
|
const unitPath = getUnitPath(deps.env);
|
|
4176
|
-
await deps.mkdir(
|
|
4192
|
+
await deps.mkdir(path20.dirname(unitPath));
|
|
4177
4193
|
await deps.writeFile(unitPath, buildUnitFile({ nodePath: deps.nodePath, scriptPath: deps.scriptPath }));
|
|
4178
4194
|
deps.log(`Wrote ${unitPath}`);
|
|
4179
4195
|
const reload = await deps.exec(["systemctl", "--user", "daemon-reload"]);
|
|
@@ -4195,7 +4211,7 @@ async function installService() {
|
|
|
4195
4211
|
platform: process.platform,
|
|
4196
4212
|
env: process.env,
|
|
4197
4213
|
nodePath: process.execPath,
|
|
4198
|
-
scriptPath:
|
|
4214
|
+
scriptPath: path20.resolve(process.argv[1] ?? ""),
|
|
4199
4215
|
writeFile: (p, content) => writeFile11(p, content, "utf8"),
|
|
4200
4216
|
mkdir: async (p) => {
|
|
4201
4217
|
await mkdir9(p, { recursive: true });
|
|
@@ -4337,7 +4353,7 @@ function register10(program, deps) {
|
|
|
4337
4353
|
const startRepo = ({ root, projectId }) => {
|
|
4338
4354
|
const roadmapsPath = cacheDir(process.env, projectId);
|
|
4339
4355
|
const warn2 = (line2) => {
|
|
4340
|
-
process.stderr.write(line2.startsWith(" ") ? line2 + "\n" : `Warning: [${
|
|
4356
|
+
process.stderr.write(line2.startsWith(" ") ? line2 + "\n" : `Warning: [${path21.basename(root)}] ${line2}
|
|
4341
4357
|
`);
|
|
4342
4358
|
};
|
|
4343
4359
|
mkdirSync(roadmapsPath, { recursive: true, mode: 448 });
|
|
@@ -4354,7 +4370,7 @@ function register10(program, deps) {
|
|
|
4354
4370
|
exec: promisify3(execFile4),
|
|
4355
4371
|
gitLinks: process.env.NOLTO_GIT_LINKS !== "0",
|
|
4356
4372
|
http,
|
|
4357
|
-
log: (line2) => process.stdout.write(`[${
|
|
4373
|
+
log: (line2) => process.stdout.write(`[${path21.basename(root)}] ${line2}
|
|
4358
4374
|
`),
|
|
4359
4375
|
warn: warn2
|
|
4360
4376
|
}
|
|
@@ -4367,7 +4383,7 @@ function register10(program, deps) {
|
|
|
4367
4383
|
warn: (line2) => process.stderr.write(line2 + "\n")
|
|
4368
4384
|
});
|
|
4369
4385
|
watcher.on("all", (_event, filePath) => {
|
|
4370
|
-
if (
|
|
4386
|
+
if (path21.dirname(filePath) === roadmapsPath && !filePath.endsWith(".json")) return;
|
|
4371
4387
|
repoWatch.handleEvent(filePath);
|
|
4372
4388
|
});
|
|
4373
4389
|
void checkSkillDrift(root, { homeSkillDirs: deps.homeSkillDirs }).then((drifted) => {
|
|
@@ -4487,7 +4503,7 @@ stale: ${result.stale}`, deps.output.mode);
|
|
|
4487
4503
|
printResult(deps.output.mode === "json" ? { repos } : repos.map((repo) => `${repo.root} ${repo.projectId ?? "\u2014"}${repo.exists ? "" : " (missing)"}`).join("\n"), deps.output.mode);
|
|
4488
4504
|
});
|
|
4489
4505
|
watch.command("remove [root]").description("Remove a repository from the watch registry.").action(async (arg) => {
|
|
4490
|
-
const root = arg === void 0 ? findRepoRoot(resolveStartDir(process.env, process.cwd())).root :
|
|
4506
|
+
const root = arg === void 0 ? findRepoRoot(resolveStartDir(process.env, process.cwd())).root : path21.resolve(arg);
|
|
4491
4507
|
const { removed } = await removeRepoFromRegistry(getRegistryPath(process.env), root);
|
|
4492
4508
|
if (!removed) throw new CliError(`${root} is not in the watch registry.`, 2, "Run `nolto watch list` to see registered repositories.");
|
|
4493
4509
|
printResult(deps.output.mode === "json" ? { removed: true, root } : `Removed ${root} from the watch registry.`, deps.output.mode);
|
|
@@ -4499,14 +4515,14 @@ import { execFile as execFile5 } from "child_process";
|
|
|
4499
4515
|
import { existsSync as existsSync8 } from "fs";
|
|
4500
4516
|
import { realpath as realpath5 } from "fs/promises";
|
|
4501
4517
|
import { createRequire as createRequire2 } from "module";
|
|
4502
|
-
import
|
|
4518
|
+
import path23 from "path";
|
|
4503
4519
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
4504
4520
|
import { promisify as promisify4 } from "util";
|
|
4505
4521
|
|
|
4506
4522
|
// src/update-notifier.ts
|
|
4507
4523
|
import { readFile as readFile16, writeFile as writeFile9, mkdir as mkdir8 } from "fs/promises";
|
|
4508
4524
|
import https from "https";
|
|
4509
|
-
import
|
|
4525
|
+
import path22 from "path";
|
|
4510
4526
|
var PACKAGE = "@nolto/cli";
|
|
4511
4527
|
var CACHE_FILE = "update-check.json";
|
|
4512
4528
|
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -4564,7 +4580,7 @@ function fetchLatestFromRegistry(timeoutMs = REQUEST_TIMEOUT_MS, opts = {}) {
|
|
|
4564
4580
|
});
|
|
4565
4581
|
}
|
|
4566
4582
|
async function writeUpdateCache(cachePath, now, latest2) {
|
|
4567
|
-
await mkdir8(
|
|
4583
|
+
await mkdir8(path22.dirname(cachePath), { recursive: true });
|
|
4568
4584
|
const payload = { checkedAt: now, latest: latest2 };
|
|
4569
4585
|
await writeFile9(cachePath, JSON.stringify(payload), { mode: 384 });
|
|
4570
4586
|
}
|
|
@@ -4575,7 +4591,7 @@ async function refreshCache(cachePath, now, fetchLatest) {
|
|
|
4575
4591
|
}
|
|
4576
4592
|
async function checkForUpdate(opts) {
|
|
4577
4593
|
if (isDisabled(opts.env)) return null;
|
|
4578
|
-
const cachePath =
|
|
4594
|
+
const cachePath = path22.join(opts.configDir, CACHE_FILE);
|
|
4579
4595
|
let cache = {};
|
|
4580
4596
|
try {
|
|
4581
4597
|
cache = JSON.parse(await readFile16(cachePath, "utf8"));
|
|
@@ -4684,7 +4700,7 @@ async function updateCliWith(deps) {
|
|
|
4684
4700
|
}
|
|
4685
4701
|
deps.log(`Updated ${PACKAGE2} ${deps.currentVersion} \u2192 ${latest2}.`);
|
|
4686
4702
|
await deps.writeCache(
|
|
4687
|
-
|
|
4703
|
+
path23.join(deps.configDir, UPDATE_CACHE_FILE),
|
|
4688
4704
|
deps.now,
|
|
4689
4705
|
latest2
|
|
4690
4706
|
).catch(() => void 0);
|
|
@@ -4715,10 +4731,10 @@ async function updateCliWith(deps) {
|
|
|
4715
4731
|
};
|
|
4716
4732
|
}
|
|
4717
4733
|
function getCurrentVersion() {
|
|
4718
|
-
const dirname =
|
|
4734
|
+
const dirname = path23.dirname(fileURLToPath3(import.meta.url));
|
|
4719
4735
|
const require3 = createRequire2(import.meta.url);
|
|
4720
4736
|
try {
|
|
4721
|
-
const pkg = require3(
|
|
4737
|
+
const pkg = require3(path23.resolve(dirname, "../package.json"));
|
|
4722
4738
|
return pkg.version ?? "0.0.0";
|
|
4723
4739
|
} catch {
|
|
4724
4740
|
return "0.0.0";
|
|
@@ -5144,6 +5160,7 @@ function printWrite(deps, ctx, action, response, isNew = false, put) {
|
|
|
5144
5160
|
}
|
|
5145
5161
|
async function pull2(deps, opts) {
|
|
5146
5162
|
let ctx;
|
|
5163
|
+
let userChanged = false;
|
|
5147
5164
|
let updateNotice = Promise.resolve("");
|
|
5148
5165
|
let updateRefresh = Promise.resolve();
|
|
5149
5166
|
const signal = opts.hook ? AbortSignal.timeout(8e3) : void 0;
|
|
@@ -5179,7 +5196,11 @@ async function pull2(deps, opts) {
|
|
|
5179
5196
|
if (opts.hook && typeof opts.hook === "string" && !["claude", "codex", "gemini"].includes(opts.hook)) throw new CliError("Unknown hook agent", 2);
|
|
5180
5197
|
const scope = opts.scope ? [...new Set(opts.scope.split(",").map((s) => parseScope(s.trim(), scopeHint)))].sort().join(",") : "";
|
|
5181
5198
|
const previous = ctx.cache.state.entries;
|
|
5182
|
-
const
|
|
5199
|
+
const profile = await deps.http.get("/api/me/profile", signal).catch(() => null);
|
|
5200
|
+
const profileUserId = typeof profile?.profile?.id === "string" ? profile.profile.id : void 0;
|
|
5201
|
+
const userId = profileUserId ?? ctx.cache.state.userId;
|
|
5202
|
+
userChanged = profileUserId !== void 0 && (profileUserId !== ctx.cache.state.userId || !ctx.cache.state.userId && previous.length > 0);
|
|
5203
|
+
const reset = ctx.cache.meta.cursor === 0 || ctx.cache.state.scope !== scope || userChanged;
|
|
5183
5204
|
let cursor = reset ? 0 : ctx.cache.meta.cursor;
|
|
5184
5205
|
let entries = reset ? [] : previous;
|
|
5185
5206
|
while (true) {
|
|
@@ -5190,12 +5211,8 @@ async function pull2(deps, opts) {
|
|
|
5190
5211
|
cursor = page.cursor;
|
|
5191
5212
|
if (!page.hasMore) break;
|
|
5192
5213
|
}
|
|
5193
|
-
const
|
|
5194
|
-
deps.http.get("/api/projects", signal).catch(() => null),
|
|
5195
|
-
deps.http.get("/api/me/profile", signal).catch(() => null)
|
|
5196
|
-
]);
|
|
5214
|
+
const projects = await deps.http.get("/api/projects", signal).catch(() => null);
|
|
5197
5215
|
const projectName = projects?.projects?.find((p) => p.id === ctx.project)?.name ?? ctx.cache.state.projectName;
|
|
5198
|
-
const userId = typeof profile?.profile?.id === "string" ? profile.profile.id : ctx.cache.state.userId;
|
|
5199
5216
|
const next = { ...ctx, cache: { state: { entries, scope, projectName, ...userId ? { userId } : {} }, meta: { cursor, pulledAt: (/* @__PURE__ */ new Date()).toISOString() } } };
|
|
5200
5217
|
const text = await memoryIndexText(next, deps);
|
|
5201
5218
|
const unsafe = await saveMemoryCache(ctx.dir, next.cache, previous, text, reset);
|
|
@@ -5206,7 +5223,7 @@ async function pull2(deps, opts) {
|
|
|
5206
5223
|
} catch (error) {
|
|
5207
5224
|
if (!opts.hook) throw error;
|
|
5208
5225
|
let text = pullHint;
|
|
5209
|
-
if (ctx?.cache.meta.pulledAt) {
|
|
5226
|
+
if (!userChanged && ctx?.cache.meta.pulledAt) {
|
|
5210
5227
|
try {
|
|
5211
5228
|
const age = Math.max(0, Math.floor((Date.now() - Date.parse(ctx.cache.meta.pulledAt)) / 6e4));
|
|
5212
5229
|
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)
|
|
@@ -5386,11 +5403,11 @@ function buildProgram(deps) {
|
|
|
5386
5403
|
}
|
|
5387
5404
|
|
|
5388
5405
|
// src/index.ts
|
|
5389
|
-
var __dirname3 =
|
|
5406
|
+
var __dirname3 = path24.dirname(fileURLToPath4(import.meta.url));
|
|
5390
5407
|
var require2 = createRequire3(import.meta.url);
|
|
5391
5408
|
function getVersion() {
|
|
5392
5409
|
try {
|
|
5393
|
-
const pkgPath =
|
|
5410
|
+
const pkgPath = path24.resolve(__dirname3, "../package.json");
|
|
5394
5411
|
const pkg = require2(pkgPath);
|
|
5395
5412
|
return pkg.version ?? "0.0.0";
|
|
5396
5413
|
} catch {
|
|
@@ -5444,10 +5461,10 @@ async function main() {
|
|
|
5444
5461
|
output: { mode },
|
|
5445
5462
|
version,
|
|
5446
5463
|
configPath,
|
|
5447
|
-
claudeProjectsDir:
|
|
5464
|
+
claudeProjectsDir: path24.join(process.env.CLAUDE_CONFIG_DIR ?? path24.join(os5.homedir(), ".claude"), "projects"),
|
|
5448
5465
|
homeSkillDirs: [
|
|
5449
|
-
|
|
5450
|
-
|
|
5466
|
+
path24.join(process.env.CLAUDE_CONFIG_DIR ?? path24.join(os5.homedir(), ".claude"), "skills"),
|
|
5467
|
+
path24.join(os5.homedir(), ".agents", "skills")
|
|
5451
5468
|
],
|
|
5452
5469
|
repoBinding
|
|
5453
5470
|
});
|