@gobing-ai/knowledge-kit 0.1.24 → 0.1.27
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/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +416 -79
- package/package.json +1 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +47 -6
- package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
- package/plugins/generations/music-gen/dist/index.js +17 -13
- package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
- package/plugins/kk/decisions/extract/ai-news.yaml +8 -1
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +4 -4
- package/plugins/kk/publish-presets/itc-main.json +39 -23
- package/plugins/kk/scripts/cn-lead-gate.ts +494 -0
- package/plugins/kk/scripts/daily-stages.ts +880 -131
- package/plugins/kk/scripts/kk-workflow-stages.ts +58 -3
- package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
- package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
- package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
- package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +25 -6
- package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
- package/plugins/kk/skills/news-editorial/references/selection.md +42 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +1 -1
- package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
- package/plugins/kk/workflows/kk-news-generate.yaml +71 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +35 -3
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/cnblogs-pub/dist/index.js +35 -3
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/csdn-pub/dist/index.js +35 -3
- package/plugins/publishings/csdn-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/infoq-pub/dist/index.js +35 -3
- package/plugins/publishings/infoq-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/jike-pub/dist/index.js +35 -3
- package/plugins/publishings/jike-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/juejin-pub/dist/index.js +35 -3
- package/plugins/publishings/juejin-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/linkedin-pub/dist/index.js +86 -14
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +52 -6
- package/plugins/publishings/linkedin-pub/src/index.ts +126 -9
- package/plugins/publishings/medium-pub/dist/index.js +9229 -279
- package/plugins/publishings/medium-pub/dist/profile-check.js +21205 -0
- package/plugins/publishings/medium-pub/package.json +3 -1
- package/plugins/publishings/medium-pub/plugin.json +6 -1
- package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
- package/plugins/publishings/medium-pub/src/index.ts +17 -1
- package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
- package/plugins/publishings/shipinhao-pub/dist/index.js +38 -4
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +37 -4
- package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +11 -4
- package/plugins/publishings/sspai-pub/dist/index.js +35 -3
- package/plugins/publishings/sspai-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/substack-pub/dist/index.js +35 -3
- package/plugins/publishings/substack-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/surfdash-pub/dist/index.js +53 -15
- package/plugins/publishings/surfdash-pub/src/index.ts +31 -4
- package/plugins/publishings/surfdash-pub/src/patch.ts +81 -12
- package/plugins/publishings/threads-pub/dist/index.js +35 -3
- package/plugins/publishings/threads-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/wechatmp-pub/dist/index.js +326 -44
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +69 -4
- package/plugins/publishings/wechatmp-pub/src/flow.ts +447 -53
- package/plugins/publishings/wechatmp-pub/src/index.ts +68 -2
- package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
- package/plugins/publishings/weibo-pub/dist/index.js +58 -9
- package/plugins/publishings/weibo-pub/dist/profile-check.js +57 -9
- package/plugins/publishings/weibo-pub/plugin.json +1 -1
- package/plugins/publishings/weibo-pub/src/index.ts +76 -8
- package/plugins/publishings/x-pub/dist/index.js +35 -3
- package/plugins/publishings/x-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/xhs-pub/dist/index.js +35 -3
- package/plugins/publishings/xhs-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +35 -3
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +35 -3
package/dist/index.js
CHANGED
|
@@ -38202,7 +38202,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
38202
38202
|
const leaseDir = join15(leaseRoot, id);
|
|
38203
38203
|
await fileSystem.ensureDir(leaseRoot);
|
|
38204
38204
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
38205
|
-
|
|
38205
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
38206
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
38207
|
+
}
|
|
38208
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
38209
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
38210
|
+
}
|
|
38206
38211
|
}
|
|
38207
38212
|
const token = randomBytes(16).toString("hex");
|
|
38208
38213
|
const owner = {
|
|
@@ -38318,7 +38323,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
38318
38323
|
}
|
|
38319
38324
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
38320
38325
|
}
|
|
38321
|
-
|
|
38326
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
38327
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
38328
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
38329
|
+
}
|
|
38330
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
38331
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
38332
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
38333
|
+
return false;
|
|
38334
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
38335
|
+
return false;
|
|
38336
|
+
const target = staleLeaseDir(leaseDir);
|
|
38337
|
+
try {
|
|
38338
|
+
rename(leaseDir, target);
|
|
38339
|
+
} catch {
|
|
38340
|
+
return false;
|
|
38341
|
+
}
|
|
38342
|
+
const moved = await readOwner(fileSystem, target);
|
|
38343
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
38344
|
+
try {
|
|
38345
|
+
rename(target, leaseDir);
|
|
38346
|
+
} catch {}
|
|
38347
|
+
return false;
|
|
38348
|
+
}
|
|
38349
|
+
return true;
|
|
38350
|
+
}
|
|
38351
|
+
function staleLeaseDir(leaseDir) {
|
|
38352
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
38353
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
38322
38354
|
}
|
|
38323
38355
|
async function holderResidue(fileSystem, leaseDir) {
|
|
38324
38356
|
try {
|
|
@@ -38930,6 +38962,7 @@ __export(exports_browser, {
|
|
|
38930
38962
|
createExclusiveFile: () => createExclusiveFile,
|
|
38931
38963
|
createKkBrowserLauncher: () => createKkBrowserLauncher,
|
|
38932
38964
|
createShadowFinder: () => createShadowFinder,
|
|
38965
|
+
ensureProfileDir: () => ensureProfileDir2,
|
|
38933
38966
|
enterDelegatedLease: () => enterDelegatedLease,
|
|
38934
38967
|
execBot: () => execBot,
|
|
38935
38968
|
execFailureDetail: () => execFailureDetail,
|
|
@@ -38938,6 +38971,7 @@ __export(exports_browser, {
|
|
|
38938
38971
|
findLeftoverTransaction: () => findLeftoverTransaction,
|
|
38939
38972
|
findShadowControl: () => findShadowControl,
|
|
38940
38973
|
injectBrowserAntiDetection: () => injectBrowserAntiDetection,
|
|
38974
|
+
isProcessAlive: () => isProcessAlive,
|
|
38941
38975
|
isSafeBotName: () => isSafeBotName,
|
|
38942
38976
|
isSessionFactDate: () => isSessionFactDate,
|
|
38943
38977
|
isSessionFactIdentity: () => isSessionFactIdentity,
|
|
@@ -38965,6 +38999,7 @@ __export(exports_browser, {
|
|
|
38965
38999
|
resolveSelector: () => resolveSelector,
|
|
38966
39000
|
rmdir: () => rmdir,
|
|
38967
39001
|
runProfileCli: () => runProfileCli,
|
|
39002
|
+
signalSafeRelease: () => signalSafeRelease,
|
|
38968
39003
|
uploadFile: () => uploadFile,
|
|
38969
39004
|
validateExecUrl: () => validateExecUrl,
|
|
38970
39005
|
verifyLeaseHeld: () => verifyLeaseHeld,
|
|
@@ -39090,7 +39125,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
39090
39125
|
return resolveBrowserProfileDir(channel, chosen);
|
|
39091
39126
|
}
|
|
39092
39127
|
async function checkChannelSession(config, opts) {
|
|
39093
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
39128
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
39094
39129
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
39095
39130
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
39096
39131
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -39449,16 +39484,67 @@ async function readIdentityOrUndefined(readIdentity, page) {
|
|
|
39449
39484
|
return;
|
|
39450
39485
|
}
|
|
39451
39486
|
}
|
|
39487
|
+
function signalSafeRelease(options) {
|
|
39488
|
+
const sigintBefore = new Set(process.listeners("SIGINT"));
|
|
39489
|
+
let releasing;
|
|
39490
|
+
const release = (signal) => {
|
|
39491
|
+
releasing ??= (async () => {
|
|
39492
|
+
await options.close().catch(() => {});
|
|
39493
|
+
await options.release().catch((error) => {
|
|
39494
|
+
echoError(`kk: releasing the profile lease after ${signal ?? "shutdown"} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
39495
|
+
});
|
|
39496
|
+
if (signal !== undefined)
|
|
39497
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
39498
|
+
})();
|
|
39499
|
+
return releasing;
|
|
39500
|
+
};
|
|
39501
|
+
const onSigint = () => void release("SIGINT");
|
|
39502
|
+
const onSigterm = () => void release("SIGTERM");
|
|
39503
|
+
process.once("SIGINT", onSigint);
|
|
39504
|
+
process.once("SIGTERM", onSigterm);
|
|
39505
|
+
return {
|
|
39506
|
+
park: () => {
|
|
39507
|
+
const parked = process.listeners("SIGINT").filter((listener) => !sigintBefore.has(listener) && listener !== onSigint);
|
|
39508
|
+
for (const listener of parked)
|
|
39509
|
+
process.off("SIGINT", listener);
|
|
39510
|
+
return () => {
|
|
39511
|
+
for (const listener of parked)
|
|
39512
|
+
process.on("SIGINT", listener);
|
|
39513
|
+
};
|
|
39514
|
+
},
|
|
39515
|
+
shutdown: async (signal) => {
|
|
39516
|
+
process.off("SIGINT", onSigint);
|
|
39517
|
+
process.off("SIGTERM", onSigterm);
|
|
39518
|
+
await release(signal);
|
|
39519
|
+
}
|
|
39520
|
+
};
|
|
39521
|
+
}
|
|
39452
39522
|
async function loginBot(name, url, options = {}) {
|
|
39453
39523
|
assertSafeBotName(name);
|
|
39454
39524
|
const defaultUrl = normalizeBotDefaultUrl(url);
|
|
39455
39525
|
const navigationUrl = url.trim();
|
|
39456
39526
|
const fileSystem = options.fileSystem ?? createNodeFileSystem();
|
|
39457
39527
|
const profileDir = resolveBotProfileDir(name, { root: options.root });
|
|
39458
|
-
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39459
39528
|
let transaction;
|
|
39460
39529
|
let context;
|
|
39461
39530
|
let promoting = false;
|
|
39531
|
+
const childAbort = new AbortController;
|
|
39532
|
+
const leaseRef = {};
|
|
39533
|
+
const shutdown = signalSafeRelease({
|
|
39534
|
+
close: async () => {
|
|
39535
|
+
childAbort.abort();
|
|
39536
|
+
await closeBotContext(context);
|
|
39537
|
+
if (!promoting)
|
|
39538
|
+
await transaction?.abort().catch(() => {});
|
|
39539
|
+
},
|
|
39540
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
39541
|
+
});
|
|
39542
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
39543
|
+
await shutdown.shutdown();
|
|
39544
|
+
throw error;
|
|
39545
|
+
});
|
|
39546
|
+
leaseRef.current = lease;
|
|
39547
|
+
let unpark;
|
|
39462
39548
|
try {
|
|
39463
39549
|
transaction = await beginBotTransaction({
|
|
39464
39550
|
name,
|
|
@@ -39472,11 +39558,13 @@ async function loginBot(name, url, options = {}) {
|
|
|
39472
39558
|
adapter: options.adapter,
|
|
39473
39559
|
transaction,
|
|
39474
39560
|
lease,
|
|
39475
|
-
fileSystem
|
|
39561
|
+
fileSystem,
|
|
39562
|
+
signal: childAbort.signal
|
|
39476
39563
|
});
|
|
39477
39564
|
}
|
|
39478
39565
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: transaction.stageDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39479
39566
|
context = await launcher.launch({ profileDir: transaction.stageDir, headless: false });
|
|
39567
|
+
unpark = shutdown.park();
|
|
39480
39568
|
const page = await openBotPage(context);
|
|
39481
39569
|
await navigateBot(page, navigationUrl);
|
|
39482
39570
|
await focusBotPage(page);
|
|
@@ -39505,21 +39593,24 @@ async function loginBot(name, url, options = {}) {
|
|
|
39505
39593
|
};
|
|
39506
39594
|
} catch (error) {
|
|
39507
39595
|
await closeBotContext(context);
|
|
39596
|
+
context = undefined;
|
|
39508
39597
|
if (!promoting && transaction !== undefined) {
|
|
39509
39598
|
await transaction.abort().catch(() => {});
|
|
39510
39599
|
}
|
|
39511
39600
|
throw error;
|
|
39512
39601
|
} finally {
|
|
39513
|
-
await
|
|
39602
|
+
await shutdown.shutdown();
|
|
39603
|
+
unpark?.();
|
|
39514
39604
|
}
|
|
39515
39605
|
}
|
|
39516
39606
|
async function runAdapterLogin(name, url, ctx) {
|
|
39517
|
-
const { adapter, transaction, lease, fileSystem } = ctx;
|
|
39607
|
+
const { adapter, transaction, lease, fileSystem, signal } = ctx;
|
|
39518
39608
|
const child = await adapter.run({
|
|
39519
39609
|
mode: "login",
|
|
39520
39610
|
profileDir: transaction.stageDir,
|
|
39521
39611
|
url,
|
|
39522
|
-
env: await lease.delegatedEnv(transaction.stageDir)
|
|
39612
|
+
env: await lease.delegatedEnv(transaction.stageDir),
|
|
39613
|
+
...signal === undefined ? {} : { signal }
|
|
39523
39614
|
});
|
|
39524
39615
|
if (child.exitCode === 2) {
|
|
39525
39616
|
throw new BotError("usage", `session adapter '${adapter.pluginName}' reported a usage error (exit 2) \u2014 nothing was saved`);
|
|
@@ -39599,14 +39690,29 @@ async function openBot(name, options = {}) {
|
|
|
39599
39690
|
if (openUrl === undefined) {
|
|
39600
39691
|
throw missingBotProfile(name, lstat(profileDir) !== null);
|
|
39601
39692
|
}
|
|
39602
|
-
const
|
|
39693
|
+
const leaseRef = {};
|
|
39694
|
+
let context;
|
|
39695
|
+
const childAbort = new AbortController;
|
|
39696
|
+
const shutdown = signalSafeRelease({
|
|
39697
|
+
close: async () => {
|
|
39698
|
+
childAbort.abort();
|
|
39699
|
+
await closeBotContext(context);
|
|
39700
|
+
},
|
|
39701
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
39702
|
+
});
|
|
39703
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
39704
|
+
await shutdown.shutdown();
|
|
39705
|
+
throw error;
|
|
39706
|
+
});
|
|
39707
|
+
leaseRef.current = lease;
|
|
39603
39708
|
if (options.adapter !== undefined) {
|
|
39604
39709
|
try {
|
|
39605
39710
|
const child = await options.adapter.run({
|
|
39606
39711
|
mode: "open",
|
|
39607
39712
|
profileDir,
|
|
39608
39713
|
url: openUrl,
|
|
39609
|
-
env: await lease.delegatedEnv(profileDir)
|
|
39714
|
+
env: await lease.delegatedEnv(profileDir),
|
|
39715
|
+
signal: childAbort.signal
|
|
39610
39716
|
});
|
|
39611
39717
|
if (child.exitCode === 2) {
|
|
39612
39718
|
throw new BotError("usage", `session adapter '${options.adapter.pluginName}' reported a usage error (exit 2)`);
|
|
@@ -39620,13 +39726,14 @@ async function openBot(name, options = {}) {
|
|
|
39620
39726
|
message: `closed the local session for bot '${name}' \u2014 the saved profile is unchanged`
|
|
39621
39727
|
};
|
|
39622
39728
|
} finally {
|
|
39623
|
-
await
|
|
39729
|
+
await shutdown.shutdown();
|
|
39624
39730
|
}
|
|
39625
39731
|
}
|
|
39626
|
-
let
|
|
39732
|
+
let unpark;
|
|
39627
39733
|
try {
|
|
39628
39734
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: profileDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39629
39735
|
context = await launcher.launch({ profileDir, headless: false });
|
|
39736
|
+
unpark = shutdown.park();
|
|
39630
39737
|
const closed = new Promise((resolveClose) => {
|
|
39631
39738
|
context?.once("close", () => resolveClose());
|
|
39632
39739
|
});
|
|
@@ -39641,9 +39748,11 @@ async function openBot(name, options = {}) {
|
|
|
39641
39748
|
};
|
|
39642
39749
|
} catch (error) {
|
|
39643
39750
|
await closeBotContext(context);
|
|
39751
|
+
context = undefined;
|
|
39644
39752
|
throw error;
|
|
39645
39753
|
} finally {
|
|
39646
|
-
await
|
|
39754
|
+
await shutdown.shutdown();
|
|
39755
|
+
unpark?.();
|
|
39647
39756
|
}
|
|
39648
39757
|
}
|
|
39649
39758
|
async function execBot(name, request, options = {}) {
|
|
@@ -39853,6 +39962,7 @@ var init_browser = __esm(() => {
|
|
|
39853
39962
|
init_bot_transaction();
|
|
39854
39963
|
init_src();
|
|
39855
39964
|
init_profile_dir2();
|
|
39965
|
+
init_profile_dir2();
|
|
39856
39966
|
init_profile_lease();
|
|
39857
39967
|
init_browser_anti_detection();
|
|
39858
39968
|
init_bot();
|
|
@@ -41072,6 +41182,7 @@ async function replayBotSession(bot, transcript, options) {
|
|
|
41072
41182
|
return { bot, rows, stoppedBeforeSubmit: false };
|
|
41073
41183
|
}
|
|
41074
41184
|
async function replayBot(bot, transcript, options = {}) {
|
|
41185
|
+
await Promise.resolve().then(() => init_browser());
|
|
41075
41186
|
await Promise.resolve().then(() => init_browser());
|
|
41076
41187
|
const { mkdirSync } = await import("fs");
|
|
41077
41188
|
const { join } = await import("path");
|
|
@@ -41080,11 +41191,22 @@ async function replayBot(bot, transcript, options = {}) {
|
|
|
41080
41191
|
const profileDir = resolveBotProfileDir(bot, { root: options.root });
|
|
41081
41192
|
const outDir = options.outDir ?? join(".spur", "run", `bot-replay-${bot}`);
|
|
41082
41193
|
mkdirSync(outDir, { recursive: true });
|
|
41083
|
-
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem });
|
|
41084
41194
|
let context;
|
|
41195
|
+
const leaseRef = {};
|
|
41196
|
+
const shutdown = signalSafeRelease({
|
|
41197
|
+
close: () => closeBotContext(context),
|
|
41198
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
41199
|
+
});
|
|
41200
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
41201
|
+
await shutdown.shutdown();
|
|
41202
|
+
throw error;
|
|
41203
|
+
});
|
|
41204
|
+
leaseRef.current = lease;
|
|
41205
|
+
let unpark;
|
|
41085
41206
|
try {
|
|
41086
41207
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: profileDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
41087
41208
|
context = await launcher.launch({ profileDir, headless: false });
|
|
41209
|
+
unpark = shutdown.park();
|
|
41088
41210
|
const page = await openBotPage(context);
|
|
41089
41211
|
const shots = [];
|
|
41090
41212
|
const result = await replayBotSession(bot, transcript, {
|
|
@@ -41104,8 +41226,8 @@ async function replayBot(bot, transcript, options = {}) {
|
|
|
41104
41226
|
`);
|
|
41105
41227
|
return { result, outDir, replayPath };
|
|
41106
41228
|
} finally {
|
|
41107
|
-
await
|
|
41108
|
-
|
|
41229
|
+
await shutdown.shutdown();
|
|
41230
|
+
unpark?.();
|
|
41109
41231
|
}
|
|
41110
41232
|
}
|
|
41111
41233
|
var UNREACHABLE = '[aria-hidden="true"], [inert]';
|
|
@@ -44013,7 +44135,8 @@ async function spawnPluginSession(opts) {
|
|
|
44013
44135
|
env: pluginEntryEnv(opts),
|
|
44014
44136
|
stdin: "inherit",
|
|
44015
44137
|
stdout: "pipe",
|
|
44016
|
-
stderr: "inherit"
|
|
44138
|
+
stderr: "inherit",
|
|
44139
|
+
...opts.signal === undefined ? {} : { signal: opts.signal }
|
|
44017
44140
|
});
|
|
44018
44141
|
} catch {
|
|
44019
44142
|
return null;
|
|
@@ -49519,13 +49642,20 @@ async function sendRows(options) {
|
|
|
49519
49642
|
if (retry) {
|
|
49520
49643
|
if (!await fs.exists(targetReceiptPath))
|
|
49521
49644
|
continue;
|
|
49645
|
+
let priorRetry;
|
|
49522
49646
|
try {
|
|
49523
|
-
|
|
49524
|
-
if (priorReceipt.status === "succeeded" || priorReceipt.effect !== "none")
|
|
49525
|
-
continue;
|
|
49647
|
+
priorRetry = JSON.parse(await fs.readFile(targetReceiptPath));
|
|
49526
49648
|
} catch {
|
|
49527
49649
|
continue;
|
|
49528
49650
|
}
|
|
49651
|
+
if (priorRetry.status === "succeeded")
|
|
49652
|
+
continue;
|
|
49653
|
+
if (priorRetry.effect !== "none") {
|
|
49654
|
+
const unknownEffect = (priorRetry.status === "uncertain" || priorRetry.effect === "unknown") && (row.mode === "live" || priorRetry.mode === "live");
|
|
49655
|
+
if (!unknownEffect || options.confirmNone !== true)
|
|
49656
|
+
continue;
|
|
49657
|
+
echoError(`${label}: ${row.key} re-attempted on the operator's confirmation that the unknown-effect attempt published nothing (--confirm-none)`);
|
|
49658
|
+
}
|
|
49529
49659
|
reattempt = true;
|
|
49530
49660
|
} else if (await fs.exists(targetReceiptPath)) {
|
|
49531
49661
|
const priorRaw = await fs.exists(targetReceiptPath) ? await fs.readFile(targetReceiptPath) : undefined;
|
|
@@ -50108,7 +50238,7 @@ class UnknownChannelModeError extends Error {
|
|
|
50108
50238
|
}
|
|
50109
50239
|
}
|
|
50110
50240
|
function targetMatchesChannel(target, token) {
|
|
50111
|
-
return target.plugin === token || target.id === token || target.variant !== undefined && `${target.plugin}/${target.variant}` === token;
|
|
50241
|
+
return target.plugin === token || target.id === token || targetId(target) === token || target.variant !== undefined && `${target.plugin}/${target.variant}` === token;
|
|
50112
50242
|
}
|
|
50113
50243
|
function validatePublishChannelTokens(preset, tokens) {
|
|
50114
50244
|
for (const token of tokens) {
|
|
@@ -50208,8 +50338,25 @@ async function runPublishMatrixValidate(args, deps = {}) {
|
|
|
50208
50338
|
}
|
|
50209
50339
|
var LINK_SOURCES = [
|
|
50210
50340
|
{ placeholder: "{{article_url}}", plugin: "surfdash-pub", receipt: "article" },
|
|
50211
|
-
{ placeholder: "{{podcast_url}}", plugin: "podcast-pub", receipt: "podcast" }
|
|
50341
|
+
{ placeholder: "{{podcast_url}}", plugin: "podcast-pub", receipt: "podcast", fallback: "article" }
|
|
50212
50342
|
];
|
|
50343
|
+
function substituteLinkPlaceholders(payloadText, links) {
|
|
50344
|
+
let text = payloadText;
|
|
50345
|
+
const fallbacks = [];
|
|
50346
|
+
for (const source of LINK_SOURCES) {
|
|
50347
|
+
if (!text.includes(source.placeholder))
|
|
50348
|
+
continue;
|
|
50349
|
+
const own = links[source.receipt];
|
|
50350
|
+
const url = own ?? (source.fallback === undefined ? undefined : links[source.fallback]);
|
|
50351
|
+
if (url === undefined)
|
|
50352
|
+
continue;
|
|
50353
|
+
if (own === undefined && source.fallback !== undefined) {
|
|
50354
|
+
fallbacks.push({ placeholder: source.placeholder, source: source.fallback, url });
|
|
50355
|
+
}
|
|
50356
|
+
text = text.split(source.placeholder).join(JSON.stringify(url).slice(1, -1));
|
|
50357
|
+
}
|
|
50358
|
+
return { text, fallbacks };
|
|
50359
|
+
}
|
|
50213
50360
|
async function readPlan(fs, workDir, window) {
|
|
50214
50361
|
const planPath = join10(workDir, "4-publish", `plan.${window}.json`);
|
|
50215
50362
|
if (!await fs.exists(planPath)) {
|
|
@@ -50336,7 +50483,7 @@ async function composePlan(fs, input) {
|
|
|
50336
50483
|
throw new Error(`channel '${liveToken}' is dummy-only and cannot be promoted to live`);
|
|
50337
50484
|
}
|
|
50338
50485
|
const mode = input.dummy ? "dummy" : liveToken !== undefined || target.mode === "live" ? "live" : target.mode === "dummy" ? "dummy" : "draft";
|
|
50339
|
-
if (mode === "live" && safety === undefined) {
|
|
50486
|
+
if (mode === "live" && safety === undefined && bundle.contentType === "news") {
|
|
50340
50487
|
throw new Error(`bundle has no final-variant safety evidence; run the variants safety gate (kk-daily-safety scope=variants) before a live launch`);
|
|
50341
50488
|
}
|
|
50342
50489
|
if (target.variant === undefined) {
|
|
@@ -50371,7 +50518,17 @@ async function composePlan(fs, input) {
|
|
|
50371
50518
|
delete inherited.publishStatus;
|
|
50372
50519
|
delete inherited.published;
|
|
50373
50520
|
delete inherited.status;
|
|
50374
|
-
const nativeMode = mode === "live" ? {
|
|
50521
|
+
const nativeMode = mode === "live" ? {
|
|
50522
|
+
"surfdash-pub": { published: true },
|
|
50523
|
+
"podcast-pub": { status: "published" },
|
|
50524
|
+
"qiita-pub": { private: false, published: true },
|
|
50525
|
+
"zenn-pub": { published: true }
|
|
50526
|
+
} : {
|
|
50527
|
+
"surfdash-pub": { published: false },
|
|
50528
|
+
"podcast-pub": { status: "unpublished" },
|
|
50529
|
+
"qiita-pub": { private: true, published: false },
|
|
50530
|
+
"zenn-pub": { published: false }
|
|
50531
|
+
};
|
|
50375
50532
|
const payload = {
|
|
50376
50533
|
...parsedContent.data,
|
|
50377
50534
|
metadata: {
|
|
@@ -50384,6 +50541,7 @@ async function composePlan(fs, input) {
|
|
|
50384
50541
|
const payloadRelative = `4-publish/payloads/content.${id}.json`;
|
|
50385
50542
|
const payloadText = `${JSON.stringify(payload, null, 2)}
|
|
50386
50543
|
`;
|
|
50544
|
+
const explicitlySelected = mode !== "dummy" && (liveToken !== undefined || input.channels.some((token) => matches(target, token)));
|
|
50387
50545
|
rows.push({
|
|
50388
50546
|
id,
|
|
50389
50547
|
plugin: target.plugin,
|
|
@@ -50392,7 +50550,7 @@ async function composePlan(fs, input) {
|
|
|
50392
50550
|
tier: target.tier ?? 3,
|
|
50393
50551
|
window: input.window,
|
|
50394
50552
|
mode,
|
|
50395
|
-
required: target.required ?? false,
|
|
50553
|
+
required: (target.required ?? false) || explicitlySelected,
|
|
50396
50554
|
approval: mode === "live" ? "required" : "none",
|
|
50397
50555
|
status: "planned",
|
|
50398
50556
|
...target.transport !== undefined ? { transport: target.transport } : {},
|
|
@@ -50747,13 +50905,15 @@ async function runPublishMatrixSettle(args, deps = {}) {
|
|
|
50747
50905
|
unresolved.push({ id: row.id, reason: `prepared as ${receipt.mode ?? "unknown"}, not published live` });
|
|
50748
50906
|
}
|
|
50749
50907
|
}
|
|
50908
|
+
const coverPatch = await readCoverPatchDiagnostic(fs, publishDir);
|
|
50750
50909
|
const settlement = {
|
|
50751
50910
|
schemaVersion: 1,
|
|
50752
50911
|
window: parsedWindow.data,
|
|
50753
50912
|
runDate: plan.runDate ?? "",
|
|
50754
50913
|
parentRunId,
|
|
50755
50914
|
marked: unresolved.length === 0,
|
|
50756
|
-
unresolved
|
|
50915
|
+
unresolved,
|
|
50916
|
+
...coverPatch !== undefined ? { coverPatch } : {}
|
|
50757
50917
|
};
|
|
50758
50918
|
await fs.ensureDir(publishDir);
|
|
50759
50919
|
const settlementPath = join10(publishDir, `settlement.${parsedWindow.data}.json`);
|
|
@@ -50954,6 +51114,27 @@ async function readOfficialAccountArticleIds(fs, publishDir, plan) {
|
|
|
50954
51114
|
}
|
|
50955
51115
|
return ids;
|
|
50956
51116
|
}
|
|
51117
|
+
async function readCoverPatchDiagnostic(fs, publishDir) {
|
|
51118
|
+
const path = join10(publishDir, "patch-surfdash.result.json");
|
|
51119
|
+
if (!await fs.exists(path))
|
|
51120
|
+
return;
|
|
51121
|
+
try {
|
|
51122
|
+
const result = JSON.parse(await fs.readFile(path));
|
|
51123
|
+
const coverPatch = result.metadata?.coverPatch;
|
|
51124
|
+
if (coverPatch === null || typeof coverPatch !== "object" || Array.isArray(coverPatch))
|
|
51125
|
+
return;
|
|
51126
|
+
const entry = coverPatch;
|
|
51127
|
+
if (entry.status !== "applied" && entry.status !== "skipped")
|
|
51128
|
+
return;
|
|
51129
|
+
return {
|
|
51130
|
+
status: entry.status,
|
|
51131
|
+
reason: typeof entry.reason === "string" ? entry.reason : "",
|
|
51132
|
+
pageUrl: typeof entry.pageUrl === "string" ? entry.pageUrl : ""
|
|
51133
|
+
};
|
|
51134
|
+
} catch {
|
|
51135
|
+
return;
|
|
51136
|
+
}
|
|
51137
|
+
}
|
|
50957
51138
|
var DISPATCH_MODE_RANK = { off: 0, dummy: 1, draft: 2, live: 3 };
|
|
50958
51139
|
function ledgerSuppresses(row, entry, hasReceipt) {
|
|
50959
51140
|
if (entry === undefined || entry.state !== "dispatched")
|
|
@@ -51164,28 +51345,38 @@ async function sendPublishMatrix(args, deps = {}) {
|
|
|
51164
51345
|
});
|
|
51165
51346
|
}
|
|
51166
51347
|
}
|
|
51167
|
-
|
|
51168
|
-
|
|
51169
|
-
|
|
51170
|
-
|
|
51171
|
-
|
|
51172
|
-
|
|
51348
|
+
const substitution = substituteLinkPlaceholders(raw, links);
|
|
51349
|
+
let resolved = substitution.text;
|
|
51350
|
+
for (const fallback of substitution.fallbacks) {
|
|
51351
|
+
await appendEvent(fs, publishDir, {
|
|
51352
|
+
event: "link-fallback",
|
|
51353
|
+
window: plan.window,
|
|
51354
|
+
id: row.key,
|
|
51355
|
+
placeholder: fallback.placeholder,
|
|
51356
|
+
source: fallback.source,
|
|
51357
|
+
url: fallback.url,
|
|
51358
|
+
mode: row.mode
|
|
51359
|
+
});
|
|
51360
|
+
echo(`publish-matrix-send: ${row.key} carries the ${fallback.source} link in place of ${fallback.placeholder} (no succeeded receipt for it)`);
|
|
51173
51361
|
}
|
|
51174
51362
|
if (cardLink !== undefined) {
|
|
51175
51363
|
const carried = carryOfficialAccountLink(resolved, cardLink);
|
|
51176
51364
|
resolved = carried.text;
|
|
51177
51365
|
echo(`publish-matrix-send: ${row.key} carries the confirmed Official Account link (${carried.placement})`);
|
|
51178
51366
|
}
|
|
51179
|
-
|
|
51180
|
-
|
|
51181
|
-
const draftMayDropLink =
|
|
51182
|
-
|
|
51183
|
-
|
|
51367
|
+
let stillUnresolved = LINK_SOURCES.filter((source) => resolved.includes(source.placeholder));
|
|
51368
|
+
if (stillUnresolved.length > 0 && row.mode === "draft") {
|
|
51369
|
+
const draftMayDropLink = stillUnresolved.every((source) => source.placeholder === "{{article_url}}");
|
|
51370
|
+
const dropped = draftMayDropLink ? resolved.replace(/"originalUrl"\s*:\s*"\{\{article_url\}\}"/, '"originalUrl": ""') : resolved;
|
|
51371
|
+
if (dropped !== resolved) {
|
|
51372
|
+
resolved = dropped;
|
|
51373
|
+
stillUnresolved = LINK_SOURCES.filter((source) => resolved.includes(source.placeholder));
|
|
51184
51374
|
echo(`publish-matrix-send: ${row.key} is a draft \u2014 dropped the unresolved {{article_url}} cross-link`);
|
|
51185
51375
|
}
|
|
51186
51376
|
}
|
|
51187
|
-
if (
|
|
51188
|
-
|
|
51377
|
+
if (stillUnresolved.length > 0) {
|
|
51378
|
+
const namable = stillUnresolved.find((source) => source.fallback !== undefined);
|
|
51379
|
+
return { error: namable === undefined ? "unresolved-link" : `${namable.receipt}-link-missing` };
|
|
51189
51380
|
}
|
|
51190
51381
|
const resolvedPath = join10(workDir, "4-publish", "payloads", `content.${row.key}.resolved.json`);
|
|
51191
51382
|
await fs.writeFile(resolvedPath, resolved);
|
|
@@ -53413,7 +53604,10 @@ function appendLadderReport(body, workDir) {
|
|
|
53413
53604
|
const section = [
|
|
53414
53605
|
"## Pool ladder",
|
|
53415
53606
|
"",
|
|
53416
|
-
`- Driving measure: ${String(ladder.
|
|
53607
|
+
`- Driving measure: ${String(ladder.spokenPerPoolChar ?? "unknown")} spoken chars per pool char (keep rate ${String(ladder.keepRate ?? "unknown")} \xD7 kept ratio ${String(ladder.keptRatio ?? "unknown")})`,
|
|
53608
|
+
`- Keep rate: ${String(ladder.keepRate ?? "unknown")} (${String(ladder.keepRateSource ?? "unknown source")})`,
|
|
53609
|
+
`- Kept ratio: ${String(ladder.keptRatio ?? "unknown")} (${String(ladder.keptRatioSource ?? "unknown source")})`,
|
|
53610
|
+
`- Recorded pool ratio: ${String(ladder.ratioUsed ?? "unknown")} (${String(ladder.ratioSource ?? "unknown source")})`,
|
|
53417
53611
|
`- Chosen window: ${String(ladder.chosen ?? "unknown")}`,
|
|
53418
53612
|
"",
|
|
53419
53613
|
"| Window | Items | Characters | Estimated minutes | Clears floor |",
|
|
@@ -53659,7 +53853,8 @@ function bindAdapterSession(candidate) {
|
|
|
53659
53853
|
url: request.url,
|
|
53660
53854
|
extraEnv: request.env,
|
|
53661
53855
|
pluginKind: record.kind,
|
|
53662
|
-
pluginName: record.name
|
|
53856
|
+
pluginName: record.name,
|
|
53857
|
+
...request.signal === undefined ? {} : { signal: request.signal }
|
|
53663
53858
|
});
|
|
53664
53859
|
}
|
|
53665
53860
|
};
|
|
@@ -56676,10 +56871,14 @@ async function validatePreset(fs, presetName, variants) {
|
|
|
56676
56871
|
}
|
|
56677
56872
|
async function runFreezeStage(input, fs) {
|
|
56678
56873
|
const bundlePath = join28(input.workDir, PUBLISH_DIR, "bundle.json");
|
|
56679
|
-
const
|
|
56680
|
-
|
|
56681
|
-
|
|
56682
|
-
|
|
56874
|
+
const request = await readJson3(fs, join28(input.workDir, REQUEST_FILE));
|
|
56875
|
+
const seededFromFile = typeof request?.from === "string" && request.from.trim() !== "";
|
|
56876
|
+
if (!seededFromFile) {
|
|
56877
|
+
const completed = await deps.runItc(["itc-author-complete", input.workDir, input.runId]);
|
|
56878
|
+
if (completed !== 0) {
|
|
56879
|
+
echoError(`kk generate-bundle: itc-author-complete failed (exit ${completed}) for ${input.workDir}`);
|
|
56880
|
+
return 1;
|
|
56881
|
+
}
|
|
56683
56882
|
}
|
|
56684
56883
|
const content = await readJson3(fs, join28(input.workDir, PUBLISH_DIR, CONTENT_FILE));
|
|
56685
56884
|
if (content === null) {
|
|
@@ -56691,13 +56890,23 @@ async function runFreezeStage(input, fs) {
|
|
|
56691
56890
|
echoError(`kk generate-bundle: ${join28(input.workDir, PUBLISH_DIR, CONTENT_FILE)} has no title; the draft's H1 is the bundle title`);
|
|
56692
56891
|
return 1;
|
|
56693
56892
|
}
|
|
56694
|
-
const sourceLocale = typeof content.sourceLocale === "string" ? content.sourceLocale : "en";
|
|
56893
|
+
const sourceLocale = typeof content.sourceLocale === "string" ? content.sourceLocale : typeof request?.locale === "string" ? request.locale : "en";
|
|
56695
56894
|
const variants = {};
|
|
56696
56895
|
for (const [key, variant] of Object.entries(generationVariants(content))) {
|
|
56697
56896
|
if (!variant.adapt)
|
|
56698
56897
|
continue;
|
|
56699
56898
|
variants[key] = await variantEntry(fs, input.workDir, variant.file);
|
|
56700
56899
|
}
|
|
56900
|
+
if (isObject3(request?.variants)) {
|
|
56901
|
+
for (const name of Object.keys(request.variants)) {
|
|
56902
|
+
if (variants[name] !== undefined)
|
|
56903
|
+
continue;
|
|
56904
|
+
const file = `content.${name}.json`;
|
|
56905
|
+
if (await fs.exists(join28(input.workDir, PUBLISH_DIR, file))) {
|
|
56906
|
+
variants[name] = await variantEntry(fs, input.workDir, file);
|
|
56907
|
+
}
|
|
56908
|
+
}
|
|
56909
|
+
}
|
|
56701
56910
|
const source = await variantEntry(fs, input.workDir, CONTENT_FILE);
|
|
56702
56911
|
variants.article = source;
|
|
56703
56912
|
variants[`${sourceLocale}-article`] = source;
|
|
@@ -57261,7 +57470,20 @@ async function countFiles(ctx, dir, suffix) {
|
|
|
57261
57470
|
const path = join29(ctx.workDir, dir);
|
|
57262
57471
|
if (!await ctx.fs.exists(path))
|
|
57263
57472
|
return 0;
|
|
57264
|
-
|
|
57473
|
+
let count = 0;
|
|
57474
|
+
for (const entry of await ctx.fs.readDir(path)) {
|
|
57475
|
+
if (entry.endsWith(suffix)) {
|
|
57476
|
+
count += 1;
|
|
57477
|
+
continue;
|
|
57478
|
+
}
|
|
57479
|
+
const nested = join29(path, entry);
|
|
57480
|
+
if (!await ctx.fs.exists(nested))
|
|
57481
|
+
continue;
|
|
57482
|
+
try {
|
|
57483
|
+
count += (await ctx.fs.readDir(nested)).filter((child) => child.endsWith(suffix)).length;
|
|
57484
|
+
} catch {}
|
|
57485
|
+
}
|
|
57486
|
+
return count;
|
|
57265
57487
|
}
|
|
57266
57488
|
var newsVariantsStage = (ctx) => ctx.noun === "news" && ctx.bundleStage === "variants";
|
|
57267
57489
|
var GENERATE_ROWS = [
|
|
@@ -57772,7 +57994,7 @@ async function runPreflight(deps, context) {
|
|
|
57772
57994
|
...await diffDirs(deps, join30(context.harnessRoot, "plugins", "kk", "scripts"), join30(install, "plugins", "kk", "scripts"))
|
|
57773
57995
|
];
|
|
57774
57996
|
if (diffs.length > 0) {
|
|
57775
|
-
reasons.push(`checkout diverges from installed kk (${install}): ${diffs.join("; ")}`);
|
|
57997
|
+
reasons.push(`checkout diverges from installed kk (${install}): ${diffs.join("; ")} \u2014 refresh the stale side: \`bun scripts/bundle-plugins.ts\` in a checkout, or reinstall the package when the install is behind`);
|
|
57776
57998
|
}
|
|
57777
57999
|
}
|
|
57778
58000
|
const target = context.agent === "inline" ? "scribe" : context.agent;
|
|
@@ -58177,7 +58399,8 @@ function validateLiveTokens(preset, window, tokens, presetName) {
|
|
|
58177
58399
|
fail2(5, "kk.content.publish", `cannot validate --live-channels: preset '${presetName}' was not found`);
|
|
58178
58400
|
}
|
|
58179
58401
|
const inWindow = (preset.targets ?? []).filter((target) => (target.window ?? "after-generate") === window);
|
|
58180
|
-
const
|
|
58402
|
+
const computedId = (target) => target.id ?? (target.plugin && target.operation ? `${target.plugin}.${target.operation.trim().replace(/[\s/]+/g, "-")}` : target.plugin);
|
|
58403
|
+
const refused = tokens.filter((token) => !inWindow.some((target) => (target.plugin === token || target.id === token || computedId(target) === token) && (target.mode ?? "draft") !== "off"));
|
|
58181
58404
|
if (refused.length > 0) {
|
|
58182
58405
|
fail2(5, "kk.content.publish", `live token(s) ${refused.join(", ")} have no active row in window '${window}' of preset '${presetName}'`);
|
|
58183
58406
|
}
|
|
@@ -58187,6 +58410,22 @@ async function readPreset(presetName, fs) {
|
|
|
58187
58410
|
const path = join31(root, "plugins", "kk", "publish-presets", `${presetName}.json`);
|
|
58188
58411
|
return await readJson4(fs, path);
|
|
58189
58412
|
}
|
|
58413
|
+
var INLINE_FIGURE_OPERATION = "\u6587\u7AE0";
|
|
58414
|
+
var INLINE_FIGURE_VARIANT = "article";
|
|
58415
|
+
function targetSelectedBy(target, tokens) {
|
|
58416
|
+
return tokens.some((token) => target.plugin === token || target.id === token || target.plugin !== undefined && target.variant !== undefined && `${target.plugin}/${target.variant}` === token);
|
|
58417
|
+
}
|
|
58418
|
+
function inlineFigureRefusal(presetName, targets, channels) {
|
|
58419
|
+
const rows = targets.filter((target) => target.plugin === "wechatmp-pub" && target.operation === INLINE_FIGURE_OPERATION && target.variant === INLINE_FIGURE_VARIANT);
|
|
58420
|
+
const enabled = rows.filter((target) => target.mode !== undefined && target.mode !== "off");
|
|
58421
|
+
if (enabled.length === 0) {
|
|
58422
|
+
return rows.length === 0 ? `--inline-illustrations: preset '${presetName}' declares no wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target to carry the figures` : `--inline-illustrations: no enabled wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target in preset '${presetName}'`;
|
|
58423
|
+
}
|
|
58424
|
+
if (channels !== undefined && channels.length > 0 && !enabled.some((target) => targetSelectedBy(target, channels))) {
|
|
58425
|
+
return `--inline-illustrations: --channels (${channels.join(", ")}) excludes the wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target, so no article would carry the figures`;
|
|
58426
|
+
}
|
|
58427
|
+
return null;
|
|
58428
|
+
}
|
|
58190
58429
|
async function generateAction(noun, defaultType, options) {
|
|
58191
58430
|
const fs = createNodeFileSystem();
|
|
58192
58431
|
const type = options.type ?? defaultType;
|
|
@@ -58206,7 +58445,21 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58206
58445
|
const workflowPath = await resolveWorkflowPath(resolved.workflow, config, fs);
|
|
58207
58446
|
const channels = channelList(options.channels);
|
|
58208
58447
|
const liveChannels = channelList(options.liveChannels);
|
|
58448
|
+
const packageRoot = await resolvePackageRoot(fs);
|
|
58209
58449
|
const vars = { skill_dir: resolved.skillDir, preset: resolved.publish_preset };
|
|
58450
|
+
if (type === "news")
|
|
58451
|
+
vars.visual_skill_root = join31(packageRoot, "plugins", "kk", "skills");
|
|
58452
|
+
if (options.inlineIllustrations === true) {
|
|
58453
|
+
if (type !== "news") {
|
|
58454
|
+
fail2(2, "kk.content.generate", `'--inline-illustrations' is news-only: the '${type}' workflow declares no inline-figure stage`);
|
|
58455
|
+
}
|
|
58456
|
+
const preset = await readPreset(resolved.publish_preset, fs);
|
|
58457
|
+
const selected = channels === undefined ? undefined : channels.split(",").map((token) => token.trim());
|
|
58458
|
+
const refusal = inlineFigureRefusal(resolved.publish_preset, preset?.targets ?? [], selected);
|
|
58459
|
+
if (refusal !== null)
|
|
58460
|
+
fail2(5, "kk.content.generate", refusal);
|
|
58461
|
+
vars.inline_illustrations = "true";
|
|
58462
|
+
}
|
|
58210
58463
|
if (options.skipReview === true)
|
|
58211
58464
|
vars.skip_review = "true";
|
|
58212
58465
|
if (options.auto === true) {
|
|
@@ -58215,6 +58468,16 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58215
58468
|
}
|
|
58216
58469
|
vars.auto = "true";
|
|
58217
58470
|
}
|
|
58471
|
+
if (options.adaptOnly === true) {
|
|
58472
|
+
if (type !== "itc") {
|
|
58473
|
+
fail2(2, "kk.content.generate", `--adapt-only is article-only: the '${type}' workflow declares no 'adapt_only' var`);
|
|
58474
|
+
}
|
|
58475
|
+
const draftPath = join31(run.workDir, "3-draft-draft-article.md");
|
|
58476
|
+
if (!await fs.exists(draftPath)) {
|
|
58477
|
+
fail2(5, "kk.content.generate", `--adapt-only requires an existing draft at ${draftPath}; seed with \`kk article new --from <file.md>\` first`);
|
|
58478
|
+
}
|
|
58479
|
+
vars.adapt_only = "true";
|
|
58480
|
+
}
|
|
58218
58481
|
const receipt = await launchWorkflow({
|
|
58219
58482
|
type,
|
|
58220
58483
|
workflow: resolved.workflow,
|
|
@@ -58222,7 +58485,7 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58222
58485
|
run: run.run,
|
|
58223
58486
|
workDir: run.workDir,
|
|
58224
58487
|
worksDir,
|
|
58225
|
-
harnessRoot:
|
|
58488
|
+
harnessRoot: packageRoot,
|
|
58226
58489
|
identityVar: type === "news" ? "run_date" : "slug",
|
|
58227
58490
|
vars,
|
|
58228
58491
|
writerSkill: { dir: resolved.skillDir, sha256: resolved.skillSha256 },
|
|
@@ -58315,6 +58578,24 @@ async function publishRun(settings) {
|
|
|
58315
58578
|
}
|
|
58316
58579
|
}
|
|
58317
58580
|
}
|
|
58581
|
+
if (bundle === null && type !== "news" && settings.dryRun !== true) {
|
|
58582
|
+
const request = await readJson4(fs, join31(run.workDir, "request.json"));
|
|
58583
|
+
if (typeof request?.from === "string" && request.from.trim() !== "" && await fs.exists(join31(publishDir, "content.json"))) {
|
|
58584
|
+
const frozen = await runArticleBundle({
|
|
58585
|
+
workDir: run.workDir,
|
|
58586
|
+
type,
|
|
58587
|
+
runId: `kk-content-${run.run}`,
|
|
58588
|
+
preset: presetName,
|
|
58589
|
+
maxRevisions: DEFAULT_MAX_REVISIONS,
|
|
58590
|
+
step: "",
|
|
58591
|
+
bundleStage: "freeze"
|
|
58592
|
+
}, fs);
|
|
58593
|
+
if (frozen.code !== 0) {
|
|
58594
|
+
fail2(5, "kk.content.publish", `failed to freeze seeded article bundle in ${run.workDir}`);
|
|
58595
|
+
}
|
|
58596
|
+
bundle = await readJson4(fs, await resolveBundlePath(fs, run.workDir));
|
|
58597
|
+
}
|
|
58598
|
+
}
|
|
58318
58599
|
if (bundle === null && settings.dryRun !== true) {
|
|
58319
58600
|
fail2(5, "kk.content.publish", `no publishable bundle at ${bundlePath}`);
|
|
58320
58601
|
}
|
|
@@ -58355,6 +58636,7 @@ async function publishRun(settings) {
|
|
|
58355
58636
|
receiptPath,
|
|
58356
58637
|
...settings.agent === undefined ? {} : { agent: settings.agent },
|
|
58357
58638
|
...settings.timeoutMs === undefined ? {} : { timeoutMs: settings.timeoutMs },
|
|
58639
|
+
...settings.allowDirty === undefined ? {} : { allowDirty: settings.allowDirty },
|
|
58358
58640
|
...settings.dryRun === undefined ? {} : { dryRun: settings.dryRun }
|
|
58359
58641
|
});
|
|
58360
58642
|
if (receipt.dryRun === undefined || planned.length === 0)
|
|
@@ -58418,6 +58700,7 @@ async function publishAction(noun, defaultType, options) {
|
|
|
58418
58700
|
...options.retry === undefined ? {} : { retry: options.retry },
|
|
58419
58701
|
...options.agent === undefined ? {} : { agent: options.agent },
|
|
58420
58702
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
58703
|
+
...options.allowDirty === undefined ? {} : { allowDirty: options.allowDirty },
|
|
58421
58704
|
...options.dryRun === undefined ? {} : { dryRun: options.dryRun }
|
|
58422
58705
|
});
|
|
58423
58706
|
const code = reportReceipt(receipt);
|
|
@@ -58430,7 +58713,7 @@ function configureGenerate(command, noun, defaultType) {
|
|
|
58430
58713
|
} else {
|
|
58431
58714
|
command.option("--run-date <YYYYMMDD>", "news run date");
|
|
58432
58715
|
}
|
|
58433
|
-
command.option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--skip-review", "skip the workflow review pause").option("--auto", "skip the human gates (article only)").option("--publish", "launch publish for window after-generate once generation is green").option("--channels <a,b>", "publish plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--allow-dirty", "launch even when harness paths are dirty").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => generateAction(noun, defaultType, options));
|
|
58716
|
+
command.option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--skip-review", "skip the workflow review pause").option("--auto", "skip the human gates (article only)").option("--inline-illustrations", "render figures inline in the WeChat article (news only)").option("--adapt-only", "skip authoring and run adapt + freeze over an existing draft (article only)").option("--publish", "launch publish for window after-generate once generation is green").option("--channels <a,b>", "publish plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--allow-dirty", "launch even when harness paths are dirty").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => generateAction(noun, defaultType, options));
|
|
58434
58717
|
}
|
|
58435
58718
|
function configurePublish(command, noun, defaultType) {
|
|
58436
58719
|
if (noun === "article") {
|
|
@@ -58438,7 +58721,7 @@ function configurePublish(command, noun, defaultType) {
|
|
|
58438
58721
|
} else {
|
|
58439
58722
|
command.option("--run-date <YYYYMMDD>", "news run date");
|
|
58440
58723
|
}
|
|
58441
|
-
command.option("--work-dir <dir>", "explicit run directory").option("--window <window>", `publish window (${PUBLISH_WINDOWS2.join("|")})`, "after-generate").option("--preset <name>", "publish preset").option("--channels <a,b>", "plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--live-confirm", "pause for live approval before sending").option("--dummy", "plan and validate every row without dispatching").option("--retry", "retry the rows a previous window left failed").option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--unattended", "scheduled posture: generate once when the bundle is missing").option("--yes", "consent to that one generate without --unattended").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => publishAction(noun, defaultType, options));
|
|
58724
|
+
command.option("--work-dir <dir>", "explicit run directory").option("--window <window>", `publish window (${PUBLISH_WINDOWS2.join("|")})`, "after-generate").option("--preset <name>", "publish preset").option("--channels <a,b>", "plan rows or plugins to include").option("--live-channels <a,b>", "promote enabled rows to live; off rows stay disabled").option("--live-confirm", "pause for live approval before sending").option("--dummy", "plan and validate every row without dispatching").option("--retry", "retry the rows a previous window left failed").option("--agent <executor>", "executor the workflow dispatches to (default: inline)").option("--unattended", "scheduled posture: generate once when the bundle is missing").option("--yes", "consent to that one generate without --unattended").option("--timeout-ms <n>", "deadline for the workflow child in milliseconds").option("--allow-dirty", "launch even when harness paths are dirty").option("--dry-run", "run the preflight and print the planned launch without taking the lock").action((options) => publishAction(noun, defaultType, options));
|
|
58442
58725
|
}
|
|
58443
58726
|
function registerContentLaunchVerbs(group, noun, defaultType) {
|
|
58444
58727
|
configureGenerate(group.command("generate").description("launch the generation workflow for a run"), noun, defaultType);
|
|
@@ -58485,6 +58768,13 @@ function commandFailure(command, code, message) {
|
|
|
58485
58768
|
function isOutcomeRows(value) {
|
|
58486
58769
|
return typeof value === "object" && value !== null && Array.isArray(value.rows);
|
|
58487
58770
|
}
|
|
58771
|
+
async function everyPlannedRealRowFailed(fs, workDir, window, rows) {
|
|
58772
|
+
const plan = await readJson5(fs, join32(workDir, "4-publish", `plan.${window}.json`));
|
|
58773
|
+
const planRows = Array.isArray(plan?.rows) ? plan.rows : [];
|
|
58774
|
+
const rehearsalIds = new Set(planRows.filter((row) => row.mode === "dummy").map((row) => String(row.id)));
|
|
58775
|
+
const real = rows.filter((row) => !rehearsalIds.has(String(row.id)) && row.dummy !== true);
|
|
58776
|
+
return real.length > 0 && real.every((row) => row.status !== "succeeded");
|
|
58777
|
+
}
|
|
58488
58778
|
function quietStdout2(action) {
|
|
58489
58779
|
const restore = setDefaultOutputTargets({ stdout: { write() {} } });
|
|
58490
58780
|
return action().finally(restore);
|
|
@@ -58544,6 +58834,9 @@ async function planAction(type, options) {
|
|
|
58544
58834
|
const command = "kk.content.publish-plan";
|
|
58545
58835
|
const fs = createNodeFileSystem();
|
|
58546
58836
|
const context = await loadContext(type, options, command, fs);
|
|
58837
|
+
const stalePlanPath = join32(context.workDir, "4-publish", `plan.${context.window}.json`);
|
|
58838
|
+
if (await fs.exists(stalePlanPath))
|
|
58839
|
+
await fs.deleteFile(stalePlanPath);
|
|
58547
58840
|
const applied = (() => {
|
|
58548
58841
|
try {
|
|
58549
58842
|
validatePublishChannelTokens(context.preset, [
|
|
@@ -58718,7 +59011,7 @@ async function settleAction(type, options) {
|
|
|
58718
59011
|
}
|
|
58719
59012
|
const outcomePath = join32(context.workDir, "4-publish", `outcome.${context.window}.json`);
|
|
58720
59013
|
const outcome = PublishOutcomeSchema.parse.bind(PublishOutcomeSchema)(parseJson7(await fs.readFile(outcomePath)));
|
|
58721
|
-
const failedRequired = outcome.rows.some((row) => row.required && !row.dummy && row.status !== "succeeded");
|
|
59014
|
+
const failedRequired = outcome.rows.some((row) => row.required && !row.dummy && row.status !== "succeeded") || await everyPlannedRealRowFailed(fs, context.workDir, context.window, outcome.rows);
|
|
58722
59015
|
consoleOutput.write(JSON.stringify(outcome));
|
|
58723
59016
|
if (settleCode !== 0 || failedRequired)
|
|
58724
59017
|
throw new CommanderError(1, command, "publish-settle: required targets failed");
|
|
@@ -58777,7 +59070,7 @@ async function reportAction(type, options) {
|
|
|
58777
59070
|
} catch {
|
|
58778
59071
|
return commandFailure(command, 1, `publish-report: ${outcomePath} is unreadable or malformed`);
|
|
58779
59072
|
}
|
|
58780
|
-
const failed = rows.some((row) => row.required === true && row.dummy !== true && row.status !== "succeeded");
|
|
59073
|
+
const failed = rows.some((row) => row.required === true && row.dummy !== true && row.status !== "succeeded") || await everyPlannedRealRowFailed(fs, context.workDir, context.window, rows);
|
|
58781
59074
|
if (failed) {
|
|
58782
59075
|
return commandFailure(command, 1, `publish-report: required targets failed \u2014 see outcome.${context.window}.json and the page`);
|
|
58783
59076
|
}
|
|
@@ -58935,28 +59228,47 @@ function splitMarkdown(markdown, fallbackTitle, titleOverride) {
|
|
|
58935
59228
|
`).trim();
|
|
58936
59229
|
return { title, body };
|
|
58937
59230
|
}
|
|
58938
|
-
async function writeSeededContent(fs, workDir, locale, markdown, options) {
|
|
59231
|
+
async function writeSeededContent(fs, workDir, locale, markdown, options, coverDest, variants) {
|
|
58939
59232
|
const contentDir = join33(workDir, "content", locale);
|
|
58940
59233
|
await fs.ensureDir(contentDir);
|
|
58941
59234
|
await fs.writeFile(join33(contentDir, "article.md"), markdown);
|
|
59235
|
+
await fs.writeFile(join33(workDir, "3-draft-draft-article.md"), markdown);
|
|
58942
59236
|
const fallbackTitle = options.slug?.replaceAll("-", " ") ?? "article";
|
|
58943
59237
|
const article = splitMarkdown(markdown, fallbackTitle, options.title);
|
|
58944
59238
|
if (article.body === "")
|
|
58945
59239
|
fail3(2, "kk.content.new", `source file is empty: ${options.from ?? "(source)"}`);
|
|
59240
|
+
const metadata = {
|
|
59241
|
+
published: false,
|
|
59242
|
+
...parseTags(options.tags) !== undefined ? { tags: parseTags(options.tags) } : {},
|
|
59243
|
+
...options.description !== undefined ? { description: options.description } : {},
|
|
59244
|
+
...coverDest !== undefined ? { coverImage: coverDest } : {}
|
|
59245
|
+
};
|
|
58946
59246
|
const content = {
|
|
58947
59247
|
title: article.title,
|
|
58948
59248
|
format: "markdown",
|
|
58949
59249
|
body: article.body,
|
|
58950
|
-
metadata
|
|
58951
|
-
published: false,
|
|
58952
|
-
...parseTags(options.tags) !== undefined ? { tags: parseTags(options.tags) } : {},
|
|
58953
|
-
...options.description !== undefined ? { description: options.description } : {}
|
|
58954
|
-
}
|
|
59250
|
+
metadata
|
|
58955
59251
|
};
|
|
58956
59252
|
const publishDir = join33(workDir, "4-publish");
|
|
58957
59253
|
await fs.ensureDir(publishDir);
|
|
58958
59254
|
await fs.writeFile(join33(publishDir, "content.json"), `${JSON.stringify(content, null, 2)}
|
|
58959
59255
|
`);
|
|
59256
|
+
if (variants !== undefined) {
|
|
59257
|
+
for (const [name, sourcePath] of Object.entries(variants)) {
|
|
59258
|
+
const variantMd = await fs.readFile(sourcePath);
|
|
59259
|
+
const split = splitMarkdown(variantMd, article.title);
|
|
59260
|
+
if (split.body === "")
|
|
59261
|
+
fail3(2, "kk.content.new", `variant file is empty: ${sourcePath}`);
|
|
59262
|
+
const variantContent = {
|
|
59263
|
+
title: split.title,
|
|
59264
|
+
format: "markdown",
|
|
59265
|
+
body: split.body,
|
|
59266
|
+
metadata
|
|
59267
|
+
};
|
|
59268
|
+
await fs.writeFile(join33(publishDir, `content.${name}.json`), `${JSON.stringify(variantContent, null, 2)}
|
|
59269
|
+
`);
|
|
59270
|
+
}
|
|
59271
|
+
}
|
|
58960
59272
|
}
|
|
58961
59273
|
async function seedItcPreparation(fs, workDir, run, options, preset) {
|
|
58962
59274
|
const launchPath = join33(workDir, ".content-itc-prepare.json");
|
|
@@ -59031,13 +59343,16 @@ async function newAction(defaultType, options, article) {
|
|
|
59031
59343
|
await fs.ensureDir(run.workDir);
|
|
59032
59344
|
if (article)
|
|
59033
59345
|
await seedItcPreparation(fs, run.workDir, run, options, resolved.publish_preset);
|
|
59034
|
-
|
|
59035
|
-
await writeSeededContent(fs, run.workDir, locale, await fs.readFile(fromPath), options);
|
|
59346
|
+
let coverDest;
|
|
59036
59347
|
if (options.cover !== undefined) {
|
|
59037
59348
|
const coverPath = resolve26(expandHome4(options.cover));
|
|
59038
59349
|
const coverDir = join33(run.workDir, "4-illustrations");
|
|
59039
59350
|
await fs.ensureDir(coverDir);
|
|
59040
|
-
|
|
59351
|
+
coverDest = join33(coverDir, `cover${extname(coverPath) || ".png"}`);
|
|
59352
|
+
await fs.copy(coverPath, coverDest);
|
|
59353
|
+
}
|
|
59354
|
+
if (fromPath !== undefined) {
|
|
59355
|
+
await writeSeededContent(fs, run.workDir, locale, await fs.readFile(fromPath), options, coverDest, variants);
|
|
59041
59356
|
}
|
|
59042
59357
|
const request = requestObject(type, resolved, run, options, locale, variants, run.workDir);
|
|
59043
59358
|
await fs.writeFile(requestPath, `${JSON.stringify(request, null, 2)}
|
|
@@ -59057,6 +59372,13 @@ async function readJson6(fs, path) {
|
|
|
59057
59372
|
return null;
|
|
59058
59373
|
}
|
|
59059
59374
|
}
|
|
59375
|
+
function variantCount(variants) {
|
|
59376
|
+
if (Array.isArray(variants))
|
|
59377
|
+
return variants.length;
|
|
59378
|
+
if (isObject7(variants))
|
|
59379
|
+
return Object.keys(variants).length;
|
|
59380
|
+
return null;
|
|
59381
|
+
}
|
|
59060
59382
|
async function statusPayload(fs, workDir, type, selectedWindow) {
|
|
59061
59383
|
const receipt = await readJson6(fs, join33(workDir, "schedule-receipt.json"));
|
|
59062
59384
|
const generate = receipt === null ? null : {
|
|
@@ -59065,11 +59387,14 @@ async function statusPayload(fs, workDir, type, selectedWindow) {
|
|
|
59065
59387
|
executor: optionalString3(receipt.executor),
|
|
59066
59388
|
checkoutCommit: optionalString3(receipt.checkoutCommit)
|
|
59067
59389
|
};
|
|
59068
|
-
const
|
|
59390
|
+
const bundlePath = await resolveBundlePath(fs, workDir);
|
|
59391
|
+
const bundle = await readJson6(fs, bundlePath);
|
|
59392
|
+
const atRunRoot = bundlePath === join33(workDir, "bundle.json");
|
|
59069
59393
|
const bundleSummary = bundle === null ? null : {
|
|
59070
|
-
frozen: typeof bundle.frozen === "boolean" ? bundle.frozen : null,
|
|
59394
|
+
frozen: typeof bundle.frozen === "boolean" ? bundle.frozen : atRunRoot ? true : null,
|
|
59071
59395
|
runId: optionalString3(bundle.runId),
|
|
59072
|
-
variants: bundle.variants ?? null
|
|
59396
|
+
variants: bundle.variants ?? null,
|
|
59397
|
+
...atRunRoot ? { variantCount: variantCount(bundle.variants) } : {}
|
|
59073
59398
|
};
|
|
59074
59399
|
const windows = {};
|
|
59075
59400
|
const publishDir = join33(workDir, "4-publish");
|
|
@@ -60674,19 +60999,22 @@ var SILENCE_EDGE_TOLERANCE_SECONDS = 0.05;
|
|
|
60674
60999
|
var DEFAULT_SILENCE_NOISE_DB = -50;
|
|
60675
61000
|
var DEFAULT_SILENCE_MIN_SECONDS = 0.5;
|
|
60676
61001
|
var processExecutor = new NodeProcessExecutor;
|
|
60677
|
-
|
|
60678
|
-
|
|
60679
|
-
|
|
60680
|
-
|
|
60681
|
-
|
|
60682
|
-
|
|
60683
|
-
|
|
60684
|
-
|
|
60685
|
-
|
|
60686
|
-
|
|
60687
|
-
|
|
60688
|
-
|
|
60689
|
-
};
|
|
61002
|
+
function createSpawnRunner(executor = processExecutor) {
|
|
61003
|
+
return async (argv) => {
|
|
61004
|
+
const [bin, ...args] = argv;
|
|
61005
|
+
if (bin === undefined) {
|
|
61006
|
+
throw new AudioToolError("ffmpeg", "spawn", "no binary was given to the audio runner", "");
|
|
61007
|
+
}
|
|
61008
|
+
const result = await executor.run({ command: bin, args, label: `audio ${bin}` });
|
|
61009
|
+
if (result.exitCode === null) {
|
|
61010
|
+
const detail = result.stderr.trim();
|
|
61011
|
+
const killed = result.signal === undefined ? "" : ` (killed by ${result.signal})`;
|
|
61012
|
+
throw new AudioToolError(bin, "spawn", `could not be executed${detail === "" ? "" : ` (${detail})`}${killed} \u2014 install ffmpeg or point ffmpegBin/ffprobeBin at it`, "");
|
|
61013
|
+
}
|
|
61014
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
|
|
61015
|
+
};
|
|
61016
|
+
}
|
|
61017
|
+
var spawnRunner = createSpawnRunner();
|
|
60690
61018
|
function ffprobeArgs(path, bin = DEFAULT_FFPROBE_BIN) {
|
|
60691
61019
|
return [bin, "-v", "error", "-print_format", "json", "-show_format", "-show_streams", path];
|
|
60692
61020
|
}
|
|
@@ -64086,6 +64414,7 @@ async function readLabelItems(items, ids) {
|
|
|
64086
64414
|
title: row.title,
|
|
64087
64415
|
body: row.body,
|
|
64088
64416
|
source: row.source,
|
|
64417
|
+
sourceUri: row.canonicalUrl,
|
|
64089
64418
|
contentHash: row.contentHash,
|
|
64090
64419
|
metadata: parseMetadata(row.metadataJson)
|
|
64091
64420
|
});
|
|
@@ -64139,6 +64468,7 @@ async function heuristicAnnotations(fs, scratch, runId, items) {
|
|
|
64139
64468
|
id: item.id,
|
|
64140
64469
|
title: item.title,
|
|
64141
64470
|
body: item.body,
|
|
64471
|
+
...item.sourceUri === null ? {} : { sourceUri: item.sourceUri },
|
|
64142
64472
|
metadata: item.metadata
|
|
64143
64473
|
}));
|
|
64144
64474
|
await fs.writeFile(inputPath, JSON.stringify(docs));
|
|
@@ -66393,6 +66723,10 @@ async function main2(argv = process.argv, options = {}) {
|
|
|
66393
66723
|
};
|
|
66394
66724
|
inheritSettings(program);
|
|
66395
66725
|
const userArgs = argv.slice(2);
|
|
66726
|
+
const isHelpOrVersion = userArgs.length === 0 || userArgs[0] === "help" || ["--help", "-h", "--version", "-V"].some((flag) => userArgs.includes(flag));
|
|
66727
|
+
const previousExitCode = process.exitCode;
|
|
66728
|
+
if (isHelpOrVersion)
|
|
66729
|
+
process.exitCode = 0;
|
|
66396
66730
|
try {
|
|
66397
66731
|
if (userArgs.length === 0) {
|
|
66398
66732
|
program.help();
|
|
@@ -66407,6 +66741,9 @@ async function main2(argv = process.argv, options = {}) {
|
|
|
66407
66741
|
return err.exitCode;
|
|
66408
66742
|
}
|
|
66409
66743
|
throw err;
|
|
66744
|
+
} finally {
|
|
66745
|
+
if (isHelpOrVersion)
|
|
66746
|
+
process.exitCode = previousExitCode;
|
|
66410
66747
|
}
|
|
66411
66748
|
}
|
|
66412
66749
|
|